components/openstack/cinder/files/solaris/zfs.py
author Sean Wilcox <sean.wilcox@oracle.com>
Tue, 09 Feb 2016 16:26:27 -0800
branchs11u3-sru
changeset 5431 a515b642a711
parent 5430 b6b088be89d5
child 6035 c9748fcc32de
permissions -rw-r--r--
21480249 create --source-volid should clone the volume w/o blocking the delete of source
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
#
5317
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
     5
# Copyright (c) 2014, 2016, 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 socket
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
    26
import subprocess
4072
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
    27
import time
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    28
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    29
from oslo.config import cfg
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
    30
import paramiko
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    31
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    32
from cinder import exception
4937
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
    33
from cinder.i18n import _
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    34
from cinder.image import image_utils
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    35
from cinder.openstack.common import log as logging
3178
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
    36
from cinder.openstack.common import processutils
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    37
from cinder.volume import driver
4937
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
    38
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
    39
3147
891ab4caf1bc 18658040 zfs.py can't handle terabyte pools
Strony <strony.zhang@oracle.com>
parents: 3028
diff changeset
    40
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
    41
3178
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
    42
FLAGS = cfg.CONF
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    43
LOG = logging.getLogger(__name__)
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    44
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    45
solaris_zfs_opts = [
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    46
    cfg.StrOpt('zfs_volume_base',
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    47
               default='rpool/cinder',
5317
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
    48
               help='The base dataset for ZFS volumes.'),
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
    49
    cfg.StrOpt('zfs_target_group',
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
    50
               default='tgt-grp',
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
    51
               help='iSCSI target group name.'), ]
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    52
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    53
FLAGS.register_opts(solaris_zfs_opts)
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    54
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    55
4937
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
    56
class ZFSVolumeDriver(SanDriver):
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    57
    """Local ZFS volume operations."""
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    58
    protocol = 'local'
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
    def __init__(self, *args, **kwargs):
4937
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
    61
        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
    62
                                              *args, **kwargs)
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    63
        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
    64
        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
    65
        self.hostname = socket.gethostname()
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
    66
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
    67
    def solaris_execute(self, *cmd, **kwargs):
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
    68
        """Execute the command locally or remotely."""
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
    69
        if self.run_local:
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
    70
            return processutils.execute(*cmd, **kwargs)
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
    71
        else:
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
    72
            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
    73
                                                         check_exit_code=True)
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    74
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    75
    def check_for_setup_error(self):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    76
        """Check the setup error."""
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    77
        pass
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    78
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    79
    def create_volume(self, volume):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    80
        """Create a volume."""
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    81
        size = '%sG' % volume['size']
4937
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
    82
        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
    83
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    84
        # Create a ZFS volume
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    85
        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
    86
        self._execute(*cmd)
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    87
        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
    88
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    89
    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
    90
        """Create a cloned volume from a snapshot."""
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    91
        if volume['size'] != snapshot['volume_size']:
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    92
            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
    93
                                   "its volume size of '%s' is different "
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    94
                                   "from that of the snapshot, '%s'.")
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    95
                                 % (volume['name'], volume['size'],
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    96
                                    snapshot['volume_size']))
