lb

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MATRIX = []VirtualMatrix{
	{Name: "host,host,port", Value: 1},
	{Name: "host,host,any", Value: 2},
	{Name: "host,net,port", Value: 3},
	{Name: "host,net,any", Value: 4},
	{Name: "host,any,port", Value: 5},
	{Name: "host,any,any", Value: 6},

	{Name: "net,host,port", Value: 7},
	{Name: "net,host,any", Value: 8},
	{Name: "net,net,port", Value: 9},
	{Name: "net,net,any", Value: 10},
	{Name: "net,any,port", Value: 11},
	{Name: "net,any,any", Value: 12},

	{Name: "any,host,port", Value: 13},
	{Name: "any,host,any", Value: 14},
	{Name: "any,net,port", Value: 15},
	{Name: "any,net,any", Value: 16},
	{Name: "any,any,port", Value: 17},
	{Name: "any,any,any", Value: 18},
}

Functions

func F5Exist

func F5Exist(hs session.HttpSession, target string, name string, partition string) (bool, error)

func F5Name

func F5Name(hs session.HttpSession) (string, error)

func F5Nodes

func F5Nodes(hs session.HttpSession) (map[string]Node, error)

func F5Pools

func F5Pools(hs session.HttpSession) (map[string]Pool, error)

func F5RouteDomain

func F5RouteDomain(hs session.HttpSession) (map[string]RouteDomain, error)

func F5RouteTableIpv4

func F5RouteTableIpv4(hs session.HttpSession, partitions []Partition, interfaces []Interface) (map[string]*network.AddressTable, error)

此处的interfaces参数需要调用self的方法返回的值

func F5RouteTableIpv6

func F5RouteTableIpv6(hs session.HttpSession, partitions []Partition, interfaces []Interface) (map[string]*network.AddressTable, error)

此处的interfaces参数需要调用self的方法返回的值

func F5Snat

func F5Snat(hs session.HttpSession) (map[string]Snat, error)

func F5SnatPools

func F5SnatPools(hs session.HttpSession) (map[string]SnatPool, error)

func F5Trunk

func F5Trunk(hs session.HttpSession) (map[string]Trunk, error)

func F5Virtuals

func F5Virtuals(hs session.HttpSession, routeDomains map[string]RouteDomain) (map[int]map[string]Virtual, error)

func NewHttpSession

func NewHttpSession(device structs.DeviceBase) (session.HttpSession, error)

Types

type CertReference

type CertReference struct {
	Link string `json:"link" mapstructure:"link"`
}

type ExecInfo

type ExecInfo struct {
	Err  error
	Info F5Result
}

type F5

type F5 struct{}

func (F5) Process

func (f F5) Process(remote *structs.L2DeviceRemoteInfo, taskConfig structs.L2NodemapTaskConfigInterface, options ...interface{}) (table *clitask.Table, err error)

type F5DeviceInfo

type F5DeviceInfo struct {
	HostName string   `json:"hostname" mapstructure:"hostname"`
	Version  string   `json:"version" mapstructure:"version"`
	Model    string   `json:"model" mapstructure:"model"`
	Sn       []string `json:"sn" mapstructure:"sn"`
}

func F5Info

func F5Info(hs session.HttpSession) (F5DeviceInfo, error)

type F5ExecResult

type F5ExecResult struct {
	Pool        ExecInfo
	PoolMembers []ExecInfo
	Virtual     ExecInfo
}

type F5OprtState

type F5OprtState int
const (
	CREATE_POOL F5OprtState // 1
	CREATE_VS               // 2
	ADD_NODE                // 3
)

func (F5OprtState) String

func (fos F5OprtState) String() string

type F5Result

type F5Result struct {
	Code     int            `json:"code" mapstructure:"code"`
	Kind     string         `json:"kind" mapstructure:"kind"`
	SelfLink string         `json:"selfLink" mapstructure:"selfLink"`
	Items    []F5ResultItem `json:"items" mapstructure:"items"`
	Message  string         `json:"message" mapstructure:"message"`
}

func F5CreatePool

func F5CreatePool(hs session.HttpSession, pools map[string]Pool, name string, partition string, monitor string) (res F5Result, err error)

func F5CreatePoolMember

func F5CreatePoolMember(hs session.HttpSession, pools map[string]Pool, pool Pool, partition Partition, hosts []string, port string, routeDomain RouteDomain) (res []F5Result, err error)

func F5CreateVirtual

func F5CreateVirtual(hs session.HttpSession, virtuals map[string]Virtual, pool Pool, virual Virtual, partition Partition, dst string, dport string, sourceAddressTranslation bool) (res F5Result, err error)

