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
e5fb7451
Commit
e5fb7451
authored
Jan 26, 2012
by
Yingjie Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rewrite upload method.
parent
a2548626
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
15 deletions
+19
-15
slapos/grid/networkcache.py
slapos/grid/networkcache.py
+19
-15
No files found.
slapos/grid/networkcache.py
View file @
e5fb7451
...
...
@@ -20,6 +20,7 @@ import re
import
shutil
import
urlparse
import
traceback
import
utils
try
:
try
:
...
...
@@ -106,23 +107,28 @@ def download_network_cached(dir_url, cache_url, path, url, logger,
@
fallback_call
def
upload_network_cached
(
dir_url
,
cache_url
,
external_url
,
path
,
logger
,
signature_private_key_file
,
shacache_cert_file
,
shacach
e_key_file
,
shadir_cert_file
,
shadir_key_file
):
def
upload_network_cached
(
software_root
,
software_url
,
cached_key
,
cache_url
,
path
,
logger
,
signature_privat
e_key_file
,
shacache_cert_file
,
shacache_key_file
,
shadir_cert_file
,
shadir_key_file
):
"""Upload file to a network cache server"""
if
not
LIBNETWORKCACHE_ENABLED
:
return
False
if
not
(
dir_url
and
cache_url
):
if
not
(
software_root
and
software_url
and
cached_key
and
cache_url
):
return
False
logger
.
info
(
'Uploading %s
into network cache.'
%
external
_url
)
logger
.
info
(
'Uploading %s
binary into network cache.'
%
software
_url
)
file_name
=
get_filename_from_url
(
external_url
)
directory_key
=
get_directory_key
(
external_url
)
kw
=
dict
(
file_name
=
file_name
,
urlmd5
=
hashlib
.
md5
(
external_url
).
hexdigest
())
kw
=
dict
(
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"
)
f
=
open
(
path
,
'r'
)
# convert '' into None in order to call nc nicely
...
...
@@ -137,7 +143,7 @@ def upload_network_cached(dir_url, cache_url, external_url, path, logger,
if
not
shadir_key_file
:
shadir_key_file
=
None
try
:
nc
=
NetworkcacheClient
(
cache_url
,
dir
_url
,
nc
=
NetworkcacheClient
(
cache_url
,
software
_url
,
signature_private_key_file
=
signature_private_key_file
,
shacache_cert_file
=
shacache_cert_file
,
shacache_key_file
=
shacache_key_file
,
...
...
@@ -148,12 +154,10 @@ def upload_network_cached(dir_url, cache_url, external_url, path, logger,
return
False
try
:
return
nc
.
upload
(
f
,
directory
_key
,
**
kw
)
return
nc
.
upload
_generic
(
f
,
cached
_key
,
**
kw
)
except
(
IOError
,
UploadError
),
e
:
logger
.
info
(
'Fail to upload file. %s'
%
\
(
str
(
e
)))
logger
.
info
(
'Fail to upload file. %s'
%
(
str
(
e
)))
return
False
finally
:
f
.
close
()
...
...
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