The association config has been removed because it incorrectly assumes there is only one association between two entities. Now each association is defined separately using association facets.

The service.py has been modified to specify the correct relationships. The API.txt has been updated.

https://fedorahosted.org/freeipa/ticket/960

--
Endi S. Dewata
From 7e69325296f112b398f0cfb737e91c12ec11c7a4 Mon Sep 17 00:00:00 2001
From: Endi S. Dewata <edew...@redhat.com>
Date: Fri, 11 Feb 2011 18:04:04 -0600
Subject: [PATCH] Fixed association facets.

The association config has been removed because it incorrectly assumes there is only one association between two entities. Now each association is defined separately using association facets.

The service.py has been modified to specify the correct relationships. The API.txt has been updated.

https://fedorahosted.org/freeipa/ticket/960
---
 API.txt                                |    4 +-
 install/ui/aci.js                      |   71 ++++++++++++++----
 install/ui/associate.js                |  128 ++++++++++++++++----------------
 install/ui/dialog.js                   |    3 +-
 install/ui/entity.js                   |   70 +-----------------
 install/ui/group.js                    |   33 +++++---
 install/ui/hbacrule.js                 |    2 +-
 install/ui/hbacsvcgroup.js             |    6 --
 install/ui/host.js                     |   35 ++++++---
 install/ui/hostgroup.js                |   22 ++++++
 install/ui/netgroup.js                 |   43 +++++++++++
 install/ui/search.js                   |    2 +-
 install/ui/service.js                  |   16 ++---
 install/ui/sudocmdgroup.js             |    6 --
 install/ui/test/association_tests.html |    2 +
 install/ui/test/association_tests.js   |   22 ++----
 install/ui/test/data/ipa_init.json     |   21 +----
 install/ui/user.js                     |   29 +++++--
 ipalib/plugins/service.py              |    3 +
 19 files changed, 281 insertions(+), 237 deletions(-)

diff --git a/API.txt b/API.txt
index fab224134343f789680050a5d04fea6560d44816..f4f312675e274b33c3763c26a407e459feff8c0e 100644
--- a/API.txt
+++ b/API.txt
@@ -2118,8 +2118,8 @@ option: Int('sizelimit?', autofill=False, flags=['no_display'], label=Gettext('S
 option: Flag('all', autofill=True, cli_name='all', default=False, exclude='webui', flags=['no_output'])
 option: Flag('raw', autofill=True, cli_name='raw', default=False, exclude='webui', flags=['no_output'])
 option: Str('version?', exclude='webui', flags=['no_option', 'no_output'])
-option: List('host?', cli_name='hosts',ist('host?', cli_name='hosts', doc='only services with member hosts', label='host', multivalue=True)
-option: List('no_host?', cli_name='no_hosts',ist('no_host?', cli_name='no_hosts', doc='only services with no member hosts', label='host', multivalue=True)
+option: List('man_by_host?', cli_name='man_by_hosts',ist('man_by_host?', cli_name='man_by_hosts', doc='only services with managed by hosts', label='host', multivalue=True)
+option: List('not_man_by_host?', cli_name='not_man_by_hosts',ist('not_man_by_host?', cli_name='not_man_by_hosts', doc='only services with no managed by hosts', label='host', multivalue=True)
 output: Output('summary', (<type 'unicode'>, <type 'NoneType'>), 'User-friendly description of action performed')
 output: ListOfEntries('result', (<type 'list'>, <type 'tuple'>), Gettext('A list of LDAP entries', domain='ipa', localedir=None))
 output: Output('count', <type 'int'>, 'Number of entries returned')
diff --git a/install/ui/aci.js b/install/ui/aci.js
index 89caec040ea28e97406f336832bb4c4f26793b7b..c72037605497212798f68f9bcf3efaa40875a9e7 100644
--- a/install/ui/aci.js
+++ b/install/ui/aci.js
@@ -559,8 +559,13 @@ IPA.entity_factories.permission = function() {
                     IPA.stanza({name:'identity', label:'Identity'}).
                         input({name: 'cn', 'read_only': true})).
                 section(IPA.rights_section()).
-                section(IPA.target_section({name: 'target', label: 'Target'})));
-
+                section(IPA.target_section({name: 'target', label: 'Target'}))).
+        facet(
+            IPA.association_facet({
+                name: 'member_privilege',
+                attribute_member: 'member',
+                other_entity: 'privilege'})).
+        standard_associations();
 };
 
 
@@ -586,14 +591,25 @@ IPA.entity_factories.privilege = function() {
                     IPA.stanza({name:'identity', label:'Privilege Settings'}).
                         input({name:'cn'}).
                         input({name: 'description'}))).
-    association({
-        name: 'permission',
-        other_entity: 'privilege',
-        add_method: 'add_permission',
-        remove_method: 'remove_permission'
-    }).
+        facet(
+            IPA.association_facet({
+                name: 'member_role',
+                attribute_member: 'member',
+                other_entity: 'role',
+                add_method: 'add_privilege',
+                remove_method: 'remove_privilege',
+                associator: IPA.serial_associator
+            })).
+        facet(
+            IPA.association_facet({
+                name: 'memberof_permission',
+                attribute_member: 'memberof',
+                other_entity: 'permission',
+                add_method: 'add_permission',
+                remove_method: 'remove_permission'
+            })).
 
-    standard_associations();
+        standard_associations();
 
 
     return that;
@@ -622,11 +638,38 @@ IPA.entity_factories.role = function() {
                     IPA.stanza({name:'identity', label:'Role Settings'}).
                         input({name:'cn'}).
                         input({name: 'description'}))).
-        association({
-            name: 'privilege',
-            add_method: 'add_privilege',
-            remove_method: 'remove_privilege'
-        }).
+        facet(
+            IPA.association_facet({
+                name: 'member_user',
+                attribute_member: 'member',
+                other_entity: 'user'
+            })).
+        facet(
+            IPA.association_facet({
+                name: 'member_group',
+                attribute_member: 'member',
+                other_entity: 'group'
+            })).
+        facet(
+            IPA.association_facet({
+                name: 'member_host',
+                attribute_member: 'member',
+                other_entity: 'host'
+            })).
+        facet(
+            IPA.association_facet({
+                name: 'member_hostgroup',
+                attribute_member: 'member',
+                other_entity: 'hostgroup'
+            })).
+        facet(
+            IPA.association_facet({
+                name: 'memberof_privilege',
+                attribute_member: 'memberof',
+                other_entity: 'privilege',
+                add_method: 'add_privilege',
+                remove_method: 'remove_privilege'
+            })).
         standard_associations();
 };
 
