1 From: Stanislaw Kardach <stanislaw.kardach@caviumnetworks.com>
2 Date: Tue, 15 Mar 2016 15:01:34 +0100
3 Subject: [PATCH] direct kernel boot for cirros
6 .../osnailyfacter/modular/astute/upload_cirros.rb | 58 +++++++++++++++++++++-
7 .../puppet/osnailyfacter/templates/vm_libvirt.erb | 8 ++-
8 2 files changed, 63 insertions(+), 3 deletions(-)
10 diff --git a/deployment/puppet/osnailyfacter/modular/astute/upload_cirros.rb b/deployment/puppet/osnailyfacter/modular/astute/upload_cirros.rb
11 index 04d597c..c342830 100755
12 --- a/deployment/puppet/osnailyfacter/modular/astute/upload_cirros.rb
13 +++ b/deployment/puppet/osnailyfacter/modular/astute/upload_cirros.rb
21 hiera = Hiera.new(:config => '/etc/hiera.yaml')
22 @@ -56,11 +57,17 @@ def image_list
23 fields = line.split('|').map { |f| f.chomp.strip }
24 next if fields[1] == 'ID'
27 + images << [fields[1], fields[2]]
29 {:images => images, :exit_code => return_code}
34 + images[:images].map! { |i| i[1] }
38 # TODO degorenko: remove --os-image-api-version after liberty (fuel-8.0) release
39 def image_create(image_hash)
41 @@ -79,6 +86,15 @@ EOF
42 [ stdout, return_code ]
45 +# Calls glance update-image with a given property and value
46 +def update_image(image_id, property, value)
47 + command = "/usr/bin/glance image-update --#{property} #{value} #{image_id}"
49 + stdout = `#{command}`
50 + return_code = $?.exitstatus
51 + [ stdout, return_code ]
54 # check if Glance is online
55 # waited until the glance is started because when vCenter used as a glance
56 # backend launch may takes up to 1 minute.
57 @@ -93,7 +109,7 @@ end
58 # upload image to Glance
59 # if it have not been already uploaded
60 def upload_image(image)
61 - list_of_images = image_list
62 + list_of_images = image_name_list
63 if list_of_images[:images].include?(image['img_name']) && list_of_images[:exit_code] == 0
64 puts "Image '#{image['img_name']}' is already present!"
66 @@ -109,6 +125,43 @@ def upload_image(image)
70 +# For each disk image try to find a kernel and initramfs images and
71 +# attach then to it via kernel_id and ramdisk_id glance properties.
72 +def connect_dependant_images(images)
74 + # get image id from glance
75 + img_list = image_list
76 + return_code = img_list[:exit_code]
78 + images.each do |image|
79 + img_list[:images].each do |il|
80 + if il[1] == image['img_name']
85 + # for each image that is not in [aki, ari]
86 + images.each do |image|
87 + next if ['aki', 'ari'].include?(image['disk_format'])
89 + # find aki/ari image whose name starts with this image's name
90 + if i['img_name'].start_with?(image['img_name'])
92 + if i['disk_format'] == 'aki'
93 + _, ret = update_image(image['id'], 'property',
94 + "kernel_id=#{i['id']}")
95 + elsif i['disk_format'] == 'ari'
96 + _, ret = update_image(image['id'], 'property',
97 + "ramdisk_id=#{i['id']}")
107 ########################
110 @@ -117,6 +170,7 @@ errors = 0
111 test_vm_images.each do |image|
112 errors += upload_image(image)
114 +errors = connect_dependant_images(test_vm_images) unless errors != 0
116 exit 1 unless errors == 0
118 diff --git a/deployment/puppet/osnailyfacter/templates/vm_libvirt.erb b/deployment/puppet/osnailyfacter/templates/vm_libvirt.erb
119 index 2d030d9..b33fb25 100644
120 --- a/deployment/puppet/osnailyfacter/templates/vm_libvirt.erb
121 +++ b/deployment/puppet/osnailyfacter/templates/vm_libvirt.erb
123 <memory unit='GiB'><%= @details['mem'] %></memory>
124 <vcpu placement='static'><%= @details['cpu'] %></vcpu>
126 - <type arch='<%= @machine_arch %>' machine='<%= @machine_type %>'>hvm</type>
127 + <type arch='<%= @machine_arch %>' machine='<%= @machine_type %>'>hvm</type>
128 + <% if $machine_arch == 'aarch64' %>
129 + <kernel>/var/lib/nova/<%= @details['id'] %>_vm.kernel</kernel>
130 + <initrd>/var/lib/nova/<%= @details['id'] %>_vm.initramfs</initrd>
131 + <cmdline>root=/dev/vda1 rw rootwait console=tty0 console=ttyS0 console=ttyAMA0</cmdline>
133 <boot dev='network'/>