use of org.ovirt.engine.sdk4.Service 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.Service in project ovirt-engine-sdk-java by oVirt.
the class VmsServiceTest method testGetObjectFromStorageDomainService.
/**
* Test we don't get null vm service for existing vm id and correct object
*/
@Test
public void testGetObjectFromStorageDomainService() {
VmService vmService = vmsService.vmService("123");
Vm vm = vmService.get().send().vm();
assertEquals("123", vm.id());
assertEquals("testvm", vm.name());
assertNull(vm.description());
}
use of org.ovirt.engine.sdk4.Service in project ovirt-engine-sdk-java by oVirt.
the class AddAffinityLabel 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 affinity labels service:
AffinityLabelsService affinityLabelsService = connection.systemService().affinityLabelsService();
// Use the "add" method to create a affinity label:
affinityLabelsService.add().label(affinityLabel().name("myaffinitylabel")).send();
// Close the connection to the server:
connection.close();
}
use of org.ovirt.engine.sdk4.Service in project ovirt-engine-sdk-java by oVirt.
the class AddBond method main.
public static void main(String[] args) throws Exception {
// Create the connection to the server:
Connection connection = connection().url("https://engine42.example.com/ovirt-engine/api").user("admin@internal").password("redhat123").insecure(true).build();
// Find the service that manages the collection of hosts:
HostsService hostsService = connection.systemService().hostsService();
// Find the host:
Host host = hostsService.list().search("name=myhost").send().hosts().get(0);
// Find the service that manages the host:
HostService hostService = hostsService.hostService(host.id());
// Configure the host adding a bond with two slaves, and attaching it to a network with an static IP address:
hostService.setupNetworks().modifiedBonds(hostNic().name("bond0").bonding(bonding().options(option().name("mode").value("1"), option().name("miimon").value("100")).slaves(hostNic().name("eth0"), hostNic().name("eth1")))).modifiedNetworkAttachments(networkAttachment().network(network().name("mynetwork")).ipAddressAssignments(ipAddressAssignment().assignmentMethod(BootProtocol.STATIC).ip(ip().address("192.168.122.100").netmask("255.255.255.0")))).send();
// After modifying the network configuration it is very important to make it persistent:
hostService.commitNetConfig().send();
// Close the connection to the server:
connection.close();
}
use of org.ovirt.engine.sdk4.Service 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