diff options
author | Alexandru Avadanii <Alexandru.Avadanii@enea.com> | 2016-06-19 17:42:00 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@172.30.200.206> | 2016-06-19 17:42:01 +0000 |
commit | 345ff10d7d737df206d4f00dcdca70b0b20d2525 (patch) | |
tree | eed4b75f7e0c8e95d6dd38d8505213df5fb6506f /patches | |
parent | e6366325517c4d6e3f026aec54cec1203e2ec965 (diff) | |
parent | 03a762e034a57698a1033cb67976f3bd0333dcad (diff) |
Merge "Fix: upload_cirros hash mixup."
Diffstat (limited to 'patches')
-rw-r--r-- | patches/fuel-library/0006-upload_cirros-Add-direct-kernel-boot-support.patch | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/patches/fuel-library/0006-upload_cirros-Add-direct-kernel-boot-support.patch b/patches/fuel-library/0006-upload_cirros-Add-direct-kernel-boot-support.patch index a928761c..ab4100c6 100644 --- a/patches/fuel-library/0006-upload_cirros-Add-direct-kernel-boot-support.patch +++ b/patches/fuel-library/0006-upload_cirros-Add-direct-kernel-boot-support.patch @@ -15,22 +15,28 @@ diff --git a/deployment/puppet/osnailyfacter/modular/astute/upload_cirros.rb b/d index f0441b0..a619f3f 100755 --- a/deployment/puppet/osnailyfacter/modular/astute/upload_cirros.rb +++ b/deployment/puppet/osnailyfacter/modular/astute/upload_cirros.rb -@@ -56,7 +56,7 @@ def image_list +@@ -52,11 +52,11 @@ def image_list + stdout = `glance --verbose image-list` + return_code = $?.exitstatus +- images = [] ++ images = Hash[] + stdout.split("\n").each do |line| fields = line.split('|').map { |f| f.chomp.strip } next if fields[1] == 'ID' next unless fields[2] - images << {fields[2] => fields[6]} -+ images << {fields[2] => { :id => fields[1], :status => fields[6]}} ++ images[fields[2]] = { :id => fields[1], :status => fields[6] } end {:images => images, :exit_code => return_code} end -@@ -78,6 +78,15 @@ EOF +@@ -78,6 +78,16 @@ EOF [ stdout, return_code ] end +# Calls glance update-image with a given property and value ++# Supported properties: 'kernel-id', 'ramdisk-id' +def update_image(image_id, property, value) -+ command = "/usr/bin/openstack image set --property #{property}=#{value} #{image_id}" ++ command = "/usr/bin/openstack image set --#{property}=#{value} #{image_id}" + puts command + stdout = `#{command}` + return_code = $?.exitstatus @@ -45,11 +51,20 @@ index f0441b0..a619f3f 100755 def check_image(image) list_of_images = image_list - if list_of_images[:exit_code] == 0 && list_of_images[:images].include?(image['img_name'] => "active") -+ if list_of_images[:exit_code] == 0 && list_of_images[:images].select { |k,v| k == image['img_name'] and v[:status] == "active" } ++ if list_of_images[:exit_code] == 0 && list_of_images[:images].select { |k,v| k == image['img_name'] and v[:status] == "active" }.count > 0 return true end return false -@@ -157,6 +166,43 @@ def delete_image(image_name) +@@ -142,7 +151,7 @@ end + # the first one + def cleanup_image(image) + list_of_images = image_list +- unless list_of_images[:images].select { |img_hash| img_hash.key?(image['img_name']) }.empty? ++ unless list_of_images[:images].select { |img_hash, v| img_hash == image['img_name'] }.count == 0 + delete_image(image['img_name']) + end + end +@@ -157,6 +166,41 @@ def delete_image(image_name) [ stdout, return_code ] end @@ -76,11 +91,9 @@ index f0441b0..a619f3f 100755 + if i['img_name'].start_with?(image['img_name']) + ret = 0 + if i['disk_format'] == 'aki' -+ _, ret = update_image(image['id'], 'property', -+ "kernel_id=#{i['id']}") ++ _, ret = update_image(image['id'], 'kernel-id', i['id']) + elsif i['disk_format'] == 'ari' -+ _, ret = update_image(image['id'], 'property', -+ "ramdisk_id=#{i['id']}") ++ _, ret = update_image(image['id'], 'ramdisk-id', i['id']) + end + return_code += ret + end |