mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Handle startup-config push using base64
Dynamips working directory management Random port selection for the ZeroMQ server TCP & UDP port allocation in a range with improvements Update Dynamips to 0.2.11 (for the tests) Focus on Python3 development (stop trying to be compatible with Python 2.x) More error/bug catching
This commit is contained in:
1 parent
687d5b75ab
commit
89888ae7bf
25 files changed
+349
-137
No files matched your search
@@ -20,7 +20,6 @@ Interface for Dynamips virtual ATM bridge module ("atm_bridge").
|
||||
http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L622
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from ..dynamips_error import DynamipsError
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ Interface for Dynamips virtual ATM switch module ("atmsw").
|
||||
http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L593
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from ..dynamips_error import DynamipsError
|
||||
|
||||
import logging
|
||||
|
||||
@@ -20,8 +20,6 @@ Interface for Dynamips NIO bridge module ("nio_bridge").
|
||||
http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L538
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
|
||||
class Bridge(object):
|
||||
"""
|
||||
@@ -36,6 +34,7 @@ class Bridge(object):
|
||||
def __init__(self, hypervisor, name):
|
||||
|
||||
self._hypervisor = hypervisor
|
||||
self._allocated_names.append(name)
|
||||
self._name = '"' + name + '"' # put name into quotes to protect spaces
|
||||
self._hypervisor.send("nio_bridge create {}".format(self._name))
|
||||
self._hypervisor.devices.append(self)
|
||||
|
||||
@@ -20,7 +20,6 @@ Interface for Dynamips virtual Cisco 1700 instances module ("c1700")
|
||||
http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L428
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from .router import Router
|
||||
from ..adapters.c1700_mb_1fe import C1700_MB_1FE
|
||||
from ..adapters.c1700_mb_wic1 import C1700_MB_WIC1
|
||||
|
||||
@@ -20,7 +20,6 @@ Interface for Dynamips virtual Cisco 2600 instances module ("c2600")
|
||||
http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L404
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from .router import Router
|
||||
from ..adapters.c2600_mb_1e import C2600_MB_1E
|
||||
from ..adapters.c2600_mb_2e import C2600_MB_2E
|
||||
|
||||
@@ -20,7 +20,6 @@ Interface for Dynamips virtual Cisco 2691 instances module ("c2691")
|
||||
http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L387
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from .router import Router
|
||||
from ..adapters.gt96100_fe import GT96100_FE
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ Interface for Dynamips virtual Cisco 3600 instances module ("c3600")
|
||||
http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L366
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from .router import Router
|
||||
from ..adapters.leopard_2fe import Leopard_2FE
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ Interface for Dynamips virtual Cisco 3725 instances module ("c3725")
|
||||
http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L346
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from .router import Router
|
||||
from ..adapters.gt96100_fe import GT96100_FE
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ Interface for Dynamips virtual Cisco 3745 instances module ("c3745")
|
||||
http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L326
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from .router import Router
|
||||
from ..adapters.gt96100_fe import GT96100_FE
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ Interface for Dynamips virtual Cisco 7200 instances module ("c7200")
|
||||
http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L294
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from ..dynamips_error import DynamipsError
|
||||
from .router import Router
|
||||
from ..adapters.c7200_io_2fe import C7200_IO_2FE
|
||||
|
||||
@@ -20,8 +20,6 @@ Interface for Dynamips virtual Ethernet switch module ("ethsw").
|
||||
http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L558
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from ..dynamips_error import DynamipsError
|
||||
|
||||
import logging
|
||||
|
||||
@@ -20,7 +20,6 @@ Interface for Dynamips virtual Frame-Relay switch module.
|
||||
http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L642
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from ..dynamips_error import DynamipsError
|
||||
|
||||
import logging
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
Hub object that uses the Bridge interface to create a hub with ports.
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from .bridge import Bridge
|
||||
from ..dynamips_error import DynamipsError
|
||||
|
||||
@@ -53,7 +52,6 @@ class Hub(Bridge):
|
||||
break
|
||||
name_id += 1
|
||||
|
||||
self._allocated_names.append(name)
|
||||
self._mapping = {}
|
||||
Bridge.__init__(self, hypervisor, name)
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ Interface for Dynamips virtual Machine module ("vm")
|
||||
http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L77
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from ..dynamips_hypervisor import DynamipsHypervisor
|
||||
from ..dynamips_error import DynamipsError
|
||||
import time
|
||||
import sys
|
||||
@@ -68,6 +68,8 @@ class Router(object):
|
||||
self._name = '"' + name + '"' # put name into quotes to protect spaces
|
||||
self._platform = platform
|
||||
self._image = ""
|
||||
self._startup_config = ""
|
||||
self._private_config = ""
|
||||
self._ram = 128 # Megabytes
|
||||
self._nvram = 128 # Kilobytes
|
||||
self._mmap = True
|
||||
@@ -100,8 +102,12 @@ class Router(object):
|
||||
log.info("router {platform} {name} [id={id}] has been created".format(name=self._name,
|
||||
platform=platform,
|
||||
id=self._id))
|
||||
self.console = self._hypervisor.baseconsole + self._id
|
||||
self.aux = self._hypervisor.baseaux + self._id
|
||||
|
||||
# allocate and check that console and aux ports are unused
|
||||
console_port = (self._hypervisor.baseconsole - 1) + self._id
|
||||
self.console = DynamipsHypervisor.find_unused_port(console_port, console_port + 1, self._hypervisor.host)
|
||||
aux_port = (self._hypervisor.baseaux - 1) + self._id
|
||||
self.aux = DynamipsHypervisor.find_unused_port(aux_port, aux_port + 1, self._hypervisor.host)
|
||||
|
||||
# get the default base MAC address
|
||||
self._mac_addr = self._hypervisor.send("{platform} get_mac_addr {name}".format(platform=self._platform,
|
||||
@@ -130,6 +136,8 @@ class Router(object):
|
||||
|
||||
router_defaults = {"platform": self._platform,
|
||||
"image": self._image,
|
||||
"startup_config": self._startup_config,
|
||||
"private_config": self._private_config,
|
||||
"ram": self._ram,
|
||||
"nvram": self._nvram,
|
||||
"mmap": self._mmap,
|
||||
@@ -249,7 +257,7 @@ class Router(object):
|
||||
Deletes this router.
|
||||
"""
|
||||
|
||||
self._hypervisor.send("vm delete {}".format(self._name))
|
||||
self._hypervisor.send("vm clean_delete {}".format(self._name))
|
||||
self._hypervisor.devices.remove(self)
|
||||
|
||||
log.info("router {name} [id={id}] has been deleted".format(name=self._name, id=self._id))
|
||||
@@ -384,6 +392,46 @@ class Router(object):
|
||||
|
||||
self._image = image
|
||||
|
||||
@property
|
||||
def startup_config(self):
|
||||
"""
|
||||
Returns the startup-config for this router.
|
||||
|
||||
:returns: path to startup-config file
|
||||
"""
|
||||
|
||||
return self._startup_config
|
||||
|
||||
@startup_config.setter
|
||||
def startup_config(self, startup_config):
|
||||
"""
|
||||
Sets the startup-config for this router.
|
||||
|
||||
:param startup_config: path to startup-config file
|
||||
"""
|
||||
|
||||
self._startup_config = startup_config
|
||||
|
||||
@property
|
||||
def private_config(self):
|
||||
"""
|
||||
Returns the private-config for this router.
|
||||
|
||||
:returns: path to private-config file
|
||||
"""
|
||||
|
||||
return self._private_config
|
||||
|
||||
@private_config.setter
|
||||
def private_config(self, private_config):
|
||||
"""
|
||||
Sets the private-config for this router.
|
||||
|
||||
:param private_config: path to private-config file
|
||||
"""
|
||||
|
||||
self._private_config = private_config
|
||||
|
||||
def set_config(self, startup_config, private_config=''):
|
||||
"""
|
||||
Sets the config files that are pushed to startup-config and
|
||||
@@ -394,18 +442,20 @@ class Router(object):
|
||||
(keep existing data when if an empty string)
|
||||
"""
|
||||
|
||||
self._hypervisor.send("vm set_config {name} {startup} {private}".format(name=self._name,
|
||||
startup='"' + startup_config + '"',
|
||||
private='"' + private_config + '"'))
|
||||
if self._startup_config != startup_config or self._private_config != private_config:
|
||||
|
||||
log.info("router {name} [id={id}]: has a startup-config set: {startup}".format(name=self._name,
|
||||
id=self._id,
|
||||
startup='"' + startup_config + '"'))
|
||||
self._hypervisor.send("vm set_config {name} {startup} {private}".format(name=self._name,
|
||||
startup='"' + startup_config + '"',
|
||||
private='"' + private_config + '"'))
|
||||
|
||||
if private_config:
|
||||
log.info("router {name} [id={id}]: has a private-config set: {private}".format(name=self._name,
|
||||
log.info("router {name} [id={id}]: has a startup-config set: {startup}".format(name=self._name,
|
||||
id=self._id,
|
||||
private='"' + private_config + '"'))
|
||||
startup='"' + startup_config + '"'))
|
||||
|
||||
if private_config:
|
||||
log.info("router {name} [id={id}]: has a private-config set: {private}".format(name=self._name,
|
||||
id=self._id,
|
||||
private='"' + private_config + '"'))
|
||||
|
||||
def extract_config(self):
|
||||
"""
|
||||
|
||||
Reference in new issue
Block a user