use of org.ovirt.engine.core.common.businessentities.VmPool in project ovirt-engine by oVirt.
the class VmPoolDaoTest method testGetFilteredWithPermissions.
@Test
public void testGetFilteredWithPermissions() {
VmPool result = dao.get(existingVmPool.getVmPoolId(), PRIVILEGED_USER_ID, true);
assertGetResult(result);
}
use of org.ovirt.engine.core.common.businessentities.VmPool in project ovirt-engine by oVirt.
the class PoolGeneralModel method updateProperties.
private void updateProperties() {
final VmPool pool = getEntity();
setName(pool.getName());
setDescription(pool.getVmPoolDescription());
Frontend.getInstance().runQuery(QueryType.GetVmDataByPoolId, new IdQueryParameters(pool.getVmPoolId()), new AsyncQuery<>(new AsyncCallback<QueryReturnValue>() {
@Override
public void onSuccess(QueryReturnValue result) {
// refactor to "switch ... case...".
if (result != null) {
setvm((VM) result.getReturnValue());
}
if (getvm() != null) {
setTemplate(vmTemplateNameRenderer.render(getvm()));
setCpuInfo(ConstantsManager.getInstance().getMessages().cpuInfoLabel(getvm().getNumOfCpus(), getvm().getNumOfSockets(), getvm().getCpuPerSocket(), getvm().getThreadsPerCpu()));
setMonitorCount(getvm().getNumOfMonitors());
setOS(getvm().getVmOsId());
// $NON-NLS-1$
setDefinedMemory(getvm().getVmMemSizeMb() + " MB");
// $NON-NLS-1$
setMinAllocatedMemory(getvm().getMinAllocatedMem() + " MB");
Translator translator = EnumTranslator.getInstance();
setDefaultDisplayType(translator.translate(getvm().getDefaultDisplayType()));
setOrigin(translator.translate(getvm().getOrigin()));
setUsbPolicy(translator.translate(getvm().getUsbPolicy()));
setHasDomain(AsyncDataProvider.getInstance().isWindowsOsType(getvm().getVmOsId()));
setOptimizedForSystemProfile(translator.translate(getvm().getVmType()));
setHasTimeZone(AsyncDataProvider.getInstance().isWindowsOsType(getvm().getVmOsId()));
setTimeZone(getvm().getTimeZone());
setIsStateless(!pool.isStateful());
setQuotaName(getvm().getQuotaName());
setHasDefaultHost(getvm().getDedicatedVmForVdsList().size() > 0);
if (getHasDefaultHost()) {
Frontend.getInstance().runQuery(QueryType.Search, new SearchParameters(// $NON-NLS-1$
"Host: cluster = " + getvm().getClusterName() + " sortby name", SearchType.VDS), new AsyncQuery<QueryReturnValue>(returnValue1 -> {
// $NON-NLS-1$
String defaultHost1 = "";
ArrayList<VDS> hosts = returnValue1.getReturnValue();
for (VDS host : hosts) {
if (getvm().getDedicatedVmForVdsList().contains(host.getId())) {
if (defaultHost1.isEmpty()) {
defaultHost1 = host.getName();
} else {
// $NON-NLS-1$
defaultHost1 += ", " + host.getName();
}
}
}
setDefaultHost(defaultHost1);
}));
} else {
setDefaultHost(ConstantsManager.getInstance().getConstants().anyHostInCluster());
}
if (getvm() != null) {
PoolGeneralModel.super.updateProperties(getvm().getId());
}
} else {
setTemplate(null);
setCpuCount(0);
setMonitorCount(0);
setOS(0);
setDefinedMemory(null);
setMinAllocatedMemory(null);
setDefaultDisplayType(null);
setHasDomain(false);
setDomain(null);
setHasTimeZone(false);
setTimeZone(null);
setUsbPolicy(null);
setDefaultHost(null);
setIsStateless(!pool.isStateful());
// $NON-NLS-1$
setGraphicsType("");
// $NON-NLS-1$
setOptimizedForSystemProfile("");
getUpdateCompleteEvent().raise(this, EventArgs.EMPTY);
}
}
}));
}
use of org.ovirt.engine.core.common.businessentities.VmPool in project ovirt-engine by oVirt.
the class PoolListModel method onSave.
public void onSave() {
final PoolModel model = (PoolModel) getWindow();
if (model.getProgress() != null) {
return;
}
if (!model.getIsNew() && getSelectedItem() == null) {
cancel();
return;
}
if (!model.validate()) {
return;
}
setCurrentPool(model.getIsNew() ? new VmPool() : (VmPool) Cloner.clone(getSelectedItem()));
final String name = model.getName().getEntity();
// Check name unicitate.
AsyncDataProvider.getInstance().isPoolNameUnique(new AsyncQuery<>(isUnique -> {
if ((model.getIsNew() && !isUnique) || (!model.getIsNew() && !isUnique && name.compareToIgnoreCase(getCurrentPool().getName()) != 0)) {
model.getName().getInvalidityReasons().add(ConstantsManager.getInstance().getConstants().nameMustBeUniqueInvalidReason());
model.getName().setIsValid(false);
model.setValidTab(TabName.GENERAL_TAB, false);
model.fireValidationCompleteEvent();
return;
}
String selectedCpu = model.getCustomCpu().getSelectedItem();
if (selectedCpu != null && !selectedCpu.isEmpty() && !model.getCustomCpu().getItems().contains(selectedCpu)) {
ConfirmationModel confirmModel = new ConfirmationModel();
confirmModel.setTitle(ConstantsManager.getInstance().getConstants().vmUnsupportedCpuTitle());
confirmModel.setMessage(ConstantsManager.getInstance().getConstants().vmUnsupportedCpuMessage());
confirmModel.setHelpTag(HelpTag.edit_unsupported_cpu);
// $NON-NLS-1$
confirmModel.setHashName("edit_unsupported_cpu");
confirmModel.getCommands().add(// $NON-NLS-1$
new UICommand("OnSave_Phase2", PoolListModel.this).setTitle(ConstantsManager.getInstance().getConstants().ok()).setIsDefault(true));
confirmModel.getCommands().add(// $NON-NLS-1$
UICommand.createCancelUiCommand(// $NON-NLS-1$
"CancelConfirmation", PoolListModel.this));
setConfirmWindow(confirmModel);
} else {
if (model.getVmType().getSelectedItem() == VmType.HighPerformance) {
displayHighPerformanceConfirmationPopup();
} else {
savePoolPostValidation();
}
}
}), name);
}
use of org.ovirt.engine.core.common.businessentities.VmPool in project ovirt-engine by oVirt.
the class PoolListModel method edit.
public void edit() {
final VmPool pool = getSelectedItem();
if (getWindow() != null) {
return;
}
final PoolListModel poolListModel = this;
Frontend.getInstance().runQuery(QueryType.GetVmDataByPoolId, new IdQueryParameters(pool.getVmPoolId()), new AsyncQuery<QueryReturnValue>(result -> {
final VM vm = result.getReturnValue();
final ExistingPoolModelBehavior behavior = new ExistingPoolModelBehavior(vm, pool);
behavior.getPoolModelBehaviorInitializedEvent().addListener((ev, sender, args) -> {
final PoolModel model = behavior.getModel();
for (EntityModel<VmPoolType> item : model.getPoolType().getItems()) {
if (item.getEntity() == pool.getVmPoolType()) {
model.getPoolType().setSelectedItem(item);
break;
}
}
String cdImage = null;
if (vm != null) {
model.getDataCenterWithClustersList().setSelectedItem(null);
model.getDataCenterWithClustersList().setSelectedItem(Linq.firstOrNull(model.getDataCenterWithClustersList().getItems(), new Linq.DataCenterWithClusterPredicate(vm.getStoragePoolId(), vm.getClusterId())));
model.getTemplateWithVersion().setIsChangeable(false);
cdImage = vm.getIsoPath();
model.getVmType().setSelectedItem(vm.getVmType());
} else {
model.getDataCenterWithClustersList().setSelectedItem(Linq.firstOrNull(model.getDataCenterWithClustersList().getItems()));
}
model.getDataCenterWithClustersList().setIsChangeable(vm == null);
boolean hasCd = !StringHelper.isNullOrEmpty(cdImage);
model.getCdImage().setIsChangeable(hasCd);
model.getCdAttached().setEntity(hasCd);
model.getProvisioning().setIsChangeable(false);
model.getStorageDomain().setIsChangeable(false);
});
PoolModel model = new PoolModel(behavior);
model.setCustomPropertiesKeysList(AsyncDataProvider.getInstance().getCustomPropertiesList());
// $NON-NLS-1$
model.setIsAdvancedModeLocalStorageKey("wa_pool_dialog");
setWindow(model);
VmBasedWidgetSwitchModeCommand switchModeCommand = new VmBasedWidgetSwitchModeCommand();
switchModeCommand.init(model);
model.getCommands().add(switchModeCommand);
// $NON-NLS-1$
UICommand command = UICommand.createDefaultOkUiCommand("OnSave", poolListModel);
model.getCommands().add(command);
// $NON-NLS-1$
model.getCommands().add(UICommand.createCancelUiCommand("Cancel", poolListModel));
model.setTitle(ConstantsManager.getInstance().getConstants().editPoolTitle());
model.setHelpTag(HelpTag.edit_pool);
// $NON-NLS-1$
model.setHashName("edit_pool");
model.initialize();
model.getName().setEntity(pool.getName());
model.getDescription().setEntity(pool.getVmPoolDescription());
model.getComment().setEntity(pool.getComment());
model.getPoolStateful().setEntity(pool.isStateful());
model.getAssignedVms().setEntity(pool.getAssignedVmsCount());
model.getPrestartedVms().setEntity(pool.getPrestartedVms());
// $NON-NLS-1$
model.setPrestartedVmsHint("0-" + pool.getAssignedVmsCount());
model.getMaxAssignedVmsPerUser().setEntity(pool.getMaxAssignedVmsPerUser());
}));
}
use of org.ovirt.engine.core.common.businessentities.VmPool in project ovirt-engine by oVirt.
the class PoolListModel method remove.
public void remove() {
if (getWindow() != null) {
return;
}
ConfirmationModel model = new ConfirmationModel();
setWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().removePoolsTitle());
model.setHelpTag(HelpTag.remove_pool);
// $NON-NLS-1$
model.setHashName("remove_pool");
ArrayList<String> list = new ArrayList<>();
for (VmPool item : getSelectedItems()) {
list.add(item.getName());
}
model.setItems(list);
// $NON-NLS-1$
UICommand tempVar = UICommand.createDefaultOkUiCommand("OnRemove", this);
model.getCommands().add(tempVar);
// $NON-NLS-1$
UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
model.getCommands().add(tempVar2);
}
Aggregations