Commit e3b11012 authored by Łukasz Nowak's avatar Łukasz Nowak

Follow the shadir spec.

Key is given by the library user. It has no internal meaning.
parent 08df4c6e
......@@ -80,7 +80,7 @@ class NetworkcacheClient(object):
self.signature_certificate_url_list.append(value)
def upload(self, file_descriptor, urlmd5=None, file_name=None,
valid_until=None, architecture=None):
valid_until=None, architecture=None, key=None):
''' Upload the file to the server.
If urlmd5 is None it must only upload to SHACACHE.
Otherwise, it must create a new entry on SHADIR.
......@@ -111,9 +111,9 @@ class NetworkcacheClient(object):
'URL: %s. Response code: %s. Response data: %s' % \
(self.shacache_host, result.status, data))
if urlmd5 is not None:
if key is not None:
if file_name is None:
raise ValueError('In case if urlmd5 is given file_name is required.')
raise ValueError('In case if key is given file_name is required.')
kw = dict()
kw['file'] = file_name
kw['urlmd5'] = urlmd5
......@@ -130,8 +130,8 @@ class NetworkcacheClient(object):
shadir_connection = httplib.HTTPConnection(self.shadir_host,
self.shadir_port)
try:
shadir_connection.request('POST', self.shadir_path, json.dumps(data),
self.shadir_header_dict)
shadir_connection.request('PUT', '/'.join([self.shadir_path, key]),
json.dumps(data), self.shadir_header_dict)
result = shadir_connection.getresponse()
data = result.read()
finally:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment