'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),
'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"),
'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 = {
}
view_tags_name = "view_node_tags"
- # tags declared here should also be defined as Accessors to ensure that the TagType is created
- 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):
"""
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:
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)
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]})