1 From ec3299c72eae195106092a646409564b5b3eb560 Mon Sep 17 00:00:00 2001
2 From: Stanislaw Kardach <stanislaw.kardach@caviumnetworks.com>
3 Date: Wed, 24 Feb 2016 20:08:24 +0100
4 Subject: [PATCH 10/20] Make TestVM creation architecture aware
6 This depends on cirros-testvm package to contain both amd64 and arm64
9 deployment/puppet/openstack/manifests/img/cirros.pp | 8 ++++++--
10 .../osnailyfacter/manifests/generate_vms/vm_config.pp | 11 +++++++++++
11 deployment/puppet/osnailyfacter/templates/vm_libvirt.erb | 15 ++++++++++++++-
12 files/fuel-migrate/fuel-migrate | 5 ++++-
13 4 files changed, 35 insertions(+), 4 deletions(-)
15 diff --git a/deployment/puppet/openstack/manifests/img/cirros.pp b/deployment/puppet/openstack/manifests/img/cirros.pp
16 index 84e202e..cff06e0 100644
17 --- a/deployment/puppet/openstack/manifests/img/cirros.pp
18 +++ b/deployment/puppet/openstack/manifests/img/cirros.pp
19 @@ -9,6 +9,10 @@ class openstack::img::cirros (
23 + $arch = $::architecture ? {
24 + /(arm64|aarch64)/ => 'aarch64',
25 + default => 'x86_64',
28 package { 'cirros-testvm':
30 @@ -17,14 +21,14 @@ class openstack::img::cirros (
34 - command => "/usr/bin/glance -N ${os_auth_url} -T ${os_tenant_name} -I ${os_username} -K ${os_password} add name=${img_name} is_public=${public} container_format=${container_format} disk_format=${disk_format} distro=${os_name} < /opt/vm/cirros-x86_64-disk.img",
35 + command => "/usr/bin/glance -N ${os_auth_url} -T ${os_tenant_name} -I ${os_username} -K ${os_password} add name=${img_name} is_public=${public} container_format=${container_format} disk_format=${disk_format} distro=${os_name} < /opt/vm/cirros-${arch}-disk.img",
36 unless => "/usr/bin/glance -N ${os_auth_url} -T ${os_tenant_name} -I ${os_username} -K ${os_password} index && (/usr/bin/glance -N ${os_auth_url} -T ${os_tenant_name} -I ${os_username} -K ${os_password} index | grep ${img_name})",
42 - command => "/usr/bin/glance -N ${os_auth_url} -T ${os_tenant_name} -I ${os_username} -K ${os_password} add name=${img_name} is_public=${public} container_format=${container_format} disk_format=${disk_format} distro=${os_name} < /usr/share/cirros-testvm/cirros-x86_64-disk.img",
43 + command => "/usr/bin/glance -N ${os_auth_url} -T ${os_tenant_name} -I ${os_username} -K ${os_password} add name=${img_name} is_public=${public} container_format=${container_format} disk_format=${disk_format} distro=${os_name} < /usr/share/cirros-testvm/cirros-${arch}-disk.img",
44 unless => "/usr/bin/glance -N ${os_auth_url} -T ${os_tenant_name} -I ${os_username} -K ${os_password} index && (/usr/bin/glance -N ${os_auth_url} -T ${os_tenant_name} -I ${os_username} -K ${os_password} index | grep ${img_name})",
47 diff --git a/deployment/puppet/osnailyfacter/manifests/generate_vms/vm_config.pp b/deployment/puppet/osnailyfacter/manifests/generate_vms/vm_config.pp
48 index 70fef32..dfefcbe 100644
49 --- a/deployment/puppet/osnailyfacter/manifests/generate_vms/vm_config.pp
50 +++ b/deployment/puppet/osnailyfacter/manifests/generate_vms/vm_config.pp
51 @@ -4,6 +4,17 @@ define osnailyfacter::generate_vms::vm_config(
55 + case $::architecture {
56 + 'arm64', 'aarch64': {
57 + $machine_arch = 'aarch64'
58 + $machine_type = 'virt'
61 + $machine_arch = 'x86_64'
62 + $machine_type = 'pc-i440fx-trusty'
66 file { "${template_dir}/template_${id}_vm.xml":
69 diff --git a/deployment/puppet/osnailyfacter/templates/vm_libvirt.erb b/deployment/puppet/osnailyfacter/templates/vm_libvirt.erb
70 index ae2ba5b..64e716d 100644
71 --- a/deployment/puppet/osnailyfacter/templates/vm_libvirt.erb
72 +++ b/deployment/puppet/osnailyfacter/templates/vm_libvirt.erb
74 <memory unit='GiB'><%= @details['mem'] %></memory>
75 <vcpu placement='static'><%= @details['cpu'] %></vcpu>
77 - <type arch='x86_64' machine='pc-i440fx-trusty'>hvm</type>
78 + <type arch='<%= @machine_arch %>' machine='<%= @machine_type %>'>hvm</type>
79 + <% if == 'aarch64' %>
80 + <kernel>/var/lib/nova/<%= @details['id'] %>_vm.kernel</kernel>
81 + <initrd>/var/lib/nova/<%= @details['id'] %>_vm.initramfs</initrd>
82 + <cmdline>root=/dev/vda1 rw rootwait console=tty0 console=ttyS0 console=ttyAMA0</cmdline>
92 + <% if $machine_arch == 'aarch64' %>
93 + <gic version='host' />
97 <on_poweroff>destroy</on_poweroff>
99 <input type='keyboard' bus='ps2'/>
100 <graphics type='vnc' port='-1' autoport='yes'/>
102 +<% if $machine_arch == 'aarch64' %>
103 + <model type='vga' vram='9216' heads='1'/>
105 <model type='cirrus' vram='9216' heads='1'/>
108 <memballoon model='virtio'>
110 diff --git a/files/fuel-migrate/fuel-migrate b/files/fuel-migrate/fuel-migrate
111 index a215e0a..7d5b6cd 100755
112 --- a/files/fuel-migrate/fuel-migrate
113 +++ b/files/fuel-migrate/fuel-migrate
114 @@ -176,6 +176,8 @@ create_vm(){
118 + # figure out atchitecture of the destination
119 + arch="$(virsh -c "${dkvm_uri}" nodeinfo | awk '/CPU model:/ { print $3}')"
121 ssh "${dkvm_ip}" qemu-img create -f raw "${dkvm_folder}/${fvm_name}.img" "${fvm_disk_size}"
122 # make template for virsh
123 @@ -185,13 +187,14 @@ create_vm(){
124 <memory unit='MiB'>${fvm_ram}</memory>
125 <vcpu >${fvm_cpu}</vcpu>
127 - <type arch='x86_64' >hvm</type>
128 + <type arch='${arch}' >hvm</type>
130 <boot dev='network'/>
135 + ${arch/aarch64/<gic version='3'\/>}
137 <clock offset='utc'/>
138 <on_poweroff>destroy</on_poweroff>