This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch 4.11
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.11 by this push:
new 8fb388e router: support multi-homed VMs in VPC (#3373)
8fb388e is described below
commit 8fb388e9312b917a8f36c7d7e3f45985a95ce773
Author: Rohit Yadav <[email protected]>
AuthorDate: Wed Jun 5 08:47:05 2019 +0530
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 <[email protected]>
---
server/src/com/cloud/network/element/VirtualRouterElement.java | 1 +
systemvm/debian/opt/cloud/bin/cs/CsDhcp.py | 8 +++-----
systemvm/debian/opt/cloud/bin/cs_dhcp.py | 5 -----
3 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/server/src/com/cloud/network/element/VirtualRouterElement.java
b/server/src/com/cloud/network/element/VirtualRouterElement.java
index 11a553c..a854d14 100644
--- a/server/src/com/cloud/network/element/VirtualRouterElement.java
+++ b/server/src/com/cloud/network/element/VirtualRouterElement.java
@@ -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;
}
diff --git a/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py
b/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py
index 6ea9174..e7abb90 100755
--- a/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py
+++ b/systemvm/debian/opt/cloud/bin/cs/CsDhcp.py
@@ -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))
diff --git a/systemvm/debian/opt/cloud/bin/cs_dhcp.py
b/systemvm/debian/opt/cloud/bin/cs_dhcp.py
index 735f847..bb2ff7b 100755
--- a/systemvm/debian/opt/cloud/bin/cs_dhcp.py
+++ b/systemvm/debian/opt/cloud/bin/cs_dhcp.py
@@ -28,11 +28,6 @@ def merge(dbag, data):
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)
break