mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Add hash_file function to cp module
This commit is contained in:
parent
9e73001008
commit
fc6d2ee6bb
@ -109,3 +109,16 @@ def cache_file(path):
|
||||
if not data:
|
||||
break
|
||||
fn_.write(data)
|
||||
|
||||
def hash_file(path):
|
||||
'''
|
||||
Return the hash of a file on the server
|
||||
'''
|
||||
auth = salt.crypt.SAuth(__opts__)
|
||||
context = zmq.Context()
|
||||
socket = context.socket(zmq.REQ)
|
||||
socket.connect(__opts__['master_uri'])
|
||||
payload = {'enc': 'aes'}
|
||||
payload['load'] = self.crypticle.dumps({'path': path})
|
||||
socket.send_pyobj(payload)
|
||||
return auth.crypticle.loads(socket.recv())
|
||||
|
Loading…
Reference in New Issue
Block a user