Showing posts with label OpenStack CLI Commands. Show all posts
Showing posts with label OpenStack CLI Commands. Show all posts

Thursday, January 19, 2017

OpenStack - Instances CLI Commands

Viewing/listing list of available flavor
Syntax: nova list
# nova list

Viewing/listing details of a specific instance
Syntax: nova show <instance>
# nova show cirros

Creating an instance from the CLI
Syntax: nova boot --flavor <flavor_name> --image <image_name/ID> --security-groups <security_group> --nic net-name=<private> <instance_name>
# nova boot --flavor m1.tiny --image cirros-0.3.4-x86_64-uec --security-groups webservers --nic net-name=private Crrios2

OpenStack - Security Groups

List Secuirty Groups
Syntax: nova secgroup-list
# nova secgroup-list

Creating Security Groups
Syntax: nova secgroup-create <security_group_name> "comments"
# nova secgroup-create webservers "Allows web traffic anywher efrom the internet"

Adding rules to Security Group
Syntax: nova secgroup-add-rule <security_group_id/name> <protocol> <from_port> <to_port> <ip_range>
# nova secgroup-add-rule webservers tcp 80 80 0.0.0.0/0
# nova secgroup-add-rule webservers tcp 443 443 0.0.0.0/0
# nova secgroup-add-rule webservers tcp 22 22 0.0.0.0/0
# nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0

Viewing rules of a Security Group
Syntax: nova secgroup-list-rules <security_group_id/name>
# nova secgroup-list-rules ab211c6d-c9c5-438b-84a6-cf5bee822ef1

Removing Security Group from an instance
Syntax: nova remove-secgroup <instance> <secgroup-name>
# nova remove-secgroup Cirros default

OpenStack - Quotas CLI Commands

Listing defaults quota
# nova quota-defaults (Note: while updating use defaults)

Updating default quota values 
Syntax: nova quota-class-update --instances <value> default (Note: while updating use default)
Syntax: nova quota-class-update --cpu <value> default (Note: while updating use default)
Syntax: nova quota-class-update --ram <value> default (Note: while updating use default)
instances, ram and cpu (different parameters can be combined)
# nova quota-class-update --instances 10 default

Listing quota for a particular tenants
Syntax: nova quota-show --tenant <tenant_ID>
# nova quota-show --tenant 9a54bc04965f40cd96e217d813b864ee

Updating quota for a particular tenants
Syntax: nova quota-update --instances <instance_value> <tenant_ID>
# nova quota-update --instances 15 3d69bce1f1b646edacb6e44e157d37b9

Viewing quota for a particular user against tenant
Syntax: nova quota-show --user <user_ID> --tenant <tenant_ID>
# nova quota-show --user 5e17d605cc10417ca8fab86d07307d5c --tenant 3d69bce1f1b646edacb6e44e157d37b9

OpenStack - Flavor CLI Commands

Listing or Viewing flavors
# nova flavor-list

Creating flavor
Syntax: nova flavor-create --is-public true <flavour_name> <ID/auto> RAM ROOT_DISK_SIZE EMOHERAL_STORAGE CPU --rxtx-factor 1.0
# nova flavor-create --is-public true m1.extra_tiny auto 4196 80 4 --rxtx-factor 1.0

Attaching flavor to project
Syntax: nova flavor-access-add FLAVOR_NAME PROJECT_ID
# nova flavor-access-add m1.extra_tiny 9a54bc04965f40cd96e217d813b864ee

Deleting flavor
Syntax: nova flavor-delete FLAVOR_ID
# nova flavor-delete 9a54bc04965f40cd96e217d813b864ee

OpenStack - Nova Key Pair CLI Commands

List the existing Keypair
# nova keypair-list

Exports the existing Keypair
Syntax: nova keypair-add KEYPAIR_NAME > keypair.pem (any name with .pem extension)
# nova keypair-add keypair > keypair.pem

Assigning permissions to the keypair
# chmod 600 key1.pem

At last assign the keypair while creating an instance (see below command as an example)

# nova boot --flavor m1.tiny --image cirros-0.3.4-x86_64-uec --security-group default --key-name key1 Cirros1

OpenStack - roles CLI Commands

Listing/Viewung roles
# openstack role list

Creating a new role
Syntax: openstack role create ROLE_NAME
# openstack role create new-role

Deleting a role
Syntax: openstack role delete ROLE_NAME
# openstack role delete role3

Adding a role to the user
Syntax: openstack role add --user <USER_NAME> --project <PROJECT_ID> <ROLE_ID>
# openstack role add --user new-user --project 06600de79aaf4978bc132966c4e693b8 cfbc017b994b487d840f90b5ad902e75

OpenStack - Project Commands

Creating a New Project
Syntax: openstack project create --description '<any_description>' <project_name>
# openstack project create --description 'my new project' new-project

Deleting a Project
Syntax: openstack project delete <project_ID>
# openstack project delete 0b1e78138d454cddbe053cf8480ff650
Listing/Viewing all the projects
# openstack project list

Disabling a Project
Syntax: openstack project set <project_ID> --disable
# openstack project set 0b1e78138d454cddbe053cf8480ff650 --disable

Enabling a Project
Syntax: openstack project set <project_ID> --enable
# openstack project set 0b1e78138d454cddbe053cf8480ff650 --enable

Viewing details of a Project
Syntax: openstack project show <project_ID>
# openstack project show 0b1e78138d454cddbe053cf8480ff6

OpenStack - User CLI Commands

View/list current Users
# openstack user list

Creating a new User
Synatax: openstack user create --project project_name --password type_password user_name
# openstack user create --project new-project --password openstack new-user

Viewing the details of a User
Synatax: openstack user show user_name
# openstack user show new-user

Disabling a User
Syntax: openstack user set user_name --disable
# openstack user set new-user --disable

Enabling a User
Syntax: openstack user set user_name --enable
# openstack user set new-user --enable

Assigning email address to the User
Syntax: openstack user set user_name --email user@example.com
# openstack user set new-user --email user@example.com

Deleting a User
Syntax: openstack user delete user_name
# openstack user delete new-user