mirror of https://github.com/apache/cloudstack.git
NaaS: Add checking for gateway service in update network offering
This commit is contained in:
parent
5c1773dd26
commit
4ea3aaeb18
|
|
@ -75,6 +75,9 @@ public class NetworkOfferingResponse extends BaseResponse{
|
|||
@SerializedName(ApiConstants.IS_SHARED) @Param(description="true if soruce NAT service offered is shared by multiple networks", responseObject = ServiceResponse.class)
|
||||
private Boolean isSourceNatShared;
|
||||
|
||||
@SerializedName(ApiConstants.REDUNDANT_ROUTER) @Param(description="true if gateway service offered redundant router", responseObject = ServiceResponse.class)
|
||||
private Boolean isRedundantRouter;
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
|
@ -142,4 +145,8 @@ public class NetworkOfferingResponse extends BaseResponse{
|
|||
public void setIsSourceNatShared(boolean isSourceNatShared) {
|
||||
this.isSourceNatShared = isSourceNatShared;
|
||||
}
|
||||
|
||||
public void setIsRedundantRouter(Boolean isRedundantRouter) {
|
||||
this.isRedundantRouter = isRedundantRouter;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2117,6 +2117,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
response.setNetworkRate(ApiDBUtils.getNetworkRate(offering.getId()));
|
||||
response.setIsLBShared(!offering.getDedicatedLB());
|
||||
response.setIsSourceNatShared(offering.getSharedSourceNat());
|
||||
response.setIsRedundantRouter(offering.getRedundantRouter());
|
||||
if (offering.getGuestType() != null) {
|
||||
response.setGuestIpType(offering.getGuestType().toString());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3032,7 +3032,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
if (gwServiceCapabilityMap.keySet().size() > 1 || !gwServiceCapabilityMap.containsKey(Capability.RedundantRouter)) {
|
||||
throw new InvalidParameterValueException("Only redundant router capability can be sepcified for gateway service");
|
||||
}
|
||||
String param = gwServiceCapabilityMap.get(Capability.RedundantRouter.getName());
|
||||
String param = gwServiceCapabilityMap.get(Capability.RedundantRouter);
|
||||
boolean enabled = param.contains("true");
|
||||
boolean disabled = param.contains("false");
|
||||
if (!enabled && !disabled) {
|
||||
|
|
@ -3068,8 +3068,10 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
Map<Capability, String> gwServiceCapabilityMap = serviceCapabilityMap.get(Service.Gateway);
|
||||
boolean redundantRouter = false;
|
||||
if ((gwServiceCapabilityMap != null) && (!gwServiceCapabilityMap.isEmpty())) {
|
||||
String param = gwServiceCapabilityMap.get(Capability.RedundantRouter.getName());
|
||||
redundantRouter = param.contains("true");
|
||||
String param = gwServiceCapabilityMap.get(Capability.RedundantRouter);
|
||||
if (param != null) {
|
||||
redundantRouter = param.contains("true");
|
||||
}
|
||||
}
|
||||
|
||||
NetworkOfferingVO offering = new NetworkOfferingVO(name, displayText, trafficType, systemOnly, specifyVlan, networkRate, multicastRate, maxConnections, isDefault, availability, tags, type, dedicatedLb, sharedSourceNat, redundantRouter);
|
||||
|
|
@ -3439,6 +3441,21 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
}
|
||||
offering.setSharedSourceNat(sharedSourceNat);
|
||||
|
||||
// verify the gateway service capabilities specified in the network offering
|
||||
Map<Capability, String> gatewayServiceCapabilityMap = cmd.getServiceCapabilities(Service.Gateway);
|
||||
boolean redundantRouter = false;
|
||||
|
||||
if (!cmd.getGatewayService() && gatewayServiceCapabilityMap != null && !gatewayServiceCapabilityMap.isEmpty()) {
|
||||
throw new InvalidParameterValueException("Capabilities for Gateway service can be specifed only when Gateway service is enabled for network offering.");
|
||||
}
|
||||
validateGatewayServiceCapablities(gatewayServiceCapabilityMap);
|
||||
|
||||
if ((gatewayServiceCapabilityMap != null) && (!gatewayServiceCapabilityMap.isEmpty())) {
|
||||
String param = gatewayServiceCapabilityMap.get(Capability.RedundantRouter.getName());
|
||||
redundantRouter = param.contains("true");
|
||||
}
|
||||
offering.setRedundantRouter(redundantRouter);
|
||||
|
||||
if (svcPrv != null && !svcPrv.isEmpty()) {
|
||||
if (networksExist) {
|
||||
throw new InvalidParameterValueException("Unable to reset service providers as there are existing networks using this network offering");
|
||||
|
|
|
|||
Loading…
Reference in New Issue