2015-06-21 12:36:07 +01:00
|
|
|
package common
|
|
|
|
|
2018-05-06 07:54:58 +10:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
)
|
|
|
|
|
2015-06-21 12:36:07 +01:00
|
|
|
// A driver is able to talk to HyperV and perform certain
|
|
|
|
// operations with it. Some of the operations on here may seem overly
|
|
|
|
// specific, but they were built specifically in mind to handle features
|
|
|
|
// of the HyperV builder for Packer, and to abstract differences in
|
|
|
|
// versions out of the builder steps, so sometimes the methods are
|
|
|
|
// extremely specific.
|
|
|
|
type Driver interface {
|
|
|
|
|
|
|
|
// Checks if the VM named is running.
|
|
|
|
IsRunning(string) (bool, error)
|
|
|
|
|
2015-10-30 08:23:30 +00:00
|
|
|
// Checks if the VM named is off.
|
|
|
|
IsOff(string) (bool, error)
|
|
|
|
|
|
|
|
//How long has VM been on
|
|
|
|
Uptime(vmName string) (uint64, error)
|
|
|
|
|
2015-06-21 12:36:07 +01:00
|
|
|
// Start starts a VM specified by the name given.
|
|
|
|
Start(string) error
|
|
|
|
|
|
|
|
// Stop stops a VM specified by the name given.
|
|
|
|
Stop(string) error
|
|
|
|
|
|
|
|
// Verify checks to make sure that this driver should function
|
|
|
|
// properly. If there is any indication the driver can't function,
|
|
|
|
// this will return an error.
|
2015-06-27 22:36:39 +01:00
|
|
|
Verify() error
|
|
|
|
|
2015-06-21 12:36:07 +01:00
|
|
|
// Finds the MAC address of the NIC nic0
|
|
|
|
Mac(string) (string, error)
|
|
|
|
|
|
|
|
// Finds the IP address of a VM connected that uses DHCP by its MAC address
|
|
|
|
IpAddress(string) (string, error)
|
2015-06-27 22:36:39 +01:00
|
|
|
|
2015-10-30 08:23:30 +00:00
|
|
|
// Finds the hostname for the ip address
|
|
|
|
GetHostName(string) (string, error)
|
|
|
|
|
2015-06-27 22:36:39 +01:00
|
|
|
// Finds the IP address of a host adapter connected to switch
|
|
|
|
GetHostAdapterIpAddressForSwitch(string) (string, error)
|
|
|
|
|
|
|
|
// Type scan codes to virtual keyboard of vm
|
|
|
|
TypeScanCodes(string, string) error
|
2015-10-30 08:23:30 +00:00
|
|
|
|
|
|
|
//Get the ip address for network adaptor
|
|
|
|
GetVirtualMachineNetworkAdapterAddress(string) (string, error)
|
|
|
|
|
|
|
|
//Set the vlan to use for switch
|
|
|
|
SetNetworkAdapterVlanId(string, string) error
|
|
|
|
|
|
|
|
//Set the vlan to use for machine
|
|
|
|
SetVirtualMachineVlanId(string, string) error
|
|
|
|
|
2017-12-15 13:24:15 +11:00
|
|
|
SetVmNetworkAdapterMacAddress(string, string) error
|
|
|
|
|
2018-12-18 04:59:00 -06:00
|
|
|
//Replace the network adapter with a (non-)legacy adapter
|
|
|
|
ReplaceVirtualMachineNetworkAdapter(string, bool) error
|
|
|
|
|
2015-10-30 08:23:30 +00:00
|
|
|
UntagVirtualMachineNetworkAdapterVlan(string, string) error
|
|
|
|
|
|
|
|
CreateExternalVirtualSwitch(string, string) error
|
|
|
|
|
|
|
|
GetVirtualMachineSwitchName(string) (string, error)
|
|
|
|
|
|
|
|
ConnectVirtualMachineNetworkAdapterToSwitch(string, string) error
|
|
|
|
|
|
|
|
CreateVirtualSwitch(string, string) (bool, error)
|
|
|
|
|
|
|
|
DeleteVirtualSwitch(string) error
|
|
|
|
|
2019-06-13 14:09:45 -07:00
|
|
|
CheckVMName(string) error
|
|
|
|
|
2018-12-19 16:30:57 -08:00
|
|
|
CreateVirtualMachine(string, string, string, int64, int64, int64, string, uint, bool, bool, string) error
|
2015-10-30 08:23:30 +00:00
|
|
|
|
2018-02-23 20:19:26 +01:00
|
|
|
AddVirtualMachineHardDrive(string, string, string, int64, int64, string) error
|
2017-10-20 09:29:17 +11:00
|
|
|
|
2018-12-10 14:46:16 -08:00
|
|
|
CloneVirtualMachine(string, string, string, bool, string, string, string, int64, string, bool) error
|
2017-03-12 11:31:31 +00:00
|
|
|
|
2015-10-30 08:23:30 +00:00
|
|
|
DeleteVirtualMachine(string) error
|
|
|
|
|
2017-03-12 11:31:31 +00:00
|
|
|
GetVirtualMachineGeneration(string) (uint, error)
|
|
|
|
|
2016-08-07 12:26:27 +01:00
|
|
|
SetVirtualMachineCpuCount(string, uint) error
|
2015-10-30 08:23:30 +00:00
|
|
|
|
2016-08-07 12:26:27 +01:00
|
|
|
SetVirtualMachineMacSpoofing(string, bool) error
|
|
|
|
|
|
|
|
SetVirtualMachineDynamicMemory(string, bool) error
|
|
|
|
|
2018-05-10 19:00:35 +02:00
|
|
|
SetVirtualMachineSecureBoot(string, bool, string) error
|
2016-08-07 12:26:27 +01:00
|
|
|
|
|
|
|
SetVirtualMachineVirtualizationExtensions(string, bool) error
|
2015-10-30 08:23:30 +00:00
|
|
|
|
|
|
|
EnableVirtualMachineIntegrationService(string, string) error
|
|
|
|
|
|
|
|
ExportVirtualMachine(string, string) error
|
|
|
|
|
2018-07-04 13:03:32 +01:00
|
|
|
PreserveLegacyExportBehaviour(string, string) error
|
|
|
|
|
2018-07-08 17:22:27 +01:00
|
|
|
MoveCreatedVHDsToOutputDir(string, string) error
|
|
|
|
|
2018-07-05 21:16:51 +01:00
|
|
|
CompactDisks(string) (string, error)
|
2015-10-30 08:23:30 +00:00
|
|
|
|
|
|
|
RestartVirtualMachine(string) error
|
|
|
|
|
2015-12-05 03:03:33 -08:00
|
|
|
CreateDvdDrive(string, string, uint) (uint, uint, error)
|
2015-10-30 08:23:30 +00:00
|
|
|
|
2015-11-01 16:00:56 +00:00
|
|
|
MountDvdDrive(string, string, uint, uint) error
|
2015-11-07 13:42:26 +00:00
|
|
|
|
2020-02-21 01:01:09 -06:00
|
|
|
SetBootDvdDrive(string, uint, uint, uint) error
|
|
|
|
|
|
|
|
SetFirstBootDevice(string, string, uint, uint, uint) error
|
2015-11-07 13:42:26 +00:00
|
|
|
|
2020-04-30 12:31:41 +01:00
|
|
|
SetBootOrder(string, []string) error
|
|
|
|
|
2015-11-01 16:00:56 +00:00
|
|
|
UnmountDvdDrive(string, uint, uint) error
|
2015-10-30 08:23:30 +00:00
|
|
|
|
2015-10-30 17:19:25 +00:00
|
|
|
DeleteDvdDrive(string, uint, uint) error
|
2015-10-30 08:23:30 +00:00
|
|
|
|
2015-10-30 17:19:25 +00:00
|
|
|
MountFloppyDrive(string, string) error
|
2015-11-07 13:42:26 +00:00
|
|
|
|
2015-10-30 17:19:25 +00:00
|
|
|
UnmountFloppyDrive(string) error
|
2018-05-06 07:54:58 +10:00
|
|
|
|
|
|
|
// Connect connects to a VM specified by the name given.
|
2018-05-10 21:50:56 +10:00
|
|
|
Connect(string) (context.CancelFunc, error)
|
2018-05-06 07:54:58 +10:00
|
|
|
|
|
|
|
// Disconnect disconnects to a VM specified by the context cancel function.
|
|
|
|
Disconnect(context.CancelFunc)
|
2015-06-21 12:36:07 +01:00
|
|
|
}
|