mirror of https://github.com/apache/jclouds.git
Issue 384: switched to vbox 4.1, cleaned up shell commands with byon, fixed so starts to work on osx
This commit is contained in:
parent
d991f3a83c
commit
5243790801
|
@ -1,27 +1,25 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
Copyright (C) 2011 Cloud Conscious, LLC <info@cloudconscious.com>
|
|
||||||
|
Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
|
||||||
====================================================================
|
====================================================================
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
or more contributor license agreements. See the NOTICE file
|
you may not use this file except in compliance with the License.
|
||||||
distributed with this work for additional information
|
You may obtain a copy of the License at
|
||||||
regarding copyright ownership. The ASF licenses this file
|
|
||||||
to you under the Apache License, Version 2.0 (the
|
|
||||||
"License"); you may not use this file except in compliance
|
|
||||||
with the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0.html
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing, software
|
||||||
software distributed under the License is distributed on an
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
KIND, either express or implied. See the License for the
|
See the License for the specific language governing permissions and
|
||||||
specific language governing permissions and limitations
|
limitations under the License.
|
||||||
under the License.
|
|
||||||
====================================================================
|
====================================================================
|
||||||
-->
|
|
||||||
|
-->
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
|
@ -32,26 +30,66 @@
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>org.jclouds.api</groupId>
|
<groupId>org.jclouds.api</groupId>
|
||||||
<artifactId>virtualbox</artifactId>
|
<artifactId>virtualbox</artifactId>
|
||||||
<name>jclouds components for a virtualbox provider</name>
|
<name>jcloud virtualbox api</name>
|
||||||
|
<description>jclouds components to access an implementation of virtualbox</description>
|
||||||
|
<packaging>bundle</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<test.virtualbox.endpoint>test:///default</test.virtualbox.endpoint>
|
<test.virtualbox.endpoint>http://localhost:18083/</test.virtualbox.endpoint>
|
||||||
<test.virtualbox.apiversion>1.0</test.virtualbox.apiversion>
|
<test.virtualbox.apiversion>4.1.0r73009</test.virtualbox.apiversion>
|
||||||
<test.virtualbox.identity>FIXME</test.virtualbox.identity>
|
<test.virtualbox.identity>administrator</test.virtualbox.identity>
|
||||||
<test.virtualbox.credential>FIXME</test.virtualbox.credential>
|
<test.virtualbox.credential>12345</test.virtualbox.credential>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<!-- bootstrapping: need to fetch the project POM -->
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>clojars.org</id>
|
<id>temporary</id>
|
||||||
<url>http://clojars.org/repo</url>
|
<url>https://jclouds.googlecode.com/svn/repo</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>sonatype-nexus-snapshots</id>
|
||||||
|
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</snapshots>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.clojars.tbatchelli</groupId>
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-compute</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.virtualbox</groupId>
|
||||||
<artifactId>vboxjws</artifactId>
|
<artifactId>vboxjws</artifactId>
|
||||||
<version>4.0.2</version>
|
<version>${test.virtualbox.apiversion}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds.api</groupId>
|
||||||
|
<artifactId>byon</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.jponge</groupId>
|
||||||
|
<artifactId>lzma-java</artifactId>
|
||||||
|
<version>1.2</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-security</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds</groupId>
|
<groupId>org.jclouds</groupId>
|
||||||
|
@ -60,11 +98,6 @@
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.jclouds</groupId>
|
|
||||||
<artifactId>jclouds-compute</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds</groupId>
|
<groupId>org.jclouds</groupId>
|
||||||
<artifactId>jclouds-compute</artifactId>
|
<artifactId>jclouds-compute</artifactId>
|
||||||
|
@ -72,12 +105,6 @@
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.jclouds.driver</groupId>
|
|
||||||
<artifactId>jclouds-log4j</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds.driver</groupId>
|
<groupId>org.jclouds.driver</groupId>
|
||||||
<artifactId>jclouds-sshj</artifactId>
|
<artifactId>jclouds-sshj</artifactId>
|
||||||
|
@ -85,16 +112,19 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.jponge</groupId>
|
<groupId>org.jclouds.driver</groupId>
|
||||||
<artifactId>lzma-java</artifactId>
|
<artifactId>jclouds-slf4j</artifactId>
|
||||||
<version>1.2</version>
|
<version>${project.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>ch.qos.logback</groupId>
|
||||||
<artifactId>jetty-security</artifactId>
|
<artifactId>logback-classic</artifactId>
|
||||||
|
<version>0.9.29</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
<id>live</id>
|
<id>live</id>
|
||||||
|
@ -103,6 +133,14 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.8.1</version>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.surefire</groupId>
|
||||||
|
<artifactId>surefire-testng</artifactId>
|
||||||
|
<version>2.8.1</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>integration</id>
|
<id>integration</id>
|
||||||
|
@ -111,12 +149,24 @@
|
||||||
<goal>test</goal>
|
<goal>test</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<systemPropertyVariables>
|
<systemProperties>
|
||||||
<test.virtualbox.endpoint>${test.virtualbox.endpoint}</test.virtualbox.endpoint>
|
<property>
|
||||||
<test.virtualbox.apiversion>${test.virtualbox.apiversion}</test.virtualbox.apiversion>
|
<name>test.virtualbox.endpoint</name>
|
||||||
<test.virtualbox.identity>${test.virtualbox.identity}</test.virtualbox.identity>
|
<value>${test.virtualbox.endpoint}</value>
|
||||||
<test.virtualbox.credential>${test.virtualbox.credential}</test.virtualbox.credential>
|
</property>
|
||||||
</systemPropertyVariables>
|
<property>
|
||||||
|
<name>test.virtualbox.apiversion</name>
|
||||||
|
<value>${test.virtualbox.apiversion}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>test.virtualbox.identity</name>
|
||||||
|
<value>${test.virtualbox.identity}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>test.virtualbox.credential</name>
|
||||||
|
<value>${test.virtualbox.credential}</value>
|
||||||
|
</property>
|
||||||
|
</systemProperties>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
@ -125,4 +175,21 @@
|
||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.felix</groupId>
|
||||||
|
<artifactId>maven-bundle-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<instructions>
|
||||||
|
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
|
||||||
|
<Export-Package>org.jclouds.virtualbox.*;version="${project.version}"</Export-Package>
|
||||||
|
<Import-Package>org.jclouds.*;version="${project.version}",*</Import-Package>
|
||||||
|
</instructions>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
package org.jclouds.virtualbox.experiment;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
|
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||||
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
|
import org.jclouds.encryption.bouncycastle.config.BouncyCastleCryptoModule;
|
||||||
|
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
|
||||||
|
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.inject.Module;
|
||||||
|
|
||||||
|
public class TestUtils {
|
||||||
|
public static ComputeServiceContext computeServiceForLocalhost() throws FileNotFoundException, IOException {
|
||||||
|
Properties contextProperties = new Properties();
|
||||||
|
|
||||||
|
StringBuilder nodes = new StringBuilder();
|
||||||
|
nodes.append("nodes:\n");
|
||||||
|
nodes.append(" - id: host\n");
|
||||||
|
nodes.append(" name: host installing virtualbox\n");
|
||||||
|
nodes.append(" hostname: localhost\n");
|
||||||
|
nodes.append(" os_family: ").append(OsFamily.LINUX).append("\n");
|
||||||
|
nodes.append(" os_description: ").append(System.getProperty("os.name")).append("\n");
|
||||||
|
nodes.append(" os_version: ").append(System.getProperty("os.version")).append("\n");
|
||||||
|
nodes.append(" group: ").append("ssh").append("\n");
|
||||||
|
nodes.append(" username: ").append(System.getProperty("user.name")).append("\n");
|
||||||
|
nodes.append(" credential_url: file://").append(System.getProperty("user.home")).append("/.ssh/id_rsa")
|
||||||
|
.append("\n");
|
||||||
|
nodes.append("\n");
|
||||||
|
nodes.append(" - id: guest\n");
|
||||||
|
nodes.append(" name: new guest\n");
|
||||||
|
nodes.append(" hostname: localhost\n");
|
||||||
|
nodes.append(" login_port: 2222\n");
|
||||||
|
nodes.append(" os_family: ubuntu").append("\n");
|
||||||
|
nodes.append(" os_description: ubuntu/11.04").append("\n");
|
||||||
|
nodes.append(" os_version: 11.04").append("\n");
|
||||||
|
nodes.append(" group: guest").append("\n");
|
||||||
|
nodes.append(" username: toor").append("\n");
|
||||||
|
nodes.append(" credential: password").append("\n");
|
||||||
|
|
||||||
|
contextProperties.setProperty("byon.nodes", nodes.toString());
|
||||||
|
|
||||||
|
return new ComputeServiceContextFactory().createContext("byon", "foo", "bar", ImmutableSet.<Module> of(
|
||||||
|
new SshjSshClientModule(), new SLF4JLoggingModule(), new BouncyCastleCryptoModule()), contextProperties);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,20 +1,18 @@
|
||||||
package org.jclouds.virtualbox.experiment;
|
package org.jclouds.virtualbox.experiment;
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.base.Throwables.propagate;
|
import static com.google.common.base.Throwables.propagate;
|
||||||
|
import static org.jclouds.compute.options.RunScriptOptions.Builder.blockOnPort;
|
||||||
|
import static org.jclouds.compute.options.RunScriptOptions.Builder.wrapInInitScript;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.Proxy;
|
import java.net.URI;
|
||||||
import java.net.URL;
|
|
||||||
import java.rmi.RemoteException;
|
import java.rmi.RemoteException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@ -23,43 +21,39 @@ import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.server.handler.DefaultHandler;
|
import org.eclipse.jetty.server.handler.DefaultHandler;
|
||||||
import org.eclipse.jetty.server.handler.HandlerList;
|
import org.eclipse.jetty.server.handler.HandlerList;
|
||||||
import org.eclipse.jetty.server.handler.ResourceHandler;
|
import org.eclipse.jetty.server.handler.ResourceHandler;
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.compute.domain.ExecResponse;
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.compute.options.RunScriptOptions;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
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.predicates.SocketOpen;
|
|
||||||
import org.jclouds.ssh.SshClient;
|
|
||||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
|
||||||
import org.jclouds.util.Strings2;
|
|
||||||
import org.jclouds.virtualbox.experiment.settings.KeyboardScancodes;
|
import org.jclouds.virtualbox.experiment.settings.KeyboardScancodes;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.AfterMethod;
|
import org.testng.annotations.AfterMethod;
|
||||||
import org.testng.annotations.BeforeGroups;
|
import org.testng.annotations.BeforeGroups;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
import org.virtualbox_4_0.AccessMode;
|
import org.virtualbox_4_1.AccessMode;
|
||||||
import org.virtualbox_4_0.DeviceType;
|
import org.virtualbox_4_1.DeviceType;
|
||||||
import org.virtualbox_4_0.IMachine;
|
import org.virtualbox_4_1.IMachine;
|
||||||
import org.virtualbox_4_0.IMedium;
|
import org.virtualbox_4_1.IMedium;
|
||||||
import org.virtualbox_4_0.IProgress;
|
import org.virtualbox_4_1.IProgress;
|
||||||
import org.virtualbox_4_0.ISession;
|
import org.virtualbox_4_1.ISession;
|
||||||
import org.virtualbox_4_0.IStorageController;
|
import org.virtualbox_4_1.IStorageController;
|
||||||
import org.virtualbox_4_0.LockType;
|
import org.virtualbox_4_1.LockType;
|
||||||
import org.virtualbox_4_0.MachineState;
|
import org.virtualbox_4_1.MachineState;
|
||||||
import org.virtualbox_4_0.NATProtocol;
|
import org.virtualbox_4_1.NATProtocol;
|
||||||
import org.virtualbox_4_0.SessionState;
|
import org.virtualbox_4_1.SessionState;
|
||||||
import org.virtualbox_4_0.StorageBus;
|
import org.virtualbox_4_1.StorageBus;
|
||||||
import org.virtualbox_4_0.VirtualBoxManager;
|
import org.virtualbox_4_1.VirtualBoxManager;
|
||||||
import org.virtualbox_4_0.jaxws.MediumVariant;
|
import org.virtualbox_4_1.jaxws.MediumVariant;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.io.Files;
|
import com.google.common.base.Splitter;
|
||||||
import com.google.common.io.InputSupplier;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.inject.Guice;
|
import com.google.common.io.ByteStreams;
|
||||||
import com.google.inject.Injector;
|
import com.google.common.io.Closeables;
|
||||||
|
|
||||||
@Test(groups = "live", testName = "virtualbox.VirtualboxAdministrationKickstartTest")
|
@Test(groups = "live", testName = "virtualbox.VirtualboxAdministrationKickstartTest")
|
||||||
public class VirtualboxAdministrationKickstartTest {
|
public class VirtualboxAdministrationKickstartTest {
|
||||||
|
@ -67,15 +61,13 @@ public class VirtualboxAdministrationKickstartTest {
|
||||||
protected String provider = "virtualbox";
|
protected String provider = "virtualbox";
|
||||||
protected String identity;
|
protected String identity;
|
||||||
protected String credential;
|
protected String credential;
|
||||||
protected String endpoint;
|
protected URI endpoint;
|
||||||
protected String apiversion;
|
protected String apiVersion;
|
||||||
protected String vmName;
|
protected String vmName;
|
||||||
|
|
||||||
VirtualBoxManager manager = VirtualBoxManager.createInstance("");
|
VirtualBoxManager manager = VirtualBoxManager.createInstance("");
|
||||||
|
|
||||||
protected Injector injector;
|
|
||||||
protected Predicate<IPSocket> socketTester;
|
protected Predicate<IPSocket> socketTester;
|
||||||
protected SshClient.Factory sshFactory;
|
|
||||||
|
|
||||||
protected String settingsFile; // Fully qualified path where the settings
|
protected String settingsFile; // Fully qualified path where the settings
|
||||||
protected String osTypeId; // Guest OS Type ID.
|
protected String osTypeId; // Guest OS Type ID.
|
||||||
|
@ -88,46 +80,39 @@ public class VirtualboxAdministrationKickstartTest {
|
||||||
protected String clonedDisk;
|
protected String clonedDisk;
|
||||||
|
|
||||||
protected String guestAdditionsDvd;
|
protected String guestAdditionsDvd;
|
||||||
private String gaIsoUrl;
|
private URI gaIsoUrl;
|
||||||
private String vboxwebsrvStartCommand;
|
|
||||||
|
|
||||||
private String gaIsoName;
|
private String gaIsoName;
|
||||||
private String installVboxOse;
|
private URI distroIsoUrl;
|
||||||
private String distroIsoUrl;
|
|
||||||
private String distroIsoName;
|
private String distroIsoName;
|
||||||
private String distroDvd;
|
|
||||||
private String controllerIDE;
|
private String controllerIDE;
|
||||||
private String controllerSATA;
|
private String controllerSATA;
|
||||||
private String keyboardSequence;
|
private String keyboardSequence;
|
||||||
private String admin_pwd;
|
|
||||||
private String vdiName;
|
private String vdiName;
|
||||||
private String preseedUrl;
|
private String preseedUrl;
|
||||||
|
|
||||||
protected Server server = null;
|
protected Server server = null;
|
||||||
private String vboxManageCommand;
|
private ComputeServiceContext context;
|
||||||
private String sshHost;
|
private String hostId = "host";
|
||||||
private String sshPort;
|
private String guestId = "guest";
|
||||||
private String sshUser;
|
private String majorVersion;
|
||||||
private String sshPass;
|
private String minorVersion;
|
||||||
private String sshKeyFile;
|
|
||||||
|
|
||||||
protected void setupCredentials() {
|
protected void setupCredentials() {
|
||||||
identity = System.getProperty("test." + provider + ".identity", "administrator");
|
identity = System.getProperty("test." + provider + ".identity", "administrator");
|
||||||
credential = System.getProperty("test." + provider + ".credential", "12345");
|
credential = System.getProperty("test." + provider + ".credential", "12345");
|
||||||
endpoint = System.getProperty("test." + provider + ".endpoint", "http://localhost:18083/");
|
endpoint = URI.create(System.getProperty("test." + provider + ".endpoint", "http://localhost:18083/"));
|
||||||
apiversion = System.getProperty("test." + provider + ".apiversion");
|
apiVersion = System.getProperty("test." + provider + ".apiversion", "4.1.0r73009");
|
||||||
|
majorVersion = Iterables.get(Splitter.on('r').split(apiVersion),0);
|
||||||
|
minorVersion = Iterables.get(Splitter.on('r').split(apiVersion),1);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Logger logger() {
|
||||||
|
return context.utils().loggerFactory().getLogger("jclouds.compute");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setupConfigurationProperties() {
|
protected void setupConfigurationProperties() {
|
||||||
|
|
||||||
sshHost = System.getProperty("test.ssh.host", "localhost");
|
|
||||||
sshPort = System.getProperty("test.ssh.port", "22");
|
|
||||||
sshUser = System.getProperty("test.ssh.username", "toor");
|
|
||||||
sshPass = System.getProperty("test.ssh.password", "password");
|
|
||||||
sshKeyFile = System.getProperty("test.ssh.keyfile");
|
|
||||||
|
|
||||||
admin_pwd = System.getProperty("test." + provider + ".admin_pwd", "password");
|
|
||||||
|
|
||||||
controllerIDE = System.getProperty("test." + provider + ".controllerIde", "IDE Controller");
|
controllerIDE = System.getProperty("test." + provider + ".controllerIde", "IDE Controller");
|
||||||
controllerSATA = System.getProperty("test." + provider + ".controllerSata", "SATA Controller");
|
controllerSATA = System.getProperty("test." + provider + ".controllerSata", "SATA Controller");
|
||||||
diskFormat = System.getProperty("test." + provider + ".diskformat", "");
|
diskFormat = System.getProperty("test." + provider + ".diskformat", "");
|
||||||
|
@ -144,28 +129,22 @@ public class VirtualboxAdministrationKickstartTest {
|
||||||
if (new File(workingDir).mkdir())
|
if (new File(workingDir).mkdir())
|
||||||
;
|
;
|
||||||
vdiName = System.getProperty("test." + provider + ".vdiName", "centos-5.2-x86.7z");
|
vdiName = System.getProperty("test." + provider + ".vdiName", "centos-5.2-x86.7z");
|
||||||
gaIsoName = System.getProperty("test." + provider + ".gaIsoName", "VBoxGuestAdditions_4.0.2-update-69551.iso");
|
gaIsoName = System.getProperty("test." + provider + ".gaIsoName", "VBoxGuestAdditions_"+majorVersion+"-update-"+minorVersion+".iso");
|
||||||
gaIsoUrl = System.getProperty("test." + provider + ".gaIsoUrl", "http://download.virtualbox.org/virtualbox/4.0.2/VBoxGuestAdditions_4.0.2-update-69551.iso");
|
gaIsoUrl = URI.create(System.getProperty("test." + provider + ".gaIsoUrl", "http://download.virtualbox.org/virtualbox/"+majorVersion+"/VBoxGuestAdditions_"+majorVersion+"-update-"+minorVersion+".iso"));
|
||||||
|
|
||||||
distroIsoName = System.getProperty("test." + provider
|
distroIsoName = System.getProperty("test." + provider
|
||||||
+ ".distroIsoName", "ubuntu-11.04-server-i386.iso");
|
+ ".distroIsoName", "ubuntu-11.04-server-i386.iso");
|
||||||
distroIsoUrl = System
|
distroIsoUrl = URI.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"));
|
||||||
|
|
||||||
installVboxOse = System.getProperty("test." + provider
|
|
||||||
+ ".installvboxose",
|
|
||||||
"sudo -S apt-get --yes install virtualbox-ose");
|
|
||||||
|
|
||||||
originalDisk = workingDir + File.separator + "VDI" + File.separator + System.getProperty("test." + provider + ".originalDisk",
|
originalDisk = workingDir + File.separator + "VDI" + File.separator + System.getProperty("test." + provider + ".originalDisk",
|
||||||
"centos-5.2-x86.vdi");
|
"centos-5.2-x86.vdi");
|
||||||
clonedDisk = workingDir + File.separator + System.getProperty("test." + provider + ".clonedDisk",
|
clonedDisk = workingDir + File.separator + System.getProperty("test." + provider + ".clonedDisk",
|
||||||
"template.vdi");
|
"template.vdi");
|
||||||
guestAdditionsDvd = workingDir + File.separator + System.getProperty("test." + provider + ".guestAdditionsDvd",
|
guestAdditionsDvd = workingDir + File.separator + System.getProperty("test." + provider + ".guestAdditionsDvd",
|
||||||
"VBoxGuestAdditions_4.0.2-update-69551.iso");
|
"VBoxGuestAdditions_"+majorVersion+"-update-"+minorVersion+".iso");
|
||||||
|
|
||||||
distroDvd = workingDir + File.separator + System.getProperty("test." + provider + ".distroDvd",
|
|
||||||
distroIsoName);
|
|
||||||
preseedUrl = System.getProperty("test." + provider + ".preseedurl",
|
preseedUrl = System.getProperty("test." + provider + ".preseedurl",
|
||||||
"http://dl.dropbox.com/u/693111/preseed.cfg");
|
"http://dl.dropbox.com/u/693111/preseed.cfg");
|
||||||
|
|
||||||
|
@ -180,51 +159,23 @@ public class VirtualboxAdministrationKickstartTest {
|
||||||
+ "keyboard-configuration/layout=USA keyboard-configuration/variant=USA console-setup/ask_detect=false "
|
+ "keyboard-configuration/layout=USA keyboard-configuration/variant=USA console-setup/ask_detect=false "
|
||||||
+ "initrd=/install/initrd.gz -- <Enter>");
|
+ "initrd=/install/initrd.gz -- <Enter>");
|
||||||
|
|
||||||
vboxwebsrvStartCommand = System.getProperty("test." + provider
|
|
||||||
+ ".vboxwebsrvStartCommand", "/usr/bin/vboxwebsrv");
|
|
||||||
vboxManageCommand = System.getProperty("test." + provider
|
|
||||||
+ ".vboxmanage", "VBoxManage");
|
|
||||||
if (!new File(distroDvd).exists()) {
|
|
||||||
try {
|
|
||||||
downloadFile(distroIsoUrl, workingDir, distroIsoName, null);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!new File(guestAdditionsDvd).exists()) {
|
|
||||||
try {
|
|
||||||
downloadFile(gaIsoUrl, workingDir, gaIsoName, null);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeGroups(groups = "live")
|
@BeforeGroups(groups = "live")
|
||||||
protected void setupClient() throws IOException, InterruptedException {
|
protected void setupClient() throws Exception {
|
||||||
|
context = TestUtils.computeServiceForLocalhost();
|
||||||
injector = Guice.createInjector(new SshjSshClientModule(),
|
socketTester = new RetryablePredicate<IPSocket>(new InetSocketAddressConnect(), 130, 10,
|
||||||
new Log4JLoggingModule());
|
|
||||||
sshFactory = injector.getInstance(SshClient.Factory.class);
|
|
||||||
socketTester = new RetryablePredicate<IPSocket>(
|
|
||||||
injector.getInstance(SocketOpen.class), 130, 10,
|
|
||||||
TimeUnit.SECONDS);
|
TimeUnit.SECONDS);
|
||||||
|
|
||||||
injector.injectMembers(socketTester);
|
|
||||||
|
|
||||||
setupCredentials();
|
setupCredentials();
|
||||||
setupConfigurationProperties();
|
setupConfigurationProperties();
|
||||||
|
downloadFileUnlessPresent(distroIsoUrl, workingDir, distroIsoName);
|
||||||
|
downloadFileUnlessPresent(gaIsoUrl, workingDir, gaIsoName);
|
||||||
installVbox();
|
installVbox();
|
||||||
// startup vbox web server
|
checkVboxVersionExpected();
|
||||||
startupVboxWebServer(vboxwebsrvStartCommand);
|
if (!new InetSocketAddressConnect().apply(new IPSocket(endpoint.getHost(), endpoint.getPort())))
|
||||||
|
startupVboxWebServer();
|
||||||
|
|
||||||
// configure and startup jetty HTTP server
|
|
||||||
try {
|
|
||||||
configureJettyServer();
|
configureJettyServer();
|
||||||
} catch (Exception e) {
|
|
||||||
propagate(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureJettyServer() throws Exception {
|
private void configureJettyServer() throws Exception {
|
||||||
|
@ -235,57 +186,59 @@ public class VirtualboxAdministrationKickstartTest {
|
||||||
resource_handler.setWelcomeFiles(new String[] { "index.html" });
|
resource_handler.setWelcomeFiles(new String[] { "index.html" });
|
||||||
|
|
||||||
resource_handler.setResourceBase(".");
|
resource_handler.setResourceBase(".");
|
||||||
Log.info("serving " + resource_handler.getBaseResource());
|
logger().info("serving " + resource_handler.getBaseResource());
|
||||||
|
|
||||||
HandlerList handlers = new HandlerList();
|
HandlerList handlers = new HandlerList();
|
||||||
handlers.setHandlers(new Handler[] { resource_handler,
|
handlers.setHandlers(new Handler[] { resource_handler,
|
||||||
new DefaultHandler() });
|
new DefaultHandler() });
|
||||||
server.setHandler(handlers);
|
server.setHandler(handlers);
|
||||||
|
|
||||||
// server.start();
|
server.start();
|
||||||
// server.join();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void installVbox() throws IOException, InterruptedException {
|
void installVbox() throws IOException, InterruptedException {
|
||||||
SshClient client = setupSshClient();
|
if (runScriptOnNode(hostId, "VBoxManage -version").getExitCode() != 0) {
|
||||||
try {
|
logger().debug("installing virtualbox");
|
||||||
client.exec("echo " + sshPass + " | " + installVboxOse);
|
if (isOSX(hostId))
|
||||||
} catch (Exception e) {
|
;// TODO
|
||||||
System.out
|
else
|
||||||
.println("It is impossible to install virtualbox with this command "
|
runScriptOnNode(hostId, "apt-get --yes install virtualbox-ose");
|
||||||
+ installVboxOse);
|
// TODO other platforms
|
||||||
} finally {
|
|
||||||
if (client != null)
|
|
||||||
client.disconnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void checkVboxVersionExpected() throws IOException, InterruptedException {
|
||||||
|
logger().debug("checking virtualbox version");
|
||||||
|
assertEquals(runScriptOnNode(hostId, "VBoxManage -version").getOutput().trim(), apiVersion);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param command
|
* @param command
|
||||||
* absolute path to command. For ubuntu 10.04:
|
* absolute path to command. For ubuntu 10.04: /usr/bin/vboxwebsrv
|
||||||
* /usr/bin/vboxwebsrv
|
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
*/
|
*/
|
||||||
private void startupVboxWebServer(String command) throws IOException,
|
void startupVboxWebServer() {
|
||||||
InterruptedException {
|
logger().debug("disabling password access");
|
||||||
// Disable login credential: $
|
runScriptOnNode(hostId, "VBoxManage setproperty websrvauthlibrary null");
|
||||||
// rt.exec("VBoxManage setproperty websrvauthlibrary null");
|
logger().debug("starting vboxwebsrv");
|
||||||
SshClient client = setupSshClient();
|
String vboxwebsrv = "vboxwebsrv -t 5 -v";
|
||||||
try {
|
if (isOSX(hostId))
|
||||||
ExecResponse response = client.exec(command + " -t 0 -b");
|
vboxwebsrv = "cd /Applications/VirtualBox.app/Contents/MacOS/&&" + vboxwebsrv;
|
||||||
} catch (Exception e) {
|
// allow jclouds to background the process, this is why we don't specify
|
||||||
propagate(e);
|
// -b; logs will go corresponding to task name in this case under /tmp/vboxwebsrv
|
||||||
} finally {
|
runScriptOnNode(hostId, vboxwebsrv,
|
||||||
if (client != null)
|
blockOnPort(endpoint.getPort(), 10).blockOnComplete(false).nameTask("vboxwebsrv"));
|
||||||
client.disconnect();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean isOSX(String id) {
|
||||||
|
return context.getComputeService().getNodeMetadata(hostId).getOperatingSystem().getDescription().equals("Mac OS X");
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeMethod
|
@BeforeMethod
|
||||||
protected void setupManager() {
|
protected void setupManager() {
|
||||||
manager.connect(endpoint, identity, credential);
|
manager.connect(endpoint.toASCIIString(), identity, credential);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterMethod
|
@AfterMethod
|
||||||
|
@ -339,7 +292,7 @@ public class VirtualboxAdministrationKickstartTest {
|
||||||
MediumVariant.VMDK_SPLIT_2_G.ordinal()));
|
MediumVariant.VMDK_SPLIT_2_G.ordinal()));
|
||||||
} else
|
} else
|
||||||
hd = manager.getVBox().openMedium(clonedDisk, DeviceType.HardDisk,
|
hd = manager.getVBox().openMedium(clonedDisk, DeviceType.HardDisk,
|
||||||
AccessMode.ReadWrite);
|
AccessMode.ReadWrite, forceOverwrite);
|
||||||
ISession session = manager.getSessionObject();
|
ISession session = manager.getSessionObject();
|
||||||
IMachine machine = manager.getVBox().findMachine(vmName);
|
IMachine machine = manager.getVBox().findMachine(vmName);
|
||||||
machine.lockMachine(session, LockType.Write);
|
machine.lockMachine(session, LockType.Write);
|
||||||
|
@ -359,7 +312,7 @@ public class VirtualboxAdministrationKickstartTest {
|
||||||
|
|
||||||
// network BRIDGED to access HTTP server
|
// network BRIDGED to access HTTP server
|
||||||
String hostInterface = null;
|
String hostInterface = null;
|
||||||
String command = vboxManageCommand + " list bridgedifs";
|
String command = "VBoxManage list bridgedifs";
|
||||||
try {
|
try {
|
||||||
Process child = Runtime.getRuntime().exec(command);
|
Process child = Runtime.getRuntime().exec(command);
|
||||||
BufferedReader bufferedReader = new BufferedReader(
|
BufferedReader bufferedReader = new BufferedReader(
|
||||||
|
@ -380,7 +333,7 @@ public class VirtualboxAdministrationKickstartTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NAT
|
// NAT
|
||||||
mutable.getNetworkAdapter(new Long(0)).attachToNAT();
|
// mutable.getNetworkAdapter(new Long(0)).attachToNAT(); TODO: this no longer exists!
|
||||||
mutable.getNetworkAdapter(new Long(0)).setNATNetwork("");
|
mutable.getNetworkAdapter(new Long(0)).setNATNetwork("");
|
||||||
machine.getNetworkAdapter(new Long(0))
|
machine.getNetworkAdapter(new Long(0))
|
||||||
.getNatDriver()
|
.getNatDriver()
|
||||||
|
@ -397,7 +350,7 @@ public class VirtualboxAdministrationKickstartTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testConfigureNIC")
|
@Test(dependsOnMethods = "testConfigureNIC")
|
||||||
public void testStartVirtualMachine() {
|
public void testStartVirtualMachine() throws InterruptedException {
|
||||||
IMachine machine = manager.getVBox().findMachine(vmName);
|
IMachine machine = manager.getVBox().findMachine(vmName);
|
||||||
ISession session = manager.getSessionObject();
|
ISession session = manager.getSessionObject();
|
||||||
launchVMProcess(machine, session);
|
launchVMProcess(machine, session);
|
||||||
|
@ -412,37 +365,11 @@ public class VirtualboxAdministrationKickstartTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testStartVirtualMachine")
|
@Test(dependsOnMethods = "testStartVirtualMachine")
|
||||||
public void testConfigureGuestAdditions() throws FileNotFoundException,
|
public void testConfigureGuestAdditions() {
|
||||||
IOException {
|
|
||||||
IPSocket socket = new IPSocket(sshHost, 2222);
|
|
||||||
|
|
||||||
System.out.printf("%d: %s awaiting ssh service to start%n",
|
|
||||||
System.currentTimeMillis(), socket);
|
|
||||||
assert socketTester.apply(socket);
|
|
||||||
System.out.printf("%d: %s ssh service started%n",
|
|
||||||
System.currentTimeMillis(), socket);
|
|
||||||
// configure GA
|
|
||||||
SshClient client = setupSshClient();
|
|
||||||
try {
|
|
||||||
// Configure your system for building kernel modules by running
|
// Configure your system for building kernel modules by running
|
||||||
ExecResponse exec = client.exec("echo " + sshPass + " | " + "sudo -S m-a prepare -i");
|
runScriptOnNode(guestId, "m-a prepare -i");
|
||||||
System.out.println(exec);
|
runScriptOnNode(guestId, "mount -o loop /usr/share/virtualbox/VBoxGuestAdditions.iso /mnt");
|
||||||
} finally {
|
runScriptOnNode(guestId, "/mnt/VBoxLinuxAdditions.run");
|
||||||
if (client != null) {
|
|
||||||
client.disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
ExecResponse exec = client.exec("echo " + sshPass + " | "
|
|
||||||
+ "sudo -S mount -o loop /usr/share/virtualbox/VBoxGuestAdditions.iso /mnt");
|
|
||||||
System.out.println(exec);
|
|
||||||
exec = client.exec("echo " + sshPass + " | " + "sudo -S sh /mnt/VBoxLinuxAdditions.run");
|
|
||||||
System.out.println(exec);
|
|
||||||
} finally {
|
|
||||||
if (client != null)
|
|
||||||
client.disconnect();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testConfigureGuestAdditions")
|
@Test(dependsOnMethods = "testConfigureGuestAdditions")
|
||||||
|
@ -506,81 +433,51 @@ public class VirtualboxAdministrationKickstartTest {
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
void stopVboxWebServer() throws IOException {
|
void stopVboxWebServer() throws IOException {
|
||||||
// stop vbox web server
|
runScriptOnNode(guestId, "pidof vboxwebsrv | xargs kill");
|
||||||
SshClient client = setupSshClient();
|
|
||||||
try {
|
|
||||||
ExecResponse exec = client.exec("pidof vboxwebsrv | xargs kill");
|
|
||||||
System.out.println(exec.getOutput());
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
if (client != null)
|
|
||||||
client.disconnect();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected ExecResponse runScriptOnNode(String nodeId, String command, RunScriptOptions options) {
|
||||||
*
|
ExecResponse toReturn = context.getComputeService().runScriptOnNode(nodeId, command, options);
|
||||||
* @param workingDir
|
assert toReturn.getExitCode() == 0: toReturn;
|
||||||
* @param vdiUrl
|
return toReturn;
|
||||||
* @param proxy
|
}
|
||||||
* Proxy proxy , new Proxy(Proxy.Type.HTTP, new
|
|
||||||
* InetSocketAddress("localhost", 5865));
|
|
||||||
* @return
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
private File downloadFile(String sourceURL, String destinationDir,
|
|
||||||
String vboxGuestAdditionsName, Proxy proxy) throws Exception {
|
|
||||||
|
|
||||||
String absolutePathName = destinationDir + File.separator
|
protected ExecResponse runScriptOnNode(String nodeId, String command) {
|
||||||
+ vboxGuestAdditionsName;
|
return runScriptOnNode(nodeId, command, wrapInInitScript(false));
|
||||||
File iso = new File(absolutePathName);
|
}
|
||||||
|
|
||||||
|
private File downloadFileUnlessPresent(URI sourceURL, String destinationDir,
|
||||||
|
String filename) throws Exception {
|
||||||
|
|
||||||
|
File iso = new File(destinationDir, filename);
|
||||||
|
|
||||||
final URL isoURL = new URL(sourceURL);
|
|
||||||
final HttpURLConnection uc = (HttpURLConnection) isoURL
|
|
||||||
.openConnection(); // isoURL.openConnection(proxy);
|
|
||||||
uc.connect();
|
|
||||||
if (!iso.exists()) {
|
if (!iso.exists()) {
|
||||||
System.out.println("Start download " + sourceURL + " to "
|
InputStream is = context.utils().http().get(sourceURL);
|
||||||
+ absolutePathName);
|
checkNotNull(is, "%s not found", sourceURL);
|
||||||
Files.copy(new InputSupplier<InputStream>() {
|
try {
|
||||||
|
ByteStreams.copy(is, new FileOutputStream(iso));
|
||||||
@Override
|
} finally {
|
||||||
public InputStream getInput() throws IOException {
|
Closeables.closeQuietly(is);
|
||||||
return uc.getInputStream();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}, iso);
|
|
||||||
}
|
}
|
||||||
return iso;
|
return iso;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendKeyboardSequence(String keyboardSequence) {
|
private void sendKeyboardSequence(String keyboardSequence) throws InterruptedException {
|
||||||
String[] sequenceSplited = keyboardSequence.split(" ");
|
String[] sequenceSplited = keyboardSequence.split(" ");
|
||||||
SshClient client = null;
|
|
||||||
try {
|
|
||||||
client = setupSshClient();
|
|
||||||
for (String word : sequenceSplited) {
|
for (String word : sequenceSplited) {
|
||||||
String converted = stringToKeycode(word);
|
String converted = stringToKeycode(word);
|
||||||
for (String string : converted.split(" ")) {
|
for (String string : converted.split(" ")) {
|
||||||
|
|
||||||
ExecResponse response = client.exec(vboxManageCommand
|
runScriptOnNode(hostId , "VBoxManage controlvm " + vmName + " keyboardputscancode "
|
||||||
+ " controlvm " + vmName + " keyboardputscancode "
|
|
||||||
+ string);
|
+ string);
|
||||||
System.out.println(response.getOutput());
|
|
||||||
if (converted
|
if (converted
|
||||||
.contains(KeyboardScancodes.SPECIAL_KEYBOARD_BUTTON_MAP
|
.contains(KeyboardScancodes.SPECIAL_KEYBOARD_BUTTON_MAP
|
||||||
.get("<Return>")))
|
.get("<Return>")))
|
||||||
Thread.sleep(180);
|
Thread.sleep(180);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
if (client != null)
|
|
||||||
client.disconnect();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String stringToKeycode(String s) {
|
private String stringToKeycode(String s) {
|
||||||
|
@ -619,24 +516,4 @@ public class VirtualboxAdministrationKickstartTest {
|
||||||
prog.waitForCompletion(-1);
|
prog.waitForCompletion(-1);
|
||||||
session.unlockMachine();
|
session.unlockMachine();
|
||||||
}
|
}
|
||||||
|
|
||||||
private SshClient setupSshClient() throws FileNotFoundException,
|
|
||||||
IOException {
|
|
||||||
int port = Integer.parseInt(sshPort);
|
|
||||||
Injector i = Guice.createInjector(new SshjSshClientModule());
|
|
||||||
SshClient.Factory factory = i.getInstance(SshClient.Factory.class);
|
|
||||||
SshClient connection;
|
|
||||||
if (sshKeyFile != null && !sshKeyFile.trim().equals("")) {
|
|
||||||
connection = factory
|
|
||||||
.create(new IPSocket(sshHost, port),
|
|
||||||
new Credentials(sshUser, Strings2
|
|
||||||
.toStringAndClose(new FileInputStream(
|
|
||||||
sshKeyFile))));
|
|
||||||
} else {
|
|
||||||
connection = factory.create(new IPSocket(sshHost, port),
|
|
||||||
new Credentials(sshUser, sshPass));
|
|
||||||
}
|
|
||||||
connection.connect();
|
|
||||||
return connection;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -14,7 +14,8 @@ import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.ExecResponse;
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
import org.jclouds.encryption.bouncycastle.config.BouncyCastleCryptoModule;
|
||||||
|
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
|
||||||
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;
|
||||||
|
@ -25,20 +26,20 @@ import org.testng.annotations.AfterMethod;
|
||||||
import org.testng.annotations.BeforeGroups;
|
import org.testng.annotations.BeforeGroups;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
import org.virtualbox_4_0.AccessMode;
|
import org.virtualbox_4_1.AccessMode;
|
||||||
import org.virtualbox_4_0.DeviceType;
|
import org.virtualbox_4_1.DeviceType;
|
||||||
import org.virtualbox_4_0.IMachine;
|
import org.virtualbox_4_1.IMachine;
|
||||||
import org.virtualbox_4_0.IMedium;
|
import org.virtualbox_4_1.IMedium;
|
||||||
import org.virtualbox_4_0.IProgress;
|
import org.virtualbox_4_1.IProgress;
|
||||||
import org.virtualbox_4_0.ISession;
|
import org.virtualbox_4_1.ISession;
|
||||||
import org.virtualbox_4_0.IStorageController;
|
import org.virtualbox_4_1.IStorageController;
|
||||||
import org.virtualbox_4_0.LockType;
|
import org.virtualbox_4_1.LockType;
|
||||||
import org.virtualbox_4_0.MachineState;
|
import org.virtualbox_4_1.MachineState;
|
||||||
import org.virtualbox_4_0.NATProtocol;
|
import org.virtualbox_4_1.NATProtocol;
|
||||||
import org.virtualbox_4_0.SessionState;
|
import org.virtualbox_4_1.SessionState;
|
||||||
import org.virtualbox_4_0.StorageBus;
|
import org.virtualbox_4_1.StorageBus;
|
||||||
import org.virtualbox_4_0.VirtualBoxManager;
|
import org.virtualbox_4_1.VirtualBoxManager;
|
||||||
import org.virtualbox_4_0.jaxws.MediumVariant;
|
import org.virtualbox_4_1.jaxws.MediumVariant;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
|
@ -197,7 +198,7 @@ public class VirtualboxAdministrationTest {
|
||||||
hostPassword = System.getProperty("test." + provider + ".hostpassword", "password");
|
hostPassword = System.getProperty("test." + provider + ".hostpassword", "password");
|
||||||
|
|
||||||
injector = Guice.createInjector(new SshjSshClientModule(),
|
injector = Guice.createInjector(new SshjSshClientModule(),
|
||||||
new Log4JLoggingModule());
|
new SLF4JLoggingModule(), new BouncyCastleCryptoModule());
|
||||||
sshFactory = injector.getInstance(SshClient.Factory.class);
|
sshFactory = injector.getInstance(SshClient.Factory.class);
|
||||||
socketTester = new RetryablePredicate<IPSocket>(
|
socketTester = new RetryablePredicate<IPSocket>(
|
||||||
new InetSocketAddressConnect(), 3600, 1, TimeUnit.SECONDS);
|
new InetSocketAddressConnect(), 3600, 1, TimeUnit.SECONDS);
|
||||||
|
@ -304,7 +305,7 @@ public class VirtualboxAdministrationTest {
|
||||||
@Test(dependsOnMethods = "testCreateDiskController")
|
@Test(dependsOnMethods = "testCreateDiskController")
|
||||||
public void testCloneAndAttachHardDisk() {
|
public void testCloneAndAttachHardDisk() {
|
||||||
IMedium hd = manager.getVBox().openMedium(originalDisk,
|
IMedium hd = manager.getVBox().openMedium(originalDisk,
|
||||||
DeviceType.HardDisk, AccessMode.ReadOnly);
|
DeviceType.HardDisk, AccessMode.ReadOnly, forceOverwrite);
|
||||||
IMedium clonedHd = null;
|
IMedium clonedHd = null;
|
||||||
if(!new File(clonedDisk).exists()) {
|
if(!new File(clonedDisk).exists()) {
|
||||||
clonedHd = manager.getVBox().createHardDisk(diskFormat, clonedDisk);
|
clonedHd = manager.getVBox().createHardDisk(diskFormat, clonedDisk);
|
||||||
|
@ -312,7 +313,7 @@ public class VirtualboxAdministrationTest {
|
||||||
cloning.waitForCompletion(-1);
|
cloning.waitForCompletion(-1);
|
||||||
} else
|
} else
|
||||||
clonedHd = manager.getVBox().openMedium(clonedDisk,
|
clonedHd = manager.getVBox().openMedium(clonedDisk,
|
||||||
DeviceType.HardDisk, AccessMode.ReadOnly);
|
DeviceType.HardDisk, AccessMode.ReadOnly, forceOverwrite);
|
||||||
|
|
||||||
ISession session = manager.getSessionObject();
|
ISession session = manager.getSessionObject();
|
||||||
IMachine machine = manager.getVBox().findMachine(vmName);
|
IMachine machine = manager.getVBox().findMachine(vmName);
|
||||||
|
@ -334,7 +335,7 @@ public class VirtualboxAdministrationTest {
|
||||||
/*
|
/*
|
||||||
* NAT
|
* NAT
|
||||||
*/
|
*/
|
||||||
mutable.getNetworkAdapter(new Long(0)).attachToNAT();
|
// mutable.getNetworkAdapter(new Long(0)).attachToNAT(); not in 4.1
|
||||||
mutable.getNetworkAdapter(new Long(0)).setNATNetwork("");
|
mutable.getNetworkAdapter(new Long(0)).setNATNetwork("");
|
||||||
mutable.getNetworkAdapter(new Long(0)).setEnabled(true);
|
mutable.getNetworkAdapter(new Long(0)).setEnabled(true);
|
||||||
mutable.saveSettings();
|
mutable.saveSettings();
|
||||||
|
@ -355,7 +356,7 @@ public class VirtualboxAdministrationTest {
|
||||||
IMachine machine = manager.getVBox().findMachine(vmName);
|
IMachine machine = manager.getVBox().findMachine(vmName);
|
||||||
|
|
||||||
IMedium guestAdditionsDVD = manager.getVBox().openMedium(guestAdditionsDvdName,
|
IMedium guestAdditionsDVD = manager.getVBox().openMedium(guestAdditionsDvdName,
|
||||||
DeviceType.DVD, AccessMode.ReadOnly);
|
DeviceType.DVD, AccessMode.ReadOnly, forceOverwrite);
|
||||||
for (IStorageController storageController : machine
|
for (IStorageController storageController : machine
|
||||||
.getStorageControllers()) {
|
.getStorageControllers()) {
|
||||||
// for DVD we choose IDE
|
// for DVD we choose IDE
|
||||||
|
|
|
@ -13,7 +13,8 @@ import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.ExecResponse;
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
import org.jclouds.encryption.bouncycastle.config.BouncyCastleCryptoModule;
|
||||||
|
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
|
||||||
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;
|
||||||
|
@ -23,19 +24,19 @@ import org.testng.annotations.AfterMethod;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
import org.virtualbox_4_0.AccessMode;
|
import org.virtualbox_4_1.AccessMode;
|
||||||
import org.virtualbox_4_0.DeviceType;
|
import org.virtualbox_4_1.DeviceType;
|
||||||
import org.virtualbox_4_0.IMachine;
|
import org.virtualbox_4_1.IMachine;
|
||||||
import org.virtualbox_4_0.IMedium;
|
import org.virtualbox_4_1.IMedium;
|
||||||
import org.virtualbox_4_0.IProgress;
|
import org.virtualbox_4_1.IProgress;
|
||||||
import org.virtualbox_4_0.ISession;
|
import org.virtualbox_4_1.ISession;
|
||||||
import org.virtualbox_4_0.LockType;
|
import org.virtualbox_4_1.LockType;
|
||||||
import org.virtualbox_4_0.MachineState;
|
import org.virtualbox_4_1.MachineState;
|
||||||
import org.virtualbox_4_0.MediumType;
|
import org.virtualbox_4_1.MediumType;
|
||||||
import org.virtualbox_4_0.SessionState;
|
import org.virtualbox_4_1.SessionState;
|
||||||
import org.virtualbox_4_0.StorageBus;
|
import org.virtualbox_4_1.StorageBus;
|
||||||
import org.virtualbox_4_0.VirtualBoxManager;
|
import org.virtualbox_4_1.VirtualBoxManager;
|
||||||
import org.virtualbox_4_0.jaxws.MediumState;
|
import org.virtualbox_4_1.jaxws.MediumState;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
|
@ -116,7 +117,7 @@ public class VirtualboxLiveTest {
|
||||||
apiversion = System.getProperty("test." + provider + ".apiversion");
|
apiversion = System.getProperty("test." + provider + ".apiversion");
|
||||||
|
|
||||||
injector = Guice.createInjector(new SshjSshClientModule(),
|
injector = Guice.createInjector(new SshjSshClientModule(),
|
||||||
new Log4JLoggingModule());
|
new SLF4JLoggingModule(), new BouncyCastleCryptoModule());
|
||||||
sshFactory = injector.getInstance(SshClient.Factory.class);
|
sshFactory = injector.getInstance(SshClient.Factory.class);
|
||||||
socketTester = new RetryablePredicate<IPSocket>(
|
socketTester = new RetryablePredicate<IPSocket>(
|
||||||
new InetSocketAddressConnect(), 180, 1, TimeUnit.SECONDS);
|
new InetSocketAddressConnect(), 180, 1, TimeUnit.SECONDS);
|
||||||
|
@ -184,8 +185,9 @@ public class VirtualboxLiveTest {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
mutable.getNetworkAdapter(new Long(0)).attachToBridgedInterface();
|
// TODO: lookup translations for 4.1 for the below
|
||||||
mutable.getNetworkAdapter(new Long(0)).setHostInterface(hostInterface.trim());
|
// mutable.getNetworkAdapter(new Long(0)).attachToBridgedInterface();
|
||||||
|
// mutable.getNetworkAdapter(new Long(0)).setHostInterface(hostInterface.trim());
|
||||||
mutable.getNetworkAdapter(new Long(0)).setEnabled(true);
|
mutable.getNetworkAdapter(new Long(0)).setEnabled(true);
|
||||||
|
|
||||||
mutable.saveSettings();
|
mutable.saveSettings();
|
||||||
|
@ -204,7 +206,7 @@ public class VirtualboxLiveTest {
|
||||||
clonedDiskPath = workingDir + File.separator + instanceClonedDisk;
|
clonedDiskPath = workingDir + File.separator + instanceClonedDisk;
|
||||||
|
|
||||||
// use template disk in multiattach mode
|
// use template disk in multiattach mode
|
||||||
IMedium clonedHd = manager.getVBox().openMedium(originalDiskPath, DeviceType.HardDisk, AccessMode.ReadOnly);
|
IMedium clonedHd = manager.getVBox().openMedium(originalDiskPath, DeviceType.HardDisk, AccessMode.ReadOnly, forceOverwrite);
|
||||||
|
|
||||||
System.out.println("cloned HD state: " + clonedHd.getState());
|
System.out.println("cloned HD state: " + clonedHd.getState());
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<configuration scan="false">
|
||||||
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{HH:mm:ss.SSS} - %msg%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
<!-- turn OFF all logging (children can override) -->
|
||||||
|
<root level="OFF">
|
||||||
|
<appender-ref ref="STDOUT"/>
|
||||||
|
</root>
|
||||||
|
<logger name="jclouds.compute" level="debug"/>
|
||||||
|
<logger name="jclouds.headers" level="debug"/>
|
||||||
|
<logger name="jclouds.ssh" level="debug"/>
|
||||||
|
</configuration>
|
Loading…
Reference in New Issue