Search in sources :

Example 1 with SecurityGroupRuleVO

use of com.cloud.network.security.SecurityGroupRuleVO in project cloudstack by apache.

the class SecurityGroupRuleDaoImpl method remove.

@Override
@DB
public boolean remove(Long id) {
    TransactionLegacy txn = TransactionLegacy.currentTxn();
    txn.start();
    SecurityGroupRuleVO entry = findById(id);
    if (entry != null) {
        _tagsDao.removeByIdAndType(id, ResourceObjectType.SecurityGroupRule);
    }
    boolean result = super.remove(id);
    txn.commit();
    return result;
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) SecurityGroupRuleVO(com.cloud.network.security.SecurityGroupRuleVO) DB(com.cloud.utils.db.DB)

Example 2 with SecurityGroupRuleVO

use of com.cloud.network.security.SecurityGroupRuleVO 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

SecurityGroupRuleVO (com.cloud.network.security.SecurityGroupRuleVO)2 PartOf (com.cloud.domain.PartOf)1 OwnedBy (com.cloud.user.OwnedBy)1 Pair (com.cloud.utils.Pair)1 DB (com.cloud.utils.db.DB)1 TransactionLegacy (com.cloud.utils.db.TransactionLegacy)1