Add hash_file function to cp module

This commit is contained in:
Thomas S Hatch 2011-05-20 13:10:59 -06:00
parent 9e73001008
commit fc6d2ee6bb

View File

@ -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())