From f6eebf97deb102abc1315087fa6d17e3b91a8898 Mon Sep 17 00:00:00 2001 From: Michal Minar Date: Thu, 7 Nov 2013 09:59:54 +0100 Subject: account: updated documentation Fixed examples for account provider. Some were syntactically wrong, others were very inefficient. --- doc/admin/account/usage.rst | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'doc') diff --git a/doc/admin/account/usage.rst b/doc/admin/account/usage.rst index 6d55851..9a28cd5 100644 --- a/doc/admin/account/usage.rst +++ b/doc/admin/account/usage.rst @@ -20,6 +20,9 @@ from following classes: Some common use cases are described in the following parts +.. note:: + Examples are written for ``lmishell`` version ``0.9``. + List users ---------- List of users are provided by :ref:`LMI_Account `. Each one object @@ -55,13 +58,16 @@ by :ref:`LMI_AssignedAccountIdentity ` with # Get users from root group # 1) Get root group object - root_group = c.root.cimv2.LMI_Group.first_instance({"Name": "root") + root_group = c.root.cimv2.LMI_Group.first_instance({"Name": "root"}) # 2) Get LMI_Identity objects associated with root group - identities = root_group.associators(ResultClass="LMI_Identity", AssocClass="LMI_MemberOfGroup") + identities = root_group.associators( + AssocClass="LMI_MemberOfGroup", ResultClass="LMI_Identity") # 3) go through all identites, get LMI_Account associated with identity and print user name # Note: associators returns a list, but there is just one LMI_Account for i in identities: - print i.first_associator(ResultClass="LMI_Account").Name + print i.first_associator( + AssocClass="LMI_AssignedAccountIdentity", + ResultClass="LMI_Account").Name Create user ----------- @@ -140,13 +146,15 @@ to :ref:`LMI_Group ` and :ref:`LMI_Identity `:: # We will add root user to pegasus group # get group pegasus - grp = c.root.cimv2.LMI_Group.first_instance({"Name": "pegasus"}) + grp = c.root.cimv2.LMI_Group.first_instance_name({"Name": "pegasus"}) # get user root acc = c.root.cimv2.LMI_Account.first_instance({"Name": "root"}) # get identity of root user - identity = acc.first_associator(ResultClass="LMI_Identity") + identity = acc.first_associator_name( + AssocClass='LMI_AssignedAccountIdentity', + ResultClass="LMI_Identity") # create instance of LMI_MemberOfGroup with the above references - c.root.cimv2.LMI_MemberOfGroup.create_instance({"Member":identity.path, "Collection":grp.path}) + c.root.cimv2.LMI_MemberOfGroup.create_instance({"Member":identity, "Collection":grp}) Remove user from group ---------------------- @@ -155,14 +163,16 @@ on the desired :ref:`LMI_MemberOfGroup ` object:: # We will remove root user from pegasus group # get group pegasus - grp = c.root.cimv2.LMI_Group.first_instance({"Name": "pegasus"}) + grp = c.root.cimv2.LMI_Group.first_instance_name({"Name": "pegasus"}) # get user root acc = c.root.cimv2.LMI_Account.first_instance({"Name": "root"}) # get identity of root user - identity = acc.associators(ResultClass="LMI_Identity")[0] + identity = acc.first_associator( + AssocClass="LMI_AssignedAccountIdentity", + ResultClass="LMI_Identity") # iterate through all LMI_MemberOfGroup associated with identity and remove the one with our group for mog in identity.references(ResultClass="LMI_MemberOfGroup"): - if mog.Collection == grp.path: + if mog.Collection == grp: mog.delete() Modify user -- cgit