use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class ClusterListModel method buildCluster.
public static Cluster buildCluster(ClusterModel model, Cluster cluster) {
Version version = model.getVersion().getSelectedItem();
cluster.setName(model.getName().getEntity());
cluster.setDescription(model.getDescription().getEntity());
cluster.setComment(model.getComment().getEntity());
cluster.setStoragePoolId(model.getDataCenter().getSelectedItem().getId());
if (model.getCPU().getSelectedItem() != null) {
cluster.setCpuName(model.getCPU().getSelectedItem().getCpuName());
}
cluster.setMaxVdsMemoryOverCommit(model.getMemoryOverCommit());
cluster.setCountThreadsAsCores(Boolean.TRUE.equals(model.getVersionSupportsCpuThreads().getEntity()) && Boolean.TRUE.equals(model.getCountThreadsAsCores().getEntity()));
cluster.setEnableKsm(Boolean.TRUE.equals(model.getEnableKsm().getEntity()));
cluster.setKsmMergeAcrossNumaNodes(model.getKsmPolicyForNuma());
cluster.setEnableBallooning(Boolean.TRUE.equals(model.getEnableBallooning().getEntity()));
// $NON-NLS-1$
cluster.setTransparentHugepages(true);
cluster.setCompatibilityVersion(version);
cluster.setRequiredSwitchTypeForCluster(model.getSwitchType().getSelectedItem());
cluster.setFirewallType(model.getFirewallType().getSelectedItem());
if (model.getDefaultNetworkProvider().getSelectedItem() != null) {
cluster.setDefaultNetworkProviderId(model.getDefaultNetworkProvider().getSelectedItem().getId());
}
cluster.setMigrateOnError(model.getMigrateOnErrorOption());
cluster.setVirtService(model.getEnableOvirtService().getEntity());
cluster.setGlusterService(model.getEnableGlusterService().getEntity());
for (AdditionalFeature feature : model.getAdditionalClusterFeatures().getSelectedItem()) {
cluster.getAddtionalFeaturesSupported().add(new SupportedAdditionalClusterFeature(cluster.getId(), true, feature));
}
cluster.setTrustedService(model.getEnableTrustedService().getEntity());
cluster.setHaReservation(model.getEnableHaReservation().getEntity());
cluster.setOptionalReasonRequired(model.getEnableOptionalReason().getEntity());
cluster.setMaintenanceReasonRequired(model.getEnableHostMaintenanceReason().getEntity());
cluster.setClusterPolicyId(model.getClusterPolicy().getSelectedItem().getId());
cluster.setClusterPolicyProperties(KeyValueModel.convertProperties(model.getCustomPropertySheet().serialize()));
if (model.getOptimizeForSpeed().getEntity()) {
cluster.setOptimizationType(OptimizationType.OPTIMIZE_FOR_SPEED);
} else if (model.getAllowOverbooking().getEntity()) {
cluster.setOptimizationType(OptimizationType.ALLOW_OVERBOOKING);
} else {
cluster.setOptimizationType(OptimizationType.NONE);
}
if (model.getCPU().getSelectedItem() == null) {
cluster.setArchitecture(model.getArchitecture().getSelectedItem());
} else {
cluster.setArchitecture(null);
}
if (model.getSpiceProxyEnabled().getEntity()) {
cluster.setSpiceProxy(model.getSpiceProxy().getEntity());
}
if (model.getMigrationPolicies().getSelectedItem() != null) {
cluster.setMigrationPolicyId(model.getMigrationPolicies().getSelectedItem().getId());
}
cluster.getFencingPolicy().setFencingEnabled(model.getFencingEnabledModel().getEntity());
cluster.getFencingPolicy().setSkipFencingIfSDActive(model.getSkipFencingIfSDActiveEnabled().getEntity());
cluster.getFencingPolicy().setSkipFencingIfConnectivityBroken(model.getSkipFencingIfConnectivityBrokenEnabled().getEntity());
cluster.getFencingPolicy().setHostsWithBrokenConnectivityThreshold(model.getHostsWithBrokenConnectivityThreshold().getSelectedItem().intValue());
cluster.getFencingPolicy().setSkipFencingIfGlusterBricksUp(model.getSkipFencingIfGlusterBricksUp().getEntity());
cluster.getFencingPolicy().setSkipFencingIfGlusterQuorumNotMet(model.getSkipFencingIfGlusterQuorumNotMet().getEntity());
cluster.setSerialNumberPolicy(model.getSerialNumberPolicy().getSelectedSerialNumberPolicy());
cluster.setCustomSerialNumber(model.getSerialNumberPolicy().getCustomSerialNumber().getEntity());
cluster.setAutoConverge(model.getAutoConverge().getSelectedItem());
cluster.setMigrateCompressed(model.getMigrateCompressed().getSelectedItem());
if (model.getEnableGlusterService().getEntity()) {
cluster.setGlusterTunedProfile(model.getGlusterTunedProfile().getSelectedItem());
}
cluster.getAdditionalRngSources().clear();
if (Boolean.TRUE.equals(model.getRngHwrngSourceRequired().getEntity())) {
cluster.getAdditionalRngSources().add(VmRngDevice.Source.HWRNG);
}
cluster.setMigrationBandwidthLimitType(model.getMigrationBandwidthLimitType().getSelectedItem());
cluster.setCustomMigrationNetworkBandwidth(MigrationBandwidthLimitType.CUSTOM.equals(model.getMigrationBandwidthLimitType().getSelectedItem()) ? model.getCustomMigrationNetworkBandwidth().getEntity() : null);
cluster.setMacPoolId(model.getMacPoolListModel().getSelectedItem().getId());
return cluster;
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class ClusterModel method version_SelectedItemChanged.
private void version_SelectedItemChanged() {
Version version = getEffectiveVersion();
AsyncDataProvider.getInstance().getCPUList(new AsyncQuery<>(cpus -> {
if (getIsEdit()) {
AsyncDataProvider.getInstance().isClusterEmpty(new AsyncQuery<>(isEmpty -> {
if (isEmpty) {
populateCPUList(cpus, true);
} else {
ArrayList<ServerCpu> filteredCpus = new ArrayList<>();
for (ServerCpu cpu : cpus) {
if (cpu.getArchitecture() == getEntity().getArchitecture()) {
filteredCpus.add(cpu);
}
}
populateCPUList(filteredCpus, false);
}
}), getEntity().getId());
} else {
cpus.add(0, null);
populateCPUList(cpus, true);
}
}), version);
getVersionSupportsCpuThreads().setEntity(true);
getEnableBallooning().setChangeProhibitionReason(ConstantsManager.getInstance().getConstants().ballooningNotAvailable());
getEnableBallooning().setIsChangeable(true);
setRngSourcesCheckboxes(version);
updateSwitchTypeUponVersionChange(version);
updateFirewallTypeUponVersionChange(version);
updateFencingPolicyContent(version);
updateMigrateOnError();
refreshMigrationPolicies();
refreshAdditionalClusterFeaturesList();
if (getEnableGlusterService().getEntity()) {
initTunedProfiles();
}
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class ClusterModel method updateMigrateOnError.
private void updateMigrateOnError() {
ServerCpu cpu = getCPU().getSelectedItem();
Version version = getVersion().getSelectedItem();
if (version == null) {
return;
}
if (cpu == null || cpu.getArchitecture() == null) {
return;
}
getMigrateOnErrorOption_NO().setIsAvailable(true);
if (AsyncDataProvider.getInstance().isMigrationSupported(cpu.getArchitecture(), version)) {
getMigrateOnErrorOption_YES().setIsAvailable(true);
getMigrateOnErrorOption_HA_ONLY().setIsAvailable(true);
} else {
getMigrateOnErrorOption_YES().setIsAvailable(false);
getMigrateOnErrorOption_HA_ONLY().setIsAvailable(false);
setMigrateOnErrorOption(MigrateOnErrorOptions.NO);
}
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class ClusterModel method initTunedProfiles.
public void initTunedProfiles() {
this.startProgress();
if (getVersion() == null || getVersion().getSelectedItem() == null) {
return;
}
Version version = getVersion().getSelectedItem();
Frontend.getInstance().runQuery(QueryType.GetGlusterTunedProfiles, new IdAndNameQueryParameters(null, version.getValue()), new AsyncQuery<QueryReturnValue>(returnValue -> {
stopProgress();
List<String> glusterTunedProfiles = new ArrayList<>();
if (returnValue.getSucceeded()) {
glusterTunedProfiles.addAll(returnValue.getReturnValue());
}
final String oldSelectedProfile = glusterTunedProfile.getSelectedItem();
glusterTunedProfile.setItems(glusterTunedProfiles);
glusterTunedProfile.setIsAvailable(glusterTunedProfile.getItems().size() > 0);
String newSelectedItem = null;
if (oldSelectedProfile != null) {
newSelectedItem = Linq.firstOrNull(glusterTunedProfiles, x -> x.equals(oldSelectedProfile));
}
if (newSelectedItem != null) {
glusterTunedProfile.setSelectedItem(newSelectedItem);
} else if (getIsEdit()) {
glusterTunedProfile.setSelectedItem(Linq.firstOrNull(glusterTunedProfiles, x -> x.equals(getEntity().getGlusterTunedProfile())));
}
}));
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class ClusterModel method storagePool_SelectedItemChanged.
private void storagePool_SelectedItemChanged() {
// possible versions for new cluster (when editing cluster, this event won't occur)
// are actually the possible versions for the data-center that the cluster is going
// to be attached to.
final StoragePool selectedDataCenter = getDataCenter().getSelectedItem();
if (selectedDataCenter == null) {
getManagementNetwork().setItems(Collections.emptyList());
return;
}
if (selectedDataCenter.isLocal()) {
setMigrationTabAvailable(false);
} else {
setMigrationTabAvailable(true);
}
AsyncDataProvider.getInstance().getDataCenterVersions(new AsyncQuery<>(new AsyncCallback<List<Version>>() {
@Override
public void onSuccess(List<Version> versions) {
Version versionToSelect = calculateNewVersionWhichShouldBeSelected(versions);
getVersion().setItems(versions, versionToSelect);
}
private Version calculateNewVersionWhichShouldBeSelected(List<Version> versions) {
ListModel<Version> version = getVersion();
Version selectedVersion = version.getSelectedItem();
if (!getIsEdit() && (selectedVersion == null || !versions.contains(selectedVersion) || selectedVersion.compareTo(selectedDataCenter.getCompatibilityVersion()) > 0)) {
if (ApplicationModeHelper.getUiMode().equals(ApplicationMode.GlusterOnly)) {
return versions.stream().max(Comparator.naturalOrder()).orElse(null);
} else {
return selectedDataCenter.getCompatibilityVersion();
}
} else if (getIsEdit()) {
return Linq.firstOrNull(versions, x -> x.equals(getEntity().getCompatibilityVersion()));
} else {
return selectedVersion;
}
}
}), ApplicationModeHelper.getUiMode().equals(ApplicationMode.GlusterOnly) ? null : selectedDataCenter.getId());
if (getManagementNetwork().getIsChangable()) {
loadDcNetworks(selectedDataCenter.getId());
}
}
Aggregations