From: Austin Cormier Date: Mon, 23 May 2016 23:12:00 +0000 (-0400) Subject: Initial Makefile for descriptor packages X-Git-Tag: v2.0.2~6^2~61 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=3aeed1205fbfdfa490cd9cb6108ef9d8b534c7ca;p=osm%2Fdevops.git Initial Makefile for descriptor packages --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..1b2211df --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build* diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..0a01862a --- /dev/null +++ b/Makefile @@ -0,0 +1,44 @@ +BUILD_DIR = build + +NSDS := gw_corpa_ns ims_allin1_corpa mwc16_gen_ns mwc16_pe_ns +NSD_SRC_DIR := src/nsd +NSD_BUILD_DIR := $(BUILD_DIR)/nsd + +NSD_SRC_DIRS := $(addprefix $(NSD_SRC_DIR)/, $(NSDS)) +NSD_BUILD_DIRS := $(addprefix $(NSD_BUILD_DIR)/, $(NSDS)) +NSD_PKGS := $(addsuffix .tar.gz, $(NSDS)) +NSD_BUILD_PKGS := $(addprefix $(NSD_BUILD_DIR)_pkgs/, $(NSD_PKGS)) + +VNFDS := 6wind_vnf gw_corpa_pe1_vnf gw_corpa_pe2_vnf ims_allin1_2p_vnf tidgen_mwc16_vnf +VNFD_SRC_DIR := src/vnfd +VNFD_BUILD_DIR := $(BUILD_DIR)/vnfd + +VNFD_SRC_DIRS := $(addprefix $(VNFD_SRC_DIR)/, $(VNFDS)) +VNFD_BUILD_DIRS := $(addprefix $(VNFD_BUILD_DIR)/, $(VNFDS)) +VNFD_PKGS := $(addsuffix .tar.gz, $(VNFDS)) +VNFD_BUILD_PKGS := $(addprefix $(VNFD_BUILD_DIR)_pkgs/, $(VNFD_PKGS)) + +all: $(VNFD_BUILD_PKGS) ${NSD_BUILD_PKGS} + echo $@ + +clean: + -@ $(RM) -rf $(BUILD_DIR) + +$(VNFD_BUILD_DIR)/%: $(VNFD_SRC_DIR)/% + mkdir -p $(VNFD_BUILD_DIR) + cp -rf $< $(VNFD_BUILD_DIR) + + src/gen_vnfd_pkg.sh $< $@ + src/generate_descriptor_pkg.sh $(BUILD_DIR)/vnfd_pkgs $@ + +$(NSD_BUILD_DIR)/%: $(NSD_SRC_DIR)/% + mkdir -p $(NSD_BUILD_DIR) + cp -rf $< $(NSD_BUILD_DIR) + + src/gen_nsd_pkg.sh $< $@ + +$(BUILD_DIR)/nsd_pkgs/%.tar.gz: $(NSD_BUILD_DIR)/% + src/generate_descriptor_pkg.sh $(BUILD_DIR)/nsd_pkgs $< + +$(BUILD_DIR)/vnfd_pkgs/%.tar.gz: $(VNFD_BUILD_DIR)/% + src/generate_descriptor_pkg.sh $(BUILD_DIR)/vnfd_pkgs $< diff --git a/src/gen_nsd_pkg.sh b/src/gen_nsd_pkg.sh new file mode 100755 index 00000000..ea5e6a71 --- /dev/null +++ b/src/gen_nsd_pkg.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# Generates a NSD descriptor package from a source directory +# Usage: +# gen_nsd_pkg.sh + +set -o nounset + +if [ $# -ne 2 ]; then + echo "Error: Must provide 2 parameters" >@2 + exit 1 +fi + +pkg_src_dir="$1" +pkg_dest_dir="$2" + +if [ ! -e ${pkg_src_dir} ]; then + echo "Error: ${pkg_src_dir} does not exist" + exit 1 +fi + +if [ ! -e ${pkg_dest_dir} ]; then + echo "Error: ${pkg_src_dir} does not exist" + exit 1 +fi + +echo "Generating package in directory: ${pkg_dest_dir}" + +# Create any missing directories/files so each package has +# a complete hierachy +nsd_dirs=( ns_config vnf_config icons scripts ) +nsd_files=( README ) + +nsd_dir="${pkg_src_dir}" +echo $(pwd) + +mkdir -p "${pkg_dest_dir}" +cp -rf ${nsd_dir}/* "${pkg_dest_dir}" +for sub_dir in ${nsd_dirs[@]}; do + dir_path=${pkg_dest_dir}/${sub_dir} + mkdir -p ${dir_path} +done + +for file in ${nsd_files[@]}; do + file_path=${pkg_dest_dir}/${file} + touch ${file_path} +done diff --git a/src/gen_vnfd_pkg.sh b/src/gen_vnfd_pkg.sh new file mode 100755 index 00000000..478d5c54 --- /dev/null +++ b/src/gen_vnfd_pkg.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# Generates a NSD descriptor package from a source directory +# Usage: +# gen_vnfd_pkg.sh + +set -o nounset + +if [ $# -ne 2 ]; then + echo "Error: Must provide 2 parameters" >@2 + exit 1 +fi + +pkg_src_dir="$1" +pkg_dest_dir="$2" + +if [ ! -e ${pkg_src_dir} ]; then + echo "Error: ${pkg_src_dir} does not exist" + exit 1 +fi + +if [ ! -e ${pkg_dest_dir} ]; then + echo "Error: ${pkg_src_dir} does not exist" + exit 1 +fi + +echo "Generating package in directory: ${pkg_dest_dir}" + +# Create any missing directories/files so each package has +# a complete hierachy +vnfd_dirs=( charms icons scripts images ) +vnfd_files=( README ) + +vnfd_dir="${pkg_src_dir}" +echo $(pwd) + +mkdir -p "${pkg_dest_dir}" +cp -rf ${vnfd_dir}/* "${pkg_dest_dir}" +for sub_dir in ${vnfd_dirs[@]}; do + dir_path=${pkg_dest_dir}/${sub_dir} + mkdir -p ${dir_path} +done + +for file in ${vnfd_files[@]}; do + file_path=${pkg_dest_dir}/${file} + touch ${file_path} +done diff --git a/src/generate_descriptor_pkg.sh b/src/generate_descriptor_pkg.sh new file mode 100755 index 00000000..82ecda13 --- /dev/null +++ b/src/generate_descriptor_pkg.sh @@ -0,0 +1,27 @@ +#! /usr/bin/bash +# STANDARD_RIFT_IO_COPYRIGHT +# Author(s): Anil Gunturu +# Creation Date: 2015/10/09 +# +# This shell script is used to create a descriptor package +# The main functions of this script include: +# - Generate checksums.txt file +# - Generate a tar.gz file + +# Usage: generate_descriptor_pkg.sh + +mkdir -p $1 +mkdir -p $2 + +dest_dir=$(cd $1 && pwd) +pkg_dir=$(cd $2 && pwd) + +echo $(pwd) +cd ${pkg_dir} +rm -rf checksums.txt +find * -type f | + while read file; do + md5sum $file >> checksums.txt + done +cd .. +tar -zcvf ${dest_dir}/$(basename $pkg_dir).tar.gz $(basename $pkg_dir) diff --git a/src/nsd/ims_allin1_corpa/IMS-corpA__nsd.yaml b/src/nsd/ims_allin1_corpa/IMS-corpA__nsd.yaml new file mode 100644 index 00000000..27a1197f --- /dev/null +++ b/src/nsd/ims_allin1_corpa/IMS-corpA__nsd.yaml @@ -0,0 +1,57 @@ +nsd:nsd-catalog: + nsd: + - id: IMS-corpA + name: IMS-corpA + short-name: IMS-corpA + description: All in one Clearwater IMS for corporation A in MWC16 + logo: osm_2x.png + constituent-vnfd: + - member-vnf-index: '1' + vnfd-id-ref: IMS-ALLIN1_2p + vld: + - id: data + name: data + type: ELAN + provider-network: + overlay-type: VLAN + physical-network: net-corp + segmentation_id: '108' + vnfd-connection-point-ref: + - member-vnf-index-ref: '1' + vnfd-connection-point-ref: eth0 + vnfd-id-ref: IMS-ALLIN1_2p + - id: management + name: management + type: ELAN + provider-network: + overlay-type: VLAN + physical-network: net-mgmtOS + vnfd-connection-point-ref: + - member-vnf-index-ref: '1' + vnfd-connection-point-ref: eth1 + vnfd-id-ref: IMS-ALLIN1_2p + config-primitive: + - name: Update Domain + vnf-primitive-group: + - member-vnf-index-ref: '1' + vnfd-id-ref: IMS-ALLIN1_2p + vnfd-name: cwims_vnfd + primitive: + - index: '1' + name: config + - name: Add User + vnf-primitive-group: + - member-vnf-index-ref: '1' + vnfd-id-ref: IMS-ALLIN1_2p + vnfd-name: cwims_vnfd + primitive: + - index: '1' + name: create-update-user + - name: Delete User + vnf-primitive-group: + - member-vnf-index-ref: '1' + vnfd-id-ref: IMS-ALLIN1_2p + vnfd-name: cwims_vnfd + primitive: + - index: '1' + name: delete-user diff --git a/src/nsd/ims_allin1_corpa/icons/osm_2x.png b/src/nsd/ims_allin1_corpa/icons/osm_2x.png new file mode 100644 index 00000000..62012d2a Binary files /dev/null and b/src/nsd/ims_allin1_corpa/icons/osm_2x.png differ diff --git a/src/nsd/ims_allin1_corpa/vnf_config/IMS-ALLIN1_2p__1.yaml b/src/nsd/ims_allin1_corpa/vnf_config/IMS-ALLIN1_2p__1.yaml new file mode 100644 index 00000000..33c5ef96 --- /dev/null +++ b/src/nsd/ims_allin1_corpa/vnf_config/IMS-ALLIN1_2p__1.yaml @@ -0,0 +1,4 @@ +initial_config_primitive: +- name: config + parameter: + proxied_ip: diff --git a/src/vnfd/ims_allin1_2p_vnf/IMS-ALLIN1__vnfd.yaml b/src/vnfd/ims_allin1_2p_vnf/IMS-ALLIN1__vnfd.yaml new file mode 100644 index 00000000..b36941a9 --- /dev/null +++ b/src/vnfd/ims_allin1_2p_vnf/IMS-ALLIN1__vnfd.yaml @@ -0,0 +1,85 @@ +vnfd:vnfd-catalog: + vnfd: + - id: IMS-ALLIN1_2p + name: IMS-ALLIN1_2p + short-name: IMS-ALLIN1_2p + description: IMS-ALLIN1_2p + logo: metaswitch_2x.png + mgmt-interface: + vdu-id: IMS-ALLIN1_2p-VM + vnf-configuration: + config-attributes: + config-delay: '0' + config-priority: '1' + config-primitive: + - name: config + parameter: + - name: home_domain + data-type: STRING + mandatory: 'true' + default-value: ims.com + - name: password + data-type: string + mandatory: 'true' + name: password + default-value: cw-aio + - name: create-update-user + parameter: + - name: number + data-type: STRING + mandatory: 'true' + - name: password + data-type: STRING + mandatory: 'true' + - name: delete-user + parameter: + - name: number + data-type: STRING + mandatory: 'true' + initial-config-primitive: + - name: config + parameter: + - name: proxied_ip + value: + seq: '1' + juju: + charm: clearwater-aio-proxy + connection-point: + - name: eth0 + type: VPORT + - name: eth1 + type: VPORT + vdu: + - id: IMS-ALLIN1_2p-VM + name: IMS-ALLIN1_2p-VM + description: IMS-ALLIN1_2p-VM + image: /mnt/powervault/virtualization/vnfs/demos/mwc2016/allin1.qcow2 + vm-flavor: + memory-mb: '4096' + storage-gb: '10' + vcpu-count: '2' + mgmt-vpci: 0000:00:0a.0 + external-interface: + - name: eth0 + virtual-interface: + bandwidth: '0' + type: VIRTIO + vpci: 0000:00:0a.0 + vnfd-connection-point-ref: eth0 + - name: eth1 + virtual-interface: + bandwidth: '0' + type: OM-MGMT + vpci: 0000:00:0b.0 + vnfd-connection-point-ref: eth1 + guest-epa: + cpu-pinning-policy: DEDICATED + cpu-thread-pinning-policy: PREFER + mempage-size: LARGE + numa-node-policy: + mem-policy: STRICT + node: + - id: '0' + paired-threads: + num-paired-threads: '1' + node-cnt: '1' diff --git a/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/README.md b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/README.md new file mode 100644 index 00000000..c67a763b --- /dev/null +++ b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/README.md @@ -0,0 +1,53 @@ +# Overview + +This is a [Juju charm](https://jujucharms.com/about), which allows configuration of the [Project Clearwater](http://projectclearwater.org) IMS core's [all-in-one](http://clearwater.readthedocs.org/en/stable/All_in_one_Images/index.html) node. + +This is a proxy charm, meaning that you must spin up the all-in-one VM first, and then point this charm at it to manage it. + +Since the all-in-one node does not support scaling up, neither does this charm. + +# Deployment + +## Initial deployment + +The all-in-one VM image should be downloaded from [http://repo.cw-ngv.com/juju-clearwater-2/cw-aio.ova](http://repo.cw-ngv.com/juju-clearwater-2/cw-aio.ova) and deployed onto your virtualization platform. (You could alternatively try the latest all-in-one VM image from [http://vm-images.cw-ngv.com/](http://vm-images.cw-ngv.com/), but this may not have been tested with this charm - the juju-clearwater-2 version above is known to work.) + +The proxy charm should then be deployed, pointing at the all-in-one VM. + +# Using the All-in-One Node + +Once installed, the all-in-one node will listen for SIP traffic on port 5060 (both TCP and UDP). You can use a standard SIP client (e.g. Blink, Boghe or X-Lite) to register against the all-in-one VM's public IP and make calls. + +Our ["Making your first call" documentation](http://clearwater.readthedocs.org/en/latest/Making_your_first_call/index.html) has more information on this process. + +# Configuration + +- `proxied_ip`: The IP address of the All-in-One node to manage +- `password`: The login password of the All-in-One node to manage (default is + very likely correct) +- `home_domain`: The home domain for this service +- `base_number`: The first number to be allocated in the number range +- `number_count`: The count of numbers to allocate + +# Actions + +This proxy charm exposes two actions. + +- `create-update-user`: Creates a user, or updates if they already exist + - `number`: The number to provision + - `password`: The number's password + +- `delete-user`: Deletes a user + - `number`: The number to delete + +For example, `juju action do clearwater-aio-proxy/0 create-update-user number=\"1234567890\" password=secret` creates a user. (Note that the escaped double-quotes are required to avoid juju parsing the number as an integer rather than a string.) + +Note that the numbers specified in `create-update-user` and `delete-user` actions need not be in the number range specified in the configuration above. + +# Contact and Upstream Project Information + +Project Clearwater is an open-source IMS core, developed by [Metaswitch Networks](http://www.metaswitch.com) and released under the [GNU GPLv3](http://www.projectclearwater.org/download/license/). You can find more information about it on [our website](http://www.projectclearwater.org/) or [our documentation site](https://clearwater.readthedocs.org). + +Clearwater source code and issue list can be found at https://github.com/Metaswitch/. + +If you have problems when using Project Clearwater, read [our troubleshooting documentation](http://clearwater.readthedocs.org/en/latest/Troubleshooting_and_Recovery/index.html) for help, or see [our support page](http://clearwater.readthedocs.org/en/latest/Support/index.html) to find out how to ask mailing list questions or raise issues. diff --git a/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/actions.yaml b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/actions.yaml new file mode 100644 index 00000000..424ae896 --- /dev/null +++ b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/actions.yaml @@ -0,0 +1,19 @@ +create-update-user: + description: Create a user, or update a user if they already exist. + params: + number: + description: The number to provision + type: string + password: + description: The number's password + type: string + required: [number, password] + additionalProperties: false +delete-user: + description: Delete a user. If the user does not exist, this is still considered success. + params: + number: + description: The number to provision + type: string + required: [number] + additionalProperties: false diff --git a/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/actions/create-update-user b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/actions/create-update-user new file mode 100755 index 00000000..1f388fe2 --- /dev/null +++ b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/actions/create-update-user @@ -0,0 +1,23 @@ +#!/bin/bash +set -e + +# Get the configuration and action parameters. +proxied_ip=$(config-get proxied_ip) +login_password=$(config-get password) +home_domain=$(config-get home_domain) +number=$(action-get number) +password=$(action-get password) + +if [ -z "$proxied_ip" ] || [ -z "$login_password" ] || [ -z "$home_domain" ] ; then + echo Proxy not yet configured! + exit 1 +fi + +# If the user doesn't exist, try to create them. Otherwise, try to update them. +if ! sshpass -p$login_password ssh -o StrictHostKeyChecking=no ubuntu@$proxied_ip "echo $login_password | sudo -S /usr/share/clearwater/bin/display_user $number $home_domain" ; then + echo "Subscriber doesn't exist - creating" + sshpass -p$login_password ssh -o StrictHostKeyChecking=no ubuntu@$proxied_ip "echo $login_password | sudo -S /usr/share/clearwater/bin/create_user $number $home_domain $password" +else + echo "Subscriber exists - updating" + sshpass -p$login_password ssh -o StrictHostKeyChecking=no ubuntu@$proxied_ip "echo $login_password | sudo -S /usr/share/clearwater/bin/update_user $number $home_domain --password $password" +fi diff --git a/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/actions/create-user b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/actions/create-user new file mode 100755 index 00000000..feeb6466 --- /dev/null +++ b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/actions/create-user @@ -0,0 +1,17 @@ +#!/bin/bash +set -e + +# Get the configuration and action parameters. +proxied_ip=$(config-get proxied_ip) +login_password=$(config-get password) +home_domain=$(config-get home_domain) +number=$(action-get number) +password=$(action-get password) + +if [ -z "$proxied_ip" ] || [ -z "$login_password" ] || [ -z "$home_domain" ] ; then + echo Proxy not yet configured! + exit 1 +fi + +# Create the user. +sshpass -p$login_password ssh -o StrictHostKeyChecking=no ubuntu@$proxied_ip "echo $login_password | sudo -S /usr/share/clearwater/bin/create_user $number $home_domain $password" diff --git a/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/actions/delete-user b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/actions/delete-user new file mode 100755 index 00000000..7ecf5198 --- /dev/null +++ b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/actions/delete-user @@ -0,0 +1,16 @@ +#!/bin/bash +set -e + +# Get the configuration and action parameters. +proxied_ip=$(config-get proxied_ip) +login_password=$(config-get password) +home_domain=$(config-get home_domain) +number=$(action-get number) + +if [ -z "$proxied_ip" ] || [ -z "$login_password" ] || [ -z "$home_domain" ] ; then + echo Proxy not yet configured! + exit 1 +fi + +# Delete the user. +sshpass -p$login_password ssh -o StrictHostKeyChecking=no ubuntu@$proxied_ip "echo $login_password | sudo -S /usr/share/clearwater/bin/delete_user -y $number $home_domain" diff --git a/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/config.yaml b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/config.yaml new file mode 100644 index 00000000..3be783fc --- /dev/null +++ b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/config.yaml @@ -0,0 +1,20 @@ +options: + proxied_ip: + description: The IP address of the All-in-One node to manage + type: string + password: + default: cw-aio + description: The login password of the All-in-One node to manage (default is very likely correct) + type: string + home_domain: + default: example.com + description: The home domain for this service + type: string + base_number: + default: "1230000000" + description: The first number to be allocated in the number range + type: string + number_count: + default: 1000 + description: The count of numbers to allocate + type: int diff --git a/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/copyright b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/copyright new file mode 100644 index 00000000..39f1ec8f --- /dev/null +++ b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/copyright @@ -0,0 +1,31 @@ +Project Clearwater - IMS in the Cloud +Copyright (C) 2016 Metaswitch Networks Ltd + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation, either version 3 of the License, or (at your +option) any later version, along with the "Special Exception" for use of +the program along with SSL, set forth below. This program is distributed +in the hope that it will be useful, but WITHOUT ANY WARRANTY; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. See the GNU General Public License for more +details. You should have received a copy of the GNU General Public +License along with this program. If not, see +. + +The author can be reached by email at clearwater@metaswitch.com or by +post at Metaswitch Networks Ltd, 100 Church St, Enfield EN2 6BQ, UK + +Special Exception +Metaswitch Networks Ltd grants you permission to copy, modify, +propagate, and distribute a work formed by combining OpenSSL with The +Software, or a work derivative of such a combination, even if such +copying, modification, propagation, or distribution would otherwise +violate the terms of the GPL. You must comply with the GPL in all +respects for all of the code used other than OpenSSL. +"OpenSSL" means OpenSSL toolkit software distributed by the OpenSSL +Project and licensed under the OpenSSL Licenses, or a work based on such +software and licensed under the OpenSSL Licenses. +"OpenSSL Licenses" means the OpenSSL License and Original SSLeay License +under which the OpenSSL Project distributes the OpenSSL toolkit software, +as those licenses appear in the file LICENSE-OPENSSL. diff --git a/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/hooks/config-changed b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/hooks/config-changed new file mode 100755 index 00000000..4382edd6 --- /dev/null +++ b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/hooks/config-changed @@ -0,0 +1,20 @@ +#!/bin/bash +set -e + +# Get the configuration. +proxied_ip=$(config-get proxied_ip) +login_password=$(config-get password) +home_domain=$(config-get home_domain) +base_number=$(config-get base_number) +number_count=$(config-get number_count) + +# If the node is configured, provision it and its numbers. +if [ -n "$proxied_ip" ] && [ -n "$home_domain" ] && [ -n "$login_password" ] ; then + # Copy the reconfigure-aio script on, and run it. + status-set maintenance "configuring" + sshpass -p$login_password scp -o StrictHostKeyChecking=no $CHARM_DIR/lib/reconfigure-aio ubuntu@$proxied_ip:/tmp/reconfigure-aio.$$ + sshpass -p$login_password ssh -o StrictHostKeyChecking=no ubuntu@$proxied_ip "echo $login_password | sudo -S bash -c 'bash /tmp/reconfigure-aio.$$ $home_domain $base_number $number_count ; rm -f /tmp/reconfigure-aio.$$'" + status-set active "configured" +else + status-set blocked "waiting for configuration" +fi diff --git a/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/hooks/install b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/hooks/install new file mode 100755 index 00000000..4378d034 --- /dev/null +++ b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/hooks/install @@ -0,0 +1,10 @@ +#!/bin/bash +set -e + +status-set maintenance "installing" + +# Install sshpass as we'll need it shortly +apt-get update +apt-get -q -y --force-yes install sshpass + +status-set maintenance "installed" diff --git a/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/hooks/start b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/hooks/start new file mode 100755 index 00000000..8824f74a --- /dev/null +++ b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/hooks/start @@ -0,0 +1,7 @@ +#!/bin/bash +# Here put anything that is needed to start the service. +# Note that currently this is run directly after install +# i.e. 'service apache2 start' +set -e + +# Nothing to do diff --git a/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/hooks/stop b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/hooks/stop new file mode 100755 index 00000000..f6ecbe3a --- /dev/null +++ b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/hooks/stop @@ -0,0 +1,10 @@ +#!/bin/bash +# This will be run when the service is being torn down, allowing you to disable +# it in various ways.. +# For example, if your web app uses a text file to signal to the load balancer +# that it is live... you could remove it and sleep for a bit to allow the load +# balancer to stop sending traffic. +# rm /srv/webroot/server-live.txt && sleep 30 +set -e + +# Nothing to do diff --git a/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/hooks/upgrade-charm b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/hooks/upgrade-charm new file mode 100755 index 00000000..fdb1f864 --- /dev/null +++ b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/hooks/upgrade-charm @@ -0,0 +1,8 @@ +#!/bin/bash +# This hook is executed each time a charm is upgraded after the new charm +# contents have been unpacked +# Best practice suggests you execute the hooks/install to ensure all updates are processed - +# hooks/config_change is triggered automatically +set -e + +$CHARM_DIR/hooks/install diff --git a/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/icon.svg b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/icon.svg new file mode 100644 index 00000000..f9ac92c4 --- /dev/null +++ b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/icon.svg @@ -0,0 +1,407 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/lib/reconfigure-aio b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/lib/reconfigure-aio new file mode 100755 index 00000000..a7cad909 --- /dev/null +++ b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/lib/reconfigure-aio @@ -0,0 +1,55 @@ +#!/bin/bash +# Reconfigures an all-in-one image to use a new home domain and number range. +# Usage: reconfigure-aio [ ] + +# Get command-line arguments. +home_domain=$1 +base_number=$2 +number_count=$3 + +if [ -z "$home_domain" ] ; then + echo "Usage: reconfigure-aio [ ]" +fi + +# Remove all old numbers from the database, unless they're currently assigned. +# We do this even if the home domain hasn't changed, because the number range might have done (and +# it's hard to tell if that's happened, and cheap/low-impact to just do the reprovisioning). +old_home_domain=$(. /etc/clearwater/config ; echo $home_domain) +echo "DELETE FROM ellis.numbers WHERE number LIKE '%@$old_home_domain' AND owner_id IS NULL ;" | mysql + +# Update /etc/clearwater/shared_config, if the home domain has changed. +if [ "$home_domain" != "$old_home_domain" ] ; then + function escape { echo $1 | sed -e 's/\//\\\//g' ; } + sed -e 's/^home_domain=.*$/home_domain='$(escape $home_domain)'/g' \ + /tmp/shared_config.$$ + mv /tmp/shared_config.$$ /etc/clearwater/shared_config + + # Restart clearwater-infrastructure to propagate changes to other configuration files. + service clearwater-infrastructure restart +fi + +# Create new numbers in the new domain, if we've been asked to. +if [ -n "$base_number" ] && [ -n "$number_count" ] ; then + /usr/share/clearwater/ellis/env/bin/python /usr/share/clearwater/ellis/src/metaswitch/ellis/tools/create_numbers.py --start $base_number --count $number_count +fi + +# Restart all the components, if the home domain has changed. +if [ "$home_domain" != "$old_home_domain" ] ; then + # Work around https://github.com/Metaswitch/sprout/issues/1296. + service bono stop + + # Restart all the processes. + for X in /usr/share/clearwater/infrastructure/scripts/restart/* ; do $X ; done + + # Kick monit to wake up and sleep for 10 seconds to make sure it has an accurate view of the system. + monit + sleep 10 + + # Now wait until all the processes are back up and running (or at least "Uptime failed", which + # means the process is running, just hasn't been running for very long). + while monit summary | grep _process | egrep -v "(Running|Uptime failed)" ; do + echo Some processes still not running - waiting... + sleep 2 + done + echo All processes running - configuration complete! +fi diff --git a/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/metadata.yaml b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/metadata.yaml new file mode 100644 index 00000000..4f1ad130 --- /dev/null +++ b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/metadata.yaml @@ -0,0 +1,10 @@ +name: clearwater-aio-proxy +summary: All-in-One proxy charm for Project Clearwater +maintainer: Project Clearwater Maintainers +description: All-in-One proxy charm for Project Clearwater +tags: + - misc +subordinate: false +provides: + ue: + interface: 3GPP-Gm diff --git a/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/revision b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/revision new file mode 100644 index 00000000..d00491fd --- /dev/null +++ b/src/vnfd/ims_allin1_2p_vnf/charms/clearwater-aio-proxy/revision @@ -0,0 +1 @@ +1 diff --git a/src/vnfd/ims_allin1_2p_vnf/icons/metaswitch_2x.png b/src/vnfd/ims_allin1_2p_vnf/icons/metaswitch_2x.png new file mode 100644 index 00000000..a899bc8e Binary files /dev/null and b/src/vnfd/ims_allin1_2p_vnf/icons/metaswitch_2x.png differ