예제 #1
0
    def runTest(self):
        logging = get_logger()
        logging.info("Running PortModFailedBadHwAdd Grp100No270 test")

        of_ports = config["port_map"].keys()
        of_ports.sort()
        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
        
        #Send features request
        request = message.features_request()
        reply, pkt = self.controller.transact(request, timeout=2)
        self.assertTrue(reply is not None, "Features Reply not recieved")
        for idx in range(len(reply.ports)):
            if reply.ports[idx].port_no == of_ports[0]:
                break
        self.assertTrue(idx <= len(reply.ports), "Error in the ports information")

        logging.info("Sending port_mod request ..")
        mod = message.port_mod()
        mod.port_no = of_ports[0]
        mod.hw_addr = [0,0,0,0,0,0]
        mod.config = ofp.OFPPC_NO_FLOOD
        mod.mask = ofp.OFPPC_NO_FLOOD
        mod.advertise = reply.ports[idx].advertised
        rv = self.controller.message_send(mod)
        self.assertTrue(rv != -1,"Unable to send the message")
        
        logging.info("Waiting for OFPT_ERROR message...")
        (response, raw) = self.controller.poll(ofp.OFPT_ERROR, timeout=10)
        self.assertTrue(response is not None,"Did not receive an error")
        self.assertTrue(response.type==ofp.OFPET_PORT_MOD_FAILED,"Unexpected Error type. Expected OFPET_PORT_MOD_FAILED error type")
        self.assertTrue(response.code==ofp.OFPPMFC_BAD_HW_ADDR," Unexpected error code, Expected OFPPMFC_BAD_HW_ADDR error code")
예제 #2
0
파일: testutils.py 프로젝트: esl/oftest
def port_config_set(controller, port_no, config, mask, logger):
    """
    Set the port configuration according the given parameters

    Gets the switch feature configuration and updates one port's
    configuration value according to config and mask
    """
    logger.info("Setting port " + str(port_no) + " to config " + str(config))
    request = message.features_request()
    reply, pkt = controller.transact(request, timeout=2)
    if reply is None:
        return -1
    logger.debug(reply.show())
    for idx in range(len(reply.ports)):
        if reply.ports[idx].port_no == port_no:
            break
    if idx >= len(reply.ports):
        return -1
    mod = message.port_mod()
    mod.port_no = port_no
    mod.hw_addr = reply.ports[idx].hw_addr
    mod.config = config
    mod.mask = mask
    mod.advertise = reply.ports[idx].advertised
    rv = controller.message_send(mod)
    return rv
예제 #3
0
def port_config_set(controller, port_no, config, mask):
    """
    Set the port configuration according the given parameters

    Gets the switch feature configuration and updates one port's
    configuration value according to config and mask
    """
    logging.info("Setting port " + str(port_no) + " to config " + str(config))
    request = message.features_request()
    reply, pkt = controller.transact(request)
    if reply is None:
        return -1
    logging.debug(reply.show())
    for idx in range(len(reply.ports)):
        if reply.ports[idx].port_no == port_no:
            break
    if idx >= len(reply.ports):
        return -1
    mod = message.port_mod()
    mod.port_no = port_no
    mod.hw_addr = reply.ports[idx].hw_addr
    mod.config = config
    mod.mask = mask
    mod.advertise = reply.ports[idx].advertised
    rv = controller.message_send(mod)
    return rv
예제 #4
0
    def runTest(self):

        logging.info("Running PortModFailedBadHwAdd Grp100No280 test")

        of_ports = config["port_map"].keys()
        of_ports.sort()
        self.assertTrue(len(of_ports) > 1, "Not enough ports for test")

        # Send features request
        request = message.features_request()
        reply, pkt = self.controller.transact(request, timeout=2)
        self.assertTrue(reply is not None, "Features Reply not recieved")
        for idx in range(len(reply.ports)):
            if reply.ports[idx].port_no == of_ports[0]:
                break
        self.assertTrue(idx <= len(reply.ports), "Error in the ports information")

        logging.info("Sending port_mod request ..")
        mod = message.port_mod()
        mod.port_no = of_ports[0]
        mod.hw_addr = [0, 0, 0, 0, 0, 0]
        mod.config = ofp.OFPPC_NO_FLOOD
        mod.mask = ofp.OFPPC_NO_FLOOD
        mod.advertise = reply.ports[idx].advertised
        rv = self.controller.message_send(mod)
        self.assertTrue(rv != -1, "Unable to send the message")

        logging.info("Waiting for OFPT_ERROR message...")
        count = 0
        while True:
            (response, raw) = self.controller.poll(ofp.OFPT_ERROR)
            if not response:  # Timeout
                break
            if not response.type == ofp.OFPET_PORT_MOD_FAILED:
                logging.info("Error type is not as expected")
                break
            if not response.code == ofp.OFPPMFC_BAD_HW_ADDR:
                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