mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
parent
35b46e4fa9
commit
c95884aa51
@ -42,6 +42,9 @@ require 'one_helper/onemarketapp_helper'
|
||||
require 'one_helper/onemarket_helper'
|
||||
require 'one_helper/onedatastore_helper'
|
||||
|
||||
require 'vcenter_driver'
|
||||
CONFIG = VCenterConf.new
|
||||
|
||||
CommandParser::CmdParser.new(ARGV) do
|
||||
usage '`onemarket` <command> [<args>] [<options>]'
|
||||
version OpenNebulaHelper::ONE_VERSION
|
||||
@ -101,6 +104,13 @@ CommandParser::CmdParser.new(ARGV) do
|
||||
end
|
||||
}
|
||||
|
||||
TEMPLATE = {
|
||||
:name => 'template',
|
||||
:large => '--template template_id ',
|
||||
:description => 'Associate with VM template',
|
||||
:format => Integer,
|
||||
}
|
||||
|
||||
MARKET = {
|
||||
:name => 'market',
|
||||
:large => '--market market_id',
|
||||
@ -123,7 +133,8 @@ CommandParser::CmdParser.new(ARGV) do
|
||||
OneDatastoreHelper::FILE_DATASTORE,
|
||||
OneMarketPlaceAppHelper::VMNAME,
|
||||
TAG,
|
||||
NO]
|
||||
NO,
|
||||
TEMPLATE]
|
||||
IMPORT_OPTIONS = [YES, NO, MARKET, OneMarketPlaceAppHelper::VMNAME]
|
||||
|
||||
########################################################################
|
||||
@ -272,7 +283,9 @@ CommandParser::CmdParser.new(ARGV) do
|
||||
:name => args[1],
|
||||
:vmtemplate_name => options[:vmname],
|
||||
:url_args => tag,
|
||||
:notemplate => options[:no] == 'no'
|
||||
:notemplate => options[:no] == 'no',
|
||||
:template => options[:template],
|
||||
:default_template => CONFIG[:default_template],
|
||||
)
|
||||
|
||||
if OpenNebula.is_error?(rc)
|
||||
|
@ -89,12 +89,14 @@ module OpenNebula::MarketPlaceAppExt
|
||||
private
|
||||
|
||||
# Exports an OpenNebula Image from this marketplace app
|
||||
# @param optoins to export the image
|
||||
# @param options to export the image
|
||||
# :vmtemplate_name [String] name of new image and template
|
||||
# :url_args [String] optional URL arguments
|
||||
# :dsid [String] Datastore id to create the image
|
||||
# :f_dsid [String] Files Datastore id
|
||||
# :notemplate [Bool] if true do not create vm_template (if any)
|
||||
# :template [Integer] Template id to use with image
|
||||
# :default_template [String] Default template id for vCenter
|
||||
# @return [Hash]
|
||||
# :image [Array] of the new image
|
||||
# :image_type [String] of the new image (CONTEXT, KERNEL, CDROM)
|
||||
@ -181,19 +183,41 @@ module OpenNebula::MarketPlaceAppExt
|
||||
return rc_info
|
||||
end
|
||||
|
||||
tmpl = Base64.decode64(self['TEMPLATE/VMTEMPLATE64'])
|
||||
tmpl << <<-EOT
|
||||
if !options[:template].nil?
|
||||
template_id = options[:template]
|
||||
|
||||
NAME = "#{options[:vmtemplate_name] || options[:name]}"
|
||||
DISK = [ IMAGE_ID = "#{image.id}" ]
|
||||
EOT
|
||||
template_id = options[:default_template] if template_id == -1
|
||||
|
||||
vmtpl = Template.new(Template.build_xml, @client)
|
||||
template = Template.new_with_id(template_id, @client)
|
||||
|
||||
rc = vmtpl.allocate(tmpl)
|
||||
rc = vmtpl.id unless OpenNebula.is_error?(rc)
|
||||
vmtpl_id = template.clone(options[:vmtemplate_name] || options[:name])
|
||||
|
||||
rc_info[:vmtemplate] = [rc]
|
||||
tmpl << <<-EOT
|
||||
|
||||
NAME = "#{options[:vmtemplate_name] || options[:name]}"
|
||||
DISK = [ IMAGE_ID = "#{image.id}" ]
|
||||
EOT
|
||||
|
||||
template = Template.new_with_id(vmtpl_id, @client)
|
||||
|
||||
template.update(tmpl, true)
|
||||
|
||||
rc_info[:vmtemplate] = [vmtpl_id]
|
||||
else
|
||||
tmpl = Base64.decode64(self['TEMPLATE/VMTEMPLATE64'])
|
||||
tmpl << <<-EOT
|
||||
|
||||
NAME = "#{options[:vmtemplate_name] || options[:name]}"
|
||||
DISK = [ IMAGE_ID = "#{image.id}" ]
|
||||
EOT
|
||||
|
||||
vmtpl = Template.new(Template.build_xml, @client)
|
||||
|
||||
rc = vmtpl.allocate(tmpl)
|
||||
rc = vmtpl.id unless OpenNebula.is_error?(rc)
|
||||
|
||||
rc_info[:vmtemplate] = [rc]
|
||||
end
|
||||
|
||||
rc_info
|
||||
end
|
||||
|
@ -35,4 +35,7 @@
|
||||
:memory_dumps: true
|
||||
|
||||
# Cache expiration for monitoring
|
||||
:cache_expire: 120
|
||||
:cache_expire: 120
|
||||
|
||||
# Default template when import from MarketPlace
|
||||
:default_template: -1
|
||||
|
Loading…
x
Reference in New Issue
Block a user