Shudong Zhou | dc276ae | 2012-10-15 16:02:56 -0700 | [diff] [blame] | 1 | """ |
| 2 | """ |
| 3 | import struct |
| 4 | |
| 5 | import logging |
| 6 | |
| 7 | from oftest import config |
| 8 | import oftest.controller as controller |
| 9 | import oftest.cstruct as ofp |
| 10 | import oftest.message as message |
| 11 | import oftest.base_tests as base_tests |
| 12 | |
| 13 | from oftest.testutils import * |
| 14 | |
| 15 | # Nicira vendor extension constants |
| 16 | NXT_VENDOR = 0x00002320 |
| 17 | |
| 18 | NXT_ROLE_REQUEST = 10 |
| 19 | |
| 20 | NXT_ROLE_VALUE = dict( other=0, slave=1, master=2 ) |
| 21 | |
Rich Lane | 0a4f637 | 2013-01-02 14:40:22 -0800 | [diff] [blame] | 22 | @nonstandard |
Shudong Zhou | dc276ae | 2012-10-15 16:02:56 -0700 | [diff] [blame] | 23 | class NiciraRoleRequest(base_tests.SimpleDataPlane): |
| 24 | """ |
| 25 | Exercise Nicira vendor extension for requesting HA roles |
| 26 | """ |
| 27 | |
Shudong Zhou | dc276ae | 2012-10-15 16:02:56 -0700 | [diff] [blame] | 28 | def nicira_role_request(self, role): |
| 29 | """ |
| 30 | Use the BSN_SET_IP_MASK vendor command to change the IP mask for the |
| 31 | given wildcard index |
| 32 | """ |
| 33 | logging.info("Sending role request %s" % role) |
| 34 | m = message.vendor() |
| 35 | m.vendor = NXT_VENDOR |
| 36 | m.data = struct.pack("!LL", NXT_ROLE_REQUEST, NXT_ROLE_VALUE[role]) |
| 37 | return m |
| 38 | |
| 39 | def runTest(self): |
| 40 | ''' |
| 41 | For now, we only verify that a response is received. |
| 42 | ''' |
| 43 | request = self.nicira_role_request("master") |
| 44 | response, pkt = self.controller.transact(request) |
| 45 | self.assertTrue(response is not None, "No reply to Nicira role request") |