class AdministrationAgent implements InitializingBean {

    protected void shutdownHost(long hostId) {
        try {
            checkIfHostIsUpAndEnabled(hostId);

            List<VMInstanceVO> vms = hostService.listAllVmsFromHost(hostId);
            if (CollectionUtils.isNotEmpty(vms)) {
                logger.debug(String.format("Could not shut dow host [id=%d], there are %d VMs running in this host.", hostId, vms.size()));
                return;
            }
            putHostInMaintenance(hostId);

            hypervisorManager.shutdownHost(hostService.findHostById(hostId));
        } catch (Exception e) {
            logger.info(String.format("Error while shutting down host [id=%d]", hostId), e);
        }
    }

}