Sergio Slobodrian | be82927 | 2017-07-17 14:45:45 -0400 | [diff] [blame] | 1 | #!/bin/bash |
Zack Williams | 41513bf | 2018-07-07 20:08:35 -0700 | [diff] [blame] | 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
Sergio Slobodrian | be82927 | 2017-07-17 14:45:45 -0400 | [diff] [blame] | 15 | |
| 16 | # This script is for developers only. It will move a container from |
| 17 | # the voltha VM to the registry and from the registry to each of the |
| 18 | # machines in the cluster. The script is pretty dumb so it will fail |
| 19 | # if a service is running that needs the container so it's best to |
| 20 | # ensure that this isn't the case. |
| 21 | |
| 22 | cont=$1 |
| 23 | uid=`id -u` |
| 24 | iVmName="vInstaller${uid}" |
| 25 | vVmName="voltha_voltha${uid}" |
| 26 | volthaHome=~/cord/incubator/voltha |
| 27 | iIpAddr=`virsh domifaddr $iVmName | tail -n +3 | awk '{ print $4 }' | sed -e 's~/.*~~'` |
| 28 | vIpAddr=`virsh domifaddr $vVmName | tail -n +3 | awk '{ print $4 }' | sed -e 's~/.*~~'` |
| 29 | pushd ~/cord/incubator/voltha/install |
| 30 | # Delete the registry push tag and create a new one just to be sure it points to the right container |
| 31 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ../.vagrant/machines/voltha${uid}/libvirt/private_key vagrant@$vIpAddr "docker rmi localhost:5000/${1}" |
| 32 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ../.vagrant/machines/voltha${uid}/libvirt/private_key vagrant@$vIpAddr "docker tag ${1} localhost:5000/${1}" |
| 33 | |
| 34 | # Push the container to the registry |
| 35 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ../.vagrant/machines/voltha${uid}/libvirt/private_key vagrant@$vIpAddr "docker push localhost:5000/${1}" |
| 36 | |
| 37 | scp -r -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i key.pem vinstall@$iIpAddr:.keys .tmp.keys |
| 38 | |
| 39 | for i in .tmp.keys/* |
| 40 | do |
| 41 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $i voltha@`basename $i` docker rmi -f ${1} |
| 42 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $i voltha@`basename $i` docker rmi -f localhost:5000/${1} |
| 43 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $i voltha@`basename $i` docker pull localhost:5000/${1} |
| 44 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $i voltha@`basename $i` docker tag localhost:5000/${1} ${1} |
| 45 | done |
| 46 | |
| 47 | #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' |
| 48 | #scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ../.vagrant/machines/voltha${uid}/libvirt/private_key key.pem vagrant@$vIpAddr:. |
| 49 | #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" |
| 50 | popd |