Example #1
0
    def test_change_password(self):
        """
        Tests that the Clearinghouse password can be changed correctly.
        """
        from django.contrib.auth.models import User
        wrap_xmlrpc_call(self.om_client.change_password, ["new_password"], {},
                         TIMEOUT)

        user = User.objects.get(username="******")

        self.assertTrue(user.check_password("new_password"))
Example #2
0
 def test_change_password(self):
     """
     Tests that the Clearinghouse password can be changed correctly.
     """
     from django.contrib.auth.models import User
     wrap_xmlrpc_call(
         self.om_client.change_password, ["new_password"], {},
         TIMEOUT)
     
     user = User.objects.get(username="******")
     
     self.assertTrue(user.check_password("new_password"))
Example #3
0
File: om.py Project: cargious/ocf
 def test_ping(self):
     """
     Communications are up.
     """
     ret = wrap_xmlrpc_call(
         self.om_client.ping, ["PING"], {}, test_settings.TIMEOUT)
     self.assertEqual(ret, "PONG: PING", "Ping returned %s." % ret)
Example #4
0
    def test_ListResources(self):
        """
        Check the list of resources.
        """

        # check the switches on the FV
        devices = self.fv_clients[0].api.listDevices()
        logger.debug("FV devices: %s" % devices)
        self.assertEqual(len(set(devices)), self.EXPECTED_NUM_SWITCHES)
        
        slice_urn, cred = self.create_ch_slice()
        options = dict(geni_compressed=False, geni_available=True)
        rspec = wrap_xmlrpc_call(
            self.am_client.ListResources, [cred, options], {}, 
            test_settings.TIMEOUT)
        
        logger.debug(rspec)
        
        # Create switches and links
        self.switches, self.links = parse_rspec(rspec)
        
        # check the number of switches and links
        self.assertEqual(len(self.switches), self.EXPECTED_NUM_SWITCHES)
        self.assertEqual(len(self.links), self.EXPECTED_NUM_LINKS)
        return slice_urn, cred
Example #5
0
File: om.py Project: cargious/ocf
    def test_get_links(self):
        """
        Tests that the links are retrieved correctly from the FV.
        """
        from openflow.optin_manager.dummyfv.models import DummyFVLink

        links = wrap_xmlrpc_call(
            self.om_client.get_links, [], {}, test_settings.TIMEOUT)
        links = set([tuple(l[:-1]) for l in links])
#        print "Received links:"
#        pprint(links)
        
        # TODO add checking for the link_infos (link attributes)
        
        expected = set([(
            link.src_dev.dpid,
            link.src_port,
            link.dst_dev.dpid,
            link.dst_port) for link in DummyFVLink.objects.all()])
#        print "Expected links:"
#        pprint(expected)
        
        self.assertTrue(
            links.issubset(expected),
            "Received links have %s not in expected links" % (
                links - expected,
            )
        )
        self.assertTrue(
            expected.issubset(links),
            "Expected links have %s not in received links" % (
                expected - links,
            )
        )
 def test_ListResources(self, zipped=False):
     """
     Check the list of resources.
     """
     from openflow.dummyom.models import DummyOM
     slice_urn, cred = self.create_ch_slice()
     options = dict(geni_compressed=zipped, geni_available=True)
     rspec = wrap_xmlrpc_call(
         self.am_client.ListResources,
         [cred, options], {}, settings.TIMEOUT)
     
     logger.debug("Got Advertisement RSpec: \n%s" % rspec)
     
     if zipped:
         import zlib, base64
         rspec = zlib.decompress(base64.b64decode(rspec))
     
     # Create switches and links
     self.switches, self.links = parse_rspec(rspec)
     
     # check the number of switches and links
     num_links = sum([len(d.get_switches()) for d in DummyOM.objects.all()])
     self.assertEqual(len(self.switches),
                      num_links)
     self.assertEqual(len(self.links),
                      settings.NUM_LINKS_PER_AGG * settings.NUM_DUMMY_OMS)
    def test_CreateDeleteSliver(self):
        """
        Tests that we can create a sliver.
        """
        from expedient.clearinghouse.slice.models import Slice
        from openflow.dummyom.models import DummyOMSlice
        
        # get the resources
        slice_urn, cred = self.create_ch_slice()
        options = dict(geni_compressed=False, geni_available=True)
        rspec = wrap_xmlrpc_call(
            self.am_client.ListResources,
            [cred, options], {}, settings.TIMEOUT)
        
        # Create switches and links
        self.switches, self.links = parse_rspec(rspec)

        # create a random reservation
        resv_rspec, flowspaces = create_random_resv(20, self.switches)
        users = [{'key':''}]
        self.am_client.CreateSliver(slice_urn, cred, resv_rspec, users)
        
        # delete the sliver
        self.assertTrue(self.am_client.DeleteSliver(slice_urn, cred))
        
        time.sleep(5)
        
        # Make sure it is gone from the CH and the OMs
        self.assertTrue(Slice.objects.all().count() == 0,
                        "Slice not deleted in Expedient")
        self.assertTrue(DummyOMSlice.objects.all().count() == 0,
                        "Slice not deleted in the OMs")
 def test_GetVersion(self):
     """
     Tests that get version returns 1.
     """
     ret = wrap_xmlrpc_call(
         self.am_client.GetVersion, [], {}, settings.TIMEOUT)
     self.assertEqual(ret['geni_api'], 1)
