ealier juju was not supported with multiple network space.
Change-Id: I9fc3017c90b8ecdf9a6a1563056dad37d995ca0e
Signed-off-by: Narinder Gupta <narinder.gupta@canonical.com>
#update source if trusty is target distribution
var=os-$opnfvsdn-$fea-$opnfvtype"-"$opnfvdistro"_"$openstack
- if ([ $osdomname ] && [ $osdomname != "null" ] && [ $osdomname != "None" ]); then
- var=$var"_"publicapi
- fi
else
var=k8-$opnfvsdn-$fea-baremetal-core
fi
{% set netdata_prefix = opnfv.spaces_dict.data.cidr[:-4] %}
dataNetwork: {{ opnfv.spaces_dict.data.cidr }}
{% endif %}
- domain: {{ lab.racks[0].osdomainname }}
ext-port: {{ lab.racks[0]['ext-port'] }}
ext_port: {{ lab.racks[0]['ext-port'] }}
floating-ip-range: {{ lab.racks[0]['floating-ip-range'] }}
interface-enable: {{ lab.racks[0].ifnamelist }}
- os-domain-name: {{ lab.racks[0].osdomainname }}
{% if opnfv.spaces_dict.public is defined %}
{% set netpublic_prefix = opnfv.spaces_dict.public.cidr[:-4] %}
publicNetwork: {{ opnfv.spaces_dict.public.cidr }}
region: *openstack-region
{% if os.ha.mode == 'ha' %}
vip: {{ opnfv.vip.ceilometer }}
-{% endif %}
-{% if os.beta.public_api %}
- os-public-hostname: api.{{ opnfv.domain }}
{% endif %}
to:
{% for unit_id in to_select() %}
cluster: *ceph-cluster-space
{% endif %}
options:
- monitor-count: {{ unit_ceph_qty() }}
- fsid: ecbb8960-0e21-11e2-b495-83a88f44db01
- monitor-secret: AQD1P2xQiKglDhAA4NGUF5j38Mhq56qwz+45wg==
+ expceted-osd-count: {{ unit_ceph_qty() }}
source: *openstack-origin
{% if os.network.ipv6 %}
prefer-ipv6: {{ os.network.ipv6 }}
region: *openstack-region
block-device: None
glance-api-version: 2
- use-internal-endpoints: True
{% if os.network.ipv6 %}
prefer-ipv6: {{ os.network.ipv6 }}
{% endif %}
{% endif %}
{% if os.ha.mode == 'ha' %}
vip: {{ opnfv.vip.cinder }}
-{% endif %}
-{% if os.beta.public_api %}
- os-public-hostname: api.{{ opnfv.domain }}
{% endif %}
to:
{% if opnfv.storage_dict.scaleio is defined %}
openstack-origin: *openstack-origin
worker-multiplier: *worker-multiplier
region: *openstack-region
- use-internal-endpoints: True
{% if os.git_repo.origin_git %}
openstack-origin-git: "{{ os.git_repo.branch }}"
{% endif %}
{% endif %}
{% if os.ha.mode == 'ha' %}
vip: {{ opnfv.vip.glance }}
-{% endif %}
-{% if os.beta.public_api %}
- os-public-hostname: api.{{ opnfv.domain }}
{% endif %}
to:
{% for unit_id in to_select() %}
worker-multiplier: *worker-multiplier
{% if os.ha.mode == 'ha' %}
# vip: {{ opnfv.vip.heat }}
-{% endif %}
-{% if os.beta.public_api %}
-# os-public-hostname: api.{{ opnfv.domain }}
{% endif %}
to:
- "lxd:nodes/0"
admin-token: {{ os.admin.name }}
{% if os.ha.mode == 'ha' %}
vip: {{ opnfv.vip.keystone }}
-{% endif %}
-{% if os.beta.public_api %}
- os-public-hostname: api.{{ opnfv.domain }}
{% endif %}
to:
{% for unit_id in to_select() %}
{% endif %}
region: *openstack-region
neutron-security-groups: true
- use-internal-endpoints: True
worker-multiplier: *worker-multiplier
{% if os.network.ipv6 %}
prefer-ipv6: {{ os.network.ipv6 }}
flat-network-providers: physnet1
manage-neutron-plugin-legacy-mode: False
{% endif %}
-{% if os.beta.public_api %}
- os-public-hostname: api.{{ opnfv.domain }}
-{% endif %}
{% if os.network.dvr %}
enable-dvr: true
{% endif %}
worker-multiplier: *worker-multiplier
single-nova-consoleauth: False
network-manager: Neutron
- use-internal-endpoints: true
{% if os.network.ipv6 %}
prefer-ipv6: {{ os.network.ipv6 }}
{% endif %}
{% endif %}
{% if opnfv.domain is defined %}
#console-proxy-ip: {{ opnfv.domain }}
-{% endif %}
-{% if os.beta.public_api %}
- os-public-hostname: api.{{ opnfv.domain }}
{% endif %}
to:
{% for unit_id in to_select() %}
enable-live-migration: True
enable-resize: True
migration-auth-type: ssh
- use-internal-endpoints: True
{% if os.network.ipv6 %}
prefer-ipv6: {{ os.network.ipv6 }}
{% endif %}
{% endif %}
{% if os.ha.mode == 'ha' %}
vip: {{ opnfv.vip.dashboard }}
-{% endif %}
-{% if os.beta.public_api %}
- endpoint-type: internalURL
{% endif %}
to:
{% for unit_id in to_select() %}
charm: ./{{ ubuntu.release }}/ceilometer-agent
options:
openstack-origin: *openstack-origin
- use-internal-endpoints: true
{% endif %}
{% if opnfv.storage_dict.ceph is defined %}
cinder-ceph:
{% if opnfv.spaces_dict.data is defined %}
{% set netdata_prefix = opnfv.spaces_dict.data.cidr[:-4] %}
dataNetwork: {{ opnfv.spaces_dict.data.cidr }}
-{% endif %}
-{% if lab.racks[0].osdomainname is defined %}
- domain: {{ lab.racks[0].osdomainname }}
- os-domain-name: {{ lab.racks[0].osdomainname }}
{% endif %}
ext-port: {{ lab.racks[0]['ext-port'] }}
ext_port: {{ lab.racks[0]['ext-port'] }}
+++ /dev/null
- 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 }}
- service_options: [mode http, balance leastconn]
- servers: [[{{ service.name }}, {{ service.ip }}, {{ service.port }}, 'maxconn 100 cookie S0 check']]
-{% endfor %}
- to:
- - "nodes=0"
+++ /dev/null
- 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 }}
- service_options: [mode http, balance leastconn]
- servers: [[{{ service.name }}, {{ service.ip }}, {{ service.port }}, 'maxconn 100 cookie S0 check']]
-{% endfor %}
- to:
- - "nodes=0"
l2_population: False
beta:
hacluster_ceph_radosgw: False
- public_api: False
huge_pages: False
cpu_pin: False
cpu_pin_set: all
# translate bundle.yaml to json
python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)' < bundles.yaml > bundles.json
-public_service() {
- # get services list having a public interface
- srv_list=$(cat bundles.json | jq -r ".services | to_entries[] | {\"key\": .key, \"value\": .value[\"bindings\"]} | select (.value!=null) | select(.value[] | contains(\"public-api\"))".key)
- # get cnt list from service list
- cnt_list=$(for cnt in $srv_list; do juju status $cnt --format=json | jq -r ".machines[].containers | to_entries[]".key; done)
- # get public network gateway (supposing it is the first ip of the network)
- public_api_gw=$(cat labconfig.json | jq --raw-output ".opnfv.spaces[] | select(.type==\"public\")".gateway)
- admin_gw=$(cat labconfig.json | jq --raw-output ".opnfv.spaces[] | select(.type==\"admin\")".gateway)
-
- if ([ $admin_gw ] && [ $admin_gw != "null" ]); then
- # set default gateway to public api gateway
- for cnt in $cnt_list; do
- echo_info "Changing default gateway on $cnt"
- if ([ $public_api_gw ] && [ $public_api_gw != "null" ]); then
- juju ssh $cnt "sudo ip r d default && sudo ip r a default via $public_api_gw";
- juju ssh $cnt "gw_dev=\$(ip r l | grep 'via $public_api_gw' | cut -d \ -f5) &&\
- sudo cp /etc/network/interfaces /etc/network/interfaces.bak &&\
- echo 'removing old default gateway' &&\
- sudo perl -i -pe 's/^\ *gateway $admin_gw\n$//' /etc/network/interfaces &&\
- sudo perl -i -pe \"s/iface \$gw_dev inet static/iface \$gw_dev inet static\\n gateway $public_api_gw/\" /etc/network/interfaces \
- ";
- fi
- done
- fi
-}
-
# Configuring deployment
if ([ $opnfvmodel == "openstack" ]); then
echo_info "Configuring OpenStack deployment"
# Set beta option from extra
-if 'publicapi' in extra:
- config['os']['beta']['public_api'] = True
if 'radosgwcluster' in extra:
config['os']['beta']['hacluster_ceph_radosgw'] = True
if 'hugepages' in extra:
+++ /dev/null
-#!/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)
# openstack
bzr branch lp:~narindergupta/charms/trusty/promise/trunk $distro/promise
-bzr branch lp:~billy-olsen/charms/xenial/mongodb/trunk $distro/mongodb
-bzr branch lp:~narindergupta/opnfv/ntp $distro/ntp
git clone https://github.com/openstack/charm-hacluster.git $distro/hacluster
git clone https://github.com/openstack/charm-ceilometer.git $distro/ceilometer
git clone https://github.com/openbaton/juju-charm.git $distro/openbaton
charm pull cs:$distro/aodh $distro/aodh
-charm pull cs:~free.ekanayaka/xenial/haproxy-1 $distro/haproxy
+charm pull cs:$distro/mongodb $distro/mongodb
+charm pull cs:$distro/ntp $distro/ntp
+charm pull cs:$distro/haproxy $distro/haproxy
charm pull cs:~narindergupta/congress-1 $distro/congress
#pulling scaleio charms.
EXTNET_NET=${EXTNET[3]}
EXTNET_PORT=`grep "ext-port" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
ADMNET_GW=`grep "admNetgway" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
- API_FQDN=`grep "os-domain-name" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
fi
# launch eth on computer nodes and remove default gw route
EOF
}
-if ([ $API_FQDN ] && [ $API_FQDN != "null" ] && [ $API_FQDN != "None" ]); then
- echo_info "OS domain name was specified - injecting API FQDN to nodes"
-
- # Push api fqdn local ip to all /etc/hosts
- if [[ "$jujuver" < "2" ]]; then
- API_FQDN=$(juju get keystone | python -c "import yaml; import sys;\
- print yaml.load(sys.stdin)['settings']['os-public-hostname']['value']")
- else
- API_FQDN=$(juju config keystone | python -c "import yaml; import sys;\
- print yaml.load(sys.stdin)['settings']['os-public-hostname']['value']")
- fi
-
-
- KEYSTONEIP=$(keystoneIp)
- juju run --all "if grep $API_FQDN /etc/hosts > /dev/null; then \
- echo 'API FQDN already present'; \
- else \
- sudo sh -c 'echo $KEYSTONEIP $API_FQDN >> /etc/hosts'; \
- echo 'API FQDN injected'; \
- fi"
-
- # remove this enhancement for heat that does not manage endpoints
- juju run --application=heat "cp /etc/hosts /tmp/hosts ; \
- grep -v $API_FQDN /tmp/hosts > /etc/hosts"
-
- #change in jumphost as well as below commands will run on jumphost
- if grep $API_FQDN /etc/hosts; then
- echo 'API FQDN already present'
- else
- sudo sh -c "echo $KEYSTONEIP $API_FQDN >> /etc/hosts"
- echo 'API FQDN injected'
- fi
-fi
-
# Create an load openrc
create_openrc
. ~/joid_config/admin-openrc
-if ([ "$opnfvlab" == "orangepod1" ] \
- || [ "$opnfvlab" == "intelpod6" ]) \
- && [ "$opnfvsdn" == "nosdn" ] \
- && [ "$API_FQDN" != "None" ]; then # only for first test phase
- if [ -e ./labconfig.yaml ]; then
- echo_info "Deploying public API proxy"
-
- PUB_API_MASK=$(grep floating-ip-range ./labconfig.yaml |cut -d/ -f2)
- PUB_API_NET=$(grep floating-ip-range ./labconfig.yaml |cut -d, -f4)
- PUB_API_IP=$(grep public-api-ip ./labconfig.yaml |cut -d: -f2)
- if grep "- type: public" ./labconfig.yaml; then
- # The public network exists on MAAS, so we push the dns record to it
-
- # Recover maas ips and login to it
- maas_ip=$(grep " ip_address" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //')
- maas_pubip=$(grep floating-ip-range ./labconfig.yaml |cut -d, -f4 |perl -pe 's!^(.*)\.\d+/\d+$!$1.5!')
- apikey=$(grep maas-oauth: environments.yaml | cut -d "'" -f 2)
- maas login maas http://${maas_ip}/MAAS/api/1.0 ${apikey}
-
- # Configure maas to add the record
- CLUSTER_UUID=$(maas ubuntu node-groups list | grep uuid | cut -d\" -f4)
- PUBLIC_MAAS_IF=$(maas ubuntu node-group-interfaces list $cluster_uuid |\
- python -c "import yaml; import sys; cfg=yaml.load(sys.stdin); net_h={net['ip']:net['name'] for net in cfg}; print(net_h['$maas_pubip'])")
- maas maas node-group-interface update ${CLUSTER_UUID} ${PUBLIC_MAAS_IF} static_ip_range_high=${PUB_API_IP} static_ip_range_low=${PUB_API_IP}
- maas maas ipaddresses reserve network=${PUB_API_NET} requested_address=${PUB_API_IP} hostname=${API_FQDN}
- dig ${PUB_API_IP} @${maas_ip} # just for log
- fi
- juju run --unit nodes/0 "sudo ip a a ${PUB_API_IP}/${PUB_API_MASK} dev br-ex" || true
- juju run --unit nodes/0 "sudo ip l set dev br-ex up" || true
- python genPublicAPIProxyBundle.py -l labconfig.yaml >> bundles.yaml
- juju-deployer -vW -d -t 7200 -r 5 -c bundles.yaml $opnfvdistro-"$opnfvos" || true
-
- echo_info "Public API proxy deployed!"
- fi
-fi
-
-
##
## removing the swift API endpoint which is created by radosgw.
## one option is not to used radosgw and other one is remove endpoint.