brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [49/50] brooklyn-server git commit: Avoid NPE in toMetadataRecord for jclouds machine
Date Mon, 01 Feb 2016 17:49:53 GMT
Avoid NPE in toMetadataRecord for jclouds machine

Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/2863788c
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/2863788c
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/2863788c

Branch: refs/heads/0.6.0
Commit: 2863788cf689ae2cf8e678a15fe28cf27c371dd6
Parents: bb96f77
Author: Aled Sage <aled.sage@gmail.com>
Authored: Mon Nov 18 13:30:46 2013 +0000
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Mon Nov 18 13:30:46 2013 +0000

----------------------------------------------------------------------
 .../location/jclouds/JcloudsSshMachineLocation.java   | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/2863788c/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsSshMachineLocation.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsSshMachineLocation.java
b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsSshMachineLocation.java
index d23ca8c..282a37f 100644
--- a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsSshMachineLocation.java
+++ b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsSshMachineLocation.java
@@ -5,6 +5,7 @@ import static brooklyn.util.GroovyJavaMethods.truth;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
@@ -15,7 +16,9 @@ import javax.annotation.Nullable;
 import org.jclouds.compute.ComputeServiceContext;
 import org.jclouds.compute.callables.RunScriptOnNode;
 import org.jclouds.compute.domain.ExecResponse;
+import org.jclouds.compute.domain.Hardware;
 import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.Processor;
 import org.jclouds.compute.options.RunScriptOptions;
 import org.jclouds.domain.LoginCredentials;
 import org.jclouds.scriptbuilder.domain.InterpretableStatement;
@@ -209,16 +212,19 @@ public class JcloudsSshMachineLocation extends SshMachineLocation implements
Has
     
     @Override
     public Map<String, String> toMetadataRecord() {
+        Hardware hardware = node.getHardware();
+        List<? extends Processor> processors = (hardware != null) ? hardware.getProcessors()
: null;
+        
         ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
         builder.putAll(super.toMetadataRecord());
         putIfNotNull(builder, "provider", getParent().getProvider());
         putIfNotNull(builder, "account", getParent().getIdentity());
         putIfNotNull(builder, "serverId", node.getProviderId());
         putIfNotNull(builder, "imageId", node.getImageId());
-        putIfNotNull(builder, "instanceTypeName", node.getHardware().getName());
-        putIfNotNull(builder, "instanceTypeId", node.getHardware().getProviderId());
-        putIfNotNull(builder, "ram", "" + node.getHardware().getRam());
-        putIfNotNull(builder, "cpus", "" + node.getHardware().getProcessors().size());
+        putIfNotNull(builder, "instanceTypeName", (hardware != null ? hardware.getName()
: null));
+        putIfNotNull(builder, "instanceTypeId", (hardware != null ? hardware.getProviderId()
: null));
+        putIfNotNull(builder, "ram", "" + (hardware != null ? hardware.getRam() : null));
+        putIfNotNull(builder, "cpus", "" + (processors != null ? processors.size() : null));
         putIfNotNull(builder, "osName", getOsDetails().getName());
         putIfNotNull(builder, "osArch", getOsDetails().getArch());
         putIfNotNull(builder, "64bit", getOsDetails().is64bit() ? "true" : "false");


Mime
View raw message