Merge branch '4.20'

This commit is contained in:
Daan Hoogland 2025-07-03 15:29:05 +02:00
commit 3e3a0c0678
18 changed files with 424 additions and 190 deletions

View File

@ -53,9 +53,12 @@ public interface Host extends StateObject<Status>, Identity, Partition, HAResour
return strs; return strs;
} }
} }
public static final String HOST_UEFI_ENABLE = "host.uefi.enable";
public static final String HOST_VOLUME_ENCRYPTION = "host.volume.encryption"; String HOST_UEFI_ENABLE = "host.uefi.enable";
public static final String HOST_INSTANCE_CONVERSION = "host.instance.conversion"; 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. * @return name of the machine.

View File

@ -62,6 +62,7 @@ import org.apache.cloudstack.utils.identity.ManagementServerNode;
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils; import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.ThreadContext; import org.apache.logging.log4j.ThreadContext;
@ -801,11 +802,25 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
Map<String, String> detailsMap = readyAnswer.getDetailsMap(); Map<String, String> detailsMap = readyAnswer.getDetailsMap();
if (detailsMap != null) { if (detailsMap != null) {
String uefiEnabled = detailsMap.get(Host.HOST_UEFI_ENABLE); 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); logger.debug("Got HOST_UEFI_ENABLE [{}] for host [{}]:", uefiEnabled, host);
if (uefiEnabled != null) { if (ObjectUtils.anyNotNull(uefiEnabled, virtv2vVersion, ovftoolVersion)) {
_hostDao.loadDetails(host); _hostDao.loadDetails(host);
boolean updateNeeded = false;
if (!uefiEnabled.equals(host.getDetails().get(Host.HOST_UEFI_ENABLE))) { if (!uefiEnabled.equals(host.getDetails().get(Host.HOST_UEFI_ENABLE))) {
host.getDetails().put(Host.HOST_UEFI_ENABLE, uefiEnabled); 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); _hostDao.saveDetails(host);
} }
} }

View File

@ -17,6 +17,8 @@
package com.cloud.hypervisor.kvm.resource; package com.cloud.hypervisor.kvm.resource;
import static com.cloud.host.Host.HOST_INSTANCE_CONVERSION; 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 com.cloud.host.Host.HOST_VOLUME_ENCRYPTION;
import static org.apache.cloudstack.utils.linux.KVMHostInfo.isHostS390x; import static org.apache.cloudstack.utils.linux.KVMHostInfo.isHostS390x;
@ -3908,7 +3910,14 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
cmd.setIqn(getIqn()); cmd.setIqn(getIqn());
cmd.getHostDetails().put(HOST_VOLUME_ENCRYPTION, String.valueOf(hostSupportsVolumeEncryption())); cmd.getHostDetails().put(HOST_VOLUME_ENCRYPTION, String.valueOf(hostSupportsVolumeEncryption()));
cmd.setHostTags(getHostTags()); 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(); HealthCheckResult healthCheckResult = getHostHealthCheckResult();
if (healthCheckResult != HealthCheckResult.IGNORE) { if (healthCheckResult != HealthCheckResult.IGNORE) {
cmd.setHostHealthCheckResult(healthCheckResult == HealthCheckResult.SUCCESS); cmd.setHostHealthCheckResult(healthCheckResult == HealthCheckResult.SUCCESS);
@ -5616,8 +5625,24 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
return exitValue == 0; 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() { public boolean ovfExportToolSupportsParallelThreads() {
String ovfExportToolVersion = Script.runSimpleBashScript(OVF_EXPORT_TOOl_GET_VERSION_CMD); String ovfExportToolVersion = getHostOvfToolVersion();
if (StringUtils.isBlank(ovfExportToolVersion)) { if (StringUtils.isBlank(ovfExportToolVersion)) {
return false; return false;
} }

View File

@ -47,6 +47,14 @@ public final class LibvirtReadyCommandWrapper extends CommandWrapper<ReadyComman
hostDetails.put(Host.HOST_UEFI_ENABLE, Boolean.TRUE.toString()); 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); return new ReadyAnswer(command, hostDetails);
} }

View File

@ -49,9 +49,12 @@ public final class CitrixResizeVolumeCommandWrapper extends CommandWrapper<Resiz
try { try {
if (command.getCurrentSize() >= newSize) { if (command.getCurrentSize() == newSize) {
logger.info("No need to resize volume: " + volId +", current size " + toHumanReadableSize(command.getCurrentSize()) + " is same as new size " + toHumanReadableSize(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); 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()) { if (command.isManaged()) {
resizeSr(conn, command); resizeSr(conn, command);

View File

@ -16,6 +16,7 @@
// under the License. // under the License.
package org.apache.cloudstack.ldap; package org.apache.cloudstack.ldap;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Hashtable; import java.util.Hashtable;
@ -24,6 +25,7 @@ import javax.naming.Context;
import javax.naming.NamingException; import javax.naming.NamingException;
import javax.naming.ldap.InitialLdapContext; import javax.naming.ldap.InitialLdapContext;
import javax.naming.ldap.LdapContext; import javax.naming.ldap.LdapContext;
import java.security.KeyStore;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -52,14 +54,14 @@ public class LdapContextFactory {
return createInitialDirContext(bindPrincipal, bindPassword, providerUrl, true, domainId); 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); return createInitialDirContext(principal, password, null, isSystemContext, domainId);
} }
private LdapContext createInitialDirContext(final String principal, final String password, final String providerUrl, final boolean isSystemContext, Long 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); 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); return new InitialLdapContext(environment, null);
} }
@ -73,8 +75,36 @@ public class LdapContextFactory {
if (sslStatus) { if (sslStatus) {
logger.info("LDAP SSL enabled."); logger.info("LDAP SSL enabled.");
environment.put(Context.SECURITY_PROTOCOL, "ssl"); environment.put(Context.SECURITY_PROTOCOL, "ssl");
System.setProperty("javax.net.ssl.trustStore", _ldapConfiguration.getTrustStore(domainId)); String trustStore = _ldapConfiguration.getTrustStore(domainId);
System.setProperty("javax.net.ssl.trustStorePassword", _ldapConfiguration.getTrustStorePassword(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;
} }
} }

View File

@ -184,6 +184,11 @@ public class LdapManagerImpl extends ComponentLifecycleBase implements LdapManag
} catch (NamingException | IOException e) { } catch (NamingException | IOException e) {
logger.debug("NamingException while doing an LDAP bind", e); logger.debug("NamingException while doing an LDAP bind", e);
throw new InvalidParameterValueException("Unable to bind to the given LDAP server"); 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 { } finally {
closeContext(context); closeContext(context);
} }

View File

@ -89,6 +89,10 @@ import com.cloud.utils.Pair;
import com.cloud.utils.component.ManagerBase; import com.cloud.utils.component.ManagerBase;
import com.cloud.utils.concurrency.NamedThreadFactory; import com.cloud.utils.concurrency.NamedThreadFactory;
import com.cloud.utils.db.SearchCriteria; 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; import org.jetbrains.annotations.Nullable;
public class AlertManagerImpl extends ManagerBase implements AlertManager, Configurable { 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()))); Math.min(CapacityManager.CapacityCalculateWorkers.value(), hostIds.size())));
for (Long hostId : hostIds) { for (Long hostId : hostIds) {
futures.put(hostId, executorService.submit(() -> { futures.put(hostId, executorService.submit(() -> {
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) {
final HostVO host = hostDao.findById(hostId); final HostVO host = hostDao.findById(hostId);
_capacityMgr.updateCapacityForHost(host); _capacityMgr.updateCapacityForHost(host);
}
});
return null; return null;
})); }));
} }
@ -316,6 +325,9 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
Math.min(CapacityManager.CapacityCalculateWorkers.value(), storagePoolIds.size()))); Math.min(CapacityManager.CapacityCalculateWorkers.value(), storagePoolIds.size())));
for (Long poolId: storagePoolIds) { for (Long poolId: storagePoolIds) {
futures.put(poolId, executorService.submit(() -> { futures.put(poolId, executorService.submit(() -> {
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) {
final StoragePoolVO pool = _storagePoolDao.findById(poolId); final StoragePoolVO pool = _storagePoolDao.findById(poolId);
long disk = _capacityMgr.getAllocatedPoolCapacity(pool, null); long disk = _capacityMgr.getAllocatedPoolCapacity(pool, null);
if (pool.isShared()) { if (pool.isShared()) {
@ -323,6 +335,8 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
} else { } else {
_storageMgr.createCapacityEntry(pool, Capacity.CAPACITY_TYPE_LOCAL_STORAGE, disk); _storageMgr.createCapacityEntry(pool, Capacity.CAPACITY_TYPE_LOCAL_STORAGE, disk);
} }
}
});
return null; return null;
})); }));
} }

