Simple example of using SALT-API to enter integrated development

Source: Internet
Author: User

When testing, it can be curl-k, but the real integration, but it is not possible.

You must not let the token fly.

Now it's time to go to this stage. Write a sample first:

ImportSaltImportSalt.authImportSalt.logImportsaltapiopts=salt.client.LocalClient (). Optsauth=Salt.auth.LoadAuth (opts) lowstate= {'username':'XXX','Password':'XXX','Eauth':'Pam'}token=Auth.mk_token (lowstate) API=Saltapi. Apiclient (opts) lowstate= {'Client':'Local',        ' Fun':'Cmd.run',        'Arg':['ls','/',],        'TGT':'192.168.11.69',        'token': token['token']}res=Api.run (lowstate) for(K,V)inchRes.items ():PrintKv

Output:

[[Email protected]]# python salt-api.py
192.168.11.69 bin
Boot
Dev
etc
Home
Lib
Lib64
Media
Mnt
Opt
Proc
Root
Run
Sbin
Srv
Sys
Tmp
Usr
Var

~~~~~~~~~~~~~~

Others don't care too much, but the fun in lowstate is the salt function (Test.ping,disk.usage,cmd.run ...). These While Arg is a possible parameter, note that if the command is executed remotely, the parameter is provided in the form of a list.

Simple example of using SALT-API to enter integrated development

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.