diff --git a/imagebuild/coreos/oem/system/teeth-agent.service b/imagebuild/coreos/oem/system/teeth-agent.service index 60d853934..a25c2ba7d 100644 --- a/imagebuild/coreos/oem/system/teeth-agent.service +++ b/imagebuild/coreos/oem/system/teeth-agent.service @@ -1,5 +1,5 @@ [Service] -ExecStart=/usr/bin/docker run -p 9999:9999 -privileged=true -v=/sys:/mnt/sys oemdocker /usr/local/bin/teeth-agent +ExecStart=/usr/bin/docker run -p 9999:9999 -privileged=true -v=/sys:/mnt/sys oemdocker /usr/local/bin/teeth-agent --ipaddr="`ip a | grep '10\.' | sed -e 's/inet \(10\.[0-9\.]\+\).*/\1/'`" Restart=always [Install] diff --git a/teeth_agent/agent.py b/teeth_agent/agent.py index 3632bd0cb..b8efe5f56 100644 --- a/teeth_agent/agent.py +++ b/teeth_agent/agent.py @@ -107,9 +107,10 @@ class TeethAgentHeartbeater(threading.Thread): class TeethAgent(object): - def __init__(self, api_url, listen_address): + def __init__(self, api_url, listen_address, ipaddr): self.api_url = api_url self.listen_address = listen_address + self.ipaddr = ipaddr self.mode_implementation = None self.version = pkg_resources.get_distribution('teeth-agent').version self.api = api.TeethAgentAPIServer(self) @@ -217,5 +218,5 @@ def _load_mode_implementation(mode_name): return mgr.driver -def build_agent(api_url, listen_host, listen_port): - return TeethAgent(api_url, (listen_host, listen_port)) +def build_agent(api_url, listen_host, listen_port, ipaddr): + return TeethAgent(api_url, (listen_host, listen_port), ipaddr) diff --git a/teeth_agent/cmd/agent.py b/teeth_agent/cmd/agent.py index bdfa8d41d..92f4ef386 100644 --- a/teeth_agent/cmd/agent.py +++ b/teeth_agent/cmd/agent.py @@ -39,8 +39,13 @@ def run(): type=int, help='The port to listen on') + parser.add_argument('--ipaddr', + required=True, + help='The external IP address to advertise to ironic') + args = parser.parse_args() logging.configure() agent.build_agent(args.api_url, args.listen_host, - args.listen_port).run() + args.listen_port, + args.ipaddr).run() diff --git a/teeth_agent/tests/agent.py b/teeth_agent/tests/agent.py index f1d4ed20c..5e46f6bd6 100644 --- a/teeth_agent/tests/agent.py +++ b/teeth_agent/tests/agent.py @@ -121,7 +121,8 @@ class TestBaseAgent(unittest.TestCase): encoding.SerializationViews.PUBLIC, indent=4) self.agent = agent.TeethAgent('https://fake_api.example.org:8081/', - ('localhost', 9999)) + ('localhost', 9999), + '192.168.1.1') def assertEqualEncoded(self, a, b): # Evidently JSONEncoder.default() can't handle None (??) so we have to