def get_packager(self, pkg_info): if self.PACKAGER_KEY_NAME in pkg_info: packager_name = pkg_info[self.PACKAGER_KEY_NAME] LOG.debug('Loading custom package manager %r', packager_name) packager = importer.import_entry_point(packager_name)(self.distro) else: LOG.debug('Using default package manager') packager = self.default_packager return packager
def extract_component(self, name, action): """Return the class + component info to use for doing the action w/the component.""" try: # Use a copy instead of the original component_info = dict(self._components[name]) entry_point = component_info['action_classes'][action] cls = importer.import_entry_point(entry_point) # Remove action class info if 'action_classes' in component_info: del component_info['action_classes'] return (cls, component_info) except KeyError: raise RuntimeError('No class configured to %s %s on %s' % (action, name, self.name))
def extract_component(self, name, action): """Return the class + component info to use for doing the action w/the component.""" try: # Use a copy instead of the original component_info = dict(self._components[name]) entry_point = component_info[action] cls = importer.import_entry_point(entry_point) # Knock all action class info (and any other keys) key_deletions = [action] + settings.ACTIONS for k in key_deletions: if k in component_info: del component_info[k] return (cls, component_info) except KeyError: raise RuntimeError('No class configured to %s %s on %s' % (action, name, self.name))
def get_default_package_manager(self): """Return a package manager that will work for this distro.""" return importer.import_entry_point(self._packager_name)(self)
def get_packager_factory(self): """Return a factory for a package manager.""" return importer.import_entry_point(self._packager_name)
def test_function(): f = importer.import_entry_point('devstack.importer:import_entry_point') assert f == importer.import_entry_point
def test_class(): c = importer.import_entry_point('devstack.distro:Distro') assert c == distro.Distro