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
1
Merge Requests
1
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
Romain Courteaud
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
Hide 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):
...
@@ -88,7 +88,8 @@ class Software(object):
if
download_network_cached
(
if
download_network_cached
(
self
.
download_binary_cache_url
,
self
.
download_binary_cache_url
,
self
.
download_binary_dir_url
,
self
.
download_binary_dir_url
,
self
.
url
,
self
.
software_url_hash
,
self
.
url
,
self
.
software_root
,
self
.
software_url_hash
,
tarpath
,
self
.
logger
,
tarpath
,
self
.
logger
,
self
.
signature_certificate_list
):
self
.
signature_certificate_list
):
tar
=
tarfile
.
open
(
tarpath
)
tar
=
tarfile
.
open
(
tarpath
)
...
...
slapos/grid/networkcache.py
View file @
76b9961e
...
@@ -22,6 +22,7 @@ import urlparse
...
@@ -22,6 +22,7 @@ import urlparse
import
traceback
import
traceback
import
utils
import
utils
import
json
import
json
import
platform
try
:
try
:
try
:
try
:
...
@@ -54,8 +55,8 @@ def fallback_call(function):
...
@@ -54,8 +55,8 @@ def fallback_call(function):
@
fallback_call
@
fallback_call
def
download_network_cached
(
cache_url
,
dir_url
,
software_url
,
key
,
path
,
def
download_network_cached
(
cache_url
,
dir_url
,
software_url
,
software_root
,
logger
,
signature_certificate_list
):
key
,
path
,
logger
,
signature_certificate_list
):
"""Downloads from a network cache provider
"""Downloads from a network cache provider
return True if download succeeded.
return True if download succeeded.
...
@@ -77,27 +78,37 @@ def download_network_cached(cache_url, dir_url, software_url, key, path,
...
@@ -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
)
logger
.
info
(
'Downloading %s binary from network cache.'
%
software_url
)
try
:
try
:
file_descriptor
=
None
json_entry_list
=
nc
.
select_generic
(
key
)
json_entry_list
=
nc
.
select_generic
(
key
)
for
entry
in
json_entry_list
:
for
entry
in
json_entry_list
:
json_information
,
_
=
entry
json_information
,
_
=
entry
try
:
try
:
tags
=
json
.
loads
(
json_information
)
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'
)
sha512
=
tags
.
get
(
'sha512'
)
file_descriptor
=
nc
.
download
(
sha512
)
file_descriptor
=
nc
.
download
(
sha512
)
break
break
except
Exception
:
except
Exception
:
continue
continue
f
=
open
(
path
,
'w+b'
)
if
file_descriptor
is
not
None
:
try
:
f
=
open
(
path
,
'w+b'
)
shutil
.
copyfileobj
(
file_descriptor
,
f
)
try
:
finally
:
shutil
.
copyfileobj
(
file_descriptor
,
f
)
f
.
close
()
finally
:
file_descriptor
.
close
()
f
.
close
()
file_descriptor
.
close
()
return
True
except
(
IOError
,
DirectoryNotFound
),
e
:
except
(
IOError
,
DirectoryNotFound
),
e
:
logger
.
info
(
'Failed to download from network cache %s: %s'
%
\
logger
.
info
(
'Failed to download from network cache %s: %s'
%
\
(
software_url
,
str
(
e
)))
(
software_url
,
str
(
e
)))
return
False
return
False
return
True
@
fallback_call
@
fallback_call
...
@@ -114,17 +125,14 @@ def upload_network_cached(software_root, software_url, cached_key,
...
@@ -114,17 +125,14 @@ def upload_network_cached(software_root, software_url, cached_key,
logger
.
info
(
'Uploading %s binary into network cache.'
%
software_url
)
logger
.
info
(
'Uploading %s binary into network cache.'
%
software_url
)
# YXU: "file" and "urlmd5" should be removed when server side is ready
kw
=
dict
(
kw
=
dict
(
file
=
software_url
,
file
=
"file"
,
urlmd5
=
cached_key
,
urlmd5
=
"urlmd5"
,
software_url
=
software_url
,
software_url
=
software_url
,
gcc_version
=
"gcc-version"
,
libc_version
=
"libc-version"
,
libcxx_version
=
"libcxx-version"
,
kernel_version
=
"kernel-version"
,
software_root
=
software_root
,
software_root
=
software_root
,
arch
=
"arch"
,
machine
=
platform
.
machine
()
,
python_version
=
"python-version"
os
=
str
(
platform
.
linux_distrubution
())
)
)
f
=
open
(
path
,
'r'
)
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