From 519c4929bf71b022b0ef5790df9604435879f289 Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Tue, 17 Jul 2012 17:09:25 -0700 Subject: [PATCH] VPC: fixed listPublicIpAddresses for the addresses with NULL network_id --- .../com/cloud/server/ManagementServerImpl.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 53f6672d7df..e79a75f8cba 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -227,6 +227,7 @@ import com.cloud.utils.db.JoinBuilder; import com.cloud.utils.db.JoinBuilder.JoinType; import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; +import com.cloud.utils.db.SearchCriteria.Op; import com.cloud.utils.db.Transaction; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.net.MacAddress; @@ -1782,8 +1783,18 @@ public class ManagementServerImpl implements ManagementServer { } // don't show SSVM/CPVM ips + boolean omitSystemVmIps = false; if (vlanType == VlanType.VirtualNetwork && (allocatedOnly) && vpcId == null) { - sb.and("associatedNetworkId", sb.entity().getAssociatedWithNetworkId(), SearchCriteria.Op.NNULL); + + SearchBuilder nonSystemVmSearch = _nicDao.createSearchBuilder(); + nonSystemVmSearch.and().op("vmTypeNnull", nonSystemVmSearch.entity().getVmType(), Op.NULL); + nonSystemVmSearch.or("vmType", nonSystemVmSearch.entity().getVmType(), Op.NOTIN); + nonSystemVmSearch.cp(); + sb.join("nonSystemVms", nonSystemVmSearch, sb.entity().getAddress(), + nonSystemVmSearch.entity().getIp4Address(), JoinType.LEFTOUTER); +// sb.and().join("nonSystemVms", nonSystemVmSearch, sb.entity().getSourceNetworkId(), +// nonSystemVmSearch.entity().getNetworkId(), JoinType.INNER); + omitSystemVmIps = true; } SearchCriteria sc = sb.create(); @@ -1800,6 +1811,10 @@ public class ManagementServerImpl implements ManagementServer { count++; } } + + if (omitSystemVmIps) { + sc.setJoinParameters("nonSystemVms", "vmType", VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm); + } if (zone != null) { sc.setParameters("dataCenterId", zone);