Skip to content

Commit

Permalink
serverdb: create new object should pass the new "object_id" to signals
Browse files Browse the repository at this point in the history
  • Loading branch information
brainexe committed Jul 5, 2024
1 parent f09d43a commit 48f7940
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
python:
- "3.9"
- "3.10"
- "3.11"

services:
db:
Expand Down
8 changes: 3 additions & 5 deletions serveradmin/serverdb/query_committer.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def _delete_servers(changed, deleted, deleted_servers):

def _create_servers(attribute_lookup, created):
created_servers = {}
for attributes in created:
for idx, attributes in enumerate(created):
if not attributes.get('hostname'):
raise CommitError('"hostname" attribute is required.')
hostname = attributes['hostname']
Expand All @@ -246,10 +246,8 @@ def _create_servers(attribute_lookup, created):

server = _insert_server(hostname, intern_ip, servertype, attributes)

created_server = {k.pk: v for k, v in attributes.items()}
created_server['hostname'] = hostname
created_server['servertype'] = servertype.pk
created_server['intern_ip'] = intern_ip
# make new id available in signals
created[idx]['object_id'] = server.server_id

created_servers[server.server_id] = server

Expand Down

0 comments on commit 48f7940

Please sign in to comment.