Allocate random names for Dynamips NIOs.

This commit is contained in:
grossmj
2015-04-12 18:14:45 -06:00
parent 78bc6e29a8
commit 443842e9b8
9 changed files with 27 additions and 127 deletions

View File

@ -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):