Documentation
¶
Index ¶
- type InMemoryRegistry
- func (r *InMemoryRegistry) Delete(ctx context.Context, id uuid.UUID) error
- func (r *InMemoryRegistry) Get(ctx context.Context, id uuid.UUID) (*nvswitch.NVSwitchTray, error)
- func (r *InMemoryRegistry) GetByBMCMAC(ctx context.Context, bmcMAC string) (*nvswitch.NVSwitchTray, error)
- func (r *InMemoryRegistry) List(ctx context.Context) ([]*nvswitch.NVSwitchTray, error)
- func (r *InMemoryRegistry) Register(ctx context.Context, tray *nvswitch.NVSwitchTray) (uuid.UUID, bool, error)
- func (r *InMemoryRegistry) Start(ctx context.Context) error
- func (r *InMemoryRegistry) Stop(ctx context.Context) error
- type NVSwitchModel
- type PostgresRegistry
- func (r *PostgresRegistry) Delete(ctx context.Context, id uuid.UUID) error
- func (r *PostgresRegistry) Get(ctx context.Context, id uuid.UUID) (*nvswitch.NVSwitchTray, error)
- func (r *PostgresRegistry) GetByBMCMAC(ctx context.Context, bmcMAC string) (*nvswitch.NVSwitchTray, error)
- func (r *PostgresRegistry) List(ctx context.Context) ([]*nvswitch.NVSwitchTray, error)
- func (r *PostgresRegistry) Register(ctx context.Context, tray *nvswitch.NVSwitchTray) (uuid.UUID, bool, error)
- func (r *PostgresRegistry) Start(ctx context.Context) error
- func (r *PostgresRegistry) Stop(ctx context.Context) error
- type Registry
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) Get ¶
func (r *InMemoryRegistry) Get(ctx context.Context, id uuid.UUID) (*nvswitch.NVSwitchTray, error)
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 ¶
func (r *InMemoryRegistry) List(ctx context.Context) ([]*nvswitch.NVSwitchTray, error)
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.
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) Get ¶
func (r *PostgresRegistry) Get(ctx context.Context, id uuid.UUID) (*nvswitch.NVSwitchTray, error)
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 ¶
func (r *PostgresRegistry) List(ctx context.Context) ([]*nvswitch.NVSwitchTray, error)
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.
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.