Class: Yadecli::Client::HostClient

Inherits:
BaseClient show all
Includes:
HTTParty
Defined in:
lib/yadecli/client/host_client.rb

Overview

host client

Instance Method Summary collapse

Methods inherited from BaseClient

#base_path, #get, #get_request, #list

Constructor Details

#initializeHostClient

Returns a new instance of HostClient.



18
19
20
# File 'lib/yadecli/client/host_client.rb', line 18

def initialize
  super('yadedomain', 'host')
end

Instance Method Details

#host_by_fqdn(host_fqdn) ⇒ Object

get host by fqdn



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

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 = Yadecli::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



23
24
25
# File 'lib/yadecli/client/host_client.rb', line 23

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