From 9df5cb1f16229add896e20b892e8534c39a43c9c Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sun, 15 Nov 2020 13:23:24 +0100 Subject: [PATCH] bundles/dhcpd: remove hardcoded group in metadata reactor get_static_allocations() --- bundles/dhcpd/metadata.py | 5 ++++- groups/locations.py | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bundles/dhcpd/metadata.py b/bundles/dhcpd/metadata.py index 2dafe29..a1a44d4 100644 --- a/bundles/dhcpd/metadata.py +++ b/bundles/dhcpd/metadata.py @@ -10,7 +10,10 @@ defaults = { @metadata_reactor def get_static_allocations(metadata): allocations = {} - for rnode in repo.nodes_in_group('home'): + for rnode in repo.nodes: + if rnode.metadata.get('location', '') != metadata.get('location', ''): + continue + for identifier, interface in rnode.metadata.get('interfaces', {}).items(): if interface.get('dhcp', False): allocations[rnode.name] = { diff --git a/groups/locations.py b/groups/locations.py index 953b027..4d46f32 100644 --- a/groups/locations.py +++ b/groups/locations.py @@ -13,6 +13,7 @@ groups['gce'] = { }, }, }, + 'location': 'gce', 'nameservers': { '8.8.8.8', '8.8.4.4', @@ -33,6 +34,9 @@ groups['htz'] = { 'subgroups': { 'htz-cloud', }, + 'metadata': { + 'location': 'htz', + }, } groups['htz-cloud'] = { @@ -70,6 +74,7 @@ groups['ovh'] = { r"ovh\..*", }, 'metadata': { + 'location': 'ovh', 'users': { 'debian': { 'delete': True,