use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class ClusterPopupView method edit.
@Override
public void edit(final ClusterModel object) {
driver.edit(object);
updateMacPool(object.getMacPoolModel());
customPropertiesSheetEditor.edit(object.getCustomPropertySheet());
enableOvirtServiceEditor.setVisible(object.getAllowClusterWithVirtGlusterEnabled());
enableGlusterServiceEditor.setVisible(object.getAllowClusterWithVirtGlusterEnabled());
enableOvirtServiceOptionEditor.setVisible(!object.getAllowClusterWithVirtGlusterEnabled());
enableGlusterServiceOptionEditor.setVisible(!object.getAllowClusterWithVirtGlusterEnabled());
serialNumberPolicyEditor.edit(object.getSerialNumberPolicy());
optimizationForServerFormatter(object);
optimizationForDesktopFormatter(object);
optimizationCustomFormatter(object);
object.getOptimizationForServer().getEntityChangedEvent().addListener((ev, sender, args) -> optimizationForServerFormatter(object));
object.getOptimizationForDesktop().getEntityChangedEvent().addListener((ev, sender, args) -> optimizationForDesktopFormatter(object));
object.getOptimizationCustom_IsSelected().getEntityChangedEvent().addListener((ev, sender, args) -> {
if (object.getOptimizationCustom_IsSelected().getEntity()) {
optimizationCustomFormatter(object);
optimizationCustomEditor.setVisible(true);
}
});
object.getDataCenter().getSelectedItemChangedEvent().addListener((ev, sender, args) -> {
migrationTab.setVisible(object.isMigrationTabAvailable());
applyModeCustomizations();
});
object.getEnableOvirtService().getEntityChangedEvent().addListener((ev, sender, args) -> updateGlusterFencingPolicyVisibility(object));
object.getEnableGlusterService().getEntityChangedEvent().addListener((ev, sender, args) -> {
importGlusterExplanationLabel.setVisible(object.getEnableGlusterService().getEntity() && object.getIsNew());
updateGlusterFencingPolicyVisibility(object);
});
updateGlusterFencingPolicyVisibility(object);
importGlusterExplanationLabel.setVisible(object.getEnableGlusterService().getEntity() && object.getIsNew());
object.getVersionSupportsCpuThreads().getEntityChangedEvent().addListener((ev, sender, args) -> cpuThreadsRow.setVisible(object.getVersionSupportsCpuThreads().getEntity()));
schedulerOptimizationInfoIcon.setText(SafeHtmlUtils.fromTrustedString(templates.italicText(object.getSchedulerOptimizationInfoMessage()).asString().replaceAll("(\r\n|\n)", // $NON-NLS-1$ //$NON-NLS-2$
"<br />")));
allowOverbookingInfoIcon.setText(SafeHtmlUtils.fromTrustedString(templates.italicText(object.getAllowOverbookingInfoMessage()).asString().replaceAll("(\r\n|\n)", // $NON-NLS-1$ //$NON-NLS-2$
"<br />")));
allowOverbookingRow.setVisible(allowOverbookingEditor.isVisible());
object.getVersion().getPropertyChangedEvent().addListener((ev, sender, args) -> {
if (object.getVersion().getSelectedItem() != null) {
Version clusterVersion = object.getVersion().getSelectedItem();
migrationPolicyDetails.setVisible(AsyncDataProvider.getInstance().isMigrationPoliciesSupported(clusterVersion));
}
});
object.getAdditionalClusterFeatures().getItemsChangedEvent().addListener((ev, sender, args) -> {
List<List<AdditionalFeature>> items = (List<List<AdditionalFeature>>) object.getAdditionalClusterFeatures().getItems();
// Hide the fields if there is no feature to show
additionalFeaturesExpander.setVisible(!items.get(0).isEmpty());
additionalFeaturesExpanderContent.setVisible(!items.get(0).isEmpty());
});
object.getMigrationPolicies().getSelectedItemChangedEvent().addListener((ev, sender, args) -> {
MigrationPolicy selectedPolicy = object.getMigrationPolicies().getSelectedItem();
if (selectedPolicy != null) {
migrationPolicyDetails.setHTML(templates.migrationPolicyDetails(selectedPolicy.getName(), selectedPolicy.getDescription()));
} else {
// $NON-NLS-1$
migrationPolicyDetails.setText("");
}
});
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class ClusterPopupView method initListBoxEditors.
private void initListBoxEditors() {
dataCenterEditor = new ListModelListBoxEditor<>(new NameRenderer<StoragePool>());
managementNetworkEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<Network>() {
@Override
protected String renderNullSafe(Network network) {
return network.getName();
}
});
cpuEditor = new ListModelListBoxEditor<>(new AbstractRenderer<ServerCpu>() {
@Override
public String render(ServerCpu object) {
return object != null ? object.getCpuName() : constants.autoDetect();
}
});
versionEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<Version>() {
@Override
public String renderNullSafe(Version object) {
return object.toString();
}
});
switchTypeEditor = new ListModelListBoxEditor<>(new EnumRenderer<SwitchType>());
firewallTypeEditor = new ListModelListBoxEditor<>(new EnumRenderer<FirewallType>());
defaultNetworkProviderEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<Provider>() {
@Override
protected String renderNullSafe(Provider provider) {
return provider.getName();
}
});
architectureEditor = new ListModelListBoxEditor<>(new EnumRenderer<ArchitectureType>() {
@Override
public String render(ArchitectureType object) {
if (object == null || object == ArchitectureType.undefined) {
// only localize the 'undefined' enum value
return super.render(object);
} else {
// all other (concrete) architectures should be displayed directly
return object.toString();
}
}
});
clusterPolicyEditor = new ListModelListBoxEditor<>(new NameRenderer<ClusterPolicy>());
hostsWithBrokenConnectivityThresholdEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<Integer>() {
@Override
public String renderNullSafe(Integer object) {
if (object == null) {
return "";
}
NumberFormatRenderer renderer = new NumberFormatRenderer(NumberFormat.getPercentFormat());
// Since this is a percentage renderer, you need to divide by 100 to get the right values to show.
return renderer.render(object.doubleValue() / 100);
}
});
autoConvergeEditor = new ListModelListBoxEditor<>(new BooleanRendererWithNullText(constants.autoConverge(), constants.dontAutoConverge(), constants.inheritFromGlobal()));
migrateCompressedEditor = new ListModelListBoxEditor<>(new BooleanRendererWithNullText(constants.compress(), constants.dontCompress(), constants.inheritFromGlobal()));
migrationBandwidthLimitTypeEditor = new ListModelListBoxEditor<>(new EnumRenderer<MigrationBandwidthLimitType>());
migrationBandwidthLimitTypeEditor.hideLabel();
migrationPolicyEditor = new ListModelListBoxEditor<>(new NameRenderer());
migrationPolicyEditor.hideLabel();
macPoolListEditor = new ListModelListBoxEditor<>(new NameRenderer<MacPool>());
macPoolListEditor.setLabel(constants.clusterPopupMacPoolLabel());
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class WebAdminConfigurator method eventRaised.
@Override
public void eventRaised(Event<? extends FileFetchEventArgs> ev, Object sender, FileFetchEventArgs args) {
if (ev.matchesDefinition(spiceVersionFileFetchedEvent_Definition)) {
Version spiceVersion = parseVersion(args.getFileContent());
setSpiceVersion(spiceVersion);
} else if (ev.matchesDefinition(documentationFileFetchedEvent_Definition)) {
String cshMapping = args.getFileContent();
ContextSensitiveHelpManager.init(cshMapping);
}
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class AddVmInterfaceCommand method validate.
@Override
protected boolean validate() {
if (getVm() == null) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_VM_NOT_FOUND);
}
macPool = getMacPool();
if (!canRunActionOnNonManagedVm()) {
return false;
}
if (getVm().isHostedEngine() && !getVm().isManagedHostedEngine()) {
addValidationMessage(EngineMessage.ACTION_TYPE_FAILED_UNMANAGED_HOSTED_ENGINE);
}
if (!updateVnicForBackwardCompatibility()) {
return false;
}
if (!validate(vmStatusLegal(vmDynamicDao.get(getParameters().getVmId()).getStatus()))) {
return false;
}
List<VmNic> interfaces = vmNicDao.getAllForVm(getParameters().getVmId());
if (!uniqueInterfaceName(interfaces)) {
return false;
}
if (!validate(vmTemplateEmpty())) {
return false;
}
// check that not exceeded PCI and IDE limit
List<VmNic> allInterfaces = new ArrayList<>(interfaces);
allInterfaces.add(getInterface());
if (!pciAndIdeWithinLimit(getVm(), allInterfaces)) {
return false;
}
Version compatibilityVersion = getVm().getClusterCompatibilityVersion();
VmNicValidator nicValidator = new VmNicValidator(getInterface(), compatibilityVersion, getVm().getOs());
if (!validate(nicValidator.isCompatibleWithOs()) || !validate(nicValidator.profileValid(getVm().getClusterId())) || !validate(nicValidator.typeMatchesProfile()) || !validate(nicValidator.passthroughIsLinked()) || !validate(nicValidator.validateProfileNotEmptyForHostedEngineVm(getVm()))) {
return false;
}
if (StringUtils.isNotEmpty(getMacAddress())) {
if (!validate(macAvailable())) {
return false;
}
} else if (macPool.getAvailableMacsCount() <= 0) {
addValidationMessage(EngineMessage.MAC_POOL_NOT_ENOUGH_MAC_ADDRESSES);
return false;
}
return true;
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class AddVmTemplateInterfaceCommand method validate.
@Override
protected boolean validate() {
if (!super.validate()) {
return false;
}
List<VmNic> interfaces = vmNicDao.getAllForTemplate(getParameters().getVmTemplateId());
if (!interfaceNameUnique(interfaces) || !validate(templateExists()) || !validate(linkedToTemplate())) {
return false;
}
vmTemplateHandler.updateDisksFromDb(getVmTemplate());
// not relevant for instance types - will be checked when a VM will be created out of it
if (getVmTemplate().getTemplateType() != VmEntityType.INSTANCE_TYPE) {
if (!updateVnicForBackwardCompatibility()) {
return false;
}
List<VmNic> interfacesForCheckPciLimit = new ArrayList<>(interfaces);
interfacesForCheckPciLimit.add(getParameters().getInterface());
if (!validate(VmValidator.checkPciAndIdeLimit(getVmTemplate().getOsId(), getCluster().getCompatibilityVersion(), getVmTemplate().getNumOfMonitors(), interfacesForCheckPciLimit, getTemplateDiskVmElements(), getVmDeviceUtils().hasVirtioScsiController(getVmTemplate().getId()), getVmDeviceUtils().hasWatchdog(getVmTemplate().getId()), getVmDeviceUtils().hasMemoryBalloon(getVmTemplate().getId()), getVmDeviceUtils().hasSoundDevice(getVmTemplate().getId())))) {
return false;
}
Version clusterCompatibilityVersion = getCluster().getCompatibilityVersion();
VmNicValidator nicValidator = new VmNicValidator(getParameters().getInterface(), clusterCompatibilityVersion, getVmTemplate().getOsId());
return validate(nicValidator.isCompatibleWithOs()) && validate(nicValidator.profileValid(getVmTemplate().getClusterId())) && validate(nicValidator.typeMatchesProfile()) && validate(nicValidator.passthroughIsLinked());
}
return true;
}
Aggregations