Browse Source

NetApp ONTAP: cifs add AD security service server as preferred DC

multiple comma separated entries can be given

Change-Id: I9d6c79704d0ceb7a6fdc18035992e707327dd908
Closes-Bug: #1804651
Maurice Schreiber 1 year ago
parent
commit
1d27be1628
No account linked to committer's email address

+ 21
- 0
manila/share/drivers/netapp/dataontap/client/client_cmode.py View File

@@ -1409,6 +1409,7 @@ class NetAppCmodeClient(client_base.NetAppBaseClient):
1409 1409
     def configure_active_directory(self, security_service, vserver_name):
1410 1410
         """Configures AD on Vserver."""
1411 1411
         self.configure_dns(security_service)
1412
+        self.set_preferred_dc(security_service)
1412 1413
 
1413 1414
         # 'cifs-server' is CIFS Server NetBIOS Name, max length is 15.
1414 1415
         # Should be unique within each domain (data['domain']).
@@ -1511,6 +1512,26 @@ class NetAppCmodeClient(client_base.NetAppBaseClient):
1511 1512
                 msg = _("Failed to configure DNS. %s")
1512 1513
                 raise exception.NetAppException(msg % e.message)
1513 1514
 
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
+
1514 1535
     @na_utils.trace
1515 1536
     def create_volume(self, aggregate_name, volume_name, size_gb,
1516 1537
                       thin_provisioned=False, snapshot_policy=None,

+ 1
- 0
manila/tests/share/drivers/netapp/dataontap/client/fakes.py View File

@@ -421,6 +421,7 @@ CIFS_SECURITY_SERVICE = {
421 421
     'ou': 'fake_ou',
422 422
     'domain': 'fake_domain',
423 423
     'dns_ip': 'fake_dns_ip',
424
+    'server': '',
424 425
 }
425 426
 
426 427
 LDAP_SECURITY_SERVICE = {

+ 34
- 0
manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode.py View File

@@ -2492,6 +2492,7 @@ class NetAppClientCmodeTestCase(test.TestCase):
2492 2492
 
2493 2493
         self.mock_object(self.client, 'send_request')
2494 2494
         self.mock_object(self.client, 'configure_dns')
2495
+        self.mock_object(self.client, 'set_preferred_dc')
2495 2496
 
2496 2497
         self.client.configure_active_directory(fake.CIFS_SECURITY_SERVICE,
2497 2498
                                                fake.VSERVER_NAME)
@@ -2511,6 +2512,8 @@ class NetAppClientCmodeTestCase(test.TestCase):
2511 2512
 
2512 2513
         self.client.configure_dns.assert_called_with(
2513 2514
             fake.CIFS_SECURITY_SERVICE)
2515
+        self.client.set_preferred_dc.assert_called_with(
2516
+            fake.CIFS_SECURITY_SERVICE)
2514 2517
         self.client.send_request.assert_has_calls([
2515 2518
             mock.call('cifs-server-create', cifs_server_create_args)])
2516 2519
 
@@ -2703,6 +2706,37 @@ class NetAppClientCmodeTestCase(test.TestCase):
2703 2706
                           self.client.configure_dns,
2704 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 2740
     def test_create_volume(self):
2707 2741
 
2708 2742
         self.mock_object(self.client, 'send_request')

+ 8
- 0
releasenotes/notes/bug-1804651-netapp-cdot-add-peferred-dc-to-cifs-ad-99072ce663762e83.yaml View File

@@ -0,0 +1,8 @@
1
+---
2
+features:
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.

Loading…
Cancel
Save