use of org.ovirt.engine.core.common.businessentities.VmTemplate in project ovirt-engine by oVirt.
the class TemplateGeneralModel method updateProperties.
private void updateProperties() {
VmTemplate template = getEntity();
super.updateProperties(template.getId());
setName(template.getName());
setTemplateId(template.getId().toString());
setDescription(template.getDescription());
// $NON-NLS-1$
setQuotaName(template.getQuotaName() != null ? template.getQuotaName() : "");
setQuotaAvailable(template.getQuotaEnforcementType() != null && !template.getQuotaEnforcementType().equals(QuotaEnforcementTypeEnum.DISABLED));
setHostCluster(template.getClusterName());
// $NON-NLS-1$
setDefinedMemory(template.getMemSizeMb() + " MB");
setIsHighlyAvailable(template.isAutoStartup());
setPriority(AsyncDataProvider.getInstance().priorityToString(template.getPriority()));
setMonitorCount(template.getNumOfMonitors());
setAllowConsoleReconnect(template.isAllowConsoleReconnect());
setCpuInfo(ConstantsManager.getInstance().getMessages().cpuInfoLabel(template.getNumOfCpus(), template.getNumOfSockets(), template.getCpuPerSocket(), template.getThreadsPerCpu()));
setOS(AsyncDataProvider.getInstance().getOsName(template.getOsId()));
Translator translator = EnumTranslator.getInstance();
setOptimizedForSystemProfile(translator.translate(template.getVmType()));
setDefaultDisplayType(translator.translate(template.getDefaultDisplayType()));
setOrigin(translator.translate(template.getOrigin()));
setHasDomain(AsyncDataProvider.getInstance().isWindowsOsType(template.getOsId()));
if (template.getVmInit() != null) {
setDomain(template.getVmInit().getDomain());
}
setHasTimeZone(AsyncDataProvider.getInstance().isWindowsOsType(template.getOsId()));
setTimeZone(template.getTimeZone());
setHasUsbPolicy(true);
setUsbPolicy(translator.translate(template.getUsbPolicy()));
setIsStateless(template.isStateless());
}
use of org.ovirt.engine.core.common.businessentities.VmTemplate in project ovirt-engine by oVirt.
the class StorageTemplateListModel method syncSearch.
@Override
protected void syncSearch() {
if (getEntity() == null) {
return;
}
super.syncSearch();
GetVmTemplatesFromStorageDomainParameters tempVar = new GetVmTemplatesFromStorageDomainParameters(getEntity().getId(), true);
tempVar.setRefresh(getIsQueryFirstTime());
Frontend.getInstance().runQuery(QueryType.GetVmTemplatesFromStorageDomain, tempVar, new AsyncQuery<QueryReturnValue>(returnValue -> {
ArrayList<VmTemplate> templates = returnValue.getReturnValue();
Collections.sort(templates, new LexoNumericNameableComparator<>());
setItems(templates);
setIsEmpty(templates.size() == 0);
}));
}
use of org.ovirt.engine.core.common.businessentities.VmTemplate in project ovirt-engine by oVirt.
the class ImportTemplatePopupView method initMainTable.
@Override
protected void initMainTable() {
this.table = new ListModelObjectCellTable<>();
AbstractCheckboxColumn<Object> cloneTemplateColumn = new AbstractCheckboxColumn<Object>((index, model, value) -> {
((ImportTemplateData) model).getClone().setEntity(value);
table.asEditor().edit(importModel);
}) {
@Override
public Boolean getValue(Object model) {
return ((ImportTemplateData) model).getClone().getEntity();
}
@Override
protected boolean canEdit(Object model) {
return ((ImportTemplateData) model).getClone().getIsChangable();
}
};
// $NON-NLS-1$
table.addColumn(cloneTemplateColumn, constants.cloneVM(), "50px");
AbstractTextColumn<Object> nameColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
return ((ImportTemplateData) object).getTemplate().getName();
}
};
// $NON-NLS-1$
table.addColumn(nameColumn, constants.nameTemplate(), "150px");
AbstractTextColumn<Object> versionNameColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
VmTemplate template = ((ImportTemplateData) object).getTemplate();
if (template.isBaseTemplate()) {
// $NON-NLS-1$
return "";
}
return // $NON-NLS-1$
StringFormat.format(// $NON-NLS-1$
"%s (%s)", // $NON-NLS-1$
template.getTemplateVersionName() != null ? template.getTemplateVersionName() : "", template.getTemplateVersionNumber());
}
};
// $NON-NLS-1$
table.addColumn(versionNameColumn, constants.versionTemplate(), "150px");
AbstractTextColumn<Object> originColumn = new AbstractEnumColumn<Object, OriginType>() {
@Override
protected OriginType getRawValue(Object object) {
return ((ImportTemplateData) object).getTemplate().getOrigin();
}
};
// $NON-NLS-1$
table.addColumn(originColumn, constants.originTemplate(), "100px");
AbstractTextColumn<Object> memoryColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
return messages.megabytes(String.valueOf(((ImportTemplateData) object).getTemplate().getMemSizeMb()));
}
};
// $NON-NLS-1$
table.addColumn(memoryColumn, constants.memoryTemplate(), "100px");
AbstractTextColumn<Object> cpuColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
return String.valueOf(((ImportTemplateData) object).getTemplate().getNumOfCpus());
}
};
// $NON-NLS-1$
table.addColumn(cpuColumn, constants.cpusTemplate(), "50px");
AbstractTextColumn<Object> archColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
return String.valueOf(((ImportTemplateData) object).getTemplate().getClusterArch());
}
};
// $NON-NLS-1$
table.addColumn(archColumn, constants.architectureTemplate(), "50px");
AbstractTextColumn<Object> diskColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
return String.valueOf(((ImportTemplateData) object).getTemplate().getDiskList().size());
}
};
// $NON-NLS-1$
table.addColumn(diskColumn, constants.disksTemplate(), "50px");
isObjectInSystemColumn = new AbstractImageResourceColumn<Object>() {
@Override
public ImageResource getValue(Object object) {
return ((ImportTemplateData) object).isExistsInSystem() ? resources.logNormalImage() : null;
}
};
// $NON-NLS-1$
table.addColumn(isObjectInSystemColumn, constants.templateInSetup(), "60px");
ScrollPanel sp = new ScrollPanel();
sp.add(table);
splitLayoutPanel.add(sp);
table.getElement().getStyle().setPosition(Position.RELATIVE);
}
use of org.ovirt.engine.core.common.businessentities.VmTemplate in project ovirt-engine by oVirt.
the class NewPoolModelBehavior method templateWithVersion_SelectedItemChanged.
@Override
public void templateWithVersion_SelectedItemChanged() {
super.templateWithVersion_SelectedItemChanged();
VmTemplate template = getModel().getTemplateWithVersion().getSelectedItem() != null ? getModel().getTemplateWithVersion().getSelectedItem().getTemplateVersion() : null;
if (template == null) {
return;
}
setupWindowModelFrom(template);
doChangeDefaultHost(template.getDedicatedVmForVdsList());
updateRngDevice(template.getId());
getModel().getCustomPropertySheet().deserialize(template.getCustomProperties());
if (getModel().getVmType().getSelectedItem() == VmType.HighPerformance && !clusterHasPpcArchitecture()) {
getModel().getHostCpu().setEntity(true);
}
}
use of org.ovirt.engine.core.common.businessentities.VmTemplate in project ovirt-engine by oVirt.
the class NewPoolModelBehavior method postDataCenterWithClusterSelectedItemChanged.
@Override
public void postDataCenterWithClusterSelectedItemChanged() {
super.postDataCenterWithClusterSelectedItemChanged();
final DataCenterWithCluster dataCenterWithCluster = getModel().getDataCenterWithClustersList().getSelectedItem();
StoragePool dataCenter = getModel().getSelectedDataCenter();
if (dataCenter == null) {
return;
}
AsyncDataProvider.getInstance().getTemplateListByDataCenter(asyncQuery(templatesByDataCenter -> {
List<VmTemplate> properArchitectureTemplates = AsyncDataProvider.getInstance().filterTemplatesByArchitecture(templatesByDataCenter, dataCenterWithCluster.getCluster().getArchitecture());
List<VmTemplate> templatesWithoutBlank = new ArrayList<>();
for (VmTemplate template : properArchitectureTemplates) {
final boolean isBlankOrVersionOfBlank = template.getId().equals(Guid.Empty) || template.getBaseTemplateId().equals(Guid.Empty);
if (!isBlankOrVersionOfBlank) {
templatesWithoutBlank.add(template);
}
}
// CustomCompatibilityVersion won't be reset by a selected template.
if (templatesWithoutBlank.isEmpty()) {
setCustomCompatibilityVersionChangeInProgress(false);
}
initTemplateWithVersion(templatesWithoutBlank, null, false);
}), dataCenter.getId());
instanceTypeManager.updateAll();
}
Aggregations