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
Boxiang Sun
slapos.core
Commits
65e35e46
Commit
65e35e46
authored
Apr 25, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
option_dict -> options
parent
f6d39f7d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
70 deletions
+70
-70
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+70
-70
No files found.
slapos/grid/slapgrid.py
View file @
65e35e46
...
...
@@ -161,29 +161,29 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
else
:
argument_option_instance
=
parser
.
parse_args
(
list
(
argument_tuple
))
# Parses arguments from config file, if needed, then merge previous arguments
option
_dict
=
{}
option
s
=
{}
configuration_file
=
argument_option_instance
.
configuration_file
[
0
]
# Loads config (if config specified)
slapgrid_configuration
=
ConfigParser
.
SafeConfigParser
()
slapgrid_configuration
.
readfp
(
configuration_file
)
# Merges the two dictionnaries
option
_dict
=
dict
(
slapgrid_configuration
.
items
(
"slapos"
))
option
s
=
dict
(
slapgrid_configuration
.
items
(
"slapos"
))
if
slapgrid_configuration
.
has_section
(
"networkcache"
):
option
_dict
.
update
(
dict
(
slapgrid_configuration
.
items
(
"networkcache"
)))
option
s
.
update
(
dict
(
slapgrid_configuration
.
items
(
"networkcache"
)))
for
argument_key
,
argument_value
in
vars
(
argument_option_instance
).
iteritems
():
if
argument_value
is
not
None
:
option
_dict
.
update
({
argument_key
:
argument_value
})
option
s
.
update
({
argument_key
:
argument_value
})
# Configures logger.
if
option
_dict
[
'verbose'
]:
if
option
s
[
'verbose'
]:
level
=
logging
.
DEBUG
else
:
level
=
logging
.
INFO
logging
.
basicConfig
(
format
=
'%(asctime)s %(levelname)-8s %(message)s'
,
level
=
level
,
datefmt
=
'%Y-%m-%dT%H:%M:%S'
)
if
option
_dict
.
get
(
'logfile'
):
console
=
logging
.
FileHandler
(
option
_dict
[
'logfile'
])
if
option
s
.
get
(
'logfile'
):
console
=
logging
.
FileHandler
(
option
s
[
'logfile'
])
console
.
setLevel
(
level
)
console
.
setFormatter
(
logging
.
Formatter
(
'%(asctime)s %(name)-18s: %(levelname)-8s %(message)s'
))
...
...
@@ -191,36 +191,36 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
missing_mandatory_parameter_list
=
[]
for
mandatory_parameter
in
MANDATORY_PARAMETER_LIST
:
if
not
mandatory_parameter
in
option
_dict
:
if
not
mandatory_parameter
in
option
s
:
missing_mandatory_parameter_list
.
append
(
mandatory_parameter
)
if
option
_dict
.
get
(
'all'
)
is
True
:
option
_dict
[
'develop'
]
=
True
if
option
s
.
get
(
'all'
)
is
True
:
option
s
[
'develop'
]
=
True
if
option
_dict
.
get
(
'maximum_periodicity'
)
is
not
None
:
option
_dict
[
'force_periodicity'
]
=
True
if
option
s
.
get
(
'maximum_periodicity'
)
is
not
None
:
option
s
[
'force_periodicity'
]
=
True
repository_required
=
False
if
'key_file'
in
option
_dict
:
if
'key_file'
in
option
s
:
repository_required
=
True
if
not
'cert_file'
in
option
_dict
:
if
not
'cert_file'
in
option
s
:
missing_mandatory_parameter_list
.
append
(
'cert_file'
)
if
'cert_file'
in
option
_dict
:
if
'cert_file'
in
option
s
:
repository_required
=
True
if
not
'key_file'
in
option
_dict
:
if
not
'key_file'
in
option
s
:
missing_mandatory_parameter_list
.
append
(
'key_file'
)
if
repository_required
:
if
'certificate_repository_path'
not
in
option
_dict
:
if
'certificate_repository_path'
not
in
option
s
:
missing_mandatory_parameter_list
.
append
(
'certificate_repository_path'
)
if
len
(
missing_mandatory_parameter_list
)
>
0
:
parser
.
error
(
'Missing mandatory parameters:
\
n
%s'
%
'
\
n
'
.
join
(
missing_mandatory_parameter_list
))
key_file
=
option
_dict
.
get
(
'key_file'
)
cert_file
=
option
_dict
.
get
(
'cert_file'
)
master_ca_file
=
option
_dict
.
get
(
'master_ca_file'
)
signature_private_key_file
=
option
_dict
.
get
(
'signature_private_key_file'
)
key_file
=
option
s
.
get
(
'key_file'
)
cert_file
=
option
s
.
get
(
'cert_file'
)
master_ca_file
=
option
s
.
get
(
'master_ca_file'
)
signature_private_key_file
=
option
s
.
get
(
'signature_private_key_file'
)
mandatory_file_list
=
[
key_file
,
cert_file
,
master_ca_file
]
# signature_private_key_file is not mandatory, we must be able to run
...
...
@@ -230,29 +230,29 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
for
k
in
[
'shacache-cert-file'
,
'shacache-key-file'
,
'shadir-cert-file'
,
'shadir-key-file'
]:
mandatory_file_list
.
append
(
option
_dict
.
get
(
k
,
None
))
mandatory_file_list
.
append
(
option
s
.
get
(
k
,
None
))
for
f
in
mandatory_file_list
:
if
f
is
not
None
:
if
not
os
.
path
.
exists
(
f
):
parser
.
error
(
'File %r does not exist.'
%
f
)
certificate_repository_path
=
option
_dict
.
get
(
'certificate_repository_path'
)
certificate_repository_path
=
option
s
.
get
(
'certificate_repository_path'
)
if
certificate_repository_path
is
not
None
:
if
not
os
.
path
.
isdir
(
certificate_repository_path
):
parser
.
error
(
'Directory %r does not exist'
%
certificate_repository_path
)
# Supervisord configuration location
if
not
option
_dict
.
get
(
'supervisord_configuration_path'
):
option
_dict
[
'supervisord_configuration_path'
]
=
\
os
.
path
.
join
(
option
_dict
[
'instance_root'
],
'etc'
,
'supervisord.conf'
)
if
not
option
s
.
get
(
'supervisord_configuration_path'
):
option
s
[
'supervisord_configuration_path'
]
=
\
os
.
path
.
join
(
option
s
[
'instance_root'
],
'etc'
,
'supervisord.conf'
)
# Supervisord socket
if
not
option
_dict
.
get
(
'supervisord_socket'
):
option
_dict
[
'supervisord_socket'
]
=
\
os
.
path
.
join
(
option
_dict
[
'instance_root'
],
'supervisord.socket'
)
if
not
option
s
.
get
(
'supervisord_socket'
):
option
s
[
'supervisord_socket'
]
=
\
os
.
path
.
join
(
option
s
[
'instance_root'
],
'supervisord.socket'
)
signature_certificate_list_string
=
\
option
_dict
.
get
(
'signature-certificate-list'
,
None
)
option
s
.
get
(
'signature-certificate-list'
,
None
)
if
signature_certificate_list_string
is
not
None
:
cert_marker
=
"-----BEGIN CERTIFICATE-----"
signature_certificate_list
=
[
...
...
@@ -265,24 +265,24 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
# Parse cache / binary cache options
# Backward compatibility about "binary-cache-url-blacklist" deprecated option
if
option
_dict
.
get
(
"binary-cache-url-blacklist"
)
and
not
\
option
_dict
.
get
(
"download-from-binary-cache-url-blacklist"
):
option
_dict
[
"download-from-binary-cache-url-blacklist"
]
=
\
option
_dict
[
"binary-cache-url-blacklist"
]
option
_dict
[
"download-from-binary-cache-url-blacklist"
]
=
[
url
.
strip
()
for
url
in
option
_dict
.
get
(
if
option
s
.
get
(
"binary-cache-url-blacklist"
)
and
not
\
option
s
.
get
(
"download-from-binary-cache-url-blacklist"
):
option
s
[
"download-from-binary-cache-url-blacklist"
]
=
\
option
s
[
"binary-cache-url-blacklist"
]
option
s
[
"download-from-binary-cache-url-blacklist"
]
=
[
url
.
strip
()
for
url
in
option
s
.
get
(
"download-from-binary-cache-url-blacklist"
,
""
).
split
(
'
\
n
'
)
if
url
]
option
_dict
[
"upload-to-binary-cache-url-blacklist"
]
=
[
url
.
strip
()
for
url
in
option
_dict
.
get
(
option
s
[
"upload-to-binary-cache-url-blacklist"
]
=
[
url
.
strip
()
for
url
in
option
s
.
get
(
"upload-to-binary-cache-url-blacklist"
,
""
).
split
(
'
\
n
'
)
if
url
]
# Sleep for a random time to avoid SlapOS Master being DDOSed by an army of
# SlapOS Nodes configured with cron.
if
option
_dict
[
"now"
]:
if
option
s
[
"now"
]:
# XXX-Cedric: deprecate "--now"
maximal_delay
=
0
else
:
maximal_delay
=
int
(
option
_dict
.
get
(
"maximal_delay"
,
"0"
))
maximal_delay
=
int
(
option
s
.
get
(
"maximal_delay"
,
"0"
))
if
maximal_delay
>
0
:
duration
=
random
.
randint
(
1
,
maximal_delay
)
logging
.
info
(
"Sleeping for %s seconds. To disable this feature, "
\
...
...
@@ -290,12 +290,12 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
time
.
sleep
(
duration
)
# Return new Slapgrid instance and options
return
([
Slapgrid
(
software_root
=
option
_dict
[
'software_root'
],
instance_root
=
option
_dict
[
'instance_root'
],
master_url
=
option
_dict
[
'master_url'
],
computer_id
=
option
_dict
[
'computer_id'
],
supervisord_socket
=
option
_dict
[
'supervisord_socket'
],
supervisord_configuration_path
=
option
_dict
[
return
([
Slapgrid
(
software_root
=
option
s
[
'software_root'
],
instance_root
=
option
s
[
'instance_root'
],
master_url
=
option
s
[
'master_url'
],
computer_id
=
option
s
[
'computer_id'
],
supervisord_socket
=
option
s
[
'supervisord_socket'
],
supervisord_configuration_path
=
option
s
[
'supervisord_configuration_path'
],
key_file
=
key_file
,
cert_file
=
cert_file
,
...
...
@@ -304,42 +304,42 @@ def parseArgumentTupleAndReturnSlapgridObject(*argument_tuple):
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
),
option
s
.
get
(
'download-binary-cache-url'
,
None
),
upload_binary_cache_url
=
\
option
_dict
.
get
(
'upload-binary-cache-url'
,
None
),
option
s
.
get
(
'upload-binary-cache-url'
,
None
),
download_from_binary_cache_url_blacklist
=
\
option
_dict
.
get
(
'download-from-binary-cache-url-blacklist'
,
[]),
option
s
.
get
(
'download-from-binary-cache-url-blacklist'
,
[]),
upload_to_binary_cache_url_blacklist
=
\
option
_dict
.
get
(
'upload-to-binary-cache-url-blacklist'
,
[]),
upload_cache_url
=
option
_dict
.
get
(
'upload-cache-url'
,
None
),
option
s
.
get
(
'upload-to-binary-cache-url-blacklist'
,
[]),
upload_cache_url
=
option
s
.
get
(
'upload-cache-url'
,
None
),
download_binary_dir_url
=
\
option
_dict
.
get
(
'download-binary-dir-url'
,
None
),
option
s
.
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
),
buildout
=
option
_dict
.
get
(
'buildout'
),
promise_timeout
=
option
_dict
[
'promise_timeout'
],
shacache_cert_file
=
option
_dict
.
get
(
'shacache-cert-file'
,
None
),
shacache_key_file
=
option
_dict
.
get
(
'shacache-key-file'
,
None
),
shadir_cert_file
=
option
_dict
.
get
(
'shadir-cert-file'
,
None
),
shadir_key_file
=
option
_dict
.
get
(
'shadir-key-file'
,
None
),
develop
=
option
_dict
.
get
(
'develop'
,
False
),
software_release_filter_list
=
option
_dict
.
get
(
'only-sr'
,
option
s
.
get
(
'upload-binary-dir-url'
,
None
),
upload_dir_url
=
option
s
.
get
(
'upload-dir-url'
,
None
),
buildout
=
option
s
.
get
(
'buildout'
),
promise_timeout
=
option
s
[
'promise_timeout'
],
shacache_cert_file
=
option
s
.
get
(
'shacache-cert-file'
,
None
),
shacache_key_file
=
option
s
.
get
(
'shacache-key-file'
,
None
),
shadir_cert_file
=
option
s
.
get
(
'shadir-cert-file'
,
None
),
shadir_key_file
=
option
s
.
get
(
'shadir-key-file'
,
None
),
develop
=
option
s
.
get
(
'develop'
,
False
),
software_release_filter_list
=
option
s
.
get
(
'only-sr'
,
# Try to fetch from deprecated argument
option
_dict
.
get
(
'only_sr'
,
None
)),
computer_partition_filter_list
=
option
_dict
.
get
(
'only-cp'
,
option
s
.
get
(
'only_sr'
,
None
)),
computer_partition_filter_list
=
option
s
.
get
(
'only-cp'
,
# Try to fetch from deprecated argument
option
_dict
.
get
(
'only_cp'
,
None
)),
force_periodicity
=
option
_dict
.
get
(
'force_periodicity'
,
False
),
maximum_periodicity
=
option
_dict
.
get
(
'maximum_periodicity'
,
86400
),
option
s
.
get
(
'only_cp'
,
None
)),
force_periodicity
=
option
s
.
get
(
'force_periodicity'
,
False
),
maximum_periodicity
=
option
s
.
get
(
'maximum_periodicity'
,
86400
),
),
option
_dict
])
option
s
])
def
realRun
(
argument_tuple
,
method_list
):
slapgrid_object
,
option
_dict
=
\
slapgrid_object
,
option
s
=
\
parseArgumentTupleAndReturnSlapgridObject
(
*
argument_tuple
)
pidfile
=
option
_dict
.
get
(
'pidfile'
)
pidfile
=
option
s
.
get
(
'pidfile'
)
if
pidfile
:
setRunning
(
pidfile
)
try
:
...
...
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