コード例 #1
0
 def time_of_the_monkey(self):
     """Create some chaos"""
     if not self.should_run():
         return
     chaos = random.choice(self.chaos_types)
     logger.info("Selected random script: '%s'" % chaos)
     vm = random.choice(self.get_all_ips())
     logger.info("Selected random machine '%s'" % vm)
     runner = ScriptRunner(vm)
     runner.connect(username=self.username, password=self.password, key_filename=self.key_filename)
     runner.run_file(self.SCRIPT_DIR + "/" + chaos)
     runner.close()
     if self.twitter:
         try:
             self.twitter.PostUpdate("Haha! Just ran '%s' on '%s'." % (chaos, vm))
         except Exception as e:
             logger.exception(e)
     logger.info("Ran '%s' on '%s'." % (chaos, vm))
     self.last_run = datetime.datetime.now()
コード例 #2
0
 def one_check(self, ip, script_file):
     runner = ScriptRunner(ip)
     runner.connect(username=self.username, password=self.password, key_filename=self.key_filename)
     return_code, stdout, stderr = runner.run_file(script_file)
     self.results.append(
         dict(return_code=return_code,
              stdout=stdout,
              stderr=stderr,
              ip=ip,
              scriptfile=script_file
              )
     )
     self.result_count -= 1
     if not self.result_count:
         logger.info('Security run done. Check report')
         self.complete_run()
     runner.close()
コード例 #3
0
ファイル: supermonkey.py プロジェクト: jyoungs/pySimians
 def run_script_on_host(self, host, script, daemonize=False):
   runner = ScriptRunner(host)
   runner.connect(**dict(self.get_vm_credentials()))
   return_code, stdout, stderr = runner.run_file(script, daemonize)
   runner.close()
   return return_code, stdout, stderr