当前位置: 首页>>代码示例>>Java>>正文


Java VirtualMachineProfileImpl类代码示例

本文整理汇总了Java中com.cloud.vm.VirtualMachineProfileImpl的典型用法代码示例。如果您正苦于以下问题:Java VirtualMachineProfileImpl类的具体用法?Java VirtualMachineProfileImpl怎么用?Java VirtualMachineProfileImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


VirtualMachineProfileImpl类属于com.cloud.vm包,在下文中一共展示了VirtualMachineProfileImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkWhenDcInAvoidList

import com.cloud.vm.VirtualMachineProfileImpl; //导入依赖的package包/类
@Test
public void checkWhenDcInAvoidList() throws InsufficientServerCapacityException {
    final Zone zone = mock(Zone.class);
    final ExcludeList avoids = mock(ExcludeList.class);
    final VirtualMachineProfileImpl vmProfile = mock(VirtualMachineProfileImpl.class);
    final VMInstanceVO vm = mock(VMInstanceVO.class);
    final DataCenterDeployment plan = mock(DataCenterDeployment.class);

    when(avoids.shouldAvoid(zone)).thenReturn(true);
    when(vmProfile.getVirtualMachine()).thenReturn(vm);
    when(vm.getDataCenterId()).thenReturn(1L);
    when(zoneRepository.findOne(1L)).thenReturn(zone);

    final List<Long> clusterList = planner.orderClusters(vmProfile, plan, avoids);
    assertTrue("Cluster list should be null/empty if the dc is in avoid list", (clusterList == null || clusterList.isEmpty()));
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:17,代码来源:ImplicitPlannerTest.java

示例2: checkStrictModeNoHostsAvailable

import com.cloud.vm.VirtualMachineProfileImpl; //导入依赖的package包/类
@Test
public void checkStrictModeNoHostsAvailable() throws InsufficientServerCapacityException {
    final VirtualMachineProfileImpl vmProfile = mock(VirtualMachineProfileImpl.class);
    final DataCenterDeployment plan = mock(DataCenterDeployment.class);
    final ExcludeList avoids = new ExcludeList();

    initializeForTest(vmProfile, plan);

    initializeForImplicitPlannerTest(false);

    // Mark the host 5 and 6 to be in avoid list.
    avoids.addHost(5L);
    avoids.addHost(6L);
    final List<Long> clusterList = planner.orderClusters(vmProfile, plan, avoids);

    // Validations.
    // Check cluster list is empty.
    assertTrue("Cluster list should not be null/empty", (clusterList == null || clusterList.isEmpty()));
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:20,代码来源:ImplicitPlannerTest.java

示例3: checkPreferredModeNoHostsAvailable

import com.cloud.vm.VirtualMachineProfileImpl; //导入依赖的package包/类
@Test
public void checkPreferredModeNoHostsAvailable() throws InsufficientServerCapacityException {
    final VirtualMachineProfileImpl vmProfile = mock(VirtualMachineProfileImpl.class);
    final DataCenterDeployment plan = mock(DataCenterDeployment.class);
    final ExcludeList avoids = new ExcludeList();

    initializeForTest(vmProfile, plan);

    initializeForImplicitPlannerTest(false);

    // Mark the host 5, 6 and 7 to be in avoid list.
    avoids.addHost(5L);
    avoids.addHost(6L);
    avoids.addHost(7L);
    final List<Long> clusterList = planner.orderClusters(vmProfile, plan, avoids);

    // Validations.
    // Check cluster list is empty.
    assertTrue("Cluster list should not be null/empty", (clusterList == null || clusterList.isEmpty()));
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:21,代码来源:ImplicitPlannerTest.java

示例4: checkWhenDcInAvoidList

import com.cloud.vm.VirtualMachineProfileImpl; //导入依赖的package包/类
@Test
public void checkWhenDcInAvoidList() throws InsufficientServerCapacityException {
    DataCenterVO mockDc = mock(DataCenterVO.class);
    ExcludeList avoids = mock(ExcludeList.class);
    VirtualMachineProfileImpl vmProfile = mock(VirtualMachineProfileImpl.class);
    VMInstanceVO vm = mock(VMInstanceVO.class);
    DataCenterDeployment plan = mock(DataCenterDeployment.class);

    when(avoids.shouldAvoid(mockDc)).thenReturn(true);
    when(vmProfile.getVirtualMachine()).thenReturn(vm);
    when(vm.getDataCenterId()).thenReturn(1L);
    when(dcDao.findById(1L)).thenReturn(mockDc);

    List<Long> clusterList = planner.orderClusters(vmProfile, plan, avoids);
    assertTrue("Cluster list should be null/empty if the dc is in avoid list", (clusterList == null || clusterList.isEmpty()));
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:17,代码来源:ImplicitPlannerTest.java

示例5: checkStrictModeNoHostsAvailable

import com.cloud.vm.VirtualMachineProfileImpl; //导入依赖的package包/类
@Test
public void checkStrictModeNoHostsAvailable() throws InsufficientServerCapacityException {
    @SuppressWarnings("unchecked")
    VirtualMachineProfileImpl vmProfile = mock(VirtualMachineProfileImpl.class);
    DataCenterDeployment plan = mock(DataCenterDeployment.class);
    ExcludeList avoids = new ExcludeList();

    initializeForTest(vmProfile, plan);

    initializeForImplicitPlannerTest(false);

    // Mark the host 5 and 6 to be in avoid list.
    avoids.addHost(5L);
    avoids.addHost(6L);
    List<Long> clusterList = planner.orderClusters(vmProfile, plan, avoids);

    // Validations.
    // Check cluster list is empty.
    assertTrue("Cluster list should not be null/empty", (clusterList == null || clusterList.isEmpty()));
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:21,代码来源:ImplicitPlannerTest.java

示例6: checkPreferredModeNoHostsAvailable

import com.cloud.vm.VirtualMachineProfileImpl; //导入依赖的package包/类
@Test
public void checkPreferredModeNoHostsAvailable() throws InsufficientServerCapacityException {
    @SuppressWarnings("unchecked")
    VirtualMachineProfileImpl vmProfile = mock(VirtualMachineProfileImpl.class);
    DataCenterDeployment plan = mock(DataCenterDeployment.class);
    ExcludeList avoids = new ExcludeList();

    initializeForTest(vmProfile, plan);

    initializeForImplicitPlannerTest(false);

    // Mark the host 5, 6 and 7 to be in avoid list.
    avoids.addHost(5L);
    avoids.addHost(6L);
    avoids.addHost(7L);
    List<Long> clusterList = planner.orderClusters(vmProfile, plan, avoids);

    // Validations.
    // Check cluster list is empty.
    assertTrue("Cluster list should not be null/empty", (clusterList == null || clusterList.isEmpty()));
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:22,代码来源:ImplicitPlannerTest.java

示例7: findStoragePool

import com.cloud.vm.VirtualMachineProfileImpl; //导入依赖的package包/类
@Override
public StoragePool findStoragePool(final DiskProfile dskCh, final DataCenter dc, final Pod pod, final Long clusterId, final Long hostId, final VirtualMachine vm, final
Set<StoragePool> avoid) {
    Long podId = null;
    if (pod != null) {
        podId = pod.getId();
    } else if (clusterId != null) {
        final Cluster cluster = _entityMgr.findById(Cluster.class, clusterId);
        if (cluster != null) {
            podId = cluster.getPodId();
        }
    }

    final VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);
    for (final StoragePoolAllocator allocator : _storagePoolAllocators) {

        final ExcludeList avoidList = new ExcludeList();
        for (final StoragePool pool : avoid) {
            avoidList.addPool(pool.getId());
        }
        final DataCenterDeployment plan = new DataCenterDeployment(dc.getId(), podId, clusterId, hostId, null, null);

        final List<StoragePool> poolList = allocator.allocateToPool(dskCh, profile, plan, avoidList, 1);
        if (poolList != null && !poolList.isEmpty()) {
            return (StoragePool) dataStoreMgr.getDataStore(poolList.get(0).getId(), DataStoreRole.Primary);
        }
    }
    return null;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:30,代码来源:VolumeOrchestrator.java

示例8: checkStrictModeWithCurrentAccountVmsPresent

import com.cloud.vm.VirtualMachineProfileImpl; //导入依赖的package包/类
@Test
public void checkStrictModeWithCurrentAccountVmsPresent() throws InsufficientServerCapacityException {
    final VirtualMachineProfileImpl vmProfile = mock(VirtualMachineProfileImpl.class);
    final DataCenterDeployment plan = mock(DataCenterDeployment.class);
    final ExcludeList avoids = new ExcludeList();

    initializeForTest(vmProfile, plan);

    initializeForImplicitPlannerTest(false);

    final List<Long> clusterList = planner.orderClusters(vmProfile, plan, avoids);

    // Validations.
    // Check cluster 2 and 3 are not in the cluster list.
    // Host 6 and 7 should also be in avoid list.
    assertFalse("Cluster list should not be null/empty", (clusterList == null || clusterList.isEmpty()));
    boolean foundNeededCluster = false;
    for (final Long cluster : clusterList) {
        if (cluster != 1) {
            fail("Found a cluster that shouldn't have been present, cluster id : " + cluster);
        } else {
            foundNeededCluster = true;
        }
    }
    assertTrue("Didn't find cluster 1 in the list. It should have been present", foundNeededCluster);

    final Set<Long> hostsInAvoidList = avoids.getHostsToAvoid();
    assertFalse("Host 5 shouldn't have be in the avoid list, but it is present", hostsInAvoidList.contains(5L));
    final Set<Long> hostsThatShouldBeInAvoidList = new HashSet<>();
    hostsThatShouldBeInAvoidList.add(6L);
    hostsThatShouldBeInAvoidList.add(7L);
    assertTrue("Hosts 6 and 7 that should have been present were not found in avoid list", hostsInAvoidList.containsAll(hostsThatShouldBeInAvoidList));
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:34,代码来源:ImplicitPlannerTest.java

示例9: checkStrictModeHostWithCurrentAccountVmsFull

import com.cloud.vm.VirtualMachineProfileImpl; //导入依赖的package包/类
@Test
public void checkStrictModeHostWithCurrentAccountVmsFull() throws InsufficientServerCapacityException {
    final VirtualMachineProfileImpl vmProfile = mock(VirtualMachineProfileImpl.class);
    final DataCenterDeployment plan = mock(DataCenterDeployment.class);
    final ExcludeList avoids = new ExcludeList();

    initializeForTest(vmProfile, plan);

    initializeForImplicitPlannerTest(false);

    // Mark the host 5 with current account vms to be in avoid list.
    avoids.addHost(5L);
    final List<Long> clusterList = planner.orderClusters(vmProfile, plan, avoids);

    // Validations.
    // Check cluster 1 and 3 are not in the cluster list.
    // Host 5 and 7 should also be in avoid list.
    assertFalse("Cluster list should not be null/empty", (clusterList == null || clusterList.isEmpty()));
    boolean foundNeededCluster = false;
    for (final Long cluster : clusterList) {
        if (cluster != 2) {
            fail("Found a cluster that shouldn't have been present, cluster id : " + cluster);
        } else {
            foundNeededCluster = true;
        }
    }
    assertTrue("Didn't find cluster 2 in the list. It should have been present", foundNeededCluster);

    final Set<Long> hostsInAvoidList = avoids.getHostsToAvoid();
    assertFalse("Host 6 shouldn't have be in the avoid list, but it is present", hostsInAvoidList.contains(6L));
    final Set<Long> hostsThatShouldBeInAvoidList = new HashSet<>();
    hostsThatShouldBeInAvoidList.add(5L);
    hostsThatShouldBeInAvoidList.add(7L);
    assertTrue("Hosts 5 and 7 that should have been present were not found in avoid list", hostsInAvoidList.containsAll(hostsThatShouldBeInAvoidList));
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:36,代码来源:ImplicitPlannerTest.java

示例10: checkPreferredModePreferredHostAvailable

import com.cloud.vm.VirtualMachineProfileImpl; //导入依赖的package包/类
@Test
public void checkPreferredModePreferredHostAvailable() throws InsufficientServerCapacityException {
    final VirtualMachineProfileImpl vmProfile = mock(VirtualMachineProfileImpl.class);
    final DataCenterDeployment plan = mock(DataCenterDeployment.class);
    final ExcludeList avoids = new ExcludeList();

    initializeForTest(vmProfile, plan);

    initializeForImplicitPlannerTest(true);

    // Mark the host 5 and 6 to be in avoid list.
    avoids.addHost(5L);
    avoids.addHost(6L);
    final List<Long> clusterList = planner.orderClusters(vmProfile, plan, avoids);

    // Validations.
    // Check cluster 1 and 2 are not in the cluster list.
    // Host 5 and 6 should also be in avoid list.
    assertFalse("Cluster list should not be null/empty", (clusterList == null || clusterList.isEmpty()));
    boolean foundNeededCluster = false;
    for (final Long cluster : clusterList) {
        if (cluster != 3) {
            fail("Found a cluster that shouldn't have been present, cluster id : " + cluster);
        } else {
            foundNeededCluster = true;
        }
    }
    assertTrue("Didn't find cluster 3 in the list. It should have been present", foundNeededCluster);

    final Set<Long> hostsInAvoidList = avoids.getHostsToAvoid();
    assertFalse("Host 7 shouldn't have be in the avoid list, but it is present", hostsInAvoidList.contains(7L));
    final Set<Long> hostsThatShouldBeInAvoidList = new HashSet<>();
    hostsThatShouldBeInAvoidList.add(5L);
    hostsThatShouldBeInAvoidList.add(6L);
    assertTrue("Hosts 5 and 6 that should have been present were not found in avoid list", hostsInAvoidList.containsAll(hostsThatShouldBeInAvoidList));
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:37,代码来源:ImplicitPlannerTest.java

示例11: finalizeDeploymentTest

import com.cloud.vm.VirtualMachineProfileImpl; //导入依赖的package包/类
@Test
public void finalizeDeploymentTest() throws ResourceUnavailableException {
    ReservationContext context = Mockito.mock(ReservationContext.class);
    Commands cmds = Mockito.mock(Commands.class);
    DataCenter dc = Mockito.mock(DataCenter.class);

    VirtualMachineProfileImpl profile = Mockito.mock(VirtualMachineProfileImpl.class);
    Mockito.when(profile.getNics()).thenReturn(new ArrayList<NicProfile>());
    Mockito.when(profile.getId()).thenReturn(0l);

    AutonomiccsSystemVm autonomiccsSystemVm = Mockito.mock(AutonomiccsSystemVm.class);
    Mockito.doReturn(autonomiccsSystemVm).when(autonomiccsSystemVmDao).findById(Mockito.anyLong());

    DeployDestination dest = Mockito.mock(DeployDestination.class);
    Mockito.when(dest.getDataCenter()).thenReturn(dc);

    Mockito.doNothing().when(spy).setIpAddressOfEachNic(Mockito.any(AutonomiccsSystemVm.class), Mockito.any(DataCenter.class), Matchers.anyListOf(NicProfile.class));
    Mockito.doReturn(true).when(autonomiccsSystemVmDao).update(Mockito.anyLong(), Mockito.any(AutonomiccsSystemVm.class));

    boolean result = spy.finalizeDeployment(cmds, profile, dest, context);
    Assert.assertEquals(true, result);

    InOrder inOrder = Mockito.inOrder(autonomiccsSystemVmDao, spy);
    inOrder.verify(autonomiccsSystemVmDao).findById(Mockito.anyLong());
    inOrder.verify(spy).setIpAddressOfEachNic(Mockito.any(AutonomiccsSystemVm.class), Mockito.any(DataCenter.class), Matchers.anyListOf(NicProfile.class));
    inOrder.verify(autonomiccsSystemVmDao).update(Mockito.anyLong(), Mockito.any(AutonomiccsSystemVm.class));
}
 
开发者ID:Autonomiccs,项目名称:autonomiccs-platform,代码行数:28,代码来源:AutonomiccsSystemVmsGuruTest.java

示例12: findStoragePool

import com.cloud.vm.VirtualMachineProfileImpl; //导入依赖的package包/类
@Override
public StoragePool findStoragePool(DiskProfile dskCh, DataCenter dc, Pod pod, Long clusterId, Long hostId, VirtualMachine vm, final Set<StoragePool> avoid) {
    Long podId = null;
    if (pod != null) {
        podId = pod.getId();
    } else if (clusterId != null) {
        Cluster cluster = _entityMgr.findById(Cluster.class, clusterId);
        if (cluster != null) {
            podId = cluster.getPodId();
        }
    }

    VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);
    for (StoragePoolAllocator allocator : _storagePoolAllocators) {

        ExcludeList avoidList = new ExcludeList();
        for (StoragePool pool : avoid) {
            avoidList.addPool(pool.getId());
        }
        DataCenterDeployment plan = new DataCenterDeployment(dc.getId(), podId, clusterId, hostId, null, null);

        final List<StoragePool> poolList = allocator.allocateToPool(dskCh, profile, plan, avoidList, 1);
        if (poolList != null && !poolList.isEmpty()) {
            return (StoragePool)dataStoreMgr.getDataStore(poolList.get(0).getId(), DataStoreRole.Primary);
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:29,代码来源:VolumeOrchestrator.java

示例13: testRelease

import com.cloud.vm.VirtualMachineProfileImpl; //导入依赖的package包/类
@Test
public void testRelease() {
    final Answer answer = mock(Answer.class);
    when(endpoint.sendMessage(any(HandleConfigDriveIsoCommand.class))).thenReturn(answer);
    when(answer.getResult()).thenReturn(true);
    VirtualMachineProfile profile = new VirtualMachineProfileImpl(virtualMachine, null, serviceOfferingVO, null, null);
    assertTrue(_configDrivesNetworkElement.release(network, nicp, profile, null));
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:9,代码来源:ConfigDriveNetworkElementTest.java

示例14: testAddPasswordAndUserdata

import com.cloud.vm.VirtualMachineProfileImpl; //导入依赖的package包/类
@Test
public void testAddPasswordAndUserdata() throws InsufficientCapacityException, ResourceUnavailableException {
    final Answer answer = mock(Answer.class);
    final UserVmDetailVO userVmDetailVO = mock(UserVmDetailVO.class);
    when(endpoint.sendMessage(any(HandleConfigDriveIsoCommand.class))).thenReturn(answer);
    when(answer.getResult()).thenReturn(true);
    when(network.getTrafficType()).thenReturn(Networks.TrafficType.Guest);
    when(virtualMachine.getState()).thenReturn(VirtualMachine.State.Stopped);
    when(userVmDetailVO.getValue()).thenReturn(PUBLIC_KEY);
    when(_userVmDetailsDao.findDetail(anyLong(), anyString())).thenReturn(userVmDetailVO);
    Map<VirtualMachineProfile.Param, Object> parms = Maps.newHashMap();
    parms.put(VirtualMachineProfile.Param.VmPassword, PASSWORD);
    parms.put(VirtualMachineProfile.Param.VmSshPubKey, PUBLIC_KEY);
    VirtualMachineProfile profile = new VirtualMachineProfileImpl(virtualMachine, null, serviceOfferingVO, null, parms);
    assertTrue(_configDrivesNetworkElement.addPasswordAndUserdata(
            network, nicp, profile, deployDestination, null));

    ArgumentCaptor<HandleConfigDriveIsoCommand> commandCaptor = ArgumentCaptor.forClass(HandleConfigDriveIsoCommand.class);
    verify(endpoint, times(1)).sendMessage(commandCaptor.capture());
    HandleConfigDriveIsoCommand result = commandCaptor.getValue();
    List<String[]> actualVmData = result.getVmData();

    assertThat(actualVmData, containsInAnyOrder(
            new String[]{"userdata", "user_data", VMUSERDATA},
            new String[]{"metadata", "service-offering", VMOFFERING},
            new String[]{"metadata", "availability-zone", ZONENAME},
            new String[]{"metadata", "local-hostname", VMINSTANCENAME},
            new String[]{"metadata", "vm-id", String.valueOf(VMID)},
            new String[]{"metadata", "instance-id", String.valueOf(VMINSTANCENAME)},
            new String[]{"metadata", "public-keys", PUBLIC_KEY},
            new String[]{"metadata", "cloud-identifier", String.format("CloudStack-{%s}", CLOUD_ID)},
            new String[]{PASSWORD, "vm_password", PASSWORD}
    ));

}
 
开发者ID:apache,项目名称:cloudstack,代码行数:36,代码来源:ConfigDriveNetworkElementTest.java

示例15: checkStrictModeWithCurrentAccountVmsPresent

import com.cloud.vm.VirtualMachineProfileImpl; //导入依赖的package包/类
@Test
public void checkStrictModeWithCurrentAccountVmsPresent() throws InsufficientServerCapacityException {
    VirtualMachineProfileImpl vmProfile = mock(VirtualMachineProfileImpl.class);
    DataCenterDeployment plan = mock(DataCenterDeployment.class);
    ExcludeList avoids = new ExcludeList();

    initializeForTest(vmProfile, plan);

    initializeForImplicitPlannerTest(false);

    List<Long> clusterList = planner.orderClusters(vmProfile, plan, avoids);

    // Validations.
    // Check cluster 2 and 3 are not in the cluster list.
    // Host 6 and 7 should also be in avoid list.
    assertFalse("Cluster list should not be null/empty", (clusterList == null || clusterList.isEmpty()));
    boolean foundNeededCluster = false;
    for (Long cluster : clusterList) {
        if (cluster != 1) {
            fail("Found a cluster that shouldn't have been present, cluster id : " + cluster);
        } else {
            foundNeededCluster = true;
        }
    }
    assertTrue("Didn't find cluster 1 in the list. It should have been present", foundNeededCluster);

    Set<Long> hostsInAvoidList = avoids.getHostsToAvoid();
    assertFalse("Host 5 shouldn't have be in the avoid list, but it is present", hostsInAvoidList.contains(5L));
    Set<Long> hostsThatShouldBeInAvoidList = new HashSet<Long>();
    hostsThatShouldBeInAvoidList.add(6L);
    hostsThatShouldBeInAvoidList.add(7L);
    assertTrue("Hosts 6 and 7 that should have been present were not found in avoid list", hostsInAvoidList.containsAll(hostsThatShouldBeInAvoidList));
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:34,代码来源:ImplicitPlannerTest.java


注:本文中的com.cloud.vm.VirtualMachineProfileImpl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。