mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
Merge remote-tracking branch 'apache/4.16'
This commit is contained in:
commit
944b6037cc
@ -2756,25 +2756,25 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
public String getVolumePath(final Connect conn, final DiskTO volume, boolean diskOnHostCache) throws LibvirtException, URISyntaxException {
|
||||
final DataTO data = volume.getData();
|
||||
final DataStoreTO store = data.getDataStore();
|
||||
final String dataPath = data.getPath();
|
||||
|
||||
if (volume.getType() == Volume.Type.ISO && data.getPath() != null && (store instanceof NfsTO ||
|
||||
store instanceof PrimaryDataStoreTO && data instanceof TemplateObjectTO && !((TemplateObjectTO) data).isDirectDownload())) {
|
||||
|
||||
if (data.getPath().startsWith(ConfigDrive.CONFIGDRIVEDIR) && diskOnHostCache) {
|
||||
String configDrivePath = getConfigPath() + "/" + data.getPath();
|
||||
return configDrivePath;
|
||||
if (volume.getType() == Volume.Type.ISO && dataPath != null) {
|
||||
if (dataPath.startsWith(ConfigDrive.CONFIGDRIVEDIR) && diskOnHostCache) {
|
||||
return getConfigPath() + "/" + data.getPath();
|
||||
}
|
||||
|
||||
final String isoPath = store.getUrl().split("\\?")[0] + File.separator + data.getPath();
|
||||
final int index = isoPath.lastIndexOf("/");
|
||||
final String path = isoPath.substring(0, index);
|
||||
final String name = isoPath.substring(index + 1);
|
||||
final KVMStoragePool secondaryPool = _storagePoolMgr.getStoragePoolByURI(path);
|
||||
final KVMPhysicalDisk isoVol = secondaryPool.getPhysicalDisk(name);
|
||||
return isoVol.getPath();
|
||||
} else {
|
||||
return data.getPath();
|
||||
if (store instanceof NfsTO || store instanceof PrimaryDataStoreTO && data instanceof TemplateObjectTO && !((TemplateObjectTO) data).isDirectDownload()) {
|
||||
final String isoPath = store.getUrl().split("\\?")[0] + File.separator + dataPath;
|
||||
final int index = isoPath.lastIndexOf("/");
|
||||
final String path = isoPath.substring(0, index);
|
||||
final String name = isoPath.substring(index + 1);
|
||||
final KVMStoragePool secondaryPool = _storagePoolMgr.getStoragePoolByURI(path);
|
||||
final KVMPhysicalDisk isoVol = secondaryPool.getPhysicalDisk(name);
|
||||
return isoVol.getPath();
|
||||
}
|
||||
}
|
||||
|
||||
return dataPath;
|
||||
}
|
||||
|
||||
public void createVbd(final Connect conn, final VirtualMachineTO vmSpec, final String vmName, final LibvirtVMDef vm) throws InternalErrorException, LibvirtException, URISyntaxException {
|
||||
|
||||
@ -153,7 +153,7 @@ public final class LibvirtMigrateCommandWrapper extends CommandWrapper<MigrateCo
|
||||
String oldIsoVolumePath = getOldVolumePath(disks, vmName);
|
||||
String newIsoVolumePath = getNewVolumePathIfDatastoreHasChanged(libvirtComputingResource, conn, to);
|
||||
if (newIsoVolumePath != null && !newIsoVolumePath.equals(oldIsoVolumePath)) {
|
||||
s_logger.debug("Editing mount path");
|
||||
s_logger.debug(String.format("Editing mount path of iso from %s to %s", oldIsoVolumePath, newIsoVolumePath));
|
||||
xmlDesc = replaceDiskSourceFile(xmlDesc, newIsoVolumePath, vmName);
|
||||
}
|
||||
// delete the metadata of vm snapshots before migration
|
||||
@ -568,7 +568,7 @@ public final class LibvirtMigrateCommandWrapper extends CommandWrapper<MigrateCo
|
||||
|
||||
String newIsoVolumePath = null;
|
||||
if (newDisk != null) {
|
||||
newIsoVolumePath = libvirtComputingResource.getVolumePath(conn, newDisk);
|
||||
newIsoVolumePath = libvirtComputingResource.getVolumePath(conn, newDisk, to.isConfigDriveOnHostCache());
|
||||
}
|
||||
return newIsoVolumePath;
|
||||
}
|
||||
|
||||
@ -927,15 +927,26 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
final Long accountId = cmd.getAccountId();
|
||||
final Long domainId = cmd.getDomainId();
|
||||
final Long imageStoreId = cmd.getImageStoreId();
|
||||
ConfigKey<?> configKey = null;
|
||||
Optional optionalValue;
|
||||
final ConfigKey<?> configKey = _configDepot.get(name);
|
||||
if (configKey == null) {
|
||||
s_logger.warn("Probably the component manager where configuration variable " + name + " is defined needs to implement Configurable interface");
|
||||
throw new InvalidParameterValueException("Config parameter with name " + name + " doesn't exist");
|
||||
String defaultValue;
|
||||
String category;
|
||||
String configScope;
|
||||
final ConfigurationVO config = _configDao.findByName(name);
|
||||
if (config == null) {
|
||||
configKey = _configDepot.get(name);
|
||||
if (configKey == null) {
|
||||
s_logger.warn("Probably the component manager where configuration variable " + name + " is defined needs to implement Configurable interface");
|
||||
throw new InvalidParameterValueException("Config parameter with name " + name + " doesn't exist");
|
||||
}
|
||||
defaultValue = configKey.defaultValue();
|
||||
category = configKey.category();
|
||||
configScope = configKey.scope().toString();
|
||||
} else {
|
||||
defaultValue = config.getDefaultValue();
|
||||
category = config.getCategory();
|
||||
configScope = config.getScope();
|
||||
}
|
||||
String defaultValue = configKey.defaultValue();
|
||||
String category = configKey.category();
|
||||
String configScope = configKey.scope().toString();
|
||||
|
||||
String scope = "";
|
||||
Map<String, Long> scopeMap = new LinkedHashMap<>();
|
||||
@ -971,7 +982,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
throw new InvalidParameterValueException("unable to find zone by id " + id);
|
||||
}
|
||||
_dcDetailsDao.removeDetail(id, name);
|
||||
optionalValue = Optional.ofNullable(configKey.valueIn(id));
|
||||
optionalValue = Optional.ofNullable(configKey != null ? configKey.valueIn(id): config.getValue());
|
||||
newValue = optionalValue.isPresent() ? optionalValue.get().toString() : defaultValue;
|
||||
break;
|
||||
|
||||
@ -981,13 +992,13 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
throw new InvalidParameterValueException("unable to find cluster by id " + id);
|
||||
}
|
||||
ClusterDetailsVO clusterDetailsVO = _clusterDetailsDao.findDetail(id, name);
|
||||
newValue = configKey.value().toString();
|
||||
newValue = configKey != null ? configKey.value().toString() : config.getValue();
|
||||
if (name.equalsIgnoreCase("cpu.overprovisioning.factor") || name.equalsIgnoreCase("mem.overprovisioning.factor")) {
|
||||
_clusterDetailsDao.persist(id, name, newValue);
|
||||
} else if (clusterDetailsVO != null) {
|
||||
_clusterDetailsDao.remove(clusterDetailsVO.getId());
|
||||
}
|
||||
optionalValue = Optional.ofNullable(configKey.valueIn(id));
|
||||
optionalValue = Optional.ofNullable(configKey != null ? configKey.valueIn(id): config.getValue());
|
||||
newValue = optionalValue.isPresent() ? optionalValue.get().toString() : defaultValue;
|
||||
break;
|
||||
|
||||
@ -997,7 +1008,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
throw new InvalidParameterValueException("unable to find storage pool by id " + id);
|
||||
}
|
||||
_storagePoolDetailsDao.removeDetail(id, name);
|
||||
optionalValue = Optional.ofNullable(configKey.valueIn(id));
|
||||
optionalValue = Optional.ofNullable(configKey != null ? configKey.valueIn(id) : config.getValue());
|
||||
newValue = optionalValue.isPresent() ? optionalValue.get().toString() : defaultValue;
|
||||
break;
|
||||
|
||||
@ -1010,7 +1021,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
if (domainDetailVO != null) {
|
||||
_domainDetailsDao.remove(domainDetailVO.getId());
|
||||
}
|
||||
optionalValue = Optional.ofNullable(configKey.valueIn(id));
|
||||
optionalValue = Optional.ofNullable(configKey != null ? configKey.valueIn(id) : config.getValue());
|
||||
newValue = optionalValue.isPresent() ? optionalValue.get().toString() : defaultValue;
|
||||
break;
|
||||
|
||||
@ -1023,7 +1034,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
if (accountDetailVO != null) {
|
||||
_accountDetailsDao.remove(accountDetailVO.getId());
|
||||
}
|
||||
optionalValue = Optional.ofNullable(configKey.valueIn(id));
|
||||
optionalValue = Optional.ofNullable(configKey != null ? configKey.valueIn(id) : config.getValue());
|
||||
newValue = optionalValue.isPresent() ? optionalValue.get().toString() : defaultValue;
|
||||
break;
|
||||
|
||||
@ -1036,7 +1047,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
if (imageStoreDetailVO != null) {
|
||||
_imageStoreDetailsDao.remove(imageStoreDetailVO.getId());
|
||||
}
|
||||
optionalValue = Optional.ofNullable(configKey.valueIn(id));
|
||||
optionalValue = Optional.ofNullable(configKey != null ? configKey.valueIn(id) : config.getValue());
|
||||
newValue = optionalValue.isPresent() ? optionalValue.get().toString() : defaultValue;
|
||||
break;
|
||||
|
||||
@ -1045,7 +1056,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
s_logger.error("Failed to reset configuration option, name: " + name + ", defaultValue:" + defaultValue);
|
||||
throw new CloudRuntimeException("Failed to reset configuration value. Please contact Cloud Support.");
|
||||
}
|
||||
optionalValue = Optional.ofNullable(configKey.value());
|
||||
optionalValue = Optional.ofNullable(configKey != null ? configKey.value() : config.getValue());
|
||||
newValue = optionalValue.isPresent() ? optionalValue.get().toString() : defaultValue;
|
||||
}
|
||||
|
||||
|
||||
@ -497,7 +497,7 @@ public class ConfigDriveNetworkElement extends AdapterBase implements NetworkEle
|
||||
agentId = dest.getHost().getId();
|
||||
}
|
||||
if (!VirtualMachineManager.VmConfigDriveOnPrimaryPool.valueIn(dest.getDataCenter().getId()) &&
|
||||
!VirtualMachineManager.VmConfigDriveForceHostCacheUse.valueIn(dest.getDataCenter().getId())) {
|
||||
!VirtualMachineManager.VmConfigDriveForceHostCacheUse.valueIn(dest.getDataCenter().getId()) && dataStore != null) {
|
||||
agentId = findAgentIdForImageStore(dataStore);
|
||||
}
|
||||
return agentId;
|
||||
@ -630,6 +630,10 @@ public class ConfigDriveNetworkElement extends AdapterBase implements NetworkEle
|
||||
private boolean deleteConfigDriveIso(final VirtualMachine vm) throws ResourceUnavailableException {
|
||||
Long hostId = (vm.getHostId() != null) ? vm.getHostId() : vm.getLastHostId();
|
||||
Location location = getConfigDriveLocation(vm.getId());
|
||||
if (hostId == null) {
|
||||
LOG.info(String.format("The VM was never booted; no config-drive ISO created for VM %s", vm.getName()));
|
||||
return true;
|
||||
}
|
||||
if (location == Location.HOST) {
|
||||
return deleteConfigDriveIsoOnHostCache(vm, hostId);
|
||||
}
|
||||
@ -639,7 +643,9 @@ public class ConfigDriveNetworkElement extends AdapterBase implements NetworkEle
|
||||
|
||||
if (location == Location.SECONDARY) {
|
||||
dataStore = _dataStoreMgr.getImageStoreWithFreeCapacity(vm.getDataCenterId());
|
||||
agentId = findAgentIdForImageStore(dataStore);
|
||||
if (dataStore != null) {
|
||||
agentId = findAgentIdForImageStore(dataStore);
|
||||
}
|
||||
} else if (location == Location.PRIMARY) {
|
||||
List<VolumeVO> volumes = _volumeDao.findByInstanceAndType(vm.getId(), Volume.Type.ROOT);
|
||||
if (volumes != null && volumes.size() > 0) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user