mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-15 12:59:06 +00:00
Allocate random names for Dynamips NIOs.
This commit is contained in:
parent
78bc6e29a8
commit
443842e9b8
@ -20,6 +20,7 @@ Interface for FIFO NIOs.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import uuid
|
||||
from .nio import NIO
|
||||
|
||||
import logging
|
||||
@ -34,24 +35,12 @@ class NIOFIFO(NIO):
|
||||
:param hypervisor: Dynamips hypervisor instance
|
||||
"""
|
||||
|
||||
_instance_count = 0
|
||||
|
||||
def __init__(self, hypervisor):
|
||||
|
||||
# create an unique ID and name
|
||||
nio_id = NIOFIFO._instance_count
|
||||
NIOFIFO._instance_count += 1
|
||||
name = 'nio_fifo' + str(nio_id)
|
||||
# create an unique name
|
||||
name = 'fifo-{}'.format(uuid.uuid4())
|
||||
super().__init__(name, hypervisor)
|
||||
|
||||
@classmethod
|
||||
def reset(cls):
|
||||
"""
|
||||
Reset the instance count.
|
||||
"""
|
||||
|
||||
cls._instance_count = 0
|
||||
|
||||
@asyncio.coroutine
|
||||
def create(self):
|
||||
|
||||
|
@ -20,6 +20,7 @@ Interface for generic Ethernet NIOs (PCAP library).
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import uuid
|
||||
from .nio import NIO
|
||||
|
||||
import logging
|
||||
@ -35,25 +36,13 @@ class NIOGenericEthernet(NIO):
|
||||
:param ethernet_device: Ethernet device name (e.g. eth0)
|
||||
"""
|
||||
|
||||
_instance_count = 0
|
||||
|
||||
def __init__(self, hypervisor, ethernet_device):
|
||||
|
||||
# create an unique ID and name
|
||||
nio_id = NIOGenericEthernet._instance_count
|
||||
NIOGenericEthernet._instance_count += 1
|
||||
name = 'nio_gen_eth' + str(nio_id)
|
||||
# create an unique name
|
||||
name = 'generic_ethernet-{}'.format(uuid.uuid4())
|
||||
self._ethernet_device = ethernet_device
|
||||
super().__init__(name, hypervisor)
|
||||
|
||||
@classmethod
|
||||
def reset(cls):
|
||||
"""
|
||||
Reset the instance count.
|
||||
"""
|
||||
|
||||
cls._instance_count = 0
|
||||
|
||||
@asyncio.coroutine
|
||||
def create(self):
|
||||
|
||||
|
@ -20,6 +20,7 @@ Interface for Linux Ethernet NIOs (Linux only).
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import uuid
|
||||
from .nio import NIO
|
||||
|
||||
import logging
|
||||
@ -35,25 +36,12 @@ class NIOLinuxEthernet(NIO):
|
||||
:param ethernet_device: Ethernet device name (e.g. eth0)
|
||||
"""
|
||||
|
||||
_instance_count = 0
|
||||
|
||||
def __init__(self, hypervisor, ethernet_device):
|
||||
|
||||
# create an unique ID and name
|
||||
nio_id = NIOLinuxEthernet._instance_count
|
||||
NIOLinuxEthernet._instance_count += 1
|
||||
name = 'nio_linux_eth' + str(nio_id)
|
||||
# create an unique name
|
||||
name = 'linux_ethernet-{}'.format(uuid.uuid4())
|
||||
self._ethernet_device = ethernet_device
|
||||
super().__init__(name, hypervisor)
|
||||
|
||||
@classmethod
|
||||
def reset(cls):
|
||||
"""
|
||||
Reset the instance count.
|
||||
"""
|
||||
|
||||
cls._instance_count = 0
|
||||
|
||||
@asyncio.coroutine
|
||||
def create(self):
|
||||
|
||||
|
@ -20,6 +20,7 @@ Interface for multicast NIOs.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import uuid
|
||||
from .nio import NIO
|
||||
|
||||
import logging
|
||||
@ -36,27 +37,15 @@ class NIOMcast(NIO):
|
||||
:param port: port for binding
|
||||
"""
|
||||
|
||||
_instance_count = 0
|
||||
|
||||
def __init__(self, hypervisor, group, port):
|
||||
|
||||
# create an unique ID and name
|
||||
nio_id = NIOMcast._instance_count
|
||||
NIOMcast._instance_count += 1
|
||||
name = 'nio_mcast' + str(nio_id)
|
||||
# create an unique name
|
||||
name = 'mcast-{}'.format(uuid.uuid4())
|
||||
self._group = group
|
||||
self._port = port
|
||||
self._ttl = 1 # default TTL
|
||||
super().__init__(name, hypervisor)
|
||||
|
||||
@classmethod
|
||||
def reset(cls):
|
||||
"""
|
||||
Reset the instance count.
|
||||
"""
|
||||
|
||||
cls._instance_count = 0
|
||||
|
||||
@asyncio.coroutine
|
||||
def create(self):
|
||||
|
||||
|
@ -20,6 +20,7 @@ Interface for dummy NIOs (mostly for tests).
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import uuid
|
||||
from .nio import NIO
|
||||
|
||||
import logging
|
||||
@ -34,24 +35,12 @@ class NIONull(NIO):
|
||||
:param hypervisor: Dynamips hypervisor instance
|
||||
"""
|
||||
|
||||
_instance_count = 0
|
||||
|
||||
def __init__(self, hypervisor):
|
||||
|
||||
# create an unique ID and name
|
||||
nio_id = NIONull._instance_count
|
||||
NIONull._instance_count += 1
|
||||
name = 'nio_null' + str(nio_id)
|
||||
# create an unique name
|
||||
name = 'null-{}'.format(uuid.uuid4())
|
||||
super().__init__(name, hypervisor)
|
||||
|
||||
@classmethod
|
||||
def reset(cls):
|
||||
"""
|
||||
Reset the instance count.
|
||||
"""
|
||||
|
||||
cls._instance_count = 0
|
||||
|
||||
@asyncio.coroutine
|
||||
def create(self):
|
||||
|
||||
|
@ -20,6 +20,7 @@ Interface for TAP NIOs (UNIX based OSes only).
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import uuid
|
||||
from .nio import NIO
|
||||
|
||||
import logging
|
||||
@ -35,25 +36,13 @@ class NIOTAP(NIO):
|
||||
:param tap_device: TAP device name (e.g. tap0)
|
||||
"""
|
||||
|
||||
_instance_count = 0
|
||||
|
||||
def __init__(self, hypervisor, tap_device):
|
||||
|
||||
# create an unique ID and name
|
||||
nio_id = NIOTAP._instance_count
|
||||
NIOTAP._instance_count += 1
|
||||
name = 'nio_tap' + str(nio_id)
|
||||
# create an unique name
|
||||
name = 'tap-{}'.format(uuid.uuid4())
|
||||
self._tap_device = tap_device
|
||||
super().__init__(name, hypervisor)
|
||||
|
||||
@classmethod
|
||||
def reset(cls):
|
||||
"""
|
||||
Reset the instance count.
|
||||
"""
|
||||
|
||||
cls._instance_count = 0
|
||||
|
||||
@asyncio.coroutine
|
||||
def create(self):
|
||||
|
||||
|
@ -20,6 +20,7 @@ Interface for UDP NIOs.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import uuid
|
||||
from .nio import NIO
|
||||
|
||||
import logging
|
||||
@ -37,27 +38,15 @@ class NIOUDP(NIO):
|
||||
:param rport: remote port number
|
||||
"""
|
||||
|
||||
_instance_count = 0
|
||||
|
||||
def __init__(self, hypervisor, lport, rhost, rport):
|
||||
|
||||
# create an unique ID and name
|
||||
nio_id = NIOUDP._instance_count
|
||||
NIOUDP._instance_count += 1
|
||||
name = 'nio_udp' + str(nio_id)
|
||||
# create an unique name
|
||||
name = 'udp-{}'.format(uuid.uuid4())
|
||||
self._lport = lport
|
||||
self._rhost = rhost
|
||||
self._rport = rport
|
||||
super().__init__(name, hypervisor)
|
||||
|
||||
@classmethod
|
||||
def reset(cls):
|
||||
"""
|
||||
Reset the instance count.
|
||||
"""
|
||||
|
||||
cls._instance_count = 0
|
||||
|
||||
@asyncio.coroutine
|
||||
def create(self):
|
||||
|
||||
|
@ -20,6 +20,7 @@ Interface for UNIX NIOs (Unix based OSes only).
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import uuid
|
||||
from .nio import NIO
|
||||
|
||||
import logging
|
||||
@ -36,26 +37,14 @@ class NIOUNIX(NIO):
|
||||
:param remote_file: remote UNIX socket filename
|
||||
"""
|
||||
|
||||
_instance_count = 0
|
||||
|
||||
def __init__(self, hypervisor, local_file, remote_file):
|
||||
|
||||
# create an unique ID and name
|
||||
nio_id = NIOUNIX._instance_count
|
||||
NIOUNIX._instance_count += 1
|
||||
name = 'nio_unix' + str(nio_id)
|
||||
# create an unique name
|
||||
name = 'unix-{}'.format(uuid.uuid4())
|
||||
self._local_file = local_file
|
||||
self._remote_file = remote_file
|
||||
super().__init__(name, hypervisor)
|
||||
|
||||
@classmethod
|
||||
def reset(cls):
|
||||
"""
|
||||
Reset the instance count.
|
||||
"""
|
||||
|
||||
cls._instance_count = 0
|
||||
|
||||
@asyncio.coroutine
|
||||
def create(self):
|
||||
|
||||
|
@ -20,6 +20,7 @@ Interface for VDE (Virtual Distributed Ethernet) NIOs (Unix based OSes only).
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import uuid
|
||||
from .nio import NIO
|
||||
|
||||
import logging
|
||||
@ -36,26 +37,14 @@ class NIOVDE(NIO):
|
||||
:param local_file: VDE local filename
|
||||
"""
|
||||
|
||||
_instance_count = 0
|
||||
|
||||
def __init__(self, hypervisor, control_file, local_file):
|
||||
|
||||
# create an unique ID and name
|
||||
nio_id = NIOVDE._instance_count
|
||||
NIOVDE._instance_count += 1
|
||||
name = 'nio_vde' + str(nio_id)
|
||||
# create an unique name
|
||||
name = 'vde-{}'.format(uuid.uuid4())
|
||||
self._control_file = control_file
|
||||
self._local_file = local_file
|
||||
super().__init__(name, hypervisor)
|
||||
|
||||
@classmethod
|
||||
def reset(cls):
|
||||
"""
|
||||
Reset the instance count.
|
||||
"""
|
||||
|
||||
cls._instance_count = 0
|
||||
|
||||
@asyncio.coroutine
|
||||
def create(self):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user