1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-24 17:28:08 +00:00

Default port set to 80 for server running in the GNS3 VM. Fixes #1737

This commit is contained in:
grossmj 2020-05-05 12:40:50 +09:30
parent 1b008fb516
commit 10645a412b
5 changed files with 30 additions and 19 deletions

View File

@ -205,7 +205,12 @@ class Controller:
# load GNS3 VM settings # load GNS3 VM settings
if "gns3vm" in controller_settings: if "gns3vm" in controller_settings:
self.gns3vm.settings = controller_settings["gns3vm"] gns3_vm_settings = controller_settings["gns3vm"]
if "port" not in gns3_vm_settings:
# port setting was added in version 2.2.8
# the default port was 3080 before this
gns3_vm_settings["port"] = 3080
self.gns3vm.settings = gns3_vm_settings
# load the IOU license settings # load the IOU license settings
if "iou_license" in controller_settings: if "iou_license" in controller_settings:

View File

@ -39,7 +39,7 @@ class GNS3VM:
Proxy between the controller and the GNS3 VM engine Proxy between the controller and the GNS3 VM engine
""" """
def __init__(self, controller, settings={}): def __init__(self, controller):
self._controller = controller self._controller = controller
# Keep instance of the loaded engines # Keep instance of the loaded engines
self._engines = {} self._engines = {}
@ -50,9 +50,9 @@ class GNS3VM:
"enable": False, "enable": False,
"engine": "vmware", "engine": "vmware",
"ram": 2048, "ram": 2048,
"vcpus": 1 "vcpus": 1,
"port": 80,
} }
self.settings = settings
def engine_list(self): def engine_list(self):
""" """
@ -72,10 +72,11 @@ class GNS3VM:
else: else:
vmware_info["name"] = "VMware Workstation / Player (recommended)" vmware_info["name"] = "VMware Workstation / Player (recommended)"
download_url = "https://github.com/GNS3/gns3-gui/releases/download/v{version}/GNS3.VM.Hyper-V.{version}.zip".format(version=__version__)
hyperv_info = { hyperv_info = {
"engine_id": "hyper-v", "engine_id": "hyper-v",
"name": "Hyper-V", "name": "Hyper-V",
"description": 'Hyper-V support (Windows 10/Server 2016 and above). Nested virtualization must be supported and enabled (Intel processor only)', "description": 'Hyper-V support (Windows 10/Server 2016 and above). Nested virtualization must be supported and enabled (Intel processor only)<br>The GNS3 VM can be <a href="{}">downloaded here</a>'.format(download_url),
"support_when_exit": True, "support_when_exit": True,
"support_headless": False, "support_headless": False,
"support_ram": True "support_ram": True
@ -85,7 +86,7 @@ class GNS3VM:
virtualbox_info = { virtualbox_info = {
"engine_id": "virtualbox", "engine_id": "virtualbox",
"name": "VirtualBox", "name": "VirtualBox",
"description": 'VirtualBox doesn\'t support nested virtualization, this means Qemu based VMs will run extremely slowly.<br>The GNS3 VM can be <a href="{}">downloaded here</a>'.format(download_url), "description": 'VirtualBox support. Nested virtualization for both Intel and AMD processors is supported since version 6.1<br>The GNS3 VM can be <a href="{}">downloaded here</a>'.format(download_url),
"support_when_exit": True, "support_when_exit": True,
"support_headless": True, "support_headless": True,
"support_ram": True "support_ram": True
@ -313,6 +314,7 @@ class GNS3VM:
engine.ram = self._settings["ram"] engine.ram = self._settings["ram"]
engine.vcpus = self._settings["vcpus"] engine.vcpus = self._settings["vcpus"]
engine.headless = self._settings["headless"] engine.headless = self._settings["headless"]
engine.port = self._settings["port"]
compute = await self._controller.add_compute(compute_id="vm", compute = await self._controller.add_compute(compute_id="vm",
name="GNS3 VM is starting ({})".format(engine.vmname), name="GNS3 VM is starting ({})".format(engine.vmname),
host=None, host=None,

View File

@ -15,7 +15,6 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import asyncio
import psutil import psutil
import logging import logging
@ -29,7 +28,7 @@ class BaseGNS3VM:
self._controller = controller self._controller = controller
self._vmname = None self._vmname = None
self._ip_address = None self._ip_address = None
self._port = 3080 self._port = 80 # value not used, will be overwritten
self._headless = False self._headless = False
self._vcpus = 1 self._vcpus = 1
self._ram = 1024 self._ram = 1024

View File

@ -285,13 +285,12 @@ class VirtualBoxGNS3VM(BaseGNS3VM):
log.info("Removing GNS3VM NAT port forwarding rule from interface {}".format(nat_interface_number)) log.info("Removing GNS3VM NAT port forwarding rule from interface {}".format(nat_interface_number))
await self._execute("controlvm", [self._vmname, "natpf{}".format(nat_interface_number), "delete", "GNS3VM"]) await self._execute("controlvm", [self._vmname, "natpf{}".format(nat_interface_number), "delete", "GNS3VM"])
# add a GNS3VM NAT port forwarding rule to redirect 127.0.0.1 with random port to port 3080 in the VM # add a GNS3VM NAT port forwarding rule to redirect 127.0.0.1 with random port to the port in the VM
log.info("Adding GNS3VM NAT port forwarding rule with port {} to interface {}".format(api_port, nat_interface_number)) log.info("Adding GNS3VM NAT port forwarding rule with port {} to interface {}".format(api_port, nat_interface_number))
await self._execute("controlvm", [self._vmname, "natpf{}".format(nat_interface_number), await self._execute("controlvm", [self._vmname, "natpf{}".format(nat_interface_number),
"GNS3VM,tcp,{},{},,3080".format(ip_address, api_port)]) "GNS3VM,tcp,{},{},,{}".format(ip_address, api_port, self.port)])
self.ip_address = await self._get_ip(hostonly_interface_number, api_port) self.ip_address = await self._get_ip(hostonly_interface_number, api_port)
self.port = 3080
log.info("GNS3 VM has been started with IP {}".format(self.ip_address)) log.info("GNS3 VM has been started with IP {}".format(self.ip_address))
self.running = True self.running = True

View File

@ -48,6 +48,12 @@ GNS3VM_SETTINGS_SCHEMA = {
"ram": { "ram": {
"description": "Amount of ram affected to the VM", "description": "Amount of ram affected to the VM",
"type": "integer" "type": "integer"
},
"port": {
"description": "Server port",
"type": "integer",
"minimum": 1,
"maximum": 65535
} }
}, },
"additionalProperties": False "additionalProperties": False