Skip to content
This repository has been archived by the owner on Mar 25, 2018. It is now read-only.

Commit

Permalink
added support for vbox 4.2.6;
Browse files Browse the repository at this point in the history
added hostname support;
added generic md5 support;
dralves`s comments addressed
adrian`s comments addressed
dralver`s comments addressed
second round of comments addressed
fix CreateAndRegisterMachineFromIsoIfNotAlreadyExistsLiveTest
formatting
swept check*
updated jclouds-sshj pom.xml with latest bouncycastle version
  • Loading branch information
andreaturli committed Dec 31, 2012
1 parent b8b258d commit ac0e5f5
Show file tree
Hide file tree
Showing 104 changed files with 1,486 additions and 1,365 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ bin/
TAGS
.metadata/
atlassian-ide-plugin.xml
.DS_Store
6 changes: 6 additions & 0 deletions drivers/sshj/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@
</properties>

<dependencies>
<!-- until sshj will update to latest bouncycastle 1.47 -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>1.47</version>
</dependency>
<dependency>
<groupId>org.jclouds</groupId>
<artifactId>jclouds-compute</artifactId>
Expand Down
Binary file added labs/virtualbox/.DS_Store
Binary file not shown.
19 changes: 10 additions & 9 deletions labs/virtualbox/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@
<packaging>bundle</packaging>

<properties>
<virtualbox.version>4.2.6</virtualbox.version>
<test.virtualbox.endpoint>http://localhost:18083/</test.virtualbox.endpoint>
<test.virtualbox.api-version>4.1.4</test.virtualbox.api-version>
<test.virtualbox.build-version>4.1.20r80170</test.virtualbox.build-version>
<test.virtualbox.api-version>4.2.6</test.virtualbox.api-version>
<test.virtualbox.build-version>${virtualbox.version}</test.virtualbox.build-version>
<test.virtualbox.identity>${user.name}</test.virtualbox.identity>
<test.virtualbox.credential>CHANGE_ME</test.virtualbox.credential>
<test.virtualbox.template>osFamily=UBUNTU,osVersionMatches=12.04.1,os64Bit=true,osArchMatches=amd64,loginUser=toor:password,authenticateSudo=true</test.virtualbox.template>
Expand All @@ -49,7 +50,7 @@
*
</jclouds.osgi.import>
</properties>

<dependencies>
<dependency>
<groupId>org.jclouds</groupId>
Expand All @@ -59,7 +60,7 @@
<dependency>
<groupId>org.virtualbox</groupId>
<artifactId>vboxjws</artifactId>
<version>${test.virtualbox.api-version}</version>
<version>${virtualbox.version}</version>
</dependency>
<dependency>
<groupId>org.jclouds.api</groupId>
Expand All @@ -86,6 +87,11 @@
<artifactId>jclouds-slf4j</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jclouds</groupId>
<artifactId>jclouds-core</artifactId>
Expand All @@ -100,11 +106,6 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.jclouds.virtualbox;

import org.virtualbox_4_1.VirtualBoxManager;
import org.virtualbox_4_2.VirtualBoxManager;

public class VirtualBox {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@

import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_DEFAULT_DIR;
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_GUEST_MEMORY;
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGES_DESCRIPTOR;
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_INSTALLATION_KEY_SEQUENCE;
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_PRECONFIGURATION_URL;
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_WORKINGDIR;
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_GUEST_MEMORY;


import java.io.File;
import java.net.URI;
Expand Down Expand Up @@ -65,23 +64,24 @@ public static Properties defaultProperties() {

properties.put(VIRTUALBOX_INSTALLATION_KEY_SEQUENCE, "<Esc><Esc><Enter> "
+ "/install/vmlinuz noapic preseed/url=PRECONFIGURATION_URL "
+ "debian-installer=en_US auto locale=en_US kbd-chooser/method=us " + "hostname=" + "HOSTNAME "
+ "debian-installer=en_US auto locale=en_US kbd-chooser/method=us "
+ "hostname=" + "HOSTNAME "
+ "fb=false debconf/frontend=noninteractive "
+ "keyboard-configuration/layout=USA keyboard-configuration/variant=USA console-setup/ask_detect=false "
+ "console-setup/ask_detect=false keyboard-configuration/layoutcode=us "
+ "initrd=/install/initrd.gz -- <Enter>");

String workingDir = System.getProperty("test.virtualbox.workingDir", VIRTUALBOX_DEFAULT_DIR);
properties.put(VIRTUALBOX_WORKINGDIR, workingDir);

String ram = System.getProperty(VIRTUALBOX_GUEST_MEMORY, "1024");
String ram = System.getProperty(VIRTUALBOX_GUEST_MEMORY, "512");
properties.put(VIRTUALBOX_GUEST_MEMORY, ram);

String yamlDescriptor = System.getProperty("test.virtualbox.image.descriptor.yaml", VIRTUALBOX_WORKINGDIR
+ File.separator + "images.yaml");

properties.put(VIRTUALBOX_IMAGES_DESCRIPTOR, yamlDescriptor);
properties.put(VIRTUALBOX_PRECONFIGURATION_URL, "http://10.0.2.2:23232/preseed.cfg");
properties.setProperty(TEMPLATE, "osFamily=UBUNTU,osVersionMatches=12.04.1,os64Bit=true,osArchMatches=amd64");
properties.setProperty(TEMPLATE, "osFamily=UBUNTU,osVersionMatches=12.04.1,os64Bit=true,osArchMatches=amd64");
return properties;
}

Expand All @@ -96,10 +96,9 @@ protected Builder() {
.defaultIdentity(System.getProperty("user.name"))
.defaultCredential("CHANGE_ME")
.defaultEndpoint("http://localhost:18083/")
.documentation(URI.create("https://github.com/jclouds/jclouds/tree/master/apis/byon"))
// later version not in maven, yet
.version("4.1.4")
.buildVersion("4.1.8r75467")
.documentation(URI.create("https://github.com/jclouds/jclouds/tree/master/labs/virtualbox"))
.version("4.2.4")
.buildVersion("4.2.4")
.defaultProperties(VirtualBoxApiMetadata.defaultProperties())
.view(ComputeServiceContext.class)
.defaultModules(ImmutableSet.<Class<? extends Module>>of(HardcodeLocalhostAsNodeMetadataSupplier.class, VirtualBoxComputeServiceContextModule.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@

import org.jclouds.byon.Node;
import org.jclouds.compute.domain.OsFamily;
import org.virtualbox_4_1.IGuestOSType;
import org.virtualbox_4_1.IMachine;
import org.virtualbox_4_1.VirtualBoxManager;
import org.virtualbox_4_2.IGuestOSType;
import org.virtualbox_4_2.IMachine;
import org.virtualbox_4_2.VirtualBoxManager;

import com.google.common.base.Function;
import com.google.common.cache.CacheLoader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@
import org.jclouds.virtualbox.domain.YamlImage;
import org.jclouds.virtualbox.functions.admin.UnregisterMachineIfExistsAndForceDeleteItsMedia;
import org.jclouds.virtualbox.util.MachineController;
import org.virtualbox_4_1.IMachine;
import org.virtualbox_4_1.IProgress;
import org.virtualbox_4_1.ISession;
import org.virtualbox_4_1.MachineState;
import org.virtualbox_4_1.VBoxException;
import org.virtualbox_4_1.VirtualBoxManager;
import org.virtualbox_4_2.IMachine;
import org.virtualbox_4_2.IProgress;
import org.virtualbox_4_2.ISession;
import org.virtualbox_4_2.MachineState;
import org.virtualbox_4_2.VBoxException;
import org.virtualbox_4_2.VirtualBoxManager;

import com.google.common.base.Function;
import com.google.common.base.Predicate;
Expand Down Expand Up @@ -90,7 +90,7 @@ public VirtualBoxComputeServiceAdapter(Supplier<VirtualBoxManager> manager,
Function<NodeSpec, NodeAndInitialCredentials<IMachine>> cloneCreator,
Function<IMachine, Image> imachineToImage,
MachineController machineController) {
this.manager = checkNotNull(manager, "manager");
this.manager = checkNotNull(manager, "virtualbox manager can't be null");
this.imagesToYamlImages = imagesMapper.get();
this.mastersLoader = mastersLoader;
this.cloneCreator = cloneCreator;
Expand Down Expand Up @@ -254,10 +254,10 @@ private void powerDownMachine(IMachine machine) {
logger.debug("vm was already powered down: ", machine.getId());
return;
}
logger.debug("powering down vm: %s", machine.getName());
logger.debug("<< powering down vm(%s)", machine.getName());
machineController.ensureMachineHasPowerDown(machine.getName());
} catch (Exception e) {
logger.error(e, "problem in powering down the %s", machine.getName());
logger.error(e, "problem in powering down vm(%s)", machine.getName());
throw Throwables.propagate(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,18 @@
import org.jclouds.virtualbox.functions.TakeSnapshotIfNotAlreadyAttached;
import org.jclouds.virtualbox.functions.admin.UnregisterMachineIfExistsAndDeleteItsMedia;
import org.jclouds.virtualbox.util.MachineUtils;
import org.virtualbox_4_1.CloneMode;
import org.virtualbox_4_1.CloneOptions;
import org.virtualbox_4_1.IMachine;
import org.virtualbox_4_1.IProgress;
import org.virtualbox_4_1.ISnapshot;
import org.virtualbox_4_1.VirtualBoxManager;
import org.virtualbox_4_2.CloneMode;
import org.virtualbox_4_2.CloneOptions;
import org.virtualbox_4_2.IMachine;
import org.virtualbox_4_2.IProgress;
import org.virtualbox_4_2.ISnapshot;
import org.virtualbox_4_2.VirtualBoxManager;

import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.Futures;
Expand Down Expand Up @@ -118,9 +119,12 @@ public ListenableFuture<Image> createImage(ImageTemplate template) {

IMachine source = manager.get().getVBox().findMachine(cloneTemplate.getSourceNodeId());

String settingsFile = manager.get().getVBox().composeMachineFilename(template.getName(), workingDir);
String flags = "";
List<String> groups = ImmutableList.of();
String group = "";
String settingsFile = manager.get().getVBox().composeMachineFilename(template.getName(), group , flags , workingDir);
IMachine clonedMachine = manager.get().getVBox()
.createMachine(settingsFile, template.getName(), source.getOSTypeId(), template.getName(), true);
.createMachine(settingsFile, template.getName(), groups, source.getOSTypeId(), flags);

List<CloneOptions> options = Lists.newArrayList();
if (isLinkedClone)
Expand All @@ -136,7 +140,7 @@ public ListenableFuture<Image> createImage(ImageTemplate template) {
IProgress progress = currentSnapshot.getMachine().cloneTo(clonedMachine, CloneMode.MachineState, options);
progress.waitForCompletion(-1);

logger.debug(String.format("Machine %s is cloned correctly", clonedMachine.getName()));
logger.debug(String.format("<< master(%s) is cloned correctly to vm(%s)", source.getName(), clonedMachine.getName()));

// registering
manager.get().getVBox().registerMachine(clonedMachine);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@
import org.jclouds.virtualbox.functions.admin.PreseedCfgServer;
import org.jclouds.virtualbox.functions.admin.StartVBoxIfNotAlreadyRunning;
import org.jclouds.virtualbox.predicates.SshResponds;
import org.virtualbox_4_1.IMachine;
import org.virtualbox_4_1.LockType;
import org.virtualbox_4_1.MachineState;
import org.virtualbox_4_1.VirtualBoxManager;
import org.virtualbox_4_2.IMachine;
import org.virtualbox_4_2.LockType;
import org.virtualbox_4_2.MachineState;
import org.virtualbox_4_2.VirtualBoxManager;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
Expand Down Expand Up @@ -104,15 +104,15 @@ protected void configure() {
bind(new TypeLiteral<Function<IMachine, Image>>() {
}).to(IMachineToImage.class);
bind(new TypeLiteral<CacheLoader<IsoSpec, URI>>() {
}).to((Class) PreseedCfgServer.class);
}).to(Class.class.cast(PreseedCfgServer.class));
bind(new TypeLiteral<Function<URI, File>>() {
}).to((Class) FileDownloadFromURI.class);
}).to(Class.class.cast(FileDownloadFromURI.class));

bind(new TypeLiteral<Supplier<VirtualBoxManager>>() {
}).to((Class) StartVBoxIfNotAlreadyRunning.class);
}).to(Class.class.cast(StartVBoxIfNotAlreadyRunning.class));
// the yaml config to image mapper
bind(new TypeLiteral<Supplier<Map<Image, YamlImage>>>() {
}).to((Class) ImagesToYamlImagesFromYamlDescriptor.class);
}).to(Class.class.cast(ImagesToYamlImagesFromYamlDescriptor.class));
// the yaml config provider
bind(YamlImagesFromFileConfig.class);

Expand All @@ -126,15 +126,15 @@ protected void configure() {

// the master creating function
bind(new TypeLiteral<Function<MasterSpec, IMachine>>() {
}).to((Class) CreateAndInstallVm.class);
}).to(Class.class.cast(CreateAndInstallVm.class));
// the machine cloning function
bind(new TypeLiteral<Function<NodeSpec, NodeAndInitialCredentials<IMachine>>>() {
}).to((Class) NodeCreator.class);
}).to(Class.class.cast(NodeCreator.class));
bind(new TypeLiteral<Function<CloneSpec, IMachine>>() {
}).to((Class) CloneAndRegisterMachineFromIMachineIfNotAlreadyExists.class);
}).to(Class.class.cast(CloneAndRegisterMachineFromIMachineIfNotAlreadyExists.class));
// the jetty server provider
bind(new TypeLiteral<Server>() {
}).to((Class) PreseedCfgServer.class).asEagerSingleton();
}).to(Class.class.cast(PreseedCfgServer.class)).asEagerSingleton();

bind(new TypeLiteral<Function<IMachine, SshClient>>() {
}).to(IMachineToSshClient.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ public BridgedIf build() {
public BridgedIf(String name, String guid, String dhcp, String ipAddress,
String networkMask, String ipv6Address, String iv6NetworkMask,
String mediumType, String status) {
this.name = checkNotNull(name, "bridgedIf name");
this.name = checkNotNull(name, "bridgedIf name can't be null");
this.guid = guid;
this.dhcp = dhcp;
this.ipAddress = checkNotNull(ipAddress, "bridgedIf ipAddress");
this.ipAddress = checkNotNull(ipAddress, "bridgedIf ipAddress can't be null");
this.networkMask = networkMask;
this.ipv6Address = ipv6Address;
this.ipv6NetworkMask = iv6NetworkMask;
this.mediumType = mediumType;
this.status = checkNotNull(status, "bridgedIf status");
this.status = checkNotNull(status, "bridgedIf status can't be null");
}

public String getName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import static com.google.common.base.Preconditions.checkNotNull;

import org.virtualbox_4_1.IMachine;
import org.virtualbox_4_2.IMachine;

import com.google.common.base.Objects;

Expand Down Expand Up @@ -74,12 +74,9 @@ public CloneSpec build() {
}

public CloneSpec(VmSpec vmSpec, NetworkSpec networkSpec, IMachine master, boolean isLinked) {
checkNotNull(vmSpec, "vmSpec");
checkNotNull(networkSpec, "networkSpec");
checkNotNull(master, "master");
this.vmSpec = vmSpec;
this.networkSpec = networkSpec;
this.master = master;
this.vmSpec = checkNotNull(vmSpec, "vmSpec can't be null");
this.networkSpec = checkNotNull(networkSpec, "networkSpec can't be null");
this.master = checkNotNull(master, "master can't be null");
this.isLinked = isLinked;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import static com.google.common.base.Preconditions.checkNotNull;

import org.virtualbox_4_1.DeviceType;
import org.virtualbox_4_2.DeviceType;

import com.google.common.base.Objects;

Expand All @@ -43,10 +43,9 @@ public class DeviceDetails {
private final DeviceType deviceType;

public DeviceDetails(int port, int deviceSlot, DeviceType deviceType) {
checkNotNull(deviceType, "deviceType");
this.port = port;
this.deviceSlot = deviceSlot;
this.deviceType = deviceType;
this.deviceType = checkNotNull(deviceType, "deviceType can't be null");
}

public int getPort() {
Expand Down Expand Up @@ -87,7 +86,7 @@ public Builder deviceSlot(int slot) {
}

public DeviceDetails build() {
checkNotNull(deviceType, "deviceType");
checkNotNull(deviceType, "deviceType can't be null");
return new DeviceDetails(port, deviceSlot, deviceType);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

import java.util.Map;

import org.virtualbox_4_1.VBoxException;
import org.virtualbox_4_1.jaxws.RuntimeFaultMsg;
import org.virtualbox_4_2.VBoxException;
import org.virtualbox_4_2.jaxws.RuntimeFaultMsg;

import com.google.common.collect.ImmutableMap;

Expand Down Expand Up @@ -76,7 +76,7 @@ public enum ErrorCode {
this.code = code;
}

private static final Map<Long, ErrorCode> TABLE;
private final static Map<Long, ErrorCode> TABLE;
static {
ImmutableMap.Builder<Long, ErrorCode> builder = ImmutableMap.builder();
for (ErrorCode errorCode : ErrorCode.values()) {
Expand Down
Loading

0 comments on commit ac0e5f5

Please sign in to comment.