mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-16 22:50:10 +03:00
Merge branch 'master' of git.opennebula.org:one
This commit is contained in:
commit
e8d4ec1dd8
@ -51,11 +51,12 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
||||
CLIHelper.print_header(str_h1 %
|
||||
["VIRTUAL NETWORK #{vn.id.to_s} INFORMATION"])
|
||||
|
||||
str="%-10s: %-20s"
|
||||
str="%-15s: %-20s"
|
||||
puts str % ["ID", vn.id.to_s]
|
||||
puts str % ["USER", vn['UNAME']]
|
||||
puts str % ["GROUP", vn['GNAME']]
|
||||
puts str % ["PUBLIC", OpenNebulaHelper.boolean_to_str(vn['PUBLIC'])]
|
||||
puts str % ["USED LEASES", vn['TOTAL_LEASES']]
|
||||
|
||||
puts
|
||||
CLIHelper.print_header(str_h1 % ["VIRTUAL NETWORK TEMPLATE"], false)
|
||||
|
@ -33,8 +33,6 @@ public class User extends PoolElement{
|
||||
private static final String DELETE = METHOD_PREFIX + "delete";
|
||||
private static final String PASSWD = METHOD_PREFIX + "passwd";
|
||||
private static final String CHGRP = METHOD_PREFIX + "chgrp";
|
||||
private static final String ADDGROUP = METHOD_PREFIX + "addgroup";
|
||||
private static final String DELGROUP = METHOD_PREFIX + "delgroup";
|
||||
|
||||
/**
|
||||
* Creates a new User representation.
|
||||
@ -127,32 +125,6 @@ public class User extends PoolElement{
|
||||
return client.call(CHGRP, id, gid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds this user to a secondary group
|
||||
*
|
||||
* @param client XML-RPC Client.
|
||||
* @param id The user id (uid) of the target user we want to modify.
|
||||
* @param gid The new group ID.
|
||||
* @return If an error occurs the error message contains the reason.
|
||||
*/
|
||||
public static OneResponse addgroup(Client client, int id, int gid)
|
||||
{
|
||||
return client.call(ADDGROUP, id, gid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes this user from a secondary group
|
||||
*
|
||||
* @param client XML-RPC Client.
|
||||
* @param id The user id (uid) of the target user we want to modify.
|
||||
* @param gid The new group ID.
|
||||
* @return If an error occurs the error message contains the reason.
|
||||
*/
|
||||
public static OneResponse delgroup(Client client, int id, int gid)
|
||||
{
|
||||
return client.call(DELGROUP, id, gid);
|
||||
}
|
||||
|
||||
// =================================
|
||||
// Instanced object XML-RPC methods
|
||||
// =================================
|
||||
@ -203,28 +175,6 @@ public class User extends PoolElement{
|
||||
return chgrp(client, id, gid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds this user to a secondary group
|
||||
*
|
||||
* @param gid The new group ID.
|
||||
* @return If an error occurs the error message contains the reason.
|
||||
*/
|
||||
public OneResponse addgroup(int gid)
|
||||
{
|
||||
return addgroup(client, id, gid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes this user from a secondary group
|
||||
*
|
||||
* @param gid The new group ID.
|
||||
* @return If an error occurs the error message contains the reason.
|
||||
*/
|
||||
public OneResponse delgroup(int gid)
|
||||
{
|
||||
return delgroup(client, id, gid);
|
||||
}
|
||||
|
||||
// =================================
|
||||
// Helpers
|
||||
// =================================
|
||||
@ -239,16 +189,4 @@ public class User extends PoolElement{
|
||||
String enabled = xpath("ENABLED");
|
||||
return enabled != null && enabled.equals("1");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not the user is part of the group
|
||||
*
|
||||
* @param gid The group ID.
|
||||
* @return whether or not the user is part of the group
|
||||
*/
|
||||
public boolean isPartOf(int gid)
|
||||
{
|
||||
String res = xpath("GROUPS/ID[.="+gid+"]");
|
||||
return res != null && res.equals(""+gid);
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class AclTest
|
||||
{
|
||||
for(Acl rule : aclPool)
|
||||
{
|
||||
if( rule.id() != 0 )
|
||||
if( rule.id() != 0 && rule.id() != 1 )
|
||||
{
|
||||
rule.delete();
|
||||
}
|
||||
@ -81,7 +81,7 @@ public class AclTest
|
||||
res = aclPool.info();
|
||||
assertTrue( !res.isError() );
|
||||
|
||||
assertEquals(1, aclPool.getLength());
|
||||
assertEquals(2, aclPool.getLength());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -219,13 +219,13 @@ public class AclTest
|
||||
assertTrue( !res.isError() );
|
||||
|
||||
aclPool.info();
|
||||
assertTrue( aclPool.getLength() == 2 );
|
||||
assertTrue( aclPool.getLength() == 3 );
|
||||
|
||||
res = Acl.delete(client, res.getIntMessage());
|
||||
assertTrue( !res.isError() );
|
||||
|
||||
aclPool.info();
|
||||
assertTrue( aclPool.getLength() == 1 );
|
||||
assertTrue( aclPool.getLength() == 2 );
|
||||
}
|
||||
catch (RuleParseException e)
|
||||
{
|
||||
|
@ -133,7 +133,8 @@ public class GroupTest
|
||||
}
|
||||
|
||||
// Commented out, secondary groups do not exist any more
|
||||
// @Test
|
||||
/*
|
||||
@Test
|
||||
public void userGroupRelations()
|
||||
{
|
||||
Hashtable<String, User> users = new Hashtable<String, User>();
|
||||
@ -221,5 +222,5 @@ public class GroupTest
|
||||
assertTrue( groups.get("d").contains( users.get("c").id() ) );
|
||||
assertTrue( groups.get("d").contains( users.get("d").id() ) );
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
@ -26,9 +26,7 @@ module OpenNebula
|
||||
:allocate => "user.allocate",
|
||||
:delete => "user.delete",
|
||||
:passwd => "user.passwd",
|
||||
:chgrp => "user.chgrp",
|
||||
:addgroup => "user.addgroup",
|
||||
:delgroup => "user.delgroup"
|
||||
:chgrp => "user.chgrp"
|
||||
}
|
||||
|
||||
SELF = -1
|
||||
@ -115,21 +113,5 @@ module OpenNebula
|
||||
def gid
|
||||
self['GID'].to_i
|
||||
end
|
||||
|
||||
# Returns whether or not the user is part of the group 'gid'
|
||||
def is_part_of(gid)
|
||||
return self["GROUPS/ID[.=#{gid}]"] != nil
|
||||
end
|
||||
|
||||
# Returns an array with the numeric group ids
|
||||
def group_ids
|
||||
array = Array.new
|
||||
|
||||
self.each("GROUPS/ID") do |id|
|
||||
array << id.text.to_i
|
||||
end
|
||||
|
||||
return array
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user