self._container = container
# traces -- list of available traces for the box
self._traces = dict()
+ # tags -- list of tags for the box
+ self._tags = list()
# connectors -- list of available connectors for the box
self._connectors = dict()
# factory_attributes -- factory attributes for box construction
for trace in factory.traces:
tr = Trace(trace.trace_id, trace.help, trace.enabled)
self._traces[trace.trace_id] = tr
+ for tag_id in factory.tags:
+ self._tags.append(tag_id)
for attr in factory.box_attributes.attributes:
self.add_attribute(attr.name, attr.help, attr.type, attr.value,
attr.range, attr.allowed, attr.flags,
def factory_attributes(self):
return self._factory_attributes
+ @property
+ def tags(self):
+ return self._tags
+
@property
def addresses(self):
return []
self._category = category
self._connector_types = list()
self._traces = list()
+ self._tags = list()
self._box_attributes = AttributesMap()
if not self._has_addresses and not self._has_routes:
def traces(self):
return self._traces
+ @property
+ def tags(self):
+ return self._tags
+
@property
def box_attributes(self):
return self._box_attributes
trace = Trace(trace_id, help, enabled)
self._traces.append(trace)
+ def add_tag(self, tag_id):
+ self._tags.append(tag_id)
+
def add_box_attribute(self, name, help, type, value = None, range = None,
allowed = None, flags = Attribute.NoFlags, validation_function = None,
category = None):
self._prestart_function = prestart_function
self._connector_types = dict()
self._traces = list()
+ self._tags = list()
self._box_attributes = AttributesMap()
@property
def traces(self):
return self._traces
+ @property
+ def tags(self):
+ return self._tags
+
def connector_type(self, name):
return self._connector_types[name]
def add_trace(self, trace_id):
self._traces.append(trace_id)
+ def add_tag(self, tag_id):
+ self._tags.append(tag_id)
+
def add_box_attribute(self, name, help, type, value = None, range = None,
allowed = None, flags = Attribute.NoFlags, validation_function = None,
category = None):
def get_attribute_list(self, guid):
raise NotImplementedError
+ def get_tags(self, guid):
+ raise NotImplementedError
+
def action(self, time, guid, action):
raise NotImplementedError
testbed = self._testbeds[testbed_guid]
return testbed.get(guid, name, time)
+ def get_tags(self, testbed_guid, guid):
+ testbed = self._testbeds[testbed_guid]
+ return testbed.get_tags(guid)
+
def shutdown(self):
for testbed in self._testbeds.values():
testbed.shutdown()
"factory_attributes": list of references to attribute_ids,
"box_attributes": list of regerences to attribute_ids,
"traces": list of references to trace_id
+ "tags": list of references to tag_id
"connector_types": list of references to connector_types
})
"""
self._add_attributes(factory, info, "box_attributes", True)
self._add_design_traces(factory, info)
+ self._add_tags(factory, info)
self._add_design_connector_types(factory, info)
factories.append(factory)
return factories
self._add_attributes(factory, info, "box_attributes", True)
self._add_execute_traces(factory, info)
+ self._add_tags(factory, info)
self._add_execute_connector_types(factory, info)
factories.append(factory)
return factories
trace_id = trace_info["name"]
factory.add_trace(trace_id)
+ def _add_tags(self, factory, info):
+ if "tags" in info:
+ for tag_id in info["tags"]:
+ factory.add_tag(tag_id)
+
def _add_design_connector_types(self, factory, info):
from nepi.core.design import ConnectorType
if "connector_types" in info:
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()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
+from nepi.util import tags
from nepi.util.constants import AF_INET, STATUS_NOT_STARTED, STATUS_RUNNING, \
STATUS_FINISHED, STATUS_UNDETERMINED
from nepi.util.tunchannel_impl import \
"Rho",
"X",
"Y"],
+ "tags": [tags.MOBILE],
}),
"ns3::Node": dict({
"category": "Topology",
"DeltaX",
"DeltaY",
"LayoutType"],
+ "tags": [tags.MOBILE],
}),
"ns3::TapBridge": dict({
"category": "Device",
"connector_types": ["node"],
"box_attributes": ["Position",
"Velocity"],
+ "tags": [tags.MOBILE],
}),
"ns3::V4Ping": dict({
"category": "Application",
"connector_types": ["node"],
"box_attributes": ["Position",
"Velocity"],
+ "tags": [tags.MOBILE],
}),
"ns3::GaussMarkovMobilityModel": dict({
"category": "Mobility",
"NormalPitch",
"Position",
"Velocity"],
+ "tags": [tags.MOBILE],
}),
"ns3::dot11s::HwmpProtocol": dict({
"category": "Protocol",
"box_attributes": ["WaypointsLeft",
"Position",
"Velocity"],
+ "tags": [tags.MOBILE],
}),
"ns3::FileDescriptorNetDevice": dict({
"category": "Device",
"box_attributes": ["rho",
"X",
"Y"],
+ "tags": [tags.MOBILE],
}),
"ns3::RandomBoxPositionAllocator": dict({
"category": "Mobility",
"box_attributes": ["X",
"Y",
"Z"],
+ "tags": [tags.MOBILE],
}),
"ns3::Ipv6ExtensionDestination": dict({
"category": "",
"connector_types": [],
"box_attributes": ["X",
"Y"],
+ "tags": [tags.MOBILE],
}),
"ns3::NqapWifiMac": dict({
"category": "Mac",
"connector_types": ["node"],
"box_attributes": ["Position",
"Velocity"],
+ "tags": [tags.MOBILE],
}),
"ns3::ThreeLogDistancePropagationLossModel": dict({
"category": "Loss",
"MaxY",
"Position",
"Velocity"],
+ "tags": [tags.MOBILE],
}),
"ns3::BaseStationNetDevice": dict({
"category": "Device",
"Pause",
"Position",
"Velocity"],
+ "tags": [tags.MOBILE],
}),
"ns3::RangePropagationLossModel": dict({
"category": "Loss",
"connector_types": ["node"],
"box_attributes": ["Position",
"Velocity"],
+ "tags": [tags.MOBILE],
}),
"ns3::FixedRssLossModel": dict({
"category": "Loss",
"Speed",
"Position",
"Velocity"],
+ "tags": [tags.MOBILE],
}),
"ns3::ListPositionAllocator": dict({
"category": "",
"Pause",
"Position",
"Velocity"],
+ "tags": [tags.MOBILE],
}),
"ns3::UanMacAloha": dict({
"category": "",
EXPERIMENT_SET = 37
EXPERIMENT_GET = 38
DO_PRESTART = 39
+GET_TAGS = 40
instruction_text = dict({
OK: "OK",
TESTBED_VERSION: "TESTBED_VERSION",
EXPERIMENT_SET: "EXPERIMENT_SET",
EXPERIMENT_GET: "EXPERIMENT_GET",
+ GET_TAGS: "GET_TAGS",
})
def log_msg(server, params):
def get_attribute_list(self, guid):
return self._testbed.get_attribute_list(guid)
+ @Marshalling.handles(GET_TAGS)
+ @Marshalling.args(int)
+ @Marshalling.retval( Marshalling.pickled_data )
+ def get_tags(self, guid):
+ return self._testbed.get_tags(guid)
+
class ExperimentControllerServer(BaseServer):
def __init__(self, root_dir, log_level, experiment_xml):
super(ExperimentControllerServer, self).__init__(root_dir, log_level)
def set(self, testbed_guid, guid, name, value, time):
self._controller.set(testbed_guid, guid, name, value, time)
+ @Marshalling.handles(GET_TAGS)
+ @Marshalling.args(int, int)
+ @Marshalling.retval( Marshalling.pickled_data )
+ def get_tags(self, testbed_guid, guid):
+ return self._controller.get_tags(testbed_guid, guid)
+
@Marshalling.handles(START)
@Marshalling.args()
@Marshalling.retvoid
# -*- coding: utf-8 -*-
from nepi.core.design import ExperimentDescription, FactoriesProvider
+from nepi.util import tags
import mock.metadata_v01
import sys
import unittest
app.connector("node").connect(node1.connector("apps"))
app.enable_trace("fake")
+ self.assertEquals(node1.tags, [tags.MOBILE])
+
xml = exp_desc.to_xml()
exp_desc2 = ExperimentDescription()
exp_desc2.from_xml(xml)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
+from nepi.util import tags
from nepi.util.constants import STATUS_FINISHED
import mock
import mock.metadata_v01
"""
self.assertTrue(app_result.startswith(comp_result))
+ self.assertEquals(instance.get_tags(4), [tags.MOBILE])
+
instance.stop()
instance.shutdown()
# -*- coding: utf-8 -*-
from nepi.core.design import ExperimentDescription, FactoriesProvider
+from nepi.util import proxy, tags
from nepi.util.constants import STATUS_FINISHED, DeploymentConfiguration as DC
-from nepi.util import proxy
import mock
import mock.metadata_v01
import mock2
1 packets transmitted, 1 received, 0% packet loss, time 0ms
"""
self.assertTrue(fake_result.startswith(comp_result))
+ self.assertEquals(controller.get_tags(desc.guid, node1.guid), [tags.MOBILE])
+
controller.stop()
controller.shutdown()
1 packets transmitted, 1 received, 0% packet loss, time 0ms
"""
self.assertTrue(fake_result.startswith(comp_result))
+ self.assertEquals(controller.get_tags(desc.guid, node1.guid), [tags.MOBILE])
+
controller.stop()
controller.shutdown()
1 packets transmitted, 1 received, 0% packet loss, time 0ms
"""
self.assertTrue(fake_result.startswith(comp_result))
+ self.assertEquals(controller.get_tags(desc.guid, node1.guid), [tags.MOBILE])
+
controller.stop()
controller.shutdown()
1 packets transmitted, 1 received, 0% packet loss, time 0ms
"""
self.assertTrue(fake_result.startswith(comp_result))
+ self.assertEquals(controller.get_tags(desc.guid, node1.guid), [tags.MOBILE])
+
controller.stop()
controller.shutdown()
1 packets transmitted, 1 received, 0% packet loss, time 0ms
"""
self.assertTrue(fake_result.startswith(comp_result))
-
+ self.assertEquals(controller.get_tags(desc.guid, node1.guid), [tags.MOBILE])
+
# controller dies
del controller
from constants import TESTBED_ID
from nepi.core import metadata
from nepi.core.attributes import Attribute
-from nepi.util import validation
+from nepi.util import validation, tags
from nepi.util.constants import STATUS_FINISHED
NODE = "Node"
"stop_function": None,
"status_function": None,
"box_attributes": ["fake","test"],
- "connector_types": ["devs", "apps"]
+ "connector_types": ["devs", "apps"],
+ "tags": [tags.MOBILE]
}),
IFACE: dict({
"help": "Fake iface",