github.phpd.cn/hashicorp/packer@v1.3.2/builder/hyperv/common/driver.go (about)

     1  package common
     2  
     3  import (
     4  	"context"
     5  )
     6  
     7  // A driver is able to talk to HyperV and perform certain
     8  // operations with it. Some of the operations on here may seem overly
     9  // specific, but they were built specifically in mind to handle features
    10  // of the HyperV builder for Packer, and to abstract differences in
    11  // versions out of the builder steps, so sometimes the methods are
    12  // extremely specific.
    13  type Driver interface {
    14  
    15  	// Checks if the VM named is running.
    16  	IsRunning(string) (bool, error)
    17  
    18  	// Checks if the VM named is off.
    19  	IsOff(string) (bool, error)
    20  
    21  	//How long has VM been on
    22  	Uptime(vmName string) (uint64, error)
    23  
    24  	// Start starts a VM specified by the name given.
    25  	Start(string) error
    26  
    27  	// Stop stops a VM specified by the name given.
    28  	Stop(string) error
    29  
    30  	// Verify checks to make sure that this driver should function
    31  	// properly. If there is any indication the driver can't function,
    32  	// this will return an error.
    33  	Verify() error
    34  
    35  	// Finds the MAC address of the NIC nic0
    36  	Mac(string) (string, error)
    37  
    38  	// Finds the IP address of a VM connected that uses DHCP by its MAC address
    39  	IpAddress(string) (string, error)
    40  
    41  	// Finds the hostname for the ip address
    42  	GetHostName(string) (string, error)
    43  
    44  	// Finds the IP address of a host adapter connected to switch
    45  	GetHostAdapterIpAddressForSwitch(string) (string, error)
    46  
    47  	// Type scan codes to virtual keyboard of vm
    48  	TypeScanCodes(string, string) error
    49  
    50  	//Get the ip address for network adaptor
    51  	GetVirtualMachineNetworkAdapterAddress(string) (string, error)
    52  
    53  	//Set the vlan to use for switch
    54  	SetNetworkAdapterVlanId(string, string) error
    55  
    56  	//Set the vlan to use for machine
    57  	SetVirtualMachineVlanId(string, string) error
    58  
    59  	SetVmNetworkAdapterMacAddress(string, string) error
    60  
    61  	UntagVirtualMachineNetworkAdapterVlan(string, string) error
    62  
    63  	CreateExternalVirtualSwitch(string, string) error
    64  
    65  	GetVirtualMachineSwitchName(string) (string, error)
    66  
    67  	ConnectVirtualMachineNetworkAdapterToSwitch(string, string) error
    68  
    69  	CreateVirtualSwitch(string, string) (bool, error)
    70  
    71  	DeleteVirtualSwitch(string) error
    72  
    73  	CreateVirtualMachine(string, string, string, int64, int64, int64, string, uint, bool, bool) error
    74  
    75  	AddVirtualMachineHardDrive(string, string, string, int64, int64, string) error
    76  
    77  	CloneVirtualMachine(string, string, string, bool, string, string, string, int64, string) error
    78  
    79  	DeleteVirtualMachine(string) error
    80  
    81  	GetVirtualMachineGeneration(string) (uint, error)
    82  
    83  	SetVirtualMachineCpuCount(string, uint) error
    84  
    85  	SetVirtualMachineMacSpoofing(string, bool) error
    86  
    87  	SetVirtualMachineDynamicMemory(string, bool) error
    88  
    89  	SetVirtualMachineSecureBoot(string, bool, string) error
    90  
    91  	SetVirtualMachineVirtualizationExtensions(string, bool) error
    92  
    93  	EnableVirtualMachineIntegrationService(string, string) error
    94  
    95  	ExportVirtualMachine(string, string) error
    96  
    97  	PreserveLegacyExportBehaviour(string, string) error
    98  
    99  	MoveCreatedVHDsToOutputDir(string, string) error
   100  
   101  	CompactDisks(string) (string, error)
   102  
   103  	RestartVirtualMachine(string) error
   104  
   105  	CreateDvdDrive(string, string, uint) (uint, uint, error)
   106  
   107  	MountDvdDrive(string, string, uint, uint) error
   108  
   109  	SetBootDvdDrive(string, uint, uint, uint) error
   110  
   111  	UnmountDvdDrive(string, uint, uint) error
   112  
   113  	DeleteDvdDrive(string, uint, uint) error
   114  
   115  	MountFloppyDrive(string, string) error
   116  
   117  	UnmountFloppyDrive(string) error
   118  
   119  	// Connect connects to a VM specified by the name given.
   120  	Connect(string) (context.CancelFunc, error)
   121  
   122  	// Disconnect disconnects to a VM specified by the context cancel function.
   123  	Disconnect(context.CancelFunc)
   124  }