Skip to content

Commit 8fb388e

Browse files
authored
router: support multi-homed VMs in VPC (apache#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 apache#3273 Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 41f569e commit 8fb388e

3 files changed

Lines changed: 4 additions & 10 deletions

File tree

server/src/com/cloud/network/element/VirtualRouterElement.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,7 @@ public VirtualRouterProvider getCreatedElement(final long id) {
895895
@Override
896896
public boolean release(final Network network, final NicProfile nic, final VirtualMachineProfile vm, final ReservationContext context) throws ConcurrentOperationException,
897897
ResourceUnavailableException {
898+
removeDhcpEntry(network, nic, vm);
898899
return true;
899900
}
900901

systemvm/debian/opt/cloud/bin/cs/CsDhcp.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ def configure_server(self):
118118

119119
def delete_leases(self):
120120
macs_dhcphosts = []
121-
interfaces = filter(lambda x: x.startswith('eth'), os.listdir('/sys/class/net'))
122121
try:
123122
logging.info("Attempting to delete entries from dnsmasq.leases file for VMs which are not on dhcphosts file")
124123
for host in open(DHCP_HOSTS):
@@ -130,10 +129,9 @@ def delete_leases(self):
130129
mac = lease[1]
131130
ip = lease[2]
132131
if mac not in macs_dhcphosts:
133-
for interface in interfaces:
134-
cmd = "dhcp_release %s %s %s" % (interface, ip, mac)
135-
logging.info(cmd)
136-
CsHelper.execute(cmd)
132+
cmd = "dhcp_release $(ip route get %s | grep eth | head -1 | awk '{print $3}') %s %s" % (ip, ip, mac)
133+
logging.info(cmd)
134+
CsHelper.execute(cmd)
137135
removed = removed + 1
138136
self.del_host(ip)
139137
logging.info("Deleted %s entries from dnsmasq.leases file" % str(removed))

systemvm/debian/opt/cloud/bin/cs_dhcp.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ def merge(dbag, data):
2727
del(dbag[data['ipv4_address']])
2828
else:
2929
remove_keys = set()
30-
for key, entry in dbag.iteritems():
31-
if key != 'id' and entry['host_name'] == data['host_name']:
32-
remove_keys.add(key)
33-
break
34-
3530
for key, entry in dbag.iteritems():
3631
if key != 'id' and entry['mac_address'] == data['mac_address']:
3732
remove_keys.add(key)

0 commit comments

Comments
 (0)