Commit 68014b94 authored by Yingjie Xu's avatar Yingjie Xu

Revert "Extend methods to use binary cache."

This reverts commit 2a9024fc.
parent c0c5c973
...@@ -24,8 +24,7 @@ import tempfile ...@@ -24,8 +24,7 @@ import tempfile
import traceback import traceback
import urllib2 import urllib2
import urlparse import urlparse
import ctypes
from ctypes import util
class NetworkcacheClient(object): class NetworkcacheClient(object):
''' '''
...@@ -113,7 +112,7 @@ class NetworkcacheClient(object): ...@@ -113,7 +112,7 @@ class NetworkcacheClient(object):
self.shadir_cert_file = shadir_cert_file self.shadir_cert_file = shadir_cert_file
def upload(self, file_descriptor, key=None, urlmd5=None, file_name=None, def upload(self, file_descriptor, key=None, urlmd5=None, file_name=None,
valid_until=None, architecture=None, kernel=None, libc_version=None): valid_until=None, architecture=None):
''' Upload the file to the server. ''' Upload the file to the server.
If urlmd5 is None it must only upload to SHACACHE. If urlmd5 is None it must only upload to SHACACHE.
Otherwise, it must create a new entry on SHADIR. Otherwise, it must create a new entry on SHADIR.
...@@ -162,10 +161,6 @@ class NetworkcacheClient(object): ...@@ -162,10 +161,6 @@ class NetworkcacheClient(object):
kw['valid-until'] = valid_until kw['valid-until'] = valid_until
if architecture is not None: if architecture is not None:
kw['architecture'] = architecture kw['architecture'] = architecture
if kernel is not None:
kw['kernel'] = kernel
if libc_version is not None:
kw['libc-version'] = libc_version
sha_entry = json.dumps(kw) sha_entry = json.dumps(kw)
try: try:
...@@ -205,7 +200,7 @@ class NetworkcacheClient(object): ...@@ -205,7 +200,7 @@ class NetworkcacheClient(object):
headers=self.shadir_header_dict) headers=self.shadir_header_dict)
return urllib2.urlopen(request) return urllib2.urlopen(request)
def select(self, key, binary_mode=False): def select(self, key):
''' Download a file from shacache by selecting the entry in shadir ''' Download a file from shacache by selecting the entry in shadir
Raise DirectoryNotFound if multiple files are found. Raise DirectoryNotFound if multiple files are found.
''' '''
...@@ -223,8 +218,7 @@ class NetworkcacheClient(object): ...@@ -223,8 +218,7 @@ class NetworkcacheClient(object):
if self.signature_certificate_list is not None: if self.signature_certificate_list is not None:
for data in data_list: for data in data_list:
if len(data[1]): if len(data[1]):
if self._verifySignatureInCertificateList(data[0], data[1]) and \ if self._verifySignatureInCertificateList(data[0], data[1]):
self._isCompatible(data[0], binary_mode=binary_mode):
filtered_data_list.append(data) filtered_data_list.append(data)
else: else:
filtered_data_list = data_list filtered_data_list = data_list
...@@ -324,26 +318,6 @@ class NetworkcacheClient(object): ...@@ -324,26 +318,6 @@ class NetworkcacheClient(object):
content_file.close() content_file.close()
pubkey_file.close() pubkey_file.close()
def _isCompatible(self, information_json, binary_mode=False):
if not binary_mode:
return True
try:
information_dict = json.loads(information_json)
except Exception:
raise DirectoryNotFound('It was impossible to parse json-in-json '
'response:\n%s' % traceback.format_exc())
_, _, kernel, _, _ = os.uname()
LIBC = ctypes.cdll.LoadLibrary(ctypes.util.find_library('c'))
libc_version = LIBC.gnu_get_libc_version
libc_version.restype = ctypes.c_char_p
try:
if kernel != information_dict.get('kernel'):
return False
if ("libc-%s" % libc_version()) != information_dict.get('libc-version'):
return False
except Exception:
return False
return True
class DirectoryNotFound(Exception): class DirectoryNotFound(Exception):
pass pass
......
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