mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 03:08:14 +00:00
Add explicit option to automatically create or not the config disk. Off by default.
(cherry picked from commit 56aba96a5f
)
This commit is contained in:
parent
9d3f7c79a2
commit
a56b816c1a
@ -122,6 +122,7 @@ class QemuVM(BaseNode):
|
|||||||
self._kernel_command_line = ""
|
self._kernel_command_line = ""
|
||||||
self._legacy_networking = False
|
self._legacy_networking = False
|
||||||
self._replicate_network_connection_state = True
|
self._replicate_network_connection_state = True
|
||||||
|
self._create_config_disk = False
|
||||||
self._on_close = "power_off"
|
self._on_close = "power_off"
|
||||||
self._cpu_throttling = 0 # means no CPU throttling
|
self._cpu_throttling = 0 # means no CPU throttling
|
||||||
self._process_priority = "low"
|
self._process_priority = "low"
|
||||||
@ -139,9 +140,8 @@ class QemuVM(BaseNode):
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
self.config_disk_image = self.manager.get_abs_image_path(self.config_disk_name)
|
self.config_disk_image = self.manager.get_abs_image_path(self.config_disk_name)
|
||||||
except (NodeError, ImageMissingError) as e:
|
except (NodeError, ImageMissingError):
|
||||||
log.warning("Config disk: image '{}' missing"
|
log.warning("Config disk: image '{}' missing".format(self.config_disk_name))
|
||||||
.format(self.config_disk_name))
|
|
||||||
self.config_disk_name = ""
|
self.config_disk_name = ""
|
||||||
|
|
||||||
log.info('QEMU VM "{name}" [{id}] has been created'.format(name=self._name, id=self._id))
|
log.info('QEMU VM "{name}" [{id}] has been created'.format(name=self._name, id=self._id))
|
||||||
@ -671,6 +671,30 @@ class QemuVM(BaseNode):
|
|||||||
log.info('QEMU VM "{name}" [{id}] has disabled network connection state replication'.format(name=self._name, id=self._id))
|
log.info('QEMU VM "{name}" [{id}] has disabled network connection state replication'.format(name=self._name, id=self._id))
|
||||||
self._replicate_network_connection_state = replicate_network_connection_state
|
self._replicate_network_connection_state = replicate_network_connection_state
|
||||||
|
|
||||||
|
@property
|
||||||
|
def create_config_disk(self):
|
||||||
|
"""
|
||||||
|
Returns whether a config disk is automatically created on HDD disk interface (secondary slave)
|
||||||
|
|
||||||
|
:returns: boolean
|
||||||
|
"""
|
||||||
|
|
||||||
|
return self._create_config_disk
|
||||||
|
|
||||||
|
@create_config_disk.setter
|
||||||
|
def create_config_disk(self, create_config_disk):
|
||||||
|
"""
|
||||||
|
Sets whether a config disk is automatically created on HDD disk interface (secondary slave)
|
||||||
|
|
||||||
|
:param replicate_network_connection_state: boolean
|
||||||
|
"""
|
||||||
|
|
||||||
|
if create_config_disk:
|
||||||
|
log.info('QEMU VM "{name}" [{id}] has enabled the config disk creation feature'.format(name=self._name, id=self._id))
|
||||||
|
else:
|
||||||
|
log.info('QEMU VM "{name}" [{id}] has disabled the config disk creation feature'.format(name=self._name, id=self._id))
|
||||||
|
self._create_config_disk = create_config_disk
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def on_close(self):
|
def on_close(self):
|
||||||
"""
|
"""
|
||||||
@ -1818,7 +1842,7 @@ class QemuVM(BaseNode):
|
|||||||
|
|
||||||
# config disk
|
# config disk
|
||||||
disk_image = getattr(self, "config_disk_image")
|
disk_image = getattr(self, "config_disk_image")
|
||||||
if disk_image:
|
if disk_image and self._create_config_disk:
|
||||||
if getattr(self, "_hdd_disk_image"):
|
if getattr(self, "_hdd_disk_image"):
|
||||||
log.warning("Config disk: blocked by disk image 'hdd'")
|
log.warning("Config disk: blocked by disk image 'hdd'")
|
||||||
else:
|
else:
|
||||||
@ -1837,6 +1861,7 @@ class QemuVM(BaseNode):
|
|||||||
log.warning("Could not create '{}' disk image: {}".format(disk_name, e))
|
log.warning("Could not create '{}' disk image: {}".format(disk_name, e))
|
||||||
if disk_exists:
|
if disk_exists:
|
||||||
options.extend(self._disk_interface_options(disk, 3, interface, "raw"))
|
options.extend(self._disk_interface_options(disk, 3, interface, "raw"))
|
||||||
|
self.hdd_disk_image = disk
|
||||||
|
|
||||||
return options
|
return options
|
||||||
|
|
||||||
|
@ -190,6 +190,10 @@ QEMU_CREATE_SCHEMA = {
|
|||||||
"description": "Replicate the network connection state for links in Qemu",
|
"description": "Replicate the network connection state for links in Qemu",
|
||||||
"type": ["boolean", "null"],
|
"type": ["boolean", "null"],
|
||||||
},
|
},
|
||||||
|
"create_config_disk": {
|
||||||
|
"description": "Automatically create a config disk on HDD disk interface (secondary slave)",
|
||||||
|
"type": ["boolean", "null"],
|
||||||
|
},
|
||||||
"on_close": {
|
"on_close": {
|
||||||
"description": "Action to execute on the VM is closed",
|
"description": "Action to execute on the VM is closed",
|
||||||
"enum": ["power_off", "shutdown_signal", "save_vm_state"],
|
"enum": ["power_off", "shutdown_signal", "save_vm_state"],
|
||||||
@ -380,6 +384,10 @@ QEMU_UPDATE_SCHEMA = {
|
|||||||
"description": "Replicate the network connection state for links in Qemu",
|
"description": "Replicate the network connection state for links in Qemu",
|
||||||
"type": ["boolean", "null"],
|
"type": ["boolean", "null"],
|
||||||
},
|
},
|
||||||
|
"create_config_disk": {
|
||||||
|
"description": "Automatically create a config disk on HDD disk interface (secondary slave)",
|
||||||
|
"type": ["boolean", "null"],
|
||||||
|
},
|
||||||
"on_close": {
|
"on_close": {
|
||||||
"description": "Action to execute on the VM is closed",
|
"description": "Action to execute on the VM is closed",
|
||||||
"enum": ["power_off", "shutdown_signal", "save_vm_state"],
|
"enum": ["power_off", "shutdown_signal", "save_vm_state"],
|
||||||
@ -583,6 +591,10 @@ QEMU_OBJECT_SCHEMA = {
|
|||||||
"description": "Replicate the network connection state for links in Qemu",
|
"description": "Replicate the network connection state for links in Qemu",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
},
|
},
|
||||||
|
"create_config_disk": {
|
||||||
|
"description": "Automatically create a config disk on HDD disk interface (secondary slave)",
|
||||||
|
"type": ["boolean", "null"],
|
||||||
|
},
|
||||||
"on_close": {
|
"on_close": {
|
||||||
"description": "Action to execute on the VM is closed",
|
"description": "Action to execute on the VM is closed",
|
||||||
"enum": ["power_off", "shutdown_signal", "save_vm_state"],
|
"enum": ["power_off", "shutdown_signal", "save_vm_state"],
|
||||||
@ -653,6 +665,7 @@ QEMU_OBJECT_SCHEMA = {
|
|||||||
"kernel_command_line",
|
"kernel_command_line",
|
||||||
"legacy_networking",
|
"legacy_networking",
|
||||||
"replicate_network_connection_state",
|
"replicate_network_connection_state",
|
||||||
|
"create_config_disk",
|
||||||
"on_close",
|
"on_close",
|
||||||
"cpu_throttling",
|
"cpu_throttling",
|
||||||
"process_priority",
|
"process_priority",
|
||||||
|
@ -183,6 +183,11 @@ QEMU_TEMPLATE_PROPERTIES = {
|
|||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": True
|
"default": True
|
||||||
},
|
},
|
||||||
|
"create_config_disk": {
|
||||||
|
"description": "Automatically create a config disk on HDD disk interface (secondary slave)",
|
||||||
|
"type": "boolean",
|
||||||
|
"default": True
|
||||||
|
},
|
||||||
"on_close": {
|
"on_close": {
|
||||||
"description": "Action to execute on the VM is closed",
|
"description": "Action to execute on the VM is closed",
|
||||||
"enum": ["power_off", "shutdown_signal", "save_vm_state"],
|
"enum": ["power_off", "shutdown_signal", "save_vm_state"],
|
||||||
|
Loading…
Reference in New Issue
Block a user