Return trafficType/networkType as a part of Nic information for listSystemVms/listDomainRouters/listUserVms.

This commit is contained in:
alena 2010-12-06 09:43:37 -08:00
parent 619d378095
commit cd8513598f
4 changed files with 65 additions and 2 deletions

View File

@ -104,12 +104,14 @@ public class DomainRouterResponse extends BaseResponse {
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain associated with the router")
private String domainName;
@SerializedName("nics") @Param(description="the list of nics associated with domain router")
private List<NicResponse> nics;
public Long getObjectId() {
return getId();
}
@SerializedName("nics") @Param(description="the list of nics associated with domain router")
private List<NicResponse> nics;
public Long getId() {
return id;

View File

@ -42,6 +42,14 @@ public class NicResponse extends BaseResponse {
@SerializedName("broadcasturi") @Param(description="the broadcast uri of the nic")
private String broadcastUri;
//TODO - add description
@SerializedName("traffictype")
private String trafficType;
//TODO - add description
@SerializedName("type")
private String type;
public Long getId() {
return id;
@ -98,4 +106,20 @@ public class NicResponse extends BaseResponse {
public void setBroadcastUri(String broadcastUri) {
this.broadcastUri = broadcastUri;
}
public String getTrafficType() {
return trafficType;
}
public void setTrafficType(String trafficType) {
this.trafficType = trafficType;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}

View File

@ -31,6 +31,7 @@ import com.cloud.network.LoadBalancerVO;
import com.cloud.network.Network;
import com.cloud.network.NetworkManager;
import com.cloud.network.NetworkRuleConfigVO;
import com.cloud.network.NetworkVO;
import com.cloud.network.dao.IPAddressDao;
import com.cloud.network.dao.LoadBalancerDao;
import com.cloud.network.dao.NetworkDao;
@ -130,6 +131,7 @@ public class ApiDBUtils {
private static VolumeDao _volumeDao;
private static DataCenterDao _zoneDao;
private static NetworkOfferingDao _networkOfferingDao;
private static NetworkDao _networkDao;
static {
_ms = (ManagementServer)ComponentLocator.getComponent(ManagementServer.Name);
@ -171,6 +173,7 @@ public class ApiDBUtils {
_zoneDao = locator.getDao(DataCenterDao.class);
_networkGroupDao = locator.getDao(NetworkGroupDao.class);
_networkOfferingDao = locator.getDao(NetworkOfferingDao.class);
_networkDao = locator.getDao(NetworkDao.class);
// Note: stats collector should already have been initialized by this time, otherwise a null instance is returned
_statsCollector = StatsCollector.getInstance();
@ -501,4 +504,8 @@ public class ApiDBUtils {
return _vlanDao.listVlansByNetworkId(networkId);
}
public static NetworkVO findNetworkById(long id) {
return _networkDao.findById(id);
}
}

View File

@ -1220,6 +1220,16 @@ public class ApiResponseHelper implements ResponseGenerator {
nicResponse.setIsolationUri(singleNic.getIsolationUri().toString());
}
}
//Set traffic type
Network network = ApiDBUtils.findNetworkById(singleNic.getNetworkId());
nicResponse.setTrafficType(network.getTrafficType().toString());
//Set type
NetworkOffering networkOffering = ApiDBUtils.findNetworkOfferingById(network.getNetworkOfferingId());
if (networkOffering.getGuestIpType() != null) {
nicResponse.setType(networkOffering.getGuestIpType().toString());
}
nicResponse.setObjectName("nic");
nicResponses.add(nicResponse);
@ -1269,6 +1279,16 @@ public class ApiResponseHelper implements ResponseGenerator {
nicResponse.setIsolationUri(singleNic.getIsolationUri().toString());
}
//Set traffic type
Network network = ApiDBUtils.findNetworkById(singleNic.getNetworkId());
nicResponse.setTrafficType(network.getTrafficType().toString());
//Set type
NetworkOffering networkOffering = ApiDBUtils.findNetworkOfferingById(network.getNetworkOfferingId());
if (networkOffering.getGuestIpType() != null) {
nicResponse.setType(networkOffering.getGuestIpType().toString());
}
nicResponse.setObjectName("nic");
nicResponses.add(nicResponse);
}
@ -1350,6 +1370,16 @@ public class ApiResponseHelper implements ResponseGenerator {
nicResponse.setIsolationUri(singleNic.getIsolationUri().toString());
}
//Set traffic type
Network network = ApiDBUtils.findNetworkById(singleNic.getNetworkId());
nicResponse.setTrafficType(network.getTrafficType().toString());
//Set type
NetworkOffering networkOffering = ApiDBUtils.findNetworkOfferingById(network.getNetworkOfferingId());
if (networkOffering.getGuestIpType() != null) {
nicResponse.setType(networkOffering.getGuestIpType().toString());
}
nicResponse.setObjectName("nic");
nicResponses.add(nicResponse);
}