This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/master by this push:
new 8e6d8a1 CLOUDSTACK-9542: make listNics and ListUserVms return uniform
NIC data (#2208)
8e6d8a1 is described below
commit 8e6d8a1cf35655523a34f0a3a0266981b447f194
Author: dahn <[email protected]>
AuthorDate: Thu Dec 21 12:21:45 2017 +0000
CLOUDSTACK-9542: make listNics and ListUserVms return uniform NIC data
(#2208)
Makes listNics and ListUserVms return uniform NICs.
---
server/src/com/cloud/api/ApiResponseHelper.java | 76 +++++++++++++++-------
.../com/cloud/api/query/dao/UserVmJoinDaoImpl.java | 41 ++++++++++--
2 files changed, 86 insertions(+), 31 deletions(-)
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java
b/server/src/com/cloud/api/ApiResponseHelper.java
index e714acf..19730d0 100644
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -3594,6 +3594,10 @@ public class ApiResponseHelper implements
ResponseGenerator {
return response;
}
+ /**
+ * The resulting Response attempts to be in line with what is returned from
+ * @see
com.cloud.api.query.dao.UserVmJoinDaoImpl#setUserVmResponse(ResponseView,
UserVmResponse, UserVmJoinVO)
+ */
@Override
public NicResponse createNicResponse(Nic result) {
NicResponse response = new NicResponse();
@@ -3602,30 +3606,63 @@ public class ApiResponseHelper implements
ResponseGenerator {
UserVmJoinVO userVm = _entityMgr.findById(UserVmJoinVO.class,
result.getInstanceId());
List<NicExtraDhcpOptionVO> nicExtraDhcpOptionVOs =
_nicExtraDhcpOptionDao.listByNicId(result.getId());
+ // The numbered comments are to keep track of the data returned from
here and UserVmJoinDaoImpl.setUserVmResponse()
+ // the data can't be identical but some tidying up/unifying might be
possible
+ /*1: nicUuid*/
response.setId(result.getUuid());
+ /*2: networkUuid*/
response.setNetworkid(network.getUuid());
-
+ /*3: vmId*/
if (vm != null) {
response.setVmId(vm.getUuid());
}
if (userVm != null){
if (userVm.getTrafficType() != null) {
+ /*4: trafficType*/
response.setTrafficType(userVm.getTrafficType().toString());
}
if (userVm.getGuestType() != null) {
+ /*5: guestType*/
response.setType(userVm.getGuestType().toString());
}
}
+ /*6: ipAddress*/
response.setIpaddress(result.getIPv4Address());
-
- List<NicExtraDhcpOptionResponse> nicExtraDhcpOptionResponses =
nicExtraDhcpOptionVOs
- .stream()
- .map(vo -> new
NicExtraDhcpOptionResponse(Dhcp.DhcpOptionCode.valueOfInt(vo.getCode()).getName(),
vo.getCode(), vo.getValue()))
- .collect(Collectors.toList());
-
- response.setExtraDhcpOptions(nicExtraDhcpOptionResponses);
-
+ /*7: gateway*/
+ response.setGateway(result.getIPv4Gateway());
+ /*8: netmask*/
+ response.setNetmask(result.getIPv4Netmask());
+ /*9: networkName*/
+ if(userVm != null && userVm.getNetworkName() != null) {
+ response.setNetworkName(userVm.getNetworkName());
+ }
+ /*10: macAddress*/
+ response.setMacAddress(result.getMacAddress());
+ /*11: IPv6Address*/
+ if (result.getIPv6Address() != null) {
+ response.setIp6Address(result.getIPv6Address());
+ }
+ /*12: IPv6Gateway*/
+ if (result.getIPv6Gateway() != null) {
+ response.setIp6Gateway(result.getIPv6Gateway());
+ }
+ /*13: IPv6Cidr*/
+ if (result.getIPv6Cidr() != null) {
+ response.setIp6Cidr(result.getIPv6Cidr());
+ }
+ /*14: deviceId*/
+ response.setDeviceId(String.valueOf(result.getDeviceId()));
+ /*15: broadcastURI*/
+ if (result.getBroadcastUri() != null) {
+ response.setBroadcastUri(result.getBroadcastUri().toString());
+ }
+ /*16: isolationURI*/
+ if (result.getIsolationUri() != null) {
+ response.setIsolationUri(result.getIsolationUri().toString());
+ }
+ /*17: default*/
+ response.setIsDefault(result.isDefaultNic());
if (result.getSecondaryIp()) {
List<NicSecondaryIpVO> secondaryIps =
ApiDBUtils.findNicSecondaryIps(result.getId());
if (secondaryIps != null) {
@@ -3639,22 +3676,13 @@ public class ApiResponseHelper implements
ResponseGenerator {
response.setSecondaryIps(ipList);
}
}
+ /*18: extra dhcp options */
+ List<NicExtraDhcpOptionResponse> nicExtraDhcpOptionResponses =
nicExtraDhcpOptionVOs
+ .stream()
+ .map(vo -> new
NicExtraDhcpOptionResponse(Dhcp.DhcpOptionCode.valueOfInt(vo.getCode()).getName(),
vo.getCode(), vo.getValue()))
+ .collect(Collectors.toList());
- response.setGateway(result.getIPv4Gateway());
- response.setNetmask(result.getIPv4Netmask());
- response.setMacAddress(result.getMacAddress());
-
- if (result.getIPv6Address() != null) {
- response.setIp6Address(result.getIPv6Address());
- }
-
- if (result.getIPv6Cidr() != null) {
- response.setIp6Cidr(result.getIPv6Cidr());
- }
-
- response.setDeviceId(String.valueOf(result.getDeviceId()));
-
- response.setIsDefault(result.isDefaultNic());
+ response.setExtraDhcpOptions(nicExtraDhcpOptionResponses);
if (result instanceof NicVO){
if (((NicVO)result).getNsxLogicalSwitchUuid() != null){
diff --git a/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
b/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
index c0eb222..f0a0a56 100644
--- a/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
@@ -324,6 +324,10 @@ public class UserVmJoinDaoImpl extends
GenericDaoBaseWithTagInformation<UserVmJo
return userVmResponse;
}
+ /**
+ * The resulting Response attempts to be in line with what is returned from
+ * @see com.cloud.api.ApiResponseHelper#createNicResponse(Nic)
+ */
@Override
public UserVmResponse setUserVmResponse(ResponseView view, UserVmResponse
userVmData, UserVmJoinVO uvo) {
Long securityGroupId = uvo.getSecurityGroupId();
@@ -345,28 +349,50 @@ public class UserVmJoinDaoImpl extends
GenericDaoBaseWithTagInformation<UserVmJo
long nic_id = uvo.getNicId();
if (nic_id > 0) {
NicResponse nicResponse = new NicResponse();
+ // The numbered comments are to keep track of the data returned
from here and ApiResponseHelper.createNicResponse()
+ // the data can't be identical but some tidying up/unifying might
be possible
+ /*1: nicUuid*/
nicResponse.setId(uvo.getNicUuid());
+ /*2: networkUuid*/
+ nicResponse.setNetworkid(uvo.getNetworkUuid());
+ /*3: vmId makes no sense on a nested nic object so it is ommited
here */
+
+ if (uvo.getTrafficType() != null) {
+ /*4: trafficType*/
+ nicResponse.setTrafficType(uvo.getTrafficType().toString());
+ }
+ if (uvo.getGuestType() != null) {
+ /*5: guestType*/
+ nicResponse.setType(uvo.getGuestType().toString());
+ }
+ /*6: ipAddress*/
nicResponse.setIpaddress(uvo.getIpAddress());
+ /*7: gateway*/
nicResponse.setGateway(uvo.getGateway());
+ /*8: netmask*/
nicResponse.setNetmask(uvo.getNetmask());
- nicResponse.setNetworkid(uvo.getNetworkUuid());
+ /*9: networkName*/
nicResponse.setNetworkName(uvo.getNetworkName());
+ /*10: macAddress*/
nicResponse.setMacAddress(uvo.getMacAddress());
+ /*11: IPv6Address*/
nicResponse.setIp6Address(uvo.getIp6Address());
+ /*12: IPv6Gateway*/
nicResponse.setIp6Gateway(uvo.getIp6Gateway());
+ /*13: IPv6Cidr*/
nicResponse.setIp6Cidr(uvo.getIp6Cidr());
+ /*14: deviceId*/
+// where do we find nicResponse.setDeviceId(
+// this is probably not String.valueOf(uvo.getNicId())); as this is a db-id
+ /*15: broadcastURI*/
if (uvo.getBroadcastUri() != null) {
nicResponse.setBroadcastUri(uvo.getBroadcastUri().toString());
}
+ /*16: isolationURI*/
if (uvo.getIsolationUri() != null) {
nicResponse.setIsolationUri(uvo.getIsolationUri().toString());
}
- if (uvo.getTrafficType() != null) {
- nicResponse.setTrafficType(uvo.getTrafficType().toString());
- }
- if (uvo.getGuestType() != null) {
- nicResponse.setType(uvo.getGuestType().toString());
- }
+ /*17: default*/
nicResponse.setIsDefault(uvo.isDefaultNic());
List<NicSecondaryIpVO> secondaryIps =
ApiDBUtils.findNicSecondaryIps(uvo.getNicId());
if (secondaryIps != null) {
@@ -380,6 +406,7 @@ public class UserVmJoinDaoImpl extends
GenericDaoBaseWithTagInformation<UserVmJo
nicResponse.setSecondaryIps(ipList);
}
+ /* 18: extra dhcp options */
nicResponse.setObjectName("nic");
List<NicExtraDhcpOptionResponse> nicExtraDhcpOptionResponses =
_nicExtraDhcpOptionDao.listByNicId(nic_id)
.stream()
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].