3178
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
    97
            raise exception.InvalidInput(reason=exception_message)
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    98
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
    99
        # Create a ZFS clone
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   100
        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
   101
        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
   102
        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
   103
        self._execute(*cmd)
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   104
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   105
        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
   106
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   107
    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
   108
        """Create a clone of the specified volume."""
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   109
        if volume['size'] != src_vref['size']:
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   110
            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
   111
                                   "its volume size of '%s' is different "
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   112
                                   "from that of the source volume, '%s'.")
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   113
                                 % (volume['name'], volume['size'],
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   114
                                    src_vref['size']))
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   115
            raise exception.VolumeBackendAPIException(data=exception_message)
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   116
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
   117
        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
   118
                            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
   119
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   120
        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
   121
                  % (volume['name'], src_vref['name']))
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   122
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   123
    def delete_volume(self, volume):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   124
        """Delete a volume.
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   125
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   126
        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
   127
        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
   128
        well after it is removed.
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   129
        """
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   130
        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
   131
        try:
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   132
            (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
   133
        except processutils.ProcessExecutionError:
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   134
            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
   135
            return
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   136
4937
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   137
        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
   138
        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
   139
        tmp_cloned_vol = False
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
        # 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
   142
        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
   143
            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
   144
            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
   145
            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
   146
                tmp_cloned_vol = True
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   147
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   148
        cmd = ['/usr/sbin/zfs', 'destroy', zfs_volume]
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   149
        self._execute(*cmd)
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   150
        LOG.debug(_("Deleted volume '%s'") % volume['name'])
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   151
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   152
        if tmp_cloned_vol:
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   153
            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
   154
            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
   155
                      % (origin_snapshot, volume['name']))
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
    def create_snapshot(self, snapshot):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   158
        """Create a snapshot."""
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   159
        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
   160
        self._execute(*cmd)
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   161
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   162
        LOG.debug(_("Created snapshot '%s'") % snapshot['name'])
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   163
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   164
    def delete_snapshot(self, snapshot):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   165
        """Delete a snapshot."""
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   166
        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
   167
        self._execute(*cmd)
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   168
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   169
        LOG.debug(_("Deleted snapshot '%s'") % snapshot['name'])
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   170
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   171
    def ensure_export(self, context, volume):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   172
        """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
   173
        pass
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 create_export(self, context, volume):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   176
        """Export the volume."""
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   177
        pass
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   178
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   179
    def remove_export(self, context, volume):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   180
        """Remove an export for a volume."""
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   181
        pass
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   182
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   183
    def initialize_connection(self, volume, connector):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   184
        """Initialize the connection and returns connection info."""
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   185
        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
   186
                                        volume['id'])
4072
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   187
        properties = {}
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   188
        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
   189
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   190
        return {
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   191
            'driver_volume_type': 'local',
3178
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   192
            'volume_path': volume_path,
4072
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   193
            'data': properties
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   194
        }
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   195
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   196
    def terminate_connection(self, volume, connector, **kwargs):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   197
        """Disconnection from the connector."""
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   198
        pass
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   199
3178
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   200
    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
   201
                      mountpoint):
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   202
        """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
   203
        pass
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   204
3178
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   205
    def detach_volume(self, context, volume):
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   206
        """ Callback for volume detached."""
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   207
        pass
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 get_volume_stats(self, refresh=False):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   210
        """Get volume status."""
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   211
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   212
        if refresh:
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   213
            self._update_volume_stats()
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   214
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   215
        return self._stats
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   216
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   217
    def copy_image_to_volume(self, context, volume, image_service, image_id):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   218
        """Fetch the image from image_service and write it to the volume."""
4937
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   219
        raise NotImplementedError()
3028
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
    def copy_volume_to_image(self, context, volume, image_service, image_meta):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   222
        """Copy the volume to the specified image."""
