diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js index c27822cf95..a4bb7a1d34 100644 --- a/src/sunstone/public/js/plugins/vms-tab.js +++ b/src/sunstone/public/js/plugins/vms-tab.js @@ -244,12 +244,20 @@ var vm_actions = { {data:obj, success: function (req) { Sunstone.runAction("VM.show", - req.request.data[0]); + req.request.data[0][0]); }, error: onError }); } }, - + + "VM.saveas_disks" : { + type: "single", + call: OpenNebula.VM.show, + callback: saveasDisksCallback, + error: onError, + notify: false + }, + "VM.shutdown" : { type: "multiple", call: OpenNebula.VM.shutdown, @@ -689,10 +697,10 @@ function setupSaveasDialog(){
\
\
\ -
\ - \ - \ -
\ +
\ + \ + \ +
\ \
'); @@ -711,7 +719,7 @@ function setupSaveasDialog(){ var id = $('#vm_id',this).text(); var disk_id = $('#vm_disk_id',this).val(); var image_name = $('#image_name',this).val(); - var type = $('#image_type',this).val(); + //var type = $('#image_type',this).val(); if (!id.length || !disk_id.length || !image_name.length) { notifyError("Skipping VM "+id+ @@ -721,8 +729,8 @@ function setupSaveasDialog(){ var obj = { vm_id: id, disk_id : disk_id, - image_name : image_name, - type: type + image_name : image_name + //type: type }; args.push(id); Sunstone.runAction("VM.saveas",obj); @@ -755,35 +763,68 @@ function popUpSaveasDialog(elems){
Saveas for VM with ID '+this+'
\
\
\ - \ - \ + \ + \
\
\ \ \
\ + \
\ '; $('#saveas_vm_dialog #saveas_tabs').append(tab); + Sunstone.runAction("VM.saveas_disks",this); }); $('#saveas_vm_dialog #saveas_tabs').tabs(); $('#saveas_vm_dialog button').button(); - $('#saveas_vm_dialog').dialog('open'); } +function saveasDisksCallback(req,response){ + var vm_info = response.VM; + var id=vm_info.ID; + var select=""; + + var gen_option = function(id, name, source){ + if (name){ + return ''; + } + else { + return ''; + } + } + + var disks = vm_info.TEMPLATE.DISK; + if (!disks) { select = '';} + else if (disks.constructor == Array) //several disks + { + for (var i=0;i