project

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package project groups machines, storage pools and networks into projects with members and limits (ADR-0060): multi-tenancy for VirtoMir. A project owns the resources created inside it; members reach it by direct membership or through one of their Linux groups, and the highest role wins.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Limits

type Limits struct {
	Machines  int   `json:"machines"`
	VCPUs     int   `json:"vcpus"`
	MemoryMiB int64 `json:"memoryMiB"`
	DiskGiB   int64 `json:"diskGiB"`
	// GPUs caps GPUs per GPU pool ID (ADR-0071); a pool missing or at 0 is not limited.
	GPUs map[string]int `json:"gpus,omitempty"`
}

Limits caps a project's machines together; zero means unlimited.

func (Limits) Exceeded

func (l Limits) Exceeded(usage, demand Usage) error

Exceeded reports the first resource that demand would push past the limits, given current usage; zero limits are unlimited.

type Member

type Member struct {
	Kind string `json:"kind"` // user or group
	Name string `json:"name"`
	Role string `json:"role"` // viewer, operator or admin
}

Member gives one user (Kind "user") or everyone in a group (Kind "group") a Role in a project: "viewer", "operator" or "admin".

type Project

type Project struct {
	ID           string    `json:"id"`
	Name         string    `json:"name"`
	Description  string    `json:"description,omitempty"`
	Members      []Member  `json:"members"`
	Limits       Limits    `json:"limits"`
	StoragePools []string  `json:"storagePools"`
	Networks     []string  `json:"networks"`
	Created      time.Time `json:"created"`
}

Project is one tenant: its machines, storage pools and networks, who may use them and up to how much.

type Store

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

func Open

func Open(path string) (*Store, error)

func (*Store) Create

func (s *Store) Create(p Project) (Project, error)

Create adds a project.

func (*Store) Delete

func (s *Store) Delete(id string) error

Delete removes a project.

func (*Store) Get

func (s *Store) Get(id string) (Project, bool)

func (*Store) List

func (s *Store) List() []Project

List returns every project, by ID.

func (*Store) ProjectsFor

func (s *Store) ProjectsFor(user string, groups []string) []Project

ProjectsFor is every project the user can see, directly or through any of their groups, by ID.

func (*Store) RoleFor

func (s *Store) RoleFor(projectID, user string, groups []string) (string, bool)

RoleFor is the highest role the user has in a project, directly or through any of their groups; ok is false when they are not a member.

func (*Store) Update

func (s *Store) Update(p Project) error

Update changes a project's name, description, members, limits, pools and networks.

type Usage

type Usage struct {
	Machines  int   `json:"machines"`
	VCPUs     int   `json:"vcpus"`
	MemoryMiB int64 `json:"memoryMiB"`
	DiskGiB   int64 `json:"diskGiB"`
	// GPUs per GPU pool ID.
	GPUs map[string]int `json:"gpus,omitempty"`
}

Usage is what a project's machines take now.

Jump to

Keyboard shortcuts

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