Skip to content

Nornir, Netbox and connection variables #818

Answered by ohai89
ohai89 asked this question in Q&A
Discussion options

You must be logged in to vote

It seems that by manually setting the task.host.open_connection() I can pass in arbitrary variables for the connection:

def open_connection(
        self,
        connection: str,
        configuration: Config,
        hostname: Optional[str] = None,
        username: Optional[str] = None,
        password: Optional[str] = None,
        port: Optional[int] = None,
        platform: Optional[str] = None,
        extras: Optional[Dict[str, Any]] = None,
        default_to_host_attributes: bool = True,
    ) -> ConnectionPlugin:

So I came up with:

def nornir_task(task: Task) -> Result:
    task.host.open_connection(
        connection="netmiko", configuration=task.nornir.config, port=args.p…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by ohai89
Comment options

You must be logged in to vote
2 replies
@ohai89
Comment options

@dbarrosop
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants