Commit 4ef38744 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/virtualbox-*: seed RNG [GH-1386]

parent df8e2f4f
...@@ -18,6 +18,7 @@ BUG FIXES: ...@@ -18,6 +18,7 @@ BUG FIXES:
* builder/parallels/all: Add support for Parallels Desktop 10 [GH-1438] * builder/parallels/all: Add support for Parallels Desktop 10 [GH-1438]
* builder/parallels/all: Added some navigation keys [GH-1442] * builder/parallels/all: Added some navigation keys [GH-1442]
* builder/qemu: If headless, sdl display won't be used. [GH-1395] * builder/qemu: If headless, sdl display won't be used. [GH-1395]
* builder/virtualbox/all: Seed RNG to avoid same ports. [GH-1386]
* builder/vmware/all: `ssh_host` accepts templates. [GH-1396] * builder/vmware/all: `ssh_host` accepts templates. [GH-1396]
* builder/vmware/vmx: Do not re-add floppy disk files to VMX [GH-1361] * builder/vmware/vmx: Do not re-add floppy disk files to VMX [GH-1361]
......
...@@ -3,12 +3,15 @@ package iso ...@@ -3,12 +3,15 @@ package iso
import ( import (
"errors" "errors"
"fmt" "fmt"
"log"
"math/rand"
"strings"
"time"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
vboxcommon "github.com/mitchellh/packer/builder/virtualbox/common" vboxcommon "github.com/mitchellh/packer/builder/virtualbox/common"
"github.com/mitchellh/packer/common" "github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
"log"
"strings"
) )
const BuilderId = "mitchellh.virtualbox" const BuilderId = "mitchellh.virtualbox"
...@@ -254,6 +257,9 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { ...@@ -254,6 +257,9 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
} }
func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packer.Artifact, error) { func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packer.Artifact, error) {
// Seed the random number generator
rand.Seed(time.Now().UTC().UnixNano())
// Create the driver that we'll use to communicate with VirtualBox // Create the driver that we'll use to communicate with VirtualBox
driver, err := vboxcommon.NewDriver() driver, err := vboxcommon.NewDriver()
if err != nil { if err != nil {
......
...@@ -4,6 +4,8 @@ import ( ...@@ -4,6 +4,8 @@ import (
"errors" "errors"
"fmt" "fmt"
"log" "log"
"math/rand"
"time"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
vboxcommon "github.com/mitchellh/packer/builder/virtualbox/common" vboxcommon "github.com/mitchellh/packer/builder/virtualbox/common"
...@@ -32,6 +34,9 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { ...@@ -32,6 +34,9 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
// Run executes a Packer build and returns a packer.Artifact representing // Run executes a Packer build and returns a packer.Artifact representing
// a VirtualBox appliance. // a VirtualBox appliance.
func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packer.Artifact, error) { func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packer.Artifact, error) {
// Seed the random number generator
rand.Seed(time.Now().UTC().UnixNano())
// Create the driver that we'll use to communicate with VirtualBox // Create the driver that we'll use to communicate with VirtualBox
driver, err := vboxcommon.NewDriver() driver, err := vboxcommon.NewDriver()
if err != nil { if err != nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment