Search in sources :

Example 66 with AccountVO

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

the class DedicatedResourceManagerImpl method createDedicateClusterResponse.

@Override
public DedicateClusterResponse createDedicateClusterResponse(DedicatedResources resource) {
    DedicateClusterResponse dedicateClusterResponse = new DedicateClusterResponse();
    ClusterVO cluster = _clusterDao.findById(resource.getClusterId());
    DomainVO domain = _domainDao.findById(resource.getDomainId());
    AccountVO account = _accountDao.findById(resource.getAccountId());
    AffinityGroup group = _affinityGroupDao.findById(resource.getAffinityGroupId());
    dedicateClusterResponse.setId(resource.getUuid());
    dedicateClusterResponse.setClusterId(cluster.getUuid());
    dedicateClusterResponse.setClusterName(cluster.getName());
    dedicateClusterResponse.setDomainId(domain.getUuid());
    dedicateClusterResponse.setAffinityGroupId(group.getUuid());
    if (account != null) {
        dedicateClusterResponse.setAccountId(account.getUuid());
    }
    dedicateClusterResponse.setObjectName("dedicatedcluster");
    return dedicateClusterResponse;
}
Also used : DomainVO(com.cloud.domain.DomainVO) ClusterVO(com.cloud.dc.ClusterVO) DedicateClusterResponse(org.apache.cloudstack.api.response.DedicateClusterResponse) AccountVO(com.cloud.user.AccountVO) AffinityGroup(org.apache.cloudstack.affinity.AffinityGroup)

Example 67 with AccountVO

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

the class DedicatedResourceManagerImpl method createDedicateHostResponse.

@Override
public DedicateHostResponse createDedicateHostResponse(DedicatedResources resource) {
    DedicateHostResponse dedicateHostResponse = new DedicateHostResponse();
    HostVO host = _hostDao.findById(resource.getHostId());
    DomainVO domain = _domainDao.findById(resource.getDomainId());
    AccountVO account = _accountDao.findById(resource.getAccountId());
    AffinityGroup group = _affinityGroupDao.findById(resource.getAffinityGroupId());
    dedicateHostResponse.setId(resource.getUuid());
    dedicateHostResponse.setHostId(host.getUuid());
    dedicateHostResponse.setHostName(host.getName());
    dedicateHostResponse.setDomainId(domain.getUuid());
    dedicateHostResponse.setAffinityGroupId(group.getUuid());
    if (account != null) {
        dedicateHostResponse.setAccountId(account.getUuid());
    }
    dedicateHostResponse.setObjectName("dedicatedhost");
    return dedicateHostResponse;
}
Also used : DomainVO(com.cloud.domain.DomainVO) DedicateHostResponse(org.apache.cloudstack.api.response.DedicateHostResponse) AccountVO(com.cloud.user.AccountVO) HostVO(com.cloud.host.HostVO) AffinityGroup(org.apache.cloudstack.affinity.AffinityGroup)

Example 68 with AccountVO

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

the class ImplicitPlannerTest method initializeForTest.

private void initializeForTest(VirtualMachineProfileImpl vmProfile, DataCenterDeployment plan) {
    DataCenterVO mockDc = mock(DataCenterVO.class);
    VMInstanceVO vm = mock(VMInstanceVO.class);
    UserVmVO userVm = mock(UserVmVO.class);
    ServiceOfferingVO offering = mock(ServiceOfferingVO.class);
    AccountVO account = mock(AccountVO.class);
    when(account.getId()).thenReturn(accountId);
    when(account.getAccountId()).thenReturn(accountId);
    when(vmProfile.getOwner()).thenReturn(account);
    when(vmProfile.getVirtualMachine()).thenReturn(vm);
    when(vmProfile.getId()).thenReturn(12L);
    when(vmDao.findById(12L)).thenReturn(userVm);
    when(userVm.getAccountId()).thenReturn(accountId);
    when(vm.getDataCenterId()).thenReturn(dataCenterId);
    when(dcDao.findById(1L)).thenReturn(mockDc);
    when(plan.getDataCenterId()).thenReturn(dataCenterId);
    when(plan.getClusterId()).thenReturn(null);
    when(plan.getPodId()).thenReturn(null);
    when(configDao.getValue(anyString())).thenReturn("false").thenReturn("CPU");
    // Mock offering details.
    when(vmProfile.getServiceOffering()).thenReturn(offering);
    when(offering.getId()).thenReturn(offeringId);
    when(vmProfile.getServiceOfferingId()).thenReturn(offeringId);
    when(offering.getCpu()).thenReturn(noOfCpusInOffering);
    when(offering.getSpeed()).thenReturn(cpuSpeedInOffering);
    when(offering.getRamSize()).thenReturn(ramInOffering);
    List<Long> clustersWithEnoughCapacity = new ArrayList<Long>();
    clustersWithEnoughCapacity.add(1L);
    clustersWithEnoughCapacity.add(2L);
    clustersWithEnoughCapacity.add(3L);
    when(capacityDao.listClustersInZoneOrPodByHostCapacities(dataCenterId, noOfCpusInOffering * cpuSpeedInOffering, ramInOffering * 1024L * 1024L, Capacity.CAPACITY_TYPE_CPU, true)).thenReturn(clustersWithEnoughCapacity);
    Map<Long, Double> clusterCapacityMap = new HashMap<Long, Double>();
    clusterCapacityMap.put(1L, 2048D);
    clusterCapacityMap.put(2L, 2048D);
    clusterCapacityMap.put(3L, 2048D);
    Pair<List<Long>, Map<Long, Double>> clustersOrderedByCapacity = new Pair<List<Long>, Map<Long, Double>>(clustersWithEnoughCapacity, clusterCapacityMap);
    when(capacityDao.orderClustersByAggregateCapacity(dataCenterId, Capacity.CAPACITY_TYPE_CPU, true)).thenReturn(clustersOrderedByCapacity);
    List<Long> disabledClusters = new ArrayList<Long>();
    List<Long> clustersWithDisabledPods = new ArrayList<Long>();
    when(clusterDao.listDisabledClusters(dataCenterId, null)).thenReturn(disabledClusters);
    when(clusterDao.listClustersWithDisabledPods(dataCenterId)).thenReturn(clustersWithDisabledPods);
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) UserVmVO(com.cloud.vm.UserVmVO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) VMInstanceVO(com.cloud.vm.VMInstanceVO) ServiceOfferingVO(com.cloud.service.ServiceOfferingVO) AccountVO(com.cloud.user.AccountVO) List(java.util.List) ArrayList(java.util.ArrayList) ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) Map(java.util.Map) HashMap(java.util.HashMap) Pair(com.cloud.utils.Pair)

Example 69 with AccountVO

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

the class CommandCreationWorkerTest method testHandle.

@Test
public void testHandle() throws ResourceAllocationException {
    // Prepare
    final BaseAsyncCreateCmd asyncCreateCmd = mock(BaseAsyncCreateCmd.class);
    final Map<String, String> params = new HashMap<String, String>();
    Account account = new AccountVO("testaccount", 1L, "networkdomain", (short) 0, "uuid");
    UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
    CallContext.register(user, account);
    // Execute
    final CommandCreationWorker creationWorker = new CommandCreationWorker();
    creationWorker.handle(new DispatchTask(asyncCreateCmd, params));
    // Assert
    verify(asyncCreateCmd, times(1)).create();
}
Also used : Account(com.cloud.user.Account) UserVO(com.cloud.user.UserVO) HashMap(java.util.HashMap) BaseAsyncCreateCmd(org.apache.cloudstack.api.BaseAsyncCreateCmd) AccountVO(com.cloud.user.AccountVO) Test(org.junit.Test)

Example 70 with AccountVO

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

the class ConfigurationManagerTest method setup.

@Before
public void setup() throws Exception {
    MockitoAnnotations.initMocks(this);
    configurationMgr._accountMgr = _accountMgr;
    configurationMgr._projectMgr = _projectMgr;
    configurationMgr._resourceLimitMgr = _resourceLimitMgr;
    configurationMgr._networkMgr = _networkMgr;
    configurationMgr._accountDao = _accountDao;
    configurationMgr._vlanDao = _vlanDao;
    configurationMgr._accountVlanMapDao = _accountVlanMapDao;
    configurationMgr._domainVlanMapDao = _domainVlanMapDao;
    configurationMgr._publicIpAddressDao = _publicIpAddressDao;
    configurationMgr._zoneDao = _zoneDao;
    configurationMgr._firewallDao = _firewallDao;
    configurationMgr._ipAddrMgr = _ipAddrMgr;
    configurationMgr._networkModel = _networkModel;
    configurationMgr._privateIpAddressDao = _privateIpAddressDao;
    configurationMgr._volumeDao = _volumeDao;
    configurationMgr._hostDao = _hostDao;
    configurationMgr._vmInstanceDao = _vmInstanceDao;
    configurationMgr._clusterDao = _clusterDao;
    configurationMgr._podDao = _podDao;
    configurationMgr._physicalNetworkDao = _physicalNetworkDao;
    Account account = new AccountVO("testaccount", 1, "networkdomain", (short) 0, UUID.randomUUID().toString());
    when(configurationMgr._accountMgr.getAccount(anyLong())).thenReturn(account);
    when(configurationMgr._accountDao.findActiveAccount(anyString(), anyLong())).thenReturn(account);
    when(configurationMgr._accountMgr.getActiveAccountById(anyLong())).thenReturn(account);
    UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
    CallContext.register(user, account);
    when(configurationMgr._publicIpAddressDao.countIPs(anyLong(), anyLong(), anyBoolean())).thenReturn(1);
    doNothing().when(configurationMgr._resourceLimitMgr).checkResourceLimit(any(Account.class), any(ResourceType.class), anyLong());
    when(configurationMgr._accountVlanMapDao.persist(any(AccountVlanMapVO.class))).thenReturn(new AccountVlanMapVO());
    when(configurationMgr._vlanDao.acquireInLockTable(anyLong(), anyInt())).thenReturn(vlan);
    Field dedicateIdField = _dedicatePublicIpRangeClass.getDeclaredField("id");
    dedicateIdField.setAccessible(true);
    dedicateIdField.set(dedicatePublicIpRangesCmd, 1L);
    Field accountNameField = _dedicatePublicIpRangeClass.getDeclaredField("accountName");
    accountNameField.setAccessible(true);
    accountNameField.set(dedicatePublicIpRangesCmd, "accountname");
    Field projectIdField = _dedicatePublicIpRangeClass.getDeclaredField("projectId");
    projectIdField.setAccessible(true);
    projectIdField.set(dedicatePublicIpRangesCmd, null);
    Field domainIdField = _dedicatePublicIpRangeClass.getDeclaredField("domainId");
    domainIdField.setAccessible(true);
    domainIdField.set(dedicatePublicIpRangesCmd, 1L);
    Field releaseIdField = _releasePublicIpRangeClass.getDeclaredField("id");
    releaseIdField.setAccessible(true);
    releaseIdField.set(releasePublicIpRangesCmd, 1L);
}
Also used : Account(com.cloud.user.Account) Field(java.lang.reflect.Field) UserVO(com.cloud.user.UserVO) AccountVlanMapVO(com.cloud.dc.AccountVlanMapVO) ResourceType(com.cloud.configuration.Resource.ResourceType) AccountVO(com.cloud.user.AccountVO) Before(org.junit.Before)

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