Documentation
¶
Index ¶
- func Sync(c *util.ConfigRoot, name string, reporter jobevent.Reporter, dryRun bool) error
- type Client
- func (c *Client) Call(method string, params map[string]any) (json.RawMessage, error)
- func (c *Client) Devices(domain string) ([]*Device, error)
- func (c *Client) GetElement(name string, rootOID int) (*Device, error)
- func (c *Client) GetObject(oid int) (*Object, error)
- func (c *Client) Index(objs []Object)
- func (c *Client) Interfaces(elementOID int) (map[string]*Interface, error)
- func (c *Client) LoadTree(rootOID int) error
- func (c *Client) Login() error
- func (c *Client) Logout()
- func (c *Client) ObjectTreeFind(oid int, classmask string, walkdown int) ([]Object, error)
- func (c *Client) SearchOpaque(oid int, name string) (string, error)
- func (c *Client) SearchParent(oid int) (string, error)
- type Device
- type Interface
- type Object
- type Opaque
- type OpaqueValue
- type Parameter
- type ParameterValue
- type Prefix
- type Resource
- type Syncer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Sync ¶
Sync fetches ibos elements from BECS, reconciles Netbox devices that have a non-zero becs_oid custom field against them, then runs netbox.Sync so factum sees the result. If name is set, only that device is created/updated/deleted (the full BECS tree is still loaded — parent/opaque lookup walks it). dryRun plans the same Netbox writes and reports the exact payloads, but does not apply them or run the factum half.
Types ¶
type Client ¶
type Client struct {
URL string
Username string
Password string
SessionID string
// contains filtered or unexported fields
}
Client talks to the BECS JSON-RPC API. Objects from the last LoadTree (plus any ancestors fetched while walking parents) live in memory — there is no on-disk cache; the API is fast enough without one.
func (*Client) Devices ¶
Devices returns every ibos element-attach as a Device. LoadTree must have been called first.
func (*Client) GetElement ¶
GetElement loads the tree (if needed) and returns the named ibos element. Name is matched case-insensitively against the short name.
func (*Client) Index ¶
Index replaces the in-memory object map and rebuilds parent/child links. Used by LoadTree and by tests that feed a fixture.
func (*Client) Interfaces ¶
Interfaces returns the interfaces of an element-attach, keyed by name.
func (*Client) LoadTree ¶
LoadTree fetches the object tree starting at rootOID (walkdown 0 = unlimited, matching the Python client) and indexes it in memory. If the client already has objects (e.g. tests that called Index), it is a no-op so a later Devices/GetElement call does not hit the API.
func (*Client) ObjectTreeFind ¶
func (*Client) SearchOpaque ¶
SearchOpaque walks from oid toward the root and returns the first opaque value with the given name. Does not handle arrays.
type Device ¶
type Device struct {
OID int
Name string // FQDN when a default domain is configured
ShortName string
Manufacturer string
Model string
Role string
Platform string
Enabled bool
AlarmTimeperiod string
AlarmDestination string
ConnectionMethod string
Parents []string
Interfaces map[string]*Interface
InterfacesOID map[int]*Interface
}
Device is a BECS element-attach mapped to the Netbox device shape.
type Object ¶
type Object struct {
OID int `json:"oid"`
ParentOID int `json:"parentoid"`
Class string `json:"class"`
Name string `json:"name"`
ElementType string `json:"elementtype"`
Role string `json:"role"`
Flags string `json:"flags"`
Parameters []Parameter `json:"parameters"`
Opaque []Opaque `json:"opaque"`
Resource *Resource `json:"resource"`
ChildrenOID []int `json:"-"`
}
Object is one BECS object (element-attach, interface, resource-inet, or a folder fetched while walking parents).
type Opaque ¶
type Opaque struct {
Name string `json:"name"`
Values []OpaqueValue `json:"values"`
}
type OpaqueValue ¶
type OpaqueValue struct {
Value string `json:"value"`
}
type Parameter ¶
type Parameter struct {
Name string `json:"name"`
Values []ParameterValue `json:"values"`
}
type ParameterValue ¶
type ParameterValue struct {
Value string `json:"value"`
}