mirror of https://github.com/apache/jclouds.git
issue 384: adding vbox - virtualbox installation on macosx
This commit is contained in:
parent
a3d628e688
commit
6092d58046
|
@ -41,11 +41,15 @@ import org.eclipse.jetty.server.handler.HandlerList;
|
||||||
import org.eclipse.jetty.server.handler.ResourceHandler;
|
import org.eclipse.jetty.server.handler.ResourceHandler;
|
||||||
import org.jclouds.compute.ComputeServiceContext;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.compute.domain.ExecResponse;
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
import org.jclouds.compute.options.RunScriptOptions;
|
import org.jclouds.compute.options.RunScriptOptions;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.net.IPSocket;
|
import org.jclouds.net.IPSocket;
|
||||||
import org.jclouds.predicates.InetSocketAddressConnect;
|
import org.jclouds.predicates.InetSocketAddressConnect;
|
||||||
import org.jclouds.predicates.RetryablePredicate;
|
import org.jclouds.predicates.RetryablePredicate;
|
||||||
|
import org.jclouds.scriptbuilder.domain.OsFamily;
|
||||||
|
import org.jclouds.scriptbuilder.domain.Statement;
|
||||||
|
import org.jclouds.scriptbuilder.statements.login.AdminAccess;
|
||||||
import org.jclouds.ssh.SshException;
|
import org.jclouds.ssh.SshException;
|
||||||
import org.jclouds.virtualbox.experiment.settings.KeyboardScancodes;
|
import org.jclouds.virtualbox.experiment.settings.KeyboardScancodes;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
|
@ -115,6 +119,8 @@ public class VirtualboxAdministrationKickstartLiveTest {
|
||||||
private String guestId = "guest";
|
private String guestId = "guest";
|
||||||
private String majorVersion;
|
private String majorVersion;
|
||||||
private String minorVersion;
|
private String minorVersion;
|
||||||
|
private URI vboxDmg;
|
||||||
|
private String vboxVersionName;
|
||||||
|
|
||||||
protected void setupCredentials() {
|
protected void setupCredentials() {
|
||||||
identity = System.getProperty("test." + provider + ".identity",
|
identity = System.getProperty("test." + provider + ".identity",
|
||||||
|
@ -170,7 +176,8 @@ public class VirtualboxAdministrationKickstartLiveTest {
|
||||||
.create(System
|
.create(System
|
||||||
.getProperty("test." + provider + ".distroIsoUrl",
|
.getProperty("test." + provider + ".distroIsoUrl",
|
||||||
"http://releases.ubuntu.com/11.04/ubuntu-11.04-server-i386.iso"));
|
"http://releases.ubuntu.com/11.04/ubuntu-11.04-server-i386.iso"));
|
||||||
|
vboxDmg = URI.create(System.getProperty("test." + provider + ".vboxDmg","http://download.virtualbox.org/virtualbox/4.1.2/VirtualBox-4.1.2-73507-OSX.dmg"));
|
||||||
|
vboxVersionName = System.getProperty("test" + provider + ".vboxVersionName", "VirtualBox-4.1.2-73507-OSX.dmg");
|
||||||
originalDisk = workingDir
|
originalDisk = workingDir
|
||||||
+ File.separator
|
+ File.separator
|
||||||
+ "VDI"
|
+ "VDI"
|
||||||
|
@ -241,12 +248,14 @@ public class VirtualboxAdministrationKickstartLiveTest {
|
||||||
server.start();
|
server.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void installVbox() {
|
void installVbox() throws Exception {
|
||||||
if (runScriptOnNode(hostId, "VBoxManage --version").getExitCode() != 0) {
|
if (runScriptOnNode(hostId, "VBoxManage --version", runAsRoot(false).wrapInInitScript(false)).getExitCode() != 0) {
|
||||||
logger().debug("installing virtualbox");
|
logger().debug("installing virtualbox");
|
||||||
if (isOSX(hostId))
|
if (isOSX(hostId)) {
|
||||||
;// TODO
|
downloadFileUnlessPresent(vboxDmg, workingDir, vboxVersionName);
|
||||||
else {
|
runScriptOnNode(hostId, "hdiutil attach " + workingDir + "/" + vboxVersionName);
|
||||||
|
runScriptOnNode(hostId, "installer -pkg /Volumes/VirtualBox/VirtualBox.mpkg -target /Volumes/Macintosh\\ HD");
|
||||||
|
} else {
|
||||||
// TODO other platforms
|
// TODO other platforms
|
||||||
runScriptOnNode(hostId, "cat > /etc/apt/sources.list.d/TODO");
|
runScriptOnNode(hostId, "cat > /etc/apt/sources.list.d/TODO");
|
||||||
runScriptOnNode(
|
runScriptOnNode(
|
||||||
|
@ -255,7 +264,6 @@ public class VirtualboxAdministrationKickstartLiveTest {
|
||||||
runScriptOnNode(hostId, "apt-get update");
|
runScriptOnNode(hostId, "apt-get update");
|
||||||
runScriptOnNode(hostId, "apt-get --yes install virtualbox-4.1");
|
runScriptOnNode(hostId, "apt-get --yes install virtualbox-4.1");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,10 +289,7 @@ public class VirtualboxAdministrationKickstartLiveTest {
|
||||||
if (isOSX(hostId))
|
if (isOSX(hostId))
|
||||||
vboxwebsrv = "cd /Applications/VirtualBox.app/Contents/MacOS/ && "
|
vboxwebsrv = "cd /Applications/VirtualBox.app/Contents/MacOS/ && "
|
||||||
+ vboxwebsrv;
|
+ vboxwebsrv;
|
||||||
// allow jclouds to background the process, this is why we don't specify
|
|
||||||
// -b;
|
|
||||||
// logs will go corresponding to task name in this case under
|
|
||||||
// /tmp/vboxwebsrv
|
|
||||||
runScriptOnNode(
|
runScriptOnNode(
|
||||||
hostId,
|
hostId,
|
||||||
vboxwebsrv,
|
vboxwebsrv,
|
||||||
|
@ -311,16 +316,6 @@ public class VirtualboxAdministrationKickstartLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateVirtualMachine() {
|
public void testCreateVirtualMachine() {
|
||||||
/*
|
|
||||||
* IMachine machine = manager.getVBox().findMachine(vmName); if(machine
|
|
||||||
* != null) { ISession session = manager.getSessionObject();
|
|
||||||
* machine.lockMachine(session, LockType.Write); IMachine mutable =
|
|
||||||
* session.getMachine(); List<IMedium> media =
|
|
||||||
* machine.unregister(CleanupMode.Full); machine.delete(media);
|
|
||||||
* mutable.saveSettings(); session.unlockMachine();
|
|
||||||
*
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
IMachine newVM = manager.getVBox().createMachine(settingsFile, vmName,
|
IMachine newVM = manager.getVBox().createMachine(settingsFile, vmName,
|
||||||
osTypeId, vmId, forceOverwrite);
|
osTypeId, vmId, forceOverwrite);
|
||||||
manager.getVBox().registerMachine(newVM);
|
manager.getVBox().registerMachine(newVM);
|
||||||
|
@ -439,7 +434,7 @@ public class VirtualboxAdministrationKickstartLiveTest {
|
||||||
boolean sshDeamonIsRunning = false;
|
boolean sshDeamonIsRunning = false;
|
||||||
while(!sshDeamonIsRunning) {
|
while(!sshDeamonIsRunning) {
|
||||||
try {
|
try {
|
||||||
if(runScriptOnNode(guestId, "echo ciao").getExitCode() == 0)
|
if(runScriptOnNode(guestId, "echo ciao", runAsRoot(false).wrapInInitScript(false)).getExitCode() == 0)
|
||||||
sshDeamonIsRunning = true;
|
sshDeamonIsRunning = true;
|
||||||
} catch(SshException e) {
|
} catch(SshException e) {
|
||||||
System.err.println("connection reset");
|
System.err.println("connection reset");
|
||||||
|
@ -564,7 +559,7 @@ public class VirtualboxAdministrationKickstartLiveTest {
|
||||||
.get("<Return>"))) {
|
.get("<Return>"))) {
|
||||||
runScriptOnNode(hostId, sb.toString(), runAsRoot(false)
|
runScriptOnNode(hostId, sb.toString(), runAsRoot(false)
|
||||||
.wrapInInitScript(false));
|
.wrapInInitScript(false));
|
||||||
sb = new StringBuilder();
|
sb.delete(0, sb.length()-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ d-i user-setup/allow-password-weak boolean true
|
||||||
|
|
||||||
## minimum is puppet and ssh and ntp
|
## minimum is puppet and ssh and ntp
|
||||||
# Individual additional packages to install
|
# Individual additional packages to install
|
||||||
d-i pkgsel/include string openssh-server ntp dkms virtualbox-guest-additions build-essential module-assistant
|
d-i pkgsel/include string openssh-server ntp dkms build-essential module-assistant
|
||||||
|
|
||||||
# Whether to upgrade packages after debootstrap.
|
# Whether to upgrade packages after debootstrap.
|
||||||
# Allowed values: none, safe-upgrade, full-upgrade
|
# Allowed values: none, safe-upgrade, full-upgrade
|
||||||
|
|
Loading…
Reference in New Issue