use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.
the class UnitVmModel method updateMigrationRelatedFields.
private void updateMigrationRelatedFields() {
Cluster cluster = getSelectedCluster();
boolean override = Boolean.TRUE.equals(getOverrideMigrationPolicy().getEntity());
boolean hasMigrationPolicy = true;
if (override) {
MigrationPolicy selectedPolicy = getMigrationPolicies().getSelectedItem();
if (selectedPolicy == null) {
// if had selected something which does not exist anymore
hasMigrationPolicy = false;
} else if (selectedPolicy.getId().equals(NoMigrationPolicy.ID)) {
// explicitly selected the empty
hasMigrationPolicy = false;
}
} else {
if (cluster == null) {
// for non-cluster entities (e.g. blank template, instance types)
hasMigrationPolicy = false;
} else if (cluster.getMigrationPolicyId() == null || cluster.getMigrationPolicyId().equals(NoMigrationPolicy.ID)) {
// explicitly selected the empty
hasMigrationPolicy = false;
}
}
getOverrideMigrationDowntime().setIsChangeable(!hasMigrationPolicy, constants.availableOnlyWithLegacyPolicy());
boolean overrideDowntime = Boolean.TRUE.equals(getOverrideMigrationDowntime().getEntity());
getMigrationDowntime().setIsChangeable(!hasMigrationPolicy && overrideDowntime, constants.availableOnlyWithLegacyPolicy());
getAutoConverge().setIsChangeable(!hasMigrationPolicy, constants.availableOnlyWithLegacyPolicy());
getMigrateCompressed().setIsChangeable(!hasMigrationPolicy, constants.availableOnlyWithLegacyPolicy());
}
use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.
the class UnitVmModel method setupDataCenterWithClusters.
protected void setupDataCenterWithClusters(UnitVmModel model, List<StoragePool> dataCenters, List<Cluster> clusters, Guid selectedCluster) {
Map<Guid, List<Cluster>> dataCenterToCluster = new HashMap<>();
for (Cluster cluster : clusters) {
if (cluster.getStoragePoolId() == null) {
continue;
}
if (!dataCenterToCluster.containsKey(cluster.getStoragePoolId())) {
dataCenterToCluster.put(cluster.getStoragePoolId(), new ArrayList<Cluster>());
}
dataCenterToCluster.get(cluster.getStoragePoolId()).add(cluster);
}
List<DataCenterWithCluster> dataCentersWithClusters = new ArrayList<>();
for (StoragePool dataCenter : dataCenters) {
if (dataCenterToCluster.containsKey(dataCenter.getId())) {
for (Cluster cluster : dataCenterToCluster.get(dataCenter.getId())) {
dataCentersWithClusters.add(new DataCenterWithCluster(dataCenter, cluster));
}
}
}
selectDataCenterWithCluster(selectedCluster, dataCentersWithClusters);
}
use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.
the class VirtioScsiUtil method updateVirtioScsiEnabled.
public void updateVirtioScsiEnabled(final Guid vmId, int osId, VirtioScasiEnablingFinished finishedCallback) {
this.finishedCallback = finishedCallback;
final Cluster cluster = model.getSelectedCluster();
if (cluster == null) {
return;
}
AsyncDataProvider.getInstance().getDiskInterfaceList(osId, cluster.getCompatibilityVersion(), model.asyncQuery(diskInterfaces -> {
boolean isOsSupportVirtioScsi = diskInterfaces.contains(DiskInterface.VirtIO_SCSI);
callBeforeUpdates();
model.getIsVirtioScsiEnabled().setIsChangeable(isOsSupportVirtioScsi);
if (!isOsSupportVirtioScsi) {
model.getIsVirtioScsiEnabled().setEntity(false);
model.getIsVirtioScsiEnabled().setChangeProhibitionReason(constants.cannotEnableVirtioScsiForOs());
callAfterUpdates();
} else {
AsyncDataProvider.getInstance().isVirtioScsiEnabledForVm(model.asyncQuery(returnValue -> {
model.getIsVirtioScsiEnabled().setEntity(returnValue);
callAfterUpdates();
}), vmId);
}
}));
}
use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.
the class ExistingVmModelBehavior method loadDataCenter.
private void loadDataCenter() {
// Preinitialize the VM compatibility version because it's needed during init
Version newCustomCompatibilityVersion = ((ExistingVmModelBehavior) getModel().getBehavior()).getVm().getStaticData().getCustomCompatibilityVersion();
if (newCustomCompatibilityVersion != null) {
getModel().getCustomCompatibilityVersion().setItems(Collections.singletonList(newCustomCompatibilityVersion), newCustomCompatibilityVersion);
}
AsyncDataProvider.getInstance().getDataCenterById(asyncQuery(dataCenter -> {
if (dataCenter != null) {
final List<StoragePool> dataCenters = new ArrayList<>(Arrays.asList(new StoragePool[] { dataCenter }));
initClusters(dataCenters);
} else {
ExistingVmModelBehavior behavior = (ExistingVmModelBehavior) getModel().getBehavior();
VM currentVm = behavior.vm;
Cluster cluster = new Cluster();
cluster.setId(currentVm.getClusterId());
cluster.setName(currentVm.getClusterName());
cluster.setCompatibilityVersion(currentVm.getClusterCompatibilityVersion());
cluster.setStoragePoolId(currentVm.getStoragePoolId());
DataCenterWithCluster dataCenterWithCluster = new DataCenterWithCluster(null, cluster);
getModel().getDataCenterWithClustersList().setItems(Arrays.asList(dataCenterWithCluster));
getModel().getDataCenterWithClustersList().setSelectedItem(dataCenterWithCluster);
behavior.initTemplate();
behavior.updateCdImage();
}
}), vm.getStoragePoolId());
}
use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.
the class ExistingVmModelBehavior method isHotSetCpuSupported.
public boolean isHotSetCpuSupported() {
Cluster selectedCluster = getModel().getSelectedCluster();
Version compatibilityVersion = getModel().getCompatibilityVersion();
boolean hotplugCpuSupported = Boolean.parseBoolean(((Map<String, String>) AsyncDataProvider.getInstance().getConfigValuePreConverted(ConfigValues.HotPlugCpuSupported, compatibilityVersion.getValue())).get(selectedCluster.getArchitecture().name()));
return getVm().getStatus() == VMStatus.Up && hotplugCpuSupported;
}
Aggregations