Skip to content

Commit

Permalink
Refs fog#193 - retrieve boot_order
Browse files Browse the repository at this point in the history
  • Loading branch information
ezr-ondrej committed Mar 23, 2019
1 parent 86e938d commit 21dce2b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/fog/vsphere/compute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ module Shared
cpuHotAddEnabled: 'config.cpuHotAddEnabled',
memoryHotAddEnabled: 'config.memoryHotAddEnabled',
firmware: 'config.firmware',
boot_order: 'config.bootOptions.bootOrder',
annotation: 'config.annotation'
}.freeze

Expand Down Expand Up @@ -198,6 +199,8 @@ def props_to_attr_hash(vm_mob_ref, props)
attrs['mo_ref'] = vm_mob_ref._ref
# The name method "magically" appears after a VM is ready and
# finished cloning.
attrs['boot_order'] = parse_boot_order(attrs['boot_order'])

if attrs['hypervisor'].is_a?(RbVmomi::VIM::HostSystem)
host = attrs['hypervisor']

Expand Down Expand Up @@ -284,6 +287,24 @@ def parent_attribute(path, type)
nil
end

# Maps RbVmomi boot order values to fog understandable strings.
# Result is uniqued, what effectively means that the order is defined by the first occurence.
def parse_boot_order(vm_boot_devs)
return unless values.is_a?(Array)
vm_boot_devs.map do |vm_boot_dev|
case vm_boot_dev
when RbVmomi::VIM::VirtualMachineBootOptionsBootableEthernetDevice
'network'
when RbVmomi::VIM::VirtualMachineBootOptionsBootableDiskDevice
'disk'
when RbVmomi::VIM::VirtualMachineBootOptionsBootableCdromDevice
'cdrom'
when RbVmomi::VIM::VirtualMachineBootOptionsBootableFloppyDevice
'floppy'
end
end.compact.uniq
end

# returns vmware managed obj id string
def managed_obj_id(obj)
obj.to_s.match(/\("([^"]+)"\)/)[1]
Expand Down
1 change: 1 addition & 0 deletions lib/fog/vsphere/models/compute/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class Server < Fog::Compute::Server
attribute :cpuHotAddEnabled
attribute :memoryHotAddEnabled
attribute :firmware
attribute :boot_order
attribute :annotation

def initialize(attributes = {})
Expand Down

0 comments on commit 21dce2b

Please sign in to comment.