VPC: fixed listPublicIpAddresses for the addresses with NULL network_id

Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/519c4929
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/519c4929
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/519c4929

Branch: refs/heads/vpc
Commit: 519c4929bf71b022b0ef5790df9604435879f289
Parents: d51719d
Author: Alena Prokharchyk <[email protected]>
Authored: Tue Jul 17 17:09:25 2012 -0700
Committer: Alena Prokharchyk <[email protected]>
Committed: Tue Jul 17 17:12:00 2012 -0700

----------------------------------------------------------------------
 .../src/com/cloud/server/ManagementServerImpl.java |   17 ++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/519c4929/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java 
b/server/src/com/cloud/server/ManagementServerImpl.java
index 53f6672..e79a75f 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<NicVO> 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<IPAddressVO> 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);

Reply via email to