mirror of https://github.com/apache/cloudstack.git
CS-15999: added nics to domain router api response
This commit is contained in:
parent
93b0b11a79
commit
44fd5108f3
|
|
@ -13,6 +13,7 @@
|
|||
package com.cloud.api.response;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.serializer.Param;
|
||||
|
|
@ -136,6 +137,10 @@ public class DomainRouterResponse extends BaseResponse implements ControlledEnti
|
|||
@SerializedName(ApiConstants.VPC_ID) @Param(description="VPC the network belongs to")
|
||||
private IdentityProxy vpcId = new IdentityProxy("vpc");
|
||||
|
||||
@SerializedName("nic") @Param(description="the list of nics associated with the router",
|
||||
responseObject = NicResponse.class, since="3.0.1")
|
||||
private List<NicResponse> nics;
|
||||
|
||||
@Override
|
||||
public Long getObjectId() {
|
||||
return getId();
|
||||
|
|
@ -308,4 +313,8 @@ public class DomainRouterResponse extends BaseResponse implements ControlledEnti
|
|||
public void setVpcId(Long vpcId) {
|
||||
this.vpcId.setValue(vpcId);
|
||||
}
|
||||
|
||||
public void setNics(List<NicResponse> nics) {
|
||||
this.nics = nics;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,7 +128,6 @@ import com.cloud.dc.Vlan.VlanType;
|
|||
import com.cloud.dc.VlanVO;
|
||||
import com.cloud.domain.Domain;
|
||||
import com.cloud.event.Event;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostStats;
|
||||
import com.cloud.host.HostVO;
|
||||
|
|
@ -1710,8 +1709,10 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
}
|
||||
routerResponse.setPodId(router.getPodIdToDeployIn());
|
||||
List<NicProfile> nicProfiles = ApiDBUtils.getNics(router);
|
||||
List<NicResponse> nicResponses = new ArrayList<NicResponse>();
|
||||
for (NicProfile singleNicProfile : nicProfiles) {
|
||||
Network network = ApiDBUtils.findNetworkById(singleNicProfile.getNetworkId());
|
||||
//legacy code, public/control/guest nic info is kept in nics response object
|
||||
if (network != null) {
|
||||
if (network.getTrafficType() == TrafficType.Public) {
|
||||
routerResponse.setPublicIp(singleNicProfile.getIp4Address());
|
||||
|
|
@ -1731,8 +1732,32 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
routerResponse.setGuestNetworkId(singleNicProfile.getNetworkId());
|
||||
routerResponse.setNetworkDomain(network.getNetworkDomain());
|
||||
}
|
||||
|
||||
NicResponse nicResponse = new NicResponse();
|
||||
nicResponse.setId(singleNicProfile.getId());
|
||||
nicResponse.setIpaddress(singleNicProfile.getIp4Address());
|
||||
nicResponse.setGateway(singleNicProfile.getGateway());
|
||||
nicResponse.setNetmask(singleNicProfile.getNetmask());
|
||||
nicResponse.setNetworkid(singleNicProfile.getNetworkId());
|
||||
nicResponse.setNetworkName(network.getName());
|
||||
|
||||
if (singleNicProfile.getBroadCastUri() != null) {
|
||||
nicResponse.setBroadcastUri(singleNicProfile.getBroadCastUri().toString());
|
||||
}
|
||||
if (singleNicProfile.getIsolationUri() != null) {
|
||||
nicResponse.setIsolationUri(singleNicProfile.getIsolationUri().toString());
|
||||
}
|
||||
|
||||
nicResponse.setTrafficType(network.getTrafficType().toString());
|
||||
if (network.getGuestType() != null) {
|
||||
nicResponse.setType(network.getGuestType().toString());
|
||||
}
|
||||
nicResponse.setIsDefault(singleNicProfile.isDefaultNic());
|
||||
nicResponse.setObjectName("nic");
|
||||
nicResponses.add(nicResponse);
|
||||
}
|
||||
}
|
||||
routerResponse.setNics(nicResponses);
|
||||
}
|
||||
|
||||
// Service Offering Info
|
||||
|
|
|
|||
Loading…
Reference in New Issue