Class: Yade::Domain::Rest::Client::HostClient

Inherits:
BaseClient
  • Object
show all
Includes:
HTTParty
Defined in:
lib/yade/domain/rest/client/host_client.rb

Overview

host client

Instance Method Summary collapse

Constructor Details

#initializeHostClient

Returns a new instance of HostClient.



19
20
21
# File 'lib/yade/domain/rest/client/host_client.rb', line 19

def initialize
  super('yadedomain', 'host', 'Yade::Domain::Rest::Model::Host')
end

Instance Method Details

#host_by_fqdn(host_fqdn) ⇒ Object

get host by fqdn



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/yade/domain/rest/client/host_client.rb', line 29

def host_by_fqdn(host_fqdn)
  splitted = host_fqdn.split('.')

  hostname = splitted.first
  fqdn = splitted.last(splitted.size - 1).join('.')

  all_hosts_with_name = list.select { |h| h.name == hostname }

  domain_client = Yade::Domain::Rest::Client::DomainClient.new

  all_hosts_with_name.each do |h|
    domain = domain_client.get(h.domainId)
    return h if domain.name == fqdn
  end
end

#masterObject

get master host



24
25
26
# File 'lib/yade/domain/rest/client/host_client.rb', line 24

def master
  list.select(&:isMaster).first
end