mirror of https://github.com/apache/jclouds.git
moving forward no more guice errors
This commit is contained in:
parent
80f6b65d4b
commit
c015f9f699
|
@ -19,7 +19,8 @@
|
|||
under the License.
|
||||
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.jclouds</groupId>
|
||||
|
@ -42,6 +43,8 @@
|
|||
<test.virtualbox.image-id>ubuntu-11.04-server-i386</test.virtualbox.image-id>
|
||||
<test.virtualbox.image.login-user>toor:password</test.virtualbox.image.login-user>
|
||||
<test.virtualbox.image.authenticate-sudo>true</test.virtualbox.image.authenticate-sudo>
|
||||
<test.virtualbox.image.authenticate-sudo>true</test.virtualbox.image.authenticate-sudo>
|
||||
<test.virtualbox.image.descriptor.yaml>target/test-classes/testImages.yaml</test.virtualbox.image.descriptor.yaml>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
@ -70,6 +73,11 @@
|
|||
<artifactId>jetty-server</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jclouds</groupId>
|
||||
<artifactId>jclouds-core</artifactId>
|
||||
|
@ -141,6 +149,7 @@
|
|||
<test.virtualbox.image-id>${test.virtualbox.image-id}</test.virtualbox.image-id>
|
||||
<test.virtualbox.image.login-user>${test.virtualbox.image.login-user}</test.virtualbox.image.login-user>
|
||||
<test.virtualbox.image.authenticate-sudo>${test.virtualbox.image.authenticate-sudo}</test.virtualbox.image.authenticate-sudo>
|
||||
<test.virtualbox.image.descriptor.yaml>${test.virtualbox.image.descriptor.yaml}</test.virtualbox.image.descriptor.yaml>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
|
@ -24,13 +24,18 @@ import static org.jclouds.Constants.PROPERTY_BUILD_VERSION;
|
|||
import static org.jclouds.Constants.PROPERTY_CREDENTIAL;
|
||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||
import static org.jclouds.Constants.PROPERTY_IDENTITY;
|
||||
import static org.jclouds.compute.reference.ComputeServiceConstants.PROPERTY_IMAGE_AUTHENTICATE_SUDO;
|
||||
import static org.jclouds.compute.reference.ComputeServiceConstants.PROPERTY_IMAGE_LOGIN_USER;
|
||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_DEFAULT_DIR;
|
||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGES_DESCRIPTOR;
|
||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_INSTALLATION_KEY_SEQUENCE;
|
||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_PRECONFIGURATION_URL;
|
||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_WORKINGDIR;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.PropertiesBuilder;
|
||||
import static org.jclouds.compute.reference.ComputeServiceConstants.*;
|
||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.*;
|
||||
|
||||
/**
|
||||
* Builds properties for VirtualBox integration.
|
||||
|
@ -57,33 +62,30 @@ public class VirtualBoxPropertiesBuilder extends PropertiesBuilder {
|
|||
properties.put(PROPERTY_IDENTITY, "administrator");
|
||||
properties.put(PROPERTY_CREDENTIAL, "12345");
|
||||
|
||||
properties.put(PROPERTY_IMAGE_ID, "ubuntu-11.04-server-i386");
|
||||
properties.put(PROPERTY_IMAGE_LOGIN_USER, "toor:password");
|
||||
properties.put(PROPERTY_IMAGE_AUTHENTICATE_SUDO, "true");
|
||||
|
||||
properties.put(VIRTUALBOX_ISO_URL, "http://releases.ubuntu.com/11.04/ubuntu-11.04-server-i386.iso");
|
||||
properties.put(VIRTUALBOX_INSTALLATION_KEY_SEQUENCE, "<Esc><Esc><Enter> "
|
||||
+ "/install/vmlinuz noapic preseed/url=PRECONFIGURATION_URL "
|
||||
+ "debian-installer=en_US auto locale=en_US kbd-chooser/method=us "
|
||||
+ "hostname=" + "HOSTNAME "
|
||||
+ "debian-installer=en_US auto locale=en_US kbd-chooser/method=us " + "hostname=" + "HOSTNAME "
|
||||
+ "fb=false debconf/frontend=noninteractive "
|
||||
+ "keyboard-configuration/layout=USA keyboard-configuration/variant=USA console-setup/ask_detect=false "
|
||||
+ "initrd=/install/initrd.gz -- <Enter>");
|
||||
|
||||
properties.put(VIRTUALBOX_WORKINGDIR, System.getProperty("user.home") + File.separator
|
||||
+ System.getProperty("test.virtualbox.workingDir", ".jclouds-virtualbox"));
|
||||
|
||||
properties.put(VIRTUALBOX_IMAGES_DESCRIPTOR,
|
||||
properties.put(
|
||||
VIRTUALBOX_WORKINGDIR,
|
||||
System.getProperty("user.home") + File.separator
|
||||
+ System.getProperty("test.virtualbox.image.descriptor.yaml", "images.yaml"));
|
||||
+ System.getProperty("test.virtualbox.workingDir", ".jclouds-vbox"));
|
||||
|
||||
// allow to set the descriptor as a sysprop but default to just setting a default file path. The configured supplier
|
||||
// must be able to handle the chosen option.
|
||||
properties.put(
|
||||
VIRTUALBOX_IMAGES_DESCRIPTOR,
|
||||
System.getProperty("test.virtualbox.image.descriptor.yaml", VIRTUALBOX_DEFAULT_DIR + File.separator
|
||||
+ "images.yaml"));
|
||||
|
||||
properties.put(VIRTUALBOX_PRECONFIGURATION_URL, "http://10.0.2.2:8080/src/test/resources/preseed.cfg");
|
||||
|
||||
|
||||
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,8 +22,9 @@ package org.jclouds.virtualbox.compute;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.collect.Iterables.filter;
|
||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGE_PREFIX;
|
||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_NODE_PREFIX;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
|
@ -32,6 +33,7 @@ import org.jclouds.compute.domain.Image;
|
|||
import org.jclouds.compute.domain.Template;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.virtualbox.domain.YamlImage;
|
||||
import org.virtualbox_4_1.CleanupMode;
|
||||
import org.virtualbox_4_1.IMachine;
|
||||
import org.virtualbox_4_1.IProgress;
|
||||
|
@ -49,8 +51,7 @@ import com.google.common.collect.Iterables;
|
|||
import com.google.inject.Singleton;
|
||||
|
||||
/**
|
||||
* Defines the connection between the
|
||||
* {@link org.virtualbox_4_1.VirtualBoxManager} implementation and the jclouds
|
||||
* Defines the connection between the {@link org.virtualbox_4_1.VirtualBoxManager} implementation and the jclouds
|
||||
* {@link org.jclouds.compute.ComputeService}
|
||||
*
|
||||
* @author Mattias Holmqvist, Andrea Turli
|
||||
|
@ -59,36 +60,39 @@ import com.google.inject.Singleton;
|
|||
public class VirtualBoxComputeServiceAdapter implements ComputeServiceAdapter<IMachine, IMachine, Image, Location> {
|
||||
|
||||
private final Supplier<VirtualBoxManager> manager;
|
||||
private final Function<IMachine, Image> iMachineToImage;
|
||||
private final Function<String, LoadingCache<String, Image>> images;
|
||||
private final Supplier<String> imagesDescSupplier;
|
||||
private final Map<Image, YamlImage> images;
|
||||
private final LoadingCache<Image, IMachine> mastersLoader;
|
||||
private final Function<IMachine, NodeAndInitialCredentials<IMachine>> cloneCreator;
|
||||
|
||||
@Inject
|
||||
public VirtualBoxComputeServiceAdapter(Supplier<VirtualBoxManager> manager,
|
||||
Function<IMachine, Image> iMachineToImage,
|
||||
Function<String, LoadingCache<String, Image>> images,
|
||||
Supplier<String> imagesStreamSupplier) {
|
||||
this.iMachineToImage = iMachineToImage;
|
||||
Function<String, Map<Image, YamlImage>> imagesMapper,
|
||||
LoadingCache<Image, IMachine> mastersLoader, Supplier<String> imagesDescSupplier,
|
||||
Function<IMachine, NodeAndInitialCredentials<IMachine>> cloneCreator) {
|
||||
this.manager = checkNotNull(manager, "manager");
|
||||
this.images = images;
|
||||
this.imagesDescSupplier = imagesStreamSupplier;
|
||||
this.images = imagesMapper.apply(imagesDescSupplier.get());
|
||||
this.mastersLoader = mastersLoader;
|
||||
this.cloneCreator = cloneCreator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeAndInitialCredentials<IMachine> createNodeWithGroupEncodedIntoName(String tag, String name,
|
||||
Template template) {
|
||||
return null;
|
||||
try {
|
||||
IMachine master = mastersLoader.get(template.getImage());
|
||||
return cloneCreator.apply(master);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<IMachine> listNodes() {
|
||||
return Iterables.filter(manager.get().getVBox().getMachines(), new Predicate<IMachine>() {
|
||||
|
||||
@Override
|
||||
public boolean apply(IMachine arg0) {
|
||||
return !arg0.getName().startsWith(VIRTUALBOX_IMAGE_PREFIX);
|
||||
return !arg0.getName().startsWith(VIRTUALBOX_NODE_PREFIX);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -99,7 +103,7 @@ public class VirtualBoxComputeServiceAdapter implements ComputeServiceAdapter<IM
|
|||
|
||||
@Override
|
||||
public Iterable<Image> listImages() {
|
||||
return images.apply(imagesDescSupplier.get()).asMap().values();
|
||||
return images.keySet();
|
||||
}
|
||||
|
||||
private Iterable<IMachine> imageMachines() {
|
||||
|
@ -116,7 +120,7 @@ public class VirtualBoxComputeServiceAdapter implements ComputeServiceAdapter<IM
|
|||
@Override
|
||||
public Iterable<Location> listLocations() {
|
||||
// Not using the adapter to determine locations
|
||||
return ImmutableSet.<Location>of();
|
||||
return ImmutableSet.<Location> of();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
package org.jclouds.virtualbox.config;
|
||||
|
||||
public class LocalFileYamlStreamSupplier {
|
||||
|
||||
}
|
|
@ -34,6 +34,7 @@ import org.jclouds.byon.Node;
|
|||
import org.jclouds.byon.functions.NodeToNodeMetadata;
|
||||
import org.jclouds.byon.suppliers.SupplyFromProviderURIOrNodesProperty;
|
||||
import org.jclouds.compute.ComputeServiceAdapter;
|
||||
import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials;
|
||||
import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
||||
import org.jclouds.compute.domain.Hardware;
|
||||
import org.jclouds.compute.domain.Image;
|
||||
|
@ -50,10 +51,16 @@ import org.jclouds.virtualbox.Preconfiguration;
|
|||
import org.jclouds.virtualbox.compute.VirtualBoxComputeServiceAdapter;
|
||||
import org.jclouds.virtualbox.domain.ExecutionType;
|
||||
import org.jclouds.virtualbox.domain.IsoSpec;
|
||||
import org.jclouds.virtualbox.domain.MasterSpec;
|
||||
import org.jclouds.virtualbox.domain.YamlImage;
|
||||
import org.jclouds.virtualbox.functions.IMachineToHardware;
|
||||
import org.jclouds.virtualbox.functions.IMachineToImage;
|
||||
import org.jclouds.virtualbox.functions.IMachineToNodeMetadata;
|
||||
import org.jclouds.virtualbox.functions.IMachineToSshClient;
|
||||
import org.jclouds.virtualbox.functions.MasterImages;
|
||||
import org.jclouds.virtualbox.functions.MasterLoader;
|
||||
import org.jclouds.virtualbox.functions.NodeCreator;
|
||||
import org.jclouds.virtualbox.functions.YamlImagesFromFileConfig;
|
||||
import org.jclouds.virtualbox.functions.admin.ImageFromYamlString;
|
||||
import org.jclouds.virtualbox.functions.admin.StartJettyIfNotAlreadyRunning;
|
||||
import org.jclouds.virtualbox.functions.admin.StartVBoxIfNotAlreadyRunning;
|
||||
|
@ -107,8 +114,22 @@ public class VirtualBoxComputeServiceContextModule extends
|
|||
}).to((Class) StartJettyIfNotAlreadyRunning.class);
|
||||
bind(new TypeLiteral<Supplier<VirtualBoxManager>>() {
|
||||
}).to((Class) StartVBoxIfNotAlreadyRunning.class);
|
||||
bind(new TypeLiteral<Function<InputStream, LoadingCache<String, Image>>>() {
|
||||
// the yaml config to image mapper
|
||||
bind(new TypeLiteral<Function<String, Map<Image, YamlImage>>>() {
|
||||
}).to((Class) ImageFromYamlString.class);
|
||||
// the yaml config provider
|
||||
bind(new TypeLiteral<Supplier<String>>() {
|
||||
}).to((Class)YamlImagesFromFileConfig.class);
|
||||
// the master machines cache
|
||||
bind(new TypeLiteral<LoadingCache<Image, IMachine>>() {
|
||||
}).to((Class)MasterImages.class);
|
||||
// the master machines loading/creating function
|
||||
bind(new TypeLiteral<Function<MasterSpec, IMachine>>() {
|
||||
}).to((Class)MasterLoader.class);
|
||||
// the machine cloning function
|
||||
bind(new TypeLiteral<Function<IMachine, NodeAndInitialCredentials<IMachine>>>() {
|
||||
}).to((Class)NodeCreator.class);
|
||||
|
||||
// for byon
|
||||
bind(new TypeLiteral<Function<URI, InputStream>>() {
|
||||
}).to(SupplyFromProviderURIOrNodesProperty.class);
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
package org.jclouds.virtualbox.config;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Configuration properties used for interacting with VirtualBox instances.
|
||||
*
|
||||
|
@ -29,6 +31,8 @@ public interface VirtualBoxConstants {
|
|||
|
||||
public static final String VIRTUALBOX_IMAGE_PREFIX = "jclouds-image-";
|
||||
|
||||
public static final String VIRTUALBOX_NODE_PREFIX = "jclouds-node-";
|
||||
|
||||
public static final String VIRTUALBOX_PRECONFIGURATION_URL = "jclouds.virtualbox.preconfigurationurl";
|
||||
|
||||
public static final String VIRTUALBOX_INSTALLATION_KEY_SEQUENCE = "jclouds.virtualbox.installationkeysequence";
|
||||
|
@ -37,8 +41,6 @@ public interface VirtualBoxConstants {
|
|||
|
||||
public static final String VIRTUALBOX_IMAGES_DESCRIPTOR = "jclouds.virtualbox.image.descriptor.yaml";
|
||||
|
||||
public static final String VIRTUALBOX_ISO_URL = "jclouds.virtualbox.isourl";
|
||||
|
||||
public static final String VIRTUALBOX_MACHINE_GROUP = "jclouds.virtualbox.machinegroup";
|
||||
|
||||
public static final String VIRTUALBOX_MACHINE_USERNAME = "jclouds.virtualbox.username";
|
||||
|
@ -53,4 +55,7 @@ public interface VirtualBoxConstants {
|
|||
|
||||
public static final String VIRTUALBOX_WEBSERVER_CREDENTIAL = "jclouds.virtualbox.webserver.credential";
|
||||
|
||||
public static final String VIRTUALBOX_DEFAULT_DIR = System.getProperty("user.home")
|
||||
+ File.separator +".jclouds-vbox";
|
||||
|
||||
}
|
||||
|
|
|
@ -19,10 +19,11 @@
|
|||
|
||||
package org.jclouds.virtualbox.domain;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.virtualbox_4_1.DeviceType;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
* Represents a specification for a device attachment.
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
*/
|
||||
package org.jclouds.virtualbox.domain;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
* Represents an optical medium (DVD) in a VirtualBox VM.
|
||||
* <p/>
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
|
||||
package org.jclouds.virtualbox.domain;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
* A complete specification of a "master" node, including the ISO, networking setup
|
||||
* and the physical machine specification.
|
||||
|
|
|
@ -19,14 +19,15 @@
|
|||
|
||||
package org.jclouds.virtualbox.domain;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.virtualbox_4_1.NATProtocol;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import org.virtualbox_4_1.NATProtocol;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* Represents a NAT network adapter in VirtualBox.
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
|
||||
package org.jclouds.virtualbox.domain;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
* Describes the network configuration for a VirtualBox machine.
|
||||
|
|
|
@ -18,10 +18,11 @@
|
|||
*/
|
||||
package org.jclouds.virtualbox.domain;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.virtualbox_4_1.NATProtocol;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
* @author Mattias Holmqvist
|
||||
|
|
|
@ -18,14 +18,17 @@
|
|||
*/
|
||||
package org.jclouds.virtualbox.domain;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import org.virtualbox_4_1.CleanupMode;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.virtualbox_4_1.CleanupMode;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
* A description of a Virtual Machine in VirtualBox.
|
||||
*/
|
||||
|
|
|
@ -19,25 +19,40 @@
|
|||
|
||||
package org.jclouds.virtualbox.functions;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.virtualbox.config.VirtualBoxConstants;
|
||||
import org.jclouds.virtualbox.domain.*;
|
||||
import org.jclouds.virtualbox.util.MachineUtils;
|
||||
import org.virtualbox_4_1.*;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.virtualbox.config.VirtualBoxConstants;
|
||||
import org.jclouds.virtualbox.domain.DeviceDetails;
|
||||
import org.jclouds.virtualbox.domain.HardDisk;
|
||||
import org.jclouds.virtualbox.domain.IsoImage;
|
||||
import org.jclouds.virtualbox.domain.MasterSpec;
|
||||
import org.jclouds.virtualbox.domain.NatAdapter;
|
||||
import org.jclouds.virtualbox.domain.NetworkSpec;
|
||||
import org.jclouds.virtualbox.domain.StorageController;
|
||||
import org.jclouds.virtualbox.domain.VmSpec;
|
||||
import org.jclouds.virtualbox.util.MachineUtils;
|
||||
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.IVirtualBox;
|
||||
import org.virtualbox_4_1.VBoxException;
|
||||
import org.virtualbox_4_1.VirtualBoxManager;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
|
||||
/**
|
||||
* @author Mattias Holmqvist
|
||||
|
|
|
@ -28,7 +28,11 @@ 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.IMachine;
|
||||
import org.virtualbox_4_1.IProgress;
|
||||
import org.virtualbox_4_1.SessionState;
|
||||
import org.virtualbox_4_1.VBoxException;
|
||||
import org.virtualbox_4_1.VirtualBoxManager;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
|
|
|
@ -0,0 +1,141 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_DEFAULT_DIR;
|
||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGE_PREFIX;
|
||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_INSTALLATION_KEY_SEQUENCE;
|
||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_WORKINGDIR;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.config.ValueOfConfigurationKeyOrNull;
|
||||
import org.jclouds.virtualbox.domain.HardDisk;
|
||||
import org.jclouds.virtualbox.domain.IsoSpec;
|
||||
import org.jclouds.virtualbox.domain.MasterSpec;
|
||||
import org.jclouds.virtualbox.domain.NatAdapter;
|
||||
import org.jclouds.virtualbox.domain.NetworkSpec;
|
||||
import org.jclouds.virtualbox.domain.StorageController;
|
||||
import org.jclouds.virtualbox.domain.VmSpec;
|
||||
import org.jclouds.virtualbox.domain.YamlImage;
|
||||
import org.virtualbox_4_1.CleanupMode;
|
||||
import org.virtualbox_4_1.IMachine;
|
||||
import org.virtualbox_4_1.StorageBus;
|
||||
|
||||
import com.beust.jcommander.internal.Maps;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.cache.AbstractLoadingCache;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
* Does most of the work wrt to creating the master image.
|
||||
*
|
||||
* @author dralves
|
||||
*
|
||||
*/
|
||||
public class MasterImages extends AbstractLoadingCache<Image, IMachine> {
|
||||
|
||||
private final Map<Image, IMachine> masters = Maps.newHashMap();
|
||||
private final Function<MasterSpec, IMachine> mastersLoader;
|
||||
private final Map<Image, YamlImage> imageMapping;
|
||||
private final ValueOfConfigurationKeyOrNull cfg;
|
||||
private final String workingDir;
|
||||
private final String adminDisk;
|
||||
private String guestAdditionsIso;
|
||||
|
||||
@Inject
|
||||
public MasterImages(@Named(Constants.PROPERTY_BUILD_VERSION) String version,
|
||||
Function<MasterSpec, IMachine> masterLoader, ValueOfConfigurationKeyOrNull cfg, Supplier<String> yamlSupplier,
|
||||
Function<String, Map<Image, YamlImage>> yamlMapper) {
|
||||
checkNotNull(version, "version");
|
||||
this.mastersLoader = masterLoader;
|
||||
this.cfg = cfg;
|
||||
this.workingDir = cfg.apply(VIRTUALBOX_WORKINGDIR) == null ? VIRTUALBOX_DEFAULT_DIR : cfg
|
||||
.apply(VIRTUALBOX_WORKINGDIR);
|
||||
File wdFile = new File(workingDir);
|
||||
if (!wdFile.exists()) {
|
||||
wdFile.mkdirs();
|
||||
}
|
||||
this.adminDisk = workingDir + "/testadmin.vdi";
|
||||
this.imageMapping = yamlMapper.apply(yamlSupplier.get());
|
||||
this.guestAdditionsIso = String.format("%s/VBoxGuestAdditions_%s.iso", workingDir,
|
||||
Iterables.get(Splitter.on('r').split(version), 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMachine get(Image key) throws ExecutionException {
|
||||
if (masters.containsKey(key)) {
|
||||
return masters.get(key);
|
||||
}
|
||||
|
||||
checkState(new File(guestAdditionsIso).exists(), "guest additions iso does not exist at: " + guestAdditionsIso);
|
||||
|
||||
YamlImage yamlImage = imageMapping.get(key);
|
||||
|
||||
String vmName = VIRTUALBOX_IMAGE_PREFIX + yamlImage.id;
|
||||
|
||||
HardDisk hardDisk = HardDisk.builder().diskpath(adminDisk).autoDelete(true).controllerPort(0).deviceSlot(1).build();
|
||||
|
||||
StorageController ideController = StorageController.builder().name("IDE Controller").bus(StorageBus.IDE)
|
||||
.attachISO(0, 0, yamlImage.iso).attachHardDisk(hardDisk).attachISO(1, 1, guestAdditionsIso).build();
|
||||
|
||||
VmSpec vmSpecification = VmSpec.builder().id(yamlImage.id).name(vmName).memoryMB(512).osTypeId("")
|
||||
.controller(ideController).forceOverwrite(true).cleanUpMode(CleanupMode.Full).build();
|
||||
|
||||
MasterSpec masterSpec = MasterSpec
|
||||
.builder()
|
||||
.vm(vmSpecification)
|
||||
.iso(
|
||||
IsoSpec
|
||||
.builder()
|
||||
.sourcePath(yamlImage.iso)
|
||||
.installationScript(
|
||||
cfg.apply(VIRTUALBOX_INSTALLATION_KEY_SEQUENCE).replace("HOSTNAME", vmSpecification.getVmName()))
|
||||
.build())
|
||||
.network(
|
||||
NetworkSpec.builder()
|
||||
.natNetworkAdapter(0, NatAdapter.builder().tcpRedirectRule("127.0.0.1", 2222, "", 22).build()).build())
|
||||
.build();
|
||||
|
||||
IMachine masterMachine = mastersLoader.apply(masterSpec);
|
||||
masters.put(key, masterMachine);
|
||||
return masterMachine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMachine getIfPresent(Image key) {
|
||||
if (masters.containsKey(key)) {
|
||||
return masters.get(key);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package org.jclouds.virtualbox.functions;
|
||||
|
||||
import org.jclouds.virtualbox.domain.MasterSpec;
|
||||
import org.virtualbox_4_1.IMachine;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
public class MasterLoader implements Function<MasterSpec, IMachine> {
|
||||
|
||||
@Override
|
||||
public IMachine apply(MasterSpec input) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package org.jclouds.virtualbox.functions;
|
||||
|
||||
import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials;
|
||||
import org.virtualbox_4_1.IMachine;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
public class NodeCreator implements Function<IMachine, NodeAndInitialCredentials<IMachine>> {
|
||||
|
||||
@Override
|
||||
public NodeAndInitialCredentials<IMachine> apply(IMachine input) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.jclouds.virtualbox.config.VirtualBoxConstants;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
|
||||
/**
|
||||
* A supplier for vbox yaml config that reads a yaml whose path is stored under
|
||||
* VirtualBoxConstants.VIRTUALBOX_IMAGES_DESCRIPTOR.
|
||||
*
|
||||
* @author dralves
|
||||
*
|
||||
*/
|
||||
public class YamlImagesFromFileConfig implements Supplier<String> {
|
||||
|
||||
private String yamlFilePath;
|
||||
|
||||
@Inject
|
||||
public YamlImagesFromFileConfig(@Named(VirtualBoxConstants.VIRTUALBOX_IMAGES_DESCRIPTOR) String yamlFilePath) {
|
||||
this.yamlFilePath = yamlFilePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get() {
|
||||
checkNotNull(yamlFilePath, "yaml file path");
|
||||
File yamlFile = new File(yamlFilePath);
|
||||
checkState(yamlFile.exists(), "yaml file does not exist at: " + yamlFilePath);
|
||||
try {
|
||||
return IOUtils.toString(new FileInputStream(yamlFile));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("error reading yaml file");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.jclouds.virtualbox.functions.admin;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -33,19 +34,13 @@ 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.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Andrea Turli
|
||||
*/
|
||||
@Singleton
|
||||
public class ImageFromYamlString implements Function<String, LoadingCache<String, Image>> {
|
||||
public class ImageFromYamlString implements Function<String, Map<Image, YamlImage>> {
|
||||
|
||||
/**
|
||||
* Type-safe config class for YAML
|
||||
|
@ -56,7 +51,10 @@ public class ImageFromYamlString implements Function<String, LoadingCache<String
|
|||
}
|
||||
|
||||
@Override
|
||||
public LoadingCache<String, Image> apply(String source) {
|
||||
public Map<Image, YamlImage> apply(String source) {
|
||||
|
||||
checkNotNull(source, "yaml descriptor");
|
||||
checkState(!source.equals(""),"yaml descriptor is empty");
|
||||
|
||||
Constructor constructor = new Constructor(Config.class);
|
||||
|
||||
|
@ -69,17 +67,11 @@ public class ImageFromYamlString implements Function<String, LoadingCache<String
|
|||
checkState(config != null, "missing config: class");
|
||||
checkState(config.images != null, "missing images: collection");
|
||||
|
||||
|
||||
Map<String, Image> backingMap = Maps.uniqueIndex(Iterables.transform(config.images, YamlImage.toImage),
|
||||
new Function<Image, String>() {
|
||||
public String apply(Image image) {
|
||||
return image.getId();
|
||||
Map<Image, YamlImage> backingMap = Maps.newLinkedHashMap();
|
||||
for (YamlImage yamlImage : config.images) {
|
||||
backingMap.put(YamlImage.toImage.apply(yamlImage), yamlImage);
|
||||
}
|
||||
});
|
||||
LoadingCache<String, Image> cache = CacheBuilder.newBuilder().build(CacheLoader.from(Functions.forMap(backingMap)));
|
||||
for (String node : backingMap.keySet())
|
||||
cache.getUnchecked(node);
|
||||
return cache;
|
||||
return backingMap;
|
||||
}
|
||||
|
||||
}
|
|
@ -18,9 +18,16 @@
|
|||
*/
|
||||
package org.jclouds.virtualbox.util;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.inject.Inject;
|
||||
import static org.jclouds.compute.options.RunScriptOptions.Builder.runAsRoot;
|
||||
import static org.jclouds.scriptbuilder.domain.Statements.call;
|
||||
import static org.jclouds.scriptbuilder.domain.Statements.findPid;
|
||||
import static org.jclouds.scriptbuilder.domain.Statements.kill;
|
||||
import static org.jclouds.scriptbuilder.domain.Statements.newStatementList;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.callables.RunScriptOnNode;
|
||||
import org.jclouds.compute.callables.RunScriptOnNode.Factory;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
|
@ -29,14 +36,16 @@ import org.jclouds.logging.Logger;
|
|||
import org.jclouds.scriptbuilder.domain.Statement;
|
||||
import org.jclouds.util.Throwables2;
|
||||
import org.jclouds.virtualbox.functions.MutableMachine;
|
||||
import org.virtualbox_4_1.*;
|
||||
import org.virtualbox_4_1.IMachine;
|
||||
import org.virtualbox_4_1.ISession;
|
||||
import org.virtualbox_4_1.LockType;
|
||||
import org.virtualbox_4_1.SessionState;
|
||||
import org.virtualbox_4_1.VBoxException;
|
||||
import org.virtualbox_4_1.VirtualBoxManager;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import static org.jclouds.compute.options.RunScriptOptions.Builder.runAsRoot;
|
||||
import static org.jclouds.scriptbuilder.domain.Statements.*;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
* Utilities for executing functions on a VirtualBox machine.
|
||||
|
|
|
@ -19,16 +19,9 @@
|
|||
|
||||
package org.jclouds.virtualbox;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.byon.Node;
|
||||
import org.jclouds.byon.config.CacheNodeStoreModule;
|
||||
|
@ -51,8 +44,16 @@ import org.testng.annotations.BeforeClass;
|
|||
import org.testng.annotations.Test;
|
||||
import org.virtualbox_4_1.VirtualBoxManager;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code VirtualBoxClient}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
package org.jclouds.virtualbox.compute;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials;
|
||||
|
@ -57,7 +56,10 @@ public class VirtualBoxComputeServiceAdapterLiveTest extends BaseVirtualBoxClien
|
|||
public void testCreateNodeWithGroupEncodedIntoNameThenStoreCredentials() {
|
||||
String group = "foo";
|
||||
String name = "foo-ef4";
|
||||
Template template = context.getComputeService().templateBuilder().build();
|
||||
// get the image from
|
||||
Image image = Iterables.get(adapter.listImages(),0);
|
||||
System.out.println(context.getComputeService().templateBuilder());
|
||||
Template template = context.getComputeService().templateBuilder().fromImage(image).build();
|
||||
machine = adapter.createNodeWithGroupEncodedIntoName(group, name, template);
|
||||
assertEquals(machine.getNode().getName(), name);
|
||||
assertEquals(machine.getNodeId(), machine.getNode().getId());
|
||||
|
|
|
@ -23,10 +23,8 @@ import static org.easymock.EasyMock.createNiceMock;
|
|||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.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;
|
||||
|
||||
|
@ -38,7 +36,6 @@ import org.jclouds.compute.reference.ComputeServiceConstants;
|
|||
import org.jclouds.json.Json;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.virtualbox.functions.IMachineToImage;
|
||||
import org.jclouds.virtualbox.functions.admin.ImageFromYamlString;
|
||||
import org.testng.annotations.Test;
|
||||
import org.virtualbox_4_1.IGuestOSType;
|
||||
import org.virtualbox_4_1.IMachine;
|
||||
|
@ -46,9 +43,7 @@ import org.virtualbox_4_1.IVirtualBox;
|
|||
import org.virtualbox_4_1.VirtualBoxManager;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.inject.Guice;
|
||||
|
||||
@Test(groups = "unit")
|
||||
|
@ -85,25 +80,25 @@ public class VirtualBoxComputeServiceAdapterTest {
|
|||
replay(manager, vBox, clonedMachine, imageMachine, osType);
|
||||
|
||||
Function<IMachine, Image> iMachineToImage = new IMachineToImage(Suppliers.ofInstance(manager), osMap);
|
||||
VirtualBoxComputeServiceAdapter adapter = new VirtualBoxComputeServiceAdapter(Suppliers.ofInstance(manager), iMachineToImage, new ImageFromYamlString(), new Supplier<String>() {
|
||||
|
||||
@Override
|
||||
public String get() {
|
||||
return "images:\n" +
|
||||
" - id: myTestId\n" +
|
||||
" name: ubuntu-11.04-server-i386\n" +
|
||||
" description: ubuntu 11.04 server (i386)\n" +
|
||||
" os_arch: x86\n" +
|
||||
" os_family: ubuntu\n" +
|
||||
" os_description: ubuntu\n" +
|
||||
" os_version: 11.04\n" +
|
||||
" iso: http://releases.ubuntu.com/11.04/ubuntu-11.04-server-i386.iso";
|
||||
}
|
||||
});
|
||||
|
||||
Iterator<Image> iterator = adapter.listImages().iterator();
|
||||
Image image = Iterators.getOnlyElement(iterator);
|
||||
assertEquals(image.getDescription(), "ubuntu 11.04 server (i386)");
|
||||
// VirtualBoxComputeServiceAdapter adapter = new VirtualBoxComputeServiceAdapter(Suppliers.ofInstance(manager), iMachineToImage, new ImageFromYamlString(), new Supplier<String>() {
|
||||
//
|
||||
// @Override
|
||||
// public String get() {
|
||||
// return "images:\n" +
|
||||
// " - id: myTestId\n" +
|
||||
// " name: ubuntu-11.04-server-i386\n" +
|
||||
// " description: ubuntu 11.04 server (i386)\n" +
|
||||
// " os_arch: x86\n" +
|
||||
// " os_family: ubuntu\n" +
|
||||
// " os_description: ubuntu\n" +
|
||||
// " os_version: 11.04\n" +
|
||||
// " iso: http://releases.ubuntu.com/11.04/ubuntu-11.04-server-i386.iso";
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// Iterator<Image> iterator = adapter.listImages().iterator();
|
||||
// Image image = Iterators.getOnlyElement(iterator);
|
||||
// assertEquals(image.getDescription(), "ubuntu 11.04 server (i386)");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,12 @@
|
|||
|
||||
package org.jclouds.virtualbox.functions;
|
||||
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.createNiceMock;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
|
||||
import org.jclouds.virtualbox.domain.StorageController;
|
||||
import org.testng.annotations.Test;
|
||||
import org.virtualbox_4_1.IMachine;
|
||||
|
@ -26,9 +32,6 @@ import org.virtualbox_4_1.IStorageController;
|
|||
import org.virtualbox_4_1.StorageBus;
|
||||
import org.virtualbox_4_1.VBoxException;
|
||||
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.classextension.EasyMock.*;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
|
||||
package org.jclouds.virtualbox.functions;
|
||||
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.createNiceMock;
|
||||
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 static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
import org.virtualbox_4_1.IMachine;
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
*/
|
||||
package org.jclouds.virtualbox.functions;
|
||||
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.createNiceMock;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
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.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
import static org.virtualbox_4_1.NetworkAdapterType.Am79C973;
|
||||
import static org.virtualbox_4_1.NetworkAttachmentType.Bridged;
|
||||
|
||||
|
|
|
@ -21,12 +21,12 @@ package org.jclouds.virtualbox.functions;
|
|||
|
||||
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||
import static org.easymock.EasyMock.anyLong;
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.createNiceMock;
|
||||
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 static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
|
||||
import org.jclouds.virtualbox.domain.DeviceDetails;
|
||||
import org.jclouds.virtualbox.domain.HardDisk;
|
||||
|
|
|
@ -31,9 +31,6 @@ import org.jclouds.virtualbox.domain.MasterSpec;
|
|||
import org.jclouds.virtualbox.domain.NetworkSpec;
|
||||
import org.jclouds.virtualbox.domain.StorageController;
|
||||
import org.jclouds.virtualbox.domain.VmSpec;
|
||||
import org.jclouds.virtualbox.functions.CloneAndRegisterMachineFromIMachineIfNotAlreadyExists;
|
||||
import org.jclouds.virtualbox.functions.CreateAndRegisterMachineFromIsoIfNotAlreadyExists;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
import org.virtualbox_4_1.CleanupMode;
|
||||
|
|
|
@ -23,15 +23,22 @@ import static org.testng.Assert.fail;
|
|||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
import org.jclouds.virtualbox.BaseVirtualBoxClientLiveTest;
|
||||
import org.jclouds.virtualbox.domain.*;
|
||||
import org.jclouds.virtualbox.domain.ErrorCode;
|
||||
import org.jclouds.virtualbox.domain.HardDisk;
|
||||
import org.jclouds.virtualbox.domain.IsoSpec;
|
||||
import org.jclouds.virtualbox.domain.MasterSpec;
|
||||
import org.jclouds.virtualbox.domain.NetworkSpec;
|
||||
import org.jclouds.virtualbox.domain.StorageController;
|
||||
import org.jclouds.virtualbox.domain.VmSpec;
|
||||
import org.testng.annotations.Test;
|
||||
import org.virtualbox_4_1.CleanupMode;
|
||||
import org.virtualbox_4_1.IMachine;
|
||||
import org.virtualbox_4_1.StorageBus;
|
||||
import org.virtualbox_4_1.VBoxException;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* @author Mattias Holmqvist
|
||||
*/
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
*/
|
||||
package org.jclouds.virtualbox.functions;
|
||||
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.createNiceMock;
|
||||
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 static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
import org.virtualbox_4_1.IMachine;
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
|
||||
package org.jclouds.virtualbox.functions;
|
||||
|
||||
import static org.easymock.EasyMock.createNiceMock;
|
||||
import static org.easymock.EasyMock.eq;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.classextension.EasyMock.createNiceMock;
|
||||
import static org.easymock.classextension.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.compute.domain.Hardware;
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
|
||||
package org.jclouds.virtualbox.functions;
|
||||
|
||||
import static org.easymock.EasyMock.createNiceMock;
|
||||
import static org.easymock.EasyMock.eq;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.classextension.EasyMock.createNiceMock;
|
||||
import static org.easymock.classextension.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.AssertJUnit.assertTrue;
|
||||
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
package org.jclouds.virtualbox.functions;
|
||||
|
||||
import static org.easymock.EasyMock.createNiceMock;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.classextension.EasyMock.createNiceMock;
|
||||
import static org.easymock.classextension.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.virtualbox.domain.HardDisk;
|
||||
|
|
|
@ -18,14 +18,18 @@
|
|||
*/
|
||||
package org.jclouds.virtualbox.functions;
|
||||
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
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 static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
|
||||
import org.jclouds.virtualbox.domain.ExecutionType;
|
||||
import org.testng.annotations.Test;
|
||||
import org.virtualbox_4_1.*;
|
||||
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;
|
||||
|
||||
@Test(groups = "unit", testName = "LaunchMachineIfNotAlreadyRunningTest")
|
||||
public class LaunchMachineIfNotAlreadyRunningTest {
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
*/
|
||||
package org.jclouds.virtualbox.functions;
|
||||
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.createNiceMock;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
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.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
import org.virtualbox_4_1.IConsole;
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.virtualbox.functions.admin;
|
|||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
@ -37,7 +36,7 @@ import com.google.common.collect.ImmutableMap;
|
|||
* @author Andrea Turli
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ImageFromYamlStreamTest {
|
||||
public class ImageFromYamlStringTest {
|
||||
|
||||
public static final Image TEST1 = new ImageBuilder()
|
||||
.id("myTestId")
|
||||
|
@ -55,7 +54,7 @@ public class ImageFromYamlStreamTest {
|
|||
}
|
||||
|
||||
ImageFromYamlString parser = new ImageFromYamlString();
|
||||
assertEquals(parser.apply(yamlFileLines.toString()).asMap(), ImmutableMap.of(TEST1.getId(), TEST1));
|
||||
assertEquals(parser.apply(yamlFileLines.toString()), ImmutableMap.of(TEST1.getId(), TEST1));
|
||||
}
|
||||
|
||||
}
|
|
@ -19,15 +19,17 @@
|
|||
|
||||
package org.jclouds.virtualbox.functions.admin;
|
||||
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.jclouds.virtualbox.domain.IsoSpec;
|
||||
import org.testng.annotations.Test;
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.classextension.EasyMock.*;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.jclouds.virtualbox.domain.IsoSpec;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author Andrea Turli, Adrian Cole
|
||||
|
|
|
@ -18,17 +18,19 @@
|
|||
*/
|
||||
package org.jclouds.virtualbox.functions.admin;
|
||||
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.createNiceMock;
|
||||
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.EasyMock.replay;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.jclouds.virtualbox.domain.*;
|
||||
import org.jclouds.virtualbox.domain.HardDisk;
|
||||
import org.jclouds.virtualbox.domain.StorageController;
|
||||
import org.jclouds.virtualbox.domain.VmSpec;
|
||||
import org.testng.annotations.Test;
|
||||
import org.virtualbox_4_1.CleanupMode;
|
||||
import org.virtualbox_4_1.IMachine;
|
||||
|
|
|
@ -44,7 +44,6 @@ import org.virtualbox_4_1.StorageBus;
|
|||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
|
|
|
@ -19,13 +19,14 @@
|
|||
|
||||
package org.jclouds.virtualbox.statements;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.inject.Injector;
|
||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGE_PREFIX;
|
||||
|
||||
import org.jclouds.virtualbox.BaseVirtualBoxClientLiveTest;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGE_PREFIX;
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* @author Andrea Turli
|
||||
|
|
Loading…
Reference in New Issue