Example #9
0
    def test_delete_slice(self):
        """
        Tests that slices are deleted correctly from the OM to FV
        """

        num_slices = random.randint(1, 5)
        for i in range(num_slices):
            self.test_create_slice(id=i)

        # delete some slices and make sure they are gone
        ids = range(1, num_slices)
        random.shuffle(ids)
        for i in ids:
            err = wrap_xmlrpc_call(self.om_client.delete_slice, [i], {},
                                   TIMEOUT)
            self.assertEqual(err, "")
            num_slices -= 1
            for fv in DummyFV.objects.all():
                num_actual_slices = DummyFVSlice.objects.filter(fv=fv).count()
                self.assertTrue(
                    num_actual_slices == num_slices,
                    "Expected %s slices after delete but found %s" %
                    (num_slices, num_actual_slices))
            # Check internal OM database:
            count = Experiment.objects.all().count()
            self.assertEqual(count, num_slices,
                             "There are more slices in OM than expected")
            count = Experiment.objects.filter(slice_id=i).count()
            self.assertEqual(count, 0, "Slice in OM has not deleted!")
            count = ExperimentFLowSpace.objects.filter(exp__slice_id=i).count()
            self.assertEqual(
                count, 0,
                "FlowSpace associated with experiment slice_id" +\
                "=%d has not deleted completely" % i)
Example #10
0
File: gapi.py Project: cargious/ocf
    def test_CreateDeleteSliver(self):
        """
        Tests that we can create a sliver.
        """
        from expedient.clearinghouse.slice.models import Slice
        from openflow.dummyom.models import DummyOMSlice

        # get the resources
        slice_urn, cred = self.create_ch_slice()
        options = dict(geni_compressed=False, geni_available=True)
        rspec = wrap_xmlrpc_call(self.am_client.ListResources, [cred, options],
                                 {}, settings.TIMEOUT)

        # Create switches and links
        self.switches, self.links = parse_rspec(rspec)

        # create a random reservation
        resv_rspec, flowspaces = create_random_resv(20, self.switches)
        users = [{'key': ''}]
        self.am_client.CreateSliver(slice_urn, cred, resv_rspec, users)

        # delete the sliver
        self.assertTrue(self.am_client.DeleteSliver(slice_urn, cred))

        time.sleep(5)

        # Make sure it is gone from the CH and the OMs
        self.assertTrue(Slice.objects.all().count() == 0,
                        "Slice not deleted in Expedient")
        self.assertTrue(DummyOMSlice.objects.all().count() == 0,
                        "Slice not deleted in the OMs")
Example #11
0
 def test_ping(self):
     """
     Communications are up.
     """
     ret = wrap_xmlrpc_call(
         self.om_client.ping, ["PING"], {}, TIMEOUT)
     self.assertEqual(ret, "PONG: PING", "Ping returned %s." % ret)
Example #12
0
    def test_get_links(self):
        """
        Tests that the links are retrieved correctly from the FV.
        """
        from openflow.optin_manager.dummyfv.models import DummyFVLink

        links = wrap_xmlrpc_call(
            self.om_client.get_links, [], {}, TIMEOUT)
        links = set([tuple(l[:-1]) for l in links])


        # TODO add checking for the link_infos (link attributes)
        expected = set([(
            link.src_dev.dpid,
            link.src_port,
            link.dst_dev.dpid,
            link.dst_port) for link in DummyFVLink.objects.all()])

        
        self.assertTrue(
            links.issubset(expected),
            "Received links have %s not in expected links" % (
                links - expected,
            )
        )
        self.assertTrue(
            expected.issubset(links),
            "Expected links have %s not in received links" % (
                expected - links,
            )
        )
Example #13
0
File: gapi.py Project: cargious/ocf
 def test_GetVersion(self):
     """
     Tests that get version returns 1.
     """
     ret = wrap_xmlrpc_call(self.am_client.GetVersion, [], {},
                            settings.TIMEOUT)
     self.assertEqual(ret['geni_api'], 1)
def xmlrpc_wrap_delete_slice(username, password, url, slice_id):
    xmlrpc_proxy = PasswordXMLRPCServerProxy()
    xmlrpc_proxy.setup(username, password, url, False)
    try:
        returned_data = wrap_xmlrpc_call(xmlrpc_proxy.delete_slice,[slice_id],{},10)
        return returned_data
    except Exception,e:
        return str(e)   
Example #15
0
def xmlrpc_wrap_ping(username, password, url, ping_data):
    xmlrpc_proxy = PasswordXMLRPCServerProxy()
    xmlrpc_proxy.setup(username, password, url, False)
    try:
        data = wrap_xmlrpc_call(xmlrpc_proxy.ping, [ping_data], {}, 10)
        return data
    except Exception, e:
        return str(e)
def xmlrpc_wrap_change_password(username, password, url,new_password):
    xmlrpc_proxy = PasswordXMLRPCServerProxy()
    xmlrpc_proxy.setup(username, password, url, False)
    try:
        returned_data = wrap_xmlrpc_call(xmlrpc_proxy.change_password,[new_password],{},10)
        return returned_data
    except Exception,e:
        return str(e)
def xmlrpc_wrap_ping(username,password,url,ping_data):
    xmlrpc_proxy = PasswordXMLRPCServerProxy()
    xmlrpc_proxy.setup(username, password, url, False)
    try:
        data = wrap_xmlrpc_call(xmlrpc_proxy.ping,[ping_data],{},10)
        return data
    except Exception,e:
        return str(e)
def xmlrpc_wrap_register_topology_callback(username, password, om_url,url,cookie):
    xmlrpc_proxy = PasswordXMLRPCServerProxy()
    xmlrpc_proxy.setup(username, password, om_url, False)
    try:
        returned_data = wrap_xmlrpc_call(xmlrpc_proxy.register_topology_callback,[url,cookie],{},10)
        return returned_data
    except Exception,e:
        return str(e)
Example #19
0
def xmlrpc_wrap_get_links(username, password, url):
    xmlrpc_proxy = PasswordXMLRPCServerProxy()
    xmlrpc_proxy.setup(username, password, url, False)
    try:
        returned_data = wrap_xmlrpc_call(xmlrpc_proxy.get_links, [], {}, 10)
        return returned_data
    except Exception, e:
        return str(e)
def xmlrpc_wrap_get_links(username, password, url):
    xmlrpc_proxy = PasswordXMLRPCServerProxy()
    xmlrpc_proxy.setup(username, password, url, False)
    try:
        returned_data = wrap_xmlrpc_call(xmlrpc_proxy.get_links,[],{},10)
        return returned_data
    except Exception,e:
        return str(e)
Example #21
0
def xmlrpc_wrap_delete_slice(username, password, url, slice_id):
    xmlrpc_proxy = PasswordXMLRPCServerProxy()
    xmlrpc_proxy.setup(username, password, url, False)
    try:
        returned_data = wrap_xmlrpc_call(xmlrpc_proxy.delete_slice, [slice_id],
                                         {}, 10)
        return returned_data
    except Exception, e:
        return str(e)
Example #22
0
def xmlrpc_wrap_change_password(username, password, url, new_password):
    xmlrpc_proxy = PasswordXMLRPCServerProxy()
    xmlrpc_proxy.setup(username, password, url, False)
    try:
        returned_data = wrap_xmlrpc_call(xmlrpc_proxy.change_password,
                                         [new_password], {}, 10)
        return returned_data
    except Exception, e:
        return str(e)
