From 4ca1b175aff1579713640e98de2714d4121744a7 Mon Sep 17 00:00:00 2001
From: Alexander Schreiber <als@google.com>
Date: Mon, 17 Sep 2007 14:04:13 +0000
Subject: [PATCH] Cleanup up selective imports for utils and utils unit test.

Reviewed-by: iustinp, imsnah
---
 lib/utils.py                  | 12 ++++++------
 test/ganeti.utils_unittest.py |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/utils.py b/lib/utils.py
index 3f2864658..13ec99a27 100644
--- a/lib/utils.py
+++ b/lib/utils.py
@@ -32,7 +32,7 @@ import re
 import socket
 import tempfile
 import shutil
-from errno import ENOENT, ENOTDIR, EISDIR, EEXIST, EADDRNOTAVAIL, ECONNREFUSED
+import errno
 
 from ganeti import logger
 from ganeti import errors
@@ -115,7 +115,7 @@ def Lock(name, max_retries=None, debug=False):
       fd = os.open(lockfile, os.O_CREAT | os.O_EXCL | os.O_RDWR | os.O_SYNC)
       break
     except OSError, creat_err:
-      if creat_err.errno != EEXIST:
+      if creat_err.errno != errno.EEXIST:
         raise errors.LockError("Can't create the lock file. Error '%s'." %
                                str(creat_err))
 
@@ -266,7 +266,7 @@ def RemoveFile(filename):
   try:
     os.unlink(filename)
   except OSError, err:
-    if err.errno not in (ENOENT, EISDIR):
+    if err.errno not in (errno.ENOENT, errno.EISDIR):
       raise
 
 
@@ -355,7 +355,7 @@ def IsProcessAlive(pid):
   try:
     f = open("/proc/%d/status" % pid)
   except IOError, err:
-    if err.errno in (ENOENT, ENOTDIR):
+    if err.errno in (errno.ENOENT, errno.ENOTDIR):
       return False
 
   alive = True
@@ -804,7 +804,7 @@ def TcpPing(source, target, port, timeout=10, live_port_needed=True):
   try:
     sock.bind((source, 0))
   except socket.error, (errcode, errstring):
-    if errcode == EADDRNOTAVAIL:
+    if errcode == errno.EADDRNOTAVAIL:
       success = False
 
   sock.settimeout(timeout)
@@ -816,6 +816,6 @@ def TcpPing(source, target, port, timeout=10, live_port_needed=True):
   except socket.timeout:
     success = False
   except socket.error, (errcode, errstring):
-    success = (not live_port_needed) and (errcode == ECONNREFUSED)
+    success = (not live_port_needed) and (errcode == errno.ECONNREFUSED)
 
   return success
diff --git a/test/ganeti.utils_unittest.py b/test/ganeti.utils_unittest.py
index 388cb44bd..1ef9f9cf6 100755
--- a/test/ganeti.utils_unittest.py
+++ b/test/ganeti.utils_unittest.py
@@ -28,7 +28,7 @@ import tempfile
 import os.path
 import md5
 import socket
-from errno import EADDRNOTAVAIL
+
 
 import ganeti
 from ganeti.utils import IsProcessAlive, Lock, Unlock, RunCmd, \
-- 
GitLab