mirror of https://github.com/apache/cloudstack.git
VPC: added "forVpc" parameter to listNetworkOfferings command. If true, the offeirng can be used for vpc networks only
This commit is contained in:
parent
1011dfd31c
commit
9f6d03b87b
|
|
@ -361,8 +361,6 @@ public class ApiConstants {
|
|||
public static final String VPC_ID = "vpcid";
|
||||
public static final String CAN_USE_FOR_DEPLOY = "canusefordeploy";
|
||||
public static final String GATEWAY_ID = "gatewayid";
|
||||
|
||||
|
||||
public static final String S2S_VPN_GATEWAY_ID = "s2svpngatewayid";
|
||||
public static final String S2S_CUSTOMER_GATEWAY_ID = "s2scustomergatewayid";
|
||||
public static final String IPSEC_PSK = "ipsecpsk";
|
||||
|
|
@ -371,6 +369,7 @@ public class ApiConstants {
|
|||
public static final String IKE_POLICY = "ikepolicy";
|
||||
public static final String ESP_POLICY = "esppolicy";
|
||||
public static final String LIFETIME = "lifetime";
|
||||
public static final String FOR_VPC = "forvpc";
|
||||
|
||||
public enum HostDetails {
|
||||
all, capacity, events, stats, min;
|
||||
|
|
|
|||
|
|
@ -86,6 +86,10 @@ public class ListNetworkOfferingsCmd extends BaseListCmd {
|
|||
@Parameter(name=ApiConstants.IS_TAGGED, type=CommandType.BOOLEAN, description="true if offering has tags specified")
|
||||
private Boolean isTagged;
|
||||
|
||||
@Parameter(name=ApiConstants.FOR_VPC, type=CommandType.BOOLEAN, description="the network offering can be used" +
|
||||
" only for network creation inside the VPC")
|
||||
private Boolean forVpc;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
@ -154,6 +158,10 @@ public class ListNetworkOfferingsCmd extends BaseListCmd {
|
|||
return isTagged;
|
||||
}
|
||||
|
||||
public Boolean getForVpc() {
|
||||
return forVpc;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -70,6 +70,9 @@ public class NetworkOfferingResponse extends BaseResponse{
|
|||
@SerializedName(ApiConstants.SERVICE) @Param(description="the list of supported services", responseObject = ServiceResponse.class)
|
||||
private List<ServiceResponse> services;
|
||||
|
||||
@SerializedName(ApiConstants.FOR_VPC) @Param(description="true if network offering can be used by VPC networks only")
|
||||
private Boolean forVpc;
|
||||
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id.setValue(id);
|
||||
|
|
@ -138,4 +141,8 @@ public class NetworkOfferingResponse extends BaseResponse{
|
|||
public void setSpecifyIpRanges(Boolean specifyIpRanges) {
|
||||
this.specifyIpRanges = specifyIpRanges;
|
||||
}
|
||||
|
||||
public void setForVpc(Boolean forVpc) {
|
||||
this.forVpc = forVpc;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import com.cloud.api.commands.DeleteZoneCmd;
|
|||
import com.cloud.api.commands.LDAPConfigCmd;
|
||||
import com.cloud.api.commands.LDAPRemoveCmd;
|
||||
import com.cloud.api.commands.ListNetworkOfferingsCmd;
|
||||
import com.cloud.api.commands.MarkDefaultZoneForAccountCmd;
|
||||
import com.cloud.api.commands.UpdateCfgCmd;
|
||||
import com.cloud.api.commands.UpdateDiskOfferingCmd;
|
||||
import com.cloud.api.commands.UpdateNetworkOfferingCmd;
|
||||
|
|
@ -259,4 +258,10 @@ public interface ConfigurationService {
|
|||
boolean updateLDAP(LDAPConfigCmd cmd) throws NamingException;
|
||||
|
||||
boolean removeLDAP(LDAPRemoveCmd cmd);
|
||||
|
||||
/**
|
||||
* @param offering
|
||||
* @return
|
||||
*/
|
||||
boolean isOfferingForVpc(NetworkOffering offering);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ import com.cloud.network.security.SecurityGroupManager;
|
|||
import com.cloud.network.security.SecurityGroupVO;
|
||||
import com.cloud.network.security.dao.SecurityGroupDao;
|
||||
import com.cloud.network.vpc.VpcManager;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
|
|
@ -793,4 +794,9 @@ public class ApiDBUtils {
|
|||
public static List<? extends ResourceTag> listByResourceTypeAndId(TaggedResourceType type, long resourceId) {
|
||||
return _taggedResourceService.listByResourceTypeAndId(type, resourceId);
|
||||
}
|
||||
|
||||
public static boolean isOfferingForVpc(NetworkOffering offering) {
|
||||
boolean vpcProvider = _configMgr.isOfferingForVpc(offering);
|
||||
return vpcProvider;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2886,6 +2886,8 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
|
||||
serviceResponses.add(svcRsp);
|
||||
}
|
||||
response.setForVpc(ApiDBUtils.isOfferingForVpc(offering));
|
||||
|
||||
response.setServices(serviceResponses);
|
||||
response.setObjectName("networkoffering");
|
||||
return response;
|
||||
|
|
|
|||
|
|
@ -3283,6 +3283,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
Object specifyIpRanges = cmd.getSpecifyIpRanges();
|
||||
String tags = cmd.getTags();
|
||||
Boolean isTagged = cmd.isTagged();
|
||||
Boolean forVpc = cmd.getForVpc();
|
||||
|
||||
if (zoneId != null) {
|
||||
zone = getZone(zoneId);
|
||||
|
|
@ -3410,7 +3411,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
// filter by supported services
|
||||
boolean listBySupportedServices = (supportedServicesStr != null && !supportedServicesStr.isEmpty() && !offerings.isEmpty());
|
||||
boolean checkIfProvidersAreEnabled = (zoneId != null);
|
||||
boolean parseOfferings = (listBySupportedServices || sourceNatSupported != null || checkIfProvidersAreEnabled);
|
||||
boolean parseOfferings = (listBySupportedServices || sourceNatSupported != null || checkIfProvidersAreEnabled
|
||||
|| forVpc != null);
|
||||
|
||||
if (parseOfferings) {
|
||||
List<NetworkOfferingVO> supportedOfferings = new ArrayList<NetworkOfferingVO>();
|
||||
|
|
@ -3457,6 +3459,10 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
if (sourceNatSupported != null) {
|
||||
addOffering = addOffering && (_networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), Network.Service.SourceNat) == sourceNatSupported);
|
||||
}
|
||||
|
||||
if (forVpc != null) {
|
||||
addOffering = addOffering && (isOfferingForVpc(offering) == forVpc.booleanValue());
|
||||
}
|
||||
|
||||
if (addOffering) {
|
||||
supportedOfferings.add(offering);
|
||||
|
|
@ -3470,6 +3476,13 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOfferingForVpc(NetworkOffering offering) {
|
||||
boolean vpcProvider = _ntwkOffServiceMapDao.isProviderForNetworkOffering(offering.getId(),
|
||||
Provider.VPCVirtualRouter);
|
||||
return vpcProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_OFFERING_DELETE, eventDescription = "deleting network offering")
|
||||
public boolean deleteNetworkOffering(DeleteNetworkOfferingCmd cmd) {
|
||||
|
|
|
|||
|
|
@ -2808,9 +2808,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
//Create guest network
|
||||
Network network = null;
|
||||
if (vpcId != null) {
|
||||
if (!_configMgr.isOfferingForVpc(ntwkOff)){
|
||||
throw new InvalidParameterValueException("Network offering can't be used for VPC networks");
|
||||
}
|
||||
network = createVpcGuestNetwork(networkOfferingId, name, displayText, gateway, cidr, vlanId,
|
||||
networkDomain, owner, sharedDomainId, pNtwk, zoneId, aclType, subdomainAccess, vpcId);
|
||||
} else {
|
||||
if (_configMgr.isOfferingForVpc(ntwkOff)){
|
||||
throw new InvalidParameterValueException("Network offering can be used for VPC networks only");
|
||||
}
|
||||
network = createGuestNetwork(networkOfferingId, name, displayText, gateway, cidr, vlanId,
|
||||
networkDomain, owner, sharedDomainId, pNtwk, zoneId, aclType, subdomainAccess, vpcId);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue