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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
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
Show 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):
...
@@ -33,26 +33,22 @@ class Recipe(GenericBaseRecipe):
def
install
(
self
):
def
install
(
self
):
self
.
logger
.
info
(
"Installing dcron..."
)
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
.
debug
(
'Main cron executable created at : %r'
,
script
)
self
.
logger
.
info
(
"dcron successfully installed."
)
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
...
@@ -31,16 +31,17 @@ from slapos.recipe.librecipe import GenericBaseRecipe
class
Recipe
(
GenericBaseRecipe
):
class
Recipe
(
GenericBaseRecipe
):
def
install
(
self
):
def
install
(
self
):
commandline
=
[
self
.
options
[
'server-binary'
]]
options
=
self
.
options
commandline
.
extend
([
'--callbacks'
,
self
.
options
[
'callbacks'
]])
script
=
self
.
createWrapper
(
name
=
options
[
'wrapper'
],
commandline
.
extend
([
'--feeds'
,
self
.
options
[
'feeds'
]])
command
=
options
[
'server-binary'
],
commandline
.
extend
([
'--equeue-socket'
,
self
.
options
[
'equeue-socket'
]])
parameters
=
[
commandline
.
append
(
self
.
options
[
'host'
])
'--callbacks'
,
options
[
'callbacks'
],
commandline
.
append
(
self
.
options
[
'port'
])
'--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
):
class
Callback
(
GenericBaseRecipe
):
...
@@ -57,36 +58,40 @@ class Callback(GenericBaseRecipe):
...
@@ -57,36 +58,40 @@ class Callback(GenericBaseRecipe):
class
Notify
(
GenericBaseRecipe
):
class
Notify
(
GenericBaseRecipe
):
def
createNotifier
(
self
,
notifier_binary
,
executable
,
wrapper
,
**
kwargs
):
def
createNotifier
(
self
,
notifier_binary
,
wrapper
,
executable
,
if
not
os
.
path
.
exists
(
kwargs
[
'log'
]):
log
,
title
,
notification_url
,
feed_url
):
if
not
os
.
path
.
exists
(
log
):
# Just a touch
# Just a touch
open
(
kwargs
[
'log'
]
,
'w'
).
close
()
open
(
log
,
'w'
).
close
()
commandline
=
[
notifier_binary
,
parameters
=
[
'-l'
,
kwargs
[
'log'
],
'-l'
,
log
,
'--title'
,
kwargs
[
'title'
],
'--title'
,
title
,
'--feed'
,
kwargs
[
'feed_url'
],
'--feed'
,
feed_url
,
'--notification-url'
]
'--notification-url'
,
]
parameters
.
extend
(
notification_url
.
split
(
' '
))
parameters
.
extend
([
'--executable'
,
executable
])
commandline
.
extend
(
kwargs
[
'notification_url'
].
split
(
' '
))
return
self
.
createWrapper
(
name
=
wrapper
,
commandline
.
extend
([
'--executable'
,
executable
])
command
=
notifier_binary
,
parameters
=
parameters
)
return
self
.
createPythonScript
(
wrapper
,
'slapos.recipe.librecipe.execute.execute'
,
[
str
(
i
)
for
i
in
commandline
])
def
install
(
self
):
def
install
(
self
):
feedurl
=
self
.
unparseUrl
(
scheme
=
'http'
,
host
=
self
.
options
[
'host'
],
feed
_
url
=
self
.
unparseUrl
(
scheme
=
'http'
,
host
=
self
.
options
[
'host'
],
port
=
self
.
options
[
'port'
],
port
=
self
.
options
[
'port'
],
path
=
'/get/%s'
%
self
.
options
[
'name'
])
path
=
'/get/%s'
%
self
.
options
[
'name'
])
script
=
self
.
createNotifier
(
log
=
os
.
path
.
join
(
self
.
options
[
'feeds'
],
self
.
options
[
'name'
])
self
.
options
[
'notifier-binary'
],
wrapper
=
self
.
options
[
'wrapper'
],
options
=
self
.
options
executable
=
self
.
options
[
'executable'
],
script
=
self
.
createNotifier
(
notifier_binary
=
options
[
'notifier-binary'
],
log
=
os
.
path
.
join
(
self
.
options
[
'feeds'
],
self
.
options
[
'name'
]),
wrapper
=
options
[
'wrapper'
],
title
=
self
.
options
[
'title'
],
executable
=
options
[
'executable'
],
notification_url
=
self
.
options
[
'notify'
],
log
=
log
,
feed_url
=
feedurl
,
title
=
options
[
'title'
],
)
notification_url
=
options
[
'notify'
],
feed_url
=
feed_url
)
return
[
script
]
return
[
script
]
slapos/recipe/pbs.py
View file @
13e05252
...
@@ -215,15 +215,14 @@ class Recipe(GenericSlapRecipe, Notify, Callback):
...
@@ -215,15 +215,14 @@ class Recipe(GenericSlapRecipe, Notify, Callback):
else
:
else
:
command
=
[
self
.
options
[
'rdiffbackup-binary'
]]
self
.
logger
.
info
(
"Server mode"
)
self
.
logger
.
info
(
"Server mode"
)
command
.
extend
([
'--restrict'
,
self
.
options
[
'path'
]])
command
.
append
(
'--server'
)
wrapper
=
self
.
createPythonScript
(
wrapper
=
self
.
createWrapper
(
name
=
self
.
options
[
'wrapper'
],
self
.
options
[
'wrapper'
],
command
=
self
.
options
[
'rdiffbackup-binary'
],
'slapos.recipe.librecipe.execute.execute'
,
parameters
=
[
command
)
'--restrict'
,
self
.
options
[
'path'
],
'--server'
])
path_list
.
append
(
wrapper
)
path_list
.
append
(
wrapper
)
return
path_list
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