Explicit ID names, remove {uuid} from URLs and add vms in URLs for VMs.

This commit is contained in:
Jeremy committed 2015-02-04 13:48:29 -07:00
1 parent 568e203580
commit 1bea78194c
22 files changed
+336 -344

No files matched your search

+26 -25
View File
@@ -97,71 +97,72 @@ class BaseManager:
@asyncio.coroutine
def unload(self):
for uuid in self._vms.keys():
for vm_id in self._vms.keys():
try:
yield from self.close_vm(uuid)
yield from self.close_vm(vm_id)
except Exception as e:
log.error("Could not delete VM {}: {}".format(uuid, e), exc_info=1)
log.error("Could not delete VM {}: {}".format(vm_id, e), exc_info=1)
continue
if hasattr(BaseManager, "_instance"):
BaseManager._instance = None
log.debug("Module {} unloaded".format(self.module_name))
def get_vm(self, uuid):
def get_vm(self, vm_id):
"""
Returns a VM instance.
:param uuid: VM UUID
:param vm_id: VM identifier
:returns: VM instance
"""
try:
UUID(uuid, version=4)
UUID(vm_id, version=4)
except ValueError:
raise aiohttp.web.HTTPBadRequest(text="{} is not a valid UUID".format(uuid))
raise aiohttp.web.HTTPBadRequest(text="{} is not a valid UUID".format(vm_id))
if uuid not in self._vms:
raise aiohttp.web.HTTPNotFound(text="UUID {} doesn't exist".format(uuid))
return self._vms[uuid]
if vm_id not in self._vms:
raise aiohttp.web.HTTPNotFound(text="ID {} doesn't exist".format(vm_id))
return self._vms[vm_id]
@asyncio.coroutine
def create_vm(self, name, project_uuid, uuid, *args, **kwargs):
def create_vm(self, name, project_id, vm_id, *args, **kwargs):
"""
Create a new VM
:param name: VM name
:param project_uuid: UUID of Project
:param uuid: restore a VM UUID
:param project_id: Project identifier
:param vm_id: restore a VM identifier
"""
project = ProjectManager.instance().get_project(project_uuid)
project = ProjectManager.instance().get_project(project_id)
# TODO: support for old projects VM with normal IDs.
if not uuid:
uuid = str(uuid4())
if not vm_id:
vm_id = str(uuid4())
vm = self._VM_CLASS(name, uuid, project, self, *args, **kwargs)
vm = self._VM_CLASS(name, vm_id, project, self, *args, **kwargs)
if asyncio.iscoroutinefunction(vm.create):
yield from vm.create()
else:
vm.create()
self._vms[vm.uuid] = vm
self._vms[vm.id] = vm
project.add_vm(vm)
return vm
@asyncio.coroutine
def close_vm(self, uuid):
def close_vm(self, vm_id):
"""
Delete a VM
:param uuid: VM UUID
:param vm_id: VM identifier
:returns: VM instance
"""
vm = self.get_vm(uuid)
vm = self.get_vm(vm_id)
if asyncio.iscoroutinefunction(vm.close):
yield from vm.close()
else:
@@ -169,18 +170,18 @@ class BaseManager:
return vm
@asyncio.coroutine
def delete_vm(self, uuid):
def delete_vm(self, vm_id):
"""
Delete a VM. VM working directory will be destroy when
we receive a commit.
:param uuid: VM UUID
:param vm_id: VM identifier
:returns: VM instance
"""
vm = yield from self.close_vm(uuid)
vm = yield from self.close_vm(vm_id)
vm.project.mark_vm_for_destruction(vm)
del self._vms[vm.uuid]
del self._vms[vm.id]
return vm
@staticmethod
+16 -16
View File
@@ -21,16 +21,16 @@ log = logging.getLogger(__name__)
class BaseVM:
def __init__(self, name, uuid, project, manager):
def __init__(self, name, vm_id, project, manager):
self._name = name
self._uuid = uuid
self._id = vm_id
self._project = project
self._manager = manager
log.debug("{module}: {name} [{uuid}] initialized".format(module=self.manager.module_name,
name=self.name,
uuid=self.uuid))
log.debug("{module}: {name} [{id}] initialized".format(module=self.manager.module_name,
name=self.name,
id=self.id))
def __del__(self):
@@ -64,21 +64,21 @@ class BaseVM:
:param new_name: name
"""
log.info("{module}: {name} [{uuid}] renamed to {new_name}".format(module=self.manager.module_name,
name=self.name,
uuid=self.uuid,
new_name=new_name))
log.info("{module}: {name} [{id}] renamed to {new_name}".format(module=self.manager.module_name,
name=self.name,
id=self.id,
new_name=new_name))
self._name = new_name
@property
def uuid(self):
def id(self):
"""
Returns the UUID for this VM.
Returns the ID for this VM.
:returns: uuid (string)
:returns: VM identifier (string)
"""
return self._uuid
return self._id
@property
def manager(self):
@@ -103,9 +103,9 @@ class BaseVM:
Creates the VM.
"""
log.info("{module}: {name} [{uuid}] created".format(module=self.manager.module_name,
name=self.name,
uuid=self.uuid))
log.info("{module}: {name} [{id}] created".format(module=self.manager.module_name,
name=self.name,
id=self.id))
def start(self):
"""
+13 -13
View File
@@ -34,21 +34,21 @@ class Project:
A project contains a list of VM.
In theory VM are isolated project/project.
:param uuid: Force project uuid (None by default auto generate an UUID)
:param project_id: Force project identifier (None by default auto generate an UUID)
:param location: Parent path of the project. (None should create a tmp directory)
:param temporary: Boolean the project is a temporary project (destroy when closed)
"""
def __init__(self, uuid=None, location=None, temporary=False):
def __init__(self, project_id=None, location=None, temporary=False):
if uuid is None:
self._uuid = str(uuid4())
if project_id is None:
self._id = str(uuid4())
else:
try:
UUID(uuid, version=4)
UUID(project_id, version=4)
except ValueError:
raise aiohttp.web.HTTPBadRequest(text="{} is not a valid UUID".format(uuid))
self._uuid = uuid
raise aiohttp.web.HTTPBadRequest(text="{} is not a valid UUID".format(project_id))
self._id = project_id
config = Config.instance().get_section_config("Server")
self._location = location
@@ -60,13 +60,13 @@ class Project:
self._vms = set()
self._vms_to_destroy = set()
self._path = os.path.join(self._location, self._uuid)
self._path = os.path.join(self._location, self._id)
try:
os.makedirs(os.path.join(self._path, "vms"), exist_ok=True)
except OSError as e:
raise aiohttp.web.HTTPInternalServerError(text="Could not create project directory: {}".format(e))
self.temporary = temporary
log.debug("Create project {uuid} in directory {path}".format(path=self._path, uuid=self._uuid))
log.debug("Create project {id} in directory {path}".format(path=self._path, id=self._id))
@classmethod
def _get_default_project_directory(cls):
@@ -83,9 +83,9 @@ class Project:
return path
@property
def uuid(self):
def id(self):
return self._uuid
return self._id
@property
def location(self):
@@ -134,7 +134,7 @@ class Project:
:returns: A string with a VM working directory
"""
workdir = os.path.join(self._path, vm.manager.module_name.lower(), vm.uuid)
workdir = os.path.join(self._path, vm.manager.module_name.lower(), vm.id)
try:
os.makedirs(workdir, exist_ok=True)
except OSError as e:
@@ -166,7 +166,7 @@ class Project:
def __json__(self):
return {
"project_id": self._uuid,
"project_id": self._id,
"location": self._location,
"temporary": self._temporary
}
+8 -8
View File
@@ -42,23 +42,23 @@ class ProjectManager:
cls._instance = cls()
return cls._instance
def get_project(self, uuid):
def get_project(self, project_id):
"""
Returns a Project instance.
:param uuid: Project UUID
:param project_id: Project identifier
:returns: Project instance
"""
try:
UUID(uuid, version=4)
UUID(project_id, version=4)
except ValueError:
raise aiohttp.web.HTTPBadRequest(text="{} is not a valid UUID".format(uuid))
raise aiohttp.web.HTTPBadRequest(text="{} is not a valid UUID".format(project_id))
if uuid not in self._projects:
raise aiohttp.web.HTTPNotFound(text="Project UUID {} doesn't exist".format(uuid))
return self._projects[uuid]
if project_id not in self._projects:
raise aiohttp.web.HTTPNotFound(text="Project ID {} doesn't exist".format(project_id))
return self._projects[project_id]
def create_project(self, **kwargs):
"""
@@ -68,5 +68,5 @@ class ProjectManager:
"""
project = Project(**kwargs)
self._projects[project.uuid] = project
self._projects[project.id] = project
return project
+1 -1
View File
@@ -119,7 +119,7 @@ class VirtualBox(BaseManager):
vms = []
result = yield from self.execute("list", ["vms"])
for line in result:
vmname, uuid = line.rsplit(' ', 1)
vmname, _ = line.rsplit(' ', 1)
vmname = vmname.strip('"')
if vmname == "<inaccessible>":
continue # ignore inaccessible VMs
+61 -62
View File
@@ -48,9 +48,9 @@ class VirtualBoxVM(BaseVM):
VirtualBox VM implementation.
"""
def __init__(self, name, uuid, project, manager, vmname, linked_clone, adapters=0):
def __init__(self, name, vm_id, project, manager, vmname, linked_clone, adapters=0):
super().__init__(name, uuid, project, manager)
super().__init__(name, vm_id, project, manager)
self._maximum_adapters = 8
self._linked_clone = linked_clone
@@ -77,9 +77,9 @@ class VirtualBoxVM(BaseVM):
def __json__(self):
return {"name": self.name,
"uuid": self.uuid,
"vm_id": self.id,
"console": self.console,
"project_id": self.project.uuid,
"project_id": self.project.id,
"vmname": self.vmname,
"headless": self.headless,
"enable_remote_console": self.enable_remote_console,
@@ -144,10 +144,10 @@ class VirtualBoxVM(BaseVM):
yield from self._get_system_properties()
if parse_version(self._system_properties["API version"]) < parse_version("4_3"):
raise VirtualBoxError("The VirtualBox API version is lower than 4.3")
log.info("VirtualBox VM '{name}' [{uuid}] created".format(name=self.name, uuid=self.uuid))
log.info("VirtualBox VM '{name}' [{id}] created".format(name=self.name, id=self.id))
if self._linked_clone:
if self.uuid and os.path.isdir(os.path.join(self.working_dir, self._vmname)):
if self.id and os.path.isdir(os.path.join(self.working_dir, self._vmname)):
vbox_file = os.path.join(self.working_dir, self._vmname, self._vmname + ".vbox")
yield from self.manager.execute("registervm", [vbox_file])
yield from self._reattach_hdds()
@@ -180,7 +180,7 @@ class VirtualBoxVM(BaseVM):
if self._headless:
args.extend(["--type", "headless"])
result = yield from self.manager.execute("startvm", args)
log.info("VirtualBox VM '{name}' [{uuid}] started".format(name=self.name, uuid=self.uuid))
log.info("VirtualBox VM '{name}' [{id}] started".format(name=self.name, id=self.id))
log.debug("Start result: {}".format(result))
# add a guest property to let the VM know about the GNS3 name
@@ -202,7 +202,7 @@ class VirtualBoxVM(BaseVM):
if vm_state == "running" or vm_state == "paused" or vm_state == "stuck":
# power off the VM
result = yield from self._control_vm("poweroff")
log.info("VirtualBox VM '{name}' [{uuid}] stopped".format(name=self.name, uuid=self.uuid))
log.info("VirtualBox VM '{name}' [{id}] stopped".format(name=self.name, id=self.id))
log.debug("Stop result: {}".format(result))
yield from asyncio.sleep(0.5) # give some time for VirtualBox to unlock the VM
@@ -228,11 +228,11 @@ class VirtualBoxVM(BaseVM):
vm_state = yield from self._get_vm_state()
if vm_state == "running":
yield from self._control_vm("pause")
log.info("VirtualBox VM '{name}' [{uuid}] suspended".format(name=self.name, uuid=self.uuid))
log.info("VirtualBox VM '{name}' [{id}] suspended".format(name=self.name, id=self.id))
else:
log.warn("VirtualBox VM '{name}' [{uuid}] cannot be suspended, current state: {state}".format(name=self.name,
uuid=self.uuid,
state=vm_state))
log.warn("VirtualBox VM '{name}' [{id}] cannot be suspended, current state: {state}".format(name=self.name,
id=self.id,
state=vm_state))
@asyncio.coroutine
def resume(self):
@@ -241,7 +241,7 @@ class VirtualBoxVM(BaseVM):
"""
yield from self._control_vm("resume")
log.info("VirtualBox VM '{name}' [{uuid}] resumed".format(name=self.name, uuid=self.uuid))
log.info("VirtualBox VM '{name}' [{id}] resumed".format(name=self.name, id=self.id))
@asyncio.coroutine
def reload(self):
@@ -250,7 +250,7 @@ class VirtualBoxVM(BaseVM):
"""
result = yield from self._control_vm("reset")
log.info("VirtualBox VM '{name}' [{uuid}] reloaded".format(name=self.name, uuid=self.uuid))
log.info("VirtualBox VM '{name}' [{id}] reloaded".format(name=self.name, id=self.id))
log.debug("Reload result: {}".format(result))
@property
@@ -275,9 +275,9 @@ class VirtualBoxVM(BaseVM):
self._manager.port_manager.release_console_port(self._console)
self._console = self._manager.port_manager.reserve_console_port(console)
log.info("VirtualBox VM '{name}' [{uuid}]: console port set to {port}".format(name=self.name,
uuid=self.uuid,
port=console))
log.info("VirtualBox VM '{name}' [{id}]: console port set to {port}".format(name=self.name,
id=self.id,
port=console))
@asyncio.coroutine
def _get_all_hdd_files(self):
@@ -306,12 +306,12 @@ class VirtualBoxVM(BaseVM):
for hdd_info in hdd_table:
hdd_file = os.path.join(self.working_dir, self._vmname, "Snapshots", hdd_info["hdd"])
if os.path.exists(hdd_file):
log.info("VirtualBox VM '{name}' [{uuid}] attaching HDD {controller} {port} {device} {medium}".format(name=self.name,
uuid=self.uuid,
controller=hdd_info["controller"],
port=hdd_info["port"],
device=hdd_info["device"],
medium=hdd_file))
log.info("VirtualBox VM '{name}' [{id}] attaching HDD {controller} {port} {device} {medium}".format(name=self.name,
id=self.id,
controller=hdd_info["controller"],
port=hdd_info["port"],
device=hdd_info["device"],
medium=hdd_file))
yield from self._storage_attach('--storagectl "{}" --port {} --device {} --type hdd --medium "{}"'.format(hdd_info["controller"],
hdd_info["port"],
hdd_info["device"],
@@ -345,11 +345,11 @@ class VirtualBoxVM(BaseVM):
port = match.group(2)
device = match.group(3)
if value in hdd_files:
log.info("VirtualBox VM '{name}' [{uuid}] detaching HDD {controller} {port} {device}".format(name=self.name,
uuid=self.uuid,
controller=controller,
port=port,
device=device))
log.info("VirtualBox VM '{name}' [{id}] detaching HDD {controller} {port} {device}".format(name=self.name,
id=self.id,
controller=controller,
port=port,
device=device))
yield from self._storage_attach('--storagectl "{}" --port {} --device {} --type hdd --medium none'.format(controller, port, device))
hdd_table.append(
{
@@ -360,7 +360,7 @@ class VirtualBoxVM(BaseVM):
}
)
log.info("VirtualBox VM '{name}' [{uuid}] unregistering".format(name=self.name, uuid=self.uuid))
log.info("VirtualBox VM '{name}' [{id}] unregistering".format(name=self.name, id=self.id))
yield from self.manager.execute("unregistervm", [self._name])
if hdd_table:
@@ -369,12 +369,11 @@ class VirtualBoxVM(BaseVM):
with open(hdd_info_file, "w") as f:
json.dump(hdd_table, f, indent=4)
except OSError as e:
log.warning("VirtualBox VM '{name}' [{uuid}] could not write HHD info file: {error}".format(name=self.name,
uuid=self.uuid,
error=e.strerror))
log.warning("VirtualBox VM '{name}' [{id}] could not write HHD info file: {error}".format(name=self.name,
id=self.id,
error=e.strerror))
log.info("VirtualBox VM '{name}' [{uuid}] closed".format(name=self.name,
uuid=self.uuid))
log.info("VirtualBox VM '{name}' [{id}] closed".format(name=self.name, id=self.id))
self._closed = True
@property
@@ -396,9 +395,9 @@ class VirtualBoxVM(BaseVM):
"""
if headless:
log.info("VirtualBox VM '{name}' [{uuid}] has enabled the headless mode".format(name=self.name, uuid=self.uuid))
log.info("VirtualBox VM '{name}' [{id}] has enabled the headless mode".format(name=self.name, id=self.id))
else:
log.info("VirtualBox VM '{name}' [{uuid}] has disabled the headless mode".format(name=self.name, uuid=self.uuid))
log.info("VirtualBox VM '{name}' [{id}] has disabled the headless mode".format(name=self.name, id=self.id))
self._headless = headless
@property
@@ -420,10 +419,10 @@ class VirtualBoxVM(BaseVM):
"""
if enable_remote_console:
log.info("VirtualBox VM '{name}' [{uuid}] has enabled the console".format(name=self.name, uuid=self.uuid))
log.info("VirtualBox VM '{name}' [{id}] has enabled the console".format(name=self.name, id=self.id))
# self._start_remote_console()
else:
log.info("VirtualBox VM '{name}' [{uuid}] has disabled the console".format(name=self.name, uuid=self.uuid))
log.info("VirtualBox VM '{name}' [{id}] has disabled the console".format(name=self.name, id=self.id))
# self._stop_remote_console()
self._enable_remote_console = enable_remote_console
@@ -445,7 +444,7 @@ class VirtualBoxVM(BaseVM):
:param vmname: VirtualBox VM name
"""
log.info("VirtualBox VM '{name}' [{uuid}] has set the VM name to '{vmname}'".format(name=self.name, uuid=self.uuid, vmname=vmname))
log.info("VirtualBox VM '{name}' [{id}] has set the VM name to '{vmname}'".format(name=self.name, id=self.id, vmname=vmname))
# TODO: test linked clone
# if self._linked_clone:
# yield from self._modify_vm('--name "{}"'.format(vmname))
@@ -472,9 +471,9 @@ class VirtualBoxVM(BaseVM):
self._ethernet_adapters.append(EthernetAdapter())
self._adapters = len(self._ethernet_adapters)
log.info("VirtualBox VM '{name}' [{uuid}] has changed the number of Ethernet adapters to {adapters}".format(name=self.name,
uuid=self.uuid,
adapters=adapters))
log.info("VirtualBox VM '{name}' [{id}] has changed the number of Ethernet adapters to {adapters}".format(name=self.name,
id=self.id,
adapters=adapters))
@property
def adapter_start_index(self):
@@ -496,9 +495,9 @@ class VirtualBoxVM(BaseVM):
self._adapter_start_index = adapter_start_index
self.adapters = self.adapters # this forces to recreate the adapter list with the correct index
log.info("VirtualBox VM '{name}' [{uuid}]: adapter start index changed to {index}".format(name=self.name,
uuid=self.uuid,
index=adapter_start_index))
log.info("VirtualBox VM '{name}' [{id}]: adapter start index changed to {index}".format(name=self.name,
id=self.id,
index=adapter_start_index))
@property
def adapter_type(self):
@@ -520,9 +519,9 @@ class VirtualBoxVM(BaseVM):
self._adapter_type = adapter_type
log.info("VirtualBox VM '{name}' [{uuid}]: adapter type changed to {adapter_type}".format(name=self.name,
uuid=self.uuid,
adapter_type=adapter_type))
log.info("VirtualBox VM '{name}' [{id}]: adapter type changed to {adapter_type}".format(name=self.name,
id=self.id,
adapter_type=adapter_type))
@asyncio.coroutine
def _get_vm_info(self):
@@ -779,10 +778,10 @@ class VirtualBoxVM(BaseVM):
yield from self._control_vm("setlinkstate{} on".format(adapter_id + 1))
adapter.add_nio(0, nio)
log.info("VirtualBox VM '{name}' [{uuid}]: {nio} added to adapter {adapter_id}".format(name=self.name,
uuid=self.uuid,
nio=nio,
adapter_id=adapter_id))
log.info("VirtualBox VM '{name}' [{id}]: {nio} added to adapter {adapter_id}".format(name=self.name,
id=self.id,
nio=nio,
adapter_id=adapter_id))
@asyncio.coroutine
def port_remove_nio_binding(self, adapter_id):
@@ -811,10 +810,10 @@ class VirtualBoxVM(BaseVM):
self.manager.port_manager.release_udp_port(nio.lport)
adapter.remove_nio(0)
log.info("VirtualBox VM '{name}' [{uuid}]: {nio} removed from adapter {adapter_id}".format(name=self.name,
uuid=self.uuid,
nio=nio,
adapter_id=adapter_id))
log.info("VirtualBox VM '{name}' [{id}]: {nio} removed from adapter {adapter_id}".format(name=self.name,
id=self.id,
nio=nio,
adapter_id=adapter_id))
return nio
def start_capture(self, adapter_id, output_file):
@@ -836,9 +835,9 @@ class VirtualBoxVM(BaseVM):
raise VirtualBoxError("Packet capture is already activated on adapter {adapter_id}".format(adapter_id=adapter_id))
nio.startPacketCapture(output_file)
log.info("VirtualBox VM '{name}' [{uuid}]: starting packet capture on adapter {adapter_id}".format(name=self.name,
uuid=self.uuid,
adapter_id=adapter_id))
log.info("VirtualBox VM '{name}' [{id}]: starting packet capture on adapter {adapter_id}".format(name=self.name,
id=self.id,
adapter_id=adapter_id))
def stop_capture(self, adapter_id):
"""
@@ -856,6 +855,6 @@ class VirtualBoxVM(BaseVM):
nio = adapter.get_nio(0)
nio.stopPacketCapture()
log.info("VirtualBox VM '{name}' [{uuid}]: stopping packet capture on adapter {adapter_id}".format(name=self.name,
uuid=self.uuid,
adapter_id=adapter_id))
log.info("VirtualBox VM '{name}' [{id}]: stopping packet capture on adapter {adapter_id}".format(name=self.name,
id=self.id,
adapter_id=adapter_id))
+12 -12
View File
@@ -38,28 +38,28 @@ class VPCS(BaseManager):
def create_vm(self, *args, **kwargs):
vm = yield from super().create_vm(*args, **kwargs)
self._free_mac_ids.setdefault(vm.project.uuid, list(range(0, 255)))
self._free_mac_ids.setdefault(vm.project.id, list(range(0, 255)))
try:
self._used_mac_ids[vm.uuid] = self._free_mac_ids[vm.project.uuid].pop(0)
self._used_mac_ids[vm.id] = self._free_mac_ids[vm.project.id].pop(0)
except IndexError:
raise VPCSError("No mac address available")
return vm
@asyncio.coroutine
def delete_vm(self, uuid, *args, **kwargs):
def delete_vm(self, vm_id, *args, **kwargs):
vm = self.get_vm(uuid)
i = self._used_mac_ids[uuid]
self._free_mac_ids[vm.project.uuid].insert(0, i)
del self._used_mac_ids[uuid]
yield from super().delete_vm(uuid, *args, **kwargs)
vm = self.get_vm(vm_id)
i = self._used_mac_ids[vm_id]
self._free_mac_ids[vm.project.id].insert(0, i)
del self._used_mac_ids[vm_id]
yield from super().delete_vm(vm_id, *args, **kwargs)
def get_mac_id(self, vm_uuid):
def get_mac_id(self, vm_id):
"""
Get an unique VPCS mac id
:param vm_uuid: UUID of the VPCS vm
:returns: VPCS Mac id
:param vm_id: ID of the VPCS VM
:returns: VPCS MAC id
"""
return self._used_mac_ids.get(vm_uuid, 1)
return self._used_mac_ids.get(vm_id, 1)
+14 -14
View File
@@ -45,7 +45,7 @@ class VPCSVM(BaseVM):
VPCS vm implementation.
:param name: name of this VPCS vm
:param uuid: VPCS instance UUID
:param vm_id: VPCS instance identifier
:param project: Project instance
:param manager: parent VM Manager
:param console: TCP console port
@@ -53,9 +53,9 @@ class VPCSVM(BaseVM):
:param startup_script: Content of vpcs startup script file
"""
def __init__(self, name, uuid, project, manager, console=None, script_file=None, startup_script=None):
def __init__(self, name, vm_id, project, manager, console=None, script_file=None, startup_script=None):
super().__init__(name, uuid, project, manager)
super().__init__(name, vm_id, project, manager)
self._path = manager.config.get_section_config("VPCS").get("vpcs_path", "vpcs")
self._console = console
@@ -105,9 +105,9 @@ class VPCSVM(BaseVM):
def __json__(self):
return {"name": self.name,
"uuid": self.uuid,
"vm_id": self.id,
"console": self._console,
"project_id": self.project.uuid,
"project_id": self.project.id,
"script_file": self.script_file,
"startup_script": self.startup_script}
@@ -329,10 +329,10 @@ class VPCSVM(BaseVM):
port_number=port_number))
self._ethernet_adapter.add_nio(port_number, nio)
log.info("VPCS {name} {uuid}]: {nio} added to port {port_number}".format(name=self._name,
uuid=self.uuid,
nio=nio,
port_number=port_number))
log.info("VPCS {name} {id}]: {nio} added to port {port_number}".format(name=self._name,
id=self.id,
nio=nio,
port_number=port_number))
return nio
def port_remove_nio_binding(self, port_number):
@@ -353,10 +353,10 @@ class VPCSVM(BaseVM):
self.manager.port_manager.release_udp_port(nio.lport)
self._ethernet_adapter.remove_nio(port_number)
log.info("VPCS {name} [{uuid}]: {nio} removed from port {port_number}".format(name=self._name,
uuid=self.uuid,
nio=nio,
port_number=port_number))
log.info("VPCS {name} [{id}]: {nio} removed from port {port_number}".format(name=self._name,
id=self.id,
nio=nio,
port_number=port_number))
return nio
def _build_command(self):
@@ -411,7 +411,7 @@ class VPCSVM(BaseVM):
command.extend(["-e"])
command.extend(["-d", nio.tap_vm])
command.extend(["-m", str(self._manager.get_mac_id(self._uuid))]) # the unique ID is used to set the MAC address offset
command.extend(["-m", str(self._manager.get_mac_id(self.id))]) # the unique ID is used to set the MAC address offset
command.extend(["-i", "1"]) # option to start only one VPC instance
command.extend(["-F"]) # option to avoid the daemonization of VPCS
if self._script_file: