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
5d47a675
Commit
5d47a675
authored
Apr 28, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extracted merged_options()
parent
d02436db
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
34 deletions
+39
-34
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+39
-34
No files found.
slapos/grid/slapgrid.py
View file @
5d47a675
...
...
@@ -125,7 +125,7 @@ def check_missing_files(options):
raise
RuntimeError
(
'Directory %r does not exist'
%
d
)
def
parse_arguments
_merge_config
(
*
argument_tuple
):
def
parse_arguments
(
*
argument_tuple
):
"""Parse arguments and return options dictionary merged with the config file."""
ap
=
argparse
.
ArgumentParser
()
...
...
@@ -197,9 +197,11 @@ def parse_arguments_merge_config(*argument_tuple):
else
:
args
=
ap
.
parse_args
(
list
(
argument_tuple
))
return
args
def
merged_options
(
args
,
config
):
options
=
{}
config
=
ConfigParser
.
SafeConfigParser
()
config
.
readfp
(
args
.
configuration_file
)
options
=
dict
(
config
.
items
(
'slapos'
))
if
config
.
has_section
(
'networkcache'
):
...
...
@@ -208,6 +210,34 @@ def parse_arguments_merge_config(*argument_tuple):
if
value
is
not
None
:
options
[
key
]
=
value
if
options
.
get
(
'all'
):
options
[
'develop'
]
=
True
if
options
.
get
(
'maximum_periodicity'
)
is
not
None
:
options
[
'force_periodicity'
]
=
True
# Supervisord configuration location
if
not
options
.
get
(
'supervisord_configuration_path'
):
options
[
'supervisord_configuration_path'
]
=
\
os
.
path
.
join
(
options
[
'instance_root'
],
'etc'
,
'supervisord.conf'
)
# Supervisord socket
if
not
options
.
get
(
'supervisord_socket'
):
options
[
'supervisord_socket'
]
=
\
os
.
path
.
join
(
options
[
'instance_root'
],
'supervisord.socket'
)
# Parse cache / binary cache options
# Backward compatibility about "binary-cache-url-blacklist" deprecated option
if
options
.
get
(
"binary-cache-url-blacklist"
)
and
not
\
options
.
get
(
"download-from-binary-cache-url-blacklist"
):
options
[
"download-from-binary-cache-url-blacklist"
]
=
\
options
[
"binary-cache-url-blacklist"
]
options
[
"download-from-binary-cache-url-blacklist"
]
=
[
url
.
strip
()
for
url
in
options
.
get
(
"download-from-binary-cache-url-blacklist"
,
""
).
split
(
'
\
n
'
)
if
url
]
options
[
"upload-to-binary-cache-url-blacklist"
]
=
[
url
.
strip
()
for
url
in
options
.
get
(
"upload-to-binary-cache-url-blacklist"
,
""
).
split
(
'
\
n
'
)
if
url
]
return
options
...
...
@@ -247,46 +277,22 @@ def random_delay(options, logger):
time
.
sleep
(
duration
)
def
parseArgumentTupleAndReturnSlapgridObject
(
*
argument_tuple
):
"""Returns a new instance of slapgrid.Slapgrid created with argument+config parameters.
Also returns the pidfile path, and configures logger.
"""
options
=
parse_arguments_merge_config
(
*
argument_tuple
)
args
=
parse_arguments
(
*
argument_tuple
)
config
=
ConfigParser
.
SafeConfigParser
()
config
.
readfp
(
args
.
configuration_file
)
options
=
merged_options
(
args
,
config
)
logger
=
setup_logger
(
options
)
check_missing_parameters
(
options
)
check_missing_files
(
options
)
if
options
.
get
(
'all'
):
options
[
'develop'
]
=
True
if
options
.
get
(
'maximum_periodicity'
)
is
not
None
:
options
[
'force_periodicity'
]
=
True
# Supervisord configuration location
if
not
options
.
get
(
'supervisord_configuration_path'
):
options
[
'supervisord_configuration_path'
]
=
\
os
.
path
.
join
(
options
[
'instance_root'
],
'etc'
,
'supervisord.conf'
)
# Supervisord socket
if
not
options
.
get
(
'supervisord_socket'
):
options
[
'supervisord_socket'
]
=
\
os
.
path
.
join
(
options
[
'instance_root'
],
'supervisord.socket'
)
# Parse cache / binary cache options
# Backward compatibility about "binary-cache-url-blacklist" deprecated option
if
options
.
get
(
"binary-cache-url-blacklist"
)
and
not
\
options
.
get
(
"download-from-binary-cache-url-blacklist"
):
options
[
"download-from-binary-cache-url-blacklist"
]
=
\
options
[
"binary-cache-url-blacklist"
]
options
[
"download-from-binary-cache-url-blacklist"
]
=
[
url
.
strip
()
for
url
in
options
.
get
(
"download-from-binary-cache-url-blacklist"
,
""
).
split
(
'
\
n
'
)
if
url
]
options
[
"upload-to-binary-cache-url-blacklist"
]
=
[
url
.
strip
()
for
url
in
options
.
get
(
"upload-to-binary-cache-url-blacklist"
,
""
).
split
(
'
\
n
'
)
if
url
]
random_delay
(
options
,
logger
=
logger
)
slapgrid_object
=
create_slapgrid_object
(
options
,
logger
=
logger
)
...
...
@@ -294,7 +300,6 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
return
slapgrid_object
,
options
.
get
(
'pidfile'
)
def
create_slapgrid_object
(
options
,
logger
):
signature_certificate_list
=
None
if
'signature-certificate-list'
in
options
:
...
...
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