mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-20 10:50:08 +03:00
Merge branch 'master' of git.opennebula.org:one
This commit is contained in:
commit
f1dcb31385
@ -64,10 +64,20 @@ AclManager::AclManager(SqlDB * _db) : db(_db), lastOID(-1)
|
||||
|
||||
if (lastOID == -1)
|
||||
{
|
||||
// Add a default rule
|
||||
// @1 VM+NET+IMAGE+TEMPLATE/* CREATE+INFO_POOL_MINE
|
||||
// Add a default rules for the ACL engine
|
||||
string error_str;
|
||||
add_rule(0x200000001LL, 0x2d400000000LL, 0x41LL, error_str);
|
||||
|
||||
// Users in group USERS can create and look at standard resources
|
||||
// @1 VM+NET+IMAGE+TEMPLATE/* CREATE+INFO_POOL_MINE
|
||||
add_rule(0x0000000200000001LL,
|
||||
0x000002d400000000LL,
|
||||
0x0000000000000041LL, error_str);
|
||||
|
||||
// Users in USERS can deploy VMs in any HOST
|
||||
// @1 HOST/* USE
|
||||
add_rule(0x0000000200000001LL,
|
||||
0x0000002400000000LL,
|
||||
0x0000000000000004LL, error_str);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -331,11 +331,11 @@ EOT
|
||||
"OpenNebula #{poolname} name or id"
|
||||
end
|
||||
|
||||
def OpenNebulaHelper.public_to_str(str)
|
||||
def OpenNebulaHelper.boolean_to_str(str)
|
||||
if str.to_i == 1
|
||||
public_str = "Y"
|
||||
"Yes"
|
||||
else
|
||||
public_str = "N"
|
||||
"No"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -25,10 +25,6 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
|
||||
"oneimage.yaml"
|
||||
end
|
||||
|
||||
def self.persistent_to_str(str)
|
||||
str.to_i==1 ? "Yes" : "No"
|
||||
end
|
||||
|
||||
def self.state_to_str(id)
|
||||
id = id.to_i
|
||||
state_str = Image::IMAGE_STATES[id]
|
||||
@ -68,9 +64,10 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
|
||||
puts str % ["TYPE", image.type_str]
|
||||
puts str % ["REGISTER TIME",
|
||||
OpenNebulaHelper.time_to_str(image['REGTIME'])]
|
||||
puts str % ["PUBLIC", OpenNebulaHelper.public_to_str(image['PUBLIC'])]
|
||||
puts str % ["PUBLIC",
|
||||
OpenNebulaHelper.boolean_to_str(image['PUBLIC'])]
|
||||
puts str % ["PERSISTENT",
|
||||
OneImageHelper.persistent_to_str(image["PERSISTENT"])]
|
||||
OneImageHelper.boolean_to_str(image["PERSISTENT"])]
|
||||
puts str % ["SOURCE", image['SOURCE']]
|
||||
puts str % ["STATE", image.short_state_str]
|
||||
puts str % ["RUNNING_VMS", image['RUNNING_VMS']]
|
||||
@ -112,12 +109,12 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
|
||||
|
||||
column :PUBLIC, "Whether the Image is public or not",
|
||||
:size=>3 do |d|
|
||||
OpenNebulaHelper.public_to_str(d["PUBLIC"])
|
||||
OpenNebulaHelper.boolean_to_str(d["PUBLIC"])
|
||||
end
|
||||
|
||||
column :PERSISTENT, "Whether the Image is persistent or not",
|
||||
:size=>3 do |d|
|
||||
OneImageHelper.persistent_to_str(d["PERSISTENT"])
|
||||
OneImageHelper.boolean_to_str(d["PERSISTENT"])
|
||||
end
|
||||
|
||||
column :STAT, "State of the Image", :size=>4 do |d|
|
||||
|
@ -53,7 +53,7 @@ class OneTemplateHelper < OpenNebulaHelper::OneHelper
|
||||
puts str % ["REGISTER TIME",
|
||||
OpenNebulaHelper.time_to_str(template['REGTIME'])]
|
||||
puts str % ["PUBLIC",
|
||||
OpenNebulaHelper.public_to_str(template['PUBLIC'])]
|
||||
OpenNebulaHelper.boolean_to_str(template['PUBLIC'])]
|
||||
puts
|
||||
|
||||
CLIHelper.print_header(str_h1 % "TEMPLATE CONTENTS",false)
|
||||
@ -87,7 +87,7 @@ class OneTemplateHelper < OpenNebulaHelper::OneHelper
|
||||
|
||||
column :PUBLIC, "Whether the Template is public or not",
|
||||
:size=>3 do |d|
|
||||
OpenNebulaHelper.public_to_str(d["PUBLIC"])
|
||||
OpenNebulaHelper.boolean_to_str(d["PUBLIC"])
|
||||
end
|
||||
|
||||
default :ID, :USER, :GROUP, :NAME, :REGTIME, :PUBLIC
|
||||
|
@ -70,16 +70,10 @@ 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 % ["MAIN_GROUP", user.gid]
|
||||
puts str % ["GROUP", user.gid]
|
||||
puts str % ["PASSWORD", user['PASSWORD']]
|
||||
puts str % ["ENABLED", user['ENABLED']]
|
||||
puts
|
||||
|
||||
CLIHelper.print_header(str_h1 % "GROUPS", false)
|
||||
CLIHelper.print_header("%-15s %-20s" % ["ID","NAME"])
|
||||
user.group_ids.each do |gid|
|
||||
puts "%-15s %-20s" % [gid, self.gid_to_str(gid.to_s)]
|
||||
end
|
||||
puts str % ["ENABLED",
|
||||
OpenNebulaHelper.boolean_to_str(user['ENABLED'])]
|
||||
end
|
||||
|
||||
def format_pool(pool, options, top=false)
|
||||
|
@ -55,7 +55,7 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
||||
puts str % ["ID", vn.id.to_s]
|
||||
puts str % ["USER", vn['UNAME']]
|
||||
puts str % ["GROUP", vn['GNAME']]
|
||||
puts str % ["PUBLIC", OpenNebulaHelper.public_to_str(vn['PUBLIC'])]
|
||||
puts str % ["PUBLIC", OpenNebulaHelper.boolean_to_str(vn['PUBLIC'])]
|
||||
|
||||
puts
|
||||
CLIHelper.print_header(str_h1 % ["VIRTUAL NETWORK TEMPLATE"], false)
|
||||
@ -107,8 +107,8 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
||||
end
|
||||
|
||||
column :PUBLIC, "Whether the Virtual Network is public or not",
|
||||
:size=>3 do |d|
|
||||
OpenNebulaHelper.public_to_str(d['PUBLIC'])
|
||||
:size=>1 do |d|
|
||||
OpenNebulaHelper.boolean_to_str(d['PUBLIC'])
|
||||
end
|
||||
|
||||
column :LEASES, "Number of this Virtual Network's given leases",
|
||||
|
@ -137,8 +137,10 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
Shows information for the given User
|
||||
EOT
|
||||
|
||||
command :show, show_desc, :userid, :options=>OpenNebulaHelper::XML do
|
||||
helper.show_resource(args[0],options)
|
||||
command :show, show_desc, [:userid, nil],
|
||||
:options=>OpenNebulaHelper::XML do
|
||||
user=args[0] || OpenNebula::User::SELF
|
||||
helper.show_resource(user,options)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -31,6 +31,8 @@ module OpenNebula
|
||||
:delgroup => "user.delgroup"
|
||||
}
|
||||
|
||||
SELF = -1
|
||||
|
||||
# Creates a User description with just its identifier
|
||||
# this method should be used to create plain User objects.
|
||||
# +id+ the id of the user
|
||||
@ -60,7 +62,7 @@ module OpenNebula
|
||||
# ---------------------------------------------------------------------
|
||||
# XML-RPC Methods for the User Object
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
|
||||
# Retrieves the information of the given User.
|
||||
def info()
|
||||
super(USER_METHODS[:info], 'USER')
|
||||
|
@ -214,14 +214,15 @@ module OpenNebula
|
||||
|
||||
str_line << n.collect {|n2|
|
||||
if n2 && n2.class==REXML::Element
|
||||
str = ind_tab + n2.name + "="
|
||||
str += n2.text if n2.text
|
||||
str = ""
|
||||
str << ind_tab << n2.name << '='
|
||||
str << attr_to_str(n2.text) if n2.text
|
||||
str
|
||||
end
|
||||
}.compact.join(","+ind_enter)
|
||||
}.compact.join(','+ind_enter)
|
||||
str_line<<" ]"
|
||||
else
|
||||
str_line<<n.name << "=" << n.text.to_s
|
||||
str_line << n.name << '=' << attr_to_str(n.text.to_s)
|
||||
end
|
||||
str_line
|
||||
end
|
||||
@ -284,6 +285,17 @@ module OpenNebula
|
||||
|
||||
hash
|
||||
end
|
||||
|
||||
private
|
||||
def attr_to_str(attr)
|
||||
attr.gsub!('"',"\\\"")
|
||||
|
||||
if attr.match(/[=,' ']/)
|
||||
return '"' + attr + '"'
|
||||
end
|
||||
|
||||
return attr
|
||||
end
|
||||
end
|
||||
|
||||
###########################################################################
|
||||
|
@ -27,6 +27,7 @@ void VMTemplateInstantiate::request_execute(xmlrpc_c::paramList const& paramList
|
||||
string name = xmlrpc_c::value_string(paramList.getString(2));
|
||||
|
||||
int rc, ouid, ogid, vid;
|
||||
bool pub;
|
||||
|
||||
Nebula& nd = Nebula::instance();
|
||||
VirtualMachinePool* vmpool = nd.get_vmpool();
|
||||
@ -51,6 +52,7 @@ void VMTemplateInstantiate::request_execute(xmlrpc_c::paramList const& paramList
|
||||
tmpl = rtmpl->clone_template();
|
||||
ouid = rtmpl->get_uid();
|
||||
ogid = rtmpl->get_gid();
|
||||
pub = rtmpl->isPublic();
|
||||
|
||||
rtmpl->unlock();
|
||||
|
||||
@ -61,7 +63,7 @@ void VMTemplateInstantiate::request_execute(xmlrpc_c::paramList const& paramList
|
||||
{
|
||||
AuthRequest ar(att.uid, att.gid);
|
||||
|
||||
ar.add_auth(auth_object, id, ogid, auth_op, ouid, false);
|
||||
ar.add_auth(auth_object, id, ogid, auth_op, ouid, pub);
|
||||
|
||||
VirtualMachine::set_auth_request(att.uid, ar, tmpl);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user