Example #23
0
def xmlrpc_wrap_register_topology_callback(username, password, om_url, url,
                                           cookie):
    xmlrpc_proxy = PasswordXMLRPCServerProxy()
    xmlrpc_proxy.setup(username, password, om_url, False)
    try:
        returned_data = wrap_xmlrpc_call(
            xmlrpc_proxy.register_topology_callback, [url, cookie], {}, 10)
        return returned_data
    except Exception, e:
        return str(e)
Example #24
0
    def test_CreateDeleteSliver(self):
        """
        Check that we can create then delete a sliver.
        """
        slice_urn, cred = self.test_CreateSliver()

        self.assertTrue(
            wrap_xmlrpc_call(self.am_client.DeleteSliver, [slice_urn, cred],
                             {}, test_settings.TIMEOUT),
            "Failed to delete sliver.")

        self.assertEqual(
            len(self.fv_clients[0].api.listSlices()),
            1,
            "Slice not deleted at FlowVisor",
        )
Example #25
0
 def create_ch_slice(self):
     """
     Code mostly copied from GENI test harness from BBN.
     """
     import gcf.sfa.trust.credential as cred
     
     slice_cred_string = wrap_xmlrpc_call(
         self.ch_client.CreateSlice, [], {}, test_settings.TIMEOUT)
     slice_credential = cred.Credential(string=slice_cred_string)
     slice_gid = slice_credential.get_gid_object()
     slice_urn = slice_gid.get_urn()
     
     # Set up the array of credentials as just the slice credential
     credentials = [slice_cred_string]
     
     return (slice_urn, credentials)
Example #26
0
    def run_flowvisor(self, flowvisor):
        """
        Run flowvisor.
        Delete all the rules and slices.
        """

        if RUN_FV_SUBPROCESS:
            kill_old_procs(flowvisor["of_port"], flowvisor["xmlrpc_port"])

            self.fv_procs.append(
                self.run_proc_cmd(
                    "%s/scripts/flowvisor.sh %s/%s 2>&1 | tee /tmp/flowvisor.out "
                    % (
                        flowvisor["path"][0],
                        flowvisor["path"][0],
                        flowvisor["path"][1],
                    )))

        id_re = re.compile(r"id=\[(?P<id>\d+)\]")
        fv_url = "https://%s:%s@%s:%s" % (
            flowvisor["username"],
            flowvisor["password"],
            flowvisor["host"],
            flowvisor["xmlrpc_port"],
        )

        s = xmlrpclib.ServerProxy(fv_url)

        logger.debug("Waiting for flowvisor to be up.")
        ret = wrap_xmlrpc_call(s.api.ping, ["PONG"], {}, test_settings.TIMEOUT)
        logger.debug("Ping returned: %s" % ret)

        logger.debug("Getting flowspace from flowvisor")
        flowspaces = s.api.listFlowSpace()
        ops = []
        logger.debug("Deleting all flowspace")
        for fs in flowspaces:
            id = id_re.search(fs).group("id")
            ops.append(dict(operation="REMOVE", id=id))
        if ops:
            s.api.changeFlowSpace(ops)

        slices = s.api.listSlices()
        [s.api.deleteSlice(slice) for slice in slices if slice != "root"]

        self.fv_clients.append(s)
 def test_parse_slice(self):
     from openflow.plugin.gapi.rspec import parse_slice
     
     # get the resources
     slice_urn, cred = self.create_ch_slice()
     options = dict(geni_compressed=False, geni_available=True)
     rspec = wrap_xmlrpc_call(
         self.am_client.ListResources,
         [cred, options], {}, settings.TIMEOUT)
     
     logger.debug("Got RSpec\n%s" % rspec)
     
     # Create switches and links
     self.switches, self.links = parse_rspec(rspec)
     
     # create a random reservation
     vals = dict(
        firstname="John", lastname="Doe",
        email="*****@*****.**", password="******",
        proj_name="Stanford Networking",
        proj_desc="Making the world better.",
        slice_name="Crazy Load Balancer",
        slice_desc="Does this and that...",
        ctrl_url="tcp:controller.stanford.edu:6633")
     resv_rspec, flowspaces = create_random_resv(2, self.switches, **vals)
     
     project_name, project_desc, slice_name, slice_desc,\
     controller_url, email, password, iface_fs_map = parse_slice(resv_rspec)
     
     self.assertEqual(project_name, vals["proj_name"])
     self.assertEqual(project_desc, vals["proj_desc"])
     self.assertEqual(slice_name, vals["slice_name"])
     self.assertEqual(slice_desc, vals["slice_desc"])
     self.assertEqual(controller_url, vals["ctrl_url"])
     self.assertEqual(email, vals["email"])
     self.assertEqual(password, vals["password"])
     
     dpid_fs_map = {} # map dpid to requested fs
     for fs in flowspaces:
         for sw in fs.switches:
             if sw.dpid not in dpid_fs_map:
                 dpid_fs_map[sw.dpid] = []
             dpid_fs_map[sw.dpid].append(fs)
     
     logger.debug(iface_fs_map)
    def run_flowvisor(self, flowvisor):
        """
        Run flowvisor.
        Delete all the rules and slices.
        """
        
        if RUN_FV_SUBPROCESS:
            kill_old_procs(flowvisor["of_port"],
                           flowvisor["xmlrpc_port"])

            self.fv_procs.append(
                self.run_proc_cmd(
                    "%s/scripts/flowvisor.sh %s/%s 2>&1 | tee /tmp/flowvisor.out " % (
                        flowvisor["path"][0], flowvisor["path"][0],
                        flowvisor["path"][1],
                    )
                )
            )
        
        id_re = re.compile(r"id=\[(?P<id>\d+)\]")
        fv_url = "https://%s:%s@%s:%s" % (
            flowvisor["username"], flowvisor["password"],
            flowvisor["host"], flowvisor["xmlrpc_port"],
        )

        s = xmlrpclib.ServerProxy(fv_url)
        
        logger.debug("Waiting for flowvisor to be up.")
        ret = wrap_xmlrpc_call(s.api.ping, ["PONG"], {}, test_settings.TIMEOUT)
        logger.debug("Ping returned: %s" % ret)
        
        logger.debug("Getting flowspace from flowvisor")
        flowspaces = s.api.listFlowSpace()
        ops = []
        logger.debug("Deleting all flowspace")
        for fs in flowspaces:
            id = id_re.search(fs).group("id")
            ops.append(dict(operation="REMOVE", id=id))
        if ops:
            s.api.changeFlowSpace(ops)
        
        slices = s.api.listSlices()
        [s.api.deleteSlice(slice) for slice in slices if slice != "root"]
        
        self.fv_clients.append(s)
