Create a Project in OpenStack
Projects are used to group and isolate resources (instances, volumes, networks, etc.) and assign them to users. To create a new project (tenant) in OpenStack, you need administrative privileges.
Step 1: Source Your OpenStack RC File
First, source your OpenStack RC file to set the necessary environment variables for authentication.
sudo -i -u stack
cd ~/devstack
source openrc admin admin
Step 2: Create a New Project
Use the openstack project create
command to create a new project.
openstack project create <PROJECT_NAME>
Step 3: Verify the Project Creation
List the existing projects to ensure that your new project was created successfully.
openstack project list
Step 4: Create a User for the Project
You need to create or assign users to the new project. If you need to create a new user, use the openstack user create
command.
openstack user create --project <PROJECT_NAME> --password <PASSWORD> <USERNAME>
Step 5: Verify the User Creation
List the existing users to ensure that your new user was created successfully.
openstack user list
Step 6: Assign Roles to the User
You can list existing roles first and then assign a role to the user in the project. Typically, the "member" role is assigned.
openstack role list
openstack role add --project <PROJECT_NAME> --user <USERNAME> <ROLE>
Step 7: Verify User Assignment
To verify that the user has been assigned to the project with the appropriate role, list the role assignments.
openstack role assignment list --user <USERNAME> --project <PROJECT_NAME>
Step 8: Create an OpenStack RC File
Create a file (e.g., my-openrc
) with the following content, replacing the placeholders with your actual details.
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "Usage: source openrc <USERNAME> <PROJECT>"
return 1
fi
export OS_USERNAME=$1
export OS_PROJECT_NAME=$2
export OS_PASSWORD=<PASSWORD>
export OS_AUTH_URL=http://<KEYSTONE_ENDPOINT>/identity
export OS_USER_DOMAIN_NAME=default
export OS_PROJECT_DOMAIN_NAME=default
export OS_IDENTITY_API_VERSION=3
Step 9: Source the RC File
Load the environment variables by sourcing the file.
source my-openrc <USERNAME> <PROJECT_NAME>
Step 10: Verify Authentication
Test the authentication by running a simple OpenStack CLI command, such as listing the available projects.
openstack project list