define tags exposed to the API in the Accessors area
[plcapi.git] / PLC / Nodes.py
index a61e366..723aeae 100644 (file)
@@ -72,22 +72,17 @@ class Node(Row):
     related_fields = {
        'interfaces': [Mixed(Parameter(int, "Interface identifier"),
                              Filter(Interface.fields))],
-       'nodegroups': [Mixed(Parameter(int, "NodeGroup identifier"),
-                             Parameter(str, "NodeGroup name"))],
        'conf_files': [Parameter(int, "ConfFile identifier")],
        'slices': [Mixed(Parameter(int, "Slice identifier"),
                          Parameter(str, "Slice name"))],
        'slices_whitelist': [Mixed(Parameter(int, "Slice identifier"),
                                    Parameter(str, "Slice name"))]
        }
-    view_name = "view_nodes"
+
     view_tags_name = "view_node_tags"
-    tags = {
-        # regular
-        'arch': Parameter(str, "node/config", ro=True),
-        'deployment': Parameter(str, "node/operation"),
-        # dummynet
-        }
+    # tags are used by the Add/Get/Update methods to expose tags
+    # this is initialized here and updated by the accessors factory
+    tags = { }
 
     def validate_hostname(self, hostname):
         if not valid_hostname(hostname):
@@ -292,7 +287,8 @@ class Nodes(Table):
                 node_filter = Filter(Node.fields, {'node_id': ints, 'hostname': strs})
                 sql += " AND (%s) %s" % node_filter.sql(api, "OR")
             elif isinstance(node_filter, dict):
-                node_filter = Filter(Node.fields, node_filter)
+                allowed_fields=dict(Node.fields.items()+Node.tags.items())
+                node_filter = Filter(allowed_fields, node_filter)
                 sql += " AND (%s) %s" % node_filter.sql(api, "AND")
             elif isinstance (node_filter, StringTypes):
                 node_filter = Filter(Node.fields, {'hostname':[node_filter]})