diff --git a/novaclient/tests/unit/test_utils.py b/novaclient/tests/unit/test_utils.py index 372e6f007..46ffbc13a 100644 --- a/novaclient/tests/unit/test_utils.py +++ b/novaclient/tests/unit/test_utils.py @@ -380,26 +380,6 @@ class ValidationsTestCase(test_utils.TestCase): self.assertIn(key, str(ce)) -class ResourceManagerExtraKwargsHookTestCase(test_utils.TestCase): - def test_get_resource_manager_extra_kwargs_hook_test(self): - do_foo = mock.MagicMock() - - def hook1(args): - return {'kwarg1': 'v_hook1'} - - def hook2(args): - return {'kwarg1': 'v_hook2'} - do_foo.resource_manager_kwargs_hooks = [hook1, hook2] - args = {} - exc = self.assertRaises(exceptions.NoUniqueMatch, - utils.get_resource_manager_extra_kwargs, - do_foo, - args) - except_error = ("Hook 'hook2' is attempting to redefine " - "attributes") - self.assertIn(except_error, six.text_type(exc)) - - class DoActionOnManyTestCase(test_utils.TestCase): def _test_do_action_on_many(self, side_effect, fail): diff --git a/novaclient/utils.py b/novaclient/utils.py index df4464e6c..8869f696b 100644 --- a/novaclient/utils.py +++ b/novaclient/utils.py @@ -118,43 +118,6 @@ def service_type(stype): return inner -def add_resource_manager_extra_kwargs_hook(f, hook): - """Add hook to bind CLI arguments to ResourceManager calls. - - The `do_foo` calls in shell.py will receive CLI args and then in turn pass - them through to the ResourceManager. Before passing through the args, the - hooks registered here will be called, giving us a chance to add extra - kwargs (taken from the command-line) to what's passed to the - ResourceManager. - """ - if not hasattr(f, 'resource_manager_kwargs_hooks'): - f.resource_manager_kwargs_hooks = [] - - names = [h.__name__ for h in f.resource_manager_kwargs_hooks] - if hook.__name__ not in names: - f.resource_manager_kwargs_hooks.append(hook) - - -def get_resource_manager_extra_kwargs(f, args, allow_conflicts=False): - """Return extra_kwargs by calling resource manager kwargs hooks.""" - hooks = getattr(f, "resource_manager_kwargs_hooks", []) - extra_kwargs = {} - for hook in hooks: - hook_kwargs = hook(args) - hook_name = hook.__name__ - conflicting_keys = set(hook_kwargs.keys()) & set(extra_kwargs.keys()) - if conflicting_keys and not allow_conflicts: - msg = (_("Hook '%(hook_name)s' is attempting to redefine " - "attributes '%(conflicting_keys)s'") % - {'hook_name': hook_name, - 'conflicting_keys': conflicting_keys}) - raise exceptions.NoUniqueMatch(msg) - - extra_kwargs.update(hook_kwargs) - - return extra_kwargs - - def pretty_choice_list(l): return ', '.join("'%s'" % i for i in l) diff --git a/novaclient/v2/shell.py b/novaclient/v2/shell.py index 7c05d1691..5fcff2df9 100644 --- a/novaclient/v2/shell.py +++ b/novaclient/v2/shell.py @@ -877,9 +877,6 @@ def do_boot(cs, args): """Boot a new server.""" boot_args, boot_kwargs = _boot(cs, args) - extra_boot_kwargs = utils.get_resource_manager_extra_kwargs(do_boot, args) - boot_kwargs.update(extra_boot_kwargs) - server = cs.servers.create(*boot_args, **boot_kwargs) if boot_kwargs['reservation_id']: new_server = {'reservation_id': server} @@ -1815,13 +1812,11 @@ def do_rebuild(cs, args): else: _password = None - kwargs = utils.get_resource_manager_extra_kwargs(do_rebuild, args) - kwargs['preserve_ephemeral'] = args.preserve_ephemeral - kwargs['name'] = args.name + kwargs = {'preserve_ephemeral': args.preserve_ephemeral, + 'name': args.name, + 'meta': _meta_parsing(args.meta)} if 'description' in args: kwargs['description'] = args.description - meta = _meta_parsing(args.meta) - kwargs['meta'] = meta # 2.57 deprecates the --file option and adds the --user-data and # --user-data-unset options. @@ -1910,8 +1905,7 @@ def do_resize(cs, args): """Resize a server.""" server = _find_server(cs, args.server) flavor = _find_flavor(cs, args.flavor) - kwargs = utils.get_resource_manager_extra_kwargs(do_resize, args) - server.resize(flavor, **kwargs) + server.resize(flavor) if args.poll: _poll_for_status(cs.servers.get, server.id, 'resizing', ['active', 'verify_resize']) diff --git a/releasenotes/notes/get-rid-off-redundant-methods-47e679c13e88f28a.yaml b/releasenotes/notes/get-rid-off-redundant-methods-47e679c13e88f28a.yaml new file mode 100644 index 000000000..954ae395d --- /dev/null +++ b/releasenotes/notes/get-rid-off-redundant-methods-47e679c13e88f28a.yaml @@ -0,0 +1,10 @@ +--- +deprecations: + - | + ``novaclient.utils.add_resource_manager_extra_kwargs_hook`` and + ``novaclient.utils.get_resource_manager_extra_kwargs`` were designed for + supporting extensions in nova/novaclient. Nowadays, this "extensions" + feature is abandoned and both ``add_resource_manager_extra_kwargs_hook``, + ``add_resource_manager_extra_kwargs_hook`` are not used in novaclient's + code. These methods are not documented, so we are removing them without + standard deprecation cycle.