use of com.cloud.affinity.AffinityGroupResponse in project cosmic by MissionCriticalCloud.
the class CreateAffinityGroupCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
final AffinityGroup group = _affinityGroupService.getAffinityGroup(getEntityId());
if (group != null) {
final AffinityGroupResponse response = _responseGenerator.createAffinityGroupResponse(group);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create affinity group:" + affinityGroupName);
}
}
use of com.cloud.affinity.AffinityGroupResponse in project cosmic by MissionCriticalCloud.
the class ApiResponseHelper method createAffinityGroupResponse.
@Override
public AffinityGroupResponse createAffinityGroupResponse(final AffinityGroup group) {
final AffinityGroupResponse response = new AffinityGroupResponse();
final Account account = ApiDBUtils.findAccountById(group.getAccountId());
response.setId(group.getUuid());
response.setAccountName(account.getAccountName());
response.setName(group.getName());
response.setType(group.getType());
response.setDescription(group.getDescription());
final Domain domain = ApiDBUtils.findDomainById(account.getDomainId());
if (domain != null) {
response.setDomainId(domain.getUuid());
response.setDomainName(domain.getName());
}
response.setObjectName("affinitygroup");
return response;
}
use of com.cloud.affinity.AffinityGroupResponse in project cosmic by MissionCriticalCloud.
the class AffinityGroupJoinDaoImpl method newAffinityGroupResponse.
@Override
public AffinityGroupResponse newAffinityGroupResponse(final AffinityGroupJoinVO vag) {
final AffinityGroupResponse agResponse = new AffinityGroupResponse();
agResponse.setId(vag.getUuid());
agResponse.setName(vag.getName());
agResponse.setDescription(vag.getDescription());
agResponse.setType(vag.getType());
ApiResponseHelper.populateOwner(agResponse, vag);
// update vm information
final long instanceId = vag.getVmId();
if (instanceId > 0) {
final List<String> vmIdList = new ArrayList<>();
vmIdList.add(vag.getVmUuid());
agResponse.setVMIdList(vmIdList);
}
agResponse.setObjectName("affinitygroup");
return agResponse;
}
use of com.cloud.affinity.AffinityGroupResponse in project cosmic by MissionCriticalCloud.
the class ViewResponseHelper method createAffinityGroupResponses.
public static List<AffinityGroupResponse> createAffinityGroupResponses(final List<AffinityGroupJoinVO> groups) {
final Hashtable<Long, AffinityGroupResponse> vrDataList = new Hashtable<>();
for (final AffinityGroupJoinVO vr : groups) {
AffinityGroupResponse vrData = vrDataList.get(vr.getId());
if (vrData == null) {
// first time encountering this AffinityGroup
vrData = ApiDBUtils.newAffinityGroupResponse(vr);
} else {
// update vms
vrData = ApiDBUtils.fillAffinityGroupDetails(vrData, vr);
}
vrDataList.put(vr.getId(), vrData);
}
return new ArrayList<>(vrDataList.values());
}
use of com.cloud.affinity.AffinityGroupResponse in project cosmic by MissionCriticalCloud.
the class UserVmJoinDaoImpl method setUserVmResponse.
@Override
public UserVmResponse setUserVmResponse(final ResponseView view, final UserVmResponse userVmData, final UserVmJoinVO uvo) {
final long nic_id = uvo.getNicId();
if (nic_id > 0) {
final 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());
final List<NicSecondaryIpVO> secondaryIps = ApiDBUtils.findNicSecondaryIps(uvo.getNicId());
if (secondaryIps != null) {
final List<NicSecondaryIpResponse> ipList = new ArrayList<>();
for (final NicSecondaryIpVO ip : secondaryIps) {
final NicSecondaryIpResponse ipRes = new NicSecondaryIpResponse();
ipRes.setId(ip.getUuid());
ipRes.setIpAddr(ip.getIp4Address());
ipList.add(ipRes);
}
nicResponse.setSecondaryIps(ipList);
}
nicResponse.setObjectName("nic");
userVmData.addNic(nicResponse);
}
final long tag_id = uvo.getTagId();
if (tag_id > 0 && !userVmData.containTag(tag_id)) {
final ResourceTagJoinVO vtag = ApiDBUtils.findResourceTagViewById(tag_id);
if (vtag != null) {
userVmData.addTag(ApiDBUtils.newResourceTagResponse(vtag, false));
}
}
final Long affinityGroupId = uvo.getAffinityGroupId();
if (affinityGroupId != null && affinityGroupId.longValue() != 0) {
final 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;
}
Aggregations