diff --git a/troveclient/osc/v1/datastores.py b/troveclient/osc/v1/datastores.py index c20262a5..f83894fb 100644 --- a/troveclient/osc/v1/datastores.py +++ b/troveclient/osc/v1/datastores.py @@ -194,6 +194,20 @@ class CreateDatastoreVersion(command.Command): help=_('ID of the datastore image in Glance. This can be empty ' 'string if --image-tags is specified.'), ) + parser.add_argument( + '--registry-ext', + help=_('Extension for default datastore managers. ' + 'Allows the use of custom managers for each of ' + 'the datastores supported by Trove.' + 'This can be empty string.'), + ) + parser.add_argument( + '--repl-strategy', + help=_('Extension for default strategy for replication. ' + 'Allows the use of custom replication strategy ' + 'for each of the datastores supported by Trove.' + 'This can be empty string.'), + ) parser.add_argument( '--active', action='store_true', @@ -229,6 +243,8 @@ class CreateDatastoreVersion(command.Command): parsed_args.datastore_manager, parsed_args.image_id, image_tags=image_tags, + registry_ext=parsed_args.registry_ext, + repl_strategy=parsed_args.repl_strategy, active='true' if parsed_args.active else 'false', default='true' if parsed_args.default else 'false', version=parsed_args.version_number @@ -263,6 +279,20 @@ class UpdateDatastoreVersion(command.Command): default=None, help=_('List of image tags separated by comma, e.g. trove,mysql'), ) + parser.add_argument( + '--registry-ext', + help=_('Extension for default datastore managers. ' + 'Allows the use of custom managers for each of ' + 'the datastores supported by Trove.' + 'This can be empty string.'), + ) + parser.add_argument( + '--repl-strategy', + help=_('Extension for default strategy for replication. ' + 'Allows the use of custom replication strategy ' + 'for each of the datastores supported by Trove.' + 'This can be empty string.'), + ) parser.add_argument( '--version-name', help=_('New datastore version name.'), @@ -303,6 +333,8 @@ class UpdateDatastoreVersion(command.Command): datastore_manager=parsed_args.datastore_manager, image=parsed_args.image, image_tags=image_tags, + registry_ext=parsed_args.registry_ext, + repl_strategy=parsed_args.repl_strategy, active=parsed_args.enable, default=parsed_args.default, name=parsed_args.version_name ) diff --git a/troveclient/tests/osc/v1/test_datastores.py b/troveclient/tests/osc/v1/test_datastores.py index 62473e14..b123e663 100644 --- a/troveclient/tests/osc/v1/test_datastores.py +++ b/troveclient/tests/osc/v1/test_datastores.py @@ -166,7 +166,9 @@ class TestCreateDatastoreVersion(TestDatastores): def test_create_datastore_version(self): image_id = uuidutils.generate_uuid() args = ['new_name', 'ds_name', 'ds_manager', image_id, '--active', - '--default', '--image-tags', 'trove,mysql'] + '--default', '--image-tags', 'trove,mysql', + '--registry-ext', 'registry-ext', + '--repl-strategy', 'repl_strategy'] parsed_args = self.check_parser(self.cmd, args, []) self.cmd.take_action(parsed_args) @@ -174,7 +176,8 @@ class TestCreateDatastoreVersion(TestDatastores): self.dsversion_mgmt_client.create.assert_called_once_with( 'new_name', 'ds_name', 'ds_manager', image_id, active='true', default='true', image_tags=['trove', 'mysql'], - version=None) + registry_ext="registry-ext", + repl_strategy="repl_strategy", version=None) class TestUpdateDatastoreVersion(TestDatastores): @@ -184,8 +187,9 @@ class TestUpdateDatastoreVersion(TestDatastores): def test_update_datastore_version(self): version_id = uuidutils.generate_uuid() - args = [version_id, '--image-tags', 'trove,mysql', '--enable', - '--non-default'] + args = [version_id, '--registry-ext', 'registry-ext', + '--repl-strategy', 'repl_strategy', + '--image-tags', 'trove,mysql', '--enable', '--non-default'] parsed_args = self.check_parser(self.cmd, args, []) self.cmd.take_action(parsed_args) @@ -193,4 +197,5 @@ class TestUpdateDatastoreVersion(TestDatastores): self.dsversion_mgmt_client.edit.assert_called_once_with( version_id, datastore_manager=None, image=None, active='true', default='false', image_tags=['trove', 'mysql'], - name=None) + registry_ext="registry-ext", + repl_strategy="repl_strategy", name=None) diff --git a/troveclient/tests/test_management.py b/troveclient/tests/test_management.py index 73d0a7cb..bfb10ef1 100644 --- a/troveclient/tests/test_management.py +++ b/troveclient/tests/test_management.py @@ -235,12 +235,15 @@ class MgmtDatastoreVersionsTest(testtools.TestCase): self.ds_version._create = mock.Mock(side_effect=side_effect_func) p, b, = self.ds_version.create( "ds-version1", "mysql", "mysql", "image-id", - ["mysql-server-5.5"], "true", "true") + ["mysql-server-5.5"], "registry-ext", + "repl-strategy", "true", "true") self.assertEqual("/mgmt/datastore-versions", p) self.assertEqual("ds-version1", b["version"]["name"]) self.assertEqual("mysql", b["version"]["datastore_name"]) self.assertEqual("mysql", b["version"]["datastore_manager"]) self.assertEqual("image-id", b["version"]["image"]) + self.assertEqual("registry-ext", b["version"]["registry_ext"]) + self.assertEqual("repl-strategy", b["version"]["repl_strategy"]) self.assertEqual(["mysql-server-5.5"], b["version"]["packages"]) self.assertTrue(b["version"]["active"]) self.assertTrue(b["version"]["default"]) diff --git a/troveclient/v1/management.py b/troveclient/v1/management.py index fc7f0303..f7d25a69 100644 --- a/troveclient/v1/management.py +++ b/troveclient/v1/management.py @@ -268,8 +268,8 @@ class MgmtDatastoreVersions(base.ManagerWithFind): "version") def create(self, name, datastore_name, datastore_manager, image, - packages=None, active='true', default='false', image_tags=[], - version=None): + packages=None, registry_ext=None, repl_strategy=None, + active='true', default='false', image_tags=[], version=None): """Create a new datastore version.""" packages = packages or [] body = { @@ -285,14 +285,19 @@ class MgmtDatastoreVersions(base.ManagerWithFind): } if image: body['version']['image'] = image + + if registry_ext: + body['version']['registry_ext'] = registry_ext + if repl_strategy: + body['version']['repl_strategy'] = repl_strategy if version: body['version']['version'] = version return self._create("/mgmt/datastore-versions", body, None, True) def edit(self, datastore_version_id, datastore_manager=None, image=None, - packages=None, active=None, default=None, image_tags=None, - name=None): + packages=None, registry_ext=None, repl_strategy=None, + active=None, default=None, image_tags=None, name=None): """Update a datastore-version.""" packages = packages or [] body = {} @@ -302,6 +307,10 @@ class MgmtDatastoreVersions(base.ManagerWithFind): body['image'] = image if packages: body['packages'] = packages + if registry_ext: + body['registry_ext'] = registry_ext + if repl_strategy: + body['repl_strategy'] = repl_strategy if active is not None: body['active'] = json.loads(active) if default is not None: