Class: Serverspec::Type::ConsulNode

Inherits:
ConsulBase show all
Defined in:
lib/serverspec_extra_types/types/consul_node.rb

Instance Method Summary collapse

Methods inherited from ConsulBase

#[], #initialize

Methods inherited from ApiBase

#[], #initialize

Constructor Details

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

Instance Method Details

#datacenterObject



16
17
18
# File 'lib/serverspec_extra_types/types/consul_node.rb', line 16

def datacenter
  inspection['Node']['Datacenter']
end

#has_datacenter?(dc) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/serverspec_extra_types/types/consul_node.rb', line 12

def has_datacenter?(dc)
  datacenter == dc
end

#has_service?(service_name) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/serverspec_extra_types/types/consul_node.rb', line 20

def has_service?(service_name)
  service(service_name) != nil
end

#inspectionObject



32
33
34
# File 'lib/serverspec_extra_types/types/consul_node.rb', line 32

def inspection
  @inspection ||= ::MultiJson.load(get_inspection.stdout)
end

#service(service_name) ⇒ Object



24
25
26
# File 'lib/serverspec_extra_types/types/consul_node.rb', line 24

def service(service_name)
  services.find service_name
end

#servicesObject



28
29
30
# File 'lib/serverspec_extra_types/types/consul_node.rb', line 28

def services
  inspection['Services']
end

#urlObject



8
9
10
# File 'lib/serverspec_extra_types/types/consul_node.rb', line 8

def url
  "#{@url_base}/v1/catalog/node/#{@name}"
end