Search in sources :

Example 1 with PartOf

use of com.cloud.domain.PartOf in project cloudstack by apache.

the class TaggedResourceManagerImpl method getAccountDomain.

private Pair<Long, Long> getAccountDomain(long resourceId, ResourceObjectType resourceType) {
    Class<?> clazz = s_typeMap.get(resourceType);
    Object entity = _entityMgr.findById(clazz, resourceId);
    Long accountId = null;
    Long domainId = null;
    // if the resource type is a security group rule, get the accountId and domainId from the security group itself
    if (resourceType == ResourceObjectType.SecurityGroupRule) {
        SecurityGroupRuleVO rule = (SecurityGroupRuleVO) entity;
        Object SecurityGroup = _entityMgr.findById(s_typeMap.get(ResourceObjectType.SecurityGroup), rule.getSecurityGroupId());
        accountId = ((SecurityGroupVO) SecurityGroup).getAccountId();
        domainId = ((SecurityGroupVO) SecurityGroup).getDomainId();
    }
    if (entity instanceof OwnedBy) {
        accountId = ((OwnedBy) entity).getAccountId();
    }
    if (entity instanceof PartOf) {
        domainId = ((PartOf) entity).getDomainId();
    }
    if (accountId == null) {
        accountId = Account.ACCOUNT_ID_SYSTEM;
    }
    if ((domainId == null) || ((accountId != null) && (domainId.longValue() == -1))) {
        domainId = _accountDao.getDomainIdForGivenAccountId(accountId);
    }
    return new Pair<Long, Long>(accountId, domainId);
}
Also used : OwnedBy(com.cloud.user.OwnedBy) SecurityGroupRuleVO(com.cloud.network.security.SecurityGroupRuleVO) PartOf(com.cloud.domain.PartOf) Pair(com.cloud.utils.Pair)

Aggregations

PartOf (com.cloud.domain.PartOf)1 SecurityGroupRuleVO (com.cloud.network.security.SecurityGroupRuleVO)1 OwnedBy (com.cloud.user.OwnedBy)1 Pair (com.cloud.utils.Pair)1