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; FloatingIP ip = null;
try { try {
logger.debug(">> allocating or reassigning floating ip for node(%s)", node.getId()); logger.debug(">> allocating or reassigning floating ip for node(%s)", node.getId());
ip = floatingIpApi.allocate(); ip = floatingIpApi.create();
} catch (InsufficientResourcesException e) { } catch (InsufficientResourcesException e) {
logger.trace("<< [%s] allocating a new floating ip for node(%s)", e.getMessage(), node.getId()); 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()); 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); logger.debug(">> removing floatingIp(%s) from node(%s)", ip, id);
floatingIpApi.removeFromServer(ip.getIp(), id.getId()); floatingIpApi.removeFromServer(ip.getIp(), id.getId());
logger.debug(">> deallocating floatingIp(%s)", ip); logger.debug(">> deallocating floatingIp(%s)", ip);
floatingIpApi.deallocate(ip.getId()); floatingIpApi.delete(ip.getId());
} }
floatingIpCache.invalidate(id); floatingIpCache.invalidate(id);
return id; return id;
@ -71,6 +71,6 @@ public class RemoveFloatingIpFromNodeAndDeallocate implements Function<ZoneAndId
@Override @Override
public String toString() { 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 public class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet extends
CreateNodesWithGroupEncodedIntoNameThenAddToSet { CreateNodesWithGroupEncodedIntoNameThenAddToSet {
private final AllocateAndAddFloatingIpToNode allocateAndAddFloatingIpToNode; private final AllocateAndAddFloatingIpToNode createAndAddFloatingIpToNode;
private final LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupCache; private final LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupCache;
private final LoadingCache<ZoneAndName, KeyPair> keyPairCache; private final LoadingCache<ZoneAndName, KeyPair> keyPairCache;
private final NovaApi novaApi; private final NovaApi novaApi;
@ -77,15 +77,15 @@ public class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddT
GroupNamingConvention.Factory namingConvention, GroupNamingConvention.Factory namingConvention,
CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.Factory customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory, CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.Factory customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor,
AllocateAndAddFloatingIpToNode allocateAndAddFloatingIpToNode, AllocateAndAddFloatingIpToNode createAndAddFloatingIpToNode,
LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupCache, LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupCache,
LoadingCache<ZoneAndName, KeyPair> keyPairCache, NovaApi novaApi) { LoadingCache<ZoneAndName, KeyPair> keyPairCache, NovaApi novaApi) {
super(addNodeWithTagStrategy, listNodesStrategy, namingConvention, executor, super(addNodeWithTagStrategy, listNodesStrategy, namingConvention, executor,
customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory); customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory);
this.securityGroupCache = checkNotNull(securityGroupCache, "securityGroupCache"); this.securityGroupCache = checkNotNull(securityGroupCache, "securityGroupCache");
this.keyPairCache = checkNotNull(keyPairCache, "keyPairCache"); this.keyPairCache = checkNotNull(keyPairCache, "keyPairCache");
this.allocateAndAddFloatingIpToNode = checkNotNull(allocateAndAddFloatingIpToNode, this.createAndAddFloatingIpToNode = checkNotNull(createAndAddFloatingIpToNode,
"allocateAndAddFloatingIpToNode"); "createAndAddFloatingIpToNode");
this.novaApi = checkNotNull(novaApi, "novaApi"); this.novaApi = checkNotNull(novaApi, "novaApi");
} }
@ -153,7 +153,7 @@ public class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddT
NovaTemplateOptions templateOptions = NovaTemplateOptions.class.cast(template.getOptions()); NovaTemplateOptions templateOptions = NovaTemplateOptions.class.cast(template.getOptions());
if (templateOptions.shouldAutoAssignFloatingIp()) { if (templateOptions.shouldAutoAssignFloatingIp()) {
return Futures.compose(future, allocateAndAddFloatingIpToNode, executor); return Futures.compose(future, createAndAddFloatingIpToNode, executor);
} else { } else {
return future; return future;
} }

View File

@ -31,10 +31,10 @@ public class NovaProperties {
public static final String TIMEOUT_SECURITYGROUP_PRESENT = "jclouds.openstack-nova.timeout.securitygroup-present"; 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 * Whenever a node is created, automatically create and assign a floating ip address, also
* deallocate when the node is destroyed. * 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 * 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 * 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 * @param id
* the Floating IP id * the Floating IP id
*/ */
void deallocate(String id); void delete(String id);
/** /**
* Add a Floating IP address to a Server * 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); ListenableFuture<? extends FloatingIP> get(@PathParam("id") String id);
/** /**
* @see FloatingIPApi#allocate * @see FloatingIPApi#create
*/ */
@POST @POST
@Path("/os-floating-ips") @Path("/os-floating-ips")
@ -93,16 +93,16 @@ public interface FloatingIPAsyncApi {
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
@Payload("{}") @Payload("{}")
ListenableFuture<? extends FloatingIP> allocate(); ListenableFuture<? extends FloatingIP> create();
/** /**
* @see FloatingIPApi#deallocate * @see FloatingIPApi#delete
*/ */
@DELETE @DELETE
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
@Path("/os-floating-ips/{id}") @Path("/os-floating-ips/{id}")
ListenableFuture<Void> deallocate(@PathParam("id") String id); ListenableFuture<Void> delete(@PathParam("id") String id);
/** /**
* @see FloatingIPApi#addToServer * @see FloatingIPApi#addToServer

View File

@ -37,7 +37,7 @@ import com.google.common.collect.ImmutableSet;
* @see KeystoneProperties#CREDENTIAL_TYPE * @see KeystoneProperties#CREDENTIAL_TYPE
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "unit", testName = "AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest") @Test(groups = "unit", testName = "AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest")
public class AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest extends BaseNovaApiExpectTest { public class AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest extends BaseNovaApiExpectTest {
public AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest() { public AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest() {
identity = "identity"; 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"), URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/os-floating-ips"),
400, 400,
"HTTP/1.1 400 Bad Request", "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); 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")) host).name("Server 71592").status(Status.RUNNING).privateAddresses(ImmutableSet.of("10.4.27.237"))
.credentials(LoginCredentials.builder().password("foo").build()).build(); .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( 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", ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
authToken).build()).payload(payloadFromStringWithContentType("{}", "application/json")).build(); authToken).build()).payload(payloadFromStringWithContentType("{}", "application/json")).build();
@ -65,7 +65,7 @@ public class AllocateAndAddFloatingIpToNodeExpectTest extends BaseNovaComputeSer
HttpResponse addFloatingIPResponse = HttpResponse.builder().statusCode(200).build(); HttpResponse addFloatingIPResponse = HttpResponse.builder().statusCode(200).build();
public void testAllocateWhenAllocationReturnsIpIsAddedToServerAndUpdatesNodeMetadataButSavesCredentials() throws Exception { public void testAllocateWhenAllocationReturnsIpIsAddedToServerAndUpdatesNodeMetadataButSavesCredentials() throws Exception {
HttpResponse allocateFloatingIPResponse = HttpResponse.builder().statusCode(200).payload( HttpResponse createFloatingIPResponse = HttpResponse.builder().statusCode(200).payload(
payloadFromResource("/floatingip_details.json")).build(); payloadFromResource("/floatingip_details.json")).build();
HttpRequest addFloatingIPRequest = addFloatingIPForAddress("10.0.0.3"); HttpRequest addFloatingIPRequest = addFloatingIPForAddress("10.0.0.3");
@ -73,7 +73,7 @@ public class AllocateAndAddFloatingIpToNodeExpectTest extends BaseNovaComputeSer
AllocateAndAddFloatingIpToNode fn = requestsSendResponses( AllocateAndAddFloatingIpToNode fn = requestsSendResponses(
ImmutableMap.<HttpRequest, HttpResponse> builder().put(keystoneAuthWithUsernameAndPasswordAndTenantName, ImmutableMap.<HttpRequest, HttpResponse> builder().put(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess).put(extensionsOfNovaRequest, extensionsOfNovaResponse).put( responseWithKeystoneAccess).put(extensionsOfNovaRequest, extensionsOfNovaResponse).put(
allocateFloatingIP, allocateFloatingIPResponse) createFloatingIP, createFloatingIPResponse)
.put(addFloatingIPRequest, addFloatingIPResponse).build()).getContext().utils().injector() .put(addFloatingIPRequest, addFloatingIPResponse).build()).getContext().utils().injector()
.getInstance(AllocateAndAddFloatingIpToNode.class); .getInstance(AllocateAndAddFloatingIpToNode.class);
@ -98,12 +98,12 @@ public class AllocateAndAddFloatingIpToNodeExpectTest extends BaseNovaComputeSer
} }
public void testAllocateWhenAllocationFailsLookupUnusedIpAddToServerAndUpdatesNodeMetadata() throws Exception { public void testAllocateWhenAllocationFailsLookupUnusedIpAddToServerAndUpdatesNodeMetadata() throws Exception {
HttpResponse allocateFloatingIPResponse = HttpResponse HttpResponse createFloatingIPResponse = HttpResponse
.builder() .builder()
.statusCode(400) .statusCode(400)
.payload( .payload(
payloadFromStringWithContentType( 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(); "application/json")).build();
HttpRequest list = HttpRequest.builder().method("GET").endpoint( HttpRequest list = HttpRequest.builder().method("GET").endpoint(
@ -119,7 +119,7 @@ public class AllocateAndAddFloatingIpToNodeExpectTest extends BaseNovaComputeSer
AllocateAndAddFloatingIpToNode fn = requestsSendResponses( AllocateAndAddFloatingIpToNode fn = requestsSendResponses(
ImmutableMap.<HttpRequest, HttpResponse> builder().put(keystoneAuthWithUsernameAndPasswordAndTenantName, ImmutableMap.<HttpRequest, HttpResponse> builder().put(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess).put(extensionsOfNovaRequest, extensionsOfNovaResponse).put( responseWithKeystoneAccess).put(extensionsOfNovaRequest, extensionsOfNovaResponse).put(
allocateFloatingIP, allocateFloatingIPResponse) createFloatingIP, createFloatingIPResponse)
.put(addFloatingIPRequest, addFloatingIPResponse).put(list, .put(addFloatingIPRequest, addFloatingIPResponse).put(list,
listResponseForUnassigned).build()).getContext().utils().injector() listResponseForUnassigned).build()).getContext().utils().injector()
.getInstance(AllocateAndAddFloatingIpToNode.class); .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.nova.v2_0.options.CreateBackupOfServerOptions;
import org.jclouds.openstack.v2_0.features.ExtensionApi; import org.jclouds.openstack.v2_0.features.ExtensionApi;
import org.testng.SkipException; import org.testng.SkipException;
import org.testng.annotations.AfterGroups; import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod; import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.base.Optional; import com.google.common.base.Optional;
@ -60,7 +60,7 @@ public class AdminActionsApiLiveTest extends BaseNovaApiLiveTest {
private String testServerId; private String testServerId;
private String backupImageId; private String backupImageId;
@BeforeGroups(groups = { "integration", "live" }) @BeforeClass(groups = {"integration", "live"})
@Override @Override
public void setupContext() { public void setupContext() {
super.setupContext(); super.setupContext();
@ -74,9 +74,9 @@ public class AdminActionsApiLiveTest extends BaseNovaApiLiveTest {
} }
} }
@AfterGroups(groups = "live", alwaysRun = true) @AfterClass(groups = { "integration", "live" })
@Override @Override
protected void tearDown() { protected void tearDownContext() {
if (apiOption.isPresent()) { if (apiOption.isPresent()) {
if (testServerId != null) { if (testServerId != null) {
assertTrue(novaContext.getApi().getServerApiForZone(zone).delete(testServerId)); assertTrue(novaContext.getApi().getServerApiForZone(zone).delete(testServerId));
@ -85,7 +85,7 @@ public class AdminActionsApiLiveTest extends BaseNovaApiLiveTest {
imageApi.delete(backupImageId); imageApi.delete(backupImageId);
} }
} }
super.tearDown(); super.tearDownContext();
} }
protected void skipOnAdminExtensionAbsent() { 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.features.FlavorApi;
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest; import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
import org.jclouds.openstack.v2_0.domain.Resource; import org.jclouds.openstack.v2_0.domain.Resource;
import org.testng.annotations.AfterGroups; import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.base.Optional; import com.google.common.base.Optional;
@ -50,7 +50,7 @@ public class FlavorExtraSpecsApiLiveTest extends BaseNovaApiLiveTest {
private Resource testFlavor; private Resource testFlavor;
private Map<String, String> testSpecs = ImmutableMap.of("jclouds-test", "some data", "jclouds-test2", "more data!"); private Map<String, String> testSpecs = ImmutableMap.of("jclouds-test", "some data", "jclouds-test2", "more data!");
@BeforeGroups(groups = { "integration", "live" }) @BeforeClass(groups = {"integration", "live"})
@Override @Override
public void setupContext() { public void setupContext() {
super.setupContext(); super.setupContext();
@ -59,15 +59,15 @@ public class FlavorExtraSpecsApiLiveTest extends BaseNovaApiLiveTest {
apiOption = novaContext.getApi().getFlavorExtraSpecsExtensionForZone(zone); apiOption = novaContext.getApi().getFlavorExtraSpecsExtensionForZone(zone);
} }
@AfterGroups(groups = "live") @AfterClass(groups = { "integration", "live" })
@Override @Override
public void tearDown() { protected void tearDownContext() {
if (apiOption.isPresent() && testFlavor != null) { if (apiOption.isPresent() && testFlavor != null) {
for(String key : testSpecs.keySet()) { for(String key : testSpecs.keySet()) {
assertTrue(apiOption.get().deleteMetadataKey(testFlavor.getId(), key)); assertTrue(apiOption.get().deleteMetadataKey(testFlavor.getId(), key));
} }
} }
super.tearDown(); super.tearDownContext();
} }
public void testCreateExtraSpecs() { public void testCreateExtraSpecs() {

View File

@ -133,7 +133,7 @@ public class FloatingIPApiExpectTest extends BaseNovaApiExpectTest {
} }
public void testAllocateWhenResponseIs2xx() throws Exception { public void testAllocateWhenResponseIs2xx() throws Exception {
HttpRequest allocateFloatingIP = HttpRequest HttpRequest createFloatingIP = HttpRequest
.builder() .builder()
.method("POST") .method("POST")
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips") .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) .addHeader("X-Auth-Token", authToken)
.payload(payloadFromStringWithContentType("{}", "application/json")).build(); .payload(payloadFromStringWithContentType("{}", "application/json")).build();
HttpResponse allocateFloatingIPResponse = HttpResponse.builder().statusCode(200) HttpResponse createFloatingIPResponse = HttpResponse.builder().statusCode(200)
.payload(payloadFromResource("/floatingip_details.json")).build(); .payload(payloadFromResource("/floatingip_details.json")).build();
NovaApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, NovaApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, allocateFloatingIP, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createFloatingIP,
allocateFloatingIPResponse); 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()); new ParseFloatingIPTest().expected().toString());
} }
public void testAllocateWhenResponseIs404() throws Exception { public void testAllocateWhenResponseIs404() throws Exception {
HttpRequest allocateFloatingIP = HttpRequest HttpRequest createFloatingIP = HttpRequest
.builder() .builder()
.method("POST") .method("POST")
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips") .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) .addHeader("X-Auth-Token", authToken)
.payload(payloadFromStringWithContentType("{}", "application/json")).build(); .payload(payloadFromStringWithContentType("{}", "application/json")).build();
HttpResponse allocateFloatingIPResponse = HttpResponse.builder().statusCode(404).build(); HttpResponse createFloatingIPResponse = HttpResponse.builder().statusCode(404).build();
NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, allocateFloatingIP, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createFloatingIP,
allocateFloatingIPResponse); 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 @Test
public void testAllocateAndDeallocateFloatingIPs() throws Exception { public void testAllocateAndDecreateFloatingIPs() throws Exception {
for (String zoneId : novaContext.getApi().getConfiguredZones()) { for (String zoneId : novaContext.getApi().getConfiguredZones()) {
Optional<? extends FloatingIPApi> apiOption = novaContext.getApi().getFloatingIPExtensionForZone(zoneId); Optional<? extends FloatingIPApi> apiOption = novaContext.getApi().getFloatingIPExtensionForZone(zoneId);
if (!apiOption.isPresent()) if (!apiOption.isPresent())
continue; continue;
FloatingIPApi api = apiOption.get(); FloatingIPApi api = apiOption.get();
FloatingIP floatingIP = api.allocate(); FloatingIP floatingIP = api.create();
assertNotNull(floatingIP); assertNotNull(floatingIP);
Set<? extends FloatingIP> response = api.list().toImmutableSet(); Set<? extends FloatingIP> response = api.list().toImmutableSet();
@ -85,7 +85,7 @@ public class FloatingIPApiLiveTest extends BaseNovaApiLiveTest {
} }
assertTrue(ipInSet); assertTrue(ipInSet);
api.deallocate(floatingIP.getId()); api.delete(floatingIP.getId());
response = api.list().toImmutableSet(); response = api.list().toImmutableSet();
ipInSet = false; ipInSet = false;
@ -107,7 +107,7 @@ public class FloatingIPApiLiveTest extends BaseNovaApiLiveTest {
FloatingIPApi api = apiOption.get(); FloatingIPApi api = apiOption.get();
ServerApi serverApi = novaContext.getApi().getServerApiForZone(zoneId); ServerApi serverApi = novaContext.getApi().getServerApiForZone(zoneId);
Server server = createServerInZone(zoneId); Server server = createServerInZone(zoneId);
FloatingIP floatingIP = api.allocate(); FloatingIP floatingIP = api.create();
assertNotNull(floatingIP); assertNotNull(floatingIP);
try { try {
api.addToServer(floatingIP.getIp(), server.getId()); api.addToServer(floatingIP.getIp(), server.getId());

View File

@ -135,7 +135,7 @@ public class FloatingIPAsyncApiExpectTest extends BaseNovaAsyncApiExpectTest {
} }
public void testAllocateWhenResponseIs2xx() throws Exception { public void testAllocateWhenResponseIs2xx() throws Exception {
HttpRequest allocateFloatingIP = HttpRequest HttpRequest createFloatingIP = HttpRequest
.builder() .builder()
.method("POST") .method("POST")
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips") .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) .addHeader("X-Auth-Token", authToken)
.payload(payloadFromStringWithContentType("{}", "application/json")).build(); .payload(payloadFromStringWithContentType("{}", "application/json")).build();
HttpResponse allocateFloatingIPResponse = HttpResponse.builder().statusCode(200) HttpResponse createFloatingIPResponse = HttpResponse.builder().statusCode(200)
.payload(payloadFromResource("/floatingip_details.json")).build(); .payload(payloadFromResource("/floatingip_details.json")).build();
NovaAsyncApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, NovaAsyncApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, allocateFloatingIP, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createFloatingIP,
allocateFloatingIPResponse); 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()); .toString(), new ParseFloatingIPTest().expected().toString());
} }
public void testAllocateWhenResponseIs404() throws Exception { public void testAllocateWhenResponseIs404() throws Exception {
HttpRequest allocateFloatingIP = HttpRequest HttpRequest createFloatingIP = HttpRequest
.builder() .builder()
.method("POST") .method("POST")
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips") .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) .addHeader("X-Auth-Token", authToken)
.payload(payloadFromStringWithContentType("{}", "application/json")).build(); .payload(payloadFromStringWithContentType("{}", "application/json")).build();
HttpResponse allocateFloatingIPResponse = HttpResponse.builder().statusCode(404).build(); HttpResponse createFloatingIPResponse = HttpResponse.builder().statusCode(404).build();
NovaAsyncApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, NovaAsyncApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, allocateFloatingIP, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createFloatingIP,
allocateFloatingIPResponse); 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.Host;
import org.jclouds.openstack.nova.v2_0.domain.HostAggregate; import org.jclouds.openstack.nova.v2_0.domain.HostAggregate;
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest; import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
import org.testng.annotations.AfterGroups; import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.base.Optional; import com.google.common.base.Optional;
@ -49,7 +49,7 @@ public class HostAggregateApiLiveTest extends BaseNovaApiLiveTest {
private HostAggregate testAggregate; private HostAggregate testAggregate;
@BeforeGroups(groups = {"integration", "live"}) @BeforeClass(groups = {"integration", "live"})
@Override @Override
public void setupContext() { public void setupContext() {
super.setupContext(); super.setupContext();
@ -58,13 +58,13 @@ public class HostAggregateApiLiveTest extends BaseNovaApiLiveTest {
hostAdminOption = novaContext.getApi().getHostAdministrationExtensionForZone(zone); hostAdminOption = novaContext.getApi().getHostAdministrationExtensionForZone(zone);
} }
@AfterClass(groups = { "integration", "live" })
@Override @Override
@AfterGroups(groups = {"integration", "live"}) protected void tearDownContext() {
public void tearDown() {
if (testAggregate != null) { if (testAggregate != null) {
assertTrue(apiOption.get().delete(testAggregate.getId())); assertTrue(apiOption.get().delete(testAggregate.getId()));
} }
super.tearDown(); super.tearDownContext();
} }
public void testCreateAggregate() { 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.CreateVolumeOptions;
import org.jclouds.openstack.nova.v2_0.options.CreateVolumeSnapshotOptions; import org.jclouds.openstack.nova.v2_0.options.CreateVolumeSnapshotOptions;
import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.RetryablePredicate;
import org.testng.annotations.AfterGroups; import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.base.Objects; import com.google.common.base.Objects;
@ -54,7 +54,7 @@ public class VolumeApiLiveTest extends BaseNovaApiLiveTest {
private Volume testVolume; private Volume testVolume;
private VolumeSnapshot testSnapshot; private VolumeSnapshot testSnapshot;
@BeforeGroups(groups = { "integration", "live" }) @BeforeClass(groups = {"integration", "live"})
@Override @Override
public void setupContext() { public void setupContext() {
super.setupContext(); super.setupContext();
@ -62,9 +62,9 @@ public class VolumeApiLiveTest extends BaseNovaApiLiveTest {
volumeOption = novaContext.getApi().getVolumeExtensionForZone(zone); volumeOption = novaContext.getApi().getVolumeExtensionForZone(zone);
} }
@AfterGroups(groups = "live", alwaysRun = true) @AfterClass(groups = { "integration", "live" })
@Override @Override
protected void tearDown() { protected void tearDownContext() {
if (volumeOption.isPresent()) { if (volumeOption.isPresent()) {
if (testSnapshot != null) { if (testSnapshot != null) {
final String snapshotId = testSnapshot.getId(); final String snapshotId = testSnapshot.getId();
@ -87,7 +87,7 @@ public class VolumeApiLiveTest extends BaseNovaApiLiveTest {
}, 180 * 1000L).apply(volumeOption.get())); }, 180 * 1000L).apply(volumeOption.get()));
} }
} }
super.tearDown(); super.tearDownContext();
} }
public void testCreateVolume() { 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.internal.BaseNovaApiLiveTest;
import org.jclouds.openstack.nova.v2_0.options.CreateVolumeTypeOptions; import org.jclouds.openstack.nova.v2_0.options.CreateVolumeTypeOptions;
import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.RetryablePredicate;
import org.testng.annotations.AfterGroups; import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -59,9 +59,10 @@ public class VolumeTypeApiLiveTest extends BaseNovaApiLiveTest {
volumeTypeOption = novaContext.getApi().getVolumeTypeExtensionForZone(zone); volumeTypeOption = novaContext.getApi().getVolumeTypeExtensionForZone(zone);
} }
@AfterGroups(groups = "live")
@AfterClass(groups = { "integration", "live" })
@Override @Override
protected void tearDown() { protected void tearDownContext() {
if (volumeTypeOption.isPresent()) { if (volumeTypeOption.isPresent()) {
if (testVolumeType != null) { if (testVolumeType != null) {
final String id = testVolumeType.getId(); final String id = testVolumeType.getId();
@ -74,7 +75,7 @@ public class VolumeTypeApiLiveTest extends BaseNovaApiLiveTest {
}, 5 * 1000L).apply(volumeTypeOption.get())); }, 5 * 1000L).apply(volumeTypeOption.get()));
} }
} }
super.tearDown(); super.tearDownContext();
} }
public void testCreateVolumeType() { public void testCreateVolumeType() {

View File

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

View File

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

View File

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

View File

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