Class: Yade::Domain::Rest::Client::HostClient
- Inherits:
-
BaseClient
- Object
- BaseClient
- Yade::Domain::Rest::Client::HostClient
- Includes:
- HTTParty
- Defined in:
- lib/yade/domain/rest/client/host_client.rb
Overview
host client
Instance Method Summary collapse
-
#host_by_fqdn(host_fqdn) ⇒ Object
get host by fqdn.
-
#initialize ⇒ HostClient
constructor
A new instance of HostClient.
-
#master ⇒ Object
get master host.
Constructor Details
#initialize ⇒ HostClient
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 |
#master ⇒ Object
get master host
24 25 26 |
# File 'lib/yade/domain/rest/client/host_client.rb', line 24 def master list.select(&:isMaster).first end |