예제 #1
0
 def _verify_version_compatibility(self):
     current_version = get_edi_version()
     required_version = str(self._get_general_item('edi_required_minimal_edi_version', current_version))
     if Version(get_stripped_version(current_version)) < Version(get_stripped_version(required_version)):
         raise FatalError(('The current configuration requires a newer version of edi (>={}).\n'
                           'Please update your edi installation!'
                           ).format(get_stripped_version(required_version)))
예제 #2
0
    def run(self, project_name, config_template):
        workdir = os.getcwd()

        if os.getuid() == 0:
            raise FatalError('Do not initialize a configuration as root!')

        if not os.access(workdir, os.W_OK):
            raise FatalError('''No write access to '{}'.'''.format(workdir))

        if os.listdir(workdir):
            raise FatalError(
                'Please initialize your new configuration within an empty folder!'
            )

        source = get_project_tree()
        copy_tree(source, workdir)
        template = ConfigurationTemplate(workdir)
        with open(get_template(config_template), encoding="UTF-8",
                  mode="r") as template_file:
            t = Template(template_file.read())
            template_dict = yaml.load(t.render(get_base_dictionary())).get(
                'parameters', {})

        template_dict['edi_project_name'] = project_name
        template_dict["edi_edi_version"] = get_stripped_version(
            get_edi_version())
        template.render(template_dict)

        print_success(
            '''Configuration for project '{}' generated in folder '{}'.'''.
            format(project_name, workdir))
예제 #3
0
    def check():
        if LxdVersion._check_done:
            return

        if Version(get_stripped_version(get_lxd_version())) < Version(
                LxdVersion._required_minimal_version):
            raise FatalError((
                'The current lxd installation ({}) does not meet the minimal requirements (>={}).\n'
                'Please update your lxd installation using snaps or xenial-backports!'
            ).format(get_lxd_version(), LxdVersion._required_minimal_version))
        else:
            LxdVersion._check_done = True