From e66847184999a84c472648e78d71e12b7c5b23d2 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Wed, 7 Mar 2018 16:36:03 +0000 Subject: bifrost: Use the pre-built XCI OS images instead of dib We already have images for all 3 distros which we could simply re-use for all the XCI VM deployments instead of building new ones everytime with DIB. The images will be copied to the new VM from the cache directory if they are available otherwise we will simply download them during the XCI execution phase. Change-Id: I2a8391650558511668654c6b54a10db316f867a2 Signed-off-by: Markos Chandras --- bifrost/playbooks/opnfv-virtual.yaml | 48 ++++++++++++++++++++++++++++++++++-- bifrost/scripts/bifrost-provision.sh | 4 ++- xci/config/user-vars | 1 + xci/scripts/vm/start-new-vm.sh | 9 ++++--- 4 files changed, 56 insertions(+), 6 deletions(-) diff --git a/bifrost/playbooks/opnfv-virtual.yaml b/bifrost/playbooks/opnfv-virtual.yaml index 4e985db8..cfcb71a1 100644 --- a/bifrost/playbooks/opnfv-virtual.yaml +++ b/bifrost/playbooks/opnfv-virtual.yaml @@ -24,6 +24,45 @@ - name: "Override the ipv4_gateway setting" set_fact: ipv4_gateway: "192.168.122.1" + - name: Prepare the XCI pre-built images + block: + - name: Create the PXE directory + file: + path: /httpboot + state: directory + become: yes + - name: Download the {{ xci_distro }} image checksum file + get_url: + dest: /httpboot/{{ xci_distro }}.qcow2.sha256.txt + force: no + url: http://artifacts.opnfv.org/releng/xci/images/{{ xci_distro }}.qcow2.sha256.txt + timeout: 3000 + become: yes + - name: Extract checksum + shell: awk '{print $1}' /httpboot/{{ xci_distro }}.qcow2.sha256.txt + register: _image_checksum + - fail: + msg: "Failed to get image checksum" + when: _image_checksum == '' + - set_fact: + image_checksum: "{{ _image_checksum.stdout }}" + - name: Download the {{ xci_distro }} image file + get_url: + url: http://artifacts.opnfv.org/releng/xci/images/{{ xci_distro }}.qcow2 + checksum: "sha256:{{ image_checksum }}" + timeout: 3000 + dest: /httpboot/deployment_image.qcow2 + force: no + become: yes + - name: Set correct mode for {{ xci_distro }}.qcow2 file + file: + path: /httpboot/deployment_image.qcow2 + mode: '0755' + owner: 'root' + group: 'root' + become: yes + when: use_prebuilt_images | bool == true + roles: - { role: bifrost-prep-for-install, when: skip_install is not defined } environment: @@ -49,7 +88,9 @@ dib_os_release: "jessie" dib_elements: "ironic-agent {{ ipa_extra_dib_elements | default('') }}" dib_notmpfs: true - when: create_ipa_image | bool == true + when: + - create_ipa_image | bool == true + - not use_prebuilt_images | bool == false - role: bifrost-create-dib-image dib_imagetype: "qcow2" dib_imagename: "{{deploy_image}}" @@ -61,7 +102,10 @@ dib_elements: "vm enable-serial-console simple-init devuser openssh-server growroot pip-and-virtualenv {{ extra_dib_elements }}" dib_packages: "{{ lookup('env', 'DIB_OS_PACKAGES') }}" dib_notmpfs: true - when: create_image_via_dib | bool == true and transform_boot_image | bool == false + when: + - create_image_via_dib | bool == true + - transform_boot_image | bool == false + - use_prebuilt_images | bool == false - role: bifrost-keystone-client-config user: "{{ ansible_env.SUDO_USER }}" clouds: diff --git a/bifrost/scripts/bifrost-provision.sh b/bifrost/scripts/bifrost-provision.sh index e64277d6..5ebe2031 100755 --- a/bifrost/scripts/bifrost-provision.sh +++ b/bifrost/scripts/bifrost-provision.sh @@ -141,7 +141,9 @@ ${ANSIBLE} ${XCI_ANSIBLE_VERBOSITY} \ -e ironicinspectorclient_git_branch=${BIFROST_IRONIC_INSPECTOR_CLIENT_VERSION} \ -e ironicclient_source_install=true \ -e ironicclient_git_branch=${BIFROST_IRONIC_CLIENT_VERSION} \ - -e ironic_git_branch=${BIFROST_IRONIC_VERSION} + -e ironic_git_branch=${BIFROST_IRONIC_VERSION} \ + -e use_prebuilt_images=${BIFROST_USE_PREBUILT_IMAGES} \ + -e xci_distro=${XCI_DISTRO} EXITCODE=$? if [ $EXITCODE != 0 ]; then diff --git a/xci/config/user-vars b/xci/config/user-vars index 06e91cf0..451b6b85 100755 --- a/xci/config/user-vars +++ b/xci/config/user-vars @@ -46,5 +46,6 @@ export XCI_INSTALLER=${XCI_INSTALLER:-osa} export XCI_ANSIBLE_VERBOSITY=${XCI_ANSIBLE_VERBOSITY:-""} export RUN_TEMPEST=${RUN_TEMPEST:-false} export CORE_OPENSTACK_INSTALL=${CORE_OPENSTACK_INSTALL:-false} +export BIFROST_USE_PREBUILT_IMAGES=${BIFROST_USE_PREBUILT_IMAGES:-false} # Set this to to true to force XCI to re-create the target OS images export CLEAN_DIB_IMAGES=${CLEAN_DIB_IMAGES:-false} diff --git a/xci/scripts/vm/start-new-vm.sh b/xci/scripts/vm/start-new-vm.sh index 59d1ee2e..e2a918b3 100755 --- a/xci/scripts/vm/start-new-vm.sh +++ b/xci/scripts/vm/start-new-vm.sh @@ -179,7 +179,7 @@ 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}/ declare -r OS_IMAGE_FILE=${OS}.qcow2 [[ ! -e ${OS_IMAGE_FILE} ]] && echo "${OS_IMAGE_FILE} not found! This should never happen!" && exit 1 @@ -324,9 +324,7 @@ EOF do_copy() { rsync -a \ --exclude "${VM_NAME}*" \ - --exclude "${OS}*" \ --exclude "build.log" \ - --exclude "*.qcow2*" \ -e "$vm_ssh" ${BASE_PATH}/ ${VM_NAME}:~/releng-xci/ } @@ -340,6 +338,10 @@ $vm_ssh ${VM_NAME} "sudo mv /home/devuser/releng-xci/vm_hosts.txt /etc/hosts" # Disable 3-level nested virtualization since it makes things terribly slow $vm_ssh ${VM_NAME} "sudo bash -c 'echo \"options kvm_intel nested=0\" > /etc/modprobe.d/qemu-system-x86.conf'" $vm_ssh ${VM_NAME} "sudo modprobe -r kvm_intel && sudo modprobe -a kvm_intel" +# Copy image files over +$vm_ssh ${VM_NAME} "sudo mkdir /httpboot" +$vm_ssh ${VM_NAME} "sudo mv /home/devuser/releng-xci/${OS}.qcow2.sha256.txt /httpboot" +$vm_ssh ${VM_NAME} "sudo mv /home/devuser/releng-xci/${OS}.qcow2 /httpboot/deployment_image.qcow2" set +e @@ -354,6 +356,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 -- cgit 1.2.3-korg