4937
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   223
        raise NotImplementedError()
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   224
3147
891ab4caf1bc 18658040 zfs.py can't handle terabyte pools
Strony <strony.zhang@oracle.com>
parents: 3028
diff changeset
   225
    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
   226
        """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
   227
        try:
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   228
            (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
   229
                                        'value', prop, dataset)
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   230
            return out.rstrip()
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   231
        except processutils.ProcessExecutionError:
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   232
            LOG.info(_("Failed to get the property '%s' of the dataset '%s'") %
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   233
                     (prop, dataset))
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   234
            return None
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   235
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   236
    def _get_zfs_snap_name(self, snapshot):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   237
        """Get the snapshot path."""
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   238
        return "%s/%[email protected]%s" % (self.configuration.zfs_volume_base,
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   239
                             snapshot['volume_name'], snapshot['name'])
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   240
4937
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   241
    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
   242
        """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
   243
        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
   244
                          volume_name)
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   245
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
   246
    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
   247
        """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
   248
        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
   249
                  (' '.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
   250
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
   251
        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
   252
        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
   253
        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
   254
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
   255
        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
   256
        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
   257
        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
   258
        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
   259
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
   260
        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
   261
            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
   262
                        "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
   263
                      % (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
   264
            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
   265
            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
   266
4937
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   267
    def _piped_execute(self, cmd1, cmd2):
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   268
        """Pipe output of cmd1 into cmd2."""
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   269
        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
   270
                  (' '.join(cmd1), ' '.join(cmd2)))
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   271
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   272
        try:
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   273
            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
   274
                                  stderr=subprocess.PIPE)
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   275
        except:
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   276
            LOG.error(_("_piped_execute '%s' failed.") % (cmd1))
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   277
            raise
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   278
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   279
        # 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
   280
        # the non-blocking pipe.
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   281
        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
   282
        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
   283
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   284
        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
   285
                              stdout=subprocess.PIPE,
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   286
                              stderr=subprocess.PIPE)
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   287
        p1.stdout.close()
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   288
        stdout, stderr = p2.communicate()
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   289
        if p2.returncode:
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   290
            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
   291
                   (stdout, stderr))
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   292
            raise exception.VolumeBackendAPIException(data=msg)
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   293
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
   294
    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
   295
        """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
   296
        src_snapshot = {'volume_name': src['name'],
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   297
                        'name': 'tmp-snapshot-%s' % src['id']}
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   298
        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
   299
        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
   300
        # 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
   301
        if prop_type == 'snapshot':
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   302
            self.delete_snapshot(src_snapshot)
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   303
        # Create a temporary snapshot of volume
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   304
        self.create_snapshot(src_snapshot)
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   305
        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
   306
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   307
        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
   308
        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
   309
        # 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
   310
        # cinder.utils.check_ssh_injection(), the piped commands must be passed
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
   311
        # through via paramiko.  These commands take no user defined input
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
   312
        # 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
   313
        # 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
   314
        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
   315
            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
   316
            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
   317
            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
   318
            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
   319
        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
   320
            self._piped_execute(cmd1, cmd2)
4937
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   321
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   322
        # 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
   323
        self.delete_snapshot(src_snapshot)
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   324
        dst_snapshot_name = "%[email protected]%s" % (dst, src['id'])
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   325
        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
   326
        self._execute(*cmd)
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   327
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   328
    def _get_zvol_path(self, volume):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   329
        """Get the ZFS volume path."""
4937
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   330
        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
   331
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   332
    def _update_volume_stats(self):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   333
        """Retrieve volume status info."""
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   334
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   335
        LOG.debug(_("Updating volume status"))
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   336
        stats = {}
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   337
        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
   338
        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
   339
        stats["storage_protocol"] = self.protocol
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   340
        stats["driver_version"] = '1.0'
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   341
        stats["vendor_name"] = 'Oracle'
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   342
        stats['QoS_support'] = False
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   343
3147
891ab4caf1bc 18658040 zfs.py can't handle terabyte pools
Strony <strony.zhang@oracle.com>
parents: 3028
diff changeset
   344
        dataset = self.configuration.zfs_volume_base
891ab4caf1bc 18658040 zfs.py can't handle terabyte pools
Strony <strony.zhang@oracle.com>
parents: 3028
diff changeset
   345
        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
   346
        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
   347
        stats['total_capacity_gb'] = \
