From 98b1286e28dfab7441463b3d948a8e11e750f373 Mon Sep 17 00:00:00 2001 From: Vlastimil Holer Date: Mon, 6 Nov 2017 18:23:14 +0100 Subject: [PATCH 01/31] Bump to version 5.4.4 (#562) --- include/Nebula.h | 2 +- share/onegate/onegate | 2 +- share/rubygems/generate | 2 +- src/cloud/common/CloudClient.rb | 2 +- src/im_mad/remotes/VERSION | 2 +- src/oca/java/src/org/opennebula/client/OneSystem.java | 2 +- src/oca/ruby/opennebula.rb | 2 +- src/sunstone/views/index.erb | 2 +- src/sunstone/views/login.erb | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/Nebula.h b/include/Nebula.h index 46101d7625..20b2dad949 100644 --- a/include/Nebula.h +++ b/include/Nebula.h @@ -357,7 +357,7 @@ public: */ static string code_version() { - return "5.4.3"; // bump version + return "5.4.4"; // bump version } /** diff --git a/share/onegate/onegate b/share/onegate/onegate index 31f7587313..db5cb25f50 100755 --- a/share/onegate/onegate +++ b/share/onegate/onegate @@ -13,7 +13,7 @@ require 'pp' module CloudClient # OpenNebula version - VERSION = '5.4.3' + VERSION = '5.4.4' # ######################################################################### # Default location for the authentication file diff --git a/share/rubygems/generate b/share/rubygems/generate index 33f9cb468b..1cdb5fa337 100755 --- a/share/rubygems/generate +++ b/share/rubygems/generate @@ -19,7 +19,7 @@ require 'fileutils' require 'tmpdir' -VERSION = "5.4.3" +VERSION = "5.4.4" def version v = VERSION diff --git a/src/cloud/common/CloudClient.rb b/src/cloud/common/CloudClient.rb index 367495776b..565e1cd340 100644 --- a/src/cloud/common/CloudClient.rb +++ b/src/cloud/common/CloudClient.rb @@ -50,7 +50,7 @@ end module CloudClient # OpenNebula version - VERSION = '5.4.3' + VERSION = '5.4.4' # ######################################################################### # Default location for the authentication file diff --git a/src/im_mad/remotes/VERSION b/src/im_mad/remotes/VERSION index b5db1702f3..3238344b3b 100644 --- a/src/im_mad/remotes/VERSION +++ b/src/im_mad/remotes/VERSION @@ -1 +1 @@ -5.4.3 \ No newline at end of file +5.4.4 \ No newline at end of file diff --git a/src/oca/java/src/org/opennebula/client/OneSystem.java b/src/oca/java/src/org/opennebula/client/OneSystem.java index 683603c548..767c39c8f4 100644 --- a/src/oca/java/src/org/opennebula/client/OneSystem.java +++ b/src/oca/java/src/org/opennebula/client/OneSystem.java @@ -32,7 +32,7 @@ public class OneSystem private static final String GROUP_QUOTA_INFO = "groupquota.info"; private static final String GROUP_QUOTA_UPDATE = "groupquota.update"; - public static final String VERSION = "5.4.3"; + public static final String VERSION = "5.4.4"; public OneSystem(Client client) { diff --git a/src/oca/ruby/opennebula.rb b/src/oca/ruby/opennebula.rb index 69a3414aaf..3fa30b60b7 100644 --- a/src/oca/ruby/opennebula.rb +++ b/src/oca/ruby/opennebula.rb @@ -69,5 +69,5 @@ require 'opennebula/vm_group_pool' module OpenNebula # OpenNebula version - VERSION = '5.4.3' + VERSION = '5.4.4' end diff --git a/src/sunstone/views/index.erb b/src/sunstone/views/index.erb index 41c260a1d4..a0b6da8574 100644 --- a/src/sunstone/views/index.erb +++ b/src/sunstone/views/index.erb @@ -81,7 +81,7 @@ diff --git a/src/sunstone/views/login.erb b/src/sunstone/views/login.erb index bde5d91b1b..f454af7ca7 100644 --- a/src/sunstone/views/login.erb +++ b/src/sunstone/views/login.erb @@ -28,7 +28,7 @@ <% end %>
-
diff --git a/src/sunstone/public/app/utils/user-inputs.js b/src/sunstone/public/app/utils/user-inputs.js index 65ea06ed32..01964ad823 100644 --- a/src/sunstone/public/app/utils/user-inputs.js +++ b/src/sunstone/public/app/utils/user-inputs.js @@ -706,6 +706,9 @@ define(function(require) { break; case "range": case "range-float": + if(attr.max_value != ""){ + attr.max_value = attr.max; + } input = RangeSlider.html(attr); break; From d0e1af693bf60769545c3d8d7dc20ca7e8329e10 Mon Sep 17 00:00:00 2001 From: Abel Coronado Date: Fri, 17 Nov 2017 15:47:07 +0100 Subject: [PATCH 12/31] Better default for PAGE SIZE (DEFAULT_POOL_PAGE_SIZE = 200) (cherry picked from commit 56341375b62cf1cd5d9dc1cd1e7194ca6a6c0e9b) --- src/oca/ruby/opennebula/client.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/oca/ruby/opennebula/client.rb b/src/oca/ruby/opennebula/client.rb index 3434cd1de7..47df9cb9a5 100644 --- a/src/oca/ruby/opennebula/client.rb +++ b/src/oca/ruby/opennebula/client.rb @@ -69,7 +69,7 @@ module OpenNebula end end - DEFAULT_POOL_PAGE_SIZE = 2000 + DEFAULT_POOL_PAGE_SIZE = 200 if size=ENV['ONE_POOL_PAGE_SIZE'] if size.strip.match(/^\d+$/) && size.to_i >= 2 From 3b5a77ec94aeb55a1c93a7dd3af3d20634009fb1 Mon Sep 17 00:00:00 2001 From: Mariano Guezuraga Date: Fri, 17 Nov 2017 15:49:11 +0100 Subject: [PATCH 13/31] Oned: Fix typo in help (#553) (cherry picked from commit fa727a7e13549d83743be4332c3a221761c62556) --- src/nebula/oned.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nebula/oned.cc b/src/nebula/oned.cc index 705fe72591..be84b7d2ec 100644 --- a/src/nebula/oned.cc +++ b/src/nebula/oned.cc @@ -53,7 +53,7 @@ static void print_help() << " -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"; + << " -i, --init-db\tinitialize the database and exit\n"; } /* ------------------------------------------------------------------------- */ From 46bf8d174845c3bed8b04712f051f9f92aca5df5 Mon Sep 17 00:00:00 2001 From: juanmont Date: Fri, 17 Nov 2017 15:52:23 +0100 Subject: [PATCH 14/31] B #5550: increased timeout for oneshowback and decreased for zones (cherry picked from commit 93b8c6d52dfedb9f5cea05d3aa3a3435526d5ce7) --- src/cli/one_helper.rb | 4 ++-- src/cli/one_helper/onezone_helper.rb | 3 ++- src/cli/oneshowback | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cli/one_helper.rb b/src/cli/one_helper.rb index 138bfc3bd0..3c9dce4fd6 100644 --- a/src/cli/one_helper.rb +++ b/src/cli/one_helper.rb @@ -417,8 +417,8 @@ EOT else sync = true end - - @@client=OpenNebula::Client.new(secret, endpoint, :sync => sync) + options[:sync] = sync + @@client=OpenNebula::Client.new(secret, endpoint, options) end end diff --git a/src/cli/one_helper/onezone_helper.rb b/src/cli/one_helper/onezone_helper.rb index 8a1f0212ab..aef3c644c9 100644 --- a/src/cli/one_helper/onezone_helper.rb +++ b/src/cli/one_helper/onezone_helper.rb @@ -124,7 +124,8 @@ class OneZoneHelper < OpenNebulaHelper::OneHelper next if endpoint.nil? - client = OpenNebula::Client.new(nil, endpoint) + options[:timeout] = 5 #5 sec + client = OpenNebula::Client.new(nil, endpoint, options) xml_doc = client.call("zone.raftstatus") diff --git a/src/cli/oneshowback b/src/cli/oneshowback index faae345c40..425934fe28 100755 --- a/src/cli/oneshowback +++ b/src/cli/oneshowback @@ -43,6 +43,7 @@ cmd = CommandParser::CmdParser.new(ARGV) do helper=OpenNebulaHelper::OneHelper.new before_proc do + options[:timeout] = 60 #60 sec helper.set_client(options) end From 889086d1413ac02d55051aeb1d79feba41a332a1 Mon Sep 17 00:00:00 2001 From: Abel Coronado Date: Fri, 17 Nov 2017 15:54:30 +0100 Subject: [PATCH 15/31] B #5558: No way for disable select auth type on settings-tab (cherry picked from commit 9b7919eb5ae818a6f6eb74e6128829a975f5853a) --- src/sunstone/public/app/tabs/users-tab/panels/auth/html.hbs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sunstone/public/app/tabs/users-tab/panels/auth/html.hbs b/src/sunstone/public/app/tabs/users-tab/panels/auth/html.hbs index 364f3866e4..790391a6a4 100644 --- a/src/sunstone/public/app/tabs/users-tab/panels/auth/html.hbs +++ b/src/sunstone/public/app/tabs/users-tab/panels/auth/html.hbs @@ -29,7 +29,9 @@ {{tr "Authentication driver"}} {{{userCreationHTML}}} {{element.AUTH_DRIVER}} - + {{#isTabActionEnabled tabId "User.change_authentication"}} + + {{/isTabActionEnabled}} {{tr "Password"}} From ca99f7076095b663cd4249f9267aedf538dfdcf9 Mon Sep 17 00:00:00 2001 From: Diego del Corral Date: Fri, 17 Nov 2017 21:20:54 +0100 Subject: [PATCH 16/31] Added error message for change-body function + trailling spaces fixed (cherry picked from commit 253738d6e88c11b04f13d55044594cb95b9d6ac8) --- src/oca/ruby/opennebula/error.rb | 2 +- src/onedb/onedb | 2 +- src/onedb/onedb_live.rb | 24 +++++++++++-------- .../app/tabs/users-tab/panels/auth-common.js | 2 +- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/oca/ruby/opennebula/error.rb b/src/oca/ruby/opennebula/error.rb index 41ac9e927a..e287b75950 100644 --- a/src/oca/ruby/opennebula/error.rb +++ b/src/oca/ruby/opennebula/error.rb @@ -31,7 +31,7 @@ module OpenNebula EALLOCATE = 0x4000 ENOTDEFINED = 0xF001 EXML_RPC_CALL = 0xF002 - + attr_reader :message, :errno # +message+ Description of the error diff --git a/src/onedb/onedb b/src/onedb/onedb index 16ddf60db7..462ab409c5 100755 --- a/src/onedb/onedb +++ b/src/onedb/onedb @@ -570,7 +570,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do * --id: vm id, example: 156 * --seq: sequence number of the record, example: 0 - The new value for this elemente is set in the third parameter. + The new value for this elemente is set in the third parameter. Change the the hostname of first record: diff --git a/src/onedb/onedb_live.rb b/src/onedb/onedb_live.rb index bd1f97bc42..7530b560ea 100644 --- a/src/onedb/onedb_live.rb +++ b/src/onedb/onedb_live.rb @@ -82,22 +82,27 @@ class OneDBLive def select(table, where) sql = "SELECT * FROM #{table} WHERE #{where}" res = db_query(sql, "Error querying database") - + element = OpenNebula::XMLElement.new( OpenNebula::XMLElement.build_xml(res, '/SQL_COMMAND')) - + hash = element.to_hash - - row = hash['SQL_COMMAND']['RESULT']['ROW'] rescue nil + row = hash['SQL_COMMAND']['RESULT']['ROW'] rescue nil + + if !row + raise "Empty SQL query result: " + end + [row].flatten.compact end def db_query(sql, error_msg) rc = system_db.sql_query_command(sql) + if OpenNebula.is_error?(rc) raise "#{error_msg}: #{rc.message}" end - + rc end @@ -370,13 +375,13 @@ class OneDBLive def change_body(object, xpath, value, options = {}) table, object, federate = get_pool_config(object) - if !value && !options[:delete] raise "A value or --delete should specified" end - - object.info_all - + + rc = object.info_all + raise rc.message if OpenNebula.is_error?(rc) + object.each do |o| if options[:id] next unless o.id.to_s.strip == options[:id].to_s @@ -385,7 +390,6 @@ class OneDBLive elsif options[:expr] next unless check_expr(o, options[:expr]) end - # Get body from the database begin db_data = select(table, "oid = #{o.id}") diff --git a/src/sunstone/public/app/tabs/users-tab/panels/auth-common.js b/src/sunstone/public/app/tabs/users-tab/panels/auth-common.js index f3dbb2686e..d0de116782 100644 --- a/src/sunstone/public/app/tabs/users-tab/panels/auth-common.js +++ b/src/sunstone/public/app/tabs/users-tab/panels/auth-common.js @@ -30,7 +30,7 @@ define(function(require) { /* TEMPLATES */ - + var TemplateTable = require('utils/panel/template-table'); /* From 4992c02ad8d5aea8c080ab21411c24284a4c9aa7 Mon Sep 17 00:00:00 2001 From: juanmont Date: Tue, 21 Nov 2017 11:02:48 +0100 Subject: [PATCH 17/31] B #1493: Options never will be empty when you create a resource (cherry picked from commit 87a5fb45a4d00ed30bcc2600c31406b1b6d546c2) --- src/cli/onegroup | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/cli/onegroup b/src/cli/onegroup index 38f073e051..9444d3e8bc 100755 --- a/src/cli/onegroup +++ b/src/cli/onegroup @@ -87,13 +87,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do command :create, create_desc, [:group_name, nil], :options => OpenNebulaHelper::GROUP_OPTIONS do - - if !args[0] && options.empty? - STDERR.puts "Please use either a group name or command arguments."<< - " Run onegroup create -h for more information" - next -1 - end - if options && options[:admin_user] if !options[:admin_password] STDERR.puts "Admin user needs password" @@ -108,11 +101,15 @@ cmd=CommandParser::CmdParser.new(ARGV) do options[:group_admin] = admin_user end - if !options.empty? - helper.create_complete_resource(options) - elsif args[0] + if args[0] options[:name] = args[0] helper.create_complete_resource(options) + elsif options[:name] + helper.create_complete_resource(options) + else + STDERR.puts "Please use either a group name or command arguments."<< + " Run onegroup create -h for more information" + next -1 end end From c76877ab31cb227acd9c53905980092110b28cc6 Mon Sep 17 00:00:00 2001 From: Diego del Corral Date: Wed, 22 Nov 2017 15:45:04 +0100 Subject: [PATCH 18/31] B #1506 change-body command, show connection errors and missing id's (cherry picked from commit e128f3d00f1ad0268d154ae0b854bad6039af4c0) --- src/onedb/onedb_live.rb | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/onedb/onedb_live.rb b/src/onedb/onedb_live.rb index 7530b560ea..a1d4610c13 100644 --- a/src/onedb/onedb_live.rb +++ b/src/onedb/onedb_live.rb @@ -82,27 +82,27 @@ class OneDBLive def select(table, where) sql = "SELECT * FROM #{table} WHERE #{where}" res = db_query(sql, "Error querying database") - + element = OpenNebula::XMLElement.new( OpenNebula::XMLElement.build_xml(res, '/SQL_COMMAND')) - + hash = element.to_hash row = hash['SQL_COMMAND']['RESULT']['ROW'] rescue nil - + if !row raise "Empty SQL query result: " end - + [row].flatten.compact end def db_query(sql, error_msg) rc = system_db.sql_query_command(sql) - + if OpenNebula.is_error?(rc) raise "#{error_msg}: #{rc.message}" end - + rc end @@ -375,16 +375,19 @@ class OneDBLive def change_body(object, xpath, value, options = {}) table, object, federate = get_pool_config(object) + found_id = false + if !value && !options[:delete] raise "A value or --delete should specified" end - + rc = object.info_all raise rc.message if OpenNebula.is_error?(rc) - + object.each do |o| if options[:id] - next unless o.id.to_s.strip == options[:id].to_s + found_id = o.id.to_s.strip == options[:id].to_s + next unless found_id elsif options[:xpath] next unless o[options[:xpath]] elsif options[:expr] @@ -427,7 +430,9 @@ class OneDBLive next end end + break if found_id end + raise "Object with id #{options[:id]} not found" if options[:id] && !found_id end def editor_body(body_xml) From 0bc1f03ded7c1de5966875130f6b246470983af7 Mon Sep 17 00:00:00 2001 From: Vlastimil Holer Date: Wed, 22 Nov 2017 15:54:28 +0100 Subject: [PATCH 19/31] B #1481: Better estimate image sizes (#1502) (cherry picked from commit 212de23fab8195102ee14d82c74d2209cdc6c00a) --- src/datastore_mad/remotes/common/stat | 12 +- src/datastore_mad/remotes/downloader.sh | 26 ++- src/datastore_mad/remotes/libfs.sh | 238 ++++++++++++++++++++---- src/tm_mad/fs_lvm/clone | 2 +- 4 files changed, 229 insertions(+), 49 deletions(-) diff --git a/src/datastore_mad/remotes/common/stat b/src/datastore_mad/remotes/common/stat index 07adcaca51..af41fb3ed7 100755 --- a/src/datastore_mad/remotes/common/stat +++ b/src/datastore_mad/remotes/common/stat @@ -45,15 +45,21 @@ unset i XPATH_ELEMENTS while IFS= read -r -d '' element; do XPATH_ELEMENTS[i++]="$element" -done < <($XPATH /DS_DRIVER_ACTION_DATA/IMAGE/PATH) +done < <($XPATH /DS_DRIVER_ACTION_DATA/IMAGE/PATH \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/NO_DECOMPRESS \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/LIMIT_TRANSFER_BW) -SRC="${XPATH_ELEMENTS[0]}" +unset i + +SRC="${XPATH_ELEMENTS[i++]}" +NO_DECOMPRESS="${XPATH_ELEMENTS[i++]}" +LIMIT_TRANSFER_BW="${XPATH_ELEMENTS[i++]}" # ------------------------------------------------------------------------------ # Compute the size # ------------------------------------------------------------------------------ -SIZE=`fs_size $SRC` +SIZE=`fs_size "${SRC}" "${NO_DECOMPRESS}" "${LIMIT_TRANSFER_BW}"` if [ "$SIZE" = "0" ]; then log_error "Cannot determine size for $SRC" diff --git a/src/datastore_mad/remotes/downloader.sh b/src/datastore_mad/remotes/downloader.sh index 748da6bb33..1f85dda909 100755 --- a/src/datastore_mad/remotes/downloader.sh +++ b/src/datastore_mad/remotes/downloader.sh @@ -57,7 +57,10 @@ function get_decompressor echo "gunzip -c -" ;; "application/x-bzip2") - echo "bunzip2 -c -" + echo "bunzip2 -qc -" + ;; + "application/x-xz") + echo "unxz -c -" ;; *) echo "cat" @@ -221,7 +224,7 @@ function get_rbd_cmd echo "ssh '$(esc_sq "$DST_HOST")' \"$RBD export '$(esc_sq "$SOURCE")' -\"" } -TEMP=`getopt -o m:s:l:n -l md5:,sha1:,limit:,nodecomp -- "$@"` +TEMP=`getopt -o m:s:l:c:n -l md5:,sha1:,limit:,max-size:,nodecomp -- "$@"` if [ $? != 0 ] ; then echo "Arguments error" @@ -250,6 +253,10 @@ while true; do export LIMIT_RATE="$2" shift 2 ;; + -c|--max-size) + export MAX_SIZE="$2" + shift 2 + ;; --) shift break @@ -324,7 +331,19 @@ esac file_type=$(get_type "$command") decompressor=$(get_decompressor "$file_type") -eval "$command" | tee >( hasher $HASH_TYPE) | decompress "$decompressor" "$TO" +if [ -z "${MAX_SIZE}" ]; then + eval "$command" | \ + tee >( hasher $HASH_TYPE) | \ + decompress "$decompressor" "$TO" +else + # ignore broken pipe + trap '' PIPE + + eval "$command" | \ + tee >( hasher $HASH_TYPE) 2>/dev/null | \ + decompress "$decompressor" "$TO" 2>/dev/null | \ + head -c "${MAX_SIZE}" +fi if [ "$?" != "0" -o "$PIPESTATUS" != "0" ]; then echo "Error copying" >&2 @@ -344,4 +363,3 @@ fi if [ "$TO" != "-" ]; then unarchive "$TO" fi - diff --git a/src/datastore_mad/remotes/libfs.sh b/src/datastore_mad/remotes/libfs.sh index b477945584..16ada366ee 100644 --- a/src/datastore_mad/remotes/libfs.sh +++ b/src/datastore_mad/remotes/libfs.sh @@ -60,6 +60,14 @@ function image_format { echo "$($QEMU_IMG info $1 2>/dev/null | grep -Po '(?<=file format: )\w+')" } +#------------------------------------------------------------------------------- +# Get image virtual size using qemu-img +# @return string representation of the format, empty if error +#------------------------------------------------------------------------------- +function image_vsize { + echo "$($QEMU_IMG info "${1}" 2>/dev/null | sed -n 's/.*(\([0-9]*\) bytes).*/\1/p')" +} + #------------------------------------------------------------------------------- # Generates an unique image hash. Requires ID to be set # @return hash for the image (empty if error) @@ -118,7 +126,7 @@ function set_downloader_args { HASHES="$HASHES --sha1 $2" fi - if [ "$3" = "yes" -o "$3" = "Yes" -o "$3" = "YES" ]; then + if [ "x$(echo "$3" | tr A-Z a-z)" = "xyes" ]; then HASHES="$HASHES --nodecomp" fi @@ -149,6 +157,17 @@ function file_size { $STAT_CMD "$*" } + +#------------------------------------------------------------------------------ +# Gets the MIME type of a file +# @param $1 - Path to the image +# @return MIME type +#------------------------------------------------------------------------------ + +function file_type { + file -b --mime-type "${1}" | tr A-Z a-z +} + #------------------------------------------------------------------------------ # Gets the size in bytes of a gzipped file # @param $1 - Path to the image @@ -159,58 +178,195 @@ function gzip_file_size { gzip -l "$1" | tail -n 1 | awk '{print $2}' } +#------------------------------------------------------------------------------ +# Gets the size in bytes of a xzipped file +# @param $1 - Path to the image +# @return size of the image in bytes +#------------------------------------------------------------------------------ + +function xz_file_size { + xz -l --robot "$1" | tail -n 1 | awk '{print $5}' +} + +#------------------------------------------------------------------------------ +# Gets the size in bytes of a bzipped file +# @param $1 - Path to the image +# @return size of the image in bytes +#------------------------------------------------------------------------------ + +function bzip_file_size { + bunzip2 -c "${1}" | wc -c +} + #------------------------------------------------------------------------------- # Computes the size of an image # @param $1 - Path to the image +# @param $2 - NO_DECOMPRESS +# @param $3 - BW LIMIT # @return size of the image in Mb #------------------------------------------------------------------------------- function fs_size { + SRC=$1 + NO_DECOMPRESS=$(echo "$2" | tr A-Z a-z) + LIMIT_TRANSFER_BW=$3 - case $1 in - http://*|https://*) - HEADERS=`curl -LIk --max-time 60 "${1}" 2>&1` + DOWNLOADER_ARGS=`set_downloader_args '' '' "${NO_DECOMPRESS}" "${LIMIT_TRANSFER_BW}"` - if echo "$HEADERS" | grep -i -q "OpenNebula-AppMarket-Size"; then - # An AppMarket/Marketplace URL - SIZE=$(echo "$HEADERS" | grep -i "^OpenNebula-AppMarket-Size:" | tail -n1 | cut -d: -f2) + if [ -z "${UTILS_PATH}" ] && [ -n "${DRIVER_PATH}" ]; then + UTILS_PATH="${DRIVER_PATH}/../../datastore" + fi + + if ! [ -d "${UTILS_PATH}" ]; then + log_error "Failed to detect downloader.sh location" + exit 1 + fi + + error=1 + + # limit only on local or remote http(s) + if [ -d "${SRC}" ]; then + SIZE=`du -sb "${SRC}" | cut -f1` + error=$? + elif [ -f "${SRC}" ] || (echo "${SRC}" | grep -qe '^https\?://'); then + IMAGE=$(mktemp) + + # try first download only a part of image + $UTILS_PATH/downloader.sh ${DOWNLOADER_ARGS} -c 65536 "${SRC}" - >"${IMAGE}" 2>/dev/null + error=$? + if [ $error -ne 0 ]; then + # better fail here ... + log_error "Failed to download image head" + echo '0' + return + fi + + TYPE=$(image_format "${IMAGE}") + + # raw images requires special handling, as there is no image header + # with size available and we can't predict image virtual size just + # from a part of the file + if [ "${TYPE}" = 'raw' ]; then + $UTILS_PATH/downloader.sh ${DOWNLOADER_ARGS} --nodecomp -c 65536 "${SRC}" - >"${IMAGE}" 2>/dev/null error=$? - else - # Not an AppMarket/Marketplace URL - SIZE=$(echo "$HEADERS" | grep -i "^Content-Length:" | tail -n1 | cut -d: -f2 | tr -d "\r") - error=$? - - # Try to download the image head and inspect via qemu-img - IMAGE=$(mktemp) - curl -Lk --max-time 60 "${1}" 2>/dev/null | head -c 65536 >${IMAGE} - QSIZE=$($QEMU_IMG info "${IMAGE}" | sed -n 's/.*(\([0-9]*\) bytes).*/\1/p') - rm "${IMAGE}" 2>/dev/null - - if [ "${QSIZE}" -gt "${SIZE}" ]; then - SIZE="${QSIZE}" + if [ $error -ne 0 ]; then + # better fail here ... + log_error "Failed to download image head" + echo '0' + return + fi + + ORIG_TYPE=$(file_type "${IMAGE}") + + # if NO_DECOMPRESS=yes is configured on the datastore, + # treat the downloaded data as image as is + if [ "${NO_DECOMPRESS}" = 'yes' ]; then + ORIG_TYPE='application/octet-stream' + fi + + if [ -f "${SRC}" ] ; then + # for local raw images: + # - compressed: use decompressor on local file + # - uncompressed: get file size + case ${ORIG_TYPE} in + "application/x-gzip"|"application/gzip") + SIZE=$(gzip_file_size "${SRC}") + error=$? + ;; + "application/x-xz") + SIZE=$(xz_file_size "${SRC}") + error=$? + ;; + "application/x-bzip2") + SIZE=$(bzip_file_size "${SRC}") + error=$? + ;; + *) + SIZE=$(image_vsize "${SRC}") + error=$? + ;; + esac + else + # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + # code which allows downloading is experimental for future use, + # longer downloads may result in image import failure, as + # the datastore stat operation is synchronous with import call + # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + ALLOW_DOWNLOADS='no' + + # for remote raw images + # - compressed: complete download and use decompressor + # - uncompressed: get size from HTTP headers or complete download + case ${ORIG_TYPE} in + "application/x-gzip"|"application/gzip") + if [ "${ALLOW_DOWNLOADS}" = 'yes' ]; then + $UTILS_PATH/downloader.sh ${DOWNLOADER_ARGS} --nodecomp "${SRC}" - >"${IMAGE}" 2>/dev/null + error=$? + if [ $error -eq 0 ]; then + SIZE=$(gzip_file_size "${IMAGE}") + error=$? + fi + else + log_error 'Unsupported remote image format' + error=1 + fi + ;; + "application/x-xz") + if [ "${ALLOW_DOWNLOADS}" = 'yes' ]; then + $UTILS_PATH/downloader.sh ${DOWNLOADER_ARGS} --nodecomp "${SRC}" - >"${IMAGE}" 2>/dev/null + error=$? + if [ $error -eq 0 ]; then + SIZE=$(xz_file_size "${IMAGE}") + error=$? + fi + else + log_error 'Unsupported remote image format' + error=1 + fi + ;; + "application/x-bzip2") + if [ "${ALLOW_DOWNLOADS}" = 'yes' ]; then + $UTILS_PATH/downloader.sh ${DOWNLOADER_ARGS} "${SRC}" - >"${IMAGE}" 2>/dev/null + error=$? + if [ $error -eq 0 ]; then + SIZE=$(image_vsize "${IMAGE}") + error=$? + fi + else + log_error 'Unsupported remote image format' + error=1 + fi + ;; + *) + HEADERS=`curl -LIk --max-time 60 "${SRC}" 2>&1` + error=$? + SIZE=$(echo "$HEADERS" | grep -i "^Content-Length:" | tail -n1 | cut -d: -f2 | tr -d "\r") + + if [ -z "${SIZE}" ]; then + if [ "${ALLOW_DOWNLOADS}" = 'yes' ]; then + $UTILS_PATH/downloader.sh ${DOWNLOADER_ARGS} "${SRC}" - >"${IMAGE}" 2>/dev/null + error=$? + if [ $error -eq 0 ]; then + SIZE=$(image_vsize "${IMAGE}") + error=$? + fi + else + log_error 'Unsupported remote image format' + error=1 + fi + fi + ;; + esac fi - fi - ;; - *) - if [ -d "$1" ]; then - SIZE=`du -sb "$1" | cut -f1` - error=$? else - TYPE=$(cat "$1" | head -n 1024 | file -b - | tr A-Z a-z) - case "$TYPE" in - *gzip*) - SIZE=$(gzip_file_size "$1") - ;; - *qcow*) - SIZE=$($QEMU_IMG info "$1" | sed -n 's/.*(\([0-9]*\) bytes).*/\1/p') - ;; - *) - SIZE=$(file_size "$1") - ;; - esac - error=$? + SIZE=$(image_vsize "${IMAGE}") fi - ;; - esac + + if [ -f "${IMAGE}" ]; then + unlink "${IMAGE}" 2>/dev/null + fi + fi + + ##### SIZE=$(echo $SIZE | tr -d "\r") diff --git a/src/tm_mad/fs_lvm/clone b/src/tm_mad/fs_lvm/clone index a891b11a4b..a15d667db7 100755 --- a/src/tm_mad/fs_lvm/clone +++ b/src/tm_mad/fs_lvm/clone @@ -76,7 +76,7 @@ SIZE="${XPATH_ELEMENTS[j++]}" ORIGINAL_SIZE="${XPATH_ELEMENTS[j++]}" TM_MAD="${XPATH_ELEMENTS[j++]}" -FILE_SIZE=`fs_size $SRC_PATH` +FILE_SIZE=`fs_size "${SRC_PATH}" YES` if [ $FILE_SIZE -gt $SIZE ]; then SIZE="$FILE_SIZE" From 9c25da6dbff5bd5e5ea32a23700ac10f88622b60 Mon Sep 17 00:00:00 2001 From: Vlastimil Holer Date: Thu, 23 Nov 2017 15:36:04 +0100 Subject: [PATCH 20/31] B #1481: Avoid downloading complete file on partial download (#1513) (cherry picked from commit 32fcc5ecca5bc81c4b7e5423920af4a0d40e07b5) --- src/datastore_mad/remotes/downloader.sh | 50 ++++++++++++++++++++----- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/src/datastore_mad/remotes/downloader.sh b/src/datastore_mad/remotes/downloader.sh index 1f85dda909..285b5762ff 100755 --- a/src/datastore_mad/remotes/downloader.sh +++ b/src/datastore_mad/remotes/downloader.sh @@ -270,8 +270,13 @@ done FROM="$1" TO="$2" -# File used by the hasher function to store the resulting hash -export HASH_FILE="/tmp/downloader.hash.$$" +if [ -n "${HASH_TYPE}" -a -n "${MAX_SIZE}" ]; then + echo "Hash check not supported for partial downloads" >&2 + exit -1 +else + # File used by the hasher function to store the resulting hash + export HASH_FILE="/tmp/downloader.hash.$$" +fi GLOBAL_CURL_ARGS="--fail -sS -k -L" @@ -335,19 +340,44 @@ if [ -z "${MAX_SIZE}" ]; then eval "$command" | \ tee >( hasher $HASH_TYPE) | \ decompress "$decompressor" "$TO" -else - # ignore broken pipe - trap '' PIPE + if [ "$?" != "0" -o "$PIPESTATUS" != "0" ]; then + echo "Error copying" >&2 + exit -1 + fi +else + # Order of the 'head' command is here on purpose: + # 1. We want to download more bytes than needed to get a requested + # number of bytes on the output. Decompressor may need more + # data to decompress the stream. + # 2. Decompressor command is also misused to detect SIGPIPE error. eval "$command" | \ - tee >( hasher $HASH_TYPE) 2>/dev/null | \ decompress "$decompressor" "$TO" 2>/dev/null | \ head -c "${MAX_SIZE}" -fi -if [ "$?" != "0" -o "$PIPESTATUS" != "0" ]; then - echo "Error copying" >&2 - exit -1 + # Following table shows exit codes of each command + # in the pipe for various scenarios: + # + # ---------------------------------------------------- + # | $COMMAND | TYPE | PIPESTATUS | BEHAVIOUR + # ---------------------------------------------------- + # | cat | partial | 141 141 0 | OK + # | cat | full | 0 0 0 | OK + # | cat | error | 1 0 0 | fail + # | curl | partial | 23 141 0 | OK + # | curl | full | 0 0 0 | OK + # | curl | error | 22 0 0 | fail + # | ssh | partial | 255 141 0 | OK + # | ssh | full | 0 0 0 | OK + # | ssh | error ssh | 255 0 0 | fail + # | ssh | error ssh cat | 1 0 0 | fail + if [ \( "${PIPESTATUS[0]}" != '0' -a "${PIPESTATUS[1]}" = '0' \) \ + -o \( "${PIPESTATUS[1]}" != '0' -a "${PIPESTATUS[1]}" != '141' \) \ + -o \( "${PIPESTATUS[2]}" != "0" \) ]; + then + echo "Error copying" >&2 + exit -1 + fi fi if [ -n "$HASH_TYPE" ]; then From 7179489a1cca636e12d59a3565d5a4270e656045 Mon Sep 17 00:00:00 2001 From: juanmont Date: Thu, 23 Nov 2017 15:47:59 +0100 Subject: [PATCH 21/31] Returned -1 if have been an error when parsing the xml * Returned -1 if have been an error when parsing the xml * Update VirtualMachine.cc (cherry picked from commit b3208c90045fa395ae0b63640d63ac1c66523252) --- src/vm/VirtualMachine.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index 870fb9b97a..97b81898cb 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -2019,7 +2019,12 @@ int VirtualMachine::from_xml(const string &xml_str) int rc = 0; // Initialize the internal XML object - update_from_str(xml_str); + rc = update_from_str(xml_str); + + if ( rc != 0 ) + { + return -1; + } // Get class base attributes rc += xpath(oid, "/VM/ID", -1); From e8a888c564a2451ecc6e2e078ed8a63ac8dfb7bf Mon Sep 17 00:00:00 2001 From: juanmont Date: Fri, 24 Nov 2017 11:44:56 +0100 Subject: [PATCH 22/31] B #1505: Removed delete nic (#1516) --- src/rm/RequestManagerVirtualRouter.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/rm/RequestManagerVirtualRouter.cc b/src/rm/RequestManagerVirtualRouter.cc index 435c037afa..e95ce711d1 100644 --- a/src/rm/RequestManagerVirtualRouter.cc +++ b/src/rm/RequestManagerVirtualRouter.cc @@ -293,13 +293,10 @@ void VirtualRouterAttachNic::request_execute( { failure_response(ACTION, att); - delete nic; return; } } - delete nic; - success_response(vrid, att); } From 773e90b40057a34b6a5ba240c59288c56415f8d7 Mon Sep 17 00:00:00 2001 From: Abel Coronado Date: Fri, 24 Nov 2017 12:10:51 +0100 Subject: [PATCH 23/31] F #1495: Minimized overhead | VMs caching * Minimized overhead in Sinatra * Caching all pools (cherry picked from commit 4827198ebb27e2f2b3eecee03505a8dc09dd1d77) --- src/sunstone/public/app/sunstone.js | 479 +++++++++--------- src/sunstone/public/app/tabs/dashboard-tab.js | 3 +- 2 files changed, 243 insertions(+), 239 deletions(-) diff --git a/src/sunstone/public/app/sunstone.js b/src/sunstone/public/app/sunstone.js index f0877366de..eb17c435bf 100644 --- a/src/sunstone/public/app/sunstone.js +++ b/src/sunstone/public/app/sunstone.js @@ -15,24 +15,24 @@ /* -------------------------------------------------------------------------- */ define(function(require) { - require('jquery'); + require("jquery"); //require('foundation.reveal'); //require('foundation.tab'); //require('foundation.dropdown'); - var Config = require('sunstone-config'); - var Locale = require('utils/locale'); - var Notifier = require('utils/notifier'); - var Menu = require('utils/menu'); - var Tips = require('utils/tips'); - var Navigo = require('Navigo'); + var Config = require("sunstone-config"); + var Locale = require("utils/locale"); + var Notifier = require("utils/notifier"); + var Menu = require("utils/menu"); + var Tips = require("utils/tips"); + var Navigo = require("Navigo"); var router; var TOP_INTERVAL = 10000; //ms - var CONFIRM_DIALOG_ID = require('utils/dialogs/confirm/dialogId'); - var CONFIRM_WITH_SELECT_DIALOG_ID = require('utils/dialogs/confirm-with-select/dialogId'); - var DASHBOARD_TAB_ID = require('tabs/dashboard-tab/tabId'); + var CONFIRM_DIALOG_ID = require("utils/dialogs/confirm/dialogId"); + var CONFIRM_WITH_SELECT_DIALOG_ID = require("utils/dialogs/confirm-with-select/dialogId"); + var DASHBOARD_TAB_ID = require("tabs/dashboard-tab/tabId"); var SunstoneCfg = { "actions" : {}, @@ -45,14 +45,14 @@ define(function(require) { _addActions(); $.each(Config.enabledTabs, function(i, tabName){ - var name = './tabs/' + tabName; + var name = "./tabs/" + tabName; var tabObj = require(name); var _tabId = tabObj.tabId; SunstoneCfg["tabs"][_tabId] = tabObj; var panels = tabObj.panels; if (panels) { - _addPanels(_tabId, panels) + _addPanels(_tabId, panels); } var panelsHooks = tabObj.panelsHooks; @@ -67,19 +67,19 @@ define(function(require) { var dialogs = tabObj.dialogs; if (dialogs) { - _addDialogs(dialogs) + _addDialogs(dialogs); } var formPanels = tabObj.formPanels; if (formPanels) { - _addFormPanels(_tabId, formPanels) + _addFormPanels(_tabId, formPanels); } }); - } + }; var _addActions = function() { $.each(Config.allTabs(), function(i, tabName){ - var name = './tabs/' + tabName; + var name = "./tabs/" + tabName; var tabObj = require(name); var actions = tabObj.actions; @@ -89,43 +89,43 @@ define(function(require) { }); } }); - } + }; var _addDialogs = function(dialogs) { $.each(dialogs, function(index, dialog) { - SunstoneCfg['dialogs'][dialog.DIALOG_ID] = dialog - }) + SunstoneCfg["dialogs"][dialog.DIALOG_ID] = dialog; + }); return false; - } + }; var _addPanelsHooks = function(tabId, hooks) { - SunstoneCfg["tabs"][tabId]['panelsHooks'] = hooks; + SunstoneCfg["tabs"][tabId]["panelsHooks"] = hooks; return false; - } + }; var _addInitHooks = function(tabId, hooks) { - SunstoneCfg["tabs"][tabId]['initHooks'] = hooks; + SunstoneCfg["tabs"][tabId]["initHooks"] = hooks; return false; - } + }; var _addPanels = function(tabId, panels) { - var indexedPanels = {} + var indexedPanels = {}; $.each(panels, function(index, panel) { - indexedPanels[panel.PANEL_ID] = panel - }) - SunstoneCfg["tabs"][tabId]['panels'] = indexedPanels; + indexedPanels[panel.PANEL_ID] = panel; + }); + SunstoneCfg["tabs"][tabId]["panels"] = indexedPanels; return false; - } + }; var _addFormPanels = function(tabId, formPanels) { - var indexedFormPanels = {} + var indexedFormPanels = {}; $.each(formPanels, function(index, formPanel) { - indexedFormPanels[formPanel.FORM_PANEL_ID] = formPanel - }) - SunstoneCfg["tabs"][tabId]['formPanels'] = indexedFormPanels; - SunstoneCfg["tabs"][tabId]['formPanelInstances'] = {}; + indexedFormPanels[formPanel.FORM_PANEL_ID] = formPanel; + }); + SunstoneCfg["tabs"][tabId]["formPanels"] = indexedFormPanels; + SunstoneCfg["tabs"][tabId]["formPanelInstances"] = {}; return false; - } + }; //Inserts all main tabs in the DOM var _insertTabs = function() { @@ -134,7 +134,7 @@ define(function(require) { _insertButtonsInTab(tabName); _setupDataTable(tabName); - var hooks = SunstoneCfg['tabs'][tabName].initHooks; + var hooks = SunstoneCfg["tabs"][tabName].initHooks; if (hooks) { $.each(hooks, function(i, hook){ @@ -155,61 +155,61 @@ define(function(require) { } _setupTabs(); - } + }; var _setupDataTable = function(tabName) { - var dataTable = SunstoneCfg['tabs'][tabName].dataTable; + var dataTable = SunstoneCfg["tabs"][tabName].dataTable; if (dataTable) { dataTable.initialize(); } - } + }; //Inserts a main tab in the DOM. This is done by //adding the content to the proper div and by adding a list item //link to the navigation menu var _insertTab = function(tabName) { - var tabInfo = SunstoneCfg['tabs'][tabName]; - var condition = tabInfo['condition']; - var tabClass = tabInfo['tabClass'] ? tabInfo['tabClass'] : 'topTab'; - var parent = tabInfo['parentTab'] ? tabInfo['parentTab'] : ''; + var tabInfo = SunstoneCfg["tabs"][tabName]; + var condition = tabInfo["condition"]; + var tabClass = tabInfo["tabClass"] ? tabInfo["tabClass"] : "topTab"; + var parent = tabInfo["parentTab"] ? tabInfo["parentTab"] : ""; //skip this tab if we do not meet the condition if (condition && !condition()) {return;} if (tabInfo.no_content === true) { - tabClass += " tab_with_no_content is-accordion-submenu-parent" + tabClass += " tab_with_no_content is-accordion-submenu-parent"; } else { - tabInfo['tabName'] = tabName; - var TabTemplate = require('hbs!sunstone/tab') - $('div.sunstone-content').append(TabTemplate(tabInfo)); + tabInfo["tabName"] = tabName; + var TabTemplate = require("hbs!sunstone/tab"); + $("div.sunstone-content").append(TabTemplate(tabInfo)); } var liItem; - var title = ''; + var title = ""; if (tabInfo.icon) { - title += ' '; + title += " "; } title += tabInfo.title; - if (parent !== '') { - liItem = '
  • ' + - '' + title + '' + - '
  • '; + if (parent !== "") { + liItem = "
  • " + + "" + title + "" + + "
  • "; - if ($('#menu ul#navigation #li_' + parent + ' .menu').length > 0) { - $('#menu ul#navigation #li_' + parent + ' .menu').append(liItem); + if ($("#menu ul#navigation #li_" + parent + " .menu").length > 0) { + $("#menu ul#navigation #li_" + parent + " .menu").append(liItem); } else { - $('#menu ul#navigation #li_' + parent).append( - '"); } } else { - liItem = '
  • ' + - '' + title + '' + - '
  • '; + liItem = "
  • " + + "" + title + "" + + "
  • "; - $('div#menu ul#navigation').append(liItem); + $("div#menu ul#navigation").append(liItem); } //if this is a submenu... @@ -224,12 +224,12 @@ define(function(require) { if (tabInfo.forms) { $.each(tabInfo.forms, function(key, value) { - Sunstone.addFormPanel(tabName, key, value) - }) + Sunstone.addFormPanel(tabName, key, value); + }); } if (tabInfo.setup) { - var context = $('div#' + tabName, $('div.sunstone-content')); + var context = $("div#" + tabName, $("div.sunstone-content")); tabInfo.setup(context); } @@ -248,14 +248,14 @@ define(function(require) { context = customContext; } else { customId = tabName; - context = $('div#' + tabName, $('div.sunstone-content')); + context = $("div#" + tabName, $("div.sunstone-content")); } - var actionBlock = $('div.action_blocks', context) + var actionBlock = $("div.action_blocks", context); if (actionBlock.length) { - var ButtonsTemplate = require('hbs!./sunstone/buttons') + var ButtonsTemplate = require("hbs!./sunstone/buttons"); var buttonsRow = $(ButtonsTemplate({customId: customId, customContext: customContext})); //for every button defined for this tab... @@ -268,20 +268,20 @@ define(function(require) { continue; } - var type = button.type + '_button'; - var strClass = [type] + var type = button.type + "_button"; + var strClass = [type]; switch (button.type) { case "select": break; case "image": - strClass.push("action_button") + strClass.push("action_button"); break; case "create_dialog": - strClass.push("action_button") - strClass.push("top_button") + strClass.push("action_button"); + strClass.push("top_button"); break; default: - strClass.push("top_button") + strClass.push("top_button"); } if (button.alwaysActive) { @@ -297,92 +297,92 @@ define(function(require) { switch (button.layout) { case "create": buttonContext = $("#" + customId + "create_buttons", buttonsRow); - icon = button.icon ? button.icon : ''; - text = button.text ? icon + ' ' + button.text : icon; + icon = button.icon ? button.icon : ""; + text = button.text ? icon + " " + button.text : icon; strClass.push("success", "button"); - buttonCode = ''; + buttonCode = ""; break; case "refresh": buttonContext = $("#" + customId + "refresh_buttons", buttonsRow); - icon = button.icon ? button.icon : ''; - text = button.text ? icon + ' ' + button.text : icon; + icon = button.icon ? button.icon : ""; + text = button.text ? icon + " " + button.text : icon; strClass.push("refresh", "button", "secondary"); - buttonCode = ''; + buttonCode = ""; break; case "top": buttonContext = $("#" + customId + "refresh_buttons", buttonsRow); - text = '' + - '' + - '' + - ''; + text = "" + + "" + + "" + + ""; strClass.push("toggle_top_button", "only-sunstone-list", "button", "hollow"); - buttonCode = '' + text + ''; + buttonCode = "" + text + ""; break; case "main": buttonContext = $("#" + customId + "main_buttons", buttonsRow); text = button.text; strClass.push("button"); - buttonCode = ''; + buttonCode = ""; break; case "vmsplay_buttons": buttonContext = $("#" + customId + "vmsplay_buttons", buttonsRow); text = button.text; strClass.push("button"); - buttonCode = ''; + buttonCode = ""; break; case "vmspause_buttons": buttonContext = $("#" + customId + "vmspause_buttons", buttonsRow); text = button.text; - buttonCode = '
  • ' + text + '
  • '; + buttonCode = "
  • " + text + "
  • "; break; case "vmsstop_buttons": buttonContext = $("#" + customId + "vmsstop_buttons", buttonsRow); text = button.text; - buttonCode = '
  • ' + text + '
  • '; + buttonCode = "
  • " + text + "
  • "; break; case "vmsrepeat_buttons": buttonContext = $("#" + customId + "vmsrepeat_buttons", buttonsRow); text = button.text; - buttonCode = '
  • ' + text + '
  • '; + buttonCode = "
  • " + text + "
  • "; break; case "vmsdelete_buttons": buttonContext = $("#" + customId + "vmsdelete_buttons", buttonsRow); text = button.text; - buttonCode = '
  • ' + text + '
  • '; + buttonCode = "
  • " + text + "
  • "; break; case "vmsplanification_buttons": buttonContext = $("#" + customId + "vmsplanification_buttons", buttonsRow); text = button.text; - buttonCode = '
  • ' + text + '
  • '; + buttonCode = "
  • " + text + "
  • "; break; case "more_select": buttonContext = $("#" + customId + "more_buttons", buttonsRow); text = button.text; - buttonCode = '
  • ' + text + '
  • '; + buttonCode = "
  • " + text + "
  • "; break; case "user_select": buttonContext = $("#" + customId + "user_buttons", buttonsRow); text = button.text; - buttonCode = '
  • ' + text + '
  • '; + buttonCode = "
  • " + text + "
  • "; break; case "del": buttonContext = $("#" + customId + "delete_buttons", buttonsRow); - text = ' '; + text = " "; strClass.push("alert", "button"); - buttonCode = ''; + buttonCode = ""; break; case "labels": buttonContext = $("#" + customId + "labels_buttons", buttonsRow); - text = ''; + text = ""; strClass.push("only-sunstone-info", "only-sunstone-list", "top_button", "secondary", "button", "dropdown"); - buttonCode = ''; + buttonCode = ""; break; default: buttonContext = $("#" + customId + "main_buttons", buttonsRow); text = button.text; strClass.push("button"); - buttonCode = ''; + buttonCode = ""; } buttonContext.append(buttonCode); @@ -392,78 +392,78 @@ define(function(require) { actionBlock.append(buttonsRow); //actionBlock.foundation(); - Foundation.reflow(actionBlock, 'dropdown'); + Foundation.reflow(actionBlock, "dropdown"); Tips.setup(actionBlock); if ($("#" + customId + "more_buttons li", actionBlock).length == 0) { - $("button[data-toggle=" + customId + "more_buttons]", actionBlock).remove() + $("button[data-toggle=" + customId + "more_buttons]", actionBlock).remove(); } if ($("#" + customId + "user_buttons li", actionBlock).length == 0) { - $("button[data-toggle=" + customId + "user_buttons]", actionBlock).remove() + $("button[data-toggle=" + customId + "user_buttons]", actionBlock).remove(); } if ($("#" + customId + "vmsplanification_buttons li", actionBlock).length == 0) { - $("button[data-toggle=" + customId + "vmsplanification_buttons]", actionBlock).remove() + $("button[data-toggle=" + customId + "vmsplanification_buttons]", actionBlock).remove(); } if ($("#" + customId + "vmsdelete_buttons li", actionBlock).length == 0) { - $("button[data-toggle=" + customId + "vmsdelete_buttons]", actionBlock).remove() + $("button[data-toggle=" + customId + "vmsdelete_buttons]", actionBlock).remove(); } if ($("#" + customId + "vmsstop_buttons li", actionBlock).length == 0) { - $("button[data-toggle=" + customId + "vmsstop_buttons]", actionBlock).remove() + $("button[data-toggle=" + customId + "vmsstop_buttons]", actionBlock).remove(); } if ($("#" + customId + "vmspause_buttons li", actionBlock).length == 0) { - $("button[data-toggle=" + customId + "vmspause_buttons]", actionBlock).remove() + $("button[data-toggle=" + customId + "vmspause_buttons]", actionBlock).remove(); } if ($("#" + customId + "vmsrepeat_buttons li", actionBlock).length == 0) { - $("button[data-toggle=" + customId + "vmsrepeat_buttons]", actionBlock).remove() + $("button[data-toggle=" + customId + "vmsrepeat_buttons]", actionBlock).remove(); } if ($("#" + customId + "user_buttons li", actionBlock).length == 0) { - $("button[data-toggle=" + customId + "user_buttons]", actionBlock).remove() + $("button[data-toggle=" + customId + "user_buttons]", actionBlock).remove(); } if ($("#" + customId + "labels_buttons button", buttonsRow).length != 0) { - $('#' + customId + 'labels_buttons').append( - ''); + $("#" + customId + "labels_buttons").append( + "
    "); } - $('#' + customId + 'labels_buttons').foundation(); + $("#" + customId + "labels_buttons").foundation(); //actionBlock.foundationButtons(); - $('.top_button, .list_button', actionBlock).prop('disabled', false); - $('.top_button, .list_button', actionBlock).prop('disabled', true); - $('.create_dialog_button', actionBlock).prop('disabled', false).removeAttr('disabled'); - $('.alwaysActive', actionBlock).prop('disabled', false).removeAttr('disabled'); + $(".top_button, .list_button", actionBlock).prop("disabled", false); + $(".top_button, .list_button", actionBlock).prop("disabled", true); + $(".create_dialog_button", actionBlock).prop("disabled", false).removeAttr("disabled"); + $(".alwaysActive", actionBlock).prop("disabled", false).removeAttr("disabled"); - $('#' + customId + 'reset_button', actionBlock).on("click", function() { + $("#" + customId + "reset_button", actionBlock).on("click", function() { _resetFormPanel(tabName); return false; - }) + }); - $('.submit_button', actionBlock).on("click", function() { + $(".submit_button", actionBlock).on("click", function() { _submitFormPanel(tabName); return false; - }) + }); }//if tab exists - } + }; var _setupButtons = function() { //Listen for .action_buttons //An action buttons runs a predefined action. If it has type //"multiple" it runs that action on the elements of a datatable. - $(document).on("click", '.action_button', function() { + $(document).on("click", ".action_button", function() { var error = 0; - var value = $(this).val() + var value = $(this).val(); if ($.isEmptyObject(value)) { - value = $(this).attr('href'); + value = $(this).attr("href"); } - $('.dropdown-pane').foundation('close'); + $(".dropdown-pane").foundation("close"); var action = SunstoneCfg["actions"][value]; if (!action) { @@ -485,23 +485,23 @@ define(function(require) { //Listen .confirm_buttons. These buttons show a confirmation dialog //before running the action. - $(document).on("click", '.confirm_button', function() { - var dialogInstance = _getDialogInstance(CONFIRM_DIALOG_ID) + $(document).on("click", ".confirm_button", function() { + var dialogInstance = _getDialogInstance(CONFIRM_DIALOG_ID); dialogInstance.reset(); - $('#' + CONFIRM_DIALOG_ID).data('buttonAction', $(this).attr('href')); - $('#' + CONFIRM_DIALOG_ID).data('buttonTab', $(this).parents('.tab').attr('id')); + $("#" + CONFIRM_DIALOG_ID).data("buttonAction", $(this).attr("href")); + $("#" + CONFIRM_DIALOG_ID).data("buttonTab", $(this).parents(".tab").attr("id")); dialogInstance.show(); return false; }); //Listen .confirm_buttons. These buttons show a confirmation dialog //with a select box before running the action. - $(document).on("click", '.confirm_with_select_button', function() { + $(document).on("click", ".confirm_with_select_button", function() { var dialogInstance = _getDialogInstance(CONFIRM_WITH_SELECT_DIALOG_ID); dialogInstance.setParams({ - 'buttonAction' : $(this).attr('href'), - 'buttonTab' : $(this).parents('.tab').attr('id') + "buttonAction" : $(this).attr("href"), + "buttonTab" : $(this).parents(".tab").attr("id") }); dialogInstance.reset(); @@ -517,26 +517,26 @@ define(function(require) { window.history.back(); e.preventDefault(); }); - } + }; var _setupTabs = function() { - Foundation.reflow($('#menu'), 'accordion-menu'); - Foundation.reflow($('div.sunstone-content'), 'sticky') + Foundation.reflow($("#menu"), "accordion-menu"); + Foundation.reflow($("div.sunstone-content"), "sticky"); var topTabs = $(".sunstone-menu-content ul li.topTab"); var subTabs = $(".sunstone-menu-content ul li.subTab > a"); subTabs.on("click", function() { - if ($(this).closest('li').hasClass('topTab')) { + if ($(this).closest("li").hasClass("topTab")) { return false; } else { - var tabName = $(this).closest('li').attr('id').substring(3); + var tabName = $(this).closest("li").attr("id").substring(3); _showTab(tabName); return false; } }); topTabs.on("click", function(e) { - var tabName = $(this).attr('id').substring(3); + var tabName = $(this).attr("id").substring(3); if ($(this).hasClass("tab_with_no_content")) { //Subtabs have a class with the name of this tab @@ -553,7 +553,7 @@ define(function(require) { }; var _showRighList = function(tabName) { - var tab = $('#' + tabName); + var tab = $("#" + tabName); $(".tab").hide(); tab.show(); @@ -563,11 +563,11 @@ define(function(require) { $(".only-sunstone-info", tab).hide(); $(".only-sunstone-form", tab).hide(); $(".only-sunstone-list", tab).fadeIn(); - $('.action_blocks', tab).removeClass('large-12').addClass('large-9'); + $(".action_blocks", tab).removeClass("large-12").addClass("large-9"); }; var _showRighInfo = function(tabName) { - var tab = $('#' + tabName); + var tab = $("#" + tabName); $(".tab").hide(); tab.show(); @@ -577,8 +577,8 @@ define(function(require) { $(".only-sunstone-list", tab).hide(); $(".only-sunstone-form", tab).hide(); $(".only-sunstone-info", tab).fadeIn(); - $('.action_blocks', tab).removeClass('large-9').addClass('large-12'); - } + $(".action_blocks", tab).removeClass("large-9").addClass("large-12"); + }; var _showTab = function(tabName) { if (_getTab() == tabName && _rightListVisible()){ @@ -590,12 +590,12 @@ define(function(require) { _routerShowTab(tabName); } } - } + }; var _routerShowTab = function(tabName) { - $('.labels-tree', '#navigation').remove(); + $(".labels-tree", "#navigation").remove(); - if (!SunstoneCfg['tabs'][tabName]) { + if (!SunstoneCfg["tabs"][tabName]) { return false; } @@ -605,7 +605,7 @@ define(function(require) { // TODO check if necessary // last_selected_row = null; - if (tabName.indexOf('#') == 0) { + if (tabName.indexOf("#") == 0) { tabName = tabName.substring(1); } @@ -613,24 +613,29 @@ define(function(require) { $("#navigation li").removeClass("navigation-active-li"); $("#navigation li#li_" + tabName).addClass("navigation-active-li"); - var tab = $('#' + tabName); + var tab = $("#" + tabName); //show tab _showRighList(tabName); - var dataTable = SunstoneCfg['tabs'][tabName]['dataTable']; + var dataTable = SunstoneCfg["tabs"][tabName]["dataTable"]; if (dataTable) { dataTable.recountCheckboxes(); } - var res = SunstoneCfg['tabs'][tabName]['resource'] + var hashRes = ["Dashboard", "Settings", "NetworkTopology"]; + var res = SunstoneCfg["tabs"][tabName]["resource"]; if (res) { - Sunstone.runAction(res + ".refresh"); + if (!hashRes.includes(res)){ + Sunstone.runAction(res + ".list"); + } else { + Sunstone.runAction(res + ".refresh"); + } } - } + }; var _getTab = function() { return $(".tab:visible").attr("id"); - } + }; var _showElement = function(tabName, elementId) { if(!Config.isTabEnabled(tabName)){ @@ -642,7 +647,7 @@ define(function(require) { }else{ _routerShowElement(tabName, elementId); } - } + }; var _routerShowElement = function(tabName, elementId) { var resource = SunstoneCfg["tabs"][tabName].resource; @@ -655,39 +660,39 @@ define(function(require) { _routerShowTab(tabName); - var context = $('#' + tabName); + var context = $("#" + tabName); $(".resource-id", context).html(elementId); $(".resource-info-header", context).text(""); - var loading = '
    loading...
    '; + var loading = "
    \"loading...\"
    "; $(".sunstone-info", context).html(loading); _showRighInfo(tabName); Sunstone.runAction(infoAction, elementId); //enable action buttons - $('.top_button, .list_button', context).attr('disabled', false); - } + $(".top_button, .list_button", context).attr("disabled", false); + }; // Returns the element that is currently shown in the right info var _getElementRightInfo = function(tabName, context) { var context = context || $(".sunstone-info", $("#" + tabName)); - return context.data('element'); - } + return context.data("element"); + }; var _insertPanels = function(tabName, info, contextTabId, context) { var context = context || $(".sunstone-info", $("#" + tabName)); - context.data('element', info[Object.keys(info)[0]]); + context.data("element", info[Object.keys(info)[0]]); - var containerId = tabName + '-panels'; + var containerId = tabName + "-panels"; var activaTab = $("li.is-active a", $("#" + containerId)); if (activaTab) { - var activaTabHref = activaTab.attr('href'); + var activaTabHref = activaTab.attr("href"); } var isRefresh = (activaTabHref != undefined); - var prevPanelInstances = SunstoneCfg['tabs'][tabName]["panelInstances"]; + var prevPanelInstances = SunstoneCfg["tabs"][tabName]["panelInstances"]; var prevPanelStates = {}; if(isRefresh && prevPanelInstances != undefined){ @@ -698,7 +703,7 @@ define(function(require) { }); } - var hooks = SunstoneCfg['tabs'][tabName].panelsHooks; + var hooks = SunstoneCfg["tabs"][tabName].panelsHooks; if (hooks) { $.each(hooks, function(i, hook){ @@ -706,10 +711,10 @@ define(function(require) { }); } - var panels = SunstoneCfg['tabs'][tabName].panels; + var panels = SunstoneCfg["tabs"][tabName].panels; var active = false; - var templatePanelsParams = [] - SunstoneCfg['tabs'][tabName]["panelInstances"] = {}; + var templatePanelsParams = []; + SunstoneCfg["tabs"][tabName]["panelInstances"] = {}; $.each(panels, function(panelName, Panel) { if (Config.isTabPanelEnabled((contextTabId||tabName), panelName)) { @@ -718,20 +723,20 @@ define(function(require) { active = true; } } else { - activaTabHref = "#" + panelName + activaTabHref = "#" + panelName; active = true; } try { var panelInstance = new Panel(info, contextTabId); - SunstoneCfg['tabs'][tabName]["panelInstances"][panelName] = panelInstance; + SunstoneCfg["tabs"][tabName]["panelInstances"][panelName] = panelInstance; templatePanelsParams.push({ - 'panelName': panelName, - 'icon': panelInstance.icon, - 'title': panelInstance.title, - 'html': panelInstance.html(), - 'active': active - }) + "panelName": panelName, + "icon": panelInstance.icon, + "title": panelInstance.title, + "html": panelInstance.html(), + "active": active + }); } catch (err) { console.log(err); } @@ -740,14 +745,14 @@ define(function(require) { } }); - var TemplatePanels = require('hbs!./sunstone/panels'); + var TemplatePanels = require("hbs!./sunstone/panels"); var html = TemplatePanels({ - 'containerId': containerId, - 'panels': templatePanelsParams - }) + "containerId": containerId, + "panels": templatePanelsParams + }); context.html(html); - $.each(SunstoneCfg['tabs'][tabName]["panelInstances"], function(panelName, panel) { + $.each(SunstoneCfg["tabs"][tabName]["panelInstances"], function(panelName, panel) { panel.setup(context); if(isRefresh && prevPanelStates[panelName] && panel.setState){ @@ -755,19 +760,19 @@ define(function(require) { } }); - $('#' + containerId + 'Tabs', context).on('change.zf.tabs', function(target) { - var tabIdWithHash = $('.is-active > a', this)[0].hash; - var panel = SunstoneCfg['tabs'][tabName]["panelInstances"][tabIdWithHash.substring(1)]; + $("#" + containerId + "Tabs", context).on("change.zf.tabs", function(target) { + var tabIdWithHash = $(".is-active > a", this)[0].hash; + var panel = SunstoneCfg["tabs"][tabName]["panelInstances"][tabIdWithHash.substring(1)]; if (panel && panel.onShow) { panel.onShow(context); } }); - Foundation.reflow(context, 'tabs'); + Foundation.reflow(context, "tabs"); if(activaTabHref != undefined){ - $('[href="' + activaTabHref + '"]', context).trigger("click"); - $('#' + containerId + 'Tabs', context).trigger('change.zf.tabs'); + $("[href=\"" + activaTabHref + "\"]", context).trigger("click"); + $("#" + containerId + "Tabs", context).trigger("change.zf.tabs"); } if (hooks) { @@ -775,7 +780,7 @@ define(function(require) { hook.post(info, (contextTabId||tabName)); }); } - } + }; //Runs a predefined action. Wraps the calls to opennebula.js and //can be use to run action depending on conditions and notify them @@ -875,7 +880,7 @@ define(function(require) { } return 0; - } + }; function _showFormPanel(tabId, formPanelId, action, onShow2) { var context = $("#" + tabId); @@ -890,12 +895,12 @@ define(function(require) { if (!formPanelInstance) { formContext = - $('
    \ -
    \ -
    \ -
    ').appendTo( $(".contentForm", context) ); + $("
    \ +
    \ +
    \ +
    ").appendTo( $(".contentForm", context) ); // Create panelInstance, insert in the DOM and setup var formPanel = tab["formPanels"][formPanelId]; @@ -904,7 +909,7 @@ define(function(require) { return false; } // Panel not defined - Foundation.reflow(context, 'tabs'); + Foundation.reflow(context, "tabs"); formPanelInstance = new formPanel(); tab["formPanelInstances"][formPanelId] = formPanelInstance; @@ -927,7 +932,7 @@ define(function(require) { $(".wizard_tabs", context).show(); } else { $(".wizard_tabs", context).hide(); - $('a[href="#'+tab.tabName+'-wizardForms"]', context).click(); + $("a[href=\"#"+tab.tabName+"-wizardForms\"]", context).click(); } // Hide reset button if not defined @@ -943,14 +948,14 @@ define(function(require) { if (onShow2) { onShow2(formPanelInstance, formContext); } - }, 13) + }, 13); } var _submitFormPanel = function(tabId) { var context = $("#" + tabId); //_popFormPanelLoading(tabId); // Workaround until Foundation.abide support hidden forms - + var context = $("#" + tabId); $(".sunstone-form-title", context).text(Locale.tr("Submitting...")); $(".submit_button", context).text(Locale.tr("Submitting...")); @@ -958,15 +963,15 @@ define(function(require) { _disableFormPanelSubmit(tabId); setTimeout(function() { - var formPanelInstance = SunstoneCfg["tabs"][tabId].activeFormPanel + var formPanelInstance = SunstoneCfg["tabs"][tabId].activeFormPanel; if ($(".wizardForms", context).is(":visible")) { - $('#' + formPanelInstance.formPanelId + 'Wizard').submit(); + $("#" + formPanelInstance.formPanelId + "Wizard").submit(); } else if ($(".advancedForms", context).is(":visible")) { - $('#' + formPanelInstance.formPanelId + 'Advanced').submit(); + $("#" + formPanelInstance.formPanelId + "Advanced").submit(); } - }, 13) - } + }, 13); + }; /** * Resets the form panel. The loading screen is shown, then the panel is reset @@ -979,7 +984,7 @@ define(function(require) { */ var _resetFormPanel = function(tabId, formPanelId) { if (tabId == undefined){ - tabId = _getTab() + tabId = _getTab(); } _popFormPanelLoading(tabId); @@ -987,7 +992,7 @@ define(function(require) { setTimeout(function() { var formPanelInstance; if (formPanelId != undefined) { - formPanelInstance = SunstoneCfg["tabs"][tabId]['formPanelInstances'][formPanelId]; + formPanelInstance = SunstoneCfg["tabs"][tabId]["formPanelInstances"][formPanelId]; } else { formPanelInstance = SunstoneCfg["tabs"][tabId].activeFormPanel; } @@ -1003,8 +1008,8 @@ define(function(require) { if (_formPanelVisible($("#"+tabId))){ _showFormPanel(tabId, formPanelId); } - }, 13) - } + }, 13); + }; /** * Hides the form panel loading (spinning icon on submit), and resets @@ -1015,7 +1020,7 @@ define(function(require) { */ function _hideFormPanelLoading(tabId) { if (tabId == undefined){ - tabId = _getTab() + tabId = _getTab(); } var context = $("#" + tabId); @@ -1038,19 +1043,19 @@ define(function(require) { function _hideFormPanel(tabId) { if (tabId == undefined){ - tabId = _getTab() + tabId = _getTab(); } var context = $("#" + tabId); if (_formPanelVisible(context)){ - $('[href="back"]', context).trigger("click"); + $("[href=\"back\"]", context).trigger("click"); } } function _popFormPanelLoading(tabId) { if (tabId == undefined){ - tabId = _getTab() + tabId = _getTab(); } if(_getTab() != tabId){ @@ -1068,7 +1073,7 @@ define(function(require) { $(".only-sunstone-list", context).hide(); $(".only-sunstone-info", context).hide(); $(".only-sunstone-form", context).show(); - $('.action_blocks', context).removeClass('large-9').addClass('large-12'); + $(".action_blocks", context).removeClass("large-9").addClass("large-12"); $(".sunstone-form-title", context).text(Locale.tr("Loading...")); $(".submit_button", context).text(Locale.tr("Loading...")); @@ -1091,7 +1096,7 @@ define(function(require) { function _enableFormPanelSubmit(tabId) { if (tabId == undefined){ - tabId = _getTab() + tabId = _getTab(); } var context = $("#" + tabId); @@ -1119,51 +1124,51 @@ define(function(require) { button = buttons["action_list"]["actions"][buttonName]; } return button; - } + }; var _rightInfoVisible = function(context) { - return $(".sunstone-info", context).is(':visible'); - } + return $(".sunstone-info", context).is(":visible"); + }; var _rightListVisible = function(context) { - return $(".sunstone-list", context).is(':visible'); - } + return $(".sunstone-list", context).is(":visible"); + }; var _formPanelVisible = function(context) { - return $(".sunstone-form", context).is(':visible'); - } + return $(".sunstone-form", context).is(":visible"); + }; var _rightInfoResourceId = function(context) { return $(".resource-id", context).text(); - } + }; var _getAction = function(actionId) { return SunstoneCfg["actions"][actionId]; - } + }; var _getDataTable = function(tabName) { - if (SunstoneCfg['tabs'][tabName]) { - return SunstoneCfg['tabs'][tabName].dataTable; + if (SunstoneCfg["tabs"][tabName]) { + return SunstoneCfg["tabs"][tabName].dataTable; } - } + }; var _getResource = function(tabName) { - if (SunstoneCfg['tabs'][tabName]) { - return SunstoneCfg['tabs'][tabName].resource; + if (SunstoneCfg["tabs"][tabName]) { + return SunstoneCfg["tabs"][tabName].resource; } - } + }; var _getDialogInstance = function(dialogId) { - var dialogInstance = SunstoneCfg['dialogInstances'][dialogId]; + var dialogInstance = SunstoneCfg["dialogInstances"][dialogId]; if (dialogInstance == undefined) { - var Dialog = SunstoneCfg['dialogs'][dialogId] + var Dialog = SunstoneCfg["dialogs"][dialogId]; var dialogInstance = new Dialog(); dialogInstance.insert(); - SunstoneCfg['dialogInstances'][dialogId] = dialogInstance; + SunstoneCfg["dialogInstances"][dialogId] = dialogInstance; } return dialogInstance; - } + }; var _setupNavigoRoutes = function() { router = new Navigo(null, true); @@ -1177,7 +1182,7 @@ define(function(require) { }.bind(tabName)); router.on(new RegExp("(?:#|/)"+tabName+"/(\\d+)"), function(id){ - _routerShowElement(this, id) + _routerShowElement(this, id); }.bind(tabName)); router.on(new RegExp("(?:#|/)"+tabName), function(){ @@ -1197,7 +1202,7 @@ define(function(require) { }); router.resolve(); - } + }; var Sunstone = { "addMainTabs": _addMainTabs, @@ -1207,7 +1212,7 @@ define(function(require) { "insertPanels": _insertPanels, "getElementRightInfo": _getElementRightInfo, - 'showTab': _showTab, + "showTab": _showTab, "showElement" : _showElement, "getTab": _getTab, @@ -1237,7 +1242,7 @@ define(function(require) { "TOP_INTERVAL": TOP_INTERVAL, "setupNavigoRoutes": _setupNavigoRoutes - } + }; return Sunstone; }); diff --git a/src/sunstone/public/app/tabs/dashboard-tab.js b/src/sunstone/public/app/tabs/dashboard-tab.js index 1e3c86628a..fead984125 100644 --- a/src/sunstone/public/app/tabs/dashboard-tab.js +++ b/src/sunstone/public/app/tabs/dashboard-tab.js @@ -86,8 +86,6 @@ define(function(require) { 'vms': { 'html': require('hbs!./dashboard-tab/vms'), 'onShow': function() { - Sunstone.runAction("VM.list"); - var end_time = -1; // today var start_time = Math.floor(new Date().getTime() / 1000); start_time = start_time - 604800; // 604800 = 7 days = 7*24*60*60 @@ -106,6 +104,7 @@ define(function(require) { success: function(req, response) { Accounting.fillAccounting($("#dashboard_vm_accounting"), req, response, no_table); Accounting.fillAccounting($("#dashboard_user_accounting"), req, response, no_table); + Sunstone.runAction("VM.list"); }, error: Notifier.onError, data: options From 0bb1cd3b48df23c679150ba0cfb99b725429ce30 Mon Sep 17 00:00:00 2001 From: juanmont Date: Fri, 24 Nov 2017 12:14:24 +0100 Subject: [PATCH 24/31] B #1483: Removed capacity attribute when it's empty (cherry picked from commit 700f544439bfeffa796dd6243f1083d03b70a80c) --- src/sunstone/public/app/tabs/hosts-tab/form-panels/create.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sunstone/public/app/tabs/hosts-tab/form-panels/create.js b/src/sunstone/public/app/tabs/hosts-tab/form-panels/create.js index afe05c9879..2903e2c76c 100644 --- a/src/sunstone/public/app/tabs/hosts-tab/form-panels/create.js +++ b/src/sunstone/public/app/tabs/hosts-tab/form-panels/create.js @@ -262,7 +262,9 @@ define(function(require) { host_json["host"]["region_name"] = region_name; host_json["host"]["ec2_secret"] = ec2_secret; host_json["host"]["ec2_access"] = ec2_access; - host_json["host"]["capacity"] = capacity; + if (capacity.length > 0){ + host_json["host"]["capacity"] = capacity; + } } //Create the OpenNebula.Host. //If it is successfull we refresh the list. From b5f8722aed80fe51845e1c93ecb1fc24f9e04083 Mon Sep 17 00:00:00 2001 From: juanmont Date: Fri, 24 Nov 2017 12:17:18 +0100 Subject: [PATCH 25/31] B #1490: Checked if owner has permissions for manage the template (cherry picked from commit d985a2ca5c09c859fe264dc5fd98c223c461661e) --- src/sunstone/public/app/tabs/provision-tab/templates/list.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sunstone/public/app/tabs/provision-tab/templates/list.js b/src/sunstone/public/app/tabs/provision-tab/templates/list.js index 844364553a..5be999c3a5 100644 --- a/src/sunstone/public/app/tabs/provision-tab/templates/list.js +++ b/src/sunstone/public/app/tabs/provision-tab/templates/list.js @@ -169,7 +169,7 @@ define(function(require) { } } - if (Config.isTabActionEnabled("provision-tab", "Template.delete")) { + if (Config.isTabActionEnabled("provision-tab", "Template.delete") && data["PERMISSIONS"]["OWNER_M"] === "1") { actions_html += ''; } From 4a8c96fef724dea158bd3f6f69fbf2fddadfe78e Mon Sep 17 00:00:00 2001 From: Vlastimil Holer Date: Mon, 27 Nov 2017 09:43:30 +0100 Subject: [PATCH 26/31] B #1489: Fix LDAP group membership checks with custom 'user_group_field' (cherry picked from commit 9eecb45924b2eb5c6631043f33ccd338cbf376d2) --- src/authm_mad/remotes/ldap/ldap_auth.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/authm_mad/remotes/ldap/ldap_auth.rb b/src/authm_mad/remotes/ldap/ldap_auth.rb index 9a7ac5220c..091e91b3fb 100644 --- a/src/authm_mad/remotes/ldap/ldap_auth.rb +++ b/src/authm_mad/remotes/ldap/ldap_auth.rb @@ -66,6 +66,11 @@ class OpenNebula::LdapAuth @options[:attributes] << @options[:user_field] end + # fetch the user group field only if we need that + if @options[:group] or !@options[:rfc2307bis] + @options[:attributes] << @options[:user_group_field] + end + ops[:host]=@options[:host] if @options[:host] ops[:port]=@options[:port].to_i if @options[:port] ops[:encryption]=@options[:encryption] if @options[:encryption] From 490e2aea80f7d5bcb0711118998f12cd5d770802 Mon Sep 17 00:00:00 2001 From: Abel Coronado Date: Tue, 28 Nov 2017 09:45:16 +0100 Subject: [PATCH 27/31] B #1533: TypeError: Cannot read property 'updateView' (cherry picked from commit c4980894b48630ad911797254281baaa40cc145c) --- src/sunstone/public/app/utils/common-actions.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sunstone/public/app/utils/common-actions.js b/src/sunstone/public/app/utils/common-actions.js index 8f3598f0c6..b34bf10d61 100644 --- a/src/sunstone/public/app/utils/common-actions.js +++ b/src/sunstone/public/app/utils/common-actions.js @@ -55,7 +55,10 @@ define(function(require) { type: "list", call: that.openNebulaResource.list, callback: function(request, response) { - Sunstone.getDataTable(that.tabId).updateView(request, response); + var datatable = Sunstone.getDataTable(that.tabId); + if (datatable){ + datatable.updateView(request, response); + } }, error: Notifier.onError } From 143daceb3b16eabc75a438b2d4fc7a01e0db6ee0 Mon Sep 17 00:00:00 2001 From: juanmont Date: Tue, 28 Nov 2017 15:11:37 +0100 Subject: [PATCH 28/31] B #1520: Saved MAC into attribute VROUTER_MAC for can detach nic (cherry picked from commit 5ed8aaa47b24d5ff1b24a5254ac8c659d602b3ef) --- src/vrouter/VirtualRouter.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/vrouter/VirtualRouter.cc b/src/vrouter/VirtualRouter.cc index 9e0d889689..530bc112da 100644 --- a/src/vrouter/VirtualRouter.cc +++ b/src/vrouter/VirtualRouter.cc @@ -409,7 +409,7 @@ int VirtualRouter::release_network_leases(const VectorAttribute * nic) return -1; } - mac = nic->vector_value("MAC"); + mac = nic->vector_value("VROUTER_MAC"); vn = vnpool->get(vnid, true); @@ -457,8 +457,7 @@ static void prepare_nic_vm(VectorAttribute * nic) if (floating) { - nic->remove("MAC"); - + vrouter_prefix(nic, "MAC"); vrouter_prefix(nic, "IP"); vrouter_prefix(nic, "IP6_LINK"); vrouter_prefix(nic, "IP6_ULA"); @@ -659,10 +658,10 @@ int VirtualRouter::detach_nic(int nic_id) return -1; } - obj_template->remove(nic); - release_network_leases(nic); + obj_template->remove(nic); + // Update quotas tmpl.set(nic); From 027671f6d31a9360955b4a3e6c412f4ee5223450 Mon Sep 17 00:00:00 2001 From: juanmont Date: Tue, 28 Nov 2017 15:18:38 +0100 Subject: [PATCH 29/31] F #1512: Do not overwrite attributes already defined in the image (cherry picked from commit 22e06f49e0af06d9c63f2e515d2e498ee413cb54) --- src/datastore/Datastore.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/datastore/Datastore.cc b/src/datastore/Datastore.cc index def084789a..0ca47e9f9f 100644 --- a/src/datastore/Datastore.cc +++ b/src/datastore/Datastore.cc @@ -118,14 +118,14 @@ void Datastore::disk_attribute( get_template_attribute("CLONE_TARGET", st); - if(!st.empty()) + if(!st.empty() && disk->vector_value("CLONE_TARGET").empty()) { disk->replace("CLONE_TARGET", st); } get_template_attribute("LN_TARGET", st); - if(!st.empty()) + if(!st.empty() && disk->vector_value("LN_TARGET").empty()) { disk->replace("LN_TARGET", st); } @@ -135,13 +135,13 @@ void Datastore::disk_attribute( current_val = disk->vector_value((*it).c_str()); get_template_attribute((*it).c_str(), inherit_val); - if ( current_val.empty() && !inherit_val.empty() ) + if ( current_val.empty() && !inherit_val.empty() && disk->vector_value((*it).c_str()).empty()) { disk->replace(*it, inherit_val); } } - if (disk->is_volatile()) + if (disk->is_volatile() && disk->vector_value("DISK_TYPE").empty()) { disk->replace("DISK_TYPE", Image::disk_type_to_str(get_disk_type())); } @@ -152,7 +152,7 @@ void Datastore::disk_attribute( { get_template_attribute("DRIVER", st); - if(!st.empty()) + if(!st.empty() && disk->vector_value("DRIVER").empty()) { disk->replace("DRIVER", st); } From fdb2ccdf8cb5a1054404993162608e0012d915be Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 30 Nov 2017 16:39:33 +0100 Subject: [PATCH 30/31] Revert "F #1512: Do not overwrite attributes already defined in the image" This reverts commit 027671f6d31a9360955b4a3e6c412f4ee5223450. --- src/datastore/Datastore.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/datastore/Datastore.cc b/src/datastore/Datastore.cc index 0ca47e9f9f..def084789a 100644 --- a/src/datastore/Datastore.cc +++ b/src/datastore/Datastore.cc @@ -118,14 +118,14 @@ void Datastore::disk_attribute( get_template_attribute("CLONE_TARGET", st); - if(!st.empty() && disk->vector_value("CLONE_TARGET").empty()) + if(!st.empty()) { disk->replace("CLONE_TARGET", st); } get_template_attribute("LN_TARGET", st); - if(!st.empty() && disk->vector_value("LN_TARGET").empty()) + if(!st.empty()) { disk->replace("LN_TARGET", st); } @@ -135,13 +135,13 @@ void Datastore::disk_attribute( current_val = disk->vector_value((*it).c_str()); get_template_attribute((*it).c_str(), inherit_val); - if ( current_val.empty() && !inherit_val.empty() && disk->vector_value((*it).c_str()).empty()) + if ( current_val.empty() && !inherit_val.empty() ) { disk->replace(*it, inherit_val); } } - if (disk->is_volatile() && disk->vector_value("DISK_TYPE").empty()) + if (disk->is_volatile()) { disk->replace("DISK_TYPE", Image::disk_type_to_str(get_disk_type())); } @@ -152,7 +152,7 @@ void Datastore::disk_attribute( { get_template_attribute("DRIVER", st); - if(!st.empty() && disk->vector_value("DRIVER").empty()) + if(!st.empty()) { disk->replace("DRIVER", st); } From 59665e9f81132be4b3ee9fc64b3d4d81d20c0840 Mon Sep 17 00:00:00 2001 From: Vlastimil Holer Date: Fri, 1 Dec 2017 11:28:51 +0100 Subject: [PATCH 31/31] B #1554: Fix EC2 deployment failure with custom USERDATA (#1556) --- src/vmm_mad/remotes/ec2/ec2_driver.rb | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/vmm_mad/remotes/ec2/ec2_driver.rb b/src/vmm_mad/remotes/ec2/ec2_driver.rb index 50030ea6f1..0d2b859e12 100755 --- a/src/vmm_mad/remotes/ec2/ec2_driver.rb +++ b/src/vmm_mad/remotes/ec2/ec2_driver.rb @@ -336,22 +336,22 @@ class EC2Driver if !ec2_value(ec2_info, 'USERDATA') xml = OpenNebula::XMLElement.new xml.initialize_xml(xml_text, 'VM') - end - if xml.has_elements?('TEMPLATE/CONTEXT') - # Since there is only 1 level ',' will not be added - context_str = xml.template_like_str('TEMPLATE/CONTEXT') + if xml.has_elements?('TEMPLATE/CONTEXT') + # Since there is only 1 level ',' will not be added + context_str = xml.template_like_str('TEMPLATE/CONTEXT') - if xml['TEMPLATE/CONTEXT/TOKEN'] == 'YES' - # TODO use OneGate library - token_str = generate_onegate_token(xml) - if token_str - context_str << "\nONEGATE_TOKEN=\"#{token_str}\"" + if xml['TEMPLATE/CONTEXT/TOKEN'] == 'YES' + # TODO use OneGate library + token_str = generate_onegate_token(xml) + if token_str + context_str << "\nONEGATE_TOKEN=\"#{token_str}\"" + end end - end - userdata_key = EC2[:run][:args]["USERDATA"][:opt] - opts[userdata_key] = Base64.encode64(context_str) + userdata_key = EC2[:run][:args]["USERDATA"][:opt] + opts[userdata_key] = Base64.encode64(context_str) + end end instances = @ec2.create_instances(opts)