class AdministrationAgent implements InitializingBean {

    protected void putHostInMaintenance(long hostId) {
        try {
            resourceManager.maintain(hostId);
        } catch (Exception e) {
            throw new CloudRuntimeException(String.format("Problems while putting host [id=%d] on maintenance", hostId), e);
        }
        do {
            threadUtils.sleepThread(3);
            if (hostService.isHostInMaintenanceError(hostId)) {
                throw new CloudRuntimeException(String.format("Error while sending the maintenance command to host [id=%d]", hostId));
            }

        } while (hostService.isHostInPreparedForMaintenance(hostId));
    }

}