Coverage for nova/virt/libvirt/volume/scaleio.py: 100%
31 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-04-24 11:16 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-04-24 11:16 +0000
1# Copyright (c) 2015 EMC Corporation
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
16"""Libvirt volume driver for ScaleIO."""
18from os_brick import initiator
19from os_brick.initiator import connector
20from oslo_log import log as logging
22import nova.conf
23from nova import utils
24from nova.virt.libvirt.volume import volume as libvirt_volume
26LOG = logging.getLogger(__name__)
28CONF = nova.conf.CONF
31class LibvirtScaleIOVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
32 """Class ScaleIO Libvirt volume Driver
34 Implements Libvirt part of volume driver for ScaleIO cinder driver.
35 Uses the ScaleIO connector from the os-brick projects
36 """
38 def __init__(self, host):
39 super(LibvirtScaleIOVolumeDriver, self).__init__(host,
40 is_block_dev=False)
41 self.connector = connector.InitiatorConnector.factory(
42 initiator.SCALEIO, utils.get_root_helper(),
43 device_scan_attempts=CONF.libvirt.num_volume_scan_tries)
45 def get_config(self, connection_info, disk_info):
46 conf = super(LibvirtScaleIOVolumeDriver, self).get_config(
47 connection_info, disk_info)
49 conf.source_type = 'block'
50 conf.source_path = connection_info['data']['device_path']
51 conf.driver_io = "native"
52 return conf
54 def connect_volume(self, connection_info, instance):
55 device_info = self.connector.connect_volume(connection_info['data'])
56 LOG.debug("Attached ScaleIO volume %s.", device_info,
57 instance=instance)
58 connection_info['data']['device_path'] = device_info['path']
60 def disconnect_volume(self, connection_info, instance, force=False):
61 self.connector.disconnect_volume(
62 connection_info['data'], None, force=force)
63 LOG.debug("Disconnected volume", instance=instance)
65 super(LibvirtScaleIOVolumeDriver, self).disconnect_volume(
66 connection_info, instance, force=force)
68 def extend_volume(self, connection_info, instance, requested_size):
69 LOG.debug("calling os-brick to extend ScaleIO Volume",
70 instance=instance)
71 new_size = self.connector.extend_volume(connection_info['data'])
72 LOG.debug("Extend ScaleIO Volume %s; new_size=%s",
73 connection_info['data']['device_path'],
74 new_size, instance=instance)
75 return new_size