summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Basnight <mbasnight@gmail.com>2013-10-10 19:09:47 +0000
committerNikhil Manchanda <SlickNik@gmail.com>2013-10-10 14:31:36 -0700
commit3b09d769082fb288bbf8f8326d83b7db105762b8 (patch)
tree72838a9eb330e92e48376e2ff43b27609f03f9e6
parentfadd19e3a99510b08ca210587c907bf16dedff75 (diff)
downloadpython-troveclient-3b09d769082fb288bbf8f8326d83b7db105762b8.tar.gz
Fixing the backwards verb/noun cli names
The cli names were backwards. instead of backup-list, list-backups was the name. They have been reordered to match the other openstack clients. Also added a better readme. Change-Id: I280f637bfa7bbeaf55c70115339f430dbb279152
-rw-r--r--README.rst156
-rw-r--r--troveclient/v1/shell.py52
2 files changed, 171 insertions, 37 deletions
diff --git a/README.rst b/README.rst
index 2be9bfb..ed36aad 100644
--- a/README.rst
+++ b/README.rst
@@ -1,21 +1,155 @@
-Python bindings to the Trove API
-==================================================
+Python bindings to the OpenStack Trove API
+===========================================
-This is a client for the Trove API. There's a Python API (the
+This is a client for the OpenStack Trove API. There's a Python API (the
``troveclient`` module), and a command-line script (``trove``). Each
-implements 100% (or less ;) ) of the Trove API.
+implements 100% of the OpenStack Trove API.
+
+See the `OpenStack CLI guide`_ for information on how to use the ``trove``
+command-line tool. You may also want to look at the
+`OpenStack API documentation`_.
+
+.. _OpenStack CLI Guide: http://docs.openstack.org/cli/quick-start/content/
+.. _OpenStack API documentation: http://docs.openstack.org/api/
+
+The project is hosted on `Launchpad`_, where bugs can be filed. The code is
+hosted on `Github`_. Patches must be submitted using `Gerrit`_, *not* Github
+pull requests.
+
+.. _Github: https://github.com/openstack/python-troveclient
+.. _Launchpad: https://launchpad.net/python-troveclient
+.. _Gerrit: http://wiki.openstack.org/GerritWorkflow
+
+This code a fork of `Jacobian's python-cloudservers`__ If you need API support
+for the Rackspace API solely or the BSD license, you should use that repository.
+python-troveclient is licensed under the Apache License like the rest of OpenStack.
+
+__ http://github.com/jacobian/python-cloudservers
+
+.. contents:: Contents:
+ :local:
Command-line API
----------------
-To use the command line API, first log in using your user name, api key,
-tenant, and appropriate auth url.
+Installing this package gets you a shell command, ``trove``, that you
+can use to interact with any Rackspace compatible API (including OpenStack).
+
+You'll need to provide your OpenStack username and password. You can do this
+with the ``--os-username``, ``--os-password`` and ``--os-tenant-name``
+params, but it's easier to just set them as environment variables::
+
+ export OS_USERNAME=openstack
+ export OS_PASSWORD=yadayada
+ export OS_TENANT_NAME=myproject
+
+You will also need to define the authentication url with ``--os-auth-url``
+and the version of the API with ``--version``. Or set them as an environment
+variables as well::
+
+ export OS_AUTH_URL=http://example.com:5000/v2.0/
+
+Since Keystone can return multiple regions in the Service Catalog, you
+can specify the one you want with ``--os-region-name`` (or
+``export OS_REGION_NAME``). It defaults to the first in the list returned.
+
+You'll find complete documentation on the shell by running
+``trove help``::
+
+ usage: trove [--version] [--debug] [--os-username <auth-user-name>]
+ [--os-password <auth-password>]
+ [--os-tenant-name <auth-tenant-name>]
+ [--os-tenant-id <auth-tenant-id>] [--os-auth-url <auth-url>]
+ [--os-region-name <region-name>] [--service-type <service-type>]
+ [--service-name <service-name>]
+ [--database-service-name <database-service-name>]
+ [--endpoint-type <endpoint-type>]
+ [--os-database-api-version <database-api-ver>]
+ [--os-cacert <ca-certificate>] [--retries <retries>]
+ <subcommand> ...
+
+ Command-line interface to the OpenStack Trove API.
+
+ Positional arguments:
+ <subcommand>
+ backup-create Deletes a backup.
+ backup-delete Deletes a backup.
+ backup-list List available backups.
+ backup-list-instance
+ List available backups for an instance.
+ backup-show Show details of a backup.
+ create Creates a new instance.
+ database-create Creates a database on an instance.
+ database-delete Deletes a database.
+ database-list Lists available databases on an instance.
+ delete Deletes an instance.
+ flavor-list Lists available flavors.
+ flavor-show Show details of a flavor.
+ limit-list Lists the limits for a tenant.
+ list List all the instances.
+ resize-flavor Resizes the flavor of an instance.
+ resize-volume Resizes the volume size of an instance.
+ restart Restarts the instance.
+ root-enable Enables root for a instance.
+ root-show Gets root enabled status for a instance.
+ secgroup-add-rule Creates a security group rule.
+ secgroup-delete-rule
+ Deletes a security group rule.
+ secgroup-list Lists all security gropus.
+ secgroup-show Shows details about a security group.
+ show Show details of an instance.
+ user-create Creates a user.
+ user-delete Deletes a user from the instance.
+ user-grant-access Grants access to a atabase(s) for a user.
+ user-list Lists the users for a instance.
+ user-revoke-access Revokes access to a database for a user.
+ user-show Gets a user from the instance.
+ user-show-access Gets a users access from the instance.
+ user-update-attributes
+ Updates a users attributes from the instance.
+ bash-completion Print arguments for bash_completion.
+ help Display help about this program or one of its
+ subcommands.
+
+ Optional arguments:
+ --version show program's version number and exit
+ --debug Print debugging output
+ --os-username <auth-user-name>
+ Defaults to env[OS_USERNAME].
+ --os-password <auth-password>
+ Defaults to env[OS_PASSWORD].
+ --os-tenant-name <auth-tenant-name>
+ Defaults to env[OS_TENANT_NAME].
+ --os-tenant-id <auth-tenant-id>
+ Defaults to env[OS_TENANT_ID].
+ --os-auth-url <auth-url>
+ Defaults to env[OS_AUTH_URL].
+ --os-region-name <region-name>
+ Defaults to env[OS_REGION_NAME].
+ --service-type <service-type>
+ Defaults to database for most actions
+ --service-name <service-name>
+ Defaults to env[TROVE_SERVICE_NAME]
+ --database-service-name <database-service-name>
+ Defaults to env[TROVE_DATABASE_SERVICE_NAME]
+ --endpoint-type <endpoint-type>
+ Defaults to env[TROVE_ENDPOINT_TYPE] or publicURL.
+ --os-database-api-version <database-api-ver>
+ Accepts 1,defaults to env[OS_DATABASE_API_VERSION].
+ --os-cacert <ca-certificate>
+ Specify a CA bundle file to use in verifying a TLS
+ (https) server certificate. Defaults to env[OS_CACERT]
+ --retries <retries> Number of retries.
-.. code-block:: bash
+Python API
+----------
- $ trove-cli --username=jsmith --apikey=abcdefg --tenant=12345 --auth_url=http://trove_auth:35357/v2.0/tokens auth login
+There's also a complete Python API, but it has not yet been documented.
-At this point you will be authenticated and given a token, which is stored
-at ~/.apitoken. From there you can make other calls to the CLI.
+Quick-start using keystone::
-TODO: Add docs
+ # use v2.0 auth with http://example.com:5000/v2.0/")
+ >>> from troveclient.v1 import client
+ >>> nt = client.Client(USER, PASS, TENANT, AUTH_URL, service_type="database")
+ >>> nt.instances.list()
+ [...]
diff --git a/troveclient/v1/shell.py b/troveclient/v1/shell.py
index 81b4704..cb9c0f6 100644
--- a/troveclient/v1/shell.py
+++ b/troveclient/v1/shell.py
@@ -67,7 +67,7 @@ def _find_backup(cs, backup):
# Flavor related calls
@utils.service_type('database')
-def do_list_flavors(cs, args):
+def do_flavor_list(cs, args):
"""Lists available flavors."""
flavors = cs.flavors.list()
utils.print_list(flavors, ['id', 'name', 'ram'])
@@ -75,7 +75,7 @@ def do_list_flavors(cs, args):
@utils.arg('flavor', metavar='<flavor>', help='ID of the flavor.')
@utils.service_type('database')
-def do_show_flavor(cs, args):
+def do_flavor_show(cs, args):
"""Show details of a flavor."""
flavor = _find_flavor(cs, args.flavor)
_print_instance(flavor)
@@ -142,7 +142,7 @@ def do_delete(cs, args):
help='The Zone hint to give to nova')
@utils.service_type('database')
def do_create(cs, args):
- """Add a new instance."""
+ """Creates a new instance."""
volume = None
if args.size:
volume = {"size": args.size}
@@ -209,7 +209,7 @@ def do_restart(cs, args):
@utils.arg('backup', metavar='<backup>', help='ID of the backup.')
@utils.service_type('database')
-def do_show_backup(cs, args):
+def do_backup_show(cs, args):
"""Show details of a backup."""
backup = _find_backup(cs, args.backup)
_print_instance(backup)
@@ -217,7 +217,7 @@ def do_show_backup(cs, args):
@utils.arg('instance', metavar='<instance>', help='ID of the instance.')
@utils.service_type('database')
-def do_list_instance_backups(cs, args):
+def do_backup_list_instance(cs, args):
"""List available backups for an instance."""
backups = cs.instances.backups(args.instance)
utils.print_list(backups, ['id', 'instance_id',
@@ -225,7 +225,7 @@ def do_list_instance_backups(cs, args):
@utils.service_type('database')
-def do_list_backups(cs, args):
+def do_backup_list(cs, args):
"""List available backups."""
backups = cs.backups.list()
utils.print_list(backups, ['id', 'instance_id',
@@ -234,7 +234,7 @@ def do_list_backups(cs, args):
@utils.arg('backup', metavar='<backup>', help='ID of the backup.')
@utils.service_type('database')
-def do_delete_backup(cs, args):
+def do_backup_delete(cs, args):
"""Deletes a backup."""
cs.backups.delete(args.backup)
@@ -245,7 +245,7 @@ def do_delete_backup(cs, args):
default=None,
help='An optional description for the backup.')
@utils.service_type('database')
-def do_create_backup(cs, args):
+def do_backup_create(cs, args):
"""Deletes a backup."""
backup = cs.backups.create(args.name, args.instance,
description=args.description)
@@ -262,7 +262,7 @@ def do_create_backup(cs, args):
@utils.arg('--collate', metavar='<collate>', default=None,
help='Optional collation type for database')
@utils.service_type('database')
-def do_create_database(cs, args):
+def do_database_create(cs, args):
"""Creates a database on an instance."""
database_dict = {'name': args.name}
if args.collate:
@@ -275,7 +275,7 @@ def do_create_database(cs, args):
@utils.arg('instance', metavar='<instance>', help='UUID of the instance.')
@utils.service_type('database')
-def do_list_databases(cs, args):
+def do_database_list(cs, args):
"""Lists available databases on an instance."""
wrapper = cs.databases.list(args.instance)
databases = wrapper.items
@@ -289,7 +289,7 @@ def do_list_databases(cs, args):
@utils.arg('instance', metavar='<instance>', help='UUID of the instance.')
@utils.arg('database', metavar='<database>', help='Name of the database.')
@utils.service_type('database')
-def do_delete_database(cs, args):
+def do_database_delete(cs, args):
"""Deletes a database."""
cs.databases.delete(args.instance, args.database)
@@ -305,7 +305,7 @@ def do_delete_database(cs, args):
help='Optional list of databases.',
nargs="+", default=[])
@utils.service_type('database')
-def do_create_user(cs, args):
+def do_user_create(cs, args):
"""Creates a user."""
databases = [{'name': value} for value in args.databases]
user = {'name': args.name, 'password': args.password,
@@ -317,7 +317,7 @@ def do_create_user(cs, args):
@utils.arg('instance', metavar='<instance>', help='UUID of the instance.')
@utils.service_type('database')
-def do_list_users(cs, args):
+def do_user_list(cs, args):
"""Lists the users for a instance."""
wrapper = cs.users.list(args.instance)
users = wrapper.items
@@ -333,7 +333,7 @@ def do_list_users(cs, args):
@utils.arg('--host', metavar='<host>', default=None,
help='Optional host of user')
@utils.service_type('database')
-def do_delete_user(cs, args):
+def do_user_delete(cs, args):
"""Deletes a user from the instance."""
cs.users.delete(args.instance, args.name, hostname=args.host)
@@ -345,7 +345,7 @@ def do_delete_user(cs, args):
@utils.service_type('database')
# Quoting is not working now that we arent using httplib2
# anymore and instead are using requests
-def do_get_user(cs, args):
+def do_user_show(cs, args):
"""Gets a user from the instance."""
user = cs.users.get(args.instance, args.name, hostname=args.host)
_print_instance(user)
@@ -358,7 +358,7 @@ def do_get_user(cs, args):
@utils.service_type('database')
# Quoting is not working now that we arent using httplib2
# anymore and instead are using requests
-def do_get_user_access(cs, args):
+def do_user_show_access(cs, args):
"""Gets a users access from the instance."""
access = cs.users.list_access(args.instance, args.name, hostname=args.host)
utils.print_list(access, ['name'])
@@ -377,7 +377,7 @@ def do_get_user_access(cs, args):
@utils.service_type('database')
# Quoting is not working now that we arent using httplib2
# anymore and instead are using requests
-def do_update_user_attributes(cs, args):
+def do_user_update_attributes(cs, args):
"""Updates a users attributes from the instance."""
new_attrs = {}
if args.new_name:
@@ -398,7 +398,7 @@ def do_update_user_attributes(cs, args):
help='List of databases.',
nargs="+", default=[])
@utils.service_type('database')
-def do_grant_user_access(cs, args):
+def do_user_grant_access(cs, args):
"""Grants access to a atabase(s) for a user."""
cs.users.grant(args.instance, args.name,
args.databases, hostname=args.host)
@@ -410,7 +410,7 @@ def do_grant_user_access(cs, args):
@utils.arg('--host', metavar='<host>', default=None,
help='Optional host of user')
@utils.service_type('database')
-def do_revoke_user_access(cs, args):
+def do_user_revoke_access(cs, args):
"""Revokes access to a database for a user."""
cs.users.revoke(args.instance, args.name,
args.database, hostname=args.host)
@@ -419,7 +419,7 @@ def do_revoke_user_access(cs, args):
# Limits related commands
@utils.service_type('database')
-def do_list_limits(cs, args):
+def do_limit_list(cs, args):
"""Lists the limits for a tenant."""
limits = cs.limits.list()
# Pop the first one, its absolute limits
@@ -432,7 +432,7 @@ def do_list_limits(cs, args):
@utils.arg('instance', metavar='<instance>', help='UUID of the instance.')
@utils.service_type('database')
-def do_enable_root(cs, args):
+def do_root_enable(cs, args):
"""Enables root for a instance."""
root = cs.root.create(args.instance)
utils.print_dict({'name': root[0], 'password': root[1]})
@@ -440,7 +440,7 @@ def do_enable_root(cs, args):
@utils.arg('instance', metavar='<instance>', help='UUID of the instance.')
@utils.service_type('database')
-def do_get_root(cs, args):
+def do_root_show(cs, args):
"""Gets root enabled status for a instance."""
root = cs.root.is_root_enabled(args.instance)
utils.print_dict({'is_root_enabled': root.rootEnabled})
@@ -449,7 +449,7 @@ def do_get_root(cs, args):
# security group related functions
@utils.service_type('database')
-def do_list_security_groups(cs, args):
+def do_secgroup_list(cs, args):
"""Lists all security gropus."""
wrapper = cs.security_groups.list()
sec_grps = wrapper.items
@@ -463,7 +463,7 @@ def do_list_security_groups(cs, args):
@utils.arg('security_group', metavar='<security_group>',
help='ID of the security group.')
@utils.service_type('database')
-def do_show_security_group(cs, args):
+def do_secgroup_show(cs, args):
"""Shows details about a security group."""
sec_grp = cs.security_groups.get(args.security_group)
_print_instance(sec_grp)
@@ -476,7 +476,7 @@ def do_show_security_group(cs, args):
@utils.arg('to_port', metavar='<to_port>', help='to port')
@utils.arg('cidr', metavar='<cidr>', help='CIDR address')
@utils.service_type('database')
-def do_create_security_group_rule(cs, args):
+def do_secgroup_add_rule(cs, args):
"""Creates a security group rule."""
rule = cs.security_group_rules.create(args.security_group,
args.protocol,
@@ -490,6 +490,6 @@ def do_create_security_group_rule(cs, args):
@utils.arg('security_group_rule', metavar='<security_group_rule>',
help='Security group rule')
@utils.service_type('database')
-def do_delete_security_group_rule(cs, args):
+def do_secgroup_delete_rule(cs, args):
"""Deletes a security group rule."""
cs.security_group_rules.delete(args.security_group_rule)