import org.ovirt.engine.sdk4.Connection;import org.ovirt.engine.sdk4.services.ClustersService;import org.ovirt.engine.sdk4.services.ClustersService.ListResponse;import org.ovirt.engine.sdk4.services.DataCentersService;import org.ovirt.engine.sdk4.services.HostsService;import org.ovirt.engine.sdk4.services.VmsService;import org.ovirt.engine.sdk4.types.Cluster;import org.ovirt.engine.sdk4.types.DataCenter;import org.ovirt.engine.sdk4.types.Host;import org.ovirt.engine.sdk4.types.Vm;import static org.ovirt.engine.sdk4.ConnectionBuilder.connection;import java.util.HashMap;import java.util.List;import java.util.Map;public class Test {    private static final String URL = "https://svcloud.casvip.com:443/ovirt-engine/api";    private static final String USERNAME = "admin@internal";    private static final String PASSWORD = "Admin123***";    public static void main(String[] args) {        // 1. 创建服务器连接        Connection connection = connection()                .url(URL)                .user(USERNAME)                .password(PASSWORD)                .build();                // 2. 获取数据中心        DataCentersService dataCentersSevice = connection.systemService().dataCentersService();        List
 dataCenters = dataCentersSevice.list().send().dataCenters();        Map
 dataCenterMap = new HashMap
();        System.out.println("数据中心:");        for(DataCenter dt : dataCenters) {            System.out.println("\t名称 - " + dt.name());            System.out.println("\t\tID - " + dt.id());            System.out.println("\t\tClusters - " + dt.clusters().size());            dataCenterMap.put(dt.id(), dt.name());        }                // 3. 获取集群        ClustersService clustersService = connection.systemService().clustersService();        List
 clusters = clustersService.list().send().clusters();        Map
 clusterMap = new HashMap
();        System.out.println("集群:");        for(Cluster clu : clusters) {            if(clu.id() != null) {                System.out.println("\t名称 - " + clu.name());                System.out.println("\t\tID - " + clu.id());                System.out.println("\t\tData Center - " + clu.dataCenter());                clusterMap.put(clu.id(), clu.name());            }        }                // 4.获取主机        HostsService hostsService = connection.systemService().hostsService();        List
 hosts = hostsService.list().send().hosts();        Map
 hostMap = new HashMap
();        System.out.println("主机:");        for(Host host : hosts) {            System.out.println("\t名称 - " + host.name());            System.out.println("\t\tID - " + host.id());            System.out.println("\t\tIP - " + host.address());            System.out.println("\t\tCluster - " + clusterMap.get(host.cluster().id()));            System.out.println("\t\tData Center - " + host.cluster().dataCenter());            hostMap.put(host.id(), host.name());        }                // 5. 获取虚拟机        VmsService vmsService = connection.systemService().vmsService();        List
 vms = vmsService.list().send().vms();        System.out.println("虚拟机:");        for(Vm vm : vms) {            System.out.println("\t名称 - " + vm.name());            System.out.println("\t\t注释 - " + vm.description());            if(vm.host() != null) {                System.out.println("\t\t主机 - " + hostMap.get(vm.host().id()));            }            System.out.println("\t\tIP - " + vm.display().address());            System.out.println("\t\tFQDN - " + vm.fqdn());            System.out.println("\t\tCluster - " + clusterMap.get(vm.cluster().id()));            System.out.println("\t\tMemory - " + vm.memory());            System.out.println("\t\tOS - " + vm.os().type());            System.out.println("\t\tCPU - " + vm.cpu().architecture());            System.out.println("\t\tCPU Level - " + vm.cpu().level());            System.out.println("\t\t图形界面 - " + vm.display().type().value());            System.out.println("\t\tStauts - " + vm.status().value());            System.out.println("\t\t上线时间 - " + vm.creationTime());            System.out.println("\t\t描述 - " + vm.comment());        }    }}