Class: Junos::Ez::StaticRoutes::Provider
- Inherits:
-
Provider::Parent
show all
- Defined in:
- lib/junos-ez/system/st_routes.rb,
lib/junos-ez/system/st_routes.rb,
lib/junos-ez/system/st_routes.rb
Overview
Provider collection methods
Instance Attribute Summary
#catalog, #has, #list, #name, #ndev, #parent, #properties, #providers, #should
Instance Method Summary
collapse
#[], #[]=, #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
Instance Method Details
#build_catalog ⇒ Object
154
155
156
157
|
# File 'lib/junos-ez/system/st_routes.rb', line 154
def build_catalog
@catalog = {}
@catalog
end
|
#build_list ⇒ Object
146
147
148
149
150
151
152
|
# File 'lib/junos-ez/system/st_routes.rb', line 146
def build_list
@ndev.rpc.get_configuration{|xml| xml.send(:'routing-options') {
xml.static { xml.route }
}}.xpath('//route/name').collect do |item|
item.text
end
end
|
#xml_at_top ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/junos-ez/system/st_routes.rb', line 31
def xml_at_top
@name = "0.0.0.0/0" if @name == :default
Nokogiri::XML::Builder.new {|xml| xml.configuration {
xml.send('routing-options') {
xml.static { xml.route {
xml.name @name
return xml
}}
}
}}
end
|
#xml_change_action(xml) ⇒ Object
87
88
89
90
91
92
93
94
95
|
# File 'lib/junos-ez/system/st_routes.rb', line 87
def xml_change_action( xml )
if @should[:action].nil?
xml.send( @has[:action], Netconf::JunosConfig::DELETE )
return true
end
xml.send( @should[:action] )
end
|
#xml_change_active(xml) ⇒ Object
97
98
99
|
# File 'lib/junos-ez/system/st_routes.rb', line 97
def xml_change_active( xml )
xml_set_or_delete_element( xml, 'active', @should[:active] )
end
|
#xml_change_gateway(xml) ⇒ Object
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/junos-ez/system/st_routes.rb', line 101
def xml_change_gateway( xml )
ele_nh = :'next-hop'
xml.send(ele_nh, Netconf::JunosConfig::DELETE) if @has[:gateway]
return true unless @should[:gateway]
if @should[:gateway].kind_of? String
xml.send( ele_nh, @should[:gateway] )
else
@should[:gateway].each{ |gw| xml.send( ele_nh, gw ) }
end
end
|
#xml_change_install(xml) ⇒ Object
121
122
123
|
# File 'lib/junos-ez/system/st_routes.rb', line 121
def xml_change_install( xml )
xml_set_or_delete_noele( xml, 'install' )
end
|
#xml_change_metric(xml) ⇒ Object
133
134
135
|
# File 'lib/junos-ez/system/st_routes.rb', line 133
def xml_change_metric( xml )
xml_set_or_delete( xml, 'metric', @should[:metric] )
end
|
#xml_change_readvertise(xml) ⇒ Object
129
130
131
|
# File 'lib/junos-ez/system/st_routes.rb', line 129
def xml_change_readvertise( xml )
xml_set_or_delete_noele( xml, 'readvertise' )
end
|
#xml_change_resolve(xml) ⇒ Object
125
126
127
|
# File 'lib/junos-ez/system/st_routes.rb', line 125
def xml_change_resolve( xml )
xml_set_or_delete_noele( xml, 'resolve' )
end
|
#xml_change_retain(xml) ⇒ Object
117
118
119
|
# File 'lib/junos-ez/system/st_routes.rb', line 117
def xml_change_retain( xml )
xml_set_or_delete_noele( xml, 'retain' )
end
|
#xml_get_has_xml(xml) ⇒ Object
48
49
50
|
# File 'lib/junos-ez/system/st_routes.rb', line 48
def xml_get_has_xml( xml )
xml.xpath('routing-options/static/route')[0]
end
|
#xml_read_parser(as_xml, as_hash) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/junos-ez/system/st_routes.rb', line 52
def xml_read_parser( as_xml, as_hash )
set_has_status( as_xml, as_hash )
unless (next_hop = as_xml.xpath('next-hop')).empty?
if next_hop.count == 1
as_hash[:gateway] = next_hop.text
else
as_hash[:gateway] = next_hop.collect{|i| i.text }
end
end
unless (active = as_xml.xpath('active')).empty?
as_hash[:active] = true
end
unless (action = as_xml.xpath( 'reject | discard | receive' )).empty?
as_hash[:action] = action[0].name.to_sym
end
unless (metric = as_xml.xpath('metric')).empty?
as_hash[:metric] = metric.text.to_i
end
xml_read_parse_noele( as_xml, 'retain', as_hash, :retain )
xml_read_parse_noele( as_xml, 'install', as_hash, :install )
xml_read_parse_noele( as_xml, 'resolve', as_hash, :resolve )
xml_read_parse_noele( as_xml, 'readvertise', as_hash, :readvertise )
end
|