@Override
public UserVmResponse setUserVmResponse(UserVmResponse userVmData, UserVmJoinVO uvo) {
Long securityGroupId = uvo.getSecurityGroupId();
if (securityGroupId != null && securityGroupId.longValue() != 0) {
SecurityGroupResponse resp = new SecurityGroupResponse();
resp.setId(uvo.getSecurityGroupUuid());
resp.setName(uvo.getSecurityGroupName());
resp.setDescription(uvo.getSecurityGroupDescription());
resp.setObjectName("securitygroup");
if (uvo.getAccountType() == Account.ACCOUNT_TYPE_PROJECT) {
resp.setProjectId(uvo.getProjectUuid());
resp.setProjectName(uvo.getProjectName());
} else {
resp.setAccountName(uvo.getAccountName());
}
userVmData.addSecurityGroup(resp);
}
long nic_id = uvo.getNicId();
if (nic_id > 0) {
NicResponse nicResponse = new NicResponse();
nicResponse.setId(uvo.getNicUuid());
nicResponse.setIpaddress(uvo.getIpAddress());
nicResponse.setGateway(uvo.getGateway());
nicResponse.setNetmask(uvo.getNetmask());
nicResponse.setNetworkid(uvo.getNetworkUuid());
nicResponse.setNetworkName(uvo.getNetworkName());
nicResponse.setMacAddress(uvo.getMacAddress());
nicResponse.setIp6Address(uvo.getIp6Address());
nicResponse.setIp6Gateway(uvo.getIp6Gateway());
nicResponse.setIp6Cidr(uvo.getIp6Cidr());
if (uvo.getBroadcastUri() != null) {
nicResponse.setBroadcastUri(uvo.getBroadcastUri().toString());
}
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());
}
nicResponse.setIsDefault(uvo.isDefaultNic());
nicResponse.setObjectName("nic");
userVmData.addNic(nicResponse);
}
long tag_id = uvo.getTagId();
if (tag_id > 0) {
ResourceTagJoinVO vtag = ApiDBUtils.findResourceTagViewById(tag_id);
if ( vtag != null ){
userVmData.addTag(ApiDBUtils.newResourceTagResponse(vtag, false));
}
}
Long affinityGroupId = uvo.getAffinityGroupId();
if (affinityGroupId != null && affinityGroupId.longValue() != 0) {
AffinityGroupResponse resp = new AffinityGroupResponse();
resp.setId(uvo.getAffinityGroupUuid());
resp.setName(uvo.getAffinityGroupName());
resp.setDescription(uvo.getAffinityGroupDescription());
resp.setObjectName("affinitygroup");
resp.setAccountName(uvo.getAccountName());
userVmData.addAffinityGroup(resp);
}
return userVmData;
}