znet

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2020 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadEnvironment added in v0.4.0

func LoadEnvironment(config VaultConfig, e EnvironmentConfig) (map[string]string, error)

LoadEnvironment reads reads environment variables out of vault for return.

func NewLDAPClient added in v0.4.0

func NewLDAPClient(config LDAPConfig) (*ldap.Conn, error)

NewLDAPClient constructs an LDAP client to return.

func NewSecretClient added in v0.4.0

func NewSecretClient(config VaultConfig) (*api.Client, error)

NewSecretClient receives a configuration and returns a client for Vault.

func PublicKeyFile added in v0.4.0

func PublicKeyFile(file string) ssh.AuthMethod

func SSHAgent added in v0.4.0

func SSHAgent() ssh.AuthMethod

Types

type AEInterface added in v0.1.0

type AEInterface struct {
	Description string `yaml:"description"`
	Name        string `yaml:"name"`
	MTU         int    `yaml:"mtu"`
	Options     struct {
		MinimumLinks int      `yaml:"minimum_links"`
		LACP         []string `yaml:"lacp"`
	} `yaml:"options"`
	EthernetSwitching EthernetSwitching `yaml:"ethernet_switching"`
	Units             []InetUnit        `yaml:"units,omitempty"`
	NativeVlanId      int               `yaml:"native_vlan_id"`
}

type BGP added in v0.1.0

type BGP struct {
	Groups []BGPGroup `yaml:"groups"`
}

type BGPGroup added in v0.1.0

type BGPGroup struct {
	Name      string   `yaml:"name"`
	Type      string   `yaml:"type"`
	ASN       int      `yaml:"asn"`
	Neighbors []string `yaml:"neighbors"`
	Import    []string `yaml:"import"`
	Export    []string `yaml:"export"`
}

type Config

type Config struct {
	Rooms        []Room              `yaml:"rooms,omitempty"`
	Environments []EnvironmentConfig `yaml:"environments,omitempty"`
	Nats         NatsConfig          `yaml:"nats,omitempty"`
	Junos        JunosConfig         `yaml:"junos,omitempty"`
	Redis        RedisConfig         `yaml:"redis,omitempty"`
	HTTP         HTTPConfig          `yaml:"http,omitempty"`
	LDAP         LDAPConfig          `yaml:"ldap,omitempty"`
	Vault        VaultConfig         `yaml:"vault,omitempty"`
	RPC          RPCConfig           `yaml:"rpc,omitempty"`
	Lights       LightsConfig        `yaml:"lights,omitempty"`
}

Config stores the items that are required to configure this project.

type Data added in v0.1.0

type Data struct {
	TemplateDir   string   `yaml:"template_dir"`
	TemplatePaths []string `yaml:"template_paths"`
	DataDir       string   `yaml:"data_dir"`
	Hierarchy     []string `yaml:"hierarchy"`
}

type EnvironmentConfig added in v0.2.0

type EnvironmentConfig struct {
	Name         string   `yaml:"name,omitempty"`
	SecretValues []string `yaml:"secret_values,omitempty"`
}

func GetEnvironmentConfig added in v0.5.0

func GetEnvironmentConfig(environments []EnvironmentConfig, envName string) (EnvironmentConfig, error)

GetEnvironmentConfig receives a slice of environment configurations and returns the one that matches the given name.

type EthernetInterface added in v0.1.0

type EthernetInterface struct {
	Description       string            `yaml:"description"`
	EthernetSwitching EthernetSwitching `yaml:"ethernet_switching"`
	EthernetOptions   []string          `yaml:"ethernet_options"`
	MTU               int               `yaml:"mtu"`
	Name              string            `yaml:"name"`
	NativeVlanId      int               `yaml:"native_vlan_id"`
	Units             []InetUnit        `yaml:"units"`
}

type EthernetSwitching added in v0.1.0

type EthernetSwitching struct {
	Mode         string   `yaml:"mode,omitempty"`
	StormControl string   `yaml:"storm_control,omitempty"`
	VLANs        []string `yaml:"vlans,omitempty"`
}

type HTTPConfig added in v0.2.0

