forked from M-Labs/artiq
ctlmgr: support hostnames in DDB
This commit is contained in:
parent
d2619eb78b
commit
c91705c5d1
|
@ -6,6 +6,7 @@ import os
|
||||||
import logging
|
import logging
|
||||||
import signal
|
import signal
|
||||||
import shlex
|
import shlex
|
||||||
|
import socket
|
||||||
|
|
||||||
from artiq.protocols.sync_struct import Subscriber
|
from artiq.protocols.sync_struct import Subscriber
|
||||||
from artiq.tools import verbosity_args, init_logger
|
from artiq.tools import verbosity_args, init_logger
|
||||||
|
@ -71,6 +72,14 @@ class Controller:
|
||||||
process.send_signal(signal.SIGKILL)
|
process.send_signal(signal.SIGKILL)
|
||||||
|
|
||||||
|
|
||||||
|
def get_ip_addresses(host):
|
||||||
|
try:
|
||||||
|
addrinfo = socket.getaddrinfo(host, None)
|
||||||
|
except:
|
||||||
|
return set()
|
||||||
|
return {info[4][0] for info in addrinfo}
|
||||||
|
|
||||||
|
|
||||||
class Controllers:
|
class Controllers:
|
||||||
def __init__(self, retry_command):
|
def __init__(self, retry_command):
|
||||||
self.retry_command = retry_command
|
self.retry_command = retry_command
|
||||||
|
@ -97,7 +106,7 @@ class Controllers:
|
||||||
|
|
||||||
def __setitem__(self, k, v):
|
def __setitem__(self, k, v):
|
||||||
if (isinstance(v, dict) and v["type"] == "controller"
|
if (isinstance(v, dict) and v["type"] == "controller"
|
||||||
and v["host"] == self.host_filter):
|
and self.host_filter in get_ip_addresses(v["host"])):
|
||||||
command = v["command"].format(name=k,
|
command = v["command"].format(name=k,
|
||||||
bind=self.host_filter,
|
bind=self.host_filter,
|
||||||
port=v["port"])
|
port=v["port"])
|
||||||
|
|
Loading…
Reference in New Issue