summaryrefslogtreecommitdiffstats
path: root/xci/scripts/vm
diff options
context:
space:
mode:
Diffstat (limited to 'xci/scripts/vm')
-rwxr-xr-xxci/scripts/vm/start-new-vm.sh37
1 files changed, 24 insertions, 13 deletions
diff --git a/xci/scripts/vm/start-new-vm.sh b/xci/scripts/vm/start-new-vm.sh
index 5f7fe590..868de6c3 100755
--- a/xci/scripts/vm/start-new-vm.sh
+++ b/xci/scripts/vm/start-new-vm.sh
@@ -26,13 +26,16 @@ export XCI_BUILD_CLEAN_VM_OS=${XCI_BUILD_CLEAN_VM_OS:-true}
# ones.
export XCI_UPDATE_CLEAN_VM_OS=${XCI_UPDATE_CLEAN_VM_OS:-false}
+# IP of OPNFV VM so we remove it from known_hosts
+OPNFV_VM_IP=192.168.122.2
+
grep -q -i ^Y$ /sys/module/kvm_intel/parameters/nested || { echo "Nested virtualization is not enabled but it's needed for XCI to work"; exit 1; }
destroy_vm_on_failures() {
local exit_err=${xci_error:-130}
if ! ${XCI_KEEP_CLEAN_VM_ON_FAILURES}; then
- sudo virsh destroy ${VM_NAME}_xci_vm
- sudo virsh undefine ${VM_NAME}_xci_vm
+ sudo virsh destroy ${VM_NAME}_xci_vm || true
+ sudo virsh undefine ${VM_NAME}_xci_vm || true
fi
exit $exit_err
}
@@ -53,9 +56,10 @@ update_clean_vm_files() {
local image_remote="${opnfv_url}/${OS}.qcow2"
get_new_vm_files() {
+ echo "Downloading new ${OS} images from ${opnfv_url}"
rm -rf ${vm_cache}/${OS}*
- wget --quiet ${image_remote}
- wget --quiet ${sha_remote}
+ curl -O -s --retry 10 ${image_remote}
+ curl -O -s --retry 10 ${sha_remote}
}
# There are 3 reasons why we want to fetch files from the GS storage
@@ -68,7 +72,7 @@ update_clean_vm_files() {
sha_local=$(awk '{print $1}' $shafile)
if $XCI_UPDATE_CLEAN_VM_OS; then
echo "Updating local copies of ${OS}..."
- ! curl -s ${sha_remote} | grep -q ${sha_local} && \
+ ! curl --retry 10 -s ${sha_remote} | grep -q ${sha_local} && \
get_new_vm_files
fi
echo "Verifying integrity of ${OS} files..."
@@ -127,7 +131,7 @@ esac
echo "Checking for running package manager instance..."
while true; do
- _pkg_mgr_proc=$(pgrep -f "${pkg_mgr_cmd%*install*}")
+ _pkg_mgr_proc=$(pgrep -f "${pkg_mgr_cmd%*install*}" | cat)
if [[ -n ${_pkg_mgr_proc} ]]; then
echo "Wainting for process ${_pkg_mgr_proc} to finish..."
sleep 60
@@ -175,7 +179,9 @@ sudo rm -f ${BASE_PATH}/${OS}.qcow2
# Fix perms again...
sudo chmod 777 -R $XCI_CACHE_DIR/clean_vm/images/
sudo chown $uid:$gid -R $XCI_CACHE_DIR/clean_vm/images/
-cp ${XCI_CACHE_DIR}/clean_vm/images/${OS}.qcow2 ${BASE_PATH}/
+cp ${XCI_CACHE_DIR}/clean_vm/images/${OS}.qcow2* ${BASE_PATH}/
+cp ${XCI_CACHE_DIR}/clean_vm/images/${OS}.qcow2.sha256.txt ${BASE_PATH}/deployment_image.qcow2.sha256.txt
+cp ${XCI_CACHE_DIR}/clean_vm/images/${OS}.qcow2 ${BASE_PATH}/deployment_image.qcow2
declare -r OS_IMAGE_FILE=${OS}.qcow2
[[ ! -e ${OS_IMAGE_FILE} ]] && echo "${OS_IMAGE_FILE} not found! This should never happen!" && exit 1
@@ -249,6 +255,7 @@ chmod 600 ${BASE_PATH}/xci/scripts/vm/id_rsa_for_dib*
# Remove it from known_hosts
ssh-keygen -R $_ip || true
ssh-keygen -R ${VM_NAME} || true
+ssh-keygen -R ${OPNFV_VM_IP} || true
# Initial ssh command until we setup everything
vm_ssh="ssh -o StrictHostKeyChecking=no -i ${BASE_PATH}/xci/scripts/vm/id_rsa_for_dib -l devuser"
@@ -275,26 +282,30 @@ echo "Adding ${VM_NAME} entry to /etc/hosts"
sudo sed -i "/.*${VM_NAME}.*/d" /etc/hosts
sudo bash -c "echo '${_ip} ${VM_NAME}' >> /etc/hosts"
+# remove ssh xci-vm-config that uses none-distro specific filename
+/bin/rm -f $HOME/.ssh/xci-vm-config
+
echo "Dropping a minimal .ssh/config file"
-cat > $HOME/.ssh/xci-vm-config<<EOF
+cat > $HOME/.ssh/${OS}-xci-vm-config<<EOF
Host *
StrictHostKeyChecking no
ServerAliveInterval 60
ServerAliveCountMax 5
IdentityFile ${BASE_PATH}/xci/scripts/vm/id_rsa_for_dib
-Host *_xci_vm
+Host ${OS}_xci_vm
User devuser
-Host *_xci_vm_opnfv
+Host ${OS}_xci_vm_opnfv
+Hostname 192.168.122.2
User root
TCPKeepAlive yes
StrictHostKeyChecking no
-ProxyCommand ssh -l devuser \$(echo %h | sed 's/_opnfv//') 'nc 192.168.122.2 %p'
+ProxyCommand ssh -l devuser -i ${BASE_PATH}/xci/scripts/vm/id_rsa_for_dib ${OS}_xci_vm -W %h:%p
EOF
# Final ssh command which will also test the configuration file
-declare -r vm_ssh="ssh -F $HOME/.ssh/xci-vm-config"
+declare -r vm_ssh="ssh -F $HOME/.ssh/${OS}-xci-vm-config"
echo "Preparing test environment..."
# *_xci_vm hostname is invalid. Letst just use distro name
@@ -317,7 +328,6 @@ do_copy() {
--exclude "${VM_NAME}*" \
--exclude "${OS}*" \
--exclude "build.log" \
- --exclude "*.qcow2*" \
-e "$vm_ssh" ${BASE_PATH}/ ${VM_NAME}:~/releng-xci/
}
@@ -345,6 +355,7 @@ if [[ $? != 0 ]]; then
#!/bin/bash
set -o pipefail
export XCI_FLAVOR=mini
+export BIFROST_USE_PREBUILT_IMAGES=true
cd ~/releng-xci/xci
./xci-deploy.sh | ts
EOF