Method: Rbeapi::Api::Bgp#create

Defined in:
lib/rbeapi/api/bgp.rb

#create(bgp_as, opts = {}) ⇒ Boolean

create will create a new instance of BGP routing on the node. Optional parameters can be passed in to initialize BGP specific settings.

Commands

router bgp <bgp_as>

paths.

Parameters:

  • bgp_as (String)

    The BGP autonomous system number to be configured for the local BGP routing instance.

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

    Optional keyword arguments.

Options Hash (opts):

  • router_id (String)

    The BGP routing process router-id value. When no ID has been specified (i.e. value not set), the local router ID is set to the following:

    • The loopback IP address when a single loopback interface is configured.

    • The loopback with the highest IP address when multiple loopback interfaces are configured.

    • The highest IP address on a physical interface when no loopback interfaces are configure

  • maximum_paths (Integer)

    Maximum number of equal cost

  • maximum_ecmp_paths (Integer)

    Maximum number of installed ECMP routes. The maximum_paths option must be set if maximum_ecmp_paths is set.

  • enable (Boolean)

    If true then the BGP router is enabled. If false then the BGP router is disabled.

Returns:

  • (Boolean)

    returns true if the command completed successfully.



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/rbeapi/api/bgp.rb', line 227

def create(bgp_as, opts = {})
  if opts[:maximum_ecmp_paths] && !opts[:maximum_paths]
    message = 'maximum_paths must be set if maximum_ecmp_paths is set'
    raise ArgumentError, message
  end
  cmds = ["router bgp #{bgp_as}"]
  if opts.key?(:enable)
    cmds << (opts[:enable] == true ? 'no shutdown' : 'shutdown')
  end
  cmds << "router-id #{opts[:router_id]}" if opts.key?(:router_id)
  if opts.key?(:maximum_paths)
    cmd = "maximum-paths #{opts[:maximum_paths]}"
    if opts.key?(:maximum_ecmp_paths)
      cmd << " ecmp #{opts[:maximum_ecmp_paths]}"
    end
    cmds << cmd
  end
  configure(cmds)
end