summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/how-to-use/APITests.rst70
-rw-r--r--docs/how-to-use/IntegrationTests.rst83
-rw-r--r--docs/how-to-use/LibraryUsage.rst5
-rw-r--r--docs/how-to-use/Testing.rst3
-rw-r--r--docs/how-to-use/UnitTests.rst126
-rw-r--r--snaps/openstack/create_network.py17
-rw-r--r--snaps/openstack/create_router.py5
-rw-r--r--snaps/openstack/create_security_group.py5
-rw-r--r--snaps/openstack/tests/create_network_tests.py60
-rw-r--r--snaps/openstack/tests/create_router_tests.py86
-rw-r--r--snaps/openstack/tests/create_security_group_tests.py57
-rw-r--r--snaps/openstack/tests/os_source_file_test.py3
12 files changed, 464 insertions, 56 deletions
diff --git a/docs/how-to-use/APITests.rst b/docs/how-to-use/APITests.rst
index 62efd1c..68a1a07 100644
--- a/docs/how-to-use/APITests.rst
+++ b/docs/how-to-use/APITests.rst
@@ -34,6 +34,12 @@ nova_utils_tests.py - NovaSmokeTests
Ensures that a Nova client can be obtained as well as the proper
exceptions thrown with the wrong credentials.
+heat_utils_tests.py - HeatSmokeTests
+------------------------------------
+
+Ensures that a Heat client can be obtained as well as the proper
+exceptions thrown with the wrong credentials.
+
keystone_utils_tests.py - KeystoneUtilsTests
--------------------------------------------
@@ -55,6 +61,12 @@ keystone_utils_tests.py - KeystoneUtilsTests
| test_get_endpoint_fail_without | 2 & 3 | Tests to ensure that improper credentials and proper |
| _proper_credentials | | service type cannot succeed |
+----------------------------------+---------------+-----------------------------------------------------------+
+| test_get_endpoint_with_each | 2 & 3 | Tests to ensure that an interface URL is returned for each|
+| _interface | | supported interface type (i.e. public, internal, & admin) |
++----------------------------------+---------------+-----------------------------------------------------------+
+| test_grant_user_role_to_project | 2 & 3 | Tests to ensure that one can grant a new user's role to a |
+| | | new project |
++----------------------------------+---------------+-----------------------------------------------------------+
create_user_tests.py - CreateUserSuccessTests
---------------------------------------------
@@ -64,6 +76,14 @@ create_user_tests.py - CreateUserSuccessTests
| test_create_user | 2 & 3 | Tests the creation of a user with minimal configuration |
| | | settings via the utility functions |
+----------------------------------+---------------+-----------------------------------------------------------+
+| test_create_user_2x | 2 & 3 | Tests the creation of a user 2x and ensure it has been |
+| | | done only once |
++----------------------------------+---------------+-----------------------------------------------------------+
+| test_create_delete_user | 2 & 3 | Tests the creation of a user and ensure clean can be |
+| | | called 2x without exceptions being raised |
++----------------------------------+---------------+-----------------------------------------------------------+
+| test_create_admin_user | 2 & 3 | Tests the creation of a user with an 'admin' role |
++----------------------------------+---------------+-----------------------------------------------------------+
create_project_tests.py - CreateProjectSuccessTests
---------------------------------------------------
@@ -71,13 +91,14 @@ create_project_tests.py - CreateProjectSuccessTests
+----------------------------------+---------------+-----------------------------------------------------------+
| Test Name | Keystone API | Description |
+==================================+===============+===========================================================+
-| test_create_user_minimal | 2 & 3 | Tests the creation of a user via the OpenStackUser class |
+| test_create_project | 2 & 3 | Tests the creation of a project via the OpenStackProject |
+| | | class |
+----------------------------------+---------------+-----------------------------------------------------------+
-| test_create_user_2x | 2 & 3 | Tests the creation of a user a second time via the |
-| | | OpenStackUser class to ensure it is only created once |
+| test_create_project_2x | 2 & 3 | Tests the creation of a project a second time via the |
+| | | OpenStackProject class to ensure it is only created once |
+----------------------------------+---------------+-----------------------------------------------------------+
-| test_create_delete_user | 2 & 3 | Tests the creation and deletion of a user via the |
-| | | OpenStackUser class to ensure that clean will not raise |
+| test_create_delete_project | 2 & 3 | Tests the creation and deletion of a project via the |
+| | | OpenStackProject class to ensure that clean will not raise|
| | | an exception |
+----------------------------------+---------------+-----------------------------------------------------------+
@@ -215,6 +236,18 @@ neutron_utils_tests.py - NeutronUtilsSecurityGroupTests
| test_create_sec_grp_one_rule | 2 | Ensures that neutron_utils.create_security_group_rule() |
| | | can add a rule to a security group |
+---------------------------------------+---------------+-----------------------------------------------------------+
+| test_get_sec_grp_by_id | 2 | Ensures that neutron_utils.get_security_group_by_id() |
+| | | returns the expected security group |
++---------------------------------------+---------------+-----------------------------------------------------------+
+
+neutron_utils_tests.py - NeutronUtilsFloatingIpTests
+----------------------------------------------------
+
++---------------------------------------+---------------+-----------------------------------------------------------+
+| Test Name | Neutron API | Description |
++=======================================+===============+===========================================================+
+| test_floating_ips | 2 | Ensures that a floating IP can be created |
++---------------------------------------+---------------+-----------------------------------------------------------+
nova_utils_tests.py - NovaUtilsKeypairTests
-------------------------------------------
@@ -231,10 +264,6 @@ nova_utils_tests.py - NovaUtilsKeypairTests
| test_create_key_from_file | 2 | Ensures that a keypair can be properly created via |
| | | nova_utils.upload_keypair_file() |
+---------------------------------------+---------------+-----------------------------------------------------------+
-| test_floating_ips | 2 | Ensures that a floating IP can be properly created via |
-| | | nova_utils.create_floating_ip() [note: this test should |
-| | | be moved to a new class] |
-+---------------------------------------+---------------+-----------------------------------------------------------+
nova_utils_tests.py - NovaUtilsFlavorTests
------------------------------------------
@@ -249,6 +278,16 @@ nova_utils_tests.py - NovaUtilsFlavorTests
| | | nova_utils.delete_flavor() |
+---------------------------------------+---------------+-----------------------------------------------------------+
+nova_utils_tests.py - NovaUtilsInstanceTests
+--------------------------------------------
+
++---------------------------------------+---------------+-----------------------------------------------------------+
+| Test Name | Nova API | Description |
++=======================================+===============+===========================================================+
+| test_create_instance | 2 | Ensures that a VM instance can be properly created via |
+| | | nova_utils.create_server() |
++---------------------------------------+---------------+-----------------------------------------------------------+
+
create_flavor_tests.py - CreateFlavorTests
------------------------------------------
@@ -268,3 +307,16 @@ create_flavor_tests.py - CreateFlavorTests
| | | will not raise an exception when called and the object no |
| | | longer exists |
+---------------------------------------+---------------+-----------------------------------------------------------+
+| test_create_delete_flavor_all_settings| 2 | Ensures that the OpenStackFlavor class will create a |
+| | | a flavor properly with all supported settings |
++---------------------------------------+---------------+-----------------------------------------------------------+
+
+heat_utils_tests.py - HeatUtilsCreateStackTests
+-----------------------------------------------
+
++---------------------------------------+---------------+-----------------------------------------------------------+
+| Test Name | Glance API | Description |
++=======================================+===============+===========================================================+
+| test_create_stack | 1 | Tests the heat_utils.create_stack() with a test template |
++---------------------------------------+---------------+-----------------------------------------------------------+
+
diff --git a/docs/how-to-use/IntegrationTests.rst b/docs/how-to-use/IntegrationTests.rst
index 1181776..70e51b9 100644
--- a/docs/how-to-use/IntegrationTests.rst
+++ b/docs/how-to-use/IntegrationTests.rst
@@ -16,6 +16,12 @@ create_security_group_tests.py - CreateSecurityGroupTests
| test_create_group_without_rules | Keysone 2 & 3 | Ensures the OpenStackSecurityGroup class can create a |
| | Neutron 2 | security group without any rules |
+---------------------------------------+---------------+-----------------------------------------------------------+
+| test_create_group_admin_user_to_new | Keysone 2 & 3 | Ensures the OpenStackSecurityGroup class can be created |
+| _project | Neutron 2 | by the admin user and associated with a new project |
++---------------------------------------+---------------+-----------------------------------------------------------+
+| test_create_group_new_user_to_admin | Keysone 2 & 3 | Ensures the OpenStackSecurityGroup class can be created |
+| _project | Neutron 2 | by the new user and associated with the admin project |
++---------------------------------------+---------------+-----------------------------------------------------------+
| test_create_delete_group | Keysone 2 & 3 | Ensures the OpenStackSecurityGroup class clean() method |
| | Neutron 2 | will not raise an exception should the group be deleted by|
| | | some other process |
@@ -43,20 +49,23 @@ create_image_tests.py - CreateImageSuccessTests
+---------------------------------------+---------------+-----------------------------------------------------------+
| Test Name | Glance API | Description |
+=======================================+===============+===========================================================+
-| test_create_image_clean_url | 1 | Ensures the OpenStackImage class can create an image from |
+| test_create_image_clean_url | 1 & 2 | Ensures the OpenStackImage class can create an image from |
| | | a download URL location |
+---------------------------------------+---------------+-----------------------------------------------------------+
-| test_create_image_clean_file | 1 | Ensures the OpenStackImage class can create an image from |
+| test_create_image_clean_url_properties| 1 & 2 | Ensures the OpenStackImage class can create an image from |
+| | | a download URL location with custom properties |
++---------------------------------------+---------------+-----------------------------------------------------------+
+| test_create_image_clean_file | 1 & 2 | Ensures the OpenStackImage class can create an image from |
| | | a locally sourced image file |
+---------------------------------------+---------------+-----------------------------------------------------------+
-| test_create_delete_image | 1 | Ensures the OpenStackImage.clean() method deletes an image|
+| test_create_delete_image | 1 & 2 | Ensures the OpenStackImage.clean() method deletes an image|
| | | and does not raise an exception on subsequent calls to the|
| | | clean() method |
+---------------------------------------+---------------+-----------------------------------------------------------+
-| test_create_same_image | 1 | Ensures the OpenStackImage.create() method does not create|
+| test_create_same_image | 1 & 2 | Ensures the OpenStackImage.create() method does not create|
| | | another image when one already exists with the same name |
+---------------------------------------+---------------+-----------------------------------------------------------+
-| test_create_same_image_new_settings | 1 | Tests the creation of an OpenStack image when the image |
+| test_create_same_image_new_settings | 1 & 2 | Tests the creation of an OpenStack image when the image |
| | | already exists and the configuration only contains the |
| | | the name. |
+---------------------------------------+---------------+-----------------------------------------------------------+
@@ -67,14 +76,17 @@ create_image_tests.py - CreateImageNegativeTests
+---------------------------------------+---------------+-----------------------------------------------------------+
| Test Name | Glance API | Description |
+=======================================+===============+===========================================================+
-| test_bad_image_name | 1 | Ensures OpenStackImage.create() results in an Exception |
+| test_bad_image_name | 1 & 2 | Ensures OpenStackImage.create() results in an Exception |
| | | being raised when the ImageSettings.name attribute has |
| | | not been set |
+---------------------------------------+---------------+-----------------------------------------------------------+
-| test_bad_image_url | 1 | Ensures OpenStackImage.create() results in an Exception |
+| test_bad_image_url | 1 & 2 | Ensures OpenStackImage.create() results in an Exception |
| | | being raised when the download URL is invalid |
+---------------------------------------+---------------+-----------------------------------------------------------+
-| test_bad_image_file | 1 | Ensures OpenStackImage.create() results in an Exception |
+| test_bad_image_type | 1 & 2 | Ensures OpenStackImage.create() results in an Exception |
+| | | being raised when the image format is 'foo' |
++---------------------------------------+---------------+-----------------------------------------------------------+
+| test_bad_image_file | 1 & 2 | Ensures OpenStackImage.create() results in an Exception |
| | | being raised when the image file does not exist |
+---------------------------------------+---------------+-----------------------------------------------------------+
@@ -84,11 +96,14 @@ create_image_tests.py - CreateMultiPartImageTests
+----------------------------------------+---------------+-----------------------------------------------------------+
| Test Name | Glance API | Description |
+========================================+===============+===========================================================+
-| test_create_three_part_image_from_url | 1 | Ensures that a 3-part image can be created when each part |
+| test_create_three_part_image_from_url | 1 & 2 | Ensures that a 3-part image can be created when each part |
| | | is being sourced from URLs |
+----------------------------------------+---------------+-----------------------------------------------------------+
-| test_create_three_part_image_from_file | 1 | Ensures that a 3-part image can be created when each part |
-| | | is being sourced from local files |
+| test_create_three_part_image_from_file | 1 & 2 | Ensures that a 3-part image can be created when each part |
+| _3_creators | | is being sourced from local files and 3 creators are used |
++----------------------------------------+---------------+-----------------------------------------------------------+
+| test_create_three_part_image_from_url | 1 & 2 | Ensures that a 3-part image can be created when each part |
+| _3_creators | | is being sourced from a URL and 3 creators are used |
+----------------------------------------+---------------+-----------------------------------------------------------+
create_keypairs_tests.py - CreateKeypairsTests
@@ -155,6 +170,14 @@ create_network_tests.py - CreateNetworkSuccessTests
| test_create_networks_same_name | 2 | Ensures that the OpenStackNetwork.create() method will not|
| | | create a network with the same name |
+---------------------------------------+---------------+-----------------------------------------------------------+
+| test_create_networks_router_admin_user| 2 | Ensures that the networks, subnets, and routers can be |
+| _to_new_project | | create created by an admin user and assigned to a new |
+| | | project ID |
++---------------------------------------+---------------+-----------------------------------------------------------+
+| test_create_networks_router_new_user | 2 | Ensures that the networks, subnets, and routers can be |
+| _to_admin_project | | create created by a new admin user and assigned to the |
+| | | 'admin' project ID |
++---------------------------------------+---------------+-----------------------------------------------------------+
create_router_tests.py - CreateRouterSuccessTests
-------------------------------------------------
@@ -165,6 +188,12 @@ create_router_tests.py - CreateRouterSuccessTests
| test_create_router_vanilla | 2 | Ensures that a router can be created via the |
| | | OpenStackRouter class with minimal settings |
+---------------------------------------+---------------+-----------------------------------------------------------+
+| test_create_router_admin_user_to_new | 2 | Ensures that a router can be created by an admin user and |
+| _project | | assigned to a new project |
++---------------------------------------+---------------+-----------------------------------------------------------+
+| test_create_router_new_user_to_admin | 2 | Ensures that a router can be created by a new user and |
+| _project | | assigned to the admin project |
++---------------------------------------+---------------+-----------------------------------------------------------+
| test_create_delete_router | 2 | Ensures that a router can be deleted via the |
| | | OpenStackRouter.clean() method |
+---------------------------------------+---------------+-----------------------------------------------------------+
@@ -194,6 +223,38 @@ create_router_tests.py - CreateRouterNegativeTests
| | | create a router to an external network that does not exist|
+----------------------------------------+---------------+-----------------------------------------------------------+
+create_stack_tests.py - CreateStackSuccessTests
+-----------------------------------------------
+
++---------------------------------------+---------------+-----------------------------------------------------------+
+| Test Name | Neutron API | Description |
++=======================================+===============+===========================================================+
+| test_create_stack_template_file | 2 | Ensures that a Heat stack can be created with a file-based|
+| | | Heat template file |
++---------------------------------------+---------------+-----------------------------------------------------------+
+| test_create_stack_template_dict | 2 | Ensures that a Heat stack can be created with a dictionary|
+| | | Heat template |
++---------------------------------------+---------------+-----------------------------------------------------------+
+| test_create_delete_stack | 2 | Ensures that a Heat stack can be created and deleted |
+| | | while having clean() called 2x without an exception |
++---------------------------------------+---------------+-----------------------------------------------------------+
+| test_create_same_stack | 2 | Ensures that a Heat stack with the same name cannot be |
+| | | created 2x |
++---------------------------------------+---------------+-----------------------------------------------------------+
+
+create_stack_tests.py - CreateStackNegativeTests
+--------------------------------------------------
+
++----------------------------------------+---------------+-----------------------------------------------------------+
+| Test Name | Neutron API | Description |
++========================================+===============+===========================================================+
+| test_missing_dependencies | 2 | Ensures that a Heat template fails to deploy when expected|
+| | | dependencies are missing |
++----------------------------------------+---------------+-----------------------------------------------------------+
+| test_bad_stack_file | 2 | Ensures that a Heat template fails to deploy when the Heat|
+| | | template file does not exist |
++----------------------------------------+---------------+-----------------------------------------------------------+
+
create_instance_tests.py - CreateInstanceSimpleTests
----------------------------------------------------
diff --git a/docs/how-to-use/LibraryUsage.rst b/docs/how-to-use/LibraryUsage.rst
index 9efb26f..0a137ba 100644
--- a/docs/how-to-use/LibraryUsage.rst
+++ b/docs/how-to-use/LibraryUsage.rst
@@ -34,12 +34,17 @@ attributes are listed below:
- image\_api\_version (Glance version 1 currently only validated)
- network\_api\_version (Neutron version 2 currently only validated)
- compute\_api\_version (Nova version 2 currently only validated)
+- heat\_api\_version (Heat version 1 currently only validated)
- user\_domain\_id (default='default')
- project\_domain\_id (default='default')
+- interface (default='admin', used to specify the endpoint type for keystone: public, admin, internal)
+- cacert (default=False, expected values T|F to denote server certificate verification, else value contains the path to an HTTPS certificate)
- proxy\_settings
- host (the HTTP proxy host)
- port (the HTTP proxy port)
+ - https\_host (the HTTPS proxy host, default value of host)
+ - https\_port (the HTTPS proxy port, default value of port)
- ssh\_proxy\_cmd (same as the value placed into ssh -o
ProxyCommand='<this config value>')
diff --git a/docs/how-to-use/Testing.rst b/docs/how-to-use/Testing.rst
index af66c28..92340ab 100644
--- a/docs/how-to-use/Testing.rst
+++ b/docs/how-to-use/Testing.rst
@@ -17,6 +17,7 @@ Execute the tests
| \* -s [optional - the proxy command used for SSH connections]
| \* -l [(default INFO) The log level]
| \* -u [optional - When set, the unit tests will be executed]
+| \* -st [optional - When set, the staging tests will be executed]
| \* -c [optional - When set, the connection tests will be executed]
| \* -a [optional - When set, the API tests will be executed]
| \* -i [optional - When set, the integration tests will be executed]
@@ -24,5 +25,7 @@ Execute the tests
if host running tests has access to the cloud's admin network]
| \* -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\"}']
+| \* -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/UnitTests.rst b/docs/how-to-use/UnitTests.rst
index efd6426..9da89be 100644
--- a/docs/how-to-use/UnitTests.rst
+++ b/docs/how-to-use/UnitTests.rst
@@ -24,68 +24,194 @@ FileUtilsTests
- testReadOSEnvFile - ensures that an OpenStack RC file can be properly
parsed
+ProxySettingsUnitTests
+----------------------
+
+Ensures that all required members are included when constructing a
+ProxySettings object
+
+OSCredsUnitTests
+----------------
+
+Ensures that all required members are included when constructing a
+OSCreds object
+
SecurityGroupRuleSettingsUnitTests
----------------------------------
Ensures that all required members are included when constructing a
SecurityGroupRuleSettings object
+SecurityGroupRuleDomainObjectTests
+----------------------------------
+
+Ensures that all required members are included when constructing a
+SecurityGroupRule domain object
+
SecurityGroupSettingsUnitTests
------------------------------
Ensures that all required members are included when constructing a
SecuirtyGroupSettings object
+SecurityGroupDomainObjectTests
+------------------------------
+
+Ensures that all required members are included when constructing a
+SecurityGroup domain object
+
ImageSettingsUnitTests
----------------------
Ensures that all required members are included when constructing a
ImageSettings object
+ImageDomainObjectTests
+----------------------
+
+Ensures that all required members are included when constructing a
+Image domain object
+
+FlavorSettingsUnitTests
+-----------------------
+
+Ensures that all required members are included when constructing a
+FlavorSettings object
+
+FlavorDomainObjectTests
+-----------------------
+
+Ensures that all required members are included when constructing a
+Flavor domain object
+
KeypairSettingsUnitTests
------------------------
Ensures that all required members are included when constructing a
KeypairSettings object
+KeypairDomainObjectTests
+------------------------
+
+Ensures that all required members are included when constructing a
+Keypair domain object
+
UserSettingsUnitTests
---------------------
Ensures that all required members are included when constructing a
UserSettings object
+UserDomainObjectTests
+---------------------
+
+Ensures that all required members are included when constructing a
+User domain object
+
ProjectSettingsUnitTests
------------------------
Ensures that all required members are included when constructing a
ProjectSettings object
+ProjectDomainObjectTests
+------------------------
+
+Ensures that all required members are included when constructing a
+Project domain object
+
+RoleDomainObjectTests
+---------------------
+
+Ensures that all required members are included when constructing a
+Role domain object
+
NetworkSettingsUnitTests
------------------------
Ensures that all required members are included when constructing a
NetworkSettings object
+NetworkObjectTests
+------------------
+
+Ensures that all required members are included when constructing a
+Network domain object
+
SubnetSettingsUnitTests
-----------------------
Ensures that all required members are included when constructing a
SubnetSettings object
+SubnetObjectTests
+-----------------
+
+Ensures that all required members are included when constructing a
+Subnet domain object
+
PortSettingsUnitTests
---------------------
Ensures that all required members are included when constructing a
PortSettings object
+PortDomainObjectTests
+---------------------
+
+Ensures that all required members are included when constructing a
+Port domain object
+
+RouterSettingsUnitTests
+-----------------------
+
+Ensures that all required members are included when constructing a
+RouterSettings object
+
+RouterDomainObjectTests
+-----------------------
+
+Ensures that all required members are included when constructing a
+Router domain object
+
+InterfaceRouterDomainObjectTests
+--------------------------------
+
+Ensures that all required members are included when constructing a
+InterfaceRouter domain object
+
+StackSettingsUnitTests
+----------------------
+
+Ensures that all required members are included when constructing a
+StackSettings object
+
+StackDomainObjectTests
+----------------------
+
+Ensures that all required members are included when constructing a
+Stack domain object
+
FloatingIpSettingsUnitTests
---------------------------
Ensures that all required members are included when constructing a
FloatingIpSettings object
+FloatingIpDomainObjectTests
+---------------------------
+
+Ensures that all required members are included when constructing a
+FloatingIp domain object
+
VmInstanceSettingsUnitTests
---------------------------
Ensures that all required members are included when constructing a
VmInstanceSettings object
+
+VmInstDomainObjectTests
+-----------------------
+
+Ensures that all required members are included when constructing a
+VmInst domain object
diff --git a/snaps/openstack/create_network.py b/snaps/openstack/create_network.py
index 4f27eec..2f26c43 100644
--- a/snaps/openstack/create_network.py
+++ b/snaps/openstack/create_network.py
@@ -190,7 +190,6 @@ class NetworkSettings:
if not self.name or len(self.name) < 1:
raise NetworkSettingsError('Name required for networks')
- raise NetworkSettingsError('Name required for networks')
def get_project_id(self, os_creds):
"""
@@ -203,8 +202,8 @@ class NetworkSettings:
else:
if self.project_name:
keystone = keystone_utils.keystone_client(os_creds)
- project = keystone_utils.get_project(keystone,
- self.project_name)
+ project = keystone_utils.get_project(
+ keystone=keystone, project_name=self.project_name)
if project:
return project.id
@@ -231,7 +230,7 @@ class NetworkSettings:
if self.project_name:
project_id = self.get_project_id(os_creds)
if project_id:
- out['project_id'] = project_id
+ out['tenant_id'] = project_id
else:
raise NetworkSettingsError(
'Could not find project ID for project named - ' +
@@ -345,12 +344,13 @@ class SubnetSettings:
out['name'] = self.name
if self.project_name:
keystone = keystone_utils.keystone_client(os_creds)
- project = keystone_utils.get_project(keystone, self.project_name)
+ project = keystone_utils.get_project(
+ keystone=keystone, project_name=self.project_name)
project_id = None
if project:
project_id = project.id
if project_id:
- out['project_id'] = project_id
+ out['tenant_id'] = project_id
else:
raise SubnetSettingsError(
'Could not find project ID for project named - ' +
@@ -492,7 +492,8 @@ class PortSettings:
project_id = None
if self.project_name:
keystone = keystone_utils.keystone_client(os_creds)
- project = keystone_utils.get_project(keystone, self.project_name)
+ project = keystone_utils.get_project(
+ keystone=keystone, project_name=self.project_name)
if project:
project_id = project.id
@@ -512,7 +513,7 @@ class PortSettings:
out['name'] = self.name
if self.project_name:
if project_id:
- out['project_id'] = project_id
+ out['tenant_id'] = project_id
else:
raise PortSettingsError(
'Could not find project ID for project named - ' +
diff --git a/snaps/openstack/create_router.py b/snaps/openstack/create_router.py
index e50009c..acf6602 100644
--- a/snaps/openstack/create_router.py
+++ b/snaps/openstack/create_router.py
@@ -238,12 +238,13 @@ class RouterSettings:
out['name'] = self.name
if self.project_name:
keystone = keystone_utils.keystone_client(os_creds)
- project = keystone_utils.get_project(keystone, self.project_name)
+ project = keystone_utils.get_project(
+ keystone=keystone, project_name=self.project_name)
project_id = None
if project:
project_id = project.id
if project_id:
- out['project_id'] = project_id
+ out['tenant_id'] = project_id
else:
raise RouterSettingsError(
'Could not find project ID for project named - ' +
diff --git a/snaps/openstack/create_security_group.py b/snaps/openstack/create_security_group.py
index 4291796..bde5d01 100644
--- a/snaps/openstack/create_security_group.py
+++ b/snaps/openstack/create_security_group.py
@@ -265,12 +265,13 @@ class SecurityGroupSettings:
if self.description:
out['description'] = self.description
if self.project_name:
- project = keystone_utils.get_project(keystone, self.project_name)
+ project = keystone_utils.get_project(
+ keystone=keystone, project_name=self.project_name)
project_id = None
if project:
project_id = project.id
if project_id:
- out['project_id'] = project_id
+ out['tenant_id'] = project_id
else:
raise SecurityGroupSettingsError(
'Could not find project ID for project named - ' +
diff --git a/snaps/openstack/tests/create_network_tests.py b/snaps/openstack/tests/create_network_tests.py
index 322d383..bd373f1 100644
--- a/snaps/openstack/tests/create_network_tests.py
+++ b/snaps/openstack/tests/create_network_tests.py
@@ -464,6 +464,66 @@ class CreateNetworkSuccessTests(OSIntegrationTestCase):
self.assertEqual(self.net_creator.get_network().id,
self.net_creator2.get_network().id)
+ def test_create_network_router_admin_user_to_new_project(self):
+ """
+ Tests the creation of an OpenStack network and router with the current
+ user to the admin project.
+ """
+ # Create Network/Subnet where the project names have been changed
+ admin_project_name = self.admin_os_creds.project_name
+ self.net_config.network_settings.project_name = admin_project_name
+ self.net_config.network_settings.subnet_settings[0].project_name = \
+ admin_project_name
+ self.net_creator = OpenStackNetwork(self.os_creds,
+ self.net_config.network_settings)
+ self.net_creator.create()
+
+ retrieved_net = neutron_utils.get_network(
+ self.neutron, self.net_config.network_settings.name)
+
+ self.assertEqual(self.net_creator.get_network().id, retrieved_net.id)
+
+ # Create Router
+ self.net_config.router_settings.project_name = admin_project_name
+ self.router_creator = create_router.OpenStackRouter(
+ self.os_creds, self.net_config.router_settings)
+ self.router_creator.create()
+
+ retrieved_router = neutron_utils.get_router_by_name(
+ self.neutron, self.router_creator.get_router().name)
+ self.assertEqual(
+ self.router_creator.get_router().id, retrieved_router.id)
+
+ def test_create_network_router_new_user_to_admin_project(self):
+ """
+ Tests the creation of an OpenStack network and router with the admin
+ user to the new project.
+ """
+ # Create Network/Subnet where the project names have been changed
+ new_project_name = self.os_creds.project_name
+ self.net_config.network_settings.project_name = new_project_name
+ self.net_config.network_settings.subnet_settings[0].project_name = \
+ new_project_name
+ self.net_creator = OpenStackNetwork(self.admin_os_creds,
+ self.net_config.network_settings)
+ self.net_creator.create()
+
+ retrieved_net = neutron_utils.get_network(
+ self.neutron, self.net_config.network_settings.name)
+
+ self.assertEqual(self.net_creator.get_network().id, retrieved_net.id)
+
+ # Create Router
+ self.net_config.router_settings.project_name = new_project_name
+ self.router_creator = create_router.OpenStackRouter(
+ self.admin_os_creds, self.net_config.router_settings)
+ self.router_creator.create()
+
+ retrieved_router = neutron_utils.get_router_by_name(
+ self.neutron, self.router_creator.get_router().name)
+ self.assertEqual(
+ self.router_creator.get_router().id, retrieved_router.id)
+
class CreateNetworkTypeTests(OSComponentTestCase):
"""
diff --git a/snaps/openstack/tests/create_router_tests.py b/snaps/openstack/tests/create_router_tests.py
index efa0993..6e10d66 100644
--- a/snaps/openstack/tests/create_router_tests.py
+++ b/snaps/openstack/tests/create_router_tests.py
@@ -21,7 +21,7 @@ from snaps.openstack.create_network import (
NetworkSettings, PortSettings)
from snaps.openstack.create_network import OpenStackNetwork
from snaps.openstack.create_router import (
- RouterSettings, RouterSettingsError, RouterCreationError)
+ RouterSettings, RouterSettingsError)
from snaps.openstack.tests.os_source_file_test import OSIntegrationTestCase
from snaps.openstack.utils import neutron_utils
@@ -169,6 +169,46 @@ class CreateRouterSuccessTests(OSIntegrationTestCase):
self.assertTrue(verify_router_attributes(
router, self.router_creator, ext_gateway=self.ext_net_name))
+ def test_create_router_admin_user_to_new_project(self):
+ """
+ Test creation of a most basic router with the admin user pointing
+ to the new project.
+ """
+ router_settings = RouterSettings(
+ name=self.guid + '-pub-router', external_gateway=self.ext_net_name,
+ project_name=self.os_creds.project_name)
+
+ self.router_creator = create_router.OpenStackRouter(
+ self.admin_os_creds, router_settings)
+ self.router_creator.create()
+
+ router = neutron_utils.get_router_by_name(self.neutron,
+ router_settings.name)
+ self.assertIsNotNone(router)
+
+ self.assertTrue(verify_router_attributes(
+ router, self.router_creator, ext_gateway=self.ext_net_name))
+
+ def test_create_router_new_user_to_admin_project(self):
+ """
+ Test creation of a most basic router with the new user pointing
+ to the admin project.
+ """
+ router_settings = RouterSettings(
+ name=self.guid + '-pub-router', external_gateway=self.ext_net_name,
+ project_name=self.admin_os_creds.project_name)
+
+ self.router_creator = create_router.OpenStackRouter(
+ self.os_creds, router_settings)
+ self.router_creator.create()
+
+ router = neutron_utils.get_router_by_name(self.neutron,
+ router_settings.name)
+ self.assertIsNotNone(router)
+
+ self.assertTrue(verify_router_attributes(
+ router, self.router_creator, ext_gateway=self.ext_net_name))
+
def test_create_delete_router(self):
"""
Test that clean() will not raise an exception if the router is deleted
@@ -257,14 +297,23 @@ class CreateRouterSuccessTests(OSIntegrationTestCase):
self.network_creator2.create()
port_settings = [
- create_network.PortSettings(name=self.guid + '-port1', ip_addrs=[
- {'subnet_name': network_settings1.subnet_settings[0].name,
- 'ip': static_gateway_ip1}],
- network_name=network_settings1.name),
- create_network.PortSettings(name=self.guid + '-port2', ip_addrs=[
- {'subnet_name': network_settings2.subnet_settings[0].name,
- 'ip': static_gateway_ip2}],
- network_name=network_settings2.name)]
+ create_network.PortSettings(
+ name=self.guid + '-port1',
+ ip_addrs=[{
+ 'subnet_name':
+ network_settings1.subnet_settings[0].name,
+ 'ip': static_gateway_ip1
+ }],
+ network_name=network_settings1.name,
+ project_name=self.os_creds.project_name),
+ create_network.PortSettings(
+ name=self.guid + '-port2',
+ ip_addrs=[{
+ 'subnet_name': network_settings2.subnet_settings[0].name,
+ 'ip': static_gateway_ip2
+ }],
+ network_name=network_settings2.name,
+ project_name=self.os_creds.project_name)]
router_settings = RouterSettings(name=self.guid + '-pub-router',
port_settings=port_settings)
@@ -293,14 +342,17 @@ class CreateRouterSuccessTests(OSIntegrationTestCase):
self.network_creator1.create()
port_settings = [
- create_network.PortSettings(name=self.guid + '-port1', ip_addrs=[
- {'subnet_name': network_settings.subnet_settings[0].name,
- 'ip': static_gateway_ip1}],
- network_name=network_settings.name)]
-
- router_settings = RouterSettings(name=self.guid + '-pub-router',
- external_gateway=self.ext_net_name,
- port_settings=port_settings)
+ create_network.PortSettings(
+ name=self.guid + '-port1',
+ ip_addrs=[{
+ 'subnet_name': network_settings.subnet_settings[0].name,
+ 'ip': static_gateway_ip1}],
+ network_name=network_settings.name,
+ project_name=self.os_creds.project_name)]
+
+ router_settings = RouterSettings(
+ name=self.guid + '-pub-router', external_gateway=self.ext_net_name,
+ port_settings=port_settings)
self.router_creator = create_router.OpenStackRouter(self.os_creds,
router_settings)
self.router_creator.create()
diff --git a/snaps/openstack/tests/create_security_group_tests.py b/snaps/openstack/tests/create_security_group_tests.py
index dd28d7d..7cae62b 100644
--- a/snaps/openstack/tests/create_security_group_tests.py
+++ b/snaps/openstack/tests/create_security_group_tests.py
@@ -16,12 +16,9 @@ import unittest
import uuid
from snaps.openstack import create_security_group
-from snaps.openstack.create_security_group import (SecurityGroupSettings,
- SecurityGroupRuleSettings,
- Direction, Ethertype,
- Protocol,
- SecurityGroupRuleSettingsError,
- SecurityGroupSettingsError)
+from snaps.openstack.create_security_group import (
+ SecurityGroupSettings, SecurityGroupRuleSettings, Direction, Ethertype,
+ Protocol, SecurityGroupRuleSettingsError, SecurityGroupSettingsError)
from snaps.openstack.tests import validation_utils
from snaps.openstack.tests.os_source_file_test import OSIntegrationTestCase
from snaps.openstack.utils import neutron_utils
@@ -212,6 +209,54 @@ class CreateSecurityGroupTests(OSIntegrationTestCase):
validation_utils.objects_equivalent(self.sec_grp_creator.get_rules(),
rules)
+ def test_create_group_admin_user_to_new_project(self):
+ """
+ Tests the creation of an OpenStack Security Group without custom rules.
+ """
+ # Create Image
+ sec_grp_settings = SecurityGroupSettings(
+ name=self.sec_grp_name, description='hello group',
+ project_name=self.admin_os_creds.project_name)
+ self.sec_grp_creator = create_security_group.OpenStackSecurityGroup(
+ self.os_creds, sec_grp_settings)
+ self.sec_grp_creator.create()
+
+ sec_grp = neutron_utils.get_security_group(self.neutron,
+ self.sec_grp_name)
+ self.assertIsNotNone(sec_grp)
+
+ validation_utils.objects_equivalent(
+ self.sec_grp_creator.get_security_group(), sec_grp)
+ rules = neutron_utils.get_rules_by_security_group(
+ self.neutron, self.sec_grp_creator.get_security_group())
+ self.assertEqual(len(self.sec_grp_creator.get_rules()), len(rules))
+ validation_utils.objects_equivalent(self.sec_grp_creator.get_rules(),
+ rules)
+
+ def test_create_group_new_user_to_admin_project(self):
+ """
+ Tests the creation of an OpenStack Security Group without custom rules.
+ """
+ # Create Image
+ sec_grp_settings = SecurityGroupSettings(
+ name=self.sec_grp_name, description='hello group',
+ project_name=self.os_creds.project_name)
+ self.sec_grp_creator = create_security_group.OpenStackSecurityGroup(
+ self.admin_os_creds, sec_grp_settings)
+ self.sec_grp_creator.create()
+
+ sec_grp = neutron_utils.get_security_group(self.neutron,
+ self.sec_grp_name)
+ self.assertIsNotNone(sec_grp)
+
+ validation_utils.objects_equivalent(
+ self.sec_grp_creator.get_security_group(), sec_grp)
+ rules = neutron_utils.get_rules_by_security_group(
+ self.neutron, self.sec_grp_creator.get_security_group())
+ self.assertEqual(len(self.sec_grp_creator.get_rules()), len(rules))
+ validation_utils.objects_equivalent(self.sec_grp_creator.get_rules(),
+ rules)
+
def test_create_delete_group(self):
"""
Tests the creation of an OpenStack Security Group without custom rules.
diff --git a/snaps/openstack/tests/os_source_file_test.py b/snaps/openstack/tests/os_source_file_test.py
index 2ccee3f..da474a2 100644
--- a/snaps/openstack/tests/os_source_file_test.py
+++ b/snaps/openstack/tests/os_source_file_test.py
@@ -31,6 +31,7 @@ dev_os_env_file = pkg_resources.resource_filename(
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
+
class OSComponentTestCase(unittest.TestCase):
def __init__(self, method_name='runTest', os_creds=None, ext_net_name=None,
@@ -82,7 +83,7 @@ class OSComponentTestCase(unittest.TestCase):
class OSIntegrationTestCase(OSComponentTestCase):
def __init__(self, method_name='runTest', os_creds=None, ext_net_name=None,
- use_keystone=False, flavor_metadata=None, image_metadata=None,
+ use_keystone=True, flavor_metadata=None, image_metadata=None,
log_level=logging.DEBUG):
"""
Super for integration tests requiring a connection to OpenStack