use of org.ovirt.engine.sdk4.services.VmsService in project ovirt-engine-sdk-java by oVirt.
the class ExportVm 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 root of the services tree:
SystemService systemService = connection.systemService();
// Find the virtual machine:
VmsService vmsService = systemService.vmsService();
Vm vm = vmsService.list().search("name=myvm").send().vms().get(0);
// Export the virtual machine. Note that the 'exclusive' parameter is optional, and only required if you want
// to overwrite a virtual machine that has already been exported before.
VmService vmService = vmsService.vmService(vm.id());
vmService.export().exclusive(true).discardSnapshots(true).storageDomain(storageDomain().name("myexport")).send();
// Close the connection to the server:
connection.close();
}
use of org.ovirt.engine.sdk4.services.VmsService in project ovirt-engine-sdk-java by oVirt.
the class ResponseCodeTest method test202codeDontThrowException.
/**
* Test when server return response with 202 code,
* the SDK don't raise exception.
*/
@Test
public void test202codeDontThrowException() throws Exception {
setXmlResponse("vms", 202, "<vms/>");
startServer();
Connection connection = testConnection();
VmsService vmsService = connection.systemService().vmsService();
vmsService.add().vm(vm()).send();
connection.close();
stopServer();
}
use of org.ovirt.engine.sdk4.services.VmsService in project ovirt-engine-sdk-java by oVirt.
the class ResponseCodeTest method test201codeDontThrowException.
/**
* Test when server return response with 201 code,
* the SDK don't raise exception.
*/
@Test
public void test201codeDontThrowException() throws Exception {
setXmlResponse("vms", 201, "<vms/>");
startServer();
Connection connection = testConnection();
VmsService vmsService = connection.systemService().vmsService();
vmsService.add().vm(vm()).send();
connection.close();
stopServer();
}
use of org.ovirt.engine.sdk4.services.VmsService in project ovirt-engine-sdk-java by oVirt.
the class ResponseCodeTest method test200codeDontThrowException.
/**
* Test when server return response with 200 code,
* the SDK don't raise exception.
*/
@Test
public void test200codeDontThrowException() throws Exception {
setXmlResponse("vms", 200, "<vms/>");
startServer();
Connection connection = testConnection();
VmsService vmsService = connection.systemService().vmsService();
vmsService.add().vm(vm()).send();
connection.close();
stopServer();
}
use of org.ovirt.engine.sdk4.services.VmsService in project ovirt-engine-sdk-java by oVirt.
the class PinVm 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 root of the tree of services:
SystemService systemService = connection.systemService();
// Find the virtual machine:
VmsService vmsService = systemService.vmsService();
Vm vm = vmsService.list().search("name=myvm").send().vms().get(0);
// Update the placement policy of the virtual machine so that it is pinned to the host:
VmService vmService = vmsService.vmService(vm.id());
vmService.update().vm(vm().placementPolicy(vmPlacementPolicy().hosts(host().name("myhost")))).send();
// Close the connection to the server:
connection.close();
}
Aggregations