From 8ba6e91b7cf3576134ab5b4098ca708ba4ab7202 Mon Sep 17 00:00:00 2001 From: David Ribeiro Alves Date: Mon, 12 Mar 2012 15:32:31 +0000 Subject: [PATCH] improved hardware matching. *adapter now returns the list of images instead of a no-id mock hardware --- .../config/VirtualBoxComputeServiceContextModule.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java index 95f8c662de..bc3e206501 100644 --- a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java +++ b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java @@ -24,8 +24,8 @@ import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_PRECO import java.io.File; import java.io.InputStream; import java.net.URI; -import java.util.Collections; import java.util.Map; +import java.util.Set; import java.util.concurrent.ExecutionException; import javax.inject.Named; @@ -78,6 +78,7 @@ import org.jclouds.virtualbox.functions.admin.ImagesToYamlImagesFromYamlDescript import org.jclouds.virtualbox.functions.admin.StartJettyIfNotAlreadyRunning; import org.jclouds.virtualbox.functions.admin.StartVBoxIfNotAlreadyRunning; import org.jclouds.virtualbox.predicates.SshResponds; +import org.testng.internal.annotations.Sets; import org.virtualbox_4_1.IMachine; import org.virtualbox_4_1.LockType; import org.virtualbox_4_1.MachineState; @@ -218,7 +219,13 @@ public class VirtualBoxComputeServiceContextModule extends @Override protected Supplier provideHardware(ComputeServiceAdapter adapter, Function transformer) { - return Suppliers.ofInstance(Collections.singleton(new HardwareBuilder().id("").build())); + // since no vms might be available we need to list images + Iterable images = adapter.listImages(); + Set hardware = Sets.newHashSet(); + for (Image image : images) { + hardware.add(new HardwareBuilder().ids(image.getId()).hypervisor("VirtualBox").name(image.getName()).build()); + } + return Suppliers.ofInstance(hardware); } @Override