View File

@ -99,7 +99,6 @@ import org.apache.cloudstack.config.Configuration;
import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService; 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.engine.subsystem.api.storage.ZoneScope;
import org.apache.cloudstack.framework.config.ConfigDepot; import org.apache.cloudstack.framework.config.ConfigDepot;
import org.apache.cloudstack.framework.config.ConfigKey; 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.org.Grouping.AllocationState;
import com.cloud.projects.Project; import com.cloud.projects.Project;
import com.cloud.projects.ProjectManager; import com.cloud.projects.ProjectManager;
import com.cloud.resource.ResourceManager;
import com.cloud.server.ConfigurationServer;
import com.cloud.server.ManagementService; import com.cloud.server.ManagementService;
import com.cloud.service.ServiceOfferingDetailsVO; import com.cloud.service.ServiceOfferingDetailsVO;
import com.cloud.service.ServiceOfferingVO; import com.cloud.service.ServiceOfferingVO;
@ -306,10 +303,8 @@ import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.net.NetUtils; import com.cloud.utils.net.NetUtils;
import com.cloud.vm.NicIpAlias; import com.cloud.vm.NicIpAlias;
import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachine;
import com.cloud.vm.dao.NicDao;
import com.cloud.vm.dao.NicIpAliasDao; import com.cloud.vm.dao.NicIpAliasDao;
import com.cloud.vm.dao.NicIpAliasVO; import com.cloud.vm.dao.NicIpAliasVO;
import com.cloud.vm.dao.NicSecondaryIpDao;
import com.cloud.vm.dao.VMInstanceDao; import com.cloud.vm.dao.VMInstanceDao;
import com.google.common.base.Enums; import com.google.common.base.Enums;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
@ -398,16 +393,12 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
@Inject @Inject
ProjectManager _projectMgr; ProjectManager _projectMgr;
@Inject @Inject
DataStoreManager _dataStoreMgr;
@Inject
NetworkOfferingServiceMapDao _ntwkOffServiceMapDao; NetworkOfferingServiceMapDao _ntwkOffServiceMapDao;
@Inject @Inject
PhysicalNetworkDao _physicalNetworkDao; PhysicalNetworkDao _physicalNetworkDao;
@Inject @Inject
PhysicalNetworkTrafficTypeDao _trafficTypeDao; PhysicalNetworkTrafficTypeDao _trafficTypeDao;
@Inject @Inject
NicDao _nicDao;
@Inject
FirewallRulesDao _firewallDao; FirewallRulesDao _firewallDao;
@Inject @Inject
VpcManager _vpcMgr; VpcManager _vpcMgr;
@ -420,8 +411,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
@Inject @Inject
PortableIpDao _portableIpDao; PortableIpDao _portableIpDao;
@Inject @Inject
ConfigurationServer _configServer;
@Inject
DataCenterDetailsDao _dcDetailsDao; DataCenterDetailsDao _dcDetailsDao;
@Inject @Inject
ClusterDetailsDao _clusterDetailsDao; ClusterDetailsDao _clusterDetailsDao;
@ -434,8 +423,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
@Inject @Inject
PrimaryDataStoreDao _storagePoolDao; PrimaryDataStoreDao _storagePoolDao;
@Inject @Inject
NicSecondaryIpDao _nicSecondaryIpDao;
@Inject
NicIpAliasDao _nicIpAliasDao; NicIpAliasDao _nicIpAliasDao;
@Inject @Inject
public ManagementService _mgr; public ManagementService _mgr;
@ -460,7 +447,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
@Inject @Inject
IndirectAgentLB _indirectAgentLB; IndirectAgentLB _indirectAgentLB;
@Inject @Inject
private VMTemplateZoneDao templateZoneDao; VMTemplateZoneDao templateZoneDao;
@Inject @Inject
VsphereStoragePolicyDao vsphereStoragePolicyDao; VsphereStoragePolicyDao vsphereStoragePolicyDao;
@Inject @Inject
@ -468,7 +455,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
@Inject @Inject
StoragePoolTagsDao storagePoolTagDao; StoragePoolTagsDao storagePoolTagDao;
@Inject @Inject
private AnnotationDao annotationDao; AnnotationDao annotationDao;
@Inject @Inject
UserIpv6AddressDao _ipv6Dao; UserIpv6AddressDao _ipv6Dao;
@Inject @Inject
@ -480,8 +467,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
@Inject @Inject
NsxProviderDao nsxProviderDao; NsxProviderDao nsxProviderDao;
@Inject @Inject
ResourceManager resourceManager;
@Inject
VMLeaseManager vmLeaseManager; VMLeaseManager vmLeaseManager;
// FIXME - why don't we have interface for DataCenterLinkLocalIpAddressDao? // 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> weightBasedParametersForValidation = new HashSet<>();
private Set<String> overprovisioningFactorsForValidation = 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); "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); "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); "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); "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); "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", "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); 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.", "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); 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); "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.", "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); 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); + "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); + "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", 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); "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", 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); "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 BYTES_WRITE_RATE = "Bytes Write";
private static final String DefaultForSystemVmsForPodIpRange = "0"; 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); 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); _indirectAgentLB.propagateMSListToAgents(false);
} else if (settingNameUpdated.equals(Config.RouterAggregationCommandEachTimeout.toString()) } else if (settingNameUpdated.equals(Config.RouterAggregationCommandEachTimeout.toString())
|| settingNameUpdated.equals(Config.MigrateWait.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.RouterAggregationCommandEachTimeout.toString(), _configDao.getValue(Config.RouterAggregationCommandEachTimeout.toString()));
params.put(Config.MigrateWait.toString(), _configDao.getValue(Config.MigrateWait.toString())); params.put(Config.MigrateWait.toString(), _configDao.getValue(Config.MigrateWait.toString()));
_agentManager.propagateChangeToAgents(params); _agentManager.propagateChangeToAgents(params);
@ -713,14 +698,14 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
if (mgtCidr == null || mgtCidr.trim().isEmpty()) { if (mgtCidr == null || mgtCidr.trim().isEmpty()) {
final String[] localCidrs = NetUtils.getLocalCidrs(); final String[] localCidrs = NetUtils.getLocalCidrs();
if (localCidrs != null && localCidrs.length > 0) { 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], ""); + localCidrs[0], "");
_configDao.update(Config.ManagementNetwork.key(), Config.ManagementNetwork.getCategory(), localCidrs[0]); _configDao.update(Config.ManagementNetwork.key(), Config.ManagementNetwork.getCategory(), localCidrs[0]);
} else { } else {
logger.warn("Management network CIDR is not properly configured and we are not able to find a default setting"); 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", ""); "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; return true;
} }
@Override
public boolean stop() {
return true;
}
@Override @Override
@DB @DB
public String updateConfiguration(final long userId, final String name, final String category, String value, ConfigKey.Scope scope, final Long resourceId) { 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); final String validationMsg = validateConfigurationValue(name, value, scope);
if (validationMsg != null) { if (validationMsg != null) {
logger.error("Invalid value [{}] for configuration [{}] due to [{}].", value, name, validationMsg); 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); String previousValue = _configDao.getValue(name);
if (!_configDao.update(name, category, value)) { 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."); throw new CloudRuntimeException("Failed to update configuration value. Please contact Cloud Support.");
} }
_configDepot.invalidateConfigCache(name, ConfigKey.Scope.Global, null); _configDepot.invalidateConfigCache(name, ConfigKey.Scope.Global, null);
PreparedStatement pstmt = null; PreparedStatement pstmt;
if (Config.XenServerGuestNetwork.key().equalsIgnoreCase(name)) { if (Config.XenServerGuestNetwork.key().equalsIgnoreCase(name)) {
final String sql = "update host_details set value=? where name=?"; final String sql = "update host_details set value=? where name=?";
try { try {
@ -934,11 +918,11 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
try { try {
// Change for templates // Change for templates
pstmt = txn.prepareAutoCloseStatement(sqlTemplate); 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(); pstmt.executeUpdate();
// Change for volumes // Change for volumes
pstmt = txn.prepareAutoCloseStatement(sqlVolume); 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(); pstmt.executeUpdate();
// Cleanup the download urls // Cleanup the download urls
_storageManager.cleanupDownloadUrls(); _storageManager.cleanupDownloadUrls();
@ -966,8 +950,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
String hypervisors = _configDao.getValue(hypervisorListConfigName); String hypervisors = _configDao.getValue(hypervisorListConfigName);
if (Arrays.asList(hypervisors.split(",")).contains(previousValue)) { if (Arrays.asList(hypervisors.split(",")).contains(previousValue)) {
hypervisors = hypervisors.replace(previousValue, newValue); hypervisors = hypervisors.replace(previousValue, newValue);
logger.info(String.format("Updating the hypervisor list configuration '%s' " + logger.info("Updating the hypervisor list configuration '{}}' to match the new custom hypervisor display name",
"to match the new custom hypervisor display name", hypervisorListConfigName)); hypervisorListConfigName);
_configDao.update(hypervisorListConfigName, hypervisors); _configDao.update(hypervisorListConfigName, hypervisors);
} }
} }
@ -975,7 +959,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
@Override @Override
@ActionEvent(eventType = EventTypes.EVENT_CONFIGURATION_VALUE_EDIT, eventDescription = "updating configuration") @ActionEvent(eventType = EventTypes.EVENT_CONFIGURATION_VALUE_EDIT, eventDescription = "updating configuration")
public Configuration updateConfiguration(final UpdateCfgCmd cmd) throws InvalidParameterValueException { 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(); final String name = cmd.getCfgName();
String value = cmd.getValue(); String value = cmd.getValue();
final Long zoneId = cmd.getZoneId(); 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 // FIX ME - All configuration parameters are not moved from config.java to configKey
if (config == null) { if (config == null) {
if (_configDepot.get(name) == 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"); throw new InvalidParameterValueException("Config parameter with name " + name + " doesn't exist");
} }
category = _configDepot.get(name).category(); category = _configDepot.get(name).category();
@ -1016,7 +1000,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
validateConflictingConfigValue(name, value); validateConflictingConfigValue(name, value);
if (CATEGORY_SYSTEM.equals(category) && !_accountMgr.isRootAdmin(caller.getId())) { 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."); 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) { if (config == null) {
configKey = _configDepot.get(name); configKey = _configDepot.get(name);
if (configKey == null) { 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"); throw new InvalidParameterValueException("Config parameter with name " + name + " doesn't exist");
} }
defaultValue = configKey.defaultValue(); defaultValue = configKey.defaultValue();
@ -1251,7 +1235,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
default: default:
if (!_configDao.update(name, category, defaultValue)) { 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."); throw new CloudRuntimeException("Failed to reset configuration value. Please contact Cloud Support.");
} }
optionalValue = Optional.ofNullable(configKey != null ? configKey.value() : _configDao.findByName(name).getValue()); 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); _configDepot.invalidateConfigCache(name, scope, id);
CallContext.current().setEventDetails(" Name: " + name + " New Value: " + (name.toLowerCase().contains("password") ? "*****" : defaultValue == null ? "" : defaultValue)); 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) { 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) { protected String validateConfigurationValue(String name, String value, ConfigKey.Scope scope) {
final ConfigurationVO cfg = _configDao.findByName(name); final ConfigurationVO cfg = _configDao.findByName(name);
if (cfg == null) { 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."; return "Invalid configuration variable.";
} }
validateConfigurationAllowedOnlyForDefaultAdmin(name, value); validateConfigurationAllowedOnlyForDefaultAdmin(name, value);
@ -1300,23 +1284,14 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
if (!configScope.contains(scope) && if (!configScope.contains(scope) &&
!(ENABLE_ACCOUNT_SETTINGS_FOR_DOMAIN.value() && configScope.contains(ConfigKey.Scope.Account) && !(ENABLE_ACCOUNT_SETTINGS_FOR_DOMAIN.value() && configScope.contains(ConfigKey.Scope.Account) &&
ConfigKey.Scope.Domain.equals(scope))) { 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; return "Invalid scope id provided for the parameter " + name;
} }
} }
Class<?> type; Class<?> type = getConfigurationTypeWrapperClass(name);
Config configuration = Config.getConfig(name); if (type == null) {
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.");
return null; return null;
} }
type = configKey.type();
} else {
type = configuration.getType();
}
validateSpecificConfigurationValues(name, value, type); 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 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) { protected void validateConfigurationAllowedOnlyForDefaultAdmin(String configName, String value) {
@ -1362,7 +1358,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
* <ul> * <ul>
* <li>String: any value, including null;</li> * <li>String: any value, including null;</li>
* <li>Character: 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>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> * <li>Float, Double: strings that contain a valid float/double, except infinity.</li>
* </ul> * </ul>
@ -1584,7 +1580,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
final int max = Integer.parseInt(options[1]); final int max = Integer.parseInt(options[1]);
final int val = Integer.parseInt(value); final int val = Integer.parseInt(value);
if (val < min || val > max) { 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 String.format("The provided value is not valid for this configuration. Please enter an integer in the range: [%s]", range);
} }
return null; 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. * Checks if the value for the configuration is valid for any of the ranges selected.
*/ */
protected String validateIfStringValueIsInRange(String name, String value, String... range) { protected String validateIfStringValueIsInRange(String name, String value, String... range) {
List<String> message = new ArrayList<String>(); List<String> message = new ArrayList<>();
String errMessage = ""; String errMessage = "";
for (String rangeOption : range) { for (String rangeOption : range) {
switch (rangeOption) { switch (rangeOption) {
@ -1632,9 +1628,9 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
if (NetUtils.isSiteLocalAddress(value)) { if (NetUtils.isSiteLocalAddress(value)) {
return null; 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) { } 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"; return "a valid site local IP address";
} }
@ -1690,7 +1686,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
return null; 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); 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); 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); final HostPodVO pod = _podDao.findById(podId);
@ -2018,7 +2014,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
} }
}); });
} catch (final Exception e) { } 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."); 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; DataCenterGuestIpv6Prefix dataCenterGuestIpv6Prefix = null;
try { try {
dataCenterGuestIpv6Prefix = Transaction.execute(new TransactionCallback<DataCenterGuestIpv6Prefix>() { dataCenterGuestIpv6Prefix = Transaction.execute(new TransactionCallback<>() {
@Override @Override
public DataCenterGuestIpv6Prefix doInTransaction(TransactionStatus status) { public DataCenterGuestIpv6Prefix doInTransaction(TransactionStatus status) {
DataCenterGuestIpv6PrefixVO dataCenterGuestIpv6PrefixVO = new DataCenterGuestIpv6PrefixVO(zoneId, prefix); DataCenterGuestIpv6PrefixVO dataCenterGuestIpv6PrefixVO = new DataCenterGuestIpv6PrefixVO(zoneId, prefix);
@ -2345,7 +2341,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
} }
}); });
} catch (final Exception e) { } 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)); throw new CloudRuntimeException(String.format("Unable to add IPv6 prefix for zone ID: %s. Please contact Cloud Support.", zone));
} }
return dataCenterGuestIpv6Prefix; 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_DELETE_POD_IP_RANGE_EVENT, PublishScope.LOCAL, pod);
messageBus.publish(_name, MESSAGE_CREATE_POD_IP_RANGE_EVENT, PublishScope.LOCAL, pod); messageBus.publish(_name, MESSAGE_CREATE_POD_IP_RANGE_EVENT, PublishScope.LOCAL, pod);
} catch (final Exception e) { } 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."); throw new CloudRuntimeException("Failed to edit pod. Please contact Cloud Support.");
} }
@ -2797,7 +2793,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
checkIfZoneIsDeletable(zoneId); checkIfZoneIsDeletable(zoneId);
return Transaction.execute(new TransactionCallback<Boolean>() { return Transaction.execute(new TransactionCallback<>() {
@Override @Override
public Boolean doInTransaction(final TransactionStatus status) { public Boolean doInTransaction(final TransactionStatus status) {
// delete vlans for this zone // delete vlans for this zone
@ -2861,7 +2857,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
final String networkDomain = cmd.getDomain(); final String networkDomain = cmd.getDomain();
final Boolean localStorageEnabled = cmd.getLocalStorageEnabled(); final Boolean localStorageEnabled = cmd.getLocalStorageEnabled();
final Map<String, String> newDetails = new HashMap<String, String>(); final Map<String, String> newDetails = new HashMap<>();
if (detailsMap != null) { if (detailsMap != null) {
final Collection<?> zoneDetailsCollection = detailsMap.values(); final Collection<?> zoneDetailsCollection = detailsMap.values();
final Iterator<?> iter = zoneDetailsCollection.iterator(); final Iterator<?> iter = zoneDetailsCollection.iterator();
@ -2976,7 +2972,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
Transaction.execute(new TransactionCallbackNoReturn() { Transaction.execute(new TransactionCallbackNoReturn() {
@Override @Override
public void doInTransactionWithoutResult(final TransactionStatus status) { 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); _zoneDao.loadDetails(zone);
if (zone.getDetails() != null) { if (zone.getDetails() != null) {
updatedDetails.putAll(zone.getDetails()); updatedDetails.putAll(zone.getDetails());
@ -3095,7 +3091,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
zoneFinal.setStorageAccessGroups(String.join(",", storageAccessGroups)); zoneFinal.setStorageAccessGroups(String.join(",", storageAccessGroups));
} }
return Transaction.execute(new TransactionCallback<DataCenterVO>() { return Transaction.execute(new TransactionCallback<>() {
@Override @Override
public DataCenterVO doInTransaction(final TransactionStatus status) { public DataCenterVO doInTransaction(final TransactionStatus status) {
final DataCenterVO zone = _zoneDao.persist(zoneFinal); final DataCenterVO zone = _zoneDao.persist(zoneFinal);
@ -3483,7 +3479,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
limitResourceUse, volatileVm, displayText, isSystem, vmType, limitResourceUse, volatileVm, displayText, isSystem, vmType,
hostTag, deploymentPlanner, dynamicScalingEnabled, isCustomized); hostTag, deploymentPlanner, dynamicScalingEnabled, isCustomized);
List<ServiceOfferingDetailsVO> detailsVOList = new ArrayList<ServiceOfferingDetailsVO>(); List<ServiceOfferingDetailsVO> detailsVOList = new ArrayList<>();
if (details != null) { if (details != null) {
// To have correct input, either both gpu card name and VGPU type should be passed or nothing should be passed. // 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. // Use XOR condition to verify that.
@ -4189,28 +4185,28 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
* </ul> * </ul>
*/ */
protected void validateMaximumIopsAndBytesLength(final Long iopsReadRateMaxLength, final Long iopsWriteRateMaxLength, Long bytesReadRateMaxLength, Long bytesWriteRateMaxLength) { 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()) { 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)", 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())); 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()) { 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)", 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())); 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()) { 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)", 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())); 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()) { 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)", 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())); bytesWriteRateMaxLength, BYTES_MAX_WRITE_LENGTH.value()));
@ -4958,7 +4954,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
commitVlanLock.lock(5); commitVlanLock.lock(5);
logger.debug("Acquiring lock for committing vlan"); logger.debug("Acquiring lock for committing vlan");
try { try {
Vlan vlan = Transaction.execute(new TransactionCallback<Vlan>() { Vlan vlan = Transaction.execute(new TransactionCallback<>() {
@Override @Override
public Vlan doInTransaction(final TransactionStatus status) { public Vlan doInTransaction(final TransactionStatus status) {
String newVlanNetmask = newVlanNetmaskFinal; String newVlanNetmask = newVlanNetmaskFinal;
@ -5049,16 +5045,16 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
Pair<String, String> vlanDetails = null; Pair<String, String> vlanDetails = null;
if (sameSubnet) { if (sameSubnet) {
vlanDetails = new Pair<String, String>(vlanGateway, vlanNetmask); vlanDetails = new Pair<>(vlanGateway, vlanNetmask);
} else { } 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. // check if the gatewayip is the part of the ip range being added.
if (ipv4 && NetUtils.ipRangesOverlap(startIP, endIP, vlanDetails.first(), vlanDetails.first())) { 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."); 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, 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, 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 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) { 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 @Override
public VlanVO doInTransaction(final TransactionStatus status) { public VlanVO doInTransaction(final TransactionStatus status) {
VlanVO vlan = new VlanVO(vlanType, vlanId, vlanGateway, vlanNetmask, zone.getId(), ipRange, networkId, physicalNetworkId, vlanIp6Gateway, vlanIp6Cidr, ipv6Range); 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 String gateway, final String netmask,
final boolean ipv4, final Boolean isRangeForSystemVM, final Boolean forSystemvms) { final boolean ipv4, final Boolean isRangeForSystemVM, final Boolean forSystemvms) {
return Transaction.execute(new TransactionCallback<VlanVO>() { return Transaction.execute(new TransactionCallback<>() {
@Override @Override
public VlanVO doInTransaction(final TransactionStatus status) { public VlanVO doInTransaction(final TransactionStatus status) {
VlanVO vlanRange = _vlanDao.findById(id); 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 long allocIpCount = _publicIpAddressDao.countIPs(vlan.getDataCenterId(), vlanDbId, true);
final List<IPAddressVO> ips = _publicIpAddressDao.listByVlanId(vlanDbId); final List<IPAddressVO> ips = _publicIpAddressDao.listByVlanId(vlanDbId);
boolean success = true; boolean success = true;
final List<IPAddressVO> ipsInUse = new ArrayList<IPAddressVO>(); final List<IPAddressVO> ipsInUse = new ArrayList<>();
if (allocIpCount > 0) { if (allocIpCount > 0) {
try { try {
vlan = _vlanDao.acquireInLockTable(vlanDbId, 30); vlan = _vlanDao.acquireInLockTable(vlanDbId, 30);
@ -6033,7 +6029,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
final long startIPLong = NetUtils.ip2Long(startIP); final long startIPLong = NetUtils.ip2Long(startIP);
final long endIPLong = NetUtils.ip2Long(endIP); 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 @Override
public List<String> doInTransaction(final TransactionStatus status) { public List<String> doInTransaction(final TransactionStatus status) {
final IPRangeConfig config = new IPRangeConfig(); final IPRangeConfig config = new IPRangeConfig();
@ -6062,7 +6058,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
currentStartIPLong++; currentStartIPLong++;
} }
final List<String> problemIps = Transaction.execute(new TransactionCallback<List<String>>() { final List<String> problemIps = Transaction.execute(new TransactionCallback<>() {
@Override @Override
public List<String> doInTransaction(final TransactionStatus status) { public List<String> doInTransaction(final TransactionStatus status) {
@ -6182,7 +6178,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
skipPod = podIdToBeSkipped; skipPod = podIdToBeSkipped;
} }
final HashMap<Long, List<Object>> currentPodCidrSubnets = _podDao.getCurrentPodCidrSubnets(dcId, skipPod); 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(0, getCidrAddress(cidr));
newCidrPair.add(1, (long)getCidrSize(cidr)); newCidrPair.add(1, (long)getCidrSize(cidr));
currentPodCidrSubnets.put(new Long(-1), newCidrPair); currentPodCidrSubnets.put(new Long(-1), newCidrPair);
@ -6494,8 +6490,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
NetworkOffering.RoutingMode routingMode = verifyRoutingMode(routingModeString); NetworkOffering.RoutingMode routingMode = verifyRoutingMode(routingModeString);
// configure service provider map // configure service provider map
final Map<Network.Service, Set<Network.Provider>> serviceProviderMap = new HashMap<Network.Service, Set<Network.Provider>>(); final Map<Network.Service, Set<Network.Provider>> serviceProviderMap = new HashMap<>();
final Set<Network.Provider> defaultProviders = new HashSet<Network.Provider>(); final Set<Network.Provider> defaultProviders = new HashSet<>();
// populate the services first // populate the services first
for (final String serviceName : cmd.getSupportedServices()) { for (final String serviceName : cmd.getSupportedServices()) {
@ -6518,7 +6514,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
if (guestType != GuestType.Shared) { if (guestType != GuestType.Shared) {
throw new InvalidParameterValueException("Security group service is supported for network offerings with guest ip type " + 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); sgProviders.add(Provider.SecurityGroupProvider);
serviceProviderMap.put(Network.Service.SecurityGroup, sgProviders); serviceProviderMap.put(Network.Service.SecurityGroup, sgProviders);
continue; continue;
@ -6534,7 +6530,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
} }
// populate providers // 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(); final Map<String, List<String>> svcPrv = cmd.getServiceProviders();
Provider firewallProvider = null; Provider firewallProvider = null;
Provider dhcpProvider = null; Provider dhcpProvider = null;
@ -6543,7 +6539,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
for (final String serviceStr : svcPrv.keySet()) { for (final String serviceStr : svcPrv.keySet()) {
final Network.Service service = Network.Service.getService(serviceStr); final Network.Service service = Network.Service.getService(serviceStr);
if (serviceProviderMap.containsKey(service)) { 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 // Allow to specify more than 1 provider per service only if
// the service is LB // the service is LB
if (!serviceStr.equalsIgnoreCase(Service.Lb.getName()) && svcPrv.get(serviceStr) != null && svcPrv.get(serviceStr).size() > 1) { 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; Set<Service> serviceSet = null;
if (providerCombinationToVerify.get(provider) == null) { if (providerCombinationToVerify.get(provider) == null) {
serviceSet = new HashSet<Service>(); serviceSet = new HashSet<>();
} else { } else {
serviceSet = providerCombinationToVerify.get(provider); serviceSet = providerCombinationToVerify.get(provider);
} }
@ -6656,7 +6652,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
} }
validateConnectivityServiceCapablities(guestType, serviceProviderMap.get(Service.Connectivity), connectivityServiceCapabilityMap); 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.Lb, lbServiceCapabilityMap);
serviceCapabilityMap.put(Service.SourceNat, sourceNatServiceCapabilityMap); serviceCapabilityMap.put(Service.SourceNat, sourceNatServiceCapabilityMap);
serviceCapabilityMap.put(Service.StaticNat, staticNatServiceCapabilityMap); serviceCapabilityMap.put(Service.StaticNat, staticNatServiceCapabilityMap);
@ -6671,7 +6667,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
// combination // combination
if (firewallProvider != null) { if (firewallProvider != null) {
logger.debug("Adding Firewall service with provider " + firewallProvider.getName()); 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); firewallProviderSet.add(firewallProvider);
serviceProviderMap.put(Service.Firewall, firewallProviderSet); serviceProviderMap.put(Service.Firewall, firewallProviderSet);
if (!(firewallProvider.getName().equals(Provider.JuniperSRX.getName()) || firewallProvider.getName().equals(Provider.PaloAlto.getName()) || firewallProvider.getName() 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) { if (detailsStr != null) {
for (final String detailStr : detailsStr.keySet()) { for (final String detailStr : detailsStr.keySet()) {
NetworkOffering.Detail offDetail = null; 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 @Override
public NetworkOfferingVO doInTransaction(final TransactionStatus status) { public NetworkOfferingVO doInTransaction(final TransactionStatus status) {
NetworkOfferingVO offering = offeringFinal; NetworkOfferingVO offering = offeringFinal;
@ -7171,7 +7167,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
} }
if (vpcOff && !forNsx) { if (vpcOff && !forNsx) {
final List<Service> supportedSvcs = new ArrayList<Service>(); final List<Service> supportedSvcs = new ArrayList<>();
supportedSvcs.addAll(serviceProviderMap.keySet()); supportedSvcs.addAll(serviceProviderMap.keySet());
_vpcMgr.validateNtwkOffForVpc(offering, supportedSvcs); _vpcMgr.validateNtwkOffForVpc(offering, supportedSvcs);
} }
@ -7255,7 +7251,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
} }
// 2) validate if the provider supports the scheme // 2) validate if the provider supports the scheme
final Set<Provider> lbProviders = new HashSet<Provider>(); final Set<Provider> lbProviders = new HashSet<>();
lbProviders.add(lbProvider); lbProviders.add(lbProvider);
if (detail == NetworkOffering.Detail.InternalLbProvider) { if (detail == NetworkOffering.Detail.InternalLbProvider) {
_networkModel.checkCapabilityForProvider(lbProviders, Service.Lb, Capability.LbSchemes, Scheme.Internal.toString()); _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) { if (zone.getNetworkType() == NetworkType.Basic) {
// return empty list as we don't allow to create networks in // return empty list as we don't allow to create networks in
// basic zone, and shouldn't display networkOfferings // 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()) { if (!offeringIds.isEmpty()) {
sc.addAnd("id", SearchCriteria.Op.IN, offeringIds.toArray()); sc.addAnd("id", SearchCriteria.Op.IN, offeringIds.toArray());
} else { } 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 Boolean sourceNatSupported = cmd.getSourceNatSupported();
final List<String> pNtwkTags = new ArrayList<String>(); final List<String> pNtwkTags = new ArrayList<>();
boolean checkForTags = false; boolean checkForTags = false;
boolean allowNullTag = false; boolean allowNullTag = false;
if (zone != null) { if (zone != null) {
@ -7479,7 +7475,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
for (final NetworkOfferingJoinVO offering : offerings) { for (final NetworkOfferingJoinVO offering : offerings) {
boolean addOffering = true; boolean addOffering = true;
List<Service> checkForProviders = new ArrayList<Service>(); List<Service> checkForProviders = new ArrayList<>();
if (checkForTags && !checkNetworkOfferingTags(pNtwkTags, allowNullTag, offering.getTags())) { if (checkForTags && !checkNetworkOfferingTags(pNtwkTags, allowNullTag, offering.getTags())) {
continue; continue;
@ -7518,17 +7514,17 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
// Now apply pagination // Now apply pagination
final List<NetworkOfferingJoinVO> wPagination = com.cloud.utils.StringUtils.applyPagination(supportedOfferings, cmd.getStartIndex(), cmd.getPageSizeVal()); final List<NetworkOfferingJoinVO> wPagination = com.cloud.utils.StringUtils.applyPagination(supportedOfferings, cmd.getStartIndex(), cmd.getPageSizeVal());
if (wPagination != null) { 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 listWPagination;
} }
return new Pair<List<? extends NetworkOffering>, Integer>(supportedOfferings, supportedOfferings.size()); return new Pair<>(supportedOfferings, supportedOfferings.size());
} else { } else {
final List<NetworkOfferingJoinVO> wPagination = com.cloud.utils.StringUtils.applyPagination(offerings, cmd.getStartIndex(), cmd.getPageSizeVal()); final List<NetworkOfferingJoinVO> wPagination = com.cloud.utils.StringUtils.applyPagination(offerings, cmd.getStartIndex(), cmd.getPageSizeVal());
if (wPagination != null) { if (wPagination != null) {
final Pair<List<? extends NetworkOffering>, Integer> listWPagination = new Pair<>(wPagination, offerings.size()); final Pair<List<? extends NetworkOffering>, Integer> listWPagination = new Pair<>(wPagination, offerings.size());
return listWPagination; 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 Integer regionId = cmd.getRegionIdId();
final Long rangeId = cmd.getPortableIpRangeId(); final Long rangeId = cmd.getPortableIpRangeId();
final List<PortableIpRangeVO> ranges = new ArrayList<PortableIpRangeVO>(); final List<PortableIpRangeVO> ranges = new ArrayList<>();
if (regionId != null) { if (regionId != null) {
final Region region = _regionDao.findById(regionId); final Region region = _regionDao.findById(regionId);
if (region == null) { 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 @Override
public String getConfigurationType(final String configName) { public String getConfigurationType(final String configName) {
final ConfigurationVO cfg = _configDao.findByName(configName); final ConfigurationVO cfg = _configDao.findByName(configName);
if (cfg == null) { if (cfg == null) {
logger.warn("Configuration " + configName + " not found"); logger.warn("Configuration [{}] not found", configName);
return Configuration.ValueType.String.name(); return Configuration.ValueType.String.name();
} }
@ -8294,24 +8296,14 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
return Configuration.ValueType.Range.name(); return Configuration.ValueType.Range.name();
} }
Class<?> type = null; Class<?> type = getConfigurationTypeWrapperClass(configName);
final Config c = Config.getConfig(configName); return parseConfigurationTypeIntoString(type, cfg);
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();
} }
return getInputType(type, cfg); /**
} * Parses a configuration type's wrapper class into its string representation.
*/
private String getInputType(Class<?> type, ConfigurationVO cfg) { protected String parseConfigurationTypeIntoString(Class<?> type, ConfigurationVO cfg) {
if (type == null) { if (type == null) {
return Configuration.ValueType.String.name(); return Configuration.ValueType.String.name();
} }
@ -8358,13 +8350,12 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
groupName = configGroup.getName(); groupName = configGroup.getName();
} }
return new Pair<String, String>(groupName, subGroupName); return new Pair<>(groupName, subGroupName);
} }
@Override @Override
public List<ConfigurationSubGroupVO> getConfigurationSubGroups(final Long groupId) { public List<ConfigurationSubGroupVO> getConfigurationSubGroups(final Long groupId) {
List<ConfigurationSubGroupVO> configSubGroups = _configSubGroupDao.findByGroup(groupId); return _configSubGroupDao.findByGroup(groupId);
return configSubGroups;
} }
static class ParamCountPair { static class ParamCountPair {
@ -8390,10 +8381,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
return paramCount; return paramCount;
} }
public void setParamCount(int paramCount) {
this.paramCount = paramCount;
}
public String getScope() { public String getScope() {
return scope; return scope;
} }

View File

@ -265,6 +265,7 @@ import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.SearchCriteria.Op; import com.cloud.utils.db.SearchCriteria.Op;
import com.cloud.utils.db.Transaction; import com.cloud.utils.db.Transaction;
import com.cloud.utils.db.TransactionCallbackNoReturn; import com.cloud.utils.db.TransactionCallbackNoReturn;
import com.cloud.utils.db.TransactionCallbackWithExceptionNoReturn;
import com.cloud.utils.db.TransactionLegacy; import com.cloud.utils.db.TransactionLegacy;
import com.cloud.utils.db.TransactionStatus; import com.cloud.utils.db.TransactionStatus;
import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.exception.CloudRuntimeException;
@ -1834,6 +1835,9 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
if (exceptionOccurred.get()) { if (exceptionOccurred.get()) {
return null; return null;
} }
Transaction.execute(new TransactionCallbackWithExceptionNoReturn<Exception>() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) throws Exception {
HostVO host = _hostDao.findById(hostId); HostVO host = _hostDao.findById(hostId);
try { try {
connectHostToSharedPool(host, primaryStore.getId()); connectHostToSharedPool(host, primaryStore.getId());
@ -1850,6 +1854,8 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
throw new CloudRuntimeException(reason); throw new CloudRuntimeException(reason);
} }
} }
}
});
return null; return null;
})); }));
} }

View File

@ -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." 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."); + "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 */ /* Check resource limit for this account */

View File

@ -16,6 +16,7 @@
// under the License. // under the License.
package com.cloud.configuration; package com.cloud.configuration;
import com.cloud.alert.AlertManager;
import com.cloud.capacity.dao.CapacityDao; import com.cloud.capacity.dao.CapacityDao;
import com.cloud.dc.DataCenterVO; import com.cloud.dc.DataCenterVO;
import com.cloud.dc.VlanVO; 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.exception.CloudRuntimeException;
import com.cloud.utils.net.NetUtils; import com.cloud.utils.net.NetUtils;
import com.cloud.vm.dao.VMInstanceDao; import com.cloud.vm.dao.VMInstanceDao;
import org.apache.cloudstack.acl.RoleService;
import org.apache.cloudstack.annotation.dao.AnnotationDao; import org.apache.cloudstack.annotation.dao.AnnotationDao;
import org.apache.cloudstack.api.command.admin.config.ResetCfgCmd; import org.apache.cloudstack.api.command.admin.config.ResetCfgCmd;
import org.apache.cloudstack.api.command.admin.network.CreateNetworkOfferingCmd; import org.apache.cloudstack.api.command.admin.network.CreateNetworkOfferingCmd;
@ -930,4 +932,113 @@ public class ConfigurationManagerImplTest {
configurationManagerImplSpy.validateConfigurationAllowedOnlyForDefaultAdmin(AccountManagerImpl.listOfRoleTypesAllowedForOperationsOfSameRoleType.key(), invalidValue); 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);
}
} }

View File

@ -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)', `waiters` int NOT NULL DEFAULT 0 COMMENT 'How many have the thread acquired this lock (reentrant)',
PRIMARY KEY (`key`), PRIMARY KEY (`key`),
INDEX `i_op_lock__mac_ip_thread`(`mac`, `ip`, `thread`) INDEX `i_op_lock__mac_ip_thread`(`mac`, `ip`, `thread`)
) ENGINE=Memory DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`configuration` ( CREATE TABLE `cloud`.`configuration` (
`category` varchar(255) NOT NULL DEFAULT 'Advanced', `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__taken`(`taken`),
INDEX `i_op_nwgrp_work__step`(`step`), INDEX `i_op_nwgrp_work__step`(`step`),
INDEX `i_op_nwgrp_work__seq_no`(`seq_no`) 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` ( CREATE TABLE `cloud`.`op_vm_ruleset_log` (
`id` bigint unsigned UNIQUE NOT NULL AUTO_INCREMENT COMMENT 'id', `id` bigint unsigned UNIQUE NOT NULL AUTO_INCREMENT COMMENT 'id',

View File

@ -1037,7 +1037,7 @@
"label.forcks": "For CKS", "label.forcks": "For CKS",
"label.forbidden": "Forbidden", "label.forbidden": "Forbidden",
"label.forced": "Force", "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.stop": "Force stop",
"label.force.reboot": "Force reboot", "label.force.reboot": "Force reboot",
"label.forceencap": "Force UDP encapsulation of ESP packets", "label.forceencap": "Force UDP encapsulation of ESP packets",
@ -1123,7 +1123,9 @@
"label.host": "IP address", "label.host": "IP address",
"label.host.alerts": "Hosts in alert state", "label.host.alerts": "Hosts in alert state",
"label.host.name": "Host name", "label.host.name": "Host name",
"label.host.ovftool.version": "OVFTool Version",
"label.host.tag": "Host tag", "label.host.tag": "Host tag",
"label.host.virtv2v.version": "Virt-v2v Version",
"label.hostcontrolstate": "Compute Resource Status", "label.hostcontrolstate": "Compute Resource Status",
"label.hostid": "Host", "label.hostid": "Host",
"label.hostname": "Host", "label.hostname": "Host",

View File

@ -107,7 +107,7 @@ export const QUOTA_TYPES = [
}, },
{ {
id: 29, id: 29,
type: 'VPC' type: 'BUCKET'
}, },
{ {
id: 30, id: 30,
@ -115,7 +115,7 @@ export const QUOTA_TYPES = [
}, },
{ {
id: 31, id: 31,
type: 'BACKUP_OBJECT' type: 'VPC'
} }
] ]

View File

@ -56,6 +56,22 @@
</div> </div>
</div> </div>
</a-list-item> </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"> <a-list-item v-if="host.hosttags">
<div> <div>
<strong>{{ $t('label.hosttags') }}</strong> <strong>{{ $t('label.hosttags') }}</strong>

View File

@ -90,7 +90,7 @@
:checked="autoMigrate" :checked="autoMigrate"
@change="val => { autoMigrate = val }"/> @change="val => { autoMigrate = val }"/>
</a-form-item> </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 <a-switch
v-model:checked="form.shrinkOk" v-model:checked="form.shrinkOk"
:checked="shrinkOk" :checked="shrinkOk"

View File

@ -944,6 +944,12 @@ export default {
} else { } else {
host.name = host.name + ' (' + this.$t('label.not.supported') + ')' 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'] + ')'
}
}) })
}) })
}, },