From 8b2fee5c16ce41d353d372b6c4f48af6720e1476 Mon Sep 17 00:00:00 2001 From: bp-sawyers Date: Thu, 21 Feb 2008 21:10:35 +0000 Subject: [PATCH] Added descriptions to the db tables. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@545 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT-2.0/xCAT/Client.pm | 6 +- perl-xCAT-2.0/xCAT/MsgUtils.pm | 48 +- perl-xCAT-2.0/xCAT/Schema.pm | 831 ++++++++++++------ perl-xCAT-2.0/xCAT/Table.pm | 265 +++--- xCAT-client-2.0/bin/xcatDBcmds | 4 +- xCAT-client-2.0/bin/xdsh | 3 +- xCAT-client-2.0/pods/man1/tabdump.1.pod | 18 +- xCAT-client-2.0/share/man/man1/tabdump.1 | 24 +- .../lib/xcat/plugins/DBobjectdefs.pm | 46 +- xCAT-server-2.0/lib/xcat/plugins/tabutils.pm | 30 +- 10 files changed, 811 insertions(+), 464 deletions(-) diff --git a/perl-xCAT-2.0/xCAT/Client.pm b/perl-xCAT-2.0/xCAT/Client.pm index 7d7defc68..1006e0441 100644 --- a/perl-xCAT-2.0/xCAT/Client.pm +++ b/perl-xCAT-2.0/xCAT/Client.pm @@ -536,7 +536,7 @@ sub handle_response { } # Handle {data} structure with no nodes - if (scalar @{$rsp->{data}}) { + if ($rsp->{data}) { #print "printing data\n"; my $data=($rsp->{data}); my $data_entry; @@ -556,9 +556,7 @@ sub handle_response { } } } - if ($desc) { - print "$desc\n"; - } + if ($desc) { print "$desc\n"; } } } } # end of handle_response diff --git a/perl-xCAT-2.0/xCAT/MsgUtils.pm b/perl-xCAT-2.0/xCAT/MsgUtils.pm index 8c69ef9c6..bd7d949ae 100644 --- a/perl-xCAT-2.0/xCAT/MsgUtils.pm +++ b/perl-xCAT-2.0/xCAT/MsgUtils.pm @@ -212,54 +212,56 @@ sub message # Check that correct structure is filled in. If the data is not in the # structure corresponding to the $sev, then look for it in "data" - #TODO: this is not really right for a couple reasons: 1) all the fields in the + #TODO: this is not really right for a few reasons: 1) all the fields in the # response structure are arrays, so can handle multiple lines of text. We # should not just be check the 0th element. 2) a cmd may have both error # text and data text. 3) this message() function should just take in a plain # string and put it in the correct place based on the severity. if ($call_back) { # callback routine provided my $sevkey; - if ($sev =~ /I/) { $sevkey = 'info'; } - if ($sev =~ /W/) { $sevkey = 'warning'; } - if ($sev =~ /E/) { + if ($sev =~ /D/) { $sevkey = 'data'; } + elsif ($sev =~ /I/) { $sevkey = 'info'; } + elsif ($sev =~ /W/) { $sevkey = 'warning'; } + elsif ($sev =~ /E/) { $sevkey = 'error'; if (!defined($exitcode)) { $exitcode = 1; } # default to something non-zero } - if (defined($sevkey)) { + else { print "Internal Error: Invalid severity passed to MsgUtils::message().\n"; return 1; } + + if ($sevkey ne 'data') { if (!defined ($rsp->{$sevkey}) || !scalar(@{$rsp->{$sevkey}})) { # did not pass the text in in the severity-specific field if (defined ($rsp->{data}) && scalar(@{$rsp->{data}})) { - push @{$rsp->{$sevkey}}, shift @{$rsp->{data}}; # assume they passed in the text in the data field instead + push @{$rsp->{$sevkey}}, @{$rsp->{data}}; # assume they passed in the text in the data field instead + @{$rsp->{data}} = (); # clear out the data field } } } if (!defined ($rsp->{$sevkey}) || !scalar(@{$rsp->{$sevkey}})) { return; } # if still nothing in the array, there is nothing to print out - if ($sev ne 'S') # if sev is anything but only-syslog, print the msg - { # not just syslog - if ($exitcode) { $rsp->{errorcode}->[0] = $exitcode; } + if ($sev ne 'S') { # if sev is anything but only-syslog, print the msg + if ($exitcode) { push @{$rsp->{errorcode}}, $exitcode; } $call_back->($rsp); # send message to daemon/Client.pm - shift @{$rsp->{$sevkey}}; # clear out the rsp structure in case they use it again - if ($exitcode) { shift @{$rsp->{errorcode}}; } + @{$rsp->{$sevkey}} = (); # clear out the rsp structure in case they use it again + @{$rsp->{data}} = (); + @{$rsp->{errorcode}} = (); } + # No need to support syslog writing when they specified a callback } + else # no callback provided { - if ($sev ne 'S') # syslog only + if ($sev ne 'S') # it is not syslog only { print $stdouterrf $rsp; # print the message - } + if ($sev =~ /S/) { + # If they want this msg to also go to syslog, do that now + openlog("xCAT", '', 'local4'); + syslog("err", $rsp); + closelog(); + } } - if ($sev =~ /[S]/) - { - - # need to syslog , the message - openlog("xCAT", '', 'local4'); - - syslog("err", $rsp); - closelog(); - } - return 0; + return; } 1; diff --git a/perl-xCAT-2.0/xCAT/Schema.pm b/perl-xCAT-2.0/xCAT/Schema.pm index fa4c610fa..0c8f934e1 100644 --- a/perl-xCAT-2.0/xCAT/Schema.pm +++ b/perl-xCAT-2.0/xCAT/Schema.pm @@ -10,121 +10,387 @@ package xCAT::Schema; #certain SQL backends don't ascribe meaning to the data types anyway. #New format, not sql statements, but info enough to describe xcat tables %tabspec = ( - deps => { - cols => [qw(node nodedep msdelay cmd comments disable)], - keys => [qw(node)], - }, - ppchcp => { - cols => [qw(hcp username password comments disable)], - keys => [qw(hcp)], - }, - ppc => { - cols => [qw(node hcp id profile parent comments disable)], - keys => [qw(node)], - }, - ppcdirect => { - cols => [qw(hcp username password comments disable)], - keys => [qw(hcp)], - }, - nodetype => { - cols => [qw(node os arch profile comments disable)], - keys => [qw(node)], - }, - nodepos => { - cols => [qw(node rack u chassis slot room comments disable)], - keys => [qw(node)], - }, - iscsi => { - cols => [qw(node server target file userid passwd kernel kcmdline initrd comments disable)], - keys => [qw(node)], - }, - vpd => { - cols => [qw(node serial mtm comments disable)], - keys => [qw(node)], - }, - nodehm => { - cols => [qw(node power mgt cons termserver termport conserver serialspeed serialflow getmac comments disable)], - keys => [qw(node)], - }, - hosts => { - cols => [qw(node ip hostnames comments disable)], - keys => [qw(node)], - }, - mp => { - cols => [qw(node mpa id comments disable)], - keys => [qw(node)], - }, - mpa => { - cols => [qw(mpa username password comments disable)], - keys => [qw(mpa)], - }, - mac => { - cols => [qw(node interface mac comments disable)], - keys => [qw(node)], - }, - chain => { +chain => { cols => [qw(node currstate currchain chain ondiscover comments disable)], keys => [qw(node)], + table_desc => 'Controls what operations are done (and it what order) when a node is discovered and deployed.', + descriptions => { + node => 'The node name or group name.', + currstate => 'The current chain state for this node. Set by xCAT.', + currchain => 'The current execution chain for this node. Set by xCAT. Initialized from chain and updated as chain is executed.', + chain => 'A comma-delimited chain of actions to be performed automatically for this node. Valid values: discover, boot or reboot, install or netboot, runcmd=, runimage=, shell, standby. (Default - same as no chain). Example, for BMC machines use: runcmd=bmcsetup,standby.', + ondiscover => 'What to do when a new node is discovered. Valid values: nodediscover, ??', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, }, - noderes => { - cols => [qw(node servicenode netboot tftpserver nfsserver monserver kernel initrd kcmdline nfsdir serialport installnic primarynic xcatmaster current_osimage next_osimage comments disable)], +deps => { + cols => [qw(node nodedep msdelay cmd comments disable)], keys => [qw(node)], + table_desc => 'Describes dependencies some nodes have on others. This can be used, e.g., by rpower -d to power nodes on or off in the correct order.', + descriptions => { + node => 'The node name or group name.', + nodedep => 'Comma-separated list of nodes it is dependent on.', + msdelay => 'How long to wait between operating on the dependent nodes and the primary nodes.', + cmd => 'Which xCAT command this dependency applies to.', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, }, - networks => { +hosts => { + cols => [qw(node ip hostnames comments disable)], + keys => [qw(node)], + table_desc => 'IP address and hostnames of nodes. This info can be used to populate /etc/hosts or DNS.', + descriptions => { + node => 'The node name or group name.', + ip => 'The IP address of the node.', + hostnames => 'Hostname aliases added to /etc/hosts for this node.', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, + }, +ipmi => { + cols => [qw(node bmc username password comments disable )], + keys => [qw(node)], + table_desc => 'Settings for nodes that are controlled by an on-board BMC via IPMI.', + descriptions => { + node => 'The node name or group name.', + bmc => 'The hostname of the BMC adapater.', + username => 'The BMC userid. Default is ??', + password => 'The BMC password.', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, + }, +iscsi => { + cols => [qw(node server target file userid passwd kernel kcmdline initrd comments disable)], + keys => [qw(node)], + table_desc => 'Contains settings that control how to boot a node from an iSCSI disk.', + descriptions => { + node => 'The node name or group name.', + server => 'The server containing the iscsi boot device for this node.', + target => '??The target of the iscsi disk used for the boot device for this node.', + file => '', + userid => 'The userid of the iscsi server containing the boot device for this node.', + passwd => 'The password for the iscsi server containing the boot device for this node.', + kernel => '', + kcmdline => '', + initrd => 'The initial ramdisk to use when network booting this node.', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, + }, +mac => { + cols => [qw(node interface mac comments disable)], + keys => [qw(node)], + table_desc => "The MAC address of the node's install adapter. Normally this table is populated by getmacs or node discovery, but you can also add entries to it manually.", + descriptions => { + node => 'The node name or group name.', + interface => 'The adapter interface name that will be used to install and manage the node. E.g. eth0 (for linux) or en0 (for AIX).)', + mac => 'The MAC address of the network adapter that will be used to install the node, e.g. 00:D0:A8:00:05:F3 .', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, + }, +monitoring => { + cols => [qw(name nodestatmon comments disable)], + keys => [qw(name)], + required => [qw(name)], + table_desc => 'Controls what external monitoring tools xCAT sets up and uses.', + descriptions => { + name => 'The name of the mornitoring plug-in module. Location??', + nodestatmon => 'Specifies if the monitoring plug-in is used to feed the node status to the xCAT cluster. Any one of the following values indicates "yes": y, Y, yes, Yes, YES, 1. Any other value or blank (default), indicates "no".', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, + }, +mp => { + cols => [qw(node mpa id comments disable)], + keys => [qw(node)], + table_desc => 'Contains the hardware control info specific to blades. This table also refers to the mpa table, which contains info about each Management Module.', + descriptions => { + node => 'The blade node name or group name.', + mpa => 'The managment module used to control this blade.', + id => 'The slot number of this blade in the BladeCenter chassis.', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, + }, +mpa => { + cols => [qw(mpa username password comments disable)], + keys => [qw(mpa)], + table_desc => 'Contains info about each Management Module and how to access it.', + descriptions => { + mpa => 'Hostname of the management module.', + username => 'Userid to use to access the management module.', + password => 'Password to use to access the management module.', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, + }, +networks => { cols => [qw(netname net mask mgtifname gateway dhcpserver tftpserver nameservers dynamicrange nodehostname comments disable)], - keys => [qw(net mask)] + keys => [qw(net mask)], + table_desc => 'Describes the networks in the cluster and info necessary to set up nodes on that network.', + descriptions => { + netname => 'Name used to identify this network definition.', + net => 'The network address.', + mask => 'The network mask.', + mgtifname => '??', + gateway => 'The network gateway.', + dhcpserver => 'The DHCP server that is servicing this network.', + tftpserver => 'The TFTP server that is servicing this network.', + nameservers => 'The nameservers for this network. Used in creating the DHCP network definition.', + dynamicrange => 'The IP address range used by DHCP to assign dynamic IP addresses for requests on this network.', + nodehostname => '??', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, }, - osimage => { - cols => [qw(imagename osname osvers osdistro osarch comments disable)], - keys => [qw(imagename)] - }, - nodegroup => { +nodegroup => { cols => [qw(groupname grouptype members wherevals comments disable)], - keys => [qw(groupname)] + keys => [qw(groupname)], + table_desc => 'Not supported yet! Contains group definitions, whose membership is dynamic depending on characteristics of the node.', + descriptions => { + groupname => 'Name of the group.', + grouptype => '??', + members => '??', + wherevals => 'A list of comma-separated "attr=val" pairs that can be used to determine the members of a dynamic group.', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, }, - switch => { - cols => [qw(node switch port vlan comments disable)], - keys => [qw(node switch port)] +nodehm => { + cols => [qw(node power mgt cons termserver termport conserver serialspeed serialflow getmac comments disable)], + keys => [qw(node)], + table_desc => "Settings that control how each node's hardware is managed. Typically, an additional table that is specific to the hardware type of the node contains additional info. E.g. the ipmi, mp, and ppc tables.", + descriptions => { + node => 'The node name or group name.', + power => 'The power method. If not set, the mgt attribute will be used. Valid values: ipmi, blade, hmc, ivm, fsp??. If "ipmi", xCAT will search for this node in the ipmi table for more info. If "blade", xCAT will search for this node in the mp table. If "hmc", "ivm", or "fsp", xCAT will search for this node in the ppc table.', + mgt => 'The hardware management method. Valid values: ipmi, blade, hmc, ivm, fsp. See the power attribute for more details.', + cons => 'The console method. If not set, the mgt attribute will be used. Valid values: cyclades, mrv, ??', + termserver => 'The hostname of the terminal server.', + termport => 'The port number on the terminal server that this node is connected to.', + conserver => 'Not used??', + serialspeed => 'The speed of the serial port for this node. For SOL on blades, this is typically 19200.', + serialflow => "The flow value of the serial port for this node. For SOL on blades, this is typically 'hard'.", + getmac => 'Not used??', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, }, - nodelist => { +nodelist => { cols => [qw(node nodetype groups status comments disable)], keys => [qw(node)], + table_desc => "The list of all the nodes in the cluster, including each node's current status and what groups it is in.", + descriptions => { + node => 'The hostname of a node in the cluster.', + nodetype => 'A comma-delimited list of characteristics of this node. Valid values: blade, vm (virtual machine), lpar, osi (OS image), hmc, fsp, ivm, bpa, mm, rsa, switch.', + groups => "A comma-delimited list of groups this node is a member of. Group names are arbitrary, except all nodes should be part of the 'all' group.", + status => 'The current status of this node. This attribute will be set by xCAT software. Valid values: defined, booting, discovering, installing, installed, alive, off.', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, }, - site => { +nodepos => { + cols => [qw(node rack u chassis slot room comments disable)], + keys => [qw(node)], + table_desc => 'Contains info about the physical location of each node. Currently, this info is not used by xCAT, and therefore can be in whatevery format you want. It will likely be used in xCAT in the future.', + descriptions => { + node => 'The node name or group name.', + rack => 'The frame the node is in.', + u => 'The vertical position of the node in the frame', + chassis => 'The BladeCenter chassis the blade is in.', + slot => 'The slot number of the blade in the chassis.', + room => 'The room the node is in.', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, + }, +noderes => { + cols => [qw(node servicenode netboot tftpserver nfsserver monserver kernel initrd kcmdline nfsdir serialport installnic primarynic xcatmaster current_osimage next_osimage comments disable)], + keys => [qw(node)], + table_desc => 'Resources and settings to use when installing nodes.', + descriptions => { + node => 'The node name or group name.', + servicenode => 'The node that provides most services for this node. This is the default value if any of nfsserver, tftpserver, monserver, etc., are not set.', + netboot => 'The type of network booting supported by this node. Valid values: pxe, yaboot.', + tftpserver => 'The TFTP server for this node.', + nfsserver => 'The NFS server for this node.', + monserver => 'The monitoring aggregation point for this node.', + kernel => 'The linux kernel version to install on the node.', + initrd => 'The linux initial ramdisk image used to deploy the node.', + kcmdline => 'The kernel command line used to deploy the node.', + nfsdir => 'Not used?? The path that should be mounted from the NFS server.', + serialport => 'The serial port for this node. For SOL on blades, this is typically 1. For IPMI, this is typically 0.', + installnic => 'The network adapter on the node that will be used for OS deployment. If not set, primarynic will be used.', + primarynic => 'The network adapter on the node that will be used for xCAT management. Default is eth0.', + xcatmaster => 'The hostname of the xCAT management node as known from this node.', + current_osimage => 'Not used?? The name of the osimage data object that represents the OS image currently deployed on this node.', + next_osimage => 'Not used?? The name of the osimage data object that represents the OS image that will be installed on the node the next time it is deployed.', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, + }, +nodetype => { + cols => [qw(node os arch profile comments disable)], + keys => [qw(node)], + table_desc => 'A few hardware and software characteristics of the nodes.', + descriptions => { + node => 'The node name or group name.', + os => 'The operating system deployed on this node. Valid values: rh*, centos*, fedora*, sles* (where * is the version #).', + arch => 'The hardware architecture of this node. Valid values: x86_64, ppc64, x86, ia64.', + profile => 'The kickstart or autoyast template to use for OS deployment of this node.', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, + }, +notification => { + cols => [qw(filename tables tableops comments disable)], + keys => [qw(filename)], + required => [qw(tables filename)], + table_desc => 'Contains registrations to be notified when a table in the xCAT database changes. Users can add entries to have additional software notified of changes.', + descriptions => { + filename => 'A file that implements the callback routine when the monitored table changes. Location and format??', + tables => 'The name of the xCAT database table to monitor. More than 1??', + tableops => 'Specifies the table operation to monitor for. Valid values: "d" (rows deleted), "a" (rows added), "u" (rows updated).', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, + }, +osimage => { + cols => [qw(imagename osname osvers osdistro osarch comments disable)], + keys => [qw(imagename)], + table_desc => 'Not used yet! All the info that specifies a particular operating system image that can be used on nodes.', + descriptions => { + imagename => '', + osname => '', + osvers => '', + osdistro => '', + osarch => '', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, + }, +passwd => { + cols => [qw(key username password comments disable)], + keys => [qw(key)], + table_desc => 'Contains default userids and passwords for xCAT to access cluster components. Userids/passwords for specific cluster components can be overidden in other tables, e.g. mpa, ipmi, ppchcp, etc.', + descriptions => { + key => 'The type of component this user/pw is for. Valid values: blade (management module), ipmi (BMC), system (nodes??), omapi (DHCP).', + username => 'The default userid for this type of component', + password => 'The default password for this type of component', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, + }, +policy => { + cols => [qw(priority name host commands noderange parameters time rule comments disable)], + keys => [qw(priority)], + table_desc => 'Not fully implemented! Controls who has authority to run specific xCAT operations.', + descriptions => { + priority => 'The priority value for this rule. This value is used to identify this policy data object (i.e. this rule).', + name => 'The username that is allowed to perform the commands specified by this rule. Default is "*" (all users).', + host => 'The host from which users may issue the commands specified by this rule. Default is "*" (all hosts).', + commands => 'The list of commands that this rule applies to. Default is "*" (all commands).', + noderange => 'The Noderange that this rule applies to. Default is "*" (all nodes).', + parameters => 'Command parameters that this rule applies to. Default??', + time => 'Time ranges that this command may be executed in. Default is any time.', + rule => 'Specifies how this rule should be applied. Valid values are: allow, accept. Either of these values will allow the user to run the commands. Any other value will deny the user access to the commands.', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, + }, +postscripts => { + cols => [qw(node postscripts comments disable)], + keys => [qw(node)], + table_desc => 'Not used yet! The scripts that should be run on each node after installation or diskless boot.', + descriptions => { + node => 'The node name or group name.', + postscripts => 'Comma separated list of scripts that should be run on this node after installation or diskless boot.', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, + }, +ppc => { + cols => [qw(node hcp id profile parent comments disable)], + keys => [qw(node)], + table_desc => 'List of system p hardware: HMCs, IVMs, FSPs, BPCs.', + descriptions => { + node => 'The node name or group name.', + hcp => 'The hardware control point for this node (HMC, IVM, or FSP). If ', + id => 'For LPARs: the LPAR numeric id; for FSPs: the cage number; for BPAs: the frame number.', + profile => 'The LPAR profile that will be used the next time the LPAR is powered on with rpower.', + parent => 'For LPARs: the FSP/CEC; for FSPs: the BPA (if one exists).', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, + }, +ppcdirect => { + cols => [qw(hcp username password comments disable)], + keys => [qw(hcp)], + table_desc => 'Info necessary to use FSPs to control system p CECs.', + descriptions => { + hcp => 'Hostname of the FSP.', + username => 'Userid of the FSP. Default is ??', + password => 'Password of the FSP.', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, + }, +ppchcp => { + cols => [qw(hcp username password comments disable)], + keys => [qw(hcp)], + table_desc => 'Info necessary to use HMCs and IVMs as hardware control points for LPARs.', + descriptions => { + hcp => 'Hostname of the HMC or IVM.', + username => 'Userid of the HMC or IVM. Default is hscroot for HMCs and padmin for IVMs??', + password => 'Password of the HMC or IVM.', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, + }, +site => { cols => [qw(key value comments disable)], - keys => [qw(key)] + keys => [qw(key)], + table_desc => 'Global settings for the whole cluster. This table is different from the other tables in that each attribute is just named in the key column, rather than having a separate column for each attribute.', + descriptions => { + key => 'Name of the attribute. Valid values: master (xCAT management node), xcatconfdir (default /etc/xcat), domain (DNS domain name used for the cluster), installdir (directory that holds the node deployment pkgs), xcatdport (port used by xcatd daemon??), xcatiport (??), timezone (e.g. America/New_York), nameservers (list of DNS servers for the cluster), rsh (path of remote shell command), rcp (path of remote copy command), blademaxp (max # of processes for blade hw ctrl), ppcmaxp (max # of processes for PPC hw ctrl), ipmimaxp, ipmitimeout, ipmiretries, ipmisdrcache, iscsidir, xcatservers (service nodes??), dhcpinterfaces (network interfaces DHCP should listen on??), forwarders (DNS forwarders??), genpasswords (generate BMC passwords??).', + value => 'The value of the attribute specified in the "key" column.', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, }, # site => { # cols => [qw(sitename domain master rsh rcp xcatdport installdir comments disable)], # keys => [qw(sitename)] # }, - passwd => { - cols => [qw(key username password comments disable)], - keys => [qw(key)] +switch => { + cols => [qw(node switch port vlan comments disable)], + keys => [qw(node switch port)], + table_desc => 'Contains what switch port numbers each node is connected to.', + descriptions => { + node => 'The node name or group name.', + switch => 'The switch hostname.', + port => 'The port number in the switch that this node is connected to.', + vlan => '??', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, }, - postscripts => { - cols => [qw(node postscripts)], +vpd => { + cols => [qw(node serial mtm comments disable)], keys => [qw(node)], + table_desc => 'The Machine type, Model, and Serial numbers of each node.', + descriptions => { + node => 'The node name or group name.', + serial => 'The serial number of the node.', + mtm => 'The machine type and model number of the node. E.g. 7984-6BU', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", + }, }, - ipmi => { - cols => [qw(node bmc username password comments disable )], - keys => [qw(node)] - }, - policy => { - cols => [qw(priority name host commands noderange parameters time rule comments disable)], - keys => [qw(priority)] - }, - notification => { - cols => [qw(filename tables tableops comments disable)], - keys => [qw(filename)], - required => [qw(tables filename)] - }, - monitoring => { - cols => [qw(name nodestatmon comments disable)], - keys => [qw(name)], - required => [qw(name)] - } - ); +); # end of tabspec definition @@ -138,16 +404,16 @@ package xCAT::Schema; # # Definition format: # List of data object hashes: -# => -# {attrs => +# => +# {attrs => # [ {attr_name => '', -# only_if => '=', +# only_if => '=', # # optional, used to define conditional attributes. # # is a previously resolved attribute from # # this data object. -# tabentry => '', +# tabentry => '', # # where the data is stored in the database -# access_tabentry => '=', +# access_tabentry => '=', # # how to look up tabentry. For , # # if "attr:", use a previously resolved # # attribute value from the data object @@ -158,9 +424,9 @@ package xCAT::Schema; # ... # } ], # attrhash => {}, # internally generated hash of attrs array -# # to allow code direct access to an attr def +# # to allow code direct access to an attr def # objkey => 'attribute_name' # key attribute for this data object -# } +# } # # #################################################### @@ -178,25 +444,25 @@ package xCAT::Schema; ############### -# @nodeattrs ia a list of node attrs that can be used for +# @nodeattrs ia a list of node attrs that can be used for # BOTH node and group definitions ############## my @nodeattrs = ( #################### -# postscripts table# +# postscripts table# #################### {attr_name => 'postscripts', tabentry => 'postscripts.postscripts', access_tabentry => 'postscripts.node=attr:node', - description => 'The list of post install scripts .'}, + }, #################### -# noderes table # +# noderes table # #################### {attr_name => 'xcatmaster', tabentry => 'noderes.xcatmaster', access_tabentry => 'noderes.node=attr:node', - description => 'The hostname of the xCAT management node as known from this node.'}, + }, ### # TODO: Need to check/update code to make sure it really uses servicenode as # default if other server value not set @@ -204,17 +470,17 @@ my @nodeattrs = ( {attr_name => 'servicenode', tabentry => 'noderes.servicenode', access_tabentry => 'noderes.node=attr:node', - description => 'The node that provides most services for this node. This is the default value if nfsserver, tftpserver, monserver, etc., are not set.'}, + }, {attr_name => 'tftpserver', only_if => 'nodetype=osi', tabentry => 'noderes.tftpserver', access_tabentry => 'noderes.node=attr:node', - description => 'The TFTP server for this node.'}, + }, {attr_name => 'nfsserver', only_if => 'nodetype=osi', tabentry => 'noderes.nfsserver', access_tabentry => 'noderes.node=attr:node', - description => 'The NFS server for this node.'}, + }, ### # TODO: Is noderes.nfsdir used anywhere? Could not find any code references # to this attribute. @@ -223,175 +489,175 @@ my @nodeattrs = ( only_if => 'nodetype=osi', tabentry => 'noderes.nfsdir', access_tabentry => 'noderes.node=attr:node', - description => '??? not sure if this is used ??? '}, + }, {attr_name => 'monserver', only_if => 'nodetype=osi', tabentry => 'noderes.monserver', access_tabentry => 'noderes.node=attr:node', - description => 'The monitoring server for this node.'}, + }, {attr_name => 'kernel', tabentry => 'noderes.kernel', access_tabentry => 'noderes.node=attr:node', - description => 'The linux kernel image used to deploy the node.'}, + }, {attr_name => 'initrd', tabentry => 'noderes.initrd', access_tabentry => 'noderes.node=attr:node', - description => 'The linux initial ramdisk image used to deploy the node.'}, + }, {attr_name => 'kcmdline', tabentry => 'noderes.kcmdline', access_tabentry => 'noderes.node=attr:node', - description => 'The kernel command line used to deploy the node..'}, + }, # Note that the serialport attr is actually defined down below # with the other serial* attrs from the nodehm table #{attr_name => 'serialport', # tabentry => 'noderes.serialport', # access_tabentry => 'noderes.node=attr:node', - # description => 'The serial port for this node. For SOL on blades, this is typically 1. For IPMI, this is typically 0.'}, + # }, {attr_name => 'primarynic', only_if => 'nodetype=osi', tabentry => 'noderes.primarynic', access_tabentry => 'noderes.node=attr:node', - description => 'The network adapter on the node that will be used for xCAT management. Default is eth0.'}, + }, {attr_name => 'installnic', only_if => 'nodetype=osi', tabentry => 'noderes.installnic', access_tabentry => 'noderes.node=attr:node', - description => 'The network adapter on the node that will be used for OS deployment. If not set, the primarynic will be used.'}, + }, {attr_name => 'netboot', only_if => 'nodetype=osi', tabentry => 'noderes.netboot', access_tabentry => 'noderes.node=attr:node', - description => 'The type of network booting supported by this node. Possible values are: pxe, yaboot'}, + }, {attr_name => 'current_osimage', only_if => 'nodetype=osi', tabentry => 'noderes.current_osimage', access_tabentry => 'noderes.node=attr:node', - description => 'The name of the osimage data object that represents the OS image currently deployed to this node. ??? Currently not used. ???'}, + }, {attr_name => 'next_osimage', only_if => 'nodetype=osi', tabentry => 'noderes.next_osimage', access_tabentry => 'noderes.node=attr:node', - description => 'The name of the osimage data object that represents the OS image that will be installed on the node the next time it is deployed. ??? Currently not used. ???'}, + }, ###################### -# nodetype table # +# nodetype table # ###################### {attr_name => 'arch', tabentry => 'nodetype.arch', access_tabentry => 'nodetype.node=attr:node', - description => 'Specifies the hardware architecture for this node.'}, + }, # TODO: need to decide what to do with the os attr once the osimage stuff is # implemented. The nodetype.os attr may be moved to the osimage table. {attr_name => 'os', only_if => 'nodetype=osi', tabentry => 'nodetype.os', access_tabentry => 'nodetype.node=attr:node', - description => 'Specifies the operating system for this node.'}, -# TODO: need to decide what to do with the profile attr once the osimage + }, +# TODO: need to decide what to do with the profile attr once the osimage # stuff is implemented. May want to move this to the osimage table. {attr_name => 'profile', only_if => 'nodetype=osi', tabentry => 'nodetype.profile', access_tabentry => 'nodetype.node=attr:node', - description => 'Specifies the template used for OS deployment of this node.'}, + }, #################### -# iscsi table # +# iscsi table # #################### - {attr_name => iscsiserver, - only_if => 'nodetype=osi', - tabentry => 'iscsi.server', - access_tabentry => 'iscsi.node=attr:node', - description => 'The server containing the iscsi boot device for this node.'}, - {attr_name => iscsitarget, - only_if => 'nodetype=osi', - tabentry => 'iscsi.target', - access_tabentry => 'iscsi.node=attr:node', - description => 'The target of the iscsi disk used for boot device for this node.'}, - {attr_name => iscsiuserid, - only_if => 'nodetype=osi', - tabentry => 'iscsi.userid', - access_tabentry => 'iscsi.node=attr:node', - description => 'The userid of the iscsi server containing the boot device for this node.'}, - {attr_name => iscsipassword, - only_if => 'nodetype=osi', - tabentry => 'iscsi.passwd', - access_tabentry => 'iscsi.node=attr:node', - description => 'The password for the iscsi server containing the boot device for this node.'}, + {attr_name => iscsiserver, + only_if => 'nodetype=osi', + tabentry => 'iscsi.server', + access_tabentry => 'iscsi.node=attr:node', + }, + {attr_name => iscsitarget, + only_if => 'nodetype=osi', + tabentry => 'iscsi.target', + access_tabentry => 'iscsi.node=attr:node', + }, + {attr_name => iscsiuserid, + only_if => 'nodetype=osi', + tabentry => 'iscsi.userid', + access_tabentry => 'iscsi.node=attr:node', + }, + {attr_name => iscsipassword, + only_if => 'nodetype=osi', + tabentry => 'iscsi.passwd', + access_tabentry => 'iscsi.node=attr:node', + }, #################### -# nodehm table # +# nodehm table # #################### {attr_name => 'mgt', tabentry => 'nodehm.mgt', access_tabentry => 'nodehm.node=attr:node', - description => 'Specifies the hardware management method. Valid methods are ipmi, blade, hmc, ivm, fsp.'}, + }, {attr_name => 'power', tabentry => 'nodehm.power', access_tabentry => 'nodehm.node=attr:node', - description => 'Specifies the power method. If not set, the mgt attribute will be use.'}, + }, {attr_name => 'cons', tabentry => 'nodehm.cons', access_tabentry => 'nodehm.node=attr:node', - description => 'Specifies the console method. If not set, the mgt attribute will be use.'}, + }, {attr_name => 'termserver', tabentry => 'nodehm.termserver', access_tabentry => 'nodehm.node=attr:node', - description => 'The name of the terminal server.'}, + }, {attr_name => 'termport', tabentry => 'nodehm.termport', access_tabentry => 'nodehm.node=attr:node', - description => 'The terminal port on the console server for this node.'}, + }, ### # TODO: is nodehm.conserver used anywhere? I couldn't find any code references ### {attr_name => 'conserver', tabentry => 'nodehm.conserver', access_tabentry => 'nodehm.node=attr:node', - description => '??? not sure if this is used ???.'}, + }, ### # TODO: is nodehm.getmac used anywhere? I couldn't find any code references ### {attr_name => 'getmac', tabentry => 'nodehm.getmac', access_tabentry => 'nodehm.node=attr:node', - description => '??? not sure if this is used ???.'}, + }, # Note that serialport is in the noderes table. Keeping it here in # the defspec so that it gets listed with the other serial* attrs {attr_name => 'serialport', tabentry => 'noderes.serialport', access_tabentry => 'noderes.node=attr:node', - description => 'The serial port for this node. For SOL on blades, this is typically 1. For IPMI, this is typically 0.'}, + }, {attr_name => 'serialspeed', tabentry => 'nodehm.serialspeed', access_tabentry => 'nodehm.node=attr:node', - description => 'The speed of the serial port for this node. For SOL on blades, this is typically 19200. '}, + }, {attr_name => 'serialflow', tabentry => 'nodehm.serialflow', access_tabentry => 'nodehm.node=attr:node', - description => 'The flow value of the serial port for this node. For SOL on blades, this is typically \"hard\".'}, + }, ################## -# vpd table # +# vpd table # ################## {attr_name => 'serial', tabentry => 'vpd.serial', access_tabentry => 'vpd.node=attr:node', - description => 'Serial number.'}, + }, {attr_name => 'mtm', tabentry => 'vpd.mtm', access_tabentry => 'vpd.node=attr:node', - description => 'Machine type model.'}, + }, ################## -# mac table # +# mac table # ################## {attr_name => 'interface', tabentry => 'mac.interface', access_tabentry => 'mac.node=attr:node', - description => 'The Ethernet adapter interface name that will be used to install and manage the node. (For example, eth0 or en0.)'}, + }, {attr_name => 'mac', tabentry => 'mac.mac', access_tabentry => 'mac.node=attr:node', - description => 'The machine address of the network adapter used for deployment.'}, + }, ################## -# chain table # +# chain table # ################## ### # TODO: Need user documentation from Jarrod on how to use chain, what each @@ -400,7 +666,7 @@ my @nodeattrs = ( {attr_name => 'chain', tabentry => 'chain.chain', access_tabentry => 'chain.node=attr:node', - description => 'A comma-delimited chain of actions to be performed automatically for this node. Valid actions include: discover, boot or reboot, install or netboot, runcmd=, runimage=, shell, standby (default - same as no chain) '}, + }, ### # TODO: What is chain.ondiscover used for? Could not find any code references # to this table entry @@ -408,156 +674,156 @@ my @nodeattrs = ( {attr_name => 'ondiscover', tabentry => 'chain.ondiscover', access_tabentry => 'chain.node=attr:node', - description => '?? not sure if this is used ???'}, + }, {attr_name => 'currstate', tabentry => 'chain.currstate', access_tabentry => 'chain.node=attr:node', - description => 'The current chain state for this node. Set by xCAT.'}, + }, {attr_name => 'currchain', tabentry => 'chain.currchain', access_tabentry => 'chain.node=attr:node', - description => 'The current execution chain for this node. Set by xCAT. Initialized from chain and updated as chain is executed.'}, + }, #################### -# ppchcp table # +# ppchcp table # #################### - {attr_name => username, - only_if => 'nodetype=ivm', - tabentry => 'ppchcp.username', - access_tabentry => 'ppchcp.hcp=attr:node', - description => 'The IVM userid used for hardware control.'}, - {attr_name => password, - only_if => 'nodetype=ivm', - tabentry => 'ppchcp.password', - access_tabentry => 'ppchcp.hcp=attr:node', - description => 'The IVM password used for hardware control.'}, - {attr_name => username, - only_if => 'nodetype=hmc', - tabentry => 'ppchcp.username', - access_tabentry => 'ppchcp.hcp=attr:node', - description => 'The HMC userid used for hardware control.'}, - {attr_name => password, - only_if => 'nodetype=hmc', - tabentry => 'ppchcp.password', - access_tabentry => 'ppchcp.hcp=attr:node', - description => 'The HMC password used for hardware control.'}, + {attr_name => username, + only_if => 'nodetype=ivm', + tabentry => 'ppchcp.username', + access_tabentry => 'ppchcp.hcp=attr:node', + }, + {attr_name => password, + only_if => 'nodetype=ivm', + tabentry => 'ppchcp.password', + access_tabentry => 'ppchcp.hcp=attr:node', + }, + {attr_name => username, + only_if => 'nodetype=hmc', + tabentry => 'ppchcp.username', + access_tabentry => 'ppchcp.hcp=attr:node', + }, + {attr_name => password, + only_if => 'nodetype=hmc', + tabentry => 'ppchcp.password', + access_tabentry => 'ppchcp.hcp=attr:node', + }, #################### -# ppc table # +# ppc table # #################### {attr_name => hcp, only_if => 'mgt=hmc', tabentry => 'ppc.hcp', access_tabentry => 'ppc.node=attr:node', - description => 'The host name or IP address of HMC that is the hardware control point for this node.'}, + }, {attr_name => hcp, only_if => 'mgt=ivm', tabentry => 'ppc.hcp', access_tabentry => 'ppc.node=attr:node', - description => 'The host name or IP address of IVM that is the hardware control point for this node.'}, + }, {attr_name => id, only_if => 'mgt=hmc', tabentry => 'ppc.id', access_tabentry => 'ppc.node=attr:node', - description => 'For LPARs: the LPAR numeric id; for FSPs: the cage number; for BPAs: the frame number.'}, + }, {attr_name => id, only_if => 'mgt=ivm', tabentry => 'ppc.id', access_tabentry => 'ppc.node=attr:node', - description => 'For LPARs: the LPAR numeric id; for FSPs: the cage number; for BPAs: the frame number.'}, - {attr_name => profile, - only_if => 'nodetype=lpar', - tabentry => 'ppc.profile', - access_tabentry => 'ppc.node=attr:node', - description => 'The LPAR profile that will be used the next time the LPAR is powered on with rpower.'}, - {attr_name => parent, - only_if => 'mgt=hmc', - tabentry => 'ppc.parent', - access_tabentry => 'ppc.node=attr:node', - description => 'For LPARs: the FSP/CEC; for FSPs: the BPA (if one exists)'}, - {attr_name => parent, - only_if => 'mgt=ivm', - tabentry => 'ppc.parent', - access_tabentry => 'ppc.node=attr:node', - description => 'For LPARs: the FSP/CEC; for FSPs: the BPA (if one exists)'}, + }, + {attr_name => profile, + only_if => 'nodetype=lpar', + tabentry => 'ppc.profile', + access_tabentry => 'ppc.node=attr:node', + }, + {attr_name => parent, + only_if => 'mgt=hmc', + tabentry => 'ppc.parent', + access_tabentry => 'ppc.node=attr:node', + }, + {attr_name => parent, + only_if => 'mgt=ivm', + tabentry => 'ppc.parent', + access_tabentry => 'ppc.node=attr:node', + }, ####################### -# ppcdirect table # +# ppcdirect table # ####################### {attr_name => username, only_if => 'mgt=fsp', tabentry => 'ppcdirect.username', access_tabentry => 'ppcdirect.hcp=attr:node', - description => 'The FSP userid used for hardware control.'}, + }, {attr_name => password, only_if => 'mgt=fsp', tabentry => 'ppcdirect.password', access_tabentry => 'ppcdirect.hcp=attr:node', - description => 'The FSP password used for hardware control.'}, + }, ################## -# ipmi table # +# ipmi table # ################## {attr_name => bmc, only_if => 'mgt=ipmi', tabentry => 'ipmi.bmc', access_tabentry => 'ipmi.node=attr:node', - description => 'The BMC IP address used for hardware control.'}, + }, {attr_name => bmcusername, only_if => 'mgt=ipmi', tabentry => 'ipmi.username', access_tabentry => 'ipmi.node=attr:node', - description => 'The BMC userid used for hardware control.'}, + }, {attr_name => bmcpassword, only_if => 'mgt=ipmi', tabentry => 'ipmi.password', access_tabentry => 'ipmi.node=attr:node', - description => 'The BMC password used for hardware control.'}, + }, ################ -# mp table # +# mp table # ################ {attr_name => mpa, only_if => 'mgt=blade', tabentry => 'mp.mpa', access_tabentry => 'mp.node=attr:node', - description => 'The managment module used for hardware control.'}, + }, {attr_name => id, only_if => 'mgt=blade', tabentry => 'mp.id', access_tabentry => 'mp.node=attr:node', - description => 'The slot id in the managment module used for hardware control.'}, + }, ################# -# mpa table # +# mpa table # ################# {attr_name => username, only_if => 'nodetype=mm', tabentry => 'mpa.username', access_tabentry => 'mpa.mpa=attr:node', - description => 'The managment module userid.'}, + }, {attr_name => password, only_if => 'nodetype=mm', tabentry => 'mpa.password', access_tabentry => 'mpa.mpa=attr:node', - description => 'The managment module password.'}, + }, ###################### -# nodepos table # +# nodepos table # ###################### {attr_name => 'rack', tabentry => 'nodepos.rack', access_tabentry => 'nodepos.node=attr:node', - description => 'Physical location information (customer use only).'}, + }, {attr_name => 'unit', tabentry => 'nodepos.u', access_tabentry => 'nodepos.node=attr:node', - description => 'Physical location information (customer use only).'}, + }, {attr_name => 'chassis', tabentry => 'nodepos.chassis', access_tabentry => 'nodepos.node=attr:node', - description => 'Physical location information (customer use only).'}, + }, {attr_name => 'slot', tabentry => 'nodepos.slot', access_tabentry => 'nodepos.node=attr:node', - description => 'Physical location information (customer use only).'}, + }, {attr_name => 'room', tabentry => 'nodepos.room', access_tabentry => 'nodepos.node=attr:node', - description => 'Physical location information (customer use only).'}); + }); #################### @@ -570,11 +836,11 @@ my @nodeattrs = ( {attr_name => 'node', tabentry => 'nodelist.node', access_tabentry => 'nodelist.node=attr:node', - description => 'The name of this node definition .'}, + }, {attr_name => 'nodetype', tabentry => 'nodelist.nodetype', access_tabentry => 'nodelist.node=attr:node', - description => 'Specifies a comma-separated list of node type values. (Valid values: osi, hmc, fsp, blade, vm, lpar, ivm, bpa, mm, rsa, switch)'}, + }, ### # TODO: need to implement nodelist.nodetype as a comma-separated list. # right now, all references to attr:nodetype are for single values. @@ -583,37 +849,36 @@ my @nodeattrs = ( {attr_name => 'groups', tabentry => 'nodelist.groups', access_tabentry => 'nodelist.node=attr:node', - description => 'Comma separated list of groups this node belongs to.'}, + }, {attr_name => 'status', tabentry => 'nodelist.status', access_tabentry => 'nodelist.node=attr:node', - description => 'Current status of the node. Default value is "defined". Valid values include defined, booting, installing, active, off etc.'}, + }, #################### # hosts table # #################### {attr_name => 'ip', tabentry => 'hosts.ip', access_tabentry => 'hosts.node=attr:node', - description => 'The IP address for this node.'}, + }, {attr_name => 'hostnames', tabentry => 'hosts.hostnames', access_tabentry => 'hosts.node=attr:node', - description => 'Hostname aliases added to /etc/hosts for this no -de.'}, + }, {attr_name => 'usercomment', tabentry => 'nodelist.comments', access_tabentry => 'nodelist.node=attr:node', - description => 'User comment.'}, - ); + }, + ); # add on the node attrs from other tables push(@{$defspec{node}->{'attrs'}}, @nodeattrs); - + ######################### # osimage data object # ######################### -# osimage table # +# osimage table # ######################### ### # TODO: The osimage table is currently not used by any xCAT code. @@ -624,38 +889,38 @@ push(@{$defspec{node}->{'attrs'}}, @nodeattrs); tabentry => 'osimage.imagename', access_tabentry => 'osimage.imagename=attr:imagename', # description => 'The name of this operating system image.'}, - description => '??? Currently not used by xCAT. ???'}, + }, {attr_name => 'osdistro', tabentry => 'osimage.osdistro', access_tabentry => 'osimage.imagename=attr:imagename', # description => 'The Linux distribution name to be deployed. The valid values are RedHat, and SLES.'}, - description => '??? Currently not used by xCAT. ???'}, + }, {attr_name => 'osname', tabentry => 'osimage.osname', access_tabentry => 'osimage.imagename=attr:imagename', # description => 'The name of the operating system to be deployed. The expected values are AIX or Linux.'}, - description => '??? Currently not used by xCAT. ???'}, + }, {attr_name => 'osvers', tabentry => 'osimage.osvers', access_tabentry => 'osimage.imagename=attr:imagename', # description => 'The operating system version to be deployed. The formats for the values are "version.release.mod" for AIX and "version" for Linux. (ex. AIX: "5.3.0", Linux: "5").'}, - description => '??? Currently not used by xCAT. ???'}, + }, {attr_name => 'osarch', tabentry => 'osimage.osarch', access_tabentry => 'osimage.imagename=attr:imagename', # description => 'The node machine architecture.'}, - description => '??? Currently not used by xCAT. ???'}, + }, {attr_name => 'usercomment', tabentry => 'osimage.comments', access_tabentry => 'osimage.imagename=attr:imagename', # description => 'User comment.'}, - description => '??? Currently not used by xCAT. ???'}, + }, ); - + ######################### # network data object # ######################### -# networks table # +# networks table # ######################### @{$defspec{network}->{'attrs'}} = ( ### @@ -665,45 +930,45 @@ push(@{$defspec{node}->{'attrs'}}, @nodeattrs); {attr_name => 'netname', tabentry => 'networks.netname', access_tabentry => 'networks.netname=attr:netname', - description => 'Name used to identify this network definition.'}, + }, {attr_name => 'net', tabentry => 'networks.net', access_tabentry => 'networks.netname=attr:netname', - description => 'The network address.'}, + }, {attr_name => 'mask', tabentry => 'networks.mask', access_tabentry => 'networks.netname=attr:netname', - description => 'The network mask.'}, + }, {attr_name => 'gateway', tabentry => 'networks.gateway', access_tabentry => 'networks.netname=attr:netname', - description => 'Specifies the hostname or IP address of the network gateway.'}, + }, {attr_name => 'dhcpserver', tabentry => 'networks.dhcpserver', access_tabentry => 'networks.netname=attr:netname', - description => 'The DHCP server that is servicing this network.'}, + }, {attr_name => 'tftpserver', tabentry => 'networks.tftpserver', access_tabentry => 'networks.netname=attr:netname', - description => 'The TFTP server that is servicing this network.'}, + }, {attr_name => 'nameservers', tabentry => 'networks.nameservers', access_tabentry => 'networks.netname=attr:netname', - description => 'The nameservers for this network. Used in creating the DHCP network definition.'}, + }, {attr_name => 'dynamicrange', tabentry => 'networks.dynamicrange', access_tabentry => 'networks.netname=attr:netname', - description => 'The IP address range used by DHCP to assign dynamic IP addresses for requests on this network.'}, + }, {attr_name => 'usercomment', tabentry => 'networks.comments', access_tabentry => 'networks.netname=attr:netname', - description => 'User comment.'}, + }, ); ##################### # site data object # ##################### -# site table # +# site table # ##################### ############## # TODO: need to figure out how to handle a key for the site table. @@ -766,29 +1031,29 @@ push(@{$defspec{node}->{'attrs'}}, @nodeattrs); ####################### # groups data object # ####################### -# groups table # +# groups table # ####################### @{$defspec{group}->{'attrs'}} = ( {attr_name => 'groupname', tabentry => 'nodegroup.groupname', access_tabentry => 'nodegroup.groupname=attr:groupname', - description => 'The name of this xCAT group object definition.'}, + }, {attr_name => 'grouptype', tabentry => 'nodegroup.grouptype', access_tabentry => 'nodegroup.groupname=attr:groupname', - description => 'The type of xCAT group - either static or dynamic.'}, + }, {attr_name => 'members', tabentry => 'nodegroup.members', access_tabentry => 'nodegroup.groupname=attr:groupname', - description => 'The list of members for this group.'}, + }, {attr_name => 'wherevals', tabentry => 'nodegroup.wherevals', access_tabentry => 'nodegroup.groupname=attr:groupname', - description => 'A list of comma-separated "attr=val" pairs that can be used to determine the members of a dynamic group.'}, + }, {attr_name => 'usercomment', tabentry => 'nodegroup.comments', access_tabentry => 'nodegroup.groupname=attr:groupname', - description => 'User comment.'}, + }, ### # TODO: Need to copy attrs that are common between nodes and static groups @@ -803,94 +1068,94 @@ push(@{$defspec{group}->{'attrs'}}, @nodeattrs); ####################### # policy data object # ####################### -# policy table # +# policy table # ####################### @{$defspec{policy}->{'attrs'}} = ( ### # TODO: The policy validate subroutine in the xcatd daemon code does not -# sort the rules in the policy table in priority order before +# sort the rules in the policy table in priority order before # processing. Talk to Jarrod - I think it should. ### {attr_name => 'priority', tabentry => 'policy.priority', access_tabentry => 'policy.priority=attr:priority', - description => 'The priority value for this rule. This value is used to identify this policy data object (i.e. this rule). ??? Priorities have not been implemented in the xCAT rule processing yet ???.'}, + }, {attr_name => 'name', tabentry => 'policy.name', access_tabentry => 'policy.priority=attr:priority', - description => 'The username that is allowed to perform the commands specified by this rule. Default is "*" (all users).'}, + }, {attr_name => 'host', tabentry => 'policy.host', access_tabentry => 'policy.priority=attr:priority', - description => 'The host from which users may issue the commands specified by this rule. Default is "*" (all hosts).'}, + }, {attr_name => 'commands', tabentry => 'policy.commands', access_tabentry => 'policy.priority=attr:priority', - description => 'The list of commands that this rule applies to. Default is "*" (all commands). ??? Command lists not implemented yet - only "*" or single command works ???.'}, + }, {attr_name => 'noderange', tabentry => 'policy.noderange', access_tabentry => 'policy.priority=attr:priority', - description => 'Noderange that this rule applies to. ??? Not implemented yet ???.'}, + }, {attr_name => 'parameters', tabentry => 'policy.parameters', access_tabentry => 'policy.priority=attr:priority', - description => 'Command parameters that this rule applies to. ??? Not implemented yet ???.'}, + }, {attr_name => 'time', tabentry => 'policy.time', access_tabentry => 'policy.priority=attr:priority', - description => 'Time ranges that this command may be executed in. ??? Not implemented yet ???.'}, + }, {attr_name => 'rule', tabentry => 'policy.rule', access_tabentry => 'policy.priority=attr:priority' , - description=> 'Specifies how this rule should be applied. Valid values are: allow, accept. Either of these values will allow the user to run the commands. Any other value will deny the user access to the commands.'}, + }, {attr_name => 'usercomment', tabentry => 'policy.comments', access_tabentry => 'policy.priority=attr:priority', - description => 'User comment.'}, + }, ); ############################# # notification data object # ############################# -# notification table # +# notification table # ############################# @{$defspec{notification}->{'attrs'}} = ( {attr_name => 'filename', tabentry => 'notification.filename', access_tabentry => 'notification.filename=attr:filename', - description => 'Specifies a file that implements the callback routine when the monitored table changes.'}, + }, {attr_name => 'tables', tabentry => 'notification.tables', access_tabentry => 'notification.filename=attr:filename', - description => 'The name of the xCAT database table to monitor.'}, + }, {attr_name => 'tableops', tabentry => 'notification.tableops', access_tabentry => 'notification.filename=attr:filename', - description => 'Specifies the table operation to monitor. It can be "d" for rows deleted, "a" for rows added or "u" for rows updated.'}, + }, {attr_name => 'comments', tabentry => 'notification.comments', access_tabentry => 'notification.filename=attr:filename', - description => 'User comment.'}, + }, ); - + ########################### # monitoring data object # ########################### -# monitoring table # +# monitoring table # ########################### @{$defspec{monitoring}->{'attrs'}} = ( {attr_name => 'name', tabentry => 'monitoring.name', access_tabentry => 'monitoring.name=attr:name', - description => 'The name of the mornitoring plug-in module.'}, + }, {attr_name => 'nodestatmon', tabentry => 'monitoring.nodestatmon', access_tabentry => 'monitoring.name=attr:name', - description => 'Specifies if the monitoring plug-in is used to feed the node status to the xCAT cluster. Any one of the following values indicates "yes": y, Y, yes, Yes, YES, 1. Any other value or blank (default), indicates "no". '}, + }, {attr_name => 'comments', tabentry => 'monitoring.comments', access_tabentry => 'monitoring.name=attr:name', - description => 'User comment.'}, + }, ); # Build a corresponding hash for the attribute names to make diff --git a/perl-xCAT-2.0/xCAT/Table.pm b/perl-xCAT-2.0/xCAT/Table.pm index 95d17e238..f85e6af24 100644 --- a/perl-xCAT-2.0/xCAT/Table.pm +++ b/perl-xCAT-2.0/xCAT/Table.pm @@ -26,7 +26,7 @@ use xCAT::NotifHandler; #-------------------------------------------------------------------------------- -=head1 xCAT::Table +=head1 xCAT::Table xCAT::Table - Perl module for xCAT configuration access @@ -68,13 +68,13 @@ xCAT::Table is released under an IBM license.... #-------------------------------------------------------------------------- -=head2 Subroutines +=head2 Subroutines =cut #-------------------------------------------------------------------------- -=head3 buildcreatestmt +=head3 buildcreatestmt Description: Build create table statement ( see new) @@ -82,13 +82,13 @@ xCAT::Table is released under an IBM license.... Table name Table schema ( hash of column names) Returns: - Table creation SQL + Table creation SQL Globals: - + Error: - + Example: - + my $str = buildcreatestmt($self->{tabname}, $xCAT::Schema::tabspec{$self->{tabname}}); @@ -123,10 +123,10 @@ sub buildcreatestmt #-------------------------------------------------------------------------- -=head3 new +=head3 new Description: Constructor: Connects to or Creates Database Table - + Arguments: Table name 0 = Connect to table @@ -134,11 +134,11 @@ sub buildcreatestmt Returns: Hash: Database Handle, Statement Handle, nodelist Globals: - + Error: - + Example: - $nodelisttab = xCAT::Table->new("nodelist"); + $nodelisttab = xCAT::Table->new("nodelist"); Comments: none @@ -157,6 +157,7 @@ sub new unless (defined($xCAT::Schema::tabspec{$self->{tabname}})) { return undef; } $self->{schema} = $xCAT::Schema::tabspec{$self->{tabname}}; $self->{colnames} = \@{$self->{schema}->{cols}}; + $self->{descriptions} = \%{$self->{schema}->{descriptions}}; my %otherargs = @_; my $create = $otherargs{'-create'}; #(scalar(@_) == 1 ? shift : 0); $self->{autocommit} = $otherargs{'-autocommit'}; @@ -216,7 +217,7 @@ sub new #return undef; } unless ($::XCAT_DBHS->{$self->{connstring},$self->{dbuser},$self->{dbpass},$self->{autocommit}}) { #= $self->{tabname}; - $::XCAT_DBHS->{$self->{connstring},$self->{dbuser},$self->{dbpass},$self->{autocommit}} = + $::XCAT_DBHS->{$self->{connstring},$self->{dbuser},$self->{dbpass},$self->{autocommit}} = DBI->connect($self->{connstring}, $self->{dbuser}, $self->{dbpass}, {AutoCommit => $self->{autocommit}}); } @@ -280,7 +281,7 @@ sub new } } - + updateschema($self); if ($self->{tabname} eq 'nodelist') { @@ -296,23 +297,23 @@ sub new #-------------------------------------------------------------------------- -=head3 updateschema +=head3 updateschema Description: Alters table schema Arguments: Hash containing Database and Table Handle and schema - + Returns: None - + Globals: - + Error: - + Example: $self->{tabname} = shift; $self->{schema} = $xCAT::Schema::tabspec{$self->{tabname}}; $self->{colnames} = \@{$self->{schema}->{cols}}; - updateschema($self); + updateschema($self); Comments: none @@ -384,11 +385,11 @@ sub updateschema Node name Attribute hash Returns: - + Globals: - + Error: - + Example: my $mactab = xCAT::Table->new('mac',-create=>1); $mactab->setNodeAttribs($node,{mac=>$mac}); @@ -414,15 +415,15 @@ sub setNodeAttribs Description: Add new attributes input to the routine to the nodes Arguments: - Hash of new attributes + Hash of new attributes Returns: - + Globals: - + Error: - + Example: - + Comments: none @@ -441,19 +442,19 @@ sub addNodeAttribs Description: add new attributes - Arguments: + Arguments: Hash: Database Handle, Statement Handle, nodelist Key name Key value Hash reference of column-value pairs to set Returns: - + Globals: - + Error: - + Example: - + Comments: none @@ -513,22 +514,22 @@ sub addAttribs #-------------------------------------------------------------------------- -=head3 rollback +=head3 rollback Description: rollback changes Arguments: Database Handle Returns: - none + none Globals: - + Error: - + Example: my $tab = xCAT::Table->new($table,-create =>1,-autocommit=>0); - $tab->rollback(); + $tab->rollback(); Comments: none @@ -544,22 +545,22 @@ sub rollback #-------------------------------------------------------------------------- -=head3 commit +=head3 commit Description: Commit changes Arguments: Database Handle Returns: - none + none Globals: - + Error: - + Example: my $tab = xCAT::Table->new($table,-create =>1,-autocommit=>0); - $tab->commit(); - + $tab->commit(); + Comments: none @@ -574,7 +575,7 @@ sub commit #-------------------------------------------------------------------------- -=head3 setAttribs +=head3 setAttribs Description: @@ -584,11 +585,11 @@ sub commit Hash reference of column-value pairs to set Returns: - None + None Globals: - + Error: - + Example: my $tab = xCAT::Table->new( 'ppc', -create=>1, -autocommit=>0 ); $keyhash{'node'} = $name; @@ -758,7 +759,7 @@ sub setAttribs #-------------------------------------------------------------------------- -=head3 setAttribsWhere +=head3 setAttribsWhere Description: This function sets the attributes for the rows selected by the where clause. @@ -766,9 +767,9 @@ sub setAttribs Where clause. Hash reference of column-value pairs to set Returns: - None - Globals: - Error: + None + Globals: + Error: Example: my $tab = xCAT::Table->new( 'ppc', -create=>1, -autocommit=>1 ); $updates{'type'} = lc($type); @@ -859,24 +860,24 @@ sub setAttribsWhere #-------------------------------------------------------------------------- -=head3 getNodeAttribs +=head3 getNodeAttribs - Description: Retrieves the requested attribute + Description: Retrieves the requested attribute Arguments: Table handle Noderange - Attribute type array + Attribute type array Returns: - - Attribute hash ( key attribute type) + + Attribute hash ( key attribute type) Globals: - + Error: - + Example: my $ostab = xCAT::Table->new('nodetype'); - my $ent = $ostab->getNodeAttribs($node,['profile','os','arch']); + my $ent = $ostab->getNodeAttribs($node,['profile','os','arch']); Comments: none @@ -956,20 +957,20 @@ sub getNodeAttribs #-------------------------------------------------------------------------- -=head3 getNodeAttribs_nosub +=head3 getNodeAttribs_nosub Description: Arguments: - + Returns: - + Globals: - + Error: - + Example: - + Comments: none @@ -1016,20 +1017,20 @@ sub getNodeAttribs_nosub #-------------------------------------------------------------------------- -=head3 getNodeAttribs_nosub_returnany +=head3 getNodeAttribs_nosub_returnany Description: Arguments: - + Returns: - + Globals: - + Error: - + Example: - + Comments: none @@ -1080,23 +1081,23 @@ sub getNodeAttribs_nosub_returnany #-------------------------------------------------------------------------- -=head3 getAllEntries +=head3 getAllEntries Description: Read entire table Arguments: - Table handle + Table handle Returns: - Hash containing all rows in table + Hash containing all rows in table Globals: - + Error: - + Example: my $tabh = xCAT::Table->new($table); my $recs=$tabh->getAllEntries(); - + Comments: none @@ -1126,7 +1127,7 @@ sub getAllEntries #-------------------------------------------------------------------------- -=head3 getAllAttribsWhere +=head3 getAllAttribsWhere Description: Get all attributes with "where" clause @@ -1134,13 +1135,13 @@ sub getAllEntries Database Handle Where clause Returns: - Array of attributes + Array of attributes Globals: - + Error: - + Example: - $nodelist->getAllAttribsWhere("groups like '%".$atom."%'",'node','group'); + $nodelist->getAllAttribsWhere("groups like '%".$atom."%'",'node','group'); Comments: none @@ -1183,7 +1184,7 @@ sub getAllAttribsWhere #-------------------------------------------------------------------------- -=head3 getAllNodeAttribs +=head3 getAllNodeAttribs Description: Get all the node attributes values for the input table on the attribute list @@ -1194,9 +1195,9 @@ sub getAllAttribsWhere Returns: Array of attribute values Globals: - + Error: - + Example: my @entries = $self->{switchtab}->getAllNodeAttribs(['port','switch']); Comments: @@ -1259,7 +1260,7 @@ sub getAllNodeAttribs #-------------------------------------------------------------------------- -=head3 getAllAttribs +=head3 getAllAttribs Description: Returns a list of records in the input table for the input list of attributes. @@ -1270,9 +1271,9 @@ sub getAllNodeAttribs Returns: Array of attribute values Globals: - + Error: - + Example: $nodelisttab = xCAT::Table->new("nodelist"); my @attribs = ("node"); @@ -1316,7 +1317,7 @@ sub getAllAttribs #-------------------------------------------------------------------------- -=head3 delEntries +=head3 delEntries Description: Delete table entries @@ -1324,11 +1325,11 @@ sub getAllAttribs Table Handle Entry to delete Returns: - + Globals: - + Error: - + Example: my $table=xCAT::Table->new("notification", -create => 1,-autocommit => 0); my %key_col = (filename=>$fname); @@ -1408,7 +1409,7 @@ sub delEntries #-------------------------------------------------------------------------- -=head3 getAttribs +=head3 getAttribs Description: @@ -1416,11 +1417,11 @@ sub delEntries key List of attributes Returns: - Hash of requested attributes + Hash of requested attributes Globals: - + Error: - + Example: $table = xCAT::Table->new('passwd'); @tmp=$table->getAttribs({'key'=>'ipmi'},('username','password'); @@ -1497,7 +1498,7 @@ sub getAttribs #-------------------------------------------------------------------------- -=head3 getTable +=head3 getTable Description: Read entire Table @@ -1505,11 +1506,11 @@ sub getAttribs Table Handle Returns: - Array of table rows + Array of table rows Globals: - + Error: - + Example: my $table=xCAT::Table->new("notification", -create =>0); my @row_array= $table->getTable; @@ -1556,18 +1557,18 @@ sub getTable #-------------------------------------------------------------------------- -=head3 close +=head3 close Description: Close out Table transaction Arguments: - Table Handle + Table Handle Returns: - + Globals: - + Error: - + Example: my $mactab = xCAT::Table->new('mac'); $mactab->setNodeAttribs($macmap{$mac},{mac=>$mac}); @@ -1592,20 +1593,20 @@ sub close #-------------------------------------------------------------------------- -=head3 open +=head3 open Description: Connect to Database Arguments: - Empty Hash + Empty Hash Returns: - Data Base Handle + Data Base Handle Globals: - + Error: - + Example: - + Comments: none @@ -1620,20 +1621,20 @@ sub open #-------------------------------------------------------------------------- -=head3 DESTROY +=head3 DESTROY Description: Disconnect from Database Arguments: - Database Handle + Database Handle Returns: - + Globals: - + Error: - + Example: - + Comments: none @@ -1649,5 +1650,33 @@ sub DESTROY undef $self->{nodelist}; #Could be circular } + +=head3 getTableList + Description: Returns a list of the table names in the xCAT database. +=cut +sub getTableList { return keys %xCAT::Schema::tabspec; } + + +=head3 getTableSchema + Description: Returns the db schema for the specified table. + Returns: A reference to a hash that contains the cols, keys, etc. for this table. (See Schema.pm for details.) +=cut +sub getTableSchema { return $xCAT::Schema::tabspec{$_[1]}; } + + +=head3 getTableList + Description: Returns a summary description for each table. + Returns: A reference to a hash. Each key is the table name. + Each value is the table description. +=cut +sub getDescriptions { + my $classname = shift; # we ignore this because this function is static + # List each table name and the value for table_desc. + my $ret = {}; + #my @a = keys %{$xCAT::Schema::tabspec{nodelist}}; print 'a=', @a, "\n"; + foreach my $t (keys %xCAT::Schema::tabspec) { $ret->{$t} = $xCAT::Schema::tabspec{$t}->{table_desc}; } + return $ret; +} + 1; diff --git a/xCAT-client-2.0/bin/xcatDBcmds b/xCAT-client-2.0/bin/xcatDBcmds index 96266962c..56ad1474e 100755 --- a/xCAT-client-2.0/bin/xcatDBcmds +++ b/xCAT-client-2.0/bin/xcatDBcmds @@ -8,7 +8,7 @@ use lib "$::XCATROOT/lib/perl"; use File::Basename; use xCAT::MsgUtils; -use xCAT::Client submit_request; +use xCAT::Client; my $bname = basename($0); @@ -25,7 +25,7 @@ my $bname = basename($0); # are, for the most part, in: # /opt/xcat/lib/perl/xCAT_plugin/DBobjectdefs.pm # /opt/xcat/lib/perl/xCAT_plugin/xcat2nim.pm -# /opt/xcat/lib/perl/xCAT/DBobjUtils.pm +# /opt/xcat/lib/perl/xCAT/DBobjUtils.pm # -on the xCAT management node # ######################################### diff --git a/xCAT-client-2.0/bin/xdsh b/xCAT-client-2.0/bin/xdsh index 09e095634..ff37f8788 100644 --- a/xCAT-client-2.0/bin/xdsh +++ b/xCAT-client-2.0/bin/xdsh @@ -1,5 +1,4 @@ -#!/usr/bin/perl -# !/usr/bin/env perl +#!/usr/bin/env perl # IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html BEGIN { diff --git a/xCAT-client-2.0/pods/man1/tabdump.1.pod b/xCAT-client-2.0/pods/man1/tabdump.1.pod index 1e717791f..720daf802 100644 --- a/xCAT-client-2.0/pods/man1/tabdump.1.pod +++ b/xCAT-client-2.0/pods/man1/tabdump.1.pod @@ -4,19 +4,21 @@ B - display a database table in csv format. =head1 SYNOPSIS -I +I I =head1 DESCRIPTION -The tabdump command displays the header and all the rows of the specified table in csv format. +The tabdump command displays the header and all the rows of the specified table in CSV (comma separated values) format. Only one table can be specified. If no table is specified, the list of existing tables will be displayed. =head1 OPTIONS -B<-?|-h|--help> Display usage message. +B<-?|-h|--help> Display usage message. + +B<-d> Show descriptions of the tables, instead of the contents of the tables. If a table name is also specified, descriptions of the columns (attributes) of the table will be displayed. Otherwise, a summary of each table will be displayed. =head1 RETURN VALUE @@ -34,11 +36,19 @@ B<-?|-h|--help> Display usage message. tabdump -3. To see what tables exist in the xCAT database: +3. To back up all the xCAT database tables: mkdir -p /tmp/xcatdb.backup for i in `tabdump`;do echo "Dumping $i..."; tabdump $i > /tmp/xcatdb.backup/$i.csv; done +4. To display a summary description of each table: + + tabdump -d + +5. To display a description of each column in the nodehm table: + + tabdump -d nodehm + =head1 FILES /opt/xcat/sbin/tabdump diff --git a/xCAT-client-2.0/share/man/man1/tabdump.1 b/xCAT-client-2.0/share/man/man1/tabdump.1 index 1bc04be8f..39d8620e7 100644 --- a/xCAT-client-2.0/share/man/man1/tabdump.1 +++ b/xCAT-client-2.0/share/man/man1/tabdump.1 @@ -129,22 +129,24 @@ .\" ======================================================================== .\" .IX Title "TABDUMP.1 1" -.TH TABDUMP.1 1 "2008-02-18" "perl v5.8.8" "User Contributed Perl Documentation" +.TH TABDUMP.1 1 "2008-02-20" "perl v5.8.8" "User Contributed Perl Documentation" .SH "NAME" \&\fBtabdump\fR \- display a database table in csv format. .SH "SYNOPSIS" .IX Header "SYNOPSIS" -\&\fItabdump [table]\fR +\&\fItabdump [\-d] [table]\fR .PP \&\fItabdump [? | \-h | \-\-help]\fR .SH "DESCRIPTION" .IX Header "DESCRIPTION" -The tabdump command displays the header and all the rows of the specified table in csv format. +The tabdump command displays the header and all the rows of the specified table in \s-1CSV\s0 (comma separated values) format. Only one table can be specified. If no table is specified, the list of existing tables will be displayed. .SH "OPTIONS" .IX Header "OPTIONS" -\&\fB\-?|\-h|\-\-help\fR Display usage message. +\&\fB\-?|\-h|\-\-help\fR Display usage message. +.PP +\&\fB\-d\fR Show descriptions of the tables, instead of the contents of the tables. If a table name is also specified, descriptions of the columns (attributes) of the table will be displayed. Otherwise, a summary of each table will be displayed. .SH "RETURN VALUE" .IX Header "RETURN VALUE" 0 The command completed successfully. @@ -164,12 +166,24 @@ tables will be displayed. \& tabdump .Ve .PP -3. To see what tables exist in the xCAT database: +3. To back up all the xCAT database tables: .PP .Vb 2 \& mkdir -p /tmp/xcatdb.backup \& for i in `tabdump`;do echo "Dumping $i..."; tabdump $i > /tmp/xcatdb.backup/$i.csv; done .Ve +.PP +4. To display a summary description of each table: +.PP +.Vb 1 +\& tabdump -d +.Ve +.PP +5. To display a description of each column in the nodehm table: +.PP +.Vb 1 +\& tabdump -d nodehm +.Ve .SH "FILES" .IX Header "FILES" /opt/xcat/sbin/tabdump diff --git a/xCAT-server-2.0/lib/xcat/plugins/DBobjectdefs.pm b/xCAT-server-2.0/lib/xcat/plugins/DBobjectdefs.pm index 87a0816ef..5367ba972 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/DBobjectdefs.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/DBobjectdefs.pm @@ -52,7 +52,7 @@ $Getopt::Long::ignorecase = 0; =head1 DBobjectdefs -This program module file supports the management of the xCAT data object +This program module file supports the management of the xCAT data object definitions. Supported xCAT data object commands: @@ -108,12 +108,12 @@ sub handled_commands Check for xCAT command and call the appropriate subroutine. Arguments: - + Returns: 0 - OK 1 - error Globals: - + Error: Example: @@ -179,7 +179,7 @@ sub process_request 1 - just print usage 2 - error Globals: - + Error: Example: @@ -194,7 +194,7 @@ sub processArgs my $gotattrs = 0; @ARGV = @{$::args}; - + if (scalar(@ARGV) <= 0) { return 2; } @@ -426,8 +426,7 @@ sub processArgs } my $rsp; - $rsp->{data}->[0] = - "\nThe valid attribute names for object type \'$t\' are:\n\n"; + $rsp->{data}->[0] = "The valid attribute names for object type '$t' are:\n"; # get the data type definition from Schema.pm my $datatype = $xCAT::Schema::defspec{$t}; @@ -444,20 +443,27 @@ sub processArgs { my $attr = $this_attr->{attr_name}; my $desc = $this_attr->{description}; + if (!defined($desc)) { # description key not there, so go to the corresponding entry in tabspec to get the description + my ($tab, $at) = split(/\./, $this_attr->{tabentry}); + my $schema = xCAT::Table->getTableSchema($tab); + $desc = $schema->{descriptions}->{$at}; + } - # could display the table that the attr is in + # could display the table that the attr is in # however some attrs are in more than one table!!! - my ($tab, $junk) = split('\.', $this_attr->{tabentry}); + #my ($tab, $junk) = split('\.', $this_attr->{tabentry}); if (!grep(/^$attr$/, @alreadydone)) - { + { # $outstr .= "$attr\n\t\t- $desc \n\t\t(Table: $tab)\n\n"; - $outstr .= "$attr\n\t\t- $desc\n\n"; - + #$outstr .= "$attr\n\t\t- $desc\n\n"; + my $space = (length($attr)<7 ? "\t\t" : "\t"); + $outstr .= "$attr:$space$desc\n\n"; } push(@alreadydone, $attr); } - + + chop($outstr); chop($outstr); $rsp->{data}->[2] = $outstr; xCAT::MsgUtils->message("I", $rsp, $::callback); } @@ -479,10 +485,10 @@ sub processArgs if (($::opt_t eq 'site') && ($::opt_o ne 'clustersite')) { push(@::clobjnames, 'clustersite'); - my $rsp; + my $rsp; $rsp->{data}->[0] ="Only one site definition is supported."; $rsp->{data}->[1] = "Setting the name of the site definition to \'clustersite\'.\n"; - xCAT::MsgUtils->message("I", $rsp, $::callback); + xCAT::MsgUtils->message("I", $rsp, $::callback); } elsif ($::opt_t eq 'node') @@ -515,7 +521,7 @@ sub processArgs # special case for site table!!!!!!!!!!!!!! if (($::opt_t eq 'site') && !$::opt_o) { - my $rsp; + my $rsp; $rsp->{data}->[0] ="Setting the name of the site definition to \'clustersite\'."; xCAT::MsgUtils->message("I", $rsp, $::callback); push(@::clobjnames, 'clustersite'); @@ -700,7 +706,7 @@ sub processArgs Example: Comments: - Object names to create are derived from + Object names to create are derived from -o, -t, w, -z, -x, or noderange! Attr=val pairs come from cmd line args or -z/-x files =cut @@ -1147,7 +1153,7 @@ sub defmk Example: Comments: - Object names to create are derived from + Object names to create are derived from -o, -t, w, -z, -x, or noderange! Attr=val pairs come from cmd line args or -z/-x files =cut @@ -1878,7 +1884,7 @@ sub setFINALattrs Object names derived from -o, -t, w, -a or noderange! List of attrs to display is given by -i. Output goes to standard out or a stanza/xml file (-z or -x) - + =cut #----------------------------------------------------------------------------- @@ -2442,7 +2448,7 @@ sub defls 0 - OK 1 - error Globals: - + Error: Example: diff --git a/xCAT-server-2.0/lib/xcat/plugins/tabutils.pm b/xCAT-server-2.0/lib/xcat/plugins/tabutils.pm index bcb18cccc..8d86fa5ca 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/tabutils.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/tabutils.pm @@ -345,11 +345,12 @@ sub tabdump my $cb = shift; my $table = ""; my $HELP; + my $DESC; sub tabdump_usage { my $exitcode = shift @_; my %rsp; - push @{$rsp{data}}, "Usage: tabdump [table]"; + push @{$rsp{data}}, "Usage: tabdump [-d] [table]"; push @{$rsp{data}}, " tabdump [-?|-h|--help]"; if ($exitcode) { $rsp{errorcode} = $exitcode; } $cb->(\%rsp); @@ -357,7 +358,7 @@ sub tabdump # Process arguments @ARGV = @{$args}; - if (!GetOptions('h|?|help' => \$HELP)) { tabdump_usage(1); return; } + if (!GetOptions('h|?|help' => \$HELP, 'd' => \$DESC)) { tabdump_usage(1); return; } if ($HELP) { tabdump_usage(0); return; } if (scalar(@ARGV)>1) { tabdump_usage(1); return; } @@ -365,12 +366,35 @@ sub tabdump my %rsp; # If no arguments given, we display a list of the tables if (!scalar(@ARGV)) { - push @{$rsp{data}}, keys %xCAT::Schema::tabspec; + if ($DESC) { # display the description of each table + my $tab = xCAT::Table->getDescriptions(); + foreach my $key (keys %$tab) { + my $space = (length($key)<7 ? "\t\t" : "\t"); + push @{$rsp{data}}, "$key:$space".$tab->{$key}."\n"; + } + } + else { push @{$rsp{data}}, xCAT::Table->getTableList(); } # if no descriptions, just display the list of table names + @{$rsp{data}} = sort @{$rsp{data}}; + if ($DESC && scalar(@{$rsp{data}})) { chop($rsp{data}->[scalar(@{$rsp{data}})-1]); } # remove the final newline $cb->(\%rsp); return; } $table = $ARGV[0]; + if ($DESC) { # only show the attribute descriptions, not the values + my $schema = xCAT::Table->getTableSchema($table); + if (!$schema) { $cb->({error => "table $table does not exist.",errorcode=>1}); return; } + my $desc = $schema->{descriptions}; + foreach my $c (@{$schema->{cols}}) { + my $space = (length($c)<7 ? "\t\t" : "\t"); + push @{$rsp{data}}, "$c:$space".$desc->{$c}."\n"; + } + if (scalar(@{$rsp{data}})) { chop($rsp{data}->[scalar(@{$rsp{data}})-1]); } # remove the final newline + $cb->(\%rsp); + return; + } + + my $tabh = xCAT::Table->new($table); sub tabdump_header {