Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.package
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
Romain Courteaud
slapos.package
Commits
fcf77495
Commit
fcf77495
authored
Aug 28, 2012
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Your cron file is to be perfect from now on
parent
c111ebbd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
35 deletions
+40
-35
slapos-node/slaptest
slapos-node/slaptest
+40
-35
No files found.
slapos-node/slaptest
View file @
fcf77495
...
@@ -208,45 +208,50 @@ def slapos_conf_check (config):
...
@@ -208,45 +208,50 @@ def slapos_conf_check (config):
check_networkcache
(
config
,
logger
,
configuration_parser
)
check_networkcache
(
config
,
logger
,
configuration_parser
)
class
Cron
Lin
e
:
class
Cron
Fil
e
:
"""
"""
Class to analyse each cron line individualy
Class to analyse each cron line individualy
"""
"""
def
__init__
(
self
):
def
__init__
(
self
):
""" Init all value to None"""
""" Init all values"""
self
.
command
=
None
self
.
slapformat
=
-
1
self
.
pidfile
=
None
self
.
slapgrid_cp
=
-
1
self
.
logfile
=
None
self
.
slapgrid_ur
=
-
1
self
.
config
=
None
self
.
slapgrid_sr
=
-
1
# cron file from slapos documentation
self
.
slapgrid_sr_base
=
"""*/5 * * * * root /opt/slapos/bin/slapgrid-sr --logfile=/opt/slapos/slapgrid-sr.log --pidfile=/opt/slapos/slapgrid-sr.pid /etc/opt/slapos/slapos.cfg >> /opt/slapos/slapgrid-sr.log 2>&1"""
self
.
slapgrid_cp_base
=
"""*/5 * * * * root /opt/slapos/bin/slapgrid-cp --logfile=/opt/slapos/slapgrid-cp.log --pidfile=/opt/slapos/slapgrid-cp.pid /etc/opt/slapos/slapos.cfg >> /opt/slapos/slapgrid-cp.log 2>&1"""
self
.
slapgrid_ur_base
=
"""0 0 * * * root /opt/slapos/bin/slapgrid-ur --logfile=/opt/slapos/slapgrid-ur.log --pidfile=/opt/slapos/slapgrid-ur.pid /etc/opt/slapos/slapos.cfg >> /opt/slapos/slapgrid-ur.log 2>&1"""
self
.
slapformat_base
=
"""0 0 * * * root /opt/slapos/bin/slapformat --log_file=/opt/slapos/slapformat.log -c /etc/opt/slapos/slapos.cfg >> /opt/slapos/slapformat.log 2>&1"""
def
parse
(
self
,
cron_line
):
def
parse
(
self
,
cron_line
):
""" Parse cron line and give value to attributes """
""" Parse cron line and give value to attributes """
line
=
cron_line
.
split
()
line
=
cron_line
.
split
()
self
.
command
=
line
[
6
]
command
=
line
[
6
]
for
word
in
line
:
if
"slapformat"
in
command
:
self
.
slapformat
=
self
.
compare
(
self
.
slapformat_base
.
split
()
,
line
)
if
"slapos.cfg"
in
word
:
if
"slapgrid-ur"
in
command
:
self
.
slapgrid_ur
=
self
.
compare
(
self
.
slapgrid_ur_base
.
split
()
,
line
)
self
.
config
=
word
if
"slapgrid-cp"
in
command
:
self
.
slapgrid_cp
=
self
.
compare
(
self
.
slapgrid_cp_base
.
split
()
,
line
)
if
"--pidfile"
in
word
:
if
"slapgrid-sr"
in
command
:
self
.
slapgrid_sr
=
self
.
compare
(
self
.
slapgrid_sr_base
.
split
()
,
line
)
self
.
pidfile
=
word
[
word
.
find
(
"="
)
+
1
:]
if
"--log_file"
in
word
and
"format"
in
self
.
command
:
def
compare
(
self
,
reference
,
cron_line
)
:
self
.
logfile
=
word
[
word
.
find
(
"="
)
+
1
:]
for
i
in
range
(
0
,
6
):
if
"--logfile"
in
word
and
not
"format"
in
self
.
command
:
if
not
reference
[
i
]
==
cron_line
[
i
]
:
self
.
logfile
=
word
[
word
.
find
(
"="
)
+
1
:]
return
0
ref
=
len
(
reference
[
6
:])
def
check
(
self
,
config
,
logger
)
:
if
not
len
(
set
(
reference
[
6
:])
&
set
(
cron_line
[
6
:]))
==
ref
:
""" Check if all attributes are correctly set"""
return
0
if
not
os
.
path
.
exists
(
self
.
config
):
else
:
return
1
logger
.
critical
(
"For %s command: slapos.cfg is %s should be in %s"
%
(
self
.
command
,
self
.
config
,
config
.
slapos_configuration
))
def
check
(
self
,
logger
):
el
if
not
os
.
path
.
samefile
(
self
.
config
,
os
.
path
.
join
(
config
.
slapos_configuration
,
'slapos.cfg'
)):
el
ements
=
{
"slapformat"
:
self
.
slapformat
,
"slapgrid-ur"
:
self
.
slapgrid_ur
,
logger
.
critical
(
"For %s command: slapos.cfg is %s should be in %s"
"slapgrid-sr"
:
self
.
slapgrid_sr
,
"slapgrid-cp"
:
self
.
slapgrid_cp
}
%
(
self
.
command
,
self
.
config
,
config
.
slapos_configuration
))
for
key
in
elements
:
if
self
.
pidfile
==
None
:
if
elements
[
key
]
==
0
:
logger
.
warning
(
"For %s command: No pidfile"
logger
.
error
(
"Your line for %s command does not seem right"
%
key
)
%
(
self
.
command
))
elif
elements
[
key
]
==
-
1
:
if
self
.
logfile
==
None
:
logger
.
error
(
"No line found for %s command"
%
key
)
logger
.
warning
(
"For %s command: No logfile"
elif
elements
[
key
]
==
1
:
%
(
self
.
command
)
)
logger
.
info
(
"Line for %s command is good"
%
key
)
def
cron_check
(
config
):
def
cron_check
(
config
):
...
@@ -257,12 +262,12 @@ def cron_check (config):
...
@@ -257,12 +262,12 @@ def cron_check (config):
logger
=
logging
.
getLogger
(
'Checking slapos-node cron file:'
)
logger
=
logging
.
getLogger
(
'Checking slapos-node cron file:'
)
logger
.
setLevel
(
logging
.
INFO
)
logger
.
setLevel
(
logging
.
INFO
)
logger
.
addHandler
(
ch
)
logger
.
addHandler
(
ch
)
cron
=
open
(
config
.
slapos_cron
,
"r"
)
cron
=
open
(
config
.
slapos_cron
,
"r"
)
cron_file
=
CronFile
()
for
line
in
cron
:
for
line
in
cron
:
if
"/opt/slapos"
in
line
and
not
line
[
0
]
==
"#"
:
if
"/opt/slapos"
in
line
and
not
line
[
0
]
==
"#"
:
cron_line
=
CronLine
()
cron_file
.
parse
(
line
)
cron_line
.
parse
(
line
)
cron_file
.
check
(
logger
)
cron_line
.
check
(
config
,
logger
)
def
slapos_global_check
(
config
):
def
slapos_global_check
(
config
):
"""
"""
...
...
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