Files
2025-11-23 22:37:27 +07:00

45 lines
1.2 KiB
Go

package lxc
// Manager abstracts LXC lifecycle operations.
type Manager interface {
List() ([]Container, error)
Create(spec Spec) (Container, error)
Start(id string) error
Stop(id string) error
Delete(id string) error
}
type Spec struct {
ID string `json:"id" yaml:"id"`
Name string `json:"name" yaml:"name"`
Template string `json:"template" yaml:"template"`
RootfsPool string `json:"rootfs_pool" yaml:"rootfs_pool"`
RootfsSizeG int `json:"rootfs_size_g" yaml:"rootfs_size_g"`
RootfsPath string `json:"rootfs_path" yaml:"rootfs_path"`
NICs []NICSpec `json:"nics" yaml:"nics"`
Limits Limits `json:"limits" yaml:"limits"`
Unprivileged bool `json:"unprivileged" yaml:"unprivileged"`
}
type NICSpec struct {
Bridge string `json:"bridge" yaml:"bridge"`
VLAN int `json:"vlan" yaml:"vlan"`
HWAddr string `json:"hwaddr" yaml:"hwaddr"`
MTU int `json:"mtu" yaml:"mtu"`
Name string `json:"name" yaml:"name"`
}
type Limits struct {
CPU int `json:"cpus" yaml:"cpus"`
MemoryMB int `json:"memory_mb" yaml:"memory_mb"`
}
type Container struct {
ID string
Name string
Status string
Unpriv bool
}
// TODO: shell out to lxc-* binaries with generated config under cfg path.