Exemple #1
0
    def test_incomplete_output(self):
        self.maxDiff = None
        intf = Interface(device=self.device)
        # Get outputs
        intf.maker.outputs[ShowInterface] = \
            {'':InterfaceOutput.ShowInterface}

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

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

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

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

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

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

        # Learn the feature
        intf.learn()        

        # Delete missing specific attribute values
        expect_dict = deepcopy(InterfaceOutput.InterfaceOpsOutput_info)
        del(expect_dict['Ethernet2/1']['ipv4']['10.2.2.2/24']['route_tag'])
        del(expect_dict['Ethernet2/1']['ipv4']['10.2.2.2/24']['origin'])
                
        # Verify Ops was created successfully
        self.assertEqual(intf.info, expect_dict)
Exemple #2
0
    def test_selective_attribute(self):
        self.maxDiff = None
        intf = Interface(device=self.device)
        # Get outputs
        intf.maker.outputs[ShowInterface] = \
            {'':InterfaceOutput.ShowInterface}

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

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

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

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

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

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

        # Learn the feature
        intf.learn()        

        # Check specific attribute values
        # info - vrf
        self.assertEqual(intf.info['mgmt0']['vrf'], 'management')
        # info - link_status
        self.assertEqual(intf.info['mgmt0']['oper_status'], 'up')
Exemple #3
0
    def test_complete_output(self):
        self.maxDiff = None
        intf = Interface(device=self.device)
        # Get outputs
        intf.maker.outputs[ShowInterface] = \
            {'':InterfaceOutput.ShowInterface}

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

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

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

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

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

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

        # Learn the feature
        intf.learn()

        # Verify Ops was created successfully
        self.assertEqual(intf.info, InterfaceOutput.InterfaceOpsOutput_info)
    def test_empty_output(self):
        self.maxDiff = None
        intf = Interface(device=self.device)
        # Get outputs
        outputs['show interface'] = ''
        outputs['show vrf all interface'] = ''
        outputs['show interface switchport'] = ''
        outputs['show ip interface vrf all'] = ''
        outputs['show ipv6 interface vrf all'] = ''
        intf.maker.outputs[ShowRoutingVrfAll] = {"{'vrf':''}": ''}
        intf.maker.outputs[ShowRoutingIpv6VrfAll] = {"{'vrf':''}": ''}
        self.device.execute = Mock()
        self.device.execute.side_effect = mapper
        # Learn the feature
        intf.learn()

        # Check no attribute not found
        # info - vrf
        with self.assertRaises(AttributeError):
            vrf = (intf.info['Mgmt0']['vrf'])

        outputs['show interface'] = InterfaceOutput.ShowInterface_all
        outputs[
            'show vrf all interface'] = InterfaceOutput.ShowVrfAllInterface_all
        outputs[
            'show interface switchport'] = InterfaceOutput.ShowInterfaceSwitchport_all
        outputs[
            'show ip interface vrf all'] = InterfaceOutput.ShowIpInterfaceVrfAll_all
        outputs[
            'show ipv6 interface vrf all'] = InterfaceOutput.ShowIpv6InterfaceVrfAll_all
    def test_custom_output(self):
        self.maxDiff = None
        intf = Interface(device=self.device)
        # Get outputs

        intf.maker.outputs[ShowRoutingVrfAll] = \
            {"{'vrf':'VRF1'}":InterfaceOutput.ShowRoutingVrfAll_vrf1}

        self.device.execute = Mock()
        self.device.execute.side_effect = mapper

        # Learn the feature
        intf.learn(interface='Ethernet2/1', vrf='VRF1', address_family='ipv4')

        # Verify Ops was created successfully
        self.assertDictEqual(intf.info,
                             InterfaceOutput.InterfaceOpsOutput_custom_info)
Exemple #6
0
    def test_empty_output(self):
        self.maxDiff = None
        intf = Interface(device=self.device)
        # Get outputs
        intf.maker.outputs[ShowInterface] = {'':''}
        intf.maker.outputs[ShowVrfAllInterface] = {'':''}
        intf.maker.outputs[ShowIpInterfaceVrfAll] = {'':''}
        intf.maker.outputs[ShowIpv6InterfaceVrfAll] = {'':''}
        intf.maker.outputs[ShowInterfaceSwitchport] = {'':''}
        intf.maker.outputs[ShowRoutingVrfAll] = {'':''}
        intf.maker.outputs[ShowRoutingIpv6VrfAll] = {'':''}
        
        # Learn the feature
        intf.learn()

        # Check no attribute not found
        # info - vrf
        with self.assertRaises(AttributeError):
            vrf = (intf.info['mgmt0']['vrf'])
    def test_complete_output(self):
        self.maxDiff = None
        intf = Interface(device=self.device)
        # Get outputs

        intf.maker.outputs[ShowRoutingVrfAll] = \
            {"{'vrf':''}":InterfaceOutput.ShowRoutingVrfAll}

        intf.maker.outputs[ShowRoutingIpv6VrfAll] = \
            {"{'vrf':''}":InterfaceOutput.ShowRoutingIpv6VrfAll}
        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)
    def test_selective_attribute(self):
        self.maxDiff = None
        intf = Interface(device=self.device)
        # Get outputs

        intf.maker.outputs[ShowRoutingVrfAll] = \
            {"{'vrf':''}":InterfaceOutput.ShowRoutingVrfAll}

        intf.maker.outputs[ShowRoutingIpv6VrfAll] = \
            {"{'vrf':''}":InterfaceOutput.ShowRoutingIpv6VrfAll}
        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['Mgmt0']['vrf'], 'management')
        # info - link_status
        self.assertEqual(intf.info['Mgmt0']['oper_status'], 'up')
    def test_incomplete_output(self):
        self.maxDiff = None
        intf = Interface(device=self.device)
        # Get outputs


        intf.maker.outputs[ShowRoutingVrfAll] = \
            {"{'vrf':''}":''}

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

        # Delete missing specific attribute values
        expect_dict = deepcopy(InterfaceOutput.InterfaceOpsOutput_info)
        del (expect_dict['Ethernet2/1']['ipv4']['10.2.2.2/24']['route_tag'])
        del (expect_dict['Ethernet2/1']['ipv4']['10.2.2.2/24']['origin'])

        # Verify Ops was created successfully
        self.assertDictEqual(intf.info, expect_dict)