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
Vincent Bechu
slapos
Commits
cc8a16fb
Commit
cc8a16fb
authored
Nov 22, 2011
by
Antoine Catton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify pbs recipe in order to support notifications
parent
f275875f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
9 deletions
+36
-9
slapos/recipe/pbs.py
slapos/recipe/pbs.py
+36
-9
No files found.
slapos/recipe/pbs.py
View file @
cc8a16fb
...
@@ -32,8 +32,10 @@ import subprocess
...
@@ -32,8 +32,10 @@ import subprocess
import
sys
import
sys
import
time
import
time
from
slapos.recipe.librecipe
import
Generic
Base
Recipe
from
slapos.recipe.librecipe
import
Generic
Slap
Recipe
from
slapos.recipe.dropbear
import
KnownHostsFile
from
slapos.recipe.dropbear
import
KnownHostsFile
from
slapos.recipe.notifier
import
Notify
from
slapos.recipe.notifier
import
Callback
from
slapos
import
slap
as
slapmodule
from
slapos
import
slap
as
slapmodule
...
@@ -67,7 +69,7 @@ def promise(args):
...
@@ -67,7 +69,7 @@ def promise(args):
class
Recipe
(
Generic
BaseRecipe
):
class
Recipe
(
Generic
SlapRecipe
,
Notify
,
Callback
):
def
add_slave
(
self
,
entry
,
known_hosts_file
):
def
add_slave
(
self
,
entry
,
known_hosts_file
):
path_list
=
[]
path_list
=
[]
...
@@ -119,21 +121,46 @@ class Recipe(GenericBaseRecipe):
...
@@ -119,21 +121,46 @@ class Recipe(GenericBaseRecipe):
else
:
else
:
command
.
extend
([
remote_directory
,
local_directory
])
command
.
extend
([
remote_directory
,
local_directory
])
wrapper_basepath
=
os
.
path
.
join
(
self
.
options
[
'wrappers-directory'
],
url_hash
)
wrapper_path
=
wrapper_basepath
if
'notify'
in
entry
:
wrapper_path
=
'%s_raw'
%
wrapper_basepath
wrapper
=
self
.
createPythonScript
(
wrapper
=
self
.
createPythonScript
(
os
.
path
.
join
(
self
.
options
[
'wrappers-directory'
],
url_hash
)
,
wrapper_path
,
'slapos.recipe.librecipe.execute.execute'
,
'slapos.recipe.librecipe.execute.execute'
,
command
[
str
(
i
)
for
i
in
command
]
)
)
path_list
.
append
(
wrapper
)
path_list
.
append
(
wrapper
)
cron_entry
=
os
.
path
.
join
(
self
.
options
[
'cron-entries'
],
url_hash
)
if
'notify'
in
entry
:
with
open
(
cron_entry
,
'w'
)
as
cron_entry_file
:
feed_url
=
'%s/get/%s'
%
(
self
.
options
[
'notifier-url'
],
cron_entry_file
.
write
(
'%s %s'
%
(
entry
[
'frequency'
],
wrapper
))
entry
[
'notification-id'
])
path_list
.
append
(
cron_entry
)
wrapper
=
self
.
createNotifier
(
self
.
options
[
'notifier-binary'
],
wrapper
=
wrapper_basepath
,
executable
=
wrapper_path
,
log
=
os
.
path
.
join
(
self
.
options
[
'feeds'
],
entry
[
'notification-id'
]),
title
=
entry
[
'title'
],
notification_url
=
entry
[
'notify'
],
feed_url
=
feed_url
,
)
path_list
.
append
(
wrapper
)
#self.setConnectionDict(dict(feed_url=feed_url), entry['slave_reference'])
if
'on-notification'
in
entry
:
path_list
.
append
(
self
.
createCallback
(
entry
[
'on-notification'
],
wrapper
))
else
:
cron_entry
=
os
.
path
.
join
(
self
.
options
[
'cron-entries'
],
url_hash
)
with
open
(
cron_entry
,
'w'
)
as
cron_entry_file
:
cron_entry_file
.
write
(
'%s %s'
%
(
entry
[
'frequency'
],
wrapper
))
path_list
.
append
(
cron_entry
)
return
path_list
return
path_list
def
install
(
self
):
def
_
install
(
self
):
path_list
=
[]
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