func GetResult

func GetResult(hs session.HttpSession, params HttpParams, data []byte) (f5Result F5Result, err error)

type F5ResultItem

type F5ResultItem struct {
	Kind              string        `json:"kind" mapstructure:"kind"`
	Name              string        `json:"name" mapstructure:"name"`
	Partition         string        `json:"partition" mapstructure:"partition"`
	FullPath          string        `json:"fullPath" mapstructure:"fullPath"`
	Generation        int           `json:"generation" mapstructure:"generation"`
	SelfLink          string        `json:"selfLink" mapstructure:"selfLink"`
	ActiveModules     []string      `json:"activeModules" mapstructure:"activeModules"`
	AlternateIp       string        `json:"alternateIp" mapstructure:"alternateIp"`
	BaseMac           string        `json:"baseMac" mapstructure:"baseMac"`
	Build             string        `json:"build" mapstructure:"build"`
	Cert              string        `json:"cert" mapstructure:"cert"`
	ChassisId         string        `json:"chassisId" mapstructure:"chassisId"`
	ChassisType       string        `json:"chassisType" mapstructure:"chassisType"`
	ConfigsyncIp      string        `json:"configsyncIp" mapstructure:"configsyncIp"`
	Edition           string        `json:"edition" mapstructure:"edition"`
	FailoverState     string        `json:"failoverState" mapstructure:"failoverState"`
	HaCapacity        int           `json:"haCapacity" mapstructure:"haCapacity"`
	Hostname          string        `json:"hostname" mapstructure:"hostname"`
	Key               string        `json:"key" mapstructure:"key"`
	ManagementIp      string        `json:"managementIp" mapstructure:"managementIp"`
	MarketingName     string        `json:"marketingName" mapstructure:"marketingName"`
	MgmtUnicastMode   string        `json:"mgmtUnicastMode" mapstructure:"mgmtUnicastMode"`
	MirrorIp          string        `json:"mirrorIp" mapstructure:"mirrorIp"`
	MirrorSecondaryIp string        `json:"mirrorSecondaryIp" mapstructure:"mirrorSecondaryIp"`
	MulticastIp       string        `json:"multicastIp" mapstructure:"multicastIp"`
	MulticastPort     int           `json:"multicastPort" mapstructure:"multicastPort"`
	OptionalModules   []string      `json:"optionalModules" mapstructure:"optionalModules"`
	PlatformId        string        `json:"platformId" mapstructure:"platformId"`
	Product           string        `json:"product" mapstructure:"product"`
	SelfDevice        string        `json:"selfDevice" mapstructure:"selfDevice"`
	TimeZone          string        `json:"timeZone" mapstructure:"timeZone"`
	Version           string        `json:"version" mapstructure:"version"`
	Vrf               string        `json:"vrf" mapstructure:"vrf"`
	Gw                string        `json:"gw" mapstructure:"gw"`
	Network           string        `json:"network" mapstructure:"network"`
	Mtu               int           `json:"mtu" mapstructure:"mtu"`
	PoolMembers       []interface{} `json:"poolMembers" mapstructure:"poolMembers"`
	PoolMemberPort    string        `json:"poolMembersPort" mapstructure:"poolMembersPort"`
	SnatPoolMembers   []interface{} `json:"snatPoolMembers" mapstructure:"snatPoolMembers"`

	Vlan               string        `json:"vlan" mapstructure:"vlan"`
	Address            string        `json:"address" mapstructure:"address"`
	MacAddress         string        `json:"macAddress" mapstructure:"macAddress"`
	DefaultRouteDomain int           `json:"defaultRouteDomain" mapstructure:"defaultRouteDomain"`
	Strict             string        `json:"strict" mapstructure:"strict"`
	Vlans              []interface{} `json:"vlans" mapstructure:"vlans"`

	IpProtocol       string `json:"ipProtocol"          mapstructure:"ipProtocol"`
	Source           string `json:"source" mapstructure:"source"`
	Destination      string `json:"destination" mapstructure:"destination"`
	SourcePort       string `json:"sourcePort" mapstructure:"sourcePort"`
	Enabled          bool   `json:"enabled" mapstructure:"enabled"`
	Mask             string `json:"mask" mapstructure:"mask"`
	Pool             string `json:"pool" mapstructure:"pool"`
	Disabled         bool   `json:"disabled" mapstructure:"disabled"`
	VlansEnabled     bool   `json:"vlansEnabled" mapstructure:"vlansEnabled"`
	VlansDisabled    bool   `json:"vlansDisabled" mapstructure:"vlansDisabled"`
	TranslateAddress string `json:"translateAddress" mapstructure:"translateAddress"`
	TranslatePort    string `json:"translatePort" mapstructure:"translatePort"`
	VsIndex          int    `json:"vsIndex" mapstructure:"vsIndex"`

	SourceAddressTranslation SourceAddressTranslation `json:"sourceAddressTranslation" mapstructure:"sourceAddressTranslation"`
	CertReference            CertReference            `json:"certReference" mapstructure:"certReference"`
	KeyReference             KeyReference             `json:"keyReference" mapstructure:"keyReference"`
}

