summaryrefslogtreecommitdiffstats
path: root/ci
diff options
context:
space:
mode:
Diffstat (limited to 'ci')
-rw-r--r--ci/config_tpl/public-api-proxy.yaml13
-rwxr-xr-xci/deploy.sh16
-rw-r--r--ci/genPublicAPIProxyBundle.py111
-rwxr-xr-xci/nosdn/fetch-charms.sh2
4 files changed, 139 insertions, 3 deletions
diff --git a/ci/config_tpl/public-api-proxy.yaml b/ci/config_tpl/public-api-proxy.yaml
new file mode 100644
index 00000000..726945fe
--- /dev/null
+++ b/ci/config_tpl/public-api-proxy.yaml
@@ -0,0 +1,13 @@
+haproxy:
+ charm: "local:{{ opnfv.distro }}/haproxy"
+ num_units: 1
+ options:
+ services: |-
+{% for service in public_api_services.values() %}
+ - service_name: {{ service.name }}
+ service_host: {{ public_api_ip }}
+ service_port: {{ service.port }}
+ servers: [[{{ service.name }},{{ service.ip }},{{ service.port }}]]
+{% endfor %}
+ to:
+ - "nodes=0"
diff --git a/ci/deploy.sh b/ci/deploy.sh
index 2e575898..b69b5baa 100755
--- a/ci/deploy.sh
+++ b/ci/deploy.sh
@@ -23,13 +23,13 @@ read_config() {
}
usage() { echo "Usage: $0 [-s <nosdn|odl|opencontrail>]
- [-t <nonha|ha|tip>]
+ [-t <nonha|ha|tip>]
[-o <juno|liberty>]
[-l <default|intelpod5>]
[-f <ipv6,dpdk,lxd,dvr>]
[-d <trusty|xenial>]
[-a <amd64>]
- [-r <a|b>]" 1>&2 exit 1; }
+ [-r <a|b>]" 1>&2 exit 1; }
while getopts ":s:t:o:l:h:r:f:d:a:" opt; do
case "${opt}" in
@@ -161,6 +161,18 @@ echo "...... deployment started ......"
deploy
check_status
+
+echo "...... deploy public api proxy ......"
+
+if [ "$opnfvlab" == "orangepod1" ] && [ "$opnfvsdn" == "nosdn" ]; then # only for first test phase
+ PUB_API_NET=$(grep floating-ip-range ./labconfig.yaml |cut -d/ -f2)
+ PUB_API_IP=$(grep public-api-ip ./labconfig.yaml |cut -d: -f2)
+ juju run --unit nodes/0 "sudo ip a a ${PUB_API_IP}/${PUB_API_NET} dev br-ex"
+ juju run --unit nodes/0 "sudo ip l set dev br-ex up"
+ python genPublicAPIProxyBundle.py -l labconfig.yaml > haproxy.bundle.yaml
+ juju-deployer -vW -d -t 7200 -r 5 -c haproxy.bundle.yaml haproxy
+fi
+
echo "...... deployment finished ......."
./openstack.sh "$opnfvsdn" || true
diff --git a/ci/genPublicAPIProxyBundle.py b/ci/genPublicAPIProxyBundle.py
new file mode 100644
index 00000000..87acee2c
--- /dev/null
+++ b/ci/genPublicAPIProxyBundle.py
@@ -0,0 +1,111 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+"""
+This script generates a bundle config for the haproxy managing public apis
+
+Parameters:
+ -l, --lab : lab config file
+"""
+
+from jinja2 import Environment, FileSystemLoader
+from keystoneauth1.identity import v2
+from keystoneauth1 import session
+from keystoneclient.v2_0 import client
+from optparse import OptionParser
+
+import os
+import yaml
+
+#
+# Parse parameters
+#
+
+parser = OptionParser()
+parser.add_option("-l", "--lab", dest="lab", help="lab config file")
+(options, args) = parser.parse_args()
+labconfig_file = options.lab
+
+#
+# Set Path and configs path
+#
+
+# Capture our current directory
+TPL_DIR = os.path.dirname(os.path.abspath(__file__))+'/config_tpl'
+
+#
+# Local Functions
+#
+
+
+def load_yaml(filepath):
+ """Load YAML file"""
+ with open(filepath, 'r') as stream:
+ try:
+ return yaml.load(stream)
+ except yaml.YAMLError as exc:
+ print(exc)
+
+#
+# Config import
+#
+
+# Load scenario Config
+config = load_yaml(labconfig_file)
+
+# Add public api ip to config
+if 'public_api_ip' in config['lab']['racks'][0]:
+ config['public_api_ip'] = config['lab']['racks'][0]['public_api_ip']
+else:
+ first_public_ip = config['lab']['racks'][0][
+ 'floating-ip-range'].split(',')[0]
+ # managing ipv6 and ipv4 format
+ sep = ':' if ':' in first_public_ip else '.'
+ api_ip = first_public_ip.split(sep)
+ api_ip[-1] = str(int(api_ip[-1])-1)
+ config['public_api_ip'] = sep.join(api_ip)
+
+# get endpoint list from keystone
+username = os.environ['OS_USERNAME']
+password = os.environ['OS_PASSWORD']
+tenant_name = os.environ['OS_TENANT_NAME']
+auth_url = os.environ['OS_AUTH_URL']
+auth = v2.Password(username=username,
+ password=password,
+ tenant_name=tenant_name,
+ auth_url=auth_url)
+sess = session.Session(auth=auth)
+keystone = client.Client(session=sess)
+services = keystone.services.list()
+endpoints = keystone.endpoints.list()
+srv = dict()
+for service in services:
+ if service.name != 'cinderv2':
+ srv[service.id] = {'name': service.name}
+for endpoint in endpoints:
+ if endpoint.service_id in srv.keys():
+ internal = endpoint.internalurl.split('/')[2].split(':')
+ srv[endpoint.service_id]['ip'] = ':'.join(internal[:-1])
+ srv[endpoint.service_id]['port'] = internal[-1]
+config['public_api_services'] = srv
+
+#
+# Transform template to deployconfig.yaml according to config
+#
+
+# Create the jinja2 environment.
+env = Environment(loader=FileSystemLoader(TPL_DIR),
+ trim_blocks=True)
+template = env.get_template('public-api-proxy.yaml')
+
+# Render the template
+output = template.render(**config)
+
+# Check output syntax
+try:
+ yaml.load(output)
+except yaml.YAMLError as exc:
+ print(exc)
+
+# print output
+print(output)
diff --git a/ci/nosdn/fetch-charms.sh b/ci/nosdn/fetch-charms.sh
index da7963f6..05fa705d 100755
--- a/ci/nosdn/fetch-charms.sh
+++ b/ci/nosdn/fetch-charms.sh
@@ -41,6 +41,7 @@ git clone -b stable/16.07 https://github.com/openstack/charm-rabbitmq-server.git
git clone -b stable/16.07 https://github.com/openstack/charm-heat.git $distro/heat
git clone -b stable/16.07 https://github.com/openstack/charm-lxd.git xenial/lxd
+charm pull cs:~free.ekanayaka/xenial/haproxy-1 $distro/haproxy
#charm pull cs:~openstack-charmers-next/hacluster $distro/hacluster
#charm pull cs:~openstack-charmers-next/ceilometer $distro/ceilometer
#charm pull cs:~openstack-charmers-next/ceilometer-agent $distro/ceilometer-agent
@@ -61,4 +62,3 @@ git clone -b stable/16.07 https://github.com/openstack/charm-lxd.git xenial/lxd
#charm pull cs:~openstack-charmers-next/rabbitmq-server $distro/rabbitmq-server
#charm pull cs:~openstack-charmers-next/heat $distro/heat
#charm pull cs:~openstack-charmers-next/lxd xenial/lxd
-