From bb1fc90414831c6aedae01995a6bfb878373f43d Mon Sep 17 00:00:00 2001 From: Instrumental Date: Thu, 16 Aug 2018 17:16:56 -0500 Subject: Adjust aaf HEAT shs Issue-ID: AAF-419 Change-Id: Id4fbce7fb25c703a74f93afbbb519b980d5b96dd Signed-off-by: Instrumental --- heat/ONAP/cloud-config/aaf_install.sh | 489 ++---------------------- heat/ONAP/cloud-config/aaf_vm_init.sh | 117 ++++-- heat/ONAP/cloud-config/sample_ca/.gitignore | 1 + heat/ONAP/cloud-config/sample_ca/aaf.signer.p12 | Bin 0 -> 2850 bytes 4 files changed, 125 insertions(+), 482 deletions(-) create mode 100644 heat/ONAP/cloud-config/sample_ca/.gitignore create mode 100644 heat/ONAP/cloud-config/sample_ca/aaf.signer.p12 (limited to 'heat') diff --git a/heat/ONAP/cloud-config/aaf_install.sh b/heat/ONAP/cloud-config/aaf_install.sh index 61f23daa..c2389d03 100644 --- a/heat/ONAP/cloud-config/aaf_install.sh +++ b/heat/ONAP/cloud-config/aaf_install.sh @@ -1,453 +1,46 @@ #!/bin/bash - -# Read configuration files -GERRIT_BRANCH=$(cat /opt/config/gerrit_branch.txt) -CODE_REPO=$(cat /opt/config/remote_repo.txt) -HTTP_PROXY=$(cat /opt/config/http_proxy.txt) -HTTPS_PROXY=$(cat /opt/config/https_proxy.txt) - -if [ $HTTP_PROXY != "no_proxy" ] -then - export http_proxy=$HTTP_PROXY - export https_proxy=$HTTPS_PROXY + +CURRENT_DIR=$(pwd) +export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1) + +NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) +NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) +NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt) +HOSTNAME=`hostname -f` +FQDN=aaf.api.simpledemo.onap.org +HOST_IP=$(cat /opt/config/local_ip.txt) + +echo "$NEXUS_PASSWD" | docker login -u $NEXUS_USERNAME --password-stdin $NEXUS_DOCKER_REPO + +if [ -e "/opt/authz" ]; then + cd /opt/authz + git pull +else + cd /opt + git clone https://gerrit.onap.org/r/aaf/authz + cd authz fi - -# Download dependencies -echo "deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list -echo "deb-src http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list -apt-get update -apt-get install --allow-unauthenticated -y openjdk-8-jdk maven - -# Clone Gerrit repository and run docker containers -cd /opt -git clone -b $GERRIT_BRANCH --single-branch $CODE_REPO -chmod +x /opt/authz/auth/auth-cass/docker/dinstall.sh -chmod +x /opt/authz/auth/auth-cass/docker/backup/backup.sh -chmod +x /opt/authz/auth/docker/dbuild.sh -chmod +x /opt/authz/auth/docker/drun.sh -chmod +x /opt/authz/auth/docker/dstart.sh -chmod +x /opt/authz/auth/docker/dstop.sh - -#Update maven settings -cat > /usr/share/maven/conf/settings.xml << EOF - - - - - - - - - - - - - - - - - -EOF - -if [[ $(cat /opt/config/https_proxy.txt) != "no_proxy" ]]; then - HTTPS_PROXY_HOST=$(cat /opt/config/https_proxy.txt | cut -d ':' -f1) - HTTPS_PROXY_PORT=$(cat /opt/config/https_proxy.txt | cut -d ':' -f2) - - cat >> settings.xml << EOF - - - - optional - true - http - proxyuser - proxypass - $HTTPS_PROXY_HOST - $HTTPS_PROXY_PORT - local.net|some.host.com - - - optional - true - https - proxyuser - proxypass - $HTTPS_PROXY_HOST - $HTTPS_PROXY_PORT - local.net|some.host.com - - - -EOF +cd /opt/authz/auth/auth-cass/docker +if [ "`docker container ls | grep aaf_cass`" = "" ]; then + # Cassandra Install + echo Phase 1 Cassandra Install + /bin/bash ./dinstall.sh fi + +CASS_IP=`docker inspect aaf_cass | grep '"IPAddress' | head -1 | cut -d '"' -f 4` +CASS_HOST="cass.aaf.osaaf.org:"$CASS_IP + +docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_config:latest +docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_core:latest +docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_cm:latest +docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_fs:latest +docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_gui:latest +docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_hello:latest +docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_locate:latest +docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_oauth:latest +docker pull $NEXUS_DOCKER_REPO/onap/aaf/aaf_service:latest + +cd $CURRENT_DIR +/bin/bash ./aaf_vm_init.sh -cat >> settings.xml << EOF - - - - - - - - - - - - - - - - - - - - 10_nexus - - - - - 10_nexus - http://repo.maven.apache.org/maven2/ - true - true - - - - - - 10_nexus - http://repo.maven.apache.org/maven2/ - true - true - - - - - - 20_openecomp-public - - - 20_openecomp-public - 20_openecomp-public - https://nexus.onap.org/content/repositories/public/ - - true - daily - - - false - - - - - - 20_openecomp-public - 20_openecomp-public - https://nexus.onap.org/content/repositories/public/ - - true - daily - - - false - - - - - - 30_openecomp-staging - - - 30_openecomp-staging - 30_openecomp-staging - https://nexus.onap.org/content/repositories/staging/ - - true - daily - - - false - - - - - - 30_openecomp-staging - 30_openecomp-staging - https://nexus.onap.org/content/repositories/staging/ - - true - daily - - - false - - - - - - 40_openecomp-release - - - 40_openecomp-release - 40_openecomp-release - https://nexus.onap.org/content/repositories/releases/ - - true - daily - - - false - - - - - - 40_openecomp-release - 40_openecomp-release - https://nexus.onap.org/content/repositories/releases/ - - true - daily - - - false - - - - - - - 50_openecomp-snapshots - - - 50_openecomp-snapshot - 50_openecomp-snapshot - https://nexus.onap.org/content/repositories/snapshots/ - - false - - - true - - - - - - 50_openecomp-snapshot - 50_openecomp-snapshot - https://nexus.onap.org/content/repositories/snapshots/ - - false - - - true - - - - - - 60_opendaylight-release - - - 60_opendaylight-mirror - 60_opendaylight-mirror - https://nexus.opendaylight.org/content/repositories/public/ - - true - daily - - - false - - - - - - 60_opendaylight-mirror - 60_opendaylight-mirror - https://nexus.opendaylight.org/content/repositories/public/ - - true - daily - - - false - - - - - - - 70_opendaylight-snapshots - - - 70_opendaylight-snapshot - 70_opendaylight-snapshot - https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ - - false - - - true - - - - - - 70_opendaylight-snapshot - 70_opendaylight-snapshot - https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ - - false - - - true - - - - - - - - 10_nexus - 20_openecomp-public - 30_openecomp-staging - 40_openecomp-release - 50_openecomp-snapshots - 60_opendaylight-release - 70_opendaylight-snapshots - - - - -EOF - -cd /opt/authz -mvn install -Dmaven.test.skip=true - -cd /opt -./aaf_vm_init.sh diff --git a/heat/ONAP/cloud-config/aaf_vm_init.sh b/heat/ONAP/cloud-config/aaf_vm_init.sh index a388bf2f..59486e94 100644 --- a/heat/ONAP/cloud-config/aaf_vm_init.sh +++ b/heat/ONAP/cloud-config/aaf_vm_init.sh @@ -1,55 +1,104 @@ #!/bin/bash +CURRENT_DIR=$(pwd) + NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) -NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt) -DOCKER_IMAGE_VERSION=$(cat /opt/config/docker_version.txt) -HOSTNAME=`hostname` -FQDN=aaf.api.simpledemo.onap.org -HOST_IP=$(cat /opt/config/local_ip.txt) - -docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO +if [ -e /opt/authz/auth/docker/d.props ]; then + NEXUS_DOCKER_REPO=`grep "DOCKER_REPOSITORY=" /opt/authz/auth/docker/d.props` +else + NEXUS_DOCKER_REPO="DOCKER_REPOSITORY=" +fi -cd /opt/authz -git pull +if [ "$NEXUS_DOCKER_REPO" = "DOCKER_REPOSITORY=" ]; then + NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt) +else + NEXUS_DOCKER_REPO=${NEXUS_DOCKER_REPO#DOCKER_REPOSITORY=} +fi +echo $NEXUS_DOCKER_REPO +HOSTNAME=`hostname -f` +FQDN=aaf.api.simpledemo.onap.org +HOST_IP=$(cat /opt/config/local_ip.txt) cd /opt/authz/auth/auth-cass/docker if [ "`docker container ls | grep aaf_cass`" = "" ]; then # Cassandra Install echo Phase 1 Cassandra Install - ./dinstall.sh + bash ./dinstall.sh fi +if [ ! -e /opt/authz/auth/docker/d.props ]; then + cp /opt/authz/auth/docker/d.props.init /opt/authz/auth/docker/d.props +fi + +VERSION=$(grep VERSION /opt/authz/auth/docker/d.props) +VERSION=${VERSION#VERSION=} CASS_IP=`docker inspect aaf_cass | grep '"IPAddress' | head -1 | cut -d '"' -f 4` CASS_HOST="cass.aaf.osaaf.org:"$CASS_IP - -sed -i "s/DOCKER_REPOSITORY=.*/DOCKER_REPOSITORY="$NEXUS_DOCKER_REPO"/g" /opt/authz/auth/docker/d.props -#sed -i "s/VERSION=.*/VERSION="$DOCKER_IMAGE_VERSION"/g" /opt/authz/auth/docker/d.props -sed -i "s/HOSTNAME=.*/HOSTNAME="$HOSTNAME"/g" /opt/authz/auth/docker/d.props -sed -i "s/HOST_IP=.*/HOST_IP="$HOST_IP"/g" /opt/authz/auth/docker/d.props -sed -i "s/CASS_HOST=.*/CASS_HOST="$CASS_HOST"/g" /opt/authz/auth/docker/d.props - -if [ ! -e "/opt/app/osaaf/etc" ]; then - # Nothing installed, install sample - mkdir -p /opt/app/osaaf/logs - cd /opt/app/osaaf/logs - mkdir fs cm gui hello locate oauth service - cd /opt - cp -Rf /opt/authz/auth/sample/* /opt/app/osaaf +if [ ! -e /opt/authz/auth/docker/cass.props ]; then + cp /opt/authz/auth/docker/cass.props.init /opt/authz/auth/docker/cass.props fi -# Set Location information -# Need new Deployment system properties + +sed -i "s/CASS_HOST=.*/CASS_HOST="$CASS_HOST"/g" /opt/authz/auth/docker/cass.props +# TODO Pull from Config Dir CADI_LATITUDE=37.781 CADI_LONGITUDE=-122.261 -CADI_TRUST_MASKS="${HOST_IP%\.[0-9]*}\\/24,${CASS_IP%\.[0-9]*}\\/24" -sed -i "s/cadi_latitude=.*/cadi_latitude="$CADI_LATITUDE"/g" /opt/app/osaaf/local/org.osaaf.location.props -sed -i "s/cadi_longitude=.*/cadi_longitude="$CADI_LONGITUDE"/g" /opt/app/osaaf/local/org.osaaf.location.props -sed -i "s/cadi_registration_hostname=.*/cadi_registration_hostname="$FQDN"/g" /opt/app/osaaf/local/org.osaaf.location.props -sed -i "s/cadi_trust_masks=.*/cadi_trust_masks="$CADI_TRUST_MASKS"/g" /opt/app/osaaf/local/org.osaaf.location.props +sed -i "s/DOCKER_REPOSITORY=.*/DOCKER_REPOSITORY=$NEXUS_DOCKER_REPO/g" /opt/authz/auth/docker/d.props +sed -i "s/VERSION=.*/VERSION=$VERSION/g" /opt/authz/auth/docker/d.props +sed -i "s/HOSTNAME=.*/HOSTNAME=$HOSTNAME/g" /opt/authz/auth/docker/d.props +sed -i "s/HOST_IP=.*/HOST_IP=$HOST_IP/g" /opt/authz/auth/docker/d.props +sed -i "s/LATITUDE=.*/LATITUDE=$CADI_LATITUDE/g" /opt/authz/auth/docker/d.props +sed -i "s/LONGITUDE=.*/LONGITUDE=$CADI_LONGITUDE/g" /opt/authz/auth/docker/d.props + +SIGNER_P12="$CURRENT_DIR/sample_ca/aaf.signer.p12" +AAF_P12="$CURRENT_DIR/sample_ca/aaf.bootstrap.p12" +P12_PASSWORD="something easy" + +if [ ! -e "$AAF_P12" ]; then + mkdir -p $CURRENT_DIR/sample_ca + cd /opt/authz/conf/CA + /bin/bash bootstrap.sh $SIGNER_P12 "$P12_PASSWORD" + if [ ! -e "aaf.bootstrap.p12" ]; then + echo "Certificates NOT created. Stopping installation" + exit + else + mv aaf.bootstrap.p12 $AAF_P12 + fi + cd - +fi + +if [ -e "$AAF_P12" ]; then + sed -i "s/AAF_INITIAL_X509_P12=.*/AAF_INITIAL_X509_P12=${AAF_P12//\//\\/}/g" /opt/authz/auth/docker/d.props + sed -i "s/AAF_INITIAL_X509_PASSWORD=.*/AAF_INITIAL_X509_PASSWORD=\"$P12_PASSWORD\"/g" /opt/authz/auth/docker/d.props +fi + +if [ -e "$SIGNER_P12" ]; then + if [ -e "/opt/config/cadi_x509_issuers.txt" ]; then + ISSUERS=$(cat "/opt/config/cadi_x509_issuers.txt")":" + fi + # Pick the REAL subject off the P12 + SUBJECT=$(echo "$P12_PASSWORD" | openssl pkcs12 -info -clcerts -in $SIGNER_P12 -nokeys -passin stdin | grep subject) + SUBJECT=${SUBJECT//\// } + SUBJECT=${SUBJECT/subject= /} + # Needs to be reversed, separated by ", " + for S in $SUBJECT ; do + if [ "$RSUBJECT" = "" ]; then + RSUBJECT=$S + else + RSUBJECT="$S, $RSUBJECT" + fi + done + ISSUERS="$ISSUERS$RSUBJECT" + sed -i "s/CADI_X509_ISSUERS=.*/CADI_X509_ISSUERS=\"$ISSUERS\"/g" /opt/authz/auth/docker/d.props + sed -i "s/AAF_SIGNER_P12=.*/AAF_SIGNER_P12=${SIGNER_P12//\//\\/}/g" /opt/authz/auth/docker/d.props + sed -i "s/AAF_SIGNER_PASSWORD=.*/AAF_SIGNER_PASSWORD=\"$P12_PASSWORD\"/g" /opt/authz/auth/docker/d.props +fi cd /opt/authz/auth/docker -./dbuild.sh -sleep 5 -./drun.sh +# Need new Deployment system properties +bash ./aaf.sh + +# run it +bash ./drun.sh diff --git a/heat/ONAP/cloud-config/sample_ca/.gitignore b/heat/ONAP/cloud-config/sample_ca/.gitignore new file mode 100644 index 00000000..5f8bc015 --- /dev/null +++ b/heat/ONAP/cloud-config/sample_ca/.gitignore @@ -0,0 +1 @@ +aaf.bootstrap.p12 diff --git a/heat/ONAP/cloud-config/sample_ca/aaf.signer.p12 b/heat/ONAP/cloud-config/sample_ca/aaf.signer.p12 new file mode 100644 index 00000000..8de21238 Binary files /dev/null and b/heat/ONAP/cloud-config/sample_ca/aaf.signer.p12 differ -- cgit 1.2.3-korg