Class: PuppetX::Eos::Vxlan

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet_x/eos/modules/vxlan.rb

Overview

The Vxlan provides an instance for managing vxlan virtual tunnel interfaces in EOS

Instance Method Summary collapse

Constructor Details

#initialize(api) ⇒ Vxlan

Returns a new instance of Vxlan.



44
45
46
# File 'lib/puppet_x/eos/modules/vxlan.rb', line 44

def initialize(api)
  @api = api
end

Instance Method Details

#createBoolean

Creates a new logical vxlan virtual interface in the running-config

Returns:

  • (Boolean)

    returns true if the command completed successfully



65
66
67
# File 'lib/puppet_x/eos/modules/vxlan.rb', line 65

def create
  @api.config('interface vxlan 1') == [{}]
end

#defaultBoolean

Defaults an existing vxlan logical interface from the running-config)

Returns:

  • (Boolean)

    returns true if the command completed successfully



81
82
83
# File 'lib/puppet_x/eos/modules/vxlan.rb', line 81

def default
  @api.config('default interface vxlan 1') == [{}]
end

#deleteBoolean

Deletes an existing vxlan logical interface from the running-config

Returns:

  • (Boolean)

    always returns true



73
74
75
# File 'lib/puppet_x/eos/modules/vxlan.rb', line 73

def delete
  @api.config('no interface vxlan 1') == [{}]
end

#getnil, Hash<String, String|Hash|Array>

Returns the vlan data for the provided id with the show vlan <id> command. If the id doesn’t exist then nil is returned

Returns:

  • (nil, Hash<String, String|Hash|Array>)

    Hash describing the vlan configuration specified by id. If the id is not found then nil is returned



57
58
59
# File 'lib/puppet_x/eos/modules/vxlan.rb', line 57

def get
  @api.enable('show interfaces vxlan 1')
end

#set_multicast_group(opts = {}) ⇒ Boolean

Configures the multicast-group parameter for the Vxlan interface

Parameters:

  • opts (Hash) (defaults to: {})

    The configuration parameters for the VLAN

Options Hash (opts):

  • :value (string)

    The value to set the name to

  • :default (Boolean)

    The value should be set to default

Returns:

  • (Boolean)

    returns true if the command completed successfully



116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/puppet_x/eos/modules/vxlan.rb', line 116

def set_multicast_group(opts = {})
  value = opts[:value]
  default = opts[:default] || false

  cmds = ['interface vxlan 1']
  case default
  when true
    cmds << 'default vxlan multicast-group'
  when false
    cmds << (value.nil? ?  'no vxlan multicast-group' : \
                           "vxlan multicast-group #{value}")
  end
  @api.config(cmds) == [{}, {}]
end

#set_source_interface(opts = {}) ⇒ Boolean

Configures the source-interface parameter for the Vxlan interface

Parameters:

  • opts (Hash) (defaults to: {})

    The configuration parameters for the VLAN

Options Hash (opts):

  • :value (string)

    The value to set the name to

  • :default (Boolean)

    The value should be set to default

Returns:

  • (Boolean)

    returns true if the command completed successfully



93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/puppet_x/eos/modules/vxlan.rb', line 93

def set_source_interface(opts = {})
  value = opts[:value]
  default = opts[:default] || false

  cmds = ['interface vxlan 1']
  case default
  when true
    cmds << 'default vxlan source-interface'
  when false
    cmds << (value.nil? ?  'no vxlan source-interface' : \
                           "vxlan source-interface #{value}")
  end
  @api.config(cmds) == [{}, {}]
end