use of org.ovirt.engine.ui.uicommonweb.models.vms.ImportTemplateData in project ovirt-engine by oVirt.
the class TemplateBackupModel method onRestore.
public void onRestore() {
importModel = (ImportTemplateModel) getWindow();
if (importModel.getProgress() != null) {
return;
}
if (!importModel.validate()) {
return;
}
cloneObjectMap = new HashMap<>();
objectsToClone = new ArrayList<>();
for (Object object : importModel.getItems()) {
ImportTemplateData item = (ImportTemplateData) object;
if (item.getClone().getEntity()) {
objectsToClone.add(item);
}
}
executeImportClone();
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.ImportTemplateData 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;
}
}));
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.ImportTemplateData 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.ui.uicommonweb.models.vms.ImportTemplateData in project ovirt-engine by oVirt.
the class RegisterTemplateModel method prepareActionParameters.
private List<ActionParametersBase> prepareActionParameters() {
ArrayList<ActionParametersBase> parameters = new ArrayList<>();
for (ImportTemplateData entityData : getEntities().getItems()) {
VmTemplate vmTemplate = entityData.getEntity();
Cluster cluster = entityData.getCluster().getSelectedItem();
ImportVmTemplateFromConfParameters params = new ImportVmTemplateFromConfParameters();
params.setExternalVnicProfileMappings(cloneExternalVnicProfiles(cluster));
params.setContainerId(vmTemplate.getId());
params.setStorageDomainId(getStorageDomainId());
params.setImagesExistOnTargetStorageDomain(true);
params.setClusterId(cluster != null ? cluster.getId() : null);
if (isQuotaEnabled()) {
Quota quota = entityData.getClusterQuota().getSelectedItem();
params.setQuotaId(quota != null ? quota.getId() : null);
params.setDiskTemplateMap(vmTemplate.getDiskTemplateMap());
updateDiskQuotas(new ArrayList<Disk>(params.getDiskTemplateMap().values()));
}
parameters.add(params);
}
return parameters;
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.ImportTemplateData in project ovirt-engine by oVirt.
the class TemplateBackupModel method onClone.
private void onClone() {
ImportCloneModel cloneModel = (ImportCloneModel) getConfirmWindow();
if (cloneModel.getApplyToAll().getEntity()) {
if (!cloneModel.getNoClone().getEntity()) {
String suffix = cloneModel.getSuffix().getEntity();
if (!validateSuffix(suffix, cloneModel.getSuffix())) {
return;
}
for (ImportTemplateData object : objectsToClone) {
setObjectName(object, suffix, true);
cloneObjectMap.put((Guid) object.getEntity().getQueryableId(), object);
}
}
objectsToClone.clear();
} else {
ImportTemplateData object = (ImportTemplateData) cloneModel.getEntity();
if (!cloneModel.getNoClone().getEntity()) {
String vmName = cloneModel.getName().getEntity();
if (!validateName(vmName, cloneModel.getName(), getClonedNameValidators())) {
return;
}
setObjectName(object, vmName, false);
cloneObjectMap.put((Guid) object.getEntity().getQueryableId(), object);
}
objectsToClone.remove(object);
}
setConfirmWindow(null);
executeImportClone();
}
Aggregations