Example #1
0
def run():
    client = Client()
    client.login(username=SUPERUSER_USERNAME, password=SUPERUSER_PASSWORD)

    # Add all planetlab aggregates
    for pl_agg in PL_AGGREGATE_INFO:
        print "adding pl agg %s" % pl_agg["url"]
        response = test_get_and_post_form(
            client,
            reverse("planetlab_aggregate_create"),
            pl_agg,
        )
        print "got response %s" % response
        assert response.status_code == 302

    for of_agg in OF_AGGREGATE_INFO:
        print "adding of agg %s" % of_agg["url"]
        response = test_get_and_post_form(
            client,
            reverse("openflow_aggregate_create"),
            of_agg,
            del_params=["verify_certs"],
        )
        assert response.status_code == 302

    for cnxn_tuple in OF_PL_CONNECTIONS:
        print "adding cnxn %s" % (cnxn_tuple, )
        NonOpenFlowConnection.objects.get_or_create(
            of_iface=OpenFlowInterface.objects.get(
                switch__datapath_id=cnxn_tuple[0],
                port_num=cnxn_tuple[1],
            ),
            resource=PlanetLabNode.objects.get(name=cnxn_tuple[2]),
        )

    client.logout()

    for username, info in USER_INFO.items():
        # create user
        User.objects.create_user(username=username,
                                 email=info["email"],
                                 password=info["password"])

        client.login(username=username, password=info["password"])
        # create project and slice
        for project in info["projects"]:
            response = test_get_and_post_form(
                client,
                reverse("project_create"),
                params=dict(
                    name=project["name"],
                    description=project["description"],
                ),
            )
            assert response.status_code == 302
            # This code is missing the project id. Need to get somehow to use reverse.
            # for slice in project["slices"]:
            #     response = test_get_and_post_form(
            #         client, reverse("slice_create"),
            #         params=dict(
            #             name=slice["name"],
            #             description=slice["description"],
            #         ),
            #     )
            #     assert response.status_code == 302
        client.logout()
Example #2
0
def run():
    client = Client()
    client.login(username=SUPERUSER_USERNAME, password=SUPERUSER_PASSWORD)

    # setup the Flowvisor
    response = test_get_and_post_form(
        client,
        reverse("set_flowvisor"),
        params=dict(
            name="flowvisor",
            username=FV_USERNAME,
            password=FV_PASSWORD,
            password2=FV_PASSWORD,
            url=FV_URL,
        ),
    )
    assert response.status_code == 301

    # setup the Clearinghouse user
    response = test_get_and_post_form(
        client,
        reverse("set_clearinghouse"),
        params=dict(
            username=CH_USERNAME,
            password1=CH_PASSWORD,
            password2=CH_PASSWORD,
        ),
    )
    assert response.status_code == 301

    client.logout()

    for username, info in USER_INFO.items():
        # create user
        User.objects.create_user(username=username,
                                 email=info["email"],
                                 password=info["password"])

        client.login(username=username, password=info["password"])
        # request flowspace
        for fs in info["flowspace"]:
            response = test_get_and_post_form(
                client,
                reverse("user_reg_fs"),
                params=dict(
                    mac_addr=fs["mac_addr"],
                    ip_addr=fs["ip_addr"],
                ),
            )
            assert response.status_code == 301
        client.logout()

    # Login to approve user requests
    client.login(username=SUPERUSER_USERNAME, password=SUPERUSER_PASSWORD)

    # Parse the approval form
    resp = client.get(reverse("approve_user_reg_table"))

    # Get all the forms
    d = pq(resp.content, parser="html")
    forms = d("form")
    for f in forms:
        # only post to approve urls
        if "approve" in f.action:
            client.post(f.action, {})

    client.logout()
Example #3
0
def run():
    client = Client()
    client.login(username=SUPERUSER_USERNAME,
                 password=SUPERUSER_PASSWORD)
    
    # Add all planetlab aggregates
    for pl_agg in PL_AGGREGATE_INFO:
        print "adding pl agg %s" % pl_agg["url"]
        response = test_get_and_post_form(
            client,
            reverse("planetlab_aggregate_create"),
            pl_agg,
        )
        print "got response %s" % response
        assert response.status_code == 302
        
    for of_agg in OF_AGGREGATE_INFO:
        print "adding of agg %s" % of_agg["url"]
        response = test_get_and_post_form(
            client,
            reverse("openflow_aggregate_create"),
            of_agg,
            del_params=["verify_certs"],
        )
        assert response.status_code == 302
        
    for cnxn_tuple in OF_PL_CONNECTIONS:
        print "adding cnxn %s" % (cnxn_tuple,)
        NonOpenFlowConnection.objects.get_or_create(
            of_iface=OpenFlowInterface.objects.get(
                switch__datapath_id=cnxn_tuple[0],
                port_num=cnxn_tuple[1],
            ),
            resource=PlanetLabNode.objects.get(name=cnxn_tuple[2]),
        )
    
    client.logout()
    
    for username, info in USER_INFO.items():
        # create user
        User.objects.create_user(
            username=username, email=info["email"], password=info["password"])
        
        client.login(username=username, password=info["password"])
        # create project and slice
        for project in info["projects"]:
            response = test_get_and_post_form(
                client, reverse("project_create"),
                params=dict(
                    name=project["name"],
                    description=project["description"],
                ),
            )
            assert response.status_code == 302
            # This code is missing the project id. Need to get somehow to use reverse.
            # for slice in project["slices"]:
            #     response = test_get_and_post_form(
            #         client, reverse("slice_create"),
            #         params=dict(
            #             name=slice["name"],
            #             description=slice["description"],
            #         ),
            #     )
            #     assert response.status_code == 302
        client.logout()
Example #4
0
def run():
    client = Client()
    client.login(username=SUPERUSER_USERNAME,
                 password=SUPERUSER_PASSWORD)
    
    # setup the Flowvisor
    response = test_get_and_post_form(
        client,
        reverse("set_flowvisor"),
        params=dict(
            name="flowvisor",
            username=FV_USERNAME,
            password=FV_PASSWORD,
            password2=FV_PASSWORD,
            url=FV_URL,
        ),
    )
    assert response.status_code == 301

    # setup the Clearinghouse user
    response = test_get_and_post_form(
        client, reverse("set_clearinghouse"),
        params=dict(
            username=CH_USERNAME,
            password1=CH_PASSWORD,
            password2=CH_PASSWORD,
        ),
    )
    assert response.status_code == 301
    
    client.logout()
    
    for username, info in USER_INFO.items():
        # create user
        User.objects.create_user(
            username=username, email=info["email"], password=info["password"])
        
        client.login(username=username, password=info["password"])
        # request flowspace
        for fs in info["flowspace"]:
            response = test_get_and_post_form(
                client, reverse("user_reg_fs"),
                params=dict(
                    mac_addr=fs["mac_addr"],
                    ip_addr=fs["ip_addr"],
                ),
            )
            assert response.status_code == 301
        client.logout()
        
    
    # Login to approve user requests
    client.login(username=SUPERUSER_USERNAME,
                 password=SUPERUSER_PASSWORD)

    # Parse the approval form
    resp = client.get(reverse("approve_user_reg_table"))
    
    # Get all the forms
    d = pq(resp.content, parser="html")
    forms = d("form")
    for f in forms:
        # only post to approve urls
        if "approve" in f.action:
            client.post(f.action, {})
    
    client.logout()