Ejemplo n.º 1
0
    def test_list(self):
        self.client.get_all_interface_data.return_value = [[
            "em1", "00:11:22:33:44:55", [101, 102, 104, 201, 203],
            "99:aa:bb:cc:dd:ff", "555"
        ], [
            "em2", "00:11:22:66:77:88", [201, 203], "99:aa:bb:cc:dd:ff", "777"
        ], ["em3", "00:11:22:aa:bb:cc", '', '', '']]

        arglist = ['uuid1']
        verifylist = [('node_ident', 'uuid1')]

        cmd = shell.InterfaceListCommand(self.app, None)
        parsed_args = self.check_parser(cmd, arglist, verifylist)
        cols, values = cmd.take_action(parsed_args)

        expected_cols = ("Interface", "MAC Address", "Switch Port VLAN IDs",
                         "Switch Chassis ID", "Switch Port ID")

        # Note that em3 has no lldp data
        expected_rows = [[
            "em1", "00:11:22:33:44:55", [101, 102, 104, 201, 203],
            "99:aa:bb:cc:dd:ff", "555"
        ], [
            "em2", "00:11:22:66:77:88", [201, 203], "99:aa:bb:cc:dd:ff", "777"
        ], ["em3", "00:11:22:aa:bb:cc", '', '', '']]

        self.assertEqual(expected_cols, cols)
        self.assertEqual(expected_rows, values)
Ejemplo n.º 2
0
    def test_list_no_data(self):
        self.client.get_all_interface_data.return_value = [[]]

        arglist = ['uuid1']
        verifylist = [('node_ident', 'uuid1')]

        cmd = shell.InterfaceListCommand(self.app, None)
        parsed_args = self.check_parser(cmd, arglist, verifylist)
        cols, values = cmd.take_action(parsed_args)

        expected_cols = ("Interface", "MAC Address", "Switch Port VLAN IDs",
                         "Switch Chassis ID", "Switch Port ID")
        expected_rows = [[]]

        self.assertEqual(expected_cols, cols)
        self.assertEqual(expected_rows, values)
Ejemplo n.º 3
0
    def test_list_field(self):
        self.client.get_all_interface_data.return_value = [["em1", 1514],
                                                           ["em2", 9216],
                                                           ["em3", '']]

        arglist = ['uuid1', '--fields', 'interface', "switch_port_mtu"]
        verifylist = [('node_ident', 'uuid1'),
                      ('fields', ["interface", "switch_port_mtu"])]

        cmd = shell.InterfaceListCommand(self.app, None)
        parsed_args = self.check_parser(cmd, arglist, verifylist)
        cols, values = cmd.take_action(parsed_args)

        expected_cols = ("Interface", "Switch Port MTU")
        expected_rows = [["em1", 1514], ["em2", 9216], ["em3", '']]

        self.assertEqual(expected_cols, cols)
        self.assertEqual(expected_rows, values)
Ejemplo n.º 4
0
    def test_list_filtered(self):
        self.client.get_all_interface_data.return_value = [[
            "em1", "00:11:22:33:44:55", [101, 102, 104, 201, 203],
            "99:aa:bb:cc:dd:ff", "555"
        ]]

        arglist = ['uuid1', '--vlan', '104']
        verifylist = [('node_ident', 'uuid1'), ('vlan', [104])]

        cmd = shell.InterfaceListCommand(self.app, None)
        parsed_args = self.check_parser(cmd, arglist, verifylist)
        cols, values = cmd.take_action(parsed_args)

        expected_cols = ("Interface", "MAC Address", "Switch Port VLAN IDs",
                         "Switch Chassis ID", "Switch Port ID")
        expected_rows = [[
            "em1", "00:11:22:33:44:55", [101, 102, 104, 201, 203],
            "99:aa:bb:cc:dd:ff", "555"
        ]]

        self.assertEqual(expected_cols, cols)
        self.assertEqual(expected_rows, values)