From 861545f3334632ff7b1e957ca0bc79851e3a647d Mon Sep 17 00:00:00 2001 From: bp-sawyers Date: Thu, 7 Mar 2013 20:18:48 +0000 Subject: [PATCH] update xcatdb man page regex description git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.8@15413 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/db2man | 112 ++++++++++++++++++++++++++--------------------- 1 file changed, 61 insertions(+), 51 deletions(-) diff --git a/perl-xCAT/db2man b/perl-xCAT/db2man index e1d9049bd..b4dee191f 100755 --- a/perl-xCAT/db2man +++ b/perl-xCAT/db2man @@ -157,61 +157,69 @@ B or B commands. They can be viewed using B or B, B, B, B. See Object Definitions below. xCAT allows the use of different database applications, depending on the needs of your cluster. The default database is SQLite, which is a daemonless, zero-config database. But you could instead choose to use something like postgresql for greater scalability and remote access in the hierarchical/service node case. To use a different database or a different location, create -the file /etc/xcat/cfgloc. - See the appropriate xCAT docuementation for the format of the file for the database you choose. -The following example is for PostgreSQL: +the file /etc/xcat/cfgloc. See the appropriate xCAT docuementation for the format of the file for the database you choose. +The following example /etc/xcat/cfgloc file is for PostgreSQL: - -=over 4 - -=item Pg:dbname=xcat;host=|| + Pg:dbname=xcat;host=|| where mgmtnode is the hostname of the management node adapter on the cluster side, and the pgadminuserid and pgadminpasswd are the database admin and password. -=back +=head2 GROUPS AND REGULAR EXPRESSIONS IN TABLES -The xCAT database spans a number of tables, some with records associated with particular nodes -(such as nodelist and nodehm) and others that do not have a direct relationship with any given node. -The tables not associated with a given node are straightforward, the data is stored and retrieved -as-is from the database without interpretation, and without any generic inheritance -(though some calling code may implement inheritance for specific fields, for example -nodehm.power inheriting from nodehm.mgt). - -The tables with records typically retrieved by node name have some extra features to enable a more +The xCAT database has a number of tables, some with rows that are keyed by node name +(such as noderes and nodehm) and others that are not keyed by node name (for example, the policy table). +The tables that are keyed by node name have some extra features that enable a more template-based style to be used: -Any group name can be used in lieu of a node name in the node field, and that record will then -be taken to be applicable to any node in that group. If a field is requested for a specific node, -and either a record doesn't exist specifically for that nodename or a record exists, but has no -definition for the requested field, that node's groups are then used to search for -records. If multiple records could apply from two different groups, the precedence is -the order the groups are specified in the nodelist table for that node. This is nearly identical to -most xCAT 1.x tab file conventions. This is useful in tables such as noderes, where typical -configurations have exactly the same field values for large sets of nodes. +Any group name can be used in lieu of a node name in the node field, and that row will then +provide "default" attribute values for any node in that group. A row with a specific node name +can then override one or more attribute values for that specific node. For example, if the nodehm table contains: -xCAT 2 extends the above to be made useful where a field will vary for every node with a given tag, -but in ways that would be trivial to describe. If a field is of the format /I/I/, -it is taken to be a perl regular expression, to be performed on the nodename. For example, the bmc field -of the ipmi table might be B for a record with node=ipmi to specify that the BMC hostname is derived -by appending B<-bmc> to the end of the nodename of every node in the ipmi group. + #node,power,mgt,cons,termserver,termport,conserver,serialport,serialspeed,serialflow,getmac,cmdmapping,comments,disable + "mygroup",,"ipmi",,,,,,"19200",,,,, + "node1",,,,,,,,"115200",,,,, -As an extension to the above, a regular expression extended with arithmetic operators is available, -by using the format |I|I|. This behaves similarly to the above, but () enclosed parts -in I are taken to signify arithmetic operations and substituted in. All operations are integer -arithmetic, so 5/4 would come out as 1. The typical perl positional variables are available in such expressions. +In the above example, the node group called mygroup sets mgt=ipmi and serialspeed=19200. Any nodes that are in this group +will have those attribute values, unless overridden. For example, if node2 is a member of mygroup, it will automatically +inherit these attribute values (even though it is not explicitly listed in this table). In the case of node1 above, it +inherits mgt=ipmi, but overrides the serialspeed to be 115200, instead of 19200. A useful, typical way to use this +capability is to create a node group for your nodes and for all the attribute values that are the same for every node, +set them at the group level. Then you only have to set attributes for each node that vary from node to node. -For example, if you have many blades in your cluster and their hostnames have a regular -pattern of blade1, blade2, etc., and your BladeCenter management modules also have a hostname -pattern of amm1, amm2, etc., then your B table could be expressed by the following single row: +xCAT extends the group capability so that it can also be used for attribute values that vary from node to node +in a very regular pattern. For example, if in the ipmi table you want the bmc attribute to be set to whatever the nodename is with +"-bmc" appended to the end of it, then use this in the ipmi table: - "blade","|\D+(\d+)|amm(($1-1)/14+1)|","|\D+(\d+)|(($1-1)%14+1)|",, + #node,bmc,bmcport,taggedvlan,bmcid,username,password,comments,disable + "compute","/\z/-bmc/",,,,,,, + +In this example, "compute" is a node group that contains all of the compute nodes. The 2nd attribute (bmc) is a regular +expression that is similar to a substitution pattern. The 1st part "\z" matches the end of the node name and substitutes "-bmc", effectively appending it to the node name. + +Another example is if node1 is to have IP address 10.0.0.1, node2 is to have IP address 10.0.0.2, etc., +then this could be represented in the hosts table with the single row: + + #node,ip,hostnames,otherinterfaces,comments,disable + "compute","|node(\d+)|10.0.0.($1+0)|",",,, + +In this example, the regular expression in the ip attribute uses "|" to separate the 1st and 2nd part. This means that +xCAT will allow arithmetic operations in the 2nd part. In the 1st part, "(\d+)", will match the number part of the node +name and put that in a variable called $1. The 2nd part +is what value to give the ip attribute. In this case it will set it to the string "10.0.0." and the number that is +in $1. (Zero is added to $1 just to remove any leading zeroes.) + +A more involved example is with the mp table. If your blades have node names node01, node02, etc., and your chassis +node names are cmm01, cmm02, etc., then you might have an mp table like: + + #node,mpa,id,nodetype,comments,disable + "blade","|\D+(\d+)|cmm(sprintf('%02d',($1-1)/14+1))|","|\D+(\d+)|(($1-1)%14+1)|",, Before you panic, let me explain each column: @@ -221,32 +229,34 @@ Before you panic, let me explain each column: This is a group name. In this example, we are assuming that all of your blades belong to this group. Each time the xCAT software accesses the B table to get the management module and slot number -of a specific blade (e.g. B), this row will match (because B is in the B group). -Once this row is matched for B, then the processing described in the following items will take +of a specific blade (e.g. B), this row will match (because B is in the B group). +Once this row is matched for B, then the processing described in the following items will take place. -=item B<|\D+(\d+)|amm(($1-1)/14+1)|> +=item B<|\D+(\d+)|cmm(sprintf('%02d',($1-1)/14+1))|> This is a perl substitution pattern that will produce the value for the second column of the table (the -management module hostname). -The text B<\D+(\d+)> between the 1st two vertical bars is +management module hostname). The text B<\D+(\d+)> between the 1st two vertical bars is a regular expression that matches the node -name that was searched for in this table (in this example B). The text that matches +name that was searched for in this table (in this example B). The text that matches within the 1st set of parentheses is set to $1. (If there was a 2nd set of parentheses, it would be set to $2, and so on.) In our case, the \D+ matches the non-numeric part of the name -(B) and the \d+ matches the numeric part (B<20>). So $1 is set to B<20>. The text B between the -2nd and 3rd vertical bars produces the string that should be used as the value -for this column in a hypothetical row for blade20. Since $1 is set to 20, the expression B<($1-1)/14+1> equals -19/14 + 1, which equals 2. Therefore the whole string is B, which will be used as the hostname +(B) and the B<\d+> matches the numeric part (B<20>). So $1 is set to B<20>. The text B between the +2nd and 3rd vertical bars produces the string that should be used as the value for the mpa attribute for node20. +Since $1 is set to 20, the expression B<($1-1)/14+1> equals +19/14 + 1, which equals 2. (The division is integer division, +so 19/14 equals 1. Fourteen is used as the divisor, because there are 14 blades in each chassis.) The value of 2 is then passed into sprintf() with a format string to add a leading +zero, if necessary, to always make the number two digits. Lastly the string B is added to the beginning, +making the resulting string B, which will be used as the hostname of the management module. =item B<|\D+(\d+)|(($1-1)%14+1)|> This item is similar to the one above. This substituion pattern will produce the value for -the 3rd column (the BladeCenter chassis slot number for this blade). Because this row was -the match for B, the parentheses +the 3rd column (the chassis slot number for this blade). Because this row was +the match for B, the parentheses within the 1st set of vertical bars will set $1 to 20. Since % means modulo division, the -expression B<($1-1)%14+1> will evaluate to 6. +expression B<($1-1)%14+1> will evaluate to B<6>. =back