예제 #1
0
def render_expected_profiles():
    user = get_user()
    dictionary = {'user': user,
                  'home': get_user_home_directory(user),
                  'target_home': '/home/{}'.format(user)}
    expected_profiles = []
    for boilerplate in expected_profile_boilerplates:
        template = Template(boilerplate)
        expected_profiles.append(normalize_yaml(template.render(dictionary)))
    return expected_profiles
예제 #2
0
    def _get_templates(self):
        collected_templates = []
        template_list = self.config.get_ordered_path_items(self.config_section)
        for name, path, dictionary, _ in template_list:
            with open(path, encoding="UTF-8", mode="r") as template_file:
                t = Template(template_file.read())
                template_text = normalize_yaml(t.render(dictionary))
                collected_templates.append((template_text, name, path, dictionary))

        return collected_templates
예제 #3
0
def render_expected_profiles():
    user = get_user()
    dictionary = {
        'user': get_user(),
        'home': get_user_environment_variable('HOME'),
        'target_home': '/home/{}'.format(user)
    }
    expected_profiles = []
    for boilerplate in expected_profile_boilerplates:
        template = Template(boilerplate)
        expected_profiles.append(normalize_yaml(template.render(dictionary)))
    return expected_profiles
예제 #4
0
    def get_pre_config_profiles(self):
        """
        Creates all profiles that can be applied prior to the configuration of the target.
        :return: list of profiles
        """
        if self._suppress_shared_folders():
            return []

        if self._config.get_ordered_raw_items('shared_folders'):
            return [(normalize_yaml(Template(profile_privileged).render({})),
                     'zzz_privileged', 'builtin', {})]
        else:
            return []
예제 #5
0
    def get_post_config_profiles(self):
        """
        Creates all profiles that can be applied after the configuration of the target.
        :return: list of profiles
        """
        if self._suppress_shared_folders():
            return []

        shared_folders = self._config.get_ordered_raw_items('shared_folders')
        if shared_folders:
            profiles = self.get_pre_config_profiles()
            template = Template(profile_shared_folder)
            for name, content, node_dict in shared_folders:
                for item in ['folder', 'mountpoint']:
                    node_dict['shared_folder_{}'.format(
                        item)] = self._get_mandatory_item(name, content, item)
                node_dict['shared_folder_name'] = name
                profiles.append((normalize_yaml(template.render(node_dict)),
                                 'zzz_{}'.format(name), 'builtin', node_dict))

            return profiles
        else:
            return []