Skip to content

networklore/netrasp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages