summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurice Schreiber <maurice.schreiber@sap.com>2018-04-23 08:56:42 +0200
committerMaurice Schreiber <maurice.schreiber@sap.com>2018-12-07 11:02:19 +0100
commit1d27be1628ead90ad08665bb2275672d88bac93e (patch)
tree237f2614d71c461ec1bdabd8d179c448f9ed81bd
parent0fd1b8f9fa40bdd504c9402dd5c43e86387671bd (diff)
NetApp ONTAP: cifs add AD security service server as preferred DC
multiple comma separated entries can be given Change-Id: I9d6c79704d0ceb7a6fdc18035992e707327dd908 Closes-Bug: #1804651
Notes
Notes (review): Code-Review+2: Goutham Pacha Ravi <gouthampravi@gmail.com> Code-Review+2: Thomas Bechtold <tbechtold@suse.com> Workflow+1: Thomas Bechtold <tbechtold@suse.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 18 Dec 2018 07:57:48 +0000 Reviewed-on: https://review.openstack.org/619563 Project: openstack/manila Branch: refs/heads/master
-rw-r--r--manila/share/drivers/netapp/dataontap/client/client_cmode.py21
-rw-r--r--manila/tests/share/drivers/netapp/dataontap/client/fakes.py1
-rw-r--r--manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode.py34
-rw-r--r--releasenotes/notes/bug-1804651-netapp-cdot-add-peferred-dc-to-cifs-ad-99072ce663762e83.yaml8
4 files changed, 64 insertions, 0 deletions
diff --git a/manila/share/drivers/netapp/dataontap/client/client_cmode.py b/manila/share/drivers/netapp/dataontap/client/client_cmode.py
index 476fdbf..0b910c5 100644
--- a/manila/share/drivers/netapp/dataontap/client/client_cmode.py
+++ b/manila/share/drivers/netapp/dataontap/client/client_cmode.py
@@ -1409,6 +1409,7 @@ class NetAppCmodeClient(client_base.NetAppBaseClient):
1409 def configure_active_directory(self, security_service, vserver_name): 1409 def configure_active_directory(self, security_service, vserver_name):
1410 """Configures AD on Vserver.""" 1410 """Configures AD on Vserver."""
1411 self.configure_dns(security_service) 1411 self.configure_dns(security_service)
1412 self.set_preferred_dc(security_service)
1412 1413
1413 # 'cifs-server' is CIFS Server NetBIOS Name, max length is 15. 1414 # 'cifs-server' is CIFS Server NetBIOS Name, max length is 15.
1414 # Should be unique within each domain (data['domain']). 1415 # Should be unique within each domain (data['domain']).
@@ -1512,6 +1513,26 @@ class NetAppCmodeClient(client_base.NetAppBaseClient):
1512 raise exception.NetAppException(msg % e.message) 1513 raise exception.NetAppException(msg % e.message)
1513 1514
1514 @na_utils.trace 1515 @na_utils.trace
1516 def set_preferred_dc(self, security_service):
1517 # server is optional
1518 if not security_service['server']:
1519 return
1520
1521 api_args = {
1522 'preferred-dc': [],
1523 'domain': security_service['domain'],
1524 }
1525
1526 for dc_ip in security_service['server'].split(','):
1527 api_args['preferred-dc'].append({'string': dc_ip.strip()})
1528
1529 try:
1530 self.send_request('cifs-domain-preferred-dc-add', api_args)
1531 except netapp_api.NaApiError as e:
1532 msg = _("Failed to set preferred DC. %s")
1533 raise exception.NetAppException(msg % e.message)
1534
1535 @na_utils.trace
1515 def create_volume(self, aggregate_name, volume_name, size_gb, 1536 def create_volume(self, aggregate_name, volume_name, size_gb,
1516 thin_provisioned=False, snapshot_policy=None, 1537 thin_provisioned=False, snapshot_policy=None,
1517 language=None, dedup_enabled=False, 1538 language=None, dedup_enabled=False,
diff --git a/manila/tests/share/drivers/netapp/dataontap/client/fakes.py b/manila/tests/share/drivers/netapp/dataontap/client/fakes.py
index 37139fd..dc9661f 100644
--- a/manila/tests/share/drivers/netapp/dataontap/client/fakes.py
+++ b/manila/tests/share/drivers/netapp/dataontap/client/fakes.py
@@ -421,6 +421,7 @@ CIFS_SECURITY_SERVICE = {
421 'ou': 'fake_ou', 421 'ou': 'fake_ou',
422 'domain': 'fake_domain', 422 'domain': 'fake_domain',
423 'dns_ip': 'fake_dns_ip', 423 'dns_ip': 'fake_dns_ip',
424 'server': '',
424} 425}
425 426
426LDAP_SECURITY_SERVICE = { 427LDAP_SECURITY_SERVICE = {
diff --git a/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode.py b/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode.py
index f19d5e9..91815be 100644
--- a/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode.py
+++ b/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode.py
@@ -2492,6 +2492,7 @@ class NetAppClientCmodeTestCase(test.TestCase):
2492 2492
2493 self.mock_object(self.client, 'send_request') 2493 self.mock_object(self.client, 'send_request')
2494 self.mock_object(self.client, 'configure_dns') 2494 self.mock_object(self.client, 'configure_dns')
2495 self.mock_object(self.client, 'set_preferred_dc')
2495 2496
2496 self.client.configure_active_directory(fake.CIFS_SECURITY_SERVICE, 2497 self.client.configure_active_directory(fake.CIFS_SECURITY_SERVICE,
2497 fake.VSERVER_NAME) 2498 fake.VSERVER_NAME)
@@ -2511,6 +2512,8 @@ class NetAppClientCmodeTestCase(test.TestCase):
2511 2512
2512 self.client.configure_dns.assert_called_with( 2513 self.client.configure_dns.assert_called_with(
2513 fake.CIFS_SECURITY_SERVICE) 2514 fake.CIFS_SECURITY_SERVICE)
2515 self.client.set_preferred_dc.assert_called_with(
2516 fake.CIFS_SECURITY_SERVICE)
2514 self.client.send_request.assert_has_calls([ 2517 self.client.send_request.assert_has_calls([
2515 mock.call('cifs-server-create', cifs_server_create_args)]) 2518 mock.call('cifs-server-create', cifs_server_create_args)])
2516 2519
@@ -2703,6 +2706,37 @@ class NetAppClientCmodeTestCase(test.TestCase):
2703 self.client.configure_dns, 2706 self.client.configure_dns,
2704 fake.KERBEROS_SECURITY_SERVICE) 2707 fake.KERBEROS_SECURITY_SERVICE)
2705 2708
2709 @ddt.data('', '10.0.0.1', ['10.0.0.2', '10.0.0.3'])
2710 def test_set_preferred_dc(self, server):
2711
2712 self.mock_object(self.client, 'send_request')
2713 security_service = copy.deepcopy(fake.CIFS_SECURITY_SERVICE)
2714 security_service['server'] = ', '.join(server)
2715
2716 self.client.set_preferred_dc(security_service)
2717
2718 if server is '':
2719 self.client.send_request.assert_not_called()
2720 else:
2721 preferred_dc_add_args = {
2722 'domain': fake.CIFS_SECURITY_SERVICE['domain'],
2723 'preferred-dc': [{'string': dc_ip} for dc_ip in server]
2724 }
2725
2726 self.client.send_request.assert_has_calls([
2727 mock.call('cifs-domain-preferred-dc-add',
2728 preferred_dc_add_args)])
2729
2730 def test_set_preferred_dc_api_error(self):
2731
2732 self.mock_object(self.client, 'send_request', self._mock_api_error())
2733 security_service = copy.deepcopy(fake.CIFS_SECURITY_SERVICE)
2734 security_service['server'] = 'fake_server'
2735
2736 self.assertRaises(exception.NetAppException,
2737 self.client.set_preferred_dc,
2738 security_service)
2739
2706 def test_create_volume(self): 2740 def test_create_volume(self):
2707 2741
2708 self.mock_object(self.client, 'send_request') 2742 self.mock_object(self.client, 'send_request')
diff --git a/releasenotes/notes/bug-1804651-netapp-cdot-add-peferred-dc-to-cifs-ad-99072ce663762e83.yaml b/releasenotes/notes/bug-1804651-netapp-cdot-add-peferred-dc-to-cifs-ad-99072ce663762e83.yaml
new file mode 100644
index 0000000..4e2adda
--- /dev/null
+++ b/releasenotes/notes/bug-1804651-netapp-cdot-add-peferred-dc-to-cifs-ad-99072ce663762e83.yaml
@@ -0,0 +1,8 @@
1---
2features:
3 - |
4 For NetApp CIFS share provisioning users can now specify the optional
5 "server" API parameter to provide an active directory domain controller IP
6 address for when creating a security service. Multiple IP addresses can be
7 given separated by comma. This represents the "Preferred DC" at the vserver
8 cifs domain.