summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/how-to-use/LibraryUsage.rst7
-rw-r--r--docs/how-to-use/UnitTests.rst12
-rw-r--r--examples/demo.py5
-rw-r--r--examples/launch.py7
-rw-r--r--snaps/config/__init__.py1
-rw-r--r--snaps/config/flavor.py107
-rw-r--r--snaps/config/tests/__init__.py1
-rw-r--r--snaps/config/tests/flavor_tests.py254
-rw-r--r--snaps/openstack/create_flavor.py94
-rw-r--r--snaps/openstack/create_stack.py2
-rw-r--r--snaps/openstack/tests/create_flavor_tests.py82
-rw-r--r--snaps/openstack/tests/create_instance_tests.py55
-rw-r--r--snaps/openstack/tests/create_stack_tests.py14
-rw-r--r--snaps/openstack/utils/settings_utils.py6
-rw-r--r--snaps/openstack/utils/tests/heat_utils_tests.py5
-rw-r--r--snaps/openstack/utils/tests/nova_utils_tests.py17
-rw-r--r--snaps/openstack/utils/tests/settings_utils_tests.py7
-rw-r--r--snaps/provisioning/tests/ansible_utils_tests.py17
-rw-r--r--snaps/test_suite_builder.py3
19 files changed, 500 insertions, 196 deletions
diff --git a/docs/how-to-use/LibraryUsage.rst b/docs/how-to-use/LibraryUsage.rst
index a842be0..c6b40a1 100644
--- a/docs/how-to-use/LibraryUsage.rst
+++ b/docs/how-to-use/LibraryUsage.rst
@@ -138,7 +138,7 @@ Create Flavor
-------------
- FlavorĀ - snaps.openstack.create\_flavor.OpenStackFlavor
- - snaps.openstack.create\_flavor.FlavorSettings
+ - snaps.config.flavor.FlavorConfig
- name - the flavor name (required)
- flavor\_id - the flavor's string ID (default='auto')
@@ -155,8 +155,9 @@ Create Flavor
.. code:: python
- from snaps.openstack.create_flavor import FlavorSettings, OpenStackFlavor
- flavor_settings = FlavorSettings(name='flavor-name', ram=4, disk=10, vcpus=2)
+ from snaps.config.flavor import FlavorConfig
+ from snaps.openstack.create_flavor import OpenStackFlavor
+ flavor_settings = FlavorConfig(name='flavor-name', ram=4, disk=10, vcpus=2)
flavor_creator = OpenStackFlavor(os_creds, flavor_settings)
flavor_creator.create()
diff --git a/docs/how-to-use/UnitTests.rst b/docs/how-to-use/UnitTests.rst
index e6b95ab..398a08e 100644
--- a/docs/how-to-use/UnitTests.rst
+++ b/docs/how-to-use/UnitTests.rst
@@ -78,11 +78,17 @@ ImageDomainObjectTests
Ensures that all required members are included when constructing a
Image domain object
+FlavorConfigUnitTests
+---------------------
+
+Ensures that all required members are included when constructing a
+FlavorConfig object
+
FlavorSettingsUnitTests
-----------------------
Ensures that all required members are included when constructing a
-FlavorSettings object
+deprecated FlavorSettings object
FlavorDomainObjectTests
-----------------------
@@ -310,6 +316,6 @@ snaps.domain.VolumeType object to a
snaps.openstack.create_volume.VolumeSettings object
-Ensures that the settings_utils.py#create_flavor_settings() function properly
+Ensures that the settings_utils.py#create_flavor_config() function properly
maps a snaps.domain.Flavor object correctly to a
-snaps.openstack.create_flavor.FlavorSettings object \ No newline at end of file
+snaps.config.flavor.FlavorConfig object \ No newline at end of file
diff --git a/examples/demo.py b/examples/demo.py
index faf6459..8837bd2 100644
--- a/examples/demo.py
+++ b/examples/demo.py
@@ -34,9 +34,10 @@ network.create()
# Flavors
-from snaps.openstack.create_flavor import FlavorSettings, OpenStackFlavor
+from snaps.config.flavor import FlavorConfig
+from snaps.openstack.create_flavor import OpenStackFlavor
-flavor_settings = FlavorSettings(name='test-flavor', ram=256, disk=10, vcpus=2)
+flavor_settings = FlavorConfig(name='test-flavor', ram=256, disk=10, vcpus=2)
flavor = OpenStackFlavor(os_creds, flavor_settings)
flavor.create()
diff --git a/examples/launch.py b/examples/launch.py
index debb52f..499d259 100644
--- a/examples/launch.py
+++ b/examples/launch.py
@@ -26,9 +26,10 @@ import os
import yaml
from snaps import file_utils
-from snaps.openstack.create_flavor import FlavorSettings, OpenStackFlavor
-from snaps.openstack.create_image import OpenStackImage
+from snaps.config.flavor import FlavorConfig
from snaps.config.image import ImageConfig
+from snaps.openstack.create_flavor import OpenStackFlavor
+from snaps.openstack.create_image import OpenStackImage
from snaps.openstack.create_instance import VmInstanceSettings
from snaps.openstack.create_keypairs import KeypairSettings, OpenStackKeypair
from snaps.openstack.create_network import (
@@ -635,7 +636,7 @@ def main(arguments):
# Create flavors
flavors_dict = __create_instances(
- os_creds_dict, OpenStackFlavor, FlavorSettings,
+ os_creds_dict, OpenStackFlavor, FlavorConfig,
os_config.get('flavors'), 'flavor', clean, users_dict)
creators.append(flavors_dict)
diff --git a/snaps/config/__init__.py b/snaps/config/__init__.py
index fb7560b..271c742 100644
--- a/snaps/config/__init__.py
+++ b/snaps/config/__init__.py
@@ -12,3 +12,4 @@
# 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.
+__author__ = 'spisarski'
diff --git a/snaps/config/flavor.py b/snaps/config/flavor.py
new file mode 100644
index 0000000..b29fb7c
--- /dev/null
+++ b/snaps/config/flavor.py
@@ -0,0 +1,107 @@
+# Copyright (c) 2016 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.
+
+
+class FlavorConfig(object):
+ """
+ Configuration settings for OpenStack flavor creation
+ """
+
+ def __init__(self, **kwargs):
+ """
+ Constructor
+ :param name: the flavor's name (required)
+ :param flavor_id: the string ID (default 'auto')
+ :param ram: the required RAM in MB (required)
+ :param disk: the size of the root disk in GB (required)
+ :param vcpus: the number of virtual CPUs (required)
+ :param ephemeral: the size of the ephemeral disk in GB (default 0)
+ :param swap: the size of the dedicated swap disk in GB (default 0)
+ :param rxtx_factor: the receive/transmit factor to be set on ports if
+ backend supports QoS extension (default 1.0)
+ :param is_public: denotes whether or not the flavor is public
+ (default True)
+ :param metadata: freeform dict() for special metadata
+ """
+ self.name = kwargs.get('name')
+
+ if kwargs.get('flavor_id'):
+ self.flavor_id = kwargs['flavor_id']
+ else:
+ self.flavor_id = 'auto'
+
+ self.ram = kwargs.get('ram')
+ self.disk = kwargs.get('disk')
+ self.vcpus = kwargs.get('vcpus')
+
+ if kwargs.get('ephemeral'):
+ self.ephemeral = kwargs['ephemeral']
+ else:
+ self.ephemeral = 0
+
+ if kwargs.get('swap'):
+ self.swap = kwargs['swap']
+ else:
+ self.swap = 0
+
+ if kwargs.get('rxtx_factor'):
+ self.rxtx_factor = kwargs['rxtx_factor']
+ else:
+ self.rxtx_factor = 1.0
+
+ if kwargs.get('is_public') is not None:
+ self.is_public = kwargs['is_public']
+ else:
+ self.is_public = True
+
+ if kwargs.get('metadata'):
+ self.metadata = kwargs['metadata']
+ else:
+ self.metadata = None
+
+ if not self.name or not self.ram or not self.disk or not self.vcpus:
+ raise FlavorConfigError(
+ 'The attributes name, ram, disk, and vcpus are required for'
+ 'FlavorConfig')
+
+ if not isinstance(self.ram, int):
+ raise FlavorConfigError('The ram attribute must be a integer')
+
+ if not isinstance(self.disk, int):
+ raise FlavorConfigError('The ram attribute must be a integer')
+
+ if not isinstance(self.vcpus, int):
+ raise FlavorConfigError('The vcpus attribute must be a integer')
+
+ if self.ephemeral and not isinstance(self.ephemeral, int):
+ raise FlavorConfigError(
+ 'The ephemeral attribute must be an integer')
+
+ if self.swap and not isinstance(self.swap, int):
+ raise FlavorConfigError('The swap attribute must be an integer')
+
+ if self.rxtx_factor and not isinstance(self.rxtx_factor, (int, float)):
+ raise FlavorConfigError(
+ 'The is_public attribute must be an integer or float')
+
+ if self.is_public and not isinstance(self.is_public, bool):
+ raise FlavorConfigError(
+ 'The is_public attribute must be a boolean')
+
+
+class FlavorConfigError(Exception):
+ """
+ Exception to be thrown when a flavor configuration is incorrect
+ """
diff --git a/snaps/config/tests/__init__.py b/snaps/config/tests/__init__.py
index fb7560b..271c742 100644
--- a/snaps/config/tests/__init__.py
+++ b/snaps/config/tests/__init__.py
@@ -12,3 +12,4 @@
# 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.
+__author__ = 'spisarski'
diff --git a/snaps/config/tests/flavor_tests.py b/snaps/config/tests/flavor_tests.py
new file mode 100644
index 0000000..15cd99a
--- /dev/null
+++ b/snaps/config/tests/flavor_tests.py
@@ -0,0 +1,254 @@
+# 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.flavor import FlavorConfig, FlavorConfigError
+
+
+class FlavorConfigUnitTests(unittest.TestCase):
+ """
+ Tests the construction of the FlavorConfig class
+ """
+
+ def test_no_params(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig()
+
+ def test_empty_config(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(config=dict())
+
+ def test_name_only(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(name='foo')
+
+ def test_config_with_name_only(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(config={'name': 'foo'})
+
+ def test_name_ram_only(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(name='foo', ram=1)
+
+ def test_config_with_name_ram_only(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(config={'name': 'foo', 'ram': 1})
+
+ def test_name_ram_disk_only(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(name='foo', ram=1, disk=1)
+
+ def test_config_with_name_ram_disk_only(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(config={'name': 'foo', 'ram': 1, 'disk': 1})
+
+ def test_ram_string(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(name='foo', ram='bar', disk=2, vcpus=3, ephemeral=4,
+ swap=5, rxtx_factor=6.0,
+ is_public=False)
+
+ def test_config_ram_string(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(
+ config={'name': 'foo', 'ram': 'bar', 'disk': 2, 'vcpus': 3,
+ 'ephemeral': 4, 'swap': 5,
+ 'rxtx_factor': 6.0, 'is_public': False})
+
+ def test_ram_float(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(name='foo', ram=1.5, disk=2, vcpus=3, ephemeral=4,
+ swap=5, rxtx_factor=6.0, is_public=False)
+
+ def test_config_ram_float(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(
+ config={'name': 'foo', 'ram': 1.5, 'disk': 2, 'vcpus': 3,
+ 'ephemeral': 4, 'swap': 5,
+ 'rxtx_factor': 6.0, 'is_public': False})
+
+ def test_disk_string(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(name='foo', ram=1, disk='bar', vcpus=3, ephemeral=4,
+ swap=5, rxtx_factor=6.0,
+ is_public=False)
+
+ def test_config_disk_string(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(
+ config={'name': 'foo', 'ram': 1, 'disk': 'bar', 'vcpus': 3,
+ 'ephemeral': 4, 'swap': 5,
+ 'rxtx_factor': 6.0, 'is_public': False})
+
+ def test_disk_float(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(name='foo', ram=1, disk=2.5, vcpus=3, ephemeral=4,
+ swap=5, rxtx_factor=6.0, is_public=False)
+
+ def test_config_disk_float(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(
+ config={'name': 'foo', 'ram': 1, 'disk': 2.5, 'vcpus': 3,
+ 'ephemeral': 4, 'swap': 5,
+ 'rxtx_factor': 6.0, 'is_public': False})
+
+ def test_vcpus_string(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(name='foo', ram=1, disk=2, vcpus='bar', ephemeral=4,
+ swap=5, rxtx_factor=6.0,
+ is_public=False)
+
+ def test_config_vcpus_string(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(
+ config={'name': 'foo', 'ram': 1, 'disk': 2, 'vcpus': 'bar',
+ 'ephemeral': 4, 'swap': 5,
+ 'rxtx_factor': 6.0, 'is_public': False})
+
+ def test_ephemeral_string(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(name='foo', ram=1, disk=2, vcpus=3, ephemeral='bar',
+ swap=5, rxtx_factor=6.0,
+ is_public=False)
+
+ def test_config_ephemeral_string(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(
+ config={'name': 'foo', 'ram': 1, 'disk': 2, 'vcpus': 3,
+ 'ephemeral': 'bar', 'swap': 5,
+ 'rxtx_factor': 6.0, 'is_public': False})
+
+ def test_ephemeral_float(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(name='foo', ram=1, disk=2, vcpus=3, ephemeral=4.5,
+ swap=5, rxtx_factor=6.0, is_public=False)
+
+ def test_config_ephemeral_float(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(
+ config={'name': 'foo', 'ram': 1, 'disk': 2, 'vcpus': 3,
+ 'ephemeral': 4.5, 'swap': 5,
+ 'rxtx_factor': 6.0, 'is_public': False})
+
+ def test_swap_string(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(name='foo', ram=1, disk=2, vcpus=3, ephemeral=4,
+ swap='bar', rxtx_factor=6.0,
+ is_public=False)
+
+ def test_config_swap_string(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(
+ config={'name': 'foo', 'ram': 1, 'disk': 2, 'vcpus': 3,
+ 'ephemeral': 4, 'swap': 'bar',
+ 'rxtx_factor': 6.0, 'is_public': False})
+
+ def test_swap_float(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(name='foo', ram=1, disk=2, vcpus=3, ephemeral=4,
+ swap=5.5, rxtx_factor=6.0, is_public=False)
+
+ def test_config_swap_float(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(
+ config={'name': 'foo', 'ram': 1, 'disk': 2, 'vcpus': 3,
+ 'ephemeral': 4, 'swap': 5.5,
+ 'rxtx_factor': 6.0, 'is_public': False})
+
+ def test_rxtx_string(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(name='foo', ram=1, disk=2, vcpus=3, ephemeral=4,
+ swap=5, rxtx_factor='bar', is_public=False)
+
+ def test_config_rxtx_string(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(
+ config={'name': 'foo', 'ram': 1, 'disk': 2, 'vcpus': 3,
+ 'ephemeral': 4, 'swap': 5,
+ 'rxtx_factor': 'bar', 'is_public': False})
+
+ def test_is_pub_string(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(name='foo', ram=1, disk=2, vcpus=3, ephemeral=4,
+ swap=5, rxtx_factor=6.0, is_public='bar')
+
+ def test_config_is_pub_string(self):
+ with self.assertRaises(FlavorConfigError):
+ FlavorConfig(
+ config={'name': 'foo', 'ram': 1, 'disk': 2, 'vcpus': 3,
+ 'ephemeral': 4, 'swap': 5,
+ 'rxtx_factor': 6.0, 'is_public': 'bar'})
+
+ def test_name_ram_disk_vcpus_only(self):
+ settings = FlavorConfig(name='foo', ram=1, disk=2, vcpus=3)
+ self.assertEqual('foo', settings.name)
+ self.assertEqual('auto', settings.flavor_id)
+ self.assertEqual(1, settings.ram)
+ self.assertEqual(2, settings.disk)
+ self.assertEqual(3, settings.vcpus)
+ self.assertEqual(0, settings.ephemeral)
+ self.assertEqual(0, settings.swap)
+ self.assertEqual(1.0, settings.rxtx_factor)
+ self.assertEqual(True, settings.is_public)
+ self.assertEqual(None, settings.metadata)
+
+ def test_config_with_name_ram_disk_vcpus_only(self):
+ settings = FlavorConfig(
+ **{'name': 'foo', 'ram': 1, 'disk': 2, 'vcpus': 3})
+ self.assertEqual('foo', settings.name)
+ self.assertEqual('auto', settings.flavor_id)
+ self.assertEqual(1, settings.ram)
+ self.assertEqual(2, settings.disk)
+ self.assertEqual(3, settings.vcpus)
+ self.assertEqual(0, settings.ephemeral)
+ self.assertEqual(0, settings.swap)
+ self.assertEqual(1.0, settings.rxtx_factor)
+ self.assertEqual(True, settings.is_public)
+ self.assertEqual(None, settings.metadata)
+
+ def test_all(self):
+ metadata = {'foo': 'bar'}
+ settings = FlavorConfig(
+ name='foo', flavor_id='bar', ram=1, disk=2, vcpus=3, ephemeral=4,
+ swap=5, rxtx_factor=6.0, is_public=False, metadata=metadata)
+ self.assertEqual('foo', settings.name)
+ self.assertEqual('bar', settings.flavor_id)
+ self.assertEqual(1, settings.ram)
+ self.assertEqual(2, settings.disk)
+ self.assertEqual(3, settings.vcpus)
+ self.assertEqual(4, settings.ephemeral)
+ self.assertEqual(5, settings.swap)
+ self.assertEqual(6.0, settings.rxtx_factor)
+ self.assertEqual(False, settings.is_public)
+ self.assertEqual(metadata, settings.metadata)
+
+ def test_config_all(self):
+ metadata = {'foo': 'bar'}
+ settings = FlavorConfig(
+ **{'name': 'foo', 'flavor_id': 'bar', 'ram': 1, 'disk': 2,
+ 'vcpus': 3,
+ 'ephemeral': 4, 'swap': 5, 'rxtx_factor': 6.0,
+ 'is_public': False,
+ 'metadata': metadata})
+ self.assertEqual('foo', settings.name)
+ self.assertEqual('bar', settings.flavor_id)
+ self.assertEqual(1, settings.ram)
+ self.assertEqual(2, settings.disk)
+ self.assertEqual(3, settings.vcpus)
+ self.assertEqual(4, settings.ephemeral)
+ self.assertEqual(5, settings.swap)
+ self.assertEqual(6.0, settings.rxtx_factor)
+ self.assertEqual(False, settings.is_public)
+ self.assertEqual(metadata, settings.metadata)
diff --git a/snaps/openstack/create_flavor.py b/snaps/openstack/create_flavor.py
index b428621..b866d43 100644
--- a/snaps/openstack/create_flavor.py
+++ b/snaps/openstack/create_flavor.py
@@ -16,6 +16,7 @@ import logging
from novaclient.exceptions import NotFound
+from snaps.config.flavor import FlavorConfig
from snaps.openstack.openstack_creator import OpenStackComputeObject
from snaps.openstack.utils import nova_utils
@@ -36,7 +37,7 @@ class OpenStackFlavor(OpenStackComputeObject):
"""
Constructor
:param os_creds: The OpenStack connection credentials
- :param flavor_settings: The flavor settings
+ :param flavor_settings: a FlavorConfig instance
:return:
"""
super(self.__class__, self).__init__(os_creds)
@@ -96,94 +97,13 @@ class OpenStackFlavor(OpenStackComputeObject):
return self.__flavor
-class FlavorSettings:
+class FlavorSettings(FlavorConfig):
"""
Configuration settings for OpenStack flavor creation
"""
def __init__(self, **kwargs):
- """
- Constructor
- :param name: the flavor's name (required)
- :param flavor_id: the string ID (default 'auto')
- :param ram: the required RAM in MB (required)
- :param disk: the size of the root disk in GB (required)
- :param vcpus: the number of virtual CPUs (required)
- :param ephemeral: the size of the ephemeral disk in GB (default 0)
- :param swap: the size of the dedicated swap disk in GB (default 0)
- :param rxtx_factor: the receive/transmit factor to be set on ports if
- backend supports QoS extension (default 1.0)
- :param is_public: denotes whether or not the flavor is public
- (default True)
- :param metadata: freeform dict() for special metadata
- """
- self.name = kwargs.get('name')
-
- if kwargs.get('flavor_id'):
- self.flavor_id = kwargs['flavor_id']
- else:
- self.flavor_id = 'auto'
-
- self.ram = kwargs.get('ram')
- self.disk = kwargs.get('disk')
- self.vcpus = kwargs.get('vcpus')
-
- if kwargs.get('ephemeral'):
- self.ephemeral = kwargs['ephemeral']
- else:
- self.ephemeral = 0
-
- if kwargs.get('swap'):
- self.swap = kwargs['swap']
- else:
- self.swap = 0
-
- if kwargs.get('rxtx_factor'):
- self.rxtx_factor = kwargs['rxtx_factor']
- else:
- self.rxtx_factor = 1.0
-
- if kwargs.get('is_public') is not None:
- self.is_public = kwargs['is_public']
- else:
- self.is_public = True
-
- if kwargs.get('metadata'):
- self.metadata = kwargs['metadata']
- else:
- self.metadata = None
-
- if not self.name or not self.ram or not self.disk or not self.vcpus:
- raise FlavorSettingsError(
- 'The attributes name, ram, disk, and vcpus are required for'
- 'FlavorSettings')
-
- if not isinstance(self.ram, int):
- raise FlavorSettingsError('The ram attribute must be a integer')
-
- if not isinstance(self.disk, int):
- raise FlavorSettingsError('The ram attribute must be a integer')
-
- if not isinstance(self.vcpus, int):
- raise FlavorSettingsError('The vcpus attribute must be a integer')
-
- if self.ephemeral and not isinstance(self.ephemeral, int):
- raise FlavorSettingsError(
- 'The ephemeral attribute must be an integer')
-
- if self.swap and not isinstance(self.swap, int):
- raise FlavorSettingsError('The swap attribute must be an integer')
-
- if self.rxtx_factor and not isinstance(self.rxtx_factor, (int, float)):
- raise FlavorSettingsError(
- 'The is_public attribute must be an integer or float')
-
- if self.is_public and not isinstance(self.is_public, bool):
- raise FlavorSettingsError(
- 'The is_public attribute must be a boolean')
-
-
-class FlavorSettingsError(Exception):
- """
- Exception to be thrown when an flavor settings are incorrect
- """
+ from warnings import warn
+ warn('Use snaps.config.flavor.FlavorConfig instead',
+ DeprecationWarning)
+ super(self.__class__, self).__init__(**kwargs)
diff --git a/snaps/openstack/create_stack.py b/snaps/openstack/create_stack.py
index 50d364d..aebe52a 100644
--- a/snaps/openstack/create_stack.py
+++ b/snaps/openstack/create_stack.py
@@ -406,7 +406,7 @@ class OpenStackHeatStack(OpenStackCloudObject, object):
self.__heat_cli, nova, self.__stack)
for flavor in flavors:
- settings = settings_utils.create_flavor_settings(flavor)
+ settings = settings_utils.create_flavor_config(flavor)
creator = OpenStackFlavor(self._os_creds, settings)
out.append(creator)
diff --git a/snaps/openstack/tests/create_flavor_tests.py b/snaps/openstack/tests/create_flavor_tests.py
index 3eb07bd..f84355d 100644
--- a/snaps/openstack/tests/create_flavor_tests.py
+++ b/snaps/openstack/tests/create_flavor_tests.py
@@ -15,9 +15,9 @@
import unittest
import uuid
+from snaps.config.flavor import FlavorConfig, FlavorConfigError
from snaps.openstack import create_flavor
-from snaps.openstack.create_flavor import FlavorSettings, OpenStackFlavor, \
- FlavorSettingsError
+from snaps.openstack.create_flavor import OpenStackFlavor, FlavorSettings
from snaps.openstack.tests.os_source_file_test import OSComponentTestCase
from snaps.openstack.utils import nova_utils
@@ -30,169 +30,169 @@ class FlavorSettingsUnitTests(unittest.TestCase):
"""
def test_no_params(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings()
def test_empty_config(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(config=dict())
def test_name_only(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(name='foo')
def test_config_with_name_only(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(config={'name': 'foo'})
def test_name_ram_only(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(name='foo', ram=1)
def test_config_with_name_ram_only(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(config={'name': 'foo', 'ram': 1})
def test_name_ram_disk_only(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(name='foo', ram=1, disk=1)
def test_config_with_name_ram_disk_only(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(config={'name': 'foo', 'ram': 1, 'disk': 1})
def test_ram_string(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(name='foo', ram='bar', disk=2, vcpus=3, ephemeral=4,
swap=5, rxtx_factor=6.0,
is_public=False)
def test_config_ram_string(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(
config={'name': 'foo', 'ram': 'bar', 'disk': 2, 'vcpus': 3,
'ephemeral': 4, 'swap': 5,
'rxtx_factor': 6.0, 'is_public': False})
def test_ram_float(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(name='foo', ram=1.5, disk=2, vcpus=3, ephemeral=4,
swap=5, rxtx_factor=6.0, is_public=False)
def test_config_ram_float(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(
config={'name': 'foo', 'ram': 1.5, 'disk': 2, 'vcpus': 3,
'ephemeral': 4, 'swap': 5,
'rxtx_factor': 6.0, 'is_public': False})
def test_disk_string(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(name='foo', ram=1, disk='bar', vcpus=3, ephemeral=4,
swap=5, rxtx_factor=6.0,
is_public=False)
def test_config_disk_string(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(
config={'name': 'foo', 'ram': 1, 'disk': 'bar', 'vcpus': 3,
'ephemeral': 4, 'swap': 5,
'rxtx_factor': 6.0, 'is_public': False})
def test_disk_float(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(name='foo', ram=1, disk=2.5, vcpus=3, ephemeral=4,
swap=5, rxtx_factor=6.0, is_public=False)
def test_config_disk_float(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(
config={'name': 'foo', 'ram': 1, 'disk': 2.5, 'vcpus': 3,
'ephemeral': 4, 'swap': 5,
'rxtx_factor': 6.0, 'is_public': False})
def test_vcpus_string(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(name='foo', ram=1, disk=2, vcpus='bar', ephemeral=4,
swap=5, rxtx_factor=6.0,
is_public=False)
def test_config_vcpus_string(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(
config={'name': 'foo', 'ram': 1, 'disk': 2, 'vcpus': 'bar',
'ephemeral': 4, 'swap': 5,
'rxtx_factor': 6.0, 'is_public': False})
def test_ephemeral_string(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(name='foo', ram=1, disk=2, vcpus=3, ephemeral='bar',
swap=5, rxtx_factor=6.0,
is_public=False)
def test_config_ephemeral_string(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(
config={'name': 'foo', 'ram': 1, 'disk': 2, 'vcpus': 3,
'ephemeral': 'bar', 'swap': 5,
'rxtx_factor': 6.0, 'is_public': False})
def test_ephemeral_float(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(name='foo', ram=1, disk=2, vcpus=3, ephemeral=4.5,
swap=5, rxtx_factor=6.0, is_public=False)
def test_config_ephemeral_float(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(
config={'name': 'foo', 'ram': 1, 'disk': 2, 'vcpus': 3,
'ephemeral': 4.5, 'swap': 5,
'rxtx_factor': 6.0, 'is_public': False})
def test_swap_string(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(name='foo', ram=1, disk=2, vcpus=3, ephemeral=4,
swap='bar', rxtx_factor=6.0,
is_public=False)
def test_config_swap_string(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(
config={'name': 'foo', 'ram': 1, 'disk': 2, 'vcpus': 3,
'ephemeral': 4, 'swap': 'bar',
'rxtx_factor': 6.0, 'is_public': False})
def test_swap_float(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(name='foo', ram=1, disk=2, vcpus=3, ephemeral=4,
swap=5.5, rxtx_factor=6.0, is_public=False)
def test_config_swap_float(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(
config={'name': 'foo', 'ram': 1, 'disk': 2, 'vcpus': 3,
'ephemeral': 4, 'swap': 5.5,
'rxtx_factor': 6.0, 'is_public': False})
def test_rxtx_string(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(name='foo', ram=1, disk=2, vcpus=3, ephemeral=4,
swap=5, rxtx_factor='bar', is_public=False)
def test_config_rxtx_string(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(
config={'name': 'foo', 'ram': 1, 'disk': 2, 'vcpus': 3,
'ephemeral': 4, 'swap': 5,
'rxtx_factor': 'bar', 'is_public': False})
def test_is_pub_string(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(name='foo', ram=1, disk=2, vcpus=3, ephemeral=4,
swap=5, rxtx_factor=6.0, is_public='bar')
def test_config_is_pub_string(self):
- with self.assertRaises(FlavorSettingsError):
+ with self.assertRaises(FlavorConfigError):
FlavorSettings(
config={'name': 'foo', 'ram': 1, 'disk': 2, 'vcpus': 3,
'ephemeral': 4, 'swap': 5,
@@ -291,8 +291,8 @@ class CreateFlavorTests(OSComponentTestCase):
Tests the creation of an OpenStack flavor.
"""
# Create Flavor
- flavor_settings = FlavorSettings(name=self.flavor_name, ram=1, disk=1,
- vcpus=1)
+ flavor_settings = FlavorConfig(
+ name=self.flavor_name, ram=1, disk=1, vcpus=1)
self.flavor_creator = OpenStackFlavor(self.os_creds, flavor_settings)
flavor = self.flavor_creator.create()
self.assertTrue(validate_flavor(self.nova, flavor_settings, flavor))
@@ -303,8 +303,8 @@ class CreateFlavorTests(OSComponentTestCase):
to ensure it has not been done twice.
"""
# Create Flavor
- flavor_settings = FlavorSettings(name=self.flavor_name, ram=1, disk=1,
- vcpus=1)
+ flavor_settings = FlavorConfig(
+ name=self.flavor_name, ram=1, disk=1, vcpus=1)
self.flavor_creator = OpenStackFlavor(self.os_creds, flavor_settings)
flavor = self.flavor_creator.create()
self.assertTrue(validate_flavor(self.nova, flavor_settings, flavor))
@@ -319,8 +319,8 @@ class CreateFlavorTests(OSComponentTestCase):
Tests the creation and cleanup of an OpenStack flavor.
"""
# Create Flavor
- flavor_settings = FlavorSettings(name=self.flavor_name, ram=1, disk=1,
- vcpus=1)
+ flavor_settings = FlavorConfig(
+ name=self.flavor_name, ram=1, disk=1, vcpus=1)
self.flavor_creator = OpenStackFlavor(self.os_creds, flavor_settings)
flavor = self.flavor_creator.create()
self.assertTrue(validate_flavor(self.nova, flavor_settings, flavor))
@@ -339,8 +339,8 @@ class CreateFlavorTests(OSComponentTestCase):
raise any exceptions.
"""
# Create Flavor
- flavor_settings = FlavorSettings(name=self.flavor_name, ram=1, disk=1,
- vcpus=1)
+ flavor_settings = FlavorConfig(
+ name=self.flavor_name, ram=1, disk=1, vcpus=1)
self.flavor_creator = OpenStackFlavor(self.os_creds, flavor_settings)
flavor = self.flavor_creator.create()
self.assertTrue(validate_flavor(self.nova, flavor_settings, flavor))
@@ -362,7 +362,7 @@ class CreateFlavorTests(OSComponentTestCase):
raise any exceptions.
"""
# Create Flavor
- flavor_settings = FlavorSettings(
+ flavor_settings = FlavorConfig(
name=self.flavor_name, ram=1, disk=1, vcpus=1, ephemeral=2, swap=3,
rxtx_factor=2.2, is_public=False,
metadata=create_flavor.MEM_PAGE_SIZE_ANY)
diff --git a/snaps/openstack/tests/create_instance_tests.py b/snaps/openstack/tests/create_instance_tests.py
index 1f50786..7d0c83a 100644
--- a/snaps/openstack/tests/create_instance_tests.py
+++ b/snaps/openstack/tests/create_instance_tests.py
@@ -25,9 +25,10 @@ from novaclient.exceptions import BadRequest
from snaps import file_utils
from snaps.openstack import create_network, create_router
-from snaps.openstack.create_flavor import OpenStackFlavor, FlavorSettings
-from snaps.openstack.create_image import OpenStackImage
+from snaps.config.flavor import FlavorConfig
+from snaps.openstack.create_flavor import OpenStackFlavor
from snaps.config.image import ImageConfig
+from snaps.openstack.create_image import OpenStackImage
from snaps.openstack.create_instance import (
VmInstanceSettings, OpenStackVmInstance, FloatingIpSettings,
VmInstanceSettingsError, FloatingIpSettingsError)
@@ -322,8 +323,8 @@ class SimpleHealthCheck(OSIntegrationTestCase):
# Create Flavor
self.flavor_creator = OpenStackFlavor(
self.admin_os_creds,
- FlavorSettings(name=guid + '-flavor-name', ram=256, disk=10,
- vcpus=1, metadata=self.flavor_metadata))
+ FlavorConfig(name=guid + '-flavor-name', ram=256, disk=10,
+ vcpus=1, metadata=self.flavor_metadata))
self.flavor_creator.create()
except Exception as e:
self.tearDown()
@@ -429,8 +430,8 @@ class CreateInstanceSimpleTests(OSIntegrationTestCase):
# Create Flavor
self.flavor_creator = OpenStackFlavor(
self.admin_os_creds,
- FlavorSettings(name=guid + '-flavor-name', ram=256, disk=10,
- vcpus=2, metadata=self.flavor_metadata))
+ FlavorConfig(name=guid + '-flavor-name', ram=256, disk=10,
+ vcpus=2, metadata=self.flavor_metadata))
self.flavor_creator.create()
# Create Network
@@ -567,8 +568,8 @@ class CreateInstanceSingleNetworkTests(OSIntegrationTestCase):
# Create Flavor
self.flavor_creator = OpenStackFlavor(
self.admin_os_creds,
- FlavorSettings(name=guid + '-flavor-name', ram=256, disk=10,
- vcpus=2, metadata=self.flavor_metadata))
+ FlavorConfig(name=guid + '-flavor-name', ram=256, disk=10,
+ vcpus=2, metadata=self.flavor_metadata))
self.flavor_creator.create()
self.keypair_creator = OpenStackKeypair(
@@ -845,7 +846,7 @@ class CreateInstanceIPv6NetworkTests(OSIntegrationTestCase):
self.flavor_creator = OpenStackFlavor(
self.admin_os_creds,
- FlavorSettings(
+ FlavorConfig(
name=self.guid + '-flavor-name', ram=256, disk=10, vcpus=2,
metadata=self.flavor_metadata))
self.flavor_creator.create()
@@ -1075,8 +1076,8 @@ class CreateInstancePortManipulationTests(OSIntegrationTestCase):
# Create Flavor
self.flavor_creator = OpenStackFlavor(
self.admin_os_creds,
- FlavorSettings(name=guid + '-flavor-name', ram=256, disk=10,
- vcpus=2, metadata=self.flavor_metadata))
+ FlavorConfig(name=guid + '-flavor-name', ram=256, disk=10,
+ vcpus=2, metadata=self.flavor_metadata))
self.flavor_creator.create()
except Exception as e:
self.tearDown()
@@ -1368,8 +1369,8 @@ class CreateInstanceOnComputeHost(OSIntegrationTestCase):
# Create Flavor
self.flavor_creator = OpenStackFlavor(
self.admin_os_creds,
- FlavorSettings(name=guid + '-flavor-name', ram=512, disk=1,
- vcpus=1, metadata=self.flavor_metadata))
+ FlavorConfig(name=guid + '-flavor-name', ram=512, disk=1,
+ vcpus=1, metadata=self.flavor_metadata))
self.flavor_creator.create()
# Create Image
@@ -1534,9 +1535,9 @@ class CreateInstancePubPrivNetTests(OSIntegrationTestCase):
# Create Flavor
self.flavor_creator = OpenStackFlavor(
self.admin_os_creds,
- FlavorSettings(name=self.guid + '-flavor-name', ram=512,
- disk=10, vcpus=2,
- metadata=self.flavor_metadata))
+ FlavorConfig(name=self.guid + '-flavor-name', ram=512,
+ disk=10, vcpus=2,
+ metadata=self.flavor_metadata))
self.flavor_creator.create()
# Create Keypair
@@ -1730,9 +1731,9 @@ class InstanceSecurityGroupTests(OSIntegrationTestCase):
# Create Flavor
self.flavor_creator = OpenStackFlavor(
self.admin_os_creds,
- FlavorSettings(name=self.guid + '-flavor-name', ram=256,
- disk=10, vcpus=2,
- metadata=self.flavor_metadata))
+ FlavorConfig(name=self.guid + '-flavor-name', ram=256,
+ disk=10, vcpus=2,
+ metadata=self.flavor_metadata))
self.flavor_creator.create()
self.port_settings = PortSettings(
@@ -2064,8 +2065,8 @@ class CreateInstanceFromThreePartImage(OSIntegrationTestCase):
# Create Flavor
self.flavor_creator = OpenStackFlavor(
self.admin_os_creds,
- FlavorSettings(name=guid + '-flavor-name', ram=256, disk=10,
- vcpus=2, metadata=self.flavor_metadata))
+ FlavorConfig(name=guid + '-flavor-name', ram=256, disk=10,
+ vcpus=2, metadata=self.flavor_metadata))
self.flavor_creator.create()
# Create Network
@@ -2185,7 +2186,7 @@ class CreateInstanceMockOfflineTests(OSComponentTestCase):
# Create Flavor
self.flavor_creator = OpenStackFlavor(
self.os_creds,
- FlavorSettings(
+ FlavorConfig(
name=self.guid + '-flavor-name', ram=256, disk=10,
vcpus=1))
self.flavor_creator.create()
@@ -2727,9 +2728,9 @@ class CreateInstanceTwoNetTests(OSIntegrationTestCase):
# Create Flavor
self.flavor_creator = OpenStackFlavor(
self.admin_os_creds,
- FlavorSettings(name=self.guid + '-flavor-name', ram=512,
- disk=10, vcpus=2,
- metadata=self.flavor_metadata))
+ FlavorConfig(name=self.guid + '-flavor-name', ram=512,
+ disk=10, vcpus=2,
+ metadata=self.flavor_metadata))
self.flavor_creator.create()
sec_grp_name = self.guid + '-sec-grp'
@@ -2906,8 +2907,8 @@ class CreateInstanceVolumeTests(OSIntegrationTestCase):
# Create Flavor
self.flavor_creator = OpenStackFlavor(
self.admin_os_creds,
- FlavorSettings(name=guid + '-flavor-name', ram=256, disk=1,
- vcpus=2, metadata=self.flavor_metadata))
+ FlavorConfig(name=guid + '-flavor-name', ram=256, disk=1,
+ vcpus=2, metadata=self.flavor_metadata))
self.flavor_creator.create()
# Create Network
diff --git a/snaps/openstack/tests/create_stack_tests.py b/snaps/openstack/tests/create_stack_tests.py
index 4400001..bc9cb2c 100644
--- a/snaps/openstack/tests/create_stack_tests.py
+++ b/snaps/openstack/tests/create_stack_tests.py
@@ -18,9 +18,10 @@ import time
import pkg_resources
from heatclient.exc import HTTPBadRequest
from snaps import file_utils
-from snaps.openstack.create_flavor import OpenStackFlavor, FlavorSettings
-from snaps.openstack.create_image import OpenStackImage
+from snaps.config.flavor import FlavorConfig
from snaps.config.image import ImageConfig
+from snaps.openstack.create_flavor import OpenStackFlavor
+from snaps.openstack.create_image import OpenStackImage
try:
from urllib.request import URLError
@@ -149,8 +150,8 @@ class CreateStackSuccessTests(OSIntegrationTestCase):
# Create Flavor
self.flavor_creator = OpenStackFlavor(
self.admin_os_creds,
- FlavorSettings(name=self.guid + '-flavor-name', ram=256, disk=10,
- vcpus=1))
+ FlavorConfig(
+ name=self.guid + '-flavor-name', ram=256, disk=10, vcpus=1))
self.flavor_creator.create()
self.network_name = self.guid + '-net'
@@ -983,8 +984,9 @@ class CreateStackFailureTests(OSIntegrationTestCase):
# Create Flavor
self.flavor_creator = OpenStackFlavor(
self.admin_os_creds,
- FlavorSettings(name=self.guid + '-flavor-name', ram=256, disk=10,
- vcpus=1000000))
+ FlavorConfig(
+ name=self.guid + '-flavor-name', ram=256, disk=10,
+ vcpus=1000000))
self.flavor_creator.create()
self.network_name = self.guid + '-net'
diff --git a/snaps/openstack/utils/settings_utils.py b/snaps/openstack/utils/settings_utils.py
index 2560b21..0619f15 100644
--- a/snaps/openstack/utils/settings_utils.py
+++ b/snaps/openstack/utils/settings_utils.py
@@ -15,7 +15,7 @@
import uuid
from snaps import file_utils
-from snaps.openstack.create_flavor import FlavorSettings
+from snaps.config.flavor import FlavorConfig
from snaps.openstack.create_instance import (
VmInstanceSettings, FloatingIpSettings)
from snaps.openstack.create_keypairs import KeypairSettings
@@ -191,12 +191,12 @@ def create_volume_type_settings(volume_type):
qos_spec_name=qos_spec_name, public=volume_type.public)
-def create_flavor_settings(flavor):
+def create_flavor_config(flavor):
"""
Returns a VolumeSettings object
:param flavor: a SNAPS-OO Volume object
"""
- return FlavorSettings(
+ return FlavorConfig(
name=flavor.name, flavor_id=flavor.id, ram=flavor.ram,
disk=flavor.disk, vcpus=flavor.vcpus, ephemeral=flavor.ephemeral,
swap=flavor.swap, rxtx_factor=flavor.rxtx_factor,
diff --git a/snaps/openstack/utils/tests/heat_utils_tests.py b/snaps/openstack/utils/tests/heat_utils_tests.py
index a219df6..d3d05a7 100644
--- a/snaps/openstack/utils/tests/heat_utils_tests.py
+++ b/snaps/openstack/utils/tests/heat_utils_tests.py
@@ -20,8 +20,9 @@ import uuid
import time
+from snaps.config.flavor import FlavorConfig
from snaps.openstack import create_stack
-from snaps.openstack.create_flavor import OpenStackFlavor, FlavorSettings
+from snaps.openstack.create_flavor import OpenStackFlavor
from snaps.openstack.create_image import OpenStackImage
from snaps.openstack.create_instance import OpenStackVmInstance
@@ -96,7 +97,7 @@ class HeatUtilsCreateSimpleStackTests(OSComponentTestCase):
# Create Flavor
self.flavor_creator = OpenStackFlavor(
self.os_creds,
- FlavorSettings(name=guid + '-flavor', ram=256, disk=10, vcpus=1))
+ FlavorConfig(name=guid + '-flavor', ram=256, disk=10, vcpus=1))
self.flavor_creator.create()
env_values = {'image_name': self.image_creator.image_settings.name,
diff --git a/snaps/openstack/utils/tests/nova_utils_tests.py b/snaps/openstack/utils/tests/nova_utils_tests.py
index e290c6e..0c313b9 100644
--- a/snaps/openstack/utils/tests/nova_utils_tests.py
+++ b/snaps/openstack/utils/tests/nova_utils_tests.py
@@ -13,14 +13,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
+import time
import uuid
import os
-import time
from snaps import file_utils
+from snaps.config.flavor import FlavorConfig
from snaps.openstack import create_instance
-from snaps.openstack.create_flavor import FlavorSettings, OpenStackFlavor
+from snaps.openstack.create_flavor import OpenStackFlavor
from snaps.openstack.create_image import OpenStackImage
from snaps.openstack.create_instance import (
VmInstanceSettings, OpenStackVmInstance)
@@ -159,11 +160,9 @@ class NovaUtilsFlavorTests(OSComponentTestCase):
and creating an OS image file within OpenStack
"""
guid = self.__class__.__name__ + '-' + str(uuid.uuid4())
- self.flavor_settings = FlavorSettings(name=guid + '-name',
- flavor_id=guid + '-id', ram=1,
- disk=1, vcpus=1,
- ephemeral=1, swap=2,
- rxtx_factor=3.0, is_public=False)
+ self.flavor_settings = FlavorConfig(
+ name=guid + '-name', flavor_id=guid + '-id', ram=1, disk=1,
+ vcpus=1, ephemeral=1, swap=2, rxtx_factor=3.0, is_public=False)
self.nova = nova_utils.nova_client(self.os_creds)
self.flavor = None
@@ -255,7 +254,7 @@ class NovaUtilsInstanceTests(OSComponentTestCase):
self.flavor_creator = OpenStackFlavor(
self.os_creds,
- FlavorSettings(
+ FlavorConfig(
name=guid + '-flavor-name', ram=256, disk=10, vcpus=1))
self.flavor_creator.create()
@@ -371,7 +370,7 @@ class NovaUtilsInstanceVolumeTests(OSComponentTestCase):
self.flavor_creator = OpenStackFlavor(
self.os_creds,
- FlavorSettings(
+ FlavorConfig(
name=guid + '-flavor-name', ram=256, disk=10, vcpus=1))
self.flavor_creator.create()
diff --git a/snaps/openstack/utils/tests/settings_utils_tests.py b/snaps/openstack/utils/tests/settings_utils_tests.py
index 1c4c7b5..97dfd3c 100644
--- a/snaps/openstack/utils/tests/settings_utils_tests.py
+++ b/snaps/openstack/utils/tests/settings_utils_tests.py
@@ -18,6 +18,7 @@ import unittest
import os
import uuid
+from snaps.config.flavor import FlavorConfig
from snaps.domain.flavor import Flavor
from snaps.domain.volume import (
Volume, VolumeType, VolumeTypeEncryption, QoSSpec)
@@ -200,8 +201,8 @@ class SettingsUtilsVmInstTests(OSComponentTestCase):
# Create Flavor
self.flavor_creator = create_flavor.OpenStackFlavor(
self.os_creds,
- create_flavor.FlavorSettings(name=guid + '-flavor-name',
- ram=256, disk=1, vcpus=1))
+ FlavorConfig(
+ name=guid + '-flavor-name', ram=256, disk=1, vcpus=1))
self.flavor_creator.create()
# Create Key/Pair
@@ -390,7 +391,7 @@ class SettingsUtilsUnitTests(unittest.TestCase):
flavor = Flavor(
name='flavor-name', flavor_id='flavor-id', ram=99, disk=101,
vcpus=9, ephemeral=3, swap=5, rxtx_factor=7, is_public=False)
- settings = settings_utils.create_flavor_settings(flavor)
+ settings = settings_utils.create_flavor_config(flavor)
self.assertEqual(flavor.name, settings.name)
self.assertEqual(flavor.id, settings.flavor_id)
self.assertEqual(flavor.ram, settings.ram)
diff --git a/snaps/provisioning/tests/ansible_utils_tests.py b/snaps/provisioning/tests/ansible_utils_tests.py
index da056b2..ef8c83f 100644
--- a/snaps/provisioning/tests/ansible_utils_tests.py
+++ b/snaps/provisioning/tests/ansible_utils_tests.py
@@ -18,6 +18,8 @@ import uuid
import os
import pkg_resources
from scp import SCPClient
+
+from snaps.config.flavor import FlavorConfig
from snaps.openstack import create_flavor
from snaps.openstack import create_image
from snaps.openstack import create_instance
@@ -100,9 +102,9 @@ class AnsibleProvisioningTests(OSIntegrationTestCase):
# Create Flavor
self.flavor_creator = create_flavor.OpenStackFlavor(
self.admin_os_creds,
- create_flavor.FlavorSettings(name=guid + '-flavor-name',
- ram=2048, disk=10, vcpus=2,
- metadata=self.flavor_metadata))
+ FlavorConfig(
+ name=guid + '-flavor-name', ram=2048, disk=10, vcpus=2,
+ metadata=self.flavor_metadata))
self.flavor_creator.create()
# Create Key/Pair
@@ -262,12 +264,13 @@ class AnsibleProvisioningTests(OSIntegrationTestCase):
ssh = ansible_utils.ssh_client(ip, user, priv_key,
self.os_creds.proxy_settings)
self.assertIsNotNone(ssh)
-
+ scp = None
try:
scp = SCPClient(ssh.get_transport())
scp.get('~/hello.txt', self.test_file_local_path)
finally:
- scp.close()
+ if scp:
+ scp.close()
ssh.close()
self.assertTrue(os.path.isfile(self.test_file_local_path))
@@ -326,12 +329,14 @@ class AnsibleProvisioningTests(OSIntegrationTestCase):
ssh = ansible_utils.ssh_client(ip, user, priv_key,
self.os_creds.proxy_settings)
self.assertIsNotNone(ssh)
+ scp = None
try:
scp = SCPClient(ssh.get_transport())
scp.get('/tmp/hello.txt', self.test_file_local_path)
finally:
- scp.close()
+ if scp:
+ scp.close()
ssh.close()
self.assertTrue(os.path.isfile(self.test_file_local_path))
diff --git a/snaps/test_suite_builder.py b/snaps/test_suite_builder.py
index e770618..6747b91 100644
--- a/snaps/test_suite_builder.py
+++ b/snaps/test_suite_builder.py
@@ -16,6 +16,7 @@
import logging
import unittest
+from snaps.config.tests.flavor_tests import FlavorConfigUnitTests
import snaps.config.tests.image_tests as image_tests
import snaps.openstack.tests.create_image_tests as creator_tests
from snaps.domain.test.flavor_tests import FlavorDomainObjectTests
@@ -140,6 +141,8 @@ def add_unit_tests(suite):
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
ImageDomainObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
+ FlavorConfigUnitTests))
+ suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
FlavorSettingsUnitTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
FlavorDomainObjectTests))