示例#1
0
    def get_packages(computer):
        to_install = []
        to_remove = []

        for policy in Policy.objects.filter(enabled=True):
            if policy.belongs_excluding(computer,
                                        policy.included_attributes.all(),
                                        policy.excluded_attributes.all()):
                for group in PolicyGroup.objects.filter(
                        policy=policy).order_by("priority"):
                    if policy.belongs_excluding(
                            computer, group.included_attributes.all(),
                            group.excluded_attributes.all()):
                        for pkgs in group.applications.filter(
                                packages_by_project__project__id=computer.
                                project.id).values_list(
                                    'packages_by_project__packages_to_install',
                                    flat=True):
                            to_install.extend(to_list(pkgs))

                        if policy.exclusive:
                            to_remove.extend(
                                policy.get_packages_to_remove(
                                    group, computer.project.id))
                        break

        return to_install, to_remove
示例#2
0
    def get_packages(computer):
        to_install = []
        to_remove = []

        for policy in Policy.objects.filter(enabled=True):
            if policy.belongs_excluding(
                    computer,
                    policy.included_attributes.all(),
                    policy.excluded_attributes.all()
            ):
                for group in PolicyGroup.objects.filter(
                        policy=policy
                ).order_by("priority"):
                    if policy.belongs_excluding(
                            computer,
                            group.included_attributes.all(),
                            group.excluded_attributes.all()
                    ):
                        for pkgs in group.applications.filter(
                                packages_by_project__project__id=computer.project.id
                        ).values_list(
                            'packages_by_project__packages_to_install',
                            flat=True
                        ):
                            to_install.extend(to_list(pkgs))

                        if policy.exclusive:
                            to_remove.extend(
                                policy.get_packages_to_remove(group, computer.project.id)
                            )
                        break

        return to_install, to_remove
示例#3
0
 def to_representation(self, obj):
     return {
         'project': {
             'id': obj.project.id,
             'name': obj.project.name
         },
         'packages_to_install': to_list(obj.packages_to_install)
     }
示例#4
0
    def get_packages_to_remove(group, project_id=0):
        _packages = []
        for item in PolicyGroup.objects.filter(policy=group.policy).exclude(
                id=group.id):
            for pkgs in item.applications.filter(
                    packages_by_project__project__id=project_id).values_list(
                        'packages_by_project__packages_to_install', flat=True):
                _packages.extend(to_list(pkgs))

        return _packages
示例#5
0
 def to_representation(self, obj):
     return {
         'id': obj.id,
         'application': obj.application.id,
         'project': {
             'id': obj.project.id,
             'name': obj.project.name
         },
         'packages_to_install': to_list(obj.packages_to_install)
     }
示例#6
0
    def get_packages_to_remove(group, project_id=0):
        _packages = []
        for item in PolicyGroup.objects.filter(policy=group.policy).exclude(id=group.id):
            for pkgs in item.applications.filter(
                packages_by_project__project__id=project_id
            ).values_list(
                'packages_by_project__packages_to_install',
                flat=True
            ):
                _packages.extend(to_list(pkgs))

        return _packages