weizhouapache commented on a change in pull request #3862: Userdata to display static NAT as public ip instead of VR ip URL: https://github.com/apache/cloudstack/pull/3862#discussion_r381519948
########## File path: server/src/main/java/com/cloud/network/router/CommandSetupHelper.java ########## @@ -1024,18 +1026,21 @@ private VmDataCommand generateVmDataCommand(final VirtualRouter router, final St cmd.addVmData("userdata", "user-data", userData); cmd.addVmData("metadata", "service-offering", StringUtils.unicodeEscape(serviceOffering)); cmd.addVmData("metadata", "availability-zone", StringUtils.unicodeEscape(zoneName)); - cmd.addVmData("metadata", "local-ipv4", guestIpAddress); + cmd.addVmData("metadata", "local-ipv4", vmPrivateIpAddress); cmd.addVmData("metadata", "local-hostname", StringUtils.unicodeEscape(vmName)); - if (dcVo.getNetworkType() == NetworkType.Basic) { - cmd.addVmData("metadata", "public-ipv4", guestIpAddress); + + Network network = _networkDao.findById(guestNetworkId); + if (dcVo.getNetworkType() == NetworkType.Basic || network.getGuestType() == Network.GuestType.Shared) { + cmd.addVmData("metadata", "public-ipv4", vmPrivateIpAddress); cmd.addVmData("metadata", "public-hostname", StringUtils.unicodeEscape(vmName)); } else { - if (router.getPublicIpAddress() == null) { - cmd.addVmData("metadata", "public-ipv4", guestIpAddress); + if (publicIpAddress != null) { + cmd.addVmData("metadata", "public-ipv4", publicIpAddress); + cmd.addVmData("metadata", "public-hostname", publicIpAddress); } else { Review comment: @ravening you missed one check here ``` - } else { + } else if (router.getPublicIpAddress() != null) { ``` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services