Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
105
Merge Requests
105
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos
Commits
13e05252
Commit
13e05252
authored
Oct 24, 2012
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use createWrapper() for dcron/notifier/pbs
parent
85559fce
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
56 deletions
+56
-56
slapos/recipe/dcron.py
slapos/recipe/dcron.py
+11
-15
slapos/recipe/notifier.py
slapos/recipe/notifier.py
+39
-34
slapos/recipe/pbs.py
slapos/recipe/pbs.py
+6
-7
No files found.
slapos/recipe/dcron.py
View file @
13e05252
...
...
@@ -33,26 +33,22 @@ class Recipe(GenericBaseRecipe):
def
install
(
self
):
self
.
logger
.
info
(
"Installing dcron..."
)
path_list
=
[]
options
=
self
.
options
script
=
self
.
createWrapper
(
name
=
options
[
'binary'
],
command
=
options
[
'dcrond-binary'
].
strip
(),
parameters
=
[
'-s'
,
options
[
'cron-entries'
],
'-c'
,
options
[
'crontabs'
],
'-t'
,
options
[
'cronstamps'
],
'-f'
,
'-l'
,
'5'
,
'-M'
,
options
[
'catcher'
]
])
cronstamps
=
self
.
options
[
'cronstamps'
]
cron_d
=
self
.
options
[
'cron-entries'
]
crontabs
=
self
.
options
[
'crontabs'
]
catcher
=
self
.
options
[
'catcher'
]
binary
=
self
.
options
[
'binary'
]
script
=
self
.
createPythonScript
(
binary
,
'slapos.recipe.librecipe.execute.execute'
,
[
self
.
options
[
'dcrond-binary'
].
strip
(),
'-s'
,
cron_d
,
'-c'
,
crontabs
,
'-t'
,
cronstamps
,
'-f'
,
'-l'
,
'5'
,
'-M'
,
catcher
]
)
path_list
.
append
(
script
)
self
.
logger
.
debug
(
'Main cron executable created at : %r'
,
script
)
self
.
logger
.
info
(
"dcron successfully installed."
)
return
path_list
return
[
script
]
...
...
slapos/recipe/notifier.py
View file @
13e05252
...
...
@@ -31,16 +31,17 @@ from slapos.recipe.librecipe import GenericBaseRecipe
class
Recipe
(
GenericBaseRecipe
):
def
install
(
self
):
commandline
=
[
self
.
options
[
'server-binary'
]]
commandline
.
extend
([
'--callbacks'
,
self
.
options
[
'callbacks'
]])
commandline
.
extend
([
'--feeds'
,
self
.
options
[
'feeds'
]])
commandline
.
extend
([
'--equeue-socket'
,
self
.
options
[
'equeue-socket'
]])
commandline
.
append
(
self
.
options
[
'host'
])
commandline
.
append
(
self
.
options
[
'port'
])
options
=
self
.
options
script
=
self
.
createWrapper
(
name
=
options
[
'wrapper'
],
command
=
options
[
'server-binary'
],
parameters
=
[
'--callbacks'
,
options
[
'callbacks'
],
'--feeds'
,
options
[
'feeds'
],
'--equeue-socket'
,
options
[
'equeue-socket'
],
options
[
'host'
],
options
[
'port'
]
])
return
[
script
]
return
[
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
'slapos.recipe.librecipe.execute.execute'
,
commandline
)]
class
Callback
(
GenericBaseRecipe
):
...
...
@@ -57,36 +58,40 @@ class Callback(GenericBaseRecipe):
class
Notify
(
GenericBaseRecipe
):
def
createNotifier
(
self
,
notifier_binary
,
executable
,
wrapper
,
**
kwargs
):
if
not
os
.
path
.
exists
(
kwargs
[
'log'
]):
def
createNotifier
(
self
,
notifier_binary
,
wrapper
,
executable
,
log
,
title
,
notification_url
,
feed_url
):
if
not
os
.
path
.
exists
(
log
):
# Just a touch
open
(
kwargs
[
'log'
]
,
'w'
).
close
()
open
(
log
,
'w'
).
close
()
commandline
=
[
notifier_binary
,
'-l'
,
kwargs
[
'log'
],
'--title'
,
kwargs
[
'title'
],
'--feed'
,
kwargs
[
'feed_url'
],
'--notification-url'
]
parameters
=
[
'-l'
,
log
,
'--title'
,
title
,
'--feed'
,
feed_url
,
'--notification-url'
,
]
parameters
.
extend
(
notification_url
.
split
(
' '
))
parameters
.
extend
([
'--executable'
,
executable
])
commandline
.
extend
(
kwargs
[
'notification_url'
].
split
(
' '
))
commandline
.
extend
([
'--executable'
,
executable
])
return
self
.
createWrapper
(
name
=
wrapper
,
command
=
notifier_binary
,
parameters
=
parameters
)
return
self
.
createPythonScript
(
wrapper
,
'slapos.recipe.librecipe.execute.execute'
,
[
str
(
i
)
for
i
in
commandline
])
def
install
(
self
):
feedurl
=
self
.
unparseUrl
(
scheme
=
'http'
,
host
=
self
.
options
[
'host'
],
port
=
self
.
options
[
'port'
],
path
=
'/get/%s'
%
self
.
options
[
'name'
])
feed_url
=
self
.
unparseUrl
(
scheme
=
'http'
,
host
=
self
.
options
[
'host'
],
port
=
self
.
options
[
'port'
],
path
=
'/get/%s'
%
self
.
options
[
'name'
])
log
=
os
.
path
.
join
(
self
.
options
[
'feeds'
],
self
.
options
[
'name'
])
script
=
self
.
createNotifier
(
self
.
options
[
'notifier-binary'
],
wrapper
=
self
.
options
[
'wrapper'
],
executable
=
self
.
options
[
'executable'
],
log
=
os
.
path
.
join
(
self
.
options
[
'feeds'
],
self
.
options
[
'name'
]),
title
=
self
.
options
[
'title'
],
notification_url
=
self
.
options
[
'notify'
],
feed_url
=
feedurl
,
)
options
=
self
.
options
script
=
self
.
createNotifier
(
notifier_binary
=
options
[
'notifier-binary'
],
wrapper
=
options
[
'wrapper'
],
executable
=
options
[
'executable'
],
log
=
log
,
title
=
options
[
'title'
],
notification_url
=
options
[
'notify'
],
feed_url
=
feed_url
)
return
[
script
]
slapos/recipe/pbs.py
View file @
13e05252
...
...
@@ -215,15 +215,14 @@ class Recipe(GenericSlapRecipe, Notify, Callback):
else
:
command
=
[
self
.
options
[
'rdiffbackup-binary'
]]
self
.
logger
.
info
(
"Server mode"
)
command
.
extend
([
'--restrict'
,
self
.
options
[
'path'
]])
command
.
append
(
'--server'
)
wrapper
=
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
'slapos.recipe.librecipe.execute.execute'
,
command
)
wrapper
=
self
.
createWrapper
(
name
=
self
.
options
[
'wrapper'
],
command
=
self
.
options
[
'rdiffbackup-binary'
],
parameters
=
[
'--restrict'
,
self
.
options
[
'path'
],
'--server'
])
path_list
.
append
(
wrapper
)
return
path_list
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