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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]