network

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package Yeoman provides a basic set of interfaces that you would normally find in elements such as routers and switches.

Index

Constants

View Source
const (
	DeviceCiscoIOS   = 1
	DeviceCiscoIOSXR = 2
	DeviceCiscoNexus = 3
	DeviceJunos      = 4
)
View Source
const (
	VendorCisco   = "Cisco"
	VendorJuniper = "Juniper"
)

Variables

This section is empty.

Functions

func ExpandVlansIntSlice

func ExpandVlansIntSlice(vlans string) ([]int, error)

ExpandVlansIntSlice will take a string of vlans and return an int slice with the respective vlan ids

func GetUniqueIntSlice

func GetUniqueIntSlice(intSlice []int) []int

GetUniqueIntSlice returns a unique slice of integers from the given input

func InterfaceInSlice

func InterfaceInSlice(interfaces []*Interface, interf *Interface) bool

InterfaceInSlice returns true or false whether an interface is within a given slice or not

func VlanInSlice

func VlanInSlice(vlan *Vlan, vlans []*Vlan) bool

VlanInSlice returns true or false if given vlan is in a slice

Types

type Element

type Element struct {
	DefaultMtu            int          `json:"default_mtu"`
	ManagementIP          IP           `json:"management_ip"`
	Vendor                string       `json:"Vendor"`
	OS                    string       `json:"OS"`
	Hostname              string       `json:"hostname"`
	VlanIds               string       `json:"vlan_ids"`
	Vlans                 []*Vlan      `json:"vlans"`
	Interfaces            []*Interface `json:"interfaces"`
	DeviceType            int          `json:"device_type"`
	MtuHasEthernetHeaders bool         `json:"mtu_has_ethernet_headers"`
}

Element struct for network elements

func (*Element) AddVlan

func (e *Element) AddVlan(v *Vlan)

AddVlan adds a vlan

func (*Element) BuildVlanIds

func (e *Element) BuildVlanIds()

func (*Element) CountInterfaces

func (e *Element) CountInterfaces() int

CountInterfaces returns the total number of networkInterfaces.

func (*Element) CreateVlan

func (e *Element) CreateVlan(vlanId int) *Vlan

AddVlan adds a vlan

func (*Element) DoesVlanExist

func (e *Element) DoesVlanExist(id int) bool

DoesVlanExist returns true or false whether a vlan exists in the vlan database or not

func (*Element) GetInterface

func (e *Element) GetInterface(name string) *Interface

GetInterface finds an interface by given name and returns it

func (*Element) GetVlan

func (e *Element) GetVlan(vlanId int) *Vlan

GetVlan finds a vlan by given vlanid and returns it

type IP

type IP struct {
	CIDR      string `json:"cidr"`
	IPAddress string `json:"ip_address"`
	IPNetwork string `json:"ip_network"`
	IsPrimary bool   `json:"is_primary"`
	IsIpv6    bool   `json:"is_ipv6"`
}

IP

type Interface

type Interface struct {
	Name                   string `json:"name"`
	Description            string `json:"description"`
	VRF                    string `json:"vrf"`
	SubInterface           bool   `json:"sub_interface"`
	Layer2                 bool   `json:"layer_2"`
	AccessPort             bool   `json:"access_port"`
	TrunkPort              bool   `json:"trunk_port"`
	VirtualInterface       bool   `json:"virtual_interface"`
	AllowedTrunkedVlans    []int  `json:"allowed_trunked_vlans"`
	Mtu                    int    `json:"mtu"`
	Vlan                   *Vlan  `json:"vlan"`
	IPv4Addresses          []IP   `json:"ipv4_addresses"`
	IPv6Addresses          []IP   `json:"ipv6_addresses"`
	PossiblyNoVlanDatabase bool   `json:"possibly_no_vlan_database"`
}

Interface struct for network networkInterfaces

func (*Interface) AddAllowedVlans

func (i *Interface) AddAllowedVlans(vlans []string)

AddAllowedVlans adds vlans to a trunk interface todo: need to check to see if any of these do NOT already exist & warn against for future potential cleanup.

func (*Interface) AllowsVlan

func (i *Interface) AllowsVlan(vlanId int) bool

func (*Interface) GetPrimaryV6AddressFirst

func (i *Interface) GetPrimaryV6AddressFirst() *IP

func (*Interface) IsLoopback

func (i *Interface) IsLoopback() bool

IsLoopback attempts to detect wether an interface is a loopback or not

func (*Interface) IsVirtual

func (i *Interface) IsVirtual() bool

IsVirtual returns true if interface is virtual

func (*Interface) TotalIPv4s

func (i *Interface) TotalIPv4s() int

TotalIps returns total number of IPv4 addresses.

func (*Interface) TotalIPv6s

func (i *Interface) TotalIPv6s() int

TotalIps returns total number of IPv6 addresses.

func (*Interface) TotalIps

func (i *Interface) TotalIps() int

TotalIps returns total number of IPv4 + IPv6 addresses.

type Vlan

type Vlan struct {
	Id                int          `json:"id"`
	Name              string       `json:"name"`
	AccessInterfaces  []*Interface `json:"access_interfaces"`
	TrunkInterfaces   []*Interface `json:"trunk_interfaces"`
	VirtualInterfaces []*Interface `json:"virtual_interfaces"`
}

Vlan a plain old broadcast domain

func AddVlanToSlice

func AddVlanToSlice(vlan *Vlan, vlans []*Vlan) []*Vlan

AddVlanToSlice

func NewVlan

func NewVlan(id int) *Vlan

func (*Vlan) AddAccessInterfaces

func (n *Vlan) AddAccessInterfaces(i *Interface)

func (*Vlan) AddTrunkInterface

func (n *Vlan) AddTrunkInterface(i *Interface)

func (*Vlan) AddVirtualInterfaces

func (n *Vlan) AddVirtualInterfaces(i *Interface)

Jump to

Keyboard shortcuts

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