type F5TableResult

type F5TableResult struct {
	Err   error
	Table F5ExecResult
}

type F5Urls

type F5Urls int
const (
	AUTH             F5Urls // 1 /mgmt/shared/authn/login
	DEVICE_INFO             // 2 mgmt/tm/cm/device
	VIRTUAL                 // 3 mgmt/tm/ltm/virtual
	POOL                    // 4 mgmt/tm/ltm/pool
	POOL_MEMBER             // 5 mgmt/tm/ltm/pool/%s/members
	SNAT_POOL               // 6 mgmt/tm/ltm/snatpool
	SNAT_POOL_MEMBER        // 7 mgmt/tm/ltm/snat-translation/{}/
	SNAT                    // 8 mgmt/tm/ltm/snat
	POOL_STAT               // 9 /mgmt/tm/ltm/pool/stats
	NODE_INFO               // 10 mgmt/tm/ltm/node
	INTERFACE               // 11 mgmt/tm/net/interface
	TRUNK                   // 12 mgmt/tm/net/trunk
	VLAN                    // 13 mgmt/tm/net/vlan
	VLAN_INTERFACE          // 14 mgmt/tm/net/vlan/{name}/interfaces
	PARTITION               // 15 mgmt/tm/auth/partition
	ROUTE_DOMAIN            // 16 mgmt/tm/net/route-domain
	SELF                    // 17 mgmt/tm/net/self
	ROUTE                   // 18 mgmt/tm/net/route
)

func (F5Urls) String

func (w F5Urls) String() string

type HttpParams

type HttpParams struct {
	Method  string
	Url     string
	Key     string
	Timeout int
	Force   bool
	Data    []byte
}

type Interface

type Interface struct {
	Name       string        `json:"name" mapstructure:"name"`
	Ipv4       []interface{} `json:"ipv4" mapstructure:"ipv4"`
	Ipv6       []interface{} `json:"ipv6" mapstructure:"ipv6"`
	Vrf        string        `json:"vrf" mapstructure:"vrf"`
	MacAddress string        `json:"macAddress" mapstructure:"macAddress"`
}

func F5Interface

func F5Interface(hs session.HttpSession) ([]Interface, error)

func PrefectInterfaces

func PrefectInterfaces(vlans []Vlan) (interfaces []Interface)

type KeyReference

type KeyReference struct {
	Link string `json:"link" mapstructure:"link"`
}

type LBProcessResult

type LBProcessResult struct {
	Virtual     string   `json:"virtual" mapstructure:"virtual"`
	Partition   string   `json:"partition" mapstructure:"partition"`
	Dst         string   `json:"dst" mapstructure:"dst"`
	Dport       string   `json:"dport" mapstructure:"dport"`
	Pool        string   `json:"pool" mapstructure:"pool"`
	AutoMap     bool     `json:"autoMap" mapstructure:"autoMap"`
	State       []string `json:"state" mapstructure:"state"`
	Nodes       []string `json:"nodes" mapstructure:"nodes"`
	RouteDomain string   `json:"routeDomain" mapstructure:"routeDomain"`
	NodePort    string   `json:"nodePort" mapstructure:"nodePort"`
	ErrMsg      string   `json:"errMsg" mapstructure:"errMsg"`
}

type Node

type Node struct {
	Name      string    `json:"name" mapstructure:"name"`
	IP        string    `json:"ip" mapstructure:"ip"`
	Partition Partition `json:"partition" mapstructure:"partition"`
}

type Partition

type Partition struct {
	Name          string `json:"name" mapstructure:"name"`
	DefaultDomain int    `json:"default_domain" mapstructure:"default_domain"`
}

func F5Partition

func F5Partition(hs session.HttpSession) ([]Partition, error)

type Pool

type Pool struct {
	Name        string       `json:"name" mapstructure:"name"`
	FullPath    string       `json:"fullPath" mapstructure:"fullPath"`
	PoolMembers []PoolMember `json:"poolMembers" mapstructure:"poolMembers"`
}

