1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-04-01 06:50:25 +03:00

Feature #862: Update Java OCA to use the new permissions

This commit is contained in:
Carlos Martín 2012-01-10 18:56:51 +01:00
parent 9e586e8ef0
commit bd4df10204
12 changed files with 473 additions and 173 deletions

View File

@ -100,6 +100,77 @@ public abstract class PoolElement {
catch (Exception e) {}
}
/**
* Changes the permissions
*
* @param client XML-RPC Client.
* @param method XML-RPC method.
* @param id The id of the target object.
* @param owner_u 1 to allow, 0 deny, -1 do not change
* @param owner_m 1 to allow, 0 deny, -1 do not change
* @param owner_a 1 to allow, 0 deny, -1 do not change
* @param group_u 1 to allow, 0 deny, -1 do not change
* @param group_m 1 to allow, 0 deny, -1 do not change
* @param group_a 1 to allow, 0 deny, -1 do not change
* @param other_u 1 to allow, 0 deny, -1 do not change
* @param other_m 1 to allow, 0 deny, -1 do not change
* @param other_a 1 to allow, 0 deny, -1 do not change
* @return If an error occurs the error message contains the reason.
*/
protected static OneResponse chmod(Client client, String method, int id,
int owner_u, int owner_m, int owner_a,
int group_u, int group_m, int group_a,
int other_u, int other_m, int other_a)
{
return client.call(method, id,
owner_u, owner_m, owner_a,
group_u, group_m, group_a,
other_u, other_m, other_a);
}
/**
* Changes the permissions
*
* @param client XML-RPC Client.
* @param method XML-RPC method.
* @param id The id of the target object.
* @param octet Permissions octed , e.g. 640
* @return If an error occurs the error message contains the reason.
*/
protected static OneResponse chmod(Client client, String method, int id,
String octet)
{
int owner_u = (Integer.parseInt(octet.substring(0, 1)) & 4) != 0 ? 1 : 0;
int owner_m = (Integer.parseInt(octet.substring(0, 1)) & 2) != 0 ? 1 : 0;
int owner_a = (Integer.parseInt(octet.substring(0, 1)) & 1) != 0 ? 1 : 0;
int group_u = (Integer.parseInt(octet.substring(1, 2)) & 4) != 0 ? 1 : 0;
int group_m = (Integer.parseInt(octet.substring(1, 2)) & 2) != 0 ? 1 : 0;
int group_a = (Integer.parseInt(octet.substring(1, 2)) & 1) != 0 ? 1 : 0;
int other_u = (Integer.parseInt(octet.substring(2, 3)) & 4) != 0 ? 1 : 0;
int other_m = (Integer.parseInt(octet.substring(2, 3)) & 2) != 0 ? 1 : 0;
int other_a = (Integer.parseInt(octet.substring(2, 3)) & 1) != 0 ? 1 : 0;
return chmod(client, method, id,
owner_u, owner_m, owner_a,
group_u, group_m, group_a,
other_u, other_m, other_a);
}
/**
* Changes the template permissions
*
* @param client XML-RPC Client.
* @param method XML-RPC method.
* @param id The id of the target object.
* @param octet Permissions octed , e.g. 640
* @return If an error occurs the error message contains the reason.
*/
protected static OneResponse chmod(Client client, String method, int id,
int octet)
{
return chmod(client, method, id, Integer.toString(octet));
}
/**
* Returns the element's ID.
* @return the element's ID.

View File

@ -69,17 +69,10 @@ public class Acl extends PoolElement{
HashMap<String, Long> tmpRights = new HashMap<String, Long>();
tmpRights.put("CREATE" , 0x1L);
tmpRights.put("DELETE" , 0x2L);
tmpRights.put("USE" , 0x4L);
tmpRights.put("MANAGE" , 0x8L);
tmpRights.put("INFO" , 0x10L);
tmpRights.put("INFO_POOL" , 0x20L);
tmpRights.put("INFO_POOL_MINE", 0x40L);
tmpRights.put("INSTANTIATE" , 0x80L);
tmpRights.put("CHOWN" , 0x100L);
tmpRights.put("DEPLOY" , 0x200L);
tmpRights.put("CHAUTH" , 0x400L);
tmpRights.put("USE" , 0x1L);
tmpRights.put("MANAGE" , 0x2L);
tmpRights.put("ADMIN" , 0x4L);
tmpRights.put("CREATE" , 0x8L);
RIGHTS = Collections.unmodifiableMap(tmpRights);
}
@ -328,7 +321,7 @@ public class Acl extends PoolElement{
+ "' does not exist");
}
ret += RIGHTS.get(right);
ret = ret | RIGHTS.get(right);
}
return Long.toHexString(ret);

View File

@ -33,8 +33,8 @@ public class Image extends PoolElement
private static final String DELETE = METHOD_PREFIX + "delete";
private static final String UPDATE = METHOD_PREFIX + "update";
private static final String ENABLE = METHOD_PREFIX + "enable";
private static final String PUBLISH = METHOD_PREFIX + "publish";
private static final String CHOWN = METHOD_PREFIX + "chown";
private static final String CHMOD = METHOD_PREFIX + "chmod";
private static final String CHTYPE = METHOD_PREFIX + "chtype";
private static final String[] IMAGE_STATES =
@ -146,7 +146,9 @@ public class Image extends PoolElement
*/
public static OneResponse publish(Client client, int id, boolean publish)
{
return client.call(PUBLISH, id, publish);
int group_u = publish ? 1 : 0;
return chmod(client, id, -1, -1, -1, group_u, -1, -1, -1, -1, -1);
}
/**
@ -163,6 +165,33 @@ public class Image extends PoolElement
return client.call(CHOWN, id, uid, gid);
}
/**
* Changes the Image permissions
*
* @param client XML-RPC Client.
* @param id The image id of the target image we want to modify.
* @param owner_u 1 to allow, 0 deny, -1 do not change
* @param owner_m 1 to allow, 0 deny, -1 do not change
* @param owner_a 1 to allow, 0 deny, -1 do not change
* @param group_u 1 to allow, 0 deny, -1 do not change
* @param group_m 1 to allow, 0 deny, -1 do not change
* @param group_a 1 to allow, 0 deny, -1 do not change
* @param other_u 1 to allow, 0 deny, -1 do not change
* @param other_m 1 to allow, 0 deny, -1 do not change
* @param other_a 1 to allow, 0 deny, -1 do not change
* @return If an error occurs the error message contains the reason.
*/
public static OneResponse chmod(Client client, int id,
int owner_u, int owner_m, int owner_a,
int group_u, int group_m, int group_a,
int other_u, int other_m, int other_a)
{
return chmod(client, CHMOD, id,
owner_u, owner_m, owner_a,
group_u, group_m, group_a,
other_u, other_m, other_a);
}
/**
* Changes the Image type
*
@ -288,6 +317,30 @@ public class Image extends PoolElement
return chown(client, id, uid, gid);
}
/**
* Changes the Image permissions
*
* @param owner_u 1 to allow, 0 deny, -1 do not change
* @param owner_m 1 to allow, 0 deny, -1 do not change
* @param owner_a 1 to allow, 0 deny, -1 do not change
* @param group_u 1 to allow, 0 deny, -1 do not change
* @param group_m 1 to allow, 0 deny, -1 do not change
* @param group_a 1 to allow, 0 deny, -1 do not change
* @param other_u 1 to allow, 0 deny, -1 do not change
* @param other_m 1 to allow, 0 deny, -1 do not change
* @param other_a 1 to allow, 0 deny, -1 do not change
* @return If an error occurs the error message contains the reason.
*/
public OneResponse chmod(int owner_u, int owner_m, int owner_a,
int group_u, int group_m, int group_a,
int other_u, int other_m, int other_a)
{
return chmod(client, id,
owner_u, owner_m, owner_a,
group_u, group_m, group_a,
other_u, other_m, other_a);
}
/**
* Changes the owner
*
@ -393,15 +446,4 @@ public class Image extends PoolElement
{
return state() != 3;
}
/**
* Returns true if the image is public.
*
* @return True if the image is public.
*/
public boolean isPublic()
{
String isPub = xpath("PUBLIC");
return isPub != null && isPub.equals("1");
}
}

