Class: Junos::Ez::Vlans::Provider::BRIDGE_DOMAIN
- Inherits:
-
Junos::Ez::Vlans::Provider
- Object
- Provider::Parent
- Junos::Ez::Vlans::Provider
- Junos::Ez::Vlans::Provider::BRIDGE_DOMAIN
- Defined in:
- lib/junos-ez/vlans/bridge_domain.rb,
lib/junos-ez/vlans/bridge_domain.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_description(xml) ⇒ Object
- #xml_change_no_mac_learning(xml) ⇒ Object
- #xml_change_vlan_id(xml) ⇒ Object
- #xml_get_has_xml(xml) ⇒ Object
-
#xml_on_create(xml) ⇒ Object
————————————————————— XML writers —————————————————————.
-
#xml_read! ⇒ Object
————————————————————— XML 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_config_read!, #xml_element_newname, #xml_on_delete
Constructor Details
This class inherits a constructor from Junos::Ez::Provider::Parent
Instance Method Details
#build_catalog ⇒ Object
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/junos-ez/vlans/bridge_domain.rb', line 77 def build_catalog @catalog = {} bd_cfgs = @ndev.rpc.get_configuration{ |x| x.send :'bridge-domains' } bd_cfgs.xpath('bridge-domains/domain').collect do |domain| name = domain.xpath('name').text @catalog[name] = {} xml_read_parser( domain, @catalog[name] ) end return @catalog end |
#build_list ⇒ Object
70 71 72 73 74 75 |
# File 'lib/junos-ez/vlans/bridge_domain.rb', line 70 def build_list bd_cfgs = @ndev.rpc.get_configuration{ |x| x.send :'bridge-domains' } bd_cfgs.xpath('bridge-domains/domain').collect do |domain| domain.xpath('name').text end end |
#xml_at_top ⇒ Object
XML top placement
7 8 9 10 11 12 13 |
# File 'lib/junos-ez/vlans/bridge_domain.rb', line 7 def xml_at_top Nokogiri::XML::Builder.new{|x| x.configuration{ x.send( :'bridge-domains' ) { x.domain { x.name @name return x }} }} end |
#xml_change_description(xml) ⇒ Object
57 58 59 |
# File 'lib/junos-ez/vlans/bridge_domain.rb', line 57 def xml_change_description( xml ) xml.description @should[:description] end |
#xml_change_no_mac_learning(xml) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/junos-ez/vlans/bridge_domain.rb', line 45 def xml_change_no_mac_learning( xml ) no_ml = @should[:no_mac_learning] return unless ( exists? and no_ml ) xml.send(:'bridge-options') { xml.send(:'no-mac-learning', (no_ml == :enable) ? nil : Netconf::JunosConfig::DELETE ) } end |
#xml_change_vlan_id(xml) ⇒ Object
53 54 55 |
# File 'lib/junos-ez/vlans/bridge_domain.rb', line 53 def xml_change_vlan_id( xml ) xml.send( :'vlan-id', @should[:vlan_id] ) end |
#xml_get_has_xml(xml) ⇒ Object
25 26 27 |
# File 'lib/junos-ez/vlans/bridge_domain.rb', line 25 def xml_get_has_xml( xml ) xml.xpath('//domain')[0] end |
#xml_on_create(xml) ⇒ Object
XML writers
41 42 43 |
# File 'lib/junos-ez/vlans/bridge_domain.rb', line 41 def xml_on_create( xml ) xml.send( :'domain-type', 'bridge' ) end |
#xml_read! ⇒ Object
XML readers
19 20 21 22 23 |
# File 'lib/junos-ez/vlans/bridge_domain.rb', line 19 def xml_read! cfg_xml = @ndev.rpc.get_configuration( xml_at_top ) return nil unless (@has_xml = cfg_xml.xpath('//domain')[0]) xml_read_parser( @has_xml, @has ) end |
#xml_read_parser(as_xml, as_hash) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/junos-ez/vlans/bridge_domain.rb', line 29 def xml_read_parser( as_xml, as_hash ) set_has_status( as_xml, as_hash ) as_hash[:vlan_id] = as_xml.xpath('vlan-id').text.to_i as_hash[:description] = as_xml.xpath('description').text as_hash[:no_mac_learning] = as_xml.xpath('bridge-options/no-mac-learning').empty? ? :disable : :enable return true end |