class AutonomiccsSystemVirtualMachinesTemplateRegister implements InitializingBean {

    @Scheduled(initialDelay = ONE_MINUTE_IN_MILLISECONDS, fixedDelay = ONE_MINUTE_IN_MILLISECONDS * NUMBER_OF_MINUTES_BETWEEN_REGISTRATION_OF_TEMPLATES)
    public void registerTemplatesIfNeeded() {
        if (autonomicManagementHeuristicService.getAdministrationAlgorithm().canHeuristicShutdownHosts() || hostService.isThereAnyHostOnCloudDeactivatedByOurManager()) {
            List<HypervisorType> allHypervisorsTypeInCloud = hostService.getAllHypervisorsTypeInCloud();
            for (HypervisorType hypervisorType : allHypervisorsTypeInCloud) {
                if (!autonomiccsSystemVmTemplateService.isTemplateRegisteredForHypervisor(hypervisorType)) {
                    RegisterTemplateCmd templateCommandForHypervisor = createRegisterTemplateCommandForHypervisor(hypervisorType);
                    try {
                        templateService.registerTemplate(templateCommandForHypervisor);
                    } catch (Exception e) {
                        logger.error("Error while registering a Autonomiccs system vm. ", e);
                    }
                }
            }
        }
    }

}