template test predicate refactor

This commit is contained in:
Adrian Cole 2011-01-29 20:55:31 -08:00
parent 99bbdfce8a
commit 2d888fb18e
22 changed files with 330 additions and 315 deletions

View File

@ -1,57 +0,0 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed 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.cloudservers.compute;
import org.jclouds.compute.BaseTemplateBuilderLiveTest;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.os.OsFamilyVersion64Bit;
import org.testng.annotations.Test;
import com.google.common.base.Predicate;
/**
*
* @author Adrian Cole
*/
@Test(groups = "live")
public class CloudServersTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
public CloudServersTemplateBuilderLiveTest() {
provider = "cloudservers";
}
@Override
protected Predicate<OsFamilyVersion64Bit> defineUnsupportedOperatingSystems() {
return new Predicate<OsFamilyVersion64Bit>() {
@Override
public boolean apply(OsFamilyVersion64Bit input) {
return (input.family != OsFamily.WINDOWS && !input.is64Bit) || //
input.family == OsFamily.RHEL || //
(input.family == OsFamily.UBUNTU && input.version.equals("11.04")) || //
(input.family == OsFamily.CENTOS && input.version.matches("5.[23]")) || //
(input.family == OsFamily.WINDOWS && input.version.equals("2008")) || //
(input.family == OsFamily.WINDOWS && input.version.equals("2008 R2") && !input.is64Bit);
}
};
}
}

View File

@ -1,56 +0,0 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed 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.elasticstack.compute;
import org.jclouds.compute.BaseTemplateBuilderLiveTest;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.os.OsFamilyVersion64Bit;
import org.testng.annotations.Test;
import com.google.common.base.Predicate;
/**
*
* @author Adrian Cole
*/
@Test(groups = "live")
public class ElasticStackTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
public ElasticStackTemplateBuilderLiveTest() {
provider = "elasticstack";
}
@Override
protected Predicate<OsFamilyVersion64Bit> defineUnsupportedOperatingSystems() {
return new Predicate<OsFamilyVersion64Bit>() {
@Override
public boolean apply(OsFamilyVersion64Bit input) {
return ((input.family == OsFamily.RHEL) || //
(input.family == OsFamily.CENTOS && !(input.version.equals("5.5") && input.is64Bit)) || //
(input.family == OsFamily.UBUNTU && !(input.version.equals("10.04") && input.is64Bit)) || //
(input.family == OsFamily.WINDOWS && !((input.version.equals("2008") || input.version.equals("2008 R2")) && input.is64Bit)) //
);
}
};
}
}

View File

@ -1,76 +0,0 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed 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.eucalyptus.compute;
import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
import static org.testng.Assert.assertEquals;
import java.io.IOException;
import org.jclouds.compute.BaseTemplateBuilderLiveTest;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.domain.os.OsFamilyVersion64Bit;
import org.testng.annotations.Test;
import com.google.common.base.Predicate;
/**
*
* @author Adrian Cole
*/
@Test(groups = "live")
public class EucalyptusTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
public EucalyptusTemplateBuilderLiveTest() {
provider = "eucalyptus";
}
@Override
protected Predicate<OsFamilyVersion64Bit> defineUnsupportedOperatingSystems() {
return new Predicate<OsFamilyVersion64Bit>() {
@Override
public boolean apply(OsFamilyVersion64Bit input) {
return input.family == OsFamily.RHEL || //
(input.family == OsFamily.CENTOS && !input.version.equals("5.3") || !input.is64Bit) || //
input.family == OsFamily.WINDOWS || //
input.family == OsFamily.UBUNTU;
}
};
}
@Test
public void testDefaultTemplateBuilder() throws IOException {
Template defaultTemplate = context.getComputeService().templateBuilder().build();
assert (defaultTemplate.getImage().getProviderId().startsWith("emi-")) : defaultTemplate;
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "5.3");
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS);
assertEquals(defaultTemplate.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
assertEquals(defaultTemplate.getLocation().getId(), "Eucalyptus");
assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
}
}

View File

@ -20,21 +20,14 @@
package org.jclouds.vcloud.compute.functions;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.compute.util.ComputeServiceUtils.parseOsFamilyOrUnrecognized;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.inject.Inject;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.ImageBuilder;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OperatingSystemBuilder;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
import org.jclouds.compute.util.ComputeServiceUtils;
import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.domain.VCloudExpressVAppTemplate;
@ -46,17 +39,16 @@ import com.google.common.base.Function;
public class ImageForVCloudExpressVAppTemplate implements Function<VCloudExpressVAppTemplate, Image> {
private final FindLocationForResource findLocationForResource;
private final PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider;
private ReferenceType parent;
private final Function<String, OperatingSystem> osParser;
private final Map<OsFamily, Map<String, String>> osVersionMap;
private ReferenceType parent;
@Inject
protected ImageForVCloudExpressVAppTemplate(FindLocationForResource findLocationForResource,
PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider,
Map<OsFamily, Map<String, String>> osVersionMap) {
this.osVersionMap = osVersionMap;
PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider, Function<String, OperatingSystem> osParser) {
this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource");
this.credentialsProvider = checkNotNull(credentialsProvider, "credentialsProvider");
this.osParser = osParser;
}
public ImageForVCloudExpressVAppTemplate withParent(ReferenceType parent) {
@ -72,24 +64,8 @@ public class ImageForVCloudExpressVAppTemplate implements Function<VCloudExpress
builder.name(from.getName());
builder.location(findLocationForResource.apply(checkNotNull(parent, "parent")));
builder.description(from.getDescription() != null ? from.getDescription() : from.getName());
builder.operatingSystem(parseOs(from));
builder.operatingSystem(osParser.apply(from.getName()));
builder.defaultCredentials(credentialsProvider.execute(from));
return builder.build();
}
public static final Pattern OS_PATTERN = Pattern.compile("(([^ ]*) ([0-9.]+) ?.*)");
protected OperatingSystem parseOs(VCloudExpressVAppTemplate from) {
OperatingSystemBuilder builder = new OperatingSystemBuilder();
OsFamily osFamily = parseOsFamilyOrUnrecognized("vcloudexpress", checkNotNull(from, "vapp template").getName());
builder.family(osFamily);
builder.description(from.getName());
builder.is64Bit(from.getName().indexOf("64") != -1);
Matcher matcher = OS_PATTERN.matcher(from.getName());
if (matcher.find()) {
builder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap));
}
return builder.build();
}
}

View File

@ -0,0 +1,66 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed 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.vcloud.compute.functions;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.compute.util.ComputeServiceUtils.parseOsFamilyOrUnrecognized;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OperatingSystemBuilder;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.util.ComputeServiceUtils;
import com.google.common.base.Function;
/**
* @author Adrian Cole
*/
@Singleton
public class ParseOsFromVAppTemplateName implements Function<String, OperatingSystem> {
protected static final Pattern OS_PATTERN = Pattern.compile("(([^ ]*) ([0-9.]+) ?.*)");
protected final Map<OsFamily, Map<String, String>> osVersionMap;
@Inject
protected ParseOsFromVAppTemplateName(Map<OsFamily, Map<String, String>> osVersionMap) {
this.osVersionMap = checkNotNull(osVersionMap, "osVersionMap");
}
@Override
public OperatingSystem apply(String from) {
OperatingSystemBuilder builder = new OperatingSystemBuilder();
OsFamily osFamily = parseOsFamilyOrUnrecognized(checkNotNull(from, "vapp template name"));
builder.family(osFamily);
builder.description(from);
builder.is64Bit(from.indexOf("64") != -1);
Matcher matcher = OS_PATTERN.matcher(from);
if (matcher.find()) {
builder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap));
}
return builder.build();
}
}

View File

@ -25,10 +25,10 @@ import static org.testng.Assert.assertEquals;
import java.io.IOException;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.Properties;
import java.util.Set;
import java.util.Map.Entry;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
@ -36,6 +36,7 @@ import org.jclouds.Constants;
import org.jclouds.compute.config.BaseComputeServiceContextModule;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.compute.domain.os.OsFamilyVersion64Bit;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.json.Json;
@ -91,14 +92,14 @@ public abstract class BaseTemplateBuilderLiveTest {
@BeforeClass
public void setupClient() throws InterruptedException, ExecutionException, TimeoutException, IOException {
setupCredentials();
context = new ComputeServiceContextFactory().createContext(provider,
ImmutableSet.<Module> of(new Log4JLoggingModule()), setupProperties());
context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet
.<Module> of(new Log4JLoggingModule()), setupProperties());
}
@DataProvider(name = "osSupported")
public Object[][] osSupported() {
return convertToArray(Sets.filter(provideAllOperatingSystems(),
Predicates.not(defineUnsupportedOperatingSystems())));
return convertToArray(Sets.filter(provideAllOperatingSystems(), Predicates
.not(defineUnsupportedOperatingSystems())));
}
protected Object[][] convertToArray(Set<OsFamilyVersion64Bit> supportedOperatingSystems) {
@ -121,7 +122,7 @@ public abstract class BaseTemplateBuilderLiveTest {
protected Set<OsFamilyVersion64Bit> provideAllOperatingSystems() {
Map<OsFamily, Map<String, String>> map = new BaseComputeServiceContextModule() {
}.provideOsVersionMap(new ComputeServiceConstants.ReferenceData(), Guice.createInjector(new GsonModule())
.getInstance(Json.class));
.getInstance(Json.class));
Set<OsFamilyVersion64Bit> supportedOperatingSystems = Sets.newHashSet();
for (Entry<OsFamily, Map<String, String>> osVersions : map.entrySet()) {
@ -135,17 +136,24 @@ public abstract class BaseTemplateBuilderLiveTest {
@Test(dataProvider = "osSupported")
public void testTemplateBuilderCanFind(OsFamilyVersion64Bit matrix) throws InterruptedException {
Template template = context.getComputeService().templateBuilder().osFamily(matrix.family)
.osVersionMatches("^" + matrix.version + "$").os64Bit(matrix.is64Bit).build();
assertEquals(template.getImage().getOperatingSystem().getVersion(), matrix.version);
TemplateBuilder builder = context.getComputeService().templateBuilder().osFamily(matrix.family).os64Bit(
matrix.is64Bit);
if (!matrix.version.equals(""))
builder.osVersionMatches("^" + matrix.version + "$");
Template template = builder.build();
if (!matrix.version.equals(""))
assertEquals(template.getImage().getOperatingSystem().getVersion(), matrix.version);
assertEquals(template.getImage().getOperatingSystem().is64Bit(), matrix.is64Bit);
assertEquals(template.getImage().getOperatingSystem().getFamily(), matrix.family);
}
@Test(dataProvider = "osNotSupported", expectedExceptions = NoSuchElementException.class)
public void testTemplateBuilderCannotFind(OsFamilyVersion64Bit matrix) throws InterruptedException {
context.getComputeService().templateBuilder().osFamily(matrix.family)
.osVersionMatches("^" + matrix.version + "$").os64Bit(matrix.is64Bit).build();
TemplateBuilder builder = context.getComputeService().templateBuilder().osFamily(matrix.family).os64Bit(
matrix.is64Bit);
if (!matrix.version.equals(""))
builder.osVersionMatches("^" + matrix.version + "$");
builder.build();
}
@Test
@ -153,7 +161,7 @@ public abstract class BaseTemplateBuilderLiveTest {
Template defaultTemplate = context.getComputeService().templateBuilder().build();
Template template = context.getComputeService().templateBuilder().imageId(defaultTemplate.getImage().getId())
.build();
.build();
assertEquals(template.getImage(), defaultTemplate.getImage());
}

View File

@ -57,9 +57,16 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
@Override
public boolean apply(OsFamilyVersion64Bit input) {
return input.family == OsFamily.RHEL || //
(input.family == OsFamily.CENTOS && !input.version.matches("5.[42]")) || //
(input.family == OsFamily.WINDOWS && !input.version.matches("200[38]"));
switch (input.family) {
case UBUNTU:
return false;
case CENTOS:
return !(input.version.matches("5.[42]") || input.version.equals(""));
case WINDOWS:
return !(input.version.matches("200[38]") || input.version.equals(""));
default:
return true;
}
}
};
@ -75,7 +82,6 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
assertEquals(template.getImage().getOperatingSystem().getVersion(), "10.10");
assertEquals(template.getImage().getOperatingSystem().is64Bit(), false);
assertEquals(template.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(template.getImage().getVersion(), "20110126");
assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
assertEquals(template.getLocation().getId(), "us-east-1");
assertEquals(getCores(template.getHardware()), 1.0d);
@ -120,10 +126,10 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
public void testTemplateBuilderMicro() throws IOException {
Template microTemplate = context.getComputeService().templateBuilder().hardwareId(InstanceType.T1_MICRO)
.osFamily(OsFamily.UBUNTU).build();
.osFamily(OsFamily.UBUNTU).osVersionMatches("10.10").os64Bit(true).build();
assert (microTemplate.getImage().getProviderId().startsWith("ami-")) : microTemplate;
assertEquals(microTemplate.getImage().getOperatingSystem().getVersion(), "10.04");
assertEquals(microTemplate.getImage().getOperatingSystem().getVersion(), "10.10");
assertEquals(microTemplate.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(microTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(microTemplate.getImage().getUserMetadata().get("rootDeviceType"), "ebs");

View File

@ -0,0 +1,52 @@
package org.jclouds.vcloud.bluelock.compute;
import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
import static org.testng.Assert.assertEquals;
import java.io.IOException;
import org.jclouds.compute.BaseTemplateBuilderLiveTest;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.domain.os.OsFamilyVersion64Bit;
import org.testng.annotations.Test;
import com.google.common.base.Predicate;
/**
*
* @author Adrian Cole
*/
@Test(groups = "live")
public class BlueLockVCloudDirectorTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
public BlueLockVCloudDirectorTemplateBuilderLiveTest() {
provider = "bluelock-vcdirector";
}
@Override
protected Predicate<OsFamilyVersion64Bit> defineUnsupportedOperatingSystems() {
return new Predicate<OsFamilyVersion64Bit>() {
@Override
public boolean apply(OsFamilyVersion64Bit input) {
switch (input.family) {
case UBUNTU:
return !input.version.equals("");
default:
return true;
}
}
};
}
@Override
public void testDefaultTemplateBuilder() throws IOException {
Template defaultTemplate = context.getComputeService().templateBuilder().build();
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "");
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
}
}

View File

@ -47,12 +47,17 @@ public class CloudServersUKTemplateBuilderLiveTest extends BaseTemplateBuilderLi
@Override
public boolean apply(OsFamilyVersion64Bit input) {
return (input.family != OsFamily.WINDOWS && !input.is64Bit) || //
input.family == OsFamily.RHEL || //
(input.family == OsFamily.UBUNTU && input.version.equals("11.04")) || //
(input.family == OsFamily.CENTOS && input.version.matches("5.[23]")) || //
(input.family == OsFamily.WINDOWS && input.version.equals("2008")) || //
(input.family == OsFamily.WINDOWS && input.version.equals("2008 R2") && !input.is64Bit);
switch (input.family) {
case UBUNTU:
return input.version.equals("11.04") || input.version.equals("8.04") || !input.is64Bit;
case CENTOS:
return input.version.matches("5.[023]") || !input.is64Bit;
case WINDOWS:
return input.version.equals("2008") || input.version.indexOf("2003") != -1
|| (input.version.equals("2008 R2") && !input.is64Bit);
default:
return true;
}
}
};

View File

@ -47,12 +47,17 @@ public class CloudServersUSTemplateBuilderLiveTest extends BaseTemplateBuilderLi
@Override
public boolean apply(OsFamilyVersion64Bit input) {
return (input.family != OsFamily.WINDOWS && !input.is64Bit) || //
input.family == OsFamily.RHEL || //
(input.family == OsFamily.UBUNTU && input.version.equals("11.04")) || //
(input.family == OsFamily.CENTOS && input.version.matches("5.[23]")) || //
(input.family == OsFamily.WINDOWS && input.version.equals("2008")) || //
(input.family == OsFamily.WINDOWS && input.version.equals("2008 R2") && !input.is64Bit);
switch (input.family) {
case UBUNTU:
return input.version.equals("11.04") || input.version.equals("8.04") || !input.is64Bit;
case CENTOS:
return input.version.matches("5.[023]") || !input.is64Bit;
case WINDOWS:
return input.version.equals("2008") || input.version.indexOf("2003") != -1
|| (input.version.equals("2008 R2") && !input.is64Bit);
default:
return true;
}
}
};

View File

@ -46,20 +46,26 @@ public class CloudSigmaTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTe
@Override
protected Predicate<OsFamilyVersion64Bit> defineUnsupportedOperatingSystems() {
return new Predicate<OsFamilyVersion64Bit>() {
@Override
public boolean apply(OsFamilyVersion64Bit input) {
return ((input.family == OsFamily.RHEL) || //
(input.family == OsFamily.CENTOS && !(input.version.equals("5.5") && input.is64Bit)) || //
(input.family == OsFamily.UBUNTU && !(input.version.matches("10.10") && input.is64Bit)) || //
(input.family == OsFamily.WINDOWS && !((input.version.equals("2008 R2") && input.is64Bit)
|| (input.version.equals("2008") && !input.is64Bit) || (input.version.equals("2003")))) //
);
switch (input.family) {
case UBUNTU:
return !input.version.equals("") && !(input.version.equals("10.10") && input.is64Bit);
case CENTOS:
return !(input.version.equals("") && input.is64Bit)
&& !(input.version.equals("5.5") && input.is64Bit);
case WINDOWS:
return !((input.version.equals("2008 R2") && input.is64Bit)
|| (input.version.equals("2008") && !input.is64Bit) || input.version.equals("") || (input.version
.equals("2003")));
default:
return true;
}
}
};
}
@Override
public void testDefaultTemplateBuilder() throws IOException {
Template defaultTemplate = context.getComputeService().templateBuilder().build();

View File

@ -47,11 +47,19 @@ public class ElasticHostsBlueSquareLondonTemplateBuilderLiveTest extends BaseTem
@Override
public boolean apply(OsFamilyVersion64Bit input) {
return ((input.family == OsFamily.RHEL) || //
(input.family == OsFamily.CENTOS && !(input.version.equals("5.5") && input.is64Bit)) || //
(input.family == OsFamily.UBUNTU && !(input.version.equals("10.04") && input.is64Bit)) || //
(input.family == OsFamily.WINDOWS && !((input.version.equals("2008") || input.version.equals("2008 R2")) && input.is64Bit)) //
);
switch (input.family) {
case UBUNTU:
return !(input.version.equals("") && input.is64Bit)
&& !(input.version.equals("10.04") && input.is64Bit);
case CENTOS:
return !(input.version.equals("") && input.is64Bit)
&& !(input.version.equals("5.5") && input.is64Bit);
case WINDOWS:
return !(input.version.equals("") && input.is64Bit)
&& !((input.version.equals("2008 R2") && input.is64Bit) || (input.version.equals("2008") && input.is64Bit));
default:
return true;
}
}
};

View File

@ -47,11 +47,19 @@ public class ElasticHostsPeer1LondonTemplateBuilderLiveTest extends BaseTemplate
@Override
public boolean apply(OsFamilyVersion64Bit input) {
return ((input.family == OsFamily.RHEL) || //
(input.family == OsFamily.CENTOS && !(input.version.equals("5.5") && input.is64Bit)) || //
(input.family == OsFamily.UBUNTU && !(input.version.equals("10.04") && input.is64Bit)) || //
(input.family == OsFamily.WINDOWS && !((input.version.equals("2008") || input.version.equals("2008 R2")) && input.is64Bit)) //
);
switch (input.family) {
case UBUNTU:
return !(input.version.equals("") && input.is64Bit)
&& !(input.version.equals("10.04") && input.is64Bit);
case CENTOS:
return !(input.version.equals("") && input.is64Bit)
&& !(input.version.equals("5.5") && input.is64Bit);
case WINDOWS:
return !(input.version.equals("") && input.is64Bit)
&& !((input.version.equals("2008 R2") && input.is64Bit) || (input.version.equals("2008") && input.is64Bit));
default:
return true;
}
}
};

View File

@ -47,11 +47,19 @@ public class ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest extends BaseTemp
@Override
public boolean apply(OsFamilyVersion64Bit input) {
return ((input.family == OsFamily.RHEL) || //
(input.family == OsFamily.CENTOS && !(input.version.equals("5.5") && input.is64Bit)) || //
(input.family == OsFamily.UBUNTU && !(input.version.equals("10.04") && input.is64Bit)) || //
(input.family == OsFamily.WINDOWS && !((input.version.equals("2008") || input.version.equals("2008 R2")) && input.is64Bit)) //
);
switch (input.family) {
case UBUNTU:
return !(input.version.equals("") && input.is64Bit)
&& !(input.version.equals("10.04") && input.is64Bit);
case CENTOS:
return !(input.version.equals("") && input.is64Bit)
&& !(input.version.equals("5.5") && input.is64Bit);
case WINDOWS:
return !(input.version.equals("") && input.is64Bit)
&& !((input.version.equals("2008 R2") && input.is64Bit) || (input.version.equals("2008") && input.is64Bit));
default:
return true;
}
}
};

View File

@ -49,11 +49,15 @@ public class EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest extends Bas
@Override
public boolean apply(OsFamilyVersion64Bit input) {
return input.family == OsFamily.RHEL || //
(input.family == OsFamily.CENTOS && !input.version.equals("5.3") || !input.is64Bit) || //
(input.family == OsFamily.WINDOWS && !(input.version.equals("2008") && input.is64Bit)) || //
input.family == OsFamily.UBUNTU;
switch (input.family) {
case CENTOS:
return !(input.version.equals("") && input.is64Bit)
&& !(input.version.equals("5.3") && input.is64Bit);
case WINDOWS:
return !(input.version.equals("") && input.is64Bit);
default:
return true;
}
}
};

