Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nicolas Wavrant
slapos.core
Commits
76b9961e
Commit
76b9961e
authored
Feb 08, 2012
by
Yingjie Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix json tags.
parent
ebefd105
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
19 deletions
+28
-19
slapos/grid/SlapObject.py
slapos/grid/SlapObject.py
+2
-1
slapos/grid/networkcache.py
slapos/grid/networkcache.py
+26
-18
No files found.
slapos/grid/SlapObject.py
View file @
76b9961e
...
...
@@ -88,7 +88,8 @@ class Software(object):
if
download_network_cached
(
self
.
download_binary_cache_url
,
self
.
download_binary_dir_url
,
self
.
url
,
self
.
software_url_hash
,
self
.
url
,
self
.
software_root
,
self
.
software_url_hash
,
tarpath
,
self
.
logger
,
self
.
signature_certificate_list
):
tar
=
tarfile
.
open
(
tarpath
)
...
...
slapos/grid/networkcache.py
View file @
76b9961e
...
...
@@ -22,6 +22,7 @@ import urlparse
import
traceback
import
utils
import
json
import
platform
try
:
try
:
...
...
@@ -54,8 +55,8 @@ def fallback_call(function):
@
fallback_call
def
download_network_cached
(
cache_url
,
dir_url
,
software_url
,
key
,
path
,
logger
,
signature_certificate_list
):
def
download_network_cached
(
cache_url
,
dir_url
,
software_url
,
software_root
,
key
,
path
,
logger
,
signature_certificate_list
):
"""Downloads from a network cache provider
return True if download succeeded.
...
...
@@ -77,27 +78,37 @@ def download_network_cached(cache_url, dir_url, software_url, key, path,
logger
.
info
(
'Downloading %s binary from network cache.'
%
software_url
)
try
:
file_descriptor
=
None
json_entry_list
=
nc
.
select_generic
(
key
)
for
entry
in
json_entry_list
:
json_information
,
_
=
entry
try
:
tags
=
json
.
loads
(
json_information
)
if
tags
.
get
(
'machine'
)
!=
platform
.
machine
():
continue
if
tags
.
get
(
'os'
)
!=
str
(
platform
.
linux_distribution
()):
continue
if
tags
.
get
(
'software_url'
)
!=
software_url
:
continue
if
tags
.
get
(
'software_root'
)
!=
software_root
:
continue
sha512
=
tags
.
get
(
'sha512'
)
file_descriptor
=
nc
.
download
(
sha512
)
break
except
Exception
:
continue
if
file_descriptor
is
not
None
:
f
=
open
(
path
,
'w+b'
)
try
:
shutil
.
copyfileobj
(
file_descriptor
,
f
)
finally
:
f
.
close
()
file_descriptor
.
close
()
return
True
except
(
IOError
,
DirectoryNotFound
),
e
:
logger
.
info
(
'Failed to download from network cache %s: %s'
%
\
(
software_url
,
str
(
e
)))
return
False
return
True
@
fallback_call
...
...
@@ -114,17 +125,14 @@ def upload_network_cached(software_root, software_url, cached_key,
logger
.
info
(
'Uploading %s binary into network cache.'
%
software_url
)
# YXU: "file" and "urlmd5" should be removed when server side is ready
kw
=
dict
(
file
=
software_url
,
urlmd5
=
cached_key
,
file
=
"file"
,
urlmd5
=
"urlmd5"
,
software_url
=
software_url
,
gcc_version
=
"gcc-version"
,
libc_version
=
"libc-version"
,
libcxx_version
=
"libcxx-version"
,
kernel_version
=
"kernel-version"
,
software_root
=
software_root
,
arch
=
"arch"
,
python_version
=
"python-version"
machine
=
platform
.
machine
()
,
os
=
str
(
platform
.
linux_distrubution
())
)
f
=
open
(
path
,
'r'
)
...
...
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