mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
server: create network offering for specified domain(s) and zone(s)
Signed-off-by: Abhishek Kumar <abhishek.kumar@shapeblue.com>
This commit is contained in:
parent
e2bb43a392
commit
dc589a442d
@ -38,7 +38,7 @@ public interface NetworkOffering extends InfrastructureEntity, InternalIdentity,
|
||||
}
|
||||
|
||||
public enum Detail {
|
||||
InternalLbProvider, PublicLbProvider, servicepackageuuid, servicepackagedescription, PromiscuousMode, MacAddressChanges, ForgedTransmits, RelatedNetworkOffering
|
||||
InternalLbProvider, PublicLbProvider, servicepackageuuid, servicepackagedescription, PromiscuousMode, MacAddressChanges, ForgedTransmits, RelatedNetworkOffering, domainid, zoneid
|
||||
}
|
||||
|
||||
public final static String SystemPublicNetwork = "System-Public-Network";
|
||||
|
||||
@ -20,9 +20,14 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.cloudstack.api.response.DomainResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
@ -58,9 +63,9 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
|
||||
private String displayText;
|
||||
|
||||
@Parameter(name = ApiConstants.TRAFFIC_TYPE,
|
||||
type = CommandType.STRING,
|
||||
required = true,
|
||||
description = "the traffic type for the network offering. Supported type in current release is GUEST only")
|
||||
type = CommandType.STRING,
|
||||
required = true,
|
||||
description = "the traffic type for the network offering. Supported type in current release is GUEST only")
|
||||
private String traffictype;
|
||||
|
||||
@Parameter(name = ApiConstants.TAGS, type = CommandType.STRING, description = "the tags for the network offering.", length = 4096)
|
||||
@ -79,37 +84,37 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
|
||||
private Boolean conserveMode;
|
||||
|
||||
@Parameter(name = ApiConstants.SERVICE_OFFERING_ID,
|
||||
type = CommandType.UUID,
|
||||
entityType = ServiceOfferingResponse.class,
|
||||
description = "the service offering ID used by virtual router provider")
|
||||
type = CommandType.UUID,
|
||||
entityType = ServiceOfferingResponse.class,
|
||||
description = "the service offering ID used by virtual router provider")
|
||||
private Long serviceOfferingId;
|
||||
|
||||
@Parameter(name = ApiConstants.GUEST_IP_TYPE, type = CommandType.STRING, required = true, description = "guest type of the network offering: Shared or Isolated")
|
||||
private String guestIptype;
|
||||
|
||||
@Parameter(name = ApiConstants.SUPPORTED_SERVICES,
|
||||
type = CommandType.LIST,
|
||||
required = true,
|
||||
collectionType = CommandType.STRING,
|
||||
description = "services supported by the network offering")
|
||||
type = CommandType.LIST,
|
||||
required = true,
|
||||
collectionType = CommandType.STRING,
|
||||
description = "services supported by the network offering")
|
||||
private List<String> supportedServices;
|
||||
|
||||
@Parameter(name = ApiConstants.SERVICE_PROVIDER_LIST,
|
||||
type = CommandType.MAP,
|
||||
description = "provider to service mapping. If not specified, the provider for the service will be mapped to the default provider on the physical network")
|
||||
type = CommandType.MAP,
|
||||
description = "provider to service mapping. If not specified, the provider for the service will be mapped to the default provider on the physical network")
|
||||
private Map serviceProviderList;
|
||||
|
||||
@Parameter(name = ApiConstants.SERVICE_CAPABILITY_LIST, type = CommandType.MAP, description = "desired service capabilities as part of network offering")
|
||||
private Map serviceCapabilitystList;
|
||||
|
||||
@Parameter(name = ApiConstants.SPECIFY_IP_RANGES,
|
||||
type = CommandType.BOOLEAN,
|
||||
description = "true if network offering supports specifying ip ranges; defaulted to false if not specified")
|
||||
type = CommandType.BOOLEAN,
|
||||
description = "true if network offering supports specifying ip ranges; defaulted to false if not specified")
|
||||
private Boolean specifyIpRanges;
|
||||
|
||||
@Parameter(name = ApiConstants.IS_PERSISTENT,
|
||||
type = CommandType.BOOLEAN,
|
||||
description = "true if network offering supports persistent networks; defaulted to false if not specified")
|
||||
type = CommandType.BOOLEAN,
|
||||
description = "true if network offering supports persistent networks; defaulted to false if not specified")
|
||||
private Boolean isPersistent;
|
||||
|
||||
@Parameter(name = ApiConstants.FOR_VPC,
|
||||
@ -118,26 +123,41 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
|
||||
private Boolean forVpc;
|
||||
|
||||
@Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, since = "4.2.0", description = "Network offering details in key/value pairs."
|
||||
+ " Supported keys are internallbprovider/publiclbprovider with service provider as a value, and"
|
||||
+ " promiscuousmode/macaddresschanges/forgedtransmits with true/false as value to accept/reject the security settings if available for a nic/portgroup")
|
||||
+ " Supported keys are internallbprovider/publiclbprovider with service provider as a value, and"
|
||||
+ " promiscuousmode/macaddresschanges/forgedtransmits with true/false as value to accept/reject the security settings if available for a nic/portgroup")
|
||||
protected Map details;
|
||||
|
||||
@Parameter(name = ApiConstants.EGRESS_DEFAULT_POLICY,
|
||||
type = CommandType.BOOLEAN,
|
||||
description = "true if guest network default egress policy is allow; false if default egress policy is deny")
|
||||
type = CommandType.BOOLEAN,
|
||||
description = "true if guest network default egress policy is allow; false if default egress policy is deny")
|
||||
private Boolean egressDefaultPolicy;
|
||||
|
||||
@Parameter(name = ApiConstants.KEEPALIVE_ENABLED,
|
||||
type = CommandType.BOOLEAN,
|
||||
required = false,
|
||||
description = "if true keepalive will be turned on in the loadbalancer. At the time of writing this has only an effect on haproxy; the mode http and httpclose options are unset in the haproxy conf file.")
|
||||
type = CommandType.BOOLEAN,
|
||||
required = false,
|
||||
description = "if true keepalive will be turned on in the loadbalancer. At the time of writing this has only an effect on haproxy; the mode http and httpclose options are unset in the haproxy conf file.")
|
||||
private Boolean keepAliveEnabled;
|
||||
|
||||
@Parameter(name = ApiConstants.MAX_CONNECTIONS,
|
||||
type = CommandType.INTEGER,
|
||||
description = "maximum number of concurrent connections supported by the network offering")
|
||||
type = CommandType.INTEGER,
|
||||
description = "maximum number of concurrent connections supported by the network offering")
|
||||
private Integer maxConnections;
|
||||
|
||||
@Parameter(name = ApiConstants.DOMAIN_ID,
|
||||
type = CommandType.LIST,
|
||||
collectionType = CommandType.UUID,
|
||||
entityType = DomainResponse.class,
|
||||
description = "the ID of the containing domain(s), null for public offerings")
|
||||
private List<Long> domainIds;
|
||||
|
||||
@Parameter(name = ApiConstants.ZONE_ID,
|
||||
type = CommandType.LIST,
|
||||
collectionType = CommandType.UUID,
|
||||
entityType = ZoneResponse.class,
|
||||
description = "the ID of the containing zone(s), null for public offerings",
|
||||
since = "4.13")
|
||||
private List<Long> zoneIds;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@ -227,7 +247,7 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
|
||||
Collection servicesCollection = serviceProviderList.values();
|
||||
Iterator iter = servicesCollection.iterator();
|
||||
while (iter.hasNext()) {
|
||||
HashMap<String, String> services = (HashMap<String, String>)iter.next();
|
||||
HashMap<String, String> services = (HashMap<String, String>) iter.next();
|
||||
String service = services.get("service");
|
||||
String provider = services.get("provider");
|
||||
List<String> providerList = null;
|
||||
@ -252,7 +272,7 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
|
||||
Collection serviceCapabilityCollection = serviceCapabilitystList.values();
|
||||
Iterator iter = serviceCapabilityCollection.iterator();
|
||||
while (iter.hasNext()) {
|
||||
HashMap<String, String> svcCapabilityMap = (HashMap<String, String>)iter.next();
|
||||
HashMap<String, String> svcCapabilityMap = (HashMap<String, String>) iter.next();
|
||||
Capability capability = null;
|
||||
String svc = svcCapabilityMap.get("service");
|
||||
String capabilityName = svcCapabilityMap.get("capabilitytype");
|
||||
@ -283,11 +303,10 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
|
||||
}
|
||||
|
||||
Collection paramsCollection = details.values();
|
||||
Object objlist[]= paramsCollection.toArray();
|
||||
Map<String, String> params = (Map<String, String>)(objlist[0]);
|
||||
for(int i=1; i< objlist.length; i++)
|
||||
{
|
||||
params.putAll((Map<String, String>)(objlist[i]));
|
||||
Object objlist[] = paramsCollection.toArray();
|
||||
Map<String, String> params = (Map<String, String>) (objlist[0]);
|
||||
for (int i = 1; i < objlist.length; i++) {
|
||||
params.putAll((Map<String, String>) (objlist[i]));
|
||||
}
|
||||
|
||||
return params;
|
||||
@ -297,7 +316,25 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
|
||||
Map<String, String> data = getDetails();
|
||||
if (data == null)
|
||||
return null;
|
||||
return data.get(NetworkOffering.Detail.servicepackageuuid+ "");
|
||||
return data.get(NetworkOffering.Detail.servicepackageuuid + "");
|
||||
}
|
||||
|
||||
public List<Long> getDomainIds() {
|
||||
if (CollectionUtils.isNotEmpty(domainIds)) {
|
||||
Set<Long> set = new LinkedHashSet<>(domainIds);
|
||||
domainIds.clear();
|
||||
domainIds.addAll(set);
|
||||
}
|
||||
return domainIds;
|
||||
}
|
||||
|
||||
public List<Long> getZoneIds() {
|
||||
if (CollectionUtils.isNotEmpty(zoneIds)) {
|
||||
Set<Long> set = new LinkedHashSet<>(zoneIds);
|
||||
zoneIds.clear();
|
||||
zoneIds.addAll(set);
|
||||
}
|
||||
return zoneIds;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ -16,6 +16,13 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.command.admin.network;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.cloudstack.api.response.DomainResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
@ -49,7 +56,7 @@ 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")
|
||||
+ " Default value is Required for Guest Virtual network offering; Optional for Guest Direct network offering")
|
||||
private String availability;
|
||||
|
||||
@Parameter(name = ApiConstants.SORT_KEY, type = CommandType.INTEGER, description = "sort key of the network offering, integer")
|
||||
@ -59,19 +66,34 @@ public class UpdateNetworkOfferingCmd extends BaseCmd {
|
||||
private String state;
|
||||
|
||||
@Parameter(name = ApiConstants.KEEPALIVE_ENABLED,
|
||||
type = CommandType.BOOLEAN,
|
||||
required = false,
|
||||
description = "if true keepalive will be turned on in the loadbalancer. At the time of writing this has only an effect on haproxy; the mode http and httpclose options are unset in the haproxy conf file.")
|
||||
type = CommandType.BOOLEAN,
|
||||
required = false,
|
||||
description = "if true keepalive will be turned on in the loadbalancer. At the time of writing this has only an effect on haproxy; the mode http and httpclose options are unset in the haproxy conf file.")
|
||||
private Boolean keepAliveEnabled;
|
||||
|
||||
@Parameter(name = ApiConstants.MAX_CONNECTIONS,
|
||||
type = CommandType.INTEGER,
|
||||
description = "maximum number of concurrent connections supported by the network offering")
|
||||
type = CommandType.INTEGER,
|
||||
description = "maximum number of concurrent connections supported by the network offering")
|
||||
private Integer maxConnections;
|
||||
|
||||
@Parameter(name = ApiConstants.TAGS, type = CommandType.STRING, description = "the tags for the network offering.", length = 4096)
|
||||
private String tags;
|
||||
|
||||
@Parameter(name = ApiConstants.DOMAIN_ID,
|
||||
type = CommandType.LIST,
|
||||
collectionType = CommandType.UUID,
|
||||
entityType = DomainResponse.class,
|
||||
description = "the ID of the containing domain(s), null for public offerings")
|
||||
private List<Long> domainIds;
|
||||
|
||||
@Parameter(name = ApiConstants.ZONE_ID,
|
||||
type = CommandType.LIST,
|
||||
collectionType = CommandType.UUID,
|
||||
entityType = ZoneResponse.class,
|
||||
description = "the ID of the containing zone(s), null for public offerings",
|
||||
since = "4.13")
|
||||
private List<Long> zoneIds;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@ -112,6 +134,24 @@ public class UpdateNetworkOfferingCmd extends BaseCmd {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public List<Long> getDomainIds() {
|
||||
if (CollectionUtils.isNotEmpty(domainIds)) {
|
||||
Set<Long> set = new LinkedHashSet<>(domainIds);
|
||||
domainIds.clear();
|
||||
domainIds.addAll(set);
|
||||
}
|
||||
return domainIds;
|
||||
}
|
||||
|
||||
public List<Long> getZoneIds() {
|
||||
if (CollectionUtils.isNotEmpty(zoneIds)) {
|
||||
Set<Long> set = new LinkedHashSet<>(zoneIds);
|
||||
zoneIds.clear();
|
||||
zoneIds.addAll(set);
|
||||
}
|
||||
return zoneIds;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ -20,14 +20,13 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
import org.apache.cloudstack.api.EntityReference;
|
||||
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@EntityReference(value = NetworkOffering.class)
|
||||
@SuppressWarnings("unused")
|
||||
@ -124,6 +123,22 @@ public class NetworkOfferingResponse extends BaseResponse {
|
||||
@Param(description = "true if network offering supports public access for guest networks", since = "4.10.0")
|
||||
private Boolean supportsPublicAccess;
|
||||
|
||||
@SerializedName(ApiConstants.DOMAIN_ID)
|
||||
@Param(description = "the domain ID(s) this disk offering belongs to. Ignore this information as it is not currently applicable.")
|
||||
private String domainId;
|
||||
|
||||
@SerializedName(ApiConstants.DOMAIN)
|
||||
@Param(description = "the domain name(s) this disk offering belongs to. Ignore this information as it is not currently applicable.")
|
||||
private String domain;
|
||||
|
||||
@SerializedName(ApiConstants.ZONE_ID)
|
||||
@Param(description = "the zone ID(s) this disk offering belongs to. Ignore this information as it is not currently applicable.", since = "4.13.0")
|
||||
private String zoneId;
|
||||
|
||||
@SerializedName(ApiConstants.ZONE)
|
||||
@Param(description = "the zone name(s) this disk offering belongs to. Ignore this information as it is not currently applicable.", since = "4.13.0")
|
||||
private String zone;
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
@ -215,4 +230,36 @@ public class NetworkOfferingResponse extends BaseResponse {
|
||||
public void setSupportsPublicAccess(Boolean supportsPublicAccess) {
|
||||
this.supportsPublicAccess = supportsPublicAccess;
|
||||
}
|
||||
|
||||
public String getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public void setDomainId(String domainId) {
|
||||
this.domainId = domainId;
|
||||
}
|
||||
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
public void setDomain(String domain) {
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
public String getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public void setZoneId(String zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
public String getZone() {
|
||||
return zone;
|
||||
}
|
||||
|
||||
public void setZone(String zone) {
|
||||
this.zone = zone;
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
// under the License.
|
||||
package com.cloud.configuration;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@ -205,13 +206,15 @@ public interface ConfigurationManager {
|
||||
* ;
|
||||
* @param details TODO
|
||||
* @param forVpc
|
||||
* @param domainIds
|
||||
* @param zoneIds
|
||||
* @return network offering object
|
||||
*/
|
||||
|
||||
NetworkOfferingVO createNetworkOffering(String name, String displayText, TrafficType trafficType, String tags, boolean specifyVlan, Availability availability,
|
||||
Integer networkRate, Map<Service, Set<Provider>> serviceProviderMap, boolean isDefault, Network.GuestType type, boolean systemOnly, Long serviceOfferingId,
|
||||
boolean conserveMode, Map<Service, Map<Capability, String>> serviceCapabilityMap, boolean specifyIpRanges, boolean isPersistent,
|
||||
Map<NetworkOffering.Detail, String> details, boolean egressDefaultPolicy, Integer maxconn, boolean enableKeepAlive, Boolean forVpc);
|
||||
Integer networkRate, Map<Service, Set<Provider>> serviceProviderMap, boolean isDefault, Network.GuestType type, boolean systemOnly, Long serviceOfferingId,
|
||||
boolean conserveMode, Map<Service, Map<Capability, String>> serviceCapabilityMap, boolean specifyIpRanges, boolean isPersistent,
|
||||
Map<NetworkOffering.Detail, String> details, boolean egressDefaultPolicy, Integer maxconn, boolean enableKeepAlive, Boolean forVpc, List<Long> domainIds, List<Long> zoneIds);
|
||||
|
||||
Vlan createVlanAndPublicIpRange(long zoneId, long networkId, long physicalNetworkId, boolean forVirtualNetwork, boolean forSystemVms, Long podId, String startIP, String endIP,
|
||||
String vlanGateway, String vlanNetmask, String vlanId, boolean bypassVlanOverlapCheck, Domain domain, Account vlanOwner, String startIPv6, String endIPv6, String vlanIp6Gateway, String vlanIp6Cidr)
|
||||
|
||||
@ -442,7 +442,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
|
||||
if (_networkOfferingDao.findByUniqueName(NetworkOffering.QuickCloudNoServices) == null) {
|
||||
offering = _configMgr.createNetworkOffering(NetworkOffering.QuickCloudNoServices, "Offering for QuickCloud with no services", TrafficType.Guest, null, true,
|
||||
Availability.Optional, null, new HashMap<Network.Service, Set<Network.Provider>>(), true, Network.GuestType.Shared, false, null, true, null, true,
|
||||
false, null, false, null, true, false);
|
||||
false, null, false, null, true, false, null, null);
|
||||
offering.setState(NetworkOffering.State.Enabled);
|
||||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
}
|
||||
@ -451,7 +451,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
|
||||
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultSharedNetworkOfferingWithSGService) == null) {
|
||||
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultSharedNetworkOfferingWithSGService, "Offering for Shared Security group enabled networks",
|
||||
TrafficType.Guest, null, true, Availability.Optional, null, defaultSharedNetworkOfferingProviders, true, Network.GuestType.Shared, false, null, true,
|
||||
null, true, false, null, false, null, true, false);
|
||||
null, true, false, null, false, null, true, false, null, null);
|
||||
offering.setState(NetworkOffering.State.Enabled);
|
||||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
}
|
||||
@ -460,7 +460,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
|
||||
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultSharedNetworkOffering) == null) {
|
||||
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultSharedNetworkOffering, "Offering for Shared networks", TrafficType.Guest, null, true,
|
||||
Availability.Optional, null, defaultSharedNetworkOfferingProviders, true, Network.GuestType.Shared, false, null, true, null, true, false, null, false,
|
||||
null, true, false);
|
||||
null, true, false, null, null);
|
||||
offering.setState(NetworkOffering.State.Enabled);
|
||||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
}
|
||||
@ -470,7 +470,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
|
||||
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOfferingWithSourceNatService,
|
||||
"Offering for Isolated networks with Source Nat service enabled", TrafficType.Guest, null, false, Availability.Required, null,
|
||||
defaultIsolatedSourceNatEnabledNetworkOfferingProviders, true, Network.GuestType.Isolated, false, null, true, null, false, false, null, false, null,
|
||||
true, false);
|
||||
true, false, null, null);
|
||||
|
||||
offering.setState(NetworkOffering.State.Enabled);
|
||||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
@ -480,7 +480,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
|
||||
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworks) == null) {
|
||||
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworks,
|
||||
"Offering for Isolated VPC networks with Source Nat service enabled", TrafficType.Guest, null, false, Availability.Optional, null,
|
||||
defaultVPCOffProviders, true, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, true);
|
||||
defaultVPCOffProviders, true, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, true, null, null);
|
||||
offering.setState(NetworkOffering.State.Enabled);
|
||||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
}
|
||||
@ -491,7 +491,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
|
||||
defaultVPCOffProviders.remove(Service.Lb);
|
||||
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksNoLB,
|
||||
"Offering for Isolated VPC networks with Source Nat service enabled and LB service disabled", TrafficType.Guest, null, false, Availability.Optional,
|
||||
null, defaultVPCOffProviders, true, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, true);
|
||||
null, defaultVPCOffProviders, true, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, true, null, null);
|
||||
offering.setState(NetworkOffering.State.Enabled);
|
||||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
}
|
||||
@ -500,7 +500,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
|
||||
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultIsolatedNetworkOffering) == null) {
|
||||
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOffering, "Offering for Isolated networks with no Source Nat service",
|
||||
TrafficType.Guest, null, true, Availability.Optional, null, defaultIsolatedNetworkOfferingProviders, true, Network.GuestType.Isolated, false, null,
|
||||
true, null, true, false, null, false, null, true, false);
|
||||
true, null, true, false, null, false, null, true, false, null, null);
|
||||
offering.setState(NetworkOffering.State.Enabled);
|
||||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
}
|
||||
@ -524,7 +524,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
|
||||
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksWithInternalLB) == null) {
|
||||
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksWithInternalLB,
|
||||
"Offering for Isolated VPC networks with Internal Lb support", TrafficType.Guest, null, false, Availability.Optional, null, internalLbOffProviders,
|
||||
true, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, true);
|
||||
true, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, true, null, null);
|
||||
offering.setState(NetworkOffering.State.Enabled);
|
||||
offering.setInternalLb(true);
|
||||
offering.setPublicLb(false);
|
||||
@ -556,7 +556,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
|
||||
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultSharedEIPandELBNetworkOffering) == null) {
|
||||
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultSharedEIPandELBNetworkOffering,
|
||||
"Offering for Shared networks with Elastic IP and Elastic LB capabilities", TrafficType.Guest, null, true, Availability.Optional, null,
|
||||
netscalerServiceProviders, true, Network.GuestType.Shared, false, null, true, serviceCapabilityMap, true, false, null, false, null, true, false);
|
||||
netscalerServiceProviders, true, Network.GuestType.Shared, false, null, true, serviceCapabilityMap, true, false, null, false, null, true, false, null, null);
|
||||
offering.setState(NetworkOffering.State.Enabled);
|
||||
offering.setDedicatedLB(false);
|
||||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
|
||||
@ -25,9 +25,10 @@ import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.apache.cloudstack.api.ResourceDetail;
|
||||
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.Detail;
|
||||
import org.apache.cloudstack.api.ResourceDetail;
|
||||
|
||||
@Entity
|
||||
@Table(name = "network_offering_details")
|
||||
@ -47,6 +48,9 @@ public class NetworkOfferingDetailsVO implements ResourceDetail {
|
||||
@Column(name = "value", length = 1024)
|
||||
private String value;
|
||||
|
||||
@Column(name = "display")
|
||||
private boolean display;
|
||||
|
||||
public NetworkOfferingDetailsVO() {
|
||||
}
|
||||
|
||||
@ -54,6 +58,7 @@ public class NetworkOfferingDetailsVO implements ResourceDetail {
|
||||
this.resourceId = resourceId;
|
||||
this.name = detailName;
|
||||
this.value = value;
|
||||
this.display = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -84,7 +89,7 @@ public class NetworkOfferingDetailsVO implements ResourceDetail {
|
||||
|
||||
@Override
|
||||
public boolean isDisplay() {
|
||||
return false;
|
||||
return display;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
|
||||
@ -16,16 +16,18 @@
|
||||
// under the License.
|
||||
package com.cloud.offerings.dao;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.resourcedetail.ResourceDetailsDao;
|
||||
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.Detail;
|
||||
import com.cloud.offerings.NetworkOfferingDetailsVO;
|
||||
import org.apache.cloudstack.resourcedetail.ResourceDetailsDao;
|
||||
|
||||
public interface NetworkOfferingDetailsDao extends ResourceDetailsDao<NetworkOfferingDetailsVO> {
|
||||
|
||||
Map<NetworkOffering.Detail, String> getNtwkOffDetails(long offeringId);
|
||||
|
||||
String getDetail(long offeringId, Detail detailName);
|
||||
List<Long> findDomainIds(final long resourceId);
|
||||
List<Long> findZoneIds(final long resourceId);
|
||||
}
|
||||
|
||||
@ -16,12 +16,14 @@
|
||||
// under the License.
|
||||
package com.cloud.offerings.dao;
|
||||
|
||||
import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase;
|
||||
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.Detail;
|
||||
import com.cloud.offerings.NetworkOfferingDetailsVO;
|
||||
@ -77,7 +79,32 @@ public class NetworkOfferingDetailsDaoImpl extends ResourceDetailsDaoBase<Networ
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void addDetail(long resourceId, String key, String value, boolean display) {
|
||||
@Override
|
||||
public void addDetail(long resourceId, String key, String value, boolean display) {
|
||||
persist(new NetworkOfferingDetailsVO(resourceId, Detail.valueOf(key), value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> findDomainIds(long resourceId) {
|
||||
final List<Long> domainIds = new ArrayList<>();
|
||||
for (final NetworkOfferingDetailsVO detail: findDetails(resourceId, ApiConstants.DOMAIN_ID)) {
|
||||
final Long domainId = Long.valueOf(detail.getValue());
|
||||
if (domainId > 0) {
|
||||
domainIds.add(domainId);
|
||||
}
|
||||
}
|
||||
return domainIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> findZoneIds(long resourceId) {
|
||||
final List<Long> zoneIds = new ArrayList<>();
|
||||
for (final NetworkOfferingDetailsVO detail: findDetails(resourceId, ApiConstants.ZONE_ID)) {
|
||||
final Long zoneId = Long.valueOf(detail.getValue());
|
||||
if (zoneId > 0) {
|
||||
zoneIds.add(zoneId);
|
||||
}
|
||||
}
|
||||
return zoneIds;
|
||||
}
|
||||
}
|
||||
|
||||
@ -210,6 +210,7 @@
|
||||
<bean id="networkExternalFirewallDaoImpl" class="com.cloud.network.dao.NetworkExternalFirewallDaoImpl" />
|
||||
<bean id="networkExternalLoadBalancerDaoImpl" class="com.cloud.network.dao.NetworkExternalLoadBalancerDaoImpl" />
|
||||
<bean id="networkOfferingDaoImpl" class="com.cloud.offerings.dao.NetworkOfferingDaoImpl" />
|
||||
<bean id="networkOfferingJoinDaoImpl" class="com.cloud.api.query.dao.NetworkOfferingJoinDaoImpl" />
|
||||
<bean id="networkOfferingServiceMapDaoImpl" class="com.cloud.offerings.dao.NetworkOfferingServiceMapDaoImpl" />
|
||||
<bean id="networkOpDaoImpl" class="com.cloud.network.dao.NetworkOpDaoImpl" />
|
||||
<bean id="networkRuleConfigDaoImpl" class="com.cloud.network.dao.NetworkRuleConfigDaoImpl" />
|
||||
|
||||
@ -154,3 +154,68 @@ CREATE VIEW `cloud`.`service_offering_view` AS
|
||||
`disk_offering`.`state`='Active'
|
||||
GROUP BY
|
||||
`service_offering`.`id`;
|
||||
|
||||
-- Add display column for network offering details table
|
||||
ALTER TABLE `cloud`.`network_offering_details` ADD COLUMN `display` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'True if the detail can be displayed to the end user';
|
||||
|
||||
-- Network offering with multi-domains and multi-zones
|
||||
DROP VIEW IF EXISTS `cloud`.`network_offering_view`;
|
||||
CREATE VIEW `cloud`.`network_offering_view` AS
|
||||
SELECT
|
||||
`network_offerings`.`id` AS `id`,
|
||||
`network_offerings`.`uuid` AS `uuid`,
|
||||
`network_offerings`.`name` AS `name`,
|
||||
`network_offerings`.`unique_name` AS `unique_name`,
|
||||
`network_offerings`.`display_text` AS `display_text`,
|
||||
`network_offerings`.`nw_rate` AS `nw_rate`,
|
||||
`network_offerings`.`mc_rate` AS `mc_rate`,
|
||||
`network_offerings`.`traffic_type` AS `traffic_type`,
|
||||
`network_offerings`.`tags` AS `tags`,
|
||||
`network_offerings`.`system_only` AS `system_only`,
|
||||
`network_offerings`.`specify_vlan` AS `specify_vlan`,
|
||||
`network_offerings`.`service_offering_id` AS `service_offering_id`,
|
||||
`network_offerings`.`conserve_mode` AS `conserve_mode`,
|
||||
`network_offerings`.`created` AS `created`,
|
||||
`network_offerings`.`removed` AS `removed`,
|
||||
`network_offerings`.`default` AS `default`,
|
||||
`network_offerings`.`availability` AS `availability`,
|
||||
`network_offerings`.`dedicated_lb_service` AS `dedicated_lb_service`,
|
||||
`network_offerings`.`shared_source_nat_service` AS `shared_source_nat_service`,
|
||||
`network_offerings`.`sort_key` AS `sort_key`,
|
||||
`network_offerings`.`redundant_router_service` AS `redundant_router_service`,
|
||||
`network_offerings`.`state` AS `state`,
|
||||
`network_offerings`.`guest_type` AS `guest_type`,
|
||||
`network_offerings`.`elastic_ip_service` AS `elastic_ip_service`,
|
||||
`network_offerings`.`eip_associate_public_ip` AS `eip_associate_public_ip`,
|
||||
`network_offerings`.`elastic_lb_service` AS `elastic_lb_service`,
|
||||
`network_offerings`.`specify_ip_ranges` AS `specify_ip_ranges`,
|
||||
`network_offerings`.`inline` AS `inline`,
|
||||
`network_offerings`.`is_persistent` AS `is_persistent`,
|
||||
`network_offerings`.`internal_lb` AS `internal_lb`,
|
||||
`network_offerings`.`public_lb` AS `public_lb`,
|
||||
`network_offerings`.`egress_default_policy` AS `egress_default_policy`,
|
||||
`network_offerings`.`concurrent_connections` AS `concurrent_connections`,
|
||||
`network_offerings`.`keep_alive_enabled` AS `keep_alive_enabled`,
|
||||
`network_offerings`.`supports_streched_l2` AS `supports_streched_l2`,
|
||||
`network_offerings`.`supports_public_access` AS `supports_public_access`,
|
||||
`network_offerings`.`for_vpc` AS `for_vpc`,
|
||||
`network_offerings`.`service_package_id` AS `service_package_id`,
|
||||
GROUP_CONCAT(DISTINCT(domain.id)) AS domain_id,
|
||||
GROUP_CONCAT(DISTINCT(domain.uuid)) AS domain_uuid,
|
||||
GROUP_CONCAT(DISTINCT(domain.name)) AS domain_name,
|
||||
GROUP_CONCAT(DISTINCT(domain.path)) AS domain_path,
|
||||
GROUP_CONCAT(DISTINCT(zone.id)) AS zone_id,
|
||||
GROUP_CONCAT(DISTINCT(zone.uuid)) AS zone_uuid,
|
||||
GROUP_CONCAT(DISTINCT(zone.name)) AS zone_name
|
||||
FROM
|
||||
`cloud`.`network_offerings`
|
||||
LEFT JOIN
|
||||
`cloud`.`network_offering_details` AS `domain_details` ON `domain_details`.`network_offering_id` = `network_offerings`.`id` AND `domain_details`.`name`='domainid'
|
||||
LEFT JOIN
|
||||
`cloud`.`domain` AS `domain` ON FIND_IN_SET(`domain`.`id`, `domain_details`.`value`)
|
||||
LEFT JOIN
|
||||
`cloud`.`network_offering_details` AS `zone_details` ON `zone_details`.`network_offering_id` = `network_offerings`.`id` AND `zone_details`.`name`='zoneid'
|
||||
LEFT JOIN
|
||||
`cloud`.`data_center` AS `zone` ON FIND_IN_SET(`zone`.`id`, `zone_details`.`value`)
|
||||
GROUP BY
|
||||
`network_offerings`.`id`;
|
||||
@ -219,7 +219,7 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
|
||||
ConfigurationManager configMgr = (ConfigurationManager) _configService;
|
||||
NetworkOfferingVO voffer = configMgr.createNetworkOffering(offeringName, offeringDisplayText,
|
||||
TrafficType.Public, null, true, Availability.Optional, null, serviceProviderMap, true,
|
||||
Network.GuestType.Shared, false, null, false, null, true, false, null, true, null, false, false);
|
||||
Network.GuestType.Shared, false, null, false, null, true, false, null, true, null, false, false, null, null);
|
||||
|
||||
voffer.setState(NetworkOffering.State.Enabled);
|
||||
long id = voffer.getId();
|
||||
@ -256,7 +256,7 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
|
||||
ConfigurationManager configMgr = (ConfigurationManager)_configService;
|
||||
NetworkOfferingVO voffer =
|
||||
configMgr.createNetworkOffering(offeringName, offeringDisplayText, TrafficType.Guest, null, false, Availability.Optional, null, serviceProviderMap, true,
|
||||
Network.GuestType.Isolated, false, null, false, null, false, true, null, true, null, false, offeringName.equals(vpcRouterOfferingName));
|
||||
Network.GuestType.Isolated, false, null, false, null, false, true, null, true, null, false, offeringName.equals(vpcRouterOfferingName), null, null);
|
||||
|
||||
voffer.setState(NetworkOffering.State.Enabled);
|
||||
if (offeringName.equals(vpcRouterOfferingName)) {
|
||||
|
||||
@ -48,6 +48,7 @@ import org.apache.cloudstack.api.response.HostResponse;
|
||||
import org.apache.cloudstack.api.response.HostTagResponse;
|
||||
import org.apache.cloudstack.api.response.ImageStoreResponse;
|
||||
import org.apache.cloudstack.api.response.InstanceGroupResponse;
|
||||
import org.apache.cloudstack.api.response.NetworkOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectAccountResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectInvitationResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectResponse;
|
||||
@ -84,6 +85,7 @@ import com.cloud.api.query.dao.HostJoinDao;
|
||||
import com.cloud.api.query.dao.HostTagDao;
|
||||
import com.cloud.api.query.dao.ImageStoreJoinDao;
|
||||
import com.cloud.api.query.dao.InstanceGroupJoinDao;
|
||||
import com.cloud.api.query.dao.NetworkOfferingJoinDao;
|
||||
import com.cloud.api.query.dao.ProjectAccountJoinDao;
|
||||
import com.cloud.api.query.dao.ProjectInvitationJoinDao;
|
||||
import com.cloud.api.query.dao.ProjectJoinDao;
|
||||
@ -107,6 +109,7 @@ import com.cloud.api.query.vo.HostJoinVO;
|
||||
import com.cloud.api.query.vo.HostTagVO;
|
||||
import com.cloud.api.query.vo.ImageStoreJoinVO;
|
||||
import com.cloud.api.query.vo.InstanceGroupJoinVO;
|
||||
import com.cloud.api.query.vo.NetworkOfferingJoinVO;
|
||||
import com.cloud.api.query.vo.ProjectAccountJoinVO;
|
||||
import com.cloud.api.query.vo.ProjectInvitationJoinVO;
|
||||
import com.cloud.api.query.vo.ProjectJoinVO;
|
||||
@ -227,6 +230,7 @@ import com.cloud.network.vpc.dao.VpcDao;
|
||||
import com.cloud.network.vpc.dao.VpcGatewayDao;
|
||||
import com.cloud.network.vpc.dao.VpcOfferingDao;
|
||||
import com.cloud.offering.DiskOffering;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
@ -370,6 +374,7 @@ public class ApiDBUtils {
|
||||
static Site2SiteCustomerGatewayDao s_site2SiteCustomerGatewayDao;
|
||||
static DataCenterDao s_zoneDao;
|
||||
static NetworkOfferingDao s_networkOfferingDao;
|
||||
static NetworkOfferingJoinDao s_networkOfferingJoinDao;
|
||||
static NetworkDao s_networkDao;
|
||||
static PhysicalNetworkDao s_physicalNetworkDao;
|
||||
static ConfigurationService s_configSvc;
|
||||
@ -539,6 +544,8 @@ public class ApiDBUtils {
|
||||
@Inject
|
||||
private NetworkOfferingDao networkOfferingDao;
|
||||
@Inject
|
||||
private NetworkOfferingJoinDao networkOfferingJoinDao;
|
||||
@Inject
|
||||
private NetworkDao networkDao;
|
||||
@Inject
|
||||
private PhysicalNetworkDao physicalNetworkDao;
|
||||
@ -724,6 +731,7 @@ public class ApiDBUtils {
|
||||
s_securityGroupDao = securityGroupDao;
|
||||
s_securityGroupJoinDao = securityGroupJoinDao;
|
||||
s_networkOfferingDao = networkOfferingDao;
|
||||
s_networkOfferingJoinDao = networkOfferingJoinDao;
|
||||
s_networkDao = networkDao;
|
||||
s_physicalNetworkDao = physicalNetworkDao;
|
||||
s_configDao = configDao;
|
||||
@ -1242,6 +1250,14 @@ public class ApiDBUtils {
|
||||
return s_networkMgr.convertNetworkToNetworkProfile(networkId);
|
||||
}
|
||||
|
||||
public static NetworkOfferingResponse newNetworkOfferingResponse(NetworkOffering offering) {
|
||||
return s_networkOfferingJoinDao.newNetworkOfferingResponse(offering);
|
||||
}
|
||||
|
||||
public static NetworkOfferingJoinVO newNetworkOfferingView(NetworkOffering offering) {
|
||||
return s_networkOfferingJoinDao.newNetworkOfferingView(offering);
|
||||
}
|
||||
|
||||
public static NetworkOfferingVO findNetworkOfferingById(long networkOfferingId) {
|
||||
return s_networkOfferingDao.findByIdIncludingRemoved(networkOfferingId);
|
||||
}
|
||||
|
||||
@ -16,9 +16,153 @@
|
||||
// under the License.
|
||||
package com.cloud.api;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.acl.ControlledEntity;
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
import org.apache.cloudstack.affinity.AffinityGroup;
|
||||
import org.apache.cloudstack.affinity.AffinityGroupResponse;
|
||||
import org.apache.cloudstack.api.ApiConstants.HostDetails;
|
||||
import org.apache.cloudstack.api.ApiConstants.VMDetails;
|
||||
import org.apache.cloudstack.api.ResponseGenerator;
|
||||
import org.apache.cloudstack.api.ResponseObject.ResponseView;
|
||||
import org.apache.cloudstack.api.command.user.job.QueryAsyncJobResultCmd;
|
||||
import org.apache.cloudstack.api.response.AccountResponse;
|
||||
import org.apache.cloudstack.api.response.ApplicationLoadBalancerInstanceResponse;
|
||||
import org.apache.cloudstack.api.response.ApplicationLoadBalancerResponse;
|
||||
import org.apache.cloudstack.api.response.ApplicationLoadBalancerRuleResponse;
|
||||
import org.apache.cloudstack.api.response.AsyncJobResponse;
|
||||
import org.apache.cloudstack.api.response.AutoScalePolicyResponse;
|
||||
import org.apache.cloudstack.api.response.AutoScaleVmGroupResponse;
|
||||
import org.apache.cloudstack.api.response.AutoScaleVmProfileResponse;
|
||||
import org.apache.cloudstack.api.response.CapabilityResponse;
|
||||
import org.apache.cloudstack.api.response.CapacityResponse;
|
||||
import org.apache.cloudstack.api.response.ClusterResponse;
|
||||
import org.apache.cloudstack.api.response.ConditionResponse;
|
||||
import org.apache.cloudstack.api.response.ConfigurationResponse;
|
||||
import org.apache.cloudstack.api.response.ControlledEntityResponse;
|
||||
import org.apache.cloudstack.api.response.ControlledViewEntityResponse;
|
||||
import org.apache.cloudstack.api.response.CounterResponse;
|
||||
import org.apache.cloudstack.api.response.CreateCmdResponse;
|
||||
import org.apache.cloudstack.api.response.CreateSSHKeyPairResponse;
|
||||
import org.apache.cloudstack.api.response.DiskOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.DomainResponse;
|
||||
import org.apache.cloudstack.api.response.DomainRouterResponse;
|
||||
import org.apache.cloudstack.api.response.EventResponse;
|
||||
import org.apache.cloudstack.api.response.ExtractResponse;
|
||||
import org.apache.cloudstack.api.response.FirewallResponse;
|
||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
|
||||
import org.apache.cloudstack.api.response.GlobalLoadBalancerResponse;
|
||||
import org.apache.cloudstack.api.response.GuestOSResponse;
|
||||
import org.apache.cloudstack.api.response.GuestOsMappingResponse;
|
||||
import org.apache.cloudstack.api.response.GuestVlanRangeResponse;
|
||||
import org.apache.cloudstack.api.response.HostForMigrationResponse;
|
||||
import org.apache.cloudstack.api.response.HostResponse;
|
||||
import org.apache.cloudstack.api.response.HypervisorCapabilitiesResponse;
|
||||
import org.apache.cloudstack.api.response.IPAddressResponse;
|
||||
import org.apache.cloudstack.api.response.ImageStoreResponse;
|
||||
import org.apache.cloudstack.api.response.InstanceGroupResponse;
|
||||
import org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse;
|
||||
import org.apache.cloudstack.api.response.IpForwardingRuleResponse;
|
||||
import org.apache.cloudstack.api.response.IsolationMethodResponse;
|
||||
import org.apache.cloudstack.api.response.LBHealthCheckPolicyResponse;
|
||||
import org.apache.cloudstack.api.response.LBHealthCheckResponse;
|
||||
import org.apache.cloudstack.api.response.LBStickinessPolicyResponse;
|
||||
import org.apache.cloudstack.api.response.LBStickinessResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.LoadBalancerResponse;
|
||||
import org.apache.cloudstack.api.response.ManagementServerResponse;
|
||||
import org.apache.cloudstack.api.response.NetworkACLItemResponse;
|
||||
import org.apache.cloudstack.api.response.NetworkACLResponse;
|
||||
import org.apache.cloudstack.api.response.NetworkOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.NetworkResponse;
|
||||
import org.apache.cloudstack.api.response.NicExtraDhcpOptionResponse;
|
||||
import org.apache.cloudstack.api.response.NicResponse;
|
||||
import org.apache.cloudstack.api.response.NicSecondaryIpResponse;
|
||||
import org.apache.cloudstack.api.response.OvsProviderResponse;
|
||||
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
|
||||
import org.apache.cloudstack.api.response.PodResponse;
|
||||
import org.apache.cloudstack.api.response.PortableIpRangeResponse;
|
||||
import org.apache.cloudstack.api.response.PortableIpResponse;
|
||||
import org.apache.cloudstack.api.response.PrivateGatewayResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectAccountResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectInvitationResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectResponse;
|
||||
import org.apache.cloudstack.api.response.ProviderResponse;
|
||||
import org.apache.cloudstack.api.response.RegionResponse;
|
||||
import org.apache.cloudstack.api.response.RemoteAccessVpnResponse;
|
||||
import org.apache.cloudstack.api.response.ResourceCountResponse;
|
||||
import org.apache.cloudstack.api.response.ResourceLimitResponse;
|
||||
import org.apache.cloudstack.api.response.ResourceTagResponse;
|
||||
import org.apache.cloudstack.api.response.SSHKeyPairResponse;
|
||||
import org.apache.cloudstack.api.response.SecurityGroupResponse;
|
||||
import org.apache.cloudstack.api.response.SecurityGroupRuleResponse;
|
||||
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.ServiceResponse;
|
||||
import org.apache.cloudstack.api.response.Site2SiteCustomerGatewayResponse;
|
||||
import org.apache.cloudstack.api.response.Site2SiteVpnConnectionResponse;
|
||||
import org.apache.cloudstack.api.response.Site2SiteVpnGatewayResponse;
|
||||
import org.apache.cloudstack.api.response.SnapshotPolicyResponse;
|
||||
import org.apache.cloudstack.api.response.SnapshotResponse;
|
||||
import org.apache.cloudstack.api.response.SnapshotScheduleResponse;
|
||||
import org.apache.cloudstack.api.response.StaticRouteResponse;
|
||||
import org.apache.cloudstack.api.response.StorageNetworkIpRangeResponse;
|
||||
import org.apache.cloudstack.api.response.StoragePoolResponse;
|
||||
import org.apache.cloudstack.api.response.SystemVmInstanceResponse;
|
||||
import org.apache.cloudstack.api.response.SystemVmResponse;
|
||||
import org.apache.cloudstack.api.response.TemplatePermissionsResponse;
|
||||
import org.apache.cloudstack.api.response.TemplateResponse;
|
||||
import org.apache.cloudstack.api.response.TrafficMonitorResponse;
|
||||
import org.apache.cloudstack.api.response.TrafficTypeResponse;
|
||||
import org.apache.cloudstack.api.response.UpgradeRouterTemplateResponse;
|
||||
import org.apache.cloudstack.api.response.UsageRecordResponse;
|
||||
import org.apache.cloudstack.api.response.UserResponse;
|
||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
import org.apache.cloudstack.api.response.VMSnapshotResponse;
|
||||
import org.apache.cloudstack.api.response.VirtualRouterProviderResponse;
|
||||
import org.apache.cloudstack.api.response.VlanIpRangeResponse;
|
||||
import org.apache.cloudstack.api.response.VolumeResponse;
|
||||
import org.apache.cloudstack.api.response.VpcOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.VpcResponse;
|
||||
import org.apache.cloudstack.api.response.VpnUsersResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.cloudstack.config.Configuration;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreCapabilities;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
|
||||
import org.apache.cloudstack.framework.jobs.AsyncJob;
|
||||
import org.apache.cloudstack.framework.jobs.AsyncJobManager;
|
||||
import org.apache.cloudstack.management.ManagementServerHost;
|
||||
import com.cloud.utils.crypt.DBEncryptionUtil;
|
||||
import com.cloud.tags.dao.ResourceTagDao;
|
||||
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
|
||||
import org.apache.cloudstack.region.PortableIp;
|
||||
import org.apache.cloudstack.region.PortableIpRange;
|
||||
import org.apache.cloudstack.region.Region;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||
import org.apache.cloudstack.usage.Usage;
|
||||
import org.apache.cloudstack.usage.UsageService;
|
||||
import org.apache.cloudstack.usage.UsageTypes;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.VgpuTypesInfo;
|
||||
import com.cloud.api.query.ViewResponseHelper;
|
||||
import com.cloud.api.query.vo.AccountJoinVO;
|
||||
@ -154,6 +298,7 @@ import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.dao.VolumeDao;
|
||||
import com.cloud.storage.snapshot.SnapshotPolicy;
|
||||
import com.cloud.storage.snapshot.SnapshotSchedule;
|
||||
import com.cloud.tags.dao.ResourceTagDao;
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
@ -163,11 +308,12 @@ import com.cloud.user.UserAccount;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.StringUtils;
|
||||
import com.cloud.utils.crypt.DBEncryptionUtil;
|
||||
import com.cloud.utils.db.EntityManager;
|
||||
import com.cloud.utils.net.Dhcp;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.Dhcp;
|
||||
import com.cloud.utils.net.Ip;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.ConsoleProxyVO;
|
||||
@ -183,150 +329,6 @@ import com.cloud.vm.VirtualMachine.Type;
|
||||
import com.cloud.vm.dao.NicExtraDhcpOptionDao;
|
||||
import com.cloud.vm.dao.NicSecondaryIpVO;
|
||||
import com.cloud.vm.snapshot.VMSnapshot;
|
||||
import org.apache.cloudstack.acl.ControlledEntity;
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
import org.apache.cloudstack.affinity.AffinityGroup;
|
||||
import org.apache.cloudstack.affinity.AffinityGroupResponse;
|
||||
import org.apache.cloudstack.api.ApiConstants.HostDetails;
|
||||
import org.apache.cloudstack.api.ApiConstants.VMDetails;
|
||||
import org.apache.cloudstack.api.ResponseGenerator;
|
||||
import org.apache.cloudstack.api.ResponseObject.ResponseView;
|
||||
import org.apache.cloudstack.api.command.user.job.QueryAsyncJobResultCmd;
|
||||
import org.apache.cloudstack.api.response.AccountResponse;
|
||||
import org.apache.cloudstack.api.response.ApplicationLoadBalancerInstanceResponse;
|
||||
import org.apache.cloudstack.api.response.ApplicationLoadBalancerResponse;
|
||||
import org.apache.cloudstack.api.response.ApplicationLoadBalancerRuleResponse;
|
||||
import org.apache.cloudstack.api.response.AsyncJobResponse;
|
||||
import org.apache.cloudstack.api.response.AutoScalePolicyResponse;
|
||||
import org.apache.cloudstack.api.response.AutoScaleVmGroupResponse;
|
||||
import org.apache.cloudstack.api.response.AutoScaleVmProfileResponse;
|
||||
import org.apache.cloudstack.api.response.CapabilityResponse;
|
||||
import org.apache.cloudstack.api.response.CapacityResponse;
|
||||
import org.apache.cloudstack.api.response.ClusterResponse;
|
||||
import org.apache.cloudstack.api.response.ConditionResponse;
|
||||
import org.apache.cloudstack.api.response.ConfigurationResponse;
|
||||
import org.apache.cloudstack.api.response.ControlledEntityResponse;
|
||||
import org.apache.cloudstack.api.response.ControlledViewEntityResponse;
|
||||
import org.apache.cloudstack.api.response.CounterResponse;
|
||||
import org.apache.cloudstack.api.response.CreateCmdResponse;
|
||||
import org.apache.cloudstack.api.response.CreateSSHKeyPairResponse;
|
||||
import org.apache.cloudstack.api.response.DiskOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.DomainResponse;
|
||||
import org.apache.cloudstack.api.response.DomainRouterResponse;
|
||||
import org.apache.cloudstack.api.response.EventResponse;
|
||||
import org.apache.cloudstack.api.response.ExtractResponse;
|
||||
import org.apache.cloudstack.api.response.FirewallResponse;
|
||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
|
||||
import org.apache.cloudstack.api.response.GlobalLoadBalancerResponse;
|
||||
import org.apache.cloudstack.api.response.GuestOSResponse;
|
||||
import org.apache.cloudstack.api.response.GuestOsMappingResponse;
|
||||
import org.apache.cloudstack.api.response.GuestVlanRangeResponse;
|
||||
import org.apache.cloudstack.api.response.HostForMigrationResponse;
|
||||
import org.apache.cloudstack.api.response.HostResponse;
|
||||
import org.apache.cloudstack.api.response.HypervisorCapabilitiesResponse;
|
||||
import org.apache.cloudstack.api.response.IPAddressResponse;
|
||||
import org.apache.cloudstack.api.response.ImageStoreResponse;
|
||||
import org.apache.cloudstack.api.response.InstanceGroupResponse;
|
||||
import org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse;
|
||||
import org.apache.cloudstack.api.response.IpForwardingRuleResponse;
|
||||
import org.apache.cloudstack.api.response.IsolationMethodResponse;
|
||||
import org.apache.cloudstack.api.response.LBHealthCheckPolicyResponse;
|
||||
import org.apache.cloudstack.api.response.LBHealthCheckResponse;
|
||||
import org.apache.cloudstack.api.response.LBStickinessPolicyResponse;
|
||||
import org.apache.cloudstack.api.response.LBStickinessResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.LoadBalancerResponse;
|
||||
import org.apache.cloudstack.api.response.ManagementServerResponse;
|
||||
import org.apache.cloudstack.api.response.NetworkACLItemResponse;
|
||||
import org.apache.cloudstack.api.response.NetworkACLResponse;
|
||||
import org.apache.cloudstack.api.response.NetworkOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.NetworkResponse;
|
||||
import org.apache.cloudstack.api.response.NicExtraDhcpOptionResponse;
|
||||
import org.apache.cloudstack.api.response.NicResponse;
|
||||
import org.apache.cloudstack.api.response.NicSecondaryIpResponse;
|
||||
import org.apache.cloudstack.api.response.OvsProviderResponse;
|
||||
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
|
||||
import org.apache.cloudstack.api.response.PodResponse;
|
||||
import org.apache.cloudstack.api.response.PortableIpRangeResponse;
|
||||
import org.apache.cloudstack.api.response.PortableIpResponse;
|
||||
import org.apache.cloudstack.api.response.PrivateGatewayResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectAccountResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectInvitationResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectResponse;
|
||||
import org.apache.cloudstack.api.response.ProviderResponse;
|
||||
import org.apache.cloudstack.api.response.RegionResponse;
|
||||
import org.apache.cloudstack.api.response.RemoteAccessVpnResponse;
|
||||
import org.apache.cloudstack.api.response.ResourceCountResponse;
|
||||
import org.apache.cloudstack.api.response.ResourceLimitResponse;
|
||||
import org.apache.cloudstack.api.response.ResourceTagResponse;
|
||||
import org.apache.cloudstack.api.response.SSHKeyPairResponse;
|
||||
import org.apache.cloudstack.api.response.SecurityGroupResponse;
|
||||
import org.apache.cloudstack.api.response.SecurityGroupRuleResponse;
|
||||
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.ServiceResponse;
|
||||
import org.apache.cloudstack.api.response.Site2SiteCustomerGatewayResponse;
|
||||
import org.apache.cloudstack.api.response.Site2SiteVpnConnectionResponse;
|
||||
import org.apache.cloudstack.api.response.Site2SiteVpnGatewayResponse;
|
||||
import org.apache.cloudstack.api.response.SnapshotPolicyResponse;
|
||||
import org.apache.cloudstack.api.response.SnapshotResponse;
|
||||
import org.apache.cloudstack.api.response.SnapshotScheduleResponse;
|
||||
import org.apache.cloudstack.api.response.StaticRouteResponse;
|
||||
import org.apache.cloudstack.api.response.StorageNetworkIpRangeResponse;
|
||||
import org.apache.cloudstack.api.response.StoragePoolResponse;
|
||||
import org.apache.cloudstack.api.response.SystemVmInstanceResponse;
|
||||
import org.apache.cloudstack.api.response.SystemVmResponse;
|
||||
import org.apache.cloudstack.api.response.TemplatePermissionsResponse;
|
||||
import org.apache.cloudstack.api.response.TemplateResponse;
|
||||
import org.apache.cloudstack.api.response.TrafficMonitorResponse;
|
||||
import org.apache.cloudstack.api.response.TrafficTypeResponse;
|
||||
import org.apache.cloudstack.api.response.UpgradeRouterTemplateResponse;
|
||||
import org.apache.cloudstack.api.response.UsageRecordResponse;
|
||||
import org.apache.cloudstack.api.response.UserResponse;
|
||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
import org.apache.cloudstack.api.response.VMSnapshotResponse;
|
||||
import org.apache.cloudstack.api.response.VirtualRouterProviderResponse;
|
||||
import org.apache.cloudstack.api.response.VlanIpRangeResponse;
|
||||
import org.apache.cloudstack.api.response.VolumeResponse;
|
||||
import org.apache.cloudstack.api.response.VpcOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.VpcResponse;
|
||||
import org.apache.cloudstack.api.response.VpnUsersResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.cloudstack.config.Configuration;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreCapabilities;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
|
||||
import org.apache.cloudstack.framework.jobs.AsyncJob;
|
||||
import org.apache.cloudstack.framework.jobs.AsyncJobManager;
|
||||
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
|
||||
import org.apache.cloudstack.region.PortableIp;
|
||||
import org.apache.cloudstack.region.PortableIpRange;
|
||||
import org.apache.cloudstack.region.Region;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||
import org.apache.cloudstack.usage.Usage;
|
||||
import org.apache.cloudstack.usage.UsageService;
|
||||
import org.apache.cloudstack.usage.UsageTypes;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ApiResponseHelper implements ResponseGenerator {
|
||||
|
||||
@ -1911,23 +1913,8 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
|
||||
@Override
|
||||
public NetworkOfferingResponse createNetworkOfferingResponse(NetworkOffering offering) {
|
||||
NetworkOfferingResponse response = new NetworkOfferingResponse();
|
||||
response.setId(offering.getUuid());
|
||||
response.setName(offering.getName());
|
||||
response.setDisplayText(offering.getDisplayText());
|
||||
response.setTags(offering.getTags());
|
||||
response.setTrafficType(offering.getTrafficType().toString());
|
||||
response.setIsDefault(offering.isDefault());
|
||||
response.setSpecifyVlan(offering.isSpecifyVlan());
|
||||
response.setConserveMode(offering.isConserveMode());
|
||||
response.setSpecifyIpRanges(offering.isSpecifyIpRanges());
|
||||
response.setAvailability(offering.getAvailability().toString());
|
||||
response.setIsPersistent(offering.isPersistent());
|
||||
NetworkOfferingResponse response = ApiDBUtils.newNetworkOfferingResponse(offering);
|
||||
response.setNetworkRate(ApiDBUtils.getNetworkRate(offering.getId()));
|
||||
response.setEgressDefaultPolicy(offering.isEgressDefaultPolicy());
|
||||
response.setConcurrentConnections(offering.getConcurrentConnections());
|
||||
response.setSupportsStrechedL2Subnet(offering.isSupportingStrechedL2());
|
||||
response.setSupportsPublicAccess(offering.isSupportingPublicAccess());
|
||||
Long so = null;
|
||||
if (offering.getServiceOfferingId() != null) {
|
||||
so = offering.getServiceOfferingId();
|
||||
@ -1940,13 +1927,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
response.setServiceOfferingId(soffering.getUuid());
|
||||
}
|
||||
}
|
||||
|
||||
if (offering.getGuestType() != null) {
|
||||
response.setGuestIpType(offering.getGuestType().toString());
|
||||
}
|
||||
|
||||
response.setState(offering.getState().name());
|
||||
|
||||
Map<Service, Set<Provider>> serviceProviderMap = ApiDBUtils.listNetworkOfferingServices(offering.getId());
|
||||
List<ServiceResponse> serviceResponses = new ArrayList<ServiceResponse>();
|
||||
for (Map.Entry<Service,Set<Provider>> entry : serviceProviderMap.entrySet()) {
|
||||
@ -1967,7 +1947,6 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
}
|
||||
}
|
||||
svcRsp.setProviders(providers);
|
||||
|
||||
if (Service.Lb == service) {
|
||||
List<CapabilityResponse> lbCapResponse = new ArrayList<CapabilityResponse>();
|
||||
|
||||
@ -2015,20 +1994,15 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
|
||||
svcRsp.setCapabilities(staticNatCapResponse);
|
||||
}
|
||||
|
||||
serviceResponses.add(svcRsp);
|
||||
}
|
||||
response.setForVpc(_configMgr.isOfferingForVpc(offering));
|
||||
|
||||
response.setServices(serviceResponses);
|
||||
|
||||
//set network offering details
|
||||
Map<Detail, String> details = _ntwkModel.getNtwkOffDetails(offering.getId());
|
||||
if (details != null && !details.isEmpty()) {
|
||||
response.setDetails(details);
|
||||
}
|
||||
|
||||
response.setObjectName("networkoffering");
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@ -2608,7 +2608,7 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
|
||||
*/
|
||||
|
||||
Pair<List<DiskOfferingJoinVO>, Integer> result = _diskOfferingJoinDao.searchAndCount(sc, searchFilter);
|
||||
// Remove offerings that are not associated with caller's domain and passed zone
|
||||
// Remove offerings that are not associated with caller's domain
|
||||
// TODO: Better approach
|
||||
if (account.getType() != Account.ACCOUNT_TYPE_ADMIN && CollectionUtils.isNotEmpty(result.first())) {
|
||||
ListIterator<DiskOfferingJoinVO> it = result.first().listIterator();
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package com.cloud.api.query.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.response.NetworkOfferingResponse;
|
||||
|
||||
import com.cloud.api.query.vo.NetworkOfferingJoinVO;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface NetworkOfferingJoinDao extends GenericDao<NetworkOfferingJoinVO, Long> {
|
||||
|
||||
List<NetworkOfferingJoinVO> findByDomainId(long domainId);
|
||||
|
||||
List<NetworkOfferingJoinVO> findByZoneId(long zoneId);
|
||||
|
||||
NetworkOfferingResponse newNetworkOfferingResponse(NetworkOffering nof);
|
||||
|
||||
NetworkOfferingJoinVO newNetworkOfferingView(NetworkOffering nof);
|
||||
}
|
||||
@ -0,0 +1,108 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package com.cloud.api.query.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.response.NetworkOfferingResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.query.vo.NetworkOfferingJoinVO;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
public class NetworkOfferingJoinDaoImpl extends GenericDaoBase<NetworkOfferingJoinVO, Long> implements NetworkOfferingJoinDao {
|
||||
public static final Logger s_logger = Logger.getLogger(NetworkOfferingJoinDaoImpl.class);
|
||||
|
||||
private final SearchBuilder<NetworkOfferingJoinVO> nofIdSearch;
|
||||
|
||||
protected NetworkOfferingJoinDaoImpl() {
|
||||
|
||||
nofIdSearch = createSearchBuilder();
|
||||
nofIdSearch.and("id", nofIdSearch.entity().getId(), SearchCriteria.Op.EQ);
|
||||
nofIdSearch.done();
|
||||
|
||||
_count = "select count(distinct id) from network_offering_view WHERE ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkOfferingJoinVO> findByDomainId(long domainId) {
|
||||
SearchBuilder<NetworkOfferingJoinVO> sb = createSearchBuilder();
|
||||
sb.and("domainId", sb.entity().getDomainId(), SearchCriteria.Op.FIND_IN_SET);
|
||||
sb.done();
|
||||
|
||||
SearchCriteria<NetworkOfferingJoinVO> sc = sb.create();
|
||||
sc.setParameters("domainId", String.valueOf(domainId));
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkOfferingJoinVO> findByZoneId(long zoneId) {
|
||||
SearchBuilder<NetworkOfferingJoinVO> sb = createSearchBuilder();
|
||||
sb.and("zoneId", sb.entity().getZoneId(), SearchCriteria.Op.FIND_IN_SET);
|
||||
sb.done();
|
||||
|
||||
SearchCriteria<NetworkOfferingJoinVO> sc = sb.create();
|
||||
sc.setParameters("zoneId", String.valueOf(zoneId));
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkOfferingResponse newNetworkOfferingResponse(NetworkOffering offering) {
|
||||
NetworkOfferingResponse networkOfferingResponse = new NetworkOfferingResponse();
|
||||
networkOfferingResponse.setId(offering.getUuid());
|
||||
networkOfferingResponse.setName(offering.getName());
|
||||
networkOfferingResponse.setDisplayText(offering.getDisplayText());
|
||||
networkOfferingResponse.setTags(offering.getTags());
|
||||
networkOfferingResponse.setTrafficType(offering.getTrafficType().toString());
|
||||
networkOfferingResponse.setIsDefault(offering.isDefault());
|
||||
networkOfferingResponse.setSpecifyVlan(offering.isSpecifyVlan());
|
||||
networkOfferingResponse.setConserveMode(offering.isConserveMode());
|
||||
networkOfferingResponse.setSpecifyIpRanges(offering.isSpecifyIpRanges());
|
||||
networkOfferingResponse.setAvailability(offering.getAvailability().toString());
|
||||
networkOfferingResponse.setIsPersistent(offering.isPersistent());
|
||||
networkOfferingResponse.setEgressDefaultPolicy(offering.isEgressDefaultPolicy());
|
||||
networkOfferingResponse.setConcurrentConnections(offering.getConcurrentConnections());
|
||||
networkOfferingResponse.setSupportsStrechedL2Subnet(offering.isSupportingStrechedL2());
|
||||
networkOfferingResponse.setSupportsPublicAccess(offering.isSupportingPublicAccess());
|
||||
if (offering.getGuestType() != null) {
|
||||
networkOfferingResponse.setGuestIpType(offering.getGuestType().toString());
|
||||
}
|
||||
networkOfferingResponse.setState(offering.getState().name());
|
||||
if (offering instanceof NetworkOfferingJoinVO) {
|
||||
networkOfferingResponse.setDomainId(((NetworkOfferingJoinVO) offering).getDomainUuid());
|
||||
networkOfferingResponse.setDomain(((NetworkOfferingJoinVO) offering).getDomainPath());
|
||||
networkOfferingResponse.setZoneId(((NetworkOfferingJoinVO) offering).getZoneUuid());
|
||||
networkOfferingResponse.setZone(((NetworkOfferingJoinVO) offering).getZoneName());
|
||||
}
|
||||
networkOfferingResponse.setObjectName("networkoffering");
|
||||
|
||||
return networkOfferingResponse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkOfferingJoinVO newNetworkOfferingView(NetworkOffering offering) {
|
||||
SearchCriteria<NetworkOfferingJoinVO> sc = nofIdSearch.create();
|
||||
sc.setParameters("id", offering.getId());
|
||||
List<NetworkOfferingJoinVO> offerings = searchIncludingRemoved(sc, null, null, false);
|
||||
assert offerings != null && offerings.size() == 1 : "No network offering found for offering id " + offering.getId();
|
||||
return offerings.get(0);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,396 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package com.cloud.api.query.vo;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Networks;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
@Entity
|
||||
@Table(name = "network_offering_view")
|
||||
public class NetworkOfferingJoinVO extends BaseViewVO implements NetworkOffering {
|
||||
|
||||
@Id
|
||||
@Column(name = "id", updatable = false, nullable = false)
|
||||
private long id;
|
||||
|
||||
@Column(name = "uuid")
|
||||
private String uuid;
|
||||
|
||||
@Column(name = "name")
|
||||
private String name;
|
||||
|
||||
@Column(name = "unique_name")
|
||||
private String uniqueName;
|
||||
|
||||
@Column(name = "display_text")
|
||||
private String displayText;
|
||||
|
||||
@Column(name = "nw_rate")
|
||||
private Integer rateMbps;
|
||||
|
||||
@Column(name = "mc_rate")
|
||||
private Integer multicastRateMbps;
|
||||
|
||||
@Column(name = "traffic_type")
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
private Networks.TrafficType trafficType;
|
||||
|
||||
@Column(name = "tags", length = 4096)
|
||||
private String tags;
|
||||
|
||||
@Column(name = "system_only")
|
||||
private boolean systemOnly;
|
||||
|
||||
@Column(name = "specify_vlan")
|
||||
private boolean specifyVlan;
|
||||
|
||||
@Column(name = "service_offering_id")
|
||||
private Long serviceOfferingId;
|
||||
|
||||
@Column(name = "conserve_mode")
|
||||
private boolean conserveMode;
|
||||
|
||||
@Column(name = GenericDao.REMOVED_COLUMN)
|
||||
private Date removed;
|
||||
|
||||
@Column(name = GenericDao.CREATED_COLUMN)
|
||||
private Date created;
|
||||
|
||||
@Column(name = "default")
|
||||
private boolean isDefault;
|
||||
|
||||
@Column(name = "availability")
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
NetworkOffering.Availability availability;
|
||||
|
||||
@Column(name = "dedicated_lb_service")
|
||||
private boolean dedicatedLB;
|
||||
|
||||
@Column(name = "shared_source_nat_service")
|
||||
private boolean sharedSourceNat;
|
||||
|
||||
@Column(name = "sort_key")
|
||||
private int sortKey;
|
||||
|
||||
@Column(name = "redundant_router_service")
|
||||
private boolean redundantRouter;
|
||||
|
||||
@Column(name = "state")
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
private NetworkOffering.State state = NetworkOffering.State.Disabled;
|
||||
|
||||
@Column(name = "guest_type")
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
private Network.GuestType guestType;
|
||||
|
||||
@Column(name = "elastic_ip_service")
|
||||
private boolean elasticIp;
|
||||
|
||||
@Column(name = "eip_associate_public_ip")
|
||||
private boolean eipAssociatePublicIp;
|
||||
|
||||
@Column(name = "elastic_lb_service")
|
||||
private boolean elasticLb;
|
||||
|
||||
@Column(name = "specify_ip_ranges")
|
||||
private boolean specifyIpRanges = false;
|
||||
|
||||
@Column(name = "inline")
|
||||
private boolean inline;
|
||||
|
||||
@Column(name = "is_persistent")
|
||||
private boolean persistent;
|
||||
|
||||
@Column(name = "internal_lb")
|
||||
private boolean internalLb;
|
||||
|
||||
@Column(name = "public_lb")
|
||||
private boolean publicLb;
|
||||
|
||||
@Column(name = "egress_default_policy")
|
||||
private boolean egressdefaultpolicy;
|
||||
|
||||
@Column(name = "concurrent_connections")
|
||||
private Integer concurrentConnections;
|
||||
|
||||
@Column(name = "keep_alive_enabled")
|
||||
private boolean keepAliveEnabled = false;
|
||||
|
||||
@Column(name = "supports_streched_l2")
|
||||
private boolean supportsStrechedL2 = false;
|
||||
|
||||
@Column(name = "supports_public_access")
|
||||
private boolean supportsPublicAccess = false;
|
||||
|
||||
@Column(name = "for_vpc")
|
||||
private boolean forVpc;
|
||||
|
||||
@Column(name = "service_package_id")
|
||||
private String servicePackageUuid = null;
|
||||
|
||||
@Column(name = "domain_id")
|
||||
private String domainId = null;
|
||||
|
||||
@Column(name = "domain_uuid")
|
||||
private String domainUuid = null;
|
||||
|
||||
@Column(name = "domain_name")
|
||||
private String domainName = null;
|
||||
|
||||
@Column(name = "domain_path")
|
||||
private String domainPath = null;
|
||||
|
||||
@Column(name = "zone_id")
|
||||
private String zoneId = null;
|
||||
|
||||
@Column(name = "zone_uuid")
|
||||
private String zoneUuid = null;
|
||||
|
||||
@Column(name = "zone_name")
|
||||
private String zoneName = null;
|
||||
|
||||
public NetworkOfferingJoinVO() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getUniqueName() {
|
||||
return uniqueName;
|
||||
}
|
||||
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
public Integer getRateMbps() {
|
||||
return rateMbps;
|
||||
}
|
||||
|
||||
public Integer getMulticastRateMbps() {
|
||||
return multicastRateMbps;
|
||||
}
|
||||
|
||||
public Networks.TrafficType getTrafficType() {
|
||||
return trafficType;
|
||||
}
|
||||
|
||||
public String getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public boolean isSystemOnly() {
|
||||
return systemOnly;
|
||||
}
|
||||
|
||||
public boolean isSpecifyVlan() {
|
||||
return specifyVlan;
|
||||
}
|
||||
|
||||
public Long getServiceOfferingId() {
|
||||
return serviceOfferingId;
|
||||
}
|
||||
|
||||
public boolean isConserveMode() {
|
||||
return conserveMode;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public Date getRemoved() {
|
||||
return removed;
|
||||
}
|
||||
|
||||
public boolean isDefault() {
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
public NetworkOffering.Availability getAvailability() {
|
||||
return availability;
|
||||
}
|
||||
|
||||
public boolean isDedicatedLB() {
|
||||
return dedicatedLB;
|
||||
}
|
||||
|
||||
public boolean isSharedSourceNat() {
|
||||
return sharedSourceNat;
|
||||
}
|
||||
|
||||
public int getSortKey() {
|
||||
return sortKey;
|
||||
}
|
||||
|
||||
public boolean isRedundantRouter() {
|
||||
return redundantRouter;
|
||||
}
|
||||
|
||||
public NetworkOffering.State getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setState(State state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public Network.GuestType getGuestType() {
|
||||
return guestType;
|
||||
}
|
||||
|
||||
public boolean isElasticIp() {
|
||||
return elasticIp;
|
||||
}
|
||||
|
||||
public boolean isAssociatePublicIP() {
|
||||
return eipAssociatePublicIp;
|
||||
}
|
||||
|
||||
public boolean isElasticLb() {
|
||||
return elasticLb;
|
||||
}
|
||||
|
||||
public boolean isSpecifyIpRanges() {
|
||||
return specifyIpRanges;
|
||||
}
|
||||
|
||||
public boolean isInline() {
|
||||
return inline;
|
||||
}
|
||||
|
||||
public boolean isPersistent() {
|
||||
return persistent;
|
||||
}
|
||||
|
||||
public boolean isInternalLb() {
|
||||
return internalLb;
|
||||
}
|
||||
|
||||
public boolean isPublicLb() {
|
||||
return publicLb;
|
||||
}
|
||||
|
||||
public boolean isEgressDefaultPolicy() {
|
||||
return egressdefaultpolicy;
|
||||
}
|
||||
|
||||
public Integer getConcurrentConnections() {
|
||||
return this.concurrentConnections;
|
||||
}
|
||||
|
||||
public boolean isKeepAliveEnabled() {
|
||||
return keepAliveEnabled;
|
||||
}
|
||||
|
||||
public boolean isSupportingStrechedL2() {
|
||||
return supportsStrechedL2;
|
||||
}
|
||||
|
||||
public boolean isSupportingPublicAccess() {
|
||||
return supportsPublicAccess;
|
||||
}
|
||||
|
||||
public boolean isForVpc() {
|
||||
return forVpc;
|
||||
}
|
||||
|
||||
public String getServicePackage() {
|
||||
return servicePackageUuid;
|
||||
}
|
||||
|
||||
public String getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public void setDomainId(String domainId) {
|
||||
this.domainId = domainId;
|
||||
}
|
||||
|
||||
public String getDomainUuid() {
|
||||
return domainUuid;
|
||||
}
|
||||
|
||||
public void setDomainUuid(String domainUuid) {
|
||||
this.domainUuid = domainUuid;
|
||||
}
|
||||
|
||||
public String getDomainName() {
|
||||
return domainName;
|
||||
}
|
||||
|
||||
public void setDomainName(String domainName) {
|
||||
this.domainName = domainName;
|
||||
}
|
||||
|
||||
public String getDomainPath() {
|
||||
return domainPath;
|
||||
}
|
||||
|
||||
public void setDomainPath(String domainPath) {
|
||||
this.domainPath = domainPath;
|
||||
}
|
||||
|
||||
public String getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public void setZoneId(String zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
public String getZoneUuid() {
|
||||
return zoneUuid;
|
||||
}
|
||||
|
||||
public void setZoneUuid(String zoneUuid) {
|
||||
this.zoneUuid = zoneUuid;
|
||||
}
|
||||
|
||||
public String getZoneName() {
|
||||
return zoneName;
|
||||
}
|
||||
|
||||
public void setZoneName(String zoneName) {
|
||||
this.zoneName = zoneName;
|
||||
}
|
||||
|
||||
}
|
||||
@ -27,6 +27,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
@ -100,6 +101,8 @@ import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.alert.AlertManager;
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.api.query.dao.NetworkOfferingJoinDao;
|
||||
import com.cloud.api.query.vo.NetworkOfferingJoinVO;
|
||||
import com.cloud.capacity.CapacityManager;
|
||||
import com.cloud.capacity.dao.CapacityDao;
|
||||
import com.cloud.configuration.Resource.ResourceType;
|
||||
@ -177,9 +180,11 @@ import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.Availability;
|
||||
import com.cloud.offering.NetworkOffering.Detail;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.offerings.NetworkOfferingDetailsVO;
|
||||
import com.cloud.offerings.NetworkOfferingServiceMapVO;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDetailsDao;
|
||||
import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
|
||||
import com.cloud.org.Grouping;
|
||||
import com.cloud.org.Grouping.AllocationState;
|
||||
@ -215,6 +220,7 @@ import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.EntityManager;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.GlobalLock;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionCallback;
|
||||
@ -273,6 +279,10 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
@Inject
|
||||
NetworkOfferingDao _networkOfferingDao;
|
||||
@Inject
|
||||
NetworkOfferingJoinDao networkOfferingJoinDao;
|
||||
@Inject
|
||||
NetworkOfferingDetailsDao networkOfferingDetailsDao;
|
||||
@Inject
|
||||
VlanDao _vlanDao;
|
||||
@Inject
|
||||
IPAddressDao _publicIpAddressDao;
|
||||
@ -4466,10 +4476,29 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
final Map<String, String> detailsStr = cmd.getDetails();
|
||||
final Boolean egressDefaultPolicy = cmd.getEgressDefaultPolicy();
|
||||
Boolean forVpc = cmd.getForVpc();
|
||||
|
||||
Integer maxconn = null;
|
||||
boolean enableKeepAlive = false;
|
||||
String servicePackageuuid = cmd.getServicePackageId();
|
||||
final List<Long> domainIds = cmd.getDomainIds();
|
||||
final List<Long> zoneIds = cmd.getZoneIds();
|
||||
|
||||
// check if valid domain
|
||||
if (CollectionUtils.isNotEmpty(domainIds)) {
|
||||
for (final Long domainId: domainIds) {
|
||||
if (_domainDao.findById(domainId) == null) {
|
||||
throw new InvalidParameterValueException("Please specify a valid domain id");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check if valid zone
|
||||
if (CollectionUtils.isNotEmpty(zoneIds)) {
|
||||
for (Long zoneId : zoneIds) {
|
||||
if (_zoneDao.findById(zoneId) == null)
|
||||
throw new InvalidParameterValueException("Please specify a valid zone id");
|
||||
}
|
||||
}
|
||||
|
||||
// Verify traffic type
|
||||
for (final TrafficType tType : TrafficType.values()) {
|
||||
if (tType.name().equalsIgnoreCase(trafficTypeString)) {
|
||||
@ -4726,7 +4755,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
}
|
||||
|
||||
final NetworkOffering offering = createNetworkOffering(name, displayText, trafficType, tags, specifyVlan, availability, networkRate, serviceProviderMap, false, guestType, false,
|
||||
serviceOfferingId, conserveMode, serviceCapabilityMap, specifyIpRanges, isPersistent, details, egressDefaultPolicy, maxconn, enableKeepAlive, forVpc);
|
||||
serviceOfferingId, conserveMode, serviceCapabilityMap, specifyIpRanges, isPersistent, details, egressDefaultPolicy, maxconn, enableKeepAlive, forVpc, domainIds, zoneIds);
|
||||
CallContext.current().setEventDetails(" Id: " + offering.getId() + " Name: " + name);
|
||||
return offering;
|
||||
}
|
||||
@ -4863,7 +4892,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
final Integer networkRate, final Map<Service, Set<Provider>> serviceProviderMap, final boolean isDefault, final GuestType type, final boolean systemOnly,
|
||||
final Long serviceOfferingId,
|
||||
final boolean conserveMode, final Map<Service, Map<Capability, String>> serviceCapabilityMap, final boolean specifyIpRanges, final boolean isPersistent,
|
||||
final Map<Detail, String> details, final boolean egressDefaultPolicy, final Integer maxconn, final boolean enableKeepAlive, Boolean forVpc) {
|
||||
final Map<Detail, String> details, final boolean egressDefaultPolicy, final Integer maxconn, final boolean enableKeepAlive, Boolean forVpc,
|
||||
final List<Long> domainIds, final List<Long> zoneIds) {
|
||||
|
||||
String servicePackageUuid;
|
||||
String spDescription = null;
|
||||
@ -5100,6 +5130,22 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
s_logger.trace("Added service for the network offering: " + offService + " with null provider");
|
||||
}
|
||||
}
|
||||
if (offering != null) {
|
||||
// Filter child domains when both parent and child domains are present
|
||||
List<Long> filteredDomainIds = filterChildSubDomains(domainIds);
|
||||
List<NetworkOfferingDetailsVO> detailsVO = new ArrayList<>();
|
||||
for (Long domainId : filteredDomainIds) {
|
||||
detailsVO.add(new NetworkOfferingDetailsVO(offering.getId(), Detail.domainid, String.valueOf(domainId)));
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(zoneIds)) {
|
||||
for (Long zoneId : zoneIds) {
|
||||
detailsVO.add(new NetworkOfferingDetailsVO(offering.getId(), Detail.zoneid, String.valueOf(zoneId)));
|
||||
}
|
||||
}
|
||||
if (!detailsVO.isEmpty()) {
|
||||
networkOfferingDetailsDao.saveDetails(detailsVO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return offering;
|
||||
@ -5148,9 +5194,9 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
public Pair<List<? extends NetworkOffering>, Integer> searchForNetworkOfferings(final ListNetworkOfferingsCmd cmd) {
|
||||
Boolean isAscending = Boolean.parseBoolean(_configDao.getValue("sortkey.algorithm"));
|
||||
isAscending = isAscending == null ? Boolean.TRUE : isAscending;
|
||||
final Filter searchFilter = new Filter(NetworkOfferingVO.class, "sortKey", isAscending, null, null);
|
||||
final Filter searchFilter = new Filter(NetworkOfferingJoinVO.class, "sortKey", isAscending, null, null);
|
||||
final Account caller = CallContext.current().getCallingAccount();
|
||||
final SearchCriteria<NetworkOfferingVO> sc = _networkOfferingDao.createSearchCriteria();
|
||||
final SearchCriteria<NetworkOfferingJoinVO> sc = networkOfferingJoinDao.createSearchCriteria();
|
||||
|
||||
final Long id = cmd.getId();
|
||||
final Object name = cmd.getNetworkOfferingName();
|
||||
@ -5277,7 +5323,39 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
}
|
||||
}
|
||||
|
||||
final List<NetworkOfferingVO> offerings = _networkOfferingDao.search(sc, searchFilter);
|
||||
if (zoneId != null) {
|
||||
SearchBuilder<NetworkOfferingJoinVO> sb = networkOfferingJoinDao.createSearchBuilder();
|
||||
sb.and("zoneId", sb.entity().getZoneId(), SearchCriteria.Op.FIND_IN_SET);
|
||||
sb.or("zId", sb.entity().getZoneId(), SearchCriteria.Op.NULL);
|
||||
sb.done();
|
||||
SearchCriteria<NetworkOfferingJoinVO> zoneSC = sb.create();
|
||||
zoneSC.setParameters("zoneId", String.valueOf(zoneId));
|
||||
sc.addAnd("zoneId", SearchCriteria.Op.SC, zoneSC);
|
||||
}
|
||||
|
||||
final List<NetworkOfferingJoinVO> offerings = networkOfferingJoinDao.search(sc, searchFilter);
|
||||
// Remove offerings that are not associated with caller's domain
|
||||
// TODO: Better approach
|
||||
if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN && CollectionUtils.isNotEmpty(offerings)) {
|
||||
ListIterator<NetworkOfferingJoinVO> it = offerings.listIterator();
|
||||
while (it.hasNext()) {
|
||||
NetworkOfferingJoinVO offering = it.next();
|
||||
if(!Strings.isNullOrEmpty(offering.getDomainId())) {
|
||||
boolean toRemove = true;
|
||||
String[] domainIdsArray = offering.getDomainId().split(",");
|
||||
for (String domainIdString : domainIdsArray) {
|
||||
Long dId = Long.valueOf(domainIdString.trim());
|
||||
if (_domainDao.isChildDomain(caller.getDomainId(), dId)) {
|
||||
toRemove = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (toRemove) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final Boolean sourceNatSupported = cmd.getSourceNatSupported();
|
||||
final List<String> pNtwkTags = new ArrayList<String>();
|
||||
boolean checkForTags = false;
|
||||
@ -5302,7 +5380,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
final boolean parseOfferings = listBySupportedServices || sourceNatSupported != null || checkIfProvidersAreEnabled || forVpc != null || network != null;
|
||||
|
||||
if (parseOfferings) {
|
||||
final List<NetworkOfferingVO> supportedOfferings = new ArrayList<NetworkOfferingVO>();
|
||||
final List<NetworkOfferingJoinVO> supportedOfferings = new ArrayList<>();
|
||||
Service[] supportedServices = null;
|
||||
|
||||
if (listBySupportedServices) {
|
||||
@ -5319,7 +5397,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
}
|
||||
}
|
||||
|
||||
for (final NetworkOfferingVO offering : offerings) {
|
||||
for (final NetworkOfferingJoinVO offering : offerings) {
|
||||
boolean addOffering = true;
|
||||
List<Service> checkForProviders = new ArrayList<Service>();
|
||||
|
||||
@ -5348,9 +5426,9 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
}
|
||||
|
||||
if (forVpc != null) {
|
||||
addOffering = addOffering && isOfferingForVpc(offering) == forVpc.booleanValue();
|
||||
addOffering = addOffering && offering.isForVpc() == forVpc.booleanValue();
|
||||
} else if (network != null) {
|
||||
addOffering = addOffering && isOfferingForVpc(offering) == (network.getVpcId() != null);
|
||||
addOffering = addOffering && offering.isForVpc() == (network.getVpcId() != null);
|
||||
}
|
||||
|
||||
if (addOffering) {
|
||||
@ -5360,16 +5438,16 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
}
|
||||
|
||||
// Now apply pagination
|
||||
final List<? extends NetworkOffering> wPagination = StringUtils.applyPagination(supportedOfferings, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
final List<NetworkOfferingJoinVO> wPagination = StringUtils.applyPagination(supportedOfferings, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
if (wPagination != null) {
|
||||
final Pair<List<? extends NetworkOffering>, Integer> listWPagination = new Pair<List<? extends NetworkOffering>, Integer>(wPagination, supportedOfferings.size());
|
||||
return listWPagination;
|
||||
}
|
||||
return new Pair<List<? extends NetworkOffering>, Integer>(supportedOfferings, supportedOfferings.size());
|
||||
} else {
|
||||
final List<? extends NetworkOffering> wPagination = StringUtils.applyPagination(offerings, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
final List<NetworkOfferingJoinVO> wPagination = StringUtils.applyPagination(offerings, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
if (wPagination != null) {
|
||||
final Pair<List<? extends NetworkOffering>, Integer> listWPagination = new Pair<List<? extends NetworkOffering>, Integer>(wPagination, offerings.size());
|
||||
final Pair<List<? extends NetworkOffering>, Integer> listWPagination = new Pair<>(wPagination, offerings.size());
|
||||
return listWPagination;
|
||||
}
|
||||
return new Pair<List<? extends NetworkOffering>, Integer>(offerings, offerings.size());
|
||||
|
||||
@ -448,9 +448,9 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu
|
||||
*/
|
||||
@Override
|
||||
public NetworkOfferingVO createNetworkOffering(String name, String displayText, TrafficType trafficType, String tags, boolean specifyVlan, Availability availability,
|
||||
Integer networkRate, Map<Service, Set<Provider>> serviceProviderMap, boolean isDefault, GuestType type, boolean systemOnly, Long serviceOfferingId,
|
||||
boolean conserveMode, Map<Service, Map<Capability, String>> serviceCapabilityMap, boolean specifyIpRanges, boolean isPersistent,
|
||||
Map<NetworkOffering.Detail, String> details, boolean egressDefaultPolicy, Integer maxconn, boolean enableKeepAlive, Boolean forVpc) {
|
||||
Integer networkRate, Map<Service, Set<Provider>> serviceProviderMap, boolean isDefault, GuestType type, boolean systemOnly, Long serviceOfferingId,
|
||||
boolean conserveMode, Map<Service, Map<Capability, String>> serviceCapabilityMap, boolean specifyIpRanges, boolean isPersistent,
|
||||
Map<NetworkOffering.Detail, String> details, boolean egressDefaultPolicy, Integer maxconn, boolean enableKeepAlive, Boolean forVpc, List<Long> domainIds, List<Long> zoneIds) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ public class CreateNetworkOfferingTest extends TestCase {
|
||||
public void createSharedNtwkOffWithVlan() {
|
||||
NetworkOfferingVO off =
|
||||
configMgr.createNetworkOffering("shared", "shared", TrafficType.Guest, null, true, Availability.Optional, 200, null, false, Network.GuestType.Shared, false,
|
||||
null, false, null, true, false, null, false, null, true, false);
|
||||
null, false, null, true, false, null, false, null, true, false, null, null);
|
||||
assertNotNull("Shared network offering with specifyVlan=true failed to create ", off);
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ public class CreateNetworkOfferingTest extends TestCase {
|
||||
public void createSharedNtwkOffWithNoVlan() {
|
||||
NetworkOfferingVO off =
|
||||
configMgr.createNetworkOffering("shared", "shared", TrafficType.Guest, null, false, Availability.Optional, 200, null, false, Network.GuestType.Shared,
|
||||
false, null, false, null, true, false, null, false, null, true, false);
|
||||
false, null, false, null, true, false, null, false, null, true, false, null, null);
|
||||
assertNull("Shared network offering with specifyVlan=false was created", off);
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ public class CreateNetworkOfferingTest extends TestCase {
|
||||
public void createSharedNtwkOffWithSpecifyIpRanges() {
|
||||
NetworkOfferingVO off =
|
||||
configMgr.createNetworkOffering("shared", "shared", TrafficType.Guest, null, true, Availability.Optional, 200, null, false, Network.GuestType.Shared, false,
|
||||
null, false, null, true, false, null, false, null, true, false);
|
||||
null, false, null, true, false, null, false, null, true, false, null, null);
|
||||
|
||||
assertNotNull("Shared network offering with specifyIpRanges=true failed to create ", off);
|
||||
}
|
||||
@ -150,7 +150,7 @@ public class CreateNetworkOfferingTest extends TestCase {
|
||||
public void createSharedNtwkOffWithoutSpecifyIpRanges() {
|
||||
NetworkOfferingVO off =
|
||||
configMgr.createNetworkOffering("shared", "shared", TrafficType.Guest, null, true, Availability.Optional, 200, null, false, Network.GuestType.Shared,
|
||||
false, null, false, null, false, false, null, false, null, true, false);
|
||||
false, null, false, null, false, false, null, false, null, true, false, null, null);
|
||||
assertNull("Shared network offering with specifyIpRanges=false was created", off);
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ public class CreateNetworkOfferingTest extends TestCase {
|
||||
serviceProviderMap.put(Network.Service.SourceNat, vrProvider);
|
||||
NetworkOfferingVO off =
|
||||
configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, false, Availability.Optional, 200, serviceProviderMap, false,
|
||||
Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, false);
|
||||
Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, false, null, null);
|
||||
|
||||
assertNotNull("Isolated network offering with specifyIpRanges=false failed to create ", off);
|
||||
}
|
||||
@ -176,7 +176,7 @@ public class CreateNetworkOfferingTest extends TestCase {
|
||||
serviceProviderMap.put(Network.Service.SourceNat, vrProvider);
|
||||
NetworkOfferingVO off =
|
||||
configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, true, Availability.Optional, 200, serviceProviderMap, false,
|
||||
Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, false);
|
||||
Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, false, null, null);
|
||||
assertNotNull("Isolated network offering with specifyVlan=true wasn't created", off);
|
||||
|
||||
}
|
||||
@ -189,7 +189,7 @@ public class CreateNetworkOfferingTest extends TestCase {
|
||||
serviceProviderMap.put(Network.Service.SourceNat, vrProvider);
|
||||
NetworkOfferingVO off =
|
||||
configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, false, Availability.Optional, 200, serviceProviderMap, false,
|
||||
Network.GuestType.Isolated, false, null, false, null, true, false, null, false, null, true, false);
|
||||
Network.GuestType.Isolated, false, null, false, null, true, false, null, false, null, true, false, null, null);
|
||||
assertNull("Isolated network offering with specifyIpRanges=true and source nat service enabled, was created", off);
|
||||
}
|
||||
|
||||
@ -200,7 +200,7 @@ public class CreateNetworkOfferingTest extends TestCase {
|
||||
Set<Network.Provider> vrProvider = new HashSet<Network.Provider>();
|
||||
NetworkOfferingVO off =
|
||||
configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, false, Availability.Optional, 200, serviceProviderMap, false,
|
||||
Network.GuestType.Isolated, false, null, false, null, true, false, null, false, null, true, false);
|
||||
Network.GuestType.Isolated, false, null, false, null, true, false, null, false, null, true, false, null, null);
|
||||
assertNotNull("Isolated network offering with specifyIpRanges=true and with no sourceNatService, failed to create", off);
|
||||
|
||||
}
|
||||
@ -218,7 +218,7 @@ public class CreateNetworkOfferingTest extends TestCase {
|
||||
serviceProviderMap.put(Network.Service.Lb, vrProvider);
|
||||
NetworkOfferingVO off =
|
||||
configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, true, Availability.Optional, 200, serviceProviderMap, false,
|
||||
Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, true);
|
||||
Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, true, null, null);
|
||||
// System.out.println("Creating Vpc Network Offering");
|
||||
assertNotNull("Vpc Isolated network offering with Vpc provider ", off);
|
||||
}
|
||||
@ -238,7 +238,7 @@ public class CreateNetworkOfferingTest extends TestCase {
|
||||
serviceProviderMap.put(Network.Service.Lb, lbProvider);
|
||||
NetworkOfferingVO off =
|
||||
configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, true, Availability.Optional, 200, serviceProviderMap, false,
|
||||
Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, true);
|
||||
Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, true, null, null);
|
||||
// System.out.println("Creating Vpc Network Offering");
|
||||
assertNotNull("Vpc Isolated network offering with Vpc and Netscaler provider ", off);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user