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:
Adrian Cole 2011-07-27 02:31:10 -07:00
parent d991f3a83c
commit 5243790801
6 changed files with 439 additions and 427 deletions

View File

@ -1,128 +1,195 @@
<?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 ====================================================================
or more contributor license agreements. See the NOTICE file Licensed under the Apache License, Version 2.0 (the "License");
distributed with this work for additional information you may not use this file except in compliance with the License.
regarding copyright ownership. The ASF licenses this file You may obtain a copy of the License at
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance http://www.apache.org/licenses/LICENSE-2.0
with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software
http://www.apache.org/licenses/LICENSE-2.0.html distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Unless required by applicable law or agreed to in writing, See the License for the specific language governing permissions and
software distributed under the License is distributed on an limitations under the License.
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ====================================================================
KIND, either express or implied. See the License for the
specific language governing permissions and limitations -->
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">
--> <modelVersion>4.0.0</modelVersion>
<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"> <parent>
<modelVersion>4.0.0</modelVersion> <groupId>org.jclouds</groupId>
<parent> <artifactId>jclouds-project</artifactId>
<groupId>org.jclouds</groupId> <version>1.1.0-SNAPSHOT</version>
<artifactId>jclouds-project</artifactId> <relativePath>../../project/pom.xml</relativePath>
<version>1.1.0-SNAPSHOT</version> </parent>
<relativePath>../../project/pom.xml</relativePath> <groupId>org.jclouds.api</groupId>
</parent> <artifactId>virtualbox</artifactId>
<groupId>org.jclouds.api</groupId> <name>jcloud virtualbox api</name>
<artifactId>virtualbox</artifactId> <description>jclouds components to access an implementation of virtualbox</description>
<name>jclouds components for a virtualbox provider</name> <packaging>bundle</packaging>
<properties>
<test.virtualbox.endpoint>test:///default</test.virtualbox.endpoint> <properties>
<test.virtualbox.apiversion>1.0</test.virtualbox.apiversion> <test.virtualbox.endpoint>http://localhost:18083/</test.virtualbox.endpoint>
<test.virtualbox.identity>FIXME</test.virtualbox.identity> <test.virtualbox.apiversion>4.1.0r73009</test.virtualbox.apiversion>
<test.virtualbox.credential>FIXME</test.virtualbox.credential> <test.virtualbox.identity>administrator</test.virtualbox.identity>
</properties> <test.virtualbox.credential>12345</test.virtualbox.credential>
</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>
</repository> <releases>
</repositories> <enabled>true</enabled>
<dependencies> </releases>
<dependency> <snapshots>
<groupId>org.clojars.tbatchelli</groupId> <enabled>false</enabled>
<artifactId>vboxjws</artifactId> </snapshots>
<version>4.0.2</version> </repository>
</dependency> <repository>
<dependency> <id>sonatype-nexus-snapshots</id>
<groupId>org.jclouds</groupId> <url>https://oss.sonatype.org/content/repositories/snapshots</url>
<artifactId>jclouds-core</artifactId> <releases>
<version>${project.version}</version> <enabled>false</enabled>
<type>test-jar</type> </releases>
<scope>test</scope> <snapshots>
</dependency> <enabled>true</enabled>
<dependency> </snapshots>
<groupId>org.jclouds</groupId> </repository>
<artifactId>jclouds-compute</artifactId> </repositories>
<version>${project.version}</version>
</dependency> <dependencies>
<dependency> <dependency>
<groupId>org.jclouds</groupId> <groupId>org.jclouds</groupId>
<artifactId>jclouds-compute</artifactId> <artifactId>jclouds-compute</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
<type>test-jar</type> </dependency>
<scope>test</scope> <dependency>
</dependency> <groupId>org.virtualbox</groupId>
<dependency> <artifactId>vboxjws</artifactId>
<groupId>org.jclouds.driver</groupId> <version>${test.virtualbox.apiversion}</version>
<artifactId>jclouds-log4j</artifactId> </dependency>
<version>${project.version}</version> <dependency>
<scope>test</scope> <groupId>org.jclouds.api</groupId>
</dependency> <artifactId>byon</artifactId>
<dependency> <version>${project.version}</version>
<groupId>org.jclouds.driver</groupId> </dependency>
<artifactId>jclouds-sshj</artifactId> <dependency>
<version>${project.version}</version> <groupId>com.github.jponge</groupId>
<scope>test</scope> <artifactId>lzma-java</artifactId>
</dependency> <version>1.2</version>
<dependency> <scope>test</scope>
<groupId>com.github.jponge</groupId> </dependency>
<artifactId>lzma-java</artifactId> <dependency>
<version>1.2</version> <groupId>org.eclipse.jetty</groupId>
</dependency> <artifactId>jetty-security</artifactId>
<dependency> <scope>test</scope>
<groupId>org.eclipse.jetty</groupId> </dependency>
<artifactId>jetty-security</artifactId> <dependency>
<scope>test</scope> <groupId>org.jclouds</groupId>
</dependency> <artifactId>jclouds-core</artifactId>
</dependencies> <version>${project.version}</version>
<profiles> <type>test-jar</type>
<profile> <scope>test</scope>
<id>live</id> </dependency>
<build> <dependency>
<plugins> <groupId>org.jclouds</groupId>
<plugin> <artifactId>jclouds-compute</artifactId>
<groupId>org.apache.maven.plugins</groupId> <version>${project.version}</version>
<artifactId>maven-surefire-plugin</artifactId> <type>test-jar</type>
<executions> <scope>test</scope>
<execution> </dependency>
<id>integration</id> <dependency>
<phase>integration-test</phase> <groupId>org.jclouds.driver</groupId>
<goals> <artifactId>jclouds-sshj</artifactId>
<goal>test</goal> <version>${project.version}</version>
</goals> <scope>test</scope>
<configuration> </dependency>
<systemPropertyVariables> <dependency>
<test.virtualbox.endpoint>${test.virtualbox.endpoint}</test.virtualbox.endpoint> <groupId>org.jclouds.driver</groupId>
<test.virtualbox.apiversion>${test.virtualbox.apiversion}</test.virtualbox.apiversion> <artifactId>jclouds-slf4j</artifactId>
<test.virtualbox.identity>${test.virtualbox.identity}</test.virtualbox.identity> <version>${project.version}</version>
<test.virtualbox.credential>${test.virtualbox.credential}</test.virtualbox.credential> <scope>test</scope>
</systemPropertyVariables> </dependency>
</configuration> <dependency>
</execution> <groupId>ch.qos.logback</groupId>
</executions> <artifactId>logback-classic</artifactId>
</plugin> <version>0.9.29</version>
</plugins> <scope>test</scope>
</build> </dependency>
</profile> </dependencies>
</profiles>
</project> <profiles>
<profile>
<id>live</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<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>
<execution>
<id>integration</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<systemProperties>
<property>
<name>test.virtualbox.endpoint</name>
<value>${test.virtualbox.endpoint}</value>
</property>
<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>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</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>

View File

@ -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);
}
}

View File

@ -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 = URI.create(System.getProperty("test." + provider + ".endpoint", "http://localhost:18083/"));
endpoint = System.getProperty("test." + provider + ".endpoint", "http://localhost:18083/"); apiVersion = System.getProperty("test." + provider + ".apiversion", "4.1.0r73009");
apiversion = System.getProperty("test." + provider + ".apiversion"); 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 configureJettyServer();
try {
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");
* @param command assertEquals(runScriptOnNode(hostId, "VBoxManage -version").getOutput().trim(), apiVersion);
* absolute path to command. For ubuntu 10.04: }
* /usr/bin/vboxwebsrv
* @throws IOException /**
* @throws InterruptedException *
*/ * @param command
private void startupVboxWebServer(String command) throws IOException, * absolute path to command. For ubuntu 10.04: /usr/bin/vboxwebsrv
InterruptedException { * @throws IOException
// Disable login credential: $ * @throws InterruptedException
// rt.exec("VBoxManage setproperty websrvauthlibrary null"); */
SshClient client = setupSshClient(); void startupVboxWebServer() {
try { logger().debug("disabling password access");
ExecResponse response = client.exec(command + " -t 0 -b"); runScriptOnNode(hostId, "VBoxManage setproperty websrvauthlibrary null");
} catch (Exception e) { logger().debug("starting vboxwebsrv");
propagate(e); String vboxwebsrv = "vboxwebsrv -t 5 -v";
} finally { if (isOSX(hostId))
if (client != null) vboxwebsrv = "cd /Applications/VirtualBox.app/Contents/MacOS/&&" + vboxwebsrv;
client.disconnect(); // 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(hostId, vboxwebsrv,
blockOnPort(endpoint.getPort(), 10).blockOnComplete(false).nameTask("vboxwebsrv"));
}
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 { // Configure your system for building kernel modules by running
IPSocket socket = new IPSocket(sshHost, 2222); runScriptOnNode(guestId, "m-a prepare -i");
runScriptOnNode(guestId, "mount -o loop /usr/share/virtualbox/VBoxGuestAdditions.iso /mnt");
System.out.printf("%d: %s awaiting ssh service to start%n", runScriptOnNode(guestId, "/mnt/VBoxLinuxAdditions.run");
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
ExecResponse exec = client.exec("echo " + sshPass + " | " + "sudo -S m-a prepare -i");
System.out.println(exec);
} finally {
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)); protected ExecResponse runScriptOnNode(String nodeId, String command) {
* @return return runScriptOnNode(nodeId, command, wrapInInitScript(false));
* @throws Exception }
*/
private File downloadFile(String sourceURL, String destinationDir,
String vboxGuestAdditionsName, Proxy proxy) throws Exception {
String absolutePathName = destinationDir + File.separator private File downloadFileUnlessPresent(URI sourceURL, String destinationDir,
+ vboxGuestAdditionsName; String filename) throws Exception {
File iso = new File(absolutePathName);
final URL isoURL = new URL(sourceURL); File iso = new File(destinationDir, filename);
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;
}
} }

View File

@ -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;
@ -196,8 +197,8 @@ public class VirtualboxAdministrationTest {
hostUsername = System.getProperty("test." + provider + ".hostusername", "toor"); hostUsername = System.getProperty("test." + provider + ".hostusername", "toor");
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

View File

@ -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;
@ -115,8 +116,8 @@ public class VirtualboxLiveTest {
endpoint = System.getProperty("test." + provider + ".endpoint", "http://localhost:18083/"); endpoint = System.getProperty("test." + provider + ".endpoint", "http://localhost:18083/");
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());
/* /*

View File

@ -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>