use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.
the class BaseVmListModelTest method mockCdListModel.
protected ListModel<RepoImage> mockCdListModel() {
final ListModel<RepoImage> model = mockListModel(new RepoImage(ISO_NAME));
when(model.getIsChangable()).thenReturn(true);
return model;
}
use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.
the class RunVmCommand method guestToolsVersionTreatment.
/**
* If vds version greater then vm's and vm not running with cd and there is appropriate RhevAgentTools image -
* add it to vm as cd.
*/
private String guestToolsVersionTreatment() {
boolean attachCd = false;
String selectedToolsVersion = "";
String selectedToolsClusterVersion = "";
Guid isoDomainId = getActiveIsoDomainId();
if (osRepository.isWindows(getVm().getVmOsId()) && null != isoDomainId) {
// get cluster version of the vm tools
Version vmToolsClusterVersion = null;
if (getVm().getHasAgent()) {
Version clusterVer = getVm().getPartialVersion();
if (new Version("4.4").equals(clusterVer)) {
vmToolsClusterVersion = new Version("2.1");
} else {
vmToolsClusterVersion = clusterVer;
}
}
// Fetch cached Iso files from active Iso domain.
List<RepoImage> repoFilesMap = getIsoDomainListSynchronizer().getCachedIsoListByDomainId(isoDomainId, ImageFileType.ISO);
Version bestClusterVer = null;
int bestToolVer = 0;
for (RepoImage map : repoFilesMap) {
String fileName = StringUtils.defaultString(map.getRepoImageId(), "");
Matcher matchToolPattern = Pattern.compile(IsoDomainListSynchronizer.REGEX_TOOL_PATTERN).matcher(fileName);
if (matchToolPattern.find()) {
// Get cluster version and tool version of Iso tool.
Version clusterVer = new Version(matchToolPattern.group(IsoDomainListSynchronizer.TOOL_CLUSTER_LEVEL));
int toolVersion = Integer.parseInt(matchToolPattern.group(IsoDomainListSynchronizer.TOOL_VERSION));
if (clusterVer.compareTo(getVm().getCompatibilityVersion()) <= 0) {
if ((bestClusterVer == null) || (clusterVer.compareTo(bestClusterVer) > 0)) {
bestToolVer = toolVersion;
bestClusterVer = clusterVer;
} else if (clusterVer.equals(bestClusterVer) && toolVersion > bestToolVer) {
bestToolVer = toolVersion;
bestClusterVer = clusterVer;
}
}
}
}
if (bestClusterVer != null && (vmToolsClusterVersion == null || vmToolsClusterVersion.compareTo(bestClusterVer) < 0 || (vmToolsClusterVersion.equals(bestClusterVer) && getVm().getHasAgent() && getVm().getGuestAgentVersion().getBuild() < bestToolVer))) {
// Vm has no tools or there are new tools
selectedToolsVersion = Integer.toString(bestToolVer);
selectedToolsClusterVersion = bestClusterVer.toString();
attachCd = true;
}
}
if (attachCd) {
String rhevToolsPath = String.format("%1$s%2$s_%3$s.iso", IsoDomainListSynchronizer.getGuestToolsSetupIsoPrefix(), selectedToolsClusterVersion, selectedToolsVersion);
String isoDir = (String) runVdsCommand(VDSCommandType.IsoDirectory, new IrsBaseVDSCommandParameters(getVm().getStoragePoolId())).getReturnValue();
rhevToolsPath = isoDir + File.separator + rhevToolsPath;
return rhevToolsPath;
}
return null;
}
use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.
the class BackendFilesResource method listFiles.
protected List<String> listFiles() {
GetImagesListParameters queryParams = new GetImagesListParameters(asGuid(storageDomainId), ImageFileType.All);
Boolean forceRefresh = ParametersHelper.getBooleanParameter(httpHeaders, uriInfo, FORCE_REFRESH, null, null);
queryParams.setForceRefresh(forceRefresh);
List<RepoImage> files = getBackendCollection(RepoImage.class, QueryType.GetImagesList, queryParams);
return files.stream().map(RepoImage::getRepoImageId).collect(toList());
}
use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.
the class RepoFileMetaDataDaoTest method testSave.
/**
* Ensures that saving a domain works as expected.
*/
@Test
public void testSave() {
// Fetch the file from cache table
List<RepoImage> listOfRepoFiles = repoFileMetaDataDao.getRepoListForStorageDomain(FixturesTool.STORAGE_DOMAIN_NFS_ISO, ImageFileType.ISO);
assertNotNull(listOfRepoFiles);
assertTrue(listOfRepoFiles.isEmpty());
RepoImage newRepoFileMap = getNewIsoRepoFile();
repoFileMetaDataDao.addRepoFileMap(newRepoFileMap);
listOfRepoFiles = repoFileMetaDataDao.getRepoListForStorageDomain(FixturesTool.STORAGE_DOMAIN_NFS_ISO, ImageFileType.ISO);
assertFalse(listOfRepoFiles.isEmpty());
}
use of org.ovirt.engine.core.common.businessentities.storage.RepoImage in project ovirt-engine by oVirt.
the class RepoFileMetaDataDaoTest method getNewIsoRepoFile.
private static RepoImage getNewIsoRepoFile() {
RepoImage newRepoFileMap = new RepoImage();
newRepoFileMap.setFileType(ImageFileType.ISO);
newRepoFileMap.setRepoImageId("isoDomain.iso");
newRepoFileMap.setLastRefreshed(System.currentTimeMillis());
newRepoFileMap.setSize(null);
newRepoFileMap.setDateCreated(null);
newRepoFileMap.setRepoDomainId(FixturesTool.STORAGE_DOMAIN_NFS_ISO);
return newRepoFileMap;
}
Aggregations