type PoolMember

type PoolMember struct {
	PoolName string `json:"poolName" mapstructure:"poolName"`
	FullPath string `json:"fullPath" mapstructure:"fullPath"`
	Port     string `json:"port" mapstructure:"port"`
}

type RouteDomain

type RouteDomain struct {
	Partition string        `json:"partition" mapstructure:"partition"`
	ID        string        `json:"id" mapstructure:"id"`
	Name      string        `json:"name" mapstructure:"name"`
	Strict    string        `json:"strict" mapstructure:"strict"`
	Vlans     []interface{} `json:"vlans" mapstructure:"vlans"`
	Vrf       string        `json:"vrf" mapstructure:"vrf"`
}

type Snat

type Snat struct {
	Name     string `json:"name" mapstructure:"name"`
	FullPath string `json:"fullPath" mapstructure:"fullPath"`
}

type SnatPool

type SnatPool struct {
	Name            string           `json:"name" mapstructure:"name"`
	FullPath        string           `json:"fullPath" mapstructure:"fullPath"`
	SnatPoolMembers []SnatPoolMember `json:"snatPoolMembers" mapstructure:"snatPoolMembers"`
}

type SnatPoolMember

type SnatPoolMember struct {
	SnatPoolName string `json:"snatPoolName" mapstructure:"snatPoolName"`
	FullPath     string `json:"fullPath" mapstructure:"fullPath"`
}

type SourceAddressTranslation

type SourceAddressTranslation struct {
	Pool string `json:"pool" mapstructure:"pool"`
	Type string `json:"type" mapstructure:"type"`
}

type Trunk

type Trunk struct {
	Name       string        `json:"name" mapstructure:"name"`
	Interfaces []interface{} `json:"interfaces" mapstructure:"interfaces"`
}

type Virtual

type Virtual struct {
	Name             string `json:"name" mapstructure:"name"`
	Vrf              string `json:"vrf" mapstructure:"vrf"`
	IpProtocol       string `json:"ipProtocol"          mapstructure:"ipProtocol"`
	Source           string `json:"source" mapstructure:"source"`
	Destination      string `json:"destination" mapstructure:"destination"`
	Port             string `json:"port" mapstructure:"port"`
	FullPath         string `json:"fullPath" mapstructure:"fullPath"`
	Enabled          bool   `json:"enabled" mapstructure:"enabled"`
	Disabled         bool   `json:"disabled" mapstructure:"disabled"`
	Mask             string `json:"mask" mapstructure:"mask"`
	VlansEnabled     bool   `json:"vlansEnabled" mapstructure:"vlansEnabled"`
	VlansDisabled    bool   `json:"vlansDisabled" mapstructure:"vlansDisabled"`
	TranslateAddress string `json:"translateAddress" mapstructure:"translateAddress"`
	TranslatePort    string `json:"translatePort" mapstructure:"translatePort"`
	VsIndex          int    `json:"vsIndex" mapstructure:"vsIndex"`

	Orignal                  policy.PolicyEntry       `json:"orignal" mapstructure:"orignal"`
	SourceAddressTranslation SourceAddressTranslation `json:"sourceAddressTranslation" mapstructure:"sourceAddressTranslation"`
	Partition                Partition                `json:"partition" mapstructure:"partition"`
	Pool                     Pool                     `json:"pool" mapstructure:"pool"`
}

func (Virtual) Match

func (vs Virtual) Match(intent policy.Intent, sameDst bool) bool

type VirtualMatrix

type VirtualMatrix struct {
	Name  string
	Value int
}

type Vlan

type Vlan struct {
	Name             string        `json:"name" mapstructure:"name"`
	InterfaceOrTrunk string        `json:"Interface_or_trunk" mapstructure:"Interface_or_trunk"`
	Ipv4             []interface{} `json:"ipv4" mapstructure:"ipv4"`
	Ipv6             []interface{} `json:"ipv6" mapstructure:"ipv6"`
	Vrf              string        `json:"vrf" mapstructure:"vrf"`
	RouteDomain      string        `json:"routeDomain" mapstructure:"routeDomain"`
	MacAddress       string        `json:"macAddress" mapstructure:"macAddress"`
}

func F5Self

func F5Self(hs session.HttpSession, interfaces []Interface, vlans []Vlan, domains map[string]RouteDomain, patitions []Partition) ([]Vlan, map[string]RouteDomain, error)

func F5Vlan

func F5Vlan(hs session.HttpSession) ([]Vlan, error)

Jump to

Keyboard shortcuts

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