diff --git a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/statements/InstallGuestAdditions.java b/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/statements/InstallGuestAdditions.java index b0eb11a425..0a4e8f5023 100644 --- a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/statements/InstallGuestAdditions.java +++ b/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/statements/InstallGuestAdditions.java @@ -23,12 +23,16 @@ import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.scriptbuilder.domain.Statements.call; import static org.jclouds.scriptbuilder.domain.Statements.exec; +import java.net.URI; import java.util.Collections; import org.jclouds.scriptbuilder.ScriptBuilder; import org.jclouds.scriptbuilder.domain.OsFamily; +import org.jclouds.scriptbuilder.domain.SaveHttpResponseTo; import org.jclouds.scriptbuilder.domain.Statement; +import com.google.common.collect.ImmutableMultimap; + public class InstallGuestAdditions implements Statement { private final String vboxVersion; @@ -56,9 +60,11 @@ public class InstallGuestAdditions implements Statement { String vboxGuestAdditionsIso = "VBoxGuestAdditions_" + vboxVersion + ".iso"; ScriptBuilder scriptBuilder = new ScriptBuilder() - .addStatement(exec("{cd} {fs}tmp")) - .addStatement(exec("wget http://download.virtualbox.org/virtualbox/" + vboxVersion + "/" + vboxGuestAdditionsIso)) - .addStatement(exec(String.format("mount -o loop %s %s", vboxGuestAdditionsIso, mountPoint))) + .addStatement( + new SaveHttpResponseTo("{tmp}", vboxGuestAdditionsIso, "GET", URI + .create("http://download.virtualbox.org/virtualbox/" + vboxVersion + "/" + + vboxGuestAdditionsIso), ImmutableMultimap. of())) + .addStatement(exec(String.format("mount -o loop {tmp}{fs}%s %s", vboxGuestAdditionsIso, mountPoint))) .addStatement(call("installGuestAdditions")) .addStatement(exec(String.format("sh %s%s", mountPoint, "/VBoxLinuxAdditions.run"))) .addStatement(exec(String.format("umount %s", mountPoint))); diff --git a/sandbox-apis/virtualbox/src/test/resources/test_install_guest_additions.sh b/sandbox-apis/virtualbox/src/test/resources/test_install_guest_additions.sh index e4f4172807..fe2736bff5 100644 --- a/sandbox-apis/virtualbox/src/test/resources/test_install_guest_additions.sh +++ b/sandbox-apis/virtualbox/src/test/resources/test_install_guest_additions.sh @@ -22,9 +22,8 @@ function installGuestAdditions { return 0 } export PATH=/usr/ucb/bin:/bin:/sbin:/usr/bin:/usr/sbin -cd /tmp -wget http://download.virtualbox.org/virtualbox/4.1.6/VBoxGuestAdditions_4.1.6.iso -mount -o loop VBoxGuestAdditions_4.1.6.iso /mnt +(mkdir -p /tmp && cd /tmp && [ ! -f VBoxGuestAdditions_4.1.6.iso ] && curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -C - -X GET http://download.virtualbox.org/virtualbox/4.1.6/VBoxGuestAdditions_4.1.6.iso >VBoxGuestAdditions_4.1.6.iso) +mount -o loop /tmp/VBoxGuestAdditions_4.1.6.iso /mnt installGuestAdditions || exit 1 sh /mnt/VBoxLinuxAdditions.run umount /mnt