Class LocalCall<R>

java.lang.Object
com.suse.salt.netapi.calls.AbstractCall<R>
com.suse.salt.netapi.calls.LocalCall<R>
Type Parameters:
R - the return type of the called function
All Implemented Interfaces:
Call<R>

public class LocalCall<R> extends AbstractCall<R>
Class representing a function call of a salt execution module.
  • Field Details

  • Constructor Details

  • Method Details

    • withMetadata

      public LocalCall<R> withMetadata(Object metadata)
    • withoutMetadata

      public LocalCall<R> withoutMetadata()
    • withTimeouts

      public LocalCall<R> withTimeouts(Optional<Integer> timeout, Optional<Integer> gatherJobTimeout)
    • withoutTimeouts

      public LocalCall<R> withoutTimeouts()
    • getPayload

      public Map<String,Object> getPayload()
      Return the call payload as a map of key/value pairs. Usually this contains the function name and arguments, but the various clients differ in the details.
      Returns:
      call payload as a map of key/value pairs
    • callAsync

      public CompletionStage<Optional<LocalAsyncResult<R>>> callAsync(SaltClient client, Target<?> target, AuthMethod auth, Batch batch)
      Calls a execution module function on the given target asynchronously and returns information about the scheduled job that can be used to query the result. Authentication is done with the token therefore you have to login prior to using this function.
      Parameters:
      client - SaltClient instance
      target - the target for the function
      auth - authentication credentials to use
      batch - parameter for enabling and configuring batching
      Returns:
      information about the scheduled job
    • callAsync

      public CompletionStage<Optional<LocalAsyncResult<R>>> callAsync(SaltClient client, Target<?> target, AuthMethod auth, Optional<Batch> batch)
      Calls a execution module function on the given target asynchronously and returns information about the scheduled job that can be used to query the result. Authentication is done with the token therefore you have to login prior to using this function.
      Parameters:
      client - SaltClient instance
      target - the target for the function
      auth - authentication credentials to use
      batch - parameter for enabling and configuring batching
      Returns:
      information about the scheduled job
    • callAsync

      public CompletionStage<Optional<LocalAsyncResult<R>>> callAsync(SaltClient client, Target<?> target, AuthMethod auth)
      Calls a execution module function on the given target asynchronously and returns information about the scheduled job that can be used to query the result. Authentication is done with the token therefore you have to login prior to using this function.
      Parameters:
      client - SaltClient instance
      target - the target for the function
      auth - authentication credentials to use
      Returns:
      information about the scheduled job
    • callAsync

      public CompletionStage<Optional<Map<String, CompletionStage<Result<R>>>>> callAsync(SaltClient client, Target<?> target, AuthMethod auth, EventStream events, CompletionStage<GenericError> cancel, Batch batch)
      Calls this salt call via the async client and returns the results as they come in via the event stream.
      Parameters:
      client - SaltClient instance
      target - the target for the function
      auth - authentication credentials to use
      events - the event stream to use
      cancel - future to cancel the action
      batch - parameter for enabling and configuring batching
      Returns:
      a map from minion id to future of the result.
    • callAsync

      public CompletionStage<Optional<Map<String, CompletionStage<Result<R>>>>> callAsync(SaltClient client, Target<?> target, AuthMethod auth, EventStream events, CompletionStage<GenericError> cancel, Optional<Batch> batch)
      Calls this salt call via the async client and returns the results as they come in via the event stream.
      Parameters:
      client - SaltClient instance
      target - the target for the function
      auth - authentication credentials to use
      events - the event stream to use
      cancel - future to cancel the action
      batch - parameter for enabling and configuring batching
      Returns:
      a map from minion id to future of the result.
    • callAsync

      Calls this salt call via the async client and returns the results as they come in via the event stream.
      Parameters:
      localAsync - function providing callAsync for LocalCalls
      runnerAsync - function providing callAsync for RunnerCalls
      events - the event stream to use
      cancel - future to cancel the action
      Returns:
      a map from minion id to future of the result.
    • callSync

      public CompletionStage<Map<String, Result<R>>> callSync(SaltClient client, Target<?> target, AuthMethod auth)
      Calls a execution module function on the given target and synchronously waits for the result. Authentication is done with the token therefore you have to login prior to using this function.
      Parameters:
      client - SaltClient instance
      target - the target for the function
      auth - authentication credentials to use
      Returns:
      a map containing the results with the minion name as key
    • callSync

      public CompletionStage<List<Map<String, Result<R>>>> callSync(SaltClient client, Target<?> target, AuthMethod auth, Batch batch)
      Calls a execution module function on the given target with batching and synchronously waits for the result. Authentication is done with the token therefore you have to login prior to using this function.
      Parameters:
      client - SaltClient instance
      target - the target for the function
      auth - authentication credentials to use
      batch - the batch specification
      Returns:
      A list of maps with each list representing each batch, and maps containing the results with the minion names as keys.
    • callSync

      public CompletionStage<List<Map<String, Result<R>>>> callSync(SaltClient client, Target<?> target, AuthMethod auth, Optional<Batch> batch)
      Calls a execution module function on the given target with batching and synchronously waits for the result. Authentication is done with the token therefore you have to login prior to using this function.
      Parameters:
      client - SaltClient instance
      target - the target for the function
      auth - authentication credentials to use
      batch - parameter for enabling and configuring batching
      Returns:
      A list of maps with each list representing each batch, and maps containing the results with the minion names as keys.
    • handleRetcodeBatchingHack

      private List<Map<String, Result<R>>> handleRetcodeBatchingHack(List<Map<String, Result<R>>> list, Type xor)
    • callSyncHelperNonBlock

      private CompletionStage<List<Map<String, Result<R>>>> callSyncHelperNonBlock(SaltClient client, Target<?> target, AuthMethod auth, Optional<Batch> batch)
      Helper to call an execution module function on the given target for batched or unbatched while also providing an option to use the given credentials or to use a prior created token. Synchronously waits for the result.
      Parameters:
      client - SaltClient instance
      target - the target for the function
      auth - authentication credentials to use
      batch - the batch parameter, empty for unbatched
      Returns:
      A list of maps with each list representing each batch, and maps containing the results with the minion names as keys. The first list is the entire output for unbatched input.
    • callSyncSSH

      public CompletionStage<Map<String, Result<SSHResult<R>>>> callSyncSSH(SaltClient client, SSHTarget<?> target, SaltSSHConfig cfg, AuthMethod auth)
      Call an execution module function on the given target via salt-ssh and synchronously wait for the result.
      Parameters:
      client - SaltClient instance
      target - the target for the function
      cfg - Salt SSH configuration object
      auth - authentication credentials to use
      Returns:
      a map containing the results with the minion name as key
    • onRunnerReturn

      private static <R> void onRunnerReturn(String jid, RunnerReturnEvent rre, com.google.gson.reflect.TypeToken<Result<R>> tt, Map<String, CompletableFuture<Result<R>>> targets)
    • onJobReturn

      private static <R> void onJobReturn(String jid, JobReturnEvent jre, com.google.gson.reflect.TypeToken<Result<R>> tt, Map<String, CompletableFuture<Result<R>>> targets)