class PuppetX::Eos::Ipinterface
The Ipinterface
class provides an instance for managing logical IP interfaces configured using eAPI.
Public Class Methods
# File lib/puppet_x/eos/modules/ipinterface.rb, line 43 def initialize(api) @api = api end
Public Instance Methods
Create a new logical IP interface in the running-config
@param [String] name The name of the interface
@return [Boolean] True if the create succeeds otherwise False
# File lib/puppet_x/eos/modules/ipinterface.rb, line 95 def create(name) @api.config(["interface #{name}", 'no switchport']) == [{}, {}] end
Deletes a logical IP interface from the running-config
@param [String] name The name of the interface
@return [Boolean] True if the create succeeds otherwise False
# File lib/puppet_x/eos/modules/ipinterface.rb, line 105 def delete(name) @api.config(["interface #{name}", 'no ip address']) == [{}, {}] end
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": { ... } } }
@return [Hash]
# File lib/puppet_x/eos/modules/ipinterface.rb, line 85 def getall @api.enable('show ip interface') end
Configures the IP address and mask length for the interface
@param [String] name The name of the interface to configure @param [Hash] opts The configuration parameters for the interface @option opts [string] :value The value to set the address to @option opts [Boolean] :default The value should be set to default
@return [Boolean] True if the commands succeed otherwise False
# 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