def set(self, time, guid, name, value):
super(TestbedInstance, self).set(time, guid, name, value)
+
# TODO: take on account schedule time for the task
- element = self._elements[guid]
+ element = self._elements.get(guid)
if element:
setattr(element, name, value)
def get(self, time, guid, name):
# TODO: take on account schedule time for the task
- element = self._elements[guid]
- return getattr(element, name)
+ element = self._elements.get(guid)
+ if element:
+ try:
+ if hasattr(element, name):
+ # Runtime attribute
+ return getattr(element, name)
+ else:
+ # Try design-time attributes
+ return self.box_get(time, guid, name)
+ except KeyError, AttributeError:
+ return None
+
+ def get_route(self, guid, index, attribute):
+ # TODO: fetch real data from netns
+ try:
+ return self.box_get_route(guid, int(index), attribute)
+ except KeyError, AttributeError:
+ return None
+
+ def get_address(self, guid, index, attribute='Address'):
+ # TODO: fetch real data from netns
+ try:
+ return self.box_get_address(guid, int(index), attribute)
+ except KeyError, AttributeError:
+ return None
+
def action(self, time, guid, action):
raise NotImplementedError
- def trace(self, guid, trace_id):
- fd = open("%s" % self.trace_filename(guid, trace_id), "r")
- content = fd.read()
- fd.close()
- return content
-
def shutdown(self):
for trace in self._traces.values():
trace.close()