mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
router: support multi-homed VMs in VPC (#3373)
This does not remove VM entries in dbags when hostnames match. The current codebase already removes entry when a VM is stopped/removed so we don't need to handle lazy removal. This will allow a VM on multiple-tiers in a VPC to get dns/dhcp rules as expected. This also fixes the issue of dhcp_release based on a specific interface and removes dhcp/dns entry when a nic is removed on a guest VM. Fixes #3273 Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
41f569e8a8
commit
8fb388e931
@ -895,6 +895,7 @@ NetworkMigrationResponder, AggregatedCommandExecutor, RedundantResource, DnsServ
|
||||
@Override
|
||||
public boolean release(final Network network, final NicProfile nic, final VirtualMachineProfile vm, final ReservationContext context) throws ConcurrentOperationException,
|
||||
ResourceUnavailableException {
|
||||
removeDhcpEntry(network, nic, vm);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -118,7 +118,6 @@ class CsDhcp(CsDataBag):
|
||||
|
||||
def delete_leases(self):
|
||||
macs_dhcphosts = []
|
||||
interfaces = filter(lambda x: x.startswith('eth'), os.listdir('/sys/class/net'))
|
||||
try:
|
||||
logging.info("Attempting to delete entries from dnsmasq.leases file for VMs which are not on dhcphosts file")
|
||||
for host in open(DHCP_HOSTS):
|
||||
@ -130,10 +129,9 @@ class CsDhcp(CsDataBag):
|
||||
mac = lease[1]
|
||||
ip = lease[2]
|
||||
if mac not in macs_dhcphosts:
|
||||
for interface in interfaces:
|
||||
cmd = "dhcp_release %s %s %s" % (interface, ip, mac)
|
||||
logging.info(cmd)
|
||||
CsHelper.execute(cmd)
|
||||
cmd = "dhcp_release $(ip route get %s | grep eth | head -1 | awk '{print $3}') %s %s" % (ip, ip, mac)
|
||||
logging.info(cmd)
|
||||
CsHelper.execute(cmd)
|
||||
removed = removed + 1
|
||||
self.del_host(ip)
|
||||
logging.info("Deleted %s entries from dnsmasq.leases file" % str(removed))
|
||||
|
||||
@ -27,11 +27,6 @@ def merge(dbag, data):
|
||||
del(dbag[data['ipv4_address']])
|
||||
else:
|
||||
remove_keys = set()
|
||||
for key, entry in dbag.iteritems():
|
||||
if key != 'id' and entry['host_name'] == data['host_name']:
|
||||
remove_keys.add(key)
|
||||
break
|
||||
|
||||
for key, entry in dbag.iteritems():
|
||||
if key != 'id' and entry['mac_address'] == data['mac_address']:
|
||||
remove_keys.add(key)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user