Skip to content

async_driver

scrapli_community.scrapli.networkdriver.ansync_driver

AsyncScrapliNetworkDriverWithMethods

Bases: AsyncNetworkDriver

Source code in scrapli/networkdriver/async_driver.py
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
class AsyncScrapliNetworkDriverWithMethods(AsyncNetworkDriver):
    def __init__(self, *args: Any, **kwargs: Any) -> None:
        """
        Example scrapli community platform class

        Args:
            args: positional args
            kwargs: keyword args

        Returns:
            N/A

        Raises:
            N/A

        """
        super().__init__(*args, **kwargs)

    async def example_method(self) -> None:
        """
        Example scrapli community method

        Args:
            N/A

        Returns:
            N/A

        Raises:
            N/A

        """
        self.channel.send_return()
        result = await self.channel.read()
        print(result)

__init__(*args: Any, **kwargs: Any) -> None

Example scrapli community platform class

Parameters:

Name Type Description Default
args

positional args

required
kwargs

keyword args

required

Returns:

Type Description
None

N/A

Source code in scrapli/networkdriver/async_driver.py
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
def __init__(self, *args: Any, **kwargs: Any) -> None:
    """
    Example scrapli community platform class

    Args:
        args: positional args
        kwargs: keyword args

    Returns:
        N/A

    Raises:
        N/A

    """
    super().__init__(*args, **kwargs)

example_method() -> None async

Example scrapli community method

Returns:

Type Description
None

N/A

Source code in scrapli/networkdriver/async_driver.py
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
async def example_method(self) -> None:
    """
    Example scrapli community method

    Args:
        N/A

    Returns:
        N/A

    Raises:
        N/A

    """
    self.channel.send_return()
    result = await self.channel.read()
    print(result)

default_async_on_close(conn: AsyncNetworkDriver) -> None async

Async scrapli_example default on_close callable

Parameters:

Name Type Description Default
conn AsyncNetworkDriver

AsyncNetworkDriver object

required

Returns:

Type Description
None

N/A

Source code in scrapli/networkdriver/async_driver.py
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
async def default_async_on_close(conn: AsyncNetworkDriver) -> None:
    """
    Async scrapli_example default on_close callable

    Args:
        conn: AsyncNetworkDriver object

    Returns:
        N/A

    Raises:
        N/A
    """
    # write exit directly to the transport as channel would fail to find the prompt after sending
    # the exit command!
    await conn.acquire_priv(desired_priv=conn.default_desired_privilege_level)
    conn.channel.write(channel_input="exit")
    conn.channel.send_return()

default_async_on_open(conn: AsyncNetworkDriver) -> None async

Async scrapli_example default on_open callable

Parameters:

Name Type Description Default
conn AsyncNetworkDriver

AsyncNetworkDriver object

required

Returns:

Type Description
None

N/A

Source code in scrapli/networkdriver/async_driver.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
async def default_async_on_open(conn: AsyncNetworkDriver) -> None:
    """
    Async scrapli_example default on_open callable

    Args:
        conn: AsyncNetworkDriver object

    Returns:
        N/A

    Raises:
        N/A
    """
    await conn.acquire_priv(desired_priv=conn.default_desired_privilege_level)
    await conn.send_command(command="terminal length 0")
    await conn.send_command(command="terminal width 512")