#!/bin/bash

export JUJU_REPOSITORY=`pwd`/charm-sources
export CHARM_LAYERS_DIR=$JUJU_REPOSITORY/layers
export CHARM_BUILD_DIR=`pwd`/vEPC_vnfd/charms

rm -rf $CHARM_BUILD_DIR

for charm in hsscharm spgwcharm; do
    cd $CHARM_LAYERS_DIR/$charm
    charm build &
    cd -
done

wait

for file in vEPC_nsd vEPC_vnfd
do
    rm ${file}.tar.gz
    tar -czf ${file}.tar.gz ${file}/
done

osm nsd-delete  vEPC_nsd
osm vnfd-delete vEPC_vnfd

osm vnfd-create vEPC_vnfd.tar.gz || exit 1
osm nsd-create vEPC_nsd.tar.gz || exit 1

osm ns-create --ns_name NextEPC --nsd_name vEPC_nsd --ssh_keys ~/.ssh/id_rsa.pub --config_file params.yaml --vim_account vnfob
