Skip to content
This repository was archived by the owner on Sep 16, 2020. It is now read-only.

Add role management#180

Merged
AlanCoding merged 9 commits intoansible:masterfrom
AlanCoding:roles
Jul 29, 2016
Merged

Add role management#180
AlanCoding merged 9 commits intoansible:masterfrom
AlanCoding:roles

Conversation

@AlanCoding
Copy link
Member

Example command:

$ tower-cli role grant --user new_user --credential pi --type admin
== ==== ===== ========== 
id user type  credential 
== ==== ===== ========== 
62   10 admin          2
== ==== ===== ========== 

@jangsutsr jangsutsr self-assigned this Jul 28, 2016
@jangsutsr
Copy link
Contributor

Manually tested in sequence:

(tower_cli_devel) sitan-OSX:tower-cli sitan$ tower-cli role list --user 2 -v --insecure
*** DETAILS: Getting records. *************************************************
GET https://ec2-54-234-179-218.compute-1.amazonaws.com/api/v1/roles/
Params: {'members__in': 2, u'page': 1}

== ====== ============= ============= 
id  type  resource_name resource_type 
== ====== ============= ============= 
28 Admin  role          user
 4 Member Default       organization
== ====== ============= ============= 
(tower_cli_devel) sitan-OSX:tower-cli sitan$ tower-cli role grant --user 2 --inventory 1 --type use -v --insecure
*** DETAILS: Checking if role exists. *****************************************
GET https://ec2-54-234-179-218.compute-1.amazonaws.com/api/v1/inventories/1/object_roles/
Params: {'role_field': 'use_role'}

*** DETAILS: Checking if user already has role. *******************************
GET https://ec2-54-234-179-218.compute-1.amazonaws.com/api/v1/inventories/1/object_roles/
Params: {'members__in': 2, 'role_field': 'use_role'}

*** DETAILS: Attempting to add the user from this role. ***********************
POST https://ec2-54-234-179-218.compute-1.amazonaws.com/api/v1/users/2/roles/
Data: {'id': 18}

== ==== ==== ========= 
id user type inventory 
== ==== ==== ========= 
18    2 use          1
== ==== ==== ========= 
(tower_cli_devel) sitan-OSX:tower-cli sitan$ tower-cli role grant --user 2 --inventory 1 --type use -v --insecure
*** DETAILS: Checking if role exists. *****************************************
GET https://ec2-54-234-179-218.compute-1.amazonaws.com/api/v1/inventories/1/object_roles/
Params: {'role_field': 'use_role'}

*** DETAILS: Checking if user already has role. *******************************
GET https://ec2-54-234-179-218.compute-1.amazonaws.com/api/v1/inventories/1/object_roles/
Params: {'members__in': 2, 'role_field': 'use_role'}

*** DECISION: This user is already a member of the role. **********************
== ==== ==== ========= 
id user type inventory 
== ==== ==== ========= 
18    2 use          1
== ==== ==== ========= 
(tower_cli_devel) sitan-OSX:tower-cli sitan$ tower-cli role grant --user 2 --inventory 1 --type auditor -v --insecure
*** DETAILS: Checking if role exists. *****************************************
GET https://ec2-54-234-179-218.compute-1.amazonaws.com/api/v1/inventories/1/object_roles/
Params: {'role_field': 'auditor_role'}

Error: The requested object could not be found.
(tower_cli_devel) sitan-OSX:tower-cli sitan$ tower-cli role revoke --user 2 --inventory 1 --type use -v --insecure
*** DETAILS: Checking if role exists. *****************************************
GET https://ec2-54-234-179-218.compute-1.amazonaws.com/api/v1/inventories/1/object_roles/
Params: {'role_field': 'use_role'}

*** DETAILS: Checking if user already has role. *******************************
GET https://ec2-54-234-179-218.compute-1.amazonaws.com/api/v1/inventories/1/object_roles/
Params: {'members__in': 2, 'role_field': 'use_role'}

*** DETAILS: Attempting to remove the user from this role. ********************
POST https://ec2-54-234-179-218.compute-1.amazonaws.com/api/v1/users/2/roles/
Data: {'id': 18, 'disassociate': True}

== ==== ==== ========= 
id user type inventory 
== ==== ==== ========= 
18    2 use          1
== ==== ==== ========= 
(tower_cli_devel) sitan-OSX:tower-cli sitan$ tower-cli role revoke --user 2 --inventory 1 --type use -v --insecure
*** DETAILS: Checking if role exists. *****************************************
GET https://ec2-54-234-179-218.compute-1.amazonaws.com/api/v1/inventories/1/object_roles/
Params: {'role_field': 'use_role'}

*** DETAILS: Checking if user already has role. *******************************
GET https://ec2-54-234-179-218.compute-1.amazonaws.com/api/v1/inventories/1/object_roles/
Params: {'members__in': 2, 'role_field': 'use_role'}

*** DECISION: This user is already a non-member of the role. ******************
== ==== ==== ========= 
id user type inventory 
== ==== ==== ========= 
18    2 use          1
== ==== ==== ========= 
(tower_cli_devel) sitan-OSX:tower-cli sitan$ tower-cli role get 18 -v --insecure
*** DETAILS: Getting the role record. *****************************************
GET https://ec2-54-234-179-218.compute-1.amazonaws.com/api/v1/roles/18/
Params: {}

== ==== ============== ============= 
id type resource_name  resource_type 
== ==== ============== ============= 
18 Use  Demo Inventory inventory
== ==== ============== ============= 
(tower_cli_devel) sitan-OSX:tower-cli sitan$ tower-cli role get --user 2 -v --insecure
*** DETAILS: Getting the role record. *****************************************
GET https://ec2-54-234-179-218.compute-1.amazonaws.com/api/v1/roles/
Params: {'members__in': 2}

Error: Expected one result, got 2. Tighten your criteria.

Everything works as described in doc/help-text. Great Job! 👍

@jangsutsr jangsutsr added this to the release_2.4.0 milestone Jul 28, 2016
@coveralls
Copy link

coveralls commented Jul 28, 2016

Coverage Status

Coverage decreased (-0.1%) to 99.079% when pulling 76888ff on AlanCoding:roles into bb0e52e on ansible:master.

@coveralls
Copy link

coveralls commented Jul 29, 2016

Coverage Status

Coverage increased (+0.08%) to 99.252% when pulling 601acee on AlanCoding:roles into bb0e52e on ansible:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 99.079% when pulling 60c6c58 on AlanCoding:roles into 1270bdd on ansible:master.

@coveralls
Copy link

coveralls commented Jul 29, 2016

Coverage Status

Coverage increased (+0.08%) to 99.252% when pulling 60c6c58 on AlanCoding:roles into 1270bdd on ansible:master.

@AlanCoding AlanCoding merged commit 056a01a into ansible:master Jul 29, 2016
@AlanCoding AlanCoding removed the review label Jul 29, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants