1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
3
# Copyright (c) 2013 Huawei Technologies Co., Ltd.
4
# Copyright (c) 2013 OpenStack LLC.
7
# Licensed under the Apache License, Version 2.0 (the "License"); you may
8
# not use this file except in compliance with the License. You may obtain
9
# a copy of the License at
11
# http://www.apache.org/licenses/LICENSE-2.0
13
# Unless required by applicable law or agreed to in writing, software
14
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
# License for the specific language governing permissions and limitations
19
Volume Drivers for Huawei OceanStor HVS storage arrays.
22
from cinder.volume import driver
23
from cinder.volume.drivers.huawei.rest_common import HVSCommon
26
class HuaweiHVSISCSIDriver(driver.ISCSIDriver):
27
"""ISCSI driver for Huawei OceanStor HVS storage arrays."""
31
def __init__(self, *args, **kwargs):
32
super(HuaweiHVSISCSIDriver, self).__init__(*args, **kwargs)
34
def do_setup(self, context):
35
"""Instantiate common class and log in storage system."""
36
self.common = HVSCommon(configuration=self.configuration)
39
def check_for_setup_error(self):
40
"""Check configuration file."""
41
self.common._check_conf_file()
43
def create_volume(self, volume):
44
"""Create a volume."""
45
self.common.create_volume(volume)
47
def create_volume_from_snapshot(self, volume, snapshot):
48
"""Create a volume from a snapshot."""
49
self.common.create_volume_from_snapshot(volume, snapshot)
51
def create_cloned_volume(self, volume, src_vref):
52
"""Create a clone of the specified volume."""
53
self.common.create_cloned_volume(volume, src_vref)
55
def delete_volume(self, volume):
56
"""Delete a volume."""
57
self.common.delete_volume(volume)
59
def create_snapshot(self, snapshot):
60
"""Create a snapshot."""
61
self.common.create_snapshot(snapshot)
63
def delete_snapshot(self, snapshot):
64
"""Delete a snapshot."""
65
self.common.delete_snapshot(snapshot)
67
def get_volume_stats(self, refresh=False):
68
"""Get volume stats."""
69
data = self.common.update_volume_stats(refresh)
70
backend_name = self.configuration.safe_get('volume_backend_name')
71
data['volume_backend_name'] = backend_name or self.__class__.__name__
72
data['storage_protocol'] = 'iSCSI'
73
data['driver_version'] = self.VERSION
76
def initialize_connection(self, volume, connector):
77
"""Map a volume to a host."""
78
return self.common.initialize_connection_iscsi(volume, connector)
80
def terminate_connection(self, volume, connector, **kwargs):
81
"""Terminate the map."""
82
self.common.terminate_connection(volume, connector, **kwargs)
84
def create_export(self, context, volume):
85
"""Export the volume."""
88
def ensure_export(self, context, volume):
89
"""Synchronously recreate an export for a volume."""
92
def remove_export(self, context, volume):
93
"""Remove an export for a volume."""
97
class HuaweiHVSFCDriver(driver.FibreChannelDriver):
98
"""FC driver for Huawei OceanStor HVS storage arrays."""
102
def __init__(self, *args, **kwargs):
103
super(HuaweiHVSFCDriver, self).__init__(*args, **kwargs)
105
def do_setup(self, context):
106
"""Instantiate common class and log in storage system."""
107
self.common = HVSCommon(configuration=self.configuration)
110
def check_for_setup_error(self):
111
"""Check configuration file."""
112
self.common._check_conf_file()
114
def create_volume(self, volume):
115
"""Create a volume."""
116
self.common.create_volume(volume)
118
def create_volume_from_snapshot(self, volume, snapshot):
119
"""Create a volume from a snapshot."""
120
self.common.create_volume_from_snapshot(volume, snapshot)
122
def create_cloned_volume(self, volume, src_vref):
123
"""Create a clone of the specified volume."""
124
self.common.create_cloned_volume(volume, src_vref)
126
def delete_volume(self, volume):
127
"""Delete a volume."""
128
self.common.delete_volume(volume)
130
def create_snapshot(self, snapshot):
131
"""Create a snapshot."""
132
self.common.create_snapshot(snapshot)
134
def delete_snapshot(self, snapshot):
135
"""Delete a snapshot."""
136
self.common.delete_snapshot(snapshot)
138
def get_volume_stats(self, refresh=False):
139
"""Get volume stats."""
140
data = self.common.update_volume_stats(refresh)
141
backend_name = self.configuration.safe_get('volume_backend_name')
142
data['volume_backend_name'] = backend_name or self.__class__.__name__
143
data['storage_protocol'] = 'FC'
144
data['driver_version'] = self.VERSION
147
def initialize_connection(self, volume, connector):
148
"""Map a volume to a host."""
149
return self.common.initialize_connection_fc(volume, connector)
151
def terminate_connection(self, volume, connector, **kwargs):
152
"""Terminate the map."""
153
self.common.terminate_connection(volume, connector, **kwargs)
155
def create_export(self, context, volume):
156
"""Export the volume."""
159
def ensure_export(self, context, volume):
160
"""Synchronously recreate an export for a volume."""
163
def remove_export(self, context, volume):
164
"""Remove an export for a volume."""