1
0
mirror of https://github.com/GNS3/gns3-server synced 2025-01-11 16:41:04 +00:00

ACPI shutdown support for VMware VMs. Fixes #436.

This commit is contained in:
Jeremy 2015-06-18 15:02:31 -06:00
parent 0a48fbe7e4
commit 11e96e6521
2 changed files with 44 additions and 1 deletions

View File

@ -71,6 +71,7 @@ class VMwareVM(BaseVM):
self._headless = False
self._vmx_path = vmx_path
self._enable_remote_console = False
self._acpi_shutdown = False
self._adapters = 0
self._ethernet_adapters = {}
self._adapter_type = "e1000"
@ -87,6 +88,7 @@ class VMwareVM(BaseVM):
"project_id": self.project.id,
"vmx_path": self.vmx_path,
"headless": self.headless,
"acpi_shutdown": self.acpi_shutdown,
"enable_remote_console": self.enable_remote_console,
"adapters": self._adapters,
"adapter_type": self.adapter_type,
@ -451,6 +453,10 @@ class VMwareVM(BaseVM):
self._ubridge_process = None
try:
if self.acpi_shutdown:
# use ACPI to shutdown the VM
yield from self._control_vm("stop", ["soft"])
else:
yield from self._control_vm("stop")
finally:
self._started = False
@ -537,6 +543,7 @@ class VMwareVM(BaseVM):
self.manager.port_manager.release_udp_port(nio.lport, self._project)
try:
self.acpi_shutdown = False
yield from self.stop()
except VMwareError:
pass
@ -595,6 +602,30 @@ class VMwareVM(BaseVM):
log.info("VMware VM '{name}' [{id}] has disabled the headless mode".format(name=self.name, id=self.id))
self._headless = headless
@property
def acpi_shutdown(self):
"""
Returns either the VM will use ACPI shutdown
:returns: boolean
"""
return self._acpi_shutdown
@acpi_shutdown.setter
def acpi_shutdown(self, acpi_shutdown):
"""
Sets either the VM will use ACPI shutdown
:param acpi_shutdown: boolean
"""
if acpi_shutdown:
log.info("VMware VM '{name}' [{id}] has enabled the ACPI shutdown mode".format(name=self.name, id=self.id))
else:
log.info("VMware VM '{name}' [{id}] has disabled the ACPI shutdown mode".format(name=self.name, id=self.id))
self._acpi_shutdown = acpi_shutdown
@property
def vmx_path(self):
"""

View File

@ -56,6 +56,10 @@ VMWARE_CREATE_SCHEMA = {
"description": "headless mode",
"type": "boolean"
},
"acpi_shutdown": {
"description": "ACPI shutdown",
"type": "boolean"
},
"adapters": {
"description": "number of adapters",
"type": "integer",
@ -105,6 +109,10 @@ VMWARE_UPDATE_SCHEMA = {
"description": "headless mode",
"type": "boolean"
},
"acpi_shutdown": {
"description": "ACPI shutdown",
"type": "boolean"
},
"adapters": {
"description": "number of adapters",
"type": "integer",
@ -161,6 +169,10 @@ VMWARE_OBJECT_SCHEMA = {
"description": "headless mode",
"type": "boolean"
},
"acpi_shutdown": {
"description": "ACPI shutdown",
"type": "boolean"
},
"adapters": {
"description": "number of adapters",
"type": "integer",