overlord: add environment variables to change port to bind/connect

Add ability to control which port overlordd/ghost to bind/connect to
using environment variables OVERLORD_PORT, OVERLORD_HTTP_PORT,
OVERLORD_LD_PORT, GHOST_RPC_PORT.

Also fix two tests that are calling overlord to use random port, so they
can be passed even if another overlord instance is running.

We expect that the default port is always used, but we need this ability
to make unit test not failing because of port is in used.

BUG=chromium:665306
TEST=make test, and make sure all tests can be passed in the first try.
TEST=manually start an overlordd instance, then run make test. check all
     tests still pass.

Change-Id: Icf3335bc0a586cc68a07a812f998444cfdc1ebb6
Reviewed-on: https://chromium-review.googlesource.com/422791
Commit-Ready: Pi-Hsun Shih <pihsun@chromium.org>
Tested-by: Pi-Hsun Shih <pihsun@chromium.org>
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
diff --git a/py/tools/ghost.py b/py/tools/ghost.py
index 0133a6e..0130682 100755
--- a/py/tools/ghost.py
+++ b/py/tools/ghost.py
@@ -36,11 +36,11 @@
 from jsonrpclib.SimpleJSONRPCServer import SimpleJSONRPCServer
 
 
-_GHOST_RPC_PORT = 4499
+_GHOST_RPC_PORT = int(os.getenv('GHOST_RPC_PORT', 4499))
 
-_OVERLORD_PORT = 4455
-_OVERLORD_LAN_DISCOVERY_PORT = 4456
-_OVERLORD_HTTP_PORT = 9000
+_OVERLORD_PORT = int(os.getenv('OVERLORD_PORT', 4455))
+_OVERLORD_LAN_DISCOVERY_PORT = int(os.getenv('OVERLORD_LD_PORT', 4456))
+_OVERLORD_HTTP_PORT = int(os.getenv('OVERLORD_HTTP_PORT', 9000))
 
 _BUFSIZE = 8192
 _RETRY_INTERVAL = 2