svn keywords
[plcapi.git] / PLC / Nodes.py
index 723aeae..46fb99a 100644 (file)
@@ -5,6 +5,7 @@
 # Copyright (C) 2006 The Trustees of Princeton University
 #
 # $Id$
+# $URL$
 #
 
 from types import StringTypes
@@ -48,6 +49,7 @@ class Node(Row):
         'hostname': Parameter(str, "Fully qualified hostname", max = 255),
         'site_id': Parameter(int, "Site at which this node is located"),
         'boot_state': Parameter(str, "Boot state", max = 20),
+        'run_level': Parameter(str, "Run level", max = 20),
         'model': Parameter(str, "Make and model of the actual machine", max = 255, nullok = True),
         'boot_nonce': Parameter(str, "(Admin only) Random value generated by the node at last boot", max = 128),
         'version': Parameter(str, "Apparent Boot CD version", max = 64),
@@ -55,6 +57,7 @@ class Node(Row):
         'date_created': Parameter(int, "Date and time when node entry was created", ro = True),
         'last_updated': Parameter(int, "Date and time when node entry was created", ro = True),
        'last_contact': Parameter(int, "Date and time when node last contacted plc", ro = True), 
+        'verified': Parameter(bool, "Whether the node configuration is verified correct", ro=False),
         'key': Parameter(str, "(Admin only) Node key", max = 256),
         'session': Parameter(str, "(Admin only) Node session value", max = 256, ro = True),
         'interface_ids': Parameter([int], "List of network interfaces that this node has"),
@@ -66,7 +69,7 @@ class Node(Row):
         'ports': Parameter([int], "List of PCU ports that this node is connected to"),
         'peer_id': Parameter(int, "Peer to which this node belongs", nullok = True),
         'peer_node_id': Parameter(int, "Foreign node identifier at peer", nullok = True),
-        'tag_ids' : Parameter ([int], "List of tags attached to this node"),
+        'node_tag_ids' : Parameter ([int], "List of tags attached to this node"),
         'nodegroup_ids': Parameter([int], "List of node groups that this node is in"),
         }
     related_fields = {
@@ -245,11 +248,15 @@ class Node(Row):
         """
 
         assert 'node_id' in self
-       assert 'interface_ids' in self
 
        # we need to clean up InterfaceTags, so handling interfaces as part of join_tables does not work
-       for interface in Interfaces(self.api,self['interface_ids']):
-           interface.delete()
+        # federated nodes don't have interfaces though so for smooth transition from 4.2 to 4.3
+        if 'peer_id' in self and self['peer_id']:
+            pass
+        else:
+            assert 'interface_ids' in self
+            for interface in Interfaces(self.api,self['interface_ids']):
+                interface.delete()
 
         # Clean up miscellaneous join tables
         for table in self.join_tables:
@@ -274,7 +281,8 @@ class Nodes(Table):
         view = "view_nodes"
         # as many left joins as requested tags
         for tagname in self.tag_columns:
-            view= "%s left join %s using (%s)"%(view,Node.tagvalue_view_name(tagname),Node.primary_key)
+            view= "%s left join %s using (%s)"%(view,Node.tagvalue_view_name(tagname),
+                                                Node.primary_key)
             
         sql = "SELECT %s FROM %s WHERE deleted IS False" % \
               (", ".join(self.columns.keys()+self.tag_columns.keys()),view)