def bsn_set_mirroring(self, enabled): """ Use the BSN_SET_MIRRORING vendor command to enable/disable mirror action support """ m = message.vendor() m.vendor = 0x005c16c7 m.data = struct.pack("!LBBBB", 3, enabled, 0, 0, 0) self.controller.message_send(m)
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 bsn_set_ip_mask(self, index, mask): """ Use the BSN_SET_IP_MASK vendor command to change the IP mask for the given wildcard index """ m = message.vendor() m.vendor = 0x005c16c7 m.data = struct.pack("!LBBBBL", 0, index, 0, 0, 0, mask) rc = self.controller.message_send(m) self.assertNotEqual(rc, -1, "Error sending set IP mask command")
def bsn_set_ip_mask(self, index, mask): """ Use the BSN_SET_IP_MASK vendor command to change the IP mask for the given wildcard index """ logging.info("Setting index %d to mask is %s" % (index, mask)) m = message.vendor() m.vendor = 0x005c16c7 m.data = struct.pack("!LBBBBL", 0, index, 0, 0, 0, mask) self.controller.message_send(m)
def runTest(self): logging = get_logger() logging.info("Running Grp100No50 BadRequestBadVendor test") request = message.vendor() request.vendor = 400 (response, pkt) = self.controller.transact(request) self.assertEqual(response.header.type,ofp.OFPT_ERROR,'response is not error message') self.assertEqual(response.type, ofp.OFPET_BAD_REQUEST,'Error type not as expected') self.assertTrue(response.code == ofp.OFPBRC_BAD_VENDOR or response.code == ofp.OFPBRC_EPERM, "Error code is not as expected")
def bsn_set_ip_mask(self, index, mask): """ Use the BSN_SET_IP_MASK vendor command to change the IP mask for the given wildcard index """ logging.info("Setting index %d to mask is %s" % (index, mask)) m = message.vendor() m.vendor = 0x005c16c7 m.data = struct.pack("!LBBBBL", 0, index, 0, 0, 0, mask) rc = self.controller.message_send(m) self.assertNotEqual(rc, -1, "Error sending set IP mask command")
def runTest(self): logging.info("Running Grp100No60 BadRequestBadVendor test") request = message.vendor() request.vendor = 400 (response, pkt) = self.controller.transact(request) self.assertEqual(response.header.type, ofp.OFPT_ERROR, "response is not error message") self.assertEqual(response.type, ofp.OFPET_BAD_REQUEST, "Error type not as expected") if not response.code == ofp.OFPBAC_BAD_VENDOR | ofp.OFPBRC_EPERM: logging.info("Error code is not as expected")
def bsn_get_mirroring(self): """ Use the BSN_GET_MIRRORING_REQUEST vendor command to get the enabled/disabled state of mirror action support """ m = message.vendor() m.vendor = 0x005c16c7 m.data = struct.pack("!LBBBB", 4, 0, 0, 0, 0) self.controller.message_send(m) m, r = self.controller.poll(ofp.OFPT_VENDOR, 2) self.assertEqual(m.vendor, 0x005c16c7, "Wrong vendor ID") x = struct.unpack("!LBBBB", m.data) self.assertEqual(x[0], 5, "Wrong subtype") return x[1]
def bsn_get_ip_mask(self, index): """ Use the BSN_GET_IP_MASK_REQUEST vendor command to get the current IP mask for the given wildcard index """ m = message.vendor() m.vendor = 0x005c16c7 m.data = struct.pack( "!LBBBBL", 1, index, 0, 0, 0, 0 ) self.controller.message_send(m) m, r = self.controller.poll(ofp.OFPT_VENDOR) self.assertEqual(m.vendor, 0x005c16c7, "Wrong vendor ID") x = struct.unpack("!LBBBBL", m.data) self.assertEqual(x[0], 2, "Wrong subtype") self.assertEqual(x[1], index, "Wrong index") return x[5]
def bsn_get_ip_mask(self, index): """ Use the BSN_GET_IP_MASK_REQUEST vendor command to get the current IP mask for the given wildcard index """ m = message.vendor() m.vendor = 0x005c16c7 m.data = struct.pack("!LBBBBL", 1, index, 0, 0, 0, 0) rc = self.controller.message_send(m) self.assertNotEqual(rc, -1, "Error sending get IP mask command") m, r = self.controller.poll(ofp.OFPT_VENDOR) self.assertEqual(m.vendor, 0x005c16c7, "Wrong vendor ID") x = struct.unpack("!LBBBBL", m.data) self.assertEqual(x[0], 2, "Wrong subtype") self.assertEqual(x[1], index, "Wrong index") return x[5]
def bsn_shell_command(self, cmd): """ Use the BSN_SHELL_COMMAND vendor command to run the given command and receive the output """ m = message.vendor() m.vendor = 0x005c16c7 m.data = struct.pack("!LL", 6, 0) + cmd rc = self.controller.message_send(m) self.assertNotEqual(rc, -1, "Error sending shell command") out = "" while True: m, r = self.controller.poll(ofp.OFPT_VENDOR, 60) self.assertEqual(m.vendor, 0x005c16c7, "Wrong vendor ID") subtype = struct.unpack("!L", m.data[:4])[0] if subtype == 7: out += m.data[4:] elif subtype == 8: status = struct.unpack("!LL", m.data)[1] return status, out else: assert False, "Wrong subtype"
def runTest(self): request = message.vendor() request.vendor = 400 rv = self.controller.message_send(request) self.assertTrue(rv==0,"Unable to send the message") count = 0 while True: (response, raw) = self.controller.poll(ofp.OFPT_ERROR) if not response: # Timeout break if not response.type == ofp.OFPET_BAD_REQUEST: logging.info("Error type not as expected") break if not response.code == ofp.OFPBAC_BAD_VENDOR | ofp.OFPBRC_EPERM: logging.info("Error code is not as expected") break if not config["relax"]: # Only one attempt to match break count += 1 if count > 10: # Too many tries break