+class ExperimentData(object):
+ def __init__(self):
+ self.data = dict()
+
+ @property
+ def guids(self):
+ return self.data.keys()
+
+ def add_testbed_data(self, guid, testbed_id, testbed_version):
+ testbed_data = dict()
+ testbed_data["testbed_id"] = testbed_id
+ testbed_data["testbed_version"] = testbed_version
+ self.data[guid] = testbed_data
+
+ def add_box_data(self, guid, testbed_guid, factory_id):
+ box_data = dict()
+ box_data["testbed_guid"] = testbed_guid
+ box_data["factory_id"] = factory_id
+ self.data[guid] = box_data
+
+ def add_factory_attribute_data(self, guid, name, value):
+ data = self.data[guid]
+ if not "factory_attributes" in data:
+ data["factory_attributes"] = dict()
+ factory_attributes_data = data["factory_attributes"]
+ factory_attributes_data[name] = value
+
+ def add_attribute_data(self, guid, name, value):
+ data = self.data[guid]
+ if not "attributes" in data:
+ data["attributes"] = dict()
+ attributes_data = data["attributes"]
+ attributes_data[name] = value
+
+ def add_trace_data(self, guid, trace_name):
+ data = self.data[guid]
+ if not "traces" in data:
+ data["traces"] = list()
+ traces_data = data["traces"]
+ traces_data.append(trace_name)
+
+ def add_connection_data(self, guid, connector_type_name, other_guid,
+ other_connector_type_name):
+ data = self.data[guid]
+ if not "connections" in data:
+ data["connections"] = dict()
+ connections_data = data["connections"]
+ if not connector_type_name in connections_data:
+ connections_data[connector_type_name] = dict()
+ connection_data = connections_data[connector_type_name]
+ connection_data[other_guid] = other_connector_type_name
+
+ def add_address_data(self, guid, autoconf, address, family, netprefix,
+ broadcast):
+ data = self.data[guid]
+ if not "addresses" in data:
+ data["addresses"] = list()
+ addresses_data = data["addresses"]
+ address_data = dict()
+ if autoconf:
+ address_data["AutoConfigure"] = autoconf
+ if address:
+ address_data["Address"] = address
+ if family:
+ address_data["Family"] = family
+ if netprefix:
+ address_data["NetPrefix"] = netprefix
+ if broadcast:
+ address_data["Broadcast"] = broadcast
+ addresses_data.append(address_data)
+
+ def add_route_data(self, guid, family, destination, netprefix, nexthop,
+ interface):
+ data = self.data[guid]
+ if not "routes" in data:
+ data["routes"] = list()
+ routes_data = data["routes"]
+ route_data = dict({
+ "Family": family,
+ "Destination": destination,
+ "NetPrefix": netprefix,
+ "NextHop": nexthop,
+ "Interface": Interface
+ })
+ routes_data.append(route_data)
+
+ def is_testbed_data(self, guid):
+ return True if "testbed_id" in self.data[guid] else None
+
+ def get_testbed_data(self, guid):
+ testbed_data = self.data[guid]
+ return (testbed_data["testbed_id"], testbed_data["testbed_version"])
+
+ def get_box_data(self, guid):
+ box_data = self.data[guid]
+ return (box_data["testbed_guid"], box_data["factory_id"])
+
+ def get_factory_attribute_data(self, guid):
+ data = self.data[guid]
+ if not "factory_attributes" in data:
+ return []
+ factory_attributes_data = data["factory_attributes"]
+ return [(name, value) for name, value \
+ in factory_attributes_data.iteritems()]
+
+ def get_attribute_data(self, guid):
+ data = self.data[guid]
+ if not "attributes" in data:
+ return []
+ attributes_data = data["attributes"]
+ return [(name, value) for name, value \
+ in attributes_data.iteritems()]
+
+ def get_trace_data(self, guid):
+ data = self.data[guid]
+ if not "traces" in data:
+ return []
+ return [trace_name for trace_name in data["traces"]]
+
+ def get_connection_data(self, guid):
+ data = self.data[guid]
+ if not "connections" in data:
+ return []
+ connections_data = data["connections"]
+ return [(connector_type_name, other_guid, other_connector_type_name) \
+ for connector_type_name, connection_data \
+ in connections_data.iteritems() \
+ for other_guid, other_connector_type_name \
+ in connection_data.iteritems()]
+
+ def get_address_data(self, guid):
+ data = self.data[guid]
+ if not "addresses" in data:
+ return []
+ addresses_data = data["addresses"]
+ return [(data["AutoConfigure"] if "AutoConfigure" in data else None,
+ data["Address"] if "Address" in data else None,
+ data["Family"] if "Family" in data else None,
+ data["NetPrefix"] if "NetPrefix" in data else None,
+ data["Broadcast"] if "Broadcast" in data else None) \
+ for data in addresses_data]
+
+ def get_route_data(self, guid):
+ data = self.data[guid]
+ if not "routes" in data:
+ return []
+ routes_data = data["routes"]
+ return [(data["Family"],
+ data["Destination"],
+ data["NetPrefix"],
+ data["NextHop"],
+ data["Interface"]) \
+ for data in routes_data]
+