Search in sources :

Example 1 with ApproveVdsParameters

use of org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters in project ovirt-engine by oVirt.

the class HostListModel method onApproveInternal.

private void onApproveInternal() {
    HostModel model = (HostModel) getWindow();
    VDS vds = getSelectedItem();
    ApproveVdsParameters params = new ApproveVdsParameters(vds.getId());
    if (model.getUserPassword().getEntity() != null) {
        params.setPassword(model.getUserPassword().getEntity().toString());
    }
    params.setAuthMethod(model.getAuthenticationMethod());
    Frontend.getInstance().runMultipleAction(ActionType.ApproveVds, new ArrayList<>(Arrays.asList(new ActionParametersBase[] { params })), result -> {
    }, null);
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) ApproveVdsParameters(org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters)

Example 2 with ApproveVdsParameters

use of org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters in project ovirt-engine by oVirt.

the class DataCenterGuideModel method onSelectHost.

public void onSelectHost() {
    MoveHost model = (MoveHost) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    if (!model.validate()) {
        return;
    }
    model.setSelectedHosts(new ArrayList<MoveHostData>());
    for (MoveHostData a : model.getItems()) {
        if (a.getIsSelected()) {
            model.getSelectedHosts().add(a);
        }
    }
    Cluster cluster = model.getCluster().getSelectedItem();
    final List<ActionParametersBase> parameterList = new ArrayList<>();
    for (MoveHostData hostData : model.getSelectedHosts()) {
        VDS host = hostData.getEntity();
        // Try to change host's cluster as neccessary.
        if (host.getClusterId() != null && !host.getClusterId().equals(cluster.getId())) {
            parameterList.add(new ChangeVDSClusterParameters(cluster.getId(), host.getId()));
        }
    }
    model.startProgress();
    Frontend.getInstance().runMultipleAction(ActionType.ChangeVDSCluster, parameterList, new IFrontendMultipleActionAsyncCallback() {

        @Override
        public void executed(FrontendMultipleActionAsyncResult result) {
            final DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
            List<MoveHostData> hosts = ((MoveHost) dataCenterGuideModel.getWindow()).getSelectedHosts();
            List<ActionReturnValue> retVals = result.getReturnValue();
            final List<ActionParametersBase> activateVdsParameterList = new ArrayList<>();
            if (retVals != null && hosts.size() == retVals.size()) {
                int i = 0;
                for (MoveHostData selectedHostData : hosts) {
                    VDS selectedHost = selectedHostData.getEntity();
                    if (selectedHost.getStatus() == VDSStatus.PendingApproval && retVals.get(i) != null && retVals.get(i).getSucceeded()) {
                        Frontend.getInstance().runAction(ActionType.ApproveVds, new ApproveVdsParameters(selectedHost.getId()), null, this);
                    } else if (selectedHostData.getActivateHost()) {
                        activateVdsParameterList.add(new VdsActionParameters(selectedHostData.getEntity().getId()));
                    }
                    i++;
                }
            }
            if (activateVdsParameterList.isEmpty()) {
                dataCenterGuideModel.getWindow().stopProgress();
                dataCenterGuideModel.cancel();
                dataCenterGuideModel.postAction();
            } else {
                final String searchString = getVdsSearchString((MoveHost) dataCenterGuideModel.getWindow());
                Timer timer = new Timer() {

                    public void run() {
                        checkVdsClusterChangeSucceeded(searchString, parameterList, activateVdsParameterList);
                    }
                };
                timer.schedule(2000);
            }
        }
    }, this);
}
Also used : IFrontendMultipleActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback) MoveHost(org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHost) VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ApproveVdsParameters(org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) FrontendMultipleActionAsyncResult(org.ovirt.engine.ui.uicompat.FrontendMultipleActionAsyncResult) Timer(com.google.gwt.user.client.Timer) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters) MoveHostData(org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHostData) List(java.util.List) ArrayList(java.util.ArrayList)

Example 3 with ApproveVdsParameters

use of org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters in project ovirt-engine by oVirt.

the class BackendHostResource method approve.

@Override
public Response approve(Action action) {
    if (action.isSetCluster() && (action.getCluster().isSetId() || action.getCluster().isSetName())) {
        update(setCluster(get(), action.getCluster()));
    }
    ApproveVdsParameters params = new ApproveVdsParameters(guid);
    params = (ApproveVdsParameters) getMapper(Action.class, VdsOperationActionParameters.class).map(action, params);
    // Set pk authentication as default
    params.setAuthMethod(VdsOperationActionParameters.AuthenticationMethod.PublicKey);
    if (action.isSetRootPassword()) {
        params.setAuthMethod(VdsOperationActionParameters.AuthenticationMethod.Password);
        params.setRootPassword(action.getRootPassword());
    } else if (action.isSetSsh() && action.getSsh().isSetAuthenticationMethod()) {
        if (action.getSsh().getAuthenticationMethod() == SshAuthenticationMethod.PASSWORD) {
            params.setAuthMethod(VdsOperationActionParameters.AuthenticationMethod.Password);
            if (action.getSsh().isSetUser() && action.getSsh().getUser().isSetPassword()) {
                params.setPassword(action.getSsh().getUser().getPassword());
            }
        }
    }
    return doAction(ActionType.ApproveVds, params, action);
}
Also used : Action(org.ovirt.engine.api.model.Action) ApproveVdsParameters(org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters) VdsOperationActionParameters(org.ovirt.engine.core.common.action.VdsOperationActionParameters)

