stable openstack

This commit is contained in:
Adrian Cole 2012-09-16 22:38:22 -07:00
parent d766f8d4e3
commit 54ec689019
22 changed files with 99 additions and 100 deletions

View File

@ -82,7 +82,7 @@ public class AllocateAndAddFloatingIpToNode implements
FloatingIP ip = null;
try {
logger.debug(">> allocating or reassigning floating ip for node(%s)", node.getId());
ip = floatingIpApi.allocate();
ip = floatingIpApi.create();
} catch (InsufficientResourcesException e) {
logger.trace("<< [%s] allocating a new floating ip for node(%s)", e.getMessage(), node.getId());
logger.trace(">> searching for existing, unassigned floating ip for node(%s)", node.getId());

View File

@ -63,7 +63,7 @@ public class RemoveFloatingIpFromNodeAndDeallocate implements Function<ZoneAndId
logger.debug(">> removing floatingIp(%s) from node(%s)", ip, id);
floatingIpApi.removeFromServer(ip.getIp(), id.getId());
logger.debug(">> deallocating floatingIp(%s)", ip);
floatingIpApi.deallocate(ip.getId());
floatingIpApi.delete(ip.getId());
}
floatingIpCache.invalidate(id);
return id;
@ -71,6 +71,6 @@ public class RemoveFloatingIpFromNodeAndDeallocate implements Function<ZoneAndId
@Override
public String toString() {
return Objects.toStringHelper("RemoveFloatingIpFromNodeAndDeallocate").toString();
return Objects.toStringHelper("RemoveFloatingIpFromNodeAndDecreate").toString();
}
}

View File

@ -65,7 +65,7 @@ import com.google.common.primitives.Ints;
public class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet extends
CreateNodesWithGroupEncodedIntoNameThenAddToSet {
private final AllocateAndAddFloatingIpToNode allocateAndAddFloatingIpToNode;
private final AllocateAndAddFloatingIpToNode createAndAddFloatingIpToNode;
private final LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupCache;
private final LoadingCache<ZoneAndName, KeyPair> keyPairCache;
private final NovaApi novaApi;
@ -77,15 +77,15 @@ public class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddT
GroupNamingConvention.Factory namingConvention,
CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.Factory customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor,
AllocateAndAddFloatingIpToNode allocateAndAddFloatingIpToNode,
AllocateAndAddFloatingIpToNode createAndAddFloatingIpToNode,
LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupCache,
LoadingCache<ZoneAndName, KeyPair> keyPairCache, NovaApi novaApi) {
super(addNodeWithTagStrategy, listNodesStrategy, namingConvention, executor,
customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory);
this.securityGroupCache = checkNotNull(securityGroupCache, "securityGroupCache");
this.keyPairCache = checkNotNull(keyPairCache, "keyPairCache");
this.allocateAndAddFloatingIpToNode = checkNotNull(allocateAndAddFloatingIpToNode,
"allocateAndAddFloatingIpToNode");
this.createAndAddFloatingIpToNode = checkNotNull(createAndAddFloatingIpToNode,
"createAndAddFloatingIpToNode");
this.novaApi = checkNotNull(novaApi, "novaApi");
}
@ -153,7 +153,7 @@ public class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddT
NovaTemplateOptions templateOptions = NovaTemplateOptions.class.cast(template.getOptions());
if (templateOptions.shouldAutoAssignFloatingIp()) {
return Futures.compose(future, allocateAndAddFloatingIpToNode, executor);
return Futures.compose(future, createAndAddFloatingIpToNode, executor);
} else {
return future;
}

View File

