znet

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRedisClient added in v0.1.0

func NewRedisClient(host string) (*redis.Client, error)

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"`
}

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"`
	Endpoint     string              `yaml:"endpoint,omitempty"`
	Environments []EnvironmentConfig `yaml:"environments,omitempty"`
	Nats         NatsConfig          `yaml:"nats,omitempty"`
	Hue          HueConfig           `yaml:"hue,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"`
}

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

func (*Config) Room

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

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"`
}

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"`
}

type EthernetSwitching added in v0.1.0

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

type HTTPConfig added in v0.2.0

type HTTPConfig struct {
	ListenAddress string
}

type HostData added in v0.1.0

type HostData struct {
	NTPServers            []string              `yaml:"ntp_servers"`
	DHCPServer            string                `yaml:"dhcp_server"`
	DHCPForwardInterfaces []string              `yaml:"dhcp_forward_interfaces"`
	LLDPInterfaces        []string              `yaml:"lldp_interfaces"`
	IRBInterfaces         []IRBInterface        `yaml:"irb_interfaces"`
	AEInterfaces          []AEInterface         `yaml:"ae_interfaces"`
	EthernetInterfaces    []EthernetInterface   `yaml:"eth_interfaces"`
	RouterAdvertisements  []RouterAdvertisement `yaml:"router_advertisements"`
	BGP                   BGP                   `yaml:"bgp"`
	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 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
	BindDN string
	BindPW string
	Host   string
}

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.

type NetworkZone added in v0.1.0

type NetworkZone struct {
	Name       string
	NTPServers []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 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 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
	// 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

NewZnet creates and returns a new Znet object.

func (*Znet) ConfigureNetworkHost added in v0.1.0

func (z *Znet) ConfigureNetworkHost(host *NetworkHost, commit bool, auth *junos.AuthMethod) 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) GetNetworkHosts added in v0.1.0

func (z *Znet) GetNetworkHosts(l *ldap.Conn, baseDN string) ([]NetworkHost, error)

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

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) LoadConfig added in v0.1.0

func (z *Znet) LoadConfig(file string)

LoadConfig receives a file path for a configuration to load.

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) LoadEnvironment added in v0.2.0

func (z *Znet) LoadEnvironment() error

func (*Znet) NewLDAPClient added in v0.1.0

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

NewLDAPClient constructs an LDAP client to return.

func (*Znet) NewSecretClient added in v0.2.0

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

NewSecretClient receives a configuration and returns a client for Vault.

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