Ejemplo n.º 1
0
 def setUpClass(cls):
     """[Controller2Switch/PortStatsRequest] - size 8."""
     super().setUpClass()
     super().set_raw_dump_file('v0x01', 'ofpt_port_stats_request')
     super().set_raw_dump_object(StatsRequest, xid=17,
                                 body_type=StatsType.OFPST_PORT,
                                 flags=0, body=PortStatsRequest(port_no=80))
     super().set_minimum_size(12)
 def test_pack_unpack_port_stats(self):
     """Pack and unpack PortStatsRequest."""
     body = PortStatsRequest(Port.OFPP_NONE)
     req = StatsRequest(16909060,
                        body_type=StatsTypes.OFPST_PORT,
                        body=body)
     pack = req.pack()
     unpacked = unpack_message(pack)
     self.assertEqual(req, unpacked)
Ejemplo n.º 3
0
def request_port_stats(controller, switch):
    """Request port stats from switches.

    Args:
        controller(:class:`~kytos.core.controller.Controller`):
            the controller being used.
        switch(:class:`~kytos.core.switch.Switch`):
            target to send a stats request.
    """
    body = PortStatsRequest()
    stats_request = StatsRequest(body_type=StatsType.OFPST_PORT, body=body)
    # req.pack()
    emit_message_out(controller, switch.connection, stats_request)
 def unpack(self, buff):
     """Unpack according to :attr:`body_type`."""
     super().unpack(buff)
     if self.body_type == StatsTypes.OFPST_PORT:
         buff = self.body.value
         self.body = PortStatsRequest()
         self.body.unpack(buff)
     elif self.body_type == StatsTypes.OFPST_FLOW:
         buff = self.body.value
         self.body = FlowStatsRequest()
         self.body.unpack(buff)
     elif self.body_type == StatsTypes.OFPST_AGGREGATE:
         buff = self.body.value
         self.body = AggregateStatsRequest()
         self.body.unpack(buff)
class TestPortStatsRequest(unittest.TestCase):
    """Test for PortStatsRequest."""

    def setUp(self):
        """Basic test setup."""
        self.message = PortStatsRequest()
        self.message.port_no = 80

    def test_get_size(self):
        """[Controller2Switch/PortStatsRequest] - size 8."""
        self.assertEqual(self.message.get_size(), 8)

    @unittest.skip('Not yet implemented')
    def test_pack(self):
        """[Controller2Switch/PortStatsRequest] - packing."""
        # TODO
        pass

    @unittest.skip('Not yet implemented')
    def test_unpack(self):
        """[Controller2Switch/PortStatsRequest] - unpacking."""
        # TODO
        pass
 def setUp(self):
     """Basic test setup."""
     self.message = PortStatsRequest()
     self.message.port_no = 80
Ejemplo n.º 7
0
 def request(self, conn):
     """Ask for port stats."""
     body = PortStatsRequest(Port.OFPP_NONE)  # All ports
     req = StatsRequest(body_type=StatsTypes.OFPST_PORT, body=body)
     self._send_event(req, conn)
     log.debug('Port Stats request for switch %s sent.', conn.switch.dpid)