Exemple #1
0
    def __init__(self, name: str, is_controller: bool = False):
        self.name = name
        self.bridge_name = 'br-lan'

        # First, get the UCC port from the config file
        if is_controller:
            config_file_name = 'beerocks_controller.conf'
        else:
            config_file_name = 'beerocks_agent.conf'
        with open(os.path.join(installdir, 'config', config_file_name)) as config_file:
            ucc_port = \
                re.search(r'ucc_listener_port=(?P<port>[0-9]+)', config_file.read()).group('port')

        # On WSL, connect to the locally exposed container port
        if on_wsl:
            published_port_output = subprocess.check_output(
                ["docker", "port", name, ucc_port]).decode('utf-8').split(":")
            device_ip = published_port_output[0]
            ucc_port = int(published_port_output[1])
        else:
            device_ip_output = self.command(
                'ip', '-f', 'inet', 'addr', 'show', self.bridge_name)
            device_ip = re.search(
                r'inet (?P<ip>[0-9.]+)', device_ip_output.decode('utf-8')).group('ip')

        ucc_socket = UCCSocket(device_ip, ucc_port)
        mac = ucc_socket.dev_get_parameter('ALid')

        super().__init__(mac, ucc_socket, installdir, is_controller)

        # We always have two radios, wlan0 and wlan2
        RadioDocker(self, "wlan0")
        RadioDocker(self, "wlan2")
Exemple #2
0
    def __init__(self, device: None, is_controller: bool = False):
        self.device = device
        self.name = device.name

        if is_controller:
            self.config_file_name = '/opt/prplmesh/config/beerocks_controller.conf'
        else:
            self.config_file_name = '/opt/prplmesh/config/beerocks_agent.conf'

        ucc_port_raw = self.command("grep \"ucc_listener_port\" {}".format(
            self.config_file_name))
        ucc_port = int(
            re.search(r'ucc_listener_port=(?P<port>[0-9]+)',
                      ucc_port_raw).group('port'))
        bridge_name_raw = self.command("grep \"bridge_iface\" {}".format(
            self.config_file_name))
        self.bridge_name = re.search(r'bridge_iface=(?P<bridge>.+)\r\n',
                                     bridge_name_raw).group('bridge')
        log_folder_raw = self.command("grep log_files_path {}".format(
            self.config_file_name))
        self.log_folder = re.search(
            r'log_files_path=(?P<log_path>[a-zA-Z0-9_\/]+)',
            log_folder_raw).group('log_path')
        ucc_socket = UCCSocket(str(self.device.wan_ip), int(ucc_port))
        mac = ucc_socket.dev_get_parameter('ALid')

        super().__init__(mac, ucc_socket, installdir, is_controller)

        # We always have two radios, wlan0 and wlan2
        RadioHostapd(self, "wlan0")
        RadioHostapd(self, "wlan2")
Exemple #3
0
    def open_CAPI_socket(self, device: str, controller: bool = False) -> UCCSocket:
        '''Open a CAPI socket to the agent (or controller, if set) on "device".'''
        # First, get the UCC port from the config file
        if controller:
            config_file_name = 'beerocks_controller.conf'
        else:
            config_file_name = 'beerocks_agent.conf'
        with open(os.path.join(self.installdir, 'config', config_file_name)) as config_file:
            ucc_port = re.search(r'ucc_listener_port=(?P<port>[0-9]+)', config_file.read()).group('port')

        device_ip_output = self.docker_command(device, 'ip', '-f', 'inet', 'addr', 'show', self.bridge_name)
        device_ip = re.search(r'inet (?P<ip>[0-9.]+)', device_ip_output.decode('utf-8')).group('ip')
        return UCCSocket(device_ip, ucc_port)