Small improvements for cluster verify
[ganeti-local] / lib / luxi.py
index e4c0ff7..cfde21e 100644 (file)
@@ -1,7 +1,7 @@
 #
 #
 
-# Copyright (C) 2006, 2007 Google Inc.
+# Copyright (C) 2006, 2007, 2011 Google Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -34,6 +34,7 @@ import collections
 import time
 import errno
 import logging
+import warnings
 
 from ganeti import serializer
 from ganeti import constants
@@ -296,6 +297,8 @@ def ParseResponse(msg):
   # Parse the result
   try:
     data = serializer.LoadJson(msg)
+  except KeyboardInterrupt:
+    raise
   except Exception, err:
     raise ProtocolError("Error while deserializing response: %s" % str(err))
 
@@ -426,6 +429,12 @@ class Client(object):
       self._CloseTransport()
       raise
 
+  def Close(self):
+    """Close the underlying connection.
+
+    """
+    self._CloseTransport()
+
   def CallMethod(self, method, args):
     """Send a generic request and return the response.
 
@@ -493,7 +502,7 @@ class Client(object):
   def Query(self, what, fields, filter_):
     """Query for resources/items.
 
-    @param what: One of L{constants.QR_OP_LUXI}
+    @param what: One of L{constants.QR_VIA_LUXI}
     @type fields: List of strings
     @param fields: List of requested fields
     @type filter_: None or list
@@ -508,7 +517,7 @@ class Client(object):
   def QueryFields(self, what, fields):
     """Query for available fields.
 
-    @param what: One of L{constants.QR_OP_LUXI}
+    @param what: One of L{constants.QR_VIA_LUXI}
     @type fields: None or list of strings
     @param fields: List of requested fields
     @rtype: L{objects.QueryFieldsResponse}
@@ -543,4 +552,6 @@ class Client(object):
     return self.CallMethod(REQ_QUERY_TAGS, (kind, name))
 
   def QueryLocks(self, fields, sync):
+    warnings.warn("This LUXI call is deprecated and will be removed, use"
+                  " Query(\"%s\", ...) instead" % constants.QR_LOCK)
     return self.CallMethod(REQ_QUERY_LOCKS, (fields, sync))