From f3eaf649ef833e3e214e61a0de105e4308e019a4 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Tue, 28 Feb 2012 12:47:20 +0100 Subject: [PATCH 1/9] Fix bad variable returning - VMware --- src/im_mad/remotes/vmware.d/vmware.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/im_mad/remotes/vmware.d/vmware.rb b/src/im_mad/remotes/vmware.d/vmware.rb index b4c061656c..ea6920571e 100755 --- a/src/im_mad/remotes/vmware.d/vmware.rb +++ b/src/im_mad/remotes/vmware.d/vmware.rb @@ -106,7 +106,7 @@ conf = YAML::load(File.read(CONF_FILE)) rc, data = do_action("virsh -c #{@uri} --readonly nodeinfo") if rc == false - exit info + exit data end data.split(/\n/).each{|line| From 625908025cb8c595dadc7ed4a4e247723c304894 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Tue, 28 Feb 2012 14:03:08 +0100 Subject: [PATCH 2/9] SelfService: take advantange of verbose parameter when listing pools. Concretely, the Compute pool. No need to request the state for every single VM now. (cherry picked from commit a6067a8801bd5358051372831097f29096745998) --- src/cloud/occi/lib/ui/public/js/occi.js | 2 +- .../occi/lib/ui/public/js/plugins/compute.js | 37 ++++++------------- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/src/cloud/occi/lib/ui/public/js/occi.js b/src/cloud/occi/lib/ui/public/js/occi.js index a818fe8008..a841b00ded 100644 --- a/src/cloud/occi/lib/ui/public/js/occi.js +++ b/src/cloud/occi/lib/ui/public/js/occi.js @@ -189,7 +189,7 @@ var OCCI = { $.ajax({ url: resource.toLowerCase(), type: "GET", - data: {timeout: timeout}, + data: {timeout: timeout, verbose: true}, dataType: "xml ONEjson", success: function(response){ var res = {}; diff --git a/src/cloud/occi/lib/ui/public/js/plugins/compute.js b/src/cloud/occi/lib/ui/public/js/plugins/compute.js index 5613a1b3a2..99402b25a0 100644 --- a/src/cloud/occi/lib/ui/public/js/plugins/compute.js +++ b/src/cloud/occi/lib/ui/public/js/plugins/compute.js @@ -153,13 +153,6 @@ var vm_actions = { error: onError }, - "VM.showstate" : { - type: "single", - call: OCCI.VM.show, - callback: updateVMStateCB, - error: onError - }, - "VM.refresh" : { type: "custom", call : function (){ @@ -178,7 +171,7 @@ var vm_actions = { "VM.suspend" : { type: "multiple", call: OCCI.VM.suspend, - callback: updateVMStateCB, + callback: updateVMachineElement, elements: vmElements, error: onError, notify: true @@ -187,7 +180,7 @@ var vm_actions = { "VM.resume" : { type: "multiple", call: OCCI.VM.resume, - callback: updateVMStateCB, + callback: updateVMachineElement, elements: vmElements, error: onError, notify: true @@ -196,7 +189,7 @@ var vm_actions = { "VM.stop" : { type: "multiple", call: OCCI.VM.stop, - callback: updateVMStateCB, + callback: updateVMachineElement, elements: vmElements, error: onError, notify: true @@ -214,7 +207,7 @@ var vm_actions = { "VM.shutdown" : { type: "multiple", call: OCCI.VM.shutdown, - callback: updateVMStateCB, + callback: updateVMachineElement, elements: vmElements, error: onError, notify: true @@ -223,7 +216,7 @@ var vm_actions = { "VM.cancel" : { type: "multiple", call: OCCI.VM.cancel, - callback: updateVMStateCB, + callback: updateVMachineElement, elements: vmElements, error: onError, notify: true @@ -240,7 +233,7 @@ var vm_actions = { "VM.saveas" : { type: "single", call: OCCI.VM.saveas, - callback: updateVMStateCB, + callback: updateVMachineElement, error:onError }, @@ -259,7 +252,7 @@ var vm_actions = { }; var options = ""; for (var i = 0; i'+type+''; }; $('#dialog select#instance_type').html(options); @@ -423,7 +416,7 @@ function vMachineElementArray(vm_json){ return [ '', id, - name + VMStateBulletStr(vm_json) + name ]; } @@ -473,16 +466,15 @@ function updateVMachinesView(request, vmachine_list){ $.each(vmachine_list,function(){ el_array = vMachineElementArray(this); vmachine_list_array.push(el_array); - Sunstone.runAction("VM.showstate",el_array[1]); }); updateView(vmachine_list_array,dataTable_vMachines); updateDashboard("vms",vmachine_list); }; -function updateVMStateCB(request,vm){ +function VMStateBulletStr(vm){ var vm_state = vm.COMPUTE.STATE; - var state_html = vm_state; + var state_html = ""; switch (vm_state) { case "INIT": case "PENDING": @@ -499,13 +491,8 @@ function updateVMStateCB(request,vm){ state_html = ''+vm_state+''; break; }; - - var tag = 'input#vm_'+vm.COMPUTE.ID; - var array = vMachineElementArray(vm); - array[2] = state_html + array[2]; - updateSingleElement(array,dataTable_vMachines,tag); -}; - + return state_html; +} // Refreshes the information panel for a VM function updateVMInfo(request,vm){ From 38269de9b0140cdc708e75a332fb65b0874d4fc4 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Tue, 28 Feb 2012 14:46:35 +0100 Subject: [PATCH 3/9] Bug #1146: Prevent users from creating a VDC when no zones have been defined. (cherry picked from commit 443d7aa00c6ec2bacb4678e3d2b762a96b4b0fdd) --- src/ozones/Server/public/js/plugins/vdcs-tab.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ozones/Server/public/js/plugins/vdcs-tab.js b/src/ozones/Server/public/js/plugins/vdcs-tab.js index 2077aa5e2e..d03b75c7f8 100644 --- a/src/ozones/Server/public/js/plugins/vdcs-tab.js +++ b/src/ozones/Server/public/js/plugins/vdcs-tab.js @@ -516,6 +516,10 @@ function setupCreateVDCDialog(){ function openCreateVDCDialog(){ var dialog = $('div#create_vdc_dialog') + if (!zones_select){ + notifyError(tr("No zones defined: You need to create at least 1 zone before creating an VDC")); + return false; + }; $('select#zoneid',dialog).html(zones_select); $('select#zoneid',dialog).trigger("change"); $('#vdc_available_hosts_list',dialog).empty(); From 39d8e5b1a43cd005468fcbbd547b22ee97ca0aec Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Tue, 28 Feb 2012 16:21:01 +0100 Subject: [PATCH 4/9] Feature #1147: Improve login in Sunstone Error messages are better explained. More cases are handled (for example when server is not running). Error box looks nicer and repops up when error happens again. Ajax loader gif has been added next to login button and appears when login is being performed. (cherry picked from commit 9279848a50126863cc7eb4d27f554291b9744cd9) --- src/sunstone/public/css/login.css | 13 ++++++++++--- src/sunstone/public/js/login.js | 17 +++++++++++++---- src/sunstone/templates/login.html | 8 +++----- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/sunstone/public/css/login.css b/src/sunstone/public/css/login.css index 9c92aa9279..d275f49a57 100644 --- a/src/sunstone/public/css/login.css +++ b/src/sunstone/public/css/login.css @@ -134,10 +134,17 @@ div#login input#login_btn:hover { .error_message { display: none; position: relative; + width:400px; + margin-left: auto; + margin-right: auto; top: 80px; - font-family: Arial, Helvetica, sans-serif; - color:red; - font-size:1.6em; + font-size:1.0em; +} + +#login_spinner { + left: 44px; + position: relative; + top: 2px; } #label_remember { diff --git a/src/sunstone/public/js/login.js b/src/sunstone/public/js/login.js index 953f46aa1f..6b460d35c0 100644 --- a/src/sunstone/public/js/login.js +++ b/src/sunstone/public/js/login.js @@ -24,14 +24,19 @@ function auth_error(req, error){ switch (status){ case 401: - $("#one_error").hide(); - $("#auth_error").fadeIn("slow"); + $("#error_box").text("Invalid username or password"); break; case 500: - $("#auth_error").hide(); - $("#one_error").fadeIn("slow"); + $("#error_box").text("OpenNebula is not running or there was a server exception. Please check the server logs."); break; + case 0: + $("#error_box").text("No answer from server. Is it running?"); + break; + default: + $("#error_box").text("Unexpected error. Status "+status+". Check the server logs."); }; + $("#error_box").fadeIn("slow"); + $("#login_spinner").hide(); } function authenticate(){ @@ -39,6 +44,9 @@ function authenticate(){ var password = $("#password").val(); var remember = $("#check_remember").is(":checked"); + $("#error_box").fadeOut("slow"); + $("#login_spinner").show(); + OpenNebula.Auth.login({ data: {username: username , password: password} , remember: remember @@ -61,4 +69,5 @@ $(document).ready(function(){ }; $("input#username.box").focus(); + $("#login_spinner").hide(); }); diff --git a/src/sunstone/templates/login.html b/src/sunstone/templates/login.html index c942f3184f..1dc5352d14 100644 --- a/src/sunstone/templates/login.html +++ b/src/sunstone/templates/login.html @@ -3,6 +3,7 @@ OpenNebula Sunstone Login + @@ -25,11 +26,7 @@
-
- Invalid username or password -
-
- OpenNebula is not running +
@@ -43,6 +40,7 @@ + retrieving
From d32de04fbf2ea3841bd3ae4565dbdf94740fe877 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Tue, 28 Feb 2012 16:23:22 +0100 Subject: [PATCH 5/9] Feature #1147: Improve login in oZones Error messages are better explained. More cases are handled (for example when server is not running). Error box looks nicer and repops up when error happens again. Ajax loader gif has been added next to login button and appears when login is being performed. (cherry picked from commit c1e8b55b1a19a92813a086d57ed6a0747e19c2c1) --- src/ozones/Server/public/css/login.css | 13 +++++++++--- src/ozones/Server/public/js/login.js | 28 +++++++++++++++++--------- src/ozones/Server/templates/login.html | 9 +++------ 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/ozones/Server/public/css/login.css b/src/ozones/Server/public/css/login.css index 1ea3b09872..217c8c12ca 100644 --- a/src/ozones/Server/public/css/login.css +++ b/src/ozones/Server/public/css/login.css @@ -133,12 +133,19 @@ div#login input#login_btn:hover { } .error_message { + width: 400px; + margin-left: auto; + margin-right: auto; display: none; position: relative; top: 80px; - font-family: Arial, Helvetica, sans-serif; - color:red; - font-size:1.6em; + font-size:1.0em; +} + +#login_spinner { + left: 44px; + position: relative; + top: 2px; } #label_remember { diff --git a/src/ozones/Server/public/js/login.js b/src/ozones/Server/public/js/login.js index 70b26a3011..1ddc1ecd61 100644 --- a/src/ozones/Server/public/js/login.js +++ b/src/ozones/Server/public/js/login.js @@ -23,15 +23,21 @@ function auth_error(req, error){ var status = error.error.http_status; switch (status){ - case 401: - $("#one_error").hide(); - $("#auth_error").fadeIn("slow"); - break; - case 500: - $("#auth_error").hide(); - $("#one_error").fadeIn("slow"); - break; - } + case 401: + $("#error_box").text("Invalid username or password"); + break; + case 500: + $("#error_box").text("OpenNebula is not running or there was a server exception. Please check the server logs."); + break; + case 0: + $("#error_box").text("No answer from server. Is it running?"); + break; + default: + $("#error_box").text("Unexpected error. Status "+status+". Check the server logs."); + + }; + $("#error_box").fadeIn("slow"); + $("#login_spinner").hide(); } function authenticate(){ @@ -39,6 +45,9 @@ function authenticate(){ var password = $("#password").val(); var remember = $("#check_remember").is(":checked"); + $("#error_box").fadeOut("slow"); + $("#login_spinner").show(); + oZones.Auth.login({ data: {username: username , password: password} , remember: remember @@ -61,4 +70,5 @@ $(document).ready(function(){ }; $("input#username.box").focus(); + $("#login_spinner").hide(); }); diff --git a/src/ozones/Server/templates/login.html b/src/ozones/Server/templates/login.html index 6038b56e55..d1001aaaa4 100644 --- a/src/ozones/Server/templates/login.html +++ b/src/ozones/Server/templates/login.html @@ -3,7 +3,7 @@ OpenNebula oZones Login - + @@ -24,11 +24,7 @@
-
- Invalid username or password -
-
- OpenNebula is not running +
@@ -42,6 +38,7 @@ + retrieving
From 59c93f0768bdf03fc9ce63c3d2c57439a40fd323 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Tue, 28 Feb 2012 16:24:47 +0100 Subject: [PATCH 6/9] Feature #1147: Improve login in SelfService Error messages are better explained. More cases are handled (for example when server is not running). Error box looks nicer and repops up when error happens again. Ajax loader gif has been added next to login button and appears when login is being performed. (cherry picked from commit 5710fda8021b31c97b5285547941a6dc03231c19) --- src/cloud/occi/lib/ui/public/css/login.css | 13 ++++++++++--- src/cloud/occi/lib/ui/public/js/login.js | 18 ++++++++++++++---- src/cloud/occi/lib/ui/templates/login.html | 10 +++------- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/cloud/occi/lib/ui/public/css/login.css b/src/cloud/occi/lib/ui/public/css/login.css index 2fdd890a84..b58bacd20f 100644 --- a/src/cloud/occi/lib/ui/public/css/login.css +++ b/src/cloud/occi/lib/ui/public/css/login.css @@ -132,12 +132,19 @@ div#login input#login_btn:hover { } .error_message { + width: 400px; + margin-left: auto; + margin-right: auto; display: none; position: relative; top: 80px; - font-family: Arial, Helvetica, sans-serif; - color:red; - font-size:1.6em; + font-size:1.0em; +} + +#login_spinner { + left: 44px; + position: relative; + top: 2px; } #label_remember { diff --git a/src/cloud/occi/lib/ui/public/js/login.js b/src/cloud/occi/lib/ui/public/js/login.js index 721200f945..363fb781fd 100644 --- a/src/cloud/occi/lib/ui/public/js/login.js +++ b/src/cloud/occi/lib/ui/public/js/login.js @@ -24,14 +24,20 @@ function auth_error(req, error){ switch (status){ case 401: - $("#one_error").hide(); - $("#auth_error").fadeIn("slow"); + $("#error_box").text("Invalid username or password"); break; case 500: - $("#auth_error").hide(); - $("#one_error").fadeIn("slow"); + $("#error_box").text("OpenNebula is not running or there was a server exception. Please check the server logs."); break; + case 0: + $("#error_box").text("No answer from server. Is it running?"); + break; + default: + $("#error_box").text("Unexpected error. Status "+status+". Check the server logs."); + }; + $("#error_box").fadeIn("slow"); + $("#login_spinner").hide(); } function authenticate(){ @@ -40,6 +46,9 @@ function authenticate(){ password = Crypto.SHA1(password); var remember = $("#check_remember").is(":checked"); + $("#error_box").fadeOut("slow"); + $("#login_spinner").show(); + var obj = { data: {username: username, password: password}, remember: remember, @@ -70,4 +79,5 @@ $(document).ready(function(){ }; $("input#username.box").focus(); + $("#login_spinner").hide(); }); diff --git a/src/cloud/occi/lib/ui/templates/login.html b/src/cloud/occi/lib/ui/templates/login.html index 82b80c0785..8bf6d0c005 100644 --- a/src/cloud/occi/lib/ui/templates/login.html +++ b/src/cloud/occi/lib/ui/templates/login.html @@ -3,7 +3,7 @@ OpenNebula Self-Service Login - + @@ -28,11 +28,7 @@
-
- Invalid username or password -
-
- OpenNebula is not running +
@@ -46,7 +42,7 @@ - + retrieving
From fbbce209d5df5c86a14449c6a23b3058252d4f75 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Wed, 29 Feb 2012 11:09:14 +0100 Subject: [PATCH 7/9] Sunstone: small improvements to passwd operations Inform user that password change was successful. Empty the new password box when dialog is re-opened. (cherry picked from commit 519b7f263b5cb4b399b67cb9259d9e8fff2e84c6) --- src/sunstone/public/js/plugins/users-tab.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sunstone/public/js/plugins/users-tab.js b/src/sunstone/public/js/plugins/users-tab.js index a9d35c164f..19d48435e1 100644 --- a/src/sunstone/public/js/plugins/users-tab.js +++ b/src/sunstone/public/js/plugins/users-tab.js @@ -131,9 +131,11 @@ var user_actions = { "User.passwd" : { type: "multiple", call: OpenNebula.User.passwd, - //nocallback + callback: function(req,res){ + notifyMessage(tr("Change password successful")); + }, elements: userElements, - error: onError + error: onError, }, "User.chgrp" : { type: "multiple", @@ -492,6 +494,7 @@ function popUpCreateUserDialog(){ function popUpUpdatePasswordDialog(){ + $('#new_password',$update_pw_dialog).val(""); $update_pw_dialog.dialog('open'); } From deb5e8d025f1a2e2bd312a0bc6127ae97230f688 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Wed, 29 Feb 2012 17:55:39 +0100 Subject: [PATCH 8/9] Feature #1109: Self service support in oZones server Needs testing & GUI extension --- src/ozones/Server/lib/OZones/ApacheWritter.rb | 8 ++++++++ src/ozones/Server/lib/OZones/Zones.rb | 1 + 2 files changed, 9 insertions(+) diff --git a/src/ozones/Server/lib/OZones/ApacheWritter.rb b/src/ozones/Server/lib/OZones/ApacheWritter.rb index 327874a2e4..ca3ae1fdd3 100644 --- a/src/ozones/Server/lib/OZones/ApacheWritter.rb +++ b/src/ozones/Server/lib/OZones/ApacheWritter.rb @@ -28,12 +28,20 @@ module OZones zone.vdcs.all.each{|vdc| htaccess << "RewriteRule ^#{vdc.NAME} " + "#{zone.ENDPOINT} [P]\n" + if zone.SUNSENDPOINT != nil htaccess << "RewriteRule ^sunstone_#{vdc.NAME}/(.+) " + "#{zone.SUNSENDPOINT}/$1 [P]\n" htaccess << "RewriteRule ^sunstone_#{vdc.NAME} " + "#{zone.SUNSENDPOINT}/ [P]\n" end + + if zone.SELFENDPOINT != nil + htaccess << "RewriteRule ^self_#{vdc.NAME}/(.+) " + + "#{zone.SELFENDPOINT}/$1 [P]\n" + htaccess << "RewriteRule ^self_#{vdc.NAME} " + + "#{zone.SELFENDPOINT}/ [P]\n" + end } } diff --git a/src/ozones/Server/lib/OZones/Zones.rb b/src/ozones/Server/lib/OZones/Zones.rb index 5c1230945f..6e9aae9db7 100644 --- a/src/ozones/Server/lib/OZones/Zones.rb +++ b/src/ozones/Server/lib/OZones/Zones.rb @@ -30,6 +30,7 @@ module OZones property :ONEPASS, String, :required => true property :ENDPOINT, String, :required => true property :SUNSENDPOINT, String + property :SELFENDPOINT, String has n, :vdcs From f50df547e8c26942d503233afe0e2917ca955720 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Thu, 1 Mar 2012 18:55:42 +0100 Subject: [PATCH 9/9] Feature #1073: Add support for mysql and posgresql in oZones server --- src/ozones/Server/etc/ozones-server.conf | 1 + src/ozones/Server/ozones-server.rb | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/ozones/Server/etc/ozones-server.conf b/src/ozones/Server/etc/ozones-server.conf index 022158205e..8b09856d69 100644 --- a/src/ozones/Server/etc/ozones-server.conf +++ b/src/ozones/Server/etc/ozones-server.conf @@ -23,6 +23,7 @@ ###################### :databasetype: sqlite +#:databaseserver: dbuser:dbpassword@localhost #:htaccess: /var/www/.htaccess :dbdebug: no diff --git a/src/ozones/Server/ozones-server.rb b/src/ozones/Server/ozones-server.rb index 84dc77d9b7..a3fb9d8b85 100755 --- a/src/ozones/Server/ozones-server.rb +++ b/src/ozones/Server/ozones-server.rb @@ -57,7 +57,20 @@ config=YAML::load(config_data) db_type = config[:databasetype] -db_url = db_type + "://" + VAR_LOCATION + "/ozones.db" +case db_type + when "sqlite" then + db_url = db_type + "://" + VAR_LOCATION + "/ozones.db" + when "mysql","postgres" then + if config[:databaseserver].nil? + warn "DB server needed for this type of DB backend" + exit -1 + end + + db_url = db_type + "://" + config[:databaseserver] + "/ozones" + else + warn "DB type #{db_type} not recognized" + exit -1 +end ############################################################################## # DB bootstrapping