mirror of
https://github.com/ComputerScienceHouse/proxstar.git
synced 2025-02-14 14:01:51 +00:00
Propose new boot order to users
Propose new boot order to owners of VMs that exist on nodes running Proxmox version 6.3 or greater. Instead of returning the legacy boot order to the UI, a new boot order is created and sent instead. The new order mimics the old order, but is compliant with the new format. The new order will take effect only if the user explicitly updates.
This commit is contained in:
parent
27a6b2136e
commit
6da1095d1c
1 changed files with 30 additions and 9 deletions
|
@ -119,19 +119,40 @@ class VM:
|
|||
|
||||
@lazy_property
|
||||
def boot_order(self):
|
||||
proxmox = connect_proxmox()
|
||||
boot_order_lookup = {'a': 'Floppy', 'c': 'Hard Disk', 'd': 'CD-ROM', 'n': 'Network'}
|
||||
raw_boot_order = self.config.get('boot', 'cdn')
|
||||
boot_order = []
|
||||
try:
|
||||
# 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
|
||||
# If proxmox version supports 'order=' format
|
||||
if float(proxmox.nodes(self.node).version.get()['release']) >= 6.3:
|
||||
# Currently using 'order=' format
|
||||
if raw_boot_order.startswith('order='):
|
||||
# Add enabled boot devices
|
||||
for order in raw_boot_order[6:].split(';'):
|
||||
boot_order.append(order)
|
||||
# Add disabled boot devices
|
||||
for device in self.cdroms + [disk[0] for disk in self.disks] + [net[0] for net in self.interfaces]:
|
||||
if device not in boot_order:
|
||||
boot_order.append(device)
|
||||
# Currently using legacy format
|
||||
# Propose updating to the new format
|
||||
else:
|
||||
if raw_boot_order.startswith('legacy='):
|
||||
raw_boot_order = raw_boot_order[7:]
|
||||
# Arrange boot devices according to current format
|
||||
for order in raw_boot_order:
|
||||
if order == 'c':
|
||||
disks = [disk[0] for disk in self.disks]
|
||||
if self.config.get('bootdisk'):
|
||||
boot_order.append(self.config['bootdisk'])
|
||||
disks.remove(self.config['bootdisk'])
|
||||
boot_order.extend(disks)
|
||||
elif order == 'd':
|
||||
boot_order.extend(self.cdroms)
|
||||
elif order == 'n':
|
||||
boot_order.extend([net[0] for net in self.interfaces])
|
||||
# Proxmox version does not support 'order=' format
|
||||
else:
|
||||
for order in raw_boot_order:
|
||||
boot_order.append(boot_order_lookup[order])
|
||||
|
|
Loading…
Reference in a new issue