ovirt: Add support for an 'admin' key in vv file

When using a user with administrator rights, the VMs this user can
access from the user portal and the admin portal are different, and
REST API users must indicate which set of VMs they want through a
specific header. libgovirt already has support for that in its API, but
virt-viewer was not making use of that API.
This commit adds support for an 'admin' field in the [ovirt] section of
.vv files so oVirt can indicate remote-viewer whether this header should
be set or not.
This commit is contained in:
Christophe Fergeau 2015-04-03 16:00:45 +02:00
parent 07def4d4aa
commit 0c8f07ea64
3 changed files with 31 additions and 0 deletions

View File

@ -826,6 +826,7 @@ OvirtForeignMenu *ovirt_foreign_menu_new_from_file(VirtViewerFile *file)
{
OvirtProxy *proxy = NULL;
OvirtForeignMenu *menu = NULL;
gboolean admin;
char *ca_str = NULL;
char *jsessionid = NULL;
char *url = NULL;
@ -836,6 +837,7 @@ OvirtForeignMenu *ovirt_foreign_menu_new_from_file(VirtViewerFile *file)
vm_guid = virt_viewer_file_get_ovirt_vm_guid(file);
jsessionid = virt_viewer_file_get_ovirt_jsessionid(file);
ca_str = virt_viewer_file_get_ovirt_ca(file);
admin = virt_viewer_file_get_ovirt_admin(file);
if ((url == NULL) || (vm_guid == NULL))
goto end;
@ -850,6 +852,7 @@ OvirtForeignMenu *ovirt_foreign_menu_new_from_file(VirtViewerFile *file)
}
g_object_set(G_OBJECT(proxy),
"admin", admin,
"session-id", jsessionid,
"ca-cert", ca,
NULL);

View File

@ -76,6 +76,8 @@
* - jsessionid: string containing an authentication cookie to be used to
* connect to the oVirt engine without being asked for credentials
* - ca: string PEM data (use \n to separate the lines)
* - admin: boolean (0 or 1) indicating whether the VM is visible in the user or
* admin portal
*
* (the file can be extended with extra groups or keys, which should
* be prefixed with x- to avoid later conflicts)
@ -119,6 +121,7 @@ enum {
PROP_SECURE_CHANNELS,
PROP_DELETE_THIS_FILE,
PROP_SECURE_ATTENTION,
PROP_OVIRT_ADMIN,
PROP_OVIRT_HOST,
PROP_OVIRT_VM_GUID,
PROP_OVIRT_JSESSIONID,
@ -677,6 +680,19 @@ virt_viewer_file_set_ovirt_ca(VirtViewerFile* self, const gchar* value)
g_object_notify(G_OBJECT(self), "ovirt-ca");
}
gint
virt_viewer_file_get_ovirt_admin(VirtViewerFile* self)
{
return virt_viewer_file_get_int(self, OVIRT_GROUP, "admin");
}
void
virt_viewer_file_set_ovirt_admin(VirtViewerFile* self, gint value)
{
virt_viewer_file_set_int(self, OVIRT_GROUP, "admin", value);
g_object_notify(G_OBJECT(self), "ovirt-admin");
}
static void
spice_hotkey_set_accel(const gchar *accel_path, const gchar *key)
{
@ -840,6 +856,9 @@ virt_viewer_file_set_property(GObject* object, guint property_id,
case PROP_DELETE_THIS_FILE:
virt_viewer_file_set_delete_this_file(self, g_value_get_int(value));
break;
case PROP_OVIRT_ADMIN:
virt_viewer_file_set_ovirt_admin(self, g_value_get_int(value));
break;
case PROP_OVIRT_HOST:
virt_viewer_file_set_ovirt_host(self, g_value_get_string(value));
break;
@ -940,6 +959,9 @@ virt_viewer_file_get_property(GObject* object, guint property_id,
case PROP_DELETE_THIS_FILE:
g_value_set_int(value, virt_viewer_file_get_delete_this_file(self));
break;
case PROP_OVIRT_ADMIN:
g_value_set_int(value, virt_viewer_file_get_ovirt_admin(self));
break;
case PROP_OVIRT_HOST:
g_value_take_string(value, virt_viewer_file_get_ovirt_host(self));
break;
@ -1087,6 +1109,10 @@ virt_viewer_file_class_init(VirtViewerFileClass* klass)
g_param_spec_int("delete-this-file", "delete-this-file", "delete-this-file", 0, 1, 0,
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_OVIRT_ADMIN,
g_param_spec_int("ovirt-admin", "ovirt-admin", "ovirt-admin", 0, 1, 0,
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_OVIRT_HOST,
g_param_spec_string("ovirt-host", "ovirt-host", "ovirt-host", NULL,
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));

View File

@ -108,6 +108,8 @@ gint virt_viewer_file_get_delete_this_file(VirtViewerFile* self);
void virt_viewer_file_set_delete_this_file(VirtViewerFile* self, gint value);
gchar* virt_viewer_file_get_secure_attention(VirtViewerFile* self);
void virt_viewer_file_set_secure_attention(VirtViewerFile* self, const gchar* value);
gint virt_viewer_file_get_ovirt_admin(VirtViewerFile* self);
void virt_viewer_file_set_ovirt_admin(VirtViewerFile* self, gint value);
gchar* virt_viewer_file_get_ovirt_host(VirtViewerFile* self);
void virt_viewer_file_set_ovirt_host(VirtViewerFile* self, const gchar* value);
gchar* virt_viewer_file_get_ovirt_vm_guid(VirtViewerFile* self);