Skip to content

get_prompt

nornir_scrapli.tasks.get_prompt

get_prompt(task: Task) -> Result

Get current prompt from device using scrapli

Parameters:

Name Type Description Default
task Task

nornir task object

required

Returns:

Name Type Description
Result Result

nornir result object with Result.result value set to current prompt

Source code in tasks/core/get_prompt.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
def get_prompt(task: Task) -> Result:
    """
    Get current prompt from device using scrapli

    Args:
        task: nornir task object

    Returns:
        Result: nornir result object with Result.result value set to current prompt

    Raises:
        N/A

    """
    scrapli_conn = task.host.get_connection("scrapli", task.nornir.config)
    prompt = scrapli_conn.get_prompt()
    return Result(host=task.host, result=prompt, failed=False, changed=False)