| """ |
| """ |
| import struct |
| |
| import logging |
| |
| from oftest import config |
| import oftest.controller as controller |
| import oftest.cstruct as ofp |
| import oftest.message as message |
| import oftest.base_tests as base_tests |
| |
| from oftest.testutils import * |
| |
| # Nicira vendor extension constants |
| NXT_VENDOR = 0x00002320 |
| |
| NXT_ROLE_REQUEST = 10 |
| |
| NXT_ROLE_VALUE = dict( other=0, slave=1, master=2 ) |
| |
| class NiciraRoleRequest(base_tests.SimpleDataPlane): |
| """ |
| Exercise Nicira vendor extension for requesting HA roles |
| """ |
| |
| priority = 0 |
| |
| def nicira_role_request(self, role): |
| """ |
| Use the BSN_SET_IP_MASK vendor command to change the IP mask for the |
| given wildcard index |
| """ |
| logging.info("Sending role request %s" % role) |
| m = message.vendor() |
| m.vendor = NXT_VENDOR |
| m.data = struct.pack("!LL", NXT_ROLE_REQUEST, NXT_ROLE_VALUE[role]) |
| return m |
| |
| def runTest(self): |
| ''' |
| For now, we only verify that a response is received. |
| ''' |
| request = self.nicira_role_request("master") |
| response, pkt = self.controller.transact(request) |
| self.assertTrue(response is not None, "No reply to Nicira role request") |