Search in sources :

Example 1 with MultipleHostsModel

use of org.ovirt.engine.ui.uicommonweb.models.hosts.MultipleHostsModel in project ovirt-engine by oVirt.

the class ClusterGeneralModel method fetchAndImportNewGlusterHosts.

public void fetchAndImportNewGlusterHosts() {
    if (getWindow() != null) {
        return;
    }
    final MultipleHostsModel hostsModel = new MultipleHostsModel();
    setWindow(hostsModel);
    hostsModel.setTitle(ConstantsManager.getInstance().getConstants().addMultipleHostsTitle());
    hostsModel.setHelpTag(HelpTag.add_hosts);
    // $NON-NLS-1$
    hostsModel.setHashName("add_hosts");
    // $NON-NLS-1$
    UICommand command = UICommand.createOkUiCommand("OnSaveHosts", this);
    hostsModel.getCommands().add(command);
    hostsModel.getHosts().setItems(new ArrayList<EntityModel<HostDetailModel>>());
    // $NON-NLS-1$
    hostsModel.getCommands().add(UICommand.createCancelUiCommand("Cancel", this));
    hostsModel.startProgress();
    AsyncDataProvider.getInstance().getGlusterHostsNewlyAdded(new AsyncQuery<>(hostMap -> {
        if (hostMap == null || hostMap.isEmpty()) {
            hostsModel.setMessage(ConstantsManager.getInstance().getConstants().emptyNewGlusterHosts());
        } else {
            ArrayList<EntityModel<HostDetailModel>> list = new ArrayList<>();
            for (Map.Entry<String, String> host : hostMap.entrySet()) {
                HostDetailModel hostModel = new HostDetailModel(host.getKey(), host.getValue());
                hostModel.setName(host.getKey());
                // $NON-NLS-1$
                hostModel.setPassword("");
                EntityModel<HostDetailModel> entityModel = new EntityModel<>(hostModel);
                list.add(entityModel);
            }
            hostsModel.getHosts().setItems(list);
        }
        hostsModel.stopProgress();
    }), getEntity().getId(), true);
}
Also used : QueryType(org.ovirt.engine.core.common.queries.QueryType) Guid(org.ovirt.engine.core.compat.Guid) ServiceType(org.ovirt.engine.core.common.businessentities.gluster.ServiceType) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) HostDetailModel(org.ovirt.engine.ui.uicommonweb.models.hosts.HostDetailModel) HashMap(java.util.HashMap) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) Map(java.util.Map) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) RemoveGlusterServerParameters(org.ovirt.engine.core.common.action.gluster.RemoveGlusterServerParameters) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) GlusterServiceParameters(org.ovirt.engine.core.common.action.gluster.GlusterServiceParameters) MultipleHostsModel(org.ovirt.engine.ui.uicommonweb.models.hosts.MultipleHostsModel) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) DetachGlusterHostsModel(org.ovirt.engine.ui.uicommonweb.models.gluster.DetachGlusterHostsModel) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) Objects(java.util.Objects) GlusterStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus) List(java.util.List) MigrateOnErrorOptions(org.ovirt.engine.core.common.businessentities.MigrateOnErrorOptions) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) VDS(org.ovirt.engine.core.common.businessentities.VDS) GlusterServerService(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters) GlusterServiceStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterServiceStatus) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) MultipleHostsModel(org.ovirt.engine.ui.uicommonweb.models.hosts.MultipleHostsModel) HostDetailModel(org.ovirt.engine.ui.uicommonweb.models.hosts.HostDetailModel) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Example 2 with MultipleHostsModel

use of org.ovirt.engine.ui.uicommonweb.models.hosts.MultipleHostsModel in project ovirt-engine by oVirt.

the class ClusterListModel method postOnSaveInternalWithImport.

public void postOnSaveInternalWithImport(ActionReturnValue returnValue) {
    MultipleHostsModel hostsModel = (MultipleHostsModel) getWindow();
    if (returnValue != null && returnValue.getSucceeded()) {
        hostsModel.getClusterModel().setClusterId((Guid) returnValue.getActionReturnValue());
        addHosts(hostsModel);
    }
}
Also used : MultipleHostsModel(org.ovirt.engine.ui.uicommonweb.models.hosts.MultipleHostsModel)

Example 3 with MultipleHostsModel

use of org.ovirt.engine.ui.uicommonweb.models.hosts.MultipleHostsModel in project ovirt-engine by oVirt.

the class ClusterGeneralModel method onSaveHosts.

