api

package
v0.2.73 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestTimeout = 1200
)

Variables

View Source
var (
	ErrParentPrefixExhausted           = errors.New("parent prefix exhausted")
	ErrParentPrefixNotFound            = errors.New("parent prefix not found")
	ErrWrongMatchingPrefixSubnetFormat = errors.New("wrong matchingPrefix subnet format")
	ErrInvalidIpFamily                 = errors.New("invalid IP Family")
	ErrRestorationHashMismatch         = errors.New("restoration hash mismatch")
	ErrL2VPNRangeExhausted             = errors.New("l2vpn identifier range exhausted")
)
View Source
var ErrAsnRangeExhausted = errors.New("ASN range exhausted")
View Source
var (
	// TODO(henrybear327): centralize errors
	ErrNoPrefixMatchsSizeCriteria = errors.New("no available prefix matches size criteria")
)

Functions

func AssertError

func AssertError(t *testing.T, err error, msg string)

func AssertIpAddress

func AssertIpAddress(t *testing.T, given *netboxModels.WritableIPAddress, actual *netboxModels.IPAddress)

func AssertNil

func AssertNil(t *testing.T, err error)

func IsUpToDate added in v0.2.52

func IsUpToDate(
	ctx context.Context,
	netboxLastUpdated time.Time,
	statusLastUpdated metav1.Time,
	conditions []metav1.Condition,
	generation int64,
) bool

func SetIpAddressMask

func SetIpAddressMask(ip string, ipFamily int64) (string, error)

func TruncateDescription

func TruncateDescription(description string) string

Types

type CustomFieldEntry

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

type IPFamily

type IPFamily int64
const (
	IPv4Family IPFamily = iota + 4

	IPv6Family
)

type InstrumentedRoundTripper

type InstrumentedRoundTripper struct {
	Transport http.RoundTripper
}

func (*InstrumentedRoundTripper) RoundTrip

func (irt *InstrumentedRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

type NetboxClientV3 added in v0.2.38

type NetboxClientV3 struct {
	Ipam    interfaces.IpamInterface
	Tenancy interfaces.TenancyInterface
	Extras  interfaces.ExtrasInterface
	Dcim    interfaces.DcimInterface
}

func GetNetboxClient

func GetNetboxClient() (*NetboxClientV3, error)

type NetboxClientV4 added in v0.2.38

type NetboxClientV4 struct {
	IpamAPI   interfaces.IpamAPI
	VpnAPI    interfaces.VpnAPI
	StatusAPI interfaces.StatusAPI
	// contains filtered or unexported fields
}

func GetNetboxClientV4 added in v0.2.38

func GetNetboxClientV4() (*NetboxClientV4, error)

type NetboxCompositeClient added in v0.2.38

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

NetboxCompositeClient holds both the v3 and v4 clients, presenting a single unified interface to callers (controllers). The v4 client was introduced because of braking changes in the ip ranges and prefixes endpoints of the NetBox api in newer (4.2+) NetBox versions for requests where the v3 client is still compatible the client was not replaced

func NewNetboxCompositeClient added in v0.2.38

func NewNetboxCompositeClient(clientV3 *NetboxClientV3, clientV4 *NetboxClientV4) *NetboxCompositeClient

NewNetboxCompositeClient creates a new composite client wrapping both v3 and v4 clients.

func (*NetboxCompositeClient) DeleteAsn added in v0.2.73

func (c *NetboxCompositeClient) DeleteAsn(ctx context.Context, asnId int64) (err error)

func (*NetboxCompositeClient) DeleteIpAddress added in v0.2.38

func (c *NetboxCompositeClient) DeleteIpAddress(ipAddressId int64) error

func (*NetboxCompositeClient) DeleteIpRange added in v0.2.38

func (c *NetboxCompositeClient) DeleteIpRange(ctx context.Context, ipRangeId int32) (err error)

func (*NetboxCompositeClient) DeleteL2VPN added in v0.2.72

func (c *NetboxCompositeClient) DeleteL2VPN(ctx context.Context, l2vpnId int64) (err error)

func (*NetboxCompositeClient) DeletePrefix added in v0.2.38

func (c *NetboxCompositeClient) DeletePrefix(ctx context.Context, prefixId int32) (err error)

func (*NetboxCompositeClient) GetAsnRangeRirName added in v0.2.73

func (c *NetboxCompositeClient) GetAsnRangeRirName(ctx context.Context, name string) (string, error)

GetAsnRangeRirName returns the name of the RIR the given ASN Range belongs to.

func (*NetboxCompositeClient) GetAvailableIpAddressByClaim added in v0.2.38

func (c *NetboxCompositeClient) GetAvailableIpAddressByClaim(ctx context.Context, ipAddressClaim *models.IPAddressClaim) (*models.IPAddress, error)

GetAvailableIpAddressByClaim searches an available IpAddress in Netbox matching IpAddressClaim requirements

func (*NetboxCompositeClient) GetAvailableIpAddressesByParentPrefix added in v0.2.38

func (c *NetboxCompositeClient) GetAvailableIpAddressesByParentPrefix(parentPrefixId int32) (*ipam.IpamPrefixesAvailableIpsListOK, error)

func (*NetboxCompositeClient) GetAvailableIpRangeByClaim added in v0.2.38

func (c *NetboxCompositeClient) GetAvailableIpRangeByClaim(ctx context.Context, ipRangeClaim *models.IpRangeClaim) (*models.IpRange, error)

GetAvailableIpRangeByClaim searches an available IpRange in Netbox matching IpRangeClaim requirements

func (*NetboxCompositeClient) GetAvailableL2VPNIdentifierByClaim added in v0.2.72

func (c *NetboxCompositeClient) GetAvailableL2VPNIdentifierByClaim(ctx context.Context, claim *models.L2VPNClaim) (*models.L2VPN, error)

GetAvailableL2VPNIdentifierByClaim searches for a free VNI in the range requested by claim, by listing L2VPNs of the claim's type already using an identifier within [claim.IdentifierRangeStart, claim.IdentifierRangeEnd] and returning the first gap.

func (*NetboxCompositeClient) GetAvailablePrefixByClaim added in v0.2.38

func (c *NetboxCompositeClient) GetAvailablePrefixByClaim(ctx context.Context, prefixClaim *models.PrefixClaim) (*models.Prefix, error)

GetAvailablePrefixByClaim searches an available Prefix in Netbox matching PrefixClaim requirements

func (*NetboxCompositeClient) GetAvailablePrefixesByParentPrefix added in v0.2.38

func (c *NetboxCompositeClient) GetAvailablePrefixesByParentPrefix(parentPrefixId int32) (*ipam.IpamPrefixesAvailablePrefixesListOK, error)

func (*NetboxCompositeClient) GetAvailablePrefixesByParentPrefixSelector added in v0.2.38

func (c *NetboxCompositeClient) GetAvailablePrefixesByParentPrefixSelector(ctx context.Context, prefixClaimSpec *netboxv1.PrefixClaimSpec) ([]*models.Prefix, error)

func (*NetboxCompositeClient) ReserveAvailableAsnByClaim added in v0.2.73

func (c *NetboxCompositeClient) ReserveAvailableAsnByClaim(ctx context.Context, asnClaim *models.ASNClaim) (asn *models.ASN, err error)

ReserveAvailableAsnByClaim allocates an ASN from the specified ASN Range. Unlike the IP address and prefix equivalents this already creates the object in NetBox.

func (*NetboxCompositeClient) ReserveOrUpdateAsn added in v0.2.73

func (c *NetboxCompositeClient) ReserveOrUpdateAsn(ctx context.Context, asn *models.ASN, asnV1 *netboxv1.Asn) (resp *v4client.ASN, isUpToDate bool, err error)

func (*NetboxCompositeClient) ReserveOrUpdateIpAddress added in v0.2.38

func (c *NetboxCompositeClient) ReserveOrUpdateIpAddress(ctx context.Context, ipAddress *models.IPAddress, ipAddressV1 *netboxv1.IpAddress) (resp *netboxModels.IPAddress, isUpToDate bool, err error)

func (*NetboxCompositeClient) ReserveOrUpdateIpRange added in v0.2.38

func (c *NetboxCompositeClient) ReserveOrUpdateIpRange(ctx context.Context, ipRange *models.IpRange, ipRangeV1 *netboxv1.IpRange) (resp *v4client.IPRange, isUpToDate bool, err error)

func (*NetboxCompositeClient) ReserveOrUpdateL2VPN added in v0.2.72

func (c *NetboxCompositeClient) ReserveOrUpdateL2VPN(ctx context.Context, l2vpn *models.L2VPN, l2vpnV1 *netboxv1.L2VPN) (resp *v4client.L2VPN, isUpToDate bool, err error)

func (*NetboxCompositeClient) ReserveOrUpdatePrefix added in v0.2.38

func (c *NetboxCompositeClient) ReserveOrUpdatePrefix(ctx context.Context, prefix *models.Prefix, prefixV1 *netboxv1.Prefix) (resp *v4client.Prefix, isUpToDate bool, err error)

ReserveOrUpdatePrefix creates or updates the prefix passed as parameter

func (*NetboxCompositeClient) RestoreExistingAsnByHash added in v0.2.73

func (c *NetboxCompositeClient) RestoreExistingAsnByHash(ctx context.Context, hash string) (*models.ASN, error)

func (*NetboxCompositeClient) RestoreExistingIpByHash added in v0.2.38

func (c *NetboxCompositeClient) RestoreExistingIpByHash(hash string) (*models.IPAddress, error)

func (*NetboxCompositeClient) RestoreExistingIpRangeByHash added in v0.2.38

func (c *NetboxCompositeClient) RestoreExistingIpRangeByHash(hash string) (*models.IpRange, error)

func (*NetboxCompositeClient) RestoreExistingL2VPNByHash added in v0.2.72

func (c *NetboxCompositeClient) RestoreExistingL2VPNByHash(ctx context.Context, hash string) (*models.L2VPN, error)

RestoreExistingL2VPNByHash searches for an existing NetBox L2VPN whose restoration hash custom field matches hash. Returns nil if none is found.

func (*NetboxCompositeClient) RestoreExistingPrefixByHash added in v0.2.38

func (c *NetboxCompositeClient) RestoreExistingPrefixByHash(hash string, requestedPrefixLength string) (*models.Prefix, error)

func (*NetboxCompositeClient) VerifyNetboxConfiguration added in v0.2.38

func (c *NetboxCompositeClient) VerifyNetboxConfiguration() error

Checks that the Netbox host is properly configured for the operator to function. Currently only checks that the required custom fields for IP address handling have been added.

type OverlapError added in v0.2.53

type OverlapError struct {
	Msg string
}

func (*OverlapError) Error added in v0.2.53

func (e *OverlapError) Error() string

type QueryFilter

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

func (*QueryFilter) WriteToRequest

func (o *QueryFilter) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error

Jump to

Keyboard shortcuts

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