Merge remote-tracking branch 'upstream/one-5.4' into one-5.4

This commit is contained in:
Vlastimil Holer committed 2017-12-04 17:35:20 +01:00
commit 2583efa616
42 files changed
+707 -413

No files matched your search

+5
View File
@@ -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]
+2 -2
View File
@@ -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
+2 -1
View File
@@ -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")
+7 -10
View File
@@ -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
+1
View File
@@ -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
+9 -3
View File
@@ -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"
+58 -10
View File
@@ -43,7 +43,7 @@ function get_type
else
command=$1
( $command | head -n 1024 | file -b --mime-type - ) 2>/dev/null
( eval "$command" | head -n 1024 | file -b --mime-type - ) 2>/dev/null
fi
}
@@ -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
@@ -263,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"
@@ -324,11 +336,48 @@ 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"
if [ "$?" != "0" -o "$PIPESTATUS" != "0" ]; then
echo "Error copying" >&2
exit -1
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" | \
decompress "$decompressor" "$TO" 2>/dev/null | \
head -c "${MAX_SIZE}"
# 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
@@ -344,4 +393,3 @@ fi
if [ "$TO" != "-" ]; then
unarchive "$TO"
fi
+197 -41
View File
@@ -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")
+1
View File
@@ -103,6 +103,7 @@ ADDR_SIZE="${XPATH_ELEMENTS[i++]}"
BASE_IP=$(echo $AR_IP | cut -d'.' -f-3)
HOST_ID=$RANDOM
let "HOST_ID %= $AR_SIZE"
HOST_ID=$(($HOST_ID+1))
cat << EOT
ADDRESS = [ IP=$BASE_IP.$HOST_ID, SIZE=$ADDR_SIZE ]
@@ -121,7 +121,7 @@ else
AR=$(cat <<EOF
AR=[
TYPE="IP4",
IP ="10.0.0.10",
IP ="10.0.0.1",
SIZE="100",
NETWORK_MASK="255.255.255.0",
GATEWAY="10.0.0.1",
+3
View File
@@ -111,10 +111,13 @@ class OneMarket
end
end
begin
if !app["opennebula_template"].nil?
vmtmpl64 = template_to_str(JSON.parse(app["opennebula_template"]))
print_var(tmpl, "VMTEMPLATE64", Base64::strict_encode64(vmtmpl64))
end
rescue
end
appstr << "APP=\"#{Base64::strict_encode64(tmpl)}\"\n"
}
+1 -1
View File
@@ -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";
}
/* ------------------------------------------------------------------------- */
+1 -1
View File
@@ -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
+1 -1
View File
@@ -31,7 +31,7 @@ module OpenNebula
EALLOCATE = 0x4000
ENOTDEFINED = 0xF001
EXML_RPC_CALL = 0xF002
attr_reader :message, :errno
# +message+ Description of the error
+1 -2
View File
@@ -170,9 +170,8 @@ module OneDBFsck
counter_no_ar = counters[:vnet][row[:oid]][:no_ar_leases]
error = false
counters[:vnet][row[:oid]][:ar_leases].each do |ar_id, counter_ar|
error = false
net_ar = doc.root.at_xpath("AR_POOL/AR[AR_ID=#{ar_id}]")
if (net_ar.nil?)
+1 -1
View File
@@ -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:
+13 -4
View File
@@ -87,13 +87,18 @@ class OneDBLive
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 = hash['SQL_COMMAND']['RESULT']['ROW'] rescue nil
[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
@@ -370,22 +375,24 @@ 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
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
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]
next unless check_expr(o, options[:expr])
end
# Get body from the database
begin
db_data = select(table, "oid = #{o.id}")
@@ -423,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)
+1 -1
View File
@@ -1088,7 +1088,7 @@ bool VirtualRouterAllocate::allocate_authorization(
if (quota_authorization(tmpl, Quotas::VIRTUALROUTER, att, att.resp_msg) == false)
{
return AUTHORIZATION;
return false;
}
return true;
+6 -5
View File
@@ -255,10 +255,7 @@ Request::ErrorCode VMTemplateInstantiate::merge(
const string &str_uattrs,
RequestAttributes& att)
{
if (str_uattrs.empty())
{
return SUCCESS;
}
int rc;
@@ -270,11 +267,15 @@ Request::ErrorCode VMTemplateInstantiate::merge(
if ( rc != 0 )
{
return INTERNAL;
}
else if (uattrs.empty())
{
return SUCCESS;
}
if (att.uid!=UserPool::ONEADMIN_ID && att.gid!=GroupPool::ONEADMIN_ID)
{
if (uattrs.check_restricted(aname, tmpl))
if (uattrs.check_restricted(aname, tmpl))
{
att.resp_msg ="User Template includes a restricted attribute " + aname;
-3
View File
@@ -293,13 +293,10 @@ void VirtualRouterAttachNic::request_execute(
{
failure_response(ACTION, att);
delete nic;
return;
}
}
delete nic;
success_response(vrid, att);
}
File diff suppressed because it is too large. Load diff
@@ -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
@@ -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.
@@ -926,6 +926,9 @@ define(function(require) {
tab.on("click", "#provision_create_vm .provision_select_template .provision-pricing-table.only-one" , function(){
var create_vm_context = $("#provision_create_vm");
var that = this;
that.template_base_json = {};
if ($(this).hasClass("selected")){
//$(".provision_disk_selector", create_vm_context).html("");
@@ -954,6 +957,17 @@ define(function(require) {
$("#provision_create_vm .provision_vmgroup").show();
$("#provision_create_vm .provision_ds").show();
OpenNebula.Template.show({
data : {
id: template_id,
extended: false
},
timeout: true,
success: function (request, template_json) {
that.template_base_json= template_json;
}
});
OpenNebula.Template.show({
data : {
id: template_id,
@@ -975,6 +989,7 @@ define(function(require) {
pers = false;
}
DisksResize.insert({
template_base_json: that.template_base_json,
template_json: template_json,
disksContext: disksContext,
force_persistent: pers,
@@ -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 += '<a class="provision_confirm_delete_template_button" title="'+ Locale.tr("Delete")+'" href="#"><i class="fa fa-fw fa-lg fa-trash-o only-on-hover"/></a>';
}
@@ -153,9 +153,9 @@ define(function(require) {
success: function(request, obj_files){
var totalGB = 0;
$.each(that.templateDISKS, function(ikey, ivalue){
if (ivalue.IMAGE_ID){
if (ivalue.IMAGE || ivalue.IMAGE_ID){
$.each(obj_files, function(jkey, jvalue){
if (ivalue.IMAGE_ID == jvalue.IMAGE.ID){
if ((ivalue.IMAGE && ivalue.IMAGE === jvalue.IMAGE.NAME && ivalue.IMAGE_UNAME === jvalue.IMAGE.UNAME) || (ivalue.IMAGE_ID && ivalue.IMAGE_ID === jvalue.IMAGE.ID)){
totalGB += jvalue.IMAGE.SIZE / 1024;
}
});
@@ -264,14 +264,29 @@ define(function(require) {
this.selected_nodes = selected_nodes;
this.template_objects = [];
this.template_base_objects = {};
var templatesContext = $(".list_of_templates", context);
var idsLength = this.selected_nodes.length;
var idsDone = 0;
$.each(this.selected_nodes, function(index, template_id) {
OpenNebulaTemplate.show({
data : {
id: template_id,
extended: false
},
timeout: true,
success: function (request, template_json) {
that.template_base_objects[template_json.VMTEMPLATE.ID] = template_json;
}
});
});
templatesContext.html("");
$.each(this.selected_nodes, function(index, template_id) {
OpenNebulaTemplate.show({
data : {
id: template_id,
@@ -353,6 +368,7 @@ define(function(require) {
}
DisksResize.insert({
template_base_json: that.template_base_objects[template_json.VMTEMPLATE.ID],
template_json: template_json,
disksContext: $(".disksContext" + template_json.VMTEMPLATE.ID, context),
force_persistent: $("input.instantiate_pers", context).prop("checked"),
@@ -30,7 +30,7 @@ define(function(require) {
/*
TEMPLATES
*/
var TemplateTable = require('utils/panel/template-table');
/*
@@ -29,7 +29,9 @@
<td class="key_td">{{tr "Authentication driver"}}</td>
<td class="value_td" id="change_auth_driver" colspan="2" hidden = "true">{{{userCreationHTML}}}</td>
<td class="value_td" colspan="2" id="show_auth_driver">{{element.AUTH_DRIVER}}</td>
<td><a id="div_edit_auth_driver_link" class="edit_e" href="#"> <i class="fa fa-pencil-square-o right"/></a></td>
{{#isTabActionEnabled tabId "User.change_authentication"}}
<td><a id="div_edit_auth_driver_link" class="edit_e" href="#"> <i class="fa fa-pencil-square-o right"/></a></td>
{{/isTabActionEnabled}}
</tr>
<tr class="passsword_edit">
<td class="key_td">{{tr "Password"}}</td>
@@ -19,19 +19,19 @@ define(function(require) {
DEPENDENCIES
*/
var TemplateInfo = require('hbs!./info/html');
var ResourceSelect = require('utils/resource-select');
var TemplateUtils = require('utils/template-utils');
var Locale = require('utils/locale');
var OpenNebulaUser = require('opennebula/user');
var Sunstone = require('sunstone');
var UserCreation = require('tabs/users-tab/utils/user-creation');
var TemplateInfo = require("hbs!./info/html");
var ResourceSelect = require("utils/resource-select");
var TemplateUtils = require("utils/template-utils");
var Locale = require("utils/locale");
var OpenNebulaUser = require("opennebula/user");
var Sunstone = require("sunstone");
var UserCreation = require("tabs/users-tab/utils/user-creation");
/*
TEMPLATES
*/
var TemplateTable = require('utils/panel/template-table');
var TemplateTable = require("utils/panel/template-table");
/*
CONSTANTS
@@ -39,9 +39,9 @@ define(function(require) {
var RESOURCE = "User";
var XML_ROOT = "USER";
var PASSWORD_DIALOG_ID = require('tabs/users-tab/dialogs/password/dialogId');
var LOGIN_TOKEN_DIALOG_ID = require('tabs/users-tab/dialogs/login-token/dialogId');
var CONFIRM_DIALOG_ID = require('utils/dialogs/generic-confirm/dialogId');
var PASSWORD_DIALOG_ID = require("tabs/users-tab/dialogs/password/dialogId");
var LOGIN_TOKEN_DIALOG_ID = require("tabs/users-tab/dialogs/login-token/dialogId");
var CONFIRM_DIALOG_ID = require("utils/dialogs/generic-confirm/dialogId");
/*
CONSTRUCTOR
@@ -77,11 +77,11 @@ define(function(require) {
//====
return TemplateInfo({
'element': this.element,
'sunstone_template': this.element.TEMPLATE.SUNSTONE||{},
'templateTableHTML': templateTableHTML,
'tabId': this.tabId,
'userCreationHTML': this.userCreation.html()
"element": this.element,
"sunstone_template": this.element.TEMPLATE.SUNSTONE||{},
"templateTableHTML": templateTableHTML,
"tabId": this.tabId,
"userCreationHTML": this.userCreation.html()
});
}
@@ -104,66 +104,73 @@ define(function(require) {
}
TemplateTable.setup(strippedTemplate, RESOURCE, this.element.ID, context, hiddenValues);
//===
// Change table Order
context.off("click", "#div_edit_table_order")
context.off("click", "#div_edit_table_order");
context.on("click", "#div_edit_table_order", function() {
$(".value_td_table_order", context).html('<select id="table_order_select">' +
'<option value="asc">' + Locale.tr("ascending") + '</option>' +
'<option value="desc">' + Locale.tr("descending") + '</option>' +
'</select>');
$(".value_td_table_order", context).html("<select id=\"table_order_select\">" +
"<option> </option>" +
"<option value=\"asc\">" + Locale.tr("ascending") + "</option>" +
"<option value=\"desc\">" + Locale.tr("descending") + "</option>" +
"</select>");
if (that.element.TEMPLATE.SUNSTONE && that.element.TEMPLATE.SUNSTONE.TABLE_ORDER) {
$('#table_order_select', context).val(that.element.TEMPLATE.SUNSTONE.TABLE_ORDER);
$("#table_order_select", context).val(that.element.TEMPLATE.SUNSTONE.TABLE_ORDER);
}
});
context.off("click", "#table_order_select")
context.on("click", "#table_order_select", function() {
context.off("change", "#table_order_select");
context.on("change", "#table_order_select", function() {
var sunstone_setting = {TABLE_ORDER : $(this).val()};
Sunstone.runAction("User.append_sunstone_setting_refresh", that.element.ID, sunstone_setting);
if (sunstone_setting.TABLE_ORDER !== ""){
Sunstone.runAction("User.append_sunstone_setting_refresh", that.element.ID, sunstone_setting);
}
});
// Change language
context.off("click", "#div_edit_language")
context.off("click", "#div_edit_language");
context.on("click", "#div_edit_language", function() {
$(".value_td_language", context).html('<select id="language_select">' +
Locale.language_options +
'</select>');
$(".value_td_language", context).html("<select id=\"language_select\">" +
"<option> </option>" +
Locale.language_options +
"</select>");
if (that.element.TEMPLATE.SUNSTONE && that.element.TEMPLATE.SUNSTONE.LANG) {
$('#language_select', context).val(that.element.TEMPLATE.SUNSTONE.LANG);
$("#language_select", context).val(that.element.TEMPLATE.SUNSTONE.LANG);
}
});
context.off("click", "#language_select")
context.on("click", "#language_select", function() {
context.off("change", "#language_select");
context.on("change", "#language_select", function() {
var sunstone_setting = {LANG : $(this).val()};
Sunstone.runAction("User.append_sunstone_setting_refresh", that.element.ID, sunstone_setting);
if (sunstone_setting.LANG !== ""){
Sunstone.runAction("User.append_sunstone_setting_refresh", that.element.ID, sunstone_setting);
}
});
// Change view
context.off("click", "#div_edit_view")
context.off("click", "#div_edit_view");
context.on("click", "#div_edit_view", function() {
var options = '';
$.each( config['available_views'], function(id, view) {
options += '<option value="'+view+'">'+view+'</option>';
var options = "<option> </option>";
$.each( config["available_views"], function(id, view) {
options += "<option value=\""+view+"\">"+view+"</option>";
});
$(".value_td_view", context).html('<select id="view_select">' +
$(".value_td_view", context).html("<select id=\"view_select\">" +
options +
'</select>');
"</select>");
if (that.element.TEMPLATE.SUNSTONE && that.element.TEMPLATE.SUNSTONE.DEFAULT_VIEW) {
$('#view_select', context).val(that.element.TEMPLATE.SUNSTONE.DEFAULT_VIEW);
$("#view_select", context).val(that.element.TEMPLATE.SUNSTONE.DEFAULT_VIEW);
}
});
context.off("click", "#view_select")
context.on("click", "#view_select", function() {
context.off("change", "#view_select");
context.on("change", "#view_select", function() {
var sunstone_setting = {DEFAULT_VIEW : $(this).val()};
Sunstone.runAction("User.append_sunstone_setting_refresh", that.element.ID, sunstone_setting);
if (sunstone_setting.DEFAULT_VIEW !== ""){
Sunstone.runAction("User.append_sunstone_setting_refresh", that.element.ID, sunstone_setting);
}
});
return false;
@@ -82,9 +82,10 @@ define(function(require) {
Tips.setup(context);
$( ".diskSlider", context).html(RangeSlider.html({
min: that.diskSize,
max: Humanize.sizeToMB("500GB")*1024,
max: Humanize.sizeToMB("1024GB")*1024,
initial: that.diskSize,
name: "resize"
name: "resize",
max_value: ""
}));
$( ".uinput-slider-val",context).prop('type', 'text');
$( ".uinput-slider-val",context).val(Humanize.size($( ".uinput-slider",context).val()));
@@ -115,7 +116,7 @@ define(function(require) {
$('#' + DIALOG_ID + 'Form', context).submit(function() {
var new_size = $( ".uinput-slider",context).val();
var new_size = $( ".uinput-slider-val",context).val();
new_size = Math.round(parseInt(new_size) / 1024);
new_size = new_size.toString();
var obj = {
@@ -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
}
+19 -3
View File
@@ -22,6 +22,7 @@ define(function(require){
var UserInputs = require('utils/user-inputs');
var WizardFields = require('utils/wizard-fields');
var DisksResizeTemplate = require('hbs!./disks-resize/html');
var Humanize = require('utils/humanize');
return {
'insert': _insert,
@@ -76,6 +77,16 @@ define(function(require){
disks = [template_disk]
}
if (opts.template_base_json) {
var template_base_disk = opts.template_base_json.VMTEMPLATE.TEMPLATE.DISK
var disks_base = []
if ($.isArray(template_base_disk)) {
disks_base = template_base_disk
} else if (!$.isEmptyObject(template_base_disk)) {
disks_base = [template_base_disk]
}
}
if (disks.length > 0) {
disksContext.html(DisksResizeTemplate());
@@ -101,6 +112,9 @@ define(function(require){
var diskContext;
$(".disksContainer", disksContext).html("");
$.each(disks, function(disk_id, disk) {
diskContext = $(
'<div class="row diskContainer">'+
@@ -110,8 +124,9 @@ define(function(require){
'<div class="large-12 columns diskSlider">' +
'</div>' +
'</div>').appendTo($(".disksContainer", disksContext));
diskContext.data('template_disk', disk);
if (disks_base) {
diskContext.data('template_disk', disks_base[disk_id]);
}
var disk_snapshot_total_size = 0;
if (disk.DISK_SNAPSHOT_TOTAL_SIZE != undefined) {
@@ -175,7 +190,7 @@ define(function(require){
if (disk.SIZE != undefined){
// Range from original size to size + 500GB
var min = parseInt(disk.SIZE);
var max = min + 512000;
var max = min + Humanize.sizeToMB("1024GB");
attr = UserInputs.parse(
"SIZE",
@@ -186,6 +201,7 @@ define(function(require){
"M|number|"+label+"||");
}
}
attr.max_value = "";
if(!opts.uinput_mb){
$(".diskSlider", diskContext).html(UserInputs.attributeInput(attr));
} else {
@@ -55,8 +55,7 @@ define(function(require) {
});
});
context.off("click", ".value_td_cluster .resource_list_select");
context.on("click", ".value_td_cluster .resource_list_select", function() {
context.on("change", ".value_td_cluster .resource_list_select", function() {
var newClusterId = $(this).val();
if (newClusterId != "") {
Sunstone.runAction(resourceType + ".addtocluster", [resourceId], newClusterId);
@@ -54,7 +54,6 @@ define(function(require) {
tick_val += opts.tick_size;
}
}
sliderId += 1;
return TemplateHTML(opts);
}
@@ -23,8 +23,8 @@
{{/if}}
<div class="large-8 small-6 columns">
<input id="input-{{sliderId}}" type="range" class="uinput-slider"
min="{{min}}" max="{{max}}" step="{{step}}"
value="{{initial}}"
min="{{min}}" max="{{max}}" step="{{step}}"
value="{{initial}}"
list="uinput-list-{{sliderId}}"
{{#if disabled}}disabled="true"{{/if}}/>
<datalist id="uinput-list-{{sliderId}}">
@@ -34,9 +34,9 @@
</datalist>
</div>
<div class="large-4 small-6 columns">
<input type="number" class="uinput-slider-val"
min="{{min}}" max="{{max}}" step="{{step}}"
value="{{initial}}"
<input type="number" class="uinput-slider-val"
min="{{min}}" max="{{max_value}}" step="{{step}}"
value="{{initial}}"
{{#unless wizard_field_disabled}}wizard_field="{{name}}"{{/unless}}
{{#if disabled}}disabled="true"{{/if}} required/>
</div>
@@ -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;
+1 -2
View File
@@ -715,13 +715,12 @@ end
##############################################################################
# GET Resource information
##############################################################################
get '/:resource/:id/template' do
@SunstoneServer.get_template(params[:resource], params[:id])
end
get '/:resource/:id' do
if params[:extended]
if params[:extended] && params[:extended] != "false"
@SunstoneServer.get_resource(params[:resource], params[:id], true)
else
@SunstoneServer.get_resource(params[:resource], params[:id])
+1 -1
View File
@@ -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"
+6 -1
View File
@@ -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);
+12 -12
View File
@@ -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)
+4 -5
View File
@@ -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);