def runTest(self): request = message.role_request() request.role = ofp.OFPCR_ROLE_SLAVE gener_id = GetGenerationID(self.controller) self.assertTrue(gener_id is not None, "Did not get generation_id") request.generation_id = gener_id response, _ = self.controller.transact(request) self.assertEqual(response.header.type, ofp.OFPT_ROLE_REPLY, 'response is not role_reply') self.assertEqual(response.role, ofp.OFPCR_ROLE_SLAVE, 'response is not OFPCR_ROLE_SLAVE') request = message.role_request() request.role = ofp.OFPCR_ROLE_MASTER request.generation_id = gener_id + 1 testutils.ofmsg_send(self, request)
def runTest(self): request = message.role_request() request.role = ofp.OFPCR_ROLE_SLAVE gener_id = GetGenerationID(self.controller) self.assertTrue(gener_id is not None, "Did not get generation_id") request.generation_id = gener_id response,_ = self.controller.transact(request) self.assertEqual(response.header.type, ofp.OFPT_ROLE_REPLY, 'response is not role_reply') self.assertEqual(response.role, ofp.OFPCR_ROLE_SLAVE, 'response is not OFPCR_ROLE_SLAVE') request = message.role_request() request.role = ofp.OFPCR_ROLE_MASTER request.generation_id = gener_id + 1 testutils.ofmsg_send(self, request)
def runTest(self): request = message.role_request() request.role = ofp.OFPCR_ROLE_NOCHANGE request.generation_id = random.randint(0, 0xffffffffffffffff) response, _ = self.controller.transact(request) self.assertEqual(response.header.type, ofp.OFPT_ROLE_REPLY, 'response is not role_reply')
def runTest(self): request = message.role_request() request.role = ofp.OFPCR_ROLE_NOCHANGE request.generation_id = random.randint(0,0xffffffffffffffff) response,_ = self.controller.transact(request) self.assertEqual(response.header.type, ofp.OFPT_ROLE_REPLY, 'response is not role_reply')
def GetGenerationID(controller): ''' read current generation id ''' request = message.role_request() request.role = ofp.OFPCR_ROLE_NOCHANGE response, _ = controller.transact(request) if response is None: return None elif (response.header.type == ofp.OFPT_ROLE_REPLY): if response.generation_id == 0xffffffffffffffff: return 0 else: return response.generation_id + 1 else: print('\n' + response.show()) return None
def GetGenerationID(controller): ''' read current generation id ''' request = message.role_request() request.role = ofp.OFPCR_ROLE_NOCHANGE response,_ = controller.transact(request) if response is None: return None elif(response.header.type == ofp.OFPT_ROLE_REPLY): if response.generation_id == 0xffffffffffffffff: return 0 else: return response.generation_id + 1 else: print('\n' + response.show()) return None