[SDFAB-753] Improve ONOS cluster event

Main idea of this change is to add an additional parameter
in the event that carries information about the failed instance.

Additionally, prevents several NPE by using hostname as id
when controller hostname cannot be resolved into an ip.

Change-Id: Id9886afe3f1e5ecee0f1414b2722c340680a813e
diff --git a/cli/src/main/java/org/onosproject/cli/NodesListCommand.java b/cli/src/main/java/org/onosproject/cli/NodesListCommand.java
index ac6a5ec..da76950 100644
--- a/cli/src/main/java/org/onosproject/cli/NodesListCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/NodesListCommand.java
@@ -21,6 +21,7 @@
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import org.apache.karaf.shell.api.action.Command;
 import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.onlab.packet.IpAddress;
 import org.onosproject.cluster.ClusterAdminService;
 import org.onosproject.cluster.ControllerNode;
 import org.onosproject.core.Version;
@@ -70,9 +71,10 @@
         for (ControllerNode node : nodes) {
             ControllerNode.State nodeState = service.getState(node.id());
             Version nodeVersion = service.getVersion(node.id());
+            IpAddress nodeIp = node.ip();
             ObjectNode newNode = mapper.createObjectNode()
                     .put("id", node.id().toString())
-                    .put("ip", node.ip().toString())
+                    .put("ip", nodeIp != null ? nodeIp.toString() : node.host())
                     .put("tcpPort", node.tcpPort())
                     .put("self", node.equals(self));
             if (nodeState != null) {