From 7fb99ea126387138b77512e12c19b5e75a514270 Mon Sep 17 00:00:00 2001 From: Lusheng Ji Date: Mon, 16 Apr 2018 02:29:03 -0400 Subject: Add R2 heat deployment of DCAE Issue-ID: DCAEGEN2-434 Change-Id: Iab71fe366d2e518db0fdf3ab98bbe45e4492751a Signed-off-by: Lusheng Ji --- boot/dcae2_install.sh | 59 ++----------- boot/dcae2_vm_init.sh | 236 ++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 188 insertions(+), 107 deletions(-) diff --git a/boot/dcae2_install.sh b/boot/dcae2_install.sh index 3446b6c2..ac3c3b56 100755 --- a/boot/dcae2_install.sh +++ b/boot/dcae2_install.sh @@ -46,7 +46,9 @@ apt-get update apt-get install --allow-unauthenticated -y apt-transport-https ca-certificates wget git ntp ntpdate python python-pip # Download scripts from Nexus +if [ ! -e /opt/dcae2_vm_init.sh ]; then curl -k "$NEXUS_REPO/org.onap.demo/boot/$ARTIFACTS_VERSION/dcae2_vm_init.sh" -o /opt/dcae2_vm_init.sh +fi curl -k "$NEXUS_REPO/org.onap.demo/boot/$ARTIFACTS_VERSION/dcae2_serv.sh" -o /opt/dcae2_serv.sh chmod +x /opt/dcae2_vm_init.sh chmod +x /opt/dcae2_serv.sh @@ -75,13 +77,17 @@ if [ -s /opt/config/external_dns.txt ] then DNS_FLAG=$DNS_FLAG"--dns $(cat /opt/config/external_dns.txt) " fi -echo "DOCKER_OPTS=\"$DNS_FLAG--mtu=$MTU\"" >> /etc/default/docker +echo "DOCKER_OPTS=\"$DNS_FLAG--mtu=$MTU --raw-logs -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock\"" >> /etc/default/docker cp /lib/systemd/system/docker.service /etc/systemd/system sed -i "/ExecStart/s/$/ --mtu=$MTU/g" /etc/systemd/system/docker.service +sed -i "/ExecStart/s/$/ -H tcp:\/\/0.0.0.0:2376 --raw-logs/g" /etc/systemd/system/docker.service systemctl daemon-reload service docker restart +# add hostname aliases +echo "$(cat /opt/config/dcae_ip_addr.txt) consul" >>/etc/hosts +echo "$(cat /opt/config/dcae_ip_addr.txt) dockerhost" >>/etc/hosts # DNS IP address configuration echo "nameserver $DNS_IP_ADDR" >> /etc/resolvconf/resolv.conf.d/head @@ -101,52 +107,5 @@ chmod 777 /opt/app/config/key #cp /opt/config/keystone_url.txt /opt/app/config/keystone_url.txt -URL_ROOT='nexus.onap.org/service/local/repositories/raw/content' -REPO_BLUEPRINTS='org.onap.dcaegen2.platform.blueprints' -REPO_DEPLOYMENTS='org.onap.dcaegen2.deployments' - -if [ -e /opt/config/dcae_deployment_profile.txt ]; then - DEPLOYMENT_PROFILE=$(cat /opt/config/dcae_deployment_profile.txt) -fi -DEPLOYMENT_PROFILE=${DEPLOYMENT_PROFILE:-R1} -if [ "$DEPLOYMENT_PROFILE" == "R1" ]; then - RELEASE_TAG='releases' - # download blueprint input template files - rm -rf /opt/app/inputs-templates - mkdir -p /opt/app/inputs-templates - wget -P /opt/app/inputs-templates https://${URL_ROOT}/${REPO_BLUEPRINTS}/${RELEASE_TAG}/input-templates/inputs.yaml - wget -P /opt/app/inputs-templates https://${URL_ROOT}/${REPO_BLUEPRINTS}/${RELEASE_TAG}/input-templates/cdapinputs.yaml - wget -P /opt/app/inputs-templates https://${URL_ROOT}/${REPO_BLUEPRINTS}/${RELEASE_TAG}/input-templates/phinputs.yaml - wget -P /opt/app/inputs-templates https://${URL_ROOT}/${REPO_BLUEPRINTS}/${RELEASE_TAG}/input-templates/dhinputs.yaml - wget -P /opt/app/inputs-templates https://${URL_ROOT}/${REPO_BLUEPRINTS}/${RELEASE_TAG}/input-templates/invinputs.yaml - wget -P /opt/app/inputs-templates https://${URL_ROOT}/${REPO_BLUEPRINTS}/${RELEASE_TAG}/input-templates/vesinput.yaml - wget -P /opt/app/inputs-templates https://${URL_ROOT}/${REPO_BLUEPRINTS}/${RELEASE_TAG}/input-templates/tcainputs.yaml - wget -P /opt/app/inputs-templates https://${URL_ROOT}/${REPO_BLUEPRINTS}/${RELEASE_TAG}/input-templates/he-ip.yaml - wget -P /opt/app/inputs-templates https://${URL_ROOT}/${REPO_BLUEPRINTS}/${RELEASE_TAG}/input-templates/hr-ip.yaml - - - # generate blueprint input files - pip install --upgrade jinja2 - wget https://${URL_ROOT}/${REPO_DEPLOYMENTS}/${RELEASE_TAG}/scripts/detemplate-bpinputs.py && \ - (python detemplate-bpinputs.py /opt/config /opt/app/inputs-templates /opt/app/config; rm detemplate-bpinputs.py) - - # Run docker containers - cd /opt - ./dcae2_vm_init.sh -fi - -if [ "$DEPLOYMENT_PROFILE" == "R2MVP" ]; then - RELEASE_TAG='R2' - rm -rf /opt/app/inputs-templates - mkdir -p /opt/app/inputs-templates - wget -P /opt/app/inputs-templates https://${URL_ROOT}/${REPO_DEPLOYMENTS}/${RELEASE_TAG}/heat/${DEPLOYMENT_PROFILE}/docker-compose-1.yaml - wget -P /opt/app/inputs-templates https://${URL_ROOT}/${REPO_DEPLOYMENTS}/${RELEASE_TAG}/heat/${DEPLOYMENT_PROFILE}/docker-compose-2.yaml - - pip install --upgrade jinja2 - wget https://${URL_ROOT}/${REPO_DEPLOYMENTS}/${RELEASE_TAG}/scripts/detemplate-bpinputs.py && \ - (python detemplate-bpinputs.py /opt/config /opt/app/inputs-templates /opt/app/config; rm detemplate-bpinputs.py) - - cd /opt - ./dcae2_vm_init.sh -fi - +cd /opt +#./dcae2_vm_init.sh diff --git a/boot/dcae2_vm_init.sh b/boot/dcae2_vm_init.sh index ac6713d0..d26bb47a 100755 --- a/boot/dcae2_vm_init.sh +++ b/boot/dcae2_vm_init.sh @@ -595,6 +595,19 @@ list_dns_zone() curl -v -s -H "Content-Type: application/json" -H "X-Auth-Token: $TOKEN" -X GET "${MULTICLOUD_PLUGIN_ENDPOINT}/dns-delegate/v2/zones/${ZONEID}/recordsets" } +################################## start of vm_init ##################################### + +# prepare the configurations needed by DCAEGEN2 installer +rm -rf /opt/app/config +mkdir -p /opt/app/config + + +# private key +sed -e 's/\\n/\n/g' /opt/config/priv_key | sed -e 's/^[ \t]*//g; s/[ \t]*$//g' > /opt/app/config/key +chmod 777 /opt/app/config/key + +# move keystone url file +#cp /opt/config/keystone_url.txt /opt/app/config/keystone_url.txt URL_ROOT='nexus.onap.org/service/local/repositories/raw/content' @@ -614,13 +627,39 @@ ZONE=$(cat /opt/config/rand_str.txt) MYFLOATIP=$(cat /opt/config/dcae_float_ip.txt) MYLOCALIP=$(cat /opt/config/dcae_ip_addr.txt) + # start docker image pulling while we are waiting for A&AI to come online docker login -u "$NEXUS_USER" -p "$NEXUS_PASSWORD" "$NEXUS_DOCKER_REPO" - if [ "$DEPLOYMENT_PROFILE" == "R1" ]; then - docker pull "$NEXUS_DOCKER_REPO/onap/org.onap.dcaegen2.deployments.bootstrap:$DOCKER_VERSION" && docker pull nginx & + RELEASE_TAG='releases' + # download blueprint input template files + rm -rf /opt/app/inputs-templates + mkdir -p /opt/app/inputs-templates + wget -P /opt/app/inputs-templates https://${URL_ROOT}/${REPO_BLUEPRINTS}/${RELEASE_TAG}/input-templates/inputs.yaml + wget -P /opt/app/inputs-templates https://${URL_ROOT}/${REPO_BLUEPRINTS}/${RELEASE_TAG}/input-templates/cdapinputs.yaml + wget -P /opt/app/inputs-templates https://${URL_ROOT}/${REPO_BLUEPRINTS}/${RELEASE_TAG}/input-templates/phinputs.yaml + wget -P /opt/app/inputs-templates https://${URL_ROOT}/${REPO_BLUEPRINTS}/${RELEASE_TAG}/input-templates/dhinputs.yaml + wget -P /opt/app/inputs-templates https://${URL_ROOT}/${REPO_BLUEPRINTS}/${RELEASE_TAG}/input-templates/invinputs.yaml + wget -P /opt/app/inputs-templates https://${URL_ROOT}/${REPO_BLUEPRINTS}/${RELEASE_TAG}/input-templates/vesinput.yaml + wget -P /opt/app/inputs-templates https://${URL_ROOT}/${REPO_BLUEPRINTS}/${RELEASE_TAG}/input-templates/tcainputs.yaml + wget -P /opt/app/inputs-templates https://${URL_ROOT}/${REPO_BLUEPRINTS}/${RELEASE_TAG}/input-templates/he-ip.yaml + wget -P /opt/app/inputs-templates https://${URL_ROOT}/${REPO_BLUEPRINTS}/${RELEASE_TAG}/input-templates/hr-ip.yaml + + # generate blueprint input files + pip install --upgrade jinja2 + wget https://${URL_ROOT}/${REPO_DEPLOYMENTS}/${RELEASE_TAG}/scripts/detemplate-bpinputs.py \ + && \ + (python detemplate-bpinputs.py /opt/config /opt/app/inputs-templates /opt/app/config; \ + rm detemplate-bpinputs.py) + + # Run docker containers + cd /opt + + + docker pull "$NEXUS_DOCKER_REPO/onap/org.onap.dcaegen2.deployments.bootstrap:$DOCKER_VERSION" \ + && docker pull nginx & ######################################### # Wait for then register with A&AI @@ -666,25 +705,40 @@ if [ "$DEPLOYMENT_PROFILE" == "R1" ]; then # start proxy for consul's health check CONSULIP=$(head -1 /opt/app/config/runtime.ip.consul | sed 's/[[:space:]]//g') echo "Consul is available at $CONSULIP" - - cat >./nginx.conf <./nginx.conf < /tmp/healthcheck/r2mvp_healthy.yaml + echo "${DATA}" > /tmp/healthcheck/services.yaml + fi + + if [[ -n $CONSUL && -n $CBS && -n $PLT_CM && -n $PLT_DH && \ + -n $PLT_PH && -n $PLT_SCH && -n $PLT_INV && -n $PLT_PG_INVENTORY ]]; then + echo "${DATA}" > /tmp/healthcheck/r2_healthy.yaml + + if [[ -n $PLUS_MHB && -n $PLUS_PRH && -n $PLUS_MPR && -n $PLUS_TRAP ]]; then + echo "${DATA}" > /tmp/healthcheck/r2plus_healthy.yaml + fi + fi + + sleep 60 +done + -- cgit 1.2.3-korg