summaryrefslogtreecommitdiffstats
path: root/apex/network/network_data.py
diff options
context:
space:
mode:
authorTim Rozet <trozet@redhat.com>2017-09-12 17:32:56 -0400
committerTim Rozet <trozet@redhat.com>2017-11-06 04:35:02 +0000
commitb3c610b205f88dddb02cdac39638c52eafaaf82c (patch)
tree4826027e2d968e61c8024d972f3665ff3a8a09d7 /apex/network/network_data.py
parent3c7556eb0734706f28588fb952eedea2d424c6d2 (diff)
Adds ability to deploy from upstream openstack
To deploy with upstream openstack branch, use new deploy setting 'os_version'. A default scenario file for nosdn with pike has been included in this patch. If 'os_version' is a version other than the default version for this OPNFV release, then upstream is used. In order to use upstream with the current OS version use '--upstream' argument to the deploy command, to force an upstream deployment. Also include '-e upstream-environment.yaml' to use default upstream deployment settings. Supports nosdn and odl-nofeature deployments. Change-Id: Ic07e308827b449637b4e86cdd086434e4de2fb69 Signed-off-by: Tim Rozet <trozet@redhat.com>
Diffstat (limited to 'apex/network/network_data.py')
-rw-r--r--apex/network/network_data.py104
1 files changed, 104 insertions, 0 deletions
diff --git a/apex/network/network_data.py b/apex/network/network_data.py
new file mode 100644
index 00000000..1177af09
--- /dev/null
+++ b/apex/network/network_data.py
@@ -0,0 +1,104 @@
+##############################################################################
+# Copyright (c) 2017 Tim Rozet (trozet@redhat.com) and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+import copy
+import logging
+import pprint
+
+from apex.common import utils
+from apex.common.constants import (
+ ADMIN_NETWORK,
+ TENANT_NETWORK,
+ STORAGE_NETWORK,
+ EXTERNAL_NETWORK,
+ API_NETWORK
+)
+from apex import NetworkSettings
+
+
+class NetworkDataException(Exception):
+ pass
+
+
+def create_network_data(ns, target=None):
+ """
+ Creates network data file for deployments
+ :param ns: Network Settings
+ :param target: Target file to write
+ :return: list of networks and properties
+ """
+ network_data = list()
+ if not isinstance(ns, NetworkSettings):
+ raise NetworkDataException('Invalid network settings given')
+
+ nets = ns['networks']
+
+ # TODO(trozet) change this all to be dynamic after TripleO bug
+ # https://bugs.launchpad.net/tripleo/+bug/1720849 is fixed
+
+ for net in nets.keys():
+ if net == ADMIN_NETWORK:
+ # we dont need to add ctlplane network to network data
+ continue
+ elif net == EXTERNAL_NETWORK:
+ network = nets[net][0]
+ net_name = net.title()
+ net_lower = net.lower()
+ elif net == API_NETWORK:
+ network = nets[net]
+ net_name = 'InternalApi'
+ net_lower = 'internal_api'
+ else:
+ network = nets[net]
+ net_name = net.title()
+ net_lower = net.lower()
+ # TODO(trozet): add ipv6 support
+ tmp_net = {'name': net_name,
+ 'name_lower': net_lower,
+ 'vip': net != TENANT_NETWORK,
+ 'enabled': net in ns.enabled_network_list}
+ if 'gateway' in network:
+ tmp_net['gateway_ip'] = str(network['gateway'])
+ if 'overcloud_ip_range' in network:
+ net_range = network['overcloud_ip_range']
+ tmp_net['allocation_pools'] = [{'start': str(net_range[0]),
+ 'end': str(net_range[1])}]
+ elif tmp_net['enabled']:
+ logging.error("overcloud ip range is missing and must be provided "
+ "in network settings when network is enabled for "
+ "network {}".format(net))
+ raise NetworkDataException("overcloud_ip_range missing from "
+ "network: {}".format(net))
+ if 'cidr' in network:
+ tmp_net['ip_subnet'] = str(network['cidr'])
+ elif tmp_net['enabled']:
+ logging.error("cidr is missing and must be provided in network "
+ "settings when network is enabled for network "
+ "{}".format(net))
+ raise NetworkDataException("cidr is null for network {}".format(
+ net))
+
+ network_data.append(copy.deepcopy(tmp_net))
+
+ # have to do this due to the aforementioned bug
+ storage_mgmt_net = {
+ 'name': 'StorageMgmt',
+ 'enabled': False,
+ 'name_lower': 'storage_mgmt',
+ 'ip_subnet': '172.16.3.0/24',
+ 'allocation_pools': [{'start': '172.16.3.4', 'end': '172.16.3.250'}],
+ 'vip': True,
+ }
+ network_data.append(storage_mgmt_net)
+ if target:
+ logging.debug("Writing network data to {}".format(target))
+ utils.dump_yaml(network_data, target)
+ logging.debug("Network data parsed as:\n "
+ "{}".format(pprint.pformat(network_data)))
+ return network_data