You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2021/12/08 13:27:52 UTC

[GitHub] [cloudstack] weizhouapache opened a new pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

weizhouapache opened a new pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757


   ### Description
   
   This PR fixes the issue that new ip is not working if old ip is used in lb/pf (or dnat).
   
   Steps to reproduce the issue
   (1) create isolated network, and vm
   (2) acquire 3 public ips, add firewall rules to allow port 22 (ssh)
   (3) create NAT to the vm on public ip 1, load balancer to vm port 22 (ssh) on public ip 2,  port forwarding rule to vm port 22 on public ip 3
   (4) verify the ssh connection to vm, all work
   (5) stop vm, and update vm nic ip, start vm
   (6) expected result: DNAT, LB, PF work, 
   actual result without this PR : LB and PF do not work.
   
   <!--- Describe your changes in DETAIL - And how has behaviour functionally changed. -->
   
   <!-- For new features, provide link to FS, dev ML discussion etc. -->
   <!-- In case of bug fix, the expected and actual behaviours, steps to reproduce. -->
   
   <!-- When "Fixes: #<id>" is specified, the issue/PR will automatically be closed when this PR gets merged -->
   <!-- For addressing multiple issues/PRs, use multiple "Fixes: #<id>" -->
   <!-- Fixes: # -->
   
   <!--- ********************************************************************************* -->
   <!--- NOTE: AUTOMATATION USES THE DESCRIPTIONS TO SET LABELS AND PRODUCE DOCUMENTATION. -->
   <!--- PLEASE PUT AN 'X' in only **ONE** box -->
   <!--- ********************************************************************************* -->
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [x] Bug fix (non-breaking change which fixes an issue)
   - [ ] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Feature/Enhancement Scale
   
   - [ ] Major
   - [ ] Minor
   
   #### Bug Severity
   
   - [ ] BLOCKER
   - [ ] Critical
   - [x] Major
   - [ ] Minor
   - [ ] Trivial
   
   
   ### Screenshots (if appropriate):
   
   
   ### How Has This Been Tested?
   <!-- Please describe in detail how you tested your changes. -->
   <!-- Include details of your testing environment, and the tests you ran to -->
   <!-- see how your change affects other areas of the code, etc. -->
   
   
   <!-- Please read the [CONTRIBUTING](https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md) document -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-988858697


   @weizhouapache a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GutoVeronezi commented on a change in pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
GutoVeronezi commented on a change in pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#discussion_r773852607



##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -1826,6 +1801,45 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
         return vm;
     }
 
+    private void updatePublicIpDnatVmIp(long vmId, long networkId, String oldIp, String newIp) {
+        if (_networkModel.areServicesSupportedInNetwork(networkId, Service.StaticNat)) {
+            List<IPAddressVO> publicIps = _ipAddressDao.listByAssociatedVmId(vmId);
+            for (IPAddressVO publicIp : publicIps) {
+                if (oldIp.equals(publicIp.getVmIp()) && publicIp.getAssociatedWithNetworkId() == networkId) {
+                    publicIp.setVmIp(newIp);
+                    _ipAddressDao.persist(publicIp);
+                }
+            }
+        }

Review comment:
       @weizhouapache sorry, selecting multiple lines may have confused my comment.
   
    I agree with you when we talk about the second `if` statement, however, I meant invert the first `if` statement, like this:
   
   ```suggestion
           if (!_networkModel.areServicesSupportedInNetwork(networkId, Service.StaticNat)) {
               return;
           } 
   
           List<IPAddressVO> publicIps = _ipAddressDao.listByAssociatedVmId(vmId);
           for (IPAddressVO publicIp : publicIps) {
               if (oldIp.equals(publicIp.getVmIp()) && publicIp.getAssociatedWithNetworkId() == networkId) {
                   publicIp.setVmIp(newIp);
                   _ipAddressDao.persist(publicIp);
               }
           }
   ```
   
   
   This way we can avoid the `hadouken code` =)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-1000128535


   @weizhouapache a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan removed a comment on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan removed a comment on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-1000094455






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-1000180316


   @sureshanaparti a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-989795923


   @weizhouapache a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-990259725


   <b>Trillian test result (tid-2644)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 31177 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr5757-t2644-kvm-centos7.zip
   Smoke tests completed. 91 look OK, 0 have errors
   Only failed tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-993270727


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-988820929


   Packaging result: :heavy_multiplication_x: el7 :heavy_multiplication_x: el8 :heavy_multiplication_x: debian :heavy_multiplication_x: suse15. SL-JID 1862


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-999619464


   @weizhouapache a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan removed a comment on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan removed a comment on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-988814448


   @weizhouapache a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-989722285


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-1000096895


   <b>Trillian Build Failed (tid-2728)<b/>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-1000166002


   Packaging result: :heavy_multiplication_x: el7 :heavy_check_mark: el8 :heavy_multiplication_x: debian :heavy_check_mark: suse15. SL-JID 1998


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-1000367158


   @weizhouapache a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on a change in pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on a change in pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#discussion_r773854729



##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -1826,6 +1801,45 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
         return vm;
     }
 
+    private void updatePublicIpDnatVmIp(long vmId, long networkId, String oldIp, String newIp) {
+        if (_networkModel.areServicesSupportedInNetwork(networkId, Service.StaticNat)) {
+            List<IPAddressVO> publicIps = _ipAddressDao.listByAssociatedVmId(vmId);
+            for (IPAddressVO publicIp : publicIps) {
+                if (oldIp.equals(publicIp.getVmIp()) && publicIp.getAssociatedWithNetworkId() == networkId) {
+                    publicIp.setVmIp(newIp);
+                    _ipAddressDao.persist(publicIp);
+                }
+            }
+        }

Review comment:
       > @weizhouapache sorry, selecting multiple lines may have confused my comment.
   > 
   > I agree with you when we talk about the second `if` statement, however, I meant invert the first `if` statement, like this:
   > 
   > This way we can avoid the `hadouken code` =)
   
   @GutoVeronezi ah ok, my misunderstanding. I will change it. thanks
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-999584083


   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 1990


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan removed a comment on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan removed a comment on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-999478873






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-1000094455


   @weizhouapache a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-1000122608


   @sureshanaparti a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-1000324955


   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 2009


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GutoVeronezi commented on a change in pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
GutoVeronezi commented on a change in pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#discussion_r773852607



##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -1826,6 +1801,45 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
         return vm;
     }
 
+    private void updatePublicIpDnatVmIp(long vmId, long networkId, String oldIp, String newIp) {
+        if (_networkModel.areServicesSupportedInNetwork(networkId, Service.StaticNat)) {
+            List<IPAddressVO> publicIps = _ipAddressDao.listByAssociatedVmId(vmId);
+            for (IPAddressVO publicIp : publicIps) {
+                if (oldIp.equals(publicIp.getVmIp()) && publicIp.getAssociatedWithNetworkId() == networkId) {
+                    publicIp.setVmIp(newIp);
+                    _ipAddressDao.persist(publicIp);
+                }
+            }
+        }

Review comment:
       @weizhouapache sorry, selecting multiple lines may have confused my comment.
   
    I agree with you when we talk about the second `if` statement, however, I meant invert the first `if` statement, like this:
   
   ```suggestion
           if (!_networkModel.areServicesSupportedInNetwork(networkId, Service.StaticNat)) {
               return;
           } 
   
           List<IPAddressVO> publicIps = _ipAddressDao.listByAssociatedVmId(vmId);
           for (IPAddressVO publicIp : publicIps) {
               if (oldIp.equals(publicIp.getVmIp()) && publicIp.getAssociatedWithNetworkId() == networkId) {
                   publicIp.setVmIp(newIp);
                   _ipAddressDao.persist(publicIp);
               }
           }
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GutoVeronezi commented on a change in pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
GutoVeronezi commented on a change in pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#discussion_r773852607



##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -1826,6 +1801,45 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
         return vm;
     }
 
+    private void updatePublicIpDnatVmIp(long vmId, long networkId, String oldIp, String newIp) {
+        if (_networkModel.areServicesSupportedInNetwork(networkId, Service.StaticNat)) {
+            List<IPAddressVO> publicIps = _ipAddressDao.listByAssociatedVmId(vmId);
+            for (IPAddressVO publicIp : publicIps) {
+                if (oldIp.equals(publicIp.getVmIp()) && publicIp.getAssociatedWithNetworkId() == networkId) {
+                    publicIp.setVmIp(newIp);
+                    _ipAddressDao.persist(publicIp);
+                }
+            }
+        }

Review comment:
       @weizhouapache sorry, selecting multiple lines may have confused my comment.
   
    I agree with you when we talk about the second `if` statement, however, I meant invert the first `if` statement, like this:
   
   ```suggestion
           if (!_networkModel.areServicesSupportedInNetwork(networkId, Service.StaticNat)) {
               return;
           } 
   
           List<IPAddressVO> publicIps = _ipAddressDao.listByAssociatedVmId(vmId);
           for (IPAddressVO publicIp : publicIps) {
               if (oldIp.equals(publicIp.getVmIp()) && publicIp.getAssociatedWithNetworkId() == networkId) {
                   publicIp.setVmIp(newIp);
                   _ipAddressDao.persist(publicIp);
               }
           }
   ```
   
   
   This way we can avoid the `hadouken` code =)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-989758680


   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 1868


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-999695230


   @weizhouapache a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on a change in pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on a change in pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#discussion_r773825598



##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -1826,6 +1801,45 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
         return vm;
     }
 
+    private void updatePublicIpDnatVmIp(long vmId, long networkId, String oldIp, String newIp) {
+        if (_networkModel.areServicesSupportedInNetwork(networkId, Service.StaticNat)) {
+            List<IPAddressVO> publicIps = _ipAddressDao.listByAssociatedVmId(vmId);
+            for (IPAddressVO publicIp : publicIps) {
+                if (oldIp.equals(publicIp.getVmIp()) && publicIp.getAssociatedWithNetworkId() == networkId) {
+                    publicIp.setVmIp(newIp);
+                    _ipAddressDao.persist(publicIp);
+                }
+            }
+        }

Review comment:
       @GutoVeronezi
   thanks for your suggestion. I will consider it if there are many code lines in the `if` block.
   for these 3 methods, they have only 2 lines in `if` block, and I think `&&` is easier to understand than `!(aa) || !(bb)`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-999617678


   @blueorangutan test
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan removed a comment on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan removed a comment on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-999695230


   @weizhouapache a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-1000294838


   @blueorangutan package
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on a change in pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on a change in pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#discussion_r765655432



##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -1748,35 +1749,33 @@ public UserVm updateNicIpForVirtualMachine(UpdateVmNicIpCmd cmd) {
             }
 
             if (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.StaticNat)) {
-                IPAddressVO oldIP = _ipAddressDao.findByAssociatedVmId(vm.getId());
-                if (oldIP != null) {
-                    oldIP.setVmIp(ipaddr);
-                    _ipAddressDao.persist(oldIP);
+                List<IPAddressVO> publicIps = _ipAddressDao.listByAssociatedVmId(vm.getId());
+                for (IPAddressVO publicIp : publicIps) {
+                    if (nicVO.getIPv4Address().equals(publicIp.getVmIp() ) && publicIp.getAssociatedWithNetworkId() == network.getId()) {
+                        publicIp.setVmIp(ipaddr);
+                        _ipAddressDao.persist(publicIp);
+                    }
                 }
             }
-            // implementing the network elements and resources as a part of vm nic ip update if network has services and it is in Implemented state
-            if (!_networkModel.listNetworkOfferingServices(offering.getId()).isEmpty() && network.getState() == Network.State.Implemented) {
-                User callerUser = _accountMgr.getActiveUser(CallContext.current().getCallingUserId());
-                ReservationContext context = new ReservationContextImpl(null, null, callerUser, caller);
-                DeployDestination dest = new DeployDestination(_dcDao.findById(network.getDataCenterId()), null, null, null);
-
-                s_logger.debug("Implementing the network " + network + " elements and resources as a part of vm nic ip update");
-                try {
-                    // implement the network elements and rules again
-                    _networkMgr.implementNetworkElementsAndResources(dest, context, network, offering);
-                } catch (Exception ex) {
-                    s_logger.warn("Failed to implement network " + network + " elements and resources as a part of vm nic ip update due to ", ex);
-                    CloudRuntimeException e = new CloudRuntimeException("Failed to implement network (with specified id) elements and resources as a part of vm nic ip update");
-                    e.addProxyObject(network.getUuid(), "networkId");
-                    // restore to old ip address
-                    if (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.StaticNat)) {
-                        IPAddressVO oldIP = _ipAddressDao.findByAssociatedVmId(vm.getId());
-                        if (oldIP != null) {
-                            oldIP.setVmIp(nicVO.getIPv4Address());
-                            _ipAddressDao.persist(oldIP);
-                        }
+            if (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.Lb)) {
+                List<LoadBalancerVMMapVO> loadBalancerVMMaps = _loadBalancerVMMapDao.listByInstanceId(vm.getId());
+                for (LoadBalancerVMMapVO map : loadBalancerVMMaps) {
+                    long lbId = map.getLoadBalancerId();
+                    FirewallRuleVO rule = _rulesDao.findById(lbId);
+                    if (nicVO.getIPv4Address().equals(map.getInstanceIp()) && network.getId() == rule.getNetworkId()) {
+                        map.setInstanceIp(ipaddr);
+                        _loadBalancerVMMapDao.persist(map);
+                    }
+                }
+            }
+            if (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.PortForwarding)) {
+                List<PortForwardingRuleVO> firewallRules = _portForwardingDao.listByVm(vm.getId());
+                for (PortForwardingRuleVO firewallRule : firewallRules) {
+                    FirewallRuleVO rule = _rulesDao.findById(firewallRule.getId());
+                    if (nicVO.getIPv4Address().equals(firewallRule.getDestinationIpAddress().toString()) && network.getId() == rule.getNetworkId()) {
+                        firewallRule.setDestinationIpAddress(new Ip(ipaddr));
+                        _portForwardingDao.persist(firewallRule);

Review comment:
       Updated. thanks @DaanHoogland . 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan removed a comment on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan removed a comment on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-988820929


   Packaging result: :heavy_multiplication_x: el7 :heavy_multiplication_x: el8 :heavy_multiplication_x: debian :heavy_multiplication_x: suse15. SL-JID 1862


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache removed a comment on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache removed a comment on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-988814203


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-989321996


   <b>Trillian test result (tid-2642)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 29970 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr5757-t2642-kvm-centos7.zip
   Smoke tests completed. 91 look OK, 0 have errors
   Only failed tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan removed a comment on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan removed a comment on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-999619464


   @weizhouapache a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-1000094064


   @blueorangutan test
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache removed a comment on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache removed a comment on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-1000094064


   @blueorangutan test
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-1000122313


   @blueorangutan test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-1000257364


   @blueorangutan package
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-1000303452


   Packaging result: :heavy_multiplication_x: el7 :heavy_multiplication_x: el8 :heavy_multiplication_x: debian. SL-JID 2005


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-999589634


   @blueorangutan test
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan removed a comment on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan removed a comment on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-999590981


   @weizhouapache a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-999478338


   @blueorangutan package
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-988899431


   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 1863


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-999590981


   @weizhouapache a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-999623381


   @blueorangutan package
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-1000257880


   @weizhouapache a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-1000366678


   @blueorangutan test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-999692843


   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 1991


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan removed a comment on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan removed a comment on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-1000122608


   @sureshanaparti a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache removed a comment on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache removed a comment on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-999547222


   @blueorangutan package
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-1000295403


   @weizhouapache a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] GutoVeronezi commented on a change in pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
GutoVeronezi commented on a change in pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#discussion_r773176160



##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -1826,6 +1801,45 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
         return vm;
     }
 
+    private void updatePublicIpDnatVmIp(long vmId, long networkId, String oldIp, String newIp) {
+        if (_networkModel.areServicesSupportedInNetwork(networkId, Service.StaticNat)) {
+            List<IPAddressVO> publicIps = _ipAddressDao.listByAssociatedVmId(vmId);
+            for (IPAddressVO publicIp : publicIps) {
+                if (oldIp.equals(publicIp.getVmIp()) && publicIp.getAssociatedWithNetworkId() == networkId) {
+                    publicIp.setVmIp(newIp);
+                    _ipAddressDao.persist(publicIp);
+                }
+            }
+        }

Review comment:
       We could invert the `if` logic and add a return to reduce indentation.

##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -1826,6 +1801,45 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
         return vm;
     }
 
+    private void updatePublicIpDnatVmIp(long vmId, long networkId, String oldIp, String newIp) {
+        if (_networkModel.areServicesSupportedInNetwork(networkId, Service.StaticNat)) {
+            List<IPAddressVO> publicIps = _ipAddressDao.listByAssociatedVmId(vmId);
+            for (IPAddressVO publicIp : publicIps) {
+                if (oldIp.equals(publicIp.getVmIp()) && publicIp.getAssociatedWithNetworkId() == networkId) {
+                    publicIp.setVmIp(newIp);
+                    _ipAddressDao.persist(publicIp);
+                }
+            }
+        }
+    }
+
+    private void updateLoadBalancerRulesVmIp(long vmId, long networkId, String oldIp, String newIp) {
+        if (_networkModel.areServicesSupportedInNetwork(networkId, Service.Lb)) {
+            List<LoadBalancerVMMapVO> loadBalancerVMMaps = _loadBalancerVMMapDao.listByInstanceId(vmId);
+            for (LoadBalancerVMMapVO map : loadBalancerVMMaps) {
+                long lbId = map.getLoadBalancerId();
+                FirewallRuleVO rule = _rulesDao.findById(lbId);
+                if (oldIp.equals(map.getInstanceIp()) && networkId == rule.getNetworkId()) {
+                    map.setInstanceIp(newIp);
+                    _loadBalancerVMMapDao.persist(map);
+                }
+            }
+        }
+    }
+
+    private void updatePortForwardingRulesVmIp(long vmId, long networkId, String oldIp, String newIp) {
+        if (_networkModel.areServicesSupportedInNetwork(networkId, Service.PortForwarding)) {
+            List<PortForwardingRuleVO> firewallRules = _portForwardingDao.listByVm(vmId);
+            for (PortForwardingRuleVO firewallRule : firewallRules) {
+                FirewallRuleVO rule = _rulesDao.findById(firewallRule.getId());
+                if (oldIp.equals(firewallRule.getDestinationIpAddress().toString()) && networkId == rule.getNetworkId()) {
+                    firewallRule.setDestinationIpAddress(new Ip(newIp));
+                    _portForwardingDao.persist(firewallRule);
+                }
+            }
+        }

Review comment:
       We could invert the `if` logic and add a return to reduce indentation.

##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -1826,6 +1801,45 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
         return vm;
     }
 
+    private void updatePublicIpDnatVmIp(long vmId, long networkId, String oldIp, String newIp) {
+        if (_networkModel.areServicesSupportedInNetwork(networkId, Service.StaticNat)) {
+            List<IPAddressVO> publicIps = _ipAddressDao.listByAssociatedVmId(vmId);
+            for (IPAddressVO publicIp : publicIps) {
+                if (oldIp.equals(publicIp.getVmIp()) && publicIp.getAssociatedWithNetworkId() == networkId) {
+                    publicIp.setVmIp(newIp);
+                    _ipAddressDao.persist(publicIp);
+                }
+            }
+        }
+    }
+
+    private void updateLoadBalancerRulesVmIp(long vmId, long networkId, String oldIp, String newIp) {
+        if (_networkModel.areServicesSupportedInNetwork(networkId, Service.Lb)) {
+            List<LoadBalancerVMMapVO> loadBalancerVMMaps = _loadBalancerVMMapDao.listByInstanceId(vmId);
+            for (LoadBalancerVMMapVO map : loadBalancerVMMaps) {
+                long lbId = map.getLoadBalancerId();
+                FirewallRuleVO rule = _rulesDao.findById(lbId);
+                if (oldIp.equals(map.getInstanceIp()) && networkId == rule.getNetworkId()) {
+                    map.setInstanceIp(newIp);
+                    _loadBalancerVMMapDao.persist(map);
+                }
+            }
+        }

Review comment:
       We could invert the `if` logic and add a return to reduce indentation.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-988899969


   @blueorangutan test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on a change in pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on a change in pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#discussion_r768401561



##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -1747,38 +1748,12 @@ public UserVm updateNicIpForVirtualMachine(UpdateVmNicIpCmd cmd) {
                 throw new InvalidParameterValueException("Allocating ip to guest nic " + nicVO.getUuid() + " failed, please choose another ip");
             }
 
-            if (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.StaticNat)) {
-                IPAddressVO oldIP = _ipAddressDao.findByAssociatedVmId(vm.getId());
-                if (oldIP != null) {
-                    oldIP.setVmIp(ipaddr);
-                    _ipAddressDao.persist(oldIP);
-                }
+            if (nicVO.getIPv4Address() != null) {
+                updatePublicIpDnatVmIp(vm.getId(), network.getId(), nicVO.getIPv4Address(), ipaddr);
+                updateLoadBalancerRulesVmIp(vm.getId(), network.getId(), nicVO.getIPv4Address(), ipaddr);
+                updatePortForwardingRulesVmIp(vm.getId(), network.getId(), nicVO.getIPv4Address(), ipaddr);
             }
-            // implementing the network elements and resources as a part of vm nic ip update if network has services and it is in Implemented state
-            if (!_networkModel.listNetworkOfferingServices(offering.getId()).isEmpty() && network.getState() == Network.State.Implemented) {
-                User callerUser = _accountMgr.getActiveUser(CallContext.current().getCallingUserId());
-                ReservationContext context = new ReservationContextImpl(null, null, callerUser, caller);
-                DeployDestination dest = new DeployDestination(_dcDao.findById(network.getDataCenterId()), null, null, null);
 
-                s_logger.debug("Implementing the network " + network + " elements and resources as a part of vm nic ip update");
-                try {
-                    // implement the network elements and rules again
-                    _networkMgr.implementNetworkElementsAndResources(dest, context, network, offering);

Review comment:
       @sureshanaparti 
   it is not needed. 
   the network rules in VR will be updated when vm is started.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti commented on a change in pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on a change in pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#discussion_r768339657



##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -1747,38 +1748,12 @@ public UserVm updateNicIpForVirtualMachine(UpdateVmNicIpCmd cmd) {
                 throw new InvalidParameterValueException("Allocating ip to guest nic " + nicVO.getUuid() + " failed, please choose another ip");
             }
 
-            if (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.StaticNat)) {
-                IPAddressVO oldIP = _ipAddressDao.findByAssociatedVmId(vm.getId());
-                if (oldIP != null) {
-                    oldIP.setVmIp(ipaddr);
-                    _ipAddressDao.persist(oldIP);
-                }
+            if (nicVO.getIPv4Address() != null) {
+                updatePublicIpDnatVmIp(vm.getId(), network.getId(), nicVO.getIPv4Address(), ipaddr);
+                updateLoadBalancerRulesVmIp(vm.getId(), network.getId(), nicVO.getIPv4Address(), ipaddr);
+                updatePortForwardingRulesVmIp(vm.getId(), network.getId(), nicVO.getIPv4Address(), ipaddr);
             }
-            // implementing the network elements and resources as a part of vm nic ip update if network has services and it is in Implemented state
-            if (!_networkModel.listNetworkOfferingServices(offering.getId()).isEmpty() && network.getState() == Network.State.Implemented) {
-                User callerUser = _accountMgr.getActiveUser(CallContext.current().getCallingUserId());
-                ReservationContext context = new ReservationContextImpl(null, null, callerUser, caller);
-                DeployDestination dest = new DeployDestination(_dcDao.findById(network.getDataCenterId()), null, null, null);
 
-                s_logger.debug("Implementing the network " + network + " elements and resources as a part of vm nic ip update");
-                try {
-                    // implement the network elements and rules again
-                    _networkMgr.implementNetworkElementsAndResources(dest, context, network, offering);

Review comment:
       @weizhouapache is this call not required while updating nic?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti removed a comment on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
sureshanaparti removed a comment on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-993270727


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-999478873


   @weizhouapache a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache removed a comment on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache removed a comment on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-999589634


   @blueorangutan test
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache removed a comment on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache removed a comment on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-999623381


   @blueorangutan package
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-988814203


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-989794527


   @blueorangutan test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-988857738


   @blueorangutan package
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-999535975


   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 1988


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti commented on a change in pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on a change in pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#discussion_r768408320



##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -1747,38 +1748,12 @@ public UserVm updateNicIpForVirtualMachine(UpdateVmNicIpCmd cmd) {
                 throw new InvalidParameterValueException("Allocating ip to guest nic " + nicVO.getUuid() + " failed, please choose another ip");
             }
 
-            if (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.StaticNat)) {
-                IPAddressVO oldIP = _ipAddressDao.findByAssociatedVmId(vm.getId());
-                if (oldIP != null) {
-                    oldIP.setVmIp(ipaddr);
-                    _ipAddressDao.persist(oldIP);
-                }
+            if (nicVO.getIPv4Address() != null) {
+                updatePublicIpDnatVmIp(vm.getId(), network.getId(), nicVO.getIPv4Address(), ipaddr);
+                updateLoadBalancerRulesVmIp(vm.getId(), network.getId(), nicVO.getIPv4Address(), ipaddr);
+                updatePortForwardingRulesVmIp(vm.getId(), network.getId(), nicVO.getIPv4Address(), ipaddr);
             }
-            // implementing the network elements and resources as a part of vm nic ip update if network has services and it is in Implemented state
-            if (!_networkModel.listNetworkOfferingServices(offering.getId()).isEmpty() && network.getState() == Network.State.Implemented) {
-                User callerUser = _accountMgr.getActiveUser(CallContext.current().getCallingUserId());
-                ReservationContext context = new ReservationContextImpl(null, null, callerUser, caller);
-                DeployDestination dest = new DeployDestination(_dcDao.findById(network.getDataCenterId()), null, null, null);
 
-                s_logger.debug("Implementing the network " + network + " elements and resources as a part of vm nic ip update");
-                try {
-                    // implement the network elements and rules again
-                    _networkMgr.implementNetworkElementsAndResources(dest, context, network, offering);

Review comment:
       ok, thanks for the confirmation @weizhouapache 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-1000595412


   <b>Trillian test result (tid-2734)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 34691 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr5757-t2734-kvm-centos7.zip
   Smoke tests completed. 90 look OK, 0 have errors
   Only failed tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti merged pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
sureshanaparti merged pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache removed a comment on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache removed a comment on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-999694849


   @blueorangutan test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-999547222


   @blueorangutan package
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache removed a comment on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache removed a comment on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-999617678






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-1000178136


   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-988814448


   @weizhouapache a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] DaanHoogland commented on a change in pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on a change in pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#discussion_r765543450



##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -1748,35 +1749,33 @@ public UserVm updateNicIpForVirtualMachine(UpdateVmNicIpCmd cmd) {
             }
 
             if (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.StaticNat)) {
-                IPAddressVO oldIP = _ipAddressDao.findByAssociatedVmId(vm.getId());
-                if (oldIP != null) {
-                    oldIP.setVmIp(ipaddr);
-                    _ipAddressDao.persist(oldIP);
+                List<IPAddressVO> publicIps = _ipAddressDao.listByAssociatedVmId(vm.getId());
+                for (IPAddressVO publicIp : publicIps) {
+                    if (nicVO.getIPv4Address().equals(publicIp.getVmIp() ) && publicIp.getAssociatedWithNetworkId() == network.getId()) {
+                        publicIp.setVmIp(ipaddr);
+                        _ipAddressDao.persist(publicIp);
+                    }
                 }
             }
-            // implementing the network elements and resources as a part of vm nic ip update if network has services and it is in Implemented state
-            if (!_networkModel.listNetworkOfferingServices(offering.getId()).isEmpty() && network.getState() == Network.State.Implemented) {
-                User callerUser = _accountMgr.getActiveUser(CallContext.current().getCallingUserId());
-                ReservationContext context = new ReservationContextImpl(null, null, callerUser, caller);
-                DeployDestination dest = new DeployDestination(_dcDao.findById(network.getDataCenterId()), null, null, null);
-
-                s_logger.debug("Implementing the network " + network + " elements and resources as a part of vm nic ip update");
-                try {
-                    // implement the network elements and rules again
-                    _networkMgr.implementNetworkElementsAndResources(dest, context, network, offering);
-                } catch (Exception ex) {
-                    s_logger.warn("Failed to implement network " + network + " elements and resources as a part of vm nic ip update due to ", ex);
-                    CloudRuntimeException e = new CloudRuntimeException("Failed to implement network (with specified id) elements and resources as a part of vm nic ip update");
-                    e.addProxyObject(network.getUuid(), "networkId");
-                    // restore to old ip address
-                    if (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.StaticNat)) {
-                        IPAddressVO oldIP = _ipAddressDao.findByAssociatedVmId(vm.getId());
-                        if (oldIP != null) {
-                            oldIP.setVmIp(nicVO.getIPv4Address());
-                            _ipAddressDao.persist(oldIP);
-                        }
+            if (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.Lb)) {
+                List<LoadBalancerVMMapVO> loadBalancerVMMaps = _loadBalancerVMMapDao.listByInstanceId(vm.getId());
+                for (LoadBalancerVMMapVO map : loadBalancerVMMaps) {
+                    long lbId = map.getLoadBalancerId();
+                    FirewallRuleVO rule = _rulesDao.findById(lbId);
+                    if (nicVO.getIPv4Address().equals(map.getInstanceIp()) && network.getId() == rule.getNetworkId()) {
+                        map.setInstanceIp(ipaddr);
+                        _loadBalancerVMMapDao.persist(map);
+                    }
+                }
+            }
+            if (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.PortForwarding)) {
+                List<PortForwardingRuleVO> firewallRules = _portForwardingDao.listByVm(vm.getId());
+                for (PortForwardingRuleVO firewallRule : firewallRules) {
+                    FirewallRuleVO rule = _rulesDao.findById(firewallRule.getId());
+                    if (nicVO.getIPv4Address().equals(firewallRule.getDestinationIpAddress().toString()) && network.getId() == rule.getNetworkId()) {
+                        firewallRule.setDestinationIpAddress(new Ip(ipaddr));
+                        _portForwardingDao.persist(firewallRule);

Review comment:
       can we factor these out in twoo separate methods, please @weizhouapache ?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-989725410


   @weizhouapache a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-999625306


   @weizhouapache a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-1000227822


   Packaging result: :heavy_multiplication_x: el7 :heavy_multiplication_x: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 2002


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-1000127957


   @blueorangutan package
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-999547577


   @weizhouapache a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] weizhouapache commented on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-999694849


   @blueorangutan test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti removed a comment on pull request #5757: network: update ip in lb/pf/dnat tables when update vm nic ip

Posted by GitBox <gi...@apache.org>.
sureshanaparti removed a comment on pull request #5757:
URL: https://github.com/apache/cloudstack/pull/5757#issuecomment-1000122313


   @blueorangutan test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org