コード例 #1
0
ファイル: ch_api.py プロジェクト: pentikousis/C-BAS-framework
        [fv_args, match_list] = update_opts_into_exp(e)
        if len(fv_args) > 0:
            # update previous opt-ins into this updated experiment
            try:
                returned_ids = fv.proxy.api.changeFlowSpace(fv_args)
                for i in range(len(match_list)):
                    match_list[i].fv_id = returned_ids[i]
                    match_list[i].save()
            except Exception, exc:
                from openflow.optin_manager.opts.helper import opt_fses_outof_exp
                import traceback
                traceback.print_exc()
                all_opts = UserOpts.objects.filter(experiment=e)
                for opt in all_opts:
                    optfses = OptsFlowSpace.objects.filter(opt=opt)
                    opt_fses_outof_exp(optfses)
                all_opts.delete()
                print exc
                raise Exception(
                    parseFVexception(
                        exc,
                        "Couldn't re-opt into updated experiment. Lost all the opt-ins: "
                    ))

    flowspace_correctly_granted = True
    automatic_settings = get_automatic_settings()
    try:
        if automatic_settings["flowspace_auto_approval"]:
            auto_fs_granter(e)
    # FIXME An exception is being raised. Investigate.
    except Exception as exc:
コード例 #2
0
ファイル: views.py プロジェクト: cargious/ocf
def opt_out(request):
    '''
    The view function for opt-out. 
    the request.POST should contain {UserOpts.id:"checked"} for all the UserOpts
    to be opted out.
    '''
    error_msg = []
    profile = UserProfile.get_or_create_profile(request.user)
    keys = request.POST.keys()

    if (request.method == "POST"):
        fv_args = []
        for key in keys:
            try:
                # check all the keys that are integer values and opt them out.
                int(key)
                opt = UserOpts.objects.get(id=key)
            except:
                continue

            ofs = OptsFlowSpace.objects.filter(opt=opt)
            new_fv_args = opt_fses_outof_exp(ofs)
            fv_args = fv_args + new_fv_args
            opt.delete()

        if len(error_msg) == 0:
            # Now make sure the priorities are consequative
            nice_opts = UserOpts.objects.filter(user=request.user,
                                                nice=True).order_by('priority')
            next_priority = profile.max_priority_level - Priority.Strict_Priority_Offset - 1
            for opt in nice_opts:
                if opt.priority != next_priority:
                    opt.priority = next_priority
                    opt.save()
                    new_args = update_match_struct_priority_and_get_fv_args(
                        opt)
                    fv_args = fv_args + new_args
                next_priority = next_priority - 1
            strict_opts = UserOpts.objects.filter(
                user=request.user, nice=False).order_by('priority')
            next_priority = profile.max_priority_level - 1
            for opt in strict_opts:
                if opt.priority != next_priority:
                    opt.priority = next_priority
                    opt.save()
                    new_args = update_match_struct_priority_and_get_fv_args(
                        opt)
                    fv_args = fv_args + new_args
                next_priority = next_priority - 1

            try:
                fv = FVServerProxy.objects.all()[0]
                try:
                    if len(fv_args) > 0:
                        fv.proxy.api.changeFlowSpace(fv_args)
                except Exception, e:
                    import traceback
                    traceback.print_exc()
                    transaction.rollback()
                    error_msg.append(
                        "change flowspace in opt_out view failed: %s" % str(e))
            except Exception, e:
                import traceback
                traceback.print_exc()
                transaction.rollback()
                error_msg.append("Flowvisor not set: %s" % str(e))
コード例 #3
0
ファイル: views.py プロジェクト: cargious/ocf
            if (len(error_msg) == 0):
                userFS = UserFlowSpace.objects.filter(user=request.user)

                # check if the user already have opted into this experiment before
                prev_opts = UserOpts.objects.filter(experiment=selexp)
                if (prev_opts.count() > 0):
                    assigned_priority = prev_opts[0].priority
                    all_prev_opts_fs = []
                    for a_prev_opt in prev_opts:
                        a_prev_opt_fses = a_prev_opt.optsflowspace_set.all()
                        for a_prev_opt_fs in a_prev_opt_fses:
                            all_prev_opts_fs.append(a_prev_opt_fs)

                    # now opt out the flowpsaces and clear flowspace and match_struct entries
                    # from the database:
                    del_fv_args = opt_fses_outof_exp(all_prev_opts_fs)

                    # delete all the previous opts into this experiemnt from the database
                    prev_opts.delete()
                else:
                    del_fv_args = []

                # Now opt the user into the selected experiemnt
                [add_fv_args,
                 match_list] = opt_fs_into_exp(userFS, selexp, request.user,
                                               assigned_priority, True)

                try:
                    fv = FVServerProxy.objects.all()[0]
                    try:
                        fv_args = add_fv_args + del_fv_args
