Exemple #1
0
    def test_ensure_device_instance_not_exist(self):
        """Verify ensure_device_instance function."""
        nbk = NetboxKeeper(self.ndk2)
        nbk.device_type = self.device_type1
        nbk.netdev.ot = self.onboarding_task3

        nbk.ensure_device_instance()
        self.assertIsInstance(nbk.device, Device)
        self.assertEqual(nbk.device, nbk.netdev.ot.created_device)
        self.assertEqual(nbk.device.serial, "123456")
Exemple #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)
Exemple #3
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")
Exemple #4
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)
    def test_ensure_device_instance_exist(self):
        """Verify ensure_device_instance function."""
        device = Device.objects.create(
            name=self.ndk2.hostname,
            site=self.site1,
            device_type=self.device_type1,
            device_role=self.device_role1,
            status="planned",
            serial="987654",
        )

        nbk = NetboxKeeper(self.ndk2)
        nbk.netdev.ot = self.onboarding_task3
        self.assertEqual(nbk.device, None)
        nbk.ensure_device_instance(default_status="active")
        self.assertIsInstance(nbk.device, Device)
        self.assertEqual(nbk.device.status, "planned")
        self.assertEqual(nbk.device.platform, self.platform1)
        self.assertEqual(nbk.device, device)
        self.assertEqual(nbk.device.serial, "123456")