[libgovirt] Implement ovirt_vm_get_cdroms()



commit 431b414b6a08778f66ad8358678db84a08af189c
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Fri Aug 23 18:39:02 2013 +0200

    Implement ovirt_vm_get_cdroms()

 govirt/govirt.sym |    2 ++
 govirt/ovirt-vm.c |   43 +++++++++++++++++++++++++++++++++++++------
 govirt/ovirt-vm.h |    4 ++++
 3 files changed, 43 insertions(+), 6 deletions(-)
---
diff --git a/govirt/govirt.sym b/govirt/govirt.sym
index fad6d2a..b48e531 100644
--- a/govirt/govirt.sym
+++ b/govirt/govirt.sym
@@ -73,6 +73,8 @@ GOVIRT_0.2.1 {
         ovirt_storage_domain_new;
 
         ovirt_storage_domain_get_files;
+
+        ovirt_vm_get_cdroms;
 } GOVIRT_0.2.0;
 
 
diff --git a/govirt/ovirt-vm.c b/govirt/ovirt-vm.c
index 5606853..dcdeb9e 100644
--- a/govirt/ovirt-vm.c
+++ b/govirt/ovirt-vm.c
@@ -22,12 +22,7 @@
 
 #include <config.h>
 
-#include "ovirt-enum-types.h"
-#include "ovirt-error.h"
-#include "ovirt-proxy.h"
-#include "ovirt-rest-call.h"
-#include "ovirt-vm.h"
-#include "ovirt-vm-display.h"
+#include "govirt.h"
 #include "govirt-private.h"
 
 #include <rest/rest-xml-node.h>
@@ -46,6 +41,8 @@ static gboolean parse_ticket_status(RestXmlNode *root, OvirtVm *vm,
         (G_TYPE_INSTANCE_GET_PRIVATE((obj), OVIRT_TYPE_VM, OvirtVmPrivate))
 
 struct _OvirtVmPrivate {
+    OvirtCollection *cdroms;
+
     OvirtVmState state;
     OvirtVmDisplay *display;
 } ;
@@ -114,6 +111,7 @@ static void ovirt_vm_dispose(GObject *object)
 {
     OvirtVm *vm = OVIRT_VM(object);
 
+    g_clear_object(&vm->priv->cdroms);
     g_clear_object(&vm->priv->display);
 
     G_OBJECT_CLASS(ovirt_vm_parent_class)->dispose(object);
@@ -577,3 +575,36 @@ gboolean ovirt_vm_refresh_finish(OvirtVm *vm,
 
     return ovirt_rest_call_finish(result, err);
 }
+
+
+/**
+ * ovirt_vm_get_cdroms:
+ * @vm: a #OvirtVm
+ *
+ * Gets a #OvirtCollection representing the list of remote cdroms from a
+ * virtual machine object.  This method does not initiate any network
+ * activity, the remote cdrom list must be then be fetched using
+ * ovirt_collection_fetch() or ovirt_collection_fetch_async().
+ *
+ * Return value: (transfer full): a #OvirtCollection representing the list
+ * of cdroms associated with @vm.
+ */
+OvirtCollection *ovirt_vm_get_cdroms(OvirtVm *vm)
+{
+    const char *href;
+
+    g_return_val_if_fail(OVIRT_IS_VM(vm), NULL);
+
+    if (vm->priv->cdroms != NULL)
+        return vm->priv->cdroms;
+
+    href = ovirt_resource_get_sub_collection(OVIRT_RESOURCE(vm), "cdroms");
+    if (href == NULL)
+        return NULL;
+
+    vm->priv->cdroms =  ovirt_collection_new(href, "cdroms",
+                                             OVIRT_TYPE_CDROM,
+                                             "cdrom");
+
+    return vm->priv->cdroms;
+}
diff --git a/govirt/ovirt-vm.h b/govirt/ovirt-vm.h
index 901a6c6..c60abd2 100644
--- a/govirt/ovirt-vm.h
+++ b/govirt/ovirt-vm.h
@@ -24,6 +24,7 @@
 
 #include <gio/gio.h>
 #include <glib-object.h>
+#include <govirt/ovirt-collection.h>
 #include <govirt/ovirt-resource.h>
 #include <govirt/ovirt-types.h>
 
@@ -112,6 +113,9 @@ void ovirt_vm_refresh_async(OvirtVm *vm, OvirtProxy *proxy,
 gboolean ovirt_vm_refresh_finish(OvirtVm *vm,
                                  GAsyncResult *result,
                                  GError **err);
+
+OvirtCollection *ovirt_vm_get_cdroms(OvirtVm *vm);
+
 G_END_DECLS
 
 #endif /* __OVIRT_VM_H__ */


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