Search in sources :

Example 6 with Cluster

use of org.ovirt.engine.sdk4.types.Cluster in project ovirt-engine-sdk-java by oVirt.

the class AddHost method main.

public static void main(String[] args) throws Exception {
    // Create the connection to the server:
    Connection connection = connection().url("https://engine40.example.com/ovirt-engine/api").user("admin@internal").password("redhat123").trustStoreFile("truststore.jks").build();
    // Get the reference to the hosts service:
    HostsService hostsService = connection.systemService().hostsService();
    // Add the host:
    Host host = hostsService.add().host(host().name("myhost").description("My host").address("node40.example.com").rootPassword("redhat123").cluster(cluster().name("mycluster"))).send().host();
    // Wait till the host is up:
    HostService hostService = hostsService.hostService(host.id());
    for (; ; ) {
        Thread.sleep(5 * 1000);
        host = hostService.get().send().host();
        if (host.status() == HostStatus.UP) {
            break;
        }
    }
    // Close the connection to the server:
    connection.close();
}
Also used : HostService(org.ovirt.engine.sdk4.services.HostService) Connection(org.ovirt.engine.sdk4.Connection) HostsService(org.ovirt.engine.sdk4.services.HostsService) Host(org.ovirt.engine.sdk4.types.Host)

Example 7 with Cluster

use of org.ovirt.engine.sdk4.types.Cluster in project ovirt-engine-sdk-java by oVirt.

the class FollowLinkTest method testFollowLinkToDatacenter.

/**
 * Test follow link to data center from cluster
 */
@Test
public void testFollowLinkToDatacenter() {
    ClusterService clusterService = clustersService.clusterService("123");
    Cluster cluster = clusterService.get().send().cluster();
    DataCenter dc = connection.followLink(cluster.dataCenter());
    assertEquals("testdc", dc.name());
}
Also used : ClusterService(org.ovirt.engine.sdk4.services.ClusterService) DataCenter(org.ovirt.engine.sdk4.types.DataCenter) Cluster(org.ovirt.engine.sdk4.types.Cluster) Test(org.junit.Test)

Example 8 with Cluster

use of org.ovirt.engine.sdk4.types.Cluster in project ovirt-engine-sdk-java by oVirt.

the class ClusterReaderTest method testReadValueAfterEmptyList.

/**
 * Test given switch type after empty RNG source both are read correctly.
 */
@Test
public void testReadValueAfterEmptyList() throws Exception {
    String response = "<cluster>" + "<required_rng_sources/>" + "<switch_type>legacy</switch_type>" + "</cluster>";
    try (InputStream stream = new ByteArrayInputStream(response.getBytes(StandardCharsets.UTF_8));
        XmlReader reader = new XmlReader(stream)) {
        Cluster cluster = XmlClusterReader.readOne(reader);
        assertEquals(Arrays.asList(), cluster.requiredRngSources());
        assertEquals(SwitchType.LEGACY, cluster.switchType());
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Cluster(org.ovirt.engine.sdk4.types.Cluster) XmlReader(org.ovirt.api.metamodel.runtime.xml.XmlReader) Test(org.junit.Test)

Example 9 with Cluster

use of org.ovirt.engine.sdk4.types.Cluster in project ovirt-engine-sdk-java by oVirt.

the class ClusterServiceTest method testGetObjectFromClusterService.

/**
 * Test we don't get null cluster service for existing cluster id and correct object
 */
@Test
public void testGetObjectFromClusterService() {
    ClusterService clusterService = clustersService.clusterService("123");
    Cluster cluster = clusterService.get().send().cluster();
    assertEquals("123", cluster.id());
    assertEquals("testcluster", cluster.name());
    assertNull(cluster.description());
}
Also used : ClusterService(org.ovirt.engine.sdk4.services.ClusterService) Cluster(org.ovirt.engine.sdk4.types.Cluster) Test(org.junit.Test)

Example 10 with Cluster

use of org.ovirt.engine.sdk4.types.Cluster in project ovirt-engine-sdk-java by oVirt.

the class AddCluster method main.

public static void main(String[] args) throws Exception {
    // Create the connection to the server:
    Connection connection = connection().url("https://engine40.example.com/ovirt-engine/api").user("admin@internal").password("redhat123").trustStoreFile("truststore.jks").build();
    // Get the reference to the clusters service:
    ClustersService clustersService = connection.systemService().clustersService();
    // Use the "add" method to create a new data center:
    clustersService.add().cluster(cluster().name("mycluster").description("My cluster").cpu(cpu().architecture(Architecture.X86_64).type("Intel Conroe Family")).dataCenter(dataCenter().name("mydc"))).send();
    // Close the connection to the server:
    connection.close();
}
Also used : Connection(org.ovirt.engine.sdk4.Connection) ClustersService(org.ovirt.engine.sdk4.services.ClustersService)

Aggregations

Connection (org.ovirt.engine.sdk4.Connection)13 Cluster (org.ovirt.engine.sdk4.types.Cluster)7 VmsService (org.ovirt.engine.sdk4.services.VmsService)6 Vm (org.ovirt.engine.sdk4.types.Vm)5 ClusterService (org.ovirt.engine.sdk4.services.ClusterService)4 ClustersService (org.ovirt.engine.sdk4.services.ClustersService)4 StorageDomainsService (org.ovirt.engine.sdk4.services.StorageDomainsService)4 StorageDomain (org.ovirt.engine.sdk4.types.StorageDomain)4 Test (org.junit.Test)3 SystemService (org.ovirt.engine.sdk4.services.SystemService)3 StorageDomainService (org.ovirt.engine.sdk4.services.StorageDomainService)2 StorageDomainVmsService (org.ovirt.engine.sdk4.services.StorageDomainVmsService)2 VmService (org.ovirt.engine.sdk4.services.VmService)2 Template (org.ovirt.engine.sdk4.types.Template)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 XmlReader (org.ovirt.api.metamodel.runtime.xml.XmlReader)1 ClusterNetworksService (org.ovirt.engine.sdk4.services.ClusterNetworksService)1 HostService (org.ovirt.engine.sdk4.services.HostService)1 HostsService (org.ovirt.engine.sdk4.services.HostsService)1