mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Merge branch '4.20'
This commit is contained in:
commit
3e3a0c0678
@ -53,9 +53,12 @@ public interface Host extends StateObject<Status>, Identity, Partition, HAResour
|
||||
return strs;
|
||||
}
|
||||
}
|
||||
public static final String HOST_UEFI_ENABLE = "host.uefi.enable";
|
||||
public static final String HOST_VOLUME_ENCRYPTION = "host.volume.encryption";
|
||||
public static final String HOST_INSTANCE_CONVERSION = "host.instance.conversion";
|
||||
|
||||
String HOST_UEFI_ENABLE = "host.uefi.enable";
|
||||
String HOST_VOLUME_ENCRYPTION = "host.volume.encryption";
|
||||
String HOST_INSTANCE_CONVERSION = "host.instance.conversion";
|
||||
String HOST_OVFTOOL_VERSION = "host.ovftool.version";
|
||||
String HOST_VIRTV2V_VERSION = "host.virtv2v.version";
|
||||
|
||||
/**
|
||||
* @return name of the machine.
|
||||
|
||||
@ -62,6 +62,7 @@ import org.apache.cloudstack.utils.identity.ManagementServerNode;
|
||||
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.ThreadContext;
|
||||
|
||||
@ -801,11 +802,25 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
|
||||
Map<String, String> detailsMap = readyAnswer.getDetailsMap();
|
||||
if (detailsMap != null) {
|
||||
String uefiEnabled = detailsMap.get(Host.HOST_UEFI_ENABLE);
|
||||
String virtv2vVersion = detailsMap.get(Host.HOST_VIRTV2V_VERSION);
|
||||
String ovftoolVersion = detailsMap.get(Host.HOST_OVFTOOL_VERSION);
|
||||
logger.debug("Got HOST_UEFI_ENABLE [{}] for host [{}]:", uefiEnabled, host);
|
||||
if (uefiEnabled != null) {
|
||||
if (ObjectUtils.anyNotNull(uefiEnabled, virtv2vVersion, ovftoolVersion)) {
|
||||
_hostDao.loadDetails(host);
|
||||
boolean updateNeeded = false;
|
||||
if (!uefiEnabled.equals(host.getDetails().get(Host.HOST_UEFI_ENABLE))) {
|
||||
host.getDetails().put(Host.HOST_UEFI_ENABLE, uefiEnabled);
|
||||
updateNeeded = true;
|
||||
}
|
||||
if (StringUtils.isNotBlank(virtv2vVersion) && !virtv2vVersion.equals(host.getDetails().get(Host.HOST_VIRTV2V_VERSION))) {
|
||||
host.getDetails().put(Host.HOST_VIRTV2V_VERSION, virtv2vVersion);
|
||||
updateNeeded = true;
|
||||
}
|
||||
if (StringUtils.isNotBlank(ovftoolVersion) && !ovftoolVersion.equals(host.getDetails().get(Host.HOST_OVFTOOL_VERSION))) {
|
||||
host.getDetails().put(Host.HOST_OVFTOOL_VERSION, ovftoolVersion);
|
||||
updateNeeded = true;
|
||||
}
|
||||
if (updateNeeded) {
|
||||
_hostDao.saveDetails(host);
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,6 +17,8 @@
|
||||
package com.cloud.hypervisor.kvm.resource;
|
||||
|
||||
import static com.cloud.host.Host.HOST_INSTANCE_CONVERSION;
|
||||
import static com.cloud.host.Host.HOST_OVFTOOL_VERSION;
|
||||
import static com.cloud.host.Host.HOST_VIRTV2V_VERSION;
|
||||
import static com.cloud.host.Host.HOST_VOLUME_ENCRYPTION;
|
||||
import static org.apache.cloudstack.utils.linux.KVMHostInfo.isHostS390x;
|
||||
|
||||
@ -3908,7 +3910,14 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
cmd.setIqn(getIqn());
|
||||
cmd.getHostDetails().put(HOST_VOLUME_ENCRYPTION, String.valueOf(hostSupportsVolumeEncryption()));
|
||||
cmd.setHostTags(getHostTags());
|
||||
cmd.getHostDetails().put(HOST_INSTANCE_CONVERSION, String.valueOf(hostSupportsInstanceConversion()));
|
||||
boolean instanceConversionSupported = hostSupportsInstanceConversion();
|
||||
cmd.getHostDetails().put(HOST_INSTANCE_CONVERSION, String.valueOf(instanceConversionSupported));
|
||||
if (instanceConversionSupported) {
|
||||
cmd.getHostDetails().put(HOST_VIRTV2V_VERSION, getHostVirtV2vVersion());
|
||||
}
|
||||
if (hostSupportsOvfExport()) {
|
||||
cmd.getHostDetails().put(HOST_OVFTOOL_VERSION, getHostOvfToolVersion());
|
||||
}
|
||||
HealthCheckResult healthCheckResult = getHostHealthCheckResult();
|
||||
if (healthCheckResult != HealthCheckResult.IGNORE) {
|
||||
cmd.setHostHealthCheckResult(healthCheckResult == HealthCheckResult.SUCCESS);
|
||||
@ -5616,8 +5625,24 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
return exitValue == 0;
|
||||
}
|
||||
|
||||
public String getHostVirtV2vVersion() {
|
||||
if (!hostSupportsInstanceConversion()) {
|
||||
return "";
|
||||
}
|
||||
String cmd = String.format("%s | awk '{print $2}'", INSTANCE_CONVERSION_SUPPORTED_CHECK_CMD);
|
||||
String version = Script.runSimpleBashScript(cmd);
|
||||
return StringUtils.isNotBlank(version) ? version.split(",")[0] : "";
|
||||
}
|
||||
|
||||
public String getHostOvfToolVersion() {
|
||||
if (!hostSupportsOvfExport()) {
|
||||
return "";
|
||||
}
|
||||
return Script.runSimpleBashScript(OVF_EXPORT_TOOl_GET_VERSION_CMD);
|
||||
}
|
||||
|
||||
public boolean ovfExportToolSupportsParallelThreads() {
|
||||
String ovfExportToolVersion = Script.runSimpleBashScript(OVF_EXPORT_TOOl_GET_VERSION_CMD);
|
||||
String ovfExportToolVersion = getHostOvfToolVersion();
|
||||
if (StringUtils.isBlank(ovfExportToolVersion)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -47,6 +47,14 @@ public final class LibvirtReadyCommandWrapper extends CommandWrapper<ReadyComman
|
||||
hostDetails.put(Host.HOST_UEFI_ENABLE, Boolean.TRUE.toString());
|
||||
}
|
||||
|
||||
if (libvirtComputingResource.hostSupportsInstanceConversion()) {
|
||||
hostDetails.put(Host.HOST_VIRTV2V_VERSION, libvirtComputingResource.getHostVirtV2vVersion());
|
||||
}
|
||||
|
||||
if (libvirtComputingResource.hostSupportsOvfExport()) {
|
||||
hostDetails.put(Host.HOST_OVFTOOL_VERSION, libvirtComputingResource.getHostOvfToolVersion());
|
||||
}
|
||||
|
||||
return new ReadyAnswer(command, hostDetails);
|
||||
}
|
||||
|
||||
|
||||
@ -49,9 +49,12 @@ public final class CitrixResizeVolumeCommandWrapper extends CommandWrapper<Resiz
|
||||
|
||||
try {
|
||||
|
||||
if (command.getCurrentSize() >= newSize) {
|
||||
logger.info("No need to resize volume: " + volId +", current size " + toHumanReadableSize(command.getCurrentSize()) + " is same as new size " + toHumanReadableSize(newSize));
|
||||
if (command.getCurrentSize() == newSize) {
|
||||
logger.info("No need to resize volume [{}], current size [{}] is same as new size [{}].", volId, toHumanReadableSize(command.getCurrentSize()), toHumanReadableSize(newSize));
|
||||
return new ResizeVolumeAnswer(command, true, "success", newSize);
|
||||
} else if (command.getCurrentSize() > newSize) {
|
||||
logger.error("XenServer does not support volume shrink. Volume [{}] current size [{}] is smaller than new size [{}]", volId, toHumanReadableSize(command.getCurrentSize()), toHumanReadableSize(newSize));
|
||||
return new ResizeVolumeAnswer(command, false, "operation not supported");
|
||||
}
|
||||
if (command.isManaged()) {
|
||||
resizeSr(conn, command);
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.ldap;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Hashtable;
|
||||
|
||||
@ -24,6 +25,7 @@ import javax.naming.Context;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.ldap.InitialLdapContext;
|
||||
import javax.naming.ldap.LdapContext;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@ -52,14 +54,14 @@ public class LdapContextFactory {
|
||||
return createInitialDirContext(bindPrincipal, bindPassword, providerUrl, true, domainId);
|
||||
}
|
||||
|
||||
private LdapContext createInitialDirContext(final String principal, final String password, final boolean isSystemContext, Long domainId) throws NamingException, IOException {
|
||||
private LdapContext createInitialDirContext(final String principal, final String password, final boolean isSystemContext, Long domainId) throws NamingException {
|
||||
return createInitialDirContext(principal, password, null, isSystemContext, domainId);
|
||||
}
|
||||
|
||||
private LdapContext createInitialDirContext(final String principal, final String password, final String providerUrl, final boolean isSystemContext, Long domainId)
|
||||
throws NamingException, IOException {
|
||||
throws NamingException {
|
||||
Hashtable<String, String> environment = getEnvironment(principal, password, providerUrl, isSystemContext, domainId);
|
||||
logger.debug("initializing ldap with provider url: " + environment.get(Context.PROVIDER_URL));
|
||||
logger.debug("initializing ldap with provider url: {}", environment.get(Context.PROVIDER_URL));
|
||||
return new InitialLdapContext(environment, null);
|
||||
}
|
||||
|
||||
@ -73,8 +75,36 @@ public class LdapContextFactory {
|
||||
if (sslStatus) {
|
||||
logger.info("LDAP SSL enabled.");
|
||||
environment.put(Context.SECURITY_PROTOCOL, "ssl");
|
||||
System.setProperty("javax.net.ssl.trustStore", _ldapConfiguration.getTrustStore(domainId));
|
||||
System.setProperty("javax.net.ssl.trustStorePassword", _ldapConfiguration.getTrustStorePassword(domainId));
|
||||
String trustStore = _ldapConfiguration.getTrustStore(domainId);
|
||||
String trustStorePassword = _ldapConfiguration.getTrustStorePassword(domainId);
|
||||
|
||||
if (!validateTrustStore(trustStore, trustStorePassword)) {
|
||||
throw new RuntimeException("Invalid truststore or truststore password");
|
||||
}
|
||||
|
||||
System.setProperty("javax.net.ssl.trustStore", trustStore);
|
||||
System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean validateTrustStore(String trustStore, String trustStorePassword) {
|
||||
if (trustStore == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (trustStorePassword == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
KeyStore.getInstance("JKS").load(
|
||||
new FileInputStream(trustStore),
|
||||
trustStorePassword.toCharArray()
|
||||
);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
logger.warn("Failed to validate truststore: {}", e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -184,6 +184,11 @@ public class LdapManagerImpl extends ComponentLifecycleBase implements LdapManag
|
||||
} catch (NamingException | IOException e) {
|
||||
logger.debug("NamingException while doing an LDAP bind", e);
|
||||
throw new InvalidParameterValueException("Unable to bind to the given LDAP server");
|
||||
} catch (RuntimeException e) {
|
||||
if (e.getMessage().contains("Invalid truststore")) {
|
||||
throw new InvalidParameterValueException("Invalid truststore or truststore password");
|
||||
}
|
||||
throw e;
|
||||
} finally {
|
||||
closeContext(context);
|
||||
}
|
||||
|
||||
@ -89,6 +89,10 @@ import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.ManagerBase;
|
||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionCallbackNoReturn;
|
||||
import com.cloud.utils.db.TransactionStatus;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class AlertManagerImpl extends ManagerBase implements AlertManager, Configurable {
|
||||
@ -290,8 +294,13 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
|
||||
Math.min(CapacityManager.CapacityCalculateWorkers.value(), hostIds.size())));
|
||||
for (Long hostId : hostIds) {
|
||||
futures.put(hostId, executorService.submit(() -> {
|
||||
Transaction.execute(new TransactionCallbackNoReturn() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
final HostVO host = hostDao.findById(hostId);
|
||||
_capacityMgr.updateCapacityForHost(host);
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}));
|
||||
}
|
||||
@ -316,6 +325,9 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
|
||||
Math.min(CapacityManager.CapacityCalculateWorkers.value(), storagePoolIds.size())));
|
||||
for (Long poolId: storagePoolIds) {
|
||||
futures.put(poolId, executorService.submit(() -> {
|
||||
Transaction.execute(new TransactionCallbackNoReturn() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
final StoragePoolVO pool = _storagePoolDao.findById(poolId);
|
||||
long disk = _capacityMgr.getAllocatedPoolCapacity(pool, null);
|
||||
if (pool.isShared()) {
|
||||
@ -323,6 +335,8 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
|
||||
} else {
|
||||
_storageMgr.createCapacityEntry(pool, Capacity.CAPACITY_TYPE_LOCAL_STORAGE, disk);
|
||||
}
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}));
|
||||
}
|
||||
|
||||
@ -99,7 +99,6 @@ import org.apache.cloudstack.config.Configuration;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
|
||||
import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
|
||||
import org.apache.cloudstack.framework.config.ConfigDepot;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
@ -255,8 +254,6 @@ import com.cloud.org.Grouping;
|
||||
import com.cloud.org.Grouping.AllocationState;
|
||||
import com.cloud.projects.Project;
|
||||
import com.cloud.projects.ProjectManager;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.server.ConfigurationServer;
|
||||
import com.cloud.server.ManagementService;
|
||||
import com.cloud.service.ServiceOfferingDetailsVO;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
@ -306,10 +303,8 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.NicIpAlias;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
import com.cloud.vm.dao.NicIpAliasDao;
|
||||
import com.cloud.vm.dao.NicIpAliasVO;
|
||||
import com.cloud.vm.dao.NicSecondaryIpDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
import com.google.common.base.Enums;
|
||||
import com.google.common.base.MoreObjects;
|
||||
@ -398,16 +393,12 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
@Inject
|
||||
ProjectManager _projectMgr;
|
||||
@Inject
|
||||
DataStoreManager _dataStoreMgr;
|
||||
@Inject
|
||||
NetworkOfferingServiceMapDao _ntwkOffServiceMapDao;
|
||||
@Inject
|
||||
PhysicalNetworkDao _physicalNetworkDao;
|
||||
@Inject
|
||||
PhysicalNetworkTrafficTypeDao _trafficTypeDao;
|
||||
@Inject
|
||||
NicDao _nicDao;
|
||||
@Inject
|
||||
FirewallRulesDao _firewallDao;
|
||||
@Inject
|
||||
VpcManager _vpcMgr;
|
||||
@ -420,8 +411,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
@Inject
|
||||
PortableIpDao _portableIpDao;
|
||||
@Inject
|
||||
ConfigurationServer _configServer;
|
||||
@Inject
|
||||
DataCenterDetailsDao _dcDetailsDao;
|
||||
@Inject
|
||||
ClusterDetailsDao _clusterDetailsDao;
|
||||
@ -434,8 +423,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
@Inject
|
||||
PrimaryDataStoreDao _storagePoolDao;
|
||||
@Inject
|
||||
NicSecondaryIpDao _nicSecondaryIpDao;
|
||||
@Inject
|
||||
NicIpAliasDao _nicIpAliasDao;
|
||||
@Inject
|
||||
public ManagementService _mgr;
|
||||
@ -460,7 +447,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
@Inject
|
||||
IndirectAgentLB _indirectAgentLB;
|
||||
@Inject
|
||||
private VMTemplateZoneDao templateZoneDao;
|
||||
VMTemplateZoneDao templateZoneDao;
|
||||
@Inject
|
||||
VsphereStoragePolicyDao vsphereStoragePolicyDao;
|
||||
@Inject
|
||||
@ -468,7 +455,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
@Inject
|
||||
StoragePoolTagsDao storagePoolTagDao;
|
||||
@Inject
|
||||
private AnnotationDao annotationDao;
|
||||
AnnotationDao annotationDao;
|
||||
@Inject
|
||||
UserIpv6AddressDao _ipv6Dao;
|
||||
@Inject
|
||||
@ -480,8 +467,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
@Inject
|
||||
NsxProviderDao nsxProviderDao;
|
||||
@Inject
|
||||
ResourceManager resourceManager;
|
||||
@Inject
|
||||
VMLeaseManager vmLeaseManager;
|
||||
|
||||
// FIXME - why don't we have interface for DataCenterLinkLocalIpAddressDao?
|
||||
@ -495,37 +480,37 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
private Set<String> weightBasedParametersForValidation = new HashSet<>();
|
||||
private Set<String> overprovisioningFactorsForValidation = new HashSet<>();
|
||||
|
||||
public static final ConfigKey<Boolean> SystemVMUseLocalStorage = new ConfigKey<Boolean>(Boolean.class, "system.vm.use.local.storage", "Advanced", "false",
|
||||
public static final ConfigKey<Boolean> SystemVMUseLocalStorage = new ConfigKey<>(Boolean.class, "system.vm.use.local.storage", "Advanced", "false",
|
||||
"Indicates whether to use local storage pools or shared storage pools for system VMs.", false, ConfigKey.Scope.Zone, null);
|
||||
|
||||
public final static ConfigKey<Long> BYTES_MAX_READ_LENGTH= new ConfigKey<Long>(Long.class, "vm.disk.bytes.maximum.read.length", "Advanced", "0",
|
||||
public final static ConfigKey<Long> BYTES_MAX_READ_LENGTH= new ConfigKey<>(Long.class, "vm.disk.bytes.maximum.read.length", "Advanced", "0",
|
||||
"Maximum Bytes read burst duration (seconds). If '0' (zero) then does not check for maximum burst length.", true, ConfigKey.Scope.Global, null);
|
||||
public final static ConfigKey<Long> BYTES_MAX_WRITE_LENGTH = new ConfigKey<Long>(Long.class, "vm.disk.bytes.maximum.write.length", "Advanced", "0",
|
||||
public final static ConfigKey<Long> BYTES_MAX_WRITE_LENGTH = new ConfigKey<>(Long.class, "vm.disk.bytes.maximum.write.length", "Advanced", "0",
|
||||
"Maximum Bytes write burst duration (seconds). If '0' (zero) then does not check for maximum burst length.", true, ConfigKey.Scope.Global, null);
|
||||
public final static ConfigKey<Long> IOPS_MAX_READ_LENGTH = new ConfigKey<Long>(Long.class, "vm.disk.iops.maximum.read.length", "Advanced", "0",
|
||||
public final static ConfigKey<Long> IOPS_MAX_READ_LENGTH = new ConfigKey<>(Long.class, "vm.disk.iops.maximum.read.length", "Advanced", "0",
|
||||
"Maximum IOPS read burst duration (seconds). If '0' (zero) then does not check for maximum burst length.", true, ConfigKey.Scope.Global, null);
|
||||
public final static ConfigKey<Long> IOPS_MAX_WRITE_LENGTH = new ConfigKey<Long>(Long.class, "vm.disk.iops.maximum.write.length", "Advanced", "0",
|
||||
public final static ConfigKey<Long> IOPS_MAX_WRITE_LENGTH = new ConfigKey<>(Long.class, "vm.disk.iops.maximum.write.length", "Advanced", "0",
|
||||
"Maximum IOPS write burst duration (seconds). If '0' (zero) then does not check for maximum burst length.", true, ConfigKey.Scope.Global, null);
|
||||
public static final ConfigKey<Boolean> ADD_HOST_ON_SERVICE_RESTART_KVM = new ConfigKey<Boolean>(Boolean.class, "add.host.on.service.restart.kvm", "Advanced", "true",
|
||||
public static final ConfigKey<Boolean> ADD_HOST_ON_SERVICE_RESTART_KVM = new ConfigKey<>(Boolean.class, "add.host.on.service.restart.kvm", "Advanced", "true",
|
||||
"Indicates whether the host will be added back to cloudstack after restarting agent service on host. If false it won't be added back even after service restart",
|
||||
true, ConfigKey.Scope.Global, null);
|
||||
public static final ConfigKey<Boolean> SET_HOST_DOWN_TO_MAINTENANCE = new ConfigKey<Boolean>(Boolean.class, "set.host.down.to.maintenance", "Advanced", "false",
|
||||
public static final ConfigKey<Boolean> SET_HOST_DOWN_TO_MAINTENANCE = new ConfigKey<>(Boolean.class, "set.host.down.to.maintenance", "Advanced", "false",
|
||||
"Indicates whether the host in down state can be put into maintenance state so thats its not enabled after it comes back.",
|
||||
true, ConfigKey.Scope.Zone, null);
|
||||
public static final ConfigKey<Boolean> ENABLE_ACCOUNT_SETTINGS_FOR_DOMAIN = new ConfigKey<Boolean>(Boolean.class, "enable.account.settings.for.domain", "Advanced", "false",
|
||||
public static final ConfigKey<Boolean> ENABLE_ACCOUNT_SETTINGS_FOR_DOMAIN = new ConfigKey<>(Boolean.class, "enable.account.settings.for.domain", "Advanced", "false",
|
||||
"Indicates whether to add account settings for domain. If true, account settings will be added to domain settings, all accounts in the domain will inherit the domain setting if account setting is not set.", true, ConfigKey.Scope.Global, null);
|
||||
public static final ConfigKey<Boolean> ENABLE_DOMAIN_SETTINGS_FOR_CHILD_DOMAIN = new ConfigKey<Boolean>(Boolean.class, "enable.domain.settings.for.child.domain", "Advanced", "false",
|
||||
public static final ConfigKey<Boolean> ENABLE_DOMAIN_SETTINGS_FOR_CHILD_DOMAIN = new ConfigKey<>(Boolean.class, "enable.domain.settings.for.child.domain", "Advanced", "false",
|
||||
"Indicates whether the settings of parent domain should be applied for child domain. If true, the child domain will get value from parent domain if its not configured in child domain else global value is taken.",
|
||||
true, ConfigKey.Scope.Global, null);
|
||||
|
||||
public static ConfigKey<Integer> VM_SERVICE_OFFERING_MAX_CPU_CORES = new ConfigKey<Integer>("Advanced", Integer.class, "vm.serviceoffering.cpu.cores.max", "0", "Maximum CPU cores "
|
||||
public static ConfigKey<Integer> VM_SERVICE_OFFERING_MAX_CPU_CORES = new ConfigKey<>("Advanced", Integer.class, "vm.serviceoffering.cpu.cores.max", "0", "Maximum CPU cores "
|
||||
+ "for vm service offering. If 0 - no limitation", true);
|
||||
|
||||
public static ConfigKey<Integer> VM_SERVICE_OFFERING_MAX_RAM_SIZE = new ConfigKey<Integer>("Advanced", Integer.class, "vm.serviceoffering.ram.size.max", "0", "Maximum RAM size in "
|
||||
public static ConfigKey<Integer> VM_SERVICE_OFFERING_MAX_RAM_SIZE = new ConfigKey<>("Advanced", Integer.class, "vm.serviceoffering.ram.size.max", "0", "Maximum RAM size in "
|
||||
+ "MB for vm service offering. If 0 - no limitation", true);
|
||||
|
||||
public static final ConfigKey<Boolean> MIGRATE_VM_ACROSS_CLUSTERS = new ConfigKey<Boolean>(Boolean.class, "migrate.vm.across.clusters", "Advanced", "false",
|
||||
"Indicates whether the VM can be migrated to different cluster if no host is found in same cluster",true, ConfigKey.Scope.Zone, null);
|
||||
public static final ConfigKey<Boolean> MIGRATE_VM_ACROSS_CLUSTERS = new ConfigKey<>(Boolean.class, "migrate.vm.across.clusters", "Advanced", "false",
|
||||
"Indicates whether the VM can be migrated to different cluster if no host is found in same cluster", true, ConfigKey.Scope.Zone, null);
|
||||
|
||||
public static final ConfigKey<Boolean> ALLOW_DOMAIN_ADMINS_TO_CREATE_TAGGED_OFFERINGS = new ConfigKey<>(Boolean.class, "allow.domain.admins.to.create.tagged.offerings", "Advanced",
|
||||
"false", "Allow domain admins to create offerings with tags.", true, ConfigKey.Scope.Account, null);
|
||||
@ -541,7 +526,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
private static final String BYTES_WRITE_RATE = "Bytes Write";
|
||||
|
||||
private static final String DefaultForSystemVmsForPodIpRange = "0";
|
||||
private static final String DefaultVlanForPodIpRange = Vlan.UNTAGGED.toString();
|
||||
private static final String DefaultVlanForPodIpRange = Vlan.UNTAGGED;
|
||||
|
||||
private static final Set<Provider> VPC_ONLY_PROVIDERS = Sets.newHashSet(Provider.VPCVirtualRouter, Provider.JuniperContrailVpcRouter, Provider.InternalLbVm);
|
||||
|
||||
@ -643,7 +628,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
_indirectAgentLB.propagateMSListToAgents(false);
|
||||
} else if (settingNameUpdated.equals(Config.RouterAggregationCommandEachTimeout.toString())
|
||||
|| settingNameUpdated.equals(Config.MigrateWait.toString())) {
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put(Config.RouterAggregationCommandEachTimeout.toString(), _configDao.getValue(Config.RouterAggregationCommandEachTimeout.toString()));
|
||||
params.put(Config.MigrateWait.toString(), _configDao.getValue(Config.MigrateWait.toString()));
|
||||
_agentManager.propagateChangeToAgents(params);
|
||||
@ -713,14 +698,14 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
if (mgtCidr == null || mgtCidr.trim().isEmpty()) {
|
||||
final String[] localCidrs = NetUtils.getLocalCidrs();
|
||||
if (localCidrs != null && localCidrs.length > 0) {
|
||||
logger.warn("Management network CIDR is not configured originally. Set it default to " + localCidrs[0]);
|
||||
logger.warn("Management network CIDR is not configured originally. Set it default to {}", localCidrs[0]);
|
||||
|
||||
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_MANAGEMENT_NODE, 0, new Long(0), "Management network CIDR is not configured originally. Set it default to "
|
||||
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_MANAGEMENT_NODE, 0, 0L, "Management network CIDR is not configured originally. Set it default to "
|
||||
+ localCidrs[0], "");
|
||||
_configDao.update(Config.ManagementNetwork.key(), Config.ManagementNetwork.getCategory(), localCidrs[0]);
|
||||
} else {
|
||||
logger.warn("Management network CIDR is not properly configured and we are not able to find a default setting");
|
||||
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_MANAGEMENT_NODE, 0, new Long(0),
|
||||
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_MANAGEMENT_NODE, 0, 0L,
|
||||
"Management network CIDR is not properly configured and we are not able to find a default setting", "");
|
||||
}
|
||||
}
|
||||
@ -728,14 +713,13 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stop() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public String updateConfiguration(final long userId, final String name, final String category, String value, ConfigKey.Scope scope, final Long resourceId) {
|
||||
if (Boolean.class == getConfigurationTypeWrapperClass(name)) {
|
||||
value = value.toLowerCase();
|
||||
}
|
||||
|
||||
final String validationMsg = validateConfigurationValue(name, value, scope);
|
||||
if (validationMsg != null) {
|
||||
logger.error("Invalid value [{}] for configuration [{}] due to [{}].", value, name, validationMsg);
|
||||
@ -865,12 +849,12 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
|
||||
String previousValue = _configDao.getValue(name);
|
||||
if (!_configDao.update(name, category, value)) {
|
||||
logger.error("Failed to update configuration option, name: " + name + ", value:" + value);
|
||||
logger.error("Failed to update configuration option, name: {}, value: {}", name, value);
|
||||
throw new CloudRuntimeException("Failed to update configuration value. Please contact Cloud Support.");
|
||||
}
|
||||
_configDepot.invalidateConfigCache(name, ConfigKey.Scope.Global, null);
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
PreparedStatement pstmt;
|
||||
if (Config.XenServerGuestNetwork.key().equalsIgnoreCase(name)) {
|
||||
final String sql = "update host_details set value=? where name=?";
|
||||
try {
|
||||
@ -934,11 +918,11 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
try {
|
||||
// Change for templates
|
||||
pstmt = txn.prepareAutoCloseStatement(sqlTemplate);
|
||||
pstmt.setDate(1, new Date(-1l));// Set the time before the epoch time.
|
||||
pstmt.setDate(1, new Date(-1L));// Set the time before the epoch time.
|
||||
pstmt.executeUpdate();
|
||||
// Change for volumes
|
||||
pstmt = txn.prepareAutoCloseStatement(sqlVolume);
|
||||
pstmt.setDate(1, new Date(-1l));// Set the time before the epoch time.
|
||||
pstmt.setDate(1, new Date(-1L));// Set the time before the epoch time.
|
||||
pstmt.executeUpdate();
|
||||
// Cleanup the download urls
|
||||
_storageManager.cleanupDownloadUrls();
|
||||
@ -966,8 +950,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
String hypervisors = _configDao.getValue(hypervisorListConfigName);
|
||||
if (Arrays.asList(hypervisors.split(",")).contains(previousValue)) {
|
||||
hypervisors = hypervisors.replace(previousValue, newValue);
|
||||
logger.info(String.format("Updating the hypervisor list configuration '%s' " +
|
||||
"to match the new custom hypervisor display name", hypervisorListConfigName));
|
||||
logger.info("Updating the hypervisor list configuration '{}}' to match the new custom hypervisor display name",
|
||||
hypervisorListConfigName);
|
||||
_configDao.update(hypervisorListConfigName, hypervisors);
|
||||
}
|
||||
}
|
||||
@ -975,7 +959,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_CONFIGURATION_VALUE_EDIT, eventDescription = "updating configuration")
|
||||
public Configuration updateConfiguration(final UpdateCfgCmd cmd) throws InvalidParameterValueException {
|
||||
final Long userId = CallContext.current().getCallingUserId();
|
||||
final long userId = CallContext.current().getCallingUserId();
|
||||
final String name = cmd.getCfgName();
|
||||
String value = cmd.getValue();
|
||||
final Long zoneId = cmd.getZoneId();
|
||||
@ -1004,7 +988,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
// FIX ME - All configuration parameters are not moved from config.java to configKey
|
||||
if (config == null) {
|
||||
if (_configDepot.get(name) == null) {
|
||||
logger.warn("Probably the component manager where configuration variable " + name + " is defined needs to implement Configurable interface");
|
||||
logger.warn("Probably the component manager where configuration variable {} is defined needs to implement Configurable interface", name);
|
||||
throw new InvalidParameterValueException("Config parameter with name " + name + " doesn't exist");
|
||||
}
|
||||
category = _configDepot.get(name).category();
|
||||
@ -1016,7 +1000,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
validateConflictingConfigValue(name, value);
|
||||
|
||||
if (CATEGORY_SYSTEM.equals(category) && !_accountMgr.isRootAdmin(caller.getId())) {
|
||||
logger.warn("Only Root Admin is allowed to edit the configuration " + name);
|
||||
logger.warn("Only Root Admin is allowed to edit the configuration {}", name);
|
||||
throw new CloudRuntimeException("Only Root Admin is allowed to edit this configuration.");
|
||||
}
|
||||
|
||||
@ -1129,7 +1113,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
if (config == null) {
|
||||
configKey = _configDepot.get(name);
|
||||
if (configKey == null) {
|
||||
logger.warn("Probably the component manager where configuration variable " + name + " is defined needs to implement Configurable interface");
|
||||
logger.warn("Probably the component manager where configuration variable {} is defined needs to implement Configurable interface", name);
|
||||
throw new InvalidParameterValueException("Config parameter with name " + name + " doesn't exist");
|
||||
}
|
||||
defaultValue = configKey.defaultValue();
|
||||
@ -1251,7 +1235,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
|
||||
default:
|
||||
if (!_configDao.update(name, category, defaultValue)) {
|
||||
logger.error("Failed to reset configuration option, name: " + name + ", defaultValue:" + defaultValue);
|
||||
logger.error("Failed to reset configuration option, name: {}, defaultValue: {}", name, defaultValue);
|
||||
throw new CloudRuntimeException("Failed to reset configuration value. Please contact Cloud Support.");
|
||||
}
|
||||
optionalValue = Optional.ofNullable(configKey != null ? configKey.value() : _configDao.findByName(name).getValue());
|
||||
@ -1265,7 +1249,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
_configDepot.invalidateConfigCache(name, scope, id);
|
||||
|
||||
CallContext.current().setEventDetails(" Name: " + name + " New Value: " + (name.toLowerCase().contains("password") ? "*****" : defaultValue == null ? "" : defaultValue));
|
||||
return new Pair<Configuration, String>(_configDao.findByName(name), newValue);
|
||||
return new Pair<>(_configDao.findByName(name), newValue);
|
||||
}
|
||||
|
||||
private String getConfigurationValueInScope(ConfigurationVO config, String name, ConfigKey.Scope scope, Long id) {
|
||||
@ -1290,7 +1274,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
protected String validateConfigurationValue(String name, String value, ConfigKey.Scope scope) {
|
||||
final ConfigurationVO cfg = _configDao.findByName(name);
|
||||
if (cfg == null) {
|
||||
logger.error("Missing configuration variable " + name + " in configuration table");
|
||||
logger.error("Missing configuration variable {} in configuration table", name);
|
||||
return "Invalid configuration variable.";
|
||||
}
|
||||
validateConfigurationAllowedOnlyForDefaultAdmin(name, value);
|
||||
@ -1300,23 +1284,14 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
if (!configScope.contains(scope) &&
|
||||
!(ENABLE_ACCOUNT_SETTINGS_FOR_DOMAIN.value() && configScope.contains(ConfigKey.Scope.Account) &&
|
||||
ConfigKey.Scope.Domain.equals(scope))) {
|
||||
logger.error("Invalid scope id provided for the parameter " + name);
|
||||
logger.error("Invalid scope id provided for the parameter {}", name);
|
||||
return "Invalid scope id provided for the parameter " + name;
|
||||
}
|
||||
}
|
||||
Class<?> type;
|
||||
Config configuration = Config.getConfig(name);
|
||||
if (configuration == null) {
|
||||
logger.warn("Did not find configuration " + name + " in Config.java. Perhaps moved to ConfigDepot");
|
||||
ConfigKey<?> configKey = _configDepot.get(name);
|
||||
if(configKey == null) {
|
||||
logger.warn("Did not find configuration " + name + " in ConfigDepot too.");
|
||||
Class<?> type = getConfigurationTypeWrapperClass(name);
|
||||
if (type == null) {
|
||||
return null;
|
||||
}
|
||||
type = configKey.type();
|
||||
} else {
|
||||
type = configuration.getType();
|
||||
}
|
||||
|
||||
validateSpecificConfigurationValues(name, value, type);
|
||||
|
||||
@ -1325,7 +1300,28 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
return String.format("Value [%s] is not a valid [%s].", value, type);
|
||||
}
|
||||
|
||||
return validateValueRange(name, value, type, configuration);
|
||||
return validateValueRange(name, value, type, Config.getConfig(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the configuration type's wrapper class.
|
||||
* @param name name of the configuration.
|
||||
* @return if the configuration exists, returns its type's wrapper class; if not, returns null.
|
||||
*/
|
||||
protected Class<?> getConfigurationTypeWrapperClass(String name) {
|
||||
Config configuration = Config.getConfig(name);
|
||||
if (configuration != null) {
|
||||
return configuration.getType();
|
||||
}
|
||||
|
||||
logger.warn("Did not find configuration [{}] in Config.java. Perhaps moved to ConfigDepot.", name);
|
||||
ConfigKey<?> configKey = _configDepot.get(name);
|
||||
if (configKey == null) {
|
||||
logger.warn("Did not find configuration [{}] in ConfigDepot too.", name);
|
||||
return null;
|
||||
}
|
||||
|
||||
return configKey.type();
|
||||
}
|
||||
|
||||
protected void validateConfigurationAllowedOnlyForDefaultAdmin(String configName, String value) {
|
||||
@ -1362,7 +1358,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
* <ul>
|
||||
* <li>String: any value, including null;</li>
|
||||
* <li>Character: any value, including null;</li>
|
||||
* <li>Boolean: strings that equal "true" or "false" (case-sensitive);</li>
|
||||
* <li>Boolean: strings that equal "true" or "false" (case-insensitive);</li>
|
||||
* <li>Integer, Short, Long: strings that contain a valid int/short/long;</li>
|
||||
* <li>Float, Double: strings that contain a valid float/double, except infinity.</li>
|
||||
* </ul>
|
||||
@ -1584,7 +1580,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
final int max = Integer.parseInt(options[1]);
|
||||
final int val = Integer.parseInt(value);
|
||||
if (val < min || val > max) {
|
||||
logger.error(String.format("Invalid value for configuration [%s]. Please enter a value in the range [%s].", name, range));
|
||||
logger.error("Invalid value for configuration [{}]. Please enter a value in the range [{}].", name, range);
|
||||
return String.format("The provided value is not valid for this configuration. Please enter an integer in the range: [%s]", range);
|
||||
}
|
||||
return null;
|
||||
@ -1594,7 +1590,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
* Checks if the value for the configuration is valid for any of the ranges selected.
|
||||
*/
|
||||
protected String validateIfStringValueIsInRange(String name, String value, String... range) {
|
||||
List<String> message = new ArrayList<String>();
|
||||
List<String> message = new ArrayList<>();
|
||||
String errMessage = "";
|
||||
for (String rangeOption : range) {
|
||||
switch (rangeOption) {
|
||||
@ -1632,9 +1628,9 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
if (NetUtils.isSiteLocalAddress(value)) {
|
||||
return null;
|
||||
}
|
||||
logger.error(String.format("Value [%s] is not a valid private IP range for configuration [%s].", value, name));
|
||||
logger.error("Value [{}] is not a valid private IP range for configuration [{}].", value, name);
|
||||
} catch (final NullPointerException e) {
|
||||
logger.error(String.format("Error while parsing IP address for [%s].", name));
|
||||
logger.error("Error while parsing IP address for [{}].", name);
|
||||
}
|
||||
return "a valid site local IP address";
|
||||
}
|
||||
@ -1690,7 +1686,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
return null;
|
||||
}
|
||||
}
|
||||
logger.error(String.format("Invalid value for configuration [%s].", name));
|
||||
logger.error("Invalid value for configuration [{}].", name);
|
||||
return String.format("a valid value for this configuration (Options are: [%s])", rangeOption);
|
||||
}
|
||||
|
||||
@ -1906,7 +1902,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
}
|
||||
|
||||
String vlanNumberFromUri = getVlanNumberFromUri(vlan);
|
||||
final Integer vlanId = vlanNumberFromUri.equals(Vlan.UNTAGGED.toString()) ? null : Integer.parseInt(vlanNumberFromUri);
|
||||
final Integer vlanId = vlanNumberFromUri.equals(Vlan.UNTAGGED) ? null : Integer.parseInt(vlanNumberFromUri);
|
||||
|
||||
final HostPodVO pod = _podDao.findById(podId);
|
||||
|
||||
@ -2018,7 +2014,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
}
|
||||
});
|
||||
} catch (final Exception e) {
|
||||
logger.error("Unable to create Pod IP range due to " + e.getMessage(), e);
|
||||
logger.error("Unable to create Pod IP range due to {}", e.getMessage(), e);
|
||||
throw new CloudRuntimeException("Failed to create Pod IP range. Please contact Cloud Support.");
|
||||
}
|
||||
|
||||
@ -2336,7 +2332,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
}
|
||||
DataCenterGuestIpv6Prefix dataCenterGuestIpv6Prefix = null;
|
||||
try {
|
||||
dataCenterGuestIpv6Prefix = Transaction.execute(new TransactionCallback<DataCenterGuestIpv6Prefix>() {
|
||||
dataCenterGuestIpv6Prefix = Transaction.execute(new TransactionCallback<>() {
|
||||
@Override
|
||||
public DataCenterGuestIpv6Prefix doInTransaction(TransactionStatus status) {
|
||||
DataCenterGuestIpv6PrefixVO dataCenterGuestIpv6PrefixVO = new DataCenterGuestIpv6PrefixVO(zoneId, prefix);
|
||||
@ -2345,7 +2341,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
}
|
||||
});
|
||||
} catch (final Exception e) {
|
||||
logger.error(String.format("Unable to add IPv6 prefix for zone: %s due to %s", zone, e.getMessage()), e);
|
||||
logger.error("Unable to add IPv6 prefix for zone: {} due to {}", zone, e.getMessage(), e);
|
||||
throw new CloudRuntimeException(String.format("Unable to add IPv6 prefix for zone ID: %s. Please contact Cloud Support.", zone));
|
||||
}
|
||||
return dataCenterGuestIpv6Prefix;
|
||||
@ -2502,7 +2498,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
messageBus.publish(_name, MESSAGE_DELETE_POD_IP_RANGE_EVENT, PublishScope.LOCAL, pod);
|
||||
messageBus.publish(_name, MESSAGE_CREATE_POD_IP_RANGE_EVENT, PublishScope.LOCAL, pod);
|
||||
} catch (final Exception e) {
|
||||
logger.error("Unable to edit pod due to " + e.getMessage(), e);
|
||||
logger.error("Unable to edit pod due to {}", e.getMessage(), e);
|
||||
throw new CloudRuntimeException("Failed to edit pod. Please contact Cloud Support.");
|
||||
}
|
||||
|
||||
@ -2797,7 +2793,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
|
||||
checkIfZoneIsDeletable(zoneId);
|
||||
|
||||
return Transaction.execute(new TransactionCallback<Boolean>() {
|
||||
return Transaction.execute(new TransactionCallback<>() {
|
||||
@Override
|
||||
public Boolean doInTransaction(final TransactionStatus status) {
|
||||
// delete vlans for this zone
|
||||
@ -2861,7 +2857,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
final String networkDomain = cmd.getDomain();
|
||||
final Boolean localStorageEnabled = cmd.getLocalStorageEnabled();
|
||||
|
||||
final Map<String, String> newDetails = new HashMap<String, String>();
|
||||
final Map<String, String> newDetails = new HashMap<>();
|
||||
if (detailsMap != null) {
|
||||
final Collection<?> zoneDetailsCollection = detailsMap.values();
|
||||
final Iterator<?> iter = zoneDetailsCollection.iterator();
|
||||
@ -2976,7 +2972,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
Transaction.execute(new TransactionCallbackNoReturn() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(final TransactionStatus status) {
|
||||
final Map<String, String> updatedDetails = new HashMap<String, String>();
|
||||
final Map<String, String> updatedDetails = new HashMap<>();
|
||||
_zoneDao.loadDetails(zone);
|
||||
if (zone.getDetails() != null) {
|
||||
updatedDetails.putAll(zone.getDetails());
|
||||
@ -3095,7 +3091,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
zoneFinal.setStorageAccessGroups(String.join(",", storageAccessGroups));
|
||||
}
|
||||
|
||||
return Transaction.execute(new TransactionCallback<DataCenterVO>() {
|
||||
return Transaction.execute(new TransactionCallback<>() {
|
||||
@Override
|
||||
public DataCenterVO doInTransaction(final TransactionStatus status) {
|
||||
final DataCenterVO zone = _zoneDao.persist(zoneFinal);
|
||||
@ -3483,7 +3479,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
limitResourceUse, volatileVm, displayText, isSystem, vmType,
|
||||
hostTag, deploymentPlanner, dynamicScalingEnabled, isCustomized);
|
||||
|
||||
List<ServiceOfferingDetailsVO> detailsVOList = new ArrayList<ServiceOfferingDetailsVO>();
|
||||
List<ServiceOfferingDetailsVO> detailsVOList = new ArrayList<>();
|
||||
if (details != null) {
|
||||
// To have correct input, either both gpu card name and VGPU type should be passed or nothing should be passed.
|
||||
// Use XOR condition to verify that.
|
||||
@ -4189,28 +4185,28 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
* </ul>
|
||||
*/
|
||||
protected void validateMaximumIopsAndBytesLength(final Long iopsReadRateMaxLength, final Long iopsWriteRateMaxLength, Long bytesReadRateMaxLength, Long bytesWriteRateMaxLength) {
|
||||
if (IOPS_MAX_READ_LENGTH.value() != null && IOPS_MAX_READ_LENGTH.value() != 0l) {
|
||||
if (IOPS_MAX_READ_LENGTH.value() != null && IOPS_MAX_READ_LENGTH.value() != 0L) {
|
||||
if (iopsReadRateMaxLength != null && iopsReadRateMaxLength > IOPS_MAX_READ_LENGTH.value()) {
|
||||
throw new InvalidParameterValueException(String.format("IOPS read max length (%d seconds) cannot be greater than vm.disk.iops.maximum.read.length (%d seconds)",
|
||||
iopsReadRateMaxLength, IOPS_MAX_READ_LENGTH.value()));
|
||||
}
|
||||
}
|
||||
|
||||
if (IOPS_MAX_WRITE_LENGTH.value() != null && IOPS_MAX_WRITE_LENGTH.value() != 0l) {
|
||||
if (IOPS_MAX_WRITE_LENGTH.value() != null && IOPS_MAX_WRITE_LENGTH.value() != 0L) {
|
||||
if (iopsWriteRateMaxLength != null && iopsWriteRateMaxLength > IOPS_MAX_WRITE_LENGTH.value()) {
|
||||
throw new InvalidParameterValueException(String.format("IOPS write max length (%d seconds) cannot be greater than vm.disk.iops.maximum.write.length (%d seconds)",
|
||||
iopsWriteRateMaxLength, IOPS_MAX_WRITE_LENGTH.value()));
|
||||
}
|
||||
}
|
||||
|
||||
if (BYTES_MAX_READ_LENGTH.value() != null && BYTES_MAX_READ_LENGTH.value() != 0l) {
|
||||
if (BYTES_MAX_READ_LENGTH.value() != null && BYTES_MAX_READ_LENGTH.value() != 0L) {
|
||||
if (bytesReadRateMaxLength != null && bytesReadRateMaxLength > BYTES_MAX_READ_LENGTH.value()) {
|
||||
throw new InvalidParameterValueException(String.format("Bytes read max length (%d seconds) cannot be greater than vm.disk.bytes.maximum.read.length (%d seconds)",
|
||||
bytesReadRateMaxLength, BYTES_MAX_READ_LENGTH.value()));
|
||||
}
|
||||
}
|
||||
|
||||
if (BYTES_MAX_WRITE_LENGTH.value() != null && BYTES_MAX_WRITE_LENGTH.value() != 0l) {
|
||||
if (BYTES_MAX_WRITE_LENGTH.value() != null && BYTES_MAX_WRITE_LENGTH.value() != 0L) {
|
||||
if (bytesWriteRateMaxLength != null && bytesWriteRateMaxLength > BYTES_MAX_WRITE_LENGTH.value()) {
|
||||
throw new InvalidParameterValueException(String.format("Bytes write max length (%d seconds) cannot be greater than vm.disk.bytes.maximum.write.length (%d seconds)",
|
||||
bytesWriteRateMaxLength, BYTES_MAX_WRITE_LENGTH.value()));
|
||||
@ -4958,7 +4954,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
commitVlanLock.lock(5);
|
||||
logger.debug("Acquiring lock for committing vlan");
|
||||
try {
|
||||
Vlan vlan = Transaction.execute(new TransactionCallback<Vlan>() {
|
||||
Vlan vlan = Transaction.execute(new TransactionCallback<>() {
|
||||
@Override
|
||||
public Vlan doInTransaction(final TransactionStatus status) {
|
||||
String newVlanNetmask = newVlanNetmaskFinal;
|
||||
@ -5049,16 +5045,16 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
Pair<String, String> vlanDetails = null;
|
||||
|
||||
if (sameSubnet) {
|
||||
vlanDetails = new Pair<String, String>(vlanGateway, vlanNetmask);
|
||||
vlanDetails = new Pair<>(vlanGateway, vlanNetmask);
|
||||
} else {
|
||||
vlanDetails = new Pair<String, String>(newVlanGateway, newVlanNetmask);
|
||||
vlanDetails = new Pair<>(newVlanGateway, newVlanNetmask);
|
||||
}
|
||||
// check if the gatewayip is the part of the ip range being added.
|
||||
if (ipv4 && NetUtils.ipRangesOverlap(startIP, endIP, vlanDetails.first(), vlanDetails.first())) {
|
||||
throw new InvalidParameterValueException("The gateway ip should not be the part of the ip range being added.");
|
||||
}
|
||||
|
||||
return new Pair<Boolean, Pair<String, String>>(sameSubnet, vlanDetails);
|
||||
return new Pair<>(sameSubnet, vlanDetails);
|
||||
}
|
||||
|
||||
public boolean hasSameSubnet(boolean ipv4, String vlanGateway, String vlanNetmask, String newVlanGateway, String newVlanNetmask, String newStartIp, String newEndIp,
|
||||
@ -5389,7 +5385,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
private VlanVO commitVlanAndIpRange(final long zoneId, final long networkId, final long physicalNetworkId, final Long podId, final String startIP, final String endIP,
|
||||
final String vlanGateway, final String vlanNetmask, final String vlanId, final Domain domain, final Account vlanOwner, final String vlanIp6Gateway, final String vlanIp6Cidr,
|
||||
final boolean ipv4, final DataCenterVO zone, final VlanType vlanType, final String ipv6Range, final String ipRange, final boolean forSystemVms, final boolean forNsx) {
|
||||
return Transaction.execute(new TransactionCallback<VlanVO>() {
|
||||
return Transaction.execute(new TransactionCallback<>() {
|
||||
@Override
|
||||
public VlanVO doInTransaction(final TransactionStatus status) {
|
||||
VlanVO vlan = new VlanVO(vlanType, vlanId, vlanGateway, vlanNetmask, zone.getId(), ipRange, networkId, physicalNetworkId, vlanIp6Gateway, vlanIp6Cidr, ipv6Range);
|
||||
@ -5624,7 +5620,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
final String gateway, final String netmask,
|
||||
final boolean ipv4, final Boolean isRangeForSystemVM, final Boolean forSystemvms) {
|
||||
|
||||
return Transaction.execute(new TransactionCallback<VlanVO>() {
|
||||
return Transaction.execute(new TransactionCallback<>() {
|
||||
@Override
|
||||
public VlanVO doInTransaction(final TransactionStatus status) {
|
||||
VlanVO vlanRange = _vlanDao.findById(id);
|
||||
@ -5976,7 +5972,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
final long allocIpCount = _publicIpAddressDao.countIPs(vlan.getDataCenterId(), vlanDbId, true);
|
||||
final List<IPAddressVO> ips = _publicIpAddressDao.listByVlanId(vlanDbId);
|
||||
boolean success = true;
|
||||
final List<IPAddressVO> ipsInUse = new ArrayList<IPAddressVO>();
|
||||
final List<IPAddressVO> ipsInUse = new ArrayList<>();
|
||||
if (allocIpCount > 0) {
|
||||
try {
|
||||
vlan = _vlanDao.acquireInLockTable(vlanDbId, 30);
|
||||
@ -6033,7 +6029,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
final long startIPLong = NetUtils.ip2Long(startIP);
|
||||
final long endIPLong = NetUtils.ip2Long(endIP);
|
||||
|
||||
final List<String> problemIps = Transaction.execute(new TransactionCallback<List<String>>() {
|
||||
final List<String> problemIps = Transaction.execute(new TransactionCallback<>() {
|
||||
@Override
|
||||
public List<String> doInTransaction(final TransactionStatus status) {
|
||||
final IPRangeConfig config = new IPRangeConfig();
|
||||
@ -6062,7 +6058,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
currentStartIPLong++;
|
||||
}
|
||||
|
||||
final List<String> problemIps = Transaction.execute(new TransactionCallback<List<String>>() {
|
||||
final List<String> problemIps = Transaction.execute(new TransactionCallback<>() {
|
||||
|
||||
@Override
|
||||
public List<String> doInTransaction(final TransactionStatus status) {
|
||||
@ -6182,7 +6178,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
skipPod = podIdToBeSkipped;
|
||||
}
|
||||
final HashMap<Long, List<Object>> currentPodCidrSubnets = _podDao.getCurrentPodCidrSubnets(dcId, skipPod);
|
||||
final List<Object> newCidrPair = new ArrayList<Object>();
|
||||
final List<Object> newCidrPair = new ArrayList<>();
|
||||
newCidrPair.add(0, getCidrAddress(cidr));
|
||||
newCidrPair.add(1, (long)getCidrSize(cidr));
|
||||
currentPodCidrSubnets.put(new Long(-1), newCidrPair);
|
||||
@ -6494,8 +6490,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
NetworkOffering.RoutingMode routingMode = verifyRoutingMode(routingModeString);
|
||||
|
||||
// configure service provider map
|
||||
final Map<Network.Service, Set<Network.Provider>> serviceProviderMap = new HashMap<Network.Service, Set<Network.Provider>>();
|
||||
final Set<Network.Provider> defaultProviders = new HashSet<Network.Provider>();
|
||||
final Map<Network.Service, Set<Network.Provider>> serviceProviderMap = new HashMap<>();
|
||||
final Set<Network.Provider> defaultProviders = new HashSet<>();
|
||||
|
||||
// populate the services first
|
||||
for (final String serviceName : cmd.getSupportedServices()) {
|
||||
@ -6518,7 +6514,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
if (guestType != GuestType.Shared) {
|
||||
throw new InvalidParameterValueException("Security group service is supported for network offerings with guest ip type " + GuestType.Shared);
|
||||
}
|
||||
final Set<Network.Provider> sgProviders = new HashSet<Network.Provider>();
|
||||
final Set<Network.Provider> sgProviders = new HashSet<>();
|
||||
sgProviders.add(Provider.SecurityGroupProvider);
|
||||
serviceProviderMap.put(Network.Service.SecurityGroup, sgProviders);
|
||||
continue;
|
||||
@ -6534,7 +6530,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
}
|
||||
|
||||
// populate providers
|
||||
final Map<Provider, Set<Service>> providerCombinationToVerify = new HashMap<Provider, Set<Service>>();
|
||||
final Map<Provider, Set<Service>> providerCombinationToVerify = new HashMap<>();
|
||||
final Map<String, List<String>> svcPrv = cmd.getServiceProviders();
|
||||
Provider firewallProvider = null;
|
||||
Provider dhcpProvider = null;
|
||||
@ -6543,7 +6539,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
for (final String serviceStr : svcPrv.keySet()) {
|
||||
final Network.Service service = Network.Service.getService(serviceStr);
|
||||
if (serviceProviderMap.containsKey(service)) {
|
||||
final Set<Provider> providers = new HashSet<Provider>();
|
||||
final Set<Provider> providers = new HashSet<>();
|
||||
// Allow to specify more than 1 provider per service only if
|
||||
// the service is LB
|
||||
if (!serviceStr.equalsIgnoreCase(Service.Lb.getName()) && svcPrv.get(serviceStr) != null && svcPrv.get(serviceStr).size() > 1) {
|
||||
@ -6588,7 +6584,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
|
||||
Set<Service> serviceSet = null;
|
||||
if (providerCombinationToVerify.get(provider) == null) {
|
||||
serviceSet = new HashSet<Service>();
|
||||
serviceSet = new HashSet<>();
|
||||
} else {
|
||||
serviceSet = providerCombinationToVerify.get(provider);
|
||||
}
|
||||
@ -6656,7 +6652,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
}
|
||||
validateConnectivityServiceCapablities(guestType, serviceProviderMap.get(Service.Connectivity), connectivityServiceCapabilityMap);
|
||||
|
||||
final Map<Service, Map<Capability, String>> serviceCapabilityMap = new HashMap<Service, Map<Capability, String>>();
|
||||
final Map<Service, Map<Capability, String>> serviceCapabilityMap = new HashMap<>();
|
||||
serviceCapabilityMap.put(Service.Lb, lbServiceCapabilityMap);
|
||||
serviceCapabilityMap.put(Service.SourceNat, sourceNatServiceCapabilityMap);
|
||||
serviceCapabilityMap.put(Service.StaticNat, staticNatServiceCapabilityMap);
|
||||
@ -6671,7 +6667,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
// combination
|
||||
if (firewallProvider != null) {
|
||||
logger.debug("Adding Firewall service with provider " + firewallProvider.getName());
|
||||
final Set<Provider> firewallProviderSet = new HashSet<Provider>();
|
||||
final Set<Provider> firewallProviderSet = new HashSet<>();
|
||||
firewallProviderSet.add(firewallProvider);
|
||||
serviceProviderMap.put(Service.Firewall, firewallProviderSet);
|
||||
if (!(firewallProvider.getName().equals(Provider.JuniperSRX.getName()) || firewallProvider.getName().equals(Provider.PaloAlto.getName()) || firewallProvider.getName()
|
||||
@ -6681,7 +6677,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
}
|
||||
}
|
||||
|
||||
final Map<NetworkOffering.Detail, String> details = new HashMap<NetworkOffering.Detail, String>();
|
||||
final Map<NetworkOffering.Detail, String> details = new HashMap<>();
|
||||
if (detailsStr != null) {
|
||||
for (final String detailStr : detailsStr.keySet()) {
|
||||
NetworkOffering.Detail offDetail = null;
|
||||
@ -7145,7 +7141,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
}
|
||||
}
|
||||
|
||||
return Transaction.execute(new TransactionCallback<NetworkOfferingVO>() {
|
||||
return Transaction.execute(new TransactionCallback<>() {
|
||||
@Override
|
||||
public NetworkOfferingVO doInTransaction(final TransactionStatus status) {
|
||||
NetworkOfferingVO offering = offeringFinal;
|
||||
@ -7171,7 +7167,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
}
|
||||
|
||||
if (vpcOff && !forNsx) {
|
||||
final List<Service> supportedSvcs = new ArrayList<Service>();
|
||||
final List<Service> supportedSvcs = new ArrayList<>();
|
||||
supportedSvcs.addAll(serviceProviderMap.keySet());
|
||||
_vpcMgr.validateNtwkOffForVpc(offering, supportedSvcs);
|
||||
}
|
||||
@ -7255,7 +7251,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
}
|
||||
|
||||
// 2) validate if the provider supports the scheme
|
||||
final Set<Provider> lbProviders = new HashSet<Provider>();
|
||||
final Set<Provider> lbProviders = new HashSet<>();
|
||||
lbProviders.add(lbProvider);
|
||||
if (detail == NetworkOffering.Detail.InternalLbProvider) {
|
||||
_networkModel.checkCapabilityForProvider(lbProviders, Service.Lb, Capability.LbSchemes, Scheme.Internal.toString());
|
||||
@ -7361,7 +7357,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
if (zone.getNetworkType() == NetworkType.Basic) {
|
||||
// return empty list as we don't allow to create networks in
|
||||
// basic zone, and shouldn't display networkOfferings
|
||||
return new Pair<List<? extends NetworkOffering>, Integer>(new ArrayList<NetworkOffering>(), 0);
|
||||
return new Pair<>(new ArrayList<>(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7394,7 +7390,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
if (!offeringIds.isEmpty()) {
|
||||
sc.addAnd("id", SearchCriteria.Op.IN, offeringIds.toArray());
|
||||
} else {
|
||||
return new Pair<List<? extends NetworkOffering>, Integer>(new ArrayList<NetworkOffering>(), 0);
|
||||
return new Pair<>(new ArrayList<>(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7446,7 +7442,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
}
|
||||
}
|
||||
final Boolean sourceNatSupported = cmd.getSourceNatSupported();
|
||||
final List<String> pNtwkTags = new ArrayList<String>();
|
||||
final List<String> pNtwkTags = new ArrayList<>();
|
||||
boolean checkForTags = false;
|
||||
boolean allowNullTag = false;
|
||||
if (zone != null) {
|
||||
@ -7479,7 +7475,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
|
||||
for (final NetworkOfferingJoinVO offering : offerings) {
|
||||
boolean addOffering = true;
|
||||
List<Service> checkForProviders = new ArrayList<Service>();
|
||||
List<Service> checkForProviders = new ArrayList<>();
|
||||
|
||||
if (checkForTags && !checkNetworkOfferingTags(pNtwkTags, allowNullTag, offering.getTags())) {
|
||||
continue;
|
||||
@ -7518,17 +7514,17 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
// Now apply pagination
|
||||
final List<NetworkOfferingJoinVO> wPagination = com.cloud.utils.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());
|
||||
final Pair<List<? extends NetworkOffering>, Integer> listWPagination = new Pair<>(wPagination, supportedOfferings.size());
|
||||
return listWPagination;
|
||||
}
|
||||
return new Pair<List<? extends NetworkOffering>, Integer>(supportedOfferings, supportedOfferings.size());
|
||||
return new Pair<>(supportedOfferings, supportedOfferings.size());
|
||||
} else {
|
||||
final List<NetworkOfferingJoinVO> wPagination = com.cloud.utils.StringUtils.applyPagination(offerings, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
if (wPagination != null) {
|
||||
final Pair<List<? extends NetworkOffering>, Integer> listWPagination = new Pair<>(wPagination, offerings.size());
|
||||
return listWPagination;
|
||||
}
|
||||
return new Pair<List<? extends NetworkOffering>, Integer>(offerings, offerings.size());
|
||||
return new Pair<>(offerings, offerings.size());
|
||||
}
|
||||
}
|
||||
|
||||
@ -8157,7 +8153,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
final Integer regionId = cmd.getRegionIdId();
|
||||
final Long rangeId = cmd.getPortableIpRangeId();
|
||||
|
||||
final List<PortableIpRangeVO> ranges = new ArrayList<PortableIpRangeVO>();
|
||||
final List<PortableIpRangeVO> ranges = new ArrayList<>();
|
||||
if (regionId != null) {
|
||||
final Region region = _regionDao.findById(regionId);
|
||||
if (region == null) {
|
||||
@ -8282,11 +8278,17 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a string representing the specified configuration's type.
|
||||
* @param configName name of the configuration.
|
||||
* @return if the configuration exists, returns its type; if not, returns {@link Configuration.ValueType#String}.
|
||||
*/
|
||||
@Override
|
||||
public String getConfigurationType(final String configName) {
|
||||
final ConfigurationVO cfg = _configDao.findByName(configName);
|
||||
if (cfg == null) {
|
||||
logger.warn("Configuration " + configName + " not found");
|
||||
logger.warn("Configuration [{}] not found", configName);
|
||||
return Configuration.ValueType.String.name();
|
||||
}
|
||||
|
||||
@ -8294,24 +8296,14 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
return Configuration.ValueType.Range.name();
|
||||
}
|
||||
|
||||
Class<?> type = null;
|
||||
final Config c = Config.getConfig(configName);
|
||||
if (c == null) {
|
||||
logger.warn("Configuration " + configName + " no found. Perhaps moved to ConfigDepot");
|
||||
final ConfigKey<?> configKey = _configDepot.get(configName);
|
||||
if (configKey == null) {
|
||||
logger.warn("Couldn't find configuration " + configName + " in ConfigDepot too.");
|
||||
return Configuration.ValueType.String.name();
|
||||
}
|
||||
type = configKey.type();
|
||||
} else {
|
||||
type = c.getType();
|
||||
Class<?> type = getConfigurationTypeWrapperClass(configName);
|
||||
return parseConfigurationTypeIntoString(type, cfg);
|
||||
}
|
||||
|
||||
return getInputType(type, cfg);
|
||||
}
|
||||
|
||||
private String getInputType(Class<?> type, ConfigurationVO cfg) {
|
||||
/**
|
||||
* Parses a configuration type's wrapper class into its string representation.
|
||||
*/
|
||||
protected String parseConfigurationTypeIntoString(Class<?> type, ConfigurationVO cfg) {
|
||||
if (type == null) {
|
||||
return Configuration.ValueType.String.name();
|
||||
}
|
||||
@ -8358,13 +8350,12 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
groupName = configGroup.getName();
|
||||
}
|
||||
|
||||
return new Pair<String, String>(groupName, subGroupName);
|
||||
return new Pair<>(groupName, subGroupName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ConfigurationSubGroupVO> getConfigurationSubGroups(final Long groupId) {
|
||||
List<ConfigurationSubGroupVO> configSubGroups = _configSubGroupDao.findByGroup(groupId);
|
||||
return configSubGroups;
|
||||
return _configSubGroupDao.findByGroup(groupId);
|
||||
}
|
||||
|
||||
static class ParamCountPair {
|
||||
@ -8390,10 +8381,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
return paramCount;
|
||||
}
|
||||
|
||||
public void setParamCount(int paramCount) {
|
||||
this.paramCount = paramCount;
|
||||
}
|
||||
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
@ -265,6 +265,7 @@ import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionCallbackNoReturn;
|
||||
import com.cloud.utils.db.TransactionCallbackWithExceptionNoReturn;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
import com.cloud.utils.db.TransactionStatus;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
@ -1834,6 +1835,9 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
||||
if (exceptionOccurred.get()) {
|
||||
return null;
|
||||
}
|
||||
Transaction.execute(new TransactionCallbackWithExceptionNoReturn<Exception>() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(TransactionStatus status) throws Exception {
|
||||
HostVO host = _hostDao.findById(hostId);
|
||||
try {
|
||||
connectHostToSharedPool(host, primaryStore.getId());
|
||||
@ -1850,6 +1854,8 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
||||
throw new CloudRuntimeException(reason);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}));
|
||||
}
|
||||
|
||||
@ -2435,6 +2435,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
||||
throw new InvalidParameterValueException("Going from existing size of " + currentSize + " to size of " + newSize + " would shrink the volume."
|
||||
+ "Need to sign off by supplying the shrinkok parameter with value of true.");
|
||||
}
|
||||
if (ApiDBUtils.getHypervisorTypeFromFormat(volume.getDataCenterId(), volume.getFormat()) == HypervisorType.XenServer) {
|
||||
throw new InvalidParameterValueException("Shrink volume is not supported for the XenServer hypervisor.");
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Check resource limit for this account */
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
// under the License.
|
||||
package com.cloud.configuration;
|
||||
|
||||
import com.cloud.alert.AlertManager;
|
||||
import com.cloud.capacity.dao.CapacityDao;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.VlanVO;
|
||||
@ -53,6 +54,7 @@ import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
import org.apache.cloudstack.acl.RoleService;
|
||||
import org.apache.cloudstack.annotation.dao.AnnotationDao;
|
||||
import org.apache.cloudstack.api.command.admin.config.ResetCfgCmd;
|
||||
import org.apache.cloudstack.api.command.admin.network.CreateNetworkOfferingCmd;
|
||||
@ -930,4 +932,113 @@ public class ConfigurationManagerImplTest {
|
||||
configurationManagerImplSpy.validateConfigurationAllowedOnlyForDefaultAdmin(AccountManagerImpl.listOfRoleTypesAllowedForOperationsOfSameRoleType.key(), invalidValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getConfigurationTypeWrapperClassTestReturnsConfigType() {
|
||||
Config configuration = Config.AlertEmailAddresses;
|
||||
|
||||
Assert.assertEquals(configuration.getType(), configurationManagerImplSpy.getConfigurationTypeWrapperClass(configuration.key()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getConfigurationTypeWrapperClassTestReturnsConfigKeyType() {
|
||||
String configurationName = "configuration.name";
|
||||
|
||||
Mockito.when(configDepot.get(configurationName)).thenReturn(configKeyMock);
|
||||
Mockito.when(configKeyMock.type()).thenReturn(Integer.class);
|
||||
|
||||
Assert.assertEquals(Integer.class, configurationManagerImplSpy.getConfigurationTypeWrapperClass(configurationName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getConfigurationTypeWrapperClassTestReturnsNullWhenConfigurationDoesNotExist() {
|
||||
String configurationName = "configuration.name";
|
||||
|
||||
Mockito.when(configDepot.get(configurationName)).thenReturn(null);
|
||||
Assert.assertNull(configurationManagerImplSpy.getConfigurationTypeWrapperClass(configurationName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseConfigurationTypeIntoStringTestReturnsStringWhenTypeIsNull() {
|
||||
Assert.assertEquals(Configuration.ValueType.String.name(), configurationManagerImplSpy.parseConfigurationTypeIntoString(null, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseConfigurationTypeIntoStringTestReturnsStringWhenTypeIsStringAndConfigurationKindIsNull() {
|
||||
Mockito.when(configurationVOMock.getKind()).thenReturn(null);
|
||||
Assert.assertEquals(Configuration.ValueType.String.name(), configurationManagerImplSpy.parseConfigurationTypeIntoString(String.class, configurationVOMock));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseConfigurationTypeIntoStringTestReturnsKindWhenTypeIsStringAndKindIsNotNull() {
|
||||
Mockito.when(configurationVOMock.getKind()).thenReturn(ConfigKey.Kind.CSV.name());
|
||||
Assert.assertEquals(ConfigKey.Kind.CSV.name(), configurationManagerImplSpy.parseConfigurationTypeIntoString(String.class, configurationVOMock));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseConfigurationTypeIntoStringTestReturnsKindWhenTypeIsCharacterAndKindIsNotNull() {
|
||||
Mockito.when(configurationVOMock.getKind()).thenReturn(ConfigKey.Kind.CSV.name());
|
||||
Assert.assertEquals(ConfigKey.Kind.CSV.name(), configurationManagerImplSpy.parseConfigurationTypeIntoString(Character.class, configurationVOMock));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseConfigurationTypeIntoStringTestReturnsNumberWhenTypeIsInteger() {
|
||||
Assert.assertEquals(Configuration.ValueType.Number.name(), configurationManagerImplSpy.parseConfigurationTypeIntoString(Integer.class, configurationVOMock));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseConfigurationTypeIntoStringTestReturnsNumberWhenTypeIsLong() {
|
||||
Assert.assertEquals(Configuration.ValueType.Number.name(), configurationManagerImplSpy.parseConfigurationTypeIntoString(Long.class, configurationVOMock));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseConfigurationTypeIntoStringTestReturnsNumberWhenTypeIsShort() {
|
||||
Assert.assertEquals(Configuration.ValueType.Number.name(), configurationManagerImplSpy.parseConfigurationTypeIntoString(Short.class, configurationVOMock));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseConfigurationTypeIntoStringTestReturnsDecimalWhenTypeIsFloat() {
|
||||
Assert.assertEquals(Configuration.ValueType.Decimal.name(), configurationManagerImplSpy.parseConfigurationTypeIntoString(Float.class, configurationVOMock));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseConfigurationTypeIntoStringTestReturnsDecimalWhenTypeIsDouble() {
|
||||
Assert.assertEquals(Configuration.ValueType.Decimal.name(), configurationManagerImplSpy.parseConfigurationTypeIntoString(Double.class, configurationVOMock));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseConfigurationTypeIntoStringTestReturnsBooleanWhenTypeIsBoolean() {
|
||||
Assert.assertEquals(Configuration.ValueType.Boolean.name(), configurationManagerImplSpy.parseConfigurationTypeIntoString(Boolean.class, configurationVOMock));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseConfigurationTypeIntoStringTestReturnsStringWhenTypeDoesNotMatchAnyAvailableType() {
|
||||
Assert.assertEquals(Configuration.ValueType.String.name(), configurationManagerImplSpy.parseConfigurationTypeIntoString(Object.class, configurationVOMock));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getConfigurationTypeTestReturnsStringWhenConfigurationDoesNotExist() {
|
||||
Mockito.when(configDao.findByName(Mockito.anyString())).thenReturn(null);
|
||||
Assert.assertEquals(Configuration.ValueType.String.name(), configurationManagerImplSpy.getConfigurationType(Mockito.anyString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getConfigurationTypeTestReturnsRangeForConfigurationsThatAcceptIntervals() {
|
||||
String configurationName = AlertManager.CPUCapacityThreshold.key();
|
||||
|
||||
Mockito.when(configDao.findByName(configurationName)).thenReturn(configurationVOMock);
|
||||
Assert.assertEquals(Configuration.ValueType.Range.name(), configurationManagerImplSpy.getConfigurationType(configurationName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getConfigurationTypeTestReturnsStringRepresentingConfigurationType() {
|
||||
ConfigKey<Boolean> configuration = RoleService.EnableDynamicApiChecker;
|
||||
|
||||
Mockito.when(configDao.findByName(configuration.key())).thenReturn(configurationVOMock);
|
||||
Mockito.doReturn(configuration.type()).when(configurationManagerImplSpy).getConfigurationTypeWrapperClass(configuration.key());
|
||||
|
||||
configurationManagerImplSpy.getConfigurationType(configuration.key());
|
||||
Mockito.verify(configurationManagerImplSpy).parseConfigurationTypeIntoString(configuration.type(), configurationVOMock);
|
||||
}
|
||||
}
|
||||
|
||||
@ -398,7 +398,7 @@ CREATE TABLE `cloud`.`op_lock` (
|
||||
`waiters` int NOT NULL DEFAULT 0 COMMENT 'How many have the thread acquired this lock (reentrant)',
|
||||
PRIMARY KEY (`key`),
|
||||
INDEX `i_op_lock__mac_ip_thread`(`mac`, `ip`, `thread`)
|
||||
) ENGINE=Memory DEFAULT CHARSET=utf8;
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `cloud`.`configuration` (
|
||||
`category` varchar(255) NOT NULL DEFAULT 'Advanced',
|
||||
@ -1793,7 +1793,7 @@ CREATE TABLE `cloud`.`op_nwgrp_work` (
|
||||
INDEX `i_op_nwgrp_work__taken`(`taken`),
|
||||
INDEX `i_op_nwgrp_work__step`(`step`),
|
||||
INDEX `i_op_nwgrp_work__seq_no`(`seq_no`)
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=utf8;
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `cloud`.`op_vm_ruleset_log` (
|
||||
`id` bigint unsigned UNIQUE NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||
|
||||
@ -1037,7 +1037,7 @@
|
||||
"label.forcks": "For CKS",
|
||||
"label.forbidden": "Forbidden",
|
||||
"label.forced": "Force",
|
||||
"label.force.ms.to.import.vm.files": "Force MS to export OVF from VMware to temporary storage",
|
||||
"label.force.ms.to.import.vm.files": "Enable to force OVF Download via Management Server. Disable to use KVM Host ovftool (if installed)",
|
||||
"label.force.stop": "Force stop",
|
||||
"label.force.reboot": "Force reboot",
|
||||
"label.forceencap": "Force UDP encapsulation of ESP packets",
|
||||
@ -1123,7 +1123,9 @@
|
||||
"label.host": "IP address",
|
||||
"label.host.alerts": "Hosts in alert state",
|
||||
"label.host.name": "Host name",
|
||||
"label.host.ovftool.version": "OVFTool Version",
|
||||
"label.host.tag": "Host tag",
|
||||
"label.host.virtv2v.version": "Virt-v2v Version",
|
||||
"label.hostcontrolstate": "Compute Resource Status",
|
||||
"label.hostid": "Host",
|
||||
"label.hostname": "Host",
|
||||
|
||||
@ -107,7 +107,7 @@ export const QUOTA_TYPES = [
|
||||
},
|
||||
{
|
||||
id: 29,
|
||||
type: 'VPC'
|
||||
type: 'BUCKET'
|
||||
},
|
||||
{
|
||||
id: 30,
|
||||
@ -115,7 +115,7 @@ export const QUOTA_TYPES = [
|
||||
},
|
||||
{
|
||||
id: 31,
|
||||
type: 'BACKUP_OBJECT'
|
||||
type: 'VPC'
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@ -56,6 +56,22 @@
|
||||
</div>
|
||||
</div>
|
||||
</a-list-item>
|
||||
<a-list-item v-if="host.details && host.details['host.virtv2v.version']">
|
||||
<div>
|
||||
<strong>{{ $t('label.host.virtv2v.version') }}</strong>
|
||||
<div>
|
||||
{{ host.details['host.virtv2v.version'] }}
|
||||
</div>
|
||||
</div>
|
||||
</a-list-item>
|
||||
<a-list-item v-if="host.details && host.details['host.ovftool.version']">
|
||||
<div>
|
||||
<strong>{{ $t('label.host.ovftool.version') }}</strong>
|
||||
<div>
|
||||
{{ host.details['host.ovftool.version'] }}
|
||||
</div>
|
||||
</div>
|
||||
</a-list-item>
|
||||
<a-list-item v-if="host.hosttags">
|
||||
<div>
|
||||
<strong>{{ $t('label.hosttags') }}</strong>
|
||||
|
||||
@ -90,7 +90,7 @@
|
||||
:checked="autoMigrate"
|
||||
@change="val => { autoMigrate = val }"/>
|
||||
</a-form-item>
|
||||
<a-form-item name="shrinkOk" ref="shrinkOk" :label="$t('label.shrinkok')">
|
||||
<a-form-item name="shrinkOk" ref="shrinkOk" :label="$t('label.shrinkok')" v-if="!['XenServer'].includes(resource.hypervisor)">
|
||||
<a-switch
|
||||
v-model:checked="form.shrinkOk"
|
||||
:checked="shrinkOk"
|
||||
|
||||
@ -944,6 +944,12 @@ export default {
|
||||
} else {
|
||||
host.name = host.name + ' (' + this.$t('label.not.supported') + ')'
|
||||
}
|
||||
if (host.details['host.virtv2v.version']) {
|
||||
host.name = host.name + ' (virt-v2v=' + host.details['host.virtv2v.version'] + ')'
|
||||
}
|
||||
if (host.details['host.ovftool.version']) {
|
||||
host.name = host.name + ' (ovftool=' + host.details['host.ovftool.version'] + ')'
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user