예제 #1
0
    def get_active_policies(self, username):

        user_policy = self.db_service.select('policy', ['id', 'version', 'name'],
                                             ' type=\'U\' and name=\'' + username + '\'')
        ahenk_policy = self.db_service.select('policy', ['id', 'version'], ' type=\'A\' ')

        plugin_columns = ['id', 'active', 'create_date', 'deleted', 'description', 'machine_oriented', 'modify_date',
                          'name', 'policy_plugin', 'user_oriented', 'version', 'task_plugin', 'x_based']
        profile_columns = ['id', 'create_date', 'label', 'description', 'overridable', 'active', 'deleted',
                           'profile_data', 'modify_date', 'plugin']

        policy = PolicyBean(username=username)

        if len(user_policy) > 0:
            user_policy_version = user_policy[0][0]
            policy.set_user_policy_version(user_policy_version)
            user_profiles = self.db_service.select('profile', profile_columns, ' id=' + str(user_policy_version) + ' ')
            arr_profiles = []
            if len(user_profiles) > 0:
                for profile in user_profiles:
                    plu = self.db_service.select('plugin', plugin_columns, ' id=\'' + profile[9] + '\'')[0]
                    plugin = PluginBean(p_id=plu[0], active=plu[1], create_date=plu[2], deleted=plu[3],
                                        description=plu[4], machine_oriented=plu[5], modify_date=plu[6], name=plu[7],
                                        policy_plugin=plu[8], user_oriented=plu[9], version=plu[10],
                                        task_plugin=plu[11], x_based=plu[12])

                    arr_profiles.append(
                        ProfileBean(profile[0], profile[1], profile[2], profile[3], profile[4], profile[5], profile[6],
                                    profile[7], profile[8], plugin, policy.get_username()))
                policy.set_user_profiles(arr_profiles)

        if len(ahenk_policy) > 0:
            ahenk_policy_version = ahenk_policy[0][0]
            policy.set_ahenk_policy_version(ahenk_policy_version)
            ahenk_profiles = self.db_service.select('profile', profile_columns,
                                                    ' id=' + str(ahenk_policy_version) + ' ')
            arr_profiles = []
            if len(ahenk_profiles) > 0:
                for profile in ahenk_profiles:
                    plu = self.db_service.select('plugin', plugin_columns, ' id=\'' + profile[9] + '\'')[0]
                    plugin = PluginBean(p_id=plu[0], active=plu[1], create_date=plu[2], deleted=plu[3],
                                        description=plu[4], machine_oriented=plu[5], modify_date=plu[6], name=plu[7],
                                        policy_plugin=plu[8], user_oriented=plu[9], version=plu[10],
                                        task_plugin=plu[11], x_based=plu[12])

                    arr_profiles.append(
                        ProfileBean(profile[0], profile[1], profile[2], profile[3], profile[4], profile[5], profile[6],
                                    profile[7], profile[8], plugin, policy.get_username()))
                policy.set_ahenk_profiles(arr_profiles)

        return policy
예제 #2
0
    def get_active_policies(self, username):

        try:
            # TODO vt den gecerli son tarihi olani cek
            user_policy = self.db_service.select(
                'policy', ['id', 'version', 'name', 'expiration_date'],
                ' type=\'U\' and name=\'' + username + '\'')
            ahenk_policy = self.db_service.select(
                'policy', ['id', 'version', 'expiration_date'], ' type=\'A\' ')

            plugin_columns = [
                'id', 'active', 'create_date', 'deleted', 'description',
                'machine_oriented', 'modify_date', 'name', 'policy_plugin',
                'user_oriented', 'version', 'task_plugin', 'x_based'
            ]
            profile_columns = [
                'id', 'create_date', 'label', 'description', 'overridable',
                'active', 'deleted', 'profile_data', 'modify_date', 'plugin'
            ]

            policy = PolicyBean(username=username)

            if len(user_policy) > 0 and self.check_expiration(
                    user_policy[0][3]):
                user_policy_version = user_policy[0][0]
                policy.set_user_policy_version(user_policy_version)

                user_profiles = self.db_service.select(
                    'profile', profile_columns,
                    ' id=' + str(user_policy_version) + ' ')
                arr_profiles = []
                if len(user_profiles) > 0:
                    for profile in user_profiles:
                        plu = self.db_service.select(
                            'plugin', plugin_columns,
                            ' id=\'' + profile[9] + '\'')[0]
                        plugin = PluginBean(p_id=plu[0],
                                            active=plu[1],
                                            create_date=plu[2],
                                            deleted=plu[3],
                                            description=plu[4],
                                            machine_oriented=plu[5],
                                            modify_date=plu[6],
                                            name=plu[7],
                                            policy_plugin=plu[8],
                                            user_oriented=plu[9],
                                            version=plu[10],
                                            task_plugin=plu[11],
                                            x_based=plu[12])

                        arr_profiles.append(
                            ProfileBean(profile[0], profile[1], profile[2],
                                        profile[3], profile[4], profile[5],
                                        profile[6], profile[7], profile[8],
                                        plugin, policy.get_username()))
                    policy.set_user_profiles(arr_profiles)

            if len(ahenk_policy) > 0 and self.check_expiration(
                    ahenk_policy[0][2]):
                ahenk_policy_version = ahenk_policy[0][0]
                policy.set_ahenk_policy_version(ahenk_policy_version)
                ahenk_profiles = self.db_service.select(
                    'profile', profile_columns,
                    ' id=' + str(ahenk_policy_version) + ' ')
                arr_profiles = []
                if len(ahenk_profiles) > 0:
                    for profile in ahenk_profiles:
                        plu = self.db_service.select(
                            'plugin', plugin_columns,
                            ' id=\'' + profile[9] + '\'')[0]
                        plugin = PluginBean(p_id=plu[0],
                                            active=plu[1],
                                            create_date=plu[2],
                                            deleted=plu[3],
                                            description=plu[4],
                                            machine_oriented=plu[5],
                                            modify_date=plu[6],
                                            name=plu[7],
                                            policy_plugin=plu[8],
                                            user_oriented=plu[9],
                                            version=plu[10],
                                            task_plugin=plu[11],
                                            x_based=plu[12])

                        arr_profiles.append(
                            ProfileBean(profile[0], profile[1], profile[2],
                                        profile[3], profile[4], profile[5],
                                        profile[6], profile[7], profile[8],
                                        plugin, policy.get_username()))
                    policy.set_ahenk_profiles(arr_profiles)

            return policy
        except Exception as e:
            self.logger.error(
                'A problem occurred while getting active policies. Error Message : {0}'
                .format(str(e)))
