From: Alina Quereilhac Date: Tue, 24 May 2011 10:44:45 +0000 (+0200) Subject: Added metods to obtain factory_id, testbed_id and testbed_version for a box using... X-Git-Tag: nepi_v2~2^2~5 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=88fe3d5283967d3cf30b4104a640b4506759ca3f;p=nepi.git Added metods to obtain factory_id, testbed_id and testbed_version for a box using inly a guid, from the controller --- diff --git a/src/nepi/core/execute.py b/src/nepi/core/execute.py index c7919d5a..d2d21c58 100644 --- a/src/nepi/core/execute.py +++ b/src/nepi/core/execute.py @@ -329,7 +329,7 @@ class TestbedController(object): def get_attribute_list(self, guid): raise NotImplementedError - def get_tags(self, guid): + def get_factory_id(self, guid): raise NotImplementedError def action(self, time, guid, action): @@ -420,7 +420,7 @@ class ExperimentController(object): self._parallel([testbed.do_setup for guid,testbed in self._testbeds.iteritems() if guid in allowed_guids]) - + # perform create-connect in parallel, wait # (internal connections only) self._parallel([testbed.do_create @@ -438,9 +438,10 @@ class ExperimentController(object): self._parallel([testbed.do_preconfigure for guid,testbed in self._testbeds.iteritems() if guid in allowed_guids]) - + self._clear_caches() + steps_to_configure(self, self._testbeds) - + if self._netreffed_testbeds: # initally resolve netrefs self.do_netrefs(data, fail_if_undefined=False) @@ -466,7 +467,8 @@ class ExperimentController(object): self._parallel([testbed.do_configure for testbed in self._testbeds.itervalues()]) - + self._clear_caches() + #print >>sys.stderr, "DO IT" #import time #time.sleep(60) @@ -479,17 +481,24 @@ class ExperimentController(object): cross_data = self._get_cross_data(guid) testbed.do_cross_connect_compl(cross_data) + self._clear_caches() + # Last chance to configure (parallel on all testbeds) self._parallel([testbed.do_prestart for testbed in self._testbeds.itervalues()]) - # After this point no new elements will be craeted. Cleaning cache for safety. - self._guids_in_testbed_cache = dict() + self._clear_caches() # start experiment (parallel start on all testbeds) self._parallel([testbed.start for testbed in self._testbeds.itervalues()]) + self._clear_caches() + + def _clear_caches(self): + # Cleaning cache for safety. + self._guids_in_testbed_cache = dict() + def _persist_testbed_proxies(self): TRANSIENT = ('Recover',) @@ -579,10 +588,22 @@ class ExperimentController(object): return testbed.get(guid, name, time) raise RuntimeError("No element exists with guid %d" % guid) - def get_tags(self, guid): + def get_factory_id(self, guid): + testbed = self._testbed_for_guid(guid) + if testbed != None: + return testbed.get_factory_id(guid) + raise RuntimeError("No element exists with guid %d" % guid) + + def get_testbed_id(self, guid): + testbed = self._testbed_for_guid(guid) + if testbed != None: + return testbed.testbed_id + raise RuntimeError("No element exists with guid %d" % guid) + + def get_testbed_version(self, guid): testbed = self._testbed_for_guid(guid) if testbed != None: - return testbed.get_tags(guid) + return testbed.testbed_version raise RuntimeError("No element exists with guid %d" % guid) def shutdown(self): diff --git a/src/nepi/core/testbed_impl.py b/src/nepi/core/testbed_impl.py index b34b8fe1..663851d8 100644 --- a/src/nepi/core/testbed_impl.py +++ b/src/nepi/core/testbed_impl.py @@ -392,15 +392,15 @@ class TestbedController(execute.TestbedController): return addresses[index][attribute_index] - def get_tags(self, guid): - factory = self._get_factory(guid) - return factory.tags - def get_attribute_list(self, guid): factory = self._get_factory(guid) attribute_list = list() return factory.box_attributes.attributes_list + def get_factory_id(self, guid): + factory = self._get_factory(guid) + return factory.factory_id + def start(self, time = TIME_NOW): self._do_in_factory_order( 'start_function', diff --git a/src/nepi/util/proxy.py b/src/nepi/util/proxy.py index 8db9dd77..7ed34ce5 100644 --- a/src/nepi/util/proxy.py +++ b/src/nepi/util/proxy.py @@ -53,10 +53,10 @@ DO_CONNECT_COMPL = 33 DO_CROSS_CONNECT_COMPL = 34 TESTBED_ID = 35 TESTBED_VERSION = 36 -EXPERIMENT_SET = 37 -EXPERIMENT_GET = 38 -DO_PRESTART = 39 -GET_TAGS = 40 +DO_PRESTART = 37 +GET_FACTORY_ID = 38 +GET_TESTBED_ID = 39 +GET_TESTBED_VERSION = 40 instruction_text = dict({ OK: "OK", @@ -90,14 +90,14 @@ instruction_text = dict({ GET_ROUTE: "GET_ROUTE", GET_ADDRESS: "GET_ADDRESS", GET_ATTRIBUTE_LIST: "GET_ATTRIBUTE_LIST", + GET_FACTORY_ID: "GET_FACTORY_ID", + GET_TESTBED_ID: "GET_TESTBED_ID", + GET_TESTBED_VERSION: "GET_TESTBED_VERSION", ACTION: "ACTION", STATUS: "STATUS", GUIDS: "GUIDS", TESTBED_ID: "TESTBED_ID", TESTBED_VERSION: "TESTBED_VERSION", - EXPERIMENT_SET: "EXPERIMENT_SET", - EXPERIMENT_GET: "EXPERIMENT_GET", - GET_TAGS: "GET_TAGS", }) def log_msg(server, params): @@ -645,11 +645,11 @@ class TestbedControllerServer(BaseServer): def get_attribute_list(self, guid): return self._testbed.get_attribute_list(guid) - @Marshalling.handles(GET_TAGS) + @Marshalling.handles(GET_FACTORY_ID) @Marshalling.args(int) - @Marshalling.retval( Marshalling.pickled_data ) - def get_tags(self, guid): - return self._testbed.get_tags(guid) + @Marshalling.retval() + def get_factory_id(self, guid): + return self._testbed.get_factory_id(guid) class ExperimentControllerServer(BaseServer): def __init__(self, root_dir, log_level, experiment_xml): @@ -686,24 +686,18 @@ class ExperimentControllerServer(BaseServer): def is_finished(self, guid): return self._controller.is_finished(guid) - @Marshalling.handles(EXPERIMENT_GET) + @Marshalling.handles(GET) @Marshalling.args(int, Marshalling.base64_data, str) @Marshalling.retval( Marshalling.pickled_data ) def get(self, guid, name, time): return self._controller.get(guid, name, time) - @Marshalling.handles(EXPERIMENT_SET) + @Marshalling.handles(SET) @Marshalling.args(int, Marshalling.base64_data, Marshalling.pickled_data, str) @Marshalling.retvoid def set(self, guid, name, value, time): self._controller.set(guid, name, value, time) - @Marshalling.handles(GET_TAGS) - @Marshalling.args(int) - @Marshalling.retval( Marshalling.pickled_data ) - def get_tags(self, guid): - return self._controller.get_tags(guid) - @Marshalling.handles(START) @Marshalling.args() @Marshalling.retvoid @@ -728,6 +722,24 @@ class ExperimentControllerServer(BaseServer): def shutdown(self): self._controller.shutdown() + @Marshalling.handles(GET_TESTBED_ID) + @Marshalling.args(int) + @Marshalling.retval() + def get_testbed_id(self, guid): + return self._controller.get_testbed_id(guid) + + @Marshalling.handles(GET_FACTORY_ID) + @Marshalling.args(int) + @Marshalling.retval() + def get_factory_id(self, guid): + return self._controller.get_factory_id(guid) + + @Marshalling.handles(GET_TESTBED_VERSION) + @Marshalling.args(int) + @Marshalling.retval() + def get_testbed_version(self, guid): + return self._controller.get_testbed_version(guid) + class BaseProxy(object): _ServerClass = None _ServerClassModule = "nepi.util.proxy" diff --git a/test/core/execute.py b/test/core/execute.py index 2f393792..8055e99e 100755 --- a/test/core/execute.py +++ b/test/core/execute.py @@ -50,7 +50,6 @@ class ExecuteTestCase(unittest.TestCase): """ self.assertTrue(app_result.startswith(comp_result)) - self.assertEquals(instance.get_tags(4), [tags.MOBILE]) instance.stop() instance.shutdown() diff --git a/test/core/integration.py b/test/core/integration.py index 2bd0d9b7..c135b5f3 100755 --- a/test/core/integration.py +++ b/test/core/integration.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- from nepi.core.design import ExperimentDescription, FactoriesProvider -from nepi.util import proxy, tags +from nepi.util import proxy from nepi.util.constants import STATUS_FINISHED, DeploymentConfiguration as DC import mock import mock.metadata_v01 @@ -100,7 +100,10 @@ class ExecuteTestCase(unittest.TestCase): 1 packets transmitted, 1 received, 0% packet loss, time 0ms """ self.assertTrue(fake_result.startswith(comp_result)) - self.assertEquals(controller.get_tags(node1.guid), [tags.MOBILE]) + + self.assertEquals(controller.get_testbed_id(node1.guid), "mock") + self.assertEquals(controller.get_testbed_version(node1.guid), "01") + self.assertEquals(controller.get_factory_id(node1.guid), "Node") controller.stop() controller.shutdown() @@ -123,7 +126,10 @@ class ExecuteTestCase(unittest.TestCase): 1 packets transmitted, 1 received, 0% packet loss, time 0ms """ self.assertTrue(fake_result.startswith(comp_result)) - self.assertEquals(controller.get_tags(node1.guid), [tags.MOBILE]) + + self.assertEquals(controller.get_testbed_id(node1.guid), "mock") + self.assertEquals(controller.get_testbed_version(node1.guid), "01") + self.assertEquals(controller.get_factory_id(node1.guid), "Node") controller.stop() controller.shutdown() @@ -148,7 +154,10 @@ class ExecuteTestCase(unittest.TestCase): 1 packets transmitted, 1 received, 0% packet loss, time 0ms """ self.assertTrue(fake_result.startswith(comp_result)) - self.assertEquals(controller.get_tags(node1.guid), [tags.MOBILE]) + + self.assertEquals(controller.get_testbed_id(node1.guid), "mock") + self.assertEquals(controller.get_testbed_version(node1.guid), "01") + self.assertEquals(controller.get_factory_id(node1.guid), "Node") controller.stop() controller.shutdown() @@ -178,7 +187,10 @@ class ExecuteTestCase(unittest.TestCase): 1 packets transmitted, 1 received, 0% packet loss, time 0ms """ self.assertTrue(fake_result.startswith(comp_result)) - self.assertEquals(controller.get_tags(node1.guid), [tags.MOBILE]) + + self.assertEquals(controller.get_testbed_id(node1.guid), "mock") + self.assertEquals(controller.get_testbed_version(node1.guid), "01") + self.assertEquals(controller.get_factory_id(node1.guid), "Node") controller.stop() controller.shutdown() @@ -208,7 +220,10 @@ class ExecuteTestCase(unittest.TestCase): 1 packets transmitted, 1 received, 0% packet loss, time 0ms """ self.assertTrue(fake_result.startswith(comp_result)) - self.assertEquals(controller.get_tags(node1.guid), [tags.MOBILE]) + + self.assertEquals(controller.get_testbed_id(node1.guid), "mock") + self.assertEquals(controller.get_testbed_version(node1.guid), "01") + self.assertEquals(controller.get_factory_id(node1.guid), "Node") # controller dies del controller