use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class ConfigureLocalStorageModel method dataCenterVersion_SelectedItemChanged.
private void dataCenterVersion_SelectedItemChanged() {
Version version = getDataCenter().getVersion().getSelectedItem();
// Keep in sync version for data center and cluster.
getCluster().getVersion().setSelectedItem(version);
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class ConfigureLocalStorageModel method setDefaultNames8.
private void setDefaultNames8() {
VDS host = context.host;
List<StoragePool> dataCenters = context.dataCenterList;
List<Cluster> clusters = context.clusterList;
// $NON-NLS-1$
setCommonName(host.getName().replace('.', '-') + "-Local");
StoragePool candidate = null;
// Check if current settings suitable for local setup (in case just SD creation failed - re-using the same
// setup)
boolean useCurrentSettings = false;
if (host.getStoragePoolId() != null) {
StoragePool tempCandidate = context.hostDataCenter;
if (isLocalDataCenterEmpty(tempCandidate)) {
candidate = tempCandidate;
useCurrentSettings = true;
} else {
if (tempCandidate != null && tempCandidate.isLocal()) {
setMessage(ConstantsManager.getInstance().getConstants().noteLocalStorageAlreadyConfiguredForThisHostMsg() + " " + host.getStoragePoolName() + " " + // $NON-NLS-1$ //$NON-NLS-2$
ConstantsManager.getInstance().getConstants().withLocalStorageDomainMsg());
}
}
}
// Check if there is other DC suitable for re-use
if (candidate == null) {
for (StoragePool dataCenter : dataCenters) {
// Need to check if the new DC is without host.
if (isLocalDataCenterEmpty(dataCenter) && context.localStorageHostByDataCenterMap.get(dataCenter) == null) {
candidate = dataCenter;
break;
}
}
}
ArrayList<String> names;
// In case we found a suitable candidate for re-use:
if (candidate != null) {
getDataCenter().setDataCenterId(candidate.getId());
getDataCenter().getName().setEntity(candidate.getName());
getDataCenter().getDescription().setEntity(candidate.getdescription());
Version version = candidate.getCompatibilityVersion();
getDataCenter().getVersion().setSelectedItem(version);
getCluster().getVersion().setSelectedItem(version);
setCandidateDataCenter(candidate);
// If we use current settings there is no need to create cluster.
if (useCurrentSettings) {
getCluster().setClusterId(host.getClusterId());
getCluster().getName().setEntity(host.getClusterName());
Cluster cluster = context.hostCluster;
if (cluster != null) {
getCluster().getDescription().setEntity(cluster.getDescription());
ServerCpu cpu = new ServerCpu();
cpu.setCpuName(cluster.getCpuName());
getCluster().getCPU().setSelectedItem(cpu);
}
setCandidateCluster(cluster);
} else // Use different cluster
{
// Check the DC cluster list (for re-use)
clusters = context.clusterListByDataCenterMap.get(candidate);
// No clusters available - pick up new name.
if (clusters == null || clusters.isEmpty()) {
names = new ArrayList<>();
List<Cluster> listClusters = context.clusterList;
for (Cluster cluster : listClusters) {
names.add(cluster.getName());
}
getCluster().getName().setEntity(availableName(names));
} else {
// Use the DC cluster.
Cluster cluster = Linq.firstOrNull(clusters);
getCluster().setClusterId(cluster.getId());
getCluster().getName().setEntity(cluster.getName());
getCluster().getDescription().setEntity(cluster.getDescription());
cluster = Linq.firstOrNull(context.clusterList, new Linq.IdPredicate<>(getCluster().getClusterId()));
if (cluster != null) {
ServerCpu cpu = new ServerCpu();
cpu.setCpuName(cluster.getCpuName());
getCluster().getCPU().setSelectedItem(cpu);
}
setCandidateCluster(cluster);
}
}
} else {
// Didn't found DC to re-use, so we select new names.
names = new ArrayList<>();
for (StoragePool dataCenter : dataCenters) {
names.add(dataCenter.getName());
}
getDataCenter().getName().setEntity(availableName(names));
// Choose a Data Center version corresponding to the host.
if (!StringHelper.isNullOrEmpty(host.getSupportedClusterLevels())) {
// The supported_cluster_levels are sorted.
// $NON-NLS-1$
String[] array = host.getSupportedClusterLevels().split("[,]", -1);
Version maxVersion = null;
for (int i = 0; i < array.length; i++) {
Version vdsVersion = new Version(array[i]);
for (Version version : getDataCenter().getVersion().getItems()) {
if (version.equals(vdsVersion) && version.compareTo(maxVersion) > 0) {
maxVersion = version;
}
}
}
if (maxVersion != null) {
getDataCenter().getVersion().setSelectedItem(maxVersion);
getCluster().getVersion().setSelectedItem(maxVersion);
}
}
names = new ArrayList<>();
if (clusters != null) {
for (Cluster cluster : clusters) {
names.add(cluster.getName());
}
}
getCluster().getName().setEntity(availableName(names));
}
// Choose default CPU name to match host.
List<ServerCpu> serverCpus = (List<ServerCpu>) getCluster().getCPU().getItems();
if (host.getCpuName() != null) {
getCluster().getCPU().setSelectedItem(Linq.firstOrNull(serverCpus, new Linq.ServerCpuPredicate(host.getCpuName().getCpuName())));
} else {
getCluster().getCPU().setSelectedItem(serverCpus.isEmpty() ? null : serverCpus.get(0));
}
// Always choose a available storage name.
List<StorageDomain> storages = context.storageList;
names = new ArrayList<>();
for (StorageDomain storageDomain : storages) {
names.add(storageDomain.getStorageName());
}
getFormattedStorageName().setEntity(availableName(names));
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class TryBackToAllSnapshotsOfVmCommand method validateMemoryTakenInSupportedVersion.
private boolean validateMemoryTakenInSupportedVersion() {
VM vmFromSnapshot = null;
try {
vmFromSnapshot = ovfHelper.readVmFromOvf(getDstSnapshot().getVmConfiguration()).getVm();
} catch (OvfReaderException e) {
// should never happen since the OVF was created by us
log.error("Failed to parse a given ovf configuration: {}", e.getMessage());
return false;
}
Version originalClusterVersion = vmFromSnapshot.getClusterCompatibilityVersionOrigin();
if (Version.getLowest().greater(originalClusterVersion)) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_MEMORY_TOO_OLD, String.format("$Cv %s", originalClusterVersion != null ? originalClusterVersion : "N/A"));
}
return true;
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class CustomMapSqlParameterSourceTest method testAddValueVersion.
@Test
public void testAddValueVersion() {
Version verision = new Version(this.random.nextInt(), this.random.nextInt());
paramSource.addValue(paramName, verision);
assertEquals("wrong value returned from parameter source", verision.toString(), paramSource.getValue(paramName));
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class LibvirtVmXmlBuilder method writeClusterVersionMetadata.
private void writeClusterVersionMetadata() {
Version version = vm.getCompatibilityVersion();
writer.writeStartElement("clusterVersion");
writer.writeRaw(String.valueOf(version.getMajor()) + "." + String.valueOf(version.getMinor()));
writer.writeEndElement();
}
Aggregations