|
|
eec4b3 |
From bd65db51e463fe84a72ea7849483d21e87c97095 Mon Sep 17 00:00:00 2001
|
|
|
eec4b3 |
From: Christophe Fergeau <cfergeau@redhat.com>
|
|
|
eec4b3 |
Date: Fri, 3 Apr 2015 16:00:45 +0200
|
|
|
eec4b3 |
Subject: [PATCH] ovirt: Add support for an 'admin' key in vv file
|
|
|
eec4b3 |
|
|
|
eec4b3 |
When using a user with administrator rights, the VMs this user can
|
|
|
eec4b3 |
access from the user portal and the admin portal are different, and
|
|
|
eec4b3 |
REST API users must indicate which set of VMs they want through a
|
|
|
eec4b3 |
specific header. libgovirt already has support for that in its API, but
|
|
|
eec4b3 |
virt-viewer was not making use of that API.
|
|
|
eec4b3 |
This commit adds support for an 'admin' field in the [ovirt] section of
|
|
|
eec4b3 |
.vv files so oVirt can indicate remote-viewer whether this header should
|
|
|
eec4b3 |
be set or not.
|
|
|
eec4b3 |
---
|
|
|
eec4b3 |
src/ovirt-foreign-menu.c | 3 +++
|
|
|
eec4b3 |
src/virt-viewer-file.c | 26 ++++++++++++++++++++++++++
|
|
|
eec4b3 |
src/virt-viewer-file.h | 2 ++
|
|
|
eec4b3 |
3 files changed, 31 insertions(+)
|
|
|
eec4b3 |
|
|
|
eec4b3 |
diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
|
|
|
eec4b3 |
index 7c95e4c..9b6d3b8 100644
|
|
|
eec4b3 |
--- a/src/ovirt-foreign-menu.c
|
|
|
eec4b3 |
+++ b/src/ovirt-foreign-menu.c
|
|
|
eec4b3 |
@@ -826,6 +826,7 @@ OvirtForeignMenu *ovirt_foreign_menu_new_from_file(VirtViewerFile *file)
|
|
|
eec4b3 |
{
|
|
|
eec4b3 |
OvirtProxy *proxy = NULL;
|
|
|
eec4b3 |
OvirtForeignMenu *menu = NULL;
|
|
|
eec4b3 |
+ gboolean admin;
|
|
|
eec4b3 |
char *ca_str = NULL;
|
|
|
eec4b3 |
char *jsessionid = NULL;
|
|
|
eec4b3 |
char *url = NULL;
|
|
|
eec4b3 |
@@ -836,6 +837,7 @@ OvirtForeignMenu *ovirt_foreign_menu_new_from_file(VirtViewerFile *file)
|
|
|
eec4b3 |
vm_guid = virt_viewer_file_get_ovirt_vm_guid(file);
|
|
|
eec4b3 |
jsessionid = virt_viewer_file_get_ovirt_jsessionid(file);
|
|
|
eec4b3 |
ca_str = virt_viewer_file_get_ovirt_ca(file);
|
|
|
eec4b3 |
+ admin = virt_viewer_file_get_ovirt_admin(file);
|
|
|
eec4b3 |
|
|
|
eec4b3 |
if ((url == NULL) || (vm_guid == NULL))
|
|
|
eec4b3 |
goto end;
|
|
|
eec4b3 |
@@ -850,6 +852,7 @@ OvirtForeignMenu *ovirt_foreign_menu_new_from_file(VirtViewerFile *file)
|
|
|
eec4b3 |
}
|
|
|
eec4b3 |
|
|
|
eec4b3 |
g_object_set(G_OBJECT(proxy),
|
|
|
eec4b3 |
+ "admin", admin,
|
|
|
eec4b3 |
"session-id", jsessionid,
|
|
|
eec4b3 |
"ca-cert", ca,
|
|
|
eec4b3 |
NULL);
|
|
|
eec4b3 |
diff --git a/src/virt-viewer-file.c b/src/virt-viewer-file.c
|
|
|
eec4b3 |
index c8f04e8..69b6531 100644
|
|
|
eec4b3 |
--- a/src/virt-viewer-file.c
|
|
|
eec4b3 |
+++ b/src/virt-viewer-file.c
|
|
|
eec4b3 |
@@ -76,6 +76,8 @@
|
|
|
eec4b3 |
* - jsessionid: string containing an authentication cookie to be used to
|
|
|
eec4b3 |
* connect to the oVirt engine without being asked for credentials
|
|
|
eec4b3 |
* - ca: string PEM data (use \n to separate the lines)
|
|
|
eec4b3 |
+ * - admin: boolean (0 or 1) indicating whether the VM is visible in the user or
|
|
|
eec4b3 |
+ * admin portal
|
|
|
eec4b3 |
*
|
|
|
eec4b3 |
* (the file can be extended with extra groups or keys, which should
|
|
|
eec4b3 |
* be prefixed with x- to avoid later conflicts)
|
|
|
eec4b3 |
@@ -119,6 +121,7 @@ enum {
|
|
|
eec4b3 |
PROP_SECURE_CHANNELS,
|
|
|
eec4b3 |
PROP_DELETE_THIS_FILE,
|
|
|
eec4b3 |
PROP_SECURE_ATTENTION,
|
|
|
eec4b3 |
+ PROP_OVIRT_ADMIN,
|
|
|
eec4b3 |
PROP_OVIRT_HOST,
|
|
|
eec4b3 |
PROP_OVIRT_VM_GUID,
|
|
|
eec4b3 |
PROP_OVIRT_JSESSIONID,
|
|
|
eec4b3 |
@@ -677,6 +680,19 @@ virt_viewer_file_set_ovirt_ca(VirtViewerFile* self, const gchar* value)
|
|
|
eec4b3 |
g_object_notify(G_OBJECT(self), "ovirt-ca");
|
|
|
eec4b3 |
}
|
|
|
eec4b3 |
|
|
|
eec4b3 |
+gint
|
|
|
eec4b3 |
+virt_viewer_file_get_ovirt_admin(VirtViewerFile* self)
|
|
|
eec4b3 |
+{
|
|
|
eec4b3 |
+ return virt_viewer_file_get_int(self, OVIRT_GROUP, "admin");
|
|
|
eec4b3 |
+}
|
|
|
eec4b3 |
+
|
|
|
eec4b3 |
+void
|
|
|
eec4b3 |
+virt_viewer_file_set_ovirt_admin(VirtViewerFile* self, gint value)
|
|
|
eec4b3 |
+{
|
|
|
eec4b3 |
+ virt_viewer_file_set_int(self, OVIRT_GROUP, "admin", value);
|
|
|
eec4b3 |
+ g_object_notify(G_OBJECT(self), "ovirt-admin");
|
|
|
eec4b3 |
+}
|
|
|
eec4b3 |
+
|
|
|
eec4b3 |
static void
|
|
|
eec4b3 |
spice_hotkey_set_accel(const gchar *accel_path, const gchar *key)
|
|
|
eec4b3 |
{
|
|
|
eec4b3 |
@@ -840,6 +856,9 @@ virt_viewer_file_set_property(GObject* object, guint property_id,
|
|
|
eec4b3 |
case PROP_DELETE_THIS_FILE:
|
|
|
eec4b3 |
virt_viewer_file_set_delete_this_file(self, g_value_get_int(value));
|
|
|
eec4b3 |
break;
|
|
|
eec4b3 |
+ case PROP_OVIRT_ADMIN:
|
|
|
eec4b3 |
+ virt_viewer_file_set_ovirt_admin(self, g_value_get_int(value));
|
|
|
eec4b3 |
+ break;
|
|
|
eec4b3 |
case PROP_OVIRT_HOST:
|
|
|
eec4b3 |
virt_viewer_file_set_ovirt_host(self, g_value_get_string(value));
|
|
|
eec4b3 |
break;
|
|
|
eec4b3 |
@@ -940,6 +959,9 @@ virt_viewer_file_get_property(GObject* object, guint property_id,
|
|
|
eec4b3 |
case PROP_DELETE_THIS_FILE:
|
|
|
eec4b3 |
g_value_set_int(value, virt_viewer_file_get_delete_this_file(self));
|
|
|
eec4b3 |
break;
|
|
|
eec4b3 |
+ case PROP_OVIRT_ADMIN:
|
|
|
eec4b3 |
+ g_value_set_int(value, virt_viewer_file_get_ovirt_admin(self));
|
|
|
eec4b3 |
+ break;
|
|
|
eec4b3 |
case PROP_OVIRT_HOST:
|
|
|
eec4b3 |
g_value_take_string(value, virt_viewer_file_get_ovirt_host(self));
|
|
|
eec4b3 |
break;
|
|
|
eec4b3 |
@@ -1087,6 +1109,10 @@ virt_viewer_file_class_init(VirtViewerFileClass* klass)
|
|
|
eec4b3 |
g_param_spec_int("delete-this-file", "delete-this-file", "delete-this-file", 0, 1, 0,
|
|
|
eec4b3 |
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
|
|
|
eec4b3 |
|
|
|
eec4b3 |
+ g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_OVIRT_ADMIN,
|
|
|
eec4b3 |
+ g_param_spec_int("ovirt-admin", "ovirt-admin", "ovirt-admin", 0, 1, 0,
|
|
|
eec4b3 |
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
|
|
|
eec4b3 |
+
|
|
|
eec4b3 |
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_OVIRT_HOST,
|
|
|
eec4b3 |
g_param_spec_string("ovirt-host", "ovirt-host", "ovirt-host", NULL,
|
|
|
eec4b3 |
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
|
|
|
eec4b3 |
diff --git a/src/virt-viewer-file.h b/src/virt-viewer-file.h
|
|
|
eec4b3 |
index f4b030c..e84988a 100644
|
|
|
eec4b3 |
--- a/src/virt-viewer-file.h
|
|
|
eec4b3 |
+++ b/src/virt-viewer-file.h
|
|
|
eec4b3 |
@@ -108,6 +108,8 @@ gint virt_viewer_file_get_delete_this_file(VirtViewerFile* self);
|
|
|
eec4b3 |
void virt_viewer_file_set_delete_this_file(VirtViewerFile* self, gint value);
|
|
|
eec4b3 |
gchar* virt_viewer_file_get_secure_attention(VirtViewerFile* self);
|
|
|
eec4b3 |
void virt_viewer_file_set_secure_attention(VirtViewerFile* self, const gchar* value);
|
|
|
eec4b3 |
+gint virt_viewer_file_get_ovirt_admin(VirtViewerFile* self);
|
|
|
eec4b3 |
+void virt_viewer_file_set_ovirt_admin(VirtViewerFile* self, gint value);
|
|
|
eec4b3 |
gchar* virt_viewer_file_get_ovirt_host(VirtViewerFile* self);
|
|
|
eec4b3 |
void virt_viewer_file_set_ovirt_host(VirtViewerFile* self, const gchar* value);
|
|
|
eec4b3 |
gchar* virt_viewer_file_get_ovirt_vm_guid(VirtViewerFile* self);
|