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