mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 17:28:08 +00:00
Support for base MAC address for Qemu VMs.
This commit is contained in:
parent
1c803f7afb
commit
37ddff9f07
@ -75,6 +75,7 @@ class QemuVM(BaseVM):
|
|||||||
self._hdb_disk_image = ""
|
self._hdb_disk_image = ""
|
||||||
self._hdc_disk_image = ""
|
self._hdc_disk_image = ""
|
||||||
self._hdd_disk_image = ""
|
self._hdd_disk_image = ""
|
||||||
|
self._mac_address = "00:00:ab:%s:%s:00" % (self.id[-4:-2], self.id[-2:])
|
||||||
self._options = ""
|
self._options = ""
|
||||||
self._ram = 256
|
self._ram = 256
|
||||||
self._ethernet_adapters = []
|
self._ethernet_adapters = []
|
||||||
@ -276,6 +277,31 @@ class QemuVM(BaseVM):
|
|||||||
id=self._id,
|
id=self._id,
|
||||||
adapter_type=adapter_type))
|
adapter_type=adapter_type))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def mac_address(self):
|
||||||
|
"""
|
||||||
|
Returns the MAC address for this QEMU VM.
|
||||||
|
|
||||||
|
:returns: adapter type (string)
|
||||||
|
"""
|
||||||
|
|
||||||
|
return self._mac_address
|
||||||
|
|
||||||
|
@mac_address.setter
|
||||||
|
def mac_address(self, mac_address):
|
||||||
|
"""
|
||||||
|
Sets the MAC address for this QEMU VM.
|
||||||
|
|
||||||
|
:param mac_address: MAC address
|
||||||
|
"""
|
||||||
|
|
||||||
|
self._mac_address = mac_address
|
||||||
|
|
||||||
|
log.info('QEMU VM "{name}" [{id}]: MAC address changed to {mac_addr}'.format(name=self._name,
|
||||||
|
id=self._id,
|
||||||
|
mac_addr=mac_address))
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def legacy_networking(self):
|
def legacy_networking(self):
|
||||||
"""
|
"""
|
||||||
@ -1033,8 +1059,7 @@ class QemuVM(BaseVM):
|
|||||||
network_options = []
|
network_options = []
|
||||||
network_options.extend(["-net", "none"]) # we do not want any user networking back-end if no adapter is connected.
|
network_options.extend(["-net", "none"]) # we do not want any user networking back-end if no adapter is connected.
|
||||||
for adapter_number, adapter in enumerate(self._ethernet_adapters):
|
for adapter_number, adapter in enumerate(self._ethernet_adapters):
|
||||||
# TODO: let users specify a base mac address
|
mac = "%s%02x" % (self._mac_address[:-2], (int(self._mac_address[-2:]) + adapter_number) % 255)
|
||||||
mac = "00:00:ab:%s:%s:%02x" % (self.id[-4:-2], self.id[-2:], adapter_number)
|
|
||||||
nio = adapter.get_nio(0)
|
nio = adapter.get_nio(0)
|
||||||
if self._legacy_networking:
|
if self._legacy_networking:
|
||||||
# legacy QEMU networking syntax (-net)
|
# legacy QEMU networking syntax (-net)
|
||||||
|
@ -78,6 +78,12 @@ QEMU_CREATE_SCHEMA = {
|
|||||||
"type": ["string", "null"],
|
"type": ["string", "null"],
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
},
|
},
|
||||||
|
"mac_address": {
|
||||||
|
"description": "QEMU MAC address",
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"minLength": 1,
|
||||||
|
"pattern": "^([0-9a-fA-F]{2}[:]){5}([0-9a-fA-F]{2})$"
|
||||||
|
},
|
||||||
"initrd": {
|
"initrd": {
|
||||||
"description": "QEMU initrd path",
|
"description": "QEMU initrd path",
|
||||||
"type": ["string", "null"],
|
"type": ["string", "null"],
|
||||||
@ -175,6 +181,12 @@ QEMU_UPDATE_SCHEMA = {
|
|||||||
"type": ["string", "null"],
|
"type": ["string", "null"],
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
},
|
},
|
||||||
|
"mac_address": {
|
||||||
|
"description": "QEMU MAC address",
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"minLength": 1,
|
||||||
|
"pattern": "^([0-9a-fA-F]{2}[:]){5}([0-9a-fA-F]{2})$"
|
||||||
|
},
|
||||||
"initrd": {
|
"initrd": {
|
||||||
"description": "QEMU initrd path",
|
"description": "QEMU initrd path",
|
||||||
"type": ["string", "null"],
|
"type": ["string", "null"],
|
||||||
@ -275,6 +287,12 @@ QEMU_OBJECT_SCHEMA = {
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
},
|
},
|
||||||
|
"mac_address": {
|
||||||
|
"description": "QEMU MAC address",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1,
|
||||||
|
"pattern": "^([0-9a-fA-F]{2}[:]){5}([0-9a-fA-F]{2})$"
|
||||||
|
},
|
||||||
"console": {
|
"console": {
|
||||||
"description": "console TCP port",
|
"description": "console TCP port",
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
@ -323,7 +341,7 @@ QEMU_OBJECT_SCHEMA = {
|
|||||||
},
|
},
|
||||||
"additionalProperties": False,
|
"additionalProperties": False,
|
||||||
"required": ["vm_id", "project_id", "name", "qemu_path", "hda_disk_image", "hdb_disk_image",
|
"required": ["vm_id", "project_id", "name", "qemu_path", "hda_disk_image", "hdb_disk_image",
|
||||||
"hdc_disk_image", "hdd_disk_image", "ram", "adapters", "adapter_type", "console",
|
"hdc_disk_image", "hdd_disk_image", "ram", "adapters", "adapter_type", "mac_address", "console",
|
||||||
"initrd", "kernel_image", "kernel_command_line", "legacy_networking", "acpi_shutdown",
|
"initrd", "kernel_image", "kernel_command_line", "legacy_networking", "acpi_shutdown",
|
||||||
"cpu_throttling", "process_priority", "options"]
|
"cpu_throttling", "process_priority", "options"]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user