blob: f3d519ac036bd3fd40c5da7572888b37c9abdfcf [file] [log] [blame]
Sergio Slobodrianbe829272017-07-17 14:45:45 -04001#!/bin/bash
2
3# This script is for developers only. It will move a container from
4# the voltha VM to the registry and from the registry to each of the
5# machines in the cluster. The script is pretty dumb so it will fail
6# if a service is running that needs the container so it's best to
7# ensure that this isn't the case.
8
9cont=$1
10uid=`id -u`
11iVmName="vInstaller${uid}"
12vVmName="voltha_voltha${uid}"
13volthaHome=~/cord/incubator/voltha
14iIpAddr=`virsh domifaddr $iVmName | tail -n +3 | awk '{ print $4 }' | sed -e 's~/.*~~'`
15vIpAddr=`virsh domifaddr $vVmName | tail -n +3 | awk '{ print $4 }' | sed -e 's~/.*~~'`
16pushd ~/cord/incubator/voltha/install
17# Delete the registry push tag and create a new one just to be sure it points to the right container
18ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ../.vagrant/machines/voltha${uid}/libvirt/private_key vagrant@$vIpAddr "docker rmi localhost:5000/${1}"
19ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ../.vagrant/machines/voltha${uid}/libvirt/private_key vagrant@$vIpAddr "docker tag ${1} localhost:5000/${1}"
20
21# Push the container to the registry
22ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ../.vagrant/machines/voltha${uid}/libvirt/private_key vagrant@$vIpAddr "docker push localhost:5000/${1}"
23
24scp -r -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i key.pem vinstall@$iIpAddr:.keys .tmp.keys
25
26for i in .tmp.keys/*
27do
28 ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $i voltha@`basename $i` docker rmi -f ${1}
29 ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $i voltha@`basename $i` docker rmi -f localhost:5000/${1}
30 ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $i voltha@`basename $i` docker pull localhost:5000/${1}
31 ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $i voltha@`basename $i` docker tag localhost:5000/${1} ${1}
32done
33
34#ssh -f -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i key.pem vinstall@$iIpAddr 'for i in .keys/*; do ssh -f -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ServerAliveInterval=600 -o ServerAliveCountMax=9999 -i $i voltha@`basename $i` docker rmi -f '${1}' && docker rmi -f localhost:5000/'${1}' && docker pull localhost:5000/'${1}' && docker tag localhost:5000/'${1}' '${1}'; done'
35#scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ../.vagrant/machines/voltha${uid}/libvirt/private_key key.pem vagrant@$vIpAddr:.
36#ssh -f -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ../.vagrant/machines/voltha${uid}/libvirt/private_key vagrant@$vIpAddr "ssh -f -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ServerAliveInterval=600 -o ServerAliveCountMax=9999 -L 5000:localhost:5000 -i key.pem vinstall@${iIpAddr} sleep 5999400"
37popd