コード例 #4
0
ファイル: CreateOFSliver.py プロジェクト: fp7-alien/C-BAS
    [fv_args,match_list] = update_opts_into_exp(e)
    if len(fv_args) > 0:
        # update previous opt-ins into this updated experiment
        try:
            returned_ids = fv.proxy.api.changeFlowSpace(fv_args)
            for i in range(len(match_list)):
                match_list[i].fv_id = returned_ids[i]
                match_list[i].save()
        except Exception, exc:
            from openflow.optin_manager.opts.helper import opt_fses_outof_exp
            import traceback
            traceback.print_exc()
            all_opts = UserOpts.objects.filter(experiment=e)
            for opt in all_opts:
                optfses = OptsFlowSpace.objects.filter(opt = opt)
                opt_fses_outof_exp(optfses)
            all_opts.delete()
            print exc
            raise Exception(parseFVexception(exc,"Couldn't re-opt into updated experiment. Lost all the opt-ins: "))
         
try:
    # Get project detail URL to send via e-mail
    from openflow.optin_manager.opts import urls
    from django.core.urlresolvers import reverse
    project_detail_url = reverse("opt_in_experiment") or "/"
    # No "https://" check should be needed if settings are OK
    site_domain_url = "https://" + Site.objects.get_current().domain + project_detail_url
    # Tuple with the requested VLAN range
    try:
        vlan_range = "\nVLAN range: %s\n\n" % str((all_efs[0].vlan_id_s, all_efs[0].vlan_id_e))
    except:
コード例 #5
0
ファイル: views.py プロジェクト: HalasNet/felix
def opt_out(request):
    '''
    The view function for opt-out. 
    the request.POST should contain {UserOpts.id:"checked"} for all the UserOpts
    to be opted out.
    '''
    error_msg = []
    profile = UserProfile.get_or_create_profile(request.user)
    keys = request.POST.keys()
    

    if (request.method == "POST"):
        fv_args = []
        for key in keys:
            try:
                # check all the keys that are integer values and opt them out.
                int(key)
                opt = UserOpts.objects.get(id=key)
            except:
                continue
                
            ofs = OptsFlowSpace.objects.filter(opt=opt)
            new_fv_args = opt_fses_outof_exp(ofs)
            fv_args = fv_args + new_fv_args
            opt.delete()  
                  
        if len(error_msg) == 0:            
            # Now make sure the priorities are consequative
            nice_opts = UserOpts.objects.filter(user = request.user,nice=True).order_by('priority')
            next_priority = profile.max_priority_level - Priority.Strict_Priority_Offset - 1
            for opt in nice_opts:
                if opt.priority != next_priority:
                    opt.priority = next_priority
                    opt.save()
                    new_args = update_match_struct_priority_and_get_fv_args(opt)
                    fv_args = fv_args + new_args
                next_priority = next_priority - 1
            strict_opts = UserOpts.objects.filter(user = request.user,nice=False).order_by('priority')
            next_priority = profile.max_priority_level - 1
            for opt in strict_opts:
                if opt.priority != next_priority:
                    opt.priority = next_priority
                    opt.save()
                    new_args = update_match_struct_priority_and_get_fv_args(opt)
                    fv_args = fv_args + new_args
                next_priority = next_priority -1
                        
            try:
                fv = FVServerProxy.objects.all()[0]
                try:
                    if len(fv_args) > 0:
                        fv.proxy.api.changeFlowSpace(fv_args)
                except Exception,e:
                    import traceback
                    traceback.print_exc()
                    transaction.rollback()
                    error_msg.append("change flowspace in opt_out view failed: %s"%str(e))
            except Exception,e:
                import traceback
                traceback.print_exc()
                transaction.rollback()
                error_msg.append("Flowvisor not set: %s"%str(e))
コード例 #6
0
ファイル: views.py プロジェクト: HalasNet/felix
            if (len(error_msg)==0):
                userFS = UserFlowSpace.objects.filter(user = request.user)                    

                # check if the user already have opted into this experiment before
                prev_opts = UserOpts.objects.filter(experiment = selexp)
                if (prev_opts.count() > 0):
                    assigned_priority = prev_opts[0].priority
                    all_prev_opts_fs = []
                    for a_prev_opt in prev_opts:
                        a_prev_opt_fses = a_prev_opt.optsflowspace_set.all()
                        for a_prev_opt_fs in a_prev_opt_fses:
                            all_prev_opts_fs.append(a_prev_opt_fs)
                    
                    # now opt out the flowpsaces and clear flowspace and match_struct entries 
                    # from the database:
                    del_fv_args = opt_fses_outof_exp(all_prev_opts_fs)
                    
                    # delete all the previous opts into this experiemnt from the database    
                    prev_opts.delete()
                else:
                    del_fv_args = []
                    
                # Now opt the user into the selected experiemnt
                [add_fv_args,match_list] = opt_fs_into_exp(userFS,selexp,request.user,
                                        assigned_priority,True)
                    
                try:
                    fv = FVServerProxy.objects.all()[0]
                    try:
                        fv_args = add_fv_args + del_fv_args
                        if len(fv_args) > 0: