diff --git a/api/src/com/cloud/api/commands/CreateNetworkCmd.java b/api/src/com/cloud/api/commands/CreateNetworkCmd.java index b07a24cb838..d3df5426941 100644 --- a/api/src/com/cloud/api/commands/CreateNetworkCmd.java +++ b/api/src/com/cloud/api/commands/CreateNetworkCmd.java @@ -27,12 +27,10 @@ import com.cloud.api.BaseCmd; import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; -import com.cloud.api.BaseCmd.CommandType; import com.cloud.api.response.NetworkResponse; import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.InsufficientCapacityException; import com.cloud.network.Network; -import com.cloud.user.Account; import com.cloud.user.UserContext; @Implementation(description="Creates a network", responseObject=NetworkResponse.class) @@ -81,9 +79,6 @@ public class CreateNetworkCmd extends BaseCmd { @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="domain ID of the account owning a network") private Long domainId; - @Parameter(name=ApiConstants.IS_SHARED, type=CommandType.BOOLEAN, description="true is network is shared across accounts in the Zone") - private Boolean isShared; - @Parameter(name=ApiConstants.IS_DEFAULT, type=CommandType.BOOLEAN, description="true if network is default, false otherwise") private Boolean isDefault; @@ -144,10 +139,6 @@ public class CreateNetworkCmd extends BaseCmd { return displayText; } - public boolean getIsShared() { - return isShared == null ? false : isShared; - } - public Boolean isDefault() { return isDefault; } diff --git a/api/src/com/cloud/api/commands/CreateNetworkOfferingCmd.java b/api/src/com/cloud/api/commands/CreateNetworkOfferingCmd.java index b4487f374cf..4636b9d0c27 100644 --- a/api/src/com/cloud/api/commands/CreateNetworkOfferingCmd.java +++ b/api/src/com/cloud/api/commands/CreateNetworkOfferingCmd.java @@ -18,9 +18,11 @@ 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; @@ -31,7 +33,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.offering.NetworkOffering; import com.cloud.offering.NetworkOffering.Availability; import com.cloud.user.Account; @@ -101,6 +102,9 @@ public class CreateNetworkOfferingCmd extends BaseCmd { @Parameter(name=ApiConstants.SECURITY_GROUP_EANBLED, type=CommandType.BOOLEAN, description="true is security group is enabled for the network offering") private Boolean securityGroupEnabled; + + @Parameter(name=ApiConstants.TYPE, type=CommandType.STRING, required=true, description="type of the network offering: Shared or Isolated") + private String type; ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// @@ -182,17 +186,28 @@ public class CreateNetworkOfferingCmd extends BaseCmd { return vpnService == null ? false : vpnService; } - public Map getServiceProviderList() { - Map serviceProviderMap = null; + public String getType() { + return type; + } + + public Map> getServiceProviders() { + Map> serviceProviderMap = null; if (serviceProviderList != null && !serviceProviderList.isEmpty()) { - serviceProviderMap = new HashMap(); + serviceProviderMap = new HashMap>(); Collection servicesCollection = serviceProviderList.values(); Iterator iter = servicesCollection.iterator(); while (iter.hasNext()) { HashMap services = (HashMap) iter.next(); String service = (String)services.get("service"); String provider = (String) services.get("provider"); - serviceProviderMap.put(service, provider); + List providerList = null; + if (serviceProviderMap.containsKey(service)) { + providerList = serviceProviderMap.get(service); + } else { + providerList = new ArrayList(); + } + providerList.add(provider); + serviceProviderMap.put(service, providerList); } } diff --git a/api/src/com/cloud/api/commands/ListNetworkOfferingsCmd.java b/api/src/com/cloud/api/commands/ListNetworkOfferingsCmd.java index eb2ff70f329..e9cedb86d82 100644 --- a/api/src/com/cloud/api/commands/ListNetworkOfferingsCmd.java +++ b/api/src/com/cloud/api/commands/ListNetworkOfferingsCmd.java @@ -27,7 +27,6 @@ import com.cloud.api.ApiConstants; import com.cloud.api.BaseListCmd; import com.cloud.api.Implementation; import com.cloud.api.Parameter; -import com.cloud.api.BaseCmd.CommandType; import com.cloud.api.response.ListResponse; import com.cloud.api.response.NetworkOfferingResponse; import com.cloud.offering.NetworkOffering; diff --git a/api/src/com/cloud/api/commands/ListNetworksCmd.java b/api/src/com/cloud/api/commands/ListNetworksCmd.java index a198a044148..9f660b35f95 100644 --- a/api/src/com/cloud/api/commands/ListNetworksCmd.java +++ b/api/src/com/cloud/api/commands/ListNetworksCmd.java @@ -27,7 +27,6 @@ import com.cloud.api.ApiConstants; import com.cloud.api.BaseListCmd; import com.cloud.api.Implementation; import com.cloud.api.Parameter; -import com.cloud.api.BaseCmd.CommandType; import com.cloud.api.response.ListResponse; import com.cloud.api.response.NetworkResponse; import com.cloud.network.Network; diff --git a/api/src/com/cloud/api/commands/UpdateNetworkOfferingCmd.java b/api/src/com/cloud/api/commands/UpdateNetworkOfferingCmd.java index 23c9425803b..db6e1a9b58c 100644 --- a/api/src/com/cloud/api/commands/UpdateNetworkOfferingCmd.java +++ b/api/src/com/cloud/api/commands/UpdateNetworkOfferingCmd.java @@ -18,6 +18,13 @@ 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; @@ -25,6 +32,7 @@ import com.cloud.api.BaseCmd; import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; +import com.cloud.api.BaseCmd.CommandType; import com.cloud.api.response.NetworkOfferingResponse; import com.cloud.offering.NetworkOffering; import com.cloud.offering.NetworkOffering.Availability; @@ -49,7 +57,40 @@ public class UpdateNetworkOfferingCmd extends BaseCmd { private String displayText; @Parameter(name=ApiConstants.AVAILABILITY, type=CommandType.STRING, description="the availability of network offering. Default value is Required for Guest Virtual network offering; Optional for Guest Direct network offering") - private String availability; + private String availability; + + @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.VPN_SERVICE, type=CommandType.BOOLEAN, description="true is network offering supports vpn service") + private Boolean vpnService; + + @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.STATE, type=CommandType.STRING, description="list network offerings by state") + private String state; + + @Parameter(name=ApiConstants.SECURITY_GROUP_EANBLED, type=CommandType.BOOLEAN, description="true is security group is enabled for the network offering") + private Boolean securityGroupEnabled; ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// @@ -69,6 +110,70 @@ public class UpdateNetworkOfferingCmd extends BaseCmd { public String getAvailability() { return availability == null ? Availability.Required.toString() : availability; + } + + public Boolean getDhcpService() { + return dhcpService; + } + + public Boolean getDnsService() { + return dnsService; + } + + public Boolean getGatewayService() { + return gatewayService; + } + + public Boolean getFirewallService() { + return firewallService; + } + + public Boolean getLbService() { + return lbService; + } + + public Boolean getUserdataService() { + return userdataService; + } + + public Boolean getSourceNatService() { + return sourceNatService; + } + + public Boolean getVpnService() { + return vpnService; + } + + public Map> getServiceProviders() { + Map> serviceProviderMap = null; + if (serviceProviderList != null && !serviceProviderList.isEmpty()) { + serviceProviderMap = new HashMap>(); + Collection servicesCollection = serviceProviderList.values(); + Iterator iter = servicesCollection.iterator(); + while (iter.hasNext()) { + HashMap services = (HashMap) iter.next(); + String service = (String)services.get("service"); + String provider = (String) services.get("provider"); + List providerList = null; + if (serviceProviderMap.containsKey(service)) { + providerList = serviceProviderMap.get(service); + } else { + providerList = new ArrayList(); + } + providerList.add(provider); + serviceProviderMap.put(service, providerList); + } + } + + return serviceProviderMap; + } + + public String getState() { + return state; + } + + public Boolean getSecurityGroupEnabled() { + return securityGroupEnabled; } ///////////////////////////////////////////////////// diff --git a/api/src/com/cloud/api/response/NetworkOfferingResponse.java b/api/src/com/cloud/api/response/NetworkOfferingResponse.java index 2c5c41574f3..26b3833ee73 100644 --- a/api/src/com/cloud/api/response/NetworkOfferingResponse.java +++ b/api/src/com/cloud/api/response/NetworkOfferingResponse.java @@ -70,6 +70,9 @@ public class NetworkOfferingResponse extends BaseResponse{ @SerializedName(ApiConstants.STATE) @Param(description="state of the network offering. Can be Disabled/Enabled/Inactive") private String state; + + @SerializedName(ApiConstants.TYPE) @Param(description="type of the network offering, can be Shared or Isolated") + private String type; @SerializedName("service") @Param(description="the list of supported services", responseObject = ServiceResponse.class) private List services; @@ -137,4 +140,8 @@ public class NetworkOfferingResponse extends BaseResponse{ public void setState(String state) { this.state = state; } + + public void setType(String type) { + this.type = type; + } } diff --git a/api/src/com/cloud/api/response/NetworkResponse.java b/api/src/com/cloud/api/response/NetworkResponse.java index f998cfc706b..f4f4a272551 100644 --- a/api/src/com/cloud/api/response/NetworkResponse.java +++ b/api/src/com/cloud/api/response/NetworkResponse.java @@ -69,6 +69,7 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes @SerializedName("networkofferingavailability") @Param(description="availability of the network offering the network is created from") private String networkOfferingAvailability; + @Deprecated @SerializedName(ApiConstants.IS_SHARED) @Param(description="true if network is shared, false otherwise") private Boolean isShared; diff --git a/api/src/com/cloud/api/response/ProviderResponse.java b/api/src/com/cloud/api/response/ProviderResponse.java new file mode 100644 index 00000000000..a3cdf811aa6 --- /dev/null +++ b/api/src/com/cloud/api/response/ProviderResponse.java @@ -0,0 +1,35 @@ +/** + * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved + * + * This software is licensed under the GNU General Public License v3 or later. + * + * It is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +package com.cloud.api.response; + +import java.util.List; + +import com.cloud.api.ApiConstants; +import com.cloud.serializer.Param; +import com.google.gson.annotations.SerializedName; + +@SuppressWarnings("unused") +public class ProviderResponse extends BaseResponse { + + @SerializedName(ApiConstants.NAME) @Param(description="the provider name") + private String name; + + public void setName(String name) { + this.name = name; + } +} diff --git a/api/src/com/cloud/api/response/ServiceResponse.java b/api/src/com/cloud/api/response/ServiceResponse.java index e32fed76396..d3ce9198c7d 100644 --- a/api/src/com/cloud/api/response/ServiceResponse.java +++ b/api/src/com/cloud/api/response/ServiceResponse.java @@ -30,7 +30,7 @@ public class ServiceResponse extends BaseResponse { private String name; @SerializedName(ApiConstants.PROVIDER) @Param(description="the service provider name") - private String provider; + private List providers; @SerializedName("capability") @Param(description="the list of capabilities", responseObject = CapabilityResponse.class) private List capabilities; @@ -47,7 +47,7 @@ public class ServiceResponse extends BaseResponse { this.capabilities = capabilities; } - public void setProvider(String provider) { - this.provider = provider; + public void setProviders(List providers) { + this.providers = providers; } } \ No newline at end of file diff --git a/api/src/com/cloud/network/Network.java b/api/src/com/cloud/network/Network.java index 653229728c8..b13c8683744 100644 --- a/api/src/com/cloud/network/Network.java +++ b/api/src/com/cloud/network/Network.java @@ -43,6 +43,11 @@ public interface Network extends ControlledEntity { Virtual, Direct, } + + public enum Type { + Shared, + Isolated + } public static class Service { private static List supportedServices = new ArrayList(); @@ -247,8 +252,6 @@ public interface Network extends ControlledEntity { String getDisplayText(); - boolean getIsShared(); - String getReservationId(); boolean isDefault(); @@ -259,4 +262,6 @@ public interface Network extends ControlledEntity { List getTags(); + Type getType(); + } diff --git a/api/src/com/cloud/network/NetworkProfile.java b/api/src/com/cloud/network/NetworkProfile.java index 64da475b91d..c03435f1472 100644 --- a/api/src/com/cloud/network/NetworkProfile.java +++ b/api/src/com/cloud/network/NetworkProfile.java @@ -43,14 +43,14 @@ public class NetworkProfile implements Network { private String cidr; private long networkOfferingId; private long related; - private GuestIpType guestIpType; private String displayText; - private boolean isShared; private String reservationId; private boolean isDefault; private String networkDomain; private boolean isSecurityGroupEnabled; private List tags; + private Network.Type type; + private GuestIpType guestIpType; public NetworkProfile(Network network) { this.id = network.getId(); @@ -66,14 +66,14 @@ public class NetworkProfile implements Network { this.cidr = network.getCidr(); this.networkOfferingId = network.getNetworkOfferingId(); this.related = network.getRelated(); - this.guestIpType = network.getGuestType(); this.displayText = network.getDisplayText(); - this.isShared = network.getIsShared(); this.reservationId = network.getReservationId(); this.isDefault = network.isDefault(); this.networkDomain = network.getNetworkDomain(); this.domainId = network.getDomainId(); this.isSecurityGroupEnabled = network.isSecurityGroupEnabled(); + this.type = network.getType(); + this.guestIpType = network.getGuestType(); } @Override @@ -175,12 +175,7 @@ public class NetworkProfile implements Network { public String getDisplayText() { return displayText; } - - @Override - public boolean getIsShared() { - return isShared; - } - + @Override public String getReservationId() { return reservationId; @@ -205,4 +200,9 @@ public class NetworkProfile implements Network { public boolean isSecurityGroupEnabled() { return isSecurityGroupEnabled; } + + @Override + public Network.Type getType(){ + return type; + } } diff --git a/api/src/com/cloud/network/NetworkService.java b/api/src/com/cloud/network/NetworkService.java index 807efee15e0..8cfce0ad783 100644 --- a/api/src/com/cloud/network/NetworkService.java +++ b/api/src/com/cloud/network/NetworkService.java @@ -19,6 +19,7 @@ package com.cloud.network; import java.util.List; import java.util.Map; +import java.util.Set; import com.cloud.api.commands.AssociateIPAddrCmd; import com.cloud.api.commands.CreateNetworkCmd; @@ -86,5 +87,5 @@ public interface NetworkService { Network getSystemNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType); - Map listNetworkOfferingServices(long networkOfferingId); + Map> listNetworkOfferingServices(long networkOfferingId); } diff --git a/api/src/com/cloud/offering/NetworkOffering.java b/api/src/com/cloud/offering/NetworkOffering.java index 2b0ea43ef95..81c2e141c5c 100644 --- a/api/src/com/cloud/offering/NetworkOffering.java +++ b/api/src/com/cloud/offering/NetworkOffering.java @@ -18,6 +18,9 @@ package com.cloud.offering; import com.cloud.network.Network.GuestIpType; +import com.cloud.network.Network.Provider; +import com.cloud.network.Network.Service; +import com.cloud.network.Network.Type; import com.cloud.network.Networks.TrafficType; /** @@ -97,4 +100,8 @@ public interface NetworkOffering { void setState(State state); State getState(); + + void setSecurityGroupEnabled(boolean securityGroupEnabled); + + Type getType(); } diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java index 0ac2249cd91..d3659751f47 100755 --- a/server/src/com/cloud/api/ApiDBUtils.java +++ b/server/src/com/cloud/api/ApiDBUtils.java @@ -21,6 +21,7 @@ package com.cloud.api; import java.util.Hashtable; import java.util.List; import java.util.Map; +import java.util.Set; import com.cloud.agent.AgentManager; import com.cloud.async.AsyncJobManager; @@ -649,7 +650,7 @@ public class ApiDBUtils { return _projectMgr.getProjectOwner(projectId).getId(); } - public static Map listNetworkOfferingServices(long networkOfferingId) { + public static Map> listNetworkOfferingServices(long networkOfferingId) { return _networkMgr.listNetworkOfferingServices(networkOfferingId); } } diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index 5cdf3dd3873..e49dabaa923 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -66,6 +66,7 @@ import com.cloud.api.response.PodResponse; import com.cloud.api.response.ProjectAccountResponse; import com.cloud.api.response.ProjectInvitationResponse; import com.cloud.api.response.ProjectResponse; +import com.cloud.api.response.ProviderResponse; import com.cloud.api.response.RemoteAccessVpnResponse; import com.cloud.api.response.ResourceCountResponse; import com.cloud.api.response.ResourceLimitResponse; @@ -2111,6 +2112,9 @@ public class ApiResponseHelper implements ResponseGenerator { response.setAvailability(offering.getAvailability().toString()); response.setNetworkRate(ApiDBUtils.getNetworkRate(offering.getId())); response.setIsSecurityGroupEnabled(offering.isSecurityGroupEnabled()); + if (offering.getType() != null) { + response.setType(offering.getType().toString()); + } if (offering.getGuestType() != null) { response.setGuestIpType(offering.getGuestType().toString()); @@ -2118,12 +2122,18 @@ public class ApiResponseHelper implements ResponseGenerator { response.setState(offering.getState().name()); - Map serviceProviderMap = ApiDBUtils.listNetworkOfferingServices(offering.getId()); + Map> serviceProviderMap = ApiDBUtils.listNetworkOfferingServices(offering.getId()); List serviceResponses = new ArrayList(); for (String service : serviceProviderMap.keySet()) { ServiceResponse svcRsp = new ServiceResponse(); svcRsp.setName(service); - svcRsp.setProvider(serviceProviderMap.get(service)); + List providers = new ArrayList(); + for (String provider : serviceProviderMap.get(service)) { + ProviderResponse providerRsp = new ProviderResponse(); + providerRsp.setName(provider); + providers.add(providerRsp); + } + svcRsp.setProviders(providers); serviceResponses.add(svcRsp); } response.setServices(serviceResponses); @@ -2179,7 +2189,9 @@ public class ApiResponseHelper implements ResponseGenerator { response.setNetworkOfferingAvailability(networkOffering.getAvailability().toString()); } - response.setIsShared(network.getIsShared()); + if (network.getType() != null && network.getType() == Network.Type.Shared) { + response.setIsShared(true); + } response.setIsDefault(network.isDefault()); response.setState(network.getState().toString()); response.setRelated(network.getRelated()); diff --git a/server/src/com/cloud/baremetal/BareMetalVmManagerImpl.java b/server/src/com/cloud/baremetal/BareMetalVmManagerImpl.java index 78dfe31da9d..bcbbdf166b2 100755 --- a/server/src/com/cloud/baremetal/BareMetalVmManagerImpl.java +++ b/server/src/com/cloud/baremetal/BareMetalVmManagerImpl.java @@ -321,7 +321,7 @@ public class BareMetalVmManagerImpl extends UserVmManagerImpl implements BareMet if (network == null) { throw new InvalidParameterValueException("Unable to find network by id " + networkId); } else { - if (!network.getIsShared()) { + if (network.getType() != Network.Type.Shared) { //Check account permissions List networkMap = _networkDao.listBy(accountId, networkId); if (networkMap == null || networkMap.isEmpty()) { diff --git a/server/src/com/cloud/configuration/ConfigurationManager.java b/server/src/com/cloud/configuration/ConfigurationManager.java index d89c0cf89f9..add65a754bb 100644 --- a/server/src/com/cloud/configuration/ConfigurationManager.java +++ b/server/src/com/cloud/configuration/ConfigurationManager.java @@ -19,6 +19,7 @@ package com.cloud.configuration; import java.util.List; import java.util.Map; +import java.util.Set; import com.cloud.dc.ClusterVO; import com.cloud.dc.DataCenter; @@ -33,6 +34,8 @@ import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.PermissionDeniedException; import com.cloud.network.Network; import com.cloud.network.Network.GuestIpType; +import com.cloud.network.Network.Provider; +import com.cloud.network.Network.Service; import com.cloud.network.Networks.TrafficType; import com.cloud.offering.DiskOffering; import com.cloud.offering.NetworkOffering.Availability; @@ -178,12 +181,13 @@ public interface ConfigurationManager extends ConfigurationService, Manager { * @param serviceProviderMap TODO * @param isDefault TODO * @param isSecurityGroupEnabled TODO + * @param type TODO * @param id * @param specifyVlan; * @return network offering object */ - NetworkOfferingVO createNetworkOffering(long userId, String name, String displayText, TrafficType trafficType, String tags, Integer maxConnections, boolean specifyVlan, Availability availability, GuestIpType guestIpType, Integer networkRate, Map serviceProviderMap, boolean isDefault, boolean isSecurityGroupEnabled); + NetworkOfferingVO createNetworkOffering(long userId, String name, String displayText, TrafficType trafficType, String tags, Integer maxConnections, boolean specifyVlan, Availability availability, GuestIpType guestIpType, Integer networkRate, Map> serviceProviderMap, boolean isDefault, boolean isSecurityGroupEnabled, Network.Type type); Vlan createVlanAndPublicIpRange(Long userId, Long zoneId, Long podId, String startIP, String endIP, String vlanGateway, String vlanNetmask, boolean forVirtualNetwork, String vlanId, Account account, Long networkId) throws InsufficientCapacityException, ConcurrentOperationException, InvalidParameterValueException; diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index f24e4c61b04..c26c4a5e5b1 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -97,6 +97,8 @@ import com.cloud.host.dao.HostDetailsDao; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.network.Network; import com.cloud.network.Network.GuestIpType; +import com.cloud.network.Network.Provider; +import com.cloud.network.Network.Service; import com.cloud.network.NetworkManager; import com.cloud.network.NetworkVO; import com.cloud.network.Networks.BroadcastDomainType; @@ -1523,7 +1525,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura } userNetwork.setBroadcastDomainType(broadcastDomainType); userNetwork.setNetworkDomain(networkDomain); - _networkMgr.setupNetwork(systemAccount, offering, userNetwork, plan, null, null, true, isNetworkDefault, false, null, null); + _networkMgr.setupNetwork(systemAccount, offering, userNetwork, plan, null, null, isNetworkDefault, false, null, null); } } } @@ -1998,7 +2000,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura if (network == null) { // find default public network in the zone networkId = _networkMgr.getSystemNetworkByZoneAndTrafficType(zoneId, TrafficType.Public).getId(); - } else if (network.getGuestType() != null || network.getTrafficType() != TrafficType.Public) { + } else if (network.getType() != null || network.getTrafficType() != TrafficType.Public) { throw new InvalidParameterValueException("Can't find Public network by id=" + networkId); } } else { @@ -2012,8 +2014,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura } networkId = network.getId(); } - } else if (network.getGuestType() == null || network.getGuestType() == GuestIpType.Virtual) { - throw new InvalidParameterValueException("Can't create direct vlan for network id=" + networkId + " with GuestType: " + network.getGuestType()); + } else if (network.getType() == null || network.getType()== Network.Type.Isolated) { + throw new InvalidParameterValueException("Can't create direct vlan for network id=" + networkId + " with type: " + network.getType()); } } @@ -2852,6 +2854,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura TrafficType trafficType = null; GuestIpType guestIpType = null; Availability availability = null; + Network.Type type = null; // Verify traffic type for (TrafficType tType : TrafficType.values()) { @@ -2875,6 +2878,18 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura if (guestIpType == null) { throw new InvalidParameterValueException("Invalid guest IP type; can have Direct or Virtual value"); } + + //Verify offering type + for (Network.Type offType : Network.Type.values()) { + if (offType.name().equalsIgnoreCase(cmd.getType())){ + type = offType; + break; + } + } + + if (type == null) { + throw new InvalidParameterValueException("Invalid type is given; can have Shared and Isolated values"); + } // Verify availability for (Availability avlb : Availability.values()) { @@ -2890,73 +2905,79 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura Integer maxConnections = cmd.getMaxconnections(); //configure service provider map - Map serviceProviderMap = new HashMap(); + Map> serviceProviderMap = new HashMap>(); + Set defaultProviders = new HashSet(); + defaultProviders.add(Network.Provider.defaultProvider); //populate all services first if (cmd.getDhcpService()) { - serviceProviderMap.put(Network.Service.Dhcp, Network.Provider.defaultProvider); + serviceProviderMap.put(Network.Service.Dhcp, defaultProviders); } if (cmd.getDnsService()) { - serviceProviderMap.put(Network.Service.Dns, Network.Provider.defaultProvider); + serviceProviderMap.put(Network.Service.Dns, defaultProviders); } if (cmd.getFirewallService()) { - serviceProviderMap.put(Network.Service.Firewall, Network.Provider.defaultProvider); + serviceProviderMap.put(Network.Service.Firewall, defaultProviders); } if (cmd.getGatewayService()) { - serviceProviderMap.put(Network.Service.Gateway, Network.Provider.defaultProvider); + serviceProviderMap.put(Network.Service.Gateway, defaultProviders); } if (cmd.getLbService()) { - serviceProviderMap.put(Network.Service.Lb, Network.Provider.defaultProvider); + serviceProviderMap.put(Network.Service.Lb, defaultProviders); } if (cmd.getSourceNatService()) { - serviceProviderMap.put(Network.Service.SourceNat, Network.Provider.defaultProvider); + serviceProviderMap.put(Network.Service.SourceNat, defaultProviders); } if (cmd.getUserdataService()) { - serviceProviderMap.put(Network.Service.UserData, Network.Provider.defaultProvider); + serviceProviderMap.put(Network.Service.UserData, defaultProviders); } if (cmd.getVpnService()) { - serviceProviderMap.put(Network.Service.Vpn, Network.Provider.defaultProvider); + serviceProviderMap.put(Network.Service.Vpn, defaultProviders); } //populate providers - Map svcPrv = (Map)cmd.getServiceProviderList(); + Map> svcPrv = (Map>)cmd.getServiceProviders(); if (svcPrv != null) { for (String serviceStr : svcPrv.keySet()) { Network.Service service = Network.Service.getService(serviceStr); if (serviceProviderMap.containsKey(service)) { - //check if provider is supported - Network.Provider provider; - String prvNameStr = svcPrv.get(serviceStr); - provider = Network.Provider.getProvider(prvNameStr); - if (provider == null) { - throw new InvalidParameterValueException("Invalid service provider: " + prvNameStr); - } - serviceProviderMap.put(service, provider); + serviceProviderMap.clear(); + Set providers = new HashSet(); + 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"); } } } - return createNetworkOffering(userId, name, displayText, trafficType, tags, maxConnections, specifyVlan, availability, guestIpType, networkRate, serviceProviderMap, false, isSecurityGroupEnabled); + return createNetworkOffering(userId, name, displayText, trafficType, tags, maxConnections, specifyVlan, availability, guestIpType, networkRate, serviceProviderMap, false, isSecurityGroupEnabled, type); } @Override @DB public NetworkOfferingVO createNetworkOffering(long userId, String name, String displayText, TrafficType trafficType, String tags, Integer maxConnections, boolean specifyVlan, - Availability availability, GuestIpType guestIpType, Integer networkRate, Map serviceProviderMap, boolean isDefault, boolean isSecurityGroupEnabled) { + Availability availability, GuestIpType guestIpType, Integer networkRate, Map> serviceProviderMap, boolean isDefault, boolean isSecurityGroupEnabled, Network.Type type) { String multicastRateStr = _configDao.getValue("multicast.throttling.rate"); int multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr)); tags = cleanupTags(tags); - NetworkOfferingVO offering = new NetworkOfferingVO(name, displayText, trafficType, false, specifyVlan, networkRate, multicastRate, maxConnections, isDefault, availability,guestIpType, tags, isSecurityGroupEnabled); + NetworkOfferingVO offering = new NetworkOfferingVO(name, displayText, trafficType, false, specifyVlan, networkRate, multicastRate, maxConnections, isDefault, availability,guestIpType, tags, isSecurityGroupEnabled, type); Transaction txn = Transaction.currentTxn(); txn.start(); @@ -2966,9 +2987,11 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura //populate services and providers if (serviceProviderMap != null) { for (Network.Service service : serviceProviderMap.keySet()) { - NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(offering.getId(), service, serviceProviderMap.get(service)); - _ntwkOffServiceMapDao.persist(offService); - s_logger.trace("Added service for the network offering: " + offService); + 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); + } } } @@ -3095,12 +3118,15 @@ 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(); String name = cmd.getNetworkOfferingName(); String availabilityStr = cmd.getAvailability(); Availability availability = null; + Boolean sgEnabled = cmd.getSecurityGroupEnabled(); + String state = cmd.getState(); UserContext.current().setEventDetails(" Id: "+id); // Verify input parameters @@ -3114,11 +3140,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura throw new InvalidParameterValueException("Can't update system network offerings"); } - // Don't allow to update default Direct network offering - if (offeringToUpdate.isDefault() && offeringToUpdate.getGuestType() == GuestIpType.Direct) { - throw new InvalidParameterValueException("Can't update Default Direct network offering"); - } - NetworkOfferingVO offering = _networkOfferingDao.createForUpdate(id); if (name != null) { @@ -3128,6 +3149,19 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura if (displayText != null) { offering.setDisplayText(displayText); } + + if (state != null) { + boolean validState = false; + for (NetworkOffering.State st : NetworkOffering.State.values()) { + if (st.name().equalsIgnoreCase(state)) { + validState = true; + offering.setState(st); + } + } + if (!validState) { + throw new InvalidParameterValueException("Incorrect state value: " + state); + } + } // Verify availability if (availabilityStr != null) { @@ -3142,10 +3176,107 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura offering.setAvailability(availability); } } - - if (_networkOfferingDao.update(id, offering)) { - offering = _networkOfferingDao.findById(id); - return offering; + + //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); + + if (sgEnabled != null) { + if (networksExist) { + throw new InvalidParameterValueException("Unable to reset securityGroupEnabled property as there are existing networks using this network offering"); + } + offering.setSecurityGroupEnabled(sgEnabled); + } + + //configure service provider map + Map> serviceProviderMap = new HashMap>(); + Set defaultProviders = new HashSet(); + 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()) { + serviceProviderMap.put(Network.Service.SourceNat, defaultProviders); + } + + if (cmd.getUserdataService()) { + serviceProviderMap.put(Network.Service.UserData, defaultProviders); + } + + if (cmd.getVpnService()) { + serviceProviderMap.put(Network.Service.Vpn, defaultProviders); + } + + //populate providers + Map> svcPrv = (Map>)cmd.getServiceProviders(); + if (svcPrv != null) { + for (String serviceStr : svcPrv.keySet()) { + Network.Service service = Network.Service.getService(serviceStr); + if (serviceProviderMap.containsKey(service)) { + serviceProviderMap.clear(); + Set providers = new HashSet(); + 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"); + } + } + } + + 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); + _ntwkOffServiceMapDao.deleteByOfferingId(id); + //update services/providers - delete old ones, insert new ones + if (serviceProviderMap != null) { + 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) { + return _networkOfferingDao.findById(id); } else { return null; } diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java index b155abf42b3..2d9285fc4ad 100644 --- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java +++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java @@ -558,9 +558,9 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx NicProfile defaultNic = new NicProfile(); defaultNic.setDefaultNic(true); defaultNic.setDeviceId(2); - networks.add(new Pair(_networkMgr.setupNetwork(systemAcct, defaultOffering.get(0), plan, null, null, false, false).get(0), defaultNic)); + networks.add(new Pair(_networkMgr.setupNetwork(systemAcct, defaultOffering.get(0), plan, null, null, false).get(0), defaultNic)); for (NetworkOfferingVO offering : offerings) { - networks.add(new Pair(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false, false).get(0), null)); + networks.add(new Pair(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false).get(0), null)); } VMTemplateVO template = _templateDao.findSystemVMTemplate(dataCenterId, desiredHyp); diff --git a/server/src/com/cloud/network/NetworkManager.java b/server/src/com/cloud/network/NetworkManager.java index 582b884f850..d9438c3de08 100644 --- a/server/src/com/cloud/network/NetworkManager.java +++ b/server/src/com/cloud/network/NetworkManager.java @@ -30,6 +30,7 @@ import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.Network.Capability; import com.cloud.network.Network.GuestIpType; +import com.cloud.network.Network.Provider; import com.cloud.network.Network.Service; import com.cloud.network.Networks.TrafficType; import com.cloud.network.addr.PublicIp; @@ -107,11 +108,11 @@ public interface NetworkManager extends NetworkService { */ List listPublicIpAddressesInVirtualNetwork(long accountId, long dcId, Boolean sourceNat, Long associatedNetworkId); - List setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name, String displayText, boolean isShared, boolean isDefault) + List setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name, String displayText, boolean isDefault) throws ConcurrentOperationException; - List setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean isShared, boolean isDefault, - boolean errorIfAlreadySetup, Long domainId, List tags) throws ConcurrentOperationException; + List setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean isDefault, boolean errorIfAlreadySetup, + Long domainId, List tags) throws ConcurrentOperationException; List getSystemAccountNetworkOfferings(String... offeringNames); @@ -159,8 +160,8 @@ public interface NetworkManager extends NetworkService { boolean destroyNetwork(long networkId, ReservationContext context); - Network createNetwork(long networkOfferingId, String name, String displayText, Boolean isShared, Boolean isDefault, Long zoneId, String gateway, String cidr, String vlanId, String networkDomain, - Account owner, boolean isSecurityGroupEnabled, Long domainId, List tags) throws ConcurrentOperationException, InsufficientCapacityException; + Network createNetwork(long networkOfferingId, String name, String displayText, Boolean isDefault, Long zoneId, String gateway, String cidr, String vlanId, String networkDomain, Account owner, + boolean isSecurityGroupEnabled, Long domainId, List tags) throws ConcurrentOperationException, InsufficientCapacityException; /** * @throws InsufficientCapacityException @@ -219,5 +220,7 @@ public interface NetworkManager extends NetworkService { String getIpInNetworkIncludingRemoved(long vmId, long networkId); Long getPodIdForVlan(long vlanDbId); + + boolean isProviderSupported(long networkOfferingId, Service service, Provider provider); } diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index c7d905de1fc..5de0ecf2b54 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -637,7 +637,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag // First IP address should be source nat when it's being associated with Guest Virtual network List addrs = listPublicIpAddressesInVirtualNetwork(ownerId, zoneId, true, networkId); - if (addrs.isEmpty() && network.getGuestType() == GuestIpType.Virtual) { + if (addrs.isEmpty() && network.getType() == Network.Type.Isolated) { isSourceNat = true; } } @@ -782,20 +782,24 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag _systemNetworks.put(NetworkOfferingVO.SystemStorageNetwork, storageNetworkOffering); //populate providers - Map defaultDirectNetworkOfferingProviders = new HashMap(); - defaultDirectNetworkOfferingProviders.put(Service.Dhcp, Provider.DhcpServer); - defaultDirectNetworkOfferingProviders.put(Service.Dns, Provider.DhcpServer); - defaultDirectNetworkOfferingProviders.put(Service.UserData, Provider.DhcpServer); + Map> defaultDirectNetworkOfferingProviders = new HashMap>(); + Set defaultProviders = new HashSet(); + defaultProviders.add(Network.Provider.DhcpServer); + defaultDirectNetworkOfferingProviders.put(Service.Dhcp, defaultProviders); + defaultDirectNetworkOfferingProviders.put(Service.Dns, defaultProviders); + defaultDirectNetworkOfferingProviders.put(Service.UserData, defaultProviders); - Map defaultVirtualNetworkOfferingProviders = new HashMap(); - defaultVirtualNetworkOfferingProviders.put(Service.Dhcp, Provider.VirtualRouter); - defaultVirtualNetworkOfferingProviders.put(Service.Dns, Provider.VirtualRouter); - defaultVirtualNetworkOfferingProviders.put(Service.UserData, Provider.VirtualRouter); - defaultVirtualNetworkOfferingProviders.put(Service.Firewall, Provider.VirtualRouter); - defaultVirtualNetworkOfferingProviders.put(Service.Gateway, Provider.VirtualRouter); - defaultVirtualNetworkOfferingProviders.put(Service.Lb, Provider.VirtualRouter); - defaultVirtualNetworkOfferingProviders.put(Service.SourceNat, Provider.VirtualRouter); - defaultVirtualNetworkOfferingProviders.put(Service.Vpn, Provider.VirtualRouter); + Map> defaultVirtualNetworkOfferingProviders = new HashMap>(); + defaultProviders.clear(); + defaultProviders.add(Network.Provider.VirtualRouter); + defaultVirtualNetworkOfferingProviders.put(Service.Dhcp, defaultProviders); + defaultVirtualNetworkOfferingProviders.put(Service.Dns, defaultProviders); + defaultVirtualNetworkOfferingProviders.put(Service.UserData, defaultProviders); + defaultVirtualNetworkOfferingProviders.put(Service.Firewall, defaultProviders); + defaultVirtualNetworkOfferingProviders.put(Service.Gateway, defaultProviders); + defaultVirtualNetworkOfferingProviders.put(Service.Lb, defaultProviders); + defaultVirtualNetworkOfferingProviders.put(Service.SourceNat, defaultProviders); + defaultVirtualNetworkOfferingProviders.put(Service.Vpn, defaultProviders); Transaction txn = Transaction.currentTxn(); txn.start(); @@ -803,19 +807,19 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag //check that offering already exists NetworkOfferingVO offering = null; if (_networkOfferingDao.findByUniqueName(NetworkOffering.SystemGuestNetwork) == null) { - offering = _configMgr.createNetworkOffering(Account.ACCOUNT_ID_SYSTEM, NetworkOffering.SystemGuestNetwork, "System Offering for System-Guest-Network", TrafficType.Guest, null, null, false, Availability.Optional, GuestIpType.Direct, null, defaultDirectNetworkOfferingProviders, true, true); + offering = _configMgr.createNetworkOffering(Account.ACCOUNT_ID_SYSTEM, NetworkOffering.SystemGuestNetwork, "System Offering for System-Guest-Network", TrafficType.Guest, null, null, false, Availability.Optional, GuestIpType.Direct, null, defaultDirectNetworkOfferingProviders, true, true, Network.Type.Shared); offering.setState(NetworkOffering.State.Enabled); _networkOfferingDao.update(offering.getId(), offering); } if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultVirtualizedNetworkOffering) == null) { - offering = _configMgr.createNetworkOffering(Account.ACCOUNT_ID_SYSTEM,NetworkOffering.DefaultVirtualizedNetworkOffering, "Virtual Vlan", TrafficType.Guest, null, null, false, Availability.Required, GuestIpType.Virtual, null, defaultVirtualNetworkOfferingProviders, true, false); + offering = _configMgr.createNetworkOffering(Account.ACCOUNT_ID_SYSTEM,NetworkOffering.DefaultVirtualizedNetworkOffering, "Virtual Vlan", TrafficType.Guest, null, null, false, Availability.Required, GuestIpType.Virtual, null, defaultVirtualNetworkOfferingProviders, true, false, Network.Type.Isolated); offering.setState(NetworkOffering.State.Enabled); _networkOfferingDao.update(offering.getId(), offering); } if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultDirectNetworkOffering) == null) { - offering = _configMgr.createNetworkOffering(Account.ACCOUNT_ID_SYSTEM, NetworkOffering.DefaultDirectNetworkOffering, "Direct", TrafficType.Guest, null, null, true, Availability.Optional, GuestIpType.Direct, null, defaultDirectNetworkOfferingProviders, true, false); + offering = _configMgr.createNetworkOffering(Account.ACCOUNT_ID_SYSTEM, NetworkOffering.DefaultDirectNetworkOffering, "Direct", TrafficType.Guest, null, null, true, Availability.Optional, GuestIpType.Direct, null, defaultDirectNetworkOfferingProviders, true, false, Network.Type.Shared); offering.setState(NetworkOffering.State.Enabled); _networkOfferingDao.update(offering.getId(), offering); } @@ -913,15 +917,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } @Override - public List setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name, String displayText, boolean isShared, boolean isDefault) + public List setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name, String displayText, boolean isDefault) throws ConcurrentOperationException { - return setupNetwork(owner, offering, null, plan, name, displayText, isShared, isDefault, false, null, null); + return setupNetwork(owner, offering, null, plan, name, displayText, isDefault, false, null, null); } @Override @DB - public List setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean isShared, boolean isDefault, - boolean errorIfAlreadySetup, Long domainId, List tags) throws ConcurrentOperationException { + public List setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean isDefault, boolean errorIfAlreadySetup, + Long domainId, List tags) throws ConcurrentOperationException { Account locked = _accountDao.acquireInLockTable(owner.getId()); if (locked == null) { throw new ConcurrentOperationException("Unable to acquire lock on " + owner); @@ -980,8 +984,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag related = id; } - NetworkVO vo = new NetworkVO(id, network, offering.getId(), plan.getDataCenterId(), guru.getName(), owner.getDomainId(), owner.getId(), related, name, displayText, isShared, isDefault, - predefined.isSecurityGroupEnabled(), (domainId != null), predefined.getNetworkDomain()); + NetworkVO vo = new NetworkVO(id, network, offering.getId(), plan.getDataCenterId(), guru.getName(), owner.getDomainId(), owner.getId(), related, name, displayText, isDefault, + predefined.isSecurityGroupEnabled(), (domainId != null), predefined.getNetworkDomain(), offering.getType()); vo.setTags(tags); networks.add(_networksDao.persist(vo, vo.getGuestType() != null)); @@ -1223,13 +1227,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag // If this is a guest virtual network and the network offering does not support a shared source NAT rule, // associate a source NAT IP (if one isn't already associated with the network) - if (network.getGuestType() == GuestIpType.Virtual && !offering.isSharedSourceNatService()) { + if (network.getType() == Network.Type.Isolated && !offering.isSharedSourceNatService()) { List ips = _ipAddressDao.listByAssociatedNetwork(networkId, true); if (ips.isEmpty()) { s_logger.debug("Creating a source nat ip for " + network); Account owner = _accountMgr.getAccount(network.getAccountId()); - PublicIp sourceNatIp = assignSourceNatIpAddress(owner, network, context.getCaller().getId()); + assignSourceNatIpAddress(owner, network, context.getCaller().getId()); } } @@ -1556,7 +1560,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag String vlanId = cmd.getVlan(); String name = cmd.getNetworkName(); String displayText = cmd.getDisplayText(); - Boolean isShared = cmd.getIsShared(); Boolean isDefault = cmd.isDefault(); Long userId = UserContext.current().getCallerUserId(); Account caller = UserContext.current().getCaller(); @@ -1574,12 +1577,21 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (networkOffering == null || networkOffering.isSystemOnly()) { throw new InvalidParameterValueException("Unable to find network offeirng by id " + networkOfferingId); } + + if (networkOffering.getState() != NetworkOffering.State.Enabled) { + throw new InvalidParameterValueException("Can't use network offering id=" + networkOfferingId + " as its state is not " + NetworkOffering.State.Enabled); + } + + boolean isShared = false; + if (networkOffering.getType() == Network.Type.Shared) { + isShared = true; + } // Check if the network is domain specific if (cmd.getDomainId() != null && cmd.getAccountName() == null) { - if (networkOffering.getTrafficType() != TrafficType.Guest || networkOffering.getGuestType() != GuestIpType.Direct) { - throw new InvalidParameterValueException("Domain level networks are supported just for traffic type " + TrafficType.Guest + " and guest Ip type " + GuestIpType.Direct); - } else if (isShared == null || !isShared) { + if (networkOffering.getTrafficType() != TrafficType.Guest || networkOffering.getType() != Network.Type.Shared) { + throw new InvalidParameterValueException("Domain level networks are supported just for traffic type " + TrafficType.Guest + " and only for type " + Network.Type.Shared); + } else if (!isShared) { throw new InvalidParameterValueException("Network dedicated to domain should be shared"); } else { DomainVO domain = _domainDao.findById(cmd.getDomainId()); @@ -1679,15 +1691,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag domainId = cmd.getDomainId(); } - Network network = createNetwork(networkOfferingId, name, displayText, isShared, isDefault, zoneId, gateway, cidr, vlanId, networkDomain, owner, false, domainId, tags); + Network network = createNetwork(networkOfferingId, name, displayText, isDefault, zoneId, gateway, cidr, vlanId, networkDomain, owner, false, domainId, tags); - // Don't pass owner to create vlan when network offering is of type Direct - done to prevent accountVlanMap entry + // Don't pass owner to create vlan when network offering is of type Shared - done to prevent accountVlanMap entry // creation when vlan is mapped to network - if (network.getGuestType() == GuestIpType.Direct) { + if (network.getType() == Network.Type.Shared) { owner = null; } - if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN && network.getGuestType() == GuestIpType.Direct && defineNetworkConfig) { + if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN && network.getType() == Network.Type.Shared && defineNetworkConfig) { // Create vlan ip range _configMgr.createVlanAndPublicIpRange(userId, zoneId, null, startIP, endIP, gateway, netmask, false, vlanId, owner, network.getId()); } @@ -1699,38 +1711,30 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag @Override @DB - public Network createNetwork(long networkOfferingId, String name, String displayText, Boolean isShared, Boolean isDefault, Long zoneId, String gateway, String cidr, String vlanId, - String networkDomain, Account owner, boolean isSecurityGroupEnabled, Long domainId, List tags) throws ConcurrentOperationException, InsufficientCapacityException { + public Network createNetwork(long networkOfferingId, String name, String displayText, Boolean isDefault, Long zoneId, String gateway, String cidr, String vlanId, String networkDomain, + Account owner, boolean isSecurityGroupEnabled, Long domainId, List tags) throws ConcurrentOperationException, InsufficientCapacityException { NetworkOfferingVO networkOffering = _networkOfferingDao.findById(networkOfferingId); DataCenterVO zone = _dcDao.findById(zoneId); - // Only Direct Account specific networks can be created in Advanced Security Group enabled zone - if (zone.isSecurityGroupEnabled() && (networkOffering.getGuestType() == GuestIpType.Virtual || (isShared != null && isShared))) { - throw new InvalidParameterValueException("Virtual Network and Direct Shared Network creation is not allowed if zone is security group enabled"); - } - - if (zone.getNetworkType() == NetworkType.Basic) { - throw new InvalidParameterValueException("Network creation is not allowed in zone with network type " + NetworkType.Basic); - } - - // allow isDefault/isShared to be set only for Direct network - if (networkOffering.getGuestType() == GuestIpType.Virtual) { + // allow isDefault to be set only for Shared network + if (networkOffering.getType() == Network.Type.Isolated) { if (isDefault != null && !isDefault) { throw new InvalidParameterValueException("Can specify isDefault parameter only for Direct network."); } else { isDefault = true; } - if (isShared != null && isShared) { - throw new InvalidParameterValueException("Can specify isShared parameter for Direct networks only"); - } } else { if (isDefault == null) { isDefault = false; } } - // if network is shared, defult its owner to be system + // if network is shared, default its owner to be system + boolean isShared = false; + if (networkOffering.getType() == Network.Type.Shared) { + isShared = true; + } if (isShared) { owner = _accountMgr.getSystemAccount(); } @@ -1824,13 +1828,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } } - List networks = setupNetwork(owner, networkOffering, userNetwork, plan, name, displayText, isShared, isDefault, true, domainId, tags); + List networks = setupNetwork(owner, networkOffering, userNetwork, plan, name, displayText, isDefault, true, domainId, tags); Network network = null; if (networks == null || networks.isEmpty()) { throw new CloudRuntimeException("Fail to create a network"); } else { - if (networks.size() > 0 && networks.get(0).getGuestType() == GuestIpType.Virtual && networks.get(0).getTrafficType() == TrafficType.Guest) { + if (networks.size() > 0 && networks.get(0).getType()== Network.Type.Isolated && networks.get(0).getTrafficType() == TrafficType.Guest) { Network defaultGuestNetwork = networks.get(0); for (Network nw : networks) { if (nw.getCidr() != null && nw.getCidr().equals(zone.getGuestNetworkCidr())) { @@ -2745,7 +2749,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag // create new Virtual network for the user if it doesn't exist if (createNetwork) { List offerings = _configMgr.listNetworkOfferings(TrafficType.Guest, false); - network = createNetwork(offerings.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName() + "-network", false, null, zoneId, null, null, null, null, owner, false, null, null); + network = createNetwork(offerings.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName() + "-network", null, zoneId, null, null, null, null, owner, false, null, null); if (network == null) { s_logger.warn("Failed to create default Virtual network for the account " + accountId + "in zone " + zoneId); @@ -2957,7 +2961,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag for (NetworkVO network : zoneNetworks) { NetworkOfferingVO no = _networkOfferingDao.findById(network.getNetworkOfferingId()); if (!no.isSystemOnly()) { - if (network.getIsShared() || !_networksDao.listBy(accountId, network.getId()).isEmpty()) { + if (network.getType() == Network.Type.Shared || !_networksDao.listBy(accountId, network.getId()).isEmpty()) { if ((guestType == null || guestType == network.getGuestType()) && (isDefault == null || isDefault.booleanValue() == network.isDefault)) { accountNetworks.add(network); } @@ -3013,7 +3017,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag public boolean isNetworkAvailableInDomain(long networkId, long domainId) { Long networkDomainId = null; Network network = getNetwork(networkId); - if (!network.getIsShared()) { + if (network.getType() != Network.Type.Shared) { s_logger.trace("Network id=" + networkId + " is not shared"); return false; } @@ -3317,14 +3321,27 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } @Override - public Map listNetworkOfferingServices(long networkOfferingId) { - Map serviceProviderMap = new HashMap(); + public Map> listNetworkOfferingServices(long networkOfferingId) { + Map> serviceProviderMap = new HashMap>(); List map = _ntwkOfferingSrvcDao.getServices(networkOfferingId); for (NetworkOfferingServiceMapVO instance : map) { - serviceProviderMap.put(instance.getService(), instance.getProvider()); + String service = instance.getService(); + Set providers; + if (serviceProviderMap.containsKey(service)) { + providers = serviceProviderMap.get(service); + } else { + providers = new HashSet(); + } + providers.add(instance.getProvider()); + serviceProviderMap.put(service, providers); } return serviceProviderMap; } + + @Override + public boolean isProviderSupported(long networkOfferingId, Service service, Provider provider){ + return _ntwkOfferingSrvcDao.isProviderSupported(networkOfferingId, service, provider); + } } diff --git a/server/src/com/cloud/network/NetworkVO.java b/server/src/com/cloud/network/NetworkVO.java index 94bc3f003df..4a67c19a43b 100644 --- a/server/src/com/cloud/network/NetworkVO.java +++ b/server/src/com/cloud/network/NetworkVO.java @@ -150,6 +150,10 @@ public class NetworkVO implements Network { @Column(name="tag") @CollectionTable(name="network_tags", joinColumns=@JoinColumn(name="network_id")) List tags; + + @Column(name="type") + @Enumerated(value=EnumType.STRING) + Network.Type type; public NetworkVO() { } @@ -178,8 +182,8 @@ public class NetworkVO implements Network { this.guestType = guestType; } - public NetworkVO(long id, Network that, long offeringId, long dataCenterId, String guruName, long domainId, long accountId, long related, String name, String displayText, Boolean isShared, boolean isDefault, boolean isSecurityGroupEnabled, boolean isDomainSpecific, String networkDomain) { - this(id, that.getTrafficType(), that.getGuestType(), that.getMode(), that.getBroadcastDomainType(), offeringId, dataCenterId, domainId, accountId, related, name, displayText, isShared, isDefault, isDomainSpecific, networkDomain); + public NetworkVO(long id, Network that, long offeringId, long dataCenterId, String guruName, long domainId, long accountId, long related, String name, String displayText, boolean isDefault, boolean isSecurityGroupEnabled, boolean isDomainSpecific, String networkDomain, Type type) { + this(id, that.getTrafficType(), that.getGuestType(), that.getMode(), that.getBroadcastDomainType(), offeringId, dataCenterId, domainId, accountId, related, name, displayText,isDefault, isDomainSpecific, networkDomain, type); this.gateway = that.getGateway(); this.cidr = that.getCidr(); this.broadcastUri = that.getBroadcastUri(); @@ -207,8 +211,9 @@ public class NetworkVO implements Network { * @param isDefault * @param isDomainSpecific * @param networkDomain + * @param type TODO */ - public NetworkVO(long id, TrafficType trafficType, GuestIpType guestType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId, long domainId, long accountId, long related, String name, String displayText, Boolean isShared, boolean isDefault, boolean isDomainSpecific, String networkDomain) { + public NetworkVO(long id, TrafficType trafficType, GuestIpType guestType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId, long domainId, long accountId, long related, String name, String displayText, boolean isDefault, boolean isDomainSpecific, String networkDomain, Type type) { this(trafficType, guestType, mode, broadcastDomainType, networkOfferingId, dataCenterId, State.Allocated); this.domainId = domainId; this.accountId = accountId; @@ -216,10 +221,15 @@ public class NetworkVO implements Network { this.id = id; this.name = name; this.displayText = displayText; - this.isShared = isShared; + if (type == Network.Type.Shared) { + this.isShared = true; + } else if (type == Network.Type.Isolated) { + this.isShared = false; + } this.isDefault = isDefault; this.isDomainSpecific = isDomainSpecific; this.networkDomain = networkDomain; + this.type = type; } @Override @@ -413,11 +423,6 @@ public class NetworkVO implements Network { this.displayText = displayText; } - @Override - public boolean getIsShared() { - return isShared; - } - @Override public boolean isDefault() { return isDefault; @@ -455,6 +460,11 @@ public class NetworkVO implements Network { public boolean isDomainSpecific() { return isDomainSpecific; } + + @Override + public Network.Type getType() { + return type; + } @Override public boolean equals(Object obj) { diff --git a/server/src/com/cloud/network/dao/NetworkDao.java b/server/src/com/cloud/network/dao/NetworkDao.java index 94c2831095b..8f912ff5502 100644 --- a/server/src/com/cloud/network/dao/NetworkDao.java +++ b/server/src/com/cloud/network/dao/NetworkDao.java @@ -64,4 +64,6 @@ public interface NetworkDao extends GenericDao { List listNetworksBy(boolean isShared); List listByZoneIncludingRemoved(long zoneId); + + Long getNetworkCountByOfferingId(long offeringId); } diff --git a/server/src/com/cloud/network/dao/NetworkDaoImpl.java b/server/src/com/cloud/network/dao/NetworkDaoImpl.java index dac59335d41..4ffd6c077ca 100644 --- a/server/src/com/cloud/network/dao/NetworkDaoImpl.java +++ b/server/src/com/cloud/network/dao/NetworkDaoImpl.java @@ -24,6 +24,7 @@ import javax.ejb.Local; import javax.persistence.TableGenerator; import com.cloud.network.Network.GuestIpType; +import com.cloud.network.Network; import com.cloud.network.NetworkAccountDaoImpl; import com.cloud.network.NetworkAccountVO; import com.cloud.network.NetworkDomainVO; @@ -31,13 +32,16 @@ import com.cloud.network.NetworkVO; import com.cloud.network.Networks.BroadcastDomainType; import com.cloud.network.Networks.Mode; import com.cloud.network.Networks.TrafficType; +import com.cloud.storage.dao.VolumeDaoImpl.SumCount; import com.cloud.utils.component.ComponentLocator; import com.cloud.utils.db.DB; import com.cloud.utils.db.GenericDaoBase; +import com.cloud.utils.db.GenericSearchBuilder; import com.cloud.utils.db.JoinBuilder; import com.cloud.utils.db.JoinBuilder.JoinType; import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; +import com.cloud.utils.db.SearchCriteria.Func; import com.cloud.utils.db.SearchCriteria.Op; import com.cloud.utils.db.SequenceFetcher; import com.cloud.utils.db.Transaction; @@ -51,6 +55,7 @@ public class NetworkDaoImpl extends GenericDaoBase implements N final SearchBuilder AccountNetworkSearch; final SearchBuilder ZoneBroadcastUriSearch; final SearchBuilder ZoneSecurityGroupSearch; + final GenericSearchBuilder CountByOfferingId; NetworkAccountDaoImpl _accountsDao = ComponentLocator.inject(NetworkAccountDaoImpl.class); NetworkDomainDaoImpl _domainsDao = ComponentLocator.inject(NetworkDomainDaoImpl.class); @@ -72,7 +77,7 @@ public class NetworkDaoImpl extends GenericDaoBase implements N AllFieldsSearch.and("account", AllFieldsSearch.entity().getAccountId(), Op.EQ); AllFieldsSearch.and("guesttype", AllFieldsSearch.entity().getGuestType(), Op.EQ); AllFieldsSearch.and("related", AllFieldsSearch.entity().getRelated(), Op.EQ); - AllFieldsSearch.and("isShared", AllFieldsSearch.entity().getIsShared(), Op.EQ); + AllFieldsSearch.and("type", AllFieldsSearch.entity().getType(), Op.EQ); AllFieldsSearch.done(); AccountSearch = createSearchBuilder(); @@ -109,6 +114,12 @@ public class NetworkDaoImpl extends GenericDaoBase implements N ZoneSecurityGroupSearch.and("dataCenterId", ZoneSecurityGroupSearch.entity().getDataCenterId(), Op.EQ); ZoneSecurityGroupSearch.and("securityGroup", ZoneSecurityGroupSearch.entity().isSecurityGroupEnabled(), Op.EQ); ZoneSecurityGroupSearch.done(); + + CountByOfferingId = createSearchBuilder(Long.class); + CountByOfferingId.select(null, Func.COUNT, CountByOfferingId.entity().getId()); + CountByOfferingId.and("offeringId", CountByOfferingId.entity().getNetworkOfferingId(), Op.EQ); + CountByOfferingId.and("removed", CountByOfferingId.entity().getRemoved(), Op.NULL); + CountByOfferingId.done(); _tgMacAddress = _tgs.get("macAddress"); @@ -297,7 +308,12 @@ public class NetworkDaoImpl extends GenericDaoBase implements N @Override public List listNetworksBy(boolean isShared) { SearchCriteria sc = AllFieldsSearch.create(); - sc.setParameters("isShared", isShared); + if (isShared) { + sc.setParameters("type", Network.Type.Shared); + } else { + sc.setParameters("type", Network.Type.Isolated); + } + return listBy(sc); } @@ -307,4 +323,12 @@ public class NetworkDaoImpl extends GenericDaoBase implements N sc.setParameters("dataCenterId", zoneId); return listIncludingRemovedBy(sc); } + + @Override + public Long getNetworkCountByOfferingId(long offeringId) { + SearchCriteria sc = CountByOfferingId.create(); + sc.setParameters("offering", offeringId); + List results = customSearch(sc, null); + return results.get(0); + } } diff --git a/server/src/com/cloud/network/element/CloudZonesNetworkElement.java b/server/src/com/cloud/network/element/CloudZonesNetworkElement.java index f9d778b41eb..824f328f102 100644 --- a/server/src/com/cloud/network/element/CloudZonesNetworkElement.java +++ b/server/src/com/cloud/network/element/CloudZonesNetworkElement.java @@ -63,7 +63,6 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.Network; import com.cloud.network.NetworkVO; import com.cloud.network.Network.Capability; -import com.cloud.network.Network.GuestIpType; import com.cloud.network.Network.Provider; import com.cloud.network.Network.Service; import com.cloud.network.NetworkManager; @@ -111,7 +110,7 @@ public class CloudZonesNetworkElement extends AdapterBase implements NetworkElem @Inject AgentManager _agentManager; @Inject ServiceOfferingDao _serviceOfferingDao; - private boolean canHandle(GuestIpType ipType, DeployDestination dest, TrafficType trafficType) { + private boolean canHandle(DeployDestination dest, TrafficType trafficType) { DataCenterVO dc = (DataCenterVO)dest.getDataCenter(); if (dc.getDhcpProvider().equalsIgnoreCase(Provider.ExternalDhcpServer.getName())){ @@ -127,7 +126,7 @@ public class CloudZonesNetworkElement extends AdapterBase implements NetworkElem @Override public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException { - if (!canHandle(network.getGuestType(), dest, offering.getTrafficType())) { + if (!canHandle(dest, offering.getTrafficType())) { return false; } @@ -136,7 +135,7 @@ public class CloudZonesNetworkElement extends AdapterBase implements NetworkElem @Override public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vmProfile, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException { - if (canHandle(network.getGuestType(), dest, network.getTrafficType())) { + if (canHandle(dest, network.getTrafficType())) { if (vmProfile.getType() != VirtualMachine.Type.User) { return false; diff --git a/server/src/com/cloud/network/element/DhcpElement.java b/server/src/com/cloud/network/element/DhcpElement.java index e9dde7e4127..c1d23b29ba6 100644 --- a/server/src/com/cloud/network/element/DhcpElement.java +++ b/server/src/com/cloud/network/element/DhcpElement.java @@ -27,8 +27,8 @@ import org.apache.log4j.Logger; import com.cloud.configuration.ConfigurationManager; import com.cloud.dc.DataCenter; -import com.cloud.dc.Pod; import com.cloud.dc.DataCenter.NetworkType; +import com.cloud.dc.Pod; import com.cloud.dc.dao.HostPodDao; import com.cloud.deploy.DeployDestination; import com.cloud.exception.ConcurrentOperationException; @@ -37,18 +37,15 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.host.dao.HostDao; import com.cloud.network.Network; import com.cloud.network.Network.Capability; -import com.cloud.network.Network.GuestIpType; import com.cloud.network.Network.Provider; import com.cloud.network.Network.Service; +import com.cloud.network.Network.Type; import com.cloud.network.NetworkManager; import com.cloud.network.Networks.TrafficType; -import com.cloud.network.PublicIpAddress; import com.cloud.network.dao.NetworkDao; import com.cloud.network.router.VirtualNetworkApplianceManager; import com.cloud.network.router.VirtualRouter; import com.cloud.network.router.VirtualRouter.Role; -import com.cloud.network.rules.FirewallRule; -import com.cloud.network.rules.StaticNat; import com.cloud.offering.NetworkOffering; import com.cloud.org.Cluster; import com.cloud.user.AccountManager; @@ -83,27 +80,20 @@ public class DhcpElement extends AdapterBase implements PasswordServiceProvider @Inject AccountManager _accountMgr; @Inject HostDao _hostDao; - private boolean canHandle(GuestIpType ipType, DeployDestination dest, TrafficType trafficType) { - DataCenter dc = dest.getDataCenter(); - String provider = dc.getGatewayProvider(); - - if (provider != null && provider.equalsIgnoreCase(Provider.JuniperSRX.getName()) && ipType == GuestIpType.Virtual) { + private boolean canHandle(DeployDestination dest, TrafficType trafficType, Type networkType, long offeringId) { + if (_networkMgr.isProviderSupported(offeringId, Service.Gateway, Provider.JuniperSRX) && networkType == Network.Type.Isolated) { return true; } else if (dest.getPod() != null && dest.getPod().getExternalDhcp()){ //This pod is using external DHCP server return false; } else { - if (dc.getNetworkType() == NetworkType.Basic) { - return (ipType == GuestIpType.Direct && trafficType == TrafficType.Guest); - } else { - return (ipType == GuestIpType.Direct); - } + return (networkType == Network.Type.Shared); } } @Override public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException { - if (!canHandle(network.getGuestType(), dest, offering.getTrafficType())) { + if (!canHandle(dest, offering.getTrafficType(), network.getType(), network.getNetworkOfferingId())) { return false; } @@ -115,7 +105,7 @@ public class DhcpElement extends AdapterBase implements PasswordServiceProvider @Override public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException { - if (canHandle(network.getGuestType(), dest, network.getTrafficType())) { + if (canHandle(dest, network.getTrafficType(), network.getType(), network.getNetworkOfferingId())) { if (vm.getType() != VirtualMachine.Type.User) { return false; @@ -204,7 +194,7 @@ public class DhcpElement extends AdapterBase implements PasswordServiceProvider DeployDestination dest = new DeployDestination(dc, null, null, null); NetworkOffering offering = _configMgr.getNetworkOffering(network.getNetworkOfferingId()); - if (!canHandle(network.getGuestType(), dest, offering.getTrafficType())) { + if (!canHandle(dest, offering.getTrafficType(), network.getType(), network.getNetworkOfferingId())) { s_logger.trace("Dhcp element doesn't handle network restart for the network " + network); return false; } diff --git a/server/src/com/cloud/network/element/ElasticLoadBalancerElement.java b/server/src/com/cloud/network/element/ElasticLoadBalancerElement.java index 2a09a83ada3..3da9c705c62 100644 --- a/server/src/com/cloud/network/element/ElasticLoadBalancerElement.java +++ b/server/src/com/cloud/network/element/ElasticLoadBalancerElement.java @@ -34,15 +34,13 @@ import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.Network; import com.cloud.network.Network.Capability; -import com.cloud.network.Network.Provider; +import com.cloud.network.Network.Provider; import com.cloud.network.Network.Service; import com.cloud.network.NetworkManager; import com.cloud.network.Networks.TrafficType; -import com.cloud.network.PublicIpAddress; import com.cloud.network.dao.NetworkDao; import com.cloud.network.lb.ElasticLoadBalancerManager; import com.cloud.network.rules.FirewallRule; -import com.cloud.network.rules.StaticNat; import com.cloud.offering.NetworkOffering; import com.cloud.offerings.dao.NetworkOfferingDao; import com.cloud.utils.component.AdapterBase; @@ -67,8 +65,8 @@ public class ElasticLoadBalancerElement extends AdapterBase implements FirewallS TrafficType _frontEndTrafficType = TrafficType.Guest; private boolean canHandle(Network network) { - if (network.getGuestType() != Network.GuestIpType.Direct || network.getTrafficType() != TrafficType.Guest) { - s_logger.debug("Not handling network with guest Type " + network.getGuestType() + " and traffic type " + network.getTrafficType()); + if (network.getType() != Network.Type.Shared|| network.getTrafficType() != TrafficType.Guest) { + s_logger.debug("Not handling network with type " + network.getType() + " and traffic type " + network.getTrafficType()); return false; } diff --git a/server/src/com/cloud/network/element/ExternalDhcpElement.java b/server/src/com/cloud/network/element/ExternalDhcpElement.java index 777f4af7b41..3524c04cb66 100644 --- a/server/src/com/cloud/network/element/ExternalDhcpElement.java +++ b/server/src/com/cloud/network/element/ExternalDhcpElement.java @@ -19,7 +19,6 @@ package com.cloud.network.element; -import java.util.List; import java.util.Map; import javax.ejb.Local; @@ -37,18 +36,15 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.host.Host; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.network.Network; -import com.cloud.network.PublicIpAddress; import com.cloud.network.Network.Capability; import com.cloud.network.Network.GuestIpType; import com.cloud.network.Network.Provider; import com.cloud.network.Network.Service; +import com.cloud.network.Network.Type; import com.cloud.network.Networks.TrafficType; -import com.cloud.network.rules.FirewallRule; -import com.cloud.network.rules.StaticNat; import com.cloud.offering.NetworkOffering; import com.cloud.utils.component.AdapterBase; import com.cloud.utils.component.Inject; -import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.vm.NicProfile; import com.cloud.vm.ReservationContext; import com.cloud.vm.VirtualMachine; @@ -58,12 +54,12 @@ import com.cloud.vm.VirtualMachineProfile; public class ExternalDhcpElement extends AdapterBase implements NetworkElement { private static final Logger s_logger = Logger.getLogger(ExternalDhcpElement.class); @Inject ExternalDhcpManager _dhcpMgr; - private boolean canHandle(GuestIpType ipType, DeployDestination dest, TrafficType trafficType) { + private boolean canHandle(DeployDestination dest, TrafficType trafficType, Type networkType) { DataCenter dc = dest.getDataCenter(); Pod pod = dest.getPod(); if (pod.getExternalDhcp() && dc.getNetworkType() == NetworkType.Basic && trafficType == TrafficType.Guest - && ipType == GuestIpType.Direct) { + && networkType == Network.Type.Shared) { s_logger.debug("External DHCP can handle"); return true; } @@ -84,7 +80,7 @@ public class ExternalDhcpElement extends AdapterBase implements NetworkElement { @Override public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException { - if (!canHandle(network.getGuestType(), dest, offering.getTrafficType())) { + if (!canHandle(dest, offering.getTrafficType(), network.getType())) { return false; } return true; @@ -94,7 +90,7 @@ public class ExternalDhcpElement extends AdapterBase implements NetworkElement { public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException { Host host = dest.getHost(); - if (host.getHypervisorType() == HypervisorType.BareMetal || !canHandle(network.getGuestType(), dest, network.getTrafficType())) { + if (host.getHypervisorType() == HypervisorType.BareMetal || !canHandle(dest, network.getTrafficType(), network.getType())) { //BareMetalElement or DhcpElement handle this return false; } diff --git a/server/src/com/cloud/network/element/ExternalFirewallElement.java b/server/src/com/cloud/network/element/ExternalFirewallElement.java index 07b9a377ec7..f8aa16c6068 100644 --- a/server/src/com/cloud/network/element/ExternalFirewallElement.java +++ b/server/src/com/cloud/network/element/ExternalFirewallElement.java @@ -74,8 +74,8 @@ public class ExternalFirewallElement extends AdapterBase implements SourceNATSer private boolean canHandle(Network config) { DataCenter zone = _configMgr.getZone(config.getDataCenterId()); - if ((zone.getNetworkType() == NetworkType.Advanced && config.getGuestType() != Network.GuestIpType.Virtual) || (zone.getNetworkType() == NetworkType.Basic && config.getGuestType() != Network.GuestIpType.Direct)) { - s_logger.trace("Not handling guest ip type = " + config.getGuestType()); + if ((zone.getNetworkType() == NetworkType.Advanced && config.getType() != Network.Type.Isolated) || (zone.getNetworkType() == NetworkType.Basic && config.getType() != Network.Type.Shared)) { + s_logger.trace("Not handling network type = " + config.getType()); return false; } diff --git a/server/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java b/server/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java index e80ed7f0c73..e2dc5dc2f0f 100644 --- a/server/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java +++ b/server/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java @@ -63,8 +63,8 @@ public class F5ExternalLoadBalancerElement extends AdapterBase implements Firewa private boolean canHandle(Network config) { DataCenter zone = _configMgr.getZone(config.getDataCenterId()); - if (config.getGuestType() != Network.GuestIpType.Virtual || config.getTrafficType() != TrafficType.Guest) { - s_logger.trace("Not handling network with guest Type " + config.getGuestType() + " and traffic type " + config.getTrafficType()); + if (config.getType() != Network.Type.Isolated || config.getTrafficType() != TrafficType.Guest) { + s_logger.trace("Not handling network with Type " + config.getType() + " and traffic type " + config.getTrafficType()); return false; } diff --git a/server/src/com/cloud/network/element/NetscalerExternalLoadBalancerElement.java b/server/src/com/cloud/network/element/NetscalerExternalLoadBalancerElement.java index 287419348fc..2a177f7054b 100644 --- a/server/src/com/cloud/network/element/NetscalerExternalLoadBalancerElement.java +++ b/server/src/com/cloud/network/element/NetscalerExternalLoadBalancerElement.java @@ -63,8 +63,8 @@ public class NetscalerExternalLoadBalancerElement extends AdapterBase implements private boolean canHandle(Network config) { DataCenter zone = _configMgr.getZone(config.getDataCenterId()); - if (config.getGuestType() != Network.GuestIpType.Virtual || config.getTrafficType() != TrafficType.Guest) { - s_logger.trace("Not handling network with guest Type " + config.getGuestType() + " and traffic type " + config.getTrafficType()); + if (config.getType() != Network.Type.Isolated || config.getTrafficType() != TrafficType.Guest) { + s_logger.trace("Not handling network with Type " + config.getType() + " and traffic type " + config.getTrafficType()); return false; } diff --git a/server/src/com/cloud/network/element/RedundantVirtualRouterElement.java b/server/src/com/cloud/network/element/RedundantVirtualRouterElement.java index 21ca386da72..6f63bd1e627 100644 --- a/server/src/com/cloud/network/element/RedundantVirtualRouterElement.java +++ b/server/src/com/cloud/network/element/RedundantVirtualRouterElement.java @@ -8,7 +8,6 @@ import javax.ejb.Local; import org.apache.log4j.Logger; -import com.cloud.dc.DataCenter; import com.cloud.deploy.DeployDestination; import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.InsufficientCapacityException; @@ -16,9 +15,13 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.Network; import com.cloud.network.Network.GuestIpType; import com.cloud.network.Network.Provider; +import com.cloud.network.Network.Service; +import com.cloud.network.Network.Type; +import com.cloud.network.NetworkManager; import com.cloud.network.router.VirtualRouter; import com.cloud.offering.NetworkOffering; import com.cloud.uservm.UserVm; +import com.cloud.utils.component.Inject; import com.cloud.vm.DomainRouterVO; import com.cloud.vm.NicProfile; import com.cloud.vm.ReservationContext; @@ -29,9 +32,10 @@ import com.cloud.vm.VirtualMachineProfile; public class RedundantVirtualRouterElement extends VirtualRouterElement { private static final Logger s_logger = Logger.getLogger(RedundantVirtualRouterElement.class); - private boolean canHandle(GuestIpType ipType, DataCenter dc) { - String provider = dc.getGatewayProvider(); - boolean result = (provider != null && ipType == GuestIpType.Virtual && provider.equals(Provider.VirtualRouter.getName())); + @Inject NetworkManager _networkMgr; + + private boolean canHandle(Type networkType, long offeringId) { + boolean result = (networkType == Network.Type.Isolated && _networkMgr.isProviderSupported(offeringId, Service.Gateway, Provider.VirtualRouter)); if (!result) { s_logger.trace("Virtual router element only takes care of guest ip type " + GuestIpType.Virtual + " for provider " + Provider.VirtualRouter.getName()); } @@ -41,7 +45,7 @@ public class RedundantVirtualRouterElement extends VirtualRouterElement { @Override public boolean implement(Network guestConfig, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException { - if (!canHandle(guestConfig.getGuestType(), dest.getDataCenter())) { + if (!canHandle(guestConfig.getType(), offering.getId())) { return false; } @@ -56,7 +60,7 @@ public class RedundantVirtualRouterElement extends VirtualRouterElement { @Override public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException { - if (canHandle(network.getGuestType(), dest.getDataCenter())) { + if (canHandle(network.getType(), network.getNetworkOfferingId())) { if (vm.getType() != VirtualMachine.Type.User) { return false; } diff --git a/server/src/com/cloud/network/element/VirtualRouterElement.java b/server/src/com/cloud/network/element/VirtualRouterElement.java index 38b7cd19501..201ca58f20e 100644 --- a/server/src/com/cloud/network/element/VirtualRouterElement.java +++ b/server/src/com/cloud/network/element/VirtualRouterElement.java @@ -35,9 +35,9 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.host.dao.HostDao; import com.cloud.network.Network; import com.cloud.network.Network.Capability; -import com.cloud.network.Network.GuestIpType; import com.cloud.network.Network.Provider; import com.cloud.network.Network.Service; +import com.cloud.network.Network.Type; import com.cloud.network.NetworkManager; import com.cloud.network.PublicIpAddress; import com.cloud.network.RemoteAccessVpn; @@ -52,7 +52,6 @@ import com.cloud.network.rules.FirewallRule; import com.cloud.network.rules.RulesManager; import com.cloud.network.rules.StaticNat; import com.cloud.offering.NetworkOffering; -import com.cloud.offerings.NetworkOfferingVO; import com.cloud.offerings.dao.NetworkOfferingDao; import com.cloud.org.Cluster; import com.cloud.uservm.UserVm; @@ -89,18 +88,17 @@ public class VirtualRouterElement extends DhcpElement implements SourceNATServic @Inject HostDao _hostDao; @Inject ConfigurationDao _configDao; - private boolean canHandle(GuestIpType ipType, DataCenter dc) { - String provider = dc.getGatewayProvider(); - boolean result = (provider != null && ipType == GuestIpType.Virtual && provider.equals(Provider.VirtualRouter.getName())); + private boolean canHandle(Type networkType, long offeringId) { + boolean result = (networkType == Network.Type.Isolated && _networkMgr.isProviderSupported(offeringId, Service.Gateway, Provider.VirtualRouter)); if (!result) { - s_logger.trace("Virtual router element only takes care of guest ip type " + GuestIpType.Virtual + " for provider " + Provider.VirtualRouter.getName()); + s_logger.trace("Virtual router element only takes care of type " + Network.Type.Isolated + " for provider " + Provider.VirtualRouter.getName()); } return result; } @Override public boolean implement(Network guestConfig, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException { - if (!canHandle(guestConfig.getGuestType(), dest.getDataCenter())) { + if (!canHandle(guestConfig.getType(), offering.getId())) { return false; } @@ -115,7 +113,7 @@ public class VirtualRouterElement extends DhcpElement implements SourceNATServic @Override public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException { - if (canHandle(network.getGuestType(), dest.getDataCenter())) { + if (canHandle(network.getType(), network.getNetworkOfferingId())) { if (vm.getType() != VirtualMachine.Type.User) { return false; } @@ -136,7 +134,7 @@ public class VirtualRouterElement extends DhcpElement implements SourceNATServic @Override public boolean restart(Network network, ReservationContext context, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{ DataCenter dc = _configMgr.getZone(network.getDataCenterId()); - if (!canHandle(network.getGuestType(), dc)) { + if (!canHandle(network.getType(), network.getNetworkOfferingId())) { s_logger.trace("Virtual router element doesn't handle network restart for the network " + network); return false; } @@ -182,7 +180,7 @@ public class VirtualRouterElement extends DhcpElement implements SourceNATServic public boolean applyRules(Network config, List rules) throws ResourceUnavailableException { DataCenter dc = _configMgr.getZone(config.getDataCenterId()); - if (canHandle(config.getGuestType(),dc)) { + if (canHandle(config.getType(), config.getNetworkOfferingId())) { List routers = _routerDao.listByNetworkAndRole(config.getId(), Role.DHCP_FIREWALL_LB_PASSWD_USERDATA); if (routers == null || routers.isEmpty()) { s_logger.debug("Virtual router elemnt doesn't need to apply firewall rules on the backend; virtual router doesn't exist in the network " + config.getId()); @@ -211,7 +209,7 @@ public class VirtualRouterElement extends DhcpElement implements SourceNATServic return null; } - if (canHandle(network.getGuestType(),dc)) { + if (canHandle(network.getType(), network.getNetworkOfferingId())) { return _routerMgr.applyVpnUsers(network, users, routers); } else { s_logger.debug("Element " + this.getName() + " doesn't handle applyVpnUsers command"); @@ -229,7 +227,7 @@ public class VirtualRouterElement extends DhcpElement implements SourceNATServic return true; } - if (canHandle(network.getGuestType(),dc)) { + if (canHandle(network.getType(), network.getNetworkOfferingId())) { return _routerMgr.startRemoteAccessVpn(network, vpn, routers); } else { s_logger.debug("Element " + this.getName() + " doesn't handle createVpn command"); @@ -247,7 +245,7 @@ public class VirtualRouterElement extends DhcpElement implements SourceNATServic return true; } - if (canHandle(network.getGuestType(),dc)) { + if (canHandle(network.getType(), network.getNetworkOfferingId())) { return _routerMgr.deleteRemoteAccessVpn(network, vpn, routers); } else { s_logger.debug("Element " + this.getName() + " doesn't handle removeVpn command"); @@ -258,7 +256,7 @@ public class VirtualRouterElement extends DhcpElement implements SourceNATServic @Override public boolean applyIps(Network network, List ipAddress) throws ResourceUnavailableException { DataCenter dc = _configMgr.getZone(network.getDataCenterId()); - if (canHandle(network.getGuestType(),dc)) { + if (canHandle(network.getType(), network.getNetworkOfferingId())) { List routers = _routerDao.listByNetworkAndRole(network.getId(), Role.DHCP_FIREWALL_LB_PASSWD_USERDATA); if (routers == null || routers.isEmpty()) { @@ -322,7 +320,7 @@ public class VirtualRouterElement extends DhcpElement implements SourceNATServic @Override public boolean applyStaticNats(Network config, List rules) throws ResourceUnavailableException { DataCenter dc = _configMgr.getZone(config.getDataCenterId()); - if (canHandle(config.getGuestType(),dc)) { + if (canHandle(config.getType(), config.getNetworkOfferingId())) { List routers = _routerDao.listByNetworkAndRole(config.getId(), Role.DHCP_FIREWALL_LB_PASSWD_USERDATA); if (routers == null || routers.isEmpty()) { s_logger.debug("Virtual router elemnt doesn't need to apply static nat on the backend; virtual router doesn't exist in the network " + config.getId()); diff --git a/server/src/com/cloud/network/guru/DirectNetworkGuru.java b/server/src/com/cloud/network/guru/DirectNetworkGuru.java index a942c3ea935..e6f31cdb5b1 100644 --- a/server/src/com/cloud/network/guru/DirectNetworkGuru.java +++ b/server/src/com/cloud/network/guru/DirectNetworkGuru.java @@ -34,7 +34,6 @@ import com.cloud.exception.InsufficientVirtualNetworkCapcityException; import com.cloud.exception.InvalidParameterValueException; import com.cloud.network.IPAddressVO; import com.cloud.network.Network; -import com.cloud.network.Network.GuestIpType; import com.cloud.network.Network.State; import com.cloud.network.NetworkManager; import com.cloud.network.NetworkProfile; @@ -76,8 +75,9 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru { protected boolean canHandle(NetworkOffering offering, DataCenter dc) { // this guru handles only non-system network with guestIpType = Direct - if (dc.getNetworkType() == NetworkType.Advanced && offering.getGuestType() == GuestIpType.Direct && offering.getTrafficType() == TrafficType.Guest) { - if (dc.isSecurityGroupEnabled()) { + //TODO - after broadCastDomainType + physical network are introduced, don't rely on network type of the dc + if (dc.getNetworkType() == NetworkType.Advanced && offering.getType() == Network.Type.Shared && offering.getTrafficType() == TrafficType.Guest) { + if (offering.isSecurityGroupEnabled()) { return true; } else if (!offering.isSystemOnly()) { return true; diff --git a/server/src/com/cloud/network/guru/PublicNetworkGuru.java b/server/src/com/cloud/network/guru/PublicNetworkGuru.java index b896256afff..150be147b98 100644 --- a/server/src/com/cloud/network/guru/PublicNetworkGuru.java +++ b/server/src/com/cloud/network/guru/PublicNetworkGuru.java @@ -26,7 +26,6 @@ import javax.ejb.Local; import org.apache.log4j.Logger; import com.cloud.dc.DataCenter; -import com.cloud.dc.DataCenter.NetworkType; import com.cloud.dc.Vlan.VlanType; import com.cloud.dc.dao.DataCenterDao; import com.cloud.dc.dao.VlanDao; @@ -78,7 +77,7 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru { NetworkOfferingDao _networkOfferingDao; protected boolean canHandle(NetworkOffering offering, DataCenter dc) { - if (((dc.getNetworkType() == NetworkType.Advanced && !dc.isSecurityGroupEnabled()) || dc.getNetworkType() == NetworkType.Basic) && offering.getTrafficType() == TrafficType.Public && offering.isSystemOnly()) { + if (!offering.isSecurityGroupEnabled() && offering.getTrafficType() == TrafficType.Public && offering.isSystemOnly()) { return true; } else { s_logger.trace("We only take care of System only Public Virtual Network"); diff --git a/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java b/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java index 6f60a310959..cd0a385e2a7 100644 --- a/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java +++ b/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java @@ -461,7 +461,7 @@ public class ElasticLoadBalancerManagerImpl implements try { NetworkOffering offering = _networkOfferingDao.findByIdIncludingRemoved(guestNetwork.getNetworkOfferingId()); - if (offering.isSystemOnly() || guestNetwork.getIsShared()) { + if (offering.isSystemOnly() || guestNetwork.getType() == Network.Type.Shared) { owner = _accountService.getSystemAccount(); } @@ -486,7 +486,7 @@ public class ElasticLoadBalancerManagerImpl implements List offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork); NetworkOfferingVO controlOffering = offerings.get(0); - NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false, false).get(0); + NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false).get(0); List> networks = new ArrayList>(2); NicProfile guestNic = new NicProfile(); @@ -613,8 +613,8 @@ public class ElasticLoadBalancerManagerImpl implements NetworkVO network=_networkDao.findById(networkId); - if (network.getGuestType() != GuestIpType.Direct) { - s_logger.info("ELB: not handling guest traffic of type " + network.getGuestType()); + if (network.getType() != Network.Type.Shared) { + s_logger.info("ELB: not handling traffic for network of type " + network.getType()); return null; } return network; diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index 96d0c720693..c1a70f1c911 100755 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -1063,11 +1063,11 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian List offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork); NetworkOfferingVO controlOffering = offerings.get(0); - NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false, false).get(0); + NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false).get(0); List> networks = new ArrayList>(3); NetworkOfferingVO publicOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork).get(0); - List publicNetworks = _networkMgr.setupNetwork(_systemAcct, publicOffering, plan, null, null, false, false); + List publicNetworks = _networkMgr.setupNetwork(_systemAcct, publicOffering, plan, null, null, false); networks.add(new Pair(publicNetworks.get(0), defaultNic)); NicProfile gatewayNic = new NicProfile(); if (isRedundant) { @@ -1253,7 +1253,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian List offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork); NetworkOfferingVO controlOffering = offerings.get(0); - NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false, false).get(0); + NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false).get(0); List> networks = new ArrayList>(3); @@ -1304,7 +1304,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian public List deployDhcp(Network guestNetwork, DeployDestination dest, Account owner, Map params) throws InsufficientCapacityException, StorageUnavailableException, ConcurrentOperationException, ResourceUnavailableException { NetworkOffering offering = _networkOfferingDao.findByIdIncludingRemoved(guestNetwork.getNetworkOfferingId()); - if (offering.isSystemOnly() || guestNetwork.getIsShared()) { + if (offering.isSystemOnly() || guestNetwork.getType() == Network.Type.Shared) { owner = _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM); } @@ -1461,11 +1461,11 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian buf.append(" dnssearchorder=").append(domain_suffix); } - if (!network.isDefault() && network.getGuestType() == GuestIpType.Direct) { + if (!network.isDefault() && network.getType() == Network.Type.Shared) { buf.append(" defaultroute=false"); String virtualNetworkElementNicIP = _networkMgr.getIpOfNetworkElementInVirtualNetwork(network.getAccountId(), network.getDataCenterId()); - if (!network.getIsShared() && virtualNetworkElementNicIP != null) { + if (network.getType() != Network.Type.Shared && virtualNetworkElementNicIP != null) { defaultDns1 = virtualNetworkElementNicIP; } else { s_logger.debug("No Virtual network found for account id=" + network.getAccountId() + " so setting dns to the dns of the network id=" + network.getId()); @@ -1908,7 +1908,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian if (cmds.size() > 0) { boolean podLevelException = false; //for user vm in Basic zone we should try to re-deploy vm in a diff pod if it fails to deploy in original pod; so throwing exception with Pod scope - if (isZoneBasic && podId != null && profile.getVirtualMachine().getType() == VirtualMachine.Type.User && network.getTrafficType() == TrafficType.Guest && network.getGuestType() == GuestIpType.Direct) { + if (isZoneBasic && podId != null && profile.getVirtualMachine().getType() == VirtualMachine.Type.User && network.getTrafficType() == TrafficType.Guest && network.getType() == Network.Type.Shared) { podLevelException = true; } try { diff --git a/server/src/com/cloud/offerings/NetworkOfferingVO.java b/server/src/com/cloud/offerings/NetworkOfferingVO.java index fab3211db65..6b09cc52de6 100644 --- a/server/src/com/cloud/offerings/NetworkOfferingVO.java +++ b/server/src/com/cloud/offerings/NetworkOfferingVO.java @@ -28,8 +28,8 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; +import com.cloud.network.Network; import com.cloud.network.Network.GuestIpType; -import com.cloud.network.Network.State; import com.cloud.network.Networks.TrafficType; import com.cloud.offering.NetworkOffering; import com.cloud.utils.db.GenericDao; @@ -100,6 +100,10 @@ public class NetworkOfferingVO implements NetworkOffering { @Column(name="is_security_group_enabled") boolean securityGroupEnabled; + @Column(name="type") + @Enumerated(value=EnumType.STRING) + Network.Type type; + @Override public String getDisplayText() { return displayText; @@ -216,8 +220,18 @@ public class NetworkOfferingVO implements NetworkOffering { public State getState() { return state; } + + @Override + public void setSecurityGroupEnabled(boolean securityGroupEnabled) { + this.securityGroupEnabled = securityGroupEnabled; + } + + @Override + public Network.Type getType() { + return type; + } - public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, boolean systemOnly, boolean specifyVlan, Integer rateMbps, Integer multicastRateMbps, Integer concurrentConnections, boolean isDefault, Availability availability, GuestIpType guestIpType, String tags, boolean isSecurityGroupEnabled) { + public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, boolean systemOnly, boolean specifyVlan, Integer rateMbps, Integer multicastRateMbps, Integer concurrentConnections, boolean isDefault, Availability availability, GuestIpType guestIpType, String tags, boolean isSecurityGroupEnabled, Network.Type type) { this.name = name; this.displayText = displayText; this.rateMbps = rateMbps; @@ -232,6 +246,7 @@ public class NetworkOfferingVO implements NetworkOffering { this.tags = tags; this.guestType = guestIpType; this.securityGroupEnabled = isSecurityGroupEnabled; + this.type = type; } public NetworkOfferingVO() { @@ -243,7 +258,7 @@ public class NetworkOfferingVO implements NetworkOffering { * @param trafficType */ public NetworkOfferingVO(String name, TrafficType trafficType) { - this(name, "System Offering for " + name, trafficType, true, false, 0, 0, null, true, Availability.Required, null, null, false); + this(name, "System Offering for " + name, trafficType, true, false, 0, 0, null, true, Availability.Required, null, null, false, null); this.state = State.Enabled; } diff --git a/server/src/com/cloud/offerings/dao/NetworkOfferingServiceMapDao.java b/server/src/com/cloud/offerings/dao/NetworkOfferingServiceMapDao.java index f835f8b2d16..323ce374d1e 100644 --- a/server/src/com/cloud/offerings/dao/NetworkOfferingServiceMapDao.java +++ b/server/src/com/cloud/offerings/dao/NetworkOfferingServiceMapDao.java @@ -35,6 +35,7 @@ public interface NetworkOfferingServiceMapDao extends GenericDao getServicesForProvider(long networkOfferingId, Provider provider); List getProvidersForService(long networkOfferingid, Service service); List getServices(long networkOfferingId); + void deleteByOfferingId(long networkOfferingId); } diff --git a/server/src/com/cloud/offerings/dao/NetworkOfferingServiceMapDaoImpl.java b/server/src/com/cloud/offerings/dao/NetworkOfferingServiceMapDaoImpl.java index d990b53e0fc..5aa825bc9f1 100644 --- a/server/src/com/cloud/offerings/dao/NetworkOfferingServiceMapDaoImpl.java +++ b/server/src/com/cloud/offerings/dao/NetworkOfferingServiceMapDaoImpl.java @@ -112,4 +112,11 @@ public class NetworkOfferingServiceMapDaoImpl extends GenericDaoBase sc = AllFieldsSearch.create(); + sc.setParameters("networkOfferingId", networkOfferingId); + remove(sc); + } } diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java index 649eba8b4fa..e32158e7ce9 100644 --- a/server/src/com/cloud/server/ConfigurationServerImpl.java +++ b/server/src/com/cloud/server/ConfigurationServerImpl.java @@ -852,7 +852,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { "System-Guest-Network", TrafficType.Guest, false, false, null, null, null, true, - Availability.Optional, GuestIpType.Direct, null, true); + Availability.Optional, GuestIpType.Direct, null, true, Network.Type.Shared); guestNetworkOffering.setState(NetworkOffering.State.Enabled); @@ -869,7 +869,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { "Virtual Vlan", TrafficType.Guest, false, false, null, null, null, true, - Availability.Required, GuestIpType.Virtual, null, false); + Availability.Required, GuestIpType.Virtual, null, false, Network.Type.Isolated); defaultGuestNetworkOffering.setState(NetworkOffering.State.Enabled); defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestNetworkOffering); @@ -886,7 +886,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { "Direct", TrafficType.Guest, false, true, null, null, null, true, - Availability.Optional, GuestIpType.Direct, null, false); + Availability.Optional, GuestIpType.Direct, null, false, Network.Type.Shared); defaultGuestDirectNetworkOffering.setState(NetworkOffering.State.Enabled); defaultGuestDirectNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestDirectNetworkOffering); @@ -953,7 +953,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { } if (broadcastDomainType != null) { - NetworkVO network = new NetworkVO(id, trafficType, null, mode, broadcastDomainType, networkOfferingId, zoneId, domainId, accountId, related, null, null, true, isNetworkDefault, false, networkDomain); + NetworkVO network = new NetworkVO(id, trafficType, null, mode, broadcastDomainType, networkOfferingId, zoneId, domainId, accountId, related, null, null, isNetworkDefault, false, networkDomain, Network.Type.Shared); network.setGuruName(guruNames.get(network.getTrafficType())); network.setDns1(zone.getDns1()); network.setDns2(zone.getDns2()); diff --git a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java index d18aecf8c28..b042e574533 100644 --- a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java +++ b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java @@ -504,9 +504,9 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V defaultNic.setDefaultNic(true); defaultNic.setDeviceId(2); try { - networks.add(new Pair(_networkMgr.setupNetwork(systemAcct, defaultOffering.get(0), plan, null, null, false, false).get(0), defaultNic)); + networks.add(new Pair(_networkMgr.setupNetwork(systemAcct, defaultOffering.get(0), plan, null, null, false).get(0), defaultNic)); for (NetworkOfferingVO offering : offerings) { - networks.add(new Pair(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false, false).get(0), null)); + networks.add(new Pair(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false).get(0), null)); } } catch (ConcurrentOperationException e) { s_logger.info("Unable to setup due to concurrent operation. " + e); diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 8880c8d2254..f30c8f97377 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -2096,12 +2096,12 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager throw new InvalidParameterValueException("Can't create a vm with multiple networks one of which is Security Group enabled"); } - if (network.getTrafficType() != TrafficType.Guest || network.getGuestType() != GuestIpType.Direct || (network.getIsShared() && !network.isSecurityGroupEnabled())) { + if (network.getTrafficType() != TrafficType.Guest || network.getType() != Network.Type.Shared || (network.getType() == Network.Type.Shared && !network.isSecurityGroupEnabled())) { throw new InvalidParameterValueException("Can specify only Direct Guest Account specific networks when deploy vm in Security Group enabled zone"); } // Perform account permission check - if (!network.getIsShared()) { + if (network.getType() != Network.Type.Shared) { // Check account permissions List networkMap = _networkDao.listBy(owner.getId(), network.getId()); if (networkMap == null || networkMap.isEmpty()) { @@ -2177,8 +2177,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager if (virtualNetworks.isEmpty()) { s_logger.debug("Creating default Virtual network for account " + owner + " as a part of deployVM process"); - Network newNetwork = _networkMgr.createNetwork(defaultVirtualOffering.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName() + "-network", false, null, - zone.getId(), null, null, null, null, owner, false, null, null); + Network newNetwork = _networkMgr.createNetwork(defaultVirtualOffering.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName() + "-network", null, zone.getId(), + null, null, null, null, owner, false, null, null); defaultNetwork = _networkDao.findById(newNetwork.getId()); } else if (virtualNetworks.size() > 1) { throw new InvalidParameterValueException("More than 1 default Virtaul networks are found for account " + owner + "; please specify networkIds"); @@ -2190,8 +2190,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager if (defaultNetworks.isEmpty()) { if (defaultVirtualOffering.get(0).getAvailability() == Availability.Optional) { s_logger.debug("Creating default Virtual network for account " + owner + " as a part of deployVM process"); - Network newNetwork = _networkMgr.createNetwork(defaultVirtualOffering.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName() + "-network", false, null, - zone.getId(), null, null, null, null, owner, false, null, null); + Network newNetwork = _networkMgr.createNetwork(defaultVirtualOffering.get(0).getId(), owner.getAccountName() + "-network", owner.getAccountName() + "-network", null, zone.getId(), + null, null, null, null, owner, false, null, null); defaultNetwork = _networkDao.findById(newNetwork.getId()); } else { throw new InvalidParameterValueException("Unable to find default networks for account " + owner); @@ -2231,7 +2231,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager } // Perform account permission check - if (!network.getIsShared()) { + if (network.getType() != Network.Type.Shared) { List networkMap = _networkDao.listBy(owner.getId(), network.getId()); if (networkMap == null || networkMap.isEmpty()) { throw new PermissionDeniedException("Unable to create a vm using network with id " + network.getId() + ", permission denied"); @@ -3324,7 +3324,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager for (NetworkVO network : zoneNetworks) { // get the default networks for the account NetworkOfferingVO no = _networkOfferingDao.findById(network.getNetworkOfferingId()); if (!no.isSystemOnly()) { - if (network.getIsShared() || !_networkDao.listBy(oldAccount.getId(), network.getId()).isEmpty()) { + if (network.getType() == Network.Type.Shared || !_networkDao.listBy(oldAccount.getId(), network.getId()).isEmpty()) { if (network.isDefault()) { oldNetworks.add(network); } @@ -3335,8 +3335,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager long networkOffering = oldNet.getNetworkOfferingId(); List virtualNetworks = _networkMgr.listNetworksForAccount(newAccount.getId(), zone.getId(), GuestIpType.Virtual, true); if (virtualNetworks.isEmpty()) { - Network newNetwork = _networkMgr.createNetwork(networkOffering, newAccount.getAccountName() + "-network", newAccount.getAccountName() + "-network", false, null, - vm.getDataCenterIdToDeployIn(), null, null, null, null, newAccount, false, null, null); + Network newNetwork = _networkMgr.createNetwork(networkOffering, newAccount.getAccountName() + "-network", newAccount.getAccountName() + "-network", null, vm.getDataCenterIdToDeployIn(), + null, null, null, null, newAccount, false, null, null); defaultNetwork = _networkDao.findById(newNetwork.getId()); } else if (virtualNetworks.size() > 1) { throw new InvalidParameterValueException("More than 1 default Virtaul networks are found for account " + newAccount + "; please specify networkIds"); diff --git a/server/test/com/cloud/network/MockNetworkManagerImpl.java b/server/test/com/cloud/network/MockNetworkManagerImpl.java index fa661458be1..5e1f5bb6a0e 100644 --- a/server/test/com/cloud/network/MockNetworkManagerImpl.java +++ b/server/test/com/cloud/network/MockNetworkManagerImpl.java @@ -9,7 +9,6 @@ import javax.naming.ConfigurationException; import com.cloud.api.commands.AssociateIPAddrCmd; import com.cloud.api.commands.CreateNetworkCmd; import com.cloud.api.commands.ListNetworksCmd; -import com.cloud.api.commands.RestartNetworkCmd; import com.cloud.dc.Vlan; import com.cloud.dc.Vlan.VlanType; import com.cloud.deploy.DeployDestination; @@ -27,8 +26,6 @@ import com.cloud.network.addr.PublicIp; import com.cloud.network.guru.NetworkGuru; import com.cloud.network.rules.FirewallRule; import com.cloud.network.rules.StaticNat; -import com.cloud.network.vpn.PasswordResetElement; -import com.cloud.network.vpn.RemoteAccessVpnElement; import com.cloud.offering.NetworkOffering; import com.cloud.offerings.NetworkOfferingVO; import com.cloud.user.Account; @@ -93,12 +90,6 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS return false; } - @Override - public boolean restartNetwork(RestartNetworkCmd cmd) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException { - // TODO Auto-generated method stub - return false; - } - @Override public int getActiveNicsInNetwork(long networkId) { // TODO Auto-generated method stub @@ -202,15 +193,15 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS } @Override - public List setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name, String displayText, boolean isShared, boolean isDefault) + public List setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name, String displayText, boolean isDefault) throws ConcurrentOperationException { // TODO Auto-generated method stub return null; } @Override - public List setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean isShared, boolean isDefault, - boolean errorIfAlreadySetup, Long domainId, List tags) throws ConcurrentOperationException { + public List setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean isDefault, boolean errorIfAlreadySetup, + Long domainId, List tags) throws ConcurrentOperationException { // TODO Auto-generated method stub return null; } @@ -344,8 +335,8 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS } @Override - public Network createNetwork(long networkOfferingId, String name, String displayText, Boolean isShared, Boolean isDefault, Long zoneId, String gateway, String cidr, String vlanId, - String networkDomain, Account owner, boolean isSecurityGroupEnabled, Long domainId, List tags) throws ConcurrentOperationException, InsufficientCapacityException { + public Network createNetwork(long networkOfferingId, String name, String displayText, Boolean isDefault, Long zoneId, String gateway, String cidr, String vlanId, String networkDomain, + Account owner, boolean isSecurityGroupEnabled, Long domainId, List tags) throws ConcurrentOperationException, InsufficientCapacityException { // TODO Auto-generated method stub return null; } @@ -387,12 +378,6 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS return null; } - @Override - public List getPasswordResetElements() { - // TODO Auto-generated method stub - return null; - } - @Override public boolean zoneIsConfiguredForExternalNetworking(long zoneId) { // TODO Auto-generated method stub @@ -453,12 +438,6 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS return null; } - @Override - public List getRemoteAccessVpnElements() { - // TODO Auto-generated method stub - return null; - } - @Override public String acquireGuestIpAddress(Network network, String requestedIp) { // TODO Auto-generated method stub diff --git a/server/test/com/cloud/network/dao/NetworkDaoTest.java b/server/test/com/cloud/network/dao/NetworkDaoTest.java index b7ad959bb68..81b95246319 100644 --- a/server/test/com/cloud/network/dao/NetworkDaoTest.java +++ b/server/test/com/cloud/network/dao/NetworkDaoTest.java @@ -19,7 +19,7 @@ public class NetworkDaoTest extends TestCase { NetworkDaoImpl dao = ComponentLocator.inject(NetworkDaoImpl.class); dao.expunge(1001l); - NetworkVO network = new NetworkVO(1001, TrafficType.Control, GuestIpType.Direct, Mode.Dhcp, BroadcastDomainType.Native, 1, 1, 1, 1, 1001, "Name", "DisplayText", false, true, true, null); + NetworkVO network = new NetworkVO(1001, TrafficType.Control, GuestIpType.Direct, Mode.Dhcp, BroadcastDomainType.Native, 1, 1, 1, 1, 1001, "Name", "DisplayText", false, true, true, null, null); network.setGuruName("guru_name"); List tags = new ArrayList(); diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql index 98dbcb495b5..b38ca8ae320 100755 --- a/setup/db/create-schema.sql +++ b/setup/db/create-schema.sql @@ -187,6 +187,7 @@ CREATE TABLE `cloud`.`networks` ( `created` datetime NOT NULL COMMENT 'date created', `removed` datetime COMMENT 'date removed if not null', `is_security_group_enabled` tinyint NOT NULL DEFAULT 0 COMMENT '1: enabled, 0: not', + `type` char(32) COMMENT 'type of the network, can be Shared or Isolated', PRIMARY KEY (`id`), CONSTRAINT `fk_networks__network_offering_id` FOREIGN KEY (`network_offering_id`) REFERENCES `network_offerings`(`id`), CONSTRAINT `fk_networks__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES `data_center`(`id`) ON DELETE CASCADE, @@ -264,6 +265,7 @@ CREATE TABLE `cloud`.`network_offerings` ( `guest_type` char(32) COMMENT 'guest ip type of network offering', `is_security_group_enabled` tinyint NOT NULL DEFAULT 0 COMMENT '1: enabled, 0: not', `state` char(32) COMMENT 'state of the network offering; has Disabled value by default', + `type` char(32) COMMENT 'type of the network offering, can be Shared or Isolated', PRIMARY KEY (`id`), INDEX `i_network_offerings__system_only`(`system_only`), INDEX `i_network_offerings__removed`(`removed`)