introduce podman machine

podman machine allows podman to create, manage, and interact with a vm
running some form of linux (default is fcos).  podman is then configured
to be able to interact with the vm automatically.

while this is usable on linux, the real push is to get this working on
both current apple architectures in macos.

Ashley Cui contributed to this PR and was a great help.

[NO TESTS NEEDED]

Signed-off-by: baude <bbaude@redhat.com>
This commit is contained in:
baude
2021-03-15 14:52:43 -05:00
parent a861f6fd3e
commit b5f54a9b23
113 changed files with 30795 additions and 151 deletions

View File

@@ -0,0 +1,18 @@
package rhcos
// Extensions is data specific to Red Hat Enterprise Linux CoreOS
type Extensions struct {
AzureDisk *AzureDisk `json:"azure-disk,omitempty"`
}
// AzureDisk represents an Azure disk image that can be imported
// into an image gallery or otherwise replicated, and then used
// as a boot source for virtual machines.
type AzureDisk struct {
// Release is the source release version
Release string `json:"release"`
// URL to an image already stored in Azure infrastructure
// that can be copied into an image gallery. Avoid creating VMs directly
// from this URL as that may lead to performance limitations.
URL string `json:"url,omitempty"`
}

View File

@@ -0,0 +1,74 @@
// Package stream models a CoreOS "stream", which is
// a description of the recommended set of binary images for CoreOS. Use
// this API to find cloud images, bare metal disk images, etc.
package stream
import (
"github.com/coreos/stream-metadata-go/stream/rhcos"
)
// Stream contains artifacts available in a stream
type Stream struct {
Stream string `json:"stream"`
Metadata Metadata `json:"metadata"`
Architectures map[string]Arch `json:"architectures"`
}
// Metadata for a release or stream
type Metadata struct {
LastModified string `json:"last-modified"`
}
// Arch contains release details for a particular hardware architecture
type Arch struct {
Artifacts map[string]PlatformArtifacts `json:"artifacts"`
Images Images `json:"images,omitempty"`
// RHELCoreOSExtensions is data specific to Red Hat Enterprise Linux CoreOS
RHELCoreOSExtensions *rhcos.Extensions `json:"rhel-coreos-extensions,omitempty"`
}
// PlatformArtifacts contains images for a platform
type PlatformArtifacts struct {
Release string `json:"release"`
Formats map[string]ImageFormat `json:"formats"`
}
// ImageFormat contains all artifacts for a single OS image
type ImageFormat struct {
Disk *Artifact `json:"disk,omitempty"`
Kernel *Artifact `json:"kernel,omitempty"`
Initramfs *Artifact `json:"initramfs,omitempty"`
Rootfs *Artifact `json:"rootfs,omitempty"`
}
// Artifact represents one image file, plus its metadata
type Artifact struct {
Location string `json:"location"`
Signature string `json:"signature"`
Sha256 string `json:"sha256"`
UncompressedSha256 string `json:"uncompressed-sha256,omitempty"`
}
// Images contains images available in cloud providers
type Images struct {
Aws *AwsImage `json:"aws,omitempty"`
Gcp *GcpImage `json:"gcp,omitempty"`
}
// AwsImage represents an image across all AWS regions
type AwsImage struct {
Regions map[string]AwsRegionImage `json:"regions,omitempty"`
}
// AwsRegionImage represents an image in one AWS region
type AwsRegionImage struct {
Release string `json:"release"`
Image string `json:"image"`
}
// GcpImage represents a GCP cloud image
type GcpImage struct {
Project string `json:"project,omitempty"`
Family string `json:"family,omitempty"`
Name string `json:"name,omitempty"`
}

View File

@@ -0,0 +1,47 @@
package stream
import "fmt"
// FormatPrefix describes a stream+architecture combination, intended for prepending to error messages
func (st *Stream) FormatPrefix(archname string) string {
return fmt.Sprintf("%s/%s", st.Stream, archname)
}
// GetArchitecture loads the architecture-specific builds from a stream,
// with a useful descriptive error message if the architecture is not found.
func (st *Stream) GetArchitecture(archname string) (*Arch, error) {
archdata, ok := st.Architectures[archname]
if !ok {
return nil, fmt.Errorf("stream:%s does not have architecture '%s'", st.Stream, archname)
}
return &archdata, nil
}
// GetAwsRegionImage returns the release data (AMI and release ID) for a particular
// architecture and region.
func (st *Stream) GetAwsRegionImage(archname, region string) (*AwsRegionImage, error) {
starch, err := st.GetArchitecture(archname)
if err != nil {
return nil, err
}
awsimages := starch.Images.Aws
if awsimages == nil {
return nil, fmt.Errorf("%s: No AWS images", st.FormatPrefix(archname))
}
var regionVal AwsRegionImage
var ok bool
if regionVal, ok = awsimages.Regions[region]; !ok {
return nil, fmt.Errorf("%s: No AWS images in region %s", st.FormatPrefix(archname), region)
}
return &regionVal, nil
}
// GetAMI returns the AWS machine image for a particular architecture and region.
func (st *Stream) GetAMI(archname, region string) (string, error) {
regionVal, err := st.GetAwsRegionImage(archname, region)
if err != nil {
return "", err
}
return regionVal.Image, nil
}