summaryrefslogtreecommitdiff
path: root/playbooks/nova-emulation/pre.yaml
blob: f763f82458b690c5d3d30974238162b3351d062e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
- hosts: controller
  tasks:
    - name: create local.sh
      become: yes
      blockinfile:
        path: /opt/stack/devstack/local.sh
        create: True
        mode: 0777
        block: |
          #!/bin/bash
          sudo apt update
          sudo apt install -yy qemu-system qemu-efi-aarch64 qemu-efi-arm
          # This changes the default image metadata to enable emulation
          source /opt/stack/devstack/openrc admin

          image_id=$(openstack image list -f value -c ID | awk 'NR==1{print $1}')

          echo "Setting required image metadata properties"
          openstack image set --property hw_emulation_architecture=aarch64 ${image_id}
          openstack image set --property hw_firmware_type=uefi ${image_id}
          openstack image set --property hw_machine_type=virt ${image_id}

          meta_props=$(openstack image show ${image_id} | grep properties | sed 's/,\||/\n/g' | grep hw_)

          for prop in ${meta_props};
          do
              if [ -z "${prop}" ]
              then
                  echo "Image Properties not set"
                  exit 5
              else
                  echo ${prop}
              fi
          done