Class: Rbeapi::Api::VxlanInterface

Inherits:
BaseInterface show all
Defined in:
lib/rbeapi/api/interfaces.rb

Constant Summary collapse

DEFAULT_SRC_INTF =
''
DEFAULT_MCAST_GRP =
''

Constants inherited from BaseInterface

BaseInterface::DEFAULT_INTF_DESCRIPTION

Instance Attribute Summary

Attributes inherited from Entity

#config, #error, #node

Instance Method Summary collapse

Methods inherited from BaseInterface

#create, #default, #delete, #set_description, #set_shutdown

Methods inherited from Entity

#configure, #get_block, #initialize, instance

Constructor Details

This class inherits a constructor from Rbeapi::Api::Entity

Instance Method Details

#get(name = 'Vxlan1') ⇒ nil, Hash<String, String>

Returns the Vxlan interface configuration as a Ruby hash of key/value pairs from the nodes running configuration. This method extends the BaseInterface get method and adds the Vxlan specific attributes to the hash

Examples:

{
  "name": <string>,
  "type": 'vxlan',
  "description": <string>,
  "shutdown": [true, false],
  "source_interface": <string>,
  "multicast_group": <string>
}

Parameters:

  • :name (String)

    The interface name to return from the nodes configuration. This optional parameter defaults to Vxlan1

Returns:

  • (nil, Hash<String, String>)

    Returns the interface configuration as a Ruby hash object. If the provided interface name is not found then this method will return nil


1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
# File 'lib/rbeapi/api/interfaces.rb', line 1081

def get(name = 'Vxlan1')
  config = get_block("interface #{name}")
  return nil unless config

  response = super(name)
  response[:type] = 'vxlan'
  response.merge!(parse_source_interface(config))
  response.merge!(parse_multicast_group(config))
  response
end

#set_multicast_group(name = 'Vxlan1', opts = {}) ⇒ Boolean

Configures the vxlan multcast-group flood address to the specified value. The value should be a valid multicast address

Parameters:

  • :name (String)

    The name of the interface to apply the configuration values to

  • :opt (Hash)

    Optional keyword arguments

  • :opts (Hash)

    a customizable set of options

Returns:

  • (Boolean)

    This method returns true if the commands were successful otherwise it returns false


1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
# File 'lib/rbeapi/api/interfaces.rb', line 1176

def set_multicast_group(name = 'Vxlan1', opts = {})
  value = opts[:value]
  default = opts.fetch(:default, false)

  cmds = ["interface #{name}"]
  case default
  when true
    cmds << 'default vxlan multicast-group'
  when false
    cmds << (value ? "vxlan multicast-group #{value}" : \
                     'no vxlan multtcast-group')
  end
  configure(cmds)
end

#set_source_interface(name = 'Vxlan1', opts = {}) ⇒ Boolean

Configures the vxlan source-interface to the specified value. This parameter should be a the interface identifier of the interface to act as the source for all Vxlan traffic

Parameters:

  • :name (String)

    The name of the interface to apply the configuration values to

  • :opt (Hash)

    Optional keyword arguments

  • :opts (Hash)

    a customizable set of options

Returns:

  • (Boolean)

    This method returns true if the commands were successful otherwise it returns false


1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
# File 'lib/rbeapi/api/interfaces.rb', line 1145

def set_source_interface(name = 'Vxlan1', opts = {})
  value = opts[:value]
  default = opts.fetch(:default, false)

  cmds = ["interface #{name}"]
  case default
  when true
    cmds << 'default vxlan source-interface'
  when false
    cmds << (value ? "vxlan source-interface #{value}" : \
                     'no vxlan source-interface')
  end
  configure(cmds)
end