Class: PuppetX::Eos::Mlag
- Inherits:
-
Object
- Object
- PuppetX::Eos::Mlag
- Defined in:
- lib/puppet_x/eos/modules/mlag.rb
Overview
The Mlag class provides a base class instance for working with the global mlag configuration
Instance Method Summary collapse
-
#add_interface(name, id) ⇒ Boolean
Adds a new interface to the MLAG domain with specified Mlag id.
-
#create(name) ⇒ Boolean
Creates a new mlag instance.
-
#default ⇒ Boolean
Defaults the current mlag configuration.
-
#delete ⇒ Boolean
Deletes the current mlag configuration from the running-config.
-
#get ⇒ Array<Hash>
Returns the Mlag hash representing global snmp configuration.
-
#get_interfaces ⇒ Array<Hash>
Retrieves the interfaces that are mlag enabled from the running-config.
-
#initialize(api) ⇒ PuppetX::Eos::Mlag
constructor
Initialize instance of Snmp.
-
#remove_interface(name) ⇒ Boolean
Removes a previously configured interface from the Mlag domain.
-
#set_domain_id(opts = {}) ⇒ Boolean
Configures the mlag domain_id.
-
#set_local_interface(opts = {}) ⇒ Boolean
Configures the mlag local_interface.
-
#set_mlag_id(name, opts = {}) ⇒ Boolean
Configures the mlag id for an interface.
-
#set_peer_address(opts = {}) ⇒ Boolean
Configures the mlag peer_address.
-
#set_peer_link(opts = {}) ⇒ Boolean
Configures the mlag peer_link.
-
#set_shutdown(opts = {}) ⇒ Boolean
Configures the mlag operational state.
Constructor Details
#initialize(api) ⇒ PuppetX::Eos::Mlag
Initialize instance of Snmp
50 51 52 |
# File 'lib/puppet_x/eos/modules/mlag.rb', line 50 def initialize(api) @api = api end |
Instance Method Details
#add_interface(name, id) ⇒ Boolean
Adds a new interface to the MLAG domain with specified Mlag id
120 121 122 |
# File 'lib/puppet_x/eos/modules/mlag.rb', line 120 def add_interface(name, id) @api.config(["interface #{name}", "mlag #{id}"]) == [{}, {}] end |
#create(name) ⇒ Boolean
Creates a new mlag instance
85 86 87 |
# File 'lib/puppet_x/eos/modules/mlag.rb', line 85 def create(name) @api.config(['mlag configuration', "domain-id #{name}"]) == [{}, {}] end |
#default ⇒ Boolean
Defaults the current mlag configuration
101 102 103 |
# File 'lib/puppet_x/eos/modules/mlag.rb', line 101 def default @api.config('default mlag configuration') == [{}] end |
#delete ⇒ Boolean
Deletes the current mlag configuration from the running-config
93 94 95 |
# File 'lib/puppet_x/eos/modules/mlag.rb', line 93 def delete @api.config('no mlag configuration') == [{}] end |
#get ⇒ Array<Hash>
Returns the Mlag hash representing global snmp configuration
Example
{
"domain_id": <String>,
"local_interface": <String>,
"peer_address": <String>,
"peer_link": <String>,
"enable": [true, false]
}
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/puppet_x/eos/modules/mlag.rb', line 67 def get result = @api.enable('show mlag') attr_hash = { domain_id: result[0]['domainId'], peer_link: result[0]['peerLink'], local_interface: result[0]['localInterface'], peer_address: result[0]['peerAddress'], enable: result[0]['state'] == 'disabled' ? :false : :true } attr_hash end |
#get_interfaces ⇒ Array<Hash>
Retrieves the interfaces that are mlag enabled from the running-config
109 110 111 |
# File 'lib/puppet_x/eos/modules/mlag.rb', line 109 def get_interfaces @api.enable('show mlag interfaces') end |
#remove_interface(name) ⇒ Boolean
Removes a previously configured interface from the Mlag domain
130 131 132 |
# File 'lib/puppet_x/eos/modules/mlag.rb', line 130 def remove_interface(name) @api.config(["interface #{name}", 'no mlag']) == [{}, {}] end |
#set_domain_id(opts = {}) ⇒ Boolean
Configures the mlag domain_id
165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/puppet_x/eos/modules/mlag.rb', line 165 def set_domain_id(opts = {}) value = opts[:value] || false default = opts[:default] || false cmds = ['mlag configuration'] case default when true cmds << 'default domain-id' when false cmds << (value ? "domain-id #{value}" : 'no domain-id') end @api.config(cmds) == [{}, {}] end |
#set_local_interface(opts = {}) ⇒ Boolean
Configures the mlag local_interface
231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/puppet_x/eos/modules/mlag.rb', line 231 def set_local_interface(opts = {}) value = opts[:value] || false default = opts[:default] || false cmds = ['mlag configuration'] case default when true cmds << 'default local-interface' when false cmds << (value ? "local-interface #{value}" : 'no local-interface') end @api.config(cmds) == [{}, {}] end |
#set_mlag_id(name, opts = {}) ⇒ Boolean
Configures the mlag id for an interface
143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/puppet_x/eos/modules/mlag.rb', line 143 def set_mlag_id(name, opts = {}) value = opts[:value] || false default = opts[:default] || false cmds = ["interface #{name}"] case default when true cmds << 'default mlag' when false cmds << (value ? "mlag #{value}" : 'no mlag') end @api.config(cmds) == [{}, {}] end |
#set_peer_address(opts = {}) ⇒ Boolean
Configures the mlag peer_address
209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/puppet_x/eos/modules/mlag.rb', line 209 def set_peer_address(opts = {}) value = opts[:value] || false default = opts[:default] || false cmds = ['mlag configuration'] case default when true cmds << 'default peer-address' when false cmds << (value ? "peer-address #{value}" : 'no peer-address') end @api.config(cmds) == [{}, {}] end |
#set_peer_link(opts = {}) ⇒ Boolean
Configures the mlag peer_link
187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/puppet_x/eos/modules/mlag.rb', line 187 def set_peer_link(opts = {}) value = opts[:value] || false default = opts[:default] || false cmds = ['mlag configuration'] case default when true cmds << 'default peer-link' when false cmds << (value ? "peer-link #{value}" : 'no peer-link') end @api.config(cmds) == [{}, {}] end |
#set_shutdown(opts = {}) ⇒ Boolean
Configures the mlag operational state
253 254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/puppet_x/eos/modules/mlag.rb', line 253 def set_shutdown(opts = {}) value = opts[:value] || false default = opts[:default] || false cmds = ['mlag configuration'] case default when true cmds << 'default shutdown' when false cmds << (value ? 'shutdown' : 'no shutdown') end @api.config(cmds) == [{}, {}] end |