storage

package
v1.1.46-poll Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

README

MergeTB Portal Storage

This is the storage library for creating persistent objects in a MergeTB portal. Support for managing objects in both etcd and MinIO is provided.

Consistency

There are two types of locks that ensure data consistency

  • Optimistic locks based on object revisions.
  • Distributed locks implemented by etcd.

In almost all situations optimistic locking is to be used and is done automatically by the etcdTx and minioTx functions respectively. The only time distributed locks should be used is for truly global state. An example is UID and PID counters. Because such objects are singular entities at global scope, the probability for conflicts is high. All objects with multiplicity however, such as users, projects, experiments etc. should be optimistically locked.

Documentation

Index

Constants

View Source
const (
	VlanMergeReserved  = 100  // reserved for Merge
	VlanSwitchReserved = 1000 // reserved for Cumulus
	VlanMax            = 1<<12 - 1 - VlanSwitchReserved
	VlanMin            = VlanMergeReserved
	VtepMergeReserved  = 100 // reserved for Merge
	VtepSwitchReserved = 0
	VtepMax            = 1<<24 - 1 - VtepSwitchReserved
	VtepMin            = VtepMergeReserved
)

Variables

View Source
var EtcdClient *clientv3.Client
View Source
var MinIOClient *minio.Client

Functions

func CreateFacilityModel

func CreateFacilityModel(name string, m *xir.Facility) error

Model CRUD

func DeleteEnclaveWgIfreqs added in v1.1.38

func DeleteEnclaveWgIfreqs(enclave string) error

func DeleteEndpoints

func DeleteEndpoints(rlz *portal.Realization) error

DeleteEndpoints removes the etcd keys containing the emulation endpoint count for a realization

func DeleteMaterialization

func DeleteMaterialization(pid, eid, rid string) error

func EnsureVlistBucket

func EnsureVlistBucket() error

func InitPortalEtcdClient

func InitPortalEtcdClient() error

func InitPortalMinIOClient

func InitPortalMinIOClient() error

func IsValidMaterializationName added in v1.1.28

func IsValidMaterializationName(pid, eid, rid string) error

IsValidMaterializationName - return an error if the given component names would create an invalid mtz name.

func ListWgIfreqs added in v1.1.38

func ListWgIfreqs() (map[string][]*WgIfRequest, error)

func ReadBlockPool

func ReadBlockPool(b *BlockPool) error

func ReadBlockPoolAllocations

func ReadBlockPoolAllocations(b []*BlockPoolAllocations) error

func ReadExperiments

func ReadExperiments(es []*Experiment) error

func ReadFacilities

func ReadFacilities(fs []*Facility) error

func ReadFacilityModel

func ReadFacilityModel(name string) (*xir.Facility, error)

func ReadMaterialization

func ReadMaterialization(pid, eid, rid string) (*portal.Materialization, error)

func ReadOrganizations added in v1.1.22

func ReadOrganizations(orgs []*Organization) error

Read the organization data for the given organizations.

func ReadProjects

func ReadProjects(ps []*Project) error

Read the project data for the given projects.

func ReadRealizationResult

func ReadRealizationResult(project, experiment, realization string) (*portal.RealizationResult, error)

func ReadRealizeRequests

func ReadRealizeRequests(rs []*RealizeRequest) error

ReadRealizeRequests will read the given realization requests

func ReadUsers

func ReadUsers(users []*User) error

func RecordEndpoints

func RecordEndpoints(rlz *portal.Realization) error

RecordEndpoints stores the number of endpoints on the emulation server used for a realization. This information is used by the realization engine to load balance materializations across multiple emulation servers.

func SaveMaterialization

func SaveMaterialization(mtz *portal.Materialization) error

func UpdateFacilityModel

func UpdateFacilityModel(rq *portal.UpdateFacilityRequest) error

func UserExists added in v1.1.22

func UserExists(username string) bool

func WriteRealizationResult added in v1.1.40

func WriteRealizationResult(r *portal.RealizationResult) error

func XdcId

func XdcId(name, project string) string

The canonical way to name an xdc.

func XpPathSplit

func XpPathSplit(path string) (string, string, error)

TODO this is a bit gross..... /experiments/<proj>/<experiment> -> <experiment> <project>

Types

type BlockPool

type BlockPool struct {
	*portal.BlockPool
	// contains filtered or unexported fields
}

The max size of this data structure should be 1024 address blocks times 15 characters max per address ~15KB, so should be safe for etcd.

func FetchBlockPool

func FetchBlockPool() (*BlockPool, error)

func NewBlockPool

func NewBlockPool() *BlockPool

func (*BlockPool) Bucket

func (x *BlockPool) Bucket() string

func (*BlockPool) GetVersion

func (x *BlockPool) GetVersion() int64

func (*BlockPool) Id

func (x *BlockPool) Id() string

func (*BlockPool) Key

func (x *BlockPool) Key() string

func (*BlockPool) SetVersion

func (x *BlockPool) SetVersion(v int64)

func (*BlockPool) Substrate

func (x *BlockPool) Substrate() Substrate

func (*BlockPool) Value

func (x *BlockPool) Value() interface{}

type BlockPoolAllocations

type BlockPoolAllocations struct {
	*portal.BlockPoolAllocations
	// contains filtered or unexported fields
}

func FetchBlockPoolAllocations

func FetchBlockPoolAllocations(id string) (*BlockPoolAllocations, error)

func NewBlockPoolAllocations

func NewBlockPoolAllocations(id string) *BlockPoolAllocations

func (*BlockPoolAllocations) Bucket

func (x *BlockPoolAllocations) Bucket() string

func (*BlockPoolAllocations) GetVersion

func (x *BlockPoolAllocations) GetVersion() int64

func (*BlockPoolAllocations) Id

func (x *BlockPoolAllocations) Id() string

func (*BlockPoolAllocations) Key

func (x *BlockPoolAllocations) Key() string

func (*BlockPoolAllocations) SetVersion

func (x *BlockPoolAllocations) SetVersion(v int64)

func (*BlockPoolAllocations) Substrate

func (x *BlockPoolAllocations) Substrate() Substrate

func (*BlockPoolAllocations) Value

func (x *BlockPoolAllocations) Value() interface{}

type Counter

type Counter struct {
	internal.CountSet
}

func NewCounter

func NewCounter(name string, size, offset uint64) *Counter

func (*Counter) Bucket

func (c *Counter) Bucket() string

func (*Counter) Create

func (c *Counter) Create() (*Rollback, error)

func (*Counter) Delete

func (c *Counter) Delete() (*Rollback, error)

func (*Counter) Free

func (c *Counter) Free(v uint64) error

func (*Counter) GetVersion

func (c *Counter) GetVersion() int64

func (*Counter) Id

func (c *Counter) Id() string

func (*Counter) Key

func (c *Counter) Key() string

func (*Counter) Next

func (c *Counter) Next() (uint64, error)

func (*Counter) Read

func (c *Counter) Read() error

func (*Counter) SetVersion

func (c *Counter) SetVersion(v int64)

func (*Counter) Substrate

func (c *Counter) Substrate() Substrate

func (*Counter) Update

func (c *Counter) Update() (*Rollback, error)

func (*Counter) Value

func (c *Counter) Value() interface{}

type EmuServers added in v1.1.2

type EmuServers map[string]int

Stores the number of endpoints each network emulation server is processing

func GetEmuServers added in v1.1.2

func GetEmuServers(nodes []string) (EmuServers, error)

Returns a map with the number of endpoints on each requested emulation server

func (EmuServers) Alloc added in v1.1.2

func (s EmuServers) Alloc(count int) string

Alloc requests an emulation server with "count" endpoints

type EtcdRollback

type EtcdRollback func() (*clientv3.TxnResponse, error)

type Experiment

type Experiment struct {
	*portal.Experiment
	UpdateRequest *portal.UpdateExperimentRequest
}

func NewExperiment

func NewExperiment(name, project string) *Experiment

func (*Experiment) AddCompilation

func (e *Experiment) AddCompilation(revision string, comp_err error) error

func (*Experiment) Bucket

func (e *Experiment) Bucket() string

func (*Experiment) Create

func (e *Experiment) Create() (*Rollback, error)

func (*Experiment) Delete

func (e *Experiment) Delete() (*Rollback, error)

func (*Experiment) DeleteLinkedOps

func (e *Experiment) DeleteLinkedOps(tc *TransactionCache) ([]StorOp, error)

Get the storage ops that should be transacted when an experiment is deleted. The existing writeOp users are passed in and should be modified in place.

func (*Experiment) DeleteLinkedOpsUsers added in v1.1.22

func (e *Experiment) DeleteLinkedOpsUsers(projUsers []ObjectIO) ([]StorOp, error)

Get the storage ops that should be transacted when an experiment is deleted. The existing writeOp users are passed in and should be modified in place.

func (*Experiment) GetVersion

func (e *Experiment) GetVersion() int64

func (*Experiment) Id

func (e *Experiment) Id() string

func (*Experiment) Key

func (e *Experiment) Key() string

func (*Experiment) Read

func (e *Experiment) Read() error

func (*Experiment) ReadExperimentModel

func (e *Experiment) ReadExperimentModel(revision string) (*portal.XpNetModel, string, error)

func (*Experiment) ReadExperimentModels

func (e *Experiment) ReadExperimentModels() (map[string]*portal.XpNetModel, error)

func (*Experiment) SetVersion

func (e *Experiment) SetVersion(v int64)

func (*Experiment) Substrate

func (e *Experiment) Substrate() Substrate

func (*Experiment) Update

func (e *Experiment) Update() (*Rollback, error)

func (*Experiment) Value

func (e *Experiment) Value() interface{}

type Facility

type Facility struct {
	*portal.Facility
	UpdateRequest *portal.UpdateFacilityRequest
}

func ListFacilities

func ListFacilities() ([]*Facility, error)

func NewFacility

func NewFacility(name string) *Facility

func (*Facility) Bucket

func (f *Facility) Bucket() string

func (*Facility) Create

func (f *Facility) Create() (*Rollback, error)

func (*Facility) Delete

func (f *Facility) Delete() (*Rollback, error)

func (*Facility) GetVersion

func (f *Facility) GetVersion() int64

func (*Facility) Id

func (f *Facility) Id() string

func (*Facility) Key

func (f *Facility) Key() string

func (*Facility) Read

func (f *Facility) Read() error

func (*Facility) SetVersion

func (f *Facility) SetVersion(v int64)

func (*Facility) Substrate

func (f *Facility) Substrate() Substrate

func (*Facility) Update

func (f *Facility) Update() (*Rollback, error)

func (*Facility) Value

func (f *Facility) Value() interface{}

type InitHarborRequest

