mirror of https://github.com/apache/jclouds.git
Merge pull request #1192 from rackspace/rax-clb-access-rules-fix
Changed return types on remove methods and minor naming fixes.
This commit is contained in:
commit
57e2c0cddc
|
@ -31,14 +31,14 @@ import org.jclouds.rackspace.cloudloadbalancers.domain.AccessRuleWithId;
|
||||||
*/
|
*/
|
||||||
public interface AccessRuleApi {
|
public interface AccessRuleApi {
|
||||||
/**
|
/**
|
||||||
* Create a new access list or append to an existing access list.
|
* Create new access rules or append to existing access rules.
|
||||||
*
|
*
|
||||||
* When creating an access list, one or more AccessRules are required. If a populated access list already exists
|
* When creating access rules, one or more AccessRules are required. If populated access rules already exist
|
||||||
* for the load balancer, it will be appended to with subsequent creates. One access list may include up to 100
|
* for the load balancer, it will be appended to with subsequent creates. One access list may include up to 100
|
||||||
* AccessRules. A single address or subnet definition is considered unique and cannot be duplicated between rules
|
* AccessRules. A single address or subnet definition is considered unique and cannot be duplicated between rules
|
||||||
* in an access list.
|
* in an access list.
|
||||||
*/
|
*/
|
||||||
void create(Iterable<AccessRule> accessList);
|
void create(Iterable<AccessRule> accessRules);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List the AccessRules
|
* List the AccessRules
|
||||||
|
@ -47,16 +47,22 @@ public interface AccessRuleApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove an access rule from the access list.
|
* Remove an access rule from the access list.
|
||||||
|
*
|
||||||
|
* @return true on a successful removal, false if the access rule was not found
|
||||||
*/
|
*/
|
||||||
void remove(int id);
|
boolean remove(int id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Batch delete the access rules given the specified ids.
|
* Batch delete the access rules given the specified ids.
|
||||||
|
*
|
||||||
|
* @return true on a successful removal, false if the access rule was not found
|
||||||
*/
|
*/
|
||||||
void remove(Iterable<Integer> ids);
|
boolean remove(Iterable<Integer> ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the entire access list.
|
* Remove the entire access list.
|
||||||
|
*
|
||||||
|
* @return true on a successful removal, false if the access rule was not found
|
||||||
*/
|
*/
|
||||||
void removeAll();
|
boolean removeAll();
|
||||||
}
|
}
|
|
@ -28,7 +28,7 @@ import javax.ws.rs.QueryParam;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
|
import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
|
||||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
|
||||||
import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
|
import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
|
||||||
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
||||||
import org.jclouds.rackspace.cloudloadbalancers.domain.AccessRule;
|
import org.jclouds.rackspace.cloudloadbalancers.domain.AccessRule;
|
||||||
|
@ -55,9 +55,9 @@ public interface AccessRuleAsyncApi {
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@Fallback(NullOnNotFoundOr404.class)
|
@Fallback(VoidOnNotFoundOr404.class)
|
||||||
@Path("/accesslist")
|
@Path("/accesslist")
|
||||||
ListenableFuture<Void> create(@WrapWith("accessList") Iterable<AccessRule> accessList);
|
ListenableFuture<Void> create(@WrapWith("accessList") Iterable<AccessRule> accessRules);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see AccessRuleApi#list()
|
* @see AccessRuleApi#list()
|
||||||
|
@ -73,26 +73,26 @@ public interface AccessRuleAsyncApi {
|
||||||
* @see AccessRuleApi#remove(int)
|
* @see AccessRuleApi#remove(int)
|
||||||
*/
|
*/
|
||||||
@DELETE
|
@DELETE
|
||||||
@Fallback(VoidOnNotFoundOr404.class)
|
@Fallback(FalseOnNotFoundOr404.class)
|
||||||
@Path("/accesslist/{id}")
|
@Path("/accesslist/{id}")
|
||||||
@Consumes("*/*")
|
@Consumes("*/*")
|
||||||
ListenableFuture<Void> remove(@PathParam("id") int id);
|
ListenableFuture<Boolean> remove(@PathParam("id") int id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see AccessRuleApi#remove(Iterable)
|
* @see AccessRuleApi#remove(Iterable)
|
||||||
*/
|
*/
|
||||||
@DELETE
|
@DELETE
|
||||||
@Fallback(VoidOnNotFoundOr404.class)
|
@Fallback(FalseOnNotFoundOr404.class)
|
||||||
@Path("/accesslist")
|
@Path("/accesslist")
|
||||||
@Consumes("*/*")
|
@Consumes("*/*")
|
||||||
ListenableFuture<Void> remove(@QueryParam("id") Iterable<Integer> ids);
|
ListenableFuture<Boolean> remove(@QueryParam("id") Iterable<Integer> ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see AccessRuleApi#removeAll()
|
* @see AccessRuleApi#removeAll()
|
||||||
*/
|
*/
|
||||||
@DELETE
|
@DELETE
|
||||||
@Fallback(VoidOnNotFoundOr404.class)
|
@Fallback(FalseOnNotFoundOr404.class)
|
||||||
@Path("/accesslist")
|
@Path("/accesslist")
|
||||||
@Consumes("*/*")
|
@Consumes("*/*")
|
||||||
ListenableFuture<Void> removeAll();
|
ListenableFuture<Boolean> removeAll();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
package org.jclouds.rackspace.cloudloadbalancers.features;
|
package org.jclouds.rackspace.cloudloadbalancers.features;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -39,7 +40,7 @@ import com.google.common.collect.ImmutableList;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit")
|
@Test(groups = "unit")
|
||||||
public class AccessRuleApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<CloudLoadBalancersApi> {
|
public class AccessRuleApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<CloudLoadBalancersApi> {
|
||||||
public void testListAccessList() {
|
public void testListAccessRules() {
|
||||||
URI endpoint = URI.create("https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/123123/loadbalancers/2000/accesslist");
|
URI endpoint = URI.create("https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/123123/loadbalancers/2000/accesslist");
|
||||||
AccessRuleApi api = requestsSendResponses(
|
AccessRuleApi api = requestsSendResponses(
|
||||||
rackspaceAuthWithUsernameAndApiKey,
|
rackspaceAuthWithUsernameAndApiKey,
|
||||||
|
@ -49,10 +50,10 @@ public class AccessRuleApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<
|
||||||
).getAccessRuleApiForZoneAndLoadBalancer("DFW", 2000);
|
).getAccessRuleApiForZoneAndLoadBalancer("DFW", 2000);
|
||||||
|
|
||||||
Iterable<AccessRuleWithId> accessList = api.list();
|
Iterable<AccessRuleWithId> accessList = api.list();
|
||||||
assertEquals(accessList, getAccessList());
|
assertEquals(accessList, getAccessRules());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateAccessList() {
|
public void testCreateAccessRules() {
|
||||||
URI endpoint = URI.create("https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/123123/loadbalancers/2000/accesslist");
|
URI endpoint = URI.create("https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/123123/loadbalancers/2000/accesslist");
|
||||||
AccessRuleApi api = requestsSendResponses(
|
AccessRuleApi api = requestsSendResponses(
|
||||||
rackspaceAuthWithUsernameAndApiKey,
|
rackspaceAuthWithUsernameAndApiKey,
|
||||||
|
@ -78,7 +79,7 @@ public class AccessRuleApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<
|
||||||
HttpResponse.builder().statusCode(200).build()
|
HttpResponse.builder().statusCode(200).build()
|
||||||
).getAccessRuleApiForZoneAndLoadBalancer("DFW", 2000);
|
).getAccessRuleApiForZoneAndLoadBalancer("DFW", 2000);
|
||||||
|
|
||||||
api.remove(23);
|
assertTrue(api.remove(23));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testRemoveManyAccessRules() {
|
public void testRemoveManyAccessRules() {
|
||||||
|
@ -91,7 +92,7 @@ public class AccessRuleApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<
|
||||||
).getAccessRuleApiForZoneAndLoadBalancer("DFW", 2000);
|
).getAccessRuleApiForZoneAndLoadBalancer("DFW", 2000);
|
||||||
|
|
||||||
List<Integer> accessRuleIds = ImmutableList.<Integer> of(23, 24);
|
List<Integer> accessRuleIds = ImmutableList.<Integer> of(23, 24);
|
||||||
api.remove(accessRuleIds);
|
assertTrue(api.remove(accessRuleIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testRemoveAllAccessRules() {
|
public void testRemoveAllAccessRules() {
|
||||||
|
@ -103,14 +104,14 @@ public class AccessRuleApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<
|
||||||
HttpResponse.builder().statusCode(200).build()
|
HttpResponse.builder().statusCode(200).build()
|
||||||
).getAccessRuleApiForZoneAndLoadBalancer("DFW", 2000);
|
).getAccessRuleApiForZoneAndLoadBalancer("DFW", 2000);
|
||||||
|
|
||||||
api.removeAll();
|
assertTrue(api.removeAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Iterable<AccessRule> getAccessList() {
|
private Iterable<AccessRuleWithId> getAccessRules() {
|
||||||
AccessRule accessRule1 = new AccessRuleWithId(23, "206.160.163.21", AccessRule.Type.DENY);
|
AccessRuleWithId accessRule1 = new AccessRuleWithId(23, "206.160.163.21", AccessRule.Type.DENY);
|
||||||
AccessRule accessRule2 = new AccessRuleWithId(24, "206.160.165.11", AccessRule.Type.DENY);
|
AccessRuleWithId accessRule2 = new AccessRuleWithId(24, "206.160.165.11", AccessRule.Type.DENY);
|
||||||
AccessRule accessRule3 = new AccessRuleWithId(25, "206.160.163.22", AccessRule.Type.DENY);
|
AccessRuleWithId accessRule3 = new AccessRuleWithId(25, "206.160.163.22", AccessRule.Type.DENY);
|
||||||
|
|
||||||
return ImmutableList.<AccessRule> of(accessRule1, accessRule2, accessRule3);
|
return ImmutableList.<AccessRuleWithId> of(accessRule1, accessRule2, accessRule3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class AccessRuleApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
LoadBalancerRequest lbRequest = LoadBalancerRequest.builder()
|
LoadBalancerRequest lbRequest = LoadBalancerRequest.builder()
|
||||||
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(nodeRequest).build();
|
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(nodeRequest).build();
|
||||||
|
|
||||||
zone = Iterables.getFirst(clbApi.getConfiguredZones(), null);
|
zone = "ORD";//Iterables.getFirst(clbApi.getConfiguredZones(), null);
|
||||||
lb = clbApi.getLoadBalancerApiForZone(zone).create(lbRequest);
|
lb = clbApi.getLoadBalancerApiForZone(zone).create(lbRequest);
|
||||||
|
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
|
@ -96,7 +96,7 @@ public class AccessRuleApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
AccessRuleWithId removedAccessRule = Iterables.getFirst(actualAccessList, null);
|
AccessRuleWithId removedAccessRule = Iterables.getFirst(actualAccessList, null);
|
||||||
accessRules.remove(removedAccessRule.getAddress());
|
accessRules.remove(removedAccessRule.getAddress());
|
||||||
|
|
||||||
clbApi.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).remove(removedAccessRule.getId());
|
assertTrue(clbApi.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).remove(removedAccessRule.getId()));
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
|
|
||||||
assertExpectedAccessRules(accessRules);
|
assertExpectedAccessRules(accessRules);
|
||||||
|
@ -111,7 +111,7 @@ public class AccessRuleApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
accessRules.remove(removedAccessRule1.getAddress());
|
accessRules.remove(removedAccessRule1.getAddress());
|
||||||
accessRules.remove(removedAccessRule2.getAddress());
|
accessRules.remove(removedAccessRule2.getAddress());
|
||||||
|
|
||||||
clbApi.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).remove(removedAccessRuleIds);
|
assertTrue(clbApi.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).remove(removedAccessRuleIds));
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
|
|
||||||
assertExpectedAccessRules(accessRules);
|
assertExpectedAccessRules(accessRules);
|
||||||
|
@ -119,7 +119,7 @@ public class AccessRuleApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testRemoveManyAccessRules")
|
@Test(dependsOnMethods = "testRemoveManyAccessRules")
|
||||||
public void testRemoveAllAccessRules() throws Exception {
|
public void testRemoveAllAccessRules() throws Exception {
|
||||||
clbApi.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).removeAll();
|
assertTrue(clbApi.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).removeAll());
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
|
|
||||||
assertExpectedAccessRules(new HashMap<String, AccessRule>());
|
assertExpectedAccessRules(new HashMap<String, AccessRule>());
|
||||||
|
|
Loading…
Reference in New Issue