mirror of
https://github.com/GNS3/gns3-server
synced 2025-05-25 18:28:52 +00:00
ACPI shutdown support for VMware VMs. Fixes #436.
This commit is contained in:
parent
0a48fbe7e4
commit
11e96e6521
@ -71,6 +71,7 @@ class VMwareVM(BaseVM):
|
|||||||
self._headless = False
|
self._headless = False
|
||||||
self._vmx_path = vmx_path
|
self._vmx_path = vmx_path
|
||||||
self._enable_remote_console = False
|
self._enable_remote_console = False
|
||||||
|
self._acpi_shutdown = False
|
||||||
self._adapters = 0
|
self._adapters = 0
|
||||||
self._ethernet_adapters = {}
|
self._ethernet_adapters = {}
|
||||||
self._adapter_type = "e1000"
|
self._adapter_type = "e1000"
|
||||||
@ -87,6 +88,7 @@ class VMwareVM(BaseVM):
|
|||||||
"project_id": self.project.id,
|
"project_id": self.project.id,
|
||||||
"vmx_path": self.vmx_path,
|
"vmx_path": self.vmx_path,
|
||||||
"headless": self.headless,
|
"headless": self.headless,
|
||||||
|
"acpi_shutdown": self.acpi_shutdown,
|
||||||
"enable_remote_console": self.enable_remote_console,
|
"enable_remote_console": self.enable_remote_console,
|
||||||
"adapters": self._adapters,
|
"adapters": self._adapters,
|
||||||
"adapter_type": self.adapter_type,
|
"adapter_type": self.adapter_type,
|
||||||
@ -451,6 +453,10 @@ class VMwareVM(BaseVM):
|
|||||||
self._ubridge_process = None
|
self._ubridge_process = None
|
||||||
|
|
||||||
try:
|
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")
|
yield from self._control_vm("stop")
|
||||||
finally:
|
finally:
|
||||||
self._started = False
|
self._started = False
|
||||||
@ -537,6 +543,7 @@ class VMwareVM(BaseVM):
|
|||||||
self.manager.port_manager.release_udp_port(nio.lport, self._project)
|
self.manager.port_manager.release_udp_port(nio.lport, self._project)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
self.acpi_shutdown = False
|
||||||
yield from self.stop()
|
yield from self.stop()
|
||||||
except VMwareError:
|
except VMwareError:
|
||||||
pass
|
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))
|
log.info("VMware VM '{name}' [{id}] has disabled the headless mode".format(name=self.name, id=self.id))
|
||||||
self._headless = headless
|
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
|
@property
|
||||||
def vmx_path(self):
|
def vmx_path(self):
|
||||||
"""
|
"""
|
||||||
|
@ -56,6 +56,10 @@ VMWARE_CREATE_SCHEMA = {
|
|||||||
"description": "headless mode",
|
"description": "headless mode",
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
|
"acpi_shutdown": {
|
||||||
|
"description": "ACPI shutdown",
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
"adapters": {
|
"adapters": {
|
||||||
"description": "number of adapters",
|
"description": "number of adapters",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
@ -105,6 +109,10 @@ VMWARE_UPDATE_SCHEMA = {
|
|||||||
"description": "headless mode",
|
"description": "headless mode",
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
|
"acpi_shutdown": {
|
||||||
|
"description": "ACPI shutdown",
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
"adapters": {
|
"adapters": {
|
||||||
"description": "number of adapters",
|
"description": "number of adapters",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
@ -161,6 +169,10 @@ VMWARE_OBJECT_SCHEMA = {
|
|||||||
"description": "headless mode",
|
"description": "headless mode",
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
|
"acpi_shutdown": {
|
||||||
|
"description": "ACPI shutdown",
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
"adapters": {
|
"adapters": {
|
||||||
"description": "number of adapters",
|
"description": "number of adapters",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
|
Loading…
Reference in New Issue
Block a user