Example #29
0
File: gapi.py Project: cargious/ocf
    def test_parse_slice(self):
        from openflow.plugin.gapi.rspec import parse_slice

        # get the resources
        slice_urn, cred = self.create_ch_slice()
        options = dict(geni_compressed=False, geni_available=True)
        rspec = wrap_xmlrpc_call(self.am_client.ListResources, [cred, options],
                                 {}, settings.TIMEOUT)

        logger.debug("Got RSpec\n%s" % rspec)

        # Create switches and links
        self.switches, self.links = parse_rspec(rspec)

        # create a random reservation
        vals = dict(firstname="John",
                    lastname="Doe",
                    email="*****@*****.**",
                    password="******",
                    proj_name="Stanford Networking",
                    proj_desc="Making the world better.",
                    slice_name="Crazy Load Balancer",
                    slice_desc="Does this and that...",
                    ctrl_url="tcp:controller.stanford.edu:6633")
        resv_rspec, flowspaces = create_random_resv(2, self.switches, **vals)

        project_name, project_desc, slice_name, slice_desc,\
        controller_url, email, password, iface_fs_map = parse_slice(resv_rspec)

        self.assertEqual(project_name, vals["proj_name"])
        self.assertEqual(project_desc, vals["proj_desc"])
        self.assertEqual(slice_name, vals["slice_name"])
        self.assertEqual(slice_desc, vals["slice_desc"])
        self.assertEqual(controller_url, vals["ctrl_url"])
        self.assertEqual(email, vals["email"])
        self.assertEqual(password, vals["password"])

        dpid_fs_map = {}  # map dpid to requested fs
        for fs in flowspaces:
            for sw in fs.switches:
                if sw.dpid not in dpid_fs_map:
                    dpid_fs_map[sw.dpid] = []
                dpid_fs_map[sw.dpid].append(fs)

        logger.debug(iface_fs_map)
Example #30
0
 def test_CreateDeleteSliver(self):
     """
     Check that we can create then delete a sliver.
     """
     slice_urn, cred = self.test_CreateSliver()
     
     self.assertTrue(
         wrap_xmlrpc_call(
             self.am_client.DeleteSliver,
             [slice_urn, cred], {}, 
             test_settings.TIMEOUT),
         "Failed to delete sliver.")
     
     self.assertEqual(
         len(self.fv_clients[0].api.listSlices()),
         1,
         "Slice not deleted at FlowVisor",
     )
    def test_CreateSliver(self):
        """
        Tests that we can create a sliver.
        """
        from openflow.plugin.models import OpenFlowSwitch
        from openflow.dummyom.models import DummyOMSlice
        from expedient.clearinghouse.slice.models import Slice
        
        # get the resources
        slice_urn, cred = self.create_ch_slice()
        options = dict(geni_compressed=False, geni_available=True)
        rspec = wrap_xmlrpc_call(
            self.am_client.ListResources,
            [cred, options], {}, settings.TIMEOUT)
        
        # Create switches and links
        self.switches, self.links = parse_rspec(rspec)

        # create a random reservation
        resv_rspec, flowspaces = create_random_resv(20, self.switches)
        users = [{'key':''}]
        ret = self.am_client.CreateSliver(slice_urn, cred, resv_rspec, users)
        
        self.assertEqual(resv_rspec, ret)
        
        # check that all the switches are stored in the slice on the CH
        slice = Slice.objects.get(gapislice__slice_urn=slice_urn)
        
        switches = OpenFlowSwitch.objects.filter(
            openflowinterface__slice_set=slice).distinct()
        
        dpids = []
        for fs in flowspaces:
            for switch in fs.switches:
                dpids.append(switch.dpid)
        dpids = set(dpids)
        
        # TODO: Do a better check
        self.assertEqual(len(dpids), len(switches))
        
        # check that the create_slice call has reached the dummyoms correctly
        # TODO: Do a better check
        self.assertEqual(len(DummyOMSlice.objects.all()),
                         settings.NUM_DUMMY_OMS)
Example #32
0
    def test_get_switches(self):
        """
        Test that a slice can be created and the calls are routed to the
        FV correctly.
        """
        # TODO: Fix to also check the returned info
        self.dpids_info = wrap_xmlrpc_call(self.om_client.get_switches, [], {},
                                           TIMEOUT)
        dpids = set([d[0] for d in self.dpids_info])

        # check that we expect all the dpids
        expected = set(DummyFVDevice.objects.values_list('dpid', flat=True), )

        self.assertEqual(
            dpids, expected,
            "Received dpids (%s) not same as expected (%s)." % (
                dpids,
                expected,
            ))
Example #33
0
File: gapi.py Project: cargious/ocf
    def test_CreateSliver(self):
        """
        Tests that we can create a sliver.
        """
        from openflow.plugin.models import OpenFlowSwitch
        from openflow.dummyom.models import DummyOMSlice
        from expedient.clearinghouse.slice.models import Slice

        # get the resources
        slice_urn, cred = self.create_ch_slice()
        options = dict(geni_compressed=False, geni_available=True)
        rspec = wrap_xmlrpc_call(self.am_client.ListResources, [cred, options],
                                 {}, settings.TIMEOUT)

        # Create switches and links
        self.switches, self.links = parse_rspec(rspec)

        # create a random reservation
        resv_rspec, flowspaces = create_random_resv(20, self.switches)
        users = [{'key': ''}]
        ret = self.am_client.CreateSliver(slice_urn, cred, resv_rspec, users)

        self.assertEqual(resv_rspec, ret)

        # check that all the switches are stored in the slice on the CH
        slice = Slice.objects.get(gapislice__slice_urn=slice_urn)

        switches = OpenFlowSwitch.objects.filter(
            openflowinterface__slice_set=slice).distinct()

        dpids = []
        for fs in flowspaces:
            for switch in fs.switches:
                dpids.append(switch.dpid)
        dpids = set(dpids)

        # TODO: Do a better check
        self.assertEqual(len(dpids), len(switches))

        # check that the create_slice call has reached the dummyoms correctly
        # TODO: Do a better check
        self.assertEqual(len(DummyOMSlice.objects.all()),
                         settings.NUM_DUMMY_OMS)
 def test_topoChange_ListResources(self):
     """
     Check the list of resources before and after a topology change
     """
     from openflow.dummyom.models import DummyOM
     
     slice_urn, cred = self.create_ch_slice()
     options = dict(geni_compressed=False, geni_available=True)
     rspec = wrap_xmlrpc_call(
         self.am_client.ListResources,
         [cred, options], {}, settings.TIMEOUT)
     
     # Create switches and links
     self.switches, self.links = parse_rspec(rspec)
     
     # check the number of switches and links
     num_links = sum([len(d.get_switches()) for d in DummyOM.objects.all()])
     self.assertEqual(len(self.switches),
                      num_links)
     self.assertEqual(len(self.links),
                      settings.NUM_LINKS_PER_AGG*settings.NUM_DUMMY_OMS)
     
     killed_dpids = []
     for om in DummyOM.objects.all():
         killed_dpids.append(om.kill_dpid())
         om.dummycallbackproxy.call_back()
         
     # Create switches and links
     options = dict(geni_compressed=False, geni_available=True)
     rspec = self.am_client.ListResources(cred, options)
     self.switches, self.links = parse_rspec(rspec)
     
     # check the number of switches
     num_links = sum([len(d.get_switches()) for d in DummyOM.objects.all()])
     self.assertEqual(len(self.switches),
                      num_links)
     
     # make sure all killed dpids are gone: None of the dpids still
     # here should have the dpid of a killed switch.
     for s in self.switches:
         for d in killed_dpids:
             self.assertNotEqual(str(s.dpid), str(d))
