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>
Class representing a function call of a salt execution module.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLocalCall(String functionName, Optional<List<?>> arg, Optional<Map<String, ?>> kwarg, com.google.gson.reflect.TypeToken<R> returnType) LocalCall(String functionName, Optional<List<?>> arg, Optional<Map<String, ?>> kwarg, com.google.gson.reflect.TypeToken<R> returnType, Optional<?> metadata) LocalCall(String functionName, Optional<List<?>> arg, Optional<Map<String, ?>> kwarg, com.google.gson.reflect.TypeToken<R> returnType, Optional<?> metadata, Optional<Integer> timeout, Optional<Integer> gatherJobTimeout) LocalCall(String functionName, Optional<List<?>> arg, Optional<Map<String, ?>> kwarg, com.google.gson.reflect.TypeToken<R> returnType, Optional<Integer> timeout, Optional<Integer> gatherJobTimeout) -
Method Summary
Modifier and TypeMethodDescriptioncallAsync(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.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.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.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.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.callAsync(Function<LocalCall<R>, CompletionStage<Optional<LocalAsyncResult<R>>>> localAsync, Function<RunnerCall<Map<String, R>>, CompletionStage<RunnerAsyncResult<Map<String, R>>>> runnerAsync, EventStream events, CompletionStage<GenericError> cancel) Calls this salt call via the async client and returns the results as they come in via the event stream.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.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.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.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.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.Return the call payload as a map of key/value pairs.private static <R> voidonJobReturn(String jid, JobReturnEvent jre, com.google.gson.reflect.TypeToken<Result<R>> tt, Map<String, CompletableFuture<Result<R>>> targets) private static <R> voidonRunnerReturn(String jid, RunnerReturnEvent rre, com.google.gson.reflect.TypeToken<Result<R>> tt, Map<String, CompletableFuture<Result<R>>> targets) withMetadata(Object metadata) withTimeouts(Optional<Integer> timeout, Optional<Integer> gatherJobTimeout) Methods inherited from class AbstractCall
getFunction, getFunctionName, getModuleName, getReturnType
-
Field Details
-
arg
-
kwarg
-
metadata
-
timeout
-
gatherJobTimeout
-
-
Constructor Details
-
LocalCall
-
LocalCall
-
LocalCall
-
LocalCall
-
-
Method Details
-
withMetadata
-
withoutMetadata
-
withTimeouts
-
withoutTimeouts
-
getPayload
-
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 instancetarget- the target for the functionauth- authentication credentials to usebatch- 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 instancetarget- the target for the functionauth- authentication credentials to usebatch- 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 instancetarget- the target for the functionauth- 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 instancetarget- the target for the functionauth- authentication credentials to useevents- the event stream to usecancel- future to cancel the actionbatch- 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 instancetarget- the target for the functionauth- authentication credentials to useevents- the event stream to usecancel- future to cancel the actionbatch- 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(Function<LocalCall<R>, CompletionStage<Optional<LocalAsyncResult<R>>>> localAsync, Function<RunnerCall<Map<String, R>>, CompletionStage<RunnerAsyncResult<Map<String, R>>>> runnerAsync, EventStream events, CompletionStage<GenericError> cancel) 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 LocalCallsrunnerAsync- function providing callAsync for RunnerCallsevents- the event stream to usecancel- 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 instancetarget- the target for the functionauth- 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 instancetarget- the target for the functionauth- authentication credentials to usebatch- 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 instancetarget- the target for the functionauth- authentication credentials to usebatch- 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
-
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 instancetarget- the target for the functionauth- authentication credentials to usebatch- 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 instancetarget- the target for the functioncfg- Salt SSH configuration objectauth- 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)
-