enforce tags system
authorAlina Quereilhac <alina.quereilhac@inria.fr>
Wed, 6 Jul 2011 10:36:00 +0000 (12:36 +0200)
committerAlina Quereilhac <alina.quereilhac@inria.fr>
Wed, 6 Jul 2011 10:36:00 +0000 (12:36 +0200)
src/nepi/core/attributes.py
src/nepi/core/design.py
src/nepi/core/factory.py
src/nepi/core/metadata.py
src/nepi/testbeds/netns/metadata_v01.py
src/nepi/testbeds/ns3/factories_metadata_v3_9.py
src/nepi/testbeds/planetlab/metadata_v01.py
src/nepi/util/tags.py
test/core/design.py
test/lib/mock/metadata_v01.py
test/lib/mock2/metadata_v01.py

index 151cab0..201ca04 100644 (file)
@@ -143,6 +143,7 @@ class AttributesMap(object):
     are going to be manipulated by the end-user in a script or GUI.
     """
     def __init__(self):
+        super(AttributesMap, self).__init__()
         self._attributes = dict()
 
     @property
index 46e54bd..602667c 100644 (file)
@@ -11,6 +11,7 @@ from nepi.util import validation
 from nepi.util.guid import GuidGenerator
 from nepi.util.graphical_info import GraphicalInfo
 from nepi.util.parser._xml import XmlExperimentParser
+from nepi.util.tags import Taggable
 import sys
 
 class Connector(object):
@@ -153,7 +154,7 @@ class Route(AttributesMap):
                 flags = Attribute.HasNoDefaultValue,
                 validation_function = validation.is_integer)
 
-class Box(AttributesMap):
+class Box(AttributesMap, Taggable):
     def __init__(self, guid, factory, testbed_guid, container = None):
         super(Box, self).__init__()
         # guid -- global unique identifier
@@ -166,8 +167,6 @@ class Box(AttributesMap):
         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
@@ -182,7 +181,7 @@ class Box(AttributesMap):
             trace = Trace(name, help, enabled)
             self._traces[name] = trace
         for tag_id in factory.tags:
-            self._tags.append(tag_id)
+            self.add_tag(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, 
@@ -226,10 +225,6 @@ class Box(AttributesMap):
     def factory_attributes(self):
         return self._factory_attributes
 
-    @property
-    def tags(self):
-        return self._tags
-
     def trace_help(self, trace_id):
         return self._traces[trace_id].help
 
index ae7f041..efe05e2 100644 (file)
@@ -2,6 +2,8 @@
 # -*- coding: utf-8 -*-
 
 from nepi.core.attributes import AttributesMap, Attribute
+from nepi.util import tags
+from nepi.util.tags import Taggable
 
 class AddressableMixin(object):
     def __init__(self, guid, factory, testbed_guid, container = None):
@@ -96,7 +98,7 @@ def MixIn(MyClass, MixIn):
         MixIn.__name__.replace('MixIn','')+'Box',
         1)
 
-class Factory(AttributesMap):
+class Factory(AttributesMap, Taggable):
     _box_class_cache = {}
 
     def __init__(self, factory_id,
@@ -108,19 +110,11 @@ class Factory(AttributesMap):
             preconfigure_function,
             prestart_function,
             help = None,
-            category = None,
-            allow_addresses = False, 
-            has_addresses = False,
-            allow_routes = False, 
-            has_routes = False):
+            category = None):
 
         super(Factory, self).__init__()
 
         self._factory_id = factory_id
-        self._allow_addresses = bool(allow_addresses)
-        self._allow_routes = bool(allow_routes)
-        self._has_addresses = bool(has_addresses) or self._allow_addresses
-        self._has_routes = bool(has_routes) or self._allow_routes
         self._create_function = create_function
         self._start_function = start_function
         self._stop_function = stop_function
@@ -132,15 +126,21 @@ class Factory(AttributesMap):
         self._category = category
         self._connector_types = dict()
         self._traces = dict()
-        self._tags = list()
         self._box_attributes = AttributesMap()
+        self._factory = None
+
+    @property
+    def factory(self):
+        if self._factory:
+            return self._factory
 
         from nepi.core.design import Box
-        if not self._has_addresses and not self._has_routes:
+
+        if not self.has_addresses and not self.has_routes:
             self._factory = Box
         else:
-            addresses = 'w' if self._allow_addresses else ('r' if self._has_addresses else '-')
-            routes    = 'w' if self._allow_routes else ('r' if self._has_routes else '-')
+            addresses = 'w' if self.allow_addresses else ('r' if self.has_addresses else '-')
+            routes    = 'w' if self.allow_routes else ('r' if self.has_routes else '-')
             key = addresses+routes
             
             if key in self._box_class_cache:
@@ -152,18 +152,19 @@ class Factory(AttributesMap):
                         super(_factory, self).__init__(guid, factory, testbed_guid, container)
                 
                 # Add mixins, one by one
-                if allow_addresses:
+                if self.allow_addresses:
                     MixIn(_factory, UserAddressableMixin)
-                elif has_addresses:
+                elif self.has_addresses:
                     MixIn(_factory, AddressableMixin)
                     
-                if allow_routes:
+                if self.allow_routes:
                     MixIn(_factory, UserRoutableMixin)
-                elif has_routes:
+                elif self.has_routes:
                     MixIn(_factory, RoutableMixin)
                 
                 # Put into cache
                 self._box_class_cache[key] = self._factory = _factory
+        return self._factory
 
     @property
     def factory_id(self):
@@ -171,19 +172,21 @@ class Factory(AttributesMap):
 
     @property
     def allow_addresses(self):
-        return self._allow_addresses
+        return self.has_tag(tags.ALLOW_ADDRESSES)
 
     @property
     def allow_routes(self):
-        return self._allow_routes
+        return self.has_tag(tags.ALLOW_ROUTES)
 
     @property
     def has_addresses(self):
-        return self._has_addresses
+        return self.has_tag(tags.HAS_ADDRESSES) or \
+                self.allow_addresses
 
     @property
     def has_routes(self):
-        return self._has_routes
+        return self.has_tag(tags.HAS_ROUTES) or \
+                self.allow_routes
 
     @property
     def help(self):
@@ -205,10 +208,6 @@ class Factory(AttributesMap):
     def traces_list(self):
         return self._traces.keys()
 
-    @property
-    def tags(self):
-        return self._tags
-    
     @property
     def box_attributes(self):
         return self._box_attributes
@@ -250,9 +249,6 @@ class Factory(AttributesMap):
     def add_trace(self, name, help, enabled = False):
         self._traces[name] = (name, help, enabled)
 
-    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):
@@ -260,7 +256,7 @@ class Factory(AttributesMap):
                 allowed, flags, validation_function, category)
 
     def create(self, guid, testbed_description):
-        return self._factory(guid, self, testbed_description.guid)
+        return self.factory(guid, self, testbed_description.guid)
 
     def destroy(self):
         super(Factory, self).destroy()
index 90febc6..377efa2 100644 (file)
@@ -111,10 +111,6 @@ class VersionedMetadataInfo(object):
     def factories_info(self):
         """ dictionary of dictionaries of factory specific information
             factory_id: dict({
-                "allow_addresses": whether the box allows adding IP addresses,
-                "allow_routes": wether the box allows adding routes,
-                "has_addresses": whether the box allows obtaining IP addresses,
-                "has_routes": wether the box allows obtaining routes,
                 "help": help text,
                 "category": category the element belongs to,
                 "create_function": function for element instantiation,
@@ -389,10 +385,6 @@ class Metadata(object):
             configure_function = info.get("configure_function")
             preconfigure_function = info.get("preconfigure_function")
             prestart_function = info.get("prestart_function")
-            allow_addresses = info.get("allow_addresses", False)
-            allow_routes = info.get("allow_routes", False)
-            has_addresses = info.get("has_addresses", False)
-            has_routes = info.get("has_routes", False)
             help = info["help"]
             category = info["category"]
             factory = Factory(factory_id, 
@@ -404,11 +396,7 @@ class Metadata(object):
                     preconfigure_function,
                     prestart_function,
                     help,
-                    category,
-                    allow_addresses, 
-                    has_addresses,
-                    allow_routes, 
-                    has_routes)
+                    category)
                     
             factory_attributes = self._factory_attributes(factory_id, info)
             self._add_attributes(factory.add_attribute, factory_attributes)
index 801f91b..539175f 100644 (file)
@@ -4,7 +4,7 @@
 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 tags, validation
 from nepi.util.constants import ApplicationStatus as AS, \
         FactoryCategories as FC
 
@@ -460,44 +460,44 @@ configure_order = [ P2PIFACE, NODEIFACE, TAPIFACE,
 
 factories_info = dict({
     NODE: dict({
-            "allow_routes": True,
             "help": "Emulated Node with virtualized network stack",
             "category": FC.CATEGORY_NODES,
             "create_function": create_node,
             "configure_function": configure_node,
             "box_attributes": ["forward_X11"],
             "connector_types": ["devs", "apps"],
-            "traces": ["node_pcap"]
+            "traces": ["node_pcap"],
+            "tags": [tags.NODE, tags.ALLOW_ROUTES],
        }),
     P2PIFACE: dict({
-            "allow_addresses": True,
             "help": "Point to point network interface",
             "category": FC.CATEGORY_DEVICES,
             "create_function": create_p2piface,
             "configure_function": configure_device,
             "box_attributes": ["lladdr", "up", "device_name", "mtu", 
                 "multicast", "broadcast", "arp"],
-            "connector_types": ["node", "p2p"]
+            "connector_types": ["node", "p2p"],
+            "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
        }),
     TAPIFACE: dict({
-            "allow_addresses": True,
             "help": "Tap device network interface",
             "category": FC.CATEGORY_DEVICES,
             "create_function": create_tapiface,
             "configure_function": configure_device,
             "box_attributes": ["lladdr", "up", "device_name", "mtu", 
                 "multicast", "broadcast", "arp"],
-            "connector_types": ["node", "fd->"]
+            "connector_types": ["node", "fd->"],
+            "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
         }),
     NODEIFACE: dict({
-            "allow_addresses": True,
             "help": "Node network interface",
             "category": FC.CATEGORY_DEVICES,
             "create_function": create_nodeiface,
             "configure_function": configure_device,
             "box_attributes": ["lladdr", "up", "device_name", "mtu", 
                 "multicast", "broadcast", "arp"],
-            "connector_types": ["node", "switch"]
+            "connector_types": ["node", "switch"],
+            "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
         }),
     SWITCH: dict({
             "display_name": "Switch",
@@ -510,7 +510,8 @@ factories_info = dict({
              #TODO: Add attribute ("HelloTime", help, type, value, range, allowed, readonly, validation_function),
              #TODO: Add attribute ("AgeingTime", help, type, value, range, allowed, readonly, validation_function),
              #TODO: Add attribute ("MaxAge", help, type, value, range, allowed, readonly, validation_function)
-           "connector_types": ["devs"]
+            "connector_types": ["devs"],
+            "tags": [tags.SWITCH],
         }),
     APPLICATION: dict({
             "help": "Generic executable command line application",
@@ -521,19 +522,21 @@ factories_info = dict({
             "status_function": status_application,
             "box_attributes": ["command", "user"],
             "connector_types": ["node"],
-            "traces": ["stdout", "stderr"]
+            "traces": ["stdout", "stderr"],
+            "tags": [tags.APPLICATION],
         }),
      TUNCHANNEL : dict({
-        "category": FC.CATEGORY_TUNNELS,
-        "create_function": create_tunchannel,
-        "preconfigure_function": preconfigure_tunchannel,
-        "configure_function": postconfigure_tunchannel,
-        "prestart_function": wait_tunchannel,
-        "help": "Channel to forward "+TAPIFACE+" data to "
+            "category": FC.CATEGORY_TUNNELS,
+            "create_function": create_tunchannel,
+            "preconfigure_function": preconfigure_tunchannel,
+            "configure_function": postconfigure_tunchannel,
+            "prestart_function": wait_tunchannel,
+            "help": "Channel to forward "+TAPIFACE+" data to "
                 "other TAP interfaces supporting the NEPI tunneling protocol.",
-        "connector_types": ["->fd", "udp", "tcp"],
-        "allow_addresses": False,
-        "box_attributes": ["tun_proto", "tun_addr", "tun_port", "tun_key"]
+            "connector_types": ["->fd", "udp", "tcp"],
+            "allow_addresses": False,
+            "box_attributes": ["tun_proto", "tun_addr", "tun_port", "tun_key"],
+            "tags": [tags.TUNNEL],
     }),
 })
 
index 6333437..2ba1336 100644 (file)
@@ -686,11 +686,11 @@ factories_info = dict({
         "category": FC.CATEGORY_APPLICATIONS,
         "create_function": create_element,
         "configure_function": configure_element,
-        "help": "",
-        "connector_types": [],
         "stop_function": stop_application,
         "start_function": start_application,
         "status_function": status_application,
+        "help": "",
+        "connector_types": [],
         "box_attributes": ["MaxPackets",
             "Interval",
             "RemoteIpv6",
@@ -698,6 +698,7 @@ factories_info = dict({
             "PacketSize",
             "StartTime",
             "StopTime"],
+        "tags": [tags.APPLICATION],
     }),
      "ns3::UdpL4Protocol": dict({
         "category": FC.CATEGORY_PROTOCOLS,
@@ -706,6 +707,7 @@ factories_info = dict({
         "help": "",
         "connector_types": ["node"],
         "box_attributes": ["ProtocolNumber"],
+        "tags": [tags.PROTOCOL],
     }),
      "ns3::RandomDiscPositionAllocator": dict({
         "category": FC.CATEGORY_MOBILITY_MODELS,
@@ -725,8 +727,7 @@ factories_info = dict({
         "configure_function": configure_node,
         "help": "",
         "connector_types": ["devs", "apps", "protos", "mobility"],
-        "allow_routes": True,
-        "box_attributes": [],
+        "tags": [tags.NODE, tags.ALLOW_ROUTES],
     }),
      "ns3::GridPositionAllocator": dict({
         "category": FC.CATEGORY_MOBILITY_MODELS,
@@ -740,7 +741,6 @@ factories_info = dict({
             "DeltaX",
             "DeltaY",
             "LayoutType"],
-        "tags": [tags.MOBILE],
     }),
      "ns3::TapBridge": dict({
         "category": FC.CATEGORY_DEVICES,
@@ -748,7 +748,6 @@ factories_info = dict({
         "configure_function": configure_element,
         "help": "",
         "connector_types": [],
-        "allow_addresses": True,
         "box_attributes": ["Mtu",
             "DeviceName",
             "Gateway",
@@ -757,9 +756,10 @@ factories_info = dict({
             "Netmask",
             "Start",
             "Stop"],
+        "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
     }),
      "ns3::FlowMonitor": dict({
-        "category": "",
+        "category": FC.CATEGORY_SERVICE_FLOWS,
         "create_function": create_element,
         "configure_function": configure_element,
         "help": "",
@@ -797,6 +797,7 @@ factories_info = dict({
             "StartTime",
             "StopTime"],
         "traces": ["rtt"],
+        "tags": [tags.APPLICATION],
     }),
      "ns3::dot11s::PeerLink": dict({
         "category": "",
@@ -817,12 +818,12 @@ factories_info = dict({
         "configure_function": configure_device,
         "help": "",
         "connector_types": ["node", "err", "queue", "chan"],
-        "allow_addresses": True,
         "box_attributes": ["Mtu",
             "Address",
             "DataRate",
             "InterframeGap"],
-        "traces": ["p2ppcap", "p2pascii"]
+        "traces": ["p2ppcap", "p2pascii"],
+        "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
     }),
      "ns3::NakagamiPropagationLossModel": dict({
         "category": FC.CATEGORY_LOSS_MODELS,
@@ -891,6 +892,7 @@ factories_info = dict({
             "Protocol",
             "StartTime",
             "StopTime"],
+        "tags": [tags.APPLICATION],
     }),
      "ns3::AdhocWifiMac": dict({
         "category": FC.CATEGORY_MAC_MODELS,
@@ -1037,11 +1039,11 @@ factories_info = dict({
         "configure_function": configure_device,
         "help": "Network interface associated to a file descriptor",
         "connector_types": ["node", "->fd"],
-        "allow_addresses": True,
         "box_attributes": ["Address", 
             "LinuxSocketAddress",
             "tun_proto", "tun_addr", "tun_port", "tun_key"],
-        "traces": ["fdpcap"]
+        "traces": ["fdpcap"],
+        "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
     }),
      "ns3::Nepi::TunChannel": dict({
         "category": FC.CATEGORY_TUNNELS,
@@ -1053,7 +1055,9 @@ factories_info = dict({
                 "other TAP interfaces supporting the NEPI tunneling protocol.",
         "connector_types": ["fd->", "udp", "tcp"],
         "allow_addresses": False,
-        "box_attributes": ["tun_proto", "tun_addr", "tun_port", "tun_key"]
+        "box_attributes": ["tun_proto", "tun_addr", "tun_port", "tun_key"],
+        "tags": [tags.TUNNEL],
     }),
      "ns3::CsmaNetDevice": dict({
         "category": FC.CATEGORY_DEVICES,
@@ -1061,12 +1065,12 @@ factories_info = dict({
         "configure_function": configure_device,
         "help": "CSMA (carrier sense, multiple access) interface",
         "connector_types": ["node", "chan", "err", "queue"],
-        "allow_addresses": True,
         "box_attributes": ["Address",
             "Mtu",
             "SendEnable",
             "ReceiveEnable"],
-        "traces": ["csmapcap", "csmapcap_promisc"]
+        "traces": ["csmapcap", "csmapcap_promisc"],
+        "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
     }),
      "ns3::UanPropModelThorp": dict({
         "category": "",
@@ -1111,8 +1115,8 @@ factories_info = dict({
         "configure_function": configure_element,
         "help": "",
         "connector_types": ["node", "chan"],
-        "allow_addresses": True,
         "box_attributes": [],
+        "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
     }),
      "ns3::FriisPropagationLossModel": dict({
         "category": FC.CATEGORY_LOSS_MODELS,
@@ -1169,6 +1173,7 @@ factories_info = dict({
         "help": "",
         "connector_types": [],
         "box_attributes": [],
+        "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
     }),
      "ns3::ConstantSpeedPropagationDelayModel": dict({
         "category": FC.CATEGORY_DELAY_MODELS,
@@ -1444,7 +1449,6 @@ factories_info = dict({
         "configure_function": configure_station,
         "help": "Base station for wireless mobile network",
         "connector_types": ["node", "chan", "phy", "uplnk", "dwnlnk"],
-        "allow_addresses": True,
         "box_attributes": ["InitialRangInterval",
             "DcdInterval",
             "UcdInterval",
@@ -1456,6 +1460,7 @@ factories_info = dict({
             "RTG",
             "TTG"],
         "traces": ["wimaxpcap", "wimaxascii"],
+        "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
     }),
      "ns3::UdpServer": dict({
         "category": FC.CATEGORY_APPLICATIONS,
@@ -1523,6 +1528,7 @@ factories_info = dict({
             "Start",
             "Stop",
             "RxQueueSize"],
+        "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
     }),
      "ns3::Ipv6ExtensionLooseRouting": dict({
         "category": FC.CATEGORY_ROUTING,
@@ -1560,6 +1566,7 @@ factories_info = dict({
         "connector_types": [],
         "box_attributes": ["Address",
             "Mtu"],
+        "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
     }),
      "ns3::MatrixPropagationLossModel": dict({
         "category": FC.CATEGORY_LOSS_MODELS,
@@ -1575,8 +1582,8 @@ factories_info = dict({
         "configure_function": configure_device,
         "help": "",
         "connector_types": ["node", "mac", "phy", "manager"],
-        "allow_addresses": True,
         "box_attributes": ["Mtu"],
+        "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
     }),
      "ns3::CsmaChannel": dict({
         "category": FC.CATEGORY_CHANNELS,
@@ -1593,10 +1600,10 @@ factories_info = dict({
         "configure_function": configure_element,
         "help": "",
         "connector_types": ["node"],
-        "allow_addresses": True,
         "box_attributes": ["Mtu",
            "EnableLearning",
            "ExpirationTime"],
+        "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
     }),
      "ns3::Ipv6ExtensionRouting": dict({
         "category": FC.CATEGORY_ROUTING,
@@ -1643,6 +1650,7 @@ factories_info = dict({
             "PacketSize",
             "StartTime",
             "StopTime"],
+        "tags": [tags.APPLICATION],
     }),
      "ns3::UdpClient": dict({
         "category": FC.CATEGORY_APPLICATIONS,
@@ -1660,6 +1668,7 @@ factories_info = dict({
             "PacketSize",
             "StartTime",
             "StopTime"],
+        "tags": [tags.APPLICATION],
     }),
      "ns3::PointToPointChannel": dict({
         "category": FC.CATEGORY_CHANNELS,
@@ -1752,8 +1761,8 @@ factories_info = dict({
         "configure_function": configure_element,
         "help": "",
         "connector_types": [],
-        "allow_addresses": True,
         "box_attributes": ["Mtu"],
+        "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
     }),
      "ns3::BasicEnergySource": dict({
         "category": FC.CATEGORY_ENERGY_MODELS,
@@ -1816,8 +1825,8 @@ factories_info = dict({
         "configure_function": configure_element,
         "help": "",
         "connector_types": [],
-        "allow_addresses": True,
         "box_attributes": [],
+        "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
     }),
      "ns3::RateErrorModel": dict({
         "category": FC.CATEGORY_ERROR_MODELS,
@@ -2114,8 +2123,8 @@ factories_info = dict({
         "configure_function": configure_element,
         "help": "",
         "connector_types": [],
-        "allow_addresses": True,
         "box_attributes": ["Mtu"],
+        "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
     }),
      "ns3::UanPhyGen": dict({
         "category": FC.CATEGORY_PHY_MODELS,
@@ -2211,6 +2220,7 @@ factories_info = dict({
             "Protocol",
             "StartTime",
             "StopTime"],
+        "tags": [tags.APPLICATION],
     }),
      "ns3::RandomDirection2dMobilityModel": dict({
         "category": FC.CATEGORY_MOBILITY_MODELS,
@@ -2364,6 +2374,7 @@ factories_info = dict({
         "box_attributes": ["Port",
            "StartTime",
            "StopTime"],
+        "tags": [tags.APPLICATION],
     }),
      "ns3::AmrrWifiManager": dict({
         "category": FC.CATEGORY_MANAGERS,
@@ -2404,7 +2415,6 @@ factories_info = dict({
         "configure_function": configure_station,
         "help": "Subscriber station for mobile wireless network",
         "connector_types": ["node", "chan", "phy", "sflows"],
-        "allow_addresses": True,
         "box_attributes": ["LostDlMapInterval",
             "LostUlMapInterval",
             "MaxDcdInterval",
@@ -2421,6 +2431,7 @@ factories_info = dict({
             "RTG",
             "TTG"],
         "traces": ["wimaxpcap", "wimaxascii"],
+        "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
     }),
     "ns3::flame::FlameRtable": dict({
         "category": "",
index 6fcc07d..9f2fd3c 100644 (file)
@@ -6,7 +6,7 @@ import time
 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 tags, validation
 from nepi.util.constants import ApplicationStatus as AS, \
         FactoryCategories as FC, \
         ATTR_NEPI_TESTBED_ENVIRONMENT_SETUP
@@ -945,7 +945,6 @@ start_order = [ INTERNET, NODEIFACE, TAPIFACE, TUNIFACE, NODE, NETPIPE, NEPIDEPE
 
 factories_info = dict({
     NODE: dict({
-            "allow_routes": True,
             "help": "Virtualized Node (V-Server style)",
             "category": FC.CATEGORY_NODES,
             "create_function": create_node,
@@ -966,19 +965,19 @@ factories_info = dict({
                 # NEPI-in-NEPI attributes
                 ATTR_NEPI_TESTBED_ENVIRONMENT_SETUP,
             ],
-            "connector_types": ["devs", "apps", "pipes", "deps"]
+            "connector_types": ["devs", "apps", "pipes", "deps"],
+            "tags": [tags.NODE, tags.ALLOW_ROUTES],
        }),
     NODEIFACE: dict({
-            "has_addresses": True,
             "help": "External network interface - they cannot be brought up or down, and they MUST be connected to the internet.",
             "category": FC.CATEGORY_DEVICES,
             "create_function": create_nodeiface,
             "preconfigure_function": configure_nodeiface,
             "box_attributes": [ ],
-            "connector_types": ["node", "inet"]
+            "connector_types": ["node", "inet"],
+            "tags": [tags.INTERFACE, tags.HAS_ADDRESSES],
         }),
     TUNIFACE: dict({
-            "allow_addresses": True,
             "help": "Virtual TUN network interface (layer 3)",
             "category": FC.CATEGORY_DEVICES,
             "create_function": create_tuniface,
@@ -991,10 +990,10 @@ factories_info = dict({
                 "tun_proto", "tun_addr", "tun_port", "tun_key"
             ],
             "traces": ["packets"],
-            "connector_types": ["node","udp","tcp","fd->"]
+            "connector_types": ["node","udp","tcp","fd->"],
+            "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
         }),
     TAPIFACE: dict({
-            "allow_addresses": True,
             "help": "Virtual TAP network interface (layer 2)",
             "category": FC.CATEGORY_DEVICES,
             "create_function": create_tapiface,
@@ -1007,7 +1006,8 @@ factories_info = dict({
                 "tun_proto", "tun_addr", "tun_port", "tun_key"
             ],
             "traces": ["packets"],
-            "connector_types": ["node","udp","tcp","fd->"]
+            "connector_types": ["node","udp","tcp","fd->"],
+            "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
         }),
     APPLICATION: dict({
             "help": "Generic executable command line application",
@@ -1021,7 +1021,8 @@ factories_info = dict({
                                "depends", "build-depends", "build", "install",
                                "sources", "rpm-fusion" ],
             "connector_types": ["node"],
-            "traces": ["stdout", "stderr", "buildlog"]
+            "traces": ["stdout", "stderr", "buildlog"],
+            "tags": [tags.APPLICATION],
         }),
     DEPENDENCY: dict({
             "help": "Requirement for package or application to be installed on some node",
@@ -1031,16 +1032,16 @@ factories_info = dict({
             "box_attributes": ["depends", "build-depends", "build", "install",
                                "sources", "rpm-fusion" ],
             "connector_types": ["node"],
-            "traces": ["buildlog"]
+            "traces": ["buildlog"],
         }),
     NEPIDEPENDENCY: dict({
             "help": "Requirement for NEPI inside NEPI - required to run testbed instances inside a node",
             "category": FC.CATEGORY_APPLICATIONS,
             "create_function": create_nepi_dependency,
             "preconfigure_function": configure_dependency,
-            "box_attributes": [ ],
+            "box_attributes": [],
             "connector_types": ["node"],
-            "traces": ["buildlog"]
+            "traces": ["buildlog"],
         }),
     NS3DEPENDENCY: dict({
             "help": "Requirement for NS3 inside NEPI - required to run NS3 testbed instances inside a node. It also needs NepiDependency.",
@@ -1049,13 +1050,14 @@ factories_info = dict({
             "preconfigure_function": configure_dependency,
             "box_attributes": [ ],
             "connector_types": ["node"],
-            "traces": ["buildlog"]
+            "traces": ["buildlog"],
         }),
     INTERNET: dict({
             "help": "Internet routing",
             "category": FC.CATEGORY_CHANNELS,
             "create_function": create_internet,
             "connector_types": ["devs"],
+            "tags": [tags.INTERNET],
         }),
     NETPIPE: dict({
             "help": "Link emulation",
@@ -1067,7 +1069,7 @@ factories_info = dict({
                                "bw_in","plr_in","delay_in",
                                "bw_out","plr_out","delay_out"],
             "connector_types": ["node"],
-            "traces": ["netpipe_stats"]
+            "traces": ["netpipe_stats"],
         }),
 })
 
index 85d39fb..e3fbdf2 100644 (file)
@@ -1,5 +1,36 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
-MOBILE = 0
+MOBILE = "mobile"
+NODE = "node"
+INTERFACE = "interface"
+WIRELESS = "wireless"
+APPLICATION = "application"
+NAT = "nat"
+ROUTER = "router" 
+SWITCH = "switch"
+PPP = "point-to-point"
+PROTOCOL = "protocol"
+TUNNEL = "tunnel"
+INTERNET = "internet"
+HUB = "hub"
+ALLOW_ADDRESSES = "allow_addresses"
+ALLOW_ROUTES = "allow_routes"
+HAS_ADDRESSES = "has_addresses"
+HAS_ROUTES = "has_routes"
+
+class Taggable(object):
+    def __init__(self):
+        super(Taggable, self).__init__()
+        self._tags = list()
+
+    @property
+    def tags(self):
+        return self._tags
+
+    def add_tag(self, tag_id):
+        self._tags.append(tag_id)
+
+    def has_tag(self, tag_id):
+        return tag_id in self._tags
 
index e9a67c1..8456510 100755 (executable)
@@ -35,7 +35,7 @@ class DesignTestCase(unittest.TestCase):
         app.connector("node").connect(node1.connector("apps"))
         app.enable_trace("fake")
 
-        self.assertEquals(node1.tags, [tags.MOBILE])
+        self.assertEquals(node1.tags, [tags.MOBILE, tags.NODE, tags.ALLOW_ROUTES])
 
         xml = exp_desc.to_xml()
         exp_desc2 = ExperimentDescription()
index 88d5410..8c2bf55 100644 (file)
@@ -143,7 +143,7 @@ factories_info = dict({
             "status_function": None,
             "box_attributes": ["fake","test"],
             "connector_types": ["devs", "apps"],
-            "tags": [tags.MOBILE]
+            "tags": [tags.MOBILE, tags.NODE, tags.ALLOW_ROUTES],
        }),
     IFACE: dict({
             "help": "Fake iface",
@@ -155,7 +155,8 @@ factories_info = dict({
             "allow_addresses": True,
             "factory_attributes": ["fake", "MaxAddresses"],
             "box_attributes": ["fake", "test", "cross"],
-            "connector_types": ["node", "iface", "cross"]
+            "connector_types": ["node", "iface", "cross"],
+            "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
        }),
     APP: dict({
             "help": "Fake application",
@@ -166,7 +167,8 @@ factories_info = dict({
             "status_function": status_application,
             "box_attributes": ["fake", "test"],
             "connector_types": ["node"],
-            "traces": ["fake"]
+            "traces": ["fake"],
+            "tags": [tags.APPLICATION],
         }),
 })
 
index 44fc8fb..f3d534d 100644 (file)
@@ -4,7 +4,7 @@
 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 tags, validation
 from nepi.util.constants import ApplicationStatus as AS
 
 NODE = "Node"
@@ -134,7 +134,8 @@ factories_info = dict({
             "stop_function": None,
             "status_function": None,
             "box_attributes": ["fake","test"],
-            "connector_types": ["devs", "apps"]
+            "connector_types": ["devs", "apps"],
+            "tags": [tags.NODE, tags.ALLOW_ROUTES],
        }),
     IFACE: dict({
             "help": "Fake iface",
@@ -146,7 +147,8 @@ factories_info = dict({
             "allow_addresses": True,
             "factory_attributes": ["fake"],
             "box_attributes": ["fake", "test", "cross"],
-            "connector_types": ["node", "iface", "cross"]
+            "connector_types": ["node", "iface", "cross"],
+            "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
        }),
     APP: dict({
             "help": "Fake application",
@@ -157,7 +159,8 @@ factories_info = dict({
             "status_function": status_application,
             "box_attributes": ["fake", "test"],
             "connector_types": ["node"],
-            "traces": ["fake"]
+            "traces": ["fake"],
+            "tags": [tags.APPLICATION],
         }),
 })