adding virtualboxissue 384 - NAT configuration for jetty web server

This commit is contained in:
toor 2011-07-26 01:22:44 +01:00
parent 5a2053a3d0
commit dc070417a9
2 changed files with 22 additions and 53 deletions

View File

@ -9,7 +9,7 @@ import org.eclipse.jetty.util.log.Log;
public class FileServer { public class FileServer {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Server server = new Server(args.length == 0?80:Integer.parseInt(args[0])); Server server = new Server(args.length == 0?8080:Integer.parseInt(args[0]));
ResourceHandler resource_handler = new ResourceHandler(); ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true); resource_handler.setDirectoriesListed(true);

View File

@ -92,8 +92,6 @@ public class VirtualboxAdministrationKickstartTest {
private String vboxwebsrvStartCommand; private String vboxwebsrvStartCommand;
private String gaIsoName; private String gaIsoName;
private String hostUsername;
private String hostPassword;
private String installVboxOse; private String installVboxOse;
private String distroIsoUrl; private String distroIsoUrl;
private String distroIsoName; private String distroIsoName;
@ -129,7 +127,7 @@ public class VirtualboxAdministrationKickstartTest {
sshHost = System.getProperty("test.ssh.host", "localhost"); sshHost = System.getProperty("test.ssh.host", "localhost");
sshPort = System.getProperty("test.ssh.port", "22"); sshPort = System.getProperty("test.ssh.port", "22");
sshUser = System.getProperty("test.ssh.username", "root"); sshUser = System.getProperty("test.ssh.username", "toor");
sshPass = System.getProperty("test.ssh.password", "password"); sshPass = System.getProperty("test.ssh.password", "password");
sshKeyFile = System.getProperty("test.ssh.keyfile"); sshKeyFile = System.getProperty("test.ssh.keyfile");
@ -207,8 +205,8 @@ public class VirtualboxAdministrationKickstartTest {
.getProperty( .getProperty(
"test." + provider + ".keyboardSequence", "test." + provider + ".keyboardSequence",
"<Esc> <Esc> <Enter> " "<Esc> <Esc> <Enter> "
//+ "/install/vmlinuz noapic preseed/url=http://192.168.1.12/src/test/resources/preseed.cfg " + "/install/vmlinuz noapic preseed/url=http://10.0.2.2:8080/src/test/resources/preseed.cfg "
+ "/install/vmlinuz noapic preseed/url=" + preseedUrl + " " //+ "/install/vmlinuz noapic preseed/url=" + preseedUrl + " "
+ "debian-installer=en_US auto locale=en_US kbd-chooser/method=us " + "debian-installer=en_US auto locale=en_US kbd-chooser/method=us "
+ "hostname=" + vmName + " " + "hostname=" + vmName + " "
+ "fb=false debconf/frontend=noninteractive " + "fb=false debconf/frontend=noninteractive "
@ -216,7 +214,7 @@ public class VirtualboxAdministrationKickstartTest {
+ "initrd=/install/initrd.gz -- <Enter>"); + "initrd=/install/initrd.gz -- <Enter>");
vboxwebsrvStartCommand = System.getProperty("test." + provider vboxwebsrvStartCommand = System.getProperty("test." + provider
+ ".vboxwebsrvStartCommand", "/usr/bin/vboxwebsrv.exe"); + ".vboxwebsrvStartCommand", "/usr/bin/vboxwebsrv");
vboxManageCommand = System vboxManageCommand = System
.getProperty( .getProperty(
"test." + provider + ".vboxmanage", "VBoxManage"); "test." + provider + ".vboxmanage", "VBoxManage");
@ -238,9 +236,6 @@ public class VirtualboxAdministrationKickstartTest {
@BeforeGroups(groups = "live") @BeforeGroups(groups = "live")
protected void setupClient() throws IOException, InterruptedException { protected void setupClient() throws IOException, InterruptedException {
hostUsername = System.getProperty("test." + provider + ".hostusername", "toor");
hostPassword = System.getProperty("test." + provider + ".hostpassword",
"password");
injector = Guice.createInjector(new SshjSshClientModule(), injector = Guice.createInjector(new SshjSshClientModule(),
new Log4JLoggingModule()); new Log4JLoggingModule());
@ -277,16 +272,15 @@ public class VirtualboxAdministrationKickstartTest {
HandlerList handlers = new HandlerList(); HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { resource_handler, new DefaultHandler() }); handlers.setHandlers(new Handler[] { resource_handler, new DefaultHandler() });
server.setHandler(handlers); server.setHandler(handlers);
//server.start();
//server.join();
} }
private void installVbox() throws IOException, InterruptedException { private void installVbox() throws IOException, InterruptedException {
IPSocket socket = new IPSocket("127.0.0.1", 22); SshClient client = setupSshClient();
socketTester.apply(socket);
SshClient client = sshFactory.create(socket, new Credentials(
hostUsername, hostPassword));
try { try {
client.connect(); client.exec("echo " + sshPass + " | " + installVboxOse);
client.exec("echo " + hostPassword + " | " + installVboxOse);
} catch (Exception e) { } catch (Exception e) {
System.out.println("It is impossible to install virtualbox with this command " + installVboxOse); System.out.println("It is impossible to install virtualbox with this command " + installVboxOse);
} finally { } finally {
@ -310,8 +304,7 @@ public class VirtualboxAdministrationKickstartTest {
// rt.exec("VBoxManage setproperty websrvauthlibrary null"); // rt.exec("VBoxManage setproperty websrvauthlibrary null");
SshClient client = setupSshClient(); SshClient client = setupSshClient();
try { try {
ExecResponse response = client.exec(command); ExecResponse response = client.exec(command + " -t 0 -b");
System.out.println(response.getOutput());
} catch (Exception e) { } catch (Exception e) {
propagate(e); propagate(e);
} finally { } finally {
@ -599,12 +592,8 @@ public class VirtualboxAdministrationKickstartTest {
@AfterClass @AfterClass
void stopVboxWebServer() throws IOException { void stopVboxWebServer() throws IOException {
// stop vbox web server // stop vbox web server
IPSocket socket = new IPSocket("127.0.0.1", 22); SshClient client = setupSshClient();
socketTester.apply(socket);
SshClient client = sshFactory.create(socket, new Credentials(
hostUsername, hostPassword));
try { try {
client.connect();
ExecResponse exec = client.exec("pidof vboxwebsrv | xargs kill"); ExecResponse exec = client.exec("pidof vboxwebsrv | xargs kill");
System.out.println(exec.getOutput()); System.out.println(exec.getOutput());
@ -654,42 +643,22 @@ public class VirtualboxAdministrationKickstartTest {
private void sendKeyboardSequence(String keyboardSequence) { private void sendKeyboardSequence(String keyboardSequence) {
String[] sequenceSplited = keyboardSequence.split(" "); String[] sequenceSplited = keyboardSequence.split(" ");
/* SshClient client = null;
for (String word : sequenceSplited) { try {
client = setupSshClient();
String converted = stringToKeycode(word); for (String word : sequenceSplited) {
for (String string : converted.split(" ")) {
try {
Thread.sleep(100);
Runtime.getRuntime().exec(vboxManageCommand + " controlvm " + vmName + " keyboardputscancode " + string);
Thread.sleep(50);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
*/
for (String word : sequenceSplited) {
IPSocket socket = new IPSocket("127.0.0.1", 22);
socketTester.apply(socket);
SshClient client = sshFactory.create(socket, new Credentials(hostUsername, hostPassword));
try {
client.connect();
String converted = stringToKeycode(word); String converted = stringToKeycode(word);
for (String string : converted.split(" ")) { for (String string : converted.split(" ")) {
ExecResponse response = client.exec(vboxManageCommand + " controlvm " + vmName + " keyboardputscancode " + string); ExecResponse response = client.exec(vboxManageCommand + " controlvm " + vmName + " keyboardputscancode " + string);
System.out.println(response.getOutput()); System.out.println(response.getOutput());
} }
} catch (Exception e) { }
e.printStackTrace(); } catch (Exception e) {
} finally { e.printStackTrace();
if (client != null) } finally {
client.disconnect(); if (client != null)
} client.disconnect();
} }
} }
private String stringToKeycode(String s) { private String stringToKeycode(String s) {