@ -31,10 +31,10 @@ public class NovaProperties {
public static final String TIMEOUT_SECURITYGROUP_PRESENT = "jclouds.openstack-nova.timeout.securitygroup-present";
/**
* Whenever a node is created, automatically allocate and assign a floating ip address, also
* deallocate when the node is destroyed.
* Whenever a node is created, automatically create and assign a floating ip address, also
* delete when the node is destroyed.
*/
public static final String AUTO_ALLOCATE_FLOATING_IPS = "jclouds.openstack-nova.auto-allocate-floating-ips";
public static final String AUTO_ALLOCATE_FLOATING_IPS = "jclouds.openstack-nova.auto-create-floating-ips";
/**
* Whenever a node is created, automatically generate keypairs for groups, as needed, also

View File

@ -57,17 +57,17 @@ public interface FloatingIPApi {
/**
* Allocate a Floating IP address
*
* @return a newly allocated FloatingIP
* @return a newly created FloatingIP
*/
FloatingIP allocate();
FloatingIP create();
/**
* Deallocate a Floating IP address
* Decreate a Floating IP address
*
* @param id
* the Floating IP id
*/
void deallocate(String id);
void delete(String id);
/**
* Add a Floating IP address to a Server

View File

@ -84,7 +84,7 @@ public interface FloatingIPAsyncApi {
ListenableFuture<? extends FloatingIP> get(@PathParam("id") String id);
/**
* @see FloatingIPApi#allocate
* @see FloatingIPApi#create
*/
@POST
@Path("/os-floating-ips")
@ -93,16 +93,16 @@ public interface FloatingIPAsyncApi {
@Produces(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
@Payload("{}")
ListenableFuture<? extends FloatingIP> allocate();
ListenableFuture<? extends FloatingIP> create();
/**
* @see FloatingIPApi#deallocate
* @see FloatingIPApi#delete
*/
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
@Path("/os-floating-ips/{id}")
ListenableFuture<Void> deallocate(@PathParam("id") String id);
ListenableFuture<Void> delete(@PathParam("id") String id);
/**
* @see FloatingIPApi#addToServer

View File

@ -37,7 +37,7 @@ import com.google.common.collect.ImmutableSet;
* @see KeystoneProperties#CREDENTIAL_TYPE
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest")
@Test(groups = "unit", testName = "AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest")
public class AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest extends BaseNovaApiExpectTest {
public AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest() {
identity = "identity";

View File

@ -81,7 +81,7 @@ public class NovaErrorHandlerTest {
URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/os-floating-ips"),
400,
"HTTP/1.1 400 Bad Request",
"{\"badRequest\": {\"message\": \"AddressLimitExceeded: Address quota exceeded. You cannot allocate any more addresses\", \"code\": 400}}",
"{\"badRequest\": {\"message\": \"AddressLimitExceeded: Address quota exceeded. You cannot create any more addresses\", \"code\": 400}}",
InsufficientResourcesException.class);
}

View File

@ -57,7 +57,7 @@ public class AllocateAndAddFloatingIpToNodeExpectTest extends BaseNovaComputeSer
host).name("Server 71592").status(Status.RUNNING).privateAddresses(ImmutableSet.of("10.4.27.237"))
.credentials(LoginCredentials.builder().password("foo").build()).build();
HttpRequest allocateFloatingIP = HttpRequest.builder().method("POST").endpoint(
HttpRequest createFloatingIP = HttpRequest.builder().method("POST").endpoint(
URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips")).headers(
ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
authToken).build()).payload(payloadFromStringWithContentType("{}", "application/json")).build();
@ -65,7 +65,7 @@ public class AllocateAndAddFloatingIpToNodeExpectTest extends BaseNovaComputeSer
HttpResponse addFloatingIPResponse = HttpResponse.builder().statusCode(200).build();
public void testAllocateWhenAllocationReturnsIpIsAddedToServerAndUpdatesNodeMetadataButSavesCredentials() throws Exception {
HttpResponse allocateFloatingIPResponse = HttpResponse.builder().statusCode(200).payload(
HttpResponse createFloatingIPResponse = HttpResponse.builder().statusCode(200).payload(
payloadFromResource("/floatingip_details.json")).build();
HttpRequest addFloatingIPRequest = addFloatingIPForAddress("10.0.0.3");
@ -73,7 +73,7 @@ public class AllocateAndAddFloatingIpToNodeExpectTest extends BaseNovaComputeSer
AllocateAndAddFloatingIpToNode fn = requestsSendResponses(
ImmutableMap.<HttpRequest, HttpResponse> builder().put(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess).put(extensionsOfNovaRequest, extensionsOfNovaResponse).put(
allocateFloatingIP, allocateFloatingIPResponse)
createFloatingIP, createFloatingIPResponse)
.put(addFloatingIPRequest, addFloatingIPResponse).build()).getContext().utils().injector()
.getInstance(AllocateAndAddFloatingIpToNode.class);
@ -98,12 +98,12 @@ public class AllocateAndAddFloatingIpToNodeExpectTest extends BaseNovaComputeSer
}
public void testAllocateWhenAllocationFailsLookupUnusedIpAddToServerAndUpdatesNodeMetadata() throws Exception {
HttpResponse allocateFloatingIPResponse = HttpResponse
HttpResponse createFloatingIPResponse = HttpResponse
.builder()
.statusCode(400)
.payload(
payloadFromStringWithContentType(
"{\"badRequest\": {\"message\": \"AddressLimitExceeded: Address quota exceeded. You cannot allocate any more addresses\", \"code\": 400}}",
"{\"badRequest\": {\"message\": \"AddressLimitExceeded: Address quota exceeded. You cannot create any more addresses\", \"code\": 400}}",
"application/json")).build();
HttpRequest list = HttpRequest.builder().method("GET").endpoint(
@ -119,7 +119,7 @@ public class AllocateAndAddFloatingIpToNodeExpectTest extends BaseNovaComputeSer
AllocateAndAddFloatingIpToNode fn = requestsSendResponses(
ImmutableMap.<HttpRequest, HttpResponse> builder().put(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess).put(extensionsOfNovaRequest, extensionsOfNovaResponse).put(
allocateFloatingIP, allocateFloatingIPResponse)
createFloatingIP, createFloatingIPResponse)
.put(addFloatingIPRequest, addFloatingIPResponse).put(list,
listResponseForUnassigned).build()).getContext().utils().injector()
.getInstance(AllocateAndAddFloatingIpToNode.class);

View File

@ -33,9 +33,9 @@ import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
import org.jclouds.openstack.nova.v2_0.options.CreateBackupOfServerOptions;
import org.jclouds.openstack.v2_0.features.ExtensionApi;
import org.testng.SkipException;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.base.Optional;
@ -60,7 +60,7 @@ public class AdminActionsApiLiveTest extends BaseNovaApiLiveTest {
private String testServerId;
private String backupImageId;
@BeforeGroups(groups = { "integration", "live" })
@BeforeClass(groups = {"integration", "live"})
@Override
public void setupContext() {
super.setupContext();
@ -74,9 +74,9 @@ public class AdminActionsApiLiveTest extends BaseNovaApiLiveTest {
}
}
@AfterGroups(groups = "live", alwaysRun = true)
@AfterClass(groups = { "integration", "live" })
@Override
protected void tearDown() {
protected void tearDownContext() {
if (apiOption.isPresent()) {
if (testServerId != null) {
assertTrue(novaContext.getApi().getServerApiForZone(zone).delete(testServerId));
@ -85,7 +85,7 @@ public class AdminActionsApiLiveTest extends BaseNovaApiLiveTest {
imageApi.delete(backupImageId);
}
}
super.tearDown();
super.tearDownContext();
}
protected void skipOnAdminExtensionAbsent() {

View File

@ -27,8 +27,8 @@ import java.util.Map;
import org.jclouds.openstack.nova.v2_0.features.FlavorApi;
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
import org.jclouds.openstack.v2_0.domain.Resource;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.base.Optional;
@ -50,7 +50,7 @@ public class FlavorExtraSpecsApiLiveTest extends BaseNovaApiLiveTest {
private Resource testFlavor;
private Map<String, String> testSpecs = ImmutableMap.of("jclouds-test", "some data", "jclouds-test2", "more data!");
@BeforeGroups(groups = { "integration", "live" })
@BeforeClass(groups = {"integration", "live"})
@Override
public void setupContext() {
super.setupContext();
@ -59,15 +59,15 @@ public class FlavorExtraSpecsApiLiveTest extends BaseNovaApiLiveTest {
apiOption = novaContext.getApi().getFlavorExtraSpecsExtensionForZone(zone);
}
@AfterGroups(groups = "live")
@AfterClass(groups = { "integration", "live" })
@Override
public void tearDown() {
protected void tearDownContext() {
if (apiOption.isPresent() && testFlavor != null) {
for(String key : testSpecs.keySet()) {
assertTrue(apiOption.get().deleteMetadataKey(testFlavor.getId(), key));
}
}
super.tearDown();
super.tearDownContext();
}
public void testCreateExtraSpecs() {

View File

@ -133,7 +133,7 @@ public class FloatingIPApiExpectTest extends BaseNovaApiExpectTest {
}
public void testAllocateWhenResponseIs2xx() throws Exception {
HttpRequest allocateFloatingIP = HttpRequest
HttpRequest createFloatingIP = HttpRequest
.builder()
.method("POST")
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips")
@ -141,20 +141,20 @@ public class FloatingIPApiExpectTest extends BaseNovaApiExpectTest {
.addHeader("X-Auth-Token", authToken)
.payload(payloadFromStringWithContentType("{}", "application/json")).build();
HttpResponse allocateFloatingIPResponse = HttpResponse.builder().statusCode(200)
HttpResponse createFloatingIPResponse = HttpResponse.builder().statusCode(200)
.payload(payloadFromResource("/floatingip_details.json")).build();
NovaApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, allocateFloatingIP,
allocateFloatingIPResponse);
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createFloatingIP,
createFloatingIPResponse);
assertEquals(apiWhenFloatingIPsExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().allocate().toString(),
assertEquals(apiWhenFloatingIPsExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().create().toString(),
new ParseFloatingIPTest().expected().toString());
}
public void testAllocateWhenResponseIs404() throws Exception {
HttpRequest allocateFloatingIP = HttpRequest
HttpRequest createFloatingIP = HttpRequest
.builder()
.method("POST")
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips")
@ -162,13 +162,13 @@ public class FloatingIPApiExpectTest extends BaseNovaApiExpectTest {
.addHeader("X-Auth-Token", authToken)
.payload(payloadFromStringWithContentType("{}", "application/json")).build();
HttpResponse allocateFloatingIPResponse = HttpResponse.builder().statusCode(404).build();
HttpResponse createFloatingIPResponse = HttpResponse.builder().statusCode(404).build();
NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, allocateFloatingIP,
allocateFloatingIPResponse);
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createFloatingIP,
createFloatingIPResponse);
assertNull(apiWhenNoServersExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().allocate());
assertNull(apiWhenNoServersExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().create());
}
}

View File

@ -68,13 +68,13 @@ public class FloatingIPApiLiveTest extends BaseNovaApiLiveTest {
}
@Test
public void testAllocateAndDeallocateFloatingIPs() throws Exception {
public void testAllocateAndDecreateFloatingIPs() throws Exception {
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
Optional<? extends FloatingIPApi> apiOption = novaContext.getApi().getFloatingIPExtensionForZone(zoneId);
if (!apiOption.isPresent())
continue;
FloatingIPApi api = apiOption.get();
FloatingIP floatingIP = api.allocate();
FloatingIP floatingIP = api.create();
assertNotNull(floatingIP);
Set<? extends FloatingIP> response = api.list().toImmutableSet();
@ -85,7 +85,7 @@ public class FloatingIPApiLiveTest extends BaseNovaApiLiveTest {
}
assertTrue(ipInSet);
api.deallocate(floatingIP.getId());
api.delete(floatingIP.getId());
response = api.list().toImmutableSet();
ipInSet = false;
@ -107,7 +107,7 @@ public class FloatingIPApiLiveTest extends BaseNovaApiLiveTest {
FloatingIPApi api = apiOption.get();
ServerApi serverApi = novaContext.getApi().getServerApiForZone(zoneId);
Server server = createServerInZone(zoneId);
FloatingIP floatingIP = api.allocate();
FloatingIP floatingIP = api.create();
assertNotNull(floatingIP);
try {
api.addToServer(floatingIP.getIp(), server.getId());

View File

@ -135,7 +135,7 @@ public class FloatingIPAsyncApiExpectTest extends BaseNovaAsyncApiExpectTest {
}
public void testAllocateWhenResponseIs2xx() throws Exception {
HttpRequest allocateFloatingIP = HttpRequest
HttpRequest createFloatingIP = HttpRequest
.builder()
.method("POST")
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips")
@ -143,20 +143,20 @@ public class FloatingIPAsyncApiExpectTest extends BaseNovaAsyncApiExpectTest {
.addHeader("X-Auth-Token", authToken)
.payload(payloadFromStringWithContentType("{}", "application/json")).build();
HttpResponse allocateFloatingIPResponse = HttpResponse.builder().statusCode(200)
HttpResponse createFloatingIPResponse = HttpResponse.builder().statusCode(200)
.payload(payloadFromResource("/floatingip_details.json")).build();
NovaAsyncApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, allocateFloatingIP,
allocateFloatingIPResponse);
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createFloatingIP,
createFloatingIPResponse);
assertEquals(apiWhenFloatingIPsExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().allocate().get()
assertEquals(apiWhenFloatingIPsExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().create().get()
.toString(), new ParseFloatingIPTest().expected().toString());
}
public void testAllocateWhenResponseIs404() throws Exception {
HttpRequest allocateFloatingIP = HttpRequest
HttpRequest createFloatingIP = HttpRequest
.builder()
.method("POST")
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips")
@ -164,13 +164,13 @@ public class FloatingIPAsyncApiExpectTest extends BaseNovaAsyncApiExpectTest {
.addHeader("X-Auth-Token", authToken)
.payload(payloadFromStringWithContentType("{}", "application/json")).build();
HttpResponse allocateFloatingIPResponse = HttpResponse.builder().statusCode(404).build();
HttpResponse createFloatingIPResponse = HttpResponse.builder().statusCode(404).build();
NovaAsyncApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, allocateFloatingIP,
allocateFloatingIPResponse);
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createFloatingIP,
createFloatingIPResponse);
assertNull(apiWhenNoServersExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().allocate().get());
assertNull(apiWhenNoServersExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().create().get());
}
}

View File

@ -28,8 +28,8 @@ import java.util.Set;
import org.jclouds.openstack.nova.v2_0.domain.Host;
import org.jclouds.openstack.nova.v2_0.domain.HostAggregate;
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.base.Optional;
@ -49,7 +49,7 @@ public class HostAggregateApiLiveTest extends BaseNovaApiLiveTest {
private HostAggregate testAggregate;
@BeforeGroups(groups = {"integration", "live"})
@BeforeClass(groups = {"integration", "live"})
@Override
public void setupContext() {
super.setupContext();
@ -58,13 +58,13 @@ public class HostAggregateApiLiveTest extends BaseNovaApiLiveTest {
hostAdminOption = novaContext.getApi().getHostAdministrationExtensionForZone(zone);
}
@AfterClass(groups = { "integration", "live" })
@Override
@AfterGroups(groups = {"integration", "live"})
public void tearDown() {
protected void tearDownContext() {
if (testAggregate != null) {
assertTrue(apiOption.get().delete(testAggregate.getId()));
}
super.tearDown();
super.tearDownContext();
}
public void testCreateAggregate() {

View File

@ -31,8 +31,8 @@ import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
import org.jclouds.openstack.nova.v2_0.options.CreateVolumeOptions;
import org.jclouds.openstack.nova.v2_0.options.CreateVolumeSnapshotOptions;
import org.jclouds.predicates.RetryablePredicate;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.base.Objects;
@ -54,7 +54,7 @@ public class VolumeApiLiveTest extends BaseNovaApiLiveTest {
private Volume testVolume;
private VolumeSnapshot testSnapshot;
@BeforeGroups(groups = { "integration", "live" })
@BeforeClass(groups = {"integration", "live"})
@Override
public void setupContext() {
super.setupContext();
@ -62,9 +62,9 @@ public class VolumeApiLiveTest extends BaseNovaApiLiveTest {
volumeOption = novaContext.getApi().getVolumeExtensionForZone(zone);
}
@AfterGroups(groups = "live", alwaysRun = true)
@AfterClass(groups = { "integration", "live" })
@Override
protected void tearDown() {
protected void tearDownContext() {
if (volumeOption.isPresent()) {
if (testSnapshot != null) {
final String snapshotId = testSnapshot.getId();
@ -87,7 +87,7 @@ public class VolumeApiLiveTest extends BaseNovaApiLiveTest {
}, 180 * 1000L).apply(volumeOption.get()));
}
}
super.tearDown();
super.tearDownContext();
}
public void testCreateVolume() {

View File

@ -28,7 +28,7 @@ import org.jclouds.openstack.nova.v2_0.domain.VolumeType;
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
import org.jclouds.openstack.nova.v2_0.options.CreateVolumeTypeOptions;
import org.jclouds.predicates.RetryablePredicate;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;
@ -59,9 +59,10 @@ public class VolumeTypeApiLiveTest extends BaseNovaApiLiveTest {
volumeTypeOption = novaContext.getApi().getVolumeTypeExtensionForZone(zone);
}
@AfterGroups(groups = "live")
@AfterClass(groups = { "integration", "live" })
@Override
protected void tearDown() {
protected void tearDownContext() {
if (volumeTypeOption.isPresent()) {
if (testVolumeType != null) {
final String id = testVolumeType.getId();
@ -74,7 +75,7 @@ public class VolumeTypeApiLiveTest extends BaseNovaApiLiveTest {
}, 5 * 1000L).apply(volumeTypeOption.get()));
}
}
super.tearDown();
super.tearDownContext();
}
public void testCreateVolumeType() {

View File

@ -65,8 +65,8 @@ public class ImageApiLiveTest extends BaseNovaApiLiveTest {
assertNotNull(image.getName());
assertNotNull(image.getLinks());
assertNotNull(image.getCreated());
assertTrue(image.getMinDisk() > 0);
assertTrue(image.getMinRam() > 0);
// image.getMinDisk() can be zero
// image.getMinRam() can be zero
assertTrue(image.getProgress() >= 0 && image.getProgress() <= 100);
assertNotNull(image.getStatus());
// image.getServer() can be null

View File

@ -33,9 +33,9 @@ import org.jclouds.openstack.nova.v2_0.domain.ServerCreated;
import org.jclouds.openstack.nova.v2_0.features.FlavorApi;
import org.jclouds.openstack.nova.v2_0.features.ImageApi;
import org.jclouds.openstack.nova.v2_0.features.ServerApi;
import org.jclouds.openstack.v2_0.domain.Resource;
import org.jclouds.rest.RestContext;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.base.Throwables;
@ -50,6 +50,7 @@ import com.google.common.collect.Ordering;
*/
@Test(groups = "live")
public class BaseNovaApiLiveTest extends BaseComputeServiceContextLiveTest {
protected String hostName = System.getProperty("user.name").replace('.','-').toLowerCase();
public BaseNovaApiLiveTest() {
provider = "openstack-nova";
@ -58,12 +59,19 @@ public class BaseNovaApiLiveTest extends BaseComputeServiceContextLiveTest {
protected Set<String> zones;
protected RestContext<NovaApi, NovaAsyncApi> novaContext;
@BeforeGroups(groups = { "integration", "live" }, alwaysRun = true)
@BeforeClass(groups = { "integration", "live" })
@Override
public void setupContext() {
super.setupContext();
novaContext = view.unwrap();
zones = novaContext.getApi().getConfiguredZones();
for (String zone : zones){
ServerApi api = novaContext.getApi().getServerApiForZone(zone);
for (Resource server : api.list().concat()){
if (server.getName().equals(hostName))
api.delete(server.getId());
}
}
}
@Override
@ -74,15 +82,9 @@ public class BaseNovaApiLiveTest extends BaseComputeServiceContextLiveTest {
return props;
}
@AfterGroups(groups = "live")
protected void tearDown() {
if (novaContext != null)
novaContext.close();
}
protected Server createServerInZone(String zoneId) {
ServerApi serverApi = novaContext.getApi().getServerApiForZone(zoneId);
ServerCreated server = serverApi.create("test", imageIdForZone(zoneId), flavorRefForZone(zoneId));
ServerCreated server = serverApi.create(hostName, imageIdForZone(zoneId), flavorRefForZone(zoneId));
blockUntilServerInState(server.getId(), serverApi, Status.ACTIVE);
return serverApi.get(server.getId());
}
@ -93,10 +95,9 @@ public class BaseNovaApiLiveTest extends BaseComputeServiceContextLiveTest {
*/
protected void blockUntilServerInState(String serverId, ServerApi api, Status status) {
Server currentDetails = null;
for (currentDetails = api.get(serverId); currentDetails.getStatus() != status ||
(currentDetails.getExtendedStatus().isPresent() && currentDetails.getExtendedStatus().get().getTaskState() != null);
currentDetails = api
.get(serverId)) {
for (currentDetails = api.get(serverId); currentDetails.getStatus() != status
|| ((currentDetails.getExtendedStatus().isPresent() && currentDetails.getExtendedStatus().get()
.getTaskState() != null)); currentDetails = api.get(serverId)) {
System.out.printf("blocking on status %s%n%s%n", status, currentDetails);
try {
Thread.sleep(5 * 1000);

View File

@ -18,8 +18,6 @@
*/
package org.jclouds.hpcloud.objectstorage;
import static org.jclouds.openstack.keystone.v2_0.config.CredentialTypes.API_ACCESS_KEY_CREDENTIALS;
import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE;
import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.REQUIRES_TENANT;
import java.net.URI;
@ -57,7 +55,6 @@ public class HPCloudObjectStorageProviderMetadata extends BaseProviderMetadata {
public static Properties defaultProperties() {
Properties properties = new Properties();
properties.setProperty(CREDENTIAL_TYPE, API_ACCESS_KEY_CREDENTIALS);
properties.setProperty(REQUIRES_TENANT, "true");
return properties;
}

View File

@ -44,7 +44,7 @@ import com.google.common.collect.ImmutableMultimap;
public class HPCloudObjectStorageBlobRequestSignerTest extends BaseHPCloudObjectStorageBlobStoreExpectTest {
Map<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder().put(
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess).build();
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess).build();
public void testSignGetBlob() {

View File

@ -39,7 +39,7 @@ public class HPCloudObjectStorageBlobStoreExpectTest extends BaseHPCloudObjectSt
public void testListObjectsWhenResponseIs2xx() throws Exception {
Map<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder().put(
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess).build();
keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess).build();
BlobStore clientWhenLocationsExist = requestsSendResponses(requestResponseMap);