diff --git a/install/ui/associate.js b/install/ui/associate.js
index 2d416f0fd7482bb53ffa80addec5e92c2299cdb8..f4a07d60ff86c5508174cc4d7b864f7420d17578 100644
--- a/install/ui/associate.js
+++ b/install/ui/associate.js
@@ -51,7 +51,7 @@ IPA.associator = function (spec) {
 /**
 *This associator is built for the case where each association requires a separate rpc
 */
-function serial_associator(spec) {
+IPA.serial_associator = function(spec) {
 
     spec = spec || {};
 
@@ -74,23 +74,27 @@ function serial_associator(spec) {
         var options = {};
         options[that.entity_name] = that.pkey;
 
-        IPA.cmd(
-            that.method,
-            args,
-            options,
-            that.execute,
-            that.on_error,
-            that.other_entity);
+        var command = IPA.command({
+            method: that.other_entity+'_'+that.method,
+            args: args,
+            options: options,
+            on_success: that.execute,
+            on_error: that.on_error
+        });
+
+        //alert(JSON.stringify(command.to_json()));
+
+        command.execute();
     };
 
     return that;
-}
+};
 
 /**
 *This associator is for the common case where all the asociations can be sent
 in a single rpc
 */
-function bulk_associator(spec) {
+IPA.bulk_associator = function(spec) {
 
     spec = spec || {};
 
@@ -117,17 +121,21 @@ function bulk_associator(spec) {
         var options = { 'all': true };
         options[that.other_entity] = value;
 
-        IPA.cmd(
-            that.method,
-            args,
-            options,
-            that.on_success,
-            that.on_error,
-            that.entity_name);
+        var command = IPA.command({
+            method: that.entity_name+'_'+that.method,
+            args: args,
+            options: options,
+            on_success: that.on_success,
+            on_error: that.on_error
+        });
+
+        //alert(JSON.stringify(command.to_json()));
+
+        command.execute();
     };
 
     return that;
-}
+};
 
 /**
  * This dialog is used for adding associations between two entities.
@@ -228,7 +236,7 @@ IPA.association_deleter_dialog = function (spec) {
     that.on_success = spec.on_success;
     that.on_error = spec.on_error;
 
-    that.remove = function() {
+    that.execute = function() {
 
         var associator = that.associator({
             'entity_name': that.entity_name,
@@ -271,7 +279,7 @@ IPA.association_table_widget = function (spec) {
     that.other_entity = spec.other_entity;
     that.attribute_member = spec.attribute_member;
 
-    that.associator = spec.associator || bulk_associator;
+    that.associator = spec.associator || IPA.bulk_associator;
     that.add_method = spec.add_method || 'add_member';
     that.remove_method = spec.remove_method || 'remove_member';
 
@@ -296,16 +304,7 @@ IPA.association_table_widget = function (spec) {
     that.init = function() {
 
         var entity = IPA.get_entity(that.entity_name);
-        var association = entity.get_association(that.other_entity);
         var column;
-        if (association) {
-            if (association.associator) {
-                that.associator = association.associator == 'serial' ? serial_associator : bulk_associator;
-            }
-
-            if (association.add_method) that.add_method = association.add_method;
-            if (association.remove_method) that.remove_method = association.remove_method;
-        }
 
         // create a column if none defined
         if (!that.columns.length) {
@@ -523,7 +522,7 @@ IPA.association_table_widget = function (spec) {
             method: that.remove_method
         });
 
-        dialog.remove = function() {
+        dialog.execute = function() {
             that.remove(
                 selected_values,
                 function() {
@@ -574,8 +573,9 @@ IPA.association_facet = function (spec) {
     that.other_entity = spec.other_entity;
     that.facet_group = spec.facet_group;
     that.attribute_member = spec.attribute_member;
+    that.label = that.label ? that.label : (IPA.metadata[that.other_entity] ? IPA.metadata[that.other_entity].label : that.other_entity);
 
-    that.associator = spec.associator || bulk_associator;
+    that.associator = spec.associator || IPA.bulk_associator;
     that.add_method = spec.add_method || 'add_member';
     that.remove_method = spec.remove_method || 'remove_member';
 
@@ -620,19 +620,9 @@ IPA.association_facet = function (spec) {
         that.facet_init();
 
         var entity = IPA.get_entity(that.entity_name);
-        var association = entity.get_association(that.other_entity);
         var column;
         var i;
 
-        if (association) {
-            if (association.associator) {
-                that.associator = association.associator == 'serial' ? serial_associator : bulk_associator;
-            }
-
-            if (association.add_method) that.add_method = association.add_method;
-            if (association.remove_method) that.remove_method = association.remove_method;
-        }
-
         var label = IPA.metadata[that.other_entity] ? IPA.metadata[that.other_entity].label : that.other_entity;
         var pkey_name = IPA.metadata[that.other_entity].primary_key;
 
@@ -734,14 +724,11 @@ IPA.association_facet = function (spec) {
             'value': IPA.messages.button.remove
         }).appendTo(li);
 
-        /* TODO: genering handling of different relationships */
-        if ((relationship[0] == 'Member')||(relationship[0] == 'Member Of')) {
-            $('<input/>', {
-                'type': 'button',
-                'name': 'add',
-                'value': IPA.messages.button.enroll
-            }).appendTo(li);
-        }
+        $('<input/>', {
+            'type': 'button',
+            'name': 'add',
+            'value': IPA.messages.button.enroll
+        }).appendTo(li);
     };
 
     that.setup = function(container) {
@@ -830,23 +817,34 @@ IPA.association_facet = function (spec) {
         var title = 'Remove '+label+' from '+that.entity_name+' '+pkey;
 
         var dialog = IPA.association_deleter_dialog({
-            'title': title,
-            'entity_name': that.entity_name,
-            'pkey': pkey,
-            'other_entity': that.other_entity,
-            'values': values,
-            'associator': that.associator,
-            'method': that.remove_method,
-            'on_success': function() {
-                that.refresh();
-                dialog.close();
-            },
-            'on_error': function() {
-                that.refresh();
-                dialog.close();
-            }
+            title: title,
+            entity_name: that.entity_name,
+            pkey: pkey,
+            other_entity: that.other_entity,
+            values: values
         });
 
+        dialog.execute = function() {
+
+            var associator = that.associator({
+                entity_name: that.entity_name,
+                pkey: pkey,
+                other_entity: that.other_entity,
+                values: values,
+                method: that.remove_method,
+                on_success: function() {
+                    that.refresh();
+                    dialog.close();
+                },
+                on_error: function() {
+                    that.refresh();
+                    dialog.close();
+                }
+            });
+
+            associator.execute();
+        };
+
         dialog.init();
 
         dialog.open(that.container);
@@ -919,7 +917,7 @@ IPA.association_facet = function (spec) {
         }
 
         var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
-        IPA.cmd('show', [pkey], {'rights': true}, on_success, on_error, that.entity_name);
+        IPA.cmd('show', [pkey], {'all': true, 'rights': true}, on_success, on_error, that.entity_name);
     };
 
     that.association_facet_init = that.init;
diff --git a/install/ui/dialog.js b/install/ui/dialog.js
index 4733b7814c845fa9862af95d1d2df8fa95349b6b..9d94786ae0d67f34ecfbc96087f4c21552223575 100644
--- a/install/ui/dialog.js
+++ b/install/ui/dialog.js
@@ -512,7 +512,6 @@ IPA.deleter_dialog =  function (spec) {
     var that = IPA.dialog(spec);
 
     that.title = spec.title || IPA.messages.button.remove;
-    that.remove = spec.remove;
 
     that.values = spec.values || [];
 
@@ -546,7 +545,7 @@ IPA.deleter_dialog =  function (spec) {
 
     that.open = function(container) {
         that.buttons = {
-            'Delete': that.remove,
+            'Delete': that.execute,
             'Cancel': that.close
         };
 
diff --git a/install/ui/entity.js b/install/ui/entity.js
index fdc45d8272fdbf1a0f60d33832ff2cfccbd5a1be..ff2274556b0150f4fd501dcf7975677f2c01d0b3 100644
--- a/install/ui/entity.js
+++ b/install/ui/entity.js
@@ -122,9 +122,6 @@ IPA.entity = function (spec) {
 
     that.autogenerate_associations = false;
 
-    that.associations = [];
-    that.associations_by_name = {};
-
     that.get_dialog = function(name) {
         return that.dialogs_by_name[name];
     };
@@ -166,32 +163,6 @@ IPA.entity = function (spec) {
         return that;
     };
 
-    that.get_associations = function() {
-        return that.associations;
-    };
-
-    that.get_association = function(name) {
-        return that.associations_by_name[name];
-    };
-
-    that.add_association = function(config) {
-        that.associations.push(config);
-        that.associations_by_name[config.name] = config;
-    };
-
-    that.create_association = function(spec) {
-        var config = IPA.association_config(spec);
-        that.add_association(config);
-        return config;
-    };
-
-    that.association = function(spec) {
-        var config = IPA.association_config(spec);
-        that.add_association(config);
-        return that;
-    };
-
-
     that.create_association_facet = function(attribute_member, other_entity, label, facet_group) {
 
         if (!attribute_member) {
@@ -203,18 +174,13 @@ IPA.entity = function (spec) {
 
         //TODO remove from the facets and facets_by_name collections
         var facet = that.get_facet(association_name);
-        if (facet){
+        if (facet) {
             facet.facet_group = facet_group;
             facet.attribute_member =  attribute_member;
             return;
         }
 
-        var config = that.get_association(other_entity);
-        if (!config){
-            config = that.get_association(association_name);
-        }
-
-        var spec ={
+        var spec = {
             'name': association_name,
             'label': label,
             'other_entity': other_entity,
@@ -222,18 +188,7 @@ IPA.entity = function (spec) {
             'attribute_member': attribute_member
         };
 
-        if (config){
-            for (var key in config){
-                /*name is special, as iut has already been munged 
-                  into the association name */
-                if (key === "name"){
-                    continue;
-                }
-                spec[key] = config[key] ;
-            }
-        }
-
-        facet =  IPA.association_facet(spec);
+        facet = IPA.association_facet(spec);
 
         that.add_facet(facet);
     };
@@ -381,25 +336,6 @@ IPA.entity_set_details_definition = function (entity_name, sections) {
     }
 };
 
-
-IPA.entity_set_association_definition = function (entity_name, data) {
-
-    var entity = IPA.fetch_entity(entity_name);
-
-    entity.autogenerate_associations = true;
-
-    for (var other_entity in data) {
-        var config = data[other_entity];
-        entity.create_association({
-            'name': other_entity,
-            'associator': config.associator,
-            'add_method': config.add_method,
-            'remove_method': config.remove_method
-        });
-    }
-};
-
-
 IPA.entity_set_facet_definition = function (entity_name, list) {
 
     var entity = IPA.fetch_entity(entity_name);
diff --git a/install/ui/group.js b/install/ui/group.js
index f7e7e51f888e68349f7ca0332d8b1d927720cfb0..58083c828010a027137111d262490c1603aad2d6 100644
--- a/install/ui/group.js
+++ b/install/ui/group.js
@@ -61,18 +61,27 @@ IPA.entity_factories.group =  function () {
                 'label': 'Users',
                 'other_entity': 'user'
             })).
-        association({
-            name: 'netgroup',
-            associator: 'serial'
-        }).
-        association({
-            name: 'rolegroup',
-            associator: 'serial'
-        }).
-        association({
-            name: 'taskgroup',
-            associator: 'serial'
-        }).
+        facet(
+            IPA.association_facet({
+                name: 'memberof_group',
+                attribute_member: 'memberof',
+                other_entity: 'group',
+                associator: IPA.serial_associator
+            })).
+        facet(
+            IPA.association_facet({
+                name: 'memberof_netgroup',
+                attribute_member: 'memberof',
+                other_entity: 'netgroup',
+                associator: IPA.serial_associator
+            })).
+        facet(
+            IPA.association_facet({
+                name: 'memberof_role',
+                attribute_member: 'memberof',
+                other_entity: 'role',
+                associator: IPA.serial_associator
+            })).
         standard_associations();
 };
 
diff --git a/install/ui/hbacrule.js b/install/ui/hbacrule.js
index 9525f2b79d58ee4cb179e7990ae600ea90639ef1..004c9c5d0f5390e8fee8324b43302fc844c97c7a 100644
--- a/install/ui/hbacrule.js
+++ b/install/ui/hbacrule.js
@@ -958,7 +958,7 @@ IPA.hbacrule_accesstime_widget = function (spec) {
             'values': values
         });
 
-        dialog.remove = function() {
+        dialog.execute = function() {
 
             var batch = IPA.batch_command({
                 'on_success': function() {
diff --git a/install/ui/hbacsvcgroup.js b/install/ui/hbacsvcgroup.js
index e0f476b99262409848665789f22f7def8dd46379..61bce15e755672d3daedfb2781343243f0ae37e4 100644
--- a/install/ui/hbacsvcgroup.js
+++ b/install/ui/hbacsvcgroup.js
@@ -30,12 +30,6 @@ IPA.entity_factories.hbacsvcgroup = function () {
 
     that.init = function() {
 
-        that.create_association({
-            'name': 'hbacsvc',
-            'add_method': 'add_member',
-            'remove_method': 'remove_member'
-        });
-
         var facet = IPA.hbacsvcgroup_search_facet({
             'name': 'search',
             'label': 'Search'
diff --git a/install/ui/host.js b/install/ui/host.js
index 7f56aeee46d4764b0df7ab133830e42006517173..3bb112ffeaaff171e8fe1897d44865c2115a9893 100644
--- a/install/ui/host.js
+++ b/install/ui/host.js
@@ -32,16 +32,6 @@ IPA.entity_factories.host = function () {
 
     that.init = function() {
 
-        that.create_association({
-            'name': 'hostgroup',
-            'associator': 'serial'
-        });
-
-        that.create_association({
-            'name': 'rolegroup',
-            'associator': 'serial'
-        });
-
         var facet = IPA.host_search_facet({
             'name': 'search',
             'label': 'Search'
@@ -61,11 +51,34 @@ IPA.entity_factories.host = function () {
 
         facet = IPA.host_managedby_host_facet({
             'name': 'managedby_host',
-            'label': IPA.messages.association.managedby+' '+IPA.metadata['host'].label,
             'other_entity': 'host'
         });
         that.add_facet(facet);
 
+        facet = IPA.association_facet({
+            name: 'memberof_hostgroup',
+            attribute_member: 'memberof',
+            other_entity: 'hostgroup',
+            associator: IPA.serial_associator
+        });
+        that.add_facet(facet);
+
+        facet = IPA.association_facet({
+            name: 'memberof_netgroup',
+            attribute_member: 'memberof',
+            other_entity: 'netgroup',
+            associator: IPA.serial_associator
+        });
+        that.add_facet(facet);
+
+        facet = IPA.association_facet({
+            name: 'memberof_role',
+            attribute_member: 'memberof',
+            other_entity: 'role',
+            associator: IPA.serial_associator
+        });
+        that.add_facet(facet);
+
         that.create_association_facets();
 
         that.entity_init();
diff --git a/install/ui/hostgroup.js b/install/ui/hostgroup.js
index 9c66ff6139d62812af87216ebb08ba8b372819df..90b1f14798ebc28f1ccf5df483f6be2557a00736 100644
--- a/install/ui/hostgroup.js
+++ b/install/ui/hostgroup.js
@@ -54,6 +54,28 @@ IPA.entity_factories.hostgroup = function() {
                         input({name:'cn'}).
                         input({name: 'description'})));
 
+        that.facet(
+            IPA.association_facet({
+                name: 'member_host',
+                attribute_member: 'member',
+                other_entity: 'host'
+            }));
+
+        that.facet(
+            IPA.association_facet({
+                name: 'member_hostgroup',
+                attribute_member: 'member',
+                other_entity: 'hostgroup'
+            }));
+
+        that.facet(
+            IPA.association_facet({
+                name: 'memberof_hostgroup',
+                attribute_member: 'memberof',
+                other_entity: 'hostgroup',
+                associator: IPA.serial_associator
+            }));
+
         that.create_association_facets();
         that.entity_init();
     };
diff --git a/install/ui/netgroup.js b/install/ui/netgroup.js
index d7908ef3279aca961984d21e8fde026c434e4590..f97f5cdf07056426c43840df85691d5a887f06e8 100644
--- a/install/ui/netgroup.js
+++ b/install/ui/netgroup.js
@@ -54,6 +54,49 @@ IPA.entity_factories.netgroup = function() {
                         input({name: 'description'}).
                         input({name: 'nisdomainname'})));
 
+        that.facet(
+            IPA.association_facet({
+                name: 'member_netgroup',
+                attribute_member: 'member',
+                other_entity: 'netgroup'
+            }));
+
+        that.facet(
+            IPA.association_facet({
+                name: 'memberhost_host',
+                attribute_member: 'memberhost',
+                other_entity: 'host'
+            }));
+
+        that.facet(
+            IPA.association_facet({
+                name: 'memberhost_hostgroup',
+                attribute_member: 'memberhost',
+                other_entity: 'hostgroup'
+            }));
+
+        that.facet(
+            IPA.association_facet({
+                name: 'memberuser_user',
+                attribute_member: 'memberuser',
+                other_entity: 'user'
+            }));
+
+        that.facet(
+            IPA.association_facet({
+                name: 'memberuser_group',
+                attribute_member: 'memberuser',
+                other_entity: 'group'
+            }));
+
+        that.facet(
+            IPA.association_facet({
+                name: 'memberof_netgroup',
+                attribute_member: 'memberof',
+                other_entity: 'netgroup',
+                associator: IPA.serial_associator
+            }));
+
         that.create_association_facets();
         that.entity_init();
     };
diff --git a/install/ui/search.js b/install/ui/search.js
index 9130613f660eb4042c8ace488a5e27418e8fe360..c2f41f7c394ae37c6c981bfa0a80e1e8e99d6fab 100644
--- a/install/ui/search.js
+++ b/install/ui/search.js
@@ -189,7 +189,7 @@ IPA.search_widget = function (spec) {
             'values': values
         });
 
-        dialog.remove = function() {
+        dialog.execute = function() {
 
             var batch = IPA.batch_command({
                 'on_success': function() {
diff --git a/install/ui/service.js b/install/ui/service.js
index 7fc1547223c08d8bc574284764ae2e4886ed8b46..5cfa470ba08cd1ec8ebec9cff6100db71f12d193 100644
--- a/install/ui/service.js
+++ b/install/ui/service.js
@@ -28,11 +28,6 @@ IPA.entity_factories.service = function() {
     return  IPA.entity({
         name: 'service'
     }).
-        association({
-            name: 'host',
-            add_method: 'add_host',
-            remove_method: 'remove_host'
-        }).
         facet(
             IPA.search_facet().
                 column({name: 'krbprincipalname'}).
@@ -44,11 +39,12 @@ IPA.entity_factories.service = function() {
                     }))).
         facet(IPA.service_details_facet()).
         facet(IPA.service_managedby_host_facet({
-            name: 'managedby_host',
-            label: IPA.messages.association.managedby +
-                ' '+IPA.metadata['host'].label,
-            other_entity: 'host'
-        }));
+                name: 'managedby_host',
+                other_entity: 'host',
+                add_method: 'add_host',
+                remove_method: 'remove_host'
+            })).
+        standard_associations();
 };
 
 
diff --git a/install/ui/sudocmdgroup.js b/install/ui/sudocmdgroup.js
index 8e45341f374168e0cdf5c1ed72fa1298fa5695d8..d99bb61f553e4c75481d8ad7bae1763fa66e229c 100644
--- a/install/ui/sudocmdgroup.js
+++ b/install/ui/sudocmdgroup.js
@@ -30,12 +30,6 @@ IPA.entity_factories.sudocmdgroup = function () {
 
     that.init = function() {
 
-        that.create_association({
-            'name': 'sudocmd',
-            'add_method': 'add_member',
-            'remove_method': 'remove_member'
-        });
-
         var facet = IPA.sudocmdgroup_search_facet({
             'name': 'search',
             'label': 'Search'
diff --git a/install/ui/test/association_tests.html b/install/ui/test/association_tests.html
index 40b3c208d37190edcd885ac41798ece0a259f406..383c9b0b6c5fd273b130a6f6fa7142b098874a51 100644
--- a/install/ui/test/association_tests.html
+++ b/install/ui/test/association_tests.html
@@ -5,6 +5,8 @@
     <link rel="stylesheet" href="qunit.css" type="text/css" media="screen">
     <script type="text/javascript" src="qunit.js"></script>
     <script type="text/javascript" src="../jquery.js"></script>
+    <script type="text/javascript" src="../jquery.ba-bbq.js"></script>
+    <script type="text/javascript" src="../jquery-ui.js"></script>
     <script type="text/javascript" src="../ipa.js"></script>
     <script type="text/javascript" src="../details.js"></script>
     <script type="text/javascript" src="../search.js"></script>
diff --git a/install/ui/test/association_tests.js b/install/ui/test/association_tests.js
index a65678a7feb650895601633e56a7887edfa101b1..41b113d76bbea2395ab25c8414fce9186ca0ff93 100644
--- a/install/ui/test/association_tests.js
+++ b/install/ui/test/association_tests.js
@@ -23,7 +23,7 @@ module('associate');
 
 test("Testing serial_associator().", function() {
 
-    expect(10);
+    expect(7);
 
     var orig_ipa_cmd = IPA.cmd;
 
@@ -42,16 +42,11 @@ test("Testing serial_associator().", function() {
         counter++;
 
         equals(
-            name, params.method,
+            name, params.other_entity+'_'+params.method,
             "Checking IPA.cmd() parameter: method"
         );
 
         equals(
-            objname, params.other_entity,
-            "Checking IPA.cmd() parameter: object name"
-        );
-
-        equals(
             args[0], "user"+counter,
             "Checking IPA.cmd() parameter: primary key"
         );
@@ -65,7 +60,7 @@ test("Testing serial_associator().", function() {
         ok(true, "on_success() is invoked.");
     };
 
-    var associator = serial_associator(params);
+    var associator = IPA.serial_associator(params);
     associator.execute();
 
     IPA.cmd = orig_ipa_cmd;
@@ -73,7 +68,7 @@ test("Testing serial_associator().", function() {
 
 test("Testing bulk_associator().", function() {
 
-    expect(5);
+    expect(4);
 
     var orig_ipa_cmd = IPA.cmd;
 
@@ -92,16 +87,11 @@ test("Testing bulk_associator().", function() {
         counter++;
 
         equals(
-            name, params.method,
+            name, params.entity_name+'_'+params.method,
             "Checking IPA.cmd() parameter: method"
         );
 
         equals(
-            objname, params.entity_name,
-            "Checking IPA.cmd() parameter: object name"
-        );
-
-        equals(
             args[0], params.pkey,
             "Checking IPA.cmd() parameter: primary key"
         );
@@ -120,7 +110,7 @@ test("Testing bulk_associator().", function() {
         ok(true, "on_success() is invoked.");
     };
 
-    var associator = bulk_associator(params);
+    var associator = IPA.bulk_associator(params);
     associator.execute();
 
     IPA.cmd = orig_ipa_cmd;
diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json
index 862a9972f399a6897231a3e97f0f30d6c25358b1..d25f61033d6d7c491a05a7efbd9ce7e96b2f7bf6 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -4713,7 +4713,6 @@
                         ], 
                         "attribute_members": {
                             "member": [
-                                "permission", 
                                 "role"
                             ], 
                             "memberof": [
@@ -5434,22 +5433,12 @@
                         "primary_key": "krbprincipalname", 
                         "rdn_attribute": "", 
                         "relationships": {
-                            "member": [
-                                "Member", 
-                                "", 
-                                "no_"
-                            ], 
-                            "memberindirect": [
-                                "Indirect Member", 
-                                null, 
-                                "no_indirect_"
-                            ], 
-                            "memberof": [
-                                "Member Of", 
-                                "in_", 
-                                "not_in_"
+                            "managedby": [
+                                "Managed by",
+                                "man_by_",
+                                "not_man_by_"
                             ]
-                        }, 
+                        },
                         "takes_params": [
                             {
                                 "alwaysask": false, 
diff --git a/install/ui/user.js b/install/ui/user.js
index f60a511c6f5e52a6cef4236982ebee45038d793f..fb680a6e3ce108444be224739099f5baa5540ce5 100644
--- a/install/ui/user.js
+++ b/install/ui/user.js
@@ -28,14 +28,6 @@ IPA.entity_factories.user = function() {
     return IPA.entity({
         name: 'user'
     }).
-        association({
-            'name': 'group',
-            'associator': 'serial'
-        }).
-        association({
-            'name': 'netgroup',
-            'associator': 'serial'
-        }).
         facet(
             IPA.search_facet().
                 column({name:'cn'}).
@@ -90,6 +82,27 @@ IPA.entity_factories.user = function() {
             section(
                 IPA.stanza({name: 'misc', label: IPA.messages.details.misc}).
                     input({name:'carlicense'}))).
+        facet(
+            IPA.association_facet({
+                name: 'memberof_group',
+                attribute_member: 'memberof',
+                other_entity: 'group',
+                associator: IPA.serial_associator
+            })).
+        facet(
+            IPA.association_facet({
+                name: 'memberof_netgroup',
+                attribute_member: 'memberof',
+                other_entity: 'netgroup',
+                associator: IPA.serial_associator
+            })).
+        facet(
+            IPA.association_facet({
+                name: 'memberof_role',
+                attribute_member: 'memberof',
+                other_entity: 'role',
+                associator: IPA.serial_associator
+            })).
         standard_associations();
 };
 
diff --git a/ipalib/plugins/service.py b/ipalib/plugins/service.py
index 970ed04371494d9755e159c6924a687217008f52..3e0fb1387db2ee6edbc3dba7eaa34c4d376bd5fe 100644
--- a/ipalib/plugins/service.py
+++ b/ipalib/plugins/service.py
@@ -288,6 +288,9 @@ class service(LDAPObject):
         'managedby': ['host'],
     }
     bindable = True
+    relationships = {
+        'managedby': ('Managed by', 'man_by_', 'not_man_by_'),
+    }
 
     label = _('Services')
 
-- 
1.6.6.1

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

Reply via email to