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();
}
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());
}
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());
}
}
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());
}
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();
}
Aggregations