weizhouapache commented on code in PR #7403:
URL: https://github.com/apache/cloudstack/pull/7403#discussion_r1217772408
##########
server/src/main/java/com/cloud/api/ApiResponseHelper.java:
##########
@@ -935,6 +936,38 @@ private boolean isForSystemVms(long vlanId){
return userIpAddresVO != null ? userIpAddresVO.isForSystemVms() :
false;
}
+ private void addVmDetailsInIpResponse(IPAddressResponse response,
IpAddress ipAddress) {
+ if (ipAddress.getAllocatedToAccountId() == Account.ACCOUNT_ID_SYSTEM) {
+ NicVO nic =
ApiDBUtils.findByIp4AddressAndNetworkId(ipAddress.getAddress().toString(),
ipAddress.getNetworkId());
+ if (nic != null) {
+ addSystemVmInfoToIpResponse(nic, response);
+ }
+ }
+ if (ipAddress.getAssociatedWithVmId() != null) {
+ addUserVmDetailsInIpResponse(response, ipAddress);
+ }
+ }
+
+ private void addSystemVmInfoToIpResponse(NicVO nic, IPAddressResponse
ipResponse) {
+ final boolean isAdmin =
Account.Type.ADMIN.equals(CallContext.current().getCallingAccount().getType());
+ VirtualMachine vm = ApiDBUtils.findVMInstanceById(nic.getInstanceId());
+ if (vm != null && isAdmin) {
+ ipResponse.setVirtualMachineId(vm.getUuid());
+ ipResponse.setVirtualMachineName(vm.getHostName());
+ ipResponse.setVirtualMachineType(vm.getType().toString());
+ }
Review Comment:
@shwstppr
looks good, committed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]