Class: Cisco::InterfaceChannelGroup
- Inherits:
-
NodeUtil
- Object
- NodeUtil
- Cisco::InterfaceChannelGroup
show all
- Defined in:
- lib/cisco_node_utils/interface_channel_group.rb
Overview
Interface - node utility class for general interface config management
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from NodeUtil
config_get, #config_get, config_get_default, #config_get_default, #config_set, config_set, #node, node, #show
Constructor Details
Returns a new instance of InterfaceChannelGroup.
25
26
27
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 25
def initialize(name)
validate_args(name)
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
23
24
25
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 23
def name
@name
end
|
Class Method Details
.interfaces ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 29
def self.interfaces
hash = {}
all = config_get('interface_channel_group', 'all_interfaces')
return hash if all.nil?
all.each do |id|
id = id.downcase
hash[id] = InterfaceChannelGroup.new(id)
end
hash
end
|
Instance Method Details
#channel_group ⇒ Object
63
64
65
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 63
def channel_group
config_get('interface_channel_group', 'channel_group', @get_args)
end
|
#channel_group=(group) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 67
def channel_group=(group)
if group
state = ''
force = 'force'
else
state = 'no'
group = force = ''
end
config_set('interface_channel_group', 'channel_group',
set_args_keys(state: state, group: group, force: force))
rescue Cisco::CliError => e
fail_cli(e)
end
|
#default_channel_group ⇒ Object
87
88
89
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 87
def default_channel_group
config_get_default('interface_channel_group', 'channel_group')
end
|
#default_description ⇒ Object
104
105
106
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 104
def default_description
config_get_default('interface_channel_group', 'description')
end
|
#default_shutdown ⇒ Object
120
121
122
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 120
def default_shutdown
config_get_default('interface_channel_group', 'shutdown')
end
|
#description ⇒ Object
92
93
94
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 92
def description
config_get('interface_channel_group', 'description', @get_args)
end
|
#description=(desc) ⇒ Object
96
97
98
99
100
101
102
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 96
def description=(desc)
state = desc.strip.empty? ? 'no' : ''
config_set('interface_channel_group', 'description',
set_args_keys(state: state, desc: desc))
rescue Cisco::CliError => e
fail_cli(e)
end
|
#fail_cli(e) ⇒ Object
55
56
57
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 55
def fail_cli(e)
fail "[#{@name}] '#{e.command}' : #{e.clierror}"
end
|
#set_args_keys(hash = {}) ⇒ Object
rubocop:disable Style/AccessorMethodName
50
51
52
53
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 50
def set_args_keys(hash={})
@get_args = { name: @name }
@set_args = @get_args.merge!(hash) unless hash.empty?
end
|
#shutdown ⇒ Object
109
110
111
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 109
def shutdown
config_get('interface_channel_group', 'shutdown', @get_args)
end
|
#shutdown=(state) ⇒ Object
113
114
115
116
117
118
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 113
def shutdown=(state)
config_set('interface_channel_group', 'shutdown',
set_args_keys(state: state ? '' : 'no'))
rescue Cisco::CliError => e
fail_cli(e)
end
|
#validate_args(name) ⇒ Object
41
42
43
44
45
46
47
48
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 41
def validate_args(name)
fail TypeError unless name.is_a?(String)
fail ArgumentError unless name.length > 0
fail "channel_group is not supported on #{name}" unless
name[/Ethernet/i]
@name = name.downcase
set_args_keys
end
|