nova command-line tool

client install depends on the client os and the openstack version deployed. here an example for essex

The documentation can be found online: managing-the-cloud or python-novaclient/2.6.0

essentially do:

$ curl -O http://pypi.python.org/packages/source/p/python-novaclient/python-novaclient-2012.1.tar.gz
$ tar -zxvf python-novaclient-2012.1.tar.gz
$ cd python-novaclient-2012.1
$ sudo python setup.py install

to confirm the installation:

$ nova help

add either --service_name nova_compat to every command or add

export NOVA_SERVICE_NAME=nova_compat

to your environment

General Information

The environment specific information in this document refers to the standard crowbar setup. usernames and passwords my differ in your environment.

see Username-and-Password-Customizations

The examples use the “openstack” tenant with the following default credentials from /opt/dell/barclamps/keystone/chef/data_bags/crowbar/bc-template-keystone.json

Key Value
Tenant name openstack
OpenStack username crowbar
OpenStack password crowbar

Connect to PoC environment

We assume that there is a host which is connected to the nova-fixed and or admin lan of the PoC.

Connect to Dashboard

Find the node with the nova_dashboard-server role in crowbar and open the URL. e.g. Dashboard URL: http://192.168.122.1 (depends on your deployment)

use the ip from an accessible network (e.g. the admin/nova_fixed/public ip

Install OpenStack CLI tools

To use the cli outside the PoC you have to install the appropriate client libraries (see above)

  • swift >= 1.4.8
  • glance - Essex final
  • nova - Essex final

Setup CLI environment

Add these commands to your login profile dotfile or create a file “openstackenv” that you can source each time you want to create this environment.

Openstack API setup:

e.g. use a config like:

# NOVA ENV VARIABLES
export NOVA_USERNAME=crowbar
export NOVA_PASSWORD=crowbar
export NOVA_PROJECT_ID=openstack
export NOVA_API_KEY=${NOVA_PASSWORD}
export NOVA_URL=http://192.168.124.82:5000/v2.0/
export NOVA_VERSION=1.1
export NOVA_REGION_NAME=RegionOne

# COMMON ENV VARIABLES
export OS_USERNAME=${NOVA_USERNAME}
export OS_PASSWORD=${NOVA_PASSWORD}
export OS_TENANT_NAME=${NOVA_PROJECT_ID}
export OS_AUTH_TENANT=${NOVA_PROJECT_ID}
export OS_AUTH_URL=${NOVA_URL}
export OS_AUTH_STRATEGY=keystone

# EUCA2OOLs ENV VARIABLES
export EC2_ACCESS_KEY=${NOVA_USERNAME}
export EC2_SECRET_KEY=${NOVA_PASSWORD}
export EC2_URL=http://192.168.124.82:8773/services/Cloud

Glance image management

Upload Image

get a image to upload to glance. e.g. from the admin server

scp /opt/dell/barclamps/tempest/cache/files/tempest/cirros-0.3.0-x86_64-uec.tar.gz 192.168.124.82:

Extract the image bundle:

tar fxvz cirros-0.3.0-x86_64-uec.tar.gz

Upload the kernel first:

glance add is_public=true disk_format=aki container_format=aki name=cirros-0.3.0-x86_64-vmlinuz < cirros-0.3.0-x86_64-vmlinuz

Note the image ID number for the kernel, this is the long hex value with 5 groups, for e.g. “4377042f-9c60-4b2d-9bb5-d7114ba666b4”.

Upload the initrd (if needed):

glance add is_public=true disk_format=ari container_format=ari name=cirros-0.3.0-x86_64-initrd < cirros-0.3.0-x86_64-initrd

Note the image ID number for the ramdisk.

Use the kernel ID and ramdisk id that you noted and use it in the next command for kernelid and ramdiskid:

 glance add is_public=true disk_format=ami container_format=ami kernel_id=4377042f-9c60-4b2d-9bb5-d7114ba666b4 ramdisk_id=f8e8824f-6d44-4ba6-b0f1-519003e9f9b8 name=cirros-0.3.0-x86_64 < cirros-0.3.0-x86_64-blank.img

An script to do this is available at https://github.com/dolph/openstack-setup/blob/master/glance-upload-lucid.sh

How to create OpenStack compatible images from standard VM images: http://cssoss.wordpress.com/2011/11/28/bundling-opensuse-image-for-openstack/

List images

Option 1: Dashboard

Go to “Images” page in dashboard. The dashboard shows only bootable images whereas the CLI also shows kernels and boot loaders.

Option 2: CLI

List all images that are in glance:

glance index

Delete Image

Use the “delete” command followed by the image id (e.g. e5069f9d-c15d-4987-822b-908981201f04) to delete the image.

glance delete e5069f9d-c15d-4987-822b-908981201f04

If you try to delete an image of another tenant, you will get an error message: “No image with ID was found”.

Nova compute instances

Keypair-Management

It is important to save the private key as it will not be saved on the server and cannot be regenerated. If you accidently forget to save it, just delete the keypair from the system.

 nova API

nova keypair-add mykeypair > mykeypair.pem
chmod 400 mykeypair.pem

If you already have a key you can upload your key:

ssh-keygen # create a default if you do not have one

nova keypair-add --pub_key .ssh/id_rsa.pub mykeypair2

To delete a keypair just issue the following command (where mykeypair is the name of the keypair you want to delete):

nova keypair-delete mykeypair2

If you have instances running that use this keypair they will not be affected. You just will not be able to assign the keypair to new instances any more.

Dashboard

Go to the “Keypairs” page and use “Add new keypair” or “import keypair”

create instance

No matter which way of launching an instance you choose. The following information is needed:

  1. The image that should be launched
  2. The size of the instance
  3. an SSH keypair to log in to the instance

Nova API

Get needed information to start an instance:

Get available flavors (sizes)

nova flavor-list

Get available images

nova image-list

Get available keypairs

nova keypair-list

Choose image and flavor by id and launch instance:

nova boot --flavor 1 --image 2bdac530-428b-4a10-aa2a-075dc808cd4c  --key_name mykeypair mynewnovainstance

Verify the status of current instance.

nova list

When the status of the instance is no longer “BUILD” but “RUNNING” you can access the instance using SSH.

Dashboard

Go to “Images” page and click “Launch”. Select keypair, flavor (size) and lauch.

Log in to instance

Nova API

Check if instance is running and note IP address (in our example: 192.168.123.52)

 nova list

Set default security group to allow ping and ssh access

nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0
nova secgroup-add-rule default tcp 22 22 0.0.0.0/0

ssh to instance using the keypair supplied on boot

ssh -i mykeypair.pem root@192.168.123.52

Allocating a public IP address to instance

We use the IP range 192.168.122.0/24 to simulate public IPs. (depends on your crowbar config)

Nova API

nova floating-ip-create

Use the new ip and associate it with a running instance (instance id in the example is 28) nova add-floating-ip 55c6f2ec-a995-4c9d-8f2f-877279c4cc0e 192.168.122.128

Check that assignment was successfull:

nova floating-ip-list

You should be able to connect to the instance using the floating IP now:

ssh -i mykeypair.pem root@192.168.122.128

destroy instance

Dashboard

Go to instances overview page and click “Terminate”.

nova API

List running servers:

nova list

Delete running server:

nova delete 55c6f2ec-a995-4c9d-8f2f-877279c4cc0e

Interested in Cloud or Chef Trainings? Have a look at our Commandemy Trainings page. Need help migrating to the cloud? Check out Infralovers.

comments powered by Disqus
Blog Tags