chiark / gitweb /
svc/connect.in: Add a method for finding a named PingPeer.
[tripe] / svc / connect.in
index feb79ea8ef005e155b67037cc02d090592331c6d..917366d15eb0b86553311c798072ede0133fee5e 100644 (file)
@@ -586,6 +586,10 @@ class Pinger (T.Coroutine):
     """
     return me._peers.keys()
 
+  def find(me, name):
+    """Return the PingPeer with the given name."""
+    return me._peers[name]
+
 ###--------------------------------------------------------------------------
 ### New connections.
 
@@ -712,8 +716,8 @@ def cmd_kick(name):
   """
   kick NAME: Force a new connection attempt for the NAMEd peer.
   """
-  if name not in pinger.adopted():
-    raise T.TripeJobError('peer-not-adopted', name)
+  try: pp = pinger.find(name)
+  except KeyError: raise T.TripeJobError('peer-not-adopted', name)
   try: peer = Peer(name)
   except KeyError: raise T.TripeJobError('unknown-peer', name)
   T.spawn(run_connect, peer, peer.get('connect'))