summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPanagiotis Karalis <pkaralis@intracom-telecom.com>2018-05-16 17:33:40 +0300
committerPanagiotis Karalis <pkaralis@intracom-telecom.com>2018-05-22 13:32:36 +0300
commitc5fd2310c8e9f63cf607de7fa9c21f60ab877224 (patch)
tree6d3414b256af5d885b7e50e14a85e48f6b32747b
parent399d3eddd132ed77af569d2532c47624cb7e1168 (diff)
Extra changes on Flavor Config
JIRA: SNAPS-254 Change-Id: I4f18c0d11fe2e8456c0ebce0681f22e3e1daf6bf Signed-off-by: Panagiotis Karalis <pkaralis@intracom-telecom.com>
-rw-r--r--docs/how-to-use/LibraryUsage.rst4
-rw-r--r--docs/how-to-use/Testing.rst4
-rw-r--r--docs/how-to-use/VirtEnvDeploy.rst6
-rw-r--r--snaps/openstack/tests/create_flavor_tests.py7
-rw-r--r--snaps/openstack/tests/openstack_tests.py37
-rw-r--r--snaps/openstack/utils/tests/nova_utils_tests.py2
6 files changed, 53 insertions, 7 deletions
diff --git a/docs/how-to-use/LibraryUsage.rst b/docs/how-to-use/LibraryUsage.rst
index aa7bf91..3183305 100644
--- a/docs/how-to-use/LibraryUsage.rst
+++ b/docs/how-to-use/LibraryUsage.rst
@@ -154,6 +154,10 @@ Create Flavor
- is\_public - flag that denotes whether or not other projects
can access image (default=True)
- metadata - freeform dict() for special metadata (optional)
+ - freeform dict() for values of basic elements
+ (e.g. ram, vcpu, disk, etc) could be added.
+ As result the hard coded values of those elements will be
+ overwritten by the new ones (optional)
.. code:: python
diff --git a/docs/how-to-use/Testing.rst b/docs/how-to-use/Testing.rst
index 92340ab..8e08abb 100644
--- a/docs/how-to-use/Testing.rst
+++ b/docs/how-to-use/Testing.rst
@@ -26,6 +26,8 @@ Execute the tests
| \* -f [optional - When set, will execute tests requiring Floating
IPS]
| \* -im [optional - File containing image endpoints to override
-| \* -fm [optional - JSON string containing a dict() for flavor metadata default='{\"hw:mem_page_size\": \"any\"}']
+| \* -fm [optional - JSON string containing a dict(): - for flavor metadata default='{\"hw:mem_page_size\": \"any\"}'
+ - for values of basic elements (e.g. ram, vcpu, disk, etc) could be added.
+ As result the hard coded values of those elements will be overwritten by the new ones]
| \* -ci [optional - runs the tests required by SNAPS-OO CI]
| \* -r [optional with default value of '1' - The number of test iterations to execute]
diff --git a/docs/how-to-use/VirtEnvDeploy.rst b/docs/how-to-use/VirtEnvDeploy.rst
index 6c99992..0345f34 100644
--- a/docs/how-to-use/VirtEnvDeploy.rst
+++ b/docs/how-to-use/VirtEnvDeploy.rst
@@ -121,7 +121,11 @@ Use launcher.py to deploy and clean up example environments. These examples are
- rxtx\_factor: the receive/transmit factor to be set on ports if
backend supports QoS extension (default 1.0)
- is\_public: denotes whether or not the flavor is public (default = True)
- - metadata: freeform dict() for special metadata (optional)
+ - metadata: - freeform dict() for special metadata (optional)
+ - freeform dict() for values of basic elements
+ (e.g. ram, vcpu, disk, etc) could be added.
+ As result the hard coded values of those elements will be
+ overwritten by the new ones (optional)
- qos_specs: the QoS Specs to create
diff --git a/snaps/openstack/tests/create_flavor_tests.py b/snaps/openstack/tests/create_flavor_tests.py
index 453509b..a69de40 100644
--- a/snaps/openstack/tests/create_flavor_tests.py
+++ b/snaps/openstack/tests/create_flavor_tests.py
@@ -20,6 +20,7 @@ from snaps.openstack import create_flavor
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
+from snaps.openstack.tests import openstack_tests
__author__ = 'spisarski'
@@ -364,10 +365,12 @@ class CreateFlavorTests(OSComponentTestCase):
raise any exceptions.
"""
# Create Flavor
- flavor_settings = FlavorConfig(
+ if self.flavor_metadata:
+ self.flavor_metadata.update(create_flavor.MEM_PAGE_SIZE_ANY)
+ flavor_settings = openstack_tests.get_flavor_config(
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)
+ metadata=self.flavor_metadata)
self.flavor_creator = OpenStackFlavor(self.os_creds, flavor_settings)
flavor = self.flavor_creator.create()
self.assertTrue(validate_flavor(self.nova, flavor_settings, flavor))
diff --git a/snaps/openstack/tests/openstack_tests.py b/snaps/openstack/tests/openstack_tests.py
index b4101a6..e8e0b75 100644
--- a/snaps/openstack/tests/openstack_tests.py
+++ b/snaps/openstack/tests/openstack_tests.py
@@ -331,28 +331,61 @@ def get_pub_net_config(
def get_flavor_config(name, ram, disk, vcpus, ephemeral=None, swap=None,
rxtx_factor=None, is_public=None, metadata=None):
+ """This method replaces the hard coded basic element (e.g. ram, vcpu, disk
+ etc) with those are included in the new freeform dict() of metadata
+ parameter.
+
+ :param name: the flavor name (required)
+ :param ram: memory in MB to allocate to VM (required)
+ :param disk: disk storage in GB (required)
+ :param vcpus: the number of CPUs to allocate to VM (required)
+ :param ephemeral: the size of the ephemeral disk in GB (default=0)
+ :param swap: the size of the 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: flag that denotes whether or not other projects
+ can access image (default=True)
+ :param metadata: - freeform dict() for special metadata (optional)
+ - freeform dict() for values of basic elements
+ (e.g. ram, vcpu, disk, etc) could be added.
+ As result the hard coded values of those elements will be
+ overwritten by the new ones (optional)
+ :return: The FlavorConfig replacing the hard coded basic element values
+ (e.g. ram, vcpu, disk etc) with those are included in the metadata
+ dict [optional]. The metadata parameter in the FlavorConfig
+ consist of the metadata data only.
+ """
+
+ metadata_excl = metadata
if metadata:
if 'ram' in metadata:
ram = metadata['ram']
+ del metadata_excl['ram']
if 'disk' in metadata:
disk = metadata['disk']
+ del metadata_excl['disk']
if 'vcpus' in metadata:
vcpus = metadata['vcpus']
+ del metadata_excl['vcpus']
if 'ephemeral' in metadata:
ephemeral = metadata['ephemeral']
+ del metadata_excl['ephemeral']
if 'swap' in metadata:
swap = metadata['swap']
+ del metadata_excl['swap']
if 'rxtx_factor' in metadata:
rxtx_factor = metadata['rxtx_factor']
+ del metadata_excl['rxtx_factor']
if 'is_public' in metadata:
is_public = metadata['is_public']
+ del metadata_excl['is_public']
if 'metadata' in metadata:
- metadata = metadata['metadata']
+ metadata_excl = metadata['metadata']
return FlavorConfig(
name=name, ram=ram, disk=disk, vcpus=vcpus, ephemeral=ephemeral,
swap=swap, rxtx_factor=rxtx_factor, is_public=is_public,
- metadata=metadata)
+ metadata=metadata_excl)
class OSNetworkConfig:
diff --git a/snaps/openstack/utils/tests/nova_utils_tests.py b/snaps/openstack/utils/tests/nova_utils_tests.py
index 93aa7bf..3e55558 100644
--- a/snaps/openstack/utils/tests/nova_utils_tests.py
+++ b/snaps/openstack/utils/tests/nova_utils_tests.py
@@ -400,7 +400,7 @@ class NovaUtilsInstanceVolumeTests(OSComponentTestCase):
self.os_creds, network_settings)
self.network_creator.create()
- flavor_settings = FlavorConfig(
+ flavor_settings = openstack_tests.get_flavor_config(
name=guid + '-flavor', ram=256, disk=10, vcpus=1,
metadata=self.flavor_metadata)
self.flavor_creator = OpenStackFlavor(