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 bd78030  server: update dhcp configurations in vrs while update 
default nic of running vms (#3205)
bd78030 is described below

commit bd780303853132c696cf8e2ab20d9e1641fd5a25
Author: ustcweizhou <[email protected]>
AuthorDate: Fri May 31 08:53:55 2019 +0200

    server: update dhcp configurations in vrs while update default nic of 
running vms (#3205)
    
    In virtual routers, there are different dnsmasq settings for default nic 
and non-default nic on vm.
    We need to update dhcp informations on network vrs when default nic is 
changed.
    
    For example, if 172.16.1.135 is non-default nic of vm VPC1-001-001, then
    
    root@r-22-VM:~# cat /etc/dhcphosts.txt
    02:00:1d:15:00:05,set:172_16_1_135,172.16.1.135,VPC1-001-001,710h
    root@r-22-VM:~# cat /etc/dhcpopts.txt
    172_16_1_135,3
    172_16_1_135,6
    172_16_1_135,15
    
    If it is default nic,then
    
    root@r-22-VM:~# cat /etc/dhcpopts.txt
    root@r-22-VM:~# cat /etc/dhcphosts.txt
    02:00:1d:15:00:05,172.16.1.135,VPC1-001-001,757h
    
    Fixes #3201
---
 server/src/com/cloud/vm/UserVmManagerImpl.java | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java 
b/server/src/com/cloud/vm/UserVmManagerImpl.java
index 7ba282f..8857fe9 100644
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -1448,6 +1448,19 @@ public class UserVmManagerImpl extends ManagerBase 
implements UserVmManager, Vir
                     newNetworkOfferingId, null, 0L, 
VirtualMachine.class.getName(), vmInstance.getUuid(), vmInstance.isDisplay());
             
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NETWORK_OFFERING_ASSIGN, 
vmInstance.getAccountId(), vmInstance.getDataCenterId(), vmInstance.getId(),
                     oldNicIdString, oldNetworkOfferingId, null, 0L, 
VirtualMachine.class.getName(), vmInstance.getUuid(), vmInstance.isDisplay());
+
+            if (vmInstance.getState() != State.Stopped) {
+                try {
+                    VirtualMachineProfile vmProfile = new 
VirtualMachineProfileImpl(vmInstance);
+                    User callerUser = 
_accountMgr.getActiveUser(CallContext.current().getCallingUserId());
+                    ReservationContext context = new 
ReservationContextImpl(null, null, callerUser, caller);
+                    DeployDestination dest = new DeployDestination(dc, null, 
null, null);
+                    _networkMgr.prepare(vmProfile, dest, context);
+                } catch (final Exception e) {
+                    s_logger.info("Got exception: ", e);
+                }
+            }
+
             return _vmDao.findById(vmInstance.getId());
         }
 

Reply via email to