mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
B #3060: Fix update procedure for linuxcontainers appliances
Co-authored-by: Daniel Clavijo Coca <dclavijo@opennebula.systems>
This commit is contained in:
parent
ea86bd2039
commit
672f9f8134
@ -22,6 +22,7 @@ require 'json'
|
||||
require 'base64'
|
||||
require 'rexml/document'
|
||||
require 'time'
|
||||
require 'digest/md5'
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
@ -52,7 +53,7 @@ CONTEXT = [
|
||||
NETWORK =\"YES\",
|
||||
SSH_PUBLIC_KEY =\"$USER[SSH_PUBLIC_KEY]\",
|
||||
SET_HOSTNAME =\"$NAME\"
|
||||
]"
|
||||
]"
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration varibales
|
||||
@ -153,28 +154,35 @@ CONTEXT = [
|
||||
#-----------------------------------------------------------------------
|
||||
tree.each do |distro, value|
|
||||
value.each do |version, path|
|
||||
source = app_url(path)
|
||||
description = 'Downloaded from https://images.linuxcontainers.org'
|
||||
name = "#{distro[0...-1]}_#{version[0...-1]} - LXD"
|
||||
description = "Downloaded from #{@options[:url]}"
|
||||
regtime = app_time(path).to_s
|
||||
|
||||
data = {
|
||||
'NAME' => name, 'SOURCE' => source.to_s, 'FORMAT' => 'raw',
|
||||
'IMPORT_ID' => '-1', 'ORIGIN_ID' => '-1', 'TYPE' => 'IMAGE',
|
||||
'PUBLISHER' => 'linuxcontainers.org', 'VERSION' => '1.0',
|
||||
'DESCRIPTION' => description, 'REGTIME' => app_time(path),
|
||||
'TAGS' => '', 'SIZE' => @options[:sizemb]
|
||||
'NAME' => "#{distro[0...-1]}_#{version[0...-1]} - LXD",
|
||||
'SIZE' => @options[:sizemb],
|
||||
'PUBLISHER' => @options[:url],
|
||||
'FORMAT' => @options[:format],
|
||||
'REGTIME' => regtime,
|
||||
'SOURCE' => app_url(path).to_s,
|
||||
'MD5' => md5(regtime),
|
||||
'IMPORT_ID' => '-1',
|
||||
'ORIGIN_ID' => '-1',
|
||||
'VERSION' => '1.0',
|
||||
'TYPE' => 'IMAGE',
|
||||
'DESCRIPTION' => description,
|
||||
'TAGS' => ''
|
||||
}
|
||||
|
||||
tmpl = ''
|
||||
|
||||
data.each {|key, val| print_var(tmpl, key, val) }
|
||||
|
||||
tmpl64 = ''
|
||||
print_var(tmpl64, 'DRIVER', 'raw')
|
||||
print_var(tmpl, 'APPTEMPLATE64',
|
||||
Base64.strict_encode64(tmpl64))
|
||||
print_var(tmpl, 'VMTEMPLATE64',
|
||||
Base64.strict_encode64(TEMPLATE))
|
||||
|
||||
data = { 'APPTEMPLATE64' => tmpl64, 'VMTEMPLATE64' => TEMPLATE }
|
||||
data.each do |key, val|
|
||||
print_var(tmpl, key, Base64.strict_encode64(val))
|
||||
end
|
||||
|
||||
appstr << "APP=\"#{Base64.strict_encode64(tmpl)}\"\n"
|
||||
end
|
||||
@ -215,13 +223,18 @@ CONTEXT = [
|
||||
str << "#{name}=\"#{val}\"\n"
|
||||
end
|
||||
|
||||
# Returns an md5 from a combination of the @option hash and an input string
|
||||
def md5(string)
|
||||
Digest::MD5.hexdigest("#{@options} #{string}")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
################################################################################
|
||||
# Main Program. Outpust the list of marketplace appliances
|
||||
################################################################################
|
||||
def set_option(option, doc, name, path)
|
||||
option[name] = ddoc.elements[path].text if doc.elements[path]
|
||||
option[name] = doc.elements[path].text if doc.elements[path]
|
||||
end
|
||||
|
||||
begin
|
||||
|
Loading…
x
Reference in New Issue
Block a user