From 099b90081f50d6331e90966a512a8f1640904867 Mon Sep 17 00:00:00 2001 From: forest Date: Thu, 9 Dec 2021 11:21:53 -0600 Subject: [PATCH] comment out temporarily broken ensure_vms_and_db_are_synced --- capsulflask/cli.py | 65 +++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/capsulflask/cli.py b/capsulflask/cli.py index 9fb5078..3c83e47 100644 --- a/capsulflask/cli.py +++ b/capsulflask/cli.py @@ -268,45 +268,46 @@ def notify_users_about_account_balance(): def ensure_vms_and_db_are_synced(): - db_vms = get_model().all_vm_ids_with_desired_state() - # TODO replaced - #virt_vms = current_app.config["HUB_MODEL"].virsh_list() + pass + # db_vms = get_model().all_vm_ids_with_desired_state() + # # TODO replaced + # #virt_vms = current_app.config["HUB_MODEL"].virsh_list() - db_ids_dict = dict() - virt_ids_dict = dict() + # db_ids_dict = dict() + # virt_ids_dict = dict() - for vm in db_vms: - db_ids_dict[vm['id']] = vm['desired_state'] + # for vm in db_vms: + # db_ids_dict[vm['id']] = vm['desired_state'] - for vm in virt_vms: - virt_ids_dict[vm['id']] = vm['desired_state'] + # for vm in virt_vms: + # virt_ids_dict[vm['id']] = vm['desired_state'] - errors = list() + # errors = list() - for id in db_ids_dict: - if id not in virt_ids_dict: - errors.append(f"{id} is in the database but not in the virtualization model") - elif db_ids_dict[id] != virt_ids_dict[id]: - errors.append(f"{id} has the desired state {db_ids_dict[id]} in the database but current state {virt_ids_dict[id]} in the virtualization model") + # for id in db_ids_dict: + # if id not in virt_ids_dict: + # errors.append(f"{id} is in the database but not in the virtualization model") + # elif db_ids_dict[id] != virt_ids_dict[id]: + # errors.append(f"{id} has the desired state {db_ids_dict[id]} in the database but current state {virt_ids_dict[id]} in the virtualization model") - for id in virt_ids_dict: - if id not in db_ids_dict: - errors.append(f"{id} is in the virtualization model but not in the database") + # for id in virt_ids_dict: + # if id not in db_ids_dict: + # errors.append(f"{id} is in the virtualization model but not in the database") - if len(errors) > 0: - email_addresses_raw = current_app.config['ADMIN_EMAIL_ADDRESSES'].split(",") - email_addresses = list(filter(lambda x: len(x) > 6, map(lambda x: x.strip(), email_addresses_raw ) )) + # if len(errors) > 0: + # email_addresses_raw = current_app.config['ADMIN_EMAIL_ADDRESSES'].split(",") + # email_addresses = list(filter(lambda x: len(x) > 6, map(lambda x: x.strip(), email_addresses_raw ) )) - current_app.logger.info(f"cron_task: sending inconsistency warning email to {','.join(email_addresses)}:") - for error in errors: - current_app.logger.info(f"cron_task: {error}.") + # current_app.logger.info(f"cron_task: sending inconsistency warning email to {','.join(email_addresses)}:") + # for error in errors: + # current_app.logger.info(f"cron_task: {error}.") - current_app.config["FLASK_MAIL_INSTANCE"].send( - Message( - "Capsul Consistency Check Failed", - sender=current_app.config["MAIL_DEFAULT_SENDER"], - body="\n".join(errors), - recipients=email_addresses - ) - ) + # current_app.config["FLASK_MAIL_INSTANCE"].send( + # Message( + # "Capsul Consistency Check Failed", + # sender=current_app.config["MAIL_DEFAULT_SENDER"], + # body="\n".join(errors), + # recipients=email_addresses + # ) + # )