class VCloudSdk::Xml::NicItemWrapper

Public Class Methods

new(item) click to toggle source
Calls superclass method VCloudSdk::Xml::Wrapper::new
# File lib/ruby_vcloud_sdk/xml/wrapper_classes/nic_item_wrapper.rb, line 5
def initialize(item)
  super(item.node, item.namespace, item.namespace_definitions)

  # Ensure the underlying XML has all the necessary RASD elements.
  # This is useful for NIC creation.
  # Should have no effect when receiving XML from VCD.
  [:ADDRESS_ON_PARENT, :CONNECTION, :INSTANCE_ID].each { |t|
    rt = RASD_TYPES[t]
    add_rasd(rt) unless get_rasd(rt) }

  rt = RASD_TYPES[:RESOURCE_SUB_TYPE]
  unless get_rasd(rt)
    add_rasd(rt)
    set_rasd(rt, RESOURCE_SUB_TYPE[:VMXNET3])
  end

  rt = RASD_TYPES[:RESOURCE_TYPE]
  unless get_rasd(rt)
    add_rasd(rt)
    set_rasd(rt, HARDWARE_TYPE[:NIC])
  end
end

Public Instance Methods

ip_addressing_mode() click to toggle source
# File lib/ruby_vcloud_sdk/xml/wrapper_classes/nic_item_wrapper.rb, line 46
def ip_addressing_mode
  attr = create_qualified_name("ipAddressingMode", VCLOUD_NAMESPACE)
  connection[attr]
end
is_primary() click to toggle source
# File lib/ruby_vcloud_sdk/xml/wrapper_classes/nic_item_wrapper.rb, line 28
def is_primary
  connection["primaryNetworkConnection"]
end
is_primary=(value) click to toggle source
# File lib/ruby_vcloud_sdk/xml/wrapper_classes/nic_item_wrapper.rb, line 32
def is_primary=(value)
  primary_attr = create_qualified_name("primaryNetworkConnection",
    VCLOUD_NAMESPACE)
  connection[primary_attr] = value.to_s
end
mac_address() click to toggle source
# File lib/ruby_vcloud_sdk/xml/wrapper_classes/nic_item_wrapper.rb, line 69
def mac_address
  get_rasd_content(RASD_TYPES[:ADDRESS])
end
network() click to toggle source
# File lib/ruby_vcloud_sdk/xml/wrapper_classes/nic_item_wrapper.rb, line 73
def network
  connection.content
end
network=(value) click to toggle source
# File lib/ruby_vcloud_sdk/xml/wrapper_classes/nic_item_wrapper.rb, line 77
def network=(value)
  connection.content = value
end
nic_index() click to toggle source
# File lib/ruby_vcloud_sdk/xml/wrapper_classes/nic_item_wrapper.rb, line 38
def nic_index
  get_rasd_content(RASD_TYPES[:ADDRESS_ON_PARENT])
end
nic_index=(value) click to toggle source
# File lib/ruby_vcloud_sdk/xml/wrapper_classes/nic_item_wrapper.rb, line 42
def nic_index=(value)
  set_rasd(RASD_TYPES[:ADDRESS_ON_PARENT], value)
end
set_ip_addressing_mode(mode, ip = nil) click to toggle source
# File lib/ruby_vcloud_sdk/xml/wrapper_classes/nic_item_wrapper.rb, line 51
def set_ip_addressing_mode(mode, ip = nil)
  unless IP_ADDRESSING_MODE.values.include?(mode)
    raise ArgumentError, "Invalid choice for IP addressing mode."
  end

  if ip && !ip_addressing_mode == IP_ADDRESSING_MODE[:MANUAL]
    raise ArgumentError,
      "Cannot set IP address unless IP addressing mode is MANUAL"
  end

  mode_attr = create_qualified_name("ipAddressingMode",
    VCLOUD_NAMESPACE)
  connection[mode_attr] = mode

  ip_attr =  create_qualified_name("ipAddress", VCLOUD_NAMESPACE)
  connection[ip_attr] = !ip.nil? ? ip : ""
end

Private Instance Methods

connection() click to toggle source
# File lib/ruby_vcloud_sdk/xml/wrapper_classes/nic_item_wrapper.rb, line 83
def connection
  get_rasd(RASD_TYPES[:CONNECTION])
end