From 100dcbdebaf3e99219b6c0a28d2049a837018806 Mon Sep 17 00:00:00 2001 From: Alina Quereilhac Date: Sun, 1 May 2011 20:14:43 +0200 Subject: [PATCH] testbed.status now accept guid = None to return the testbed status --- src/nepi/core/testbed_impl.py | 4 +++- src/nepi/util/proxy.py | 20 +++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/nepi/core/testbed_impl.py b/src/nepi/core/testbed_impl.py index 23673ea5..37d53eb7 100644 --- a/src/nepi/core/testbed_impl.py +++ b/src/nepi/core/testbed_impl.py @@ -418,7 +418,9 @@ class TestbedController(execute.TestbedController): stop_function(self, guid) self._status = TESTBED_STATUS_STOPPED - def status(self, guid): + def status(self, guid = None): + if not guid: + return self._status if not guid in self._create: raise RuntimeError("Element guid %d doesn't exist" % guid) factory = self._get_factory(guid) diff --git a/src/nepi/util/proxy.py b/src/nepi/util/proxy.py index 40f06d43..9470ad5e 100644 --- a/src/nepi/util/proxy.py +++ b/src/nepi/util/proxy.py @@ -99,7 +99,7 @@ testbed_messages = dict({ GET_ROUTE: "%d|%s" % (GET, "%d|%d|%s"), GET_ADDRESS: "%d|%s" % (GET, "%d|%d|%s"), ACTION: "%d|%s" % (ACTION, "%s|%d|%s"), - STATUS: "%d|%s" % (STATUS, "%d"), + STATUS: "%d|%s" % (STATUS, "%s"), GUIDS: "%d" % GUIDS, GET_ATTRIBUTE_LIST: "%d" % GET_ATTRIBUTE_LIST, TESTBED_ID: "%d" % TESTBED_ID, @@ -591,16 +591,16 @@ class TestbedControllerServer(server.Server): return "%d|%s" % (OK, "") def get_address(self, params): - guid = int(param[1]) - index = int(param[2]) + guid = int(params[1]) + index = int(params[2]) attribute = base64.b64decode(param[3]) value = self._testbed.get_address(guid, index, attribute) result = base64.b64encode(str(value)) return "%d|%s" % (OK, result) def get_route(self, params): - guid = int(param[1]) - index = int(param[2]) + guid = int(params[1]) + index = int(params[2]) attribute = base64.b64decode(param[3]) value = self._testbed.get_route(guid, index, attribute) result = base64.b64encode(str(value)) @@ -614,13 +614,15 @@ class TestbedControllerServer(server.Server): return "%d|%s" % (OK, "") def status(self, params): - guid = int(params[1]) + guid = None + if params[1] != "None": + guid = int(params[1]) status = self._testbed.status(guid) result = base64.b64encode(str(status)) return "%d|%s" % (OK, result) def get_attribute_list(self, params): - guid = int(param[1]) + guid = int(params[1]) attr_list = self._testbed.get_attribute_list(guid) value = cPickle.dumps(attr_list) result = base64.b64encode(value) @@ -1090,9 +1092,9 @@ class TestbedControllerProxy(object): if code == ERROR: raise RuntimeError(text) - def status(self, guid): + def status(self, guid = None): msg = testbed_messages[STATUS] - msg = msg % (guid) + msg = msg % str(guid) self._client.send_msg(msg) reply = self._client.read_reply() result = reply.split("|") -- 2.47.0