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

This commit is contained in:
Mitchell Hashimoto 2014-09-02 09:35:59 -07:00
parent df8e2f4f84
commit 4ef3874467
3 changed files with 14 additions and 2 deletions

View File

@ -18,6 +18,7 @@ BUG FIXES:
* builder/parallels/all: Add support for Parallels Desktop 10 [GH-1438]
* builder/parallels/all: Added some navigation keys [GH-1442]
* 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/vmx: Do not re-add floppy disk files to VMX [GH-1361]

View File

@ -3,12 +3,15 @@ package iso
import (
"errors"
"fmt"
"log"
"math/rand"
"strings"
"time"
"github.com/mitchellh/multistep"
vboxcommon "github.com/mitchellh/packer/builder/virtualbox/common"
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/packer"
"log"
"strings"
)
const BuilderId = "mitchellh.virtualbox"
@ -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) {
// Seed the random number generator
rand.Seed(time.Now().UTC().UnixNano())
// Create the driver that we'll use to communicate with VirtualBox
driver, err := vboxcommon.NewDriver()
if err != nil {

View File

@ -4,6 +4,8 @@ import (
"errors"
"fmt"
"log"
"math/rand"
"time"
"github.com/mitchellh/multistep"
vboxcommon "github.com/mitchellh/packer/builder/virtualbox/common"
@ -32,6 +34,9 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
// Run executes a Packer build and returns a packer.Artifact representing
// a VirtualBox appliance.
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
driver, err := vboxcommon.NewDriver()
if err != nil {