View File

@ -32,8 +32,8 @@ public class Template extends PoolElement
private static final String INFO = METHOD_PREFIX + "info";
private static final String DELETE = METHOD_PREFIX + "delete";
private static final String UPDATE = METHOD_PREFIX + "update";
private static final String PUBLISH = METHOD_PREFIX + "publish";
private static final String CHOWN = METHOD_PREFIX + "chown";
private static final String CHMOD = METHOD_PREFIX + "chmod";
private static final String INSTANTIATE = METHOD_PREFIX + "instantiate";
/**
@ -120,7 +120,9 @@ public class Template extends PoolElement
*/
public static OneResponse publish(Client client, int id, boolean publish)
{
return client.call(PUBLISH, id, publish);
int group_u = publish ? 1 : 0;
return chmod(client, id, -1, -1, -1, group_u, -1, -1, -1, -1, -1);
}
/**
@ -137,6 +139,33 @@ public class Template extends PoolElement
return client.call(CHOWN, id, uid, gid);
}
/**
* Changes the template permissions
*
* @param client XML-RPC Client.
* @param id The template id of the target template.
* @param owner_u 1 to allow, 0 deny, -1 do not change
* @param owner_m 1 to allow, 0 deny, -1 do not change
* @param owner_a 1 to allow, 0 deny, -1 do not change
* @param group_u 1 to allow, 0 deny, -1 do not change
* @param group_m 1 to allow, 0 deny, -1 do not change
* @param group_a 1 to allow, 0 deny, -1 do not change
* @param other_u 1 to allow, 0 deny, -1 do not change
* @param other_m 1 to allow, 0 deny, -1 do not change
* @param other_a 1 to allow, 0 deny, -1 do not change
* @return If an error occurs the error message contains the reason.
*/
public static OneResponse chmod(Client client, int id,
int owner_u, int owner_m, int owner_a,
int group_u, int group_m, int group_a,
int other_u, int other_m, int other_a)
{
return chmod(client, CHMOD, id,
owner_u, owner_m, owner_a,
group_u, group_m, group_a,
other_u, other_m, other_a);
}
/**
* Creates a VM instance from a Template
*
@ -253,6 +282,30 @@ public class Template extends PoolElement
return chown(-1, gid);
}
/**
* Changes the template permissions
*
* @param owner_u 1 to allow, 0 deny, -1 do not change
* @param owner_m 1 to allow, 0 deny, -1 do not change
* @param owner_a 1 to allow, 0 deny, -1 do not change
* @param group_u 1 to allow, 0 deny, -1 do not change
* @param group_m 1 to allow, 0 deny, -1 do not change
* @param group_a 1 to allow, 0 deny, -1 do not change
* @param other_u 1 to allow, 0 deny, -1 do not change
* @param other_m 1 to allow, 0 deny, -1 do not change
* @param other_a 1 to allow, 0 deny, -1 do not change
* @return If an error occurs the error message contains the reason.
*/
public OneResponse chmod(int owner_u, int owner_m, int owner_a,
int group_u, int group_m, int group_a,
int other_u, int other_m, int other_a)
{
return chmod(client, id,
owner_u, owner_m, owner_a,
group_u, group_m, group_a,
other_u, other_m, other_a);
}
/**
* Creates a VM instance from a Template
*
@ -277,15 +330,4 @@ public class Template extends PoolElement
// =================================
// Helpers
// =================================
/**
* Returns true if the template is public.
*
* @return True if the template is public.
*/
public boolean isPublic()
{
String isPub = xpath("PUBLIC");
return isPub != null && isPub.equals("1");
}
}

View File

@ -36,6 +36,7 @@ public class VirtualMachine extends PoolElement{
private static final String MIGRATE = METHOD_PREFIX + "migrate";
private static final String SAVEDISK = METHOD_PREFIX + "savedisk";
private static final String CHOWN = METHOD_PREFIX + "chown";
private static final String CHMOD = METHOD_PREFIX + "chmod";
private static final String[] VM_STATES =
{
@ -213,6 +214,33 @@ public class VirtualMachine extends PoolElement{
return client.call(CHOWN, id, uid, gid);
}
/**
* Changes the VM permissions
*
* @param client XML-RPC Client.
* @param id The VM id of the target VM.
* @param owner_u 1 to allow, 0 deny, -1 do not change
* @param owner_m 1 to allow, 0 deny, -1 do not change
* @param owner_a 1 to allow, 0 deny, -1 do not change
* @param group_u 1 to allow, 0 deny, -1 do not change
* @param group_m 1 to allow, 0 deny, -1 do not change
* @param group_a 1 to allow, 0 deny, -1 do not change
* @param other_u 1 to allow, 0 deny, -1 do not change
* @param other_m 1 to allow, 0 deny, -1 do not change
* @param other_a 1 to allow, 0 deny, -1 do not change
* @return If an error occurs the error message contains the reason.
*/
public static OneResponse chmod(Client client, int id,
int owner_u, int owner_m, int owner_a,
int group_u, int group_m, int group_a,
int other_u, int other_m, int other_a)
{
return chmod(client, CHMOD, id,
owner_u, owner_m, owner_a,
group_u, group_m, group_a,
other_u, other_m, other_a);
}
// =================================
// Instanced object XML-RPC methods
// =================================
@ -345,6 +373,31 @@ public class VirtualMachine extends PoolElement{
return chown(-1, gid);
}
/**
* Changes the VM permissions
*
* @param owner_u 1 to allow, 0 deny, -1 do not change
* @param owner_m 1 to allow, 0 deny, -1 do not change
* @param owner_a 1 to allow, 0 deny, -1 do not change
* @param group_u 1 to allow, 0 deny, -1 do not change
* @param group_m 1 to allow, 0 deny, -1 do not change
* @param group_a 1 to allow, 0 deny, -1 do not change
* @param other_u 1 to allow, 0 deny, -1 do not change
* @param other_m 1 to allow, 0 deny, -1 do not change
* @param other_a 1 to allow, 0 deny, -1 do not change
* @return If an error occurs the error message contains the reason.
*/
public OneResponse chmod(int owner_u, int owner_m, int owner_a,
int group_u, int group_m, int group_a,
int other_u, int other_m, int other_a)
{
return chmod(client, id,
owner_u, owner_m, owner_a,
group_u, group_m, group_a,
other_u, other_m, other_a);
}
// =================================
// Helpers
// =================================

View File

@ -31,10 +31,10 @@ public class VirtualNetwork extends PoolElement{
private static final String ALLOCATE = METHOD_PREFIX + "allocate";
private static final String INFO = METHOD_PREFIX + "info";
private static final String DELETE = METHOD_PREFIX + "delete";
private static final String PUBLISH = METHOD_PREFIX + "publish";
private static final String ADDLEASES = METHOD_PREFIX + "addleases";
private static final String RMLEASES = METHOD_PREFIX + "rmleases";
private static final String CHOWN = METHOD_PREFIX + "chown";
private static final String CHMOD = METHOD_PREFIX + "chmod";
private static final String UPDATE = METHOD_PREFIX + "update";
private static final String HOLD = METHOD_PREFIX + "hold";
private static final String RELEASE = METHOD_PREFIX + "release";
@ -112,7 +112,9 @@ public class VirtualNetwork extends PoolElement{
*/
public static OneResponse publish(Client client, int id, boolean publish)
{
return client.call(PUBLISH, id, publish);
int group_u = publish ? 1 : 0;
return chmod(client, id, -1, -1, -1, group_u, -1, -1, -1, -1, -1);
}
/**
@ -181,6 +183,33 @@ public class VirtualNetwork extends PoolElement{
return client.call(CHOWN, id, uid, gid);
}
/**
* Changes the VirtualNetwork permissions
*
* @param client XML-RPC Client.
* @param id The virtual network id (nid) of the target network.
* @param owner_u 1 to allow, 0 deny, -1 do not change
* @param owner_m 1 to allow, 0 deny, -1 do not change
* @param owner_a 1 to allow, 0 deny, -1 do not change
* @param group_u 1 to allow, 0 deny, -1 do not change
* @param group_m 1 to allow, 0 deny, -1 do not change
* @param group_a 1 to allow, 0 deny, -1 do not change
* @param other_u 1 to allow, 0 deny, -1 do not change
* @param other_m 1 to allow, 0 deny, -1 do not change
* @param other_a 1 to allow, 0 deny, -1 do not change
* @return If an error occurs the error message contains the reason.
*/
public static OneResponse chmod(Client client, int id,
int owner_u, int owner_m, int owner_a,
int group_u, int group_m, int group_a,
int other_u, int other_m, int other_a)
{
return chmod(client, CHMOD, id,
owner_u, owner_m, owner_a,
group_u, group_m, group_a,
other_u, other_m, other_a);
}
/**
* Replaces the VirtualNetwork template contents.
*
@ -356,6 +385,30 @@ public class VirtualNetwork extends PoolElement{
return chown(-1, gid);
}
/**
* Changes the VirtualNetwork permissions
*
* @param owner_u 1 to allow, 0 deny, -1 do not change
* @param owner_m 1 to allow, 0 deny, -1 do not change
* @param owner_a 1 to allow, 0 deny, -1 do not change
* @param group_u 1 to allow, 0 deny, -1 do not change
* @param group_m 1 to allow, 0 deny, -1 do not change
* @param group_a 1 to allow, 0 deny, -1 do not change
* @param other_u 1 to allow, 0 deny, -1 do not change
* @param other_m 1 to allow, 0 deny, -1 do not change
* @param other_a 1 to allow, 0 deny, -1 do not change
* @return If an error occurs the error message contains the reason.
*/
public OneResponse chmod(int owner_u, int owner_m, int owner_a,
int group_u, int group_m, int group_a,
int other_u, int other_m, int other_a)
{
return chmod(client, id,
owner_u, owner_m, owner_a,
group_u, group_m, group_a,
other_u, other_m, other_a);
}
/**
* Replaces the VirtualNetwork template contents.
*
@ -371,14 +424,4 @@ public class VirtualNetwork extends PoolElement{
// Helpers
// =================================
/**
* Returns true if the Virtual Network is public.
*
* @return True if the Virtual Network is public.
*/
public boolean isPublic()
{
String isPub = xpath("PUBLIC");
return isPub != null && isPub.equals("1");
}
}

View File

@ -88,7 +88,7 @@ public class AclTest
public void hexAllocate()
{
// Allocate rule "#1 VM+HOST/@1 INFO+CREATE"
res = Acl.allocate(client, "0x100000001", "0x3200000001", "0x11");
res = Acl.allocate(client, "0x100000001", "0x3200000001", "0x8");
assertTrue( !res.isError() );
aclPool.info();
@ -99,15 +99,15 @@ public class AclTest
assertEquals(res.getIntMessage(), acl.id());
assertEquals(0x100000001L, acl.user());
assertEquals(0x3200000001L, acl.resource());
assertEquals(0x11L, acl.rights());
assertEquals("#1 VM+HOST/@1 CREATE+INFO", acl.toString());
assertEquals(0x8L, acl.rights());
assertEquals("#1 VM+HOST/@1 CREATE",acl.toString());
}
@Test
public void numericAllocate()
{
// Allocate rule "#1 VM+HOST/@1 INFO+CREATE"
res = Acl.allocate(client, 0x100000001L, 214748364801L, 0x11L);
// Allocate rule "#1 VM+HOST/@1 USE"
res = Acl.allocate(client, 0x100000001L, 214748364801L, 0x1L);
assertTrue( !res.isError() );
aclPool.info();
@ -118,8 +118,8 @@ public class AclTest
assertEquals(res.getIntMessage(), acl.id());
assertEquals(0x100000001L, acl.user());
assertEquals(0x3200000001L, acl.resource());
assertEquals(0x11L, acl.rights());
assertEquals("#1 VM+HOST/@1 CREATE+INFO", acl.toString());
assertEquals(0x1L, acl.rights());
assertEquals("#1 VM+HOST/@1 USE", acl.toString());
}
@Test
@ -127,7 +127,7 @@ public class AclTest
{
try
{
res = Acl.allocate(client, "@507 IMAGE/#456 CREATE");
res = Acl.allocate(client, "@507 IMAGE/#456 MANAGE");
assertTrue( !res.isError() );
aclPool.info();
@ -138,8 +138,8 @@ public class AclTest
assertEquals(res.getIntMessage(), acl.id());
assertEquals(0x2000001fbL, acl.user());
assertEquals(0x81000001c8L, acl.resource());
assertEquals(0x1L, acl.rights());
assertEquals("@507 IMAGE/#456 CREATE", acl.toString());
assertEquals(0x2L, acl.rights());
assertEquals("@507 IMAGE/#456 MANAGE", acl.toString());
}
catch (RuleParseException e)
{
@ -151,12 +151,12 @@ public class AclTest
public void parseRules()
{
String[] rules = {
"#3 TEMPLATE/#0 INFO",
"#2 IMAGE/#0 INFO",
"@107 IMAGE+TEMPLATE/@100 INFO",
"* VM+IMAGE+TEMPLATE/@100 CREATE+INFO+INFO_POOL",
"#2345 VM+IMAGE+TEMPLATE/* CREATE+INFO+INFO_POOL+INFO_POOL_MINE+INSTANTIATE",
"@7 HOST/@100 INFO+INFO_POOL+USE+DEPLOY",
"#3 TEMPLATE/#0 USE",
"#2 IMAGE/#0 USE",
"@107 IMAGE+TEMPLATE/@100 USE",
"* VM+IMAGE+TEMPLATE/@100 CREATE+USE",
"#2345 VM+IMAGE+TEMPLATE/* CREATE+USE",
"@7 HOST/@100 USE+MANAGE",
};
long[] users = {
@ -178,12 +178,12 @@ public class AclTest
};
long[] rights = {
0x10L,
0x10L,
0x10L,
0x31L,
0xf1L,
0x234L
0x1L,
0x1L,
0x1L,
0x9L,
0x9L,
0x3L
};
for( int i = 0; i < rules.length; i++ )
@ -219,7 +219,7 @@ public class AclTest
{
try
{
res = Acl.allocate(client, "#1 HOST/@2 INFO_POOL");
res = Acl.allocate(client, "#1 HOST/@2 USE");
assertTrue( !res.isError() );
aclPool.info();
@ -244,30 +244,30 @@ public class AclTest
public void wrongRules()
{
String[] rules = {
"#-3 TEMPLATE/#0 INFO",
"#+3 TEMPLATE/#0 INFO",
"@3+ TEMPLATE/#0 INFO",
"*3 TEMPLATE/#0 INFO",
"# TEMPLATE/#0 INFO",
"@@ TEMPLATE/#0 INFO",
"@#3 TEMPLATE/#0 INFO",
"#3 TEMPLATE+HOS/#0 INFO",
"#3 /#0 INFO",
"#3 TEMPLATE/# INFO",
"#3 TEMPLATE/#5 INFO CREATE",
"#-3 TEMPLATE/#0 USE",
"#+3 TEMPLATE/#0 USE",
"@3+ TEMPLATE/#0 USE",
"*3 TEMPLATE/#0 USE",
"# TEMPLATE/#0 USE",
"@@ TEMPLATE/#0 USE",
"@#3 TEMPLATE/#0 USE",
"#3 TEMPLATE+HOS/#0 USE",
"#3 /#0 USE",
"#3 TEMPLATE/# USE",
"#3 TEMPLATE/#5 USE CREATE",
"#3 TEMPLATE/#5",
"#3 ",
"",
"#2 IMAGE @10654 INFO",
"#2 IMAGE/ INFO",
"#2 IMAGE#0 INFO",
"#2 IMAGE/# INFO",
"#2 IMAGE/@- INFO",
"#2 IMAGE/#0/#0 INFO",
"#2 IMAGE/#0/INFO CREATE",
"#2 IMAGE/#0/INFO+CREATE",
"#2 IMAGE @10654 USE",
"#2 IMAGE/ USE",
"#2 IMAGE#0 USE",
"#2 IMAGE/# USE",
"#2 IMAGE/@- USE",
"#2 IMAGE/#0/#0 USE",
"#2 IMAGE/#0/USE CREATE",
"#2 IMAGE/#0/USE+CREATE",
"#2 IMAGE/#0 IFO",
"#2 IMAGE/#0 INFO+CREAT",
"#2 IMAGE/#0 USE+CREAT",
};
for( int i = 0; i < rules.length; i++ )

View File

@ -13,9 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
import static org.junit.Assert.*;
import java.util.Hashtable;
import static org.junit.Assert.assertTrue;
import org.junit.After;
import org.junit.AfterClass;
@ -24,8 +22,8 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.opennebula.client.Client;
import org.opennebula.client.OneResponse;
import org.opennebula.client.group.*;
import org.opennebula.client.user.User;
import org.opennebula.client.group.Group;
import org.opennebula.client.group.GroupPool;
public class GroupTest
{

View File

@ -166,7 +166,8 @@ public class ImageTest
image.info();
assertTrue( !image.isEnabled() );
}
// TODO
/*
@Test
public void publish()
{
@ -186,7 +187,7 @@ public class ImageTest
image.info();
assertTrue( !image.isPublic() );
}
*/
@Test
public void attributes()
{

View File

@ -149,7 +149,7 @@ public class TemplateTest
assertTrue( !res.isError() );
template.info();
assertTrue( template.isPublic() );
assertTrue( template.xpath("PERMISSIONS/GROUP_U").equals("1") );
}
@Test
@ -159,9 +159,35 @@ public class TemplateTest
assertTrue( !res.isError() );
template.info();
assertTrue( !template.isPublic() );
assertTrue( template.xpath("PERMISSIONS/GROUP_U").equals("0") );
}
@Test
public void chmod()
{
res = template.info();
assertTrue( !res.isError() );
String owner_a = template.xpath("PERMISSIONS/OWNER_A");
String group_a = template.xpath("PERMISSIONS/GROUP_A");
res = template.chmod(0, 1, -1, 1, 0, -1, 1, 1, 0);
assertTrue( !res.isError() );
res = template.info();
assertTrue( !res.isError() );
assertTrue( template.xpath("PERMISSIONS/OWNER_U").equals("0") );
assertTrue( template.xpath("PERMISSIONS/OWNER_M").equals("1") );
assertTrue( template.xpath("PERMISSIONS/OWNER_A").equals(owner_a) );
assertTrue( template.xpath("PERMISSIONS/GROUP_U").equals("1") );
assertTrue( template.xpath("PERMISSIONS/GROUP_M").equals("0") );
assertTrue( template.xpath("PERMISSIONS/GROUP_A").equals(group_a) );
assertTrue( template.xpath("PERMISSIONS/OTHER_U").equals("1") );
assertTrue( template.xpath("PERMISSIONS/OTHER_M").equals("1") );
assertTrue( template.xpath("PERMISSIONS/OTHER_A").equals("0") );
}
@Test
public void attributes()
{

View File

@ -147,7 +147,8 @@ public class VirtualNetworkTest
res = vnet.info();
assertTrue( res.isError() );
}
// TODO
/*
@Test
public void publish()
{
@ -169,7 +170,7 @@ public class VirtualNetworkTest
res = vnet.info();
assertTrue( !vnet.isPublic() );
}
*/
@Test
public void addLeases()
{

View File

@ -10,13 +10,15 @@
# than MANAGER_TIMER.
#
# HOST_MONITORING_INTERVAL: Time in seconds between host monitorization.
# HOST_PER_INTERVAL: Number of hosts monitored in each interval.
#
# VM_POLLING_INTERVAL: Time in seconds between virtual machine monitorization.
# (use 0 to disable VM monitoring).
# VM_PER_INTERVAL: Number of VMs monitored in each interval.
#
# VM_DIR: Remote path to store the VM images, it should be shared between all
# the cluster nodes to perform live migrations. This variable is the default
# for all the hosts in the cluster. VM_DIR IS ONLY FOR THE NODES AND *NOT* THE
# for all the hosts in the cluster. VM_DIR IS ONLY FOR THE NODES AND *NOT* THE
# FRONT-END
#
# SCRIPTS_REMOTE_DIR: Remote path to store the monitoring and VM management
@ -39,17 +41,19 @@
# DEBUG_LEVEL: 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG
#*******************************************************************************
#MANAGER_TIMER=30
#MANAGER_TIMER = 30
HOST_MONITORING_INTERVAL = 600
#HOST_PER_INTERVAL = 15
VM_POLLING_INTERVAL = 600
#VM_PER_INTERVAL = 5
#VM_DIR=/srv/cloud/one/var
SCRIPTS_REMOTE_DIR=/var/tmp/one
PORT=2666
PORT = 2666
DB = [ backend = "sqlite" ]
@ -63,7 +67,7 @@ DB = [ backend = "sqlite" ]
VNC_BASE_PORT = 5900
DEBUG_LEVEL=3
DEBUG_LEVEL = 3
#*******************************************************************************
# Physical Networks configuration
@ -82,9 +86,6 @@ MAC_PREFIX = "02:00"
#*******************************************************************************
# Image Repository Configuration
#*******************************************************************************
# IMAGE_REPOSITORY_PATH: Define the path to the image repository, by default
# is set to $ONE_LOCATION/var/images
#
# DEFAULT_IMAGE_TYPE: This can take values
# OS Image file holding an operating system
# CDROM Image file holding a CDROM
@ -96,8 +97,6 @@ MAC_PREFIX = "02:00"
# xvd XEN Virtual Disk
# vd KVM virtual disk
#*******************************************************************************
#IMAGE_REPOSITORY_PATH = /srv/cloud/var/images
DEFAULT_IMAGE_TYPE = "OS"
DEFAULT_DEVICE_PREFIX = "hd"
@ -140,6 +139,17 @@ IM_MAD = [
# arguments = "xen" ]
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# VMware Information Driver Manager Configuration
# -r number of retries when monitoring a host
# -t number of threads, i.e. number of hosts monitored at the same time
#-------------------------------------------------------------------------------
#IM_MAD = [
# name = "im_vmware",
# executable = "one_im_sh",
# arguments = "-t 15 -r 0 vmware" ]
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# EC2 Information Driver Manager Configuration
#-------------------------------------------------------------------------------
@ -189,13 +199,16 @@ IM_MAD = [ name="im_dummy", executable="one_im_dummy"]
# KVM Virtualization Driver Manager Configuration
# -r number of retries when monitoring a host
# -t number of threads, i.e. number of hosts monitored at the same time
# -p name of the poll probe (executed locally)
# -l <actions[=command_name]> actions executed locally, command can be
# overridden for each action.
# Valid actions: deploy, shutdown, cancel, save, restore, migrate, poll
# An example: "-l migrate,poll=poll_ganglia,save"
#-------------------------------------------------------------------------------
VM_MAD = [
name = "vmm_kvm",
executable = "one_vmm_ssh",
executable = "one_vmm_exec",
arguments = "-t 15 -r 0 kvm",
default = "vmm_ssh/vmm_ssh_kvm.conf",
default = "vmm_exec/vmm_exec_kvm.conf",
type = "kvm" ]
#-------------------------------------------------------------------------------
@ -203,17 +216,32 @@ VM_MAD = [
# XEN Virtualization Driver Manager Configuration
# -r number of retries when monitoring a host
# -t number of threads, i.e. number of hosts monitored at the same time
# -l do not perform the VM polling in the node
# -p name of the poll probe (executed locally)
# -l <actions[=command_name]> actions executed locally, command can be
# overridden for each action.
# Valid actions: deploy, shutdown, cancel, save, restore, migrate, poll
# An example: "-l migrate,poll=poll_ganglia,save"
#-------------------------------------------------------------------------------
#VM_MAD = [
# name = "vmm_xen",
# executable = "one_vmm_ssh",
# arguments = "xen",
# default = "vmm_ssh/vmm_ssh_xen.conf",
# executable = "one_vmm_exec",
# arguments = "-t 15 -r 0 xen",
# default = "vmm_exec/vmm_exec_xen.conf",
# type = "xen" ]
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# VMware Virtualization Driver Manager Configuration
# -r number of retries when monitoring a host
# -t number of threads, i.e. number of hosts monitored at the same time
#-------------------------------------------------------------------------------
#VM_MAD = [
# name = "vmm_vmware",
# executable = "one_vmm_sh",
# arguments = "-t 15 -r 0 vmware",
# default = "vmm_exec/vmm_exec_vmware.conf",
# type = "vmware" ]
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# EC2 Virtualization Driver Manager Configuration
# arguments: default values for the EC2 driver, can be an absolute path or
@ -285,6 +313,15 @@ TM_MAD = [
# arguments = "tm_lvm/tm_lvm.conf" ]
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# VMware DataStore Transfer Manager Driver Configuration
#-------------------------------------------------------------------------------
#TM_MAD = [
# name = "tm_vmware",
# executable = "one_tm",
# arguments = "tm_vmware/tm_vmware.conf" ]
#-------------------------------------------------------------------------------
#*******************************************************************************
# Image Manager Driver Configuration
#*******************************************************************************
@ -320,19 +357,20 @@ IMAGE_MAD = [
# name : for the hook, useful to track the hook (OPTIONAL)
# on : when the hook should be executed,
# - CREATE, when the VM is created (onevm create)
# - PROLOG, when the VM is in the prolog state
# - RUNNING, after the VM is successfully booted
# - SHUTDOWN, after the VM is shutdown
# - STOP, after the VM is stopped (including VM image transfers)
# - DONE, after the VM is deleted or shutdown
# - FAILED, when the VM enters the failed state
# command : path can be absolute or relative to $ONE_LOCATION/share/hooks
# case of self-contained installation or relative to
# /usr/share/one/hooks in case of system-wide installation
# arguments : for the hook. You can access to VM template variables with $
# - $ATTR, the value of an attribute e.g. $NAME or $VMID
# - $ATTR[VAR], the value of a vector e.g. $NIC[MAC]
# - $ATTR[VAR, COND], same of previous but COND select between
# multiple ATTRs e.g. $NIC[MAC, NETWORK="Public"]
# command : path is relative to $ONE_LOCATION/var/remotes/hook
# (self-contained) or to /var/lib/one/remotes/hook (system-wide).
# That directory will be copied on the hosts under
# SCRIPTS_REMOTE_DIR. It can be an absolute path that must exist
# on the target host
# arguments : for the hook. You can access to VM information with $
# - $VMID, the ID of the virtual machine
# - $TEMPLATE, the VM template in xml and base64 encoded
# remote : values,
# - YES, The hook is executed in the host where the VM was
# allocated
@ -345,11 +383,14 @@ IMAGE_MAD = [
# - CREATE, when the Host is created (onehost create)
# - ERROR, when the Host enters the error state
# - DISABLE, when the Host is disabled
# command : path can be absolute or relative to $ONE_LOCATION/share/hooks
# case of self-contained installation or relative to
# /usr/share/one/hooks in case of system-wide installation
# arguments : for the hook. You can use the Host ID with $HID to pass it as
# argument for the hook
# command : path is relative to $ONE_LOCATION/var/remotes/hook
# (self-contained) or to /var/lib/one/remotes/hook (system-wide).
# That directory will be copied on the hosts under
# SCRIPTS_REMOTE_DIR. It can be an absolute path that must exist
# on the target host.
# arguments : for the hook. You can use the following Host information:
# - $HID, the ID of the host
# - $TEMPLATE, the Host template in xml and base64 encoded
# remote : values,
# - YES, The hook is executed in the host
# - NO, The hook is executed in the OpenNebula server (default)
@ -360,24 +401,27 @@ HM_MAD = [
#-------------------------------------------------------------------------------
#------------------------------ Fault Tolerance Hooks --------------------------
#*******************************************************************************
# Fault Tolerance Hooks
#*******************************************************************************
# This hook is used to perform recovery actions when a host fails. The VMs
# running in the host can be deleted (use -d option) or resubmitted (-r) in
# other host
# Last argument (force) can be "y", so suspended VMs in the host will be
# Last argument (force) can be "y", so suspended VMs in the host will be
# resubmitted/deleted, or "n", so suspended VMs in the host will be ignored
#
#HOST_HOOK = [
# name = "error",
# on = "ERROR",
# command = "host_error.rb",
# command = "ft/host_error.rb",
# arguments = "$HID -r n",
# remote = "no" ]
#-------------------------------------------------------------------------------
# This two hooks can be used to automatically delete or resubmit VMs that reach
# These two hooks can be used to automatically delete or resubmit VMs that reach
# the "failed" state. This way, the administrator doesn't have to interact
# manually to release its resources or retry the deployment.
#
#
# Only one of them should be uncommented.
#-------------------------------------------------------------------------------
#
@ -394,46 +438,32 @@ HM_MAD = [
# arguments = "$VMID" ]
#-------------------------------------------------------------------------------
#-------------------------------- ebtables Hook---------------------------------
# You can use these two hooks to isolate networks at the ethernet level so the
# traffic generated in different virtual networks can not be seen in others.
#
# All the network configuration will be done in the cluster nodes, these are the
# additional requisites:
# - ebtables package installed
# - sudoers configured so oneadmin can execute ebtables without password
#
# NOTE: Change the first command for ebtables-xen if you are using Xen
#
#VM_HOOK = [
# name = "ebtables-start",
# on = "running",
# command = "ebtables-kvm", # or ebtables-xen
# arguments = "one-$VMID",
# remote = "yes" ]
#
#VM_HOOK = [
# name = "ebtables-flush",
# on = "done",
# command = "ebtables-flush",
# arguments = "",
# remote = "yes" ]
#-------------------------------------------------------------------------------
#*******************************************************************************
# Auth Manager Configuration
#*******************************************************************************
# The Driver (AUTHM_MAD) that will be used to authenticate and authorize
# OpenNebula requests. If not defined OpenNebula will use the built-in auth
# policies
# AUTH_MAD: The Driver that will be used to authenticate (authn) and
# authorize (authz) OpenNebula requests. If defined OpenNebula will use the
# built-in auth policies.
#
# executable: path of the auth driver executable, can be an
# absolute path or relative to $ONE_LOCATION/lib/mads (or
# /usr/lib/one/mads/ if OpenNebula was installed in /)
#
# arguments : for the driver executable, can be an absolute path or relative
# to $ONE_LOCATION/etc (or /etc/one/ if OpenNebula was installed
# in /)
#-------------------------------------------------------------------------------
# arguments :
# --authn: list of authentication modules separated by commas, if not
# defined all the modules available will be enabled
# --authz: authorization module
#
# SESSION_EXPIRATION_TIME: Time in seconds to keep an authenticated token as
# valid. During this time, the driver is not used. Use 0 to disable session
# caching
#*******************************************************************************
AUTH_MAD = [
executable = "one_auth_mad",
arguments = "--authn ssh,x509,ldap,server_cipher,server_x509"
# arguments = "--authz quota --authn ssh,x509,ldap,server_cipher,server_x509"
]
SESSION_EXPIRATION_TIME = 900
#AUTH_MAD = [
# executable = "one_auth_mad" ]