You can use the command line tool to control your OpenStack without Horizon (the web OpenStack dashboard).
This approach can provide you a great flexibility to develop your cloud applications. For example, you can launch and terminate your instance without human intervention.
(Of course, you can use other API tools such as jClouds. However, should try command line tools before using these for your better understanding.)
In order to use the command line tool, you must be authenticated as a tenant by putting your credential in your environmental variable.
(1) You should create a new user, if needed. You can do this using Horizon. (Admin -> Identity Panel -> Users, Note: different Horizon version might have a different location to add a new user.)
(2) You need to run:
$ source openrc your_user_id your_project_name
For my case, I added this command into “rejoin-stack.sh” script.
Now you can use the command line tool.
For example, you can type:
$ nova-manage flavor list
The result would show instance flavors like:
$ nova-manage flavor list
m1.medium: Memory: 4096MB, VCPUS: 2, Root: 40GB, Ephemeral: 0Gb, FlavorID: 3, Swap: 0MB, RXTX Factor: 1.0, public, ExtraSpecs {}
m1.tiny: Memory: 512MB, VCPUS: 1, Root: 1GB, Ephemeral: 0Gb, FlavorID: 1, Swap: 0MB, RXTX Factor: 1.0, public, ExtraSpecs {}
m1.large: Memory: 8192MB, VCPUS: 4, Root: 80GB, Ephemeral: 0Gb, FlavorID: 4, Swap: 0MB, RXTX Factor: 1.0, public, ExtraSpecs {}
......
If you can see a list of flavors, this means that you can use the command line tool.
Otherwise, when running “nova” command, you possibly see this message:
ERROR (CommandError): You must provide a username or user id via --os-username, --os-user-id, env[OS_USERNAME] or env[OS_USER_ID]
You can fix this error to edit variable values in “openrc(http://devstack.org/openrc.html)” permanently.
#admin must be replaced to a tenant name (project name).
export OS_TENANT_NAME=${OS_TENANT_NAME:-admin}
#"yong" must be replaced to your user ID.
export OS_USERNAME=${OS_USERNAME:-yong}
#"password" must be replaced to your admin password.
export OS_PASSWORD=${ADMIN_PASSWORD:-password}
#"192.168.1.1" must be replaced to your host IP address.
HOST_IP=${HOST_IP:-192.168.1.1}
Try this “nova list”, and you should see a running instance list such as:
+--------------------------------------+---------------+--------+------------+-------------+--------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+---------------+--------+------------+-------------+--------------------+
| c51df836-d8d1-40a2-b0a4-6ff44c8da487 | Ubuntu Server | ACTIVE | - | Running | private=10.11.12.2 |
+--------------------------------------+---------------+--------+------------+-------------+--------------------+