hyperv

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: 21 Imported by: 0

Documentation

Index

Constants

View Source
const ProviderName = "hyper-v"

ProviderName of the cloud platform provider

Variables

This section is empty.

Functions

func AddVirtualMachineHardDiskDrive

func AddVirtualMachineHardDiskDrive(vmName string, path string, hdController string, setBootDev bool) error

AddVirtualMachineHardDiskDrive adds virtual hard disk (vhdx) in path to virtual machine Due to issues on using vhdx files located inside WSL it copies the image to a user directory located at `~/vhdx-images` before attaching to the virtual machine. See more details on https://github.com/MicrosoftDocs/windows-powershell-docs/issues/2286

func AddVirtualMachineNetworkAdapter

func AddVirtualMachineNetworkAdapter(vmName string, vmSwitch string) error

AddVirtualMachineNetworkAdapter creates a virtual machine network adapter that connects to a switch

func ConnectVirtualMachineNetworkAdapterToSwitch

func ConnectVirtualMachineNetworkAdapterToSwitch(vmName string, switchName string) error

ConnectVirtualMachineNetworkAdapterToSwitch connects current virtual machine network adapter to switch

func CreateExternalVirtualSwitch

func CreateExternalVirtualSwitch(switchName string) error

CreateExternalVirtualSwitch creates an external virtual switch connected to a physical network adapter

func CreateVirtualMachine

func CreateVirtualMachine(vmName string, path string, ram int64, diskSize int64, switchName string, generation uint) error

CreateVirtualMachine creates a virtual machine

func CreateVirtualMachineWithNoHD

func CreateVirtualMachineWithNoHD(vmName string, ram int64, generation uint) error

CreateVirtualMachineWithNoHD creates a virtual machine without disks attached. The image disk is attached after using 'AddVirtualMachineHardDiskDrive'

func CreateVirtualSwitch

func CreateVirtualSwitch(switchName string, switchType string) (bool, error)

CreateVirtualSwitch creates a virtual switch

func DeleteVirtualMachine

func DeleteVirtualMachine(vmName string) error

DeleteVirtualMachine deletes a virtual machine

func DeleteVirtualSwitch

func DeleteVirtualSwitch(switchName string) error

DeleteVirtualSwitch deletes a virtual switch

func GetExternalOnlineVirtualSwitch

func GetExternalOnlineVirtualSwitch() (string, error)

GetExternalOnlineVirtualSwitch returns an online external virtual switch name

func GetVirtualMachineByName

func GetVirtualMachineByName(vmName string) (string, error)

GetVirtualMachineByName returns a virtual machine details

func GetVirtualMachineNetworkAdapterAddress

func GetVirtualMachineNetworkAdapterAddress(vmName string) (string, error)

GetVirtualMachineNetworkAdapterAddress returns a virtual machine ip address

func GetVirtualMachineSwitchName

func GetVirtualMachineSwitchName(vmName string) (string, error)

GetVirtualMachineSwitchName returns the name of the switch connected to a virtual machine

func GetVirtualMachines

func GetVirtualMachines() (string, error)

GetVirtualMachines returns the list of virtual machines

func IPAddress

func IPAddress(mac string) (string, error)

IPAddress gets virtual machine ip addresses

func IsOff

func IsOff(vmName string) (bool, error)

IsOff checks whether a virtual machine is off

func IsPowershellAvailable

func IsPowershellAvailable() (bool, string, error)

IsPowershellAvailable checks whether powershell executable exists in os

func IsRunning

func IsRunning(vmName string) (bool, error)

IsRunning checks whether a virtual machine is running

func Mac

func Mac(vmName string) (string, error)

Mac returns mac address of virtual machine network adapter

func RestartVirtualMachine

func RestartVirtualMachine(vmName string) error

RestartVirtualMachine restarts a virtual machine

func SetVMComPort

func SetVMComPort(vmName string) error

SetVMComPort sets com port with a named pipe with the same name of the vm

func SetVMSecureBoot

func SetVMSecureBoot(vmName string, enable bool) error

SetVMSecureBoot enables or disables secure boot on a VM

func ShutDown

func ShutDown(vmName string) error

ShutDown forces virtual machine to stop

func StartVirtualMachine

func StartVirtualMachine(vmName string) error

StartVirtualMachine starts a virtual machine

func StopVirtualMachine

func StopVirtualMachine(vmName string) error

StopVirtualMachine stops a virtual machine

func TurnOff

func TurnOff(vmName string) error

TurnOff turns virtual machine off

func Uptime

func Uptime(vmName string) (uint64, error)

Uptime gets virtual machine uptime

Types

type PowerShellCmd

type PowerShellCmd struct {
	Stdout io.Writer
	Stderr io.Writer
}

PowerShellCmd executes powershell commands

func (*PowerShellCmd) Output

func (ps *PowerShellCmd) Output(fileContents string, params ...string) (string, error)

Output runs the PowerShell command and returns its standard output.

func (*PowerShellCmd) Run

func (ps *PowerShellCmd) Run(fileContents string, params ...string) error

Run executes powershell command

type Provider

type Provider struct{}

Provider to interact with Hyper-V cloud infrastructure

func NewProvider

func NewProvider() *Provider

NewProvider Hyper-V

func (*Provider) AttachVolume

func (p *Provider) AttachVolume(ctx *lepton.Context, image, name string, attachID int) error

AttachVolume is a stub

func (*Provider) BuildImage

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

BuildImage creates and converts a raw image to vhdx

func (*Provider) BuildImageWithPackage

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

BuildImageWithPackage creates and converts a raw image to vhdx using package image

func (*Provider) CreateImage

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

CreateImage is a stub

func (*Provider) CreateInstance

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

CreateInstance uses a vhdx image to launch a virtual machine in hyper-v

func (*Provider) CreateVolume

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

CreateVolume is a stub

func (*Provider) CustomizeImage

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

CustomizeImage is a stub

func (*Provider) DeleteImage

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

DeleteImage removes hyper-v image

func (*Provider) DeleteInstance

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

DeleteInstance removes virtual machine

func (*Provider) DeleteVolume

func (p *Provider) DeleteVolume(ctx *lepton.Context, name string) error

DeleteVolume is a stub

func (*Provider) DetachVolume

func (p *Provider) DetachVolume(ctx *lepton.Context, image, name string) error

DetachVolume is a stub

func (*Provider) GetAllVolumes

func (p *Provider) GetAllVolumes(ctx *lepton.Context) (*[]lepton.NanosVolume, error)

GetAllVolumes is a stub

func (*Provider) GetImages

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

GetImages returns the list of images available to run hyper-v virtual machines

func (*Provider) GetInstanceByName

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

GetInstanceByName returns hyper-v virtual machine with given name

func (*Provider) GetInstanceLogs

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

GetInstanceLogs reads content from named pipe file

func (*Provider) GetInstances

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

GetInstances returns the list of virtual machines managed by hyper-v

func (*Provider) Initialize

func (p *Provider) Initialize(c *types.ProviderConfig) error

Initialize checks conditions to use hyper-v

func (*Provider) ListImages

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

ListImages prints hyper-v images in table format

func (*Provider) ListInstances

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

ListInstances prints virtual machines list managed by hyper-v in table

func (*Provider) PrintInstanceLogs

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

PrintInstanceLogs prints vm logs content on console

func (*Provider) RebootInstance

func (p *Provider) RebootInstance(ctx *lepton.Context, instanceName string) error

RebootInstance reboots the instance.

func (*Provider) ResizeImage

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

ResizeImage is a stub

func (*Provider) StartInstance

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

StartInstance initiates virtual machine in hyper-v

func (*Provider) StopInstance

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

StopInstance stops virtual machine in hyper-v

func (*Provider) SyncImage

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

SyncImage is a stub

Jump to

Keyboard shortcuts

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