def _board_table(cli_service):
        """Get board table.

        :rtype: dict
        """
        board_table = {}
        output = CommandTemplateExecutor(
            cli_service, command_template.SHOW_BOARD).execute_command()
        serial_search = re.search(r"BOARD\s+.*S/N\((.+?)\)", output, re.DOTALL)
        if serial_search:
            board_table["serial_number"] = serial_search.group(1)

        model_search = re.search(r"^rome\s+type\s+(.+?)\s*$",
                                 output,
                                 flags=re.MULTILINE | re.IGNORECASE)
        if model_search:
            board_table["model_name"] = model_search.group(1)
        else:
            board_table["model_name"] = "Rome"

        sw_version_search = re.search(
            r"ACTIVE\s+SW\s+VER\s+(\d+\.\d+\.\d+\.\d+)", output, re.DOTALL)
        if sw_version_search:
            board_table["sw_version"] = sw_version_search.group(1)

        return board_table
    def ports_in_pending_connections(self, cli_service, ports):
        """Check ports in process or pending.

        Command in process:
        connect, ports: A3-A4, status: in process with payload

        ======= ========= ========= ================== ======= ===================
        Request Port1     Port2     Command            Source  User
        ======= ========= ========= ================== ======= ===================
        772     A1        A2        connect            CLI     admin
        """
        self.check_full_output(cli_service)

        output = CommandTemplateExecutor(
            cli_service,
            command_template.CONNECTION_SHOW_PENDING,
            action_map=self.CONNECTION_PENDING_RESET_MAP,
        ).execute_command()

        self.check_full_output(cli_service)

        for src, dst in ports:
            match = re.search(r"ports:\s+{}-{}\D".format(src, dst), output,
                              re.I)
            match = match or re.search(r"\w+\s+{}\s+{}\s+\w+".format(src, dst),
                                       output, re.I)
            if match:
                return True

        return False
    def _connect(self, cli_service, src_port_name, dst_port_name):
        """Connect ports by name.

        :type cli_service: cloudshell.cli.cli_service_impl.CliServiceImpl
        :type src_port_name: str
        :type dst_port_name: str
        :return: output
        :rtype: str
        """
        return CommandTemplateExecutor(
            cli_service,
            command_template.CONNECT,
            action_map=self.CONNECTION_PENDING_RESET_MAP,
        ).execute_command(src_port=src_port_name, dst_port=dst_port_name)
 def _get_port_table(cli_service):
     port_table_output = CommandTemplateExecutor(
         cli_service, command_template.PORT_SHOW).execute_command()
     return PortTable.from_output(port_table_output,
                                  cli_service.session.host)