891ab4caf1bc 18658040 zfs.py can't handle terabyte pools
Strony <strony.zhang@oracle.com>
parents: 3028
diff changeset
   348
            (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
   349
        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
   350
        stats['reserved_percentage'] = self.configuration.reserved_percentage
4937
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   351
        stats['location_info'] =\
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   352
            ('ZFSVolumeDriver:%(hostname)s:%(zfs_volume_base)s' %
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   353
             {'hostname': self.hostname,
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   354
              '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
   355
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   356
        self._stats = stats
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   357
3178
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   358
    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
   359
        """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
   360
        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
   361
        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
   362
        try:
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   363
            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
   364
        except Exception:
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   365
            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
   366
                   % {'new_size': new_size})
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   367
            raise exception.VolumeBackendAPIException(data=msg)
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   368
4937
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   369
    def rename_volume(self, src, dst):
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   370
        """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
   371
        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
   372
        self._execute(*cmd)
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   373
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   374
        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
   375
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   376
    def migrate_volume(self, context, volume, host):
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   377
        """Migrate the volume among different backends on the same server.
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   378
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   379
        The volume migration can only run locally by calling zfs send/recv
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   380
        cmds and the specified host needs to be on the same server with the
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   381
        host. But, one exception is when the src and dst volume are located
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   382
        under the same zpool locally or remotely, the migration will be done
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   383
        by just renaming the volume.
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   384
        :param context: context
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   385
        :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
   386
        :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
   387
        """
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   388
        false_ret = (False, None)
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   389
        if volume['status'] != 'available':
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   390
            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
   391
                      (volume['name'], volume['status']))
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   392
            return false_ret
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   393
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   394
        if 'capabilities' not in host or \
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   395
           'location_info' not in host['capabilities']:
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   396
            LOG.debug(_("No location_info or capabilities are in host info"))
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   397
            return false_ret
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   398
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   399
        info = host['capabilities']['location_info']
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   400
        if (self.hostname != info.split(':')[1]):
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   401
            LOG.debug(_("Migration between two different servers '%s' and "
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   402
                      "'%s' is not supported yet.") %
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   403
                      (self.hostname, info.split(':')[1]))
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   404
            return false_ret
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   405
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   406
        dst_volume = "%s/%s" % (info.split(':')[-1], volume['name'])
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   407
        src_volume = self._get_zfs_volume_name(volume['name'])
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   408
        # check if the src and dst volume are under the same zpool
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   409
        if (src_volume.split('/')[0] == dst_volume.split('/')[0]):
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   410
            self.rename_volume(src_volume, dst_volume)
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   411
        else:
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   412
            self._zfs_send_recv(volume, dst_volume)
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   413
            # delete the source volume
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   414
            self.delete_volume(volume)
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   415
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   416
        provider_location = {}
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   417
        return (True, provider_location)
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   418
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   419
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   420
class STMFDriver(ZFSVolumeDriver):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   421
    """Abstract base class for common COMSTAR operations."""
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   422
    __metaclass__ = abc.ABCMeta
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   423
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   424
    def __init__(self, *args, **kwargs):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   425
        super(STMFDriver, self).__init__(*args, **kwargs)
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   426
4072
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   427
    def _stmf_execute(self, *cmd):
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   428
        """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
   429
        tries = 0
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   430
        while True:
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   431
            try:
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   432
                self._execute(*cmd)
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   433
                return
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   434
            except processutils.ProcessExecutionError as ex:
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   435
                tries = tries + 1
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   436
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   437
                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
   438
                        '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
   439
                    raise
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   440
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   441
                time.sleep(tries ** 2)
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   442
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   443
    def _check_target(self, target, protocol):
5317
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   444
        """Verify the target and check its status."""
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   445
        try:
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   446
            (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
   447
                                        '-v', target)
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   448
            tmp_protocol = None
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   449
            status = None
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   450
            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
   451
                if line.startswith("Operational"):
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   452
                    status = line.split()[-1]
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   453
                if line.startswith("Protocol"):
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   454
                    tmp_protocol = line.split()[-1]
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   455
                    break
5317
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   456
            if tmp_protocol == protocol:
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   457
                return status
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   458
            else:
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   459
                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
   460
                             " for target '%s'.")
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   461
                           % (protocol, tmp_protocol, target))
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   462
        except processutils.ProcessExecutionError as error:
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   463
            if 'not found' in error.stderr:
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   464
                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
   465
                return None
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   466
            else:
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   467
                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
   468
                           % (target, error.stderr))
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   469
        raise exception.VolumeBackendAPIException(data=err_msg)
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   470
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   471
    def _check_tg(self, tg):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   472
        """Check if the target group exists."""
5317
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   473
        try:
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   474
            self._execute('/usr/sbin/stmfadm', 'list-tg', tg)
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   475
            return True
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   476
        except processutils.ProcessExecutionError as error:
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   477
            if 'not found' in error.stderr:
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   478
                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
   479
                return False
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   480
            else:
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   481
                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
   482
                           % (tg, error.stderr))
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   483
            raise exception.VolumeBackendAPIException(data=err_msg)
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
    def _get_luid(self, volume):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   486
        """Get the LU corresponding to the volume."""
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   487
        zvol = self._get_zvol_path(volume)
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   488
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   489
        (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
   490
        luid = None
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   491
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   492
        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
   493
            if line.startswith("LU Name:"):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   494
                luid = line.split()[-1]
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   495
            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
   496
                break
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   497
        else:
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   498
            luid = None
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   499
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   500
        if luid is not None:
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   501
            LOG.debug(_("Got the LU '%s'") % luid)
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   502
        else:
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   503
            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
   504
                      % volume['name'])
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   505
        return luid
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   506
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   507
    def _get_view_and_lun(self, lu):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   508
        """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
   509
        view_and_lun = {}
3178
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   510
        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
   511
        try:
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   512
            (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
   513
                                        '-l', lu, '-v')
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   514
        except processutils.ProcessExecutionError as error:
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   515
            if 'no views found' in error.stderr:
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   516
                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
   517
                return view_and_lun
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   518
            else:
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   519
                raise
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   520
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   521
        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
   522
            if line.startswith("View Entry:"):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   523
                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
   524
            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
   525
                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
   526
                break
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   527
            if line.startswith("Lun"):
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   528
                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
   529
3178
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   530
        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
   531
            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
   532
                       % lu)
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   533
            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
   534
        else:
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   535
            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
   536
                      % (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
   537
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   538
        return view_and_lun
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   539
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   540
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   541
class ZFSISCSIDriver(STMFDriver, driver.ISCSIDriver):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   542
    """ZFS volume operations in iSCSI mode."""
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   543
    protocol = 'iSCSI'
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   544
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   545
    def __init__(self, *args, **kwargs):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   546
        super(ZFSISCSIDriver, self).__init__(*args, **kwargs)
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   547
5317
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   548
    def do_setup(self, context):
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   549
        """Setup the target and target group."""
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   550
        target_group = self.configuration.zfs_target_group
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   551
        target_name = '%s%s-%s-target' % \
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   552
                      (self.configuration.iscsi_target_prefix,
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   553
                       self.hostname,
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   554
                       target_group)
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   555
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   556
        if not self._check_tg(target_group):
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   557
            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
   558
        target_status = self._check_target(target_name, 'iSCSI')
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   559
        if target_status == 'Online':
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   560
            return
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   561
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   562
        if target_status is None:
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   563
            # 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
   564
            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
   565
                               target_name)
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   566
            self._stmf_execute('/usr/sbin/stmfadm', 'offline-target',
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   567
                               target_name)
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   568
            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
   569
                               target_group, target_name)
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   570
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   571
        # Online the target from the 'Offline' status
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   572
        self._stmf_execute('/usr/sbin/stmfadm', 'online-target',
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   573
                           target_name)
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   574
        assert self._check_target(target_name, 'iSCSI') == 'Online'
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   575
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   576
    def create_export(self, context, volume):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   577
        """Export the volume."""
5430
b6b088be89d5 18595100 nova resize does not work
Sean Wilcox <sean.wilcox@oracle.com>
parents: 5317
diff changeset
   578
        # 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
   579
        # 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
   580
        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
   581
        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
   582
            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
   583
            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
   584
                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
   585
            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
   586
                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
   587
                         "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
   588
                raise exception.VolumeBackendAPIException(data=msg)
5430
b6b088be89d5 18595100 nova resize does not work
Sean Wilcox <sean.wilcox@oracle.com>
parents: 5317
diff changeset
   589
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   590
        zvol = self._get_zvol_path(volume)
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   591
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   592
        # 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
   593
        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
   594
        luid = self._get_luid(volume)
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   595
        if not luid:
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   596
            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
   597
                   % volume['name'])
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   598
            raise exception.VolumeBackendAPIException(data=msg)
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   599
5317
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   600
        # Add a view entry to the logical unit
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   601
        target_group = self.configuration.zfs_target_group
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   602
        self._stmf_execute('/usr/sbin/stmfadm', 'add-view',
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   603
                           '-t', target_group, luid)
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   604
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   605
    def remove_export(self, context, volume):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   606
        """Remove an export for a volume.
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   607
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   608
        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
   609
        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
   610
        """
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   611
        luid = self._get_luid(volume)
5317
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   612
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   613
        # Remove the LU
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   614
        if luid is not None:
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   615
            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
   616
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   617
        # 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
   618
        # earlier versions of the volume driver
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   619
        target_group = 'tg-%s' % volume['name']
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   620
        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
   621
                                volume['name'])
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   622
5317
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   623
        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
   624
            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
   625
                               target_name)
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   626
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   627
        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
   628
            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
   629
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   630
    def _get_iscsi_properties(self, volume):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   631
        """Get iSCSI configuration
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   632
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   633
        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
   634
        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
   635
        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
   636
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   637
        :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
   638
        :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
   639
        :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
   640
        :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
   641
        :volume_id:            the id of the volume
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   642
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   643
        :auth_method:, :auth_username:, :auth_password:
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   644
            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
   645
            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
   646
            meaning use CHAP with the specified credentials.
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   647
        """
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   648
        luid = self._get_luid(volume)
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   649
        if not luid:
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   650
            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
   651
            raise exception.VolumeBackendAPIException(data=msg)
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   652
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   653
        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
   654
                                volume['name'])
5317
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   655
        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
   656
            target_name = '%s%s-%s-target' % \
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   657
                          (self.configuration.iscsi_target_prefix,
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   658
                           self.hostname,
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   659
                           self.configuration.zfs_target_group)
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   660
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   661
        properties = {}
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   662
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   663
        properties['target_discovered'] = True
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   664
        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
   665
4937
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   666
        # 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
   667
        # iSCSI target with iscsi_ip_address.
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   668
        if self.configuration.san_is_local:
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   669
            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
   670
        else:
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   671
            target_ip = self.configuration.san_ip
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   672
        properties['target_portal'] = ('%s:%d' %
4937
8f0976d7e40e PSARC 2015/289 OpenStack Cinder Enhancements
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4072
diff changeset
   673
                                       (target_ip,
3178
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   674
                                        self.configuration.iscsi_port))
3028
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   675
        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
   676
        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
   677
            properties['target_lun'] = view_lun['lun']
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   678
        properties['volume_id'] = volume['id']
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   679
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   680
        auth = volume['provider_auth']
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   681
        if auth:
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   682
            (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
   683
            properties['auth_method'] = auth_method
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   684
            properties['auth_username'] = auth_username
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   685
            properties['auth_password'] = auth_secret
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   686
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   687
        return properties
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   688
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   689
    def initialize_connection(self, volume, connector):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   690
        """Initialize the connection and returns connection info.
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   691
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   692
        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
   693
        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
   694
        Example return value::
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   695
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   696
        {
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   697
            'driver_volume_type': 'iscsi'
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   698
            'data': {
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   699
                'target_discovered': True,
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   700
                'target_iqn':
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   701
                '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
   702
                'target_portal': '127.0.0.1:3260',
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   703
                'volume_id': 1,
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   704
            }
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   705
        }
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   706
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   707
        """
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   708
        initiator_name = connector['initiator']
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   709
        volume_name = volume['name']
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   710
        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
   711
                    'for volume %(volume_name)s')
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   712
                  % {'initiator_name': initiator_name,
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   713
                     'volume_name': volume_name})
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   714
        iscsi_properties = self._get_iscsi_properties(volume)
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   715
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   716
        return {
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   717
            'driver_volume_type': 'iscsi',
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   718
            'data': iscsi_properties
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   719
        }
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
    def terminate_connection(self, volume, connector, **kwargs):
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   722
        """Disconnection from the connector."""
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   723
        initiator_name = connector['initiator']
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   724
        volume_name = volume['name']
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   725
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   726
        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
   727
                    'for volume %(volume_name)s')
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   728
                  % {'initiator_name': initiator_name,
5e73a3a3f66a PSARC/2013/350 OpenStack for Solaris (Umbrella)
Drew Fisher <drew.fisher@oracle.com>
parents:
diff changeset
   729
                     'volume_name': volume_name})
