Skip to content

Commit

Permalink
made suggested changes, used serialization method for not defined can…
Browse files Browse the repository at this point in the history
…onical facts
  • Loading branch information
aleccohan committed Aug 13, 2019
1 parent bc5b827 commit 59a1c1c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 21 deletions.
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

```
Expand Down
12 changes: 6 additions & 6 deletions api/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))


Expand Down
6 changes: 1 addition & 5 deletions app/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
return HostEvent().dumps({"timestamp": datetime.utcnow(), **host, "type": "delete"}).data
2 changes: 1 addition & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 59a1c1c

Please sign in to comment.