summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Morales <v.morales@samsung.com>2020-07-31 13:34:33 -0400
committerVictor Morales <v.morales@samsung.com>2020-07-31 15:35:19 -0400
commit038ca1a88c07bb3f91a676ee5a022aaf0ca899dc (patch)
tree089474896a5d1bf01f0a4e65e8c84d5696370b3f
parent3ee3953f99d7c10d328eaffd3fb8c66c5f2bb558 (diff)
Drop VM_IP environment variable
It's not necessary to declare this variable because the IP address of the jumpbox can retrieved calling the get_vm_ip function. Signed-off-by: Victor Morales <v.morales@samsung.com> Change-Id: I92f29a70ea1924eb105d66781d9d313427e2d1f0
-rwxr-xr-xdeploy.sh3
-rwxr-xr-xfunctions.sh15
2 files changed, 6 insertions, 12 deletions
diff --git a/deploy.sh b/deploy.sh
index 4ecd6c6..631f580 100755
--- a/deploy.sh
+++ b/deploy.sh
@@ -33,9 +33,6 @@ clean_up
create_jump
setup_PXE_network
-# Get IP of the jumphost VM
-get_vm_ip
-
# Copy files needed by Infra engine & BMRA in the jumphost VM
copy_files_jump
diff --git a/functions.sh b/functions.sh
index edfbb46..32f3c9a 100755
--- a/functions.sh
+++ b/functions.sh
@@ -31,16 +31,13 @@ create_jump() {
# Get jumphost VM IP
get_vm_ip() {
- export VM_IP=$(sudo virsh domifaddr ${VM_NAME} | \
- sed 3q | sed '$!d' |awk '{print $4}' | cut -d/ -f1)
- echo "VM IP is ${VM_IP}"
+ sudo virsh domifaddr ${VM_NAME} | awk 'FNR == 3 {gsub(/\/.*/, ""); print $4}'
}
# Setup PXE network
setup_PXE_network() {
- get_vm_ip
- ssh -o StrictHostKeyChecking=no -tT $USERNAME@$VM_IP << EOF
+ ssh -o StrictHostKeyChecking=no -tT $USERNAME@$(get_vm_ip) << EOF
sudo ifconfig $PXE_IF up
sudo ifconfig $PXE_IF $PXE_IF_IP netmask $NETMASK
sudo ifconfig $PXE_IF hw ether $PXE_IF_MAC
@@ -51,14 +48,14 @@ EOF
copy_files_jump() {
scp -r -o StrictHostKeyChecking=no $CURRENTPATH/{hw_config/$VENDOR/,sw_config/$INSTALLER/} \
- $USERNAME@$VM_IP:$PROJECT_ROOT
+ $USERNAME@$(get_vm_ip):$PROJECT_ROOT
}
# Host Provisioning
provision_hosts() {
# SSH to jumphost
- ssh -tT $USERNAME@$VM_IP << EOF
+ ssh -tT $USERNAME@$(get_vm_ip) << EOF
# Install and run cloud-infra
if [ ! -d "${PROJECT_ROOT}/engine" ]; then
ssh-keygen -t rsa -N "" -f ${PROJECT_ROOT}/.ssh/id_rsa
@@ -75,7 +72,7 @@ EOF
setup_network() {
# SSH to jumphost
- ssh -tT $USERNAME@$VM_IP << EOF
+ ssh -tT $USERNAME@$(get_vm_ip) << EOF
ssh -o StrictHostKeyChecking=no root@$MASTER_IP 'bash -s' < ${PROJECT_ROOT}/${VENDOR}/setup_network.sh
ssh -o StrictHostKeyChecking=no root@$WORKER_IP 'bash -s' < ${PROJECT_ROOT}/${VENDOR}/setup_network.sh
EOF
@@ -85,7 +82,7 @@ EOF
provision_k8s() {
# SSH to jumphost
- ssh -tT $USERNAME@$VM_IP << EOF
+ ssh -tT $USERNAME@$(get_vm_ip) << EOF
# Install BMRA
if [ ! -d "${PROJECT_ROOT}/container-experience-kits" ]; then
curl -fsSL https://get.docker.com/ | sh