XenHypervisor implements HypervisorHost { @Override public void shutdownHost(HostVO hostVo) { String privateMacAddress = getHostPrivateMacAddress(hostVo); hostService.updateHostPrivaceMacAddress(hostVo, privateMacAddress); Connection conn = getConnection(hostVo); String hostToDeactivatedUuid = hostVo.getGuid(); try { Host master = getMasterHost(conn); changeMasterIfNeeded(conn, master, hostToDeactivatedUuid); Host host = Host.getByUuid(conn, hostToDeactivatedUuid); String hostAddress = host.getAddress(conn); disableAndShutdownHost(conn, host); do { threadUtils.sleepThread(3); } while (hostUtils.isHostReachable(hostAddress)); } catch (Exception e) { throw new CloudRuntimeException(String.format("Could not shut down host [uuid=%s]", hostToDeactivatedUuid), e); } }  @Override void shutdownHost(HostVO hostVo); @Override boolean supportsHypervisor(HypervisorType hypervisorType);  }
@Test public void shutdownHostTest() throws Exception { HostVO hostVo = setupShutdownHostTest(); xenHypervisor.shutdownHost(hostVo); verifyShutdownHostCalledMethods(); }
@Test public void shutdownHostTestExceptionThrownByChangeMasterIfNeeded() throws Exception { HostVO hostVo = setupShutdownHostTest(); xenHypervisor.shutdownHost(hostVo); verifyShutdownHostCalledMethods(); }