1 This patch is to replace Linux-specific code with conditional checks in |
1 This patch is to replace Linux-specific code with conditional checks in |
2 the Cinder Brick code to support Cinder backup on Solaris. Patch has |
2 the Cinder Brick code to support Cinder backup on Solaris. Patch has |
3 not yet been submitted upstream. |
3 not yet been submitted upstream. |
4 |
4 |
5 --- cinder-2015.1.2/cinder/brick/initiator/connector.py.~1~ 2015-10-13 09:27:35.000000000 -0700 |
5 --- cinder-8.0.0/cinder/utils.py.~1~ 2016-04-07 00:30:55.000000000 -0700 |
6 +++ cinder-2015.1.2/cinder/brick/initiator/connector.py 2016-01-31 00:12:30.729547660 -0800 |
6 +++ cinder-8.0.0/cinder/utils.py 2016-06-10 14:39:00.866171230 -0700 |
7 @@ -32,6 +32,8 @@ from cinder.brick.initiator import host_ |
7 @@ -143,8 +143,12 @@ def check_exclusive_options(**kwargs): |
8 from cinder.brick.initiator import linuxfc |
|
9 from cinder.brick.initiator import linuxscsi |
|
10 from cinder.brick.remotefs import remotefs |
|
11 +from cinder.brick.initiator import solarisfc |
|
12 +from cinder.brick.initiator import solarisiscsi |
|
13 from cinder.i18n import _, _LE, _LW |
|
14 from cinder.openstack.common import loopingcall |
|
15 |
|
16 @@ -72,7 +74,10 @@ def get_connector_properties(root_helper |
|
17 """ |
|
18 |
|
19 iscsi = ISCSIConnector(root_helper=root_helper) |
|
20 - fc = linuxfc.LinuxFibreChannel(root_helper=root_helper) |
|
21 + if sys.platform == 'sunos5': |
|
22 + fc = solarisfc.SolarisFibreChannel() |
|
23 + else: |
|
24 + fc = linuxfc.LinuxFibreChannel(root_helper=root_helper) |
|
25 |
|
26 props = {} |
|
27 props['ip'] = my_ip |
|
28 @@ -188,8 +193,11 @@ class InitiatorConnector(executor.Execut |
|
29 'of=/dev/null', 'count=1') |
|
30 out, info = None, None |
|
31 try: |
|
32 - out, info = self._execute(*cmd, run_as_root=run_as_root, |
|
33 - root_helper=self._root_helper) |
|
34 + if sys.platform == 'sunos5': |
|
35 + out, info = self._execute(*cmd) |
|
36 + else: |
|
37 + out, info = self._execute(*cmd, run_as_root=run_as_root, |
|
38 + root_helper=self._root_helper) |
|
39 except putils.ProcessExecutionError as e: |
|
40 LOG.error(_LE("Failed to access the device on the path " |
|
41 "%(path)s: %(error)s %(info)s.") % |
|
42 @@ -225,7 +233,10 @@ class ISCSIConnector(InitiatorConnector) |
|
43 execute=putils.execute, use_multipath=False, |
|
44 device_scan_attempts=DEVICE_SCAN_ATTEMPTS_DEFAULT, |
|
45 *args, **kwargs): |
|
46 - self._linuxscsi = linuxscsi.LinuxSCSI(root_helper, execute) |
|
47 + if sys.platform == 'sunos5': |
|
48 + self._solarisiscsi = solarisiscsi.SolarisiSCSI() |
|
49 + else: |
|
50 + self._linuxscsi = linuxscsi.LinuxSCSI(root_helper, execute) |
|
51 super(ISCSIConnector, self).__init__(root_helper, driver=driver, |
|
52 execute=execute, |
|
53 device_scan_attempts= |
|
54 @@ -235,6 +246,8 @@ class ISCSIConnector(InitiatorConnector) |
|
55 |
|
56 def set_execute(self, execute): |
|
57 super(ISCSIConnector, self).set_execute(execute) |
|
58 + if sys.platform == 'sunos5': |
|
59 + return |
|
60 self._linuxscsi.set_execute(execute) |
|
61 |
|
62 def _iterate_all_targets(self, connection_properties): |
|
63 @@ -289,6 +302,9 @@ class ISCSIConnector(InitiatorConnector) |
|
64 Note that plural keys may be used when use_multipath=True |
|
65 """ |
|
66 |
|
67 + if sys.platform == 'sunos5': |
|
68 + return self._solarisiscsi.connect_volume(connection_properties, |
|
69 + self.device_scan_attempts) |
|
70 device_info = {'type': 'block'} |
|
71 |
|
72 if self.use_multipath: |
|
73 @@ -365,6 +381,8 @@ class ISCSIConnector(InitiatorConnector) |
|
74 target_iqn(s) - iSCSI Qualified Name |
|
75 target_lun(s) - LUN id of the volume |
|
76 """ |
|
77 + if sys.platform == 'sunos5': |
|
78 + return |
|
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 @@ -431,6 +449,9 @@ class ISCSIConnector(InitiatorConnector) |
|
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 @@ -674,8 +695,11 @@ class FibreChannelConnector(InitiatorCon |
|
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 @@ -685,6 +709,8 @@ class FibreChannelConnector(InitiatorCon |
|
107 |
|
108 def set_execute(self, execute): |
|
109 super(FibreChannelConnector, self).set_execute(execute) |
|
110 + if sys.platform == 'sunos5': |
|
111 + return |
|
112 self._linuxscsi.set_execute(execute) |
|
113 self._linuxfc.set_execute(execute) |
|
114 |
|
115 @@ -697,6 +723,10 @@ class FibreChannelConnector(InitiatorCon |
|
116 target_iqn - iSCSI Qualified Name |
|
117 target_lun - LUN id of the volume |
|
118 """ |
|
119 + if sys.platform == 'sunos5': |
|
120 + return self._solarisfc.connect_volume(connection_properties, |
|
121 + self.device_scan_attempts) |
|
122 + |
|
123 LOG.debug("execute = %s" % self._execute) |
|
124 device_info = {'type': 'block'} |
|
125 |
|
126 @@ -830,6 +860,13 @@ class FibreChannelConnector(InitiatorCon |
|
127 target_wwn - iSCSI Qualified Name |
|
128 target_lun - LUN id of the volume |
|
129 """ |
|
130 + if sys.platform == 'sunos5': |
|
131 + # There is some latency before the next time connection happens. |
|
132 + # The best practice is to offline the state of the switch now |
|
133 + # and online it at the next connection. |
|
134 + # But now, we just return without any operation. |
|
135 + return |
|
136 + |
|
137 devices = device_info['devices'] |
|
138 |
|
139 # If this is a multipath device, we need to search again |
|
140 --- cinder-2015.1.2/cinder/utils.py.~1~ 2015-10-13 09:27:35.000000000 -0700 |
|
141 +++ cinder-2015.1.2/cinder/utils.py 2016-01-31 00:12:30.730160694 -0800 |
|
142 @@ -138,8 +138,12 @@ def check_exclusive_options(**kwargs): |
|
143 |
8 |
144 def execute(*cmd, **kwargs): |
9 def execute(*cmd, **kwargs): |
145 """Convenience wrapper around oslo's execute() method.""" |
10 """Convenience wrapper around oslo's execute() method.""" |
146 - if 'run_as_root' in kwargs and 'root_helper' not in kwargs: |
11 - if 'run_as_root' in kwargs and 'root_helper' not in kwargs: |
147 - kwargs['root_helper'] = get_root_helper() |
12 - kwargs['root_helper'] = get_root_helper() |