7cfb7a import libgovirt-0.3.4-8.el8

Merged and Committed by centosrcm 5 years ago
36 files changed. 4531 lines added. 0 lines removed.
.gitignore
file added
+2
.libgovirt.metadata
file added
+2
SOURCES/0001-proxy-Fix-persistent-session-with-oVirt-3.6.patch
file added
+52
SOURCES/0002-Force-use-of-v3-REST-API.patch
file added
+28
SOURCES/0003-New-storage-format-added-in-oVirt-4.1.patch
file added
+22
SOURCES/0004-proxy-Hold-reference-to-cancellable-object.patch
file added
+35
SOURCES/0005-proxy-Check-if-operation-is-cancelled-before-disconn.patch
file added
+40
SOURCES/0006-storage-domain-Factor-out-property-value-setting-fro.patch
file added
+108
SOURCES/0007-storage-domain-use-explicit-initialization-of-struct.patch
file added
+89
SOURCES/0008-storage-domain-Move-out-ovirt_resource_parse_xml-to-.patch
file added
+325
SOURCES/0009-utils-Remove-unused-function-ovirt_rest_xml_node_get.patch
file added
+57
SOURCES/0010-utils-Rename-ovirt_rest_xml_node_get_content_va-to-o.patch
file added
+91
SOURCES/0011-utils-Retrieve-node-attributes-in-ovirt_resource_par.patch
file added
+65
SOURCES/0012-utils-Support-G_TYPE_STRING-in-_set_property_value_f.patch
file added
+26
SOURCES/0013-utils-Support-G_TYPE_STRV-in-_set_property_value_fro.patch
file added
+111
SOURCES/0014-Introduce-auxiliary-function-ovirt_sub_collection_ne.patch
file added
+203
SOURCES/0015-New-API-functions-to-enable-search-queries-of-collec.patch
file added
+199
SOURCES/0016-Introduce-ovirt_resource_new-functions.patch
file added
+85
SOURCES/0017-Use-ovirt_resource_new-functions-instead-of-g_initab.patch
file added
+146
SOURCES/0018-Move-resource-type-definitions-to-ovirt-types.h.patch
file added
+136
SOURCES/0019-Initial-support-for-hosts.patch
file added
+515
SOURCES/0020-Initial-support-for-clusters.patch
file added
+519
SOURCES/0021-Initial-support-for-data-centers.patch
file added
+452
SOURCES/0022-vm-Introduce-ovirt_vm_get_host.patch
file added
+196
SOURCES/0023-vm-Introduce-ovirt_vm_get_cluster.patch
file added
+177
SOURCES/0024-host-Introduce-ovirt_host_get_cluster.patch
file added
+96
SOURCES/0025-cluster-Introduce-ovirt_cluster_get_data_center.patch
file added
+94
SOURCES/0026-storage-domain-Retrieve-data-center-ids.patch
file added
+93
SOURCES/0027-Add-missing-include-in-govirt.h.patch
file added
+26
SOURCES/0028-resource-Fix-ovirt_resource_rest_call_sync-return-va.patch
file added
+25
SOURCES/0029-resource-Fix-ovirt_resource_rest_call_sync-crash-on-.patch
file added
+39
SOURCES/0030-resource-Fix-ovirt_resource_init_from_xml_real-preco.patch
file added
+29
SOURCES/0031-resource-Update-xml-node-in-ovirt_resource_init_from.patch
file added
+61
SOURCES/0032-utils-Drop-type-member-from-OvirtXmlElement-struct.patch
file added
+151
SOURCES/libgovirt-0.3.4.tar.xz.sign
file added
+17
SPECS/libgovirt.spec
file added
+219
    import libgovirt-0.3.4-8.el8
    
        
file added
+2
.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ SOURCES/cfergeau-29AC6C82.keyring
2
+ SOURCES/libgovirt-0.3.4.tar.xz
file added
+2
.libgovirt.metadata ADDED
@@ -0,0 +1,2 @@
1
+ 84d3abd436c6f4e194aa3f7a58be17ec9ced0a82 SOURCES/cfergeau-29AC6C82.keyring
2
+ aa9d6f7f0c3f24e52117c1b93795df36cf882702 SOURCES/libgovirt-0.3.4.tar.xz
SOURCES/0001-proxy-Fix-persistent-session-with-oVirt-3.6.patch ADDED
@@ -0,0 +1,52 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: Christophe Fergeau <cfergeau@redhat.com>
3
+ Date: Tue, 14 Jun 2016 14:38:07 +0200
4
+ Subject: [PATCH] proxy: Fix persistent session with oVirt 3.6
5
+
6
+ commit d3683c2 "proxy: Only set 'Prefer: persistent-auth' with
7
+ jsession-id" was working as expected when using the
8
+ OvirtProxy::jsession-id and OvirtProxy::sso-token properties.
9
+
10
+ However, when not using these properties and expecting the jsessionid to
11
+ be set as a cookie during a regular HTTP session, this was not working
12
+ properly as oVirt is not sending a jsessionid cookie when Prefer:
13
+ persistent-auth is not set.
14
+
15
+ Consequently, we need to set it upon OvirtProxy creation in order not to
16
+ break this usecase. We don't add the header in RestProxyCall as was done
17
+ before as we want to be able to disable this addition after
18
+ OvirtProxy::sso-token has been set.
19
+ ---
20
+ govirt/ovirt-proxy.c | 5 ++---
21
+ 1 file changed, 2 insertions(+), 3 deletions(-)
22
+
23
+ diff --git a/govirt/ovirt-proxy.c b/govirt/ovirt-proxy.c
24
+ index fc0273f..08e42d2 100644
25
+ --- a/govirt/ovirt-proxy.c
26
+ +++ b/govirt/ovirt-proxy.c
27
+ @@ -801,9 +801,6 @@ static void ovirt_proxy_set_session_id(OvirtProxy *proxy, const char *session_id
28
+ cookie = soup_cookie_new("JSESSIONID", session_id, domain, "/ovirt-engine/api", -1);
29
+ soup_cookie_jar_add_cookie(proxy->priv->cookie_jar, cookie);
30
+ proxy->priv->jsessionid_cookie = cookie;
31
+ - ovirt_proxy_add_header(proxy, "Prefer", "persistent-auth");
32
+ - } else {
33
+ - ovirt_proxy_add_header(proxy, "Prefer", NULL);
34
+ }
35
+ g_free(url);
36
+ }
37
+ @@ -815,6 +812,7 @@ static void ovirt_proxy_set_sso_token(OvirtProxy *proxy, const char *sso_token)
38
+ g_free(proxy->priv->sso_token);
39
+ proxy->priv->sso_token = g_strdup(sso_token);
40
+
41
+ + ovirt_proxy_add_header(proxy, "Prefer", NULL);
42
+ header_value = g_strdup_printf("Bearer %s", sso_token);
43
+ ovirt_proxy_add_header(proxy, "Authorization", header_value);
44
+ g_free(header_value);
45
+ @@ -903,6 +901,7 @@ static void ovirt_proxy_constructed(GObject *gobject)
46
+ g_warning("Disabling strict checking of SSL certificates");
47
+ g_object_set(OVIRT_PROXY(gobject), "ssl-strict", FALSE, NULL);
48
+ }
49
+ + ovirt_proxy_add_header(OVIRT_PROXY(gobject), "Prefer", "persistent-auth");
50
+
51
+ /* Chain up to the parent class */
52
+ if (G_OBJECT_CLASS(ovirt_proxy_parent_class)->constructed)
SOURCES/0002-Force-use-of-v3-REST-API.patch ADDED
@@ -0,0 +1,28 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: Christophe Fergeau <cfergeau@redhat.com>
3
+ Date: Thu, 16 Jun 2016 11:10:27 +0200
4
+ Subject: [PATCH] Force use of v3 REST API
5
+
6
+ oVirt 4.0 introduced a slightly incompatible REST API, see
7
+ https://github.com/oVirt/ovirt-engine/tree/master/backend/manager/modules/restapi
8
+ A short term fix is to send a "Version: 3" header with each request,
9
+ which this commit does. This might stop working with oVirt 4.1 though.
10
+
11
+ Longer term fix is tracked in
12
+ https://bugzilla.gnome.org/show_bug.cgi?id=767724
13
+ ---
14
+ govirt/ovirt-proxy.c | 1 +
15
+ 1 file changed, 1 insertion(+)
16
+
17
+ diff --git a/govirt/ovirt-proxy.c b/govirt/ovirt-proxy.c
18
+ index 08e42d2..efe3284 100644
19
+ --- a/govirt/ovirt-proxy.c
20
+ +++ b/govirt/ovirt-proxy.c
21
+ @@ -902,6 +902,7 @@ static void ovirt_proxy_constructed(GObject *gobject)
22
+ g_object_set(OVIRT_PROXY(gobject), "ssl-strict", FALSE, NULL);
23
+ }
24
+ ovirt_proxy_add_header(OVIRT_PROXY(gobject), "Prefer", "persistent-auth");
25
+ + ovirt_proxy_add_header(OVIRT_PROXY(gobject), "Version", "3");
26
+
27
+ /* Chain up to the parent class */
28
+ if (G_OBJECT_CLASS(ovirt_proxy_parent_class)->constructed)
SOURCES/0003-New-storage-format-added-in-oVirt-4.1.patch ADDED
@@ -0,0 +1,22 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Tue, 21 Feb 2017 11:20:38 -0300
4
+ Subject: [PATCH] New storage format added in oVirt 4.1
5
+
6
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
7
+ ---
8
+ govirt/ovirt-storage-domain.h | 1 +
9
+ 1 file changed, 1 insertion(+)
10
+
11
+ diff --git a/govirt/ovirt-storage-domain.h b/govirt/ovirt-storage-domain.h
12
+ index 15c3340..79f1741 100644
13
+ --- a/govirt/ovirt-storage-domain.h
14
+ +++ b/govirt/ovirt-storage-domain.h
15
+ @@ -41,6 +41,7 @@ typedef enum {
16
+ OVIRT_STORAGE_DOMAIN_FORMAT_VERSION_V1,
17
+ OVIRT_STORAGE_DOMAIN_FORMAT_VERSION_V2,
18
+ OVIRT_STORAGE_DOMAIN_FORMAT_VERSION_V3,
19
+ + OVIRT_STORAGE_DOMAIN_FORMAT_VERSION_V4,
20
+ } OvirtStorageDomainFormatVersion;
21
+
22
+ typedef enum {
SOURCES/0004-proxy-Hold-reference-to-cancellable-object.patch ADDED
@@ -0,0 +1,35 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Thu, 2 Feb 2017 15:11:42 -0200
4
+ Subject: [PATCH] proxy: Hold reference to cancellable object
5
+
6
+ Being an asynchronous operation, there is no guarantee that the object
7
+ is valid by the time of the cleanup, so we hold a reference to it to
8
+ ensure it.
9
+
10
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
11
+ ---
12
+ govirt/ovirt-proxy.c | 3 ++-
13
+ 1 file changed, 2 insertions(+), 1 deletion(-)
14
+
15
+ diff --git a/govirt/ovirt-proxy.c b/govirt/ovirt-proxy.c
16
+ index efe3284..2b690b6 100644
17
+ --- a/govirt/ovirt-proxy.c
18
+ +++ b/govirt/ovirt-proxy.c
19
+ @@ -220,6 +220,7 @@ static void ovirt_proxy_call_async_data_free(OvirtProxyCallAsyncData *data)
20
+ if ((data->cancellable != NULL) && (data->cancellable_cb_id != 0)) {
21
+ g_cancellable_disconnect(data->cancellable, data->cancellable_cb_id);
22
+ }
23
+ + g_clear_object(&data->cancellable);
24
+ g_slice_free(OvirtProxyCallAsyncData, data);
25
+ }
26
+
27
+ @@ -284,7 +285,7 @@ void ovirt_rest_call_async(OvirtRestCall *call,
28
+ data->call_user_data = user_data;
29
+ data->destroy_call_data = destroy_func;
30
+ if (cancellable != NULL) {
31
+ - data->cancellable = cancellable;
32
+ + data->cancellable = g_object_ref(cancellable);
33
+ data->cancellable_cb_id = g_cancellable_connect(cancellable,
34
+ G_CALLBACK (call_async_cancelled_cb),
35
+ call, NULL);
SOURCES/0005-proxy-Check-if-operation-is-cancelled-before-disconn.patch ADDED
@@ -0,0 +1,40 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Thu, 2 Feb 2017 15:13:48 -0200
4
+ Subject: [PATCH] proxy: Check if operation is cancelled before disconnecting
5
+ signal
6
+
7
+ According to the documentation, g_cancellable_disconnect() waits for the
8
+ signal handler to finish, and if it is called from the handler itself, it
9
+ will result in a deadlock. To avoid it, we check if the operation is
10
+ cancelled and if so, call g_signal_handler_disconnect() instead of
11
+ g_cancellable_disconnect().
12
+
13
+ https://developer.gnome.org/gio/stable/GCancellable.html#g-cancellable-disconnect
14
+
15
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
16
+ ---
17
+ govirt/ovirt-proxy.c | 10 +++++++++-
18
+ 1 file changed, 9 insertions(+), 1 deletion(-)
19
+
20
+ diff --git a/govirt/ovirt-proxy.c b/govirt/ovirt-proxy.c
21
+ index 2b690b6..921e22e 100644
22
+ --- a/govirt/ovirt-proxy.c
23
+ +++ b/govirt/ovirt-proxy.c
24
+ @@ -218,7 +218,15 @@ static void ovirt_proxy_call_async_data_free(OvirtProxyCallAsyncData *data)
25
+ g_object_unref(G_OBJECT(data->result));
26
+ }
27
+ if ((data->cancellable != NULL) && (data->cancellable_cb_id != 0)) {
28
+ - g_cancellable_disconnect(data->cancellable, data->cancellable_cb_id);
29
+ + if (g_cancellable_is_cancelled(data->cancellable)) {
30
+ + /* Cancellable has already been cancelled, we don't need to use
31
+ + * g_cancellable_disconnect() to disconnect the signal handler
32
+ + * as we know the 'cancelled' signal is no longer going to be emitted
33
+ + */
34
+ + g_signal_handler_disconnect(data->cancellable, data->cancellable_cb_id);
35
+ + } else {
36
+ + g_cancellable_disconnect(data->cancellable, data->cancellable_cb_id);
37
+ + }
38
+ }
39
+ g_clear_object(&data->cancellable);
40
+ g_slice_free(OvirtProxyCallAsyncData, data);
SOURCES/0006-storage-domain-Factor-out-property-value-setting-fro.patch ADDED
@@ -0,0 +1,108 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Wed, 10 May 2017 15:45:36 -0300
4
+ Subject: [PATCH] storage-domain: Factor out property value setting from
5
+ ovirt_resource_parse_xml()
6
+
7
+ Instead of using chained if/else blocks, use a switch for the type. With
8
+ this small refactor we prepare to move this function to ovirt-utils so
9
+ that it can be reused by other objects.
10
+
11
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
12
+ ---
13
+ govirt/ovirt-storage-domain.c | 74 ++++++++++++++++++++++-------------
14
+ 1 file changed, 47 insertions(+), 27 deletions(-)
15
+
16
+ diff --git a/govirt/ovirt-storage-domain.c b/govirt/ovirt-storage-domain.c
17
+ index e7308bb..4087d75 100644
18
+ --- a/govirt/ovirt-storage-domain.c
19
+ +++ b/govirt/ovirt-storage-domain.c
20
+ @@ -277,6 +277,51 @@ OvirtStorageDomain *ovirt_storage_domain_new(void)
21
+ return OVIRT_STORAGE_DOMAIN(domain);
22
+ }
23
+
24
+ +static gboolean
25
+ +_set_property_value_from_type(GValue *value,
26
+ + GType type,
27
+ + const char *value_str,
28
+ + RestXmlNode *node)
29
+ +{
30
+ + gboolean ret = TRUE;
31
+ +
32
+ + if (g_type_is_a(type, OVIRT_TYPE_RESOURCE)) {
33
+ + GObject *resource_value = g_initable_new(type, NULL, NULL, "xml-node", node, NULL);
34
+ + g_value_set_object(value, resource_value);
35
+ + goto end;
36
+ + }
37
+ +
38
+ + /* All other types require valid value_str */
39
+ + if (value_str == NULL)
40
+ + return FALSE;
41
+ +
42
+ + if (G_TYPE_IS_ENUM(type)) {
43
+ + int enum_value = ovirt_utils_genum_get_value(type, value_str, 0);
44
+ + g_value_set_enum(value, enum_value);
45
+ + goto end;
46
+ + }
47
+ +
48
+ + switch(type) {
49
+ + case G_TYPE_BOOLEAN: {
50
+ + gboolean bool_value = ovirt_utils_boolean_from_string(value_str);
51
+ + g_value_set_boolean(value, bool_value);
52
+ + break;
53
+ + }
54
+ + case G_TYPE_UINT64: {
55
+ + guint64 int64_value = g_ascii_strtoull(value_str, NULL, 0);
56
+ + g_value_set_uint64(value, int64_value);
57
+ + break;
58
+ + }
59
+ + default: {
60
+ + g_warning("Unexpected type '%s' with value '%s'", g_type_name(type), value_str);
61
+ + ret = FALSE;
62
+ + }
63
+ + }
64
+ +
65
+ +end:
66
+ + return ret;
67
+ +}
68
+ +
69
+ typedef struct {
70
+ const char *xml_node;
71
+ GType type;
72
+ @@ -296,34 +341,9 @@ ovirt_resource_parse_xml(OvirtResource *resource,
73
+ GValue value = { 0, };
74
+
75
+ value_str = ovirt_rest_xml_node_get_content_from_path(node, elements->xml_node);
76
+ - if (value_str == NULL) {
77
+ - continue;
78
+ - }
79
+ g_value_init(&value, elements->type);
80
+ -
81
+ - if (G_TYPE_IS_ENUM(elements->type)) {
82
+ - int enum_value;
83
+ - enum_value = ovirt_utils_genum_get_value(elements->type,
84
+ - value_str, 0);
85
+ - g_value_set_enum(&value, enum_value);
86
+ - } else if (elements->type == G_TYPE_BOOLEAN) {
87
+ - gboolean bool_value;
88
+ -
89
+ - bool_value = ovirt_utils_boolean_from_string(value_str);
90
+ - g_value_set_boolean(&value, bool_value);
91
+ - } else if (elements->type == G_TYPE_UINT64) {
92
+ - guint64 int64_value;
93
+ -
94
+ - int64_value = g_ascii_strtoull(value_str, NULL, 0);
95
+ - g_value_set_uint64(&value, int64_value);
96
+ - } else if (g_type_is_a(elements->type, OVIRT_TYPE_RESOURCE)) {
97
+ - GObject *resource_value;
98
+ -
99
+ - resource_value = g_initable_new(elements->type, NULL, NULL,
100
+ - "xml-node", node, NULL);
101
+ - g_value_set_object(&value, resource_value);
102
+ - }
103
+ - g_object_set_property(G_OBJECT(resource), elements->prop_name, &value);
104
+ + if (_set_property_value_from_type(&value, elements->type, value_str, node))
105
+ + g_object_set_property(G_OBJECT(resource), elements->prop_name, &value);
106
+ g_value_unset(&value);
107
+ }
108
+
SOURCES/0007-storage-domain-use-explicit-initialization-of-struct.patch ADDED
@@ -0,0 +1,89 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Wed, 10 May 2017 16:12:01 -0300
4
+ Subject: [PATCH] storage-domain: use explicit initialization of struct
5
+ OvirtXmlElement members
6
+
7
+ Also, members have been reordered and the xml_node field has been
8
+ renamed to more proper xml_path.
9
+
10
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
11
+ ---
12
+ govirt/ovirt-storage-domain.c | 46 ++++++++++++++++++++++++++---------
13
+ 1 file changed, 34 insertions(+), 12 deletions(-)
14
+
15
+ diff --git a/govirt/ovirt-storage-domain.c b/govirt/ovirt-storage-domain.c
16
+ index 4087d75..07c0ef0 100644
17
+ --- a/govirt/ovirt-storage-domain.c
18
+ +++ b/govirt/ovirt-storage-domain.c
19
+ @@ -323,9 +323,9 @@ end:
20
+ }
21
+
22
+ typedef struct {
23
+ - const char *xml_node;
24
+ - GType type;
25
+ const char *prop_name;
26
+ + GType type;
27
+ + const char *xml_path;
28
+ } OvirtXmlElement;
29
+
30
+ static gboolean
31
+ @@ -336,11 +336,12 @@ ovirt_resource_parse_xml(OvirtResource *resource,
32
+ g_return_val_if_fail(OVIRT_IS_RESOURCE(resource), FALSE);
33
+ g_return_val_if_fail(elements != NULL, FALSE);
34
+
35
+ - for (;elements->xml_node != NULL; elements++) {
36
+ + for (;elements->xml_path != NULL; elements++) {
37
+ const char *value_str;
38
+ GValue value = { 0, };
39
+
40
+ - value_str = ovirt_rest_xml_node_get_content_from_path(node, elements->xml_node);
41
+ + value_str = ovirt_rest_xml_node_get_content_from_path(node, elements->xml_path);
42
+ +
43
+ g_value_init(&value, elements->type);
44
+ if (_set_property_value_from_type(&value, elements->type, value_str, node))
45
+ g_object_set_property(G_OBJECT(resource), elements->prop_name, &value);
46
+ @@ -355,14 +356,35 @@ ovirt_storage_domain_refresh_from_xml(OvirtStorageDomain *domain,
47
+ RestXmlNode *node)
48
+ {
49
+ OvirtXmlElement storage_domain_elements[] = {
50
+ - { "type", OVIRT_TYPE_STORAGE_DOMAIN_TYPE, "type" },
51
+ - { "master", G_TYPE_BOOLEAN, "master" },
52
+ - { "available", G_TYPE_UINT64, "available" },
53
+ - { "used", G_TYPE_UINT64, "used" },
54
+ - { "committed", G_TYPE_UINT64, "committed" },
55
+ - { "storage_format", OVIRT_TYPE_STORAGE_DOMAIN_FORMAT_VERSION, "version" },
56
+ - { "status/state", OVIRT_TYPE_STORAGE_DOMAIN_STATE, "state" },
57
+ - { NULL, G_TYPE_INVALID, NULL }
58
+ + { .prop_name = "type",
59
+ + .type = OVIRT_TYPE_STORAGE_DOMAIN_TYPE,
60
+ + .xml_path = "type",
61
+ + },
62
+ + { .prop_name = "master",
63
+ + .type = G_TYPE_BOOLEAN,
64
+ + .xml_path = "master",
65
+ + },
66
+ + { .prop_name = "available",
67
+ + .type = G_TYPE_UINT64,
68
+ + .xml_path = "available",
69
+ + },
70
+ + { .prop_name = "used",
71
+ + .type = G_TYPE_UINT64,
72
+ + .xml_path = "used",
73
+ + },
74
+ + { .prop_name = "committed",
75
+ + .type = G_TYPE_UINT64,
76
+ + .xml_path = "committed",
77
+ + },
78
+ + { .prop_name = "version",
79
+ + .type = OVIRT_TYPE_STORAGE_DOMAIN_FORMAT_VERSION,
80
+ + .xml_path = "storage_format",
81
+ + },
82
+ + { .prop_name = "state",
83
+ + .type = OVIRT_TYPE_STORAGE_DOMAIN_STATE,
84
+ + .xml_path = "status/state",
85
+ + },
86
+ + { NULL , }
87
+ };
88
+
89
+ return ovirt_resource_parse_xml(OVIRT_RESOURCE(domain), node, storage_domain_elements);
SOURCES/0008-storage-domain-Move-out-ovirt_resource_parse_xml-to-.patch ADDED
@@ -0,0 +1,325 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Thu, 22 Jun 2017 13:06:53 -0300
4
+ Subject: [PATCH] storage-domain: Move out ovirt_resource_parse_xml() to
5
+ ovirt-utils
6
+
7
+ There were a couple of tweaks to the function:
8
+
9
+ 1) Renamed to ovirt_rest_xml_node_parse()
10
+ More suited to the task performed.
11
+
12
+ 2) Validates GObject instead of OvirtResource
13
+ This removes the restriction of usage by a OvirtResource, and in the
14
+ future it can also be used by OvirtVmDisplay to parse the elements.
15
+ It also makes it more coherent to its purpose, as the function only
16
+ sets properties of a GObject and does not really require a
17
+ OvirtResource.
18
+
19
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
20
+ ---
21
+ govirt/ovirt-storage-domain.c | 152 +++++++---------------------------
22
+ govirt/ovirt-utils.c | 71 +++++++++++++++-
23
+ govirt/ovirt-utils.h | 13 ++-
24
+ 3 files changed, 113 insertions(+), 123 deletions(-)
25
+
26
+ diff --git a/govirt/ovirt-storage-domain.c b/govirt/ovirt-storage-domain.c
27
+ index 07c0ef0..0582203 100644
28
+ --- a/govirt/ovirt-storage-domain.c
29
+ +++ b/govirt/ovirt-storage-domain.c
30
+ @@ -53,10 +53,6 @@ enum {
31
+ PROP_STATE
32
+ };
33
+
34
+ -static gboolean
35
+ -ovirt_storage_domain_refresh_from_xml(OvirtStorageDomain *domain,
36
+ - RestXmlNode *node);
37
+ -
38
+ static void ovirt_storage_domain_get_property(GObject *object,
39
+ guint prop_id,
40
+ GValue *value,
41
+ @@ -145,10 +141,39 @@ static gboolean ovirt_storage_domain_init_from_xml(OvirtResource *resource,
42
+ {
43
+ gboolean parsed_ok;
44
+ OvirtResourceClass *parent_class;
45
+ - OvirtStorageDomain *domain;
46
+ + OvirtXmlElement storage_domain_elements[] = {
47
+ + { .prop_name = "type",
48
+ + .type = OVIRT_TYPE_STORAGE_DOMAIN_TYPE,
49
+ + .xml_path = "type",
50
+ + },
51
+ + { .prop_name = "master",
52
+ + .type = G_TYPE_BOOLEAN,
53
+ + .xml_path = "master",
54
+ + },
55
+ + { .prop_name = "available",
56
+ + .type = G_TYPE_UINT64,
57
+ + .xml_path = "available",
58
+ + },
59
+ + { .prop_name = "used",
60
+ + .type = G_TYPE_UINT64,
61
+ + .xml_path = "used",
62
+ + },
63
+ + { .prop_name = "committed",
64
+ + .type = G_TYPE_UINT64,
65
+ + .xml_path = "committed",
66
+ + },
67
+ + { .prop_name = "version",
68
+ + .type = OVIRT_TYPE_STORAGE_DOMAIN_FORMAT_VERSION,
69
+ + .xml_path = "storage_format",
70
+ + },
71
+ + { .prop_name = "state",
72
+ + .type = OVIRT_TYPE_STORAGE_DOMAIN_STATE,
73
+ + .xml_path = "status/state",
74
+ + },
75
+ + { NULL , }
76
+ + };
77
+
78
+ - domain = OVIRT_STORAGE_DOMAIN(resource);
79
+ - parsed_ok = ovirt_storage_domain_refresh_from_xml(domain, node);
80
+ + parsed_ok = ovirt_rest_xml_node_parse(node, G_OBJECT(resource), storage_domain_elements);
81
+ if (!parsed_ok) {
82
+ return FALSE;
83
+ }
84
+ @@ -277,119 +302,6 @@ OvirtStorageDomain *ovirt_storage_domain_new(void)
85
+ return OVIRT_STORAGE_DOMAIN(domain);
86
+ }
87
+
88
+ -static gboolean
89
+ -_set_property_value_from_type(GValue *value,
90
+ - GType type,
91
+ - const char *value_str,
92
+ - RestXmlNode *node)
93
+ -{
94
+ - gboolean ret = TRUE;
95
+ -
96
+ - if (g_type_is_a(type, OVIRT_TYPE_RESOURCE)) {
97
+ - GObject *resource_value = g_initable_new(type, NULL, NULL, "xml-node", node, NULL);
98
+ - g_value_set_object(value, resource_value);
99
+ - goto end;
100
+ - }
101
+ -
102
+ - /* All other types require valid value_str */
103
+ - if (value_str == NULL)
104
+ - return FALSE;
105
+ -
106
+ - if (G_TYPE_IS_ENUM(type)) {
107
+ - int enum_value = ovirt_utils_genum_get_value(type, value_str, 0);
108
+ - g_value_set_enum(value, enum_value);
109
+ - goto end;
110
+ - }
111
+ -
112
+ - switch(type) {
113
+ - case G_TYPE_BOOLEAN: {
114
+ - gboolean bool_value = ovirt_utils_boolean_from_string(value_str);
115
+ - g_value_set_boolean(value, bool_value);
116
+ - break;
117
+ - }
118
+ - case G_TYPE_UINT64: {
119
+ - guint64 int64_value = g_ascii_strtoull(value_str, NULL, 0);
120
+ - g_value_set_uint64(value, int64_value);
121
+ - break;
122
+ - }
123
+ - default: {
124
+ - g_warning("Unexpected type '%s' with value '%s'", g_type_name(type), value_str);
125
+ - ret = FALSE;
126
+ - }
127
+ - }
128
+ -
129
+ -end:
130
+ - return ret;
131
+ -}
132
+ -
133
+ -typedef struct {
134
+ - const char *prop_name;
135
+ - GType type;
136
+ - const char *xml_path;
137
+ -} OvirtXmlElement;
138
+ -
139
+ -static gboolean
140
+ -ovirt_resource_parse_xml(OvirtResource *resource,
141
+ - RestXmlNode *node,
142
+ - OvirtXmlElement *elements)
143
+ -{
144
+ - g_return_val_if_fail(OVIRT_IS_RESOURCE(resource), FALSE);
145
+ - g_return_val_if_fail(elements != NULL, FALSE);
146
+ -
147
+ - for (;elements->xml_path != NULL; elements++) {
148
+ - const char *value_str;
149
+ - GValue value = { 0, };
150
+ -
151
+ - value_str = ovirt_rest_xml_node_get_content_from_path(node, elements->xml_path);
152
+ -
153
+ - g_value_init(&value, elements->type);
154
+ - if (_set_property_value_from_type(&value, elements->type, value_str, node))
155
+ - g_object_set_property(G_OBJECT(resource), elements->prop_name, &value);
156
+ - g_value_unset(&value);
157
+ - }
158
+ -
159
+ - return TRUE;
160
+ -}
161
+ -
162
+ -static gboolean
163
+ -ovirt_storage_domain_refresh_from_xml(OvirtStorageDomain *domain,
164
+ - RestXmlNode *node)
165
+ -{
166
+ - OvirtXmlElement storage_domain_elements[] = {
167
+ - { .prop_name = "type",
168
+ - .type = OVIRT_TYPE_STORAGE_DOMAIN_TYPE,
169
+ - .xml_path = "type",
170
+ - },
171
+ - { .prop_name = "master",
172
+ - .type = G_TYPE_BOOLEAN,
173
+ - .xml_path = "master",
174
+ - },
175
+ - { .prop_name = "available",
176
+ - .type = G_TYPE_UINT64,
177
+ - .xml_path = "available",
178
+ - },
179
+ - { .prop_name = "used",
180
+ - .type = G_TYPE_UINT64,
181
+ - .xml_path = "used",
182
+ - },
183
+ - { .prop_name = "committed",
184
+ - .type = G_TYPE_UINT64,
185
+ - .xml_path = "committed",
186
+ - },
187
+ - { .prop_name = "version",
188
+ - .type = OVIRT_TYPE_STORAGE_DOMAIN_FORMAT_VERSION,
189
+ - .xml_path = "storage_format",
190
+ - },
191
+ - { .prop_name = "state",
192
+ - .type = OVIRT_TYPE_STORAGE_DOMAIN_STATE,
193
+ - .xml_path = "status/state",
194
+ - },
195
+ - { NULL , }
196
+ - };
197
+ -
198
+ - return ovirt_resource_parse_xml(OVIRT_RESOURCE(domain), node, storage_domain_elements);
199
+ -}
200
+ -
201
+
202
+ /**
203
+ * ovirt_storage_domain_get_files:
204
+ diff --git a/govirt/ovirt-utils.c b/govirt/ovirt-utils.c
205
+ index 0e0134c..44ea7da 100644
206
+ --- a/govirt/ovirt-utils.c
207
+ +++ b/govirt/ovirt-utils.c
208
+ @@ -31,6 +31,7 @@
209
+ #include "ovirt-utils.h"
210
+
211
+ #include "ovirt-error.h"
212
+ +#include "ovirt-resource.h"
213
+
214
+ RestXmlNode *
215
+ ovirt_rest_xml_node_from_call(RestProxyCall *call)
216
+ @@ -77,7 +78,7 @@ ovirt_rest_xml_node_get_content_va(RestXmlNode *node,
217
+ return node->content;
218
+ }
219
+
220
+ -G_GNUC_INTERNAL const char *
221
+ +static const char *
222
+ ovirt_rest_xml_node_get_content_from_path(RestXmlNode *node, const char *path)
223
+ {
224
+ GStrv pathv;
225
+ @@ -109,6 +110,74 @@ ovirt_rest_xml_node_get_content(RestXmlNode *node, ...)
226
+ return content;
227
+ }
228
+
229
+ +static gboolean
230
+ +_set_property_value_from_type(GValue *value,
231
+ + GType type,
232
+ + const char *value_str,
233
+ + RestXmlNode *node)
234
+ +{
235
+ + gboolean ret = TRUE;
236
+ +
237
+ + if (g_type_is_a(type, OVIRT_TYPE_RESOURCE)) {
238
+ + GObject *resource_value = g_initable_new(type, NULL, NULL, "xml-node", node, NULL);
239
+ + g_value_set_object(value, resource_value);
240
+ + goto end;
241
+ + }
242
+ +
243
+ + /* All other types require valid value_str */
244
+ + if (value_str == NULL)
245
+ + return FALSE;
246
+ +
247
+ + if (G_TYPE_IS_ENUM(type)) {
248
+ + int enum_value = ovirt_utils_genum_get_value(type, value_str, 0);
249
+ + g_value_set_enum(value, enum_value);
250
+ + goto end;
251
+ + }
252
+ +
253
+ + switch(type) {
254
+ + case G_TYPE_BOOLEAN: {
255
+ + gboolean bool_value = ovirt_utils_boolean_from_string(value_str);
256
+ + g_value_set_boolean(value, bool_value);
257
+ + break;
258
+ + }
259
+ + case G_TYPE_UINT64: {
260
+ + guint64 int64_value = g_ascii_strtoull(value_str, NULL, 0);
261
+ + g_value_set_uint64(value, int64_value);
262
+ + break;
263
+ + }
264
+ + default: {
265
+ + g_warning("Unexpected type '%s' with value '%s'", g_type_name(type), value_str);
266
+ + ret = FALSE;
267
+ + }
268
+ + }
269
+ +
270
+ +end:
271
+ + return ret;
272
+ +}
273
+ +
274
+ +gboolean
275
+ +ovirt_rest_xml_node_parse(RestXmlNode *node,
276
+ + GObject *object,
277
+ + OvirtXmlElement *elements)
278
+ +{
279
+ + g_return_val_if_fail(G_IS_OBJECT(object), FALSE);
280
+ + g_return_val_if_fail(elements != NULL, FALSE);
281
+ +
282
+ + for (;elements->xml_path != NULL; elements++) {
283
+ + const char *value_str;
284
+ + GValue value = { 0, };
285
+ +
286
+ + value_str = ovirt_rest_xml_node_get_content_from_path(node, elements->xml_path);
287
+ +
288
+ + g_value_init(&value, elements->type);
289
+ + if (_set_property_value_from_type(&value, elements->type, value_str, node))
290
+ + g_object_set_property(object, elements->prop_name, &value);
291
+ + g_value_unset(&value);
292
+ + }
293
+ +
294
+ + return TRUE;
295
+ +}
296
+ +
297
+
298
+ /* These 2 functions come from
299
+ * libvirt-glib/libvirt-gconfig/libvirt-gconfig-helpers.c
300
+ diff --git a/govirt/ovirt-utils.h b/govirt/ovirt-utils.h
301
+ index 3f43fc9..4fd4164 100644
302
+ --- a/govirt/ovirt-utils.h
303
+ +++ b/govirt/ovirt-utils.h
304
+ @@ -27,10 +27,19 @@
305
+
306
+ G_BEGIN_DECLS
307
+
308
+ +typedef struct _OvirtXmlElement OvirtXmlElement;
309
+ +struct _OvirtXmlElement
310
+ +{
311
+ + const char *prop_name;
312
+ + GType type;
313
+ + const char *xml_path;
314
+ +};
315
+ +
316
+ RestXmlNode *ovirt_rest_xml_node_from_call(RestProxyCall *call);
317
+ const char *ovirt_rest_xml_node_get_content(RestXmlNode *node, ...);
318
+ -const char *ovirt_rest_xml_node_get_content_from_path(RestXmlNode *node,
319
+ - const char *path);
320
+ +gboolean ovirt_rest_xml_node_parse(RestXmlNode *node,
321
+ + GObject *object,
322
+ + OvirtXmlElement *elements);
323
+ gboolean ovirt_utils_gerror_from_xml_fault(RestXmlNode *root, GError **error);
324
+ gboolean g_object_set_guint_property_from_xml(GObject *g_object,
325
+ RestXmlNode *node,
SOURCES/0009-utils-Remove-unused-function-ovirt_rest_xml_node_get.patch ADDED
@@ -0,0 +1,57 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Fri, 28 Apr 2017 17:16:31 -0300
4
+ Subject: [PATCH] utils: Remove unused function
5
+ ovirt_rest_xml_node_get_content()
6
+
7
+ Most uses were removed in dbf8dd85 "Add generic resource parser" and the
8
+ last use in 18d7c005 "storage-domain: Parse storage domain status"
9
+
10
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
11
+ ---
12
+ govirt/ovirt-utils.c | 19 -------------------
13
+ govirt/ovirt-utils.h | 1 -
14
+ 2 files changed, 20 deletions(-)
15
+
16
+ diff --git a/govirt/ovirt-utils.c b/govirt/ovirt-utils.c
17
+ index 44ea7da..951c693 100644
18
+ --- a/govirt/ovirt-utils.c
19
+ +++ b/govirt/ovirt-utils.c
20
+ @@ -91,25 +91,6 @@ ovirt_rest_xml_node_get_content_from_path(RestXmlNode *node, const char *path)
21
+ return content;
22
+ }
23
+
24
+ -G_GNUC_INTERNAL const char *
25
+ -ovirt_rest_xml_node_get_content(RestXmlNode *node, ...)
26
+ -{
27
+ - va_list args;
28
+ - const char *content;
29
+ -
30
+ - g_return_val_if_fail(node != NULL, NULL);
31
+ -
32
+ - va_start(args, node);
33
+ -
34
+ - content = ovirt_rest_xml_node_get_content_va(node, &args, NULL);
35
+ -
36
+ - va_end(args);
37
+ -
38
+ - g_warn_if_fail(node != NULL);
39
+ -
40
+ - return content;
41
+ -}
42
+ -
43
+ static gboolean
44
+ _set_property_value_from_type(GValue *value,
45
+ GType type,
46
+ diff --git a/govirt/ovirt-utils.h b/govirt/ovirt-utils.h
47
+ index 4fd4164..e786311 100644
48
+ --- a/govirt/ovirt-utils.h
49
+ +++ b/govirt/ovirt-utils.h
50
+ @@ -36,7 +36,6 @@ struct _OvirtXmlElement
51
+ };
52
+
53
+ RestXmlNode *ovirt_rest_xml_node_from_call(RestProxyCall *call);
54
+ -const char *ovirt_rest_xml_node_get_content(RestXmlNode *node, ...);
55
+ gboolean ovirt_rest_xml_node_parse(RestXmlNode *node,
56
+ GObject *object,
57
+ OvirtXmlElement *elements);
SOURCES/0010-utils-Rename-ovirt_rest_xml_node_get_content_va-to-o.patch ADDED
@@ -0,0 +1,91 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Fri, 19 May 2017 00:31:46 -0300
4
+ Subject: [PATCH] utils: Rename ovirt_rest_xml_node_get_content_va() to
5
+ ovirt_rest_xml_node_find()
6
+
7
+ It is more useful to make this function retrieve a sub node and let the
8
+ caller do what it wants with that node, instead of returning the content
9
+ directly.
10
+
11
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
12
+ ---
13
+ govirt/ovirt-utils.c | 59 +++++++++++++++++++-------------------------
14
+ 1 file changed, 26 insertions(+), 33 deletions(-)
15
+
16
+ diff --git a/govirt/ovirt-utils.c b/govirt/ovirt-utils.c
17
+ index 951c693..c0541e9 100644
18
+ --- a/govirt/ovirt-utils.c
19
+ +++ b/govirt/ovirt-utils.c
20
+ @@ -50,45 +50,38 @@ ovirt_rest_xml_node_from_call(RestProxyCall *call)
21
+ return node;
22
+ }
23
+
24
+ -static const char *
25
+ -ovirt_rest_xml_node_get_content_va(RestXmlNode *node,
26
+ - va_list *args,
27
+ - GStrv str_array)
28
+ -{
29
+ - g_return_val_if_fail((args != NULL) || (str_array != NULL), NULL);
30
+ -
31
+ - while (TRUE) {
32
+ - const char *node_name;
33
+ -
34
+ - if (args != NULL) {
35
+ - node_name = va_arg(*args, const char *);
36
+ - } else {
37
+ - node_name = *str_array;
38
+ - str_array++;
39
+ - }
40
+ - if (node_name == NULL)
41
+ - break;
42
+ - node = rest_xml_node_find(node, node_name);
43
+ - if (node == NULL) {
44
+ - g_debug("could not find XML node '%s'", node_name);
45
+ - return NULL;
46
+ - }
47
+ - }
48
+ -
49
+ - return node->content;
50
+ -}
51
+ -
52
+ -static const char *
53
+ -ovirt_rest_xml_node_get_content_from_path(RestXmlNode *node, const char *path)
54
+ +static RestXmlNode *
55
+ +ovirt_rest_xml_node_find(RestXmlNode *node, const char *path)
56
+ {
57
+ + guint i;
58
+ GStrv pathv;
59
+ - const char *content;
60
+ +
61
+ + g_return_val_if_fail((path != NULL), NULL);
62
+
63
+ pathv = g_strsplit(path, "/", -1);
64
+ - content = ovirt_rest_xml_node_get_content_va(node, NULL, pathv);
65
+ +
66
+ + for (i = 0; i < g_strv_length(pathv); ++i) {
67
+ + node = rest_xml_node_find(node, pathv[i]);
68
+ + if (node == NULL) {
69
+ + g_debug("could not find XML node '%s'", pathv[i]);
70
+ + break;
71
+ + }
72
+ + }
73
+ +
74
+ g_strfreev(pathv);
75
+
76
+ - return content;
77
+ + return node;
78
+ +}
79
+ +
80
+ +static const char *
81
+ +ovirt_rest_xml_node_get_content_from_path(RestXmlNode *node, const char *path)
82
+ +{
83
+ + node = ovirt_rest_xml_node_find(node, path);
84
+ +
85
+ + if (node == NULL)
86
+ + return NULL;
87
+ +
88
+ + return node->content;
89
+ }
90
+
91
+ static gboolean
SOURCES/0011-utils-Retrieve-node-attributes-in-ovirt_resource_par.patch ADDED
@@ -0,0 +1,65 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Thu, 18 May 2017 17:53:33 -0300
4
+ Subject: [PATCH] utils: Retrieve node attributes in ovirt_resource_parse_xml()
5
+
6
+ This commit adds a new field to the OvirtXmlElement struct, which is
7
+ used to retrieve an attribute from the xml node. It is optional, meaning
8
+ that, if not informed, the function will still retrieve the node
9
+ contents instead.
10
+
11
+ We also introduce ovirt_rest_xml_node_get_attr_from_path() function,
12
+ to retrieve the given attribute value from the path below the node, much
13
+ similar to ovirt_rest_xml_node_get_content_from_path().
14
+
15
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
16
+ ---
17
+ govirt/ovirt-utils.c | 15 ++++++++++++++-
18
+ govirt/ovirt-utils.h | 1 +
19
+ 2 files changed, 15 insertions(+), 1 deletion(-)
20
+
21
+ diff --git a/govirt/ovirt-utils.c b/govirt/ovirt-utils.c
22
+ index c0541e9..b9b7c15 100644
23
+ --- a/govirt/ovirt-utils.c
24
+ +++ b/govirt/ovirt-utils.c
25
+ @@ -84,6 +84,16 @@ ovirt_rest_xml_node_get_content_from_path(RestXmlNode *node, const char *path)
26
+ return node->content;
27
+ }
28
+
29
+ +static const char *
30
+ +ovirt_rest_xml_node_get_attr_from_path(RestXmlNode *node, const char *path, const char *attr)
31
+ +{
32
+ + node = ovirt_rest_xml_node_find(node, path);
33
+ + if (node == NULL)
34
+ + return NULL;
35
+ +
36
+ + return rest_xml_node_get_attr(node, attr);
37
+ +}
38
+ +
39
+ static gboolean
40
+ _set_property_value_from_type(GValue *value,
41
+ GType type,
42
+ @@ -141,7 +151,10 @@ ovirt_rest_xml_node_parse(RestXmlNode *node,
43
+ const char *value_str;
44
+ GValue value = { 0, };
45
+
46
+ - value_str = ovirt_rest_xml_node_get_content_from_path(node, elements->xml_path);
47
+ + if (elements->xml_attr != NULL)
48
+ + value_str = ovirt_rest_xml_node_get_attr_from_path(node, elements->xml_path, elements->xml_attr);
49
+ + else
50
+ + value_str = ovirt_rest_xml_node_get_content_from_path(node, elements->xml_path);
51
+
52
+ g_value_init(&value, elements->type);
53
+ if (_set_property_value_from_type(&value, elements->type, value_str, node))
54
+ diff --git a/govirt/ovirt-utils.h b/govirt/ovirt-utils.h
55
+ index e786311..545847a 100644
56
+ --- a/govirt/ovirt-utils.h
57
+ +++ b/govirt/ovirt-utils.h
58
+ @@ -33,6 +33,7 @@ struct _OvirtXmlElement
59
+ const char *prop_name;
60
+ GType type;
61
+ const char *xml_path;
62
+ + const char *xml_attr; /* if NULL, retrieve node content instead of attribute */
63
+ };
64
+
65
+ RestXmlNode *ovirt_rest_xml_node_from_call(RestProxyCall *call);
SOURCES/0012-utils-Support-G_TYPE_STRING-in-_set_property_value_f.patch ADDED
@@ -0,0 +1,26 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Wed, 10 May 2017 15:46:27 -0300
4
+ Subject: [PATCH] utils: Support G_TYPE_STRING in
5
+ _set_property_value_from_type()
6
+
7
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
8
+ ---
9
+ govirt/ovirt-utils.c | 4 ++++
10
+ 1 file changed, 4 insertions(+)
11
+
12
+ diff --git a/govirt/ovirt-utils.c b/govirt/ovirt-utils.c
13
+ index b9b7c15..fafb9ec 100644
14
+ --- a/govirt/ovirt-utils.c
15
+ +++ b/govirt/ovirt-utils.c
16
+ @@ -124,6 +124,10 @@ _set_property_value_from_type(GValue *value,
17
+ g_value_set_boolean(value, bool_value);
18
+ break;
19
+ }
20
+ + case G_TYPE_STRING: {
21
+ + g_value_set_string(value, value_str);
22
+ + break;
23
+ + }
24
+ case G_TYPE_UINT64: {
25
+ guint64 int64_value = g_ascii_strtoull(value_str, NULL, 0);
26
+ g_value_set_uint64(value, int64_value);
SOURCES/0013-utils-Support-G_TYPE_STRV-in-_set_property_value_fro.patch ADDED
@@ -0,0 +1,111 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Thu, 11 May 2017 17:31:43 -0300
4
+ Subject: [PATCH] utils: Support G_TYPE_STRV in _set_property_value_from_type()
5
+
6
+ Because user can require either the attribute or the node content, it
7
+ was necessary to change the function signature to receive both
8
+ parameters.
9
+
10
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
11
+ ---
12
+ govirt/ovirt-utils.c | 63 ++++++++++++++++++++++++++++++++++++++------
13
+ 1 file changed, 55 insertions(+), 8 deletions(-)
14
+
15
+ diff --git a/govirt/ovirt-utils.c b/govirt/ovirt-utils.c
16
+ index fafb9ec..a200e48 100644
17
+ --- a/govirt/ovirt-utils.c
18
+ +++ b/govirt/ovirt-utils.c
19
+ @@ -94,20 +94,73 @@ ovirt_rest_xml_node_get_attr_from_path(RestXmlNode *node, const char *path, cons
20
+ return rest_xml_node_get_attr(node, attr);
21
+ }
22
+
23
+ +static GStrv
24
+ +ovirt_rest_xml_node_get_str_array_from_path(RestXmlNode *node, const char *path, const char *attr)
25
+ +{
26
+ + GArray *array;
27
+ + GHashTableIter iter;
28
+ + gpointer sub_node;
29
+ +
30
+ + node = ovirt_rest_xml_node_find(node, path);
31
+ + if (node == NULL)
32
+ + return NULL;
33
+ +
34
+ + array = g_array_new(TRUE, FALSE, sizeof(gchar *));
35
+ +
36
+ + g_hash_table_iter_init(&iter, node->children);
37
+ + while (g_hash_table_iter_next(&iter, NULL, &sub_node)) {
38
+ + const char *value;
39
+ + char *array_value;
40
+ +
41
+ + node = (RestXmlNode *) sub_node;
42
+ +
43
+ + if (attr != NULL)
44
+ + value = rest_xml_node_get_attr(node, attr);
45
+ + else
46
+ + value = node->content;
47
+ +
48
+ + if (value == NULL) {
49
+ + g_warning("node %s%s is NULL", attr ? "attribute:" : "content", attr ? attr : "" );
50
+ + continue;
51
+ + }
52
+ +
53
+ + array_value = g_strdup(value);
54
+ + g_array_append_val(array, array_value);
55
+ + }
56
+ +
57
+ + return (GStrv) g_array_free(array, FALSE);
58
+ +}
59
+ +
60
+ static gboolean
61
+ _set_property_value_from_type(GValue *value,
62
+ GType type,
63
+ - const char *value_str,
64
+ + const char *path,
65
+ + const char *attr,
66
+ RestXmlNode *node)
67
+ {
68
+ gboolean ret = TRUE;
69
+ + const char *value_str;
70
+
71
+ if (g_type_is_a(type, OVIRT_TYPE_RESOURCE)) {
72
+ GObject *resource_value = g_initable_new(type, NULL, NULL, "xml-node", node, NULL);
73
+ g_value_set_object(value, resource_value);
74
+ goto end;
75
+ + } else if (g_type_is_a(type, G_TYPE_STRV)) {
76
+ + GStrv strv_value = ovirt_rest_xml_node_get_str_array_from_path(node, path, attr);
77
+ + if (strv_value == NULL) {
78
+ + ret = FALSE;
79
+ + goto end;
80
+ + }
81
+ +
82
+ + g_value_take_boxed(value, strv_value);
83
+ + goto end;
84
+ }
85
+
86
+ + if (attr != NULL)
87
+ + value_str = ovirt_rest_xml_node_get_attr_from_path(node, path, attr);
88
+ + else
89
+ + value_str = ovirt_rest_xml_node_get_content_from_path(node, path);
90
+ +
91
+ /* All other types require valid value_str */
92
+ if (value_str == NULL)
93
+ return FALSE;
94
+ @@ -152,16 +205,10 @@ ovirt_rest_xml_node_parse(RestXmlNode *node,
95
+ g_return_val_if_fail(elements != NULL, FALSE);
96
+
97
+ for (;elements->xml_path != NULL; elements++) {
98
+ - const char *value_str;
99
+ GValue value = { 0, };
100
+
101
+ - if (elements->xml_attr != NULL)
102
+ - value_str = ovirt_rest_xml_node_get_attr_from_path(node, elements->xml_path, elements->xml_attr);
103
+ - else
104
+ - value_str = ovirt_rest_xml_node_get_content_from_path(node, elements->xml_path);
105
+ -
106
+ g_value_init(&value, elements->type);
107
+ - if (_set_property_value_from_type(&value, elements->type, value_str, node))
108
+ + if (_set_property_value_from_type(&value, elements->type, elements->xml_path, elements->xml_attr, node))
109
+ g_object_set_property(object, elements->prop_name, &value);
110
+ g_value_unset(&value);
111
+ }
SOURCES/0014-Introduce-auxiliary-function-ovirt_sub_collection_ne.patch ADDED
@@ -0,0 +1,203 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Thu, 18 May 2017 16:45:37 -0300
4
+ Subject: [PATCH] Introduce auxiliary function
5
+ ovirt_sub_collection_new_from_resource()
6
+
7
+ This function eliminates duplication of code used to create a
8
+ subcollection from a resource. Users are updated accordingly.
9
+
10
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
11
+ ---
12
+ govirt/ovirt-api.c | 50 +++++++++++--------------------
13
+ govirt/ovirt-collection-private.h | 5 ++++
14
+ govirt/ovirt-collection.c | 15 ++++++++++
15
+ govirt/ovirt-storage-domain.c | 18 ++++-------
16
+ govirt/ovirt-vm.c | 18 ++++-------
17
+ 5 files changed, 50 insertions(+), 56 deletions(-)
18
+
19
+ diff --git a/govirt/ovirt-api.c b/govirt/ovirt-api.c
20
+ index 001ee42..37c0935 100644
21
+ --- a/govirt/ovirt-api.c
22
+ +++ b/govirt/ovirt-api.c
23
+ @@ -123,18 +123,14 @@ OvirtApi *ovirt_api_new(void)
24
+ */
25
+ OvirtCollection *ovirt_api_get_vms(OvirtApi *api)
26
+ {
27
+ - const char *href;
28
+ -
29
+ g_return_val_if_fail(OVIRT_IS_API(api), NULL);
30
+
31
+ - if (api->priv->vms != NULL)
32
+ - return api->priv->vms;
33
+ -
34
+ - href = ovirt_resource_get_sub_collection(OVIRT_RESOURCE(api), "vms");
35
+ - if (href == NULL)
36
+ - return NULL;
37
+ -
38
+ - api->priv->vms = ovirt_collection_new(href, "vms", OVIRT_TYPE_VM, "vm");
39
+ + if (api->priv->vms == NULL)
40
+ + api->priv->vms = ovirt_sub_collection_new_from_resource(OVIRT_RESOURCE(api),
41
+ + "vms",
42
+ + "vms",
43
+ + OVIRT_TYPE_VM,
44
+ + "vm");
45
+
46
+ return api->priv->vms;
47
+ }
48
+ @@ -151,18 +147,14 @@ OvirtCollection *ovirt_api_get_vms(OvirtApi *api)
49
+ */
50
+ OvirtCollection *ovirt_api_get_vm_pools(OvirtApi *api)
51
+ {
52
+ - const char *href;
53
+ -
54
+ g_return_val_if_fail(OVIRT_IS_API(api), NULL);
55
+
56
+ - if (api->priv->vm_pools != NULL)
57
+ - return api->priv->vm_pools;
58
+ -
59
+ - href = ovirt_resource_get_sub_collection(OVIRT_RESOURCE(api), "vmpools");
60
+ - if (href == NULL)
61
+ - return NULL;
62
+ -
63
+ - api->priv->vm_pools = ovirt_collection_new(href, "vmpools", OVIRT_TYPE_VM_POOL, "vmpool");
64
+ + if (api->priv->vm_pools == NULL)
65
+ + api->priv->vm_pools = ovirt_sub_collection_new_from_resource(OVIRT_RESOURCE(api),
66
+ + "vmpools",
67
+ + "vmpools",
68
+ + OVIRT_TYPE_VM_POOL,
69
+ + "vmpool");
70
+
71
+ return api->priv->vm_pools;
72
+ }
73
+ @@ -180,20 +172,14 @@ OvirtCollection *ovirt_api_get_vm_pools(OvirtApi *api)
74
+ */
75
+ OvirtCollection *ovirt_api_get_storage_domains(OvirtApi *api)
76
+ {
77
+ - const char *href;
78
+ -
79
+ g_return_val_if_fail(OVIRT_IS_API(api), NULL);
80
+
81
+ - if (api->priv->storage_domains != NULL)
82
+ - return api->priv->storage_domains;
83
+ -
84
+ - href = ovirt_resource_get_sub_collection(OVIRT_RESOURCE(api), "storagedomains");
85
+ - if (href == NULL)
86
+ - return NULL;
87
+ -
88
+ - api->priv->storage_domains = ovirt_collection_new(href, "storage_domains",
89
+ - OVIRT_TYPE_STORAGE_DOMAIN,
90
+ - "storage_domain");
91
+ + if (api->priv->storage_domains == NULL)
92
+ + api->priv->storage_domains = ovirt_sub_collection_new_from_resource(OVIRT_RESOURCE(api),
93
+ + "storagedomains",
94
+ + "storage_domains",
95
+ + OVIRT_TYPE_STORAGE_DOMAIN,
96
+ + "storage_domain");
97
+
98
+ return api->priv->storage_domains;
99
+ }
100
+ diff --git a/govirt/ovirt-collection-private.h b/govirt/ovirt-collection-private.h
101
+ index 5bc294f..d955fc6 100644
102
+ --- a/govirt/ovirt-collection-private.h
103
+ +++ b/govirt/ovirt-collection-private.h
104
+ @@ -41,6 +41,11 @@ OvirtCollection *ovirt_collection_new_from_xml(RestXmlNode *root_node,
105
+ GType resource_type,
106
+ const char *resource_name,
107
+ GError **error);
108
+ +OvirtCollection *ovirt_sub_collection_new_from_resource(OvirtResource *resource,
109
+ + const char *href,
110
+ + const char *collection_name,
111
+ + GType resource_type,
112
+ + const char *resource_name);
113
+
114
+ G_END_DECLS
115
+
116
+ diff --git a/govirt/ovirt-collection.c b/govirt/ovirt-collection.c
117
+ index a3b0f3f..6ec1c6e 100644
118
+ --- a/govirt/ovirt-collection.c
119
+ +++ b/govirt/ovirt-collection.c
120
+ @@ -344,6 +344,21 @@ OvirtCollection *ovirt_collection_new_from_xml(RestXmlNode *root_node,
121
+ }
122
+
123
+
124
+ +OvirtCollection *ovirt_sub_collection_new_from_resource(OvirtResource *resource,
125
+ + const char *href,
126
+ + const char *collection_name,
127
+ + GType resource_type,
128
+ + const char *resource_name)
129
+ +{
130
+ + const char *link = ovirt_resource_get_sub_collection(resource, href);
131
+ +
132
+ + if (link == NULL)
133
+ + return NULL;
134
+ +
135
+ + return ovirt_collection_new(link, collection_name, resource_type, resource_name);
136
+ +}
137
+ +
138
+ +
139
+ /**
140
+ * ovirt_collection_fetch:
141
+ * @collection: a #OvirtCollection
142
+ diff --git a/govirt/ovirt-storage-domain.c b/govirt/ovirt-storage-domain.c
143
+ index 0582203..38c4a62 100644
144
+ --- a/govirt/ovirt-storage-domain.c
145
+ +++ b/govirt/ovirt-storage-domain.c
146
+ @@ -317,20 +317,14 @@ OvirtStorageDomain *ovirt_storage_domain_new(void)
147
+ */
148
+ OvirtCollection *ovirt_storage_domain_get_files(OvirtStorageDomain *domain)
149
+ {
150
+ - const char *href;
151
+ -
152
+ g_return_val_if_fail(OVIRT_IS_STORAGE_DOMAIN(domain), NULL);
153
+
154
+ - if (domain->priv->files != NULL)
155
+ - return domain->priv->files;
156
+ -
157
+ - href = ovirt_resource_get_sub_collection(OVIRT_RESOURCE(domain), "files");
158
+ - if (href == NULL)
159
+ - return NULL;
160
+ -
161
+ - domain->priv->files = ovirt_collection_new(href, "files",
162
+ - OVIRT_TYPE_RESOURCE,
163
+ - "file");
164
+ + if (domain->priv->files == NULL)
165
+ + domain->priv->files = ovirt_sub_collection_new_from_resource(OVIRT_RESOURCE(domain),
166
+ + "files",
167
+ + "files",
168
+ + OVIRT_TYPE_RESOURCE,
169
+ + "file");
170
+
171
+ return domain->priv->files;
172
+ }
173
+ diff --git a/govirt/ovirt-vm.c b/govirt/ovirt-vm.c
174
+ index 9a07c2f..3d64649 100644
175
+ --- a/govirt/ovirt-vm.c
176
+ +++ b/govirt/ovirt-vm.c
177
+ @@ -329,20 +329,14 @@ gboolean ovirt_vm_refresh_finish(OvirtVm *vm,
178
+ */
179
+ OvirtCollection *ovirt_vm_get_cdroms(OvirtVm *vm)
180
+ {
181
+ - const char *href;
182
+ -
183
+ g_return_val_if_fail(OVIRT_IS_VM(vm), NULL);
184
+
185
+ - if (vm->priv->cdroms != NULL)
186
+ - return vm->priv->cdroms;
187
+ -
188
+ - href = ovirt_resource_get_sub_collection(OVIRT_RESOURCE(vm), "cdroms");
189
+ - if (href == NULL)
190
+ - return NULL;
191
+ -
192
+ - vm->priv->cdroms = ovirt_collection_new(href, "cdroms",
193
+ - OVIRT_TYPE_CDROM,
194
+ - "cdrom");
195
+ + if (vm->priv->cdroms == NULL)
196
+ + vm->priv->cdroms = ovirt_sub_collection_new_from_resource(OVIRT_RESOURCE(vm),
197
+ + "cdroms",
198
+ + "cdroms",
199
+ + OVIRT_TYPE_CDROM,
200
+ + "cdrom");
201
+
202
+ return vm->priv->cdroms;
203
+ }
SOURCES/0015-New-API-functions-to-enable-search-queries-of-collec.patch ADDED
@@ -0,0 +1,199 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Fri, 7 Apr 2017 16:25:46 -0300
4
+ Subject: [PATCH] New API functions to enable search queries of collections
5
+
6
+ Currently it is not possible to specify search query to optimize the
7
+ collections returned by the REST API. It is necessary to retrieve and
8
+ parse the full results and then iterate over the data to find what you
9
+ are really looking for.
10
+
11
+ This patch introduces the search functionality for the APIs that are
12
+ currently supported, improving bandwidth usage and also the need to
13
+ iterate over the results.
14
+
15
+ Like the previous patch, this patch also introduces an auxiliary
16
+ function in ovirt-collection to retrieve a sub-collection with a search
17
+ query.
18
+
19
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
20
+ ---
21
+ govirt/govirt.sym | 4 +++
22
+ govirt/ovirt-api.c | 60 +++++++++++++++++++++++++++++++
23
+ govirt/ovirt-api.h | 3 ++
24
+ govirt/ovirt-collection-private.h | 6 ++++
25
+ govirt/ovirt-collection.c | 31 ++++++++++++++++
26
+ 5 files changed, 104 insertions(+)
27
+
28
+ diff --git a/govirt/govirt.sym b/govirt/govirt.sym
29
+ index 8371779..d02e77f 100644
30
+ --- a/govirt/govirt.sym
31
+ +++ b/govirt/govirt.sym
32
+ @@ -105,6 +105,10 @@ GOVIRT_0.3.2 {
33
+ ovirt_resource_delete;
34
+ ovirt_resource_delete_async;
35
+ ovirt_resource_delete_finish;
36
+ +
37
+ + ovirt_api_search_storage_domains;
38
+ + ovirt_api_search_vms;
39
+ + ovirt_api_search_vm_pools;
40
+ } GOVIRT_0.3.1;
41
+
42
+ GOVIRT_0.3.4 {
43
+ diff --git a/govirt/ovirt-api.c b/govirt/ovirt-api.c
44
+ index 37c0935..ca3fdcf 100644
45
+ --- a/govirt/ovirt-api.c
46
+ +++ b/govirt/ovirt-api.c
47
+ @@ -135,6 +135,26 @@ OvirtCollection *ovirt_api_get_vms(OvirtApi *api)
48
+ return api->priv->vms;
49
+ }
50
+
51
+ +/**
52
+ + * ovirt_api_search_vms:
53
+ + * @api: a #OvirtApi
54
+ + * @query: search query
55
+ + *
56
+ + * Return value: (transfer full):
57
+ + */
58
+ +OvirtCollection *ovirt_api_search_vms(OvirtApi *api, const char *query)
59
+ +{
60
+ + g_return_val_if_fail(OVIRT_IS_API(api), NULL);
61
+ +
62
+ + return ovirt_sub_collection_new_from_resource_search(OVIRT_RESOURCE(api),
63
+ + "vms/search",
64
+ + "vms",
65
+ + OVIRT_TYPE_VM,
66
+ + "vm",
67
+ + query);
68
+ +}
69
+ +
70
+ +
71
+ /**
72
+ * ovirt_api_get_vm_pools:
73
+ * @api: a #OvirtApi
74
+ @@ -160,6 +180,26 @@ OvirtCollection *ovirt_api_get_vm_pools(OvirtApi *api)
75
+ }
76
+
77
+
78
+ +/**
79
+ + * ovirt_api_search_vm_pools:
80
+ + * @api: a #OvirtApi
81
+ + * @query: search query
82
+ + *
83
+ + * Return value: (transfer full):
84
+ + */
85
+ +OvirtCollection *ovirt_api_search_vm_pools(OvirtApi *api, const char *query)
86
+ +{
87
+ + g_return_val_if_fail(OVIRT_IS_API(api), NULL);
88
+ +
89
+ + return ovirt_sub_collection_new_from_resource_search(OVIRT_RESOURCE(api),
90
+ + "vmpools/search",
91
+ + "vmpools",
92
+ + OVIRT_TYPE_VM_POOL,
93
+ + "vmpool",
94
+ + query);
95
+ +}
96
+ +
97
+ +
98
+ /**
99
+ * ovirt_api_get_storage_domains:
100
+ * @api: a #OvirtApi
101
+ @@ -183,3 +223,23 @@ OvirtCollection *ovirt_api_get_storage_domains(OvirtApi *api)
102
+
103
+ return api->priv->storage_domains;
104
+ }
105
+ +
106
+ +
107
+ +/**
108
+ + * ovirt_api_search_storage_domains:
109
+ + * @api: a #OvirtApi
110
+ + * @query: search query
111
+ + *
112
+ + * Return value: (transfer full):
113
+ + */
114
+ +OvirtCollection *ovirt_api_search_storage_domains(OvirtApi *api, const char *query)
115
+ +{
116
+ + g_return_val_if_fail(OVIRT_IS_API(api), NULL);
117
+ +
118
+ + return ovirt_sub_collection_new_from_resource_search(OVIRT_RESOURCE(api),
119
+ + "storagedomains/search",
120
+ + "storage_domains",
121
+ + OVIRT_TYPE_STORAGE_DOMAIN,
122
+ + "storage_domain",
123
+ + query);
124
+ +}
125
+ diff --git a/govirt/ovirt-api.h b/govirt/ovirt-api.h
126
+ index 5f0d4e9..1bf6c02 100644
127
+ --- a/govirt/ovirt-api.h
128
+ +++ b/govirt/ovirt-api.h
129
+ @@ -62,8 +62,11 @@ GType ovirt_api_get_type(void);
130
+ OvirtApi *ovirt_api_new(void);
131
+
132
+ OvirtCollection *ovirt_api_get_storage_domains(OvirtApi *api);
133
+ +OvirtCollection *ovirt_api_search_storage_domains(OvirtApi *api, const char *query);
134
+ OvirtCollection *ovirt_api_get_vms(OvirtApi *api);
135
+ +OvirtCollection *ovirt_api_search_vms(OvirtApi *api, const char *query);
136
+ OvirtCollection *ovirt_api_get_vm_pools(OvirtApi *api);
137
+ +OvirtCollection *ovirt_api_search_vm_pools(OvirtApi *api, const char *query);
138
+
139
+ G_END_DECLS
140
+
141
+ diff --git a/govirt/ovirt-collection-private.h b/govirt/ovirt-collection-private.h
142
+ index d955fc6..cf7e603 100644
143
+ --- a/govirt/ovirt-collection-private.h
144
+ +++ b/govirt/ovirt-collection-private.h
145
+ @@ -46,6 +46,12 @@ OvirtCollection *ovirt_sub_collection_new_from_resource(OvirtResource *resource,
146
+ const char *collection_name,
147
+ GType resource_type,
148
+ const char *resource_name);
149
+ +OvirtCollection *ovirt_sub_collection_new_from_resource_search(OvirtResource *resource,
150
+ + const char *href,
151
+ + const char *collection_name,
152
+ + GType resource_type,
153
+ + const char *resource_name,
154
+ + const char *query);
155
+
156
+ G_END_DECLS
157
+
158
+ diff --git a/govirt/ovirt-collection.c b/govirt/ovirt-collection.c
159
+ index 6ec1c6e..d36d750 100644
160
+ --- a/govirt/ovirt-collection.c
161
+ +++ b/govirt/ovirt-collection.c
162
+ @@ -358,6 +358,37 @@ OvirtCollection *ovirt_sub_collection_new_from_resource(OvirtResource *resource,
163
+ return ovirt_collection_new(link, collection_name, resource_type, resource_name);
164
+ }
165
+
166
+ +OvirtCollection *ovirt_sub_collection_new_from_resource_search(OvirtResource *resource,
167
+ + const char *href,
168
+ + const char *collection_name,
169
+ + GType resource_type,
170
+ + const char *resource_name,
171
+ + const char *query)
172
+ +{
173
+ + const char *link;
174
+ + char *substr;
175
+ + gchar *link_query, *escaped_query;
176
+ + OvirtCollection *collection;
177
+ +
178
+ + link = ovirt_resource_get_sub_collection(resource, href);
179
+ + if (link == NULL)
180
+ + return NULL;
181
+ +
182
+ + /* link is will be something like "/ovirt-engine/api/vms?search={query}", so
183
+ + * we need to strip out {query} substring.
184
+ + */
185
+ + substr = g_strrstr(link, "{query}");
186
+ + if (substr != NULL)
187
+ + *substr = '\0';
188
+ +
189
+ + escaped_query = g_uri_escape_string(query, NULL, FALSE);
190
+ + link_query = g_strconcat(link, escaped_query, NULL);
191
+ + collection = ovirt_collection_new(link_query, collection_name, resource_type, resource_name);
192
+ + g_free(escaped_query);
193
+ + g_free(link_query);
194
+ +
195
+ + return collection;
196
+ +}
197
+
198
+ /**
199
+ * ovirt_collection_fetch:
SOURCES/0016-Introduce-ovirt_resource_new-functions.patch ADDED
@@ -0,0 +1,85 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Thu, 13 Jul 2017 16:56:34 -0300
4
+ Subject: [PATCH] Introduce ovirt_resource_new*() functions
5
+
6
+ These functions should be used to replace usage of g_initable_new()
7
+ around the codebase, as it avoids code duplication by combining all
8
+ different ways of creating a resource in a single function.
9
+
10
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
11
+ ---
12
+ govirt/ovirt-resource-private.h | 4 +++
13
+ govirt/ovirt-resource.c | 47 +++++++++++++++++++++++++++++++++
14
+ 2 files changed, 51 insertions(+)
15
+
16
+ diff --git a/govirt/ovirt-resource-private.h b/govirt/ovirt-resource-private.h
17
+ index ff4e705..ef47557 100644
18
+ --- a/govirt/ovirt-resource-private.h
19
+ +++ b/govirt/ovirt-resource-private.h
20
+ @@ -27,6 +27,10 @@
21
+
22
+ G_BEGIN_DECLS
23
+
24
+ +OvirtResource *ovirt_resource_new(GType type);
25
+ +OvirtResource *ovirt_resource_new_from_id(GType type, const char *id, const char *href);
26
+ +OvirtResource *ovirt_resource_new_from_xml(GType type, RestXmlNode *node, GError **error);
27
+ +
28
+ const char *ovirt_resource_get_action(OvirtResource *resource,
29
+ const char *action);
30
+ char *ovirt_resource_to_xml(OvirtResource *resource);
31
+ diff --git a/govirt/ovirt-resource.c b/govirt/ovirt-resource.c
32
+ index 7f79ab7..1413a77 100644
33
+ --- a/govirt/ovirt-resource.c
34
+ +++ b/govirt/ovirt-resource.c
35
+ @@ -1065,3 +1065,50 @@ gboolean ovirt_resource_delete_finish(OvirtResource *resource,
36
+
37
+ return ovirt_rest_call_finish(result, err);
38
+ }
39
+ +
40
+ +
41
+ +static OvirtResource *ovirt_resource_new_valist(GType type, GError **error, const char *prop_name, ...)
42
+ +{
43
+ + gpointer resource;
44
+ + va_list var_args;
45
+ + GError *local_error = NULL;
46
+ +
47
+ + g_return_val_if_fail(g_type_is_a(type, OVIRT_TYPE_RESOURCE), NULL);
48
+ +
49
+ + va_start(var_args, prop_name);
50
+ + resource = g_initable_new_valist(type, prop_name, var_args, NULL, &local_error);
51
+ + va_end(var_args);
52
+ +
53
+ + if (local_error != NULL) {
54
+ + g_warning("Failed to create resource of type %s: %s", g_type_name(type), local_error->message);
55
+ + g_propagate_error(error, local_error);
56
+ + }
57
+ +
58
+ + return OVIRT_RESOURCE(resource);
59
+ +}
60
+ +
61
+ +
62
+ +G_GNUC_INTERNAL
63
+ +OvirtResource *ovirt_resource_new(GType type)
64
+ +{
65
+ + return ovirt_resource_new_valist(type, NULL, NULL);
66
+ +}
67
+ +
68
+ +
69
+ +G_GNUC_INTERNAL
70
+ +OvirtResource *ovirt_resource_new_from_id(GType type, const char *id, const char *href)
71
+ +{
72
+ + g_return_val_if_fail(id != NULL, NULL);
73
+ + g_return_val_if_fail(href != NULL, NULL);
74
+ +
75
+ + return ovirt_resource_new_valist(type, NULL, "guid", id, "href", href, NULL);
76
+ +}
77
+ +
78
+ +
79
+ +G_GNUC_INTERNAL
80
+ +OvirtResource *ovirt_resource_new_from_xml(GType type, RestXmlNode *node, GError **error)
81
+ +{
82
+ + g_return_val_if_fail(node != NULL, NULL);
83
+ +
84
+ + return ovirt_resource_new_valist(type, error, "xml-node", node, NULL);
85
+ +}
SOURCES/0017-Use-ovirt_resource_new-functions-instead-of-g_initab.patch ADDED
@@ -0,0 +1,146 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Thu, 13 Jul 2017 16:58:28 -0300
4
+ Subject: [PATCH] Use ovirt_resource_new* functions instead of g_initable_new
5
+
6
+ This patch also fix some functions that were supposed to be tagged as
7
+ G_GNUC_INTERNAL.
8
+
9
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
10
+ ---
11
+ govirt/ovirt-api.c | 8 +++++---
12
+ govirt/ovirt-collection.c | 4 +---
13
+ govirt/ovirt-storage-domain.c | 11 ++---------
14
+ govirt/ovirt-utils.c | 3 ++-
15
+ govirt/ovirt-vm-pool.c | 3 ++-
16
+ govirt/ovirt-vm.c | 8 +++++---
17
+ 6 files changed, 17 insertions(+), 20 deletions(-)
18
+
19
+ diff --git a/govirt/ovirt-api.c b/govirt/ovirt-api.c
20
+ index ca3fdcf..93dc3d5 100644
21
+ --- a/govirt/ovirt-api.c
22
+ +++ b/govirt/ovirt-api.c
23
+ @@ -98,16 +98,18 @@ static void ovirt_api_init(G_GNUC_UNUSED OvirtApi *api)
24
+ api->priv = OVIRT_API_GET_PRIVATE(api);
25
+ }
26
+
27
+ +G_GNUC_INTERNAL
28
+ OvirtApi *ovirt_api_new_from_xml(RestXmlNode *node, GError **error)
29
+ {
30
+ - return OVIRT_API(g_initable_new(OVIRT_TYPE_API, NULL, error,
31
+ - "xml-node", node, NULL));
32
+ + OvirtResource *api = ovirt_resource_new_from_xml(OVIRT_TYPE_API, node, error);
33
+ + return OVIRT_API(api);
34
+ }
35
+
36
+
37
+ OvirtApi *ovirt_api_new(void)
38
+ {
39
+ - return OVIRT_API(g_initable_new(OVIRT_TYPE_API, NULL, NULL, NULL));
40
+ + OvirtResource *api = ovirt_resource_new(OVIRT_TYPE_API);
41
+ + return OVIRT_API(api);
42
+ }
43
+
44
+
45
+ diff --git a/govirt/ovirt-collection.c b/govirt/ovirt-collection.c
46
+ index d36d750..8008903 100644
47
+ --- a/govirt/ovirt-collection.c
48
+ +++ b/govirt/ovirt-collection.c
49
+ @@ -235,9 +235,7 @@ ovirt_collection_new_resource_from_xml(OvirtCollection *collection,
50
+ RestXmlNode *node,
51
+ GError **error)
52
+ {
53
+ - return OVIRT_RESOURCE(g_initable_new(collection->priv->resource_type,
54
+ - NULL, error,
55
+ - "xml-node", node , NULL));
56
+ + return ovirt_resource_new_from_xml(collection->priv->resource_type, node, error);
57
+ }
58
+
59
+
60
+ diff --git a/govirt/ovirt-storage-domain.c b/govirt/ovirt-storage-domain.c
61
+ index 38c4a62..e255565 100644
62
+ --- a/govirt/ovirt-storage-domain.c
63
+ +++ b/govirt/ovirt-storage-domain.c
64
+ @@ -285,20 +285,13 @@ G_GNUC_INTERNAL
65
+ OvirtStorageDomain *ovirt_storage_domain_new_from_xml(RestXmlNode *node,
66
+ GError **error)
67
+ {
68
+ - GObject *domain;
69
+ -
70
+ - domain = g_initable_new(OVIRT_TYPE_STORAGE_DOMAIN, NULL, error,
71
+ - "xml-node", node, NULL);
72
+ -
73
+ + OvirtResource *domain = ovirt_resource_new_from_xml(OVIRT_TYPE_STORAGE_DOMAIN, node, error);
74
+ return OVIRT_STORAGE_DOMAIN(domain);
75
+ }
76
+
77
+ OvirtStorageDomain *ovirt_storage_domain_new(void)
78
+ {
79
+ - GObject *domain;
80
+ -
81
+ - domain = g_initable_new(OVIRT_TYPE_STORAGE_DOMAIN, NULL, NULL, NULL);
82
+ -
83
+ + OvirtResource *domain = ovirt_resource_new(OVIRT_TYPE_STORAGE_DOMAIN);
84
+ return OVIRT_STORAGE_DOMAIN(domain);
85
+ }
86
+
87
+ diff --git a/govirt/ovirt-utils.c b/govirt/ovirt-utils.c
88
+ index a200e48..1898862 100644
89
+ --- a/govirt/ovirt-utils.c
90
+ +++ b/govirt/ovirt-utils.c
91
+ @@ -32,6 +32,7 @@
92
+
93
+ #include "ovirt-error.h"
94
+ #include "ovirt-resource.h"
95
+ +#include "ovirt-resource-private.h"
96
+
97
+ RestXmlNode *
98
+ ovirt_rest_xml_node_from_call(RestProxyCall *call)
99
+ @@ -142,7 +143,7 @@ _set_property_value_from_type(GValue *value,
100
+ const char *value_str;
101
+
102
+ if (g_type_is_a(type, OVIRT_TYPE_RESOURCE)) {
103
+ - GObject *resource_value = g_initable_new(type, NULL, NULL, "xml-node", node, NULL);
104
+ + OvirtResource *resource_value = ovirt_resource_new_from_xml(type, node, NULL);
105
+ g_value_set_object(value, resource_value);
106
+ goto end;
107
+ } else if (g_type_is_a(type, G_TYPE_STRV)) {
108
+ diff --git a/govirt/ovirt-vm-pool.c b/govirt/ovirt-vm-pool.c
109
+ index 3187a8c..9d0d742 100644
110
+ --- a/govirt/ovirt-vm-pool.c
111
+ +++ b/govirt/ovirt-vm-pool.c
112
+ @@ -168,7 +168,8 @@ static void ovirt_vm_pool_init(G_GNUC_UNUSED OvirtVmPool *vm_pool)
113
+
114
+ OvirtVmPool *ovirt_vm_pool_new(void)
115
+ {
116
+ - return OVIRT_VM_POOL(g_initable_new(OVIRT_TYPE_VM_POOL, NULL, NULL, NULL));
117
+ + OvirtResource *vm_pool = ovirt_resource_new(OVIRT_TYPE_VM_POOL);
118
+ + return OVIRT_VM_POOL(vm_pool);
119
+ }
120
+
121
+
122
+ diff --git a/govirt/ovirt-vm.c b/govirt/ovirt-vm.c
123
+ index 3d64649..806b5f3 100644
124
+ --- a/govirt/ovirt-vm.c
125
+ +++ b/govirt/ovirt-vm.c
126
+ @@ -163,15 +163,17 @@ static void ovirt_vm_init(G_GNUC_UNUSED OvirtVm *vm)
127
+ vm->priv = OVIRT_VM_GET_PRIVATE(vm);
128
+ }
129
+
130
+ +G_GNUC_INTERNAL
131
+ OvirtVm *ovirt_vm_new_from_xml(RestXmlNode *node, GError **error)
132
+ {
133
+ - return OVIRT_VM(g_initable_new(OVIRT_TYPE_VM, NULL, error,
134
+ - "xml-node", node, NULL));
135
+ + OvirtResource *vm = ovirt_resource_new_from_xml(OVIRT_TYPE_VM, node, error);
136
+ + return OVIRT_VM(vm);
137
+ }
138
+
139
+ OvirtVm *ovirt_vm_new(void)
140
+ {
141
+ - return OVIRT_VM(g_initable_new(OVIRT_TYPE_VM, NULL, NULL, NULL));
142
+ + OvirtResource *vm = ovirt_resource_new(OVIRT_TYPE_VM);
143
+ + return OVIRT_VM(vm);
144
+ }
145
+
146
+
SOURCES/0018-Move-resource-type-definitions-to-ovirt-types.h.patch ADDED
@@ -0,0 +1,136 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Thu, 13 Jul 2017 16:43:53 -0300
4
+ Subject: [PATCH] Move resource type definitions to ovirt-types.h
5
+
6
+ With recently added ovirt_resource_new* functions, it is now possible to
7
+ create any type of resource, being only necessary to pass the type as
8
+ argument.
9
+
10
+ In order to avoid interdependencies between objects, we need a common
11
+ place for definition of the resource types. For instance, it should be
12
+ possible to access a OvirtHost from a OvirtVm and vice-versa.
13
+
14
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
15
+ ---
16
+ govirt/ovirt-api.h | 1 -
17
+ govirt/ovirt-cdrom.h | 1 -
18
+ govirt/ovirt-collection.h | 1 -
19
+ govirt/ovirt-storage-domain.h | 1 -
20
+ govirt/ovirt-types.h | 7 +++++++
21
+ govirt/ovirt-vm-display.h | 2 +-
22
+ govirt/ovirt-vm-pool.h | 1 -
23
+ govirt/ovirt-vm.h | 1 -
24
+ 8 files changed, 8 insertions(+), 7 deletions(-)
25
+
26
+ diff --git a/govirt/ovirt-api.h b/govirt/ovirt-api.h
27
+ index 1bf6c02..d511d70 100644
28
+ --- a/govirt/ovirt-api.h
29
+ +++ b/govirt/ovirt-api.h
30
+ @@ -37,7 +37,6 @@ G_BEGIN_DECLS
31
+ #define OVIRT_IS_API_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OVIRT_TYPE_API))
32
+ #define OVIRT_API_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OVIRT_TYPE_API, OvirtApiClass))
33
+
34
+ -typedef struct _OvirtApi OvirtApi;
35
+ typedef struct _OvirtApiPrivate OvirtApiPrivate;
36
+ typedef struct _OvirtApiClass OvirtApiClass;
37
+
38
+ diff --git a/govirt/ovirt-cdrom.h b/govirt/ovirt-cdrom.h
39
+ index a268d01..a43d85d 100644
40
+ --- a/govirt/ovirt-cdrom.h
41
+ +++ b/govirt/ovirt-cdrom.h
42
+ @@ -36,7 +36,6 @@ G_BEGIN_DECLS
43
+ #define OVIRT_IS_CDROM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OVIRT_TYPE_CDROM))
44
+ #define OVIRT_CDROM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OVIRT_TYPE_CDROM, OvirtCdromClass))
45
+
46
+ -typedef struct _OvirtCdrom OvirtCdrom;
47
+ typedef struct _OvirtCdromPrivate OvirtCdromPrivate;
48
+ typedef struct _OvirtCdromClass OvirtCdromClass;
49
+
50
+ diff --git a/govirt/ovirt-collection.h b/govirt/ovirt-collection.h
51
+ index b41d269..af630e1 100644
52
+ --- a/govirt/ovirt-collection.h
53
+ +++ b/govirt/ovirt-collection.h
54
+ @@ -36,7 +36,6 @@ G_BEGIN_DECLS
55
+ #define OVIRT_IS_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OVIRT_TYPE_COLLECTION))
56
+ #define OVIRT_COLLECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OVIRT_TYPE_COLLECTION, OvirtCollectionClass))
57
+
58
+ -typedef struct _OvirtCollection OvirtCollection;
59
+ typedef struct _OvirtCollectionPrivate OvirtCollectionPrivate;
60
+ typedef struct _OvirtCollectionClass OvirtCollectionClass;
61
+
62
+ diff --git a/govirt/ovirt-storage-domain.h b/govirt/ovirt-storage-domain.h
63
+ index 79f1741..dd7b593 100644
64
+ --- a/govirt/ovirt-storage-domain.h
65
+ +++ b/govirt/ovirt-storage-domain.h
66
+ @@ -61,7 +61,6 @@ typedef enum {
67
+ OVIRT_STORAGE_DOMAIN_TYPE_IMAGE,
68
+ } OvirtStorageDomainType;
69
+
70
+ -typedef struct _OvirtStorageDomain OvirtStorageDomain;
71
+ typedef struct _OvirtStorageDomainPrivate OvirtStorageDomainPrivate;
72
+ typedef struct _OvirtStorageDomainClass OvirtStorageDomainClass;
73
+
74
+ diff --git a/govirt/ovirt-types.h b/govirt/ovirt-types.h
75
+ index 6e83368..c89521b 100644
76
+ --- a/govirt/ovirt-types.h
77
+ +++ b/govirt/ovirt-types.h
78
+ @@ -25,7 +25,14 @@
79
+
80
+ G_BEGIN_DECLS
81
+
82
+ +typedef struct _OvirtApi OvirtApi;
83
+ +typedef struct _OvirtCdrom OvirtCdrom;
84
+ +typedef struct _OvirtCollection OvirtCollection;
85
+ typedef struct _OvirtProxy OvirtProxy;
86
+ +typedef struct _OvirtStorageDomain OvirtStorageDomain;
87
+ +typedef struct _OvirtVmDisplay OvirtVmDisplay;
88
+ +typedef struct _OvirtVmPool OvirtVmPool;
89
+ +typedef struct _OvirtVm OvirtVm;
90
+
91
+ G_END_DECLS
92
+
93
+ diff --git a/govirt/ovirt-vm-display.h b/govirt/ovirt-vm-display.h
94
+ index 2b8a86d..f7eb310 100644
95
+ --- a/govirt/ovirt-vm-display.h
96
+ +++ b/govirt/ovirt-vm-display.h
97
+ @@ -23,6 +23,7 @@
98
+ #define __OVIRT_VM_DISPLAY_H__
99
+
100
+ #include <glib-object.h>
101
+ +#include <govirt/ovirt-types.h>
102
+
103
+ G_BEGIN_DECLS
104
+
105
+ @@ -33,7 +34,6 @@ G_BEGIN_DECLS
106
+ #define OVIRT_IS_VM_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OVIRT_TYPE_VM_DISPLAY))
107
+ #define OVIRT_VM_DISPLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OVIRT_TYPE_VM_DISPLAY, OvirtVmDisplayClass))
108
+
109
+ -typedef struct _OvirtVmDisplay OvirtVmDisplay;
110
+ typedef struct _OvirtVmDisplayPrivate OvirtVmDisplayPrivate;
111
+ typedef struct _OvirtVmDisplayClass OvirtVmDisplayClass;
112
+
113
+ diff --git a/govirt/ovirt-vm-pool.h b/govirt/ovirt-vm-pool.h
114
+ index ee2f55c..10e7be7 100644
115
+ --- a/govirt/ovirt-vm-pool.h
116
+ +++ b/govirt/ovirt-vm-pool.h
117
+ @@ -35,7 +35,6 @@ G_BEGIN_DECLS
118
+ #define OVIRT_IS_VM_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OVIRT_TYPE_VM_POOL))
119
+ #define OVIRT_VM_POOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OVIRT_TYPE_VM_POOL, OvirtVmPoolClass))
120
+
121
+ -typedef struct _OvirtVmPool OvirtVmPool;
122
+ typedef struct _OvirtVmPoolPrivate OvirtVmPoolPrivate;
123
+ typedef struct _OvirtVmPoolClass OvirtVmPoolClass;
124
+
125
+ diff --git a/govirt/ovirt-vm.h b/govirt/ovirt-vm.h
126
+ index 10910e3..1e6c7ad 100644
127
+ --- a/govirt/ovirt-vm.h
128
+ +++ b/govirt/ovirt-vm.h
129
+ @@ -41,7 +41,6 @@ G_BEGIN_DECLS
130
+ #define OVIRT_IS_VM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OVIRT_TYPE_VM))
131
+ #define OVIRT_VM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OVIRT_TYPE_VM, OvirtVmClass))
132
+
133
+ -typedef struct _OvirtVm OvirtVm;
134
+ typedef struct _OvirtVmPrivate OvirtVmPrivate;
135
+ typedef struct _OvirtVmClass OvirtVmClass;
136
+
SOURCES/0019-Initial-support-for-hosts.patch ADDED
@@ -0,0 +1,515 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Tue, 11 Apr 2017 21:47:44 -0300
4
+ Subject: [PATCH] Initial support for hosts
5
+
6
+ At the moment, we only care about the information about the cluster the
7
+ host is part of, and the list of the vms associated with it.
8
+
9
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
10
+ ---
11
+ govirt/Makefile.am | 3 +
12
+ govirt/govirt-private.h | 1 +
13
+ govirt/govirt.sym | 11 ++
14
+ govirt/ovirt-api.c | 47 ++++++++
15
+ govirt/ovirt-api.h | 2 +
16
+ govirt/ovirt-host-private.h | 37 +++++++
17
+ govirt/ovirt-host.c | 214 ++++++++++++++++++++++++++++++++++++
18
+ govirt/ovirt-host.h | 66 +++++++++++
19
+ govirt/ovirt-types.h | 1 +
20
+ 9 files changed, 382 insertions(+)
21
+ create mode 100644 govirt/ovirt-host-private.h
22
+ create mode 100644 govirt/ovirt-host.c
23
+ create mode 100644 govirt/ovirt-host.h
24
+
25
+ diff --git a/govirt/Makefile.am b/govirt/Makefile.am
26
+ index e905f1f..c62a1d6 100644
27
+ --- a/govirt/Makefile.am
28
+ +++ b/govirt/Makefile.am
29
+ @@ -21,6 +21,7 @@ libgovirt_la_HEADERS = \
30
+ ovirt-cdrom.h \
31
+ ovirt-collection.h \
32
+ ovirt-error.h \
33
+ + ovirt-host.h \
34
+ ovirt-options.h \
35
+ ovirt-proxy.h \
36
+ ovirt-resource.h \
37
+ @@ -38,6 +39,7 @@ noinst_HEADERS = \
38
+ ovirt-action-rest-call.h \
39
+ ovirt-api-private.h \
40
+ ovirt-collection-private.h \
41
+ + ovirt-host-private.h \
42
+ ovirt-proxy-private.h \
43
+ ovirt-resource-private.h \
44
+ ovirt-rest-call.h \
45
+ @@ -54,6 +56,7 @@ libgovirt_la_SOURCES = \
46
+ ovirt-cdrom.c \
47
+ ovirt-collection.c \
48
+ ovirt-error.c \
49
+ + ovirt-host.c \
50
+ ovirt-options.c \
51
+ ovirt-proxy.c \
52
+ ovirt-proxy-deprecated.c \
53
+ diff --git a/govirt/govirt-private.h b/govirt/govirt-private.h
54
+ index 972ebac..b51feb3 100644
55
+ --- a/govirt/govirt-private.h
56
+ +++ b/govirt/govirt-private.h
57
+ @@ -26,6 +26,7 @@
58
+ #include <govirt/ovirt-api-private.h>
59
+ #include <govirt/ovirt-collection-private.h>
60
+ #include <govirt/ovirt-enum-types-private.h>
61
+ +#include <govirt/ovirt-host-private.h>
62
+ #include <govirt/ovirt-proxy-private.h>
63
+ #include <govirt/ovirt-resource-private.h>
64
+ #include <govirt/ovirt-resource-rest-call.h>
65
+ diff --git a/govirt/govirt.sym b/govirt/govirt.sym
66
+ index d02e77f..6dc8159 100644
67
+ --- a/govirt/govirt.sym
68
+ +++ b/govirt/govirt.sym
69
+ @@ -109,6 +109,17 @@ GOVIRT_0.3.2 {
70
+ ovirt_api_search_storage_domains;
71
+ ovirt_api_search_vms;
72
+ ovirt_api_search_vm_pools;
73
+ +
74
+ + ovirt_api_get_hosts;
75
+ +
76
+ + ovirt_api_search_hosts;
77
+ + ovirt_api_search_storage_domains;
78
+ + ovirt_api_search_vms;
79
+ + ovirt_api_search_vm_pools;
80
+ +
81
+ + ovirt_host_get_type;
82
+ + ovirt_host_get_vms;
83
+ + ovirt_host_new;
84
+ } GOVIRT_0.3.1;
85
+
86
+ GOVIRT_0.3.4 {
87
+ diff --git a/govirt/ovirt-api.c b/govirt/ovirt-api.c
88
+ index 93dc3d5..fef04ba 100644
89
+ --- a/govirt/ovirt-api.c
90
+ +++ b/govirt/ovirt-api.c
91
+ @@ -41,6 +41,7 @@
92
+
93
+
94
+ struct _OvirtApiPrivate {
95
+ + OvirtCollection *hosts;
96
+ OvirtCollection *storage_domains;
97
+ OvirtCollection *vms;
98
+ OvirtCollection *vm_pools;
99
+ @@ -73,6 +74,7 @@ static void ovirt_api_dispose(GObject *object)
100
+ {
101
+ OvirtApi *api = OVIRT_API(object);
102
+
103
+ + g_clear_object(&api->priv->hosts);
104
+ g_clear_object(&api->priv->storage_domains);
105
+ g_clear_object(&api->priv->vms);
106
+ g_clear_object(&api->priv->vm_pools);
107
+ @@ -245,3 +247,48 @@ OvirtCollection *ovirt_api_search_storage_domains(OvirtApi *api, const char *que
108
+ "storage_domain",
109
+ query);
110
+ }
111
+ +
112
+ +
113
+ +/**
114
+ + * ovirt_api_get_hosts:
115
+ + * @api: a #OvirtApi
116
+ + *
117
+ + * This method does not initiate any network activity, the collection
118
+ + * must be fetched with ovirt_collection_fetch() before having up-to-date
119
+ + * content.
120
+ + *
121
+ + * Return value: (transfer none):
122
+ + */
123
+ +OvirtCollection *ovirt_api_get_hosts(OvirtApi *api)
124
+ +{
125
+ + g_return_val_if_fail(OVIRT_IS_API(api), NULL);
126
+ +
127
+ + if (api->priv->hosts == NULL)
128
+ + api->priv->hosts = ovirt_sub_collection_new_from_resource(OVIRT_RESOURCE(api),
129
+ + "hosts",
130
+ + "hosts",
131
+ + OVIRT_TYPE_HOST,
132
+ + "host");
133
+ +
134
+ + return api->priv->hosts;
135
+ +}
136
+ +
137
+ +
138
+ +/**
139
+ + * ovirt_api_search_hosts:
140
+ + * @api: a #OvirtApi
141
+ + * @query: search query
142
+ + *
143
+ + * Return value: (transfer none):
144
+ + */
145
+ +OvirtCollection *ovirt_api_search_hosts(OvirtApi *api, const char *query)
146
+ +{
147
+ + g_return_val_if_fail(OVIRT_IS_API(api), NULL);
148
+ +
149
+ + return ovirt_sub_collection_new_from_resource_search(OVIRT_RESOURCE(api),
150
+ + "hosts",
151
+ + "hosts",
152
+ + OVIRT_TYPE_HOST,
153
+ + "host",
154
+ + query);
155
+ +}
156
+ diff --git a/govirt/ovirt-api.h b/govirt/ovirt-api.h
157
+ index d511d70..c46e934 100644
158
+ --- a/govirt/ovirt-api.h
159
+ +++ b/govirt/ovirt-api.h
160
+ @@ -60,6 +60,8 @@ struct _OvirtApiClass
161
+ GType ovirt_api_get_type(void);
162
+ OvirtApi *ovirt_api_new(void);
163
+
164
+ +OvirtCollection *ovirt_api_get_hosts(OvirtApi *api);
165
+ +OvirtCollection *ovirt_api_search_hosts(OvirtApi *api, const char *query);
166
+ OvirtCollection *ovirt_api_get_storage_domains(OvirtApi *api);
167
+ OvirtCollection *ovirt_api_search_storage_domains(OvirtApi *api, const char *query);
168
+ OvirtCollection *ovirt_api_get_vms(OvirtApi *api);
169
+ diff --git a/govirt/ovirt-host-private.h b/govirt/ovirt-host-private.h
170
+ new file mode 100644
171
+ index 0000000..26587ea
172
+ --- /dev/null
173
+ +++ b/govirt/ovirt-host-private.h
174
+ @@ -0,0 +1,37 @@
175
+ +/*
176
+ + * ovirt-host-private.h: oVirt host resource
177
+ + *
178
+ + * Copyright (C) 2017 Red Hat, Inc.
179
+ + *
180
+ + * This library is free software; you can redistribute it and/or
181
+ + * modify it under the terms of the GNU Lesser General Public
182
+ + * License as published by the Free Software Foundation; either
183
+ + * version 2.1 of the License, or (at your option) any later version.
184
+ + *
185
+ + * This library is distributed in the hope that it will be useful,
186
+ + * but WITHOUT ANY WARRANTY; without even the implied warranty of
187
+ + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
188
+ + * Lesser General Public License for more details.
189
+ + *
190
+ + * You should have received a copy of the GNU Lesser General Public
191
+ + * License along with this library. If not, see
192
+ + * <http://www.gnu.org/licenses/>.
193
+ + *
194
+ + * Author: Eduardo Lima (Etrunko) <etrunko@redhat.com>
195
+ + */
196
+ +#ifndef __OVIRT_HOST_PRIVATE_H__
197
+ +#define __OVIRT_HOST_PRIVATE_H__
198
+ +
199
+ +#include <ovirt-host.h>
200
+ +#include <rest/rest-xml-node.h>
201
+ +
202
+ +G_BEGIN_DECLS
203
+ +
204
+ +OvirtHost *ovirt_host_new_from_id(const char *id,
205
+ + const char *href);
206
+ +OvirtHost *ovirt_host_new_from_xml(RestXmlNode *node,
207
+ + GError **error);
208
+ +
209
+ +G_END_DECLS
210
+ +
211
+ +#endif /* __OVIRT_HOST_PRIVATE_H__ */
212
+ diff --git a/govirt/ovirt-host.c b/govirt/ovirt-host.c
213
+ new file mode 100644
214
+ index 0000000..2df2a64
215
+ --- /dev/null
216
+ +++ b/govirt/ovirt-host.c
217
+ @@ -0,0 +1,214 @@
218
+ +/*
219
+ + * ovirt-host.c: oVirt host handling
220
+ + *
221
+ + * Copyright (C) 2017 Red Hat, Inc.
222
+ + *
223
+ + * This library is free software; you can redistribute it and/or
224
+ + * modify it under the terms of the GNU Lesser General Public
225
+ + * License as published by the Free Software Foundation; either
226
+ + * version 2.1 of the License, or (at your option) any later version.
227
+ + *
228
+ + * This library is distributed in the hope that it will be useful,
229
+ + * but WITHOUT ANY WARRANTY; without even the implied warranty of
230
+ + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
231
+ + * Lesser General Public License for more details.
232
+ + *
233
+ + * You should have received a copy of the GNU Lesser General Public
234
+ + * License along with this library. If not, see
235
+ + * <http://www.gnu.org/licenses/>.
236
+ + *
237
+ + * Author: Eduardo Lima (Etrunko) <etrunko@redhat.com>
238
+ + */
239
+ +
240
+ +#include <config.h>
241
+ +#include "ovirt-enum-types.h"
242
+ +#include "ovirt-host.h"
243
+ +#include "govirt-private.h"
244
+ +
245
+ +#define OVIRT_HOST_GET_PRIVATE(obj) \
246
+ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), OVIRT_TYPE_HOST, OvirtHostPrivate))
247
+ +
248
+ +struct _OvirtHostPrivate {
249
+ + gchar *cluster_href;
250
+ + gchar *cluster_id;
251
+ + OvirtCollection *vms;
252
+ +};
253
+ +
254
+ +G_DEFINE_TYPE(OvirtHost, ovirt_host, OVIRT_TYPE_RESOURCE);
255
+ +
256
+ +enum {
257
+ + PROP_0,
258
+ + PROP_CLUSTER_HREF,
259
+ + PROP_CLUSTER_ID,
260
+ +};
261
+ +
262
+ +static void ovirt_host_get_property(GObject *object,
263
+ + guint prop_id,
264
+ + GValue *value,
265
+ + GParamSpec *pspec)
266
+ +{
267
+ + OvirtHost *host = OVIRT_HOST(object);
268
+ +
269
+ + switch (prop_id) {
270
+ + case PROP_CLUSTER_HREF:
271
+ + g_value_set_string(value, host->priv->cluster_href);
272
+ + break;
273
+ + case PROP_CLUSTER_ID:
274
+ + g_value_set_string(value, host->priv->cluster_id);
275
+ + break;
276
+ + default:
277
+ + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
278
+ + }
279
+ +}
280
+ +
281
+ +static void ovirt_host_set_property(GObject *object,
282
+ + guint prop_id,
283
+ + const GValue *value,
284
+ + GParamSpec *pspec)
285
+ +{
286
+ + OvirtHost *host = OVIRT_HOST(object);
287
+ +
288
+ + switch (prop_id) {
289
+ + case PROP_CLUSTER_HREF:
290
+ + g_free(host->priv->cluster_href);
291
+ + host->priv->cluster_href = g_value_dup_string(value);
292
+ + break;
293
+ + case PROP_CLUSTER_ID:
294
+ + g_free(host->priv->cluster_id);
295
+ + host->priv->cluster_id = g_value_dup_string(value);
296
+ + break;
297
+ + default:
298
+ + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
299
+ + }
300
+ +}
301
+ +
302
+ +
303
+ +static void
304
+ +ovirt_host_dispose(GObject *obj)
305
+ +{
306
+ + OvirtHost *host = OVIRT_HOST(obj);
307
+ +
308
+ + g_clear_pointer(&host->priv->cluster_href, g_free);
309
+ + g_clear_pointer(&host->priv->cluster_id, g_free);
310
+ + g_clear_object(&host->priv->vms);
311
+ +
312
+ + G_OBJECT_CLASS(ovirt_host_parent_class)->dispose(obj);
313
+ +}
314
+ +
315
+ +
316
+ +static gboolean ovirt_host_init_from_xml(OvirtResource *resource,
317
+ + RestXmlNode *node,
318
+ + GError **error)
319
+ +{
320
+ + OvirtResourceClass *parent_class;
321
+ + OvirtXmlElement host_elements[] = {
322
+ + { .prop_name = "cluster-href",
323
+ + .type = G_TYPE_STRING,
324
+ + .xml_path = "cluster",
325
+ + .xml_attr = "href",
326
+ + },
327
+ + { .prop_name = "cluster-id",
328
+ + .type = G_TYPE_STRING,
329
+ + .xml_path = "cluster",
330
+ + .xml_attr = "id",
331
+ + },
332
+ + { NULL , },
333
+ + };
334
+ +
335
+ + if (!ovirt_rest_xml_node_parse(node, G_OBJECT(resource), host_elements))
336
+ + return FALSE;
337
+ +
338
+ + parent_class = OVIRT_RESOURCE_CLASS(ovirt_host_parent_class);
339
+ + return parent_class->init_from_xml(resource, node, error);
340
+ +}
341
+ +
342
+ +
343
+ +static void ovirt_host_class_init(OvirtHostClass *klass)
344
+ +{
345
+ + GObjectClass *object_class = G_OBJECT_CLASS(klass);
346
+ + OvirtResourceClass *resource_class = OVIRT_RESOURCE_CLASS(klass);
347
+ + GParamSpec *param_spec;
348
+ +
349
+ + g_type_class_add_private(klass, sizeof(OvirtHostPrivate));
350
+ +
351
+ + resource_class->init_from_xml = ovirt_host_init_from_xml;
352
+ + object_class->dispose = ovirt_host_dispose;
353
+ + object_class->get_property = ovirt_host_get_property;
354
+ + object_class->set_property = ovirt_host_set_property;
355
+ +
356
+ + param_spec = g_param_spec_string("cluster-href",
357
+ + "Cluster href",
358
+ + "Cluster href for the Host",
359
+ + NULL,
360
+ + G_PARAM_READWRITE |
361
+ + G_PARAM_STATIC_STRINGS);
362
+ + g_object_class_install_property(object_class,
363
+ + PROP_CLUSTER_HREF,
364
+ + param_spec);
365
+ +
366
+ + param_spec = g_param_spec_string("cluster-id",
367
+ + "Cluster Id",
368
+ + "Cluster Id for the Host",
369
+ + NULL,
370
+ + G_PARAM_READWRITE |
371
+ + G_PARAM_STATIC_STRINGS);
372
+ + g_object_class_install_property(object_class,
373
+ + PROP_CLUSTER_ID,
374
+ + param_spec);
375
+ +}
376
+ +
377
+ +static void ovirt_host_init(OvirtHost *host)
378
+ +{
379
+ + host->priv = OVIRT_HOST_GET_PRIVATE(host);
380
+ +}
381
+ +
382
+ +G_GNUC_INTERNAL
383
+ +OvirtHost *ovirt_host_new_from_id(const char *id,
384
+ + const char *href)
385
+ +{
386
+ + OvirtResource *host = ovirt_resource_new_from_id(OVIRT_TYPE_HOST, id, href);
387
+ + return OVIRT_HOST(host);
388
+ +}
389
+ +
390
+ +G_GNUC_INTERNAL
391
+ +OvirtHost *ovirt_host_new_from_xml(RestXmlNode *node,
392
+ + GError **error)
393
+ +{
394
+ + OvirtResource *host = ovirt_resource_new_from_xml(OVIRT_TYPE_HOST, node, error);
395
+ + return OVIRT_HOST(host);
396
+ +}
397
+ +
398
+ +OvirtHost *ovirt_host_new(void)
399
+ +{
400
+ + OvirtResource *host = ovirt_resource_new(OVIRT_TYPE_HOST);
401
+ + return OVIRT_HOST(host);
402
+ +}
403
+ +
404
+ +/**
405
+ + * ovirt_host_get_vms:
406
+ + * @host: a #OvirtHost
407
+ + *
408
+ + * Gets a #OvirtCollection representing the list of remote vms from a
409
+ + * host object. This method does not initiate any network
410
+ + * activity, the remote vm list must be then be fetched using
411
+ + * ovirt_collection_fetch() or ovirt_collection_fetch_async().
412
+ + *
413
+ + * Return value: (transfer none): a #OvirtCollection representing the list
414
+ + * of vms associated with @host.
415
+ + */
416
+ +OvirtCollection *ovirt_host_get_vms(OvirtHost *host)
417
+ +{
418
+ + g_return_val_if_fail(OVIRT_IS_HOST(host), NULL);
419
+ +
420
+ + if (host->priv->vms == NULL) {
421
+ + OvirtCollection *collection;
422
+ + collection = ovirt_sub_collection_new_from_resource(OVIRT_RESOURCE(host),
423
+ + "vms",
424
+ + "vms",
425
+ + OVIRT_TYPE_VM,
426
+ + "vm");
427
+ + host->priv->vms = collection;
428
+ + }
429
+ +
430
+ + return host->priv->vms;
431
+ +}
432
+ diff --git a/govirt/ovirt-host.h b/govirt/ovirt-host.h
433
+ new file mode 100644
434
+ index 0000000..91441f6
435
+ --- /dev/null
436
+ +++ b/govirt/ovirt-host.h
437
+ @@ -0,0 +1,66 @@
438
+ +/*
439
+ + * ovirt-host.h: oVirt host resource
440
+ + *
441
+ + * Copyright (C) 2017 Red Hat, Inc.
442
+ + *
443
+ + * This library is free software; you can redistribute it and/or
444
+ + * modify it under the terms of the GNU Lesser General Public
445
+ + * License as published by the Free Software Foundation; either
446
+ + * version 2.1 of the License, or (at your option) any later version.
447
+ + *
448
+ + * This library is distributed in the hope that it will be useful,
449
+ + * but WITHOUT ANY WARRANTY; without even the implied warranty of
450
+ + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
451
+ + * Lesser General Public License for more details.
452
+ + *
453
+ + * You should have received a copy of the GNU Lesser General Public
454
+ + * License along with this library. If not, see
455
+ + * <http://www.gnu.org/licenses/>.
456
+ + *
457
+ + * Author: Eduardo Lima (Etrunko) <etrunko@redhat.com>
458
+ + */
459
+ +#ifndef __OVIRT_HOST_H__
460
+ +#define __OVIRT_HOST_H__
461
+ +
462
+ +#include <gio/gio.h>
463
+ +#include <glib-object.h>
464
+ +#include <govirt/ovirt-collection.h>
465
+ +#include <govirt/ovirt-resource.h>
466
+ +#include <govirt/ovirt-types.h>
467
+ +
468
+ +G_BEGIN_DECLS
469
+ +
470
+ +#define OVIRT_TYPE_HOST (ovirt_host_get_type ())
471
+ +#define OVIRT_HOST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), OVIRT_TYPE_HOST, OvirtHost))
472
+ +#define OVIRT_HOST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), OVIRT_TYPE_HOST, OvirtHostClass))
473
+ +#define OVIRT_IS_HOST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OVIRT_TYPE_HOST))
474
+ +#define OVIRT_IS_HOST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OVIRT_TYPE_HOST))
475
+ +#define OVIRT_HOST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OVIRT_TYPE_HOST, OvirtHostClass))
476
+ +
477
+ +typedef struct _OvirtHostPrivate OvirtHostPrivate;
478
+ +typedef struct _OvirtHostClass OvirtHostClass;
479
+ +
480
+ +struct _OvirtHost
481
+ +{
482
+ + OvirtResource parent;
483
+ +
484
+ + OvirtHostPrivate *priv;
485
+ +
486
+ + /* Do not add fields to this struct */
487
+ +};
488
+ +
489
+ +struct _OvirtHostClass
490
+ +{
491
+ + OvirtResourceClass parent_class;
492
+ +
493
+ + gpointer padding[20];
494
+ +};
495
+ +
496
+ +GType ovirt_host_get_type(void);
497
+ +
498
+ +OvirtHost *ovirt_host_new(void);
499
+ +OvirtCollection *ovirt_host_get_vms(OvirtHost *host);
500
+ +
501
+ +G_END_DECLS
502
+ +
503
+ +#endif /* __OVIRT_HOST_H__ */
504
+ diff --git a/govirt/ovirt-types.h b/govirt/ovirt-types.h
505
+ index c89521b..42fc004 100644
506
+ --- a/govirt/ovirt-types.h
507
+ +++ b/govirt/ovirt-types.h
508
+ @@ -28,6 +28,7 @@ G_BEGIN_DECLS
509
+ typedef struct _OvirtApi OvirtApi;
510
+ typedef struct _OvirtCdrom OvirtCdrom;
511
+ typedef struct _OvirtCollection OvirtCollection;
512
+ +typedef struct _OvirtHost OvirtHost;
513
+ typedef struct _OvirtProxy OvirtProxy;
514
+ typedef struct _OvirtStorageDomain OvirtStorageDomain;
515
+ typedef struct _OvirtVmDisplay OvirtVmDisplay;
SOURCES/0020-Initial-support-for-clusters.patch ADDED
@@ -0,0 +1,519 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Tue, 11 Apr 2017 21:51:14 -0300
4
+ Subject: [PATCH] Initial support for clusters
5
+
6
+ Like the previous commit, at the moment, we only care about the
7
+ information of the data center the cluster is part of, and the list of
8
+ the hosts associated with it.
9
+
10
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
11
+ ---
12
+ govirt/Makefile.am | 3 +
13
+ govirt/govirt-private.h | 1 +
14
+ govirt/govirt.sym | 6 +
15
+ govirt/ovirt-api.c | 47 +++++++
16
+ govirt/ovirt-api.h | 2 +
17
+ govirt/ovirt-cluster-private.h | 37 ++++++
18
+ govirt/ovirt-cluster.c | 215 +++++++++++++++++++++++++++++++++
19
+ govirt/ovirt-cluster.h | 66 ++++++++++
20
+ govirt/ovirt-types.h | 1 +
21
+ 9 files changed, 378 insertions(+)
22
+ create mode 100644 govirt/ovirt-cluster-private.h
23
+ create mode 100644 govirt/ovirt-cluster.c
24
+ create mode 100644 govirt/ovirt-cluster.h
25
+
26
+ diff --git a/govirt/Makefile.am b/govirt/Makefile.am
27
+ index c62a1d6..cf6b858 100644
28
+ --- a/govirt/Makefile.am
29
+ +++ b/govirt/Makefile.am
30
+ @@ -19,6 +19,7 @@ libgovirt_la_HEADERS = \
31
+ govirt.h \
32
+ ovirt-api.h \
33
+ ovirt-cdrom.h \
34
+ + ovirt-cluster.h \
35
+ ovirt-collection.h \
36
+ ovirt-error.h \
37
+ ovirt-host.h \
38
+ @@ -38,6 +39,7 @@ noinst_HEADERS = \
39
+ govirt-private.h \
40
+ ovirt-action-rest-call.h \
41
+ ovirt-api-private.h \
42
+ + ovirt-cluster-private.h \
43
+ ovirt-collection-private.h \
44
+ ovirt-host-private.h \
45
+ ovirt-proxy-private.h \
46
+ @@ -54,6 +56,7 @@ libgovirt_la_SOURCES = \
47
+ ovirt-action-rest-call.c \
48
+ ovirt-api.c \
49
+ ovirt-cdrom.c \
50
+ + ovirt-cluster.c \
51
+ ovirt-collection.c \
52
+ ovirt-error.c \
53
+ ovirt-host.c \
54
+ diff --git a/govirt/govirt-private.h b/govirt/govirt-private.h
55
+ index b51feb3..d466f7a 100644
56
+ --- a/govirt/govirt-private.h
57
+ +++ b/govirt/govirt-private.h
58
+ @@ -24,6 +24,7 @@
59
+
60
+ #include <govirt/ovirt-action-rest-call.h>
61
+ #include <govirt/ovirt-api-private.h>
62
+ +#include <govirt/ovirt-cluster-private.h>
63
+ #include <govirt/ovirt-collection-private.h>
64
+ #include <govirt/ovirt-enum-types-private.h>
65
+ #include <govirt/ovirt-host-private.h>
66
+ diff --git a/govirt/govirt.sym b/govirt/govirt.sym
67
+ index 6dc8159..56e1d66 100644
68
+ --- a/govirt/govirt.sym
69
+ +++ b/govirt/govirt.sym
70
+ @@ -110,13 +110,19 @@ GOVIRT_0.3.2 {
71
+ ovirt_api_search_vms;
72
+ ovirt_api_search_vm_pools;
73
+
74
+ + ovirt_api_get_clusters;
75
+ ovirt_api_get_hosts;
76
+
77
+ + ovirt_api_search_clusters;
78
+ ovirt_api_search_hosts;
79
+ ovirt_api_search_storage_domains;
80
+ ovirt_api_search_vms;
81
+ ovirt_api_search_vm_pools;
82
+
83
+ + ovirt_cluster_get_type;
84
+ + ovirt_cluster_get_hosts;
85
+ + ovirt_cluster_new;
86
+ +
87
+ ovirt_host_get_type;
88
+ ovirt_host_get_vms;
89
+ ovirt_host_new;
90
+ diff --git a/govirt/ovirt-api.c b/govirt/ovirt-api.c
91
+ index fef04ba..14c6c5a 100644
92
+ --- a/govirt/ovirt-api.c
93
+ +++ b/govirt/ovirt-api.c
94
+ @@ -41,6 +41,7 @@
95
+
96
+
97
+ struct _OvirtApiPrivate {
98
+ + OvirtCollection *clusters;
99
+ OvirtCollection *hosts;
100
+ OvirtCollection *storage_domains;
101
+ OvirtCollection *vms;
102
+ @@ -74,6 +75,7 @@ static void ovirt_api_dispose(GObject *object)
103
+ {
104
+ OvirtApi *api = OVIRT_API(object);
105
+
106
+ + g_clear_object(&api->priv->clusters);
107
+ g_clear_object(&api->priv->hosts);
108
+ g_clear_object(&api->priv->storage_domains);
109
+ g_clear_object(&api->priv->vms);
110
+ @@ -292,3 +294,48 @@ OvirtCollection *ovirt_api_search_hosts(OvirtApi *api, const char *query)
111
+ "host",
112
+ query);
113
+ }
114
+ +
115
+ +
116
+ +/**
117
+ + * ovirt_api_get_clusters:
118
+ + * @api: a #OvirtApi
119
+ + *
120
+ + * This method does not initiate any network activity, the collection
121
+ + * must be fetched with ovirt_collection_fetch() before having up-to-date
122
+ + * content.
123
+ + *
124
+ + * Return value: (transfer none):
125
+ + */
126
+ +OvirtCollection *ovirt_api_get_clusters(OvirtApi *api)
127
+ +{
128
+ + g_return_val_if_fail(OVIRT_IS_API(api), NULL);
129
+ +
130
+ + if (api->priv->clusters == NULL)
131
+ + api->priv->clusters = ovirt_sub_collection_new_from_resource(OVIRT_RESOURCE(api),
132
+ + "clusters",
133
+ + "clusters",
134
+ + OVIRT_TYPE_CLUSTER,
135
+ + "cluster");
136
+ +
137
+ + return api->priv->clusters;
138
+ +}
139
+ +
140
+ +
141
+ +/**
142
+ + * ovirt_api_search_clusters:
143
+ + * @api: a #OvirtApi
144
+ + * @query: search query
145
+ + *
146
+ + * Return value: (transfer none):
147
+ + */
148
+ +OvirtCollection *ovirt_api_search_clusters(OvirtApi *api, const char *query)
149
+ +{
150
+ + g_return_val_if_fail(OVIRT_IS_API(api), NULL);
151
+ +
152
+ + return ovirt_sub_collection_new_from_resource_search(OVIRT_RESOURCE(api),
153
+ + "clusters/search",
154
+ + "clusters",
155
+ + OVIRT_TYPE_CLUSTER,
156
+ + "cluster",
157
+ + query);
158
+ +}
159
+ diff --git a/govirt/ovirt-api.h b/govirt/ovirt-api.h
160
+ index c46e934..1b60f35 100644
161
+ --- a/govirt/ovirt-api.h
162
+ +++ b/govirt/ovirt-api.h
163
+ @@ -60,6 +60,8 @@ struct _OvirtApiClass
164
+ GType ovirt_api_get_type(void);
165
+ OvirtApi *ovirt_api_new(void);
166
+
167
+ +OvirtCollection *ovirt_api_get_clusters(OvirtApi *api);
168
+ +OvirtCollection *ovirt_api_search_clusters(OvirtApi *api, const char *query);
169
+ OvirtCollection *ovirt_api_get_hosts(OvirtApi *api);
170
+ OvirtCollection *ovirt_api_search_hosts(OvirtApi *api, const char *query);
171
+ OvirtCollection *ovirt_api_get_storage_domains(OvirtApi *api);
172
+ diff --git a/govirt/ovirt-cluster-private.h b/govirt/ovirt-cluster-private.h
173
+ new file mode 100644
174
+ index 0000000..1a1817d
175
+ --- /dev/null
176
+ +++ b/govirt/ovirt-cluster-private.h
177
+ @@ -0,0 +1,37 @@
178
+ +/*
179
+ + * ovirt-cluster-private.h: oVirt cluster resource
180
+ + *
181
+ + * Copyright (C) 2017 Red Hat, Inc.
182
+ + *
183
+ + * This library is free software; you can redistribute it and/or
184
+ + * modify it under the terms of the GNU Lesser General Public
185
+ + * License as published by the Free Software Foundation; either
186
+ + * version 2.1 of the License, or (at your option) any later version.
187
+ + *
188
+ + * This library is distributed in the hope that it will be useful,
189
+ + * but WITHOUT ANY WARRANTY; without even the implied warranty of
190
+ + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
191
+ + * Lesser General Public License for more details.
192
+ + *
193
+ + * You should have received a copy of the GNU Lesser General Public
194
+ + * License along with this library. If not, see
195
+ + * <http://www.gnu.org/licenses/>.
196
+ + *
197
+ + * Author: Eduardo Lima (Etrunko) <etrunko@redhat.com>
198
+ + */
199
+ +#ifndef __OVIRT_CLUSTER_PRIVATE_H__
200
+ +#define __OVIRT_CLUSTER_PRIVATE_H__
201
+ +
202
+ +#include <ovirt-cluster.h>
203
+ +#include <rest/rest-xml-node.h>
204
+ +
205
+ +G_BEGIN_DECLS
206
+ +
207
+ +OvirtCluster *ovirt_cluster_new_from_id(const char *id,
208
+ + const char *href);
209
+ +OvirtCluster *ovirt_cluster_new_from_xml(RestXmlNode *node,
210
+ + GError **error);
211
+ +
212
+ +G_END_DECLS
213
+ +
214
+ +#endif /* __OVIRT_CLUSTER_PRIVATE_H__ */
215
+ diff --git a/govirt/ovirt-cluster.c b/govirt/ovirt-cluster.c
216
+ new file mode 100644
217
+ index 0000000..83b0fa1
218
+ --- /dev/null
219
+ +++ b/govirt/ovirt-cluster.c
220
+ @@ -0,0 +1,215 @@
221
+ +/*
222
+ + * ovirt-cluster.c: oVirt cluster handling
223
+ + *
224
+ + * Copyright (C) 2017 Red Hat, Inc.
225
+ + *
226
+ + * This library is free software; you can redistribute it and/or
227
+ + * modify it under the terms of the GNU Lesser General Public
228
+ + * License as published by the Free Software Foundation; either
229
+ + * version 2.1 of the License, or (at your option) any later version.
230
+ + *
231
+ + * This library is distributed in the hope that it will be useful,
232
+ + * but WITHOUT ANY WARRANTY; without even the implied warranty of
233
+ + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
234
+ + * Lesser General Public License for more details.
235
+ + *
236
+ + * You should have received a copy of the GNU Lesser General Public
237
+ + * License along with this library. If not, see
238
+ + * <http://www.gnu.org/licenses/>.
239
+ + *
240
+ + * Author: Eduardo Lima (Etrunko) <etrunko@redhat.com>
241
+ + */
242
+ +
243
+ +#include <config.h>
244
+ +#include "ovirt-enum-types.h"
245
+ +#include "ovirt-cluster.h"
246
+ +#include "govirt-private.h"
247
+ +
248
+ +#define OVIRT_CLUSTER_GET_PRIVATE(obj) \
249
+ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), OVIRT_TYPE_CLUSTER, OvirtClusterPrivate))
250
+ +
251
+ +struct _OvirtClusterPrivate {
252
+ + gchar *data_center_href;
253
+ + gchar *data_center_id;
254
+ + OvirtCollection *hosts;
255
+ +};
256
+ +
257
+ +G_DEFINE_TYPE(OvirtCluster, ovirt_cluster, OVIRT_TYPE_RESOURCE);
258
+ +
259
+ +enum {
260
+ + PROP_0,
261
+ + PROP_DATA_CENTER_HREF,
262
+ + PROP_DATA_CENTER_ID,
263
+ +};
264
+ +
265
+ +static void ovirt_cluster_get_property(GObject *object,
266
+ + guint prop_id,
267
+ + GValue *value,
268
+ + GParamSpec *pspec)
269
+ +{
270
+ + OvirtCluster *cluster = OVIRT_CLUSTER(object);
271
+ +
272
+ + switch (prop_id) {
273
+ + case PROP_DATA_CENTER_HREF:
274
+ + g_value_set_string(value, cluster->priv->data_center_href);
275
+ + break;
276
+ + case PROP_DATA_CENTER_ID:
277
+ + g_value_set_string(value, cluster->priv->data_center_id);
278
+ + break;
279
+ + default:
280
+ + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
281
+ + }
282
+ +}
283
+ +
284
+ +static void ovirt_cluster_set_property(GObject *object,
285
+ + guint prop_id,
286
+ + const GValue *value,
287
+ + GParamSpec *pspec)
288
+ +{
289
+ + OvirtCluster *cluster = OVIRT_CLUSTER(object);
290
+ +
291
+ + switch (prop_id) {
292
+ + case PROP_DATA_CENTER_HREF:
293
+ + g_free(cluster->priv->data_center_href);
294
+ + cluster->priv->data_center_href = g_value_dup_string(value);
295
+ + break;
296
+ + case PROP_DATA_CENTER_ID:
297
+ + g_free(cluster->priv->data_center_id);
298
+ + cluster->priv->data_center_id = g_value_dup_string(value);
299
+ + break;
300
+ + default:
301
+ + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
302
+ + }
303
+ +}
304
+ +
305
+ +
306
+ +static void
307
+ +ovirt_cluster_dispose(GObject *obj)
308
+ +{
309
+ + OvirtCluster *cluster = OVIRT_CLUSTER(obj);
310
+ +
311
+ + g_clear_pointer(&cluster->priv->data_center_href, g_free);
312
+ + g_clear_pointer(&cluster->priv->data_center_id, g_free);
313
+ + g_clear_object(&cluster->priv->hosts);
314
+ +
315
+ + G_OBJECT_CLASS(ovirt_cluster_parent_class)->dispose(obj);
316
+ +}
317
+ +
318
+ +
319
+ +static gboolean ovirt_cluster_init_from_xml(OvirtResource *resource,
320
+ + RestXmlNode *node,
321
+ + GError **error)
322
+ +{
323
+ + OvirtResourceClass *parent_class;
324
+ + OvirtXmlElement cluster_elements[] = {
325
+ + { .prop_name = "data-center-href",
326
+ + .type = G_TYPE_STRING,
327
+ + .xml_path = "data_center",
328
+ + .xml_attr = "href",
329
+ + },
330
+ + { .prop_name = "data-center-id",
331
+ + .type = G_TYPE_STRING,
332
+ + .xml_path = "data_center",
333
+ + .xml_attr = "id",
334
+ + },
335
+ + { NULL , },
336
+ + };
337
+ +
338
+ + if (!ovirt_rest_xml_node_parse(node, G_OBJECT(resource), cluster_elements))
339
+ + return FALSE;
340
+ +
341
+ + parent_class = OVIRT_RESOURCE_CLASS(ovirt_cluster_parent_class);
342
+ + return parent_class->init_from_xml(resource, node, error);
343
+ +}
344
+ +
345
+ +
346
+ +static void ovirt_cluster_class_init(OvirtClusterClass *klass)
347
+ +{
348
+ + GObjectClass *object_class = G_OBJECT_CLASS(klass);
349
+ + OvirtResourceClass *resource_class = OVIRT_RESOURCE_CLASS(klass);
350
+ + GParamSpec *param_spec;
351
+ +
352
+ + g_type_class_add_private(klass, sizeof(OvirtClusterPrivate));
353
+ +
354
+ + resource_class->init_from_xml = ovirt_cluster_init_from_xml;
355
+ + object_class->dispose = ovirt_cluster_dispose;
356
+ + object_class->get_property = ovirt_cluster_get_property;
357
+ + object_class->set_property = ovirt_cluster_set_property;
358
+ +
359
+ + param_spec = g_param_spec_string("data-center-href",
360
+ + "Data Center href",
361
+ + "Data Center href for the Cluster",
362
+ + NULL,
363
+ + G_PARAM_READWRITE |
364
+ + G_PARAM_STATIC_STRINGS);
365
+ + g_object_class_install_property(object_class,
366
+ + PROP_DATA_CENTER_HREF,
367
+ + param_spec);
368
+ +
369
+ + param_spec = g_param_spec_string("data-center-id",
370
+ + "Data Center Id",
371
+ + "Data Center Id for the Cluster",
372
+ + NULL,
373
+ + G_PARAM_READWRITE |
374
+ + G_PARAM_STATIC_STRINGS);
375
+ + g_object_class_install_property(object_class,
376
+ + PROP_DATA_CENTER_ID,
377
+ + param_spec);
378
+ +}
379
+ +
380
+ +static void ovirt_cluster_init(OvirtCluster *cluster)
381
+ +{
382
+ + cluster->priv = OVIRT_CLUSTER_GET_PRIVATE(cluster);
383
+ +}
384
+ +
385
+ +G_GNUC_INTERNAL
386
+ +OvirtCluster *ovirt_cluster_new_from_id(const char *id,
387
+ + const char *href)
388
+ +{
389
+ + OvirtResource *cluster = ovirt_resource_new_from_id(OVIRT_TYPE_CLUSTER, id, href);
390
+ + return OVIRT_CLUSTER(cluster);
391
+ +}
392
+ +
393
+ +G_GNUC_INTERNAL
394
+ +OvirtCluster *ovirt_cluster_new_from_xml(RestXmlNode *node,
395
+ + GError **error)
396
+ +{
397
+ + OvirtResource *cluster = ovirt_resource_new_from_xml(OVIRT_TYPE_CLUSTER, node, error);
398
+ + return OVIRT_CLUSTER(cluster);
399
+ +}
400
+ +
401
+ +OvirtCluster *ovirt_cluster_new(void)
402
+ +{
403
+ + OvirtResource *cluster = ovirt_resource_new(OVIRT_TYPE_CLUSTER);
404
+ + return OVIRT_CLUSTER(cluster);
405
+ +}
406
+ +
407
+ +/**
408
+ + * ovirt_cluster_get_hosts:
409
+ + * @cluster: a #OvirtCluster
410
+ + *
411
+ + * Gets a #OvirtCollection representing the list of remote hosts from a
412
+ + * cluster object. This method does not initiate any network
413
+ + * activity, the remote host list must be then be fetched using
414
+ + * ovirt_collection_fetch() or ovirt_collection_fetch_async().
415
+ + *
416
+ + * Return value: (transfer none): a #OvirtCollection representing the list
417
+ + * of hosts associated with @cluster.
418
+ + */
419
+ +OvirtCollection *ovirt_cluster_get_hosts(OvirtCluster *cluster)
420
+ +{
421
+ + g_return_val_if_fail(OVIRT_IS_CLUSTER(cluster), NULL);
422
+ +
423
+ + if (cluster->priv->hosts == NULL) {
424
+ + OvirtCollection *collection;
425
+ + collection = ovirt_sub_collection_new_from_resource(OVIRT_RESOURCE(cluster),
426
+ + "hosts",
427
+ + "hosts",
428
+ + OVIRT_TYPE_HOST,
429
+ + "host");
430
+ + cluster->priv->hosts = collection;
431
+ + }
432
+ +
433
+ + return cluster->priv->hosts;
434
+ +}
435
+ +
436
+ diff --git a/govirt/ovirt-cluster.h b/govirt/ovirt-cluster.h
437
+ new file mode 100644
438
+ index 0000000..9505e8c
439
+ --- /dev/null
440
+ +++ b/govirt/ovirt-cluster.h
441
+ @@ -0,0 +1,66 @@
442
+ +/*
443
+ + * ovirt-cluster.h: oVirt cluster resource
444
+ + *
445
+ + * Copyright (C) 2017 Red Hat, Inc.
446
+ + *
447
+ + * This library is free software; you can redistribute it and/or
448
+ + * modify it under the terms of the GNU Lesser General Public
449
+ + * License as published by the Free Software Foundation; either
450
+ + * version 2.1 of the License, or (at your option) any later version.
451
+ + *
452
+ + * This library is distributed in the hope that it will be useful,
453
+ + * but WITHOUT ANY WARRANTY; without even the implied warranty of
454
+ + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
455
+ + * Lesser General Public License for more details.
456
+ + *
457
+ + * You should have received a copy of the GNU Lesser General Public
458
+ + * License along with this library. If not, see
459
+ + * <http://www.gnu.org/licenses/>.
460
+ + *
461
+ + * Author: Eduardo Lima (Etrunko) <etrunko@redhat.com>
462
+ + */
463
+ +#ifndef __OVIRT_CLUSTER_H__
464
+ +#define __OVIRT_CLUSTER_H__
465
+ +
466
+ +#include <gio/gio.h>
467
+ +#include <glib-object.h>
468
+ +#include <govirt/ovirt-collection.h>
469
+ +#include <govirt/ovirt-resource.h>
470
+ +#include <govirt/ovirt-types.h>
471
+ +
472
+ +G_BEGIN_DECLS
473
+ +
474
+ +#define OVIRT_TYPE_CLUSTER (ovirt_cluster_get_type ())
475
+ +#define OVIRT_CLUSTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), OVIRT_TYPE_CLUSTER, OvirtCluster))
476
+ +#define OVIRT_CLUSTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), OVIRT_TYPE_CLUSTER, OvirtClusterClass))
477
+ +#define OVIRT_IS_CLUSTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OVIRT_TYPE_CLUSTER))
478
+ +#define OVIRT_IS_CLUSTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OVIRT_TYPE_CLUSTER))
479
+ +#define OVIRT_CLUSTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OVIRT_TYPE_CLUSTER, OvirtClusterClass))
480
+ +
481
+ +typedef struct _OvirtClusterPrivate OvirtClusterPrivate;
482
+ +typedef struct _OvirtClusterClass OvirtClusterClass;
483
+ +
484
+ +struct _OvirtCluster
485
+ +{
486
+ + OvirtResource parent;
487
+ +
488
+ + OvirtClusterPrivate *priv;
489
+ +
490
+ + /* Do not add fields to this struct */
491
+ +};
492
+ +
493
+ +struct _OvirtClusterClass
494
+ +{
495
+ + OvirtResourceClass parent_class;
496
+ +
497
+ + gpointer padding[20];
498
+ +};
499
+ +
500
+ +GType ovirt_cluster_get_type(void);
501
+ +
502
+ +OvirtCluster *ovirt_cluster_new(void);
503
+ +OvirtCollection *ovirt_cluster_get_hosts(OvirtCluster *cluster);
504
+ +
505
+ +G_END_DECLS
506
+ +
507
+ +#endif /* __OVIRT_CLUSTER_H__ */
508
+ diff --git a/govirt/ovirt-types.h b/govirt/ovirt-types.h
509
+ index 42fc004..e2f196e 100644
510
+ --- a/govirt/ovirt-types.h
511
+ +++ b/govirt/ovirt-types.h
512
+ @@ -27,6 +27,7 @@ G_BEGIN_DECLS
513
+
514
+ typedef struct _OvirtApi OvirtApi;
515
+ typedef struct _OvirtCdrom OvirtCdrom;
516
+ +typedef struct _OvirtCluster OvirtCluster;
517
+ typedef struct _OvirtCollection OvirtCollection;
518
+ typedef struct _OvirtHost OvirtHost;
519
+ typedef struct _OvirtProxy OvirtProxy;
SOURCES/0021-Initial-support-for-data-centers.patch ADDED
@@ -0,0 +1,452 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Tue, 11 Apr 2017 21:53:26 -0300
4
+ Subject: [PATCH] Initial support for data centers
5
+
6
+ For this higher level object, the list of clusters and storage domains
7
+ associated with it are stored.
8
+
9
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
10
+ ---
11
+ govirt/Makefile.am | 3 +
12
+ govirt/govirt-private.h | 1 +
13
+ govirt/govirt.sym | 7 ++
14
+ govirt/ovirt-api.c | 47 ++++++++++
15
+ govirt/ovirt-api.h | 2 +
16
+ govirt/ovirt-data-center-private.h | 37 ++++++++
17
+ govirt/ovirt-data-center.c | 144 +++++++++++++++++++++++++++++
18
+ govirt/ovirt-data-center.h | 67 ++++++++++++++
19
+ govirt/ovirt-types.h | 1 +
20
+ 9 files changed, 309 insertions(+)
21
+ create mode 100644 govirt/ovirt-data-center-private.h
22
+ create mode 100644 govirt/ovirt-data-center.c
23
+ create mode 100644 govirt/ovirt-data-center.h
24
+
25
+ diff --git a/govirt/Makefile.am b/govirt/Makefile.am
26
+ index cf6b858..9bf0eba 100644
27
+ --- a/govirt/Makefile.am
28
+ +++ b/govirt/Makefile.am
29
+ @@ -21,6 +21,7 @@ libgovirt_la_HEADERS = \
30
+ ovirt-cdrom.h \
31
+ ovirt-cluster.h \
32
+ ovirt-collection.h \
33
+ + ovirt-data-center.h \
34
+ ovirt-error.h \
35
+ ovirt-host.h \
36
+ ovirt-options.h \
37
+ @@ -41,6 +42,7 @@ noinst_HEADERS = \
38
+ ovirt-api-private.h \
39
+ ovirt-cluster-private.h \
40
+ ovirt-collection-private.h \
41
+ + ovirt-data-center-private.h \
42
+ ovirt-host-private.h \
43
+ ovirt-proxy-private.h \
44
+ ovirt-resource-private.h \
45
+ @@ -58,6 +60,7 @@ libgovirt_la_SOURCES = \
46
+ ovirt-cdrom.c \
47
+ ovirt-cluster.c \
48
+ ovirt-collection.c \
49
+ + ovirt-data-center.c \
50
+ ovirt-error.c \
51
+ ovirt-host.c \
52
+ ovirt-options.c \
53
+ diff --git a/govirt/govirt-private.h b/govirt/govirt-private.h
54
+ index d466f7a..cd98b5b 100644
55
+ --- a/govirt/govirt-private.h
56
+ +++ b/govirt/govirt-private.h
57
+ @@ -26,6 +26,7 @@
58
+ #include <govirt/ovirt-api-private.h>
59
+ #include <govirt/ovirt-cluster-private.h>
60
+ #include <govirt/ovirt-collection-private.h>
61
+ +#include <govirt/ovirt-data-center-private.h>
62
+ #include <govirt/ovirt-enum-types-private.h>
63
+ #include <govirt/ovirt-host-private.h>
64
+ #include <govirt/ovirt-proxy-private.h>
65
+ diff --git a/govirt/govirt.sym b/govirt/govirt.sym
66
+ index 56e1d66..b22af76 100644
67
+ --- a/govirt/govirt.sym
68
+ +++ b/govirt/govirt.sym
69
+ @@ -111,9 +111,11 @@ GOVIRT_0.3.2 {
70
+ ovirt_api_search_vm_pools;
71
+
72
+ ovirt_api_get_clusters;
73
+ + ovirt_api_get_data_centers;
74
+ ovirt_api_get_hosts;
75
+
76
+ ovirt_api_search_clusters;
77
+ + ovirt_api_search_data_centers;
78
+ ovirt_api_search_hosts;
79
+ ovirt_api_search_storage_domains;
80
+ ovirt_api_search_vms;
81
+ @@ -123,6 +125,11 @@ GOVIRT_0.3.2 {
82
+ ovirt_cluster_get_hosts;
83
+ ovirt_cluster_new;
84
+
85
+ + ovirt_data_center_get_clusters;
86
+ + ovirt_data_center_get_storage_domains;
87
+ + ovirt_data_center_get_type;
88
+ + ovirt_data_center_new;
89
+ +
90
+ ovirt_host_get_type;
91
+ ovirt_host_get_vms;
92
+ ovirt_host_new;
93
+ diff --git a/govirt/ovirt-api.c b/govirt/ovirt-api.c
94
+ index 14c6c5a..d78ba7e 100644
95
+ --- a/govirt/ovirt-api.c
96
+ +++ b/govirt/ovirt-api.c
97
+ @@ -42,6 +42,7 @@
98
+
99
+ struct _OvirtApiPrivate {
100
+ OvirtCollection *clusters;
101
+ + OvirtCollection *data_centers;
102
+ OvirtCollection *hosts;
103
+ OvirtCollection *storage_domains;
104
+ OvirtCollection *vms;
105
+ @@ -76,6 +77,7 @@ static void ovirt_api_dispose(GObject *object)
106
+ OvirtApi *api = OVIRT_API(object);
107
+
108
+ g_clear_object(&api->priv->clusters);
109
+ + g_clear_object(&api->priv->data_centers);
110
+ g_clear_object(&api->priv->hosts);
111
+ g_clear_object(&api->priv->storage_domains);
112
+ g_clear_object(&api->priv->vms);
113
+ @@ -339,3 +341,48 @@ OvirtCollection *ovirt_api_search_clusters(OvirtApi *api, const char *query)
114
+ "cluster",
115
+ query);
116
+ }
117
+ +
118
+ +
119
+ +/**
120
+ + * ovirt_api_get_data_centers:
121
+ + * @api: a #OvirtApi
122
+ + *
123
+ + * This method does not initiate any network activity, the collection
124
+ + * must be fetched with ovirt_collection_fetch() before having up-to-date
125
+ + * content.
126
+ + *
127
+ + * Return value: (transfer none):
128
+ + */
129
+ +OvirtCollection *ovirt_api_get_data_centers(OvirtApi *api)
130
+ +{
131
+ + g_return_val_if_fail(OVIRT_IS_API(api), NULL);
132
+ +
133
+ + if (api->priv->data_centers == NULL)
134
+ + api->priv->data_centers = ovirt_sub_collection_new_from_resource(OVIRT_RESOURCE(api),
135
+ + "datacenters",
136
+ + "data_centers",
137
+ + OVIRT_TYPE_DATA_CENTER,
138
+ + "data_center");
139
+ +
140
+ + return api->priv->data_centers;
141
+ +}
142
+ +
143
+ +
144
+ +/**
145
+ + * ovirt_api_search_data_centers:
146
+ + * @api: a #OvirtApi
147
+ + * @query: search query
148
+ + *
149
+ + * Return value: (transfer none):
150
+ + */
151
+ +OvirtCollection *ovirt_api_search_data_centers(OvirtApi *api, const char *query)
152
+ +{
153
+ + g_return_val_if_fail(OVIRT_IS_API(api), NULL);
154
+ +
155
+ + return ovirt_sub_collection_new_from_resource_search(OVIRT_RESOURCE(api),
156
+ + "datacenters/search",
157
+ + "data_centers",
158
+ + OVIRT_TYPE_DATA_CENTER,
159
+ + "data_center",
160
+ + query);
161
+ +}
162
+ diff --git a/govirt/ovirt-api.h b/govirt/ovirt-api.h
163
+ index 1b60f35..1448296 100644
164
+ --- a/govirt/ovirt-api.h
165
+ +++ b/govirt/ovirt-api.h
166
+ @@ -62,6 +62,8 @@ OvirtApi *ovirt_api_new(void);
167
+
168
+ OvirtCollection *ovirt_api_get_clusters(OvirtApi *api);
169
+ OvirtCollection *ovirt_api_search_clusters(OvirtApi *api, const char *query);
170
+ +OvirtCollection *ovirt_api_get_data_centers(OvirtApi *api);
171
+ +OvirtCollection *ovirt_api_search_data_centers(OvirtApi *api, const char *query);
172
+ OvirtCollection *ovirt_api_get_hosts(OvirtApi *api);
173
+ OvirtCollection *ovirt_api_search_hosts(OvirtApi *api, const char *query);
174
+ OvirtCollection *ovirt_api_get_storage_domains(OvirtApi *api);
175
+ diff --git a/govirt/ovirt-data-center-private.h b/govirt/ovirt-data-center-private.h
176
+ new file mode 100644
177
+ index 0000000..5839755
178
+ --- /dev/null
179
+ +++ b/govirt/ovirt-data-center-private.h
180
+ @@ -0,0 +1,37 @@
181
+ +/*
182
+ + * ovirt-data_center-private.h: oVirt data center resource
183
+ + *
184
+ + * Copyright (C) 2017 Red Hat, Inc.
185
+ + *
186
+ + * This library is free software; you can redistribute it and/or
187
+ + * modify it under the terms of the GNU Lesser General Public
188
+ + * License as published by the Free Software Foundation; either
189
+ + * version 2.1 of the License, or (at your option) any later version.
190
+ + *
191
+ + * This library is distributed in the hope that it will be useful,
192
+ + * but WITHOUT ANY WARRANTY; without even the implied warranty of
193
+ + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
194
+ + * Lesser General Public License for more details.
195
+ + *
196
+ + * You should have received a copy of the GNU Lesser General Public
197
+ + * License along with this library. If not, see
198
+ + * <http://www.gnu.org/licenses/>.
199
+ + *
200
+ + * Author: Eduardo Lima (Etrunko) <etrunko@redhat.com>
201
+ + */
202
+ +#ifndef __OVIRT_DATA_CENTER_PRIVATE_H__
203
+ +#define __OVIRT_DATA_CENTER_PRIVATE_H__
204
+ +
205
+ +#include <ovirt-data-center.h>
206
+ +#include <rest/rest-xml-node.h>
207
+ +
208
+ +G_BEGIN_DECLS
209
+ +
210
+ +OvirtDataCenter *ovirt_data_center_new_from_id(const char *id,
211
+ + const char *href);
212
+ +OvirtDataCenter *ovirt_data_center_new_from_xml(RestXmlNode *node,
213
+ + GError **error);
214
+ +
215
+ +G_END_DECLS
216
+ +
217
+ +#endif /* __OVIRT_DATA_CENTER_PRIVATE_H__ */
218
+ diff --git a/govirt/ovirt-data-center.c b/govirt/ovirt-data-center.c
219
+ new file mode 100644
220
+ index 0000000..577a31f
221
+ --- /dev/null
222
+ +++ b/govirt/ovirt-data-center.c
223
+ @@ -0,0 +1,144 @@
224
+ +/*
225
+ + * ovirt-data_center.c: oVirt data center handling
226
+ + *
227
+ + * Copyright (C) 2017 Red Hat, Inc.
228
+ + *
229
+ + * This library is free software; you can redistribute it and/or
230
+ + * modify it under the terms of the GNU Lesser General Public
231
+ + * License as published by the Free Software Foundation; either
232
+ + * version 2.1 of the License, or (at your option) any later version.
233
+ + *
234
+ + * This library is distributed in the hope that it will be useful,
235
+ + * but WITHOUT ANY WARRANTY; without even the implied warranty of
236
+ + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
237
+ + * Lesser General Public License for more details.
238
+ + *
239
+ + * You should have received a copy of the GNU Lesser General Public
240
+ + * License along with this library. If not, see
241
+ + * <http://www.gnu.org/licenses/>.
242
+ + *
243
+ + * Author: Eduardo Lima (Etrunko) <etrunko@redhat.com>
244
+ + */
245
+ +
246
+ +#include <config.h>
247
+ +#include "ovirt-enum-types.h"
248
+ +#include "ovirt-data-center.h"
249
+ +#include "govirt-private.h"
250
+ +
251
+ +#define OVIRT_DATA_CENTER_GET_PRIVATE(obj) \
252
+ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), OVIRT_TYPE_DATA_CENTER, OvirtDataCenterPrivate))
253
+ +
254
+ +struct _OvirtDataCenterPrivate {
255
+ + OvirtCollection *clusters;
256
+ + OvirtCollection *storage_domains;
257
+ +};
258
+ +
259
+ +G_DEFINE_TYPE(OvirtDataCenter, ovirt_data_center, OVIRT_TYPE_RESOURCE);
260
+ +
261
+ +static void
262
+ +ovirt_data_center_dispose(GObject *obj)
263
+ +{
264
+ + OvirtDataCenter *data_center = OVIRT_DATA_CENTER(obj);
265
+ +
266
+ + g_clear_object(&data_center->priv->clusters);
267
+ + g_clear_object(&data_center->priv->storage_domains);
268
+ +
269
+ + G_OBJECT_CLASS(ovirt_data_center_parent_class)->dispose(obj);
270
+ +}
271
+ +
272
+ +static void ovirt_data_center_class_init(OvirtDataCenterClass *klass)
273
+ +{
274
+ + GObjectClass *object_class = G_OBJECT_CLASS(klass);
275
+ +
276
+ + g_type_class_add_private(klass, sizeof(OvirtDataCenterPrivate));
277
+ +
278
+ + object_class->dispose = ovirt_data_center_dispose;
279
+ +}
280
+ +
281
+ +
282
+ +static void ovirt_data_center_init(OvirtDataCenter *data_center)
283
+ +{
284
+ + data_center->priv = OVIRT_DATA_CENTER_GET_PRIVATE(data_center);
285
+ +}
286
+ +
287
+ +G_GNUC_INTERNAL
288
+ +OvirtDataCenter *ovirt_data_center_new_from_id(const char *id,
289
+ + const char *href)
290
+ +{
291
+ + OvirtResource *data_center = ovirt_resource_new_from_id(OVIRT_TYPE_DATA_CENTER, id, href);
292
+ + return OVIRT_DATA_CENTER(data_center);
293
+ +}
294
+ +
295
+ +G_GNUC_INTERNAL
296
+ +OvirtDataCenter *ovirt_data_center_new_from_xml(RestXmlNode *node,
297
+ + GError **error)
298
+ +{
299
+ + OvirtResource *data_center = ovirt_resource_new_from_xml(OVIRT_TYPE_DATA_CENTER, node, error);
300
+ + return OVIRT_DATA_CENTER(data_center);
301
+ +}
302
+ +
303
+ +OvirtDataCenter *ovirt_data_center_new(void)
304
+ +{
305
+ + OvirtResource *data_center = ovirt_resource_new(OVIRT_TYPE_DATA_CENTER);
306
+ + return OVIRT_DATA_CENTER(data_center);
307
+ +}
308
+ +
309
+ +
310
+ +/**
311
+ + * ovirt_data_center_get_clusters:
312
+ + * @data_center: a #OvirtDataCenter
313
+ + *
314
+ + * Gets a #OvirtCollection representing the list of remote clusters from a
315
+ + * data center object. This method does not initiate any network
316
+ + * activity, the remote cluster list must be then be fetched using
317
+ + * ovirt_collection_fetch() or ovirt_collection_fetch_async().
318
+ + *
319
+ + * Return value: (transfer none): a #OvirtCollection representing the list
320
+ + * of clusters associated with @data_center.
321
+ + */
322
+ +OvirtCollection *ovirt_data_center_get_clusters(OvirtDataCenter *data_center)
323
+ +{
324
+ + g_return_val_if_fail(OVIRT_IS_DATA_CENTER(data_center), NULL);
325
+ +
326
+ + if (data_center->priv->clusters == NULL) {
327
+ + OvirtCollection *collection;
328
+ + collection = ovirt_sub_collection_new_from_resource(OVIRT_RESOURCE(data_center),
329
+ + "clusters",
330
+ + "clusters",
331
+ + OVIRT_TYPE_CLUSTER,
332
+ + "cluster");
333
+ + data_center->priv->clusters = collection;
334
+ + }
335
+ +
336
+ + return data_center->priv->clusters;
337
+ +}
338
+ +
339
+ +
340
+ +/**
341
+ + * ovirt_data_center_get_storage_domains:
342
+ + * @data_center: a #OvirtDataCenter
343
+ + *
344
+ + * Gets a #OvirtCollection representing the list of remote storage domains from a
345
+ + * data center object. This method does not initiate any network
346
+ + * activity, the remote storage domain list must be then be fetched using
347
+ + * ovirt_collection_fetch() or ovirt_collection_fetch_async().
348
+ + *
349
+ + * Return value: (transfer none): a #OvirtCollection representing the list
350
+ + * of storage_domains associated with @data_center.
351
+ + */
352
+ +OvirtCollection *ovirt_data_center_get_storage_domains(OvirtDataCenter *data_center)
353
+ +{
354
+ + g_return_val_if_fail(OVIRT_IS_DATA_CENTER(data_center), NULL);
355
+ +
356
+ + if (data_center->priv->storage_domains == NULL) {
357
+ + OvirtCollection *collection;
358
+ + collection = ovirt_sub_collection_new_from_resource(OVIRT_RESOURCE(data_center),
359
+ + "storagedomains",
360
+ + "storage_domains",
361
+ + OVIRT_TYPE_STORAGE_DOMAIN,
362
+ + "storage_domain");
363
+ + data_center->priv->storage_domains = collection;
364
+ + }
365
+ +
366
+ + return data_center->priv->storage_domains;
367
+ +}
368
+ diff --git a/govirt/ovirt-data-center.h b/govirt/ovirt-data-center.h
369
+ new file mode 100644
370
+ index 0000000..1bad06f
371
+ --- /dev/null
372
+ +++ b/govirt/ovirt-data-center.h
373
+ @@ -0,0 +1,67 @@
374
+ +/*
375
+ + * ovirt-data_center.h: oVirt data center resource
376
+ + *
377
+ + * Copyright (C) 2017 Red Hat, Inc.
378
+ + *
379
+ + * This library is free software; you can redistribute it and/or
380
+ + * modify it under the terms of the GNU Lesser General Public
381
+ + * License as published by the Free Software Foundation; either
382
+ + * version 2.1 of the License, or (at your option) any later version.
383
+ + *
384
+ + * This library is distributed in the hope that it will be useful,
385
+ + * but WITHOUT ANY WARRANTY; without even the implied warranty of
386
+ + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
387
+ + * Lesser General Public License for more details.
388
+ + *
389
+ + * You should have received a copy of the GNU Lesser General Public
390
+ + * License along with this library. If not, see
391
+ + * <http://www.gnu.org/licenses/>.
392
+ + *
393
+ + * Author: Eduardo Lima (Etrunko) <etrunko@redhat.com>
394
+ + */
395
+ +#ifndef __OVIRT_DATA_CENTER_H__
396
+ +#define __OVIRT_DATA_CENTER_H__
397
+ +
398
+ +#include <gio/gio.h>
399
+ +#include <glib-object.h>
400
+ +#include <govirt/ovirt-collection.h>
401
+ +#include <govirt/ovirt-resource.h>
402
+ +#include <govirt/ovirt-types.h>
403
+ +
404
+ +G_BEGIN_DECLS
405
+ +
406
+ +#define OVIRT_TYPE_DATA_CENTER (ovirt_data_center_get_type ())
407
+ +#define OVIRT_DATA_CENTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), OVIRT_TYPE_DATA_CENTER, OvirtDataCenter))
408
+ +#define OVIRT_DATA_CENTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), OVIRT_TYPE_DATA_CENTER, OvirtDataCenterClass))
409
+ +#define OVIRT_IS_DATA_CENTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OVIRT_TYPE_DATA_CENTER))
410
+ +#define OVIRT_IS_DATA_CENTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OVIRT_TYPE_DATA_CENTER))
411
+ +#define OVIRT_DATA_CENTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OVIRT_TYPE_DATA_CENTER, OvirtDataCenterClass))
412
+ +
413
+ +typedef struct _OvirtDataCenterPrivate OvirtDataCenterPrivate;
414
+ +typedef struct _OvirtDataCenterClass OvirtDataCenterClass;
415
+ +
416
+ +struct _OvirtDataCenter
417
+ +{
418
+ + OvirtResource parent;
419
+ +
420
+ + OvirtDataCenterPrivate *priv;
421
+ +
422
+ + /* Do not add fields to this struct */
423
+ +};
424
+ +
425
+ +struct _OvirtDataCenterClass
426
+ +{
427
+ + OvirtResourceClass parent_class;
428
+ +
429
+ + gpointer padding[20];
430
+ +};
431
+ +
432
+ +GType ovirt_data_center_get_type(void);
433
+ +
434
+ +OvirtDataCenter *ovirt_data_center_new(void);
435
+ +OvirtCollection *ovirt_data_center_get_clusters(OvirtDataCenter *data_center);
436
+ +OvirtCollection *ovirt_data_center_get_storage_domains(OvirtDataCenter *data_center);
437
+ +
438
+ +G_END_DECLS
439
+ +
440
+ +#endif /* __OVIRT_DATA_CENTER_H__ */
441
+ diff --git a/govirt/ovirt-types.h b/govirt/ovirt-types.h
442
+ index e2f196e..eb85fd6 100644
443
+ --- a/govirt/ovirt-types.h
444
+ +++ b/govirt/ovirt-types.h
445
+ @@ -29,6 +29,7 @@ typedef struct _OvirtApi OvirtApi;
446
+ typedef struct _OvirtCdrom OvirtCdrom;
447
+ typedef struct _OvirtCluster OvirtCluster;
448
+ typedef struct _OvirtCollection OvirtCollection;
449
+ +typedef struct _OvirtDataCenter OvirtDataCenter;
450
+ typedef struct _OvirtHost OvirtHost;
451
+ typedef struct _OvirtProxy OvirtProxy;
452
+ typedef struct _OvirtStorageDomain OvirtStorageDomain;
SOURCES/0022-vm-Introduce-ovirt_vm_get_host.patch ADDED
@@ -0,0 +1,196 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Thu, 13 Jul 2017 18:02:49 -0300
4
+ Subject: [PATCH] vm: Introduce ovirt_vm_get_host()
5
+
6
+ With initial support for hosts implemented, this new function can be
7
+ used to retrieve the host the virtual machine belongs to.
8
+
9
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
10
+ ---
11
+ govirt/govirt.sym | 2 ++
12
+ govirt/ovirt-vm.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++-
13
+ govirt/ovirt-vm.h | 1 +
14
+ 3 files changed, 94 insertions(+), 1 deletion(-)
15
+
16
+ diff --git a/govirt/govirt.sym b/govirt/govirt.sym
17
+ index b22af76..039c88b 100644
18
+ --- a/govirt/govirt.sym
19
+ +++ b/govirt/govirt.sym
20
+ @@ -133,6 +133,8 @@ GOVIRT_0.3.2 {
21
+ ovirt_host_get_type;
22
+ ovirt_host_get_vms;
23
+ ovirt_host_new;
24
+ +
25
+ + ovirt_vm_get_host;
26
+ } GOVIRT_0.3.1;
27
+
28
+ GOVIRT_0.3.4 {
29
+ diff --git a/govirt/ovirt-vm.c b/govirt/ovirt-vm.c
30
+ index 806b5f3..6016c77 100644
31
+ --- a/govirt/ovirt-vm.c
32
+ +++ b/govirt/ovirt-vm.c
33
+ @@ -42,6 +42,8 @@ struct _OvirtVmPrivate {
34
+
35
+ OvirtVmState state;
36
+ OvirtVmDisplay *display;
37
+ + gchar *host_href;
38
+ + gchar *host_id;
39
+ } ;
40
+ G_DEFINE_TYPE(OvirtVm, ovirt_vm, OVIRT_TYPE_RESOURCE);
41
+
42
+ @@ -56,9 +58,28 @@ enum OvirtResponseStatus {
43
+ enum {
44
+ PROP_0,
45
+ PROP_STATE,
46
+ - PROP_DISPLAY
47
+ + PROP_DISPLAY,
48
+ + PROP_HOST_HREF,
49
+ + PROP_HOST_ID,
50
+ };
51
+
52
+ +static char *ensure_href_from_id(const char *id,
53
+ + const char *path)
54
+ +{
55
+ + if (id == NULL)
56
+ + return NULL;
57
+ +
58
+ + return g_strdup_printf("%s/%s", path, id);
59
+ +}
60
+ +
61
+ +static const char *get_host_href(OvirtVm *vm)
62
+ +{
63
+ + if (vm->priv->host_href == NULL)
64
+ + vm->priv->host_href = ensure_href_from_id(vm->priv->host_id, "/ovirt-engine/api/hosts");
65
+ +
66
+ + return vm->priv->host_href;
67
+ +}
68
+ +
69
+ static void ovirt_vm_get_property(GObject *object,
70
+ guint prop_id,
71
+ GValue *value,
72
+ @@ -73,6 +94,12 @@ static void ovirt_vm_get_property(GObject *object,
73
+ case PROP_DISPLAY:
74
+ g_value_set_object(value, vm->priv->display);
75
+ break;
76
+ + case PROP_HOST_HREF:
77
+ + g_value_set_string(value, get_host_href(vm));
78
+ + break;
79
+ + case PROP_HOST_ID:
80
+ + g_value_set_string(value, vm->priv->host_id);
81
+ + break;
82
+ default:
83
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
84
+ }
85
+ @@ -94,6 +121,14 @@ static void ovirt_vm_set_property(GObject *object,
86
+ g_object_unref(vm->priv->display);
87
+ vm->priv->display = g_value_dup_object(value);
88
+ break;
89
+ + case PROP_HOST_HREF:
90
+ + g_free(vm->priv->host_href);
91
+ + vm->priv->host_href = g_value_dup_string(value);
92
+ + break;
93
+ + case PROP_HOST_ID:
94
+ + g_free(vm->priv->host_id);
95
+ + vm->priv->host_id = g_value_dup_string(value);
96
+ + break;
97
+ default:
98
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
99
+ }
100
+ @@ -106,6 +141,8 @@ static void ovirt_vm_dispose(GObject *object)
101
+
102
+ g_clear_object(&vm->priv->cdroms);
103
+ g_clear_object(&vm->priv->display);
104
+ + g_clear_pointer(&vm->priv->host_href, g_free);
105
+ + g_clear_pointer(&vm->priv->host_id, g_free);
106
+
107
+ G_OBJECT_CLASS(ovirt_vm_parent_class)->dispose(object);
108
+ }
109
+ @@ -117,11 +154,28 @@ static gboolean ovirt_vm_init_from_xml(OvirtResource *resource,
110
+ {
111
+ gboolean parsed_ok;
112
+ OvirtResourceClass *parent_class;
113
+ + OvirtXmlElement vm_elements[] = {
114
+ + { .prop_name = "host-href",
115
+ + .type = G_TYPE_STRING,
116
+ + .xml_path = "host",
117
+ + .xml_attr = "href",
118
+ + },
119
+ + { .prop_name = "host-id",
120
+ + .type = G_TYPE_STRING,
121
+ + .xml_path = "host",
122
+ + .xml_attr = "id",
123
+ + },
124
+ + { NULL, },
125
+ + };
126
+
127
+ parsed_ok = ovirt_vm_refresh_from_xml(OVIRT_VM(resource), node);
128
+ if (!parsed_ok) {
129
+ return FALSE;
130
+ }
131
+ +
132
+ + if (!ovirt_rest_xml_node_parse(node, G_OBJECT(resource), vm_elements))
133
+ + return FALSE;
134
+ +
135
+ parent_class = OVIRT_RESOURCE_CLASS(ovirt_vm_parent_class);
136
+
137
+ return parent_class->init_from_xml(resource, node, error);
138
+ @@ -156,6 +210,22 @@ static void ovirt_vm_class_init(OvirtVmClass *klass)
139
+ OVIRT_TYPE_VM_DISPLAY,
140
+ G_PARAM_READWRITE |
141
+ G_PARAM_STATIC_STRINGS));
142
+ + g_object_class_install_property(object_class,
143
+ + PROP_HOST_HREF,
144
+ + g_param_spec_string("host-href",
145
+ + "Host href",
146
+ + "Host href for the Virtual Machine",
147
+ + NULL,
148
+ + G_PARAM_READWRITE |
149
+ + G_PARAM_STATIC_STRINGS));
150
+ + g_object_class_install_property(object_class,
151
+ + PROP_HOST_ID,
152
+ + g_param_spec_string("host-id",
153
+ + "Host Id",
154
+ + "Host Id for the Virtual Machine",
155
+ + NULL,
156
+ + G_PARAM_READWRITE |
157
+ + G_PARAM_STATIC_STRINGS));
158
+ }
159
+
160
+ static void ovirt_vm_init(G_GNUC_UNUSED OvirtVm *vm)
161
+ @@ -342,3 +412,23 @@ OvirtCollection *ovirt_vm_get_cdroms(OvirtVm *vm)
162
+
163
+ return vm->priv->cdroms;
164
+ }
165
+ +
166
+ +
167
+ +/**
168
+ + * ovirt_vm_get_host:
169
+ + * @vm: a #OvirtVm
170
+ + *
171
+ + * Gets a #OvirtHost representing the host the virtual machine belongs to.
172
+ + * This method does not initiate any network activity, the remote host must be
173
+ + * then be fetched using ovirt_resource_refresh() or
174
+ + * ovirt_resource_refresh_async().
175
+ + *
176
+ + * Return value: (transfer full): a #OvirtHost representing host the @vm
177
+ + * belongs to.
178
+ + */
179
+ +OvirtHost *ovirt_vm_get_host(OvirtVm *vm)
180
+ +{
181
+ + g_return_val_if_fail(OVIRT_IS_VM(vm), NULL);
182
+ + g_return_val_if_fail(vm->priv->host_id != NULL, NULL);
183
+ + return ovirt_host_new_from_id(vm->priv->host_id, get_host_href(vm));
184
+ +}
185
+ diff --git a/govirt/ovirt-vm.h b/govirt/ovirt-vm.h
186
+ index 1e6c7ad..e230ebb 100644
187
+ --- a/govirt/ovirt-vm.h
188
+ +++ b/govirt/ovirt-vm.h
189
+ @@ -120,6 +120,7 @@ gboolean ovirt_vm_refresh_finish(OvirtVm *vm,
190
+ GError **err);
191
+
192
+ OvirtCollection *ovirt_vm_get_cdroms(OvirtVm *vm);
193
+ +OvirtHost *ovirt_vm_get_host(OvirtVm *vm);
194
+
195
+ G_END_DECLS
196
+
SOURCES/0023-vm-Introduce-ovirt_vm_get_cluster.patch ADDED
@@ -0,0 +1,177 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Thu, 13 Jul 2017 18:03:11 -0300
4
+ Subject: [PATCH] vm: Introduce ovirt_vm_get_cluster()
5
+
6
+ Similar to previous commit, this new function can be used to retrieve
7
+ the cluster the virtual machine belongs to.
8
+
9
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
10
+ ---
11
+ govirt/govirt.sym | 1 +
12
+ govirt/ovirt-vm.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++
13
+ govirt/ovirt-vm.h | 1 +
14
+ 3 files changed, 76 insertions(+)
15
+
16
+ diff --git a/govirt/govirt.sym b/govirt/govirt.sym
17
+ index 039c88b..bbfbd79 100644
18
+ --- a/govirt/govirt.sym
19
+ +++ b/govirt/govirt.sym
20
+ @@ -135,6 +135,7 @@ GOVIRT_0.3.2 {
21
+ ovirt_host_new;
22
+
23
+ ovirt_vm_get_host;
24
+ + ovirt_vm_get_cluster;
25
+ } GOVIRT_0.3.1;
26
+
27
+ GOVIRT_0.3.4 {
28
+ diff --git a/govirt/ovirt-vm.c b/govirt/ovirt-vm.c
29
+ index 6016c77..70b6f3a 100644
30
+ --- a/govirt/ovirt-vm.c
31
+ +++ b/govirt/ovirt-vm.c
32
+ @@ -44,6 +44,8 @@ struct _OvirtVmPrivate {
33
+ OvirtVmDisplay *display;
34
+ gchar *host_href;
35
+ gchar *host_id;
36
+ + gchar *cluster_href;
37
+ + gchar *cluster_id;
38
+ } ;
39
+ G_DEFINE_TYPE(OvirtVm, ovirt_vm, OVIRT_TYPE_RESOURCE);
40
+
41
+ @@ -61,6 +63,8 @@ enum {
42
+ PROP_DISPLAY,
43
+ PROP_HOST_HREF,
44
+ PROP_HOST_ID,
45
+ + PROP_CLUSTER_HREF,
46
+ + PROP_CLUSTER_ID,
47
+ };
48
+
49
+ static char *ensure_href_from_id(const char *id,
50
+ @@ -80,6 +84,14 @@ static const char *get_host_href(OvirtVm *vm)
51
+ return vm->priv->host_href;
52
+ }
53
+
54
+ +static const char *get_cluster_href(OvirtVm *vm)
55
+ +{
56
+ + if (vm->priv->cluster_href == NULL)
57
+ + vm->priv->cluster_href = ensure_href_from_id(vm->priv->cluster_id, "/ovirt-engine/api/clusters");
58
+ +
59
+ + return vm->priv->cluster_href;
60
+ +}
61
+ +
62
+ static void ovirt_vm_get_property(GObject *object,
63
+ guint prop_id,
64
+ GValue *value,
65
+ @@ -100,6 +112,12 @@ static void ovirt_vm_get_property(GObject *object,
66
+ case PROP_HOST_ID:
67
+ g_value_set_string(value, vm->priv->host_id);
68
+ break;
69
+ + case PROP_CLUSTER_HREF:
70
+ + g_value_set_string(value, get_cluster_href(vm));
71
+ + break;
72
+ + case PROP_CLUSTER_ID:
73
+ + g_value_set_string(value, vm->priv->cluster_id);
74
+ + break;
75
+ default:
76
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
77
+ }
78
+ @@ -129,6 +147,14 @@ static void ovirt_vm_set_property(GObject *object,
79
+ g_free(vm->priv->host_id);
80
+ vm->priv->host_id = g_value_dup_string(value);
81
+ break;
82
+ + case PROP_CLUSTER_HREF:
83
+ + g_free(vm->priv->cluster_href);
84
+ + vm->priv->cluster_href = g_value_dup_string(value);
85
+ + break;
86
+ + case PROP_CLUSTER_ID:
87
+ + g_free(vm->priv->cluster_id);
88
+ + vm->priv->cluster_id = g_value_dup_string(value);
89
+ + break;
90
+ default:
91
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
92
+ }
93
+ @@ -143,6 +169,8 @@ static void ovirt_vm_dispose(GObject *object)
94
+ g_clear_object(&vm->priv->display);
95
+ g_clear_pointer(&vm->priv->host_href, g_free);
96
+ g_clear_pointer(&vm->priv->host_id, g_free);
97
+ + g_clear_pointer(&vm->priv->cluster_href, g_free);
98
+ + g_clear_pointer(&vm->priv->cluster_id, g_free);
99
+
100
+ G_OBJECT_CLASS(ovirt_vm_parent_class)->dispose(object);
101
+ }
102
+ @@ -165,6 +193,16 @@ static gboolean ovirt_vm_init_from_xml(OvirtResource *resource,
103
+ .xml_path = "host",
104
+ .xml_attr = "id",
105
+ },
106
+ + { .prop_name = "cluster-href",
107
+ + .type = G_TYPE_STRING,
108
+ + .xml_path = "cluster",
109
+ + .xml_attr = "href",
110
+ + },
111
+ + { .prop_name = "cluster-id",
112
+ + .type = G_TYPE_STRING,
113
+ + .xml_path = "cluster",
114
+ + .xml_attr = "id",
115
+ + },
116
+ { NULL, },
117
+ };
118
+
119
+ @@ -226,6 +264,22 @@ static void ovirt_vm_class_init(OvirtVmClass *klass)
120
+ NULL,
121
+ G_PARAM_READWRITE |
122
+ G_PARAM_STATIC_STRINGS));
123
+ + g_object_class_install_property(object_class,
124
+ + PROP_CLUSTER_HREF,
125
+ + g_param_spec_string("cluster-href",
126
+ + "Cluster href",
127
+ + "Cluster href for the Virtual Machine",
128
+ + NULL,
129
+ + G_PARAM_READWRITE |
130
+ + G_PARAM_STATIC_STRINGS));
131
+ + g_object_class_install_property(object_class,
132
+ + PROP_CLUSTER_ID,
133
+ + g_param_spec_string("cluster-id",
134
+ + "Cluster Id",
135
+ + "Cluster Id for the Virtual Machine",
136
+ + NULL,
137
+ + G_PARAM_READWRITE |
138
+ + G_PARAM_STATIC_STRINGS));
139
+ }
140
+
141
+ static void ovirt_vm_init(G_GNUC_UNUSED OvirtVm *vm)
142
+ @@ -432,3 +486,23 @@ OvirtHost *ovirt_vm_get_host(OvirtVm *vm)
143
+ g_return_val_if_fail(vm->priv->host_id != NULL, NULL);
144
+ return ovirt_host_new_from_id(vm->priv->host_id, get_host_href(vm));
145
+ }
146
+ +
147
+ +
148
+ +/**
149
+ + * ovirt_vm_get_cluster:
150
+ + * @vm: a #OvirtVm
151
+ + *
152
+ + * Gets a #OvirtCluster representing the cluster the virtual machine belongs
153
+ + * to. This method does not initiate any network activity, the remote host must
154
+ + * be then be fetched using ovirt_resource_refresh() or
155
+ + * ovirt_resource_refresh_async().
156
+ + *
157
+ + * Return value: (transfer full): a #OvirtCluster representing cluster the @vm
158
+ + * belongs to.
159
+ + */
160
+ +OvirtCluster *ovirt_vm_get_cluster(OvirtVm *vm)
161
+ +{
162
+ + g_return_val_if_fail(OVIRT_IS_VM(vm), NULL);
163
+ + g_return_val_if_fail(vm->priv->cluster_id != NULL, NULL);
164
+ + return ovirt_cluster_new_from_id(vm->priv->cluster_id, get_cluster_href(vm));
165
+ +}
166
+ diff --git a/govirt/ovirt-vm.h b/govirt/ovirt-vm.h
167
+ index e230ebb..bef4289 100644
168
+ --- a/govirt/ovirt-vm.h
169
+ +++ b/govirt/ovirt-vm.h
170
+ @@ -121,6 +121,7 @@ gboolean ovirt_vm_refresh_finish(OvirtVm *vm,
171
+
172
+ OvirtCollection *ovirt_vm_get_cdroms(OvirtVm *vm);
173
+ OvirtHost *ovirt_vm_get_host(OvirtVm *vm);
174
+ +OvirtCluster *ovirt_vm_get_cluster(OvirtVm *vm);
175
+
176
+ G_END_DECLS
177
+
SOURCES/0024-host-Introduce-ovirt_host_get_cluster.patch ADDED
@@ -0,0 +1,96 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Thu, 13 Jul 2017 17:44:13 -0300
4
+ Subject: [PATCH] host: Introduce ovirt_host_get_cluster()
5
+
6
+ Following the same principle as previous commits, this functions can be
7
+ used to retrieve the cluster that includes this host.
8
+
9
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
10
+ ---
11
+ govirt/govirt.sym | 1 +
12
+ govirt/ovirt-host.c | 35 ++++++++++++++++++++++++++++++++++-
13
+ govirt/ovirt-host.h | 1 +
14
+ 3 files changed, 36 insertions(+), 1 deletion(-)
15
+
16
+ diff --git a/govirt/govirt.sym b/govirt/govirt.sym
17
+ index bbfbd79..243ce0b 100644
18
+ --- a/govirt/govirt.sym
19
+ +++ b/govirt/govirt.sym
20
+ @@ -130,6 +130,7 @@ GOVIRT_0.3.2 {
21
+ ovirt_data_center_get_type;
22
+ ovirt_data_center_new;
23
+
24
+ + ovirt_host_get_cluster;
25
+ ovirt_host_get_type;
26
+ ovirt_host_get_vms;
27
+ ovirt_host_new;
28
+ diff --git a/govirt/ovirt-host.c b/govirt/ovirt-host.c
29
+ index 2df2a64..191b360 100644
30
+ --- a/govirt/ovirt-host.c
31
+ +++ b/govirt/ovirt-host.c
32
+ @@ -42,6 +42,19 @@ enum {
33
+ PROP_CLUSTER_ID,
34
+ };
35
+
36
+ +
37
+ +static const char *get_cluster_href(OvirtHost *host)
38
+ +{
39
+ + if (host->priv->cluster_href == NULL &&
40
+ + host->priv->cluster_id != NULL) {
41
+ + host->priv->cluster_href = g_strdup_printf("%s/%s",
42
+ + "/ovirt-engine/api/clusters",
43
+ + host->priv->cluster_id);
44
+ + }
45
+ +
46
+ + return host->priv->cluster_href;
47
+ +}
48
+ +
49
+ static void ovirt_host_get_property(GObject *object,
50
+ guint prop_id,
51
+ GValue *value,
52
+ @@ -51,7 +64,7 @@ static void ovirt_host_get_property(GObject *object,
53
+
54
+ switch (prop_id) {
55
+ case PROP_CLUSTER_HREF:
56
+ - g_value_set_string(value, host->priv->cluster_href);
57
+ + g_value_set_string(value, get_cluster_href(host));
58
+ break;
59
+ case PROP_CLUSTER_ID:
60
+ g_value_set_string(value, host->priv->cluster_id);
61
+ @@ -212,3 +225,23 @@ OvirtCollection *ovirt_host_get_vms(OvirtHost *host)
62
+
63
+ return host->priv->vms;
64
+ }
65
+ +
66
+ +
67
+ +/**
68
+ + * ovirt_host_get_cluster:
69
+ + * @host: a #OvirtHost
70
+ + *
71
+ + * Gets a #OvirtCluster representing the cluster the host belongs
72
+ + * to. This method does not initiate any network activity, the remote host must
73
+ + * be then be fetched using ovirt_resource_refresh() or
74
+ + * ovirt_resource_refresh_async().
75
+ + *
76
+ + * Return value: (transfer full): a #OvirtCluster representing cluster the @host
77
+ + * belongs to.
78
+ + */
79
+ +OvirtCluster *ovirt_host_get_cluster(OvirtHost *host)
80
+ +{
81
+ + g_return_val_if_fail(OVIRT_IS_HOST(host), NULL);
82
+ + g_return_val_if_fail(host->priv->cluster_id != NULL, NULL);
83
+ + return ovirt_cluster_new_from_id(host->priv->cluster_id, get_cluster_href(host));
84
+ +}
85
+ diff --git a/govirt/ovirt-host.h b/govirt/ovirt-host.h
86
+ index 91441f6..cdf702c 100644
87
+ --- a/govirt/ovirt-host.h
88
+ +++ b/govirt/ovirt-host.h
89
+ @@ -60,6 +60,7 @@ GType ovirt_host_get_type(void);
90
+
91
+ OvirtHost *ovirt_host_new(void);
92
+ OvirtCollection *ovirt_host_get_vms(OvirtHost *host);
93
+ +OvirtCluster *ovirt_host_get_cluster(OvirtHost *host);
94
+
95
+ G_END_DECLS
96
+
SOURCES/0025-cluster-Introduce-ovirt_cluster_get_data_center.patch ADDED
@@ -0,0 +1,94 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Thu, 13 Jul 2017 17:49:36 -0300
4
+ Subject: [PATCH] cluster: Introduce ovirt_cluster_get_data_center()
5
+
6
+ This function can be used to retrieve the data center associated with
7
+ the cluster.
8
+
9
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
10
+ ---
11
+ govirt/govirt.sym | 1 +
12
+ govirt/ovirt-cluster.c | 33 ++++++++++++++++++++++++++++++++-
13
+ govirt/ovirt-cluster.h | 1 +
14
+ 3 files changed, 34 insertions(+), 1 deletion(-)
15
+
16
+ diff --git a/govirt/govirt.sym b/govirt/govirt.sym
17
+ index 243ce0b..9806033 100644
18
+ --- a/govirt/govirt.sym
19
+ +++ b/govirt/govirt.sym
20
+ @@ -121,6 +121,7 @@ GOVIRT_0.3.2 {
21
+ ovirt_api_search_vms;
22
+ ovirt_api_search_vm_pools;
23
+
24
+ + ovirt_cluster_get_data_center;
25
+ ovirt_cluster_get_type;
26
+ ovirt_cluster_get_hosts;
27
+ ovirt_cluster_new;
28
+ diff --git a/govirt/ovirt-cluster.c b/govirt/ovirt-cluster.c
29
+ index 83b0fa1..4aaf6b1 100644
30
+ --- a/govirt/ovirt-cluster.c
31
+ +++ b/govirt/ovirt-cluster.c
32
+ @@ -42,6 +42,18 @@ enum {
33
+ PROP_DATA_CENTER_ID,
34
+ };
35
+
36
+ +static const char *get_data_center_href(OvirtCluster *cluster)
37
+ +{
38
+ + if (cluster->priv->data_center_href == NULL &&
39
+ + cluster->priv->data_center_id != NULL) {
40
+ + cluster->priv->data_center_href = g_strdup_printf("%s/%s",
41
+ + "/ovirt-engine/api/data_centers",
42
+ + cluster->priv->data_center_id);
43
+ + }
44
+ +
45
+ + return cluster->priv->data_center_href;
46
+ +}
47
+ +
48
+ static void ovirt_cluster_get_property(GObject *object,
49
+ guint prop_id,
50
+ GValue *value,
51
+ @@ -51,7 +63,7 @@ static void ovirt_cluster_get_property(GObject *object,
52
+
53
+ switch (prop_id) {
54
+ case PROP_DATA_CENTER_HREF:
55
+ - g_value_set_string(value, cluster->priv->data_center_href);
56
+ + g_value_set_string(value, get_data_center_href(cluster));
57
+ break;
58
+ case PROP_DATA_CENTER_ID:
59
+ g_value_set_string(value, cluster->priv->data_center_id);
60
+ @@ -213,3 +225,22 @@ OvirtCollection *ovirt_cluster_get_hosts(OvirtCluster *cluster)
61
+ return cluster->priv->hosts;
62
+ }
63
+
64
+ +
65
+ +/**
66
+ + * ovirt_cluster_get_data_center:
67
+ + * @cluster: a #OvirtCluster
68
+ + *
69
+ + * Gets a #OvirtCluster representing the data center the cluster belongs
70
+ + * to. This method does not initiate any network activity, the remote data center must
71
+ + * be then be fetched using ovirt_resource_refresh() or
72
+ + * ovirt_resource_refresh_async().
73
+ + *
74
+ + * Return value: (transfer full): a #OvirtDataCenter representing data center
75
+ + * the @host belongs to.
76
+ + */
77
+ +OvirtDataCenter *ovirt_cluster_get_data_center(OvirtCluster *cluster)
78
+ +{
79
+ + g_return_val_if_fail(OVIRT_IS_CLUSTER(cluster), NULL);
80
+ + g_return_val_if_fail(cluster->priv->data_center_id != NULL, NULL);
81
+ + return ovirt_data_center_new_from_id(cluster->priv->data_center_id, get_data_center_href(cluster));
82
+ +}
83
+ diff --git a/govirt/ovirt-cluster.h b/govirt/ovirt-cluster.h
84
+ index 9505e8c..cdd54b7 100644
85
+ --- a/govirt/ovirt-cluster.h
86
+ +++ b/govirt/ovirt-cluster.h
87
+ @@ -60,6 +60,7 @@ GType ovirt_cluster_get_type(void);
88
+
89
+ OvirtCluster *ovirt_cluster_new(void);
90
+ OvirtCollection *ovirt_cluster_get_hosts(OvirtCluster *cluster);
91
+ +OvirtDataCenter *ovirt_cluster_get_data_center(OvirtCluster *cluster);
92
+
93
+ G_END_DECLS
94
+
SOURCES/0026-storage-domain-Retrieve-data-center-ids.patch ADDED
@@ -0,0 +1,93 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Thu, 13 Apr 2017 15:26:41 -0300
4
+ Subject: [PATCH] storage-domain: Retrieve data center ids
5
+
6
+ Storage domains can be part of one or more data centers, so we use a
7
+ GStrv to store each id.
8
+
9
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
10
+ ---
11
+ govirt/ovirt-storage-domain.c | 27 ++++++++++++++++++++++++++-
12
+ 1 file changed, 26 insertions(+), 1 deletion(-)
13
+
14
+ diff --git a/govirt/ovirt-storage-domain.c b/govirt/ovirt-storage-domain.c
15
+ index e255565..718c1d2 100644
16
+ --- a/govirt/ovirt-storage-domain.c
17
+ +++ b/govirt/ovirt-storage-domain.c
18
+ @@ -30,6 +30,7 @@
19
+
20
+ struct _OvirtStorageDomainPrivate {
21
+ OvirtCollection *files;
22
+ + GStrv data_center_ids;
23
+
24
+ OvirtStorageDomainType type;
25
+ gboolean is_master;
26
+ @@ -50,7 +51,8 @@ enum {
27
+ PROP_USED,
28
+ PROP_COMMITTED,
29
+ PROP_VERSION,
30
+ - PROP_STATE
31
+ + PROP_STATE,
32
+ + PROP_DATA_CENTER_IDS,
33
+ };
34
+
35
+ static void ovirt_storage_domain_get_property(GObject *object,
36
+ @@ -82,6 +84,9 @@ static void ovirt_storage_domain_get_property(GObject *object,
37
+ case PROP_STATE:
38
+ g_value_set_enum(value, domain->priv->state);
39
+ break;
40
+ + case PROP_DATA_CENTER_IDS:
41
+ + g_value_set_boxed(value, domain->priv->data_center_ids);
42
+ + break;
43
+ default:
44
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
45
+ break;
46
+ @@ -117,6 +122,10 @@ static void ovirt_storage_domain_set_property(GObject *object,
47
+ case PROP_STATE:
48
+ domain->priv->state = g_value_get_enum(value);
49
+ break;
50
+ + case PROP_DATA_CENTER_IDS:
51
+ + g_strfreev(domain->priv->data_center_ids);
52
+ + domain->priv->data_center_ids = g_value_dup_boxed(value);
53
+ + break;
54
+ default:
55
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
56
+ break;
57
+ @@ -130,6 +139,7 @@ ovirt_storage_domain_dispose(GObject *obj)
58
+ OvirtStorageDomain *domain = OVIRT_STORAGE_DOMAIN(obj);
59
+
60
+ g_clear_object(&domain->priv->files);
61
+ + g_clear_pointer(&domain->priv->data_center_ids, g_strfreev);
62
+
63
+ G_OBJECT_CLASS(ovirt_storage_domain_parent_class)->dispose(obj);
64
+ }
65
+ @@ -170,6 +180,11 @@ static gboolean ovirt_storage_domain_init_from_xml(OvirtResource *resource,
66
+ .type = OVIRT_TYPE_STORAGE_DOMAIN_STATE,
67
+ .xml_path = "status/state",
68
+ },
69
+ + { .prop_name = "data-center-ids",
70
+ + .type = G_TYPE_STRV,
71
+ + .xml_path = "data_centers",
72
+ + .xml_attr = "id",
73
+ + },
74
+ { NULL , }
75
+ };
76
+
77
+ @@ -274,6 +289,16 @@ static void ovirt_storage_domain_class_init(OvirtStorageDomainClass *klass)
78
+ g_object_class_install_property(object_class,
79
+ PROP_STATE,
80
+ param_spec);
81
+ +
82
+ + param_spec = g_param_spec_boxed("data-center-ids",
83
+ + "Data Center Ids",
84
+ + "Ids of Data Centers for this Storage Domain",
85
+ + G_TYPE_STRV,
86
+ + G_PARAM_READWRITE |
87
+ + G_PARAM_STATIC_STRINGS);
88
+ + g_object_class_install_property(object_class,
89
+ + PROP_DATA_CENTER_IDS,
90
+ + param_spec);
91
+ }
92
+
93
+ static void ovirt_storage_domain_init(OvirtStorageDomain *domain)
SOURCES/0027-Add-missing-include-in-govirt.h.patch ADDED
@@ -0,0 +1,26 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Thu, 3 Aug 2017 16:53:09 -0300
4
+ Subject: [PATCH] Add missing #include in govirt.h
5
+
6
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
7
+ ---
8
+ govirt/govirt.h | 3 +++
9
+ 1 file changed, 3 insertions(+)
10
+
11
+ diff --git a/govirt/govirt.h b/govirt/govirt.h
12
+ index fb7756f..9c92318 100644
13
+ --- a/govirt/govirt.h
14
+ +++ b/govirt/govirt.h
15
+ @@ -25,8 +25,11 @@
16
+ #include <govirt/ovirt-enum-types.h>
17
+ #include <govirt/ovirt-api.h>
18
+ #include <govirt/ovirt-cdrom.h>
19
+ +#include <govirt/ovirt-cluster.h>
20
+ #include <govirt/ovirt-collection.h>
21
+ +#include <govirt/ovirt-data-center.h>
22
+ #include <govirt/ovirt-error.h>
23
+ +#include <govirt/ovirt-host.h>
24
+ #include <govirt/ovirt-options.h>
25
+ #include <govirt/ovirt-proxy.h>
26
+ #include <govirt/ovirt-resource.h>
SOURCES/0028-resource-Fix-ovirt_resource_rest_call_sync-return-va.patch ADDED
@@ -0,0 +1,25 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: Christophe Fergeau <cfergeau@redhat.com>
3
+ Date: Tue, 25 Jul 2017 17:34:31 +0200
4
+ Subject: [PATCH] resource: Fix ovirt_resource_rest_call_sync return value
5
+
6
+ Upon success, ovirt_resource_rest_call_sync() was always returning
7
+ NULL, which is not what is expected. This, among other things, made
8
+ ovirt_resource_refresh() non-functional.
9
+ ---
10
+ govirt/ovirt-resource.c | 2 +-
11
+ 1 file changed, 1 insertion(+), 1 deletion(-)
12
+
13
+ diff --git a/govirt/ovirt-resource.c b/govirt/ovirt-resource.c
14
+ index 1413a77..0c750ac 100644
15
+ --- a/govirt/ovirt-resource.c
16
+ +++ b/govirt/ovirt-resource.c
17
+ @@ -499,7 +499,7 @@ G_GNUC_INTERNAL RestXmlNode *ovirt_resource_rest_call_sync(OvirtRestCall *call,
18
+ return NULL;
19
+ }
20
+
21
+ - return root;
22
+ + return ovirt_rest_xml_node_from_call(REST_PROXY_CALL(call));
23
+ }
24
+
25
+
SOURCES/0029-resource-Fix-ovirt_resource_rest_call_sync-crash-on-.patch ADDED
@@ -0,0 +1,39 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: Christophe Fergeau <cfergeau@redhat.com>
3
+ Date: Tue, 25 Jul 2017 17:36:05 +0200
4
+ Subject: [PATCH] resource: Fix ovirt_resource_rest_call_sync() crash on 404
5
+
6
+ When the REST call fails, we do not always get an XML answer from oVirt
7
+ describing the failure in more details. In particular, this is the case
8
+ when we hit a 404. In such situations, we'd be crashing because we'd
9
+ attempt to dereference a NULL pointer.
10
+ ---
11
+ govirt/ovirt-resource.c | 9 +++++----
12
+ 1 file changed, 5 insertions(+), 4 deletions(-)
13
+
14
+ diff --git a/govirt/ovirt-resource.c b/govirt/ovirt-resource.c
15
+ index 0c750ac..0f4a129 100644
16
+ --- a/govirt/ovirt-resource.c
17
+ +++ b/govirt/ovirt-resource.c
18
+ @@ -485,16 +485,17 @@ G_GNUC_INTERNAL RestXmlNode *ovirt_resource_rest_call_sync(OvirtRestCall *call,
19
+ GError *local_error = NULL;
20
+
21
+ root = ovirt_rest_xml_node_from_call(REST_PROXY_CALL(call));
22
+ - ovirt_utils_gerror_from_xml_fault(root, &local_error);
23
+ + if (root != NULL) {
24
+ + ovirt_utils_gerror_from_xml_fault(root, &local_error);
25
+ + rest_xml_node_unref(root);
26
+ + }
27
+ if (local_error != NULL) {
28
+ g_clear_error(error);
29
+ g_warning("Error while updating resource");
30
+ g_warning("message: %s", local_error->message);
31
+ g_propagate_error(error, local_error);
32
+ }
33
+ - if (root != NULL) {
34
+ - rest_xml_node_unref(root);
35
+ - }
36
+ + g_warn_if_fail(error == NULL || *error != NULL);
37
+
38
+ return NULL;
39
+ }
SOURCES/0030-resource-Fix-ovirt_resource_init_from_xml_real-preco.patch ADDED
@@ -0,0 +1,29 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: Christophe Fergeau <cfergeau@redhat.com>
3
+ Date: Mon, 11 Sep 2017 15:01:59 +0200
4
+ Subject: [PATCH] resource: Fix ovirt_resource_init_from_xml_real precondition
5
+
6
+ When ovirt_resource_init_from_xml_real is called, the current value of
7
+ OvirtResource::xml-node is not very relevant, what matters is whether
8
+ the passed in xml node is NULL or not.
9
+
10
+ This updates the test-govirt test case to call
11
+ ovirt_resource_refresh(ovirt_vm_get_cluster()) as this triggers this
12
+ precondition failure.
13
+ ---
14
+ govirt/ovirt-resource.c | 2 +-
15
+ 1 file changed, 1 insertion(+), 1 deletion(-)
16
+
17
+ diff --git a/govirt/ovirt-resource.c b/govirt/ovirt-resource.c
18
+ index 0f4a129..ad5e8ca 100644
19
+ --- a/govirt/ovirt-resource.c
20
+ +++ b/govirt/ovirt-resource.c
21
+ @@ -422,7 +422,7 @@ static gboolean ovirt_resource_init_from_xml_real(OvirtResource *resource,
22
+ */
23
+ is_api = OVIRT_IS_API(resource);
24
+
25
+ - g_return_val_if_fail(resource->priv->xml != NULL, FALSE);
26
+ + g_return_val_if_fail(node != NULL, FALSE);
27
+
28
+ guid = rest_xml_node_get_attr(node, "id");
29
+ if ((guid == NULL) && !is_api) {
SOURCES/0031-resource-Update-xml-node-in-ovirt_resource_init_from.patch ADDED
@@ -0,0 +1,61 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: Christophe Fergeau <cfergeau@redhat.com>
3
+ Date: Mon, 11 Sep 2017 14:59:08 +0200
4
+ Subject: [PATCH] resource: Update xml node in
5
+ ovirt_resource_init_from_xml_real
6
+
7
+ ovirt_resource_init_from_xml_real is called indirectly when
8
+ ovirt_resource_refresh() is used. For some reason, it updates
9
+ the various OvirtResource properties with the new XML node content, but
10
+ OvirtResource::xml-node is not set to be the new node.
11
+ This commit fixes this inconsistent state by making sure
12
+ OvirtResource::xml-node is changed to point to the new node.
13
+ ---
14
+ govirt/ovirt-resource.c | 19 +++++++++++++------
15
+ 1 file changed, 13 insertions(+), 6 deletions(-)
16
+
17
+ diff --git a/govirt/ovirt-resource.c b/govirt/ovirt-resource.c
18
+ index ad5e8ca..1984b1d 100644
19
+ --- a/govirt/ovirt-resource.c
20
+ +++ b/govirt/ovirt-resource.c
21
+ @@ -97,6 +97,15 @@ static void ovirt_resource_get_property(GObject *object,
22
+ }
23
+ }
24
+
25
+ +static void ovirt_resource_set_xml_node(OvirtResource *resource,
26
+ + RestXmlNode *node)
27
+ +{
28
+ + g_clear_pointer(&resource->priv->xml, &rest_xml_node_unref);
29
+ + if (node != NULL) {
30
+ + resource->priv->xml = rest_xml_node_ref(node);
31
+ + }
32
+ +}
33
+ +
34
+ static void ovirt_resource_set_property(GObject *object,
35
+ guint prop_id,
36
+ const GValue *value,
37
+ @@ -121,13 +130,10 @@ static void ovirt_resource_set_property(GObject *object,
38
+ g_free(resource->priv->description);
39
+ resource->priv->description = g_value_dup_string(value);
40
+ break;
41
+ - case PROP_XML_NODE: {
42
+ - if (resource->priv->xml != NULL) {
43
+ - g_boxed_free(REST_TYPE_XML_NODE, resource->priv->xml);
44
+ - }
45
+ - resource->priv->xml = g_value_dup_boxed(value);
46
+ + case PROP_XML_NODE:
47
+ + ovirt_resource_set_xml_node(OVIRT_RESOURCE(object),
48
+ + g_value_get_boxed(value));
49
+ break;
50
+ - }
51
+ default:
52
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
53
+ }
54
+ @@ -438,6 +444,7 @@ static gboolean ovirt_resource_init_from_xml_real(OvirtResource *resource,
55
+ return FALSE;
56
+ }
57
+
58
+ + ovirt_resource_set_xml_node(resource, node);
59
+ g_object_set(G_OBJECT(resource), "guid", guid, "href", href, NULL);
60
+
61
+ ovirt_resource_set_name_from_xml(resource, node);
SOURCES/0032-utils-Drop-type-member-from-OvirtXmlElement-struct.patch ADDED
@@ -0,0 +1,151 @@
1
+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
+ From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
3
+ Date: Thu, 18 May 2017 17:21:10 -0300
4
+ Subject: [PATCH] utils: Drop 'type' member from OvirtXmlElement struct
5
+
6
+ Instead of passing the type, it is possible to get it using by calling
7
+ g_object_class_find_property(). All users have been updated accordingly.
8
+
9
+ Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
10
+ ---
11
+ govirt/ovirt-cluster.c | 2 --
12
+ govirt/ovirt-host.c | 2 --
13
+ govirt/ovirt-storage-domain.c | 8 --------
14
+ govirt/ovirt-utils.c | 8 ++++++--
15
+ govirt/ovirt-utils.h | 1 -
16
+ govirt/ovirt-vm.c | 4 ----
17
+ 6 files changed, 6 insertions(+), 19 deletions(-)
18
+
19
+ diff --git a/govirt/ovirt-cluster.c b/govirt/ovirt-cluster.c
20
+ index 4aaf6b1..ae25d63 100644
21
+ --- a/govirt/ovirt-cluster.c
22
+ +++ b/govirt/ovirt-cluster.c
23
+ @@ -115,12 +115,10 @@ static gboolean ovirt_cluster_init_from_xml(OvirtResource *resource,
24
+ OvirtResourceClass *parent_class;
25
+ OvirtXmlElement cluster_elements[] = {
26
+ { .prop_name = "data-center-href",
27
+ - .type = G_TYPE_STRING,
28
+ .xml_path = "data_center",
29
+ .xml_attr = "href",
30
+ },
31
+ { .prop_name = "data-center-id",
32
+ - .type = G_TYPE_STRING,
33
+ .xml_path = "data_center",
34
+ .xml_attr = "id",
35
+ },
36
+ diff --git a/govirt/ovirt-host.c b/govirt/ovirt-host.c
37
+ index 191b360..1570cba 100644
38
+ --- a/govirt/ovirt-host.c
39
+ +++ b/govirt/ovirt-host.c
40
+ @@ -116,12 +116,10 @@ static gboolean ovirt_host_init_from_xml(OvirtResource *resource,
41
+ OvirtResourceClass *parent_class;
42
+ OvirtXmlElement host_elements[] = {
43
+ { .prop_name = "cluster-href",
44
+ - .type = G_TYPE_STRING,
45
+ .xml_path = "cluster",
46
+ .xml_attr = "href",
47
+ },
48
+ { .prop_name = "cluster-id",
49
+ - .type = G_TYPE_STRING,
50
+ .xml_path = "cluster",
51
+ .xml_attr = "id",
52
+ },
53
+ diff --git a/govirt/ovirt-storage-domain.c b/govirt/ovirt-storage-domain.c
54
+ index 718c1d2..a9078f4 100644
55
+ --- a/govirt/ovirt-storage-domain.c
56
+ +++ b/govirt/ovirt-storage-domain.c
57
+ @@ -153,35 +153,27 @@ static gboolean ovirt_storage_domain_init_from_xml(OvirtResource *resource,
58
+ OvirtResourceClass *parent_class;
59
+ OvirtXmlElement storage_domain_elements[] = {
60
+ { .prop_name = "type",
61
+ - .type = OVIRT_TYPE_STORAGE_DOMAIN_TYPE,
62
+ .xml_path = "type",
63
+ },
64
+ { .prop_name = "master",
65
+ - .type = G_TYPE_BOOLEAN,
66
+ .xml_path = "master",
67
+ },
68
+ { .prop_name = "available",
69
+ - .type = G_TYPE_UINT64,
70
+ .xml_path = "available",
71
+ },
72
+ { .prop_name = "used",
73
+ - .type = G_TYPE_UINT64,
74
+ .xml_path = "used",
75
+ },
76
+ { .prop_name = "committed",
77
+ - .type = G_TYPE_UINT64,
78
+ .xml_path = "committed",
79
+ },
80
+ { .prop_name = "version",
81
+ - .type = OVIRT_TYPE_STORAGE_DOMAIN_FORMAT_VERSION,
82
+ .xml_path = "storage_format",
83
+ },
84
+ { .prop_name = "state",
85
+ - .type = OVIRT_TYPE_STORAGE_DOMAIN_STATE,
86
+ .xml_path = "status/state",
87
+ },
88
+ { .prop_name = "data-center-ids",
89
+ - .type = G_TYPE_STRV,
90
+ .xml_path = "data_centers",
91
+ .xml_attr = "id",
92
+ },
93
+ diff --git a/govirt/ovirt-utils.c b/govirt/ovirt-utils.c
94
+ index 1898862..501acb9 100644
95
+ --- a/govirt/ovirt-utils.c
96
+ +++ b/govirt/ovirt-utils.c
97
+ @@ -207,9 +207,13 @@ ovirt_rest_xml_node_parse(RestXmlNode *node,
98
+
99
+ for (;elements->xml_path != NULL; elements++) {
100
+ GValue value = { 0, };
101
+ + GParamSpec *prop;
102
+
103
+ - g_value_init(&value, elements->type);
104
+ - if (_set_property_value_from_type(&value, elements->type, elements->xml_path, elements->xml_attr, node))
105
+ + prop = g_object_class_find_property(G_OBJECT_GET_CLASS(object), elements->prop_name);
106
+ + g_return_val_if_fail(prop != NULL, FALSE);
107
+ +
108
+ + g_value_init(&value, prop->value_type);
109
+ + if (_set_property_value_from_type(&value, prop->value_type, elements->xml_path, elements->xml_attr, node))
110
+ g_object_set_property(object, elements->prop_name, &value);
111
+ g_value_unset(&value);
112
+ }
113
+ diff --git a/govirt/ovirt-utils.h b/govirt/ovirt-utils.h
114
+ index 545847a..e03f453 100644
115
+ --- a/govirt/ovirt-utils.h
116
+ +++ b/govirt/ovirt-utils.h
117
+ @@ -31,7 +31,6 @@ typedef struct _OvirtXmlElement OvirtXmlElement;
118
+ struct _OvirtXmlElement
119
+ {
120
+ const char *prop_name;
121
+ - GType type;
122
+ const char *xml_path;
123
+ const char *xml_attr; /* if NULL, retrieve node content instead of attribute */
124
+ };
125
+ diff --git a/govirt/ovirt-vm.c b/govirt/ovirt-vm.c
126
+ index 70b6f3a..36ffd35 100644
127
+ --- a/govirt/ovirt-vm.c
128
+ +++ b/govirt/ovirt-vm.c
129
+ @@ -184,22 +184,18 @@ static gboolean ovirt_vm_init_from_xml(OvirtResource *resource,
130
+ OvirtResourceClass *parent_class;
131
+ OvirtXmlElement vm_elements[] = {
132
+ { .prop_name = "host-href",
133
+ - .type = G_TYPE_STRING,
134
+ .xml_path = "host",
135
+ .xml_attr = "href",
136
+ },
137
+ { .prop_name = "host-id",
138
+ - .type = G_TYPE_STRING,
139
+ .xml_path = "host",
140
+ .xml_attr = "id",
141
+ },
142
+ { .prop_name = "cluster-href",
143
+ - .type = G_TYPE_STRING,
144
+ .xml_path = "cluster",
145
+ .xml_attr = "href",
146
+ },
147
+ { .prop_name = "cluster-id",
148
+ - .type = G_TYPE_STRING,
149
+ .xml_path = "cluster",
150
+ .xml_attr = "id",
151
+ },
SOURCES/libgovirt-0.3.4.tar.xz.sign ADDED
@@ -0,0 +1,17 @@
1
+ -----BEGIN PGP SIGNATURE-----
2
+ Version: GnuPG v1
3
+
4
+ iQIcBAABCAAGBQJXDmDvAAoJEKnYwhQprGyCgyYQALXgvc8Yj66gIHZ5xfj+m5b/
5
+ rfz6ZS0q6g5ya+jSNpZjf2oonhuXa9RrfKsuJ9tQdnajbCDygnn3EITSXZyD56tJ
6
+ RCNElJuycGMQADK7ng7dkrCuXNDyZLSI7V3VHw7YKgfU6Wu9meqOWI3N65SAhlIZ
7
+ zSuRpCUhxZVfx02ogopdwZh5nCCExZjAPcCeEUKQvEtWLFSNI4eDlGB3aafYFnmV
8
+ McM7NxLtdsZ9Y3Y6khtoFC7puMZq7Bl7l9ExTdTlZncLOuEVWtKL2zFts82oBPms
9
+ ZTI8AxpK+EK4bIwl1qi5ovdrg5JHEUbeypbCKWj9DVVcTR6aacgXiQTeLBI1x4nk
10
+ JlAxhMKnVQpVffOF1e27Xaa0AHJqHHtz2lYWKvpNWz+jDdqtAU8aspyuL6qG+EpK
11
+ 9cnHBiWou9EEoIYnwMdkZnPtoEI8KWz5ttpPoGbYUKaqlBUwJjr6HLK1U3utYKdT
12
+ lOqy1zPRo88KX0EakZQ4BQaPfecBjQ7prHteFKyxunlEDu3fEHFhLeMKTto3wlWZ
13
+ FZDn3YvWv5iXrRaH2LwojsN82G+oRwf4IUM0uUesNzpgs7E+kYVisWwDLLM8H3Xs
14
+ d5o6KmU90nyAG4rCnV2rNH4/ing2+pYvcNyDcVEzxWXMktlekQqTWyr5LezGXTOK
15
+ coKms31iehaDddKVI4UX
16
+ =Kk6z
17
+ -----END PGP SIGNATURE-----
file added
+219
SPECS/libgovirt.spec ADDED
@@ -0,0 +1,219 @@
1
+ # -*- rpm-spec -*-
2
+
3
+ %global with_gir 0
4
+
5
+ # Default to skipping autoreconf. Distros can change just this one line
6
+ # (or provide a command-line override) if they backport any patches that
7
+ # touch configure.ac or Makefile.am.
8
+
9
+ # Force running autoreconf because data center patches touch Makefile.am.
10
+ # To disable autoreconf, change the value to 0.
11
+ %{!?enable_autotools:%global enable_autotools 1}
12
+
13
+ %if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
14
+ %global with_gir 1
15
+ %endif
16
+
17
+ Summary: A GObject library for interacting with oVirt REST API
18
+ Name: libgovirt
19
+ Version: 0.3.4
20
+ Release: 8%{?dist}%{?extra_release}
21
+ License: LGPLv2+
22
+ Group: Development/Libraries
23
+ Source0: http://ftp.gnome.org/pub/GNOME/sources/libgovirt/0.3/%{name}-%{version}.tar.xz
24
+ Source1: http://ftp.gnome.org/pub/GNOME/sources/libgovirt/0.3/%{name}-%{version}.tar.xz.sign
25
+ Source2: cfergeau-29AC6C82.keyring
26
+ URL: http://people.freedesktop.org/~teuf/govirt/
27
+ Patch01: 0001-proxy-Fix-persistent-session-with-oVirt-3.6.patch
28
+ Patch02: 0002-Force-use-of-v3-REST-API.patch
29
+ Patch03: 0003-New-storage-format-added-in-oVirt-4.1.patch
30
+ Patch04: 0004-proxy-Hold-reference-to-cancellable-object.patch
31
+ Patch05: 0005-proxy-Check-if-operation-is-cancelled-before-disconn.patch
32
+ Patch06: 0006-storage-domain-Factor-out-property-value-setting-fro.patch
33
+ Patch07: 0007-storage-domain-use-explicit-initialization-of-struct.patch
34
+ Patch08: 0008-storage-domain-Move-out-ovirt_resource_parse_xml-to-.patch
35
+ Patch09: 0009-utils-Remove-unused-function-ovirt_rest_xml_node_get.patch
36
+ Patch10: 0010-utils-Rename-ovirt_rest_xml_node_get_content_va-to-o.patch
37
+ Patch11: 0011-utils-Retrieve-node-attributes-in-ovirt_resource_par.patch
38
+ Patch12: 0012-utils-Support-G_TYPE_STRING-in-_set_property_value_f.patch
39
+ Patch13: 0013-utils-Support-G_TYPE_STRV-in-_set_property_value_fro.patch
40
+ Patch14: 0014-Introduce-auxiliary-function-ovirt_sub_collection_ne.patch
41
+ Patch15: 0015-New-API-functions-to-enable-search-queries-of-collec.patch
42
+ Patch16: 0016-Introduce-ovirt_resource_new-functions.patch
43
+ Patch17: 0017-Use-ovirt_resource_new-functions-instead-of-g_initab.patch
44
+ Patch18: 0018-Move-resource-type-definitions-to-ovirt-types.h.patch
45
+ Patch19: 0019-Initial-support-for-hosts.patch
46
+ Patch20: 0020-Initial-support-for-clusters.patch
47
+ Patch21: 0021-Initial-support-for-data-centers.patch
48
+ Patch22: 0022-vm-Introduce-ovirt_vm_get_host.patch
49
+ Patch23: 0023-vm-Introduce-ovirt_vm_get_cluster.patch
50
+ Patch24: 0024-host-Introduce-ovirt_host_get_cluster.patch
51
+ Patch25: 0025-cluster-Introduce-ovirt_cluster_get_data_center.patch
52
+ Patch26: 0026-storage-domain-Retrieve-data-center-ids.patch
53
+ Patch27: 0027-Add-missing-include-in-govirt.h.patch
54
+ Patch28: 0028-resource-Fix-ovirt_resource_rest_call_sync-return-va.patch
55
+ Patch29: 0029-resource-Fix-ovirt_resource_rest_call_sync-crash-on-.patch
56
+ Patch30: 0030-resource-Fix-ovirt_resource_init_from_xml_real-preco.patch
57
+ Patch31: 0031-resource-Update-xml-node-in-ovirt_resource_init_from.patch
58
+ Patch32: 0032-utils-Drop-type-member-from-OvirtXmlElement-struct.patch
59
+
60
+ %if 0%{?enable_autotools}
61
+ BuildRequires: autoconf
62
+ BuildRequires: automake
63
+ BuildRequires: gettext-devel
64
+ BuildRequires: libtool
65
+ %endif
66
+ BuildRequires: git-core
67
+
68
+ BuildRequires: pkgconfig(glib-2.0)
69
+ BuildRequires: intltool
70
+ BuildRequires: rest-devel >= 0.7.92
71
+ %if %{with_gir}
72
+ BuildRequires: gobject-introspection-devel
73
+ %endif
74
+ #needed for make check
75
+ BuildRequires: glib-networking
76
+ BuildRequires: dconf
77
+ #needed for GPG signature checek
78
+ BuildRequires: gnupg2
79
+
80
+ %description
81
+ libgovirt is a library that allows applications to use oVirt REST API
82
+ to list VMs managed by an oVirt instance, and to get the connection
83
+ parameters needed to make a SPICE/VNC connection to them.
84
+
85
+ %package devel
86
+ Summary: Libraries, includes, etc. to compile with the libgovirt library
87
+ Group: Development/Libraries
88
+ Requires: %{name}%{?_isa} = %{version}-%{release}
89
+ Requires: pkgconfig
90
+ Requires: glib2-devel
91
+
92
+ %description devel
93
+ libgovirt is a library that allows applications to use oVirt REST API
94
+ to list VMs managed by an oVirt instance, and to get the connection
95
+ parameters needed to make a SPICE/VNC connection to them.
96
+
97
+ Libraries, includes, etc. to compile with the libgovirt library
98
+
99
+ %prep
100
+ gpgv2 --quiet --keyring %{SOURCE2} %{SOURCE1} %{SOURCE0}
101
+ %autosetup -S git_am
102
+
103
+ %build
104
+ %if 0%{?enable_autotools}
105
+ autoreconf -if
106
+ %endif
107
+
108
+ %if %{with_gir}
109
+ %global gir_arg --enable-introspection=yes
110
+ %else
111
+ %global gir_arg --enable-introspection=no
112
+ %endif
113
+
114
+ %configure %{gir_arg}
115
+ %__make %{?_smp_mflags} V=1
116
+
117
+ %install
118
+ %__make install DESTDIR=%{buildroot}
119
+ rm -f %{buildroot}%{_libdir}/*.a
120
+ rm -f %{buildroot}%{_libdir}/*.la
121
+ %find_lang %{name} --with-gnome
122
+
123
+ %check
124
+ make check
125
+
126
+ %ldconfig_scriptlets
127
+
128
+ %files -f %{name}.lang
129
+ %doc AUTHORS COPYING MAINTAINERS README
130
+ %{_libdir}/%{name}.so.2*
131
+ %if %{with_gir}
132
+ %{_libdir}/girepository-1.0/GoVirt-1.0.typelib
133
+ %endif
134
+
135
+ %files devel
136
+ %{_libdir}/%{name}.so
137
+ %dir %{_includedir}/govirt-1.0/
138
+ %dir %{_includedir}/govirt-1.0/govirt/
139
+ %{_includedir}/govirt-1.0/govirt/*.h
140
+ %{_libdir}/pkgconfig/govirt-1.0.pc
141
+ %if %{with_gir}
142
+ %{_datadir}/gir-1.0/GoVirt-1.0.gir
143
+ %endif
144
+
145
+ %changelog
146
+ * Mon Jun 11 2018 Christophe Fergeau <cfergeau@redhat.com> - 0.3.4-8
147
+ - Sync with the rhel 7.6 package
148
+ Resolves: rhbz#1584506
149
+
150
+ * Fri Feb 09 2018 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 0.3.4-7
151
+ - Escape macros in %%changelog
152
+
153
+ * Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.3.4-6
154
+ - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
155
+
156
+ * Sat Feb 03 2018 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 0.3.4-5
157
+ - Switch to %%ldconfig_scriptlets
158
+
159
+ * Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.3.4-4
160
+ - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
161
+
162
+ * Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.3.4-3
163
+ - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
164
+
165
+ * Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.3.4-2
166
+ - Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
167
+
168
+ * Wed Apr 13 2016 Christophe Fergeau <cfergeau@redhat.com> 0.3.4-1
169
+ - Update to libgovirt 0.3.4
170
+
171
+ * Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.3.3-3
172
+ - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
173
+
174
+ * Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.3.3-2
175
+ - Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
176
+
177
+ * Wed Apr 08 2015 Christophe Fergeau <cfergeau@redhat.com> 0.3.3-1
178
+ - Update to upstream release 0.3.3
179
+
180
+ * Thu Oct 09 2014 Christophe Fergeau <cfergeau@redhat.com> 0.3.2-1
181
+ - Update to upstream release 0.3.2
182
+
183
+ * Wed Sep 03 2014 Christophe Fergeau <cfergeau@redhat.com> 0.3.1-1
184
+ - Update to upstream release 0.3.1
185
+
186
+ * Sun Aug 17 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.3.0-7
187
+ - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
188
+
189
+ * Sat Aug 02 2014 Richard Jones <rjones@redhat.com> - 0.3.0-6
190
+ - Force rebuild for aarch64.
191
+
192
+ * Tue Jul 22 2014 Kalev Lember <kalevlember@gmail.com> - 0.3.0-5
193
+ - Rebuilt for gobject-introspection 1.41.4
194
+
195
+ * Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.3.0-4
196
+ - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
197
+
198
+ * Tue Nov 26 2013 Christophe Fergeau <cfergeau@redhat.com> 0.3.0-3
199
+ - Actually apply Patch0 /o\
200
+
201
+ * Tue Nov 26 2013 Christophe Fergeau <cfergeau@redhat.com> 0.3.0-2
202
+ - Add patch to fix a memory corruption issue when librest does not have the
203
+ RestProxy::ssl-ca-file property (which is currently the case in Fedora)
204
+
205
+ * Sat Aug 03 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.1.0-2
206
+ - Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
207
+
208
+ * Tue Jun 11 2013 Christophe Fergeau <cfergeau@redhat.com> 0.1.0-1
209
+ - Update to upstream release 0.1.0
210
+
211
+ * Mon Mar 11 2013 Christophe Fergeau <cfergeau@redhat.com> 0.0.3-2
212
+ - Removed definition of BuildRoot and cleanup of BuildRoot in %%clean
213
+ - Added missing arch to versioned Requires: %%{name} in the -devel package
214
+ - Don't include empty NEWS and ChangeLog in built RPM
215
+
216
+ * Wed Feb 20 2013 Christophe Fergeau <cfergeau@redhat.com> 0.0.3-1
217
+ - Initial import of libgovirt 0.0.3
218
+
219
+