package
0.0.17
Repository: https://github.com/ales999/cisaccs.git
Documentation: pkg.go.dev

# README

netrasp

Netrasp is a package that communicates to network devices over SSH. It takes care of handling the pty terminal of network devices giving you an API with common actions such as executing commands and configuring devices.

Warning

Netrasp is in pre release mode so some parts of the API might change before the initial version is released.

Example

package main

import (
	"context"
	"fmt"
	"log"
	"time"

	"github.com/networklore/netrasp/pkg/netrasp"
)

func main() {
	device, err := netrasp.New("switch1",
		netrasp.WithUsernamePassword("my_user", "my_password123"),
		netrasp.WithDriver("ios"),
	)
	if err != nil {
		log.Fatalf("unable to create client: %v", err)
	}

	ctx, cancelOpen := context.WithTimeout(context.Background(), 2000*time.Millisecond)
	defer cancelOpen()
	err = device.Dial(ctx)
	if err != nil {
		fmt.Printf("unable to connect: %v\n", err)

		return
	}
	defer device.Close(context.Background())

	ctx, cancelRun := context.WithTimeout(context.Background(), 300*time.Millisecond)
	defer cancelRun()
	output, err := device.Run(ctx, "show running")
	if err != nil {
		fmt.Printf("unable to run command: %v\n", err)

		return
	}
	fmt.Println(output)
}

Network Device Support

The initial release of Netrasp comes with support for the following platforms:

  • Cisco IOS: netrasp.WithDriver("ios")
  • Cisco NXOS: netrasp.WithDriver("nxos")
  • Cisco ASA: netrasp.WithDriver("asa")
  • Nokia SR OS: netrasp.WithDriver("sros")

Use cases

You can use Netrasp as a package as in the example above of combine it with something like Gornir to get the same type of experience you'd have from using Netmiko and Nornir in the Python world.

Blog Posts

Credits

Netrasp was created by Patrick Ogenstad. Special thanks to David Barroso for providing feedback and recommendations of the structure and code.

# Functions

New creates a new SSH connection to the device.
WithDialTimeout allows you to configure timeout for dialing SSH server.
WithDriver tells Netrasp which network driver to use for the connection for example "asa", "ios", "nxos".
WithInsecureIgnoreHostKey allows you to ignore the validation of the public SSH key of a device against a reference in a known_hosts file.
WithSSHCipher allows you to configure additional SSH Ciphers that the connection will use.
WithSSHKeyExchange allows you to configure additional SSH key exchange algorithms.
WithSSHPort allows you to specify an alternate SSH port, defaults to 22.
No description provided by the author
No description provided by the author

# Structs

ConfigCommand contains a configuration command together with the output from that command.
ConfigResult is returned by a Configure operation and contains output and results.

# Interfaces

ConfigOpt configures a Netrasp connection and platform.
Platform defines an interface for network drivers.