mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-06 07:11:13 +02:00
Dynamips NIO connections.
This commit is contained in:
1 parent
83edc649d2
commit
a5ac7c5481
18 files changed
+515
-270
No files matched your search
@@ -38,7 +38,7 @@ class NIO:
|
||||
def __init__(self, name, hypervisor):
|
||||
|
||||
self._hypervisor = hypervisor
|
||||
self._name = None
|
||||
self._name = name
|
||||
self._bandwidth = None # no bandwidth constraint by default
|
||||
self._input_filter = None # no input filter applied by default
|
||||
self._output_filter = None # no output filter applied by default
|
||||
|
||||
@@ -38,12 +38,11 @@ class NIOFIFO(NIO):
|
||||
|
||||
def __init__(self, hypervisor):
|
||||
|
||||
NIO.__init__(self, hypervisor)
|
||||
|
||||
# create an unique ID
|
||||
self._id = NIOFIFO._instance_count
|
||||
# create an unique ID and name
|
||||
nio_id = NIOFIFO._instance_count
|
||||
NIOFIFO._instance_count += 1
|
||||
self._name = 'nio_fifo' + str(self._id)
|
||||
name = 'nio_fifo' + str(nio_id)
|
||||
NIO.__init__(name, self, hypervisor)
|
||||
|
||||
@classmethod
|
||||
def reset(cls):
|
||||
@@ -71,3 +70,7 @@ class NIOFIFO(NIO):
|
||||
nio=nio))
|
||||
|
||||
log.info("NIO FIFO {name} crossconnected with {nio_name}.".format(name=self._name, nio_name=nio.name))
|
||||
|
||||
def __json__(self):
|
||||
|
||||
return {"type": "nio_fifo"}
|
||||
@@ -39,13 +39,12 @@ class NIOGenericEthernet(NIO):
|
||||
|
||||
def __init__(self, hypervisor, ethernet_device):
|
||||
|
||||
NIO.__init__(self, hypervisor)
|
||||
|
||||
# create an unique ID
|
||||
self._id = NIOGenericEthernet._instance_count
|
||||
# create an unique ID and name
|
||||
nio_id = NIOGenericEthernet._instance_count
|
||||
NIOGenericEthernet._instance_count += 1
|
||||
self._name = 'nio_gen_eth' + str(self._id)
|
||||
name = 'nio_gen_eth' + str(nio_id)
|
||||
self._ethernet_device = ethernet_device
|
||||
NIO.__init__(self, name, hypervisor)
|
||||
|
||||
@classmethod
|
||||
def reset(cls):
|
||||
@@ -73,3 +72,8 @@ class NIOGenericEthernet(NIO):
|
||||
"""
|
||||
|
||||
return self._ethernet_device
|
||||
|
||||
def __json__(self):
|
||||
|
||||
return {"type": "nio_generic_ethernet",
|
||||
"ethernet_device": self._ethernet_device}
|
||||
@@ -39,13 +39,12 @@ class NIOLinuxEthernet(NIO):
|
||||
|
||||
def __init__(self, hypervisor, ethernet_device):
|
||||
|
||||
NIO.__init__(self, hypervisor)
|
||||
|
||||
# create an unique ID
|
||||
self._id = NIOLinuxEthernet._instance_count
|
||||
# create an unique ID and name
|
||||
nio_id = NIOLinuxEthernet._instance_count
|
||||
NIOLinuxEthernet._instance_count += 1
|
||||
self._name = 'nio_linux_eth' + str(self._id)
|
||||
name = 'nio_linux_eth' + str(nio_id)
|
||||
self._ethernet_device = ethernet_device
|
||||
NIO.__init__(self, name, hypervisor)
|
||||
|
||||
@classmethod
|
||||
def reset(cls):
|
||||
@@ -73,3 +72,8 @@ class NIOLinuxEthernet(NIO):
|
||||
"""
|
||||
|
||||
return self._ethernet_device
|
||||
|
||||
def __json__(self):
|
||||
|
||||
return {"type": "nio_linux_ethernet",
|
||||
"ethernet_device": self._ethernet_device}
|
||||
@@ -40,15 +40,14 @@ class NIOMcast(NIO):
|
||||
|
||||
def __init__(self, hypervisor, group, port):
|
||||
|
||||
NIO.__init__(self, hypervisor)
|
||||
|
||||
# create an unique ID
|
||||
self._id = NIOMcast._instance_count
|
||||
# create an unique ID and name
|
||||
nio_id = NIOMcast._instance_count
|
||||
NIOMcast._instance_count += 1
|
||||
self._name = 'nio_mcast' + str(self._id)
|
||||
name = 'nio_mcast' + str(nio_id)
|
||||
self._group = group
|
||||
self._port = port
|
||||
self._ttl = 1 # default TTL
|
||||
NIO.__init__(self, name, hypervisor)
|
||||
|
||||
@classmethod
|
||||
def reset(cls):
|
||||
@@ -109,3 +108,9 @@ class NIOMcast(NIO):
|
||||
yield from self._hypervisor.send("nio set_mcast_ttl {name} {ttl}".format(name=self._name,
|
||||
ttl=ttl))
|
||||
self._ttl = ttl
|
||||
|
||||
def __json__(self):
|
||||
|
||||
return {"type": "nio_mcast",
|
||||
"mgroup": self._mgroup,
|
||||
"mport": self._mport}
|
||||
@@ -38,12 +38,11 @@ class NIONull(NIO):
|
||||
|
||||
def __init__(self, hypervisor):
|
||||
|
||||
NIO.__init__(self, hypervisor)
|
||||
|
||||
# create an unique ID
|
||||
self._id = NIONull._instance_count
|
||||
# create an unique ID and name
|
||||
nio_id = NIONull._instance_count
|
||||
NIONull._instance_count += 1
|
||||
self._name = 'nio_null' + str(self._id)
|
||||
name = 'nio_null' + str(nio_id)
|
||||
NIO.__init__(self, name, hypervisor)
|
||||
|
||||
@classmethod
|
||||
def reset(cls):
|
||||
@@ -58,3 +57,7 @@ class NIONull(NIO):
|
||||
|
||||
yield from self._hypervisor.send("nio create_null {}".format(self._name))
|
||||
log.info("NIO NULL {name} created.".format(name=self._name))
|
||||
|
||||
def __json__(self):
|
||||
|
||||
return {"type": "nio_null"}
|
||||
@@ -39,13 +39,12 @@ class NIOTAP(NIO):
|
||||
|
||||
def __init__(self, hypervisor, tap_device):
|
||||
|
||||
NIO.__init__(self, hypervisor)
|
||||
|
||||
# create an unique ID
|
||||
self._id = NIOTAP._instance_count
|
||||
# create an unique ID and name
|
||||
nio_id = NIOTAP._instance_count
|
||||
NIOTAP._instance_count += 1
|
||||
self._name = 'nio_tap' + str(self._id)
|
||||
name = 'nio_tap' + str(nio_id)
|
||||
self._tap_device = tap_device
|
||||
NIO.__init__(self, name, hypervisor)
|
||||
|
||||
@classmethod
|
||||
def reset(cls):
|
||||
@@ -70,3 +69,8 @@ class NIOTAP(NIO):
|
||||
"""
|
||||
|
||||
return self._tap_device
|
||||
|
||||
def __json__(self):
|
||||
|
||||
return {"type": "nio_tap",
|
||||
"tap_device": self._tap_device}
|
||||
@@ -41,15 +41,14 @@ class NIOUDP(NIO):
|
||||
|
||||
def __init__(self, hypervisor, lport, rhost, rport):
|
||||
|
||||
NIO.__init__(self, hypervisor)
|
||||
|
||||
# create an unique ID
|
||||
self._id = NIOUDP._instance_count
|
||||
# create an unique ID and name
|
||||
nio_id = NIOUDP._instance_count
|
||||
NIOUDP._instance_count += 1
|
||||
self._name = 'nio_udp' + str(self._id)
|
||||
name = 'nio_udp' + str(nio_id)
|
||||
self._lport = lport
|
||||
self._rhost = rhost
|
||||
self._rport = rport
|
||||
NIO.__init__(self, name, hypervisor)
|
||||
|
||||
@classmethod
|
||||
def reset(cls):
|
||||
@@ -101,3 +100,10 @@ class NIOUDP(NIO):
|
||||
"""
|
||||
|
||||
return self._rport
|
||||
|
||||
def __json__(self):
|
||||
|
||||
return {"type": "nio_udp",
|
||||
"lport": self._lport,
|
||||
"rport": self._rport,
|
||||
"rhost": self._rhost}
|
||||
@@ -41,17 +41,15 @@ class NIOUDPAuto(NIO):
|
||||
|
||||
def __init__(self, hypervisor, laddr, lport_start, lport_end):
|
||||
|
||||
NIO.__init__(self, hypervisor)
|
||||
|
||||
# create an unique ID
|
||||
self._id = NIOUDPAuto._instance_count
|
||||
# create an unique ID and name
|
||||
nio_id = NIOUDPAuto._instance_count
|
||||
NIOUDPAuto._instance_count += 1
|
||||
self._name = 'nio_udp_auto' + str(self._id)
|
||||
|
||||
name = 'nio_udp_auto' + str(nio_id)
|
||||
self._laddr = laddr
|
||||
self._lport = None
|
||||
self._raddr = None
|
||||
self._rport = None
|
||||
NIO.__init__(self, name, hypervisor)
|
||||
|
||||
@classmethod
|
||||
def reset(cls):
|
||||
@@ -133,3 +131,10 @@ class NIOUDPAuto(NIO):
|
||||
log.info("NIO UDP AUTO {name} connected to {raddr}:{rport}".format(name=self._name,
|
||||
raddr=raddr,
|
||||
rport=rport))
|
||||
|
||||
def __json__(self):
|
||||
|
||||
return {"type": "nio_udp_auto",
|
||||
"lport": self._lport,
|
||||
"rport": self._rport,
|
||||
"raddr": self._raddr}
|
||||
@@ -40,14 +40,13 @@ class NIOUNIX(NIO):
|
||||
|
||||
def __init__(self, hypervisor, local_file, remote_file):
|
||||
|
||||
NIO.__init__(self, hypervisor)
|
||||
|
||||
# create an unique ID
|
||||
self._id = NIOUNIX._instance_count
|
||||
# create an unique ID and name
|
||||
nio_id = NIOUNIX._instance_count
|
||||
NIOUNIX._instance_count += 1
|
||||
self._name = 'nio_unix' + str(self._id)
|
||||
name = 'nio_unix' + str(nio_id)
|
||||
self._local_file = local_file
|
||||
self._remote_file = remote_file
|
||||
NIO.__init__(self, name, hypervisor)
|
||||
|
||||
@classmethod
|
||||
def reset(cls):
|
||||
@@ -87,3 +86,9 @@ class NIOUNIX(NIO):
|
||||
"""
|
||||
|
||||
return self._remote_file
|
||||
|
||||
def __json__(self):
|
||||
|
||||
return {"type": "nio_unix",
|
||||
"local_file": self._local_file,
|
||||
"remote_file": self._remote_file}
|
||||
@@ -19,6 +19,7 @@
|
||||
Interface for VDE (Virtual Distributed Ethernet) NIOs (Unix based OSes only).
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
from .nio import NIO
|
||||
|
||||
import logging
|
||||
@@ -39,22 +40,13 @@ class NIOVDE(NIO):
|
||||
|
||||
def __init__(self, hypervisor, control_file, local_file):
|
||||
|
||||
NIO.__init__(self, hypervisor)
|
||||
|
||||
# create an unique ID
|
||||
self._id = NIOVDE._instance_count
|
||||
# create an unique ID and name
|
||||
nio_id = NIOVDE._instance_count
|
||||
NIOVDE._instance_count += 1
|
||||
self._name = 'nio_vde' + str(self._id)
|
||||
name = 'nio_vde' + str(nio_id)
|
||||
self._control_file = control_file
|
||||
self._local_file = local_file
|
||||
|
||||
self._hypervisor.send("nio create_vde {name} {control} {local}".format(name=self._name,
|
||||
control=control_file,
|
||||
local=local_file))
|
||||
|
||||
log.info("NIO VDE {name} created with control={control}, local={local}".format(name=self._name,
|
||||
control=control_file,
|
||||
local=local_file))
|
||||
NIO.__init__(self, name, hypervisor)
|
||||
|
||||
@classmethod
|
||||
def reset(cls):
|
||||
@@ -64,6 +56,17 @@ class NIOVDE(NIO):
|
||||
|
||||
cls._instance_count = 0
|
||||
|
||||
@asyncio.coroutine
|
||||
def create(self):
|
||||
|
||||
self._hypervisor.send("nio create_vde {name} {control} {local}".format(name=self._name,
|
||||
control=self._control_file,
|
||||
local=self._local_file))
|
||||
|
||||
log.info("NIO VDE {name} created with control={control}, local={local}".format(name=self._name,
|
||||
control=self._control_file,
|
||||
local=self._local_file))
|
||||
|
||||
@property
|
||||
def control_file(self):
|
||||
"""
|
||||
@@ -83,3 +86,9 @@ class NIOVDE(NIO):
|
||||
"""
|
||||
|
||||
return self._local_file
|
||||
|
||||
def __json__(self):
|
||||
|
||||
return {"type": "nio_vde",
|
||||
"local_file": self._local_file,
|
||||
"control_file": self._control_file}
|
||||
Reference in new issue
Block a user