summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorspisarski <s.pisarski@cablelabs.com>2017-11-17 16:07:40 -0700
committerspisarski <s.pisarski@cablelabs.com>2017-11-20 12:52:10 -0700
commita82209830309354c5bdc7e8b885c51df42c731d1 (patch)
tree8526779a6add5ff3dae7562b9b525231032f0a51 /examples
parent1d7f4a18cf4a070570beccbb46303f5822840c41 (diff)
Refactoring of NetworkSettings to extend NetworkConfig
This also includes SubnetSettings extending to SubnetConfig and PortSettings extenting to Portconfig and neutron_utils have a runtime cyclical dependency. This patch reduces this dependency and deprecates the NetworkSettings, SubnetSettings, and PortSettings classes. JIRA: SNAPS-220 Change-Id: I996d73d9b910c075a6511a423f01d966f5b6fb74 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/demo.py33
-rw-r--r--examples/launch.py8
2 files changed, 25 insertions, 16 deletions
diff --git a/examples/demo.py b/examples/demo.py
index 8837bd2..c888d7b 100644
--- a/examples/demo.py
+++ b/examples/demo.py
@@ -5,11 +5,14 @@ logging.basicConfig(level=logging.INFO)
from snaps.openstack.os_credentials import OSCreds, ProxySettings
-proxy_settings = ProxySettings(host='10.197.123.27', port='3128',
- ssh_proxy_cmd='/usr/local/bin/corkscrew 10.197.123.27 3128 %h %p')
+proxy_settings = ProxySettings(
+ host='10.197.123.27', port='3128',
+ ssh_proxy_cmd='/usr/local/bin/corkscrew 10.197.123.27 3128 %h %p')
-os_creds = OSCreds(username='admin', password='cable123', auth_url='http://192.168.67.10:5000/v2.0/',
- project_name='admin', proxy_settings=proxy_settings)
+os_creds = OSCreds(
+ username='admin', password='cable123',
+ auth_url='http://192.168.67.10:5000/v2.0/', project_name='admin',
+ proxy_settings=proxy_settings)
# Images
@@ -25,10 +28,12 @@ image.create()
# Network
-from snaps.openstack.create_network import NetworkSettings, SubnetSettings, OpenStackNetwork
+from snaps.config.network import NetworkConfig, SubnetConfig
+from snaps.openstack.create_network import OpenStackNetwork
-subnet_settings = SubnetSettings(name='test-subnet', cidr='10.0.0.1/24')
-network_settings = NetworkSettings(name='test-net', subnet_settings=[subnet_settings])
+subnet_settings = SubnetConfig(name='test-subnet', cidr='10.0.0.1/24')
+network_settings = NetworkConfig(
+ name='test-net', subnet_settings=[subnet_settings])
network = OpenStackNetwork(os_creds, network_settings)
network.create()
@@ -42,11 +47,15 @@ flavor = OpenStackFlavor(os_creds, flavor_settings)
flavor.create()
# Instances
-from snaps.openstack.create_network import PortSettings
-from snaps.openstack.create_instance import VmInstanceSettings, OpenStackVmInstance
-
-port_settings = PortSettings(name='test-port', network_name=network_settings.name)
-instance_settings = VmInstanceSettings(name='test-inst', flavor=flavor_settings.name, port_settings=[port_settings])
+from snaps.config.network import PortConfig
+from snaps.openstack.create_instance import (
+ VmInstanceSettings, OpenStackVmInstance)
+
+port_settings = PortConfig(
+ name='test-port', network_name=network_settings.name)
+instance_settings = VmInstanceSettings(
+ name='test-inst', flavor=flavor_settings.name,
+ port_settings=[port_settings])
vm_inst = OpenStackVmInstance(os_creds, instance_settings, image_settings)
vm_inst.create(block=True)
diff --git a/examples/launch.py b/examples/launch.py
index b0311e6..9320512 100644
--- a/examples/launch.py
+++ b/examples/launch.py
@@ -29,6 +29,7 @@ from snaps import file_utils
from snaps.config.flavor import FlavorConfig
from snaps.config.image import ImageConfig
from snaps.config.keypair import KeypairConfig
+from snaps.config.network import PortConfig, NetworkConfig
from snaps.config.project import ProjectConfig
from snaps.config.qos import QoSConfig
from snaps.config.router import RouterConfig
@@ -39,8 +40,7 @@ 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 OpenStackKeypair
-from snaps.openstack.create_network import (
- PortSettings, NetworkSettings, OpenStackNetwork)
+from snaps.openstack.create_network import OpenStackNetwork
from snaps.openstack.create_project import OpenStackProject
from snaps.openstack.create_qos import OpenStackQoS
from snaps.openstack.create_router import OpenStackRouter
@@ -152,7 +152,7 @@ def __parse_ports_config(config):
"""
out = list()
for port_config in config:
- out.append(PortSettings(**port_config.get('port')))
+ out.append(PortConfig(**port_config.get('port')))
return out
@@ -673,7 +673,7 @@ def main(arguments):
# Create networks
creators.append(__create_instances(
- os_creds_dict, OpenStackNetwork, NetworkSettings,
+ os_creds_dict, OpenStackNetwork, NetworkConfig,
os_config.get('networks'), 'network', clean, users_dict))
# Create routers