Class: PuppetX::Eos::Ipinterface
- Inherits:
-
Object
- Object
- PuppetX::Eos::Ipinterface
- Defined in:
- lib/puppet_x/eos/modules/ipinterface.rb
Overview
The Ipinterface class provides an instance for managing logical IP interfaces configured using eAPI.
Instance Method Summary collapse
-
#create(name) ⇒ Boolean
Create a new logical IP interface in the running-config.
-
#delete(name) ⇒ Boolean
Deletes a logical IP interface from the running-config.
-
#getall ⇒ Hash
Retrieves all logical IP interfaces from the running-configuration and returns all instances.
-
#initialize(api) ⇒ Ipinterface
constructor
A new instance of Ipinterface.
-
#set_address(name, opts = {}) ⇒ Boolean
Configures the IP address and mask length for the interface.
Constructor Details
#initialize(api) ⇒ Ipinterface
Returns a new instance of Ipinterface.
43 44 45 |
# File 'lib/puppet_x/eos/modules/ipinterface.rb', line 43 def initialize(api) @api = api end |
Instance Method Details
#create(name) ⇒ Boolean
Create a new logical IP interface in the running-config
95 96 97 |
# File 'lib/puppet_x/eos/modules/ipinterface.rb', line 95 def create(name) @api.config(["interface #{name}", 'no switchport']) == [{}, {}] end |
#delete(name) ⇒ Boolean
Deletes a logical IP interface from the running-config
105 106 107 |
# File 'lib/puppet_x/eos/modules/ipinterface.rb', line 105 def delete(name) @api.config(["interface #{name}", 'no ip address']) == [{}, {}] end |
#getall ⇒ Hash
Retrieves all logical IP interfaces from the running-configuration and returns all instances
Example:
{
"interfaces": {
"Ethernet1": {
"interfaceAddress": {
"secondaryIpsOrderedList": [],
"broadcastAddress": "255.255.255.255",
"secondaryIps": {},
"primaryIp": {
"maskLen": 32,
"address": "1.1.1.1"
},
"virtualIp": {
"maskLen": 0,
"address": "0.0.0.0"
}
},
"name": "Loopback0",
"urpf": "disable",
"interfaceStatus": "connected",
"enabled": true,
"mtu": 65535,
"vrf": "default",
"localProxyArp": false,
"proxyArp": false,
"lineProtocolStatus": "up",
"description": "managed by PE"
},
"Ethernet2": { ... },
"Ethernet3": { ... }
}
}
85 86 87 |
# File 'lib/puppet_x/eos/modules/ipinterface.rb', line 85 def getall @api.enable('show ip interface') end |
#set_address(name, opts = {}) ⇒ Boolean
Configures the IP address and mask length for the interface
118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/puppet_x/eos/modules/ipinterface.rb', line 118 def set_address(name, opts = {}) value = opts[:value] default = opts[:default] || false cmds = ["interface #{name}"] case default when true cmds << 'default ip address' when false cmds << (value.nil? ? 'no ip address' : "ip address #{value}") end @api.config(cmds) == [{}, {}] end |