type HTTPConfig struct {
	ListenAddress string
}

type HostData added in v0.1.0

type HostData struct {
	AEInterfaces          []AEInterface         `yaml:"ae_interfaces"`
	BGP                   BGP                   `yaml:"bgp"`
	DHCPForwardInterfaces []string              `yaml:"dhcp_forward_interfaces"`
	DHCPServer            string                `yaml:"dhcp_server"`
	EthernetInterfaces    []EthernetInterface   `yaml:"eth_interfaces"`
	IRBInterfaces         []IRBInterface        `yaml:"irb_interfaces"`
	LLDPInterfaces        []string              `yaml:"lldp_interfaces"`
	NTPServers            []string              `yaml:"ntp_servers"`
	RouterAdvertisements  []RouterAdvertisement `yaml:"router_advertisements"`
	Routing               Routing               `yaml:"routing"`
	PolicyOptions         PolicyOptions         `yaml:"policy_options"`
	Security              Security              `yaml:"security"`
	VLANs                 []VLAN                `yaml:"vlans"`
}

type HueConfig added in v0.2.0

type HueConfig struct {
	Endpoint string `yaml:"endpoint"`
	User     string `yaml:"user"`
}

type IRBInterface added in v0.1.0

type IRBInterface struct {
	Unit  string   `yaml:"unit"`
	Inet  []string `yaml:"inet"`
	Inet6 []string `yaml:"inet6"`
	MTU   int      `yaml:"mtu"`
}

type InetUnit added in v0.3.0

type InetUnit struct {
	Inet  []string `yaml:"inet"`
	Inet6 []string `yaml:"inet6"`
	MTU   int      `yaml:"mtu"`
}

type Inventory added in v0.4.0

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

func (*Inventory) NetworkHosts added in v0.4.0

func (i *Inventory) NetworkHosts() ([]NetworkHost, error)

NetworkHosts retrieves the NetworkHost objects from LDAP given an LDPA connection and baseDN.

func (*Inventory) UnknownHosts added in v0.6.1

func (i *Inventory) UnknownHosts() ([]UnknownHost, error)

type JunosConfig added in v0.1.0

type JunosConfig struct {
	Hosts      []string
	Username   string
	PrivateKey string
}

type LDAPConfig added in v0.2.0

type LDAPConfig struct {
	BaseDN    string `yaml:"basedn"`
	BindDN    string `yaml:"binddn"`
	BindPW    string `yaml:"bindpw"`
	Host      string `yaml:"host"`
	UnknownDN string `yaml:"unknowndn"`
}

type Lights added in v0.4.0

type Lights struct {
	RFToy *rftoy.RFToy
	HUE   *huego.Bridge
	// contains filtered or unexported fields
}

Lights holds the information necessary to communicate with lighting equipment.

func NewLights added in v0.4.0

func NewLights(config LightsConfig) *Lights

NewLights creates and returns a new Lights object based on the received configuration.

func (*Lights) Off added in v0.4.0

func (l *Lights) Off(roomName string)

Off turns off the Hue lights for a room.

func (*Lights) On added in v0.4.0

func (l *Lights) On(roomName string)

On turns off the Hue lights for a room.

func (*Lights) Status added in v0.4.0

func (l *Lights) Status() []huego.Light

type LightsConfig added in v0.4.0

type LightsConfig struct {
	Rooms []Room      `yaml:"rooms"`
	Hue   HueConfig   `yaml:"hue,omitempty"`
	RFToy RFToyConfig `yaml:"rftoy,omitempty"`
}

func (*LightsConfig) Room added in v0.4.0

func (c *LightsConfig) Room(name string) (Room, error)

type Listener added in v0.1.0

type Listener struct {
	Config *Config
	// contains filtered or unexported fields
}

Listener is a znet server

func NewListener added in v0.1.0

func NewListener(config *Config) (*Listener, error)

NewListener builds a new Listener object from the received configuration.

func (*Listener) Listen added in v0.1.0

func (l *Listener) Listen(listenAddr string, ch chan bool)

Listen starts the http listener

func (*Listener) Shutdown added in v0.1.0