View File

@ -46,17 +46,20 @@ public class GoGridTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
@Override
protected Predicate<OsFamilyVersion64Bit> defineUnsupportedOperatingSystems() {
return new Predicate<OsFamilyVersion64Bit>() {
@Override
public boolean apply(OsFamilyVersion64Bit input) {
return ((input.family == OsFamily.RHEL && !input.version.equals("5.4")) || //
(input.family == OsFamily.CENTOS && input.version.matches("5.[542]")) || //
(input.family == OsFamily.CENTOS && input.is64Bit && input.version.equals("5.[42]")) || //
(input.family == OsFamily.UBUNTU) || //
(input.family == OsFamily.WINDOWS && input.version.equals("2008 SP2") || //
(input.family == OsFamily.WINDOWS && input.version.equals("2008 R2"))));
switch (input.family) {
case RHEL:
return !input.version.equals("") && !input.version.equals("5.4");
case CENTOS:
return !input.version.equals("") && !input.version.equals("5.3");
case WINDOWS:
return !input.version.equals("") && (input.is64Bit && !input.version.matches("200[38]"))
|| (input.version.matches("200[38] [RS]P?2") && !input.is64Bit);
default:
return true;
}
}
};
}

View File

@ -49,11 +49,16 @@ public class OpenHostingEast1TemplateBuilderLiveTest extends BaseTemplateBuilder
@Override
public boolean apply(OsFamilyVersion64Bit input) {
return ((input.family == OsFamily.RHEL) || //
(input.family == OsFamily.CENTOS && !(input.version.equals("5.5") && input.is64Bit)) || //
(input.family == OsFamily.UBUNTU && !(input.version.equals("10.10") && input.is64Bit)) || //
(input.family == OsFamily.WINDOWS) //
);
switch (input.family) {
case UBUNTU:
return !(input.version.equals("") && input.is64Bit)
&& !(input.version.equals("10.10") && input.is64Bit);
case CENTOS:
return !(input.version.equals("") && input.is64Bit)
&& !(input.version.equals("5.5") && input.is64Bit);
default:
return true;
}
}
};

