author | saurabh.vyas@oracle.com |
Wed, 25 May 2016 14:31:44 -0700 | |
branch | s11u3-sru |
changeset 7787 | 26bcbec7afce |
parent 6035 | c9748fcc32de |
permissions | -rw-r--r-- |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
1 |
# vim: tabstop=4 shiftwidth=4 softtabstop=4 |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
2 |
# Copyright (c) 2012 OpenStack LLC. |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
3 |
# All Rights Reserved. |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
4 |
# |
7787
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
5 |
# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
6 |
# |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
7 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
8 |
# not use this file except in compliance with the License. You may obtain |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
9 |
# a copy of the License at |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
10 |
# |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
11 |
# http://www.apache.org/licenses/LICENSE-2.0 |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
12 |
# |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
13 |
# Unless required by applicable law or agreed to in writing, software |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
14 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
15 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
16 |
# License for the specific language governing permissions and limitations |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
17 |
# under the License. |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
18 |
""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
19 |
Drivers for Solaris ZFS operations in local and iSCSI modes |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
20 |
""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
21 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
22 |
import abc |
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
23 |
import fcntl |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
24 |
import os |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
25 |
import subprocess |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
26 |
import time |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
27 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
28 |
from oslo_concurrency import processutils |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
29 |
from oslo_config import cfg |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
30 |
from oslo_log import log as logging |
5431
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
31 |
import paramiko |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
32 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
33 |
from cinder import exception |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
34 |
from cinder.i18n import _, _LE, _LI |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
35 |
from cinder.image import image_utils |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
36 |
from cinder.volume import driver |
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
37 |
from cinder.volume.drivers.san.san import SanDriver |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
38 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
39 |
from eventlet.green import socket |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
40 |
from eventlet.green.OpenSSL import SSL |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
41 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
42 |
import rad.client as radc |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
43 |
import rad.connect as radcon |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
44 |
import rad.bindings.com.oracle.solaris.rad.zfsmgr_1 as zfsmgr |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
45 |
import rad.auth as rada |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
46 |
|
3147
891ab4caf1bc
18658040 zfs.py can't handle terabyte pools
Strony <strony.zhang@oracle.com>
parents:
3028
diff
changeset
|
47 |
from solaris_install.target.size import Size |
891ab4caf1bc
18658040 zfs.py can't handle terabyte pools
Strony <strony.zhang@oracle.com>
parents:
3028
diff
changeset
|
48 |
|
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
49 |
FLAGS = cfg.CONF |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
50 |
LOG = logging.getLogger(__name__) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
51 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
52 |
solaris_zfs_opts = [ |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
53 |
cfg.StrOpt('zfs_volume_base', |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
54 |
default='rpool/cinder', |
5317
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
55 |
help='The base dataset for ZFS volumes.'), |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
56 |
cfg.StrOpt('zfs_target_group', |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
57 |
default='tgt-grp', |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
58 |
help='iSCSI target group name.'), ] |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
59 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
60 |
FLAGS.register_opts(solaris_zfs_opts) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
61 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
62 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
63 |
def connect_tls(host, port=12302, locale=None, ca_certs=None): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
64 |
"""Connect to a RAD instance over TLS. |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
65 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
66 |
Arguments: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
67 |
host string, target host |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
68 |
port int, target port (RAD_PORT_TLS = 12302) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
69 |
locale string, locale |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
70 |
ca_certs string, path to file containing CA certificates |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
71 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
72 |
Returns: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
73 |
RadConnection: a connection to RAD |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
74 |
""" |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
75 |
# We don't want SSL 2.0, SSL 3.0 nor TLS 1.0 in RAD |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
76 |
context = SSL.Context(SSL.SSLv23_METHOD) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
77 |
context.set_options(SSL.OP_NO_SSLv2) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
78 |
context.set_options(SSL.OP_NO_SSLv3) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
79 |
context.set_options(SSL.OP_NO_TLSv1) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
80 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
81 |
if ca_certs is not None: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
82 |
context.set_verify(SSL.VERIFY_PEER, _tls_verify_cb) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
83 |
context.load_verify_locations(ca_certs) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
84 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
85 |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
86 |
sock = SSL.Connection(context, sock) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
87 |
sock.connect((host, port)) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
88 |
sock.do_handshake() |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
89 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
90 |
return radcon.RadConnection(sock, locale=locale) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
91 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
92 |
|
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
93 |
class ZFSVolumeDriver(SanDriver): |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
94 |
"""OpenStack Cinder ZFS volume driver for generic ZFS volumes. |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
95 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
96 |
Version history: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
97 |
1.0.0 - Initial driver with basic functionalities in Havana |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
98 |
1.1.0 - Support SAN for the remote storage nodes access in Juno |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
99 |
1.1.1 - Add support for the volume backup |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
100 |
1.1.2 - Add support for the volume migration |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
101 |
1.2.0 - Add support for the volume management in Kilo |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
102 |
1.2.1 - Enable the connect_tls by importing eventlet.green.socket |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
103 |
1.2.2 - Introduce the ZFS RAD for volume migration enhancement |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
104 |
1.2.3 - Replace volume-specific targets with one shared target in |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
105 |
the ZFSISCSIDriver |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
106 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
107 |
""" |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
108 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
109 |
version = "1.2.3" |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
110 |
protocol = 'local' |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
111 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
112 |
def __init__(self, *args, **kwargs): |
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
113 |
super(ZFSVolumeDriver, self).__init__(execute=self.solaris_execute, |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
114 |
*args, **kwargs) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
115 |
self.configuration.append_config_values(solaris_zfs_opts) |
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
116 |
self.run_local = self.configuration.san_is_local |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
117 |
self.hostname = socket.gethostname() |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
118 |
|
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
119 |
def solaris_execute(self, *cmd, **kwargs): |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
120 |
"""Execute the command locally or remotely.""" |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
121 |
if self.run_local: |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
122 |
return processutils.execute(*cmd, **kwargs) |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
123 |
else: |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
124 |
return super(ZFSVolumeDriver, self)._run_ssh(cmd, |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
125 |
check_exit_code=True) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
126 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
127 |
def check_for_setup_error(self): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
128 |
"""Check the setup error.""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
129 |
pass |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
130 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
131 |
def create_volume(self, volume): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
132 |
"""Create a volume.""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
133 |
size = '%sG' % volume['size'] |
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
134 |
zfs_volume = self._get_zfs_volume_name(volume['name']) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
135 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
136 |
# Create a ZFS volume |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
137 |
cmd = ['/usr/sbin/zfs', 'create', '-V', size, zfs_volume] |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
138 |
self._execute(*cmd) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
139 |
LOG.debug(_("Created ZFS volume '%s'") % volume['name']) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
140 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
141 |
def create_volume_from_snapshot(self, volume, snapshot): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
142 |
"""Create a cloned volume from a snapshot.""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
143 |
if volume['size'] != snapshot['volume_size']: |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
144 |
exception_message = (_("Could not create volume '%s' because " |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
145 |
"its volume size of '%s' is different " |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
146 |
"from that of the snapshot, '%s'.") |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
147 |
% (volume['name'], volume['size'], |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
148 |
snapshot['volume_size'])) |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
149 |
raise exception.InvalidInput(reason=exception_message) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
150 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
151 |
# Create a ZFS clone |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
152 |
zfs_snapshot = self._get_zfs_snap_name(snapshot) |
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
153 |
zfs_volume = self._get_zfs_volume_name(volume['name']) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
154 |
cmd = ['/usr/sbin/zfs', 'clone', zfs_snapshot, zfs_volume] |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
155 |
self._execute(*cmd) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
156 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
157 |
LOG.debug(_("Created cloned volume '%s'") % volume['name']) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
158 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
159 |
def create_cloned_volume(self, volume, src_vref): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
160 |
"""Create a clone of the specified volume.""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
161 |
if volume['size'] != src_vref['size']: |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
162 |
exception_message = (_("Could not clone volume '%s' because " |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
163 |
"its volume size of '%s' is different " |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
164 |
"from that of the source volume, '%s'.") |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
165 |
% (volume['name'], volume['size'], |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
166 |
src_vref['size'])) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
167 |
raise exception.VolumeBackendAPIException(data=exception_message) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
168 |
|
5431
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
169 |
self._zfs_send_recv(src_vref, |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
170 |
self._get_zfs_volume_name(volume['name'])) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
171 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
172 |
LOG.debug(_("Created cloned volume '%s' from source volume '%s'") |
5431
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
173 |
% (volume['name'], src_vref['name'])) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
174 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
175 |
def delete_volume(self, volume): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
176 |
"""Delete a volume. |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
177 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
178 |
Firstly, the volume should be checked if it is a cloned one. If yes, |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
179 |
its parent snapshot with prefix 'tmp-snapshot-' should be deleted as |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
180 |
well after it is removed. |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
181 |
""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
182 |
zvol = self._get_zvol_path(volume) |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
183 |
try: |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
184 |
(out, _err) = self._execute('/usr/bin/ls', zvol) |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
185 |
except processutils.ProcessExecutionError: |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
186 |
LOG.debug(_("The volume path '%s' doesn't exist") % zvol) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
187 |
return |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
188 |
|
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
189 |
zfs_volume = self._get_zfs_volume_name(volume['name']) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
190 |
origin_snapshot = self._get_zfs_property('origin', zfs_volume) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
191 |
tmp_cloned_vol = False |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
192 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
193 |
# Check if it is the temporary snapshot created for the cloned volume |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
194 |
if origin_snapshot.startswith(self.configuration.zfs_volume_base): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
195 |
prop_type = self._get_zfs_property('type', origin_snapshot) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
196 |
tmp_snap_prefix = 'tmp-snapshot-%s' % volume['id'] |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
197 |
if prop_type == 'snapshot' and tmp_snap_prefix in origin_snapshot: |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
198 |
tmp_cloned_vol = True |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
199 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
200 |
cmd = ['/usr/sbin/zfs', 'destroy', zfs_volume] |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
201 |
self._execute(*cmd) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
202 |
LOG.debug(_("Deleted volume '%s'") % volume['name']) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
203 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
204 |
if tmp_cloned_vol: |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
205 |
self._execute('/usr/sbin/zfs', 'destroy', origin_snapshot) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
206 |
LOG.debug(_("Deleted parent snapshot '%s' of volume '%s'") |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
207 |
% (origin_snapshot, volume['name'])) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
208 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
209 |
def create_snapshot(self, snapshot): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
210 |
"""Create a snapshot.""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
211 |
cmd = ['/usr/sbin/zfs', 'snapshot', self._get_zfs_snap_name(snapshot)] |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
212 |
self._execute(*cmd) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
213 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
214 |
LOG.debug(_("Created snapshot '%s'") % snapshot['name']) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
215 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
216 |
def delete_snapshot(self, snapshot): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
217 |
"""Delete a snapshot.""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
218 |
cmd = ['/usr/sbin/zfs', 'destroy', self._get_zfs_snap_name(snapshot)] |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
219 |
self._execute(*cmd) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
220 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
221 |
LOG.debug(_("Deleted snapshot '%s'") % snapshot['name']) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
222 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
223 |
def ensure_export(self, context, volume): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
224 |
"""Synchronously recreate an export for a logical volume.""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
225 |
pass |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
226 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
227 |
def create_export(self, context, volume): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
228 |
"""Export the volume.""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
229 |
pass |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
230 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
231 |
def remove_export(self, context, volume): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
232 |
"""Remove an export for a volume.""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
233 |
pass |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
234 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
235 |
def initialize_connection(self, volume, connector): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
236 |
"""Initialize the connection and returns connection info.""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
237 |
volume_path = '%s/volume-%s' % (self.configuration.zfs_volume_base, |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
238 |
volume['id']) |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
239 |
properties = {} |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
240 |
properties['device_path'] = self._get_zvol_path(volume) |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
241 |
|
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
242 |
return { |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
243 |
'driver_volume_type': 'local', |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
244 |
'volume_path': volume_path, |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
245 |
'data': properties |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
246 |
} |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
247 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
248 |
def terminate_connection(self, volume, connector, **kwargs): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
249 |
"""Disconnection from the connector.""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
250 |
pass |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
251 |
|
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
252 |
def attach_volume(self, context, volume, instance_uuid, host_name, |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
253 |
mountpoint): |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
254 |
"""Callback for volume attached to instance or host.""" |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
255 |
pass |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
256 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
257 |
def detach_volume(self, context, volume, attachment): |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
258 |
""" Callback for volume detached.""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
259 |
pass |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
260 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
261 |
def get_volume_stats(self, refresh=False): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
262 |
"""Get volume status.""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
263 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
264 |
if refresh: |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
265 |
self._update_volume_stats() |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
266 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
267 |
return self._stats |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
268 |
|
3147
891ab4caf1bc
18658040 zfs.py can't handle terabyte pools
Strony <strony.zhang@oracle.com>
parents:
3028
diff
changeset
|
269 |
def _get_zfs_property(self, prop, dataset): |
891ab4caf1bc
18658040 zfs.py can't handle terabyte pools
Strony <strony.zhang@oracle.com>
parents:
3028
diff
changeset
|
270 |
"""Get the value of property for the dataset.""" |
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
271 |
try: |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
272 |
(out, _err) = self._execute('/usr/sbin/zfs', 'get', '-H', '-o', |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
273 |
'value', prop, dataset) |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
274 |
return out.rstrip() |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
275 |
except processutils.ProcessExecutionError: |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
276 |
LOG.info(_LI("Failed to get the property '%s' of the dataset '%s'") |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
277 |
% (prop, dataset)) |
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
278 |
return None |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
279 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
280 |
def _get_zfs_snap_name(self, snapshot): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
281 |
"""Get the snapshot path.""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
282 |
return "%s/%s@%s" % (self.configuration.zfs_volume_base, |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
283 |
snapshot['volume_name'], snapshot['name']) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
284 |
|
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
285 |
def _get_zfs_volume_name(self, volume_name): |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
286 |
"""Add the pool name to get the ZFS volume.""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
287 |
return "%s/%s" % (self.configuration.zfs_volume_base, |
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
288 |
volume_name) |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
289 |
|
5431
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
290 |
def _remote_piped_execute(self, cmd1, cmd2, ip, username, password): |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
291 |
"""Piped execute on a remote host.""" |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
292 |
LOG.debug(_("Piping cmd1='%s' into cmd='%s' on host '%s'") % |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
293 |
(' '.join(cmd1), ' '.join(cmd2), ip)) |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
294 |
|
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
295 |
client = paramiko.SSHClient() |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
296 |
client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
297 |
client.connect(ip, username=username, password=password) |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
298 |
|
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
299 |
cmd = ' '.join(cmd1) + '|' + ' '.join(cmd2) |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
300 |
stdin, stdout, stderr = client.exec_command(cmd) |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
301 |
channel = stdout.channel |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
302 |
exit_status = channel.recv_exit_status() |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
303 |
|
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
304 |
if exit_status != 0: |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
305 |
LOG.error(_("_remote_piped_execute: failed to host '%s' with " |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
306 |
"stdout '%s' and stderr '%s'") |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
307 |
% (ip, stdout.read(), stderr.read())) |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
308 |
msg = (_("Remote piped execution failed to host '%s'.") % ip) |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
309 |
raise exception.VolumeBackendAPIException(data=msg) |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
310 |
|
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
311 |
def _piped_execute(self, cmd1, cmd2): |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
312 |
"""Pipe output of cmd1 into cmd2.""" |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
313 |
LOG.debug(_("Piping cmd1='%s' into cmd2='%s'") % |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
314 |
(' '.join(cmd1), ' '.join(cmd2))) |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
315 |
|
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
316 |
try: |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
317 |
p1 = subprocess.Popen(cmd1, stdout=subprocess.PIPE, |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
318 |
stderr=subprocess.PIPE) |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
319 |
except: |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
320 |
LOG.error(_LE("_piped_execute '%s' failed.") % (cmd1)) |
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
321 |
raise |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
322 |
|
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
323 |
# Set the pipe to be blocking because evenlet.green.subprocess uses |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
324 |
# the non-blocking pipe. |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
325 |
flags = fcntl.fcntl(p1.stdout, fcntl.F_GETFL) & (~os.O_NONBLOCK) |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
326 |
fcntl.fcntl(p1.stdout, fcntl.F_SETFL, flags) |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
327 |
|
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
328 |
p2 = subprocess.Popen(cmd2, stdin=p1.stdout, |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
329 |
stdout=subprocess.PIPE, |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
330 |
stderr=subprocess.PIPE) |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
331 |
p1.stdout.close() |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
332 |
stdout, stderr = p2.communicate() |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
333 |
if p2.returncode: |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
334 |
msg = (_("_piped_execute failed with the info '%s' and '%s'.") % |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
335 |
(stdout, stderr)) |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
336 |
raise exception.VolumeBackendAPIException(data=msg) |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
337 |
|
5431
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
338 |
def _zfs_send_recv(self, src, dst): |
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
339 |
"""Replicate the ZFS dataset by calling zfs send/recv cmd""" |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
340 |
src_snapshot = {'volume_name': src['name'], |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
341 |
'name': 'tmp-snapshot-%s' % src['id']} |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
342 |
src_snapshot_name = self._get_zfs_snap_name(src_snapshot) |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
343 |
prop_type = self._get_zfs_property('type', src_snapshot_name) |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
344 |
# Delete the temporary snapshot if it already exists |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
345 |
if prop_type == 'snapshot': |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
346 |
self.delete_snapshot(src_snapshot) |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
347 |
# Create a temporary snapshot of volume |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
348 |
self.create_snapshot(src_snapshot) |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
349 |
src_snapshot_name = self._get_zfs_snap_name(src_snapshot) |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
350 |
|
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
351 |
cmd1 = ['/usr/sbin/zfs', 'send', src_snapshot_name] |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
352 |
cmd2 = ['/usr/sbin/zfs', 'receive', dst] |
5431
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
353 |
# Due to pipe injection protection in the ssh utils method, |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
354 |
# cinder.utils.check_ssh_injection(), the piped commands must be passed |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
355 |
# through via paramiko. These commands take no user defined input |
5431
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
356 |
# other than the names of the zfs datasets which are already protected |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
357 |
# against the special characters of concern. |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
358 |
if not self.run_local: |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
359 |
ip = self.configuration.san_ip |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
360 |
username = self.configuration.san_login |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
361 |
password = self.configuration.san_password |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
362 |
self._remote_piped_execute(cmd1, cmd2, ip, username, password) |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
363 |
else: |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
364 |
self._piped_execute(cmd1, cmd2) |
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
365 |
|
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
366 |
# Delete the temporary src snapshot and dst snapshot |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
367 |
self.delete_snapshot(src_snapshot) |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
368 |
dst_snapshot_name = "%s@tmp-snapshot-%s" % (dst, src['id']) |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
369 |
cmd = ['/usr/sbin/zfs', 'destroy', dst_snapshot_name] |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
370 |
self._execute(*cmd) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
371 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
372 |
def _get_rc_connect(self, san_info=None): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
373 |
"""Connect the RAD server.""" |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
374 |
if san_info is not None: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
375 |
san_ip = san_info.split(';')[0] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
376 |
san_login = san_info.split(';')[1] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
377 |
san_password = san_info.split(';')[2] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
378 |
else: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
379 |
san_ip = self.configuration.san_ip |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
380 |
san_login = self.configuration.san_login |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
381 |
san_password = self.configuration.san_password |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
382 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
383 |
rc = connect_tls(san_ip) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
384 |
auth = rada.RadAuth(rc) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
385 |
auth.pam_login(san_login, san_password) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
386 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
387 |
return rc |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
388 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
389 |
def _rad_zfs_send_recv(self, src, dst, dst_san_info=None): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
390 |
"""Replicate the ZFS dataset stream.""" |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
391 |
src_snapshot = {'volume_name': src['name'], |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
392 |
'name': 'tmp-send-snapshot-%s' % src['id']} |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
393 |
src_snapshot_name = self._get_zfs_snap_name(src_snapshot) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
394 |
prop_type = self._get_zfs_property('type', src_snapshot_name) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
395 |
# Delete the temporary snapshot if it already exists |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
396 |
if prop_type == 'snapshot': |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
397 |
self.delete_snapshot(src_snapshot) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
398 |
# Create the temporary snapshot of src volume |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
399 |
self.create_snapshot(src_snapshot) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
400 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
401 |
src_rc = self._get_rc_connect() |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
402 |
dst_rc = self._get_rc_connect(dst_san_info) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
403 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
404 |
src_pat = self._get_zfs_volume_name(src['name']) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
405 |
src_vol_obj = src_rc.get_object(zfsmgr.ZfsDataset(), |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
406 |
radc.ADRGlobPattern({"name": src_pat})) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
407 |
dst_pat = dst.rsplit('/', 1)[0] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
408 |
dst_vol_obj = dst_rc.get_object(zfsmgr.ZfsDataset(), |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
409 |
radc.ADRGlobPattern({"name": dst_pat})) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
410 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
411 |
send_sock_info = src_vol_obj.get_send_socket( |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
412 |
name=src_snapshot_name, socket_type=zfsmgr.SocketType.AF_INET) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
413 |
send_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
414 |
send_sock.connect((self.hostname, int(send_sock_info.socket))) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
415 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
416 |
dst_san_ip = dst_san_info.split(';')[0] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
417 |
remote_host, alias, addresslist = socket.gethostbyaddr(dst_san_ip) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
418 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
419 |
recv_sock_info = dst_vol_obj.get_receive_socket( |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
420 |
name=dst, socket_type=zfsmgr.SocketType.AF_INET, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
421 |
name_options=zfsmgr.ZfsRecvNameOptions.use_provided_name) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
422 |
recv_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
423 |
recv_sock.connect((remote_host, int(recv_sock_info.socket))) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
424 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
425 |
# Set 4mb buffer size |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
426 |
buf_size = 4194304 |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
427 |
while True: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
428 |
# Read the data from the send stream |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
429 |
buf = send_sock.recv(buf_size) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
430 |
if not buf: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
431 |
break |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
432 |
# Write the data to the receive steam |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
433 |
recv_sock.send(buf) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
434 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
435 |
recv_sock.close() |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
436 |
send_sock.close() |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
437 |
time.sleep(1) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
438 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
439 |
# Delete the temporary dst snapshot |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
440 |
pat = radc.ADRGlobPattern({"name": dst}) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
441 |
dst_zvol_obj = dst_rc.get_object(zfsmgr.ZfsDataset(), pat) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
442 |
snapshot_list = dst_zvol_obj.get_snapshots() |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
443 |
for snap in snapshot_list: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
444 |
if 'tmp-send-snapshot'in snap: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
445 |
dst_zvol_obj.destroy_snapshot(snap) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
446 |
break |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
447 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
448 |
# Delete the temporary src snapshot |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
449 |
self.delete_snapshot(src_snapshot) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
450 |
LOG.debug(("Transfered src stream'%s' to dst'%s' on the host'%s'") % |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
451 |
(src_snapshot_name, dst, self.hostname)) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
452 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
453 |
src_rc.close() |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
454 |
dst_rc.close() |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
455 |
|
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
456 |
def _get_zvol_path(self, volume): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
457 |
"""Get the ZFS volume path.""" |
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
458 |
return "/dev/zvol/rdsk/%s" % self._get_zfs_volume_name(volume['name']) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
459 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
460 |
def _update_volume_stats(self): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
461 |
"""Retrieve volume status info.""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
462 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
463 |
LOG.debug(_("Updating volume status")) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
464 |
stats = {} |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
465 |
backend_name = self.configuration.safe_get('volume_backend_name') |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
466 |
stats["volume_backend_name"] = backend_name or self.__class__.__name__ |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
467 |
stats["storage_protocol"] = self.protocol |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
468 |
stats["driver_version"] = self.version |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
469 |
stats["vendor_name"] = 'Oracle' |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
470 |
stats['QoS_support'] = False |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
471 |
|
3147
891ab4caf1bc
18658040 zfs.py can't handle terabyte pools
Strony <strony.zhang@oracle.com>
parents:
3028
diff
changeset
|
472 |
dataset = self.configuration.zfs_volume_base |
891ab4caf1bc
18658040 zfs.py can't handle terabyte pools
Strony <strony.zhang@oracle.com>
parents:
3028
diff
changeset
|
473 |
used_size = self._get_zfs_property('used', dataset) |
891ab4caf1bc
18658040 zfs.py can't handle terabyte pools
Strony <strony.zhang@oracle.com>
parents:
3028
diff
changeset
|
474 |
avail_size = self._get_zfs_property('avail', dataset) |
891ab4caf1bc
18658040 zfs.py can't handle terabyte pools
Strony <strony.zhang@oracle.com>
parents:
3028
diff
changeset
|
475 |
stats['total_capacity_gb'] = \ |
891ab4caf1bc
18658040 zfs.py can't handle terabyte pools
Strony <strony.zhang@oracle.com>
parents:
3028
diff
changeset
|
476 |
(Size(used_size) + Size(avail_size)).get(Size.gb_units) |
891ab4caf1bc
18658040 zfs.py can't handle terabyte pools
Strony <strony.zhang@oracle.com>
parents:
3028
diff
changeset
|
477 |
stats['free_capacity_gb'] = Size(avail_size).get(Size.gb_units) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
478 |
stats['reserved_percentage'] = self.configuration.reserved_percentage |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
479 |
|
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
480 |
stats['location_info'] =\ |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
481 |
('ZFSVolumeDriver:%(hostname)s:%(zfs_volume_base)s:local' % |
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
482 |
{'hostname': self.hostname, |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
483 |
'zfs_volume_base': self.configuration.zfs_volume_base}) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
484 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
485 |
self._stats = stats |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
486 |
|
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
487 |
def extend_volume(self, volume, new_size): |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
488 |
"""Extend an existing volume's size.""" |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
489 |
volsize_str = 'volsize=%sg' % new_size |
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
490 |
zfs_volume = self._get_zfs_volume_name(volume['name']) |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
491 |
try: |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
492 |
self._execute('/usr/sbin/zfs', 'set', volsize_str, zfs_volume) |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
493 |
except Exception: |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
494 |
msg = (_("Failed to extend volume size to %(new_size)s GB.") |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
495 |
% {'new_size': new_size}) |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
496 |
raise exception.VolumeBackendAPIException(data=msg) |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
497 |
|
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
498 |
def rename_volume(self, src, dst): |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
499 |
"""Rename the volume from src to dst in the same zpool.""" |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
500 |
cmd = ['/usr/sbin/zfs', 'rename', src, dst] |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
501 |
self._execute(*cmd) |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
502 |
|
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
503 |
LOG.debug(_("Rename the volume '%s' to '%s'") % (src, dst)) |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
504 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
505 |
def _get_existing_volume_ref_name(self, existing_ref): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
506 |
"""Returns the volume name of an existing reference. |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
507 |
And Check if an existing volume reference has a source-name |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
508 |
""" |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
509 |
if 'source-name' in existing_ref: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
510 |
vol_name = existing_ref['source-name'] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
511 |
return vol_name |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
512 |
else: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
513 |
reason = _("Reference must contain source-name.") |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
514 |
raise exception.ManageExistingInvalidReference( |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
515 |
existing_ref=existing_ref, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
516 |
reason=reason) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
517 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
518 |
def manage_existing_get_size(self, volume, existing_ref): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
519 |
"""Return size of volume to be managed by manage_existing. |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
520 |
existing_ref is a dictionary of the form: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
521 |
{'source-name': <name of the volume>} |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
522 |
""" |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
523 |
target_vol_name = self._get_existing_volume_ref_name(existing_ref) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
524 |
volsize = self._get_zfs_property('volsize', target_vol_name) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
525 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
526 |
return Size(volsize).get(Size.gb_units) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
527 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
528 |
def manage_existing(self, volume, existing_ref): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
529 |
"""Brings an existing zfs volume object under Cinder management. |
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
530 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
531 |
:param volume: Cinder volume to manage |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
532 |
:param existing_ref: Driver-specific information used to identify a |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
533 |
volume |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
534 |
""" |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
535 |
# Check the existence of the ZFS volume |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
536 |
target_vol_name = self._get_existing_volume_ref_name(existing_ref) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
537 |
prop_type = self._get_zfs_property('type', target_vol_name) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
538 |
if prop_type != 'volume': |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
539 |
msg = (_("Failed to identify the volume '%s'.") |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
540 |
% target_vol_name) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
541 |
raise exception.InvalidInput(reason=msg) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
542 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
543 |
if volume['name']: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
544 |
volume_name = volume['name'] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
545 |
else: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
546 |
volume_name = 'new_zvol' |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
547 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
548 |
# rename the volume |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
549 |
dst_volume = "%s/%s" % (self.configuration.zfs_volume_base, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
550 |
volume_name) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
551 |
self.rename_volume(target_vol_name, dst_volume) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
552 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
553 |
def unmanage(self, volume): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
554 |
"""Removes the specified volume from Cinder management.""" |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
555 |
# Rename the volume's name to cinder-unm-* format. |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
556 |
volume_name = self._get_zfs_volume_name(volume['name']) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
557 |
tmp_volume_name = "cinder-unm-%s" % volume['name'] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
558 |
new_volume_name = "%s/%s" % (self.configuration.zfs_volume_base, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
559 |
tmp_volume_name) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
560 |
self.rename_volume(volume_name, new_volume_name) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
561 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
562 |
def migrate_volume(self, context, volume, host): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
563 |
"""Migrate the volume from one backend to another one. |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
564 |
The backends should be in the same volume type. |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
565 |
|
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
566 |
:param context: context |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
567 |
:param volume: a dictionary describing the volume to migrate |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
568 |
:param host: a dictionary describing the host to migrate to |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
569 |
""" |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
570 |
false_ret = (False, None) |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
571 |
if volume['status'] != 'available': |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
572 |
LOG.debug(_("Status of volume '%s' is '%s', not 'available'.") % |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
573 |
(volume['name'], volume['status'])) |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
574 |
return false_ret |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
575 |
|
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
576 |
if 'capabilities' not in host: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
577 |
LOG.debug(("No 'capabilities' is reported in the host'%s'") % |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
578 |
host['host']) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
579 |
return false_ret |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
580 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
581 |
if 'location_info' not in host['capabilities']: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
582 |
LOG.debug(("No 'location_info' is reported in the host'%s'") % |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
583 |
host['host']) |
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
584 |
return false_ret |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
585 |
|
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
586 |
info = host['capabilities']['location_info'] |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
587 |
dst_volume = "%s/%s" % (info.split(':')[2], volume['name']) |
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
588 |
src_volume = self._get_zfs_volume_name(volume['name']) |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
589 |
|
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
590 |
# check if the src and dst volume are under the same zpool |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
591 |
dst_san_info = info.split(':')[3] |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
592 |
if dst_san_info == 'local': |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
593 |
self._zfs_send_recv(volume, dst_volume) |
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
594 |
else: |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
595 |
self._rad_zfs_send_recv(volume, dst_volume, dst_san_info) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
596 |
# delete the source volume |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
597 |
self.delete_volume(volume) |
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
598 |
|
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
599 |
provider_location = {} |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
600 |
return (True, provider_location) |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
601 |
|
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
602 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
603 |
class STMFDriver(ZFSVolumeDriver): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
604 |
"""Abstract base class for common COMSTAR operations.""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
605 |
__metaclass__ = abc.ABCMeta |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
606 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
607 |
def __init__(self, *args, **kwargs): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
608 |
super(STMFDriver, self).__init__(*args, **kwargs) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
609 |
|
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
610 |
def _stmf_execute(self, *cmd): |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
611 |
"""Handle the possible race during the local execution.""" |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
612 |
tries = 0 |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
613 |
while True: |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
614 |
try: |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
615 |
self._execute(*cmd) |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
616 |
return |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
617 |
except processutils.ProcessExecutionError as ex: |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
618 |
tries = tries + 1 |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
619 |
|
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
620 |
if tries >= self.configuration.num_shell_tries or \ |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
621 |
'resource busy' not in ex.stderr: |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
622 |
raise |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
623 |
|
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
624 |
time.sleep(tries ** 2) |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
625 |
|
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
626 |
def _check_target(self, target, protocol): |
5317
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
627 |
"""Verify the target and check its status.""" |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
628 |
try: |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
629 |
(out, _err) = self._execute('/usr/sbin/stmfadm', 'list-target', |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
630 |
'-v', target) |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
631 |
tmp_protocol = None |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
632 |
status = None |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
633 |
for line in [l.strip() for l in out.splitlines()]: |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
634 |
if line.startswith("Operational"): |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
635 |
status = line.split()[-1] |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
636 |
if line.startswith("Protocol"): |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
637 |
tmp_protocol = line.split()[-1] |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
638 |
break |
5317
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
639 |
if tmp_protocol == protocol: |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
640 |
return status |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
641 |
else: |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
642 |
err_msg = (_("'%s' does not match the listed protocol '%s'" |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
643 |
" for target '%s'.") |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
644 |
% (protocol, tmp_protocol, target)) |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
645 |
except processutils.ProcessExecutionError as error: |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
646 |
if 'not found' in error.stderr: |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
647 |
LOG.debug(_("The target '%s' is not found.") % target) |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
648 |
return None |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
649 |
else: |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
650 |
err_msg = (_("Failed to list the target '%s': '%s'") |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
651 |
% (target, error.stderr)) |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
652 |
raise exception.VolumeBackendAPIException(data=err_msg) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
653 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
654 |
def _check_tg(self, tg): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
655 |
"""Check if the target group exists.""" |
5317
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
656 |
try: |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
657 |
self._execute('/usr/sbin/stmfadm', 'list-tg', tg) |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
658 |
return True |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
659 |
except processutils.ProcessExecutionError as error: |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
660 |
if 'not found' in error.stderr: |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
661 |
LOG.debug(_("The target group '%s' is not found.") % tg) |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
662 |
return False |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
663 |
else: |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
664 |
err_msg = (_("Failed to list the target group '%s': '%s'") |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
665 |
% (tg, error.stderr)) |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
666 |
raise exception.VolumeBackendAPIException(data=err_msg) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
667 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
668 |
def _get_luid(self, volume): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
669 |
"""Get the LU corresponding to the volume.""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
670 |
zvol = self._get_zvol_path(volume) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
671 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
672 |
(out, _err) = self._execute('/usr/sbin/stmfadm', 'list-lu', '-v') |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
673 |
luid = None |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
674 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
675 |
for line in [l.strip() for l in out.splitlines()]: |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
676 |
if line.startswith("LU Name:"): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
677 |
luid = line.split()[-1] |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
678 |
if line.startswith("Alias") and line.split()[-1] == zvol: |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
679 |
break |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
680 |
else: |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
681 |
luid = None |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
682 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
683 |
if luid is not None: |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
684 |
LOG.debug(_("Got the LU '%s'") % luid) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
685 |
else: |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
686 |
LOG.debug(_("Failed to get LU for volume '%s'") |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
687 |
% volume['name']) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
688 |
return luid |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
689 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
690 |
def _get_view_and_lun(self, lu): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
691 |
"""Check the view entry of the LU and then get the lun and view.""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
692 |
view_and_lun = {} |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
693 |
view_and_lun['view'] = view_and_lun['lun'] = None |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
694 |
try: |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
695 |
(out, _err) = self._execute('/usr/sbin/stmfadm', 'list-view', |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
696 |
'-l', lu, '-v') |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
697 |
except processutils.ProcessExecutionError as error: |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
698 |
if 'no views found' in error.stderr: |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
699 |
LOG.debug(_("No view is found for LU '%s'") % lu) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
700 |
return view_and_lun |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
701 |
else: |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
702 |
raise |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
703 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
704 |
for line in [l.strip() for l in out.splitlines()]: |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
705 |
if line.startswith("View Entry:"): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
706 |
view_and_lun['view'] = line.split()[-1] |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
707 |
if line.startswith("LUN") and 'Auto' not in line.split()[-1]: |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
708 |
view_and_lun['lun'] = int(line.split()[-1]) |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
709 |
break |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
710 |
if line.startswith("Lun"): |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
711 |
view_and_lun['lun'] = int(line.split()[2]) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
712 |
|
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
713 |
if view_and_lun['view'] is None or view_and_lun['lun'] is None: |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
714 |
err_msg = (_("Failed to get the view_entry or LUN of the LU '%s'.") |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
715 |
% lu) |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
716 |
raise exception.VolumeBackendAPIException(data=err_msg) |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
717 |
else: |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
718 |
LOG.debug(_("The view_entry and LUN of LU '%s' are '%s' and '%d'.") |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
719 |
% (lu, view_and_lun['view'], view_and_lun['lun'])) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
720 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
721 |
return view_and_lun |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
722 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
723 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
724 |
class ZFSISCSIDriver(STMFDriver, driver.ISCSIDriver): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
725 |
"""ZFS volume operations in iSCSI mode.""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
726 |
protocol = 'iSCSI' |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
727 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
728 |
def __init__(self, *args, **kwargs): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
729 |
super(ZFSISCSIDriver, self).__init__(*args, **kwargs) |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
730 |
if not self.configuration.san_is_local: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
731 |
self.hostname, alias, addresslist = \ |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
732 |
socket.gethostbyaddr(self.configuration.san_ip) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
733 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
734 |
def get_volume_stats(self, refresh=False): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
735 |
"""Get volume status.""" |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
736 |
status = super(ZFSISCSIDriver, self).get_volume_stats(refresh) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
737 |
status["storage_protocol"] = self.protocol |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
738 |
backend_name = self.configuration.safe_get('volume_backend_name') |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
739 |
status["volume_backend_name"] = backend_name or self.__class__.__name__ |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
740 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
741 |
if not self.configuration.san_is_local: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
742 |
san_info = "%s;%s;%s" % (self.configuration.san_ip, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
743 |
self.configuration.san_login, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
744 |
self.configuration.san_password) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
745 |
status['location_info'] = \ |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
746 |
('ZFSISCSIDriver:%(hostname)s:%(zfs_volume_base)s:' |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
747 |
'%(san_info)s' % |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
748 |
{'hostname': self.hostname, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
749 |
'zfs_volume_base': self.configuration.zfs_volume_base, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
750 |
'san_info': san_info}) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
751 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
752 |
return status |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
753 |
|
5317
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
754 |
def do_setup(self, context): |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
755 |
"""Setup the target and target group.""" |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
756 |
target_group = self.configuration.zfs_target_group |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
757 |
target_name = '%s%s-%s-target' % \ |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
758 |
(self.configuration.iscsi_target_prefix, |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
759 |
self.hostname, |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
760 |
target_group) |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
761 |
|
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
762 |
if not self._check_tg(target_group): |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
763 |
self._stmf_execute('/usr/sbin/stmfadm', 'create-tg', target_group) |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
764 |
target_status = self._check_target(target_name, 'iSCSI') |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
765 |
if target_status == 'Online': |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
766 |
return |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
767 |
|
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
768 |
if target_status is None: |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
769 |
# Create and add the target into the target group |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
770 |
self._stmf_execute('/usr/sbin/itadm', 'create-target', '-n', |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
771 |
target_name) |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
772 |
self._stmf_execute('/usr/sbin/stmfadm', 'offline-target', |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
773 |
target_name) |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
774 |
self._stmf_execute('/usr/sbin/stmfadm', 'add-tg-member', '-g', |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
775 |
target_group, target_name) |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
776 |
|
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
777 |
# Online the target from the 'Offline' status |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
778 |
self._stmf_execute('/usr/sbin/stmfadm', 'online-target', |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
779 |
target_name) |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
780 |
assert self._check_target(target_name, 'iSCSI') == 'Online' |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
781 |
|
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
782 |
def create_export(self, context, volume): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
783 |
"""Export the volume.""" |
5430
b6b088be89d5
18595100 nova resize does not work
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5317
diff
changeset
|
784 |
# If the volume is already exported there is nothing to do, as we |
b6b088be89d5
18595100 nova resize does not work
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5317
diff
changeset
|
785 |
# simply export volumes and they are universally available. |
5431
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
786 |
luid = self._get_luid(volume) |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
787 |
if luid: |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
788 |
view_lun = self._get_view_and_lun(luid) |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
789 |
if view_lun['view'] is not None: |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
790 |
return |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
791 |
else: |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
792 |
msg = (_("Failed to create logical unit for volume '%s' due " |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
793 |
"to an existing LU id but no view.") % volume['name']) |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
794 |
raise exception.VolumeBackendAPIException(data=msg) |
5430
b6b088be89d5
18595100 nova resize does not work
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5317
diff
changeset
|
795 |
|
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
796 |
zvol = self._get_zvol_path(volume) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
797 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
798 |
# Create a Logical Unit (LU) |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
799 |
self._stmf_execute('/usr/sbin/stmfadm', 'create-lu', zvol) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
800 |
luid = self._get_luid(volume) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
801 |
if not luid: |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
802 |
msg = (_("Failed to create LU for volume '%s'") |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
803 |
% volume['name']) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
804 |
raise exception.VolumeBackendAPIException(data=msg) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
805 |
|
5317
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
806 |
# Add a view entry to the logical unit |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
807 |
target_group = self.configuration.zfs_target_group |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
808 |
self._stmf_execute('/usr/sbin/stmfadm', 'add-view', |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
809 |
'-t', target_group, luid) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
810 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
811 |
def remove_export(self, context, volume): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
812 |
"""Remove an export for a volume. |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
813 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
814 |
All of the related elements about the volume, including the |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
815 |
target, target group, view entry and lu, are deleted. |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
816 |
""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
817 |
luid = self._get_luid(volume) |
5317
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
818 |
|
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
819 |
# Remove the LU |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
820 |
if luid is not None: |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
821 |
self._stmf_execute('/usr/sbin/stmfadm', 'delete-lu', luid) |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
822 |
|
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
823 |
# Remove the target and its target group if they were created by |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
824 |
# earlier versions of the volume driver |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
825 |
target_group = 'tg-%s' % volume['name'] |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
826 |
target_name = '%s%s' % (self.configuration.iscsi_target_prefix, |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
827 |
volume['name']) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
828 |
|
5317
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
829 |
if self._check_target(target_name, 'iSCSI') is not None: |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
830 |
self._stmf_execute('/usr/sbin/itadm', 'delete-target', '-f', |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
831 |
target_name) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
832 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
833 |
if self._check_tg(target_group): |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
834 |
self._stmf_execute('/usr/sbin/stmfadm', 'delete-tg', target_group) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
835 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
836 |
def _get_iscsi_properties(self, volume): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
837 |
"""Get iSCSI configuration |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
838 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
839 |
Now we use the discovery address as the default approach to add |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
840 |
objects into the initiator. A discovery address is an IP address:port |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
841 |
combination used in a SendTargets discovery session in the initiator. |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
842 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
843 |
:target_discovered: boolean indicating whether discovery was used |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
844 |
:target_iqn: the IQN of the iSCSI target |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
845 |
:target_portal: the portal of the iSCSI target |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
846 |
:target_lun: the lun of the iSCSI target |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
847 |
:volume_id: the id of the volume |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
848 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
849 |
:auth_method:, :auth_username:, :auth_password: |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
850 |
the authentication details. Right now, either auth_method is not |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
851 |
present meaning no authentication, or auth_method == `CHAP` |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
852 |
meaning use CHAP with the specified credentials. |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
853 |
""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
854 |
luid = self._get_luid(volume) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
855 |
if not luid: |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
856 |
msg = (_("Failed to get LU for volume '%s'") % volume['name']) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
857 |
raise exception.VolumeBackendAPIException(data=msg) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
858 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
859 |
target_name = '%s%s' % (self.configuration.iscsi_target_prefix, |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
860 |
volume['name']) |
5317
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
861 |
if self._check_target(target_name, 'iSCSI') is None: |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
862 |
target_name = '%s%s-%s-target' % \ |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
863 |
(self.configuration.iscsi_target_prefix, |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
864 |
self.hostname, |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
865 |
self.configuration.zfs_target_group) |
fa561e436e88
22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4937
diff
changeset
|
866 |
|
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
867 |
properties = {} |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
868 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
869 |
properties['target_discovered'] = True |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
870 |
properties['target_iqn'] = target_name |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
871 |
|
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
872 |
# Here the san_is_local means that the cinder-volume runs in the |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
873 |
# iSCSI target with iscsi_ip_address. |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
874 |
if self.configuration.san_is_local: |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
875 |
target_ip = self.configuration.iscsi_ip_address |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
876 |
else: |
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
877 |
target_ip = self.configuration.san_ip |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
878 |
properties['target_portal'] = ('%s:%d' % |
4937
8f0976d7e40e
PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents:
4072
diff
changeset
|
879 |
(target_ip, |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
880 |
self.configuration.iscsi_port)) |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
881 |
view_lun = self._get_view_and_lun(luid) |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
882 |
if view_lun['lun'] is not None: |
3028
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
883 |
properties['target_lun'] = view_lun['lun'] |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
884 |
properties['volume_id'] = volume['id'] |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
885 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
886 |
auth = volume['provider_auth'] |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
887 |
if auth: |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
888 |
(auth_method, auth_username, auth_secret) = auth.split() |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
889 |
properties['auth_method'] = auth_method |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
890 |
properties['auth_username'] = auth_username |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
891 |
properties['auth_password'] = auth_secret |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
892 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
893 |
return properties |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
894 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
895 |
def initialize_connection(self, volume, connector): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
896 |
"""Initialize the connection and returns connection info. |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
897 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
898 |
The iSCSI driver returns a driver_volume_type of 'iscsi'. |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
899 |
The format of the driver data is defined in _get_iscsi_properties. |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
900 |
Example return value:: |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
901 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
902 |
{ |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
903 |
'driver_volume_type': 'iscsi' |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
904 |
'data': { |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
905 |
'target_discovered': True, |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
906 |
'target_iqn': |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
907 |
'iqn.1986-03.com.sun:02:200720c6-9bca-cb8f-c061-d427d7ab978f', |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
908 |
'target_portal': '127.0.0.1:3260', |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
909 |
'volume_id': 1, |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
910 |
} |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
911 |
} |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
912 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
913 |
""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
914 |
initiator_name = connector['initiator'] |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
915 |
volume_name = volume['name'] |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
916 |
LOG.debug(_('Connecting the initiator %(initiator_name)s ' |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
917 |
'for volume %(volume_name)s') |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
918 |
% {'initiator_name': initiator_name, |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
919 |
'volume_name': volume_name}) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
920 |
iscsi_properties = self._get_iscsi_properties(volume) |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
921 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
922 |
return { |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
923 |
'driver_volume_type': 'iscsi', |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
924 |
'data': iscsi_properties |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
925 |
} |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
926 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
927 |
def terminate_connection(self, volume, connector, **kwargs): |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
928 |
"""Disconnection from the connector.""" |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
929 |
initiator_name = connector['initiator'] |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
930 |
volume_name = volume['name'] |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
931 |
|
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
932 |
LOG.debug(_('Disconnecting the initiator %(initiator_name)s ' |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
933 |
'for volume %(volume_name)s') |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
934 |
% {'initiator_name': initiator_name, |
5e73a3a3f66a
PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff
changeset
|
935 |
'volume_name': volume_name}) |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
936 |
|
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
937 |
|
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
938 |
class ZFSFCDriver(STMFDriver, driver.FibreChannelDriver): |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
939 |
"""ZFS volume operations in FC mode.""" |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
940 |
protocol = 'FC' |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
941 |
|
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
942 |
def __init__(self, *args, **kwargs): |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
943 |
super(ZFSFCDriver, self).__init__(*args, **kwargs) |
6035
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
944 |
if not self.configuration.san_is_local: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
945 |
self.hostname, alias, addresslist = \ |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
946 |
socket.gethostbyaddr(self.configuration.san_ip) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
947 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
948 |
def get_volume_stats(self, refresh=False): |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
949 |
"""Get volume status.""" |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
950 |
status = super(ZFSFCDriver, self).get_volume_stats(refresh) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
951 |
status["storage_protocol"] = self.protocol |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
952 |
backend_name = self.configuration.safe_get('volume_backend_name') |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
953 |
status["volume_backend_name"] = backend_name or self.__class__.__name__ |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
954 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
955 |
if not self.configuration.san_is_local: |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
956 |
san_info = "%s;%s;%s" % (self.configuration.san_ip, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
957 |
self.configuration.san_login, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
958 |
self.configuration.san_password) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
959 |
status['location_info'] = \ |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
960 |
('ZFSFCDriver:%(hostname)s:%(zfs_volume_base)s:' |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
961 |
'%(san_info)s' % |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
962 |
{'hostname': self.hostname, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
963 |
'zfs_volume_base': self.configuration.zfs_volume_base, |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
964 |
'san_info': san_info}) |
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
965 |
|
c9748fcc32de
PSARC 2015/535 OpenStack service updates for Kilo
Devjani Ray <devjani.ray@oracle.com>
parents:
5431
diff
changeset
|
966 |
return status |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
967 |
|
7787
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
968 |
def do_setup(self, context): |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
969 |
"""Check wwns and setup the target group.""" |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
970 |
self.wwns = self._get_wwns() |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
971 |
if not self.wwns: |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
972 |
msg = (_("Could not determine fibre channel world wide " |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
973 |
"node names.")) |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
974 |
raise exception.VolumeBackendAPIException(data=msg) |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
975 |
|
7787
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
976 |
self.tg = 'tg-wwn-%s' % self.wwns[0] |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
977 |
if not self._check_tg(self.tg): |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
978 |
self._setup_tg(self.tg) |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
979 |
|
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
980 |
def _get_wwns(self): |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
981 |
"""Get the FC port WWNs of the host.""" |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
982 |
(out, _err) = self._execute('/usr/sbin/fcinfo', 'hba-port', '-t') |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
983 |
|
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
984 |
wwns = [] |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
985 |
for line in [l.strip() for l in out.splitlines()]: |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
986 |
if line.startswith("HBA Port WWN:"): |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
987 |
wwn = line.split()[-1] |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
988 |
LOG.debug(_("Got the FC port WWN '%s'") % wwn) |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
989 |
wwns.append(wwn) |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
990 |
|
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
991 |
return wwns |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
992 |
|
7787
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
993 |
def _get_target_wwns(self, tg): |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
994 |
"""Get the target members in the tg.""" |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
995 |
(out, _err) = self._execute('/usr/sbin/stmfadm', 'list-tg', |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
996 |
'-v', tg) |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
997 |
|
7787
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
998 |
wwns = [] |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
999 |
for line in [l.strip() for l in out.splitlines()]: |
7787
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1000 |
if line.startswith("Member:"): |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1001 |
wwn = line.split()[-1] |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1002 |
target_wwn = wwn.split('.')[-1] |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1003 |
wwns.append(target_wwn) |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1004 |
return wwns |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1005 |
|
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1006 |
def _setup_tg(self, tg): |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1007 |
"""Setup the target group.""" |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1008 |
self._stmf_execute('/usr/sbin/stmfadm', 'create-tg', tg) |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1009 |
|
7787
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1010 |
# Add free target wwns into the target group |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1011 |
for wwn in self.wwns: |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1012 |
if not self._target_in_tg(wwn, None): |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1013 |
target_wwn = 'wwn.%s' % wwn |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1014 |
try: |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1015 |
self._stmf_execute('/usr/sbin/stmfadm', 'offline-target', |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1016 |
target_wwn) |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1017 |
self._stmf_execute('/usr/sbin/stmfadm', 'add-tg-member', |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1018 |
'-g', tg, target_wwn) |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1019 |
self._stmf_execute('/usr/sbin/stmfadm', 'online-target', |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1020 |
target_wwn) |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1021 |
assert self._check_target(wwn, 'Channel') == 'Online' |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1022 |
|
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1023 |
except: |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1024 |
LOG.error(_LE("Failed to add and online the target '%s'.") |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1025 |
% (target_wwn)) |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1026 |
|
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1027 |
target_wwns = self._get_target_wwns(tg) |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1028 |
if not target_wwns: |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1029 |
msg = (_("No target members exist in the target group '%s'.") |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1030 |
% tg) |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1031 |
raise exception.VolumeBackendAPIException(data=msg) |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1032 |
|
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1033 |
def _only_lu(self, lu): |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1034 |
"""Check if the LU is the only one.""" |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1035 |
(out, _err) = self._execute('/usr/sbin/stmfadm', 'list-lu', '-v') |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1036 |
linecount = 0 |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1037 |
|
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1038 |
for line in [l.strip() for l in out.splitlines()]: |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1039 |
if line.startswith("LU Name:"): |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1040 |
luid = line.split()[-1] |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1041 |
linecount += 1 |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1042 |
|
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1043 |
if linecount == 1 and luid == lu: |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1044 |
LOG.debug(_("The LU '%s' is the only one.") % lu) |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1045 |
return True |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1046 |
else: |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1047 |
return False |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1048 |
|
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1049 |
def _target_in_tg(self, wwn, tg): |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1050 |
"""Check if the target has been added into a target group.""" |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1051 |
target = 'wwn.%s' % wwn.upper() |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1052 |
|
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1053 |
if tg is not None: |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1054 |
(out, _err) = self._execute('/usr/sbin/stmfadm', 'list-tg', |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1055 |
'-v', tg) |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1056 |
else: |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1057 |
(out, _err) = self._execute('/usr/sbin/stmfadm', 'list-tg', '-v') |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1058 |
for line in [l.strip() for l in out.splitlines()]: |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1059 |
if line.startswith("Member:") and target in line: |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1060 |
return True |
7787
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1061 |
LOG.debug(_("The target '%s' is not in %s target group.") % |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1062 |
(target, tg if tg else 'any')) |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1063 |
return False |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1064 |
|
7787
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1065 |
def _force_lip_wwn(self): |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1066 |
"""Force the link to reinitialize.""" |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1067 |
target_wwns = self._get_target_wwns(self.tg) |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1068 |
for target_wwn in target_wwns: |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1069 |
self._stmf_execute('/usr/sbin/fcadm', 'force-lip', target_wwn) |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1070 |
|
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1071 |
def create_export(self, context, volume): |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1072 |
"""Export the volume.""" |
5431
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
1073 |
# If the volume is already exported there is nothing to do, as we |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
1074 |
# simply export volumes and they are universally available. |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
1075 |
luid = self._get_luid(volume) |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
1076 |
if luid: |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
1077 |
view_lun = self._get_view_and_lun(luid) |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
1078 |
if view_lun['view'] is not None: |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
1079 |
return |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
1080 |
else: |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
1081 |
msg = (_("Failed to create logical unit for volume '%s' due " |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
1082 |
"to an existing LU id but no view.") % volume['name']) |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
1083 |
raise exception.VolumeBackendAPIException(data=msg) |
a515b642a711
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Sean Wilcox <sean.wilcox@oracle.com>
parents:
5430
diff
changeset
|
1084 |
|
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1085 |
zvol = self._get_zvol_path(volume) |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1086 |
# Create a Logical Unit (LU) |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
1087 |
self._stmf_execute('/usr/sbin/stmfadm', 'create-lu', zvol) |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1088 |
luid = self._get_luid(volume) |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1089 |
if not luid: |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1090 |
msg = (_("Failed to create logic unit for volume '%s'") |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1091 |
% volume['name']) |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1092 |
raise exception.VolumeBackendAPIException(data=msg) |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1093 |
|
7787
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1094 |
# setup the target group if it doesn't exist. |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1095 |
if not self._check_tg(self.tg): |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1096 |
self._setup_tg(self.tg) |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1097 |
# Add a logical unit view entry |
7787
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1098 |
self._stmf_execute('/usr/sbin/stmfadm', 'add-view', '-t', |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1099 |
self.tg, luid) |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1100 |
self._force_lip_wwn() |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1101 |
|
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1102 |
def remove_export(self, context, volume): |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1103 |
"""Remove an export for a volume.""" |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1104 |
luid = self._get_luid(volume) |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1105 |
|
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1106 |
if luid is not None: |
7787
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1107 |
target_group = self.tg |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1108 |
view_lun = self._get_view_and_lun(luid) |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1109 |
if view_lun['view']: |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
1110 |
self._stmf_execute('/usr/sbin/stmfadm', 'remove-view', '-l', |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
1111 |
luid, view_lun['view']) |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1112 |
|
7787
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1113 |
# Remove the target group when the LU to be deleted is last one |
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1114 |
# exposed by the target group. |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1115 |
if self._only_lu(luid): |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1116 |
if self._check_tg(target_group): |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
1117 |
self._stmf_execute('/usr/sbin/stmfadm', 'delete-tg', |
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
1118 |
target_group) |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1119 |
|
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1120 |
# Remove the LU |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
1121 |
self._stmf_execute('/usr/sbin/stmfadm', 'delete-lu', luid) |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1122 |
|
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1123 |
def _get_fc_properties(self, volume): |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1124 |
"""Get Fibre Channel configuration. |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1125 |
|
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1126 |
:target_discovered: boolean indicating whether discovery was used |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1127 |
:target_wwn: the world wide name of the FC port target |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1128 |
:target_lun: the lun assigned to the LU for the view entry |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1129 |
|
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1130 |
""" |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1131 |
luid = self._get_luid(volume) |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1132 |
if not luid: |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1133 |
msg = (_("Failed to get logic unit for volume '%s'") |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1134 |
% volume['name']) |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1135 |
raise exception.VolumeBackendAPIException(data=msg) |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1136 |
|
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1137 |
properties = {} |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1138 |
|
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1139 |
properties['target_discovered'] = True |
7787
26bcbec7afce
23294485 Cinder ZFSFCDriver fails to find the right target wwn
saurabh.vyas@oracle.com
parents:
6035
diff
changeset
|
1140 |
properties['target_wwn'] = self._get_target_wwns(self.tg) |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1141 |
view_lun = self._get_view_and_lun(luid) |
4072
db0cec748ec0
PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents:
3178
diff
changeset
|
1142 |
if view_lun['lun'] is not None: |
3178
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1143 |
properties['target_lun'] = view_lun['lun'] |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1144 |
return properties |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1145 |
|
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1146 |
def initialize_connection(self, volume, connector): |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1147 |
"""Initializes the connection and returns connection info. |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1148 |
|
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1149 |
The driver returns a driver_volume_type of 'fibre_channel'. |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1150 |
The target_wwn can be a single entry or a list of wwns that |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1151 |
correspond to the list of remote wwn(s) that will export the volume. |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1152 |
Example return values: |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1153 |
|
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1154 |
{ |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1155 |
'driver_volume_type': 'fibre_channel' |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1156 |
'data': { |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1157 |
'target_discovered': True, |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1158 |
'target_lun': 1, |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1159 |
'target_wwn': '1234567890123', |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1160 |
} |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1161 |
} |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1162 |
|
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1163 |
or |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1164 |
|
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1165 |
{ |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1166 |
'driver_volume_type': 'fibre_channel' |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1167 |
'data': { |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1168 |
'target_discovered': True, |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1169 |
'target_lun': 1, |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1170 |
'target_wwn': ['1234567890123', '0987654321321'], |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1171 |
} |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1172 |
} |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1173 |
|
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1174 |
""" |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1175 |
fc_properties = self._get_fc_properties(volume) |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1176 |
|
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1177 |
return { |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1178 |
'driver_volume_type': 'fibre_channel', |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1179 |
'data': fc_properties |
77584387a894
PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents:
3147
diff
changeset
|
1180 |
} |