Beispiel #1
0
class PortStatusTest(unittest.TestCase):

    def setUp(self):
        self.client = FbossAgentClient(host=args.host, port=args.port)

    def test_port_status_matchfb303(self):
        """ Verify that for each port, it's internal status (down, up)
        matches what we're reporting to fb303.  See t14145409
        """
        for _pnum, pstate in self.client.getAllPortInfo().items():
            self.assertEqual(pstate.operState,
                             self.client.getCounter("%s.up" % pstate.name))

    def test_port_FEC(self):
        """Verify that FEC is exposed per port"""
        for _pnum, pstate in self.client.getAllPortInfo().items():
            self.assertTrue(hasattr(pstate, 'fecEnabled'))

    def tearDown(self):
        # TODO(rsher) figure out better cleanup
        self.client.__exit__(None, None, None)
Beispiel #2
0
    def convert(self, value, param, ctx):
        try:
            if self.port_info_map is None:
                client = FbossAgentClient(ctx.obj.hostname)
                self.port_info_map = client.getAllPortInfo()
            if value.isdigit():
                port = self.port_info_map[int(value)]
                return port.portId
            for port_id, port_info in self.port_info_map.items():
                if port_info.name == value:
                    return port_id
            raise ValueError("No port found with that name")

        except (ValueError, KeyError):
            self.fail('%s is not a valid Port' % value, param, ctx)
Beispiel #3
0
    def convert(self, value, param, ctx):
        try:
            if self.port_info_map is None:
                client = FbossAgentClient(ctx.obj.hostname)
                self.port_info_map = client.getAllPortInfo()
            if value.isdigit():
                port = self.port_info_map[int(value)]
                return port.portId
            for port_id, port_info in self.port_info_map.items():
                if port_info.name == value:
                    return port_id
            raise ValueError("No port found with that name")

        except (ValueError, KeyError):
            self.fail('%s is not a valid Port' % value, param, ctx)