mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-04 22:41:12 +02:00
PEP 8 clean thanks to auto pep8
This commit is contained in:
1 parent
7f185663d1
commit
f5ed9fbcf1
124 files changed
+340
-210
No files matched your search
@@ -95,6 +95,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Dynamips(IModule):
|
||||
|
||||
"""
|
||||
Dynamips module.
|
||||
|
||||
@@ -140,7 +141,7 @@ class Dynamips(IModule):
|
||||
self._console_host = dynamips_config.get("console_host", kwargs["console_host"])
|
||||
|
||||
if not sys.platform.startswith("win32"):
|
||||
#FIXME: pickle issues Windows
|
||||
# FIXME: pickle issues Windows
|
||||
self._callback = self.add_periodic_callback(self._check_hypervisors, 5000)
|
||||
self._callback.start()
|
||||
|
||||
@@ -323,7 +324,7 @@ class Dynamips(IModule):
|
||||
|
||||
log.debug("received request {}".format(request))
|
||||
|
||||
#TODO: JSON schema validation
|
||||
# TODO: JSON schema validation
|
||||
if not self._hypervisor_manager:
|
||||
|
||||
if "path" in request:
|
||||
@@ -407,7 +408,7 @@ class Dynamips(IModule):
|
||||
rhost = request["nio"]["rhost"]
|
||||
rport = request["nio"]["rport"]
|
||||
try:
|
||||
#TODO: handle IPv6
|
||||
# TODO: handle IPv6
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock:
|
||||
sock.connect((rhost, rport))
|
||||
except OSError as e:
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
|
||||
class Adapter(object):
|
||||
|
||||
"""
|
||||
Base class for adapters.
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ from .adapter import Adapter
|
||||
|
||||
|
||||
class C1700_MB_1FE(Adapter):
|
||||
|
||||
"""
|
||||
Integrated 1 port FastEthernet adapter for c1700 platform.
|
||||
"""
|
||||
|
||||
@@ -19,6 +19,7 @@ from .adapter import Adapter
|
||||
|
||||
|
||||
class C1700_MB_WIC1(Adapter):
|
||||
|
||||
"""
|
||||
Fake module to provide a placeholder for slot 1 interfaces when WICs
|
||||
are inserted into WIC slot 1.
|
||||
|
||||
@@ -19,6 +19,7 @@ from .adapter import Adapter
|
||||
|
||||
|
||||
class C2600_MB_1E(Adapter):
|
||||
|
||||
"""
|
||||
Integrated 1 port Ethernet adapter for the c2600 platform.
|
||||
"""
|
||||
|
||||
@@ -19,6 +19,7 @@ from .adapter import Adapter
|
||||
|
||||
|
||||
class C2600_MB_1FE(Adapter):
|
||||
|
||||
"""
|
||||
Integrated 1 port FastEthernet adapter for the c2600 platform.
|
||||
"""
|
||||
|
||||
@@ -19,6 +19,7 @@ from .adapter import Adapter
|
||||
|
||||
|
||||
class C2600_MB_2E(Adapter):
|
||||
|
||||
"""
|
||||
Integrated 2 port Ethernet adapter for the c2600 platform.
|
||||
"""
|
||||
|
||||
@@ -19,6 +19,7 @@ from .adapter import Adapter
|
||||
|
||||
|
||||
class C2600_MB_2FE(Adapter):
|
||||
|
||||
"""
|
||||
Integrated 2 port FastEthernet adapter for the c2600 platform.
|
||||
"""
|
||||
|
||||
@@ -19,6 +19,7 @@ from .adapter import Adapter
|
||||
|
||||
|
||||
class C7200_IO_2FE(Adapter):
|
||||
|
||||
"""
|
||||
C7200-IO-2FE FastEthernet Input/Ouput controller.
|
||||
"""
|
||||
|
||||
@@ -19,6 +19,7 @@ from .adapter import Adapter
|
||||
|
||||
|
||||
class C7200_IO_FE(Adapter):
|
||||
|
||||
"""
|
||||
C7200-IO-FE FastEthernet Input/Ouput controller.
|
||||
"""
|
||||
|
||||
@@ -19,6 +19,7 @@ from .adapter import Adapter
|
||||
|
||||
|
||||
class C7200_IO_GE_E(Adapter):
|
||||
|
||||
"""
|
||||
C7200-IO-GE-E GigabitEthernet Input/Ouput controller.
|
||||
"""
|
||||
|
||||
@@ -19,6 +19,7 @@ from .adapter import Adapter
|
||||
|
||||
|
||||
class Leopard_2FE(Adapter):
|
||||
|
||||
"""
|
||||
Integrated 2 port FastEthernet adapter for c3660 router.
|
||||
"""
|
||||
|
||||
@@ -19,6 +19,7 @@ from .adapter import Adapter
|
||||
|
||||
|
||||
class NM_16ESW(Adapter):
|
||||
|
||||
"""
|
||||
NM-16ESW FastEthernet network module.
|
||||
"""
|
||||
|
||||
@@ -19,6 +19,7 @@ from .adapter import Adapter
|
||||
|
||||
|
||||
class NM_1E(Adapter):
|
||||
|
||||
"""
|
||||
NM-1E Ethernet network module.
|
||||
"""
|
||||
|
||||
@@ -19,6 +19,7 @@ from .adapter import Adapter
|
||||
|
||||
|
||||
class NM_1FE_TX(Adapter):
|
||||
|
||||
"""
|
||||
NM-1FE-TX FastEthernet network module.
|
||||
"""
|
||||
|
||||
@@ -19,6 +19,7 @@ from .adapter import Adapter
|
||||
|
||||
|
||||
class NM_4E(Adapter):
|
||||
|
||||
"""
|
||||
NM-4E Ethernet network module.
|
||||
"""
|
||||
|
||||
@@ -19,6 +19,7 @@ from .adapter import Adapter
|
||||
|
||||
|
||||
class NM_4T(Adapter):
|
||||
|
||||
"""
|
||||
NM-4T Serial network module.
|
||||
"""
|
||||
|
||||
@@ -19,6 +19,7 @@ from .adapter import Adapter
|
||||
|
||||
|
||||
class PA_2FE_TX(Adapter):
|
||||
|
||||
"""
|
||||
PA-2FE-TX FastEthernet port adapter.
|
||||
"""
|
||||
|
||||
@@ -19,6 +19,7 @@ from .adapter import Adapter
|
||||
|
||||
|
||||
class PA_4E(Adapter):
|
||||
|
||||
"""
|
||||
PA-4E Ethernet port adapter.
|
||||
"""
|
||||
|
||||
@@ -19,6 +19,7 @@ from .adapter import Adapter
|
||||
|
||||
|
||||
class PA_4T(Adapter):
|
||||
|
||||
"""
|
||||
PA-4T+ Serial port adapter.
|
||||
"""
|
||||
|
||||
@@ -19,6 +19,7 @@ from .adapter import Adapter
|
||||
|
||||
|
||||
class PA_8E(Adapter):
|
||||
|
||||
"""
|
||||
PA-8E Ethernet port adapter.
|
||||
"""
|
||||
|
||||
@@ -19,6 +19,7 @@ from .adapter import Adapter
|
||||
|
||||
|
||||
class PA_8T(Adapter):
|
||||
|
||||
"""
|
||||
PA-8T Serial port adapter.
|
||||
"""
|
||||
|
||||
@@ -19,6 +19,7 @@ from .adapter import Adapter
|
||||
|
||||
|
||||
class PA_A1(Adapter):
|
||||
|
||||
"""
|
||||
PA-A1 ATM port adapter.
|
||||
"""
|
||||
|
||||
@@ -19,6 +19,7 @@ from .adapter import Adapter
|
||||
|
||||
|
||||
class PA_FE_TX(Adapter):
|
||||
|
||||
"""
|
||||
PA-FE-TX FastEthernet port adapter.
|
||||
"""
|
||||
|
||||
@@ -19,6 +19,7 @@ from .adapter import Adapter
|
||||
|
||||
|
||||
class PA_GE(Adapter):
|
||||
|
||||
"""
|
||||
PA-GE GigabitEthernet port adapter.
|
||||
"""
|
||||
|
||||
@@ -19,6 +19,7 @@ from .adapter import Adapter
|
||||
|
||||
|
||||
class PA_POS_OC3(Adapter):
|
||||
|
||||
"""
|
||||
PA-POS-OC3 port adapter.
|
||||
"""
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
|
||||
class WIC_1ENET(object):
|
||||
|
||||
"""
|
||||
WIC-1ENET Ethernet
|
||||
"""
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
|
||||
class WIC_1T(object):
|
||||
|
||||
"""
|
||||
WIC-1T Serial
|
||||
"""
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
|
||||
class WIC_2T(object):
|
||||
|
||||
"""
|
||||
WIC-2T Serial
|
||||
"""
|
||||
|
||||
@@ -466,7 +466,7 @@ class VM(object):
|
||||
adapter_name = value
|
||||
adapter = ADAPTER_MATRIX[adapter_name]()
|
||||
try:
|
||||
if router.slots[slot_id] and type(router.slots[slot_id]) != type(adapter):
|
||||
if router.slots[slot_id] and not isinstance(router.slots[slot_id], type(adapter)):
|
||||
router.slot_remove_binding(slot_id)
|
||||
router.slot_add_binding(slot_id, adapter)
|
||||
response[name] = value
|
||||
@@ -487,14 +487,14 @@ class VM(object):
|
||||
wic_name = value
|
||||
wic = WIC_MATRIX[wic_name]()
|
||||
try:
|
||||
if router.slots[0].wics[wic_slot_id] and type(router.slots[0].wics[wic_slot_id]) != type(wic):
|
||||
if router.slots[0].wics[wic_slot_id] and not isinstance(router.slots[0].wics[wic_slot_id], type(wic)):
|
||||
router.uninstall_wic(wic_slot_id)
|
||||
router.install_wic(wic_slot_id, wic)
|
||||
response[name] = value
|
||||
except DynamipsError as e:
|
||||
self.send_custom_error(str(e))
|
||||
return
|
||||
elif name.startswith("wic") and value == None:
|
||||
elif name.startswith("wic") and value is None:
|
||||
wic_slot_id = int(name[-1])
|
||||
if router.slots[0].wics and router.slots[0].wics[wic_slot_id]:
|
||||
try:
|
||||
|
||||
@@ -30,6 +30,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DynamipsHypervisor(object):
|
||||
|
||||
"""
|
||||
Creates a new connection to a Dynamips server (also called hypervisor)
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Hypervisor(DynamipsHypervisor):
|
||||
|
||||
"""
|
||||
Hypervisor.
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class HypervisorManager(object):
|
||||
|
||||
"""
|
||||
Manages Dynamips hypervisors.
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class NIO(object):
|
||||
|
||||
"""
|
||||
Base NIO class
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class NIO_FIFO(NIO):
|
||||
|
||||
"""
|
||||
Dynamips FIFO NIO.
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class NIO_GenericEthernet(NIO):
|
||||
|
||||
"""
|
||||
Dynamips generic Ethernet NIO.
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class NIO_LinuxEthernet(NIO):
|
||||
|
||||
"""
|
||||
Dynamips Linux Ethernet NIO.
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class NIO_Mcast(NIO):
|
||||
|
||||
"""
|
||||
Dynamips Linux Ethernet NIO.
|
||||
|
||||
@@ -103,5 +104,5 @@ class NIO_Mcast(NIO):
|
||||
"""
|
||||
|
||||
self._hypervisor.send("nio set_mcast_ttl {name} {ttl}".format(name=self._name,
|
||||
ttl=ttl))
|
||||
ttl=ttl))
|
||||
self._ttl = ttl
|
||||
@@ -26,6 +26,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class NIO_Null(NIO):
|
||||
|
||||
"""
|
||||
Dynamips NULL NIO.
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class NIO_TAP(NIO):
|
||||
|
||||
"""
|
||||
Dynamips TAP NIO.
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class NIO_UDP(NIO):
|
||||
|
||||
"""
|
||||
Dynamips UDP NIO.
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class NIO_UDP_auto(NIO):
|
||||
|
||||
"""
|
||||
Dynamips auto UDP NIO.
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class NIO_UNIX(NIO):
|
||||
|
||||
"""
|
||||
Dynamips UNIX NIO.
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class NIO_VDE(NIO):
|
||||
|
||||
"""
|
||||
Dynamips VDE NIO.
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ from ..dynamips_error import DynamipsError
|
||||
|
||||
|
||||
class ATMBridge(object):
|
||||
|
||||
"""
|
||||
Dynamips bridge switch.
|
||||
|
||||
@@ -33,7 +34,7 @@ class ATMBridge(object):
|
||||
|
||||
def __init__(self, hypervisor, name):
|
||||
|
||||
#FIXME: instance tracking
|
||||
# FIXME: instance tracking
|
||||
self._hypervisor = hypervisor
|
||||
self._name = '"' + name + '"' # put name into quotes to protect spaces
|
||||
self._hypervisor.send("atm_bridge create {}".format(self._name))
|
||||
|
||||
@@ -28,6 +28,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ATMSwitch(object):
|
||||
|
||||
"""
|
||||
Dynamips ATM switch.
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L538
|
||||
|
||||
|
||||
class Bridge(object):
|
||||
|
||||
"""
|
||||
Dynamips bridge.
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class C1700(Router):
|
||||
|
||||
"""
|
||||
Dynamips c1700 router.
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class C2600(Router):
|
||||
|
||||
"""
|
||||
Dynamips c2600 router.
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class C2691(Router):
|
||||
|
||||
"""
|
||||
Dynamips c2691 router.
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class C3600(Router):
|
||||
|
||||
"""
|
||||
Dynamips c3600 router.
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class C3725(Router):
|
||||
|
||||
"""
|
||||
Dynamips c3725 router.
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class C3745(Router):
|
||||
|
||||
"""
|
||||
Dynamips c3745 router.
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class C7200(Router):
|
||||
|
||||
"""
|
||||
Dynamips c7200 router (model is 7206).
|
||||
|
||||
@@ -227,9 +228,9 @@ class C7200(Router):
|
||||
powered_on=power_supply))
|
||||
|
||||
log.info("router {name} [id={id}]: power supply {power_supply_id} state updated to {powered_on}".format(name=self._name,
|
||||
id=self._id,
|
||||
power_supply_id=power_supply_id,
|
||||
powered_on=power_supply))
|
||||
id=self._id,
|
||||
power_supply_id=power_supply_id,
|
||||
powered_on=power_supply))
|
||||
power_supply_id += 1
|
||||
|
||||
self._power_supplies = power_supplies
|
||||
|
||||
@@ -28,6 +28,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class EthernetSwitch(object):
|
||||
|
||||
"""
|
||||
Dynamips Ethernet switch.
|
||||
|
||||
@@ -268,9 +269,9 @@ class EthernetSwitch(object):
|
||||
outer_vlan=outer_vlan))
|
||||
|
||||
log.info("Ethernet switch {name} [id={id}]: port {port} set as a QinQ port with outer VLAN {vlan_id}".format(name=self._name,
|
||||
id=self._id,
|
||||
port=port,
|
||||
vlan_id=outer_vlan))
|
||||
id=self._id,
|
||||
port=port,
|
||||
vlan_id=outer_vlan))
|
||||
self._mapping[port] = ("qinq", outer_vlan)
|
||||
|
||||
def get_mac_addr_table(self):
|
||||
|
||||
@@ -28,6 +28,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class FrameRelaySwitch(object):
|
||||
|
||||
"""
|
||||
Dynamips Frame Relay switch.
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Hub(Bridge):
|
||||
|
||||
"""
|
||||
Dynamips hub (based on Bridge)
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Router(object):
|
||||
|
||||
"""
|
||||
Dynamips router implementation.
|
||||
|
||||
@@ -575,7 +576,7 @@ class Router(object):
|
||||
try:
|
||||
reply = self._hypervisor.send("vm extract_config {}".format(self._name))[0].rsplit(' ', 2)[-2:]
|
||||
except IOError:
|
||||
#for some reason Dynamips gets frozen when it does not find the magic number in the NVRAM file.
|
||||
# for some reason Dynamips gets frozen when it does not find the magic number in the NVRAM file.
|
||||
return None, None
|
||||
startup_config = reply[0][1:-1] # get statup-config and remove single quotes
|
||||
private_config = reply[1][1:-1] # get private-config and remove single quotes
|
||||
|
||||
@@ -44,7 +44,7 @@ ETHSW_DELETE_SCHEMA = {
|
||||
"required": ["id"]
|
||||
}
|
||||
|
||||
#TODO: ports {'1': {'vlan': 1, 'type': 'qinq'}
|
||||
# TODO: ports {'1': {'vlan': 1, 'type': 'qinq'}
|
||||
ETHSW_UPDATE_SCHEMA = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "Request validation to update an Ethernet switch instance",
|
||||
@@ -59,20 +59,20 @@ ETHSW_UPDATE_SCHEMA = {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
},
|
||||
# "ports": {
|
||||
# "type": "object",
|
||||
# "properties": {
|
||||
# "type": {
|
||||
# "description": "Port type",
|
||||
# "enum": ["access", "dot1q", "qinq"],
|
||||
# },
|
||||
# "vlan": {
|
||||
# "description": "VLAN number",
|
||||
# "type": "integer",
|
||||
# "minimum": 1
|
||||
# },
|
||||
# },
|
||||
# },
|
||||
# "ports": {
|
||||
# "type": "object",
|
||||
# "properties": {
|
||||
# "type": {
|
||||
# "description": "Port type",
|
||||
# "enum": ["access", "dot1q", "qinq"],
|
||||
# },
|
||||
# "vlan": {
|
||||
# "description": "VLAN number",
|
||||
# "type": "integer",
|
||||
# "minimum": 1
|
||||
# },
|
||||
# },
|
||||
# },
|
||||
},
|
||||
#"additionalProperties": False,
|
||||
"required": ["id"]
|
||||
|
||||
@@ -147,7 +147,7 @@ VM_RELOAD_SCHEMA = {
|
||||
"required": ["id"]
|
||||
}
|
||||
|
||||
#TODO: improve platform specific properties (dependencies?)
|
||||
# TODO: improve platform specific properties (dependencies?)
|
||||
VM_UPDATE_SCHEMA = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "Request validation to update a VM instance",
|
||||
|
||||
Reference in new issue
Block a user