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
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
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
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 33
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
86
87
88
89
90
|
# 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
raise unless e.message[/the entered commands do not exist/]
raise Cisco::UnsupportedError.new('interface', 'channel_group')
end
|
#default_channel_group ⇒ Object
92
93
94
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 92
def default_channel_group
config_get_default('interface_channel_group', 'channel_group')
end
|
#default_description ⇒ Object
107
108
109
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 107
def default_description
config_get_default('interface_channel_group', 'description')
end
|
#default_shutdown ⇒ Object
121
122
123
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 121
def default_shutdown
config_get_default('interface_channel_group', 'shutdown')
end
|
#description ⇒ Object
97
98
99
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 97
def description
config_get('interface_channel_group', 'description', @get_args)
end
|
#description=(desc) ⇒ Object
101
102
103
104
105
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 101
def description=(desc)
state = desc.strip.empty? ? 'no' : ''
config_set('interface_channel_group', 'description',
set_args_keys(state: state, desc: desc))
end
|
#set_args_keys(hash = {}) ⇒ Object
rubocop:disable Style/AccessorMethodName
54
55
56
57
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 54
def set_args_keys(hash={}) @get_args = { name: @name }
@set_args = @get_args.merge!(hash) unless hash.empty?
end
|
#shutdown ⇒ Object
112
113
114
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 112
def shutdown
config_get('interface_channel_group', 'shutdown', @get_args)
end
|
#shutdown=(state) ⇒ Object
116
117
118
119
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 116
def shutdown=(state)
config_set('interface_channel_group', 'shutdown',
set_args_keys(state: state ? '' : 'no'))
end
|
#to_s ⇒ Object
29
30
31
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 29
def to_s
"interface_channel_group #{name}"
end
|
#validate_args(name) ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'lib/cisco_node_utils/interface_channel_group.rb', line 45
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
|