netrasp

package module
v0.0.0-...-2a6631e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2021 License: Apache-2.0 Imports: 0 Imported by: 0

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.

Documentation

Overview

Netrasp documentation

Directories

Path Synopsis
pkg
netrasp
Package netrasp provides an easy way to communicate with network devices Using an SSH connection it lets you send commands and configure devices that only supports screen scraping.
Package netrasp provides an easy way to communicate with network devices Using an SSH connection it lets you send commands and configure devices that only supports screen scraping.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL