#
#
-# 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
import time
import errno
import logging
+import warnings
from ganeti import serializer
from ganeti import constants
while True:
try:
data = self.socket.recv(4096)
+ except socket.timeout, err:
+ raise TimeoutError("Receive timeout: %s" % str(err))
except socket.error, err:
if err.args and err.args[0] == errno.EAGAIN:
continue
raise
- except socket.timeout, err:
- raise TimeoutError("Receive timeout: %s" % str(err))
break
if not data:
raise ConnectionClosedError("Connection closed while reading")
# Parse the result
try:
data = serializer.LoadJson(msg)
+ except KeyboardInterrupt:
+ raise
except Exception, err:
raise ProtocolError("Error while deserializing response: %s" % str(err))
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.
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
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}
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))