1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-12 09:17:41 +03:00

Merge branch 'master' into feature-602

This commit is contained in:
Carlos Martín 2011-11-28 02:34:49 -08:00
commit abdf5116b1
7 changed files with 73 additions and 13 deletions

View File

@ -44,7 +44,7 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
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

View File

@ -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

View File

@ -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"

View File

@ -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));

View File

@ -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();
}

View File

@ -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

View File

@ -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"`