Beispiel #1
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))
Beispiel #2
0
def verify_shared_folder(container_name):
    base_dict = get_base_dictionary()
    random_file = get_random_string(20)
    workspace_folder = 'edi-workspace'
    cmd = [lxc_exec(), 'exec', container_name, '--',
           'sudo', '-u', base_dict.get('edi_current_user_name'), 'touch',
           os.path.join(base_dict.get('edi_current_user_target_home_directory'), workspace_folder, random_file)]
    run(cmd)
    shared_file = os.path.join(base_dict.get('edi_current_user_host_home_directory'),
                               workspace_folder, random_file)
    stat = os.stat(shared_file)
    assert stat.st_gid == base_dict.get('edi_current_user_gid')
    assert stat.st_uid == base_dict.get('edi_current_user_uid')
    os.remove(shared_file)