type InitHarborRequest struct {
	*portal.InitHarborRequest
}

func NewInitHarborRequest

func NewInitHarborRequest(facility string) *InitHarborRequest

func (*InitHarborRequest) Bucket

func (i *InitHarborRequest) Bucket() string

func (*InitHarborRequest) Create

func (r *InitHarborRequest) Create() (*Rollback, error)

func (*InitHarborRequest) Delete

func (r *InitHarborRequest) Delete() (*Rollback, error)

func (*InitHarborRequest) GetVersion

func (i *InitHarborRequest) GetVersion() int64

func (*InitHarborRequest) Id

func (i *InitHarborRequest) Id() string

func (*InitHarborRequest) Key

func (i *InitHarborRequest) Key() string

func (*InitHarborRequest) SetVersion

func (i *InitHarborRequest) SetVersion(v int64)

func (*InitHarborRequest) Substrate

func (i *InitHarborRequest) Substrate() Substrate

func (*InitHarborRequest) Value

func (i *InitHarborRequest) Value() interface{}

type JupyterCfg

type JupyterCfg struct {
	*portal.JupyterCfg
	// contains filtered or unexported fields
}

func NewJupyterCfg

func NewJupyterCfg(host string) *JupyterCfg

func (*JupyterCfg) Bucket

func (j *JupyterCfg) Bucket() string

func (*JupyterCfg) Create

func (j *JupyterCfg) Create() (*Rollback, error)

func (*JupyterCfg) Delete

func (j *JupyterCfg) Delete() (*Rollback, error)

func (*JupyterCfg) GetVersion

func (j *JupyterCfg) GetVersion() int64

func (*JupyterCfg) Id

func (j *JupyterCfg) Id() string

func (*JupyterCfg) Key

func (j *JupyterCfg) Key() string

func (*JupyterCfg) Read

func (j *JupyterCfg) Read() error

func (*JupyterCfg) SetVersion

func (j *JupyterCfg) SetVersion(v int64)

func (*JupyterCfg) Substrate

func (j *JupyterCfg) Substrate() Substrate

func (*JupyterCfg) Update

func (j *JupyterCfg) Update() (*Rollback, error)

func (*JupyterCfg) Value

func (j *JupyterCfg) Value() interface{}

type Lock

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

func (*Lock) Unlock

func (lk *Lock) Unlock() error

type Locks

type Locks []*Lock

func (Locks) Unlock

func (lks Locks) Unlock() []error

type MaterializeRequest

type MaterializeRequest struct {
	*portal.MaterializeRequest
}

func ListMaterializeRequests added in v1.1.38

func ListMaterializeRequests() ([]*MaterializeRequest, error)

func NewMaterializeRequest

func NewMaterializeRequest(name, experiment, project string) *MaterializeRequest

func (*MaterializeRequest) Bucket

func (m *MaterializeRequest) Bucket() string

func (*MaterializeRequest) Create

func (m *MaterializeRequest) Create() (*Rollback, error)

func (*MaterializeRequest) Delete

func (m *MaterializeRequest) Delete() (*Rollback, error)

func (*MaterializeRequest) DeleteLinkedOps

func (m *MaterializeRequest) DeleteLinkedOps() ([]StorOp, error)

func (*MaterializeRequest) GetVersion

func (m *MaterializeRequest) GetVersion() int64

func (*MaterializeRequest) Id

func (m *MaterializeRequest) Id() string

func (*MaterializeRequest) Key

func (m *MaterializeRequest) Key() string

func (*MaterializeRequest) Read

func (m *MaterializeRequest) Read() error

func (*MaterializeRequest) SetVersion

func (m *MaterializeRequest) SetVersion(v int64)

func (*MaterializeRequest) Substrate

func (m *MaterializeRequest) Substrate() Substrate

func (*MaterializeRequest) Value

func (m *MaterializeRequest) Value() interface{}

type Object

type Object interface {
	ObjectIO
	Create() (*Rollback, error)
	Read() error
	Update() (*Rollback, error)
	Delete() (*Rollback, error)
}

type ObjectIO

type ObjectIO interface {
	Bucket() string //XXX
	Id() string     //XXX
	Key() string
	Value() interface{}
	Substrate() Substrate //XXX
	GetVersion() int64
	SetVersion(int64)
}

TODO the original idea here was for the object interface to pull double transaction duty with etcd and minio, but this did not really pan out and we just wound up using it for etcd, so i think we can remove the minio specific trappings

type Operation

type Operation int
const (
	Read Operation = iota + 1
	Write
	Delete
)

type Organization added in v1.1.22

type Organization struct {
	*portal.Organization
	UpdateRequest *portal.UpdateOrganizationRequest
}

func ListOrganizations added in v1.1.22

func ListOrganizations() ([]*Organization, error)

Return a list of all organizations.

func NewOrganization added in v1.1.22

func NewOrganization(name string) *Organization

func (*Organization) Bucket added in v1.1.22

func (o *Organization) Bucket() string

func (*Organization) Create added in v1.1.22

func (o *Organization) Create() (*Rollback, error)

func (*Organization) Delete added in v1.1.22

func (o *Organization) Delete() (*Rollback, error)

func (*Organization) DeleteLinkedOps added in v1.1.22

func (o *Organization) DeleteLinkedOps(tc *TransactionCache) ([]StorOp, error)

func (*Organization) GetVersion added in v1.1.22

func (o *Organization) GetVersion() int64

