From ac1ea7616abbb89b1f1b8525572ed470037cca28 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Mon, 3 Dec 2012 21:44:40 -0800 Subject: [PATCH] api_refactor: refactor vpc apis - Fix refactored apis in commands*.in - Fix comments etc. - Expand tabs, remove trailing whitespace Signed-off-by: Rohit Yadav --- api/src/com/cloud/network/vpc/VpcService.java | 4 +- .../vpc/command}/CreateStaticRouteCmd.java | 16 +++---- .../api/user/vpc/command}/CreateVPCCmd.java | 46 +++++++++---------- .../vpc/command}/DeleteStaticRouteCmd.java | 18 ++++---- .../api/user/vpc/command}/DeleteVPCCmd.java | 6 +-- .../vpc/command}/ListPrivateGatewaysCmd.java | 22 ++++----- .../vpc/command}/ListStaticRoutesCmd.java | 16 +++---- .../vpc/command}/ListVPCOfferingsCmd.java | 28 +++++------ .../api/user/vpc/command}/ListVPCsCmd.java | 44 +++++++++--------- .../api/user/vpc/command}/RestartVPCCmd.java | 14 +++--- .../api/user/vpc/command}/UpdateVPCCmd.java | 16 +++---- client/tomcatconf/commands.properties.in | 20 ++++---- .../com/cloud/network/vpc/VpcManagerImpl.java | 8 ++-- .../com/cloud/vpc/MockVpcManagerImpl.java | 4 +- 14 files changed, 131 insertions(+), 131 deletions(-) rename api/src/{com/cloud/api/commands => org/apache/cloudstack/api/user/vpc/command}/CreateStaticRouteCmd.java (98%) rename api/src/{com/cloud/api/commands => org/apache/cloudstack/api/user/vpc/command}/CreateVPCCmd.java (94%) rename api/src/{com/cloud/api/commands => org/apache/cloudstack/api/user/vpc/command}/DeleteStaticRouteCmd.java (98%) rename api/src/{com/cloud/api/commands => org/apache/cloudstack/api/user/vpc/command}/DeleteVPCCmd.java (97%) rename api/src/{com/cloud/api/commands => org/apache/cloudstack/api/user/vpc/command}/ListPrivateGatewaysCmd.java (97%) rename api/src/{com/cloud/api/commands => org/apache/cloudstack/api/user/vpc/command}/ListStaticRoutesCmd.java (96%) rename api/src/{com/cloud/api/commands => org/apache/cloudstack/api/user/vpc/command}/ListVPCOfferingsCmd.java (96%) rename api/src/{com/cloud/api/commands => org/apache/cloudstack/api/user/vpc/command}/ListVPCsCmd.java (95%) rename api/src/{com/cloud/api/commands => org/apache/cloudstack/api/user/vpc/command}/RestartVPCCmd.java (97%) rename api/src/{com/cloud/api/commands => org/apache/cloudstack/api/user/vpc/command}/UpdateVPCCmd.java (98%) diff --git a/api/src/com/cloud/network/vpc/VpcService.java b/api/src/com/cloud/network/vpc/VpcService.java index c13e37f1b55..3d6c2b78fd0 100644 --- a/api/src/com/cloud/network/vpc/VpcService.java +++ b/api/src/com/cloud/network/vpc/VpcService.java @@ -20,8 +20,8 @@ import java.util.List; import java.util.Map; import java.util.Set; -import com.cloud.api.commands.ListPrivateGatewaysCmd; -import com.cloud.api.commands.ListStaticRoutesCmd; +import org.apache.cloudstack.api.user.vpc.command.ListPrivateGatewaysCmd; +import org.apache.cloudstack.api.user.vpc.command.ListStaticRoutesCmd; import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.InsufficientAddressCapacityException; import com.cloud.exception.InsufficientCapacityException; diff --git a/api/src/com/cloud/api/commands/CreateStaticRouteCmd.java b/api/src/org/apache/cloudstack/api/user/vpc/command/CreateStaticRouteCmd.java similarity index 98% rename from api/src/com/cloud/api/commands/CreateStaticRouteCmd.java rename to api/src/org/apache/cloudstack/api/user/vpc/command/CreateStaticRouteCmd.java index 446116c3569..bcd1bbb38b9 100644 --- a/api/src/com/cloud/api/commands/CreateStaticRouteCmd.java +++ b/api/src/org/apache/cloudstack/api/user/vpc/command/CreateStaticRouteCmd.java @@ -14,7 +14,7 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package com.cloud.api.commands; +package org.apache.cloudstack.api.user.vpc.command; import org.apache.log4j.Logger; import org.apache.cloudstack.api.ApiConstants; @@ -40,12 +40,12 @@ import com.cloud.user.UserContext; public class CreateStaticRouteCmd extends BaseAsyncCreateCmd{ private static final String s_name = "createstaticrouteresponse"; public static final Logger s_logger = Logger.getLogger(CreateStaticRouteCmd.class.getName()); - + @IdentityMapper(entityTableName="vpc_gateways") - @Parameter(name=ApiConstants.GATEWAY_ID, type=CommandType.LONG, required=true, + @Parameter(name=ApiConstants.GATEWAY_ID, type=CommandType.LONG, required=true, description="the gateway id we are creating static route for") private Long gatewayId; - + @Parameter(name = ApiConstants.CIDR, required = true, type = CommandType.STRING, description = "static route cidr") private String cidr; @@ -100,7 +100,7 @@ public class CreateStaticRouteCmd extends BaseAsyncCreateCmd{ // State is different after the route is applied, so get new object here route = _entityMgr.findById(StaticRoute.class, getEntityId()); - StaticRouteResponse routeResponse = new StaticRouteResponse(); + StaticRouteResponse routeResponse = new StaticRouteResponse(); if (route != null) { routeResponse = _responseGenerator.createStaticRouteResponse(route); setResponseObject(routeResponse); @@ -113,7 +113,7 @@ public class CreateStaticRouteCmd extends BaseAsyncCreateCmd{ } } } - + @Override public String getCommandName() { return s_name; @@ -127,7 +127,7 @@ public class CreateStaticRouteCmd extends BaseAsyncCreateCmd{ } return _vpcService.getVpc(gateway.getVpcId()).getAccountId(); } - + @Override public String getSyncObjType() { return BaseAsyncCmd.vpcSyncObject; @@ -141,7 +141,7 @@ public class CreateStaticRouteCmd extends BaseAsyncCreateCmd{ } return gateway.getVpcId(); } - + @Override public AsyncJob.Type getInstanceType() { return AsyncJob.Type.StaticRoute; diff --git a/api/src/com/cloud/api/commands/CreateVPCCmd.java b/api/src/org/apache/cloudstack/api/user/vpc/command/CreateVPCCmd.java similarity index 94% rename from api/src/com/cloud/api/commands/CreateVPCCmd.java rename to api/src/org/apache/cloudstack/api/user/vpc/command/CreateVPCCmd.java index b07a7146fb2..c56f71587b7 100644 --- a/api/src/com/cloud/api/commands/CreateVPCCmd.java +++ b/api/src/org/apache/cloudstack/api/user/vpc/command/CreateVPCCmd.java @@ -14,7 +14,7 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package com.cloud.api.commands; +package org.apache.cloudstack.api.user.vpc.command; import org.apache.log4j.Logger; @@ -38,52 +38,52 @@ import com.cloud.user.UserContext; public class CreateVPCCmd extends BaseAsyncCreateCmd{ public static final Logger s_logger = Logger.getLogger(CreateVPCCmd.class.getName()); private static final String s_name = "createvpcresponse"; - + ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="the account associated with the VPC. " + - "Must be used with the domainId parameter.") + "Must be used with the domainId parameter.") private String accountName; - + @IdentityMapper(entityTableName="domain") @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the domain ID associated with the VPC. " + - "If used with the account parameter returns the VPC associated with the account for the specified domain.") + "If used with the account parameter returns the VPC associated with the account for the specified domain.") private Long domainId; - + @IdentityMapper(entityTableName="projects") @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="create VPC for the project") private Long projectId; - + @IdentityMapper(entityTableName="data_center") @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the ID of the availability zone") private Long zoneId; @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the VPC") private String vpcName; - + @Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, required=true, description="the display text of " + "the VPC") private String displayText; - + @Parameter(name=ApiConstants.CIDR, type=CommandType.STRING, required=true, description="the cidr of the VPC. All VPC " + - "guest networks' cidrs should be within this CIDR") + "guest networks' cidrs should be within this CIDR") private String cidr; - - + + @IdentityMapper(entityTableName="vpc_offerings") @Parameter(name=ApiConstants.VPC_OFF_ID, type=CommandType.LONG, required=true, description="the ID of the VPC offering") private Long vpcOffering; - - @Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, + + @Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="VPC network domain. All networks inside the VPC will belong to this domain") private String networkDomain; - + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// - + public String getAccountName() { return accountName; } @@ -103,7 +103,7 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd{ public String getCidr() { return cidr; } - + public String getDisplayText() { return displayText; } @@ -111,7 +111,7 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd{ public Long getVpcOffering() { return vpcOffering; } - + public String getNetworkDomain() { return networkDomain; } @@ -126,7 +126,7 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd{ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create a VPC"); } } - + @Override public void execute() { Vpc vpc = null; @@ -139,13 +139,13 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd{ throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage()); } catch (ConcurrentOperationException ex) { s_logger.warn("Exception: ", ex); - throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage()); + throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage()); } catch (InsufficientCapacityException ex) { s_logger.info(ex); s_logger.trace(ex); throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage()); } - + if (vpc != null) { VpcResponse response = _responseGenerator.createVpcResponse(vpc); response.setResponseName(getCommandName()); @@ -171,7 +171,7 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd{ public String getEventDescription() { return "creating VPC. Id: " + getEntityId(); } - + @Override public String getCommandName() { return s_name; @@ -183,7 +183,7 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd{ if (accountId == null) { return UserContext.current().getCaller().getId(); } - + return accountId; } } diff --git a/api/src/com/cloud/api/commands/DeleteStaticRouteCmd.java b/api/src/org/apache/cloudstack/api/user/vpc/command/DeleteStaticRouteCmd.java similarity index 98% rename from api/src/com/cloud/api/commands/DeleteStaticRouteCmd.java rename to api/src/org/apache/cloudstack/api/user/vpc/command/DeleteStaticRouteCmd.java index e2f2c523b9f..1235729016d 100644 --- a/api/src/com/cloud/api/commands/DeleteStaticRouteCmd.java +++ b/api/src/org/apache/cloudstack/api/user/vpc/command/DeleteStaticRouteCmd.java @@ -14,7 +14,7 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package com.cloud.api.commands; +package org.apache.cloudstack.api.user.vpc.command; import org.apache.log4j.Logger; @@ -57,7 +57,7 @@ public class DeleteStaticRouteCmd extends BaseAsyncCmd{ public Long getId() { return id; } - + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -65,7 +65,7 @@ public class DeleteStaticRouteCmd extends BaseAsyncCmd{ public String getCommandName() { return s_name; } - + @Override public String getEventType() { return EventTypes.EVENT_STATIC_ROUTE_DELETE; @@ -75,7 +75,7 @@ public class DeleteStaticRouteCmd extends BaseAsyncCmd{ public String getEventDescription() { return ("Deleting static route id=" + id); } - + @Override public long getEntityOwnerId() { if (ownerId == null) { @@ -88,12 +88,12 @@ public class DeleteStaticRouteCmd extends BaseAsyncCmd{ } return ownerId; } - + @Override public void execute() throws ResourceUnavailableException { UserContext.current().setEventDetails("Route Id: " + id); boolean result = _vpcService.revokeStaticRoute(id); - + if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); this.setResponseObject(response); @@ -101,8 +101,8 @@ public class DeleteStaticRouteCmd extends BaseAsyncCmd{ throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete static route"); } } - - + + @Override public String getSyncObjType() { return BaseAsyncCmd.vpcSyncObject; @@ -116,7 +116,7 @@ public class DeleteStaticRouteCmd extends BaseAsyncCmd{ } return route.getVpcId(); } - + @Override public AsyncJob.Type getInstanceType() { return AsyncJob.Type.StaticRoute; diff --git a/api/src/com/cloud/api/commands/DeleteVPCCmd.java b/api/src/org/apache/cloudstack/api/user/vpc/command/DeleteVPCCmd.java similarity index 97% rename from api/src/com/cloud/api/commands/DeleteVPCCmd.java rename to api/src/org/apache/cloudstack/api/user/vpc/command/DeleteVPCCmd.java index d12c9fa4696..78dbfc1499e 100644 --- a/api/src/com/cloud/api/commands/DeleteVPCCmd.java +++ b/api/src/org/apache/cloudstack/api/user/vpc/command/DeleteVPCCmd.java @@ -14,7 +14,7 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package com.cloud.api.commands; +package org.apache.cloudstack.api.user.vpc.command; import org.apache.log4j.Logger; @@ -79,13 +79,13 @@ public class DeleteVPCCmd extends BaseAsyncCmd{ this.setResponseObject(response); } else { throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete VPC"); - } + } }catch (ResourceUnavailableException ex) { s_logger.warn("Exception: ", ex); throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage()); } catch (ConcurrentOperationException ex) { s_logger.warn("Exception: ", ex); - throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage()); + throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage()); } } diff --git a/api/src/com/cloud/api/commands/ListPrivateGatewaysCmd.java b/api/src/org/apache/cloudstack/api/user/vpc/command/ListPrivateGatewaysCmd.java similarity index 97% rename from api/src/com/cloud/api/commands/ListPrivateGatewaysCmd.java rename to api/src/org/apache/cloudstack/api/user/vpc/command/ListPrivateGatewaysCmd.java index b6a02f3decf..a76b07f51f8 100644 --- a/api/src/com/cloud/api/commands/ListPrivateGatewaysCmd.java +++ b/api/src/org/apache/cloudstack/api/user/vpc/command/ListPrivateGatewaysCmd.java @@ -14,7 +14,7 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package com.cloud.api.commands; +package org.apache.cloudstack.api.user.vpc.command; import java.util.ArrayList; import java.util.List; @@ -43,20 +43,20 @@ public class ListPrivateGatewaysCmd extends BaseListProjectAndAccountResourcesCm @IdentityMapper(entityTableName="vpc_gateways") @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="list private gateway by id") private Long id; - + @Parameter(name=ApiConstants.IP_ADDRESS, type=CommandType.STRING, description="list gateways by ip address") private String ipAddress; - + @Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, description="list gateways by vlan") private String vlan; - + @IdentityMapper(entityTableName="vpc") @Parameter(name=ApiConstants.VPC_ID, type=CommandType.LONG, description="list gateways by vpc") private Long vpcId; - + @Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="list gateways by state") private String state; - + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -69,15 +69,15 @@ public class ListPrivateGatewaysCmd extends BaseListProjectAndAccountResourcesCm public String getIpAddress() { return ipAddress; } - + public Long getVpcId() { return vpcId; } - + public Long getId() { return id; } - + public String getState() { return state; } @@ -89,7 +89,7 @@ public class ListPrivateGatewaysCmd extends BaseListProjectAndAccountResourcesCm public String getCommandName() { return s_name; } - + @Override public void execute() { Pair, Integer> gateways = _vpcService.listPrivateGateway(this); @@ -101,7 +101,7 @@ public class ListPrivateGatewaysCmd extends BaseListProjectAndAccountResourcesCm } response.setResponses(projectResponses, gateways.second()); response.setResponseName(getCommandName()); - + this.setResponseObject(response); } } diff --git a/api/src/com/cloud/api/commands/ListStaticRoutesCmd.java b/api/src/org/apache/cloudstack/api/user/vpc/command/ListStaticRoutesCmd.java similarity index 96% rename from api/src/com/cloud/api/commands/ListStaticRoutesCmd.java rename to api/src/org/apache/cloudstack/api/user/vpc/command/ListStaticRoutesCmd.java index e397c6cc1c2..e5ae9f07ffa 100644 --- a/api/src/com/cloud/api/commands/ListStaticRoutesCmd.java +++ b/api/src/org/apache/cloudstack/api/user/vpc/command/ListStaticRoutesCmd.java @@ -14,7 +14,7 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package com.cloud.api.commands; +package org.apache.cloudstack.api.user.vpc.command; import java.util.ArrayList; import java.util.List; @@ -31,18 +31,18 @@ import com.cloud.utils.Pair; @Implementation(description="Lists all static routes", responseObject=StaticRouteResponse.class) public class ListStaticRoutesCmd extends BaseListTaggedResourcesCmd { private static final String s_name = "liststaticroutesresponse"; - + ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// @IdentityMapper(entityTableName="static_routes") @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="list static route by id") private Long id; - + @IdentityMapper(entityTableName="vpc") @Parameter(name=ApiConstants.VPC_ID, type=CommandType.LONG, description="list static routes by vpc id") private Long vpcId; - + @IdentityMapper(entityTableName="vpc_gateways") @Parameter(name=ApiConstants.GATEWAY_ID, type=CommandType.LONG, description="list static routes by gateway id") private Long gatewayId; @@ -58,7 +58,7 @@ public class ListStaticRoutesCmd extends BaseListTaggedResourcesCmd { public Long getGatewayId() { return gatewayId; } - + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -66,20 +66,20 @@ public class ListStaticRoutesCmd extends BaseListTaggedResourcesCmd { public String getCommandName() { return s_name; } - + @Override public void execute(){ Pair, Integer> result = _vpcService.listStaticRoutes(this); ListResponse response = new ListResponse(); List routeResponses = new ArrayList(); - + for (StaticRoute route : result.first()) { StaticRouteResponse ruleData = _responseGenerator.createStaticRouteResponse(route); routeResponses.add(ruleData); } response.setResponses(routeResponses, result.second()); response.setResponseName(getCommandName()); - this.setResponseObject(response); + this.setResponseObject(response); } diff --git a/api/src/com/cloud/api/commands/ListVPCOfferingsCmd.java b/api/src/org/apache/cloudstack/api/user/vpc/command/ListVPCOfferingsCmd.java similarity index 96% rename from api/src/com/cloud/api/commands/ListVPCOfferingsCmd.java rename to api/src/org/apache/cloudstack/api/user/vpc/command/ListVPCOfferingsCmd.java index ecca2ddb148..727b43c33f7 100644 --- a/api/src/com/cloud/api/commands/ListVPCOfferingsCmd.java +++ b/api/src/org/apache/cloudstack/api/user/vpc/command/ListVPCOfferingsCmd.java @@ -14,7 +14,7 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package com.cloud.api.commands; +package org.apache.cloudstack.api.user.vpc.command; import java.util.ArrayList; import java.util.List; @@ -34,32 +34,32 @@ import com.cloud.network.vpc.VpcOffering; public class ListVPCOfferingsCmd extends BaseListCmd{ public static final Logger s_logger = Logger.getLogger(ListVPCOfferingsCmd.class.getName()); private static final String _name = "listvpcofferingsresponse"; - + ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// @IdentityMapper(entityTableName="vpc_offerings") @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="list VPC offerings by id") private Long id; - + @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="list VPC offerings by name") private String vpcOffName; - + @Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="list VPC offerings by display text") private String displayText; - + @Parameter(name=ApiConstants.IS_DEFAULT, type=CommandType.BOOLEAN, description="true if need to list only default " + - "VPC offerings. Default value is false") + "VPC offerings. Default value is false") private Boolean isDefault; - - @Parameter(name=ApiConstants.SUPPORTED_SERVICES, type=CommandType.LIST, collectionType=CommandType.STRING, + + @Parameter(name=ApiConstants.SUPPORTED_SERVICES, type=CommandType.LIST, collectionType=CommandType.STRING, description="list VPC offerings supporting certain services") private List supportedServices; - + @Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="list VPC offerings by state") private String state; - - + + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -82,11 +82,11 @@ public class ListVPCOfferingsCmd extends BaseListCmd{ public List getSupportedServices() { return supportedServices; } - + public String getState() { return state; } - + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -107,7 +107,7 @@ public class ListVPCOfferingsCmd extends BaseListCmd{ this.setResponseObject(response); } - + @Override public String getCommandName() { return _name; diff --git a/api/src/com/cloud/api/commands/ListVPCsCmd.java b/api/src/org/apache/cloudstack/api/user/vpc/command/ListVPCsCmd.java similarity index 95% rename from api/src/com/cloud/api/commands/ListVPCsCmd.java rename to api/src/org/apache/cloudstack/api/user/vpc/command/ListVPCsCmd.java index fec3eeab425..657dbd84be7 100644 --- a/api/src/com/cloud/api/commands/ListVPCsCmd.java +++ b/api/src/org/apache/cloudstack/api/user/vpc/command/ListVPCsCmd.java @@ -14,7 +14,7 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package com.cloud.api.commands; +package org.apache.cloudstack.api.user.vpc.command; import java.util.ArrayList; import java.util.List; @@ -35,56 +35,56 @@ import com.cloud.network.vpc.Vpc; public class ListVPCsCmd extends BaseListTaggedResourcesCmd{ public static final Logger s_logger = Logger.getLogger(ListVPCsCmd.class.getName()); private static final String s_name = "listvpcsresponse"; - + ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// @IdentityMapper(entityTableName="vpc") @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="list VPC by id") private Long id; - + @IdentityMapper(entityTableName="data_center") @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="list by zone") private Long zoneId; @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="list by name of the VPC") private String vpcName; - + @Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="List by display text of " + "the VPC") private String displayText; - + @Parameter(name=ApiConstants.CIDR, type=CommandType.STRING, description="list by cidr of the VPC. All VPC " + "guest networks' cidrs should be within this CIDR") private String cidr; - + @IdentityMapper(entityTableName="vpc_offerings") @Parameter(name=ApiConstants.VPC_OFF_ID, type=CommandType.LONG, description="list by ID of the VPC offering") private Long VpcOffId; - + @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="list by account associated with the VPC. " + "Must be used with the domainId parameter.") private String accountName; - + @IdentityMapper(entityTableName="domain") @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="list by domain ID associated with the VPC. " + "If used with the account parameter returns the VPC associated with the account for the specified domain.") private Long domainId; - - @Parameter(name=ApiConstants.SUPPORTED_SERVICES, type=CommandType.LIST, collectionType=CommandType.STRING, + + @Parameter(name=ApiConstants.SUPPORTED_SERVICES, type=CommandType.LIST, collectionType=CommandType.STRING, description="list VPC supporting certain services") private List supportedServices; - + @Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="list VPCs by state") private String state; - + @Parameter(name=ApiConstants.RESTART_REQUIRED, type=CommandType.BOOLEAN, description="list VPCs by restartRequired option") private Boolean restartRequired; - + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// - + public String getAccountName() { return accountName; } @@ -104,7 +104,7 @@ public class ListVPCsCmd extends BaseListTaggedResourcesCmd{ public String getCidr() { return cidr; } - + public String getDisplayText() { return displayText; } @@ -112,23 +112,23 @@ public class ListVPCsCmd extends BaseListTaggedResourcesCmd{ public Long getVpcOffId() { return VpcOffId; } - + public Long getId() { return id; } - + public List getSupportedServices() { return supportedServices; } - + public String getState() { return state; } - + public Boolean getRestartRequired() { return restartRequired; } - + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -136,8 +136,8 @@ public class ListVPCsCmd extends BaseListTaggedResourcesCmd{ @Override public void execute() { List vpcs = _vpcService.listVpcs(getId(), getVpcName(), getDisplayText(), - getSupportedServices(), getCidr(), getVpcOffId(), getState(), getAccountName(), getDomainId(), - this.getKeyword(), this.getStartIndex(), this.getPageSizeVal(), getZoneId(), this.isRecursive(), + getSupportedServices(), getCidr(), getVpcOffId(), getState(), getAccountName(), getDomainId(), + this.getKeyword(), this.getStartIndex(), this.getPageSizeVal(), getZoneId(), this.isRecursive(), this.listAll(), getRestartRequired(), getTags(), getProjectId()); ListResponse response = new ListResponse(); List offeringResponses = new ArrayList(); diff --git a/api/src/com/cloud/api/commands/RestartVPCCmd.java b/api/src/org/apache/cloudstack/api/user/vpc/command/RestartVPCCmd.java similarity index 97% rename from api/src/com/cloud/api/commands/RestartVPCCmd.java rename to api/src/org/apache/cloudstack/api/user/vpc/command/RestartVPCCmd.java index dc7d8970981..8421cdeef94 100644 --- a/api/src/com/cloud/api/commands/RestartVPCCmd.java +++ b/api/src/org/apache/cloudstack/api/user/vpc/command/RestartVPCCmd.java @@ -14,7 +14,7 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package com.cloud.api.commands; +package org.apache.cloudstack.api.user.vpc.command; import org.apache.log4j.Logger; @@ -42,7 +42,7 @@ public class RestartVPCCmd extends BaseAsyncCmd{ ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - + @IdentityMapper(entityTableName="vpc") @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the id of the VPC") private Long id; @@ -51,11 +51,11 @@ public class RestartVPCCmd extends BaseAsyncCmd{ ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// - + public Long getId() { return id; } - + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// @@ -64,7 +64,7 @@ public class RestartVPCCmd extends BaseAsyncCmd{ public String getCommandName() { return _name; } - + @Override public long getEntityOwnerId() { Vpc vpc = _entityMgr.findById(Vpc.class, getId()); @@ -84,13 +84,13 @@ public class RestartVPCCmd extends BaseAsyncCmd{ this.setResponseObject(response); } else { throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to restart VPC"); - } + } } catch (ResourceUnavailableException ex) { s_logger.warn("Exception: ", ex); throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage()); } catch (ConcurrentOperationException ex) { s_logger.warn("Exception: ", ex); - throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage()); + throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage()); } catch (InsufficientCapacityException ex) { s_logger.info(ex); s_logger.trace(ex); diff --git a/api/src/com/cloud/api/commands/UpdateVPCCmd.java b/api/src/org/apache/cloudstack/api/user/vpc/command/UpdateVPCCmd.java similarity index 98% rename from api/src/com/cloud/api/commands/UpdateVPCCmd.java rename to api/src/org/apache/cloudstack/api/user/vpc/command/UpdateVPCCmd.java index abe66fe8bb1..14b8ce7b97a 100644 --- a/api/src/com/cloud/api/commands/UpdateVPCCmd.java +++ b/api/src/org/apache/cloudstack/api/user/vpc/command/UpdateVPCCmd.java @@ -14,7 +14,7 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package com.cloud.api.commands; +package org.apache.cloudstack.api.user.vpc.command; import org.apache.log4j.Logger; @@ -38,14 +38,14 @@ public class UpdateVPCCmd extends BaseAsyncCmd{ ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - + @IdentityMapper(entityTableName="vpc") @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the id of the VPC") private Long id; @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the VPC") private String vpcName; - + @Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="the display text of the VPC") private String displayText; @@ -53,19 +53,19 @@ public class UpdateVPCCmd extends BaseAsyncCmd{ ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// - + public String getVpcName() { return vpcName; } - + public String getDisplayText() { return displayText; } - + public Long getId() { return id; } - + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// @@ -74,7 +74,7 @@ public class UpdateVPCCmd extends BaseAsyncCmd{ public String getCommandName() { return _name; } - + @Override public long getEntityOwnerId() { Vpc vpc = _entityMgr.findById(Vpc.class, getId()); diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in index 32848b64ffd..2dd9c164b98 100755 --- a/client/tomcatconf/commands.properties.in +++ b/client/tomcatconf/commands.properties.in @@ -381,21 +381,21 @@ listNetworkDevice=com.cloud.api.commands.ListNetworkDeviceCmd;1 deleteNetworkDevice=com.cloud.api.commands.DeleteNetworkDeviceCmd;1 ### VPC commands -createVPC=com.cloud.api.commands.CreateVPCCmd;15 -listVPCs=com.cloud.api.commands.ListVPCsCmd;15 -deleteVPC=com.cloud.api.commands.DeleteVPCCmd;15 -updateVPC=com.cloud.api.commands.UpdateVPCCmd;15 -restartVPC=com.cloud.api.commands.RestartVPCCmd;15 +createVPC=org.apache.cloudstack.api.user.vpc.command.CreateVPCCmd;15 +listVPCs=org.apache.cloudstack.api.user.vpc.command.ListVPCsCmd;15 +deleteVPC=org.apache.cloudstack.api.user.vpc.command.DeleteVPCCmd;15 +updateVPC=org.apache.cloudstack.api.user.vpc.command.UpdateVPCCmd;15 +restartVPC=org.apache.cloudstack.api.user.vpc.command.RestartVPCCmd;15 #### VPC offering commands createVPCOffering=com.cloud.api.commands.CreateVPCOfferingCmd;1 updateVPCOffering=com.cloud.api.commands.UpdateVPCOfferingCmd;1 deleteVPCOffering=com.cloud.api.commands.DeleteVPCOfferingCmd;1 -listVPCOfferings=com.cloud.api.commands.ListVPCOfferingsCmd;15 +listVPCOfferings=org.apache.cloudstack.api.user.vpc.command.ListVPCOfferingsCmd;15 #### Private gateway commands createPrivateGateway=com.cloud.api.commands.CreatePrivateGatewayCmd;1 -listPrivateGateways=com.cloud.api.commands.ListPrivateGatewaysCmd;15 +listPrivateGateways=org.apache.cloudstack.api.user.vpc.command.ListPrivateGatewaysCmd;15 deletePrivateGateway=com.cloud.api.commands.DeletePrivateGatewayCmd;1 #### Network ACL commands @@ -404,9 +404,9 @@ deleteNetworkACL=com.cloud.api.commands.DeleteNetworkACLCmd;15 listNetworkACLs=com.cloud.api.commands.ListNetworkACLsCmd;15 #### Static route commands -createStaticRoute=com.cloud.api.commands.CreateStaticRouteCmd;15 -deleteStaticRoute=com.cloud.api.commands.DeleteStaticRouteCmd;15 -listStaticRoutes=com.cloud.api.commands.ListStaticRoutesCmd;15 +createStaticRoute=org.apache.cloudstack.api.user.vpc.command.CreateStaticRouteCmd;15 +deleteStaticRoute=org.apache.cloudstack.api.user.vpc.command.DeleteStaticRouteCmd;15 +listStaticRoutes=org.apache.cloudstack.api.user.vpc.command.ListStaticRoutesCmd;15 #### Tags commands createTags=com.cloud.api.commands.CreateTagsCmd;15 diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java index dbaecbbc3cb..5a8d2851170 100644 --- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java +++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java @@ -33,8 +33,8 @@ import javax.naming.ConfigurationException; import org.apache.log4j.Logger; import com.cloud.acl.ControlledEntity.ACLType; -import com.cloud.api.commands.ListPrivateGatewaysCmd; -import com.cloud.api.commands.ListStaticRoutesCmd; +import org.apache.cloudstack.api.user.vpc.command.ListPrivateGatewaysCmd; +import org.apache.cloudstack.api.user.vpc.command.ListStaticRoutesCmd; import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManager; import com.cloud.configuration.Resource.ResourceType; @@ -983,7 +983,7 @@ public class VpcManagerImpl implements VpcManager, Manager{ } else { if (_ntwkMgr.areServicesSupportedInNetwork(network.getId(), Service.Lb)) { throw new InvalidParameterValueException("LB service is already supported " + - "by network " + network + " in VPC " + vpc); + "by network " + network + " in VPC " + vpc); } } } @@ -1070,7 +1070,7 @@ public class VpcManagerImpl implements VpcManager, Manager{ //5) network domain should be the same as VPC's if (!networkDomain.equalsIgnoreCase(vpc.getNetworkDomain())) { throw new InvalidParameterValueException("Network domain of the new network should match network" + - " domain of vpc " + vpc); + " domain of vpc " + vpc); } //6) gateway should never be equal to the cidr subnet diff --git a/server/test/com/cloud/vpc/MockVpcManagerImpl.java b/server/test/com/cloud/vpc/MockVpcManagerImpl.java index 7880402de7b..27ca4c1b607 100644 --- a/server/test/com/cloud/vpc/MockVpcManagerImpl.java +++ b/server/test/com/cloud/vpc/MockVpcManagerImpl.java @@ -24,8 +24,8 @@ import javax.ejb.Local; import javax.naming.ConfigurationException; import com.cloud.acl.ControlledEntity.ACLType; -import com.cloud.api.commands.ListPrivateGatewaysCmd; -import com.cloud.api.commands.ListStaticRoutesCmd; +import org.apache.cloudstack.api.user.vpc.command.ListPrivateGatewaysCmd; +import org.apache.cloudstack.api.user.vpc.command.ListStaticRoutesCmd; import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.InsufficientAddressCapacityException; import com.cloud.exception.InsufficientCapacityException;