From e256a3a0372036f5b8091e47627b82128bc4461e Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 8 Dec 2010 18:36:43 -0800 Subject: [PATCH] bug 7448: add forVirtualNetwork parameter to ListVLANIpRange. (by Alena) --- .../cloud/api/commands/ListVlanIpRangesCmd.java | 14 +++++++++++--- .../com/cloud/server/ManagementServerImpl.java | 16 ++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/api/src/com/cloud/api/commands/ListVlanIpRangesCmd.java b/api/src/com/cloud/api/commands/ListVlanIpRangesCmd.java index a4cc7a81c9f..4bfcdf2e796 100644 --- a/api/src/com/cloud/api/commands/ListVlanIpRangesCmd.java +++ b/api/src/com/cloud/api/commands/ListVlanIpRangesCmd.java @@ -26,6 +26,7 @@ import com.cloud.api.ApiConstants; import com.cloud.api.BaseListCmd; import com.cloud.api.Implementation; import com.cloud.api.Parameter; +import com.cloud.api.BaseCmd.CommandType; import com.cloud.api.response.ListResponse; import com.cloud.api.response.VlanIpRangeResponse; import com.cloud.dc.Vlan; @@ -60,6 +61,9 @@ public class ListVlanIpRangesCmd extends BaseListCmd { @Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.LONG, description="network id of the VLAN IP range") private Long networkId; + + @Parameter(name=ApiConstants.FOR_VIRTUAL_NETWORK, type=CommandType.BOOLEAN, description="true if VLAN is of Virtual type, false if Direct") + private Boolean forVirtualNetwork; ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// @@ -92,13 +96,17 @@ public class ListVlanIpRangesCmd extends BaseListCmd { public Long getNetworkId() { return networkId; } + + public Boolean getForVirtualNetwork() { + return forVirtualNetwork; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// - - - @Override + + @Override public String getName() { return s_name; } diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 679847c1da0..359f1f2344f 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -1390,6 +1390,9 @@ public class ManagementServerImpl implements ManagementServer { Long domainId = cmd.getDomainId(); Long accountId = null; Long networkId = cmd.getNetworkId(); + Boolean forVirtual = cmd.getForVirtualNetwork(); + String vlanType = null; + if (accountName != null && domainId != null) { Account account = _accountDao.findActiveAccount(accountName, domainId); if (account == null) { @@ -1398,6 +1401,14 @@ public class ManagementServerImpl implements ManagementServer { accountId = account.getId(); } } + + if (forVirtual != null) { + if (forVirtual) { + vlanType = VlanType.VirtualNetwork.toString(); + } else { + vlanType = VlanType.DirectAttached.toString(); + } + } Filter searchFilter = new Filter(VlanVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal()); @@ -1411,7 +1422,9 @@ public class ManagementServerImpl implements ManagementServer { sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ); sb.and("vlan", sb.entity().getVlanId(), SearchCriteria.Op.EQ); sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ); + sb.and("vlan", sb.entity().getVlanId(), SearchCriteria.Op.EQ); sb.and("networkId", sb.entity().getNetworkId(), SearchCriteria.Op.EQ); + sb.and("vlanType", sb.entity().getVlanType(), SearchCriteria.Op.EQ); if (accountId != null) { SearchBuilder accountVlanMapSearch = _accountVlanMapDao.createSearchBuilder(); @@ -1455,6 +1468,9 @@ public class ManagementServerImpl implements ManagementServer { if (podId != null) { sc.setJoinParameters("podVlanMapSearch", "podId", podId); } + if (vlanType != null) { + sc.setParameters("vlanType", vlanType); + } } return _vlanDao.search(sc, searchFilter);