func (*Organization) Id added in v1.1.22

func (o *Organization) Id() string

func (*Organization) Key added in v1.1.22

func (o *Organization) Key() string

func (*Organization) Read added in v1.1.22

func (o *Organization) Read() error

func (*Organization) SetVersion added in v1.1.22

func (o *Organization) SetVersion(v int64)

func (*Organization) Substrate added in v1.1.22

func (o *Organization) Substrate() Substrate

func (*Organization) Update added in v1.1.22

func (o *Organization) Update() (*Rollback, error)

func (*Organization) Value added in v1.1.22

func (o *Organization) Value() interface{}

type Pool

type Pool struct {
	//
	*portal.Pool

	// modify this, then call Update() to update the pool
	PoolUpdate *portal.Pool
}

func GetOrganizationPool added in v1.1.22

func GetOrganizationPool(organization string) *Pool

func GetPools

func GetPools() ([]*Pool, error)

func GetProjectPool added in v1.0.4

func GetProjectPool(project string) *Pool

func NewPool

func NewPool(name string) *Pool

func (*Pool) AddFacility added in v1.0.4

func (p *Pool) AddFacility(facility string, resources []string) (*Rollback, error)

func (*Pool) AddOrganization added in v1.1.22

func (p *Pool) AddOrganization(organization string) (*Rollback, error)

func (*Pool) AddProject

func (p *Pool) AddProject(project string) (*Rollback, error)

utils

func (*Pool) Bucket

func (p *Pool) Bucket() string

func (*Pool) Create

func (p *Pool) Create() (*Rollback, error)

func (*Pool) Delete

func (p *Pool) Delete() (*Rollback, error)

func (*Pool) GetVersion

func (p *Pool) GetVersion() int64

func (*Pool) Id

func (p *Pool) Id() string

func (*Pool) Key

func (p *Pool) Key() string

func (*Pool) Read

func (p *Pool) Read() error

func (*Pool) RemoveFacility added in v1.0.4

func (p *Pool) RemoveFacility(facility string) (*Rollback, error)

func (*Pool) RemoveOrganization added in v1.1.22

func (p *Pool) RemoveOrganization(organization string) (*Rollback, error)

func (*Pool) RemoveProject

func (p *Pool) RemoveProject(project string) (*Rollback, error)

func (*Pool) SetVersion

func (p *Pool) SetVersion(ver int64)

func (*Pool) Substrate

func (p *Pool) Substrate() Substrate

func (*Pool) Update

func (p *Pool) Update() (*Rollback, error)

func (*Pool) UpdateResources added in v1.0.4

func (p *Pool) UpdateResources(facility string, resources []string, strat *portal.PatchStrategy) (*Rollback, error)

func (*Pool) Value

func (p *Pool) Value() interface{}

type PortalConfig

type PortalConfig struct {
	Config struct {
		APIEndpoint     string `json:"api_endpoint"`
		GRPCEndpoint    string `json:"grpc_endpoint"`
		SSHJumpEndpoint string `json:"sshjump_endpoint"`
		Ver             int64  `json:"ver"`
		Reconcile       struct {
			HeartbeatIntervalSec    int64 `json:"heartbeat_interval_sec,omitempty"`
			HeartbeatGracePeriodSec int64 `json:"heartbeat_grace_period_sec,omitempty"`
		}

		Institutions []string `json:"institutions"`

		// User categories
		Categories []string `json:"categories"`

		// Types points to list of subtypes.
		EntityTypes map[string][]string `json:"entitytypes"`
	}
	Ver int64
}

func GetPortalConfig

func GetPortalConfig() (*PortalConfig, error)

func (*PortalConfig) Bucket

func (c *PortalConfig) Bucket() string

func (*PortalConfig) Create

func (c *PortalConfig) Create() (*Rollback, error)

func (*PortalConfig) Delete

func (c *PortalConfig) Delete() (*Rollback, error)

func (*PortalConfig) GetVersion

func (c *PortalConfig) GetVersion() int64

func (*PortalConfig) Id

func (c *PortalConfig) Id() string

func (*PortalConfig) Key

func (c *PortalConfig) Key() string

func (*PortalConfig) Marshal

func (c *PortalConfig) Marshal() ([]byte, error)

func (*PortalConfig) Read

func (c *PortalConfig) Read() error

func (*PortalConfig) SetVersion

func (c *PortalConfig) SetVersion(v int64)

func (*PortalConfig) Substrate

func (c *PortalConfig) Substrate() Substrate

func (*PortalConfig) Unmarshal

func (c *PortalConfig) Unmarshal(b []byte) error

func (*PortalConfig) Update

func (c *PortalConfig) Update() (*Rollback, error)

func (*PortalConfig) Value

func (c *PortalConfig) Value() interface{}

type Project

type Project struct {
	*portal.Project
	UpdateRequest *portal.UpdateProjectRequest
}

func ListProjects

func ListProjects() ([]*Project, error)

Return a list of all projects.

func NewProject

func NewProject(name string) *Project

func (*Project) Bucket

func (p *Project) Bucket() string

func (*Project) Create

func (p *Project) Create() (*Rollback, error)

func (*Project) Delete

func (p *Project) Delete() (*Rollback, error)

func (*Project) DeleteLinkedOps added in v1.1.22

func (p *Project) DeleteLinkedOps(tc *TransactionCache) ([]StorOp, error)

func (*Project) GetVersion

func (p *Project) GetVersion() int64

func (*Project) Id

func (p *Project) Id() string

func (*Project) Key

func (p *Project) Key() string

func (*Project) Read

func (p *Project) Read() error

func (*Project) SetVersion

func (p *Project) SetVersion(v int64)

func (*Project) Substrate

func (p *Project) Substrate() Substrate

func (*Project) Update

func (p *Project) Update() (*Rollback, error)

func (*Project) Value

func (p *Project) Value() interface{}

type PublicKey

type PublicKey struct {
	*portal.PublicKey
	User string // to whom does this pubkey belong? only used for constructing etcd keys
	Ver  int64  // not stored, is that OK?
}

func ListUserPublicKeys

func ListUserPublicKeys(user string) ([]*PublicKey, error)

Return a list of all keys for the specified user

func NewPublicKey

func NewPublicKey(user string, fingerprint string) *PublicKey

func (*PublicKey) Bucket

func (p *PublicKey) Bucket() string

func (*PublicKey) Create

func (p *PublicKey) Create() (*Rollback, error)

func (*PublicKey) Delete

func (p *PublicKey) Delete() (*Rollback, error)

func (*PublicKey) GetVersion

func (p *PublicKey) GetVersion() int64

func (*PublicKey) Id

func (p *PublicKey) Id() string

func (*PublicKey) Key

func (p *PublicKey) Key() string

func (*PublicKey) Read

func (p *PublicKey) Read() error

func (*PublicKey) SetVersion

func (p *PublicKey) SetVersion(v int64)

func (*PublicKey) Substrate

func (p *PublicKey) Substrate() Substrate

func (*PublicKey) Update

func (p *PublicKey) Update() (*Rollback, error)

func (*PublicKey) Value

func (p *PublicKey) Value() interface{}

type RbStack

type RbStack []*Rollback

func (RbStack) Pop

func (rbs RbStack) Pop() (*Rollback, RbStack)

func (RbStack) Push

func (rbs RbStack) Push(rb *Rollback) RbStack

func (RbStack) PushAll added in v1.1.22

func (rbs RbStack) PushAll(rs RbStack) RbStack

func (RbStack) Unwind

func (rbs RbStack) Unwind() error

type RealizeRequest

type RealizeRequest struct {
	*portal.RealizeRequest
}

func GetAllRealizationRequests added in v1.1.40

func GetAllRealizationRequests() ([]*RealizeRequest, error)

GetAllRealizations will read all realization requests in the database and return the values.

func NewRealizeRequest

func NewRealizeRequest(name, experiment, project string) *RealizeRequest

func (*RealizeRequest) Bucket

func (r *RealizeRequest) Bucket() string

func (*RealizeRequest) Create

func (r *RealizeRequest) Create() (*Rollback, error)

func (*RealizeRequest) Delete

func (r *RealizeRequest) Delete() (*Rollback, error)

func (*RealizeRequest) DeleteLinkedOps

func (r *RealizeRequest) DeleteLinkedOps() ([]StorOp, error)

func (*RealizeRequest) GetVersion

func (r *RealizeRequest) GetVersion() int64

func (*RealizeRequest) Id

func (r *RealizeRequest) Id() string

func (*RealizeRequest) Key

func (r *RealizeRequest) Key() string

func (*RealizeRequest) Read

func (r *RealizeRequest) Read() error

func (*RealizeRequest) SetVersion

func (r *RealizeRequest) SetVersion(v int64)

func (*RealizeRequest) Substrate

func (r *RealizeRequest) Substrate() Substrate

func (*RealizeRequest) Value

func (r *RealizeRequest) Value() interface{}

type Rollback

type Rollback struct {
	Etcd EtcdRollback
}

func ReadVsets

func ReadVsets(vs []*Vset) (*Rollback, error)

func WriteBlockPool

func WriteBlockPool(b *BlockPool) (*Rollback, error)

func WriteBlockPoolAllocations

func WriteBlockPoolAllocations(b []*BlockPoolAllocations) (*Rollback, error)

func WriteVsets

func WriteVsets(vs []*Vset) (*Rollback, error)

type SSHCert

type SSHCert struct {
	*portal.SSHCert
	User   string
	IsHost bool // if true this is a host cert, else a user cert
	Ver    int64
}

func GetSSHCerts

func GetSSHCerts() ([]*SSHCert, error)

func NewSSHHostCert

func NewSSHHostCert(host string) *SSHCert

func NewSSHUserCert

func NewSSHUserCert(username string) *SSHCert

func (*SSHCert) Bucket

func (sc *SSHCert) Bucket() string

SSH Cert

func (*SSHCert) Create

func (sc *SSHCert) Create() (*Rollback, error)

func (*SSHCert) Delete

func (sc *SSHCert) Delete() (*Rollback, error)

func (*SSHCert) GetVersion

func (sc *SSHCert) GetVersion() int64

func (*SSHCert) Id

func (sc *SSHCert) Id() string

func (*SSHCert) Key

func (sc *SSHCert) Key() string

func (*SSHCert) Read

func (sc *SSHCert) Read() error

func (*SSHCert) SetVersion

func (sc *SSHCert) SetVersion(ver int64)

func (*SSHCert) Substrate

func (sc *SSHCert) Substrate() Substrate

func (*SSHCert) Type

func (sc *SSHCert) Type() string

func (*SSHCert) Update

func (sc *SSHCert) Update() (*Rollback, error)

