Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.libnetworkcache
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Douglas
slapos.libnetworkcache
Commits
68014b94
Commit
68014b94
authored
Jan 19, 2012
by
Yingjie Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Extend methods to use binary cache."
This reverts commit
2a9024fc
.
parent
c0c5c973
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
30 deletions
+4
-30
slapos/libnetworkcache.py
slapos/libnetworkcache.py
+4
-30
No files found.
slapos/libnetworkcache.py
View file @
68014b94
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment