def create_future_message( cloud_obj, future_days, cloud_info, host_list_expire, ): cc_users = conf["report_cc"].split(",") ticket = cloud_obj.ticket for user in cloud_obj.ccuser: cc_users.append("%s@%s" % (user, conf["domain"])) template_file = "future_message" with open(os.path.join(TEMPLATES_PATH, template_file)) as _file: template = Template(_file.read()) content = template.render( days_to_report=future_days, cloud_info=cloud_info, wp_wiki=conf["wp_wiki"], cloud=cloud_obj.name, hosts=host_list_expire, ) postman = Postman( "QUADS upcoming assignment notification - %s - %s" % (cloud_obj.name, ticket), cloud_obj.owner, cc_users, content, ) postman.send_email()
def create_message( cloud_obj, day, cloud_info, host_list_expire, ): template_file = "message" cloud = cloud_obj.name real_owner = cloud_obj.owner ticket = cloud_obj.ticket cc = cloud_obj.ccuser cc_users = conf["report_cc"].split(",") for user in cc: cc_users.append("%s@%s" % (user, conf["domain"])) with open(os.path.join(TEMPLATES_PATH, template_file)) as _file: template = Template(_file.read()) quads_request_url = conf.get("quads_request_url") content = template.render( days_to_report=day, cloud_info=cloud_info, wp_wiki=conf["wp_wiki"], quads_request_url=quads_request_url, quads_request_deadline_day=conf["quads_request_deadline_day"], quads_notify_until_extended=conf["quads_notify_until_extended"], cloud=cloud, hosts=host_list_expire, ) postman = Postman( "QUADS upcoming expiration for %s - %s" % (cloud, ticket), real_owner, cc_users, content, ) postman.send_email()
def create_initial_message(real_owner, cloud, cloud_info, ticket, cc): template_file = "initial_message" irc_bot_ip = conf["ircbot_ipaddr"] irc_bot_port = conf["ircbot_port"] irc_bot_channel = conf["ircbot_channel"] infra_location = conf["infra_location"] cc_users = conf["report_cc"].split(",") for user in cc: cc_users.append("%s@%s" % (user, conf["domain"])) if conf["email_notify"]: with open(os.path.join(TEMPLATES_PATH, template_file)) as _file: template = Template(_file.read()) content = template.render( cloud_info=cloud_info, wp_wiki=conf["wp_wiki"], cloud=cloud, quads_url=conf["quads_url"], real_owner=real_owner, password=f"{infra_location}@{ticket}", foreman_url=conf["foreman_url"], ) postman = Postman( "New QUADS Assignment Allocated - %s %s" % (cloud, ticket), real_owner, cc_users, content) postman.send_email() if conf["irc_notify"]: try: with Netcat(irc_bot_ip, irc_bot_port) as nc: message = "%s QUADS: %s is now active, choo choo! - http://%s/assignments/#%s" % ( irc_bot_channel, cloud_info, conf["wp_wiki"], cloud) nc.write(bytes(message.encode("utf-8"))) except (TypeError, BrokenPipeError) as ex: logger.debug(ex) logger.error("Beep boop netcat can't communicate with your IRC.")
def create_message(real_owner, day, cloud, cloud_info, ticket, cc, validated, current_hosts, future_hosts): template_file = "message" report_file = "%s-%s-%s-%s" % (cloud, real_owner, day, ticket) cc_users = conf["report_cc"].split(",") for user in cc: cc_users.append("%s@%s" % (user, conf["domain"])) if not os.path.exists(os.path.join(conf["data_dir"], "report", report_file)): if validated: host_list_expire = set(current_hosts) - set(future_hosts) if host_list_expire: Path(os.path.join(conf["data_dir"], "report", report_file)).touch() if conf["email_notify"]: with open(os.path.join(TEMPLATES_PATH, template_file)) as _file: template = Template(_file.read()) content = template.render( days_to_report=day, cloud_info=cloud_info, wp_wiki=conf["wp_wiki"], cloud=cloud, hosts=host_list_expire, ) postman = Postman("QUADS upcoming expiration notification", real_owner, cc_users, content) postman.send_email() return
def create_future_message( real_owner, future_days, cloud, cloud_info, cc, host_list_expire, report_path, ): cc_users = conf["report_cc"].split(",") for user in cc: cc_users.append("%s@%s" % (user, conf["domain"])) template_file = "future_message" with open(os.path.join(TEMPLATES_PATH, template_file)) as _file: template = Template(_file.read()) content = template.render( days_to_report=future_days, cloud_info=cloud_info, wp_wiki=conf["wp_wiki"], cloud=cloud, hosts=host_list_expire, ) postman = Postman("QUADS upcoming assignment notification", real_owner, cc_users, content) postman.send_email() Path(report_path).touch()
def create_future_initial_message(real_owner, cloud_info, cc): template_file = "future_initial_message" cc_users = conf["report_cc"].split(",") for user in cc: cc_users.append("%s@%s" % (user, conf["domain"])) with open(os.path.join(TEMPLATES_PATH, template_file)) as _file: template = Template(_file.read()) content = template.render( cloud_info=cloud_info, wp_wiki=conf["wp_wiki"], ) postman = Postman("New QUADS Assignment Allocated", real_owner, cc_users, content) postman.send_email()
def notify_success(_cloud): template_file = "validation_succeded" with open(os.path.join(TEMPLATES_PATH, template_file)) as _file: template = Template(_file.read()) parameters = { "cloud": _cloud.name, "owner": _cloud.owner, "ticket": _cloud.ticket, } content = template.render(**parameters) subject = "Validation check succeeded for {cloud} / {owner} / {ticket}".format(**parameters) _cc_users = conf["report_cc"].split(",") postman = Postman(subject, "dev-null", _cc_users, content) postman.send_email()
def create_future_initial_message(cloud_obj, cloud_info): template_file = "future_initial_message" cloud = cloud_obj.name ticket = cloud_obj.ticket cc_users = conf["report_cc"].split(",") for user in cloud_obj.ccuser: cc_users.append("%s@%s" % (user, conf["domain"])) with open(os.path.join(TEMPLATES_PATH, template_file)) as _file: template = Template(_file.read()) content = template.render( cloud_info=cloud_info, wp_wiki=conf["wp_wiki"], ) postman = Postman( "New QUADS Assignment Defined for the Future: %s - %s" % (cloud, ticket), cloud_obj.owner, cc_users, content) postman.send_email()
def create_future_initial_message(real_owner, cloud, cloud_info, ticket, cc): template_file = "future_initial_message" report_file = "%s-%s-pre-initial-%s" % (cloud, real_owner, ticket) cc_users = conf["report_cc"].split(",") for user in cc: cc_users.append("%s@%s" % (user, conf["domain"])) if not os.path.exists(os.path.join(conf["data_dir"], "report", report_file)): Path(os.path.join(conf["data_dir"], "report", report_file)).touch() if conf["email_notify"]: with open(os.path.join(TEMPLATES_PATH, template_file)) as _file: template = Template(_file.read()) content = template.render( cloud_info=cloud_info, wp_wiki=conf["wp_wiki"], ) postman = Postman("New QUADS Assignment Allocated", real_owner, cc_users, content) postman.send_email() return