Ejemplo n.º 1
0
def check_module_version(path, version):
    descriptor = Module(
        tools.load_descriptor(os.path.join(path, 'module.yaml')), path)
    if descriptor.version != version:
        raise ConcreateError(
            "Requested conflicting version '%s' of module '%s'" %
            (version, descriptor['name']))
Ejemplo n.º 2
0
    def __init__(self, descriptor_path, target, overrides):

        self.descriptor = Image(tools.load_descriptor(descriptor_path),
                                os.path.dirname(descriptor_path))
        self.target = target

        if overrides:
            self.descriptor = self.override(overrides)

        logger.info("Initializing image descriptor...")
Ejemplo n.º 3
0
def discover_modules(repo_dir):
    """Looks through the directory trees for modules descriptor.
    When module is found, it create concreate.module.Module instance
    and add this instance to the concreate.module.modules list.
    """
    for modules_dir, _, files in os.walk(repo_dir):
        if 'module.yaml' in files:
            module = Module(tools.load_descriptor(os.path.join(modules_dir, 'module.yaml')),
                            modules_dir)
            module.fetch_dependencies(repo_dir)
            logger.debug("Adding module '%s', path: '%s'" % (module.name, module.path))
            modules.append(module)
Ejemplo n.º 4
0
    def __init__(self, descriptor_path, target, overrides):
        descriptor = tools.load_descriptor(descriptor_path)

        # if there is a local modules directory and no modules are defined
        # we will inject it for a backward compatibility
        local_mod_path = os.path.join(
            os.path.abspath(os.path.dirname(descriptor_path)), 'modules')
        if os.path.exists(local_mod_path) and 'modules' in descriptor:
            modules = descriptor.get('modules')
            if not modules.get('repositories'):
                modules['repositories'] = [{
                    'path': local_mod_path,
                    'name': 'modules'
                }]
        self.descriptor = Image(descriptor, os.path.dirname(descriptor_path))
        self.target = target

        if overrides:
            self.descriptor = self.override(overrides)

        logger.info("Initializing image descriptor...")
Ejemplo n.º 5
0
 def override(self, overrides_path):
     logger.info("Using overrides file from '%s'." % overrides_path)
     descriptor = Overrides(tools.load_descriptor(overrides_path))
     descriptor.merge(self.descriptor)
     return descriptor
Ejemplo n.º 6
0
 def __init__(self, descriptor_path, descriptor_type):
     self.directory = os.path.dirname(descriptor_path)
     self.descriptor = tools.load_descriptor(descriptor_path,
                                             descriptor_type)
     if descriptor_type == 'image':
         self.check_schema_version()