Пример #1
0
    def _load_extensions(self):
        """Load extensions specified on the command line."""

        extensions = list(self.cls_list)

        for ext_factory in extensions:
            try:
                self.load_extension(ext_factory)
            except Exception as exc:
                LOG.warning(_LW('Failed to load extension %(ext_factory)s: '
                                '%(exc)s'),
                            {'ext_factory': ext_factory, 'exc': exc})
Пример #2
0
 def basic_config_check(self):
     """Perform basic config checks before starting service."""
     # Make sure report interval is less than service down time
     if self.report_interval:
         if CONF.service_down_time <= self.report_interval:
             new_down_time = int(self.report_interval * 2.5)
             LOG.warning(
                 _LW("Report interval must be less than service down "
                     "time. Current config service_down_time: "
                     "%(service_down_time)s, report_interval for this: "
                     "service is: %(report_interval)s. Setting global "
                     "service_down_time to: %(new_down_time)s"),
                 {'service_down_time': CONF.service_down_time,
                  'report_interval': self.report_interval,
                  'new_down_time': new_down_time})
             CONF.set_override('service_down_time', new_down_time)
Пример #3
0
 def basic_config_check(self):
     """Perform basic config checks before starting service."""
     # Make sure report interval is less than service down time
     if self.report_interval:
         if CONF.service_down_time <= self.report_interval:
             new_down_time = int(self.report_interval * 2.5)
             LOG.warning(
                 _LW("Report interval must be less than service down "
                     "time. Current config service_down_time: "
                     "%(service_down_time)s, report_interval for this: "
                     "service is: %(report_interval)s. Setting global "
                     "service_down_time to: %(new_down_time)s"), {
                         'service_down_time': CONF.service_down_time,
                         'report_interval': self.report_interval,
                         'new_down_time': new_down_time
                     })
             CONF.set_override('service_down_time', new_down_time)
Пример #4
0
    def _setup_extensions(self, ext_mgr):
        for extension in ext_mgr.get_controller_extensions():
            collection = extension.collection
            controller = extension.controller

            if collection not in self.resources:
                LOG.warning(_LW('Extension %(ext_name)s: Cannot extend '
                                'resource %(collection)s: No such resource'),
                            {'ext_name': extension.extension.name,
                             'collection': collection})
                continue

            LOG.debug('Extension %(ext_name)s extending resource: '
                      '%(collection)s',
                      {'ext_name': extension.extension.name,
                       'collection': collection})

            resource = self.resources[collection]
            resource.register_actions(controller)
            resource.register_extensions(controller)
Пример #5
0
    def _setup_extensions(self, ext_mgr):
        for extension in ext_mgr.get_controller_extensions():
            collection = extension.collection
            controller = extension.controller

            if collection not in self.resources:
                LOG.warning(
                    _LW('Extension %(ext_name)s: Cannot extend '
                        'resource %(collection)s: No such resource'), {
                            'ext_name': extension.extension.name,
                            'collection': collection
                        })
                continue

            LOG.debug(
                'Extension %(ext_name)s extending resource: '
                '%(collection)s', {
                    'ext_name': extension.extension.name,
                    'collection': collection
                })

            resource = self.resources[collection]
            resource.register_actions(controller)
            resource.register_extensions(controller)
Пример #6
0
def load_standard_extensions(ext_mgr, logger, path, package, ext_list=None):
    """Registers all standard API extensions."""

    # Walk through all the modules in our directory...
    our_dir = path[0]
    for dirpath, dirnames, filenames in os.walk(our_dir):
        # Compute the relative package name from the dirpath
        relpath = os.path.relpath(dirpath, our_dir)
        if relpath == '.':
            relpkg = ''
        else:
            relpkg = '.%s' % '.'.join(relpath.split(os.sep))

        # Now, consider each file in turn, only considering .py files
        for fname in filenames:
            root, ext = os.path.splitext(fname)

            # Skip __init__ and anything that's not .py
            if ext != '.py' or root == '__init__':
                continue

            # Try loading it
            classname = "%s%s" % (root[0].upper(), root[1:])
            classpath = ("%s%s.%s.%s" %
                         (package, relpkg, root, classname))

            if ext_list is not None and classname not in ext_list:
                logger.debug("Skipping extension: %s" % classpath)
                continue

            try:
                ext_mgr.load_extension(classpath)
            except Exception as exc:
                logger.warning(_LW('Failed to load extension %(classpath)s: '
                                   '%(exc)s'),
                               {'classpath': classpath, 'exc': exc})

        # Now, let's consider any subdirectories we may have...
        subdirs = []
        for dname in dirnames:
            # Skip it if it does not have __init__.py
            if not os.path.exists(os.path.join(dirpath, dname,
                                               '__init__.py')):
                continue

            # If it has extension(), delegate...
            ext_name = ("%s%s.%s.extension" %
                        (package, relpkg, dname))
            try:
                ext = importutils.import_class(ext_name)
            except ImportError:
                # extension() doesn't exist on it, so we'll explore
                # the directory for ourselves
                subdirs.append(dname)
            else:
                try:
                    ext(ext_mgr)
                except Exception as exc:
                    logger.warning(_LW('Failed to load extension '
                                       '%(ext_name)s: %(exc)s'),
                                   {'ext_name': ext_name, 'exc': exc})

        # Update the list of directories we'll explore...
        dirnames[:] = subdirs
Пример #7
0
def root_app_factory(loader, global_conf, **local_conf):
    LOG.warning(_LW('The conveyoragent api-paste.int v2v_gateway_api '
                    'load start.'))
    return paste.urlmap.urlmap_factory(loader, global_conf, **local_conf)