Class: Serverspec::Type::DefaultGateway

Inherits:
Base
  • Object
show all
Defined in:
lib/serverspec/type/default_gateway.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, #to_ary

Constructor Details

This class inherits a constructor from Serverspec::Type::Base

Instance Method Details

#interfaceObject


10
11
12
13
14
# File 'lib/serverspec/type/default_gateway.rb', line 10

def interface
  ret = backend.run_command(commands.check_routing_table('default'))
  ret[:stdout] =~ /^(\S+)(?: via (\S+))? dev (\S+).+(?:\r)?\n(?:default via (\S+))?/
  $3
end

#ipaddressObject


4
5
6
7
8
# File 'lib/serverspec/type/default_gateway.rb', line 4

def ipaddress
  ret = backend.run_command(commands.check_routing_table('default'))
  ret[:stdout] =~ /^(\S+)(?: via (\S+))? dev (\S+).+(?:\r)?\n(?:default via (\S+))?/
  $2 ? $2 : $4
end

#to_sObject


16
17
18
# File 'lib/serverspec/type/default_gateway.rb', line 16

def to_s
  'Default Gateway'
end