Class: OMF::SFA::Resource::Interface

Inherits:
OComponent show all
Defined in:
lib/omf-sfa/resource/interface.rb

Instance Method Summary collapse

Methods inherited from OComponent

#_from_sfa_exo_sliver__geni_sliver_info_property_xml, #clone, #component_name, #create_from_xml, #destroy, #destroy!, #update_from_xml

Methods included from Base::ClassMethods

#_sfa_add_ns, #_sfa_prefix_for_namespace, #_to_sfa_xml, #default_component_manager_id, #default_domain, #descendants, #from_sfa, #sfa, #sfa_add_namespace, #sfa_add_namespaces_to_document, #sfa_cast_property_value, #sfa_class, #sfa_def_for, #sfa_defs, #sfa_suppress_id, #sfa_suppress_id?, #sfa_suppress_uuid, #sfa_suppress_uuid?, #to_rspec

Methods included from Base::InstanceMethods

#_to_sfa_property_hash, #_to_sfa_xml, #_xml_name, #component_id, #component_manager_id, #default_domain, #from_sfa, #resource_type, #sfa_class, #sfa_id, #sfa_property, #to_sfa_hash, #to_sfa_hash_short, #to_sfa_short_xml, #to_sfa_xml

Methods inherited from OResource

#_dirty_self?, #_oprops_to_hash, #all_resources, #clone, #default_href_prefix, #destroy, #destroy!, #dirty_self?, #each_resource, #group?, #href, href_resolver, init, json_create, #oproperties_as_hash, #oproperty, oproperty, #oproperty_array_get, #oproperty_get, #oproperty_set, prop_all, #remove_from_all_groups, #resource_type, #status, #to_hash, #to_hash_brief, #to_hash_long, #to_json, #uuid

Instance Method Details

#_from_sfa_ip_property_xml(resource_el, props, context) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/omf-sfa/resource/interface.rb', line 56

def _from_sfa_ip_property_xml(resource_el, props, context)
  resource_el.children.each do |el|
    next unless el.is_a? Nokogiri::XML::Element
    next unless el.name == 'ip' # should check namespace as well

    unless address_attr = el.attributes['address']
      raise "Expected 'address' attr for ip in '#{el}'"
    end
    address = address_attr.value
    ip = self.ip_addresses.find do |r|
      r.address == address
    end
    unless ip
      # doesn't exist yet, create new one
      ip = Ip.new(:interface => self)
    end
    #puts "IP -----"
    ip.from_sfa(el)
    #puts "IP '#{ip.inspect}'"
    self.ip_addresses << ip
  end
end

#_to_sfa_property_xml(pname, value, res_el, pdef, obj2id, opts) ⇒ Object

Override xml serialization of ‘ip’



48
49
50
51
52
53
54
# File 'lib/omf-sfa/resource/interface.rb', line 48

def _to_sfa_property_xml(pname, value, res_el, pdef, obj2id, opts)
  if pname == 'ip'
    value.to_sfa_xml(res_el, obj2id, opts)
    return
  end
  super
end

#independent_component?Boolean

Returns:

  • (Boolean)

See Also:

  • IComponent


31
32
33
# File 'lib/omf-sfa/resource/interface.rb', line 31

def independent_component?
  false
end

#sliverObject



17
18
19
# File 'lib/omf-sfa/resource/interface.rb', line 17

def sliver
  node.sliver
end

#to_sfa_ref_xml(res_el, obj2id, opts) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/omf-sfa/resource/interface.rb', line 35

def to_sfa_ref_xml(res_el, obj2id, opts)
  #puts "IF_OPTS #{opts}"
  if obj2id.key?(self)
    el = res_el.add_child(Nokogiri::XML::Element.new('interface_ref', res_el.document))
    el.set_attribute('component_id', self.component_id.to_s) unless opts[:type] == :request
    #el.set_attribute('id_ref', self.uuid.to_s)
    el.set_attribute('client_id', self.component_name)
  else
    self.to_sfa_xml(res_el, obj2id, opts)
  end
end