Пример #1
0
    def runTest(self):
        ing_port = config["port_map"].keys()[0]
        out_port1 = config["port_map"].keys()[1]
        out_port2 = config["port_map"].keys()[2]
        pkt = testutils.simple_tcp_packet()
        testutils.delete_all_flows(self.controller, logging)
        fm_orig = testutils.flow_msg_create(self, pkt, 
                                            ing_port=ing_port, 
                                            egr_port=out_port1)
        fm_new = testutils.flow_msg_create(self, pkt, 
                                            ing_port=ing_port, 
                                            egr_port=out_port2)
        fm_new.command = ofp.OFPFC_MODIFY_STRICT
        rv = self.controller.message_send(fm_orig)
        self.assertEqual(rv, 0, "Failed to insert 1st flow_mod")
        testutils.do_barrier(self.controller)
        rv = self.controller.message_send(fm_new)
        testutils.do_barrier(self.controller)
        self.assertEqual(rv, 0, "Failed to insert 2nd flow_mod")
        flow_stats = testutils.flow_stats_get(self)
        self.assertEqual(len(flow_stats.entries),1,
                         "Expected only one flow_mod")
        stat = flow_stats.entries[0]

        def canonicalize_match(match):
            match.oxm_list.sort(key=lambda x: x.type_len)

        canonicalize_match(stat.match)
        canonicalize_match(fm_new.match)
        self.assertEqual(stat.match, fm_new.match)
        self.assertEqual(stat.instructions, fm_new.instructions)
Пример #2
0
    def runTest(self):
        ing_port = config["port_map"].keys()[0]
        out_port1 = config["port_map"].keys()[1]
        out_port2 = config["port_map"].keys()[2]
        pkt = testutils.simple_tcp_packet()
        testutils.delete_all_flows(self.controller, logging)
        fm_orig = testutils.flow_msg_create(self,
                                            pkt,
                                            ing_port=ing_port,
                                            egr_port=out_port1)
        fm_new = testutils.flow_msg_create(self,
                                           pkt,
                                           ing_port=ing_port,
                                           egr_port=out_port2)
        fm_new.command = ofp.OFPFC_MODIFY_STRICT
        rv = self.controller.message_send(fm_orig)
        self.assertEqual(rv, 0, "Failed to insert 1st flow_mod")
        testutils.do_barrier(self.controller)
        rv = self.controller.message_send(fm_new)
        testutils.do_barrier(self.controller)
        self.assertEqual(rv, 0, "Failed to insert 2nd flow_mod")
        flow_stats = testutils.flow_stats_get(self)
        self.assertEqual(len(flow_stats.entries), 1,
                         "Expected only one flow_mod")
        stat = flow_stats.entries[0]

        def canonicalize_match(match):
            match.oxm_list.sort(key=lambda x: x.type_len)

        canonicalize_match(stat.match)
        canonicalize_match(fm_new.match)
        self.assertEqual(stat.match, fm_new.match)
        self.assertEqual(stat.instructions, fm_new.instructions)
Пример #3
0
    def send_ctrl_exp_noerror(self, msg, log = ''):
        logging.info('Sending message ' + log)
#        logging.debug(msg.show())
        rv = self.controller.message_send(msg)
        self.assertTrue(rv != -1, 'Error sending!')

        logging.info('Waiting for error messages...')
        (response, raw) = self.controller.poll(ofp.OFPT_ERROR, 1)

        self.assertTrue(response is None, 'Unexpected error message received')

        testutils.do_barrier(self.controller);
Пример #4
0
    def send_ctrl_exp_noerror(self, msg, log = ''):
        logging.info('Sending message ' + log)
#        logging.debug(msg.show())
        rv = self.controller.message_send(msg)
        self.assertTrue(rv != -1, 'Error sending!')

        logging.info('Waiting for error messages...')
        (response, raw) = self.controller.poll(ofp.OFPT_ERROR, 1)

        self.assertTrue(response is None, 'Unexpected error message received')

        testutils.do_barrier(self.controller);
Пример #5
0
    def send_ctrl_exp_error(self, msg, log = '', type = 0, code = 0):
        logging.info('Sending message ' + log)
        logging.debug(msg.show())
        rv = self.controller.message_send(msg)
        self.assertTrue(rv != -1, 'Error sending!')

        logging.info('Waiting for error messages...')
        (response, raw) = self.controller.poll(ofp.OFPT_ERROR, 1)

        self.assertTrue(response is not None, 
                        'Did not receive an error message')

        self.assertEqual(response.header.type, ofp.OFPT_ERROR,
                         'Did not receive an error message')

        if type != 0:
            self.assertEqual(response.type, type,
                             'Did not receive a ' + str(type) + ' type error message')

        if code != 0:
            self.assertEqual(response.code, code,
                             'Did not receive a ' + str(code) + ' code error message')
        
        testutils.do_barrier(self.controller);
Пример #6
0
    def send_ctrl_exp_error(self, msg, log = '', type = 0, code = 0):
        logging.info('Sending message ' + log)
        logging.debug(msg.show())
        rv = self.controller.message_send(msg)
        self.assertTrue(rv != -1, 'Error sending!')

        logging.info('Waiting for error messages...')
        (response, raw) = self.controller.poll(ofp.OFPT_ERROR, 1)

        self.assertTrue(response is not None, 
                        'Did not receive an error message')

        self.assertEqual(response.type, ofp.OFPT_ERROR,
                         'Did not receive an error message')

        if type != 0:
            self.assertEqual(response.err_type, type,
                             'Did not receive a ' + str(type) + ' type error message')

        if code != 0:
            self.assertEqual(response.code, code,
                             'Did not receive a ' + str(code) + ' code error message')
        
        testutils.do_barrier(self.controller);