unspecified string instead of empty image name or description

This commit is contained in:
Dmitri Babaev 2011-04-07 23:01:21 +04:00 committed by Dmitri Babaev
parent e0a76aa08b
commit 4019137687
4 changed files with 17 additions and 12 deletions

View File

@ -44,10 +44,10 @@ public class NovaImageToImage implements Function<org.jclouds.openstack.nova.dom
public Image apply(org.jclouds.openstack.nova.domain.Image from) {
ImageBuilder builder = new ImageBuilder();
builder.ids(from.getId() + "");
builder.name(from.getName() + "");
builder.description(from.getName() + "");
builder.name(from.getName() != null ? from.getName() : "unspecified");
builder.description(from.getName() != null ? from.getName() : "unspecified");
builder.version(from.getUpdated().getTime() + "");
//builder.operatingSystem(imageToOs.apply(from)); //image name may not represent the OS type
builder.operatingSystem(imageToOs.apply(from)); //image name may not represent the OS type
builder.defaultCredentials(new Credentials("root", null));
Image image = builder.build();
return image;

View File

@ -62,13 +62,15 @@ public class NovaImageToOperatingSystem implements
String osName = null;
String osArch = null;
String osVersion = null;
String osDescription = from.getName();
String osDescription = from.getName() != null ? from.getName() : "unspecified";
String name = from.getName() != null ? from.getName() : "unspecified";
boolean is64Bit = true;
if (from.getName().indexOf("Red Hat EL") != -1) {
if (name.indexOf("Red Hat EL") != -1) {
osFamily = OsFamily.RHEL;
} else if (from.getName().indexOf("Oracle EL") != -1) {
} else if (name.indexOf("Oracle EL") != -1) {
osFamily = OsFamily.OEL;
} else if (from.getName().indexOf("Windows") != -1) {
} else if (name.indexOf("Windows") != -1) {
osFamily = OsFamily.WINDOWS;
Matcher matcher = WINDOWS_PATTERN.matcher(from.getName());
if (matcher.find()) {
@ -76,7 +78,7 @@ public class NovaImageToOperatingSystem implements
is64Bit = matcher.group(2).equals("x64");
}
} else {
Matcher matcher = DEFAULT_PATTERN.matcher(from.getName());
Matcher matcher = DEFAULT_PATTERN.matcher(name);
if (matcher.find()) {
try {
osFamily = OsFamily.fromValue(matcher.group(2).toLowerCase());

View File

@ -55,7 +55,7 @@ public class NovaListNodesStrategy implements ListNodesStrategy {
@Override
public Iterable<? extends NodeMetadata> listDetailsOnNodesMatching(Predicate<ComputeMetadata> filter) {
return Iterables.filter(Iterables.transform(client.listServers(/*ListOptions.Builder.withDetails()*/),
return Iterables.filter(Iterables.transform(client.listServers(ListOptions.Builder.withDetails()),
serverToNodeMetadata), filter);
}
}

View File

@ -31,14 +31,17 @@ public class _NovaClient {
ComputeService cs = context.getComputeService();
System.out.println(cs.listImages());
//System.out.println(cs.listNodes());
TemplateOptions options = new TemplateOptions();
//options.authorizePublicKey("");
Template template = cs.templateBuilder().hardwareId("m1.small").imageId("ami-0000000d").options(options).build();
try {
Template template = cs.templateBuilder().hardwareId("m1.small").imageId("13").options(options).build();
/*try {
cs.runNodesWithTag("test", 1, template);
} catch (RunNodesException e) {
e.printStackTrace();
}
}*/
//System.out.println(cs.listNodes());
//System.out.println(cs.listImages());