func (l *Listener) Shutdown()

Shutdown closes down the to the message bus and shuts down the HTTP server.

type NatsConfig added in v0.1.0

type NatsConfig struct {
	URL   string
	Topic string
}

type NetworkHost added in v0.1.0

type NetworkHost struct {
	Name        string
	HostName    string
	Domain      string
	Platform    string
	Group       string
	Role        string
	DeviceType  string
	Data        HostData
	Watch       bool
	Description string
	MACAddress  []string
	Environment map[string]string
}

NetworkHost is a device that connects to the network.

func (*NetworkHost) Update added in v0.4.0

func (h *NetworkHost) Update() (*ssh.Conn, error)

type NetworkZone added in v0.1.0

type NetworkZone struct {
	Name       string
	NTPServers []string
}

type PolicyOptions added in v0.3.0

type PolicyOptions struct {
	Statements map[string]PolicyStatement `yaml:"statements"`
}

type PolicyStatement added in v0.3.0

type PolicyStatement struct {
	Name  string       `yaml:"name"`
	Terms []PolicyTerm `yaml:"terms"`
	Then  string       `yaml:"then"`
}

type PolicyTerm added in v0.3.0

type PolicyTerm struct {
	From []string `yaml:"from"`
	Then string   `yaml:"then"`
}

type RFToyConfig added in v0.4.0

type RFToyConfig struct {
	Endpoint string `yaml:"endpoint,omitempty"`
}

type RPCConfig added in v0.4.0

type RPCConfig struct {
	ListenAddress string
	ServerAddress string
}

type RedisConfig added in v0.1.0

type RedisConfig struct {
	Host string
}

type Room

type Room struct {
	Name   string `yaml:"name"`
	IDs    []int  `yaml:"ids"`
	HueIDs []int  `yaml:"hue"`
}

type RouterAdvertisement added in v0.1.0

type RouterAdvertisement struct {
	Interface string `yaml:"interface"`
	DNSServer string `yaml:"dns_server"`
	Prefix    string `yaml:"prefix"`
}

type Routing added in v0.3.0

type Routing struct {
	RouterID     string       `yaml:"router_id"`
	ASN          int          `yaml:"asn"`
	StaticRoutes StaticRoutes `yaml:"static_routes"`
}

type Security added in v0.1.0

type Security struct {
	Zones          []SecurityZone         `yaml:"zones"`
	Policies       []SecurityPolicies     `yaml:"policies"`
	SimplePolicies []SimpleSecurityPolicy `yaml:"simple_policies"`
	NATRuleSets    []SecurityNATRuleSet   `yaml:"nat_rulesets"`
}

type SecurityNATRule added in v0.2.0

type SecurityNATRule struct {
	Name  string               `yaml:"name"`
	Match SecurityNATRuleMatch `yaml:"match"`
}

type SecurityNATRuleMatch added in v0.2.0

type SecurityNATRuleMatch struct {
	SourceAddressNames []string `yaml:"source_address_names"`
	SourceAddress      []string `yaml:"source_address"`
}

type SecurityNATRuleSet added in v0.2.0

type SecurityNATRuleSet struct {
	Name  string            `yaml:"name"`
	From  string            `yaml:"from_zone"`
	To    string            `yaml:"to_zone"`
	Rules []SecurityNATRule `yaml:"rules"`
}

type SecurityPolicies added in v0.1.0

type SecurityPolicies struct {
	From     string           `yaml:"from"`
	To       string           `yaml:"to"`
	Policies []SecurityPolicy `yaml:"policies"`
}

type SecurityPolicy added in v0.1.0

type SecurityPolicy struct {
	Name  string   `yaml:"name"`
	Match []string `yaml:"match"`
	Then  []string `yaml:"then"`
}

type SecurityZone added in v0.1.0

type SecurityZone struct {
	Name           string                  `yaml:"name"`
	Screen         string                  `yaml:"screen"`
	SystemServices []string                `yaml:"system_services"`
	Protocols      []string                `yaml:"protocols"`
	Interfaces     []SecurityZoneInterface `yaml:"interfaces"`
}

