def test_setup_expert(self):
        """
        This UnitTest executes the wca_setup_expert-function with the given config-file.
        It sets the values of all the  from WebInterface of the Router.
        """
        print("Test if the 'wca_setup_wizard'-function is working")
        router = self._create_router()
        # NVAssisten
        nv_assist = NVAssistent("eth0")
        nv_assist.create_namespace_vlan(router)
        # Set netns for the current process
        netns.setns(router.namespace_name)
        try:
            # Config
            config = ConfigManager.get_web_interface_list()[router.id]
            self.assertEqual(len(config), 30, "Wrong size of the Config-Directory")

            print("Set the following configuration: \n" + str(config))

            router_web_config = RouterWebConfiguration(router, config, wizard=True)
            router_web_config.start()
            router_web_config.join()
        except Exception as e:
            nv_assist.close()
            raise e

        assert router.mode == Mode.normal
        nv_assist.close()
コード例 #2
0
    def test_setup_expert(self):
        """
        This UnitTest executes the wca_setup_expert-function with the given config-file.
        It sets the values of all the  from WebInterface of the Router.
        """
        print("Test if the 'wca_setup_expert'-function is working")
        router = self._create_router()
        # NVAssisten
        nv_assist = NVAssistent("eth0")
        nv_assist.create_namespace_vlan(router)
        # Set netns for the current process
        netns.setns(router.namespace_name)

        # Config
        config = ConfigManager().get_web_interface_dict()[router.id]
        self.assertEqual(len(config), 30, "Wrong size of the Config-Directory")

        print("Set the following configuration: \n" + str(config))

        router_web_config = RouterWebConfiguration(router,
                                                   config,
                                                   wizard=False)
        router_web_config.start()
        router_web_config.join()

        assert router.mode == Mode.configuration
        nv_assist.close()
コード例 #3
0
    def test_create_namespace_vlan_veth(self):
        router = self._create_router()

        print("Test NVAssistent ...")
        for i in range(0, 2):
            print("Test" + str(i))
            nv_assi = NVAssistent("eth0")
            assert isinstance(nv_assi, NVAssistent)
            nv_assi.create_namespace_vlan(router)

            # Test if the Namespace now exists
            process = Popen(["ip", "netns"], stdout=PIPE, stderr=PIPE)
            stdout, sterr = process.communicate()
            assert sterr.decode('utf-8') == ""
            assert router.namespace_name in stdout.decode('utf-8')

            # Test if the VLAN now in Namespace exists
            process = Popen([
                "ip", "netns", "exec", router.namespace_name, "ip", "link",
                "show", "dev", router.vlan_iface_name
            ],
                            stdout=PIPE,
                            stderr=PIPE)
            stdout, sterr = process.communicate()
            assert sterr.decode('utf-8') == ""
            assert router.vlan_iface_name in stdout.decode('utf-8')

            nv_assi.close()
コード例 #4
0
    def test_flash_firmware(self):
        print("Test Router_Flash_Firmware")
        router = self._create_router()

        print("Download/Import firmware-image from UpdateServer/PI ...")
        # Download firmare-image from UpdateServer
        sysupdate = Sysupdate(router)
        sysupdate.start()
        sysupdate.join()

        # NVAssisten
        nv_assist = NVAssistent("eth0")
        nv_assist.create_namespace_vlan(router)
        # Set netns for the current process
        netns.setns(router.namespace_name)
        # The IP where the Router can download the firmware image (should be the frameworks IP)
        web_server_ip = nv_assist.get_ip_address(router.namespace_name,
                                                 router.vlan_iface_name)[0]

        try:
            # Copy firmware-image to the Router (/tmp/image)
            print("Copy firmware-image to Router ...")
            sysupgrade = Sysupgrade(router,
                                    n=True,
                                    web_server_ip=web_server_ip,
                                    debug=True)
            sysupgrade.start()
            sysupgrade.join()
        except Exception:
            raise
        finally:
            nv_assist.close()
コード例 #5
0
    def test_flash_firmware(self):
        print("Test Router_Flash_Firmware")
        router = self._create_router()

        print("Download/Import firmware-image from UpdateServer/PI ...")
        # Download firmare-image from UpdateServer
        sysupdate = Sysupdate(router)
        sysupdate.start()
        sysupdate.join()

        # NVAssisten
        nv_assist = NVAssistent("eth0")
        nv_assist.create_namespace_vlan(router)
        # Set netns for the current process
        netns.setns(router.namespace_name)
        # The IP where the Router can download the firmware image (should be the frameworks IP)
        web_server_ip = nv_assist.get_ip_address(router.namespace_name, router.vlan_iface_name)[0]

        try:
            # Copy firmware-image to the Router (/tmp/image)
            print("Copy firmware-image to Router ...")
            sysupgrade = Sysupgrade(router, n=True, web_server_ip=web_server_ip, debug=True)
            sysupgrade.start()
            sysupgrade.join()
        except Exception:
            raise
        finally:
            nv_assist.close()
コード例 #6
0
ファイル: test_M_ubnt.py プロジェクト: wj188888/TestFramework
    def _power_off(self, ps: Ubnt, q: Queue, port: int):
        nv_assist = NVAssistent("eth0")
        nv_assist.create_namespace_vlan(ps)
        netns.setns(ps.namespace_name)

        power_on = PowerStripControl(self.router, ps, False, port)
        power_on.start()
        power_on.join()

        nv_assist.close()
        q.put(ps)
コード例 #7
0
    def _reboot_into_normal(self, router: Router, q: Queue):
        print("Reboot Router back into normalmode ...")
        nv_assist = NVAssistent("eth0")
        nv_assist.create_namespace_vlan(router)
        # Set netns for the current process
        netns.setns(router.namespace_name)

        router_reboot = RouterReboot(router, configmode=False)
        router_reboot.start()
        router_reboot.join()
        assert router.mode == Mode.normal
        nv_assist.close()
        q.put(router)
コード例 #8
0
    def _reboot_into_normal(self, router: Router, q: Queue):
        print("Reboot Router back into normalmode ...")
        nv_assist = NVAssistent("eth0")
        nv_assist.create_namespace_vlan(router)
        # Set netns for the current process
        netns.setns(router.namespace_name)

        router_reboot = RouterReboot(router, configmode=False)
        router_reboot.start()
        router_reboot.join()
        assert router.mode == Mode.normal
        nv_assist.close()
        q.put(router)
コード例 #9
0
    def _reboot_into_config(self, router: Router, q: Queue):
        print("Reboot Router into configmode ...")
        # Create NVAssistent
        nv_assist = NVAssistent("eth0")
        nv_assist.create_namespace_vlan(router)
        # Set netns for the current process
        netns.setns(router.namespace_name)

        # Reboot Router into configmode
        router_reboot = RouterReboot(router, configmode=True)
        router_reboot.start()
        router_reboot.join()
        assert router.mode == Mode.configuration
        nv_assist.close()
        q.put(router)
コード例 #10
0
    def _reboot_into_config(self, router: Router, q: Queue):
        print("Reboot Router into configmode ...")
        # Create NVAssistent
        nv_assist = NVAssistent("eth0")
        nv_assist.create_namespace_vlan(router)
        # Set netns for the current process
        netns.setns(router.namespace_name)

        # Reboot Router into configmode
        router_reboot = RouterReboot(router, configmode=True)
        router_reboot.start()
        router_reboot.join()
        assert router.mode == Mode.configuration
        nv_assist.close()
        q.put(router)
コード例 #11
0
    def test_router_info(self):
        print("Test Router_Info")
        router = self._create_router()

        # NVAssisten
        nv_assist = NVAssistent("eth0")
        nv_assist.create_namespace_vlan(router)
        # Set netns for the current process
        netns.setns(router.namespace_name)

        print("Get informations via ssh-commands ...")
        router_info = RouterInfo(router)
        router_info.start()
        router_info.join()

        print(str(router))

        # Close Namespaces and VLANs
        nv_assist.close()
コード例 #12
0
    def test_router_info(self):
        print("Test Router_Info")
        router = self._create_router()

        # NVAssisten
        nv_assist = NVAssistent("eth0")
        nv_assist.create_namespace_vlan(router)
        # Set netns for the current process
        netns.setns(router.namespace_name)

        print("Get informations via ssh-commands ...")
        router_info = RouterInfo(router)
        router_info.start()
        router_info.join()

        print(str(router))

        # Close Namespaces and VLANs
        nv_assist.close()
コード例 #13
0
    def test_router_online(self):
        print("Test if the Router is reachable")
        router = self._create_router()
        # NVAssisten
        nv_assist = NVAssistent("eth0")
        nv_assist.create_namespace_vlan(router)
        # Set netns for the current process
        netns.setns(router.namespace_name)

        print("Send a Ping to the two static IP-addresses ...")
        router_online = RouterOnline(router)
        router_online.start()
        router_online.join()

        print("Router is online with IP " + router.ip + "/" +
              str(router.ip_mask))

        self.assertEqual(router.mode, Mode.configuration,
                         "The Configuration Mode is not correct")

        # Close Namespaces and VLANs
        nv_assist.close()
コード例 #14
0
    def test_create_namespace_vlan_veth(self):
        router = self._create_router()

        print("Test NVAssistent ...")
        for i in range(0, 2):
            print("Test" + str(i))
            nv_assi = NVAssistent("eth0")
            assert isinstance(nv_assi, NVAssistent)
            nv_assi.create_namespace_vlan(router)

            # Test if the Namespace now exists
            process = Popen(["ip", "netns"], stdout=PIPE, stderr=PIPE)
            stdout, sterr = process.communicate()
            assert sterr.decode('utf-8') == ""
            assert router.namespace_name in stdout.decode('utf-8')

            # Test if the VLAN now in Namespace exists
            process = Popen(["ip", "netns", "exec", router.namespace_name,
                             "ip", "link", "show", "dev", router.vlan_iface_name], stdout=PIPE, stderr=PIPE)
            stdout, sterr = process.communicate()
            assert sterr.decode('utf-8') == ""
            assert router.vlan_iface_name in stdout.decode('utf-8')

            nv_assi.close()