func (*SSHCert) Value

func (sc *SSHCert) Value() interface{}

type SSHJump

type SSHJump struct {
	*portal.SSHJump
}

func ListSSHJumps

func ListSSHJumps() ([]*SSHJump, error)

func NewSSHJump

func NewSSHJump(name string) *SSHJump

func (*SSHJump) Bucket

func (j *SSHJump) Bucket() string

func (*SSHJump) Create

func (j *SSHJump) Create() (*Rollback, error)

func (*SSHJump) Delete

func (j *SSHJump) Delete() (*Rollback, error)

func (*SSHJump) GetVersion

func (j *SSHJump) GetVersion() int64

func (*SSHJump) Id

func (j *SSHJump) Id() string

func (*SSHJump) Key

func (j *SSHJump) Key() string

func (*SSHJump) Read

func (j *SSHJump) Read() error

func (*SSHJump) SetVersion

func (j *SSHJump) SetVersion(v int64)

func (*SSHJump) Substrate

func (j *SSHJump) Substrate() Substrate

func (*SSHJump) Update

func (j *SSHJump) Update() (*Rollback, error)

func (*SSHJump) Value

func (j *SSHJump) Value() interface{}

type SSHKeyPair

type SSHKeyPair struct {
	*portal.SSHKeyPair
	User   string
	IsHost bool
	Ver    int64
}

func GetSSHKeys

func GetSSHKeys() ([]*SSHKeyPair, error)

func NewSSHHostKeyPair

func NewSSHHostKeyPair(host string) *SSHKeyPair

func NewSSHUserKeyPair

func NewSSHUserKeyPair(user string) *SSHKeyPair

func (*SSHKeyPair) Bucket

func (skp *SSHKeyPair) Bucket() string

func (*SSHKeyPair) Create

func (skp *SSHKeyPair) Create() (*Rollback, error)

func (*SSHKeyPair) Delete

func (skp *SSHKeyPair) Delete() (*Rollback, error)

func (*SSHKeyPair) GetVersion

func (skp *SSHKeyPair) GetVersion() int64

func (*SSHKeyPair) Id

func (skp *SSHKeyPair) Id() string

func (*SSHKeyPair) Key

func (skp *SSHKeyPair) Key() string

func (*SSHKeyPair) Read

func (skp *SSHKeyPair) Read() error

func (*SSHKeyPair) SetVersion

func (skp *SSHKeyPair) SetVersion(ver int64)

func (*SSHKeyPair) Substrate

func (skp *SSHKeyPair) Substrate() Substrate

func (*SSHKeyPair) Type

func (skp *SSHKeyPair) Type() string

func (*SSHKeyPair) Update

func (skp *SSHKeyPair) Update() (*Rollback, error)

func (*SSHKeyPair) Value

func (skp *SSHKeyPair) Value() interface{}

type StorOp

type StorOp struct {
	Op     Operation
	Object ObjectIO
}

func (*StorOp) String

func (so *StorOp) String() string

type StorageMessage

type StorageMessage interface {
	Marshal() ([]byte, error)
	Unmarshal([]byte) error
}

Support for types that want to marshal and unmarshal themselves.

type Substrate

type Substrate int
const (
	Etcd Substrate = iota + 1
	MinIO
)

type Transaction

type Transaction []StorOp

func (Transaction) Exec

func (t Transaction) Exec() error

type TransactionCache added in v1.1.22

type TransactionCache struct {
	// Cache objects by type and etcd key.
	Objs map[TransactionCacheType]map[string]Object
}

func NewTransactionCache added in v1.1.22

func NewTransactionCache() *TransactionCache

func (*TransactionCache) NewObj added in v1.1.22

func (tc *TransactionCache) NewObj(t TransactionCacheType, args ...string) Object

Create a new thing or give back a cahed version of the thing. args are what is used to New...() the object type requestsed.

func (*TransactionCache) Read added in v1.1.22

func (tc *TransactionCache) Read() (*Rollback, error)

Read objects using cache.

type TransactionCacheType added in v1.1.22

type TransactionCacheType int64

Keep track of ongoing updates to data while gathering all the operations for a single transaction.

const (
	PTOrg TransactionCacheType = iota
	PTProj
	PTExp
	PTUser
	PTFac
	PTPool
)

type User

type User struct {
	*portal.User
	UpdateRequest *portal.UpdateUserRequest
}

func ListUsers

func ListUsers() ([]*User, error)

func NewUser

func NewUser(username string) *User

func (*User) Bucket

func (u *User) Bucket() string

func (*User) Create

func (u *User) Create() (*Rollback, error)

func (*User) Delete

func (u *User) Delete() (*Rollback, error)

func (*User) DeleteLinkedOps added in v1.1.22

func (u *User) DeleteLinkedOps(tc *TransactionCache) ([]StorOp, error)

func (*User) GetVersion

func (u *User) GetVersion() int64

func (*User) Id

func (u *User) Id() string

func (*User) Key

func (u *User) Key() string

func (*User) Read

func (u *User) Read() error

func (*User) SetVersion

func (u *User) SetVersion(v int64)

func (*User) Substrate

func (u *User) Substrate() Substrate

func (*User) Update

func (u *User) Update() (*Rollback, error)

func (*User) Value

func (u *User) Value() interface{}

func (*User) WriteRegistration added in v1.1.39

func (u *User) WriteRegistration() (*Rollback, error)

