weizhouapache commented on code in PR #10641:
URL: https://github.com/apache/cloudstack/pull/10641#discussion_r2394791327


##########
plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java:
##########
@@ -5837,11 +5837,19 @@ protected Answer execute(GetVmIpAddressCommand cmd) {
                 if (toolsStatus == 
VirtualMachineToolsStatus.TOOLS_NOT_INSTALLED) {
                     details += "Vmware tools not installed.";
                 } else {
-                    ip = guestInfo.getIpAddress();
-                    if (ip != null) {
-                        result = true;
+                    var normalizedMac = cmd.getMacAddress().replaceAll("-", 
":");
+                    for(var guestInfoNic : guestInfo.getNet()) {
+                        var normalizedNicMac = 
guestInfoNic.getMacAddress().replaceAll("-", ":");
+                        if (!result && 
normalizedNicMac.equalsIgnoreCase(normalizedMac)) {
+                            result = true;
+                            details = null;
+                            for (var ipAddr : guestInfoNic.getIpAddress()) {
+                                if (cmd.getVmNetworkCidr() == null || 
NetUtils.isIpWithInCidrRange(ipAddr, cmd.getVmNetworkCidr())) {

Review Comment:
   ```suggestion
                                   if (NetUtils.isValidIp4(ipAddr) && 
(cmd.getVmNetworkCidr() == null || NetUtils.isIpWithInCidrRange(ipAddr, 
cmd.getVmNetworkCidr()))) {
   ```



-- 
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]

Reply via email to