Search in sources :

Example 1 with MachineLimitsDto

use of org.eclipse.che.api.machine.shared.dto.MachineLimitsDto in project che by eclipse.

the class SshCategoryPresenter method connect.

/**
     * Opens a connection to the selected target.
     * Starts a machine based on the selected recipe.
     */
private void connect() {
    sshView.setConnectButtonText(null);
    connectTargetName = selectedTarget.getName();
    connectNotification = notificationManager.notify(machineLocale.targetsViewConnectProgress(selectedTarget.getName()), PROGRESS, FLOAT_MODE);
    String recipeURL = selectedTarget.getRecipe().getLink("get recipe script").getHref();
    MachineLimitsDto limitsDto = dtoFactory.createDto(MachineLimitsDto.class).withRam(1024);
    MachineSourceDto sourceDto = dtoFactory.createDto(MachineSourceDto.class).withType("ssh-config").withLocation(recipeURL);
    MachineConfigDto configDto = dtoFactory.createDto(MachineConfigDto.class).withDev(false).withName(selectedTarget.getName()).withSource(sourceDto).withLimits(limitsDto).withType(getCategory());
    Promise<Void> machinePromise = workspaceServiceClient.createMachine(appContext.getWorkspaceId(), configDto);
    machinePromise.then(new Operation<Void>() {

        @Override
        public void apply(Void arg) throws OperationException {
        }
    });
    machinePromise.catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError promiseError) throws OperationException {
            onConnectingFailed(null);
        }
    });
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) MachineLimitsDto(org.eclipse.che.api.machine.shared.dto.MachineLimitsDto) MachineConfigDto(org.eclipse.che.api.machine.shared.dto.MachineConfigDto) MachineSourceDto(org.eclipse.che.api.machine.shared.dto.MachineSourceDto) OperationException(org.eclipse.che.api.promises.client.OperationException)

Aggregations

MachineConfigDto (org.eclipse.che.api.machine.shared.dto.MachineConfigDto)1 MachineLimitsDto (org.eclipse.che.api.machine.shared.dto.MachineLimitsDto)1 MachineSourceDto (org.eclipse.che.api.machine.shared.dto.MachineSourceDto)1 OperationException (org.eclipse.che.api.promises.client.OperationException)1 PromiseError (org.eclipse.che.api.promises.client.PromiseError)1