mirror of https://github.com/apache/cloudstack.git
api: Add vpc name and uuid to VMs list response (nics) and nics response (#6461)
This commit is contained in:
parent
bfe1697721
commit
1b716960fc
|
|
@ -210,6 +210,14 @@ public class NicResponse extends BaseResponse {
|
|||
this.extraDhcpOptions = extraDhcpOptions;
|
||||
}
|
||||
|
||||
@SerializedName(ApiConstants.VPC_ID)
|
||||
@Param(description = "Id of the vpc to which the nic belongs")
|
||||
private String vpcId;
|
||||
|
||||
@SerializedName(ApiConstants.VPC_NAME)
|
||||
@Param(description = "name of the vpc to which the nic belongs")
|
||||
private String vpcName;
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
|
@ -364,4 +372,20 @@ public class NicResponse extends BaseResponse {
|
|||
public void setIpAddresses(List<String> ipAddresses) {
|
||||
this.ipAddresses = ipAddresses;
|
||||
}
|
||||
|
||||
public String getVpcId() {
|
||||
return vpcId;
|
||||
}
|
||||
|
||||
public void setVpcId(String vpcId) {
|
||||
this.vpcId = vpcId;
|
||||
}
|
||||
|
||||
public String getVpcName() {
|
||||
return vpcName;
|
||||
}
|
||||
|
||||
public void setVpcName(String vpcName) {
|
||||
this.vpcName = vpcName;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ import java.util.stream.Collectors;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.cloud.api.query.dao.UserVmJoinDao;
|
||||
import com.cloud.network.vpc.VpcVO;
|
||||
import org.apache.cloudstack.acl.ControlledEntity;
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
import org.apache.cloudstack.affinity.AffinityGroup;
|
||||
|
|
@ -442,6 +444,8 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
NetworkOfferingDao networkOfferingDao;
|
||||
@Inject
|
||||
Ipv6Service ipv6Service;
|
||||
@Inject
|
||||
UserVmJoinDao userVmJoinDao;
|
||||
|
||||
@Override
|
||||
public UserResponse createUserResponse(User user) {
|
||||
|
|
@ -4318,6 +4322,13 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
response.setNsxLogicalSwitchPort(((NicVO)result).getNsxLogicalSwitchPortUuid());
|
||||
}
|
||||
}
|
||||
|
||||
UserVmJoinVO userVm = userVmJoinDao.findById(vm.getId());
|
||||
if (userVm != null && userVm.getVpcUuid() != null) {
|
||||
response.setVpcId(userVm.getVpcUuid());
|
||||
VpcVO vpc = _entityMgr.findByUuidIncludingRemoved(VpcVO.class, userVm.getVpcUuid());
|
||||
response.setVpcName(vpc.getName());
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ import java.util.stream.Collectors;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.cloud.network.vpc.VpcVO;
|
||||
import com.cloud.network.vpc.dao.VpcDao;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import org.apache.cloudstack.affinity.AffinityGroupResponse;
|
||||
import org.apache.cloudstack.annotation.AnnotationService;
|
||||
|
|
@ -88,6 +90,8 @@ public class UserVmJoinDaoImpl extends GenericDaoBaseWithTagInformation<UserVmJo
|
|||
@Inject
|
||||
private AnnotationDao annotationDao;
|
||||
@Inject
|
||||
private VpcDao vpcDao;
|
||||
@Inject
|
||||
UserStatisticsDao userStatsDao;
|
||||
|
||||
private final SearchBuilder<UserVmJoinVO> VmDetailSearch;
|
||||
|
|
@ -291,6 +295,12 @@ public class UserVmJoinDaoImpl extends GenericDaoBaseWithTagInformation<UserVmJo
|
|||
if (userVm.getGuestType() != null) {
|
||||
nicResponse.setType(userVm.getGuestType().toString());
|
||||
}
|
||||
|
||||
if (userVm.getVpcUuid() != null) {
|
||||
nicResponse.setVpcId(userVm.getVpcUuid());
|
||||
VpcVO vpc = vpcDao.findByUuidIncludingRemoved(userVm.getVpcUuid());
|
||||
nicResponse.setVpcName(vpc.getName());
|
||||
}
|
||||
nicResponse.setIsDefault(userVm.isDefaultNic());
|
||||
nicResponse.setDeviceId(String.valueOf(userVm.getNicDeviceId()));
|
||||
List<NicSecondaryIpVO> secondaryIps = ApiDBUtils.findNicSecondaryIps(userVm.getNicId());
|
||||
|
|
|
|||
Loading…
Reference in New Issue