Class: Junos::Ez::L1ports::Provider::CLASSIC
- Inherits:
-
Junos::Ez::L1ports::Provider
- Object
- Provider::Parent
- Junos::Ez::L1ports::Provider
- Junos::Ez::L1ports::Provider::CLASSIC
- Defined in:
- lib/junos-ez/l1_ports/classic.rb
Instance Attribute Summary
Attributes inherited from Provider::Parent
#catalog, #has, #list, #name, #ndev, #parent, #properties, #providers, #should
Instance Method Summary collapse
-
#xml_at_top ⇒ Object
————————————————————— XML top placement —————————————————————.
- #xml_change_duplex(xml) ⇒ Object
-
#xml_change_speed(xml) ⇒ Object
————————————————————— XML property writers —————————————————————.
- #xml_config_read! ⇒ Object
-
#xml_read_filter(xml) ⇒ Object
————————————————————— XML property readers —————————————————————.
- #xml_read_parser(as_xml, as_hash) ⇒ Object
Methods inherited from Junos::Ez::L1ports::Provider
#build_catalog, #build_list, #status, #xml_change_mtu, #xml_get_has_xml
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_element_newname, #xml_get_has_xml, #xml_on_create, #xml_on_delete
Constructor Details
This class inherits a constructor from Junos::Ez::Provider::Parent
Instance Method Details
#xml_at_top ⇒ Object
XML top placement
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/junos-ez/l1_ports/classic.rb', line 7 def xml_at_top xml = Nokogiri::XML::Builder.new {|xml| xml.configuration { xml.interfaces { xml.interface { xml.name @name return xml } } }} end |
#xml_change_duplex(xml) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/junos-ez/l1_ports/classic.rb', line 74 def xml_change_duplex( xml ) if @should[:duplex] == :auto unless is_new? xml.send( :'link-mode', Netconf::JunosConfig::DELETE ) end else xml.send( :'link-mode', case @should[:duplex] when :full then 'full-duplex' when :half then 'half-duplex' end ) end end |
#xml_change_speed(xml) ⇒ Object
XML property writers
64 65 66 67 68 69 70 71 72 |
# File 'lib/junos-ez/l1_ports/classic.rb', line 64 def xml_change_speed( xml ) if @should[:speed] == :auto if is_new? xml.speed Netconf::JunosConfig::DELETE end else xml.speed @should[:speed] end end |
#xml_config_read! ⇒ Object
31 32 33 34 35 |
# File 'lib/junos-ez/l1_ports/classic.rb', line 31 def xml_config_read! xml = xml_at_top xml_read_filter( xml ) @ndev.rpc.get_configuration( xml ) end |
#xml_read_filter(xml) ⇒ Object
XML property readers
22 23 24 25 26 27 28 29 |
# File 'lib/junos-ez/l1_ports/classic.rb', line 22 def xml_read_filter( xml ) xml.description xml.disable xml.mtu xml.speed xml.send(:'link-mode') xml.unit({:recurse => 'false'}) end |
#xml_read_parser(as_xml, as_hash) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/junos-ez/l1_ports/classic.rb', line 37 def xml_read_parser( as_xml, as_hash ) set_has_status( as_xml, as_hash ) as_hash[:admin] = as_xml.xpath('disable').empty? ? :up : :down unless (desc = as_xml.xpath('description').text.chomp).empty? as_hash[:description] = desc end if mtu = as_xml.xpath('mtu')[0]; as_hash[:mtu] = mtu.text.to_i end as_hash[:duplex] = case as_xml.xpath('link-mode').text.chomp when 'full-duplex' then :full when 'half-duplex' then :half else :auto end as_hash[:speed] = ( speed = as_xml.xpath('speed')[0] ) ? speed.text : :auto as_hash[:unit_count] = as_xml.xpath('unit').count return true end |