use of org.ovirt.engine.core.common.businessentities.VM in project ovirt-engine by oVirt.
the class VmListModel method cancelMigration.
private void cancelMigration() {
ArrayList<ActionParametersBase> list = new ArrayList<>();
for (Object item : getSelectedItems()) {
VM a = (VM) item;
list.add(new VmOperationParameterBase(a.getId()));
}
Frontend.getInstance().runMultipleAction(ActionType.CancelMigrateVm, list, result -> {
}, null);
}
use of org.ovirt.engine.core.common.businessentities.VM in project ovirt-engine by oVirt.
the class VmListModel method powerAction.
private void powerAction(String actionName, String title, String message, boolean reasonVisible) {
ConfirmationModel model = new ConfirmationModel();
setWindow(model);
model.setTitle(title);
model.setReasonVisible(reasonVisible);
if (actionName.equals(SHUTDOWN)) {
model.setHelpTag(HelpTag.shutdown_virtual_machine);
// $NON-NLS-1$
model.setHashName("shutdown_virtual_machine");
} else if (actionName.equals(STOP)) {
model.setHelpTag(HelpTag.stop_virtual_machine);
// $NON-NLS-1$
model.setHashName("stop_virtual_machine");
} else if (actionName.equals(REBOOT)) {
model.setHelpTag(HelpTag.reboot_virtual_machine);
// $NON-NLS-1$
model.setHashName("reboot_virtual_machine");
}
model.setMessage(message);
ArrayList<String> items = new ArrayList<>();
boolean stoppingSingleVM = getSelectedItems().size() == 1 && (actionName.equals(SHUTDOWN) || actionName.equals(STOP));
for (Object item : getSelectedItems()) {
VM vm = (VM) item;
items.add(vm.getName());
// is populated with the current reason so the user can edit it.
if (stoppingSingleVM && reasonVisible && VMStatus.PoweringDown.equals(vm.getStatus())) {
model.getReason().setEntity(vm.getStopReason());
}
}
model.setItems(items);
// $NON-NLS-1$
UICommand tempVar = new UICommand("On" + actionName, this);
tempVar.setTitle(ConstantsManager.getInstance().getConstants().ok());
tempVar.setIsDefault(true);
model.getCommands().add(tempVar);
// $NON-NLS-1$
UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
model.getCommands().add(tempVar2);
}
use of org.ovirt.engine.core.common.businessentities.VM in project ovirt-engine by oVirt.
the class VmListModel method updateVM.
@Override
protected void updateVM(final UnitVmModel model) {
final VM selectedItem = getSelectedItem();
// explicitly pass non-editable field from the original VM
getcurrentVm().setCreatedByUserId(selectedItem.getCreatedByUserId());
getcurrentVm().setUseLatestVersion(model.getTemplateWithVersion().getSelectedItem().isLatest());
if (selectedItem.isRunningOrPaused() && !selectedItem.isHostedEngine()) {
AsyncDataProvider.getInstance().getVmChangedFieldsForNextRun(editedVm, getcurrentVm(), getUpdateVmParameters(false), new AsyncQuery<>(new AsyncCallback<QueryReturnValue>() {
@Override
public void onSuccess(QueryReturnValue returnValue) {
List<String> changedFields = returnValue.getReturnValue();
final boolean cpuHotPluggable = VmCommonUtils.isCpusToBeHotpluggedOrUnplugged(selectedItem, getcurrentVm());
final boolean isHeadlessModeChanged = isHeadlessModeChanged(editedVm, getUpdateVmParameters(false));
final boolean memoryHotPluggable = VmCommonUtils.isMemoryToBeHotplugged(selectedItem, getcurrentVm());
final boolean minAllocatedMemoryChanged = selectedItem.getMinAllocatedMem() != getcurrentVm().getMinAllocatedMem();
final boolean vmLeaseUpdated = VmCommonUtils.isVmLeaseToBeHotPluggedOrUnplugged(selectedItem, getcurrentVm());
if (isHeadlessModeChanged) {
changedFields.add(constants.headlessMode());
}
// provide warnings if isVmUnpinned()
if (!changedFields.isEmpty() || isVmUnpinned() || memoryHotPluggable || cpuHotPluggable || vmLeaseUpdated) {
VmNextRunConfigurationModel confirmModel = new VmNextRunConfigurationModel();
if (isVmUnpinned()) {
confirmModel.setVmUnpinned();
}
confirmModel.setTitle(ConstantsManager.getInstance().getConstants().editNextRunConfigurationTitle());
confirmModel.setHelpTag(HelpTag.edit_next_run_configuration);
// $NON-NLS-1$
confirmModel.setHashName("edit_next_run_configuration");
confirmModel.setChangedFields(changedFields);
confirmModel.setCpuPluggable(cpuHotPluggable);
confirmModel.setMemoryPluggable(memoryHotPluggable);
// it can be plugged only together with the memory, never alone
confirmModel.setMinAllocatedMemoryPluggable(memoryHotPluggable && minAllocatedMemoryChanged);
confirmModel.setVmLeaseUpdated(vmLeaseUpdated);
confirmModel.getCommands().add(// $NON-NLS-1$
new UICommand("updateExistingVm", VmListModel.this).setTitle(ConstantsManager.getInstance().getConstants().ok()).setIsDefault(true));
// $NON-NLS-1$
confirmModel.getCommands().add(UICommand.createCancelUiCommand("CancelConfirmation", VmListModel.this));
setConfirmWindow(confirmModel);
} else {
updateExistingVm(false);
}
}
private boolean isVmUnpinned() {
if (selectedItem.isRunning()) {
if (selectedItem.getMigrationSupport() == MigrationSupport.PINNED_TO_HOST && getcurrentVm().getMigrationSupport() != MigrationSupport.PINNED_TO_HOST) {
return true;
}
}
return false;
}
}));
} else {
updateExistingVm(false);
}
}
use of org.ovirt.engine.core.common.businessentities.VM in project ovirt-engine by oVirt.
the class VmListModel method cancelConversion.
private void cancelConversion() {
List<ActionParametersBase> parameters = new ArrayList<>();
for (VM vm : getSelectedItems()) {
parameters.add(new VmOperationParameterBase(vm.getId()));
}
Frontend.getInstance().runMultipleAction(ActionType.CancelConvertVm, parameters);
}
use of org.ovirt.engine.core.common.businessentities.VM in project ovirt-engine by oVirt.
the class VmListModel method initImportModelForVmsToImportNamesOnly.
private void initImportModelForVmsToImportNamesOnly(final ImportVmsModel importVmsModel, final ImportVmModel importVmModel) {
final UIMessages messages = ConstantsManager.getInstance().getMessages();
final UIConstants constants = ConstantsManager.getInstance().getConstants();
final List<String> vmsToImport = new ArrayList<>();
OriginType originType = convertImportSourceToOriginType(importVmsModel.getImportSources().getSelectedItem());
final List<VM> externalVms = importVmsModel.getVmsToImport();
for (VM vm : externalVms) {
vmsToImport.add(vm.getName());
}
importVmsModel.clearProblem();
importVmsModel.startProgress();
importVmModel.setMessage("");
AsyncQuery query = new AsyncQuery(returnValue -> {
if (returnValue instanceof QueryReturnValue) {
importVmsModel.setError(messages.providerFailure());
importVmsModel.stopProgress();
} else {
List<VM> remoteVms = (List<VM>) returnValue;
List<VM> remoteDownVms = new ArrayList<>();
List<VM> nonRetrievedVms = new ArrayList<>();
// find vms with status=down
for (VM vm : remoteVms) {
if (vm.isDown()) {
remoteDownVms.add(vm);
}
}
// i.e. they were retrieved with their names only but not with their full info
if (remoteVms.size() != externalVms.size()) {
for (VM vm : externalVms) {
if (!remoteVms.contains(vm)) {
nonRetrievedVms.add(vm);
}
}
}
importVmsModel.stopProgress();
// prepare error message to be displayed in one of the models
String messageForImportVm = null;
String messageForImportVms = null;
if (remoteVms.size() != remoteDownVms.size()) {
if (!nonRetrievedVms.isEmpty()) {
messageForImportVm = constants.nonRetrievedAndRunningVmsWereFilteredOnImportVm();
messageForImportVms = constants.nonRetrievedAndRunningVmsWereAllFilteredOnImportVm();
} else {
messageForImportVm = constants.runningVmsWereFilteredOnImportVm();
messageForImportVms = constants.runningVmsWereAllFilteredOnImportVm();
}
} else if (!nonRetrievedVms.isEmpty()) {
messageForImportVm = constants.nonRetrievedVmsWereFilteredOnImportVm();
messageForImportVms = constants.nonRetrievedVmsWereAllFilteredOnImportVm();
}
if (remoteDownVms.isEmpty() && messageForImportVms != null) {
importVmsModel.setError(messageForImportVms);
}
if (!importVmsModel.validateArchitectures(remoteDownVms)) {
return;
}
// init and display next dialog - the importVmsModel model
importVmModel.init(remoteDownVms, importVmsModel.getDataCenters().getSelectedItem().getId());
setWindow(null);
setWindow(importVmModel);
if (messageForImportVm != null) {
importVmModel.setMessage(messageForImportVm);
}
}
});
if (!(importVmModel instanceof ImportVmFromExternalSourceModel)) {
importVmsModel.setError(messages.providerImportFailure());
importVmsModel.stopProgress();
return;
}
ImportVmFromExternalSourceModel importVmsFromExternalSource = (ImportVmFromExternalSourceModel) importVmModel;
query.setHandleFailure(true);
AsyncDataProvider.getInstance().getVmsFromExternalServer(query, importVmsModel.getDataCenters().getSelectedItem().getId(), importVmsFromExternalSource.getProxyHostId(), importVmsFromExternalSource.getUrl(), importVmsFromExternalSource.getUsername(), importVmsFromExternalSource.getPassword(), originType, vmsToImport);
}
Aggregations