3178
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   730
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   731
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   732
class ZFSFCDriver(STMFDriver, driver.FibreChannelDriver):
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   733
    """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
   734
    protocol = 'FC'
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   735
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   736
    def __init__(self, *args, **kwargs):
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   737
        super(ZFSFCDriver, self).__init__(*args, **kwargs)
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   738
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   739
    def check_for_setup_error(self):
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   740
        """Check the setup error."""
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   741
        wwns = self._get_wwns()
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   742
        if not wwns:
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   743
            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
   744
                     "node names."))
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   745
            raise exception.VolumeBackendAPIException(data=msg)
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   746
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   747
    def _get_wwns(self):
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   748
        """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
   749
        (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
   750
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   751
        wwns = []
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   752
        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
   753
            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
   754
                wwn = line.split()[-1]
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   755
                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
   756
                wwns.append(wwn)
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   757
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   758
        return wwns
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   759
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   760
    def _check_wwn_tg(self, wwn):
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   761
        """Check if the target group 'tg-wwn-xxx' exists."""
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   762
        (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
   763
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   764
        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
   765
            if line.startswith("Target Group:") and wwn in line:
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   766
                tg = line.split()[-1]
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   767
                break
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   768
        else:
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   769
            LOG.debug(_("The target group 'tg-wwn-%s' doesn't exist.") % wwn)
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   770
            tg = None
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   771
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   772
        return tg
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   773
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   774
    def _only_lu(self, lu):
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   775
        """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
   776
        (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
   777
        linecount = 0
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   778
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   779
        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
   780
            if line.startswith("LU Name:"):
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   781
                luid = line.split()[-1]
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   782
                linecount += 1
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   783
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   784
        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
   785
            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
   786
            return True
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   787
        else:
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   788
            return False
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   789
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   790
    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
   791
        """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
   792
        target = 'wwn.%s' % wwn.upper()
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   793
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   794
        if tg is not None:
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   795
            (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
   796
                                        '-v', tg)
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   797
        else:
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   798
            (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
   799
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   800
        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
   801
            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
   802
                return True
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   803
        LOG.debug(_("The target '%s' is not in any target group.") % target)
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   804
        return False
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   805
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   806
    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
   807
        """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
   808
        # 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
   809
        # 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
   810
        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
   811
        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
   812
            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
   813
            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
   814
                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
   815
            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
   816
                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
   817
                         "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
   818
                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
   819
3178
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   820
        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
   821
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   822
        # 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
   823
        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
   824
        luid = self._get_luid(volume)
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   825
        if not luid:
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   826
            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
   827
                   % volume['name'])
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   828
            raise exception.VolumeBackendAPIException(data=msg)
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   829
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   830
        wwns = self._get_wwns()
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   831
        wwn = wwns[0]
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   832
        target_group = self._check_wwn_tg(wwn)
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   833
        if target_group is None:
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   834
            target_group = 'tg-wwn-%s' % wwn
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   835
            if self._target_in_tg(wwn, None):
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   836
                msg = (_("Target WWN '%s' has been found in another"
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   837
                         "target group, so it will not be added "
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   838
                         "into the expected target group '%s'.") %
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   839
                       (wwn, target_group))
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   840
                raise exception.VolumeBackendAPIException(data=msg)
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   841
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   842
            # Create a target group for the wwn
4072
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   843
            self._stmf_execute('/usr/sbin/stmfadm', 'create-tg', target_group)
3178
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   844
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   845
            # Enable the target and add it to the 'tg-wwn-xxx' group
4072
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   846
            self._stmf_execute('/usr/sbin/stmfadm', 'offline-target',
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   847
                               'wwn.%s' % wwn)
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   848
            self._stmf_execute('/usr/sbin/stmfadm', 'add-tg-member', '-g',
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   849
                               target_group, 'wwn.%s' % wwn)
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   850
            self._stmf_execute('/usr/sbin/stmfadm', 'online-target',
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   851
                               'wwn.%s' % wwn)
3178
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   852
        assert self._target_in_tg(wwn, target_group)
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   853
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   854
        # Add a logical unit view entry
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   855
        # TODO(Strony): replace the auto assigned LUN with '-n' option
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   856
        if luid is not None:
4072
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   857
            self._stmf_execute('/usr/sbin/stmfadm', 'add-view', '-t',
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   858
                               target_group, luid)
3178
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   859
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   860
    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
   861
        """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
   862
        luid = self._get_luid(volume)
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   863
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   864
        if luid is not None:
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   865
            wwns = self._get_wwns()
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   866
            wwn = wwns[0]
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   867
            target_wwn = 'wwn.%s' % wwn
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   868
            target_group = 'tg-wwn-%s' % wwn
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   869
            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
   870
            if view_lun['view']:
4072
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   871
                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
   872
                                   luid, view_lun['view'])
3178
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   873
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   874
            # Remove the target group when only one LU exists.
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   875
            if self._only_lu(luid):
5317
fa561e436e88 22031461 volume attachment failed
Qiang Strony Zhang <strony.zhang@oracle.com>
parents: 4937
diff changeset
   876
                if self._check_target(target_wwn, 'Channel') == 'Online':
4072
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   877
                    self._stmf_execute('/usr/sbin/stmfadm', 'offline-target',
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   878
                                       target_wwn)
3178
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   879
                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
   880
                    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
   881
                                       target_group)
3178
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   882
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   883
            # Remove the LU
4072
db0cec748ec0 PSARC 2015/110 OpenStack service updates for Juno
Danek Duvall <danek.duvall@oracle.com>
parents: 3178
diff changeset
   884
            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
   885
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   886
    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
   887
        """Get Fibre Channel configuration.
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   888
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   889
        :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
   890
        :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
   891
        :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
   892
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   893
        """
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   894
        wwns = self._get_wwns()
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   895
        if not wwns:
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   896
            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
   897
                     "node names."))
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   898
            raise exception.VolumeBackendAPIException(data=msg)
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   899
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   900
        luid = self._get_luid(volume)
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   901
        if not luid:
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   902
            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
   903
                   % volume['name'])
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   904
            raise exception.VolumeBackendAPIException(data=msg)
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   905
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   906
        properties = {}
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   907
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   908
        properties['target_discovered'] = True
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   909
        properties['target_wwn'] = wwns
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   910
        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
   911
        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
   912
            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
   913
        return properties
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   914
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   915
    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
   916
        """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
   917
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   918
        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
   919
        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
   920
        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
   921
        Example return values:
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   922
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   923
            {
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   924
                'driver_volume_type': 'fibre_channel'
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   925
                'data': {
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   926
                    'target_discovered': True,
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   927
                    'target_lun': 1,
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   928
                    'target_wwn': '1234567890123',
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   929
                }
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   930
            }
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   931
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   932
            or
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   933
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   934
             {
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   935
                'driver_volume_type': 'fibre_channel'
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   936
                'data': {
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   937
                    'target_discovered': True,
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   938
                    'target_lun': 1,
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   939
                    'target_wwn': ['1234567890123', '0987654321321'],
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   940
                }
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
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   943
        """
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   944
        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
   945
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   946
        return {
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   947
            'driver_volume_type': 'fibre_channel',
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   948
            'data': fc_properties
77584387a894 PSARC/2014/207 OpenStack Glance Update to Havana
Drew Fisher <drew.fisher@oracle.com>
parents: 3147
diff changeset
   949
        }