diff --git a/manilaclient/tests/functional/base.py b/manilaclient/tests/functional/base.py index ca3faa5d9..185d5318f 100644 --- a/manilaclient/tests/functional/base.py +++ b/manilaclient/tests/functional/base.py @@ -273,7 +273,7 @@ class BaseTestCase(base.ClientTestBase): @classmethod def create_security_service(cls, type='ldap', name=None, description=None, - dns_ip=None, server=None, domain=None, + dns_ip=None, ou=None, server=None, domain=None, user=None, password=None, client=None, cleanup_in_class=False, microversion=None): if client is None: @@ -287,6 +287,7 @@ class BaseTestCase(base.ClientTestBase): 'server': server, 'domain': domain, 'dns_ip': dns_ip, + 'ou': ou, 'microversion': microversion, } ss = client.create_security_service(**data) diff --git a/manilaclient/tests/functional/client.py b/manilaclient/tests/functional/client.py index 5e7875cb1..4564e6874 100644 --- a/manilaclient/tests/functional/client.py +++ b/manilaclient/tests/functional/client.py @@ -1196,7 +1196,7 @@ class ManilaCLIClient(base.CLIClient): return output_parser.listing(response) def create_security_service(self, type='ldap', name=None, description=None, - dns_ip=None, server=None, domain=None, + dns_ip=None, ou=None, server=None, domain=None, user=None, password=None, microversion=None): """Creates security service. @@ -1204,6 +1204,7 @@ class ManilaCLIClient(base.CLIClient): :param name: desired name of new security service. :param description: desired description of new security service. :param dns_ip: DNS IP address inside tenant's network. + :param ou: security service organizational unit :param server: security service IP address or hostname. :param domain: security service domain. :param user: user of the new security service. @@ -1215,6 +1216,7 @@ class ManilaCLIClient(base.CLIClient): name=name, description=description, dns_ip=dns_ip, + ou=ou, server=server, domain=domain, user=user, @@ -1226,14 +1228,15 @@ class ManilaCLIClient(base.CLIClient): @not_found_wrapper def update_security_service(self, security_service, name=None, - description=None, dns_ip=None, server=None, - domain=None, user=None, password=None, - microversion=None): + description=None, dns_ip=None, ou=None, + server=None, domain=None, user=None, + password=None, microversion=None): cmd = 'security-service-update %s ' % security_service cmd += self. _combine_security_service_data( name=name, description=description, dns_ip=dns_ip, + ou=ou, server=server, domain=domain, user=user, @@ -1242,8 +1245,8 @@ class ManilaCLIClient(base.CLIClient): self.manila(cmd, microversion=microversion)) def _combine_security_service_data(self, name=None, description=None, - dns_ip=None, server=None, domain=None, - user=None, password=None): + dns_ip=None, ou=None, server=None, + domain=None, user=None, password=None): data = '' if name is not None: data += '--name %s ' % name @@ -1251,6 +1254,8 @@ class ManilaCLIClient(base.CLIClient): data += '--description %s ' % description if dns_ip is not None: data += '--dns-ip %s ' % dns_ip + if ou is not None: + data += '--ou %s ' % ou if server is not None: data += '--server %s ' % server if domain is not None: diff --git a/manilaclient/tests/functional/test_security_services.py b/manilaclient/tests/functional/test_security_services.py index 11c3186d7..afd967fe5 100644 --- a/manilaclient/tests/functional/test_security_services.py +++ b/manilaclient/tests/functional/test_security_services.py @@ -32,6 +32,7 @@ class SecurityServiceReadWriteTest(base.BaseTestCase): cls.server = 'fake_server' cls.domain = 'fake_domain' cls.dns_ip = '1.2.3.4' + cls.ou = 'fake_ou' @ddt.data( {'name': 'test_name'}, @@ -41,6 +42,7 @@ class SecurityServiceReadWriteTest(base.BaseTestCase): {'server': 'test_server'}, {'domain': 'test_domain'}, {'dns_ip': 'test_dns_ip'}, + {'ou': 'test_ou'}, {'name': '""'}, {'description': '""'}, {'user': '""'}, @@ -48,6 +50,7 @@ class SecurityServiceReadWriteTest(base.BaseTestCase): {'server': '""'}, {'domain': '""'}, {'dns_ip': '""'}, + {'ou': '""'}, ) def test_create_update_security_service(self, ss_data): expected_data = { @@ -58,6 +61,7 @@ class SecurityServiceReadWriteTest(base.BaseTestCase): 'server': self.server, 'domain': self.domain, 'dns_ip': self.dns_ip, + 'ou': self.ou, } ss = self.create_security_service(**expected_data) diff --git a/manilaclient/tests/unit/v2/fakes.py b/manilaclient/tests/unit/v2/fakes.py index 6196fc321..c00c7817e 100644 --- a/manilaclient/tests/unit/v2/fakes.py +++ b/manilaclient/tests/unit/v2/fakes.py @@ -658,6 +658,7 @@ class FakeHTTPClient(fakes.FakeHTTPClient): 'domain': 'fake_domain', 'server': 'fake_server', 'dns_ip': 'fake_dns_ip', + 'ou': 'fake_ou', 'type': 'fake_type', 'status': 'fake_status', 'project_id': 'fake_project_id', diff --git a/manilaclient/tests/unit/v2/test_security_services.py b/manilaclient/tests/unit/v2/test_security_services.py index d4ea4a4ca..a6fa30399 100644 --- a/manilaclient/tests/unit/v2/test_security_services.py +++ b/manilaclient/tests/unit/v2/test_security_services.py @@ -34,6 +34,7 @@ class SecurityServiceTest(utils.TestCase): values = { 'type': 'ldap', 'dns_ip': 'fake dns ip', + 'ou': 'fake ou', 'server': 'fake.ldap.server', 'domain': 'fake.ldap.domain', 'user': 'fake user', @@ -139,6 +140,7 @@ class SecurityServiceTest(utils.TestCase): security_service = 'fake service' values = { 'dns_ip': 'new dns ip', + 'ou': 'new ou', 'server': 'new.ldap.server', 'domain': 'new.ldap.domain', 'user': 'new user', diff --git a/manilaclient/tests/unit/v2/test_shell.py b/manilaclient/tests/unit/v2/test_shell.py index c07f3a735..b454e2e67 100644 --- a/manilaclient/tests/unit/v2/test_shell.py +++ b/manilaclient/tests/unit/v2/test_shell.py @@ -1912,6 +1912,7 @@ class ShellTest(test_utils.TestCase): 'type': 'ldap', 'user': 'fake-user', 'dns-ip': '1.1.1.1', + 'ou': 'fake-ou', 'server': 'fake-server', 'domain': 'fake-domain', 'offset': 10, @@ -1925,8 +1926,8 @@ class ShellTest(test_utils.TestCase): self.assert_called( 'GET', '/security-services?dns_ip=1.1.1.1&domain=fake-domain&limit=20' - '&name=fake-name&offset=10&server=fake-server&status=new' - '&type=ldap&user=fake-user', + '&name=fake-name&offset=10&ou=fake-ou&server=fake-server' + '&status=new&type=ldap&user=fake-user', ) cliutils.print_list.assert_called_once_with( mock.ANY, @@ -1943,10 +1944,22 @@ class ShellTest(test_utils.TestCase): mock.ANY, fields=['id', 'name', 'status', 'type']) + @mock.patch.object(cliutils, 'print_list', mock.Mock()) + def test_security_service_list_filter_by_ou_alias(self): + self.run_command('security-service-list --ou fake-ou') + self.assert_called( + 'GET', + '/security-services?ou=fake-ou', + ) + cliutils.print_list.assert_called_once_with( + mock.ANY, + fields=['id', 'name', 'status', 'type']) + @ddt.data( {'--name': 'fake_name'}, {'--description': 'fake_description'}, {'--dns-ip': 'fake_dns_ip'}, + {'--ou': 'fake_ou'}, {'--domain': 'fake_domain'}, {'--server': 'fake_server'}, {'--user': 'fake_user'}, @@ -1954,6 +1967,7 @@ class ShellTest(test_utils.TestCase): {'--name': 'fake_name', '--description': 'fake_description', '--dns-ip': 'fake_dns_ip', + '--ou': 'fake_ou', '--domain': 'fake_domain', '--server': 'fake_server', '--user': 'fake_user', @@ -1961,6 +1975,7 @@ class ShellTest(test_utils.TestCase): {'--name': '""'}, {'--description': '""'}, {'--dns-ip': '""'}, + {'--ou': '""'}, {'--domain': '""'}, {'--server': '""'}, {'--user': '""'}, @@ -1968,6 +1983,7 @@ class ShellTest(test_utils.TestCase): {'--name': '""', '--description': '""', '--dns-ip': '""', + '--ou': '""', '--domain': '""', '--server': '""', '--user': '""', diff --git a/manilaclient/v2/security_services.py b/manilaclient/v2/security_services.py index c52e80709..296994e9b 100644 --- a/manilaclient/v2/security_services.py +++ b/manilaclient/v2/security_services.py @@ -42,13 +42,15 @@ class SecurityServiceManager(base.ManagerWithFind): resource_class = SecurityService - def create(self, type, dns_ip=None, server=None, domain=None, user=None, - password=None, name=None, description=None): + def create(self, type, dns_ip=None, ou=None, server=None, domain=None, + user=None, password=None, name=None, + description=None): """Create security service for NAS. :param type: security service type - 'ldap', 'kerberos' or 'active_directory' :param dns_ip: dns ip address used inside tenant's network + :param ou: security service organizational unit :param server: security service server ip address or hostname :param domain: security service domain :param user: security identifier used by tenant @@ -60,6 +62,8 @@ class SecurityServiceManager(base.ManagerWithFind): values = {'type': type} if dns_ip: values['dns_ip'] = dns_ip + if ou: + values['ou'] = ou if server: values['server'] = server if domain: @@ -88,12 +92,14 @@ class SecurityServiceManager(base.ManagerWithFind): RESOURCE_NAME, ) - def update(self, security_service, dns_ip=None, server=None, domain=None, - password=None, user=None, name=None, description=None): + def update(self, security_service, dns_ip=None, ou=None, server=None, + domain=None, password=None, user=None, name=None, + description=None): """Updates a security service. :param security_service: security service to update. :param dns_ip: dns ip address used inside tenant's network + :param ou: security service organizational unit :param server: security service server ip address or hostname :param domain: security service domain :param user: security identifier used by tenant @@ -106,6 +112,8 @@ class SecurityServiceManager(base.ManagerWithFind): values = {} if dns_ip is not None: values['dns_ip'] = dns_ip + if ou is not None: + values['ou'] = ou if server is not None: values['server'] = server if domain is not None: diff --git a/manilaclient/v2/shell.py b/manilaclient/v2/shell.py index 660207492..92b6bbfc4 100644 --- a/manilaclient/v2/shell.py +++ b/manilaclient/v2/shell.py @@ -3099,6 +3099,12 @@ def do_share_network_delete(cs, args): metavar='', default=None, help="DNS IP address used inside tenant's network.") +@cliutils.arg( + '--ou', + metavar='', + default=None, + help="Security service OU (Organizational Unit). Available only for " + "microversion >= 2.44.") @cliutils.arg( '--server', metavar='', @@ -3140,6 +3146,15 @@ def do_security_service_create(cs, args): 'name': args.name, 'description': args.description, } + + if cs.api_version.matches(api_versions.APIVersion("2.44"), + api_versions.APIVersion()): + values['ou'] = args.ou + elif args.ou: + raise exceptions.CommandError( + "Security service Organizational Unit (ou) option " + "is only available with manila API version >= 2.44") + security_service = cs.security_services.create(args.type, **values) info = security_service._info.copy() cliutils.print_dict(info) @@ -3154,6 +3169,12 @@ def do_security_service_create(cs, args): metavar='', default=None, help="DNS IP address used inside tenant's network.") +@cliutils.arg( + '--ou', + metavar='', + default=None, + help="Security service OU (Organizational Unit). Available only for " + "microversion >= 2.44.") @cliutils.arg( '--server', metavar='', @@ -3195,6 +3216,15 @@ def do_security_service_update(cs, args): 'name': args.name, 'description': args.description, } + + if cs.api_version.matches(api_versions.APIVersion("2.44"), + api_versions.APIVersion()): + values['ou'] = args.ou + elif args.ou: + raise exceptions.CommandError( + "Security service Organizational Unit (ou) option " + "is only available with manila API version >= 2.44") + security_service = _find_security_service( cs, args.security_service).update(**values) cliutils.print_dict(security_service._info) @@ -3254,6 +3284,12 @@ def do_security_service_show(cs, args): action='single_alias', default=None, help="Filter results by DNS IP address used inside tenant's network.") +@cliutils.arg( + '--ou', + metavar='', + default=None, + help="Filter results by security service OU (Organizational Unit)." + " Available only for microversion >= 2.44.") @cliutils.arg( '--server', metavar='', @@ -3305,6 +3341,15 @@ def do_security_service_list(cs, args): 'offset': args.offset, 'limit': args.limit, } + + if cs.api_version.matches(api_versions.APIVersion("2.44"), + api_versions.APIVersion()): + search_opts['ou'] = args.ou + elif args.ou: + raise exceptions.CommandError( + "Security service Organizational Unit (ou) option " + "is only available with manila API version >= 2.44") + if args.share_network: search_opts['share_network_id'] = _find_share_network( cs, args.share_network).id diff --git a/releasenotes/notes/bug-1799934-add-ou-parameter-260f9aaf939d1919.yaml b/releasenotes/notes/bug-1799934-add-ou-parameter-260f9aaf939d1919.yaml new file mode 100644 index 000000000..6fb42beef --- /dev/null +++ b/releasenotes/notes/bug-1799934-add-ou-parameter-260f9aaf939d1919.yaml @@ -0,0 +1,3 @@ +--- +features: + - organizational unit (--ou) parameter support added in manila cli