Class: Junos::Ez::Vlans::Provider::BRIDGE_DOMAIN

Inherits:
Junos::Ez::Vlans::Provider show all
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

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_get_has_xml, #xml_on_delete

Constructor Details

This class inherits a constructor from Junos::Ez::Provider::Parent

Instance Method Details

#build_catalogObject



73
74
75
76
77
78
79
80
81
82
# File 'lib/junos-ez/vlans/bridge_domain.rb', line 73

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_listObject



66
67
68
69
70
71
# File 'lib/junos-ez/vlans/bridge_domain.rb', line 66

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_topObject


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



53
54
55
# File 'lib/junos-ez/vlans/bridge_domain.rb', line 53

def xml_change_description( xml )
  xml.description @should[:description]
end

#xml_change_no_mac_learning(xml) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/junos-ez/vlans/bridge_domain.rb', line 41

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 ? nil : Netconf::JunosConfig::DELETE )
  }    
end

#xml_change_vlan_id(xml) ⇒ Object



49
50
51
# File 'lib/junos-ez/vlans/bridge_domain.rb', line 49

def xml_change_vlan_id( xml )
  xml.send( :'vlan-id', @should[:vlan_id] )
end

#xml_on_create(xml) ⇒ Object


XML writers




37
38
39
# File 'lib/junos-ez/vlans/bridge_domain.rb', line 37

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



25
26
27
28
29
30
31
# File 'lib/junos-ez/vlans/bridge_domain.rb', line 25

def xml_read_parser( as_xml, as_hash )
  status_from_junos( 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? ? false : true    
  return true    
end