2015-06-21 07:36:07 -04:00
|
|
|
package common
|
|
|
|
|
2018-05-05 17:54:58 -04:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
)
|
|
|
|
|
2015-06-21 07:36:07 -04: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 04:23:30 -04: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 07:36:07 -04: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 17:36:39 -04:00
|
|
|
Verify() error
|
|
|
|
|
2015-06-21 07:36:07 -04: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 17:36:39 -04:00
|
|
|
|
2015-10-30 04:23:30 -04:00
|
|
|
// Finds the hostname for the ip address
|
|
|
|
GetHostName(string) (string, error)
|
|
|
|
|
2015-06-27 17:36:39 -04: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 04:23:30 -04: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-14 21:24:15 -05:00
|
|
|
SetVmNetworkAdapterMacAddress(string, string) error
|
|
|
|
|
2018-12-18 05:59:00 -05:00
|
|
|
//Replace the network adapter with a (non-)legacy adapter
|
|
|
|
ReplaceVirtualMachineNetworkAdapter(string, bool) error
|
|
|
|
|
2015-10-30 04:23:30 -04: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 17:09:45 -04:00
|
|
|
CheckVMName(string) error
|
|
|
|
|
2018-12-19 19:30:57 -05:00
|
|
|
CreateVirtualMachine(string, string, string, int64, int64, int64, string, uint, bool, bool, string) error
|
2015-10-30 04:23:30 -04:00
|
|
|
|
2018-02-23 14:19:26 -05:00
|
|
|
AddVirtualMachineHardDrive(string, string, string, int64, int64, string) error
|
2017-10-19 18:29:17 -04:00
|
|
|
|
2018-12-10 17:46:16 -05:00
|
|
|
CloneVirtualMachine(string, string, string, bool, string, string, string, int64, string, bool) error
|
2017-03-12 07:31:31 -04:00
|
|
|
|
2015-10-30 04:23:30 -04:00
|
|
|
DeleteVirtualMachine(string) error
|
|
|
|
|
2017-03-12 07:31:31 -04:00
|
|
|
GetVirtualMachineGeneration(string) (uint, error)
|
|
|
|
|
2016-08-07 07:26:27 -04:00
|
|
|
SetVirtualMachineCpuCount(string, uint) error
|
2015-10-30 04:23:30 -04:00
|
|
|
|
2016-08-07 07:26:27 -04:00
|
|
|
SetVirtualMachineMacSpoofing(string, bool) error
|
|
|
|
|
|
|
|
SetVirtualMachineDynamicMemory(string, bool) error
|
|
|
|
|
2018-05-10 13:00:35 -04:00
|
|
|
SetVirtualMachineSecureBoot(string, bool, string) error
|
2016-08-07 07:26:27 -04:00
|
|
|
|
|
|
|
SetVirtualMachineVirtualizationExtensions(string, bool) error
|
2015-10-30 04:23:30 -04:00
|
|
|
|
|
|
|
EnableVirtualMachineIntegrationService(string, string) error
|
|
|
|
|
|
|
|
ExportVirtualMachine(string, string) error
|
|
|
|
|
2018-07-04 08:03:32 -04:00
|
|
|
PreserveLegacyExportBehaviour(string, string) error
|
|
|
|
|
2018-07-08 12:22:27 -04:00
|
|
|
MoveCreatedVHDsToOutputDir(string, string) error
|
|
|
|
|
2018-07-05 16:16:51 -04:00
|
|
|
CompactDisks(string) (string, error)
|
2015-10-30 04:23:30 -04:00
|
|
|
|
|
|
|
RestartVirtualMachine(string) error
|
|
|
|
|
2015-12-05 06:03:33 -05:00
|
|
|
CreateDvdDrive(string, string, uint) (uint, uint, error)
|
2015-10-30 04:23:30 -04:00
|
|
|
|
2015-11-01 11:00:56 -05:00
|
|
|
MountDvdDrive(string, string, uint, uint) error
|
2015-11-07 08:42:26 -05:00
|
|
|
|
|
|
|
SetBootDvdDrive(string, uint, uint, uint) error
|
|
|
|
|
2015-11-01 11:00:56 -05:00
|
|
|
UnmountDvdDrive(string, uint, uint) error
|
2015-10-30 04:23:30 -04:00
|
|
|
|
2015-10-30 13:19:25 -04:00
|
|
|
DeleteDvdDrive(string, uint, uint) error
|
2015-10-30 04:23:30 -04:00
|
|
|
|
2015-10-30 13:19:25 -04:00
|
|
|
MountFloppyDrive(string, string) error
|
2015-11-07 08:42:26 -05:00
|
|
|
|
2015-10-30 13:19:25 -04:00
|
|
|
UnmountFloppyDrive(string) error
|
2018-05-05 17:54:58 -04:00
|
|
|
|
|
|
|
// Connect connects to a VM specified by the name given.
|
2018-05-10 07:50:56 -04:00
|
|
|
Connect(string) (context.CancelFunc, error)
|
2018-05-05 17:54:58 -04:00
|
|
|
|
|
|
|
// Disconnect disconnects to a VM specified by the context cancel function.
|
|
|
|
Disconnect(context.CancelFunc)
|
2015-06-21 07:36:07 -04:00
|
|
|
}
|