[libgovirt] proxy: Add ovirt_proxy_get_vms_internal()



commit a42cb029bc21ffef2dd45e5e088c3c75835237ce
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Fri Jul 24 15:47:14 2015 +0200

    proxy: Add ovirt_proxy_get_vms_internal()
    
    This internal function will be used by several of the subsequent commits
    in order to get the list of VMs after going through
    OvirtProxy->OvirtApi->OvirtCollection->VM GList
    
    The _internal() name is just a hack because the same
    ovirt_proxy_get_vms() is already exported but is deprecated, so using it
    would cause warnings. We could also do some #ifdef magic to make sure
    ovirt_proxy_get_vms() do not appear deprecated when libgovirt is being
    compiled, but for now this _internal() suffix will do.

 govirt/ovirt-proxy-private.h |    3 +++
 govirt/ovirt-proxy.c         |   24 ++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/govirt/ovirt-proxy-private.h b/govirt/ovirt-proxy-private.h
index b9cc153..45c84b0 100644
--- a/govirt/ovirt-proxy-private.h
+++ b/govirt/ovirt-proxy-private.h
@@ -69,6 +69,9 @@ void ovirt_rest_call_async(OvirtRestCall *call,
                            GDestroyNotify destroy_func);
 gboolean ovirt_rest_call_finish(GAsyncResult *result, GError **err);
 
+/* Work around G_GNUC_DEPRECATED attribute on ovirt_proxy_get_vms() */
+GList *ovirt_proxy_get_vms_internal(OvirtProxy *proxy);
+
 G_END_DECLS
 
 #endif /* __OVIRT_PROXY_H__ */
diff --git a/govirt/ovirt-proxy.c b/govirt/ovirt-proxy.c
index b63b79a..7241f11 100644
--- a/govirt/ovirt-proxy.c
+++ b/govirt/ovirt-proxy.c
@@ -1051,3 +1051,27 @@ ovirt_proxy_get_api(OvirtProxy *proxy)
 {
     return proxy->priv->api;
 }
+
+
+GList *ovirt_proxy_get_vms_internal(OvirtProxy *proxy)
+{
+    OvirtApi *api;
+    OvirtCollection *vm_collection;
+    GHashTable *vms;
+
+    g_return_val_if_fail(OVIRT_IS_PROXY(proxy), NULL);
+
+    api = ovirt_proxy_get_api(proxy);
+    if (api == NULL)
+        return NULL;
+
+    vm_collection = ovirt_api_get_vms(api);
+    if (vm_collection == NULL)
+        return NULL;
+
+    vms = ovirt_collection_get_resources(vm_collection);
+    if (vms == NULL)
+        return NULL;
+
+    return g_hash_table_get_values(vms);
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]