View File

@ -47,11 +47,19 @@ public class ServerloveManchesterTemplateBuilderLiveTest extends BaseTemplateBui
@Override
public boolean apply(OsFamilyVersion64Bit input) {
return ((input.family == OsFamily.RHEL) || //
(input.family == OsFamily.CENTOS && !(input.version.equals("5.5") && input.is64Bit)) || //
(input.family == OsFamily.UBUNTU && !(input.version.equals("10.04") && input.is64Bit)) || //
(input.family == OsFamily.WINDOWS && !(input.version.equals("2008 R2") && input.is64Bit)) //
);
switch (input.family) {
case UBUNTU:
return !(input.version.equals("") && input.is64Bit)
&& !(input.version.equals("10.04") && input.is64Bit);
case CENTOS:
return !(input.version.equals("") && input.is64Bit)
&& !(input.version.equals("5.5") && input.is64Bit);
case WINDOWS:
return !(input.version.equals("") && input.is64Bit)
&& !(input.version.equals("2008 R2") && input.is64Bit);
default:
return true;
}
}
};

View File

@ -49,11 +49,17 @@ public class SkaliCloudMalaysiaTemplateBuilderLiveTest extends BaseTemplateBuild
@Override
public boolean apply(OsFamilyVersion64Bit input) {
return ((input.family == OsFamily.RHEL) || //
(input.family == OsFamily.CENTOS && !input.version.equals("5.5")) || //
(input.family == OsFamily.UBUNTU && !input.version.equals("10.10")) || //
(input.family == OsFamily.WINDOWS && !(input.version.equals("2008 R2") && input.is64Bit)) //
);
switch (input.family) {
case UBUNTU:
return !input.version.equals("") && !input.version.equals("10.10");
case CENTOS:
return !input.version.equals("") && !input.version.equals("5.5");
case WINDOWS:
return !(input.version.equals("") && input.is64Bit)
&& !(input.version.equals("2008 R2") && input.is64Bit);
default:
return true;
}
}
};

View File

@ -49,11 +49,23 @@ public class SlicehostTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes
@Override
public boolean apply(OsFamilyVersion64Bit input) {
return (input.family == OsFamily.RHEL || //
(input.family == OsFamily.UBUNTU && input.version.equals("11.04")) || //
(input.family == OsFamily.CENTOS && input.version.matches("5.[23]")) || //
(input.family == OsFamily.WINDOWS && !(input.is64Bit && input.version.equals("2008 R2"))//
&& !(!input.is64Bit && input.version.equals("2008 SP2"))));
switch (input.family) {
case UBUNTU:
return !input.version.equals("") && !(input.version.equals("10.04") || input.version.endsWith(".10"));
case RHEL:
return !(input.version.equals("") && input.is64Bit);
case CENTOS:
return !input.version.equals("") && input.version.matches("5.[23]")
|| (input.version.equals("5.0") && !input.is64Bit);
case WINDOWS:
return !input.version.equals("")
&& input.version.startsWith("2008")
&& !(input.version.startsWith("2008 R2") && input.is64Bit || input.version
.startsWith("2008 SP2")
&& !input.is64Bit) || input.version.indexOf("2003") != -1;
default:
return true;
}
}
};

View File

@ -49,12 +49,23 @@ public class TerremarkECloudTemplateBuilderLiveTest extends BaseTemplateBuilderL
@Override
public boolean apply(OsFamilyVersion64Bit input) {
return ((input.family == OsFamily.RHEL) || //
(input.family == OsFamily.CENTOS && !input.version.equals("5.5")) || //
(input.family == OsFamily.UBUNTU &&( !input.version.equals("10.04")&&!input.version.equals("8.04"))) || //
(input.family == OsFamily.WINDOWS && (input.version.equals("2008 SP2") || input.version.equals("2008 R2"))));
switch (input.family) {
case RHEL:
return !input.version.equals("") && !input.version.matches("5.[50]");
case SOLARIS:
return !input.is64Bit;
case CENTOS:
return !input.version.equals("") && !input.version.matches("5.[50]");
case UBUNTU:
return !input.version.equals("") && !input.version.equals("10.04") && !input.version.equals("8.04");
case WINDOWS:
return !input.version.equals("") && !input.version.equals("2003 R2") //
&& !(input.version.equals("2008") && !input.is64Bit) //
&& !(input.version.matches("2008( R2)?") && input.is64Bit);
default:
return true;
}
}
};
}
@ -65,7 +76,6 @@ public class TerremarkECloudTemplateBuilderLiveTest extends BaseTemplateBuilderL
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS);
assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
}
}

View File

@ -46,14 +46,22 @@ public class TerremarkVCloudExpressTemplateBuilderLiveTest extends BaseTemplateB
@Override
protected Predicate<OsFamilyVersion64Bit> defineUnsupportedOperatingSystems() {
return new Predicate<OsFamilyVersion64Bit>() {
@Override
public boolean apply(OsFamilyVersion64Bit input) {
return ((input.family == OsFamily.RHEL || input.family == OsFamily.CENTOS) || //
(input.family == OsFamily.UBUNTU && !input.version.equals("9.10")) || //
(input.family == OsFamily.WINDOWS && (input.version.equals("2008 SP2") || input.version.equals("2008 R2"))));
switch (input.family) {
case RHEL:
return !input.version.equals("") && !input.version.equals("5.0");
case CENTOS:
return !input.version.equals("") && !input.version.matches("5.0");
case UBUNTU:
return !input.version.equals("") && !(input.version.equals("9.04") || input.version.equals("9.10"));
case WINDOWS:
return !input.version.equals("") && !input.version.equals("2003") //
&& !input.version.equals("2008");
default:
return true;
}
}
};
}