Hi,

This patch adds the Service tab using Adam's association classes.
It also contains the sample data for some service operations.

Thanks!

--
Endi S. Dewata
>From 3258e05bd5777e6ca31369491a964d8335452b55 Mon Sep 17 00:00:00 2001
From: Endi Sukma Dewata <edew...@redhat.com>
Date: Thu, 2 Sep 2010 04:14:57 -0400
Subject: [PATCH] Added Services tab.

---
 install/static/Makefile.am                       |    1 +
 install/static/index.xhtml                       |    1 +
 install/static/navigation.js                     |    7 +-
 install/static/sampledata/service_add.json       |   29 +++++++
 install/static/sampledata/service_del.json       |    9 ++
 install/static/sampledata/service_find.json      |   48 +++++++++++
 install/static/sampledata/service_remove_host.sh |   18 ++++
 install/static/sampledata/service_show.json      |   18 ++++
 install/static/service.js                        |   96 ++++++++++++++++++++++
 9 files changed, 225 insertions(+), 2 deletions(-)
 create mode 100644 install/static/sampledata/service_add.json
 create mode 100644 install/static/sampledata/service_del.json
 create mode 100644 install/static/sampledata/service_find.json
 create mode 100644 install/static/sampledata/service_remove_host.sh
 create mode 100644 install/static/sampledata/service_show.json
 create mode 100644 install/static/service.js

diff --git a/install/static/Makefile.am b/install/static/Makefile.am
index 63e5894..b0c4c7f 100644
--- a/install/static/Makefile.am
+++ b/install/static/Makefile.am
@@ -19,6 +19,7 @@ app_DATA =                              \
 	jquery.cookie.js 		\
 	navigation.js			\
 	netgroup.js 			\
+	service.js 			\
 	pageparams.js 			\
 	search.js 			\
 	details.js 			\
diff --git a/install/static/index.xhtml b/install/static/index.xhtml
index 4077d4f..6e1d043 100644
--- a/install/static/index.xhtml
+++ b/install/static/index.xhtml
@@ -20,6 +20,7 @@
     <script type="text/javascript" src="host.js"></script>
     <script type="text/javascript" src="hostgroup.js"></script>
     <script type="text/javascript" src="netgroup.js"></script>
+    <script type="text/javascript" src="service.js"></script>
 
     <script type="text/javascript">
 
diff --git a/install/static/navigation.js b/install/static/navigation.js
index 94fe47a..ed19077 100644
--- a/install/static/navigation.js
+++ b/install/static/navigation.js
@@ -24,6 +24,7 @@ function getParentTabs(){
         host     : "identity",
         hostgroup: "identity",
         netgroup : "identity",
+        service  : "identity",
         policy   : "policy",
         config   : "config"
     };
@@ -54,7 +55,8 @@ function buildNavigation(){
             {name:"Hostgroups",
              tab:"hostgroup",
              setup:  setupHostgroup},
-            {name:"Netgroups",tab:"netgroup", setup:setupNetgroup}
+            {name:"Netgroups",tab:"netgroup", setup:setupNetgroup},
+            {name:"Services",tab:"service", setup:setupService}
             ]},
            {name:"POLICY",  tab:"policy", setup: unimplemented},
            {name:"CONFIG",  tab:"config", setup: unimplemented }];
@@ -139,6 +141,7 @@ function getSetupFunctions(){
         host:     setupHost,
         hostgroup:setupHostgroup,
         netgroup:setupNetgroup,
+        service:setupService,
     };
     }
     return setupFunctions;
@@ -236,4 +239,4 @@ function showDetails(){
 function showAssociations(){
     clearOld();
     $('#associations').css("display","block");
-}
\ No newline at end of file
+}
diff --git a/install/static/sampledata/service_add.json b/install/static/sampledata/service_add.json
new file mode 100644
index 0000000..f8b3f77
--- /dev/null
+++ b/install/static/sampledata/service_add.json
@@ -0,0 +1,29 @@
+{
+    "error": null, 
+    "id": 0, 
+    "result": {
+        "result": {
+            "dn": "krbprincipalname=test/dev.example....@dev.example.com,cn=services,cn=accounts,dc=dev,dc=example,dc=com", 
+            "ipauniqueid": [
+                "5b314ad9-bae4-11df-b82f-00163e72f2d9"
+            ], 
+            "krbprincipalname": [
+                "test/dev.example....@dev.example.com"
+            ], 
+            "managedby_host": [
+                "dev.example.com"
+            ], 
+            "objectclass": [
+                "krbprincipal", 
+                "krbprincipalaux", 
+                "krbticketpolicyaux", 
+                "ipaobject", 
+                "ipaservice", 
+                "pkiuser", 
+                "top"
+            ]
+        }, 
+        "summary": "Added service \"test/dev.example....@dev.example.com\"", 
+        "value": "test/dev.example....@dev.example.com"
+    }
+}
\ No newline at end of file
diff --git a/install/static/sampledata/service_del.json b/install/static/sampledata/service_del.json
new file mode 100644
index 0000000..326625b
--- /dev/null
+++ b/install/static/sampledata/service_del.json
@@ -0,0 +1,9 @@
+{
+    "error": null, 
+    "id": 0, 
+    "result": {
+        "result": true, 
+        "summary": "Deleted service \"test/dev.example....@dev.example.com\"", 
+        "value": "test/dev.example....@dev.example.com"
+    }
+}
\ No newline at end of file
diff --git a/install/static/sampledata/service_find.json b/install/static/sampledata/service_find.json
new file mode 100644
index 0000000..dc95b9b
--- /dev/null
+++ b/install/static/sampledata/service_find.json
@@ -0,0 +1,48 @@
+{
+    "error": null, 
+    "id": 0, 
+    "result": {
+        "count": 3, 
+        "result": [
+            {
+                "dn": "krbprincipalname=ldap/dev.example....@dev.example.com,cn=services,cn=accounts,dc=dev,dc=example,dc=com", 
+                "has_keytab": true, 
+                "krbprincipalname": [
+                    "ldap/dev.example....@dev.example.com"
+                ], 
+                "managedby_host": [
+                    "dev.example.com"
+                ], 
+                "usercertificate": [
+                    {
+                        "__base64__": "MIICbjCCAdegAwIBAgICA+0wDQYJKoZIhvcNAQEFBQAwKTEnMCUGA1UEAxMeSVBBIFRlc3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MB4XDTEwMDkwMjA2NTYzMloXDTIwMDkwMjA2NTYzMlowKDEMMAoGA1UEChMDSVBBMRgwFgYDVQQDEw9kZXYuZXhhbXBsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDc63RjpqUCI84j9kjn0XYmpAOjkYbLddT9F0UUanASg1iIhscwWjvp/Mf5ZIzEYoB+dloI9gvEUWb8CU/x42QZr4lgEK4m/vCSDA0CkAnWvU/DHdtcAgpdZeBOQ1CMynyvNvN/ajyaA8dPwRcs9yJDrWXMa7LzMuw+ct5HA7HRdDdvUeIFr8YZEd/Mt1N96BmlVf3GA3P89cWfCKr1iVnmyewanjKuwcws1GCxawCnp0w1GHbKct4PPhB3k6EN8ZipFDGZmSeDVsa3gF7y2reLAYTS1/RwWPAHNeQ0cpOMe155cF3uHGSoX+RWtgo0BZ1+wgLMU5sf9W3ZMln3WmoFAgMBAAGjIjAgMBEGCWCGSAGG+EIBAQQEAwIGQDALBgNVHQ8EBAMCBSAwDQYJKoZIhvcNAQEFBQADgYEAbSYTU+IQvfppQE7setcpO/PiFNnMaZ3Ss7UGjm6XoPem9X0ktQOfWhBuhfH/7MbPdg2zn+55soaRpd8rOThr187G40GAMM5I3Jr+8386Q4zwCvED7B09pzBhQd/4ecVTIYFc82EytsM6I1aBrG9cLLuT+RL2dK5efOymCf/zjsw="
+                    }
+                ]
+            }, 
+            {
+                "dn": "krbprincipalname=http/dev.example....@dev.example.com,cn=services,cn=accounts,dc=dev,dc=example,dc=com", 
+                "has_keytab": true, 
+                "krbprincipalname": [
+                    "HTTP/dev.example....@dev.example.com"
+                ], 
+                "usercertificate": [
+                    {
+                        "__base64__": "MIICbjCCAdegAwIBAgICA+4wDQYJKoZIhvcNAQEFBQAwKTEnMCUGA1UEAxMeSVBBIFRlc3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MB4XDTEwMDkwMjA2NTY1MFoXDTIwMDkwMjA2NTY1MFowKDEMMAoGA1UEChMDSVBBMRgwFgYDVQQDEw9kZXYuZXhhbXBsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2g0DTtC0f7StYfbVqc3bZ6niWHCBZp9SVEgD1lGY9+efQnO1Z6dqbUxLI+oUcVqA2aoeWVSTQ1KZLglF0pYUJcMVfUAQaFbwhY05rLtKya0+6DgYbnJ187fSHNOLQ71v/6pFt9THyLFICFJgKX64ouQYxV7+UY/vyqaKCjonWBJznJHaw07cEYj6tFkQxwNIhQRWZP2yLrSEay1cDLtA7Rm6AYRKIhiBKwFVewi4VEo6HbgfKpeZRZ2G8w1UErxTuPom2WymByoOg1Z8Xn23OiW+CkcrwRFhDYyp3LRiIT+86fPYkF4TBqO9lWbxKy4ZtcHXfMcGBmQSc3yjN+IctAgMBAAGjIjAgMBEGCWCGSAGG+EIBAQQEAwIGQDALBgNVHQ8EBAMCBSAwDQYJKoZIhvcNAQEFBQADgYEAi1vdSKmUUPdkwxv6tnabo6sEpTCdyV33Jops5hMkdtIKsvOG+CeXuvPYIwZpvwozAppL3tcXsh6t35YklpjeoX8qX5gYTZvuusCUAQHfJC4H/ggU+TrjQW5GnGOLTpgew/NtLKj7LACp/YrwMNA5ktdsBbj2kESIEVlokLvITy4="
+                    }
+                ]
+            }, 
+            {
+                "dn": "krbprincipalname=test/dev.example....@dev.example.com,cn=services,cn=accounts,dc=dev,dc=example,dc=com", 
+                "has_keytab": false, 
+                "krbprincipalname": [
+                    "test/dev.example....@dev.example.com"
+                ], 
+                "managedby_host": [
+                    "dev.example.com"
+                ]
+            }
+        ], 
+        "summary": "3 services matched", 
+        "truncated": false
+    }
+}
\ No newline at end of file
diff --git a/install/static/sampledata/service_remove_host.sh b/install/static/sampledata/service_remove_host.sh
new file mode 100644
index 0000000..cc56169
--- /dev/null
+++ b/install/static/sampledata/service_remove_host.sh
@@ -0,0 +1,18 @@
+{
+    "error": null, 
+    "id": 0, 
+    "result": {
+        "completed": 1, 
+        "failed": {
+            "managedby": {
+                "host": []
+            }
+        }, 
+        "result": {
+            "dn": "krbprincipalname=test/dev.example....@dev.example.com,cn=services,cn=accounts,dc=dev,dc=example,dc=com", 
+            "krbprincipalname": [
+                "test/dev.example....@dev.example.com"
+            ]
+        }
+    }
+}
\ No newline at end of file
diff --git a/install/static/sampledata/service_show.json b/install/static/sampledata/service_show.json
new file mode 100644
index 0000000..879bc58
--- /dev/null
+++ b/install/static/sampledata/service_show.json
@@ -0,0 +1,18 @@
+{
+    "error": null, 
+    "id": 0, 
+    "result": {
+        "result": {
+            "dn": "krbprincipalname=test/dev.example....@dev.example.com,cn=services,cn=accounts,dc=dev,dc=example,dc=com", 
+            "has_keytab": false, 
+            "krbprincipalname": [
+                "test/dev.example....@dev.example.com"
+            ], 
+            "managedby_host": [
+                "dev.example.com"
+            ]
+        }, 
+        "summary": null, 
+        "value": "test/dev.example....@dev.example.com"
+    }
+}
\ No newline at end of file
diff --git a/install/static/service.js b/install/static/service.js
new file mode 100644
index 0000000..467e56a
--- /dev/null
+++ b/install/static/service.js
@@ -0,0 +1,96 @@
+function setupService(facet) {
+    serviceForms.setup(facet);
+}
+
+var serviceForms = new ServiceForms();
+
+function ServiceForms() {
+
+    this.obj = "service";
+
+    this.facets = ['details', 'hosts', 'assignhosts'];
+
+    this.setup = function(facet) {
+        if (this[facet]) {
+            this[facet].setup();
+        } else {
+            this.unspecified.setup();
+        }
+    };
+
+    this.hostListColumns = [ {title:"host",column:"managedby_host"} ];
+
+    this.hosts = new AssociationList(
+        this.obj,
+        "hosts",
+        "assignhosts",
+        this.hostListColumns,
+        this.facets
+    );
+
+    this.assignhosts = new AssociationForm(
+        this.obj,
+        "host",
+        "assignhosts",
+        this.facets,
+        "fqdn",
+        function() {
+            return 'Add Hosts to service : ' + qs['pkey'];
+        },
+        BulkAssociator,
+        "add_host"
+    );
+
+    this.detailsList = [
+        ['identity', 'Service Details', [
+            ['krbprincipalname', 'Kerberos Principal']
+        ]]
+    ];
+
+    this.details = new DetailsForm(
+        "service",
+        this.detailsList,
+        "krbprincipalname",
+        this.facets
+    );
+
+    this.addProperties = [
+        {title: 'Principal', id: 'pkey', type: 'text'}
+    ];
+
+    this.addOptionsFunction = function() {
+        var options = {
+            name: $('#pkey').val()
+        };
+        return options;
+    };
+
+    this.add = new EntityBuilder(
+        "service",
+        this.addProperties,
+        this.addOptionsFunction
+    );
+
+    this.searchColumns = [
+        {
+            title: "Service",
+            column: "krbprincipalname",
+            render: function (current, cell) {
+                renderPkeyColumn2('service', 'krbprincipalname', current, cell);
+            }
+        },
+        {
+            title: "Has Keytab",
+            column: "has_keytab",
+            render: renderSimpleColumn
+        }
+    ];
+
+    this.search = new SearchForm(
+        "service",
+        "find",
+        this.searchColumns
+    );
+
+    this.unspecified = this.search;
+}
-- 
1.7.2.2

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

Reply via email to