예제 #3
0
    def get_active_policies(self, username):

        user_policy = self.db_service.select(
            'policy', ['id', 'version', 'name'],
            ' type=\'U\' and name=\'' + username + '\'')
        ahenk_policy = self.db_service.select('policy', ['id', 'version'],
                                              ' type=\'A\' ')

        plugin_columns = [
            'id', 'active', 'create_date', 'deleted', 'description',
            'machine_oriented', 'modify_date', 'name', 'policy_plugin',
            'user_oriented', 'version', 'task_plugin', 'x_based'
        ]
        profile_columns = [
            'id', 'create_date', 'label', 'description', 'overridable',
            'active', 'deleted', 'profile_data', 'modify_date', 'plugin'
        ]

        policy = PolicyBean(username=username)

        if len(user_policy) > 0:
            user_policy_version = user_policy[0][0]
            policy.set_user_policy_version(user_policy_version)
            user_profiles = self.db_service.select(
                'profile', profile_columns,
                ' id=' + str(user_policy_version) + ' ')
            arr_profiles = []
            if len(user_profiles) > 0:
                for profile in user_profiles:
                    plu = self.db_service.select('plugin', plugin_columns,
                                                 ' id=\'' + profile[9] +
                                                 '\'')[0]
                    plugin = PluginBean(p_id=plu[0],
                                        active=plu[1],
                                        create_date=plu[2],
                                        deleted=plu[3],
                                        description=plu[4],
                                        machine_oriented=plu[5],
                                        modify_date=plu[6],
                                        name=plu[7],
                                        policy_plugin=plu[8],
                                        user_oriented=plu[9],
                                        version=plu[10],
                                        task_plugin=plu[11],
                                        x_based=plu[12])

                    arr_profiles.append(
                        ProfileBean(profile[0], profile[1], profile[2],
                                    profile[3], profile[4], profile[5],
                                    profile[6], profile[7], profile[8], plugin,
                                    policy.get_username()))
                policy.set_user_profiles(arr_profiles)

        if len(ahenk_policy) > 0:
            ahenk_policy_version = ahenk_policy[0][0]
            policy.set_ahenk_policy_version(ahenk_policy_version)
            ahenk_profiles = self.db_service.select(
                'profile', profile_columns,
                ' id=' + str(ahenk_policy_version) + ' ')
            arr_profiles = []
            if len(ahenk_profiles) > 0:
                for profile in ahenk_profiles:
                    plu = self.db_service.select('plugin', plugin_columns,
                                                 ' id=\'' + profile[9] +
                                                 '\'')[0]
                    plugin = PluginBean(p_id=plu[0],
                                        active=plu[1],
                                        create_date=plu[2],
                                        deleted=plu[3],
                                        description=plu[4],
                                        machine_oriented=plu[5],
                                        modify_date=plu[6],
                                        name=plu[7],
                                        policy_plugin=plu[8],
                                        user_oriented=plu[9],
                                        version=plu[10],
                                        task_plugin=plu[11],
                                        x_based=plu[12])

                    arr_profiles.append(
                        ProfileBean(profile[0], profile[1], profile[2],
                                    profile[3], profile[4], profile[5],
                                    profile[6], profile[7], profile[8], plugin,
                                    policy.get_username()))
                policy.set_ahenk_profiles(arr_profiles)

        return policy