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