mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Use Dynamips, IOU and VPCS identifiers to correctly load a topology.
This commit is contained in:
1 parent
f9ee38dd55
commit
cb763e0926
18 files changed
+115
-55
No files matched your search
@@ -226,6 +226,7 @@ class VPCS(IModule):
|
||||
|
||||
name = request["name"]
|
||||
console = request.get("console")
|
||||
vpcs_id = request.get("vpcs_id")
|
||||
|
||||
try:
|
||||
|
||||
@@ -236,6 +237,7 @@ class VPCS(IModule):
|
||||
self._vpcs,
|
||||
self._working_dir,
|
||||
self._host,
|
||||
vpcs_id,
|
||||
console,
|
||||
self._console_start_port_range,
|
||||
self._console_end_port_range)
|
||||
|
||||
@@ -26,6 +26,10 @@ VPCS_CREATE_SCHEMA = {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
},
|
||||
"vpcs_id": {
|
||||
"description": "VPCS device instance ID",
|
||||
"type": "integer"
|
||||
},
|
||||
"console": {
|
||||
"description": "console TCP port",
|
||||
"minimum": 1,
|
||||
|
||||
@@ -40,10 +40,11 @@ class VPCSDevice(object):
|
||||
"""
|
||||
VPCS device implementation.
|
||||
|
||||
:param name: name of this VPCS device
|
||||
:param path: path to VPCS executable
|
||||
:param working_dir: path to a working directory
|
||||
:param host: host/address to bind for console and UDP connections
|
||||
:param name: name of this VPCS device
|
||||
:param vpcs_id: VPCS instance ID
|
||||
:param console: TCP console port
|
||||
:param console_start_port_range: TCP console port range start
|
||||
:param console_end_port_range: TCP console port range end
|
||||
@@ -57,22 +58,30 @@ class VPCSDevice(object):
|
||||
path,
|
||||
working_dir,
|
||||
host="127.0.0.1",
|
||||
vpcs_id=None,
|
||||
console=None,
|
||||
console_start_port_range=4512,
|
||||
console_end_port_range=5000):
|
||||
|
||||
# find an instance identifier (1 <= id <= 255)
|
||||
# This 255 limit is due to a restriction on the number of possible
|
||||
# MAC addresses given in VPCS using the -m option
|
||||
self._id = 0
|
||||
for identifier in range(1, 256):
|
||||
if identifier not in self._instances:
|
||||
self._id = identifier
|
||||
self._instances.append(self._id)
|
||||
break
|
||||
|
||||
if self._id == 0:
|
||||
raise VPCSError("Maximum number of VPCS instances reached")
|
||||
if not vpcs_id:
|
||||
# find an instance identifier is none is provided (1 <= id <= 255)
|
||||
# This 255 limit is due to a restriction on the number of possible
|
||||
# MAC addresses given in VPCS using the -m option
|
||||
self._id = 0
|
||||
for identifier in range(1, 256):
|
||||
if identifier not in self._instances:
|
||||
self._id = identifier
|
||||
self._instances.append(self._id)
|
||||
break
|
||||
|
||||
if self._id == 0:
|
||||
raise VPCSError("Maximum number of VPCS instances reached")
|
||||
else:
|
||||
if vpcs_id in self._instances:
|
||||
raise VPCSError("VPCS identifier {} is already used by another VPCS device".format(vpcs_id))
|
||||
self._id = vpcs_id
|
||||
self._instances.append(self._id)
|
||||
|
||||
self._name = name
|
||||
self._path = path
|
||||
@@ -91,8 +100,13 @@ class VPCSDevice(object):
|
||||
self._script_file = ""
|
||||
self._ethernet_adapter = EthernetAdapter() # one adapter with 1 Ethernet interface
|
||||
|
||||
working_dir_path = os.path.join(working_dir, "vpcs", "pc-{}".format(self._id))
|
||||
|
||||
if vpcs_id and not os.path.isdir(working_dir_path):
|
||||
raise VPCSError("Working directory {} doesn't exist".format(working_dir_path))
|
||||
|
||||
# create the device own working directory
|
||||
self.working_dir = os.path.join(working_dir, "vpcs", "{}".format(name))
|
||||
self.working_dir = working_dir_path
|
||||
|
||||
if not self._console:
|
||||
# allocate a console port
|
||||
|
||||
Reference in new issue
Block a user