broker

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: Apache-2.0 Imports: 31 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// KanodPoolnameAnnotation is the annotation containing the poolname value
	KanodPoolnameAnnotation string = "kanod.io/poolname"

	// KanodServernameAnnotation is the annotation containing the servername value
	KanodServernameAnnotation string = "kanod.io/servername"

	// KanodRedfishSchemaAnnotation is the annotation containing the redfish-schema value
	KanodRedfishSchemaAnnotation string = "kanod.io/redfish-schema"

	// NO_ERROR is given back when network assocation succeeds
	NO_ERROR ErrorCode = iota
	// CHECK_CERTIFICATE_ERROR is given back when certificate is wrong
	CHECK_CERTIFICATE_ERROR
	// OTHER_ERROR is an internal error
	OTHER_ERROR
)
View Source
const (
	ACCOUNTS_PATH = "/redfish/v1/AccountService/Accounts"
)

Variables

This section is empty.

Functions

func Sign added in v0.1.5

func Sign(challenge string, logger logr.Logger) (result string, err error)

func ValidateServerDataRequest

func ValidateServerDataRequest(serverValues ServerRequest) error

func Verify added in v0.1.5

func Verify(challenge string, signature string, logger logr.Logger) (err error)

Types

type Account added in v0.1.10

type Account struct {
	Id       string `json:"Id"`
	Name     string `json:"Name"`
	Password string `json:"Password"`
	UserName string `json:"UserName"`
	RoleId   string `json:"RoleId"`
	Locked   bool   `json:"Locked"`
	Enabled  bool   `json:"Enabled"`
}

Account is the go representation of a Redfish account

type AuthRequest

type AuthRequest struct {
	UserName string `json:"username"`
	Password string `json:"password"`
}

type Baremetal

type Baremetal struct {
	Id                             string               `json:"id"`
	Url                            string               `json:"url"`
	Username                       string               `json:"username"`
	Password                       string               `json:"password"`
	MacAddress                     string               `json:"macAddress"`
	K8sLabels                      map[string]string    `json:"k8slabels"`
	K8sAnnotations                 map[string]string    `json:"k8sannotations"`
	RootDeviceHints                *bmh.RootDeviceHints `json:"rootDeviceHints,omitempty"`
	DisableCertificateVerification bool                 `json:"disablecertificateverification"`
}

type Broker added in v0.1.10

type Broker struct {
	Client       client.Client
	Log          logr.Logger
	Scheme       *runtime.Scheme
	Baremetals   map[string]*Baremetal
	Pools        map[string]*Pool
	Users        map[string]*User
	Mutex        sync.Mutex
	Namespace    string
	BrokerImplem BrokerImplem
}

Broker implements a broker server that is used as a backend by BaremetalPools to retrieve access to servers

func NewBroker added in v0.1.10

func NewBroker(client client.Client, logr logr.Logger, scheme *runtime.Scheme, brokerImplem BrokerImplem) *Broker

NewBroker creates the structure associated to a redfish broker server.

func (*Broker) AddAnnotation added in v0.1.10

func (b *Broker) AddAnnotation(baremetalId string, namespace string, poolId string, serverId string, schema string) error

func (*Broker) BaremetalFound added in v0.1.10

func (b *Broker) BaremetalFound(name string) bool

func (*Broker) BookOne added in v0.1.10

func (b *Broker) BookOne(pool *Pool) bool

func (*Broker) CountUsage added in v0.1.10

func (b *Broker) CountUsage(user *User)

func (*Broker) CreateNewPool added in v0.1.10

func (b *Broker) CreateNewPool(pool Pool)

func (*Broker) CreateNewServer added in v0.1.10

func (b *Broker) CreateNewServer(poolId string, serverId string, baremetalName string, schema string)

func (*Broker) CreatePool added in v0.1.10

func (b *Broker) CreatePool(w http.ResponseWriter, r *http.Request)

func (*Broker) DeleteBaremetal added in v0.1.10

func (b *Broker) DeleteBaremetal(name string)

func (*Broker) DeletePool added in v0.1.10

func (b *Broker) DeletePool(poolId string, logger logr.Logger)

func (*Broker) DeleteServer added in v0.1.10

func (b *Broker) DeleteServer(serverId string, poolId string)

func (*Broker) DeleteUser added in v0.1.10

func (b *Broker) DeleteUser(userId string, logger logr.Logger)

func (*Broker) GetBaremetal added in v0.1.10

func (b *Broker) GetBaremetal(name string) *Baremetal

func (*Broker) GetPoolResponse added in v0.1.10

func (b *Broker) GetPoolResponse(poolId string) *PoolResponse

func (*Broker) GetServerResponse added in v0.1.10

func (b *Broker) GetServerResponse(name string, poolid string) *ServerResponse

func (*Broker) HandleBrokerApiRequests added in v0.1.10

func (b *Broker) HandleBrokerApiRequests()

func (*Broker) InitBrokerData added in v0.1.10

func (b *Broker) InitBrokerData(setupLog logr.Logger) error

func (*Broker) IsBrokerDataEmpty added in v0.1.10

func (b *Broker) IsBrokerDataEmpty() bool

func (*Broker) PoolFound added in v0.1.10

func (b *Broker) PoolFound(name string) bool

func (*Broker) ReleaseOne added in v0.1.10

func (b *Broker) ReleaseOne(pool *Pool)

func (*Broker) RetrieveAllBaremetals added in v0.1.10

func (b *Broker) RetrieveAllBaremetals() []Baremetal

func (*Broker) RetrieveAllPools added in v0.1.10

func (b *Broker) RetrieveAllPools() []PoolResponse

func (*Broker) RetrieveAllServers added in v0.1.10

func (b *Broker) RetrieveAllServers(poolId string) []ServerResponse

func (*Broker) ServerFound added in v0.1.10

func (b *Broker) ServerFound(name string, poolid string) bool

func (*Broker) UpdatePoolValues added in v0.1.10

func (b *Broker) UpdatePoolValues(name string, poolValues Pool)

func (*Broker) VerifyPoolAuthent added in v0.1.10

func (b *Broker) VerifyPoolAuthent(username string, password string, poolId string) bool

func (*Broker) VerifySignature added in v0.1.10

func (b *Broker) VerifySignature(w http.ResponseWriter, r *http.Request)

func (*Broker) VerifyUserAuthent added in v0.1.10

func (b *Broker) VerifyUserAuthent(username string, password string) bool

//////////////////////////////////////////////////////////////

type BrokerAuth added in v0.1.10

type BrokerAuth struct {
	Broker *Broker
}

BrokerAuth is the type of the implementation of a Redfish broker using ephemeral accounts to virtualize the BMC of a server.

func (*BrokerAuth) BookServer added in v0.1.10

func (bp *BrokerAuth) BookServer(pool *Pool, server *Baremetal) error

func (*BrokerAuth) CreateAccount added in v0.1.10

func (ba *BrokerAuth) CreateAccount(bmh *Baremetal, username string, password string) error

CreateAccount creates an account on a baremetal host. username and password are the credentials of the newly created account.

func (*BrokerAuth) FindAccount added in v0.1.10

func (ba *BrokerAuth) FindAccount(redfishClient *RedfishClient, username string) (string, error)

FindAccount

func (*BrokerAuth) GetComponents added in v0.1.10

func (ba *BrokerAuth) GetComponents(client *RedfishClient, target string) ([]string, error)

GetComponents gives back all the paths of a redfish collection.

func (*BrokerAuth) GetRedfishClient added in v0.1.10

func (ba *BrokerAuth) GetRedfishClient(bmh *Baremetal) (*RedfishClient, error)

GetRedfishClient builds a redfish client from a baremetalhost specification.

func (*BrokerAuth) Init added in v0.1.10

func (bp *BrokerAuth) Init(b *Broker, r *mux.Router)

func (*BrokerAuth) ReleaseServer added in v0.1.10

func (bp *BrokerAuth) ReleaseServer(pool *Pool, server *Baremetal) error

func (*BrokerAuth) RemoveAccount added in v0.1.10

func (ba *BrokerAuth) RemoveAccount(bmh *Baremetal, username string) error

RemoveAccount removes a redfish account on a baremetal host knowing the username of the account.

func (*BrokerAuth) ServerResponse added in v0.1.10

func (bp *BrokerAuth) ServerResponse(name string, poolid string) *ServerResponse

type BrokerData

type BrokerData struct {
	Baremetals map[string]*Baremetal
	Pools      map[string]*Pool
}

type BrokerImplem added in v0.1.10

type BrokerImplem interface {
	// Init initializes the specific implementation with the broker structure
	// and the base router so that new function can be provided.
	Init(b *Broker, r *mux.Router)
	// Synthesize the specific response for a given implementation.
	ServerResponse(serverId string, poolid string) *ServerResponse
	// Operations specific to an implementation performed when baremetal is booked.
	BookServer(pool *Pool, server *Baremetal) error
	// Operations specific to an implementation performed when baremetal is released
	ReleaseServer(pool *Pool, server *Baremetal) error
}

BrokerImplem is the inteface that hides the specific implementation of the proxy or the authentication back-end that creates accounts.

type BrokerProxy added in v0.1.10

type BrokerProxy struct {
	RedfishDomain string
	Broker        *Broker
}

BrokerProxy is the type of the implementation of a Redfish broker using a proxy to virtualize the BMC of servers.

func (*BrokerProxy) BookServer added in v0.1.10

func (bp *BrokerProxy) BookServer(pool *Pool, server *Baremetal) error

func (*BrokerProxy) Init added in v0.1.10

func (bp *BrokerProxy) Init(b *Broker, r *mux.Router)

func (*BrokerProxy) ReleaseServer added in v0.1.10

func (bp *BrokerProxy) ReleaseServer(pool *Pool, server *Baremetal) error

func (*BrokerProxy) ServerResponse added in v0.1.10

func (bp *BrokerProxy) ServerResponse(name string, poolid string) *ServerResponse

type ChallengeRequest added in v0.1.5

type ChallengeRequest struct {
	Challenge string `json:"challenge"`
}

type ChallengeResponse added in v0.1.5

type ChallengeResponse struct {
	Challenge       string `json:"challenge"`
	SignedChallenge string `json:"signedchallenge"`
}

type ErrorCode added in v0.1.5

type ErrorCode int

ErrorCode is the identification of the error

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
}

ErrorResponse is the standard error given back

type ErrorResponseNetdef added in v0.1.5

type ErrorResponseNetdef struct {
	Code    ErrorCode `json:"code"`
	Message string    `json:"message"`
}

ErrorResponseNetDef is the error message for network assocation

type Member added in v0.1.10

type Member struct {
	ODataId string `json:"@odata.id"`
}

Member is a member of a redfish collection

type PasswordData added in v0.1.11

type PasswordData struct {
	Password string
}

type PatchSpec

type PatchSpec struct {
	Op    string `json:"op"`
	Path  string `json:"path"`
	Value string `json:"value"`
}

PatchSpec is a typed JSON patch description

type Pool

type Pool struct {
	Id            string
	Username      string
	LabelSelector map[string]string
	MaxServers    int
	Servers       map[string]ServerData
	NetDefMap     map[string]string
}

type PoolLimit added in v0.1.10

type PoolLimit struct {
	Label   string
	Value   string
	Max     int
	Current int
}

func InitializeLimits added in v0.1.10

func InitializeLimits(limits []brokerv1.PoolLimit) []PoolLimit

type PoolRequest added in v0.1.10

type PoolRequest struct {
	Id            string            `json:"id"`
	LabelSelector map[string]string `json:"labelSelector"`
	MaxServers    int               `json:"maxServers"`
}

type PoolResponse

type PoolResponse struct {
	Id            string            `json:"id"`
	Username      string            `json:"username"`
	LabelSelector map[string]string `json:"labelSelector"`
	MaxServers    int               `json:"maxServers"`
	NetDefMap     map[string]string `json:"netDefMap"`
}

type RedfishClient added in v0.1.10

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

RedfishClient is the type of a specialized http.Client for Redfish It stores the target host and the credentials.

func (*RedfishClient) DoRequest added in v0.1.10

func (c *RedfishClient) DoRequest(method string, path string, body io.Reader) (*http.Response, error)

DoRequest performs an arbitrary http request using a RedfishClient.

type RedfishCollection added in v0.1.10

type RedfishCollection struct {
	Name    string `json:"Name"`
	Members []Member
}

RedfishCollection is the type of a collection of records in Redfish. It only contains pointers to the actual objects.

type ServerData

type ServerData struct {
	Id        string `json:"id"`
	Baremetal string `json:"baremetal"`
	Schema    string `json:"schema"`
}

type ServerRequest

type ServerRequest struct {
	Id     string `json:"id"`
	Schema string `json:"schema"`
}

type ServerResponse

type ServerResponse struct {
	Id                             string               `json:"id"`
	K8sLabels                      map[string]string    `json:"k8slabels"`
	K8sAnnotations                 map[string]string    `json:"k8sannotations"`
	Baremetal                      string               `json:"baremetal"`
	Url                            string               `json:"url"`
	MacAddress                     string               `json:"macAddress"`
	RootDeviceHints                *bmh.RootDeviceHints `json:"rootDeviceHints,omitempty"`
	DisableCertificateVerification bool                 `json:"disablecertificateverification"`
}

type SignatureRequest added in v0.1.5

type SignatureRequest struct {
	Challenge string `json:"challenge"`
	Signature string `json:"signature"`
}

type SignatureResponse added in v0.1.5

type SignatureResponse struct {
	SignatureVerified string `json:"signatureverified"`
}

type User added in v0.1.10

type User struct {
	Username       string
	Password       string
	MaxServers     int
	CurrentServers int
	Limits         []PoolLimit
}

Jump to

Keyboard shortcuts

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