diff --git a/src/sunstone/public/js/plugins/templates-tab.js b/src/sunstone/public/js/plugins/templates-tab.js
index 0c2ad5cbb8..c58dfc76eb 100644
--- a/src/sunstone/public/js/plugins/templates-tab.js
+++ b/src/sunstone/public/js/plugins/templates-tab.js
@@ -295,7 +295,7 @@ var create_template_tmpl = '
\
\
Name of the network to attach this device
\
\
-
\
+
\
\
\
Request an specific IP from the Network
\
diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js
index d1362e0dcd..5ffc5be8de 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,
@@ -289,15 +297,14 @@ var vm_actions = {
//update the tab and pop it up again
var log_lines = res.split("\n");
var colored_log = '';
- for (line in log_lines){
- line = log_lines[line];
- if (typeof line == "string") {
- if (line.match(/\[E\]/)){
- line = ''+line+''
- }
- colored_log += line + "\n";
+ for (var i = 0; i < log_lines.length;i++){
+ var line = log_lines[i];
+ if (line.match(/\[E\]/)){
+ line = ''+line+'';
}
+ colored_log += line + "\n";
}
+
var log_tab = {
title: "VM log",
content: '
'+colored_log+'
'
@@ -690,10 +697,10 @@ function setupSaveasDialog(){
');
@@ -712,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+
@@ -722,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);
@@ -756,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\
Leases information
\
'+
- prettyPrintJSON(vn_info.LEASES)+
+ prettyPrintJSON(vn_info.LEASES.LEASE)+
'';
}
diff --git a/src/sunstone/public/js/sunstone-util.js b/src/sunstone/public/js/sunstone-util.js
index 5e2ba6d22b..ca9ca9eabc 100644
--- a/src/sunstone/public/js/sunstone-util.js
+++ b/src/sunstone/public/js/sunstone-util.js
@@ -198,59 +198,75 @@ function notifyMessage(msg){
// It recursively explores objects
function prettyPrintJSON(template_json,padding,weight, border_bottom,padding_top_bottom){
var str = ""
+ if (!template_json){ return "Not defined";}
if (!padding) {padding=0};
if (!weight) {weight="bold";}
if (!border_bottom) {border_bottom = "1px solid #CCCCCC";}
if (!padding_top_bottom) {padding_top_bottom=6;}
+ var field = null;
- for (field in template_json) {
- if (typeof template_json[field] == 'object'){
- //name of field row
- str += '
';
};
+
return str;
}
@@ -336,7 +352,7 @@ function onError(request,error_json) {
var value;
rows = ["method","action","object","id","reason"];
message = "";
- for (i in rows){
+ for (i = 0; i