mirror of https://github.com/apache/cloudstack.git
NaaS: Add redundant capability for Gateway service
This commit is contained in:
parent
bc86800d30
commit
47114af94b
|
|
@ -163,6 +163,7 @@ public interface Network extends ControlledEntity {
|
|||
public static final Capability TrafficStatistics = new Capability("TrafficStatistics");
|
||||
public static final Capability LoadBalancingSupportedIps = new Capability("LoadBalancingSupportedIps");
|
||||
public static final Capability AllowDnsSuffixModification = new Capability("AllowDnsSuffixModification");
|
||||
public static final Capability RedundantRouter = new Capability("RedundantRouter");
|
||||
|
||||
private String name;
|
||||
|
||||
|
|
|
|||
|
|
@ -100,4 +100,6 @@ public interface NetworkOffering {
|
|||
boolean getDedicatedLB();
|
||||
|
||||
boolean getSharedSourceNat();
|
||||
|
||||
boolean getRedundantRouter();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2983,9 +2983,17 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
}
|
||||
validateFirewallServiceCapablities(fwServiceCapabilityMap);
|
||||
|
||||
// verify the Gateway service capabilities specified in the network offering
|
||||
Map<Capability, String> gwServiceCapabilityMap = cmd.getServiceCapabilities(Service.Gateway);
|
||||
if (!cmd.getGatewayService() && gwServiceCapabilityMap != null && !gwServiceCapabilityMap.isEmpty()) {
|
||||
throw new InvalidParameterValueException("Capabilities for Gateway service can be specifed only when Gateway service is enabled for network offering.");
|
||||
}
|
||||
validateGatewayServiceCapablities(gwServiceCapabilityMap);
|
||||
|
||||
Map<Service, Map<Capability, String>> serviceCapabilityMap = new HashMap<Service, Map<Capability, String>>();
|
||||
serviceCapabilityMap.put(Service.Lb, lbServiceCapabilityMap);
|
||||
serviceCapabilityMap.put(Service.Firewall, fwServiceCapabilityMap);
|
||||
serviceCapabilityMap.put(Service.Gateway, gwServiceCapabilityMap);
|
||||
|
||||
return createNetworkOffering(userId, name, displayText, trafficType, tags, maxConnections, specifyVlan, availability, networkRate, serviceProviderMap, false,
|
||||
guestType, false, serviceOfferingId, serviceCapabilityMap);
|
||||
|
|
@ -3019,6 +3027,20 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
}
|
||||
}
|
||||
|
||||
void validateGatewayServiceCapablities(Map<Capability, String> gwServiceCapabilityMap) {
|
||||
if (gwServiceCapabilityMap != null) {
|
||||
if (gwServiceCapabilityMap.keySet().size() > 1 || !gwServiceCapabilityMap.containsKey(Capability.RedundantRouter.getName())) {
|
||||
throw new InvalidParameterValueException("Only redundant router capability can be sepcified for gateway service");
|
||||
}
|
||||
String param = gwServiceCapabilityMap.get(Capability.RedundantRouter.getName());
|
||||
boolean enabled = param.contains("true");
|
||||
boolean disabled = param.contains("false");
|
||||
if (!enabled && !disabled) {
|
||||
throw new InvalidParameterValueException("Unknown specified value for " + Capability.RedundantRouter.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public NetworkOfferingVO createNetworkOffering(long userId, String name, String displayText, TrafficType trafficType, String tags, Integer maxConnections, boolean specifyVlan,
|
||||
|
|
@ -3043,7 +3065,14 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
sharedSourceNat = sourceNatType.contains("perzone");
|
||||
}
|
||||
|
||||
NetworkOfferingVO offering = new NetworkOfferingVO(name, displayText, trafficType, systemOnly, specifyVlan, networkRate, multicastRate, maxConnections, isDefault, availability, tags, type, dedicatedLb, sharedSourceNat);
|
||||
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");
|
||||
}
|
||||
|
||||
NetworkOfferingVO offering = new NetworkOfferingVO(name, displayText, trafficType, systemOnly, specifyVlan, networkRate, multicastRate, maxConnections, isDefault, availability, tags, type, dedicatedLb, sharedSourceNat, redundantRouter);
|
||||
|
||||
if (serviceOfferingId != null) {
|
||||
offering.setServiceOfferingId(serviceOfferingId);
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
Map<VirtualMachineProfile.Param, Object> params = new HashMap<VirtualMachineProfile.Param, Object>(1);
|
||||
params.put(VirtualMachineProfile.Param.ReProgramNetwork, true);
|
||||
|
||||
_routerMgr.deployVirtualRouter(network, dest, _accountMgr.getAccount(network.getAccountId()), params, false);
|
||||
_routerMgr.deployVirtualRouter(network, dest, _accountMgr.getAccount(network.getAccountId()), params, offering.getRedundantRouter());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -147,7 +147,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
VirtualMachineProfile<UserVm> uservm = (VirtualMachineProfile<UserVm>)vm;
|
||||
List<DomainRouterVO> routers = _routerMgr.deployVirtualRouter(network, dest, _accountMgr.getAccount(network.getAccountId()), uservm.getParameters(), false);
|
||||
List<DomainRouterVO> routers = _routerMgr.deployVirtualRouter(network, dest, _accountMgr.getAccount(network.getAccountId()), uservm.getParameters(), offering.getRedundantRouter());
|
||||
if ((routers == null) || (routers.size() == 0)) {
|
||||
throw new ResourceUnavailableException("Can't find at least one running router!", this.getClass(), 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,6 +103,9 @@ public class NetworkOfferingVO implements NetworkOffering {
|
|||
@Column(name="shared_source_nat_service")
|
||||
boolean sharedSourceNat;
|
||||
|
||||
@Column(name="redundant_router_service")
|
||||
boolean redundantRouter;
|
||||
|
||||
@Override
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
|
|
@ -237,6 +240,15 @@ public class NetworkOfferingVO implements NetworkOffering {
|
|||
this.sharedSourceNat = sharedSourceNat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getRedundantRouter() {
|
||||
return redundantRouter;
|
||||
}
|
||||
|
||||
public void setRedundantRouter(boolean redundantRouter) {
|
||||
this.redundantRouter = redundantRouter;
|
||||
}
|
||||
|
||||
public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, boolean systemOnly, boolean specifyVlan, Integer rateMbps, Integer multicastRateMbps, Integer concurrentConnections,
|
||||
boolean isDefault, Availability availability, String tags, Network.GuestType guestType) {
|
||||
this.name = name;
|
||||
|
|
@ -254,13 +266,15 @@ public class NetworkOfferingVO implements NetworkOffering {
|
|||
this.guestType = guestType;
|
||||
this.dedicatedLB = true;
|
||||
this.sharedSourceNat =false;
|
||||
this.redundantRouter= false;
|
||||
}
|
||||
|
||||
public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, boolean systemOnly, boolean specifyVlan, Integer rateMbps, Integer multicastRateMbps, Integer concurrentConnections,
|
||||
boolean isDefault, Availability availability, String tags, Network.GuestType guestType, boolean dedicatedLb, boolean sharedSourceNat) {
|
||||
boolean isDefault, Availability availability, String tags, Network.GuestType guestType, boolean dedicatedLb, boolean sharedSourceNat, boolean redundantRouter) {
|
||||
this(name, displayText, trafficType, systemOnly, specifyVlan, rateMbps, multicastRateMbps, concurrentConnections, isDefault, availability, tags, guestType);
|
||||
this.dedicatedLB = dedicatedLb;
|
||||
this.sharedSourceNat = sharedSourceNat;
|
||||
this.redundantRouter = redundantRouter;
|
||||
}
|
||||
|
||||
public NetworkOfferingVO() {
|
||||
|
|
|
|||
|
|
@ -256,6 +256,7 @@ CREATE TABLE `cloud`.`network_offerings` (
|
|||
`availability` varchar(255) NOT NULL COMMENT 'availability of the network',
|
||||
`dedicated_lb_service` int(1) unsigned NOT NULL DEFAULT 1 COMMENT 'true if the network offering provides a dedicated load balancer for each network',
|
||||
`shared_source_nat_service` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if the network offering provides the shared source nat service',
|
||||
`redundant_router_service` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if the network offering provides the redundant router service',
|
||||
`state` char(32) COMMENT 'state of the network offering; has Disabled value by default',
|
||||
`guest_type` char(32) COMMENT 'type of guest network; can be shared or isolated',
|
||||
PRIMARY KEY (`id`),
|
||||
|
|
@ -1863,7 +1864,7 @@ CREATE TABLE `cloud`.`virtual_router_providers` (
|
|||
`id` bigint unsigned NOT NULL auto_increment COMMENT 'id',
|
||||
`nsp_id` bigint unsigned NOT NULL COMMENT 'Network Service Provider ID',
|
||||
`uuid` varchar(255) UNIQUE,
|
||||
`type` varchar(255) NOT NULL COMMENT 'DHCP element, or Virtual router, or redundant virtual router',
|
||||
`type` varchar(255) NOT NULL COMMENT 'Virtual router, or ElbVM',
|
||||
`enabled` int(1) NOT NULL COMMENT 'Enabled or disabled',
|
||||
`removed` datetime COMMENT 'date removed if not null',
|
||||
PRIMARY KEY (`id`),
|
||||
|
|
|
|||
Loading…
Reference in New Issue