WriteRegistration - write the user data required for registration only. Do not "init" the user by allocating a uid/gid or creating a user personal project. This function only write a minimal set of user data that is given during account registration. To generate UID/GID and a personal project, call user.Create().

type UserStatus

type UserStatus struct {
	*portal.UserStatus
}

Keep track of user state wrt current status. Used to generate certs, keys, xdc accounts, etc.

func NewUserStatus

func NewUserStatus(username string) *UserStatus

func (*UserStatus) Bucket

func (us *UserStatus) Bucket() string

**************************************************************************** UserStatus ****************************************************************************

func (*UserStatus) Create

func (us *UserStatus) Create() (*Rollback, error)

func (*UserStatus) Delete

func (us *UserStatus) Delete() (*Rollback, error)

func (*UserStatus) GetVersion

func (us *UserStatus) GetVersion() int64

func (*UserStatus) Id

func (us *UserStatus) Id() string

func (*UserStatus) Key

func (us *UserStatus) Key() string

func (*UserStatus) Read

func (us *UserStatus) Read() error

func (*UserStatus) SetVersion

func (us *UserStatus) SetVersion(v int64)

func (*UserStatus) Substrate

func (us *UserStatus) Substrate() Substrate

func (*UserStatus) Unmarshal

func (us *UserStatus) Unmarshal(b []byte) error

func (*UserStatus) Update

func (us *UserStatus) Update() (*Rollback, error)

func (*UserStatus) Value

func (us *UserStatus) Value() interface{}

type VlanAllocationTable

type VlanAllocationTable struct {
	// hosts participating in the VID allocation
	VidHosts []string

	// name of the VNI table
	VniTable string
}

func NewVlanAllocationTable

func NewVlanAllocationTable(hosts []string, vnitable string) *VlanAllocationTable

func (*VlanAllocationTable) AllocateVid

func (vat *VlanAllocationTable) AllocateVid() (uint32, error)

Find a VID that is free on each host in the VAT This involves read/modify/write over a collection of switches and hosts, and so could fail, particularly for large realizations. Use a retry loop to catch them

func (*VlanAllocationTable) AllocateVni

func (vat *VlanAllocationTable) AllocateVni() (uint32, error)

Allocate a globally free VNI VNI is a global entity, use a lock

func (*VlanAllocationTable) FreeVid

func (vat *VlanAllocationTable) FreeVid(vid uint32) error

Release the VID back to each host set

func (*VlanAllocationTable) FreeVni

func (vat *VlanAllocationTable) FreeVni(vni uint32) error

Free a VNI back to the pool VNI is a global entity, use a lock

type Vlist

type Vlist struct {
	*internal.CountSet
	Ver int64
}

Uses countset backend with minio as substrate. We need this because VNI lists can easily grow well beyond the 1.5 MiB etcd limit

Though this is stored in minio, we use an etcd lock to protect it, which makes this a little bit of a messy object definition

func NewVlist

func NewVlist(name string, size, offset uint32) *Vlist

func (*Vlist) Bucket

func (vl *Vlist) Bucket() string

We need to implement the object interface to make use of etcd locks

func (*Vlist) Create

func (vl *Vlist) Create() (*Rollback, error)

func (*Vlist) Delete

func (vl *Vlist) Delete() (*Rollback, error)

func (*Vlist) Free

func (vl *Vlist) Free(val uint32) error

func (*Vlist) GetVersion

func (vl *Vlist) GetVersion() int64

func (*Vlist) Id

func (vl *Vlist) Id() string

func (*Vlist) Key

func (vl *Vlist) Key() string

func (*Vlist) Lock

func (vl *Vlist) Lock() (*Lock, error)

func (*Vlist) Next

func (vl *Vlist) Next() (uint32, error)

func (*Vlist) Read

func (vl *Vlist) Read() error

func (*Vlist) SetVersion

func (vl *Vlist) SetVersion(ver int64)

func (*Vlist) Substrate

func (vl *Vlist) Substrate() Substrate

func (*Vlist) Unlock

func (vl *Vlist) Unlock(lk *Lock) error

func (*Vlist) Update

func (vl *Vlist) Update() (*Rollback, error)

func (*Vlist) Value

func (vl *Vlist) Value() interface{}

func (*Vlist) Write

func (vl *Vlist) Write() error

type Vset

type Vset struct {
	*internal.Set
	Ver int64
}

Uses a set backend implementation and Etcd as a substrate, so must be kept small

func NewVset

func NewVset(name string) *Vset

func (*Vset) Bucket

func (v *Vset) Bucket() string

func (*Vset) Contains

func (v *Vset) Contains(val uint32) bool

func (*Vset) Create

func (v *Vset) Create() (*Rollback, error)

func (*Vset) Delete

func (v *Vset) Delete() (*Rollback, error)

func (*Vset) Get

func (v *Vset) Get(val uint32) error

func (*Vset) GetAny

func (v *Vset) GetAny() (uint32, error)

func (*Vset) GetVersion

func (v *Vset) GetVersion() int64

func (*Vset) Id

func (v *Vset) Id() string

func (*Vset) Key

func (v *Vset) Key() string

func (*Vset) Put

func (v *Vset) Put(val uint32) error

func (*Vset) Read

func (v *Vset) Read() error

func (*Vset) SetVersion

func (v *Vset) SetVersion(x int64)

func (*Vset) Substrate

func (v *Vset) Substrate() Substrate

func (*Vset) Update

func (v *Vset) Update() (*Rollback, error)

