Merge pull request #67 from rackerlabs/get-host-ip
Add horrible method of getting the host IP
This commit is contained in:
commit
9165d459a4
@ -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]
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user