From 59a1c1c0cc4cd64e413d13ad59bd495c7d1dadda Mon Sep 17 00:00:00 2001 From: Alec Cohan Date: Tue, 13 Aug 2019 14:29:56 -0400 Subject: [PATCH] made suggested changes, used serialization method for not defined canonical facts --- README.md | 9 --------- api/host.py | 12 ++++++------ app/events.py | 6 +----- run.py | 2 +- 4 files changed, 8 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index c9f234a62d..b824d6f5ff 100644 --- a/README.md +++ b/README.md @@ -92,15 +92,6 @@ _prometheus_multiproc_dir_ environment variable. This is done automatically. python run_gunicorn.py ``` -Should issues occur with the server's connection to the docker service, it might -be necessary to add the following to your hosts file: - -``` -kafka 127.0.0.1 -``` - - - ## Configuration environment variables ``` diff --git a/api/host.py b/api/host.py index fe21848410..5e0259e025 100644 --- a/api/host.py +++ b/api/host.py @@ -283,28 +283,28 @@ def find_hosts_by_hostname_or_id(account_number, hostname): def delete_by_id(host_id_list): query = _get_host_list_by_id_list(current_identity.account_number, host_id_list) - host_ids_to_delete = [] + hosts_to_delete = [] for host in query.all(): try: - host_ids_to_delete.append({"id": host.id, **host.canonical_facts, "account": host.account}) + hosts_to_delete.append(host.to_json()) except sqlalchemy.orm.exc.ObjectDeletedError: logger.exception( "Encountered sqlalchemy.orm.exc.ObjectDeletedError exception during delete_by_id operation. Host was " "already deleted." ) - if not host_ids_to_delete: + if not hosts_to_delete: return flask.abort(status.HTTP_404_NOT_FOUND) with metrics.delete_host_processing_time.time(): query.delete(synchronize_session="fetch") db.session.commit() - metrics.delete_host_count.inc(len(host_ids_to_delete)) + metrics.delete_host_count.inc(len(hosts_to_delete)) - logger.debug("Deleted hosts: %s", host_ids_to_delete) + logger.debug("Deleted hosts: %s", hosts_to_delete) - for deleted_host_id in host_ids_to_delete: + for deleted_host_id in hosts_to_delete: emit_event(events.delete(deleted_host_id)) diff --git a/app/events.py b/app/events.py index 8fca6e5ffc..5bc535c3c5 100644 --- a/app/events.py +++ b/app/events.py @@ -25,8 +25,4 @@ class HostEvent(Schema): def delete(host): - return HostEvent(strict=True).dumps({"id": host['id'], "insights_id": host['insights_id'], "rhel_machine_id": host['rhel_machine_id'], - "subscription_manager_id": host['subscription_manager_id'], "satellite_id": host['satellite_id'], - "fqdn": host['fqdn'], "bios_uuid": host['bios_uuid'], "ip_addresses": host['ip_addresses'], - "mac_addresses:": host['mac_addresses'], "external_id": host['external_id'], - "account": host['account'], "timestamp": datetime.utcnow(), "type": "delete"}).data \ No newline at end of file + return HostEvent().dumps({"timestamp": datetime.utcnow(), **host, "type": "delete"}).data \ No newline at end of file diff --git a/run.py b/run.py index 824cf75a5c..c239bcc52f 100755 --- a/run.py +++ b/run.py @@ -3,7 +3,7 @@ from app import create_app -config_name = os.getenv("APP_SETTINGS", "testing") +config_name = os.getenv("APP_SETTINGS", "development") application = create_app(config_name) listen_port = os.getenv("LISTEN_PORT", 8080)