bug 7448: add forVirtualNetwork parameter to ListVLANIpRange. (by Alena)

This commit is contained in:
Jessica Wang 2010-12-08 18:36:43 -08:00
parent b285bbb683
commit e256a3a037
2 changed files with 27 additions and 3 deletions

View File

@ -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;
}

View File

@ -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<AccountVlanMapVO> 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);