コード例 #1
0
ファイル: TestHaOnKvm10.java プロジェクト: Ryan9181/zstack
  @Test
  public void test() throws ApiSenderException, InterruptedException {
    VmInstanceInventory vm1 = deployer.vms.get("TestVm1");
    VmInstanceInventory vm2 = deployer.vms.get("TestVm2");
    api.setVmHaLevel(vm1.getUuid(), VmHaLevel.NeverStop, null);
    api.setVmHaLevel(vm2.getUuid(), VmHaLevel.OnHostFailure, null);

    api.maintainHost(vm1.getHostUuid());

    HostInventory host2 = deployer.hosts.get("host2");
    VmInstanceVO vmvo1 = dbf.findByUuid(vm1.getUuid(), VmInstanceVO.class);
    VmInstanceVO vmvo2 = dbf.findByUuid(vm2.getUuid(), VmInstanceVO.class);
    Assert.assertEquals(VmInstanceState.Running, vmvo1.getState());
    Assert.assertEquals(host2.getUuid(), vmvo1.getHostUuid());
    Assert.assertEquals(VmInstanceState.Stopped, vmvo2.getState());
  }