Commit 31c25e4c authored by Vincent Pelletier's avatar Vincent Pelletier

Make neoctl expect & handle properly a "not ready" error code from admin node.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@1037 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent d1530fcd
......@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo.neoctl.neoctl import NeoCTL
from neo.neoctl.neoctl import NeoCTL, NotReadyException
from neo.util import bin, dump
from neo import protocol
......@@ -209,7 +209,10 @@ class Application(object):
if result is None:
result = 'Ok'
else:
result = action(args[level:])
try:
result = action(args[level:])
except NotReadyException, message:
result = message
return result
......
......@@ -68,3 +68,6 @@ class CommandEventHandler(EventHandler):
def handleNoError(self, conn, packet, msg):
self.__respond((packet.getType(), protocol.NO_ERROR_CODE, msg))
def handleNotReady(self, conn, packet, msg):
self.__respond((packet.getType(), protocol.NOT_READY_CODE, msg))
......@@ -21,6 +21,9 @@ from neo.event import EventManager
from neo.neoctl.handler import CommandEventHandler
from neo import protocol
class NotReadyException(Exception):
pass
class NeoCTL(object):
connection = None
......@@ -52,7 +55,11 @@ class NeoCTL(object):
self.em.poll(0)
if not self.connected:
raise Exception, 'Connection closed'
return response_queue.pop()
response = response_queue.pop()
if response[0] == protocol.ERROR and \
response[1] == protocol.NOT_READY_CODE:
raise NotReadyException(response[2])
return response
def enableStorageList(self, node_list):
"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment