Exemplo n.º 1
0
    def test_incomplete_output(self):
        self.maxDiff = None
        intf = Interface(device=self.device)
        custom = {
            'ShowInterfacesAccounting': {
                '': 'GigabitEthernet1/0/1',
            }
        }
        outputs['show interfaces accounting'] = ''
        outputs['show ip interface'] = ''
        # intf.maker.outputs[ShowInterfacesAccounting] = \
        #     {"{'intf': 'GigabitEthernet1/0/1'}":InterfaceOutput.ShowInterfacesAccountingCustom}

        intf.maker.outputs[ShowInterfacesAccounting] = \
            {'':InterfaceOutput.ShowInterfacesAccountingCustom}
        self.device.execute = Mock()
        self.device.execute.side_effect = mapper
        # Learn the feature
        intf.learn(custom=custom)

        # Delete missing specific attribute values
        outputs[
            'show interfaces accounting'] = InterfaceOutput.ShowInterfacesAccounting_all
        outputs['show ip interface'] = InterfaceOutput.ShowIpInterfaces_all
        expect_dict = deepcopy(InterfaceOutput.InterfaceOpsOutput_info)
        del (expect_dict['GigabitEthernet1/0/1']['ipv4'])
        del (expect_dict['GigabitEthernet1/0/2']['accounting'])
        # Verify Ops was created successfully
        self.assertDictEqual(intf.info, expect_dict)
Exemplo n.º 2
0
    def test_selective_attribute(self):
        self.maxDiff = None
        intf = Interface(device=self.device)
        # Get outputs
        intf.maker.outputs[ShowInterfaces] = \
            {'':InterfaceOutput.ShowInterfaces}

        intf.maker.outputs[ShowEtherchannelSummary] = \
            {'':InterfaceOutput.ShowEtherchannelSummary}

        intf.maker.outputs[ShowIpInterface] = \
            {'':InterfaceOutput.ShowIpInterface}

        intf.maker.outputs[ShowIpv6Interface] = \
            {'':InterfaceOutput.ShowIpv6Interface}

        intf.maker.outputs[ShowVrfDetail] = \
            {'':InterfaceOutput.ShowVrfDetail}

        intf.maker.outputs[ShowInterfacesAccounting] = \
            {'':InterfaceOutput.ShowInterfacesAccounting}

        # Learn the feature
        intf.learn()

        # Check specific attribute values
        # info - vrf
        self.assertEqual(intf.info['GigabitEthernet0/0']['vrf'], 'Mgmt-vrf')
        # info - link_status
        self.assertEqual(intf.info['GigabitEthernet1/0/2']['oper_status'],
                         'up')
Exemplo n.º 3
0
    def test_complete_output(self):
        self.maxDiff = None
        intf = Interface(device=self.device)
        # Get outputs
        intf.maker.outputs[ShowInterfaces] = \
            {'':InterfaceOutput.ShowInterfaces}

        intf.maker.outputs[ShowEtherchannelSummary] = \
            {'':InterfaceOutput.ShowEtherchannelSummary}

        intf.maker.outputs[ShowIpInterface] = \
            {'':InterfaceOutput.ShowIpInterface}

        intf.maker.outputs[ShowIpv6Interface] = \
            {'':InterfaceOutput.ShowIpv6Interface}

        intf.maker.outputs[ShowVrfDetail] = \
            {'':InterfaceOutput.ShowVrfDetail}

        intf.maker.outputs[ShowInterfacesAccounting] = \
            {'':InterfaceOutput.ShowInterfacesAccounting}

        # Learn the feature
        intf.learn()

        # Verify Ops was created successfully
        self.assertEqual(intf.info, InterfaceOutput.InterfaceOpsOutput_info)
Exemplo n.º 4
0
    def test_incomplete_output(self):
        self.maxDiff = None
        intf = Interface(device=self.device)
        # Get outputs
        intf.maker.outputs[ShowInterfaces] = \
            {'':InterfaceOutput.ShowInterfaces}

        intf.maker.outputs[ShowEtherchannelSummary] = \
            {'':InterfaceOutput.ShowEtherchannelSummary}

        intf.maker.outputs[ShowIpInterface] = {'': ''}

        intf.maker.outputs[ShowIpv6Interface] = \
            {'':InterfaceOutput.ShowIpv6Interface}

        intf.maker.outputs[ShowVrfDetail] = \
            {'':InterfaceOutput.ShowVrfDetail}

        intf.maker.outputs[ShowInterfacesAccounting] = \
            {'':InterfaceOutput.ShowInterfacesAccounting}

        # Learn the feature
        intf.learn()

        # Delete missing specific attribute values
        expect_dict = deepcopy(InterfaceOutput.InterfaceOpsOutput_info)
        del (expect_dict['GigabitEthernet1/0/1']['ipv4'])
        del (expect_dict['GigabitEthernet0/0']['ipv4'])
        del (expect_dict['Vlan100']['ipv4'])

        # Verify Ops was created successfully
        self.assertEqual(intf.info, expect_dict)
Exemplo n.º 5
0
    def test_custom_output(self):
        intf = Interface(device=self.device)
        self.device.execute = Mock()
        self.device.execute.side_effect = mapper
        # Learn the feature
        intf.learn(interface='GigabitEthernet1/0/1', address_family='ipv4')

        self.maxDiff = None
        # Verify Ops was created successfully
        self.assertDictEqual(intf.info,
                             InterfaceOutput.interfaceOpsOutput_custom_info)
Exemplo n.º 6
0
    def test_complete_output(self):
        self.maxDiff = None
        intf = Interface(device=self.device)
        # Get outputs
        self.device.execute = Mock()
        self.device.execute.side_effect = mapper

        # Learn the feature
        intf.learn()

        # Verify Ops was created successfully
        self.assertDictEqual(intf.info,
                             InterfaceOutput.InterfaceOpsOutput_info)
Exemplo n.º 7
0
    def test_selective_attribute(self):
        self.maxDiff = None
        intf = Interface(device=self.device)
        # Get outputs
        self.device.execute = Mock()
        self.device.execute.side_effect = mapper

        # Learn the feature
        intf.learn()

        # Check specific attribute values
        # info - vrf
        self.assertEqual(intf.info['GigabitEthernet1/0/1']['vrf'], 'VRF1')
        # info - link_status
        self.assertEqual(intf.info['GigabitEthernet1/0/2']['oper_status'],
                         'up')
Exemplo n.º 8
0
    def test_empty_output(self):
        self.maxDiff = None
        intf = Interface(device=self.device)
        # Get outputs
        intf.maker.outputs[ShowInterfaces] = {'': ''}
        intf.maker.outputs[ShowEtherchannelSummary] = {'': ''}
        intf.maker.outputs[ShowIpInterface] = {'': ''}
        intf.maker.outputs[ShowIpv6Interface] = {'': ''}
        intf.maker.outputs[ShowVrfDetail] = {'': ''}

        # Learn the feature
        intf.learn()

        # Check no attribute not found
        # info - oper_status
        with self.assertRaises(AttributeError):
            vrf = (intf.info['GigabitEthernet1/0/2']['oper_status'])
Exemplo n.º 9
0
    def test_empty_output(self):
        self.maxDiff = None
        intf = Interface(device=self.device)
        # Get outputs
        outputs['show interfaces GigabitEthernet1/0/1'] = ''
        outputs['show interfaces GigabitEthernet1/0/1 accounting'] = ''
        outputs['show ip interface GigabitEthernet1/0/1'] = ''
        outputs['show ipv6 interface GigabitEthernet1/0/1'] = ''
        outputs['show vrf'] = ''
        outputs['show interfaces'] = ''
        outputs['show ip interface'] = ''
        outputs['show ipv6 interface'] = ''
        outputs['show interfaces accounting'] = ''
        outputs['show etherchannel summary'] = ''
        self.device.execute = Mock()
        self.device.execute.side_effect = mapper

        # Learn the feature
        intf.learn()
        outputs[
            'show interfaces GigabitEthernet1/0/1'] = InterfaceOutput.ShowInterfaces_gi1
        outputs[
            'show interfaces GigabitEthernet1/0/1 accounting'] = \
            InterfaceOutput.ShowInterfacesAccounting_gi1
        outputs[
            'show ip interface GigabitEthernet1/0/1'] = \
            InterfaceOutput.ShowIpInterfaces_gi1
        outputs[
            'show ipv6 interface GigabitEthernet1/0/1'] = \
            InterfaceOutput.ShowIpv6Interfaces_gi1
        outputs['show vrf'] = InterfaceOutput.ShowVrf_all
        outputs['show interfaces'] = InterfaceOutput.ShowInterfaces_all
        outputs['show ip interface'] = InterfaceOutput.ShowIpInterfaces_all
        outputs['show ipv6 interface'] = InterfaceOutput.ShowIpv6Interfaces_all
        outputs[
            'show interfaces accounting'] = InterfaceOutput.ShowInterfacesAccounting_all
        outputs[
            'show etherchannel summary'] = InterfaceOutput.ShowEtherchannelSummary_all
        # Check no attribute not found
        # info - oper_status
        with self.assertRaises(AttributeError):
            vrf = (intf.info['GigabitEthernet1/0/2']['oper_status'])