From abc4350f75999d7dc6040045f7ff20bab3b5f4bc Mon Sep 17 00:00:00 2001 From: v-vlshch Date: Mon, 23 Jun 2014 11:19:06 -0700 Subject: [PATCH] Hyper-V support added --- post-processor/vagrant/hyperv.go | 30 ++++++++++++++++++++++++ post-processor/vagrant/post-processor.go | 3 +++ 2 files changed, 33 insertions(+) create mode 100644 post-processor/vagrant/hyperv.go diff --git a/post-processor/vagrant/hyperv.go b/post-processor/vagrant/hyperv.go new file mode 100644 index 000000000..d5fa0ce52 --- /dev/null +++ b/post-processor/vagrant/hyperv.go @@ -0,0 +1,30 @@ +package vagrant + +import ( + "fmt" + "github.com/mitchellh/packer/packer" + "path/filepath" +) + +type HypervProvider struct{} + +func (p *HypervProvider) KeepInputArtifact() bool { + return false +} + +func (p *HypervProvider) Process(ui packer.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) { + // Create the metadata + metadata = map[string]interface{}{"provider": "hyperv"} + + // Copy all of the original contents into the temporary directory + for _, path := range artifact.Files() { + ui.Message(fmt.Sprintf("Copying: %s", path)) + + dstPath := filepath.Join(dir, filepath.Base(path)) + if err = CopyContents(dstPath, path); err != nil { + return + } + } + + return +} diff --git a/post-processor/vagrant/post-processor.go b/post-processor/vagrant/post-processor.go index 39feebb2c..8fb486edb 100644 --- a/post-processor/vagrant/post-processor.go +++ b/post-processor/vagrant/post-processor.go @@ -22,6 +22,7 @@ var builtins = map[string]string{ "mitchellh.vmware": "vmware", "pearkes.digitalocean": "digitalocean", "packer.parallels": "parallels", + "MSOpenTech.hyperv": "hyperv", } type Config struct { @@ -220,6 +221,8 @@ func providerForName(name string) Provider { return new(VMwareProvider) case "parallels": return new(ParallelsProvider) + case "hyperv": + return new(HypervProvider) default: return nil }