|
1 This patch is to replace the linux-specific codes with the solaris |
|
2 codes to support the cinder backup on the Solaris. |
|
3 |
|
4 --- cinder-2014.2.2/cinder/brick/initiator/connector.py.~1~ 2014-10-16 06:26:26.000000000 -0700 |
|
5 +++ cinder-2014.2.2/cinder/brick/initiator/connector.py 2015-01-04 23:12:23.661116812 -0800 |
|
6 @@ -15,6 +15,7 @@ |
|
7 |
|
8 import os |
|
9 import socket |
|
10 +import sys |
|
11 import time |
|
12 |
|
13 from cinder.brick import exception |
|
14 @@ -22,6 +23,8 @@ |
|
15 from cinder.brick.initiator import host_driver |
|
16 from cinder.brick.initiator import linuxfc |
|
17 from cinder.brick.initiator import linuxscsi |
|
18 +from cinder.brick.initiator import solarisfc |
|
19 +from cinder.brick.initiator import solarisiscsi |
|
20 from cinder.brick.remotefs import remotefs |
|
21 from cinder.i18n import _ |
|
22 from cinder.openstack.common import lockutils |
|
23 @@ -39,7 +42,10 @@ |
|
24 """Get the connection properties for all protocols.""" |
|
25 |
|
26 iscsi = ISCSIConnector(root_helper=root_helper) |
|
27 - fc = linuxfc.LinuxFibreChannel(root_helper=root_helper) |
|
28 + if sys.platform == 'sunos5': |
|
29 + fc = solarisfc.SolarisFibreChannel() |
|
30 + else: |
|
31 + fc = linuxfc.LinuxFibreChannel(root_helper=root_helper) |
|
32 |
|
33 props = {} |
|
34 props['ip'] = my_ip |
|
35 @@ -134,8 +140,11 @@ |
|
36 'of=/dev/null', 'count=1') |
|
37 out, info = None, None |
|
38 try: |
|
39 - out, info = self._execute(*cmd, run_as_root=True, |
|
40 - root_helper=self._root_helper) |
|
41 + if sys.platform == 'sunos5': |
|
42 + out, info = self._execute(*cmd) |
|
43 + else: |
|
44 + out, info = self._execute(*cmd, run_as_root=True, |
|
45 + root_helper=self._root_helper) |
|
46 except putils.ProcessExecutionError as e: |
|
47 LOG.error(_("Failed to access the device on the path " |
|
48 "%(path)s: %(error)s %(info)s.") % |
|
49 @@ -171,7 +180,10 @@ |
|
50 execute=putils.execute, use_multipath=False, |
|
51 device_scan_attempts=DEVICE_SCAN_ATTEMPTS_DEFAULT, |
|
52 *args, **kwargs): |
|
53 - self._linuxscsi = linuxscsi.LinuxSCSI(root_helper, execute) |
|
54 + if sys.platform == 'sunos5': |
|
55 + self._solarisiscsi = solarisiscsi.SolarisiSCSI() |
|
56 + else: |
|
57 + self._linuxscsi = linuxscsi.LinuxSCSI(root_helper, execute) |
|
58 super(ISCSIConnector, self).__init__(root_helper, driver=driver, |
|
59 execute=execute, |
|
60 device_scan_attempts= |
|
61 @@ -192,6 +204,9 @@ |
|
62 target_iqn - iSCSI Qualified Name |
|
63 target_lun - LUN id of the volume |
|
64 """ |
|
65 + if sys.platform == 'sunos5': |
|
66 + return self._solarisiscsi.connect_volume(connection_properties, |
|
67 + self.device_scan_attempts) |
|
68 |
|
69 device_info = {'type': 'block'} |
|
70 |
|
71 @@ -262,6 +277,10 @@ |
|
72 target_iqn - iSCSI Qualified Name |
|
73 target_lun - LUN id of the volume |
|
74 """ |
|
75 + if sys.platform == 'sunos5': |
|
76 + self._solarisiscsi.disconnect_iscsi() |
|
77 + return |
|
78 + |
|
79 # Moved _rescan_iscsi and _rescan_multipath |
|
80 # from _disconnect_volume_multipath_iscsi to here. |
|
81 # Otherwise, if we do rescan after _linuxscsi.remove_multipath_device |
|
82 @@ -306,6 +325,9 @@ |
|
83 |
|
84 def get_initiator(self): |
|
85 """Secure helper to read file as root.""" |
|
86 + if sys.platform == 'sunos5': |
|
87 + return self._solarisiscsi.get_initiator() |
|
88 + |
|
89 file_path = '/etc/iscsi/initiatorname.iscsi' |
|
90 try: |
|
91 lines, _err = self._execute('cat', file_path, run_as_root=True, |
|
92 @@ -555,8 +577,11 @@ |
|
93 execute=putils.execute, use_multipath=False, |
|
94 device_scan_attempts=DEVICE_SCAN_ATTEMPTS_DEFAULT, |
|
95 *args, **kwargs): |
|
96 - self._linuxscsi = linuxscsi.LinuxSCSI(root_helper, execute) |
|
97 - self._linuxfc = linuxfc.LinuxFibreChannel(root_helper, execute) |
|
98 + if sys.platform == 'sunos5': |
|
99 + self._solarisfc = solarisfc.SolarisFibreChannel() |
|
100 + else: |
|
101 + self._linuxscsi = linuxscsi.LinuxSCSI(root_helper, execute) |
|
102 + self._linuxfc = linuxfc.LinuxFibreChannel(root_helper, execute) |
|
103 super(FibreChannelConnector, self).__init__(root_helper, driver=driver, |
|
104 execute=execute, |
|
105 device_scan_attempts= |
|
106 @@ -578,6 +603,10 @@ |
|
107 target_iqn - iSCSI Qualified Name |
|
108 target_lun - LUN id of the volume |
|
109 """ |
|
110 + if sys.platform == 'sunos5': |
|
111 + return self._solarisfc.connect_volume(connection_properties, |
|
112 + self.device_scan_attempts) |
|
113 + |
|
114 LOG.debug("execute = %s" % self._execute) |
|
115 device_info = {'type': 'block'} |
|
116 |
|
117 @@ -686,6 +715,13 @@ |
|
118 target_wwn - iSCSI Qualified Name |
|
119 target_lun - LUN id of the volume |
|
120 """ |
|
121 + if sys.platform == 'sunos5': |
|
122 + # There is some latency before the next time connection happens. |
|
123 + # The best practice is to offline the state of the switch now |
|
124 + # and online it at the next connection. |
|
125 + # But now, we just return without any operation. |
|
126 + return |
|
127 + |
|
128 devices = device_info['devices'] |
|
129 |
|
130 # If this is a multipath device, we need to search again |
|
131 |
|
132 |
|
133 --- cinder-2014.2.2/cinder/utils.py.~1~ 2014-10-16 06:26:26.000000000 -0700 |
|
134 +++ cinder-2014.2.2/cinder/utils.py 2015-01-04 23:26:04.305688145 -0800 |
|
135 @@ -137,8 +137,9 @@ |
|
136 |
|
137 def execute(*cmd, **kwargs): |
|
138 """Convenience wrapper around oslo's execute() method.""" |
|
139 - if 'run_as_root' in kwargs and 'root_helper' not in kwargs: |
|
140 - kwargs['root_helper'] = get_root_helper() |
|
141 + if sys.platform != 'sunos5': |
|
142 + if 'run_as_root' in kwargs and 'root_helper' not in kwargs: |
|
143 + kwargs['root_helper'] = get_root_helper() |
|
144 return processutils.execute(*cmd, **kwargs) |
|
145 |
|
146 |