Retrieve cluster status using the SDK

Using the SDK how can I retrieve a clusters (network) status. I am able to retrieve a cluster object using code like this: Cluster cluster = sysService.clustersService().clusterService(DataCenterUtils.getClusterObjectFromName(sysService, DEFAULT_CLUSTER_NAME).id()).get().send().cluster(); However I cannot see any variables associated with this object type that relate to its Network Status. The information i'm referring to can be found on the UI after creating a custom network. Starting on the left panel Navigate to Network -> Networks -> Custom Network -> Clusters Tab

If you look into the API. You will find that the cluster is represented as: GET /clusters/123 <cluster ..> <name>..</name> ... <link href="/ovirt-engine/api/clusters/123/networks" rel="networks"/> ... </cluster> So when you actually call the following in the SDK: Cluster cluster = sysService.clustersService().clusterService('123').get().send().cluster(); You will get the Cluster java object which excatly represent the above XML. (we have this concept quite nicely explained here[1]). So if you call 'cluster.networks()', you will have access to the link of the cluster networks. In order to follow the link a get the full network objects the SDK has followLink method of Connection class: https://github.com/oVirt/ovirt-engine-sdk-java/blob/master/sdk/src/test/java... So to fix your example and list the cluster networks statuses you should do the follwoing: List<Network> nets = sysService.clustersService().clusterService("123").get().send().cluster().networks(); for (Network n : connection.followLink(nets)) { System.out.println(n.name() + ": " + n.status().value()); } [1] https://github.com/oVirt/ovirt-engine-sdk/tree/master/sdk#usage On 15/10/2019 15:37, Jamie Holohan wrote:
Using the SDK how can I retrieve a clusters (network) status. I am able to retrieve a cluster object using code like this:
Cluster cluster = sysService.clustersService().clusterService(DataCenterUtils.getClusterObjectFromName(sysService, DEFAULT_CLUSTER_NAME).id()).get().send().cluster();
However I cannot see any variables associated with this object type that relate to its Network Status.
The information i'm referring to can be found on the UI after creating a custom network. Starting on the left panel Navigate to Network -> Networks -> Custom Network -> Clusters Tab _______________________________________________ Devel mailing list -- devel@ovirt.org To unsubscribe send an email to devel-leave@ovirt.org Privacy Statement: https://www.ovirt.org/site/privacy-policy/ oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/ List Archives: https://lists.ovirt.org/archives/list/devel@ovirt.org/message/HEAT56FCKS4DNK...
participants (2)
-
Jamie Holohan
-
Ondra Machacek