mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-14 19:24:10 +03:00
parent
473fc4f9da
commit
14f09cf958
@ -21,6 +21,7 @@ require 'uri'
|
||||
require 'json'
|
||||
require 'base64'
|
||||
require 'rexml/document'
|
||||
require 'securerandom'
|
||||
|
||||
# OpenNebula MarketPlace
|
||||
class OneMarket
|
||||
@ -111,14 +112,12 @@ class OneMarket
|
||||
|
||||
def render_vmtemplate(tmpl, app)
|
||||
print_var(tmpl, 'SIZE', 0)
|
||||
print_var(tmpl, 'MD5', app['md5'])
|
||||
|
||||
if app['disks']
|
||||
app['disks'].each do |disk|
|
||||
dname = disk.keys.first
|
||||
|
||||
app['disks'].each do |app_name|
|
||||
tmpl << <<-EOT.strip
|
||||
DISK = [ NAME = "#{dname}", APP="#{disk[dname]}" ]
|
||||
DISK = [ NAME = "#{SecureRandom.hex[0..9]}",
|
||||
APP="#{app_name}" ]
|
||||
EOT
|
||||
end
|
||||
end
|
||||
@ -137,14 +136,11 @@ class OneMarket
|
||||
|
||||
def render_service_template(tmpl, app)
|
||||
print_var(tmpl, 'SIZE', 0)
|
||||
print_var(tmpl, 'MD5', app['md5'])
|
||||
|
||||
if app['roles']
|
||||
app['roles'].each do |role|
|
||||
rname = role.keys.first
|
||||
|
||||
app['roles'].each do |role_name, app_name|
|
||||
tmpl << <<-EOT.strip
|
||||
ROLE = [ NAME = "#{rname}", APP="#{role[rname]}" ]
|
||||
ROLE = [ NAME = "#{role_name}", APP="#{app_name}" ]
|
||||
EOT
|
||||
end
|
||||
end
|
||||
|
@ -73,6 +73,8 @@ module OpenNebula::MarketPlaceAppExt
|
||||
when 'IMAGE'
|
||||
export_image(options)
|
||||
when 'VMTEMPLATE'
|
||||
options[:notemplate] = true
|
||||
|
||||
export_vm_template(options)
|
||||
when 'SERVICE_TEMPLATE'
|
||||
export_service_template(options)
|
||||
@ -328,10 +330,12 @@ module OpenNebula::MarketPlaceAppExt
|
||||
tmpl['roles'].each do |role|
|
||||
t_id = roles.find {|_, v| v[:names].include?(role['name']) }
|
||||
|
||||
next if t_id.nil? || t_id[1].nil? || t_id[1][:vmtemplate]
|
||||
if t_id.nil? || t_id[1].nil? || t_id[1][:vmtemplate].nil?
|
||||
next
|
||||
end
|
||||
|
||||
role['vm_template'] = nil
|
||||
role['vm_template'] = t_id[1][:vmtemplate]
|
||||
role['vm_template'] = t_id[1][:vmtemplate][0]
|
||||
end
|
||||
|
||||
# --------------------------------------------------------------
|
||||
@ -387,8 +391,9 @@ module OpenNebula::MarketPlaceAppExt
|
||||
obj.extend(MarketPlaceAppExt)
|
||||
|
||||
rc = obj.export(
|
||||
:dsid => options[:dsid],
|
||||
:name => "#{options[:name]}-#{idx}"
|
||||
:dsid => options[:dsid],
|
||||
:name => "#{options[:name]}-#{idx}",
|
||||
:notemplate => options[:notemplate]
|
||||
)
|
||||
|
||||
image = rc[:image].first if rc[:image]
|
||||
|
Loading…
x
Reference in New Issue
Block a user