diff --git a/api/src/main/java/com/cloud/storage/VolumeApiService.java b/api/src/main/java/com/cloud/storage/VolumeApiService.java index 986326454b0..475df50bbef 100644 --- a/api/src/main/java/com/cloud/storage/VolumeApiService.java +++ b/api/src/main/java/com/cloud/storage/VolumeApiService.java @@ -162,6 +162,8 @@ public interface VolumeApiService { Volume recoverVolume(long volumeId); + void validateCustomDiskOfferingSizeRange(Long sizeInGB); + boolean validateVolumeSizeInBytes(long size); Volume changeDiskOfferingForVolume(ChangeOfferingForVolumeCmd cmd) throws ResourceAllocationException; diff --git a/scripts/util/keystore-setup b/scripts/util/keystore-setup index 8ca6cc77baa..25bf28af008 100755 --- a/scripts/util/keystore-setup +++ b/scripts/util/keystore-setup @@ -23,6 +23,7 @@ KS_VALIDITY="$4" CSR_FILE="$5" ALIAS="cloud" +LIBVIRTD_FILE="/etc/libvirt/libvirtd.conf" # Re-use existing password or use the one provided if [ -f "$PROPS_FILE" ]; then @@ -46,6 +47,27 @@ keytool -genkey -storepass "$KS_PASS" -keypass "$KS_PASS" -alias "$ALIAS" -keyal rm -f "$CSR_FILE" addresses=$(ip address | grep inet | awk '{print $2}' | sed 's/\/.*//g' | grep -v '^169.254.' | grep -v '^127.0.0.1' | egrep -v '^::1|^fe80' | grep -v '^::1' | sed 's/^/ip:/g' | tr '\r\n' ',') keytool -certreq -storepass "$KS_PASS" -alias "$ALIAS" -file $CSR_FILE -keystore "$KS_FILE" -ext san="$addresses" > /dev/null 2>&1 + +if [ $? -ne 0 ];then + echo "Failed to generate CSR file, retrying after removing existing settings" + + if [ -f "$LIBVIRTD_FILE" ]; then + echo "Reverting libvirtd to not listen on TLS" + sed -i "s,^listen_tls=1,listen_tls=0,g" $LIBVIRTD_FILE + systemctl restart libvirtd + fi + + echo "Removing cloud.* files in /etc/cloudstack/agent" + rm -f /etc/cloudstack/agent/cloud.* + + echo "Retrying to generate CSR file" + keytool -certreq -storepass "$KS_PASS" -alias "$ALIAS" -file $CSR_FILE -keystore "$KS_FILE" -ext san="$addresses" >/dev/null 2>&1 + if [ $? -ne 0 ];then + echo "Failed to generate CSR file while retrying" + exit 1 + fi +fi + cat "$CSR_FILE" # Fix file permissions diff --git a/server/src/main/java/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java b/server/src/main/java/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java index 4f1fcb26a7c..f4706be185d 100644 --- a/server/src/main/java/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java +++ b/server/src/main/java/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java @@ -260,10 +260,11 @@ public abstract class LibvirtServerDiscoverer extends DiscovererBase implements final String privateKey = _configDao.getValue("ssh.privatekey"); if (!SSHCmdHelper.acquireAuthorizedConnectionWithPublicKey(sshConnection, username, privateKey)) { - s_logger.error("Failed to authenticate with ssh key"); if (org.apache.commons.lang3.StringUtils.isEmpty(password)) { + s_logger.error("Failed to authenticate with ssh key"); throw new DiscoveredWithErrorException("Authentication error with ssh private key"); } + s_logger.info("Failed to authenticate with ssh key, retrying with password"); if (!sshConnection.authenticateWithPassword(username, password)) { s_logger.error("Failed to authenticate with password"); throw new DiscoveredWithErrorException("Authentication error with host password"); diff --git a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java index b2bf946bf94..735a8b29306 100644 --- a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java @@ -724,12 +724,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic if (size == null) { throw new InvalidParameterValueException("This disk offering requires a custom size specified"); } - Long customDiskOfferingMaxSize = VolumeOrchestrationService.CustomDiskOfferingMaxSize.value(); - Long customDiskOfferingMinSize = VolumeOrchestrationService.CustomDiskOfferingMinSize.value(); - - if ((sizeInGB < customDiskOfferingMinSize) || (sizeInGB > customDiskOfferingMaxSize)) { - throw new InvalidParameterValueException("Volume size: " + sizeInGB + "GB is out of allowed range. Max: " + customDiskOfferingMaxSize + " Min:" + customDiskOfferingMinSize); - } + validateCustomDiskOfferingSizeRange(sizeInGB); } if (!diskOffering.isCustomized() && size != null) { @@ -886,6 +881,16 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic _uuidMgr.generateUuid(Volume.class, cmd.getCustomId()), details); } + @Override + public void validateCustomDiskOfferingSizeRange(Long sizeInGB) { + Long customDiskOfferingMaxSize = VolumeOrchestrationService.CustomDiskOfferingMaxSize.value(); + Long customDiskOfferingMinSize = VolumeOrchestrationService.CustomDiskOfferingMinSize.value(); + + if ((sizeInGB < customDiskOfferingMinSize) || (sizeInGB > customDiskOfferingMaxSize)) { + throw new InvalidParameterValueException(String.format("Volume size: %s GB is out of allowed range. Min: %s. Max: %s", sizeInGB, customDiskOfferingMinSize, customDiskOfferingMaxSize)); + } + } + private VolumeVO commitVolume(final CreateVolumeCmd cmd, final Account caller, final Account owner, final Boolean displayVolume, final Long zoneId, final Long diskOfferingId, final Storage.ProvisioningType provisioningType, final Long size, final Long minIops, final Long maxIops, final VolumeVO parentVolume, final String userSpecifiedName, final String uuid, final Map details) { return Transaction.execute(new TransactionCallback() { @@ -1075,6 +1080,10 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic throw new InvalidParameterValueException(String.format("Resize of volume %s is not allowed, since disk size is strictly fixed as per the disk offering", volume.getUuid())); } + if (diskOffering.isCustomized()) { + validateCustomDiskOfferingSizeRange(newSize); + } + if (isNotPossibleToResize(volume, diskOffering)) { throw new InvalidParameterValueException( "Failed to resize Root volume. The service offering of this Volume has been configured with a root disk size; " @@ -1158,6 +1167,8 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic throw new InvalidParameterValueException("The new disk offering requires that a size be specified."); } + validateCustomDiskOfferingSizeRange(newSize); + // convert from GiB to bytes newSize = newSize << 30; } else { diff --git a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java index 924c6deec59..72fe27a48d5 100644 --- a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java @@ -4332,12 +4332,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir if (diskSize == null) { throw new InvalidParameterValueException("This disk offering requires a custom size specified"); } - Long customDiskOfferingMaxSize = VolumeOrchestrationService.CustomDiskOfferingMaxSize.value(); - Long customDiskOfferingMinSize = VolumeOrchestrationService.CustomDiskOfferingMinSize.value(); - if ((diskSize < customDiskOfferingMinSize) || (diskSize > customDiskOfferingMaxSize)) { - throw new InvalidParameterValueException("VM Creation failed. Volume size: " + diskSize + "GB is out of allowed range. Max: " + customDiskOfferingMaxSize - + " Min:" + customDiskOfferingMinSize); - } + _volumeService.validateCustomDiskOfferingSizeRange(diskSize); size = diskSize * GiB_TO_BYTES; } else { size = diskOffering.getDiskSize(); diff --git a/ui/src/components/view/InfoCard.vue b/ui/src/components/view/InfoCard.vue index 32ac7aad91b..f7eb3a529db 100644 --- a/ui/src/components/view/InfoCard.vue +++ b/ui/src/components/view/InfoCard.vue @@ -143,8 +143,8 @@
{{ $t('label.cpu') }}
- {{ resource.cputotal }} - {{ resource.cpunumber }} CPU x {{ parseFloat(resource.cpuspeed / 1000.0).toFixed(2) }} Ghz + {{ resource.cpunumber }} CPU x {{ parseFloat(resource.cpuspeed / 1000.0).toFixed(2) }} Ghz + {{ resource.cputotal }}