Beispiel #1
0
    def test_ensure_interface_not_exist(self):
        """Verify ensure_interface function when the interface do not exist."""
        nbk = NetboxKeeper(self.ndk2)
        nbk.device_type = self.device_type1
        nbk.netdev.ot = self.onboarding_task3

        nbk.ensure_device_instance()

        nbk.ensure_interface()
        self.assertIsInstance(nbk.interface, Interface)
        self.assertEqual(nbk.interface.name, "ge-0/0/0")
Beispiel #2
0
    def test_ensure_primary_ip_not_exist(self):
        """Verify ensure_primary_ip function when the Ip address do not already exist."""
        nbk = NetboxKeeper(self.ndk2)
        nbk.device_type = self.device_type1
        nbk.netdev.ot = self.onboarding_task3

        nbk.ensure_device_instance()
        nbk.ensure_interface()
        nbk.ensure_primary_ip()
        self.assertIsInstance(nbk.primary_ip, IPAddress)
        self.assertEqual(nbk.primary_ip.interface, nbk.interface)
Beispiel #3
0
    def test_ensure_interface_exist(self):
        """Verify ensure_interface function when the interface already exist."""
        nbk = NetboxKeeper(self.ndk2)
        nbk.device_type = self.device_type1
        nbk.netdev.ot = self.onboarding_task3

        nbk.ensure_device_instance()
        intf = Interface.objects.create(name=nbk.netdev.mgmt_ifname, device=nbk.device)

        nbk.ensure_interface()
        self.assertEqual(nbk.interface, intf)