}
if (details.contains(VMDetails.all) || details.contains(VMDetails.secgrp)) {
Long securityGroupId = userVm.getSecurityGroupId();
if (securityGroupId != null && securityGroupId.longValue() != 0) {
SecurityGroupResponse resp = new SecurityGroupResponse();
resp.setId(userVm.getSecurityGroupUuid());
resp.setName(userVm.getSecurityGroupName());
resp.setDescription(userVm.getSecurityGroupDescription());
resp.setObjectName("securitygroup");
if (userVm.getAccountType() == Account.ACCOUNT_TYPE_PROJECT) {
resp.setProjectId(userVm.getProjectUuid());
resp.setProjectName(userVm.getProjectName());
} else {
resp.setAccountName(userVm.getAccountName());
}
userVmResponse.addSecurityGroup(resp);
}
}
if (details.contains(VMDetails.all) || details.contains(VMDetails.nics)) {
long nic_id = userVm.getNicId();
if (nic_id > 0) {
NicResponse nicResponse = new NicResponse();
nicResponse.setId(userVm.getNicUuid());
nicResponse.setIpaddress(userVm.getIpAddress());
nicResponse.setGateway(userVm.getGateway());
nicResponse.setNetmask(userVm.getNetmask());
nicResponse.setNetworkid(userVm.getNetworkUuid());
nicResponse.setNetworkName(userVm.getNetworkName());
nicResponse.setMacAddress(userVm.getMacAddress());
nicResponse.setIp6Address(userVm.getIp6Address());
nicResponse.setIp6Gateway(userVm.getIp6Gateway());
nicResponse.setIp6Cidr(userVm.getIp6Cidr());
if (userVm.getBroadcastUri() != null) {
nicResponse.setBroadcastUri(userVm.getBroadcastUri().toString());
}
if (userVm.getIsolationUri() != null) {
nicResponse.setIsolationUri(userVm.getIsolationUri().toString());
}
if (userVm.getTrafficType() != null) {
nicResponse.setTrafficType(userVm.getTrafficType().toString());
}
if (userVm.getGuestType() != null) {
nicResponse.setType(userVm.getGuestType().toString());
}
nicResponse.setIsDefault(userVm.isDefaultNic());
List<NicSecondaryIpVO> secondaryIps = ApiDBUtils.findNicSecondaryIps(userVm.getNicId());
if (secondaryIps != null) {
List<NicSecondaryIpResponse> ipList = new ArrayList<NicSecondaryIpResponse>();
for (NicSecondaryIpVO ip : secondaryIps) {
NicSecondaryIpResponse ipRes = new NicSecondaryIpResponse();
ipRes.setId(ip.getUuid());
ipRes.setIpAddr(ip.getIp4Address());
ipList.add(ipRes);
}
nicResponse.setSecondaryIps(ipList);
}
nicResponse.setObjectName("nic");
userVmResponse.addNic(nicResponse);
}
}
// update tag information
long tag_id = userVm.getTagId();
if (tag_id > 0) {
ResourceTagJoinVO vtag = ApiDBUtils.findResourceTagViewById(tag_id);
if ( vtag != null ){
userVmResponse.addTag(ApiDBUtils.newResourceTagResponse(vtag, false));
}
}
if (details.contains(VMDetails.all) || details.contains(VMDetails.affgrp)) {
Long affinityGroupId = userVm.getAffinityGroupId();
if (affinityGroupId != null && affinityGroupId.longValue() != 0) {
AffinityGroupResponse resp = new AffinityGroupResponse();
resp.setId(userVm.getAffinityGroupUuid());
resp.setName(userVm.getAffinityGroupName());
resp.setDescription(userVm.getAffinityGroupDescription());
resp.setObjectName("affinitygroup");
resp.setAccountName(userVm.getAccountName());
userVmResponse.addAffinityGroup(resp);
}
}
// set resource details map