stabilized glesys templates

This commit is contained in:
Adrian Cole 2012-02-09 11:31:55 +00:00
parent e0c2090fca
commit 993ba39243
8 changed files with 185 additions and 36 deletions

View File

@ -38,7 +38,14 @@ public enum OsFamily {
*
* Oracle Enterprise Linux
*/
OEL, OPENBSD, RHEL, SIGAR, SOLARIS, SUSE, TURBOLINUX, UBUNTU, WINDOWS;
OEL, OPENBSD, RHEL,
/**
* Scientific Linux
*/
SCIENTIFIC,
SIGAR,
SLACKWARE,
SOLARIS, SUSE, TURBOLINUX, UBUNTU, WINDOWS;
public String value() {
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name());
}

View File

@ -91,7 +91,7 @@ public interface ComputeServiceConstants {
@Inject(optional = true)
@Named(PROPERTY_OS_VERSION_MAP_JSON)
// TODO: switch this to read from resource, failing back to string constant on classpath problem
public String osVersionMapJson = "{\"suse\":{\"\":\"\",\"11\":\"11\",\"11 SP1\":\"11 SP1\"},\"debian\":{\"\":\"\",\"lenny\":\"5.0\",\"squeeze\":\"6.0\"},\"centos\":{\"\":\"\",\"5\":\"5.0\",\"5.2\":\"5.2\",\"5.3\":\"5.3\",\"5.4\":\"5.4\",\"5.5\":\"5.5\",\"5.6\":\"5.6\",\"5.7\":\"5.7\",\"6\":\"6.0\",\"6.0\":\"6.0\"},\"rhel\":{\"\":\"\",\"5\":\"5.0\",\"5.2\":\"5.2\",\"5.3\":\"5.3\",\"5.4\":\"5.4\",\"5.5\":\"5.5\",\"5.6\":\"5.6\",\"5.7\":\"5.7\",\"6\":\"6.0\",\"6.0\":\"6.0\"},\"solaris\":{\"\":\"\",\"10\":\"10\"},\"ubuntu\":{\"\":\"\",\"hardy\":\"8.04\",\"karmic\":\"9.10\",\"lucid\":\"10.04\",\"10.04.1\":\"10.04\",\"maverick\":\"10.10\",\"natty\":\"11.04\",\"oneiric\":\"11.10\",\"precise\":\"12.04\"},\"windows\":{\"\":\"\",\"7\":\"7\",\"2003\":\"2003\",\"2003 Standard\":\"2003\",\"2003 R2\":\"2003 R2\",\"2008\":\"2008\",\"2008 Web\":\"2008\",\"2008 Server\":\"2008\",\"Server 2008\":\"2008\",\"2008 R1\":\"2008 R1\",\"2008 R2\":\"2008 R2\",\"Server 2008 R2\":\"2008 R2\",\"2008 Server R2\":\"2008 R2\",\"2008 SP2\":\"2008 SP2\",\"Server 2008 SP2\":\"2008 SP2\"}}";
public String osVersionMapJson = "{\"suse\":{\"\":\"\",\"11\":\"11\",\"11 SP1\":\"11 SP1\"},\"debian\":{\"\":\"\",\"lenny\":\"5.0\",\"6\":\"6.0\",\"squeeze\":\"6.0\"},\"centos\":{\"\":\"\",\"5\":\"5.0\",\"5.2\":\"5.2\",\"5.3\":\"5.3\",\"5.4\":\"5.4\",\"5.5\":\"5.5\",\"5.6\":\"5.6\",\"5.7\":\"5.7\",\"6\":\"6.0\",\"6.0\":\"6.0\"},\"rhel\":{\"\":\"\",\"5\":\"5.0\",\"5.2\":\"5.2\",\"5.3\":\"5.3\",\"5.4\":\"5.4\",\"5.5\":\"5.5\",\"5.6\":\"5.6\",\"5.7\":\"5.7\",\"6\":\"6.0\",\"6.0\":\"6.0\"},\"solaris\":{\"\":\"\",\"10\":\"10\"},\"ubuntu\":{\"\":\"\",\"hardy\":\"8.04\",\"karmic\":\"9.10\",\"lucid\":\"10.04\",\"10.04.1\":\"10.04\",\"maverick\":\"10.10\",\"natty\":\"11.04\",\"oneiric\":\"11.10\",\"precise\":\"12.04\"},\"windows\":{\"\":\"\",\"7\":\"7\",\"2003\":\"2003\",\"2003 Standard\":\"2003\",\"2003 R2\":\"2003 R2\",\"2008\":\"2008\",\"2008 Web\":\"2008\",\"2008 Server\":\"2008\",\"Server 2008\":\"2008\",\"2008 R1\":\"2008 R1\",\"2008 R2\":\"2008 R2\",\"Server 2008 R2\":\"2008 R2\",\"2008 Server R2\":\"2008 R2\",\"2008 SP2\":\"2008 SP2\",\"Server 2008 SP2\":\"2008 SP2\"}}";
}
@Singleton

