def test_create_slice(self, id=10):
        from openflow.tests.helpers import Flowspace
        from openflow.optin_manager.xmlrpc_server.ch_api import convert_star_int
        
        # get the switches into self.dpids_info
        self.test_get_switches()
        
        # create some random flowspaces
        switch_slivers=[]
        for i in xrange(10):
            switch = random.choice(self.dpids_info)
#            print "Creating flow space for switch %s" % switch
            fs_set = [Flowspace.create_random([switch]) \
                      for j in range(random.randint(1,10))]
            switch_slivers.append({
                "datapath_id": switch[0],
                "flowspace": [fs.get_full_attrs() for fs in fs_set],
            })
        
        args = {
            "slice_id": id,
            "project_name": "project_name",
            "project_description": "project_description",
            "slice_name": "slice name-%s" % id,
            "slice_description": "slice_description",
            "controller_url": "bla:bla.bla.bla:6633",
            "owner_email": "bla@bla.com",
            "owner_password": "password",
            "switch_slivers": switch_slivers,
        }

        # Create!
        ret = self.om_client.create_slice(
            args["slice_id"], args["project_name"], args["project_description"],
            args["slice_name"], args["slice_description"],
            args["controller_url"], args["owner_email"], args["owner_password"],
            args["switch_slivers"]
        )
        
        # check the return value
        self.assertEqual(ret, {'error_msg': "", 'switches': []})
        
        # check the OM database to see if Experiment has been created correctly

        returned = Experiment.objects.filter(slice_name=args["slice_name"])

        self.assertEqual(
            returned.count(), 1 ,
            "more than one slice with same name %s" % args["slice_name"])
        returned_string = "%s %s %s %s %s %s %s %s" % (
            returned[0].slice_id, returned[0].slice_name,
            returned[0].slice_desc, returned[0].project_name,
            returned[0].project_desc, returned[0].controller_url,
            returned[0].owner_email, returned[0].owner_password
        )
        expected_string = "%s %s %s %s %s %s %s %s" % ( 
            args["slice_id"],args["slice_name"],
            args["slice_description"],args["project_name"],
            args["project_description"],args["controller_url"],
            args["owner_email"],args["owner_password"])

        self.assertEqual(
            returned_string, expected_string,
            "The OM Experiment table is different " + \
            "from what expected %s != %s" % (returned_string,expected_string)
        )
        
        # check the OM database to see if ExperimentFlowSpace 
        # has been created correctly
        expfs = ExperimentFLowSpace.objects.filter(exp=returned[0])
        returned_string = ""
        for fs in expfs:
            returned_string = "%s %s %s %s %s " % (
                returned_string, fs.dpid, fs.port_number_s, fs.port_number_e,
                fs.stringify()
            )
        expected_string = ""

        for sliver in args["switch_slivers"]:
            for fs in sliver["flowspace"]:
                fs = convert_star_int(fs)
                expected_string = \
                    "%s %s %s %s %s %s %s %s %s %s %s " % (
                        expected_string, sliver["datapath_id"],
                        fs["port_num_start"], fs["port_num_end"],
                        fs["dl_src_start"], fs["dl_src_end"],
                        fs["dl_dst_start"], fs["dl_dst_end"],
                        fs["vlan_id_start"], fs["vlan_id_end"],
                        fs["nw_src_start"],
                    ) +\
                    "%s %s %s %s %s %s %s %s %s " % (
                        fs["nw_src_end"], fs["nw_dst_start"], fs["nw_dst_end"],
                        fs["nw_proto_start"], fs["nw_proto_end"],
                        fs["tp_src_start"], fs["tp_src_end"],
                        fs["tp_dst_start"], fs["tp_dst_end"]
                    )

        self.assertEqual(
            returned_string, expected_string,
            "Experiment FlowSpaces are not equal %s != %s" % (
                returned_string,expected_string
            )
        )

        for fv in DummyFV.objects.all():
            self.assertEqual(DummyFVRule.objects.filter(fv=fv).count(), 0)
Tests that slices are created correctly from the OM to the FV
dataset/ETHPy150Open fp7-ofelia/ocf/optin_manager/src/python/openflow/optin_manager/xmlrpc_server/tests.py/Tests.test_create_slice