mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
6d86198765
@ -107,9 +107,9 @@ class AuthDriver < OpenNebulaDriver
|
||||
#build path for the auth action
|
||||
#/var/lib/one/remotes/auth/<driver>/authenticate
|
||||
authN_path = File.join(@local_scripts_path, driver)
|
||||
|
||||
command = File.join(authN_path,ACTION[:authN].downcase)
|
||||
command << ' ' << user << ' ' << password << ' ' << secret
|
||||
|
||||
command = File.join(authN_path,ACTION[:authN].downcase)
|
||||
command << " '" << user.gsub("'", '\'"\'"\'') << "' '" << password.gsub("'", '\'"\'"\'') << "' " << secret
|
||||
|
||||
local_action(command, request_id, ACTION[:authN])
|
||||
end
|
||||
|
@ -78,7 +78,13 @@ class Quota
|
||||
|
||||
IMAGE_USAGE = {
|
||||
:STORAGE => {
|
||||
:proc_info => lambda {|template| File.size(template['PATH']) },
|
||||
:proc_info => lambda {|template|
|
||||
if template['TYPE'] == 'DATABLOCK'
|
||||
template['SIZE'].to_i
|
||||
else
|
||||
File.size(template['PATH'])
|
||||
end
|
||||
},
|
||||
:xpath => 'SIZE'
|
||||
}
|
||||
}
|
||||
|
@ -37,14 +37,14 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
|
||||
return -1, "Can not read file: #{arg}"
|
||||
end
|
||||
else
|
||||
password = arg
|
||||
password = arg.dup
|
||||
end
|
||||
|
||||
if options[:driver] == OpenNebula::User::X509_AUTH
|
||||
password.delete!("\s")
|
||||
end
|
||||
|
||||
if options[:sha1]
|
||||
if options[:sha1] || options[:driver] == OpenNebula::User::CIPHER_AUTH
|
||||
require 'digest/sha1'
|
||||
password = Digest::SHA1.hexdigest(password)
|
||||
end
|
||||
@ -166,7 +166,7 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
|
||||
CLIHelper.print_header(str_h1 % "USER #{user['ID']} INFORMATION")
|
||||
puts str % ["ID", user.id.to_s]
|
||||
puts str % ["NAME", user.name]
|
||||
puts str % ["GROUP", user.gid]
|
||||
puts str % ["GROUP", user['GNAME']]
|
||||
puts str % ["PASSWORD", user['PASSWORD']]
|
||||
puts str % ["AUTH_DRIVER", user['AUTH_DRIVER']]
|
||||
|
||||
|
@ -275,11 +275,25 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
end
|
||||
|
||||
chauth_desc = <<-EOT.unindent
|
||||
Changes the User's auth driver
|
||||
Changes the User's auth driver and its password (optional)
|
||||
Examples:
|
||||
oneuser chauth my_user core
|
||||
oneuser chauth my_user core new_password
|
||||
oneuser chauth my_user core -r /tmp/mypass
|
||||
oneuser chauth my_user --ssh --key /home/oneadmin/.ssh/id_rsa
|
||||
oneuser chauth my_user --ssh -r /tmp/public_key
|
||||
oneuser chauth my_user --x509 --cert /tmp/my_cert.pem
|
||||
EOT
|
||||
|
||||
command :chauth, chauth_desc, :userid, :auth, [:password, nil],
|
||||
command :chauth, chauth_desc, :userid, [:auth, nil], [:password, nil],
|
||||
:options=>create_options do
|
||||
if options[:driver]
|
||||
driver = options[:driver]
|
||||
elsif args[1]
|
||||
driver = args[1]
|
||||
else
|
||||
exit_with_code 0, "An Auth driver should be specified"
|
||||
end
|
||||
|
||||
helper = OneUserHelper.new
|
||||
|
||||
@ -297,7 +311,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
helper.perform_action(args[0],
|
||||
options,
|
||||
"Auth driver and password changed") do |user|
|
||||
user.chauth(args[1], pass)
|
||||
user.chauth(driver, pass)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -64,15 +64,16 @@ class CloudAuth
|
||||
begin
|
||||
require core_auth[0]
|
||||
@server_auth = Kernel.const_get(core_auth[1]).new_client
|
||||
|
||||
token = @server_auth.login_token(expiration_time)
|
||||
@oneadmin_client ||= OpenNebula::Client.new(token, @conf[:one_xmlrpc])
|
||||
rescue => e
|
||||
raise e.message
|
||||
end
|
||||
end
|
||||
|
||||
def client(username)
|
||||
# Generate a new OpenNebula client for the target User, if the username
|
||||
# is nil the Client is generated for the server_admin
|
||||
# ussername:: _String_ Name of the User
|
||||
# [return] _Client_
|
||||
def client(username=nil)
|
||||
token = @server_auth.login_token(expiration_time,username)
|
||||
Client.new(token,@conf[:one_xmlrpc])
|
||||
end
|
||||
@ -97,7 +98,7 @@ class CloudAuth
|
||||
end
|
||||
|
||||
def update_userpool_cache
|
||||
@user_pool ||= OpenNebula::UserPool.new(@oneadmin_client)
|
||||
@user_pool = OpenNebula::UserPool.new(client)
|
||||
|
||||
rc = @user_pool.info
|
||||
if OpenNebula.is_error?(rc)
|
||||
|
@ -38,6 +38,9 @@ module OpenNebula
|
||||
# Driver name for default core authentication
|
||||
CORE_AUTH = "core"
|
||||
|
||||
# Driver name for default core authentication
|
||||
CIPHER_AUTH = "server_cipher"
|
||||
|
||||
# Driver name for ssh authentication
|
||||
SSH_AUTH = "ssh"
|
||||
|
||||
|
@ -198,6 +198,8 @@ PoolObjectSQL * PoolSQL::get(
|
||||
}
|
||||
else
|
||||
{
|
||||
map<string,PoolObjectSQL *>::iterator name_index;
|
||||
|
||||
objectsql = create();
|
||||
|
||||
objectsql->oid = oid;
|
||||
@ -214,6 +216,19 @@ PoolObjectSQL * PoolSQL::get(
|
||||
}
|
||||
|
||||
string okey = key(objectsql->name,objectsql->uid);
|
||||
name_index = name_pool.find(okey);
|
||||
|
||||
if ( name_index != name_pool.end() )
|
||||
{
|
||||
name_index->second->lock();
|
||||
|
||||
PoolObjectSQL * tmp_ptr = name_index->second;
|
||||
|
||||
name_pool.erase(okey);
|
||||
pool.erase(tmp_ptr->oid);
|
||||
|
||||
delete tmp_ptr;
|
||||
}
|
||||
|
||||
pool.insert(make_pair(objectsql->oid,objectsql));
|
||||
name_pool.insert(make_pair(okey, objectsql));
|
||||
|
@ -170,7 +170,10 @@ public:
|
||||
//Should be set to MAX_POOL -1
|
||||
for (int i=0 ; i < 14999 ; i++)
|
||||
{
|
||||
create_allocate(i,"A Test object");
|
||||
ostringstream name;
|
||||
name << "A Test object " << i;
|
||||
|
||||
create_allocate(i,name.str());
|
||||
|
||||
obj_lock = pool->get(i, true);
|
||||
CPPUNIT_ASSERT(obj_lock != 0);
|
||||
@ -178,16 +181,22 @@ public:
|
||||
|
||||
for (int i=14999 ; i < 15200 ; i++) //Works with just 1 cache line
|
||||
{
|
||||
create_allocate(i,"A Test object");
|
||||
ostringstream name;
|
||||
name << "A Test object " << i;
|
||||
|
||||
create_allocate(i,name.str());
|
||||
}
|
||||
|
||||
for (int i=14999; i < 15200 ; i++)
|
||||
{
|
||||
ostringstream name;
|
||||
name << "A Test object " << i;
|
||||
|
||||
obj = pool->get(i, true);
|
||||
CPPUNIT_ASSERT(obj != 0);
|
||||
|
||||
CPPUNIT_ASSERT(obj->number == i);
|
||||
CPPUNIT_ASSERT(obj->text == "A Test object");
|
||||
CPPUNIT_ASSERT(obj->text == name.str());
|
||||
obj->unlock();
|
||||
}
|
||||
|
||||
|
@ -35,9 +35,14 @@ DST_HOST=`arg_host $DST`
|
||||
|
||||
DST_DIR=`dirname $DST_PATH`
|
||||
|
||||
log "Moving $SRC_PATH"
|
||||
exec_and_log "$SSH $DST_HOST mkdir -p $DST_DIR" \
|
||||
"Unable to create directory $DST_DIR"
|
||||
exec_and_log "$SCP -r $SRC $DST" \
|
||||
"Could not copy $SRC to $DST"
|
||||
exec_and_log "$SSH $SRC_HOST rm -rf $SRC_PATH"
|
||||
if full_src_and_dst_equal; then
|
||||
log "Not moving $SRC to $DST, they are the same path"
|
||||
else
|
||||
log "Moving $SRC_PATH"
|
||||
exec_and_log "$SSH $DST_HOST mkdir -p $DST_DIR" \
|
||||
"Unable to create directory $DST_DIR"
|
||||
exec_and_log "$SCP -r $SRC $DST" \
|
||||
"Could not copy $SRC to $DST"
|
||||
exec_and_log "$SSH $SRC_HOST rm -rf $SRC_PATH"
|
||||
fi
|
||||
|
||||
|
@ -49,6 +49,20 @@ function fix_dir_slashes
|
||||
dirname "$1/file" | $SED 's/\/+/\//g'
|
||||
}
|
||||
|
||||
function get_compare_target
|
||||
{
|
||||
echo "$1" | $SED 's/\/+/\//g' | $SED 's/\/images$//'
|
||||
}
|
||||
|
||||
function full_src_and_dst_equal
|
||||
{
|
||||
s=`get_compare_target "$SRC"`
|
||||
d=`get_compare_target "$DST"`
|
||||
|
||||
[ "$s" == "$d" ]
|
||||
|
||||
}
|
||||
|
||||
function fix_var_slashes
|
||||
{
|
||||
ONE_LOCAL_VAR=`fix_dir_slashes "$ONE_LOCAL_VAR"`
|
||||
|
Loading…
x
Reference in New Issue
Block a user