Archived documentation version rendered and hosted by DevNetExpertTraining.com
Skip to content

Module scrapli_netconf.transport.plugins.ssh2.transport

scrapli_netconf.transport.plugins.ssh2.transport

Expand source code
        
"""scrapli_netconf.transport.plugins.ssh2.transport"""
from scrapli.exceptions import ScrapliConnectionNotOpened
from scrapli.transport.plugins.ssh2.transport import PluginTransportArgs, Ssh2Transport

# imported from base driver
_ = PluginTransportArgs


class NetconfSsh2Transport(Ssh2Transport):
    def open_netconf(self) -> bytes:
        """
        Netconf open method

        Simply calls the "normal" open method, but retaining an explicit "netconf" open for sanity

        Args:
            N/A

        Returns:
            None

        Raises:
            N/A

        """
        super().open()

        return b""

    def _open_channel(self) -> None:
        """
        Overriding the base open_channel to invoke netconf subsystem

        Args:
            N/A

        Returns:
            None

        Raises:
            ScrapliConnectionNotOpened: if session is unopened/None

        """
        if not self.session:
            raise ScrapliConnectionNotOpened

        self.session_channel = self.session.open_session()
        # unlike "normal" ssh2 -- we do *not* need to enable the "shell" on the channel...
        # we *do* still want it to be a pty though!
        self.session_channel.pty()
        self.session_channel.subsystem("netconf")
        
    

Classes

NetconfSsh2Transport

1
2
Helper class that provides a standard way to create an ABC using
inheritance.
Expand source code
        
class NetconfSsh2Transport(Ssh2Transport):
    def open_netconf(self) -> bytes:
        """
        Netconf open method

        Simply calls the "normal" open method, but retaining an explicit "netconf" open for sanity

        Args:
            N/A

        Returns:
            None

        Raises:
            N/A

        """
        super().open()

        return b""

    def _open_channel(self) -> None:
        """
        Overriding the base open_channel to invoke netconf subsystem

        Args:
            N/A

        Returns:
            None

        Raises:
            ScrapliConnectionNotOpened: if session is unopened/None

        """
        if not self.session:
            raise ScrapliConnectionNotOpened

        self.session_channel = self.session.open_session()
        # unlike "normal" ssh2 -- we do *not* need to enable the "shell" on the channel...
        # we *do* still want it to be a pty though!
        self.session_channel.pty()
        self.session_channel.subsystem("netconf")
        
    

Ancestors (in MRO)

  • scrapli.transport.plugins.ssh2.transport.Ssh2Transport
  • scrapli.transport.base.sync_transport.Transport
  • scrapli.transport.base.base_transport.BaseTransport
  • abc.ABC

Methods

open_netconf

open_netconf(self) ‑> bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
Netconf open method

Simply calls the "normal" open method, but retaining an explicit "netconf" open for sanity

Args:
    N/A

Returns:
    None

Raises:
    N/A