mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Merge remote-tracking branch 'origin/4.14'
This commit is contained in:
commit
7bbb4d4bef
@ -109,7 +109,7 @@ public class CreateStaticRouteCmd extends BaseAsyncCreateCmd {
|
||||
routeResponse.setResponseName(getCommandName());
|
||||
} finally {
|
||||
if (!success || route == null) {
|
||||
_vpcService.revokeStaticRoute(getEntityId());
|
||||
_entityMgr.remove(StaticRoute.class, getEntityId());
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create static route");
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,6 +48,9 @@ public class ListStaticRoutesCmd extends BaseListTaggedResourcesCmd {
|
||||
@Parameter(name = ApiConstants.GATEWAY_ID, type = CommandType.UUID, entityType = PrivateGatewayResponse.class, description = "list static routes by gateway id")
|
||||
private Long gatewayId;
|
||||
|
||||
@Parameter(name = ApiConstants.STATE, type = CommandType.STRING, description = "list static routes by state")
|
||||
private String state;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@ -60,6 +63,10 @@ public class ListStaticRoutesCmd extends BaseListTaggedResourcesCmd {
|
||||
return gatewayId;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ -30,6 +30,8 @@ public interface StaticRouteDao extends GenericDao<StaticRouteVO, Long> {
|
||||
|
||||
List<StaticRouteVO> listByVpcId(long vpcId);
|
||||
|
||||
List<StaticRouteVO> listByGatewayId(long gatewayId);
|
||||
|
||||
long countRoutesByGateway(long gatewayId);
|
||||
|
||||
}
|
||||
|
||||
@ -62,6 +62,7 @@ public class StaticRouteDaoImpl extends GenericDaoBase<StaticRouteVO, Long> impl
|
||||
RoutesByGatewayCount = createSearchBuilder(Long.class);
|
||||
RoutesByGatewayCount.select(null, Func.COUNT, RoutesByGatewayCount.entity().getId());
|
||||
RoutesByGatewayCount.and("gatewayId", RoutesByGatewayCount.entity().getVpcGatewayId(), Op.EQ);
|
||||
RoutesByGatewayCount.and("state", RoutesByGatewayCount.entity().getState(), Op.EQ);
|
||||
RoutesByGatewayCount.done();
|
||||
}
|
||||
|
||||
@ -91,10 +92,18 @@ public class StaticRouteDaoImpl extends GenericDaoBase<StaticRouteVO, Long> impl
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StaticRouteVO> listByGatewayId(long gatewayId) {
|
||||
SearchCriteria<StaticRouteVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("gatewayId", gatewayId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countRoutesByGateway(long gatewayId) {
|
||||
SearchCriteria<Long> sc = RoutesByGatewayCount.create();
|
||||
sc.setParameters("gatewayId", gatewayId);
|
||||
sc.setParameters("state", "Active");
|
||||
return customSearch(sc, null).get(0);
|
||||
}
|
||||
|
||||
|
||||
@ -2035,7 +2035,10 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
||||
}
|
||||
}
|
||||
|
||||
// 2) Delete private gateway from the DB
|
||||
// 2) Clean up any remaining routes
|
||||
cleanUpRoutesByGatewayId(gatewayId);
|
||||
|
||||
// 3) Delete private gateway from the DB
|
||||
return deletePrivateGatewayFromTheDB(gateway);
|
||||
|
||||
} finally {
|
||||
@ -2045,6 +2048,13 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
||||
}
|
||||
}
|
||||
|
||||
private void cleanUpRoutesByGatewayId(long gatewayId){
|
||||
List<StaticRouteVO> routes = _staticRouteDao.listByGatewayId(gatewayId);
|
||||
for (StaticRouteVO route: routes){
|
||||
_staticRouteDao.remove(route.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@DB
|
||||
protected boolean deletePrivateGatewayFromTheDB(final PrivateGateway gateway) {
|
||||
// check if there are ips allocted in the network
|
||||
@ -2337,6 +2347,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
||||
final List<Long> permittedAccounts = new ArrayList<Long>();
|
||||
final Map<String, String> tags = cmd.getTags();
|
||||
final Long projectId = cmd.getProjectId();
|
||||
final String state = cmd.getState();
|
||||
|
||||
final Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(domainId, isRecursive,
|
||||
null);
|
||||
@ -2352,6 +2363,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
||||
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
||||
sb.and("vpcId", sb.entity().getVpcId(), SearchCriteria.Op.EQ);
|
||||
sb.and("vpcGatewayId", sb.entity().getVpcGatewayId(), SearchCriteria.Op.EQ);
|
||||
sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ);
|
||||
|
||||
if (tags != null && !tags.isEmpty()) {
|
||||
final SearchBuilder<ResourceTagVO> tagSearch = _resourceTagDao.createSearchBuilder();
|
||||
@ -2379,6 +2391,10 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
||||
sc.addAnd("vpcGatewayId", Op.EQ, gatewayId);
|
||||
}
|
||||
|
||||
if (state != null) {
|
||||
sc.addAnd("state", Op.EQ, state);
|
||||
}
|
||||
|
||||
if (tags != null && !tags.isEmpty()) {
|
||||
int count = 0;
|
||||
sc.setJoinParameters("tagSearch", "resourceType", ResourceObjectType.StaticRoute.toString());
|
||||
|
||||
@ -2666,7 +2666,8 @@
|
||||
url: createURL('listStaticRoutes'),
|
||||
data: {
|
||||
gatewayid: args.context.vpcGateways[0].id,
|
||||
listAll: true
|
||||
listAll: true,
|
||||
state: "Active"
|
||||
},
|
||||
success: function(json) {
|
||||
var items = json.liststaticroutesresponse.staticroute;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user