Method: Rbeapi::Api::Switchports#set_mode

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

#set_mode(name, opts = {}) ⇒ Boolean

Configures the switchport mode for the specified interafce. Valid modes are access (default) or trunk

Parameters:

  • name (String)

    The name of the interface to configure

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

    The configuration parameters for the interface

Options Hash (opts):

  • :value (string)

    The value to set the mode to

  • :default (Boolean)

    The value should be set to default

Returns:

  • (Boolean)

    True if the commands succeed otherwise False



156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/rbeapi/api/switchports.rb', line 156

def set_mode(name, opts = {})
  value = opts[:value]
  default = opts[:default] || false

  cmds = ["interface #{name}"]
  case default
  when true
    cmds << 'default switchport mode'
  when false
    cmds << (value.nil? ? 'no switchport mode' : \
                          "switchport mode #{value}")
  end
  configure(cmds)
end