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