21365620 cinder volume backups sometimes fail on SPARC
authorStrony <strony.zhang@oracle.com>
Tue, 18 Aug 2015 13:55:16 -0700
changeset 4793 24053a14d972
parent 4792 969312f27025
child 4794 be62c55aa235
21365620 cinder volume backups sometimes fail on SPARC
components/openstack/cinder/files/cinder.exec_attr
components/openstack/cinder/files/solaris/solarisfc.py
components/openstack/cinder/files/solaris/solarisiscsi.py
--- a/components/openstack/cinder/files/cinder.exec_attr	Tue Aug 18 13:30:09 2015 -0700
+++ b/components/openstack/cinder/files/cinder.exec_attr	Tue Aug 18 13:55:16 2015 -0700
@@ -9,6 +9,8 @@
 
 cinder-volume:solaris:cmd:RO::/usr/sbin/fcinfo:privs=file_dac_read,sys_devices
 
+cinder-volume:solaris:cmd:RO::/usr/sbin/format:euid=0
+
 cinder-volume:solaris:cmd:RO::/usr/sbin/iscsiadm:euid=0
 
 cinder-volume:solaris:cmd:RO::/usr/sbin/itadm:uid=0
--- a/components/openstack/cinder/files/solaris/solarisfc.py	Tue Aug 18 13:30:09 2015 -0700
+++ b/components/openstack/cinder/files/solaris/solarisfc.py	Tue Aug 18 13:55:16 2015 -0700
@@ -17,6 +17,7 @@
 """Generic Solaris Fibre Channel utilities."""
 
 import os
+import platform
 import time
 
 from cinder.brick import exception
@@ -107,7 +108,7 @@
         for wwpn in wwpns:
             self.execute('/usr/sbin/fcadm', 'force-lip', wwpn)
 
-    def get_device_path(self, wwn):
+    def _get_device_path(self, wwn):
         """Get the Device Name of the WWN"""
         try:
             out, err = self.execute('/usr/sbin/fcinfo', 'logical-unit', '-v')
@@ -146,7 +147,7 @@
         # a refresh.
         for i in range(1, scan_tries):
             LOG.debug("Looking for Fibre Channel device")
-            host_dev = self.get_device_path(wwn)
+            host_dev = self._get_device_path(wwn)
 
             if host_dev is not None and os.path.exists(host_dev):
                 break
@@ -158,5 +159,15 @@
             LOG.error(msg)
             raise exception.NoFibreChannelVolumeDeviceFound()
 
+        # Set the label EFI to the disk on SPARC before it is accessed and
+        # make sure the correct device path with slice 0
+        # (like '/dev/rdsk/c0t600xxxd0s0').
+        if platform.processor() == 'sparc':
+            tmp_dev_name = host_device.rsplit('s', 1)
+            disk_name = tmp_dev_name[0].split('/')[-1]
+            (out, _err) = self.execute('/usr/sbin/format', '-L', 'efi', '-d',
+                                       disk_name)
+            host_device = '%ss0' % tmp_dev_name[0]
+
         device_info['path'] = host_dev
         return device_info
--- a/components/openstack/cinder/files/solaris/solarisiscsi.py	Tue Aug 18 13:30:09 2015 -0700
+++ b/components/openstack/cinder/files/solaris/solarisiscsi.py	Tue Aug 18 13:55:16 2015 -0700
@@ -17,6 +17,7 @@
 """Generic Solaris iSCSI utilities."""
 
 import os
+import platform
 import time
 
 from cinder.brick import exception
@@ -107,5 +108,15 @@
         else:
             raise exception.VolumeDeviceNotFound(device=host_device)
 
+        # Set the label EFI to the disk on SPARC before it is accessed and
+        # make sure the correct device path with slice 0
+        # (like '/dev/rdsk/c0t600xxxd0s0').
+        if platform.processor() == 'sparc':
+            tmp_dev_name = host_device.rsplit('s', 1)
+            disk_name = tmp_dev_name[0].split('/')[-1]
+            (out, _err) = self.execute('/usr/sbin/format', '-L', 'efi', '-d',
+                                       disk_name)
+            host_device = '%ss0' % tmp_dev_name[0]
+
         device_info['path'] = host_device
         return device_info