mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
Feature #708: Update Sunstone to use the template instantiate method instead of VM create method.
This commit is contained in:
parent
954ff1a4fc
commit
bcc56d415c
@ -46,6 +46,7 @@ module OpenNebulaJSON
|
||||
when "unpublish" then self.unpublish
|
||||
when "update" then self.update(action_hash['params'])
|
||||
when "chown" then self.chown(action_hash['params'])
|
||||
when "instantiate" then self.instantiate(action_hash['params'])
|
||||
else
|
||||
error_msg = "#{action_hash['perform']} action not " <<
|
||||
" available for this resource"
|
||||
@ -60,5 +61,10 @@ module OpenNebulaJSON
|
||||
def chown(params=Hash.new)
|
||||
super(params['owner_id'].to_i,params['group_id'].to_i)
|
||||
end
|
||||
|
||||
def instantiate(params=Hash.new)
|
||||
super(params['vm_name'])
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -2333,6 +2333,39 @@ var OpenNebula = {
|
||||
});
|
||||
|
||||
},
|
||||
"instantiate" : function(params) {
|
||||
var callback = params.success;
|
||||
var callback_error = params.error;
|
||||
var id = params.data.id;
|
||||
var vm_name = params.data.extra_param ? params.data.extra_param : "";
|
||||
var vm_obj = { "vm_name" : vm_name }
|
||||
|
||||
var method = "instantiate";
|
||||
var action = OpenNebula.Helper.action(method,vm_obj);
|
||||
var resource = OpenNebula.Template.resource;
|
||||
var request = OpenNebula.Helper.request(resource,method, [id,vm_obj]);
|
||||
|
||||
$.ajax({
|
||||
url: "template/" + id + "/action",
|
||||
type: "POST",
|
||||
data: JSON.stringify(action),
|
||||
success: function()
|
||||
{
|
||||
if (callback)
|
||||
{
|
||||
callback(request);
|
||||
}
|
||||
},
|
||||
error: function(response)
|
||||
{
|
||||
if(callback_error)
|
||||
{
|
||||
callback_error(request, OpenNebula.Error(response));
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
"fetch_template" : function(params)
|
||||
{
|
||||
var callback = params.success;
|
||||
|
@ -646,17 +646,22 @@ var template_actions = {
|
||||
notify: true
|
||||
},
|
||||
|
||||
"Template.instantiate" : {
|
||||
"Template.instantiate" : {
|
||||
type: "single",
|
||||
call: OpenNebula.Template.instantiate,
|
||||
callback: function(){},
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"Template.instantiate_vms" : {
|
||||
type: "custom",
|
||||
call: function(){
|
||||
nodes = getSelectedNodes(dataTable_templates);
|
||||
$.each(nodes,function(){
|
||||
Sunstone.runAction("VM.create",
|
||||
{vm : {
|
||||
template_id: this
|
||||
}
|
||||
});
|
||||
Sunstone.runAction("Template.instantiate",this,"");
|
||||
});
|
||||
Sunstone.runAction("VM.refresh");
|
||||
},
|
||||
notify: false
|
||||
},
|
||||
@ -701,7 +706,7 @@ var template_buttons = {
|
||||
condition: True,
|
||||
alwaysActive: true
|
||||
},
|
||||
"Template.instantiate" : {
|
||||
"Template.instantiate_vms" : {
|
||||
type: "action",
|
||||
text: "Instantiate",
|
||||
condition: True
|
||||
|
@ -96,11 +96,13 @@ var rfb;
|
||||
|
||||
var vm_actions = {
|
||||
"VM.create" : {
|
||||
type: "create",
|
||||
call: OpenNebula.VM.create,
|
||||
type: "custom",
|
||||
call: function(id,name) {
|
||||
Sunstone.runAction("Template.instantiate",id,name);
|
||||
Sunstone.runAction("VM.list");
|
||||
},
|
||||
callback: addVMachineElement,
|
||||
error: onError,
|
||||
notify: true
|
||||
error: onError
|
||||
},
|
||||
|
||||
"VM.create_dialog" : {
|
||||
@ -765,9 +767,8 @@ function setupCreateVMDialog(){
|
||||
$('#create_vm_dialog #create_vm_proceed').click(function(){
|
||||
var vm_name = $('#create_vm_form #vm_name').val();
|
||||
var template_id = $('#create_vm_form #template_id').val();
|
||||
var vm_json = { vm: { vm_name: vm_name, template_id : template_id }};
|
||||
|
||||
Sunstone.runAction("VM.create",vm_json);
|
||||
Sunstone.runAction("VM.create",template_id,vm_name);
|
||||
$('#create_vm_dialog').dialog('close');
|
||||
return false;
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user