mirror of
https://github.com/ComputerScienceHouse/proxstar.git
synced 2025-02-12 13:01:51 +00:00
Update boot device order parsing
Update boot order parsing so as to be compatible with the new Proxmox syntax for virtual machine boot device ordering. Maintain support for the deprecated boot device order syntax. Virtual machines using the deprecated syntax are not updated to use the new syntax.
This commit is contained in:
parent
ff094bc686
commit
c16c383b36
1 changed files with 22 additions and 5 deletions
|
@ -122,8 +122,21 @@ class VM:
|
||||||
boot_order_lookup = {'a': 'Floppy', 'c': 'Hard Disk', 'd': 'CD-ROM', 'n': 'Network'}
|
boot_order_lookup = {'a': 'Floppy', 'c': 'Hard Disk', 'd': 'CD-ROM', 'n': 'Network'}
|
||||||
raw_boot_order = self.config.get('boot', 'cdn')
|
raw_boot_order = self.config.get('boot', 'cdn')
|
||||||
boot_order = []
|
boot_order = []
|
||||||
for order in raw_boot_order:
|
try:
|
||||||
boot_order.append(boot_order_lookup[order])
|
# Check if new syntax
|
||||||
|
if raw_boot_order.startswith('order='):
|
||||||
|
for order in raw_boot_order[6:].split(';'):
|
||||||
|
boot_order.append(order)
|
||||||
|
# Check if legacy syntax
|
||||||
|
elif raw_boot_order.startswith('legacy='):
|
||||||
|
for order in raw_boot_order[7:]:
|
||||||
|
boot_order.append(boot_order_lookup[order])
|
||||||
|
# Assume legacy syntax
|
||||||
|
else:
|
||||||
|
for order in raw_boot_order:
|
||||||
|
boot_order.append(boot_order_lookup[order])
|
||||||
|
except:
|
||||||
|
return []
|
||||||
return boot_order
|
return boot_order
|
||||||
|
|
||||||
@lazy_property
|
@lazy_property
|
||||||
|
@ -134,9 +147,13 @@ class VM:
|
||||||
def set_boot_order(self, boot_order):
|
def set_boot_order(self, boot_order):
|
||||||
proxmox = connect_proxmox()
|
proxmox = connect_proxmox()
|
||||||
boot_order_lookup = {'Floppy': 'a', 'Hard Disk': 'c', 'CD-ROM': 'd', 'Network': 'n'}
|
boot_order_lookup = {'Floppy': 'a', 'Hard Disk': 'c', 'CD-ROM': 'd', 'Network': 'n'}
|
||||||
raw_boot_order = ''
|
# Check if legacy format
|
||||||
for order in boot_order:
|
if boot_order[0] in boot_order_lookup.keys():
|
||||||
raw_boot_order += boot_order_lookup[order]
|
raw_boot_order = ''
|
||||||
|
for order in boot_order:
|
||||||
|
raw_boot_order += boot_order_lookup[order]
|
||||||
|
else:
|
||||||
|
raw_boot_order = f"order={';'.join(boot_order)}"
|
||||||
proxmox.nodes(self.node).qemu(self.id).config.put(boot=raw_boot_order)
|
proxmox.nodes(self.node).qemu(self.id).config.put(boot=raw_boot_order)
|
||||||
|
|
||||||
@lazy_property
|
@lazy_property
|
||||||
|
|
Loading…
Reference in a new issue