mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
Merge branch 'master' of git.opennebula.org:one
This commit is contained in:
commit
31200cb183
@ -295,7 +295,7 @@ var create_template_tmpl = '<div id="template_create_tabs">\
|
||||
</select>\
|
||||
<div class="tip">Name of the network to attach this device</div>\
|
||||
</div>\
|
||||
<div class="vm_param kvm_opt xen_opt niccfg">\
|
||||
<div class="vm_param kvm_opt xen_opt niccfg network">\
|
||||
<label for="IP">IP:</label>\
|
||||
<input type="text" id="IP" name="ip" />\
|
||||
<div class="tip">Request an specific IP from the Network</div>\
|
||||
|
@ -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 = '<span class="vm_log_error">'+line+'</span>'
|
||||
}
|
||||
colored_log += line + "\n";
|
||||
for (var i = 0; i < log_lines.length;i++){
|
||||
var line = log_lines[i];
|
||||
if (line.match(/\[E\]/)){
|
||||
line = '<span class="vm_log_error">'+line+'</span>';
|
||||
}
|
||||
colored_log += line + "\n";
|
||||
}
|
||||
|
||||
var log_tab = {
|
||||
title: "VM log",
|
||||
content: '<pre>'+colored_log+'</pre>'
|
||||
@ -690,10 +697,10 @@ function setupSaveasDialog(){
|
||||
<form action="javascript:alert(\'js error!\');">\
|
||||
<div id="saveas_tabs">\
|
||||
</div>\
|
||||
<div class="form_buttons">\
|
||||
<button id="vm_saveas_proceed" value="">OK</button>\
|
||||
<button id="vm_saveas_cancel" value="">Cancel</button>\
|
||||
</div>\
|
||||
<div class="form_buttons">\
|
||||
<button id="vm_saveas_proceed" value="">OK</button>\
|
||||
<button id="vm_saveas_cancel" value="">Cancel</button>\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
</form>');
|
||||
|
||||
@ -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){
|
||||
<div id="vm_id_text">Saveas for VM with ID <span id="vm_id">'+this+'</span></div>\
|
||||
<fieldset>\
|
||||
<div>\
|
||||
<label for="vm_disk_id">Disk id:</label>\
|
||||
<input type="text" id="vm_disk_id" name="vm_disk_id" value="" size="2"/>\
|
||||
<label for="vm_disk_id">Select disk:</label>\
|
||||
<select id="vm_disk_id" name="vm_disk_id">\
|
||||
<option value="">Retrieving...</option>\
|
||||
</select>\
|
||||
</div>\
|
||||
<div>\
|
||||
<label for="image_name">Image name:</label>\
|
||||
<input type="text" id="image_name" name="image_name" value="" />\
|
||||
</div>\
|
||||
<!-- not used anymore\
|
||||
<div>\
|
||||
<label for="img_attr_value">Type:</label>\
|
||||
<select id="image_type" name="image_type">\
|
||||
<option value="">Default</option>\
|
||||
<option value="disk">Disk</option>\
|
||||
<option value="floppy">Floppy</option>\
|
||||
<option value="cdrom">CD-ROM</option>\
|
||||
<option value="swap">Swap</option>\
|
||||
<option value="fs">FS</option>\
|
||||
<option value="block">Block</option>\
|
||||
</select>\
|
||||
<option value="disk">Disk</option>\
|
||||
<option value="floppy">Floppy</option>\
|
||||
<option value="cdrom">CD-ROM</option>\
|
||||
<option value="swap">Swap</option>\
|
||||
<option value="fs">FS</option>\
|
||||
<option value="block">Block</option>\
|
||||
</select>\
|
||||
</div>\
|
||||
-->\
|
||||
</fieldset>\
|
||||
</div>';
|
||||
$('#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 '<option value="'+id+'">'+name+' (disk id: '+id+')</option>';
|
||||
}
|
||||
else {
|
||||
return '<option value="'+id+'">'+source+' (disk id: '+id+')</option>';
|
||||
}
|
||||
}
|
||||
|
||||
var disks = vm_info.TEMPLATE.DISK;
|
||||
if (!disks) { select = '<option value="">No disks defined</option>';}
|
||||
else if (disks.constructor == Array) //several disks
|
||||
{
|
||||
for (var i=0;i<disks.length;i++){
|
||||
select += gen_option(disks[i].DISK_ID,disks[i].IMAGE,disks[i].SOURCE);
|
||||
}
|
||||
} else {
|
||||
select+= gen_option(disks.DISK_ID,disks.IMAGE,disks.SOURCE);
|
||||
}
|
||||
//introduce options in the right tab
|
||||
$('#saveas_tabs #saveas_tab_'+id+' #vm_disk_id').html(select);
|
||||
|
||||
}
|
||||
|
||||
//Prepares autorefresh
|
||||
function setVMAutorefresh(){
|
||||
setInterval(function(){
|
||||
|
@ -381,7 +381,7 @@ function updateVNetworkInfo(request,vn){
|
||||
<thead>\
|
||||
<tr><th colspan="2">Leases information</th></tr>\
|
||||
</thead>'+
|
||||
prettyPrintJSON(vn_info.LEASES)+
|
||||
prettyPrintJSON(vn_info.LEASES.LEASE)+
|
||||
'</table>';
|
||||
}
|
||||
|
||||
|
@ -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 += '<tr>\
|
||||
<td class="key_td" style=\
|
||||
"padding-left:'+padding+'px;\
|
||||
font-weight:'+weight+';\
|
||||
border-bottom:'+border_bottom+';\
|
||||
padding-top:'+padding_top_bottom+'px;\
|
||||
padding-bottom:'+padding_top_bottom+'px;">'
|
||||
+field+
|
||||
'</td>\
|
||||
<td class="value_td" style=\
|
||||
"border-bottom:'+border_bottom+';\
|
||||
padding-top:'+padding_top_bottom+'px;\
|
||||
padding-bottom:'+padding_top_bottom+'px">\
|
||||
</td>\
|
||||
</tr>';
|
||||
//attributes rows
|
||||
//empty row - prettyprint - empty row
|
||||
str += '<tr>\
|
||||
<td class="key_td" style="border-bottom:0"></td>\
|
||||
<td class="value_td" style="border-bottom:0"></td>\
|
||||
</tr>' +
|
||||
prettyPrintJSON(template_json[field],padding+25,"normal","0",1) +
|
||||
'<tr>\
|
||||
<td class="key_td"></td>\
|
||||
<td class="value_td"></td>\
|
||||
</tr>';
|
||||
} else {
|
||||
str += '<tr>\
|
||||
<td class="key_td" style="\
|
||||
padding-left:'+padding+'px;\
|
||||
font-weight:'+weight+';\
|
||||
border-bottom:'+border_bottom+';\
|
||||
padding-top:'+padding_top_bottom+'px;\
|
||||
padding-bottom:'+padding_top_bottom+'px">'+
|
||||
field+
|
||||
'</td>\
|
||||
<td class="value_td" style="\
|
||||
border-bottom:'+border_bottom+';\
|
||||
padding-top:'+padding_top_bottom+'px;\
|
||||
padding-bottom:'+padding_top_bottom+'px">'+
|
||||
template_json[field]+
|
||||
'</td>\
|
||||
if (template_json.constructor == Array){
|
||||
for (field = 0; field < template_json.length; ++field){
|
||||
str += prettyPrintRowJSON(field,template_json[field],padding,weight, border_bottom,padding_top_bottom);
|
||||
}
|
||||
} else {
|
||||
for (field in template_json) {
|
||||
str += prettyPrintRowJSON(field,template_json[field],padding,weight, border_bottom,padding_top_bottom);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
function prettyPrintRowJSON(field,value,padding,weight, border_bottom,padding_top_bottom){
|
||||
var str="";
|
||||
|
||||
if (typeof value == 'object'){
|
||||
//name of field row
|
||||
str += '<tr>\
|
||||
<td class="key_td" style=\
|
||||
"padding-left:'+padding+'px;\
|
||||
font-weight:'+weight+';\
|
||||
border-bottom:'+border_bottom+';\
|
||||
padding-top:'+padding_top_bottom+'px;\
|
||||
padding-bottom:'+padding_top_bottom+'px;">'
|
||||
+field+
|
||||
'</td>\
|
||||
<td class="value_td" style=\
|
||||
"border-bottom:'+border_bottom+';\
|
||||
padding-top:'+padding_top_bottom+'px;\
|
||||
padding-bottom:'+padding_top_bottom+'px">\
|
||||
</td>\
|
||||
</tr>';
|
||||
};
|
||||
//attributes rows
|
||||
//empty row - prettyprint - empty row
|
||||
str += '<tr>\
|
||||
<td class="key_td" style="border-bottom:0"></td>\
|
||||
<td class="value_td" style="border-bottom:0"></td>\
|
||||
</tr>' +
|
||||
prettyPrintJSON(value,padding+25,"normal","0",1) +
|
||||
'<tr>\
|
||||
<td class="key_td"></td>\
|
||||
<td class="value_td"></td>\
|
||||
</tr>';
|
||||
} else {
|
||||
str += '<tr>\
|
||||
<td class="key_td" style="\
|
||||
padding-left:'+padding+'px;\
|
||||
font-weight:'+weight+';\
|
||||
border-bottom:'+border_bottom+';\
|
||||
padding-top:'+padding_top_bottom+'px;\
|
||||
padding-bottom:'+padding_top_bottom+'px">'+
|
||||
field+
|
||||
'</td>\
|
||||
<td class="value_td" style="\
|
||||
border-bottom:'+border_bottom+';\
|
||||
padding-top:'+padding_top_bottom+'px;\
|
||||
padding-bottom:'+padding_top_bottom+'px">'+
|
||||
value+
|
||||
'</td>\
|
||||
</tr>';
|
||||
};
|
||||
|
||||
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<rows.length; i++){
|
||||
key = rows[i];
|
||||
value = eval(key);
|
||||
if (value)
|
||||
|
Loading…
x
Reference in New Issue
Block a user