mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Work arounds for how CS adds and removes hosts
This commit is contained in:
parent
748e2e51a9
commit
3cc0915a01
@ -128,8 +128,9 @@ class CsDhcp(CsDataBag):
|
||||
|
||||
def write_hosts(self):
|
||||
file = CsFile("/etc/hosts")
|
||||
file.repopulate()
|
||||
for ip in self.hosts:
|
||||
file.search("^%s" % ip, "%s\t%s" % (ip, self.hosts[ip]))
|
||||
file.add("%s\t%s" % (ip, self.hosts[ip]))
|
||||
file.commit()
|
||||
if file.is_changed():
|
||||
logging.info("Updated hosts file")
|
||||
@ -138,13 +139,9 @@ class CsDhcp(CsDataBag):
|
||||
|
||||
def add(self, entry):
|
||||
self.add_host(entry['ipv4_adress'], entry['host_name'])
|
||||
if self.cloud.search("%s," % entry['mac_address'],
|
||||
"%s,%s,%s,infinite" % (entry['mac_address'],
|
||||
self.cloud.add("%s,%s,%s,infinite" % (entry['mac_address'],
|
||||
entry['ipv4_adress'],
|
||||
entry['host_name'])):
|
||||
self.changed.append({'mac': entry['mac_address'],
|
||||
'ip4': entry['ipv4_adress'],
|
||||
'host': entry['host_name']})
|
||||
entry['host_name']))
|
||||
i = IPAddress(entry['ipv4_adress'])
|
||||
# Calculate the device
|
||||
for v in self.devinfo:
|
||||
|
||||
@ -53,6 +53,9 @@ class CsFile:
|
||||
self.config = []
|
||||
self.new_config = []
|
||||
|
||||
def repopulate(self):
|
||||
self.new_config = []
|
||||
|
||||
def commit(self):
|
||||
if not self.is_changed():
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user