revised syntax of security groups

This commit is contained in:
Adrian Cole 2012-03-19 17:50:30 -07:00
parent a061348989
commit 206dd67c00
4 changed files with 16 additions and 8 deletions

View File

@ -84,7 +84,7 @@ public interface SecurityGroupAsyncClient {
ListenableFuture<SecurityGroup> getSecurityGroup(@PathParam("id") String id); ListenableFuture<SecurityGroup> getSecurityGroup(@PathParam("id") String id);
/** /**
* @see SecurityGroupClient#createSecurityGroup * @see SecurityGroupClient#createSecurityGroupWithNameAndDescription
*/ */
@POST @POST
@Path("/os-security-groups") @Path("/os-security-groups")
@ -93,7 +93,7 @@ public interface SecurityGroupAsyncClient {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Payload("%7B\"security_group\":%7B\"name\":\"{name}\",\"description\":\"{description}\"%7D%7D") @Payload("%7B\"security_group\":%7B\"name\":\"{name}\",\"description\":\"{description}\"%7D%7D")
ListenableFuture<SecurityGroup> createSecurityGroup(@PayloadParam("name") String name, ListenableFuture<SecurityGroup> createSecurityGroupWithNameAndDescription(@PayloadParam("name") String name,
@PayloadParam("description") String description); @PayloadParam("description") String description);
/** /**

View File

@ -57,7 +57,7 @@ public interface SecurityGroupClient {
* *
* @return a new Security Group * @return a new Security Group
*/ */
SecurityGroup createSecurityGroup(String name, String description); SecurityGroup createSecurityGroupWithNameAndDescription(String name, String description);
/** /**
* Delete a Security Group. * Delete a Security Group.

View File

@ -149,7 +149,7 @@ public class SecurityGroupClientExpectTest extends BaseNovaClientExpectTest {
assertEquals( assertEquals(
clientWhenSecurityGroupsExist.getSecurityGroupExtensionForZone("az-1.region-a.geo-1").get() clientWhenSecurityGroupsExist.getSecurityGroupExtensionForZone("az-1.region-a.geo-1").get()
.createSecurityGroup("name", "description").toString(), createSecurityGroupExpected().toString()); .createSecurityGroupWithNameAndDescription("name", "description").toString(), createSecurityGroupExpected().toString());
} }
public void testDeleteSecurityGroupWhenResponseIs2xx() throws Exception { public void testDeleteSecurityGroupWhenResponseIs2xx() throws Exception {

View File

@ -51,7 +51,8 @@ public class SecurityGroupClientLiveTest extends BaseNovaClientLiveTest {
SecurityGroup securityGroup = null; SecurityGroup securityGroup = null;
String id; String id;
try { try {
securityGroup = client.createSecurityGroup(SECURITY_GROUP_NAME, "test security group"); securityGroup = client
.createSecurityGroupWithNameAndDescription(SECURITY_GROUP_NAME, "test security group");
assertNotNull(securityGroup); assertNotNull(securityGroup);
id = securityGroup.getId(); id = securityGroup.getId();
SecurityGroup theGroup = client.getSecurityGroup(id); SecurityGroup theGroup = client.getSecurityGroup(id);
@ -70,13 +71,20 @@ public class SecurityGroupClientLiveTest extends BaseNovaClientLiveTest {
SecurityGroup securityGroup = null; SecurityGroup securityGroup = null;
try { try {
securityGroup = client.createSecurityGroup(SECURITY_GROUP_NAME, "test security group"); securityGroup = client
.createSecurityGroupWithNameAndDescription(SECURITY_GROUP_NAME, "test security group");
assertNotNull(securityGroup); assertNotNull(securityGroup);
SecurityGroupRule rule = client.createSecurityGroupRule("tcp", "443", "443", "0.0.0.0/0", "", SecurityGroupRule rule = client.createSecurityGroupRule("tcp", "443", "443", "0.0.0.0/0", "", securityGroup
securityGroup.getId()); .getId());
assertNotNull(rule); assertNotNull(rule);
SecurityGroupRule rule2 = client.createSecurityGroupRule("tcp", "443", "443", "", securityGroup.getId(),
securityGroup.getId());
assertNotNull(rule2);
securityGroup = client.getSecurityGroup(securityGroup.getId());
} finally { } finally {
if (securityGroup != null) { if (securityGroup != null) {
client.deleteSecurityGroup(securityGroup.getId()); client.deleteSecurityGroup(securityGroup.getId());