diff --git a/src/sunstone/bin/sunstone-server b/src/sunstone/bin/sunstone-server index 977750dd03..06efb73b8a 100755 --- a/src/sunstone/bin/sunstone-server +++ b/src/sunstone/bin/sunstone-server @@ -32,6 +32,14 @@ fi PORT="4567" HOST="127.0.0.1" +usage() { + echo + echo "Usage: sunstone-server [-H host] [-p port]" + echo + echo "-H: Host for the Sunstone server, default value: localhost" + echo "-p: Port for incoming connections, default value: 4567" +} + setup() { @@ -92,30 +100,25 @@ stop() # Kill the sunstone daemon kill -INT `cat $SUNSTONE_PID` &> /dev/null + # Remove pid files + rm -f $SUNSTONE_LOCK_FILE &> /dev/null + echo "sunstone-server stopped" } -while getopts "p:h:" OPTION +while getopts "p:H:" OPTION do case $OPTION in - p) PORT=$OPTARG;; - h) HOST=$OPTARG;; - \?) echo "Invalid option: -$OPTARG" >&2; exit 3 ;; + p) PORT=$OPTARG;; + H) HOST=$OPTARG;; + *) usage; exit 3;; esac done shift $((OPTIND-1)) case "$1" in - start) - setup - start - ;; - stop) - stop - ;; - *) - echo "Usage: sunstone {start|stop}" >&2 - exit 3 - ;; + start) setup; start;; + stop) stop;; + *) usage; exit 3;; esac diff --git a/src/sunstone/models/SunstoneServer.rb b/src/sunstone/models/SunstoneServer.rb index fbb9422c82..0efa1dc63e 100644 --- a/src/sunstone/models/SunstoneServer.rb +++ b/src/sunstone/models/SunstoneServer.rb @@ -14,8 +14,6 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -# TBD Change path for intallation tree - ONE_LOCATION = ENV["ONE_LOCATION"] if !ONE_LOCATION @@ -24,7 +22,6 @@ else VAR_LOCATION = ONE_LOCATION+"/var" end -#require 'OpenNebulaJSON' require 'models/OpenNebulaJSON' include OpenNebulaJSON @@ -61,9 +58,8 @@ class SunstoneServer ############################################################################ # ############################################################################ - def get_pool(kind, user_id) - user_flag = user_id=="0" ? -2 : -1 - + def get_pool(kind) + user_flag = -1 pool = case kind when "cluster" then ClusterPoolJSON.new(@client) when "host" then HostPoolJSON.new(@client) @@ -199,8 +195,7 @@ class SunstoneServer begin log = File.read(vm_log_file) rescue Exception => e - error = Error.new("Error: log for VM #{id} not available") - return [500, error.to_s] + return [200, "Log for VM #{id} not available"] end return [200, log] diff --git a/src/sunstone/public/js/one-ui_views.js b/src/sunstone/public/js/one-ui_views.js index 7497a7484e..2613efdd35 100644 --- a/src/sunstone/public/js/one-ui_views.js +++ b/src/sunstone/public/js/one-ui_views.js @@ -179,7 +179,8 @@ function initDataTables(){ "aoColumnDefs": [ { "bSortable": false, "aTargets": ["check"] }, { "sWidth": "60px", "aTargets": [0] }, - { "sWidth": "35px", "aTargets": [1] } + { "sWidth": "35px", "aTargets": [1] }, + { "sWidth": "100px", "aTargets": [2] } ] }); @@ -190,8 +191,9 @@ function initDataTables(){ "sPaginationType": "full_numbers", "aoColumnDefs": [ { "bSortable": false, "aTargets": ["check"] }, - { "sWidth": "60px", "aTargets": [0,5,6,7] }, - { "sWidth": "35px", "aTargets": [1] } + { "sWidth": "60px", "aTargets": [0,4,5,6,7] }, + { "sWidth": "35px", "aTargets": [1] }, + { "sWidth": "100px", "aTargets": [2] } ] }); @@ -217,7 +219,8 @@ function initDataTables(){ "aoColumnDefs": [ { "bSortable": false, "aTargets": ["check"] }, { "sWidth": "60px", "aTargets": [0,3] }, - { "sWidth": "35px", "aTargets": [1] } + { "sWidth": "35px", "aTargets": [1] }, + { "sWidth": "100px", "aTargets": [2,3] } ] }); @@ -345,11 +348,11 @@ function refreshButtonListener(){ callback = updateHostsView; waiting_nodes(dataTable_hosts); OpenNebula.Host.list({success: callback, error: onError}); + callback = updateClustersView; + OpenNebula.Cluster.list({success: callback, error: onError}); break; case "OpenNebula.Cluster.list": - callback = updateClustersView; - waiting_nodes(dataTable_clusters); - OpenNebula.Cluster.list({success: callback, error: onError}); + //we have no cluster button for this break; case "OpenNebula.VM.list": callback = updateVMachinesView; @@ -523,7 +526,7 @@ function confirmWithSelectListener(){ dataTable="null"; select_var = clusters_select; callback = function (){ - OpenNebula.Host.list({success: updateClustersView,error: onError}); + OpenNebula.Cluster.list({success: updateClustersView,error: onError}); } break; case "OpenNebula.VM.deploy": @@ -739,9 +742,8 @@ function actionButtonListener(){ nodes_id.push($(this).val()); //Calling action(id,callback,error_callback) if (extra_param!=null){ //action with two parameters - data = extra_param; - data.id = $(this).val(); - (eval(action)({data: data, success: callback, error: onError})); + var data_arg = {cluster_id: extra_param, id: $(this).val()}; + (eval(action)({data: data_arg, success: callback, error: onError})); } else { //action with one parameter (eval(action)({data:{id:$(this).val()},success: callback,error: onError})); }; @@ -810,11 +812,11 @@ function setupImageAttributesDialogs(){
\ \ \ - \ + \
\
\ \ - \ + \
\
\ \ @@ -827,7 +829,7 @@ function setupImageAttributesDialogs(){ autoOpen:false, width:400, modal:true, - height:270, + height:200, resizable:false, }); @@ -1046,7 +1048,7 @@ function createClusterDialog(){ //If it's successfull we refresh the list. OpenNebula.Cluster.create({ data:cluster_json, success: function(){ - OpenNebula.Cluster.list(updateClustersView,onError)}, + OpenNebula.Cluster.list({success:updateClustersView,error:onError})}, error: onError}); $create_cluster_dialog.dialog('close'); return false; @@ -2090,7 +2092,7 @@ function createImageDialog(){ break; } obj = { "image" : img_json }; - OpenNebula.Image.create({data: obj,success: addImageElement,error: onError}); + OpenNebula.Image.register({data: obj,success: addImageElement,error: onError}); $create_image_dialog.dialog('close'); return false; @@ -2236,9 +2238,17 @@ function tableCheckboxesListener(dataTable){ dataTable = $(this).parents('table').dataTable(); context = dataTable.parents('form'); last_action_b = $('.last_action_button',context); - nodes_length = $('input:checked',dataTable.fnGetNodes()).length; + nodes = dataTable.fnGetNodes(); + total_length = nodes.length; + checked_length = $('input:checked',nodes).length; - if (nodes_length){ + if (total_length == checked_length){ + $('.check_all',dataTable).attr("checked","checked"); + } else { + $('.check_all',dataTable).removeAttr("checked"); + } + + if (checked_length){ $('.top_button, .list_button',context).button("enable"); if (last_action_b.length && last_action_b.val().length){ last_action_b.button("enable"); @@ -2765,12 +2775,14 @@ function updateVNetworkElement(request, vn_json){ function deleteVNetworkElement(req){ deleteElement(dataTable_vNetworks,'#vnetwork_'+req.request.data); + //How to delete vNetwork select option here? } function addVNetworkElement(request,vn_json){ element = vNetworkElementArray(vn_json); addElement(element,dataTable_vNetworks); - + vnetworks_select += ""; + $('div.vm_section#networks select#NETWORK').html(vnetworks_select); } function updateVNetworksView(request, network_list){ @@ -2822,11 +2834,14 @@ function updateImageElement(request, image_json){ function deleteImageElement(req){ deleteElement(dataTable_images,'#image_'+req.request.data); + //how to update the image select here? } function addImageElement(request, image_json){ element = imageElementArray(image_json); addElement(element,dataTable_images); + images_select += ""; + $('div.vm_section#disks select#IMAGE').html(images_select); } function updateImagesView(request, images_list){ @@ -3112,14 +3127,16 @@ function updateVNetworkInfo(request,vn){ Public\ '+(parseInt(vn_info.PUBLIC) ? "yes" : "no" )+'\ \ - \ - \ +
'; + if (vn_info.TEMPLATE.TYPE == "FIXED"){ + rendered_info += '\ \ \ '+ prettyPrintJSON(vn_info.LEASES)+ - '
Leases information
\ -
\ + ''; + } + rendered_info += '\
\ \ '+ @@ -3163,11 +3180,11 @@ function updateImageInfo(request,img){ \ \ \ - \ + \ \ \ \ - \ + \ \ \ \ @@ -3175,7 +3192,7 @@ function updateImageInfo(request,img){ \ \ \ - \ + \ \
Virtual Network template
Public'+(img_info.PUBLIC ? "yes" : "no")+''+(parseInt(img_info.PUBLIC) ? "yes" : "no")+'
Persistent'+(img_info.PERSISTENT ? "yes" : "no")+''+(parseInt(img_info.PERSISTENT) ? "yes" : "no")+'
Source
State'+img_info.STATE+''+OpenNebula.Helper.resource_state("image",img_info.STATE)+'
\
\ diff --git a/src/sunstone/public/js/one-ui_views.templates.js b/src/sunstone/public/js/one-ui_views.templates.js index 67dbaa50b6..a9dbe832eb 100644 --- a/src/sunstone/public/js/one-ui_views.templates.js +++ b/src/sunstone/public/js/one-ui_views.templates.js @@ -168,14 +168,14 @@ var hostlist_tmpl = \
\ \ + \ \
\
\ - \ + \
\ \ \ @@ -895,7 +895,7 @@ var userlist_tmpl = '\
\
\ - OpenNebula.VM.list\ + OpenNebula.User.list\
\
\ \ @@ -1042,10 +1042,13 @@ var create_image_tmpl =
\
\ \ - Provide a path
\ - Provide a source
\ - Create an empty datablock\ -
Please choose path if you have a file-based image. Choose source otherwise or create an empty datablock disk.
\ + \ +
\ + \ +
\ + \ + \ +
Please choose path if you have a file-based image. Choose source otherwise or create an empty datablock disk.

\
\
\ \ diff --git a/src/sunstone/public/js/opennebula.js b/src/sunstone/public/js/opennebula.js index 9579bd4683..310e88a7d3 100644 --- a/src/sunstone/public/js/opennebula.js +++ b/src/sunstone/public/js/opennebula.js @@ -145,7 +145,9 @@ var OpenNebula = { var p_pool = []; - pool = response[pool_name][type]; + if (response[pool_name]) { + pool = response[pool_name][type]; + } else { pull = null }; if (pool == null) { diff --git a/src/sunstone/sunstone-server.rb b/src/sunstone/sunstone-server.rb index c71b857aa1..f855f3e0bc 100755 --- a/src/sunstone/sunstone-server.rb +++ b/src/sunstone/sunstone-server.rb @@ -123,7 +123,7 @@ end # GET Pool information ############################################################################## get '/:pool' do - @SunstoneServer.get_pool(params[:pool], session["user_id"]) + @SunstoneServer.get_pool(params[:pool]) end ##############################################################################