View File

@ -103,7 +103,7 @@ public class GleSYSComputeServiceAdapter implements ComputeServiceAdapter<Server
ServerSpec.Builder builder = ServerSpec.builder();
builder.datacenter(template.getLocation().getId());
builder.templateName(template.getImage().getName());
builder.templateName(template.getImage().getId());
builder.platform(template.getHardware().getHypervisor());
builder.diskSizeGB(Math.round(template.getHardware().getVolumes().get(0).getSize()));
builder.cpuCores((int) template.getHardware().getProcessors().get(0).getCores());

View File

@ -51,7 +51,7 @@ public class OSTemplateToImage implements Function<OSTemplate, Image> {
Builder builder = OperatingSystem.builder();
builder.name(template.getName()).description(template.getName()).is64Bit(parsed.is64Bit).version(parsed.version)
.family(parsed.family);
return new ImageBuilder().ids(template.getName()).description(template.getName())
.operatingSystem(builder.build()).build();
return new ImageBuilder().ids(template.getName()).name(template.getName()).description(template.getName())
.operatingSystem(builder.build()).build();
}
}

View File

@ -34,8 +34,8 @@ import org.jclouds.compute.util.ComputeServiceUtils;
import com.google.common.base.Function;
/**
* Defaults to version null and 64bit, if the operating system is unrecognized and the pattern
* "32bit" isn't in the string.
* Defaults to version null and 64bit, if the operating system is unrecognized
* and the pattern "32bit" isn't in the string.
*
* @author Adrian Cole
*
@ -51,24 +51,43 @@ public class ParseOsFamilyVersion64BitFromImageName implements Function<String,
// ex Debian 6.0 64-bit
// ex. Ubuntu 10.04 LTS 32-bit
public static final Pattern PATTERN = Pattern.compile("([^ ]+).* ([0-9.]+)( [36][24]-bit)?$");
public static final Pattern OSFAMILY_VERSION = Pattern
.compile("([^ ]+).*[ -]([0-9.]+)( LTS)?( [36][24]-bit)?( x[68][46])?$");
public static final Pattern OSFAMILY = Pattern.compile("([^ ]+).*$");
@Override
public OsFamilyVersion64Bit apply(String input) {
boolean is64Bit = containsPattern("64-bit").apply(input);
boolean is64Bit = containsPattern("64").apply(input);
String version = "";
Matcher matcher = PATTERN.matcher(input);
if (input.indexOf("Windows") != -1) {
Matcher matcher = Pattern.compile(".*(20[01][0-9] R[1-9]).*").matcher(input);
if (matcher.find()) {
OsFamily fam = OsFamily.fromValue(matcher.group(1).toLowerCase());
switch (fam) {
case UNRECOGNIZED:
return new OsFamilyVersion64Bit(OsFamily.UNRECOGNIZED, null, is64Bit);
}
return new OsFamilyVersion64Bit(fam, ComputeServiceUtils.parseVersionOrReturnEmptyString(fam, matcher
.group(2), osVersionMap), is64Bit);
version = matcher.group(1);
} else {
return new OsFamilyVersion64Bit(OsFamily.UNRECOGNIZED, null, is64Bit);
matcher = Pattern.compile(".*(20[01][0-9]).*").matcher(input);
if (matcher.find())
version = matcher.group(1);
}
return new OsFamilyVersion64Bit(OsFamily.WINDOWS, osVersionMap.get(OsFamily.WINDOWS).get(version), is64Bit);
}
Matcher osFamilyVersionMatcher = OSFAMILY_VERSION.matcher(input);
if (osFamilyVersionMatcher.find()) {
OsFamily fam = OsFamily.fromValue(osFamilyVersionMatcher.group(1).toLowerCase());
switch (fam) {
case UNRECOGNIZED:
return new OsFamilyVersion64Bit(OsFamily.UNRECOGNIZED, version, is64Bit);
}
return new OsFamilyVersion64Bit(fam, ComputeServiceUtils.parseVersionOrReturnEmptyString(fam,
osFamilyVersionMatcher.group(2), osVersionMap), is64Bit);
} else {
Matcher osFamilyMatcher = OSFAMILY.matcher(input);
OsFamily fam = OsFamily.UNRECOGNIZED;
if (osFamilyMatcher.find()) {
fam = OsFamily.fromValue(osFamilyMatcher.group(1).toLowerCase());
}
return new OsFamilyVersion64Bit(fam, version, is64Bit);
}
}
}

View File

@ -48,7 +48,7 @@ public class GleSYSExperimentLiveTest extends BaseVersionedServiceLiveTest {
context = new ComputeServiceContextFactory().createContext(provider, identity, credential, ImmutableSet
.<Module> of(new Log4JLoggingModule(), new SshjSshClientModule()));
assertEquals(context.getComputeService().listAssignableLocations().size(), 6);
assertEquals(context.getComputeService().listAssignableLocations().size(), 4);
} finally {
if (context != null)

View File

@ -55,20 +55,24 @@ public class GleSYSTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
@Override
public boolean apply(OsFamilyVersion64Bit input) {
// TODO: this is an incomplete list until ParseOsFamilyVersion64BitFromImageName is
// complete
switch (input.family) {
case UBUNTU:
return (input.version.equals("")|| input.version.equals("11.04")) && input.is64Bit;
case DEBIAN:
return input.version.equals("") || input.version.matches("[56].0");
case FEDORA:
return input.version.equals("") || input.version.equals("13") || input.version.equals("15");
case CENTOS:
return input.version.equals("") || input.version.equals("5") || input.version.equals("5.0")
|| input.version.equals("6.0");
default:
return false;
case UBUNTU:
return input.version.equals("")
|| input.version.equals("10.04")
|| ((input.version.equals("8.04") || input.version.equals("11.04") || input.version
.equals("10.10")) && input.is64Bit);
case DEBIAN:
return input.version.equals("") || input.version.matches("[56].0");
case FEDORA:
return input.version.equals("") || input.version.equals("13") || input.version.equals("15");
case CENTOS:
return input.version.equals("") || input.version.equals("5") || input.version.equals("5.5")
|| input.version.equals("5.0") || input.version.equals("6.0");
case WINDOWS:
return input.version.equals("") || input.version.equals("2008")
|| (input.version.equals("2008 R2") && input.is64Bit);
default:
return false;
}
}
@ -78,7 +82,7 @@ public class GleSYSTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
@Test
public void testDefaultTemplateBuilder() throws IOException {
Template defaultTemplate = context.getComputeService().templateBuilder().build();
assertEquals(defaultTemplate.getImage().getId(), "11.04");
assertEquals(defaultTemplate.getImage().getId(), "Ubuntu 11.04 x64");
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.04");
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
@ -93,6 +97,6 @@ public class GleSYSTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
@Override
protected Set<String> getIso3166Codes() {
return ImmutableSet.<String> of("NL-NH","SE-N","US-NY","SE-AB");
return ImmutableSet.<String> of("NL-NH", "SE-N", "US-NY", "SE-AB");
}
}

View File

@ -4,12 +4,21 @@
"version": "5.0",
"is64Bit": false
},
"Centos 5 64-bit": {
"family": "CENTOS",
"version": "5.0",
"is64Bit": true
},
"CentOS 5.5 x64": {
"family": "CENTOS",
"version": "5.5",
"is64Bit": true
},
"CentOS 5.5 x86": {
"family": "CENTOS",
"version": "5.5",
"is64Bit": false
},
"Centos 6 32-bit": {
"family": "CENTOS",
"version": "6.0",
@ -20,6 +29,16 @@
"version": "6.0",
"is64Bit": true
},
"Centos 6 x64": {
"family": "CENTOS",
"version": "6.0",
"is64Bit": true
},
"Centos 6 x86": {
"family": "CENTOS",
"version": "6.0",
"is64Bit": false
},
"Debian 5.0": {
"family": "DEBIAN",
"version": "5.0",
@ -30,6 +49,11 @@
"version": "5.0",
"is64Bit": true
},
"Debian 5.0.1 x64": {
"family": "DEBIAN",
"version": "5.0",
"is64Bit": true
},
"Debian 6.0 32-bit": {
"family": "DEBIAN",
"version": "6.0",
@ -40,9 +64,104 @@
"version": "6.0",
"is64Bit": true
},
"Debian-6 x64": {
"family": "DEBIAN",
"version": "6.0",
"is64Bit": true
},
"Fedora Core 11": {
"family": "FEDORA",
"version": "",
"is64Bit": false
},
"Fedora Core 11 64-bit": {
"family": "FEDORA",
"version": "",
"is64Bit": true
},
"FreeBSD 8.2": {
"family": "FREEBSD",
"version": "",
"is64Bit": false
},
"Gentoo": {
"family": "GENTOO",
"version": "",
"is64Bit": false
},
"Gentoo 10.1 x64": {
"family": "GENTOO",
"version": "",
"is64Bit": true
},
"Gentoo 64-bit": {
"family": "GENTOO",
"version": "",
"is64Bit": true
},
"Scientific Linux 6": {
"family": "SCIENTIFIC",
"version": "",
"is64Bit": false
},
"Scientific Linux 6 64-bit": {
"family": "SCIENTIFIC",
"version": "",
"is64Bit": true
},
"Slackware 12": {
"family": "SLACKWARE",
"version": "",
"is64Bit": false
},
"Ubuntu 10.04 LTS 32-bit": {
"family": "UBUNTU",
"version": "10.04",
"is64Bit": false
},
"Ubuntu 10.04 LTS 64-bit": {
"family": "UBUNTU",
"version": "10.04",
"is64Bit": true
},
"Ubuntu 10.10 x64": {
"family": "UBUNTU",
"version": "10.10",
"is64Bit": true
},
"Ubuntu 11.04 64-bit": {
"family": "UBUNTU",
"version": "11.04",
"is64Bit": true
},
"Ubuntu 11.04 x64": {
"family": "UBUNTU",
"version": "11.04",
"is64Bit": true
},
"Ubuntu 8.04 x64": {
"family": "UBUNTU",
"version": "8.04",
"is64Bit": true
},
"Windows Server 2008 R2 x64 std": {
"family": "WINDOWS",
"version": "2008 R2",
"is64Bit": true
},
"Windows Server 2008 R2 x64 web": {
"family": "WINDOWS",
"version": "2008 R2",
"is64Bit": true
},
"Windows Server 2008 x64 web": {
"family": "WINDOWS",
"version": "2008",
"is64Bit": true
},
"Windows Server 2008 x86 web": {
"family": "WINDOWS",
"version": "2008",
"is64Bit": false
}
}