Browse Source

ping/exec-on-peer: derive target from MAC

the previous addresses field is not published by BATCAVE
Helge Jung 9 years ago
parent
commit
5ebe9ba802
1 changed files with 6 additions and 6 deletions
  1. 6 6
      modules/ffpb.py

+ 6 - 6
modules/ffpb.py

@@ -657,9 +657,9 @@ def ffpb_ping(bot, trigger=None, target_name=None, reply_directly=True):
     if node is None:
         return None
 
-    # get the first non-linklocal address from the node
-    target = [x for x in node["network"]["addresses"]
-              if not x.lower().startswith("fe80:")][0]
+    # derive node address from MAC
+    node_mac = node.get('mac')
+    target = mac2ipv6(node_mac, 'fdca:ffee:ff12:132:')
     target_alias = node["hostname"]
 
     # execute the actual ping and reply the result
@@ -778,9 +778,9 @@ def ffpb_remoteexec(bot, trigger):
     if not playitsafe(bot, trigger, via_channel=True, node=node):
         return
 
-    # use the node's first non-linklocal address
-    naddrs = node["network"]["addresses"]
-    target = [x for x in naddrs if not x.lower().startswith("fe80:")][0]
+    # derive target from node's MAC
+    node_mac = node.get('mac')
+    target = mac2ipv6(node_mac, 'fdca:ffee:ff12:132:')
     target_alias = node["hostname"]
 
     # assemble SSH command