fixies to get FGCP template tests working

This commit is contained in:
Adrian Cole 2013-01-27 15:50:24 -08:00
parent e085086617
commit 0e38612c9c
3 changed files with 18 additions and 43 deletions

View File

@ -25,8 +25,7 @@ import java.util.Properties;
import org.jclouds.providers.internal.BaseProviderMetadata;
/**
* Base implementation of {@link org.jclouds.providers.ProviderMetadata} for
* FGCP.
* Base implementation of {@link org.jclouds.providers.ProviderMetadata} for FGCP.
*
* @author Dies Koper
*/
@ -46,10 +45,7 @@ public class FGCPProviderMetadata extends BaseProviderMetadata {
public static Properties defaultProperties() {
Properties properties = new Properties();
properties.setProperty(TEMPLATE,
"osFamily=CENTOS,osVersionMatches=6.2,os64Bit=true");
properties.setProperty(TEMPLATE, "osFamily=CENTOS,osVersionMatches=6.2,os64Bit=true");
return properties;
}
}

View File

@ -30,10 +30,8 @@ import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.fujitsu.fgcp.domain.DiskImage;
import org.jclouds.location.suppliers.all.RegionToProviderOrJustProvider;
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
/**
* Created by IntelliJ IDEA.
@ -44,15 +42,10 @@ import com.google.common.collect.Iterables;
public class DiskImageToImage implements Function<DiskImage, Image> {
private final DiskImageToOperatingSystem diskImageToOperatingSystem;
private final RegionToProviderOrJustProvider regionSupplier;
@Inject
public DiskImageToImage(
DiskImageToOperatingSystem diskImageToOperatingSystem,
RegionToProviderOrJustProvider locationSupplier) {
this.diskImageToOperatingSystem = checkNotNull(
diskImageToOperatingSystem, "diskImageToOperatingSystem");
this.regionSupplier = checkNotNull(locationSupplier, "locationProvider");
public DiskImageToImage(DiskImageToOperatingSystem diskImageToOperatingSystem) {
this.diskImageToOperatingSystem = checkNotNull(diskImageToOperatingSystem, "diskImageToOperatingSystem");
}
@Override
@ -64,17 +57,12 @@ public class DiskImageToImage implements Function<DiskImage, Image> {
builder.ids(from.getId());
builder.name(from.getName());
builder.description(from.getDescription());
builder.location(Iterables.getOnlyElement(regionSupplier.get()));
// in fgcp, if the image is listed it is available
builder.status(Status.AVAILABLE);
OperatingSystem os = diskImageToOperatingSystem.apply(from);
builder.operatingSystem(os);
String user = os.getFamily() == OsFamily.WINDOWS ? "Administrator"
: "root";
builder.defaultCredentials(LoginCredentials.builder().identity(user)
.noPassword().build());
String user = os.getFamily() == OsFamily.WINDOWS ? "Administrator" : "root";
builder.defaultCredentials(LoginCredentials.builder().identity(user).noPassword().build());
return builder.build();
}
}

View File

@ -15,8 +15,7 @@ import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
public abstract class FGCPBaseTemplateBuilderLiveTest extends
BaseTemplateBuilderLiveTest {
public abstract class FGCPBaseTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
@Override
protected Properties setupProperties() {
@ -27,16 +26,12 @@ public abstract class FGCPBaseTemplateBuilderLiveTest extends
String[] parts = proxy.split("http://|:|@");
overrides.setProperty(Constants.PROPERTY_PROXY_HOST,
parts[parts.length - 2]);
overrides.setProperty(Constants.PROPERTY_PROXY_PORT,
parts[parts.length - 1]);
overrides.setProperty(Constants.PROPERTY_PROXY_HOST, parts[parts.length - 2]);
overrides.setProperty(Constants.PROPERTY_PROXY_PORT, parts[parts.length - 1]);
if (parts.length >= 4) {
overrides.setProperty(Constants.PROPERTY_PROXY_USER,
parts[parts.length - 4]);
overrides.setProperty(Constants.PROPERTY_PROXY_PASSWORD,
parts[parts.length - 3]);
overrides.setProperty(Constants.PROPERTY_PROXY_USER, parts[parts.length - 4]);
overrides.setProperty(Constants.PROPERTY_PROXY_PASSWORD, parts[parts.length - 3]);
}
}
@ -55,11 +50,11 @@ public abstract class FGCPBaseTemplateBuilderLiveTest extends
public boolean apply(OsFamilyVersion64Bit input) {
switch (input.family) {
case CENTOS:
return input.version.matches("5.[46]")
return ("".equals(input.version) && input.is64Bit) || (input.version.matches("5.[46]") && input.is64Bit)
|| input.version.equals("6.[2]");
case WINDOWS:
return (input.version.equals("2008 R2 SE") || input.version
.equals("2008 R2 EE")) && input.is64Bit;
return ("".equals(input.version) && input.is64Bit)
|| (input.version.equals("2008 R2 SE") || input.version.equals("2008 R2 EE")) && input.is64Bit;
default:
return false;
}
@ -69,15 +64,11 @@ public abstract class FGCPBaseTemplateBuilderLiveTest extends
}
public void testDefaultTemplateBuilder() throws IOException {
Template defaultTemplate = view.getComputeService().templateBuilder()
.build();
assert defaultTemplate.getImage().getOperatingSystem().getVersion()
.matches("6.2") : defaultTemplate.getImage()
Template defaultTemplate = view.getComputeService().templateBuilder().build();
assert defaultTemplate.getImage().getOperatingSystem().getVersion().matches("6.2") : defaultTemplate.getImage()
.getOperatingSystem().getVersion();
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(),
true);
assertEquals(defaultTemplate.getImage().getOperatingSystem()
.getFamily(), OsFamily.CENTOS);
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS);
assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
}