Add upgrade to OSC
This change adds database support for the python-openstackclient project for the upgrade and cluster-upgrade commands. The trove command upgrade is now: openstack database instance upgrade The trove command cluster-upgrade is now: openstack database cluster upgrade Change-Id: Ic416d476c645fa3c697881fb001d512ed3d25d2b Partially-Implements: blueprint trove-support-in-python-openstackclient Signed-off-by: Zhao Chao <zhaochao1984@gmail.com>
This commit is contained in:
parent
4fbb1b1b11
commit
e93d56de56
10
releasenotes/notes/add-upgrade-to-osc-837461ff1d588be2.yaml
Normal file
10
releasenotes/notes/add-upgrade-to-osc-837461ff1d588be2.yaml
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
The command ``trove upgrade`` is now available to use in the
|
||||
python-openstackclient CLI as ``openstack database instance
|
||||
upgrade``.
|
||||
- |
|
||||
The command ``trove cluster-upgrade`` is now available to use
|
||||
in the python-openstackclient CLI as ``openstack database
|
||||
cluster upgrade``.
|
@ -41,6 +41,7 @@ openstack.database.v1 =
|
||||
database_cluster_list_instances = troveclient.osc.v1.database_clusters:ListDatabaseClusterInstances
|
||||
database_cluster_reset_status = troveclient.osc.v1.database_clusters:ResetDatabaseClusterStatus
|
||||
database_cluster_show = troveclient.osc.v1.database_clusters:ShowDatabaseCluster
|
||||
database_cluster_upgrade = troveclient.osc.v1.database_clusters:UpgradeDatabaseCluster
|
||||
database_configuration_attach = troveclient.osc.v1.database_configurations:AttachDatabaseConfiguration
|
||||
database_configuration_create = troveclient.osc.v1.database_configurations:CreateDatabaseConfiguration
|
||||
database_configuration_delete = troveclient.osc.v1.database_configurations:DeleteDatabaseConfiguration
|
||||
@ -60,6 +61,7 @@ openstack.database.v1 =
|
||||
database_instance_reset_status = troveclient.osc.v1.database_instances:ResetDatabaseInstanceStatus
|
||||
database_instance_resize_flavor = troveclient.osc.v1.database_instances:ResizeDatabaseInstanceFlavor
|
||||
database_instance_show = troveclient.osc.v1.database_instances:ShowDatabaseInstance
|
||||
database_instance_upgrade = troveclient.osc.v1.database_instances:UpgradeDatabaseInstance
|
||||
database_limit_list = troveclient.osc.v1.database_limits:ListDatabaseLimits
|
||||
database_root_disable = troveclient.osc.v1.database_root:DisableDatabaseRoot
|
||||
database_root_enable = troveclient.osc.v1.database_root:EnableDatabaseRoot
|
||||
|
@ -233,3 +233,28 @@ class ListDatabaseClusterInstances(command.Lister):
|
||||
instances = [utils.get_dict_properties(inst, self.columns)
|
||||
for inst in instances]
|
||||
return self.columns, instances
|
||||
|
||||
|
||||
class UpgradeDatabaseCluster(command.Command):
|
||||
|
||||
_description = _("Upgrades a cluster to a new datastore version.")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(UpgradeDatabaseCluster, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'cluster',
|
||||
metavar='<cluster>',
|
||||
help=_('ID or name of the cluster.'),
|
||||
)
|
||||
parser.add_argument(
|
||||
'datastore_version',
|
||||
metavar='<datastore_version>',
|
||||
help=_('A datastore version name or ID.'),
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
database_clusters = self.app.client_manager.database.clusters
|
||||
cluster = utils.find_resource(database_clusters,
|
||||
parsed_args.cluster)
|
||||
database_clusters.upgrade(cluster, parsed_args.datastore_version)
|
||||
|
@ -419,3 +419,29 @@ class ResizeDatabaseInstanceFlavor(command.Command):
|
||||
flavor = osc_utils.find_resource(db_flavor,
|
||||
parsed_args.flavor_id)
|
||||
db_instances.resize_instance(instance, flavor)
|
||||
|
||||
|
||||
class UpgradeDatabaseInstance(command.Command):
|
||||
|
||||
_description = _("Upgrades an instance to a new datastore version.")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(UpgradeDatabaseInstance, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'instance',
|
||||
metavar='<instance>',
|
||||
type=str,
|
||||
help=_('ID or name of the instance.'),
|
||||
)
|
||||
parser.add_argument(
|
||||
'datastore_version',
|
||||
metavar='<datastore_version>',
|
||||
help=_('ID or name of the instance.'),
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
db_instances = self.app.client_manager.database.instances
|
||||
instance = osc_utils.find_resource(db_instances,
|
||||
parsed_args.instance)
|
||||
db_instances.upgrade(instance, parsed_args.datastore_version)
|
||||
|
@ -188,3 +188,20 @@ class TestClusterListInstances(TestClusters):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.values, data)
|
||||
|
||||
|
||||
class TestDatabaseClusterUpgrade(TestClusters):
|
||||
|
||||
def setUp(self):
|
||||
super(TestDatabaseClusterUpgrade, self).setUp()
|
||||
self.cmd = database_clusters.UpgradeDatabaseCluster(self.app, None)
|
||||
|
||||
@mock.patch.object(utils, 'find_resource')
|
||||
def test_cluster_upgrade(self, mock_find):
|
||||
args = ['cluster1', 'datastore_version1']
|
||||
mock_find.return_value = args[0]
|
||||
parsed_args = self.check_parser(self.cmd, args, [])
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
self.cluster_client.upgrade.assert_called_with('cluster1',
|
||||
'datastore_version1')
|
||||
self.assertIsNone(result)
|
||||
|
@ -201,3 +201,20 @@ class TestDatabaseInstanceResizeFlavor(TestInstances):
|
||||
self.instance_client.resize_instance.assert_called_with('instance1',
|
||||
'flavor_id')
|
||||
self.assertIsNone(result)
|
||||
|
||||
|
||||
class TestDatabaseInstanceUpgrade(TestInstances):
|
||||
|
||||
def setUp(self):
|
||||
super(TestDatabaseInstanceUpgrade, self).setUp()
|
||||
self.cmd = database_instances.UpgradeDatabaseInstance(self.app, None)
|
||||
|
||||
@mock.patch.object(utils, 'find_resource')
|
||||
def test_instance_upgrade(self, mock_find):
|
||||
args = ['instance1', 'datastore_version1']
|
||||
mock_find.return_value = args[0]
|
||||
parsed_args = self.check_parser(self.cmd, args, [])
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
self.instance_client.upgrade.assert_called_with('instance1',
|
||||
'datastore_version1')
|
||||
self.assertIsNone(result)
|
||||
|
Loading…
x
Reference in New Issue
Block a user