caller.py 409 B

12345678910111213141516171819
  1. import salt.client
  2. salt = salt.client.Caller()
  3. print(type(salt.cmd('network.ping', '1.1.1.1')))
  4. print(salt.cmd('archive.tar', 'czf', '/tmp/etc.tar.gz', '/etc/'))
  5. print(salt.cmd('file.readdir', '/tmp/'))
  6. req = salt.cmd('http.query', 'https://checkip.amazonaws.com', method='GET')
  7. ip = req.get('body', '0.0.0.0').strip()
  8. print(ip)
  9. print(req)
  10. salt.cmd('event.send', 'salt/hello', {'msg':'Hello world'})