diff options
author | George Kraft <george.kraft@calxeda.com> | 2012-11-29 14:43:46 -0600 |
---|---|---|
committer | George Kraft <george.kraft@calxeda.com> | 2012-11-29 14:43:46 -0600 |
commit | 27c136d2e7ba65fd5abe502db8803049fb472a2c (patch) | |
tree | 6013283bbe7acd3e9d9e0a80716730be98a62c3a | |
parent | 5a02a590a41f0a19f5be78734948d6d98dade707 (diff) | |
download | cxmanage-27c136d2e7ba65fd5abe502db8803049fb472a2c.tar.gz |
InternalTftp: Always listen on all interfaces
Specifying an IP address for InternalTftp just overrides the
automatic discovery, nothing else. This is necessary for a host
under NAT to use an externally-facing IP address instead of its
internal one.
Also, InternalTftp.get_address now returns "localhost" if no
ip_address or relative_host are specified.
-rw-r--r-- | cxmanage_api/tftp.py | 8 | ||||
-rw-r--r-- | cxmanage_test/tftp_test.py | 7 |
2 files changed, 5 insertions, 10 deletions
diff --git a/cxmanage_api/tftp.py b/cxmanage_api/tftp.py index 0a4f13f..ded4a54 100644 --- a/cxmanage_api/tftp.py +++ b/cxmanage_api/tftp.py @@ -85,10 +85,10 @@ class InternalTftp(object): thread = PortThread() thread.start() try: - if (self.verbose): + if not self.verbose: setLogLevel(logging.CRITICAL) # Start accepting connections ... - server.listen(ip_address, port) + server.listen(listenport=port) except KeyboardInterrupt: # User @ keyboard cancelled server ... if (self.verbose): @@ -115,8 +115,10 @@ class InternalTftp(object): :rtype: string """ - if ((self.ip_address != None) or (relative_host == None)): + if (self.ip_address != None): return self.ip_address + elif (relative_host == None): + return "localhost" else: sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.connect((relative_host, self.port)) diff --git a/cxmanage_test/tftp_test.py b/cxmanage_test/tftp_test.py index 121d666..784211a 100644 --- a/cxmanage_test/tftp_test.py +++ b/cxmanage_test/tftp_test.py @@ -79,13 +79,6 @@ class InternalTftpTest(unittest.TestCase): self.assertEqual(open(filename).read(), contents) os.remove(filename) - def test_get_address_no_relative_host(self): - """Tests the get_address(relative_host) function with NO relative - host defined. - """ - self.assertEqual(self.tftp1.ip_address, - self.tftp1.get_address(relative_host=None)) - def test_get_address_with_relative_host(self): """Tests the get_address(relative_host) function with a relative_host specified. |