mirror of https://github.com/apache/cloudstack.git
api_refactor: refactor vpc apis
- Fix refactored apis in commands*.in - Fix comments etc. - Expand tabs, remove trailing whitespace Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
This commit is contained in:
parent
6fc3bc3760
commit
ac1ea7616a
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -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<List<PrivateGateway>, 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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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<List<? extends StaticRoute>, Integer> result = _vpcService.listStaticRoutes(this);
|
||||
ListResponse<StaticRouteResponse> response = new ListResponse<StaticRouteResponse>();
|
||||
List<StaticRouteResponse> routeResponses = new ArrayList<StaticRouteResponse>();
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -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<String> 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<String> 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;
|
||||
|
|
@ -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<String> 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<String> 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<? extends Vpc> 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<VpcResponse> response = new ListResponse<VpcResponse>();
|
||||
List<VpcResponse> offeringResponses = new ArrayList<VpcResponse>();
|
||||
|
|
@ -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);
|
||||
|
|
@ -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());
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue