3.5. 列出主机
此 Ruby 示例列出了主机。
# Get the reference to the root of the services tree: system_service = connection.system_service # Get the reference to the service that manages the # collection of hosts: host_service = system_service.hosts_service # Retrieve the list of hosts and for each one # print its name: host = host_service.list host.each do |host| puts host.name end
在一个环境中,只有一个附加主机(Atlantic
)示例输出:
Atlantic
有关更多信息,请参阅 HostsService:list-instance_method。