summaryrefslogtreecommitdiffstats
path: root/utils/infra_setup/vm_dev_setup
diff options
context:
space:
mode:
Diffstat (limited to 'utils/infra_setup/vm_dev_setup')
-rw-r--r--utils/infra_setup/vm_dev_setup/common.sh65
-rw-r--r--utils/infra_setup/vm_dev_setup/package.conf3
-rwxr-xr-xutils/infra_setup/vm_dev_setup/setup_env.sh60
-rw-r--r--utils/infra_setup/vm_dev_setup/vm_prepare_setup.sh18
4 files changed, 131 insertions, 15 deletions
diff --git a/utils/infra_setup/vm_dev_setup/common.sh b/utils/infra_setup/vm_dev_setup/common.sh
new file mode 100644
index 00000000..625a447e
--- /dev/null
+++ b/utils/infra_setup/vm_dev_setup/common.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+generate_ssh_key() {
+ if [ ! -d ~/.ssh ]; then
+ mkdir ~/.ssh
+ fi
+
+ cat << EOF > ~/.ssh/id_rsa
+-----BEGIN RSA PRIVATE KEY-----
+MIIEowIBAAKCAQEAsJsfP/OlXNcqqqZTD5Jv8OsAdq+WJegozjfOSqOUszxKZ8rC
+cDucoGzApUE28wlM7SKRXjvA+sXVpYT5oTBCSFrUYfg8dLMAfgcjK2hkz/dscSqN
+rpFs2COnrtuS5iV/mtZZlT5nsEKvunT8yMIAmb8A/FFXuS/ndBD9q294p4kFaAc5
+LFJoS9zeo6di4KbHH4tclxYIxXS6Q7AnBXDPkOsEFAtvqhgWGuUcanq3FsyEkm7w
+LGMAu1HqZoxaXI91v1l9kHDggyJQM3lEbwvD2zncwrYHjIboR9uPfQXCFEszzKY8
+76UYh6+Unhf86z3lvthItTHx4taqwQsUvCQarQIDAQABAoIBAHF4ea+hYFIyfVt/
+2kZbFEl69KVNU++vJui4uncCe3xd9ICTqjJqWsxIk86aBDBLfX2vhC9DvU5i5k6f
+DbUfSLcshOEdmdpxWJOhClvNi1iD5M0hRj8vePu2jPqwYcY1ubNGnfBiVETP1BC9
+Md3bqH8gVgXITdDSkqfkctg/mwoo0gCvW7J+PWs8Nw5yYZlc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-----
+EOF
+
+ cat << EOF > ~/.ssh/id_rsa.pub
+ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCwmx8/86Vc1yqqplMPkm/w6wB2r5Yl6CjON85Ko5SzPEpnysJwO5ygbMClQTbzCUztIpFeO8D6xdWlhPmhMEJIWtRh+Dx0swB+ByMraGTP92xxKo2ukWzYI6eu25LmJX+a1lmVPmewQq+6dPzIwgCZvwD8UVe5L+d0EP2rb3iniQVoBzksUmhL3N6jp2Lgpscfi1yXFgjFdLpDsCcFcM+Q6wQUC2+qGBYa5RxqercWzISSbvAsYwC7UepmjFpcj3W/WX2QcOCDIlAzeURvC8PbOdzCtgeMhuhH2499BcIUSzPMpjzvpRiHr5SeF/zrPeW+2Ei1MfHi1qrBCxS8JBqt bottlenecks@bottlenecks.opnfv.org
+EOF
+ chmod 600 ~/.ssh/id_rsa
+}
+
+configue_nameserver()
+{
+ echo "Bottlenecks: configue nameserver"
+ sudo rm /etc/resolv.conf
+ sudo echo "nameserver $1" > /etc/resolv.conf
+ sudo echo "nameserver 8.8.8.8" >> /etc/resolv.conf
+ sudo echo "nameserver 8.8.4.4" >> /etc/resolv.conf
+}
+
+install_packages()
+{
+ echo "Bottlenecks: install preinstall packages in VM"
+ sudo apt-get update
+
+ for i in $@; do
+ if ! apt --installed list 2>/dev/null |grep "\<$i\>"
+ then
+ sudo apt-get install -y --force-yes $i
+ fi
+ done
+}
+
diff --git a/utils/infra_setup/vm_dev_setup/package.conf b/utils/infra_setup/vm_dev_setup/package.conf
index 18eb5c56..6af6152b 100644
--- a/utils/infra_setup/vm_dev_setup/package.conf
+++ b/utils/infra_setup/vm_dev_setup/package.conf
@@ -9,3 +9,6 @@ export RUBBOS_RUN_DIR=${RUBBOS_RUN_DIR:-$BOTTLENECKS_REPO_DIR/rubbos/rubbos_scri
export RUBBOS_EXE_DIR=${RUBBOS_EXE_DIR:-$BOTTLENECKS_REPO_DIR/rubbos/rubbos_scripts/1-1-1/scripts}
export RUBBOS_APP_TOOLS_URL=${RUBBOS_APP_TOOLS_URL:-$PACKAGE_URL/rubbos/app_tools.tar.gz}
export RUBBOS_MULINI6_URL=${RUBBOS_MULINI6_URL:-$PACKAGE_URL/rubbos/rubbosMulini6.tar.gz}
+
+export PreInstall_Packages="git gcc gettext g++ libaio1 libaio-dev make"
+
diff --git a/utils/infra_setup/vm_dev_setup/setup_env.sh b/utils/infra_setup/vm_dev_setup/setup_env.sh
index fa59dc47..52579e0d 100755
--- a/utils/infra_setup/vm_dev_setup/setup_env.sh
+++ b/utils/infra_setup/vm_dev_setup/setup_env.sh
@@ -2,17 +2,46 @@
set -ex
+wait_vm_ok() {
+ ip=$1
+
+ retry=0
+ until timeout 1s ssh $ssh_args ec2-user@$ip "exit" >/dev/null 2>&1
+ do
+ echo "retry connect rubbos vm ip $ip $retry"
+ sleep 1
+ let retry+=1
+ if [[ $retry -ge $2 ]];then
+ echo "rubbos control start timeout !!!"
+ exit 1
+ fi
+ done
+}
+
bottlenecks_prepare_env()
{
- echo "Bottlenecks: install preinstall packages in VM"
- sudo apt-get update
+ echo "Bottlenecks prepare env in VMs"
- for i in $PreInstall_Packages; do
- if ! apt --installed list 2>/dev/null |grep "\<$i\>"
- then
- sudo apt-get install -y --force-yes $i
- fi
+ # configue rubbos control ssh key
+ generate_ssh_key
+
+ # wait all other VMs ok
+ for i in $rubbos_benchmark $rubbos_client1 $rubbos_client2 \
+ $rubbos_client3 $rubbos_client4 $rubbos_httpd $rubbos_mysql1 $rubbos_tomcat1
+ do
+ wait_vm_ok $i 120
done
+
+ # asynchronous configue other VMs
+ for i in $rubbos_benchmark $rubbos_client1 $rubbos_client2 \
+ $rubbos_client3 $rubbos_client4 $rubbos_httpd $rubbos_mysql1 $rubbos_tomcat1
+ do
+ scp $ssh_args -r $SCRIPT_DIR ec2-user@$i:$SCRIPT_DIR
+ ssh $ssh_args ec2-user@$i "sudo bash $SCRIPT_DIR/vm_prepare_setup.sh" &
+ done
+
+ # ugly use ssh execute script to fix ec2-user previlege issue
+ ssh $ssh_args ec2-user@$rubbos_control "sudo bash $SCRIPT_DIR/vm_prepare_setup.sh"
}
bottlenecks_download_repo()
@@ -21,11 +50,11 @@ bottlenecks_download_repo()
if [ -d $BOTTELENECKS_REPO_DIR/.git ]; then
cd $BOTTLENECKS_REPO_DIR
- git pull origin master
+ sudo git pull origin master
cd -
else
- rm -rf $BOTTLENECKS_REPO_DIR
- git clone $BOTTLENECKS_REPO $BOTTLENECKS_REPO_DIR
+ sudo rm -rf $BOTTLENECKS_REPO_DIR
+ sudo git clone $BOTTLENECKS_REPO $BOTTLENECKS_REPO_DIR
fi
}
@@ -48,10 +77,10 @@ bottlenecks_download_packages()
echo "Bottlenecks: download rubbos dependent packages from artifacts"
curl --connect-timeout 10 -o /tmp/app_tools.tar.gz $RUBBOS_APP_TOOLS_URL 2>/dev/null
- tar zxvf /tmp/app_tools.tar.gz -C $RUBBOS_DIR
+ sudo tar zxvf /tmp/app_tools.tar.gz -C $RUBBOS_DIR
rm -rf /tmp/app_tools.tar.gz
curl --connect-timeout 10 -o /tmp/rubbosMulini6.tar.gz $RUBBOS_MULINI6_URL 2>/dev/null
- tar zxvf /tmp/rubbosMulini6.tar.gz -C $RUBBOS_MULINI6_DIR
+ sudo tar zxvf /tmp/rubbosMulini6.tar.gz -C $RUBBOS_MULINI6_DIR
rm -rf /tmp/rubbosMulini6.tar.gz
}
@@ -60,18 +89,19 @@ bottlenecks_rubbos_install_exe()
echo "Bottlenecks: install and run rubbos"
cd $RUBBOS_RUN_DIR
- ./run.sh
+ sudo ./run.sh
cd $RUBBOS_EXE_DIR
- ./CONTROL_rubbos_exec.sh
+ sudo ./CONTROL_rubbos_exec.sh
}
main()
{
- PreInstall_Packages="git gcc gettext g++ libaio1 libaio-dev make"
SCRIPT_DIR=`cd ${BASH_SOURCE[0]%/*};pwd`
+ ssh_args="-o StrictHostKeyChecking=no -o BatchMode=yes"
source $SCRIPT_DIR/package.conf
source $SCRIPT_DIR/hosts.conf
+ source $SCRIPT_DIR/common.sh
bottlenecks_prepare_env
bottlenecks_download_repo
diff --git a/utils/infra_setup/vm_dev_setup/vm_prepare_setup.sh b/utils/infra_setup/vm_dev_setup/vm_prepare_setup.sh
new file mode 100644
index 00000000..cb7b6dfd
--- /dev/null
+++ b/utils/infra_setup/vm_dev_setup/vm_prepare_setup.sh
@@ -0,0 +1,18 @@
+#!/bain/bash
+
+main()
+{
+ SCRIPT_DIR=`cd ${BASH_SOURCE[0]%/*};pwd`
+
+ source $SCRIPT_DIR/package.conf
+ source $SCRIPT_DIR/hosts.conf
+ source $SCRIPT_DIR/common.sh
+
+ generate_ssh_key
+ configue_nameserver $nameserver_ip
+ install_packages $PreInstall_Packages
+
+}
+
+main
+