author | Laszlo Peter <laszlo.peter@oracle.com> |
Wed, 07 Sep 2016 14:48:24 -0700 | |
changeset 6761 | f2bb9c5b1768 |
parent 6070 | components/openstack/cinder/files/solaris/solarisfc.py@87daa7413b2d |
permissions | -rw-r--r-- |
3998
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
1 |
# vim: tabstop=4 shiftwidth=4 softtabstop=4 |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
2 |
|
6070
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
3 |
# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
3998
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
4 |
# |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
6 |
# not use this file except in compliance with the License. You may obtain |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
7 |
# a copy of the License at |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
8 |
# |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
10 |
# |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
13 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
14 |
# License for the specific language governing permissions and limitations |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
15 |
# under the License. |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
16 |
|
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
17 |
"""Generic Solaris Fibre Channel utilities.""" |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
18 |
|
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
19 |
import os |
4793
24053a14d972
21365620 cinder volume backups sometimes fail on SPARC
Strony <strony.zhang@oracle.com>
parents:
3998
diff
changeset
|
20 |
import platform |
3998
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
21 |
import time |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
22 |
|
5405
66fd59fecd68
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4793
diff
changeset
|
23 |
from oslo_concurrency import processutils as putils |
66fd59fecd68
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4793
diff
changeset
|
24 |
from oslo_log import log as logging |
66fd59fecd68
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
4793
diff
changeset
|
25 |
|
6761
f2bb9c5b1768
PSARC 2016/361 os-brick - managing local volume attaches in OpenStack Cinder
Laszlo Peter <laszlo.peter@oracle.com>
parents:
6070
diff
changeset
|
26 |
from os_brick import exception |
f2bb9c5b1768
PSARC 2016/361 os-brick - managing local volume attaches in OpenStack Cinder
Laszlo Peter <laszlo.peter@oracle.com>
parents:
6070
diff
changeset
|
27 |
import oslo_i18n |
3998
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
28 |
|
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
29 |
LOG = logging.getLogger(__name__) |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
30 |
|
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
31 |
|
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
32 |
class SolarisFibreChannel(object): |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
33 |
def __init__(self, *args, **kwargs): |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
34 |
self.execute = putils.execute |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
35 |
|
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
36 |
def _get_fc_hbas(self): |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
37 |
"""Get Fibre Channel HBA information.""" |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
38 |
out = None |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
39 |
try: |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
40 |
out, err = self.execute('/usr/sbin/fcinfo', 'hba-port') |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
41 |
except putils.ProcessExecutionError as err: |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
42 |
return None |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
43 |
|
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
44 |
if out is None: |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
45 |
LOG.info(_("Cannot find any Fibre Channel HBAs")) |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
46 |
return None |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
47 |
|
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
48 |
hbas = [] |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
49 |
hba = {} |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
50 |
for line in out.splitlines(): |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
51 |
line = line.strip() |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
52 |
# Collect the following hba-port data: |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
53 |
# 1: Port WWN |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
54 |
# 2: State (online|offline) |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
55 |
# 3: Node WWN |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
56 |
if line.startswith("HBA Port WWN:"): |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
57 |
# New HBA port entry |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
58 |
hba = {} |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
59 |
wwpn = line.split()[-1] |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
60 |
hba['port_name'] = wwpn |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
61 |
continue |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
62 |
elif line.startswith("Port Mode:"): |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
63 |
mode = line.split()[-1] |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
64 |
# Skip Target mode ports |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
65 |
if mode != 'Initiator': |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
66 |
break |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
67 |
elif line.startswith("State:"): |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
68 |
state = line.split()[-1] |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
69 |
hba['port_state'] = state |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
70 |
continue |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
71 |
elif line.startswith("Node WWN:"): |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
72 |
wwnn = line.split()[-1] |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
73 |
hba['node_name'] = wwnn |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
74 |
continue |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
75 |
if len(hba) == 3: |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
76 |
hbas.append(hba) |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
77 |
hba = {} |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
78 |
return hbas |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
79 |
|
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
80 |
def get_fc_wwnns(self): |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
81 |
"""Get Fibre Channel WWNNs from the system, if any.""" |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
82 |
hbas = self._get_fc_hbas() |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
83 |
if hbas is None: |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
84 |
return None |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
85 |
|
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
86 |
wwnns = [] |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
87 |
for hba in hbas: |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
88 |
if hba['port_state'] == 'online': |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
89 |
wwnn = hba['node_name'] |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
90 |
wwnns.append(wwnn) |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
91 |
return wwnns |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
92 |
|
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
93 |
def get_fc_wwpns(self): |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
94 |
"""Get Fibre Channel WWPNs from the system, if any.""" |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
95 |
hbas = self._get_fc_hbas() |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
96 |
if hbas is None: |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
97 |
return None |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
98 |
|
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
99 |
wwpns = [] |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
100 |
for hba in hbas: |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
101 |
if hba['port_state'] == 'online': |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
102 |
wwpn = hba['port_name'] |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
103 |
wwpns.append(wwpn) |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
104 |
return wwpns |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
105 |
|
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
106 |
def _refresh_connection(self): |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
107 |
"""Force the link reinitialization to make the LUN present.""" |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
108 |
wwpns = self.get_fc_wwpns() |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
109 |
for wwpn in wwpns: |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
110 |
self.execute('/usr/sbin/fcadm', 'force-lip', wwpn) |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
111 |
|
6070
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
112 |
def _get_device_path(self, wwn, target_lun): |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
113 |
"""Get the Device path for the specified LUN. |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
114 |
|
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
115 |
The output of CMD below is like this: |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
116 |
|
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
117 |
OS Device Name: /dev/rdsk/c0t600C0FF0000000000036223AE73EB705d0s2 |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
118 |
HBA Port WWN: 210100e08b27a8a1 |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
119 |
Remote Port WWN: 256000c0ffc03622 |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
120 |
LUN: 0 |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
121 |
Remote Port WWN: 216000c0ff803622 |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
122 |
LUN: 0 |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
123 |
HBA Port WWN: 210000e08b07a8a1 |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
124 |
Remote Port WWN: 256000c0ffc03622 |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
125 |
LUN: 0 |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
126 |
Remote Port WWN: 216000c0ff803622 |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
127 |
LUN: 0 |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
128 |
Vendor: SUN |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
129 |
Product: StorEdge 3510 |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
130 |
Device Type: Disk device |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
131 |
...... |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
132 |
""" |
3998
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
133 |
try: |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
134 |
out, err = self.execute('/usr/sbin/fcinfo', 'logical-unit', '-v') |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
135 |
except putils.ProcessExecutionError as err: |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
136 |
return None |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
137 |
|
6070
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
138 |
host_device = None |
3998
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
139 |
remote_port = None |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
140 |
if out is not None: |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
141 |
for line in [l.strip() for l in out.splitlines()]: |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
142 |
if line.startswith("OS Device Name:"): |
6070
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
143 |
host_device = line.split()[-1] |
3998
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
144 |
if line.startswith("Remote Port WWN:"): |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
145 |
remote_port = line.split()[-1] |
6070
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
146 |
if line.startswith("LUN:"): |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
147 |
lun = line.split()[-1] |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
148 |
if remote_port.upper() == wwn and \ |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
149 |
int(lun) == int(target_lun): |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
150 |
return host_device |
3998
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
151 |
|
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
152 |
return None |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
153 |
|
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
154 |
def connect_volume(self, connection_properties, scan_tries): |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
155 |
"""Attach the volume to instance_name. |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
156 |
|
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
157 |
connection_properties for Fibre Channel must include: |
6070
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
158 |
target_wwn - Specified port WWNs |
3998
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
159 |
target_lun - LUN id of the volume |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
160 |
""" |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
161 |
device_info = {'type': 'block'} |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
162 |
target_wwn = connection_properties['target_wwn'] |
6070
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
163 |
target_lun = connection_properties['target_lun'] |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
164 |
wwns = [] |
3998
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
165 |
if isinstance(target_wwn, list): |
6070
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
166 |
wwns = target_wwn |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
167 |
else: |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
168 |
wwns.append(target_wwn) |
3998
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
169 |
|
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
170 |
# The scsi_vhci disk node is not always present immediately. |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
171 |
# Sometimes we need to reinitialize the connection to trigger |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
172 |
# a refresh. |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
173 |
for i in range(1, scan_tries): |
6070
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
174 |
# initiator needs time to refresh the LU list |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
175 |
time.sleep(i * 2) |
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
176 |
host_device = self._get_device_path(wwns[0], target_lun) |
3998
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
177 |
|
6070
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
178 |
if host_device is not None and os.path.exists(host_device): |
3998
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
179 |
break |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
180 |
else: |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
181 |
self._refresh_connection() |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
182 |
else: |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
183 |
msg = _("Fibre Channel volume device not found.") |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
184 |
LOG.error(msg) |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
185 |
raise exception.NoFibreChannelVolumeDeviceFound() |
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
186 |
|
4793
24053a14d972
21365620 cinder volume backups sometimes fail on SPARC
Strony <strony.zhang@oracle.com>
parents:
3998
diff
changeset
|
187 |
# Set the label EFI to the disk on SPARC before it is accessed and |
24053a14d972
21365620 cinder volume backups sometimes fail on SPARC
Strony <strony.zhang@oracle.com>
parents:
3998
diff
changeset
|
188 |
# make sure the correct device path with slice 0 |
24053a14d972
21365620 cinder volume backups sometimes fail on SPARC
Strony <strony.zhang@oracle.com>
parents:
3998
diff
changeset
|
189 |
# (like '/dev/rdsk/c0t600xxxd0s0'). |
24053a14d972
21365620 cinder volume backups sometimes fail on SPARC
Strony <strony.zhang@oracle.com>
parents:
3998
diff
changeset
|
190 |
if platform.processor() == 'sparc': |
24053a14d972
21365620 cinder volume backups sometimes fail on SPARC
Strony <strony.zhang@oracle.com>
parents:
3998
diff
changeset
|
191 |
tmp_dev_name = host_device.rsplit('s', 1) |
24053a14d972
21365620 cinder volume backups sometimes fail on SPARC
Strony <strony.zhang@oracle.com>
parents:
3998
diff
changeset
|
192 |
disk_name = tmp_dev_name[0].split('/')[-1] |
24053a14d972
21365620 cinder volume backups sometimes fail on SPARC
Strony <strony.zhang@oracle.com>
parents:
3998
diff
changeset
|
193 |
(out, _err) = self.execute('/usr/sbin/format', '-L', 'efi', '-d', |
24053a14d972
21365620 cinder volume backups sometimes fail on SPARC
Strony <strony.zhang@oracle.com>
parents:
3998
diff
changeset
|
194 |
disk_name) |
24053a14d972
21365620 cinder volume backups sometimes fail on SPARC
Strony <strony.zhang@oracle.com>
parents:
3998
diff
changeset
|
195 |
host_device = '%ss0' % tmp_dev_name[0] |
24053a14d972
21365620 cinder volume backups sometimes fail on SPARC
Strony <strony.zhang@oracle.com>
parents:
3998
diff
changeset
|
196 |
|
6070
87daa7413b2d
23294485 Cinder ZFSFCDriver fails to find the right target wwn
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
5405
diff
changeset
|
197 |
device_info['path'] = host_device |
3998
5bd484384122
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
diff
changeset
|
198 |
return device_info |