Examples of AffinityGroup


Examples of org.apache.cloudstack.affinity.AffinityGroup

        return response;
    }

    @Override
    public Long getAffinityGroupId(String groupName, long accountId) {
        AffinityGroup ag = ApiDBUtils.getAffinityGroup(groupName, accountId);
        if (ag == null) {
            return null;
        } else {
            return ag.getId();
        }
    }
View Full Code Here

Examples of org.apache.cloudstack.affinity.AffinityGroup

    @Override
    public boolean checkAccess(Account caller, ControlledEntity entity, AccessType accessType)
            throws PermissionDeniedException {
        if (entity instanceof AffinityGroup) {
            AffinityGroup group = (AffinityGroup) entity;

            if (_affinityGroupService.isAdminControlledGroup(group)) {
                if (accessType != null && accessType == AccessType.ModifyEntry
                        && !_accountMgr.isRootAdmin(caller.getType())) {
                    throw new PermissionDeniedException(caller + " does not have permission to operate with resource "
                            + entity);
                }
            }

            if (group.getAclType() == ACLType.Domain) {
                if (!_affinityGroupService.isAffinityGroupAvailableInDomain(group.getId(), caller.getDomainId())) {
                    throw new PermissionDeniedException("Affinity group is not available in domain id="
                            + caller.getDomainId());
                } else {
                    return true;
                }
            } else {
                //acl_type account
                if (caller.getId() != group.getAccountId()) {
                      throw new PermissionDeniedException(caller
                      + " does not have permission to operate with resource " + entity);
                }else{
                    return true;
                }
View Full Code Here

Examples of org.apache.cloudstack.affinity.AffinityGroup

        checkHostsSuitabilityForExplicitDedication(accountId, childDomainIds, hosts);

        Transaction txn = Transaction.currentTxn();
        txn.start();
        // find or create the affinity group by name under this account/domain
        AffinityGroup group = findOrCreateDedicatedAffinityGroup(domainId, accountId);
        if (group == null) {
            s_logger.error("Unable to dedicate zone due to, failed to create dedication affinity group");
            throw new CloudRuntimeException("Failed to dedicate zone. Please contact Cloud Support.");
        }

        DedicatedResourceVO dedicatedResource = new DedicatedResourceVO(zoneId, null, null, null, null, null,
                group.getId());
        try {
            dedicatedResource.setDomainId(domainId);
            if (accountId != null) {
                dedicatedResource.setAccountId(accountId);
            }
View Full Code Here

Examples of org.apache.cloudstack.affinity.AffinityGroup

        checkHostsSuitabilityForExplicitDedication(accountId, childDomainIds, hosts);

        Transaction txn = Transaction.currentTxn();
        txn.start();
        // find or create the affinity group by name under this account/domain
        AffinityGroup group = findOrCreateDedicatedAffinityGroup(domainId, accountId);
        if (group == null) {
            s_logger.error("Unable to dedicate zone due to, failed to create dedication affinity group");
            throw new CloudRuntimeException("Failed to dedicate zone. Please contact Cloud Support.");
        }
        DedicatedResourceVO dedicatedResource = new DedicatedResourceVO(null, podId, null, null, null, null,
                group.getId());
        try {
            dedicatedResource.setDomainId(domainId);
            if (accountId != null) {
                dedicatedResource.setAccountId(accountId);
            }
View Full Code Here

Examples of org.apache.cloudstack.affinity.AffinityGroup

        checkHostsSuitabilityForExplicitDedication(accountId, childDomainIds, hosts);

        Transaction txn = Transaction.currentTxn();
        txn.start();
        // find or create the affinity group by name under this account/domain
        AffinityGroup group = findOrCreateDedicatedAffinityGroup(domainId, accountId);
        if (group == null) {
            s_logger.error("Unable to dedicate zone due to, failed to create dedication affinity group");
            throw new CloudRuntimeException("Failed to dedicate zone. Please contact Cloud Support.");
        }
        DedicatedResourceVO dedicatedResource = new DedicatedResourceVO(null, null, clusterId, null, null, null,
                group.getId());
        try {
            dedicatedResource.setDomainId(domainId);
            if (accountId != null) {
                dedicatedResource.setAccountId(accountId);
            }
View Full Code Here

Examples of org.apache.cloudstack.affinity.AffinityGroup

        checkHostSuitabilityForExplicitDedication(accountId, childDomainIds, hostId);

        Transaction txn = Transaction.currentTxn();
        txn.start();
        // find or create the affinity group by name under this account/domain
        AffinityGroup group = findOrCreateDedicatedAffinityGroup(domainId, accountId);
        if (group == null) {
            s_logger.error("Unable to dedicate zone due to, failed to create dedication affinity group");
            throw new CloudRuntimeException("Failed to dedicate zone. Please contact Cloud Support.");
        }
        DedicatedResourceVO dedicatedResource = new DedicatedResourceVO(null, null, null, hostId, null, null,
                group.getId());
        try {
            dedicatedResource.setDomainId(domainId);
            if (accountId != null) {
                dedicatedResource.setAccountId(accountId);
            }
View Full Code Here

Examples of org.apache.cloudstack.affinity.AffinityGroup

                                          // are tracked
    }

    @Override
    public void execute() {
        AffinityGroup group = _affinityGroupService.getAffinityGroup(getEntityId());
        if (group != null) {
            AffinityGroupResponse response = _responseGenerator.createAffinityGroupResponse(group);
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
View Full Code Here

Examples of org.apache.cloudstack.affinity.AffinityGroup

        }
    }

    @Override
    public void create() throws ResourceAllocationException {
        AffinityGroup result = _affinityGroupService.createAffinityGroup(accountName, domainId, affinityGroupName,
                affinityGroupType, description);
        if (result != null) {
            setEntityId(result.getId());
            setEntityUuid(result.getUuid());
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create affinity group entity" + affinityGroupName);
        }

    }
View Full Code Here

Examples of org.apache.cloudstack.affinity.AffinityGroup

    private AffinityGroup findOrCreateDedicatedAffinityGroup(Long domainId, Long accountId) {
        if(domainId == null){
            return null;
        }

        AffinityGroup group = null;
        String accountName = null;
        String affinityGroupName = null;

        if (accountId != null) {
            AccountVO account = _accountDao.findById(accountId);
View Full Code Here

Examples of org.apache.cloudstack.affinity.AffinityGroup

    public DedicateZoneResponse createDedicateZoneResponse(DedicatedResources resource) {
        DedicateZoneResponse dedicateZoneResponse = new DedicateZoneResponse();
        DataCenterVO dc = _zoneDao.findById(resource.getDataCenterId());
        DomainVO domain = _domainDao.findById(resource.getDomainId());
        AccountVO account = _accountDao.findById(resource.getAccountId());
        AffinityGroup group = _affinityGroupDao.findById(resource.getAffinityGroupId());
        dedicateZoneResponse.setId(resource.getUuid());
        dedicateZoneResponse.setZoneId(dc.getUuid());
        dedicateZoneResponse.setZoneName(dc.getName());
        dedicateZoneResponse.setDomainId(domain.getUuid());
        dedicateZoneResponse.setAffinityGroupId(group.getUuid());
        if (account != null) {
            dedicateZoneResponse.setAccountId(account.getUuid());
        }
        dedicateZoneResponse.setObjectName("dedicatedzone");
        return dedicateZoneResponse;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.