Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
83 lines (54 loc) · 2.82 KB

File metadata and controls

83 lines (54 loc) · 2.82 KB
Copy raw file
Download raw file
Outline
Edit and raw actions

The Java Command Line Interface

Introduction

The command line interface serves as an example consumer of the Java bindings to the OpenStack API.
It isn’t intended to replace the ‘nova’ client, though it may be an alternative for basic usage.

Direct Usage

Build the code using mvn package, if you haven’t already done so.

This builds everything, including an all-in-one JAR which can be run standalone.

If you’re running devstack, you should then be able to run this (replacing the server address with your keystone server address):
java -jar openstack-cli/target/openstack-cli-standalone.jar --user demo --password supersecret --tenant demo --server http://192.168.71.1:5000/v2.0/ list-flavors

Usage with nailgun

Nailgun is a way of running the OpenStack CLI as a server, and quickly connecting to it using a small C client, rather than starting a JVM every time.

Unfortunately, the version of nailgun shipped with Debian/Ubuntu has a few bugs. We recommend installing/using the version we provide. Simply do this:

cd nailgun
make
cd ..

Now, there are some helper scripts that are very useful: bin/os and bin/start-os-server.

bin/start-os-server starts the nailgun server, so it’ll be listening for connections. Run it:

bin/start-os-server

The OpenStack CLI should now be running as a server, listening on port 2012

Now, you’ll want to create a configuration file to hold your credentials. By default, we look for ~/.credentials/openstack

It should look like this (edit with your own details):

OS_USERNAME=demo
OS_PASSWORD=supersecret
OS_TENANT_NAME=demo
OS_AUTH_URL=http://192.168.71.1:5000/v2.0

Everything should now be ready; try running

bin/os list-flavors

And you should get a list of flavors (much faster than you did previously).

Enabling bash auto-completion

The CLI tool has some nice bash auto-completion features. You’ll want the ‘os’ command on your PATH; I like to put symlinks in ~/bin for this.

BASEDIR=`pwd`
mkdir -p ~/bin
cd ~/bin
ln -s ${BASEDIR}/bin/os
ln -s ${BASEDIR}/nailgun/ng
cd /etc/bash_completion.d/
sudo ln -s ${BASEDIR}/etc/bash_completion.d/os
cd ${BASEDIR}
. /etc/bash_completion

That last command (. /etc/bash_completion) lets the bash auto completion features take effect in the current session. You can run it
in other sessions, it should happen automatically on new sessions from now on.

So now try typing:
os [TAB][TAB] (where [TAB] means press the [TAB] key)
os l[TAB] (should auto-complete the beginning of the list- command)
os list-fl[TAB] (should auto-complete the beginning of the list-flavors command)

Argument auto-completion is also smart. For example, the command to create a server is
os create-server <name> <image> <flavor>

If you type os create-server test1 [TAB][TAB] then a list of images should be provided to you.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.