mirror of https://github.com/apache/cloudstack.git
Changes to create ServiceOffering with deployment_planner
This commit is contained in:
parent
70405bd2b4
commit
ec7ea15cb6
|
|
@ -18,6 +18,8 @@ package org.apache.cloudstack.api.response;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
import org.apache.cloudstack.api.EntityReference;
|
||||
|
|
@ -82,6 +84,8 @@ public class ServiceOfferingResponse extends BaseResponse {
|
|||
@SerializedName(ApiConstants.NETWORKRATE) @Param(description="data transfer rate in megabits per second allowed.")
|
||||
private Integer networkRate;
|
||||
|
||||
@SerializedName(ApiConstants.DEPLOYMENT_PLANNER) @Param(description="deployment strategy used to deploy VM.")
|
||||
private String deploymentPlanner;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
|
|
@ -225,4 +229,12 @@ public class ServiceOfferingResponse extends BaseResponse {
|
|||
public void setNetworkRate(Integer networkRate) {
|
||||
this.networkRate = networkRate;
|
||||
}
|
||||
|
||||
public String getDeploymentPlanner() {
|
||||
return deploymentPlanner;
|
||||
}
|
||||
|
||||
public void setDeploymentPlanner(String deploymentPlanner) {
|
||||
this.deploymentPlanner = deploymentPlanner;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,6 +209,7 @@ listConfigurations=1
|
|||
ldapConfig=1
|
||||
ldapRemove=1
|
||||
listCapabilities=15
|
||||
listDeploymentPlanners=1
|
||||
|
||||
#### pod commands
|
||||
createPod=1
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ public class ServiceOfferingJoinDaoImpl extends GenericDaoBase<ServiceOfferingJo
|
|||
offeringResponse.setDomainId(offering.getDomainUuid());
|
||||
offeringResponse.setNetworkRate(offering.getRateMbps());
|
||||
offeringResponse.setHostTag(offering.getHostTag());
|
||||
offeringResponse.setDeploymentPlanner(offering.getDeploymentPlanner());
|
||||
offeringResponse.setObjectName("serviceoffering");
|
||||
|
||||
return offeringResponse;
|
||||
|
|
|
|||
|
|
@ -106,6 +106,9 @@ public class ServiceOfferingJoinVO extends BaseViewVO implements InternalIdentit
|
|||
@Column(name="domain_path")
|
||||
private String domainPath = null;
|
||||
|
||||
@Column(name = "deployment_planner")
|
||||
private String deploymentPlanner;
|
||||
|
||||
|
||||
public ServiceOfferingJoinVO() {
|
||||
}
|
||||
|
|
@ -307,5 +310,13 @@ public class ServiceOfferingJoinVO extends BaseViewVO implements InternalIdentit
|
|||
this.vm_type = vm_type;
|
||||
}
|
||||
|
||||
public String getDeploymentPlanner() {
|
||||
return deploymentPlanner;
|
||||
}
|
||||
|
||||
public void setDeploymentPlanner(String deploymentPlanner) {
|
||||
this.deploymentPlanner = deploymentPlanner;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
// 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,
|
||||
|
|
@ -129,6 +129,7 @@ import com.cloud.org.Grouping.AllocationState;
|
|||
import com.cloud.projects.Project;
|
||||
import com.cloud.projects.ProjectManager;
|
||||
import com.cloud.server.ConfigurationServer;
|
||||
import com.cloud.server.ManagementService;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
|
|
@ -206,7 +207,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
@Inject
|
||||
AlertManager _alertMgr;
|
||||
// @com.cloud.utils.component.Inject(adapter = SecurityChecker.class)
|
||||
@Inject
|
||||
@Inject
|
||||
List<SecurityChecker> _secChecker;
|
||||
|
||||
@Inject
|
||||
|
|
@ -246,6 +247,9 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
@Inject
|
||||
PrimaryDataStoreDao _storagePoolDao;
|
||||
|
||||
@Inject
|
||||
public ManagementService _mgr;
|
||||
|
||||
// FIXME - why don't we have interface for DataCenterLinkLocalIpAddressDao?
|
||||
@Inject protected DataCenterLinkLocalIpAddressDao _LinkLocalIpAllocDao;
|
||||
|
||||
|
|
@ -256,11 +260,11 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
@Override
|
||||
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
|
||||
String maxVolumeSizeInGbString = _configDao.getValue(Config.MaxVolumeSize.key());
|
||||
_maxVolumeSizeInGb = NumbersUtil.parseInt(maxVolumeSizeInGbString,
|
||||
_maxVolumeSizeInGb = NumbersUtil.parseInt(maxVolumeSizeInGbString,
|
||||
Integer.parseInt(Config.MaxVolumeSize.getDefaultValue()));
|
||||
|
||||
String defaultPageSizeString = _configDao.getValue(Config.DefaultPageSize.key());
|
||||
_defaultPageSize = NumbersUtil.parseLong(defaultPageSizeString,
|
||||
_defaultPageSize = NumbersUtil.parseLong(defaultPageSizeString,
|
||||
Long.parseLong(Config.DefaultPageSize.getDefaultValue()));
|
||||
|
||||
populateConfigValuesForValidationSet();
|
||||
|
|
@ -820,7 +824,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
checkPodCidrSubnets(zoneId, podId, cidr);
|
||||
/*
|
||||
* Commenting out due to Bug 11593 - CIDR conflicts with zone when extending pod but not when creating it
|
||||
*
|
||||
*
|
||||
* checkCidrVlanOverlap(zoneId, cidr);
|
||||
*/
|
||||
}
|
||||
|
|
@ -1613,7 +1617,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
if (internalDns2 == null) {
|
||||
internalDns2 = zone.getInternalDns2();
|
||||
}
|
||||
|
||||
|
||||
if (guestCidr == null) {
|
||||
guestCidr = zone.getGuestNetworkCidr();
|
||||
}
|
||||
|
|
@ -1798,7 +1802,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
|
||||
userNetwork.setBroadcastDomainType(broadcastDomainType);
|
||||
userNetwork.setNetworkDomain(networkDomain);
|
||||
_networkMgr.setupNetwork(systemAccount, offering, userNetwork, plan, null, null, false,
|
||||
_networkMgr.setupNetwork(systemAccount, offering, userNetwork, plan, null, null, false,
|
||||
Domain.ROOT_DOMAIN, null, null, null);
|
||||
}
|
||||
}
|
||||
|
|
@ -1932,6 +1936,18 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
throw new InvalidParameterValueException("Network rate can be specified only for non-System offering and system offerings having \"domainrouter\" systemvmtype");
|
||||
}
|
||||
|
||||
if (cmd.getDeploymentPlanner() != null) {
|
||||
List<String> planners = _mgr.listDeploymentPlanners();
|
||||
if (planners != null && !planners.isEmpty()) {
|
||||
if (!planners.contains(cmd.getDeploymentPlanner())) {
|
||||
throw new InvalidParameterValueException(
|
||||
"Invalid name for Deployment Planner specified, please use listDeploymentPlanners to get the valid set");
|
||||
}
|
||||
} else {
|
||||
throw new InvalidParameterValueException("No deployment planners found");
|
||||
}
|
||||
}
|
||||
|
||||
return createServiceOffering(userId, cmd.getIsSystem(), vmType, cmd.getServiceOfferingName(), cpuNumber.intValue(), memory.intValue(), cpuSpeed.intValue(), cmd.getDisplayText(),
|
||||
localStorageRequired, offerHA, limitCpuUse, volatileVm, cmd.getTags(), cmd.getDomainId(), cmd.getHostTag(), cmd.getNetworkRate());
|
||||
}
|
||||
|
|
@ -2224,9 +2240,9 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
String endIPv6 = cmd.getEndIpv6();
|
||||
String ip6Gateway = cmd.getIp6Gateway();
|
||||
String ip6Cidr = cmd.getIp6Cidr();
|
||||
|
||||
|
||||
Account vlanOwner = null;
|
||||
|
||||
|
||||
boolean ipv4 = (startIP != null);
|
||||
boolean ipv6 = (startIPv6 != null);
|
||||
|
||||
|
|
@ -2283,7 +2299,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
} else if (ipv6) {
|
||||
throw new InvalidParameterValueException("Only support IPv6 on extending existed network");
|
||||
}
|
||||
|
||||
|
||||
// Verify that zone exists
|
||||
DataCenterVO zone = _zoneDao.findById(zoneId);
|
||||
if (zone == null) {
|
||||
|
|
@ -2330,18 +2346,18 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Check if zone is enabled
|
||||
Account caller = UserContext.current().getCaller();
|
||||
if (Grouping.AllocationState.Disabled == zone.getAllocationState() && !_accountMgr.isRootAdmin(caller.getType())) {
|
||||
throw new PermissionDeniedException("Cannot perform this operation, Zone is currently disabled: " + zoneId);
|
||||
}
|
||||
}
|
||||
|
||||
if (zone.isSecurityGroupEnabled() && zone.getNetworkType() != DataCenter.NetworkType.Basic && forVirtualNetwork) {
|
||||
throw new InvalidParameterValueException("Can't add virtual ip range into a zone with security group enabled");
|
||||
}
|
||||
|
||||
|
||||
// If networkId is not specified, and vlan is Virtual or Direct Untagged, try to locate default networks
|
||||
if (forVirtualNetwork) {
|
||||
if (network == null) {
|
||||
|
|
@ -2438,7 +2454,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
Vlan vlan = createVlanAndPublicIpRange(zoneId, networkId, physicalNetworkId, forVirtualNetwork, podId, startIP,
|
||||
Vlan vlan = createVlanAndPublicIpRange(zoneId, networkId, physicalNetworkId, forVirtualNetwork, podId, startIP,
|
||||
endIP, vlanGateway, vlanNetmask, vlanId, vlanOwner, startIPv6, endIPv6, ip6Gateway, ip6Cidr);
|
||||
|
||||
txn.commit();
|
||||
|
|
@ -2448,39 +2464,39 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
|
||||
@Override
|
||||
@DB
|
||||
public Vlan createVlanAndPublicIpRange(long zoneId, long networkId, long physicalNetworkId, boolean forVirtualNetwork, Long podId,
|
||||
public Vlan createVlanAndPublicIpRange(long zoneId, long networkId, long physicalNetworkId, boolean forVirtualNetwork, Long podId,
|
||||
String startIP, String endIP, String vlanGateway, String vlanNetmask,
|
||||
String vlanId, Account vlanOwner, String startIPv6, String endIPv6, String vlanIp6Gateway, String vlanIp6Cidr) {
|
||||
Network network = _networkModel.getNetwork(networkId);
|
||||
|
||||
|
||||
boolean ipv4 = false, ipv6 = false;
|
||||
|
||||
|
||||
if (startIP != null) {
|
||||
ipv4 = true;
|
||||
}
|
||||
|
||||
|
||||
if (startIPv6 != null) {
|
||||
ipv6 = true;
|
||||
}
|
||||
|
||||
|
||||
if (!ipv4 && !ipv6) {
|
||||
throw new InvalidParameterValueException("Please specify IPv4 or IPv6 address.");
|
||||
}
|
||||
|
||||
|
||||
//Validate the zone
|
||||
DataCenterVO zone = _zoneDao.findById(zoneId);
|
||||
if (zone == null) {
|
||||
throw new InvalidParameterValueException("Please specify a valid zone.");
|
||||
}
|
||||
|
||||
|
||||
// ACL check
|
||||
checkZoneAccess(UserContext.current().getCaller(), zone);
|
||||
|
||||
|
||||
//Validate the physical network
|
||||
if (_physicalNetworkDao.findById(physicalNetworkId) == null) {
|
||||
throw new InvalidParameterValueException("Please specify a valid physical network id");
|
||||
}
|
||||
|
||||
|
||||
//Validate the pod
|
||||
if (podId != null) {
|
||||
Pod pod = _podDao.findById(podId);
|
||||
|
|
@ -2492,11 +2508,11 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
}
|
||||
//pod vlans can be created in basic zone only
|
||||
if (zone.getNetworkType() != NetworkType.Basic || network.getTrafficType() != TrafficType.Guest) {
|
||||
throw new InvalidParameterValueException("Pod id can be specified only for the networks of type "
|
||||
+ TrafficType.Guest + " in zone of type " + NetworkType.Basic);
|
||||
throw new InvalidParameterValueException("Pod id can be specified only for the networks of type "
|
||||
+ TrafficType.Guest + " in zone of type " + NetworkType.Basic);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//1) if vlan is specified for the guest network range, it should be the same as network's vlan
|
||||
//2) if vlan is missing, default it to the guest network's vlan
|
||||
if (network.getTrafficType() == TrafficType.Guest) {
|
||||
|
|
@ -2506,7 +2522,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
String[] vlan = uri.toString().split("vlan:\\/\\/");
|
||||
networkVlanId = vlan[1];
|
||||
}
|
||||
|
||||
|
||||
if (vlanId != null) {
|
||||
// if vlan is specified, throw an error if it's not equal to network's vlanId
|
||||
if (networkVlanId != null && !networkVlanId.equalsIgnoreCase(vlanId)) {
|
||||
|
|
@ -2519,14 +2535,14 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
//vlan id is required for public network
|
||||
throw new InvalidParameterValueException("Vlan id is required when add ip range to the public network");
|
||||
}
|
||||
|
||||
|
||||
if (vlanId == null) {
|
||||
vlanId = Vlan.UNTAGGED;
|
||||
}
|
||||
|
||||
VlanType vlanType = forVirtualNetwork ? VlanType.VirtualNetwork : VlanType.DirectAttached;
|
||||
|
||||
|
||||
|
||||
|
||||
if (vlanOwner != null && zone.getNetworkType() != NetworkType.Advanced) {
|
||||
throw new InvalidParameterValueException("Vlan owner can be defined only in the zone of type " + NetworkType.Advanced);
|
||||
}
|
||||
|
|
@ -2542,7 +2558,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
throw new InvalidParameterValueException("Please specify a valid netmask");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ipv6) {
|
||||
if (!NetUtils.isValidIpv6(vlanIp6Gateway)) {
|
||||
throw new InvalidParameterValueException("Please specify a valid IPv6 gateway");
|
||||
|
|
@ -2597,7 +2613,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
List<VlanVO> vlans = _vlanDao.listByZone(zone.getId());
|
||||
for (VlanVO vlan : vlans) {
|
||||
String otherVlanGateway = vlan.getVlanGateway();
|
||||
// Continue if it's not IPv4
|
||||
// Continue if it's not IPv4
|
||||
if (otherVlanGateway == null) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -2633,14 +2649,14 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String ipv6Range = null;
|
||||
if (ipv6) {
|
||||
ipv6Range = startIPv6;
|
||||
if (endIPv6 != null) {
|
||||
ipv6Range += "-" + endIPv6;
|
||||
}
|
||||
|
||||
|
||||
List<VlanVO> vlans = _vlanDao.listByZone(zone.getId());
|
||||
for (VlanVO vlan : vlans) {
|
||||
if (vlan.getIp6Gateway() == null) {
|
||||
|
|
@ -2680,14 +2696,14 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
}
|
||||
|
||||
String ipRange = null;
|
||||
|
||||
|
||||
if (ipv4) {
|
||||
ipRange = startIP;
|
||||
if (endIP != null) {
|
||||
ipRange += "-" + endIP;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Everything was fine, so persist the VLAN
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
|
@ -2699,7 +2715,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
// IPv6 use a used ip map, is different from ipv4, no need to save public ip range
|
||||
if (ipv4) {
|
||||
if (!savePublicIPRange(startIP, endIP, zoneId, vlan.getId(), networkId, physicalNetworkId)) {
|
||||
throw new CloudRuntimeException("Failed to save IPv4 range. Please contact Cloud Support.");
|
||||
throw new CloudRuntimeException("Failed to save IPv4 range. Please contact Cloud Support.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2733,7 +2749,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
if (vlan == null) {
|
||||
throw new InvalidParameterValueException("Please specify a valid IP range id.");
|
||||
}
|
||||
|
||||
|
||||
boolean isAccountSpecific = false;
|
||||
List<AccountVlanMapVO> acctVln = _accountVlanMapDao.listAccountVlanMapsByVlan(vlan.getId());
|
||||
// Check for account wide pool. It will have an entry for account_vlan_map.
|
||||
|
|
@ -2746,7 +2762,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
List<IPAddressVO> ips = _publicIpAddressDao.listByVlanId(vlanDbId);
|
||||
boolean success = true;
|
||||
if (allocIpCount > 0) {
|
||||
if (isAccountSpecific) {
|
||||
if (isAccountSpecific) {
|
||||
try {
|
||||
vlan = _vlanDao.acquireInLockTable(vlanDbId, 30);
|
||||
if (vlan == null) {
|
||||
|
|
@ -2759,7 +2775,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
|
||||
for (IPAddressVO ip : ips) {
|
||||
if (ip.isOneToOneNat()) {
|
||||
throw new InvalidParameterValueException("Can't delete account specific vlan " + vlanDbId +
|
||||
throw new InvalidParameterValueException("Can't delete account specific vlan " + vlanDbId +
|
||||
" as ip " + ip + " belonging to the range is used for static nat purposes. Cleanup the rules first");
|
||||
}
|
||||
|
||||
|
|
@ -2768,9 +2784,9 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
" as ip " + ip + " belonging to the range is a source nat ip for the network id=" + ip.getSourceNetworkId() +
|
||||
". IP range with the source nat ip address can be removed either as a part of Network, or account removal");
|
||||
}
|
||||
|
||||
|
||||
if (_firewallDao.countRulesByIpId(ip.getId()) > 0) {
|
||||
throw new InvalidParameterValueException("Can't delete account specific vlan " + vlanDbId +
|
||||
throw new InvalidParameterValueException("Can't delete account specific vlan " + vlanDbId +
|
||||
" as ip " + ip + " belonging to the range has firewall rules applied. Cleanup the rules first");
|
||||
}
|
||||
//release public ip address here
|
||||
|
|
@ -2781,7 +2797,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
}
|
||||
} finally {
|
||||
_vlanDao.releaseFromLockTable(vlanDbId);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new InvalidParameterValueException("The IP range can't be deleted because it has allocated public IP addresses.");
|
||||
}
|
||||
|
|
@ -3026,7 +3042,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@DB
|
||||
protected boolean savePublicIPRange(String startIP, String endIP, long zoneId, long vlanDbId, long sourceNetworkid, long physicalNetworkId) {
|
||||
|
|
@ -3229,7 +3245,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private boolean validPod(long podId) {
|
||||
return (_podDao.findById(podId) != null);
|
||||
}
|
||||
|
|
@ -3447,7 +3463,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
if (provider == Provider.JuniperSRX || provider == Provider.CiscoVnmc) {
|
||||
firewallProvider = provider;
|
||||
}
|
||||
|
||||
|
||||
if ((service == Service.PortForwarding || service == Service.StaticNat) && provider == Provider.VirtualRouter){
|
||||
firewallProvider = Provider.VirtualRouter;
|
||||
}
|
||||
|
|
@ -3622,7 +3638,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
if (!specifyVlan && type == GuestType.Shared) {
|
||||
throw new InvalidParameterValueException("SpecifyVlan should be true if network offering's type is " + type);
|
||||
}
|
||||
|
||||
|
||||
//specifyIpRanges should always be true for Shared networks
|
||||
//specifyIpRanges can only be true for Isolated networks with no Source Nat service
|
||||
if (specifyIpRanges) {
|
||||
|
|
@ -3646,7 +3662,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
if (availability == NetworkOffering.Availability.Required) {
|
||||
boolean canOffBeRequired = (type == GuestType.Isolated && serviceProviderMap.containsKey(Service.SourceNat));
|
||||
if (!canOffBeRequired) {
|
||||
throw new InvalidParameterValueException("Availability can be " + NetworkOffering.Availability.Required
|
||||
throw new InvalidParameterValueException("Availability can be " + NetworkOffering.Availability.Required
|
||||
+ " only for networkOfferings of type " + GuestType.Isolated + " and with "
|
||||
+ Service.SourceNat.getName() + " enabled");
|
||||
}
|
||||
|
|
@ -3654,11 +3670,11 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
// only one network offering in the system can be Required
|
||||
List<NetworkOfferingVO> offerings = _networkOfferingDao.listByAvailability(Availability.Required, false);
|
||||
if (!offerings.isEmpty()) {
|
||||
throw new InvalidParameterValueException("System already has network offering id=" + offerings.get(0).getId()
|
||||
throw new InvalidParameterValueException("System already has network offering id=" + offerings.get(0).getId()
|
||||
+ " with availability " + Availability.Required);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
boolean dedicatedLb = false;
|
||||
boolean elasticLb = false;
|
||||
boolean sharedSourceNat = false;
|
||||
|
|
@ -3668,7 +3684,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
boolean inline = false;
|
||||
if (serviceCapabilityMap != null && !serviceCapabilityMap.isEmpty()) {
|
||||
Map<Capability, String> lbServiceCapabilityMap = serviceCapabilityMap.get(Service.Lb);
|
||||
|
||||
|
||||
if ((lbServiceCapabilityMap != null) && (!lbServiceCapabilityMap.isEmpty())) {
|
||||
String isolationCapability = lbServiceCapabilityMap.get(Capability.SupportedLBIsolation);
|
||||
if (isolationCapability != null) {
|
||||
|
|
@ -3682,7 +3698,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
if (param != null) {
|
||||
elasticLb = param.contains("true");
|
||||
}
|
||||
|
||||
|
||||
String inlineMode = lbServiceCapabilityMap.get(Capability.InlineMode);
|
||||
if (inlineMode != null) {
|
||||
_networkModel.checkCapabilityForProvider(serviceProviderMap.get(Service.Lb), Service.Lb, Capability.InlineMode, inlineMode);
|
||||
|
|
@ -3696,14 +3712,14 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
if ((sourceNatServiceCapabilityMap != null) && (!sourceNatServiceCapabilityMap.isEmpty())) {
|
||||
String sourceNatType = sourceNatServiceCapabilityMap.get(Capability.SupportedSourceNatTypes);
|
||||
if (sourceNatType != null) {
|
||||
_networkModel.checkCapabilityForProvider(serviceProviderMap.get(Service.SourceNat), Service.SourceNat,
|
||||
_networkModel.checkCapabilityForProvider(serviceProviderMap.get(Service.SourceNat), Service.SourceNat,
|
||||
Capability.SupportedSourceNatTypes, sourceNatType);
|
||||
sharedSourceNat = sourceNatType.contains("perzone");
|
||||
}
|
||||
|
||||
String param = sourceNatServiceCapabilityMap.get(Capability.RedundantRouter);
|
||||
if (param != null) {
|
||||
_networkModel.checkCapabilityForProvider(serviceProviderMap.get(Service.SourceNat), Service.SourceNat,
|
||||
_networkModel.checkCapabilityForProvider(serviceProviderMap.get(Service.SourceNat), Service.SourceNat,
|
||||
Capability.RedundantRouter, param);
|
||||
redundantRouter = param.contains("true");
|
||||
}
|
||||
|
|
@ -3722,7 +3738,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
}
|
||||
}
|
||||
|
||||
NetworkOfferingVO offering = new NetworkOfferingVO(name, displayText, trafficType, systemOnly, specifyVlan,
|
||||
NetworkOfferingVO offering = new NetworkOfferingVO(name, displayText, trafficType, systemOnly, specifyVlan,
|
||||
networkRate, multicastRate, isDefault, availability, tags, type, conserveMode, dedicatedLb,
|
||||
sharedSourceNat, redundantRouter, elasticIp, elasticLb, specifyIpRanges, inline, isPersistent, associatePublicIp);
|
||||
|
||||
|
|
@ -3749,7 +3765,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
_ntwkOffServiceMapDao.persist(offService);
|
||||
s_logger.trace("Added service for the network offering: " + offService + " with provider " + provider.getName());
|
||||
}
|
||||
|
||||
|
||||
if (vpcOff) {
|
||||
List<Service> supportedSvcs = new ArrayList<Service>();
|
||||
supportedSvcs.addAll(serviceProviderMap.keySet());
|
||||
|
|
@ -3923,7 +3939,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
// filter by supported services
|
||||
boolean listBySupportedServices = (supportedServicesStr != null && !supportedServicesStr.isEmpty() && !offerings.isEmpty());
|
||||
boolean checkIfProvidersAreEnabled = (zoneId != null);
|
||||
boolean parseOfferings = (listBySupportedServices || sourceNatSupported != null || checkIfProvidersAreEnabled
|
||||
boolean parseOfferings = (listBySupportedServices || sourceNatSupported != null || checkIfProvidersAreEnabled
|
||||
|| forVpc != null || network != null);
|
||||
|
||||
if (parseOfferings) {
|
||||
|
|
@ -3971,7 +3987,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
if (sourceNatSupported != null) {
|
||||
addOffering = addOffering && (_networkModel.areServicesSupportedByNetworkOffering(offering.getId(), Network.Service.SourceNat) == sourceNatSupported);
|
||||
}
|
||||
|
||||
|
||||
if (forVpc != null) {
|
||||
addOffering = addOffering && (isOfferingForVpc(offering) == forVpc.booleanValue());
|
||||
} else if (network != null){
|
||||
|
|
@ -4089,14 +4105,14 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
}
|
||||
}
|
||||
if (availability == null) {
|
||||
throw new InvalidParameterValueException("Invalid value for Availability. Supported types: "
|
||||
throw new InvalidParameterValueException("Invalid value for Availability. Supported types: "
|
||||
+ Availability.Required + ", " + Availability.Optional);
|
||||
} else {
|
||||
if (availability == NetworkOffering.Availability.Required) {
|
||||
boolean canOffBeRequired = (offeringToUpdate.getGuestType() == GuestType.Isolated
|
||||
boolean canOffBeRequired = (offeringToUpdate.getGuestType() == GuestType.Isolated
|
||||
&& _networkModel.areServicesSupportedByNetworkOffering(offeringToUpdate.getId(), Service.SourceNat));
|
||||
if (!canOffBeRequired) {
|
||||
throw new InvalidParameterValueException("Availability can be " +
|
||||
throw new InvalidParameterValueException("Availability can be " +
|
||||
NetworkOffering.Availability.Required + " only for networkOfferings of type " + GuestType.Isolated + " and with "
|
||||
+ Service.SourceNat.getName() + " enabled");
|
||||
}
|
||||
|
|
@ -4104,7 +4120,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
// only one network offering in the system can be Required
|
||||
List<NetworkOfferingVO> offerings = _networkOfferingDao.listByAvailability(Availability.Required, false);
|
||||
if (!offerings.isEmpty() && offerings.get(0).getId() != offeringToUpdate.getId()) {
|
||||
throw new InvalidParameterValueException("System already has network offering id=" +
|
||||
throw new InvalidParameterValueException("System already has network offering id=" +
|
||||
offerings.get(0).getId() + " with availability " + Availability.Required);
|
||||
}
|
||||
}
|
||||
|
|
@ -4123,7 +4139,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
@ActionEvent(eventType = EventTypes.EVENT_ACCOUNT_MARK_DEFAULT_ZONE, eventDescription = "Marking account with the " +
|
||||
"default zone", async=true)
|
||||
public AccountVO markDefaultZone(String accountName, long domainId, long defaultZoneId) {
|
||||
|
||||
|
||||
// Check if the account exists
|
||||
Account account = _accountDao.findEnabledAccount(accountName, domainId);
|
||||
if (account == null) {
|
||||
|
|
@ -4137,9 +4153,9 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
}
|
||||
|
||||
AccountVO acctForUpdate = _accountDao.findById(account.getId());
|
||||
|
||||
|
||||
acctForUpdate.setDefaultZoneId(defaultZoneId);
|
||||
|
||||
|
||||
if (_accountDao.update(account.getId(), acctForUpdate)) {
|
||||
UserContext.current().setEventDetails("Default zone id= " + defaultZoneId);
|
||||
return _accountDao.findById(account.getId());
|
||||
|
|
@ -4147,7 +4163,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Note: This method will be used for entity name validations in the coming
|
||||
// releases (place holder for now)
|
||||
private void validateEntityName(String str) {
|
||||
|
|
@ -4275,10 +4291,10 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
public ClusterVO getCluster(long id) {
|
||||
return _clusterDao.findById(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AllocationState findClusterAllocationState(ClusterVO cluster){
|
||||
|
||||
|
||||
if(cluster.getAllocationState() == AllocationState.Disabled){
|
||||
return AllocationState.Disabled;
|
||||
}else if(ApiDBUtils.findPodById(cluster.getPodId()).getAllocationState() == AllocationState.Disabled){
|
||||
|
|
@ -4286,20 +4302,20 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
}else {
|
||||
DataCenterVO zone = ApiDBUtils.findZoneById(cluster.getDataCenterId());
|
||||
return zone.getAllocationState();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AllocationState findPodAllocationState(HostPodVO pod){
|
||||
|
||||
|
||||
if(pod.getAllocationState() == AllocationState.Disabled){
|
||||
return AllocationState.Disabled;
|
||||
}else {
|
||||
DataCenterVO zone = ApiDBUtils.findZoneById(pod.getDataCenterId());
|
||||
return zone.getAllocationState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean allowIpRangeOverlap(VlanVO vlan, boolean forVirtualNetwork, long networkId) {
|
||||
// FIXME - delete restriction for virtual network in the future
|
||||
if (vlan.getVlanType() == VlanType.DirectAttached && !forVirtualNetwork) {
|
||||
|
|
|
|||
|
|
@ -444,6 +444,8 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
|
|||
if (hostResourceType == resourceUsageRequired) {
|
||||
return true;
|
||||
} else {
|
||||
s_logger.debug("Cannot use this host for usage: " + resourceUsageRequired
|
||||
+ ", since this host has been reserved for planner usage : " + hostResourceType);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -469,6 +471,8 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
|
|||
if (lockedEntry.getResourceUsage() == resourceUsageRequired) {
|
||||
return true;
|
||||
} else {
|
||||
s_logger.debug("Cannot use this host for usage: " + resourceUsageRequired
|
||||
+ ", since this host has been reserved for planner usage : " + hostResourceType);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,6 +196,7 @@ import org.apache.cloudstack.api.command.admin.cluster.DeleteClusterCmd;
|
|||
import org.apache.cloudstack.api.command.admin.cluster.ListClustersCmd;
|
||||
import org.apache.cloudstack.api.command.admin.cluster.UpdateClusterCmd;
|
||||
import org.apache.cloudstack.api.command.admin.config.ListCfgsByCmd;
|
||||
import org.apache.cloudstack.api.command.admin.config.ListDeploymentPlannersCmd;
|
||||
import org.apache.cloudstack.api.command.admin.config.ListHypervisorCapabilitiesCmd;
|
||||
import org.apache.cloudstack.api.command.admin.config.UpdateCfgCmd;
|
||||
import org.apache.cloudstack.api.command.admin.config.UpdateHypervisorCapabilitiesCmd;
|
||||
|
|
@ -402,7 +403,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
private String _hashKey = null;
|
||||
private String _encryptionKey = null;
|
||||
private String _encryptionIV = null;
|
||||
|
||||
|
||||
@Inject
|
||||
protected AffinityGroupVMMapDao _affinityGroupVMMapDao;
|
||||
|
||||
|
|
@ -2544,6 +2545,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
cmdList.add(ListAffinityGroupsCmd.class);
|
||||
cmdList.add(UpdateVMAffinityGroupCmd.class);
|
||||
cmdList.add(ListAffinityGroupTypesCmd.class);
|
||||
cmdList.add(ListDeploymentPlannersCmd.class);
|
||||
|
||||
return cmdList;
|
||||
}
|
||||
|
|
@ -3305,7 +3307,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
// although we may have race conditioning here, database transaction serialization should
|
||||
// give us the same key
|
||||
if (_hashKey == null) {
|
||||
_hashKey = _configDao.getValueAndInitIfNotExist(Config.HashKey.key(), Config.HashKey.getCategory(),
|
||||
_hashKey = _configDao.getValueAndInitIfNotExist(Config.HashKey.key(), Config.HashKey.getCategory(),
|
||||
getBase64EncodedRandomKey(128));
|
||||
}
|
||||
return _hashKey;
|
||||
|
|
@ -3314,41 +3316,41 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
@Override
|
||||
public String getEncryptionKey() {
|
||||
if (_encryptionKey == null) {
|
||||
_encryptionKey = _configDao.getValueAndInitIfNotExist(Config.EncryptionKey.key(),
|
||||
Config.EncryptionKey.getCategory(),
|
||||
_encryptionKey = _configDao.getValueAndInitIfNotExist(Config.EncryptionKey.key(),
|
||||
Config.EncryptionKey.getCategory(),
|
||||
getBase64EncodedRandomKey(128));
|
||||
}
|
||||
return _encryptionKey;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getEncryptionIV() {
|
||||
if (_encryptionIV == null) {
|
||||
_encryptionIV = _configDao.getValueAndInitIfNotExist(Config.EncryptionIV.key(),
|
||||
Config.EncryptionIV.getCategory(),
|
||||
_encryptionIV = _configDao.getValueAndInitIfNotExist(Config.EncryptionIV.key(),
|
||||
Config.EncryptionIV.getCategory(),
|
||||
getBase64EncodedRandomKey(128));
|
||||
}
|
||||
return _encryptionIV;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public void resetEncryptionKeyIV() {
|
||||
|
||||
|
||||
SearchBuilder<ConfigurationVO> sb = _configDao.createSearchBuilder();
|
||||
sb.and("name1", sb.entity().getName(), SearchCriteria.Op.EQ);
|
||||
sb.or("name2", sb.entity().getName(), SearchCriteria.Op.EQ);
|
||||
sb.done();
|
||||
|
||||
|
||||
SearchCriteria<ConfigurationVO> sc = sb.create();
|
||||
sc.setParameters("name1", Config.EncryptionKey.key());
|
||||
sc.setParameters("name2", Config.EncryptionIV.key());
|
||||
|
||||
|
||||
_configDao.expunge(sc);
|
||||
_encryptionKey = null;
|
||||
_encryptionIV = null;
|
||||
}
|
||||
|
||||
|
||||
private static String getBase64EncodedRandomKey(int nBits) {
|
||||
SecureRandom random;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -934,9 +934,42 @@ CREATE TABLE `cloud`.`op_host_planner_reservation` (
|
|||
CONSTRAINT `fk_planner_reservation__cluster_id` FOREIGN KEY (`cluster_id`) REFERENCES `cloud`.`cluster`(`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
ALTER TABLE `cloud`.`service_offering` ADD COLUMN `deployment_planner` varchar(255) NOT NULL DEFAULT 'FirstFitPlanner' COMMENT 'Planner heuristics used to deploy a VM of this offering';
|
||||
|
||||
-- Re-enable foreign key checking, at the end of the upgrade path
|
||||
SET foreign_key_checks = 1;
|
||||
DROP VIEW IF EXISTS `cloud`.`service_offering_view`;
|
||||
CREATE VIEW `cloud`.`service_offering_view` AS
|
||||
select
|
||||
service_offering.id,
|
||||
disk_offering.uuid,
|
||||
disk_offering.name,
|
||||
disk_offering.display_text,
|
||||
disk_offering.created,
|
||||
disk_offering.tags,
|
||||
disk_offering.removed,
|
||||
disk_offering.use_local_storage,
|
||||
disk_offering.system_use,
|
||||
service_offering.cpu,
|
||||
service_offering.speed,
|
||||
service_offering.ram_size,
|
||||
service_offering.nw_rate,
|
||||
service_offering.mc_rate,
|
||||
service_offering.ha_enabled,
|
||||
service_offering.limit_cpu_use,
|
||||
service_offering.host_tag,
|
||||
service_offering.default_use,
|
||||
service_offering.vm_type,
|
||||
service_offering.sort_key,
|
||||
service_offering.deployment_planner,
|
||||
domain.id domain_id,
|
||||
domain.uuid domain_uuid,
|
||||
domain.name domain_name,
|
||||
domain.path domain_path
|
||||
from
|
||||
`cloud`.`service_offering`
|
||||
inner join
|
||||
`cloud`.`disk_offering` ON service_offering.id = disk_offering.id
|
||||
left join
|
||||
`cloud`.`domain` ON disk_offering.domain_id = domain.id;
|
||||
|
||||
|
||||
-- Add "default" field to account/user tables
|
||||
|
|
@ -1143,3 +1176,6 @@ INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'manage
|
|||
|
||||
alter table cloud.vpc_gateways add column source_nat boolean default false;
|
||||
alter table cloud.private_ip_address add column source_nat boolean default false;
|
||||
|
||||
-- Re-enable foreign key checking, at the end of the upgrade path
|
||||
SET foreign_key_checks = 1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue