此内容没有您所选择的语言版本。
Chapter 2. Role Management
2.1. Role Management 复制链接链接已复制到粘贴板!
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 复制链接链接已复制到粘贴板!
Use the following command to list the available predefined roles.
To get details for a specified role, run:
openstack role show admin
$ openstack role show admin
Example
2.1.2. Create and Assign a Role 复制链接链接已复制到粘贴板!
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-rolerole:openstack role create [ROLE_NAME]
$ openstack role create [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:
openstack user list
$ openstack user listCopy to Clipboard Copied! Toggle word wrap Toggle overflow List roles:
openstack role list
$ openstack role listCopy to Clipboard Copied! Toggle word wrap Toggle overflow List projects:
openstack project list
$ openstack project listCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Assign a role to a user-project pair.
openstack role add --project [PROJECT_NAME] --user [USER_ID] [ROLE_ID]
openstack role add --project [PROJECT_NAME] --user [USER_ID] [ROLE_ID]Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example
In this example, you assign the
adminrole to theadminuser in thedemoproject:openstack role add --project demo --user 895e43465b9643b9aa29df0073572bb2 ae49e2b796ea4820ac51637be27650d8
$ openstack role add --project demo --user 895e43465b9643b9aa29df0073572bb2 ae49e2b796ea4820ac51637be27650d8Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the role assignment for the user
admin:openstack role assignment list --user [USER_ID] --project [PROJECT_ID]
$ openstack role assignment list --user [USER_ID] --project [PROJECT_ID]Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example
Copy to Clipboard Copied! Toggle word wrap Toggle overflow