Example 4 with ApproveVdsParameters

use of org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters in project ovirt-engine by oVirt.

the class RegisterVdsQuery method dispatchOvirtApprovalCommand.

private boolean dispatchOvirtApprovalCommand(Guid oVirtId) {
    boolean isApprovalDispatched = true;
    final ApproveVdsParameters params = new ApproveVdsParameters();
    params.setVdsId(oVirtId);
    params.setApprovedByRegister(true);
    try {
        ThreadPoolUtil.execute(() -> {
            try {
                ActionReturnValue ret = Backend.getInstance().runInternalAction(ActionType.ApproveVds, params);
                if (ret == null || !ret.getSucceeded()) {
                    log.error("Approval of oVirt '{}' failed. ", params.getVdsId());
                } else if (ret.getSucceeded()) {
                    log.info("Approval of oVirt '{}' ended successfully. ", params.getVdsId());
                }
            } catch (RuntimeException ex) {
                log.error("Failed to Approve host", ex);
            }
        });
    } catch (Exception e) {
        isApprovalDispatched = false;
    }
    return isApprovalDispatched;
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ApproveVdsParameters(org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters)

Example 5 with ApproveVdsParameters

use of org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters in project ovirt-engine by oVirt.

the class ClusterGuideModel method onSelectHost.

public void onSelectHost() {
    MoveHost model = (MoveHost) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    if (!model.validate()) {
        return;
    }
    model.setSelectedHosts(new ArrayList<MoveHostData>());
    for (EntityModel a : model.getItems()) {
        if (a.getIsSelected()) {
            model.getSelectedHosts().add((MoveHostData) a);
        }
    }
    Cluster cluster = model.getCluster().getSelectedItem();
    final List<ActionParametersBase> parameterList = new ArrayList<>();
    for (MoveHostData hostData : model.getSelectedHosts()) {
        VDS host = hostData.getEntity();
        // Try to change host's cluster as neccessary.
        if (host.getClusterId() != null && !host.getClusterId().equals(cluster.getId())) {
            parameterList.add(new ChangeVDSClusterParameters(cluster.getId(), host.getId()));
        }
    }
    model.startProgress();
    Frontend.getInstance().runMultipleAction(ActionType.ChangeVDSCluster, parameterList, result -> {
        List<MoveHostData> hosts = ((MoveHost) getWindow()).getSelectedHosts();
        List<ActionReturnValue> retVals = result.getReturnValue();
        final List<ActionParametersBase> activateVdsParameterList = new ArrayList<>();
        if (retVals != null && hosts.size() == retVals.size()) {
            int i = 0;
            for (MoveHostData selectedHostData : hosts) {
                VDS selectedHost = selectedHostData.getEntity();
                if (selectedHost.getStatus() == VDSStatus.PendingApproval && retVals.get(i) != null && retVals.get(i).getSucceeded()) {
                    Frontend.getInstance().runAction(ActionType.ApproveVds, new ApproveVdsParameters(selectedHost.getId()));
                } else if (selectedHostData.getActivateHost()) {
                    activateVdsParameterList.add(new VdsActionParameters(selectedHostData.getEntity().getId()));
                }
                i++;
            }
        }
        if (activateVdsParameterList.isEmpty()) {
            getWindow().stopProgress();
            cancel();
            postAction();
        } else {
            final String searchString = getVdsSearchString((MoveHost) getWindow());
            Timer timer = new Timer() {

                public void run() {
                    checkVdsClusterChangeSucceeded(searchString, parameterList, activateVdsParameterList);
                }
            };
            timer.schedule(2000);
        }
    }, this);
}
Also used : MoveHost(org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHost) VDS(org.ovirt.engine.core.common.businessentities.VDS) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ApproveVdsParameters(org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) Timer(com.google.gwt.user.client.Timer) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters) MoveHostData(org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHostData)

Aggregations

ApproveVdsParameters (org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters)5 VDS (org.ovirt.engine.core.common.businessentities.VDS)3 Timer (com.google.gwt.user.client.Timer)2 ArrayList (java.util.ArrayList)2 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)2 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)2 ChangeVDSClusterParameters (org.ovirt.engine.core.common.action.ChangeVDSClusterParameters)2 VdsActionParameters (org.ovirt.engine.core.common.action.VdsActionParameters)2 AddVdsActionParameters (org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters)2 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2 MoveHost (org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHost)2 MoveHostData (org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHostData)2 List (java.util.List)1 Action (org.ovirt.engine.api.model.Action)1 VdsOperationActionParameters (org.ovirt.engine.core.common.action.VdsOperationActionParameters)1 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)1 FrontendMultipleActionAsyncResult (org.ovirt.engine.ui.uicompat.FrontendMultipleActionAsyncResult)1 IFrontendMultipleActionAsyncCallback (org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback)1