CLI tool and interpreter to manage OpenStack and Rackspace Cloud products. It leverages pyrax module, therefore it aims to expose all the features implemented in pyrax.
Watch pyraxshell in action:
ATTENTION pyraxshell is currently in development stage, therefore it should be used for testing purposes only.
Just clone the pyraxshell repository on Github and run it:
$ git clone https://github.com/siso/pyraxshell $ cd pyraxshell $ python pyraxshell
pyraxshell supports three different authentication methods: credentials file, login and token.
Create ~/.pyrax.cfg
file with your credentials:
cat > ~/.pyrax.cfg << EOF [rackspace_cloud] identity_type=rackspace username = USERNAME api_key = APIKEY region = REGION EOF
then simply run python pyraxshell
and pyraxshell will try to
authenticate with ~/.pyrax.cfg credentials.
Run pyraxshell and enter login credentials:
$ python pyraxshell H>auth H auth>login identity_type:rackspace username:USERNAME apikey:APIKEY region=REGION
Run pyraxshell and enter your token:
$ python pyraxshell H>auth H auth>token token:TOKEN tenantId:TENANTID identity_type:IDENTITYTYPE region:REGION
pyraxshell can be executed interactively, so you can start experimenting OpenStack and Rackspace with few simple commands:
$ python pyraxshell H>
hit TAB-TAB
to auto-complete:
H> EOF auth databases endpoints help servers test H>auth EOF credentials is_authenticated print_identity token change_password help login print_token
authenticate:
H auth>login identity_type:rackspace username:MYUSERNAME apikey:MYAPIKEY region=LON
return to the previous menu/interpreter CTRL-D
:
H auth> H>servers H servers> EOF delete help list_flavors create details list list_images H servers>list_flavors +----+-------------------------+-------+------+-------+ | id | name | ram | swap | vcpus | +----+-------------------------+-------+------+-------+ | 2 | 512MB Standard Instance | 512 | 512 | 1 | ...
and so on, you have got the idea. No need to learn anything new, just use it as you would do with any other interpreter, with history, auto-completion, etc.
If a parameter has a default value, then it is considered optional:
H dns>help create_domain create a domain Parameters: name name of the domain email_address ttl TTL (optional, default:900) comment (optional, default:void)
pyraxcli
is a wrapper which allows to run pyraxshell commands from
the command-line, e.g.:
$ python pyraxshell/pyraxcli.py servers, list, EOF, loadbalancers, list, list_nodes id:81957
using the same pyraxshell syntax, and commands separated by commas.
Running pyraxshell non-teractively is pretty easy, and it is the best way to automate tasks. Just create a text file with the commands you want to run:
$ cat > commands.txt << EOF auth login identity_type:rackspace username:MYUSERNAME apikey:MYAPIKEY region=LON exit servers list_flavors EOF
and pipe that to standard input:
$ cat commands.txt | python pyraxshell ... +----+-------------------------+-------+------+-------+ | id | name | ram | swap | vcpus | +----+-------------------------+-------+------+-------+ | 2 | 512MB Standard Instance | 512 | 512 | 1 | ...
To use comments start a line with '#', then run:
$ cat commands.txt | grep -v "^#" | python pyraxshell
i.e.:
$ cat > commands.txt << EOF # THIS IS A COMMENT # AUTHENTICATE auth login identity_type:rackspace username:MYUSERNAME apikey:MYAPIKEY region=LON # EXIT AUTHENTICATION SUB-INTERPRETER exit # ENTER SERVERS MENU servers # LIST FLAVORS list_flavors EOF
See ./scripts
directory which contains some examples.
pyraxshell leverages its plugins system to provide users with all
its features. Please, read PLUGINS.md
to know more about the
pyraxshell plug-ins system, and feel free to poke around
./pyraxshell/plugins
directory too!
On first run ~/.pyraxshell
directory is created, and populated with
default file: * db.sqlite3
- database to store sessions, commands,
etc * logging.conf
- logging configuration file *
pyraxshell.conf
- main configuration file * pyraxshell.log
-
default logging file
pyraxshell.conf
contains default settings that can be overwritten
with CLI params.
Logging to stdout and to file /tmp/pyraxshell.log
is enabled by
default. It can be configured according to your needs, just edit
./conf/logging.conf
, and refer to Logging facility for
Python.
What features will be added to pyraxshell? See ROADMAP.md
.
Please, consult pyraxshell issues, raise a new ticket, and tag it accordingly.
GPL version 3, see LICENSE
.