Skip to content

Commit

Permalink
Removing unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed Dec 9, 2015
1 parent 5d7e0c3 commit ccb1a1e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 57 deletions.
55 changes: 1 addition & 54 deletions IM/ansible/ansible_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,6 @@ def summarize(self, host):

########################################################################

def regular_generic_msg(hostname, result, oneline, caption):
''' output on the result of a module run that is not command '''

if not oneline:
return "%s | %s >> %s\n" % (hostname, caption, ansible.utils.jsonify(result,format=True))
else:
return "%s | %s >> %s\n" % (hostname, caption, ansible.utils.jsonify(result))


def banner(msg):
str_date = str(datetime.datetime.now())
width = 78 - len(str_date + " - " + msg)
Expand All @@ -102,49 +93,6 @@ def banner(msg):
filler = "*" * width
return "\n%s %s " % (str_date + " - " + msg, filler)

def command_generic_msg(hostname, result, oneline, caption):
''' output the result of a command run '''

rc = result.get('rc', '0')
stdout = result.get('stdout','')
stderr = result.get('stderr', '')
msg = result.get('msg', '')

hostname = hostname.encode('utf-8')
caption = caption.encode('utf-8')

if not oneline:
buf = "%s | %s | rc=%s >>\n" % (hostname, caption, result.get('rc',0))
if stdout:
buf += stdout
if stderr:
buf += stderr
if msg:
buf += msg
return buf + "\n"
else:
if stderr:
return "%s | %s | rc=%s | (stdout) %s (stderr) %s" % (hostname, caption, rc, stdout, stderr)
else:
return "%s | %s | rc=%s | (stdout) %s" % (hostname, caption, rc, stdout)

def host_report_msg(hostname, module_name, result, oneline):
''' summarize the JSON results for a particular host '''

failed = ansible.utils.is_failed(result)
msg = ('', None)
if module_name in [ 'command', 'shell', 'raw' ] and 'ansible_job_id' not in result and result.get('parsed',True) != False:
if not failed:
msg = (command_generic_msg(hostname, result, oneline, 'success'), 'green')
else:
msg = (command_generic_msg(hostname, result, oneline, 'FAILED'), 'red')
else:
if not failed:
msg = (regular_generic_msg(hostname, result, oneline, 'success'), 'green')
else:
msg = (regular_generic_msg(hostname, result, oneline, 'FAILED'), 'red')
return msg

########################################################################

class PlaybookRunnerCallbacks(object):
Expand All @@ -167,8 +115,6 @@ def on_unreachable(self, host, results):
display(msg, color='red', runner=self.runner, output=self.output)

def on_failed(self, host, results, ignore_errors=False):


results2 = results.copy()
results2.pop('invocation', None)

Expand Down Expand Up @@ -361,6 +307,7 @@ def prompt(prompt, private):

def on_setup(self):
display(banner("GATHERING FACTS"), output=self.output)

def on_import_for_host(self, host, imported_file):
msg = "%s: importing %s" % (host, imported_file)
display(msg, color='cyan', output=self.output)
Expand Down
4 changes: 1 addition & 3 deletions IM/ansible/ansible_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ def launch_playbook(output, playbook_file, host, passwd, threads, pk_file = None
log_only=True, output=output
)


print ""
if len(failed_hosts) > 0:
return_code = 2
if len(unreachable_hosts) > 0:
Expand Down Expand Up @@ -186,4 +184,4 @@ def run(self):
self.results = launch_playbook(self.output, self.playbook_file, self.host, self.passwd, self.threads, self.pk_file, self.retries, self.inventory_file, self.user, self.extra_vars)
except errors.AnsibleError, e:
display("ERROR: %s" % e, color='red', stderr=True, output=self.output)
self.results = (1, [])
self.results = (1, [])

0 comments on commit ccb1a1e

Please sign in to comment.