From 2efa976b63e47741349a5f61206b9677d2453b3d Mon Sep 17 00:00:00 2001 From: Ilya Shakhat Date: Fri, 11 Aug 2017 16:40:52 +0200 Subject: [PATCH] Do not require OpenStack authentication to run osprofiler CLI OpenStack authentication is needed by Ceilometer driver only and is annoying when other drivers are used. The way we currently verify os-parameters is conceptually wrong: first it covers only subset of possible variations, second it differs from implementation inside of python-ceilometerclient. Change-Id: I3bbb7c47170064728790b22393f6071be3ace336 Closes-bug: 1653062 --- osprofiler/cmd/shell.py | 25 ------------------- osprofiler/tests/unit/cmd/test_shell.py | 33 ------------------------- 2 files changed, 58 deletions(-) diff --git a/osprofiler/cmd/shell.py b/osprofiler/cmd/shell.py index f48f23b..0087eb5 100644 --- a/osprofiler/cmd/shell.py +++ b/osprofiler/cmd/shell.py @@ -37,31 +37,6 @@ class OSProfilerShell(object): args = self._get_base_parser().parse_args(argv) opts.set_defaults(cfg.CONF) - if not (args.os_auth_token and args.ceilometer_url): - if not args.os_username: - raise exc.CommandError( - "You must provide a username via either --os-username or " - "via env[OS_USERNAME]") - - if not args.os_password: - raise exc.CommandError( - "You must provide a password via either --os-password or " - "via env[OS_PASSWORD]") - - if self._no_project_and_domain_set(args): - # steer users towards Keystone V3 API - raise exc.CommandError( - "You must provide a project_id via either --os-project-id " - "or via env[OS_PROJECT_ID] and a domain_name via either " - "--os-user-domain-name or via env[OS_USER_DOMAIN_NAME] or " - "a domain_id via either --os-user-domain-id or via " - "env[OS_USER_DOMAIN_ID]") - - if not args.os_auth_url: - raise exc.CommandError( - "You must provide an auth url via either --os-auth-url or " - "via env[OS_AUTH_URL]") - args.func(args) def _get_base_parser(self): diff --git a/osprofiler/tests/unit/cmd/test_shell.py b/osprofiler/tests/unit/cmd/test_shell.py index 20293ea..9689b71 100644 --- a/osprofiler/tests/unit/cmd/test_shell.py +++ b/osprofiler/tests/unit/cmd/test_shell.py @@ -92,39 +92,6 @@ class ShellTestCase(test.TestCase): "Expected: `osprofiler.exc.CommandError` is raised with " "message: '%s'." % expected_message) - def test_username_is_not_presented(self): - os.environ.pop("OS_USERNAME") - msg = ("You must provide a username via either --os-username or " - "via env[OS_USERNAME]") - self._test_with_command_error(self._trace_show_cmd(), msg) - - def test_password_is_not_presented(self): - os.environ.pop("OS_PASSWORD") - msg = ("You must provide a password via either --os-password or " - "via env[OS_PASSWORD]") - self._test_with_command_error(self._trace_show_cmd(), msg) - - def test_auth_url(self): - os.environ.pop("OS_AUTH_URL") - msg = ("You must provide an auth url via either --os-auth-url or " - "via env[OS_AUTH_URL]") - self._test_with_command_error(self._trace_show_cmd(), msg) - - def test_no_project_and_domain_set(self): - os.environ.pop("OS_PROJECT_ID") - os.environ.pop("OS_PROJECT_NAME") - os.environ.pop("OS_TENANT_ID") - os.environ.pop("OS_TENANT_NAME") - os.environ.pop("OS_USER_DOMAIN_ID") - os.environ.pop("OS_USER_DOMAIN_NAME") - - msg = ("You must provide a project_id via either --os-project-id or " - "via env[OS_PROJECT_ID] and a domain_name via either " - "--os-user-domain-name or via env[OS_USER_DOMAIN_NAME] or a " - "domain_id via either --os-user-domain-id or via " - "env[OS_USER_DOMAIN_ID]") - self._test_with_command_error(self._trace_show_cmd(), msg) - def test_trace_show_ceilometerclient_is_missed(self): sys.modules["ceilometerclient"] = None sys.modules["ceilometerclient.client"] = None