Method: Rbeapi::Api::Iphosts#create
- Defined in:
- lib/rbeapi/api/iphosts.rb
#create(name, opts = {}) ⇒ Boolean
create will create a ip host entry in the nodes current configuration with the specified address.
Commands
ip host <name> <address>
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/rbeapi/api/iphosts.rb', line 122 def create(name, opts = {}) ipaddress = opts.fetch(:ipaddress, NIL) # rubocop:disable Style/GuardClause, Style/ClassCheck if ipaddress.kind_of?(Array) if ipaddress.all? { |x| x =~ /(\w+\.\d+\.\d+\.\d+)/ } ips = opts[:ipaddress].join(' ') cmd = "ip host #{name} #{ips}" configure(cmd) else fail ArgumentError, 'option ipaddress must be a valid IP' end else fail ArgumentError, 'no argument given' end # rubocop:enable Style/GuardClause, Style/ClassCheck end |