public void onSaveHosts() {
    final MultipleHostsModel hostsModel = (MultipleHostsModel) getWindow();
    if (hostsModel == null) {
        return;
    }
    if (!hostsModel.validate()) {
        return;
    }
    hostsModel.startProgress();
    ArrayList<ActionParametersBase> parametersList = new ArrayList<>();
    for (Object object : hostsModel.getHosts().getItems()) {
        HostDetailModel hostDetailModel = (HostDetailModel) ((EntityModel) object).getEntity();
        VDS host = new VDS();
        host.setVdsName(hostDetailModel.getName());
        host.setHostName(hostDetailModel.getAddress());
        host.setSshKeyFingerprint(hostDetailModel.getFingerprint());
        host.setPort(54321);
        // TODO: get from UI, till than using defaults.
        host.setSshPort(22);
        // $NON-NLS-1$
        host.setSshUsername("root");
        host.setClusterId(getEntity().getId());
        host.setPmEnabled(false);
        AddVdsActionParameters parameters = new AddVdsActionParameters();
        parameters.setVdsId(host.getId());
        parameters.setvds(host);
        parameters.setPassword(hostDetailModel.getPassword());
        parameters.setOverrideFirewall(hostsModel.isConfigureFirewall());
        parametersList.add(parameters);
    }
    // Todo: calling the runMultipleAction() with isRunOnlyIfAllValidationPass=false
    // becuase this flag is now supported.
    // should check what is the required behaviour and return to true if required.
    Frontend.getInstance().runMultipleAction(ActionType.AddVds, parametersList, false, result -> {
        hostsModel.stopProgress();
        boolean isAllValidatePassed = true;
        for (ActionReturnValue returnValueBase : result.getReturnValue()) {
            isAllValidatePassed = isAllValidatePassed && returnValueBase.isValid();
            if (!isAllValidatePassed) {
                break;
            }
        }
        if (isAllValidatePassed) {
            updateAlerts();
            cancel();
        }
    }, null);
}
Also used : MultipleHostsModel(org.ovirt.engine.ui.uicommonweb.models.hosts.MultipleHostsModel) HostDetailModel(org.ovirt.engine.ui.uicommonweb.models.hosts.HostDetailModel) VDS(org.ovirt.engine.core.common.businessentities.VDS) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ArrayList(java.util.ArrayList) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 4 with MultipleHostsModel

use of org.ovirt.engine.ui.uicommonweb.models.hosts.MultipleHostsModel in project ovirt-engine by oVirt.

the class ClusterListModel method importClusterHosts.

private void importClusterHosts(ClusterModel clusterModel, ArrayList<EntityModel<HostDetailModel>> hostList) {
    setWindow(null);
    getAddMultipleHostsCommand().execute();
    final MultipleHostsModel hostsModel = new MultipleHostsModel();
    setWindow(hostsModel);
    hostsModel.setTitle(ConstantsManager.getInstance().getConstants().addMultipleHostsTitle());
    hostsModel.setHelpTag(HelpTag.add_hosts);
    // $NON-NLS-1$
    hostsModel.setHashName("add_hosts");
    hostsModel.setClusterModel(clusterModel);
    hostsModel.getHosts().setItems(hostList);
    // $NON-NLS-1$
    UICommand command = UICommand.createOkUiCommand("OnSaveHosts", this);
    hostsModel.getCommands().add(command);
    // $NON-NLS-1$
    hostsModel.getCommands().add(UICommand.createCancelUiCommand("Cancel", this));
}
Also used : MultipleHostsModel(org.ovirt.engine.ui.uicommonweb.models.hosts.MultipleHostsModel) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Aggregations

MultipleHostsModel (org.ovirt.engine.ui.uicommonweb.models.hosts.MultipleHostsModel)4 ArrayList (java.util.ArrayList)2 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)2 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)2 AddVdsActionParameters (org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters)2 VDS (org.ovirt.engine.core.common.businessentities.VDS)2 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)2 HostDetailModel (org.ovirt.engine.ui.uicommonweb.models.hosts.HostDetailModel)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 GlusterServiceParameters (org.ovirt.engine.core.common.action.gluster.GlusterServiceParameters)1 RemoveGlusterServerParameters (org.ovirt.engine.core.common.action.gluster.RemoveGlusterServerParameters)1 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)1 MigrateOnErrorOptions (org.ovirt.engine.core.common.businessentities.MigrateOnErrorOptions)1 GlusterServerService (org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService)1 GlusterServiceStatus (org.ovirt.engine.core.common.businessentities.gluster.GlusterServiceStatus)1 GlusterStatus (org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus)1