[gnome-disk-utility/wip/iscsi: 9/9] iscsi: show Auth, Startup and Timeout each iSCSI connection
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility/wip/iscsi: 9/9] iscsi: show Auth, Startup and Timeout each iSCSI connection
- Date: Tue, 28 Feb 2012 22:05:23 +0000 (UTC)
commit 319b454c721218091684b1e99e36c9c9a341fe1a
Author: David Zeuthen <davidz redhat com>
Date: Tue Feb 28 17:04:20 2012 -0500
iscsi: show Auth, Startup and Timeout each iSCSI connection
Signed-off-by: David Zeuthen <davidz redhat com>
data/ui/palimpsest.ui | 23 +++--
src/palimpsest/gduiscsipathmodel.c | 11 ++-
src/palimpsest/gduiscsipathmodel.h | 1 +
src/palimpsest/gduwindow.c | 183 +++++++++++++++++++++++++++++++++---
4 files changed, 192 insertions(+), 26 deletions(-)
---
diff --git a/data/ui/palimpsest.ui b/data/ui/palimpsest.ui
index 5bbd959..555de26 100644
--- a/data/ui/palimpsest.ui
+++ b/data/ui/palimpsest.ui
@@ -1316,6 +1316,7 @@
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="icon_name">system-run-symbolic</property>
+ <property name="tooltip_text" translatable="yes">Configure connection...</property>
</object>
<packing>
<property name="expand">False</property>
@@ -1339,18 +1340,16 @@
<property name="column_spacing">12</property>
<child>
- <object class="GtkLabel" id="iscsitab-connection-startup-label">
+ <object class="GtkLabel" id="iscsitab-connection-auth-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
- <property name="label" translatable="yes">Startup</property>
+ <property name="label" translatable="yes">Authentication</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
- <property name="left_attach">0</property>
- <property name="right_attach">1</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">GTK_FILL</property>
@@ -1359,7 +1358,7 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="iscsitab-connection-startup-value-label">
+ <object class="GtkLabel" id="iscsitab-connection-auth-value-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
@@ -1379,11 +1378,11 @@
</child>
<child>
- <object class="GtkLabel" id="iscsitab-connection-timeout-label">
+ <object class="GtkLabel" id="iscsitab-connection-startup-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
- <property name="label" translatable="yes">Timeout</property>
+ <property name="label" translatable="yes">Connect at Startup</property>
<style>
<class name="dim-label"/>
</style>
@@ -1399,7 +1398,7 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="iscsitab-connection-timeout-value-label">
+ <object class="GtkLabel" id="iscsitab-connection-startup-value-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
@@ -1419,16 +1418,18 @@
</child>
<child>
- <object class="GtkLabel" id="iscsitab-connection-auth-label">
+ <object class="GtkLabel" id="iscsitab-connection-timeout-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
- <property name="label" translatable="yes">Authentication</property>
+ <property name="label" translatable="yes">Timeout</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
@@ -1437,7 +1438,7 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="iscsitab-connection-auth-value-label">
+ <object class="GtkLabel" id="iscsitab-connection-timeout-value-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
diff --git a/src/palimpsest/gduiscsipathmodel.c b/src/palimpsest/gduiscsipathmodel.c
index fc62ee5..308d90d 100644
--- a/src/palimpsest/gduiscsipathmodel.c
+++ b/src/palimpsest/gduiscsipathmodel.c
@@ -139,8 +139,9 @@ gdu_iscsi_path_model_constructed (GObject *object)
types[2] = G_TYPE_INT;
types[3] = G_TYPE_INT;
types[4] = G_TYPE_STRING;
- types[5] = G_TYPE_STRING;
- G_STATIC_ASSERT (6 == GDU_ISCSI_PATH_MODEL_N_COLUMNS);
+ types[5] = G_TYPE_VARIANT;
+ types[6] = G_TYPE_STRING;
+ G_STATIC_ASSERT (7 == GDU_ISCSI_PATH_MODEL_N_COLUMNS);
gtk_list_store_set_column_types (GTK_LIST_STORE (model),
GDU_ISCSI_PATH_MODEL_N_COLUMNS,
types);
@@ -261,6 +262,7 @@ update_all (GduiSCSIPathModel *model)
const gchar *portal_name;
gint port;
gint group;
+ GVariant *configuration;
const gchar *iface_name;
const gchar *state;
@@ -270,11 +272,12 @@ update_all (GduiSCSIPathModel *model)
g_variant_iter_init (&portal_iter, portals_and_interfaces);
while (g_variant_iter_next (&portal_iter,
- "(&sii&s&sa{sv})",
+ "(&sii&s a{ss}&sa{sv})",
&portal_name,
&port,
&group,
&iface_name,
+ &configuration,
&state,
NULL)) /* expansion */
{
@@ -309,8 +312,10 @@ update_all (GduiSCSIPathModel *model)
GDU_ISCSI_PATH_MODEL_COLUMN_PORTAL_PORT, port,
GDU_ISCSI_PATH_MODEL_COLUMN_TPGT, group,
GDU_ISCSI_PATH_MODEL_COLUMN_INTERFACE, iface_name,
+ GDU_ISCSI_PATH_MODEL_COLUMN_CONFIGURATION, configuration,
GDU_ISCSI_PATH_MODEL_COLUMN_STATUS, status,
-1);
+ g_variant_unref (configuration);
g_free (status);
}
}
diff --git a/src/palimpsest/gduiscsipathmodel.h b/src/palimpsest/gduiscsipathmodel.h
index 938ab36..caa3647 100644
--- a/src/palimpsest/gduiscsipathmodel.h
+++ b/src/palimpsest/gduiscsipathmodel.h
@@ -39,6 +39,7 @@ enum
GDU_ISCSI_PATH_MODEL_COLUMN_PORTAL_PORT,
GDU_ISCSI_PATH_MODEL_COLUMN_TPGT,
GDU_ISCSI_PATH_MODEL_COLUMN_INTERFACE,
+ GDU_ISCSI_PATH_MODEL_COLUMN_CONFIGURATION,
GDU_ISCSI_PATH_MODEL_COLUMN_STATUS,
GDU_ISCSI_PATH_MODEL_N_COLUMNS
};
diff --git a/src/palimpsest/gduwindow.c b/src/palimpsest/gduwindow.c
index 9dc79aa..8e3fc6c 100644
--- a/src/palimpsest/gduwindow.c
+++ b/src/palimpsest/gduwindow.c
@@ -251,6 +251,9 @@ static void teardown_iscsi_target_page (GduWindow *window);
static void on_volume_grid_changed (GduVolumeGrid *grid,
gpointer user_data);
+static void on_iscsi_connections_tree_selection_changed (GtkTreeSelection *tree_selection,
+ gpointer user_data);
+
static void on_devtab_action_generic_activated (GtkAction *action, gpointer user_data);
static void on_devtab_action_partition_create_activated (GtkAction *action, gpointer user_data);
static void on_devtab_action_partition_delete_activated (GtkAction *action, gpointer user_data);
@@ -2337,7 +2340,6 @@ init_iscsi_target_page (GduWindow *window)
{
static volatile gsize init_val = 0;
GtkTreeView *tree_view;
- /* GtkTreeSelection *selection; */
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;
@@ -2346,14 +2348,11 @@ init_iscsi_target_page (GduWindow *window)
tree_view = GTK_TREE_VIEW (window->iscsitab_connections_treeview);
gtk_tree_view_set_rules_hint (tree_view, TRUE);
-#if 0
- selection = gtk_tree_view_get_selection (tree_view);
- gtk_tree_selection_set_select_function (selection, dont_select_headings, NULL, NULL);
- g_signal_connect (selection,
+
+ g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (window->iscsitab_connections_treeview)),
"changed",
- G_CALLBACK (on_tree_selection_changed),
+ G_CALLBACK (on_iscsi_connections_tree_selection_changed),
window);
-#endif
column = gtk_tree_view_column_new ();
gtk_tree_view_append_column (tree_view, column);
@@ -2407,6 +2406,7 @@ init_iscsi_target_page (GduWindow *window)
;
}
+#if 0
static gboolean
iscsi_target_has_active_connections (UDisksiSCSITarget *target)
{
@@ -2435,10 +2435,85 @@ iscsi_target_has_active_connections (UDisksiSCSITarget *target)
out:
return ret;
}
+#endif
+static void
+update_iscsi_connection_details (GduWindow *window)
+{
+
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GVariant *configuration;
+ const gchar *node_startup = NULL;
+ const gchar *startup = NULL;
+ const gchar *timeout_str = NULL;
+ gint timeout_val = 0;
+ gchar *timeout= NULL;
+ const gchar *auth_method = NULL;
+ const gchar *username_in = NULL;
+ gchar *auth = NULL;
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->iscsitab_connections_treeview));
+ if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+ goto out;
+
+ gtk_tree_model_get (model, &iter,
+ GDU_ISCSI_PATH_MODEL_COLUMN_CONFIGURATION, &configuration,
+ -1);
+
+ g_variant_lookup (configuration, "node.startup", "&s", &node_startup);
+ if (g_strcmp0 (node_startup, "automatic") == 0)
+ startup = C_("iscsi-target", "Yes");
+ else
+ startup = C_("iscsi-target", "No");
+
+ g_variant_lookup (configuration, "node.session.timeo.replacement_timeout", "&s", &timeout_str);
+ if (timeout_str != NULL)
+ timeout_val = atoi (timeout_str);
+ timeout = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE,
+ "%d second",
+ "%d seconds",
+ timeout_val),
+ timeout_val);
+
+ g_variant_lookup (configuration, "node.session.auth.authmethod", "&s", &auth_method);
+ g_variant_lookup (configuration, "node.session.auth.username_in", "&s", &username_in);
+ if (g_strcmp0 (auth_method, "None") == 0)
+ {
+ auth = g_strdup (C_("iscsi-target", "None"));
+ }
+ else if (g_strcmp0 (auth_method, "CHAP") == 0)
+ {
+ if (username_in != NULL && strlen (username_in) > 0)
+ auth = g_strdup (C_("iscsi-target", "Mutual CHAP"));
+ else
+ auth = g_strdup (C_("iscsi-target", "CHAP"));
+ }
+ else
+ {
+ auth = g_strdup_printf (C_("iscsi-target", "Other (%s)"), auth_method);
+ }
+
+out:
+ set_markup (window,
+ "iscsitab-connection-startup-label",
+ "iscsitab-connection-startup-value-label",
+ startup, SET_MARKUP_FLAGS_HYPHEN_IF_EMPTY);
+ set_markup (window,
+ "iscsitab-connection-timeout-label",
+ "iscsitab-connection-timeout-value-label",
+ timeout, SET_MARKUP_FLAGS_HYPHEN_IF_EMPTY);
+ set_markup (window,
+ "iscsitab-connection-auth-label",
+ "iscsitab-connection-auth-value-label",
+ auth, SET_MARKUP_FLAGS_HYPHEN_IF_EMPTY);
+ g_free (timeout);
+ g_free (auth);
+}
static void
-update_iscsi_target_page (GduWindow *window)
+update_iscsi_target_page (GduWindow *window)
{
GList *children;
GList *l;
@@ -2500,6 +2575,81 @@ update_iscsi_target_page (GduWindow *window)
"iscsitab-discovery-value-label",
discovery, SET_MARKUP_FLAGS_HYPHEN_IF_EMPTY);
g_free (discovery);
+
+ update_iscsi_connection_details (window);
+}
+
+
+static void
+iscsi_connections_select_first (GduWindow *window,
+ GtkTreeModel *model)
+{
+ GtkTreeIter iter;
+ GtkTreeSelection *selection;
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->iscsitab_connections_treeview));
+ if (gtk_tree_model_get_iter_first (model, &iter))
+ {
+ gtk_tree_selection_select_iter (selection, &iter);
+ }
+}
+
+static void
+iscsi_connections_ensure_selected (GduWindow *window)
+{
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->iscsitab_connections_treeview));
+ if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+ {
+ /* ensure something is always selected */
+ iscsi_connections_select_first (window, model);
+ }
+}
+
+static void
+iscsi_connections_on_row_deleted (GtkTreeModel *model,
+ GtkTreePath *path,
+ gpointer user_data)
+{
+ GduWindow *window = GDU_WINDOW (user_data);
+ iscsi_connections_ensure_selected (window);
+}
+
+static void
+iscsi_connections_on_row_inserted (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer user_data)
+{
+ GduWindow *window = GDU_WINDOW (user_data);
+ iscsi_connections_ensure_selected (window);
+}
+
+static void
+on_iscsi_connections_tree_selection_changed (GtkTreeSelection *tree_selection,
+ gpointer user_data)
+{
+ GduWindow *window = GDU_WINDOW (user_data);
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ if (gtk_tree_selection_get_selected (tree_selection, &model, &iter))
+ {
+ ShowFlags show_flags;
+ show_flags = SHOW_FLAGS_NONE;
+ update_details_page (window, window->current_page, &show_flags);
+ update_for_show_flags (window, show_flags);
+ }
+ else
+ {
+ if (model != NULL)
+ {
+ /* ensure something is always selected */
+ iscsi_connections_select_first (window, model);
+ }
+ }
}
static void
@@ -2508,16 +2658,25 @@ setup_iscsi_target_page (GduWindow *window,
{
GtkTreeView *tree_view;
GduiSCSIPathModel *model;
- GtkTreeIter first_iter;
init_iscsi_target_page (window);
tree_view = GTK_TREE_VIEW (window->iscsitab_connections_treeview);
model = gdu_iscsi_path_model_new (window->client, object);
gtk_tree_view_set_model (tree_view, GTK_TREE_MODEL (model));
- /* select the first row */
- if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &first_iter))
- gtk_tree_selection_select_iter (gtk_tree_view_get_selection (tree_view), &first_iter);
+
+ iscsi_connections_select_first (window, GTK_TREE_MODEL (model));
+
+ /* to ensure something is always selected */
+ g_signal_connect (model,
+ "row-deleted",
+ G_CALLBACK (iscsi_connections_on_row_deleted),
+ window);
+ g_signal_connect (model,
+ "row-inserted",
+ G_CALLBACK (iscsi_connections_on_row_inserted),
+ window);
+
g_object_unref (model);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]