Commit 69b1df32 authored by Marco Mariani's avatar Marco Mariani

Merge remote-tracking branch 'origin/resiliency_annotated' into lapp-resilient2

parents 944d97c2 9ef171f8
...@@ -134,6 +134,7 @@ class ResilientInstance(object): ...@@ -134,6 +134,7 @@ class ResilientInstance(object):
if self.participant_id != new_id: if self.participant_id != new_id:
self.halter_id = new_id self.halter_id = new_id
self.participant_id = new_id self.participant_id = new_id
log.debug('I am {} of {}'.format(self.participant_id, self.total_participants))
## Needs to be changed to use the master ## Needs to be changed to use the master
def aliveManagement(self): def aliveManagement(self):
...@@ -251,6 +252,7 @@ class Wrapper(object): ...@@ -251,6 +252,7 @@ class Wrapper(object):
params = open(self.confpath, 'r').readlines() params = open(self.confpath, 'r').readlines()
self.ips = params[0].split() self.ips = params[0].split()
self.participant_id = int(params[1]) self.participant_id = int(params[1])
log.debug('I am {} of {}'.format(self.participant_id, self.ips))
def start(self): def start(self):
self.getConnectionInfo() self.getConnectionInfo()
......
...@@ -95,7 +95,7 @@ class GenericBaseRecipe(object): ...@@ -95,7 +95,7 @@ class GenericBaseRecipe(object):
def addLineToFile(self, filepath, line, encoding='utf8'): def addLineToFile(self, filepath, line, encoding='utf8'):
"""Append a single line to a text file, if the line does not exist yet. """Append a single line to a text file, if the line does not exist yet.
line must be unicode.""" line must be unicode."""
try: try:
...@@ -127,16 +127,18 @@ class GenericBaseRecipe(object): ...@@ -127,16 +127,18 @@ class GenericBaseRecipe(object):
path, arguments=arguments)[0] path, arguments=arguments)[0]
return script return script
def createWrapper(self, name, command, parameters): def createWrapper(self, name, command, parameters, comments=[]):
""" """
Creates a very simple (one command) shell script for process replacement. Creates a very simple (one command) shell script for process replacement.
Takes care of quoting. Takes care of quoting.
""" """
lines = [ lines = [ '#!/bin/sh' ]
'#!/bin/sh',
'exec %s' % shlex.quote(command) for comment in comments:
] lines.append('# %s' % comment)
lines.append('exec %s' % shlex.quote(command))
for param in parameters: for param in parameters:
if len(lines[-1]) < 30: if len(lines[-1]) < 30:
......
...@@ -39,7 +39,11 @@ class Recipe(GenericBaseRecipe): ...@@ -39,7 +39,11 @@ class Recipe(GenericBaseRecipe):
'--feeds', options['feeds'], '--feeds', options['feeds'],
'--equeue-socket', options['equeue-socket'], '--equeue-socket', options['equeue-socket'],
options['host'], options['port'] options['host'], options['port']
]) ],
comments=[
'',
'Upon receiving a notification, execute the callback(s).',
''])
return [script] return [script]
...@@ -77,7 +81,11 @@ class Notify(GenericBaseRecipe): ...@@ -77,7 +81,11 @@ class Notify(GenericBaseRecipe):
return self.createWrapper(name=wrapper, return self.createWrapper(name=wrapper,
command=notifier_binary, command=notifier_binary,
parameters=parameters) parameters=parameters,
comments=[
'',
'Call an executable and send notification(s).',
''])
def install(self): def install(self):
......
...@@ -150,8 +150,10 @@ class Recipe(GenericSlapRecipe, Notify, Callback): ...@@ -150,8 +150,10 @@ class Recipe(GenericSlapRecipe, Notify, Callback):
parameters.extend(['--restore-as-of', 'now']) parameters.extend(['--restore-as-of', 'now'])
parameters.append('--force') parameters.append('--force')
parameters.extend([local_directory, remote_directory]) parameters.extend([local_directory, remote_directory])
comments = ['','Push data to a PBS *-import instance.','']
else: else:
parameters.extend([remote_directory, local_directory]) parameters.extend([remote_directory, local_directory])
comments = ['','Pull data from a PBS *-export instance.','']
wrapper_basepath = os.path.join(self.options['wrappers-directory'], wrapper_basepath = os.path.join(self.options['wrappers-directory'],
url_hash) url_hash)
...@@ -163,7 +165,8 @@ class Recipe(GenericSlapRecipe, Notify, Callback): ...@@ -163,7 +165,8 @@ class Recipe(GenericSlapRecipe, Notify, Callback):
wrapper = self.createWrapper(name=wrapper_path, wrapper = self.createWrapper(name=wrapper_path,
command=self.options['rdiffbackup-binary'], command=self.options['rdiffbackup-binary'],
parameters=parameters) parameters=parameters,
comments = comments)
path_list.append(wrapper) path_list.append(wrapper)
if 'notify' in entry: if 'notify' in entry:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment