NetapiClient

The NetapiClient class provides access to Python API client interfaces when developing netapi modules

class salt.netapi.NetapiClient(opts)

Provide a uniform method of accessing the various client interfaces in Salt in the form of low-data data structures. For example:

>>> client = NetapiClient(__opts__)
>>> lowstate = {'client': 'local', 'tgt': '*', 'fun': 'test.ping', 'arg': ''}
>>> client.run(lowstate)
local(*args, **kwargs)

Run execution modules synchronously

See salt.client.LocalClient.cmd() for all available parameters.

Sends a command from the master to the targeted minions. This is the same interface that Salt's own CLI uses. Note the arg and kwarg parameters are sent down to the minion(s) and the given function, fun, is called with those parameters.

Returns:

Returns the result from the execution module

local_async(*args, **kwargs)

Run execution modules asynchronously

Wraps salt.client.LocalClient.run_job().

Returns:

job ID

local_subset(*args, **kwargs)

Run execution modules against subsets of minions

New in version 2016.3.0.

Wraps salt.client.LocalClient.cmd_subset()

run(low)

Execute the specified function in the specified client by passing the lowstate

runner(fun, timeout=None, full_return=False, **kwargs)

Run runner modules <all-salt.runners> synchronously

Wraps salt.runner.RunnerClient.cmd_sync().

Note that runner functions must be called using keyword arguments. Positional arguments are not supported.

Returns:

Returns the result from the runner module

runner_async(fun, **kwargs)

Run runner modules <all-salt.runners> asynchronously

Wraps salt.runner.RunnerClient.cmd_async().

Note that runner functions must be called using keyword arguments. Positional arguments are not supported.

Returns:

event data and a job ID for the executed function.

ssh(*args, **kwargs)

Run salt-ssh commands synchronously

Wraps salt.client.ssh.client.SSHClient.cmd_sync().

Returns:

Returns the result from the salt-ssh command

wheel(fun, **kwargs)

Run wheel modules synchronously

Wraps salt.wheel.WheelClient.master_call().

Note that wheel functions must be called using keyword arguments. Positional arguments are not supported.

Returns:

Returns the result from the wheel module

wheel_async(fun, **kwargs)

Run wheel modules asynchronously

Wraps salt.wheel.WheelClient.master_call().

Note that wheel functions must be called using keyword arguments. Positional arguments are not supported.

Returns:

Returns the result from the wheel module