tmsh

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2019 License: MIT Imports: 8 Imported by: 3

README

go-tmsh

Build Status license

go-tmsh is a library providing functions to operate the BIG-IP Traffic Management Shell (TMSH) via SSH.

go-tmsh is also a command-line tool that will operate TMSH using these functions.

Tested versions of BIG-IP

Currently the following versions of BIG-IP are tested.

  • v11.5.3
  • v11.2.1

Install

$ go get github.com/yukirii/go-tmsh/...

Usage

Using the go-tmsh library
import "github.com/yukirii/go-tmsh"

Please refer to the examples directory for an example source code.

Using the tmsh command line tool

tmsh is single command-line application. This application then takes subcommands. To check the all available commands,

$ tmsh help

To get help for any specific subcommand, run it with the -h flag,

$ tmsh node -h

Licence

MIT

Documentation

Index

Constants

View Source
const EOF = 57347
View Source
const IDENT = 57352
View Source
const ILLEGAL = 57346
View Source
const LTM = 57353
View Source
const L_BRACE = 57350
View Source
const NEWLINE = 57349
View Source
const R_BRACE = 57351
View Source
const WS = 57348

Variables

This section is empty.

Functions

func Unmarshal added in v0.2.1

func Unmarshal(data string, out interface{}) error

Unmarshal parses the 'field-fmt' formatted data and stores the result in the value pointed to by out.

Types

type BigIP

type BigIP struct {
	// contains filtered or unexported fields
}

BigIP is a struct for session state

func GenSession added in v0.3.0

func GenSession(host, port, user, password string, key []byte) (*BigIP, error)

GenSession handles either Password or SSH Key based..

func NewKeySession added in v0.3.0

func NewKeySession(host, port, user string, key []byte) (*BigIP, error)

NewKeySession is NewSession plus key handling

func NewSession

func NewSession(host, port, user, password string) (*BigIP, error)

NewSession sets up new SSH session to BIG-IP TMSH

func (*BigIP) AddMonitorToPool

func (bigip *BigIP) AddMonitorToPool(poolName, monitorName string) error

DeletePoolMember adds a monitor to pool.

func (*BigIP) AddPoolMember

func (bigip *BigIP) AddPoolMember(poolName, nodeName, monitorName string, port int) error

DeletePoolMember adds a new pool member.

func (*BigIP) AddSecurityFWPolicyRule

func (bigip *BigIP) AddSecurityFWPolicyRule(firewallPolicyName, ruleName, action string, targetPort int) error

func (*BigIP) AddVirtualServerProfile

func (bigip *BigIP) AddVirtualServerProfile(vsName, profileName, context string) error

AddVirtualServerProfile adds a profile to a virtual server.

func (*BigIP) ApplyPolicyToVirtualServer

func (bigip *BigIP) ApplyPolicyToVirtualServer(vsName, policyName string) error

ApplyPolicyToVirtualServer applies a policy to a virtual server.

func (*BigIP) Close

func (bigip *BigIP) Close()

Close is used to close SSH session

func (*BigIP) CreateNode

func (bigip *BigIP) CreateNode(name, ipaddr string) error

CreateNode creates a new node.

func (*BigIP) CreatePool

func (bigip *BigIP) CreatePool(name string) error

CreatePool creates a new pool.

func (*BigIP) CreateSecurityFWPolicy

func (bigip *BigIP) CreateSecurityFWPolicy(firewallPolicyName string) error

func (*BigIP) CreateVirtualServer

func (bigip *BigIP) CreateVirtualServer(vsName, poolName, targetVIP, defaultProfileName string, targetPort int) error

CreateVirtualServer creates a virtual server.

func (*BigIP) DeleteNode

func (bigip *BigIP) DeleteNode(name string) error

DeleteNode removes a node.

func (*BigIP) DeletePool

func (bigip *BigIP) DeletePool(name string) error

DeletePool removes a pool.

func (*BigIP) DeletePoolMember

func (bigip *BigIP) DeletePoolMember(poolName, nodeName string, port int) error

DeletePoolMember removes a pool member.

func (*BigIP) DeleteVirtualServer

func (bigip *BigIP) DeleteVirtualServer(vsName string) error

DeleteVirtualServer removes a virtual server.

func (*BigIP) DeleteVirtualServerProfile

func (bigip *BigIP) DeleteVirtualServerProfile(vsName, profileName, context string) error

DeleteVirtualServerProfile removes a profile from a virtual server.

func (*BigIP) DisableNode

func (bigip *BigIP) DisableNode(name string) error

DisableNode changes the status of a node to disable.

func (*BigIP) DisablePoolMember

func (bigip *BigIP) DisablePoolMember(poolName, nodeName string, port int) error

DisablePoolMember changes the status of pool member to disable.

func (*BigIP) EnableNode

func (bigip *BigIP) EnableNode(name string) error

EnableNode changes the status of a node to enable.

func (*BigIP) EnablePoolMember

func (bigip *BigIP) EnablePoolMember(poolName, nodeName string, port int) error

EnablePoolMember changes the status of pool member to enable.

func (*BigIP) ExecuteCommand

func (bigip *BigIP) ExecuteCommand(cmd string) (string, error)

ExecuteCommand is used to execute any TMSH commands

func (*BigIP) GetAllClientSSLProfiles added in v0.4.0

func (bigip *BigIP) GetAllClientSSLProfiles() ([]ClientSSLProfile, error)

GetAllClientSSLProfiles returns a list of all Client SSL Profiles

func (*BigIP) GetAllNodes added in v0.2.1

func (bigip *BigIP) GetAllNodes() ([]Node, error)

GetAllNodes returns a list of all nodes.

func (*BigIP) GetAllPools added in v0.2.1

func (bigip *BigIP) GetAllPools() ([]Pool, error)

GetAllPools returns a list of all pools

func (*BigIP) GetAllVirtualServers added in v0.2.1

func (bigip *BigIP) GetAllVirtualServers() ([]VirtualServer, error)

GetAllVirtualServers returns a list of all virtual servers

func (*BigIP) GetClientSSLProfile added in v0.4.0

func (bigip *BigIP) GetClientSSLProfile(name string) (*ClientSSLProfile, error)

GetClientSSLProfile gets a Client SSL Profile by name. Return nil if the profile does not found.

func (*BigIP) GetNode

func (bigip *BigIP) GetNode(name string) (*Node, error)

GetNode gets a node by name. Return nil if the node does not exist.

func (*BigIP) GetPool

func (bigip *BigIP) GetPool(name string) (*Pool, error)

GetPool gets a pool by name. Return nil if the pool does not exist.

func (*BigIP) GetVirtualServer

func (bigip *BigIP) GetVirtualServer(name string) (*VirtualServer, error)

GetVirtualServer gets a virtual server by name. Rerutn nil if the virtual server does not found.

func (*BigIP) RouteAdvertisementEnabled

func (bigip *BigIP) RouteAdvertisementEnabled(targetVIP string) error

func (*BigIP) Save

func (bigip *BigIP) Save() error

Save is used to execute 'save /sys config' command

type ClientSSLProfile added in v0.4.0

type ClientSSLProfile struct {
	Name      string `ltm:"name"`
	Component string `ltm:"component"`

	Cert                string                       `ltm:"cert"`
	CertKeyChain        map[string]map[string]string `ltm:"cert-key-chain"`
	Chain               string                       `ltm:"chain"`
	DefaultsFrom        string                       `ltm:"defaults-from"`
	InheritCertkeychain bool                         `ltm:"inherit-certkeychain"`
	Key                 string                       `ltm:"key"`
}

ClientSSLProffile contains information about Client SSL profile

type Lexer added in v0.2.1

type Lexer struct {
	// contains filtered or unexported fields
}

func (*Lexer) Error added in v0.2.1

func (l *Lexer) Error(e string)

func (*Lexer) Lex added in v0.2.1

func (l *Lexer) Lex(lval *yySymType) int

type Node

type Node struct {
	Name          string `ltm:"name"`
	Addr          string `ltm:"addr"`
	MonitorRule   string `ltm:"monitor-rule"`
	MonitorStatus string `ltm:"monitor-status"`
	EnabledState  string `ltm:"status.enabled-state"`
}

Node contains information about each node

type Pool

type Pool struct {
	ActiveMemberCount int          `ltm:"active-member-cnt"`
	Name              string       `ltm:"name"`
	MonitorRule       string       `ltm:"monitor-rule"`
	AvailabilityState string       `ltm:"status.availability-state"`
	EnabledState      string       `ltm:"status.enabled-state"`
	StatusReason      string       `ltm:"status.status-reason"`
	PoolMembers       []PoolMember `ltm:"members"`
}

Pool contains information about each Pool

type PoolMember

type PoolMember struct {
	Name              string `ltm:"node-name"`
	Addr              string `ltm:"addr"`
	Port              int    `ltm:"port"`
	MonitorRule       string `ltm:"monitor-rule"`
	MonitorStatus     string `ltm:"monitor-status"`
	EnabledState      string `ltm:"status.enabled-state"`
	AvailabilityState string `ltm:"status.availability-state"`
	StatusReason      string `ltm:"status.status-reason"`
}

Pool contains information about each pool member in a pool

type SSH

type SSH interface {
	Send(cmd string) (int, error)
	Recv(suffix string) ([]byte, error)
	Close() error
}

type Token added in v0.2.1

type Token struct {
	// contains filtered or unexported fields
}

type VirtualServer

type VirtualServer struct {
	Name        string                       `ltm:"name"`
	Destination string                       `ltm:"destination"`
	IpProtocol  string                       `ltm:"ip-protocol"`
	Mask        string                       `ltm:"mask"`
	Partition   string                       `ltm:"partition"`
	Pool        string                       `ltm:"pool"`
	Profiles    map[string]map[string]string `ltm:"profiles"`
}

VirtualServer contains information about each virtual server

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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