ananace / fog-hyperv

Hyper-V provider for fog
MIT License
8 stars 1 forks source link

Support boot order changes on generation 2 #13

Open ananace opened 7 years ago

ananace commented 7 years ago

Because of how UEFI handles the boot order, it's not as simple to change as it is on generation 1. (BIOS)

A thought would be to still read an array of enum values like the current BIOS config, and generate a PS script from that. The generated script for a call could then look something like;

firmware.boot_order = [{NetworkAdapter: '<NIC ID>'}, {VHD: '<HD ID>'}, :VHD]

# Or possibly with fog models instead;
firmware.boot_order = [network_adapter.first, hard_drive.get('New disk')]
$VM = Get-VM -VMId "<VM ID>"
$NICs = Get-VMNetworkAdapter -VM $VM
$VHDs = Get-VMHardDiskDrive -VM $VM

$Boot1 = $NICs | where Id -eq "<NIC ID>" # NetworkAdapter: '<NIC ID/Name/etc>'
$Boot2 = $VHDs | where Id -eq "<HD ID>"  # VHD: '<HD ID>/<Path>/<Controller number/etc>'
$Boot3 = $VHDs | select -First 1         # :VHD

Set-VMFirmware -BootOrder $Boot1, $Boot2, $Boot3