Search in sources :

Example 16 with IAMGroup

use of org.apache.cloudstack.iam.api.IAMGroup in project cloudstack by apache.

the class AttachIAMPolicyToIAMGroupCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException {
    CallContext.current().setEventDetails("IAM group Id: " + getId());
    IAMGroup result = _iamApiSrv.attachIAMPoliciesToGroup(policyIdList, id);
    if (result != null) {
        IAMGroupResponse response = _iamApiSrv.createIAMGroupResponse(result);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add roles to iam group");
    }
}
Also used : IAMGroup(org.apache.cloudstack.iam.api.IAMGroup) ServerApiException(org.apache.cloudstack.api.ServerApiException) IAMGroupResponse(org.apache.cloudstack.api.response.iam.IAMGroupResponse)

Example 17 with IAMGroup

use of org.apache.cloudstack.iam.api.IAMGroup in project cloudstack by apache.

the class CreateIAMGroupCmd method execute.

@Override
public void execute() {
    IAMGroup grp = _entityMgr.findById(IAMGroup.class, getEntityId());
    if (grp != null) {
        IAMGroupResponse response = _iamApiSrv.createIAMGroupResponse(grp);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create iam group:" + name);
    }
}
Also used : IAMGroup(org.apache.cloudstack.iam.api.IAMGroup) ServerApiException(org.apache.cloudstack.api.ServerApiException) IAMGroupResponse(org.apache.cloudstack.api.response.iam.IAMGroupResponse)

Example 18 with IAMGroup

use of org.apache.cloudstack.iam.api.IAMGroup in project cloudstack by apache.

the class RemoveIAMPolicyFromIAMGroupCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException {
    CallContext.current().setEventDetails("IAM group Id: " + getId());
    IAMGroup result = _iamApiSrv.removeIAMPoliciesFromGroup(policyIdList, id);
    if (result != null) {
        IAMGroupResponse response = _iamApiSrv.createIAMGroupResponse(result);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add roles to iam group");
    }
}
Also used : IAMGroup(org.apache.cloudstack.iam.api.IAMGroup) ServerApiException(org.apache.cloudstack.api.ServerApiException) IAMGroupResponse(org.apache.cloudstack.api.response.iam.IAMGroupResponse)

Example 19 with IAMGroup

use of org.apache.cloudstack.iam.api.IAMGroup in project cloudstack by apache.

the class IAMApiServiceImpl method createPolicyAndAddToDomainGroup.

private void createPolicyAndAddToDomainGroup(String policyName, String description, String entityType, Long entityId, String action, AccessType accessType, Long domainId, Boolean recursive) {
    Domain domain = _domainDao.findById(domainId);
    if (domain != null) {
        IAMPolicy policy = _iamSrv.createIAMPolicy(policyName, description, null, domain.getPath());
        _iamSrv.addIAMPermissionToIAMPolicy(policy.getId(), entityType, PermissionScope.RESOURCE.toString(), entityId, action, accessType.toString(), Permission.Allow, recursive);
        List<Long> policyList = new ArrayList<Long>();
        policyList.add(new Long(policy.getId()));
        List<IAMGroup> domainGroups = listDomainGroup(domain);
        if (domainGroups != null) {
            for (IAMGroup group : domainGroups) {
                _iamSrv.attachIAMPoliciesToGroup(policyList, group.getId());
            }
        }
    }
}
Also used : IAMGroup(org.apache.cloudstack.iam.api.IAMGroup) IAMPolicy(org.apache.cloudstack.iam.api.IAMPolicy) ArrayList(java.util.ArrayList) Domain(com.cloud.domain.Domain)

Example 20 with IAMGroup

use of org.apache.cloudstack.iam.api.IAMGroup in project cloudstack by apache.

the class IAMServiceImpl method createIAMGroup.

@DB
@Override
public IAMGroup createIAMGroup(String iamGroupName, String description, String path) {
    // check if the group is already existing
    IAMGroup grp = _aclGroupDao.findByName(path, iamGroupName);
    if (grp != null) {
        throw new InvalidParameterValueException("Unable to create acl group with name " + iamGroupName + " already exists for path " + path);
    }
    IAMGroupVO rvo = new IAMGroupVO(iamGroupName, description);
    rvo.setPath(path);
    return _aclGroupDao.persist(rvo);
}
Also used : IAMGroup(org.apache.cloudstack.iam.api.IAMGroup) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) DB(com.cloud.utils.db.DB)

Aggregations

IAMGroup (org.apache.cloudstack.iam.api.IAMGroup)26 ArrayList (java.util.ArrayList)13 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)9 IAMGroupResponse (org.apache.cloudstack.api.response.iam.IAMGroupResponse)9 List (java.util.List)7 DB (com.cloud.utils.db.DB)6 ServerApiException (org.apache.cloudstack.api.ServerApiException)6 IAMPolicy (org.apache.cloudstack.iam.api.IAMPolicy)6 Pair (com.cloud.utils.Pair)5 TransactionCallbackNoReturn (com.cloud.utils.db.TransactionCallbackNoReturn)5 TransactionStatus (com.cloud.utils.db.TransactionStatus)5 IAMGroupVO (org.apache.cloudstack.iam.server.IAMGroupVO)5 Test (org.junit.Test)5 Domain (com.cloud.domain.Domain)3 Account (com.cloud.user.Account)2 AccountVO (com.cloud.user.AccountVO)2 SSHKeyPair (com.cloud.user.SSHKeyPair)1 Filter (com.cloud.utils.db.Filter)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1