diff --git a/lib/VMwareWebService/MiqVimVm.rb b/lib/VMwareWebService/MiqVimVm.rb index 9e4c3c8..2ea25da 100644 --- a/lib/VMwareWebService/MiqVimVm.rb +++ b/lib/VMwareWebService/MiqVimVm.rb @@ -21,8 +21,13 @@ class MiqVimVm VIRTUAL_SCSI_CONTROLLERS = %w( VirtualBusLogicController VirtualLsiLogicController VirtualLsiLogicSASController - ParaVirtualSCSIController - ).freeze + ParaVirtualSCSIController ).freeze + VIRTUAL_NICS = %w( VirtualE1000 + VirtualE1000e + VirtualPCNet32 + VirtualVmxnet + VirtualVmxnet2 + VirtualVmxnet3 ).freeze MAX_SCSI_DEVICES = 15 MAX_SCSI_CONTROLLERS = 4 @@ -925,6 +930,20 @@ def getDeviceKeysByBacking(backingFile, hardware = nil) ([nil, nil]) end # def getDeviceKeysByBacking + def getDeviceKeysByLabel(device_label) + hardware = getHardware + hardware["device"].to_a.each do |dev| + next unless VIRTUAL_NICS.include?(dev.xsiType) + next unless dev["deviceInfo"]["label"] == device_label + controller_key = dev["controllerKey"] + key = dev["key"] + unit_number = dev["unitNumber"] + return controller_key, key, unit_number + end + # controller_key, key, unit_number + [nil, nil, nil] + end + ##################### # Miq Alarm methods. #####################