config

package
v1.1.24 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

PulseHA - HA Cluster Daemon Copyright (C) 2017-2020 Andrew Zak <andrew@linux.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

View Source
var (
	CONFIG_LOCATION = "/etc/pulseha/config.json"
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Pulse  Local               `json:"pulseha"`
	Groups map[string][]string `json:"floating_ip_groups"`
	Nodes  map[string]*Node    `json:"nodes"`
	sync.Mutex
}

func New

func New() *Config

* Instantiate, setup and return our Config

func (*Config) ClusterCheck

func (c *Config) ClusterCheck() bool

ClusterCheck - Check to see if wea re in a configured cluster or not.

func (*Config) GetConfig

func (c *Config) GetConfig() Config

GetConfig - Returns a copy of the config

func (*Config) GetGroupIface

func (c *Config) GetGroupIface(hostname string, groupName string) (ifaceName string, err error)

* Returns the interface the group is assigned to

func (*Config) GetLocalNode

func (c *Config) GetLocalNode() Node

func (*Config) GetLocalNodeUUID

func (c *Config) GetLocalNodeUUID() string

GetLocalNode - Return the local node UID

func (*Config) GetNodeByHostname

func (c *Config) GetNodeByHostname(hostname string) (uid string, node Node, err error)

GetNodeByHostname - Get node by hostname

func (*Config) GetNodeHostnameByAddress

func (c *Config) GetNodeHostnameByAddress(address string) (string, error)

* Returns the hostname for a node based of it's IP address

func (*Config) Load

func (c *Config) Load() error

Load - Used to load the config into memory

func (*Config) LocalNode

func (c *Config) LocalNode() Node

LocalNode - Get the local node object

func (*Config) NodeCount

func (c *Config) NodeCount() int

NodeCount - Returns the total number of nodes in the configured cluster

func (*Config) Reload

func (c *Config) Reload()

*

  • Reload the config file into memory.
  • Note: Need to clear memory value before calling Load()

func (*Config) Save

func (c *Config) Save() error

*

  • Function used to save the config

func (*Config) SaveDefaultLocalConfig

func (c *Config) SaveDefaultLocalConfig() error

DefaultLocalConfig - Generate a default config to write

func (*Config) UpdateHostname

func (c *Config) UpdateHostname(newHostname string)

UpdateHostname - Changes our local node hostname and the hostname in our node section

func (*Config) UpdateValue

func (c *Config) UpdateValue(key string, value string) error

UpdateValue - Update a key's value

func (*Config) Validate

func (c *Config) Validate() error

*

*

type Local

type Local struct {
	HealthCheckInterval int    `json:"hcs_interval"`
	FailOverInterval    int    `json:"fos_interval"`
	FailOverLimit       int    `json:"fo_limit"`
	LocalNode           string `json:"local_node"`
	ClusterToken        string `json:"cluster_token"`
	LoggingLevel        string `json:"logging_level"`
	AutoFailback        bool   `json:"auto_failback"`
	LogToFile           bool   `json:"log_to_file"`
	LogFileLocation     string `json:"log_file_location"`
}

type Node

type Node struct {
	Hostname string              `json:"hostname"`
	IP       string              `json:"bind_address"`
	Port     string              `json:"bind_port"`
	IPGroups map[string][]string `json:"group_assignments"`
}

Jump to

Keyboard shortcuts

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