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
Carlos Ramos Carreño
slapos.core
Commits
f0c93b97
Commit
f0c93b97
authored
Jan 26, 2012
by
Yingjie Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement upload.
parent
cb810ffa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
4 deletions
+76
-4
slapos/grid/SlapObject.py
slapos/grid/SlapObject.py
+41
-4
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+35
-0
No files found.
slapos/grid/SlapObject.py
View file @
f0c93b97
...
@@ -38,6 +38,8 @@ import utils
...
@@ -38,6 +38,8 @@ import utils
from
svcbackend
import
getSupervisorRPC
from
svcbackend
import
getSupervisorRPC
from
exception
import
BuildoutFailedError
,
WrongPermissionError
,
\
from
exception
import
BuildoutFailedError
,
WrongPermissionError
,
\
PathDoesNotExistError
PathDoesNotExistError
from
networkcache
import
download_network_cached
,
upload_network_cached
import
tarfile
REQUIRED_COMPUTER_PARTITION_PERMISSION
=
'0750'
REQUIRED_COMPUTER_PARTITION_PERMISSION
=
'0750'
...
@@ -45,27 +47,62 @@ REQUIRED_COMPUTER_PARTITION_PERMISSION = '0750'
...
@@ -45,27 +47,62 @@ REQUIRED_COMPUTER_PARTITION_PERMISSION = '0750'
class
Software
(
object
):
class
Software
(
object
):
"""This class is responsible of installing a software release"""
"""This class is responsible of installing a software release"""
def
__init__
(
self
,
url
,
software_root
,
console
,
buildout
,
def
__init__
(
self
,
url
,
software_root
,
console
,
buildout
,
signature_private_key_file
=
None
,
upload_cache_url
=
None
,
signature_private_key_file
=
None
,
signature_certificate_list
=
None
,
upload_dir_url
=
None
,
shacache_cert_file
=
None
,
shacache_key_file
=
None
,
upload_cache_url
=
None
,
upload_dir_url
=
None
,
shacache_cert_file
=
None
,
shadir_cert_file
=
None
,
shadir_key_file
=
None
):
shacache_key_file
=
None
,
shadir_cert_file
=
None
,
shadir_key_file
=
None
,
download_binary_cache_url
=
None
,
upload_binary_cache_url
=
None
,
download_binary_dir_url
=
None
,
upload_binary_dir_url
=
None
):
"""Initialisation of class parameters
"""Initialisation of class parameters
"""
"""
self
.
url
=
url
self
.
url
=
url
self
.
software_root
=
software_root
self
.
software_root
=
software_root
self
.
software_url_hash
=
utils
.
getSoftwareUrlHash
(
self
.
url
)
self
.
software_path
=
os
.
path
.
join
(
self
.
software_root
,
self
.
software_path
=
os
.
path
.
join
(
self
.
software_root
,
utils
.
getSoftwareUrlHash
(
self
.
url
)
)
self
.
software_url_hash
)
self
.
buildout
=
buildout
self
.
buildout
=
buildout
self
.
logger
=
logging
.
getLogger
(
'BuildoutManager'
)
self
.
logger
=
logging
.
getLogger
(
'BuildoutManager'
)
self
.
console
=
console
self
.
console
=
console
self
.
signature_private_key_file
=
signature_private_key_file
self
.
signature_private_key_file
=
signature_private_key_file
self
.
signature_certificate_list
=
signature_certificate_list
self
.
upload_cache_url
=
upload_cache_url
self
.
upload_cache_url
=
upload_cache_url
self
.
upload_dir_url
=
upload_dir_url
self
.
upload_dir_url
=
upload_dir_url
self
.
shacache_cert_file
=
shacache_cert_file
self
.
shacache_cert_file
=
shacache_cert_file
self
.
shacache_key_file
=
shacache_key_file
self
.
shacache_key_file
=
shacache_key_file
self
.
shadir_cert_file
=
shadir_cert_file
self
.
shadir_cert_file
=
shadir_cert_file
self
.
shadir_key_file
=
shadir_key_file
self
.
shadir_key_file
=
shadir_key_file
self
.
download_binary_cache_url
=
download_binary_cache_url
self
.
upload_binary_cache_url
=
upload_binary_cache_url
self
.
download_binary_dir_url
=
download_binary_dir_url
self
.
upload_binary_dir_url
=
upload_binary_dir_url
def
install
(
self
):
def
install
(
self
):
""" Fetches binary cache if possible.
Installs from buildout otherwise.
"""
tarname
=
self
.
software_url_hash
cache_dir
=
tempfile
.
mkdtemp
()
tarpath
=
os
.
path
.
join
(
cache_dir
,
tarname
)
self
.
_install_from_buildout
()
tar
=
tarfile
.
open
(
tarpath
,
"w:gz"
)
try
:
tar
.
add
(
self
.
software_path
,
arcname
=
self
.
software_url_hash
)
finally
:
tar
.
close
()
upload_network_cached
(
self
.
software_root
,
self
.
url
,
self
.
software_url_hash
,
self
.
upload_binary_cache_url
,
self
.
upload_binary_dir_url
,
tarpath
,
self
.
logger
,
self
.
signature_private_key_file
,
self
.
shacache_cert_file
,
self
.
shacache_key_file
,
self
.
shadir_cert_file
,
self
.
shadir_key_file
)
def
_install_from_buildout
(
self
):
""" Fetches buildout configuration from the server, run buildout with
""" Fetches buildout configuration from the server, run buildout with
it. If it fails, we notify the server.
it. If it fails, we notify the server.
"""
"""
...
...
slapos/grid/slapgrid.py
View file @
f0c93b97
...
@@ -204,6 +204,17 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
...
@@ -204,6 +204,17 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
if
not
option_dict
.
get
(
'supervisord_socket'
):
if
not
option_dict
.
get
(
'supervisord_socket'
):
option_dict
[
'supervisord_socket'
]
=
\
option_dict
[
'supervisord_socket'
]
=
\
os
.
path
.
join
(
option_dict
[
'instance_root'
],
'supervisord.socket'
)
os
.
path
.
join
(
option_dict
[
'instance_root'
],
'supervisord.socket'
)
signature_certificate_list_string
=
\
option_dict
.
get
(
'signature-certificate-list'
,
None
)
if
signature_certificate_list_string
is
not
None
:
cert_marker
=
"-----BEGIN CERTIFICATE-----"
signature_certificate_list
=
[
cert_marker
+
'
\
n
'
+
q
.
strip
()
\
for
q
in
signature_certificate_list_string
.
split
(
cert_marker
)
\
if
q
.
strip
()]
else
:
signature_certificate_list
=
None
# Returning new Slapgrid instance and options
# Returning new Slapgrid instance and options
return
([
Slapgrid
(
software_root
=
option_dict
[
'software_root'
],
return
([
Slapgrid
(
software_root
=
option_dict
[
'software_root'
],
instance_root
=
option_dict
[
'instance_root'
],
instance_root
=
option_dict
[
'instance_root'
],
...
@@ -218,7 +229,16 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
...
@@ -218,7 +229,16 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
master_ca_file
=
master_ca_file
,
master_ca_file
=
master_ca_file
,
certificate_repository_path
=
certificate_repository_path
,
certificate_repository_path
=
certificate_repository_path
,
signature_private_key_file
=
signature_private_key_file
,
signature_private_key_file
=
signature_private_key_file
,
signature_certificate_list
=
signature_certificate_list
,
download_binary_cache_url
=
\
option_dict
.
get
(
'download-binary-cache-url'
,
None
),
upload_binary_cache_url
=
\
option_dict
.
get
(
'upload-binary-cache-url'
,
None
),
upload_cache_url
=
option_dict
.
get
(
'upload-cache-url'
,
None
),
upload_cache_url
=
option_dict
.
get
(
'upload-cache-url'
,
None
),
download_binary_dir_url
=
\
option_dict
.
get
(
'download-binary-dir-url'
,
None
),
upload_binary_dir_url
=
\
option_dict
.
get
(
'upload-binary-dir-url'
,
None
),
upload_dir_url
=
option_dict
.
get
(
'upload-dir-url'
,
None
),
upload_dir_url
=
option_dict
.
get
(
'upload-dir-url'
,
None
),
console
=
option_dict
[
'console'
],
console
=
option_dict
[
'console'
],
buildout
=
option_dict
.
get
(
'buildout'
),
buildout
=
option_dict
.
get
(
'buildout'
),
...
@@ -299,7 +319,12 @@ class Slapgrid(object):
...
@@ -299,7 +319,12 @@ class Slapgrid(object):
key_file
=
None
,
key_file
=
None
,
cert_file
=
None
,
cert_file
=
None
,
signature_private_key_file
=
None
,
signature_private_key_file
=
None
,
signature_certificate_list
=
None
,
download_binary_cache_url
=
None
,
upload_binary_cache_url
=
None
,
upload_cache_url
=
None
,
upload_cache_url
=
None
,
download_binary_dir_url
=
None
,
upload_binary_dir_url
=
None
,
upload_dir_url
=
None
,
upload_dir_url
=
None
,
master_ca_file
=
None
,
master_ca_file
=
None
,
certificate_repository_path
=
None
,
certificate_repository_path
=
None
,
...
@@ -323,7 +348,12 @@ class Slapgrid(object):
...
@@ -323,7 +348,12 @@ class Slapgrid(object):
self
.
master_ca_file
=
master_ca_file
self
.
master_ca_file
=
master_ca_file
self
.
certificate_repository_path
=
certificate_repository_path
self
.
certificate_repository_path
=
certificate_repository_path
self
.
signature_private_key_file
=
signature_private_key_file
self
.
signature_private_key_file
=
signature_private_key_file
self
.
signature_certificate_list
=
signature_certificate_list
self
.
download_binary_cache_url
=
download_binary_cache_url
self
.
upload_binary_cache_url
=
upload_binary_cache_url
self
.
upload_cache_url
=
upload_cache_url
self
.
upload_cache_url
=
upload_cache_url
self
.
download_binary_dir_url
=
download_binary_dir_url
self
.
upload_binary_dir_url
=
upload_binary_dir_url
self
.
upload_dir_url
=
upload_dir_url
self
.
upload_dir_url
=
upload_dir_url
self
.
shacache_cert_file
=
shacache_cert_file
self
.
shacache_cert_file
=
shacache_cert_file
self
.
shacache_key_file
=
shacache_key_file
self
.
shacache_key_file
=
shacache_key_file
...
@@ -403,7 +433,12 @@ class Slapgrid(object):
...
@@ -403,7 +433,12 @@ class Slapgrid(object):
Software
(
url
=
software_release_uri
,
software_root
=
self
.
software_root
,
Software
(
url
=
software_release_uri
,
software_root
=
self
.
software_root
,
console
=
self
.
console
,
buildout
=
self
.
buildout
,
console
=
self
.
console
,
buildout
=
self
.
buildout
,
signature_private_key_file
=
self
.
signature_private_key_file
,
signature_private_key_file
=
self
.
signature_private_key_file
,
signature_certificate_list
=
self
.
signature_certificate_list
,
download_binary_cache_url
=
self
.
download_binary_cache_url
,
upload_binary_cache_url
=
self
.
upload_binary_cache_url
,
upload_cache_url
=
self
.
upload_cache_url
,
upload_cache_url
=
self
.
upload_cache_url
,
download_binary_dir_url
=
self
.
download_binary_dir_url
,
upload_binary_dir_url
=
self
.
upload_binary_dir_url
,
upload_dir_url
=
self
.
upload_dir_url
,
upload_dir_url
=
self
.
upload_dir_url
,
shacache_cert_file
=
self
.
shacache_cert_file
,
shacache_cert_file
=
self
.
shacache_cert_file
,
shacache_key_file
=
self
.
shacache_key_file
,
shacache_key_file
=
self
.
shacache_key_file
,
...
...
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