1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

Merge branch 'master' into vdc-federation

This commit is contained in:
Daniel Molina 2014-02-03 17:38:04 +01:00
commit f7edf6e46b
8 changed files with 1973 additions and 1995 deletions

13
.gitignore vendored Normal file
View File

@ -0,0 +1,13 @@
*.a
*.o
*.pyc
.xmlrpc_test/
.sconsign.dblite
share/man/*.gz
src/im_mad/collectd/collectd
src/scheduler/src/sched/.xmlrpc_test/
src/scheduler/src/sched/mm_sched
src/sunstone/locale/languages/*.js
src/mad/utils/tty_expect
src/nebula/.xmlrpc_test/
src/nebula/oned

View File

@ -154,25 +154,18 @@ function gzip_file_size {
function fs_size {
case $1 in
http://*/download|https://*/download)
BASE_URL=${1%%/download}
HEADERS=`wget -S --spider --no-check-certificate $BASE_URL 2>&1`
http://*)
HEADERS=`curl -LIk $1 2>&1`
echo $HEADERS | grep "market" > /dev/null 2>&1
if [ $? -eq 0 ]; then
#URL is from market place
SIZE=`wget -O - -S --no-check-certificate $BASE_URL 2>&1|grep -E "^ *\"size\": \"?[0-9]+\"?.$"|tr -dc 0-9`
if echo "$HEADERS" | grep -q "OpenNebula-AppMarket-Size"; then
# An AppMarket/Marketplace URL
SIZE=$(echo "$HEADERS" | grep "^OpenNebula-AppMarket-Size:" | tail -n1 | cut -d: -f2)
else
#Not a marketplace URL
SIZE=`wget -S --spider --no-check-certificate $1 2>&1 | grep Content-Length | cut -d':' -f2`
# Not an AppMarket/Marketplace URL
SIZE=$(echo "$HEADERS" | grep "^Content-Length:" | tail -n1 | cut -d: -f2)
fi
error=$?
;;
http://*|https://*)
SIZE=`wget -S --spider --no-check-certificate $1 2>&1 | grep Content-Length | cut -d':' -f2`
error=$?
;;
*)
if [ -d "$1" ]; then
SIZE=`du -sb "$1" | cut -f1`
@ -195,6 +188,8 @@ function fs_size {
;;
esac
SIZE=$(echo $SIZE | tr -d "\r")
if [ $error -ne 0 ]; then
SIZE=0
else

View File

@ -18,28 +18,14 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include <getopt.h>
#include <ostream>
#include "Nebula.h"
using namespace std;
/* ------------------------------------------------------------------------- */
/* GLOBAL VARIABLES */
/* ------------------------------------------------------------------------- */
static const char * usage =
"\n oned [-h] [-v] [-f]\n\n"
"SYNOPSIS\n"
" Starts the OpenNebula daemon\n\n"
"OPTIONS\n"
"\t-v\tprints OpenNebula version and license\n"
"\t-h\tprints this help.\n"
"\t-f\tforeground, do not fork the oned daemon\n"
"\t-i\tinitialize the dabase and exit.\n";
static const char * susage =
"usage: oned [-h] [-v] [-f]\n";
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
@ -51,6 +37,25 @@ static void print_license()
<< "(http://www.apache.org/licenses/LICENSE-2.0).\n";
}
static void print_usage(ostream& str)
{
str << "Usage: oned [-h] [-v] [-f] [-i]\n";
}
static void print_help()
{
print_usage(cout);
cout << "\n"
<< "SYNOPSIS\n"
<< " Starts the OpenNebula daemon\n\n"
<< "OPTIONS\n"
<< " -v, --verbose\toutput version information and exit\n"
<< " -h, --help\tdisplay this help and exit\n"
<< " -f, --foreground\tforeground, do not fork the oned daemon\n"
<< " -i, --init-db\tinitialize the dabase and exit\n";
}
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
@ -100,7 +105,19 @@ int main(int argc, char **argv)
string wd;
int rc;
while((opt = getopt(argc,argv,"vhif")) != -1)
static struct option long_options[] = {
{"version", no_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{"foreground", no_argument, 0, 'f'},
{"init-db", no_argument, 0, 'i'},
{0, 0, 0, 0}
};
int long_index = 0;
while ((opt = getopt_long(argc, argv, "vhif",
long_options, &long_index)) != -1)
{
switch(opt)
{
case 'v':
@ -108,7 +125,7 @@ int main(int argc, char **argv)
exit(0);
break;
case 'h':
cout << usage;
print_help();
exit(0);
break;
case 'i':
@ -119,10 +136,11 @@ int main(int argc, char **argv)
foreground = true;
break;
default:
cerr << susage;
print_usage(cerr);
exit(-1);
break;
}
}
// ---------------------------------
// Check if other oned is running

View File

@ -344,9 +344,12 @@ var image_actions = {
"Image.create" : {
type: "create",
call: OpenNebula.Image.create,
callback: addImageElement,
error: onError,
notify:true
callback: function(request, response){
addImageElement(request, response);
$create_image_dialog.trigger("reveal:close")
notifyCustom(tr("Image created "), "ID: " + response.IMAGE.ID, false)
},
error: onError
},
"Image.create_dialog" : {
@ -866,26 +869,20 @@ function enable_all_datastores()
}
// Prepare the image creation dialog
function setupCreateImageDialog(){
function setupCreateImageDialog(dialog){
dialogs_context.append('<div id="create_image_dialog"></div>');
$create_image_dialog = $('#create_image_dialog',dialogs_context);
var dialog = $create_image_dialog;
dialog.html(create_image_tmpl);
setupTips($create_image_dialog);
var height = Math.floor($(window).height()*0.8); //set height to a percentage of the window
//Prepare jquery dialog
//dialog.dialog({
// autoOpen: false,
// modal:true,
// width: 520,
// height: height
//});
dialog.addClass("reveal-modal large max-height");
initialize_create_image_dialog(dialog);
}
function initialize_create_image_dialog(dialog) {
setupTips(dialog);
$('.advanced',dialog).hide();
$('#advanced_image_create',dialog).click(function(){
@ -893,32 +890,24 @@ function setupCreateImageDialog(){
return false;
});
//$('#img_tabs',dialog).tabs();
//$('button',dialog).button();
//$('#datablock_img',dialog).attr('disabled','disabled');
$('select#img_type',dialog).change(function(){
var value = $(this).val();
var context = $create_image_dialog;
var context = dialog;
switch (value){
case "DATABLOCK":
$('#datablock_img',context).removeAttr("disabled");
//$('#empty_datablock', context).show();
break;
default:
$('#datablock_img',context).attr('disabled','disabled');
//$('#empty_datablock', context).hide();
$('#path_img',context).click();
}
});
$('#img_path,#img_fstype,#img_size,#file-uploader',dialog).closest('.row').hide();
$("input[name='src_path']", dialog).change(function(){
var context = $create_image_dialog;
var context = dialog;
var value = $(this).val();
switch (value){
case "path":
@ -942,8 +931,8 @@ function setupCreateImageDialog(){
$('#add_custom_var_image_button', dialog).click(
function(){
var name = $('#custom_var_image_name',$create_image_dialog).val();
var value = $('#custom_var_image_value',$create_image_dialog).val();
var name = $('#custom_var_image_name',dialog).val();
var value = $('#custom_var_image_value',dialog).val();
if (!name.length || !value.length) {
notifyError(tr("Custom attribute name and value must be filled in"));
return false;
@ -951,14 +940,14 @@ function setupCreateImageDialog(){
option= '<option value=\''+value+'\' name=\''+name+'\'>'+
name+'='+value+
'</option>';
$('select#custom_var_image_box',$create_image_dialog).append(option);
$('select#custom_var_image_box',dialog).append(option);
return false;
}
);
$('#remove_custom_var_image_button', dialog).click(
function(){
$('select#custom_var_image_box :selected',$create_image_dialog).remove();
$('select#custom_var_image_box :selected',dialog).remove();
return false;
}
);
@ -966,9 +955,7 @@ function setupCreateImageDialog(){
$('#upload-progress',dialog).css({
border: "1px solid #AAAAAA",
position: "relative",
// bottom: "29px",
width: "258px",
// left: "133px",
height: "15px",
display: "inline-block"
});
@ -978,7 +965,7 @@ function setupCreateImageDialog(){
// Upload is handled by FileUploader vendor plugin
var uploader = new qq.FileUploaderBasic({
button: $('#file-uploader',$create_image_dialog)[0],
button: $('#file-uploader',dialog)[0],
action: 'upload',
multiple: false,
params: {},
@ -987,35 +974,11 @@ function setupCreateImageDialog(){
//notifyMessage(message);
},
onSubmit: function(id, fileName){
//set url params
//since the body is the upload, we need the pass
//the image info here
uploader.setParams({
img : JSON.stringify(img_obj),
file: fileName
});
//we pop up an upload progress dialog
//var pos_top = $(window).height() - 120;
//var pos_left = 220;
//var pb_dialog = $('<div id="pb_dialog" title="'+
// tr("Uploading...")+'">'+
// '<div id="upload-progress"></div>'+
// '</div>').dialog({
// draggable:true,
// modal:false,
// resizable:false,
// buttons:{},
// width: 460,
// minHeight: 50,
// position: [pos_left, pos_top]
// });
//var pb_dialog = $('<div id="pb_dialog" title="'+
// tr("Uploading...")+'">'+
// '<div id="upload-progress"></div>'+
// '</div>').addClass("reveal-modal");
//$('#upload-progress',pb_dialog).progressbar({value:0});
$('#upload_progress_bars').append('<div id="'+id+'progressBar" class="row" style="margin-bottom:10px">\
<div class="two columns dataTables_info">\
'+tr("Uploading...")+'\
@ -1029,8 +992,6 @@ function setupCreateImageDialog(){
</div>');
},
onProgress: function(id, fileName, loaded, total){
//update upload dialog with current progress
//$('div#pb_dialog #upload-progress').progressbar("option","value",Math.floor(loaded*100/total));
$('span.meter', $('#'+id+'progressBar')).css('width', Math.floor(loaded*100/total)+'%')
},
onComplete: function(id, fileName, responseJSON){
@ -1152,7 +1113,7 @@ function setupCreateImageDialog(){
}
//Time to add custom attributes
$('#custom_var_image_box option',$create_image_dialog).each(function(){
$('#custom_var_image_box option',dialog).each(function(){
var attr_name = $(this).attr('name');
var attr_value = $(this).val();
img_json[attr_name] = attr_value;
@ -1170,8 +1131,6 @@ function setupCreateImageDialog(){
Sunstone.runAction("Image.create", img_obj);
};
$create_image_dialog.trigger("reveal:close")
return false;
});
@ -1192,21 +1151,21 @@ function setupCreateImageDialog(){
"ds_id" : ds_id
};
Sunstone.runAction("Image.create",img_obj);
$create_image_dialog.trigger("reveal:close")
return false;
});
$('#wizard_image_reset_button').click(function(){
$create_image_dialog.trigger('reveal:close');
$create_image_dialog.remove();
dialog.trigger('reveal:close');
dialog.remove();
setupCreateImageDialog();
popUpCreateImageDialog();
});
$('#advanced_image_reset_button').click(function(){
$create_image_dialog.trigger('reveal:close');
$create_image_dialog.remove();
dialog.trigger('reveal:close');
dialog.remove();
setupCreateImageDialog();
popUpCreateImageDialog();
@ -1214,10 +1173,7 @@ function setupCreateImageDialog(){
});
}
function popUpCreateImageDialog(){
$('#file-uploader input',$create_image_dialog).removeAttr("style");
$('#file-uploader input',$create_image_dialog).attr('style','margin:0;width:256px!important');
function initialize_datastore_info_create_image_dialog(dialog) {
datastores_str = makeSelectOptions(dataTable_datastores,
1,
4,
@ -1226,18 +1182,23 @@ function popUpCreateImageDialog(){
true
);
$('#img_datastore',$create_image_dialog).html(datastores_str);
$('#img_datastore_raw',$create_image_dialog).html(datastores_str);
$('#img_datastore',dialog).html(datastores_str);
$('#img_datastore_raw',dialog).html(datastores_str);
$create_image_dialog.reveal();
$("input#img_name",$create_image_dialog).focus();
$('select#img_datastore').children('option').each(function() {
if ($(this).val() == "2")
{
$('select#img_datastore', dialog).children('option').each(function() {
if ($(this).val() == "2") {
$(this).attr('disabled', 'disabled');
}
});
$('#file-uploader input',dialog).removeAttr("style");
$('#file-uploader input',dialog).attr('style','margin:0;width:256px!important');
}
function popUpCreateImageDialog(){
initialize_datastore_info_create_image_dialog($create_image_dialog);
$create_image_dialog.reveal();
$("input#img_name",$create_image_dialog).focus();
}
// Set the autorefresh interval for the datatable

View File

@ -16,6 +16,7 @@
/* Marketpplace tab plugin */
var dataTable_marketplace;
var $marketplace_import_dialog;
var market_actions = {
"Marketplace.list" : {
@ -42,36 +43,115 @@ var market_actions = {
elements: marketplaceElements,
call: OpenNebula.Marketplace.show,
callback: function(request,response){
$('#img_name', $create_image_dialog).val(response['name']);
$('#img_path', $create_image_dialog).val(response['links']['download']['href']);
$('#src_path_select input[value="path"]', $create_image_dialog).trigger('click');
$('select#img_type', $create_image_dialog).val('OS');
$('select#img_type', $create_image_dialog).trigger('change');
if (response['files'][0]['hypervisor'] == "KVM") {
$('#img_driver', $create_image_dialog).val(response['files'][0]['format'])
if (response['status'] && response['status'] != 'ready') {
notifyError(tr("The appliance is not ready"));
return;
}
//remove any options from the custom vars dialog box
$("#custom_var_image_box",$create_image_dialog).empty();
var md5 = response['files'][0]['md5']
if ( md5 ) {
option = '<option value=\'' +
md5 + '\' name="MD5">MD5=' +
md5 + '</option>';
$("#custom_var_image_box",$create_image_dialog).append(option);
if ($marketplace_import_dialog != undefined) {
$marketplace_import_dialog.remove();
}
var sha1 = response['files'][0]['sha1']
if ( sha1 ) {
option = '<option value=\'' +
sha1 + '\' name="SHA1">SHA1=' +
sha1 + '</option>';
$("#custom_var_image_box",$create_image_dialog).append(option);
dialogs_context.append(marketplace_import_dialog);
$marketplace_import_dialog = $('#marketplace_import_dialog',dialogs_context);
$marketplace_import_dialog.addClass("reveal-modal xlarge max-height");
$marketplace_import_dialog.reveal();
var tab_id = 1;
$.each(response['files'], function(index, value){
// Append the new div containing the tab and add the tab to the list
var image_dialog = $('<li id="'+tab_id+'Tab" class="disk wizard_internal_tab">'+
create_image_tmpl +
'</li>').appendTo($("ul#marketplace_import_dialog_tabs_content"));
var a_image_dialog = $("<dd>\
<a id='disk_tab"+tab_id+"' href='#"+tab_id+"'>"+tr("Image")+"</a>\
</dd>").appendTo($("dl#marketplace_import_dialog_tabs"));
initialize_create_image_dialog(image_dialog);
initialize_datastore_info_create_image_dialog(image_dialog);
$('#img_name', image_dialog).val(value['name']||response['name']);
$('#img_path', image_dialog).val(response['links']['download']['href']+'/'+index);
$('#src_path_select input[value="path"]', image_dialog).trigger('click');
$('select#img_type', image_dialog).val(value['type']);
$('select#img_type', image_dialog).trigger('change');
//remove any options from the custom vars dialog box
$("#custom_var_image_box",image_dialog).empty();
var md5 = value['md5']
if ( md5 ) {
option = '<option value=\'' +
md5 + '\' name="MD5">MD5=' +
md5 + '</option>';
$("#custom_var_image_box",image_dialog).append(option);
}
var sha1 = value['sha1']
if ( sha1 ) {
option = '<option value=\'' +
sha1 + '\' name="SHA1">SHA1=' +
sha1 + '</option>';
$("#custom_var_image_box",image_dialog).append(option);
}
a_image_dialog.on('click', function(){
$create_image_dialog = image_dialog;
})
image_dialog.on("reveal:close", function(){
a_image_dialog.remove();
image_dialog.remove();
if ($('a', $("dl#marketplace_import_dialog_tabs")).size > 0) {
$('a', $("dl#marketplace_import_dialog_tabs")).first().click();
} else {
$marketplace_import_dialog.trigger("reveal:close");
}
return false;
});
$("a[href='#img_manual']", image_dialog).closest('dl').remove();
tab_id++;
})
if (response['opennebula_template'] && response['opennebula_template'] !== "CPU=1") {
$create_template_dialog.remove();
// Template
// Append the new div containing the tab and add the tab to the list
var template_dialog = $('<li id="'+tab_id+'Tab" class="disk wizard_internal_tab">'+
create_template_tmpl +
'</li>').appendTo($("ul#marketplace_import_dialog_tabs_content"));
var a_template_dialog = $("<dd>\
<a id='disk_tab"+tab_id+"' href='#"+tab_id+"'>"+tr("Template")+"</a>\
</dd>").appendTo($("dl#marketplace_import_dialog_tabs"));
initialize_create_template_dialog(template_dialog);
fillTemplatePopUp(
JSON.parse(response['opennebula_template']),
template_dialog);
a_template_dialog.on('click', function(){
$create_template_dialog = template_dialog;
})
template_dialog.on("reveal:close", function(){
a_template_dialog.remove();
template_dialog.remove();
if ($('a', $("dl#marketplace_import_dialog_tabs")).size > 0) {
$('a', $("dl#marketplace_import_dialog_tabs")).first().click();
} else {
$marketplace_import_dialog.trigger("reveal:close");
}
return false;
});
$("a[href='#manual']", template_dialog).closest('dl').remove();
}
popUpCreateImageDialog();
$('a', $("dl#marketplace_import_dialog_tabs")).first().click();
},
error: onError
},
@ -97,6 +177,20 @@ var market_buttons = {
}
};
var marketplace_import_dialog =
'<div id="marketplace_import_dialog">'+
'<div class="panel">'+
'<h3><small>'+tr("Import Appliance")+'</small></h4>'+
'</div>'+
'<div class="reveal-body">'+
'<dl class="tabs" id="marketplace_import_dialog_tabs">'+
'</dl>'+
'<ul class="tabs-content" id="marketplace_import_dialog_tabs_content">'+
'</ul>'+
'</div>'+
'<a class="close-reveal-modal">&#215;</a>'+
'</div>';
var marketplace_tab_content = '\
<form class="custom" id="marketplace_form" action="">\
<div class="panel">\

File diff suppressed because it is too large Load Diff

View File

@ -336,6 +336,11 @@ function notifyMessage(msg){
$.jGrowl(msg, {theme: "jGrowl-notify-submit", position: "bottom-right"});
}
function notifyCustom(title, msg, sticky) {
msg = "<h1>" + title + "</h1>" + msg;
$.jGrowl(msg, {theme: "jGrowl-notify-submit", position: "bottom-right", sticky: sticky });
}
// Returns an HTML string with the json keys and values
// Attempts to css format output, giving different values to
// margins etc. according to depth level etc.

View File

@ -2692,6 +2692,14 @@ int VirtualMachine::generate_context(string &files, int &disk_id, string& token_
files += files_ds;
}
for (size_t i=0;i<files.length();i++)
{
if (files[i] == '\n')
{
files[i] = ' ';
}
}
context->vector_value("TOKEN", token);
if (token)