Beispiel #1
0
    def build(self):
        self.sta_powersave_disabled_profile.use_security("open",
                                                         ssid=self.ssid,
                                                         passwd=self.password)
        self.sta_powersave_disabled_profile.set_command_flag(
            "add_sta", "create_admin_down", 1)
        self.sta_powersave_disabled_profile.set_command_param(
            "set_port", "report_timer", 5000)
        self.sta_powersave_disabled_profile.set_command_flag(
            "set_port", "rpt_timer", 1)

        self.sta_powersave_enabled_profile.use_security("open",
                                                        ssid=self.ssid,
                                                        passwd=self.password)
        self.sta_powersave_enabled_profile.set_command_flag(
            "add_sta", "create_admin_down", 1)
        self.sta_powersave_enabled_profile.set_command_param(
            "set_port", "report_timer", 5000)
        self.sta_powersave_enabled_profile.set_command_flag(
            "set_port", "rpt_timer", 1)
        self.sta_powersave_enabled_profile.set_command_flag(
            "add_sta", "power_save_enable", 1)

        self.wifi_monitor_profile.create(resource_=self.resource,
                                         channel=self.channel,
                                         radio_=self.monitor_radio,
                                         name_=self.monitor_name)

        LFUtils.wait_until_ports_appear(base_url=self.local_realm.lfclient_url,
                                        port_list=[self.monitor_name])
        time.sleep(0.2)
        mon_j = self.json_get("/port/1/%s/%s" %
                              (self.resource, self.monitor_name))
        if ("interface" not in mon_j):
            raise ValueError("No monitor found")

        self.sta_powersave_disabled_profile.create(
            radio=self.normal_sta_radio,
            sta_names_=self.normal_sta_list,
            debug=self.debug,
            suppress_related_commands_=True)

        self.sta_powersave_enabled_profile.create(
            radio=self.powersave_sta_radio,
            sta_names_=self.powersave_sta_list,
            debug=self.debug,
            suppress_related_commands_=True)
        temp_sta_map = {}
        for name in self.powersave_sta_list + self.normal_sta_list:
            temp_sta_map[name] = 1
        print("Stations we want:")
        pprint.pprint(temp_sta_map)
        if len(temp_sta_map) < 1:
            self._fail("Misconfigured build(), bye", print_=True)
            exit(1)
        self.local_realm.wait_until_ports_appear(temp_sta_map.keys())

        if len(temp_sta_map) == (
                len(self.sta_powersave_disabled_profile.station_names) +
                len(self.sta_powersave_enabled_profile.station_names)):
            self._pass("Stations created", print_=True)
        else:
            print("Stations we see created:")
            pprint.pprint(temp_sta_map)
            self._fail("Not all stations created", print_=True)

        bg_side_a_eids = []
        for port in self.normal_sta_list:
            bg_side_a_eids.append("%s.%s" % (self.resource, port))

        ul_side_a_eids = []
        for port in self.normal_sta_list:
            ul_side_a_eids.append("%s.%s" % (self.resource, port))

        dl_side_a_eids = []
        for port in self.normal_sta_list:
            dl_side_a_eids.append("%s.%s" % (self.resource, port))

        print("Creating background cx profile ")
        self.cx_prof_bg.name_prefix = "udp_bg"
        self.cx_prof_bg.create(endp_type="lf_udp",
                               side_a=bg_side_a_eids,
                               side_b="1.eth1")

        print("Creating upload cx profile ")
        self.cx_prof_upload.name_prefix = "udp_up"
        self.cx_prof_upload.create(endp_type="lf_udp",
                                   side_a=ul_side_a_eids,
                                   side_b="1.eth1")

        print("Creating download cx profile")
        self.cx_prof_download.name_prefix = "udp_down"
        self.cx_prof_download.create(endp_type="lf_udp",
                                     side_a=ul_side_a_eids,
                                     side_b="1.eth1")

        print("Collecting lanforge eth0 IP...")
        eth0_resp = self.json_get("/port/1/%s/eth0?fields=port,alias,ip" %
                                  self.resource,
                                  debug_=self.debug)
        # would be nice to have a not_found() kind of method
        if (eth0_resp is None) or ("items" in eth0_resp) or (
                "empty" in eth0_resp) or ("interface" not in eth0_resp):
            self._fail("Unable to query %s.eth0" % self.resource, print_=True)
            exit(1)
        self.eth0_ip = eth0_resp["interface"]["ip"]
        if self.eth0_ip == "0.0.0.0":
            self._fail("eth0 is misconfigured or not our management port",
                       print_=True)
            exit(1)

        self.sta_mac_map = {}
    def setup(self):
        self.clear_test_results()
        self.check_connect()
        upstream_json = self.json_get("%s?fields=alias,phantom,down,port,ip" %
                                      self.get_upstream_url(),
                                      debug_=False)

        if upstream_json is None:
            self._fail(message="Unable to query %s, bye" % self.upstream_port,
                       print_=True)
            return False

        if upstream_json['interface']['ip'] == "0.0.0.0":
            if self.debug:
                pprint.pprint(upstream_json)
            self._fail("Warning: %s lacks ip address" %
                       self.get_upstream_url(),
                       print_=True)
            return False

        # remove old stations
        print("Removing old stations")
        for sta_name in self.station_names:
            sta_url = self.get_station_url(sta_name)
            response = self.json_get(sta_url)
            if (response is not None) and (response["interface"] is not None):
                for sta_name in self.station_names:
                    LFUtils.removePort(self.resource, sta_name,
                                       self.lfclient_url)
        LFUtils.wait_until_ports_disappear(self.lfclient_url,
                                           self.station_names)

        # Create stations and turn dhcp on
        self.station_profile = self.localrealm.new_station_profile()

        if self.dut_security == WPA2:
            self.station_profile.use_security(security_type="wpa2",
                                              ssid=self.dut_ssid,
                                              passwd=self.dut_passwd)
        elif self.dut_security == WPA:
            self.station_profile.use_security(security_type="wpa",
                                              ssid=self.dut_ssid,
                                              passwd=self.dut_passwd)
        elif self.dut_security == OPEN:
            self.station_profile.use_security(security_type="open",
                                              ssid=self.dut_ssid,
                                              passwd="[BLANK]")
        elif self.dut_security == WPA:
            self.station_profile.use_security(security_type="wpa",
                                              ssid=self.dut_ssid,
                                              passwd=self.dut_passwd)
        elif self.dut_security == WEP:
            self.station_profile.use_security(security_type="wep",
                                              ssid=self.dut_ssid,
                                              passwd=self.dut_passwd)
        self.station_profile.set_command_flag("add_sta", "create_admin_down",
                                              1)

        print("Adding new stations ", end="")
        self.station_profile.create(radio=self.radio,
                                    sta_names_=self.station_names,
                                    up_=False,
                                    debug=self.debug,
                                    suppress_related_commands_=True)
        LFUtils.wait_until_ports_appear(self.lfclient_url,
                                        self.station_names,
                                        debug=self.debug)
Beispiel #3
0
    def setup(self):
        self.clear_test_results()
        self.check_connect()
        upstream_json = self.json_get("%s?fields=alias,phantom,down,port,ip" %
                                      self.get_upstream_url(),
                                      debug_=False)

        if upstream_json is None:
            self._fail(message="Unable to query %s, bye" % self.upstream_port,
                       print_=True)
            return False

        if upstream_json['interface']['ip'] == "0.0.0.0":
            if self.debug:
                pprint.pprint(upstream_json)
            self._fail("Warning: %s lacks ip address" %
                       self.get_upstream_url(),
                       print_=True)
            return False

        # remove old stations
        if self.clean_all_sta:
            print("Removing all stations on resource.")
            self.localrealm.remove_all_stations(self.resource)
        else:
            print("Removing old stations to be created by this test.")
            for sta_name in self.station_names:
                sta_url = self.get_station_url(sta_name)
                response = self.json_get(sta_url)
                if (response is not None) and (response["interface"]
                                               is not None):
                    for sta_name in self.station_names:
                        LFUtils.removePort(self.resource, sta_name,
                                           self.lfclient_url)
            LFUtils.wait_until_ports_disappear(self.lfclient_url,
                                               self.station_names)

        # Create stations and turn dhcp on
        self.station_profile = self.localrealm.new_station_profile()

        if self.dut_security == WPA2:
            self.station_profile.use_security(security_type="wpa2",
                                              ssid=self.dut_ssid,
                                              passwd=self.dut_passwd)
        elif self.dut_security == OPEN:
            self.station_profile.use_security(security_type="open",
                                              ssid=self.dut_ssid,
                                              passwd="[BLANK]")
        elif self.dut_security == WPA:
            self.station_profile.use_security(security_type="wpa",
                                              ssid=self.dut_ssid,
                                              passwd=self.dut_passwd)
        elif self.dut_security == WEP:
            self.station_profile.use_security(security_type="wep",
                                              ssid=self.dut_ssid,
                                              passwd=self.dut_passwd)
        self.station_profile.set_command_flag("add_sta", "create_admin_down",
                                              1)

        print("Adding new stations ", end="")
        self.station_profile.create(radio=self.radio,
                                    sta_names_=self.station_names,
                                    up_=False,
                                    debug=self.debug,
                                    suppress_related_commands_=True)
        LFUtils.wait_until_ports_appear(self.lfclient_url,
                                        self.station_names,
                                        debug=self.debug)

        # Create UDP endpoints
        self.l3_udp_profile = self.localrealm.new_l3_cx_profile()
        self.l3_udp_profile.side_a_min_bps = 128000
        self.l3_udp_profile.side_b_min_bps = 128000
        self.l3_udp_profile.side_a_min_pdu = 1200
        self.l3_udp_profile.side_b_min_pdu = 1500
        self.l3_udp_profile.report_timer = 1000
        self.l3_udp_profile.name_prefix = "udp"
        port_list = list(
            self.localrealm.find_ports_like("%s+" % self.sta_prefix))
        if (port_list is None) or (len(port_list) < 1):
            raise ValueError("Unable to find ports named '%s'+" %
                             self.sta_prefix)
        self.l3_udp_profile.create(endp_type="lf_udp",
                                   side_a=port_list,
                                   side_b="%d.%s" %
                                   (self.resource, self.upstream_port),
                                   suppress_related_commands=True)

        # Create TCP endpoints
        self.l3_tcp_profile = self.localrealm.new_l3_cx_profile()
        self.l3_tcp_profile.side_a_min_bps = 128000
        self.l3_tcp_profile.side_b_min_bps = 56000
        self.l3_tcp_profile.name_prefix = "tcp"
        self.l3_tcp_profile.report_timer = 1000
        self.l3_tcp_profile.create(
            endp_type="lf_tcp",
            side_a=list(
                self.localrealm.find_ports_like("%s+" % self.sta_prefix)),
            side_b="%d.%s" % (self.resource, self.upstream_port),
            suppress_related_commands=True)