def send_email(self, subject="Submitted", reason="Job submission successful"): try: dir_path = "/tmp" email_list = self.params["email"].replace(" ", "") email_to = "{0}@cisco.com".format(self.params["submitter"]) for email in email_list.split(','): if email == "": continue if not email.endswith("@cisco.com"): email += "@cisco.com" email_to = "{0},{1}".format(email_to, email) input_dict = {} input_dict["submitter"] = self.params["submitter"] input_dict["submit_id"] = self.params["submit_id"] input_dict["status"] = subject input_dict["reason"] = reason subject = "N9k Sanity Job {0} Submission: {1}".format( self.params["submit_id"], subject) j2env = J2Env() template_file = 'job_submission_email.html' out_file = "{0}/{1}".format(dir_path, "req_creation_mail.html") # print(out_file) j2env.create_file(template_file, input_dict, out_file) mailer = Mailer(email_to) mailer.send_html_mail(subject, out_file) except BaseException as e: log.error("Exception in send mail:" + repr(e))
def send_email(self, subject="Finished", reason="Sanity Job Completed"): try: dir_path = "/tmp" email_to = self.email input_dict = {} input_dict["submitter"] = self.job.submitter input_dict["submit_id"] = self.job.submit_id input_dict["status"] = subject input_dict["reason"] = "{0} on testbed {1}".format( reason, self.job.testbed) subject = "N9k Sanity Job {0} Status: {1}".format( self.job.submit_id, subject) j2env = J2Env() template_file = 'job_submission_email.html' out_file = "{0}/{1}".format(dir_path, "req_creation_mail.html") # print(out_file) j2env.create_file(template_file, input_dict, out_file) mailer = Mailer(email_to) mailer.send_html_mail(subject, out_file) except BaseException as e: log.error("Exception in send mail:" + repr(e))