This works fine with sdk4. Thanks.
Unfortunately I couldn't find away to update cpu_shares config: can't set
any update option to update it now or later and no error from the API.
On Mon, Jul 11, 2016 at 1:07 PM, Juan Hernández <jhernand(a)redhat.com> wrote:
On 07/08/2016 04:09 PM, Sebastien Fuchs wrote:
> Hi,
>
> I'm developping (in JAVA) an automatic configuration manager to modify
> memory and cpu allocation (cpushares for the moment) updated on a
> calendar basis. It will also be used as a kind of enforcer/elastic
> scheduler on top of the ovirt policy scheduler.
>
> Because oVirt is not yet able to update memory and cpushares on live
> guests like XenServer, my configurator needs to know the running config
> and the next_run config as well, and force directly the config on live
> guests (with virsh schedinfo --live arg ? ).
>
> Unfortunately, the Host.getVMs().getById( "uuid" ) method returns only
> the running config so there's no way I can check if the future config is
> setup.
>
> Any suggestion?
>
Version 3 of the SDK doesn't support GET parameters, unfortunately. If
you are using version 4 of the engine then you may consider using
version 4 of the SDK, which does support them:
---8<---
import static org.ovirt.engine.sdk4.ConnectionBuilder.connection;
import org.ovirt.engine.sdk4.Connection;
import org.ovirt.engine.sdk4.services.VmService;
import org.ovirt.engine.sdk4.services.VmsService;
import org.ovirt.engine.sdk4.types.Vm;
// This example will connect to the server and start a virtual machine:
public class GetVmNextRun {
public static void main(String[] args) throws Exception {
// Create the connection to the server:
Connection connection = connection()
.url("https://engine41.example.com/ovirt-engine/api")
.user("admin@internal")
.password("...")
.trustStoreFile("truststore.jks")
.build();
// Get the reference to the "vms" service:
VmsService vmsService = connection.systemService().vmsService();
// Find the virtual machine (we need this in order to find
// the identifier of the virtual machine given its
// name):
Vm vm = vmsService.list()
.search("name=myvm")
.send()
.vms()
.get(0);
// Locate the service that manages the virtual machine:
VmService vmService = vmsService.vmService(vm.id());
// Call the "get" method using the "next_run" parameter to
// retrieve the configuration of the virtual machine that
// will be used the next time it is started:
vm = vmService.get()
.nextRun(true)
.send()
.vm();
// Print some details of the virtual machine:
System.out.printf("cpu shares: %s", vm.cpuShares());
// Close the connection to the server:
connection.close();
}
}
--->8---
If this isn't an alternative for you, then please open a bug requesting
that this support is added to version 3 of the SDK.
--
Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta
3ºD, 28016 Madrid, Spain
Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.