diff --git a/install.sh b/install.sh index ccddf49715..ec2d5b1341 100755 --- a/install.sh +++ b/install.sh @@ -297,6 +297,11 @@ INSTALL_CLIENT_FILES=( RUBY_OPENNEBULA_LIB_FILES:$LIB_LOCATION/ruby/OpenNebula ) +INSTALL_SUNSTONE_RUBY_FILES=( + SUNSTONE_RUBY_LIB_FILES:$LIB_LOCATION/ruby + RUBY_OPENNEBULA_LIB_FILES:$LIB_LOCATION/ruby/OpenNebula +) + INSTALL_SUNSTONE_FILES=( SUNSTONE_FILES:$SUNSTONE_LOCATION SUNSTONE_BIN_FILES:$BIN_LOCATION @@ -308,8 +313,6 @@ INSTALL_SUNSTONE_FILES=( SUNSTONE_PUBLIC_CSS_FILES:$SUNSTONE_LOCATION/public/css SUNSTONE_PUBLIC_CSS_VENDOR_FILES:$SUNSTONE_LOCATION/public/css/vendor SUNSTONE_PUBLIC_IMAGES_FILES:$SUNSTONE_LOCATION/public/images - SUNSTONE_RUBY_LIB_FILES:$LIB_LOCATION/ruby - RUBY_OPENNEBULA_LIB_FILES:$LIB_LOCATION/ruby/OpenNebula ) INSTALL_ETC_FILES=( @@ -818,7 +821,7 @@ do_file() { if [ "$CLIENT" = "yes" ]; then INSTALL_SET=${INSTALL_CLIENT_FILES[@]} elif [ "$SUNSTONE" = "yes" ]; then - INSTALL_SET=${INSTALL_SUNSTONE_FILES[@]} + INSTALL_SET="${INSTALL_SUNSTONE_RUBY_FILES[@]} ${INSTALL_SUNSTONE_FILES[@]}" else INSTALL_SET="${INSTALL_FILES[@]} ${INSTALL_SUNSTONE_FILES[@]}" fi 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/OpenNebulaJSON.rb b/src/sunstone/models/OpenNebulaJSON.rb index 51e2478221..709f553a48 100644 --- a/src/sunstone/models/OpenNebulaJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON.rb @@ -14,7 +14,7 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -ONE_LOCATION = ENV["ONE_LOCATION"] +ONE_LOCATION = ENV["ONE_LOCATION"] if !ONE_LOCATION if !ONE_LOCATION RUBY_LIB_LOCATION = "/usr/lib/one/ruby" 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 7df4e976b7..c0b84e342b 100644 --- a/src/sunstone/public/js/one-ui_views.js +++ b/src/sunstone/public/js/one-ui_views.js @@ -59,14 +59,14 @@ $(document).ready(function() { confirmButtonListener(); //listen to buttons that require confirmation confirmWithSelectListener(); //listen to buttons requiring a selector actionButtonListener(); //listens to all simple actions (not creates) - + hostInfoListener(); vMachineInfoListener(); vNetworkInfoListener(); imageInfoListener(); - - + + setupImageAttributesDialogs(); //setups the add/update/remove attr dialogs //Jquery-ui eye-candy @@ -75,7 +75,7 @@ $(document).ready(function() { emptyDashboard(); preloadTables(); setupAutoRefresh(); - + tableCheckboxesListener(dataTable_hosts); tableCheckboxesListener(dataTable_vMachines); tableCheckboxesListener(dataTable_vNetworks); @@ -504,7 +504,7 @@ function confirmWithSelectListener(){ }); $('div#confirm_with_select_dialog button').button(); - + $( '.confirm_with_select_button').live("click",function(){ val=$(this).val(); tip=""; @@ -2220,7 +2220,7 @@ function updateSingleElement(element,data_table,tag){ position = data_table.fnGetPosition(tr); data_table.fnUpdate(element,position,0); $('input',data_table).trigger("change"); - + } function tableCheckboxesListener(dataTable){ @@ -2339,7 +2339,7 @@ function hostElementArray(host_json){ //Adds a listener to show the extended info when clicking on a row function hostInfoListener(){ $('#tbodyhosts tr').live("click",function(e){ - + //do nothing if we are clicking a checkbox! if ($(e.target).is('input')) {return true;} @@ -2360,13 +2360,17 @@ function hostInfoListener(){ //~ } function vMachineElementArray(vm_json){ - vm = vm_json.VM; + var vm = vm_json.VM; + var state = OpenNebula.Helper.resource_state("vm",vm.STATE); + if (state == "ACTIVE") { + state = OpenNebula.Helper.resource_state("vm_lcm",vm.LCM_STATE); + } return [ '', vm.ID, vm.USERNAME ? vm.USERNAME : getUserName(vm.UID), vm.NAME, - OpenNebula.Helper.resource_state("vm",vm.STATE), + state, vm.CPU, humanize_size(vm.MEMORY), vm.HISTORY ? vm.HISTORY.HOSTNAME : "--", @@ -2407,7 +2411,7 @@ function vNetworkElementArray(vn_json){ } //Adds a listener to show the extended info when clicking on a row function vNetworkInfoListener(){ - + $('#tbodyvnetworks tr').live("click", function(e){ if ($(e.target).is('input')) {return true;} aData = dataTable_vNetworks.fnGetData(this); @@ -2443,7 +2447,7 @@ function imageElementArray(image_json){ } function imageInfoListener(target){ - + $('#tbodyimages tr').live("click",function(e){ if ($(e.target).is('input')) {return true;} aData = dataTable_images.fnGetData(this); @@ -2781,7 +2785,6 @@ function addVNetworkElement(request,vn_json){ addElement(element,dataTable_vNetworks); vnetworks_select += ""; $('div.vm_section#networks select#NETWORK').html(vnetworks_select); - } function updateVNetworksView(request, network_list){ @@ -3045,7 +3048,7 @@ function updateVMInfo(request,vm){ \