Skip to content

Openstack Usage and Examples

T20A02 edited this page Nov 10, 2023 · 10 revisions

Openstack Usage

This short guide will outline the usage of some simple commands for openstack/microstack. This includes service usage, dashboard settings, and more.

Services

To Check running services

microstack.openstack catalog list

Output Example:

image


List Microstack users

microstack.openstack user list

Output Example

image


List available images

``microstack.openstack image list```

Example Output:

image


List system networks

microstack.openstack network list

Example Output

image


List Hypervisor hosts

microstack.openstack hypervisor list

Example Output

image

Dashboard Settings

Configuring themes

Themes can be changed in the login menu from the webpage.

Example:

image


Changing User Password:

The User password for the Openstack dashboard can be changed if know, by going to Settings > Change Password.

Example

image

If the Password is not known, it can be retrieved from the CLI on the host:

sudo snap get microstack config.credentials.keystone-password

Example Output

image

Managing Templates

Managing templates can be done from the web dashboard, this includes managing images, and templates.

To create an image navigate to Admin > Compute > images

Here you can list and search images available to the system


Flavors

Flavors are a crucial part of your workflow with openstack, allowing you to create hardware templates to allow the quick creation of new guests

To create a new flavor, from cli run the following and replacing the resources respectively with what is needed

microstack.openstack flavor create --ram 1024 --disk 10 --vcpus 1 testflavor

Example Output

image


List the flavors on the system:

microstack.openstack flavor list

Example output

image

This can also be managed through the flavors tab of the dashboard at Admin > Compute > Flavors.

Here you can and remove flavors from the system dashboard

Domain / identities

In this section we are outlining the commands and usage for creating, and changes domains in openstack, not to be confused with domains related to AD

Create a new Domain

microstack.openstack domain create --description "DESCRIPTION" domain.local

Example output:

image


List domains

microstack.openstack domain list

Example:

image


Create domain user's

microstack.openstack user create --domain domain.local --password username passsword

Example:

image


Creating roles

microstack.openstack role add --domain domain.local --user-domain domain.local --user username password

No output is provided form this command

Note: To allow multi domain logins on the web page, you need to append the following config file to allow the domain entry box to be used at the login screen:

Command:

image


Managing Roles

To add a new role:

microstack.openstack role create _member_

Example:

image

To add a new project:

microstack.openstack project create --domain domain.local projectname

Example:

image

To List projects:

microstack.openstack project list --domain domain.local

Example:

image

These Same actions can be achived via the web UI, found in "Identity > Projects"

image


Managing User's and groups

To create a domain user:

microstack.openstack user create --domain domain.local --password password username

Example:

image

To List Users:

microstack.openstack user list --domain domain.local

Example:

image

To Create a new group:

microstack.openstack group create --domain domain.local grouname

Example:

image

To list groups:

microstack.openstack group list --domain domain.local

Example:

image


Managing membership and assignments

To add a user to a group:

microstack.openstack group add user --group-domain domain.local --user-domain domain.local group username

To assign a group to a rile:

microstack.openstack role add --project projectname --project-domain domain.local --group groupname --group-domain domain.local group


Elevating domain user's

Finishing making the domain admin account an administrator

microstack.openstack role add --project myproject --project-domain mydomain --user admin --user-domain mydomain admin

Then make some changes to the RC file

Download the new RC file from the top left user menu:

Then rename it:

mv ~/Downloads/myproject-openrc.sh ~/Downloads/admin-openrc.sh

Then Execute it with:

source ~/Downloads/admin-openrc.sh


Tenancy

Fix's and tenancy

We had to install some further packages to have the command work correctly. Run the following to fix issues with tenancy changes:

sudo apt install python3-openstackclient

Now that that has been installed you can call openstack without microstack:

List active running images:

image

To Create Tenancy keypairs:

openstack keypair create --private-key ./mykeypair.pem --type ssh mykeypair

Example:

image

To list keypairs:

openstack keypair list

Example:

image


Network

Create a new network:

openstack --insecure network create networkname

Example

image

List Networks:

openstack --insecure network list

Example

image

To Create a Subnet:

openstack --insecure subnet create --network mynetwork --subnet-range 192.168.0.0/24 --allocation-pool start=192.168.0.101,end=192.168.0.200 --dns-nameserver 8.8.8.8 mysubnet

Example:

image

To list subnets:

openstack --insecure subnet list

Example

image

To Create a router:

openstack --insecure router create myrouter

Example

image

To list routers:

openstack --insecure router list

Example

image

To configure external networks as a gateway for created networks:

openstack --insecure router set --external-gateway external-network myrouter


Floating Ip's

To create a new floating ip

openstack --insecure floating ip create external

Example

image

To list floating Ip's

openstack --insecure floating ip list

Example

image


Security Groups

To create a security group:

openstack security group create name

Example:

image

To list security groups

openstack --insecure security group list

Example

image

To Create a security group rule

openstack security group rule create --remote-ip 0.0.0.0/0 --dst-port 22:22 --protocol tcp --ingress mysecuritygroup

Example

image

To list security group:

openstack --insecure group rule list name

Example

image


Instances

Create a new instance:

openstack server create --flavor myflavor --image ubuntu --network mynetwork --key-name mykeypair --min 2 --max 2 myinstance

Example

image

To associate a floating Ip with a Client:

IP=$(openstack floating ip list | tail -n 2 | head -n 1 | awk '{print $4}')

openstack server add floating ip myinstance-1 $IP

Attaching security groups

chmod 0400 ~/keypai/location/key.pem

SSH Config:


ssh -i ~/Downloads/mykeypair.pem -o StrictHostKeyChecking=no ubuntu@$IP```

SSH Connection:

![image](https://github.com/T20A026/SYS-350-Enterprise-Virtualization/assets/70958837/2ce1ad01-d7c3-42db-8afe-7a5907e19d75)

To delete an instance;

```openstack server delete myinstance-2```

Clone this wiki locally