use of com.cloud.legacymodel.domain.Domain in project cosmic by MissionCriticalCloud.
the class QueryManagerImpl method listHAWorkers.
@Override
public ListResponse<HAWorkerResponse> listHAWorkers(final ListHAWorkersCmd cmd) {
final ListResponse<HAWorkerResponse> haWorkerList = new ListResponse<>();
final List<HaWorkVO> haWorkers = _haDao.listAll();
final List<HAWorkerResponse> haWorkerResponses = new ArrayList<>();
haWorkers.stream().filter(haWorker -> {
final Account account = CallContext.current().getCallingAccount();
if (account.getDomainId() == Domain.ROOT_DOMAIN) {
return cmd.getId() == null || (cmd.getId() != null && cmd.getId() == haWorker.getId());
}
// Not a root administrator, check if the user owns the virtual machine
final VirtualMachine virtualMachine = _vmInstanceDao.findByIdIncludingRemoved(haWorker.getInstanceId());
return virtualMachine != null && virtualMachine.getDomainId() == account.getDomainId() && (cmd.getId() == null || (cmd.getId() != null && haWorker.getId() == cmd.getId()));
}).forEach(haWorker -> {
final HAWorkerResponse haWorkerResponse = new HAWorkerResponse();
haWorkerResponse.setObjectName("haworker");
haWorkerResponse.setId(haWorker.getId());
haWorkerResponse.setType(haWorker.getWorkType());
haWorkerResponse.setCreated(haWorker.getCreated());
haWorkerResponse.setStep(haWorker.getStep());
haWorkerResponse.setTaken(haWorker.getDateTaken());
haWorkerResponse.setState(haWorker.getPreviousState());
final VirtualMachine virtualMachine = _vmInstanceDao.findByIdIncludingRemoved(haWorker.getInstanceId());
if (virtualMachine != null) {
haWorkerResponse.setVirtualMachineId(virtualMachine.getUuid());
haWorkerResponse.setVirtualMachineName(virtualMachine.getInstanceName());
haWorkerResponse.setVirtualMachineState(virtualMachine.getState());
final Domain domain = _domainDao.findById(virtualMachine.getDomainId());
if (domain != null) {
haWorkerResponse.setDomainId(domain.getUuid());
haWorkerResponse.setDomainName(domain.getName());
}
}
final Host host = _hostDao.findById(haWorker.getHostId());
if (host != null) {
haWorkerResponse.setHypervisor(host.getName());
}
if (haWorker.getServerId() != null) {
final ManagementServerHost managementServerHost = _mgmtServerHostDao.findByMsid(haWorker.getServerId());
if (managementServerHost != null) {
haWorkerResponse.setManagementServerName(managementServerHost.getName());
}
}
haWorkerResponses.add(haWorkerResponse);
});
haWorkerList.setResponses(haWorkerResponses);
return haWorkerList;
}
use of com.cloud.legacymodel.domain.Domain 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.legacymodel.domain.Domain in project cosmic by MissionCriticalCloud.
the class ApiResponseHelper method createPhysicalNetworkResponse.
@Override
public PhysicalNetworkResponse createPhysicalNetworkResponse(final PhysicalNetwork result) {
final PhysicalNetworkResponse response = new PhysicalNetworkResponse();
final DataCenter zone = ApiDBUtils.findZoneById(result.getDataCenterId());
if (zone != null) {
response.setZoneId(zone.getUuid());
}
response.setNetworkSpeed(result.getSpeed());
response.setVlan(result.getVnetString());
if (result.getDomainId() != null) {
final Domain domain = ApiDBUtils.findDomainById(result.getDomainId());
if (domain != null) {
response.setDomainId(domain.getUuid());
}
}
response.setId(result.getUuid());
if (result.getBroadcastDomainRange() != null) {
response.setBroadcastDomainRange(result.getBroadcastDomainRange().toString());
}
response.setIsolationMethods(result.getIsolationMethods());
response.setTags(result.getTags());
if (result.getState() != null) {
response.setState(result.getState().toString());
}
response.setName(result.getName());
response.setObjectName("physicalnetwork");
return response;
}
use of com.cloud.legacymodel.domain.Domain in project cosmic by MissionCriticalCloud.
the class ApiResponseHelper method createSSHKeyPairResponse.
@Override
public SSHKeyPairResponse createSSHKeyPairResponse(final SSHKeyPair sshkeyPair, final boolean privatekey) {
SSHKeyPairResponse response = new SSHKeyPairResponse(sshkeyPair.getName(), sshkeyPair.getFingerprint());
if (privatekey) {
response = new CreateSSHKeyPairResponse(sshkeyPair.getName(), sshkeyPair.getFingerprint(), sshkeyPair.getPrivateKey());
}
final Account account = ApiDBUtils.findAccountById(sshkeyPair.getAccountId());
response.setAccountName(account.getAccountName());
final Domain domain = ApiDBUtils.findDomainById(sshkeyPair.getDomainId());
response.setDomainId(domain.getUuid());
response.setDomainName(domain.getName());
return response;
}
use of com.cloud.legacymodel.domain.Domain in project cosmic by MissionCriticalCloud.
the class QueryManagerImpl method getVMInfo.
private void getVMInfo(final WhoHasThisAddressResponse response, final NicVO nicVO, final VMInstanceVO vm) {
if (vm != null) {
response.setVmName(vm.getHostName());
response.setVmUuid(vm.getUuid());
response.setVmType(nicVO.getVmType());
final Domain domain = _domainDao.findById(vm.getDomainId());
if (domain != null) {
response.setDomainName(domain.getName());
response.setDomainUuid(domain.getUuid());
}
}
}
Aggregations