Beispiel #1
0
    def test_custom_output(self):
        self.maxDiff = None
        ospf = Ospf(device=self.device)

        # Set outputs
        ospf.maker.outputs[ShowProtocolsAfiAllAll] = {
            '': OspfOutput.ShowProtocolsAfiAllAll
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusive] = {
            "{'vrf':'VRF1'}": OspfOutput.ShowOspfVrfAllInclusive_custom
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveShamLinks] = {
            "{'vrf':'VRF1'}": OspfOutput.ShowOspfVrfAllInclusiveShamLinks
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveVirtualLinks] = {
            "{'vrf':'VRF1'}": OspfOutput.ShowOspfVrfAllInclusiveVirtualLinks
        }
        ospf.maker.outputs[ShowOspfMplsTrafficEngLink] = {
            '': OspfOutput.ShowOspfMplsTrafficEngLink
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveDatabaseRouter] = {
            "{'vrf':'VRF1'}":
            OspfOutput.ShowOspfVrfAllInclusiveDatabaseRouter_custom
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveDatabaseExternal] = {
            "{'vrf':'VRF1'}":
            OspfOutput.ShowOspfVrfAllInclusiveDatabaseExternal_custom
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveDatabaseNetwork] = {
            "{'vrf':'VRF1'}":
            OspfOutput.ShowOspfVrfAllInclusiveDatabaseNetwork_custom
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveDatabaseSummary] = {
            "{'vrf':'VRF1'}":
            OspfOutput.ShowOspfVrfAllInclusiveDatabaseSummary_custom
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveDatabaseOpaqueArea] = {
            "{'vrf':'VRF1'}":
            OspfOutput.ShowOspfVrfAllInclusiveDatabaseOpaqueArea_custom
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveInterface] = {
            "{'interface':'GigabitEthernet0/0/0/1','vrf':'VRF1'}":
            OspfOutput.ShowOspfVrfAllInclusiveInterface_custom
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveNeighborDetail] = {
            "{'interface':'GigabitEthernet0/0/0/1','neighbor':'10.36.3.3','vrf':'VRF1'}":
            OspfOutput.ShowOspfVrfAllInclusiveNeighborDetail_custom
        }

        # Return outputs above as inputs to parser when called
        self.device.execute = Mock()
        self.device.execute.side_effect = mapper

        # Learn the feature
        ospf.learn(vrf='VRF1',
                   interface='GigabitEthernet0/0/0/1',
                   neighbor='10.36.3.3')

        # Verify Ops was created successfully
        self.assertEqual(ospf.info, OspfOutput.OspfInfo_custom)
Beispiel #2
0
    def test_empty_output(self):
        self.maxDiff = None
        ospf = Ospf(device=self.device)

        # Set outputs
        ospf.maker.outputs[ShowProtocolsAfiAllAll] = {'': {}}
        ospf.maker.outputs[ShowOspfVrfAllInclusive] = {'': {}}
        ospf.maker.outputs[ShowOspfVrfAllInclusiveShamLinks] = {'': {}}
        ospf.maker.outputs[ShowOspfVrfAllInclusiveVirtualLinks] = {'': {}}
        ospf.maker.outputs[ShowOspfMplsTrafficEngLink] = {'': {}}
        ospf.maker.outputs[ShowOspfVrfAllInclusiveDatabaseRouter] = {'': {}}
        ospf.maker.outputs[ShowOspfVrfAllInclusiveDatabaseExternal] = {'': {}}
        ospf.maker.outputs[ShowOspfVrfAllInclusiveDatabaseNetwork] = {'': {}}
        ospf.maker.outputs[ShowOspfVrfAllInclusiveDatabaseSummary] = {'': {}}
        ospf.maker.outputs[ShowOspfVrfAllInclusiveDatabaseOpaqueArea] = {
            '': {}
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveInterface] = {'': {}}
        ospf.maker.outputs[ShowOspfVrfAllInclusiveNeighborDetail] = {'': {}}

        # Return outputs above as inputs to parser when called
        self.device.execute = Mock()
        self.device.execute.side_effect = mapper

        # Learn the feature
        ospf.learn()

        # Verify attribute is missing
        with self.assertRaises(AttributeError):
            ospf.info['vrf']
Beispiel #3
0
    def test_selective_attribute(self):
        self.maxDiff = None
        ospf = Ospf(device=self.device)

        # Set outputs
        ospf.maker.outputs[ShowProtocolsAfiAllAll] = {
            '': OspfOutput.ShowProtocolsAfiAllAll
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusive] = {
            "{'vrf':''}": OspfOutput.ShowOspfVrfAllInclusive
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveShamLinks] = {
            "{'vrf':''}": OspfOutput.ShowOspfVrfAllInclusiveShamLinks
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveVirtualLinks] = {
            "{'vrf':''}": OspfOutput.ShowOspfVrfAllInclusiveVirtualLinks
        }
        ospf.maker.outputs[ShowOspfMplsTrafficEngLink] = {
            '': OspfOutput.ShowOspfMplsTrafficEngLink
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveDatabaseRouter] = {
            "{'vrf':''}": OspfOutput.ShowOspfVrfAllInclusiveDatabaseRouter
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveDatabaseExternal] = {
            "{'vrf':''}": OspfOutput.ShowOspfVrfAllInclusiveDatabaseExternal
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveDatabaseNetwork] = {
            "{'vrf':''}": OspfOutput.ShowOspfVrfAllInclusiveDatabaseNetwork
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveDatabaseSummary] = {
            "{'vrf':''}": OspfOutput.ShowOspfVrfAllInclusiveDatabaseSummary
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveDatabaseOpaqueArea] = {
            "{'vrf':''}": OspfOutput.ShowOspfVrfAllInclusiveDatabaseOpaqueArea
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveInterface] = {
            "{'interface':'','vrf':''}":
            OspfOutput.ShowOspfVrfAllInclusiveInterface
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveNeighborDetail] = {
            "{'interface':'','neighbor':'','vrf':''}":
            OspfOutput.ShowOspfVrfAllInclusiveNeighborDetail
        }

        # Return outputs above as inputs to parser when called
        self.device.execute = Mock()
        self.device.execute.side_effect = mapper

        # Learn the feature
        ospf.learn()

        # Check selective attribute
        self.assertEqual(1713, ospf.info['vrf']['VRF1']['address_family']\
                                    ['ipv4']['instance']['1']['areas']\
                                    ['0.0.0.1']['database']['lsa_types'][1]\
                                    ['lsas']['10.229.11.11 10.229.11.11']\
                                    ['ospfv2']['header']['age'])
Beispiel #4
0
    def test_missing_attributes(self):
        self.maxDiff = None
        ospf = Ospf(device=self.device)

        # Set outputs
        ospf.maker.outputs[ShowProtocolsAfiAllAll] = {'': {}}
        ospf.maker.outputs[ShowOspfVrfAllInclusive] = {
            "{'vrf':''}": OspfOutput.ShowOspfVrfAllInclusive
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveShamLinks] = {
            "{'vrf':''}": OspfOutput.ShowOspfVrfAllInclusiveShamLinks
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveVirtualLinks] = {
            "{'vrf':''}": OspfOutput.ShowOspfVrfAllInclusiveVirtualLinks
        }
        ospf.maker.outputs[ShowOspfMplsTrafficEngLink] = {
            '': OspfOutput.ShowOspfMplsTrafficEngLink
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveDatabaseRouter] = {
            "{'vrf':''}": OspfOutput.ShowOspfVrfAllInclusiveDatabaseRouter
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveDatabaseExternal] = {
            "{'vrf':''}": OspfOutput.ShowOspfVrfAllInclusiveDatabaseExternal
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveDatabaseNetwork] = {
            "{'vrf':''}": OspfOutput.ShowOspfVrfAllInclusiveDatabaseNetwork
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveDatabaseSummary] = {
            "{'vrf':''}": OspfOutput.ShowOspfVrfAllInclusiveDatabaseSummary
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveDatabaseOpaqueArea] = {
            "{'vrf':''}": OspfOutput.ShowOspfVrfAllInclusiveDatabaseOpaqueArea
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveInterface] = {
            "{'interface':'','vrf':''}":
            OspfOutput.ShowOspfVrfAllInclusiveInterface
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveNeighborDetail] = {
            "{'interface':'','neighbor':'','vrf':''}":
            OspfOutput.ShowOspfVrfAllInclusiveNeighborDetail
        }

        # Return outputs above as inputs to parser when called
        self.device.execute = Mock()
        self.device.execute.side_effect = mapper

        # Learn the feature
        ospf.learn()

        # Verify key not created due to ouput missing
        with self.assertRaises(KeyError):
            single_value_preference = ospf.info['vrf']['default']\
                                        ['address_family']['ipv4']['instance']\
                                        ['1']['preference']['single_value']['all']
Beispiel #5
0
    def test_complete_output(self):
        self.maxDiff = None
        ospf = Ospf(device=self.device)

        # Set outputs
        ospf.maker.outputs[ShowProtocolsAfiAllAll] = {
            '': OspfOutput.ShowProtocolsAfiAllAll
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusive] = {
            "{'vrf':''}": OspfOutput.ShowOspfVrfAllInclusive
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveShamLinks] = {
            "{'vrf':''}": OspfOutput.ShowOspfVrfAllInclusiveShamLinks
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveVirtualLinks] = {
            "{'vrf':''}": OspfOutput.ShowOspfVrfAllInclusiveVirtualLinks
        }
        ospf.maker.outputs[ShowOspfMplsTrafficEngLink] = {
            '': OspfOutput.ShowOspfMplsTrafficEngLink
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveDatabaseRouter] = {
            "{'vrf':''}": OspfOutput.ShowOspfVrfAllInclusiveDatabaseRouter
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveDatabaseExternal] = {
            "{'vrf':''}": OspfOutput.ShowOspfVrfAllInclusiveDatabaseExternal
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveDatabaseNetwork] = {
            "{'vrf':''}": OspfOutput.ShowOspfVrfAllInclusiveDatabaseNetwork
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveDatabaseSummary] = {
            "{'vrf':''}": OspfOutput.ShowOspfVrfAllInclusiveDatabaseSummary
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveDatabaseOpaqueArea] = {
            "{'vrf':''}": OspfOutput.ShowOspfVrfAllInclusiveDatabaseOpaqueArea
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveInterface] = {
            "{'interface':'','vrf':''}":
            OspfOutput.ShowOspfVrfAllInclusiveInterface
        }
        ospf.maker.outputs[ShowOspfVrfAllInclusiveNeighborDetail] = {
            "{'interface':'','neighbor':'','vrf':''}":
            OspfOutput.ShowOspfVrfAllInclusiveNeighborDetail
        }

        # Return outputs above as inputs to parser when called
        self.device.execute = Mock()
        self.device.execute.side_effect = mapper

        # Learn the feature
        ospf.learn()

        # Verify Ops was created successfully
        self.assertEqual(ospf.info, OspfOutput.OspfInfo)