def create_new_connection(options, &block)
      if defined?(@connection)
        logger.debug("[SSH] shutting previous connection #{@connection}")
        @connection.close
      end

      @connection_options = options
      conn = Connection.new(options, &block)

      # Cisco IOS requires a special implementation of `Net:SSH`. This uses the
      # SSH transport to identify the platform, but then replaces SSHConnection
      # with a CiscoIOSConnection in order to behave as expected for the user.
      if defined?(conn.platform.cisco_ios?) && conn.platform.cisco_ios?
        ios_options = {}
        ios_options[:host] = @options[:host]
        ios_options[:user] = @options[:user]
        # The enable password is used to elevate privileges on Cisco devices
        # We will also support the sudo password field for the same purpose
        # for the interim. # TODO
        ios_options[:enable_password] = @options[:enable_password] || @options[:sudo_password]
        ios_options[:logger] = @options[:logger]
        ios_options.merge!(@connection_options)
        conn = CiscoIOSConnection.new(ios_options)
      end

      @connection = conn unless conn.nil?
    end
def create_new_connection(options, &block)
      if defined?(@connection)
        logger.debug("[SSH] shutting previous connection #{@connection}")
        @connection.close
      end

      @connection_options = options
      conn = Connection.new(options, &block)

      # Cisco IOS requires a special implementation of `Net:SSH`. This uses the
      # SSH transport to identify the platform, but then replaces SSHConnection
      # with a CiscoIOSConnection in order to behave as expected for the user.
      if defined?(conn.platform.cisco_ios?) && conn.platform.cisco_ios?
        ios_options = {}
        ios_options[:host] = @options[:host]
        ios_options[:user] = @options[:user]
        # The enable password is used to elevate privileges on Cisco devices
        # We will also support the sudo password field for the same purpose
        # for the interim. # TODO
        ios_options[:enable_password] = @options[:enable_password] || @options[:sudo_password]
        ios_options[:logger] = @options[:logger]
        ios_options.merge!(@connection_options)
        conn = CiscoIOSConnection.new(ios_options)
      end

      @connection = conn unless conn.nil?
    end
Creates a new SSH Connection instance and save it for potential future
 reuse.

 @param options [Hash] conneciton options
 @return [Ssh::Connection] an SSH Connection instance
 @api private