Search in sources :

Example 1 with UIMessages

use of org.ovirt.engine.ui.uicompat.UIMessages 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);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) OriginType(org.ovirt.engine.core.common.businessentities.OriginType) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants)

Example 2 with UIMessages

use of org.ovirt.engine.ui.uicompat.UIMessages in project ovirt-engine by oVirt.

the class SanStorageModelBase method updateGrayedOut.

private void updateGrayedOut(boolean isInMaintenance, Set<String> metadataDevices, LunModel lunModel) {
    UIConstants constants = ConstantsManager.getInstance().getConstants();
    UIMessages messages = ConstantsManager.getInstance().getMessages();
    LUNs lun = lunModel.getEntity();
    boolean nonEmpty = lun.getStorageDomainId() != null || lun.getDiskId() != null || lun.getStatus() == LunStatus.Unusable;
    // Graying out LUNs
    lunModel.setIsGrayedOut(isIgnoreGrayedOut() ? lun.getDiskId() != null : nonEmpty);
    // Adding 'GrayedOutReasons'
    if (lun.getDiskId() != null) {
        lunModel.getGrayedOutReasons().add(messages.lunUsedByDiskWarning(lun.getDiskAlias()));
    } else if (lun.getStorageDomainId() != null && !isInMaintenance) {
        lunModel.getGrayedOutReasons().add(messages.lunAlreadyPartOfStorageDomainWarning(lun.getStorageDomainName()));
    } else if (isInMaintenance && metadataDevices.contains(lun.getId())) {
        lunModel.getGrayedOutReasons().add(messages.lunIsMetadataDevice(lun.getStorageDomainName()));
    } else if (lun.getStatus() == LunStatus.Unusable) {
        lunModel.getGrayedOutReasons().add(constants.lunUnusable());
    }
}
Also used : UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 3 with UIMessages

use of org.ovirt.engine.ui.uicompat.UIMessages in project ovirt-engine by oVirt.

the class HostListModel method restart.

public void restart(String uiCommand) {
    final UIConstants constants = ConstantsManager.getInstance().getConstants();
    final UIMessages messages = ConstantsManager.getInstance().getMessages();
    ConfirmationModel model = new ConfirmationModel();
    setConfirmWindow(model);
    model.setTitle(constants.restartHostsTitle());
    model.setHelpTag(HelpTag.restart_host);
    // $NON-NLS-1$
    model.setHashName("restart_host");
    model.setMessage(constants.areYouSureYouWantToRestartTheFollowingHostsMsg());
    ArrayList<String> items = new ArrayList<>();
    for (Object item : getSelectedItems()) {
        VDS vds = (VDS) item;
        int runningVms = vds.getVmCount();
        if (runningVms > 0) {
            items.add(messages.hostNumberOfRunningVms(vds.getName(), runningVms));
        } else {
            items.add(vds.getName());
        }
    }
    model.setItems(items);
    // $NON-NLS-1$
    UICommand tempVar = new UICommand(uiCommand, this);
    tempVar.setTitle(constants.ok());
    tempVar.setIsDefault(true);
    model.getCommands().add(tempVar);
    // $NON-NLS-1$
    UICommand tempVar2 = new UICommand("Cancel", this);
    tempVar2.setTitle(constants.cancel());
    tempVar2.setIsCancel(true);
    model.getCommands().add(tempVar2);
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) ArrayList(java.util.ArrayList) JsSingleValueStringObject(org.ovirt.engine.ui.frontend.utils.JsSingleValueStringObject) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) HostMaintenanceConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.HostMaintenanceConfirmationModel) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants)

Example 4 with UIMessages

use of org.ovirt.engine.ui.uicompat.UIMessages in project ovirt-engine by oVirt.

the class HostSetupNetworksModel method setLabelErrorsOnNicModels.

private void setLabelErrorsOnNicModels(Map<String, NetworkInterfaceModel> nicModels, List<LogicalNetworkModel> networkModelsWithLabelError, Map<String, String> labelToDesiredNicName) {
    for (LogicalNetworkModel networkModel : networkModelsWithLabelError) {
        NetworkInterfaceModel desiredNicModel = nicModels.get(labelToDesiredNicName.get(networkModel.getNetwork().getLabel()));
        NetworkOperation operation = NetworkOperationFactory.operationFor(networkModel, desiredNicModel);
        UIMessages messages = ConstantsManager.getInstance().getMessages();
        // Should be attached but can't due to conflict
        if (desiredNicModel != null) {
            if (operation.isNullOperation()) {
                networkModel.setErrorMessage(messages.networkLabelConflict(desiredNicModel.getName(), networkModel.getNetwork().getLabel()) + " " + // $NON-NLS-1$
                operation.getMessage(networkModel, desiredNicModel));
            } else {
                networkModel.setErrorMessage(messages.labeledNetworkNotAttached(desiredNicModel.getName(), networkModel.getNetwork().getLabel()));
            }
        }
    }
}
Also used : NetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkInterfaceModel) BondNetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) LogicalNetworkModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel) NetworkOperation(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkOperation)

Example 5 with UIMessages

use of org.ovirt.engine.ui.uicompat.UIMessages in project ovirt-engine by oVirt.

the class VmModelHelper method sendWarningForNonExportableDisks.

public static void sendWarningForNonExportableDisks(Model model, List<Disk> vmDisks, WarningType warningType) {
    final List<Disk> sharedImageDisks = new ArrayList<>();
    final List<Disk> directLunDisks = new ArrayList<>();
    final List<Disk> snapshotDisks = new ArrayList<>();
    for (Disk disk : vmDisks) {
        if (disk.getDiskStorageType() == DiskStorageType.IMAGE) {
            if (disk.isShareable()) {
                sharedImageDisks.add(disk);
            } else if (disk.isDiskSnapshot()) {
                snapshotDisks.add(disk);
            }
        } else if (disk.getDiskStorageType() == DiskStorageType.LUN) {
            directLunDisks.add(disk);
        }
    }
    final UIMessages messages = ConstantsManager.getInstance().getMessages();
    // check if VM provides any disk for the export
    if (vmDisks.size() - (sharedImageDisks.size() + directLunDisks.size() + snapshotDisks.size()) == 0) {
        switch(warningType) {
            case VM_EXPORT:
                model.setMessage(messages.noExportableDisksFoundForTheExport());
                break;
            case VM_SNAPSHOT:
                model.setMessage(messages.noExportableDisksFoundForTheSnapshot());
                break;
            case VM_TEMPLATE:
                model.setMessage(messages.noExportableDisksFoundForTheTemplate());
                break;
        }
    }
    String diskLabels = getDiskLabelList(sharedImageDisks);
    if (diskLabels != null) {
        switch(warningType) {
            case VM_EXPORT:
                model.setMessage(messages.sharedDisksWillNotBePartOfTheExport(diskLabels));
                break;
            case VM_SNAPSHOT:
                model.setMessage(messages.sharedDisksWillNotBePartOfTheSnapshot(diskLabels));
                break;
            case VM_TEMPLATE:
                model.setMessage(messages.sharedDisksWillNotBePartOfTheTemplate(diskLabels));
                break;
        }
    }
    diskLabels = getDiskLabelList(directLunDisks);
    if (diskLabels != null) {
        switch(warningType) {
            case VM_EXPORT:
                model.setMessage(messages.directLUNDisksWillNotBePartOfTheExport(diskLabels));
                break;
            case VM_SNAPSHOT:
                model.setMessage(messages.directLUNDisksWillNotBePartOfTheSnapshot(diskLabels));
                break;
            case VM_TEMPLATE:
                model.setMessage(messages.directLUNDisksWillNotBePartOfTheTemplate(diskLabels));
                break;
        }
    }
    diskLabels = getDiskLabelList(snapshotDisks);
    if (diskLabels != null) {
        switch(warningType) {
            case VM_EXPORT:
                model.setMessage(messages.snapshotDisksWillNotBePartOfTheExport(diskLabels));
                break;
            case VM_SNAPSHOT:
                model.setMessage(messages.snapshotDisksWillNotBePartOfTheSnapshot(diskLabels));
                break;
            case VM_TEMPLATE:
                model.setMessage(messages.snapshotDisksWillNotBePartOfTheTemplate(diskLabels));
                break;
        }
    }
}
Also used : UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) ArrayList(java.util.ArrayList) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk)

Aggregations

UIMessages (org.ovirt.engine.ui.uicompat.UIMessages)8 ArrayList (java.util.ArrayList)5 LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)3 UIConstants (org.ovirt.engine.ui.uicompat.UIConstants)3 List (java.util.List)1 Before (org.junit.Before)1 OriginType (org.ovirt.engine.core.common.businessentities.OriginType)1 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 VM (org.ovirt.engine.core.common.businessentities.VM)1 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)1 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)1 JsSingleValueStringObject (org.ovirt.engine.ui.frontend.utils.JsSingleValueStringObject)1 TypeResolver (org.ovirt.engine.ui.uicommonweb.TypeResolver)1 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)1 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)1 HostMaintenanceConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.HostMaintenanceConfirmationModel)1 BondNetworkInterfaceModel (org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel)1 LogicalNetworkModel (org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel)1 NetworkInterfaceModel (org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkInterfaceModel)1 NetworkOperation (org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkOperation)1