From a82209830309354c5bdc7e8b885c51df42c731d1 Mon Sep 17 00:00:00 2001 From: spisarski Date: Fri, 17 Nov 2017 16:07:40 -0700 Subject: 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 --- examples/demo.py | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'examples/demo.py') 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) -- cgit 1.2.3-korg