Add connector for GPFS volumes

The Cinder backup manager now uses initiator connectors for
creating and restoring backups for all volume backends, so
this patch adds a connector for GPFS volumes to fix the
backup-create & backup-restore for the GPFS driver.

DocImpact

Change-Id: I49cc52d6df5d0c1b470ced531075d851aa30208d
Implements: blueprint os-brick-gpfs-protocol-support
This commit is contained in:
digvijay2016 2016-08-12 13:40:59 +05:30
parent 5b2030e2b2
commit b815232e8e
5 changed files with 86 additions and 0 deletions

View File

@ -57,3 +57,4 @@ DISCO = "DISCO"
VZSTORAGE = "VZSTORAGE"
SHEEPDOG = "SHEEPDOG"
VMDK = "VMDK"
GPFS = "GPFS"

View File

@ -63,6 +63,7 @@ DRBD = "DRBD"
NFS = "NFS"
GLUSTERFS = "GLUSTERFS"
LOCAL = "LOCAL"
GPFS = "GPFS"
HUAWEISDSHYPERVISOR = "HUAWEISDSHYPERVISOR"
HGST = "HGST"
RBD = "RBD"
@ -85,6 +86,7 @@ connector_list = [
'os_brick.initiator.connectors.remotefs.RemoteFsConnector',
'os_brick.initiator.connectors.rbd.RBDConnector',
'os_brick.initiator.connectors.local.LocalConnector',
'os_brick.initiator.connectors.gpfs.GPFSConnector',
'os_brick.initiator.connectors.drbd.DRBDConnector',
'os_brick.initiator.connectors.huawei.HuaweiStorHyperConnector',
'os_brick.initiator.connectors.hgst.HGSTConnector',
@ -138,6 +140,9 @@ _connector_mapping_linux = {
'os_brick.initiator.connectors.sheepdog.SheepdogConnector',
initiator.VMDK:
'os_brick.initiator.connectors.vmware.VmdkConnector',
initiator.GPFS:
'os_brick.initiator.connectors.gpfs.GPFSConnector',
}
# Mapping for the S390X platform

View File

@ -0,0 +1,41 @@
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from os_brick.i18n import _
from os_brick.initiator.connectors import local
from os_brick import utils
class GPFSConnector(local.LocalConnector):
""""Connector class to attach/detach File System backed volumes."""
@utils.trace
def connect_volume(self, connection_properties):
"""Connect to a volume.
:param connection_properties: The dictionary that describes all
of the target volume attributes.
connection_properties must include:
device_path - path to the volume to be connected
:type connection_properties: dict
:returns: dict
"""
if 'device_path' not in connection_properties:
msg = (_("Invalid connection_properties specified "
"no device_path attribute."))
raise ValueError(msg)
device_info = {'type': 'gpfs',
'path': connection_properties['device_path']}
return device_info

View File

@ -0,0 +1,36 @@
# (c) Copyright 2013 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from os_brick.initiator.connectors import gpfs
from os_brick.tests.initiator.connectors import test_local
class GPFSConnectorTestCase(test_local.LocalConnectorTestCase):
def setUp(self):
super(GPFSConnectorTestCase, self).setUp()
self.connection_properties = {'name': 'foo',
'device_path': '/tmp/bar'}
self.connector = gpfs.GPFSConnector(None)
def test_connect_volume(self):
cprops = self.connection_properties
dev_info = self.connector.connect_volume(cprops)
self.assertEqual(dev_info['type'], 'gpfs')
self.assertEqual(dev_info['path'], cprops['device_path'])
def test_connect_volume_with_invalid_connection_data(self):
cprops = {}
self.assertRaises(ValueError,
self.connector.connect_volume, cprops)

View File

@ -209,6 +209,9 @@ class ConnectorTestCase(test_base.TestCase):
obj = connector.InitiatorConnector.factory('local', None)
self.assertEqual("LocalConnector", obj.__class__.__name__)
obj = connector.InitiatorConnector.factory('gpfs', None)
self.assertEqual("GPFSConnector", obj.__class__.__name__)
obj = connector.InitiatorConnector.factory('huaweisdshypervisor', None)
self.assertEqual("HuaweiStorHyperConnector", obj.__class__.__name__)