Remove flavor API

Change-Id: I5a35911b5658fdf6bc08844b31cc1325b749526a
This commit is contained in:
Lingxian Kong
2020-04-18 23:25:26 +12:00
parent 4b47eb6f7f
commit 27cf71299e
20 changed files with 34 additions and 3431 deletions

View File

@@ -1,3 +0,0 @@
.. toctree::
trove.rst

File diff suppressed because it is too large Load Diff

View File

@@ -16,8 +16,7 @@
===========================================
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% of the OpenStack Trove API.
``troveclient`` module), and an ``openstack`` command-line plugin.
Contents
--------
@@ -26,7 +25,6 @@ Contents
:maxdepth: 2
user/index
cli/index
reference/index
Indices and tables

View File

@@ -2,42 +2,16 @@
Trove Client User Guide
=========================
Command-line API
----------------
Command-line Interface
----------------------
Installing this package gets you a shell command, ``trove``, that you
can use to interact with any OpenStack cloud.
Installing this package allows you to use ``openstack`` command to interact
with Trove. Refer to
https://docs.openstack.org/python-openstackclient/latest
for how to install ``openstack`` command and configuration.
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 ``--os-database-api-version`` (default is version
1.0). Or set them as an environment variables as well::
export OS_AUTH_URL=http://example.com:5000/v2.0/
export OS_AUTH_URL=1.0
If you are using Keystone, you need to set the OS_AUTH_URL to the keystone
endpoint::
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.
Argument ``--profile`` is available only when the osprofiler lib is installed.
You'll find complete documentation on the shell by running
``trove help``.
For more details, refer to :doc:`../cli/index`.
You can find all supported Trove commands in ``openstack.database.v1``
entry_points section in ``setup.cfg`` file of the repo.
Python API
----------
@@ -46,14 +20,11 @@ There's also a complete Python API.
Quick-start using keystone::
# use v2.0 auth with http://example.com:5000/v2.0/
>>> from troveclient.v1 import client
>>> nt = client.Client(USERNAME, PASSWORD, TENANT_NAME, AUTH_URL)
>>> nt.datastores.list()
>>> from troveclient import client
>>> trove_client = client.Client('1.0', session=keystone_session, endpoint_type='public', service_type='database', region_name='RegionOne')
>>> trove_client.datastores.list()
[...]
>>> nt.flavors.list()
[...]
>>> nt.instances.list()
>>> trove_client.instances.list()
[...]
.. toctree::

View File

@@ -62,8 +62,6 @@ openstack.database.v1 =
database_db_create = troveclient.osc.v1.databases:CreateDatabase
database_db_delete = troveclient.osc.v1.databases:DeleteDatabase
database_db_list = troveclient.osc.v1.databases:ListDatabases
database_flavor_list = troveclient.osc.v1.database_flavors:ListDatabaseFlavors
database_flavor_show = troveclient.osc.v1.database_flavors:ShowDatabaseFlavor
database_instance_create = troveclient.osc.v1.database_instances:CreateDatabaseInstance
database_instance_delete = troveclient.osc.v1.database_instances:DeleteDatabaseInstance
database_instance_detach_replica = troveclient.osc.v1.database_instances:DetachDatabaseInstanceReplica

View File

@@ -21,11 +21,9 @@ from troveclient.v1.accounts import Accounts # noqa
from troveclient.v1.databases import Databases # noqa
from troveclient.v1.diagnostics import DiagnosticsInterrogator # noqa
from troveclient.v1.diagnostics import HwInfoInterrogator # noqa
from troveclient.v1.flavors import Flavors # noqa
from troveclient.v1.hosts import Hosts # noqa
from troveclient.v1.instances import Instances # noqa
from troveclient.v1.management import Management # noqa
from troveclient.v1.management import MgmtFlavors # noqa
from troveclient.v1.management import RootHistory # noqa
from troveclient.v1.root import Root # noqa
from troveclient.v1.storage import StorageInfo # noqa

View File

@@ -129,16 +129,6 @@ class InstanceCommands(common.AuthedCommandsBase):
self._pretty_print(self.dbaas.instances.configuration, self.id)
class FlavorsCommands(common.AuthedCommandsBase):
"""Command for listing Flavors."""
params = []
def list(self):
"""List the available flavors."""
self._pretty_list(self.dbaas.flavors.list)
class DatabaseCommands(common.AuthedCommandsBase):
"""Database CRUD operations on an instance."""
@@ -436,7 +426,6 @@ class MetadataCommands(common.AuthedCommandsBase):
COMMANDS = {
'auth': common.Auth,
'instance': InstanceCommands,
'flavor': FlavorsCommands,
'database': DatabaseCommands,
'limit': LimitsCommands,
'backup': BackupsCommands,

View File

@@ -309,7 +309,6 @@ class Dbaas(object):
from troveclient.v1 import databases
from troveclient.v1 import datastores
from troveclient.v1 import diagnostics
from troveclient.v1 import flavors
from troveclient.v1 import hosts
from troveclient.v1 import instances
from troveclient.v1 import limits
@@ -331,7 +330,6 @@ class Dbaas(object):
region_name=region_name)
self.versions = versions.Versions(self)
self.databases = databases.Databases(self)
self.flavors = flavors.Flavors(self)
self.instances = instances.Instances(self)
self.limits = limits.Limits(self)
self.users = users.Users(self)
@@ -349,7 +347,6 @@ class Dbaas(object):
self.storage = storage.StorageInfo(self)
self.management = management.Management(self)
self.mgmt_cluster = management.MgmtClusters(self)
self.mgmt_flavor = management.MgmtFlavors(self)
self.accounts = accounts.Accounts(self)
self.diagnostics = diagnostics.DiagnosticsInterrogator(self)
self.hwinfo = diagnostics.HwInfoInterrogator(self)

View File

@@ -181,31 +181,6 @@ class StorageCommands(common.AuthedCommandsBase):
self._pretty_list(self.dbaas.storage.index)
class FlavorsCommands(common.AuthedCommandsBase):
"""Commands for managing Flavors."""
params = [
'name',
'ram',
'disk',
'vcpus',
'flavor_id',
'ephemeral',
'swap',
'rxtx_factor',
'service_type'
]
def create(self):
"""Create a new flavor."""
self._require('name', 'ram', 'disk', 'vcpus',
'flavor_id', 'service_type')
self._pretty_print(self.dbaas.mgmt_flavor.create, self.name,
self.ram, self.disk, self.vcpus, self.flavor_id,
self.ephemeral, self.swap, self.rxtx_factor,
self.service_type)
def config_options(oparser):
oparser.add_option("-u", "--url", default="http://localhost:5000/v1.1",
help="Auth API endpoint URL with port and version. \
@@ -219,7 +194,6 @@ COMMANDS = {
'root': RootCommands,
'storage': StorageCommands,
'quota': QuotaCommands,
'flavor': FlavorsCommands,
}

View File

