Questo contenuto non è disponibile nella lingua selezionata.
Chapter 2. Role Management
2.1. Role Management Copia collegamentoCollegamento copiato negli appunti!
OpenStack uses a role-based access control (RBAC) mechanism to manage access to its resources. Roles define which actions users can perform. By default, there are two predefined roles: a member role that gets attached to a tenant, and an administrative role to enable non-admin users to administer the environment. Note that there are abstract levels of permission, and it is possible to create the roles the administrator needs, and configure services adequately.
2.1.1. View Roles Copia collegamentoCollegamento copiato negli appunti!
Use the following command to list the available predefined roles.
To get details for a specified role, run:
keystone role-get [ROLE]
$ keystone role-get [ROLE]
Example
2.1.2. Create and Assign a Role Copia collegamentoCollegamento copiato negli appunti!
As a cloud administrator, you can create and manage roles on the Keystone client using the following set of commands. Each OpenStack deployment must include at least one project, one user, and one role, linked together. However, users can be members of multiple projects. To assign users to multiple projects, create a role and assign that role to a user-project pair. Note that you can create a user and assign a primary project and default role in the dashboard.
Either the name or ID can be used to specify users, roles, or projects.
Create the
new-role
role:keystone role-create --name [ROLE_NAME]
$ keystone role-create --name [ROLE_NAME]
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To assign a user to a project, you must assign the role to a user-project pair. To do this, obtain the user, role, and project names or IDs:
List users:
keystone user-list
$ keystone user-list
Copy to Clipboard Copied! Toggle word wrap Toggle overflow List roles:
keystone role-list
$ keystone role-list
Copy to Clipboard Copied! Toggle word wrap Toggle overflow List projects:
keystone tenant-list
$ keystone tenant-list
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Assign a role to a user-project pair.
keystone user-role-add --user [USER_NAME] --role [ROLE_NAME] --tenant [TENANT_NAME]
$ keystone user-role-add --user [USER_NAME] --role [ROLE_NAME] --tenant [TENANT_NAME]
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example
In this example, you assign the
new-role
role to thedemo
-demo
pair:keystone user-role-add --user demo --role new-role --tenant demo
$ keystone user-role-add --user demo --role new-role --tenant demo
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the role assignment for the user
demo
:keystone user-role-list --user [USER_NAME] --tenant [TENANT_NAME]
$ keystone user-role-list --user [USER_NAME] --tenant [TENANT_NAME]
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example
keystone user-role-list --user demo --tenant demo
$ keystone user-role-list --user demo --tenant demo
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.1.3. Delete a Role Copia collegamentoCollegamento copiato negli appunti!
Use the following command to delete a role from a user-project pair. Deleting a role ensures the associated user-project pairing is lost.
keystone user-role-remove --user [USER_NAME] --role [ROLE] --tenant [TENANT_NAME]
$ keystone user-role-remove --user [USER_NAME] --role [ROLE] --tenant [TENANT_NAME]
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the role removal:
keystone user-role-list --user [USER_NAME] --tenant [TENANT_NAME]
$ keystone user-role-list --user [USER_NAME] --tenant [TENANT_NAME]
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If the role was removed, the command output omits the removed role.