summaryrefslogtreecommitdiffstats
path: root/snaps/openstack/utils
diff options
context:
space:
mode:
Diffstat (limited to 'snaps/openstack/utils')
-rw-r--r--snaps/openstack/utils/neutron_utils.py4
-rw-r--r--snaps/openstack/utils/settings_utils.py31
-rw-r--r--snaps/openstack/utils/tests/heat_utils_tests.py2
-rw-r--r--snaps/openstack/utils/tests/neutron_utils_tests.py64
-rw-r--r--snaps/openstack/utils/tests/nova_utils_tests.py11
-rw-r--r--snaps/openstack/utils/tests/settings_utils_tests.py31
6 files changed, 71 insertions, 72 deletions
diff --git a/snaps/openstack/utils/neutron_utils.py b/snaps/openstack/utils/neutron_utils.py
index ec8daff..b59f811 100644
--- a/snaps/openstack/utils/neutron_utils.py
+++ b/snaps/openstack/utils/neutron_utils.py
@@ -109,7 +109,7 @@ def get_network(neutron, network_settings=None, network_name=None,
else the query will use just the name from the network_name parameter.
When the project_id is included, that will be added to the query filter.
:param neutron: the client
- :param network_settings: the NetworkSettings object used to create filter
+ :param network_settings: the NetworkConfig object used to create filter
:param network_name: the name of the network to retrieve
:param project_id: the id of the network's project
:return: a SNAPS-OO Network domain object
@@ -480,7 +480,7 @@ def get_port(neutron, port_settings=None, port_name=None):
"""
Returns the first port object (dictionary) found for the given query
:param neutron: the client
- :param port_settings: the PortSettings object used for generating the query
+ :param port_settings: the PortConfig object used for generating the query
:param port_name: if port_settings is None, this name is the value to place
into the query
:return: a SNAPS-OO Port domain object
diff --git a/snaps/openstack/utils/settings_utils.py b/snaps/openstack/utils/settings_utils.py
index 80dfc84..ab26d3d 100644
--- a/snaps/openstack/utils/settings_utils.py
+++ b/snaps/openstack/utils/settings_utils.py
@@ -17,35 +17,34 @@ import uuid
from snaps import file_utils
from snaps.config.flavor import FlavorConfig
from snaps.config.keypair import KeypairConfig
+from snaps.config.network import SubnetConfig, PortConfig, NetworkConfig
from snaps.config.router import RouterConfig
from snaps.config.volume import VolumeConfig
from snaps.config.volume_type import (
ControlLocation, VolumeTypeEncryptionConfig, VolumeTypeConfig)
from snaps.openstack.create_instance import (
VmInstanceSettings, FloatingIpSettings)
-from snaps.openstack.create_network import (
- PortSettings, SubnetSettings, NetworkSettings)
from snaps.openstack.create_security_group import (
SecurityGroupSettings, SecurityGroupRuleSettings)
from snaps.openstack.utils import (
neutron_utils, nova_utils, heat_utils, glance_utils)
-def create_network_settings(neutron, network):
+def create_network_config(neutron, network):
"""
- Returns a NetworkSettings object
+ Returns a NetworkConfig object
:param neutron: the neutron client
:param network: a SNAPS-OO Network domain object
:return:
"""
- return NetworkSettings(
+ return NetworkConfig(
name=network.name, network_type=network.type,
- subnet_settings=create_subnet_settings(neutron, network))
+ subnet_settings=create_subnet_config(neutron, network))
def create_security_group_settings(neutron, security_group):
"""
- Returns a NetworkSettings object
+ Returns a NetworkConfig object
:param neutron: the neutron client
:param security_group: a SNAPS-OO SecurityGroup domain object
:return:
@@ -67,9 +66,9 @@ def create_security_group_settings(neutron, security_group):
rule_settings=rule_settings)
-def create_subnet_settings(neutron, network):
+def create_subnet_config(neutron, network):
"""
- Returns a list of SubnetSettings objects for a given network
+ Returns a list of SubnetConfig objects for a given network
:param neutron: the OpenStack neutron client
:param network: the SNAPS-OO Network domain object
:return: a list
@@ -90,7 +89,7 @@ def create_subnet_settings(neutron, network):
kwargs['host_routes'] = subnet.host_routes
kwargs['ipv6_ra_mode'] = subnet.ipv6_ra_mode
kwargs['ipv6_address_mode'] = subnet.ipv6_address_mode
- out.append(SubnetSettings(**kwargs))
+ out.append(SubnetConfig(**kwargs))
return out
@@ -135,7 +134,7 @@ def create_router_settings(neutron, router):
ports_tuple_list.append((network, ip_list))
- port_settings = __create_port_settings(neutron, ports_tuple_list)
+ port_settings = __create_port_config(neutron, ports_tuple_list)
filtered_settings = list()
for port_setting in port_settings:
@@ -231,7 +230,7 @@ def create_keypair_settings(heat_cli, stack, keypair, pk_output_key):
def create_vm_inst_settings(nova, neutron, server):
"""
- Returns a NetworkSettings object
+ Returns a NetworkConfig object
:param nova: the nova client
:param neutron: the neutron client
:param server: a SNAPS-OO VmInst domain object
@@ -250,7 +249,7 @@ def create_vm_inst_settings(nova, neutron, server):
if network:
net_tuples.append((network, ips))
- kwargs['port_settings'] = __create_port_settings(
+ kwargs['port_settings'] = __create_port_config(
neutron, net_tuples)
kwargs['security_group_names'] = server.sec_grp_names
kwargs['floating_ip_settings'] = __create_floatingip_settings(
@@ -259,7 +258,7 @@ def create_vm_inst_settings(nova, neutron, server):
return VmInstanceSettings(**kwargs)
-def __create_port_settings(neutron, networks):
+def __create_port_config(neutron, networks):
"""
Returns a list of port settings based on the networks parameter
:param neutron: the neutron client
@@ -288,7 +287,7 @@ def __create_port_settings(neutron, networks):
kwargs['allowed_address_pairs'] = port.allowed_address_pairs
kwargs['admin_state_up'] = port.admin_state_up
kwargs['ip_addrs'] = ip_addrs
- out.append(PortSettings(**kwargs))
+ out.append(PortConfig(**kwargs))
return out
@@ -298,7 +297,7 @@ def __create_floatingip_settings(neutron, port_settings):
Returns a list of FloatingIPSettings objects as they pertain to an
existing deployed server instance
:param neutron: the neutron client
- :param port_settings: list of SNAPS-OO PortSettings objects
+ :param port_settings: list of SNAPS-OO PortConfig objects
:return: a list of FloatingIPSettings objects or an empty list if no
floating IPs have been created
"""
diff --git a/snaps/openstack/utils/tests/heat_utils_tests.py b/snaps/openstack/utils/tests/heat_utils_tests.py
index d90fed4..2f1e7cc 100644
--- a/snaps/openstack/utils/tests/heat_utils_tests.py
+++ b/snaps/openstack/utils/tests/heat_utils_tests.py
@@ -374,7 +374,7 @@ class HeatUtilsCreateComplexStackTests(OSComponentTestCase):
self.assertEqual(1, len(networks))
self.assertEqual(self.network_name, networks[0].name)
- network_settings = settings_utils.create_network_settings(
+ network_settings = settings_utils.create_network_config(
neutron, networks[0])
self.assertIsNotNone(network_settings)
self.assertEqual(self.network_name, network_settings.name)
diff --git a/snaps/openstack/utils/tests/neutron_utils_tests.py b/snaps/openstack/utils/tests/neutron_utils_tests.py
index 9022578..44bc59f 100644
--- a/snaps/openstack/utils/tests/neutron_utils_tests.py
+++ b/snaps/openstack/utils/tests/neutron_utils_tests.py
@@ -16,11 +16,9 @@ import uuid
from neutronclient.common.exceptions import NotFound, BadRequest
-from snaps.openstack import create_router
-from snaps.openstack.create_network import NetworkSettings, SubnetSettings, \
- PortSettings
-from snaps.openstack.create_security_group import SecurityGroupSettings, \
- SecurityGroupRuleSettings, Direction
+from snaps.config.network import NetworkConfig, SubnetConfig, PortConfig
+from snaps.openstack.create_security_group import (
+ SecurityGroupSettings, SecurityGroupRuleSettings, Direction)
from snaps.openstack.tests import openstack_tests
from snaps.openstack.tests import validation_utils
from snaps.openstack.tests.os_source_file_test import OSComponentTestCase
@@ -123,7 +121,7 @@ class NeutronUtilsNetworkTests(OSComponentTestCase):
with self.assertRaises(Exception):
self.network = neutron_utils.create_network(
self.neutron, self.os_creds,
- network_settings=NetworkSettings(name=''))
+ network_settings=NetworkConfig(name=''))
def test_create_network_null_name(self):
"""
@@ -133,7 +131,7 @@ class NeutronUtilsNetworkTests(OSComponentTestCase):
with self.assertRaises(Exception):
self.network = neutron_utils.create_network(
self.neutron, self.os_creds,
- network_settings=NetworkSettings())
+ network_settings=NetworkConfig())
class NeutronUtilsSubnetTests(OSComponentTestCase):
@@ -198,7 +196,7 @@ class NeutronUtilsSubnetTests(OSComponentTestCase):
self.neutron, self.net_config.network_settings.name, True))
with self.assertRaises(Exception):
- SubnetSettings(cidr=self.net_config.subnet_cidr)
+ SubnetConfig(cidr=self.net_config.subnet_cidr)
def test_create_subnet_empty_name(self):
"""
@@ -274,12 +272,12 @@ class NeutronUtilsIPv6Tests(OSComponentTestCase):
Tests the neutron_utils.create_network() with an IPv6 subnet where DHCP
is True and IPv6 modes are slaac
"""
- sub_setting = SubnetSettings(
+ sub_setting = SubnetConfig(
name=self.guid + '-subnet', cidr='1:1:0:0:0:0:0:0/64',
ip_version=6, dns_nameservers=['2620:0:ccc:0:0:0:0:2'],
gateway_ip='1:1:0:0:0:0:0:1', start='1:1::ff', end='1:1::ffff',
enable_dhcp=True, ipv6_ra_mode='slaac', ipv6_address_mode='slaac')
- self.network_settings = NetworkSettings(
+ self.network_settings = NetworkConfig(
name=self.guid + '-net', subnet_settings=[sub_setting])
self.network = neutron_utils.create_network(
@@ -310,13 +308,13 @@ class NeutronUtilsIPv6Tests(OSComponentTestCase):
Tests the neutron_utils.create_network() with an IPv6 subnet where DHCP
is True and IPv6 modes are stateful
"""
- sub_setting = SubnetSettings(
+ sub_setting = SubnetConfig(
name=self.guid + '-subnet', cidr='1:1:0:0:0:0:0:0/64',
ip_version=6, dns_nameservers=['2620:0:ccc:0:0:0:0:2'],
gateway_ip='1:1:0:0:0:0:0:1', start='1:1::ff', end='1:1::ffff',
enable_dhcp=True, ipv6_ra_mode='dhcpv6-stateful',
ipv6_address_mode='dhcpv6-stateful')
- self.network_settings = NetworkSettings(
+ self.network_settings = NetworkConfig(
name=self.guid + '-net', subnet_settings=[sub_setting])
self.network = neutron_utils.create_network(
@@ -348,13 +346,13 @@ class NeutronUtilsIPv6Tests(OSComponentTestCase):
Tests the neutron_utils.create_network() when DHCP is enabled and
the RA and address modes are both 'slaac'
"""
- sub_setting = SubnetSettings(
+ sub_setting = SubnetConfig(
name=self.guid + '-subnet', cidr='1:1:0:0:0:0:0:0/64',
ip_version=6, dns_nameservers=['2620:0:ccc:0:0:0:0:2'],
gateway_ip='1:1:0:0:0:0:0:1', start='1:1::ff', end='1:1::ffff',
enable_dhcp=True, ipv6_ra_mode='dhcpv6-stateless',
ipv6_address_mode='dhcpv6-stateless')
- self.network_settings = NetworkSettings(
+ self.network_settings = NetworkConfig(
name=self.guid + '-net', subnet_settings=[sub_setting])
self.network = neutron_utils.create_network(
@@ -386,12 +384,12 @@ class NeutronUtilsIPv6Tests(OSComponentTestCase):
Tests the neutron_utils.create_network() for a BadRequest when
DHCP is not enabled and the RA and address modes are both 'slaac'
"""
- sub_setting = SubnetSettings(
+ sub_setting = SubnetConfig(
name=self.guid + '-subnet', cidr='1:1:0:0:0:0:0:0/64',
ip_version=6, dns_nameservers=['2620:0:ccc:0:0:0:0:2'],
gateway_ip='1:1:0:0:0:0:0:1', start='1:1::ff', end='1:1::ffff',
enable_dhcp=False, ipv6_ra_mode='slaac', ipv6_address_mode='slaac')
- self.network_settings = NetworkSettings(
+ self.network_settings = NetworkConfig(
name=self.guid + '-net', subnet_settings=[sub_setting])
with self.assertRaises(BadRequest):
@@ -404,10 +402,10 @@ class NeutronUtilsIPv6Tests(OSComponentTestCase):
with an invalid start IP to ensure Neutron assigns it the smallest IP
possible
"""
- sub_setting = SubnetSettings(
+ sub_setting = SubnetConfig(
name=self.guid + '-subnet', cidr='1:1::/48', ip_version=6,
start='foo')
- self.network_settings = NetworkSettings(
+ self.network_settings = NetworkConfig(
name=self.guid + '-net', subnet_settings=[sub_setting])
self.network = neutron_utils.create_network(
@@ -423,10 +421,10 @@ class NeutronUtilsIPv6Tests(OSComponentTestCase):
with an invalid end IP to ensure Neutron assigns it the largest IP
possible
"""
- sub_setting = SubnetSettings(
+ sub_setting = SubnetConfig(
name=self.guid + '-subnet', cidr='1:1::/48', ip_version=6,
end='bar')
- self.network_settings = NetworkSettings(
+ self.network_settings = NetworkConfig(
name=self.guid + '-net', subnet_settings=[sub_setting])
self.network = neutron_utils.create_network(
@@ -441,9 +439,9 @@ class NeutronUtilsIPv6Tests(OSComponentTestCase):
Tests the neutron_utils.create_network() for a BadRequest when
the subnet CIDR is invalid
"""
- sub_setting = SubnetSettings(
+ sub_setting = SubnetConfig(
name=self.guid + '-subnet', cidr='1:1:1:/48', ip_version=6)
- self.network_settings = NetworkSettings(
+ self.network_settings = NetworkConfig(
name=self.guid + '-net', subnet_settings=[sub_setting])
with self.assertRaises(BadRequest):
@@ -455,10 +453,10 @@ class NeutronUtilsIPv6Tests(OSComponentTestCase):
Tests the neutron_utils.create_network() for a BadRequest when
the subnet gateway IP is invalid
"""
- sub_setting = SubnetSettings(
+ sub_setting = SubnetConfig(
name=self.guid + '-subnet', cidr='1:1::/48', ip_version=6,
gateway_ip='1:2::1')
- self.network_settings = NetworkSettings(
+ self.network_settings = NetworkConfig(
name=self.guid + '-net', subnet_settings=[sub_setting])
with self.assertRaises(BadRequest):
@@ -470,10 +468,10 @@ class NeutronUtilsIPv6Tests(OSComponentTestCase):
Tests the neutron_utils.create_network() for a BadRequest when
the DNS IP is invalid
"""
- sub_setting = SubnetSettings(
+ sub_setting = SubnetConfig(
name=self.guid + '-subnet', cidr='1:1::/48', ip_version=6,
dns_nameservers=['foo'])
- self.network_settings = NetworkSettings(
+ self.network_settings = NetworkConfig(
name=self.guid + '-net', subnet_settings=[sub_setting])
with self.assertRaises(BadRequest):
@@ -657,7 +655,7 @@ class NeutronUtilsRouterTests(OSComponentTestCase):
self.neutron, subnet_setting.name, subnet_setting.cidr, True))
self.port = neutron_utils.create_port(
- self.neutron, self.os_creds, PortSettings(
+ self.neutron, self.os_creds, PortConfig(
name=self.port_name,
ip_addrs=[{
'subnet_name': subnet_setting.name,
@@ -681,7 +679,7 @@ class NeutronUtilsRouterTests(OSComponentTestCase):
subnet_setting.cidr, True))
self.port = neutron_utils.create_port(
- self.neutron, self.os_creds, PortSettings(
+ self.neutron, self.os_creds, PortConfig(
name=self.port_name,
network_name=self.net_config.network_settings.name,
ip_addrs=[{
@@ -706,7 +704,7 @@ class NeutronUtilsRouterTests(OSComponentTestCase):
self.port = neutron_utils.create_port(
self.neutron, self.os_creds,
- PortSettings(
+ PortConfig(
network_name=self.net_config.network_settings.name,
ip_addrs=[{
'subnet_name': subnet_setting.name,
@@ -723,7 +721,7 @@ class NeutronUtilsRouterTests(OSComponentTestCase):
with self.assertRaises(Exception):
self.port = neutron_utils.create_port(
self.neutron, self.os_creds,
- PortSettings(
+ PortConfig(
name=self.port_name,
network_name=self.net_config.network_settings.name,
ip_addrs=[{
@@ -751,7 +749,7 @@ class NeutronUtilsRouterTests(OSComponentTestCase):
with self.assertRaises(Exception):
self.port = neutron_utils.create_port(
self.neutron, self.os_creds,
- PortSettings(
+ PortConfig(
name=self.port_name,
network_name=self.net_config.network_settings.name,
ip_addrs=[{
@@ -777,7 +775,7 @@ class NeutronUtilsRouterTests(OSComponentTestCase):
with self.assertRaises(Exception):
self.port = neutron_utils.create_port(
self.neutron, self.os_creds,
- PortSettings(
+ PortConfig(
name=self.port_name,
network_name=self.net_config.network_settings.name,
ip_addrs=[{
@@ -803,7 +801,7 @@ class NeutronUtilsRouterTests(OSComponentTestCase):
with self.assertRaises(Exception):
self.port = neutron_utils.create_port(
self.neutron, self.os_creds,
- PortSettings(
+ PortConfig(
name=self.port_name,
network_name=self.net_config.network_settings.name,
ip_addrs=[{
diff --git a/snaps/openstack/utils/tests/nova_utils_tests.py b/snaps/openstack/utils/tests/nova_utils_tests.py
index 6335ed9..6d4bc3c 100644
--- a/snaps/openstack/utils/tests/nova_utils_tests.py
+++ b/snaps/openstack/utils/tests/nova_utils_tests.py
@@ -19,14 +19,15 @@ import uuid
import os
from snaps import file_utils
-from snaps.config.volume import VolumeConfig
from snaps.config.flavor import FlavorConfig
+from snaps.config.network import PortConfig
+from snaps.config.volume import VolumeConfig
from snaps.openstack import create_instance
from snaps.openstack.create_flavor import OpenStackFlavor
from snaps.openstack.create_image import OpenStackImage
from snaps.openstack.create_instance import (
VmInstanceSettings, OpenStackVmInstance)
-from snaps.openstack.create_network import OpenStackNetwork, PortSettings
+from snaps.openstack.create_network import OpenStackNetwork
from snaps.openstack.create_volume import OpenStackVolume
from snaps.openstack.tests import openstack_tests
from snaps.openstack.tests.os_source_file_test import OSComponentTestCase
@@ -259,8 +260,8 @@ class NovaUtilsInstanceTests(OSComponentTestCase):
name=guid + '-flavor-name', ram=256, disk=10, vcpus=1))
self.flavor_creator.create()
- port_settings = PortSettings(name=guid + '-port',
- network_name=network_settings.name)
+ port_settings = PortConfig(
+ name=guid + '-port', network_name=network_settings.name)
self.port = neutron_utils.create_port(
self.neutron, self.os_creds, port_settings)
@@ -382,7 +383,7 @@ class NovaUtilsInstanceVolumeTests(OSComponentTestCase):
self.os_creds, volume_settings)
self.volume_creator.create(block=True)
- port_settings = PortSettings(
+ port_settings = PortConfig(
name=guid + '-port', network_name=network_settings.name)
instance_settings = VmInstanceSettings(
name=guid + '-vm_inst',
diff --git a/snaps/openstack/utils/tests/settings_utils_tests.py b/snaps/openstack/utils/tests/settings_utils_tests.py
index 1157f2c..b34e68b 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.network import SubnetConfig, NetworkConfig, PortConfig
from snaps.config.flavor import FlavorConfig
from snaps.config.keypair import KeypairConfig
from snaps.config.qos import Consumer
@@ -27,8 +28,8 @@ from snaps.domain.volume import (
from snaps.openstack import (
create_image, create_network, create_router, create_flavor,
create_keypairs, create_instance)
-from snaps.openstack.create_network import (
- NetworkSettings, OpenStackNetwork, SubnetSettings)
+from snaps.openstack.create_qos import Consumer
+from snaps.openstack.create_network import OpenStackNetwork
from snaps.openstack.create_security_group import (
SecurityGroupRuleSettings, Direction, Protocol, OpenStackSecurityGroup,
SecurityGroupSettings)
@@ -44,7 +45,7 @@ logger = logging.getLogger('nova_utils_tests')
class SettingsUtilsNetworkingTests(OSComponentTestCase):
"""
- Tests the ability to reverse engineer NetworkSettings objects from existing
+ Tests the ability to reverse engineer NetworkConfig objects from existing
networks deployed to OpenStack
"""
@@ -70,16 +71,16 @@ class SettingsUtilsNetworkingTests(OSComponentTestCase):
def test_derive_net_settings_no_subnet(self):
"""
- Validates the utility function settings_utils#create_network_settings
- returns an acceptable NetworkSettings object and ensures that the
+ Validates the utility function settings_utils#create_network_config
+ returns an acceptable NetworkConfig object and ensures that the
new settings object will not cause the new OpenStackNetwork instance
to create another network
"""
- net_settings = NetworkSettings(name=self.network_name)
+ net_settings = NetworkConfig(name=self.network_name)
self.net_creator = OpenStackNetwork(self.os_creds, net_settings)
network = self.net_creator.create()
- derived_settings = settings_utils.create_network_settings(
+ derived_settings = settings_utils.create_network_config(
self.neutron, network)
self.assertIsNotNone(derived_settings)
@@ -97,18 +98,18 @@ class SettingsUtilsNetworkingTests(OSComponentTestCase):
def test_derive_net_settings_two_subnets(self):
"""
- Validates the utility function settings_utils#create_network_settings
- returns an acceptable NetworkSettings object
+ Validates the utility function settings_utils#create_network_config
+ returns an acceptable NetworkConfig object
"""
subnet_settings = list()
- subnet_settings.append(SubnetSettings(name='sub1', cidr='10.0.0.0/24'))
- subnet_settings.append(SubnetSettings(name='sub2', cidr='10.0.1.0/24'))
- net_settings = NetworkSettings(name=self.network_name,
- subnet_settings=subnet_settings)
+ subnet_settings.append(SubnetConfig(name='sub1', cidr='10.0.0.0/24'))
+ subnet_settings.append(SubnetConfig(name='sub2', cidr='10.0.1.0/24'))
+ net_settings = NetworkConfig(
+ name=self.network_name, subnet_settings=subnet_settings)
self.net_creator = OpenStackNetwork(self.os_creds, net_settings)
network = self.net_creator.create()
- derived_settings = settings_utils.create_network_settings(
+ derived_settings = settings_utils.create_network_config(
self.neutron, network)
self.assertIsNotNone(derived_settings)
@@ -233,7 +234,7 @@ class SettingsUtilsVmInstTests(OSComponentTestCase):
# Create instance
ports_settings = list()
ports_settings.append(
- create_network.PortSettings(
+ PortConfig(
name=self.port_1_name,
network_name=self.pub_net_config.network_settings.name))