Search in sources :

Example 1 with HostDetailModel

use of org.ovirt.engine.ui.uicommonweb.models.hosts.HostDetailModel 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 HostDetailModel

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

the class ClusterListModel method addHosts.

private void addHosts(final MultipleHostsModel hostsModel) {
    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 then using defaults.
        host.setSshPort(22);
        // $NON-NLS-1$
        host.setSshUsername("root");
        host.setClusterId(hostsModel.getClusterModel().getClusterId());
        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 = returnValueBase.isValid();
            if (!isAllValidatePassed) {
                break;
            }
        }
        if (isAllValidatePassed) {
            cancel();
        }
    }, null);
}
Also used : 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 3 with HostDetailModel

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

the class ClusterListModel method fetchAndImportClusterHosts.

private void fetchAndImportClusterHosts(final ClusterModel clusterModel) {
    getWindow().startProgress();
    AsyncQuery<QueryReturnValue> aQuery = new AsyncQuery<>(result -> {
        getWindow().stopProgress();
        QueryReturnValue returnValue = result;
        if (returnValue == null) {
            onEmptyGlusterHosts(clusterModel);
            return;
        } else if (!returnValue.getSucceeded()) {
            clusterModel.setMessage(Frontend.getInstance().getAppErrorsTranslator().translateErrorTextSingle(returnValue.getExceptionString()));
            return;
        }
        Map<String, String> hostMap = returnValue.getReturnValue();
        if (hostMap == null) {
            onEmptyGlusterHosts(clusterModel);
            return;
        }
        if (hostMap.containsValue(null) || hostMap.containsValue("")) {
            // $NON-NLS-1$
            onGlusterHostsWithoutFingerprint(hostMap, clusterModel);
            return;
        }
        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);
        }
        importClusterHosts(clusterModel, list);
    });
    aQuery.setHandleFailure(true);
    AsyncDataProvider.getInstance().getGlusterHosts(aQuery, clusterModel.getGlusterHostAddress().getEntity(), clusterModel.getGlusterHostPassword().getEntity(), clusterModel.getGlusterHostFingerprint().getEntity());
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) HostDetailModel(org.ovirt.engine.ui.uicommonweb.models.hosts.HostDetailModel) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList) Map(java.util.Map)

Example 4 with HostDetailModel

use of org.ovirt.engine.ui.uicommonweb.models.hosts.HostDetailModel 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 5 with HostDetailModel

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

the class MultipleHostsPopupView method initTableColumns.

private void initTableColumns() {
    Column<EntityModel, String> nameColumn = new Column<EntityModel, String>(new TextInputCell()) {

        @Override
        public String getValue(EntityModel object) {
            return ((HostDetailModel) object.getEntity()).getName();
        }
    };
    // $NON-NLS-1$
    hostsTable.addColumn(nameColumn, constants.nameHost(), "50px");
    nameColumn.setFieldUpdater((index, object, value) -> ((HostDetailModel) object.getEntity()).setName(value));
    hostsTable.addColumn(new AbstractEntityModelTextColumn<HostDetailModel>() {

        @Override
        public String getText(HostDetailModel hostModel) {
            return hostModel.getAddress();
        }
    }, constants.ipHost(), // $NON-NLS-1$
    "100px");
    Column<EntityModel, String> passwordColumn = new Column<EntityModel, String>(new PasswordTextInputCell()) {

        @Override
        public String getValue(EntityModel object) {
            return ((HostDetailModel) object.getEntity()).getPassword();
        }
    };
    // $NON-NLS-1$
    hostsTable.addColumn(passwordColumn, constants.hostPopupPasswordLabel(), "100px");
    passwordColumn.setFieldUpdater((index, object, value) -> ((HostDetailModel) object.getEntity()).setPassword(value));
    hostsTable.addColumn(new AbstractEntityModelTextColumn<HostDetailModel>() {

        @Override
        public String getText(HostDetailModel hostModel) {
            return hostModel.getFingerprint();
        }
    }, constants.hostsPopupFingerprint(), // $NON-NLS-1$
    "300px");
}
Also used : PasswordTextInputCell(org.ovirt.engine.ui.common.widget.table.cell.PasswordTextInputCell) HostDetailModel(org.ovirt.engine.ui.uicommonweb.models.hosts.HostDetailModel) AbstractEntityModelTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEntityModelTextColumn) Column(com.google.gwt.user.cellview.client.Column) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) TextInputCell(com.google.gwt.cell.client.TextInputCell) PasswordTextInputCell(org.ovirt.engine.ui.common.widget.table.cell.PasswordTextInputCell)

Aggregations

HostDetailModel (org.ovirt.engine.ui.uicommonweb.models.hosts.HostDetailModel)5 ArrayList (java.util.ArrayList)4 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)3 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)3 AddVdsActionParameters (org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters)3 VDS (org.ovirt.engine.core.common.businessentities.VDS)3 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)3 Map (java.util.Map)2 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)2 MultipleHostsModel (org.ovirt.engine.ui.uicommonweb.models.hosts.MultipleHostsModel)2 TextInputCell (com.google.gwt.cell.client.TextInputCell)1 Column (com.google.gwt.user.cellview.client.Column)1 HashMap (java.util.HashMap)1 List (java.util.List)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