

def configure_host(self):
    LOG.info('Cloudbase-Init version: %s', version.get_version())
    osutils = osutils_factory.get_os_utils()
    osutils.wait_for_boot_completion()
    reboot_required = self._handle_plugins_stage(osutils, None, None, plugins_base.PLUGIN_STAGE_PRE_NETWORKING)
    self._check_latest_version()
    if (not (reboot_required and CONF.allow_reboot)):
        reboot_required = self._handle_plugins_stage(osutils, None, None, plugins_base.PLUGIN_STAGE_PRE_METADATA_DISCOVERY)
    if (not (reboot_required and CONF.allow_reboot)):
        service = metadata_factory.get_metadata_service()
        LOG.info(("Metadata service loaded: '%s'" % service.get_name()))
        instance_id = service.get_instance_id()
        LOG.debug('Instance id: %s', instance_id)
        try:
            reboot_required = self._handle_plugins_stage(osutils, service, instance_id, plugins_base.PLUGIN_STAGE_MAIN)
        finally:
            service.cleanup()
    if (reboot_required and CONF.allow_reboot):
        try:
            LOG.info('Rebooting')
            osutils.reboot()
        except Exception as ex:
            LOG.error(("reboot failed with error '%s'" % ex))
    else:
        LOG.info('Plugins execution done')
        if CONF.stop_service_on_exit:
            LOG.info('Stopping Cloudbase-Init service')
            osutils.terminate()

dataset/ETHPy150Open openstack/cloudbase-init/cloudbaseinit/init.py InitManager.configure_host/original