class VirtualMachineDevice::Nic

Nic class

Public Class Methods

nic_model_class(nicmodel) click to toggle source
# File lib/vm_nic.rb, line 47
def self.nic_model_class(nicmodel)
    case nicmodel
    when 'virtuale1000', 'e1000'
        RbVmomi::VIM::VirtualE1000
    when 'virtuale1000e', 'e1000e'
        RbVmomi::VIM::VirtualE1000e
    when 'virtualpcnet32', 'pcnet32'
        RbVmomi::VIM::VirtualPCNet32
    when 'virtualsriovethernetcard', 'sriovethernetcard'
        RbVmomi::VIM::VirtualSriovEthernetCard
    when 'virtualvmxnetm', 'vmxnetm'
        RbVmomi::VIM::VirtualVmxnetm
    when 'virtualvmxnet2', 'vmnet2'
        RbVmomi::VIM::VirtualVmxnet2
    when 'virtualvmxnet3', 'vmxnet3'
        RbVmomi::VIM::VirtualVmxnet3
    else # If none matches, use vmxnet3
        RbVmomi::VIM::VirtualVmxnet3
    end
end
one_nic(id, one_res) click to toggle source

Create the OpenNebula nic representation Allow as to create the class without vCenter representation example: attached nics not synced with vCenter

# File lib/vm_nic.rb, line 24
def self.one_nic(id, one_res)
    new(id, one_res, nil)
end
vc_nic(vc_res) click to toggle source

Create the vCenter nic representation Allow as to create the class without OpenNebula representation example: detached nics that not exists in OpenNebula

# File lib/vm_nic.rb, line 31
def self.vc_nic(vc_res)
    new(nil, nil, vc_res)
end

Public Instance Methods

boot_dev() click to toggle source
# File lib/vm_nic.rb, line 40
def boot_dev
    RbVmomi::VIM
        .VirtualMachineBootOptionsBootableEthernetDevice(
            :deviceKey => key
        )
end
key() click to toggle source
# File lib/vm_nic.rb, line 35
def key
    raise_if_no_exists_in_vcenter
    @vc_res.key
end