use of org.ovirt.engine.core.common.businessentities.AdditionalFeature 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.common.businessentities.AdditionalFeature in project ovirt-engine by oVirt.
the class ClusterModel method updateAddtionClusterFeatureList.
private void updateAddtionClusterFeatureList(Set<AdditionalFeature> featuresAvailable, Set<AdditionalFeature> featuresEnabled) {
List<AdditionalFeature> features = new ArrayList<>();
List<AdditionalFeature> selectedFeatures = new ArrayList<>();
for (AdditionalFeature feature : featuresAvailable) {
features.add(feature);
if (featuresEnabled.contains(feature)) {
selectedFeatures.add(feature);
}
}
List<List<AdditionalFeature>> clusterFeatureList = new ArrayList<>();
clusterFeatureList.add(features);
getAdditionalClusterFeatures().setItems(clusterFeatureList, selectedFeatures);
}
use of org.ovirt.engine.core.common.businessentities.AdditionalFeature in project ovirt-engine by oVirt.
the class ClusterModel method init.
public void init(final boolean isEdit) {
setIsEdit(isEdit);
setName(new EntityModel<>());
setDescription(new EntityModel<>());
setComment(new EntityModel<>());
setEnableTrustedService(new EntityModel<>(false));
setEnableHaReservation(new EntityModel<>(false));
setEnableOptionalReason(new EntityModel<>(false));
setMigrationPolicies(new ListModel<>());
getMigrationPolicies().getSelectedItemChangedEvent().addListener(this);
getEnableOptionalReason().setIsAvailable(ApplicationModeHelper.isModeSupported(ApplicationMode.VirtOnly));
setEnableHostMaintenanceReason(new EntityModel<>(false));
setAllowClusterWithVirtGlusterEnabled(true);
setGlusterTunedProfile(new ListModel<>());
AsyncDataProvider.getInstance().getAllowClusterWithVirtGlusterEnabled(new AsyncQuery<>(this::setAllowClusterWithVirtGlusterEnabled));
setEnableOvirtService(new EntityModel<>());
setEnableGlusterService(new EntityModel<>());
setAdditionalClusterFeatures(new ListModel<>());
List<List<AdditionalFeature>> additionalFeatures = new ArrayList<>();
additionalFeatures.add(Collections.emptyList());
getAdditionalClusterFeatures().setItems(additionalFeatures, null);
setSpiceProxyEnabled(new EntityModel<>());
getSpiceProxyEnabled().setEntity(false);
getSpiceProxyEnabled().getEntityChangedEvent().addListener(this);
setSpiceProxy(new EntityModel<>());
getSpiceProxy().setIsChangeable(false);
setFencingEnabledModel(new EntityModel<>());
getFencingEnabledModel().setEntity(true);
getFencingEnabledModel().getEntityChangedEvent().addListener((ev, sender, args) -> updateFencingPolicyContent(getVersion() == null ? null : getVersion().getSelectedItem()));
setSkipFencingIfSDActiveEnabled(new EntityModel<>());
getSkipFencingIfSDActiveEnabled().setEntity(true);
setSkipFencingIfGlusterBricksUp(new EntityModel<>());
getSkipFencingIfGlusterBricksUp().setEntity(false);
getSkipFencingIfGlusterBricksUp().setIsAvailable(false);
setSkipFencingIfGlusterQuorumNotMet(new EntityModel<>());
getSkipFencingIfGlusterQuorumNotMet().setEntity(false);
getSkipFencingIfGlusterQuorumNotMet().setIsAvailable(false);
setSkipFencingIfConnectivityBrokenEnabled(new EntityModel<>());
getSkipFencingIfConnectivityBrokenEnabled().setEntity(true);
setEnableOvirtService(new EntityModel<>());
setEnableGlusterService(new EntityModel<>());
setSerialNumberPolicy(new SerialNumberPolicyModel());
setAutoConverge(new ListModel<>());
getAutoConverge().setItems(Arrays.asList(null, true, false));
setMigrateCompressed(new ListModel<>());
getMigrateCompressed().setItems(Arrays.asList(null, true, false));
getEnableOvirtService().getEntityChangedEvent().addListener((ev, sender, args) -> {
refreshAdditionalClusterFeaturesList();
if (!getAllowClusterWithVirtGlusterEnabled() && getEnableOvirtService().getEntity()) {
getEnableGlusterService().setEntity(Boolean.FALSE);
}
updateGlusterFencingPolicyAvailability();
getEnableGlusterService().setIsChangeable(true);
getEnableTrustedService().setEntity(false);
if (getEnableOvirtService().getEntity() != null && getEnableOvirtService().getEntity()) {
if (getEnableGlusterService().getEntity() != null && !getEnableGlusterService().getEntity()) {
getEnableTrustedService().setIsChangeable(true);
} else {
getEnableTrustedService().setIsChangeable(false);
}
} else {
getEnableTrustedService().setIsChangeable(false);
}
});
getEnableOvirtService().setEntity(ApplicationModeHelper.isModeSupported(ApplicationMode.VirtOnly));
getEnableOvirtService().setIsAvailable(ApplicationModeHelper.getUiMode() != ApplicationMode.VirtOnly && ApplicationModeHelper.isModeSupported(ApplicationMode.VirtOnly));
setRngHwrngSourceRequired(new EntityModel<>());
getRngHwrngSourceRequired().setIsAvailable(ApplicationModeHelper.isModeSupported(ApplicationMode.VirtOnly));
initImportCluster();
getEnableGlusterService().getEntityChangedEvent().addListener((ev, sender, args) -> {
refreshAdditionalClusterFeaturesList();
if (!getAllowClusterWithVirtGlusterEnabled() && getEnableGlusterService().getEntity()) {
getEnableOvirtService().setEntity(Boolean.FALSE);
}
if (!isEdit && getEnableGlusterService().getEntity() != null && getEnableGlusterService().getEntity()) {
getIsImportGlusterConfiguration().setIsAvailable(true);
getGlusterHostAddress().setIsAvailable(true);
getGlusterHostFingerprint().setIsAvailable(true);
getGlusterHostPassword().setIsAvailable(true);
} else {
getIsImportGlusterConfiguration().setIsAvailable(false);
getIsImportGlusterConfiguration().setEntity(false);
getGlusterHostAddress().setIsAvailable(false);
getGlusterHostFingerprint().setIsAvailable(false);
getGlusterHostPassword().setIsAvailable(false);
}
if (getEnableGlusterService().getEntity() != null && getEnableGlusterService().getEntity()) {
getEnableTrustedService().setEntity(false);
getEnableTrustedService().setIsChangeable(false);
} else {
if (getEnableOvirtService().getEntity() != null && getEnableOvirtService().getEntity()) {
getEnableTrustedService().setIsChangeable(true);
} else {
getEnableTrustedService().setIsChangeable(false);
}
}
getGlusterTunedProfile().setIsAvailable(getEnableGlusterService().getEntity());
updateGlusterFencingPolicyAvailability();
if (getEnableGlusterService().getEntity()) {
initTunedProfiles();
}
});
getEnableTrustedService().getEntityChangedEvent().addListener((ev, sender, args) -> {
if (getEnableTrustedService().getEntity() != null && getEnableTrustedService().getEntity()) {
getEnableGlusterService().setEntity(false);
getEnableGlusterService().setIsChangeable(false);
} else {
getEnableGlusterService().setIsChangeable(true);
}
});
getEnableGlusterService().setEntity(ApplicationModeHelper.getUiMode() == ApplicationMode.GlusterOnly);
getEnableGlusterService().setIsAvailable(ApplicationModeHelper.getUiMode() != ApplicationMode.GlusterOnly && ApplicationModeHelper.isModeSupported(ApplicationMode.GlusterOnly));
getGlusterTunedProfile().setIsAvailable(getEnableGlusterService().getEntity());
setOptimizationNone(new EntityModel<>());
setOptimizationForServer(new EntityModel<>());
setOptimizationForDesktop(new EntityModel<>());
setOptimizationCustom(new EntityModel<>());
EntityModel<Boolean> tempVar = new EntityModel<>();
tempVar.setEntity(false);
setOptimizationNone_IsSelected(tempVar);
getOptimizationNone_IsSelected().getEntityChangedEvent().addListener(this);
EntityModel<Boolean> tempVar2 = new EntityModel<>();
tempVar2.setEntity(false);
setOptimizationForServer_IsSelected(tempVar2);
getOptimizationForServer_IsSelected().getEntityChangedEvent().addListener(this);
EntityModel<Boolean> tempVar3 = new EntityModel<>();
tempVar3.setEntity(false);
setOptimizationForDesktop_IsSelected(tempVar3);
getOptimizationForDesktop_IsSelected().getEntityChangedEvent().addListener(this);
EntityModel<Boolean> tempVar4 = new EntityModel<>();
tempVar4.setEntity(false);
tempVar4.setIsAvailable(false);
setOptimizationCustom_IsSelected(tempVar4);
getOptimizationCustom_IsSelected().getEntityChangedEvent().addListener(this);
EntityModel<Boolean> tempVar5 = new EntityModel<>();
tempVar5.setEntity(false);
setMigrateOnErrorOption_YES(tempVar5);
getMigrateOnErrorOption_YES().getEntityChangedEvent().addListener(this);
EntityModel<Boolean> tempVar6 = new EntityModel<>();
tempVar6.setEntity(false);
setMigrateOnErrorOption_NO(tempVar6);
getMigrateOnErrorOption_NO().getEntityChangedEvent().addListener(this);
EntityModel<Boolean> tempVar7 = new EntityModel<>();
tempVar7.setEntity(false);
setMigrateOnErrorOption_HA_ONLY(tempVar7);
getMigrateOnErrorOption_HA_ONLY().getEntityChangedEvent().addListener(this);
// KSM feature
setEnableKsm(new EntityModel<>());
getEnableKsm().setEntity(false);
getKsmPolicyForNumaSelection().setIsChangeable(false);
getEnableKsm().getEntityChangedEvent().addListener((ev, sender, args) -> {
if (getEnableKsm().getEntity() == null) {
return;
}
if (getEnableKsm().getEntity()) {
getKsmPolicyForNumaSelection().setIsChangeable(true);
}
if (!getEnableKsm().getEntity()) {
getKsmPolicyForNumaSelection().setIsChangeable(false);
}
});
setEnableBallooning(new EntityModel<>());
getEnableBallooning().setEntity(false);
// Optimization methods:
// default value =100;
setDefaultMemoryOvercommit(AsyncDataProvider.getInstance().getClusterDefaultMemoryOverCommit());
setCountThreadsAsCores(new EntityModel<>(AsyncDataProvider.getInstance().getClusterDefaultCountThreadsAsCores()));
setVersionSupportsCpuThreads(new EntityModel<>(true));
setOptimizeForUtilization(new EntityModel<>());
setOptimizeForSpeed(new EntityModel<>());
getOptimizeForUtilization().setEntity(true);
getOptimizeForSpeed().setEntity(false);
getOptimizeForUtilization().getEntityChangedEvent().addListener(this);
getOptimizeForSpeed().getEntityChangedEvent().addListener(this);
setGuarantyResources(new EntityModel<>());
setAllowOverbooking(new EntityModel<>());
getGuarantyResources().setEntity(true);
getAllowOverbooking().setEntity(false);
getAllowOverbooking().getEntityChangedEvent().addListener(this);
getGuarantyResources().getEntityChangedEvent().addListener(this);
boolean overbookingSupported = AsyncDataProvider.getInstance().getScheudulingAllowOverbookingSupported();
getAllowOverbooking().setIsAvailable(overbookingSupported);
if (overbookingSupported) {
getOptimizeForSpeed().getEntityChangedEvent().addListener((ev, sender, args) -> {
Boolean entity = getOptimizeForSpeed().getEntity();
if (entity) {
getGuarantyResources().setEntity(true);
}
getAllowOverbooking().setIsChangeable(!entity);
});
getAllowOverbooking().getEntityChangedEvent().addListener((ev, sender, args) -> {
Boolean entity = getAllowOverbooking().getEntity();
if (entity) {
getOptimizeForUtilization().setEntity(true);
}
getOptimizeForSpeed().setIsChangeable(!entity);
});
}
setHostsWithBrokenConnectivityThreshold(new ListModel<>());
getHostsWithBrokenConnectivityThreshold().setIsAvailable(true);
getHostsWithBrokenConnectivityThreshold().getSelectedItemChangedEvent().addListener(this);
initHostsWithBrokenConnectivityThreshold();
AsyncDataProvider.getInstance().getClusterDesktopMemoryOverCommit(new AsyncQuery<>(result -> {
setDesktopOverCommit(result);
AsyncDataProvider.getInstance().getClusterServerMemoryOverCommit(new AsyncQuery<>(r -> {
setServerOverCommit(r);
// temp is used for conversion purposes
EntityModel temp;
temp = getOptimizationNone();
temp.setEntity(getDefaultMemoryOvercommit());
// res1, res2 is used for conversion purposes.
boolean res1 = getDesktopOverCommit() != getDefaultMemoryOvercommit();
boolean res2 = getServerOverCommit() != getDefaultMemoryOvercommit();
temp = getOptimizationNone_IsSelected();
setIsSelected(res1 && res2);
temp.setEntity(getIsSelected());
temp = getOptimizationForServer();
temp.setEntity(getServerOverCommit());
temp = getOptimizationForServer_IsSelected();
temp.setEntity(getServerOverCommit() == getDefaultMemoryOvercommit());
temp = getOptimizationForDesktop();
temp.setEntity(getDesktopOverCommit());
temp = getOptimizationForDesktop_IsSelected();
temp.setEntity(getDesktopOverCommit() == getDefaultMemoryOvercommit());
temp = getOptimizationCustom();
temp.setIsAvailable(false);
temp.setIsChangeable(false);
if (getIsEdit()) {
postInit();
}
}));
}));
setDataCenter(new ListModel<>());
getDataCenter().getSelectedItemChangedEvent().addListener(this);
getDataCenter().setIsAvailable(ApplicationModeHelper.getUiMode() != ApplicationMode.GlusterOnly);
setArchitecture(new ListModel<>());
getArchitecture().setIsAvailable(ApplicationModeHelper.isModeSupported(ApplicationMode.VirtOnly));
setManagementNetwork(new ListModel<>());
if (isEdit && !isClusterDetached()) {
getManagementNetwork().setChangeProhibitionReason(ConstantsManager.getInstance().getConstants().prohibitManagementNetworkChangeInEditClusterInfoMessage());
getManagementNetwork().setIsChangeable(false);
}
setCPU(new FilteredListModel<>());
getCPU().setIsAvailable(ApplicationModeHelper.getUiMode() != ApplicationMode.GlusterOnly);
getCPU().getSelectedItemChangedEvent().addListener(this);
setVersion(new ListModel<>());
getVersion().getSelectedItemChangedEvent().addListener(this);
setMigrateOnErrorOption(MigrateOnErrorOptions.YES);
setFirewallType(new ListModel<>());
initFirewallType();
setDefaultNetworkProvider(new ListModel<>());
initDefaultNetworkProvider();
setSwitchType(new ListModel<>());
initSwitchType();
getRngHwrngSourceRequired().setEntity(false);
setValidTab(TabName.GENERAL_TAB, true);
setMigrationTabAvailable(true);
setClusterPolicy(new ListModel<>());
setCustomPropertySheet(new KeyValueModel());
getClusterPolicy().getSelectedItemChangedEvent().addListener(this);
Frontend.getInstance().runQuery(QueryType.GetAllPolicyUnits, new QueryParametersBase(), new AsyncQuery<QueryReturnValue>(returnValue -> {
ArrayList<PolicyUnit> policyUnits = returnValue.getReturnValue();
policyUnitMap = new LinkedHashMap<>();
for (PolicyUnit policyUnit : policyUnits) {
policyUnitMap.put(policyUnit.getId(), policyUnit);
}
Frontend.getInstance().runQuery(QueryType.GetClusterPolicies, new QueryParametersBase(), new AsyncQuery<QueryReturnValue>(retVal -> {
ArrayList<ClusterPolicy> list = retVal.getReturnValue();
getClusterPolicy().setItems(list);
ClusterPolicy defaultClusterPolicy = null;
ClusterPolicy selectedClusterPolicy = null;
for (ClusterPolicy clusterPolicy : list) {
if (getIsEdit() && getEntity() != null && clusterPolicy.getId().equals(getEntity().getClusterPolicyId())) {
selectedClusterPolicy = clusterPolicy;
}
if (clusterPolicy.isDefaultPolicy()) {
defaultClusterPolicy = clusterPolicy;
}
}
if (selectedClusterPolicy != null) {
getClusterPolicy().setSelectedItem(selectedClusterPolicy);
} else {
getClusterPolicy().setSelectedItem(defaultClusterPolicy);
}
clusterPolicyChanged();
}));
}));
setCustomMigrationNetworkBandwidth(new EntityModel<>());
setMigrationBandwidthLimitType(new ListModel<>());
}
use of org.ovirt.engine.core.common.businessentities.AdditionalFeature in project ovirt-engine by oVirt.
the class ClusterFeatureDaoTest method buildSupportedFeature.
private SupportedAdditionalClusterFeature buildSupportedFeature(Guid featureId, Guid clusterId, boolean enabled) {
SupportedAdditionalClusterFeature supportedAdditionalClusterFeature = new SupportedAdditionalClusterFeature();
supportedAdditionalClusterFeature.setClusterId(clusterId);
supportedAdditionalClusterFeature.setEnabled(enabled);
supportedAdditionalClusterFeature.setFeature(new AdditionalFeature());
supportedAdditionalClusterFeature.getFeature().setId(featureId);
return supportedAdditionalClusterFeature;
}
use of org.ovirt.engine.core.common.businessentities.AdditionalFeature in project ovirt-engine by oVirt.
the class UpdateClusterCommandTest method createClusterWithAddtionalFeature.
private static Cluster createClusterWithAddtionalFeature() {
Cluster group = createDefaultCluster();
group.setCompatibilityVersion(VERSION_1_1);
Set<SupportedAdditionalClusterFeature> addtionalFeaturesSupported = new HashSet<>();
AdditionalFeature feature = new AdditionalFeature(DEFAULT_FEATURE_ID, "TEST_FEATURE", VERSION_1_1, "Test Feature", ApplicationMode.AllModes);
addtionalFeaturesSupported.add(new SupportedAdditionalClusterFeature(group.getId(), true, feature));
group.setAddtionalFeaturesSupported(addtionalFeaturesSupported);
return group;
}
Aggregations