Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,14 @@ public void setExtraDhcpOptions(List<NicExtraDhcpOptionResponse> extraDhcpOption
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;
Expand Down Expand Up @@ -364,4 +372,20 @@ public List<String> getIpAddresses() {
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;
}
}
11 changes: 11 additions & 0 deletions server/src/main/java/com/cloud/api/ApiResponseHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

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;
Expand Down Expand Up @@ -442,6 +444,8 @@ public class ApiResponseHelper implements ResponseGenerator {
NetworkOfferingDao networkOfferingDao;
@Inject
Ipv6Service ipv6Service;
@Inject
UserVmJoinDao userVmJoinDao;

@Override
public UserResponse createUserResponse(User user) {
Expand Down Expand Up @@ -4318,6 +4322,13 @@ public NicResponse createNicResponse(Nic result) {
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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -291,6 +295,12 @@ public UserVmResponse newUserVmResponse(ResponseView view, String objectName, Us
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());
Expand Down