Example #35
0
 def test_get_switches(self):
     """
     Test that a slice can be created and the calls are routed to the
     FV correctly.
     """
     # TODO: Fix to also check the returned info
     self.dpids_info = wrap_xmlrpc_call(
         self.om_client.get_switches, [], {}, TIMEOUT)
     dpids = set([d[0] for d in self.dpids_info])
     
     # check that we expect all the dpids
     expected = set(
         DummyFVDevice.objects.values_list('dpid', flat=True),
     )
     
     self.assertEqual(
         dpids, expected, 
         "Received dpids (%s) not same as expected (%s)." % (
             dpids, expected,
         )
     )
Example #36
0
    def test_delete_slice(self):
        """
        Tests that slices are deleted correctly from the OM to FV
        """
        from openflow.optin_manager.dummyfv.models import DummyFV, DummyFVSlice
        from openflow.optin_manager.opts.models import Experiment, \
            ExperimentFLowSpace

        num_slices = random.randint(1, 5)
        for i in range(num_slices):
            self.test_create_slice(id=i)
        
        # delete some slices and make sure they are gone
        ids = range(1, num_slices)
        random.shuffle(ids)
        for i in ids:
            err = wrap_xmlrpc_call(
                self.om_client.delete_slice, [i], {}, test_settings.TIMEOUT)
            self.assertEqual(err, "")
            num_slices -= 1
            for fv in DummyFV.objects.all():
                num_actual_slices = DummyFVSlice.objects.filter(fv=fv).count()
                self.assertTrue(
                    num_actual_slices == num_slices,
                    "Expected %s slices after delete but found %s" % (
                        num_slices, num_actual_slices))
            # Check internal OM database:
            count = Experiment.objects.all().count()
            self.assertEqual(
                count,num_slices,
                "There are more slices in OM than expected")
            count = Experiment.objects.filter(slice_id=i).count()
            self.assertEqual(count, 0, "Slice in OM has not deleted!")
            count = ExperimentFLowSpace.objects.filter(
                exp__slice_id = i).count() 
            self.assertEqual(
                count, 0,
                "FlowSpace associated with experiment slice_id" +\
                "=%d has not deleted completely" % i)            
Example #37
0
File: gapi.py Project: cargious/ocf
    def test_topoChange_ListResources(self):
        """
        Check the list of resources before and after a topology change
        """
        from openflow.dummyom.models import DummyOM

        slice_urn, cred = self.create_ch_slice()
        options = dict(geni_compressed=False, geni_available=True)
        rspec = wrap_xmlrpc_call(self.am_client.ListResources, [cred, options],
                                 {}, settings.TIMEOUT)

        # Create switches and links
        self.switches, self.links = parse_rspec(rspec)

        # check the number of switches and links
        num_links = sum([len(d.get_switches()) for d in DummyOM.objects.all()])
        self.assertEqual(len(self.switches), num_links)
        self.assertEqual(len(self.links),
                         settings.NUM_LINKS_PER_AGG * settings.NUM_DUMMY_OMS)

        killed_dpids = []
        for om in DummyOM.objects.all():
            killed_dpids.append(om.kill_dpid())
            om.dummycallbackproxy.call_back()

        # Create switches and links
        options = dict(geni_compressed=False, geni_available=True)
        rspec = self.am_client.ListResources(cred, options)
        self.switches, self.links = parse_rspec(rspec)

        # check the number of switches
        num_links = sum([len(d.get_switches()) for d in DummyOM.objects.all()])
        self.assertEqual(len(self.switches), num_links)

        # make sure all killed dpids are gone: None of the dpids still
        # here should have the dpid of a killed switch.
        for s in self.switches:
            for d in killed_dpids:
                self.assertNotEqual(str(s.dpid), str(d))
Example #38
0
File: gapi.py Project: cargious/ocf
    def test_ListResources(self, zipped=False):
        """
        Check the list of resources.
        """
        from openflow.dummyom.models import DummyOM
        slice_urn, cred = self.create_ch_slice()
        options = dict(geni_compressed=zipped, geni_available=True)
        rspec = wrap_xmlrpc_call(self.am_client.ListResources, [cred, options],
                                 {}, settings.TIMEOUT)

        logger.debug("Got Advertisement RSpec: \n%s" % rspec)

        if zipped:
            import zlib, base64
            rspec = zlib.decompress(base64.b64decode(rspec))

        # Create switches and links
        self.switches, self.links = parse_rspec(rspec)

        # check the number of switches and links
        num_links = sum([len(d.get_switches()) for d in DummyOM.objects.all()])
        self.assertEqual(len(self.switches), num_links)
        self.assertEqual(len(self.links),
                         settings.NUM_LINKS_PER_AGG * settings.NUM_DUMMY_OMS)
Example #39
0
 def test_GetVersion(self):
     ret = wrap_xmlrpc_call(
         self.am_client.GetVersion, [], {}, test_settings.TIMEOUT)
     self.assertEqual(ret['geni_api'], 1)
        elif arg.startswith("owner_password="******"switch_slivers="):
            parts = arg.split('=')
            try:
                switch_slivers = ast.literal_eval(parts[1])
            except Exception,e:
                return str(e)  
    if not (slice_id and controller_url and owner_password and switch_slivers):
        return "Invalid syntax: %s"%help_msg("create_slice")
    xmlrpc_proxy = PasswordXMLRPCServerProxy()
    xmlrpc_proxy.setup(username, password, url, False)
    try:
        returned = wrap_xmlrpc_call(xmlrpc_proxy.create_slice,[slice_id,project_name, 
                project_description,slice_name, slice_description, controller_url,
                owner_email, owner_password,switch_slivers],{},10)
        return returned
    except Exception,e:
        return str(e)
    
def xmlrpc_wrap_delete_slice(username, password, url, slice_id):
    xmlrpc_proxy = PasswordXMLRPCServerProxy()
    xmlrpc_proxy.setup(username, password, url, False)
    try:
        returned_data = wrap_xmlrpc_call(xmlrpc_proxy.delete_slice,[slice_id],{},10)
        return returned_data
    except Exception,e:
        return str(e)   
   
def xmlrpc_wrap_get_switches(username, password, url):
Example #41
0
            parts = arg.split('=')
            owner_password = parts[1]
        elif arg.startswith("switch_slivers="):
            parts = arg.split('=')
            try:
                switch_slivers = ast.literal_eval(parts[1])
            except Exception, e:
                return str(e)
    if not (slice_id and controller_url and owner_password and switch_slivers):
        return "Invalid syntax: %s" % help_msg("create_slice")
    xmlrpc_proxy = PasswordXMLRPCServerProxy()
    xmlrpc_proxy.setup(username, password, url, False)
    try:
        returned = wrap_xmlrpc_call(xmlrpc_proxy.create_slice, [
            slice_id, project_name, project_description, slice_name,
            slice_description, controller_url, owner_email, owner_password,
            switch_slivers
        ], {}, 10)
        return returned
    except Exception, e:
        return str(e)


def xmlrpc_wrap_delete_slice(username, password, url, slice_id):
    xmlrpc_proxy = PasswordXMLRPCServerProxy()
    xmlrpc_proxy.setup(username, password, url, False)
    try:
        returned_data = wrap_xmlrpc_call(xmlrpc_proxy.delete_slice, [slice_id],
                                         {}, 10)
        return returned_data
    except Exception, e: