mirror of https://github.com/apache/jclouds.git
formatting in virtualbox
This commit is contained in:
parent
71ac2b89e1
commit
d300681bcc
|
@ -19,13 +19,15 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox;
|
package org.jclouds.virtualbox;
|
||||||
|
|
||||||
import org.jclouds.PropertiesBuilder;
|
import static org.jclouds.Constants.PROPERTY_CREDENTIAL;
|
||||||
import org.jclouds.virtualbox.config.VirtualBoxConstants;
|
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||||
|
import static org.jclouds.Constants.PROPERTY_IDENTITY;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import static org.jclouds.Constants.*;
|
import org.jclouds.PropertiesBuilder;
|
||||||
|
import org.jclouds.virtualbox.config.VirtualBoxConstants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds properties for VirtualBox integration.
|
* Builds properties for VirtualBox integration.
|
||||||
|
@ -51,7 +53,9 @@ public class VirtualBoxPropertiesBuilder extends PropertiesBuilder {
|
||||||
properties.put(VirtualBoxConstants.VIRTUALBOX_PRESEED_URL, "http://dl.dropbox.com/u/693111/preseed.cfg");
|
properties.put(VirtualBoxConstants.VIRTUALBOX_PRESEED_URL, "http://dl.dropbox.com/u/693111/preseed.cfg");
|
||||||
properties.put(VirtualBoxConstants.VIRTUALBOX_SNAPSHOT_DESCRIPTION, "jclouds-virtualbox-snaphot");
|
properties.put(VirtualBoxConstants.VIRTUALBOX_SNAPSHOT_DESCRIPTION, "jclouds-virtualbox-snaphot");
|
||||||
properties.put(VirtualBoxConstants.VIRTUALBOX_HOSTNAME, "jclouds-virtualbox-kickstart-admin");
|
properties.put(VirtualBoxConstants.VIRTUALBOX_HOSTNAME, "jclouds-virtualbox-kickstart-admin");
|
||||||
properties.put(VirtualBoxConstants.VIRTUALBOX_INSTALLATION_KEY_SEQUENCE, "<Esc><Esc><Enter> "
|
properties
|
||||||
|
.put(VirtualBoxConstants.VIRTUALBOX_INSTALLATION_KEY_SEQUENCE,
|
||||||
|
"<Esc><Esc><Enter> "
|
||||||
+ "/install/vmlinuz noapic preseed/url=http://10.0.2.2:8080/src/test/resources/preseed.cfg "
|
+ "/install/vmlinuz noapic preseed/url=http://10.0.2.2:8080/src/test/resources/preseed.cfg "
|
||||||
+ "debian-installer=en_US auto locale=en_US kbd-chooser/method=us "
|
+ "debian-installer=en_US auto locale=en_US kbd-chooser/method=us "
|
||||||
+ "hostname="
|
+ "hostname="
|
||||||
|
@ -61,10 +65,8 @@ public class VirtualBoxPropertiesBuilder extends PropertiesBuilder {
|
||||||
+ "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>");
|
||||||
|
|
||||||
properties.put(VirtualBoxConstants.VIRTUALBOX_WORKINGDIR, System.getProperty("user.home")
|
properties.put(VirtualBoxConstants.VIRTUALBOX_WORKINGDIR, System.getProperty("user.home") + File.separator
|
||||||
+ File.separator
|
+ System.getProperty("test.virtualbox.workingDir", "jclouds-virtualbox-test"));
|
||||||
+ System.getProperty("test.virtualbox.workingDir",
|
|
||||||
"jclouds-virtualbox-test"));
|
|
||||||
|
|
||||||
// TODO: Add more properties and use the wired properties from test code.
|
// TODO: Add more properties and use the wired properties from test code.
|
||||||
properties.put(VirtualBoxConstants.VIRTUALBOX_DISTRO_ISO_NAME, "ubuntu-11.04-server-i386.iso");
|
properties.put(VirtualBoxConstants.VIRTUALBOX_DISTRO_ISO_NAME, "ubuntu-11.04-server-i386.iso");
|
||||||
|
|
|
@ -19,19 +19,24 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.compute;
|
package org.jclouds.virtualbox.compute;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_MACHINE_CREDENTIAL;
|
||||||
import com.google.common.cache.CacheLoader;
|
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_MACHINE_GROUP;
|
||||||
|
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_MACHINE_LOCATION;
|
||||||
|
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_MACHINE_USERNAME;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.byon.Node;
|
import org.jclouds.byon.Node;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.virtualbox_4_1.IGuestOSType;
|
import org.virtualbox_4_1.IGuestOSType;
|
||||||
import org.virtualbox_4_1.IMachine;
|
import org.virtualbox_4_1.IMachine;
|
||||||
import org.virtualbox_4_1.VirtualBoxManager;
|
import org.virtualbox_4_1.VirtualBoxManager;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import com.google.common.base.Function;
|
||||||
import java.net.URI;
|
import com.google.common.cache.CacheLoader;
|
||||||
import java.net.URISyntaxException;
|
|
||||||
|
|
||||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a node from a VirtualBox IMachine
|
* Loads a node from a VirtualBox IMachine
|
||||||
|
@ -53,16 +58,10 @@ public class LoadMachineFromVirtualBox extends CacheLoader<String, Node> {
|
||||||
public Node load(final String id) throws Exception {
|
public Node load(final String id) throws Exception {
|
||||||
|
|
||||||
if (id.equals("host")) {
|
if (id.equals("host")) {
|
||||||
final Node hostNode = Node.builder().id("host")
|
final Node hostNode = Node.builder().id("host").name("host installing virtualbox").hostname("localhost")
|
||||||
.name("host installing virtualbox")
|
.osFamily(OsFamily.LINUX.toString()).osDescription(System.getProperty("os.name"))
|
||||||
.hostname("localhost")
|
.osVersion(System.getProperty("os.version")).group("ssh").username(System.getProperty("user.name"))
|
||||||
.osFamily(OsFamily.LINUX.toString())
|
.credentialUrl(privateKeyFile()).build();
|
||||||
.osDescription(System.getProperty("os.name"))
|
|
||||||
.osVersion(System.getProperty("os.version"))
|
|
||||||
.group("ssh")
|
|
||||||
.username(System.getProperty("user.name"))
|
|
||||||
.credentialUrl(privateKeyFile())
|
|
||||||
.build();
|
|
||||||
return hostNode;
|
return hostNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,23 +70,14 @@ public class LoadMachineFromVirtualBox extends CacheLoader<String, Node> {
|
||||||
final String osTypeId = machine.getOSTypeId();
|
final String osTypeId = machine.getOSTypeId();
|
||||||
final IGuestOSType guestOSType = manager.getVBox().getGuestOSType(osTypeId);
|
final IGuestOSType guestOSType = manager.getVBox().getGuestOSType(osTypeId);
|
||||||
|
|
||||||
final Node node = Node.builder()
|
final Node node = Node.builder().id(machine.getId()).name(machine.getName())
|
||||||
.id(machine.getId())
|
.description(machine.getDescription()).loginPort(22).group(System.getProperty(VIRTUALBOX_MACHINE_GROUP))
|
||||||
.name(machine.getName())
|
|
||||||
.description(machine.getDescription())
|
|
||||||
.loginPort(22)
|
|
||||||
.group(System.getProperty(VIRTUALBOX_MACHINE_GROUP))
|
|
||||||
.username(System.getProperty(VIRTUALBOX_MACHINE_USERNAME))
|
.username(System.getProperty(VIRTUALBOX_MACHINE_USERNAME))
|
||||||
.credential(System.getProperty(VIRTUALBOX_MACHINE_CREDENTIAL))
|
.credential(System.getProperty(VIRTUALBOX_MACHINE_CREDENTIAL))
|
||||||
.sudoPassword(System.getProperty(VIRTUALBOX_MACHINE_CREDENTIAL))
|
.sudoPassword(System.getProperty(VIRTUALBOX_MACHINE_CREDENTIAL))
|
||||||
.locationId(System.getProperty(VIRTUALBOX_MACHINE_LOCATION))
|
.locationId(System.getProperty(VIRTUALBOX_MACHINE_LOCATION)).os64Bit(guestOSType.getIs64Bit())
|
||||||
.os64Bit(guestOSType.getIs64Bit())
|
.osArch(guestOSType.getDescription()).osFamily(guestOSType.getFamilyDescription())
|
||||||
.osArch(guestOSType.getDescription())
|
.osVersion(guestOSType.getId()).osDescription(guestOSType.getDescription()).hostname(ipAddress).build();
|
||||||
.osFamily(guestOSType.getFamilyDescription())
|
|
||||||
.osVersion(guestOSType.getId())
|
|
||||||
.osDescription(guestOSType.getDescription())
|
|
||||||
.hostname(ipAddress)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
|
|
||||||
|
|
|
@ -19,10 +19,16 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.compute;
|
package org.jclouds.virtualbox.compute;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import com.google.common.base.Predicate;
|
import static com.google.common.collect.Iterables.filter;
|
||||||
import com.google.common.base.Throwables;
|
import static com.google.common.collect.Iterables.transform;
|
||||||
import com.google.inject.Singleton;
|
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGE_PREFIX;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.compute.ComputeServiceAdapter;
|
import org.jclouds.compute.ComputeServiceAdapter;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.Template;
|
import org.jclouds.compute.domain.Template;
|
||||||
|
@ -30,15 +36,17 @@ import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
import org.jclouds.location.suppliers.JustProvider;
|
import org.jclouds.location.suppliers.JustProvider;
|
||||||
import org.virtualbox_4_1.*;
|
import org.virtualbox_4_1.CleanupMode;
|
||||||
|
import org.virtualbox_4_1.IMachine;
|
||||||
|
import org.virtualbox_4_1.IProgress;
|
||||||
|
import org.virtualbox_4_1.ISession;
|
||||||
|
import org.virtualbox_4_1.SessionState;
|
||||||
|
import org.virtualbox_4_1.VirtualBoxManager;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import com.google.common.base.Function;
|
||||||
import java.util.*;
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.base.Throwables;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import com.google.inject.Singleton;
|
||||||
import static com.google.common.collect.Iterables.filter;
|
|
||||||
import static com.google.common.collect.Iterables.transform;
|
|
||||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGE_PREFIX;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the connection between the
|
* Defines the connection between the
|
||||||
|
@ -55,7 +63,8 @@ public class VirtualBoxComputeServiceAdapter implements ComputeServiceAdapter<IM
|
||||||
private Function<IMachine, Image> iMachineToImage;
|
private Function<IMachine, Image> iMachineToImage;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public VirtualBoxComputeServiceAdapter(VirtualBoxManager manager, JustProvider justProvider, Function<IMachine, Image> iMachineToImage) {
|
public VirtualBoxComputeServiceAdapter(VirtualBoxManager manager, JustProvider justProvider,
|
||||||
|
Function<IMachine, Image> iMachineToImage) {
|
||||||
this.iMachineToImage = iMachineToImage;
|
this.iMachineToImage = iMachineToImage;
|
||||||
this.manager = checkNotNull(manager, "manager");
|
this.manager = checkNotNull(manager, "manager");
|
||||||
this.justProvider = checkNotNull(justProvider, "justProvider");
|
this.justProvider = checkNotNull(justProvider, "justProvider");
|
||||||
|
|
|
@ -57,7 +57,8 @@ import com.google.inject.TypeLiteral;
|
||||||
/**
|
/**
|
||||||
* @author Mattias Holmqvist, Andrea Turli
|
* @author Mattias Holmqvist, Andrea Turli
|
||||||
*/
|
*/
|
||||||
public class VirtualBoxComputeServiceContextModule extends ComputeServiceAdapterContextModule<VirtualBoxManager, VirtualBoxManager, IMachine, IMachine, Image, Location> {
|
public class VirtualBoxComputeServiceContextModule extends
|
||||||
|
ComputeServiceAdapterContextModule<VirtualBoxManager, VirtualBoxManager, IMachine, IMachine, Image, Location> {
|
||||||
|
|
||||||
public VirtualBoxComputeServiceContextModule() {
|
public VirtualBoxComputeServiceContextModule() {
|
||||||
super(VirtualBoxManager.class, VirtualBoxManager.class);
|
super(VirtualBoxManager.class, VirtualBoxManager.class);
|
||||||
|
@ -65,8 +66,8 @@ public class VirtualBoxComputeServiceContextModule extends ComputeServiceAdapter
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected VirtualBoxManager createInstance(@Provider URI endpoint, @Named(Constants.PROPERTY_IDENTITY) String identity,
|
protected VirtualBoxManager createInstance(@Provider URI endpoint,
|
||||||
@Named(Constants.PROPERTY_CREDENTIAL) String credential) {
|
@Named(Constants.PROPERTY_IDENTITY) String identity, @Named(Constants.PROPERTY_CREDENTIAL) String credential) {
|
||||||
|
|
||||||
VirtualBoxManager manager = VirtualBoxManager.createInstance("");
|
VirtualBoxManager manager = VirtualBoxManager.createInstance("");
|
||||||
manager.connect(endpoint.toASCIIString(), identity, credential);
|
manager.connect(endpoint.toASCIIString(), identity, credential);
|
||||||
|
@ -100,10 +101,8 @@ public class VirtualBoxComputeServiceContextModule extends ComputeServiceAdapter
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public static final Map<MachineState, NodeState> machineToNodeState = ImmutableMap
|
public static final Map<MachineState, NodeState> machineToNodeState = ImmutableMap
|
||||||
.<MachineState, NodeState>builder()
|
.<MachineState, NodeState> builder().put(MachineState.Running, NodeState.RUNNING)
|
||||||
.put(MachineState.Running, NodeState.RUNNING)
|
.put(MachineState.PoweredOff, NodeState.SUSPENDED).put(MachineState.DeletingSnapshot, NodeState.PENDING)
|
||||||
.put(MachineState.PoweredOff, NodeState.SUSPENDED)
|
|
||||||
.put(MachineState.DeletingSnapshot, NodeState.PENDING)
|
|
||||||
.put(MachineState.DeletingSnapshotOnline, NodeState.PENDING)
|
.put(MachineState.DeletingSnapshotOnline, NodeState.PENDING)
|
||||||
.put(MachineState.DeletingSnapshotPaused, NodeState.PENDING)
|
.put(MachineState.DeletingSnapshotPaused, NodeState.PENDING)
|
||||||
.put(MachineState.FaultTolerantSyncing, NodeState.PENDING)
|
.put(MachineState.FaultTolerantSyncing, NodeState.PENDING)
|
||||||
|
@ -113,17 +112,12 @@ public class VirtualBoxComputeServiceContextModule extends ComputeServiceAdapter
|
||||||
.put(MachineState.Stopping, NodeState.PENDING)
|
.put(MachineState.Stopping, NodeState.PENDING)
|
||||||
.put(MachineState.Restoring, NodeState.PENDING)
|
.put(MachineState.Restoring, NodeState.PENDING)
|
||||||
// TODO What to map these states to?
|
// TODO What to map these states to?
|
||||||
.put(MachineState.FirstOnline, NodeState.PENDING)
|
.put(MachineState.FirstOnline, NodeState.PENDING).put(MachineState.FirstTransient, NodeState.PENDING)
|
||||||
.put(MachineState.FirstTransient, NodeState.PENDING)
|
.put(MachineState.LastOnline, NodeState.PENDING).put(MachineState.LastTransient, NodeState.PENDING)
|
||||||
.put(MachineState.LastOnline, NodeState.PENDING)
|
.put(MachineState.Teleported, NodeState.PENDING).put(MachineState.TeleportingIn, NodeState.PENDING)
|
||||||
.put(MachineState.LastTransient, NodeState.PENDING)
|
|
||||||
.put(MachineState.Teleported, NodeState.PENDING)
|
|
||||||
.put(MachineState.TeleportingIn, NodeState.PENDING)
|
|
||||||
.put(MachineState.TeleportingPausedVM, NodeState.PENDING)
|
.put(MachineState.TeleportingPausedVM, NodeState.PENDING)
|
||||||
|
|
||||||
|
.put(MachineState.Aborted, NodeState.ERROR).put(MachineState.Stuck, NodeState.ERROR)
|
||||||
.put(MachineState.Aborted, NodeState.ERROR)
|
|
||||||
.put(MachineState.Stuck, NodeState.ERROR)
|
|
||||||
|
|
||||||
.put(MachineState.Null, NodeState.UNRECOGNIZED).build();
|
.put(MachineState.Null, NodeState.UNRECOGNIZED).build();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/**
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -19,17 +19,18 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.domain;
|
package org.jclouds.virtualbox.domain;
|
||||||
|
|
||||||
import org.virtualbox_4_1.VBoxException;
|
|
||||||
import org.virtualbox_4_1.jaxws.RuntimeFaultMsg;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.virtualbox_4_1.VBoxException;
|
||||||
|
import org.virtualbox_4_1.jaxws.RuntimeFaultMsg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps the error codes in the Virtual Box Java API into enum values.
|
* Maps the error codes in the Virtual Box Java API into enum values.
|
||||||
* <p/>
|
* <p/>
|
||||||
* <p/>
|
* <p/>
|
||||||
* To get the error code from a VBoxException, use:
|
* To get the error code from a VBoxException, use:
|
||||||
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* try {
|
* try {
|
||||||
* ...
|
* ...
|
||||||
|
@ -46,27 +47,12 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public enum ErrorCode {
|
public enum ErrorCode {
|
||||||
|
|
||||||
VBOX_E_OBJECT_NOT_FOUND(2159738881L),
|
VBOX_E_OBJECT_NOT_FOUND(2159738881L), VBOX_E_INVALID_VM_STATE(2159738882L), VBOX_E_VM_ERROR(2159738883L), VBOX_E_FILE_ERROR(
|
||||||
VBOX_E_INVALID_VM_STATE(2159738882L),
|
2159738884L), VBOX_E_IPRT_ERROR(2159738885L), VBOX_E_PDM_ERROR(2159738886L), VBOX_E_INVALID_OBJECT_STATE(
|
||||||
VBOX_E_VM_ERROR(2159738883L),
|
2159738887L), VBOX_E_HOST_ERROR(2159738888L), VBOX_E_NOT_SUPPORTED(2159738889L), VBOX_E_XML_ERROR(2159738890L), VBOX_E_INVALID_SESSION_STATE(
|
||||||
VBOX_E_FILE_ERROR(2159738884L),
|
2159738891L), VBOX_E_OBJECT_IN_USE(2159738892L), VBOX_E_ACCESSDENIED(2147942405L), VBOX_E_POINTER(2147500035L), VBOX_E_FAIL(
|
||||||
VBOX_E_IPRT_ERROR(2159738885L),
|
2147500037L), VBOX_E_NOTIMPL(2147500033L), VBOX_E_OUTOFMEMORY(2147942414L), VBOX_E_INVALIDARG(2147942487L), VBOX_E_UNEXPECTED(
|
||||||
VBOX_E_PDM_ERROR(2159738886L),
|
2147549183L), VBOX_E_UNKNOWN_ERROR_CODE(-1L), VBOX_E_ERROR_CODE_UNAVAILABLE(-2L);
|
||||||
VBOX_E_INVALID_OBJECT_STATE(2159738887L),
|
|
||||||
VBOX_E_HOST_ERROR(2159738888L),
|
|
||||||
VBOX_E_NOT_SUPPORTED(2159738889L),
|
|
||||||
VBOX_E_XML_ERROR(2159738890L),
|
|
||||||
VBOX_E_INVALID_SESSION_STATE(2159738891L),
|
|
||||||
VBOX_E_OBJECT_IN_USE(2159738892L),
|
|
||||||
VBOX_E_ACCESSDENIED(2147942405L),
|
|
||||||
VBOX_E_POINTER(2147500035L),
|
|
||||||
VBOX_E_FAIL(2147500037L),
|
|
||||||
VBOX_E_NOTIMPL(2147500033L),
|
|
||||||
VBOX_E_OUTOFMEMORY(2147942414L),
|
|
||||||
VBOX_E_INVALIDARG(2147942487L),
|
|
||||||
VBOX_E_UNEXPECTED(2147549183L),
|
|
||||||
VBOX_E_UNKNOWN_ERROR_CODE(-1L),
|
|
||||||
VBOX_E_ERROR_CODE_UNAVAILABLE(-2L);
|
|
||||||
|
|
||||||
private long code;
|
private long code;
|
||||||
|
|
||||||
|
@ -85,7 +71,8 @@ public enum ErrorCode {
|
||||||
/**
|
/**
|
||||||
* Returns an ErrorCode from the fault code given by the VirtualBox API.
|
* Returns an ErrorCode from the fault code given by the VirtualBox API.
|
||||||
*
|
*
|
||||||
* @param vboxException the exception to get the error code from.
|
* @param vboxException
|
||||||
|
* the exception to get the error code from.
|
||||||
* @return an ErrorCode representing the given fault code.
|
* @return an ErrorCode representing the given fault code.
|
||||||
*/
|
*/
|
||||||
public static ErrorCode valueOf(VBoxException vboxException) {
|
public static ErrorCode valueOf(VBoxException vboxException) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/**
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -21,10 +21,7 @@ package org.jclouds.virtualbox.domain;
|
||||||
|
|
||||||
public enum ExecutionType {
|
public enum ExecutionType {
|
||||||
|
|
||||||
GUI("gui"),
|
GUI("gui"), HEADLESS("headless"), SDL("sdl"), EMERGENCYSTOP("emergencystop");
|
||||||
HEADLESS("headless"),
|
|
||||||
SDL("sdl"),
|
|
||||||
EMERGENCYSTOP("emergencystop");
|
|
||||||
|
|
||||||
private final String type;
|
private final String type;
|
||||||
|
|
||||||
|
|
|
@ -41,73 +41,73 @@ import com.google.common.collect.Maps;
|
||||||
* Serializes to the following
|
* Serializes to the following
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
id: myTestId
|
* id: myTestId
|
||||||
name: ubuntu-11.04-server-i386
|
* name: ubuntu-11.04-server-i386
|
||||||
description: ubuntu 11.04 server (i386)
|
* description: ubuntu 11.04 server (i386)
|
||||||
os_arch: x86
|
* os_arch: x86
|
||||||
os_family: linux
|
* os_family: linux
|
||||||
os_description: ubuntu
|
* os_description: ubuntu
|
||||||
os_version: 11.04
|
* os_version: 11.04
|
||||||
iso: http://releases.ubuntu.com/11.04/ubuntu-11.04-server-i386.iso
|
* iso: http://releases.ubuntu.com/11.04/ubuntu-11.04-server-i386.iso
|
||||||
keystroke_sequence: |
|
* keystroke_sequence: |
|
||||||
<Esc><Esc><Enter>
|
* <Esc><Esc><Enter>
|
||||||
/install/vmlinuz noapic preseed/url=http://10.0.2.2:8080/src/test/resources/preseed.cfg
|
* /install/vmlinuz noapic preseed/url=http://10.0.2.2:8080/src/test/resources/preseed.cfg
|
||||||
debian-installer=en_US auto locale=en_US kbd-chooser/method=us
|
* debian-installer=en_US auto locale=en_US kbd-chooser/method=us
|
||||||
hostname=vmName
|
* hostname=vmName
|
||||||
fb=false debconf/frontend=noninteractive
|
* fb=false debconf/frontend=noninteractive
|
||||||
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>
|
||||||
preseed_cfg: |
|
* preseed_cfg: |
|
||||||
## Options to set on the command line
|
* ## Options to set on the command line
|
||||||
d-i debian-installer/locale string en_US.utf8
|
* d-i debian-installer/locale string en_US.utf8
|
||||||
d-i console-setup/ask_detect boolean false
|
* d-i console-setup/ask_detect boolean false
|
||||||
d-i console-setup/layout string USA
|
* d-i console-setup/layout string USA
|
||||||
d-i netcfg/get_hostname string unassigned-hostname
|
* d-i netcfg/get_hostname string unassigned-hostname
|
||||||
d-i netcfg/get_domain string unassigned-domain
|
* d-i netcfg/get_domain string unassigned-domain
|
||||||
# Continue without a default route
|
* # Continue without a default route
|
||||||
# Not working , specify a dummy in the DHCP
|
* # Not working , specify a dummy in the DHCP
|
||||||
d-i time/zone string UTC
|
* d-i time/zone string UTC
|
||||||
d-i clock-setup/utc-auto boolean true
|
* d-i clock-setup/utc-auto boolean true
|
||||||
d-i clock-setup/utc boolean true
|
* d-i clock-setup/utc boolean true
|
||||||
d-i kbd-chooser/method select American English
|
* d-i kbd-chooser/method select American English
|
||||||
d-i netcfg/wireless_wep string
|
* d-i netcfg/wireless_wep string
|
||||||
d-i base-installer/kernel/override-image string linux-server
|
* d-i base-installer/kernel/override-image string linux-server
|
||||||
# Choices: Dialog, Readline, Gnome, Kde, Editor, Noninteractive
|
* # Choices: Dialog, Readline, Gnome, Kde, Editor, Noninteractive
|
||||||
d-i debconf debconf/frontend select Noninteractive
|
* d-i debconf debconf/frontend select Noninteractive
|
||||||
d-i pkgsel/install-language-support boolean false
|
* d-i pkgsel/install-language-support boolean false
|
||||||
tasksel tasksel/first multiselect standard, ubuntu-server
|
* tasksel tasksel/first multiselect standard, ubuntu-server
|
||||||
d-i partman-auto/method string lvm
|
* d-i partman-auto/method string lvm
|
||||||
d-i partman-lvm/confirm boolean true
|
* d-i partman-lvm/confirm boolean true
|
||||||
d-i partman-lvm/device_remove_lvm boolean true
|
* d-i partman-lvm/device_remove_lvm boolean true
|
||||||
d-i partman-auto/choose_recipe select atomic
|
* d-i partman-auto/choose_recipe select atomic
|
||||||
d-i partman/confirm_write_new_label boolean true
|
* d-i partman/confirm_write_new_label boolean true
|
||||||
d-i partman/confirm_nooverwrite boolean true
|
* d-i partman/confirm_nooverwrite boolean true
|
||||||
d-i partman/choose_partition select finish
|
* d-i partman/choose_partition select finish
|
||||||
d-i partman/confirm boolean true
|
* d-i partman/confirm boolean true
|
||||||
# Write the changes to disks and configure LVM?
|
* # Write the changes to disks and configure LVM?
|
||||||
d-i partman-lvm/confirm boolean true
|
* d-i partman-lvm/confirm boolean true
|
||||||
d-i partman-lvm/confirm_nooverwrite boolean true
|
* d-i partman-lvm/confirm_nooverwrite boolean true
|
||||||
d-i partman-auto-lvm/guided_size string max
|
* d-i partman-auto-lvm/guided_size string max
|
||||||
## Default user, we can get away with a recipe to change this
|
* ## Default user, we can get away with a recipe to change this
|
||||||
d-i passwd/user-fullname string toor
|
* d-i passwd/user-fullname string toor
|
||||||
d-i passwd/username string toor
|
* d-i passwd/username string toor
|
||||||
d-i passwd/user-password password password
|
* d-i passwd/user-password password password
|
||||||
d-i passwd/user-password-again password password
|
* d-i passwd/user-password-again password password
|
||||||
d-i user-setup/encrypt-home boolean false
|
* d-i user-setup/encrypt-home boolean false
|
||||||
d-i user-setup/allow-password-weak boolean true
|
* d-i user-setup/allow-password-weak boolean true
|
||||||
# Individual additional packages to install
|
* # Individual additional packages to install
|
||||||
d-i pkgsel/include string openssh-server ntp
|
* d-i pkgsel/include string openssh-server ntp
|
||||||
# Whether to upgrade packages after debootstrap.
|
* # Whether to upgrade packages after debootstrap.
|
||||||
# Allowed values: none, safe-upgrade, full-upgrade
|
* # Allowed values: none, safe-upgrade, full-upgrade
|
||||||
d-i pkgsel/upgrade select full-upgrade
|
* d-i pkgsel/upgrade select full-upgrade
|
||||||
d-i grub-installer/only_debian boolean true
|
* d-i grub-installer/only_debian boolean true
|
||||||
d-i grub-installer/with_other_os boolean true
|
* d-i grub-installer/with_other_os boolean true
|
||||||
d-i finish-install/reboot_in_progress note
|
* d-i finish-install/reboot_in_progress note
|
||||||
#For the update
|
* #For the update
|
||||||
d-i pkgsel/update-policy select none
|
* d-i pkgsel/update-policy select none
|
||||||
# debconf-get-selections --install
|
* # debconf-get-selections --install
|
||||||
#Use mirror
|
* #Use mirror
|
||||||
choose-mirror-bin mirror/http/proxy string
|
* choose-mirror-bin mirror/http/proxy string
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author Kelvin Kakugawa
|
* @author Kelvin Kakugawa
|
||||||
|
@ -143,14 +143,11 @@ public class YamlImage {
|
||||||
return null;
|
return null;
|
||||||
OsFamily family = parseOsFamilyOrUnrecognized(arg0.os_family);
|
OsFamily family = parseOsFamilyOrUnrecognized(arg0.os_family);
|
||||||
|
|
||||||
OperatingSystem operatingSystem = OperatingSystem.builder()
|
OperatingSystem operatingSystem = OperatingSystem.builder().description(arg0.os_description).family(family)
|
||||||
.description(arg0.os_description)
|
.version(arg0.os_version).is64Bit(arg0.os_64bit).build();
|
||||||
.family(family)
|
|
||||||
.version(arg0.os_version)
|
|
||||||
.is64Bit(arg0.os_64bit)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
return new ImageBuilder().id(arg0.id).name(arg0.name).description(arg0.description).operatingSystem(operatingSystem).build();
|
return new ImageBuilder().id(arg0.id).name(arg0.name).description(arg0.description)
|
||||||
|
.operatingSystem(operatingSystem).build();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.virtualbox.functions;
|
package org.jclouds.virtualbox.functions;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/**
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -19,10 +19,11 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.functions;
|
package org.jclouds.virtualbox.functions;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.virtualbox_4_1.IMachine;
|
import org.virtualbox_4_1.IMachine;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mattias Holmqvist
|
* @author Mattias Holmqvist
|
||||||
|
|
|
@ -19,13 +19,14 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.functions;
|
package org.jclouds.virtualbox.functions;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.virtualbox_4_1.DeviceType;
|
import org.virtualbox_4_1.DeviceType;
|
||||||
import org.virtualbox_4_1.IMachine;
|
import org.virtualbox_4_1.IMachine;
|
||||||
import org.virtualbox_4_1.IMedium;
|
import org.virtualbox_4_1.IMedium;
|
||||||
import org.virtualbox_4_1.VBoxException;
|
import org.virtualbox_4_1.VBoxException;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mattias Holmqvist
|
* @author Mattias Holmqvist
|
||||||
|
|
|
@ -19,12 +19,14 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.functions;
|
package org.jclouds.virtualbox.functions;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
import org.virtualbox_4_1.*;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import static org.virtualbox_4_1.DeviceType.HardDisk;
|
import org.virtualbox_4_1.DeviceType;
|
||||||
|
import org.virtualbox_4_1.IMachine;
|
||||||
|
import org.virtualbox_4_1.IMedium;
|
||||||
|
import org.virtualbox_4_1.VBoxException;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mattias Holmqvist
|
* @author Mattias Holmqvist
|
||||||
|
@ -37,7 +39,8 @@ public class AttachMediumToMachineIfNotAlreadyAttached implements Function<IMach
|
||||||
private int device;
|
private int device;
|
||||||
private DeviceType deviceType;
|
private DeviceType deviceType;
|
||||||
|
|
||||||
public AttachMediumToMachineIfNotAlreadyAttached(String controllerIDE, IMedium hardDisk, int controllerPort, int device, DeviceType deviceType) {
|
public AttachMediumToMachineIfNotAlreadyAttached(String controllerIDE, IMedium hardDisk, int controllerPort,
|
||||||
|
int device, DeviceType deviceType) {
|
||||||
this.controllerIDE = controllerIDE;
|
this.controllerIDE = controllerIDE;
|
||||||
this.hardDisk = hardDisk;
|
this.hardDisk = hardDisk;
|
||||||
this.controllerPort = controllerPort;
|
this.controllerPort = controllerPort;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/**
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -19,14 +19,15 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.functions;
|
package org.jclouds.virtualbox.functions;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import static org.virtualbox_4_1.NATProtocol.TCP;
|
||||||
import org.virtualbox_4_1.IMachine;
|
import static org.virtualbox_4_1.NetworkAttachmentType.NAT;
|
||||||
import org.virtualbox_4_1.INetworkAdapter;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import static org.virtualbox_4_1.NATProtocol.TCP;
|
import org.virtualbox_4_1.IMachine;
|
||||||
import static org.virtualbox_4_1.NetworkAttachmentType.NAT;
|
import org.virtualbox_4_1.INetworkAdapter;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mattias Holmqvist
|
* @author Mattias Holmqvist
|
||||||
|
|
|
@ -19,14 +19,14 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.functions;
|
package org.jclouds.virtualbox.functions;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
import org.virtualbox_4_1.IMachine;
|
import org.virtualbox_4_1.IMachine;
|
||||||
import org.virtualbox_4_1.IVirtualBox;
|
import org.virtualbox_4_1.IVirtualBox;
|
||||||
import org.virtualbox_4_1.VBoxException;
|
import org.virtualbox_4_1.VBoxException;
|
||||||
import org.virtualbox_4_1.VirtualBoxManager;
|
import org.virtualbox_4_1.VirtualBoxManager;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mattias Holmqvist
|
* @author Mattias Holmqvist
|
||||||
|
|
|
@ -19,11 +19,17 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.functions;
|
package org.jclouds.virtualbox.functions;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
import org.virtualbox_4_1.*;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.virtualbox_4_1.DeviceType;
|
||||||
|
import org.virtualbox_4_1.IMedium;
|
||||||
|
import org.virtualbox_4_1.IProgress;
|
||||||
|
import org.virtualbox_4_1.IVirtualBox;
|
||||||
|
import org.virtualbox_4_1.VBoxException;
|
||||||
|
import org.virtualbox_4_1.VirtualBoxManager;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mattias Holmqvist
|
* @author Mattias Holmqvist
|
||||||
*/
|
*/
|
||||||
|
@ -71,15 +77,18 @@ public class CreateMediumIfNotAlreadyExists implements Function<String, IMedium>
|
||||||
private void createBaseStorage(IMedium hardDisk) {
|
private void createBaseStorage(IMedium hardDisk) {
|
||||||
try {
|
try {
|
||||||
long size = 4L * 1024L * 1024L * 1024L - 4L;
|
long size = 4L * 1024L * 1024L * 1024L - 4L;
|
||||||
IProgress storageCreation = hardDisk.createBaseStorage(size, (long) org.virtualbox_4_1.jaxws.MediumVariant.STANDARD.ordinal());
|
IProgress storageCreation = hardDisk.createBaseStorage(size,
|
||||||
|
(long) org.virtualbox_4_1.jaxws.MediumVariant.STANDARD.ordinal());
|
||||||
storageCreation.waitForCompletion(-1);
|
storageCreation.waitForCompletion(-1);
|
||||||
} catch (VBoxException e) {
|
} catch (VBoxException e) {
|
||||||
if (fileNotFoundException(e)) {
|
if (fileNotFoundException(e)) {
|
||||||
// File for medium could not be found. Something wrong with creation.
|
// File for medium could not be found. Something wrong with
|
||||||
|
// creation.
|
||||||
hardDisk.deleteStorage();
|
hardDisk.deleteStorage();
|
||||||
}
|
}
|
||||||
if (!storageAlreadyExists(e)) {
|
if (!storageAlreadyExists(e)) {
|
||||||
// Hard disk file was created but the storage had been created before that.
|
// Hard disk file was created but the storage had been created
|
||||||
|
// before that.
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,8 +99,8 @@ public class CreateMediumIfNotAlreadyExists implements Function<String, IMedium>
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean storageAlreadyExists(VBoxException e) {
|
private boolean storageAlreadyExists(VBoxException e) {
|
||||||
return e.getMessage().indexOf("VirtualBox error: Storage for the medium ") != -1 &&
|
return e.getMessage().indexOf("VirtualBox error: Storage for the medium ") != -1
|
||||||
e.getMessage().indexOf("is already created") != -1;
|
&& e.getMessage().indexOf("is already created") != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,6 @@ public class IMachineToHardware implements Function<IMachine, Hardware> {
|
||||||
public Hardware apply(@Nullable IMachine vm) {
|
public Hardware apply(@Nullable IMachine vm) {
|
||||||
String osTypeId = vm.getOSTypeId();
|
String osTypeId = vm.getOSTypeId();
|
||||||
|
|
||||||
|
|
||||||
IGuestOSType guestOSType = virtualBoxManager.getVBox().getGuestOSType(osTypeId);
|
IGuestOSType guestOSType = virtualBoxManager.getVBox().getGuestOSType(osTypeId);
|
||||||
Boolean is64Bit = guestOSType.getIs64Bit();
|
Boolean is64Bit = guestOSType.getIs64Bit();
|
||||||
HardwareBuilder hardwareBuilder = new HardwareBuilder();
|
HardwareBuilder hardwareBuilder = new HardwareBuilder();
|
||||||
|
|
|
@ -58,8 +58,7 @@ public class IMachineToImage implements Function<IMachine, Image> {
|
||||||
|
|
||||||
IGuestOSType guestOSType = virtualboxManager.getVBox().getGuestOSType(from.getOSTypeId());
|
IGuestOSType guestOSType = virtualboxManager.getVBox().getGuestOSType(from.getOSTypeId());
|
||||||
OsFamily family = parseOsFamilyOrUnrecognized(guestOSType.getDescription());
|
OsFamily family = parseOsFamilyOrUnrecognized(guestOSType.getDescription());
|
||||||
String version = parseVersionOrReturnEmptyString(family, guestOSType.getDescription(),
|
String version = parseVersionOrReturnEmptyString(family, guestOSType.getDescription(), osVersionMap);
|
||||||
osVersionMap);
|
|
||||||
OperatingSystem os = OperatingSystem.builder().description(guestOSType.getDescription()).family(family)
|
OperatingSystem os = OperatingSystem.builder().description(guestOSType.getDescription()).family(family)
|
||||||
.version(version).is64Bit(guestOSType.getIs64Bit()).build();
|
.version(version).is64Bit(guestOSType.getIs64Bit()).build();
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,10 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.functions;
|
package org.jclouds.virtualbox.functions;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import static org.jclouds.compute.options.RunScriptOptions.Builder.runAsRoot;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.jclouds.compute.ComputeService;
|
import org.jclouds.compute.ComputeService;
|
||||||
import org.jclouds.compute.domain.ExecResponse;
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.compute.options.RunScriptOptions;
|
import org.jclouds.compute.options.RunScriptOptions;
|
||||||
|
@ -28,9 +31,7 @@ import org.virtualbox_4_1.IGuestOSType;
|
||||||
import org.virtualbox_4_1.IMachine;
|
import org.virtualbox_4_1.IMachine;
|
||||||
import org.virtualbox_4_1.VirtualBoxManager;
|
import org.virtualbox_4_1.VirtualBoxManager;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
import static org.jclouds.compute.options.RunScriptOptions.Builder.runAsRoot;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an IP address from an IMachine using arp of the host machine.
|
* Get an IP address from an IMachine using arp of the host machine.
|
||||||
|
@ -63,18 +64,25 @@ public class IMachineToIpAddress implements Function<IMachine, String> {
|
||||||
IMachine hostMachine = manager.getVBox().findMachine(hostId);
|
IMachine hostMachine = manager.getVBox().findMachine(hostId);
|
||||||
if (isOSX(hostMachine)) {
|
if (isOSX(hostMachine)) {
|
||||||
if (simplifiedMacAddressOfClonedVM.contains("00"))
|
if (simplifiedMacAddressOfClonedVM.contains("00"))
|
||||||
simplifiedMacAddressOfClonedVM = new StringBuffer(simplifiedMacAddressOfClonedVM).delete(simplifiedMacAddressOfClonedVM.indexOf("00"), simplifiedMacAddressOfClonedVM.indexOf("00") + 1).toString();
|
simplifiedMacAddressOfClonedVM = new StringBuffer(simplifiedMacAddressOfClonedVM).delete(
|
||||||
|
simplifiedMacAddressOfClonedVM.indexOf("00"), simplifiedMacAddressOfClonedVM.indexOf("00") + 1)
|
||||||
|
.toString();
|
||||||
|
|
||||||
if (simplifiedMacAddressOfClonedVM.contains("0"))
|
if (simplifiedMacAddressOfClonedVM.contains("0"))
|
||||||
if (simplifiedMacAddressOfClonedVM.indexOf("0") + 1 != ':' && simplifiedMacAddressOfClonedVM.indexOf("0") - 1 != ':')
|
if (simplifiedMacAddressOfClonedVM.indexOf("0") + 1 != ':'
|
||||||
simplifiedMacAddressOfClonedVM = new StringBuffer(simplifiedMacAddressOfClonedVM).delete(simplifiedMacAddressOfClonedVM.indexOf("0"), simplifiedMacAddressOfClonedVM.indexOf("0") + 1).toString();
|
&& simplifiedMacAddressOfClonedVM.indexOf("0") - 1 != ':')
|
||||||
|
simplifiedMacAddressOfClonedVM = new StringBuffer(simplifiedMacAddressOfClonedVM).delete(
|
||||||
|
simplifiedMacAddressOfClonedVM.indexOf("0"), simplifiedMacAddressOfClonedVM.indexOf("0") + 1)
|
||||||
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This is both shell-dependent and hard-coded. Needs to be fixed.
|
// TODO: This is both shell-dependent and hard-coded. Needs to be fixed.
|
||||||
ExecResponse execResponse = runScriptOnNode(hostId, "for i in {1..254} ; do ping -c 1 -t 1 192.168.2.$i & done", runAsRoot(false).wrapInInitScript(false));
|
ExecResponse execResponse = runScriptOnNode(hostId, "for i in {1..254} ; do ping -c 1 -t 1 192.168.2.$i & done",
|
||||||
|
runAsRoot(false).wrapInInitScript(false));
|
||||||
System.out.println(execResponse);
|
System.out.println(execResponse);
|
||||||
|
|
||||||
String arpLine = runScriptOnNode(hostId, "arp -an | grep " + simplifiedMacAddressOfClonedVM, runAsRoot(false).wrapInInitScript(false)).getOutput();
|
String arpLine = runScriptOnNode(hostId, "arp -an | grep " + simplifiedMacAddressOfClonedVM,
|
||||||
|
runAsRoot(false).wrapInInitScript(false)).getOutput();
|
||||||
String ipAddress = arpLine.substring(arpLine.indexOf("(") + 1, arpLine.indexOf(")"));
|
String ipAddress = arpLine.substring(arpLine.indexOf("(") + 1, arpLine.indexOf(")"));
|
||||||
System.out.println("IP address " + ipAddress);
|
System.out.println("IP address " + ipAddress);
|
||||||
return ipAddress;
|
return ipAddress;
|
||||||
|
|
|
@ -19,8 +19,19 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.functions;
|
package org.jclouds.virtualbox.functions;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import static org.jclouds.virtualbox.config.VirtualBoxComputeServiceContextModule.machineToNodeState;
|
||||||
import org.jclouds.compute.domain.*;
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.HardwareBuilder;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
|
import org.jclouds.compute.domain.NodeState;
|
||||||
|
import org.jclouds.compute.domain.Processor;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.domain.LocationBuilder;
|
import org.jclouds.domain.LocationBuilder;
|
||||||
|
@ -31,12 +42,7 @@ import org.virtualbox_4_1.IMachine;
|
||||||
import org.virtualbox_4_1.INetworkAdapter;
|
import org.virtualbox_4_1.INetworkAdapter;
|
||||||
import org.virtualbox_4_1.MachineState;
|
import org.virtualbox_4_1.MachineState;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import com.google.common.base.Function;
|
||||||
import javax.inject.Named;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static org.jclouds.virtualbox.config.VirtualBoxComputeServiceContextModule.machineToNodeState;
|
|
||||||
|
|
||||||
public class IMachineToNodeMetadata implements Function<IMachine, NodeMetadata> {
|
public class IMachineToNodeMetadata implements Function<IMachine, NodeMetadata> {
|
||||||
|
|
||||||
|
@ -75,7 +81,6 @@ public class IMachineToNodeMetadata implements Function<IMachine, NodeMetadata>
|
||||||
nodeMetadataBuilder.hostname(vm.getName());
|
nodeMetadataBuilder.hostname(vm.getName());
|
||||||
nodeMetadataBuilder.loginPort(18083);
|
nodeMetadataBuilder.loginPort(18083);
|
||||||
|
|
||||||
|
|
||||||
MachineState vmState = vm.getState();
|
MachineState vmState = vm.getState();
|
||||||
NodeState nodeState = machineToNodeState.get(vmState);
|
NodeState nodeState = machineToNodeState.get(vmState);
|
||||||
if (nodeState == null)
|
if (nodeState == null)
|
||||||
|
|
|
@ -19,8 +19,22 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.functions;
|
package org.jclouds.virtualbox.functions;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import com.google.inject.Inject;
|
import static org.jclouds.compute.options.RunScriptOptions.Builder.runAsRoot;
|
||||||
|
import static org.jclouds.compute.options.RunScriptOptions.Builder.wrapInInitScript;
|
||||||
|
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_INSTALLATION_KEY_SEQUENCE;
|
||||||
|
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_WORKINGDIR;
|
||||||
|
import static org.virtualbox_4_1.AccessMode.ReadOnly;
|
||||||
|
import static org.virtualbox_4_1.DeviceType.DVD;
|
||||||
|
import static org.virtualbox_4_1.DeviceType.HardDisk;
|
||||||
|
import static org.virtualbox_4_1.LockType.Shared;
|
||||||
|
import static org.virtualbox_4_1.LockType.Write;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.jclouds.compute.ComputeServiceContext;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.compute.domain.ExecResponse;
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
|
@ -34,22 +48,18 @@ import org.jclouds.virtualbox.config.VirtualBoxConstants;
|
||||||
import org.jclouds.virtualbox.domain.ExecutionType;
|
import org.jclouds.virtualbox.domain.ExecutionType;
|
||||||
import org.jclouds.virtualbox.functions.admin.StartJettyIfNotAlreadyRunning;
|
import org.jclouds.virtualbox.functions.admin.StartJettyIfNotAlreadyRunning;
|
||||||
import org.jclouds.virtualbox.settings.KeyboardScancodes;
|
import org.jclouds.virtualbox.settings.KeyboardScancodes;
|
||||||
import org.virtualbox_4_1.*;
|
import org.virtualbox_4_1.AccessMode;
|
||||||
|
import org.virtualbox_4_1.DeviceType;
|
||||||
|
import org.virtualbox_4_1.IMachine;
|
||||||
|
import org.virtualbox_4_1.IMedium;
|
||||||
|
import org.virtualbox_4_1.IProgress;
|
||||||
|
import org.virtualbox_4_1.ISession;
|
||||||
|
import org.virtualbox_4_1.LockType;
|
||||||
|
import org.virtualbox_4_1.VBoxException;
|
||||||
|
import org.virtualbox_4_1.VirtualBoxManager;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import com.google.common.base.Function;
|
||||||
import javax.inject.Named;
|
import com.google.inject.Inject;
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static org.jclouds.compute.options.RunScriptOptions.Builder.runAsRoot;
|
|
||||||
import static org.jclouds.compute.options.RunScriptOptions.Builder.wrapInInitScript;
|
|
||||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_INSTALLATION_KEY_SEQUENCE;
|
|
||||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_WORKINGDIR;
|
|
||||||
import static org.virtualbox_4_1.AccessMode.ReadOnly;
|
|
||||||
import static org.virtualbox_4_1.DeviceType.DVD;
|
|
||||||
import static org.virtualbox_4_1.DeviceType.HardDisk;
|
|
||||||
import static org.virtualbox_4_1.LockType.Shared;
|
|
||||||
import static org.virtualbox_4_1.LockType.Write;
|
|
||||||
|
|
||||||
public class IsoToIMachine implements Function<String, IMachine> {
|
public class IsoToIMachine implements Function<String, IMachine> {
|
||||||
|
|
||||||
|
@ -98,7 +108,8 @@ public class IsoToIMachine implements Function<String, IMachine> {
|
||||||
String baseResource = ".";
|
String baseResource = ".";
|
||||||
Server server = new StartJettyIfNotAlreadyRunning(port).apply(baseResource);
|
Server server = new StartJettyIfNotAlreadyRunning(port).apply(baseResource);
|
||||||
|
|
||||||
IMachine vm = new CreateAndRegisterMachineFromIsoIfNotAlreadyExists(settingsFile, osTypeId, vmId, forceOverwrite, manager).apply(vmName);
|
IMachine vm = new CreateAndRegisterMachineFromIsoIfNotAlreadyExists(settingsFile, osTypeId, vmId, forceOverwrite,
|
||||||
|
manager).apply(vmName);
|
||||||
|
|
||||||
String defaultWorkingDir = System.getProperty("user.home") + "/jclouds-virtualbox-test";
|
String defaultWorkingDir = System.getProperty("user.home") + "/jclouds-virtualbox-test";
|
||||||
String workingDir = System.getProperty(VIRTUALBOX_WORKINGDIR, defaultWorkingDir);
|
String workingDir = System.getProperty(VIRTUALBOX_WORKINGDIR, defaultWorkingDir);
|
||||||
|
@ -178,13 +189,13 @@ public class IsoToIMachine implements Function<String, IMachine> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureGuestAdditionsMediumIsAttached(String vmName, final IMedium guestAdditionsDvdMedium) {
|
private void ensureGuestAdditionsMediumIsAttached(String vmName, final IMedium guestAdditionsDvdMedium) {
|
||||||
lockMachineAndApply(manager, Write, vmName,
|
lockMachineAndApply(manager, Write, vmName, new AttachMediumToMachineIfNotAlreadyAttached(controllerIDE,
|
||||||
new AttachMediumToMachineIfNotAlreadyAttached(controllerIDE, guestAdditionsDvdMedium, 1, 1, DeviceType.DVD));
|
guestAdditionsDvdMedium, 1, 1, DeviceType.DVD));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureMachineHasHardDiskAttached(String vmName, IMedium hardDisk) {
|
private void ensureMachineHasHardDiskAttached(String vmName, IMedium hardDisk) {
|
||||||
lockMachineAndApply(manager, Write, vmName,
|
lockMachineAndApply(manager, Write, vmName, new AttachMediumToMachineIfNotAlreadyAttached(controllerIDE,
|
||||||
new AttachMediumToMachineIfNotAlreadyAttached(controllerIDE, hardDisk, 0, 1, HardDisk));
|
hardDisk, 0, 1, HardDisk));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureMachineHasMemory(String vmName, final long memorySize) {
|
private void ensureMachineHasMemory(String vmName, final long memorySize) {
|
||||||
|
@ -198,10 +209,12 @@ public class IsoToIMachine implements Function<String, IMachine> {
|
||||||
private void ensureMachineHasAttachedDistroMedium(String isoName, String workingDir, String controllerIDE) {
|
private void ensureMachineHasAttachedDistroMedium(String isoName, String workingDir, String controllerIDE) {
|
||||||
final String pathToIsoFile = checkFileExists(workingDir + "/" + isoName);
|
final String pathToIsoFile = checkFileExists(workingDir + "/" + isoName);
|
||||||
final IMedium distroMedium = manager.getVBox().openMedium(pathToIsoFile, DVD, ReadOnly, forceOverwrite);
|
final IMedium distroMedium = manager.getVBox().openMedium(pathToIsoFile, DVD, ReadOnly, forceOverwrite);
|
||||||
lockMachineAndApply(manager, Write, vmName,
|
lockMachineAndApply(
|
||||||
new AttachDistroMediumToMachine(
|
manager,
|
||||||
checkNotNull(controllerIDE, "controllerIDE"),
|
Write,
|
||||||
checkNotNull(distroMedium, "distroMedium")));
|
vmName,
|
||||||
|
new AttachDistroMediumToMachine(checkNotNull(controllerIDE, "controllerIDE"), checkNotNull(distroMedium,
|
||||||
|
"distroMedium")));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String checkFileExists(String filePath) {
|
public static String checkFileExists(String filePath) {
|
||||||
|
|
|
@ -19,33 +19,35 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.functions;
|
package org.jclouds.virtualbox.functions;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import static com.google.common.base.Throwables.propagate;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
|
||||||
import org.jclouds.logging.Logger;
|
|
||||||
import org.jclouds.virtualbox.domain.ErrorCode;
|
|
||||||
import org.jclouds.virtualbox.domain.ExecutionType;
|
|
||||||
import org.virtualbox_4_1.*;
|
|
||||||
import org.virtualbox_4_1.jaxws.RuntimeFaultMsg;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.lang.model.type.ExecutableType;
|
|
||||||
|
|
||||||
import static com.google.common.base.Throwables.propagate;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import static javax.xml.bind.DatatypeConverter.parseUnsignedInt;
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.virtualbox.domain.ErrorCode;
|
||||||
|
import org.jclouds.virtualbox.domain.ExecutionType;
|
||||||
|
import org.virtualbox_4_1.IMachine;
|
||||||
|
import org.virtualbox_4_1.IProgress;
|
||||||
|
import org.virtualbox_4_1.VBoxException;
|
||||||
|
import org.virtualbox_4_1.VirtualBoxManager;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts a machine using launchMachine() with the provided type and environment.
|
* Starts a machine using launchMachine() with the provided type and
|
||||||
|
* environment.
|
||||||
* <p/>
|
* <p/>
|
||||||
* Note that launchMachine() may throw VBoxException with the following error codes:
|
* Note that launchMachine() may throw VBoxException with the following error
|
||||||
|
* codes:
|
||||||
* <p/>
|
* <p/>
|
||||||
* VBOX_E_UNEXPECTED: Virtual machine not registered.
|
* VBOX_E_UNEXPECTED: Virtual machine not registered. VBOX_E_INVALIDARG: Invalid
|
||||||
* VBOX_E_INVALIDARG: Invalid session type type.
|
* session type type. VBOX_E_OBJECT_NOT_FOUND: No machine matching machineId
|
||||||
* VBOX_E_OBJECT_NOT_FOUND: No machine matching machineId found.
|
* found. VBOX_E_INVALID_OBJECT_STATE: Session already open or being opened.
|
||||||
* VBOX_E_INVALID_OBJECT_STATE: Session already open or being opened.
|
* VBOX_E_IPRT_ERROR: Launching process for machine failed. VBOX_E_VM_ERROR:
|
||||||
* VBOX_E_IPRT_ERROR: Launching process for machine failed.
|
* Failed to assign machine to session.
|
||||||
* VBOX_E_VM_ERROR: Failed to assign machine to session.
|
|
||||||
*
|
*
|
||||||
* @author Mattias Holmqvist
|
* @author Mattias Holmqvist
|
||||||
*
|
*
|
||||||
|
@ -70,7 +72,8 @@ public class LaunchMachineIfNotAlreadyRunning implements Function<IMachine, Void
|
||||||
@Override
|
@Override
|
||||||
public Void apply(@Nullable IMachine machine) {
|
public Void apply(@Nullable IMachine machine) {
|
||||||
try {
|
try {
|
||||||
final IProgress progress = machine.launchVMProcess(manager.getSessionObject(), type.stringValue(), environment);
|
final IProgress progress = machine
|
||||||
|
.launchVMProcess(manager.getSessionObject(), type.stringValue(), environment);
|
||||||
progress.waitForCompletion(-1);
|
progress.waitForCompletion(-1);
|
||||||
Thread.sleep(5000);
|
Thread.sleep(5000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
@ -79,8 +82,8 @@ public class LaunchMachineIfNotAlreadyRunning implements Function<IMachine, Void
|
||||||
ErrorCode errorCode = ErrorCode.valueOf(e);
|
ErrorCode errorCode = ErrorCode.valueOf(e);
|
||||||
switch (errorCode) {
|
switch (errorCode) {
|
||||||
case VBOX_E_INVALID_OBJECT_STATE:
|
case VBOX_E_INVALID_OBJECT_STATE:
|
||||||
logger.warn(e, "Could not start machine. Got error code %s from launchMachine(). " +
|
logger.warn(e, "Could not start machine. Got error code %s from launchMachine(). "
|
||||||
"The machine might already be running.", errorCode);
|
+ "The machine might already be running.", errorCode);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
propagate(e);
|
propagate(e);
|
||||||
|
|
|
@ -1,28 +1,4 @@
|
||||||
package org.jclouds.virtualbox.functions.admin;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
import com.google.common.base.Functions;
|
|
||||||
import com.google.common.cache.Cache;
|
|
||||||
import com.google.common.cache.CacheBuilder;
|
|
||||||
import com.google.common.cache.CacheLoader;
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import org.jclouds.compute.domain.Image;
|
|
||||||
import org.jclouds.virtualbox.domain.YamlImage;
|
|
||||||
import org.yaml.snakeyaml.Loader;
|
|
||||||
import org.yaml.snakeyaml.TypeDescription;
|
|
||||||
import org.yaml.snakeyaml.Yaml;
|
|
||||||
import org.yaml.snakeyaml.constructor.Constructor;
|
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -39,7 +15,34 @@ import static com.google.common.base.Preconditions.checkState;
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.virtualbox.functions.admin;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.Image;
|
||||||
|
import org.jclouds.virtualbox.domain.YamlImage;
|
||||||
|
import org.yaml.snakeyaml.Loader;
|
||||||
|
import org.yaml.snakeyaml.TypeDescription;
|
||||||
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
import org.yaml.snakeyaml.constructor.Constructor;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Functions;
|
||||||
|
import com.google.common.cache.Cache;
|
||||||
|
import com.google.common.cache.CacheBuilder;
|
||||||
|
import com.google.common.cache.CacheLoader;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
|
/**
|
||||||
*
|
*
|
||||||
* @author Andrea Turli
|
* @author Andrea Turli
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -50,8 +50,7 @@ public class StartJettyIfNotAlreadyRunning implements Function<String, Server> {
|
||||||
private final int port;
|
private final int port;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public StartJettyIfNotAlreadyRunning(
|
public StartJettyIfNotAlreadyRunning(@Named(VirtualBoxConstants.VIRTUALBOX_JETTY_PORT) final String port) {
|
||||||
@Named(VirtualBoxConstants.VIRTUALBOX_JETTY_PORT) final String port) {
|
|
||||||
this.port = Integer.parseInt(port);
|
this.port = Integer.parseInt(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +58,8 @@ public class StartJettyIfNotAlreadyRunning implements Function<String, Server> {
|
||||||
public Server apply(@Nullable String baseResource) {
|
public Server apply(@Nullable String baseResource) {
|
||||||
final Server server = ServerJetty.getInstance().getServer();
|
final Server server = ServerJetty.getInstance().getServer();
|
||||||
|
|
||||||
if (!server.getState().equals(Server.STARTED) && !new InetSocketAddressConnect().apply(new IPSocket("localhost", port))) {
|
if (!server.getState().equals(Server.STARTED)
|
||||||
|
&& !new InetSocketAddressConnect().apply(new IPSocket("localhost", port))) {
|
||||||
ResourceHandler resource_handler = new ResourceHandler();
|
ResourceHandler resource_handler = new ResourceHandler();
|
||||||
resource_handler.setDirectoriesListed(true);
|
resource_handler.setDirectoriesListed(true);
|
||||||
resource_handler.setWelcomeFiles(new String[] { "index.html" });
|
resource_handler.setWelcomeFiles(new String[] { "index.html" });
|
||||||
|
|
|
@ -20,8 +20,14 @@
|
||||||
package org.jclouds.virtualbox.functions.admin;
|
package org.jclouds.virtualbox.functions.admin;
|
||||||
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import static org.jclouds.compute.options.RunScriptOptions.Builder.runAsRoot;
|
||||||
import com.google.common.cache.Cache;
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
import org.jclouds.compute.ComputeServiceContext;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
|
@ -30,14 +36,7 @@ import org.jclouds.net.IPSocket;
|
||||||
import org.jclouds.predicates.InetSocketAddressConnect;
|
import org.jclouds.predicates.InetSocketAddressConnect;
|
||||||
import org.virtualbox_4_1.VirtualBoxManager;
|
import org.virtualbox_4_1.VirtualBoxManager;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import com.google.common.base.Function;
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.inject.Named;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
import static org.jclouds.compute.options.RunScriptOptions.Builder.runAsRoot;
|
|
||||||
|
|
||||||
public class StartVBoxIfNotAlreadyRunning implements Function<URI, VirtualBoxManager> {
|
public class StartVBoxIfNotAlreadyRunning implements Function<URI, VirtualBoxManager> {
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.virtualbox.settings;
|
package org.jclouds.virtualbox.settings;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -124,6 +125,7 @@ public class KeyboardScancodes {
|
||||||
alphaToHex.put(")", "2a 0b aa 8b");
|
alphaToHex.put(")", "2a 0b aa 8b");
|
||||||
return Collections.unmodifiableMap(alphaToHex);
|
return Collections.unmodifiableMap(alphaToHex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<String, String> createSpecialMap() {
|
private static Map<String, String> createSpecialMap() {
|
||||||
Map<String, String> special = new HashMap<String, String>();
|
Map<String, String> special = new HashMap<String, String>();
|
||||||
special.put("<Enter>", "1c 9c");
|
special.put("<Enter>", "1c 9c");
|
||||||
|
|
|
@ -19,11 +19,12 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.compute;
|
package org.jclouds.virtualbox.compute;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import static org.testng.Assert.assertEquals;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import static org.testng.Assert.assertFalse;
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
import com.google.common.collect.Maps;
|
import java.net.URI;
|
||||||
import com.google.inject.Guice;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.jclouds.compute.config.BaseComputeServiceContextModule;
|
import org.jclouds.compute.config.BaseComputeServiceContextModule;
|
||||||
import org.jclouds.compute.domain.ExecResponse;
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
|
@ -44,11 +45,11 @@ import org.testng.annotations.Test;
|
||||||
import org.virtualbox_4_1.IMachine;
|
import org.virtualbox_4_1.IMachine;
|
||||||
import org.virtualbox_4_1.VirtualBoxManager;
|
import org.virtualbox_4_1.VirtualBoxManager;
|
||||||
|
|
||||||
import java.net.URI;
|
import com.google.common.base.Function;
|
||||||
import java.util.Map;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
import static org.testng.Assert.assertEquals;
|
import com.google.common.collect.Maps;
|
||||||
import static org.testng.Assert.assertFalse;
|
import com.google.inject.Guice;
|
||||||
|
|
||||||
@Test(groups = "live", singleThreaded = true, testName = "VirtualBoxComputeServiceAdapterLiveTest")
|
@Test(groups = "live", singleThreaded = true, testName = "VirtualBoxComputeServiceAdapterLiveTest")
|
||||||
public class VirtualBoxComputeServiceAdapterLiveTest extends BaseVirtualBoxClientLiveTest {
|
public class VirtualBoxComputeServiceAdapterLiveTest extends BaseVirtualBoxClientLiveTest {
|
||||||
|
@ -64,8 +65,8 @@ public class VirtualBoxComputeServiceAdapterLiveTest extends BaseVirtualBoxClien
|
||||||
super.setupClient();
|
super.setupClient();
|
||||||
final VirtualBoxManager manager = getManager();
|
final VirtualBoxManager manager = getManager();
|
||||||
Function<IMachine, Image> iMachineToImage = new IMachineToImage(manager, osVersionMap);
|
Function<IMachine, Image> iMachineToImage = new IMachineToImage(manager, osVersionMap);
|
||||||
adapter = new VirtualBoxComputeServiceAdapter(manager,
|
adapter = new VirtualBoxComputeServiceAdapter(manager, new JustProvider(provider, URI.create(endpoint),
|
||||||
new JustProvider(provider, URI.create(endpoint), ImmutableSet.<String>of()), iMachineToImage);
|
ImmutableSet.<String> of()), iMachineToImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected VirtualBoxManager getManager() {
|
protected VirtualBoxManager getManager() {
|
||||||
|
@ -91,13 +92,14 @@ public class VirtualBoxComputeServiceAdapterLiveTest extends BaseVirtualBoxClien
|
||||||
assert credentialStore.containsKey("node#" + machine.getId()) : "credentials to log into machine not found "
|
assert credentialStore.containsKey("node#" + machine.getId()) : "credentials to log into machine not found "
|
||||||
+ machine;
|
+ machine;
|
||||||
// TODO: what's the IP address?
|
// TODO: what's the IP address?
|
||||||
// assert InetAddresses.isInetAddress(machine.getPrimaryBackendIpAddress()) : machine;
|
// assert
|
||||||
|
// InetAddresses.isInetAddress(machine.getPrimaryBackendIpAddress()) :
|
||||||
|
// machine;
|
||||||
doConnectViaSsh(machine, credentialStore.get("node#" + machine.getId()));
|
doConnectViaSsh(machine, credentialStore.get("node#" + machine.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doConnectViaSsh(IMachine machine, Credentials creds) {
|
protected void doConnectViaSsh(IMachine machine, Credentials creds) {
|
||||||
SshClient ssh = context.utils().sshFactory()
|
SshClient ssh = context.utils().sshFactory().create(new IPSocket("//TODO", 22), creds);
|
||||||
.create(new IPSocket("//TODO", 22), creds);
|
|
||||||
try {
|
try {
|
||||||
ssh.connect();
|
ssh.connect();
|
||||||
ExecResponse hello = ssh.exec("echo hello");
|
ExecResponse hello = ssh.exec("echo hello");
|
||||||
|
|
|
@ -19,9 +19,17 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.compute;
|
package org.jclouds.virtualbox.compute;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import static org.easymock.EasyMock.expect;
|
||||||
import com.google.common.collect.Iterators;
|
import static org.easymock.classextension.EasyMock.createNiceMock;
|
||||||
import com.google.inject.Guice;
|
import static org.easymock.classextension.EasyMock.replay;
|
||||||
|
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGE_PREFIX;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.easymock.EasyMock;
|
import org.easymock.EasyMock;
|
||||||
import org.jclouds.compute.config.BaseComputeServiceContextModule;
|
import org.jclouds.compute.config.BaseComputeServiceContextModule;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
|
@ -37,16 +45,9 @@ import org.virtualbox_4_1.IMachine;
|
||||||
import org.virtualbox_4_1.IVirtualBox;
|
import org.virtualbox_4_1.IVirtualBox;
|
||||||
import org.virtualbox_4_1.VirtualBoxManager;
|
import org.virtualbox_4_1.VirtualBoxManager;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.google.common.base.Function;
|
||||||
import java.util.Iterator;
|
import com.google.common.collect.Iterators;
|
||||||
import java.util.List;
|
import com.google.inject.Guice;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static org.easymock.classextension.EasyMock.expect;
|
|
||||||
import static org.easymock.classextension.EasyMock.createNiceMock;
|
|
||||||
import static org.easymock.classextension.EasyMock.replay;
|
|
||||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGE_PREFIX;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
|
|
||||||
@Test(groups = "unit")
|
@Test(groups = "unit")
|
||||||
public class VirtualBoxComputeServiceAdapterTest {
|
public class VirtualBoxComputeServiceAdapterTest {
|
||||||
|
@ -83,7 +84,8 @@ public class VirtualBoxComputeServiceAdapterTest {
|
||||||
replay(manager, justProvider, vBox, clonedMachine, imageMachine, osType);
|
replay(manager, justProvider, vBox, clonedMachine, imageMachine, osType);
|
||||||
|
|
||||||
Function<IMachine, Image> iMachineToImage = new IMachineToImage(manager, osMap);
|
Function<IMachine, Image> iMachineToImage = new IMachineToImage(manager, osMap);
|
||||||
VirtualBoxComputeServiceAdapter adapter = new VirtualBoxComputeServiceAdapter(manager, justProvider, iMachineToImage);
|
VirtualBoxComputeServiceAdapter adapter = new VirtualBoxComputeServiceAdapter(manager, justProvider,
|
||||||
|
iMachineToImage);
|
||||||
|
|
||||||
Iterator<Image> iterator = adapter.listImages().iterator();
|
Iterator<Image> iterator = adapter.listImages().iterator();
|
||||||
Image image = Iterators.getOnlyElement(iterator);
|
Image image = Iterators.getOnlyElement(iterator);
|
||||||
|
|
|
@ -34,7 +34,6 @@ import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Andrea Turli
|
* @author Andrea Turli
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
/**
|
/**
|
||||||
*
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* Copyright (C) 2009 Global Cloud Specialists, Inc. <info@globalcloudspecialists.com>
|
* contributor license agreements. See the NOTICE file
|
||||||
*
|
|
||||||
* ====================================================================
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
* or more contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
* to you under the Apache License, Version 2.0 (the
|
* to you under the Apache License, Version 2.0 (the
|
||||||
* "License"); you may not use this file except in compliance
|
* "License"); you may not use this file except in compliance
|
||||||
* with the License. You may obtain a copy of the License at
|
* with the License. You may obtain a copy of the License at
|
||||||
|
@ -19,8 +15,8 @@
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
* ====================================================================
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.virtualbox.experiment;
|
package org.jclouds.virtualbox.experiment;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
@ -40,8 +36,8 @@ import org.jclouds.compute.options.RunScriptOptions;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.virtualbox.config.VirtualBoxConstants;
|
import org.jclouds.virtualbox.config.VirtualBoxConstants;
|
||||||
import org.jclouds.virtualbox.functions.admin.StartVBoxIfNotAlreadyRunning;
|
|
||||||
import org.jclouds.virtualbox.functions.admin.StartJettyIfNotAlreadyRunning;
|
import org.jclouds.virtualbox.functions.admin.StartJettyIfNotAlreadyRunning;
|
||||||
|
import org.jclouds.virtualbox.functions.admin.StartVBoxIfNotAlreadyRunning;
|
||||||
import org.testng.annotations.AfterSuite;
|
import org.testng.annotations.AfterSuite;
|
||||||
import org.testng.annotations.BeforeSuite;
|
import org.testng.annotations.BeforeSuite;
|
||||||
|
|
||||||
|
@ -151,8 +147,8 @@ public class SetupVirtualBoxForLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOSX(String id) {
|
public boolean isOSX(String id) {
|
||||||
return context.getComputeService().getNodeMetadata(hostId).getOperatingSystem().getDescription().equals(
|
return context.getComputeService().getNodeMetadata(hostId).getOperatingSystem().getDescription()
|
||||||
"Mac OS X");
|
.equals("Mac OS X");
|
||||||
}
|
}
|
||||||
|
|
||||||
public File downloadFileUnlessPresent(URI sourceURL, String destinationDir, String filename) throws Exception {
|
public File downloadFileUnlessPresent(URI sourceURL, String destinationDir, String filename) throws Exception {
|
||||||
|
|
|
@ -18,10 +18,11 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.virtualbox.experiment;
|
package org.jclouds.virtualbox.experiment;
|
||||||
|
|
||||||
import com.google.common.cache.Cache;
|
import java.io.IOException;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import java.net.URI;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import java.net.URISyntaxException;
|
||||||
import com.google.inject.Module;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.jclouds.byon.Node;
|
import org.jclouds.byon.Node;
|
||||||
import org.jclouds.byon.config.CacheNodeStoreModule;
|
import org.jclouds.byon.config.CacheNodeStoreModule;
|
||||||
import org.jclouds.compute.ComputeServiceContext;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
|
@ -31,75 +32,48 @@ import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.encryption.bouncycastle.config.BouncyCastleCryptoModule;
|
import org.jclouds.encryption.bouncycastle.config.BouncyCastleCryptoModule;
|
||||||
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
|
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
|
||||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||||
import org.jclouds.virtualbox.config.VirtualBoxConstants;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import com.google.common.cache.Cache;
|
||||||
import java.net.URI;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import java.net.URISyntaxException;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import java.util.Map;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
public class TestUtils {
|
public class TestUtils {
|
||||||
|
|
||||||
public static ComputeServiceContext computeServiceForLocalhostAndGuest() throws IOException {
|
public static ComputeServiceContext computeServiceForLocalhostAndGuest() throws IOException {
|
||||||
|
|
||||||
Node host = Node.builder().id("host")
|
Node host = Node.builder().id("host").name("host installing virtualbox").hostname("localhost")
|
||||||
.name("host installing virtualbox")
|
.osFamily(OsFamily.LINUX.toString()).osDescription(System.getProperty("os.name"))
|
||||||
.hostname("localhost")
|
.osVersion(System.getProperty("os.version")).group("ssh").username(System.getProperty("user.name"))
|
||||||
.osFamily(OsFamily.LINUX.toString())
|
.credentialUrl(privateKeyFile()).build();
|
||||||
.osDescription(System.getProperty("os.name"))
|
Node guest = Node.builder().id("guest").name("new guest").hostname("localhost").loginPort(2222)
|
||||||
.osVersion(System.getProperty("os.version"))
|
.osFamily(OsFamily.UBUNTU.toString()).osDescription("ubuntu/11.04").osVersion(System.getProperty("11.04"))
|
||||||
.group("ssh")
|
.group("guest").username("toor").sudoPassword("password").credential("password").build();
|
||||||
.username(System.getProperty("user.name"))
|
|
||||||
.credentialUrl(privateKeyFile())
|
|
||||||
.build();
|
|
||||||
Node guest = Node.builder().id("guest")
|
|
||||||
.name("new guest")
|
|
||||||
.hostname("localhost")
|
|
||||||
.loginPort(2222)
|
|
||||||
.osFamily(OsFamily.UBUNTU.toString())
|
|
||||||
.osDescription("ubuntu/11.04")
|
|
||||||
.osVersion(System.getProperty("11.04"))
|
|
||||||
.group("guest")
|
|
||||||
.username("toor")
|
|
||||||
.sudoPassword("password")
|
|
||||||
.credential("password")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
final Map<String, Node> nodeMap = ImmutableMap.<String, Node>builder().put("host", host).put("guest", guest).build();
|
final Map<String, Node> nodeMap = ImmutableMap.<String, Node> builder().put("host", host).put("guest", guest)
|
||||||
|
.build();
|
||||||
return new ComputeServiceContextFactory().createContext("byon", "foo", "bar", ImmutableSet.<Module> of(
|
return new ComputeServiceContextFactory().createContext("byon", "foo", "bar", ImmutableSet.<Module> of(
|
||||||
new SshjSshClientModule(), new SLF4JLoggingModule(), new BouncyCastleCryptoModule(), new CacheNodeStoreModule(nodeMap)));
|
new SshjSshClientModule(), new SLF4JLoggingModule(), new BouncyCastleCryptoModule(),
|
||||||
|
new CacheNodeStoreModule(nodeMap)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ComputeServiceContext computeServiceForLocalhostAndGuest(String hostId, String hostname, String guestId, String guestHostname,
|
public static ComputeServiceContext computeServiceForLocalhostAndGuest(String hostId, String hostname,
|
||||||
Credentials guestLogin) throws IOException {
|
String guestId, String guestHostname, Credentials guestLogin) throws IOException {
|
||||||
|
|
||||||
Node host = Node.builder().id(hostId)
|
Node host = Node.builder().id(hostId).name("host installing virtualbox").hostname(hostname)
|
||||||
.name("host installing virtualbox")
|
.osFamily(OsFamily.LINUX.toString()).osDescription(System.getProperty("os.name"))
|
||||||
.hostname(hostname)
|
.osVersion(System.getProperty("os.version")).group("ssh").username(System.getProperty("user.name"))
|
||||||
.osFamily(OsFamily.LINUX.toString())
|
.credentialUrl(privateKeyFile()).build();
|
||||||
.osDescription(System.getProperty("os.name"))
|
Node guest = Node.builder().id(guestId).name("new guest").hostname(guestHostname).loginPort(2222)
|
||||||
.osVersion(System.getProperty("os.version"))
|
.osFamily(OsFamily.UBUNTU.toString()).osDescription("ubuntu/11.04").osVersion(System.getProperty("11.04"))
|
||||||
.group("ssh")
|
.group("jclouds-linux-image").username(guestLogin.identity).sudoPassword(guestLogin.credential)
|
||||||
.username(System.getProperty("user.name"))
|
.credential(guestLogin.credential).build();
|
||||||
.credentialUrl(privateKeyFile())
|
|
||||||
|
final Map<String, Node> nodeMap = ImmutableMap.<String, Node> builder().put(hostId, host).put(guestId, guest)
|
||||||
.build();
|
.build();
|
||||||
Node guest = Node.builder().id(guestId)
|
|
||||||
.name("new guest")
|
|
||||||
.hostname(guestHostname)
|
|
||||||
.loginPort(2222)
|
|
||||||
.osFamily(OsFamily.UBUNTU.toString())
|
|
||||||
.osDescription("ubuntu/11.04")
|
|
||||||
.osVersion(System.getProperty("11.04"))
|
|
||||||
.group("jclouds-linux-image")
|
|
||||||
.username(guestLogin.identity)
|
|
||||||
.sudoPassword(guestLogin.credential)
|
|
||||||
.credential(guestLogin.credential)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
|
|
||||||
final Map<String, Node> nodeMap = ImmutableMap.<String, Node>builder().put(hostId, host).put(guestId, guest).build();
|
|
||||||
return new ComputeServiceContextFactory().createContext("byon", "foo", "bar", ImmutableSet.<Module> of(
|
return new ComputeServiceContextFactory().createContext("byon", "foo", "bar", ImmutableSet.<Module> of(
|
||||||
new SshjSshClientModule(), new SLF4JLoggingModule(), new BouncyCastleCryptoModule(), new CacheNodeStoreModule(nodeMap)));
|
new SshjSshClientModule(), new SLF4JLoggingModule(), new BouncyCastleCryptoModule(),
|
||||||
|
new CacheNodeStoreModule(nodeMap)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static URI privateKeyFile() {
|
private static URI privateKeyFile() {
|
||||||
|
@ -113,6 +87,7 @@ public class TestUtils {
|
||||||
|
|
||||||
public static ComputeServiceContext computeServiceForVirtualBox(Cache<String, Node> cache) {
|
public static ComputeServiceContext computeServiceForVirtualBox(Cache<String, Node> cache) {
|
||||||
return new ComputeServiceContextFactory().createContext("byon", "foo", "bar", ImmutableSet.<Module> of(
|
return new ComputeServiceContextFactory().createContext("byon", "foo", "bar", ImmutableSet.<Module> of(
|
||||||
new SshjSshClientModule(), new SLF4JLoggingModule(), new BouncyCastleCryptoModule(), new CacheNodeStoreModule(cache)));
|
new SshjSshClientModule(), new SLF4JLoggingModule(), new BouncyCastleCryptoModule(),
|
||||||
|
new CacheNodeStoreModule(cache)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/**
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -19,12 +19,16 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.functions;
|
package org.jclouds.virtualbox.functions;
|
||||||
|
|
||||||
|
import static org.easymock.EasyMock.expectLastCall;
|
||||||
|
import static org.easymock.classextension.EasyMock.createMock;
|
||||||
|
import static org.easymock.classextension.EasyMock.createNiceMock;
|
||||||
|
import static org.easymock.classextension.EasyMock.replay;
|
||||||
|
import static org.easymock.classextension.EasyMock.verify;
|
||||||
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
import org.virtualbox_4_1.IMachine;
|
import org.virtualbox_4_1.IMachine;
|
||||||
import org.virtualbox_4_1.VBoxException;
|
import org.virtualbox_4_1.VBoxException;
|
||||||
|
|
||||||
import static org.easymock.classextension.EasyMock.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mattias Holmqvist
|
* @author Mattias Holmqvist
|
||||||
*/
|
*/
|
||||||
|
@ -49,8 +53,8 @@ public class ApplyMemoryToMachineTest {
|
||||||
@Test(expectedExceptions = VBoxException.class)
|
@Test(expectedExceptions = VBoxException.class)
|
||||||
public void testRethrowInvalidRamSizeError() throws Exception {
|
public void testRethrowInvalidRamSizeError() throws Exception {
|
||||||
// Mainly here for documentation purposes
|
// Mainly here for documentation purposes
|
||||||
final String error = "VirtualBox error: Invalid RAM size: " +
|
final String error = "VirtualBox error: Invalid RAM size: "
|
||||||
"3567587327 MB (must be in range [4, 2097152] MB) (0x80070057)";
|
+ "3567587327 MB (must be in range [4, 2097152] MB) (0x80070057)";
|
||||||
|
|
||||||
long memorySize = 1024l;
|
long memorySize = 1024l;
|
||||||
IMachine machine = createMock(IMachine.class);
|
IMachine machine = createMock(IMachine.class);
|
||||||
|
|
|
@ -18,15 +18,18 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.virtualbox.functions;
|
package org.jclouds.virtualbox.functions;
|
||||||
|
|
||||||
|
import static org.easymock.EasyMock.expectLastCall;
|
||||||
|
import static org.easymock.classextension.EasyMock.createMock;
|
||||||
|
import static org.easymock.classextension.EasyMock.createNiceMock;
|
||||||
|
import static org.easymock.classextension.EasyMock.replay;
|
||||||
|
import static org.easymock.classextension.EasyMock.verify;
|
||||||
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
import org.virtualbox_4_1.DeviceType;
|
import org.virtualbox_4_1.DeviceType;
|
||||||
import org.virtualbox_4_1.IMachine;
|
import org.virtualbox_4_1.IMachine;
|
||||||
import org.virtualbox_4_1.IMedium;
|
import org.virtualbox_4_1.IMedium;
|
||||||
import org.virtualbox_4_1.VBoxException;
|
import org.virtualbox_4_1.VBoxException;
|
||||||
|
|
||||||
import static org.easymock.classextension.EasyMock.*;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mattias Holmqvist
|
* @author Mattias Holmqvist
|
||||||
*/
|
*/
|
||||||
|
@ -67,7 +70,8 @@ public class AttachDistroMediumToMachineTest {
|
||||||
errorBuilder.append("of this virtual machine (0x80BB000C)");
|
errorBuilder.append("of this virtual machine (0x80BB000C)");
|
||||||
String isoAlreadyAttachedException = errorBuilder.toString();
|
String isoAlreadyAttachedException = errorBuilder.toString();
|
||||||
|
|
||||||
VBoxException isoAttachedException = new VBoxException(createNiceMock(Throwable.class), isoAlreadyAttachedException);
|
VBoxException isoAttachedException = new VBoxException(createNiceMock(Throwable.class),
|
||||||
|
isoAlreadyAttachedException);
|
||||||
machine.attachDevice(controllerIDE, 0, 0, DeviceType.DVD, distroMedium);
|
machine.attachDevice(controllerIDE, 0, 0, DeviceType.DVD, distroMedium);
|
||||||
expectLastCall().andThrow(isoAttachedException);
|
expectLastCall().andThrow(isoAttachedException);
|
||||||
|
|
||||||
|
@ -92,7 +96,8 @@ public class AttachDistroMediumToMachineTest {
|
||||||
errorBuilder.append("Some other VBox error");
|
errorBuilder.append("Some other VBox error");
|
||||||
String isoAlreadyAttachedException = errorBuilder.toString();
|
String isoAlreadyAttachedException = errorBuilder.toString();
|
||||||
|
|
||||||
VBoxException isoAttachedException = new VBoxException(createNiceMock(Throwable.class), isoAlreadyAttachedException);
|
VBoxException isoAttachedException = new VBoxException(createNiceMock(Throwable.class),
|
||||||
|
isoAlreadyAttachedException);
|
||||||
machine.attachDevice(controllerIDE, 0, 0, DeviceType.DVD, distroMedium);
|
machine.attachDevice(controllerIDE, 0, 0, DeviceType.DVD, distroMedium);
|
||||||
expectLastCall().andThrow(isoAttachedException);
|
expectLastCall().andThrow(isoAttachedException);
|
||||||
|
|
||||||
|
@ -102,5 +107,4 @@ public class AttachDistroMediumToMachineTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,23 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.functions;
|
package org.jclouds.virtualbox.functions;
|
||||||
|
|
||||||
import org.testng.annotations.Test;
|
import static org.easymock.EasyMock.anyLong;
|
||||||
import org.virtualbox_4_1.*;
|
import static org.easymock.EasyMock.expect;
|
||||||
|
import static org.easymock.EasyMock.expectLastCall;
|
||||||
import static org.easymock.classextension.EasyMock.*;
|
import static org.easymock.classextension.EasyMock.createMock;
|
||||||
|
import static org.easymock.classextension.EasyMock.createNiceMock;
|
||||||
|
import static org.easymock.classextension.EasyMock.replay;
|
||||||
|
import static org.easymock.classextension.EasyMock.verify;
|
||||||
import static org.virtualbox_4_1.DeviceType.HardDisk;
|
import static org.virtualbox_4_1.DeviceType.HardDisk;
|
||||||
|
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
import org.virtualbox_4_1.IMachine;
|
||||||
|
import org.virtualbox_4_1.IMedium;
|
||||||
|
import org.virtualbox_4_1.IProgress;
|
||||||
|
import org.virtualbox_4_1.IVirtualBox;
|
||||||
|
import org.virtualbox_4_1.VBoxException;
|
||||||
|
import org.virtualbox_4_1.VirtualBoxManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mattias Holmqvist
|
* @author Mattias Holmqvist
|
||||||
*/
|
*/
|
||||||
|
@ -54,7 +65,8 @@ public class AttachMediumToMachineIfNotAlreadyAttachedTest {
|
||||||
machine.saveSettings();
|
machine.saveSettings();
|
||||||
replay(manager, machine, vBox, hardDisk);
|
replay(manager, machine, vBox, hardDisk);
|
||||||
|
|
||||||
new AttachMediumToMachineIfNotAlreadyAttached(controllerIDE, hardDisk, controllerPort, device, HardDisk).apply(machine);
|
new AttachMediumToMachineIfNotAlreadyAttached(controllerIDE, hardDisk, controllerPort, device, HardDisk)
|
||||||
|
.apply(machine);
|
||||||
|
|
||||||
verify(machine);
|
verify(machine);
|
||||||
|
|
||||||
|
@ -79,13 +91,15 @@ public class AttachMediumToMachineIfNotAlreadyAttachedTest {
|
||||||
errorBuilder.append("of this virtual machine (0x80BB000C)");
|
errorBuilder.append("of this virtual machine (0x80BB000C)");
|
||||||
String isoAlreadyAttachedException = errorBuilder.toString();
|
String isoAlreadyAttachedException = errorBuilder.toString();
|
||||||
|
|
||||||
VBoxException isoAttachedException = new VBoxException(createNiceMock(Throwable.class), isoAlreadyAttachedException);
|
VBoxException isoAttachedException = new VBoxException(createNiceMock(Throwable.class),
|
||||||
|
isoAlreadyAttachedException);
|
||||||
machine.attachDevice(controllerIDE, controllerPort, device, HardDisk, hardDisk);
|
machine.attachDevice(controllerIDE, controllerPort, device, HardDisk, hardDisk);
|
||||||
expectLastCall().andThrow(isoAttachedException);
|
expectLastCall().andThrow(isoAttachedException);
|
||||||
|
|
||||||
replay(manager, machine, vBox, hardDisk);
|
replay(manager, machine, vBox, hardDisk);
|
||||||
|
|
||||||
new AttachMediumToMachineIfNotAlreadyAttached(controllerIDE, hardDisk, controllerPort, device, HardDisk).apply(machine);
|
new AttachMediumToMachineIfNotAlreadyAttached(controllerIDE, hardDisk, controllerPort, device, HardDisk)
|
||||||
|
.apply(machine);
|
||||||
|
|
||||||
verify(machine);
|
verify(machine);
|
||||||
|
|
||||||
|
@ -108,13 +122,15 @@ public class AttachMediumToMachineIfNotAlreadyAttachedTest {
|
||||||
errorBuilder.append("Some other VBox error");
|
errorBuilder.append("Some other VBox error");
|
||||||
String isoAlreadyAttachedException = errorBuilder.toString();
|
String isoAlreadyAttachedException = errorBuilder.toString();
|
||||||
|
|
||||||
VBoxException isoAttachedException = new VBoxException(createNiceMock(Throwable.class), isoAlreadyAttachedException);
|
VBoxException isoAttachedException = new VBoxException(createNiceMock(Throwable.class),
|
||||||
|
isoAlreadyAttachedException);
|
||||||
machine.attachDevice(controllerIDE, controllerPort, device, HardDisk, hardDisk);
|
machine.attachDevice(controllerIDE, controllerPort, device, HardDisk, hardDisk);
|
||||||
expectLastCall().andThrow(isoAttachedException);
|
expectLastCall().andThrow(isoAttachedException);
|
||||||
|
|
||||||
replay(manager, machine, vBox, hardDisk);
|
replay(manager, machine, vBox, hardDisk);
|
||||||
|
|
||||||
new AttachMediumToMachineIfNotAlreadyAttached(controllerIDE, hardDisk, controllerPort, device, HardDisk).apply(machine);
|
new AttachMediumToMachineIfNotAlreadyAttached(controllerIDE, hardDisk, controllerPort, device, HardDisk)
|
||||||
|
.apply(machine);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/**
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -19,13 +19,20 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.functions;
|
package org.jclouds.virtualbox.functions;
|
||||||
|
|
||||||
import org.testng.annotations.Test;
|
import static org.easymock.EasyMock.expect;
|
||||||
import org.virtualbox_4_1.*;
|
import static org.easymock.classextension.EasyMock.createMock;
|
||||||
|
import static org.easymock.classextension.EasyMock.createNiceMock;
|
||||||
import static org.easymock.classextension.EasyMock.*;
|
import static org.easymock.classextension.EasyMock.replay;
|
||||||
|
import static org.easymock.classextension.EasyMock.verify;
|
||||||
import static org.virtualbox_4_1.NATProtocol.TCP;
|
import static org.virtualbox_4_1.NATProtocol.TCP;
|
||||||
import static org.virtualbox_4_1.NetworkAttachmentType.NAT;
|
import static org.virtualbox_4_1.NetworkAttachmentType.NAT;
|
||||||
|
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
import org.virtualbox_4_1.IMachine;
|
||||||
|
import org.virtualbox_4_1.INATEngine;
|
||||||
|
import org.virtualbox_4_1.INetworkAdapter;
|
||||||
|
import org.virtualbox_4_1.VBoxException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mattias Holmqvist
|
* @author Mattias Holmqvist
|
||||||
*/
|
*/
|
||||||
|
@ -60,8 +67,8 @@ public class AttachNATRedirectRuleToMachineTest {
|
||||||
INetworkAdapter networkAdapter = createMock(INetworkAdapter.class);
|
INetworkAdapter networkAdapter = createMock(INetworkAdapter.class);
|
||||||
INATEngine natEngine = createMock(INATEngine.class);
|
INATEngine natEngine = createMock(INATEngine.class);
|
||||||
|
|
||||||
String error = "VirtualBox error: Argument slot is invalid " +
|
String error = "VirtualBox error: Argument slot is invalid "
|
||||||
"(must be slot < RT_ELEMENTS(mNetworkAdapters)) (0x80070057)";
|
+ "(must be slot < RT_ELEMENTS(mNetworkAdapters)) (0x80070057)";
|
||||||
|
|
||||||
VBoxException invalidSlotException = new VBoxException(createNiceMock(Throwable.class), error);
|
VBoxException invalidSlotException = new VBoxException(createNiceMock(Throwable.class), error);
|
||||||
expect(machine.getNetworkAdapter(adapterId)).andThrow(invalidSlotException);
|
expect(machine.getNetworkAdapter(adapterId)).andThrow(invalidSlotException);
|
||||||
|
@ -73,5 +80,4 @@ public class AttachNATRedirectRuleToMachineTest {
|
||||||
verify(machine, networkAdapter, natEngine);
|
verify(machine, networkAdapter, natEngine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,15 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.functions;
|
package org.jclouds.virtualbox.functions;
|
||||||
|
|
||||||
|
import static org.easymock.EasyMock.anyBoolean;
|
||||||
|
import static org.easymock.EasyMock.eq;
|
||||||
|
import static org.easymock.EasyMock.expect;
|
||||||
|
import static org.easymock.EasyMock.expectLastCall;
|
||||||
|
import static org.easymock.classextension.EasyMock.createMock;
|
||||||
|
import static org.easymock.classextension.EasyMock.createNiceMock;
|
||||||
|
import static org.easymock.classextension.EasyMock.replay;
|
||||||
|
import static org.easymock.classextension.EasyMock.verify;
|
||||||
|
|
||||||
import org.easymock.EasyMock;
|
import org.easymock.EasyMock;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
import org.virtualbox_4_1.IMachine;
|
import org.virtualbox_4_1.IMachine;
|
||||||
|
@ -26,10 +35,6 @@ import org.virtualbox_4_1.IVirtualBox;
|
||||||
import org.virtualbox_4_1.VBoxException;
|
import org.virtualbox_4_1.VBoxException;
|
||||||
import org.virtualbox_4_1.VirtualBoxManager;
|
import org.virtualbox_4_1.VirtualBoxManager;
|
||||||
|
|
||||||
import static org.easymock.EasyMock.anyBoolean;
|
|
||||||
import static org.easymock.EasyMock.expect;
|
|
||||||
import static org.easymock.classextension.EasyMock.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mattias Holmqvist
|
* @author Mattias Holmqvist
|
||||||
*/
|
*/
|
||||||
|
@ -56,7 +61,8 @@ public class CreateAndRegisterMachineFromIsoIfNotAlreadyExistsTest {
|
||||||
vBox.findMachine(vmName);
|
vBox.findMachine(vmName);
|
||||||
expectLastCall().andThrow(vBoxException);
|
expectLastCall().andThrow(vBoxException);
|
||||||
|
|
||||||
expect(vBox.createMachine(anyString(), eq(vmName), anyString(), anyString(), anyBoolean())).andReturn(createdMachine).anyTimes();
|
expect(vBox.createMachine(anyString(), eq(vmName), anyString(), anyString(), anyBoolean())).andReturn(
|
||||||
|
createdMachine).anyTimes();
|
||||||
|
|
||||||
vBox.registerMachine(createdMachine);
|
vBox.registerMachine(createdMachine);
|
||||||
|
|
||||||
|
@ -103,7 +109,6 @@ public class CreateAndRegisterMachineFromIsoIfNotAlreadyExistsTest {
|
||||||
|
|
||||||
new CreateAndRegisterMachineFromIsoIfNotAlreadyExists("", "", "", false, manager).apply(vmName);
|
new CreateAndRegisterMachineFromIsoIfNotAlreadyExists("", "", "", false, manager).apply(vmName);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String anyString() {
|
private String anyString() {
|
||||||
|
|
|
@ -19,14 +19,23 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.functions;
|
package org.jclouds.virtualbox.functions;
|
||||||
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
import org.virtualbox_4_1.*;
|
|
||||||
|
|
||||||
import static org.easymock.EasyMock.anyLong;
|
import static org.easymock.EasyMock.anyLong;
|
||||||
import static org.easymock.EasyMock.expect;
|
import static org.easymock.EasyMock.expect;
|
||||||
import static org.easymock.classextension.EasyMock.*;
|
import static org.easymock.classextension.EasyMock.createMock;
|
||||||
|
import static org.easymock.classextension.EasyMock.createNiceMock;
|
||||||
|
import static org.easymock.classextension.EasyMock.replay;
|
||||||
|
import static org.easymock.classextension.EasyMock.verify;
|
||||||
import static org.testng.Assert.assertNotSame;
|
import static org.testng.Assert.assertNotSame;
|
||||||
|
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
import org.virtualbox_4_1.DeviceType;
|
||||||
|
import org.virtualbox_4_1.IMachine;
|
||||||
|
import org.virtualbox_4_1.IMedium;
|
||||||
|
import org.virtualbox_4_1.IProgress;
|
||||||
|
import org.virtualbox_4_1.IVirtualBox;
|
||||||
|
import org.virtualbox_4_1.VBoxException;
|
||||||
|
import org.virtualbox_4_1.VirtualBoxManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mattias Holmqvist
|
* @author Mattias Holmqvist
|
||||||
*/
|
*/
|
||||||
|
@ -137,5 +146,4 @@ public class CreateMediumIfNotAlreadyExistsTest {
|
||||||
new CreateMediumIfNotAlreadyExists(manager, diskFormat, true).apply(adminDiskPath);
|
new CreateMediumIfNotAlreadyExists(manager, diskFormat, true).apply(adminDiskPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@ import org.virtualbox_4_1.VirtualBoxManager;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
//@Test(groups = "live")
|
|
||||||
public class IMachineToNodeMetadataTest {
|
public class IMachineToNodeMetadataTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -19,10 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.functions;
|
package org.jclouds.virtualbox.functions;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Andrea Turli, Mattias Holmqvist
|
|
||||||
*/
|
|
||||||
|
|
||||||
import static com.google.common.base.Predicates.equalTo;
|
import static com.google.common.base.Predicates.equalTo;
|
||||||
import static com.google.common.collect.Iterables.any;
|
import static com.google.common.collect.Iterables.any;
|
||||||
import static org.jclouds.virtualbox.experiment.TestUtils.computeServiceForLocalhostAndGuest;
|
import static org.jclouds.virtualbox.experiment.TestUtils.computeServiceForLocalhostAndGuest;
|
||||||
|
@ -47,6 +43,9 @@ import org.virtualbox_4_1.VirtualBoxManager;
|
||||||
|
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Andrea Turli, Mattias Holmqvist
|
||||||
|
*/
|
||||||
@Test(groups = "live", singleThreaded = true, testName = "IsoToIMachineLiveTest")
|
@Test(groups = "live", singleThreaded = true, testName = "IsoToIMachineLiveTest")
|
||||||
public class IsoToIMachineLiveTest extends BaseVirtualBoxClientLiveTest {
|
public class IsoToIMachineLiveTest extends BaseVirtualBoxClientLiveTest {
|
||||||
|
|
||||||
|
@ -76,24 +75,16 @@ public class IsoToIMachineLiveTest extends BaseVirtualBoxClientLiveTest {
|
||||||
public void testCreateImageMachineFromIso() throws Exception {
|
public void testCreateImageMachineFromIso() throws Exception {
|
||||||
|
|
||||||
VirtualBoxManager manager = (VirtualBoxManager) context.getProviderSpecificContext().getApi();
|
VirtualBoxManager manager = (VirtualBoxManager) context.getProviderSpecificContext().getApi();
|
||||||
ComputeServiceContext localHostContext = computeServiceForLocalhostAndGuest(hostId, "localhost", guestId, "localhost", new Credentials("toor", "password"));
|
ComputeServiceContext localHostContext = computeServiceForLocalhostAndGuest(hostId, "localhost", guestId,
|
||||||
IMachine imageMachine = new IsoToIMachine(manager,
|
"localhost", new Credentials("toor", "password"));
|
||||||
adminDisk,
|
IMachine imageMachine = new IsoToIMachine(manager, adminDisk, diskFormat, settingsFile, vmName, osTypeId, vmId,
|
||||||
diskFormat,
|
forceOverwrite, controllerIDE, localHostContext, hostId, guestId, new Credentials("toor", "password"))
|
||||||
settingsFile,
|
.apply("ubuntu-11.04-server-i386.iso");
|
||||||
vmName,
|
|
||||||
osTypeId,
|
|
||||||
vmId,
|
|
||||||
forceOverwrite,
|
|
||||||
controllerIDE,
|
|
||||||
localHostContext,
|
|
||||||
hostId,
|
|
||||||
guestId,
|
|
||||||
new Credentials("toor", "password")).apply("ubuntu-11.04-server-i386.iso");
|
|
||||||
|
|
||||||
IMachineToImage iMachineToImage = new IMachineToImage(manager, map);
|
IMachineToImage iMachineToImage = new IMachineToImage(manager, map);
|
||||||
Image newImage = iMachineToImage.apply(imageMachine);
|
Image newImage = iMachineToImage.apply(imageMachine);
|
||||||
//TODO add the description to the cache of the images or serialize to YAML the image desc
|
// TODO add the description to the cache of the images or serialize to
|
||||||
|
// YAML the image desc
|
||||||
Set<? extends Image> images = context.getComputeService().listImages();
|
Set<? extends Image> images = context.getComputeService().listImages();
|
||||||
|
|
||||||
assertTrue(any(images, equalTo(newImage)));
|
assertTrue(any(images, equalTo(newImage)));
|
||||||
|
|
|
@ -19,6 +19,11 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.functions;
|
package org.jclouds.virtualbox.functions;
|
||||||
|
|
||||||
|
import static org.easymock.EasyMock.expect;
|
||||||
|
import static org.easymock.classextension.EasyMock.createMock;
|
||||||
|
import static org.easymock.classextension.EasyMock.replay;
|
||||||
|
import static org.easymock.classextension.EasyMock.verify;
|
||||||
|
|
||||||
import org.jclouds.virtualbox.domain.ExecutionType;
|
import org.jclouds.virtualbox.domain.ExecutionType;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
import org.virtualbox_4_1.IMachine;
|
import org.virtualbox_4_1.IMachine;
|
||||||
|
@ -26,11 +31,6 @@ import org.virtualbox_4_1.IProgress;
|
||||||
import org.virtualbox_4_1.ISession;
|
import org.virtualbox_4_1.ISession;
|
||||||
import org.virtualbox_4_1.VirtualBoxManager;
|
import org.virtualbox_4_1.VirtualBoxManager;
|
||||||
|
|
||||||
import static org.easymock.classextension.EasyMock.verify;
|
|
||||||
import static org.easymock.classextension.EasyMock.replay;
|
|
||||||
import static org.easymock.classextension.EasyMock.createMock;
|
|
||||||
import static org.easymock.classextension.EasyMock.expect;
|
|
||||||
|
|
||||||
@Test(groups = "unit", testName = "LaunchMachineIfNotAlreadyRunningTest")
|
@Test(groups = "unit", testName = "LaunchMachineIfNotAlreadyRunningTest")
|
||||||
public class LaunchMachineIfNotAlreadyRunningTest {
|
public class LaunchMachineIfNotAlreadyRunningTest {
|
||||||
|
|
||||||
|
@ -40,8 +40,9 @@ public class LaunchMachineIfNotAlreadyRunningTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// VirtualBox error: The given session is busy (0x80BB0007)
|
// VirtualBox error: The given session is busy (0x80BB0007)
|
||||||
// VirtualBox error: The machine 'jclouds-image-virtualbox-iso-to-machine-test' is not registered (0x8000FFFF)
|
// VirtualBox error: The machine
|
||||||
|
// 'jclouds-image-virtualbox-iso-to-machine-test' is not registered
|
||||||
|
// (0x8000FFFF)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLaunchIfNotStarted() throws Exception {
|
public void testLaunchIfNotStarted() throws Exception {
|
||||||
|
|
|
@ -1,3 +1,22 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds 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
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "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.
|
||||||
|
*/
|
||||||
|
|
||||||
package org.jclouds.virtualbox.functions.admin;
|
package org.jclouds.virtualbox.functions.admin;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
@ -13,23 +32,6 @@ import org.testng.annotations.Test;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more contributor license
|
|
||||||
* agreements. See the NOTICE file distributed with this work for additional
|
|
||||||
* information regarding copyright ownership. jclouds 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
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "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.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author Andrea Turli
|
* @author Andrea Turli
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit")
|
@Test(groups = "unit")
|
||||||
|
|
|
@ -19,17 +19,15 @@
|
||||||
|
|
||||||
package org.jclouds.virtualbox.functions.admin;
|
package org.jclouds.virtualbox.functions.admin;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Andrea Turli
|
|
||||||
*/
|
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.jclouds.virtualbox.BaseVirtualBoxClientLiveTest;
|
import org.jclouds.virtualbox.BaseVirtualBoxClientLiveTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Andrea Turli
|
||||||
|
*/
|
||||||
@Test(groups = "live", singleThreaded = true, testName = "StartJettyIfNotAlreadyRunningLiveTest")
|
@Test(groups = "live", singleThreaded = true, testName = "StartJettyIfNotAlreadyRunningLiveTest")
|
||||||
public class StartJettyIfNotAlreadyRunningLiveTest extends BaseVirtualBoxClientLiveTest {
|
public class StartJettyIfNotAlreadyRunningLiveTest extends BaseVirtualBoxClientLiveTest {
|
||||||
|
|
||||||
|
|
|
@ -16,31 +16,33 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.virtualbox.functions.admin;
|
package org.jclouds.virtualbox.functions.admin;
|
||||||
|
|
||||||
import org.jclouds.compute.ComputeServiceContext;
|
|
||||||
import org.jclouds.domain.Credentials;
|
|
||||||
import org.jclouds.virtualbox.functions.admin.StartVBoxIfNotAlreadyRunning;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
import org.virtualbox_4_1.SessionState;
|
|
||||||
import org.virtualbox_4_1.VirtualBoxManager;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import static org.jclouds.virtualbox.experiment.TestUtils.computeServiceForLocalhostAndGuest;
|
import static org.jclouds.virtualbox.experiment.TestUtils.computeServiceForLocalhostAndGuest;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
|
import org.jclouds.domain.Credentials;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
import org.virtualbox_4_1.SessionState;
|
||||||
|
import org.virtualbox_4_1.VirtualBoxManager;
|
||||||
|
|
||||||
@Test(groups = "live", singleThreaded = true, testName = "startVBoxIfNotAlreadyRunningLiveTest")
|
@Test(groups = "live", singleThreaded = true, testName = "startVBoxIfNotAlreadyRunningLiveTest")
|
||||||
public class StartVBoxIfNotAlreadyRunningLiveTest {
|
public class StartVBoxIfNotAlreadyRunningLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStartVbox() throws Exception {
|
public void testStartVbox() throws Exception {
|
||||||
Credentials localhostCredentials = new Credentials("toor", "password");
|
Credentials localhostCredentials = new Credentials("toor", "password");
|
||||||
ComputeServiceContext localHostContext = computeServiceForLocalhostAndGuest("hostId", "localhost", "guestId", "localhost", localhostCredentials);
|
ComputeServiceContext localHostContext = computeServiceForLocalhostAndGuest("hostId", "localhost", "guestId",
|
||||||
|
"localhost", localhostCredentials);
|
||||||
|
|
||||||
URI endpointUri = URI.create("http://localhost:18083/");
|
URI endpointUri = URI.create("http://localhost:18083/");
|
||||||
|
|
||||||
VirtualBoxManager manager = new StartVBoxIfNotAlreadyRunning(localHostContext, "hostId", localhostCredentials).apply(endpointUri);
|
VirtualBoxManager manager = new StartVBoxIfNotAlreadyRunning(localHostContext, "hostId", localhostCredentials)
|
||||||
|
.apply(endpointUri);
|
||||||
|
|
||||||
assertEquals(manager.getSessionObject().getState(), SessionState.Unlocked);
|
assertEquals(manager.getSessionObject().getState(), SessionState.Unlocked);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue