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
Labels
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Rafael Monnerat
slapos.core
Commits
d1942fda
Commit
d1942fda
authored
Apr 25, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bring out create_slapgrid_object()
parent
1bd27f3a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
74 deletions
+64
-74
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+64
-74
No files found.
slapos/grid/slapgrid.py
View file @
d1942fda
...
@@ -126,8 +126,7 @@ def check_missing_files(options):
...
@@ -126,8 +126,7 @@ def check_missing_files(options):
def
parse_arguments_merge_config
(
*
argument_tuple
):
def
parse_arguments_merge_config
(
*
argument_tuple
):
"""Parse arguments and return options dictionary
"""Parse arguments and return options dictionary merged with the config file."""
merged with the config file."""
ap
=
argparse
.
ArgumentParser
()
ap
=
argparse
.
ArgumentParser
()
ap
.
add_argument
(
'--instance-root'
,
ap
.
add_argument
(
'--instance-root'
,
...
@@ -173,7 +172,7 @@ def parse_arguments_merge_config(*argument_tuple):
...
@@ -173,7 +172,7 @@ def parse_arguments_merge_config(*argument_tuple):
help
=
'Force the update of a single software release (use url hash), '
help
=
'Force the update of a single software release (use url hash), '
'even if is already installed. This option will make all others '
'even if is already installed. This option will make all others '
'sofware releases be ignored.'
)
'sofware releases be ignored.'
)
ap
.
add_argument
(
"--only-cp"
,
ap
.
add_argument
(
'--only-cp'
,
help
=
'Update a single or a list of computer partitions '
help
=
'Update a single or a list of computer partitions '
'(ie.:slappartX, slappartY), '
'(ie.:slappartX, slappartY), '
'this option will make all others computer partitions be ignored.'
)
'this option will make all others computer partitions be ignored.'
)
...
@@ -213,7 +212,6 @@ def parse_arguments_merge_config(*argument_tuple):
...
@@ -213,7 +212,6 @@ def parse_arguments_merge_config(*argument_tuple):
def
setup_logger
(
options
):
def
setup_logger
(
options
):
# Configures logger.
if
options
[
'verbose'
]:
if
options
[
'verbose'
]:
level
=
logging
.
DEBUG
level
=
logging
.
DEBUG
else
:
else
:
...
@@ -237,22 +235,22 @@ def random_delay(options):
...
@@ -237,22 +235,22 @@ def random_delay(options):
Sleep for a random time to avoid SlapOS Master being DDOSed by an army of
Sleep for a random time to avoid SlapOS Master being DDOSed by an army of
SlapOS Nodes configured with cron.
SlapOS Nodes configured with cron.
"""
"""
if
options
[
"now"
]:
if
options
[
'now'
]:
# XXX-Cedric: deprecate
"--now"
# XXX-Cedric: deprecate
'--now'
return
return
maximal_delay
=
int
(
options
.
get
(
"maximal_delay"
,
"0"
))
maximal_delay
=
int
(
options
.
get
(
'maximal_delay'
,
'0'
))
if
maximal_delay
:
if
maximal_delay
:
duration
=
random
.
randint
(
1
,
maximal_delay
)
duration
=
random
.
randint
(
1
,
maximal_delay
)
logging
.
info
(
"Sleeping for %s seconds. To disable this feature, "
\
logging
.
info
(
'Sleeping for %s seconds. To disable this feature, '
\
"check --now parameter in slapgrid help."
%
duration
)
'check --now parameter in slapgrid help.'
%
duration
)
time
.
sleep
(
duration
)
time
.
sleep
(
duration
)
def
parseArgumentTupleAndReturnSlapgridObject
(
*
argument_tuple
):
def
parseArgumentTupleAndReturnSlapgridObject
(
*
argument_tuple
):
"""Returns a new instance of slapgrid.Slapgrid created with argument+config parameters.
"""Returns a new instance of slapgrid.Slapgrid created with argument+config parameters.
Also returns the
options dict and unused variable list
, and configures logger.
Also returns the
pidfile path
, and configures logger.
"""
"""
options
=
parse_arguments_merge_config
(
*
argument_tuple
)
options
=
parse_arguments_merge_config
(
*
argument_tuple
)
...
@@ -276,18 +274,6 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
...
@@ -276,18 +274,6 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
options
[
'supervisord_socket'
]
=
\
options
[
'supervisord_socket'
]
=
\
os
.
path
.
join
(
options
[
'instance_root'
],
'supervisord.socket'
)
os
.
path
.
join
(
options
[
'instance_root'
],
'supervisord.socket'
)
signature_certificate_list_string
=
\
options
.
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
# Parse cache / binary cache options
# Parse cache / binary cache options
# Backward compatibility about "binary-cache-url-blacklist" deprecated option
# Backward compatibility about "binary-cache-url-blacklist" deprecated option
if
options
.
get
(
"binary-cache-url-blacklist"
)
and
not
\
if
options
.
get
(
"binary-cache-url-blacklist"
)
and
not
\
...
@@ -303,55 +289,62 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
...
@@ -303,55 +289,62 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
random_delay
(
options
)
random_delay
(
options
)
# Return new Slapgrid instance and options
slapgrid_object
=
create_slapgrid_object
(
options
)
return
([
Slapgrid
(
software_root
=
options
[
'software_root'
],
instance_root
=
options
[
'instance_root'
],
return
slapgrid_object
,
options
.
get
(
'pidfile'
)
master_url
=
options
[
'master_url'
],
computer_id
=
options
[
'computer_id'
],
supervisord_socket
=
options
[
'supervisord_socket'
],
supervisord_configuration_path
=
options
[
def
create_slapgrid_object
(
options
):
'supervisord_configuration_path'
],
signature_certificate_list
=
None
key_file
=
options
.
get
(
'key_file'
),
if
'signature-certificate-list'
in
options
:
cert_file
=
options
.
get
(
'cert_file'
),
cert_marker
=
'-----BEGIN CERTIFICATE-----'
master_ca_file
=
options
.
get
(
'master_ca_file'
),
signature_certificate_list
=
[
certificate_repository_path
=
options
.
get
(
'certificate_repository_path'
),
cert_marker
+
'
\
n
'
+
q
.
strip
()
signature_private_key_file
=
options
.
get
(
'signature_private_key_file'
),
for
q
in
options
[
'signature-certificate-list'
].
split
(
cert_marker
)
signature_certificate_list
=
signature_certificate_list
,
if
q
.
strip
()
download_binary_cache_url
=
\
]
options
.
get
(
'download-binary-cache-url'
,
None
),
upload_binary_cache_url
=
\
op
=
options
options
.
get
(
'upload-binary-cache-url'
,
None
),
return
Slapgrid
(
software_root
=
op
[
'software_root'
],
download_from_binary_cache_url_blacklist
=
\
instance_root
=
op
[
'instance_root'
],
options
.
get
(
'download-from-binary-cache-url-blacklist'
,
[]),
master_url
=
op
[
'master_url'
],
upload_to_binary_cache_url_blacklist
=
\
computer_id
=
op
[
'computer_id'
],
options
.
get
(
'upload-to-binary-cache-url-blacklist'
,
[]),
supervisord_socket
=
op
[
'supervisord_socket'
],
upload_cache_url
=
options
.
get
(
'upload-cache-url'
,
None
),
supervisord_configuration_path
=
op
[
'supervisord_configuration_path'
],
download_binary_dir_url
=
\
key_file
=
op
.
get
(
'key_file'
),
options
.
get
(
'download-binary-dir-url'
,
None
),
cert_file
=
op
.
get
(
'cert_file'
),
upload_binary_dir_url
=
\
master_ca_file
=
op
.
get
(
'master_ca_file'
),
options
.
get
(
'upload-binary-dir-url'
,
None
),
certificate_repository_path
=
op
.
get
(
'certificate_repository_path'
),
upload_dir_url
=
options
.
get
(
'upload-dir-url'
,
None
),
signature_private_key_file
=
op
.
get
(
'signature_private_key_file'
),
buildout
=
options
.
get
(
'buildout'
),
signature_certificate_list
=
signature_certificate_list
,
promise_timeout
=
options
[
'promise_timeout'
],
download_binary_cache_url
=
op
.
get
(
'download-binary-cache-url'
),
shacache_cert_file
=
options
.
get
(
'shacache-cert-file'
,
None
),
upload_binary_cache_url
=
op
.
get
(
'upload-binary-cache-url'
),
shacache_key_file
=
options
.
get
(
'shacache-key-file'
,
None
),
download_from_binary_cache_url_blacklist
=
\
shadir_cert_file
=
options
.
get
(
'shadir-cert-file'
,
None
),
op
.
get
(
'download-from-binary-cache-url-blacklist'
,
[]),
shadir_key_file
=
options
.
get
(
'shadir-key-file'
,
None
),
upload_to_binary_cache_url_blacklist
=
\
develop
=
options
.
get
(
'develop'
,
False
),
op
.
get
(
'upload-to-binary-cache-url-blacklist'
,
[]),
# Try to fetch from deprecated argument
upload_cache_url
=
op
.
get
(
'upload-cache-url'
),
software_release_filter_list
=
options
.
get
(
'only-sr'
,
options
.
get
(
'only_sr'
,
None
)),
download_binary_dir_url
=
op
.
get
(
'download-binary-dir-url'
),
# Try to fetch from deprecated argument
upload_binary_dir_url
=
op
.
get
(
'upload-binary-dir-url'
),
computer_partition_filter_list
=
options
.
get
(
'only-cp'
,
options
.
get
(
'only_cp'
,
None
)),
upload_dir_url
=
op
.
get
(
'upload-dir-url'
),
force_periodicity
=
options
.
get
(
'force_periodicity'
,
False
),
buildout
=
op
.
get
(
'buildout'
),
maximum_periodicity
=
options
.
get
(
'maximum_periodicity'
,
86400
),
promise_timeout
=
op
[
'promise_timeout'
],
),
shacache_cert_file
=
op
.
get
(
'shacache-cert-file'
),
options
])
shacache_key_file
=
op
.
get
(
'shacache-key-file'
),
shadir_cert_file
=
op
.
get
(
'shadir-cert-file'
),
shadir_key_file
=
op
.
get
(
'shadir-key-file'
),
develop
=
op
.
get
(
'develop'
,
False
),
# Try to fetch from deprecated argument
software_release_filter_list
=
op
.
get
(
'only-sr'
,
op
.
get
(
'only_sr'
)),
# Try to fetch from deprecated argument
computer_partition_filter_list
=
op
.
get
(
'only-cp'
,
op
.
get
(
'only_cp'
)),
force_periodicity
=
op
.
get
(
'force_periodicity'
,
False
),
maximum_periodicity
=
op
.
get
(
'maximum_periodicity'
,
86400
))
def
realRun
(
argument_tuple
,
method
):
def
realRun
(
argument_tuple
,
method
):
slapgrid_object
,
options
=
\
slapgrid_object
,
pidfile
=
parseArgumentTupleAndReturnSlapgridObject
(
*
argument_tuple
)
parseArgumentTupleAndReturnSlapgridObject
(
*
argument_tuple
)
pidfile
=
options
.
get
(
'pidfile'
)
if
pidfile
:
if
pidfile
:
setRunning
(
pidfile
)
setRunning
(
pidfile
)
try
:
try
:
...
@@ -374,20 +367,17 @@ def realRun(argument_tuple, method):
...
@@ -374,20 +367,17 @@ def realRun(argument_tuple, method):
def
runSoftwareRelease
(
*
argument_tuple
):
def
runSoftwareRelease
(
*
argument_tuple
):
"""Hook for entry point to process Software Releases only
"""Hook for entry point to process Software Releases"""
"""
realRun
(
argument_tuple
,
'processSoftwareReleaseList'
)
realRun
(
argument_tuple
,
'processSoftwareReleaseList'
)
def
runComputerPartition
(
*
argument_tuple
):
def
runComputerPartition
(
*
argument_tuple
):
"""Hook for entry point to process Computer Partitions only
"""Hook for entry point to process Computer Partitions"""
"""
realRun
(
argument_tuple
,
'processComputerPartitionList'
)
realRun
(
argument_tuple
,
'processComputerPartitionList'
)
def
runUsageReport
(
*
argument_tuple
):
def
runUsageReport
(
*
argument_tuple
):
"""Hook for entry point to process Usage Reports only
"""Hook for entry point to process Usage Reports"""
"""
realRun
(
argument_tuple
,
'agregateAndSendUsage'
)
realRun
(
argument_tuple
,
'agregateAndSendUsage'
)
...
...
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