Merge pull request #1034 from frapposelli/fusion-shared-folders

Update VMware Fusion and vSphere driver to run boot2docker 1.6.0
This commit is contained in:
Evan Hazlett 2015-04-21 07:22:15 -07:00
commit f64eb09d1c
4 changed files with 72 additions and 33 deletions

View File

@ -31,7 +31,7 @@ import (
const ( const (
B2D_USER = "docker" B2D_USER = "docker"
B2D_PASS = "tcuser" B2D_PASS = "tcuser"
isoFilename = "boot2docker-1.5.0-GH747.iso" isoFilename = "boot2docker-1.6.0-vmw.iso"
) )
// Driver for VMware Fusion // Driver for VMware Fusion
@ -223,7 +223,7 @@ func (d *Driver) Create() error {
//} //}
// see https://github.com/boot2docker/boot2docker/pull/747 // see https://github.com/boot2docker/boot2docker/pull/747
isoURL := "https://github.com/cloudnativeapps/boot2docker/releases/download/1.5.0-GH747/boot2docker-1.5.0-GH747.iso" isoURL := "https://github.com/cloudnativeapps/boot2docker/releases/download/v1.6.0-vmw/boot2docker-1.6.0-vmw.iso"
if _, err := os.Stat(commonIsoPath); os.IsNotExist(err) { if _, err := os.Stat(commonIsoPath); os.IsNotExist(err) {
log.Infof("Downloading boot2docker.iso to %s...", commonIsoPath) log.Infof("Downloading boot2docker.iso to %s...", commonIsoPath)
@ -278,9 +278,8 @@ func (d *Driver) Create() error {
} }
} }
if err := d.Start(); err != nil { log.Infof("Starting %s...", d.MachineName)
return err vmrun("start", d.vmxPath(), "nogui")
}
var ip string var ip string
@ -320,12 +319,51 @@ func (d *Driver) Create() error {
// Expand tar file. // Expand tar file.
vmrun("-gu", B2D_USER, "-gp", B2D_PASS, "runScriptInGuest", d.vmxPath(), "/bin/sh", "sudo /bin/mv /home/docker/userdata.tar /var/lib/boot2docker/userdata.tar && sudo tar xf /var/lib/boot2docker/userdata.tar -C /home/docker/ > /var/log/userdata.log 2>&1 && sudo chown -R docker:staff /home/docker") vmrun("-gu", B2D_USER, "-gp", B2D_PASS, "runScriptInGuest", d.vmxPath(), "/bin/sh", "sudo /bin/mv /home/docker/userdata.tar /var/lib/boot2docker/userdata.tar && sudo tar xf /var/lib/boot2docker/userdata.tar -C /home/docker/ > /var/log/userdata.log 2>&1 && sudo chown -R docker:staff /home/docker")
// Enable Shared Folders
vmrun("-gu", B2D_USER, "-gp", B2D_PASS, "enableSharedFolders", d.vmxPath())
var shareName, shareDir string // TODO configurable at some point
switch runtime.GOOS {
case "darwin":
shareName = "Users"
shareDir = "/Users"
// TODO "linux" and "windows"
}
if shareDir != "" {
if _, err := os.Stat(shareDir); err != nil && !os.IsNotExist(err) {
return err
} else if !os.IsNotExist(err) {
// add shared folder, create mountpoint and mount it.
vmrun("-gu", B2D_USER, "-gp", B2D_PASS, "addSharedFolder", d.vmxPath(), shareName, shareDir)
vmrun("-gu", B2D_USER, "-gp", B2D_PASS, "runScriptInGuest", d.vmxPath(), "/bin/sh", "sudo mkdir "+shareDir+" && sudo mount -t vmhgfs .host:/"+shareName+" "+shareDir)
}
}
return nil return nil
} }
func (d *Driver) Start() error { func (d *Driver) Start() error {
log.Infof("Starting %s...", d.MachineName) log.Infof("Starting %s...", d.MachineName)
vmrun("start", d.vmxPath(), "nogui") vmrun("start", d.vmxPath(), "nogui")
log.Debugf("Mounting Shared Folders...")
var shareName, shareDir string // TODO configurable at some point
switch runtime.GOOS {
case "darwin":
shareName = "Users"
shareDir = "/Users"
// TODO "linux" and "windows"
}
if shareDir != "" {
if _, err := os.Stat(shareDir); err != nil && !os.IsNotExist(err) {
return err
} else if !os.IsNotExist(err) {
// create mountpoint and mount shared folder
vmrun("-gu", B2D_USER, "-gp", B2D_PASS, "runScriptInGuest", d.vmxPath(), "/bin/sh", "sudo mkdir "+shareDir+" && sudo mount -t vmhgfs .host:/"+shareName+" "+shareDir)
}
}
return nil return nil
} }

View File

@ -61,4 +61,6 @@ virtualHW.version = "10"
msg.autoanswer = "TRUE" msg.autoanswer = "TRUE"
uuid.action = "create" uuid.action = "create"
numvcpus = "{{.CPUs}}" numvcpus = "{{.CPUs}}"
hgfs.mapRootShare = "FALSE"
hgfs.linkRootShare = "FALSE"
` `

View File

@ -29,7 +29,7 @@ import (
const ( const (
DATASTORE_DIR = "boot2docker-iso" DATASTORE_DIR = "boot2docker-iso"
isoFilename = "boot2docker-1.5.0-GH747.iso" isoFilename = "boot2docker-1.6.0-vmw.iso"
B2D_ISO_NAME = isoFilename B2D_ISO_NAME = isoFilename
DEFAULT_CPU_NUMBER = 2 DEFAULT_CPU_NUMBER = 2
B2D_USER = "docker" B2D_USER = "docker"
@ -302,7 +302,7 @@ func (d *Driver) Create() error {
//} //}
// see https://github.com/boot2docker/boot2docker/pull/747 // see https://github.com/boot2docker/boot2docker/pull/747
isoURL := "https://github.com/cloudnativeapps/boot2docker/releases/download/1.5.0-GH747/boot2docker-1.5.0-GH747.iso" isoURL := "https://github.com/cloudnativeapps/boot2docker/releases/download/v1.6.0-vmw/boot2docker-1.6.0-vmw.iso"
if _, err := os.Stat(commonIsoPath); os.IsNotExist(err) { if _, err := os.Stat(commonIsoPath); os.IsNotExist(err) {
log.Infof("Downloading boot2docker.iso to %s...", commonIsoPath) log.Infof("Downloading boot2docker.iso to %s...", commonIsoPath)

View File

@ -4,106 +4,106 @@ load helpers
export DRIVER=vmwarefusion export DRIVER=vmwarefusion
export NAME="bats-$DRIVER-test" export NAME="bats-$DRIVER-test"
export MACHINE_STORAGE_PATH=/tmp/machine-bats-test-$DRIVER export MACHINE_STORAGE_PATH=/tmp/docker-machine-bats-test-$DRIVER
function setup() { function setup() {
# add sleep because vbox; ugh # add sleep because vbox; ugh
sleep 1 sleep 1
} }
@test "$DRIVER: machine should not exist" { @test "$DRIVER: docker-machine should not exist" {
run machine active $NAME run docker-machine active $NAME
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
} }
@test "$DRIVER: create" { @test "$DRIVER: create" {
run machine create -d $DRIVER $NAME run docker-machine create -d $DRIVER $NAME
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "$DRIVER: active" { @test "$DRIVER: active" {
run machine active $NAME run docker-machine active $NAME
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "$DRIVER: ls" { @test "$DRIVER: ls" {
run machine ls run docker-machine ls
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[[ ${lines[1]} == *"$NAME"* ]] [[ ${lines[1]} == *"$NAME"* ]]
} }
@test "$DRIVER: run busybox container" { @test "$DRIVER: run busybox container" {
run docker $(machine config $NAME) run busybox echo hello world run docker $(docker-machine config $NAME) run busybox echo hello world
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "$DRIVER: url" { @test "$DRIVER: url" {
run machine url $NAME run docker-machine url $NAME
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "$DRIVER: ip" { @test "$DRIVER: ip" {
run machine ip $NAME run docker-machine ip $NAME
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "$DRIVER: ssh" { @test "$DRIVER: ssh" {
run machine ssh $NAME -- ls -lah / run docker-machine ssh $NAME -- ls -lah /
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[[ ${lines[0]} =~ "total" ]] [[ ${lines[0]} =~ "total" ]]
} }
@test "$DRIVER: stop" { @test "$DRIVER: stop" {
run machine stop $NAME run docker-machine stop $NAME
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "$DRIVER: machine should show stopped after stop" { @test "$DRIVER: docker-machine should show stopped after stop" {
run machine ls run docker-machine ls
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[[ ${lines[1]} == *"Stopped"* ]] [[ ${lines[1]} == *"Stopped"* ]]
} }
@test "$DRIVER: start" { @test "$DRIVER: start" {
run machine start $NAME run docker-machine start $NAME
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "$DRIVER: machine should show running after start" { @test "$DRIVER: docker-machine should show running after start" {
run machine ls run docker-machine ls
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[[ ${lines[1]} == *"Running"* ]] [[ ${lines[1]} == *"Running"* ]]
} }
@test "$DRIVER: kill" { @test "$DRIVER: kill" {
run machine kill $NAME run docker-machine kill $NAME
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "$DRIVER: machine should show stopped after kill" { @test "$DRIVER: docker-machine should show stopped after kill" {
run machine ls run docker-machine ls
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[[ ${lines[1]} == *"Stopped"* ]] [[ ${lines[1]} == *"Stopped"* ]]
} }
@test "$DRIVER: restart" { @test "$DRIVER: restart" {
run machine restart $NAME run docker-machine restart $NAME
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "$DRIVER: machine should show running after restart" { @test "$DRIVER: docker-machine should show running after restart" {
run machine ls run docker-machine ls
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[[ ${lines[1]} == *"Running"* ]] [[ ${lines[1]} == *"Running"* ]]
} }
@test "$DRIVER: remove" { @test "$DRIVER: remove" {
run machine rm -f $NAME run docker-machine rm -f $NAME
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "$DRIVER: machine should not exist" { @test "$DRIVER: docker-machine should not exist" {
run machine active $NAME run docker-machine active $NAME
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
} }
@ -111,4 +111,3 @@ function setup() {
run rm -rf $MACHINE_STORAGE_PATH run rm -rf $MACHINE_STORAGE_PATH
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }