nvswitchregistry

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InMemoryRegistry

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

InMemoryRegistry is an in-memory implementation of Registry.

func NewInMemoryRegistry

func NewInMemoryRegistry() *InMemoryRegistry

NewInMemoryRegistry creates a new in-memory registry.

func (*InMemoryRegistry) Delete

func (r *InMemoryRegistry) Delete(ctx context.Context, id uuid.UUID) error

Delete removes an NV-Switch by UUID.

func (*InMemoryRegistry) Get

Get retrieves an NV-Switch by UUID.

func (*InMemoryRegistry) GetByBMCMAC

func (r *InMemoryRegistry) GetByBMCMAC(ctx context.Context, bmcMAC string) (*nvswitch.NVSwitchTray, error)

GetByBMCMAC retrieves an NV-Switch by BMC MAC address.

func (*InMemoryRegistry) List

List returns all registered NV-Switches.

func (*InMemoryRegistry) Register

func (r *InMemoryRegistry) Register(ctx context.Context, tray *nvswitch.NVSwitchTray) (uuid.UUID, bool, error)

Register creates or updates an NV-Switch tray.

func (*InMemoryRegistry) Start

func (r *InMemoryRegistry) Start(ctx context.Context) error

Start initializes the registry.

func (*InMemoryRegistry) Stop

func (r *InMemoryRegistry) Stop(ctx context.Context) error

Stop cleans up the registry.

type NVSwitchModel

type NVSwitchModel struct {
	bun.BaseModel `bun:"table:nvswitch,alias:ns"`

	UUID           uuid.UUID `bun:"uuid,pk,type:uuid"`
	Vendor         int       `bun:"vendor,notnull"`
	BMCMACAddress  string    `bun:"bmc_mac_address,notnull"`
	BMCIPAddress   string    `bun:"bmc_ip_address,notnull"`
	BMCPort        int       `bun:"bmc_port,notnull,default:443"`
	NVOSMACAddress string    `bun:"nvos_mac_address,notnull"`
	NVOSIPAddress  string    `bun:"nvos_ip_address,notnull"`
	NVOSPort       int       `bun:"nvos_port,notnull,default:22"`
	RackID         string    `bun:"rack_id"`
}

NVSwitchModel is the database model for nvswitch table.

type PostgresRegistry

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

PostgresRegistry is a PostgreSQL-backed implementation of Registry.

func NewPostgresRegistry

func NewPostgresRegistry(db *bun.DB) *PostgresRegistry

NewPostgresRegistry creates a new PostgreSQL-backed registry.

func (*PostgresRegistry) Delete

func (r *PostgresRegistry) Delete(ctx context.Context, id uuid.UUID) error

Delete removes an NV-Switch by UUID.

func (*PostgresRegistry) Get

Get retrieves an NV-Switch by UUID.

func (*PostgresRegistry) GetByBMCMAC

func (r *PostgresRegistry) GetByBMCMAC(ctx context.Context, bmcMAC string) (*nvswitch.NVSwitchTray, error)

GetByBMCMAC retrieves an NV-Switch by BMC MAC address.

func (*PostgresRegistry) List

List returns all registered NV-Switches.

func (*PostgresRegistry) Register

func (r *PostgresRegistry) Register(ctx context.Context, tray *nvswitch.NVSwitchTray) (uuid.UUID, bool, error)

Register creates or updates an NV-Switch tray. The select (lookup by BMC MAC) and the resulting insert or update run in a single transaction to avoid races when two concurrent calls register the same tray.

func (*PostgresRegistry) Start

func (r *PostgresRegistry) Start(ctx context.Context) error

Start initializes the registry.

func (*PostgresRegistry) Stop

func (r *PostgresRegistry) Stop(ctx context.Context) error

Stop cleans up the registry.

type Registry

type Registry interface {
	Start(ctx context.Context) error
	Stop(ctx context.Context) error

	// Register creates a new NV-Switch entry or updates an existing one.
	// Returns the UUID and whether it was newly created.
	Register(ctx context.Context, tray *nvswitch.NVSwitchTray) (uuid.UUID, bool, error)

	// Get retrieves an NV-Switch by UUID.
	Get(ctx context.Context, id uuid.UUID) (*nvswitch.NVSwitchTray, error)

	// GetByBMCMAC retrieves an NV-Switch by BMC MAC address.
	GetByBMCMAC(ctx context.Context, bmcMAC string) (*nvswitch.NVSwitchTray, error)

	// List returns all registered NV-Switches.
	List(ctx context.Context) ([]*nvswitch.NVSwitchTray, error)

	// Delete removes an NV-Switch by UUID.
	Delete(ctx context.Context, id uuid.UUID) error
}

Registry defines the interface for NV-Switch tray storage.

Jump to

Keyboard shortcuts

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