use of com.cloud.legacymodel.domain.Domain in project cosmic by MissionCriticalCloud.
the class ApiResponseHelper method createLBHealthCheckPolicyResponse.
@Override
public LBHealthCheckResponse createLBHealthCheckPolicyResponse(final List<? extends HealthCheckPolicy> healthcheckPolicies, final LoadBalancer lb) {
final LBHealthCheckResponse hcResponse = new LBHealthCheckResponse();
if (lb == null) {
return hcResponse;
}
hcResponse.setlbRuleId(lb.getUuid());
final Account account = ApiDBUtils.findAccountById(lb.getAccountId());
if (account != null) {
hcResponse.setAccountName(account.getAccountName());
final Domain domain = ApiDBUtils.findDomainById(account.getDomainId());
if (domain != null) {
hcResponse.setDomainId(domain.getUuid());
hcResponse.setDomainName(domain.getName());
}
}
final List<LBHealthCheckPolicyResponse> responses = new ArrayList<>();
for (final HealthCheckPolicy healthcheckPolicy : healthcheckPolicies) {
final LBHealthCheckPolicyResponse ruleResponse = new LBHealthCheckPolicyResponse(healthcheckPolicy);
responses.add(ruleResponse);
}
hcResponse.setRules(responses);
hcResponse.setObjectName("healthcheckpolicies");
return hcResponse;
}
use of com.cloud.legacymodel.domain.Domain in project cosmic by MissionCriticalCloud.
the class ApiResponseHelper method createTemplatePermissionsResponse.
@Override
public TemplatePermissionsResponse createTemplatePermissionsResponse(final ResponseView view, final List<String> accountNames, final Long id) {
Long templateOwnerDomain = null;
final VirtualMachineTemplate template = ApiDBUtils.findTemplateById(id);
final Account templateOwner = ApiDBUtils.findAccountById(template.getAccountId());
if (view == ResponseView.Full) {
// from that
if (templateOwner != null) {
templateOwnerDomain = templateOwner.getDomainId();
}
}
final TemplatePermissionsResponse response = new TemplatePermissionsResponse();
response.setId(template.getUuid());
response.setPublicTemplate(template.isPublicTemplate());
if (view == ResponseView.Full && templateOwnerDomain != null) {
final Domain domain = ApiDBUtils.findDomainById(templateOwnerDomain);
if (domain != null) {
response.setDomainId(domain.getUuid());
}
}
// Set accounts
final List<String> projectIds = new ArrayList<>();
final List<String> regularAccounts = new ArrayList<>();
for (final String accountName : accountNames) {
final Account account = ApiDBUtils.findAccountByNameDomain(accountName, templateOwner.getDomainId());
if (account.getType() != Account.ACCOUNT_TYPE_PROJECT) {
regularAccounts.add(accountName);
} else {
// convert account to projectIds
final Project project = ApiDBUtils.findProjectByProjectAccountId(account.getId());
if (project.getUuid() != null && !project.getUuid().isEmpty()) {
projectIds.add(project.getUuid());
} else {
projectIds.add(String.valueOf(project.getId()));
}
}
}
if (!projectIds.isEmpty()) {
response.setProjectIds(projectIds);
}
if (!regularAccounts.isEmpty()) {
response.setAccountNames(regularAccounts);
}
response.setObjectName("templatepermission");
return response;
}
use of com.cloud.legacymodel.domain.Domain in project cosmic by MissionCriticalCloud.
the class DomainDaoImpl method getDomainParentIds.
@Override
public Set<Long> getDomainParentIds(final long domainId) {
final Set<Long> parentDomains = new HashSet<>();
Domain domain = findById(domainId);
if (domain != null) {
parentDomains.add(domain.getId());
while (domain.getParent() != null) {
domain = findById(domain.getParent());
parentDomains.add(domain.getId());
}
}
return parentDomains;
}
use of com.cloud.legacymodel.domain.Domain in project cosmic by MissionCriticalCloud.
the class ApiResponseHelper method createVlanIpRangeResponse.
@Override
public VlanIpRangeResponse createVlanIpRangeResponse(final Vlan vlan) {
final Long podId = ApiDBUtils.getPodIdForVlan(vlan.getId());
final VlanIpRangeResponse vlanResponse = new VlanIpRangeResponse();
vlanResponse.setId(vlan.getUuid());
if (vlan.getVlanType() != null) {
vlanResponse.setForVirtualNetwork(vlan.getVlanType().equals(VlanType.VirtualNetwork));
}
vlanResponse.setVlan(vlan.getVlanTag());
final DataCenter zone = ApiDBUtils.findZoneById(vlan.getDataCenterId());
if (zone != null) {
vlanResponse.setZoneId(zone.getUuid());
}
if (podId != null) {
final HostPodVO pod = ApiDBUtils.findPodById(podId);
if (pod != null) {
vlanResponse.setPodId(pod.getUuid());
vlanResponse.setPodName(pod.getName());
}
}
vlanResponse.setGateway(vlan.getVlanGateway());
vlanResponse.setNetmask(vlan.getVlanNetmask());
// get start ip and end ip of corresponding vlan
final String ipRange = vlan.getIpRange();
if (ipRange != null) {
final String[] range = ipRange.split("-");
vlanResponse.setStartIp(range[0]);
vlanResponse.setEndIp(range[1]);
}
vlanResponse.setIp6Gateway(vlan.getIp6Gateway());
vlanResponse.setIp6Cidr(vlan.getIp6Cidr());
final String ip6Range = vlan.getIp6Range();
if (ip6Range != null) {
final String[] range = ip6Range.split("-");
vlanResponse.setStartIpv6(range[0]);
vlanResponse.setEndIpv6(range[1]);
}
if (vlan.getNetworkId() != null) {
final Network nw = ApiDBUtils.findNetworkById(vlan.getNetworkId());
if (nw != null) {
vlanResponse.setNetworkId(nw.getUuid());
}
}
final Account owner = ApiDBUtils.getVlanAccount(vlan.getId());
if (owner != null) {
populateAccount(vlanResponse, owner.getId());
populateDomain(vlanResponse, owner.getDomainId());
} else {
final Domain domain = ApiDBUtils.getVlanDomain(vlan.getId());
if (domain != null) {
populateDomain(vlanResponse, domain.getId());
} else {
final Long networkId = vlan.getNetworkId();
if (networkId != null) {
final Network network = this._ntwkModel.getNetwork(networkId);
if (network != null) {
final Long accountId = network.getAccountId();
populateAccount(vlanResponse, accountId);
populateDomain(vlanResponse, ApiDBUtils.findAccountById(accountId).getDomainId());
}
}
}
}
if (vlan.getPhysicalNetworkId() != null) {
final PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(vlan.getPhysicalNetworkId());
if (pnw != null) {
vlanResponse.setPhysicalNetworkId(pnw.getUuid());
}
}
vlanResponse.setObjectName("vlan");
return vlanResponse;
}
use of com.cloud.legacymodel.domain.Domain in project cosmic by MissionCriticalCloud.
the class ApiResponseHelper method createLBStickinessPolicyResponse.
@Override
public LBStickinessResponse createLBStickinessPolicyResponse(final StickinessPolicy stickinessPolicy, final LoadBalancer lb) {
final LBStickinessResponse spResponse = new LBStickinessResponse();
spResponse.setlbRuleId(lb.getUuid());
final Account accountTemp = ApiDBUtils.findAccountById(lb.getAccountId());
if (accountTemp != null) {
spResponse.setAccountName(accountTemp.getAccountName());
final Domain domain = ApiDBUtils.findDomainById(accountTemp.getDomainId());
if (domain != null) {
spResponse.setDomainId(domain.getUuid());
spResponse.setDomainName(domain.getName());
}
}
final List<LBStickinessPolicyResponse> responses = new ArrayList<>();
final LBStickinessPolicyResponse ruleResponse = new LBStickinessPolicyResponse(stickinessPolicy);
responses.add(ruleResponse);
spResponse.setRules(responses);
spResponse.setObjectName("stickinesspolicies");
return spResponse;
}
Aggregations