From 748e2e51a9ead7be4047e112aad2ed07a3d7a2c9 Mon Sep 17 00:00:00 2001 From: Ian Southam Date: Wed, 18 Feb 2015 18:36:59 +0100 Subject: [PATCH] Check both ip and hosts when building dhcp bag --- .../debian/config/opt/cloud/bin/cs_dhcp.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs_dhcp.py b/systemvm/patches/debian/config/opt/cloud/bin/cs_dhcp.py index 64d8f8ddf88..d9f30e5ab49 100644 --- a/systemvm/patches/debian/config/opt/cloud/bin/cs_dhcp.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/cs_dhcp.py @@ -21,6 +21,7 @@ from netaddr import * def merge(dbag, data): + search(dbag, data['host_name']) # A duplicate ip address wil clobber the old value # This seems desirable .... if "add" in data and data['add'] is False and \ @@ -31,3 +32,18 @@ def merge(dbag, data): else: dbag[data['ipv4_adress']] = data return dbag + + +def search(dbag, name): + """ + Dirty hack because CS does not deprovision hosts + """ + hosts = [] + for o in dbag: + if o == 'id': + continue + print "%s %s" % (dbag[o]['host_name'], name) + if dbag[o]['host_name'] == name: + hosts.append(o) + for o in hosts: + del(dbag[o])