onprem

package
v0.0.0-...-6054725 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Byte = 1 << (iota * 10)
	KiByte
	MiByte
	GiByte
	TiByte
	PiByte
	EiByte
)

IEC Sizes. kibis of bits

View Source
const (
	IByte = 1
	KByte = IByte * 1000
	MByte = KByte * 1000
	GByte = MByte * 1000
	TByte = GByte * 1000
	PByte = TByte * 1000
	EByte = PByte * 1000
)

SI Sizes.

View Source
const (
	// MinimumVolumeSize is the minimum size of a volume created with mkfs (1 MB).
	MinimumVolumeSize = MByte
)
View Source
const ProviderName = "onprem"

ProviderName of the cloud platform provider

Variables

This section is empty.

Functions

func AddMountsFromConfig

func AddMountsFromConfig(config *types.Config) error

AddMountsFromConfig adds RunConfig.Mounts to image from existing Mounts to simulate attach/detach volume locally

func AddVirtfsShares

func AddVirtfsShares(config *types.Config) error

AddVirtfsShares sets up RunConfig.VirtfsShares for the hypervisor

func FindBridgedIP

func FindBridgedIP(instanceID string) string

FindBridgedIP returns the ip for an instance by forcing arp resolution. You should probably use the other function that takes a pid though.

super hacky mac extraction, arp resolution; revisit in future could also potentially extract from logs || could have nanos ping upon boot

func FindBridgedIPByPID

func FindBridgedIPByPID(pid string) string

FindBridgedIPByPID finds a qemu process with the pid and returns the ip.

func GetVolumes

func GetVolumes(dir string, query map[string]string) ([]lepton.NanosVolume, error)

GetVolumes get nanos volume using filter TODO might be better to interface this

Types

type OnPrem

type OnPrem struct{}

OnPrem Provider to interact with OnPrem infrastructure

func NewProvider

func NewProvider() *OnPrem

NewProvider OnPrem

func (*OnPrem) AttachVolume

func (op *OnPrem) AttachVolume(ctx *lepton.Context, instanceName string, volumeName string, attachID int) error

AttachVolume attaches volume to instance on `ops instance create -t onprem` or `ops run --mounts` on `ops image create --mount`, it simply creates a mount path with the given volume label label can refer to volume UUID or volume label

You must start the instance with QMP otherwise this won't work.
{
  "RunConfig": {
    "QMP": true
  }
}

this currently requires instance name to be unique

func (*OnPrem) BuildImage

func (p *OnPrem) BuildImage(ctx *lepton.Context) (string, error)

BuildImage for onprem

func (*OnPrem) BuildImageWithPackage

func (p *OnPrem) BuildImageWithPackage(ctx *lepton.Context, pkgpath string) (string, error)

BuildImageWithPackage for onprem

func (*OnPrem) CreateImage

func (p *OnPrem) CreateImage(ctx *lepton.Context, imagePath string) error

CreateImage on prem assumes local for now

func (*OnPrem) CreateInstance

func (p *OnPrem) CreateInstance(ctx *lepton.Context) error

CreateInstance on premise assumes local

func (*OnPrem) CreateInstancePID

func (p *OnPrem) CreateInstancePID(ctx *lepton.Context) (string, error)

CreateInstancePID creates an instance and returns the pid.

func (*OnPrem) CreateVolume

func (op *OnPrem) CreateVolume(ctx *lepton.Context, name, data, provider string) (lepton.NanosVolume, error)

CreateVolume creates volume for onprem image

func (*OnPrem) CustomizeImage

func (p *OnPrem) CustomizeImage(ctx *lepton.Context) (string, error)

CustomizeImage for onprem as stub to satisfy interface

func (*OnPrem) DeleteImage

func (p *OnPrem) DeleteImage(ctx *lepton.Context, imagename string) error

DeleteImage on premise

func (*OnPrem) DeleteInstance

func (p *OnPrem) DeleteInstance(ctx *lepton.Context, instancename string) error

DeleteInstance from on premise

func (*OnPrem) DeleteVolume

func (op *OnPrem) DeleteVolume(ctx *lepton.Context, name string) error

DeleteVolume deletes nanos-managed volume (filename and symlink)

func (*OnPrem) DetachVolume

func (op *OnPrem) DetachVolume(ctx *lepton.Context, instanceName string, volumeName string) error

DetachVolume detaches volume

func (*OnPrem) GetAllVolumes

func (op *OnPrem) GetAllVolumes(ctx *lepton.Context) (*[]lepton.NanosVolume, error)

GetAllVolumes prints list of all onprem nanos-managed volumes

func (*OnPrem) GetImages

func (p *OnPrem) GetImages(ctx *lepton.Context) (images []lepton.CloudImage, err error)

GetImages return all images on prem

func (*OnPrem) GetInstanceByName

func (p *OnPrem) GetInstanceByName(ctx *lepton.Context, name string) (*lepton.CloudInstance, error)

GetInstanceByName returns instance with given name

func (*OnPrem) GetInstanceLogs

func (p *OnPrem) GetInstanceLogs(ctx *lepton.Context, instancename string) (string, error)

GetInstanceLogs for onprem instance logs

func (*OnPrem) GetInstances

func (p *OnPrem) GetInstances(ctx *lepton.Context) (instances []lepton.CloudInstance, err error)

GetInstances return all instances on prem

func (*OnPrem) GetMetaInstanceByName

func (p *OnPrem) GetMetaInstanceByName(ctx *lepton.Context, name string) (*instance, error)

GetMetaInstanceByName returns onprem metadata about a given named instance.

func (*OnPrem) GetMetaInstances

func (p *OnPrem) GetMetaInstances(ctx *lepton.Context) (instances []instance, err error)

GetMetaInstances returns instance data for onprem metadata found in ~/.ops/instances .

func (*OnPrem) GetStorage

func (p *OnPrem) GetStorage() lepton.Storage

GetStorage returns storage interface for cloud provider

func (*OnPrem) Initialize

func (p *OnPrem) Initialize(config *types.ProviderConfig) error

Initialize on prem provider

func (*OnPrem) ListImages

func (p *OnPrem) ListImages(ctx *lepton.Context) error

ListImages on premise

func (*OnPrem) ListInstances

func (p *OnPrem) ListInstances(ctx *lepton.Context) error

ListInstances on premise

func (*OnPrem) PrintInstanceLogs

func (p *OnPrem) PrintInstanceLogs(ctx *lepton.Context, instancename string, watch bool) error

PrintInstanceLogs writes instance logs to console

func (*OnPrem) RebootInstance

func (p *OnPrem) RebootInstance(ctx *lepton.Context, instancename string) error

RebootInstance from on premise

func (*OnPrem) ResizeImage

func (p *OnPrem) ResizeImage(ctx *lepton.Context, imagename string, hbytes string) error

ResizeImage resizes the lcoal image imagename. You should never specify a negative size.

func (*OnPrem) StartInstance

func (p *OnPrem) StartInstance(ctx *lepton.Context, instancename string) error

StartInstance from on premise right now this assumes it was paused; not a boot; there's another call we can use here to get the status first

func (*OnPrem) StopInstance

func (p *OnPrem) StopInstance(ctx *lepton.Context, instancename string) error

StopInstance from on premise

func (*OnPrem) SyncImage

func (p *OnPrem) SyncImage(config *types.Config, target lepton.Provider, image string) error

SyncImage syncs image from onprem to target provider provided in Context

Jump to

Keyboard shortcuts

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