type SecurityZoneInterface added in v0.1.0

type SecurityZoneInterface struct {
	Name           string   `yaml:"name"`
	SystemServices []string `yaml:"system_services"`
}

type SimpleSecurityPolicy added in v0.1.0

type SimpleSecurityPolicy struct {
	From string   `yaml:"from"`
	To   []string `yaml:"to"`
	Then string   `yaml:"then"`
}

type StaticRoute added in v0.3.0

type StaticRoute struct {
	Prefix  string `yaml:"prefix"`
	NextHop string `yaml:"next_hop"`
}

type StaticRoutes added in v0.3.0

type StaticRoutes struct {
	Inet  []StaticRoute `yaml:"inet"`
	Inet6 []StaticRoute `yaml:"inet6"`
}

type UnknownHost added in v0.6.1

type UnknownHost struct {
	Name       string
	IP         string
	MACAddress string
}

type VLAN added in v0.2.0

type VLAN struct {
	Name        string `yaml:"name"`
	ID          int    `yaml:"id"`
	Description string `yaml:"description"`
	L3Interface string `yaml:"l3_interface"`
}

type VaultConfig added in v0.2.0

type VaultConfig struct {
	Host      string
	TokenPath string `yaml:"token_path,omitempty"`
	VaultPath string `yaml:"vault_path,omitempty"`
}

type Znet added in v0.1.0

type Znet struct {
	ConfigDir   string
	Config      Config
	Data        Data
	Environment map[string]string

	// TODO deprecate ldapclient use at Znet, move to Inventory
	// ldapClient *ldap.Conn
	Inventory *Inventory
	Lights    *Lights
	// contains filtered or unexported fields
}

Znet is the core object for this project. It keeps track of the data, configuration and flow control for starting the server process.

func NewZnet added in v0.1.0

func NewZnet(file string) (*Znet, error)

NewZnet creates and returns a new Znet object.

func (*Znet) AdoptUnknownHost added in v0.6.1

func (z *Znet) AdoptUnknownHost(u UnknownHost, baseDN string)

func (*Znet) Close added in v0.4.0

func (z *Znet) Close() error

Close calls

func (*Znet) ConfigureNetworkHost added in v0.1.0

func (z *Znet) ConfigureNetworkHost(host *NetworkHost, commit bool, auth *junos.AuthMethod, show bool) error

ConfigureNetworkHost renders the templates using associated data for a network host. The hosts about which to load the templates, are retrieved from LDAP.

func (*Znet) DataForDevice added in v0.1.0

func (z *Znet) DataForDevice(host NetworkHost) HostData

DataForDevice returns HostData for a given NetworkHost.

func (*Znet) GetNetworkZones added in v0.1.0

func (z *Znet) GetNetworkZones(l *ldap.Conn, baseDN string) []NetworkZone

func (*Znet) HierarchyForDevice added in v0.1.0

func (z *Znet) HierarchyForDevice(host NetworkHost) []string

HierarchyForDevice retuns a list of file paths to consult for the data hierarchy.

func (*Znet) Listen added in v0.1.0

func (z *Znet) Listen(listenAddr string, ch chan bool)

Listen starts the znet listener

func (*Znet) LoadData added in v0.1.0

func (z *Znet) LoadData(configDir string)

LoadData receives a configuration directory from which to load the data for Znet.

func (*Znet) RecordUnknownHost added in v0.4.0

func (z *Znet) RecordUnknownHost(baseDN string, address string, mac string) error

func (*Znet) RenderHostTemplateFile added in v0.1.0

func (z *Znet) RenderHostTemplateFile(host NetworkHost, path string) string

RenderHostTemplateFile renders a template file using a Host object.

func (*Znet) TemplateStringsForDevice added in v0.1.0

func (z *Znet) TemplateStringsForDevice(host NetworkHost, templates []string) []string

TemplateStringsForDevice renders a list of template strings given a host.

func (*Znet) TemplatesForDevice added in v0.1.0

func (z *Znet) TemplatesForDevice(host NetworkHost) []string

TemplatesForDevice returns a list of template paths for a given host.

Jump to

Keyboard shortcuts

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