wzlib_database_controller

package
v0.0.0-...-2af49ae Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OWNER_APP_REMOTE  = "remote"
	OWNER_APP_CTRL    = "controller"
	OWNER_APP_WORKER  = "worker"
	OWNER_APP_CLIENT  = "client"
	OWNER_APP_CLUSTER = "cluster"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type WzClient

type WzClient struct {
	ID     int    `gorm:"primary_key"`
	Uid    string `gorm:"unique; not null"`
	Fqdn   string `gorm:"unique; not null"`
	RsaPk  string `gorm:"unique; not null"`
	RsaFp  string
	Status int `gorm:"not null"`
}

WzClient entity object for the database

func NewWzClient

func NewWzClient() *WzClient

NewWzClient creates an instance of the WzClient

func NewWzClientFromPayload

func NewWzClientFromPayload(payload map[string]interface{}) *WzClient

NewWzClientFromPayload creates an instance of the WzClient and fills-in with the payload

func (*WzClient) SetFingerprint

func (wcl *WzClient) SetFingerprint() *WzClient

SetFingerprint calculates and sets the fingerprint from the RSA key

type WzControllerDbh

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

WzControllerDbh class bundle

func NewWzControllerDbh

func NewWzControllerDbh() *WzControllerDbh

NewWzControllerDbh creates a new instances of the WzControllerDbh

func (*WzControllerDbh) GetClientsAPI

func (wcd *WzControllerDbh) GetClientsAPI() *WzCtrlClientsAPI

GetClientsAPI returns an API bundle to access Client facility

func (*WzControllerDbh) GetKeysAPI

func (wcd *WzControllerDbh) GetKeysAPI() *WzCtrlKeysAPI

GetKeysAPI returns an API bundle to store/retrieve/search for the PEM keys

func (*WzControllerDbh) SetDbh

func (wcd *WzControllerDbh) SetDbh(dbh *gorm.DB)

SetDbh sets database handler to all the sub-objects

type WzCtrlClientsAPI

type WzCtrlClientsAPI struct {
	wzlib_logger.WzLogger
	// contains filtered or unexported fields
}

Everything with client

func NewWzCtrlClientsAPI

func NewWzCtrlClientsAPI() *WzCtrlClientsAPI

func (*WzCtrlClientsAPI) Accept

func (wcc *WzCtrlClientsAPI) Accept(fingerprints ...string) (missing []string)

Accept that was already registered. Accepetation means flipping status and it will be "OK, now you are in". This makes client listable for the workers. But the reconciliation needs to be extra called elsewhere.

func (*WzCtrlClientsAPI) Delete

func (wcc *WzCtrlClientsAPI) Delete(fingerprints ...string) (missing []string)

Delete just deletes everything of the client. This client is eligible to be registered again.

func (*WzCtrlClientsAPI) GetByFQDN

func (wcc *WzCtrlClientsAPI) GetByFQDN()

GetByFQDN returns client data (struct?) by FQDN

func (*WzCtrlClientsAPI) GetByFp

func (wcc *WzCtrlClientsAPI) GetByFp()

GetByFp returns client data (struct?) by RSA fingerprint

func (*WzCtrlClientsAPI) GetByUid

func (wcc *WzCtrlClientsAPI) GetByUid()

GetByUid returns client data (struct?) by system ID

func (*WzCtrlClientsAPI) GetRegistered

func (wcc *WzCtrlClientsAPI) GetRegistered() []*WzClient

GetRegistered returns a list of new clients

func (*WzCtrlClientsAPI) GetRegisteredAmount

func (wcc *WzCtrlClientsAPI) GetRegisteredAmount() int64

GetRegisteredAmount returns an amout of registered clients

func (*WzCtrlClientsAPI) GetRejected

func (wcc *WzCtrlClientsAPI) GetRejected() []*WzClient

GetRejected returns a list of new clients

func (*WzCtrlClientsAPI) Register

func (wcc *WzCtrlClientsAPI) Register(client *WzClient) int

Register register a client that just appeared. Registration means "Your public RSA is in the database, now wait"

func (*WzCtrlClientsAPI) Reject

func (wcc *WzCtrlClientsAPI) Reject(fingerprints ...string) (missing []string)

Reject sets its status as "rejected", but keeps in the database everything: FQDN, machine ID and RSA pubkey. Used for black-listing.

func (*WzCtrlClientsAPI) Search

func (wcc *WzCtrlClientsAPI) Search(query string) []*WzClient

Search for clients based on specific query

func (*WzCtrlClientsAPI) Set

func (wcc *WzCtrlClientsAPI) Set()

Set sets/updates/adds client's status (struct?). This does not include traits.

func (*WzCtrlClientsAPI) UpdateClientTraits

func (wcc *WzCtrlClientsAPI) UpdateClientTraits()

UpdateTraits adds/sets/updates client's traits

type WzCtrlKeysAPI

type WzCtrlKeysAPI struct {
	wzlib_logger.WzLogger
	// contains filtered or unexported fields
}

func NewWzCtrlKeysAPI

func NewWzCtrlKeysAPI() *WzCtrlKeysAPI

func (*WzCtrlKeysAPI) AddRSAKeypairPEM

func (wck *WzCtrlKeysAPI) AddRSAKeypairPEM(pub []byte, priv []byte, machineid string, fqdn string, owner string) error

func (*WzCtrlKeysAPI) AddRSAPublicPEM

func (wck *WzCtrlKeysAPI) AddRSAPublicPEM(keypem []byte, machineid string, fqdn string, owner string) error

AddRSAPublicPEM returns client's RSA public key in PEM format, queried by the machine ID. the fqdn is to merely indicate what machine is holding it, but the key is tied up to the machine ID.

func (*WzCtrlKeysAPI) GetRSAPublicPEMByFingerprint

func (wck *WzCtrlKeysAPI) GetRSAPublicPEMByFingerprint(fingerprint string) []byte

GetRSAPublicPEMByFingerprint returns a public key body

func (*WzCtrlKeysAPI) ListRSAPublicPEMByOwner

func (wck *WzCtrlKeysAPI) ListRSAPublicPEMByOwner(owner string) []*WzPEMKeyEntity

ListRSAPublicPEM returns a list of registered public RSA keys, filtered by owner app.

func (*WzCtrlKeysAPI) RemoveRSAKeyPEM

func (wck *WzCtrlKeysAPI) RemoveRSAKeyPEM(fingerprint string) error

RemoveRSAKeyPEM from the database by full fingerprint

type WzCtrlWorkersAPI

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

func NewWzCtrlWorkersAPI

func NewWzCtrlWorkersAPI() *WzCtrlWorkersAPI

func (*WzCtrlWorkersAPI) Activate

func (cwa *WzCtrlWorkersAPI) Activate()

Activate a worker. This should return a reasonable timeout after which Reconcile() is called. If Activate is called again (new worker is in), then the previous timeout for the entire reconciliation is updated with this one

func (*WzCtrlWorkersAPI) Add

func (cwa *WzCtrlWorkersAPI) Add()

Add worker to the cluster (keeps empty, needs reconciliation)

func (*WzCtrlWorkersAPI) AssignClients

func (cwa *WzCtrlWorkersAPI) AssignClients()

AssignClients will assign clients to the worker

func (*WzCtrlWorkersAPI) Deactivate

func (cwa *WzCtrlWorkersAPI) Deactivate()

Deactivate a worker (reconciles the cluster)

func (*WzCtrlWorkersAPI) GetAll

func (cwa *WzCtrlWorkersAPI) GetAll()

GetAll workers

func (*WzCtrlWorkersAPI) GetAssignedClients

func (cwa *WzCtrlWorkersAPI) GetAssignedClients()

GetAssignedClients per a worker

func (*WzCtrlWorkersAPI) Reconcile

func (cwa *WzCtrlWorkersAPI) Reconcile()

Reconcile the whole cluster. This gets to each worker and reassigns clients to work with. Each worker works only with assigned clients and every time there might be a new clients, it never met before. Worker, essentially, a job proxy.

The reconsiliation algorithm is to shift as little as possible of clients, so only necessary machines are re-assigned to another worker.

func (*WzCtrlWorkersAPI) Remove

func (cwa *WzCtrlWorkersAPI) Remove()

Remove worker from the cluster (unassign everything)

func (*WzCtrlWorkersAPI) UnassignClients

func (cwa *WzCtrlWorkersAPI) UnassignClients()

UnassignClients from the worker

type WzPEMKeyEntity

type WzPEMKeyEntity struct {
	ID         int    `gorm:"primary_key"`
	RsaFp      string `gorm:"unique; not null"`
	RsaPk      []byte `gorm:"unique; not null"`
	RsaPrivKey []byte
	MachineId  string `gorm:"unique"`
	Fqdn       string `gorm:"unique"`
	Owner      string `gorm:"not null"`
	Type       string `gorm:"not null"`
}

WzPEMKeyEntity entity object for the database of PEM keys

Jump to

Keyboard shortcuts

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