mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-11 04:58:16 +03:00
parent
fe545803c9
commit
2b0f530865
@ -152,6 +152,26 @@ class SunstoneServer < CloudServer
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
############################################################################
|
||||
#
|
||||
############################################################################
|
||||
def createMarketApp(type, template)
|
||||
action_hash = JSONUtils.parse_json(template, 'action')
|
||||
if OpenNebula.is_error?(action_hash)
|
||||
return [500, image_hash.to_json]
|
||||
end
|
||||
marketplaceapp = MarketPlaceAppJSON.new(MarketPlaceApp.build_xml, @client)
|
||||
|
||||
rc = case type
|
||||
when "service" then marketplaceapp.app_service_import(action_hash['params'])
|
||||
else
|
||||
marketplaceapp.app_vm_import(action_hash['params']) #VM / VM_TEMPLATE
|
||||
end
|
||||
|
||||
return [201, rc.to_json]
|
||||
end
|
||||
|
||||
############################################################################
|
||||
#
|
||||
############################################################################
|
||||
|
@ -464,7 +464,31 @@ define(function(require) {
|
||||
|
||||
return ""+id;
|
||||
},
|
||||
"importMarketApp": function(params, resource, method, action_obj) {
|
||||
var callback = params.success;
|
||||
var callbackError = params.error;
|
||||
var id = params.data.id;
|
||||
var action = OpenNebulaHelper.action(method, action_obj);
|
||||
var request = OpenNebulaHelper.request(resource, method, [id, action_obj]);
|
||||
|
||||
var reqPath = resource.toLowerCase();
|
||||
var cache_name = params.cache_name ? params.cache_name : resource;
|
||||
$.ajax({
|
||||
url: reqPath + "/" + id + "/create",
|
||||
type: "POST",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
data: JSON.stringify(action),
|
||||
success: function(response) {
|
||||
_clearCache(cache_name);
|
||||
|
||||
return callback ? callback(request, response) : null;
|
||||
},
|
||||
error: function(response) {
|
||||
return callbackError ?
|
||||
callbackError(request, OpenNebulaError(response)) : null;
|
||||
}
|
||||
});
|
||||
},
|
||||
"getAppTags": function(params, resource){
|
||||
var callback = params.success;
|
||||
var callbackError = params.error;
|
||||
|
@ -127,11 +127,11 @@ define(function(require) {
|
||||
},
|
||||
"import_vm_template" : function(params){
|
||||
var action_obj = params.data.extra_param;
|
||||
OpenNebulaAction.simple_action(params, RESOURCE, "vm-template.import", action_obj);
|
||||
OpenNebulaAction.importMarketApp(params, RESOURCE, "vm-template.import", action_obj);
|
||||
},
|
||||
"import_service_template" : function(params){
|
||||
var action_obj = params.data.extra_param;
|
||||
OpenNebulaAction.simple_action(params, RESOURCE, "service_template.import", action_obj);
|
||||
OpenNebulaAction.importMarketApp(params, RESOURCE, "service_template.import", action_obj);
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -436,7 +436,7 @@ define(function(require) {
|
||||
|
||||
var newTemplate = $.extend(marketPlaceJSON, { ORIGIN_ID: String(templateId) });
|
||||
|
||||
Sunstone.runAction("MarketPlaceApp.import_vm_template", 0, newTemplate);
|
||||
Sunstone.runAction("MarketPlaceApp.import_vm_template", 'vm', newTemplate);
|
||||
},
|
||||
error: function(request, response) {
|
||||
Sunstone.hideFormPanelLoading(TAB_ID);
|
||||
@ -460,7 +460,7 @@ define(function(require) {
|
||||
marketPlaceJSON['IMPORT_ALL'] = marketPlaceJSON['IMPORT_ALL'] === 'on'
|
||||
marketPlaceJSON['MARKETPLACE_ID'] = marketplaceIdSelected;
|
||||
|
||||
Sunstone.runAction("MarketPlaceApp.import_vm_template", 0, marketPlaceJSON);
|
||||
Sunstone.runAction("MarketPlaceApp.import_vm_template", 'vmtemplate', marketPlaceJSON);
|
||||
|
||||
break;
|
||||
|
||||
@ -471,7 +471,7 @@ define(function(require) {
|
||||
marketPlaceJSON['MARKETPLACE_ID'] = marketplaceIdSelected;
|
||||
marketPlaceJSON['MARKETPLACE_SERVICE_ID'] = this.marketPlacesServiceTable.idInput().val();
|
||||
|
||||
Sunstone.runAction("MarketPlaceApp.import_service_template", 0, marketPlaceJSON);
|
||||
Sunstone.runAction("MarketPlaceApp.import_service_template", 'service', marketPlaceJSON);
|
||||
|
||||
break;
|
||||
|
||||
|
@ -135,7 +135,6 @@ define(function(require) {
|
||||
function _fill(context, templateJSON) {
|
||||
if(templateJSON && templateJSON.BACKUP_CONFIG){
|
||||
var configs = templateJSON.BACKUP_CONFIG
|
||||
console.log("dsadas", configs)
|
||||
if(configs && configs.BACKUP_VOLATILE && configs.BACKUP_VOLATILE === 'YES'){
|
||||
$(idsElements.backup_volatile, context).click();
|
||||
}
|
||||
|
@ -1191,6 +1191,13 @@ get '/marketplaceapp/:id/tags' do
|
||||
@SunstoneServer.get_docker_tags(params[:id])
|
||||
end
|
||||
|
||||
##############################################################################
|
||||
# Create a marketPlacetApp
|
||||
##############################################################################
|
||||
post '/marketplaceapp/:type/create' do
|
||||
@SunstoneServer.createMarketApp(params[:type], @request_body)
|
||||
end
|
||||
|
||||
##############################################################################
|
||||
# Create a new Resource
|
||||
##############################################################################
|
||||
|
Loading…
x
Reference in New Issue
Block a user