Class: Junos::Ez::StaticHosts::Provider
- Inherits:
-
Provider::Parent
- Object
- Provider::Parent
- Junos::Ez::StaticHosts::Provider
- Defined in:
- lib/junos-ez/system/st_hosts.rb,
lib/junos-ez/system/st_hosts.rb,
lib/junos-ez/system/st_hosts.rb
Overview
Provider collection methods
Instance Attribute Summary
Attributes inherited from Provider::Parent
#catalog, #has, #list, #name, #ndev, #parent, #properties, #providers, #should
Instance Method Summary collapse
- #build_catalog ⇒ Object
- #build_list ⇒ Object
-
#xml_at_top ⇒ Object
————————————————————— XML top placement —————————————————————.
-
#xml_change_ip(xml) ⇒ Object
————————————————————— XML property writers —————————————————————.
- #xml_change_ip6(xml) ⇒ Object
-
#xml_get_has_xml(xml) ⇒ Object
————————————————————— XML property readers —————————————————————.
- #xml_read_parser(as_xml, as_hash) ⇒ Object
Methods inherited from Provider::Parent
#[], #[]=, #activate!, #active?, #catalog!, #create, #create!, #create_from_hash!, #create_from_yaml!, #deactivate!, #delete!, #each, #exists?, #init_has, #initialize, #is_new?, #is_provider?, #list!, #name_decorated, #need_write?, #read!, #rename!, #reorder!, #select, #to_h, #to_h_expanded, #to_yaml, #with, #write!, #xml_at_edit, #xml_build_change, #xml_change__active, #xml_change__exist, #xml_change_admin, #xml_change_description, #xml_config_read!, #xml_element_newname, #xml_on_create, #xml_on_delete
Constructor Details
This class inherits a constructor from Junos::Ez::Provider::Parent
Instance Method Details
#build_catalog ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/junos-ez/system/st_hosts.rb', line 80 def build_catalog @catalog = {} @ndev.rpc.get_configuration{ |xml| xml.system { xml.send(:'static-host-mapping') }}.xpath('system/static-host-mapping').each do |item| name = item.xpath('name').text @catalog[name] = {} xml_read_parser( item, @catalog[name] ) end @catalog end |
#build_list ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/junos-ez/system/st_hosts.rb', line 72 def build_list @ndev.rpc.get_configuration{|xml| xml.system { xml.send(:'static-host-mapping') }}.xpath('system/static-host-mapping/name').collect do |item| item.text end end |
#xml_at_top ⇒ Object
XML top placement
25 26 27 28 29 30 31 32 |
# File 'lib/junos-ez/system/st_hosts.rb', line 25 def xml_at_top xml = Nokogiri::XML::Builder.new {|xml| xml.configuration { xml.system { xml.send('static-host-mapping') { xml.name @name return xml }} }} end |
#xml_change_ip(xml) ⇒ Object
XML property writers
56 57 58 |
# File 'lib/junos-ez/system/st_hosts.rb', line 56 def xml_change_ip( xml ) xml_set_or_delete( xml, 'inet', @should[:ip] ) end |
#xml_change_ip6(xml) ⇒ Object
60 61 62 |
# File 'lib/junos-ez/system/st_hosts.rb', line 60 def xml_change_ip6( xml ) xml_set_or_delete( xml, 'inet6', @should[:ip6] ) end |
#xml_get_has_xml(xml) ⇒ Object
XML property readers
38 39 40 |
# File 'lib/junos-ez/system/st_hosts.rb', line 38 def xml_get_has_xml( xml ) xml.xpath('//static-host-mapping')[0] end |
#xml_read_parser(as_xml, as_hash) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/junos-ez/system/st_hosts.rb', line 42 def xml_read_parser( as_xml, as_hash ) set_has_status( as_xml, as_hash ) ip_v4 = as_xml.xpath('inet').text as_hash[:ip] = ip_v4 unless ip_v4.empty? ip_v6 = as_xml.xpath('inet6').text as_hash[:ip6] = ip_v6 unless ip_v6.empty? end |