@@ -1,97 +0,0 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""Database v1 Flavors action implementations"""
from osc_lib.command import command
from osc_lib import utils
import six
from troveclient import exceptions
from troveclient.i18n import _
def set_attributes_for_print_detail(flavor):
info = flavor._info.copy()
# Get rid of those ugly links
if info.get('links'):
del(info['links'])
# Fallback to str_id for flavors, where necessary
if hasattr(flavor, 'str_id'):
info['id'] = flavor.id
del(info['str_id'])
return info
class ListDatabaseFlavors(command.Lister):
_description = _("List database flavors")
columns = ['ID', 'Name', 'RAM', 'vCPUs', 'Disk', 'Ephemeral']
def get_parser(self, prog_name):
parser = super(ListDatabaseFlavors, self).get_parser(prog_name)
parser.add_argument(
'--datastore-type',
dest='datastore_type',
metavar='<datastore-type>',
help=_('Type of the datastore. For eg: mysql.')
)
parser.add_argument(
'--datastore-version-id',
dest='datastore_version_id',
metavar='<datastore-version-id>',
help=_('ID of the datastore version.')
)
return parser
def take_action(self, parsed_args):
db_flavors = self.app.client_manager.database.flavors
if parsed_args.datastore_type and parsed_args.datastore_version_id:
flavors = db_flavors.list_datastore_version_associated_flavors(
datastore=parsed_args.datastore_type,
version_id=parsed_args.datastore_version_id)
elif (not parsed_args.datastore_type and not
parsed_args.datastore_version_id):
flavors = db_flavors.list()
else:
raise exceptions.MissingArgs(['datastore-type',
'datastore-version-id'])
# Fallback to str_id where necessary.
_flavors = []
for f in flavors:
if not f.id and hasattr(f, 'str_id'):
f.id = f.str_id
_flavors.append(utils.get_item_properties(f, self.columns))
return self.columns, _flavors
class ShowDatabaseFlavor(command.ShowOne):
_description = _("Shows details of a database flavor")
def get_parser(self, prog_name):
parser = super(ShowDatabaseFlavor, self).get_parser(prog_name)
parser.add_argument(
'flavor',
metavar='<flavor>',
help=_('ID or name of the flavor'),
)
return parser
def take_action(self, parsed_args):
db_flavors = self.app.client_manager.database.flavors
flavor = utils.find_resource(db_flavors,
parsed_args.flavor)
flavor = set_attributes_for_print_detail(flavor)
return zip(*sorted(six.iteritems(flavor)))

View File

@@ -225,7 +225,7 @@ class CreateDatabaseInstance(command.ShowOne):
'flavor',
metavar='<flavor>',
type=str,
help=_("A flavor name or ID."),
help=_("A flavor ID."),
)
parser.add_argument(
'--size',
@@ -348,8 +348,8 @@ class CreateDatabaseInstance(command.ShowOne):
def take_action(self, parsed_args):
database = self.app.client_manager.database
db_instances = database.instances
flavor_id = osc_utils.find_resource(database.flavors,
parsed_args.flavor).id
flavor_id = parsed_args.flavor
volume = None
if parsed_args.size is not None and parsed_args.size <= 0:
raise exceptions.ValidationError(

View File

@@ -20,7 +20,6 @@ from troveclient.v1 import clusters
from troveclient.v1 import configurations
from troveclient.v1 import databases
from troveclient.v1 import datastores
from troveclient.v1 import flavors
from troveclient.v1 import instances
from troveclient.v1 import limits
from troveclient.v1 import modules
@@ -34,13 +33,6 @@ class TestDatabasev1(utils.TestCommand):
self.app.client_manager.database = mock.MagicMock()
class FakeFlavors(object):
fake_flavors = fakes.FakeHTTPClient().get_flavors()[2]['flavors']
def get_flavors_1(self):
return flavors.Flavor(None, self.fake_flavors[0])
class FakeBackups(object):
fake_backups = fakes.FakeHTTPClient().get_backups()[2]['backups']

View File

@@ -1,78 +0,0 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from troveclient.osc.v1 import database_flavors
from troveclient.tests.osc.v1 import fakes
class TestFlavors(fakes.TestDatabasev1):
fake_flavors = fakes.FakeFlavors()
def setUp(self):
super(TestFlavors, self).setUp()
self.mock_client = self.app.client_manager.database
self.flavor_client = self.app.client_manager.database.flavors
class TestFlavorList(TestFlavors):
columns = database_flavors.ListDatabaseFlavors.columns
values = (1, 'm1.tiny', 512, '', '', '')
def setUp(self):
super(TestFlavorList, self).setUp()
self.cmd = database_flavors.ListDatabaseFlavors(self.app, None)
self.data = [self.fake_flavors.get_flavors_1()]
self.flavor_client.list.return_value = self.data
self.flavor_client.list_datastore_version_associated_flavors. \
return_value = self.data
def test_flavor_list_defaults(self):
parsed_args = self.check_parser(self.cmd, [], [])
columns, values = self.cmd.take_action(parsed_args)
self.flavor_client.list.assert_called_once_with()
self.assertEqual(self.columns, columns)
self.assertEqual([self.values], values)
def test_flavor_list_with_optional_args(self):
args = ['--datastore-type', 'mysql',
'--datastore-version-id', '5.6']
parsed_args = self.check_parser(self.cmd, args, [])
list_flavor_dict = {'datastore': 'mysql',
'version_id': '5.6'}
columns, values = self.cmd.take_action(parsed_args)
self.flavor_client.list_datastore_version_associated_flavors. \
assert_called_once_with(**list_flavor_dict)
self.assertEqual(self.columns, columns)
self.assertEqual([self.values], values)
class TestFlavorShow(TestFlavors):
values = (1, 'm1.tiny', 512)
def setUp(self):
super(TestFlavorShow, self).setUp()
self.cmd = database_flavors.ShowDatabaseFlavor(self.app, None)
self.data = self.fake_flavors.get_flavors_1()
self.flavor_client.get.return_value = self.data
self.columns = (
'id',
'name',
'ram',
)
def test_flavor_show_defaults(self):
args = ['m1.tiny']
parsed_args = self.check_parser(self.cmd, args, [])
columns, data = self.cmd.take_action(parsed_args)
self.assertEqual(self.columns, columns)
self.assertEqual(self.values, data)

View File

@@ -197,7 +197,7 @@ class TestDatabaseInstanceCreate(TestInstances):
@mock.patch.object(utils, 'find_resource')
def test_instance_create(self, mock_find):
mock_find.id.side_effect = ['103', 'test', 'mod_id']
mock_find.id.side_effect = ['test', 'mod_id']
args = ['test-name', '103',
'--size', '1',
'--databases', 'db1', 'db2',

View File

@@ -165,38 +165,6 @@ class ManagementTest(testtools.TestCase):
self.assertEqual({'reset-task-status': {}}, self.body_)
class MgmtFlavorsTest(testtools.TestCase):
def setUp(self):
super(MgmtFlavorsTest, self).setUp()
self.orig__init = management.MgmtFlavors.__init__
management.MgmtFlavors.__init__ = mock.Mock(return_value=None)
self.flavors = management.MgmtFlavors()
self.flavors.api = mock.Mock()
self.flavors.api.client = mock.Mock()
self.flavors.resource_class = mock.Mock(return_value="flavor-1")
self.orig_base_getid = base.getid
base.getid = mock.Mock(return_value="flavor1")
def tearDown(self):
super(MgmtFlavorsTest, self).tearDown()
management.MgmtFlavors.__init__ = self.orig__init
base.getid = self.orig_base_getid
def test_create(self):
def side_effect_func(path, body, inst):
return path, body, inst
self.flavors._create = mock.Mock(side_effect=side_effect_func)
p, b, i = self.flavors.create("test-name", 1024, 30, 2, 1)
self.assertEqual("/mgmt/flavors", p)
self.assertEqual("flavor", i)
self.assertEqual("test-name", b["flavor"]["name"])
self.assertEqual(1024, b["flavor"]["ram"])
self.assertEqual(2, b["flavor"]["vcpu"])
self.assertEqual(1, b["flavor"]["flavor_id"])
class MgmtDatastoreVersionsTest(testtools.TestCase):
def setUp(self):

View File

@@ -209,41 +209,6 @@ class ShellTest(utils.TestCase):
self.run_command('eject-replica-source 1234')
self.assert_called('POST', '/instances/1234/action')
def test_flavor_list(self):
self.run_command('flavor-list')
self.assert_called('GET', '/flavors')
def test_flavor_list_with_datastore(self):
cmd = ('flavor-list --datastore_type mysql '
'--datastore_version_id some-version-id')
self.run_command(cmd)
self.assert_called(
'GET', '/datastores/mysql/versions/some-version-id/flavors')
def test_flavor_list_error(self):
cmd = 'flavor-list --datastore_type mysql'
exepcted_error_msg = (r'Missing argument\(s\): '
'datastore_type, datastore_version_id')
self.assertRaisesRegex(
exceptions.MissingArgs, exepcted_error_msg, self.run_command,
cmd)
def test_flavor_show(self):
self.run_command('flavor-show 1')
self.assert_called('GET', '/flavors/1')
def test_flavor_show_leading_zero(self):
self.run_command('flavor-show 02')
self.assert_called('GET', '/flavors/02')
def test_flavor_show_by_name(self):
self.run_command('flavor-show m1.tiny') # defined in fakes.py
self.assert_called('GET', '/flavors/m1.tiny')
def test_flavor_show_uuid(self):
self.run_command('flavor-show m1.uuid')
self.assert_called('GET', '/flavors/m1.uuid')
def test_volume_type_list(self):
self.run_command('volume-type-list')
self.assert_called('GET', '/volume-types')
@@ -301,7 +266,7 @@ class ShellTest(utils.TestCase):
'POST', '/instances',
{'instance': {
'volume': {'size': 1, 'type': 'lvm'},
'flavorRef': 1,
'flavorRef': '1',
'name': 'test-member-1'
}})
@@ -312,19 +277,19 @@ class ShellTest(utils.TestCase):
'POST', '/instances',
{'instance': {
'volume': {'size': 1, 'type': 'lvm'},
'flavorRef': 1,
'flavorRef': '1',
'name': 'test-member-1',
'modules': [{'id': '4321'}, {'id': '8765'}]
}})
def test_boot_by_flavor_name(self):
self.run_command(
'create test-member-1 m1.tiny --size 1 --volume_type lvm')
'create test-member-1 1 --size 1 --volume_type lvm')
self.assert_called_anytime(
'POST', '/instances',
{'instance': {
'volume': {'size': 1, 'type': 'lvm'},
'flavorRef': 1,
'flavorRef': '1',
'name': 'test-member-1'
}})
@@ -346,7 +311,7 @@ class ShellTest(utils.TestCase):
'POST', '/instances',
{'instance': {
'volume': {'size': 1, 'type': None},
'flavorRef': 1,
'flavorRef': '1',
'name': 'repl-1',
'replica_count': 4,
'locality': 'anti-affinity'
@@ -358,7 +323,7 @@ class ShellTest(utils.TestCase):
'POST', '/instances',
{'instance': {
'volume': {'size': 1, 'type': None},
'flavorRef': 1,
'flavorRef': '1',
'name': 'slave-1',
'replica_of': 'myid',
'replica_count': 1
@@ -371,7 +336,7 @@ class ShellTest(utils.TestCase):
'POST', '/instances',
{'instance': {
'volume': {'size': 1, 'type': None},
'flavorRef': 1,
'flavorRef': '1',
'name': 'slave-1',
'replica_of': 'myid',
'replica_count': 3
@@ -383,7 +348,7 @@ class ShellTest(utils.TestCase):
'POST', '/instances',
{'instance': {
'volume': {'size': 1, 'type': None},
'flavorRef': 1,
'flavorRef': '1',
'name': 'master-1',
'locality': 'affinity'
}})
@@ -411,7 +376,7 @@ class ShellTest(utils.TestCase):
'POST', '/instances',
{'instance': {
'volume': {'size': 1, 'type': None},
'flavorRef': 1,
'flavorRef': '1',
'name': 'test-restore-1',
'restorePoint': {'backupRef': 'bk-1234'},
}})
@@ -422,7 +387,7 @@ class ShellTest(utils.TestCase):
'POST', '/instances',
{'instance': {
'volume': {'size': 1, 'type': None},
'flavorRef': 1,
'flavorRef': '1',
'name': 'test-restore-1',
'restorePoint': {'backupRef': 'bk-1234'},
}})
@@ -454,8 +419,8 @@ class ShellTest(utils.TestCase):
def test_cluster_create_by_flavor_name(self):
cmd = ('cluster-create test-clstr vertica 7.1 '
'--instance flavor=m1.small,volume=2 '
'--instance flavor=m1.leading-zero,volume=1')
'--instance flavor=2,volume=2 '
'--instance flavor=02,volume=1')
self.run_command(cmd)
self.assert_called_anytime(
'POST', '/clusters',

View File

@@ -20,7 +20,6 @@ from troveclient.v1 import clusters
from troveclient.v1 import configurations
from troveclient.v1 import databases
from troveclient.v1 import datastores
from troveclient.v1 import flavors
from troveclient.v1 import instances
from troveclient.v1 import limits
from troveclient.v1 import management
@@ -64,7 +63,6 @@ class Client(object):
# self.limits = limits.LimitsManager(self)
# extensions
self.flavors = flavors.Flavors(self)
self.volume_types = volume_types.VolumeTypes(self)
self.users = users.Users(self)
self.databases = databases.Databases(self)

View File

@@ -1,58 +0,0 @@
# Copyright 2011 OpenStack Foundation
# Copyright 2013 Rackspace Hosting
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from troveclient import base
class Flavor(base.Resource):
"""A Flavor is an Instance type, specifying other things, like RAM size."""
def __init__(self, manager, info, loaded=False):
super(Flavor, self).__init__(manager, info, loaded)
if self.id is None and self.str_id is not None:
self.id = self.str_id
def __repr__(self):
return "<Flavor: %s>" % self.name
class Flavors(base.ManagerWithFind):
"""Manage :class:`Flavor` resources."""
resource_class = Flavor
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.
:rtype: :class:`Flavor`
"""
return self._get("/flavors/%s" % base.getid(flavor),
"flavor")

View File

@@ -21,7 +21,6 @@ from troveclient import common
from troveclient.v1 import clusters
from troveclient.v1 import configurations
from troveclient.v1 import datastores
from troveclient.v1 import flavors
from troveclient.v1 import instances
@@ -145,44 +144,6 @@ class MgmtClusters(base.ManagerWithFind):
self._action(cluster_id, body)
class MgmtFlavors(base.ManagerWithFind):
"""Manage :class:`Flavor` resources."""
resource_class = flavors.Flavor
def __repr__(self):
return "<Flavors Manager at %s>" % id(self)
# Appease the abc gods
def list(self):
pass
def create(self, name, ram, disk, vcpus,
flavorid="auto", ephemeral=None, swap=None, rxtx_factor=None,
service_type=None):
"""Create a new flavor."""
body = {"flavor": {
"flavor_id": flavorid,
"name": name,
"ram": ram,
"disk": disk,
"vcpu": vcpus,
"ephemeral": 0,
"swap": 0,
"rxtx_factor": "1.0",
"is_public": "True"
}}
if ephemeral:
body["flavor"]["ephemeral"] = ephemeral
if swap:
body["flavor"]["swap"] = swap
if rxtx_factor:
body["flavor"]["rxtx_factor"] = rxtx_factor
if service_type:
body["flavor"]["service_type"] = service_type
return self._create("/mgmt/flavors", body, "flavor")
class MgmtConfigurationParameters(configurations.ConfigurationParameters):
def create(self, version, name, restart_required, data_type,
max_size=None, min_size=None):

View File

@@ -189,11 +189,6 @@ def _find_cluster(cs, cluster):
return utils.find_resource(cs.clusters, cluster)
def _find_flavor(cs, flavor):
"""Get a flavor by ID."""
return utils.find_resource(cs.flavors, flavor)
def _find_volume_type(cs, volume_type):
"""Get a volume type by ID."""
return utils.find_resource(cs.volume_types, volume_type)
@@ -224,46 +219,6 @@ def _find_configuration(cs, configuration):
return utils.find_resource(cs.configurations, configuration)
# Flavor related calls
@utils.arg('--datastore_type', metavar='<datastore_type>',
default=None,
help=_('Type of the datastore. For eg: mysql.'))
@utils.arg("--datastore_version_id", metavar="<datastore_version_id>",
default=None, help=_("ID of the datastore version."))
@utils.service_type('database')
def do_flavor_list(cs, args):
"""Lists available flavors."""
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:
raise exceptions.MissingArgs(['datastore_type',
'datastore_version_id'])
# Fallback to str_id where necessary.
_flavors = []
for f in flavors:
if not f.id and hasattr(f, 'str_id'):
f.id = f.str_id
_flavors.append(f)
utils.print_list(_flavors, ['id', 'name', 'ram', 'vcpus', 'disk',
'ephemeral'],
labels={'ram': 'RAM', 'vcpus': 'vCPUs', 'disk': 'Disk'},
order_by='ram')
@utils.arg('flavor', metavar='<flavor>', type=str,
help=_('ID or name of the flavor.'))
@utils.service_type('database')
def do_flavor_show(cs, args):
"""Shows details of a flavor."""
flavor = _find_flavor(cs, args.flavor)
_print_object(flavor)
# Volume type related calls
@utils.arg('--datastore_type', metavar='<datastore_type>',
default=None,
@@ -555,7 +510,7 @@ def do_update(cs, args):
@utils.arg('flavor',
metavar='<flavor>',
type=str,
help=_('A flavor name or ID.'))
help=_('A flavor ID.'))
@utils.arg('--databases', metavar='<database>',
help=_('Optional list of databases.'),
nargs="+", default=[])
@@ -623,7 +578,7 @@ def do_update(cs, args):
@utils.service_type('database')
def do_create(cs, args):
"""Creates a new instance."""
flavor_id = _find_flavor(cs, args.flavor).id
flavor_id = args.flavor
volume = None
if args.size is not None and args.size <= 0:
raise exceptions.ValidationError(
@@ -686,8 +641,7 @@ def _validate_nic_info(nic_info, nic_str):
def _get_flavor(cs, opts_str):
flavor_name, opts_str = _strip_option(opts_str, 'flavor', True)
flavor_id = _find_flavor(cs, flavor_name).id
flavor_id, opts_str = _strip_option(opts_str, 'flavor', True)
return str(flavor_id), opts_str
@@ -929,12 +883,12 @@ def do_cluster_create(cs, args):
@utils.arg('flavor',
metavar='<flavor>',
type=str,
help=_('New flavor of the instance.'))
help=_('New flavor ID for the instance.'))
@utils.service_type('database')
def do_resize_instance(cs, args):
"""Resizes an instance with a new flavor."""
instance = _find_instance(cs, args.instance)
flavor_id = _find_flavor(cs, args.flavor).id
flavor_id = args.flavor
cs.instances.resize_instance(instance, flavor_id)