|
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 |
|
3 not yet been submitted upstream. |
|
4 |
|
5 --- os-brick-1.2.0/os_brick/initiator/connector.py.~1~ 2016-03-28 09:30:49.000000000 +0000 |
|
6 +++ os-brick-1.2.0/os_brick/initiator/connector.py 2016-09-06 16:59:42.732438933 +0000 |
|
7 @@ -54,6 +54,8 @@ from os_brick.initiator import linuxfc |
|
8 from os_brick.initiator import linuxrbd |
|
9 from os_brick.initiator import linuxscsi |
|
10 from os_brick.remotefs import remotefs |
|
11 +from os_brick.initiator import solarisfc |
|
12 +from os_brick.initiator import solarisiscsi |
|
13 from os_brick.i18n import _, _LE, _LI, _LW |
|
14 |
|
15 LOG = logging.getLogger(__name__) |
|
16 @@ -122,7 +124,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 @@ -284,8 +289,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 @@ -502,7 +510,10 @@ class ISCSIConnector(InitiatorConnector) |
|
43 execute=putils.execute, use_multipath=False, |
|
44 device_scan_attempts=DEVICE_SCAN_ATTEMPTS_DEFAULT, |
|
45 transport='default', *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__( |
|
52 root_helper, driver=driver, |
|
53 execute=execute, |
|
54 @@ -678,6 +689,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 _validate_iface_transport(self, transport_iface): |
|
63 @@ -840,6 +853,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 host_devices, target_props = self._get_potential_volume_paths( |
|
73 @@ -912,6 +928,9 @@ 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 + |
|
80 if self.use_multipath: |
|
81 self._rescan_multipath() |
|
82 host_device = multipath_device = None |
|
83 @@ -1002,6 +1021,9 @@ class ISCSIConnector(InitiatorConnector) |
|
84 |
|
85 def get_initiator(self): |
|
86 """Secure helper to read file as root.""" |
|
87 + if sys.platform == 'sunos5': |
|
88 + return self._solarisiscsi.get_initiator() |
|
89 + |
|
90 file_path = '/etc/iscsi/initiatorname.iscsi' |
|
91 try: |
|
92 lines, _err = self._execute('cat', file_path, run_as_root=True, |
|
93 @@ -1304,8 +1326,11 @@ class FibreChannelConnector(InitiatorCon |
|
94 execute=putils.execute, use_multipath=False, |
|
95 device_scan_attempts=DEVICE_SCAN_ATTEMPTS_DEFAULT, |
|
96 *args, **kwargs): |
|
97 - self._linuxscsi = linuxscsi.LinuxSCSI(root_helper, execute) |
|
98 - self._linuxfc = linuxfc.LinuxFibreChannel(root_helper, execute) |
|
99 + if sys.platform == 'sunos5': |
|
100 + self._solarisfc = solarisfc.SolarisFibreChannel() |
|
101 + else: |
|
102 + self._linuxscsi = linuxscsi.LinuxSCSI(root_helper, execute) |
|
103 + self._linuxfc = linuxfc.LinuxFibreChannel(root_helper, execute) |
|
104 super(FibreChannelConnector, self).__init__( |
|
105 root_helper, driver=driver, |
|
106 execute=execute, |
|
107 @@ -1315,6 +1340,8 @@ class FibreChannelConnector(InitiatorCon |
|
108 |
|
109 def set_execute(self, execute): |
|
110 super(FibreChannelConnector, self).set_execute(execute) |
|
111 + if sys.platform == 'sunos5': |
|
112 + return |
|
113 self._linuxscsi.set_execute(execute) |
|
114 self._linuxfc.set_execute(execute) |
|
115 |
|
116 @@ -1373,6 +1400,10 @@ class FibreChannelConnector(InitiatorCon |
|
117 target_wwn - World Wide Name |
|
118 target_lun - LUN id of the volume |
|
119 """ |
|
120 + if sys.platform == 'sunos5': |
|
121 + return self._solarisfc.connect_volume(connection_properties, |
|
122 + self.device_scan_attempts) |
|
123 + |
|
124 LOG.debug("execute = %s", self._execute) |
|
125 device_info = {'type': 'block'} |
|
126 |
|
127 @@ -1505,6 +1536,12 @@ class FibreChannelConnector(InitiatorCon |
|
128 target_wwn - World Wide Name |
|
129 target_lun - LUN id of the volume |
|
130 """ |
|
131 + if sys.platform == 'sunos5': |
|
132 + # There is some latency before the next time connection happens. |
|
133 + # The best practice is to offline the state of the switch now |
|
134 + # and online it at the next connection. |
|
135 + # But now, we just return without any operation. |
|
136 + return |
|
137 |
|
138 devices = [] |
|
139 volume_paths = self.get_volume_paths(connection_properties) |