Refactoring of VolumeTypeSettings to extend VolumeTypeConfig 35/47435/2
authorspisarski <s.pisarski@cablelabs.com>
Fri, 17 Nov 2017 21:05:29 +0000 (14:05 -0700)
committerspisarski <s.pisarski@cablelabs.com>
Mon, 20 Nov 2017 17:12:59 +0000 (10:12 -0700)
This also includes VolumeTypeEncryptionSettings extending to
VolumeTypeEncryptionConfig which is a member of VolumeTypeConfig
VolumeTypeSettings and cinder_utils have a runtime cyclical
dependency. This patch reduces this dependency and
deprecates the VolumeTypeSettings class.

JIRA: SNAPS-228

Change-Id: Iaa9c7a1cd810cf63d1badb00f71bcdcefb527e12
Signed-off-by: spisarski <s.pisarski@cablelabs.com>
13 files changed:
docs/how-to-use/LibraryUsage.rst
docs/how-to-use/UnitTests.rst
examples/launch.py
snaps/config/tests/volume_type_tests.py [new file with mode: 0644]
snaps/config/volume_type.py [new file with mode: 0644]
snaps/openstack/create_stack.py
snaps/openstack/create_volume_type.py
snaps/openstack/tests/create_volume_tests.py
snaps/openstack/tests/create_volume_type_tests.py
snaps/openstack/utils/settings_utils.py
snaps/openstack/utils/tests/cinder_utils_tests.py
snaps/openstack/utils/tests/settings_utils_tests.py
snaps/test_suite_builder.py

index d7f3177..8e2a330 100644 (file)
@@ -451,19 +451,20 @@ Create Volume Type
 
 -  Volume Type - snaps.openstack.create\_volume\_type.OpenStackVolumeType
 
-   -  snaps.openstack.create\_volume\_type.VolumeTypeSettings
+   -  snaps.config.volume\_type.VolumeTypeConfig
 
       -  name - the volume type's name (required)
       -  description - the volume type's description (optional)
-      -  encryption - instance or config for VolumeTypeEncryptionSettings (optional)
+      -  encryption - instance or config for VolumeTypeEncryptionConfig (optional)
       -  qos\_spec\_name - name of the QoS Spec to associate (optional)
-      -  public - instance or config for VolumeTypeEncryptionSettings (optional)
+      -  public - instance or config for VolumeTypeEncryptionConfig (optional)
 
 .. code:: python
 
-    from snaps.openstack.create_volume_type import VolumeTypeSettings, OpenStackVolumeType
+    from snaps.config.volume_type import VolumeTypeConfig
+    from snaps.openstack.create_volume_type import OpenStackVolumeType
 
-    vol_type_settings = VolumeTypeSettings(name='stack-name')
+    vol_type_settings = VolumeTypeConfig(name='stack-name')
     vol_type_creator = OpenStackHeatStack(os_creds, vol_type_settings)
     vol_type_creator.create()
 
index bc5515b..74404fa 100644 (file)
@@ -276,11 +276,17 @@ VolumeDomainObjectTests
 Ensures that all required members are included when constructing a
 Volume domain object (for Cinder)
 
+VolumeTypeConfigUnitTests
+-------------------------
+
+Ensures that all required members are included when constructing a
+VolumeTypeConfig object
+
 VolumeTypeSettingsUnitTests
 ---------------------------
 
 Ensures that all required members are included when constructing a
-VolumeTypeSettings object
+deprecated VolumeTypeSettings object
 
 VolumeTypeDomainObjectTests
 ---------------------------
index b0e87ba..35ebaf7 100644 (file)
@@ -26,6 +26,7 @@ import os
 import yaml
 
 from snaps import file_utils
+from snaps.config.volume_type import VolumeTypeConfig
 from snaps.config.flavor import FlavorConfig
 from snaps.config.image import ImageConfig
 from snaps.config.keypair import KeypairConfig
@@ -46,8 +47,7 @@ from snaps.openstack.create_security_group import (
     OpenStackSecurityGroup, SecurityGroupSettings)
 from snaps.openstack.create_user import OpenStackUser
 from snaps.openstack.create_volume import OpenStackVolume, VolumeSettings
-from snaps.openstack.create_volume_type import (
-    OpenStackVolumeType, VolumeTypeSettings)
+from snaps.openstack.create_volume_type import OpenStackVolumeType
 from snaps.openstack.os_credentials import OSCreds, ProxySettings
 from snaps.openstack.utils import deploy_utils
 from snaps.provisioning import ansible_utils
@@ -653,7 +653,7 @@ def main(arguments):
 
                 # Create volume types
                 vol_type_dict = __create_instances(
-                    os_creds_dict, OpenStackVolumeType, VolumeTypeSettings,
+                    os_creds_dict, OpenStackVolumeType, VolumeTypeConfig,
                     os_config.get('volume_types'), 'volume_type', clean,
                     users_dict)
                 creators.append(vol_type_dict)
diff --git a/snaps/config/tests/volume_type_tests.py b/snaps/config/tests/volume_type_tests.py
new file mode 100644 (file)
index 0000000..7b4fb1b
--- /dev/null
@@ -0,0 +1,91 @@
+# Copyright (c) 2017 Cable Television Laboratories, Inc. ("CableLabs")
+#                    and others.  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.
+import unittest
+
+from snaps.config.volume_type import (
+    VolumeTypeConfig,  VolumeTypeEncryptionConfig, ControlLocation,
+    VolumeTypeConfigError)
+
+
+class VolumeTypeConfigUnitTests(unittest.TestCase):
+    """
+    Tests the construction of the VolumeTypeConfig class
+    """
+
+    def test_no_params(self):
+        with self.assertRaises(VolumeTypeConfigError):
+            VolumeTypeConfig()
+
+    def test_empty_config(self):
+        with self.assertRaises(VolumeTypeConfigError):
+            VolumeTypeConfig(**dict())
+
+    def test_name_only(self):
+        settings = VolumeTypeConfig(name='foo')
+        self.assertEqual('foo', settings.name)
+        self.assertIsNone(settings.description)
+        self.assertIsNone(settings.qos_spec_name)
+        self.assertIsNone(settings.encryption)
+        self.assertFalse(settings.public)
+
+    def test_config_with_name_only(self):
+        settings = VolumeTypeConfig(**{'name': 'foo'})
+        self.assertEqual('foo', settings.name)
+        self.assertIsNone(settings.description)
+        self.assertIsNone(settings.qos_spec_name)
+        self.assertIsNone(settings.encryption)
+        self.assertFalse(settings.public)
+
+    def test_all(self):
+        encryption_settings = VolumeTypeEncryptionConfig(
+            name='foo', provider_class='bar',
+            control_location=ControlLocation.back_end)
+        settings = VolumeTypeConfig(
+            name='foo', description='desc', encryption=encryption_settings,
+            qos_spec_name='spec_name', public=True)
+        self.assertEqual('foo', settings.name)
+        self.assertEqual('desc', settings.description)
+        self.assertEqual('spec_name', settings.qos_spec_name)
+        self.assertEqual(encryption_settings, settings.encryption)
+        self.assertTrue(True, settings.public)
+
+    def test_all_string(self):
+        encryption_settings = {
+            'name': 'foo', 'provider_class': 'bar',
+            'control_location': 'back-end'}
+        settings = VolumeTypeConfig(
+            name='foo', description='desc', encryption=encryption_settings,
+            qos_spec_name='spec_name', public='true')
+        self.assertEqual('foo', settings.name)
+        self.assertEqual('desc', settings.description)
+        self.assertEqual('spec_name', settings.qos_spec_name)
+        self.assertEqual(VolumeTypeEncryptionConfig(**encryption_settings),
+                         settings.encryption)
+        self.assertTrue(settings.public)
+
+    def test_config_all(self):
+        encryption_settings = {
+            'name': 'foo', 'provider_class': 'bar',
+            'control_location': 'back-end'}
+        settings = VolumeTypeConfig(
+            **{'name': 'foo', 'description': 'desc',
+               'encryption': encryption_settings,
+               'qos_spec_name': 'spec_name', 'public': 'false'})
+        self.assertEqual('foo', settings.name)
+        self.assertEqual('desc', settings.description)
+        self.assertEqual('spec_name', settings.qos_spec_name)
+        self.assertEqual(VolumeTypeEncryptionConfig(**encryption_settings),
+                         settings.encryption)
+        self.assertFalse(settings.public)
diff --git a/snaps/config/volume_type.py b/snaps/config/volume_type.py
new file mode 100644 (file)
index 0000000..35ca1d4
--- /dev/null
@@ -0,0 +1,146 @@
+# Copyright (c) 2017 Cable Television Laboratories, Inc. ("CableLabs")
+#                    and others.  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.
+import enum
+from neutronclient.common.utils import str2bool
+
+
+class VolumeTypeConfig(object):
+    def __init__(self, **kwargs):
+        """
+        Constructor
+        :param name: the volume's name (required)
+        :param description: the volume's name (optional)
+        :param encryption: VolumeTypeEncryptionConfig (optional)
+        :param qos_spec_name: name of the QoS Spec to associate (optional)
+        :param public: volume visibility where True denotes global
+                       (default - False)
+
+        TODO - Implement project_access parameter that will associate this
+        VolumeType to a list of project names
+        """
+
+        self.name = kwargs.get('name')
+        self.description = kwargs.get('description')
+        self.qos_spec_name = kwargs.get('qos_spec_name')
+
+        if 'encryption' in kwargs:
+            if isinstance(kwargs['encryption'], dict):
+                self.encryption = VolumeTypeEncryptionConfig(
+                    **kwargs['encryption'])
+            elif isinstance(kwargs['encryption'],
+                            VolumeTypeEncryptionConfig):
+                self.encryption = kwargs['encryption']
+        else:
+            self.encryption = None
+
+        if 'public' in kwargs:
+            if isinstance(kwargs['public'], str):
+                self.public = str2bool(kwargs['public'])
+            else:
+                self.public = kwargs['public']
+        else:
+            self.public = False
+
+        if not self.name:
+            raise VolumeTypeConfigError("The attribute name is required")
+
+    def __eq__(self, other):
+        return (self.name == other.name
+                and self.description == other.description
+                and self.qos_spec_name == other.qos_spec_name
+                and self.encryption == other.encryption
+                and self.public == other.public)
+
+
+class ControlLocation(enum.Enum):
+    """
+    QoS Specification consumer types
+    """
+    front_end = 'front-end'
+    back_end = 'back-end'
+
+
+class VolumeTypeEncryptionConfig(object):
+    def __init__(self, **kwargs):
+        """
+        Constructor
+        :param name: the volume's name (required)
+        :param provider_class: the volume's provider class (e.g. LuksEncryptor)
+        :param control_location: the notional service where encryption is
+                                 performed (e.g., front-end=Nova). The default
+                                 value is 'front-end.'
+        :param cipher: the encryption algorithm/mode to use
+                       (e.g., aes-xts-plain64). If the field is left empty,
+                       the provider default will be used
+        :param key_size: the size of the encryption key, in bits
+                         (e.g., 128, 256). If the field is left empty, the
+                         provider default will be used
+        """
+
+        self.name = kwargs.get('name')
+        self.provider_class = kwargs.get('provider_class')
+        self.control_location = kwargs.get('control_location')
+        if kwargs.get('control_location'):
+            self.control_location = map_control_location(
+                kwargs['control_location'])
+        else:
+            self.control_location = None
+
+        self.cipher = kwargs.get('cipher')
+        self.key_size = kwargs.get('key_size')
+
+        if (not self.name or not self.provider_class
+                or not self.control_location):
+            raise VolumeTypeConfigError(
+                'The attributes name, provider_class, and control_location '
+                'are required')
+
+    def __eq__(self, other):
+        return (self.name == other.name
+                and self.provider_class == other.provider_class
+                and self.control_location == other.control_location
+                and self.cipher == other.cipher
+                and self.key_size == other.key_size)
+
+
+def map_control_location(control_location):
+    """
+    Takes a the protocol value maps it to the Consumer enum. When None return
+    None
+    :param control_location: the value to map to the Enum
+    :return: a ControlLocation enum object
+    :raise: Exception if control_location parameter is invalid
+    """
+    if not control_location:
+        return None
+    elif isinstance(control_location, ControlLocation):
+        return control_location
+    else:
+        proto_str = str(control_location)
+        if proto_str == 'front-end':
+            return ControlLocation.front_end
+        elif proto_str == 'back-end':
+            return ControlLocation.back_end
+        else:
+            raise VolumeTypeConfigError('Invalid Consumer - ' + proto_str)
+
+
+class VolumeTypeConfigError(Exception):
+    """
+    Exception to be thrown when an volume settings are incorrect
+    """
+
+    def __init__(self, message):
+        Exception.__init__(self, message)
index 33e0106..25fe686 100644 (file)
@@ -348,7 +348,7 @@ class OpenStackHeatStack(OpenStackCloudObject, object):
             self.__heat_cli, cinder, self.__stack)
 
         for volume in vol_types:
-            settings = settings_utils.create_volume_type_settings(volume)
+            settings = settings_utils.create_volume_type_config(volume)
             creator = OpenStackVolumeType(self._os_creds, settings)
             out.append(creator)
 
index fe20c40..a7198d8 100644 (file)
 
 import logging
 
-import enum
 from cinderclient.exceptions import NotFound
-from neutronclient.common.utils import str2bool
 
+from snaps.config.volume_type import (
+    VolumeTypeConfig,  VolumeTypeEncryptionConfig)
 from snaps.openstack.openstack_creator import OpenStackVolumeObject
 from snaps.openstack.utils import cinder_utils
 
@@ -96,134 +96,32 @@ class OpenStackVolumeType(OpenStackVolumeObject):
         return self.__volume_type
 
 
-class VolumeTypeSettings:
-    def __init__(self, **kwargs):
-        """
-        Constructor
-        :param name: the volume's name (required)
-        :param description: the volume's name (optional)
-        :param encryption: VolumeTypeEncryptionSettings (optional)
-        :param qos_spec_name: name of the QoS Spec to associate (optional)
-        :param public: volume visibility where True denotes global
-                       (default - False)
-
-        TODO - Implement project_access parameter that will associate this
-        VolumeType to a list of project names
-        """
-
-        self.name = kwargs.get('name')
-        self.description = kwargs.get('description')
-        self.qos_spec_name = kwargs.get('qos_spec_name')
-
-        if 'encryption' in kwargs:
-            if isinstance(kwargs['encryption'], dict):
-                self.encryption = VolumeTypeEncryptionSettings(
-                    **kwargs['encryption'])
-            elif isinstance(kwargs['encryption'],
-                            VolumeTypeEncryptionSettings):
-                self.encryption = kwargs['encryption']
-        else:
-            self.encryption = None
-
-        if 'public' in kwargs:
-            if isinstance(kwargs['public'], str):
-                self.public = str2bool(kwargs['public'])
-            else:
-                self.public = kwargs['public']
-        else:
-            self.public = False
-
-        if not self.name:
-            raise VolumeTypeSettingsError("The attribute name is required")
-
-    def __eq__(self, other):
-        return (self.name == other.name
-                and self.description == other.description
-                and self.qos_spec_name == other.qos_spec_name
-                and self.encryption == other.encryption
-                and self.public == other.public)
-
-
-class ControlLocation(enum.Enum):
+class VolumeTypeSettings(VolumeTypeConfig):
     """
-    QoS Specification consumer types
+    Class to hold the configuration settings required for creating OpenStack
+    Volume Type objects
+    deprecated
     """
-    front_end = 'front-end'
-    back_end = 'back-end'
-
 
-class VolumeTypeEncryptionSettings:
     def __init__(self, **kwargs):
-        """
-        Constructor
-        :param name: the volume's name (required)
-        :param provider_class: the volume's provider class (e.g. LuksEncryptor)
-        :param control_location: the notional service where encryption is
-                                 performed (e.g., front-end=Nova). The default
-                                 value is 'front-end.'
-        :param cipher: the encryption algorithm/mode to use
-                       (e.g., aes-xts-plain64). If the field is left empty,
-                       the provider default will be used
-        :param key_size: the size of the encryption key, in bits
-                         (e.g., 128, 256). If the field is left empty, the
-                         provider default will be used
-        """
+        from warnings import warn
+        warn('Use snaps.config.volume_type.VolumeTypeConfig instead',
+             DeprecationWarning)
+        super(self.__class__, self).__init__(**kwargs)
 
-        self.name = kwargs.get('name')
-        self.provider_class = kwargs.get('provider_class')
-        self.control_location = kwargs.get('control_location')
-        if kwargs.get('control_location'):
-            self.control_location = map_control_location(
-                kwargs['control_location'])
-        else:
-            self.control_location = None
-
-        self.cipher = kwargs.get('cipher')
-        self.key_size = kwargs.get('key_size')
-
-        if (not self.name or not self.provider_class
-                or not self.control_location):
-            raise VolumeTypeSettingsError(
-                'The attributes name, provider_class, and control_location '
-                'are required')
-
-    def __eq__(self, other):
-        return (self.name == other.name
-                and self.provider_class == other.provider_class
-                and self.control_location == other.control_location
-                and self.cipher == other.cipher
-                and self.key_size == other.key_size)
-
-
-def map_control_location(control_location):
-    """
-    Takes a the protocol value maps it to the Consumer enum. When None return
-    None
-    :param control_location: the value to map to the Enum
-    :return: a ControlLocation enum object
-    :raise: Exception if control_location parameter is invalid
-    """
-    if not control_location:
-        return None
-    elif isinstance(control_location, ControlLocation):
-        return control_location
-    else:
-        proto_str = str(control_location)
-        if proto_str == 'front-end':
-            return ControlLocation.front_end
-        elif proto_str == 'back-end':
-            return ControlLocation.back_end
-        else:
-            raise VolumeTypeSettingsError('Invalid Consumer - ' + proto_str)
-
-
-class VolumeTypeSettingsError(Exception):
+
+class VolumeTypeEncryptionSettings(VolumeTypeEncryptionConfig):
     """
-    Exception to be thrown when an volume settings are incorrect
+    Class to hold the configuration settings required for creating OpenStack
+    Volume Type Encryption objects
+    deprecated
     """
 
-    def __init__(self, message):
-        Exception.__init__(self, message)
+    def __init__(self, **kwargs):
+        from warnings import warn
+        warn('Use snaps.config.volume_type.VolumeTypeEncryptionConfig instead',
+             DeprecationWarning)
+        super(self.__class__, self).__init__(**kwargs)
 
 
 class VolumeTypeCreationError(Exception):
index 9c3f90f..91b52b1 100644 (file)
@@ -14,9 +14,9 @@
 # limitations under the License.
 from cinderclient.exceptions import NotFound, BadRequest
 
+from snaps.config.volume_type import VolumeTypeConfig
 from snaps.openstack.create_image import OpenStackImage
-from snaps.openstack.create_volume_type import (
-    VolumeTypeSettings, OpenStackVolumeType)
+from snaps.openstack.create_volume_type import OpenStackVolumeType
 from snaps.openstack.tests import openstack_tests
 
 try:
@@ -303,7 +303,7 @@ class CreateVolumeWithTypeTests(OSIntegrationTestCase):
         self.volume_type_name = guid + '-vol-type'
 
         self.volume_type_creator = OpenStackVolumeType(
-            self.os_creds, VolumeTypeSettings(name=self.volume_type_name))
+            self.os_creds, VolumeTypeConfig(name=self.volume_type_name))
         self.volume_type_creator.create()
         self.volume_creator = None
 
index 8bff91f..70c40cc 100644 (file)
@@ -12,6 +12,9 @@
 # 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 snaps.config.volume_type import (
+    VolumeTypeConfig, VolumeTypeEncryptionConfig, VolumeTypeConfigError,
+    ControlLocation)
 from snaps.config.qos import QoSConfig, Consumer
 from snaps.openstack.create_qos import OpenStackQoS
 
@@ -24,9 +27,9 @@ import logging
 import unittest
 import uuid
 
+from snaps.openstack import create_volume_type
 from snaps.openstack.create_volume_type import (
-    VolumeTypeSettings, VolumeTypeSettingsError, VolumeTypeEncryptionSettings,
-    ControlLocation, OpenStackVolumeType)
+    VolumeTypeSettings, VolumeTypeEncryptionSettings)
 from snaps.openstack.tests.os_source_file_test import OSIntegrationTestCase
 from snaps.openstack.utils import cinder_utils
 
@@ -41,11 +44,11 @@ class VolumeTypeSettingsUnitTests(unittest.TestCase):
     """
 
     def test_no_params(self):
-        with self.assertRaises(VolumeTypeSettingsError):
+        with self.assertRaises(VolumeTypeConfigError):
             VolumeTypeSettings()
 
     def test_empty_config(self):
-        with self.assertRaises(VolumeTypeSettingsError):
+        with self.assertRaises(VolumeTypeConfigError):
             VolumeTypeSettings(**dict())
 
     def test_name_only(self):
@@ -121,7 +124,7 @@ class CreateSimpleVolumeTypeSuccessTests(OSIntegrationTestCase):
         super(self.__class__, self).__start__()
 
         guid = uuid.uuid4()
-        self.volume_type_settings = VolumeTypeSettings(
+        self.volume_type_settings = VolumeTypeConfig(
             name=self.__class__.__name__ + '-' + str(guid))
 
         self.cinder = cinder_utils.cinder_client(self.os_creds)
@@ -141,7 +144,7 @@ class CreateSimpleVolumeTypeSuccessTests(OSIntegrationTestCase):
         Tests the creation of an OpenStack volume.
         """
         # Create VolumeType
-        self.volume_type_creator = OpenStackVolumeType(
+        self.volume_type_creator = create_volume_type.OpenStackVolumeType(
             self.os_creds, self.volume_type_settings)
         created_volume_type = self.volume_type_creator.create()
         self.assertIsNotNone(created_volume_type)
@@ -163,7 +166,7 @@ class CreateSimpleVolumeTypeSuccessTests(OSIntegrationTestCase):
         clean() does not raise an Exception.
         """
         # Create VolumeType
-        self.volume_type_creator = OpenStackVolumeType(
+        self.volume_type_creator = create_volume_type.OpenStackVolumeType(
             self.os_creds, self.volume_type_settings)
         created_volume_type = self.volume_type_creator.create()
         self.assertIsNotNone(created_volume_type)
@@ -189,7 +192,7 @@ class CreateSimpleVolumeTypeSuccessTests(OSIntegrationTestCase):
         Tests the creation of an OpenStack volume_type when one already exists.
         """
         # Create VolumeType
-        self.volume_type_creator = OpenStackVolumeType(
+        self.volume_type_creator = create_volume_type.OpenStackVolumeType(
             self.os_creds, self.volume_type_settings)
         volume_type1 = self.volume_type_creator.create()
 
@@ -198,7 +201,7 @@ class CreateSimpleVolumeTypeSuccessTests(OSIntegrationTestCase):
         self.assertEqual(volume_type1, retrieved_volume_type)
 
         # Should be retrieving the instance data
-        os_volume_type_2 = OpenStackVolumeType(
+        os_volume_type_2 = create_volume_type.OpenStackVolumeType(
             self.os_creds, self.volume_type_settings)
         volume_type2 = os_volume_type_2.create()
         self.assertEqual(volume_type2, volume_type2)
@@ -238,9 +241,9 @@ class CreateVolumeTypeComplexTests(OSIntegrationTestCase):
         """
         Creates a Volume Type object with an associated QoS Spec
         """
-        self.volume_type_creator = OpenStackVolumeType(
+        self.volume_type_creator = create_volume_type.OpenStackVolumeType(
             self.os_creds,
-            VolumeTypeSettings(
+            VolumeTypeConfig(
                 name=self.volume_type_name,
                 qos_spec_name=self.qos_creator.qos_settings.name))
 
@@ -264,12 +267,12 @@ class CreateVolumeTypeComplexTests(OSIntegrationTestCase):
         """
         Creates a Volume Type object with encryption
         """
-        encryption_settings = VolumeTypeEncryptionSettings(
+        encryption_settings = VolumeTypeEncryptionConfig(
             name='foo', provider_class='bar',
             control_location=ControlLocation.back_end)
-        self.volume_type_creator = OpenStackVolumeType(
+        self.volume_type_creator = create_volume_type.OpenStackVolumeType(
             self.os_creds,
-            VolumeTypeSettings(
+            VolumeTypeConfig(
                 name=self.volume_type_name,
                 encryption=encryption_settings))
 
@@ -293,12 +296,12 @@ class CreateVolumeTypeComplexTests(OSIntegrationTestCase):
         """
         Creates a Volume Type object with encryption and an associated QoS Spec
         """
-        encryption_settings = VolumeTypeEncryptionSettings(
+        encryption_settings = VolumeTypeEncryptionConfig(
             name='foo', provider_class='bar',
             control_location=ControlLocation.back_end)
-        self.volume_type_creator = OpenStackVolumeType(
+        self.volume_type_creator = create_volume_type.OpenStackVolumeType(
             self.os_creds,
-            VolumeTypeSettings(
+            VolumeTypeConfig(
                 name=self.volume_type_name,
                 encryption=encryption_settings,
                 qos_spec_name=self.qos_creator.qos_settings.name))
index e85bd08..c4714cc 100644 (file)
@@ -15,6 +15,8 @@
 import uuid
 
 from snaps import file_utils
+from snaps.config.volume_type import (
+    ControlLocation,  VolumeTypeEncryptionConfig, VolumeTypeConfig)
 from snaps.config.flavor import FlavorConfig
 from snaps.config.keypair import KeypairConfig
 from snaps.config.router import RouterConfig
@@ -25,8 +27,6 @@ from snaps.openstack.create_network import (
 from snaps.openstack.create_security_group import (
     SecurityGroupSettings, SecurityGroupRuleSettings)
 from snaps.openstack.create_volume import VolumeSettings
-from snaps.openstack.create_volume_type import (
-    VolumeTypeSettings, VolumeTypeEncryptionSettings, ControlLocation)
 from snaps.openstack.utils import (
     neutron_utils, nova_utils, heat_utils, glance_utils)
 
@@ -161,7 +161,7 @@ def create_volume_settings(volume):
         multi_attach=volume.multi_attach)
 
 
-def create_volume_type_settings(volume_type):
+def create_volume_type_config(volume_type):
     """
     Returns a VolumeTypeSettings object
     :param volume_type: a SNAPS-OO VolumeType object
@@ -175,7 +175,7 @@ def create_volume_type_settings(volume_type):
         else:
             control = ControlLocation.back_end
 
-    encrypt_settings = VolumeTypeEncryptionSettings(
+    encrypt_settings = VolumeTypeEncryptionConfig(
         name=volume_type.encryption.__class__,
         provider_class=volume_type.encryption.provider,
         control_location=control,
@@ -186,7 +186,7 @@ def create_volume_type_settings(volume_type):
     if volume_type.qos_spec:
         qos_spec_name = volume_type.qos_spec.name
 
-    return VolumeTypeSettings(
+    return VolumeTypeConfig(
         name=volume_type.name, encryption=encrypt_settings,
         qos_spec_name=qos_spec_name, public=volume_type.public)
 
index 547a6f9..e8c31db 100644 (file)
@@ -18,11 +18,11 @@ import uuid
 import time
 from cinderclient.exceptions import NotFound, BadRequest
 
+from snaps.config.volume_type import (
+    VolumeTypeConfig, ControlLocation, VolumeTypeEncryptionConfig)
 from snaps.config.qos import Consumer, QoSConfig
 from snaps.openstack import create_volume
 from snaps.openstack.create_volume import VolumeSettings
-from snaps.openstack.create_volume_type import (
-    VolumeTypeSettings, VolumeTypeEncryptionSettings, ControlLocation)
 from snaps.openstack.tests import validation_utils
 from snaps.openstack.tests.os_source_file_test import OSComponentTestCase
 from snaps.openstack.utils import cinder_utils
@@ -275,7 +275,7 @@ class CinderUtilsSimpleVolumeTypeTests(OSComponentTestCase):
         """
         guid = uuid.uuid4()
         volume_type_name = self.__class__.__name__ + '-' + str(guid)
-        self.volume_type_settings = VolumeTypeSettings(name=volume_type_name)
+        self.volume_type_settings = VolumeTypeConfig(name=volume_type_name)
         self.volume_type = None
         self.cinder = cinder_utils.cinder_client(self.os_creds)
 
@@ -349,7 +349,7 @@ class CinderUtilsAddEncryptionTests(OSComponentTestCase):
 
         volume_type_name = self.__class__.__name__ + '-' + str(guid) + '-type'
         self.volume_type = cinder_utils.create_volume_type(
-            self.cinder, VolumeTypeSettings(name=volume_type_name))
+            self.cinder, VolumeTypeConfig(name=volume_type_name))
 
     def tearDown(self):
         """
@@ -373,7 +373,7 @@ class CinderUtilsAddEncryptionTests(OSComponentTestCase):
         Tests the cinder_utils.create_volume_encryption(),
         get_volume_encryption(), and get_volume_encryption_by_id()
         """
-        encryption_settings = VolumeTypeEncryptionSettings(
+        encryption_settings = VolumeTypeEncryptionConfig(
             name=self.encryption_name, provider_class='foo',
             control_location=ControlLocation.front_end)
         self.encryption = cinder_utils.create_volume_encryption(
@@ -391,7 +391,7 @@ class CinderUtilsAddEncryptionTests(OSComponentTestCase):
         """
         Primarily tests the cinder_utils.delete_volume_type_encryption()
         """
-        encryption_settings = VolumeTypeEncryptionSettings(
+        encryption_settings = VolumeTypeEncryptionConfig(
             name=self.encryption_name, provider_class='LuksEncryptor',
             control_location=ControlLocation.back_end)
         self.encryption = cinder_utils.create_volume_encryption(
@@ -417,7 +417,7 @@ class CinderUtilsAddEncryptionTests(OSComponentTestCase):
         Tests the cinder_utils.create_volume_encryption() with all valid
         settings
         """
-        encryption_settings = VolumeTypeEncryptionSettings(
+        encryption_settings = VolumeTypeEncryptionConfig(
             name=self.encryption_name, provider_class='foo',
             cipher='bar', control_location=ControlLocation.back_end,
             key_size=1)
@@ -439,7 +439,7 @@ class CinderUtilsAddEncryptionTests(OSComponentTestCase):
         Tests the cinder_utils.create_volume_encryption() raises an exception
         when the provider class does not exist
         """
-        encryption_settings = VolumeTypeEncryptionSettings(
+        encryption_settings = VolumeTypeEncryptionConfig(
             name=self.encryption_name, provider_class='foo',
             cipher='bar', control_location=ControlLocation.back_end,
             key_size=-1)
@@ -495,10 +495,10 @@ class CinderUtilsVolumeTypeCompleteTests(OSComponentTestCase):
         Tests the cinder_utils.create_volume_type() where encryption has been
         configured
         """
-        encryption_settings = VolumeTypeEncryptionSettings(
+        encryption_settings = VolumeTypeEncryptionConfig(
             name='foo', provider_class='bar',
             control_location=ControlLocation.back_end)
-        volume_type_settings = VolumeTypeSettings(
+        volume_type_settings = VolumeTypeConfig(
             name=self.vol_type_name, encryption=encryption_settings)
         self.volume_type = cinder_utils.create_volume_type(
             self.cinder, volume_type_settings)
@@ -514,7 +514,7 @@ class CinderUtilsVolumeTypeCompleteTests(OSComponentTestCase):
         """
         Tests the cinder_utils.create_volume_type() with an associated QoS Spec
         """
-        volume_type_settings = VolumeTypeSettings(
+        volume_type_settings = VolumeTypeConfig(
             name=self.vol_type_name, qos_spec_name=self.qos_name)
         self.volume_type = cinder_utils.create_volume_type(
             self.cinder, volume_type_settings)
@@ -529,7 +529,7 @@ class CinderUtilsVolumeTypeCompleteTests(OSComponentTestCase):
         Tests the cinder_utils.create_volume_type() when the QoS Spec name
         does not exist
         """
-        volume_type_settings = VolumeTypeSettings(
+        volume_type_settings = VolumeTypeConfig(
             name=self.vol_type_name, qos_spec_name='foo')
 
         self.volume_type = cinder_utils.create_volume_type(
@@ -542,10 +542,10 @@ class CinderUtilsVolumeTypeCompleteTests(OSComponentTestCase):
         Tests the cinder_utils.create_volume_type() with encryption and an
         associated QoS Spec
         """
-        encryption_settings = VolumeTypeEncryptionSettings(
+        encryption_settings = VolumeTypeEncryptionConfig(
             name='foo', provider_class='bar',
             control_location=ControlLocation.back_end)
-        volume_type_settings = VolumeTypeSettings(
+        volume_type_settings = VolumeTypeConfig(
             name=self.vol_type_name, qos_spec_name=self.qos_name,
             encryption=encryption_settings)
         self.volume_type = cinder_utils.create_volume_type(
index 10b5114..f4e7da5 100644 (file)
@@ -375,7 +375,7 @@ class SettingsUtilsUnitTests(unittest.TestCase):
             name='vol-type-name', volume_type_id='vol-type-id', public=True,
             encryption=encryption, qos_spec=qos_spec)
 
-        settings = settings_utils.create_volume_type_settings(volume_type)
+        settings = settings_utils.create_volume_type_config(volume_type)
         self.assertEqual(volume_type.name, settings.name)
         self.assertEqual(volume_type.public, settings.public)
 
index 1212019..f9c4e92 100644 (file)
@@ -16,6 +16,7 @@
 import logging
 import unittest
 
+from snaps.config.tests.volume_type_tests import VolumeTypeConfigUnitTests
 from snaps.config.tests.qos_tests import QoSConfigUnitTests
 from snaps.config.tests.stack_tests import StackConfigUnitTests
 from snaps.config.tests.router_tests import RouterConfigUnitTests
@@ -226,6 +227,8 @@ def add_unit_tests(suite):
         QoSConfigUnitTests))
     suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
         QoSSettingsUnitTests))
+    suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
+        VolumeTypeConfigUnitTests))
     suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
         VolumeTypeSettingsUnitTests))
     suite.addTest(unittest.TestLoader().loadTestsFromTestCase(