SaltStack netapi module --Client interfaces to develop client interfaces

Original link: https://docs.saltstack.com/en/latest/topics/netapi/index.html#client-interfaces

Salt client interface through the production values ​​are mapped to the dictionary function parameters to the function of external exposure function executable. This allows only by creating a data structure to the calling function. (This is exactly the Salt own internal work!)

This is a technical data you can also refer to maintenance on Github: Client in the interfaces of modules NetAPI

class salt.netapi.NetapiClient(opts)

To provide a uniform method of accessing the various Salt client interface in a low-data data structures. E.g:

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

local

local(*args, **kwargs)

Synchronous run Execution modules .

About all the available parameters, see salt.client.LocalClient.cmd () .

From the master host sends a command to the target minions. This is the same Salt own use CLI interface. Please note, argand kwargparameters are sent to the minions, and use these parameters to call the specified function fun.

Returns: the output result of the execution module.

##local_async

local_async(*args, **kwargs)

Run asynchronously Execution modules .

It is based on salt.client.LocalClient.run_job () a package client interface functions to achieve.

Return: job ID

local_subset

local_subset(*args, **kwargs)

The minions run within a specified network subnet range Execution modules .

New in version 2016.3.0.

Based salt.client.LocalClient.cmd_subset () to do the packaging to achieve.

runner

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

Perform a synchronized manner runner modules <all-salt.runners>.

Based salt.runner.RunnerClient.cmd_sync () wrapper implementation.

Please note, runner program function must be called using keyword arguments. It does not support the position parameters.

Returns: the result returned from the operating module

runner_async

runner_async(fun, **kwargs)

Executed asynchronously runner modules <all-salt.runners>.

Based salt.runner.RunnerClient.cmd_async () wrapper implementation.

Please note, runner program function must be called using keyword arguments. It does not support the position parameters.

Returns: the event data functions performed and job ID

ssh

**ssh(*args, kwargs)

In a synchronized manner to perform salt-ssh command.

Based salt.client.ssh.client.SSHClient.cmd () wrapper implementation.

Returns: the result of the execution salt-ssh command

wheel

wheel(fun, **kwargs)

Running wheel module in a synchronous manner.

Based on salt.wheel.WheelClient.cmd()an implementation of the function package.

Please note, wheel program function must be called using keyword arguments. It does not support the position parameters.

Returns: the result of running wheel module

wheel_async

wheel_async(fun, **kwargs)

Asynchronously running wheel module.

Based on salt.wheel.WheelClient.cmd_async()an implementation of the function package.

Please note, wheel program function must be called using keyword arguments. It does not support the position parameters.

Returns: the result of running wheel module

Guess you like

Origin blog.csdn.net/watermelonbig/article/details/102760373