From 30989fbfb85eb4a66ab66d166130b7523f38b9e6 Mon Sep 17 00:00:00 2001 From: "ridhi.j.shah@gmail.com" Date: Sat, 26 Jul 2014 15:30:41 -0500 Subject: [PATCH] Associate flavor types with datastore versions This feature provides the ability to associate flavor types with datastore versions.The trove-mange util enables adding/deleting this information.The trove-client has been changed to include a new api call: /{tenant_id}/datastores/{datastore}/versions/{version}/flavors. This call will return all nova flavors if no entries are found for the said datastore-version in datastore_version_metadata, otherwise only the entries found are returned. Change-Id: I89fc2db0078d7884b7b3fa91f5daec68c0132dfb Implements: blueprint associate-flavors-datastores --- troveclient/v1/flavors.py | 11 ++++++++++- troveclient/v1/shell.py | 16 ++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/troveclient/v1/flavors.py b/troveclient/v1/flavors.py index d61fd04..56479e2 100644 --- a/troveclient/v1/flavors.py +++ b/troveclient/v1/flavors.py @@ -30,11 +30,20 @@ class Flavors(base.ManagerWithFind): def list(self): """Get a list of all flavors. - :rtype: list of :class:`Flavor`. """ return self._list("/flavors", "flavors") + def list_datastore_version_associated_flavors(self, datastore, + version_id): + """Get a list of all flavors for the specified datastore type + and datastore version . + :rtype: list of :class:`Flavor`. + """ + return self._list("/datastores/%s/versions/%s/flavors" % + (datastore, version_id), + "flavors") + def get(self, flavor): """Get a specific flavor. diff --git a/troveclient/v1/shell.py b/troveclient/v1/shell.py index a3fc5bf..000ba29 100644 --- a/troveclient/v1/shell.py +++ b/troveclient/v1/shell.py @@ -111,11 +111,23 @@ def _find_backup(cs, backup): # Flavor related calls - +@utils.arg('--datastore_type', metavar='', + default=None, + help='Type of the datastore. For eg: mysql.') +@utils.arg("--datastore_version_id", metavar="", + default=None, help="ID of the datastore version.") @utils.service_type('database') def do_flavor_list(cs, args): """Lists available flavors.""" - flavors = cs.flavors.list() + if args.datastore_type and args.datastore_version_id: + flavors = cs.flavors.list_datastore_version_associated_flavors( + args.datastore_type, args.datastore_version_id) + elif not args.datastore_type and not args.datastore_version_id: + flavors = cs.flavors.list() + else: + err_msg = ("Specify both and " + " to list datastore version associated flavors.") + raise exceptions.CommandError(err_msg) utils.print_list(flavors, ['id', 'name', 'ram'], labels={'ram': 'RAM'})