コード例 #1
0
ファイル: helper.py プロジェクト: pentikousis/C-BAS-framework
def find_supervisor(fses):
    '''
    find the admin who has the full control over all the flowspace elements in the
    fses. It does this selection by finding the admin whose flowspace is a superset of
    fses but is not a superviosr of another admin who also owns a flowspace that is
    a superset of fses.
    @param fses: the list of flowspaces we want to find an admin for
    @type fses: list of FlowSpace objects
    @return: the User object for the admin who has full control over fses
    '''
    admins_list = UserProfile.objects.filter(is_net_admin=True).order_by('-id')
    intersected_admins = []
    intersected_supervisors = []

    for admin in admins_list:
        adminfs = AdminFlowSpace.objects.filter(user=admin.user)
        if multifs_is_subset_of(fses, adminfs):
            intersected_admins.append(admin)
            intersected_supervisors.append(admin.supervisor)

    selected_admin = None
    super_admin = None
    for admin in intersected_admins:
        if (admin.user not in intersected_supervisors):
            selected_admin = admin
            break
        if (admin.supervisor == admin.user):
            super_admin = admin

    if (selected_admin):
        return selected_admin.user
    elif (super_admin):
        return super_admin.user
    else:
        return None
コード例 #2
0
ファイル: helper.py プロジェクト: HalasNet/felix
def find_supervisor(fses):
    '''
    find the admin who has the full control over all the flowspace elements in the
    fses. It does this selection by finding the admin whose flowspace is a superset of
    fses but is not a superviosr of another admin who also owns a flowspace that is
    a superset of fses.
    @param fses: the list of flowspaces we want to find an admin for
    @type fses: list of FlowSpace objects
    @return: the User object for the admin who has full control over fses
    '''
    admins_list = UserProfile.objects.filter(is_net_admin=True).order_by('-id')
    intersected_admins = []
    intersected_supervisors = []

    for admin in admins_list:
        adminfs = AdminFlowSpace.objects.filter(user=admin.user)
        if multifs_is_subset_of(fses,adminfs):
            intersected_admins.append(admin)
            intersected_supervisors.append(admin.supervisor)
                        
    selected_admin = None
    super_admin = None
    for admin in intersected_admins:
        if (admin.user not in intersected_supervisors): 
            selected_admin = admin
            break
        if (admin.supervisor==admin.user):
            super_admin = admin
    
    if (selected_admin):
        return selected_admin.user
    elif (super_admin):
        return super_admin.user
    else:
        return None
コード例 #3
0
ファイル: tests.py プロジェクト: fp7-alien/C-BAS
 def test_multifs_is_subset_of(self):
     f1 = FlowSpace(ip_src_s=2, ip_src_e=4)
     f2 = FlowSpace(ip_src_s=5, ip_src_e=9)
     f3 = FlowSpace(ip_src_s=1, ip_src_e=6)
     f4 = FlowSpace(ip_src_s=7, ip_src_e=11)  
     self.assertTrue(multifs_is_subset_of([f1,f2],[f3,f4]))
     
         
コード例 #4
0
 def test_multifs_is_subset_of(self):
     f1 = FlowSpace(ip_src_s=2, ip_src_e=4)
     f2 = FlowSpace(ip_src_s=5, ip_src_e=9)
     f3 = FlowSpace(ip_src_s=1, ip_src_e=6)
     f4 = FlowSpace(ip_src_s=7, ip_src_e=11)
     self.assertTrue(multifs_is_subset_of([f1, f2], [f3, f4]))