use of org.ovirt.engine.core.common.businessentities.VmTemplate in project ovirt-engine by oVirt.
the class TemplateImportInterfaceListModel method onEntityChanged.
@Override
protected void onEntityChanged() {
super.onEntityChanged();
if (getEntity() != null) {
VmTemplate template = (VmTemplate) getEntity();
setItems(template.getInterfaces());
} else {
setItems(null);
}
}
use of org.ovirt.engine.core.common.businessentities.VmTemplate in project ovirt-engine by oVirt.
the class TemplateListModel method createVMFromTemplate.
private void createVMFromTemplate() {
VmTemplate template = getSelectedItem();
final List<UICommand> commands = new ArrayList<>();
// $NON-NLS-1$
commands.add(UICommand.createDefaultOkUiCommand("OnSaveVm", this));
// $NON-NLS-1$
commands.add(UICommand.createCancelUiCommand("Cancel", this));
AsyncDataProvider.getInstance().getTemplateById(new AsyncQuery<>(withVmInit -> setupNewVmModel(new UnitVmModel(new NewVmFromTemplateModelBehavior(withVmInit), TemplateListModel.this), withVmInit.getVmType(), commands)), template.getId());
}
use of org.ovirt.engine.core.common.businessentities.VmTemplate in project ovirt-engine by oVirt.
the class TemplateListModel method edit.
private void edit() {
VmTemplate template = getSelectedItem();
if (getWindow() != null) {
return;
}
// populating VMInit
AsyncDataProvider.getInstance().getTemplateById(new AsyncQuery<>(result -> vmInitLoaded(result)), template.getId());
}
use of org.ovirt.engine.core.common.businessentities.VmTemplate in project ovirt-engine by oVirt.
the class ImportTemplateModel method createSearchPattern.
private String createSearchPattern(Collection<VmTemplate> templates) {
// $NON-NLS-1$
String vmt_guidKey = "_VMT_ID =";
// $NON-NLS-1$
String orKey = " or ";
StringBuilder searchPattern = new StringBuilder();
// $NON-NLS-1$
searchPattern.append("Template: ");
for (VmTemplate template : templates) {
searchPattern.append(vmt_guidKey);
searchPattern.append(template.getId().toString());
searchPattern.append(orKey);
searchPattern.append(vmt_guidKey);
searchPattern.append(template.getBaseTemplateId().toString());
searchPattern.append(orKey);
}
return searchPattern.substring(0, searchPattern.length() - orKey.length());
}
use of org.ovirt.engine.core.common.businessentities.VmTemplate in project ovirt-engine by oVirt.
the class ImportTemplateModel method init.
public void init(final Collection<VmTemplate> externalTemplates, final Guid storageDomainId) {
Frontend.getInstance().runQuery(QueryType.Search, new SearchParameters(createSearchPattern(externalTemplates), SearchType.VmTemplate), new AsyncQuery<>(new AsyncCallback<QueryReturnValue>() {
@Override
public void onSuccess(QueryReturnValue returnValue) {
UIConstants constants = ConstantsManager.getInstance().getConstants();
List<VmTemplate> vmtList = returnValue.getReturnValue();
List<ImportTemplateData> templateDataList = new ArrayList<>();
for (VmTemplate template : externalTemplates) {
ImportTemplateData templateData = new ImportTemplateData(template);
boolean templateExistsInSystem = vmtList.contains(template);
templateData.setExistsInSystem(templateExistsInSystem);
if (templateExistsInSystem) {
templateData.enforceClone(constants.importTemplateThatExistsInSystemMustClone());
} else if (!template.isBaseTemplate() && findAnyVmTemplateById(vmtList, template.getBaseTemplateId()) == null) {
templateData.enforceClone(constants.importTemplateWithoutBaseMustClone());
}
templateDataList.add(templateData);
}
setItems(templateDataList);
withDataCenterLoaded(storageDomainId, r -> doInit());
}
private VmTemplate findAnyVmTemplateById(List<VmTemplate> vmtList, Guid templateId) {
for (VmTemplate vmt : vmtList) {
if (templateId.equals(vmt.getId())) {
return vmt;
}
}
return null;
}
}));
}
Aggregations