def populateTopology(self, num_switches, num_links, use_random=False):
        import random
        from openflow.optin_manager.flowspace.utils import long_to_dpid
        
        if not use_random: random.seed(0)
        
        if num_switches >= 1000:
            raise Exception("Can only create less than 1000 dpids per Dummy")
        
        for l in range(num_switches):
            DummyFVDevice.objects.create(
                dpid=long_to_dpid(self.id*1024+l),
                fv=self,
            )
            
        for l in range(num_links):
            src, dst = random.sample(DummyFVDevice.objects.all(), 2)
            src_port = random.randint(0, 3)
            dst_port = random.randint(0, 3)
            DummyFVLink.objects.create(
                src_dev=src,
                src_port=src_port,
                dst_dev=dst,
                dst_port=dst_port,
                fv=self,
            )
Create switches and random links
dataset/ETHPy150Open fp7-ofelia/ocf/optin_manager/src/python/openflow/optin_manager/dummyfv/models.py/DummyFV.populateTopology