mirror of https://github.com/apache/jclouds.git
Merge pull request #1250 from jclouds/fgcp-template
fixies to get FGCP template tests working
This commit is contained in:
commit
b8f3859bb6
|
@ -25,8 +25,7 @@ import java.util.Properties;
|
||||||
import org.jclouds.providers.internal.BaseProviderMetadata;
|
import org.jclouds.providers.internal.BaseProviderMetadata;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base implementation of {@link org.jclouds.providers.ProviderMetadata} for
|
* Base implementation of {@link org.jclouds.providers.ProviderMetadata} for FGCP.
|
||||||
* FGCP.
|
|
||||||
*
|
*
|
||||||
* @author Dies Koper
|
* @author Dies Koper
|
||||||
*/
|
*/
|
||||||
|
@ -46,10 +45,7 @@ public class FGCPProviderMetadata extends BaseProviderMetadata {
|
||||||
|
|
||||||
public static Properties defaultProperties() {
|
public static Properties defaultProperties() {
|
||||||
Properties properties = new Properties();
|
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;
|
return properties;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,10 +30,8 @@ import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.jclouds.domain.LoginCredentials;
|
import org.jclouds.domain.LoginCredentials;
|
||||||
import org.jclouds.fujitsu.fgcp.domain.DiskImage;
|
import org.jclouds.fujitsu.fgcp.domain.DiskImage;
|
||||||
import org.jclouds.location.suppliers.all.RegionToProviderOrJustProvider;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by IntelliJ IDEA.
|
* Created by IntelliJ IDEA.
|
||||||
|
@ -44,15 +42,10 @@ import com.google.common.collect.Iterables;
|
||||||
public class DiskImageToImage implements Function<DiskImage, Image> {
|
public class DiskImageToImage implements Function<DiskImage, Image> {
|
||||||
|
|
||||||
private final DiskImageToOperatingSystem diskImageToOperatingSystem;
|
private final DiskImageToOperatingSystem diskImageToOperatingSystem;
|
||||||
private final RegionToProviderOrJustProvider regionSupplier;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public DiskImageToImage(
|
public DiskImageToImage(DiskImageToOperatingSystem diskImageToOperatingSystem) {
|
||||||
DiskImageToOperatingSystem diskImageToOperatingSystem,
|
this.diskImageToOperatingSystem = checkNotNull(diskImageToOperatingSystem, "diskImageToOperatingSystem");
|
||||||
RegionToProviderOrJustProvider locationSupplier) {
|
|
||||||
this.diskImageToOperatingSystem = checkNotNull(
|
|
||||||
diskImageToOperatingSystem, "diskImageToOperatingSystem");
|
|
||||||
this.regionSupplier = checkNotNull(locationSupplier, "locationProvider");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -64,17 +57,12 @@ public class DiskImageToImage implements Function<DiskImage, Image> {
|
||||||
builder.ids(from.getId());
|
builder.ids(from.getId());
|
||||||
builder.name(from.getName());
|
builder.name(from.getName());
|
||||||
builder.description(from.getDescription());
|
builder.description(from.getDescription());
|
||||||
builder.location(Iterables.getOnlyElement(regionSupplier.get()));
|
|
||||||
// in fgcp, if the image is listed it is available
|
// in fgcp, if the image is listed it is available
|
||||||
builder.status(Status.AVAILABLE);
|
builder.status(Status.AVAILABLE);
|
||||||
|
|
||||||
OperatingSystem os = diskImageToOperatingSystem.apply(from);
|
OperatingSystem os = diskImageToOperatingSystem.apply(from);
|
||||||
builder.operatingSystem(os);
|
builder.operatingSystem(os);
|
||||||
String user = os.getFamily() == OsFamily.WINDOWS ? "Administrator"
|
String user = os.getFamily() == OsFamily.WINDOWS ? "Administrator" : "root";
|
||||||
: "root";
|
builder.defaultCredentials(LoginCredentials.builder().identity(user).noPassword().build());
|
||||||
builder.defaultCredentials(LoginCredentials.builder().identity(user)
|
|
||||||
.noPassword().build());
|
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,7 @@ import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
|
|
||||||
public abstract class FGCPBaseTemplateBuilderLiveTest extends
|
public abstract class FGCPBaseTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
|
||||||
BaseTemplateBuilderLiveTest {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Properties setupProperties() {
|
protected Properties setupProperties() {
|
||||||
|
@ -27,16 +26,12 @@ public abstract class FGCPBaseTemplateBuilderLiveTest extends
|
||||||
|
|
||||||
String[] parts = proxy.split("http://|:|@");
|
String[] parts = proxy.split("http://|:|@");
|
||||||
|
|
||||||
overrides.setProperty(Constants.PROPERTY_PROXY_HOST,
|
overrides.setProperty(Constants.PROPERTY_PROXY_HOST, parts[parts.length - 2]);
|
||||||
parts[parts.length - 2]);
|
overrides.setProperty(Constants.PROPERTY_PROXY_PORT, parts[parts.length - 1]);
|
||||||
overrides.setProperty(Constants.PROPERTY_PROXY_PORT,
|
|
||||||
parts[parts.length - 1]);
|
|
||||||
|
|
||||||
if (parts.length >= 4) {
|
if (parts.length >= 4) {
|
||||||
overrides.setProperty(Constants.PROPERTY_PROXY_USER,
|
overrides.setProperty(Constants.PROPERTY_PROXY_USER, parts[parts.length - 4]);
|
||||||
parts[parts.length - 4]);
|
overrides.setProperty(Constants.PROPERTY_PROXY_PASSWORD, parts[parts.length - 3]);
|
||||||
overrides.setProperty(Constants.PROPERTY_PROXY_PASSWORD,
|
|
||||||
parts[parts.length - 3]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,11 +50,11 @@ public abstract class FGCPBaseTemplateBuilderLiveTest extends
|
||||||
public boolean apply(OsFamilyVersion64Bit input) {
|
public boolean apply(OsFamilyVersion64Bit input) {
|
||||||
switch (input.family) {
|
switch (input.family) {
|
||||||
case CENTOS:
|
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]");
|
|| input.version.equals("6.[2]");
|
||||||
case WINDOWS:
|
case WINDOWS:
|
||||||
return (input.version.equals("2008 R2 SE") || input.version
|
return ("".equals(input.version) && input.is64Bit)
|
||||||
.equals("2008 R2 EE")) && input.is64Bit;
|
|| (input.version.equals("2008 R2 SE") || input.version.equals("2008 R2 EE")) && input.is64Bit;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -69,15 +64,11 @@ public abstract class FGCPBaseTemplateBuilderLiveTest extends
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDefaultTemplateBuilder() throws IOException {
|
public void testDefaultTemplateBuilder() throws IOException {
|
||||||
Template defaultTemplate = view.getComputeService().templateBuilder()
|
Template defaultTemplate = view.getComputeService().templateBuilder().build();
|
||||||
.build();
|
assert defaultTemplate.getImage().getOperatingSystem().getVersion().matches("6.2") : defaultTemplate.getImage()
|
||||||
assert defaultTemplate.getImage().getOperatingSystem().getVersion()
|
|
||||||
.matches("6.2") : defaultTemplate.getImage()
|
|
||||||
.getOperatingSystem().getVersion();
|
.getOperatingSystem().getVersion();
|
||||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(),
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
|
||||||
true);
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS);
|
||||||
assertEquals(defaultTemplate.getImage().getOperatingSystem()
|
|
||||||
.getFamily(), OsFamily.CENTOS);
|
|
||||||
assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
|
assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue