mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-25 22:26:26 +09:00
Merge branch 'feature-1291'
This commit is contained in:
commit
8f809df025
41 files changed
+1352
-236
No files matched your search
@@ -1,12 +1,12 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -22,6 +22,7 @@ import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.opennebula.client.Client;
|
||||
import org.opennebula.client.OneResponse;
|
||||
import org.opennebula.client.datastore.Datastore;
|
||||
import org.opennebula.client.image.*;
|
||||
|
||||
|
||||
@@ -47,6 +48,33 @@ public class ImageTest
|
||||
"ATT2 = \"VAL2\"";
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait until the Image changes to the specified state.
|
||||
* There is a time-out of 10 seconds.
|
||||
*/
|
||||
void waitAssert(Image img, String state)
|
||||
{
|
||||
int n_steps = 10;
|
||||
int step = 1000;
|
||||
|
||||
int i = 0;
|
||||
|
||||
img.info();
|
||||
|
||||
while( !( img.stateString().equals(state) || i > n_steps )
|
||||
&& !img.stateString().equals("ERROR") )
|
||||
{
|
||||
try{ Thread.sleep(step); } catch (Exception e){}
|
||||
|
||||
img.info();
|
||||
i++;
|
||||
}
|
||||
|
||||
assertTrue(
|
||||
"Image timeout, wanted state: " + state + "; it is in state "
|
||||
+ img.stateString(), img.stateString().equals(state) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@@ -71,10 +99,12 @@ public class ImageTest
|
||||
@Before
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
res = Image.allocate(client, template());
|
||||
res = Image.allocate(client, template(), 1);
|
||||
|
||||
int imgid = res.isError() ? -1 : Integer.parseInt(res.getMessage());
|
||||
int imgid = res.isError() ? -1 : Integer.parseInt(res.getMessage());
|
||||
image = new Image(imgid, client);
|
||||
|
||||
waitAssert(image, "READY");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,15 +121,15 @@ public class ImageTest
|
||||
{
|
||||
image.delete();
|
||||
|
||||
res = Image.allocate(client, template());
|
||||
assertTrue( !res.isError() );
|
||||
res = Image.allocate(client, template(), 1);
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
|
||||
int imgid = res.isError() ? -1 : Integer.parseInt(res.getMessage());
|
||||
int imgid = res.isError() ? -1 : Integer.parseInt(res.getMessage());
|
||||
image = new Image(imgid, client);
|
||||
|
||||
|
||||
res = imagePool.info();
|
||||
assertTrue( !res.isError() );
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
|
||||
boolean found = false;
|
||||
for(Image img : imagePool)
|
||||
@@ -110,12 +140,37 @@ public class ImageTest
|
||||
assertTrue( found );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clone_method()
|
||||
{
|
||||
res = image.clone("cloned_image");
|
||||
assertTrue(res.getErrorMessage(), !res.isError());
|
||||
|
||||
int imgid = res.isError() ? -1 : Integer.parseInt(res.getMessage());
|
||||
Image cloned_image = new Image(imgid, client);
|
||||
|
||||
res = imagePool.info();
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
|
||||
boolean found = false;
|
||||
for(Image img : imagePool)
|
||||
{
|
||||
found = found || img.getName().equals("cloned_image");
|
||||
}
|
||||
|
||||
assertTrue( found );
|
||||
|
||||
res = cloned_image.info();
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
assertTrue( cloned_image.getName().equals("cloned_image") );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void info()
|
||||
{
|
||||
res = image.info();
|
||||
assertTrue( !res.isError() );
|
||||
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
|
||||
// assertTrue( image.getId().equals("0") );
|
||||
// assertTrue( image.id() == 0 );
|
||||
assertTrue( image.getName().equals("test_img_"+cont) );
|
||||
@@ -125,7 +180,7 @@ public class ImageTest
|
||||
public void update()
|
||||
{
|
||||
res = image.info();
|
||||
assertTrue( !res.isError() );
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
|
||||
assertTrue( image.xpath("TEMPLATE/ATT1").equals( "VAL1" ) );
|
||||
assertTrue( image.xpath("TEMPLATE/ATT2").equals( "VAL2" ) );
|
||||
@@ -134,65 +189,61 @@ public class ImageTest
|
||||
"ATT3 = VAL3";
|
||||
|
||||
res = image.update(new_template);
|
||||
assertTrue( !res.isError() );
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
|
||||
|
||||
res = image.info();
|
||||
assertTrue( !res.isError() );
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
assertTrue( image.xpath("TEMPLATE/ATT1").equals( "" ) );
|
||||
assertTrue( image.xpath("TEMPLATE/ATT2").equals( "NEW_VAL" ) );
|
||||
assertTrue( image.xpath("TEMPLATE/ATT3").equals( "VAL3" ) );
|
||||
}
|
||||
|
||||
|
||||
// TODO
|
||||
// @Test
|
||||
@Test
|
||||
public void enable()
|
||||
{
|
||||
res = image.enable();
|
||||
assertTrue( !res.isError() );
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
|
||||
image.info();
|
||||
assertTrue( image.isEnabled() );
|
||||
}
|
||||
|
||||
// TODO
|
||||
// @Test
|
||||
@Test
|
||||
public void disable()
|
||||
{
|
||||
res = image.disable();
|
||||
assertTrue( !res.isError() );
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
|
||||
image.info();
|
||||
assertTrue( !image.isEnabled() );
|
||||
assertTrue( res.getErrorMessage(), !image.isEnabled() );
|
||||
}
|
||||
// TODO
|
||||
/*
|
||||
|
||||
@Test
|
||||
public void publish()
|
||||
{
|
||||
res = image.publish();
|
||||
assertTrue( !res.isError() );
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
|
||||
image.info();
|
||||
assertTrue( image.isPublic() );
|
||||
assertTrue( image.xpath("PERMISSIONS/GROUP_U").equals( "1" ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unpublish()
|
||||
{
|
||||
res = image.unpublish();
|
||||
assertTrue( !res.isError() );
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
|
||||
image.info();
|
||||
assertTrue( !image.isPublic() );
|
||||
assertTrue( image.xpath("PERMISSIONS/GROUP_U").equals( "0" ) );
|
||||
}
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void attributes()
|
||||
{
|
||||
res = image.info();
|
||||
assertTrue( !res.isError() );
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
|
||||
// assertTrue( image.xpath("ID").equals("0") );
|
||||
assertTrue( image.xpath("NAME").equals("test_img_"+cont) );
|
||||
@@ -202,7 +253,7 @@ public class ImageTest
|
||||
public void delete()
|
||||
{
|
||||
res = image.delete();
|
||||
assertTrue( !res.isError() );
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
|
||||
// res = image.info();
|
||||
// assertTrue( res.isError() );
|
||||
|
||||
@@ -298,7 +298,7 @@ TM_MAD = [
|
||||
|
||||
DATASTORE_MAD = [
|
||||
executable = "one_datastore",
|
||||
arguments = "-t 15 -d fs,vmware,iscsi,dummy"
|
||||
arguments = "-t 15 -d fs,vmware,iscsi,lvm"
|
||||
]
|
||||
|
||||
#*******************************************************************************
|
||||
@@ -406,10 +406,9 @@ HM_MAD = [
|
||||
# absolute path or relative to $ONE_LOCATION/lib/mads (or
|
||||
# /usr/lib/one/mads/ 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
|
||||
# authn : list of authentication modules separated by commas, if not
|
||||
# defined all the modules available will be enabled
|
||||
# authz : list of authentication modules separated by commas
|
||||
#
|
||||
# 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
|
||||
@@ -422,8 +421,8 @@ HM_MAD = [
|
||||
|
||||
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"
|
||||
authn = "ssh,x509,ldap,server_cipher,server_x509"
|
||||
# , authz = "quota"
|
||||
]
|
||||
|
||||
SESSION_EXPIRATION_TIME = 900
|
||||
|
||||
Reference in new issue
Block a user