Example #1
0
    def test_disable_no_instance(self):

        tb = Genie.testbed = Testbed()
        dev = Device(testbed=tb, name='PE1', os='nxos')

        rip = Rip(instance_id=1)
        rip.add_force_vrf(None)
        dev.add_feature(rip)

        # Default configuration, let's make sure it works
        output = rip.build_unconfig(unconfig_feature=True, apply=False)
        self.assertMultiLineDictEqual(output, {'PE1': 'no feature rip'})
        # Set a mock
        dev.cli = Mock()
        dev.configure = Mock()
        output = rip.build_unconfig(unconfig_feature=True, apply=True)

        expected_output = None
        self.assertEqual(output, expected_output)
Example #2
0
    def test_uncfg(self):

        tb = Genie.testbed = Testbed()
        dev = Device(testbed=tb, name='PE1', os='nxos')

        rip = Rip(instance_id=1)
        rip.add_force_vrf(None)
        # Default configuration, let's make sure it works
        output = rip.build_unconfig(apply=False)
        # There was nothing to unconfigure
        self.assertMultiLineDictEqual(output, {})

        dev.add_feature(rip)
        output = rip.build_unconfig(apply=False)
        self.assertMultiLineDictEqual(output, {'PE1': 'feature rip\nno router rip 1'})

        # Set a mock
        dev.cli = Mock()
        dev.configure = Mock()
        output = rip.build_unconfig(apply=True)

        expected_output = None
        self.assertEqual(output, expected_output)
Example #3
0
    def test_remove_vrf_af(self):
        # Add a device to it
        tb = Genie.testbed = Testbed()
        dev1 = Device(testbed=tb, name='dev1', os='nxos')
        dev2 = Device(testbed=tb, name='dev2', os='nxos')
        vrf1 = Vrf(name='blue')
        intf1 = Interface(device=dev1, name='Ethernet0/0', vrf=vrf1)
        rip = Rip(instance_id=5)
        rip.add_force_vrf(None)
        dev1.add_feature(rip)
        dev2.add_feature(rip)
        intf1.add_feature(rip)

        # Configure rip
        rip.device_attr['dev1'].vrf_attr['blue'].address_family_attr['ipv4 unicast'].distance = 5

        output = rip.build_config(apply=False)
        self.assertMultiLineDictEqual(output,
{'dev1': 'feature rip\n'
         'router rip 5\n'
         ' address-family ipv4 unicast\n'
         '  exit\n'
         ' vrf blue\n'
         '  address-family ipv4 unicast\n'
         '   distance 5\n'
         '   exit\n'
         '  exit\n'
         ' exit',
'dev2': 'feature rip\n'
         'router rip 5\n'
         ' address-family ipv4 unicast\n'
         '  exit\n'
         ' exit'})

        output = rip.build_unconfig(\
                 attributes='device_attr__dev1__vrf_attr__blue__address_family_attr__ipv4 unicast',
                 apply=False)

        self.assertMultiLineDictEqual(output,
{'dev1': 'router rip 5\n'
         ' vrf blue\n'
         '  no address-family ipv4 unicast\n'
         '  exit\n'
         ' exit'})
Example #4
0
    def test_remove_af(self):
        # Add a device to it
        tb = Genie.testbed = Testbed()
        dev1 = Device(testbed=tb, name='dev1', os='nxos')
        dev2 = Device(testbed=tb, name='dev2', os='nxos')
        rip = Rip(instance_id=5)
        rip.add_force_vrf(None)
        dev1.add_feature(rip)
        dev2.add_feature(rip)

        # Configure rip
        rip.device_attr['dev1'].vrf_attr[None].address_family_attr['ipv4 unicast'].distance = 5

        output = rip.build_config(apply=False)
        self.assertMultiLineDictEqual(output,
{'dev1': 'feature rip\n'
         'router rip 5\n'
         ' address-family ipv4 unicast\n'
         '  distance 5\n'
         '  exit\n'
         ' exit',
'dev2': 'feature rip\n'
         'router rip 5\n'
         ' address-family ipv4 unicast\n'
         '  exit\n'
         ' exit'})

        output = rip.build_unconfig(
            attributes={
                'device_attr': {
                    'dev1': {
                        'vrf_attr': {
                            None: {
                                'address_family_attr': {
                                    'ipv4 unicast': None}}}}}},
            apply=False)
        self.assertMultiLineDictEqual(output,
{'dev1': 'router rip 5\n no address-family ipv4 unicast\n exit'})