components/openstack/cinder/patches/16-launchpad-1565051.patch
author Drew Fisher <drew.fisher@oracle.com>
Tue, 15 Nov 2016 08:24:40 -0800
changeset 7604 f1b0301e4a0a
permissions -rw-r--r--
23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7604
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
     1
Based on patchset # 8 from https://review.openstack.org/#/c/371199/
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
     2
and modified for use in Mitaka.
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
     3
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
     4
From 9c39d55f8f3bfa8a1384919df2c3f8e6aafef69a Mon Sep 17 00:00:00 2001
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
     5
From: iain MacDonnell <[email protected]>
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
     6
Date: Tue, 20 Dec 2016 02:56:31 +0000
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
     7
Subject: [PATCH] ZFSSA volume driver multi-connect
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
     8
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
     9
Fix ZFSSA volume driver to allow connection of a volume to more
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    10
than one connector (initiator group) at the same time, which is
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    11
required for live-migration to work.
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    12
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    13
Note: ZFSSA software release 2013.1.3.x (or higher) will be required
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    14
to use this functionality.
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    15
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    16
Change-Id: I44b86fd967a21da465b44a8db15331ca17438961
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    17
Closes-Bug: #1565051
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    18
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    19
--- cinder-8.0.0/cinder/tests/unit/test_zfssa.py.orig   2017-01-25 15:04:22.074740153 +0000
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    20
+++ cinder-8.0.0/cinder/tests/unit/test_zfssa.py       2017-01-25 15:07:00.610253132 +0000
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    21
@@ -445,27 +445,117 @@ class TestZFSSAISCSIDriver(test.TestCase
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    22
     def test_volume_attach_detach(self, _get_provider_info):
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    23
         lcfg = self.configuration
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    24
         test_target_iqn = 'iqn.1986-03.com.sun:02:00000-aaaa-bbbb-cccc-ddddd'
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    25
-        stub_val = {'provider_location':
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    26
-                    '%s %s 0' % (lcfg.zfssa_target_portal, test_target_iqn)}
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    27
-        self.drv._get_provider_info.return_value = stub_val
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    28
+        self.drv._get_provider_info.return_value = {
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    29
+            'provider_location': '%s %s' % (lcfg.zfssa_target_portal,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    30
+                                            test_target_iqn)
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    31
+        }
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    32
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    33
-        connector = dict(initiator='iqn.1-0.org.deb:01:d7')
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    34
+        def side_effect_get_initiator_initiatorgroup(arg):
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    35
+            return [{
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    36
+                'iqn.1-0.org.deb:01:d7': 'test-init-grp1',
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    37
+                'iqn.1-0.org.deb:01:d9': 'test-init-grp2',
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    38
+            }[arg]]
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    39
+
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    40
+        self.drv.zfssa.get_initiator_initiatorgroup.side_effect = (
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    41
+            side_effect_get_initiator_initiatorgroup)
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    42
+
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    43
+        initiator = 'iqn.1-0.org.deb:01:d7'
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    44
+        initiator_group = 'test-init-grp1'
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    45
+        lu_number = '246'
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    46
+
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    47
+        self.drv.zfssa.get_lun.side_effect = iter([
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    48
+            {'initiatorgroup': [], 'number': []},
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    49
+            {'initiatorgroup': [initiator_group], 'number': [lu_number]},
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    50
+            {'initiatorgroup': [initiator_group], 'number': [lu_number]},
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    51
+        ])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    52
+
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    53
+        connector = dict(initiator=initiator)
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    54
         props = self.drv.initialize_connection(self.test_vol, connector)
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    55
-        self.drv._get_provider_info.assert_called_once_with(self.test_vol)
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    56
+        self.drv._get_provider_info.assert_called_once_with()
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    57
         self.assertEqual('iscsi', props['driver_volume_type'])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    58
         self.assertEqual(self.test_vol['id'], props['data']['volume_id'])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    59
         self.assertEqual(lcfg.zfssa_target_portal,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    60
                          props['data']['target_portal'])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    61
         self.assertEqual(test_target_iqn, props['data']['target_iqn'])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    62
-        self.assertEqual(0, props['data']['target_lun'])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    63
+        self.assertEqual(int(lu_number), props['data']['target_lun'])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    64
         self.assertFalse(props['data']['target_discovered'])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    65
+        self.drv.zfssa.set_lun_initiatorgroup.assert_called_with(
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    66
+            lcfg.zfssa_pool,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    67
+            lcfg.zfssa_project,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    68
+            self.test_vol['name'],
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    69
+            [initiator_group])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    70
+
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    71
+        self.drv.terminate_connection(self.test_vol, connector)
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    72
+        self.drv.zfssa.set_lun_initiatorgroup.assert_called_with(
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    73
+            lcfg.zfssa_pool,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    74
+            lcfg.zfssa_project,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    75
+            self.test_vol['name'],
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    76
+            [])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    77
+
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    78
+    @mock.patch.object(iscsi.ZFSSAISCSIDriver, '_get_provider_info')
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    79
+    def test_volume_attach_detach_live_migration(self, _get_provider_info):
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    80
+        lcfg = self.configuration
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    81
+        test_target_iqn = 'iqn.1986-03.com.sun:02:00000-aaaa-bbbb-cccc-ddddd'
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    82
+        self.drv._get_provider_info.return_value = {
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    83
+            'provider_location': '%s %s' % (lcfg.zfssa_target_portal,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    84
+                                            test_target_iqn)
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    85
+        }
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    86
+
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    87
+        def side_effect_get_initiator_initiatorgroup(arg):
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    88
+            return [{
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    89
+                'iqn.1-0.org.deb:01:d7': 'test-init-grp1',
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    90
+                'iqn.1-0.org.deb:01:d9': 'test-init-grp2',
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    91
+            }[arg]]
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    92
+
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    93
+        self.drv.zfssa.get_initiator_initiatorgroup.side_effect = (
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    94
+            side_effect_get_initiator_initiatorgroup)
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    95
+
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    96
+        src_initiator = 'iqn.1-0.org.deb:01:d7'
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    97
+        src_initiator_group = 'test-init-grp1'
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    98
+        src_connector = dict(initiator=src_initiator)
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    99
+        src_lu_number = '123'
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   100
+
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   101
+        dst_initiator = 'iqn.1-0.org.deb:01:d9'
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   102
+        dst_initiator_group = 'test-init-grp2'
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   103
+        dst_connector = dict(initiator=dst_initiator)
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   104
+        dst_lu_number = '456'
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   105
+
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   106
+        # In the beginning, the LUN is already presented to the source
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   107
+        # node. During initialize_connection(), and at the beginning of
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   108
+        # terminate_connection(), it's presented to both nodes.
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   109
+        self.drv.zfssa.get_lun.side_effect = iter([
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   110
+            {'initiatorgroup': [src_initiator_group],
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   111
+             'number': [src_lu_number]},
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   112
+            {'initiatorgroup': [dst_initiator_group, src_initiator_group],
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   113
+             'number': [dst_lu_number, src_lu_number]},
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   114
+            {'initiatorgroup': [dst_initiator_group, src_initiator_group],
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   115
+             'number': [dst_lu_number, src_lu_number]},
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   116
+        ])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   117
+
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   118
+        # Before migration, the volume gets connected to the destination
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   119
+        # node (whilst still connected to the source node), so it should
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   120
+        # be presented to the initiator groups for both
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   121
+        props = self.drv.initialize_connection(self.test_vol, dst_connector)
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   122
+        self.drv.zfssa.set_lun_initiatorgroup.assert_called_with(
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   123
+            lcfg.zfssa_pool,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   124
+            lcfg.zfssa_project,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   125
+            self.test_vol['name'],
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   126
+            [src_initiator_group, dst_initiator_group])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   127
+
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   128
+        # LU number must be an int -
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   129
+        # https://bugs.launchpad.net/cinder/+bug/1538582
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   130
+        # and must be the LU number for the destination node's
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   131
+        # initiatorgroup (where the connection was just initialized)
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   132
+        self.assertEqual(int(dst_lu_number), props['data']['target_lun'])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   133
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   134
-        self.drv.terminate_connection(self.test_vol, '')
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   135
-        self.drv.zfssa.set_lun_initiatorgroup.assert_called_once_with(
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   136
+        # After migration, the volume gets detached from the source node
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   137
+        # so it should be present to only the destination node
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   138
+        self.drv.terminate_connection(self.test_vol, src_connector)
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   139
+        self.drv.zfssa.set_lun_initiatorgroup.assert_called_with(
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   140
             lcfg.zfssa_pool,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   141
             lcfg.zfssa_project,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   142
             self.test_vol['name'],
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   143
-            '')
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   144
+            [dst_initiator_group])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   145
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   146
     def test_volume_attach_detach_negative(self):
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   147
         self.drv.zfssa.get_initiator_initiatorgroup.return_value = []
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   148
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   149
--- cinder-8.0.0/cinder/volume/drivers/zfssa/zfssaiscsi.py.orig	2017-01-25 10:52:12.359163201 +0000
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   150
+++ cinder-8.0.0/cinder/volume/drivers/zfssa/zfssaiscsi.py	2017-01-25 10:55:45.101897566 +0000
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   151
@@ -269,27 +269,14 @@ class ZFSSAISCSIDriver(driver.ISCSIDrive
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   152
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   153
             self.zfssa.verify_target(self._get_target_alias())
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   154
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   155
-    def _get_provider_info(self, volume, lun=None):
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   156
+    def _get_provider_info(self):
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   157
         """Return provider information."""
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   158
         lcfg = self.configuration
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   159
-        project = lcfg.zfssa_project
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   160
-        if ((lcfg.zfssa_enable_local_cache is True) and
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   161
-                (volume['name'].startswith('os-cache-vol-'))):
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   162
-            project = lcfg.zfssa_cache_project
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   163
-
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   164
-        if lun is None:
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   165
-            lun = self.zfssa.get_lun(lcfg.zfssa_pool,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   166
-                                     project,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   167
-                                     volume['name'])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   168
-
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   169
-        if isinstance(lun['number'], list):
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   170
-            lun['number'] = lun['number'][0]
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   171
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   172
         if self.tgtiqn is None:
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   173
             self.tgtiqn = self.zfssa.get_target(self._get_target_alias())
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   174
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   175
-        loc = "%s %s %s" % (lcfg.zfssa_target_portal, self.tgtiqn,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   176
-                            lun['number'])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   177
+        loc = "%s %s" % (lcfg.zfssa_target_portal, self.tgtiqn)
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   178
         LOG.debug('_get_provider_info: provider_location: %s', loc)
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   179
         provider = {'provider_location': loc}
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   180
         if lcfg.zfssa_target_user != '' and lcfg.zfssa_target_password != '':
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   181
@@ -730,6 +717,11 @@ class ZFSSAISCSIDriver(driver.ISCSIDrive
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   182
         return lun['size'] == size
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   183
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   184
     def initialize_connection(self, volume, connector):
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   185
+        """Driver entry point to setup a connection for a volume."""
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   186
+        LOG.debug('Initializing volume connection. volume: %(volname)s, '
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   187
+                  'connector: %(connector)s',
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   188
+                  {'volname': volume['name'],
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   189
+                   'connector': connector})
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   190
         lcfg = self.configuration
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   191
         init_groups = self.zfssa.get_initiator_initiatorgroup(
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   192
             connector['initiator'])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   193
@@ -748,19 +740,37 @@ class ZFSSAISCSIDriver(driver.ISCSIDrive
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   194
         else:
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   195
             project = lcfg.zfssa_project
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   196
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   197
-        for initiator_group in init_groups:
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   198
-            self.zfssa.set_lun_initiatorgroup(lcfg.zfssa_pool,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   199
-                                              project,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   200
-                                              volume['name'],
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   201
-                                              initiator_group)
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   202
+        lun = self.zfssa.get_lun(lcfg.zfssa_pool, project, volume['name'])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   203
+
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   204
+        # Construct a set (to avoid duplicates) of initiator groups by
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   205
+        # combining the list to which the LUN is already presented with
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   206
+        # the list for the new connector.
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   207
+        new_init_groups = set(lun['initiatorgroup'] + init_groups)
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   208
+        self.zfssa.set_lun_initiatorgroup(lcfg.zfssa_pool,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   209
+                                          project,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   210
+                                          volume['name'],
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   211
+                                          sorted(list(new_init_groups)))
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   212
+
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   213
         iscsi_properties = {}
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   214
-        provider = self._get_provider_info(volume)
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   215
+        provider = self._get_provider_info()
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   216
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   217
-        (target_portal, iqn, lun) = provider['provider_location'].split()
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   218
+        (target_portal, target_iqn) = provider['provider_location'].split()
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   219
         iscsi_properties['target_discovered'] = False
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   220
         iscsi_properties['target_portal'] = target_portal
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   221
-        iscsi_properties['target_iqn'] = iqn
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   222
-        iscsi_properties['target_lun'] = int(lun)
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   223
+        iscsi_properties['target_iqn'] = target_iqn
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   224
+
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   225
+        # Get LUN again to discover new initiator group mapping
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   226
+        lun = self.zfssa.get_lun(lcfg.zfssa_pool, project, volume['name'])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   227
+
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   228
+        # Construct a mapping of LU number to initiator group.
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   229
+        lu_map = dict(zip(lun['initiatorgroup'], lun['number']))
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   230
+
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   231
+        # When an initiator is a member of multiple groups, and a LUN is
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   232
+        # presented to all of them, the same LU number is assigned to all of
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   233
+        # them, so we can use the first initator group containing the
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   234
+        # initiator to lookup the right LU number in our mapping
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   235
+        iscsi_properties['target_lun'] = int(lu_map[init_groups[0]])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   236
+
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   237
         iscsi_properties['volume_id'] = volume['id']
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   238
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   239
         if 'provider_auth' in provider:
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   240
@@ -777,16 +787,28 @@ class ZFSSAISCSIDriver(driver.ISCSIDrive
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   241
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   242
     def terminate_connection(self, volume, connector, **kwargs):
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   243
         """Driver entry point to terminate a connection for a volume."""
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   244
-        LOG.debug('terminate_connection: volume name: %s.', volume['name'])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   245
+        LOG.debug('Terminating volume connection. volume: %(volname)s, '
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   246
+                  'connector: %(connector)s',
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   247
+                  {'volname': volume['name'],
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   248
+                   'connector': connector})
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   249
         lcfg = self.configuration
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   250
         project = lcfg.zfssa_project
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   251
+        pool = lcfg.zfssa_pool
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   252
+        connector_init_groups = self.zfssa.get_initiator_initiatorgroup(
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   253
+            connector['initiator'])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   254
         if ((lcfg.zfssa_enable_local_cache is True) and
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   255
                 (volume['name'].startswith('os-cache-vol-'))):
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   256
             project = lcfg.zfssa_cache_project
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   257
-        self.zfssa.set_lun_initiatorgroup(lcfg.zfssa_pool,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   258
+        lun = self.zfssa.get_lun(pool, project, volume['name'])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   259
+        # Construct the new set of initiator groups, starting with the list
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   260
+        # that the volume is currently connected to, then removing those
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   261
+        # associated with the connector that we're detaching from
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   262
+        new_init_groups = set(lun['initiatorgroup'])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   263
+        new_init_groups -= set(connector_init_groups)
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   264
+        self.zfssa.set_lun_initiatorgroup(pool,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   265
                                           project,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   266
                                           volume['name'],
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   267
-                                          '')
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   268
+                                          sorted(list(new_init_groups)))
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   269
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   270
     def _get_voltype_specs(self, volume):
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   271
         """Get specs suitable for volume creation."""
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   272
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   273
--- cinder-8.0.0/cinder/volume/drivers/zfssa/zfssarest.py.orig	2017-01-25 10:56:44.811166673 +0000
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   274
+++ cinder-8.0.0/cinder/volume/drivers/zfssa/zfssarest.py	2017-01-25 10:59:44.000469150 +0000
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   275
@@ -746,11 +746,26 @@ class ZFSSAApi(object):
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   276
             raise exception.VolumeNotFound(volume_id=lun)
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   277
 
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   278
         val = json.loads(ret.data)
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   279
+
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   280
+        # For backward-compatibility with 2013.1.2.x, convert initiatorgroup
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   281
+        # and number to lists if they're not already
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   282
+        def _listify(item):
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   283
+            return item if isinstance(item, list) else [item]
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   284
+
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   285
+        initiatorgroup = _listify(val['lun']['initiatorgroup'])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   286
+        number = _listify(val['lun']['assignednumber'])
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   287
+
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   288
+        # Hide special maskAll value when LUN is not currently presented to
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   289
+        # any initiatorgroups:
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   290
+        if 'com.sun.ms.vss.hg.maskAll' in initiatorgroup:
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   291
+            initiatorgroup = []
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   292
+            number = []
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   293
+
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   294
         ret = {
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   295
             'name': val['lun']['name'],
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   296
             'guid': val['lun']['lunguid'],
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   297
-            'number': val['lun']['assignednumber'],
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   298
-            'initiatorgroup': val['lun']['initiatorgroup'],
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   299
+            'number': number,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   300
+            'initiatorgroup': initiatorgroup,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   301
             'size': val['lun']['volsize'],
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   302
             'nodestroy': val['lun']['nodestroy'],
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   303
             'targetgroup': val['lun']['targetgroup']
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   304
@@ -797,8 +812,15 @@ class ZFSSAApi(object):
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   305
 
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   306
     def set_lun_initiatorgroup(self, pool, project, lun, initiatorgroup):
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   307
         """Set the initiatorgroup property of a LUN."""
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   308
-        if initiatorgroup == '':
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   309
+
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   310
+        # For backward-compatibility with 2013.1.2.x, set initiatorgroup
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   311
+        # to a single string if there's only one item in the list.
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   312
+        # Live-migration won't work, but existing functionality should still
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   313
+        # work. If the list is empty, substitute the special "maskAll" value.
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   314
+        if len(initiatorgroup) == 0:
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   315
             initiatorgroup = 'com.sun.ms.vss.hg.maskAll'
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   316
+        elif len(initiatorgroup) == 1:
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   317
+            initiatorgroup = initiatorgroup[0]
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   318
 
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   319
         svc = '/api/storage/v1/pools/' + pool + '/projects/' + \
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   320
             project + '/luns/' + lun
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   321
@@ -806,6 +828,14 @@ class ZFSSAApi(object):
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   322
             'initiatorgroup': initiatorgroup
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   323
         }
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   324
 
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   325
+        LOG.debug('Setting LUN initiatorgroup. pool=%(pool)s, '
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   326
+                  'project=%(project)s, lun=%(lun)s, '
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   327
+                  'initiatorgroup=%(initiatorgroup)s',
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   328
+                  {'project': project,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   329
+                   'pool': pool,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   330
+                   'lun': lun,
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   331
+                   'initiatorgroup': initiatorgroup})
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   332
+
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   333
         ret = self.rclient.put(svc, arg)
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   334
         if ret.status != restclient.Status.ACCEPTED:
f1b0301e4a0a 23026479 Live-migration with ZFSSA-backed cinder volume - filesystems to go read-only
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   335
             LOG.error(_LE('Error Setting Volume: %(lun)s to InitiatorGroup: '