Skip to content
  • Leigh B. Stoller's avatar
    Changes necessary for moving most of the stuff in the node_types · 624a0364
    Leigh B. Stoller authored
    table, into a new table called node_type_attributes, which is intended
    to be a more extensible way of describing nodes.
    
    The only things left in the node_types table will be type,class and the
    various isXXX boolean flags, since we use those in numerous joins all over
    the system (ie: when discriminating amongst nodes).
    
    For the most part, all of that other stuff is rarely used, or used in
    contexts where the information is needed, but not for type descrimination.
    Still, it made for a lot of queries to change!
    
    Along the way I added a NodeType library module that represents the type
    info as a perl object. I also beefed up the existing Node module, and
    started using it in more places. I also added an Interfaces module, but I
    have not done much with that yet.
    
    I have not yet removed all the slots from the node_types table; I plan to
    run the new code for a few days and then remove the slots.
    
    Example using the new NodeType object:
    
    	use NodeType;
    
    	my $typeinfo = NodeType->Lookup($type);
    
            if ($typeinfo->control_interface(\$control_iface) ||
                !$control_iface) {
      	    warn "No control interface for $type is defined in the DB!\n";
            }
    
    or using the Node:
    
    	use Node;
    
            my $nodeobject = Node->Lookup($node_id);
            my $imageable  = $nodeobject->NodeTypeInfo()->imageable();
    or
            my $rebootable = $nodeobject->isrebootable();
    or
            $nodeobject->NodeTypeAttribute("control_interface", \$control_iface);
    
    Lots of way to accomplish the same thing, but the main point is that the
    Node is able to override the NodeType (if it wants to), which I think is
    necessary for flexibly describing one/two of a kind things like switches, etc.
    624a0364