Documentation
¶
Overview ¶
Package inventory specifies the inventory service for the bolt inventory manager service.
Index ¶
- Constants
- func APIInit(dataStorePath string, flushInterval uint16) *mux.Router
- type Host
- type HostGroup
- type Inventory
- func (inv Inventory) GetHostgroup(hgname string) *HostGroup
- func (inv Inventory) GetHosts(hgname string) map[string]*Host
- func (inv *Inventory) GetInventory() map[string]*HostGroup
- func (inv *Inventory) NewHost(hgname string, hname string)
- func (inv *Inventory) NewHostgroup(hgname string)
- func (inv *Inventory) Save()
- func (inv *Inventory) SetHostFact(hgname string, hname string, fname string, fval string) bool
- func (inv *Inventory) StopInventory()
- func (inv *Inventory) WriteData(data []byte) bool
Constants ¶
const ( // HostgroupCapacity defines the max number of hosts that can be // created under a single hostgroup. HostgroupCapacity = 65000 // InventoryCapacity specifies the maximum number of hostgroups // that can be stored inside a single inventory service. InventoryCapacity = 32764 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Host ¶
type Host struct { // hostname The address through which the host can be reached Hostname string // fcats The host specific variable Facts map[string]string }
Host defines the structure for storing the data related to individual hosts including their names and local variables.
func (*Host) DeleteFact ¶
DeleteFact deletes a host local fact from the mapping
func (Host) GetHostFacts ¶
GetHostFacts returns the facts specific to the host
func (Host) GetHostName ¶
GetHostName returns the hostname of the host
type HostGroup ¶
type HostGroup struct { // name defines the name of the hostgroup through which it can be identified Name string // hosts defines a slice in which the hosts belonging to a particular hostgroup can be grouped together Hosts map[string]*Host }
HostGroup defines the structure used for storing the data for the hostgroups that are registered individually in the inventory service.
func NewHostGroup ¶
NewHostGroup creates a new hostgroup for the inventory
func (*HostGroup) DeleteHost ¶
DeleteHost removes a host from the Hostgroup
func (HostGroup) GetHost ¶
GetHost returns the host object provided the host name If the host doesn't exists, nil is returned
func (HostGroup) GetHostgroupName ¶
GetHostgroupName returns the name of the hostgroup
type Inventory ¶
type Inventory struct { // hostgroups store the created hostgroups along with the data related // to the individual hosts inside them. Hostgroups map[string]*HostGroup // dataStorePath defines the path where the inventory database is created // on the disk. Whenever the service starts, it will look for the inventory // database at the specified path and try to load the data from it. DataStorePath string // flushInterval defines the time in milliseconds at which the inventory // flush service will write the data to the disk file. FlushInterval uint16 // pendingOps provide the information about how many operations are still // pending to be written to the disk. This provides some data into how much // data is inventory service storing in its volatile state. This parameter // can also be used in future to enhance the inventory data flush service // to be more consistent and aggressive in writing the inventory to disk. PendingOps uint32 // A Reader Writer mutex lock to help during the Marshalling of data sync.RWMutex // contains filtered or unexported fields }
Inventory struct defines the global service based inventory database used to store the information of all the hostgroups and hosts. The Inventory struct is used to retrieve all the data that needs to be sent back as JSON to the requesting client. Since the service can suffer errors at any point of time, this database is written to the disk periodically so as to avoid any inconsistency that may take place due to unpredicted failure of the code.
func NewInventory ¶
NewInventory creates a new Inventory store to be used by the Inventory Service.
func (Inventory) GetHostgroup ¶
GetHostgroup retrieves the hostgroup when the name is provided if the hostgroup doesn't exists, the call returns a nil
func (*Inventory) GetInventory ¶
GetInventory retrieves the inventory from the inventory database
func (*Inventory) NewHost ¶
NewHost creates a new host under the specified hostgroup if the hostgroup doesn't exists, then it is created and then a new host added to it.
func (*Inventory) NewHostgroup ¶
NewHostgroup creates a new hostgroup and adds it to the inventory. If the hostgroup already exists, the call returns without making any changes.
func (*Inventory) Save ¶
func (inv *Inventory) Save()
Save defines a public interface for the inventory structure to write its data to the datastore.
func (*Inventory) SetHostFact ¶
SetHostFact sets a new fact for the host. If the fact already exists, it's value is overwritten
func (*Inventory) StopInventory ¶
func (inv *Inventory) StopInventory()
StopInventory signals the inventory service to exit gracefully