Class: Cisco::Vrf
Overview
Vrf - node utility class for VRF configuration management
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from NodeUtil
client, #client, config_get, #config_get, #config_get_default, config_get_default, config_set, #config_set, #get, #ios_xr?, #nexus?, #node, node, platform, #platform, supports?, #supports?
Constructor Details
#initialize(name, instantiate = true) ⇒ Vrf
Returns a new instance of Vrf.
27
28
29
30
31
|
# File 'lib/cisco_node_utils/vrf.rb', line 27
def initialize(name, instantiate=true)
fail TypeError unless name.is_a?(String)
@name = name.downcase.strip
create if instantiate
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
25
26
27
|
# File 'lib/cisco_node_utils/vrf.rb', line 25
def name
@name
end
|
Class Method Details
.vrfs ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/cisco_node_utils/vrf.rb', line 37
def self.vrfs
hash = {}
vrf_list = config_get('vrf', 'all_vrfs')
return hash if vrf_list.nil?
vrf_list.each do |id|
id = id.downcase.strip
hash[id] = Vrf.new(id, false)
end
hash
end
|
Instance Method Details
#create ⇒ Object
49
50
51
|
# File 'lib/cisco_node_utils/vrf.rb', line 49
def create
config_set('vrf', 'create', vrf: @name)
end
|
#default_description ⇒ Object
72
73
74
|
# File 'lib/cisco_node_utils/vrf.rb', line 72
def default_description
config_get_default('vrf', 'description')
end
|
#default_mhost_ipv4_default_interface ⇒ Object
84
85
86
|
# File 'lib/cisco_node_utils/vrf.rb', line 84
def default_mhost_ipv4_default_interface
config_get_default('vrf', 'mhost_default_interface')
end
|
#default_mhost_ipv6_default_interface ⇒ Object
96
97
98
|
# File 'lib/cisco_node_utils/vrf.rb', line 96
def default_mhost_ipv6_default_interface
config_get_default('vrf', 'mhost_default_interface')
end
|
#default_remote_route_filtering ⇒ Object
117
118
119
|
# File 'lib/cisco_node_utils/vrf.rb', line 117
def default_remote_route_filtering
config_get_default('vrf', 'remote_route_filtering')
end
|
#default_route_distinguisher ⇒ Object
158
159
160
|
# File 'lib/cisco_node_utils/vrf.rb', line 158
def default_route_distinguisher
config_get_default('vrf', 'route_distinguisher')
end
|
#default_shutdown ⇒ Object
130
131
132
|
# File 'lib/cisco_node_utils/vrf.rb', line 130
def default_shutdown
config_get_default('vrf', 'shutdown')
end
|
#default_vni ⇒ Object
174
175
176
|
# File 'lib/cisco_node_utils/vrf.rb', line 174
def default_vni
config_get_default('vrf', 'vni')
end
|
#default_vpn_id ⇒ Object
188
189
190
|
# File 'lib/cisco_node_utils/vrf.rb', line 188
def default_vpn_id
config_get_default('vrf', 'vpn_id')
end
|
#description ⇒ Object
61
62
63
|
# File 'lib/cisco_node_utils/vrf.rb', line 61
def description
config_get('vrf', 'description', vrf: @name)
end
|
#description=(desc) ⇒ Object
65
66
67
68
69
70
|
# File 'lib/cisco_node_utils/vrf.rb', line 65
def description=(desc)
fail TypeError unless desc.is_a?(String)
desc.strip!
no_cmd = desc.empty? ? 'no' : ''
config_set('vrf', 'description', vrf: @name, state: no_cmd, desc: desc)
end
|
#destroy ⇒ Object
53
54
55
|
# File 'lib/cisco_node_utils/vrf.rb', line 53
def destroy
config_set('vrf', 'destroy', vrf: @name)
end
|
#mhost_default_interface_setter_helper(afi, val) ⇒ Object
100
101
102
103
104
105
|
# File 'lib/cisco_node_utils/vrf.rb', line 100
def mhost_default_interface_setter_helper(afi, val)
val.strip!
no_cmd = val.empty? ? 'no' : ''
config_set('vrf', 'mhost_default_interface', vrf: @name,
state: no_cmd, afi: afi, intf: val)
end
|
#mhost_ipv4_default_interface ⇒ Object
76
77
78
|
# File 'lib/cisco_node_utils/vrf.rb', line 76
def mhost_ipv4_default_interface
config_get('vrf', 'mhost_default_interface', vrf: @name, afi: 'ipv4')
end
|
#mhost_ipv4_default_interface=(val) ⇒ Object
80
81
82
|
# File 'lib/cisco_node_utils/vrf.rb', line 80
def mhost_ipv4_default_interface=(val)
mhost_default_interface_setter_helper('ipv4', val)
end
|
#mhost_ipv6_default_interface ⇒ Object
88
89
90
|
# File 'lib/cisco_node_utils/vrf.rb', line 88
def mhost_ipv6_default_interface
config_get('vrf', 'mhost_default_interface', vrf: @name, afi: 'ipv6')
end
|
#mhost_ipv6_default_interface=(val) ⇒ Object
92
93
94
|
# File 'lib/cisco_node_utils/vrf.rb', line 92
def mhost_ipv6_default_interface=(val)
mhost_default_interface_setter_helper('ipv6', val)
end
|
#remote_route_filtering ⇒ Object
107
108
109
|
# File 'lib/cisco_node_utils/vrf.rb', line 107
def remote_route_filtering
config_get('vrf', 'remote_route_filtering', vrf: @name)
end
|
#remote_route_filtering=(val) ⇒ Object
111
112
113
114
115
|
# File 'lib/cisco_node_utils/vrf.rb', line 111
def remote_route_filtering=(val)
no_cmd = val ? 'no' : ''
config_set('vrf', 'remote_route_filtering', vrf: @name,
state: no_cmd, remote_route_filtering: val)
end
|
#route_distinguisher ⇒ Object
route_distinguisher Note that this property is supported by both bgp and vrf providers.
136
137
138
|
# File 'lib/cisco_node_utils/vrf.rb', line 136
def route_distinguisher
config_get('vrf', 'route_distinguisher', vrf: @name)
end
|
#route_distinguisher=(rd) ⇒ Object
#shutdown ⇒ Object
121
122
123
|
# File 'lib/cisco_node_utils/vrf.rb', line 121
def shutdown
config_get('vrf', 'shutdown', vrf: @name)
end
|
#shutdown=(val) ⇒ Object
125
126
127
128
|
# File 'lib/cisco_node_utils/vrf.rb', line 125
def shutdown=(val)
no_cmd = (val) ? '' : 'no'
config_set('vrf', 'shutdown', vrf: @name, state: no_cmd)
end
|
#to_s ⇒ Object
33
34
35
|
# File 'lib/cisco_node_utils/vrf.rb', line 33
def to_s
"VRF #{@name}"
end
|
#vni ⇒ Object
Vni (Getter/Setter/Default)
163
164
165
|
# File 'lib/cisco_node_utils/vrf.rb', line 163
def vni
config_get('vrf', 'vni', vrf: @name)
end
|
#vni=(id) ⇒ Object
167
168
169
170
171
172
|
# File 'lib/cisco_node_utils/vrf.rb', line 167
def vni=(id)
Feature.vn_segment_vlan_based_enable if platform == :nexus
no_cmd = (id) ? '' : 'no'
id = (id) ? id : vni
config_set('vrf', 'vni', vrf: @name, state: no_cmd, id: id)
end
|
#vpn_id ⇒ Object
178
179
180
|
# File 'lib/cisco_node_utils/vrf.rb', line 178
def vpn_id
config_get('vrf', 'vpn_id', vrf: @name)
end
|
#vpn_id=(val) ⇒ Object
182
183
184
185
186
|
# File 'lib/cisco_node_utils/vrf.rb', line 182
def vpn_id=(val)
val.strip!
no_cmd = val.empty? ? 'no' : ''
config_set('vrf', 'vpn_id', vrf: @name, state: no_cmd, vpnid: val)
end
|