func (*Vset) Value

func (v *Vset) Value() interface{}

type WgEnclave

type WgEnclave struct {
	*portal.WgEnclave

	AddIf *portal.AddWgIfConfigRequest
	DelIf *portal.AddWgIfConfigRequest
}

func ListWgEnclaves

func ListWgEnclaves() ([]*WgEnclave, error)

func NewWgEnclave

func NewWgEnclave(id string) *WgEnclave

func (*WgEnclave) Bucket

func (e *WgEnclave) Bucket() string

func (*WgEnclave) Create

func (e *WgEnclave) Create() (*Rollback, error)

func (*WgEnclave) Delete

func (e *WgEnclave) Delete() (*Rollback, error)

func (*WgEnclave) GetVersion

func (e *WgEnclave) GetVersion() int64

func (*WgEnclave) Id

func (e *WgEnclave) Id() string

func (*WgEnclave) Key

func (e *WgEnclave) Key() string

func (*WgEnclave) Read

func (e *WgEnclave) Read() error

func (*WgEnclave) SetVersion

func (e *WgEnclave) SetVersion(ver int64)

func (*WgEnclave) Substrate

func (e *WgEnclave) Substrate() Substrate

func (*WgEnclave) Update

func (e *WgEnclave) Update() (*Rollback, error)

func (*WgEnclave) Value

func (e *WgEnclave) Value() interface{}

type WgIfRequest

type WgIfRequest struct {
	*portal.AddWgIfConfigRequest
	Ver int64
}

*************************************************************************** Wireguard interface requests ***************************************************************************

func NewWgIfRequest

func NewWgIfRequest(enclaveid, key string) *WgIfRequest

func (*WgIfRequest) Bucket

func (r *WgIfRequest) Bucket() string

func (*WgIfRequest) Create

func (r *WgIfRequest) Create() (*Rollback, error)

func (*WgIfRequest) Delete

func (r *WgIfRequest) Delete() (*Rollback, error)

func (*WgIfRequest) GetVersion

func (r *WgIfRequest) GetVersion() int64

func (*WgIfRequest) Id

func (r *WgIfRequest) Id() string

func (*WgIfRequest) Key

func (r *WgIfRequest) Key() string

func (*WgIfRequest) Read

func (r *WgIfRequest) Read() error

func (*WgIfRequest) SetVersion

func (r *WgIfRequest) SetVersion(ver int64)

func (*WgIfRequest) Substrate

func (r *WgIfRequest) Substrate() Substrate

func (*WgIfRequest) Update

func (r *WgIfRequest) Update() (*Rollback, error)

func (*WgIfRequest) Value

func (r *WgIfRequest) Value() interface{}

type XDC

type XDC struct {
	*portal.XDCStorage

	UpdateRequest *portal.XDCStorage
}

func ListXDCs

func ListXDCs(pid string) ([]*XDC, error)

func NewXDC

func NewXDC(creator, name, project string) *XDC

func (*XDC) Bucket

func (x *XDC) Bucket() string

func (*XDC) Create

func (x *XDC) Create() (*Rollback, error)

func (*XDC) DelLinkedOps added in v1.1.9

func (x *XDC) DelLinkedOps() ([]StorOp, error)

DelLinkedOps ...

func (*XDC) Delete

func (x *XDC) Delete() (*Rollback, error)

func (*XDC) GetVersion

func (x *XDC) GetVersion() int64

func (*XDC) Id

func (x *XDC) Id() string

func (*XDC) Key

func (x *XDC) Key() string

func (*XDC) Read

func (x *XDC) Read() error

func (*XDC) SetMaterialization added in v1.0.5

func (x *XDC) SetMaterialization(mtz string) (*Rollback, error)

func (*XDC) SetVersion

func (x *XDC) SetVersion(v int64)

func (*XDC) Substrate

func (x *XDC) Substrate() Substrate

func (*XDC) Update

func (x *XDC) Update() (*Rollback, error)

func (*XDC) Value

func (x *XDC) Value() interface{}

func (*XDC) XdcId

func (x *XDC) XdcId() string

type XdcWgClient

type XdcWgClient struct {
	*portal.AttachXDCRequest
	Ver int64
}

*************************************************************************** XDC Specific wireguard client information. ***************************************************************************

func NewXdcWgClient

func NewXdcWgClient(rq *portal.AttachXDCRequest) *XdcWgClient

func (*XdcWgClient) Bucket

func (x *XdcWgClient) Bucket() string

func (*XdcWgClient) Create

func (x *XdcWgClient) Create() (*Rollback, error)

func (*XdcWgClient) Delete

func (x *XdcWgClient) Delete() (*Rollback, error)

func (*XdcWgClient) GetVersion

func (x *XdcWgClient) GetVersion() int64

func (*XdcWgClient) Id

func (x *XdcWgClient) Id() string

func (*XdcWgClient) Key

func (x *XdcWgClient) Key() string

func (*XdcWgClient) Read

func (x *XdcWgClient) Read() error

func (*XdcWgClient) SetVersion

func (x *XdcWgClient) SetVersion(ver int64)

func (*XdcWgClient) Substrate

func (x *XdcWgClient) Substrate() Substrate

func (*XdcWgClient) Update

func (x *XdcWgClient) Update() (*Rollback, error)

func (*XdcWgClient) Value

func (x *XdcWgClient) Value() interface{}

Jump to

Keyboard shortcuts

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