summaryrefslogtreecommitdiffstats
path: root/deploy/post/execute.py
diff options
context:
space:
mode:
Diffstat (limited to 'deploy/post/execute.py')
-rw-r--r--deploy/post/execute.py44
1 files changed, 28 insertions, 16 deletions
diff --git a/deploy/post/execute.py b/deploy/post/execute.py
index b9665e10..159f3b67 100644
--- a/deploy/post/execute.py
+++ b/deploy/post/execute.py
@@ -9,15 +9,17 @@
import os
import glance
+import argparse
+
import neutron
import nova
+from deploy.config.network import NetworkConfig
-def _config_admin_external_network():
- name = 'admin_external'
+def _config_external_network(ext_name):
body = {
'network': {
- 'name': name,
+ 'name': ext_name,
'admin_state_up': True,
'shared': False,
'provider:network_type': 'flat',
@@ -26,28 +28,34 @@ def _config_admin_external_network():
}
}
- return name, body
+ return body
-def _config_admin_external_subnet(nid):
+def _config_external_subnet(ext_id, network_conf):
return {
'subnets': [
{
- 'name': 'admin_external_subnet',
- 'cidr': '172.10.101.0/24',
+ 'name': '{}_subnet'.format(network_conf.ext_network_name),
+ 'cidr': network_conf.ext_cidr,
'ip_version': 4,
- 'network_id': nid,
- 'gateway_ip': '172.10.101.1',
- 'allocation_pools': [{
- 'start': '172.10.101.2',
- 'end': '172.10.101.12'
- }],
+ 'network_id': ext_id,
+ 'gateway_ip': network_conf.ext_gateway,
+ 'allocation_pools': network_conf.ext_ip_ranges,
'enable_dhcp': False
}
]
}
+def _create_external_network(network_file):
+ network_conf = NetworkConfig(network_file=network_file)
+ ext_name = network_conf.ext_network_name
+ neutronclient = neutron.Neutron()
+ ext_id = neutronclient.create_network(ext_name,
+ _config_external_network(ext_name))
+ neutronclient.create_subnet(_config_external_subnet(ext_id, network_conf))
+
+
def _create_flavor_m1_micro():
name = 'm1.micro'
novaclient = nova.Nova()
@@ -96,9 +104,13 @@ def _create_image_TestVM():
def main():
- neutronclient = neutron.Neutron()
- nid = neutronclient.create_network(*(_config_admin_external_network()))
- neutronclient.create_subnet(_config_admin_external_subnet(nid))
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-nw', '--network-file',
+ type=str,
+ required=True,
+ help='network configuration file')
+ args = parser.parse_args()
+ _create_external_network(args.network_file)
_create_flavor_m1_micro()
_create_image_TestVM()