diff --git a/os_brick/initiator/__init__.py b/os_brick/initiator/__init__.py index 5cd418d33..95e0b1002 100644 --- a/os_brick/initiator/__init__.py +++ b/os_brick/initiator/__init__.py @@ -57,3 +57,4 @@ DISCO = "DISCO" VZSTORAGE = "VZSTORAGE" SHEEPDOG = "SHEEPDOG" VMDK = "VMDK" +GPFS = "GPFS" diff --git a/os_brick/initiator/connector.py b/os_brick/initiator/connector.py index 3922e7d58..8036e597f 100644 --- a/os_brick/initiator/connector.py +++ b/os_brick/initiator/connector.py @@ -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 diff --git a/os_brick/initiator/connectors/gpfs.py b/os_brick/initiator/connectors/gpfs.py new file mode 100644 index 000000000..014fff8e3 --- /dev/null +++ b/os_brick/initiator/connectors/gpfs.py @@ -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 diff --git a/os_brick/tests/initiator/connectors/test_gpfs.py b/os_brick/tests/initiator/connectors/test_gpfs.py new file mode 100644 index 000000000..5c91aaf41 --- /dev/null +++ b/os_brick/tests/initiator/connectors/test_gpfs.py @@ -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) diff --git a/os_brick/tests/initiator/test_connector.py b/os_brick/tests/initiator/test_connector.py index 7ad4b0bdf..6739f9caa 100644 --- a/os_brick/tests/initiator/test_connector.py +++ b/os_brick/tests/initiator/test_connector.py @@ -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__)