machine

package
v5.0.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Used for testing the latest podman in fcos
	// special builds
	PodmanTestingHost = "fedorapeople.org"
	PodmanTestingURL  = "groups/podman/testing"
)
View Source
const (
	DefaultMachineName string = "podman-machine-default"
)

Variables

View Source
var (
	ForwarderBinaryName = "gvproxy"
)

Functions

func AllocateMachinePort

func AllocateMachinePort() (int, error)

Reserves a unique port for a machine instance in a global (user) scope across all machines and backend types. On success the port is guaranteed to not be allocated until released with a call to ReleaseMachinePort().

The purpose of this method is to prevent collisions between machine instances when ran at the same time. Note, that dynamic port reassignment on its own is insufficient to resolve conflicts, since there is a narrow window between port detection and actual service binding, allowing for the possibility of a second racing machine to fail if its check is unlucky to fall within that window. Additionally, there is the potential for a long running reassignment dance over start/stop until all machine instances eventually arrive at total conflict free state. By reserving ports using mechanism these scenarios are prevented.

func CleanupGVProxy

func CleanupGVProxy(f define.VMFile) error

CleanupGVProxy reads the --pid-file for gvproxy attempts to stop it

func CommonSSH

func CommonSSH(username, identityPath, name string, sshPort int, inputArgs []string) error

CommonSSH is a common function for ssh'ing to a podman machine using system-connections and a port TODO This should probably be taught about an machineconfig to reduce input

func CommonSSHSilent

func CommonSSHSilent(username, identityPath, name string, sshPort int, inputArgs []string) error

func ConfDirPrefix

func ConfDirPrefix() (string, error)

ConfDirPrefix returns the path prefix for all machine config files

func CreateSSHKeys

func CreateSSHKeys(writeLocation string) (string, error)

CreateSSHKeys makes a priv and pub ssh key for interacting the a VM.

func CreateSSHKeysPrefix

func CreateSSHKeysPrefix(identityPath string, passThru bool, skipExisting bool, prefix ...string) (string, error)

func DataDirPrefix

func DataDirPrefix() (string, error)

DataDirPrefix returns the path prefix for all machine data files

func DetermineMachineArch

func DetermineMachineArch() string

func DialNamedPipe

func DialNamedPipe(ctx context.Context, path string) (net.Conn, error)

func DownloadImage

func DownloadImage(d DistributionDownload) error

func DownloadVMImage

func DownloadVMImage(downloadURL *url2.URL, imageName string, localImagePath string) error

DownloadVMImage downloads a VM image from url to given path with download status

func GetCacheDir

func GetCacheDir(vmType define.VMType) (string, error)

GetCacheDir returns the dir where VM images are downloaded into when pulled

func GetConfDir

func GetConfDir(vmType define.VMType) (string, error)

GetConfigDir returns the filepath to where configuration files for podman-machine should live

func GetDataDir

func GetDataDir(vmType define.VMType) (string, error)

GetDataDir returns the filepath where vm images should live for podman-machine.

func GetDevNullFiles

func GetDevNullFiles() (*os.File, *os.File, error)

GetDevNullFiles returns pointers to Read-only and Write-only DevNull files

func GetEnvSetString

func GetEnvSetString(env string, val string) string

func GetFcosArch

func GetFcosArch() string

func GetGlobalDataDir

func GetGlobalDataDir() (string, error)

GetGlobalDataDir returns the root of all backends for shared machine data.

func GetMachineDirs

func GetMachineDirs(vmType define.VMType) (*define.MachineDirs, error)

func GetSSHIdentityPath

func GetSSHIdentityPath(name string) (string, error)

GetSSHIdentityPath returns the path to the expected SSH private key

func GetSSHKeys

func GetSSHKeys(identityPath string) (string, error)

GetSSHKeys checks to see if there is a ssh key at the provided location. If not, we create the priv and pub keys. The ssh key is then returned.

func IsLocalPortAvailable

func IsLocalPortAvailable(port int) bool

func IsValidFCOSStreamString

func IsValidFCOSStreamString(s string) bool

TODO can be removed when WSL is refactored into podman 5

func ParseVolumeFromPath

func ParseVolumeFromPath(v string) (source, target, options string, readonly bool, err error)

ParseVolumeFromPath is a oneshot parsing of a provided volume. It follows the "rules" of the singular parsing functions

func PrintRootlessWarning

func PrintRootlessWarning(name string)

func ReleaseMachinePort

func ReleaseMachinePort(port int) error

Releases a reserved port for a machine when no longer required. Care should be taken to ensure there are no conditions (e.g. failure paths) where the port might unintentionally remain in use after releasing

func RemoveImageAfterExpire

func RemoveImageAfterExpire(dir string, expire time.Duration) error

func SetRootful

func SetRootful(rootful bool, name, rootfulName string) error

SetRootful modifies the machine's default connection to be either rootful or rootless

func UpdatePodmanDockerSockService

func UpdatePodmanDockerSockService(mc *vmconfigs.MachineConfig) error

func WaitAPIAndPrintInfo

func WaitAPIAndPrintInfo(forwardState APIForwardingState, name, helper, forwardSock string, noInfo, rootful bool)

WaitAPIAndPrintInfo prints info about the machine and does a ping test on the API socket

func WaitAndPingAPI

func WaitAndPingAPI(sock string)

func WriteConfig

func WriteConfig(configPath string, v VM) error

WriteConfig writes the machine's JSON config file

Types

type APIForwardingState

type APIForwardingState int
const (
	NoForwarding APIForwardingState = iota
	ClaimUnsupported
	NotInstalled
	MachineLocal
	DockerGlobal
)

type CleanupCallback

type CleanupCallback struct {
	Funcs []func() error
	// contains filtered or unexported fields
}

func InitCleanup

func InitCleanup() CleanupCallback

func (*CleanupCallback) Add

func (c *CleanupCallback) Add(anotherfunc func() error)

func (*CleanupCallback) CleanIfErr

func (c *CleanupCallback) CleanIfErr(err *error)

func (*CleanupCallback) CleanOnSignal

func (c *CleanupCallback) CleanOnSignal()

type ConnectionConfig

type ConnectionConfig struct {
	// PodmanSocket is the exported podman service socket
	PodmanSocket *define.VMFile `json:"PodmanSocket"`
	// PodmanPipe is the exported podman service named pipe (Windows hosts only)
	PodmanPipe *define.VMFile `json:"PodmanPipe"`
}

ConnectionConfig contains connections like sockets, etc.

type DistributionDownload

type DistributionDownload interface {
	HasUsableCache() (bool, error)
	Get() *Download
	CleanCache() error
}

func NewGenericDownloader

func NewGenericDownloader(vmType define.VMType, vmName, pullPath string) (DistributionDownload, error)

NewGenericDownloader is used when the disk image is provided by the user

type Download

type Download struct {
	Arch                  string
	Artifact              define.Artifact
	CacheDir              string
	CompressionType       compression.ImageCompression
	DataDir               string
	Format                define.ImageFormat
	ImageName             string
	LocalPath             string
	LocalUncompressedFile string
	Sha256sum             string
	Size                  int64
	URL                   *url.URL
	VMKind                define.VMType
	VMName                string
}

func (Download) AcquireAlternateImage

func (dl Download) AcquireAlternateImage(inputPath string) (*define.VMFile, error)

AcquireAlternateImage downloads the alternate image the user provided, which can be a file path or URL

func (Download) GetFCOSDownload

func (dl Download) GetFCOSDownload(imageStream FCOSStream) (*FcosDownloadInfo, error)

GetFCOSDownload parses fedoraCoreOS's stream and returns the image download URL and the release version

func (Download) GetLocalUncompressedFile

func (dl Download) GetLocalUncompressedFile(dataDir string) string

type FCOSStream

type FCOSStream int64
const (
	// FCOS streams
	// Testing FCOS stream
	Testing FCOSStream = iota
	// Next FCOS stream
	Next
	// Stable FCOS stream
	Stable
	// Podman-Testing
	PodmanTesting
	// Custom
	CustomStream
)

func (FCOSStream) String

func (st FCOSStream) String() string

String is a helper func for fcos streams

type FcosDownload

type FcosDownload struct {
	Download
}

func (FcosDownload) CleanCache

func (f FcosDownload) CleanCache() error

func (FcosDownload) Get

func (f FcosDownload) Get() *Download

func (FcosDownload) HasUsableCache

func (f FcosDownload) HasUsableCache() (bool, error)

type FcosDownloadInfo

type FcosDownloadInfo struct {
	CompressionType compression.ImageCompression
	Location        string
	Release         string
	Sha256Sum       string
}

type GenericDownload

type GenericDownload struct {
	Download
}

GenericDownload is used when a user provides a URL or path for an image

func (GenericDownload) CleanCache

func (g GenericDownload) CleanCache() error

CleanCache cleans out downloaded uncompressed image files

func (GenericDownload) Get

func (g GenericDownload) Get() *Download

func (GenericDownload) HasUsableCache

func (g GenericDownload) HasUsableCache() (bool, error)

type ImageConfig

type ImageConfig struct {
	// IgnitionFile is the path to the filesystem where the
	// ignition file was written (if needs one)
	IgnitionFile define.VMFile `json:"IgnitionFilePath"`
	// ImageStream is the update stream for the image
	ImageStream string
	// ImageFile is the fq path to
	ImagePath define.VMFile `json:"ImagePath"`
}

ImageConfig describes the bootable image for the VM

type InspectInfo

type InspectInfo struct {
	ConfigPath         define.VMFile
	ConnectionInfo     ConnectionConfig
	Created            time.Time
	Image              ImageConfig
	LastUp             time.Time
	Name               string
	Resources          vmconfigs.ResourceConfig
	SSHConfig          vmconfigs.SSHConfig
	State              define.Status
	UserModeNetworking bool
	Rootful            bool
}

type InspectOptions

type InspectOptions struct{}

type ListOptions

type ListOptions struct{}

type ListResponse

type ListResponse struct {
	Name               string
	CreatedAt          time.Time
	LastUp             time.Time
	Running            bool
	Starting           bool
	Stream             string
	VMType             string
	CPUs               uint64
	Memory             uint64
	DiskSize           uint64
	Port               int
	RemoteUsername     string
	IdentityPath       string
	UserModeNetworking bool
}

type RemoveOptions

type RemoveOptions struct {
	Force        bool
	SaveImage    bool
	SaveIgnition bool
}

type SSHOptions

type SSHOptions struct {
	Username string
	Args     []string
}

type StartOptions

type StartOptions struct {
	NoInfo bool
	Quiet  bool
}

type StopOptions

type StopOptions struct{}

type VM

type VM interface {
	Init(opts define.InitOptions) (bool, error)
	Inspect() (*InspectInfo, error)
	Remove(name string, opts RemoveOptions) (string, func() error, error)
	Set(name string, opts define.SetOptions) ([]error, error)
	SSH(name string, opts SSHOptions) error
	Start(name string, opts StartOptions) error
	State(bypass bool) (define.Status, error)
	Stop(name string, opts StopOptions) error
}

TODO This can be removed when WSL is refactored into podman 5

type VirtIoFs

type VirtIoFs struct {
	VolumeKind
	ReadOnly bool
	Source   string
	Tag      string
	Target   string
}

func MountToVirtIOFs

func MountToVirtIOFs(mnt *vmconfigs.Mount) VirtIoFs

func NewVirtIoFsMount

func NewVirtIoFsMount(src, target string, readOnly bool) VirtIoFs

NewVirtIoFsMount describes a machine volume mount for virtio-fs. With virtio-fs the source/target are described as a "shared dir". With this style of volume mount the Tag is used as the descriptor value for the mount (in Linux).

func (VirtIoFs) Kind

func (v VirtIoFs) Kind() string

func (VirtIoFs) ToMount

func (v VirtIoFs) ToMount() vmconfigs.Mount

type Virtualization

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

TODO THis should be able to be removed once WSL is refactored for podman5

func NewVirtualization

func NewVirtualization(artifact define.Artifact, compression compression.ImageCompression, format define.ImageFormat, vmKind define.VMType) Virtualization

func (*Virtualization) Artifact

func (p *Virtualization) Artifact() define.Artifact

func (*Virtualization) Compression

func (p *Virtualization) Compression() compression.ImageCompression

func (*Virtualization) Format

func (p *Virtualization) Format() define.ImageFormat

func (*Virtualization) NewDownload

func (p *Virtualization) NewDownload(vmName string) (Download, error)

func (*Virtualization) VMType

func (p *Virtualization) VMType() define.VMType

type Volume

type Volume interface {
	Kind() VolumeKind
}

type VolumeKind

type VolumeKind string
var (
	VirtIOFsVk VolumeKind = "virtiofs"
	NinePVk    VolumeKind = "9p"
)

Jump to

Keyboard shortcuts

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