mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
-introduces 'DistributedRouter' as capability to 'Connectivity' service.
-create VPC offering to permit 'DistributedRouter' as capability to connectivity service
This commit is contained in:
parent
2aff39f8c7
commit
7c4443e233
@ -57,7 +57,7 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
|
||||
public static final Service PortForwarding = new Service("PortForwarding");
|
||||
public static final Service SecurityGroup = new Service("SecurityGroup");
|
||||
public static final Service NetworkACL = new Service("NetworkACL", Capability.SupportedProtocols);
|
||||
public static final Service Connectivity = new Service("Connectivity");
|
||||
public static final Service Connectivity = new Service("Connectivity", Capability.DistributedRouter);
|
||||
|
||||
private final String name;
|
||||
private final Capability[] caps;
|
||||
@ -186,6 +186,7 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
|
||||
public static final Capability SslTermination = new Capability("SslTermination");
|
||||
public static final Capability LbSchemes = new Capability("LbSchemes");
|
||||
public static final Capability DhcpAccrossMultipleSubnets = new Capability("DhcpAccrossMultipleSubnets");
|
||||
public static final Capability DistributedRouter = new Capability("DistributedRouter");
|
||||
|
||||
private final String name;
|
||||
|
||||
|
||||
@ -55,4 +55,9 @@ public interface VpcOffering extends InternalIdentity, Identity {
|
||||
*/
|
||||
Long getServiceOfferingId();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return true if the offering provides a distributed router capable of one-hop forwarding
|
||||
*/
|
||||
boolean supportsDistributedRouter();
|
||||
}
|
||||
|
||||
@ -23,8 +23,10 @@ public interface VpcProvisioningService {
|
||||
|
||||
public VpcOffering getVpcOffering(long vpcOfferingId);
|
||||
|
||||
public VpcOffering createVpcOffering(String name, String displayText, List<String> supportedServices, Map<String, List<String>> serviceProviders,
|
||||
Long serviceOfferingId);
|
||||
public VpcOffering createVpcOffering(String name, String displayText, List<String> supportedServices,
|
||||
Map<String, List<String>> serviceProviders,
|
||||
Map serviceCapabilitystList,
|
||||
Long serviceOfferingId);
|
||||
|
||||
List<? extends VpcOffering> listVpcOfferings(Long id, String name, String displayText, List<String> supportedServicesStr, Boolean isDefault, String keyword,
|
||||
String state, Long startIndex, Long pageSizeVal);
|
||||
|
||||
@ -588,6 +588,7 @@ public class ApiConstants {
|
||||
public static final String VGPU = "vgpu";
|
||||
public static final String VGPUTYPE = "vgputype";
|
||||
public static final String REMAININGCAPACITY = "remainingcapacity";
|
||||
public static final String DISTRIBUTED_VPC_ROUTER = "distributedvpcrouter";
|
||||
|
||||
|
||||
public enum HostDetails {
|
||||
|
||||
@ -66,6 +66,9 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd {
|
||||
+ "If not specified, the provider for the service will be mapped to the default provider on the physical network")
|
||||
private Map<String, String> serviceProviderList;
|
||||
|
||||
@Parameter(name = ApiConstants.SERVICE_CAPABILITY_LIST, type = CommandType.MAP, description = "desired service capabilities as part of vpc offering")
|
||||
private Map serviceCapabilitystList;
|
||||
|
||||
@Parameter(name = ApiConstants.SERVICE_OFFERING_ID,
|
||||
type = CommandType.UUID,
|
||||
entityType = ServiceOfferingResponse.class,
|
||||
@ -112,13 +115,18 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd {
|
||||
return serviceProviderMap;
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getServiceCapabilitystList() {
|
||||
return serviceCapabilitystList;
|
||||
}
|
||||
|
||||
public Long getServiceOfferingId() {
|
||||
return serviceOfferingId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create() throws ResourceAllocationException {
|
||||
VpcOffering vpcOff = _vpcProvSvc.createVpcOffering(getVpcOfferingName(), getDisplayText(), getSupportedServices(), getServiceProviders(), getServiceOfferingId());
|
||||
VpcOffering vpcOff = _vpcProvSvc.createVpcOffering(getVpcOfferingName(), getDisplayText(),
|
||||
getSupportedServices(), getServiceProviders(), getServiceCapabilitystList(), getServiceOfferingId());
|
||||
if (vpcOff != null) {
|
||||
setEntityId(vpcOff.getId());
|
||||
setEntityUuid(vpcOff.getUuid());
|
||||
|
||||
@ -59,6 +59,10 @@ public class VpcOfferingResponse extends BaseResponse {
|
||||
@Param(description = "the list of supported services", responseObject = ServiceResponse.class)
|
||||
private List<ServiceResponse> services;
|
||||
|
||||
@SerializedName(ApiConstants.DISTRIBUTED_VPC_ROUTER)
|
||||
@Param(description = " indicates if the vpc offering supports distributed router for one-hop forwarding")
|
||||
private Boolean supportsDistributedRouter;
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
@ -86,4 +90,8 @@ public class VpcOfferingResponse extends BaseResponse {
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public void setSupportsDistributedRouter(Boolean supportsDistributedRouter) {
|
||||
this.supportsDistributedRouter = supportsDistributedRouter;
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,6 +67,9 @@ public class VpcOfferingVO implements VpcOffering {
|
||||
@Column(name = "service_offering_id")
|
||||
Long serviceOfferingId;
|
||||
|
||||
@Column(name = "supports_distributed_router")
|
||||
boolean supportsDistributedRouter=false;
|
||||
|
||||
public VpcOfferingVO() {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
@ -80,9 +83,11 @@ public class VpcOfferingVO implements VpcOffering {
|
||||
this.state = State.Disabled;
|
||||
}
|
||||
|
||||
public VpcOfferingVO(String name, String displayText, boolean isDefault, Long serviceOfferingId) {
|
||||
public VpcOfferingVO(String name, String displayText, boolean isDefault, Long serviceOfferingId,
|
||||
boolean supportsDistributedRouter) {
|
||||
this(name, displayText, serviceOfferingId);
|
||||
this.isDefault = isDefault;
|
||||
this.supportsDistributedRouter = supportsDistributedRouter;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -145,4 +150,9 @@ public class VpcOfferingVO implements VpcOffering {
|
||||
public Long getServiceOfferingId() {
|
||||
return serviceOfferingId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsDistributedRouter() {
|
||||
return supportsDistributedRouter;
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,7 +281,7 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
|
||||
for (String svc: services) {
|
||||
serviceProviderMap.put(svc, providerSet);
|
||||
}
|
||||
vpcOffer = _vpcProvSvc.createVpcOffering(juniperVPCOfferingName, juniperVPCOfferingDisplayText, services, serviceProviderMap, null);
|
||||
vpcOffer = _vpcProvSvc.createVpcOffering(juniperVPCOfferingName, juniperVPCOfferingDisplayText, services, serviceProviderMap, null, null);
|
||||
((VpcOfferingVO)vpcOffer).setState(VpcOffering.State.Enabled);
|
||||
long id = vpcOffer.getId();
|
||||
_vpcOffDao.update(id, (VpcOfferingVO)vpcOffer);
|
||||
|
||||
@ -2765,6 +2765,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
response.setDisplayText(offering.getDisplayText());
|
||||
response.setIsDefault(offering.isDefault());
|
||||
response.setState(offering.getState().name());
|
||||
response.setSupportsDistributedRouter(offering.supportsDistributedRouter());
|
||||
|
||||
Map<Service, Set<Provider>> serviceProviderMap = ApiDBUtils.listVpcOffServices(offering.getId());
|
||||
List<ServiceResponse> serviceResponses = new ArrayList<ServiceResponse>();
|
||||
|
||||
@ -18,8 +18,10 @@ package com.cloud.network.vpc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@ -231,7 +233,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
||||
svcProviderMap.put(svc, defaultProviders);
|
||||
}
|
||||
}
|
||||
createVpcOffering(VpcOffering.defaultVPCOfferingName, VpcOffering.defaultVPCOfferingName, svcProviderMap, true, State.Enabled, null);
|
||||
createVpcOffering(VpcOffering.defaultVPCOfferingName, VpcOffering.defaultVPCOfferingName, svcProviderMap, true, State.Enabled, null, false);
|
||||
}
|
||||
|
||||
//configure default vpc offering with Netscaler as LB Provider
|
||||
@ -250,7 +252,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
||||
svcProviderMap.put(svc, defaultProviders);
|
||||
}
|
||||
}
|
||||
createVpcOffering(VpcOffering.defaultVPCNSOfferingName, VpcOffering.defaultVPCNSOfferingName, svcProviderMap, false, State.Enabled, null);
|
||||
createVpcOffering(VpcOffering.defaultVPCNSOfferingName, VpcOffering.defaultVPCNSOfferingName, svcProviderMap, false, State.Enabled, null, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -299,8 +301,10 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_VPC_OFFERING_CREATE, eventDescription = "creating vpc offering", create = true)
|
||||
public VpcOffering createVpcOffering(String name, String displayText, List<String> supportedServices, Map<String, List<String>> serviceProviders,
|
||||
Long serviceOfferingId) {
|
||||
public VpcOffering createVpcOffering(String name, String displayText, List<String> supportedServices,
|
||||
Map<String, List<String>> serviceProviders,
|
||||
Map serviceCapabilitystList,
|
||||
Long serviceOfferingId) {
|
||||
Map<Network.Service, Set<Network.Provider>> svcProviderMap = new HashMap<Network.Service, Set<Network.Provider>>();
|
||||
Set<Network.Provider> defaultProviders = new HashSet<Network.Provider>();
|
||||
defaultProviders.add(Provider.VPCVirtualRouter);
|
||||
@ -372,20 +376,25 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
||||
}
|
||||
}
|
||||
|
||||
VpcOffering offering = createVpcOffering(name, displayText, svcProviderMap, false, null, serviceOfferingId);
|
||||
boolean supportsDistributedRouter = isVpcOfferingSupportsDistributedRouter(serviceCapabilitystList);
|
||||
|
||||
VpcOffering offering = createVpcOffering(name, displayText, svcProviderMap, false, null,
|
||||
serviceOfferingId,supportsDistributedRouter);
|
||||
CallContext.current().setEventDetails(" Id: " + offering.getId() + " Name: " + name);
|
||||
|
||||
return offering;
|
||||
}
|
||||
|
||||
@DB
|
||||
protected VpcOffering createVpcOffering(final String name, final String displayText, final Map<Network.Service, Set<Network.Provider>> svcProviderMap,
|
||||
final boolean isDefault, final State state, final Long serviceOfferingId) {
|
||||
protected VpcOffering createVpcOffering(final String name, final String displayText,
|
||||
final Map<Network.Service, Set<Network.Provider>> svcProviderMap,
|
||||
final boolean isDefault, final State state, final Long serviceOfferingId,
|
||||
final boolean supportsDistributedRouter) {
|
||||
return Transaction.execute(new TransactionCallback<VpcOffering>() {
|
||||
@Override
|
||||
public VpcOffering doInTransaction(TransactionStatus status) {
|
||||
// create vpc offering object
|
||||
VpcOfferingVO offering = new VpcOfferingVO(name, displayText, isDefault, serviceOfferingId);
|
||||
// create vpc offering object
|
||||
VpcOfferingVO offering = new VpcOfferingVO(name, displayText, isDefault, serviceOfferingId, supportsDistributedRouter);
|
||||
|
||||
if (state != null) {
|
||||
offering.setState(state);
|
||||
@ -413,6 +422,44 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isVpcOfferingSupportsDistributedRouter(Map serviceCapabilitystList) {
|
||||
boolean supportsDistributedRouter = false;
|
||||
if (serviceCapabilitystList != null && !serviceCapabilitystList.isEmpty()) {
|
||||
Collection serviceCapabilityCollection = serviceCapabilitystList.values();
|
||||
Iterator iter = serviceCapabilityCollection.iterator();
|
||||
Map<Network.Capability, String> capabilityMap = null;
|
||||
|
||||
while (iter.hasNext()) {
|
||||
HashMap<String, String> svcCapabilityMap = (HashMap<String, String>)iter.next();
|
||||
Network.Capability capability = null;
|
||||
String svc = svcCapabilityMap.get("service");
|
||||
String capabilityName = svcCapabilityMap.get("capabilitytype");
|
||||
String capabilityValue = svcCapabilityMap.get("capabilityvalue");
|
||||
if (capabilityName != null) {
|
||||
capability = Network.Capability.getCapability(capabilityName);
|
||||
}
|
||||
|
||||
if ((capability == null) || (capabilityName == null) || (capabilityValue == null)) {
|
||||
throw new InvalidParameterValueException("Invalid capability:" + capabilityName + " capability value:" + capabilityValue);
|
||||
}
|
||||
|
||||
if (!svc.equalsIgnoreCase(Service.Connectivity.getName())) {
|
||||
throw new InvalidParameterValueException("Invalid Service:" + svc + " specified. Only for 'Connectivity' service capabilities can be specified");
|
||||
}
|
||||
|
||||
if (!capabilityName.equalsIgnoreCase("DistributedRouter")) {
|
||||
throw new InvalidParameterValueException("Invalid Capability:" + capabilityName + " specified. Only 'DistributedRouter' capability can be specified.");
|
||||
}
|
||||
|
||||
if (!capabilityValue.equalsIgnoreCase("true") && capabilityValue.equalsIgnoreCase("false")) {
|
||||
throw new InvalidParameterValueException("Invalid Capability value:" + capabilityValue + " specified.");
|
||||
}
|
||||
supportsDistributedRouter = capabilityValue.equalsIgnoreCase("true");
|
||||
}
|
||||
}
|
||||
return supportsDistributedRouter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vpc getActiveVpc(long vpcId) {
|
||||
return _vpcDao.getActiveVpcById(vpcId);
|
||||
|
||||
@ -739,5 +739,5 @@ UPDATE `cloud`.`guest_os_hypervisor` SET `created` = now();
|
||||
ALTER TABLE `cloud`.`guest_os` ADD COLUMN `created` datetime COMMENT 'Time when Guest OS was created in system';
|
||||
ALTER TABLE `cloud`.`guest_os` ADD COLUMN `removed` datetime COMMENT 'Time when Guest OS was removed if deleted, else NULL';
|
||||
UPDATE `cloud`.`guest_os` SET `created` = now();
|
||||
|
||||
ALTER TABLE `cloud`.`vm_reservation` ADD COLUMN `deployment_planner` varchar(40) DEFAULT NULL COMMENT 'Preferred deployment planner for the vm';
|
||||
ALTER TABLE `cloud`.`vpc_offerings` ADD COLUMN supports_distributed_router boolean default false;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user