12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/yadecli/command/host/host_list_command.rb', line 12
def execute
host_client = Yade::Domain::Rest::Client::HostClient.new
domain_client = Yade::Domain::Rest::Client::DomainClient.new
role_client = Yade::Domain::Rest::Client::RoleClient.new
hosts = host_client.list
table = TTY::Table.new header: ['Name', 'Domain', 'Role', 'Ip', 'OsType', 'Environment']
hosts.each do |h|
domain_id = h.domainId
domain = domain_client.get(domain_id)
role_id = h.roleId
role = role_client.get(role_id)
table << [h.name, domain.name, role.name, h.ip, h.osType, h.environmentType]
end
table.render(:ascii, width: 100, resize: true, padding: [0, 1])
end
|