Search in sources :

Example 61 with AccountVO

use of com.cloud.user.AccountVO in project cloudstack by apache.

the class VpcApiUnitTest method validateNtwkOffForVpcInvalidNoRVRSupport.

//5) Invalid offering - no redundant router support
@Test(expected = InvalidParameterValueException.class)
public void validateNtwkOffForVpcInvalidNoRVRSupport() {
    boolean result = false;
    try {
        _vpcService.validateNtwkOffForNtwkInVpc(2L, 5, "0.0.0.0", "111-", _vo, "10.1.1.1", new AccountVO(), null);
        result = true;
    } finally {
        assertFalse("TEST FAILED, can't use network offering with guest type = Shared", result);
    }
}
Also used : AccountVO(com.cloud.user.AccountVO) Test(org.junit.Test)

Example 62 with AccountVO

use of com.cloud.user.AccountVO in project cloudstack by apache.

the class VpcApiUnitTest method validateNtwkOffForVpcInvalidNoConserveMode.

//3) invalid offering - conserve mode is off
@Test(expected = InvalidParameterValueException.class)
public void validateNtwkOffForVpcInvalidNoConserveMode() {
    boolean result = false;
    try {
        _vpcService.validateNtwkOffForNtwkInVpc(2L, 3, "0.0.0.0", "111-", _vo, "10.1.1.1", new AccountVO(), null);
        result = true;
    } finally {
        assertFalse("Validate network offering: TEST FAILED, can't use network offering without conserve mode = true", result);
    }
}
Also used : AccountVO(com.cloud.user.AccountVO) Test(org.junit.Test)

Example 63 with AccountVO

use of com.cloud.user.AccountVO in project cloudstack by apache.

the class DedicatedResourceManagerImpl method createDedicateZoneResponse.

@Override
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;
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) DomainVO(com.cloud.domain.DomainVO) DedicateZoneResponse(org.apache.cloudstack.api.response.DedicateZoneResponse) AccountVO(com.cloud.user.AccountVO) AffinityGroup(org.apache.cloudstack.affinity.AffinityGroup)

Example 64 with AccountVO

use of com.cloud.user.AccountVO in project cloudstack by apache.

the class DedicatedResourceManagerImpl method findOrCreateDedicatedAffinityGroup.

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);
        accountName = account.getAccountName();
        group = _affinityGroupDao.findByAccountAndType(accountId, "ExplicitDedication");
        if (group != null) {
            return group;
        }
        // default to a groupname with account/domain information
        affinityGroupName = "DedicatedGrp-" + accountName;
    } else {
        // domain level group
        group = _affinityGroupDao.findDomainLevelGroupByType(domainId, "ExplicitDedication");
        if (group != null) {
            return group;
        }
        // default to a groupname with account/domain information
        String domainName = _domainDao.findById(domainId).getName();
        affinityGroupName = "DedicatedGrp-domain-" + domainName;
    }
    group = _affinityGroupService.createAffinityGroup(accountName, null, domainId, affinityGroupName, "ExplicitDedication", "dedicated resources group");
    return group;
}
Also used : AccountVO(com.cloud.user.AccountVO) AffinityGroup(org.apache.cloudstack.affinity.AffinityGroup)

Example 65 with AccountVO

use of com.cloud.user.AccountVO in project cloudstack by apache.

the class DedicatedResourceManagerImpl method createDedicatePodResponse.

@Override
public DedicatePodResponse createDedicatePodResponse(DedicatedResources resource) {
    DedicatePodResponse dedicatePodResponse = new DedicatePodResponse();
    HostPodVO pod = _podDao.findById(resource.getPodId());
    DomainVO domain = _domainDao.findById(resource.getDomainId());
    AccountVO account = _accountDao.findById(resource.getAccountId());
    AffinityGroup group = _affinityGroupDao.findById(resource.getAffinityGroupId());
    dedicatePodResponse.setId(resource.getUuid());
    dedicatePodResponse.setPodId(pod.getUuid());
    dedicatePodResponse.setPodName(pod.getName());
    dedicatePodResponse.setDomainId(domain.getUuid());
    dedicatePodResponse.setAffinityGroupId(group.getUuid());
    if (account != null) {
        dedicatePodResponse.setAccountId(account.getUuid());
    }
    dedicatePodResponse.setObjectName("dedicatedpod");
    return dedicatePodResponse;
}
Also used : DomainVO(com.cloud.domain.DomainVO) DedicatePodResponse(org.apache.cloudstack.api.response.DedicatePodResponse) HostPodVO(com.cloud.dc.HostPodVO) AccountVO(com.cloud.user.AccountVO) AffinityGroup(org.apache.cloudstack.affinity.AffinityGroup)

Aggregations

AccountVO (com.cloud.user.AccountVO)139 Account (com.cloud.user.Account)65 Test (org.junit.Test)52 UserVO (com.cloud.user.UserVO)44 Field (java.lang.reflect.Field)41 ArrayList (java.util.ArrayList)40 DomainVO (com.cloud.domain.DomainVO)32 AccountManager (com.cloud.user.AccountManager)27 Before (org.junit.Before)22 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)21 TransactionLegacy (com.cloud.utils.db.TransactionLegacy)21 Date (java.util.Date)16 QuotaAccountVO (org.apache.cloudstack.quota.vo.QuotaAccountVO)16 DomainDao (com.cloud.domain.dao.DomainDao)14 SslCertDao (com.cloud.network.dao.SslCertDao)14 AgentManager (com.cloud.agent.AgentManager)13 IPAddressDao (com.cloud.network.dao.IPAddressDao)13 LoadBalancerDao (com.cloud.network.dao.LoadBalancerDao)13 NetworkDao (com.cloud.network.dao.NetworkDao)13 NetworkVO (com.cloud.network.dao.NetworkVO)13