mirror of https://github.com/apache/cloudstack.git
bug 8340: return networkId for private/public/guest networks in listRouters response. Implemented search by networkId
status 8340: resolved fixed
This commit is contained in:
parent
8bcd5a2934
commit
9aa9c34029
|
|
@ -62,6 +62,9 @@ public class ListRoutersCmd extends BaseListCmd {
|
|||
|
||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="the Zone ID of the router")
|
||||
private Long zoneId;
|
||||
|
||||
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.LONG, description="list by network id")
|
||||
private Long networkId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
|
|
@ -94,6 +97,10 @@ public class ListRoutersCmd extends BaseListCmd {
|
|||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public Long getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ 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.UserVmResponse;
|
||||
import com.cloud.async.AsyncJob;
|
||||
|
|
|
|||
|
|
@ -66,6 +66,9 @@ public class DomainRouterResponse extends BaseResponse {
|
|||
|
||||
@SerializedName("privatenetmask") @Param(description="the private netmask for the router")
|
||||
private String privateNetmask;
|
||||
|
||||
@SerializedName("privatenetworkid") @Param(description="the ID of the corresponding private network")
|
||||
private Long privateNetworkId;
|
||||
|
||||
@SerializedName(ApiConstants.PUBLIC_IP) @Param(description="the public IP address for the router")
|
||||
private String publicIp;
|
||||
|
|
@ -75,6 +78,9 @@ public class DomainRouterResponse extends BaseResponse {
|
|||
|
||||
@SerializedName("publicnetmask") @Param(description="the public netmask for the router")
|
||||
private String publicNetmask;
|
||||
|
||||
@SerializedName("publicnetworkid") @Param(description="the ID of the corresponding public network")
|
||||
private Long publicNetworkId;
|
||||
|
||||
@SerializedName("guestipaddress") @Param(description="the guest IP address for the router")
|
||||
private String guestIpAddress;
|
||||
|
|
@ -84,6 +90,10 @@ public class DomainRouterResponse extends BaseResponse {
|
|||
|
||||
@SerializedName("guestnetmask") @Param(description="the guest netmask for the router")
|
||||
private String guestNetmask;
|
||||
|
||||
@SerializedName("guestnetworkid") @Param(description="the ID of the corresponding guest network")
|
||||
private Long guestNetworkId;
|
||||
|
||||
|
||||
@SerializedName("templateid") @Param(description="the template ID for the router")
|
||||
private Long templateId;
|
||||
|
|
@ -103,6 +113,8 @@ public class DomainRouterResponse extends BaseResponse {
|
|||
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain associated with the router")
|
||||
private String domainName;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Long getObjectId() {
|
||||
|
|
@ -316,4 +328,28 @@ public class DomainRouterResponse extends BaseResponse {
|
|||
public void setDomainName(String domainName) {
|
||||
this.domainName = domainName;
|
||||
}
|
||||
|
||||
public Long getPrivateNetworkId() {
|
||||
return privateNetworkId;
|
||||
}
|
||||
|
||||
public void setPrivateNetworkId(Long privateNetworkId) {
|
||||
this.privateNetworkId = privateNetworkId;
|
||||
}
|
||||
|
||||
public Long getPublicNetworkId() {
|
||||
return publicNetworkId;
|
||||
}
|
||||
|
||||
public void setPublicNetworkId(Long publicNetworkId) {
|
||||
this.publicNetworkId = publicNetworkId;
|
||||
}
|
||||
|
||||
public Long getGuestNetworkId() {
|
||||
return guestNetworkId;
|
||||
}
|
||||
|
||||
public void setGuestNetworkId(Long guestNetworkId) {
|
||||
this.guestNetworkId = guestNetworkId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1164,14 +1164,17 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
routerResponse.setPublicMacAddress(singleNicProfile.getMacAddress());
|
||||
routerResponse.setPublicNetmask(singleNicProfile.getNetmask());
|
||||
routerResponse.setGateway(singleNicProfile.getGateway());
|
||||
routerResponse.setPublicNetworkId(singleNicProfile.getNetworkId());
|
||||
} else if (network.getTrafficType() == TrafficType.Control) {
|
||||
routerResponse.setPrivateIp(singleNicProfile.getIp4Address());
|
||||
routerResponse.setPrivateMacAddress(singleNicProfile.getMacAddress());
|
||||
routerResponse.setPrivateNetmask(singleNicProfile.getNetmask());
|
||||
routerResponse.setPrivateNetworkId(singleNicProfile.getNetworkId());
|
||||
} else if (network.getTrafficType() == TrafficType.Guest) {
|
||||
routerResponse.setGuestIpAddress(singleNicProfile.getIp4Address());
|
||||
routerResponse.setGuestMacAddress(singleNicProfile.getMacAddress());
|
||||
routerResponse.setGuestNetmask(singleNicProfile.getNetmask());
|
||||
routerResponse.setGuestNetworkId(singleNicProfile.getNetworkId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class PortForwardingRuleVO extends FirewallRuleVO implements PortForwardi
|
|||
}
|
||||
|
||||
public PortForwardingRuleVO(String xId, long srcIpId, int srcPort, Ip dstIp, int dstPort, String protocol, long networkId, long accountId, long domainId, long instanceId, boolean isOneToOneNat) {
|
||||
this(xId, srcIpId, srcPort, srcPort, dstIp, dstPort, dstPort, protocol, networkId, accountId, domainId, instanceId, isOneToOneNat);
|
||||
this(xId, srcIpId, srcPort, srcPort, dstIp, dstPort, dstPort, protocol.toLowerCase(), networkId, accountId, domainId, instanceId, isOneToOneNat);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||
dstIp,
|
||||
rule.getDestinationPortStart(),
|
||||
rule.getDestinationPortEnd(),
|
||||
rule.getProtocol(),
|
||||
rule.getProtocol().toLowerCase(),
|
||||
networkId,
|
||||
accountId,
|
||||
domainId, vmId, isNat);
|
||||
|
|
|
|||
|
|
@ -182,7 +182,9 @@ import com.cloud.host.dao.HostDao;
|
|||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.info.ConsoleProxyInfo;
|
||||
import com.cloud.network.IPAddressVO;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.router.VirtualNetworkApplianceManager;
|
||||
import com.cloud.network.security.SecurityGroupVO;
|
||||
import com.cloud.network.security.dao.SecurityGroupDao;
|
||||
|
|
@ -259,6 +261,7 @@ import com.cloud.utils.ssh.SSHKeysHelper;
|
|||
import com.cloud.vm.ConsoleProxyVO;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.InstanceGroupVO;
|
||||
import com.cloud.vm.NicVO;
|
||||
import com.cloud.vm.SecondaryStorageVmVO;
|
||||
import com.cloud.vm.UserVmManager;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
|
|
@ -268,6 +271,7 @@ import com.cloud.vm.VirtualMachine.State;
|
|||
import com.cloud.vm.dao.ConsoleProxyDao;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.InstanceGroupDao;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
import com.cloud.vm.dao.SecondaryStorageVmDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
|
@ -311,6 +315,8 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
private final GuestOSCategoryDao _guestOSCategoryDao;
|
||||
private final StoragePoolDao _poolDao;
|
||||
private final StoragePoolHostDao _poolHostDao;
|
||||
private final NicDao _nicDao;
|
||||
private final NetworkDao _networkDao;
|
||||
private final StorageManager _storageMgr;
|
||||
|
||||
private final Adapters<UserAuthenticator> _userAuthenticators;
|
||||
|
|
@ -358,6 +364,8 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
_hostPodDao = locator.getDao(HostPodDao.class);
|
||||
_jobDao = locator.getDao(AsyncJobDao.class);
|
||||
_clusterDao = locator.getDao(ClusterDao.class);
|
||||
_nicDao = locator.getDao(NicDao.class);
|
||||
_networkDao = locator.getDao(NetworkDao.class);
|
||||
|
||||
_accountMgr = locator.getManager(AccountManager.class);
|
||||
_agentMgr = locator.getManager(AgentManager.class);
|
||||
|
|
@ -2145,6 +2153,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
Object pod = cmd.getPodId();
|
||||
Object hostId = cmd.getHostId();
|
||||
Object keyword = cmd.getKeyword();
|
||||
Object networkId = cmd.getNetworkId();
|
||||
|
||||
SearchBuilder<DomainRouterVO> sb = _routerDao.createSearchBuilder();
|
||||
sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE);
|
||||
|
|
@ -2160,6 +2169,17 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
domainSearch.and("path", domainSearch.entity().getPath(), SearchCriteria.Op.LIKE);
|
||||
sb.join("domainSearch", domainSearch, sb.entity().getDomainId(), domainSearch.entity().getId(), JoinBuilder.JoinType.INNER);
|
||||
}
|
||||
|
||||
if (networkId != null) {
|
||||
SearchBuilder<NicVO> nicSearch = _nicDao.createSearchBuilder();
|
||||
nicSearch.and("networkId", nicSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
|
||||
|
||||
SearchBuilder<NetworkVO> networkSearch = _networkDao.createSearchBuilder();
|
||||
networkSearch.and("networkId", networkSearch.entity().getId(), SearchCriteria.Op.EQ);
|
||||
nicSearch.join("networkSearch", networkSearch, nicSearch.entity().getNetworkId(), networkSearch.entity().getId(), JoinBuilder.JoinType.INNER);
|
||||
|
||||
sb.join("nicSearch", nicSearch, sb.entity().getId(), nicSearch.entity().getInstanceId(), JoinBuilder.JoinType.INNER);
|
||||
}
|
||||
|
||||
SearchCriteria<DomainRouterVO> sc = sb.create();
|
||||
if (keyword != null) {
|
||||
|
|
@ -2194,6 +2214,10 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
if (hostId != null) {
|
||||
sc.setParameters("hostId", hostId);
|
||||
}
|
||||
|
||||
if (networkId != null) {
|
||||
sc.setJoinParameters("nicSearch", "networkId", networkId);
|
||||
}
|
||||
|
||||
return _routerDao.search(sc, searchFilter);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,7 +107,6 @@ import com.cloud.ha.HighAvailabilityManager;
|
|||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.DetailsDao;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.IPAddressVO;
|
||||
import com.cloud.network.Network;
|
||||
|
|
|
|||
Loading…
Reference in New Issue