Last active
December 26, 2017 20:38
-
-
Save tsaridas/168f0178c67a2e0caa65497675209ddf to your computer and use it in GitHub Desktop.
simple-salt-client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python2.7 | |
# -*- coding: utf-8 -*- | |
import zmq | |
import msgpack | |
root_file = '/var/cache/salt/master/.root_key' | |
with open(root_file) as f: | |
root_key = f.read() | |
msg = {'load': {'tgt_type': 'list', 'jid': '', 'cmd': 'publish', 'tgt': ['salt-minion-01'], 'key': root_key, 'arg': [], 'fun': 'test.ping', 'kwargs': {'delimiter': ':', 'show_timeout': True, 'show_jid': False}, 'ret': '', 'user': 'root'}, 'enc': u'clear'} | |
context = zmq.Context() | |
message = msgpack.dumps(msg, encoding='utf-8') | |
# Socket to talk to server | |
print("Connecting to server… {0}".format(message)) | |
socket = context.socket(zmq.REQ) | |
socket.connect("tcp://192.168.69.40:4506") | |
print("Sending request %s …" % msg) | |
socket.send(b'{0}'.format(message)) | |
# Get the reply. | |
message = socket.recv() | |
message = msgpack.loads(message) | |
print("Received reply %s" % message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment