The host details page has been modified to update the keytab status
based on the data returned by the host-mod command for setting OTP.

Ticket #1710

--
Endi S. Dewata
From aa7f42b45f84f65a4735ccc3d8e8e4a2cf6479a2 Mon Sep 17 00:00:00 2001
From: Endi S. Dewata <edew...@redhat.com>
Date: Thu, 25 Aug 2011 14:03:48 -0500
Subject: [PATCH] Fixed host keytab status after setting OTP.

The host details page has been modified to update the keytab status
based on the data returned by the host-mod command for setting OTP.

Ticket #1710
---
 install/ui/details.js              |    2 +
 install/ui/host.js                 |  140 +++++++++++++++++++++++------------
 install/ui/test/data/host_mod.json |    2 +
 3 files changed, 96 insertions(+), 48 deletions(-)

diff --git a/install/ui/details.js b/install/ui/details.js
index 4550c1abfb9d408d332b858638ad28a9811cb0e9..a0a44e7b2e9c038afb5f11be1ae7aded82d2894d 100644
--- a/install/ui/details.js
+++ b/install/ui/details.js
@@ -215,6 +215,8 @@ IPA.details_list_section = function(spec) {
         }
     };
 
+    that.list_section_create = that.create;
+
     return that;
 };
 
diff --git a/install/ui/host.js b/install/ui/host.js
index 52a0e8f92927cdb24169ff99d40d4b37c2be7303..d22f54887a4489e56331f6730c05421ccf208fb3 100644
--- a/install/ui/host.js
+++ b/install/ui/host.js
@@ -29,54 +29,62 @@ IPA.entity_factories.host = function () {
     return IPA.entity_builder().
         entity('host').
         search_facet({
-            columns:['fqdn','description',{
-                name: 'krblastpwdchange',
-                label: IPA.messages.objects.host.enrolled,
-                format: IPA.utc_date_column_format
-            }]
+            columns: [
+                'fqdn',
+                'description',
+                {
+                    name: 'krblastpwdchange',
+                    label: IPA.messages.objects.host.enrolled,
+                    format: IPA.utc_date_column_format
+                }
+            ]
+        }).
+        details_facet({
+            sections: [
+                {
+                    name: 'details',
+                    fields: [
+                        {
+                            factory: IPA.host_dnsrecord_entity_link_widget,
+                            name: 'fqdn',
+                            other_entity: 'dnsrecord'
+                        },
+                        'krbprincipalname',
+                        'description',
+                        'l',
+                        'nshostlocation',
+                        'nshardwareplatform',
+                        'nsosversion'
+                    ]
+                },
+                {
+                    factory: IPA.host_enrollment_section,
+                    name: 'enrollment',
+                    fields: [
+                        {
+                            factory: IPA.host_keytab_widget,
+                            name: 'has_keytab',
+                            label: IPA.messages.objects.host.keytab
+                        },
+                        {
+                            factory: IPA.host_password_widget,
+                            name: 'has_password',
+                            label: IPA.messages.objects.host.password
+                        }
+                    ]
+                },
+                {
+                    name: 'certificate',
+                    fields: [
+                        {
+                            factory: IPA.host_certificate_status_widget,
+                            name: 'certificate_status',
+                            label: IPA.messages.objects.host.status
+                        }
+                    ]
+                }
+            ]
         }).
-        details_facet({sections:[
-            {
-                name: 'details',
-                fields: [
-                    {
-                        factory: IPA.host_dnsrecord_entity_link_widget,
-                        name: 'fqdn',
-                        other_entity:'dnsrecord'
-                    },
-                    'krbprincipalname',
-                    'description',
-                    'l',
-                    'nshostlocation',
-                    'nshardwareplatform',
-                    'nsosversion'
-                ]
-            },
-            {
-                name:'enrollment',
-                fields:[
-                    {
-                        factory: IPA.host_keytab_widget,
-                        'name': 'has_keytab',
-                        label: IPA.messages.objects.host.keytab
-                    },
-                    {
-                        factory: IPA.host_password_widget,
-                        'name': 'has_password',
-                        label: IPA.messages.objects.host.password
-                    }
-                ]
-            },
-            {
-                name:'certificate',
-                fields:[
-                    {
-                        factory: IPA.host_certificate_status_widget,
-                        'name': 'certificate_status',
-                        label: IPA.messages.objects.host.status
-                    }
-                ]
-            }]}).
         association_facet({
             name: 'managedby_host',
             add_method: 'add_managedby',
@@ -414,6 +422,42 @@ IPA.force_host_add_checkbox_widget = function(spec) {
     return IPA.checkbox_widget(spec);
 };
 
+IPA.host_enrollment_section = function(spec) {
+
+    spec = spec || {};
+
+    var that = IPA.details_list_section(spec);
+
+    that.create = function(container) {
+        that.list_section_create(container);
+
+        var keytab_field = that.get_field('has_keytab');
+        var password_field = that.get_field('has_password');
+
+        /**
+         * The set_password() in the password field is being customized to
+         * update the keytab field.
+         *
+         * The customization needs to be done here because the section
+         * doesn't create the fields. The IPA.entity_builder adds the fields
+         * after creating the section. This needs to be improved.
+         */
+        var super_set_password = password_field.set_password;
+        password_field.set_password = function(password, on_success, on_error) {
+            super_set_password.call(
+                this,
+                password,
+                function(data, text_status, xhr) {
+                    keytab_field.load(data.result.result);
+                    if (on_success) on_success.call(this, data, text_status, xhr);
+                },
+                on_error);
+        };
+    };
+
+    return that;
+};
+
 IPA.host_keytab_widget = function(spec) {
 
     spec = spec || {};
@@ -621,7 +665,7 @@ IPA.host_password_widget = function(spec) {
             that.set_password(
                 new_password,
                 function(data, text_status, xhr) {
-                    set_status('present');
+                    that.load(data.result.result);
                     dialog.close();
                 },
                 function(xhr, text_status, error_thrown) {
diff --git a/install/ui/test/data/host_mod.json b/install/ui/test/data/host_mod.json
index 3cb7d9ec5af7ec850669b7294d3f5742ad79543b..2e34257e8824ccef941aae7e438bd86099ef3829 100644
--- a/install/ui/test/data/host_mod.json
+++ b/install/ui/test/data/host_mod.json
@@ -46,6 +46,8 @@
             "fqdn": [
                 "test.example.com"
             ],
+            "has_keytab": false,
+            "has_password": true,
             "ipauniqueid": [
                 "ac28dca0-f3b5-11df-879f-00163e72f2d9"
             ],
-- 
1.7.5.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to