mirror of https://github.com/apache/cloudstack.git
Introduced "supportedServices" parameter to createNetworkOffering API. This parameter replaces old parameters: dhcpService, gatewayService, etc.
This commit is contained in:
parent
75121bd762
commit
339e72d414
|
|
@ -268,16 +268,6 @@ public class ApiConstants {
|
|||
public static final String ACCEPT = "accept";
|
||||
public static final String SORT_KEY = "sortkey";
|
||||
public static final String ACCOUNT_DETAILS = "accountdetails";
|
||||
public static final String DHCP_SERVICE = "dhcpservice";
|
||||
public static final String DNS_SERVICE = "dnsservice";
|
||||
public static final String SOURCE_NAT_SERVICE = "sourcenatservice";
|
||||
public static final String STATIC_NAT_SERVICE = "staticnatservice";
|
||||
public static final String PORT_FORWARDING_SERVICE = "staticnatservice";
|
||||
public static final String VPN_SERVICE = "vpnservice";
|
||||
public static final String USERDATA_SERVICE = "userdataservice";
|
||||
public static final String LB_SERVICE = "lbservice";
|
||||
public static final String FIREWALL_SERVICE = "firewallservice";
|
||||
public static final String GATEWAY_SERVICE = "gatewayservice";
|
||||
public static final String SERVICE_PROVIDER_LIST = "serviceproviderlist";
|
||||
public static final String SERVICE_CAPABILITY_LIST = "servicecapabilitylist";
|
||||
public static final String PROVIDER = "provider";
|
||||
|
|
@ -296,10 +286,9 @@ public class ApiConstants {
|
|||
public static final String KVM_NETWORK_LABEL = "kvmnetworklabel";
|
||||
public static final String VMWARE_NETWORK_LABEL = "vmwarenetworklabel";
|
||||
public static final String NETWORK_SERVICE_PROVIDER_ID = "nspid";
|
||||
public static final String SECURITY_GROUP_SERVICE = "securitygroupservice";
|
||||
public static final String SERVICE_LIST = "servicelist";
|
||||
public static final String CAN_ENABLE_INDIVIDUAL_SERVICE = "canenableindividualservice";
|
||||
public static final String SUPPORTED_SERVICES = "supportedservices";
|
||||
public static final String SUPPORTED_SERVICES = "supportedservices";
|
||||
public static final String NSP_ID= "nspid";
|
||||
public static final String ACL_TYPE= "acltype";
|
||||
public static final String IS_SOURCE_NAT_SHARED = "isshared";
|
||||
|
|
@ -313,4 +302,5 @@ public class ApiConstants {
|
|||
public static final String FIREWALL_DEVICE_NAME = "fwdevicename";
|
||||
public static final String FIREWALL_DEVICE_STATE = "fwdevicestate";
|
||||
public static final String FIREWALL_DEVICE_CAPACITY = "fwdevicecapacity";
|
||||
public static final String SERVICE = "service";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,38 +79,8 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
|
|||
@Parameter(name=ApiConstants.GUEST_IP_TYPE, type=CommandType.STRING, required=true, description="guest type of the network offering: Shared or Isolated")
|
||||
private String guestIptype;
|
||||
|
||||
@Parameter(name=ApiConstants.DHCP_SERVICE, type=CommandType.BOOLEAN, description="true if network offering supports dhcp service")
|
||||
private Boolean dhcpService;
|
||||
|
||||
@Parameter(name=ApiConstants.DNS_SERVICE, type=CommandType.BOOLEAN, description="true if network offering supports dns service")
|
||||
private Boolean dnsService;
|
||||
|
||||
@Parameter(name=ApiConstants.GATEWAY_SERVICE, type=CommandType.BOOLEAN, description="true if network offering supports gateway service")
|
||||
private Boolean gatewayService;
|
||||
|
||||
@Parameter(name=ApiConstants.FIREWALL_SERVICE, type=CommandType.BOOLEAN, description="true if network offering supports firewall service")
|
||||
private Boolean firewallService;
|
||||
|
||||
@Parameter(name=ApiConstants.LB_SERVICE, type=CommandType.BOOLEAN, description="true if network offering supports lb service")
|
||||
private Boolean lbService;
|
||||
|
||||
@Parameter(name=ApiConstants.USERDATA_SERVICE, type=CommandType.BOOLEAN, description="true if network offering supports user data service")
|
||||
private Boolean userdataService;
|
||||
|
||||
@Parameter(name=ApiConstants.SOURCE_NAT_SERVICE, type=CommandType.BOOLEAN, description="true if network offering supports source nat service")
|
||||
private Boolean sourceNatService;
|
||||
|
||||
@Parameter(name=ApiConstants.STATIC_NAT_SERVICE, type=CommandType.BOOLEAN, description="true if network offering supports static nat service")
|
||||
private Boolean staticNatService;
|
||||
|
||||
@Parameter(name=ApiConstants.PORT_FORWARDING_SERVICE, type=CommandType.BOOLEAN, description="true if network offering supports port forwarding service")
|
||||
private Boolean portForwardingService;
|
||||
|
||||
@Parameter(name=ApiConstants.VPN_SERVICE, type=CommandType.BOOLEAN, description="true if network offering supports vpn service")
|
||||
private Boolean vpnService;
|
||||
|
||||
@Parameter(name=ApiConstants.SECURITY_GROUP_SERVICE, type=CommandType.BOOLEAN, description="true if network offering supports security group service")
|
||||
private Boolean securityGroupService;
|
||||
@Parameter(name=ApiConstants.SUPPORTED_SERVICES, type=CommandType.LIST, required=true, collectionType=CommandType.STRING, description="services supported by the network offering")
|
||||
private List<String> supportedServices;
|
||||
|
||||
@Parameter(name = ApiConstants.SERVICE_PROVIDER_LIST, type = CommandType.MAP, description = "provider to service mapping. If not specified, the provider for the service will be mapped to the default provider on the physical network")
|
||||
private Map serviceProviderList;
|
||||
|
|
@ -165,52 +135,12 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
|
|||
public Long getServiceOfferingId() {
|
||||
return serviceOfferingId;
|
||||
}
|
||||
|
||||
public List<String> getSupportedServices() {
|
||||
return supportedServices;
|
||||
}
|
||||
|
||||
public Boolean getDhcpService() {
|
||||
return dhcpService == null ? false : dhcpService;
|
||||
}
|
||||
|
||||
public Boolean getDnsService() {
|
||||
return dnsService == null ? false : dnsService;
|
||||
}
|
||||
|
||||
public Boolean getGatewayService() {
|
||||
return gatewayService == null ? false : gatewayService;
|
||||
}
|
||||
|
||||
public Boolean getFirewallService() {
|
||||
return firewallService == null ? false : firewallService;
|
||||
}
|
||||
|
||||
public Boolean getLbService() {
|
||||
return lbService == null ? false : lbService;
|
||||
}
|
||||
|
||||
public Boolean getUserdataService() {
|
||||
return userdataService == null ? false : userdataService;
|
||||
}
|
||||
|
||||
public Boolean getSourceNatService() {
|
||||
return sourceNatService == null ? false : sourceNatService;
|
||||
}
|
||||
|
||||
public Boolean getStaticNatService() {
|
||||
return staticNatService == null ? false : staticNatService;
|
||||
}
|
||||
|
||||
public Boolean getPortForwardingService() {
|
||||
return portForwardingService == null ? false : portForwardingService;
|
||||
}
|
||||
|
||||
public Boolean getVpnService() {
|
||||
return vpnService == null ? false : vpnService;
|
||||
}
|
||||
|
||||
public Boolean getSecurityGroupService() {
|
||||
return securityGroupService == null ? false : securityGroupService;
|
||||
}
|
||||
|
||||
public String getGuestIpType() {
|
||||
public String getGuestIpType() {
|
||||
return guestIptype;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,13 +18,6 @@
|
|||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
|
|
@ -34,9 +27,6 @@ import com.cloud.api.Implementation;
|
|||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.NetworkOfferingResponse;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
|
|
@ -64,45 +54,6 @@ public class UpdateNetworkOfferingCmd extends BaseCmd {
|
|||
|
||||
@Parameter(name=ApiConstants.SORT_KEY, type=CommandType.INTEGER, description="sort key of the network offering, integer")
|
||||
private Integer sortKey;
|
||||
|
||||
@Parameter(name=ApiConstants.DHCP_SERVICE, type=CommandType.BOOLEAN, description="true is network offering supports dhcp service")
|
||||
private Boolean dhcpService;
|
||||
|
||||
@Parameter(name=ApiConstants.DNS_SERVICE, type=CommandType.BOOLEAN, description="true is network offering supports dns service")
|
||||
private Boolean dnsService;
|
||||
|
||||
@Parameter(name=ApiConstants.GATEWAY_SERVICE, type=CommandType.BOOLEAN, description="true is network offering supports gateway service")
|
||||
private Boolean gatewayService;
|
||||
|
||||
@Parameter(name=ApiConstants.FIREWALL_SERVICE, type=CommandType.BOOLEAN, description="true is network offering supports firewall service")
|
||||
private Boolean firewallService;
|
||||
|
||||
@Parameter(name=ApiConstants.LB_SERVICE, type=CommandType.BOOLEAN, description="true is network offering supports lb service")
|
||||
private Boolean lbService;
|
||||
|
||||
@Parameter(name=ApiConstants.USERDATA_SERVICE, type=CommandType.BOOLEAN, description="true is network offering supports user data service")
|
||||
private Boolean userdataService;
|
||||
|
||||
@Parameter(name=ApiConstants.SOURCE_NAT_SERVICE, type=CommandType.BOOLEAN, description="true is network offering supports source nat service")
|
||||
private Boolean sourceNatService;
|
||||
|
||||
@Parameter(name=ApiConstants.STATIC_NAT_SERVICE, type=CommandType.BOOLEAN, description="true if network offering supports static nat service")
|
||||
private Boolean staticNatService;
|
||||
|
||||
@Parameter(name=ApiConstants.PORT_FORWARDING_SERVICE, type=CommandType.BOOLEAN, description="true if network offering supports port forwarding service")
|
||||
private Boolean portForwardingService;
|
||||
|
||||
@Parameter(name=ApiConstants.VPN_SERVICE, type=CommandType.BOOLEAN, description="true is network offering supports vpn service")
|
||||
private Boolean vpnService;
|
||||
|
||||
@Parameter(name=ApiConstants.SECURITY_GROUP_SERVICE, type=CommandType.BOOLEAN, description="true if network offering supports security service")
|
||||
private Boolean securityGroupService;
|
||||
|
||||
@Parameter(name = ApiConstants.SERVICE_PROVIDER_LIST, type = CommandType.MAP, description = "provider to service mapping. If not specified, the provider for the service will be mapped to the default provider on the physical network")
|
||||
private Map serviceProviderList;
|
||||
|
||||
@Parameter(name = ApiConstants.SERVICE_CAPABILITY_LIST, type = CommandType.MAP, description = "desired service capabilities as part of network offering")
|
||||
private Map serviceCapabilistList;
|
||||
|
||||
@Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="update state for the network offering")
|
||||
private String state;
|
||||
|
|
@ -125,107 +76,8 @@ public class UpdateNetworkOfferingCmd extends BaseCmd {
|
|||
|
||||
public String getAvailability() {
|
||||
return availability;
|
||||
}
|
||||
|
||||
public Boolean getDhcpService() {
|
||||
return dhcpService == null ? false : dhcpService;
|
||||
}
|
||||
|
||||
public Boolean getDnsService() {
|
||||
return dnsService == null ? false : dnsService;
|
||||
}
|
||||
|
||||
public Boolean getGatewayService() {
|
||||
return gatewayService == null ? false : gatewayService;
|
||||
}
|
||||
|
||||
public Boolean getFirewallService() {
|
||||
return firewallService == null ? false : firewallService;
|
||||
}
|
||||
|
||||
public Boolean getLbService() {
|
||||
return lbService == null ? false : lbService;
|
||||
}
|
||||
|
||||
public Boolean getUserdataService() {
|
||||
return userdataService == null ? false : userdataService;
|
||||
}
|
||||
|
||||
public Boolean getSourceNatService() {
|
||||
return sourceNatService == null ? false : sourceNatService;
|
||||
}
|
||||
|
||||
public Boolean getStaticNatService() {
|
||||
return staticNatService == null ? false : staticNatService;
|
||||
}
|
||||
|
||||
public Boolean getPortForwardingService() {
|
||||
return portForwardingService == null ? false : portForwardingService;
|
||||
}
|
||||
|
||||
public Boolean getVpnService() {
|
||||
return vpnService == null ? false : vpnService;
|
||||
}
|
||||
|
||||
public Boolean getSecurityGroupService() {
|
||||
return securityGroupService == null ? false : securityGroupService;
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getServiceProviders() {
|
||||
Map<String, List<String>> serviceProviderMap = null;
|
||||
if (serviceProviderList != null && !serviceProviderList.isEmpty()) {
|
||||
serviceProviderMap = new HashMap<String, List<String>>();
|
||||
Collection servicesCollection = serviceProviderList.values();
|
||||
Iterator iter = servicesCollection.iterator();
|
||||
while (iter.hasNext()) {
|
||||
HashMap<String, String> services = (HashMap<String, String>) iter.next();
|
||||
String service = services.get("service");
|
||||
String provider = services.get("provider");
|
||||
List<String> providerList = null;
|
||||
if (serviceProviderMap.containsKey(service)) {
|
||||
providerList = serviceProviderMap.get(service);
|
||||
} else {
|
||||
providerList = new ArrayList<String>();
|
||||
}
|
||||
providerList.add(provider);
|
||||
serviceProviderMap.put(service, providerList);
|
||||
}
|
||||
}
|
||||
|
||||
return serviceProviderMap;
|
||||
}
|
||||
|
||||
public Map<Capability, String> getServiceCapabilities(Service service) {
|
||||
Map<Capability, String> capabilityMap = null;
|
||||
|
||||
if (serviceCapabilistList != null && !serviceCapabilistList.isEmpty()) {
|
||||
capabilityMap = new HashMap <Capability, String>();
|
||||
Collection serviceCapabilityCollection = serviceCapabilistList.values();
|
||||
Iterator iter = serviceCapabilityCollection.iterator();
|
||||
while (iter.hasNext()) {
|
||||
HashMap<String, String> svcCapabilityMap = (HashMap<String, String>) iter.next();
|
||||
Capability capability = null;
|
||||
String svc = (String) svcCapabilityMap.get("service");
|
||||
String capabilityName = (String) svcCapabilityMap.get("capabilityType");
|
||||
String capabilityValue = (String) svcCapabilityMap.get("capabilityValue");
|
||||
|
||||
if (capabilityName != null) {
|
||||
capability = Capability.getCapability(capabilityName);
|
||||
}
|
||||
|
||||
if ((capability == null) || (capabilityName == null) || (capabilityValue == null) ) {
|
||||
throw new InvalidParameterValueException("Invalid capability:" + capabilityName + " capability value:" + capabilityValue);
|
||||
}
|
||||
if (svc.equalsIgnoreCase(service.getName())) {
|
||||
capabilityMap.put(capability, capabilityValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return capabilityMap;
|
||||
}
|
||||
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,10 +60,6 @@ public class NetworkOfferingResponse extends BaseResponse{
|
|||
|
||||
@SerializedName(ApiConstants.NETWORKRATE) @Param(description="data transfer rate in megabits per second allowed.")
|
||||
private Integer networkRate;
|
||||
|
||||
public Long getId() {
|
||||
return id.getValue();
|
||||
}
|
||||
|
||||
@SerializedName(ApiConstants.STATE) @Param(description="state of the network offering. Can be Disabled/Enabled/Inactive")
|
||||
private String state;
|
||||
|
|
@ -71,7 +67,7 @@ public class NetworkOfferingResponse extends BaseResponse{
|
|||
@SerializedName(ApiConstants.GUEST_IP_TYPE) @Param(description="guest type of the network offering, can be Shared or Isolated")
|
||||
private String guestIpType;
|
||||
|
||||
@SerializedName("service") @Param(description="the list of supported services", responseObject = ServiceResponse.class)
|
||||
@SerializedName(ApiConstants.SERVICE) @Param(description="the list of supported services", responseObject = ServiceResponse.class)
|
||||
private List<ServiceResponse> services;
|
||||
|
||||
@SerializedName(ApiConstants.IS_LB_SHARED) @Param(description="true if load balncer service offered is shared by multiple networks", responseObject = ServiceResponse.class)
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.cloud.api.IdentityProxy;
|
|||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class SrxFirewallResponse extends BaseResponse {
|
||||
|
||||
@SerializedName(ApiConstants.FIREWALL_DEVICE_ID) @Param(description="device id of the SRX firewall")
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ import javax.naming.ConfigurationException;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.acl.SecurityChecker;
|
||||
import com.cloud.acl.ControlledEntity.ACLType;
|
||||
import com.cloud.alert.AlertManager;
|
||||
import com.cloud.api.commands.CreateCfgCmd;
|
||||
import com.cloud.api.commands.CreateDiskOfferingCmd;
|
||||
|
|
@ -2851,9 +2850,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
String trafficTypeString = cmd.getTraffictype();
|
||||
boolean specifyVlan = cmd.getSpecifyVlan();
|
||||
String availabilityStr = cmd.getAvailability();
|
||||
|
||||
Integer networkRate = cmd.getNetworkRate();
|
||||
|
||||
TrafficType trafficType = null;
|
||||
Availability availability = null;
|
||||
Network.GuestType guestType = null;
|
||||
|
|
@ -2915,58 +2912,26 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
Map<Network.Service, Set<Network.Provider>> serviceProviderMap = new HashMap<Network.Service, Set<Network.Provider>>();
|
||||
Set<Network.Provider> defaultProviders = new HashSet<Network.Provider>();
|
||||
defaultProviders.add(Network.Provider.defaultProvider);
|
||||
// populate all services first
|
||||
if (cmd.getDhcpService()) {
|
||||
serviceProviderMap.put(Network.Service.Dhcp, defaultProviders);
|
||||
}
|
||||
|
||||
if (cmd.getDnsService()) {
|
||||
serviceProviderMap.put(Network.Service.Dns, defaultProviders);
|
||||
}
|
||||
|
||||
if (cmd.getFirewallService()) {
|
||||
serviceProviderMap.put(Network.Service.Firewall, defaultProviders);
|
||||
}
|
||||
|
||||
if (cmd.getGatewayService()) {
|
||||
serviceProviderMap.put(Network.Service.Gateway, defaultProviders);
|
||||
}
|
||||
|
||||
if (cmd.getLbService()) {
|
||||
serviceProviderMap.put(Network.Service.Lb, defaultProviders);
|
||||
}
|
||||
|
||||
if (cmd.getSourceNatService()) {
|
||||
if (guestType == GuestType.Shared) {
|
||||
throw new InvalidParameterValueException("Source nat service is is not supported for network offerings with guest ip type " + GuestType.Shared);
|
||||
}
|
||||
serviceProviderMap.put(Network.Service.SourceNat, defaultProviders);
|
||||
}
|
||||
|
||||
if (cmd.getStaticNatService()) {
|
||||
serviceProviderMap.put(Network.Service.StaticNat, defaultProviders);
|
||||
}
|
||||
|
||||
if (cmd.getPortForwardingService()) {
|
||||
serviceProviderMap.put(Network.Service.PortForwarding, defaultProviders);
|
||||
}
|
||||
|
||||
if (cmd.getUserdataService()) {
|
||||
serviceProviderMap.put(Network.Service.UserData, defaultProviders);
|
||||
}
|
||||
|
||||
if (cmd.getVpnService()) {
|
||||
serviceProviderMap.put(Network.Service.Vpn, defaultProviders);
|
||||
}
|
||||
|
||||
if (cmd.getSecurityGroupService()) {
|
||||
//allow security group service for Shared networks only
|
||||
if (guestType != GuestType.Shared) {
|
||||
throw new InvalidParameterValueException("Secrity group service is supported for network offerings with guest ip type " + GuestType.Shared);
|
||||
}
|
||||
Set<Network.Provider> sgProviders = new HashSet<Network.Provider>();
|
||||
sgProviders.add(Provider.SecurityGroupProvider);
|
||||
serviceProviderMap.put(Network.Service.SecurityGroup, sgProviders);
|
||||
//populate the services first
|
||||
for (String serviceName : cmd.getSupportedServices()) {
|
||||
//validate if the service is supported
|
||||
Service service = Network.Service.getService(serviceName);
|
||||
if (service == null) {
|
||||
throw new InvalidParameterValueException("Invalid service " + serviceName);
|
||||
}
|
||||
|
||||
if (service == Service.SecurityGroup) {
|
||||
//allow security group service for Shared networks only
|
||||
if (guestType != GuestType.Shared) {
|
||||
throw new InvalidParameterValueException("Secrity group service is supported for network offerings with guest ip type " + GuestType.Shared);
|
||||
}
|
||||
Set<Network.Provider> sgProviders = new HashSet<Network.Provider>();
|
||||
sgProviders.add(Provider.SecurityGroupProvider);
|
||||
serviceProviderMap.put(Network.Service.SecurityGroup, sgProviders);
|
||||
continue;
|
||||
}
|
||||
serviceProviderMap.put(service, defaultProviders);
|
||||
}
|
||||
|
||||
// populate providers
|
||||
|
|
@ -2994,21 +2959,21 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
|
||||
// verify the LB service capabilities specified in the network offering
|
||||
Map<Capability, String> lbServiceCapabilityMap = cmd.getServiceCapabilities(Service.Lb);
|
||||
if (!cmd.getLbService() && lbServiceCapabilityMap != null && !lbServiceCapabilityMap.isEmpty()) {
|
||||
if (!serviceProviderMap.containsKey(Service.Lb) && lbServiceCapabilityMap != null && !lbServiceCapabilityMap.isEmpty()) {
|
||||
throw new InvalidParameterValueException("Capabilities for LB service can be specifed only when LB service is enabled for network offering.");
|
||||
}
|
||||
validateLoadBalancerServiceCapabilities(lbServiceCapabilityMap);
|
||||
|
||||
// verify the Source NAT service capabilities specified in the network offering
|
||||
Map<Capability, String> sourceNatServiceCapabilityMap = cmd.getServiceCapabilities(Service.SourceNat);
|
||||
if (!cmd.getSourceNatService() && sourceNatServiceCapabilityMap != null && !sourceNatServiceCapabilityMap.isEmpty()) {
|
||||
if (!serviceProviderMap.containsKey(Service.SourceNat) && sourceNatServiceCapabilityMap != null && !sourceNatServiceCapabilityMap.isEmpty()) {
|
||||
throw new InvalidParameterValueException("Capabilities for source NAT service can be specifed only when source NAT service is enabled for network offering.");
|
||||
}
|
||||
validateSourceNatServiceCapablities(sourceNatServiceCapabilityMap);
|
||||
|
||||
// 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()) {
|
||||
if (!serviceProviderMap.containsKey(Service.Gateway) && 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);
|
||||
|
|
@ -3288,7 +3253,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_OFFERING_EDIT, eventDescription = "updating network offering")
|
||||
@DB
|
||||
public NetworkOffering updateNetworkOffering(UpdateNetworkOfferingCmd cmd) {
|
||||
String displayText = cmd.getDisplayText();
|
||||
Long id = cmd.getId();
|
||||
|
|
@ -3351,163 +3315,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
}
|
||||
}
|
||||
|
||||
// All parameters below can be updated only when there are no networks
|
||||
// using this offering
|
||||
Long networks = _networkDao.getNetworkCountByOfferingId(id);
|
||||
boolean networksExist = (networks != null && networks.longValue() > 0);
|
||||
|
||||
// configure service provider map
|
||||
Map<Network.Service, Set<Network.Provider>> serviceProviderMap = new HashMap<Network.Service, Set<Network.Provider>>();
|
||||
Set<Network.Provider> defaultProviders = new HashSet<Network.Provider>();
|
||||
defaultProviders.add(Network.Provider.defaultProvider);
|
||||
// populate all services first
|
||||
if (cmd.getDhcpService()) {
|
||||
serviceProviderMap.put(Network.Service.Dhcp, defaultProviders);
|
||||
}
|
||||
|
||||
if (cmd.getDnsService()) {
|
||||
serviceProviderMap.put(Network.Service.Dns, defaultProviders);
|
||||
}
|
||||
|
||||
if (cmd.getFirewallService()) {
|
||||
serviceProviderMap.put(Network.Service.Firewall, defaultProviders);
|
||||
}
|
||||
|
||||
if (cmd.getGatewayService()) {
|
||||
serviceProviderMap.put(Network.Service.Gateway, defaultProviders);
|
||||
}
|
||||
|
||||
if (cmd.getLbService()) {
|
||||
serviceProviderMap.put(Network.Service.Lb, defaultProviders);
|
||||
}
|
||||
|
||||
if (cmd.getSourceNatService()) {
|
||||
if (offering.getGuestType() == GuestType.Shared) {
|
||||
throw new InvalidParameterValueException("Source nat service is is not supported for network offerings with guest ip type " + GuestType.Shared);
|
||||
}
|
||||
serviceProviderMap.put(Network.Service.SourceNat, defaultProviders);
|
||||
}
|
||||
|
||||
if (cmd.getStaticNatService()) {
|
||||
serviceProviderMap.put(Network.Service.StaticNat, defaultProviders);
|
||||
}
|
||||
|
||||
if (cmd.getPortForwardingService()) {
|
||||
serviceProviderMap.put(Network.Service.PortForwarding, defaultProviders);
|
||||
}
|
||||
|
||||
if (cmd.getUserdataService()) {
|
||||
serviceProviderMap.put(Network.Service.UserData, defaultProviders);
|
||||
}
|
||||
|
||||
if (cmd.getVpnService()) {
|
||||
serviceProviderMap.put(Network.Service.Vpn, defaultProviders);
|
||||
}
|
||||
|
||||
if (cmd.getSecurityGroupService()) {
|
||||
//allow security group service for Shared networks only
|
||||
if (offering.getGuestType() != GuestType.Shared) {
|
||||
throw new InvalidParameterValueException("Secrity group service is supported for network offerings with guest ip type " + GuestType.Shared);
|
||||
}
|
||||
Set<Network.Provider> sgProviders = new HashSet<Network.Provider>();
|
||||
sgProviders.add(Provider.SecurityGroupProvider);
|
||||
serviceProviderMap.put(Network.Service.SecurityGroup, sgProviders);
|
||||
}
|
||||
|
||||
// populate providers
|
||||
Map<String, List<String>> svcPrv = cmd.getServiceProviders();
|
||||
if (svcPrv != null) {
|
||||
for (String serviceStr : svcPrv.keySet()) {
|
||||
Network.Service service = Network.Service.getService(serviceStr);
|
||||
if (serviceProviderMap.containsKey(service)) {
|
||||
Set<Provider> providers = new HashSet<Provider>();
|
||||
for (String prvNameStr : svcPrv.get(serviceStr)) {
|
||||
// check if provider is supported
|
||||
Network.Provider provider;
|
||||
provider = Network.Provider.getProvider(prvNameStr);
|
||||
if (provider == null) {
|
||||
throw new InvalidParameterValueException("Invalid service provider: " + prvNameStr);
|
||||
}
|
||||
providers.add(provider);
|
||||
}
|
||||
serviceProviderMap.put(service, providers);
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Service " + serviceStr + " is not enabled for the network offering, can't add a provider to it");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// verify and update the LB service capabilities specified in the network offering
|
||||
Map<Capability, String> lbServiceCapabilityMap = cmd.getServiceCapabilities(Service.Lb);
|
||||
boolean dedicatedLb = true;
|
||||
if (!cmd.getLbService() && lbServiceCapabilityMap != null && !lbServiceCapabilityMap.isEmpty()) {
|
||||
throw new InvalidParameterValueException("Capabilities for LB service can be specifed only when LB service is enabled for network offering.");
|
||||
}
|
||||
validateLoadBalancerServiceCapabilities(lbServiceCapabilityMap);
|
||||
|
||||
if ((lbServiceCapabilityMap != null) && (!lbServiceCapabilityMap.isEmpty())) {
|
||||
String isolationCapability = lbServiceCapabilityMap.get(Capability.SupportedLBIsolation);
|
||||
dedicatedLb = isolationCapability.contains("dedicated");
|
||||
}
|
||||
offering.setDedicatedLb(dedicatedLb);
|
||||
|
||||
// verify the source NAT service capabilities specified in the network offering
|
||||
Map<Capability, String> sourceNatServiceCapabilityMap = cmd.getServiceCapabilities(Service.SourceNat);
|
||||
boolean sharedSourceNat = false;
|
||||
|
||||
if (!cmd.getSourceNatService() && sourceNatServiceCapabilityMap != null && !sourceNatServiceCapabilityMap.isEmpty()) {
|
||||
throw new InvalidParameterValueException("Capabilities for Firewall service can be specifed only when Firewall service is enabled for network offering.");
|
||||
}
|
||||
validateSourceNatServiceCapablities(sourceNatServiceCapabilityMap);
|
||||
|
||||
if ((sourceNatServiceCapabilityMap != null) && (!sourceNatServiceCapabilityMap.isEmpty())) {
|
||||
String sourceNatType = sourceNatServiceCapabilityMap.get(Capability.SupportedSourceNatTypes.getName());
|
||||
sharedSourceNat = sourceNatType.contains("perzone");
|
||||
}
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
boolean success = true;
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
// update network offering
|
||||
success = success && _networkOfferingDao.update(id, offering);
|
||||
|
||||
if (!serviceProviderMap.isEmpty()) {
|
||||
_ntwkOffServiceMapDao.deleteByOfferingId(id);
|
||||
// update services/providers - delete old ones, insert new ones
|
||||
for (Network.Service service : serviceProviderMap.keySet()) {
|
||||
for (Network.Provider provider : serviceProviderMap.get(service)) {
|
||||
NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(offering.getId(), service, provider);
|
||||
_ntwkOffServiceMapDao.persist(offService);
|
||||
s_logger.trace("Added service for the network offering: " + offService);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
|
||||
if (success) {
|
||||
if (_networkOfferingDao.update(id, offering)) {
|
||||
return _networkOfferingDao.findById(id);
|
||||
} else {
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Reference in New Issue