Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
5b7adb6
Port of https://github.com/pbolduc/packer-hyperv/
taliesins Jun 21, 2015
f9c7dca
Use the same configuration style as existing builders
taliesins Jun 21, 2015
755eb56
The test is meant to fail if the folder already exists
taliesins Jun 21, 2015
da1a0f4
Tests where for an old version of powershell class. Chnaged for the n…
taliesins Jun 21, 2015
d56dabd
Use the convention for default vmname
taliesins Jun 21, 2015
f4296f9
Wait until WinRM is available, before continuing with install. This i…
taliesins Jun 21, 2015
9890d7f
Throw error if we can't get mac or ip address during steps
taliesins Jun 22, 2015
ad03de1
Remove devices after it has been shut down
taliesins Jun 24, 2015
edfcdf3
Support for boot_command
taliesins Jun 27, 2015
cff52c7
With generation 2 machine by default a dvd drive is not created. So c…
taliesins Jun 29, 2015
3d17d50
Set the dvd to the first boot device
taliesins Jun 29, 2015
2b437d9
When redirecting local ports to hyper visor ports we need to configur…
Jun 30, 2015
832e1a6
We should be using uint for sshport when saving in statebag
Jun 30, 2015
e730b40
Apply template rendering to VMName
Jul 1, 2015
ea72519
Add a little safety around variables that are passed into provisioner.
Jul 1, 2015
d5a0368
Quote powershell so that it does not try to interpret command to be run
Jul 1, 2015
1f41901
Pass in any iso images to add as dvd drives during boot
taliesins Jul 12, 2015
70b85fc
Hyperv generation 2 machines use scsi for dvd drives. Allow gen 1 mac…
taliesins Jul 12, 2015
a5f0aeb
Need to expose generation as a public property
taliesins Jul 12, 2015
ed8c028
Check the floppy files and not the dvd files attached
taliesins Jul 12, 2015
cfa99c1
Remove VDI file if there is a VMDK file. We don't need VDI file as well.
Jul 13, 2015
d7b02fd
No need to remove floppy controller for 2nd generation vms
taliesins Jul 14, 2015
e81b9a1
Merge branch 'master' of https://github.com/mitchellh/packer into HyperV
taliesins Jul 16, 2015
3e122f4
Copy the folder structure correctly
taliesins Jul 16, 2015
3cee05d
Use simple naming convention for now
taliesins Jul 24, 2015
44802e1
Shelf check in - start of adding documentation
taliesins Jul 24, 2015
911cc44
Merge branch 'master' into HyperV
Jul 31, 2015
096d563
Merge branch 'master' into HyperV
Aug 7, 2015
b748257
Use plain text password
Aug 10, 2015
2bd7133
Merge branch 'master' into HyperV
Aug 10, 2015
63a82c7
Merge branch 'master' into HyperV
taliesins Sep 17, 2015
0f47da1
fix vagrant box structure
vvchik Oct 9, 2015
6a885f6
Merge branch 'master' into HyperV
taliesins Oct 17, 2015
61f1023
Merge pull request #1 from vvchik/hyperv
taliesins Oct 17, 2015
c586f4c
Should only default to first controller if its not 1 of the 2 control…
taliesins Oct 18, 2015
ae9382a
Use correct formatting for printf
taliesins Oct 18, 2015
d33449b
Quoting of powershell commands and associated tests
taliesins Oct 18, 2015
f884a35
Must escape string formatting for string fmt
taliesins Oct 18, 2015
2afd159
Default minimum and maximum sizes were geared towards spinning up win…
taliesins Oct 18, 2015
bff8578
Fix disk size test
taliesins Oct 18, 2015
b264c67
Merge branch 'HyperV' of https://github.com/taliesins/packer into HyperV
taliesins Oct 18, 2015
778298e
If there is only one ip address on a card we need to force it to be a…
taliesins Oct 25, 2015
a342e27
Merge branch 'master' of https://github.com/mitchellh/packer into HyperV
taliesins Oct 25, 2015
2c43946
Incude hyperv as part of the plugins
taliesins Oct 25, 2015
3a67c0b
Must point to iso hyperv plugin
taliesins Oct 25, 2015
101ccd8
Needs iso part
taliesins Oct 25, 2015
7e2620e
Always force turn off vm
taliesins Oct 27, 2015
52978e8
Seems like we do need to escape the double quote
taliesins Oct 28, 2015
2fc2b1d
Make use of driver instead of directly referencing hyper
taliesins Oct 30, 2015
edea154
GuestAdditionsMode and GuestAdditionsPath can be set in config. If Gu…
Oct 30, 2015
5c2ecef
Forgot to check in these files.
Oct 30, 2015
d8948d1
Include cache in the state bag.
taliesins Oct 30, 2015
32feb8a
Build agents might not have guest additions
taliesins Oct 30, 2015
3e8fa1b
Setting boot drive message
taliesins Oct 31, 2015
1e9363f
Get rid of mount and unmount that does not specify controller locatio…
taliesins Nov 1, 2015
dd77340
Useful to know what the exit code is if there is an error
taliesins Nov 1, 2015
f643bdd
If we are not getting the exit code assigned then default to it being…
Nov 2, 2015
0eeb203
Using Write-Output instead of Write-Host since PS v5 now leaks the ho…
Nov 2, 2015
81e2e1f
Ensure that progress stream does not get leaked into stdout
Nov 2, 2015
3bae6a2
Fix unit tests for not showing progress stream when using powershell
Nov 2, 2015
f0ffb3c
wite output will put ouput from function, so we don't want to be gett…
taliesins Nov 2, 2015
7d06f88
Use correct quotation of variables
taliesins Nov 2, 2015
acb6ed5
If exit code = 1 and the length of the stderr is 0, then we can assum…
taliesins Nov 3, 2015
ac80fca
Merge branch 'master' into HyperV
taliesins Nov 3, 2015
afcacaf
Accidentally included bracket
taliesins Nov 3, 2015
990cdc0
The default for wait is 1 second
taliesins Nov 4, 2015
b929dbc
Merge branch 'master' into HyperV
taliesins Nov 7, 2015
e7186f7
Fix gen 1 creation of dvd
taliesins Nov 7, 2015
0a19ccb
Setting boot drive is generation specific
taliesins Nov 7, 2015
3441535
By default a gen 1 vm get a dvd drive. Remove it on creation so that …
taliesins Nov 7, 2015
4bf0a92
Echo output when its used
taliesins Nov 7, 2015
16c08fc
removed unused reference
taliesins Nov 7, 2015
a924e41
Need to sleep after sending previous characters, not before
taliesins Nov 7, 2015
803af74
Remove all Dvd Drives on Generation 1
Nov 30, 2015
2970d27
Merge pull request #2 from gildas/HyperV
taliesins Nov 30, 2015
a6e03ae
Don't do anything if there are no scanCodes
Dec 1, 2015
19a03f2
Do not specify ComputerName with Get-CimInstance on Windows 10
Dec 1, 2015
d174dc9
Export of Hyper-V/VMCX machines
Dec 1, 2015
209004c
Merge branch 'master' of https://github.com/mitchellh/packer into HyperV
taliesins Dec 1, 2015
20c1513
Do not try to type scancodes if there are none. We haven't figured ou…
taliesins Dec 1, 2015
108eeb6
try to get the virtual keyboard a number of different ways. This shou…
taliesins Dec 5, 2015
76378c7
A workaround for bug in Windows 10 and Windows 2016 where you have to…
taliesins Dec 5, 2015
6e85886
Merge branch 'HyperV' of https://github.com/gildas/packer into HyperV
taliesins Dec 5, 2015
1aaf54b
Forget to pass in the dvd drive to eject the iso from
taliesins Dec 5, 2015
b02452f
Windows Server 2016 won't let you set the first boot device
taliesins Dec 5, 2015
2461a6f
Merge branch 'master' into HyperV
taliesins Dec 16, 2015
6b5f601
Merge branch 'master' into HyperV
taliesins Jan 25, 2016
1b6223b
http server has moved to common step
taliesins Jan 25, 2016
5be23e8
Merge branch 'master' into HyperV
taliesins Mar 29, 2016
f992221
Generate switch name using uuid v1
taliesins Mar 29, 2016
02192d1
Merged completed
taliesins Mar 29, 2016
2a4149e
Use built in UUID generator
taliesins Mar 31, 2016
28e08ff
Fix parallels test so they run on windows. IsAbs returns false for c:\
taliesins Apr 1, 2016
eef1970
On windows a lot of git clients will convert LF to CRLF. This would b…
taliesins Apr 1, 2016
9b4f019
Should not have added this file to source control
taliesins Apr 1, 2016
03dea38
When dealing with windows the file url format is file:///c:/
taliesins Apr 1, 2016
fc6e537
added file with correct line endings
taliesins Apr 1, 2016
8c9248e
Make Ansible provisioner commands that are bash or shell scripts work…
taliesins Apr 1, 2016
9b595a8
Merge branch 'master' into HyperV
taliesins Apr 7, 2016
1a8e588
Merge branch 'master' into HyperV
taliesins Jun 28, 2016
c791d0d
Try to match style of other builders
taliesins Jun 29, 2016
fe76681
Make hiding of progress backward compatible with old versions of powe…
taliesins Jun 29, 2016
6dcc39b
Merge branch 'HyperV' of https://github.com/taliesins/packer into HyperV
taliesins Jun 29, 2016
7452e2f
Dix duplicate imports
taliesins Jun 30, 2016
560fdb5
Remove another duplicate import
taliesins Jun 30, 2016
58db0a7
Skip these tests on platforms that don't have powershell installed
taliesins Jun 30, 2016
50bab2a
Don't log fatal message in tests if powershell is not available
taliesins Jun 30, 2016
57438f5
Test should run and pass even when run on an environment that does no…
taliesins Jul 1, 2016
1ff9ea5
accidentally checked in code that was used for debugging
taliesins Jul 4, 2016
3241248
Base64 encode powershell to avoid any necessary escaping
taliesins Jul 4, 2016
6cb5bb5
Encode powershell using utf8
taliesins Jul 12, 2016
7fd23d2
Pattern for infrastructure changed to quote filename and execute file…
taliesins Jul 13, 2016
6faed53
Powershell uses UTF16Le for encodedCommand
taliesins Jul 24, 2016
01292eb
Builds in AppVeyor are failing as they do not have enough free memory…
taliesins Jul 24, 2016
dd9b549
Merge branch 'master' into HyperV
taliesins Jul 24, 2016
710b057
Add type scan support for ctrl, shift, alt.
taliesins Jul 30, 2016
d7fd3bf
Dvd drive creation will auto select the controller number and control…
taliesins Jul 31, 2016
db90cf4
Add special key modifiers to log output when used.
taliesins Jul 31, 2016
38bc450
Merge branch 'master' of https://github.com/taliesins/packer into HyperV
taliesins Jul 31, 2016
483dfd8
Add special key logging back
taliesins Jul 31, 2016
67a2db0
Enable-VMIntegrationService cmdlet has a language dependent value for…
taliesins Aug 2, 2016
5e7ede4
s/EnabeSecureBoot/EnableSecureBoot/g
PatrickLang Aug 6, 2016
9126e52
Adding nested virtualization support
PatrickLang Aug 6, 2016
7ad92b8
Adding support for nested Hyper-V
PatrickLang Aug 6, 2016
c6da09e
Adding support for nested Hyper-V
PatrickLang Aug 6, 2016
51a515c
Fix type casting
PatrickLang Aug 6, 2016
494f693
Merge branch 'PatrickLang-hyperv-nested' into HyperV
taliesins Aug 7, 2016
51a4845
Add support for mac spoofing and dynamic memory.
taliesins Aug 7, 2016
01611e4
Add documentation for: enable_mac_spoofing, enable_dynamic_memory and…
taliesins Aug 7, 2016
5cfa97d
Enable VlanID
efx-jjohnson Sep 21, 2016
8ae60d8
Merge branch 'master' of https://github.com/taliesins/packer into HyperV
taliesins Sep 29, 2016
4fe13ee
Fix dodgy merge
taliesins Sep 29, 2016
4d70b68
Remove duplicate plugin
taliesins Sep 29, 2016
c896144
Merge pull request #7 from EFXCIA/HyperV
taliesins Sep 29, 2016
002094b
Added the ability to independently configure switch vlan. This will p…
taliesins Sep 29, 2016
6ed0456
SetVmIp on HyperV VM as per kitchen-hyperv
gaelcolas Oct 5, 2016
1a6e37a
reverting comment-out setpConfigureIP part
gaelcolas Oct 5, 2016
fcf895e
Adding documentation to set ip support.
gaelcolas Oct 5, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

common/test-fixtures/root/* eol=lf
65 changes: 65 additions & 0 deletions builder/hyperv/common/artifact.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package common

import (
"fmt"
"os"
"path/filepath"

"github.com/mitchellh/packer/packer"
)

// This is the common builder ID to all of these artifacts.
const BuilderId = "MSOpenTech.hyperv"

// Artifact is the result of running the hyperv builder, namely a set
// of files associated with the resulting machine.
type artifact struct {
dir string
f []string
}

// NewArtifact returns a hyperv artifact containing the files
// in the given directory.
func NewArtifact(dir string) (packer.Artifact, error) {
files := make([]string, 0, 5)
visit := func(path string, info os.FileInfo, err error) error {
if !info.IsDir() {
files = append(files, path)
}

return err
}

if err := filepath.Walk(dir, visit); err != nil {
return nil, err
}

return &artifact{
dir: dir,
f: files,
}, nil
}

func (*artifact) BuilderId() string {
return BuilderId
}

func (a *artifact) Files() []string {
return a.f
}

func (*artifact) Id() string {
return "VM"
}

func (a *artifact) String() string {
return fmt.Sprintf("VM files in directory: %s", a.dir)
}

func (a *artifact) State(name string) interface{} {
return nil
}

func (a *artifact) Destroy() error {
return os.RemoveAll(a.dir)
}
43 changes: 43 additions & 0 deletions builder/hyperv/common/artifact_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package common

import (
"io/ioutil"
"os"
"path/filepath"
"testing"

"github.com/mitchellh/packer/packer"
)

func TestArtifact_impl(t *testing.T) {
var _ packer.Artifact = new(artifact)
}

func TestNewArtifact(t *testing.T) {
td, err := ioutil.TempDir("", "packer")
if err != nil {
t.Fatalf("err: %s", err)
}
defer os.RemoveAll(td)

err = ioutil.WriteFile(filepath.Join(td, "a"), []byte("foo"), 0644)
if err != nil {
t.Fatalf("err: %s", err)
}

if err := os.Mkdir(filepath.Join(td, "b"), 0755); err != nil {
t.Fatalf("err: %s", err)
}

a, err := NewArtifact(td)
if err != nil {
t.Fatalf("err: %s", err)
}

if a.BuilderId() != BuilderId {
t.Fatalf("bad: %#v", a.BuilderId())
}
if len(a.Files()) != 1 {
t.Fatalf("should length 1: %d", len(a.Files()))
}
}
11 changes: 11 additions & 0 deletions builder/hyperv/common/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package common

import (
"testing"

"github.com/mitchellh/packer/template/interpolate"
)

func testConfigTemplate(t *testing.T) *interpolate.Context {
return &interpolate.Context{}
}
110 changes: 110 additions & 0 deletions builder/hyperv/common/driver.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// Copyright (c) Microsoft Open Technologies, Inc.
// All Rights Reserved.
// Licensed under the Apache License, Version 2.0.
// See License.txt in the project root for license information.
package common

// 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)

// Checks if the VM named is off.
IsOff(string) (bool, error)

//How long has VM been on
Uptime(vmName string) (uint64, error)

// 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.
Verify() error

// 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)

// Finds the hostname for the ip address
GetHostName(string) (string, error)

// 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

//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

UntagVirtualMachineNetworkAdapterVlan(string, string) error

CreateExternalVirtualSwitch(string, string) error

GetVirtualMachineSwitchName(string) (string, error)

ConnectVirtualMachineNetworkAdapterToSwitch(string, string) error

CreateVirtualSwitch(string, string) (bool, error)

DeleteVirtualSwitch(string) error

CreateVirtualMachine(string, string, int64, int64, string, uint) error

DeleteVirtualMachine(string) error

SetVirtualMachineCpuCount(string, uint) error

SetVirtualMachineMacSpoofing(string, bool) error

SetVirtualMachineDynamicMemory(string, bool) error

SetVirtualMachineSecureBoot(string, bool) error

SetVirtualMachineVirtualizationExtensions(string, bool) error

EnableVirtualMachineIntegrationService(string, string) error

ExportVirtualMachine(string, string) error

CompactDisks(string, string) error

CopyExportedVirtualMachine(string, string, string, string) error

RestartVirtualMachine(string) error

CreateDvdDrive(string, string, uint) (uint, uint, error)

MountDvdDrive(string, string, uint, uint) error

SetBootDvdDrive(string, uint, uint, uint) error

UnmountDvdDrive(string, uint, uint) error

DeleteDvdDrive(string, uint, uint) error

MountFloppyDrive(string, string) error

UnmountFloppyDrive(string) error

SetVirtualMachineIPNetworkConfiguration(string, string, string, string, string) error
}
Loading