From e51e155ae37e46d327d94f07b573b51bfb5a1f0e Mon Sep 17 00:00:00 2001 From: chenglch Date: Thu, 3 Dec 2015 02:15:04 -0500 Subject: [PATCH 001/310] :Add cluster maintenance doc --- .../compute_node/changing_hostname_ip.rst | 76 +++++ .../advanced/cluster_maintenance/index.rst | 1 + .../mgmt_node/changing_hostname_ip.rst | 271 +++++++++++++++++- .../service_node/changing_hostname_ip.rst | 60 ++++ .../service_node/index.rst | 7 + .../hierarchy/databases/mysql_configure.rst | 2 + 6 files changed, 416 insertions(+), 1 deletion(-) create mode 100644 docs/source/advanced/cluster_maintenance/service_node/changing_hostname_ip.rst create mode 100644 docs/source/advanced/cluster_maintenance/service_node/index.rst diff --git a/docs/source/advanced/cluster_maintenance/compute_node/changing_hostname_ip.rst b/docs/source/advanced/cluster_maintenance/compute_node/changing_hostname_ip.rst index 04ea388d7..2b7ef02b2 100644 --- a/docs/source/advanced/cluster_maintenance/compute_node/changing_hostname_ip.rst +++ b/docs/source/advanced/cluster_maintenance/compute_node/changing_hostname_ip.rst @@ -1,2 +1,78 @@ Changing the hostname/IP address ================================ + +Background +---------- + +If the hostname or ip address has already been modified on compute nodes, you +can follow the steps to change the configuration in xcat. + +Remove Old Provision Environment +-------------------------------- + +#. Remove the nodes from DNS configuration :: + + makedns -d + +#. Remove the nodes from the DHCP configuration :: + + makedhcp -d + +#. Remove the nodes from the conserver configuration :: + + makeconservercf -d + +Change Definition +----------------- + +#. Change netwoks table definitions :: + + lsdef -t network -l + + The output may be like :: + + 10_0_0_0-255_0_0_0 (network) + fd03:2e76:8631::/64 (network) + + Change the networks table definitions, take ``10_0_0_0-255_0_0_0`` as a example :: + + chdef -t network 10_0_0_0-255_0_0_0 gateway=10.0.0.103 + +#. Change the hostname in the xCAT database (This command only supports one node + at a time). For many nodes you will have to write a script. :: + + # changes node1 to node2 in the database + chdef -t node -o node1 -n node2 + +#. Change the hostname and ip address in the ``/etc/hosts`` file + + - If you do not use the hosts table in xCAT to create the ``/etc/hosts`` file, + edit the ``/etc/hosts`` file and change your hostnames/ipaddresses entries + directly. + - If you use the xCAT hosts table, and your nodes are defined by name in the + hosts table, the hosts table must be updated with the new names when + we changed the node name using chdef command. If the hosts tables contains + regular expression, you have to rewrite the regular expression to + match your new hostnames/ip addresses. + - If these is no regular expression in the hosts table, you can run :: + + # change the ip address for the new hostname in the hosts table. + nodech hosts.ip="x.xx.xx.xx" + # add host/ip records in /etc/hosts from the definition in the xCAT hosts + # table for the + makehosts + +Update The Provision Environment +-------------------------------- + +#. Configure the new names in DNS :: + + makedns -n + +#. Configure the new names in DHCP :: + + makedhcp -a + +#. Configure the new names in conserver :: + + makeconservercf diff --git a/docs/source/advanced/cluster_maintenance/index.rst b/docs/source/advanced/cluster_maintenance/index.rst index 6419d475e..e4fcb7ff7 100644 --- a/docs/source/advanced/cluster_maintenance/index.rst +++ b/docs/source/advanced/cluster_maintenance/index.rst @@ -6,4 +6,5 @@ Cluster Maintenance compute_node/index.rst mgmt_node/index.rst + service_node/index.rst sw_fw_inventory.rst diff --git a/docs/source/advanced/cluster_maintenance/mgmt_node/changing_hostname_ip.rst b/docs/source/advanced/cluster_maintenance/mgmt_node/changing_hostname_ip.rst index 0716dc9e1..8d343e866 100644 --- a/docs/source/advanced/cluster_maintenance/mgmt_node/changing_hostname_ip.rst +++ b/docs/source/advanced/cluster_maintenance/mgmt_node/changing_hostname_ip.rst @@ -1,4 +1,273 @@ Changing the hostname/IP address ================================ -There may be times when it is required to change the hostname or IP address of the xCAT management nodes. This document helps to outline the steps required to ensure successfully changing this attribute on the management node. +Overview +-------- + +This document is intended to describe the steps that must be taken if you need +to change your Linux Management Node's hostname and/or IP address +after the cluster is installed and configured by xCAT. This documentation will +only cover the changes by xCAT and will not try to cover any other changes by +any other tools. + +Backup your xCAT data +--------------------- + +It is good to backup all your xCAT data at first if necessary. Clean up the +database by running the following: :: + + tabprune -a auditlog + tabprune -a eventlog + +Now take a snapshot of the Management Node. This will also create a database +backup. You can use this data as reference if needed. :: + + xcatsnap -d + +Stop xCAT +--------- + +You need to stop the xcat daemon and any other applications that are using the +xCAT database on the Management Node and the Service Nodes. To determine your +database, run :: + + lsxcatd -a | grep dbengine + +To stop xCAT: :: + + service xcatd stop + +Stop The Database +----------------- + +For all databases except SQlite, you should stop the database. +For example :: + + service postgresql stop + service mysqld stop + +Change the Management Host name +------------------------------- + +* hostname command :: + + hostname + +* Edit hostname configuration file + + Add hostname in ``/etc/hostname`` + Add HOSTNAME attribute in ``/etc/sysconfig/network`` (only for [RHEL]) + +Update Database Files +--------------------- + +You need to update the new MN hostname or ip address in several database +configuration files. + +SQLite +^^^^^^ + +Nothing to do. + +Postgresql +^^^^^^^^^^ + +- Edit ``/etc/xcat/cfgloc`` file, replace ``Pg:dbname=xcatdb;host=|xcatadm|xcat20`` + with ``Pg:dbname=xcatdb;host=|xcatadm|xcat20``. + +- Edit config database config file ``/var/lib/pgsql/data/pg_hba.conf``, + replace ``host all all /32 md5`` + with ``host all all /32 md5``. + +Mysql +^^^^^ + +Edit ``/etc/xcat/cfglooc``, replace ``mysql:dbname=xcatdb;host=|xcatadmin|xcat20`` +with ``mysql:dbname=xcatdb;host=|xcatadmin|xcat20``. + +Start the database +------------------ + +:: + + service postgresql start + service mysqld start + +Start xCAT + +:: + + service xcatd start + +Verify your new database setup :: + + lsxcatd -a | grep dbengine + tabdump site # if output exists + +Change The Definition In xCAT Database +-------------------------------------- + +Change the site table master attribute +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +:: + + chdef -t site master= + +Change all ip address attribute relevant to the MN ipaddress +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +For example, old address was "10.6.0.1" + +* Query the attributes with old address :: + + lsdef -t node -l | grep "10.6.0.1" + # the output may looks like + conserver=10.6.0.1 + conserver=10.6.0.1 + conserver=10.6.0.1 + conserver=10.6.0.1 + nfsserver=10.6.0.1 + servicenode=10.6.0.1 + xcatmaster=10.6.0.1 + kcmdline=quiet repo=http://10.6.0.1/install/rhels6/ppc64/ ks=http://10.6.0.1/install/autoinst + /slessn ksdevice=d6:92:39:bf:71:05 + nfsserver=10.6.0.1 + servicenode=10.6.0.1 + tftpserver=10.6.0.1 + xcatmaster=10.6.0.1 + servicenode=10.6.0.1 + xcatmaster=10.6.0.1 + +* As the attribute with the old ip address is list above, take conserver as + a example, query the nodes with ``conserver=10.6.0.1``. + + :: + + lsdef -t node -w conserver="10.6.0.1" + # the output looks like + cn1 (node) + cn2 (node) + cn3 (node) + cn4 (node) + +* Change the conserver address for cn1,cn2,cn3,cn4 :: + + chdef -t node cn1-cn4 conserver= + +Repeat the same process for the other attributes. + +Change networks table +^^^^^^^^^^^^^^^^^^^^^^ + +Check your networks table to see if the network definitions are still correct, +if not edit accordingly :: + + lsdef -t network -l + chdef -t network + +Check Result +^^^^^^^^^^^^^ + +You can check whether all the old address has been changed using :: + + dumpxCATdb -P + cd + fgrep "10.6.0.1" *.csv + +If the old address still exists in the ``*.csv` file, you can edit this file, +then use the following command to restore the records :: + + tabrestore + +Generate SSL credentials(optional) +---------------------------------- + +If you do not generate new credentials, skip this section. +If you decide generate new credentials, then you will use the following +command. + +* Generate new credentials :: + + xcatconfig -c + +* Update the policy table with new MN name, + replace ``"1.4","oldMNname",,,,,,"trusted",,`` with + ``"1.4","newMNname",,,,,,"trusted",,`` + +* Setup up conserver with new credentials :: + + makeconservercf + +External DNS Server Changed +--------------------------- + +* Update nameserver entries in ``/etc/resolv.conf`` +* Update nameserver attribute in ``site`` table :: + + chdef -t site -o clustersite nameservers="newipaddress1,newipaddress2" + +* Update site forwarders in DB :: + + chdef -t site -o clustersite forwarders="newipaddress1,newipaddress2" + +* Run command ``makedns -n`` + +Domain Name Changed +------------------- + +Change the entries in ``/etc/hosts``. + +Change the ``/etc/resolv.conf``, forwarders attribute in site table. :: + + lsdef -t site -o clustersite -i forwarders + chdef -t site -o clustersite forwarders + +Change the domain name in the xCAT database site table. :: + + chdef -t site -o clustersite domain= + +From xCAT 2.8, multiple domains is supported in the cluster. Update the +networks table definition. :: + + lsdef -t network -l + chdef -t network -o ddnsdomain= + +Update the Provision Environment +-------------------------------- + +Determine if the Management node is defined in the database, assuming it was +done correctly using xcatconfig -m, by running: :: + + lsdef __mgmtnode + +If it exists, then use the return name and do the following: + + - Remove the MN from DNS configuration :: + + makedns -d + + - Remove the MN from the DHCP configuration :: + + makedns -d + + - Remove the MN from the conserver configuration :: + + makedns -d + + - Change the MN name in the xCAT database :: + + chdef -t node -o -n + + - Add the new MN to DNS :: + + makedns -n + + - Add the MN to dhcp :: + + makedhcp -a + + - Add the MN to conserver :: + + makeconservercf + diff --git a/docs/source/advanced/cluster_maintenance/service_node/changing_hostname_ip.rst b/docs/source/advanced/cluster_maintenance/service_node/changing_hostname_ip.rst new file mode 100644 index 000000000..2a80f7e8b --- /dev/null +++ b/docs/source/advanced/cluster_maintenance/service_node/changing_hostname_ip.rst @@ -0,0 +1,60 @@ +Changing the hostname/IP address +================================ + +Change compute node definition relevant to the service node +----------------------------------------------------------- + +Change the settings in database. Below shows a method to find out where the old +ip address settings (take 10.6.0.1 as a example) are used in Hierarchy +environment. + +* Query the old attribute :: + + lsdef -t node -l | grep "10.6.0.1" + # below is output of the above command. We can find out that nfsserver + # and servicenode are using the old ip address setting. + nfsserver=10.6.0.1 + servicenode=10.6.0.1 + + +* Query the nodes whose nfsserver is 10.6.0.1 :: + + lsdef -w nfsserver==10.6.0.1 + # below is output of the above command + cn1 (node) + cn2 (node) + cn3 (node) + cn4 (node) + +* Change the nfsserver address for cn1,cn2,cn3,cn4 by running the following + command: :: + + chdef -t node cn1-cn4 nfsserver= + +Database Connection Changes +--------------------------- + +Granting or revoking access privilege in the database for the service node. + +* For mysql, please refer to :ref:`grante_revoke_mysql_access_label`. +.. There is no procedure in old document on sourceforge for postgress to + grant or revoke the access privilege for service node. + +* For postgress, please refer to `TODO `_. + +Update Provision Environment on Service Node +-------------------------------------------- + +If you are using service nodes to install the nodes and using ``/etc/hosts`` +for hostname resolution, you need to copy the new ``/etc/hosts`` from the +management node to the service nodes, then run ``makedns -n`` on the service +nodes. For example: :: + + xdcp /etc/hosts /etc/hosts + xdsh makedns -n + +Reinstall the nodes to pick up all changes :: + + nodeset osimage= + +Then use your normal command to install the nodes like rinstall,rnetboot,etc. \ No newline at end of file diff --git a/docs/source/advanced/cluster_maintenance/service_node/index.rst b/docs/source/advanced/cluster_maintenance/service_node/index.rst new file mode 100644 index 000000000..bf5a4e05d --- /dev/null +++ b/docs/source/advanced/cluster_maintenance/service_node/index.rst @@ -0,0 +1,7 @@ +Service Node +============ + +.. toctree:: + :maxdepth: 2 + + changing_hostname_ip.rst diff --git a/docs/source/advanced/hierarchy/databases/mysql_configure.rst b/docs/source/advanced/hierarchy/databases/mysql_configure.rst index 4b03f9b78..beb24ebb4 100644 --- a/docs/source/advanced/hierarchy/databases/mysql_configure.rst +++ b/docs/source/advanced/hierarchy/databases/mysql_configure.rst @@ -24,6 +24,8 @@ where the /tmp/servicenodes contains a host per line: :: **While not recommended**, if you wish to manually migrate your xCAT database, see the following documentation: `Manually set up MySQL `_ +.. _grante_revoke_mysql_access_label: + Granting/Revoking access to the database for Service Node Clients ----------------------------------------------------------------- From 11443d5205545898e16c875585d4d6eb085a94bd Mon Sep 17 00:00:00 2001 From: chenglch Date: Thu, 21 Jan 2016 02:40:24 -0500 Subject: [PATCH 002/310] Modify the maintenance table according to the comments Change ip to IP, update the example to change the MN ip address in networks table --- .../compute_node/changing_hostname_ip.rst | 27 +++++---- .../mgmt_node/changing_hostname_ip.rst | 55 +++++++++---------- .../service_node/changing_hostname_ip.rst | 10 ++-- 3 files changed, 47 insertions(+), 45 deletions(-) diff --git a/docs/source/advanced/cluster_maintenance/compute_node/changing_hostname_ip.rst b/docs/source/advanced/cluster_maintenance/compute_node/changing_hostname_ip.rst index 2b7ef02b2..544f577cd 100644 --- a/docs/source/advanced/cluster_maintenance/compute_node/changing_hostname_ip.rst +++ b/docs/source/advanced/cluster_maintenance/compute_node/changing_hostname_ip.rst @@ -1,11 +1,11 @@ -Changing the hostname/IP address +Changing the Hostname/IP address ================================ Background ---------- -If the hostname or ip address has already been modified on compute nodes, you -can follow the steps to change the configuration in xcat. +If the hostname or IP address has already been modified on compute nodes, +follow the steps to change the configuration in xcat. Remove Old Provision Environment -------------------------------- @@ -32,11 +32,14 @@ Change Definition The output may be like :: 10_0_0_0-255_0_0_0 (network) - fd03:2e76:8631::/64 (network) + 192_168_122_0-255_255_255_0 (network) - Change the networks table definitions, take ``10_0_0_0-255_0_0_0`` as a example :: + Change the networks table definitions, For example ``192_168_122_0-255_255_255_0`` + is a original network configuration which should be modified to + ``192_168_123_0-255_255_255_0``:: - chdef -t network 10_0_0_0-255_0_0_0 gateway=10.0.0.103 + rmdef -t network 192_168_122_0-255_255_255_0 + mkdef -t network 192_168_123_0-255_255_255_0 net=192.168.123.0 mask=255.255.255.0 #. Change the hostname in the xCAT database (This command only supports one node at a time). For many nodes you will have to write a script. :: @@ -44,21 +47,21 @@ Change Definition # changes node1 to node2 in the database chdef -t node -o node1 -n node2 -#. Change the hostname and ip address in the ``/etc/hosts`` file +#. Change the hostname and IP address in the ``/etc/hosts`` file - If you do not use the hosts table in xCAT to create the ``/etc/hosts`` file, - edit the ``/etc/hosts`` file and change your hostnames/ipaddresses entries + edit the ``/etc/hosts`` file and change your hostname and IP address entries directly. - If you use the xCAT hosts table, and your nodes are defined by name in the hosts table, the hosts table must be updated with the new names when - we changed the node name using chdef command. If the hosts tables contains + we changed the node name using ``chdef`` command. If the hosts tables contains regular expression, you have to rewrite the regular expression to - match your new hostnames/ip addresses. + match your new hostname and IP address. - If these is no regular expression in the hosts table, you can run :: - # change the ip address for the new hostname in the hosts table. + # change the IP address for the new hostname in the hosts table. nodech hosts.ip="x.xx.xx.xx" - # add host/ip records in /etc/hosts from the definition in the xCAT hosts + # add hostname/IP records in /etc/hosts from the definition in the xCAT hosts # table for the makehosts diff --git a/docs/source/advanced/cluster_maintenance/mgmt_node/changing_hostname_ip.rst b/docs/source/advanced/cluster_maintenance/mgmt_node/changing_hostname_ip.rst index 8d343e866..85bbe9886 100644 --- a/docs/source/advanced/cluster_maintenance/mgmt_node/changing_hostname_ip.rst +++ b/docs/source/advanced/cluster_maintenance/mgmt_node/changing_hostname_ip.rst @@ -13,8 +13,7 @@ any other tools. Backup your xCAT data --------------------- -It is good to backup all your xCAT data at first if necessary. Clean up the -database by running the following: :: +Clean up the database by running ``tabprune`` command: :: tabprune -a auditlog tabprune -a eventlog @@ -46,22 +45,22 @@ For example :: service postgresql stop service mysqld stop -Change the Management Host name +Change the Management Hostname ------------------------------- * hostname command :: - hostname + hostname * Edit hostname configuration file - Add hostname in ``/etc/hostname`` - Add HOSTNAME attribute in ``/etc/sysconfig/network`` (only for [RHEL]) + | Add hostname in ``/etc/hostname`` + | Add HOSTNAME attribute in ``/etc/sysconfig/network`` (only for [RHEL]) Update Database Files --------------------- -You need to update the new MN hostname or ip address in several database +You need to update the new MN hostname or IP address in several database configuration files. SQLite @@ -72,18 +71,18 @@ Nothing to do. Postgresql ^^^^^^^^^^ -- Edit ``/etc/xcat/cfgloc`` file, replace ``Pg:dbname=xcatdb;host=|xcatadm|xcat20`` - with ``Pg:dbname=xcatdb;host=|xcatadm|xcat20``. +- Edit ``/etc/xcat/cfgloc`` file, replace ``Pg:dbname=xcatdb;host=|xcatadm|xcat20`` + with ``Pg:dbname=xcatdb;host=|xcatadm|xcat20``. - Edit config database config file ``/var/lib/pgsql/data/pg_hba.conf``, - replace ``host all all /32 md5`` - with ``host all all /32 md5``. + replace ``host all all /32 md5`` + with ``host all all /32 md5``. Mysql ^^^^^ -Edit ``/etc/xcat/cfglooc``, replace ``mysql:dbname=xcatdb;host=|xcatadmin|xcat20`` -with ``mysql:dbname=xcatdb;host=|xcatadmin|xcat20``. +Edit ``/etc/xcat/cfglooc``, replace ``mysql:dbname=xcatdb;host=|xcatadmin|xcat20`` +with ``mysql:dbname=xcatdb;host=|xcatadmin|xcat20``. Start the database ------------------ @@ -112,10 +111,10 @@ Change the site table master attribute :: - chdef -t site master= + chdef -t site master= -Change all ip address attribute relevant to the MN ipaddress -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Change all IP address attribute relevant to the MN IP address +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ For example, old address was "10.6.0.1" @@ -139,7 +138,7 @@ For example, old address was "10.6.0.1" servicenode=10.6.0.1 xcatmaster=10.6.0.1 -* As the attribute with the old ip address is list above, take conserver as +* As the attribute with the old IP address is list above, take conserver as a example, query the nodes with ``conserver=10.6.0.1``. :: @@ -153,7 +152,7 @@ For example, old address was "10.6.0.1" * Change the conserver address for cn1,cn2,cn3,cn4 :: - chdef -t node cn1-cn4 conserver= + chdef -t node cn1-cn4 conserver= Repeat the same process for the other attributes. @@ -192,8 +191,8 @@ command. xcatconfig -c * Update the policy table with new MN name, - replace ``"1.4","oldMNname",,,,,,"trusted",,`` with - ``"1.4","newMNname",,,,,,"trusted",,`` + replace ``"1.4","old_MN_name",,,,,,"trusted",,`` with + ``"1.4","new_MN_name",,,,,,"trusted",,`` * Setup up conserver with new credentials :: @@ -205,11 +204,11 @@ External DNS Server Changed * Update nameserver entries in ``/etc/resolv.conf`` * Update nameserver attribute in ``site`` table :: - chdef -t site -o clustersite nameservers="newipaddress1,newipaddress2" + chdef -t site -o clustersite nameservers="new_ip_address1,new_ip_address2" * Update site forwarders in DB :: - chdef -t site -o clustersite forwarders="newipaddress1,newipaddress2" + chdef -t site -o clustersite forwarders="new_ip_address1,new_ip_address2" * Run command ``makedns -n`` @@ -225,13 +224,13 @@ Change the ``/etc/resolv.conf``, forwarders attribute in site table. :: Change the domain name in the xCAT database site table. :: - chdef -t site -o clustersite domain= + chdef -t site -o clustersite domain= From xCAT 2.8, multiple domains is supported in the cluster. Update the networks table definition. :: lsdef -t network -l - chdef -t network -o ddnsdomain= + chdef -t network -o ddnsdomain= Update the Provision Environment -------------------------------- @@ -245,19 +244,19 @@ If it exists, then use the return name and do the following: - Remove the MN from DNS configuration :: - makedns -d + makedns -d - Remove the MN from the DHCP configuration :: - makedns -d + makedns -d - Remove the MN from the conserver configuration :: - makedns -d + makedns -d - Change the MN name in the xCAT database :: - chdef -t node -o -n + chdef -t node -o -n - Add the new MN to DNS :: diff --git a/docs/source/advanced/cluster_maintenance/service_node/changing_hostname_ip.rst b/docs/source/advanced/cluster_maintenance/service_node/changing_hostname_ip.rst index 2a80f7e8b..faffe3cbe 100644 --- a/docs/source/advanced/cluster_maintenance/service_node/changing_hostname_ip.rst +++ b/docs/source/advanced/cluster_maintenance/service_node/changing_hostname_ip.rst @@ -1,18 +1,18 @@ -Changing the hostname/IP address +Changing the Hostname/IP address ================================ Change compute node definition relevant to the service node ----------------------------------------------------------- Change the settings in database. Below shows a method to find out where the old -ip address settings (take 10.6.0.1 as a example) are used in Hierarchy +IP address settings (take 10.6.0.1 as a example) are used in Hierarchy environment. * Query the old attribute :: lsdef -t node -l | grep "10.6.0.1" # below is output of the above command. We can find out that nfsserver - # and servicenode are using the old ip address setting. + # and servicenode are using the old IP address setting. nfsserver=10.6.0.1 servicenode=10.6.0.1 @@ -29,7 +29,7 @@ environment. * Change the nfsserver address for cn1,cn2,cn3,cn4 by running the following command: :: - chdef -t node cn1-cn4 nfsserver= + chdef -t node cn1-cn4 nfsserver= Database Connection Changes --------------------------- @@ -57,4 +57,4 @@ Reinstall the nodes to pick up all changes :: nodeset osimage= -Then use your normal command to install the nodes like rinstall,rnetboot,etc. \ No newline at end of file +Then use your normal command to install the nodes like rinstall, rnetboot, etc. From 826338036c09f2afe82d6dda136af81f5232688d Mon Sep 17 00:00:00 2001 From: junxiawang Date: Thu, 17 Mar 2016 06:56:21 -0400 Subject: [PATCH 003/310] modify autotest case about statelite osimage definition --- .../installation/reg_linux_diskfull_installation_flat | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/xCAT-test/autotest/testcase/installation/reg_linux_diskfull_installation_flat b/xCAT-test/autotest/testcase/installation/reg_linux_diskfull_installation_flat index 5a6fcb7d2..be95763b6 100644 --- a/xCAT-test/autotest/testcase/installation/reg_linux_diskfull_installation_flat +++ b/xCAT-test/autotest/testcase/installation/reg_linux_diskfull_installation_flat @@ -22,10 +22,9 @@ check:rc==0 cmd:sleep 10 cmd:if cat /etc/*release |grep SUSE >/dev/null;then cat /var/lib/dhcp/db/dhcpd.leases|grep $$CN;elif cat /etc/*release |grep "Red Hat" >/dev/null;then cat /var/lib/dhcpd/dhcpd.leases|grep $$CN;fi check:output=~$$CN - -cmd:if cat /etc/*release |grep "7.2" |grep "Red Hat">/dev/null;then copycds $$ISO -n rhels7.2;else copycds $$ISO;fi +cmd:copycds $$ISO check:rc==0 -cmd:if cat /etc/*release |grep "7.2" |grep "Red Hat">/dev/null;then mkdef $$STATELITE -u profile=compute provmethod=statelite osvers=rhels7.2;else mkdef $$STATELITE -u profile=compute provmethod=statelite; fi +cmd: mkdef __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -u profile=compute provmethod=statelite osvers=__GETNODEATTR($$CN,os)__ cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute check:rc==0 cmd:lsdef $$CN |grep provmethod From 8652e1dda80c6a7f067805d57eaff8806cd2ff86 Mon Sep 17 00:00:00 2001 From: penguhyang Date: Fri, 8 Apr 2016 03:02:53 -0400 Subject: [PATCH 004/310] correct rscan only detect the first vmnics --- xCAT-server/lib/xcat/plugins/kvm.pm | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index dd881b5d2..74fafc741 100755 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -3154,21 +3154,31 @@ sub rscan { my @interfaceobjs = $domain->findnodes("/domain/devices/interface"); foreach my $interfaceobj (@interfaceobjs) { if (($interfaceobj->getAttribute("type")) eq "bridge" ) { + my ($vmnics_obj, $mac_obj, $vmnicnicmodel_obj); my @vmnicsobj = $interfaceobj->findnodes("./source"); my @macobj = $interfaceobj->findnodes("./mac"); my @vmnicnicmodelobj = $interfaceobj->findnodes("./model"); - if ((@vmnicsobj and defined($vmnicsobj[0])) and (@macobj and defined($macobj[0])) and (@vmnicnicmodelobj and defined($vmnicnicmodelobj[0]))) { - $vmnics = $vmnicsobj[0]->getAttribute("bridge"); - $mac = $macobj[0]->getAttribute("address"); - $vmnicnicmodel = $vmnicnicmodelobj[0]->getAttribute("type"); - last; + if (@vmnicsobj and defined($vmnicsobj[0])) { + $vmnics_obj = $vmnicsobj[0]->getAttribute("bridge"); } + if (@macobj and defined($macobj[0])) { + $mac_obj = $macobj[0]->getAttribute("address"); + } + if (@vmnicnicmodelobj and defined($vmnicnicmodelobj[0])) { + $vmnicnicmodel_obj = $vmnicnicmodelobj[0]->getAttribute("type"); + } + $vmnics .= "$vmnics_obj,"; + $mac .= "$mac_obj,"; + $vmnicnicmodel .= "$vmnicnicmodel_obj,"; } } + chop($vmnics); + chop($mac); + chop($vmnicnicmodel); if (length($vmnics) > $maxlength[6]) { $maxlength[6] = length($vmnics); } - push @{$host2kvm{$uuid}}, join( ",", $type,$node,$hypervisor,$id,$vmcpus,$vmmemory,$vmnics,$vmstorage,$arch,$mac,$vmnicnicmodel ); + push @{$host2kvm{$uuid}}, join( ":", $type,$node,$hypervisor,$id,$vmcpus,$vmmemory,$vmnics,$vmstorage,$arch,$mac,$vmnicnicmodel ); if ($write) { unless (exists $hash_vm2host{$node}) { $updatetable->{vm}->{$node}->{host} = $hypervisor; @@ -3276,7 +3286,7 @@ sub rscan { my @data; foreach (@{$host2kvm{$host}}) { my $info = $_; - foreach (split(',', $info)) { + foreach (split(':', $info)) { my $attr = $_; push @data, "$attr"; } From 7b4a722a5ed6106da7e5766b037ce5c3f3c7cf6d Mon Sep 17 00:00:00 2001 From: junxiawang Date: Thu, 28 Apr 2016 09:52:07 -0400 Subject: [PATCH 005/310] modify xCATreg for mini.iso --- xCAT-server/share/xcat/tools/xCATreg | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/xCAT-server/share/xcat/tools/xCATreg b/xCAT-server/share/xcat/tools/xCATreg index 2ad97c79f..a3e268e7c 100755 --- a/xCAT-server/share/xcat/tools/xCATreg +++ b/xCAT-server/share/xcat/tools/xCATreg @@ -666,10 +666,8 @@ sub install_xcat { system("xdsh $confkeys{$mn} 'apt-get clean all' >/dev/null 2>&1"); system("xdsh $confkeys{$mn} 'apt-get update' >/dev/null 2>&1"); system("xdsh $confkeys{$mn} 'apt-get -y install xcat xCAT-test > /var/log/xcat/install_xcat.log 2>&1' >/dev/null 2>&1"); - - system("xdsh $confkeys{$mn} 'mkdir -p /install/ubuntu14.04.3/ppc64el/install/netboot '"); - system("scp /install/ubuntu14.04.3/ppc64el/install/netboot/initrd.gz $confkeys{$mn}:/install/ubuntu14.04.3/ppc64el/install/netboot "); - } + system("scp $osisodir/mini.iso $confkeys{$mn}:/ "); + } #check if MN is installed successful my $lsdefout = `ssh -t $confkeys{$mn} 'bash -l -i -c "lsdef -v"'`; From 200e8eadf5da08979bccca841733d0d8b9932d66 Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Thu, 5 May 2016 03:51:32 -0400 Subject: [PATCH 006/310] add xcatdebugmode cases --- .../autotest/testcase/xcatdebugmode/cases0 | 340 ++++++++++++++++++ 1 file changed, 340 insertions(+) create mode 100644 xCAT-test/autotest/testcase/xcatdebugmode/cases0 diff --git a/xCAT-test/autotest/testcase/xcatdebugmode/cases0 b/xCAT-test/autotest/testcase/xcatdebugmode/cases0 new file mode 100644 index 000000000..9adf233f3 --- /dev/null +++ b/xCAT-test/autotest/testcase/xcatdebugmode/cases0 @@ -0,0 +1,340 @@ +start:xcatdebugmode_off_rhels +os:linux +description:site.xcatdebugmode value is 0, the following logs will be shown and ssh is not supported. +cmd:chtab key=xcatdebugmode site.value="0" +check:rc==0 +cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute +check:rc==0 +cmd:if [[ "__GETNODEATTR($$CN,arch)__" =~ "ppc64le" ]]; then rpower $$CN reset;elif [[ "__GETNODEATTR($$CN,arch)__" =~ "x86_64" ]];then mgt=`lsdef $$CN | grep mgt`; if [[ $mgt =~ "bmc" ]]; then rpower $$CN boot; elif [[ $mgt =~ "ipmi" ]]; then rsetboot $$CN net; rpower $$CN reset; fi; elif [[ "__GETNODEATTR($$CN,arch)__" =~ "ppc64" ]]; then rnetboot $$CN; fi +check:rc==0 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep installing >/dev/null`; do sleep 20;((a++));if [ $a -gt 30 ];then break;fi done +cmd:sleep 120 +cmd:xdsh $$CN date +check:output=~(Connection refused|No route to host) +check:rc==1 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 20;((a++));if [ $a -gt 90 ];then break;fi done +cmd:lsdef -l $$CN | grep status +check:output=~booted +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"Running Kickstart Pre-Installation script\"" +check:output=~Running Kickstart Pre-Installation script +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"installstatus installing\"" +check:output=~installstatus installing +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"\[get\_install\_disk\]Information from \/proc\/partitions\:\"" +check:output=~\[get\_install\_disk\]Information from \/proc\/partitions\: +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"Running Kickstart Post\-Installation script\"" +check:output=~Running Kickstart Post\-Installation script +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"running \/xcatpost\/mypostscript.post\"" +check:output=~running \/xcatpost\/mypostscript\.post +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"\/xcatpost\/mypostscript\.post return\"" +check:output=~\/xcatpost\/mypostscript\.post return +cmd:xdsh $$CN "file \/var\/log\/anaconda*" +check:output!~No such file or directory +end + +start:set_xcatdebugmode_one_rhels +os:linux +description:site.xcatdebugmode value is 1, the following logs will be shown and ssh is not supported. +cmd:chtab key=xcatdebugmode site.value="1" +check:rc==0 +cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute +check:rc==0 +cmd:if [[ "__GETNODEATTR($$CN,arch)__" =~ "ppc64le" ]]; then rpower $$CN reset;elif [[ "__GETNODEATTR($$CN,arch)__" =~ "x86_64" ]];then mgt=`lsdef $$CN | grep mgt`; if [[ $mgt =~ "bmc" ]]; then rpower $$CN boot; elif [[ $mgt =~ "ipmi" ]]; then rsetboot $$CN net; rpower $$CN reset; fi; elif [[ "__GETNODEATTR($$CN,arch)__" =~ "ppc64" ]]; then rnetboot $$CN; fi +check:rc==0 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep installing >/dev/null`; do sleep 20;((a++));if [ $a -gt 30 ];then break;fi done +cmd:sleep 120 +cmd:xdsh $$CN date +check:output=~(Connection refused|No route to host) +check:rc==1 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 20;((a++));if [ $a -gt 90 ];then break;fi done +cmd:lsdef -l $$CN | grep status +check:output=~booted +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"Running Kickstart Pre\-Installation script\"" +check:output=~Running Kickstart Pre\-Installation script +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"installstatus installing\"" +check:output=~\+ \/tmp\/baz\.py \'installstatus installing\' +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep -c \"installstatus installing\"" +checkoutput=~2 +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"\[get\_install\_disk\]Information from \/proc\/partitions\:\"" +check:output=~\+ echo \'\[get\_install\_disk\]Information from \/proc\/partitions\:\' +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep -c \"\[get\_install\_disk\]Information from \/proc\/partitions\:\"" +checkoutput=~2 +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"Running Kickstart Post-Installation script\"" +check:output=~Running Kickstart Post-Installation script +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"\/opt\/xcat\/xcatinfo generated\"" +check:output=~\+ echo \'\/opt\/xcat\/xcatinfo generated\' +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep -c \"\/opt\/xcat\/xcatinfo generated\"" +check:output=~2 +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"running \/xcatpost\/mypostscript\.post\"" +check:output=~running \/xcatpost\/mypostscript\.post +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"\+ echo "\'"\/opt\/xcat\/xcatinstallpost generated"\'"\"" +check:output=~\+ echo \'\/opt\/xcat\/xcatinstallpost generated\' +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"\/opt\/xcat\/xcatinstallpost generated\"" +check:output=~\/opt\/xcat\/xcatinstallpost generated +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"\/xcatpost\/mypostscript\.post return\"" +check:output=~\/xcatpost\/mypostscript\.post return +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"service xcatpostinit1 disabled\"" +check:output=~service xcatpostinit1 disabled +cmd:cat /var/log/xcat/computes.log | grep "/opt/xcat/xcatinfo generated" +check:output=~/opt/xcat/xcatinfo generated +cmd:cat /var/log/xcat/computes.log | grep "postscripts downloaded successfully" +check:output=~postscripts downloaded successfully +cmd:cat /var/log/xcat/computes.log | grep "running /xcatpost/mypostscript.post" +check:output=~running /xcatpost/mypostscript.post +cmd:cat /var/log/xcat/computes.log | grep "/etc/init.d/xcatpostinit1 generated" +check:output=~/etc/init.d/xcatpostinit1 generated +cmd:cat /var/log/xcat/computes.log | grep "/opt/xcat/xcatinstallpost generated" +check:output=~/opt/xcat/xcatinstallpost generated +cmd:cat /var/log/xcat/computes.log | grep "/opt/xcat/xcatdsklspost generated" +check:output=~/opt/xcat/xcatdsklspost generated +cmd:cat /var/log/xcat/computes.log | grep "running mypostscript" +check:output=~running mypostscript +cmd:xdsh $$CN "file \/var\/log\/anaconda*" +check:output!~No such file or directory +cmd:chtab key=xcatdebugmode site.value="0" +check:rc==0 +end + +start:set_xcatdebugmode_value_two_rhels +os:linux +description:site.xcatdebugmode value is 2, , the following logs will be shown and ssh is supported. +cmd:chtab key=xcatdebugmode site.value="2" +check:rc==0 +cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute +check:rc==0 +cmd:if [[ "__GETNODEATTR($$CN,arch)__" =~ "ppc64le" ]]; then rpower $$CN reset;elif [[ "__GETNODEATTR($$CN,arch)__" =~ "x86_64" ]];then mgt=`lsdef $$CN | grep mgt`; if [[ $mgt =~ "bmc" ]]; then rpower $$CN boot; elif [[ $mgt =~ "ipmi" ]]; then rsetboot $$CN net; rpower $$CN reset; fi; elif [[ "__GETNODEATTR($$CN,arch)__" =~ "ppc64" ]]; then rnetboot $$CN; fi +check:rc==0 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep installing >/dev/null`; do sleep 20;((a++));if [ $a -gt 30 ];then break;fi done +cmd:sleep 120 +cmd:xdsh $$CN date +check:output=~ 2016 +check:rc==0 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 20;((a++));if [ $a -gt 60 ];then break;fi done +cmd:lsdef -l $$CN | grep status +check:output=~booted +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"Running Kickstart Pre\-Installation script\"" +check:output=~Running Kickstart Pre\-Installation script +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"installstatus installing\"" +check:output=~\+ \/tmp\/baz\.py \'installstatus installing\' +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep -c \"installstatus installing\"" +checkoutput=~2 +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"\[get\_install\_disk\]Information from \/proc\/partitions\:\"" +check:output=~\+ echo \'\[get\_install\_disk\]Information from \/proc\/partitions\:\' +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep -c \"\[get\_install\_disk\]Information from \/proc\/partitions\:\"" +checkoutput=~2 +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"Running Kickstart Post-Installation script\"" +check:output=~Running Kickstart Post-Installation script +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"\/opt\/xcat\/xcatinfo generated\"" +check:output=~\+ echo \'\/opt\/xcat\/xcatinfo generated\' +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep -c \"\/opt\/xcat\/xcatinfo generated\"" +check:output=~2 +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"running \/xcatpost\/mypostscript\.post\"" +check:output=~running \/xcatpost\/mypostscript\.post +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"\+ echo "\'"\/opt\/xcat\/xcatinstallpost generated"\'"\"" +check:output=~\+ echo \'\/opt\/xcat\/xcatinstallpost generated\' +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"\/opt\/xcat\/xcatinstallpost generated\"" +check:output=~\/opt\/xcat\/xcatinstallpost generated +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"\/xcatpost\/mypostscript\.post return\"" +check:output=~\/xcatpost\/mypostscript\.post return +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"service xcatpostinit1 disabled\"" +check:output=~service xcatpostinit1 disabled +cmd:cat /var/log/xcat/computes.log | grep "/opt/xcat/xcatinfo generated" +check:output=~/opt/xcat/xcatinfo generated +cmd:cat /var/log/xcat/computes.log | grep "postscripts downloaded successfully" +check:output=~postscripts downloaded successfully +cmd:cat /var/log/xcat/computes.log | grep "running /xcatpost/mypostscript.post" +check:output=~running /xcatpost/mypostscript.post +cmd:cat /var/log/xcat/computes.log | grep "/etc/init.d/xcatpostinit1 generated" +check:output=~/etc/init.d/xcatpostinit1 generated +cmd:cat /var/log/xcat/computes.log | grep "/opt/xcat/xcatinstallpost generated" +check:output=~/opt/xcat/xcatinstallpost generated +cmd:cat /var/log/xcat/computes.log | grep "/opt/xcat/xcatdsklspost generated" +check:output=~/opt/xcat/xcatdsklspost generated +cmd:cat /var/log/xcat/computes.log | grep "running mypostscript" +check:output=~running mypostscript +cmd:chtab key=xcatdebugmode site.value="0" +check:rc==0 +end + +start:xcatdebugmode_off_sles +os:linux +description:site.xcatdebugmode value is 0, the following logs will be shown and ssh is not supported. +cmd:chtab key=xcatdebugmode site.value="0" +check:rc==0 +cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute +check:rc==0 +cmd:if [[ "__GETNODEATTR($$CN,arch)__" =~ "ppc64le" ]]; then rpower $$CN reset;elif [[ "__GETNODEATTR($$CN,arch)__" =~ "x86_64" ]];then mgt=`lsdef $$CN | grep mgt`; if [[ $mgt =~ "bmc" ]]; then rpower $$CN boot; elif [[ $mgt =~ "ipmi" ]]; then rsetboot $$CN net; rpower $$CN reset; fi; elif [[ "__GETNODEATTR($$CN,arch)__" =~ "ppc64" ]]; then rnetboot $$CN; fi +check:rc==0 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep installing >/dev/null`; do sleep 20;((a++));if [ $a -gt 30 ];then break;fi done +cmd:sleep 120 +cmd:xdsh $$CN date +check:output=~(Connection refused|No route to host) +check:rc==1 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 20;((a++));if [ $a -gt 90 ];then break;fi done +cmd:lsdef -l $$CN | grep status +check:output=~booted +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"Running AutoYaST Pre-Installation script\"" +check:output=~Running AutoYaST Pre-Installation script +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"installstatus installing\"" +check:output=~installstatus installing +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"\[get\_install\_disk\]Information from \/proc\/partitions\:\"" +check:output=~\[get\_install\_disk\]Information from \/proc\/partitions\: +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"Running AutoYaST Chroot-Installation script\"" +check:output=~Running AutoYaST Chroot-Installation script +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"Running AutoYaST Post\-Installation script\"" +check:output=~Running AutoYaST Post\-Installation script +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"ready\"" +check:output=~ready +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"done\"" +check:output=~done +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"running \/xcatpost\/mypostscript\.post\"" +check:output=~running \/xcatpost\/mypostscript\.post +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"\/xcatpost\/mypostscript\.post return\"" +check:output=~\/xcatpost\/mypostscript\.post return +cmd:xdsh $$CN "file \/var\/log\/YaST2" +check:output!~No such file or directory +end + +start:set_xcatdebugmode_one_sles +os:linux +description:site.xcatdebugmode value is 1, the following logs will be shown and ssh is not supported. +cmd:chtab key=xcatdebugmode site.value="1" +check:rc==0 +cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute +check:rc==0 +cmd:if [[ "__GETNODEATTR($$CN,arch)__" =~ "ppc64le" ]]; then rpower $$CN reset;elif [[ "__GETNODEATTR($$CN,arch)__" =~ "x86_64" ]];then mgt=`lsdef $$CN | grep mgt`; if [[ $mgt =~ "bmc" ]]; then rpower $$CN boot; elif [[ $mgt =~ "ipmi" ]]; then rsetboot $$CN net; rpower $$CN reset; fi; elif [[ "__GETNODEATTR($$CN,arch)__" =~ "ppc64" ]]; then rnetboot $$CN; fi +check:rc==0 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep installing >/dev/null`; do sleep 20;((a++));if [ $a -gt 30 ];then break;fi done +cmd:sleep 120 +cmd:xdsh $$CN date +check:output=~(Connection refused|No route to host) +check:rc==1 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 20;((a++));if [ $a -gt 90 ];then break;fi done +cmd:lsdef -l $$CN | grep status +check:output=~booted +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"Running AutoYaST Pre-Installation script\"" +check:output=~Running AutoYaST Pre-Installation script +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"installstatus installing\"" +check:output=~\+ \/tmp\/bar\.awk \'installstatus installing\' +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep -c \"installstatus installing\"" +checkoutput=~2 +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"\[get\_install\_disk\]Information from \/proc\/partitions\:\"" +check:output=~\+ echo \'\[get\_install\_disk\]Information from \/proc\/partitions\:\' +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep -c \"\[get\_install\_disk\]Information from \/proc\/partitions\:\"" +checkoutput=~2 +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"Running AutoYaST Chroot\-Installation script\"" +check:output=~Running AutoYaST Chroot\-Installation script +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"updateflag\.awk\"" +check:output=~\+ \/tmp\/updateflag\.awk +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"ready\"" +check:output=~ready +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"done\"" +check:output=~done +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"Running AutoYaST Post-Installation script\"" +check:output=~Running AutoYaST Post-Installation script +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"running \/xcatpost\/mypostscript\.post\"" +check:output=~running \/xcatpost\/mypostscript\.post +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"finished node installation\, reporting status\"" +check:output=~\+ echo \'finished node installation\, reporting status\.\.\.\' +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"\/xcatpost\/mypostscript\.post return\"" +check:output=~\/xcatpost\/mypostscript\.post return +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"service xcatpostinit1 disabled\"" +check:output=~service xcatpostinit1 disabled +cmd:cat /var/log/xcat/computes.log | grep "/opt/xcat/xcatinfo generated" +check:output=~/opt/xcat/xcatinfo generated +cmd:cat /var/log/xcat/computes.log | grep "postscripts downloaded successfully" +check:output=~postscripts downloaded successfully +cmd:cat /var/log/xcat/computes.log | grep "running /xcatpost/mypostscript.post" +check:output=~running /xcatpost/mypostscript.post +cmd:cat /var/log/xcat/computes.log | grep "/etc/init.d/xcatpostinit1 generated" +check:output=~/etc/init.d/xcatpostinit1 generated +cmd:cat /var/log/xcat/computes.log | grep "/opt/xcat/xcatinstallpost generated" +check:output=~/opt/xcat/xcatinstallpost generated +cmd:cat /var/log/xcat/computes.log | grep "/opt/xcat/xcatdsklspost generated" +check:output=~/opt/xcat/xcatdsklspost generated +cmd:cat /var/log/xcat/computes.log | grep "running mypostscript" +check:output=~running mypostscript +cmd:xdsh $$CN "file \/var\/log\/YaST2" +check:output!~No such file or directory +cmd:chtab key=xcatdebugmode site.value="0" +check:rc==0 +end + +start:xcatdebugmode_off_ubuntu +os:linux +description:site.xcatdebugmode value is 0, the following logs will be shown and ssh is not supported. +cmd:chtab key=xcatdebugmode site.value="0" +check:rc==0 +cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute +check:rc==0 +cmd:if [[ "__GETNODEATTR($$CN,arch)__" =~ "ppc64el" ]]; then rpower $$CN reset;elif [[ "__GETNODEATTR($$CN,arch)__" =~ "x86_64" ]];then mgt=`lsdef $$CN | grep mgt`; if [[ $mgt =~ "bmc" ]]; then rpower $$CN boot; elif [[ $mgt =~ "ipmi" ]]; then rsetboot $$CN net; rpower $$CN reset; fi; elif [[ "__GETNODEATTR($$CN,arch)__" =~ "ppc64" ]]; then rnetboot $$CN; fi +check:rc==0 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep installing >/dev/null`; do sleep 20;((a++));if [ $a -gt 30 ];then break;fi done +cmd:xdsh $$CN date +check:output=~(Connection refused|No route to host) +check:rc==1 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 20;((a++));if [ $a -gt 90 ];then break;fi done +cmd:lsdef -l $$CN | grep status +check:output=~booted +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"Running preseeding early\_command Installation script\"" +check:output=~Running preseeding early\_command Installation script +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"\[get\_install\_disk\]Information from \/proc\/partitions\:\"" +check:output=~\[get\_install\_disk\]Information from \/proc\/partitions\: +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"Running preseeding late\_command Installation script\"" +check:output=~Running preseeding late\_command Installation script +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"Generating grub configuration file\"" +check:output=~Generating grub configuration file +cmd:xdsh $$CN "file \/var\/log\/installer" +check:output!~No such file or directory +end + +start:set_xcatdebugmode_one_ubuntu +os:linux +description:site.xcatdebugmode value is 1, the following logs will be shown and ssh is not supported. +cmd:chtab key=xcatdebugmode site.value="1" +check:rc==0 +cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute +check:rc==0 +cmd:if [[ "__GETNODEATTR($$CN,arch)__" =~ "ppc64el" ]]; then rpower $$CN reset;elif [[ "__GETNODEATTR($$CN,arch)__" =~ "x86_64" ]];then mgt=`lsdef $$CN | grep mgt`; if [[ $mgt =~ "bmc" ]]; then rpower $$CN boot; elif [[ $mgt =~ "ipmi" ]]; then rsetboot $$CN net; rpower $$CN reset; fi; elif [[ "__GETNODEATTR($$CN,arch)__" =~ "ppc64" ]]; then rnetboot $$CN; fi +check:rc==0 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep installing >/dev/null`; do sleep 20;((a++));if [ $a -gt 30 ];then break;fi done +cmd:xdsh $$CN date +check:output=~(Connection refused|No route to host) +check:rc==1 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 20;((a++));if [ $a -gt 90 ];then break;fi done +cmd:lsdef -l $$CN | grep status +check:output=~booted +start:test_log +cmd:lsdef -l $$CN | grep status +check:output=~booted +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"Running preseeding early\_command Installation script\"" +check:output=~Running preseeding early\_command Installation script +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"\[get\_install\_disk\]Information from \/proc\/partitions\:\"" +check:output=~\[get\_install\_disk\]Information from \/proc\/partitions\: +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"Running preseeding late\_command Installation script\"" +checkoutput=~Running preseeding late\_command Installation script +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"postscripts downloaded successfully\"" +check:output=~\+ echo \'postscripts# downloaded successfully\' +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"mypostscript returned\"" +check:output=~\+ echo \'mypostscript returned\' +cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"finished node installation, reporting status\"" +check:output=~\+ echo \'finished node installation\' +cmd:cat /var/log/xcat/commands.log | grep "/opt/xcat/xcatinfo generated" +check:output=~/opt/xcat/xcatinfo generated +cmd:cat /var/log/xcat/commands.log | grep "postscripts downloaded successfully" +check:output=~postscripts downloaded successfully +cmd:cat /var/log/xcat/commands.log | grep "running /xcatpost/mypostscript.post" +check:output=~running /xcatpost/mypostscript.post +cmd:cat /var/log/xcat/commands.log | grep "/etc/init.d/xcatpostinit1 generated" +check:output=~/etc/init.d/xcatpostinit1 generated +cmd:cat /var/log/xcat/commands.log | grep "/opt/xcat/xcatinstallpost generated" +check:output=~/opt/xcat/xcatinstallpost generated +cmd:cat /var/log/xcat/commands.log | grep "/opt/xcat/xcatdsklspost generated" +check:output=~/opt/xcat/xcatdsklspost generated +cmd:cat /var/log/xcat/commands.log | grep "running mypostscript" +check:output=~running mypostscript +cmd:xdsh $$CN "file \/var\/log\/installer" +check:output!~No such file or directory +cmd:chtab key=xcatdebugmode site.value="0" +check:rc==0 +end + From c06d600aabbe40b93695ad2fcb4b57d1e0118260 Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Thu, 5 May 2016 03:54:59 -0400 Subject: [PATCH 007/310] delete invalid cases --- .../autotest/testcase/xcatdebugmode/cases0 | 52 ------------------- 1 file changed, 52 deletions(-) diff --git a/xCAT-test/autotest/testcase/xcatdebugmode/cases0 b/xCAT-test/autotest/testcase/xcatdebugmode/cases0 index 9adf233f3..ec612c1f0 100644 --- a/xCAT-test/autotest/testcase/xcatdebugmode/cases0 +++ b/xCAT-test/autotest/testcase/xcatdebugmode/cases0 @@ -286,55 +286,3 @@ check:output=~Generating grub configuration file cmd:xdsh $$CN "file \/var\/log\/installer" check:output!~No such file or directory end - -start:set_xcatdebugmode_one_ubuntu -os:linux -description:site.xcatdebugmode value is 1, the following logs will be shown and ssh is not supported. -cmd:chtab key=xcatdebugmode site.value="1" -check:rc==0 -cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute -check:rc==0 -cmd:if [[ "__GETNODEATTR($$CN,arch)__" =~ "ppc64el" ]]; then rpower $$CN reset;elif [[ "__GETNODEATTR($$CN,arch)__" =~ "x86_64" ]];then mgt=`lsdef $$CN | grep mgt`; if [[ $mgt =~ "bmc" ]]; then rpower $$CN boot; elif [[ $mgt =~ "ipmi" ]]; then rsetboot $$CN net; rpower $$CN reset; fi; elif [[ "__GETNODEATTR($$CN,arch)__" =~ "ppc64" ]]; then rnetboot $$CN; fi -check:rc==0 -cmd:a=0;while ! `lsdef -l $$CN|grep status|grep installing >/dev/null`; do sleep 20;((a++));if [ $a -gt 30 ];then break;fi done -cmd:xdsh $$CN date -check:output=~(Connection refused|No route to host) -check:rc==1 -cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 20;((a++));if [ $a -gt 90 ];then break;fi done -cmd:lsdef -l $$CN | grep status -check:output=~booted -start:test_log -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"Running preseeding early\_command Installation script\"" -check:output=~Running preseeding early\_command Installation script -cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"\[get\_install\_disk\]Information from \/proc\/partitions\:\"" -check:output=~\[get\_install\_disk\]Information from \/proc\/partitions\: -cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"Running preseeding late\_command Installation script\"" -checkoutput=~Running preseeding late\_command Installation script -cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"postscripts downloaded successfully\"" -check:output=~\+ echo \'postscripts# downloaded successfully\' -cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"mypostscript returned\"" -check:output=~\+ echo \'mypostscript returned\' -cmd:xdsh $$CN "cat /var/log/xcat/xcat.log | grep \"finished node installation, reporting status\"" -check:output=~\+ echo \'finished node installation\' -cmd:cat /var/log/xcat/commands.log | grep "/opt/xcat/xcatinfo generated" -check:output=~/opt/xcat/xcatinfo generated -cmd:cat /var/log/xcat/commands.log | grep "postscripts downloaded successfully" -check:output=~postscripts downloaded successfully -cmd:cat /var/log/xcat/commands.log | grep "running /xcatpost/mypostscript.post" -check:output=~running /xcatpost/mypostscript.post -cmd:cat /var/log/xcat/commands.log | grep "/etc/init.d/xcatpostinit1 generated" -check:output=~/etc/init.d/xcatpostinit1 generated -cmd:cat /var/log/xcat/commands.log | grep "/opt/xcat/xcatinstallpost generated" -check:output=~/opt/xcat/xcatinstallpost generated -cmd:cat /var/log/xcat/commands.log | grep "/opt/xcat/xcatdsklspost generated" -check:output=~/opt/xcat/xcatdsklspost generated -cmd:cat /var/log/xcat/commands.log | grep "running mypostscript" -check:output=~running mypostscript -cmd:xdsh $$CN "file \/var\/log\/installer" -check:output!~No such file or directory -cmd:chtab key=xcatdebugmode site.value="0" -check:rc==0 -end - From 842d200454efeb164243010bfef8ae16422454da Mon Sep 17 00:00:00 2001 From: penguhyang Date: Fri, 8 Apr 2016 03:02:53 -0400 Subject: [PATCH 008/310] enhance the scan for kvm --- xCAT-server/lib/xcat/plugins/kvm.pm | 71 ++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 11 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index dd881b5d2..ac9ef1bc8 100755 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -2870,7 +2870,7 @@ sub fixup_clone_network { } sub mkvm { - shift; #Throuw away first argument + shift; #Throw away first argument @ARGV = @_; my $disksize; my $mastername; @@ -2885,6 +2885,12 @@ sub mkvm { "cpus=s" => \$cpucount, 'force|f' => \$force ); + if (defined $confdata->{vm}->{$node}->[0]->{othersettings}) { + my $nodefrom = $confdata->{vm}->{$node}->[0]->{othersettings}; + if ($nodefrom =~ /^nodefromrscan/) { + return 1, "this node was defined through rscan, it does not support to use 'mkvm' to create again."; + } + } if (defined $confdata->{vm}->{$node}->[0]->{storage}) { my $diskname = $confdata->{vm}->{$node}->[0]->{storage}; if ($diskname =~ /^phy:/) { #in this case, mkvm should have no argumens @@ -3136,14 +3142,23 @@ sub rscan { } my @vmstoragediskobjs = $domain->findnodes("/domain/devices/disk"); foreach my $vmstoragediskobj (@vmstoragediskobjs) { + my ($vmstorage_file_obj, $vmstorage_block_obj); if (($vmstoragediskobj->getAttribute("device") eq "disk") and ($vmstoragediskobj->getAttribute("type") eq "file")) { my @vmstorageobj = $vmstoragediskobj->findnodes("./source"); if (@vmstorageobj and defined($vmstorageobj[0])) { - $vmstorage = $vmstorageobj[0]->getAttribute("file"); - last; + $vmstorage_file_obj = $vmstorageobj[0]->getAttribute("file"); } + $vmstorage .= "$vmstorage_file_obj,"; + } + if (($vmstoragediskobj->getAttribute("device") eq "disk") and ($vmstoragediskobj->getAttribute("type") eq "block")) { + my @vmstorageobj = $vmstoragediskobj->findnodes("./source"); + if (@vmstorageobj and defined($vmstorageobj[0])) { + $vmstorage_block_obj = $vmstorageobj[0]->getAttribute("dev"); + } + $vmstorage .= "$vmstorage_block_obj,"; } } + chop($vmstorage); if (length($vmstorage) > $maxlength[7]) { $maxlength[7] = length($vmstorage); } @@ -3154,21 +3169,31 @@ sub rscan { my @interfaceobjs = $domain->findnodes("/domain/devices/interface"); foreach my $interfaceobj (@interfaceobjs) { if (($interfaceobj->getAttribute("type")) eq "bridge" ) { + my ($vmnics_obj, $mac_obj, $vmnicnicmodel_obj); my @vmnicsobj = $interfaceobj->findnodes("./source"); my @macobj = $interfaceobj->findnodes("./mac"); my @vmnicnicmodelobj = $interfaceobj->findnodes("./model"); - if ((@vmnicsobj and defined($vmnicsobj[0])) and (@macobj and defined($macobj[0])) and (@vmnicnicmodelobj and defined($vmnicnicmodelobj[0]))) { - $vmnics = $vmnicsobj[0]->getAttribute("bridge"); - $mac = $macobj[0]->getAttribute("address"); - $vmnicnicmodel = $vmnicnicmodelobj[0]->getAttribute("type"); - last; + if (@vmnicsobj and defined($vmnicsobj[0])) { + $vmnics_obj = $vmnicsobj[0]->getAttribute("bridge"); } + if (@macobj and defined($macobj[0])) { + $mac_obj = $macobj[0]->getAttribute("address"); + } + if (@vmnicnicmodelobj and defined($vmnicnicmodelobj[0])) { + $vmnicnicmodel_obj = $vmnicnicmodelobj[0]->getAttribute("type"); + } + $vmnics .= "$vmnics_obj,"; + $mac .= "$mac_obj,"; + $vmnicnicmodel .= "$vmnicnicmodel_obj,"; } } + chop($vmnics); + chop($mac); + chop($vmnicnicmodel); if (length($vmnics) > $maxlength[6]) { $maxlength[6] = length($vmnics); } - push @{$host2kvm{$uuid}}, join( ",", $type,$node,$hypervisor,$id,$vmcpus,$vmmemory,$vmnics,$vmstorage,$arch,$mac,$vmnicnicmodel ); + push @{$host2kvm{$uuid}}, join( ":", $type,$node,$hypervisor,$id,$vmcpus,$vmmemory,$vmnics,$vmstorage,$arch,$mac,$vmnicnicmodel ); if ($write) { unless (exists $hash_vm2host{$node}) { $updatetable->{vm}->{$node}->{host} = $hypervisor; @@ -3177,15 +3202,20 @@ sub rscan { $updatetable->{vm}->{$node}->{cpus} = $vmcpus; $updatetable->{vm}->{$node}->{nics} = $vmnics; $updatetable->{vm}->{$node}->{nicmodel} = $vmnicnicmodel; + $updatetable->{vm}->{$node}->{othersettings} = "nodefromrscan"; $updatetable->{mac}->{$node}->{mac} = $mac; $updatetable->{vpd}->{$node}->{uuid} = $uuid; + $updatetable->{nodelist}->{$node}->{groups} = "vm,all"; $updatetable->{nodetype}->{$node}->{arch} = $arch; $updatetable->{nodehm}->{$node}->{mgt} = "kvm"; + $updatetable->{nodehm}->{$node}->{serialport} = "0"; + $updatetable->{nodehm}->{$node}->{serialspeed} = "115200"; + $updatetable->{kvm_nodedata}->{$node}->{xml} = $currxml; } else { if ($hash_vm2host{$node} eq $hypervisor) { - #mark this node to delete in 'vm' 'mac' vpd' 'nodetype' 'nodehm' tables + #mark this node to delete in 'vm' 'mac' vpd' 'nodelist' 'nodetype' 'nodehm' tables $updatetable->{vm}->{'!*XCATNODESTODELETE*!'}->{$node} = $node; $updatetable->{vm}->{$node}->{host} = $hypervisor; @@ -3194,14 +3224,21 @@ sub rscan { $updatetable->{vm}->{$node}->{cpus} = $vmcpus; $updatetable->{vm}->{$node}->{nics} = $vmnics; $updatetable->{vm}->{$node}->{nicmodel} = $vmnicnicmodel; + $updatetable->{vm}->{$node}->{othersettings} = "nodefromrscan"; $updatetable->{mac}->{'!*XCATNODESTODELETE*!'}->{$node} = $node; $updatetable->{mac}->{$node}->{mac} = $mac; $updatetable->{vpd}->{'!*XCATNODESTODELETE*!'}->{$node} = $node; $updatetable->{vpd}->{$node}->{uuid} = $uuid; + $updatetable->{nodelist}->{'!*XCATNODESTODELETE*!'}->{$node} = $node; + $updatetable->{nodelist}->{$node}->{groups} = "vm,all"; $updatetable->{nodetype}->{'!*XCATNODESTODELETE*!'}->{$node} = $node; $updatetable->{nodetype}->{$node}->{arch} = $arch; $updatetable->{nodehm}->{'!*XCATNODESTODELETE*!'}->{$node} = $node; $updatetable->{nodehm}->{$node}->{mgt} = "kvm"; + $updatetable->{nodehm}->{$node}->{serialport} = "0"; + $updatetable->{nodehm}->{$node}->{serialspeed} = "115200"; + $updatetable->{kvm_nodedata}->{'!*XCATNODESTODELETE*!'}->{$node} = $node; + $updatetable->{kvm_nodedata}->{$node}->{xml} = $currxml; } else { $callback->({data=>"the name of KVM guest $node on $hypervisor conflicts with the existing node in xCAT table."}); @@ -3217,14 +3254,21 @@ sub rscan { $updatetable->{vm}->{$node}->{cpus} = $vmcpus; $updatetable->{vm}->{$node}->{nics} = $vmnics; $updatetable->{vm}->{$node}->{nicmodel} = $vmnicnicmodel; + $updatetable->{vm}->{$node}->{othersettings} = "nodefromrscan"; $updatetable->{mac}->{'!*XCATNODESTODELETE*!'}->{$node} = $node; $updatetable->{mac}->{$node}->{mac} = $mac; $updatetable->{vpd}->{'!*XCATNODESTODELETE*!'}->{$node} = $node; $updatetable->{vpd}->{$node}->{uuid} = $uuid; + $updatetable->{nodelist}->{'!*XCATNODESTODELETE*!'}->{$node} = $node; + $updatetable->{nodelist}->{$node}->{groups} = "vm,all"; $updatetable->{nodetype}->{'!*XCATNODESTODELETE*!'}->{$node} = $node; $updatetable->{nodetype}->{$node}->{arch} = $arch; $updatetable->{nodehm}->{'!*XCATNODESTODELETE*!'}->{$node} = $node; $updatetable->{nodehm}->{$node}->{mgt} = "kvm"; + $updatetable->{nodehm}->{$node}->{serialport} = "0"; + $updatetable->{nodehm}->{$node}->{serialspeed} = "115200"; + $updatetable->{kvm_nodedata}->{'!*XCATNODESTODELETE*!'}->{$node} = $node; + $updatetable->{kvm_nodedata}->{$node}->{xml} = $currxml; } } if ($create) { @@ -3235,10 +3279,15 @@ sub rscan { $updatetable->{vm}->{$node}->{cpus} = $vmcpus; $updatetable->{vm}->{$node}->{nics} = $vmnics; $updatetable->{vm}->{$node}->{nicmodel} = $vmnicnicmodel; + $updatetable->{vm}->{$node}->{othersettings} = "nodefromrscan"; $updatetable->{mac}->{$node}->{mac} = $mac; $updatetable->{vpd}->{$node}->{uuid} = $uuid; + $updatetable->{nodelist}->{$node}->{groups} = "vm,all"; $updatetable->{nodetype}->{$node}->{arch} = $arch; $updatetable->{nodehm}->{$node}->{mgt} = "kvm"; + $updatetable->{nodehm}->{$node}->{serialport} = "0"; + $updatetable->{nodehm}->{$node}->{serialspeed} = "115200"; + $updatetable->{kvm_nodedata}->{$node}->{xml} = $currxml; } } if ($stanza) { @@ -3276,7 +3325,7 @@ sub rscan { my @data; foreach (@{$host2kvm{$host}}) { my $info = $_; - foreach (split(',', $info)) { + foreach (split(':', $info)) { my $attr = $_; push @data, "$attr"; } From 3d0fdc94c1d9391a881172b0b4ddd6985b1ce8d7 Mon Sep 17 00:00:00 2001 From: XuWei Date: Fri, 6 May 2016 02:24:35 -0400 Subject: [PATCH 009/310] Fix issue #1048, Resolve or clean up minor issues on getinstdisk from code review --- .../share/xcat/install/scripts/getinstdisk | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/xCAT-server/share/xcat/install/scripts/getinstdisk b/xCAT-server/share/xcat/install/scripts/getinstdisk index 720469e98..3de806db0 100644 --- a/xCAT-server/share/xcat/install/scripts/getinstdisk +++ b/xCAT-server/share/xcat/install/scripts/getinstdisk @@ -26,7 +26,7 @@ has_awk=$(find /usr/* -name "awk") utolcmd="sed -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/" -tmpfile=$tmpdir"/getinstalldisk_" +tmpfile="$tmpdir/getinstalldisk_" if [ -z "$install_disk" ]; then @@ -107,7 +107,7 @@ if [ -z "$install_disk" ]; then break done - umount $mount_dir || echo "[get_install_disk] $partition umount failed." + umount -l $mount_dir || echo "[get_install_disk] $partition umount failed." else echo "[get_install_disk] Partition $partition mount failed or the partition is swap." fi @@ -122,8 +122,11 @@ if [ -z "$install_disk" ]; then fi rmdir $mount_dir; - rm $tmpfile*; - + + for file in $tmpfile*; do + rm $file; + done + has_wwn=0 has_path=0 file_pre="" @@ -194,8 +197,11 @@ if [ -z "$install_disk" ]; then if [ "$install_file" ] && [ -s $install_file ]; then install_disk=/dev/$(cat $install_file | grep -v "^$" | sort -k 2 -b | cut -d " " -f1 | head -n 1) echo "[get_install_disk]The install_disk is $install_disk by sorting $file_pre and DRIVER." - fi - rm $tmpfile*; + fi + + for file in $tmpfile*; do + rm $file; + done fi rm -rf $tmpdir; From 23e124ac2d8f7c237b222452927b8738e378a267 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Thu, 12 May 2016 13:33:28 -0400 Subject: [PATCH 010/310] Modify the getinstdisk to create a temporary file called /tmp/xcat.install_disk so that it's easier for the admin who is debugging the install to know which files are created by xCAT --- .../admin-guides/references/man5/linuximage.5.rst | 2 +- .../admin-guides/references/man7/osimage.7.rst | 2 +- perl-xCAT/xCAT/Schema.pm | 2 +- xCAT-server/lib/perl/xCAT/Template.pm | 11 +++++------ .../share/xcat/install/scripts/getinstdisk | 9 +++++---- xCAT-server/share/xcat/install/scripts/pre.pkvm3 | 15 ++++++--------- xCAT-server/share/xcat/install/scripts/pre.rh | 15 ++++++--------- .../share/xcat/install/scripts/pre.rh.rhels7 | 15 ++++++--------- xCAT-server/share/xcat/install/scripts/pre.sles | 15 ++++++--------- .../share/xcat/install/ubuntu/compute.tmpl | 4 ++-- 10 files changed, 39 insertions(+), 51 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man5/linuximage.5.rst b/docs/source/guides/admin-guides/references/man5/linuximage.5.rst index 1028e48ac..f9855f147 100644 --- a/docs/source/guides/admin-guides/references/man5/linuximage.5.rst +++ b/docs/source/guides/admin-guides/references/man5/linuximage.5.rst @@ -158,7 +158,7 @@ linuximage Attributes: \ **partitionfile**\ - The path of the configuration file which will be used to partition the disk for the node. For stateful osimages,two types of files are supported: "" which contains a partitioning definition that will be inserted directly into the generated autoinst configuration file and must be formatted for the corresponding OS installer (e.g. kickstart for RedHat, autoyast for SLES, pressed for Ubuntu). "s:" which specifies a shell script that will be run from the OS installer configuration file %pre section; the script must write the correct partitioning definition into the file /tmp/partitionfile on the node which will be included into the configuration file during the install process. For statelite osimages, partitionfile should specify ""; see the xCAT Statelite documentation for the xCAT defined format of this configuration file.For Ubuntu, besides "" or "s:", the disk name(s) to partition must be specified in traditional, non-devfs format, delimited with space, it can be specified in 2 forms: "d:" which contains the disk name(s) to partition and "s:d:" which runs in pressed/early_command and writes the disk names into the "/tmp/install_disk" . To support other specific partition methods such as RAID or LVM in Ubuntu, some additional preseed values should be specified, these values can be specified with "c:" which contains the additional pressed entries in "d-i ..." form and "s:c:" which runs in pressed/early_command and set the preseed values with "debconf-set". The multiple values should be delimited with comma "," + The path of the configuration file which will be used to partition the disk for the node. For stateful osimages,two types of files are supported: "" which contains a partitioning definition that will be inserted directly into the generated autoinst configuration file and must be formatted for the corresponding OS installer (e.g. kickstart for RedHat, autoyast for SLES, pressed for Ubuntu). "s:" which specifies a shell script that will be run from the OS installer configuration file %pre section; the script must write the correct partitioning definition into the file /tmp/partitionfile on the node which will be included into the configuration file during the install process. For statelite osimages, partitionfile should specify ""; see the xCAT Statelite documentation for the xCAT defined format of this configuration file.For Ubuntu, besides "" or "s:", the disk name(s) to partition must be specified in traditional, non-devfs format, delimited with space, it can be specified in 2 forms: "d:" which contains the disk name(s) to partition and "s:d:" which runs in pressed/early_command and writes the disk names into the "/tmp/xcat.install_disk" . To support other specific partition methods such as RAID or LVM in Ubuntu, some additional preseed values should be specified, these values can be specified with "c:" which contains the additional pressed entries in "d-i ..." form and "s:c:" which runs in pressed/early_command and set the preseed values with "debconf-set". The multiple values should be delimited with comma "," diff --git a/docs/source/guides/admin-guides/references/man7/osimage.7.rst b/docs/source/guides/admin-guides/references/man7/osimage.7.rst index 23ac6bd49..308479527 100644 --- a/docs/source/guides/admin-guides/references/man7/osimage.7.rst +++ b/docs/source/guides/admin-guides/references/man7/osimage.7.rst @@ -279,7 +279,7 @@ osimage Attributes: \ **partitionfile**\ (linuximage.partitionfile, winimage.partitionfile) - The path of the configuration file which will be used to partition the disk for the node. For stateful osimages,two types of files are supported: "" which contains a partitioning definition that will be inserted directly into the generated autoinst configuration file and must be formatted for the corresponding OS installer (e.g. kickstart for RedHat, autoyast for SLES, pressed for Ubuntu). "s:" which specifies a shell script that will be run from the OS installer configuration file %pre section; the script must write the correct partitioning definition into the file /tmp/partitionfile on the node which will be included into the configuration file during the install process. For statelite osimages, partitionfile should specify ""; see the xCAT Statelite documentation for the xCAT defined format of this configuration file.For Ubuntu, besides "" or "s:", the disk name(s) to partition must be specified in traditional, non-devfs format, delimited with space, it can be specified in 2 forms: "d:" which contains the disk name(s) to partition and "s:d:" which runs in pressed/early_command and writes the disk names into the "/tmp/install_disk" . To support other specific partition methods such as RAID or LVM in Ubuntu, some additional preseed values should be specified, these values can be specified with "c:" which contains the additional pressed entries in "d-i ..." form and "s:c:" which runs in pressed/early_command and set the preseed values with "debconf-set". The multiple values should be delimited with comma "," + The path of the configuration file which will be used to partition the disk for the node. For stateful osimages,two types of files are supported: "" which contains a partitioning definition that will be inserted directly into the generated autoinst configuration file and must be formatted for the corresponding OS installer (e.g. kickstart for RedHat, autoyast for SLES, pressed for Ubuntu). "s:" which specifies a shell script that will be run from the OS installer configuration file %pre section; the script must write the correct partitioning definition into the file /tmp/partitionfile on the node which will be included into the configuration file during the install process. For statelite osimages, partitionfile should specify ""; see the xCAT Statelite documentation for the xCAT defined format of this configuration file.For Ubuntu, besides "" or "s:", the disk name(s) to partition must be specified in traditional, non-devfs format, delimited with space, it can be specified in 2 forms: "d:" which contains the disk name(s) to partition and "s:d:" which runs in pressed/early_command and writes the disk names into the "/tmp/xcat.install_disk" . To support other specific partition methods such as RAID or LVM in Ubuntu, some additional preseed values should be specified, these values can be specified with "c:" which contains the additional pressed entries in "d-i ..." form and "s:c:" which runs in pressed/early_command and set the preseed values with "debconf-set". The multiple values should be delimited with comma "," or diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index 402d1aa0a..7203a6570 100755 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -783,7 +783,7 @@ use xCAT::ExtTab; permission => 'The mount permission of /.statelite directory is used, its default value is 755', dump => qq{The NFS directory to hold the Linux kernel dump file (vmcore) when the node with this image crashes, its format is "nfs:///". If you want to use the node's "xcatmaster" (its SN or MN), can be left blank. For example, "nfs:///" means the NFS directory to hold the kernel dump file is on the node's SN, or MN if there's no SN.}, crashkernelsize => 'the size that assigned to the kdump kernel. If the kernel size is not set, 256M will be the default value.', - partitionfile => 'The path of the configuration file which will be used to partition the disk for the node. For stateful osimages,two types of files are supported: "" which contains a partitioning definition that will be inserted directly into the generated autoinst configuration file and must be formatted for the corresponding OS installer (e.g. kickstart for RedHat, autoyast for SLES, pressed for Ubuntu). "s:" which specifies a shell script that will be run from the OS installer configuration file %pre section; the script must write the correct partitioning definition into the file /tmp/partitionfile on the node which will be included into the configuration file during the install process. For statelite osimages, partitionfile should specify ""; see the xCAT Statelite documentation for the xCAT defined format of this configuration file.For Ubuntu, besides "" or "s:", the disk name(s) to partition must be specified in traditional, non-devfs format, delimited with space, it can be specified in 2 forms: "d:" which contains the disk name(s) to partition and "s:d:" which runs in pressed/early_command and writes the disk names into the "/tmp/install_disk" . To support other specific partition methods such as RAID or LVM in Ubuntu, some additional preseed values should be specified, these values can be specified with "c:" which contains the additional pressed entries in "d-i ..." form and "s:c:" which runs in pressed/early_command and set the preseed values with "debconf-set". The multiple values should be delimited with comma "," ', + partitionfile => 'The path of the configuration file which will be used to partition the disk for the node. For stateful osimages,two types of files are supported: "" which contains a partitioning definition that will be inserted directly into the generated autoinst configuration file and must be formatted for the corresponding OS installer (e.g. kickstart for RedHat, autoyast for SLES, pressed for Ubuntu). "s:" which specifies a shell script that will be run from the OS installer configuration file %pre section; the script must write the correct partitioning definition into the file /tmp/partitionfile on the node which will be included into the configuration file during the install process. For statelite osimages, partitionfile should specify ""; see the xCAT Statelite documentation for the xCAT defined format of this configuration file.For Ubuntu, besides "" or "s:", the disk name(s) to partition must be specified in traditional, non-devfs format, delimited with space, it can be specified in 2 forms: "d:" which contains the disk name(s) to partition and "s:d:" which runs in pressed/early_command and writes the disk names into the "/tmp/xcat.install_disk" . To support other specific partition methods such as RAID or LVM in Ubuntu, some additional preseed values should be specified, these values can be specified with "c:" which contains the additional pressed entries in "d-i ..." form and "s:c:" which runs in pressed/early_command and set the preseed values with "debconf-set". The multiple values should be delimited with comma "," ', driverupdatesrc => 'The source of the drivers which need to be loaded during the boot. Two types of driver update source are supported: Driver update disk and Driver rpm package. The value for this attribute should be comma separated sources. Each source should be the format tab:full_path_of_srouce_file. The tab keyword can be: dud (for Driver update disk) and rpm (for driver rpm). If missing the tab, the rpm format is the default. e.g. dud:/install/dud/dd.img,rpm:/install/rpm/d.rpm', comments => 'Any user-written notes.', disable => "Set to 'yes' or '1' to comment out this row.", diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index c2ba52cd6..0fe3cb4a3 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -411,7 +411,7 @@ sub subvars { if ($diskfile && $doneincludes) { - #the content of the specified file is the disknames to partition or a script which can write disk names into /tmp/install_disk + # The content of the specified file is the disknames to partition or a script which can write disk names into /tmp/xcat.install_disk # split the disk file out from the $inc ($inc, $diskcontent) = split(/FFFFFFFFFFFFPARTITIONDISKFILESTART\n/, $inc); ($diskcontent,$res) = split(/\nFFFFFFFFFFFFPARTITIONDISKFILEEND/, $diskcontent); @@ -433,9 +433,8 @@ sub subvars { $diskcontent .= "chmod 755 /tmp/diskscript\n"; $diskcontent .= "/tmp/diskscript\n"; }else{ - # Put the code to decode the preseed disk file - #$diskcontent .= "python -c 'import base64; print base64.b64decode(open(\"/tmp/diskscript.enc\",\"rb\").read())' >/tmp/install_disk\n"; - $diskcontent .= "base64decode/tmp/install_disk\n"; + # Put the code to decode the preseed disk file + $diskcontent .= "base64decode /tmp/xcat.install_disk\n"; } #replace the #XCA_PARTMAN_DISK_SCRIPT# @@ -444,10 +443,10 @@ sub subvars { } elsif ("ubuntu" eq $platform) { my $default_script = " wget http://`cat /tmp/xcatserver`".$ENV{INSTALLDIR}."/autoinst/getinstdisk; chmod u+x getinstdisk; ./getinstdisk;"; - $inc =~ s/#INCLUDE_GET_FIRST_DISK_SCRIPT#/$default_script/; + $inc =~ s/#INCLUDE_GET_INSTALL_DISK_SCRIPT#/$default_script/; } else { - $inc =~ s/#INCLUDE_GET_FIRST_DISK_SCRIPT#/ /; + $inc =~ s/#INCLUDE_GET_INSTALL_DISK_SCRIPT#/ /; } diff --git a/xCAT-server/share/xcat/install/scripts/getinstdisk b/xCAT-server/share/xcat/install/scripts/getinstdisk index 720469e98..bc8efa338 100644 --- a/xCAT-server/share/xcat/install/scripts/getinstdisk +++ b/xCAT-server/share/xcat/install/scripts/getinstdisk @@ -13,12 +13,13 @@ # type, select the first one. # 3. Select the default one: /dev/sda. # -# Output: /tmp/install_disk +# Output: /tmp/xcat.install_disk # #----------------------------------------------------------- install_disk="" -rm -f /tmp/install_disk +install_disk_file="/tmp/xcat.install_disk" + tmpdir="/tmp/xcat.getinstalldisk" mkdir -p $tmpdir @@ -205,5 +206,5 @@ if [ -z "$install_disk" ]; then echo "[get_install_disk]The default install_disk is $install_disk." fi -# Output the result to /tmp/install_disk file -echo $install_disk > /tmp/install_disk +# Output the result to $install_disk_file +echo $install_disk > $install_disk_file diff --git a/xCAT-server/share/xcat/install/scripts/pre.pkvm3 b/xCAT-server/share/xcat/install/scripts/pre.pkvm3 index bda6cced5..2e7df51a0 100755 --- a/xCAT-server/share/xcat/install/scripts/pre.pkvm3 +++ b/xCAT-server/share/xcat/install/scripts/pre.pkvm3 @@ -3,16 +3,13 @@ shopt -s nullglob -#The script getinstdisk is common for rh/sles/pkvm/ubuntu, it will write the install_disk into /tmp/install_disk file +# +# The getinstdisk script is common for RHEL/SLES/PowerKVM/Ubuntu. +# It will attempt to select the install disk and write the selection to /tmp/xcat.install_disk +# #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/getinstdisk# -if [ -e "/tmp/install_disk" ]; then - instdisk=`cat /tmp/install_disk` -fi - -# Could not determine the install disk for whatever reason, -# try the default /dev/sda -if [ -z "$instdisk" ]; then - instdisk="/dev/sda" +if [ -e "/tmp/xcat.install_disk" ]; then + instdisk=`cat /tmp/xcat.install_disk` fi echo "part PV.01 --ondisk=$instdisk" >> /tmp/partitioning diff --git a/xCAT-server/share/xcat/install/scripts/pre.rh b/xCAT-server/share/xcat/install/scripts/pre.rh index 9dd9883f9..79b28a57d 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.rh +++ b/xCAT-server/share/xcat/install/scripts/pre.rh @@ -184,18 +184,15 @@ fi #TODO: pick a likely non-SAN target if possible shopt -s nullglob -#The script getinstdisk is common for rh/sles/pkvm/ubuntu, it will write the install_disk into /tmp/install_disk file +# +# The getinstdisk script is common for RHEL/SLES/PowerKVM/Ubuntu. +# It will attempt to select the install disk and write the selection to /tmp/xcat.install_disk +# #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/getinstdisk# -if [ -e "/tmp/install_disk" ]; then - instdisk=`cat /tmp/install_disk` +if [ -e "/tmp/xcat.install_disk" ]; then + instdisk=`cat /tmp/xcat.install_disk` fi -# Could not determine the install disk for whatever reason, -# try the default /dev/sda -if [ -z "$instdisk" ]; then - instdisk="/dev/sda" -fi - modprobe ext4 >& /dev/null modprobe ext4dev >& /dev/null diff --git a/xCAT-server/share/xcat/install/scripts/pre.rh.rhels7 b/xCAT-server/share/xcat/install/scripts/pre.rh.rhels7 index 36fb944b9..01bbe8882 100755 --- a/xCAT-server/share/xcat/install/scripts/pre.rh.rhels7 +++ b/xCAT-server/share/xcat/install/scripts/pre.rh.rhels7 @@ -148,16 +148,13 @@ fi #TODO: pick a likely non-SAN target if possible shopt -s nullglob -#The script getinstdisk is common for rh/sles/pkvm/ubuntu, it will write the install_disk into /tmp/install_disk file +# +# The getinstdisk script is common for RHEL/SLES/PowerKVM/Ubuntu. +# It will attempt to select the install disk and write the selection to /tmp/xcat.install_disk +# #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/getinstdisk# -if [ -e "/tmp/install_disk" ]; then - instdisk=`cat /tmp/install_disk` -fi - -# Could not determine the install disk for whatever reason, -# try the default /dev/sda -if [ -z "$instdisk" ]; then - instdisk="/dev/sda" +if [ -e "/tmp/xcat.install_disk" ]; then + instdisk=`cat /tmp/xcat.install_disk` fi modprobe ext4 >& /dev/null diff --git a/xCAT-server/share/xcat/install/scripts/pre.sles b/xCAT-server/share/xcat/install/scripts/pre.sles index 600cc5829..f11ad0517 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.sles +++ b/xCAT-server/share/xcat/install/scripts/pre.sles @@ -135,16 +135,13 @@ fi shopt -s nullglob -#The script getinstdisk is common for rh/sles/pkvm/ubuntu, it will write the install_disk into /tmp/install_disk file +# +# The getinstdisk script is common for RHEL/SLES/PowerKVM/Ubuntu. +# It will attempt to select the install disk and write the selection to /tmp/xcat.install_disk +# #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/getinstdisk# -if [ -e "/tmp/install_disk" ]; then - instdisk=`cat /tmp/install_disk` -fi - -# Could not determine the install disk for whatever reason, -# try the default /dev/sda -if [ -z "$instdisk" ]; then - instdisk="/dev/sda" +if [ -e "/tmp/xcat.install_disk" ]; then + instdisk=`cat /tmp/xcat.install_disk` fi diff --git a/xCAT-server/share/xcat/install/ubuntu/compute.tmpl b/xCAT-server/share/xcat/install/ubuntu/compute.tmpl index cf7739aca..15b9d7056 100644 --- a/xCAT-server/share/xcat/install/ubuntu/compute.tmpl +++ b/xCAT-server/share/xcat/install/ubuntu/compute.tmpl @@ -52,8 +52,8 @@ d-i partman-md/device_remove_md boolean true #create the /tmp/partitionfile based on the uefi or legacy bios d-i partman/early_command string \ { \ -#INCLUDE_GET_FIRST_DISK_SCRIPT# \ - debconf-set partman-auto/disk "$(cat /tmp/install_disk)"; \ +#INCLUDE_GET_INSTALL_DISK_SCRIPT# \ + debconf-set partman-auto/disk "$(cat /tmp/xcat.install_disk)"; \ } >>/tmp/pre-install.log 2>&1 d-i partman-auto/expert_recipe_file string /tmp/partitionfile From d4a8bc6b6a6bcca6e08b92f0379a980b5e3f0a09 Mon Sep 17 00:00:00 2001 From: ertaozh Date: Thu, 19 May 2016 04:36:18 -0400 Subject: [PATCH 011/310] fix issue 1115: Don't run rspconfig after hardware discovery finished for servers Other than S822L(TLT) --- xCAT-genesis-scripts/bin/dodiscovery | 5 +++++ xCAT-server/lib/xcat/plugins/nodediscover.pm | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/xCAT-genesis-scripts/bin/dodiscovery b/xCAT-genesis-scripts/bin/dodiscovery index 8e139dfa9..d29d48ced 100755 --- a/xCAT-genesis-scripts/bin/dodiscovery +++ b/xCAT-genesis-scripts/bin/dodiscovery @@ -141,6 +141,11 @@ if [ "$IsStatic" ]; then fi fi +# Check whether the hardware support in-band BMC configuration with the IPMI device +if [ -r /dev/ipmi0 -o -r /dev/ipmi/0 -o -r /dev/ipmidev/0 ]; then + echo "1" >> /tmp/discopacket +fi + #so we have some cases where DMI table explictly records every function number, and some where only first function is enumerated #so for each onboard device, we record it. If it is also the first function, we'll seek out other function numbers and append #if that other function number does not show up in its own dmi type 41 record diff --git a/xCAT-server/lib/xcat/plugins/nodediscover.pm b/xCAT-server/lib/xcat/plugins/nodediscover.pm index 1c3372856..2f52069b2 100644 --- a/xCAT-server/lib/xcat/plugins/nodediscover.pm +++ b/xCAT-server/lib/xcat/plugins/nodediscover.pm @@ -371,8 +371,16 @@ sub process_request { $callback->({error=> ["The node [$node] should have a correct IP address which belongs to the management network."], errorcode=>["1"]}); return; } - if ($request->{arch}->[0] =~ /ppc/ and $request->{platform}->[0] =~ /PowerNV/) { - # This is a slow thing to do, and frequently breaks things thoroughly + if (defined($request->{bmcinband})) { + syslog("local4|info", "The attribute bmcinband is specified, just remove the temp BMC node if there is"); + if (defined($request->{pbmc_node}) and defined($request->{pbmc_node}->[0])) { + my $bmc_node = $request->{pbmc_node}->[0]; + syslog("local4|info", "Find BMC $bmc_node, so remove it"); + $doreq->({ command => ['rmdef'], arg => [$bmc_node]}); + } + } else { + # Only BMC that doesn't support in-band configuration need to run rspconfig out-of-band, such as S822L running in OPAL model + syslog("local4|info", "No bmcinband specified, need to configure BMC out-of-band"); xCAT::Utils->cleanup_for_powerLE_hardware_discovery($request, $doreq); } From ff0ce0cc3841fb7b65dec6e9c75446cadb7c55bc Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Fri, 20 May 2016 04:34:49 -0400 Subject: [PATCH 012/310] complete --- .../autotest/testcase/migration/ubuntule_migration1_p8le | 4 ++-- xCAT-test/autotest/testcase/migration/ubuntux_migration1_vm | 3 ++- xCAT-test/autotest/testcase/migration/ubuntux_migration2_vm | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/xCAT-test/autotest/testcase/migration/ubuntule_migration1_p8le b/xCAT-test/autotest/testcase/migration/ubuntule_migration1_p8le index 4f8dedf11..27a678fa9 100644 --- a/xCAT-test/autotest/testcase/migration/ubuntule_migration1_p8le +++ b/xCAT-test/autotest/testcase/migration/ubuntule_migration1_p8le @@ -18,8 +18,8 @@ cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-ins check:rc==0 cmd:rpower $$CN boot check:rc==0 -cmd:sleep 300 -cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 300 ];then break;fi done +cmd:sleep 600 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 60;((a++));if [ $a -gt 50 ];then break;fi done cmd:ping $$CN -c 3 check:output=~64 bytes from $$CN cmd:lsdef -l $$CN | grep status diff --git a/xCAT-test/autotest/testcase/migration/ubuntux_migration1_vm b/xCAT-test/autotest/testcase/migration/ubuntux_migration1_vm index a9aeea6aa..39dc90627 100644 --- a/xCAT-test/autotest/testcase/migration/ubuntux_migration1_vm +++ b/xCAT-test/autotest/testcase/migration/ubuntux_migration1_vm @@ -17,7 +17,8 @@ cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-ins check:rc==0 cmd:rpower $$CN boot check:rc==0 -cmd:sleep 3000 +cmd:sleep 600 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 60;((a++));if [ $a -gt 50 ];then break;fi done cmd:ping $$CN -c 3 check:output=~64 bytes from $$CN cmd:lsdef -l $$CN | grep status diff --git a/xCAT-test/autotest/testcase/migration/ubuntux_migration2_vm b/xCAT-test/autotest/testcase/migration/ubuntux_migration2_vm index bc16ee2c8..cfa2f11b4 100644 --- a/xCAT-test/autotest/testcase/migration/ubuntux_migration2_vm +++ b/xCAT-test/autotest/testcase/migration/ubuntux_migration2_vm @@ -17,7 +17,8 @@ cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-ins check:rc==0 cmd:rpower $$CN boot check:rc==0 -cmd:sleep 3000 +cmd:sleep 600 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 60;((a++));if [ $a -gt 50 ];then break;fi done cmd:ping $$CN -c 3 check:output=~64 bytes from $$CN cmd:lsdef -l $$CN | grep status From 33bcae42d0d03829b4caa765e80e44c564b01698 Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Fri, 20 May 2016 04:57:26 -0400 Subject: [PATCH 013/310] add xCATreg and installation cases --- xCAT-server/share/xcat/tools/xCATreg | 17 +++++++++++------ .../Diskless_installation_flat_p8_le | 2 ++ .../installation/Full_installation_flat_p8_le | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/xCAT-server/share/xcat/tools/xCATreg b/xCAT-server/share/xcat/tools/xCATreg index 2ad97c79f..879790209 100755 --- a/xCAT-server/share/xcat/tools/xCATreg +++ b/xCAT-server/share/xcat/tools/xCATreg @@ -297,6 +297,8 @@ sub mn_install { &runcmd("makedhcp -n"); &runcmd("makedns -n"); + &runcmd("chdef $confkeys{$mn} status="); + &runcmd("lsdef -l $confkeys{$mn}|grep status"); &runcmd("nodeset $confkeys{$mn} osimage=$osimage"); if( $arch =~ /x86_64/ || $arch =~ /ppc64le/ || $arch =~ /ppc64el/){ @@ -305,12 +307,15 @@ sub mn_install { &runcmd("rnetboot $confkeys{$mn}"); } - if($mn !~ /ubuntu/){ - &runcmd("sleep 300"); - &runcmd("a=0;while ! `lsdef -l $confkeys{$mn}|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ \$a -gt 200 ];then break;fi done");} - else{ - &runcmd("sleep 1800"); - } + &runcmd("sleep 600"); + &runcmd("a=0;while ! `lsdef -l $confkeys{$mn}|grep status|grep booted >/dev/null`; do sleep 30;((a++));if [ \$a -gt 100 ];then break;fi done"); + +# if($mn !~ /ubuntu/){ +# &runcmd("sleep 300"); +# &runcmd("a=0;while ! `lsdef -l $confkeys{$mn}|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ \$a -gt 200 ];then break;fi done");} +# else{ +# &runcmd("sleep 1800"); +# } &runcmd("lsdef -l $confkeys{$mn}|grep status|grep booted >/dev/null"); if($?){ diff --git a/xCAT-test/autotest/testcase/installation/Diskless_installation_flat_p8_le b/xCAT-test/autotest/testcase/installation/Diskless_installation_flat_p8_le index 0e95955f5..14d4d3ec5 100644 --- a/xCAT-test/autotest/testcase/installation/Diskless_installation_flat_p8_le +++ b/xCAT-test/autotest/testcase/installation/Diskless_installation_flat_p8_le @@ -24,6 +24,8 @@ cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute check:rc==0 cmd:packimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute check:rc==0 +cmd:chdef $$CN status= +check:rc==0 cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute check:rc==0 cmd:if [[ "__GETNODEATTR($$CN,mgt)__" = "ipmi" ]]; then rsetboot $$CN net; fi diff --git a/xCAT-test/autotest/testcase/installation/Full_installation_flat_p8_le b/xCAT-test/autotest/testcase/installation/Full_installation_flat_p8_le index 579f583f9..4ff715634 100644 --- a/xCAT-test/autotest/testcase/installation/Full_installation_flat_p8_le +++ b/xCAT-test/autotest/testcase/installation/Full_installation_flat_p8_le @@ -20,7 +20,7 @@ cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-ins check:rc==0 cmd:rpower $$CN boot check:rc==0 -cmd:sleep 300 +cmd:sleep 600 cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 60;((a++));if [ $a -gt 50 ];then break;fi done cmd:ping $$CN -c 3 check:output=~64 bytes from $$CN From a8d0293b89dea5f6d4cd91336a0022e868a62a75 Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Fri, 20 May 2016 09:23:52 -0400 Subject: [PATCH 014/310] change sleep type --- .../testcase/installation/reg_linux_SN_installation_hierarchy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-test/autotest/testcase/installation/reg_linux_SN_installation_hierarchy b/xCAT-test/autotest/testcase/installation/reg_linux_SN_installation_hierarchy index c7ed81bb0..a5ec315bc 100644 --- a/xCAT-test/autotest/testcase/installation/reg_linux_SN_installation_hierarchy +++ b/xCAT-test/autotest/testcase/installation/reg_linux_SN_installation_hierarchy @@ -67,8 +67,8 @@ check:rc==0 cmd:if [[ "__GETNODEATTR($$SN,arch)__" =~ "ppc64" ]]; then rnetboot $$SN;elif [[ "__GETNODEATTR($$SN,arch)__" =~ "x86_64" ]];then rpower $$SN boot; fi check:rc==0 -cmd:sleep 1800 -cmd:a=0;while ! `lsdef -l $$SN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 400 ];then break;fi done +cmd:sleep 600 +cmd:a=0;while ! `lsdef -l $$SN|grep status|grep booted >/dev/null`; do sleep 60;((a++));if [ $a -gt 70 ];then break;fi done cmd:ping $$SN -c 3 check:rc==0 From 3a6154f30d642001a46b760de7a2f799d7323dbf Mon Sep 17 00:00:00 2001 From: "litingt@cn.ibm.com" Date: Tue, 24 May 2016 01:28:22 -0400 Subject: [PATCH 015/310] delete invalid case --- .../linux_sn_installation_ppc64_redhat | 63 ------------------- 1 file changed, 63 deletions(-) delete mode 100644 xCAT-test/autotest/testcase/installation/linux_sn_installation_ppc64_redhat diff --git a/xCAT-test/autotest/testcase/installation/linux_sn_installation_ppc64_redhat b/xCAT-test/autotest/testcase/installation/linux_sn_installation_ppc64_redhat deleted file mode 100644 index 8e14b0bd7..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_sn_installation_ppc64_redhat +++ /dev/null @@ -1,63 +0,0 @@ -start:Linux_sn_installation_ppc64_redhat -os:Linux -cmd:chdef -t node -p $$SN groups=lpar,all -check:rc==0 -cmd:chdef -t group -o service arch=PPC64 os=$$SNOS nodetype=osi profile=service netboot=yaboot installnic=mac primarynic=mac setupnfs=1 setupdhcp=1 setuptftp=1 setupnameserver=1 setupconserver=1 -check:rc==0 -cmd:chdef -t group -p service postscripts=servicenode,odbcsetup -check:rc==0 -cmd:makedns -n -check:rc==0 -cmd:makeconservercf -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$SN -check:output=~$$SN -cmd:sleep 20 -cmd:getmacs -D $$SN -check:rc==0 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:cat /var/lib/dhcpd/dhcpd.leases| grep $$SN -check:output=~$$SN -cmd:chdef -t site clustersite installloc="/install" -check:rc==0 -cmd:mkdir -p /install/post/otherpkgs/$$SNOS/ppc64/xcat -check:rc==0 -cmd:cp -r $$XCATCORE /install/post/otherpkgs/$$SNOS/ppc64/xcat -check:rc==0 -cmd:cp -r $$XCATDEP /install/post/otherpkgs/$$SNOS/ppc64/xcat -check:rc==0 -cmd:cd /install/post/otherpkgs/$$SNOS/ppc64/xcat/xcat-core && createrepo . -check:rc==0 -cmd:cd /install/post/otherpkgs/$$SNOS/ppc64/xcat/xcat-dep/rh6/ppc64 && createrepo . -check:rc==0 -cmd:cd /install/$$SNOS/ppc64/Server/repodata && createrepo -g *comps-rhel6-Server.xml.gz . -check:rc==0 -cmd:nodeset service osimage=__GETNODEATTR($$SN,os)__-__GETNODEATTR($$SN,arch)__-install-service -check:rc==0 -cmd:rnetboot service -check:rc==0 -cmd:sleep 1200 -cmd:ping $$SN -c 3 -check:output=~64 bytes from $$SN -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$SN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:xdsh $$SN "ps -ef |grep xcatd" -check:rc==0 -check:output=~xcatd: -cmd:xdsh $$SN "lsdef" -check:rc==0 -check:output=~$$SN: $$SN -cmd:xdsh $$SN "mount" -check:rc==0 -check:output=~/install on /install -cmd:xdsh $$SN "mount" -check:rc==0 -check:output=~/tftpboot on /tftpbootl -end - From 8fb16e5bedf2fab54ad016281ed63a0dab68bf36 Mon Sep 17 00:00:00 2001 From: "litingt@cn.ibm.com" Date: Tue, 24 May 2016 01:30:37 -0400 Subject: [PATCH 016/310] fix defect 1152 to use nslookup correctly --- xCAT-test/autotest/testcase/makedns/cases0 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-test/autotest/testcase/makedns/cases0 b/xCAT-test/autotest/testcase/makedns/cases0 index eb80188df..af2aa5f49 100644 --- a/xCAT-test/autotest/testcase/makedns/cases0 +++ b/xCAT-test/autotest/testcase/makedns/cases0 @@ -72,7 +72,7 @@ check:rc==0 cmd:cat /etc/bind/named.conf check:rc==0 check:output~=zone "100.100.100.IN-ADDR.ARPA." -cmd:nslookup dnstestnode +cmd:nslookup dnstestnode $$MN check:output~=Server: $$MN check:output!~(server can't find dnstestnode) cmd:rm -f /etc/hosts From 3797cd99d8ecd0e983abcb40c2120ffdfeb5284d Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Tue, 24 May 2016 04:58:44 -0400 Subject: [PATCH 017/310] update xCATreg --- xCAT-server/share/xcat/tools/xCATreg | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/tools/xCATreg b/xCAT-server/share/xcat/tools/xCATreg index 879790209..04b79c024 100755 --- a/xCAT-server/share/xcat/tools/xCATreg +++ b/xCAT-server/share/xcat/tools/xCATreg @@ -298,7 +298,11 @@ sub mn_install { &runcmd("makedhcp -n"); &runcmd("makedns -n"); &runcmd("chdef $confkeys{$mn} status="); - &runcmd("lsdef -l $confkeys{$mn}|grep status"); + if($?){ + send_msg(0, "[$mn->$confkeys{$mn}][mn_install] Failed to change MN status in current control node"); + return 1; + } + &runcmd("nodeset $confkeys{$mn} osimage=$osimage"); if( $arch =~ /x86_64/ || $arch =~ /ppc64le/ || $arch =~ /ppc64el/){ From 55eb1f28406499b52bb523cdc9ecf309f09c0494 Mon Sep 17 00:00:00 2001 From: penguhyang Date: Tue, 24 May 2016 07:07:42 -0400 Subject: [PATCH 018/310] fix #1093, powerkvm, diskfull, enable the pre-script log can be saved to the CN --- .../install/pkvm/compute.pkvm3.ppc64le.tmpl | 19 +++++++++---------- .../share/xcat/install/scripts/pre.pkvm3 | 9 ++++++++- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/xCAT-server/share/xcat/install/pkvm/compute.pkvm3.ppc64le.tmpl b/xCAT-server/share/xcat/install/pkvm/compute.pkvm3.ppc64le.tmpl index 217b5544d..ca50f7631 100644 --- a/xCAT-server/share/xcat/install/pkvm/compute.pkvm3.ppc64le.tmpl +++ b/xCAT-server/share/xcat/install/pkvm/compute.pkvm3.ppc64le.tmpl @@ -36,22 +36,21 @@ rootpw --iscrypted #CRYPT:passwd:key=system,username=root:password# %pre { -set -x -touch "/startpre" +echo "Running Automated Network Pre-Installation script..." #add the code to determine the disk to partition here #default is /dev/sda #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/pre.pkvm3# -} >>/tmp/prelog 2>&1 +} >>/tmp/pre-install.log 2>&1 %end %post -touch "/startpost" - +mkdir -p /var/log/xcat/ +{ +cat >> /var/log/xcat/xcat.log << "EOF" +%include /tmp/pre-install.log +EOF +echo "Running Automated Network Post-Installation script..." #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.xcat# -touch "/inpost" - -#sleep 1000000 - - +} >>/var/log/xcat/xcat.log 2>&1 %end diff --git a/xCAT-server/share/xcat/install/scripts/pre.pkvm3 b/xCAT-server/share/xcat/install/scripts/pre.pkvm3 index bda6cced5..632f08197 100755 --- a/xCAT-server/share/xcat/install/scripts/pre.pkvm3 +++ b/xCAT-server/share/xcat/install/scripts/pre.pkvm3 @@ -1,3 +1,8 @@ +export XCATDEBUGMODE="#TABLEBLANKOKAY:site:key=xcatdebugmode:value#" +if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then + set -x +fi + #find first available block device (sda or vda likely) #TODO: pick a likely non-SAN target if possible @@ -18,4 +23,6 @@ fi echo "part PV.01 --ondisk=$instdisk" >> /tmp/partitioning echo "volgroup ibmpkvm_rootvg PV.01" >> /tmp/partitioning - +if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then + set +x +fi From 997b4f6b5b5d17b8ad5e1b43c57bcb1057bb3efb Mon Sep 17 00:00:00 2001 From: junxiawang Date: Tue, 24 May 2016 09:11:39 -0400 Subject: [PATCH 019/310] sync xCATreg according to GA build --- xCAT-server/share/xcat/tools/xCATreg | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/xCAT-server/share/xcat/tools/xCATreg b/xCAT-server/share/xcat/tools/xCATreg index 2ad97c79f..88084c575 100755 --- a/xCAT-server/share/xcat/tools/xCATreg +++ b/xCAT-server/share/xcat/tools/xCATreg @@ -294,6 +294,12 @@ sub mn_install { } send_msg(2, "[$mn->$confkeys{$mn}][mn_install] installing $osimage for node $confkeys{$mn}................"); + + if( $arch =~ /x86_64/ || $arch =~ /ppc64le/ || $arch =~ /ppc64el/){ + &runcmd("rmvm $confkeys{$mn} -f -p "); + &runcmd("chdef $confkeys{$mn} mac= "); + &runcmd("mkvm $confkeys{$mn} -s 40G"); + } &runcmd("makedhcp -n"); &runcmd("makedns -n"); @@ -317,6 +323,11 @@ sub mn_install { send_msg(0, "[$mn->$confkeys{$mn}][mn_install] install $osimage for node $confkeys{$mn} failed"); return 1; } + + if($mn =~ /ubuntu/){ + system("xdsh $confkeys{$mn} \"rm -rf /bin/sh\" >/dev/null 2>&1"); + system("xdsh $confkeys{$mn} \"ln -s /bin/bash /bin/sh\""); + } # if($mn =~ /ubuntu/){ # system("updatenode $confkeys{$mn} -P \"confignics -s\" >/dev/null 2>&1"); # system("xdsh $confkeys{$mn} \"iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE\" >/dev/null 2>&1"); @@ -672,9 +683,9 @@ sub install_xcat { } #check if MN is installed successful - my $lsdefout = `ssh -t $confkeys{$mn} 'bash -l -i -c "lsdef -v"'`; - chomp($lsdefout); - if($lsdefout !~ /^lsdef - Version/ ){ + my $lsdefout = `xdsh $confkeys{$mn} '/opt/xcat/bin/lsdef -v'`; + chomp($lsdefout); + if($lsdefout !~ /lsdef - Version/ ){ send_msg(0, "[$mn->$confkeys{$mn}][install_xcat] install xcat in $mn failed"); return 1; } @@ -870,13 +881,15 @@ sub do_test { $rc=system("ssh -t $confkeys{$mn} 'exec bash -l -i -c \"xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -t $diskfull_installation_flat_testcase\"' >/dev/null 2>&1"); send_msg(2, "[$mn->$confkeys{$mn}][do_test] do diskfull installation test in flat mode in $mn.....[done]"); last if($rc != 0); - + + if($mn =~ /ubuntux/){ #set up dockerhosts send_msg(2, "[$mn->$confkeys{$mn}][do_test] setupdockerhost $mn....."); $rc=system("ssh -t $confkeys{$mn} 'exec bash -l -i -c \"xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -t $setup_dockerhost_testcase\"' >/dev/null 2>&1"); send_msg(2, "[$mn->$confkeys{$mn}][do_test] setup dockerhosts $mn.....[done]"); last if($rc != 0); - + } + #commands bundle in flat mode test send_msg(2, "[$mn->$confkeys{$mn}][do_test] doing all commands test in flat mode in $mn....."); $rc=system("ssh -t $confkeys{$mn} 'exec bash -l -i -c \"xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -b $batbundle\"' >/dev/null 2>&1"); From ef3bf0c4376942c0fb1de33dc3b184c9f5d0c347 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 24 May 2016 16:05:26 -0400 Subject: [PATCH 020/310] Fix doc build errors and missing links --- .../run_xcat_in_docker_compose.rst | 5 +- .../advanced/docker/lifecycle_management.rst | 16 +- .../domain_name_resolution.rst | 2 +- .../hamn/high_available_management_node.rst | 2 +- ...ha_mgmt_node_with_raid1_and_disks_move.rst | 2 +- .../hierarchy/databases/mysql_remove.rst | 2 +- .../hierarchy/provision/diskful_sn.rst | 7 +- .../advanced/mixed_cluster/support_matrix.rst | 2 +- .../infiniband/mlnxofed_ib_known_issue.rst | 2 +- .../infiniband/switch_configuration.rst | 2 +- .../restapi_resource/restapi_reference.rst | 1 + docs/source/advanced/sysclone/sysclone.rst | 2 +- docs/source/conf.py | 39 ++- docs/source/developers/doc_guidelines.rst | 255 ------------------ .../developers/guides/docs/doc_guidelines.rst | 18 +- .../basic_concepts/global_cfg/index.rst | 2 +- .../common/deployment/create_img.rst | 2 +- .../common/deployment/deploy_os.rst | 4 - .../common/deployment/install_new_kernel.rst | 2 +- .../deployment/prepostscripts/post_script.rst | 2 + .../syncfile/syncfile_synclist_file.rst | 2 +- .../manage_clusters/common/updatenode.rst | 2 +- .../ppc64le/discovery/config_environment.rst | 3 +- .../ppc64le/discovery/switch_discovery.rst | 6 +- .../ppc64le/diskful/deploy_os.rst | 1 + .../ppc64le/virtual_machines/powerKVM.rst | 2 +- .../references/man1/buildkit.1.rst | 4 +- .../references/man1/geninitrd.1.rst | 2 +- .../references/man1/getadapter.1.rst | 2 +- .../references/man1/getmacs.1.rst | 2 +- .../admin-guides/references/man1/lsve.1.rst | 17 +- .../references/man1/rmkitcomp.1.rst | 2 +- .../references/man1/unregnotif.1.rst | 2 +- .../references/man1/updatenode.1.rst | 8 +- .../admin-guides/references/man1/xdcp.1.rst | 6 +- .../references/man8/tabprune.8.rst | 2 +- .../references/man8/winstall.8.rst | 6 +- .../references/man8/xcatdebug.8.rst | 58 +++- .../install-guides/common/uninstall_xcat.rst | 238 ---------------- docs/source/guides/install-guides/index.rst | 2 + docs/source/security/index.rst | 1 - xCAT-buildkit/pods/man1/buildkit.1.pod | 4 +- xCAT-client/pods/man1/geninitrd.1.pod | 2 +- xCAT-client/pods/man1/getadapter.1.pod | 2 +- xCAT-client/pods/man1/getmacs.1.pod | 2 +- xCAT-client/pods/man1/lsve.1.pod | 7 +- xCAT-client/pods/man1/rmkitcomp.1.pod | 2 +- xCAT-client/pods/man1/unregnotif.1.pod | 2 +- xCAT-client/pods/man1/updatenode.1.pod | 4 +- xCAT-client/pods/man1/xdcp.1.pod | 6 +- xCAT-client/pods/man8/tabprune.8.pod | 4 +- xCAT-client/pods/man8/winstall.8.pod | 6 +- xCAT-client/pods/man8/xcatdebug.8.pod | 10 +- 53 files changed, 192 insertions(+), 596 deletions(-) delete mode 100644 docs/source/developers/doc_guidelines.rst delete mode 100644 docs/source/guides/install-guides/common/uninstall_xcat.rst diff --git a/docs/source/advanced/docker/dockerized_xcat/run_xcat_in_docker_compose.rst b/docs/source/advanced/docker/dockerized_xcat/run_xcat_in_docker_compose.rst index b934a0ce8..5a21e83d8 100644 --- a/docs/source/advanced/docker/dockerized_xcat/run_xcat_in_docker_compose.rst +++ b/docs/source/advanced/docker/dockerized_xcat/run_xcat_in_docker_compose.rst @@ -147,9 +147,10 @@ Known Issues ------------ .. [1] -When you start up xCAT Docker container, you might see an error message at the end of the output like: :: - Couldn't connect to Docker daemon at http+unix://var/run/docker.sock - is it running? If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.` +When you start up xCAT Docker container, you might see an error message at the end of the output like :: + + Couldn't connect to Docker daemon at http+unix://var/run/docker.sock - is it running? If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable. You can ignore it, the container has already been running. It is a Docker bug `#1214 `_ diff --git a/docs/source/advanced/docker/lifecycle_management.rst b/docs/source/advanced/docker/lifecycle_management.rst index 100c71969..2943bd75f 100644 --- a/docs/source/advanced/docker/lifecycle_management.rst +++ b/docs/source/advanced/docker/lifecycle_management.rst @@ -56,17 +56,20 @@ The otherpkglist file should contain the following: At the time of this writing (February 2016), docker package is not available for **ppc64el** architecture from docker.org. You can follow instructions below on how to manually download and install it. -* Download docker engine for ppc64el +* Download docker engine for ppc64el: + :: wget http://launchpadlibrarian.net/251622081/docker.io_1.10.3-0ubuntu4_ppc64el.deb -O /install/docker_ppc64el/docker.io_1.10.3-0ubuntu4_ppc64el.deb -* Configure **otherpkgdir** like this +* Configure **otherpkgdir** like this: + :: otherpkgdir=/install/docker_ppc64el -* The **otherpkglist** file should be +* The **otherpkglist** file should be: + :: # cat /install/custom/ubuntu/ubuntu_docker.pkglist @@ -226,16 +229,19 @@ If things go wrong: * After dockerhost node boots, check contents of **/var/log/xcat/xcat.log** file on the dockerhost for errors. * Verify **nicname** specified in **Preparing setup trust connection for docker service and create docker network object** section exists on the docker host. Depending on the version of Ubuntu OS and host architecture, it could be **eth0**, or **em1**, or **eno1**, or **enp0s1**. Verify by running on the dockerhost + :: ip addr show dev -* Run **ps -ef | grep docker** to verify docker engine is running with configured options. It should look something like +* Run **ps -ef | grep docker** to verify docker engine is running with configured options. It should look something like + :: root 3703 1 0 Apr15 ? 00:12:28 /usr/bin/docker daemon -H unix:///var/run/docker.sock -H tcp://host01:2375 --tls --tlscacert=/root/.docker/ca-cert.pem --tlscert=/root/.docker/dockerhost-cert.pem --tlskey=/root/.docker/dockerhost-cert.pem --tlsverify=true --raw-logs -If the output is missing some options, verify that file **/lib/systemd/system/docker.service** contains the following lines +If the output is missing some options, verify that file **/lib/systemd/system/docker.service** contains the following lines + :: EnvironmentFile=-/etc/default/docker diff --git a/docs/source/advanced/domain_name_resolution/domain_name_resolution.rst b/docs/source/advanced/domain_name_resolution/domain_name_resolution.rst index e5b9ddd12..acf30517d 100644 --- a/docs/source/advanced/domain_name_resolution/domain_name_resolution.rst +++ b/docs/source/advanced/domain_name_resolution/domain_name_resolution.rst @@ -193,7 +193,7 @@ Once **/etc/hosts** is populated with all of the nodes' hostnames and IP address makedns -n -When the **/etc/resolv.conf** files for the compute nodes are created the value of the **nameserver** in /etc/resolv.conf is gotten from **site.nameservers** or **networks.nameservers** if it's specified. :: +When the **/etc/resolv.conf** files for the compute nodes are created the value of the **nameserver** in /etc/resolv.conf is gotten from **site.nameservers** or **networks.nameservers** if it's specified. For example: :: diff --git a/docs/source/advanced/hamn/high_available_management_node.rst b/docs/source/advanced/hamn/high_available_management_node.rst index e6bb3c383..4375d553b 100644 --- a/docs/source/advanced/hamn/high_available_management_node.rst +++ b/docs/source/advanced/hamn/high_available_management_node.rst @@ -55,7 +55,7 @@ The combinations of data synchronization mechanism and manual/automatic failover |Automatic Failover | 4 | **5** | **6** | +-------------------+-------------------------+-----------------+--------------+ -Option 1, :ref:`setup_ha_mgmt_node_with_raid1_and disks_move` +Option 1, :ref:`setup_ha_mgmt_node_with_raid1_and_disks_move` Option 2, :ref:`setup_ha_mgmt_node_with_shared_data` diff --git a/docs/source/advanced/hamn/setup_ha_mgmt_node_with_raid1_and_disks_move.rst b/docs/source/advanced/hamn/setup_ha_mgmt_node_with_raid1_and_disks_move.rst index 806712b30..895775f5e 100644 --- a/docs/source/advanced/hamn/setup_ha_mgmt_node_with_raid1_and_disks_move.rst +++ b/docs/source/advanced/hamn/setup_ha_mgmt_node_with_raid1_and_disks_move.rst @@ -1,4 +1,4 @@ -.. _setup_ha_mgmt_node_with_raid1_and disks_move: +.. _setup_ha_mgmt_node_with_raid1_and_disks_move: Setup HA Mgmt Node With RAID1 and disks move ============================================ diff --git a/docs/source/advanced/hierarchy/databases/mysql_remove.rst b/docs/source/advanced/hierarchy/databases/mysql_remove.rst index f00fbad56..53cc15e71 100644 --- a/docs/source/advanced/hierarchy/databases/mysql_remove.rst +++ b/docs/source/advanced/hierarchy/databases/mysql_remove.rst @@ -12,7 +12,7 @@ If you no longer want to use MySQL/MariaDB to maintain ``xcatdb``, and like to s XCATBYPASS=1 restorexCATdb -p ~/xcat-dbback -* Change to PostgreSQL, please following documentation: :doc:`/guides/admin-guides/large_clusters/databases/postgres_install` +* Change to PostgreSQL, please following documentation: :doc:`/advanced/hierarchy/databases/postgres_install` * Change back to default xCAT database, SQLite (**Note**: xCAT Hierarchy cluster will no longer work) diff --git a/docs/source/advanced/hierarchy/provision/diskful_sn.rst b/docs/source/advanced/hierarchy/provision/diskful_sn.rst index 924298c33..20813fd38 100644 --- a/docs/source/advanced/hierarchy/provision/diskful_sn.rst +++ b/docs/source/advanced/hierarchy/provision/diskful_sn.rst @@ -1,3 +1,6 @@ + +.. _setup_service_node_stateful_label: + Diskful (Stateful) Installation =============================== @@ -103,8 +106,8 @@ the build with fixes from RHEL6 team, once meet this problem, you need to manually select the SAS disk to be the first boot device and boots from the SAS disk. -Update Service Node Diskfull Image ----------------------------------- +Update Service Node Diskful Image +--------------------------------- To update the xCAT software on the Service Node: diff --git a/docs/source/advanced/mixed_cluster/support_matrix.rst b/docs/source/advanced/mixed_cluster/support_matrix.rst index 5e94e1c05..aa895ab0f 100644 --- a/docs/source/advanced/mixed_cluster/support_matrix.rst +++ b/docs/source/advanced/mixed_cluster/support_matrix.rst @@ -46,7 +46,7 @@ Notes: * The support statements refers to hardware control, operating system (os) provisioning, and general purpose system management where we do not see any obvious problems with the indicated combination. -* For diskless mixed cluster support, the initial diskless image must be created on a node running the target operating system version and architecture. see :ref:`Building_a_Stateless_Image_of_a_Different_Architecture_or_OS` for more details. +* For diskless mixed cluster support, the initial diskless image must be created on a node running the target operating system version and architecture. see :doc:`/advanced/mixed_cluster/building_stateless_images` for more details. .. rubric:: Footnotes diff --git a/docs/source/advanced/networks/infiniband/mlnxofed_ib_known_issue.rst b/docs/source/advanced/networks/infiniband/mlnxofed_ib_known_issue.rst index ef0ee44c6..c523de4fa 100644 --- a/docs/source/advanced/networks/infiniband/mlnxofed_ib_known_issue.rst +++ b/docs/source/advanced/networks/infiniband/mlnxofed_ib_known_issue.rst @@ -13,7 +13,7 @@ After you install mellanox derives in rhels7.2 successfully by xCAT, maybe you h Known Issue 2 ------------- -If you want to use ``--add-kernel-support`` attribute in sles12.1 and ppc64le scenario, you will find some dependency packages are not shipped by SLES Server DVDs, such like ``python-devel``, it's shipped in SDK DVDs. xCAT doesn't ship specific pkglist to support such scenario. If you have such requirement, please used ``otherpkglist`` and ``otherpkgs`` attributes to prepare dependency packages repository ahead. If you need help about ``otherpkglist`` and ``otherpkgs``attributes, please refer to :doc:`Add Additional Software Packages `. +If you want to use ``--add-kernel-support`` attribute in sles12.1 and ppc64le scenario, you will find some dependency packages are not shipped by SLES Server DVDs, such like ``python-devel``, it's shipped in SDK DVDs. xCAT doesn't ship specific pkglist to support such scenario. If you have such requirement, please used ``otherpkglist`` and ``otherpkgs`` attributes to prepare dependency packages repository ahead. If you need help about ``otherpkglist`` and ``otherpkgs`` attributes, please refer to :doc:`Add Additional Software Packages `. diff --git a/docs/source/advanced/networks/infiniband/switch_configuration.rst b/docs/source/advanced/networks/infiniband/switch_configuration.rst index b84d4a138..b1c6824bf 100644 --- a/docs/source/advanced/networks/infiniband/switch_configuration.rst +++ b/docs/source/advanced/networks/infiniband/switch_configuration.rst @@ -74,7 +74,7 @@ Configure xdsh for Mellanox Switch ---------------------------------- To run xdsh commands to the Mellanox Switch, you must use the --devicetype input flag to xdsh. In addition, for xCAT versions less than 2.8, you must add a configuration file, please see `Setup ssh connection to the Mellanox Switch`_ section. -For the Mellanox Switch the ``--devicetype`` is ``IBSwitch::Mellanox``. See :doc:`xdsh man page <../../../guides/admin-guides/references/man/xdsh.1.html>` for details. +For the Mellanox Switch the ``--devicetype`` is ``IBSwitch::Mellanox``. See :doc:`xdsh man page ` for details. Now you can run the switch commands from the mn using xdsh. For example: :: diff --git a/docs/source/advanced/restapi/restapi_resource/restapi_reference.rst b/docs/source/advanced/restapi/restapi_resource/restapi_reference.rst index aacfc0cf6..1953a18ba 100644 --- a/docs/source/advanced/restapi/restapi_resource/restapi_reference.rst +++ b/docs/source/advanced/restapi/restapi_resource/restapi_reference.rst @@ -1533,6 +1533,7 @@ Set the name attribute for policy 3. :: #curl -X PUT -k 'https://127.0.0.1/xcatws/policy/3?userName=root&userPW=cluster&pretty=1' -H Content-Type:application/json --data '{"name":"root"}' + POST - Create the policy {policyname}. DataBody: {attr1:v1,att2:v2...}. ``````````````````````````````````````````````````````````````````````` diff --git a/docs/source/advanced/sysclone/sysclone.rst b/docs/source/advanced/sysclone/sysclone.rst index 8801fd7a1..5aa301f80 100644 --- a/docs/source/advanced/sysclone/sysclone.rst +++ b/docs/source/advanced/sysclone/sysclone.rst @@ -40,7 +40,7 @@ This document describes how to install and configure a template node (called gol Prepare the xCAT Management Node for Support Sysclone ````````````````````````````````````````````````````` -How to configure xCAT management node please refer to section :ref:`Install Guides ` +How to configure xCAT management node please refer to section :ref:`install_guides` For support Sysclone, we need to install some extra rpms on management node and the golden client. diff --git a/docs/source/conf.py b/docs/source/conf.py index 3e3d82ae7..b5b6350b3 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -76,7 +76,42 @@ language = None # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = [] +# +# Adding a pattern or a file on this list will still make file available in the documentation, +# but will eliminate the warning message "document isn't included in any toctree" +# However, some files that generate such warning contain labels being referred to from other files, +# if put on the exclude_patters list, such labels are not visible. The commented out files in the +# exclude_patters list below, are such files. They generate a warning, but contain reference labels. +exclude_patterns = ['guides/install-guides/common_sections.rst', + '**manage_clusters/common/deployment/*.rst', + '**manage_clusters/common/discover/**', + '**manage_clusters/common/management/**', + '**manage_clusters/common/parallel_cmd.rst', + '**manage_clusters/common/updatenode.rst', + '**manage_clusters/common/kvm/manage_vm.rst', + '**manage_clusters/common/management.rst', + '**ppc64le/discovery/config_environment.rst', + '**ppc64le/discovery/pbmc_discovery.rst', + '**ppc64le/discovery/pbmc_discovery_with_bmcdiscover.rst', + '**ppc64le/discovery/pbmc_discovery_with_lsslp.rst', + '**ppc64le/discovery/schedule_environment.rst', + '**ppc64le/discovery/standard_cn_definition.rst', + '**ppc64le/diskless/customize_image/cfg_partition.rst', + '**ppc64le/diskless/customize_image/raid_cfg.rst', + #'**chain/create_image_for_runimage.rst' + #'**hamn/setup_ha_mgmt_node_with_drbd_pacemaker_corosync.rst' + #'**hamn/setup_ha_mgmt_node_with_raid1_and_disks_move.rst' + #'**hamn/setup_ha_mgmt_node_with_shared_data.rst', + #'**hamn/setup_xcat_high_available_management_node_in_softlayer.rst', + '**hierarchy/databases/postgres_tips.rst', + '**hierarchy/define_and_install_compute_node.rst', + #'**hierarchy/define_service_node.rst', + '**networks/getadapter.rst' + #'**networks/vlan/index.rst', + #'**networks/vlan/vlan.rst', + #'**license/xcat_corporate_contributor_license_agreement.rst', + #'**license/xcat_individual_contributor_license_agreement.rst' + ] # The reST default role (used for this markup: `text`) to use for all # documents. @@ -145,7 +180,7 @@ else: # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +#html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied diff --git a/docs/source/developers/doc_guidelines.rst b/docs/source/developers/doc_guidelines.rst deleted file mode 100644 index a91d0f23e..000000000 --- a/docs/source/developers/doc_guidelines.rst +++ /dev/null @@ -1,255 +0,0 @@ -Guidelines for xCAT Documentation -================================= -The following guidelines should be followed when making changes to the xCAT documentation to help create consistency in the documentation. - -Document Structure ------------------- - -Section Structure -````````````````` - -xCAT doc page may have 4 levels of title at most: :: - - The First Title - =============== - - The Second Title - ---------------- - - The Third Title - ``````````````` - - The Forth Title - ''''''''''''''' - -List Structure -`````````````` - -Bullet Lists -'''''''''''' - -* Bullet one - - The Content. -* Bullet Two - - The Content. - -:: - - * Bullet one - The Content. - * Bullet Two - The Content. - -Enumerated List -''''''''''''''' - -1. Item 1 - - a) item a - b) item b - -2. Item 2 - - a) item a - -:: - - 1. Item 1 - a) item a - b) item b - 2. Item 2 - a) item a - -Hyperlinks -> Internal Links -> External Links ----------------------------------------------- - -Add links to refer other web page is a very common way in writting document, it's very helpful to reduce the doc duplication and make doc to be easy to understand. Following are several ways to add a link in the xCAT documentation. - -* **Add an Internal Link to ``Customized Link Target``** - - ``Customized Link Target`` means a user defined **Link Target**. - -.. _my_link_target: - - Define a **Link Target** named ``my_link_target``: :: - - .. _my_link_target: - - **Customized Link Target** - - This part of content is a link target which can be linked by other content. - -.. - - Link to the customized link target ``my_link_target`` :ref:`my link `: :: - - Link to the customized link target ``my_link_target`` :ref:`my link ` - -.. - - ``Usage:`` This method is used to add a **Link Target** in any page that can be referred by any other pages. - -* **Add an Internal Link to Current Page** - - Link to an internal section in current page: `Guidelines for xCAT Documentation`_: :: - - Link to an internal section in current page: `Guidelines for xCAT Documentation`_ - -.. - - ``Usage:`` Every title of a section is an auto-generated 'link target', so you can use it directly. But it's only available inside the current page. - -* **Add an Internal Link to Other Page via File Path** - - Link to page ``http://server/overview/suport_list.html`` with **absolute file path** :doc:`support list `: :: - - Link to page ``http://server/overview/suport_list.html`` with **absolute file path** :doc:`support list ` - -.. - - Link to page ``http://server/overview/suport_list.html`` with **relative file path** :doc:`support list <../overview/support_list>`: :: - - Link to page ``http://server/overview/suport_list.html`` with **relative file path** :doc:`support list <../overview/support_list>` - -.. - - ``Usage:`` When you want to link to another whole page but don't want to make a ``Customized Link Target`` in that source page, you can use the file path to link it directly. - -* **Add an External Link** - - Link to an external web page: `google `_: :: - - Link to an external web page: `google `_ - -.. - - ``Usage:`` When you want to link to a page which does not belong to xCAT documentation. - - ``Note:`` The ``https://`` keyword must be added before the web page URL. - -* **Add a Link with Explicit URL Displayed** - - Link to http://www.google.com: :: - - Link to http://www.google.com - -.. - - ``Usage:`` Make a link and display the URL. - - -Add OS or ARCH Specific Contents --------------------------------- - -When writing a common xCAT doc, we always encounter the case that certain small part of content needs to be OS or ARCH specific. In this case, please use the following format to add specific branches. - -The keyword in the **[]** can be an OS name or ARCH name, or any name which can distinguish the content from other part. - -The valid keyword includes: **RHEL**, **SLES**, **UBUNTU**, **CENTOS**, **X86_64**, **PPC64**, **PPC64LE**. If the keyword is an OS, it can be postfixed with an OS version e.g. RHEL7. - -* **[RHEL7]** - - This part of description is for [rh7] specific. - -* **[SLES]** - - This part of description is for [sles] specific. - -* **[PPC64LE]** - - This part of description is for [ppc64le] specific. - -:: - - * **[RHEL7]** - - This part of description is for [rh7] specific. - - -Miscellaneous -------------- - -Add a Comment -````````````` - -.. Try the comment - -The sentence started with ``..`` will be a comment that won't be displayed in the doc. :: - - .. This is a comment - -Add Literal Block -````````````````` - -If you want to add a paragraph of code or something that don't want to be interpreted by browser: :: - - If you want to add a paragraph of code or something that don't want to be interpreted by browser: :: - #lsdef node1 - #tabdump - -Decorate Word -````````````` - -If you want to display one or several words to be ``Literal Word``: :: - - If you want to display one or several words to be ``Literal Word`` - -If you want to make a **strong emphasis** of the word: :: - - If you want to make a **strong emphasis** of the word: - -Add a Table -``````````` - -Add a table in the doc: - -+------------+------------+-----------+ -| Header 1 | Header 2 | Header 3 | -+============+============+===========+ -| body row 1 | column 2 | column 3 | -+------------+------------+-----------+ -| body row 2 | Cells may span columns.| -+------------+------------+-----------+ -| body row 3 | Cells may | - Cells | -+------------+ span rows. | - contain | -| body row 4 | | - blocks. | -+------------+------------+-----------+ - -:: - - +------------+------------+-----------+ - | Header 1 | Header 2 | Header 3 | - +============+============+===========+ - | body row 1 | column 2 | column 3 | - +------------+------------+-----------+ - | body row 2 | Cells may span columns.| - +------------+------------+-----------+ - | body row 3 | Cells may | - Cells | - +------------+ span rows. | - contain | - | body row 4 | | - blocks. | - +------------+------------+-----------+ - -Add Footnotes -````````````` - -This is the first example of footnotes [1]_. - -This is the second example of footnotes [2]_. - -:: - - This is the first example of footnotes [1]_. - This is the second example of footnotes [2]_. - - .. [1] First footnote - .. [2] Second footnote - ------------------------- - -.. [1] First footnote -.. [2] Second footnote - - - diff --git a/docs/source/developers/guides/docs/doc_guidelines.rst b/docs/source/developers/guides/docs/doc_guidelines.rst index a91d0f23e..347ece7cd 100644 --- a/docs/source/developers/guides/docs/doc_guidelines.rst +++ b/docs/source/developers/guides/docs/doc_guidelines.rst @@ -65,7 +65,7 @@ Enumerated List Hyperlinks -> Internal Links -> External Links ---------------------------------------------- -Add links to refer other web page is a very common way in writting document, it's very helpful to reduce the doc duplication and make doc to be easy to understand. Following are several ways to add a link in the xCAT documentation. +Add links to refer other web page is a very common way in writting document, it's very helpful to reduce the doc duplication and make docs easy to understand. Following are several ways to add a link in the xCAT documentation. * **Add an Internal Link to ``Customized Link Target``** @@ -85,7 +85,7 @@ Add links to refer other web page is a very common way in writting document, it Link to the customized link target ``my_link_target`` :ref:`my link `: :: - Link to the customized link target ``my_link_target`` :ref:`my link ` + :ref:`my link ` .. @@ -95,7 +95,7 @@ Add links to refer other web page is a very common way in writting document, it Link to an internal section in current page: `Guidelines for xCAT Documentation`_: :: - Link to an internal section in current page: `Guidelines for xCAT Documentation`_ + `Guidelines for xCAT Documentation`_ .. @@ -103,15 +103,15 @@ Add links to refer other web page is a very common way in writting document, it * **Add an Internal Link to Other Page via File Path** - Link to page ``http://server/overview/suport_list.html`` with **absolute file path** :doc:`support list `: :: + Link to page `http://server/overview/suport_list.html` with **absolute file path** :: - Link to page ``http://server/overview/suport_list.html`` with **absolute file path** :doc:`support list ` + :doc:`support list ` .. - Link to page ``http://server/overview/suport_list.html`` with **relative file path** :doc:`support list <../overview/support_list>`: :: + Link to page `http://server/overview/suport_list.html` with **relative file path** :: - Link to page ``http://server/overview/suport_list.html`` with **relative file path** :doc:`support list <../overview/support_list>` + :doc:`support list <../overview/support_list>` .. @@ -121,7 +121,7 @@ Add links to refer other web page is a very common way in writting document, it Link to an external web page: `google `_: :: - Link to an external web page: `google `_ + `google `_ .. @@ -133,7 +133,7 @@ Add links to refer other web page is a very common way in writting document, it Link to http://www.google.com: :: - Link to http://www.google.com + http://www.google.com .. diff --git a/docs/source/guides/admin-guides/basic_concepts/global_cfg/index.rst b/docs/source/guides/admin-guides/basic_concepts/global_cfg/index.rst index 37c209201..052836083 100644 --- a/docs/source/guides/admin-guides/basic_concepts/global_cfg/index.rst +++ b/docs/source/guides/admin-guides/basic_concepts/global_cfg/index.rst @@ -10,7 +10,7 @@ Database Attributes ------------------- * excludenodes: - A set of comma separated nodes and/or groups that would automatically be subtracted from any noderange, it can be used for excluding some failed nodes from any xCAT command. See :doc:`noderange ` for details on supported formats. + A set of comma separated nodes and/or groups that would automatically be subtracted from any noderange, it can be used for excluding some failed nodes from any xCAT command. See :doc:`noderange ` for details on supported formats. * nodestatus: If set to ``n``, the ``nodelist.status`` column will not be updated during the node deployment, node discovery and power operations. The default is to update. diff --git a/docs/source/guides/admin-guides/manage_clusters/common/deployment/create_img.rst b/docs/source/guides/admin-guides/manage_clusters/common/deployment/create_img.rst index 24b57eed3..c07b65f78 100644 --- a/docs/source/guides/admin-guides/manage_clusters/common/deployment/create_img.rst +++ b/docs/source/guides/admin-guides/manage_clusters/common/deployment/create_img.rst @@ -87,7 +87,7 @@ You can create/modify an osimage definition easily based on the default osimage For example, if you need to change the osimage name to your favorite name, this command may be helpful: :: - lsdef -t osimage -z rhels6.2-x86_64-install-compute | sed 's/^[^ ]\+:/mycomputeimage:/' | mkdef -z + chdef -t osimage rhels6.2-x86_64-install-compute -n rhels6.2_myimage diff --git a/docs/source/guides/admin-guides/manage_clusters/common/deployment/deploy_os.rst b/docs/source/guides/admin-guides/manage_clusters/common/deployment/deploy_os.rst index 2fca4b8de..bd7567600 100644 --- a/docs/source/guides/admin-guides/manage_clusters/common/deployment/deploy_os.rst +++ b/docs/source/guides/admin-guides/manage_clusters/common/deployment/deploy_os.rst @@ -1,5 +1,3 @@ -.. _deploy_os: - Initialize the Compute for Deployment ===================================== @@ -34,5 +32,3 @@ For **x86_64 servers**, those two operations need two independent commands. rpower reset - - diff --git a/docs/source/guides/admin-guides/manage_clusters/common/deployment/install_new_kernel.rst b/docs/source/guides/admin-guides/manage_clusters/common/deployment/install_new_kernel.rst index 535ecb613..cd1df8fc3 100644 --- a/docs/source/guides/admin-guides/manage_clusters/common/deployment/install_new_kernel.rst +++ b/docs/source/guides/admin-guides/manage_clusters/common/deployment/install_new_kernel.rst @@ -79,4 +79,4 @@ The default driver list: :: Note: With this approach, xCAT will search for the drivers in the rootimage. You need to make sure the drivers have been included in the rootimage before generating the initrd. You can install the drivers manually in an existing rootimage (using chroot) and run genimage again, or you can use a postinstall script to install drivers to the rootimage during your initial genimage run. -Use the driver rpm package to add new drivers from rpm packages to the diskless initrd.Refer to the :doc:`cfg_second_adapter.rst` for details. +Use the driver rpm package to add new drivers from rpm packages to the diskless initrd. Refer to the :doc:`/guides/admin-guides/manage_clusters/ppc64le/diskless/customize_image/cfg_second_adapter` for details. diff --git a/docs/source/guides/admin-guides/manage_clusters/common/deployment/prepostscripts/post_script.rst b/docs/source/guides/admin-guides/manage_clusters/common/deployment/prepostscripts/post_script.rst index fbe5f7af3..05f1c432b 100644 --- a/docs/source/guides/admin-guides/manage_clusters/common/deployment/prepostscripts/post_script.rst +++ b/docs/source/guides/admin-guides/manage_clusters/common/deployment/prepostscripts/post_script.rst @@ -218,6 +218,8 @@ Example of mypostscript :: The mypostscript file is generated according to the mypostscript.tmpl file. +.. _Using-the-mypostscript-template-label: + Using the mypostscript template ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/source/guides/admin-guides/manage_clusters/common/deployment/syncfile/syncfile_synclist_file.rst b/docs/source/guides/admin-guides/manage_clusters/common/deployment/syncfile/syncfile_synclist_file.rst index e3c13a2d4..6ce471eb3 100644 --- a/docs/source/guides/admin-guides/manage_clusters/common/deployment/syncfile/syncfile_synclist_file.rst +++ b/docs/source/guides/admin-guides/manage_clusters/common/deployment/syncfile/syncfile_synclist_file.rst @@ -91,7 +91,7 @@ If the above syncfile is performed by the **updatenode/xdcp** commands, or perfo Support nodes in synclist file -~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Note: From xCAT 2.9.2 on AIX and from xCAT 2.12 on Linux, xCAT support a new format for syncfile. The new format is :: diff --git a/docs/source/guides/admin-guides/manage_clusters/common/updatenode.rst b/docs/source/guides/admin-guides/manage_clusters/common/updatenode.rst index 4eeb32798..d9bcd36fd 100644 --- a/docs/source/guides/admin-guides/manage_clusters/common/updatenode.rst +++ b/docs/source/guides/admin-guides/manage_clusters/common/updatenode.rst @@ -94,7 +94,7 @@ If you need to, you can also pass arguments to your scripts: :: mypostscript template for ``updatenode`` -You can customize what attributes you want made available to the post*script, using the shipped mypostscript.tmpl file :ref:`Using-the-mypostscript-template`. +You can customize what attributes you want made available to the postscript, using the shipped mypostscript.tmpl file :ref:`Using-the-mypostscript-template-label`. Synchronize new/updated configuration files ------------------------------------------- diff --git a/docs/source/guides/admin-guides/manage_clusters/ppc64le/discovery/config_environment.rst b/docs/source/guides/admin-guides/manage_clusters/ppc64le/discovery/config_environment.rst index 95c71c100..79791d155 100644 --- a/docs/source/guides/admin-guides/manage_clusters/ppc64le/discovery/config_environment.rst +++ b/docs/source/guides/admin-guides/manage_clusters/ppc64le/discovery/config_environment.rst @@ -1,3 +1,4 @@ + Configure xCAT -------------- @@ -15,8 +16,6 @@ Run the following command to add networks in ``networks`` table if there are no makenetworks -.. _Setup-dhcp: - Setup DHCP `````````` diff --git a/docs/source/guides/admin-guides/manage_clusters/ppc64le/discovery/switch_discovery.rst b/docs/source/guides/admin-guides/manage_clusters/ppc64le/discovery/switch_discovery.rst index adc63b226..ad2c60a31 100644 --- a/docs/source/guides/admin-guides/manage_clusters/ppc64le/discovery/switch_discovery.rst +++ b/docs/source/guides/admin-guides/manage_clusters/ppc64le/discovery/switch_discovery.rst @@ -12,6 +12,8 @@ Switch info:: Switch IP Address: 10.0.201.1 Switch port for Compute Node: port0 +.. _Setup-dhcp: + .. include:: config_environment.rst Predefined Nodes @@ -19,8 +21,8 @@ Predefined Nodes In order to differentiate one node from another, the admin needs to predefine node in xCAT database based on the switches information. This consists of two parts: -#. :ref:`predefined_switches_label` -#. :ref:`predefined_server_nodes_label` +#. :ref:`Predefine Switches ` +#. :ref:`Predefine Server Node ` .. _predefined_switches_label: diff --git a/docs/source/guides/admin-guides/manage_clusters/ppc64le/diskful/deploy_os.rst b/docs/source/guides/admin-guides/manage_clusters/ppc64le/diskful/deploy_os.rst index be4ba945c..129e60c13 100644 --- a/docs/source/guides/admin-guides/manage_clusters/ppc64le/diskful/deploy_os.rst +++ b/docs/source/guides/admin-guides/manage_clusters/ppc64le/diskful/deploy_os.rst @@ -1,2 +1,3 @@ +.. _deploy_os: .. include:: ../../common/deployment/deploy_os.rst diff --git a/docs/source/guides/admin-guides/manage_clusters/ppc64le/virtual_machines/powerKVM.rst b/docs/source/guides/admin-guides/manage_clusters/ppc64le/virtual_machines/powerKVM.rst index a98c199f4..239b69b08 100644 --- a/docs/source/guides/admin-guides/manage_clusters/ppc64le/virtual_machines/powerKVM.rst +++ b/docs/source/guides/admin-guides/manage_clusters/ppc64le/virtual_machines/powerKVM.rst @@ -6,7 +6,7 @@ Provision Hypervisor with PowerKVM ---------------------------------- -Please follow the ``Diskful Installation Documentation`` :ref:`Diskful Installation ` to provision kvm hypervisor with PowerKVM, several customization steps should be taken into consideration. +Please follow the :ref:`Diskful Installation ` to provision kvm hypervisor with PowerKVM, several customization steps should be taken into consideration. To demonstrate the brief steps on hypervisor provision, take **ibm-powerkvm-3.1.0.0-39.0-ppc64le-gold-201511041419.iso** for example here: diff --git a/docs/source/guides/admin-guides/references/man1/buildkit.1.rst b/docs/source/guides/admin-guides/references/man1/buildkit.1.rst index 0594537d0..20dd710e6 100644 --- a/docs/source/guides/admin-guides/references/man1/buildkit.1.rst +++ b/docs/source/guides/admin-guides/references/man1/buildkit.1.rst @@ -23,7 +23,7 @@ SYNOPSIS To build a new Kit -\ **buildkit**\ [\ **-V | -**\ **-verbose]**\ \ *subcommand*\ [\ *kit_name*\ ] [\ *repo_name*\ |\ **all**\ ] [\ **-l | -**\ **-kitloc**\ \ *kit_location*\ ] +\ **buildkit**\ [\ **-V | -**\ **-verbose]**\ \ *subcommand*\ [\ *kit_name*\ ] [\ *repo_name*\ | \ **all**\ ] [\ **-l | -**\ **-kitloc**\ \ *kit_location*\ ] To add packages to an existing Kit. @@ -314,7 +314,7 @@ EXAMPLES \ **buildkit listrepo**\ - \ **buildkit buildrepo all **\ + \ **buildkit buildrepo all**\ \ **buildkit buildtar**\ diff --git a/docs/source/guides/admin-guides/references/man1/geninitrd.1.rst b/docs/source/guides/admin-guides/references/man1/geninitrd.1.rst index b3c98d0e6..ffac5dd95 100644 --- a/docs/source/guides/admin-guides/references/man1/geninitrd.1.rst +++ b/docs/source/guides/admin-guides/references/man1/geninitrd.1.rst @@ -31,7 +31,7 @@ DESCRIPTION Generate the initrd for the osimage: \ **imagename**\ which is an xCAT object of \ *osimage*\ type. -\ **Diskfull Osimage**\ +\ **Diskful Osimage**\ If the \ **imagename**\ is a stateful one (The provmethod attribute for the osimage is 'install'), diff --git a/docs/source/guides/admin-guides/references/man1/getadapter.1.rst b/docs/source/guides/admin-guides/references/man1/getadapter.1.rst index 147d30426..d1046d6ca 100644 --- a/docs/source/guides/admin-guides/references/man1/getadapter.1.rst +++ b/docs/source/guides/admin-guides/references/man1/getadapter.1.rst @@ -29,7 +29,7 @@ DESCRIPTION *********** -Traditionally, network interfaces in Linux are enumerated as eth[0123…], but these names do not necessarily correspond to actual labels on the chassis. \ **getadapter**\ help customer to get predictable network device name and some other network adapter information before provision or network configuration. +Traditionally, network interfaces in Linux are enumerated as eth[0123...], but these names do not necessarily correspond to actual labels on the chassis. \ **getadapter**\ help customer to get predictable network device name and some other network adapter information before provision or network configuration. \ **getadapter**\ use genesis to collect network adapters information, so that mean it need to restart the target node. diff --git a/docs/source/guides/admin-guides/references/man1/getmacs.1.rst b/docs/source/guides/admin-guides/references/man1/getmacs.1.rst index 647b277f7..68c38c47b 100644 --- a/docs/source/guides/admin-guides/references/man1/getmacs.1.rst +++ b/docs/source/guides/admin-guides/references/man1/getmacs.1.rst @@ -41,7 +41,7 @@ blade specific: =============== -\ **getmacs**\ \ *noderange*\ [\ **-V**\ | \ **-**\ **-verbose**\ ] [\ **-d**\ ] [\ **-**\ **-arp**\ ] [\ **-i**\ \ *ethN*\ |\ *enN*\ ] +\ **getmacs**\ \ *noderange*\ [\ **-V**\ | \ **-**\ **-verbose**\ ] [\ **-d**\ ] [\ **-**\ **-arp**\ ] [\ **-i**\ \ *ethN*\ | \ *enN*\ ] diff --git a/docs/source/guides/admin-guides/references/man1/lsve.1.rst b/docs/source/guides/admin-guides/references/man1/lsve.1.rst index bf71f3ac5..59c351f2b 100644 --- a/docs/source/guides/admin-guides/references/man1/lsve.1.rst +++ b/docs/source/guides/admin-guides/references/man1/lsve.1.rst @@ -66,13 +66,16 @@ OPTIONS \ **-t**\ Specify the \ **type**\ of the target object. Supported types: - \ **dc**\ - Data Center (For type of 'dc', all the elements belongs to the data - center will be listed.) - \ **cl**\ - Cluster - \ **sd**\ - Storage Domain (To get the status of Storage Doamin, show it from - \ *data center*\ it attached to. - \ **nw**\ - Network - \ **tpl**\ - Template + + + .. code-block:: perl + + B - Data Center (For type of 'dc', all the elements belongs to the data center will be listed.) + B - Cluster + B - Storage Domain (To get the status of Storage Doamin, show it from I it attached to. + B - Network + B - Template + diff --git a/docs/source/guides/admin-guides/references/man1/rmkitcomp.1.rst b/docs/source/guides/admin-guides/references/man1/rmkitcomp.1.rst index 3c4ec9d47..675774440 100644 --- a/docs/source/guides/admin-guides/references/man1/rmkitcomp.1.rst +++ b/docs/source/guides/admin-guides/references/man1/rmkitcomp.1.rst @@ -29,7 +29,7 @@ DESCRIPTION *********** -The \ **rmkitcomp**\ command removes kit components from an xCAT osimage. All the kit component attribute values that are contained in the osimage will be removed, and the kit comoponent meta rpm and package rpm could be uninstalled by <-u|-**\ **-uninstall> option. +The \ **rmkitcomp**\ command removes kit components from an xCAT osimage. All the kit component attribute values that are contained in the osimage will be removed, and the kit comoponent meta rpm and package rpm could be uninstalled by \ **-u|-**\ **-uninstall**\ option. Note: The xCAT support for Kits is only available for Linux operating systems. diff --git a/docs/source/guides/admin-guides/references/man1/unregnotif.1.rst b/docs/source/guides/admin-guides/references/man1/unregnotif.1.rst index b1ff299ca..a61c02d17 100644 --- a/docs/source/guides/admin-guides/references/man1/unregnotif.1.rst +++ b/docs/source/guides/admin-guides/references/man1/unregnotif.1.rst @@ -49,7 +49,7 @@ OPTIONS \ **-h | -help**\ Display usage message. -\ **-v | -version **\ Command Version. +\ **-v | -version**\ Command Version. \ **-V | -verbose**\ Verbose output. diff --git a/docs/source/guides/admin-guides/references/man1/updatenode.1.rst b/docs/source/guides/admin-guides/references/man1/updatenode.1.rst index 56a5c8b8a..55043ad8d 100644 --- a/docs/source/guides/admin-guides/references/man1/updatenode.1.rst +++ b/docs/source/guides/admin-guides/references/man1/updatenode.1.rst @@ -159,14 +159,18 @@ file. ospkgs postscript will normally remove all the existing rpm repositories before adding server:/install// /etc/passwd - /custom/mygroups -> /etc/group - /custom/myshadow -> /etc/shadow + /custom/mypasswd -> /etc/passwd + /custom/mygroups -> /etc/group + /custom/myshadow -> /etc/shadow Note: no order can be assumed by the order that the EXECUTE,EXECUTEALWAYS and APPEND clause fall in the synclist file. diff --git a/docs/source/guides/admin-guides/references/man8/tabprune.8.rst b/docs/source/guides/admin-guides/references/man8/tabprune.8.rst index aa0a5a78a..58c489334 100644 --- a/docs/source/guides/admin-guides/references/man8/tabprune.8.rst +++ b/docs/source/guides/admin-guides/references/man8/tabprune.8.rst @@ -19,7 +19,7 @@ SYNOPSIS ******** -\ **tabprune**\ [\ **eventlog | auditlog**\ ] [\ **-V**\ ] [\ **-i**\ \ *recid*\ |\ **-n**\ \ *number of records*\ | \ **-p**\ \ *percentage*\ | \ **-d**\ \ *number of days*\ | \ **-a**\ ] +\ **tabprune**\ [\ **eventlog | auditlog**\ ] [\ **-V**\ ] [\ **-i**\ \ *recid*\ | \ **-n**\ \ *number of records*\ | \ **-p**\ \ *percentage*\ | \ **-d**\ \ *number of days*\ | \ **-a**\ ] \ **tabprune**\ \ *tablename*\ \ **-a**\ diff --git a/docs/source/guides/admin-guides/references/man8/winstall.8.rst b/docs/source/guides/admin-guides/references/man8/winstall.8.rst index 2830397dd..d1c5aa91e 100644 --- a/docs/source/guides/admin-guides/references/man8/winstall.8.rst +++ b/docs/source/guides/admin-guides/references/man8/winstall.8.rst @@ -57,19 +57,19 @@ It will then run wcons on the nodes. \ **-o | -**\ **-osver**\ - Specifies which os version to provision. If unspecified, the current node os setting is used. Will be ignored if [\ *-O*\ |\ *--osimage*\ ] is specified or nodetype.provmethod=\ *osimage*\ . + Specifies which os version to provision. If unspecified, the current node os setting is used. Will be ignored if [\ *-O*\ | \ *--osimage*\ ] is specified or nodetype.provmethod=\ *osimage*\ . \ **-p | -**\ **-profile**\ - Specifies what profile should be used of the operating system. If not specified the current node profile setting is used. Will be ignored if [\ *-O*\ |\ *--osimage*\ ] is specified or nodetype.provmethod=\ *osimage*\ . + Specifies what profile should be used of the operating system. If not specified the current node profile setting is used. Will be ignored if [\ **-O | -**\ **-osimage**\ ] is specified or nodetype.provmethod=\ *osimage*\ . \ **-a | -**\ **-arch**\ - Specifies what architecture of the OS to provision. Typically this is unneeded, but if provisioning between x86_64 and x86 frequently, this may be a useful flag. Will be ignored if [\ *-O*\ |\ *--osimage*\ ] is specified or nodetype.provmethod=\ *osimage*\ . + Specifies what architecture of the OS to provision. Typically this is unneeded, but if provisioning between x86_64 and x86 frequently, this may be a useful flag. Will be ignored if [\ **-O | -**\ **-osimage**\ ] is specified or nodetype.provmethod=\ *osimage*\ . diff --git a/docs/source/guides/admin-guides/references/man8/xcatdebug.8.rst b/docs/source/guides/admin-guides/references/man8/xcatdebug.8.rst index 9b786f0be..6a32f61e7 100644 --- a/docs/source/guides/admin-guides/references/man8/xcatdebug.8.rst +++ b/docs/source/guides/admin-guides/references/man8/xcatdebug.8.rst @@ -38,7 +38,7 @@ The trace message includes: The name of the called subroutine; The arguments whi The flag \ **-c**\ is used to specify the subroutine list for \ **subroutine calling trace**\ , it can only work with \ **-f**\ . The value of \ **-c**\ can be a configuration file or a subroutine list. \ **configuration file**\ : a file contains multiple lines of \ **SUBROUTINE_DEFINITION**\ - \ **subroutine list**\ : \ **SUBROUTINE_DEFINITION | SUBROUTINE_DEFINITION**\ |... + \ **subroutine list**\ : \ **SUBROUTINE_DEFINITION | SUBROUTINE_DEFINITION|...**\ \ **SUBROUTINE_DEFINITION**\ : is the element for the \ **-c**\ to specify the subroutine list. @@ -109,7 +109,7 @@ OPTIONS xCAT_plugin::DBobjectdefs(defls,process_request) xCAT::DBobjUtils(getobjdefs) - \ **subroutine list**\ : a string like \ **SUBROUTINE_DEFINITION | SUBROUTINE_DEFINITION**\ |... + \ **subroutine list**\ : a string like \ **SUBROUTINE_DEFINITION | SUBROUTINE_DEFINITION|...**\ e.g. "(plugin_command)|xCAT_plugin::DBobjectdefs(defls,process_request)|xCAT::DBobjUtils(getobjdefs)" @@ -131,32 +131,62 @@ EXAMPLES 1. Enable the \ **subroutine calling trace**\ for all the subroutines in the xcatd and plugin modules. - xcatdebug -f enable - + + + .. code-block:: perl + + xcatdebug -f enable + + 2. Enable the \ **subroutine calling trace**\ for the subroutines configured in the /opt/xcat/share/xcat/samples/tracelevel0 - xcatdebug -f enable -c /opt/xcat/share/xcat/samples/tracelevel0 - + + + .. code-block:: perl + + xcatdebug -f enable -c /opt/xcat/share/xcat/samples/tracelevel0 + + 3. Enable the \ **subroutine calling trace**\ for the plugin_command in xcatd and defls,process_request in the xCAT_plugin::DBobjectdefs module. - xcatdebug -f enable -c "xCAT_plugin::DBobjectdefs(defls,process_request)|(plugin_command)" - + + + .. code-block:: perl + + xcatdebug -f enable -c "xCAT_plugin::DBobjectdefs(defls,process_request)|(plugin_command)" + + 4. Disable the \ **subroutine calling trace**\ for all the subroutines which have been enabled by \ **xcatdebug -f enable**\ . - xcatdebug -f disable - + + + .. code-block:: perl + + xcatdebug -f disable + + 5. Enable the \ **commented trace log**\ - xcatdebug -d enable - + + + .. code-block:: perl + + xcatdebug -d enable + + 6. Enable both the \ **subroutine calling trace**\ and \ **commented trace log**\ - xcatdebug -f enable -c /opt/xcat/share/xcat/samples/tracelevel0 -d enable - + + + .. code-block:: perl + + xcatdebug -f enable -c /opt/xcat/share/xcat/samples/tracelevel0 -d enable + + diff --git a/docs/source/guides/install-guides/common/uninstall_xcat.rst b/docs/source/guides/install-guides/common/uninstall_xcat.rst deleted file mode 100644 index 6e04ddb6b..000000000 --- a/docs/source/guides/install-guides/common/uninstall_xcat.rst +++ /dev/null @@ -1,238 +0,0 @@ -Remove xCAT -=========== - -Backup xCAT User Data ---------------------- - -Before removing xCAT, recommend to backup xCAT database. It's convenient to restore xCAT management environment in the future if needed. :: - - dumpxCATdb -p - -For more information of ``dumpxCATdb``, please refer to :doc:`command dumpxCATdb `. For how to restore xcat DB, please refer to `Restore xCAT User Data`_. - -Clean Up xCAT Related Configuration ------------------------------------ - -1. To clean up the node information from dhcp :: - - makedhcp -d -a - -2. To clean up the node information in tftpboot :: - - nodeset all offline - -3. To clean up the node information from ``/etc/hosts`` (optional) - - Keep xCAT nodes information in ``/etc/hosts`` is harmless. But if really need to remove them from ``/etc/hosts``, you can edit ``/etc/hosts`` by 'vi' directly, or using xCAT command ``makehosts``. :: - - makehosts -d all - -4. To clean up the node information from DNS (optional) - - After removing all the nodes from ``/etc/hosts``, run below command to clean up the node information from DNS. :: - - makedns -n - -Stop xCAT Service ------------------ - -1. Stop xCAT service :: - - service xcatd stop - -2. Stop xCAT related services(Optional) - - XCAT uses various network services on the management node and service nodes, the network services setup by xCAT may need to be cleaned up on the management node and service nodes before uninstalling xCAT. - -* **NFS** : Stop nfs service, unexport all the file systems exported by xCAT, and remove the xCAT file systems from ``/etc/exports``. -* **HTTP**: Stop http service, remove the xcat.conf in the http configuration directory. -* **TFTP**: Stop tftp service, remove the tftp files created by xCAT in tftp directory. -* **DHCP**: Stop dhcp service, remove the configuration made by xCAT in dhcp configuration files. -* **DNS** : Stop the named service, remove the named entries created by xCAT from the named database. - -Remove xCAT Files ------------------ - -1. Remove the xCAT RPMs - - There is no easy way to distinct all the packages depending by xCAT. For packages shipped by xCAT, you can remove them by the commands below. - - [RHEL and SLES] :: - - rpm -qa |grep -i xcat - - [Ubuntu] :: - - dpkg -l | awk '/xcat/ { print $2 }' - - If you want to remove more cleanly. below list maybe helpful for you. They are the packages list of xcat installation tarball. These list are the whole RPMs list, it's possible for some RPMs not to be installed due to them are not suitable for your environment. Please do judgment by yourself. - - * XCAT Core Packages list (xcat-core): - - [RHEL and SLES] :: - - perl-xCAT - xCAT - xCAT-buildkit - xCAT-client - xCAT-confluent - xCAT-genesis-scripts-ppc64 - xCAT-genesis-scripts-x86_64 - xCAT-server - xCATsn - xCAT-SoftLayer - xCAT-test - xCAT-vlan - - [Ubuntu] :: - - perl-xcat - xcat - xcat-buildkit - xcat-client - xcat-confluent - xcat-genesis-scripts - xcat-server - xcatsn - xcat-test - xcat-vlan - - * XCAT Dependency Packages (xcat-dep): - - [RHEL and SLES] :: - - conserver-xcat - cpio - cpio-lang - elilo-xcat - esxboot-xcat - fping - ganglia-devel - ganglia-gmetad - ganglia-gmond - ganglia-gmond-modules-python - ganglia-web - grub2-xcat - ipmitool-xcat - libconfuse - libconfuse-devel - libganglia - lldpd - net-snmp-perl - perl-AppConfig - perl-Compress-Raw-Zlib - perl-Crypt-Blowfish - perl-Crypt-CBC - perl-Crypt-Rijndael - perl-Crypt-SSLeay - perl-DBD-DB2 - perl-DBD-DB2Lite - perl-DBD-Pg - perl-DBD-SQLite - perl-Expect - perl-HTML-Form - perl-IO-Compress-Base - perl-IO-Compress-Zlib - perl-IO-Socket-SSL - perl-IO-Stty - perl-IO-Tty - perl-JSON - perl-Net-DNS - perl-Net-Telnet - perl-SOAP-Lite - perl-Test-Manifest - perl-version - perl-XML-Simple - pyodbc - rrdtool - scsi-target-utils - stunnel - syslinux-xcat - systemconfigurator - systemimager-client - systemimager-common - systemimager-server - xCAT-genesis-base-ppc64 - xCAT-genesis-base-x86_64 - xCAT-genesis-x86_64 - xCAT-UI-deps - xnba-kvm - xnba-undi - yaboot-xcat - zhcp - - [Ubuntu] :: - - conserver-xcat - elilo-xcat - grub2-xcat - ipmitool-xcat - syslinux - syslinux-extlinux - syslinux-xcat - xcat-genesis-base-amd64 - xcat-genesis-base-ppc64 - xnba-undi - - Along with xCAT development, above list maybe change, you can get the latest list through below links: - - - * XCAT Core Packages List (xcat-core) - - [RHEL and SLES] :: - - http://xcat.org/files/xcat/repos/yum//xcat-core/ - - [Ubuntu] :: - - http://xcat.org/files/xcat/repos/apt//xcat-core/ - - * XCAT Dependency Packages (xcat-dep) - - `RPM Packages List (RHEL and SLES) `_ - - `Debian Packages List (Ubuntu) `_ - - - Generally, we use ``yum install xCAT`` to install xCAT, so these are some RPMs shipped by operating system are installed during xCAT installation. We don't have an easy way to find out all of them, but keep these RPMs are harmless. - - -2. Remove xCAT certificate file :: - - rm -rf /root/.xcat - -3. Remove xCAT data file - - By default, xCAT use SQLite, remove SQLite data file under ``/etc/xcat/``. :: - - rm -rf /etc/xcat - -4. Remove xCAT related file(Optional) - - XCAT has ever operated below directory when it was running. Do judgment by yourself before removing these directory, to avoid removing some directories used for other purpose in your environment. :: - - /install - /tftpboot - /etc/yum.repos.d/xCAT-* - /etc/sysconfig/xcat - /etc/apache2/conf.d/xCAT-* - /etc/logrotate.d/xCAT-* - /etc/rsyslogd.d/xCAT-* - /var/log/xcat - /opt/xcat/ - /mnt/xcat - -Remove Databases ----------------- - -* For PostgreSQL: See :doc:`Removing xCAT DB from PostgreSQL `. -* For MySQL/MariaDB: See :doc:`Removing xCAT DB from MySQL/MariaDB `. - -Restore xCAT User Data ----------------------- - -If need to restore xCAT environment, after :doc:`xCAT software installation `, you can restore xCAT DB by data files dumped in the past. :: - - restorexCATdb -p - -For more information of ``restorexCATdb``, please refer to :doc:`command restorexCATdb `. diff --git a/docs/source/guides/install-guides/index.rst b/docs/source/guides/install-guides/index.rst index 07a08b77d..09a92b510 100644 --- a/docs/source/guides/install-guides/index.rst +++ b/docs/source/guides/install-guides/index.rst @@ -1,3 +1,5 @@ +.. _install_guides: + Install Guides ============== diff --git a/docs/source/security/index.rst b/docs/source/security/index.rst index 4f9535ac9..9952ab44f 100644 --- a/docs/source/security/index.rst +++ b/docs/source/security/index.rst @@ -5,4 +5,3 @@ Security Notices :maxdepth: 2 2016/index.rst - 2015/index.rst diff --git a/xCAT-buildkit/pods/man1/buildkit.1.pod b/xCAT-buildkit/pods/man1/buildkit.1.pod index 296bee60b..b5029a152 100644 --- a/xCAT-buildkit/pods/man1/buildkit.1.pod +++ b/xCAT-buildkit/pods/man1/buildkit.1.pod @@ -8,7 +8,7 @@ B [B<-?>|B<-h>|B<--help>] [B<-v>|B<--version>] To build a new Kit -B [B<-V>|B<--verbose]> I [I] [I|B] [B<-l>|B<--kitloc> I] +B [B<-V>|B<--verbose]> I [I] [I | B] [B<-l>|B<--kitloc> I] To add packages to an existing Kit. @@ -240,7 +240,7 @@ B B -B +B B diff --git a/xCAT-client/pods/man1/geninitrd.1.pod b/xCAT-client/pods/man1/geninitrd.1.pod index 8c2f72473..fce267474 100644 --- a/xCAT-client/pods/man1/geninitrd.1.pod +++ b/xCAT-client/pods/man1/geninitrd.1.pod @@ -13,7 +13,7 @@ B [B<-h> | B<--help>] Generate the initrd for the osimage: B which is an xCAT object of I type. -B +B =over 2 diff --git a/xCAT-client/pods/man1/getadapter.1.pod b/xCAT-client/pods/man1/getadapter.1.pod index 1de9d01f3..2fca0dac1 100644 --- a/xCAT-client/pods/man1/getadapter.1.pod +++ b/xCAT-client/pods/man1/getadapter.1.pod @@ -10,7 +10,7 @@ B [B<-h>|B<--help>|B<-v>|B<--version>|B<-V>] =head1 DESCRIPTION -Traditionally, network interfaces in Linux are enumerated as eth[0123…], but these names do not necessarily correspond to actual labels on the chassis. B help customer to get predictable network device name and some other network adapter information before provision or network configuration. +Traditionally, network interfaces in Linux are enumerated as eth[0123...], but these names do not necessarily correspond to actual labels on the chassis. B help customer to get predictable network device name and some other network adapter information before provision or network configuration. B use genesis to collect network adapters information, so that mean it need to restart the target node. diff --git a/xCAT-client/pods/man1/getmacs.1.pod b/xCAT-client/pods/man1/getmacs.1.pod index 72af1cff4..110d6ba54 100644 --- a/xCAT-client/pods/man1/getmacs.1.pod +++ b/xCAT-client/pods/man1/getmacs.1.pod @@ -18,7 +18,7 @@ B I [B<-V>| B<--verbose>] [B<-f>] [B<-d>] [B<--arp>] | [B<-D =head2 blade specific: -B I [B<-V>| B<--verbose>] [B<-d>] [B<--arp>] [B<-i> I|I] +B I [B<-V>| B<--verbose>] [B<-d>] [B<--arp>] [B<-i> I | I] =head1 DESCRIPTION diff --git a/xCAT-client/pods/man1/lsve.1.pod b/xCAT-client/pods/man1/lsve.1.pod index 4c9859186..a2da16334 100644 --- a/xCAT-client/pods/man1/lsve.1.pod +++ b/xCAT-client/pods/man1/lsve.1.pod @@ -42,11 +42,10 @@ The target object to display. Specify the B of the target object. Supported types: - B - Data Center (For type of 'dc', all the elements belongs to the data - center will be listed.) + + B - Data Center (For type of 'dc', all the elements belongs to the data center will be listed.) B - Cluster - B - Storage Domain (To get the status of Storage Doamin, show it from - I it attached to. + B - Storage Domain (To get the status of Storage Doamin, show it from I it attached to. B - Network B - Template diff --git a/xCAT-client/pods/man1/rmkitcomp.1.pod b/xCAT-client/pods/man1/rmkitcomp.1.pod index 43113b2a8..591f0cfd7 100644 --- a/xCAT-client/pods/man1/rmkitcomp.1.pod +++ b/xCAT-client/pods/man1/rmkitcomp.1.pod @@ -10,7 +10,7 @@ B [B<-V>|B<--verbose>] [B<-u>|B<--uninstall>] [B<-f>|B<--force>] [B<- =head1 DESCRIPTION -The B command removes kit components from an xCAT osimage. All the kit component attribute values that are contained in the osimage will be removed, and the kit comoponent meta rpm and package rpm could be uninstalled by <-u|--uninstall> option. +The B command removes kit components from an xCAT osimage. All the kit component attribute values that are contained in the osimage will be removed, and the kit comoponent meta rpm and package rpm could be uninstalled by B<-u|--uninstall> option. Note: The xCAT support for Kits is only available for Linux operating systems. diff --git a/xCAT-client/pods/man1/unregnotif.1.pod b/xCAT-client/pods/man1/unregnotif.1.pod index faf94e815..4a1381812 100644 --- a/xCAT-client/pods/man1/unregnotif.1.pod +++ b/xCAT-client/pods/man1/unregnotif.1.pod @@ -26,7 +26,7 @@ I is the path name of the Perl module or command to be registered. B<-h | -help> Display usage message. -B<-v | -version > Command Version. +B<-v | -version> Command Version. B<-V | -verbose> Verbose output. diff --git a/xCAT-client/pods/man1/updatenode.1.pod b/xCAT-client/pods/man1/updatenode.1.pod index 6f3d21b41..5f7f060f2 100644 --- a/xCAT-client/pods/man1/updatenode.1.pod +++ b/xCAT-client/pods/man1/updatenode.1.pod @@ -119,14 +119,14 @@ file. ospkgs postscript will normally remove all the existing rpm repositories before adding server:/install// Note: The updatenode command is used to update AIX diskful nodes only. For updating diskless AIX nodes refer to the xCAT for AIX update documentation and use the xCAT mknimimage command. For information on updating software on AIX cluster: For diskful installs, read: -XCAT_AIX_RTE_Diskfull_Nodes +XCAT_AIX_RTE_Diskful_Nodes For diskless installs, read: XCAT_AIX_Diskless_Nodes diff --git a/xCAT-client/pods/man1/xdcp.1.pod b/xCAT-client/pods/man1/xdcp.1.pod index 71c10d931..ff967abbb 100644 --- a/xCAT-client/pods/man1/xdcp.1.pod +++ b/xCAT-client/pods/man1/xdcp.1.pod @@ -200,9 +200,9 @@ For example, your rsynclist file may look like this: EXECUTEALWAYS: /tmp/myscript APPEND: -/custom/mypasswd -> /etc/passwd -/custom/mygroups -> /etc/group -/custom/myshadow -> /etc/shadow + /custom/mypasswd -> /etc/passwd + /custom/mygroups -> /etc/group + /custom/myshadow -> /etc/shadow Note: no order can be assumed by the order that the EXECUTE,EXECUTEALWAYS and APPEND clause fall in the synclist file. diff --git a/xCAT-client/pods/man8/tabprune.8.pod b/xCAT-client/pods/man8/tabprune.8.pod index 38ee76b9d..69b579d54 100644 --- a/xCAT-client/pods/man8/tabprune.8.pod +++ b/xCAT-client/pods/man8/tabprune.8.pod @@ -4,9 +4,9 @@ B - Deletes records from the eventlog,auditlog,isnm_perf,isnm_perf_sum =head1 SYNOPSIS -B [B] [B<-V>] [B<-i> I |B<-n> I | B<-p> I | B<-d> I | B<-a>] +B [B] [B<-V>] [B<-i> I | B<-n> I | B<-p> I | B<-d> I | B<-a>] -B I B<-a> +B I B<-a> B [B<-h>|B<--help>] [B<-v>|B<--version>] diff --git a/xCAT-client/pods/man8/winstall.8.pod b/xCAT-client/pods/man8/winstall.8.pod index ecdf4787a..5059fcbf4 100644 --- a/xCAT-client/pods/man8/winstall.8.pod +++ b/xCAT-client/pods/man8/winstall.8.pod @@ -31,16 +31,16 @@ Display version. =item B<-o>|B<--osver> -Specifies which os version to provision. If unspecified, the current node os setting is used. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I. +Specifies which os version to provision. If unspecified, the current node os setting is used. Will be ignored if [I<-O> | I<--osimage>] is specified or nodetype.provmethod=I. =item B<-p>|B<--profile> -Specifies what profile should be used of the operating system. If not specified the current node profile setting is used. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I. +Specifies what profile should be used of the operating system. If not specified the current node profile setting is used. Will be ignored if [B<-O>|B<--osimage>] is specified or nodetype.provmethod=I. =item B<-a>|B<--arch> -Specifies what architecture of the OS to provision. Typically this is unneeded, but if provisioning between x86_64 and x86 frequently, this may be a useful flag. Will be ignored if [I<-O>|I<--osimage>] is specified or nodetype.provmethod=I. +Specifies what architecture of the OS to provision. Typically this is unneeded, but if provisioning between x86_64 and x86 frequently, this may be a useful flag. Will be ignored if [B<-O>|B<--osimage>] is specified or nodetype.provmethod=I. =item B<-O>|B<--osimage> diff --git a/xCAT-client/pods/man8/xcatdebug.8.pod b/xCAT-client/pods/man8/xcatdebug.8.pod index 18452555e..b76043dac 100644 --- a/xCAT-client/pods/man8/xcatdebug.8.pod +++ b/xCAT-client/pods/man8/xcatdebug.8.pod @@ -20,7 +20,7 @@ The trace message includes: The name of the called subroutine; The arguments whi The flag B<-c> is used to specify the subroutine list for B, it can only work with B<-f>. The value of B<-c> can be a configuration file or a subroutine list. B: a file contains multiple lines of B - B: B|B|... + B: B|B B: is the element for the B<-c> to specify the subroutine list. @@ -90,7 +90,7 @@ B: a file contains multiple lines of B: a string like B|B|... +B: a string like B|B e.g. "(plugin_command)|xCAT_plugin::DBobjectdefs(defls,process_request)|xCAT::DBobjUtils(getobjdefs)" @@ -111,26 +111,32 @@ Note: The xcatd will be restarted for the performing of B<-d> =item 1. Enable the B for all the subroutines in the xcatd and plugin modules. + xcatdebug -f enable =item 2. Enable the B for the subroutines configured in the /opt/xcat/share/xcat/samples/tracelevel0 + xcatdebug -f enable -c /opt/xcat/share/xcat/samples/tracelevel0 =item 3. Enable the B for the plugin_command in xcatd and defls,process_request in the xCAT_plugin::DBobjectdefs module. + xcatdebug -f enable -c "xCAT_plugin::DBobjectdefs(defls,process_request)|(plugin_command)" =item 4. Disable the B for all the subroutines which have been enabled by B. + xcatdebug -f disable =item 5. Enable the B + xcatdebug -d enable =item 6. Enable both the B and B + xcatdebug -f enable -c /opt/xcat/share/xcat/samples/tracelevel0 -d enable =back From eb46a9c11cca46fceb7c335d146e5ba7df131e9b Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Wed, 25 May 2016 02:01:23 -0400 Subject: [PATCH 021/310] complete --- xCAT-test/autotest/testcase/makedns/cases0 | 1 + 1 file changed, 1 insertion(+) diff --git a/xCAT-test/autotest/testcase/makedns/cases0 b/xCAT-test/autotest/testcase/makedns/cases0 index eb80188df..5c2e5ad9f 100644 --- a/xCAT-test/autotest/testcase/makedns/cases0 +++ b/xCAT-test/autotest/testcase/makedns/cases0 @@ -124,6 +124,7 @@ end start:makedns description:makedns +stop:yes cmd:chtab netname=testnetwork networks.net=100.100.100.0 networks.mask=255.255.255.0 networks.mgtifname=eth0 networks.gateway=100.100.100.254 check:rc==0 cmd:makedns -n From 0eb992945238a8957fb14e811ea3846300b3505c Mon Sep 17 00:00:00 2001 From: chenglch Date: Wed, 25 May 2016 02:02:48 -0400 Subject: [PATCH 022/310] Add -1 value for $dbworkerpid to make the db access mode more clear. $dbworkerpid = -1 db process has not been started, access db in direct access mode. $dbworkerpid == 0 db process itself. $dbworkerpid >0 db process is started, access db in cache mode. --- perl-xCAT/xCAT/Table.pm | 58 ++++++++++++++++++++++------------------- xCAT-server/sbin/xcatd | 8 +++--- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/perl-xCAT/xCAT/Table.pm b/perl-xCAT/xCAT/Table.pm index 3f9e39165..8ee12b5d6 100644 --- a/perl-xCAT/xCAT/Table.pm +++ b/perl-xCAT/xCAT/Table.pm @@ -69,7 +69,11 @@ require xCAT::NodeRange; use Text::Balanced qw(extract_bracketed); require xCAT::NotifHandler; -my $dbworkerpid; #The process id of the database worker +#The process id of the database worker +# -1 db process has not been started, access db in direct access mode. +# 0 db process itself. +# >0 db process is started, access db in cache mode. +my $dbworkerpid = -1; my $dbworkersocket; my $dbsockpath = "/var/run/xcat/dbworker.sock.".$$; my $exitdbthread; @@ -99,8 +103,8 @@ sub dbc_submit { my $err; while($tries and !($clisock = IO::Socket::UNIX->new(Peer => $dbsockpath, Type => SOCK_STREAM, Timeout => 120) ) ) { #print "waiting for clisock to be available\n"; - if ($tries % 10 == 0 and $dbworkerpid != 0 and not xCAT::Utils::is_process_exists($dbworkerpid)) { - $dbworkerpid = 0; + if ($tries % 10 == 0 and $dbworkerpid > 0 and not xCAT::Utils::is_process_exists($dbworkerpid)) { + $dbworkerpid = -1; xCAT::MsgUtils->message("S","xcatd: DB access process is down, xcat is running in direct access mode. " ."Please restart xcatd to avoid of this error."); return undef; @@ -108,7 +112,7 @@ sub dbc_submit { sleep 0.1; $tries--; } - if ( $dbworkerpid !=0 and !$clisock) { + if ( $dbworkerpid > 0 and !$clisock) { use Carp qw/cluck/; cluck(); } @@ -147,7 +151,7 @@ sub dbc_submit { } sub shut_dbworker { - $dbworkerpid = 0; #For now, just turn off usage of the db worker + $dbworkerpid = -1; #For now, just turn off usage of the db worker #This was created as the monitoring framework shutdown code otherwise seems to have a race condition #this may incur an extra db handle per service node to tolerate shutdown scenarios } @@ -390,7 +394,7 @@ sub handle_dbc_request { sub _set_use_cache { my $self = shift; - if ($dbworkerpid) { + if ($dbworkerpid > 0) { return dbc_call($self,'_set_use_cache',@_); } @@ -757,7 +761,7 @@ sub new } $self->{realautocommit} = $self->{autocommit}; #Assume requester autocommit behavior maps directly to DBI layer autocommit my $class = ref($proto) || $proto; - if ($dbworkerpid) { + if ($dbworkerpid > 0) { my $request = { function => "new", tablename => $self->{tabname}, @@ -1351,7 +1355,7 @@ sub addAttribs my $self = shift; xCAT::MsgUtils->message("S","addAttribs is not supported"); die "addAttribs is not supported"; - if ($dbworkerpid) { + if ($dbworkerpid > 0) { return dbc_call($self,'addAttribs',@_); } if (not $self->{intransaction} and not $self->{autocommit} and $self->{realautocommit}) { @@ -1444,7 +1448,7 @@ sub addAttribs sub rollback { my $self = shift; - if ($dbworkerpid) { + if ($dbworkerpid > 0) { return dbc_call($self,'rollback',@_); } $self->{dbh}->rollback; @@ -1482,7 +1486,7 @@ sub rollback sub commit { my $self = shift; - if ($dbworkerpid) { + if ($dbworkerpid > 0) { return dbc_call($self,'commit',@_); } unless ($self->{dbh}->{AutoCommit}) { #caller can now hammer commit function with impunity, even when it makes no sense @@ -1540,7 +1544,7 @@ sub setAttribs #-Hash reference of column-value pairs to set my $xcatcfg =get_xcatcfg(); my $self = shift; - if ($dbworkerpid) { + if ($dbworkerpid > 0) { return dbc_call($self,'setAttribs',@_); } my $pKeypairs=shift; @@ -1768,7 +1772,7 @@ sub setAttribsWhere #-Where clause #-Hash reference of column-value pairs to set my $self = shift; - if ($dbworkerpid) { + if ($dbworkerpid > 0) { return dbc_call($self,'setAttribsWhere',@_); } my $where_clause = shift; @@ -1881,7 +1885,7 @@ sub setNodesAttribs { #-Insert intelligently with respect to scale (prepare one statement, execute many times, other syntaxes not universal) #Intelligently in this case means folding them to some degree. Update where clauses will be longer, but must be capped to avoid exceeding SQL statement length restrictions on some DBs. Restricting even all the way down to 256 could provide better than an order of magnitude better performance though my $self = shift; - if ($dbworkerpid) { + if ($dbworkerpid > 0) { return dbc_call($self,'setNodesAttribs',@_); } my $nodelist = shift; @@ -2075,7 +2079,7 @@ sub setNodesAttribs { #-------------------------------------------------------------------------------- sub getNodesAttribs { my $self = shift; - if ($dbworkerpid) { + if ($dbworkerpid > 0) { return dbc_call($self,'getNodesAttribs',@_); } my $nodelist = shift; @@ -2146,7 +2150,7 @@ sub _build_cache { #PRIVATE FUNCTION, PLEASE DON'T CALL DIRECTLY #TODO: increment a reference counter type thing to preserve current cache #Also, if ref count is 1 or greater, and the current cache is less than 3 seconds old, reuse the cache? my $self = shift; - if ($dbworkerpid) { + if ($dbworkerpid > 0) { return dbc_call($self,'_build_cache',@_); } my $attriblist = shift; @@ -2246,7 +2250,7 @@ $evalcpt->permit('require'); sub getNodeAttribs { my $self = shift; - if ($dbworkerpid) { #TODO: should this be moved outside of the DB worker entirely? I'm thinking so, but I don't dare do so right now... + if ($dbworkerpid > 0) { #TODO: should this be moved outside of the DB worker entirely? I'm thinking so, but I don't dare do so right now... #the benefit would be the potentially computationally intensive substitution logic would be moved out and less time inside limited #db worker scope return dbc_call($self,'getNodeAttribs',@_); @@ -2750,7 +2754,7 @@ sub getNodeAttribs_nosub_returnany sub getAllEntries { my $self = shift; - if ($dbworkerpid) { + if ($dbworkerpid > 0) { return dbc_call($self,'getAllEntries',@_); } @@ -2844,7 +2848,7 @@ sub getAllAttribsWhere #Takes a list of attributes, returns all records in the table. my $self = shift; - if ($dbworkerpid) { + if ($dbworkerpid > 0) { return dbc_call($self,'getAllAttribsWhere',@_); } my $clause = shift; @@ -2927,7 +2931,7 @@ sub getAllNodeAttribs #Extract and substitute every node record, expanding groups and substituting as getNodeAttribs does my $self = shift; - if ($dbworkerpid) { + if ($dbworkerpid > 0) { return dbc_call($self,'getAllNodeAttribs',@_); } my $attribq = shift; @@ -3052,7 +3056,7 @@ sub getAllAttribs #Takes a list of attributes, returns all records in the table. my $self = shift; - if ($dbworkerpid) { + if ($dbworkerpid > 0) { return dbc_call($self,'getAllAttribs',@_); } @@ -3154,7 +3158,7 @@ sub getAllAttribs sub delEntries { my $self = shift; - if ($dbworkerpid) { + if ($dbworkerpid > 0) { return dbc_call($self,'delEntries',@_); } my $keyref = shift; @@ -3286,7 +3290,7 @@ sub getAttribs # (recurse argument intended only for internal use.) # Returns a hash reference with requested attributes defined. my $self = shift; - if ($dbworkerpid) { + if ($dbworkerpid > 0) { return dbc_call($self,'getAttribs',@_); } @@ -3443,7 +3447,7 @@ sub getTable # table. Each array entry contains a pointer to a hash which is # one row of the table. The row hash is keyed by attribute name. my $self = shift; - if ($dbworkerpid) { + if ($dbworkerpid > 0) { return dbc_call($self,'getTable',@_); } my @return; @@ -3501,7 +3505,7 @@ sub close my $self = shift; #if ($self->{dbh}) { $self->{dbh}->disconnect(); } #undef $self->{dbh}; - if ($0 ne "xcatd: DB Access") { + if ($dbworkerpid != 0) { if ($self->{tabname} eq 'nodelist') { undef $self->{nodelist}; } else { @@ -3904,7 +3908,7 @@ sub buildWhereClause { sub writeAllEntries { my $self = shift; - if ($dbworkerpid) { + if ($dbworkerpid > 0) { return dbc_call($self,'writeAllEntries',@_); } my $filename = shift; @@ -3983,7 +3987,7 @@ sub writeAllAttribsWhere #Takes a list of attributes, returns all records in the table. my $self = shift; - if ($dbworkerpid) { + if ($dbworkerpid > 0) { return dbc_call($self,'writeAllAttribsWhere',@_); } my $clause = shift; @@ -4100,7 +4104,7 @@ sub output_table { sub getMAXMINEntries { my $self = shift; - if ($dbworkerpid) { + if ($dbworkerpid > 0) { return dbc_call($self,'getMAXMINEntries',@_); } my $attr = shift; diff --git a/xCAT-server/sbin/xcatd b/xCAT-server/sbin/xcatd index 6ba83ae57..2a6ee47cc 100644 --- a/xCAT-server/sbin/xcatd +++ b/xCAT-server/sbin/xcatd @@ -886,6 +886,8 @@ unless ($foreground) { } $dbmaster=xCAT::Table::init_dbworker; +# Make sure DB process is ready. +wait_db_process(); my $CHILDPID=0; # Global for reapers my %immediatechildren; sub generic_reaper { @@ -1293,8 +1295,7 @@ my @pendingconnections; my $tconn; my $sslfudgefactor = 0; my $udpalive = 1; -# Make sure DB process is ready. -wait_db_process(); + until ($quit) { $SIG{CHLD} = \&ssl_reaper; # set here to ensure that signal handler is not corrupted during loop while ($udpalive and $udpwatcher->can_read(0)) { # take an intermission to broker some state requests from udp traffic control @@ -2373,9 +2374,10 @@ sub wait_db_process { xCAT::MsgUtils->message("S","Error: xcat db process has not been started in 10 seconds."); return -1; } - # use create 1 to make sure nodelist and site object cached. + # use '-create=>1' to make sure nodelist and site object cached. my $tmptab = xCAT::Table->new('site',-create=>1); if(!$tmptab) { + xCAT::MsgUtils->message("S","Error: Failed to access site table when monitoring DB process."); return -1; } return 0; From 62dd5277955b511097a81714f3335da3872f9adf Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Wed, 25 May 2016 02:46:49 -0400 Subject: [PATCH 023/310] complete description update --- xCAT-test/autotest/testcase/migration/redhat_migration | 2 ++ xCAT-test/autotest/testcase/migration/sles_migration | 4 ++++ .../autotest/testcase/migration/ubuntule_migration1_p8le | 2 ++ .../autotest/testcase/migration/ubuntule_migration2_p8le | 2 ++ xCAT-test/autotest/testcase/migration/ubuntux_migration1_vm | 2 ++ xCAT-test/autotest/testcase/migration/ubuntux_migration2_vm | 2 ++ 6 files changed, 14 insertions(+) diff --git a/xCAT-test/autotest/testcase/migration/redhat_migration b/xCAT-test/autotest/testcase/migration/redhat_migration index 975456215..472a71644 100644 --- a/xCAT-test/autotest/testcase/migration/redhat_migration +++ b/xCAT-test/autotest/testcase/migration/redhat_migration @@ -1,5 +1,6 @@ start:redhat_migration1 os:Linux +description:update xCAT from $$MIGRATION1_VERSION to $$LATEST_VERSION, these two global parameter defined in config file stop:yes #cmd:if ping -c 1 $$SN > /dev/null;then rpower $$SN off > /dev/null;fi @@ -108,6 +109,7 @@ end start:redhat_migration2 os:Linux +description:update xCAT from $$MIGRATION2_VERSION to $$LATEST_VERSION, these two global parameter defined in config file stop:yes #cmd:if ping -c 1 $$SN > /dev/null;then rpower $$SN off > /dev/null;fi diff --git a/xCAT-test/autotest/testcase/migration/sles_migration b/xCAT-test/autotest/testcase/migration/sles_migration index 1a729b45e..a8cc0c51d 100644 --- a/xCAT-test/autotest/testcase/migration/sles_migration +++ b/xCAT-test/autotest/testcase/migration/sles_migration @@ -1,5 +1,7 @@ start:sles_migration1 os:Linux +description:update xCAT from $$MIGRATION1_VERSION to $$LATEST_VERSION, these two global parameter defined in config file + #cmd:if ping -c 1 $$SN > /dev/null;then rpower $$SN off > /dev/null;fi #cmd:chdef -t node -o $$CN servicenode= monserver=$$MN nfsserver=$$MN tftpserver=$$MN xcatmaster=$$MN #check:rc==0 @@ -109,6 +111,8 @@ end start:sles_migration2 os:Linux +description:update xCAT from $$MIGRATION22VERSION to $$LATEST_VERSION, these two global parameter defined in config file + #cmd:if ping -c 1 $$SN > /dev/null;then rpower $$SN off > /dev/null;fi #cmd:chdef -t node -o $$CN servicenode= monserver=$$MN nfsserver=$$MN tftpserver=$$MN xcatmaster=$$MN #check:rc==0 diff --git a/xCAT-test/autotest/testcase/migration/ubuntule_migration1_p8le b/xCAT-test/autotest/testcase/migration/ubuntule_migration1_p8le index 4f8dedf11..c25f3eaa8 100644 --- a/xCAT-test/autotest/testcase/migration/ubuntule_migration1_p8le +++ b/xCAT-test/autotest/testcase/migration/ubuntule_migration1_p8le @@ -1,5 +1,7 @@ start:ubuntu_migration1_p8le os:Linux +description:update xCAT from $$MIGRATION1_VERSION to $$LATEST_VERSION, these two global parameter defined in config file + cmd:copycds $$ISO check:rc==0 cmd:if [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu" ]];then mkdir /tmp/iso; mount -o loop $$MINIISO /tmp/iso ; mkdir -p /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/install/netboot; cp /tmp/iso/install/initrd.gz /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/install/netboot;umount /tmp/iso; rmdir /tmp/iso; fi diff --git a/xCAT-test/autotest/testcase/migration/ubuntule_migration2_p8le b/xCAT-test/autotest/testcase/migration/ubuntule_migration2_p8le index 92fa54ce4..83efb9b4f 100644 --- a/xCAT-test/autotest/testcase/migration/ubuntule_migration2_p8le +++ b/xCAT-test/autotest/testcase/migration/ubuntule_migration2_p8le @@ -1,5 +1,7 @@ start:ubuntu_migration2_p8le os:Linux +description:update xCAT from $$MIGRATION2_VERSION to $$LATEST_VERSION, these two global parameter defined in config file + cmd:copycds $$ISO check:rc==0 cmd:if [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu" ]];then mkdir /tmp/iso; mount -o loop $$MINIISO /tmp/iso ; mkdir -p /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/install/netboot; cp /tmp/iso/install/initrd.gz /install/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/install/netboot;umount /tmp/iso; rmdir /tmp/iso; fi diff --git a/xCAT-test/autotest/testcase/migration/ubuntux_migration1_vm b/xCAT-test/autotest/testcase/migration/ubuntux_migration1_vm index a9aeea6aa..d1841d7e2 100644 --- a/xCAT-test/autotest/testcase/migration/ubuntux_migration1_vm +++ b/xCAT-test/autotest/testcase/migration/ubuntux_migration1_vm @@ -1,5 +1,7 @@ start:ubuntux_migration1_vm os:Linux +description:update xCAT from $$MIGRATION1_VERSION to $$LATEST_VERSION, these two global parameter defined in config file + cmd:copycds $$ISO check:rc==0 cmd:makedns -n diff --git a/xCAT-test/autotest/testcase/migration/ubuntux_migration2_vm b/xCAT-test/autotest/testcase/migration/ubuntux_migration2_vm index bc16ee2c8..b13b6b682 100644 --- a/xCAT-test/autotest/testcase/migration/ubuntux_migration2_vm +++ b/xCAT-test/autotest/testcase/migration/ubuntux_migration2_vm @@ -1,5 +1,7 @@ start:ubuntux_migration2_vm os:Linux +description:update xCAT from $$MIGRATION2_VERSION to $$LATEST_VERSION, these two global parameter defined in config file + cmd:copycds $$ISO check:rc==0 cmd:makedns -n From 50755044e09b39b773a8afe327910bd0387b4c79 Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Wed, 25 May 2016 02:51:12 -0400 Subject: [PATCH 024/310] delete invalid file --- xCAT-test/autotest/testcase/makedns/cases0 | 1 - 1 file changed, 1 deletion(-) diff --git a/xCAT-test/autotest/testcase/makedns/cases0 b/xCAT-test/autotest/testcase/makedns/cases0 index 5c2e5ad9f..eb80188df 100644 --- a/xCAT-test/autotest/testcase/makedns/cases0 +++ b/xCAT-test/autotest/testcase/makedns/cases0 @@ -124,7 +124,6 @@ end start:makedns description:makedns -stop:yes cmd:chtab netname=testnetwork networks.net=100.100.100.0 networks.mask=255.255.255.0 networks.mgtifname=eth0 networks.gateway=100.100.100.254 check:rc==0 cmd:makedns -n From 65ef18a84bb655d3e5e86d947a90dbc5e741fa8d Mon Sep 17 00:00:00 2001 From: junxiawang Date: Wed, 25 May 2016 07:35:19 -0400 Subject: [PATCH 025/310] modify xCATreg about virtual machine set up --- xCAT-server/share/xcat/tools/xCATreg | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/xCAT-server/share/xcat/tools/xCATreg b/xCAT-server/share/xcat/tools/xCATreg index 88084c575..9a87698f5 100755 --- a/xCAT-server/share/xcat/tools/xCATreg +++ b/xCAT-server/share/xcat/tools/xCATreg @@ -296,10 +296,10 @@ sub mn_install { send_msg(2, "[$mn->$confkeys{$mn}][mn_install] installing $osimage for node $confkeys{$mn}................"); if( $arch =~ /x86_64/ || $arch =~ /ppc64le/ || $arch =~ /ppc64el/){ - &runcmd("rmvm $confkeys{$mn} -f -p "); - &runcmd("chdef $confkeys{$mn} mac= "); - &runcmd("mkvm $confkeys{$mn} -s 40G"); - } + &runcmd("rmvm $confkeys{$mn} -f -p "); + &runcmd("chdef $confkeys{$mn} mac= "); + &runcmd("mkvm $confkeys{$mn} -s 40G"); + } &runcmd("makedhcp -n"); &runcmd("makedns -n"); @@ -883,12 +883,12 @@ sub do_test { last if($rc != 0); if($mn =~ /ubuntux/){ - #set up dockerhosts - send_msg(2, "[$mn->$confkeys{$mn}][do_test] setupdockerhost $mn....."); - $rc=system("ssh -t $confkeys{$mn} 'exec bash -l -i -c \"xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -t $setup_dockerhost_testcase\"' >/dev/null 2>&1"); - send_msg(2, "[$mn->$confkeys{$mn}][do_test] setup dockerhosts $mn.....[done]"); - last if($rc != 0); - } + #set up dockerhosts + send_msg(2, "[$mn->$confkeys{$mn}][do_test] setupdockerhost $mn....."); + $rc=system("ssh -t $confkeys{$mn} 'exec bash -l -i -c \"xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -t $setup_dockerhost_testcase\"' >/dev/null 2>&1"); + send_msg(2, "[$mn->$confkeys{$mn}][do_test] setup dockerhosts $mn.....[done]"); + last if($rc != 0); + } #commands bundle in flat mode test send_msg(2, "[$mn->$confkeys{$mn}][do_test] doing all commands test in flat mode in $mn....."); From c0ea34e5c1f901122af6385c6a14b7865f7e4755 Mon Sep 17 00:00:00 2001 From: junxiawang Date: Wed, 25 May 2016 07:42:11 -0400 Subject: [PATCH 026/310] modify template for docker host setup --- xCAT-test/autotest/linux.conf.template | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/xCAT-test/autotest/linux.conf.template b/xCAT-test/autotest/linux.conf.template index 6dbfa6553..25bdaf241 100644 --- a/xCAT-test/autotest/linux.conf.template +++ b/xCAT-test/autotest/linux.conf.template @@ -80,6 +80,16 @@ MIGRATION1_VERSION=2.10 MIGRATION2_VERSION=2.11.1 LATEST_VERSION=2.12.1 #For migration cass End +#For docker host setup +DOCKERIMAGE=ubuntu +DOCKERCOMMAND=/bin/bash +DOCKERCONIP=10.4.27.100 +DOCKERHOSIP=10.4.27.10 +DOCKERMNXCAT=xcatmn +MYNET0VALUE=10.0.0.0/8 +DOCKERCN=host05c08 +DOCKERHOST=c910f04x27v09 +#docker host setup end [Custom] #commands run before test From be2e49a6322290f95f5d33d8cf7c96ed3f8836d3 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Wed, 25 May 2016 13:54:02 -0400 Subject: [PATCH 027/310] support different outputs from nmap command --- perl-xCAT/xCAT/SLP.pm | 5 ++ xCAT-server/lib/xcat/plugins/bmcdiscover.pm | 8 ++-- .../lib/xcat/plugins/switchdiscover.pm | 48 +++++++++++++------ 3 files changed, 42 insertions(+), 19 deletions(-) diff --git a/perl-xCAT/xCAT/SLP.pm b/perl-xCAT/xCAT/SLP.pm index d84d0a8ac..e203efccc 100755 --- a/perl-xCAT/xCAT/SLP.pm +++ b/perl-xCAT/xCAT/SLP.pm @@ -124,6 +124,11 @@ sub dodiscover { foreach my $line (split(/\n\n/,$nmapres)) { my $server; foreach my $sline (split(/\n/, $line)) { + #output of nmap command for version under 5.10 + if ($sline =~ /Interesting ports on (\d+\.\d+\.\d+\.\d+)/) { + $server = $1; + } + #output of nmap command for version 5.10 and above if ($sline =~ /Nmap scan report for (\d+\.\d+\.\d+\.\d+)/) { $server = $1; } diff --git a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm index 801b57046..3f38db8bd 100644 --- a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm @@ -461,11 +461,11 @@ sub scan_process{ my $version_result = xCAT::Utils->runcmd($ccmd, 0); my @version_array = split / /, $version_result; my $nmap_version = $version_array[2]; - # the output of nmap is different for version under 4.75 - if (xCAT::Utils->version_cmp($nmap_version,"4.75") <= 0) { - $bcmd = join(" ",$nmap_path," -sP -n $range | grep Host |cut -d ' ' -f2 |tr -s '\n' ' ' "); + # the output of nmap is different for version under 5.10 + if (xCAT::Utils->version_cmp($nmap_version,"5.10") < 0) { + $bcmd = join(" ",$nmap_path," -sP -n $range | grep \"appears to be up\" |cut -d ' ' -f2 |tr -s '\n' ' ' "); } else { - $bcmd = join(" ",$nmap_path," -sn -n $range | grep for |cut -d ' ' -f5 |tr -s '\n' ' ' "); + $bcmd = join(" ",$nmap_path," -sn -n $range | grep \"Nmap scan report\" |cut -d ' ' -f5 |tr -s '\n' ' ' "); } $ip_list = xCAT::Utils->runcmd("$bcmd", -1); diff --git a/xCAT-server/lib/xcat/plugins/switchdiscover.pm b/xCAT-server/lib/xcat/plugins/switchdiscover.pm index f2ffb8257..ccead4ce0 100644 --- a/xCAT-server/lib/xcat/plugins/switchdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/switchdiscover.pm @@ -651,8 +651,12 @@ sub nmap_scan { } }; - - $ccmd = "/usr/bin/nmap -sP -oX - @$ranges"; + my $nmap_version = get_nmapversion($request); + if (xCAT::Utils->version_cmp($nmap_version,"5.10") < 0) { + $ccmd = "/usr/bin/nmap -sP -oX - @$ranges"; + } else { + $ccmd = "/usr/bin/nmap -sn -oX - @$ranges"; + } if (exists($globalopt{verbose})) { send_msg($request, 0, "Process command: $ccmd\n"); } @@ -805,7 +809,6 @@ sub snmp_scan { my $result; my $switches; my $counter = 0; - my $nmap_version; # snmpwalk command has to be available for snmp_scan if (-x "/usr/bin/snmpwalk" ){ @@ -822,21 +825,11 @@ sub snmp_scan { ################################################## my $ranges = get_ip_ranges($request); - $ccmd = "nmap -V | grep version"; - $result = xCAT::Utils->runcmd($ccmd, 0); - my @version_array = split / /, $result; - $nmap_version = $version_array[2]; - if (exists($globalopt{verbose})) { - send_msg($request, 0, "version of nmap: $nmap_version\n"); - } #use nmap to find if snmp port is enabled # only open port will be scan - # currently, we know nmap version 4.75 has different output for snmp_scan - # command. - # for version 4.75, the line as :"Host 10.4.25.1 appears to be up ... good." - # other higher version has line like this: "Discovered open port 161/udp on 10.4.25.1" - if (xCAT::Utils->version_cmp($nmap_version,"4.75") <= 0) { + my $nmap_version = get_nmapversion($request); + if (xCAT::Utils->version_cmp($nmap_version,"5.10") <= 0) { $ccmd = "/usr/bin/nmap -P0 -v -sU -p 161 -oA snmp_scan @$ranges | grep up | grep good "; } else { $ccmd = "/usr/bin/nmap -P0 -v -sU -p 161 -oA snmp_scan @$ranges | grep 'open port 161' "; @@ -1259,5 +1252,30 @@ sub format_xml { return ($xml); } +#-------------------------------------------------------------------------------- +=head3 get_nmapversion + for nmap version 5.10 above, the sP option changed to sn. + the output of some commands also have differents. + example: for snmp_scan option, + version 4.75 has output "Host 10.4.25.1 appears to be up ... good." but + for version 6.40, it has output "Discovered open port 161/udp on 10.4.25.1" + Returns: + result: version of nmap on the system +=cut +#-------------------------------------------------------------------------------- + +sub get_nmapversion { + $request = shift; + my $nmap_version; + my $ccmd = "nmap -V | grep version"; + my $result = xCAT::Utils->runcmd($ccmd, 0); + my @version_array = split / /, $result; + $nmap_version = $version_array[2]; + if (exists($globalopt{verbose})) { + send_msg($request, 0, "version of nmap: $nmap_version\n"); + } + return $nmap_version; +} + 1; From 42c2d4854477bde1c898cb5851f5d3ebbfbf6499 Mon Sep 17 00:00:00 2001 From: "litingt@cn.ibm.com" Date: Wed, 25 May 2016 22:40:25 -0400 Subject: [PATCH 028/310] write xcatd test cases for service xcatd output changes, update bundle file according --- .../autotest/bundle/sles12.1_ppc64le.bundle | 6 + .../autotest/bundle/sles12.1_x86_64.bundle | 12 +- .../autotest/bundle/sles12_ppc64le.bundle | 6 + .../autotest/bundle/sles12_x86_64.bundle | 12 +- .../bundle/ubuntu16.04_ppc64le.bundle | 12 +- .../autotest/bundle/ubuntu16.04_x86_64.bundle | 8 +- xCAT-test/autotest/testcase/xcatd/case0 | 165 ++++++++++++++++++ 7 files changed, 202 insertions(+), 19 deletions(-) diff --git a/xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle b/xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle index a3716f22c..4435fbcc2 100644 --- a/xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle @@ -196,5 +196,11 @@ switchdiscover_range_r switchdiscover_range_x switchdiscover_range_z switchdiscover_range_z_V +xcatd_start_systemd +xcatd_stop_systemd +xcatd_restart_systemd +run_command_with_XCATBYPASS_systemd +disable_root_permission_in_policy_table_systemd +assign_certain_command_permission_systemd sles_migration1 sles_migration2 diff --git a/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle b/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle index 0225c9d50..11a149192 100644 --- a/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle +++ b/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle @@ -201,12 +201,12 @@ switchdiscover_range_x switchdiscover_range_z switchdiscover_range_z_V nodeset_check_warninginfo -xcatd_start -xcatd_stop -xcatd_restart -run_command_with_XCATBYPASS -disable_root_permission_in_policy_table -assign_certain_command_permission +xcatd_start_systemd +xcatd_stop_systemd +xcatd_restart_systemd +run_command_with_XCATBYPASS_systemd +disable_root_permission_in_policy_table_systemd +assign_certain_command_permission_systemd reg_linux_diskless_installation_flat reg_linux_statelite_installation_flat sles_migration1 diff --git a/xCAT-test/autotest/bundle/sles12_ppc64le.bundle b/xCAT-test/autotest/bundle/sles12_ppc64le.bundle index 04a1ebe34..25688bf6f 100644 --- a/xCAT-test/autotest/bundle/sles12_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/sles12_ppc64le.bundle @@ -252,6 +252,12 @@ switchdiscover_range_r switchdiscover_range_x switchdiscover_range_z switchdiscover_range_z_V +xcatd_start_systemd +xcatd_stop_systemd +xcatd_restart_systemd +run_command_with_XCATBYPASS_systemd +disable_root_permission_in_policy_table_systemd +assign_certain_command_permission_systemd makentp_v makentp_h makentp_V diff --git a/xCAT-test/autotest/bundle/sles12_x86_64.bundle b/xCAT-test/autotest/bundle/sles12_x86_64.bundle index a5da4cee6..1cac18c63 100644 --- a/xCAT-test/autotest/bundle/sles12_x86_64.bundle +++ b/xCAT-test/autotest/bundle/sles12_x86_64.bundle @@ -201,11 +201,11 @@ switchdiscover_range_x switchdiscover_range_z switchdiscover_range_z_V nodeset_check_warninginfo -xcatd_start -xcatd_stop -xcatd_restart -run_command_with_XCATBYPASS -disable_root_permission_in_policy_table -assign_certain_command_permission +xcatd_start_systemd +xcatd_stop_systemd +xcatd_restart_systemd +run_command_with_XCATBYPASS_systemd +disable_root_permission_in_policy_table_systemd +assign_certain_command_permission_systemd reg_linux_diskless_installation_flat reg_linux_statelite_installation_flat diff --git a/xCAT-test/autotest/bundle/ubuntu16.04_ppc64le.bundle b/xCAT-test/autotest/bundle/ubuntu16.04_ppc64le.bundle index de643cfcc..cbe8a9844 100644 --- a/xCAT-test/autotest/bundle/ubuntu16.04_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/ubuntu16.04_ppc64le.bundle @@ -234,9 +234,9 @@ switchdiscover_range_r switchdiscover_range_x switchdiscover_range_z switchdiscover_range_z_V -xcatd_start -xcatd_stop -xcatd_restart -run_command_with_XCATBYPASS -disable_root_permission_in_policy_table -assign_certain_command_permission +xcatd_start_systemd +xcatd_stop_systemd +xcatd_restart_systemd +run_command_with_XCATBYPASS_systemd +disable_root_permission_in_policy_table_systemd +assign_certain_command_permission_systemd diff --git a/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle b/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle index eeab10ae7..08f275336 100644 --- a/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle +++ b/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle @@ -243,6 +243,12 @@ switchdiscover_range_r switchdiscover_range_x switchdiscover_range_z switchdiscover_range_z_V +xcatd_start_systemd +xcatd_stop_systemd +xcatd_restart_systemd +run_command_with_XCATBYPASS_systemd +disable_root_permission_in_policy_table_systemd +assign_certain_command_permission_systemd nodeset_check_warninginfo rpower_stop rpower_start @@ -256,4 +262,4 @@ rmdocker_h rmdocker_command rmdocker_f_command lsdocker_h_command -lsdocker_l_command \ No newline at end of file +lsdocker_l_command diff --git a/xCAT-test/autotest/testcase/xcatd/case0 b/xCAT-test/autotest/testcase/xcatd/case0 index 9dfdc93a8..b3f442212 100644 --- a/xCAT-test/autotest/testcase/xcatd/case0 +++ b/xCAT-test/autotest/testcase/xcatd/case0 @@ -28,6 +28,47 @@ cmd:result=`ps -ef | grep "xcatd: Command log writer" | grep -v grep | wc -l`; i check:output=~only one process end +start:xcatd_start_systemd +description:this is the test case when xcat service is managed by systemd on sles12* and ubuntu16.04, the output of service xcatd changes,stop then start xcatd daemon, and check all the 6 processes are running +os:linux +cmd:service xcatd status +check:rc==0 +check:output=~xcatd.service +check:output=~active \(running\) +check:output=~/system.slice/xcatd.service +check:output=~xcatd: SSL listener +check:output=~xcatd: DB Access +check:output=~xcatd: UDP listener +check:output=~xcatd: install monitor +check:output=~xcatd: Discovery worker +check:output=~xcatd: Command log writer +cmd:service xcatd stop +check:rc==0 +cmd:sleep 3 +cmd:service xcatd status +check:rc!=0 +check:output=~xcatd.service +check:output=~inactive \(dead\) +cmd:service xcatd start +check:rc==0 +cmd:service xcatd status +check:rc==0 +check:output=~xcatd.service +check:output=~active \(running\) +cmd:result=`ps -ef | grep "xcatd: SSL listener" | grep -v grep | wc -l`; if [ $result -eq 1 ]; then echo "only one process"; fi +check:output=~only one process +cmd:result=`ps -ef | grep "xcatd: DB Access" | grep -v grep | wc -l`; if [ $result -eq 1 ]; then echo "only one process"; fi +check:output=~only one process +cmd:result=`ps -ef | grep "xcatd: UDP listener" | grep -v grep | wc -l`; if [ $result -eq 1 ]; then echo "only one process"; fi +check:output=~only one process +cmd:result=`ps -ef | grep "xcatd: install monitor" | grep -v grep | wc -l`; if [ $result -eq 1 ]; then echo "only one process"; fi +check:output=~only one process +cmd:result=`ps -ef | grep "xcatd: Discovery worke" | grep -v grep | wc -l`; if [ $result -eq 1 ]; then echo "only one process"; fi +check:output=~only one process +cmd:result=`ps -ef | grep "xcatd: Command log writer" | grep -v grep | wc -l`; if [ $result -eq 1 ]; then echo "only one process"; fi +check:output=~only one process +end + start:xcatd_stop description:stop xcatd daemon, then check all the 6 processes are stopped @@ -53,6 +94,38 @@ cmd:service xcatd start check:rc==0 end +start:xcatd_stop_systemd +description:this is the test case when xcat service is managed by systemd on sles12* and ubuntu16.04, the output of service xcatd changes,stop xcatd daemon, then check all the 6 processes are stopped +os:linux +cmd:service xcatd status +check:rc==0 +check:output=~xcatd.service +check:output=~active \(running\) +check:output=~/system.slice/xcatd.service +check:output=~xcatd: SSL listener +check:output=~xcatd: DB Access +check:output=~xcatd: UDP listener +check:output=~xcatd: install monitor +check:output=~xcatd: Discovery worker +check:output=~xcatd: Command log writer +cmd:service xcatd stop +check:rc==0 +cmd:sleep 3 +cmd:service xcatd status +check:rc!=0 +check:output=~xcatd.service +check:output=~inactive \(dead\) +cmd:ps -ef | grep xcatd +check:output!~"xcatd: SSL listener" +check:output!~"xcatd: DB Access" +check:output!~"xcatd: UDP listener" +check:output!~"xcatd: install monitor" +check:output!~"xcatd: Discovery worke" +check:output!~"xcatd: Command log writer" +cmd:service xcatd start +check:rc==0 +end + start:xcatd_restart description:restart xcatd daemon os:linux @@ -66,6 +139,22 @@ check:output=~xcatd service is running check:rc==0 end +start:xcatd_restart_systemd +description:this is the test case when xcat service is managed by systemd on sles12* and ubuntu16.04, the output of service xcatd changes,restart xcatd daemon +os:linux +cmd:service xcatd status +check:rc==0 +check:output=~xcatd.service +check:output=~active \(running\) +cmd:times=10; while [ $times -gt 0 ]; do service xcatd restart; if [ "$?" -ne "0" ]; then break; fi; ((times--)); done; if [ $times -gt 0 ]; then $?=1; fi +check:rc==0 +cmd:service xcatd status +check:rc==0 +check:output=~xcatd.service +check:output=~active \(running\) +end + + start:run_command_with_XCATBYPASS description:with XCATBYPASS=YES, the command works either xcatd deamon running or not os:linux @@ -94,6 +183,41 @@ check:rc==0 check:output=~xcatd service is running end +start:run_command_with_XCATBYPASS_systemd +description:wis is the test case when xcat service is managed by systemd,on sles12* and ubuntu16.04, the output of service xcatd changes,with XCATBYPASS=YES, the command works either xcatd deamon running or not +os:linux +cmd:service xcatd status +check:rc==0 +check:output=~xcatd.service +check:output=~active \(running\) +cmd:XCATBYPASS=YES tabdump site +check:rc==0 +cmd:service xcatd stop +check:rc==0 +cmd:sleep 3 +cmd:service xcatd status +eck:rc!=0 +check:output=~xcatd.service +check:output=~inactive \(dead\) +cmd:tabdump site +check:rc!=0 +cmd:XCATBYPASS=YES tabdump site +check:rc==0 +cmd:service xcatd start +check:rc==0 +cmd:service xcatd status +check:rc==0 +check:output=~xcatd.service +check:output=~active \(running\) +check:output=~/system.slice/xcatd.service +check:output=~xcatd: SSL listener +check:output=~xcatd: DB Access +check:output=~xcatd: UDP listener +check:output=~xcatd: install monitor +check:output=~xcatd: Discovery worker +check:output=~xcatd: Command log writer +end + start:disable_root_permission_in_policy_table description:disable root permission, only with XCATBYPASS=YES, the command works os:linux @@ -112,6 +236,25 @@ cmd:lsdef check:rc==0 end +start:disable_root_permission_in_policy_table_systemd +description:this is the test case when xcat service is managed by systemd on sles12* and ubuntu16.04, the output of service xcatd changes,disable root permission, only with XCATBYPASS=YES, the command works +os:linux +cmd:service xcatd status +check:rc==0 +check:output=~xcatd.service +check:output=~active \(running\) +cmd:chtab name=root policy.rule=disable +check:rc==0 +cmd:lsdef +check:output=~Error: Permission denied for request +cmd:XCATBYPASS=YES lsdef +check:rc==0 +cmd:XCATBYPASS=YES chtab name=root policy.rule=allow +check:rc==0 +cmd:lsdef +check:rc==0 +end + start:assign_certain_command_permission description:assign root permission to certain command, only this command works os:linux @@ -131,3 +274,25 @@ check:output=~Error: Permission denied for request cmd:chtab name=root policy.commands= policy.rule=allow check:rc==0 end + +start:assign_certain_command_permission_systemd +description:this is the test case when xcat service is managed by systemd on sles12* and ubuntu16.04, the output of service xcatd changes,assign root permission to certain command, only this command works +os:linux +cmd:service xcatd status +check:rc==0 +check:output=~xcatd.service +check:output=~active \(running\) +cmd:lsdef +check:rc==0 +cmd:tabdump policy +check:rc==0 +cmd:chtab name=root policy.commands=lsdef policy.rule=allow +check:rc==0 +cmd:lsdef +check:rc==0 +cmd:tabdump policy +check:output=~Error: Permission denied for request +cmd:chtab name=root policy.commands= policy.rule=allow +check:rc==0 +end + From d29bf877defccec9a14b17d698c9a67110b8ef66 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Thu, 26 May 2016 05:45:20 -0400 Subject: [PATCH 029/310] New code for xcat probe component --- xCAT-probe/lib/perl/ProbeUtils.pm | 317 ++++++++++++++++++++ xCAT-probe/subcmds/xcatmn | 475 ++++++++++++++++++++++++++++++ xCAT-probe/xcatprobe | 258 ++++++++++++++++ 3 files changed, 1050 insertions(+) create mode 100644 xCAT-probe/lib/perl/ProbeUtils.pm create mode 100755 xCAT-probe/subcmds/xcatmn create mode 100755 xCAT-probe/xcatprobe diff --git a/xCAT-probe/lib/perl/ProbeUtils.pm b/xCAT-probe/lib/perl/ProbeUtils.pm new file mode 100644 index 000000000..8304fb76b --- /dev/null +++ b/xCAT-probe/lib/perl/ProbeUtils.pm @@ -0,0 +1,317 @@ +package ProbeUtils; +use strict; +use File::Path; +use File::Copy; + +#----------------------------------------- +=head3 + Description: + Format output message depending on probe framework requirement + Format is [] : + The valid are debug, warning, failed and ok + Attribute: list by input sequence + output: where should output the message + num: the number of + 0: debug + 1: warning + 2: failed + 3: ok + msg: the information need to output + Return value: + 1 : Failed + 0 : success +=cut +#---------------------------------------- +sub send_msg { + my $output=shift; + $output=shift if(($output) && ($output =~ /ProbeUtils/)); + my $num = shift; + my $msg = shift; + my $flag; + + if ($num == 0) { + $flag = "[debug] :"; + }elsif($num == 1) { + $flag = "[warning]:"; + }elsif($num == 2) { + $flag = "[failed] :"; + }elsif($num == 3){ + $flag = "[ok] :"; + } + if($output eq "stdout"){ + print "$flag $msg\n"; + }else{ + if (!open (LOGFILE, ">> $output") ) { + return 1; + } + print LOGFILE "$flag $msg\n"; + close LOGFILE; + } + return 0; +} + +#------------------------------------------ +=head3 + Description: + Judge if a string is a IP address + Attribute: list by input sequence + addr: the string want to be judged + Return value: + 1 : yes + 0 : no +=cut +#------------------------------------------ +sub isIpAddr{ + my $addr = shift; + $addr=shift if(($addr) && ($addr =~ /ProbeUtils/)); + return 0 unless($addr); + return 0 if($addr !~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/); + return 0 if ($1 > 255 || $1 == 0 || $2 > 255 || $3 > 255 || $4 > 255); + return 1; +} + +#------------------------------------------ +=head3 + Description: + Judge if a IP address belongs to a network + Attribute: list by input sequence + net : network address, such like 10.10.10.0 + mask: network mask. suck like 255.255.255.0 + ip: a ip address + Return value: + 1 : yes + 0 : no +=cut +#------------------------------------------ +sub isIpBelongToNet{ + my $net=shift; + $net=shift if(($net) && ($net =~ /ProbeUtils/)); + my $mask=shift; + my $targetip=shift; + + return 0 if($net !~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/); + return 0 if($mask !~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/); + return 0 if(! isIpAddr($targetip)); + + my $bin_mask=0; + $bin_mask=(($1+0)<<24)+(($2+0)<<16)+(($3+0)<<8)+($4+0) if($mask =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/); + + my $bin_ip=0; + $bin_ip=(($1+0)<<24)+(($2+0)<<16)+(($3+0)<<8)+($4+0) if($targetip =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/); + + my $tmp_net = $bin_mask&$bin_ip; + + my $bin_net=0; + $bin_net=(($1+0)<<24)+(($2+0)<<16)+(($3+0)<<8)+($4+0) if($net =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/); + + return 0 if( $tmp_net != $bin_net); + return 1; +} + +#------------------------------------------ +=head3 + Description: + Get distro name of current operating system + Attribute: list by input sequence + None + Return value: + A string, include value are sles, redhat and ubuntu +=cut +#------------------------------------------ +sub getOS{ + my $os="unknown"; + my $output = `cat /etc/*release* 2>&1`; + if($output =~ /suse/i){ + $os="sles"; + }elsif($output =~ /Red Hat/i){ + $os="redhat"; + }elsif($output =~ /ubuntu/i){ + $os="ubuntu"; + } + + return $os; +} + +#------------------------------------------ +=head3 + Description: + Judge if a IP address is a static IP address + Attribute: list by input sequence + ip: a ip address + nic: the network adapter which ip belongs to + Return value: + 1 : yes + 0 : no +=cut +#------------------------------------------ +sub isStaticIp{ + my $ip=shift; + $ip=shift if(($ip) && ($ip =~ /ProbeUtils/)); + my $nic=shift; + my $os = getOS(); + my $rst=0; + + if($os =~ /redhat/){ + my $output1=`cat /etc/sysconfig/network-scripts/ifcfg-$nic 2>&1 |grep -i IPADDR`; + my $output2=`cat /etc/sysconfig/network-scripts/ifcfg-$nic 2>&1 |grep -i BOOTPROTO`; + $rst=1 if(($output1 =~ /$ip/) && ($output2 =~ /static/i)); + }elsif($os =~ /sles/){ + my $output1=`cat /etc/sysconfig/network/ifcfg-$nic 2>&1 |grep -i IPADDR`; + my $output2=`cat /etc/sysconfig/network/ifcfg-$nic 2>&1 |grep -i BOOTPROTO`; + $rst=1 if(($output1 =~ /$ip/) && ($output2 =~ /static/i)); + }elsif($os =~/ubuntu/){ + my $output=`cat /etc/network/interfaces 2>&1|grep -E "iface\s+$nic"`; + $rst=1 if($output =~ /static/i); + } + return $rst; +} + +#------------------------------------------ +=head3 + Description: + Judge if SELinux is opened in current operating system + Attribute: list by input sequence + None + Return value: + 1 : yes + 0 : no +=cut +#------------------------------------------ +sub isSelinuxEnable{ + if (-e "/usr/sbin/selinuxenabled") { + `/usr/sbin/selinuxenabled`; + if ($? == 0) { + return 1; + } else { + return 0; + } + } else { + return 0; + } +} + +#------------------------------------------ +=head3 + Description: + Judge if firewall is opened in current operating system + Attribute: list by input sequence + None + Return value: + 1 : yes + 0 : no +=cut +#------------------------------------------ +sub isFirewallOpen{ + my $os =getOS(); + my $output; + my $rst=0; + + if($os =~ /redhat/){ + $output=`service iptables status 2>&1`; + $rst=1 if($output =~ /running/i); + }elsif($os =~ /sles/){ + $output=`service SuSEfirewall2_setup status`; + $rst=1 if($output =~ /running/i); + }elsif($os =~/ubuntu/){ + $output=`ufw status`; + $rst=1 if($output =~ /Status: active/i); + } + return $rst; +} + +#------------------------------------------ +=head3 + Description: + Judge if http service is ready to use in current operating system + Attribute: list by input sequence + ip: http server's ip + Return value: + 1 : yes + 0 : no +=cut +#------------------------------------------ +sub isHttpReady{ + my $mnip=shift; + $mnip=shift if(($mnip) && ($mnip =~ /ProbeUtils/)); + + my $http = "http://$mnip/install/postscripts/efibootmgr"; + rename("./efibootmgr", "./efibootmgr.org") if(-e "./efibootmgr"); + + my $outputtmp = `wget $http 2>&1`; + my $rst =$?; + if(($outputtmp =~ /200 OK/) && (!$rst) && (-e "./efibootmgr")){ + unlink("./efibootmgr"); + rename("./efibootmgr.org", "./efibootmgr") if(-e "./efibootmgr.org"); + return 1; + }else{ + rename("./efibootmgr.org", "./efibootmgr") if(-e "./efibootmgr.org"); + return 0; + } +} + +#------------------------------------------ +=head3 + Description: + Judge if tftp service is ready to use in current operating system + Attribute: list by input sequence + ip: tftp server's ip + Return value: + 1 : yes + 0 : no +=cut +#------------------------------------------ +sub isTftpReady{ + my $mnip=shift; + $mnip=shift if(($mnip) && ($mnip =~ /ProbeUtils/)); + + rename("/tftpboot/tftptestt.tmp", "/tftpboot/tftptestt.tmp.old") if(-e "/tftpboot/tftptestt.tmp"); + rename("./tftptestt.tmp", "./tftptestt.tmp.old") if(-e "./tftptestt.tmp"); + + system("touch /tftpboot/tftptestt.tmp"); + my $output = `tftp -4 -v $mnip -c get tftptestt.tmp`; + if((!$?) && (-e "./tftptestt.tmp")){ + unlink("./tftptestt.tmp"); + rename("./tftptestt.tmp.old", "./tftptestt.tmp") if(-e "./tftptestt.tmp.old"); + rename("/tftpboot/tftptestt.tmp.old","/tftpboot/tftptestt.tmp") if(-e "/tftpboot/tftptestt.tmp.old"); + return 1; + }else{ + rename("./tftptestt.tmp.old", "./tftptestt.tmp") if(-e "./tftptestt.tmp.old"); + rename("/tftpboot/tftptestt.tmp.old","/tftpboot/tftptestt.tmp") if(-e "/tftpboot/tftptestt.tmp.old"); + return 0; + } +} + + +#------------------------------------------ +=head3 + Description: + Judge if DNS service is ready to use in current operating system + Attribute: list by input sequence + ip: DNS server's ip + Return value: + 1 : yes + 0 : no +=cut +#------------------------------------------ +sub isDnsReady{ + my $mnip=shift; + $mnip=shift if(($mnip) && ($mnip =~ /ProbeUtils/)); + my $hostname=shift; + my $domain=shift; + + my $output = `nslookup $mnip $mnip 2>&1`; + + if($?){ + return 0; + }else{ + chomp($output); + my $tmp=`echo "$output" |grep "Server:[\t\s]*$mnip" >/dev/null 2>&1`; + print "$tmp"; + return 0 if($?); + $tmp = `echo "$output"|grep "name ="|grep "$hostname\.$domain" >/dev/null 2>&1`; + return 0 if($?); + return 1; + } +} + +1; diff --git a/xCAT-probe/subcmds/xcatmn b/xCAT-probe/subcmds/xcatmn new file mode 100755 index 000000000..7e9c3c21c --- /dev/null +++ b/xCAT-probe/subcmds/xcatmn @@ -0,0 +1,475 @@ +#! /usr/bin/perl + +#use lib "/home/probe/lib/perl"; +use lib "/opt/xcat/probe/lib/perl"; +use ProbeUtils; +use File::Basename; +use Getopt::Long; + +my $proname=basename("$0"); +my $help; +my $mnip; +my $test; +my $output="stdout"; +my $verbose=0; +my $rst=0; + +$::USAGE = "Usage: + $proname -h + $proname -t + $proname [-m] [-f] [-v] + +Description: + After xcat installation, use this command to check if xcat has been installed correctly and is ready for use. + +Options: + -h : get usage information of $proname + -t : to verify if $proname can work, reserve option for probe framework + -m : specify current MN's IP address, if not specified, use master ip in site table + -f : specify where should $proname pass its output to. if not specified, pass output to STDOUT by default. + -v : output more information for debug +"; + +sub returncmdoutput{ + my $rst=shift; + chomp($rst); + my @lines=split("[\n\r]", $rst); + foreach my $line (@lines){ + ProbeUtils->send_msg("$output",0, "$line"); + } +} + + +#------------------------------------- +# main process +#------------------------------------- +if ( + !GetOptions("--help|h|?" => \$help, + "t"=> \$test, + "v"=> \$verbose, + "f=s" => \$output, + "m=s" => \$mnip)) +{ + ProbeUtils->send_msg("$output",2, "Invalid parameter for $proname"); + ProbeUtils->send_msg("$output",0, "$::USAGE"); + exit 1; +} + +if($help){ + if($output ne "stdout"){ + ProbeUtils->send_msg("$output",0, "$::USAGE"); + }else{ + print "$::USAGE"; + } + exit 0; +} + +if($test){ + ProbeUtils->send_msg("$output",3,"After xcat installation, use this command to check if xcat has been installed correctly and is ready for use. Before using this command , please install tftp, nslookup and wget commands ahead. The platform supported are redhat, sles and ubuntu."); + exit 0; +} + +my $hostname=`hostname -s`; +chomp($hostname); +my $hostipaddr=`hostname -i`; +chomp($hostipaddr); +my $othername=`hostname -a`; +chomp($othername); + +ProbeUtils->send_msg("$output",0,"Short hostname of this server is $hostname") if($verbose); +ProbeUtils->send_msg("$output",0,"The address of hostname $hostname is $hostipaddr") if($verbose); +ProbeUtils->send_msg("$output",0,"The other names of $hostname is $othername") if($verbose && ($othername ne "")); + +my $msg="Sub process 'xcatd: SSL listener' is running"; +my $xcatdproc = `ps aux|grep -v grep|grep xcatd`; +chomp($xcatdproc); +if($xcatdproc =~ /xcatd: SSL listener/){ + ProbeUtils->send_msg("$output",3,"$msg"); +}else{ + ProbeUtils->send_msg("$output",2,"$msg"); + $rst=1; +} + +$msg="Sub process 'xcatd: DB Access' is running"; +if($xcatdproc =~ /xcatd: DB Access/){ + ProbeUtils->send_msg("$output",3,"$msg"); +}else{ + ProbeUtils->send_msg("$output",2,"$msg"); + $rst=1; +} + +$msg="Sub process 'xcatd: UDP listener' is running"; +if($xcatdproc =~ /xcatd: UDP listener/){ + ProbeUtils->send_msg("$output",3,"$msg"); +}else{ + ProbeUtils->send_msg("$output",2,"$msg"); + $rst=1; +} + +$msg="Sub process 'xcatd: install monitor' is running"; +if($xcatdproc =~ /xcatd: install monitor/){ + ProbeUtils->send_msg("$output",3,"$msg"); +}else{ + ProbeUtils->send_msg("$output",2,"$msg"); + $rst=1; +} + +$msg="Sub process 'xcatd: Discovery worker' is running"; +if($xcatdproc =~ /xcatd: Discovery worker/){ + ProbeUtils->send_msg("$output",3,"$msg"); +}else{ + ProbeUtils->send_msg("$output",2,"$msg"); + $rst=1; +} + +$msg="Sub process 'xcatd: Command log writer' is running"; +if($xcatdproc =~ /xcatd: Command log writer/){ + ProbeUtils->send_msg("$output",3,"$msg"); +}else{ + ProbeUtils->send_msg("$output",1,"Sub process 'xcatd: Command log writer' isn't running"); +} +exit 1 if($rst); + + +my $xcatdport=`tabdump site 2>&1 | awk -F',' '/xcatdport/ { gsub(/"/, "", \$2) ; print \$2 }'`; +chomp($xcatdport); +ProbeUtils->send_msg("$output",0,"The port used by the xcatd daemon for client/server communication is $xcatdport") if($verbose); +$msg="xcatd is listening on port $xcatdport"; +my $cmdoutput = `netstat -ant|grep LISTEN|grep $xcatdport`; +if($?){ + ProbeUtils->send_msg("$output",2,"$msg"); + $rst=1; +}else{ + ProbeUtils->send_msg("$output",3,"$msg"); +} + +my $xcatiport=`tabdump site 2>&1| awk -F',' '/xcatiport/ { gsub(/"/, "", \$2) ; print \$2 }'`; +chomp($xcatiport); +ProbeUtils->send_msg("$output",0,"The port used by xcatd to receive install status updates from nodes is $xcatiport") if($verbose); +$msg="xcatd is listening on port $xcatiport"; +$cmdoutput = `netstat -ant|grep LISTEN|grep $xcatiport`; +if($?){ + ProbeUtils->send_msg("$output",2,"$msg"); + $rst=1; +}else{ + ProbeUtils->send_msg("$output",3,"$msg"); +} +exit 1 if($rst); + +$msg ="'lsxcatd -a' works"; +$cmdoutput=`lsxcatd -a 2>&1`; +$rst=$?; +returncmdoutput($cmdoutput) if($verbose); +if($rst){ + ProbeUtils->send_msg("$output",2,"$msg"); + exit $rst; +}else{ + ProbeUtils->send_msg("$output",3,"$msg"); +} + +my $masteripinsite=`tabdump site | awk -F',' '/master/ { gsub(/"/, "", \$2) ; print \$2 }'`; +chomp($masteripinsite); +ProbeUtils->send_msg("$output",0, "The value of 'master' in 'site' table is $masteripinsite") if($verbose); +ProbeUtils->send_msg("$output",2, "There isn't 'master' definition in 'site' talbe") if($masteripinsite eq ""); + +$msg="The value of 'master' in 'site' table is a IP address"; +if(ProbeUtils->isIpAddr("$masteripinsite")){ + ProbeUtils->send_msg("$output",3,"$msg"); +}else{ + ProbeUtils->send_msg("$output",2,"$msg"); + exit 1; +} + +if($mnip){ + $msg="The IP passed by command line equals the value of 'master' in 'site' table"; + if($mnip eq $masteripinsite){ + ProbeUtils->send_msg("$output",3,"$msg"); + }else{ + ProbeUtils->send_msg("$output",2,"$msg"); + $rst=1; + } +}else{ + ProbeUtils->send_msg("$output",0,"Use the value of 'master' of 'site' table as MNIP") if($verbose); + $mnip=$masteripinsite; +} + +ProbeUtils->send_msg("$output",0,"MNIP used in below checking is $mnip") if($verbose); + +$msg="There is configuration in 'passwd' table for 'system' for node provision"; +my $passwd=`tabdump passwd |awk -F',' '/system/ { gsub(/"/, "", \$2); gsub(/"/, "", \$3); print \$2,\$3 }'`; +chomp($passwd); +my ($username, $pw)=split(" ", $passwd); +if($username eq "" || $pw eq ""){ + ProbeUtils->send_msg("$output",0,"There isn't username or password for 'system' in 'passwd' table"); + ProbeUtils->send_msg("$output",2,"$msg"); + $rst=1; +}else{ + ProbeUtils->send_msg("$output",3,"$msg"); +} + +$msg="There is a network adapter on current server is configured by IP $mnip"; +my $nic=`ip addr show |grep -B2 $mnip|grep mtu|awk '{print \$2}'|sed -e 's/:\$//'`; +chomp($nic); +if("$nic" eq ""){ + ProbeUtils->send_msg("$output",2,"$msg"); + $rst=1; +}else{ + ProbeUtils->send_msg("$output",0,"IP $mnip belongs to network adapter $nic") if($verbose); + ProbeUtils->send_msg("$output",3,"$msg"); +} + +$msg="IP $mnip is a static IP on current server"; +if(ProbeUtils->isStaticIp("$mnip", "$nic")){ + ProbeUtils->send_msg("$output",3,"$msg"); +}else{ + ProbeUtils->send_msg("$output",1,"IP $mnip is not a static ip on current server"); +} + +$msg="$mnip belongs to one of networks defined in 'networks' table"; +my $networks=`tabdump networks|grep -v "^#"`; +$networks=~s/\"//g; +my $netcnt = `echo "$networks"|wc -l`; +my $hit=0; +for(my $i=1;$i<$netcnt+1;$i++){ + my $line=`echo "$networks" |sed -n ${i}p |awk -F"," '{print \$2,\$3,\$4}'`; + chomp($line); + if($line =~ /(.+) (.+) (.+)/){ + $hit=1 if(ProbeUtils->isIpBelongToNet("$1", "$2", $mnip) && ("$3" eq "$nic")); + } +} +if($hit){ + ProbeUtils->send_msg("$output",3,"$msg"); +}else{ + ProbeUtils->send_msg("$output",2,"$msg"); + $rst=1; +} + +$msg="There is domain definition in 'site' table"; +my $domain=`tabdump site | awk -F',' '/domain/ { gsub(/"/, "", \$2) ; print \$2 }'`; +chomp($domain); +if($domain){ + ProbeUtils->send_msg("$output",0,"The value of 'domain' in 'site' table is $domain") if($verbose); + ProbeUtils->send_msg("$output",3,"$msg"); +}else{ + ProbeUtils->send_msg("$output",2,"$msg"); + $rst=1; +} + +$msg="There are /install and /install/postscripts directory on current server"; +if(-e "/install/postscripts/"){ + ProbeUtils->send_msg("$output",3,"$msg"); +}else{ + ProbeUtils->send_msg("$output",2,"$msg"); + $rst=1; +} + +$msg="There is /tftpboot directory on current server"; +if(-e "/tftpboot/"){ + ProbeUtils->send_msg("$output",3,"$msg"); +}else{ + ProbeUtils->send_msg("$output",2,"$msg"); + $rst=1; +} + +my $expected=10; +$msg="The free space of / directory is more than $expected G"; +my $diskspace=`df -h|awk '{print \$4,\$6}'|grep -E "/\$"`; +if($?){ + ProbeUtils->send_msg("$output",0,"There isn't any filesystem mount on / directory"); + ProbeUtils->send_msg("$output",2,"$msg"); + $rst=1; +}else{ + chomp($diskspace); + my ($size, $dir) = split(" ", $diskspace); + $size=~s/G//g; + ProbeUtils->send_msg("$output",0,"The free space of / is $size G") if($verbose); + if($size<$expected){ + ProbeUtils->send_msg("$output",1,"The free space of / is less than $expected G"); + }else{ + ProbeUtils->send_msg("$output",3,"$msg"); + } +} + +$expected=1; +$msg="The free space of /var directory is more than $expected G"; +$diskspace=`df -h|awk '{print \$4,\$6}'|grep -E "/var\$"`; +if(!$?){ + chomp($diskspace); + my ($size, $dir) = split(" ", $diskspace); + $size=~s/G//g; + ProbeUtils->send_msg("$output",0,"The free space of /var is $size G") if($verbose); + if($size<$expected){ + ProbeUtils->send_msg("$output",1,"The free space of /var is less than $expected G"); + }else{ + ProbeUtils->send_msg("$output",3,"$msg"); + } +} + +$expected=1; +$msg="The free space of /tmp directory is more than $expected G"; +$diskspace=`df -h|awk '{print \$4,\$6}'|grep -E "/tmp\$"`; +if(!$?){ + chomp($diskspace); + my ($size, $dir) = split(" ", $diskspace); + $size=~s/G//g; + ProbeUtils->send_msg("$output",0,"The free space of /tmp is $size G") if($verbose); + if($size<$expected){ + ProbeUtils->send_msg("$output",1,"The free space of /tmp is less than $expected G"); + }else{ + ProbeUtils->send_msg("$output",3,"$msg"); + } +} + + +$expected=10; +$msg="The free space of /install directory is more than $expected G"; +$diskspace=`df -h|awk '{print \$4,\$6}'|grep -E "/install\$"`; +if(!$?){ + chomp($diskspace); + my ($size, $dir) = split(" ", $diskspace); + $size=~s/G//g; + ProbeUtils->send_msg("$output",0,"The free space of /install is $size G") if($verbose); + if($size<$expected){ + ProbeUtils->send_msg("$output",1,"The free space of /install is less than $expected G"); + }else{ + ProbeUtils->send_msg("$output",3,"$msg"); + } +} + +$msg="SELinux is disabled on current server"; +if(ProbeUtils->isSelinuxEnable()){ + ProbeUtils->send_msg("$output",2,"$msg"); + $rst=1; +}else{ + ProbeUtils->send_msg("$output",3,"$msg"); +} + +$msg="Firewall is closed on current server"; +if(ProbeUtils->isFirewallOpen()){ + ProbeUtils->send_msg("$output",2,"$msg"); + $rst=1; +}else{ + ProbeUtils->send_msg("$output",3,"$msg"); +} + +`which wget > /dev/null 2>&1`; +if($?){ + ProbeUtils->send_msg("$output",1,"wget command isn't installed on current server, skip checking HTTP service"); +}else{ + $msg="HTTP service is ready on $mnip"; + if(ProbeUtils->isHttpReady("$mnip")){ + ProbeUtils->send_msg("$output",3,"$msg"); + }else{ + ProbeUtils->send_msg("$output",2,"$msg"); + $rst=1; + } +} + +`which tftp > /dev/null 2>&1`; +if($?){ + ProbeUtils->send_msg("$output",1,"tftp command isn't installed in current server, skip checking tftp service"); +}else{ + $msg="TFTP service is ready on $mnip"; + if(ProbeUtils->isTftpReady("$mnip")){ + ProbeUtils->send_msg("$output",3,"$msg"); + }else{ + ProbeUtils->send_msg("$output",2,"$msg"); + $rst =1; + } +} + +`which nslookup > /dev/null 2>&1`; +if($?){ + ProbeUtils->send_msg("$output",1,"nslookup command isn't installed in current server, skip checking DNS service"); +}else{ + $msg="DNS server is ready on $mnip"; + ProbeUtils->send_msg("$output",0,"hostname used to check DNS is $hostname, domain used to check DNS is $domain") if($verbose); + if(ProbeUtils->isDnsReady("$mnip","$hostname", "$domain")){ + ProbeUtils->send_msg("$output",3,"$msg"); + }else{ + ProbeUtils->send_msg("$output",2,"$msg"); + $rst =1; + } +} + +my $os=ProbeUtils->getOS(); +my $leasefile=""; +$leasefile="/var/lib/dhcpd/dhcpd.leases" if($os =~ /redhat/i); +$leasefile="/var/lib/dhcp/db/dhcpd.leases" if($os =~ /sles/i); +$leasefile="/var/lib/dhcp/dhcpd.leases" if($os =~ /ubuntu/i); +$msg="The size of $leasefile is less than 100M"; +my $filesizetmp=`du -sb $leasefile`; +if($?){ + returncmdoutput($filesizetmp) if($verbose); + ProbeUtils->send_msg("$output",2,"$msg"); + $rst=1; +}else{ + chomp($filesizetmp); + my ($size, $file) = split(" ", $filesizetmp); + ProbeUtils->send_msg("$output",0,"The size of $leasefile is $size bytes") if($verbose); + if($size > 104857600){ + ProbeUtils->send_msg("$output",1,"The size of $leasefile is more than 100M"); + }else{ + ProbeUtils->send_msg("$output",3,"$msg"); + } +} + +my $msg="DHCP service is ready on $mnip"; +my $rc=0; +{ #very important brace to create a block + my $tmp=`chdef xcatmntest groups=all ip=$mnip mac=aa:aa:aa:aa:aa:aa`; + if($?){ + returncmdoutput($tmp) if($verbose); + ProbeUtils->send_msg("$output",0,"Simulate a node by chdef failed") if($verbose); + $rc=1; + last; + }else{ + ProbeUtils->send_msg("$output",0,"Simulate a node xcatmntest to do dhcp test") if($verbose); + } + + $tmp=`makehosts xcatmntest`; + if($?){ + returncmdoutput($tmp) if($verbose); + ProbeUtils->send_msg("$output",0,"makehosts xcatmntest failed") if($verbose); + $rc=1; + `rmdef xcatmntest`; + last; + } + + $tmp = `makedhcp xcatmntest 2>&1`; + if($?){ + returncmdoutput($tmp) if($verbose); + ProbeUtils->send_msg("$output",0,"makedhcp xcatmntest failed") if($verbose); + $rc=1; + `makehosts -d xcatmntest && rmdef xcatmntest`; + last; + } + + $tmp = `makedhcp -q xcatmntest`; + if($?){ + returncmdoutput($tmp) if($verbose); + ProbeUtils->send_msg("$output",0,"makedhcp -q xcatmntest failed") if($verbose); + $rc=1; + `makedhcp -d xcatmntest && makehosts -d xcatmntest && rmdef xcatmntest`; + last; + } + chomp($tmp); + if($tmp !~ /xcatmntest: ip-address = $mnip, hardware-address = aa:aa:aa:aa:aa:aa/){ + returncmdoutput($tmp) if($verbose); + ProbeUtils->send_msg("$output",0,"DHCP server's reply is wrong") if($verbose); + $rc=1; + `makedhcp -d xcatmntest && makehosts -d xcatmntest && rmdef xcatmntest`; + last; + } + + ProbeUtils->send_msg("$output",0,"Start to clear simulate information for dhcp test") if($verbose); + $tmp=`makedhcp -d xcatmntest && makehosts -d xcatmntest && rmdef xcatmntest`; + returncmdoutput($tmp) if($verbose); +} +if($rc){ + ProbeUtils->send_msg("$output",2,"$msg"); + $rst=1; +}else{ + ProbeUtils->send_msg("$output",3,"$msg"); +} +exit $rst ; diff --git a/xCAT-probe/xcatprobe b/xCAT-probe/xcatprobe new file mode 100755 index 000000000..1e602b35f --- /dev/null +++ b/xCAT-probe/xcatprobe @@ -0,0 +1,258 @@ +#!/usr/bin/env perl + +use File::Basename; +use Data::Dumper; +use File::Path; +use POSIX qw(WNOHANG setsid :errno_h); +use Term::ANSIColor qw(:constants); +$Term::ANSIColor::AUTORESET=1; + +my $pro_name=basename($0); +my $pro_dir=dirname($0); +#my $plugin_dir="$pro_dir/subcmds"; +my $plugin_dir="/opt/xcat/probe/subcmds"; +my %cmds=(); + +my $verbose=0; +my $nocolor=0; +my $help=0; +my $list=0; + +$::USAGE = "Usage: +xcatprobe -h +xcatprobe -l +xcatprobe -v +xcatprobe [-n] + +Options: + -h : get usage information of $pro_name + -l : list all valid sub commands + -v : print verbose information of $pro_name + -n : print output without colors +"; + +#----------------------------------- +=head3 + Description: + Load sub commands from ~/subcmds directory + Using -t option of command to judge if it is valid. + If command in ~/subcmds has syntax error, or doesn't follow interface specification, this command will be skipped +=cut +#----------------------------------- +sub loadsubcmds{ + my @candidate=glob("$plugin_dir/*"); + my @subcmds=(); + my @validflag=("debug", "warning", "failed", "ok"); + my $output; + + print "Starting to load sub command form ~/subcmds.............\n" if($verbose); + + foreach (@candidate) { + my $cmdname = basename("$_"); + $output = `$_ -t 2>&1`; + chomp($output); + + print "\n-->$_\n[OUTPUT]:\n$output\n" if($verbose); + if($output !~ /\[(\w+)\]\s*:\s*(.+)/){ + print "skip $_ for doing '$_ -t' failed, bad format\n" if($verbose); + next; + }else{ + my $desc =$2; + unless(@validflag ~~ /$1/){ + print "skip $_ for doing '$_ -t' failed, invalid flag\n" if($verbose); + next; + } + $cmds{$cmdname} = $desc; + print "load $_ \n" if($verbose); + } + } + print "\nLoad sub command.........[done]\n" if($verbose); +} + + +#----------------------------------- +=head3 + Description: + Format the output of sub command, make them colorfully. +=cut +#---------------------------------- +sub format_cmd_output{ + my $line=shift; + my $nocolor=shift; + + if($line =~ /\[(\w+)\]\s*:\s*(.+)/){ + my $flag = $1; + my $msg = $2; + if($flag =~ /failed/i){ + if($nocolor){ + print "[FAIL] "; + }else{ + print BOLD RED "[FAIL] "; + } + }elsif($flag =~ /warning/i){ + if($nocolor){ + print "[WARN] "; + }else{ + print BOLD BLUE "[WARN] "; + } + }elsif($flag =~ /ok/i){ + if($nocolor){ + print "[ OK ] "; + }else{ + print BOLD GREEN "[ OK ] "; + } + }elsif($flag =~ /debug/i){ + print " "; + } + print "$msg\n"; + }else{ + print "$line\n"; + } + return 0; +} + +#----------------------------------- +=head3 + Description: + List all valid sub command in ~/subcmds directory +=cut +#---------------------------------- +sub listvalidsubcmd{ + my $maxlen=0; + foreach my $key (keys %cmds) { + $maxlen=length($key) if(length($key)>$maxlen); + } + $maxlen+=4; + print "Supported sub commands are:\n"; + foreach my $key (keys %cmds){ + my @desc=split(" ", $cmds{$key}); + my $str=""; + my @formatdesc=(); + foreach my $word (@desc){ + $str.=$word." "; + if(length($str)>100){ + push @formatdesc, $str; + $str=""; + } + } + push @formatdesc, $str; + if($nocolor){ + print "$key"; + }else{ + print BOLD GREEN "$key"; + } + my $space=" " x ($maxlen-length($key)); + print "$space $formatdesc[0]\n"; + delete $formatdesc[0]; + $space=" " x $maxlen; + foreach my $line (@formatdesc){ + print "$space $line\n" if(length($line)); + } + + } +} + +####################################### +# main +####################################### +my @tmpargv=@ARGV; +my @supportopt=("-v","-h","-l","-n"); +my $pluginname; +my $optnum=0; +foreach my $attr (@tmpargv){ + if($attr =~ /^-/){ + unless(@supportopt ~~ /$attr/){ + print "Unsupported attribute: $attr\n"; + print $::USAGE; + exit 1; + } + $optnum++; + $help=1 if($attr eq "-h"); + $verbose=1 if($attr eq "-v"); + $list=1 if($attr eq "-l"); + $nocolor=1 if($attr eq "-n"); + }else{ + $pluginname=$attr; + last; + } +} + +&loadsubcmds; +if(defined ($pluginname)){ + my $hit=0; + foreach my $key (keys %cmds){ + $hit=1 if($pluginname eq $key); + } + unless($hit){ + print "Unsupported sub command: $pluginname\n"; + &listvalidsubcmd; + exit 1; + } +} + +if($help){ + print $::USAGE; + exit 0; +} + +if($ARGV[0] eq "-l"){ + &listvalidsubcmd; + exit 0; +} + +if(!defined ($pluginname)){ + print "There isn't sub command input from command line\n"; + exit 0; +} + +for(my $i =0; $i<$optnum+1; $i++){ + shift @tmpargv; +} +my $pluginattrs = join(" ", @tmpargv); + +my $date = `date +"%Y%m%d%H%M%S"`; +chomp($date); +my $cmmpath="/tmp/probe"; +my $cmmfile="$cmmpath/$pluginname.$date"; +mkpath("$cmmpath") unless(-d "$cmmpath"); +`touch $cmmfile`; +my $subcmd="$plugin_dir/$pluginname -f $cmmfile $pluginattrs"; + +print "\n[main] subcmd = $subcmd\n" if($verbose); + +my $subproc = fork(); +my $subrst=0; +if(!defined($subproc)){ + print "Unable to fork new process to run subcommand\n"; + exit 1; +}elsif($subproc==0){ + $SIG{INT} = sub { + print "Sub proc $$ recrive INT signal to exit"; + exit 0; + }; + print "[sub $$] run $subcmd\n----------------------\n" if($verbose); + `$subcmd`; + exit $? ; +} + +if(!open (CMMFILE, "$cmmfile") ) { + print "[main] Failed to open $cmmfile\n"; + exit 1; +} +my $offset = 0; +my $prst=0; +if($subproc){ + do{ + seek(CMMFILE,$offset,0); + while(my $line = ){ + chomp($line); + format_cmd_output($line, $nocolor); + } + $offset=tell; + }while(waitpid($subproc, WNOHANG)==0) +} +close(CMMFILE); + +unlink($cmmfile); +exit 0; + From 41b500809fd428795e7c6e04d51c1060dfcd9fc5 Mon Sep 17 00:00:00 2001 From: junxiawang Date: Thu, 26 May 2016 07:38:00 -0400 Subject: [PATCH 030/310] modify set up dockerhost test case --- .../bundle/ubuntu14.04.3_x86_64.bundle | 2 +- .../bundle/ubuntu14.04.4_x86_64.bundle | 4 +- .../autotest/bundle/ubuntu16.04_x86_64.bundle | 2 +- xCAT-test/autotest/bundle/x_ubuntu_cmd.bundle | 1 + .../ubuntu_full_installation_vm_docker | 49 ++++++------------- 5 files changed, 21 insertions(+), 37 deletions(-) diff --git a/xCAT-test/autotest/bundle/ubuntu14.04.3_x86_64.bundle b/xCAT-test/autotest/bundle/ubuntu14.04.3_x86_64.bundle index e7ffd6bb9..d7c88748f 100644 --- a/xCAT-test/autotest/bundle/ubuntu14.04.3_x86_64.bundle +++ b/xCAT-test/autotest/bundle/ubuntu14.04.3_x86_64.bundle @@ -1,6 +1,5 @@ Ubuntu_diskless_installation_flat_x86_vm Ubuntu_full_installation_flat_x86_vm -Full_installation_flat_docker makehosts_h makehosts_help makehosts_n_noderange @@ -244,6 +243,7 @@ switchdiscover_range_x switchdiscover_range_z switchdiscover_range_z_V nodeset_check_warninginfo +Full_installation_flat_docker rpower_stop rpower_start rpower_state diff --git a/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle b/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle index eeab10ae7..7c70fa1b9 100644 --- a/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle +++ b/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle @@ -1,6 +1,5 @@ Ubuntu_diskless_installation_flat_x86_vm Ubuntu_full_installation_flat_x86_vm -Full_installation_flat_docker makehosts_h makehosts_help makehosts_n_noderange @@ -244,6 +243,7 @@ switchdiscover_range_x switchdiscover_range_z switchdiscover_range_z_V nodeset_check_warninginfo +Full_installation_flat_docker rpower_stop rpower_start rpower_state @@ -256,4 +256,4 @@ rmdocker_h rmdocker_command rmdocker_f_command lsdocker_h_command -lsdocker_l_command \ No newline at end of file +lsdocker_l_command diff --git a/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle b/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle index 08f275336..a80535bae 100644 --- a/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle +++ b/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle @@ -1,6 +1,5 @@ Ubuntu_diskless_installation_flat_x86_vm Ubuntu_full_installation_flat_x86_vm -Full_installation_flat_docker makehosts_h makehosts_help makehosts_n_noderange @@ -250,6 +249,7 @@ run_command_with_XCATBYPASS_systemd disable_root_permission_in_policy_table_systemd assign_certain_command_permission_systemd nodeset_check_warninginfo +Full_installation_flat_docker rpower_stop rpower_start rpower_state diff --git a/xCAT-test/autotest/bundle/x_ubuntu_cmd.bundle b/xCAT-test/autotest/bundle/x_ubuntu_cmd.bundle index 11ea27fae..fe3665fb8 100644 --- a/xCAT-test/autotest/bundle/x_ubuntu_cmd.bundle +++ b/xCAT-test/autotest/bundle/x_ubuntu_cmd.bundle @@ -241,6 +241,7 @@ switchdiscover_range_x switchdiscover_range_z switchdiscover_range_z_V nodeset_check_warninginfo +Full_installation_flat_docker rpower_stop rpower_start rpower_state diff --git a/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_docker b/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_docker index 732349b1e..20b2a754d 100644 --- a/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_docker +++ b/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_docker @@ -1,54 +1,37 @@ start:Full_installation_flat_docker os:Linux -cmd:copycds $$ISO +cmd:mkdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-dockerhost -u profile=compute provmethod=install check:rc==0 -cmd:if [[ "__GETNODEATTR($$DOCKERHOST,arch)__" != "ppc64" ]];then rmvm $$DOCKERHOST -f && chdef $$DOCKERHOST mac= && mkvm $$DOCKERHOST ; fi +cmd:if [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu" ]];then ver=`cat /etc/*-release |grep "VERSION_ID"| awk -F '"' '{print $2}'| awk -F"." '{printf "%s%s\n",$1,$2}'` ; chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-dockerhost otherpkgdir="https://apt.dockerproject.org/repo ubuntu-trusty main,http://cz.archive.ubuntu.com/ubuntu trusty main" otherpkglist="/install/custom/ubuntu$ver/ubuntu"$ver"_docker.pkglist" osdistroname="__GETNODEATTR($$CN,os)__ ";fi check:rc==0 -cmd:makehosts $$DOCKERHOST +cmd:if [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu" ]];then ver=`cat /etc/*-release |grep "VERSION_ID"| awk -F '"' '{print $2}'| awk -F"." '{printf "%s%s\n",$1,$2}'` ; mkdir -p /install/custom/ubuntu$ver/ ; chdef -t osimage -o __GETNODEATTR($$DOCKERHOST,os)__-__GETNODEATTR($$DOCKERHOST,arch)__-install-dockerhost otherpkglist="/install/custom/ubuntu$ver/ubuntu"$ver"_docker.pkglist" pkglist="/install/custom/ubuntu$ver/ubuntu$ver.pkglist";fi check:rc==0 -cmd:makedns -n +cmd:if [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu" ]];then ver=`cat /etc/*-release |grep "VERSION_ID"| awk -F '"' '{print $2}'| awk -F"." '{printf "%s%s\n",$1,$2}'` ;for i in openssh-server ntp gawk nfs-common snmpd bridge-utils; do cat /install/custom/ubuntu$ver/ubuntu$ver.pkglist|grep "$i$";if [ $? -ne 0 ] ; then echo "$i" >> /install/custom/ubuntu$ver/ubuntu$ver.pkglist; fi done;fi check:rc==0 -cmd:sleep 60 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:makeconservercf $$DOCKERHOST -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$DOCKERHOST -check:output=~$$DOCKERHOST -cmd: mkdef -t osimage -o __GETNODEATTR($$DOCKERHOST,os)__-__GETNODEATTR($$DOCKERHOST,arch)__-install-dockerhost -u profile=compute provmethod=install -check:rc==0 -cmd:if [[ "__GETNODEATTR($$DOCKERHOST,os)__" =~ "ubuntu" ]];then ver=`cat /etc/*-release |grep "VERSION_ID"| awk -F '"' '{print $2}'| awk -F"." '{printf "%s%s\n",$1,$2}'` ; chdef -t osimage -o __GETNODEATTR($$DOCKERHOST,os)__-__GETNODEATTR($$DOCKERHOST,arch)__-install-dockerhost otherpkgdir="https://apt.dockerproject.org/repo ubuntu-trusty main,http://cz.archive.ubuntu.com/ubuntu trusty main" otherpkglist="/install/custom/ubuntu$ver/ubuntu"$ver"_docker.pkglist" osdistroname="__GETNODEATTR($$DOCKERHOST,os)__ ";fi -check:rc==0 -cmd:if [[ "__GETNODEATTR($$DOCKERHOST,os)__" =~ "ubuntu" ]];then ver=`cat /etc/*-release |grep "VERSION_ID"| awk -F '"' '{print $2}'| awk -F"." '{printf "%s%s\n",$1,$2}'` ; mkdir -p /install/custom/ubuntu$ver/ ; chdef -t osimage -o __GETNODEATTR($$DOCKERHOST,os)__-__GETNODEATTR($$DOCKERHOST,arch)__-install-dockerhost otherpkglist="/install/custom/ubuntu$ver/ubuntu"$ver"_docker.pkglist" pkglist="/install/custom/ubuntu$ver/ubuntu$ver.pkglist";fi -check:rc==0 -cmd:if [[ "__GETNODEATTR($$DOCKERHOST,os)__" =~ "ubuntu" ]];then ver=`cat /etc/*-release |grep "VERSION_ID"| awk -F '"' '{print $2}'| awk -F"." '{printf "%s%s\n",$1,$2}'` ;for i in openssh-server ntp gawk nfs-common snmpd bridge-utils; do cat /install/custom/ubuntu$ver/ubuntu$ver.pkglist|grep "$i$";if [ $? -ne 0 ] ; then echo "$i" >> /install/custom/ubuntu$ver/ubuntu$ver.pkglist; fi done;fi -check:rc==0 -cmd:if [[ "__GETNODEATTR($$DOCKERHOST,os)__" =~ "ubuntu14.04" ]];then ver=`cat /etc/*-release |grep "VERSION_ID"| awk -F '"' '{print $2}'| awk -F"." '{printf "%s%s\n",$1,$2}'`; for i in docker-engine;do cat /install/custom/ubuntu$ver/ubuntu"$ver"\_docker.pkglist |grep "$i$";if [ $? -ne 0 ] ; then echo "$i" >> /install/custom/ubuntu$ver/ubuntu"$ver"\_docker.pkglist;fi done;fi +cmd:if [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu14.04" ]];then ver=`cat /etc/*-release |grep "VERSION_ID"| awk -F '"' '{print $2}'| awk -F"." '{printf "%s%s\n",$1,$2}'`; for i in docker-engine;do cat /install/custom/ubuntu$ver/ubuntu"$ver"\_docker.pkglist |grep "$i$";if [ $? -ne 0 ] ; then echo "$i" >> /install/custom/ubuntu$ver/ubuntu"$ver"\_docker.pkglist;fi done;fi check:rc==0 -cmd: chdef $$DOCKERHOST -p postbootscripts="setupdockerhost mynet0=$$MYNET0VALUE@$$DOCKERHOSIP:$$NICNAME" +cmd: chdef $$CN -p postbootscripts="setupdockerhost mynet0=$$MYNET0VALUE@$$DOCKERHOSIP:$$NICNAME" check:rc==0 -cmd:nodeset $$DOCKERHOST osimage=__GETNODEATTR($$DOCKERHOST,os)__-__GETNODEATTR($$DOCKERHOST,arch)__-install-dockerhost +cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-dockerhost check:rc==0 -cmd:rpower $$DOCKERHOST boot +cmd:rpower $$CN boot check:rc==0 cmd:sleep 40 -cmd:lsdef -l $$DOCKERHOST | grep status +cmd:lsdef -l $$CN | grep status cmd:sleep 3600 check:rc==0 -cmd:ping $$DOCKERHOST -c 3 -check:output=~64 bytes from $$DOCKERHOST +cmd:ping $$CN -c 3 +check:output=~64 bytes from $$CN check:rc==0 -cmd:lsdef -l $$DOCKERHOST | grep status +cmd:lsdef -l $$CN | grep status check:output=~booted -cmd:xdsh $$DOCKERHOST date +cmd:xdsh $$CN date check:rc==0 -cmd:xdsh $$DOCKERHOST "docker -v" +cmd:xdsh $$CN "docker -v" check:output=~Docker version check:rc==0 -cmd:xdsh $$DOCKERHOST "docker pull $$DOCKERIMAGE" +cmd:xdsh $$CN "docker pull $$DOCKERIMAGE" check:rc==0 -cmd:rmdef -t osimage -o __GETNODEATTR($$DOCKERHOST,os)__-__GETNODEATTR($$DOCKERHOST,arch)__-install-dockerhost +cmd:rmdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-dockerhost check:rc==0 end From 32517a5bd7f2d5623931b2d0b15cc302b3251c0c Mon Sep 17 00:00:00 2001 From: junxiawang Date: Thu, 26 May 2016 08:48:36 -0400 Subject: [PATCH 031/310] modify docker host setup according to tingting's comments --- .../installation/ubuntu_full_installation_vm_docker | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_docker b/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_docker index 20b2a754d..b2fa46c92 100644 --- a/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_docker +++ b/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_docker @@ -1,5 +1,15 @@ start:Full_installation_flat_docker os:Linux +cmd:copycds $$ISO +check:rc==0 +cmd:if [ "__GETNODEATTR($$CN,arch)__" != "ppc64" -a "__GETNODEATTR($$CN,mgt)__" != "ipmi" ];then if [[ "__GETNODEATTR($$CN,vmstorage)__" =~ "phy" ]]; then rmvm $$CN -f -p && mkvm $$CN; else rmvm $$CN -f -p && mkvm $$CN -s 20G; fi;fi +check:rc=0 +cmd:makedns -n +check:rc==0 +cmd:makeconservercf +check:rc==0 +cmd:makedhcp -n +check:rc==0 cmd:mkdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-dockerhost -u profile=compute provmethod=install check:rc==0 cmd:if [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu" ]];then ver=`cat /etc/*-release |grep "VERSION_ID"| awk -F '"' '{print $2}'| awk -F"." '{printf "%s%s\n",$1,$2}'` ; chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-dockerhost otherpkgdir="https://apt.dockerproject.org/repo ubuntu-trusty main,http://cz.archive.ubuntu.com/ubuntu trusty main" otherpkglist="/install/custom/ubuntu$ver/ubuntu"$ver"_docker.pkglist" osdistroname="__GETNODEATTR($$CN,os)__ ";fi From 9d7120d3c6c2627b41ec00e23b15c579de1c13f4 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Thu, 26 May 2016 15:53:41 -0400 Subject: [PATCH 032/310] Add more information to the label to identify that the network boot is the Genesis Kernel and the IP which is serving it --- xCAT-server/lib/xcat/plugins/mknb.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/mknb.pm b/xCAT-server/lib/xcat/plugins/mknb.pm index 565872b12..eede1c6ae 100644 --- a/xCAT-server/lib/xcat/plugins/mknb.pm +++ b/xCAT-server/lib/xcat/plugins/mknb.pm @@ -254,7 +254,7 @@ CREAT_CONF_FILE: open($cfg,">","$tftpdir/xcat/xnba/nets/$net.elilo"); print $cfg "default=\"xCAT Genesis\"\ndelay=5\n\n"; print $cfg 'image=/tftpboot/xcat/genesis.kernel.'."$arch\n"; - print $cfg " label=\"xCAT Genesis\"\n"; + print $cfg " label=\"xCAT Genesis (".$normnets->{$_}.")\"\n"; if ($lzma_exit_value) { print $cfg " initrd=/tftpboot/xcat/genesis.fs.$arch.gz\n"; } else { @@ -271,7 +271,7 @@ CREAT_CONF_FILE: } elsif ($arch =~ /ppc/) { open($cfgfile,">", "$tftpdir/pxelinux.cfg/p/$net"); print $cfgfile "default xCAT\n"; - print $cfgfile " label xCAT\n"; + print $cfgfile " label xCAT Genesis (".$normnets->{$_}.")\n"; print $cfgfile " kernel http://".$normnets->{$_}.":80/$tftpdir/xcat/genesis.kernel.$arch\n"; print $cfgfile " initrd http://".$normnets->{$_}.":80/$initrd_file\n"; print $cfgfile ' append "quiet xcatd='.$normnets->{$_}.":$xcatdport $consolecmdline\"\n"; @@ -308,7 +308,7 @@ CREAT_CONF_FILE: } elsif ($arch =~ /ppc/) { open($cfgfile,">","$tftpdir/etc/".lc($_)); print $cfgfile "default xCAT\n"; - print $cfgfile " label xCAT\n"; + print $cfgfile " label xCAT Genesis (".$normnets->{$_}.")\n"; print $cfgfile " kernel http://".$hexnets->{$_}.":80/$tftpdir/xcat/genesis.kernel.$arch\n"; print $cfgfile " initrd http://".$hexnets->{$_}.":80/$initrd_file\n"; print $cfgfile ' append "quiet xcatd='.$hexnets->{$_}.":$xcatdport $consolecmdline\"\n"; From 01d73715067f681e555a17581b3181661133e301 Mon Sep 17 00:00:00 2001 From: chenglch Date: Fri, 27 May 2016 02:51:39 -0400 Subject: [PATCH 033/310] Fix error when stopping tftp process in AAsn.pm The check logic that wait for the tftp process can not be finished due to the empty loop. This patch aims to check the status of process group in the loop. close-issue: #1219 --- xCAT-server/lib/xcat/plugins/AAsn.pm | 47 ++++++++++++++++------------ 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/AAsn.pm b/xCAT-server/lib/xcat/plugins/AAsn.pm index e09e33aba..49523111e 100755 --- a/xCAT-server/lib/xcat/plugins/AAsn.pm +++ b/xCAT-server/lib/xcat/plugins/AAsn.pm @@ -1411,31 +1411,38 @@ sub enable_TFTPhpa if (-x "/usr/sbin/in.tftpd") { - system("killall in.tftpd"); #xinetd can leave behind blocking tftp servers even if it won't start new ones - if ($distro =~ /ubuntu.*/i){ - sleep 1; - my @checkproc=`ps axf|grep -v grep|grep in.tftpd`; - if (@checkproc){ - system("stop tftpd-hpa"); + system("killall in.tftpd"); #xinetd can leave behind blocking tftp servers even if it won't start new ones + if ($distro =~ /ubuntu.*/i || $distro =~ /debian.*/i){ + sleep 1; + my @checkproc=`ps axf|grep -v grep|grep in.tftpd`; + if (@checkproc){ + xCAT::Utils->stopservice("tftpd-hpa"); + } } - } - if ($distro =~ /debian.*/i){ - sleep 1; - my @checkproc=`ps axf|grep -v grep|grep in.tftpd`; - if (@checkproc){ - #system("service tftpd-hpa stop"); - xCAT::Utils->stopservice("tftpd-hpa"); + my @tftpprocpids=`ps axf | grep -v 'awk /in.tftpd/' | awk '/in.tftpd/ {print \$1}'`; + if (@tftpprocpids) { + my %pids_map; + my $count = 0; + map { chomp; $pids_map{$_} = 1 } @tftpprocpids; + while (keys %pids_map) { + foreach my $pid (keys %pids_map) { + if (xCAT::Utils->is_process_exists($pid)) { + $count++; + if($count >= 50) { + xCAT::MsgUtils->message("S","Error: can not stop tftp process in 5 seconds."); + return 1; + } + sleep 0.1; + } else { + delete $pids_map{$pid} + } + } + } } - } - my @tftpprocs=`ps axf|grep -v grep|grep in.tftpd`; - while (@tftpprocs) { - sleep 0.1; - } system("$startcmd"); } - - return 0; + return 0; } # enable or disable proxydhcp service From e44b37d53c039ce64ec946d637a0001334cfe1c6 Mon Sep 17 00:00:00 2001 From: junxiawang Date: Fri, 27 May 2016 08:53:44 -0400 Subject: [PATCH 034/310] add cases' variables --- xCAT-test/autotest/linux.conf.template | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/xCAT-test/autotest/linux.conf.template b/xCAT-test/autotest/linux.conf.template index 25bdaf241..c5db1c1d5 100644 --- a/xCAT-test/autotest/linux.conf.template +++ b/xCAT-test/autotest/linux.conf.template @@ -88,8 +88,26 @@ DOCKERHOSIP=10.4.27.10 DOCKERMNXCAT=xcatmn MYNET0VALUE=10.0.0.0/8 DOCKERCN=host05c08 -DOCKERHOST=c910f04x27v09 #docker host setup end +#For installnics start +INSTALLNICIP=10.2.2.27 +#End +#For image define start +STATELITE=rhels7.2-ppc64-statelite-compute +STATELESS=rhels7.2-ppc64-netboot-compute +#End +#For switch case start +range=10.4-5.24-25.1 +#End +#For ntp case start +extntpserversip=10.2.1.12 +DATE=2016 +#End +#For bmc test case start +bmcrange=10.4.30.254 +bmcusername=USERID +bmcpasswd=PASSW0RD +#End [Custom] #commands run before test From cd19f390b1eaf9578d8d334fd738dcaa4b64ca62 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Fri, 27 May 2016 11:31:40 -0400 Subject: [PATCH 035/310] man5 and man7 section formatting changes --- create_man_pages.py | 2 +- docs/source/advanced/index.rst | 1 - perl-xCAT/db2man | 2 +- perl-xCAT/xCAT/Schema.pm | 56 ++++++++++++++++++---------------- 4 files changed, 31 insertions(+), 30 deletions(-) diff --git a/create_man_pages.py b/create_man_pages.py index 3002f2d20..2a5ff368a 100755 --- a/create_man_pages.py +++ b/create_man_pages.py @@ -130,7 +130,7 @@ for component in COMPONENTS: cmd = "perl -I %s/share/perl5 %s/bin/%s " %(prefix_path, prefix_path, POD2RST) cmd += " --infile=%s --outfile=%s --title=%s.%s" %(pod_input, rst_output, title, man_ver) - print cmd + # print cmd os.system(cmd) if man_ver == '1' or man_ver == '8': fix_vertical_bar(rst_output) diff --git a/docs/source/advanced/index.rst b/docs/source/advanced/index.rst index 851788614..dacf235d0 100755 --- a/docs/source/advanced/index.rst +++ b/docs/source/advanced/index.rst @@ -22,5 +22,4 @@ Advanced Topics softlayer/index.rst switches/index.rst sysclone/index.rst - webservices/index.rst zones/index.rst diff --git a/perl-xCAT/db2man b/perl-xCAT/db2man index 55d738ce9..56430a3c3 100755 --- a/perl-xCAT/db2man +++ b/perl-xCAT/db2man @@ -417,7 +417,7 @@ EOS2 foreach my $a (sort keys %attrlist) { my $d = join("\nor\n", @{$attrlist{$a}->{'descriptions'}}); - $d =~ s/\n/\n\n/sg; # if there are newlines, double them so pod sees a blank line, otherwise pod will ignore them + #$d =~ s/\n/\n\n/sg; # if there are newlines, double them so pod sees a blank line, otherwise pod will ignore them my $t = '(' . join(', ',@{$attrlist{$a}->{'tables'}}) . ')'; #print FILE "\nB<$a> - $d\n"; print FILE "\n=item B<$a> $t\n\n$d\n"; diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index e7b7b0d97..27dd95318 100755 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -213,7 +213,8 @@ use xCAT::ExtTab; 'nicmodel' => 'Model of NICs that will be provided to VMs (i.e. e1000, rtl8139, virtio, etc)', 'bootorder' => 'Boot sequence (i.e. net,hd)', 'clockoffset' => 'Whether to have guest RTC synced to "localtime" or "utc" If not populated, xCAT will guess based on the nodetype.os contents.', - 'virtflags' => 'General flags used by the virtualization method. For example, in Xen it could, among other things, specify paravirtualized setup, or direct kernel boot. For a hypervisor/dom0 entry, it is the virtualization method (i.e. "xen"). For KVM, the following flag=value pairs are recognized: + 'virtflags' => 'General flags used by the virtualization method. + For example, in Xen it could, among other things, specify paravirtualized setup, or direct kernel boot. For a hypervisor/dom0 entry, it is the virtualization method (i.e. "xen"). For KVM, the following flag=value pairs are recognized: imageformat=[raw|fullraw|qcow2] raw is a generic sparse file that allocates storage on demand fullraw is a generic, non-sparse file that preallocates all space @@ -275,10 +276,11 @@ use xCAT::ExtTab; table_descr => 'Node storage resources', descriptions => { node => 'The node name', - controller => 'The management address to attach/detach new volumes. - In the scenario involving multiple controllers, this data must be - passed as argument rather than by table value', + controller => 'The management address to attach/detach new volumes. +In the scenario involving multiple controllers, this data must be +passed as argument rather than by table value', osvolume => "Specification of what storage to place the node OS image onto. Examples include: + localdisk (Install to first non-FC attached disk) usbdisk (Install to first USB mass storage device seen) wwn=0x50000393c813840c (Install to storage device with given WWN)", @@ -396,10 +398,7 @@ use xCAT::ExtTab; descriptions => { node => 'The node name or group name.', bmc => 'The hostname of the BMC adapater.', - bmcport => ' In systems with selectable shared/dedicated ethernet ports, - this parameter can be used to specify the preferred port. 0 - means use the shared port, 1 means dedicated, blank is to not - assign. + bmcport => 'In systems with selectable shared/dedicated ethernet ports, this parameter can be used to specify the preferred port. 0 means use the shared port, 1 means dedicated, blank is to not assign. The following special cases exist for IBM System x servers: @@ -527,6 +526,7 @@ use xCAT::ExtTab; password => 'Password to use to access the management module. If not specified, the key=blade row in the passwd table is used as the default.', displayname => 'Alternative name for BladeCenter chassis. Only used by PCM.', slots => 'The number of available slots in the chassis. For PCM, this attribute is used to store the number of slots in the following format: ,, Where: + = number of rows of slots in chassis = number of columns of slots in chassis = set to 0 if slots are vertical, and set to 1 if slots of horizontal @@ -647,12 +647,13 @@ use xCAT::ExtTab; node => 'The node name or group name.', servicenode => 'A comma separated list of node names (as known by the management node) that provides most services for this node. The first service node on the list that is accessible will be used. The 2nd node on the list is generally considered to be the backup service node for this node when running commands like snmove.', netboot => 'The type of network booting to use for this node. Valid values: - Arch OS valid netboot options - x86, x86_64 ALL pxe, xnba - ppc64 <=rhel6, <=sles11.3 yaboot - ppc64 >=rhels7, >=sles11.4 grub2,grub2-http,grub2-tftp - ppc64le NonVirtualize ALL petitboot - ppc64le PowerKVM Guest ALL grub2,grub2-http,grub2-tftp + + Arch OS valid netboot options + x86, x86_64 ALL pxe, xnba + ppc64 <=rhel6, <=sles11.3 yaboot + ppc64 >=rhels7, >=sles11.4 grub2,grub2-http,grub2-tftp + ppc64le NonVirtualize ALL petitboot + ppc64le PowerKVM Guest ALL grub2,grub2-http,grub2-tftp ', tftpserver => 'The TFTP server for this node (as known by this node). If not set, it defaults to networks.tftpserver.', @@ -1341,7 +1342,7 @@ use xCAT::ExtTab; id => 'The location or the resource name where the event occurred.', #In RMC it's the resource name and attribute name severity => 'The severity of the event. Valid values are: informational, warning, critical.', message => 'The full description of the event.', - rawdata => ' The data that associated with the event. ', # in RMC, it's the attribute value, it takes the format of attname=attvalue[,atrrname=attvalue....] + rawdata => 'The data that associated with the event. ', # in RMC, it's the attribute value, it takes the format of attname=attvalue[,atrrname=attvalue....] comments => 'Any user-provided notes.', disable => "Do not use. tabprune will not work if set to yes or 1", }, @@ -1355,7 +1356,7 @@ use xCAT::ExtTab; }, compress => 'YES', tablespace => 'XCATTBS32K', - table_desc => ' Audit Data log.', + table_desc => 'Audit Data log.', descriptions => { recid => 'The record id.', audittime => 'The timestamp for the audit entry.', @@ -1382,10 +1383,10 @@ use xCAT::ExtTab; # Do not put description text past column 88, so it displays well in a 100 char wide window. # ----------------------------------------------------------------------------------| begin => -"The scripts to be run at the beginning of the nodeset(Linux),\n" . +"The scripts to be run at the beginning of the nodeset(Linux)," . " nimnodeset(AIX) or mkdsklsnode(AIX) command.\n" . " The format is:\n" . -" [action1:]s1,s2...[|action2:s3,s4,s5...]\n" . +" [action1:]s1,s2...[| action2:s3,s4,s5...]\n" . " where:\n" . " - action1 and action2 for Linux are the nodeset actions specified in the command. \n" . " For AIX, action1 and action1 can be 'diskless' for mkdsklsnode command'\n" . @@ -1396,17 +1397,17 @@ use xCAT::ExtTab; " Examples:\n" . " myscript1,myscript2 (all actions)\n" . " diskless:myscript1,myscript2 (AIX)\n" . -" install:myscript1,myscript2|netboot:myscript3 (Linux)\n\n" . +" install:myscript1,myscript2|netboot:myscript3 (Linux)\n" . " All the scripts should be copied to /install/prescripts directory.\n" . " The following two environment variables will be passed to each script: \n" . " NODES a coma separated list of node names that need to run the script for\n" . -" ACTION current nodeset action.\n\n" . +" ACTION current nodeset action.\n" . " If '#xCAT setting:MAX_INSTANCE=number' is specified in the script, the script\n" . " will get invoked for each node in parallel, but no more than number of instances\n" . " will be invoked at at a time. If it is not specified, the script will be invoked\n" . " once for all the nodes.\n", - end => "The scripts to be run at the end of the nodeset(Linux),\n" . - " nimnodeset(AIX),or mkdsklsnode(AIX) command. \n" . + end => "The scripts to be run at the end of the nodeset(Linux)," . + " nimnodeset(AIX),or mkdsklsnode(AIX) command." . " The format is the same as the 'begin' column.", comments => 'Any user-written notes.', disable => "Set to 'yes' or '1' to comment out this row.", @@ -1463,7 +1464,8 @@ use xCAT::ExtTab; table_desc => 'Stores NIC details.', descriptions => { node => 'The node or group name.', - nicips => 'Comma-separated list of IP addresses per NIC. To specify one ip address per NIC: + nicips => 'Comma-separated list of IP addresses per NIC. + To specify one ip address per NIC: !,!,..., for example, eth0!10.0.0.100,ib0!11.0.0.100 To specify multiple ip addresses per NIC: !|,!|,..., for example, eth0!10.0.0.100|fd55::214:5eff:fe15:849b,ib0!11.0.0.100|2001::214:5eff:fe15:849a. The xCAT object definition commands support to use nicips. as the sub attributes. @@ -1491,16 +1493,16 @@ use xCAT::ExtTab; If multiple ip addresses are associated with each NIC: !|,!|, for example, eth0!10_0_0_0-255_255_0_0|fd55:faaf:e1ab:336::/64,ib0!11_0_0_0-255_255_0_0|2001:db8:1:0::/64. The xCAT object definition commands support to use nicnetworks. as the sub attributes.', nicaliases => 'Comma-separated list of hostname aliases for each NIC. - Format: eth0!,eth1!| - For multiple aliases per nic use a space-separated list. - For example: eth0!moe larry curly,eth1!tom|jerry', + Format: eth0!,eth1!| + For multiple aliases per nic use a space-separated list. + For example: eth0!moe larry curly,eth1!tom|jerry', nicextraparams => 'Comma-separated list of extra parameters that will be used for each NIC configuration. If only one ip address is associated with each NIC: !,!, for example, eth0!MTU=1500,ib0!MTU=65520 CONNECTED_MODE=yes. If multiple ip addresses are associated with each NIC: !|,!|, for example, eth0!MTU=1500|MTU=1460,ib0!MTU=65520 CONNECTED_MODE=yes. The xCAT object definition commands support to use nicextraparams. as the sub attributes.', - nicdevices => 'Comma-separated list of NIC device per NIC, multiple ethernet devices can be bonded as bond device, these ethernet devices are separated by |. !|,!, e.g. bond0!eth0|eth2,br0!bond0. The xCAT object definition commands support to use nicdevices. as the sub attributes.', + nicdevices => 'Comma-separated list of NIC device per NIC, multiple ethernet devices can be bonded as bond device, these ethernet devices are separated by | . !|,!, e.g. bond0!eth0|eth2,br0!bond0. The xCAT object definition commands support to use nicdevices. as the sub attributes.', nicsadapter => 'Comma-separated list of extra parameters that will be used for each NIC configuration. !|,!|, for example, eth0!MTU=1500|MTU=1460,ib0!MTU=65520 CONNECTED_MODE=yes.', comments => 'Any user-written notes.', From f49345368ec726003e84364453a2450ba6d1f9f1 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Fri, 27 May 2016 11:55:59 -0400 Subject: [PATCH 036/310] Checkin generated man5 and man7 generated .rst files --- .../references/man5/auditlog.5.rst | 6 +- .../references/man5/eventlog.5.rst | 6 +- .../admin-guides/references/man5/ipmi.5.rst | 7 +- .../admin-guides/references/man5/mpa.5.rst | 11 +- .../admin-guides/references/man5/nics.5.rst | 11 +- .../references/man5/noderes.5.rst | 17 +- .../references/man5/prescripts.5.rst | 31 +- .../references/man5/storage.5.rst | 17 +- .../admin-guides/references/man5/vm.5.rst | 3 +- .../admin-guides/references/man5/xcatdb.5.rst | 6 +- .../references/man7/eventlog.7.rst | 6 +- .../admin-guides/references/man7/group.7.rst | 342 ++++-------------- .../admin-guides/references/man7/node.7.rst | 342 ++++-------------- .../references/man7/osimage.7.rst | 10 +- 14 files changed, 212 insertions(+), 603 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man5/auditlog.5.rst b/docs/source/guides/admin-guides/references/man5/auditlog.5.rst index 142d68d3a..d177660f8 100644 --- a/docs/source/guides/admin-guides/references/man5/auditlog.5.rst +++ b/docs/source/guides/admin-guides/references/man5/auditlog.5.rst @@ -27,11 +27,7 @@ DESCRIPTION *********** - -.. code-block:: perl - - Audit Data log. - +Audit Data log. ******************** diff --git a/docs/source/guides/admin-guides/references/man5/eventlog.5.rst b/docs/source/guides/admin-guides/references/man5/eventlog.5.rst index 8387bb43c..f75afb9de 100644 --- a/docs/source/guides/admin-guides/references/man5/eventlog.5.rst +++ b/docs/source/guides/admin-guides/references/man5/eventlog.5.rst @@ -104,11 +104,7 @@ eventlog Attributes: \ **rawdata**\ - - .. code-block:: perl - - The data that associated with the event. - + The data that associated with the event. diff --git a/docs/source/guides/admin-guides/references/man5/ipmi.5.rst b/docs/source/guides/admin-guides/references/man5/ipmi.5.rst index 5122a442c..84b8cfde1 100644 --- a/docs/source/guides/admin-guides/references/man5/ipmi.5.rst +++ b/docs/source/guides/admin-guides/references/man5/ipmi.5.rst @@ -50,14 +50,11 @@ ipmi Attributes: \ **bmcport**\ + In systems with selectable shared/dedicated ethernet ports, this parameter can be used to specify the preferred port. 0 means use the shared port, 1 means dedicated, blank is to not assign. + .. code-block:: perl - In systems with selectable shared/dedicated ethernet ports, - this parameter can be used to specify the preferred port. 0 - means use the shared port, 1 means dedicated, blank is to not - assign. - The following special cases exist for IBM System x servers: For x3755 M3 systems, 0 means use the dedicated port, 1 means diff --git a/docs/source/guides/admin-guides/references/man5/mpa.5.rst b/docs/source/guides/admin-guides/references/man5/mpa.5.rst index e44e0f87d..4b03e9d12 100644 --- a/docs/source/guides/admin-guides/references/man5/mpa.5.rst +++ b/docs/source/guides/admin-guides/references/man5/mpa.5.rst @@ -63,9 +63,14 @@ mpa Attributes: \ **slots**\ The number of available slots in the chassis. For PCM, this attribute is used to store the number of slots in the following format: ,, Where: - = number of rows of slots in chassis - = number of columns of slots in chassis - = set to 0 if slots are vertical, and set to 1 if slots of horizontal + + + .. code-block:: perl + + = number of rows of slots in chassis + = number of columns of slots in chassis + = set to 0 if slots are vertical, and set to 1 if slots of horizontal + diff --git a/docs/source/guides/admin-guides/references/man5/nics.5.rst b/docs/source/guides/admin-guides/references/man5/nics.5.rst index 4855c0a56..6b3e28c29 100644 --- a/docs/source/guides/admin-guides/references/man5/nics.5.rst +++ b/docs/source/guides/admin-guides/references/man5/nics.5.rst @@ -44,7 +44,8 @@ nics Attributes: \ **nicips**\ - Comma-separated list of IP addresses per NIC. To specify one ip address per NIC: + Comma-separated list of IP addresses per NIC. + To specify one ip address per NIC: !,!,..., for example, eth0!10.0.0.100,ib0!11.0.0.100 To specify multiple ip addresses per NIC: !|,!|,..., for example, eth0!10.0.0.100|fd55::214:5eff:fe15:849b,ib0!11.0.0.100|2001::214:5eff:fe15:849a. The xCAT object definition commands support to use nicips. as the sub attributes. @@ -102,9 +103,9 @@ nics Attributes: \ **nicaliases**\ Comma-separated list of hostname aliases for each NIC. - Format: eth0!,eth1!| - For multiple aliases per nic use a space-separated list. - For example: eth0!moe larry curly,eth1!tom|jerry + Format: eth0!,eth1!| + For multiple aliases per nic use a space-separated list. + For example: eth0!moe larry curly,eth1!tom|jerry @@ -121,7 +122,7 @@ nics Attributes: \ **nicdevices**\ - Comma-separated list of NIC device per NIC, multiple ethernet devices can be bonded as bond device, these ethernet devices are separated by |. !|,!, e.g. bond0!eth0|eth2,br0!bond0. The xCAT object definition commands support to use nicdevices. as the sub attributes. + Comma-separated list of NIC device per NIC, multiple ethernet devices can be bonded as bond device, these ethernet devices are separated by | . !|,!, e.g. bond0!eth0|eth2,br0!bond0. The xCAT object definition commands support to use nicdevices. as the sub attributes. diff --git a/docs/source/guides/admin-guides/references/man5/noderes.5.rst b/docs/source/guides/admin-guides/references/man5/noderes.5.rst index 36c9fb575..8d2bae399 100644 --- a/docs/source/guides/admin-guides/references/man5/noderes.5.rst +++ b/docs/source/guides/admin-guides/references/man5/noderes.5.rst @@ -51,12 +51,17 @@ noderes Attributes: \ **netboot**\ The type of network booting to use for this node. Valid values: - Arch OS valid netboot options - x86, x86_64 ALL pxe, xnba - ppc64 <=rhel6, <=sles11.3 yaboot - ppc64 >=rhels7, >=sles11.4 grub2,grub2-http,grub2-tftp - ppc64le NonVirtualize ALL petitboot - ppc64le PowerKVM Guest ALL grub2,grub2-http,grub2-tftp + + + .. code-block:: perl + + Arch OS valid netboot options + x86, x86_64 ALL pxe, xnba + ppc64 <=rhel6, <=sles11.3 yaboot + ppc64 >=rhels7, >=sles11.4 grub2,grub2-http,grub2-tftp + ppc64le NonVirtualize ALL petitboot + ppc64le PowerKVM Guest ALL grub2,grub2-http,grub2-tftp + diff --git a/docs/source/guides/admin-guides/references/man5/prescripts.5.rst b/docs/source/guides/admin-guides/references/man5/prescripts.5.rst index 6b8b0ebc6..13f42e25c 100644 --- a/docs/source/guides/admin-guides/references/man5/prescripts.5.rst +++ b/docs/source/guides/admin-guides/references/man5/prescripts.5.rst @@ -44,10 +44,9 @@ prescripts Attributes: \ **begin**\ - The scripts to be run at the beginning of the nodeset(Linux), - nimnodeset(AIX) or mkdsklsnode(AIX) command. + The scripts to be run at the beginning of the nodeset(Linux), nimnodeset(AIX) or mkdsklsnode(AIX) command. The format is: - [action1:]s1,s2...[|action2:s3,s4,s5...] + [action1:]s1,s2...[| action2:s3,s4,s5...] where: - action1 and action2 for Linux are the nodeset actions specified in the command. For AIX, action1 and action1 can be 'diskless' for mkdsklsnode command' @@ -59,28 +58,20 @@ prescripts Attributes: myscript1,myscript2 (all actions) diskless:myscript1,myscript2 (AIX) install:myscript1,myscript2|netboot:myscript3 (Linux) - - - .. code-block:: perl - - All the scripts should be copied to /install/prescripts directory. - The following two environment variables will be passed to each script: - NODES a coma separated list of node names that need to run the script for - ACTION current nodeset action. - - If '#xCAT setting:MAX_INSTANCE=number' is specified in the script, the script - will get invoked for each node in parallel, but no more than number of instances - will be invoked at at a time. If it is not specified, the script will be invoked - once for all the nodes. - + All the scripts should be copied to /install/prescripts directory. + The following two environment variables will be passed to each script: + NODES a coma separated list of node names that need to run the script for + ACTION current nodeset action. + If '#xCAT setting:MAX_INSTANCE=number' is specified in the script, the script + will get invoked for each node in parallel, but no more than number of instances + will be invoked at at a time. If it is not specified, the script will be invoked + once for all the nodes. \ **end**\ - The scripts to be run at the end of the nodeset(Linux), - nimnodeset(AIX),or mkdsklsnode(AIX) command. - The format is the same as the 'begin' column. + The scripts to be run at the end of the nodeset(Linux), nimnodeset(AIX),or mkdsklsnode(AIX) command. The format is the same as the 'begin' column. diff --git a/docs/source/guides/admin-guides/references/man5/storage.5.rst b/docs/source/guides/admin-guides/references/man5/storage.5.rst index a2183e3ef..5182c1c82 100644 --- a/docs/source/guides/admin-guides/references/man5/storage.5.rst +++ b/docs/source/guides/admin-guides/references/man5/storage.5.rst @@ -43,9 +43,14 @@ storage Attributes: \ **osvolume**\ Specification of what storage to place the node OS image onto. Examples include: - localdisk (Install to first non-FC attached disk) - usbdisk (Install to first USB mass storage device seen) - wwn=0x50000393c813840c (Install to storage device with given WWN) + + + .. code-block:: perl + + localdisk (Install to first non-FC attached disk) + usbdisk (Install to first USB mass storage device seen) + wwn=0x50000393c813840c (Install to storage device with given WWN) + @@ -93,9 +98,9 @@ storage Attributes: \ **controller**\ - The management address to attach/detach new volumes. - In the scenario involving multiple controllers, this data must be - passed as argument rather than by table value + The management address to attach/detach new volumes. + In the scenario involving multiple controllers, this data must be + passed as argument rather than by table value diff --git a/docs/source/guides/admin-guides/references/man5/vm.5.rst b/docs/source/guides/admin-guides/references/man5/vm.5.rst index ece3064cc..1b079118b 100644 --- a/docs/source/guides/admin-guides/references/man5/vm.5.rst +++ b/docs/source/guides/admin-guides/references/man5/vm.5.rst @@ -128,7 +128,8 @@ vm Attributes: \ **virtflags**\ - General flags used by the virtualization method. For example, in Xen it could, among other things, specify paravirtualized setup, or direct kernel boot. For a hypervisor/dom0 entry, it is the virtualization method (i.e. "xen"). For KVM, the following flag=value pairs are recognized: + General flags used by the virtualization method. + For example, in Xen it could, among other things, specify paravirtualized setup, or direct kernel boot. For a hypervisor/dom0 entry, it is the virtualization method (i.e. "xen"). For KVM, the following flag=value pairs are recognized: imageformat=[raw|fullraw|qcow2] raw is a generic sparse file that allocates storage on demand fullraw is a generic, non-sparse file that preallocates all space diff --git a/docs/source/guides/admin-guides/references/man5/xcatdb.5.rst b/docs/source/guides/admin-guides/references/man5/xcatdb.5.rst index 86806e6ae..e92b439c9 100644 --- a/docs/source/guides/admin-guides/references/man5/xcatdb.5.rst +++ b/docs/source/guides/admin-guides/references/man5/xcatdb.5.rst @@ -329,11 +329,7 @@ The tables are: auditlog(5)|auditlog.5 - - .. code-block:: perl - - Audit Data log. - + Audit Data log. diff --git a/docs/source/guides/admin-guides/references/man7/eventlog.7.rst b/docs/source/guides/admin-guides/references/man7/eventlog.7.rst index 7837a6c39..ff31cbe01 100644 --- a/docs/source/guides/admin-guides/references/man7/eventlog.7.rst +++ b/docs/source/guides/admin-guides/references/man7/eventlog.7.rst @@ -107,11 +107,7 @@ eventlog Attributes: \ **rawdata**\ (eventlog.rawdata) - - .. code-block:: perl - - The data that associated with the event. - + The data that associated with the event. diff --git a/docs/source/guides/admin-guides/references/man7/group.7.rst b/docs/source/guides/admin-guides/references/man7/group.7.rst index 0e76c6a07..f3971c159 100644 --- a/docs/source/guides/admin-guides/references/man7/group.7.rst +++ b/docs/source/guides/admin-guides/references/man7/group.7.rst @@ -71,87 +71,45 @@ group Attributes: \ **bmcport**\ (ipmi.bmcport) + In systems with selectable shared/dedicated ethernet ports, this parameter can be used to specify the preferred port. 0 means use the shared port, 1 means dedicated, blank is to not assign. + .. code-block:: perl - In systems with selectable shared/dedicated ethernet ports, - - this parameter can be used to specify the preferred port. 0 - - means use the shared port, 1 means dedicated, blank is to not - - assign. - - - The following special cases exist for IBM System x servers: - - For x3755 M3 systems, 0 means use the dedicated port, 1 means - shared, blank is to not assign. - - For certain systems which have a mezzaine or ML2 adapter, there is a second - value to include: - - - For x3750 M4 (Model 8722): - - - 0 2 1st 1Gbps interface for LOM - - 0 0 1st 10Gbps interface for LOM - - 0 3 2nd 1Gbps interface for LOM - - 0 1 2nd 10Gbps interface for LOM - - - For x3750 M4 (Model 8752), x3850/3950 X6, dx360 M4, x3550 M4, and x3650 M4: - - - 0 Shared (1st onboard interface) - - 1 Dedicated - - 2 0 First interface on ML2 or mezzanine adapter - - 2 1 Second interface on ML2 or mezzanine adapter - - 2 2 Third interface on ML2 or mezzanine adapter - - 2 3 Fourth interface on ML2 or mezzanine adapter @@ -328,9 +286,7 @@ group Attributes: \ **hcp**\ (ppc.hcp, zvm.hcp) The hardware control point for this node (HMC, IVM, Frame or CEC). Do not need to set for BPAs and FSPs. - or - The hardware control point for this node. @@ -374,17 +330,11 @@ group Attributes: \ **hwtype**\ (ppc.nodetype, zvm.nodetype, mp.nodetype, mic.nodetype) The hardware type of the node. Only can be one of fsp, bpa, cec, frame, ivm, hmc and lpar - or - The node type. Valid values: cec (Central Electronic Complex), lpar (logical partition), zvm (z/VM host operating system), and vm (virtual machine). - or - The hardware type for mp node. Valid values: mm,cmm, blade. - or - The hardware type of the mic node. Generally, it is mic. @@ -392,9 +342,7 @@ group Attributes: \ **id**\ (ppc.id, mp.id) For LPARs: the LPAR numeric id; for CECs: the cage number; for Frames: the frame number. - or - The slot number of this blade in the BladeCenter chassis. @@ -568,17 +516,12 @@ group Attributes: .. code-block:: perl - Arch OS valid netboot options - - x86, x86_64 ALL pxe, xnba - - ppc64 <=rhel6, <=sles11.3 yaboot - - ppc64 >=rhels7, >=sles11.4 grub2,grub2-http,grub2-tftp - - ppc64le NonVirtualize ALL petitboot - - ppc64le PowerKVM Guest ALL grub2,grub2-http,grub2-tftp + Arch OS valid netboot options + x86, x86_64 ALL pxe, xnba + ppc64 <=rhel6, <=sles11.3 yaboot + ppc64 >=rhels7, >=sles11.4 grub2,grub2-http,grub2-tftp + ppc64le NonVirtualize ALL petitboot + ppc64le PowerKVM Guest ALL grub2,grub2-http,grub2-tftp @@ -598,142 +541,85 @@ group Attributes: \ **nicaliases**\ (nics.nicaliases) Comma-separated list of hostname aliases for each NIC. - - - .. code-block:: perl - - Format: eth0!,eth1!| - - For multiple aliases per nic use a space-separated list. - - For example: eth0!moe larry curly,eth1!tom|jerry - + Format: eth0!,eth1!| + For multiple aliases per nic use a space-separated list. + For example: eth0!moe larry curly,eth1!tom|jerry \ **niccustomscripts**\ (nics.niccustomscripts) Comma-separated list of custom scripts per NIC. !,!, e.g. eth0!configeth eth0, ib0!configib ib0. The xCAT object definition commands support to use niccustomscripts. as the sub attribute - . \ **nicdevices**\ (nics.nicdevices) - Comma-separated list of NIC device per NIC, multiple ethernet devices can be bonded as bond device, these ethernet devices are separated by |. !|,!, e.g. bond0!eth0|eth2,br0!bond0. The xCAT object definition commands support to use nicdevices. as the sub attributes. + Comma-separated list of NIC device per NIC, multiple ethernet devices can be bonded as bond device, these ethernet devices are separated by | . !|,!, e.g. bond0!eth0|eth2,br0!bond0. The xCAT object definition commands support to use nicdevices. as the sub attributes. \ **nicextraparams**\ (nics.nicextraparams) Comma-separated list of extra parameters that will be used for each NIC configuration. - - - .. code-block:: perl - - If only one ip address is associated with each NIC: - - !,!, for example, eth0!MTU=1500,ib0!MTU=65520 CONNECTED_MODE=yes. - - If multiple ip addresses are associated with each NIC: - - !|,!|, for example, eth0!MTU=1500|MTU=1460,ib0!MTU=65520 CONNECTED_MODE=yes. - - The xCAT object definition commands support to use nicextraparams. as the sub attributes. - + If only one ip address is associated with each NIC: + !,!, for example, eth0!MTU=1500,ib0!MTU=65520 CONNECTED_MODE=yes. + If multiple ip addresses are associated with each NIC: + !|,!|, for example, eth0!MTU=1500|MTU=1460,ib0!MTU=65520 CONNECTED_MODE=yes. + The xCAT object definition commands support to use nicextraparams. as the sub attributes. \ **nichostnameprefixes**\ (nics.nichostnameprefixes) - Comma-separated list of hostname prefixes per NIC. - - - .. code-block:: perl - - If only one ip address is associated with each NIC: - - !,!,..., for example, eth0!eth0-,ib0!ib- - - If multiple ip addresses are associcated with each NIC: - - !|,!|,..., for example, eth0!eth0-|eth0-ipv6i-,ib0!ib-|ib-ipv6-. - - The xCAT object definition commands support to use nichostnameprefixes. as the sub attributes. - - Note: According to DNS rules a hostname must be a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-),and period (.). When you are specifying "nichostnameprefixes" or "nicaliases" make sure the resulting hostnames will conform to this naming convention - + Comma-separated list of hostname prefixes per NIC. + If only one ip address is associated with each NIC: + !,!,..., for example, eth0!eth0-,ib0!ib- + If multiple ip addresses are associcated with each NIC: + !|,!|,..., for example, eth0!eth0-|eth0-ipv6i-,ib0!ib-|ib-ipv6-. + The xCAT object definition commands support to use nichostnameprefixes. as the sub attributes. + Note: According to DNS rules a hostname must be a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-),and period (.). When you are specifying "nichostnameprefixes" or "nicaliases" make sure the resulting hostnames will conform to this naming convention \ **nichostnamesuffixes**\ (nics.nichostnamesuffixes) - Comma-separated list of hostname suffixes per NIC. - - - .. code-block:: perl - - If only one ip address is associated with each NIC: - - !,!,..., for example, eth0!-eth0,ib0!-ib0 - - If multiple ip addresses are associcated with each NIC: - - !|,!|,..., for example, eth0!-eth0|-eth0-ipv6,ib0!-ib0|-ib0-ipv6. - - The xCAT object definition commands support to use nichostnamesuffixes. as the sub attributes. - - Note: According to DNS rules a hostname must be a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-),and period (.). When you are specifying "nichostnamesuffixes" or "nicaliases" make sure the resulting hostnames will conform to this naming convention - + Comma-separated list of hostname suffixes per NIC. + If only one ip address is associated with each NIC: + !,!,..., for example, eth0!-eth0,ib0!-ib0 + If multiple ip addresses are associcated with each NIC: + !|,!|,..., for example, eth0!-eth0|-eth0-ipv6,ib0!-ib0|-ib0-ipv6. + The xCAT object definition commands support to use nichostnamesuffixes. as the sub attributes. + Note: According to DNS rules a hostname must be a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-),and period (.). When you are specifying "nichostnamesuffixes" or "nicaliases" make sure the resulting hostnames will conform to this naming convention \ **nicips**\ (nics.nicips) - Comma-separated list of IP addresses per NIC. To specify one ip address per NIC: - - - .. code-block:: perl - - !,!,..., for example, eth0!10.0.0.100,ib0!11.0.0.100 - - To specify multiple ip addresses per NIC: - - !|,!|,..., for example, eth0!10.0.0.100|fd55::214:5eff:fe15:849b,ib0!11.0.0.100|2001::214:5eff:fe15:849a. The xCAT object definition commands support to use nicips. as the sub attributes. - - Note: The primary IP address must also be stored in the hosts.ip attribute. The nichostnamesuffixes should specify one hostname suffix for each ip address. - + Comma-separated list of IP addresses per NIC. + To specify one ip address per NIC: + !,!,..., for example, eth0!10.0.0.100,ib0!11.0.0.100 + To specify multiple ip addresses per NIC: + !|,!|,..., for example, eth0!10.0.0.100|fd55::214:5eff:fe15:849b,ib0!11.0.0.100|2001::214:5eff:fe15:849a. The xCAT object definition commands support to use nicips. as the sub attributes. + Note: The primary IP address must also be stored in the hosts.ip attribute. The nichostnamesuffixes should specify one hostname suffix for each ip address. \ **nicnetworks**\ (nics.nicnetworks) Comma-separated list of networks connected to each NIC. - - - .. code-block:: perl - - If only one ip address is associated with each NIC: - - !,!, for example, eth0!10_0_0_0-255_255_0_0, ib0!11_0_0_0-255_255_0_0 - - If multiple ip addresses are associated with each NIC: - - !|,!|, for example, eth0!10_0_0_0-255_255_0_0|fd55:faaf:e1ab:336::/64,ib0!11_0_0_0-255_255_0_0|2001:db8:1:0::/64. The xCAT object definition commands support to use nicnetworks. as the sub attributes. - + If only one ip address is associated with each NIC: + !,!, for example, eth0!10_0_0_0-255_255_0_0, ib0!11_0_0_0-255_255_0_0 + If multiple ip addresses are associated with each NIC: + !|,!|, for example, eth0!10_0_0_0-255_255_0_0|fd55:faaf:e1ab:336::/64,ib0!11_0_0_0-255_255_0_0|2001:db8:1:0::/64. The xCAT object definition commands support to use nicnetworks. as the sub attributes. \ **nicsadapter**\ (nics.nicsadapter) Comma-separated list of extra parameters that will be used for each NIC configuration. - - - .. code-block:: perl - - !|,!|, for example, eth0!MTU=1500|MTU=1460,ib0!MTU=65520 CONNECTED_MODE=yes. - + !|,!|, for example, eth0!MTU=1500|MTU=1460,ib0!MTU=65520 CONNECTED_MODE=yes. @@ -775,9 +661,7 @@ group Attributes: .. code-block:: perl localdisk (Install to first non-FC attached disk) - usbdisk (Install to first USB mass storage device seen) - wwn=0x50000393c813840c (Install to storage device with given WWN) @@ -834,17 +718,11 @@ group Attributes: \ **password**\ (ppchcp.password, mpa.password, websrv.password, switches.sshpassword) Password of the HMC or IVM. If not filled in, xCAT will look in the passwd table for key=hmc or key=ivm. If not in the passwd table, the default used is abc123 for HMCs and padmin for IVMs. - or - Password to use to access the management module. If not specified, the key=blade row in the passwd table is used as the default. - or - Password to use to access the web service. - or - The remote login password. It can be for ssh or telnet. If it is for telnet, please set protocol to "telnet". If the sshusername is blank, the username, password and protocol will be retrieved from the passwd table with "switch" as the key. @@ -875,73 +753,34 @@ group Attributes: \ **prescripts-begin**\ (prescripts.begin) - The scripts to be run at the beginning of the nodeset(Linux), - - - .. code-block:: perl - - nimnodeset(AIX) or mkdsklsnode(AIX) command. - - The format is: - - [action1:]s1,s2...[|action2:s3,s4,s5...] - - where: - - - action1 and action2 for Linux are the nodeset actions specified in the command. - - For AIX, action1 and action1 can be 'diskless' for mkdsklsnode command' - - and 'standalone for nimnodeset command. - - - s1 and s2 are the scripts to run for action1 in order. - - - s3, s4, and s5 are the scripts to run for actions2. - - If actions are omitted, the scripts apply to all actions. - - Examples: - - myscript1,myscript2 (all actions) - - diskless:myscript1,myscript2 (AIX) - - install:myscript1,myscript2|netboot:myscript3 (Linux) - - - - All the scripts should be copied to /install/prescripts directory. - - The following two environment variables will be passed to each script: - - NODES a coma separated list of node names that need to run the script for - - ACTION current nodeset action. - - - - If '#xCAT setting:MAX_INSTANCE=number' is specified in the script, the script - - will get invoked for each node in parallel, but no more than number of instances - - will be invoked at at a time. If it is not specified, the script will be invoked - - once for all the nodes. - + The scripts to be run at the beginning of the nodeset(Linux), nimnodeset(AIX) or mkdsklsnode(AIX) command. + The format is: + [action1:]s1,s2...[| action2:s3,s4,s5...] + where: + - action1 and action2 for Linux are the nodeset actions specified in the command. + For AIX, action1 and action1 can be 'diskless' for mkdsklsnode command' + and 'standalone for nimnodeset command. + - s1 and s2 are the scripts to run for action1 in order. + - s3, s4, and s5 are the scripts to run for actions2. + If actions are omitted, the scripts apply to all actions. + Examples: + myscript1,myscript2 (all actions) + diskless:myscript1,myscript2 (AIX) + install:myscript1,myscript2|netboot:myscript3 (Linux) + All the scripts should be copied to /install/prescripts directory. + The following two environment variables will be passed to each script: + NODES a coma separated list of node names that need to run the script for + ACTION current nodeset action. + If '#xCAT setting:MAX_INSTANCE=number' is specified in the script, the script + will get invoked for each node in parallel, but no more than number of instances + will be invoked at at a time. If it is not specified, the script will be invoked + once for all the nodes. \ **prescripts-end**\ (prescripts.end) - The scripts to be run at the end of the nodeset(Linux), - - - .. code-block:: perl - - nimnodeset(AIX),or mkdsklsnode(AIX) command. - - The format is the same as the 'begin' column. - + The scripts to be run at the end of the nodeset(Linux), nimnodeset(AIX),or mkdsklsnode(AIX) command. The format is the same as the 'begin' column. @@ -1121,9 +960,7 @@ group Attributes: .. code-block:: perl = number of rows of slots in chassis - = number of columns of slots in chassis - = set to 0 if slots are vertical, and set to 1 if slots of horizontal @@ -1161,15 +998,9 @@ group Attributes: \ **storagcontroller**\ (storage.controller) - The management address to attach/detach new volumes. - - - .. code-block:: perl - - In the scenario involving multiple controllers, this data must be - - passed as argument rather than by table value - + The management address to attach/detach new volumes. + In the scenario involving multiple controllers, this data must be + passed as argument rather than by table value @@ -1284,17 +1115,11 @@ group Attributes: \ **username**\ (ppchcp.username, mpa.username, websrv.username, switches.sshusername) Userid of the HMC or IVM. If not filled in, xCAT will look in the passwd table for key=hmc or key=ivm. If not in the passwd table, the default used is hscroot for HMCs and padmin for IVMs. - or - Userid to use to access the management module. - or - Userid to use to access the web service. - or - The remote login user name. It can be for ssh or telnet. If it is for telnet, please set protocol to "telnet". If the sshusername is blank, the username, password and protocol will be retrieved from the passwd table with "switch" as the key. @@ -1409,27 +1234,16 @@ group Attributes: \ **vmvirtflags**\ (vm.virtflags) - General flags used by the virtualization method. For example, in Xen it could, among other things, specify paravirtualized setup, or direct kernel boot. For a hypervisor/dom0 entry, it is the virtualization method (i.e. "xen"). For KVM, the following flag=value pairs are recognized: - - - .. code-block:: perl - - imageformat=[raw|fullraw|qcow2] - - raw is a generic sparse file that allocates storage on demand - - fullraw is a generic, non-sparse file that preallocates all space - - qcow2 is a sparse, copy-on-write capable format implemented at the virtualization layer rather than the filesystem level - - clonemethod=[qemu-img|reflink] - - qemu-img allows use of qcow2 to generate virtualization layer copy-on-write - - reflink uses a generic filesystem facility to clone the files on your behalf, but requires filesystem support such as btrfs - - placement_affinity=[migratable|user_migratable|pinned] - + General flags used by the virtualization method. + For example, in Xen it could, among other things, specify paravirtualized setup, or direct kernel boot. For a hypervisor/dom0 entry, it is the virtualization method (i.e. "xen"). For KVM, the following flag=value pairs are recognized: + imageformat=[raw|fullraw|qcow2] + raw is a generic sparse file that allocates storage on demand + fullraw is a generic, non-sparse file that preallocates all space + qcow2 is a sparse, copy-on-write capable format implemented at the virtualization layer rather than the filesystem level + clonemethod=[qemu-img|reflink] + qemu-img allows use of qcow2 to generate virtualization layer copy-on-write + reflink uses a generic filesystem facility to clone the files on your behalf, but requires filesystem support such as btrfs + placement_affinity=[migratable|user_migratable|pinned] diff --git a/docs/source/guides/admin-guides/references/man7/node.7.rst b/docs/source/guides/admin-guides/references/man7/node.7.rst index 0d871ee82..c98520ff0 100644 --- a/docs/source/guides/admin-guides/references/man7/node.7.rst +++ b/docs/source/guides/admin-guides/references/man7/node.7.rst @@ -83,87 +83,45 @@ node Attributes: \ **bmcport**\ (ipmi.bmcport) + In systems with selectable shared/dedicated ethernet ports, this parameter can be used to specify the preferred port. 0 means use the shared port, 1 means dedicated, blank is to not assign. + .. code-block:: perl - In systems with selectable shared/dedicated ethernet ports, - - this parameter can be used to specify the preferred port. 0 - - means use the shared port, 1 means dedicated, blank is to not - - assign. - - - The following special cases exist for IBM System x servers: - - For x3755 M3 systems, 0 means use the dedicated port, 1 means - shared, blank is to not assign. - - For certain systems which have a mezzaine or ML2 adapter, there is a second - value to include: - - - For x3750 M4 (Model 8722): - - - 0 2 1st 1Gbps interface for LOM - - 0 0 1st 10Gbps interface for LOM - - 0 3 2nd 1Gbps interface for LOM - - 0 1 2nd 10Gbps interface for LOM - - - For x3750 M4 (Model 8752), x3850/3950 X6, dx360 M4, x3550 M4, and x3650 M4: - - - 0 Shared (1st onboard interface) - - 1 Dedicated - - 2 0 First interface on ML2 or mezzanine adapter - - 2 1 Second interface on ML2 or mezzanine adapter - - 2 2 Third interface on ML2 or mezzanine adapter - - 2 3 Fourth interface on ML2 or mezzanine adapter @@ -334,9 +292,7 @@ node Attributes: \ **hcp**\ (ppc.hcp, zvm.hcp) The hardware control point for this node (HMC, IVM, Frame or CEC). Do not need to set for BPAs and FSPs. - or - The hardware control point for this node. @@ -386,17 +342,11 @@ node Attributes: \ **hwtype**\ (ppc.nodetype, zvm.nodetype, mp.nodetype, mic.nodetype) The hardware type of the node. Only can be one of fsp, bpa, cec, frame, ivm, hmc and lpar - or - The node type. Valid values: cec (Central Electronic Complex), lpar (logical partition), zvm (z/VM host operating system), and vm (virtual machine). - or - The hardware type for mp node. Valid values: mm,cmm, blade. - or - The hardware type of the mic node. Generally, it is mic. @@ -404,9 +354,7 @@ node Attributes: \ **id**\ (ppc.id, mp.id) For LPARs: the LPAR numeric id; for CECs: the cage number; for Frames: the frame number. - or - The slot number of this blade in the BladeCenter chassis. @@ -568,17 +516,12 @@ node Attributes: .. code-block:: perl - Arch OS valid netboot options - - x86, x86_64 ALL pxe, xnba - - ppc64 <=rhel6, <=sles11.3 yaboot - - ppc64 >=rhels7, >=sles11.4 grub2,grub2-http,grub2-tftp - - ppc64le NonVirtualize ALL petitboot - - ppc64le PowerKVM Guest ALL grub2,grub2-http,grub2-tftp + Arch OS valid netboot options + x86, x86_64 ALL pxe, xnba + ppc64 <=rhel6, <=sles11.3 yaboot + ppc64 >=rhels7, >=sles11.4 grub2,grub2-http,grub2-tftp + ppc64le NonVirtualize ALL petitboot + ppc64le PowerKVM Guest ALL grub2,grub2-http,grub2-tftp @@ -598,142 +541,85 @@ node Attributes: \ **nicaliases**\ (nics.nicaliases) Comma-separated list of hostname aliases for each NIC. - - - .. code-block:: perl - - Format: eth0!,eth1!| - - For multiple aliases per nic use a space-separated list. - - For example: eth0!moe larry curly,eth1!tom|jerry - + Format: eth0!,eth1!| + For multiple aliases per nic use a space-separated list. + For example: eth0!moe larry curly,eth1!tom|jerry \ **niccustomscripts**\ (nics.niccustomscripts) Comma-separated list of custom scripts per NIC. !,!, e.g. eth0!configeth eth0, ib0!configib ib0. The xCAT object definition commands support to use niccustomscripts. as the sub attribute - . \ **nicdevices**\ (nics.nicdevices) - Comma-separated list of NIC device per NIC, multiple ethernet devices can be bonded as bond device, these ethernet devices are separated by |. !|,!, e.g. bond0!eth0|eth2,br0!bond0. The xCAT object definition commands support to use nicdevices. as the sub attributes. + Comma-separated list of NIC device per NIC, multiple ethernet devices can be bonded as bond device, these ethernet devices are separated by | . !|,!, e.g. bond0!eth0|eth2,br0!bond0. The xCAT object definition commands support to use nicdevices. as the sub attributes. \ **nicextraparams**\ (nics.nicextraparams) Comma-separated list of extra parameters that will be used for each NIC configuration. - - - .. code-block:: perl - - If only one ip address is associated with each NIC: - - !,!, for example, eth0!MTU=1500,ib0!MTU=65520 CONNECTED_MODE=yes. - - If multiple ip addresses are associated with each NIC: - - !|,!|, for example, eth0!MTU=1500|MTU=1460,ib0!MTU=65520 CONNECTED_MODE=yes. - - The xCAT object definition commands support to use nicextraparams. as the sub attributes. - + If only one ip address is associated with each NIC: + !,!, for example, eth0!MTU=1500,ib0!MTU=65520 CONNECTED_MODE=yes. + If multiple ip addresses are associated with each NIC: + !|,!|, for example, eth0!MTU=1500|MTU=1460,ib0!MTU=65520 CONNECTED_MODE=yes. + The xCAT object definition commands support to use nicextraparams. as the sub attributes. \ **nichostnameprefixes**\ (nics.nichostnameprefixes) - Comma-separated list of hostname prefixes per NIC. - - - .. code-block:: perl - - If only one ip address is associated with each NIC: - - !,!,..., for example, eth0!eth0-,ib0!ib- - - If multiple ip addresses are associcated with each NIC: - - !|,!|,..., for example, eth0!eth0-|eth0-ipv6i-,ib0!ib-|ib-ipv6-. - - The xCAT object definition commands support to use nichostnameprefixes. as the sub attributes. - - Note: According to DNS rules a hostname must be a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-),and period (.). When you are specifying "nichostnameprefixes" or "nicaliases" make sure the resulting hostnames will conform to this naming convention - + Comma-separated list of hostname prefixes per NIC. + If only one ip address is associated with each NIC: + !,!,..., for example, eth0!eth0-,ib0!ib- + If multiple ip addresses are associcated with each NIC: + !|,!|,..., for example, eth0!eth0-|eth0-ipv6i-,ib0!ib-|ib-ipv6-. + The xCAT object definition commands support to use nichostnameprefixes. as the sub attributes. + Note: According to DNS rules a hostname must be a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-),and period (.). When you are specifying "nichostnameprefixes" or "nicaliases" make sure the resulting hostnames will conform to this naming convention \ **nichostnamesuffixes**\ (nics.nichostnamesuffixes) - Comma-separated list of hostname suffixes per NIC. - - - .. code-block:: perl - - If only one ip address is associated with each NIC: - - !,!,..., for example, eth0!-eth0,ib0!-ib0 - - If multiple ip addresses are associcated with each NIC: - - !|,!|,..., for example, eth0!-eth0|-eth0-ipv6,ib0!-ib0|-ib0-ipv6. - - The xCAT object definition commands support to use nichostnamesuffixes. as the sub attributes. - - Note: According to DNS rules a hostname must be a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-),and period (.). When you are specifying "nichostnamesuffixes" or "nicaliases" make sure the resulting hostnames will conform to this naming convention - + Comma-separated list of hostname suffixes per NIC. + If only one ip address is associated with each NIC: + !,!,..., for example, eth0!-eth0,ib0!-ib0 + If multiple ip addresses are associcated with each NIC: + !|,!|,..., for example, eth0!-eth0|-eth0-ipv6,ib0!-ib0|-ib0-ipv6. + The xCAT object definition commands support to use nichostnamesuffixes. as the sub attributes. + Note: According to DNS rules a hostname must be a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-),and period (.). When you are specifying "nichostnamesuffixes" or "nicaliases" make sure the resulting hostnames will conform to this naming convention \ **nicips**\ (nics.nicips) - Comma-separated list of IP addresses per NIC. To specify one ip address per NIC: - - - .. code-block:: perl - - !,!,..., for example, eth0!10.0.0.100,ib0!11.0.0.100 - - To specify multiple ip addresses per NIC: - - !|,!|,..., for example, eth0!10.0.0.100|fd55::214:5eff:fe15:849b,ib0!11.0.0.100|2001::214:5eff:fe15:849a. The xCAT object definition commands support to use nicips. as the sub attributes. - - Note: The primary IP address must also be stored in the hosts.ip attribute. The nichostnamesuffixes should specify one hostname suffix for each ip address. - + Comma-separated list of IP addresses per NIC. + To specify one ip address per NIC: + !,!,..., for example, eth0!10.0.0.100,ib0!11.0.0.100 + To specify multiple ip addresses per NIC: + !|,!|,..., for example, eth0!10.0.0.100|fd55::214:5eff:fe15:849b,ib0!11.0.0.100|2001::214:5eff:fe15:849a. The xCAT object definition commands support to use nicips. as the sub attributes. + Note: The primary IP address must also be stored in the hosts.ip attribute. The nichostnamesuffixes should specify one hostname suffix for each ip address. \ **nicnetworks**\ (nics.nicnetworks) Comma-separated list of networks connected to each NIC. - - - .. code-block:: perl - - If only one ip address is associated with each NIC: - - !,!, for example, eth0!10_0_0_0-255_255_0_0, ib0!11_0_0_0-255_255_0_0 - - If multiple ip addresses are associated with each NIC: - - !|,!|, for example, eth0!10_0_0_0-255_255_0_0|fd55:faaf:e1ab:336::/64,ib0!11_0_0_0-255_255_0_0|2001:db8:1:0::/64. The xCAT object definition commands support to use nicnetworks. as the sub attributes. - + If only one ip address is associated with each NIC: + !,!, for example, eth0!10_0_0_0-255_255_0_0, ib0!11_0_0_0-255_255_0_0 + If multiple ip addresses are associated with each NIC: + !|,!|, for example, eth0!10_0_0_0-255_255_0_0|fd55:faaf:e1ab:336::/64,ib0!11_0_0_0-255_255_0_0|2001:db8:1:0::/64. The xCAT object definition commands support to use nicnetworks. as the sub attributes. \ **nicsadapter**\ (nics.nicsadapter) Comma-separated list of extra parameters that will be used for each NIC configuration. - - - .. code-block:: perl - - !|,!|, for example, eth0!MTU=1500|MTU=1460,ib0!MTU=65520 CONNECTED_MODE=yes. - + !|,!|, for example, eth0!MTU=1500|MTU=1460,ib0!MTU=65520 CONNECTED_MODE=yes. @@ -781,9 +667,7 @@ node Attributes: .. code-block:: perl localdisk (Install to first non-FC attached disk) - usbdisk (Install to first USB mass storage device seen) - wwn=0x50000393c813840c (Install to storage device with given WWN) @@ -840,17 +724,11 @@ node Attributes: \ **password**\ (ppchcp.password, mpa.password, websrv.password, switches.sshpassword) Password of the HMC or IVM. If not filled in, xCAT will look in the passwd table for key=hmc or key=ivm. If not in the passwd table, the default used is abc123 for HMCs and padmin for IVMs. - or - Password to use to access the management module. If not specified, the key=blade row in the passwd table is used as the default. - or - Password to use to access the web service. - or - The remote login password. It can be for ssh or telnet. If it is for telnet, please set protocol to "telnet". If the sshusername is blank, the username, password and protocol will be retrieved from the passwd table with "switch" as the key. @@ -881,73 +759,34 @@ node Attributes: \ **prescripts-begin**\ (prescripts.begin) - The scripts to be run at the beginning of the nodeset(Linux), - - - .. code-block:: perl - - nimnodeset(AIX) or mkdsklsnode(AIX) command. - - The format is: - - [action1:]s1,s2...[|action2:s3,s4,s5...] - - where: - - - action1 and action2 for Linux are the nodeset actions specified in the command. - - For AIX, action1 and action1 can be 'diskless' for mkdsklsnode command' - - and 'standalone for nimnodeset command. - - - s1 and s2 are the scripts to run for action1 in order. - - - s3, s4, and s5 are the scripts to run for actions2. - - If actions are omitted, the scripts apply to all actions. - - Examples: - - myscript1,myscript2 (all actions) - - diskless:myscript1,myscript2 (AIX) - - install:myscript1,myscript2|netboot:myscript3 (Linux) - - - - All the scripts should be copied to /install/prescripts directory. - - The following two environment variables will be passed to each script: - - NODES a coma separated list of node names that need to run the script for - - ACTION current nodeset action. - - - - If '#xCAT setting:MAX_INSTANCE=number' is specified in the script, the script - - will get invoked for each node in parallel, but no more than number of instances - - will be invoked at at a time. If it is not specified, the script will be invoked - - once for all the nodes. - + The scripts to be run at the beginning of the nodeset(Linux), nimnodeset(AIX) or mkdsklsnode(AIX) command. + The format is: + [action1:]s1,s2...[| action2:s3,s4,s5...] + where: + - action1 and action2 for Linux are the nodeset actions specified in the command. + For AIX, action1 and action1 can be 'diskless' for mkdsklsnode command' + and 'standalone for nimnodeset command. + - s1 and s2 are the scripts to run for action1 in order. + - s3, s4, and s5 are the scripts to run for actions2. + If actions are omitted, the scripts apply to all actions. + Examples: + myscript1,myscript2 (all actions) + diskless:myscript1,myscript2 (AIX) + install:myscript1,myscript2|netboot:myscript3 (Linux) + All the scripts should be copied to /install/prescripts directory. + The following two environment variables will be passed to each script: + NODES a coma separated list of node names that need to run the script for + ACTION current nodeset action. + If '#xCAT setting:MAX_INSTANCE=number' is specified in the script, the script + will get invoked for each node in parallel, but no more than number of instances + will be invoked at at a time. If it is not specified, the script will be invoked + once for all the nodes. \ **prescripts-end**\ (prescripts.end) - The scripts to be run at the end of the nodeset(Linux), - - - .. code-block:: perl - - nimnodeset(AIX),or mkdsklsnode(AIX) command. - - The format is the same as the 'begin' column. - + The scripts to be run at the end of the nodeset(Linux), nimnodeset(AIX),or mkdsklsnode(AIX) command. The format is the same as the 'begin' column. @@ -1133,9 +972,7 @@ node Attributes: .. code-block:: perl = number of rows of slots in chassis - = number of columns of slots in chassis - = set to 0 if slots are vertical, and set to 1 if slots of horizontal @@ -1185,15 +1022,9 @@ node Attributes: \ **storagcontroller**\ (storage.controller) - The management address to attach/detach new volumes. - - - .. code-block:: perl - - In the scenario involving multiple controllers, this data must be - - passed as argument rather than by table value - + The management address to attach/detach new volumes. + In the scenario involving multiple controllers, this data must be + passed as argument rather than by table value @@ -1320,17 +1151,11 @@ node Attributes: \ **username**\ (ppchcp.username, mpa.username, websrv.username, switches.sshusername) Userid of the HMC or IVM. If not filled in, xCAT will look in the passwd table for key=hmc or key=ivm. If not in the passwd table, the default used is hscroot for HMCs and padmin for IVMs. - or - Userid to use to access the management module. - or - Userid to use to access the web service. - or - The remote login user name. It can be for ssh or telnet. If it is for telnet, please set protocol to "telnet". If the sshusername is blank, the username, password and protocol will be retrieved from the passwd table with "switch" as the key. @@ -1445,27 +1270,16 @@ node Attributes: \ **vmvirtflags**\ (vm.virtflags) - General flags used by the virtualization method. For example, in Xen it could, among other things, specify paravirtualized setup, or direct kernel boot. For a hypervisor/dom0 entry, it is the virtualization method (i.e. "xen"). For KVM, the following flag=value pairs are recognized: - - - .. code-block:: perl - - imageformat=[raw|fullraw|qcow2] - - raw is a generic sparse file that allocates storage on demand - - fullraw is a generic, non-sparse file that preallocates all space - - qcow2 is a sparse, copy-on-write capable format implemented at the virtualization layer rather than the filesystem level - - clonemethod=[qemu-img|reflink] - - qemu-img allows use of qcow2 to generate virtualization layer copy-on-write - - reflink uses a generic filesystem facility to clone the files on your behalf, but requires filesystem support such as btrfs - - placement_affinity=[migratable|user_migratable|pinned] - + General flags used by the virtualization method. + For example, in Xen it could, among other things, specify paravirtualized setup, or direct kernel boot. For a hypervisor/dom0 entry, it is the virtualization method (i.e. "xen"). For KVM, the following flag=value pairs are recognized: + imageformat=[raw|fullraw|qcow2] + raw is a generic sparse file that allocates storage on demand + fullraw is a generic, non-sparse file that preallocates all space + qcow2 is a sparse, copy-on-write capable format implemented at the virtualization layer rather than the filesystem level + clonemethod=[qemu-img|reflink] + qemu-img allows use of qcow2 to generate virtualization layer copy-on-write + reflink uses a generic filesystem facility to clone the files on your behalf, but requires filesystem support such as btrfs + placement_affinity=[migratable|user_migratable|pinned] diff --git a/docs/source/guides/admin-guides/references/man7/osimage.7.rst b/docs/source/guides/admin-guides/references/man7/osimage.7.rst index 23ac6bd49..0efa27081 100644 --- a/docs/source/guides/admin-guides/references/man7/osimage.7.rst +++ b/docs/source/guides/admin-guides/references/man7/osimage.7.rst @@ -90,9 +90,7 @@ osimage Attributes: \ **dump**\ (linuximage.dump, nimimage.dump) The NFS directory to hold the Linux kernel dump file (vmcore) when the node with this image crashes, its format is "nfs:///". If you want to use the node's "xcatmaster" (its SN or MN), can be left blank. For example, "nfs:///" means the NFS directory to hold the kernel dump file is on the node's SN, or MN if there's no SN. - or - The name of the NIM dump resource. @@ -279,10 +277,8 @@ osimage Attributes: \ **partitionfile**\ (linuximage.partitionfile, winimage.partitionfile) - The path of the configuration file which will be used to partition the disk for the node. For stateful osimages,two types of files are supported: "" which contains a partitioning definition that will be inserted directly into the generated autoinst configuration file and must be formatted for the corresponding OS installer (e.g. kickstart for RedHat, autoyast for SLES, pressed for Ubuntu). "s:" which specifies a shell script that will be run from the OS installer configuration file %pre section; the script must write the correct partitioning definition into the file /tmp/partitionfile on the node which will be included into the configuration file during the install process. For statelite osimages, partitionfile should specify ""; see the xCAT Statelite documentation for the xCAT defined format of this configuration file.For Ubuntu, besides "" or "s:", the disk name(s) to partition must be specified in traditional, non-devfs format, delimited with space, it can be specified in 2 forms: "d:" which contains the disk name(s) to partition and "s:d:" which runs in pressed/early_command and writes the disk names into the "/tmp/install_disk" . To support other specific partition methods such as RAID or LVM in Ubuntu, some additional preseed values should be specified, these values can be specified with "c:" which contains the additional pressed entries in "d-i ..." form and "s:c:" which runs in pressed/early_command and set the preseed values with "debconf-set". The multiple values should be delimited with comma "," - + The path of the configuration file which will be used to partition the disk for the node. For stateful osimages,two types of files are supported: "" which contains a partitioning definition that will be inserted directly into the generated autoinst configuration file and must be formatted for the corresponding OS installer (e.g. kickstart for RedHat, autoyast for SLES, pressed for Ubuntu). "s:" which specifies a shell script that will be run from the OS installer configuration file %pre section; the script must write the correct partitioning definition into the file /tmp/partitionfile on the node which will be included into the configuration file during the install process. For statelite osimages, partitionfile should specify ""; see the xCAT Statelite documentation for the xCAT defined format of this configuration file.For Ubuntu, besides "" or "s:", the disk name(s) to partition must be specified in traditional, non-devfs format, delimited with space, it can be specified in 2 forms: "d:" which contains the disk name(s) to partition and "s:d:" which runs in pressed/early_command and writes the disk names into the "/tmp/install_disk" . To support other specific partition methods such as RAID or LVM in Ubuntu, some additional preseed values should be specified, these values can be specified with "c:" which contains the additional pressed entries in "d-i ..." form and "s:c:" which runs in pressed/early_command and set the preseed values with "debconf-set". The multiple values should be delimited with comma "," or - The path of partition configuration file. Since the partition configuration for bios boot mode and uefi boot mode are different, this configuration file can include both configurations if you need to support both bios and uefi mode. Either way, you must specify the boot mode in the configuration. Example of partition configuration file: [BIOS]xxxxxxx[UEFI]yyyyyyy. To simplify the setting, you also can set installto in partitionfile with section like [INSTALLTO]0:1 @@ -398,9 +394,7 @@ osimage Attributes: \ **template**\ (linuximage.template, winimage.template) The fully qualified name of the template file that will be used to create the OS installer configuration file for stateful installations (e.g. kickstart for RedHat, autoyast for SLES). - or - The fully qualified name of the template file that is used to create the windows unattend.xml file for diskful installation. @@ -414,9 +408,7 @@ osimage Attributes: \ **usercomment**\ (linuximage.comments, nimimage.comments) Any user-written notes. - or - Any user-provided notes. From 300e7610b19d48f7896e57b94c7f93d2e806bcdf Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Fri, 27 May 2016 12:27:34 -0400 Subject: [PATCH 037/310] More formatting changes for the display --- .../admin-guides/references/man7/group.7.rst | 22 +++++++++++++++++++ .../admin-guides/references/man7/node.7.rst | 22 +++++++++++++++++++ .../references/man7/osimage.7.rst | 10 ++++++++- perl-xCAT/db2man | 2 +- 4 files changed, 54 insertions(+), 2 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man7/group.7.rst b/docs/source/guides/admin-guides/references/man7/group.7.rst index f3971c159..c3b62073b 100644 --- a/docs/source/guides/admin-guides/references/man7/group.7.rst +++ b/docs/source/guides/admin-guides/references/man7/group.7.rst @@ -286,7 +286,9 @@ group Attributes: \ **hcp**\ (ppc.hcp, zvm.hcp) The hardware control point for this node (HMC, IVM, Frame or CEC). Do not need to set for BPAs and FSPs. + or + The hardware control point for this node. @@ -330,11 +332,17 @@ group Attributes: \ **hwtype**\ (ppc.nodetype, zvm.nodetype, mp.nodetype, mic.nodetype) The hardware type of the node. Only can be one of fsp, bpa, cec, frame, ivm, hmc and lpar + or + The node type. Valid values: cec (Central Electronic Complex), lpar (logical partition), zvm (z/VM host operating system), and vm (virtual machine). + or + The hardware type for mp node. Valid values: mm,cmm, blade. + or + The hardware type of the mic node. Generally, it is mic. @@ -342,7 +350,9 @@ group Attributes: \ **id**\ (ppc.id, mp.id) For LPARs: the LPAR numeric id; for CECs: the cage number; for Frames: the frame number. + or + The slot number of this blade in the BladeCenter chassis. @@ -718,11 +728,17 @@ group Attributes: \ **password**\ (ppchcp.password, mpa.password, websrv.password, switches.sshpassword) Password of the HMC or IVM. If not filled in, xCAT will look in the passwd table for key=hmc or key=ivm. If not in the passwd table, the default used is abc123 for HMCs and padmin for IVMs. + or + Password to use to access the management module. If not specified, the key=blade row in the passwd table is used as the default. + or + Password to use to access the web service. + or + The remote login password. It can be for ssh or telnet. If it is for telnet, please set protocol to "telnet". If the sshusername is blank, the username, password and protocol will be retrieved from the passwd table with "switch" as the key. @@ -1115,11 +1131,17 @@ group Attributes: \ **username**\ (ppchcp.username, mpa.username, websrv.username, switches.sshusername) Userid of the HMC or IVM. If not filled in, xCAT will look in the passwd table for key=hmc or key=ivm. If not in the passwd table, the default used is hscroot for HMCs and padmin for IVMs. + or + Userid to use to access the management module. + or + Userid to use to access the web service. + or + The remote login user name. It can be for ssh or telnet. If it is for telnet, please set protocol to "telnet". If the sshusername is blank, the username, password and protocol will be retrieved from the passwd table with "switch" as the key. diff --git a/docs/source/guides/admin-guides/references/man7/node.7.rst b/docs/source/guides/admin-guides/references/man7/node.7.rst index c98520ff0..a0484fe5d 100644 --- a/docs/source/guides/admin-guides/references/man7/node.7.rst +++ b/docs/source/guides/admin-guides/references/man7/node.7.rst @@ -292,7 +292,9 @@ node Attributes: \ **hcp**\ (ppc.hcp, zvm.hcp) The hardware control point for this node (HMC, IVM, Frame or CEC). Do not need to set for BPAs and FSPs. + or + The hardware control point for this node. @@ -342,11 +344,17 @@ node Attributes: \ **hwtype**\ (ppc.nodetype, zvm.nodetype, mp.nodetype, mic.nodetype) The hardware type of the node. Only can be one of fsp, bpa, cec, frame, ivm, hmc and lpar + or + The node type. Valid values: cec (Central Electronic Complex), lpar (logical partition), zvm (z/VM host operating system), and vm (virtual machine). + or + The hardware type for mp node. Valid values: mm,cmm, blade. + or + The hardware type of the mic node. Generally, it is mic. @@ -354,7 +362,9 @@ node Attributes: \ **id**\ (ppc.id, mp.id) For LPARs: the LPAR numeric id; for CECs: the cage number; for Frames: the frame number. + or + The slot number of this blade in the BladeCenter chassis. @@ -724,11 +734,17 @@ node Attributes: \ **password**\ (ppchcp.password, mpa.password, websrv.password, switches.sshpassword) Password of the HMC or IVM. If not filled in, xCAT will look in the passwd table for key=hmc or key=ivm. If not in the passwd table, the default used is abc123 for HMCs and padmin for IVMs. + or + Password to use to access the management module. If not specified, the key=blade row in the passwd table is used as the default. + or + Password to use to access the web service. + or + The remote login password. It can be for ssh or telnet. If it is for telnet, please set protocol to "telnet". If the sshusername is blank, the username, password and protocol will be retrieved from the passwd table with "switch" as the key. @@ -1151,11 +1167,17 @@ node Attributes: \ **username**\ (ppchcp.username, mpa.username, websrv.username, switches.sshusername) Userid of the HMC or IVM. If not filled in, xCAT will look in the passwd table for key=hmc or key=ivm. If not in the passwd table, the default used is hscroot for HMCs and padmin for IVMs. + or + Userid to use to access the management module. + or + Userid to use to access the web service. + or + The remote login user name. It can be for ssh or telnet. If it is for telnet, please set protocol to "telnet". If the sshusername is blank, the username, password and protocol will be retrieved from the passwd table with "switch" as the key. diff --git a/docs/source/guides/admin-guides/references/man7/osimage.7.rst b/docs/source/guides/admin-guides/references/man7/osimage.7.rst index 0efa27081..23ac6bd49 100644 --- a/docs/source/guides/admin-guides/references/man7/osimage.7.rst +++ b/docs/source/guides/admin-guides/references/man7/osimage.7.rst @@ -90,7 +90,9 @@ osimage Attributes: \ **dump**\ (linuximage.dump, nimimage.dump) The NFS directory to hold the Linux kernel dump file (vmcore) when the node with this image crashes, its format is "nfs:///". If you want to use the node's "xcatmaster" (its SN or MN), can be left blank. For example, "nfs:///" means the NFS directory to hold the kernel dump file is on the node's SN, or MN if there's no SN. + or + The name of the NIM dump resource. @@ -277,8 +279,10 @@ osimage Attributes: \ **partitionfile**\ (linuximage.partitionfile, winimage.partitionfile) - The path of the configuration file which will be used to partition the disk for the node. For stateful osimages,two types of files are supported: "" which contains a partitioning definition that will be inserted directly into the generated autoinst configuration file and must be formatted for the corresponding OS installer (e.g. kickstart for RedHat, autoyast for SLES, pressed for Ubuntu). "s:" which specifies a shell script that will be run from the OS installer configuration file %pre section; the script must write the correct partitioning definition into the file /tmp/partitionfile on the node which will be included into the configuration file during the install process. For statelite osimages, partitionfile should specify ""; see the xCAT Statelite documentation for the xCAT defined format of this configuration file.For Ubuntu, besides "" or "s:", the disk name(s) to partition must be specified in traditional, non-devfs format, delimited with space, it can be specified in 2 forms: "d:" which contains the disk name(s) to partition and "s:d:" which runs in pressed/early_command and writes the disk names into the "/tmp/install_disk" . To support other specific partition methods such as RAID or LVM in Ubuntu, some additional preseed values should be specified, these values can be specified with "c:" which contains the additional pressed entries in "d-i ..." form and "s:c:" which runs in pressed/early_command and set the preseed values with "debconf-set". The multiple values should be delimited with comma "," + The path of the configuration file which will be used to partition the disk for the node. For stateful osimages,two types of files are supported: "" which contains a partitioning definition that will be inserted directly into the generated autoinst configuration file and must be formatted for the corresponding OS installer (e.g. kickstart for RedHat, autoyast for SLES, pressed for Ubuntu). "s:" which specifies a shell script that will be run from the OS installer configuration file %pre section; the script must write the correct partitioning definition into the file /tmp/partitionfile on the node which will be included into the configuration file during the install process. For statelite osimages, partitionfile should specify ""; see the xCAT Statelite documentation for the xCAT defined format of this configuration file.For Ubuntu, besides "" or "s:", the disk name(s) to partition must be specified in traditional, non-devfs format, delimited with space, it can be specified in 2 forms: "d:" which contains the disk name(s) to partition and "s:d:" which runs in pressed/early_command and writes the disk names into the "/tmp/install_disk" . To support other specific partition methods such as RAID or LVM in Ubuntu, some additional preseed values should be specified, these values can be specified with "c:" which contains the additional pressed entries in "d-i ..." form and "s:c:" which runs in pressed/early_command and set the preseed values with "debconf-set". The multiple values should be delimited with comma "," + or + The path of partition configuration file. Since the partition configuration for bios boot mode and uefi boot mode are different, this configuration file can include both configurations if you need to support both bios and uefi mode. Either way, you must specify the boot mode in the configuration. Example of partition configuration file: [BIOS]xxxxxxx[UEFI]yyyyyyy. To simplify the setting, you also can set installto in partitionfile with section like [INSTALLTO]0:1 @@ -394,7 +398,9 @@ osimage Attributes: \ **template**\ (linuximage.template, winimage.template) The fully qualified name of the template file that will be used to create the OS installer configuration file for stateful installations (e.g. kickstart for RedHat, autoyast for SLES). + or + The fully qualified name of the template file that is used to create the windows unattend.xml file for diskful installation. @@ -408,7 +414,9 @@ osimage Attributes: \ **usercomment**\ (linuximage.comments, nimimage.comments) Any user-written notes. + or + Any user-provided notes. diff --git a/perl-xCAT/db2man b/perl-xCAT/db2man index 56430a3c3..233fd2fd3 100755 --- a/perl-xCAT/db2man +++ b/perl-xCAT/db2man @@ -416,7 +416,7 @@ parentheses, what tables each attribute is stored in. EOS2 foreach my $a (sort keys %attrlist) { - my $d = join("\nor\n", @{$attrlist{$a}->{'descriptions'}}); + my $d = join("\n\nor\n\n", @{$attrlist{$a}->{'descriptions'}}); #$d =~ s/\n/\n\n/sg; # if there are newlines, double them so pod sees a blank line, otherwise pod will ignore them my $t = '(' . join(', ',@{$attrlist{$a}->{'tables'}}) . ')'; #print FILE "\nB<$a> - $d\n"; From 840f8cef6bfd195fb2fd5e826fa2d5a6cff4f07e Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Sun, 29 May 2016 22:11:32 -0400 Subject: [PATCH 038/310] fix bug 1224 xcattest returns Use of uninitialized value if the case fails and there is not stop label defined --- xCAT-test/xcattest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-test/xcattest b/xCAT-test/xcattest index 5adc90aa3..a51798fd1 100755 --- a/xCAT-test/xcattest +++ b/xCAT-test/xcattest @@ -868,7 +868,7 @@ sub runcase if($failed){ $failnum = $failnum + 1; log_error(@record); - if($$case{stop} =~ /^yes$/){ + if(defined ($$case{stop}) && ($$case{stop} =~ /^yes$/)){ $stop_to_keep_env=1; last; } From c5bdb1da871013a2a5c820213a07eae832d1c12f Mon Sep 17 00:00:00 2001 From: ertaozh Date: Fri, 27 May 2016 02:23:56 -0400 Subject: [PATCH 039/310] add command switchprobe to retrieve information from switches and/or check whether it is ready for MAC searchding --- perl-xCAT/xCAT/MacMap.pm | 192 +++++++++++++++++++++++-- perl-xCAT/xCAT/Usage.pm | 2 + xCAT-server/lib/xcat/plugins/switch.pm | 158 +++++++++++++++++++- 3 files changed, 334 insertions(+), 18 deletions(-) diff --git a/perl-xCAT/xCAT/MacMap.pm b/perl-xCAT/xCAT/MacMap.pm index ef92f18d2..21bb9508c 100644 --- a/perl-xCAT/xCAT/MacMap.pm +++ b/perl-xCAT/xCAT/MacMap.pm @@ -236,6 +236,109 @@ sub scan_qbridge_vlans { #TODO: try to scan } } + +#-------------------------------------------------------------------------------- + +=head3 dump_mac_info + Descriptions: + Retrieve information (switchport and the mac addresses got for that port) for the specified switch or all switches if no specified. + Arguments: + $req: the xcat request hash + $callback: the function to output information + Returns: + The hash variable store retrieved inforamtions + Usage example: + my $macmap = xCAT::MacMap->new(); + my $switch_data = $macmap->dump_mac_info($req, $callback); + foreach my $switch (keys %$switch_data) {...} +=cut + +#-------------------------------------------------------------------------------- + +sub dump_mac_info { + my $self = shift; + my $req = shift; + my $callback = shift; + my $noderange = undef; + if (defined($req->{node})) { + $noderange = $req->{node}; + } + my %ret = (); + $self->{collect_mac_info} = 1; + if (defined($req->{opt}->{verbose})) { + $self->{show_verbose_info} = 1; + $self->{callback} = $callback; + } + my $community = "public"; + my $dump_all_switches = 0; + my %switches_to_dump = (); + if (!defined($noderange)) { + $dump_all_switches = 1; + } + else { + foreach (@$noderange) { + $switches_to_dump{$_} = 1; + } + } + my $switchestab = xCAT::Table->new('switches', -create=>0); + my @switchesents = $switchestab->getAllNodeAttribs([qw(switch snmpversion username password privacy auth)]); + $self->fill_switchparms(community=>$community,switchesents=>\@switchesents); + my $switchtab = xCAT::Table->new('switch', -create=>0); + my @entries = (); + if ($switchtab) { + @entries = $switchtab->getAllNodeAttribs(['node','switch','port']); + } + #Build hash of switch port names per switch + $self->{switches} = {}; + foreach my $entry (@entries) { + if (defined($entry->{switch}) and $entry->{switch} ne "" and defined($entry->{port}) and $entry->{port} ne "") { + if ( !$self->{switches}->{$entry->{switch}}->{$entry->{port}}) { + $self->{switches}->{$entry->{switch}}->{$entry->{port}} = $entry->{node}; + } + else { + $self->{switches}->{$entry->{switch}}->{$entry->{port}} .= ",$entry->{node}"; + } + } + else { + xCAT::MsgUtils->message("S","xCAT Table error:".$entry->{node}."Has missing or invalid switch.switch and/or switch.port fields"); + } + } + foreach my $switch (keys $self->{switchparmhash}) { + if ($dump_all_switches or defined($switches_to_dump{$switch})) { + if ($self->{show_verbose_info}) { + xCAT::MsgUtils->message("I",{data=>["$switch: Start to get information"]}, $self->{callback}); + } + $self->refresh_switch(undef,$community,$switch); + if ($self->{show_verbose_info}) { + xCAT::MsgUtils->message("I",{data=>["$switch: Finish to get information"]}, $self->{callback}); + } + if (!defined($self->{macinfo}->{$switch})) { + $ret{$switch}->{ErrorStr} = "No information get"; + foreach my $defportname (keys %{$self->{switches}->{$switch}}) { + $ret{$switch}->{$defportname}->{Node} = $self->{switches}->{$switch}->{$defportname}; + } + } + elsif (defined($self->{macinfo}->{$switch}->{ErrorStr})) { + $ret{$switch}->{ErrorStr} = $self->{macinfo}->{$switch}->{ErrorStr}; + # To show the error message that the username/password related error is for SNMP only + if ($ret{$switch}->{ErrorStr} =~ /username|password/i) { + $ret{$switch}->{ErrorStr} .= " through SNMP"; + } + } else { + foreach my $snmpportname (keys %{$self->{macinfo}->{$switch}}) { + foreach my $defportname (keys %{$self->{switches}->{$switch}}) { + if (namesmatch($defportname, $snmpportname)) { + $ret{$switch}->{$snmpportname}->{Node} = $self->{switches}->{$switch}->{$defportname}; + } + } + @{$ret{$switch}->{$snmpportname}->{MACaddress}} = @{$self->{macinfo}->{$switch}->{$snmpportname}}; + } + } + } + } + return \%ret; +} + sub find_mac { # This function is given a mac address, checks for given mac address # and returns undef if unable to find the node, and the nodename otherwise @@ -410,6 +513,15 @@ sub walkoid { my $oid = shift; my %namedargs = @_; my $retmap = undef; + my $switch = undef; + my $callback = undef; + if (defined($namedargs{verbose})) { + $switch = $namedargs{switch}; + $callback = $namedargs{callback}; + } + if ($switch) { + xCAT::MsgUtils->message("I",{data=>["$switch: SNMP Session query OID:\"$oid\""]}, $callback); + } my $varbind = new SNMP::Varbind([$oid,'']); $session->getnext($varbind); if ($session->{ErrorStr}) { @@ -420,19 +532,28 @@ sub walkoid { xCAT::MsgUtils->message("S","Error communicating with ".$session->{DestHost}.": ".$session->{ErrorStr}); } } + if ($switch) { + xCAT::MsgUtils->message("I",{data=>["$switch: SNMP Session query OID:\"$oid\" Failed"]}, $callback); + } return undef; } my $count=0; + my $data_string; while ($varbind->[0] =~ /^$oid\.?(.*)/) { $count++; if ($1) { $retmap->{$1.".".$varbind->[1]}=$varbind->[2]; #If $1 is set, means key should + $data_string .= "\t\t '".$1.".".$varbind->[1]."' => '$varbind->[2]'\n"; } else { $retmap->{$varbind->[1]}=$varbind->[2]; #If $1 is set, means key should + $data_string .= "\t\t '$varbind->[1]' => '$varbind->[2]'\n"; } - $session->getnext($varbind); } + if ($switch) { + chomp ($data_string); + xCAT::MsgUtils->message("I",{data=>["$switch: SNMP Session get data for OID:\"$oid\":\n$data_string"]}, $callback); + } return $retmap; } @@ -460,6 +581,10 @@ sub getsnmpsession { Community => $community, UseNumeric => 1 ); + if ($self->{show_verbose_info}) { + xCAT::MsgUtils->message("I",{data=>["$switch: Generate SNMP session with parameter: \n\t\t'Version' => '$snmpver'\n\t\t'Community' => '$community'"]}, $self->{callback}); + } + } else { #we have snmp3 my %args= ( DestHost => $switch, @@ -476,6 +601,15 @@ sub getsnmpsession { $args{PrivProto} = uc($swent->{privacy}); $args{PrivPass} = $community; } + if ($self->{show_verbose_info}) { + my $parameter_string = ''; + foreach (keys %args) { + $parameter_string .= "\t\t'$_' => '$args{$_}'\n"; + } + chomp($parameter_string); + xCAT::MsgUtils->message("I",{data=>["$switch: Generate SNMP session with parameter: \n$parameter_string"]}, $self->{callback}); + } + $session = new SNMP::Session(%args); } return $session; @@ -486,11 +620,19 @@ sub refresh_switch { my $output = shift; my $community = shift; my $switch = shift; - #if ($error) { die $error; } my $session = $self->getsnmpsession('community'=>$community,'switch'=>$switch); - unless ($session) { xCAT::MsgUtils->message("S","Failed to communicate with $switch"); return; } - my $namemap = walkoid($session,'.1.3.6.1.2.1.31.1.1.1.1'); + unless ($session) { + xCAT::MsgUtils->message("S","Failed to communicate with $switch"); + if ($self->{collect_mac_info}) { + $self->{macinfo}->{$switch}->{ErrorStr} = "Failed to communicate with $switch through SNMP"; + } + return; + } + elsif ($session->{ErrorStr} and $self->{collect_mac_info}) { + $self->{macinfo}->{$switch}->{ErrorStr} = $session->{ErrorStr}; + } + my $namemap = walkoid($session,'.1.3.6.1.2.1.31.1.1.1.1', verbose=>$self->{show_verbose_info}, switch=>$switch, callback=>$self->{callback}); #namemap is the mapping of ifIndex->(human readable name) if ($namemap) { my $ifnamesupport=0; #Assume broken ifnamesupport until proven good... (Nortel switch) @@ -505,15 +647,17 @@ sub refresh_switch { } } unless ($namemap) { #Failback to ifDescr. ifDescr is close, but not perfect on some switches - $namemap = walkoid($session,'.1.3.6.1.2.1.2.2.1.2'); + $namemap = walkoid($session,'.1.3.6.1.2.1.2.2.1.2', verbose=>$self->{show_verbose_info}, switch=>$switch, callback=>$self->{callback}); } unless ($namemap) { + if ($session->{ErrorStr} and $self->{collect_mac_info}) { + $self->{macinfo}->{$switch}->{ErrorStr} = $session->{ErrorStr}; + } return; } #Above is valid without community string indexing, on cisco, we need it on the next one and onward - my $iftovlanmap = walkoid($session,'.1.3.6.1.4.1.9.9.68.1.2.2.1.2',silentfail=>1); #use cisco vlan membership mib to ascertain vlan - my $trunktovlanmap = walkoid($session,'.1.3.6.1.4.1.9.9.46.1.6.1.1.5',silentfail=>1); #for trunk ports, we are interested in the native vlan - #so we need cisco vtp mib too + my $iftovlanmap = walkoid($session,'.1.3.6.1.4.1.9.9.68.1.2.2.1.2',silentfail=>1,verbose=>$self->{show_verbose_info}, switch=>$switch, callback=>$self->{callback}); #use cisco vlan membership mib to ascertain vlan + my $trunktovlanmap = walkoid($session,'.1.3.6.1.4.1.9.9.46.1.6.1.1.5', silentfail=>1, verbose=>$self->{show_verbose_info}, switch=>$switch, callback=>$self->{callback}); #for trunk ports, we are interested in the native vlan, so we need cisco vtp mib too my %vlans_to_check; if (defined($iftovlanmap) or defined($trunktovlanmap)) { #We have a cisco, the intelligent thing is to do SNMP gets on the ports $self->{switchinfo}->{$switch}->{vlanidtoindex}="NA";#mark this switch to ignore for qbridge scans @@ -551,22 +695,44 @@ sub refresh_switch { $session = $self->getsnmpsession('switch'=>$switch,'community'=>$community,'vlanid'=>$vlan); } unless ($session) { return; } - my $bridgetoifmap = walkoid($session,'.1.3.6.1.2.1.17.1.4.1.2',ciscowarn=>$iscisco); # Good for all switches + my $bridgetoifmap = walkoid($session,'.1.3.6.1.2.1.17.1.4.1.2', ciscowarn=>$iscisco, verbose=>$self->{show_verbose_info}, switch=>$switch, callback=>$self->{callback}); # Good for all switches if (not ref $bridgetoifmap or !keys %{$bridgetoifmap}) { - xCAT::MsgUtils->message("S","Error communicating with ".$session->{DestHost}.": failed to get a valid response to BRIDGE-MIB request"); - return; + xCAT::MsgUtils->message("S","Error communicating with ".$session->{DestHost}.": failed to get a valid response to BRIDGE-MIB request"); + return; } # my $mactoindexmap = walkoid($session,'.1.3.6.1.2.1.17.4.3.1.2'); - my $mactoindexmap = walkoid($session,'.1.3.6.1.2.1.17.7.1.2.2.1.2',silentfail=>1); + my $mactoindexmap = walkoid($session,'.1.3.6.1.2.1.17.7.1.2.2.1.2',silentfail=>1, verbose=>$self->{show_verbose_info}, switch=>$switch, callback=>$self->{callback}); unless (defined($mactoindexmap)) { #if no qbridge defined, try bridge mib, probably cisco #$mactoindexmap = walkoid($session,'.1.3.6.1.2.1.17.7.1.2.2.1.2'); - $mactoindexmap = walkoid($session,'.1.3.6.1.2.1.17.4.3.1.2',ciscowarn=>$iscisco); + $mactoindexmap = walkoid($session,'.1.3.6.1.2.1.17.4.3.1.2',ciscowarn=>$iscisco, verbose=>$self->{show_verbose_info}, switch=>$switch, callback=>$self->{callback}); } #Ok, time to process the data if (not ref $mactoindexmap or !keys %{$mactoindexmap}) { xCAT::MsgUtils->message("S","Error communicating with ".$session->{DestHost}.": Unable to get MAC entries via either BRIDGE or Q-BRIDE MIB"); return; } + if (defined($self->{collect_mac_info})) { + my %index_to_mac = (); + foreach (keys %$mactoindexmap) { + my $index = $mactoindexmap->{$_}; + my @tmp = split /\./, $_; + my @mac = @tmp[-6 .. -1]; + my $macstring=sprintf("%02x:%02x:%02x:%02x:%02x:%02x",@mac); + push @{$index_to_mac{$index}}, $macstring; + } + foreach my $boid (keys %$bridgetoifmap) { + my $port_index = $boid; + my $port_name = $namemap->{$bridgetoifmap->{$port_index}}; + if (defined($index_to_mac{$port_index})) { + push @{$self->{macinfo}->{$switch}->{$port_name}}, @{$index_to_mac{$port_index}}; + } + else { + $self->{macinfo}->{$switch}->{$port_name}->[0] = ''; + } + } + return; + } + foreach my $oid (keys %$namemap) { #$oid =~ m/1.3.6.1.2.1.31.1.1.1.1.(.*)/; my $ifindex = $oid; diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index 14054ca94..e4ce30329 100755 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -304,6 +304,8 @@ my %usage = ( "switchdiscover" => "Usage: switchdiscover [-h|--help|-v|--version] switchdiscover [|--range ipranges] [-s scan_methods] [-r|-x|-z] [-w] [-V|--verbose]", + "switchprobe" => +"Usage: switchprobe [] [-V|--verbose | -c|--check]", "makentp" => "Usage: makentp [-h|--help|-v|--version] makentp [-a|--all] [-V|--verbose]", diff --git a/xCAT-server/lib/xcat/plugins/switch.pm b/xCAT-server/lib/xcat/plugins/switch.pm index f2d87daf3..1ae78f71a 100644 --- a/xCAT-server/lib/xcat/plugins/switch.pm +++ b/xCAT-server/lib/xcat/plugins/switch.pm @@ -23,6 +23,7 @@ sub handled_commands { return { findme => 'switch', findmac => 'switch', + switchprobe => 'switch', rspconfig => 'nodehm:mgt', }; } @@ -36,13 +37,13 @@ sub preprocess_request { my $noderange = $request->{node}; my $command = $request->{command}->[0]; - my $extrargs = $request->{arg}; - my @exargs=($request->{arg}); - if (ref($extrargs)) { - @exargs=@$extrargs; - } if ($command eq "rspconfig") { + my $extrargs = $request->{arg}; + my @exargs=($request->{arg}); + if (ref($extrargs)) { + @exargs=@$extrargs; + } my $usage_string=xCAT::Usage->parseCommand($command, @exargs); if ($usage_string) { $callback->({data=>$usage_string}); @@ -100,6 +101,90 @@ sub preprocess_request { } return \@requests; } + elsif ($command eq 'switchprobe') { + @ARGV = (); + if (ref($request->{arg})) { + @ARGV = @{$request->{arg}}; + } + use Getopt::Long; + $Getopt::Long::ignorecase = 0; + Getopt::Long::Configure( "bundling" ); + my $verbose = undef; + my $check = undef; + my $help = undef; + unless (GetOptions('h|help' => \$help, 'V|verbose' => \$verbose, 'c|check' => \$check)) { + $callback->({error=>["Parse args failed"], errorcode=>1}); + return; + } + if (@ARGV) { + $callback->({error=>["Option @ARGV not supported.\n".xCAT::Usage->getUsage($command)], errorcode=>1}); + return; + } + if (defined($help)) { + $callback->({data=>xCAT::Usage->getUsage($command)}); + return; + } + if (defined($verbose)) { + $request->{opt}->{verbose} = $verbose; + } + if (defined($check)) { + $request->{opt}->{check} = $check; + } + if (defined($noderange)) { + my $nthash = undef; + my $swhash = undef; + my $nodetypetab=xCAT::Table->new('nodetype',-create=>0); + if ($nodetypetab) { + $nthash = $nodetypetab->getNodesAttribs($noderange, ['nodetype']); + if (!defined($nthash)) { + $callback->({error=>["Get attributes from table 'nodetype' failed"],errorcode=>1}); + return; + } + } + else { + $callback->({error=>["Open table 'nodetype' failed"],errorcode=>1}); + return; + } + my $switchestab = xCAT::Table->new('switches', -create=>0); + if ($switchestab) { + $swhash = $switchestab->getNodesAttribs($noderange, ['switch']); + if (!defined($swhash)) { + $callback->({error=>["Get attributes from table 'switches' failed"],errorcode=>1}); + return; + } + } + else { + $callback->({error=>["Open table 'switches' failed"],errorcode=>1}); + return; + + } + my @switchnode = (); + my @errswnode = (); + my @errornode = (); + foreach my $node (@$noderange) { + if (!defined($nthash->{$node}) or $nthash->{$node}->[0]->{nodetype} ne 'switch') { + push @errornode, $node; + } + elsif (!defined($swhash->{$node})) { + push @errswnode, $node; + } + else { + push @switchnode, $node; + } + } + if (@errornode) { + $callback->({error=>["The nodetype is not 'switch' for nodes: ". join(",",@errornode)],errorcode=>1}); + } + if (@errswnode) { + $callback->({error=>["No switch configuration info find for ". join(",",@errswnode)],errorcode=>1}); + } + if (@switchnode) { + @{$request->{node}} = @switchnode; + return [$request]; + } + return; + } + } return [$request]; } @@ -119,6 +204,69 @@ sub process_request { return; } elsif ($req->{command}->[0] eq 'rspconfig') { return process_switch_config($req, $cb, $doreq); + } elsif ($req->{command}->[0] eq 'switchprobe') { + my $macinfo = $macmap->dump_mac_info($req, $cb); + if ($macinfo and ref($macinfo) eq 'HASH') { + my $switch_name_length = 0; + my $port_name_length = 0; + foreach my $switch (keys %$macinfo) { + if (length($switch) > $switch_name_length) { + $switch_name_length = length($switch); + } + if (defined($macinfo->{$switch}->{ErrorStr})) { + next; + } + foreach my $portname (keys %{$macinfo->{$switch}}) { + if (length($portname) > $port_name_length) { + $port_name_length = length($portname); + } + } + } + my $format = "%-".$switch_name_length."s %-".$port_name_length."s %-18s %s"; + my %failed_switches = (); + my $header = sprintf($format, "Switch", "Port", "MAC address", "Node"); + if (!defined($req->{opt}->{check}) and $port_name_length) { + $cb->({data=>$header}); + $cb->({data=>"------------------------------------------------------------------"}) + }; + foreach my $switch (keys %$macinfo) { + if (defined($macinfo->{$switch}->{ErrorStr})) { + if (defined($req->{opt}->{check})) { + $cb->({node=>[{name=>$switch, error=>[$macinfo->{$switch}->{ErrorStr}], errorcode=>1}]}); + } + else { + $failed_switches{$switch} = "$macinfo->{$switch}->{ErrorStr}"; + } + next; + } + elsif (defined($req->{opt}->{check})) { + $cb->({node=>[{name=>$switch, data=>["PASS"]}]}); + next; + } + foreach my $port (sort keys %{$macinfo->{$switch}}) { + my $node = ''; + if (defined($macinfo->{$switch}->{$port}->{Node})) { + $node = $macinfo->{$switch}->{$port}->{Node}; + } + my @macarrary = (); + if (defined($macinfo->{$switch}->{$port}->{MACaddress})) { + @macarray = @{$macinfo->{$switch}->{$port}->{MACaddress}}; + foreach (@macarray) { + my $data = sprintf($format, $switch, $port, ($_ ne '') ? $_ : ' N/A', $node); + $cb->({data=>$data}); + #$cb->({node=>[{name=>$switch,data=>$data}]}); + } + } + } + } + if (!defined($req->{opt}->{check}) and $port_name_length) { + $cb->({data=>"------------------------------------------------------------------"}) + } + foreach (keys %failed_switches) { + $cb->({node=>[{name=>$_, error=>[$failed_switches{$_}], errorcode=>1}]}); + } + } + return; } elsif ($req->{command}->[0] eq 'findme') { my $ip = $req->{'_xcat_clientip'}; if (defined $req->{nodetype} and $req->{nodetype}->[0] eq 'virtual') { From 38c23c3ac15751a1117103ad69f4fc1f4addf99c Mon Sep 17 00:00:00 2001 From: junxiawang Date: Mon, 30 May 2016 08:36:08 -0400 Subject: [PATCH 040/310] modify set up dockerhost testcase --- .../testcase/installation/ubuntu_full_installation_vm_docker | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_docker b/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_docker index b2fa46c92..1b9a943c8 100644 --- a/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_docker +++ b/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_docker @@ -44,4 +44,6 @@ cmd:xdsh $$CN "docker pull $$DOCKERIMAGE" check:rc==0 cmd:rmdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-dockerhost check:rc==0 +cmd: chdef $$CN postbootscripts= +check:rc==0 end From 8b05fc7185d6dd09f20e5c2e0db22e315ce744d1 Mon Sep 17 00:00:00 2001 From: junxiawang Date: Mon, 30 May 2016 08:39:59 -0400 Subject: [PATCH 041/310] modify setup docker host --- .../testcase/installation/ubuntu_full_installation_vm_docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_docker b/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_docker index 1b9a943c8..56f5d9953 100644 --- a/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_docker +++ b/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_docker @@ -28,7 +28,7 @@ cmd:rpower $$CN boot check:rc==0 cmd:sleep 40 cmd:lsdef -l $$CN | grep status -cmd:sleep 3600 +cmd:sleep 2400 check:rc==0 cmd:ping $$CN -c 3 check:output=~64 bytes from $$CN From d2e469f919506a5992d07c349938baccab54e20b Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Tue, 31 May 2016 03:24:37 -0400 Subject: [PATCH 042/310] change code logic and format depending on comments come from colleagues --- xCAT-probe/xcatprobe | 249 +++++++++++++++++++------------------------ 1 file changed, 112 insertions(+), 137 deletions(-) diff --git a/xCAT-probe/xcatprobe b/xCAT-probe/xcatprobe index 1e602b35f..366a00686 100755 --- a/xCAT-probe/xcatprobe +++ b/xCAT-probe/xcatprobe @@ -1,152 +1,159 @@ #!/usr/bin/env perl +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html use File::Basename; use Data::Dumper; use File::Path; use POSIX qw(WNOHANG setsid :errno_h); use Term::ANSIColor qw(:constants); -$Term::ANSIColor::AUTORESET=1; +$Term::ANSIColor::AUTORESET = 1; -my $pro_name=basename($0); -my $pro_dir=dirname($0); -#my $plugin_dir="$pro_dir/subcmds"; -my $plugin_dir="/opt/xcat/probe/subcmds"; -my %cmds=(); +$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; -my $verbose=0; -my $nocolor=0; -my $help=0; -my $list=0; +my $pro_name = basename($0); + +my $pro_dir="$::XCATROOT/probe/"; +my $plugin_dir = "$pro_dir/subcmds"; +my %cmds = (); + +my $verbose = 0; +my $nocolor = 0; +my $help = 0; +my $list = 0; $::USAGE = "Usage: xcatprobe -h xcatprobe -l -xcatprobe -v -xcatprobe [-n] +xcatprobe [-n] [-V] Options: -h : get usage information of $pro_name -l : list all valid sub commands - -v : print verbose information of $pro_name + -V : print verbose information of $pro_name -n : print output without colors "; #----------------------------------- + =head3 Description: Load sub commands from ~/subcmds directory Using -t option of command to judge if it is valid. If command in ~/subcmds has syntax error, or doesn't follow interface specification, this command will be skipped =cut + #----------------------------------- -sub loadsubcmds{ - my @candidate=glob("$plugin_dir/*"); - my @subcmds=(); - my @validflag=("debug", "warning", "failed", "ok"); +sub loadsubcmds { + my @candidate = glob("$plugin_dir/*"); + my @subcmds = (); my $output; - - print "Starting to load sub command form ~/subcmds.............\n" if($verbose); + + print "Starting to load sub command form ~/subcmds.............\n" if ($verbose); foreach (@candidate) { my $cmdname = basename("$_"); $output = `$_ -t 2>&1`; chomp($output); - - print "\n-->$_\n[OUTPUT]:\n$output\n" if($verbose); - if($output !~ /\[(\w+)\]\s*:\s*(.+)/){ - print "skip $_ for doing '$_ -t' failed, bad format\n" if($verbose); + + print "\n-->$_\n[OUTPUT]:\n$output\n" if ($verbose); + if ($output !~ /\[(\w+)\]\s*:\s*(.+)/) { + print "skip $_ for doing '$_ -t' failed, bad format\n" if ($verbose); next; - }else{ - my $desc =$2; - unless(@validflag ~~ /$1/){ - print "skip $_ for doing '$_ -t' failed, invalid flag\n" if($verbose); + } else { + my $desc = $2; + unless ($1 ~~ /^ok$/) { + print "skip $_ for doing '$_ -t' failed, invalid flag\n" if ($verbose); next; } $cmds{$cmdname} = $desc; - print "load $_ \n" if($verbose); + print "load $_ \n" if ($verbose); } } - print "\nLoad sub command.........[done]\n" if($verbose); + print "\nLoad sub command.........[done]\n" if ($verbose); } #----------------------------------- + =head3 Description: Format the output of sub command, make them colorfully. =cut -#---------------------------------- -sub format_cmd_output{ - my $line=shift; - my $nocolor=shift; - if($line =~ /\[(\w+)\]\s*:\s*(.+)/){ +#---------------------------------- +sub format_cmd_output { + my $line = shift; + my $nocolor = shift; + + if ($line =~ /\[(\w+)\]\s*:\s*(.+)/) { my $flag = $1; - my $msg = $2; - if($flag =~ /failed/i){ - if($nocolor){ + my $msg = $2; + if ($flag =~ /failed/i) { + if ($nocolor) { print "[FAIL] "; - }else{ - print BOLD RED "[FAIL] "; + } else { + print BOLD RED "[FAIL] "; } - }elsif($flag =~ /warning/i){ - if($nocolor){ + } elsif ($flag =~ /warning/i) { + if ($nocolor) { print "[WARN] "; - }else{ - print BOLD BLUE "[WARN] "; + } else { + print BOLD BLUE "[WARN] "; } - }elsif($flag =~ /ok/i){ - if($nocolor){ + } elsif ($flag =~ /ok/i) { + if ($nocolor) { print "[ OK ] "; - }else{ + } else { print BOLD GREEN "[ OK ] "; } - }elsif($flag =~ /debug/i){ + } elsif ($flag =~ /debug/i) { print " "; } print "$msg\n"; - }else{ + } else { print "$line\n"; } return 0; } #----------------------------------- + =head3 Description: List all valid sub command in ~/subcmds directory =cut + #---------------------------------- -sub listvalidsubcmd{ - my $maxlen=0; +sub listvalidsubcmd { + my $maxlen = 0; foreach my $key (keys %cmds) { - $maxlen=length($key) if(length($key)>$maxlen); + $maxlen = length($key) if (length($key) > $maxlen); } - $maxlen+=4; + $maxlen += 4; print "Supported sub commands are:\n"; - foreach my $key (keys %cmds){ - my @desc=split(" ", $cmds{$key}); - my $str=""; - my @formatdesc=(); - foreach my $word (@desc){ - $str.=$word." "; - if(length($str)>100){ - push @formatdesc, $str; - $str=""; + foreach my $key (keys %cmds) { + my @desc = split(" ", $cmds{$key}); + my $str = ""; + my @formatdesc = (); + foreach my $word (@desc) { + $str .= $word . " "; + if (length($str) > 100) { + push @formatdesc, $str; + $str = ""; } } push @formatdesc, $str; - if($nocolor){ + if ($nocolor) { print "$key"; - }else{ + } else { print BOLD GREEN "$key"; } - my $space=" " x ($maxlen-length($key)); + my $space = " " x ($maxlen - length($key)); print "$space $formatdesc[0]\n"; delete $formatdesc[0]; - $space=" " x $maxlen; - foreach my $line (@formatdesc){ - print "$space $line\n" if(length($line)); + $space = " " x $maxlen; + foreach my $line (@formatdesc) { + print "$space $line\n" if (length($line)); } } @@ -155,104 +162,72 @@ sub listvalidsubcmd{ ####################################### # main ####################################### -my @tmpargv=@ARGV; -my @supportopt=("-v","-h","-l","-n"); +my @tmpargv = @ARGV; +my @supportopt = ("-V", "-h", "-l", "-n"); my $pluginname; -my $optnum=0; -foreach my $attr (@tmpargv){ - if($attr =~ /^-/){ - unless(@supportopt ~~ /$attr/){ - print "Unsupported attribute: $attr\n"; - print $::USAGE; - exit 1; - } - $optnum++; - $help=1 if($attr eq "-h"); - $verbose=1 if($attr eq "-v"); - $list=1 if($attr eq "-l"); - $nocolor=1 if($attr eq "-n"); - }else{ - $pluginname=$attr; - last; - } +my $optnum = 0; +foreach my $attr (@tmpargv) { + if ($attr =~ /^-/) { + unless (@supportopt ~~ /^$attr$/) { + print "Unsupported attribute: $attr\n"; + print $::USAGE; + exit 1; + } + $optnum++; + $help = 1 if ($attr eq "-h"); + $verbose = 1 if ($attr eq "-V"); + $list = 1 if ($attr eq "-l"); + $nocolor = 1 if ($attr eq "-n"); + } else { + $pluginname = $attr; + last; + } } &loadsubcmds; -if(defined ($pluginname)){ - my $hit=0; - foreach my $key (keys %cmds){ - $hit=1 if($pluginname eq $key); +if (defined($pluginname)) { + my $hit = 0; + foreach my $key (keys %cmds) { + $hit = 1 if ($pluginname eq $key); } - unless($hit){ + unless ($hit) { print "Unsupported sub command: $pluginname\n"; &listvalidsubcmd; exit 1; } } -if($help){ +if ($help) { print $::USAGE; - exit 0; + exit 0; } -if($ARGV[0] eq "-l"){ +if ($ARGV[0] eq "-l") { &listvalidsubcmd; exit 0; } -if(!defined ($pluginname)){ +if (!defined($pluginname)) { print "There isn't sub command input from command line\n"; exit 0; } -for(my $i =0; $i<$optnum+1; $i++){ +for (my $i = 0 ; $i < $optnum + 1 ; $i++) { shift @tmpargv; } my $pluginattrs = join(" ", @tmpargv); +my $subcmd = "$plugin_dir/$pluginname $pluginattrs"; -my $date = `date +"%Y%m%d%H%M%S"`; -chomp($date); -my $cmmpath="/tmp/probe"; -my $cmmfile="$cmmpath/$pluginname.$date"; -mkpath("$cmmpath") unless(-d "$cmmpath"); -`touch $cmmfile`; -my $subcmd="$plugin_dir/$pluginname -f $cmmfile $pluginattrs"; +print "\nsubcmd = $subcmd\n" if ($verbose); -print "\n[main] subcmd = $subcmd\n" if($verbose); - -my $subproc = fork(); -my $subrst=0; -if(!defined($subproc)){ - print "Unable to fork new process to run subcommand\n"; - exit 1; -}elsif($subproc==0){ - $SIG{INT} = sub { - print "Sub proc $$ recrive INT signal to exit"; - exit 0; - }; - print "[sub $$] run $subcmd\n----------------------\n" if($verbose); - `$subcmd`; - exit $? ; +open(PIPE, "$subcmd |"); +while () { + chomp; + format_cmd_output($_, $nocolor); } +close(PIPE); # This will set the $? properly -if(!open (CMMFILE, "$cmmfile") ) { - print "[main] Failed to open $cmmfile\n"; - exit 1; -} -my $offset = 0; -my $prst=0; -if($subproc){ - do{ - seek(CMMFILE,$offset,0); - while(my $line = ){ - chomp($line); - format_cmd_output($line, $nocolor); - } - $offset=tell; - }while(waitpid($subproc, WNOHANG)==0) -} -close(CMMFILE); +my $ret = $? >> 8; -unlink($cmmfile); -exit 0; +exit $ret; From bb8e10cbac572c3cdaaf586bffb318f29a9881dc Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Tue, 31 May 2016 03:24:53 -0400 Subject: [PATCH 043/310] change code logic and format depending on comments come from colleagues --- xCAT-probe/subcmds/xcatmn | 758 +++++++++++++++++++++----------------- 1 file changed, 417 insertions(+), 341 deletions(-) diff --git a/xCAT-probe/subcmds/xcatmn b/xCAT-probe/subcmds/xcatmn index 7e9c3c21c..125a4b881 100755 --- a/xCAT-probe/subcmds/xcatmn +++ b/xCAT-probe/subcmds/xcatmn @@ -1,41 +1,42 @@ #! /usr/bin/perl +# IBM(c) 2016 EPL license http://www.eclipse.org/legal/epl-v10.html -#use lib "/home/probe/lib/perl"; -use lib "/opt/xcat/probe/lib/perl"; -use ProbeUtils; +BEGIN { $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; } + +use lib "$::XCATROOT/probe/lib/perl"; +use probe_utils; use File::Basename; -use Getopt::Long; +use Getopt::Long qw(:config no_ignore_case); -my $proname=basename("$0"); +my $proname = basename("$0"); my $help; -my $mnip; +my $installnic; my $test; -my $output="stdout"; -my $verbose=0; -my $rst=0; +my $output = "stdout"; +my $verbose = 0; +my $rst = 0; $::USAGE = "Usage: $proname -h $proname -t - $proname [-m] [-f] [-v] + $proname [-n] [-V] Description: After xcat installation, use this command to check if xcat has been installed correctly and is ready for use. Options: - -h : get usage information of $proname - -t : to verify if $proname can work, reserve option for probe framework - -m : specify current MN's IP address, if not specified, use master ip in site table - -f : specify where should $proname pass its output to. if not specified, pass output to STDOUT by default. - -v : output more information for debug + -h : Get usage information of $proname + -t : To verify if $proname can work, reserve option for probe framework + -n : Required. Specify the network interface name of provision network + -V : Output more information for debug "; -sub returncmdoutput{ - my $rst=shift; +sub returncmdoutput { + my $rst = shift; chomp($rst); - my @lines=split("[\n\r]", $rst); - foreach my $line (@lines){ - ProbeUtils->send_msg("$output",0, "$line"); + my @lines = split("[\n\r]", $rst); + foreach my $line (@lines) { + probe_utils->send_msg("$output", "d", "$line"); } } @@ -44,432 +45,507 @@ sub returncmdoutput{ # main process #------------------------------------- if ( - !GetOptions("--help|h|?" => \$help, - "t"=> \$test, - "v"=> \$verbose, - "f=s" => \$output, - "m=s" => \$mnip)) + !GetOptions("--help|h" => \$help, + "t" => \$test, + "V" => \$verbose, + "f=s" => \$output, + "n=s" => \$installnic)) { - ProbeUtils->send_msg("$output",2, "Invalid parameter for $proname"); - ProbeUtils->send_msg("$output",0, "$::USAGE"); + probe_utils->send_msg("$output", "f", "Invalid parameter for $proname"); + probe_utils->send_msg("$output", "d", "$::USAGE"); exit 1; } -if($help){ - if($output ne "stdout"){ - ProbeUtils->send_msg("$output",0, "$::USAGE"); - }else{ - print "$::USAGE"; - } - exit 0; +if ($help) { + if ($output ne "stdout") { + probe_utils->send_msg("$output", "d", "$::USAGE"); + } else { + print "$::USAGE"; + } + exit 0; } -if($test){ - ProbeUtils->send_msg("$output",3,"After xcat installation, use this command to check if xcat has been installed correctly and is ready for use. Before using this command , please install tftp, nslookup and wget commands ahead. The platform supported are redhat, sles and ubuntu."); - exit 0; +if ($test) { + probe_utils->send_msg("$output", "o", "After xcat installation, use this command to check if xcat has been installed correctly and is ready for use. Before using this command , please install tftp, nslookup and wget commands ahead. The platform supported are redhat, sles and ubuntu."); + exit 0; } -my $hostname=`hostname -s`; -chomp($hostname); -my $hostipaddr=`hostname -i`; -chomp($hostipaddr); -my $othername=`hostname -a`; -chomp($othername); +if (!defined($installnic)) { + probe_utils->send_msg("$output", "f", "Option -n is required"); + probe_utils->send_msg("$output", "d", "$::USAGE"); + exit 1; +} -ProbeUtils->send_msg("$output",0,"Short hostname of this server is $hostname") if($verbose); -ProbeUtils->send_msg("$output",0,"The address of hostname $hostname is $hostipaddr") if($verbose); -ProbeUtils->send_msg("$output",0,"The other names of $hostname is $othername") if($verbose && ($othername ne "")); +my $msg = "NIC $installnic exists on current server"; +my $nics = `ip addr show 2>&1 | grep -E '^[1-9]' | cut -d: -f2 |grep $installnic`; +if ($?) { + probe_utils->send_msg("$output", "f", "$msg"); + probe_utils->send_msg("$output", "d", "Please use 'ip addr show' to check if there is NIC named $installnic on current server"); + exit 1; +} else { + probe_utils->send_msg("$output", "o", "$msg"); +} -my $msg="Sub process 'xcatd: SSL listener' is running"; +$msg = "Get ip address of NIC $installnic"; +my $mnip = `ip addr show |grep -A2 $installnic: | awk -F" " '/inet/ {print \$2}'|awk -F"/" '{print \$1}'`; +chomp($mnip); +if (!defined($mnip) || ($mnip eq "")) { + probe_utils->send_msg("$output", "f", "$msg"); + probe_utils->send_msg("$output", "d", "Please use 'ip addr show' to check if there is ip assigned to $installnic"); + exit 1; +} else { + probe_utils->send_msg("$output", "d", "The IP of NIC $installnic is $mnip") if ($verbose); + probe_utils->send_msg("$output", "o", "$msg"); +} + +$msg = "Sub process 'xcatd: SSL listener' is running"; my $xcatdproc = `ps aux|grep -v grep|grep xcatd`; chomp($xcatdproc); -if($xcatdproc =~ /xcatd: SSL listener/){ - ProbeUtils->send_msg("$output",3,"$msg"); -}else{ - ProbeUtils->send_msg("$output",2,"$msg"); - $rst=1; +if ($xcatdproc =~ /xcatd: SSL listener/) { + probe_utils->send_msg("$output", "o", "$msg"); +} else { + probe_utils->send_msg("$output", "f", "$msg"); + $rst = 1; } -$msg="Sub process 'xcatd: DB Access' is running"; -if($xcatdproc =~ /xcatd: DB Access/){ - ProbeUtils->send_msg("$output",3,"$msg"); -}else{ - ProbeUtils->send_msg("$output",2,"$msg"); - $rst=1; +$msg = "Sub process 'xcatd: DB Access' is running"; +if ($xcatdproc =~ /xcatd: DB Access/) { + probe_utils->send_msg("$output", "o", "$msg"); +} else { + probe_utils->send_msg("$output", "f", "$msg"); + $rst = 1; } -$msg="Sub process 'xcatd: UDP listener' is running"; -if($xcatdproc =~ /xcatd: UDP listener/){ - ProbeUtils->send_msg("$output",3,"$msg"); -}else{ - ProbeUtils->send_msg("$output",2,"$msg"); - $rst=1; +$msg = "Sub process 'xcatd: UDP listener' is running"; +if ($xcatdproc =~ /xcatd: UDP listener/) { + probe_utils->send_msg("$output", "o", "$msg"); +} else { + probe_utils->send_msg("$output", "f", "$msg"); + $rst = 1; } -$msg="Sub process 'xcatd: install monitor' is running"; -if($xcatdproc =~ /xcatd: install monitor/){ - ProbeUtils->send_msg("$output",3,"$msg"); -}else{ - ProbeUtils->send_msg("$output",2,"$msg"); - $rst=1; +$msg = "Sub process 'xcatd: install monitor' is running"; +if ($xcatdproc =~ /xcatd: install monitor/) { + probe_utils->send_msg("$output", "o", "$msg"); +} else { + probe_utils->send_msg("$output", "f", "$msg"); + $rst = 1; } -$msg="Sub process 'xcatd: Discovery worker' is running"; -if($xcatdproc =~ /xcatd: Discovery worker/){ - ProbeUtils->send_msg("$output",3,"$msg"); -}else{ - ProbeUtils->send_msg("$output",2,"$msg"); - $rst=1; +$msg = "Sub process 'xcatd: Discovery worker' is running"; +if ($xcatdproc =~ /xcatd: Discovery worker/) { + probe_utils->send_msg("$output", "o", "$msg"); +} else { + probe_utils->send_msg("$output", "f", "$msg"); + $rst = 1; } -$msg="Sub process 'xcatd: Command log writer' is running"; -if($xcatdproc =~ /xcatd: Command log writer/){ - ProbeUtils->send_msg("$output",3,"$msg"); -}else{ - ProbeUtils->send_msg("$output",1,"Sub process 'xcatd: Command log writer' isn't running"); +$msg = "Sub process 'xcatd: Command log writer' is running"; +if ($xcatdproc =~ /xcatd: Command log writer/) { + probe_utils->send_msg("$output", "o", "$msg"); +} else { + probe_utils->send_msg("$output", "w", "Sub process 'xcatd: Command log writer' isn't running"); } -exit 1 if($rst); - +exit 1 if ($rst); -my $xcatdport=`tabdump site 2>&1 | awk -F',' '/xcatdport/ { gsub(/"/, "", \$2) ; print \$2 }'`; + +my $xcatdport = `tabdump site 2>&1 | awk -F',' '/xcatdport/ { gsub(/"/, "", \$2) ; print \$2 }'`; chomp($xcatdport); -ProbeUtils->send_msg("$output",0,"The port used by the xcatd daemon for client/server communication is $xcatdport") if($verbose); -$msg="xcatd is listening on port $xcatdport"; +probe_utils->send_msg("$output", "d", "The port used by the xcatd daemon for client/server communication is $xcatdport") if ($verbose); +$msg = "xcatd is listening on port $xcatdport"; my $cmdoutput = `netstat -ant|grep LISTEN|grep $xcatdport`; -if($?){ - ProbeUtils->send_msg("$output",2,"$msg"); - $rst=1; -}else{ - ProbeUtils->send_msg("$output",3,"$msg"); +if ($?) { + probe_utils->send_msg("$output", "f", "$msg"); + $rst = 1; +} else { + probe_utils->send_msg("$output", "o", "$msg"); } -my $xcatiport=`tabdump site 2>&1| awk -F',' '/xcatiport/ { gsub(/"/, "", \$2) ; print \$2 }'`; +my $xcatiport = `tabdump site 2>&1| awk -F',' '/xcatiport/ { gsub(/"/, "", \$2) ; print \$2 }'`; chomp($xcatiport); -ProbeUtils->send_msg("$output",0,"The port used by xcatd to receive install status updates from nodes is $xcatiport") if($verbose); -$msg="xcatd is listening on port $xcatiport"; -$cmdoutput = `netstat -ant|grep LISTEN|grep $xcatiport`; -if($?){ - ProbeUtils->send_msg("$output",2,"$msg"); - $rst=1; -}else{ - ProbeUtils->send_msg("$output",3,"$msg"); +probe_utils->send_msg("$output", "d", "The port used by xcatd to receive install status updates from nodes is $xcatiport") if ($verbose); +$msg = "xcatd is listening on port $xcatiport"; +$cmdoutput = `netstat -antp | grep -i xcatd|grep LISTEN|grep $xcatiport`; +if ($?) { + probe_utils->send_msg("$output", "f", "$msg"); + $rst = 1; +} else { + probe_utils->send_msg("$output", "o", "$msg"); } -exit 1 if($rst); - -$msg ="'lsxcatd -a' works"; -$cmdoutput=`lsxcatd -a 2>&1`; -$rst=$?; -returncmdoutput($cmdoutput) if($verbose); -if($rst){ - ProbeUtils->send_msg("$output",2,"$msg"); +exit 1 if ($rst); + +$msg = "'lsxcatd -a' works"; +$cmdoutput = `lsxcatd -a 2>&1`; +$rst = $?; +returncmdoutput($cmdoutput) if ($verbose); +if ($rst) { + probe_utils->send_msg("$output", "f", "$msg"); exit $rst; -}else{ - ProbeUtils->send_msg("$output",3,"$msg"); +} else { + probe_utils->send_msg("$output", "o", "$msg"); } -my $masteripinsite=`tabdump site | awk -F',' '/master/ { gsub(/"/, "", \$2) ; print \$2 }'`; +my $masteripinsite = `tabdump site | awk -F',' '/master/ { gsub(/"/, "", \$2) ; print \$2 }'`; chomp($masteripinsite); -ProbeUtils->send_msg("$output",0, "The value of 'master' in 'site' table is $masteripinsite") if($verbose); -ProbeUtils->send_msg("$output",2, "There isn't 'master' definition in 'site' talbe") if($masteripinsite eq ""); +probe_utils->send_msg("$output", "d", "The value of 'master' in 'site' table is $masteripinsite") if ($verbose); +probe_utils->send_msg("$output", "f", "There isn't 'master' definition in 'site' talbe") if ($masteripinsite eq ""); -$msg="The value of 'master' in 'site' table is a IP address"; -if(ProbeUtils->isIpAddr("$masteripinsite")){ - ProbeUtils->send_msg("$output",3,"$msg"); -}else{ - ProbeUtils->send_msg("$output",2,"$msg"); +$msg = "The value of 'master' in 'site' table is a IP address"; +if (probe_utils->is_ip_addr("$masteripinsite")) { + probe_utils->send_msg("$output", "o", "$msg"); +} else { + probe_utils->send_msg("$output", "f", "$msg"); exit 1; } -if($mnip){ - $msg="The IP passed by command line equals the value of 'master' in 'site' table"; - if($mnip eq $masteripinsite){ - ProbeUtils->send_msg("$output",3,"$msg"); - }else{ - ProbeUtils->send_msg("$output",2,"$msg"); - $rst=1; +if ($mnip) { + $msg = "The IP of $installnic equals the value of 'master' in 'site' table"; + if ($mnip eq $masteripinsite) { + probe_utils->send_msg("$output", "o", "$msg"); + } else { + probe_utils->send_msg("$output", "f", "$msg"); + $rst = 1; } -}else{ - ProbeUtils->send_msg("$output",0,"Use the value of 'master' of 'site' table as MNIP") if($verbose); - $mnip=$masteripinsite; } -ProbeUtils->send_msg("$output",0,"MNIP used in below checking is $mnip") if($verbose); - -$msg="There is configuration in 'passwd' table for 'system' for node provision"; -my $passwd=`tabdump passwd |awk -F',' '/system/ { gsub(/"/, "", \$2); gsub(/"/, "", \$3); print \$2,\$3 }'`; -chomp($passwd); -my ($username, $pw)=split(" ", $passwd); -if($username eq "" || $pw eq ""){ - ProbeUtils->send_msg("$output",0,"There isn't username or password for 'system' in 'passwd' table"); - ProbeUtils->send_msg("$output",2,"$msg"); - $rst=1; -}else{ - ProbeUtils->send_msg("$output",3,"$msg"); +$msg = "IP $mnip of NIC $installnic is a static IP on current server"; +if (probe_utils->is_static_ip("$mnip", "$installnic")) { + probe_utils->send_msg("$output", "o", "$msg"); +} else { + probe_utils->send_msg("$output", "w", "IP $mnip of $installnic is not a static ip on current server"); } -$msg="There is a network adapter on current server is configured by IP $mnip"; -my $nic=`ip addr show |grep -B2 $mnip|grep mtu|awk '{print \$2}'|sed -e 's/:\$//'`; -chomp($nic); -if("$nic" eq ""){ - ProbeUtils->send_msg("$output",2,"$msg"); - $rst=1; -}else{ - ProbeUtils->send_msg("$output",0,"IP $mnip belongs to network adapter $nic") if($verbose); - ProbeUtils->send_msg("$output",3,"$msg"); -} - -$msg="IP $mnip is a static IP on current server"; -if(ProbeUtils->isStaticIp("$mnip", "$nic")){ - ProbeUtils->send_msg("$output",3,"$msg"); -}else{ - ProbeUtils->send_msg("$output",1,"IP $mnip is not a static ip on current server"); -} - -$msg="$mnip belongs to one of networks defined in 'networks' table"; -my $networks=`tabdump networks|grep -v "^#"`; -$networks=~s/\"//g; +$msg = "$mnip belongs to one of networks defined in 'networks' table"; +my $networks = `tabdump networks|grep -v "^#"`; +$networks =~ s/\"//g; my $netcnt = `echo "$networks"|wc -l`; -my $hit=0; -for(my $i=1;$i<$netcnt+1;$i++){ - my $line=`echo "$networks" |sed -n ${i}p |awk -F"," '{print \$2,\$3,\$4}'`; +my $hit = 0; +for (my $i = 1 ; $i < $netcnt + 1 ; $i++) { + my $line = `echo "$networks" |sed -n ${i}p |awk -F"," '{print \$2,\$3,\$4}'`; chomp($line); - if($line =~ /(.+) (.+) (.+)/){ - $hit=1 if(ProbeUtils->isIpBelongToNet("$1", "$2", $mnip) && ("$3" eq "$nic")); + if ($line =~ /(.+) (.+) (.+)/) { + $hit = 1 if (probe_utils->is_ip_belong_to_net("$1", "$2", $mnip) && ("$3" eq "$installnic")); } } -if($hit){ - ProbeUtils->send_msg("$output",3,"$msg"); -}else{ - ProbeUtils->send_msg("$output",2,"$msg"); - $rst=1; +if ($hit) { + probe_utils->send_msg("$output", "o", "$msg"); +} else { + probe_utils->send_msg("$output", "f", "$msg"); + $rst = 1; } -$msg="There is domain definition in 'site' table"; -my $domain=`tabdump site | awk -F',' '/domain/ { gsub(/"/, "", \$2) ; print \$2 }'`; +$msg = "There is domain definition in 'site' table"; +my $domain = `tabdump site | awk -F',' '/domain/ { gsub(/"/, "", \$2) ; print \$2 }'`; chomp($domain); -if($domain){ - ProbeUtils->send_msg("$output",0,"The value of 'domain' in 'site' table is $domain") if($verbose); - ProbeUtils->send_msg("$output",3,"$msg"); -}else{ - ProbeUtils->send_msg("$output",2,"$msg"); - $rst=1; +if ($domain) { + probe_utils->send_msg("$output", "d", "The value of 'domain' in 'site' table is $domain") if ($verbose); + probe_utils->send_msg("$output", "o", "$msg"); +} else { + probe_utils->send_msg("$output", "f", "$msg"); + $rst = 1; } -$msg="There are /install and /install/postscripts directory on current server"; -if(-e "/install/postscripts/"){ - ProbeUtils->send_msg("$output",3,"$msg"); -}else{ - ProbeUtils->send_msg("$output",2,"$msg"); - $rst=1; +$msg = "There is configuration in 'passwd' table for 'system' for node provision"; +my $passwd = `tabdump passwd |awk -F',' '/system/ { gsub(/"/, "", \$2); gsub(/"/, "", \$3); print \$2,\$3 }'`; +chomp($passwd); +my ($username, $pw) = split(" ", $passwd); +if ($username eq "" || $pw eq "") { + probe_utils->send_msg("$output", "f", "$msg"); + probe_utils->send_msg("$output", "d", "Please define username and password for 'system' in 'passwd' table"); + $rst = 1; +} else { + probe_utils->send_msg("$output", "o", "$msg"); } -$msg="There is /tftpboot directory on current server"; -if(-e "/tftpboot/"){ - ProbeUtils->send_msg("$output",3,"$msg"); -}else{ - ProbeUtils->send_msg("$output",2,"$msg"); - $rst=1; +my $installdir = `tabdump site 2>&1 | awk -F',' '/installdir/ { gsub(/"/, "", \$2) ; print \$2 }'`; +chomp($installdir); +probe_utils->send_msg("$output", "d", "The 'install' directory is set to $installdir in 'site' table on current server") if ($verbose); +my $tftpdir = `tabdump site 2>&1 | awk -F',' '/tftpdir/ { gsub(/"/, "", \$2) ; print \$2 }'`; +chomp($tftpdir); +probe_utils->send_msg("$output", "d", "The 'tftp' directory is set to $tftpdir in 'site' talbe on current server") if ($verbose); + +$msg = "There is $installdir directory on current server"; +if (-e "$installdir/postscripts/") { + probe_utils->send_msg("$output", "o", "$msg"); +} else { + probe_utils->send_msg("$output", "f", "$msg"); + $rst = 1; } -my $expected=10; -$msg="The free space of / directory is more than $expected G"; -my $diskspace=`df -h|awk '{print \$4,\$6}'|grep -E "/\$"`; -if($?){ - ProbeUtils->send_msg("$output",0,"There isn't any filesystem mount on / directory"); - ProbeUtils->send_msg("$output",2,"$msg"); - $rst=1; -}else{ +$msg = "There is $tftpdir directory on current server"; +if (-e "$tftpdir") { + probe_utils->send_msg("$output", "o", "$msg"); +} else { + probe_utils->send_msg("$output", "f", "$msg"); + $rst = 1; +} + +my $expected = 10; +$msg = "The free space of / directory is more than $expected G"; +my $diskspace = `df -h|awk '{print \$4,\$6}'|grep -E "/\$"`; +if ($?) { + probe_utils->send_msg("$output", "d", "There isn't any filesystem mount on / directory"); + probe_utils->send_msg("$output", "f", "$msg"); + $rst = 1; +} else { chomp($diskspace); my ($size, $dir) = split(" ", $diskspace); - $size=~s/G//g; - ProbeUtils->send_msg("$output",0,"The free space of / is $size G") if($verbose); - if($size<$expected){ - ProbeUtils->send_msg("$output",1,"The free space of / is less than $expected G"); - }else{ - ProbeUtils->send_msg("$output",3,"$msg"); + $size =~ s/G//g; + probe_utils->send_msg("$output", "d", "The free space of / is $size G") if ($verbose); + if ($size < $expected) { + probe_utils->send_msg("$output", "w", "The free space of / is less than $expected G"); + } else { + probe_utils->send_msg("$output", "o", "$msg"); } } -$expected=1; -$msg="The free space of /var directory is more than $expected G"; -$diskspace=`df -h|awk '{print \$4,\$6}'|grep -E "/var\$"`; -if(!$?){ +$expected = 1; +$msg = "The free space of /var directory is more than $expected G"; +$diskspace = `df -h|awk '{print \$4,\$6}'|grep -E "/var\$"`; +if (!$?) { chomp($diskspace); my ($size, $dir) = split(" ", $diskspace); - $size=~s/G//g; - ProbeUtils->send_msg("$output",0,"The free space of /var is $size G") if($verbose); - if($size<$expected){ - ProbeUtils->send_msg("$output",1,"The free space of /var is less than $expected G"); - }else{ - ProbeUtils->send_msg("$output",3,"$msg"); + $size =~ s/G//g; + probe_utils->send_msg("$output", "d", "The free space of /var is $size G") if ($verbose); + if ($size < $expected) { + probe_utils->send_msg("$output", "w", "The free space of /var is less than $expected G"); + } else { + probe_utils->send_msg("$output", "o", "$msg"); } -} +} -$expected=1; -$msg="The free space of /tmp directory is more than $expected G"; -$diskspace=`df -h|awk '{print \$4,\$6}'|grep -E "/tmp\$"`; -if(!$?){ +$expected = 1; +$msg = "The free space of /tmp directory is more than $expected G"; +$diskspace = `df -h|awk '{print \$4,\$6}'|grep -E "/tmp\$"`; +if (!$?) { chomp($diskspace); my ($size, $dir) = split(" ", $diskspace); - $size=~s/G//g; - ProbeUtils->send_msg("$output",0,"The free space of /tmp is $size G") if($verbose); - if($size<$expected){ - ProbeUtils->send_msg("$output",1,"The free space of /tmp is less than $expected G"); - }else{ - ProbeUtils->send_msg("$output",3,"$msg"); + $size =~ s/G//g; + probe_utils->send_msg("$output", "d", "The free space of /tmp is $size G") if ($verbose); + if ($size < $expected) { + probe_utils->send_msg("$output", "w", "The free space of /tmp is less than $expected G"); + } else { + probe_utils->send_msg("$output", "o", "$msg"); } } -$expected=10; -$msg="The free space of /install directory is more than $expected G"; -$diskspace=`df -h|awk '{print \$4,\$6}'|grep -E "/install\$"`; -if(!$?){ +$expected = 10; +$msg = "The free space of $installdir directory is more than $expected G"; +$diskspace = `df -h|awk '{print \$4,\$6}'|grep -E "$installdir\$"`; +if (!$?) { chomp($diskspace); my ($size, $dir) = split(" ", $diskspace); - $size=~s/G//g; - ProbeUtils->send_msg("$output",0,"The free space of /install is $size G") if($verbose); - if($size<$expected){ - ProbeUtils->send_msg("$output",1,"The free space of /install is less than $expected G"); - }else{ - ProbeUtils->send_msg("$output",3,"$msg"); + $size =~ s/G//g; + probe_utils->send_msg("$output", "d", "The free space of /install is $size G") if ($verbose); + if ($size < $expected) { + probe_utils->send_msg("$output", "w", "The free space of /install is less than $expected G"); + } else { + probe_utils->send_msg("$output", "o", "$msg"); } } -$msg="SELinux is disabled on current server"; -if(ProbeUtils->isSelinuxEnable()){ - ProbeUtils->send_msg("$output",2,"$msg"); - $rst=1; -}else{ - ProbeUtils->send_msg("$output",3,"$msg"); +$msg = "SELinux is disabled on current server"; +if (probe_utils->is_selinux_enable()) { + probe_utils->send_msg("$output", "f", "$msg"); + $rst = 1; +} else { + probe_utils->send_msg("$output", "o", "$msg"); } -$msg="Firewall is closed on current server"; -if(ProbeUtils->isFirewallOpen()){ - ProbeUtils->send_msg("$output",2,"$msg"); - $rst=1; -}else{ - ProbeUtils->send_msg("$output",3,"$msg"); +$msg = "Firewall is closed on current server"; +if (probe_utils->is_firewall_open()) { + probe_utils->send_msg("$output", "f", "$msg"); + $rst = 1; +} else { + probe_utils->send_msg("$output", "o", "$msg"); } `which wget > /dev/null 2>&1`; -if($?){ - ProbeUtils->send_msg("$output",1,"wget command isn't installed on current server, skip checking HTTP service"); -}else{ - $msg="HTTP service is ready on $mnip"; - if(ProbeUtils->isHttpReady("$mnip")){ - ProbeUtils->send_msg("$output",3,"$msg"); - }else{ - ProbeUtils->send_msg("$output",2,"$msg"); - $rst=1; +if ($?) { + probe_utils->send_msg("$output", "w", "wget tool isn't installed on current server, skip checking HTTP service."); + probe_utils->send_msg("$output", "d", "Please do probe again after installing wget"); +} else { + $msg = "HTTP service is ready on $mnip"; + if (probe_utils->is_http_ready("$mnip")) { + probe_utils->send_msg("$output", "o", "$msg"); + } else { + probe_utils->send_msg("$output", "f", "$msg"); + $rst = 1; } } `which tftp > /dev/null 2>&1`; -if($?){ - ProbeUtils->send_msg("$output",1,"tftp command isn't installed in current server, skip checking tftp service"); -}else{ - $msg="TFTP service is ready on $mnip"; - if(ProbeUtils->isTftpReady("$mnip")){ - ProbeUtils->send_msg("$output",3,"$msg"); - }else{ - ProbeUtils->send_msg("$output",2,"$msg"); - $rst =1; +if ($?) { + probe_utils->send_msg("$output", "w", "tftp tool isn't installed on current server, skip checking tftp service."); + probe_utils->send_msg("$output", "d", "Please do probe again after installing tftp"); +} else { + $msg = "TFTP service is ready on $mnip"; + if (probe_utils->is_tftp_ready("$mnip")) { + probe_utils->send_msg("$output", "o", "$msg"); + } else { + probe_utils->send_msg("$output", "f", "$msg"); + $rst = 1; } } `which nslookup > /dev/null 2>&1`; -if($?){ - ProbeUtils->send_msg("$output",1,"nslookup command isn't installed in current server, skip checking DNS service"); -}else{ - $msg="DNS server is ready on $mnip"; - ProbeUtils->send_msg("$output",0,"hostname used to check DNS is $hostname, domain used to check DNS is $domain") if($verbose); - if(ProbeUtils->isDnsReady("$mnip","$hostname", "$domain")){ - ProbeUtils->send_msg("$output",3,"$msg"); - }else{ - ProbeUtils->send_msg("$output",2,"$msg"); - $rst =1; +if ($?) { + probe_utils->send_msg("$output", "w", "nslookup tool isn't installed in current server, skip checking DNS service."); + probe_utils->send_msg("$output", "d", "Please do probe again after installing nslookup"); +} else { + $msg = "DNS server is ready on $mnip"; + probe_utils->send_msg("$output", "d", "Domain used to check DNS is $domain") if ($verbose); + + my $rc = 0; + { #very important brace to create a block + my $tmp = `chdef xcatmntest groups=all ip=$mnip`; + if ($?) { + returncmdoutput($tmp) if ($verbose); + probe_utils->send_msg("$output", "d", "Simulate a node by chdef failed") if ($verbose); + $rc = 1; + last; + } else { + probe_utils->send_msg("$output", "d", "Simulate a node xcatmntest to do DNS test") if ($verbose); + } + + probe_utils->send_msg("$output", "d", "To do 'makehosts xcatmntest'") if ($verbose); + $tmp = `makehosts xcatmntest`; + if ($?) { + returncmdoutput($tmp) if ($verbose); + probe_utils->send_msg("$output", "d", "makehosts xcatmntest failed") if ($verbose); + $rc = 1; + `rmdef xcatmntest`; + last; + } + + $tmp = `cat /etc/hosts |grep xcatmntest |grep $mnip`; + if ($?) { + probe_utils->send_msg("$output", "d", "makehosts failed to add test node xcatmntest to /etc/hosts") if ($verbose); + $rc = 1; + `rmdef xcatmntest`; + last; + } + + probe_utils->send_msg("$output", "d", "To do 'makedns -n xcatmntest'") if ($verbose); + $tmp = `makedns -V -n xcatmntest 2>&1`; + if ($?) { + returncmdoutput($tmp) if ($verbose); + probe_utils->send_msg("$output", "d", "makedns -n xcatmntest failed") if ($verbose); + $rc = 1; + `makehosts -d xcatmntest && rmdef xcatmntest`; + last; + } + + if (!probe_utils->is_dns_ready("$mnip", "xcatmntest", "$domain")) { + probe_utils->send_msg("$output", "d", "nslookup xcatmntest $mnip failed"); + $rc = 1; + `makehosts -d xcatmntest && rmdef xcatmntest`; + last; + } + + probe_utils->send_msg("$output", "d", "Start to clear simulate information for DNS test") if ($verbose); + $tmp = `makedns -d xcatmntest && makehosts -d xcatmntest && rmdef xcatmntest`; + returncmdoutput($tmp) if ($verbose); + } + + if ($rc) { + probe_utils->send_msg("$output", "f", "$msg"); + $rst = 1; + } else { + probe_utils->send_msg("$output", "o", "$msg"); } } -my $os=ProbeUtils->getOS(); -my $leasefile=""; -$leasefile="/var/lib/dhcpd/dhcpd.leases" if($os =~ /redhat/i); -$leasefile="/var/lib/dhcp/db/dhcpd.leases" if($os =~ /sles/i); -$leasefile="/var/lib/dhcp/dhcpd.leases" if($os =~ /ubuntu/i); -$msg="The size of $leasefile is less than 100M"; -my $filesizetmp=`du -sb $leasefile`; -if($?){ - returncmdoutput($filesizetmp) if($verbose); - ProbeUtils->send_msg("$output",2,"$msg"); - $rst=1; -}else{ - chomp($filesizetmp); - my ($size, $file) = split(" ", $filesizetmp); - ProbeUtils->send_msg("$output",0,"The size of $leasefile is $size bytes") if($verbose); - if($size > 104857600){ - ProbeUtils->send_msg("$output",1,"The size of $leasefile is more than 100M"); - }else{ - ProbeUtils->send_msg("$output",3,"$msg"); - } +my $os = probe_utils->get_os(); +my $leasefile = ""; +$leasefile = "/var/lib/dhcpd/dhcpd.leases" if ($os =~ /redhat/i); +$leasefile = "/var/lib/dhcp/db/dhcpd.leases" if ($os =~ /sles/i); +$leasefile = "/var/lib/dhcp/dhcpd.leases" if ($os =~ /ubuntu/i); +$msg = "The size of $leasefile is less than 100M"; +my $filesizetmp = `du -sb $leasefile`; +if ($?) { + returncmdoutput($filesizetmp) if ($verbose); + probe_utils->send_msg("$output", "f", "$msg"); + $rst = 1; +} else { + chomp($filesizetmp); + my ($size, $file) = split(" ", $filesizetmp); + probe_utils->send_msg("$output", "d", "The size of $leasefile is $size bytes") if ($verbose); + if ($size > 104857600) { + probe_utils->send_msg("$output", "w", "The size of $leasefile is more than 100M"); + } else { + probe_utils->send_msg("$output", "o", "$msg"); + } } -my $msg="DHCP service is ready on $mnip"; -my $rc=0; +my $msg = "DHCP service is ready on $mnip"; +my $rc = 0; { #very important brace to create a block - my $tmp=`chdef xcatmntest groups=all ip=$mnip mac=aa:aa:aa:aa:aa:aa`; - if($?){ - returncmdoutput($tmp) if($verbose); - ProbeUtils->send_msg("$output",0,"Simulate a node by chdef failed") if($verbose); - $rc=1; - last; - }else{ - ProbeUtils->send_msg("$output",0,"Simulate a node xcatmntest to do dhcp test") if($verbose); - } - - $tmp=`makehosts xcatmntest`; - if($?){ - returncmdoutput($tmp) if($verbose); - ProbeUtils->send_msg("$output",0,"makehosts xcatmntest failed") if($verbose); - $rc=1; - `rmdef xcatmntest`; - last; + my $tmp = `chdef xcatmntest groups=all ip=$mnip mac=aa:aa:aa:aa:aa:aa`; if ($?) { + returncmdoutput($tmp) if ($verbose); + probe_utils->send_msg("$output", "d", "Simulate a node by chdef failed") if ($verbose); + $rc = 1; + last; + } else { + probe_utils->send_msg("$output", "d", "Simulate a node xcatmntest to do dhcp test") if ($verbose); } + probe_utils->send_msg("$output", "d", "To do 'makehosts xcatmntest'") if ($verbose); + $tmp = `makehosts xcatmntest`; + if ($?) { + returncmdoutput($tmp) if ($verbose); + probe_utils->send_msg("$output", "d", "makehosts xcatmntest failed") if ($verbose); + $rc = 1; + `rmdef xcatmntest`; + last; + } + + $tmp = `cat /etc/hosts |grep xcatmntest |grep $mnip`; + if ($?) { + probe_utils->send_msg("$output", "d", "makehosts failed to add test node xcatmntest to /etc/hosts") if ($verbose); + $rc = 1; + `rmdef xcatmntest`; + last; + } + + probe_utils->send_msg("$output", "d", "To do 'makedhcp xcatmntest'") if ($verbose); $tmp = `makedhcp xcatmntest 2>&1`; - if($?){ - returncmdoutput($tmp) if($verbose); - ProbeUtils->send_msg("$output",0,"makedhcp xcatmntest failed") if($verbose); - $rc=1; + if ($?) { + returncmdoutput($tmp) if ($verbose); + probe_utils->send_msg("$output", "d", "makedhcp xcatmntest failed") if ($verbose); + $rc = 1; `makehosts -d xcatmntest && rmdef xcatmntest`; last; - } + } + probe_utils->send_msg("$output", "d", "To do 'makedhcp -q xcatmntest'") if ($verbose); $tmp = `makedhcp -q xcatmntest`; - if($?){ - returncmdoutput($tmp) if($verbose); - ProbeUtils->send_msg("$output",0,"makedhcp -q xcatmntest failed") if($verbose); - $rc=1; - `makedhcp -d xcatmntest && makehosts -d xcatmntest && rmdef xcatmntest`; + if ($?) { + returncmdoutput($tmp) if ($verbose); + probe_utils->send_msg("$output", "d", "makedhcp -q xcatmntest failed") if ($verbose); + $rc = 1; +`makedhcp -d xcatmntest && makehosts -d xcatmntest && rmdef xcatmntest`; last; } chomp($tmp); - if($tmp !~ /xcatmntest: ip-address = $mnip, hardware-address = aa:aa:aa:aa:aa:aa/){ - returncmdoutput($tmp) if($verbose); - ProbeUtils->send_msg("$output",0,"DHCP server's reply is wrong") if($verbose); - $rc=1; - `makedhcp -d xcatmntest && makehosts -d xcatmntest && rmdef xcatmntest`; + if ($tmp !~ /xcatmntest: ip-address = $mnip, hardware-address = aa:aa:aa:aa:aa:aa/) { + returncmdoutput($tmp) if ($verbose); + probe_utils->send_msg("$output", "d", "DHCP server's reply is wrong") if ($verbose); + $rc = 1; +`makedhcp -d xcatmntest && makehosts -d xcatmntest && rmdef xcatmntest`; last; - } - - ProbeUtils->send_msg("$output",0,"Start to clear simulate information for dhcp test") if($verbose); - $tmp=`makedhcp -d xcatmntest && makehosts -d xcatmntest && rmdef xcatmntest`; - returncmdoutput($tmp) if($verbose); + } + + probe_utils->send_msg("$output", "d", "Start to clear simulate information for dhcp test") if ($verbose); + $tmp = `makedhcp -d xcatmntest && makehosts -d xcatmntest && rmdef xcatmntest`; + returncmdoutput($tmp) if ($verbose); } -if($rc){ - ProbeUtils->send_msg("$output",2,"$msg"); - $rst=1; -}else{ - ProbeUtils->send_msg("$output",3,"$msg"); +if ($rc) { + probe_utils->send_msg("$output", "f", "$msg"); + probe_utils->send_msg("$output", "d", "please run 'makedhcp -n' if never run it before."); + $rst = 1; +} else { + probe_utils->send_msg("$output", "o", "$msg"); } -exit $rst ; +exit $rst; From 8ae74152c12035b65af143442a2639e5e19c7d1f Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Tue, 31 May 2016 03:26:04 -0400 Subject: [PATCH 044/310] change code logic, format and file name depending on comments come from colleagues --- xCAT-probe/lib/perl/probe_utils.pm | 341 +++++++++++++++++++++++++++++ 1 file changed, 341 insertions(+) create mode 100644 xCAT-probe/lib/perl/probe_utils.pm diff --git a/xCAT-probe/lib/perl/probe_utils.pm b/xCAT-probe/lib/perl/probe_utils.pm new file mode 100644 index 000000000..5043e9d09 --- /dev/null +++ b/xCAT-probe/lib/perl/probe_utils.pm @@ -0,0 +1,341 @@ +package probe_utils; + +# IBM(c) 2016 EPL license http://www.eclipse.org/legal/epl-v10.html + +use strict; +use File::Path; +use File::Copy; + +#----------------------------------------- + +=head3 + Description: + Format output message depending on probe framework requirement + Format is [] : + The valid are debug, warning, failed and ok + Arguments: + output: where should output the message + num: the number of + 0: debug + 1: warning + 2: failed + 3: ok + msg: the information need to output + Returns: + 1 : Failed + 0 : success +=cut + +#---------------------------------------- +sub send_msg { + my $output = shift; + $output = shift if (($output) && ($output =~ /probe_utils/)); + my $tag = shift; + my $msg = shift; + my $flag; + + if ($tag eq "d") { + $flag = "[debug] :"; + } elsif ($tag eq "w") { + $flag = "[warning]:"; + } elsif ($tag eq "f") { + $flag = "[failed] :"; + } elsif ($tag eq "o") { + $flag = "[ok] :"; + } + + if ($output eq "stdout") { + print "$flag $msg\n"; + } else { + if (!open(LOGFILE, ">> $output")) { + return 1; + } + print LOGFILE "$flag $msg\n"; + close LOGFILE; + } + return 0; +} + +#------------------------------------------ + +=head3 + Description: + Test if a string is a IP address + Arguments: + addr: the string want to be judged + Returns: + 1 : yes + 0 : no +=cut + +#------------------------------------------ +sub is_ip_addr { + my $addr = shift; + $addr = shift if (($addr) && ($addr =~ /probe_utils/)); + return 0 unless ($addr); + return 0 if ($addr !~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/); + return 0 if ($1 > 255 || $1 == 0 || $2 > 255 || $3 > 255 || $4 > 255); + return 1; +} + +#------------------------------------------ + +=head3 + Description: + Test if a IP address belongs to a network + Arguments: + net : network address, such like 10.10.10.0 + mask: network mask. suck like 255.255.255.0 + ip: a ip address + Returns: + 1 : yes + 0 : no +=cut + +#------------------------------------------ +sub is_ip_belong_to_net { + my $net = shift; + $net = shift if (($net) && ($net =~ /probe_utils/)); + my $mask = shift; + my $targetip = shift; + + return 0 if ($net !~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/); + return 0 if ($mask !~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/); + return 0 if (!is_ip_addr($targetip)); + + my $bin_mask = 0; + $bin_mask = (($1 + 0) << 24) + (($2 + 0) << 16) + (($3 + 0) << 8) + ($4 + 0) if ($mask =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/); + + my $bin_ip = 0; + $bin_ip = (($1 + 0) << 24) + (($2 + 0) << 16) + (($3 + 0) << 8) + ($4 + 0) if ($targetip =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/); + + my $tmp_net = $bin_mask & $bin_ip; + + my $bin_net = 0; + $bin_net = (($1 + 0) << 24) + (($2 + 0) << 16) + (($3 + 0) << 8) + ($4 + 0) if ($net =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/); + + return 0 if ($tmp_net != $bin_net); + return 1; +} + +#------------------------------------------ + +=head3 + Description: + Get distro name of current operating system + Arguments: + None + Returns: + A string, include value are sles, redhat and ubuntu +=cut + +#------------------------------------------ +sub get_os { + my $os = "unknown"; + my $output = `cat /etc/*release* 2>&1`; + if ($output =~ /suse/i) { + $os = "sles"; + } elsif ($output =~ /Red Hat/i) { + $os = "redhat"; + } elsif ($output =~ /ubuntu/i) { + $os = "ubuntu"; + } + + return $os; +} + +#------------------------------------------ + +=head3 + Description: + Test if a IP address is a static IP address + Arguments: + ip: a ip address + nic: the network adapter which ip belongs to + Returns: + 1 : yes + 0 : no +=cut + +#------------------------------------------ +sub is_static_ip { + my $ip = shift; + $ip = shift if (($ip) && ($ip =~ /probe_utils/)); + my $nic = shift; + my $os = get_os(); + my $rst = 0; + + if ($os =~ /redhat/) { + my $output1 = `cat /etc/sysconfig/network-scripts/ifcfg-$nic 2>&1 |grep -i IPADDR`; + my $output2 = `cat /etc/sysconfig/network-scripts/ifcfg-$nic 2>&1 |grep -i BOOTPROTO`; + $rst = 1 if (($output1 =~ /$ip/) && ($output2 =~ /static/i)); + } elsif ($os =~ /sles/) { + my $output1 = `cat /etc/sysconfig/network/ifcfg-$nic 2>&1 |grep -i IPADDR`; + my $output2 = `cat /etc/sysconfig/network/ifcfg-$nic 2>&1 |grep -i BOOTPROTO`; + $rst = 1 if (($output1 =~ /$ip/) && ($output2 =~ /static/i)); + } elsif ($os =~ /ubuntu/) { + my $output = `cat /etc/network/interfaces 2>&1|grep -E "iface\s+$nic"`; + $rst = 1 if ($output =~ /static/i); + } + return $rst; +} + +#------------------------------------------ + +=head3 + Description: + Test if SELinux is opened in current operating system + Arguments: + None + Returns: + 1 : yes + 0 : no +=cut + +#------------------------------------------ +sub is_selinux_enable { + if (-e "/usr/sbin/selinuxenabled") { + `/usr/sbin/selinuxenabled`; + if ($? == 0) { + return 1; + } else { + return 0; + } + } else { + return 0; + } +} + +#------------------------------------------ + +=head3 + Description: + Test if firewall is opened in current operating system + Arguments: + None + Returns: + 1 : yes + 0 : no +=cut + +#------------------------------------------ +sub is_firewall_open { + my $os = get_os(); + my $output; + my $rst = 0; + + if ($os =~ /redhat/) { + $output = `service iptables status 2>&1`; + $rst = 1 if ($output =~ /running/i); + } elsif ($os =~ /sles/) { + $output = `service SuSEfirewall2_setup status`; + $rst = 1 if ($output =~ /running/i); + } elsif ($os =~ /ubuntu/) { + $output = `ufw status`; + $rst = 1 if ($output =~ /Status: active/i); + } + return $rst; +} + +#------------------------------------------ + +=head3 + Description: + Test if http service is ready to use in current operating system + Arguments: + ip: http server's ip + Returns: + 1 : yes + 0 : no +=cut + +#------------------------------------------ +sub is_http_ready { + my $mnip = shift; + $mnip = shift if (($mnip) && ($mnip =~ /probe_utils/)); + + my $http = "http://$mnip/install/postscripts/syslog"; + rename("./syslog", "./syslog.org") if (-e "./syslog"); + + my $outputtmp = `wget $http 2>&1`; + my $rst = $?; + if (($outputtmp =~ /200 OK/) && (!$rst) && (-e "./syslog")) { + unlink("./syslog"); + rename("./syslog.org", "./syslog") if (-e "./syslog.org"); + return 1; + } else { + rename("./syslog.org", "./syslog") if (-e "./syslog.org"); + return 0; + } +} + +#------------------------------------------ + +=head3 + Description: + Test if tftp service is ready to use in current operating system + Arguments: + ip: tftp server's ip + Returns: + 1 : yes + 0 : no +=cut + +#------------------------------------------ +sub is_tftp_ready { + my $mnip = shift; + $mnip = shift if (($mnip) && ($mnip =~ /probe_utils/)); + + rename("/tftpboot/tftptestt.tmp", "/tftpboot/tftptestt.tmp.old") if (-e "/tftpboot/tftptestt.tmp"); + rename("./tftptestt.tmp", "./tftptestt.tmp.old") if (-e "./tftptestt.tmp"); + + system("touch /tftpboot/tftptestt.tmp"); + my $output = `tftp -4 -v $mnip -c get tftptestt.tmp`; + if ((!$?) && (-e "./tftptestt.tmp")) { + unlink("./tftptestt.tmp"); + rename("./tftptestt.tmp.old", "./tftptestt.tmp") if (-e "./tftptestt.tmp.old"); + rename("/tftpboot/tftptestt.tmp.old", "/tftpboot/tftptestt.tmp") if (-e "/tftpboot/tftptestt.tmp.old"); + return 1; + } else { + rename("./tftptestt.tmp.old", "./tftptestt.tmp") if (-e "./tftptestt.tmp.old"); + rename("/tftpboot/tftptestt.tmp.old", "/tftpboot/tftptestt.tmp") if (-e "/tftpboot/tftptestt.tmp.old"); + return 0; + } +} + + +#------------------------------------------ + +=head3 + Description: + Test if DNS service is ready to use in current operating system + Arguments: + ip: DNS server's ip + Returns: + 1 : yes + 0 : no +=cut + +#------------------------------------------ +sub is_dns_ready { + my $mnip = shift; + $mnip = shift if (($mnip) && ($mnip =~ /probe_utils/)); + my $hostname = shift; + my $domain = shift; + + my $output = `nslookup $mnip $mnip 2>&1`; + + if ($?) { + return 0; + } else { + chomp($output); + my $tmp = `echo "$output" |grep "Server:[\t\s]*$mnip" >/dev/null 2>&1`; + print "$tmp"; + return 0 if ($?); + $tmp = `echo "$output"|grep "name ="|grep "$hostname\.$domain" >/dev/null 2>&1`; + return 0 if ($?); + return 1; + } +} + +1; From 22d14e483fad9c5266b9f2a0534c8dbbdbb7e1a0 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Tue, 31 May 2016 03:36:37 -0400 Subject: [PATCH 045/310] delete this file, replace by probe_utils.pm --- xCAT-probe/lib/perl/ProbeUtils.pm | 317 ------------------------------ 1 file changed, 317 deletions(-) delete mode 100644 xCAT-probe/lib/perl/ProbeUtils.pm diff --git a/xCAT-probe/lib/perl/ProbeUtils.pm b/xCAT-probe/lib/perl/ProbeUtils.pm deleted file mode 100644 index 8304fb76b..000000000 --- a/xCAT-probe/lib/perl/ProbeUtils.pm +++ /dev/null @@ -1,317 +0,0 @@ -package ProbeUtils; -use strict; -use File::Path; -use File::Copy; - -#----------------------------------------- -=head3 - Description: - Format output message depending on probe framework requirement - Format is [] : - The valid are debug, warning, failed and ok - Attribute: list by input sequence - output: where should output the message - num: the number of - 0: debug - 1: warning - 2: failed - 3: ok - msg: the information need to output - Return value: - 1 : Failed - 0 : success -=cut -#---------------------------------------- -sub send_msg { - my $output=shift; - $output=shift if(($output) && ($output =~ /ProbeUtils/)); - my $num = shift; - my $msg = shift; - my $flag; - - if ($num == 0) { - $flag = "[debug] :"; - }elsif($num == 1) { - $flag = "[warning]:"; - }elsif($num == 2) { - $flag = "[failed] :"; - }elsif($num == 3){ - $flag = "[ok] :"; - } - if($output eq "stdout"){ - print "$flag $msg\n"; - }else{ - if (!open (LOGFILE, ">> $output") ) { - return 1; - } - print LOGFILE "$flag $msg\n"; - close LOGFILE; - } - return 0; -} - -#------------------------------------------ -=head3 - Description: - Judge if a string is a IP address - Attribute: list by input sequence - addr: the string want to be judged - Return value: - 1 : yes - 0 : no -=cut -#------------------------------------------ -sub isIpAddr{ - my $addr = shift; - $addr=shift if(($addr) && ($addr =~ /ProbeUtils/)); - return 0 unless($addr); - return 0 if($addr !~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/); - return 0 if ($1 > 255 || $1 == 0 || $2 > 255 || $3 > 255 || $4 > 255); - return 1; -} - -#------------------------------------------ -=head3 - Description: - Judge if a IP address belongs to a network - Attribute: list by input sequence - net : network address, such like 10.10.10.0 - mask: network mask. suck like 255.255.255.0 - ip: a ip address - Return value: - 1 : yes - 0 : no -=cut -#------------------------------------------ -sub isIpBelongToNet{ - my $net=shift; - $net=shift if(($net) && ($net =~ /ProbeUtils/)); - my $mask=shift; - my $targetip=shift; - - return 0 if($net !~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/); - return 0 if($mask !~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/); - return 0 if(! isIpAddr($targetip)); - - my $bin_mask=0; - $bin_mask=(($1+0)<<24)+(($2+0)<<16)+(($3+0)<<8)+($4+0) if($mask =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/); - - my $bin_ip=0; - $bin_ip=(($1+0)<<24)+(($2+0)<<16)+(($3+0)<<8)+($4+0) if($targetip =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/); - - my $tmp_net = $bin_mask&$bin_ip; - - my $bin_net=0; - $bin_net=(($1+0)<<24)+(($2+0)<<16)+(($3+0)<<8)+($4+0) if($net =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/); - - return 0 if( $tmp_net != $bin_net); - return 1; -} - -#------------------------------------------ -=head3 - Description: - Get distro name of current operating system - Attribute: list by input sequence - None - Return value: - A string, include value are sles, redhat and ubuntu -=cut -#------------------------------------------ -sub getOS{ - my $os="unknown"; - my $output = `cat /etc/*release* 2>&1`; - if($output =~ /suse/i){ - $os="sles"; - }elsif($output =~ /Red Hat/i){ - $os="redhat"; - }elsif($output =~ /ubuntu/i){ - $os="ubuntu"; - } - - return $os; -} - -#------------------------------------------ -=head3 - Description: - Judge if a IP address is a static IP address - Attribute: list by input sequence - ip: a ip address - nic: the network adapter which ip belongs to - Return value: - 1 : yes - 0 : no -=cut -#------------------------------------------ -sub isStaticIp{ - my $ip=shift; - $ip=shift if(($ip) && ($ip =~ /ProbeUtils/)); - my $nic=shift; - my $os = getOS(); - my $rst=0; - - if($os =~ /redhat/){ - my $output1=`cat /etc/sysconfig/network-scripts/ifcfg-$nic 2>&1 |grep -i IPADDR`; - my $output2=`cat /etc/sysconfig/network-scripts/ifcfg-$nic 2>&1 |grep -i BOOTPROTO`; - $rst=1 if(($output1 =~ /$ip/) && ($output2 =~ /static/i)); - }elsif($os =~ /sles/){ - my $output1=`cat /etc/sysconfig/network/ifcfg-$nic 2>&1 |grep -i IPADDR`; - my $output2=`cat /etc/sysconfig/network/ifcfg-$nic 2>&1 |grep -i BOOTPROTO`; - $rst=1 if(($output1 =~ /$ip/) && ($output2 =~ /static/i)); - }elsif($os =~/ubuntu/){ - my $output=`cat /etc/network/interfaces 2>&1|grep -E "iface\s+$nic"`; - $rst=1 if($output =~ /static/i); - } - return $rst; -} - -#------------------------------------------ -=head3 - Description: - Judge if SELinux is opened in current operating system - Attribute: list by input sequence - None - Return value: - 1 : yes - 0 : no -=cut -#------------------------------------------ -sub isSelinuxEnable{ - if (-e "/usr/sbin/selinuxenabled") { - `/usr/sbin/selinuxenabled`; - if ($? == 0) { - return 1; - } else { - return 0; - } - } else { - return 0; - } -} - -#------------------------------------------ -=head3 - Description: - Judge if firewall is opened in current operating system - Attribute: list by input sequence - None - Return value: - 1 : yes - 0 : no -=cut -#------------------------------------------ -sub isFirewallOpen{ - my $os =getOS(); - my $output; - my $rst=0; - - if($os =~ /redhat/){ - $output=`service iptables status 2>&1`; - $rst=1 if($output =~ /running/i); - }elsif($os =~ /sles/){ - $output=`service SuSEfirewall2_setup status`; - $rst=1 if($output =~ /running/i); - }elsif($os =~/ubuntu/){ - $output=`ufw status`; - $rst=1 if($output =~ /Status: active/i); - } - return $rst; -} - -#------------------------------------------ -=head3 - Description: - Judge if http service is ready to use in current operating system - Attribute: list by input sequence - ip: http server's ip - Return value: - 1 : yes - 0 : no -=cut -#------------------------------------------ -sub isHttpReady{ - my $mnip=shift; - $mnip=shift if(($mnip) && ($mnip =~ /ProbeUtils/)); - - my $http = "http://$mnip/install/postscripts/efibootmgr"; - rename("./efibootmgr", "./efibootmgr.org") if(-e "./efibootmgr"); - - my $outputtmp = `wget $http 2>&1`; - my $rst =$?; - if(($outputtmp =~ /200 OK/) && (!$rst) && (-e "./efibootmgr")){ - unlink("./efibootmgr"); - rename("./efibootmgr.org", "./efibootmgr") if(-e "./efibootmgr.org"); - return 1; - }else{ - rename("./efibootmgr.org", "./efibootmgr") if(-e "./efibootmgr.org"); - return 0; - } -} - -#------------------------------------------ -=head3 - Description: - Judge if tftp service is ready to use in current operating system - Attribute: list by input sequence - ip: tftp server's ip - Return value: - 1 : yes - 0 : no -=cut -#------------------------------------------ -sub isTftpReady{ - my $mnip=shift; - $mnip=shift if(($mnip) && ($mnip =~ /ProbeUtils/)); - - rename("/tftpboot/tftptestt.tmp", "/tftpboot/tftptestt.tmp.old") if(-e "/tftpboot/tftptestt.tmp"); - rename("./tftptestt.tmp", "./tftptestt.tmp.old") if(-e "./tftptestt.tmp"); - - system("touch /tftpboot/tftptestt.tmp"); - my $output = `tftp -4 -v $mnip -c get tftptestt.tmp`; - if((!$?) && (-e "./tftptestt.tmp")){ - unlink("./tftptestt.tmp"); - rename("./tftptestt.tmp.old", "./tftptestt.tmp") if(-e "./tftptestt.tmp.old"); - rename("/tftpboot/tftptestt.tmp.old","/tftpboot/tftptestt.tmp") if(-e "/tftpboot/tftptestt.tmp.old"); - return 1; - }else{ - rename("./tftptestt.tmp.old", "./tftptestt.tmp") if(-e "./tftptestt.tmp.old"); - rename("/tftpboot/tftptestt.tmp.old","/tftpboot/tftptestt.tmp") if(-e "/tftpboot/tftptestt.tmp.old"); - return 0; - } -} - - -#------------------------------------------ -=head3 - Description: - Judge if DNS service is ready to use in current operating system - Attribute: list by input sequence - ip: DNS server's ip - Return value: - 1 : yes - 0 : no -=cut -#------------------------------------------ -sub isDnsReady{ - my $mnip=shift; - $mnip=shift if(($mnip) && ($mnip =~ /ProbeUtils/)); - my $hostname=shift; - my $domain=shift; - - my $output = `nslookup $mnip $mnip 2>&1`; - - if($?){ - return 0; - }else{ - chomp($output); - my $tmp=`echo "$output" |grep "Server:[\t\s]*$mnip" >/dev/null 2>&1`; - print "$tmp"; - return 0 if($?); - $tmp = `echo "$output"|grep "name ="|grep "$hostname\.$domain" >/dev/null 2>&1`; - return 0 if($?); - return 1; - } -} - -1; From 3bac56665b69bf0a4603d360c795d92a523e4623 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Tue, 31 May 2016 05:12:15 -0400 Subject: [PATCH 046/310] change the way of filtering NIC --- xCAT-probe/subcmds/xcatmn | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/xCAT-probe/subcmds/xcatmn b/xCAT-probe/subcmds/xcatmn index 125a4b881..aacf18b84 100755 --- a/xCAT-probe/subcmds/xcatmn +++ b/xCAT-probe/subcmds/xcatmn @@ -48,7 +48,6 @@ if ( !GetOptions("--help|h" => \$help, "t" => \$test, "V" => \$verbose, - "f=s" => \$output, "n=s" => \$installnic)) { probe_utils->send_msg("$output", "f", "Invalid parameter for $proname"); @@ -66,7 +65,7 @@ if ($help) { } if ($test) { - probe_utils->send_msg("$output", "o", "After xcat installation, use this command to check if xcat has been installed correctly and is ready for use. Before using this command , please install tftp, nslookup and wget commands ahead. The platform supported are redhat, sles and ubuntu."); + probe_utils->send_msg("$output", "o", "After xcat installation, use this command to check if xcat has been installed correctly and is ready for use. Before using this command, please install tftp, nslookup and wget commands ahead. The platform supported are redhat, sles and ubuntu."); exit 0; } @@ -77,7 +76,7 @@ if (!defined($installnic)) { } my $msg = "NIC $installnic exists on current server"; -my $nics = `ip addr show 2>&1 | grep -E '^[1-9]' | cut -d: -f2 |grep $installnic`; +my $nics = `ip addr show $installnic >/dev/null 2>&1`; if ($?) { probe_utils->send_msg("$output", "f", "$msg"); probe_utils->send_msg("$output", "d", "Please use 'ip addr show' to check if there is NIC named $installnic on current server"); @@ -87,7 +86,7 @@ if ($?) { } $msg = "Get ip address of NIC $installnic"; -my $mnip = `ip addr show |grep -A2 $installnic: | awk -F" " '/inet/ {print \$2}'|awk -F"/" '{print \$1}'`; +my $mnip = `ip addr show $installnic | awk -F" " '/inet / {print \$2}'|awk -F"/" '{print \$1}'`; chomp($mnip); if (!defined($mnip) || ($mnip eq "")) { probe_utils->send_msg("$output", "f", "$msg"); @@ -199,7 +198,7 @@ if (probe_utils->is_ip_addr("$masteripinsite")) { } if ($mnip) { - $msg = "The IP of $installnic equals the value of 'master' in 'site' table"; + $msg = "The IP $mnip of $installnic equals the value of 'master' in 'site' table"; if ($mnip eq $masteripinsite) { probe_utils->send_msg("$output", "o", "$msg"); } else { From 1665d4146d8c408de33cab11be153a8ac7c74b28 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Tue, 31 May 2016 05:14:24 -0400 Subject: [PATCH 047/310] change the description of send_msg function --- xCAT-probe/lib/perl/probe_utils.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xCAT-probe/lib/perl/probe_utils.pm b/xCAT-probe/lib/perl/probe_utils.pm index 5043e9d09..9a9b6f29e 100644 --- a/xCAT-probe/lib/perl/probe_utils.pm +++ b/xCAT-probe/lib/perl/probe_utils.pm @@ -16,10 +16,10 @@ use File::Copy; Arguments: output: where should output the message num: the number of - 0: debug - 1: warning - 2: failed - 3: ok + d: debug + w: warning + f: failed + o: ok msg: the information need to output Returns: 1 : Failed From 1a4a64644eaf7335dd321c7c406f73d7207a330b Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Tue, 31 May 2016 10:56:15 -0400 Subject: [PATCH 048/310] move get_nmapversion() to Utils.pm --- perl-xCAT/xCAT/Utils.pm | 22 +++++++++++++ xCAT-server/lib/xcat/plugins/bmcdiscover.pm | 7 ++-- .../lib/xcat/plugins/switchdiscover.pm | 33 +++---------------- 3 files changed, 28 insertions(+), 34 deletions(-) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index bd47dcfb2..f49fb3253 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -4690,4 +4690,26 @@ sub is_process_exists{ return 0; } +#-------------------------------------------------------------------------------- +=head3 get_nmapversion + for nmap version 5.10 above, the sP option changed to sn. + the output of some commands also have differents. + example: for snmp_scan option, + version 4.75 has output "Host 10.4.25.1 appears to be up ... good." but + for version 6.40, it has output "Discovered open port 161/udp on 10.4.25.1" + Returns: + result: version of nmap on the system +=cut +#-------------------------------------------------------------------------------- + +sub get_nmapversion { + my $nmap_version; + my $ccmd = "nmap -V | grep version"; + my $result = xCAT::Utils->runcmd($ccmd, 0); + my @version_array = split / /, $result; + $nmap_version = $version_array[2]; + return $nmap_version; +} + + 1; diff --git a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm index 3f38db8bd..02469dde2 100644 --- a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm @@ -457,15 +457,12 @@ sub scan_process{ ########################################################### if ( $method eq "nmap" ) { #check nmap version first - my $ccmd = "$nmap_path -V | grep version"; - my $version_result = xCAT::Utils->runcmd($ccmd, 0); - my @version_array = split / /, $version_result; - my $nmap_version = $version_array[2]; + my $nmap_version = xCAT::Utils->get_nmapversion(); # the output of nmap is different for version under 5.10 if (xCAT::Utils->version_cmp($nmap_version,"5.10") < 0) { $bcmd = join(" ",$nmap_path," -sP -n $range | grep \"appears to be up\" |cut -d ' ' -f2 |tr -s '\n' ' ' "); } else { - $bcmd = join(" ",$nmap_path," -sn -n $range | grep \"Nmap scan report\" |cut -d ' ' -f5 |tr -s '\n' ' ' "); + $bcmd = join(" ",$nmap_path," -sn -n $range | grep -B1 up | grep \"Nmap scan report\" |cut -d ' ' -f5 |tr -s '\n' ' ' "); } $ip_list = xCAT::Utils->runcmd("$bcmd", -1); diff --git a/xCAT-server/lib/xcat/plugins/switchdiscover.pm b/xCAT-server/lib/xcat/plugins/switchdiscover.pm index ccead4ce0..344997d2b 100644 --- a/xCAT-server/lib/xcat/plugins/switchdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/switchdiscover.pm @@ -651,7 +651,7 @@ sub nmap_scan { } }; - my $nmap_version = get_nmapversion($request); + my $nmap_version = xCAT::Utils->get_nmapversion(); if (xCAT::Utils->version_cmp($nmap_version,"5.10") < 0) { $ccmd = "/usr/bin/nmap -sP -oX - @$ranges"; } else { @@ -828,8 +828,8 @@ sub snmp_scan { #use nmap to find if snmp port is enabled # only open port will be scan - my $nmap_version = get_nmapversion($request); - if (xCAT::Utils->version_cmp($nmap_version,"5.10") <= 0) { + my $nmap_version = xCAT::Utils->get_nmapversion(); + if (xCAT::Utils->version_cmp($nmap_version,"5.10") < 0) { $ccmd = "/usr/bin/nmap -P0 -v -sU -p 161 -oA snmp_scan @$ranges | grep up | grep good "; } else { $ccmd = "/usr/bin/nmap -P0 -v -sU -p 161 -oA snmp_scan @$ranges | grep 'open port 161' "; @@ -856,7 +856,7 @@ sub snmp_scan { foreach my $line (@lines) { my @array = split / /, $line; my $ip; - if (xCAT::Utils->version_cmp($nmap_version,"4.75") <= 0) { + if (xCAT::Utils->version_cmp($nmap_version,"5.10") < 0) { $ip = $array[1]; } else { $ip = $array[5]; @@ -1252,30 +1252,5 @@ sub format_xml { return ($xml); } -#-------------------------------------------------------------------------------- -=head3 get_nmapversion - for nmap version 5.10 above, the sP option changed to sn. - the output of some commands also have differents. - example: for snmp_scan option, - version 4.75 has output "Host 10.4.25.1 appears to be up ... good." but - for version 6.40, it has output "Discovered open port 161/udp on 10.4.25.1" - Returns: - result: version of nmap on the system -=cut -#-------------------------------------------------------------------------------- - -sub get_nmapversion { - $request = shift; - my $nmap_version; - my $ccmd = "nmap -V | grep version"; - my $result = xCAT::Utils->runcmd($ccmd, 0); - my @version_array = split / /, $result; - $nmap_version = $version_array[2]; - if (exists($globalopt{verbose})) { - send_msg($request, 0, "version of nmap: $nmap_version\n"); - } - return $nmap_version; -} - 1; From f3b8e39827ebe3868e80725d582685a9230a6352 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 31 May 2016 11:38:02 -0400 Subject: [PATCH 049/310] Add some xCAT documentation writing guidelines --- .../developers/guides/docs/doc_guidelines.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/source/developers/guides/docs/doc_guidelines.rst b/docs/source/developers/guides/docs/doc_guidelines.rst index 347ece7cd..c42f5abb5 100644 --- a/docs/source/developers/guides/docs/doc_guidelines.rst +++ b/docs/source/developers/guides/docs/doc_guidelines.rst @@ -62,6 +62,24 @@ Enumerated List 2. Item 2 a) item a +Include another file +-------------------- + +To add contents of a document file inside another file, use ``.. include::``. This is usefull when a common information needs to be displayed in multiple files, whithout the use of a hyperlink. +:: + + .. include:: config_common.rst + +.. + + ``Note:`` Do not put customized link targets, such as ``.. _my_link_taget:`` inside the file to be included. If you do, a warning for a duplicate label will be displayed during the documentation build process. + +Index file +-------------------- +Index.rst files contain the ``.. toctree::`` tag. Files listed under that tag will have links to them displayed in the left side navigation area. If a documentation file does not wish to be accessbile from the navigation area, do not list it under the ``.. toctree::``. + + ``Note:`` If a file is not listed under the ``.. toctree::`` it might generate a warning during the documentation build ``WARNING: document isn't included in any toctree``. To eliminate such warning, add the file to the ``exclude_patterns`` list in the ``docs/source/conf.py`` file. However, do not add a file to the ``exclude_patterns`` list if it contains a customized link target, such as ``.. _my_link_taget:``. This link target will not be visible to other files and a ``WARNING: undefined label:`` will be displayed during the documentation build. + Hyperlinks -> Internal Links -> External Links ---------------------------------------------- From a3b995ac10b925147f28818e6a6dab7a2abcf250 Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Tue, 31 May 2016 19:07:17 +0100 Subject: [PATCH 050/310] Update mktoolscenter to incorporate Lenovo tools * prioritise IBM tools over Lenovo, in the same way as iflash * Only use unique values for machine times, don't need to do it more than that --- xCAT-server/share/xcat/tools/mktoolscenter | 38 +++++++++++++++------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/xCAT-server/share/xcat/tools/mktoolscenter b/xCAT-server/share/xcat/tools/mktoolscenter index 61752ce68..616c33462 100755 --- a/xCAT-server/share/xcat/tools/mktoolscenter +++ b/xCAT-server/share/xcat/tools/mktoolscenter @@ -188,8 +188,6 @@ chomp($ARCH); my $WEIRDARCH = $ARCH; $WEIRDARCH =~ s/_/-/; my $OSVER = "unknown"; -my $util = "ibm_utl_bomc*.bin"; -my $asu = "ibm_utl_asu_asut*$WEIRDARCH.tgz"; if ( -e '/etc/SuSE-release' ) { $OSVER=`grep -h VERSION /etc/SuSE-release |awk '{print $3}'` @@ -212,7 +210,7 @@ my $machines; if ($surrogate eq 0) { $instroot = `gettab key=installdir site.value`; my $nodes = `$nodels|tr '\n' ','`; - $machines = `$nodels $nodes vpd.mtm |cut -f2 -d:|sort -u|cut -b2-5`; + $machines = `$nodels $nodes vpd.mtm |cut -f2 -d:|sort -u|cut -b2-5 | uniq`; } else { $instroot = question("What is the installdir?","/install",''); $machines = question("What is the list of machine types?","7947",''); @@ -308,8 +306,8 @@ while ( question("Would you like to add others?","no","yesno") eq "yes") { output("#Current list is now:", $machines); } -my $srcdir = question("Where is the ibm_utl_bomc bin file?","/root/Desktop",''); -my $asudir = question("Where is the ibm_utl_asu tgz file?","/root/Desktop",''); +my $srcdir = question("Where is the BOMC bin file?","/root/Desktop",''); +my $asudir = question("Where is the ASU tgz file?","/root/Desktop",''); my $ppath = "$instroot/netboot/toolscenter/$ARCH"; my $path = "$ppath"."/".$profilename; my $reponame="repo"; @@ -328,7 +326,19 @@ my $sandbox = "$repo/sandbox"; mkpath($path); mkpath($sandbox); -if ( system("cp $srcdir/$util $repo") or system("cp $asudir/$asu $repo")) { +my $util = "_utl_bomc*.bin"; +my $asu = "_utl_asu_asut*$WEIRDARCH.tgz"; + +my $utilfile = "ibm".$util; +if (! -x $utilfile) { + $utilfile = "lnvgy".$util; +} +my $asufile = "ibm".$asu; +if (! -x $asufile) { + $asufile = "lnvgy".$asu; +} + +if ( system("cp $srcdir/$utilfile $repo") or system("cp $srcdir/$asufile $repo")) { output("Error copying input file"); exit; } @@ -344,8 +354,8 @@ if ($proxy{host} ne "") { } } -if ( system("chmod +x $repo/$util") or system("cd $repo; tar -zxf $asu") or system("cd $repo; ./$util --tui -m $machines $optstr -l .")) { - output("Error executing $repo/$util"); +if ( system("chmod +x $repo/$utilfile") or system("cd $repo; tar -zxf $asufile") or system("cd $repo; ./$utilfile --tui -m $machines $optstr -l .")) { + output("Error executing $repo/$utilfile"); exit; } @@ -375,7 +385,7 @@ if ($do_asu eq "yes") { my $srcp = "$repo/cmos_settings/$sol/$hpc"; foreach my $node (`$nodels`) { chomp($node); - my $machine_type = `$nodels $node vpd.mtm |cut -f2 -d: |cut -b2-5`; + my $machine_type = `$nodels $node vpd.mtm |cut -f2 -d: |cut -b2-5 | uniq`; chomp($machine_type); if ($machine_type ne '' and -e "$srcp/$machine_type") { `chtab node=$node firmware.cfgfile="$srcp/$machine_type"`; @@ -547,8 +557,14 @@ if (system($editstr1)) { exit; } -if ( system("cd $sandbox; cp $repo/asu* .; cp $repo/cdc_interface* .; cp $repo/$util .; cp -a $repo/uxspi .; cp $repo/ibm_utl_boot* .; echo y |./$util --tui --pxe=$path --no-acquire --latest --force -l .")) { - output("Error executing $path/$util for the second time"); +my $boot = "_utl_boot*"; +my $bootfile = "ibm".$boot; +if (! -x "$repo/$bootfile") { + $bootfile = "lnvgy".$boot; +} + +if ( system("cd $sandbox; cp $repo/asu* .; cp $repo/cdc_interface* .; cp $repo/$utilfile .; cp -a $repo/uxspi .; cp $repo/$bootfile .; echo y |./$utilfile --tui --pxe=$path --no-acquire --latest --force -l .")) { + output("Error executing $path/$utilfile for the second time"); exit; } From e7417e9b51f491a16acfd47ba7d06cd2729f0a72 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Tue, 31 May 2016 22:20:14 -0400 Subject: [PATCH 051/310] fix issue 1223 xcattest -c does not work for command list --- xCAT-test/xcattest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-test/xcattest b/xCAT-test/xcattest index 5adc90aa3..a193daa80 100755 --- a/xCAT-test/xcattest +++ b/xCAT-test/xcattest @@ -94,7 +94,7 @@ if($ret != 0){ goto EXIT; } #run case -&reordercases; +&reordercases if(defined($bundle_list) || defined($case_list)); &runcase; EXIT: From 547176bf581116ee4dd58f5e10a8f598b28bc0c4 Mon Sep 17 00:00:00 2001 From: XuWei Date: Wed, 25 May 2016 01:33:44 -0400 Subject: [PATCH 052/310] Add genesis log in doxcat --- xCAT-genesis-scripts/bin/bmcsetup | 63 ++++++++----- xCAT-genesis-scripts/bin/dodiscovery | 22 +++-- xCAT-genesis-scripts/bin/doxcat | 135 +++++++++++++++++++-------- 3 files changed, 147 insertions(+), 73 deletions(-) diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index 88513d726..2998b1c28 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -12,6 +12,8 @@ # 0x08 0x00 0x49 0x4e 0x54 0x45 0x4c # 0x08 0x04 # +log_label="xcat.genesis.bmcsetup" + allowcred.awk & CREDPID=$! sleep 5 @@ -19,7 +21,7 @@ IPCFGMETHOD=static while [ -z "$BMCIP" -a $IPCFGMETHOD="static" ]; do while ! getipmi do - echo "Retrying retrieval of IPMI settings from server" + logger -s -t $log_label -p local4.info "Retrying retrieval of IPMI settings from server" done TIMEOUT=15 BMCIP=`grep bmcip /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'` @@ -36,7 +38,7 @@ while [ -z "$BMCIP" -a $IPCFGMETHOD="static" ]; do IPCFGMETHOD="static" fi if [ -z "$BMCIP" -a $IPCFGMETHOD="static" ]; then - echo "FAILED TO RETRIEVE SETTINGS, RETRYING in 15 seconds" + logger -s -t $log_label -p local4.err "FAILED TO RETRIEVE SETTINGS, RETRYING in 15 seconds" sleep 15 fi done @@ -44,12 +46,15 @@ kill $CREDPID NUMBMCS=`grep bmcip /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'|wc -l` IPMIVER=`ipmitool mc info|grep ^IPMI|awk '{print $4}'` IPMIMFG=`ipmitool mc info|grep "^Manufacturer ID"|awk '{print $4}'` +logger -t $log_label -p local4.info "NUMBMCS is $NUMBMCS, IPMIVER is $IPMIVER, IPMIMFG is $IPMIMFG" if [ "$IPMIMFG" == 2 ]; then #IBM XPROD=`ipmitool mc info|grep "^Product ID"|awk '{print $4}'` + logger -t $log_label -p local4.info "XPROD is $XPROD" if [ "$XPROD" == "220" ]; then LOCKEDUSERS=1 BMCPORT=`grep bmcport /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'` + logger -t $log_label -p local4.info "BMCPORT is $BMCPORT" if [ ! -z "$BMCPORT" ]; then let idev=0 IFS=',' @@ -57,6 +62,7 @@ if [ "$IPMIMFG" == 2 ]; then #IBM ipmitool -d $idev raw 0xc 1 1 0xc0 $p > /dev/null ipmitool -d $idev raw 0x04 0x12 0x09 0x01 0x18 0x${p}1 0x00 > /dev/null CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` + logger -t $log_label -p local4.info "CURBMCPORT is $CURBMCPORT" while [ "$CURBMCPORT" -ne "$BMCPORT" ]; do sleep 1 CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` @@ -69,6 +75,7 @@ if [ "$IPMIMFG" == 2 ]; then #IBM LOCKEDUSERS=1 else IBMFAM=`ipmitool raw 0x3a 0x50 |head -n 1| awk '{print $1 $2 $3 $4}'` + logger -t $log_label -p local4.info "IBMFAM is $IBMFAM" if [ "$IBMFAM" == "59554f4f" ]; then BMCPORT=`grep bmcport /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'` if [ ! -z "$BMCPORT" ]; then @@ -77,6 +84,7 @@ if [ "$IPMIMFG" == 2 ]; then #IBM for p in $BMCPORT; do ipmitool -d $idev raw 0xc 1 1 0xc0 $p > /dev/null CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` + logger -t $log_label -p local4.info "CURBMCPORT is $CURBMCPORT" while [ "$CURBMCPORT" -ne "$BMCPORT" ]; do sleep 1 CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` @@ -90,11 +98,13 @@ if [ "$IPMIMFG" == 2 ]; then #IBM elif [ "$IPMIMFG" == 20301 -o "$IPMIMFG" == 19046 ] ; then XPROD=`ipmitool mc info|grep "^Product ID"|awk '{print $4}'` IBMVPDV=`ipmitool raw 0x3a 0xb 2 0 16 1` + logger -t $log_label -p local4.info "XPROD is $XPROD, IBMVPDV is $IBMVPDV" if [ $IBMVPDV -eq 2 ]; then ISITE=1; fi LOCKEDUSERS=1 BMCPORT=`grep bmcport /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'` + logger -t $log_label -p local4.info "BMCPORT is $BMCPORT" if [ ! -z "$BMCPORT" ]; then let idev=0 IFS=',' @@ -109,6 +119,7 @@ elif [ "$IPMIMFG" == 20301 -o "$IPMIMFG" == 19046 ] ; then # reverts to dhcp then static, which setting a static ip for is # considered invalid CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` + logger -t $log_label -p local4.info "CURBMCPORT is $CURBMCPORT" while [ -z "$CURBMCPORT" -o 0"$CURBMCPORT" -ne "$BMCPORT" ]; do sleep 1 CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` @@ -121,7 +132,7 @@ elif [ "$IPMIMFG" == "47488" ]; then LOCKEDUSERS=1 fi -echo -n "Auto detecting LAN channel..." +logger -s -t $log_label -p local4.info "Auto detecting LAN channel..." while [ -z "$LANCHAN" ]; do for TLANCHAN in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do if ipmitool channel info $TLANCHAN 2> /dev/null | grep 802.3 > /dev/null 2>&1 && ipmitool raw 0xc 2 $TLANCHAN 5 0 0 > /dev/null 2>&1; @@ -132,11 +143,11 @@ while [ -z "$LANCHAN" ]; do echo -n "." done if [ -z "$LANCHAN" ]; then - echo "Unable to detect lan channel, retrying in 10 seconds"; + logger -s -t $log_label -p local4.info "Unable to detect lan channel, retrying in 10 seconds" sleep 10 fi done -echo "Detected LAN channel $LANCHAN" +logger -s -t $log_label -p local4.info "Detected LAN channel $LANCHAN" let idev=NUMBMCS if [ $IPCFGMETHOD="static" ]; then @@ -236,12 +247,13 @@ if [ "$ISITE" = 1 ]; then CREDPID=$! while ! remoteimmsetup do - echo "Waiting for xCAT remote configuration of service processor via CMM.." + logger -s -t $log_label -p local4.info "Waiting for xCAT remote configuration of service processor via CMM.." done kill $CREDPID fi CURRENTUSER=`ipmitool -d $idev user list $LANCHAN|grep ^$USERSLOT|awk '{print $2}'` DISABLEUSERS=`echo 1 2 3 4|sed -e s/$USERSLOT//` +logger -t $log_label -p local4.info "CURRENTUSER is $CURRENTUSER, DISABLEUSERS is $DISABLEUSERS" for user in $DISABLEUSERS; do while ! ipmitool -d $idev user disable $user; do sleep 1 @@ -260,6 +272,7 @@ TRIES=0 # Last param in ipmitool user priv is the channel to set it on. # Penguin boxes are all channel 2 CURRPRIV=`ipmitool -d $idev user list $LANCHAN|grep ^$USERSLOT|awk '{print $6}'` +logger -t $log_label -p local4.info "CURRPRIV is $CURRPRIV" if [ "$CURRPRIV" != "ADMINISTRATOR" ]; then while ! ipmitool -d $idev user priv $USERSLOT 4 $LANCHAN; do sleep 1 @@ -294,7 +307,7 @@ while ! ipmitool -d $idev user set password $USERSLOT $bmcp; do if [ $TRIES -gt $TIMEOUT ]; then break; fi done TRIES=0 -echo "Set up following user table: " +logger -s -t $log_label -p local4.info "Set up following user table: " ipmitool -d $idev user list $LANCHAN let idev=idev-1 done @@ -303,8 +316,7 @@ let idev=NUMBMCS while [ $idev -gt 0 ]; do let idev=idev-1 - -echo -n "Enabling Channel $LANCHAN: " +logger -s -t $log_label -p local4.info "Enabling Channel $LANCHAN: " while ! ipmitool -d $idev raw 0x6 0x40 $LANCHAN 0x42 0x44 > /dev/null; do sleep 1 let TRIES=TRIES+1 @@ -316,29 +328,29 @@ while ! ipmitool -d $idev raw 0x6 0x40 $LANCHAN 0x82 0x84 > /dev/null; do let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; fi done -if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi +if [ $TRIES -gt $TIMEOUT ]; then logger -s -t $log_label -p local4.err "ERROR"; else logger -s -t $log_label -p local4.info "OK"; fi TRIES=0 -echo -n "Enabling ARP responses: " +logger -s -t $log_label -p local4.info "Enabling ARP responses: " while ! ipmitool -d $idev lan set $LANCHAN arp respond on > /dev/null; do sleep 1 let TRIES=TRIES+1 - echo -n . + echo -n "." if [ $TRIES -gt $TIMEOUT ]; then break; fi done -if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi +if [ $TRIES -gt $TIMEOUT ]; then logger -s -t $log_label -p local4.err "ERROR"; else logger -s -t $log_label -p local4.info "OK"; fi TRIES=0 -echo -n "Enabling IPMI v 1.5 MD5 LAN access:" +logger -s -t $log_label -p local4.info "Enabling IPMI v 1.5 MD5 LAN access:" while ! ipmitool -d $idev lan set $LANCHAN auth admin md5 > /dev/null; do sleep 1 let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; fi done -if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi +if [ $TRIES -gt $TIMEOUT ]; then logger -s -t $log_label -p local4.err "ERROR"; else logger -s -t $log_label -p local4.info "OK"; fi TRIES=0 if [ ! "$IPMIVER" == "1.5" ]; then - echo -n "Enabling IPMI v 2.0 LAN access: " + logger -s -t $log_label -p local4.info "Enabling IPMI v 2.0 LAN access: " #the following goals: #disable cipher suite 0 (if present, avoid password bypass) #disable cipher suite 1 (if present, to avoid weaking Kg if used) @@ -351,6 +363,7 @@ if [ ! "$IPMIVER" == "1.5" ]; then THREEIDX=$(ipmitool lan print $LANCHAN|grep ^RMCP+|cut -d: -f 2|sed -e 's/ //' -e 's/,/\n/g'|grep -n '^3$'|sed -e 's/:.*//') ACCESS=$(ipmitool lan print $LANCHAN|grep 'Cipher Suite Priv Max'|cut -d: -f 2|sed -e 's/ //g' -e 's/\(.\)/\1\n/g'|grep -v '^$') NEWACCESS="" + logger -t $log_label -p local4.info "ZEROIDX is $ZEROIDX, ONEIDX is $ONEIDX, TWOIDX is $TWOIDX, THREEIDX is $THREEIDX, ACCESS is $ACCESS" i=1 for elem in $ACCESS; do if [ $i = "$ZEROIDX" -o $i = "$ONEIDX" ]; then @@ -364,28 +377,28 @@ if [ ! "$IPMIVER" == "1.5" ]; then i=$((i+1)) done if ipmitool lan set $LANCHAN cipher_privs $NEWACCESS > /dev/null; then - echo OK + logger -s -t $log_label -p local4.info "OK" else - echo ERROR + logger -s -t $log_label -p local4.err "ERROR" fi TRIES=0 - echo -n "Enabling SOL for channel $LANCHAN:" + logger -s -t $log_label -p local4.info "Enabling SOL for channel $LANCHAN:" while ! ipmitool -d $idev raw 0xc 0x21 $LANCHAN 0x1 0x1 > /dev/null; do sleep 1 let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; fi done - if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi + if [ $TRIES -gt $TIMEOUT ]; then logger -s -t $log_label -p local4.err "ERROR"; else logger -s -t $log_label -p local4.info "OK"; fi TRIES=0 - echo -n "Enabling SOL for $BMCUS:" + logger -s -t $log_label -p local4.info "Enabling SOL for $BMCUS:" while ! ipmitool -d $idev raw 6 0x4c $LANCHAN $USERSLOT 2 0 0 0 > /dev/null; do sleep 1 let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; fi done - if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi + if [ $TRIES -gt $TIMEOUT ]; then logger -s -t $log_label -p local4.err "ERROR"; else logger -s -t $log_label -p local4.info "OK"; fi # 0xc 0x21 with data 7 is used to set payload channel, it is readonly in the ipmiv2.0 doc, so comment this section out. #echo -n "Putting SOL on channel $LANCHAN:" @@ -416,9 +429,9 @@ if [ "$XPROD" = "309" -o "$XPROD" = "43707" ] ; then # have a sleep here for 30 seconds, then issue the reset of the BMC sleep 30 fi - echo "Resetting BMC ..." + logger -s -t $log_label -p local4.info "Resetting BMC ..." ipmitool mc reset cold - echo "Waiting for the BMC to appear ..." + logger -s -t $log_label -p local4.info "Waiting for the BMC to appear ..." sleep 15 TRIES=0 while ! ipmitool lan print $LANCHAN > /dev/null; do @@ -439,7 +452,7 @@ if [ ! -z "$XCATMASTER" ]; then updateflag.awk $XCATMASTER 3002 "installstatus bmcready" fi -echo "Lighting Identify Light" +logger -s -t $log_label -p local4.info "Lighting Identify Light" while : do ipmitool -d $idev raw 0 4 10 > /dev/null sleep 7 diff --git a/xCAT-genesis-scripts/bin/dodiscovery b/xCAT-genesis-scripts/bin/dodiscovery index 8e139dfa9..b355ef115 100755 --- a/xCAT-genesis-scripts/bin/dodiscovery +++ b/xCAT-genesis-scripts/bin/dodiscovery @@ -1,10 +1,12 @@ #!/bin/bash +log_label="xcat.genesis.dodiscovery" + minixcatd.awk & PUBKEY=`openssl rsa -in /etc/xcat/privkey.pem -pubout 2> /dev/null|grep -v "PUBLIC KEY"` PUBKEY=`echo $PUBKEY|sed -e 's/ //g'` export PUBKEY -echo "Beginning node discovery process" +logger -s -t $log_label -p local4.info "Beginning node discovery process..." for nic in `ip link|grep mtu|grep -v LOOPBACK|grep -v usb|grep -v ,LOWER_UP|awk -F: '{print $2}'`; do ip link set $nic up done @@ -14,12 +16,12 @@ while [ ! -z "$NICSTOBRINGUP" -a $waitforlink -gt 0 ]; do waitforlink=$((waitforlink - 1)) sleep 0.1 if [ $waitforlink = 1 ]; then - echo "No link detected on $NICSTOBRINGUP" + logger -s -t $log_label -p local4.warning "No link detected on $NICSTOBRINGUP after 10 seconds" fi done NICSGETTINGADDR=`ip link|grep mtu|grep -v LOOPBACK|grep -v usb|grep ,LOWER_UP|awk -F: '{print $2}'` timewaiting=0 -echo "Waiting for nics to get addresses" +logger -s -t $log_label -p local4.info "Waiting for nics to get addresses" while [ ! -z "$NICSGETTINGADDR" -a $timewaiting != 700 ]; do NEWNICSGETTINGADDR="" for nic in $NICSGETTINGADDR; do @@ -33,14 +35,14 @@ while [ ! -z "$NICSGETTINGADDR" -a $timewaiting != 700 ]; do sleep 0.1 timewaiting=$((timewaiting+1)) if [ $timewaiting = 699 ]; then - echo "No DHCP answer for $nic, ignoring interface" + logger -s -t $log_label -p local4.warning "No DHCP answer for $nic, ignoring interface..." fi NICSGETTINGADDR=$NEWNICSGETTINGADDR done if [ $timewaiting != 700 -a $timewaiting -gt 450 ]; then - echo "Got an address, but it took inordinately long, you may want to check spanning tree configuration" + logger -s -t $log_label -p local4.warning "Obtained an IP address $NICSGETTINGADDR but it took $timewaiting cycles, you may want to check the spanning tree configuration in the switch." fi -echo "Network configuration complete, commencing transmit of discovery packets" +logger -s -t $log_label -p local4.info "Network configuration complete, commencing transmit of discovery packets" XCATPORT=3001 export XCATPORT for parm in `cat /proc/cmdline`; do @@ -109,6 +111,8 @@ DISKSIZE=`cat /proc/partitions |grep -e "sd.\>" |awk -F' ' '{printf "%s:%.0fGB\n # echo $line > /tmp/cpumod #done #CPUTYPE=`cat /tmp/cpumod|awk -F':' '{print $2}'|sed -e 's/^ //'` + +logger -t $log_label -p local4.info "Beginning echo infomation to discovery packet file..." echo '' > /tmp/discopacket echo "findme" >> /tmp/discopacket echo "$ARCH" >> /tmp/discopacket @@ -238,16 +242,20 @@ cat /tmp/discopacket |while read line; do echo $line >> /tmp/discopacket.new done mv /tmp/discopacket.new /tmp/discopacket - +logger -t $log_label -p local4.info "Discovery packet file is ready." rm -f /tmp/discopacket.gz gzip -9 /tmp/discopacket if [ ! -z "$XCATMASTER" ]; then + logger -t $log_label -p local4.info "Sending the discovery packet to xCAT ($XCATMASTER:$XCATPORT)..." (cat /tmp/discopacket.gz | udpcat.awk $XCATMASTER $XCATPORT ) & fi for dhcps in `grep dhcp-server /var/lib/dhclient/dhclient.leases|awk '{print $4}'|sed -s 's/;//'`; do + logger -t $log_label -p local4.info "Sending the discovery packet to xCAT ($dhcps:$XCATPORT)..." (cat /tmp/discopacket.gz | udpcat.awk $dhcps $XCATPORT ) & done #cat /tmp/discopacket + logger -t $log_label -p local4.info "Sleeping 5 seconds..." sleep 5 done +logger -t $log_label -p local4.info "Restart..." /bin/restart diff --git a/xCAT-genesis-scripts/bin/doxcat b/xCAT-genesis-scripts/bin/doxcat index 0042673b5..3de9edcc6 100755 --- a/xCAT-genesis-scripts/bin/doxcat +++ b/xCAT-genesis-scripts/bin/doxcat @@ -3,6 +3,21 @@ # - Added slash in front of "var" in the NICSTOBRINGUP dhclient section. # Bug reported by Jeff Lang . Thanks, Jeff! # +log_label="xcat.genesis.doxcat" + +# Start rsyslogd and log into a local file specified in /etc/rsyslog.conf +# Later, once xCAT MN is known, dhclient-script will change +# rsyslog.conf file to send log entries to xCAT MN +RSYSLOGD_VERSION=`rsyslogd -v | grep "rsyslogd" | cut -d" " -f2 | cut -d"." -f1` +if [ $RSYSLOGD_VERSION -ge 8 ]; then + /sbin/rsyslogd + # Newer vers of rsyslogd (8 and higher) do not support -c flag anymore +else + /sbin/rsyslogd -c4 +fi + +logger -t $log_label -p local4.info "Beginning doxcat process..." + modprobe acpi_cpufreq 2>/dev/null # on some machines this fails modprobe cpufreq_ondemand if ls /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor &>/dev/null; then @@ -12,14 +27,13 @@ if ls /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor &>/dev/null; then fi if [ ! -z "$BOOTIF" ]; then BOOTIF=`echo $BOOTIF|sed -e s/01-// -e s/-/:/g` - echo -n "Waiting for device with address $BOOTIF to appear.." + logger -s -t $log_label -p local4.info "Waiting for device with address $BOOTIF to appear.." gripeiter=6000 while [ -z "$bootnic" ]; do bootnic=`ip link show|grep -B1 $BOOTIF|grep mtu|awk '{print $2}'|sed -e 's/:$//'` sleep 0.1 if [ $gripeiter = 0 ]; then - echo "ERROR" - echo "Unable to find boot device (maybe the nbroot is missing the driver for your nic?)" + logger -s -t $log_label -p local4.err "Unable to find boot device (maybe the nbroot is missing the driver for your nic?)" while :; do sleep 365d; done fi gripeiter=$((gripeiter-1)) @@ -27,7 +41,7 @@ if [ ! -z "$BOOTIF" ]; then fi echo "Done" if [ -z "$bootnic" ]; then - echo "ERROR: BOOTIF missing, can't detect boot nic" + logger -s -t $log_label -p local4.err "BOOTIF missing, can't detect boot nic" fi if [ -r /sys/devices/virtual/dmi/id/product_uuid ]; then @@ -61,22 +75,14 @@ echo "[ req ] distinguished_name = nodedn [ nodedn ]" > /etc/pki/tls/openssl.cnf -echo -n "Generating private key..." +logger -s -t $log_label -p local4.info "Generating private key..." openssl genrsa -out /etc/xcat/privkey.pem 1024 >& /dev/null -echo "Done" +logger -s -t $log_label -p local4.info "Done" PUBKEY=`openssl rsa -in /etc/xcat/privkey.pem -pubout 2> /dev/null|grep -v "PUBLIC KEY"` PUBKEY=`echo $PUBKEY|sed -e 's/ //g'` export PUBKEY -RSYSLOGD_VERSION=`rsyslogd -v | grep "rsyslogd" | cut -d" " -f2 | cut -d"." -f1` -# Start rsyslogd and log into a local file specified in /etc/rsyslog.conf -# Later, once xCAT MN is known, dhclient-script will change -# rsyslog.conf file to send log entries to xCAT MN -if [ $RSYSLOGD_VERSION -ge 8 ]; then - # Newer vers of rsyslogd (8 and higher) do not support -c flag anymore - /sbin/rsyslogd -else - /sbin/rsyslogd -c4 -fi + +logger -t $log_label -p local4.info "Creating /var/lib/lldpad file..." mkdir -p /var/lib/lldpad echo 'lldp :' >> /var/lib/lldpad/lldpad.conf echo '{' >> /var/lib/lldpad/lldpad.conf @@ -93,6 +99,7 @@ echo '};' >> /var/lib/lldpad/lldpad.conf done echo '};' >> /var/lib/lldpad/lldpad.conf lldpad -d +logger -t $log_label -p local4.info "lldpad started." # Caclulate the broadcast address of a given IP address and mask. bcastcalc(){ @@ -126,7 +133,7 @@ mask2prefix() { 192) let nbits+=2;; 128) let nbits+=1;; 0);; - *) echo "Error: $dec is not recognised"; exit 1 + *) logger -s -t $log_label -p local4.err "$dec is not recognised"; exit 1 esac done IFS=$old_ifs @@ -152,23 +159,25 @@ done export XCATPORT export XCATMASTER +logger -t $log_label -p local4.info "XCATMASTER is $XCATMASTER, XCATPORT is $XCATPORT" + if [[ -n $hostip && -n $netmask && -n $gateway && -n $bootnic ]]; then # doing static ip # the device was determined above from the bootif mac, and put in bootnic numbits=$(mask2prefix $netmask) broadcast=$(bcastcalc $hostip $netmask) - echo "Setting static IP=$hostip/$numbits broadcast=$broadcast gateway=$gateway device=$bootnic BOOTIF=$BOOTIF ..." + logger -s -t $log_label -p local4.info "Setting static IP=$hostip/$numbits broadcast=$broadcast gateway=$gateway device=$bootnic BOOTIF=$BOOTIF ..." ip addr add $hostip/$numbits broadcast $broadcast dev $bootnic scope global label $bootnic ip link set $bootnic up ip route replace to default via $gateway dev $bootnic # in softlayer it takes up to 60 seconds for the nic to actually be able to communicate - echo -n Waiting to reach xCAT mgmt node $gateway. + logger -s -t $log_label -p local4.info "Waiting to reach xCAT mgmt node $gateway." xcatretries=60 while [ $((xcati+=1)) -le $xcatretries ] && ! ping -c2 -w3 $gateway >/dev/null 2>&1; do echo -n .; done if [ $xcati -le $xcatretries ]; then echo " success"; else echo " failed"; fi sleep 3 else - echo "Setting IP via DHCP..." + logger -s -t $log_label -p local4.info "Setting IP via DHCP..." # This section is for System P hardware discovery, which won't have a BOOTIF value set if [ -z "$bootnic" ]; then tries=0 @@ -187,13 +196,14 @@ else tries=$(($tries+1)) done - echo -n "Acquiring network addresses.." + logger -s -t $log_label -p local4.info "Acquiring network addresses.." tries=0 while [ -z "$bootnic" ]; do for tmp1 in $ALLUP_NICS; do if ip addr show dev $tmp1|grep -v 'scope link'|grep -v 'dynamic'|grep -v inet6|grep inet > /dev/null; then result=`ping -c1 -I $tmp1 $XCATMASTER 2>&1` if [ $? -eq 0 ]; then + logger -s -t $log_label -p local4.info "the nic $tmp1 can ping $XCATMASTER" bootnic=$tmp1 break fi @@ -207,6 +217,7 @@ else done if [ -z "$bootnic" ]; then /bin/bash + logger -s -t $log_label -p local4.info "still can not get $bootnic, go into /bin/bash" fi else dhclient -cf /etc/dhclient.conf -pf /var/run/dhclient.$bootnic.pid $bootnic & @@ -222,21 +233,36 @@ else done gripeiter=101 - echo -n "Acquiring network addresses.." + logger -s -t $log_label -p local4.info "Acquiring network addresses.." while ! ip addr show dev $bootnic|grep -v 'scope link'|grep -v 'dynamic'|grep -v inet6|grep inet > /dev/null; do sleep 0.1 if [ $gripeiter = 1 ]; then - echo - echo "It seems to be taking a while to acquire an IPv4 address, you may want to check spanning tree..." + logger -s -t $log_label -p local4.info "It seems to be taking a while to acquire an IPv4 address, you may want to check spanning tree..." fi gripeiter=$((gripeiter-1)) done fi fi +count_f=0 +while [ $count_f -le 8 ]; do + rsyslogd_ps=`ps -ef | grep 'rsyslogd' | grep -v 'grep'` + if [ "$rsyslogd_ps" ]; then + break + else + ((count_f++)) + sleep 0.5 + fi +done + +if [ $count_f -gt 8 ]; then + echo "rsyslogd maybe off" +fi + openssl genrsa -out /etc/xcat/certkey.pem 4096 > /dev/null 2>&1 & -echo -n "Acquired IPv4 address on $bootnic: " +logger -s -t $log_label -p local4.info "Acquired IPv4 address on $bootnic" + ip addr show dev $bootnic|grep -v 'scope link'|grep -v 'dynamic'|grep -v inet6|grep inet|awk '{print $2}' ntpd -g -x # rv 0 state does not work with the new ntp versions @@ -265,70 +291,94 @@ DEVICE=$bootnic export DEVICE if [ "$destiny" != "discover" ]; then #we aren't discoverying, we probably can and should get a cert + logger -t $log_label -p local4.info "Run getcert $XCATMASTER:$XCATPORT..." /bin/getcert $XCATMASTER:$XCATPORT + logger -t $log_label -p local4.info "Getcert done." fi while :; do grepconfigraid=`echo $destiny|grep "configraid"` if [ -z "$destiny" -o -n "$grepconfigraid" ]; then + logger -t $log_label -p local4.info "Run getdestiny $XCATMASTER:$XCATPORT..." destiny=`getdestiny $XCATMASTER:$XCATPORT` + logger -t $log_label -p local4.info "Getdestiny done." fi - destparameter=`echo $destiny|cut -d '=' -f 2-` + destparameter=`echo $destiny|cut -d '=' -f 2-` + logger -t $log_label -p local4.info "The destparameter is $destparameter" + destiny=`echo $destiny|awk -F= '{print $1}'` - dest=`echo $destiny|awk '{print $1}'` #could probably use bash but oh well + logger -t $log_label -p local4.info "The destiny is $destiny" + + dest=`echo $destiny|awk '{print $1}'` #could probably use bash but oh well + logger -t $log_label -p local4.info "The dest is $dest" + if [ "$dest" = "discover" ]; then #skip a query to xCAT when /proc/cmdline will do + logger -t $log_label -p local4.info "Run dodiscovery..." /bin/dodiscovery + logger -t $log_label -p local4.info "Dodiscovery done." + logger -t $log_label -p local4.info "Run getcert $XCATMASTER:$XCATPORT..." /bin/getcert $XCATMASTER:$XCATPORT + logger -t $log_label -p local4.info "Getcert done." destiny='' dest='' elif [ "$dest" = shell ]; then - echo "Dropping to debug shell, exit to run next destiny" + logger -s -t $log_label -p local4.info "Dropping to debug shell(exit to run next destiny)..." destiny='' dest='' /bin/bash - /bin/nextdestiny $XCATMASTER:$XCATPORT + logger -t $log_label -p local4.info "Exit shell." + logger -t $log_label -p local4.info "Run nextdestiny $XCATMASTER:$XCATPORT..." + /bin/nextdestiny $XCATMASTER:$XCATPORT + logger -t $log_label -p local4.info "Nextdestiny done." elif [ "$dest" = runcmd ]; then + logger -t $log_label -p local4.info "Run nextdestiny $XCATMASTER:$XCATPORT..." destiny=`/bin/nextdestiny $XCATMASTER:$XCATPORT` dest=`echo $destiny|awk -F= '{print $1}'` - $destparameter + $destparameter + logger -t $log_label -p local4.info "Nextdestiny done." elif [ "$dest" = runimage ]; then + logger -t $log_label -p local4.info "Run nextdestiny $XCATMASTER:$XCATPORT..." destiny=`/bin/nextdestiny $XCATMASTER:$XCATPORT` dest=`echo $destiny|awk -F= '{print $1}'` + logger -t $log_label -p local4.info "Nextdestiny done." mkdir /tmp/`basename $destparameter` cd /tmp/`basename $destparameter` eval destparameter=$destparameter ERROR=`wget $destparameter 2>&1` rc=$? if [ $rc -ne 0 ]; then - echo "Failed to wget $destparameter" - echo $ERROR + logger -s -t $log_label -p local4.err "Failed to wget $destparameter, $ERROR" fi while [ $rc -ne 0 ] && echo $ERROR|grep -v 416; do sleep 10 ERROR=`wget -c $destparameter 2>&1` rc=$? if [ $rc -ne 0 ]; then - echo "Failed to wget $destparameter" - echo $ERROR + logger -s -t $log_label -p local4.err "Failed to wget $destparameter, $ERROR" fi done tar xvf `basename $destparameter` ./runme.sh cd - elif [ "$dest" = "reboot" -o "$dest" = "boot" ]; then + logger -t $log_label -p local4.info "Run nextdestiny $XCATMASTER:$XCATPORT..." /bin/nextdestiny $XCATMASTER:$XCATPORT - if [ $IPMI_SUPPORT -ne 0 ]; then + logger -t $log_label -p local4.info "Nextdestiny done." + if [ $IPMI_SUPPORT -ne 0 ]; then ipmitool chassis bootdev pxe - fi + fi reboot -f elif [ "$dest" = "install" -o "$dest" = "netboot" ]; then - if [ $IPMI_SUPPORT -ne 0 ]; then + if [ $IPMI_SUPPORT -ne 0 ]; then ipmitool chassis bootdev pxe - fi + fi + logger -t $log_label -p local4.info "Reboot..." reboot -f elif [ "$dest" = sysclone ]; then + logger -t $log_label -p local4.info "Run dosysclone..." /bin/dosysclone + logger -t $log_label -p local4.info "Dosysclone done." destiny='' dest='' elif [ "$dest" = standby ]; then @@ -336,24 +386,27 @@ while :; do dest='' delay=$((30+$RANDOM%270)) while [ $delay -gt 0 ]; do - echo -en "Received request to retry in a bit, will call xCAT back in $delay seconds \r" + logger -s -t $log_label -p local4.info "Received request to retry in a bit, will call xCAT back in $delay seconds" delay=$((delay-1)) sleep 1 done echo "Retrying "; elif [ "$dest" = shutdown ]; then + logger -t $log_label -p local4.info "Poweroff..." poweroff -f else - echo "Unrecognized directive $dest" + logger -s -t $log_label -p local4.err "Unrecognized directive $dest" destiny='' dest='' delay=$((30+$RANDOM%270)) while [ $delay -gt 0 ]; do - echo -en "Will retry in $delay seconds \r" + logger -s -t $log_label -p local4.info "Will retry in $delay seconds" delay=$((delay-1)) sleep 1 done fi done + +logger -t $log_label -p local4.info "doxcat is done" set +x From 98caf993bf4515fef5f43f0965e34c7027a2fd4e Mon Sep 17 00:00:00 2001 From: zet809 Date: Wed, 1 Jun 2016 11:40:10 +0800 Subject: [PATCH 053/310] Fix MacMap.pm syntax issue The issue is not using '%' when getting keys for a hash variable. --- perl-xCAT/xCAT/MacMap.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/MacMap.pm b/perl-xCAT/xCAT/MacMap.pm index 21bb9508c..74c6b8afc 100644 --- a/perl-xCAT/xCAT/MacMap.pm +++ b/perl-xCAT/xCAT/MacMap.pm @@ -303,7 +303,7 @@ sub dump_mac_info { xCAT::MsgUtils->message("S","xCAT Table error:".$entry->{node}."Has missing or invalid switch.switch and/or switch.port fields"); } } - foreach my $switch (keys $self->{switchparmhash}) { + foreach my $switch (keys %{$self->{switchparmhash}}) { if ($dump_all_switches or defined($switches_to_dump{$switch})) { if ($self->{show_verbose_info}) { xCAT::MsgUtils->message("I",{data=>["$switch: Start to get information"]}, $self->{callback}); From ba68ad19483c0cc6aa1eb25ec48ec17bb8085bab Mon Sep 17 00:00:00 2001 From: chenglch Date: Wed, 1 Jun 2016 01:46:03 -0400 Subject: [PATCH 054/310] Change sleep time from 0.1 to 1 as float value is not support by default --- xCAT-server/lib/xcat/plugins/AAsn.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/AAsn.pm b/xCAT-server/lib/xcat/plugins/AAsn.pm index 49523111e..5d4a73ca5 100755 --- a/xCAT-server/lib/xcat/plugins/AAsn.pm +++ b/xCAT-server/lib/xcat/plugins/AAsn.pm @@ -1429,11 +1429,11 @@ sub enable_TFTPhpa foreach my $pid (keys %pids_map) { if (xCAT::Utils->is_process_exists($pid)) { $count++; - if($count >= 50) { - xCAT::MsgUtils->message("S","Error: can not stop tftp process in 5 seconds."); + if($count > 5) { + xCAT::MsgUtils->message("S","ERROR: Can not stop tftp process in 5 seconds."); return 1; } - sleep 0.1; + sleep 1; } else { delete $pids_map{$pid} } From d9519b6bd38117ec050892377df9209033e8e65f Mon Sep 17 00:00:00 2001 From: wangxiaopeng Date: Wed, 1 Jun 2016 03:14:51 -0400 Subject: [PATCH 055/310] issue 1137: waiting longer for stopping xcatd when the system load of xCAT MN is heavy --- xCAT-server/etc/init.d/xcatd | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/xCAT-server/etc/init.d/xcatd b/xCAT-server/etc/init.d/xcatd index c9b2ef45c..1334c0ac2 100755 --- a/xCAT-server/etc/init.d/xcatd +++ b/xCAT-server/etc/init.d/xcatd @@ -103,15 +103,21 @@ stop) fi kill -TERM -`cat /var/run/xcatd.pid` i=0; - while $STATUS > /dev/null 2>&1 && [ $i -lt 15 ]; do + while $STATUS > /dev/null 2>&1 && [ $i -lt 30 ]; do sleep .1 i=$((i+1)) done $STATUS > /dev/null 2>&1 + if [ "$?" = "0" ]; then kill -KILL -`cat /var/run/xcatd.pid` + i=0 + while $STATUS > /dev/null 2>&1 && [ $i -lt 30 ]; do + sleep .1 + i=$((i+1)) + done fi - sleep .1 + $STATUS > /dev/null 2>&1 if [ "$?" = "0" ]; then $LOG_FAILURE From d6c731935c4d69c5699b071ecd8acfad3b860192 Mon Sep 17 00:00:00 2001 From: "litingt@cn.ibm.com" Date: Wed, 1 Jun 2016 04:42:08 -0400 Subject: [PATCH 056/310] add statelite image definition creation and remove in each independent case --- xCAT-test/autotest/testcase/lslite/cases0 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xCAT-test/autotest/testcase/lslite/cases0 b/xCAT-test/autotest/testcase/lslite/cases0 index c334c0fe1..7c6461b5a 100644 --- a/xCAT-test/autotest/testcase/lslite/cases0 +++ b/xCAT-test/autotest/testcase/lslite/cases0 @@ -1,6 +1,8 @@ start:lslite_i description:lslite -i os:Linux +cmd:mkdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -u profile=compute provmethod=statelite osvers=__GETNODEATTR($$CN,os)__ +check:rc==0 cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute check:rc==0 cmd:chtab litefile.image="ALL" litefile.file="/xcatpost" litefile.options="tmpfs" @@ -15,12 +17,16 @@ check:output=~/xcatpost check:output=~/etc/mtab check:output!~Error cmd:chtab -d file="/xcatpost" litefile +cmd:rmdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute +check:rc==0 end start:lslite_noderange description:lslite noderange os:Linux +cmd:mkdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -u profile=compute provmethod=statelite osvers=__GETNODEATTR($$CN,os)__ +check:rc==0 cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute check:rc==0 cmd:chtab litefile.image="ALL" litefile.file="/xcatpost" litefile.options="tmpfs" @@ -36,6 +42,8 @@ check:output!~Error cmd:chtab -d file="/xcatpost" litefile cmd:chtab -d node=$$CN statelite cmd:chtab -d priority=2 litetree +cmd:rmdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute +check:rc==0 end From 8ea1c26113c9ccf51ec0575b629ed14979897204 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Wed, 1 Jun 2016 09:56:32 -0400 Subject: [PATCH 057/310] Fix doc_guidelines.rst based on pull request review --- docs/source/developers/guides/docs/doc_guidelines.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/developers/guides/docs/doc_guidelines.rst b/docs/source/developers/guides/docs/doc_guidelines.rst index c42f5abb5..3fe458d0c 100644 --- a/docs/source/developers/guides/docs/doc_guidelines.rst +++ b/docs/source/developers/guides/docs/doc_guidelines.rst @@ -70,15 +70,15 @@ To add contents of a document file inside another file, use ``.. include::``. Th .. include:: config_common.rst -.. - ``Note:`` Do not put customized link targets, such as ``.. _my_link_taget:`` inside the file to be included. If you do, a warning for a duplicate label will be displayed during the documentation build process. +``Note:`` Do not put customized link targets, such as ``.. _my_link_taget:`` inside the file to be included. If you do, a warning for a duplicate label will be displayed during the documentation build process. Index file --------------------- +---------- + Index.rst files contain the ``.. toctree::`` tag. Files listed under that tag will have links to them displayed in the left side navigation area. If a documentation file does not wish to be accessbile from the navigation area, do not list it under the ``.. toctree::``. - ``Note:`` If a file is not listed under the ``.. toctree::`` it might generate a warning during the documentation build ``WARNING: document isn't included in any toctree``. To eliminate such warning, add the file to the ``exclude_patterns`` list in the ``docs/source/conf.py`` file. However, do not add a file to the ``exclude_patterns`` list if it contains a customized link target, such as ``.. _my_link_taget:``. This link target will not be visible to other files and a ``WARNING: undefined label:`` will be displayed during the documentation build. +``Note:`` If a file is not listed under the ``.. toctree::`` it might generate a warning during the documentation build ``WARNING: document isn't included in any toctree``. To eliminate such warning, add the file to the ``exclude_patterns`` list in the ``docs/source/conf.py`` file. However, do not add a file to the ``exclude_patterns`` list if it contains a customized link target, such as ``.. _my_link_taget:``. This link target will not be visible to other files and a ``WARNING: undefined label:`` will be displayed during the documentation build. Hyperlinks -> Internal Links -> External Links ---------------------------------------------- From 2eb474afecece4ae688412290a3aebb19b1bc6d0 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Wed, 1 Jun 2016 14:53:07 -0400 Subject: [PATCH 058/310] Discard grep output and display error message --- xCAT/postscripts/remoteshell | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/xCAT/postscripts/remoteshell b/xCAT/postscripts/remoteshell index 1a6e3cf4e..82a3f6fab 100755 --- a/xCAT/postscripts/remoteshell +++ b/xCAT/postscripts/remoteshell @@ -108,7 +108,7 @@ fi getcredentials.awk ssh_dsa_hostkey | grep -E -v '|' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /tmp/ssh_dsa_hostkey #check the message is an error or not -grep -E '' /tmp/ssh_dsa_hostkey +grep -E '' /tmp/ssh_dsa_hostkey > /dev/null 2>&1 if [ $? -ne 0 ]; then #the message received is the data cat /tmp/ssh_dsa_hostkey | grep -E -v '|/{0,1}data>||' >/etc/ssh/ssh_host_dsa_key @@ -154,7 +154,7 @@ if [ $? -ne 0 ]; then else #the message received is an error, so parse it ERR_MSG=`sed -n 's%.*\(.*\).*%\1%p' /tmp/ssh_dsa_hostkey` - logger -t xcat -p local4.err Error: $ERR_MSG + logger -s -t xcat -p local4.err Error: $ERR_MSG fi rm /tmp/ssh_dsa_hostkey @@ -174,7 +174,7 @@ fi getcredentials.awk ssh_rsa_hostkey | grep -E -v '|' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /tmp/ssh_rsa_hostkey #check whether the message is an error or not -grep -E '' /tmp/ssh_rsa_hostkey +grep -E '' /tmp/ssh_rsa_hostkey > /dev/null 2>&1 if [ $? -ne 0 ]; then #the message received is the data we request cat /tmp/ssh_rsa_hostkey | grep -E -v '|/{0,1}data>||' >/etc/ssh/ssh_host_rsa_key @@ -220,7 +220,7 @@ if [ $? -ne 0 ]; then else #This is an error message ERR_MSG=`sed -n 's%.*\(.*\).*%\1%p' /tmp/ssh_rsa_hostkey` - logger -t xcat -p local4.err Error: $ERR_MSG + logger -s -t xcat -p local4.err Error: $ERR_MSG fi rm /tmp/ssh_rsa_hostkey @@ -242,7 +242,7 @@ if ssh-keygen -t ecdsa -f /tmp/ecdsa_key -P "" &>/dev/null ; then getcredentials.awk ssh_ecdsa_hostkey | grep -E -v '|' | sed -e 's/<//' -e 's/&/&/' -e 's/"/"/' -e "s/'/'/" > /tmp/ssh_ecdsa_hostkey #check whether the message is an error or not - grep -E '' /tmp/ssh_ecdsa_hostkey + grep -E '' /tmp/ssh_ecdsa_hostkey > /dev/null 2>&1 if [ $? -ne 0 ]; then #the message received is the data we request cat /tmp/ssh_ecdsa_hostkey | grep -E -v '|/{0,1}data>||' >/etc/ssh/ssh_host_ecdsa_key @@ -296,7 +296,7 @@ if ssh-keygen -t ecdsa -f /tmp/ecdsa_key -P "" &>/dev/null ; then else #This is an error message ERR_MSG=`sed -n 's%.*\(.*\).*%\1%p' /tmp/ssh_ecdsa_hostkey` - logger -t xcat -p local4.err Error: $ERR_MSG + logger -s -t xcat -p local4.err Error: $ERR_MSG fi rm /tmp/ssh_ecdsa_hostkey fi From 41c1938b8c0f2eae0218913c1a8d7848999b0861 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Wed, 1 Jun 2016 17:00:25 -0400 Subject: [PATCH 059/310] Use arp command to get switch mac address --- perl-xCAT/xCAT/Utils.pm | 32 +++++++++++++++++++ .../lib/xcat/plugins/switchdiscover.pm | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index f49fb3253..f92a9f1c2 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -4711,5 +4711,37 @@ sub get_nmapversion { return $nmap_version; } +#-------------------------------------------------------------------------------- +=head3 get_macbyarp + Get Mac address by arp -n + Returns: + mac: Mac address +=cut +#-------------------------------------------------------------------------------- + +sub get_macbyarp { + my $arptable; + my $mac; + my $ip = shift; + if ($ip =~ /xCAT::Utils/) + { + $ip = shift; + } + if ( -x "/usr/sbin/arp") { + $arptable = `/usr/sbin/arp -n`; + } + else{ + $arptable = `/sbin/arp -n`; + } + my @arpents = split /\n/,$arptable; + foreach (@arpents) { + if (m/^($ip)\s+\S+\s+(\S+)\s/) { + $mac=$2; + last; + } + } + + return $mac; +} 1; diff --git a/xCAT-server/lib/xcat/plugins/switchdiscover.pm b/xCAT-server/lib/xcat/plugins/switchdiscover.pm index 344997d2b..ae7a70827 100644 --- a/xCAT-server/lib/xcat/plugins/switchdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/switchdiscover.pm @@ -867,7 +867,7 @@ sub snmp_scan { my $vendor = get_snmpvendorinfo($request, $ip); if ($vendor) { - my $mac = get_snmpmac($request, $ip); + my $mac = xCAT::Utils->get_macbyarp($ip); if (!$mac) { $mac="nomac_nmap_$counter"; $counter++; From 4b138d269759e53790b729259fe47adbeb02c517 Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Thu, 2 Jun 2016 22:48:44 -0400 Subject: [PATCH 060/310] updated --- xCAT-test/autotest/testcase/switchdiscover/cases0 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-test/autotest/testcase/switchdiscover/cases0 b/xCAT-test/autotest/testcase/switchdiscover/cases0 index b51d90cd9..16c60d0b0 100644 --- a/xCAT-test/autotest/testcase/switchdiscover/cases0 +++ b/xCAT-test/autotest/testcase/switchdiscover/cases0 @@ -32,7 +32,7 @@ cmd:switchdiscover --range $$range -r check:rc==0 check:output=~Discovering switches using nmap check:output=~xml -check:output=~/usr/bin/nmap -sP -oX - $$range +check:output=~/usr/bin/nmap -sn -oX - $$range end start:switchdiscover_range_x cmd:switchdiscover --range $$range -x @@ -53,7 +53,7 @@ cmd:switchdiscover --range $$range -z -V check:rc==0 check:output=~Discovering switches using nmap check:output=~xml -check:output=~Process command: /usr/bin/nmap -sP -oX - $$range +check:output=~Process command: /usr/bin/nmap -sn -oX - $$range check:output=~nodetype=switch check:output=~groups=switch end From e6b64be7aeaab24b69554eea69d26ab9fabdbe71 Mon Sep 17 00:00:00 2001 From: immarvin Date: Fri, 27 May 2016 05:00:27 -0400 Subject: [PATCH 061/310] support mkdef --template;support lsdef --template --- xCAT-server/lib/xcat/plugins/DBobjectdefs.pm | 338 +++++++++++++------ 1 file changed, 237 insertions(+), 101 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm index 40285f360..78b771b79 100755 --- a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm +++ b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm @@ -20,6 +20,7 @@ use Getopt::Long; use xCAT::MsgUtils; use xCAT::Utils; use xCAT::SvrUtils; +use File::Find; use strict; # options can be bundled up like -vV @@ -456,7 +457,7 @@ sub processArgs undef $::opt_osimg; undef $::opt_nics; undef $::opt_setattr; - + undef $::opt_template; # parse the options - include any option from all 4 cmds Getopt::Long::Configure("no_pass_through"); @@ -485,6 +486,7 @@ sub processArgs 'osimage' => \$::opt_osimg, 'nics' => \$::opt_nics, 'u' => \$::opt_setattr, + 'template:s' => \$::opt_template, ) ) { @@ -602,6 +604,55 @@ sub processArgs return 2; } + + if($::opt_template){ + if($::opt_template =~ /,/ and $::command eq "mkdef"){ + my $rsp; + $rsp->{data}->[0] = "mkdef: multiple templates specified!"; + xCAT::MsgUtils->message("E", $rsp, $::callback); + return 2; + } + } + + + if (defined $::opt_template and ($::command eq "mkdef" or $::command eq "lsdef")){ + my $objtmpldir="$::XCATROOT/share/xcat/templates/objects/"; + + my @tmpldirlist; + if($::command eq "lsdef"){ + if (!$::opt_a){ + if($::opt_t){ + my @tmpltypelist=split(",",$::opt_t); + foreach my $objtype (@tmpltypelist){ + push(@tmpldirlist,$objtmpldir.$objtype); + } + } + }else{ + push(@tmpldirlist,$objtmpldir); + } + }elsif($::command eq "mkdef"){ + if($::opt_t){ + push(@tmpldirlist,$objtmpldir.$::opt_t); + }else{ + push(@tmpldirlist,$objtmpldir."node"); + } + } + my $objfiledata; + find(\&wanted,@tmpldirlist); + sub wanted{ + if (-f $_){ + my $line; + open(FH,$_); + while($line=){ + $objfiledata.=$line; + } + close(FH) + } + } + + $::filedata=$objfiledata; + } + # can get object names in many ways - easier to keep track $::objectsfrom_args = 0; $::objectsfrom_opto = 0; @@ -768,10 +819,39 @@ sub processArgs return 1; } - # - %::FILEATTRS{fileobjname}{attr}=val - # set @::fileobjtypes, @::fileobjnames, %::FILEATTRS + if($::opt_template){ + my %tmpfileattr; + my @tmpfileobjtypes; + my @tmpfileobjnames; + my @tmplobjlist=split(",",$::opt_template); + foreach my $key (@tmplobjlist){ + if(exists $::FILEATTRS{$key}){ + $tmpfileattr{$key}=\%{$::FILEATTRS{$key}}; + push(@tmpfileobjnames,$key); + push(@tmpfileobjtypes,$tmpfileattr{$key}{objtype}); + }else{ + delete $::FILEATTRS{$key}; + my $rsp; + $rsp->{data}->[0] = "Could not find $key in xCAT templates, checking whether it is an existing object definition... "; + xCAT::MsgUtils->message("I", $rsp, $::callback); + } + } + + if(@tmpfileobjnames){ + %::FILEATTRS=%tmpfileattr; + @::fileobjtypes=@tmpfileobjtypes; + @::fileobjnames=@tmpfileobjnames; + $::objectsfrom_file = 1; + }else{ + @::fileobjtypes=(); + @::fileobjnames=(); + } + }else{ + # - %::FILEATTRS{fileobjname}{attr}=val + # set @::fileobjtypes, @::fileobjnames, %::FILEATTRS - $::objectsfrom_file = 1; + $::objectsfrom_file = 1; + } } # @@ -830,11 +910,11 @@ sub processArgs # must have object type(s) - default if not provided - if (!@::clobjtypes && !@::fileobjtypes && !$::opt_a && !$::opt_t) + if (!@::clobjtypes && (!@::fileobjtypes || (@::fileobjtypes && defined $::opt_template)) && !$::opt_a && !$::opt_t) { - # make the default type = 'node' if not specified push(@::clobjtypes, 'node'); + my $rsp; if ( !$::opt_z && !$::opt_x) { # don't want this msg in stanza or xml output @@ -1074,7 +1154,7 @@ sub processArgs # can't have -a with other obj sources if ($::opt_a - && ($::opt_o || $::filedata || @::noderange)) + && ($::opt_o || ($::filedata && ! defined $::opt_template ) || @::noderange)) { my $rsp; @@ -1087,31 +1167,38 @@ sub processArgs if ($::opt_a) { - my @tmplist; - - # for every type of data object get the list of defined objects - foreach my $t (keys %{xCAT::Schema::defspec}) - { - # exclude the auditlog and eventlog, - # the auditlog and eventlog tables might be very big - # use lsdef -t auditlog or lsdef -t eventlog instead - if (($t eq 'auditlog') || ($t eq 'eventlog')) { next; } - - $::objectsfrom_opta = 1; - + if(!defined $::opt_template){ my @tmplist; - @tmplist = xCAT::DBobjUtils->getObjectsOfType($t); - # add objname and type to hash and global list - if (scalar(@tmplist) > 0) + # for every type of data object get the list of defined objects + foreach my $t (keys %{xCAT::Schema::defspec}) { - foreach my $o (@tmplist) + # exclude the auditlog and eventlog, + # the auditlog and eventlog tables might be very big + # use lsdef -t auditlog or lsdef -t eventlog instead + if (($t eq 'auditlog') || ($t eq 'eventlog')) { next; } + + $::objectsfrom_opta = 1; + + my @tmplist; + @tmplist = xCAT::DBobjUtils->getObjectsOfType($t); + + # add objname and type to hash and global list + if (scalar(@tmplist) > 0) { - push(@::clobjnames, $o); - $::AllObjTypeHash{$o} = $t; + foreach my $o (@tmplist) + { + push(@::clobjnames, $o); + $::AllObjTypeHash{$o} = $t; + } } } } + else{ + foreach my $fileobj (@::fileobjnames){ + $::AllObjTypeHash{$fileobj}=$::FILEATTRS{$fileobj}{objtype}; + } + } } # must have object name(s) - @@ -1125,7 +1212,7 @@ sub processArgs # combine object name all object names provided @::allobjnames = @::clobjnames; - if (scalar(@::fileobjnames) > 0) + if (scalar(@::fileobjnames) > 0 && !defined($::opt_template)) { # add list from stanza or xml file push @::allobjnames, @::fileobjnames; @@ -1170,6 +1257,53 @@ sub processArgs } } + if ($::opt_template && ($::command eq 'mkdef') ) + { + unless($::objectsfrom_file){ + my @myobjlist = xCAT::DBobjUtils->getObjectsOfType($::clobjtypes[0]); + unless (@myobjlist) + { + my $rsp; + $rsp->{data}->[0] = "Could not get objects of type \'$::clobjtypes[0]\'."; + xCAT::MsgUtils->message("E", $rsp, $::callback); + return 3; + } + + unless(grep(/^$::opt_template$/,@myobjlist)){ + my $rsp; + $rsp->{data}->[0] = "Could not find the template object named \'$::opt_template\' of type \'$::clobjtypes[0]\'."; + xCAT::MsgUtils->message("E", $rsp, $::callback); + return 3; + } + + if(grep(/^$::opt_template$/,@::allobjnames)){ + my $rsp; + $rsp->{data}->[0] = "The template node cannot be the same as the node to create."; + xCAT::MsgUtils->message("E", $rsp, $::callback); + return 1; + } + + my %objtypehash; + $objtypehash{$::opt_template} = $::clobjtypes[0]; + $::ATTRLIST="all"; + my %objattrhash = xCAT::DBobjUtils->getobjdefs(\%objtypehash); + foreach my $key(keys %{$objattrhash{$::opt_template}}){ + if($key ne "objtype" and not $::ATTRS{$key}){ + $::ATTRS{$key}=$objattrhash{$::opt_template}{$key}; + } + } + }else{ + foreach my $key(keys %{$::FILEATTRS{$::opt_template}}){ + if($key ne "objtype" and not $::ATTRS{$key}){ + $::ATTRS{$key}=$::FILEATTRS{$::opt_template}{$key}; + } + } + delete $::FILEATTRS{$::opt_template}; + @::fileobjtypes=(); + @::fileobjnames=(); + } + } + # check for the -i option if ($::opt_i && ($::command ne 'lsdef')) { @@ -2789,7 +2923,6 @@ sub defls # process the command line my $rc = &processArgs; - if ($rc != 0) { @@ -2810,7 +2943,7 @@ sub defls # do we want just the object names or all the attr=val - if ($::opt_l || @::noderange || $::opt_o || $::opt_i) + if ($::opt_l || @::noderange || $::opt_o || $::opt_i || $::opt_template) { # assume we want the the details - not just the names @@ -2861,6 +2994,26 @@ sub defls @neededattrs = (@neededattrs, @whereattrs); } } + + if (defined $::opt_template){ + + unless ($::opt_template){ + %myhash=%::FILEATTRS; + }else{ + my @templatelist=split(",",$::opt_template); + foreach my $mytemplate (@templatelist){ + if(exists $::FILEATTRS{$mytemplate}){ + $myhash{$mytemplate}= \%{$::FILEATTRS{$mytemplate}}; + }else{ + my $rsp; + $rsp->{data}->[0] = "Could not find the specified $::opt_t template $mytemplate."; + xCAT::MsgUtils->message("I", $rsp, $::callback); + return 1; + } + } + } + } + if ($::objectsfrom_opto || $::objectsfrom_nr || $::objectsfrom_args) { @@ -2883,11 +3036,11 @@ sub defls return 1; } - } + # if just provided type list then find all objects of these types - if ($::objectsfrom_optt) + if ( ! defined $::opt_template && $::objectsfrom_optt) { %objhash = %::ObjTypeHash; @@ -2901,65 +3054,70 @@ sub defls } } + # if specify all if ($::opt_a) { - - # could be modified by type - if ($::opt_t) - { - - # get all objects matching type list - # Get all object in this type list - foreach my $t (@::clobjtypes) + if(! defined $::opt_template){ + # could be modified by type + if ($::opt_t) { - my @tmplist = xCAT::DBobjUtils->getObjectsOfType($t); - if (scalar(@tmplist) > 1) + # get all objects matching type list + # Get all object in this type list + foreach my $t (@::clobjtypes) { - foreach my $obj (@tmplist) - { + my @tmplist = xCAT::DBobjUtils->getObjectsOfType($t); - $objhash{$obj} = $t; + if (scalar(@tmplist) > 1) + { + foreach my $obj (@tmplist) + { + + $objhash{$obj} = $t; + } + } + else + { + my $rsp; + $rsp->{data}->[0] = "Could not get objects of type \'$t\'."; + xCAT::MsgUtils->message("I", $rsp, $::callback); } } - else + + %myhash = xCAT::DBobjUtils->getobjdefs(\%objhash); + if (!(%myhash)) { my $rsp; - $rsp->{data}->[0] = "Could not get objects of type \'$t\'."; - xCAT::MsgUtils->message("I", $rsp, $::callback); + $rsp->{data}->[0] = "Could not get xCAT object definitions."; + xCAT::MsgUtils->message("E", $rsp, $::callback); + return 1; } - } - %myhash = xCAT::DBobjUtils->getobjdefs(\%objhash); - if (!(%myhash)) + } + else { - my $rsp; - $rsp->{data}->[0] = "Could not get xCAT object definitions."; - xCAT::MsgUtils->message("E", $rsp, $::callback); - return 1; + + %myhash = xCAT::DBobjUtils->getobjdefs(\%::AllObjTypeHash, $::VERBOSE); + if (!(%myhash)) + { + my $rsp; + $rsp->{data}->[0] = "Could not get xCAT object definitions."; + xCAT::MsgUtils->message("E", $rsp, $::callback); + return 1; + } + } - - } - else - { - - %myhash = xCAT::DBobjUtils->getobjdefs(\%::AllObjTypeHash, $::VERBOSE); - if (!(%myhash)) + foreach my $t (keys %{xCAT::Schema::defspec}) { - my $rsp; - $rsp->{data}->[0] = "Could not get xCAT object definitions."; - xCAT::MsgUtils->message("E", $rsp, $::callback); - return 1; + push(@::clobjtypes, $t); } - - } - foreach my $t (keys %{xCAT::Schema::defspec}) - { - push(@::clobjtypes, $t); + }elsif( defined $::opt_template){ + push @::clobjtypes, keys { map { $_ => 1 } @::fileobjtypes }; } } # end - if specify all + if (!(%myhash)) { my $rsp; @@ -2968,7 +3126,6 @@ sub defls return 0; } - # need a special case for the node postscripts attribute, # The 'xcatdefaults' postscript should be added to the postscripts and postbootscripts attribute my $getnodes = 0; @@ -2982,6 +3139,8 @@ sub defls } } } + + my %nodeosimagehash = (); if ($getnodes) { @@ -3172,6 +3331,8 @@ sub defls } } + + # Get osimage definition info in one invocation if(scalar(keys %imglist) > 0) { @@ -3208,6 +3369,7 @@ sub defls } } } + my $xcatdefaultsps; my $xcatdefaultspbs; my @TableRowArray = xCAT::DBobjUtils->getDBtable('postscripts'); @@ -3223,6 +3385,7 @@ sub defls } } } + foreach my $obj (keys %myhash) { if ($myhash{$obj}{objtype} eq 'node') @@ -3260,6 +3423,7 @@ sub defls } } + # the list of objects may be limited by the "-w" option # see which objects have attr/val that match the where values # - if provided @@ -3284,9 +3448,11 @@ sub defls push (@{$rsp_info->{data}}, "# "); } + # group the objects by type to make the output easier to read my $numobjects = 0; # keep track of how many object we want to display # for each type + foreach my $type (@::clobjtypes) { # Check if -i specifies valid attributes @@ -3302,6 +3468,7 @@ sub defls } } + my %defhash; foreach my $obj (keys %myhash) @@ -3337,12 +3504,6 @@ sub defls } if (!defined($::opt_S) ) { - #my $tmp1=$listtab->getAllEntries("all"); - #if (defined($tmp1) && (@$tmp1 > 0)) { - # foreach(@$tmp1) { - # $newhash{$_->{node}} = 1; - # } - #} my @def_nodes = keys %defhash; my $hidden_nodes = $listtab->getNodesAttribs(\@def_nodes, ['hidden']); foreach my $n (keys %{$hidden_nodes}) { @@ -3645,31 +3806,6 @@ sub defls } # end - for each object } # end - for each type - #delete the fsp and bpa node from the hash - #my $newrsp; - #my $listtab = xCAT::Table->new( 'nodelist' ); - #if ($listtab and (!defined($::opt_S)) ) { - # foreach my $n (@{$rsp_info->{data}}) { - # if ( $n =~ /\(node\)/ ) { - # $_= $n; - # s/ +\(node\)//; - # my ($hidhash) = $listtab->getNodeAttribs($_ ,['hidden']); - # if ( $hidhash->{hidden} ne 1) { - # push (@{$newrsp->{data}}, $n); - # } - # }else{ - # push (@{$newrsp->{data}}, $n); - # } - # } - # if (defined($newrsp->{data}) && scalar(@{$newrsp->{data}}) > 0) { - # xCAT::MsgUtils->message("I", $newrsp, $::callback); - # return 0; - # } - #}else { - # my $rsp; - # $rsp->{data}->[0] = "Could not open nodelist table."; - # xCAT::MsgUtils->message("I", $rsp, $::callback); - #} # Display the definition of objects if (defined($rsp_info->{data}) && scalar(@{$rsp_info->{data}}) > 0) { From 6b96496d1bf2e9447f6b686b6e0ad85629945d27 Mon Sep 17 00:00:00 2001 From: wangxiaopeng Date: Fri, 3 Jun 2016 04:16:07 -0400 Subject: [PATCH 062/310] issue 1233: try to rekill tftp and add more debug info when failed to kill tftpd --- xCAT-server/lib/xcat/plugins/AAsn.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/AAsn.pm b/xCAT-server/lib/xcat/plugins/AAsn.pm index 5d4a73ca5..fa351187f 100755 --- a/xCAT-server/lib/xcat/plugins/AAsn.pm +++ b/xCAT-server/lib/xcat/plugins/AAsn.pm @@ -1429,8 +1429,13 @@ sub enable_TFTPhpa foreach my $pid (keys %pids_map) { if (xCAT::Utils->is_process_exists($pid)) { $count++; - if($count > 5) { - xCAT::MsgUtils->message("S","ERROR: Can not stop tftp process in 5 seconds."); + if($count == 5) { + my $tftpinfo = `ps axf|grep -v grep|grep in.tftpd`; + xCAT::MsgUtils->message("S","ERROR: Can not stop tftp process $pid [$tftpinfo] in 5 seconds, stop it again."); + system("killall -s KILL in.tftpd"); + } + if($count > 10) { + xCAT::MsgUtils->message("S","ERROR: Can not stop tftp process in 10 seconds."); return 1; } sleep 1; From 9763caa751357dc86412dd9809abfbc3cf8da1ac Mon Sep 17 00:00:00 2001 From: junxiawang Date: Fri, 3 Jun 2016 06:59:23 -0400 Subject: [PATCH 063/310] modify statelite image --- xCAT-test/autotest/testcase/genimage/cases0 | 4 ++++ .../installation/reg_linux_statelite_installation_flat | 6 +++++- .../installation/reg_linux_statelite_installation_hierarchy | 5 ++++- .../reg_linux_statelite_installation_hierarchy_by_nfs | 5 ++++- .../reg_linux_statelite_installation_hierarchy_by_ramdisk | 5 ++++- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/xCAT-test/autotest/testcase/genimage/cases0 b/xCAT-test/autotest/testcase/genimage/cases0 index 3ca9433a1..ff4c2a804 100644 --- a/xCAT-test/autotest/testcase/genimage/cases0 +++ b/xCAT-test/autotest/testcase/genimage/cases0 @@ -28,10 +28,14 @@ start:genimage_statelite os:Linux cmd:copycds $$ISO check:rc==0 +cmd:mkdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -u profile=compute provmethod=statelite osvers=__GETNODEATTR($$CN,os)__ +check:rc==0 cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.bak;fi cmd:XCATBYPASS=1 genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute check:rc==0 cmd:XCATBYPASS=1 ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg check:rc==0 cmd:mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg +cmd:rmdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute +check:rc==0 end diff --git a/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_flat b/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_flat index 780d32e3b..3605fd021 100644 --- a/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_flat +++ b/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_flat @@ -19,6 +19,9 @@ check:rc==0 cmd:copycds $$ISO check:rc==0 +cmd:mkdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -u profile=compute provmethod=statelite osvers=__GETNODEATTR($$CN,os)__ +check:rc==0 + cmd:if cat /etc/*release |grep SUSE >/dev/null; then cp /opt/xcat/share/xcat/tools/autotest/testcase/installation/litefile_sles.csv /tmp/litefile.csv;tabrestore /tmp/litefile.csv; elif cat /etc/*release |grep "Red Hat" >/dev/null; then tabrestore /opt/xcat/share/xcat/tools/autotest/testcase/installation/litefile.csv;fi check:rc==0 cmd:tabdump litefile @@ -123,5 +126,6 @@ check:output=~64 bytes from $$CN cmd:rootimgdir=`lsdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute|grep rootimgdir|awk -F'=' '{print $2}'`; if [ -d $rootimgdir.regbak ]; then rm -rf $rootimgdir; mv $rootimgdir.regbak $rootimgdir; fi check:rc==0 - +cmd:rmdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute +check:rc==0 end diff --git a/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy b/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy index f9de59ccd..6ffbfddd4 100644 --- a/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy +++ b/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy @@ -23,7 +23,8 @@ check:rc==0 cmd:copycds $$ISO check:rc==0 - +cmd:mkdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -u profile=compute provmethod=statelite osvers=__GETNODEATTR($$CN,os)__ +check:rc==0 cmd:xdsh $$SN df|grep /install;if [ $? -eq 0 ] ;then xdsh $$SN umount /install;fi check:rc==0 cmd:xdsh $$SN 'cat /etc/exports|grep install; if [ "$?" -ne "0" ]; then echo "/install *(rw,no_root_squash,sync,no_subtree_check)" >> /etc/exports; fi' @@ -135,4 +136,6 @@ check:output=~rootfs on / type cmd:rootimgdir=`lsdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute|grep rootimgdir|awk -F'=' '{print $2}'`; if [ -d $rootimgdir.regbak ]; then rm -rf $rootimgdir; mv $rootimgdir.regbak $rootimgdir; fi check:rc==0 +cmd:rmdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute +check:rc==0 end diff --git a/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_nfs b/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_nfs index 28260fdc0..7a5ce51da 100644 --- a/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_nfs +++ b/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_nfs @@ -20,7 +20,8 @@ check:rc==0 cmd:copycds $$ISO check:rc==0 - +cmd:mkdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -u profile=compute provmethod=statelite osvers=__GETNODEATTR($$CN,os)__ +check:rc==0 cmd:xdsh $$SN df|grep /install;if [ $? -eq 0 ] ;then xdsh $$SN umount /install;fi check:rc==0 cmd:xdsh $$SN 'cat /etc/exports|grep install; if [ "$?" -ne "0" ]; then echo "/install *(rw,no_root_squash,sync,no_subtree_check)" >> /etc/exports; fi' @@ -96,4 +97,6 @@ check:output=~sync file works well cmd:rootimgdir=`lsdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute|grep rootimgdir|awk -F'=' '{print $2}'`; if [ -d $rootimgdir ]; then rm -rf $rootimgdir;fi check:rc==0 +cmd:rmdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute +check:rc==0 end diff --git a/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_ramdisk b/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_ramdisk index c9b3af64f..a1a1b3dac 100644 --- a/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_ramdisk +++ b/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_ramdisk @@ -20,7 +20,8 @@ check:rc==0 cmd:copycds $$ISO check:rc==0 - +cmd:mkdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -u profile=compute provmethod=statelite osvers=__GETNODEATTR($$CN,os)__ +check:rc==0 cmd:xdsh $$SN df|grep /install;if [ $? -eq 0 ] ;then xdsh $$SN umount /install;fi check:rc==0 cmd:xdsh $$SN 'cat /etc/exports|grep install; if [ "$?" -ne "0" ]; then echo "/install *(rw,no_root_squash,sync,no_subtree_check)" >> /etc/exports; fi' @@ -98,4 +99,6 @@ check:output=~sync file works well cmd:rootimgdir=`lsdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute|grep rootimgdir|awk -F'=' '{print $2}'`; if [ -d $rootimgdir.regbak ]; then rm -rf $rootimgdir; mv $rootimgdir.regbak $rootimgdir; fi check:rc==0 +cmd:rmdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute +check:rc==0 end From eeff6a4cd1acf6950c677f240b2f8536dafdee81 Mon Sep 17 00:00:00 2001 From: chenglch Date: Sun, 5 Jun 2016 23:05:24 -0400 Subject: [PATCH 064/310] Fix syntax error when checking the existence of tftp process --- xCAT-server/lib/xcat/plugins/AAsn.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/AAsn.pm b/xCAT-server/lib/xcat/plugins/AAsn.pm index fa351187f..5340d9d7b 100755 --- a/xCAT-server/lib/xcat/plugins/AAsn.pm +++ b/xCAT-server/lib/xcat/plugins/AAsn.pm @@ -1427,7 +1427,7 @@ sub enable_TFTPhpa map { chomp; $pids_map{$_} = 1 } @tftpprocpids; while (keys %pids_map) { foreach my $pid (keys %pids_map) { - if (xCAT::Utils->is_process_exists($pid)) { + if (xCAT::Utils::is_process_exists($pid)) { $count++; if($count == 5) { my $tftpinfo = `ps axf|grep -v grep|grep in.tftpd`; From 5e93fbcd26e6ef16a24684e807ab2601df289513 Mon Sep 17 00:00:00 2001 From: "litingt@cn.ibm.com" Date: Mon, 6 Jun 2016 02:34:26 -0400 Subject: [PATCH 065/310] modify the check for the output because the output is cut out by system --- xCAT-test/autotest/testcase/xcatd/case0 | 48 ++++++++++++------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/xCAT-test/autotest/testcase/xcatd/case0 b/xCAT-test/autotest/testcase/xcatd/case0 index b3f442212..e9947e1b9 100644 --- a/xCAT-test/autotest/testcase/xcatd/case0 +++ b/xCAT-test/autotest/testcase/xcatd/case0 @@ -36,12 +36,12 @@ check:rc==0 check:output=~xcatd.service check:output=~active \(running\) check:output=~/system.slice/xcatd.service -check:output=~xcatd: SSL listener -check:output=~xcatd: DB Access -check:output=~xcatd: UDP listener -check:output=~xcatd: install monitor -check:output=~xcatd: Discovery worker -check:output=~xcatd: Command log writer +check:output=~xcatd: SSL +check:output=~xcatd: DB +check:output=~xcatd: UDP +check:output=~xcatd: install +check:output=~xcatd: Discovery +check:output=~xcatd: Command log cmd:service xcatd stop check:rc==0 cmd:sleep 3 @@ -102,12 +102,12 @@ check:rc==0 check:output=~xcatd.service check:output=~active \(running\) check:output=~/system.slice/xcatd.service -check:output=~xcatd: SSL listener -check:output=~xcatd: DB Access -check:output=~xcatd: UDP listener -check:output=~xcatd: install monitor -check:output=~xcatd: Discovery worker -check:output=~xcatd: Command log writer +check:output=~xcatd: SSL +check:output=~xcatd: DB +check:output=~xcatd: UDP +check:output=~xcatd: install +check:output=~xcatd: Discovery +check:output=~xcatd: Command log cmd:service xcatd stop check:rc==0 cmd:sleep 3 @@ -116,12 +116,12 @@ check:rc!=0 check:output=~xcatd.service check:output=~inactive \(dead\) cmd:ps -ef | grep xcatd -check:output!~"xcatd: SSL listener" -check:output!~"xcatd: DB Access" -check:output!~"xcatd: UDP listener" -check:output!~"xcatd: install monitor" -check:output!~"xcatd: Discovery worke" -check:output!~"xcatd: Command log writer" +check:output!~"xcatd: SSL" +check:output!~"xcatd: DB" +check:output!~"xcatd: UDP" +check:output!~"xcatd: install" +check:output!~"xcatd: Discovery" +check:output!~"xcatd: Command log" cmd:service xcatd start check:rc==0 end @@ -210,12 +210,12 @@ check:rc==0 check:output=~xcatd.service check:output=~active \(running\) check:output=~/system.slice/xcatd.service -check:output=~xcatd: SSL listener -check:output=~xcatd: DB Access -check:output=~xcatd: UDP listener -check:output=~xcatd: install monitor -check:output=~xcatd: Discovery worker -check:output=~xcatd: Command log writer +check:output=~xcatd: SSL +check:output=~xcatd: DB +check:output=~xcatd: UDP +check:output=~xcatd: install +check:output=~xcatd: Discovery +check:output=~xcatd: Command log end start:disable_root_permission_in_policy_table From c266fe625a278199d958c51fd2e98faebac868d3 Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Mon, 6 Jun 2016 02:54:42 -0400 Subject: [PATCH 066/310] complete --- .../autotest/testcase/switchdiscover/cases0 | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/xCAT-test/autotest/testcase/switchdiscover/cases0 b/xCAT-test/autotest/testcase/switchdiscover/cases0 index 16c60d0b0..084f15de2 100644 --- a/xCAT-test/autotest/testcase/switchdiscover/cases0 +++ b/xCAT-test/autotest/testcase/switchdiscover/cases0 @@ -32,7 +32,12 @@ cmd:switchdiscover --range $$range -r check:rc==0 check:output=~Discovering switches using nmap check:output=~xml -check:output=~/usr/bin/nmap -sn -oX - $$range +cmd:rm -rf switchdiscover_range_r.log +cmd:switchdiscover --range $$range -r > switchdiscover_range_r.log +check:rc==0 +cmd:if [ "__GETNODEATTR($$CN,os__" != "sles11.4" ]; then cat switchdiscover_range_r.log | grep "/usr/bin/nmap -sn -oX - $$range"; else cat switchdiscover_range_r.log | grep "/usr/bin/nmap -sP -oX - $$range";fi +check:output=~/usr/bin/nmap -s(n|P) -oX - $$range +cmd:rm -rf switchdiscover_range_r.log end start:switchdiscover_range_x cmd:switchdiscover --range $$range -x @@ -48,14 +53,22 @@ check:output=~Discovering switches using nmap check:output=~nodetype=switch check:output=~groups=switch end + start:switchdiscover_range_z_V cmd:switchdiscover --range $$range -z -V check:rc==0 check:output=~Discovering switches using nmap check:output=~xml -check:output=~Process command: /usr/bin/nmap -sn -oX - $$range check:output=~nodetype=switch check:output=~groups=switch +cmd:rm -rf switchdiscover_range_z_V.log +cmd:switchdiscover --range $$range -z -V > switchdiscover_range_z_V.log +check:rc==0 +cmd:if [ "__GETNODEATTR($$CN,os__" != "sles11.4" ]; then cat switchdiscover_range_z_V.log | grep "Process command: /usr/bin/nmap -sn -oX - $$range"; else cat switchdiscover_range_z_V.log | grep "Process command: /usr/bin/nmap -sP -oX - $$range";fi +check:output=~Process command: /usr/bin/nmap -s(n|P) -oX - $$range +cmd:rm -rf switchdiscover_range_z_V.log end + + From f492ee1fcbcc6f77a917423c7689def256cf79e2 Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Mon, 6 Jun 2016 03:07:58 -0400 Subject: [PATCH 067/310] update v2 --- xCAT-test/autotest/testcase/switchdiscover/cases0 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-test/autotest/testcase/switchdiscover/cases0 b/xCAT-test/autotest/testcase/switchdiscover/cases0 index 084f15de2..7de8bb7e3 100644 --- a/xCAT-test/autotest/testcase/switchdiscover/cases0 +++ b/xCAT-test/autotest/testcase/switchdiscover/cases0 @@ -35,7 +35,7 @@ check:output=~xml cmd:rm -rf switchdiscover_range_r.log cmd:switchdiscover --range $$range -r > switchdiscover_range_r.log check:rc==0 -cmd:if [ "__GETNODEATTR($$CN,os__" != "sles11.4" ]; then cat switchdiscover_range_r.log | grep "/usr/bin/nmap -sn -oX - $$range"; else cat switchdiscover_range_r.log | grep "/usr/bin/nmap -sP -oX - $$range";fi +cmd:if [ "__GETNODEATTR($$CN,os)__" != "sles11.4" ]; then cat switchdiscover_range_r.log | grep "/usr/bin/nmap -sn -oX - $$range"; else cat switchdiscover_range_r.log | grep "/usr/bin/nmap -sP -oX - $$range";fi check:output=~/usr/bin/nmap -s(n|P) -oX - $$range cmd:rm -rf switchdiscover_range_r.log end @@ -64,7 +64,7 @@ check:output=~groups=switch cmd:rm -rf switchdiscover_range_z_V.log cmd:switchdiscover --range $$range -z -V > switchdiscover_range_z_V.log check:rc==0 -cmd:if [ "__GETNODEATTR($$CN,os__" != "sles11.4" ]; then cat switchdiscover_range_z_V.log | grep "Process command: /usr/bin/nmap -sn -oX - $$range"; else cat switchdiscover_range_z_V.log | grep "Process command: /usr/bin/nmap -sP -oX - $$range";fi +cmd:if [ "__GETNODEATTR($$CN,os)__" != "sles11.4" ]; then cat switchdiscover_range_z_V.log | grep "Process command: /usr/bin/nmap -sn -oX - $$range"; else cat switchdiscover_range_z_V.log | grep "Process command: /usr/bin/nmap -sP -oX - $$range";fi check:output=~Process command: /usr/bin/nmap -s(n|P) -oX - $$range cmd:rm -rf switchdiscover_range_z_V.log end From 6ecb8c27c312fb3d133826e826e1f5fa51224a1c Mon Sep 17 00:00:00 2001 From: junxiawang Date: Mon, 6 Jun 2016 05:16:41 -0400 Subject: [PATCH 068/310] add statelite image definition creation and remove --- xCAT-test/autotest/testcase/imgexport/cases0 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xCAT-test/autotest/testcase/imgexport/cases0 b/xCAT-test/autotest/testcase/imgexport/cases0 index 00bf4b3e1..7f2264d6b 100644 --- a/xCAT-test/autotest/testcase/imgexport/cases0 +++ b/xCAT-test/autotest/testcase/imgexport/cases0 @@ -2,6 +2,8 @@ start:imagexport_imagename_destination os:Linux description:imgexport __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute foo.tgz cmd:copycds $$ISO +cmd:mkdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -u profile=compute provmethod=statelite osvers=__GETNODEATTR($$CN,os)__ +check:rc==0 cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute check:rc==0 cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg @@ -16,12 +18,16 @@ check:output=~Done! cmd:ls foo.tgz check:rc==0 cmd:rm -rf foo.tgz +cmd:rmdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute +check:rc==0 end start:imgexport_imagename_destination_p_e os:Linux description:imgexport __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute foo.tgz -p $$CN -e /install/postscripts/testscript1 cmd:copycds $$ISO +cmd:mkdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -u profile=compute provmethod=statelite osvers=__GETNODEATTR($$CN,os)__ +check:rc==0 cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute check:rc==0 cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg @@ -38,6 +44,8 @@ cmd:ls foo.tgz check:rc==0 cmd:rm -rf foo.tgz cmd:rm -rf /install/postscripts/testscript1 +cmd:rmdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute +check:rc==0 end From 216f80f93f9ee256d631552b3ed1e341855ad748 Mon Sep 17 00:00:00 2001 From: immarvin Date: Mon, 6 Jun 2016 23:13:26 -0400 Subject: [PATCH 069/310] correct the logic to determine the ENV{XCATMASTER} --- xCAT-server/lib/perl/xCAT/Template.pm | 41 ++++++++++++++++++--------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index c2ba52cd6..d65f263a1 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -74,28 +74,43 @@ sub subvars { $inc.=$_; } close($inh); + + #the logic to determine the $ENV{XCATMASTER} confirm to the following priority(from high to low): + #the "xcatmaster" attribute of the node + #the site.master + #the ip address of the mn facing the compute node my $master; - #my $sitetab = xCAT::Table->new('site'); + + #the "xcatmaster" attribute of the node my $noderestab = xCAT::Table->new('noderes'); - #(my $et) = $sitetab->getAttribs({key=>"master"},'value'); - my @masters = xCAT::TableUtils->get_site_attribute("master"); - my $tmp = $masters[0]; - if ( defined($tmp) ) { - $master = $tmp; - } - my $ipfn; - my @ipfnd = xCAT::NetworkUtils->my_ip_facing($node); - unless ($ipfnd[0]) { $ipfn = $ipfnd[1];} - if ($ipfn) { - $master = $ipfn; - } my $et = $noderestab->getNodeAttribs($node,['xcatmaster']); if ($et and $et->{'xcatmaster'}) { $master = $et->{'xcatmaster'}; } + + unless ($master){ + #the site.master + my @masters = xCAT::TableUtils->get_site_attribute("master"); + my $tmp = $masters[0]; + if ( defined($tmp) ) { + $master = $tmp; + } + } + + unless ($master){ + #the ip address of the mn facing the compute node + my $ipfn; + my @ipfnd = xCAT::NetworkUtils->my_ip_facing($node); + unless ($ipfnd[0]) { $ipfn = $ipfnd[1];} + if ($ipfn) { + $master = $ipfn; + } + } + unless ($master) { die "Unable to identify master for $node"; } + $ENV{XCATMASTER}=$master; my ($host, $ipaddr) = xCAT::NetworkUtils->gethostnameandip($master); From a2efc938a51e4c1f014273a581ba6a2a0976c6a2 Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Mon, 6 Jun 2016 23:27:05 -0400 Subject: [PATCH 070/310] complete --- .../testcase/installation/Diskless_installation_flat_p8_le | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-test/autotest/testcase/installation/Diskless_installation_flat_p8_le b/xCAT-test/autotest/testcase/installation/Diskless_installation_flat_p8_le index 14d4d3ec5..3ec67dfeb 100644 --- a/xCAT-test/autotest/testcase/installation/Diskless_installation_flat_p8_le +++ b/xCAT-test/autotest/testcase/installation/Diskless_installation_flat_p8_le @@ -1,6 +1,5 @@ start:Diskless_installation_flat_p8_le os:Linux -stop:yes cmd:copycds $$ISO check:rc==0 @@ -33,7 +32,7 @@ check:rc==0 cmd:rpower $$CN boot check:rc==0 cmd:sleep 200 -cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 300 ];then break;fi done +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 100 ];then break;fi done cmd:lsdef -l $$CN | grep status check:output=~booted cmd:xdsh $$CN date @@ -44,6 +43,7 @@ check:rc==0 cmd:rpower $$CN reset check:rc==0 cmd:sleep 200 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 100 ];then break;fi done cmd:lsdef -l $$CN | grep status check:output=~booted cmd:xdsh $$CN date From 6e2818ae6dce32577d99650fdb6ed9bae31759d0 Mon Sep 17 00:00:00 2001 From: XuWei Date: Tue, 31 May 2016 23:23:42 -0400 Subject: [PATCH 071/310] Discovery static check, check whether genesis files ready --- xCAT-probe/subcmds/discovery | 275 +++++++++++++++++++++++++++++++++++ 1 file changed, 275 insertions(+) create mode 100755 xCAT-probe/subcmds/discovery diff --git a/xCAT-probe/subcmds/discovery b/xCAT-probe/subcmds/discovery new file mode 100755 index 000000000..be50a3efd --- /dev/null +++ b/xCAT-probe/subcmds/discovery @@ -0,0 +1,275 @@ +#! /usr/bin/perl +# IBM(c) 2016 EPL license http://www.eclipse.org/legal/epl-v10.html + +BEGIN { $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; } + +use lib "$::XCATROOT/probe/lib/perl"; +use probe_utils; +use File::Basename; +use Getopt::Long qw(:config no_ignore_case); + +my $program_name = basename("$0"); +my $help; +my $test; +my $output = "stdout"; +my $verbose = 0; +my $rst = 0; + +$::USAGE = "Usage: + $program_name -h + $program_name -t + $program_name [-V] + $program_name -s + +Description: + Check discovery files or process. + +Options: + -h : Get usage information of $program_name + -t : To verify if $program_name can work, reserve option for probe framework + -V : Output more information for debug + -s : Discovery static check, check whether genesis files are ready +"; + +sub check_genesis_file { + my $arch = shift; + if (($arch ne "ppc64") and ($arch ne "x86_64")) { + probe_utils->send_msg("$output", "f", "Please input correct arch type"); + return 1; + } + + my $rst_f = 0; + probe_utils->send_msg("$output", "d", "Start to check genesis files for $arch...") if ($verbose); + + my $os = probe_utils->get_os(); + my $genesis_base; + my $genesis_scripts; + + if ($arch eq "x86_64") { + $arch_tmp = "amd64"; + } else { + $arch_tmp = $arch; + } + + if ($os =~ "unknown") { + probe_utils->send_msg("$output", "d", "The OS is not supported.") if ($verbose); + return 1; + } elsif ($os =~ "ubuntu") { + $genesis_base = `dpkg -l | grep -i "xcat-genesis-base" | grep -i "$arch_tmp"`; + $genesis_scripts = `dpkg -l | grep -i "xcat-genesis-scripts" | grep -i "$arch_tmp"`; + } else { + $genesis_base = `rpm -qa | grep -i "xcat-genesis-base" | grep -i "$arch"`; + $genesis_scripts = `rpm -qa | grep -i "xcat-genesis-scripts" | grep -i "$arch"`; + } + unless ($genesis_base and $genesis_scripts) { + probe_utils->send_msg("$output", "d", "xCAT-genesis for $arch did not be installed.") if ($verbose); + return 1; + } + + probe_utils->send_msg("$output", "d", "xCAT-genesis for $arch installed, start to check files...") if ($verbose); + + my $tftpdir = `tabdump site | grep "tftpdir" | awk -F "," '{print \$2}'`; + chomp($tftpdir); + $tftpdir =~ s/"//g; + my $genesis_folder; + my @genesis_files; + my $genesis_line; + my $wget_rst; + + if ($arch eq "ppc64") { + $genesis_folder = "$tftpdir/pxelinux.cfg/p"; + unless (-d "$genesis_folder") { + probe_utils->send_msg("$output", "d", "There is no genesis file for $arch. Please run 'mknb ppc64' if you use ppc64/ppc64le machine.") if ($verbose); + return 1; + } + + @genesis_files = glob("$genesis_folder/*"); + + foreach (@genesis_files) { + unless (open(FILE, $_)) { + probe_utils->send_msg("$output", "d", "Cannot open file $_.") if ($verbose); + $rst_f = 1; + next; + } + + while ($genesis_line = ) { + chomp($genesis_line); + $genesis_line =~ s/^\s+|\s+$//g; + + if ($genesis_line =~ /^initrd/) { + @initrd_info = split(' ', $genesis_line); + $initrd_path = $initrd_info[1]; + $wget_rst = system("wget -q --spider $initrd_path -T 0.5 -t 3"); + if ($wget_rst) { + probe_utils->send_msg("$output", "d", "initrd cannot be downloaded from $initrd_path.") if ($verbose); + $rst_f = 1; + } else { + probe_utils->send_msg("$output", "d", "Check initrd file: $initrd_path PASS.") if ($verbose); + } + } + + if ($genesis_line =~ /^kernel/) { + @kernel_info = split(' ', $genesis_line); + $kernel_path = $kernel_info[1]; + $wget_rst = system("wget -q --spider $kernel_path -T 0.5 -t 3"); + if ($wget_rst) { + probe_utils->send_msg("$output", "d", "kernel cannot be downloaded from $kernel_path.") if ($verbose); + $rst_f = 1; + } else { + probe_utils->send_msg("$output", "d", "Check kernel file: $kernel_path PASS.") if ($verbose); + } + } + } + } + } else { + $genesis_folder = "$tftpdir/xcat/xnba/nets"; + unless (-d "$genesis_folder") { + probe_utils->send_msg("$output", "d", "There is no genesis file for $arch. Please run 'mknb x86_64' if you use x86_64 machine.") if ($verbose); + return 1; + } + + my @host_ip_arr = `ifconfig -a |awk -F" " '/inet / {gsub(/\w+:/,"",\$2);print \$2}'`; + my @netmask_arr = `ifconfig -a |awk -F" " '/inet / {gsub(/\w+:/,"",\$4);print \$4}'`; + + @genesis_files = glob("$genesis_folder/*"); + foreach (@genesis_files) { + if ($_ =~ /uefi$/) { + my $file_name = basename($_); + my @tmp_ip = split('_', $file_name); + my $ip_range = shift(@tmp_ip); + my $host_ip; + my $netmask_num = 0; + foreach (@host_ip_arr) { + chomp($_); + if (probe_utils->is_ip_belong_to_net($ip_range, $netmask_arr[$netmask_num], $_)) { + $host_ip = $_; + } + $netmask_num++; + } + + unless ($host_ip) { + probe_utils->send_msg("$output", "d", "There is no ip for range $ip_range") if ($verbose); + $rst_f = 1; + next; + } + + unless (open(FILE, $_)) { + probe_utils->send_msg("$output", "d", "Can not open file $_."); + $rst_f = 1; + next; + } + + $host_ip .= ":80"; + while ($genesis_line = ) { + chomp($genesis_line); + $genesis_line =~ s/^\s+|\s+$//g; + if ($genesis_line =~ /^chain/) { + my @file_path = split(' ', $genesis_line); + my $elilo_efi = $file_path[1]; + my $elilo_path = $file_path[3]; + $elilo_efi =~ s/\${next-server}/$host_ip/i; + + $wget_rst = system("wget -q --spider $elilo_efi -T 0.5 -t 3"); + if ($wget_rst) { + probe_utils->send_msg("$output", "d", "elilo-x64.efi cannot be downloaded from $elilo_efi.") if ($verbose); + $rst_f = 1; + } else { + probe_utils->send_msg("$output", "d", "Check elilo-x64.efi file: $elilo_efi PASS.") if ($verbose); + } + + my $elilo_http = "http://$host_ip/$elilo_path"; + $wget_rst = system("wget -q --spider $elilo_http -T 0.5 -t 3"); + if ($wget_rst) { + probe_utils->send_msg("$output", "d", "elilo file cannot be downloaded from $elilo_http.") if ($verbose); + $rst_f = 1; + } else { + probe_utils->send_msg("$output", "d", "Check elilo file: $elilo_http PASS.") if ($verbose); + unless (open(FILE_ELILO, $elilo_path)) { + probe_utils->send_msg("$output", "d", "Can not open file $_.") if ($verbose); + $rst_f = 1; + next; + } + + while ($line_elilo = ) { + chomp($line_elilo); + $line_elilo =~ s/^\s+|\s+$//g; + if ($line_elilo =~ /^image/) { + my @image_info = split('=', $line_elilo); + my $image_path = pop(@image_info); + my $image_http = "http://$host_ip/$image_path"; + + $wget_rst = system("wget -q --spider $image_http -T 0.5 -t 3"); + if ($wget_rst) { + probe_utils->send_msg("$output", "d", "image cannot be downloaded from $image_http.") if ($verbose); + $rst_f = 1; + } else { + probe_utils->send_msg("$output", "d", "Check image file: $image_http PASS.") if ($verbose); + } + } + if ($line_elilo =~ /^initrd/) { + my @initrd_info = split('=', $line_elilo); + my $initrd_path = pop(@initrd_info); + my $initrd_http = "http://$host_ip/$initrd_path"; + + $wget_rst = system("wget -q --spider $initrd_http -T 0.5 -t 3"); + if ($wget_rst) { + probe_utils->send_msg("$output", "d", "initrd cannot be downloaded from $initrd_http.") if ($verbose); + $rst_f = 1; + } else { + probe_utils->send_msg("$output", "d", "Check initrd file: $initrd_http PASS.") if ($verbose); + } + } + } + } + } + } + } + } + } + return $rst_f; +} + +#------------------------------------- +# main process +#------------------------------------- +if ( + !GetOptions("--help|h|?" => \$help, + "t" => \$test, + "V" => \$verbose, + "s" => \$static)) +{ + probe_utils->send_msg("$output", "f", "Invalid parameter for $program_name"); + probe_utils->send_msg("$output", "d", "$::USAGE"); + exit 1; +} + +if ($help) { + if ($output ne "stdout") { + probe_utils->send_msg("$output", "d", "$::USAGE"); + } else { + print "$::USAGE"; + } + exit 0; +} + +if ($test) { + probe_utils->send_msg("$output", "o", "Discovery Check."); + exit 0; +} + +if ($static) { + $rst = check_genesis_file("ppc64"); + if ($rst) { + probe_utils->send_msg("$output", "f", "Genesis files for ppc64/ppc64le failed."); + } else { + probe_utils->send_msg("$output", "o", "Genesis files for ppc64/ppc64le success."); + } + $rst = check_genesis_file("x86_64"); + if ($rst) { + probe_utils->send_msg("$output", "f", "Genesis files for x86_64 failed."); + } else { + probe_utils->send_msg("$output", "o", "Genesis files for x86_64 success."); + } +} + +exit $rst; From f3c7e7f156d3898290c5b6afe4fa5b96b350178c Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Tue, 7 Jun 2016 02:52:50 -0400 Subject: [PATCH 072/310] Add new probe command to detect DHCP, base on original detect_dhcpd tool --- xCAT-probe/lib/perl/probe_utils.pm | 5 +- xCAT-probe/subcmds/detect_dhcpd | 383 +++++++++++++++++++++++++++++ xCAT-probe/xcatprobe | 2 + 3 files changed, 389 insertions(+), 1 deletion(-) create mode 100755 xCAT-probe/subcmds/detect_dhcpd diff --git a/xCAT-probe/lib/perl/probe_utils.pm b/xCAT-probe/lib/perl/probe_utils.pm index 9a9b6f29e..c4ed6ddaf 100644 --- a/xCAT-probe/lib/perl/probe_utils.pm +++ b/xCAT-probe/lib/perl/probe_utils.pm @@ -12,7 +12,7 @@ use File::Copy; Description: Format output message depending on probe framework requirement Format is [] : - The valid are debug, warning, failed and ok + The valid are debug, warning, failed, info and ok Arguments: output: where should output the message num: the number of @@ -20,6 +20,7 @@ use File::Copy; w: warning f: failed o: ok + i: info msg: the information need to output Returns: 1 : Failed @@ -42,6 +43,8 @@ sub send_msg { $flag = "[failed] :"; } elsif ($tag eq "o") { $flag = "[ok] :"; + } elsif ($tag eq "i") { + $flag = "[info] :"; } if ($output eq "stdout") { diff --git a/xCAT-probe/subcmds/detect_dhcpd b/xCAT-probe/subcmds/detect_dhcpd new file mode 100755 index 000000000..45714dc60 --- /dev/null +++ b/xCAT-probe/subcmds/detect_dhcpd @@ -0,0 +1,383 @@ +#!/usr/bin/perl +# IBM(c) 2016 EPL license http://www.eclipse.org/legal/epl-v10.html + +BEGIN { $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; } + +use lib "$::XCATROOT/probe/lib/perl"; +use probe_utils; +use File::Basename; +use IO::Socket::INET; +use Time::HiRes qw(gettimeofday sleep); +use Getopt::Long; +Getopt::Long::Configure("bundling"); +Getopt::Long::Configure("pass_through"); + +my $program_name = basename("$0"); +my $output = "stdout"; +my $duration = 10; +my $test = 0; +my $dumpfile = "/tmp/dhcpdumpfile.log"; +my $nic; + +$::USAGE = "Usage: + $program_name -i interface [-m macaddress] [-d duration] [-V] + +Description: + This command can be used to detect the dhcp server in a network for a specific mac address. + +Options: + -i interface: Required. The interface which facing the target network. + -m macaddress: The mac that will be used to detect dhcp server. Recommend to use the real mac of the node that will be netboot. If no specified, the mac of interface which specified by -i will be used. + -d duration: The time to wait to detect the dhcp messages. The default value is 10s. + -t : To verify if $program_name can work, reserve option for probe framework. +"; + +#--------------------------- +# main +#--------------------------- + +if (!GetOptions( + 'i=s' => \$::IF, + 'm=s' => \$::MACADD, + 'd=s' => \$::DURATION, + 't' => \$::TEST, + 'V|verbose' => \$::VERBOSE, + 'h|help' => \$::HELP,)) +{ + probe_utils->send_msg("$output", "f", "Invalid parameter for $program_name"); + probe_utils->send_msg("$output", "d", "$::USAGE"); + exit 1; +} + +if ($::HELP) { + if ($output ne "stdout") { + probe_utils->send_msg("$output", "d", "$::USAGE"); + } else { + print "$::USAGE"; + } + exit 0; +} + +if ($::TEST) { + probe_utils->send_msg("$output", "o", "$program_name can be used to detect the dhcp server in a network for a specific mac address. Before using this command, please install tcpdump command ahead. The operating system supported are redhat, sles, ubuntu and debian."); + exit 0; +} + +unless (-x "/usr/sbin/tcpdump") { + probe_utils->send_msg("$output", "f", "Tool 'tcpdump' is installed on current server"); + probe_utils->send_msg("$output", "d", "$program_name needs to leverage 'tcpdump', please install 'tcpdump' first"); + exit 1; +} + +if ($::IF) { + $nic = $::IF; +} else { + probe_utils->send_msg("$output", "f", "Option '-i' needs to be assigned value for $program_name"); + probe_utils->send_msg("$output", "d", "$::USAGE"); + exit 1; +} + +my $msg = "Find right IP/MAC to do dhcp discover"; +my $IP = `ip addr show dev $nic | awk -F" " '/inet / {print \$2}' | head -n 1 |awk -F"/" '{print \$1}'`; +chomp($IP); +my $MAC; +if ($::MACADD) { + $MAC = $::MACADD; +} else { + $MAC = `ip link show $nic | awk -F" " '/ether/ {print \$2}'`; +} +chomp($MAC); + +probe_utils->send_msg("$output", "d", "Send out dhcp discover from: NIC = $nic, IP = $IP, MAC = $MAC") if ($::VERBOSE); + +if (!$IP || !$MAC) { + probe_utils->send_msg("$output", "f", $msg); + exit 1; +} + +# check the distro +$msg = "The operating system on current server is supported"; +my $os; +if (-f "/etc/redhat-release") { + $os = "rh"; +} elsif (-f "/etc/SuSE-release") { + $os = "sles"; +} elsif (-f "/etc/lsb-release") { + $os = "ubuntu"; +} elsif (-f "/etc/debian_version") { + $os = "debian"; +} else { + probe_utils->send_msg("$output", "f", $msg); + probe_utils->send_msg("$output", "d", "Only support the redhat, sles, ubuntu and debian OS"); + exit 1; +} +probe_utils->send_msg("$output", "d", "Current operating system is $os") if ($::VERBOSE); + + +if ($::DURATION) { + $duration = $::DURATION; +} + +probe_utils->send_msg("$output", "d", "The duration of capturing DHCP package is $duration second") if ($::VERBOSE); + +# send out the package +$msg = "Build the socket to send out DHCP request"; +my $sock = IO::Socket::INET->new(Proto => 'udp', + Broadcast => 1, + PeerPort => '67', + LocalAddr => $IP, + LocalPort => '68', + PeerAddr => inet_ntoa(INADDR_BROADCAST)); + +# try the any port if localport 68 has been used +unless ($sock) { + $sock = IO::Socket::INET->new(Proto => 'udp', + Broadcast => 1, + PeerPort => '67', + LocalAddr => $IP, + PeerAddr => inet_ntoa(INADDR_BROADCAST)); +} + +unless ($sock) { + probe_utils->send_msg("$output", "d", "Create socket error: $@") if ($::VERBOSE); + probe_utils->send_msg("$output", "f", $msg); + exit 1; +} + +my $package = packdhcppkg($MAC); + +probe_utils->send_msg("$output", "i", "Start to detect DHCP, please wait $duration seconds"); + +$msg = "fork a process to capture the packet by tcpdump"; +my $pid = fork; +if (!defined $pid) { + probe_utils->send_msg("$output", "f", $msg); + exit 1; +} elsif ($pid == 0) { + + # Child process + my $cmd = "tcpdump -i $nic port 68 -n -vvvvvv > $dumpfile 2>/dev/null"; + `$cmd`; + exit 0; +} +probe_utils->send_msg("$output", "d", "The id of process which is used to capture the packet by tcpdump is $pid") if ($::VERBOSE); + +my $start = Time::HiRes::gettimeofday(); +$start =~ s/(\d.*)\.(\d.*)/$1/; +my $end = $start; +while ($end - $start <= $duration) { + $sock->send($package); + probe_utils->send_msg("$output", "d", "Send DHCP rquest result: $@") if ($::VERBOSE && $@); + sleep 2; + $end = Time::HiRes::gettimeofday(); + $end =~ s/(\d.*)\.(\d.*)/$1/; +} + +$msg = "Kill the process which is used to capture the packet by tcpdump"; +kill_child(); +waitpid($pid, 0); +sleep 1; +`ps aux|grep -v grep |grep $pid > /dev/null 2>&1`; +if (!$?) { + probe_utils->send_msg("$output", "f", $msg); +} + +$msg = "Dump test result"; +unless (open(FILE, "<$dumpfile")) { + probe_utils->send_msg("$output", "d", "Open dump file $dumpfile failed") if ($::VERBOSE); + probe_utils->send_msg("$output", "f", $msg); + `rm -f $dumpfile` if (-e "$dumpfile"); + exit 1; +} +my %output; +my @snack = (); +my @siaddr = (); +my $newsection = 0; +my $offer = 0; +$chaddr = (); +$ciaddr = (); +$siaddr = (); + +probe_utils->send_msg("$output", "d", "Dump all the information captured during last $duration seconds") if ($::VERBOSE); +while () { + $line = $_; + if ($line =~ /^\d\d:\d\d:\d\d/) { + + # A new packet was captured. Parse the last one. + probe_utils->send_msg("$output", "d", "The server I found: mac = $chaddr, clientip = $ciaddr, serverip = $siaddr, offer = $offer") if ($::VERBOSE); + if ($os eq "sles") { $offer = 1; } + if ($chaddr =~ /$MAC/i && $offer && $ciaddr && $siaddr && $rsiaddr) { + $output{$rsiaddr}{'client'} = $ciaddr; + $output{$rsiaddr}{'nextsv'} = $siaddr; + } elsif ($nack && $siaddr && !grep(/^$siaddr$/, @snack)) { + push @snack, $siaddr; + } elsif ($siaddr && !grep(/^$siaddr$/, @server)) { + push @server, $siaddr; + } + $offer = 0; + $nack = 0; + $chaddr = (); + $ciaddr = (); + $siaddr = (); + $rsiaddr = (); # the server which responsing the dhcp request + } + if ($line =~ /(\d+\.\d+\.\d+\.\d+)\.[\d\w]+ > \d+\./) { + $rsiaddr = $1; + } + if ($line =~ /\s*DHCP-Message.*: Offer/) { + $offer = 1; + } elsif ($line =~ /\s*DHCP-Message.*: NACK/) { + $nack = 1; + } + if ($line =~ /\s*Client-Ethernet-Address (..:..:..:..:..:..)/) { + $chaddr = $1; + } + if ($line =~ /\s*Your-IP (\d+\.\d+\.\d+.\d+)/) { + $ciaddr = $1; + } + if ($line =~ /\s*Server-IP (\d+\.\d+\.\d+.\d+)/) { + $siaddr = $1; + } +} + +close(FILE); + +my $sn = scalar(keys %output); +probe_utils->send_msg("$output", "i", "++++++++++++++++++++++++++++++++++"); + +probe_utils->send_msg("$output", "i", "There are $sn servers reply the dhcp discover."); +foreach my $server (keys %output) { + probe_utils->send_msg("$output", "i", " Server:$server assign IP [$output{$server}{'client'}] to you. The next server is [$output{$server}{'nextsv'}]!"); +} +probe_utils->send_msg("$output", "i", "++++++++++++++++++++++++++++++++++"); + +if (scalar(@snack)) { + probe_utils->send_msg("$output", "i", "==================================="); + probe_utils->send_msg("$output", "i", "The dhcp servers which sending out NACK in present network:"); + foreach my $nack (@snack) { + probe_utils->send_msg("$output", "i", " $nack"); + } +} + +if (scalar(@server)) { + probe_utils->send_msg("$output", "i", "==================================="); + probe_utils->send_msg("$output", "i", "The dhcp servers in present network:"); + foreach my $s (@server) { + probe_utils->send_msg("$output", "i", " $s"); + } +} + +`rm -f $dumpfile` if (-e "$dumpfile"); +exit 0; + + +sub packdhcppkg { + my $mymac = shift; + my $package; + + # add the operation type. 1 - request + $package .= pack("C*", 1); + + # add the hardware type. 1 - ethernet + $package .= pack("C*", 1); + + # add the length of hardware add + $package .= pack("C*", 6); + + # add the hops + $package .= pack("C*", 0); + + # add the transaction id + $package .= pack("C*", 60, 61, 62, 63); + + # add the elapsed time + $package .= pack("C*", 0, 0); + + # add the flag 00 - broadcast + $package .= pack("C*", 128, 0); + + # add the IP of client + $package .= pack("C*", 0, 0, 0, 0); + + # add the your IP + $package .= pack("C*", 0, 0, 0, 0); + + # add the next server IP + $package .= pack("C*", 0, 0, 0, 0); + + # add the relay agent IP + $package .= pack("C*", 0, 0, 0, 0); + + # add the mac address of the client + my @macval; + if ($mymac) { + my @strmac = split(/:/, $mymac); + foreach (@strmac) { + push @macval, hex($_); + } + $package .= pack("C*", @macval); + } else { + @macval = ('0', '0', '50', '51', '52', '53'); + $package .= pack("C*", @macval); + } + + # add 10 padding for mac + my @macpad; + foreach (1 .. 10) { + push @macpad, "0"; + } + $package .= pack("C*", @macpad); + + # add the hostname of server + my @hs; + foreach (1 .. 64) { + push @hs, "0"; + } + $package .= pack("C*", @hs); + + # add the file name + my @fn; + foreach (1 .. 128) { + push @fn, "0"; + } + $package .= pack("C*", @fn); + + # add the magic cookie + $package .= pack("C*", 99, 130, 83, 99); + + # add the dhcp message type. The last num: 1 - dhcp discover + $package .= pack("C*", 53, 1, 1); + + # add the client identifier + $package .= pack("C*", 61, 7, 1); #type, length, hwtype + $package .= pack("C*", @macval); + + # add the parameter request list + $package .= pack("C*", 55, 10); #type, length + $package .= pack("C*", 1, 3, 6, 12, 15, 28, 40, 41, 42, 119); + + # add the end option + $package .= pack("C*", 255); + + # pad the package to 300 + @strpack = unpack("W*", $package); + my $curleng = length($strpack); + + my @padding; + foreach (1 .. 35) { + push @padding, '0'; + } + + $package .= pack("C*", @padding); + + return $package; +} + +sub kill_child { + kill 15, $pid; + my @pidoftcpdump = `ps -ef | grep -E "[0-9]+:[0-9]+:[0-9]+ tcpdump -i $nic" | awk -F' ' '{print \$2}'`; + foreach my $cpid (@pidoftcpdump) { + kill 15, $cpid; + } + probe_utils->send_msg("$output", "d", "Kill process $pid which is used to capture the packet by tcpdump") if ($::VERBOSE); +} diff --git a/xCAT-probe/xcatprobe b/xCAT-probe/xcatprobe index 366a00686..99b3c4b62 100755 --- a/xCAT-probe/xcatprobe +++ b/xCAT-probe/xcatprobe @@ -108,6 +108,8 @@ sub format_cmd_output { } } elsif ($flag =~ /debug/i) { print " "; + } elsif ($flag =~ /info/i) { + print "[INFO] "; } print "$msg\n"; } else { From 6c1810523396bfd0c3b3bdc932d9aba7f2b8360b Mon Sep 17 00:00:00 2001 From: Khaled Salim Date: Tue, 7 Jun 2016 12:43:28 +0300 Subject: [PATCH 073/310] Fix systemctl commands in the install guide --- docs/source/guides/install-guides/common_sections.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/guides/install-guides/common_sections.rst b/docs/source/guides/install-guides/common_sections.rst index b4646a0cb..840532675 100644 --- a/docs/source/guides/install-guides/common_sections.rst +++ b/docs/source/guides/install-guides/common_sections.rst @@ -188,22 +188,22 @@ xCAT is started automatically after the installation, but the following commands * start xCAT: :: service xcatd start - [systemd] systemctl xcatd.service start + [systemd] systemctl start xcatd.service * stop xCAT: :: service xcatd stop - [systemd] systemctl xcatd.service stop + [systemd] systemctl stop xcatd.service * restart xCAT: :: service xcatd restart - [systemd] systemctl xcatd.service restart + [systemd] systemctl restart xcatd.service * check xCAT status: :: service xcatd status - [systemd] systemctl xcatd.service status + [systemd] systemctl status xcatd.service .. END_verifying_xcat From 314df2e1116e85fd3dae2c4e97b77cb593603ec8 Mon Sep 17 00:00:00 2001 From: junxiawang Date: Tue, 7 Jun 2016 05:59:31 -0400 Subject: [PATCH 074/310] delete docker cases which could not be automated on ubuntu16.04 now --- .../autotest/bundle/ubuntu16.04_x86_64.bundle | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle b/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle index a80535bae..d1affab41 100644 --- a/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle +++ b/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle @@ -249,17 +249,3 @@ run_command_with_XCATBYPASS_systemd disable_root_permission_in_policy_table_systemd assign_certain_command_permission_systemd nodeset_check_warninginfo -Full_installation_flat_docker -rpower_stop -rpower_start -rpower_state -rpower_restart -rpower_pause -rpower_unpause -mkdocker_h -mkdocker_command -rmdocker_h -rmdocker_command -rmdocker_f_command -lsdocker_h_command -lsdocker_l_command From 199cbe1e9279771a75d395da1ed8e66a8dfeb8c9 Mon Sep 17 00:00:00 2001 From: junxiawang Date: Tue, 7 Jun 2016 06:12:02 -0400 Subject: [PATCH 075/310] delete statelite image definition on diskfull install --- .../testcase/installation/reg_linux_diskfull_installation_flat | 1 - 1 file changed, 1 deletion(-) diff --git a/xCAT-test/autotest/testcase/installation/reg_linux_diskfull_installation_flat b/xCAT-test/autotest/testcase/installation/reg_linux_diskfull_installation_flat index be95763b6..f38b631f5 100644 --- a/xCAT-test/autotest/testcase/installation/reg_linux_diskfull_installation_flat +++ b/xCAT-test/autotest/testcase/installation/reg_linux_diskfull_installation_flat @@ -24,7 +24,6 @@ cmd:if cat /etc/*release |grep SUSE >/dev/null;then cat /var/lib/dhcp/db/dhcpd.l check:output=~$$CN cmd:copycds $$ISO check:rc==0 -cmd: mkdef __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -u profile=compute provmethod=statelite osvers=__GETNODEATTR($$CN,os)__ cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute check:rc==0 cmd:lsdef $$CN |grep provmethod From d73b02386a78d8a991feab5ab0310eab263050b2 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Fri, 27 May 2016 11:33:59 -0400 Subject: [PATCH 076/310] Adding quotes to the label and default tag. Without this, petitboot menu does not count down by default --- xCAT-server/lib/xcat/plugins/mknb.pm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/mknb.pm b/xCAT-server/lib/xcat/plugins/mknb.pm index eede1c6ae..0c84e8e16 100644 --- a/xCAT-server/lib/xcat/plugins/mknb.pm +++ b/xCAT-server/lib/xcat/plugins/mknb.pm @@ -252,8 +252,9 @@ CREAT_CONF_FILE: close($cfg); if ($invisibletouch and $arch =~ /x86_64/) { #UEFI time open($cfg,">","$tftpdir/xcat/xnba/nets/$net.elilo"); - print $cfg "default=\"xCAT Genesis\"\ndelay=5\n\n"; - print $cfg 'image=/tftpboot/xcat/genesis.kernel.'."$arch\n"; + print $cfg "default=\"xCAT Genesis (".$normnets->{$_}.")\"\n"; + print $cfg " delay=5\n"; + print $cfg ' image=/tftpboot/xcat/genesis.kernel.'."$arch\n"; print $cfg " label=\"xCAT Genesis (".$normnets->{$_}.")\"\n"; if ($lzma_exit_value) { print $cfg " initrd=/tftpboot/xcat/genesis.fs.$arch.gz\n"; @@ -270,8 +271,9 @@ CREAT_CONF_FILE: } elsif ($arch =~ /ppc/) { open($cfgfile,">", "$tftpdir/pxelinux.cfg/p/$net"); - print $cfgfile "default xCAT\n"; - print $cfgfile " label xCAT Genesis (".$normnets->{$_}.")\n"; + print $cfgfile "default \"xCAT Genesis (".$normnets->{$_}.")\"\n"; + print $cfgfile " delay=10\n"; + print $cfgfile " label \"xCAT Genesis (".$normnets->{$_}.")\"\n"; print $cfgfile " kernel http://".$normnets->{$_}.":80/$tftpdir/xcat/genesis.kernel.$arch\n"; print $cfgfile " initrd http://".$normnets->{$_}.":80/$initrd_file\n"; print $cfgfile ' append "quiet xcatd='.$normnets->{$_}.":$xcatdport $consolecmdline\"\n"; @@ -307,8 +309,9 @@ CREAT_CONF_FILE: close($cfgfile); } elsif ($arch =~ /ppc/) { open($cfgfile,">","$tftpdir/etc/".lc($_)); - print $cfgfile "default xCAT\n"; - print $cfgfile " label xCAT Genesis (".$normnets->{$_}.")\n"; + print $cfgfile "default \"xCAT Genesis (".$normnets->{$_}.")\"\n"; + print $cfgfile " delay=10\n"; + print $cfgfile " label \"xCAT Genesis (".$normnets->{$_}.")\"\n"; print $cfgfile " kernel http://".$hexnets->{$_}.":80/$tftpdir/xcat/genesis.kernel.$arch\n"; print $cfgfile " initrd http://".$hexnets->{$_}.":80/$initrd_file\n"; print $cfgfile ' append "quiet xcatd='.$hexnets->{$_}.":$xcatdport $consolecmdline\"\n"; From 726d4d35f1d586762974d9207ee207a1188de4df Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Tue, 7 Jun 2016 13:49:13 -0400 Subject: [PATCH 077/310] Fix the formatting of the file to use 3 spaces instead of tab --- xCAT-server/lib/xcat/plugins/mknb.pm | 214 +++++++++++++-------------- 1 file changed, 104 insertions(+), 110 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/mknb.pm b/xCAT-server/lib/xcat/plugins/mknb.pm index 0c84e8e16..763e30388 100644 --- a/xCAT-server/lib/xcat/plugins/mknb.pm +++ b/xCAT-server/lib/xcat/plugins/mknb.pm @@ -15,39 +15,34 @@ sub handled_commands { sub process_request { my $request = shift; my $callback = shift; - #my $sitetab = xCAT::Table->new('site'); my $serialport; my $serialspeed; my $serialflow; my $initrd_file = undef; my $xcatdport = 3001; - #if ($sitetab) { - #my $portent = $sitetab->getAttribs({key=>'defserialport'},'value'); - my @entries = xCAT::TableUtils->get_site_attribute("defserialport"); - my $t_entry = $entries[0]; - if ( defined($t_entry) ) { - $serialport=$t_entry; - } - #$portent = $sitetab->getAttribs({key=>'defserialspeed'},'value'); - @entries = xCAT::TableUtils->get_site_attribute("defserialspeed"); - $t_entry = $entries[0]; - if ( defined($t_entry) ) { - $serialspeed=$t_entry; - } - #$portent = $sitetab->getAttribs({key=>'defserialflow'},'value'); - @entries = xCAT::TableUtils->get_site_attribute("defserialflow"); - $t_entry = $entries[0]; - if ( defined($t_entry) ) { - $serialflow=$t_entry; - } - #$portent = $sitetab->getAttribs({key=>'xcatdport'},'value'); - @entries = xCAT::TableUtils->get_site_attribute("xcatdport"); - $t_entry = $entries[0]; - if ( defined($t_entry) ) { - $xcatdport=$t_entry; - } - #$sitetab->close; - #} + my @entries = xCAT::TableUtils->get_site_attribute("defserialport"); + my $t_entry = $entries[0]; + if ( defined($t_entry) ) { + $serialport=$t_entry; + } + + @entries = xCAT::TableUtils->get_site_attribute("defserialspeed"); + $t_entry = $entries[0]; + if ( defined($t_entry) ) { + $serialspeed=$t_entry; + } + + @entries = xCAT::TableUtils->get_site_attribute("defserialflow"); + $t_entry = $entries[0]; + if ( defined($t_entry) ) { + $serialflow=$t_entry; + } + + @entries = xCAT::TableUtils->get_site_attribute("xcatdport"); + $t_entry = $entries[0]; + if ( defined($t_entry) ) { + $xcatdport=$t_entry; + } my $tftpdir = xCAT::TableUtils->getTftpDir(); my $arch = $request->{arg}->[0]; @@ -55,8 +50,8 @@ sub process_request { $callback->({error=>"Need to specify architecture (x86, x86_64 or ppc64)"},{errorcode=>[1]}); return; } elsif ( $arch eq "ppc64le" or $arch eq "ppc64el" ) { - $callback->({data=>"The arch:$arch is not supported at present, pls use \"ppc64\" instead"}); - return; + $callback->({data=>"The arch:$arch is not supported at present, pls use \"ppc64\" instead"}); + return; } unless (-d "$::XCATROOT/share/xcat/netboot/$arch" or -d "$::XCATROOT/share/xcat/netboot/genesis/$arch") { $callback->({error=>"Unable to find directory $::XCATROOT/share/xcat/netboot/$arch or $::XCATROOT/share/xcat/netboot/genesis/$arch",errorcode=>[1]}); @@ -121,8 +116,8 @@ sub process_request { copy("/root/.ssh/id_rsa.pub","$tempdir$sshdir/authorized_keys"); chmod(0600,"$tempdir$sshdir/authorized_keys"); if (not $invisibletouch and -r "/etc/xcat/hostkeys/ssh_host_rsa_key") { - copy("/etc/xcat/hostkeys/ssh_host_rsa_key","$tempdir/etc/ssh_host_rsa_key"); - copy("/etc/xcat/hostkeys/ssh_host_dsa_key","$tempdir/etc/ssh_host_dsa_key"); + copy("/etc/xcat/hostkeys/ssh_host_rsa_key","$tempdir/etc/ssh_host_rsa_key"); + copy("/etc/xcat/hostkeys/ssh_host_dsa_key","$tempdir/etc/ssh_host_dsa_key"); chmod(0600,<$tempdir/etc/ssh_*>); } unless ($invisibletouch or -r "$tempdir/etc/ssh_host_rsa_key") { @@ -131,34 +126,34 @@ sub process_request { } my $lzma_exit_value=1; if ($invisibletouch) { - my $done=0; - if (-x "/usr/bin/lzma") { #let's reclaim some of that size... - $callback->({data=>["Creating genesis.fs.$arch.lzma in $tftpdir/xcat"]}); - system("cd $tempdir; find . | cpio -o -H newc | lzma -C crc32 -9 > $tftpdir/xcat/genesis.fs.$arch.lzma"); - $lzma_exit_value=$? >> 8; - if ($lzma_exit_value) { - $callback->({data=>["Creating genesis.fs.$arch.lzma in $tftpdir/xcat failed, falling back to gzip"]}); - unlink ("$tftpdir/xcat/genesis.fs.$arch.lzma"); - } else { - $done = 1; - $initrd_file = "$tftpdir/xcat/genesis.fs.$arch.lzma"; - } - } - - if (not $done) { - $callback->({data=>["Creating genesis.fs.$arch.gz in $tftpdir/xcat"]}); - system("cd $tempdir; find . | cpio -o -H newc | gzip -9 > $tftpdir/xcat/genesis.fs.$arch.gz"); - $initrd_file = "$tftpdir/xcat/genesis.fs.$arch.gz"; - } + my $done=0; + if (-x "/usr/bin/lzma") { #let's reclaim some of that size... + $callback->({data=>["Creating genesis.fs.$arch.lzma in $tftpdir/xcat"]}); + system("cd $tempdir; find . | cpio -o -H newc | lzma -C crc32 -9 > $tftpdir/xcat/genesis.fs.$arch.lzma"); + $lzma_exit_value=$? >> 8; + if ($lzma_exit_value) { + $callback->({data=>["Creating genesis.fs.$arch.lzma in $tftpdir/xcat failed, falling back to gzip"]}); + unlink ("$tftpdir/xcat/genesis.fs.$arch.lzma"); + } else { + $done = 1; + $initrd_file = "$tftpdir/xcat/genesis.fs.$arch.lzma"; + } + } + + if (not $done) { + $callback->({data=>["Creating genesis.fs.$arch.gz in $tftpdir/xcat"]}); + system("cd $tempdir; find . | cpio -o -H newc | gzip -9 > $tftpdir/xcat/genesis.fs.$arch.gz"); + $initrd_file = "$tftpdir/xcat/genesis.fs.$arch.gz"; + } } else { - $callback->({data=>["Creating nbfs.$arch.gz in $tftpdir/xcat"]}); - system("cd $tempdir; find . | cpio -o -H newc | gzip -9 > $tftpdir/xcat/nbfs.$arch.gz"); - $initrd_file = "$tftpdir/xcat/nbfs.$arch.gz"; + $callback->({data=>["Creating nbfs.$arch.gz in $tftpdir/xcat"]}); + system("cd $tempdir; find . | cpio -o -H newc | gzip -9 > $tftpdir/xcat/nbfs.$arch.gz"); + $initrd_file = "$tftpdir/xcat/nbfs.$arch.gz"; } system ("rm -rf $tempdir"); unless ($initrd_file) { - $callback->({data=>["Creating filesystem file in $tftpdir/xcat failed"]}); - return; + $callback->({data=>["Creating filesystem file in $tftpdir/xcat failed"]}); + return; } CREAT_CONF_FILE: @@ -182,11 +177,11 @@ CREAT_CONF_FILE: my $normnets = xCAT::NetworkUtils->my_nets(); my $consolecmdline; if (defined($serialport) and $serialspeed) { - if ($arch =~ /ppc/) { - $consolecmdline = "console=tty0 console=hvc$serialport,$serialspeed"; - } else { - $consolecmdline = "console=tty0 console=ttyS$serialport,$serialspeed"; - } + if ($arch =~ /ppc/) { + $consolecmdline = "console=tty0 console=hvc$serialport,$serialspeed"; + } else { + $consolecmdline = "console=tty0 console=ttyS$serialport,$serialspeed"; + } if ($serialflow =~ /cts/ or $serialflow =~ /hard/) { $consolecmdline .= "n8r"; } @@ -199,12 +194,12 @@ CREAT_CONF_FILE: mkpath("$tftpdir/pxelinux.cfg"); chmod(0755,"$tftpdir/pxelinux.cfg"); if (-r "/usr/lib/syslinux/pxelinux.0") { - copy("/usr/lib/syslinux/pxelinux.0","$tftpdir/pxelinux.0"); + copy("/usr/lib/syslinux/pxelinux.0","$tftpdir/pxelinux.0"); } elsif (-r "/usr/share/syslinux/pxelinux.0") { - copy("/usr/share/syslinux/pxelinux.0","$tftpdir/pxelinux.0"); + copy("/usr/share/syslinux/pxelinux.0","$tftpdir/pxelinux.0"); } if (-r "$tftpdir/pxelinux.0") { - chmod(0644,"$tftpdir/pxelinux.0"); + chmod(0644,"$tftpdir/pxelinux.0"); } } elsif ($arch =~ /ppc/) { mkpath("$tftpdir/pxelinux.cfg/p/"); @@ -215,60 +210,59 @@ CREAT_CONF_FILE: $net =~s/\//_/; $dopxe=0; if ($arch =~ /x86/) { #only do pxe if just x86 or x86_64 and no x86 - if ($arch =~ /x86_64/ and not $invisibletouch) { - if (-r "$tftpdir/xcat/xnba/nets/$net") { - my $cfg; - my @contents; - open($cfg,"<","$tftpdir/xcat/xnba/nets/$net"); - @contents = <$cfg>; - close($cfg); - if (grep (/x86_64/,@contents)) { - $dopxe=1; - } - } else { - $dopxe = 1; - } - } else { - $dopxe = 1; - } + if ($arch =~ /x86_64/ and not $invisibletouch) { + if (-r "$tftpdir/xcat/xnba/nets/$net") { + my $cfg; + my @contents; + open($cfg,"<","$tftpdir/xcat/xnba/nets/$net"); + @contents = <$cfg>; + close($cfg); + if (grep (/x86_64/,@contents)) { + $dopxe=1; + } + } else { + $dopxe = 1; + } + } else { + $dopxe = 1; + } } if ($dopxe) { - my $cfg; + my $cfg; open($cfg,">","$tftpdir/xcat/xnba/nets/$net"); print $cfg "#!gpxe\n"; - if ($invisibletouch) { - print $cfg 'imgfetch -n kernel http://${next-server}/tftpboot/xcat/genesis.kernel.'."$arch quiet xcatd=".$normnets->{$_}.":$xcatdport $consolecmdline BOOTIF=01-".'${netX/machyp}'."\n"; - if ($lzma_exit_value) { - print $cfg 'imgfetch -n nbfs http://${next-server}/tftpboot/xcat/genesis.fs.'."$arch.gz\n"; - } else { - print $cfg 'imgfetch -n nbfs http://${next-server}/tftpboot/xcat/genesis.fs.'."$arch.lzma\n"; - } + if ($invisibletouch) { + print $cfg 'imgfetch -n kernel http://${next-server}/tftpboot/xcat/genesis.kernel.'."$arch quiet xcatd=".$normnets->{$_}.":$xcatdport $consolecmdline BOOTIF=01-".'${netX/machyp}'."\n"; + if ($lzma_exit_value) { + print $cfg 'imgfetch -n nbfs http://${next-server}/tftpboot/xcat/genesis.fs.'."$arch.gz\n"; + } else { + print $cfg 'imgfetch -n nbfs http://${next-server}/tftpboot/xcat/genesis.fs.'."$arch.lzma\n"; + } } else { - print $cfg 'imgfetch -n kernel http://${next-server}/tftpboot/xcat/nbk.'."$arch quiet xcatd=".$normnets->{$_}.":$xcatdport $consolecmdline\n"; - print $cfg 'imgfetch -n nbfs http://${next-server}/tftpboot/xcat/nbfs.'."$arch.gz\n"; - } + print $cfg 'imgfetch -n kernel http://${next-server}/tftpboot/xcat/nbk.'."$arch quiet xcatd=".$normnets->{$_}.":$xcatdport $consolecmdline\n"; + print $cfg 'imgfetch -n nbfs http://${next-server}/tftpboot/xcat/nbfs.'."$arch.gz\n"; + } print $cfg "imgload kernel\n"; print $cfg "imgexec kernel\n"; close($cfg); - if ($invisibletouch and $arch =~ /x86_64/) { #UEFI time - open($cfg,">","$tftpdir/xcat/xnba/nets/$net.elilo"); - print $cfg "default=\"xCAT Genesis (".$normnets->{$_}.")\"\n"; - print $cfg " delay=5\n"; - print $cfg ' image=/tftpboot/xcat/genesis.kernel.'."$arch\n"; - print $cfg " label=\"xCAT Genesis (".$normnets->{$_}.")\"\n"; - if ($lzma_exit_value) { - print $cfg " initrd=/tftpboot/xcat/genesis.fs.$arch.gz\n"; - } else { - print $cfg " initrd=/tftpboot/xcat/genesis.fs.$arch.lzma\n"; - } - print $cfg " append=\"quiet xcatd=".$normnets->{$_}.":$xcatdport destiny=discover $consolecmdline BOOTIF=%B\"\n"; - close($cfg); - open($cfg,">","$tftpdir/xcat/xnba/nets/$net.uefi"); - print $cfg "#!gpxe\n"; - print $cfg 'chain http://${next-server}/tftpboot/xcat/elilo-x64.efi -C /tftpboot/xcat/xnba/nets/'."$net.elilo\n"; - close($cfg); - } - + if ($invisibletouch and $arch =~ /x86_64/) { #UEFI time + open($cfg,">","$tftpdir/xcat/xnba/nets/$net.elilo"); + print $cfg "default=\"xCAT Genesis (".$normnets->{$_}.")\"\n"; + print $cfg " delay=5\n"; + print $cfg ' image=/tftpboot/xcat/genesis.kernel.'."$arch\n"; + print $cfg " label=\"xCAT Genesis (".$normnets->{$_}.")\"\n"; + if ($lzma_exit_value) { + print $cfg " initrd=/tftpboot/xcat/genesis.fs.$arch.gz\n"; + } else { + print $cfg " initrd=/tftpboot/xcat/genesis.fs.$arch.lzma\n"; + } + print $cfg " append=\"quiet xcatd=".$normnets->{$_}.":$xcatdport destiny=discover $consolecmdline BOOTIF=%B\"\n"; + close($cfg); + open($cfg,">","$tftpdir/xcat/xnba/nets/$net.uefi"); + print $cfg "#!gpxe\n"; + print $cfg 'chain http://${next-server}/tftpboot/xcat/elilo-x64.efi -C /tftpboot/xcat/xnba/nets/'."$net.elilo\n"; + close($cfg); + } } elsif ($arch =~ /ppc/) { open($cfgfile,">", "$tftpdir/pxelinux.cfg/p/$net"); print $cfgfile "default \"xCAT Genesis (".$normnets->{$_}.")\"\n"; From 7675f7ca6e2a6971f599c89da4d1a0b0a9e7566b Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 7 Jun 2016 14:43:11 -0400 Subject: [PATCH 078/310] Schema.pm missing objects and spelling fixes --- .../admin-guides/references/man5/deps.5.rst | 2 +- .../admin-guides/references/man5/domain.5.rst | 2 +- .../admin-guides/references/man5/ipmi.5.rst | 2 +- .../references/man5/kvm_masterdata.5.rst | 2 +- .../references/man5/kvm_nodedata.5.rst | 2 +- .../references/man5/linuximage.5.rst | 6 +- .../admin-guides/references/man5/mic.5.rst | 2 +- .../references/man5/monitoring.5.rst | 2 +- .../references/man5/monsetting.5.rst | 2 +- .../admin-guides/references/man5/mp.5.rst | 2 +- .../admin-guides/references/man5/nics.5.rst | 4 +- .../references/man5/nodelist.5.rst | 2 +- .../references/man5/osimage.5.rst | 2 +- .../references/man5/postscripts.5.rst | 2 +- .../admin-guides/references/man5/routes.5.rst | 2 +- .../admin-guides/references/man5/site.5.rst | 2 +- .../references/man5/statelite.5.rst | 2 +- .../references/man5/switches.5.rst | 6 +- .../admin-guides/references/man5/vm.5.rst | 4 +- .../admin-guides/references/man5/vpd.5.rst | 2 +- .../admin-guides/references/man5/xcatdb.5.rst | 8 +- .../references/man7/boottarget.7.rst | 32 ++++++- .../admin-guides/references/man7/group.7.rst | 24 +++--- .../references/man7/monitoring.7.rst | 2 +- .../admin-guides/references/man7/node.7.rst | 26 +++--- .../references/man7/osimage.7.rst | 8 +- perl-xCAT/xCAT/Schema.pm | 83 +++++++++++++------ 27 files changed, 148 insertions(+), 87 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man5/deps.5.rst b/docs/source/guides/admin-guides/references/man5/deps.5.rst index 4c61b66b7..1da97c43c 100644 --- a/docs/source/guides/admin-guides/references/man5/deps.5.rst +++ b/docs/source/guides/admin-guides/references/man5/deps.5.rst @@ -56,7 +56,7 @@ deps Attributes: \ **cmd**\ - Comma-seperated list of which operation this dependency applies to. + Comma-separated list of which operation this dependency applies to. diff --git a/docs/source/guides/admin-guides/references/man5/domain.5.rst b/docs/source/guides/admin-guides/references/man5/domain.5.rst index 90af85987..73cc78ebb 100644 --- a/docs/source/guides/admin-guides/references/man5/domain.5.rst +++ b/docs/source/guides/admin-guides/references/man5/domain.5.rst @@ -44,7 +44,7 @@ domain Attributes: \ **ou**\ - For an LDAP described machine account (i.e. Active Directory), the orginaztional unit to place the system. If not set, defaults to cn=Computers,dc=your,dc=domain + For an LDAP described machine account (i.e. Active Directory), the organizational unit to place the system. If not set, defaults to cn=Computers,dc=your,dc=domain diff --git a/docs/source/guides/admin-guides/references/man5/ipmi.5.rst b/docs/source/guides/admin-guides/references/man5/ipmi.5.rst index 84b8cfde1..88fe0488c 100644 --- a/docs/source/guides/admin-guides/references/man5/ipmi.5.rst +++ b/docs/source/guides/admin-guides/references/man5/ipmi.5.rst @@ -44,7 +44,7 @@ ipmi Attributes: \ **bmc**\ - The hostname of the BMC adapater. + The hostname of the BMC adapter. diff --git a/docs/source/guides/admin-guides/references/man5/kvm_masterdata.5.rst b/docs/source/guides/admin-guides/references/man5/kvm_masterdata.5.rst index c22dd1b82..7ac2d011a 100644 --- a/docs/source/guides/admin-guides/references/man5/kvm_masterdata.5.rst +++ b/docs/source/guides/admin-guides/references/man5/kvm_masterdata.5.rst @@ -27,7 +27,7 @@ DESCRIPTION *********** -Persistant store for KVM plugin for masters +Persistent store for KVM plugin for masters ************************** diff --git a/docs/source/guides/admin-guides/references/man5/kvm_nodedata.5.rst b/docs/source/guides/admin-guides/references/man5/kvm_nodedata.5.rst index 81054cabc..c2286a413 100644 --- a/docs/source/guides/admin-guides/references/man5/kvm_nodedata.5.rst +++ b/docs/source/guides/admin-guides/references/man5/kvm_nodedata.5.rst @@ -27,7 +27,7 @@ DESCRIPTION *********** -Persistant store for KVM plugin, not intended for manual modification. +Persistent store for KVM plugin, not intended for manual modification. ************************ diff --git a/docs/source/guides/admin-guides/references/man5/linuximage.5.rst b/docs/source/guides/admin-guides/references/man5/linuximage.5.rst index f9855f147..662d6b48b 100644 --- a/docs/source/guides/admin-guides/references/man5/linuximage.5.rst +++ b/docs/source/guides/admin-guides/references/man5/linuximage.5.rst @@ -68,13 +68,13 @@ linuximage Attributes: \ **pkgdir**\ - The name of the directory where the distro packages are stored. It could be set multiple paths.The multiple paths must be seperated by ",". The first path in the value of osimage.pkgdir must be the OS base pkg dir path, such as pkgdir=/install/rhels6.2/x86_64,/install/updates . In the os base pkg path, there are default repository data. And in the other pkg path(s), the users should make sure there are repository data. If not, use "createrepo" command to create them. For ubuntu, multiple mirrors can be specified in the pkgdir attribute, the mirrors must be prefixed by the protocol(http/ssh) and delimited with "," between each other. + The name of the directory where the distro packages are stored. It could be set to multiple paths. The multiple paths must be separated by ",". The first path in the value of osimage.pkgdir must be the OS base pkg dir path, such as pkgdir=/install/rhels6.2/x86_64,/install/updates . In the os base pkg path, there are default repository data. And in the other pkg path(s), the users should make sure there are repository data. If not, use "createrepo" command to create them. For ubuntu, multiple mirrors can be specified in the pkgdir attribute, the mirrors must be prefixed by the protocol(http/ssh) and delimited with "," between each other. \ **otherpkglist**\ - The fully qualified name of the file that stores non-distro package lists that will be included in the image. It could be set multiple paths.The multiple paths must be seperated by ",". + The fully qualified name of the file that stores non-distro package lists that will be included in the image. It could be set to multiple paths. The multiple paths must be separated by ",". @@ -92,7 +92,7 @@ linuximage Attributes: \ **postinstall**\ - The fully qualified name of the script file that will be run at the end of the genimage command. It could be set multiple paths.The multiple paths must be seperated by ",". It is used for diskless image only. + The fully qualified name of the script file that will be run at the end of the genimage command. It could be set to multiple paths. The multiple paths must be separated by ",". It is used for diskless image only. diff --git a/docs/source/guides/admin-guides/references/man5/mic.5.rst b/docs/source/guides/admin-guides/references/man5/mic.5.rst index f2c30831e..896113110 100644 --- a/docs/source/guides/admin-guides/references/man5/mic.5.rst +++ b/docs/source/guides/admin-guides/references/man5/mic.5.rst @@ -27,7 +27,7 @@ DESCRIPTION *********** -The host, slot id and configuraton of the mic (Many Integrated Core). +The host, slot id and configuration of the mic (Many Integrated Core). *************** diff --git a/docs/source/guides/admin-guides/references/man5/monitoring.5.rst b/docs/source/guides/admin-guides/references/man5/monitoring.5.rst index 8419697d1..6ea1f73d3 100644 --- a/docs/source/guides/admin-guides/references/man5/monitoring.5.rst +++ b/docs/source/guides/admin-guides/references/man5/monitoring.5.rst @@ -38,7 +38,7 @@ monitoring Attributes: \ **name**\ - The name of the mornitoring plug-in module. The plug-in must be put in /lib/perl/xCAT_monitoring/. See the man page for monstart for details. + The name of the monitoring plug-in module. The plug-in must be put in /lib/perl/xCAT_monitoring/. See the man page for monstart for details. diff --git a/docs/source/guides/admin-guides/references/man5/monsetting.5.rst b/docs/source/guides/admin-guides/references/man5/monsetting.5.rst index 5718e62e6..d14541ee0 100644 --- a/docs/source/guides/admin-guides/references/man5/monsetting.5.rst +++ b/docs/source/guides/admin-guides/references/man5/monsetting.5.rst @@ -38,7 +38,7 @@ monsetting Attributes: \ **name**\ - The name of the mornitoring plug-in module. The plug-in must be put in /lib/perl/xCAT_monitoring/. See the man page for monstart for details. + The name of the monitoring plug-in module. The plug-in must be put in /lib/perl/xCAT_monitoring/. See the man page for monstart for details. diff --git a/docs/source/guides/admin-guides/references/man5/mp.5.rst b/docs/source/guides/admin-guides/references/man5/mp.5.rst index 94ae534e0..ee046aee4 100644 --- a/docs/source/guides/admin-guides/references/man5/mp.5.rst +++ b/docs/source/guides/admin-guides/references/man5/mp.5.rst @@ -44,7 +44,7 @@ mp Attributes: \ **mpa**\ - The managment module used to control this blade. + The management module used to control this blade. diff --git a/docs/source/guides/admin-guides/references/man5/nics.5.rst b/docs/source/guides/admin-guides/references/man5/nics.5.rst index 6b3e28c29..cf4aab58c 100644 --- a/docs/source/guides/admin-guides/references/man5/nics.5.rst +++ b/docs/source/guides/admin-guides/references/man5/nics.5.rst @@ -58,7 +58,7 @@ nics Attributes: Comma-separated list of hostname suffixes per NIC. If only one ip address is associated with each NIC: !,!,..., for example, eth0!-eth0,ib0!-ib0 - If multiple ip addresses are associcated with each NIC: + If multiple ip addresses are associated with each NIC: !|,!|,..., for example, eth0!-eth0|-eth0-ipv6,ib0!-ib0|-ib0-ipv6. The xCAT object definition commands support to use nichostnamesuffixes. as the sub attributes. Note: According to DNS rules a hostname must be a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-),and period (.). When you are specifying "nichostnamesuffixes" or "nicaliases" make sure the resulting hostnames will conform to this naming convention @@ -70,7 +70,7 @@ nics Attributes: Comma-separated list of hostname prefixes per NIC. If only one ip address is associated with each NIC: !,!,..., for example, eth0!eth0-,ib0!ib- - If multiple ip addresses are associcated with each NIC: + If multiple ip addresses are associated with each NIC: !|,!|,..., for example, eth0!eth0-|eth0-ipv6i-,ib0!ib-|ib-ipv6-. The xCAT object definition commands support to use nichostnameprefixes. as the sub attributes. Note: According to DNS rules a hostname must be a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-),and period (.). When you are specifying "nichostnameprefixes" or "nicaliases" make sure the resulting hostnames will conform to this naming convention diff --git a/docs/source/guides/admin-guides/references/man5/nodelist.5.rst b/docs/source/guides/admin-guides/references/man5/nodelist.5.rst index 8c81ea740..25bf8c377 100644 --- a/docs/source/guides/admin-guides/references/man5/nodelist.5.rst +++ b/docs/source/guides/admin-guides/references/man5/nodelist.5.rst @@ -50,7 +50,7 @@ nodelist Attributes: \ **status**\ - The current status of this node. This attribute will be set by xCAT software. Valid values: defined, booting, netbooting, booted, discovering, configuring, installing, alive, standingby, powering-off, unreachable. If blank, defined is assumed. The possible status change sequenses are: For installaton: defined->[discovering]->[configuring]->[standingby]->installing->booting->booted->[alive], For diskless deployment: defined->[discovering]->[configuring]->[standingby]->netbooting->booted->[alive], For booting: [alive/unreachable]->booting->[alive], For powering off: [alive]->powering-off->[unreachable], For monitoring: alive->unreachable. Discovering and configuring are for x Series dicovery process. Alive and unreachable are set only when there is a monitoring plug-in start monitor the node status for xCAT. Please note that the status values will not reflect the real node status if you change the state of the node from outside of xCAT (i.e. power off the node using HMC GUI). + The current status of this node. This attribute will be set by xCAT software. Valid values: defined, booting, netbooting, booted, discovering, configuring, installing, alive, standingby, powering-off, unreachable. If blank, defined is assumed. The possible status change sequences are: For installation: defined->[discovering]->[configuring]->[standingby]->installing->booting->booted->[alive], For diskless deployment: defined->[discovering]->[configuring]->[standingby]->netbooting->booted->[alive], For booting: [alive/unreachable]->booting->[alive], For powering off: [alive]->powering-off->[unreachable], For monitoring: alive->unreachable. Discovering and configuring are for x Series discovery process. Alive and unreachable are set only when there is a monitoring plug-in start monitor the node status for xCAT. Please note that the status values will not reflect the real node status if you change the state of the node from outside of xCAT (i.e. power off the node using HMC GUI). diff --git a/docs/source/guides/admin-guides/references/man5/osimage.5.rst b/docs/source/guides/admin-guides/references/man5/osimage.5.rst index 283c0c0eb..968b2f443 100644 --- a/docs/source/guides/admin-guides/references/man5/osimage.5.rst +++ b/docs/source/guides/admin-guides/references/man5/osimage.5.rst @@ -122,7 +122,7 @@ osimage Attributes: \ **postscripts**\ - Comma separated list of scripts that should be run on this image after diskful installation or diskless boot. For installation of RedHat, CentOS, Fedora, the scripts will be run before the reboot. For installation of SLES, the scripts will be run after the reboot but before the init.d process. For diskless deployment, the scripts will be run at the init.d time, and xCAT will automatically add the list of scripts from the postbootscripts attribute to run after postscripts list. For installation of AIX, the scripts will run after the reboot and acts the same as the postbootscripts attribute. For AIX, use the postbootscripts attribute. See the site table runbootscripts attribute. Support will be added in the future for the postscripts attribute to run the scripts before the reboot in AIX. + Comma separated list of scripts that should be run on this image after diskful installation or diskless boot. For installation of RedHat, CentOS, Fedora, the scripts will be run before the reboot. For installation of SLES, the scripts will be run after the reboot but before the init.d process. For diskless deployment, the scripts will be run at the init.d time, and xCAT will automatically add the list of scripts from the postbootscripts attribute to run after postscripts list. For installation of AIX, the scripts will run after the reboot and acts the same as the postbootscripts attribute. For AIX, use the postbootscripts attribute. See the site table runbootscripts attribute. diff --git a/docs/source/guides/admin-guides/references/man5/postscripts.5.rst b/docs/source/guides/admin-guides/references/man5/postscripts.5.rst index ed667890d..a87cd902c 100644 --- a/docs/source/guides/admin-guides/references/man5/postscripts.5.rst +++ b/docs/source/guides/admin-guides/references/man5/postscripts.5.rst @@ -44,7 +44,7 @@ postscripts Attributes: \ **postscripts**\ - Comma separated list of scripts that should be run on this node after diskful installation or diskless boot. Each script can take zero or more parameters. For example: "script1 p1 p2,script2,...". xCAT automatically adds the postscripts from the xcatdefaults.postscripts attribute of the table to run first on the nodes after install or diskless boot. For installation of RedHat, CentOS, Fedora, the scripts will be run before the reboot. For installation of SLES, the scripts will be run after the reboot but before the init.d process. For diskless deployment, the scripts will be run at the init.d time, and xCAT will automatically add the list of scripts from the postbootscripts attribute to run after postscripts list. For installation of AIX, the scripts will run after the reboot and acts the same as the postbootscripts attribute. For AIX, use the postbootscripts attribute. Support will be added in the future for the postscripts attribute to run the scripts before the reboot in AIX. + Comma separated list of scripts that should be run on this node after diskful installation or diskless boot. Each script can take zero or more parameters. For example: "script1 p1 p2,script2,...". xCAT automatically adds the postscripts from the xcatdefaults.postscripts attribute of the table to run first on the nodes after install or diskless boot. For installation of RedHat, CentOS, Fedora, the scripts will be run before the reboot. For installation of SLES, the scripts will be run after the reboot but before the init.d process. For diskless deployment, the scripts will be run at the init.d time, and xCAT will automatically add the list of scripts from the postbootscripts attribute to run after postscripts list. For installation of AIX, the scripts will run after the reboot and acts the same as the postbootscripts attribute. For AIX, use the postbootscripts attribute. diff --git a/docs/source/guides/admin-guides/references/man5/routes.5.rst b/docs/source/guides/admin-guides/references/man5/routes.5.rst index 755c35322..b84fa965a 100644 --- a/docs/source/guides/admin-guides/references/man5/routes.5.rst +++ b/docs/source/guides/admin-guides/references/man5/routes.5.rst @@ -27,7 +27,7 @@ DESCRIPTION *********** -Describes the additional routes needed to be setup in the os routing table. These routes usually are used to connect the management node to the compute node using the servie node as gateway. +Describes the additional routes needed to be setup in the os routing table. These routes usually are used to connect the management node to the compute node using the service node as gateway. ****************** diff --git a/docs/source/guides/admin-guides/references/man5/site.5.rst b/docs/source/guides/admin-guides/references/man5/site.5.rst index 6c0495904..35c59d2b7 100644 --- a/docs/source/guides/admin-guides/references/man5/site.5.rst +++ b/docs/source/guides/admin-guides/references/man5/site.5.rst @@ -307,7 +307,7 @@ site Attributes: currently supported values: '0': disable debug mode '1': enable basic debug mode - '2': enalbe expert debug mode + '2': enable expert debug mode For the details on 'basic debug mode' and 'expert debug mode', please refer to xCAT documentation. diff --git a/docs/source/guides/admin-guides/references/man5/statelite.5.rst b/docs/source/guides/admin-guides/references/man5/statelite.5.rst index 35559be56..3b9f6e1b0 100644 --- a/docs/source/guides/admin-guides/references/man5/statelite.5.rst +++ b/docs/source/guides/admin-guides/references/man5/statelite.5.rst @@ -50,7 +50,7 @@ statelite Attributes: \ **statemnt**\ - The persistant read/write area where a node's persistent files will be written to, e.g: 10.0.0.1/state/. The node name will be automatically added to the pathname, so 10.0.0.1:/state, will become 10.0.0.1:/state/. + The persistent read/write area where a node's persistent files will be written to, e.g: 10.0.0.1/state/. The node name will be automatically added to the pathname, so 10.0.0.1:/state, will become 10.0.0.1:/state/. diff --git a/docs/source/guides/admin-guides/references/man5/switches.5.rst b/docs/source/guides/admin-guides/references/man5/switches.5.rst index 7dc675fef..5cdb6d33e 100644 --- a/docs/source/guides/admin-guides/references/man5/switches.5.rst +++ b/docs/source/guides/admin-guides/references/man5/switches.5.rst @@ -56,7 +56,7 @@ switches Attributes: \ **password**\ - The password strinng for SNMPv3 or community string for SNMPv1/SNMPv2. Falls back to passwd table, and site snmpc value if using SNMPv1/SNMPv2. + The password string for SNMPv3 or community string for SNMPv1/SNMPv2. Falls back to passwd table, and site snmpc value if using SNMPv1/SNMPv2. @@ -92,13 +92,13 @@ switches Attributes: \ **protocol**\ - Prorocol for running remote commands for the switch. The valid values are: ssh, telnet. ssh is the default. If the sshusername is blank, the username, password and protocol will be retrieved from the passwd table with "switch" as the key. The passwd.comments attribute is used for protocol. + Protocol for running remote commands for the switch. The valid values are: ssh, telnet. ssh is the default. If the sshusername is blank, the username, password and protocol will be retrieved from the passwd table with "switch" as the key. The passwd.comments attribute is used for protocol. \ **switchtype**\ - The type of switch. It is used to identify the file name that implements the functions for this swithc. The valid values are: Mellanox, Cisco, BNT and Juniper. + The type of switch. It is used to identify the file name that implements the functions for this switch. The valid values are: Mellanox, Cisco, BNT and Juniper. diff --git a/docs/source/guides/admin-guides/references/man5/vm.5.rst b/docs/source/guides/admin-guides/references/man5/vm.5.rst index 1b079118b..f16c9f3d2 100644 --- a/docs/source/guides/admin-guides/references/man5/vm.5.rst +++ b/docs/source/guides/admin-guides/references/man5/vm.5.rst @@ -86,7 +86,7 @@ vm Attributes: \ **cfgstore**\ - Optional location for persistant storage separate of emulated hard drives for virtualization solutions that require persistant store to place configuration data + Optional location for persistent storage separate of emulated hard drives for virtualization solutions that require persistant store to place configuration data @@ -191,7 +191,7 @@ vm Attributes: \ **othersettings**\ - This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:"vcpupin:'0-15,^8'",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0',the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively,the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running \ **virsh nodedev-list**\ on the host. + This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:"vcpupin:'0-15,^8'",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0',the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively, the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running \ **virsh nodedev-list**\ on the host. diff --git a/docs/source/guides/admin-guides/references/man5/vpd.5.rst b/docs/source/guides/admin-guides/references/man5/vpd.5.rst index b4ee11883..eabf05441 100644 --- a/docs/source/guides/admin-guides/references/man5/vpd.5.rst +++ b/docs/source/guides/admin-guides/references/man5/vpd.5.rst @@ -62,7 +62,7 @@ vpd Attributes: \ **asset**\ - A field for administators to use to correlate inventory numbers they may have to accomodate + A field for administrators to use to correlate inventory numbers they may have to accommodate diff --git a/docs/source/guides/admin-guides/references/man5/xcatdb.5.rst b/docs/source/guides/admin-guides/references/man5/xcatdb.5.rst index e92b439c9..2e15caff4 100644 --- a/docs/source/guides/admin-guides/references/man5/xcatdb.5.rst +++ b/docs/source/guides/admin-guides/references/man5/xcatdb.5.rst @@ -437,13 +437,13 @@ kitrepo(5)|kitrepo.5 kvm_masterdata(5)|kvm_masterdata.5 - Persistant store for KVM plugin for masters + Persistent store for KVM plugin for masters kvm_nodedata(5)|kvm_nodedata.5 - Persistant store for KVM plugin, not intended for manual modification. + Persistent store for KVM plugin, not intended for manual modification. @@ -473,7 +473,7 @@ mac(5)|mac.5 mic(5)|mic.5 - The host, slot id and configuraton of the mic (Many Integrated Core). + The host, slot id and configuration of the mic (Many Integrated Core). @@ -641,7 +641,7 @@ rack(5)|rack.5 routes(5)|routes.5 - Describes the additional routes needed to be setup in the os routing table. These routes usually are used to connect the management node to the compute node using the servie node as gateway. + Describes the additional routes needed to be setup in the os routing table. These routes usually are used to connect the management node to the compute node using the service node as gateway. diff --git a/docs/source/guides/admin-guides/references/man7/boottarget.7.rst b/docs/source/guides/admin-guides/references/man7/boottarget.7.rst index fa8729eb7..be767a2fc 100644 --- a/docs/source/guides/admin-guides/references/man7/boottarget.7.rst +++ b/docs/source/guides/admin-guides/references/man7/boottarget.7.rst @@ -19,7 +19,7 @@ SYNOPSIS ******** -\ **boottarget Attributes:**\ \ **\ +\ **boottarget Attributes:**\ \ *bprofile*\ , \ *comments*\ , \ *initrd*\ , \ *kcmdline*\ , \ *kernel*\ *********** @@ -39,6 +39,36 @@ boottarget Attributes: +\ **bprofile**\ (boottarget.bprofile) + + All nodes with a nodetype.profile value equal to this value and nodetype.os set to "boottarget", will use the associated kernel, initrd, and kcmdline. + + + +\ **comments**\ (boottarget.comments) + + Any user-written notes. + + + +\ **initrd**\ (boottarget.initrd) + + The initial ramdisk image that network boot actions should use (could be a DOS floppy or hard drive image if using memdisk as kernel) + + + +\ **kcmdline**\ (boottarget.kcmdline) + + Arguments to be passed to the kernel + + + +\ **kernel**\ (boottarget.kernel) + + The kernel that network boot actions should currently acquire and use. Note this could be a chained boot loader such as memdisk or a non-linux boot loader + + + ******** SEE ALSO diff --git a/docs/source/guides/admin-guides/references/man7/group.7.rst b/docs/source/guides/admin-guides/references/man7/group.7.rst index c3b62073b..f2d407860 100644 --- a/docs/source/guides/admin-guides/references/man7/group.7.rst +++ b/docs/source/guides/admin-guides/references/man7/group.7.rst @@ -59,7 +59,7 @@ group Attributes: \ **bmc**\ (ipmi.bmc) - The hostname of the BMC adapater. + The hostname of the BMC adapter. @@ -225,7 +225,7 @@ group Attributes: \ **dockerflag**\ (vm.othersettings) - This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:"vcpupin:'0-15,^8'",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0',the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively,the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running \ **virsh nodedev-list**\ on the host. + This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:"vcpupin:'0-15,^8'",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0',the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively, the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running \ **virsh nodedev-list**\ on the host. @@ -503,7 +503,7 @@ group Attributes: \ **mpa**\ (mp.mpa) - The managment module used to control this blade. + The management module used to control this blade. @@ -586,7 +586,7 @@ group Attributes: Comma-separated list of hostname prefixes per NIC. If only one ip address is associated with each NIC: !,!,..., for example, eth0!eth0-,ib0!ib- - If multiple ip addresses are associcated with each NIC: + If multiple ip addresses are associated with each NIC: !|,!|,..., for example, eth0!eth0-|eth0-ipv6i-,ib0!ib-|ib-ipv6-. The xCAT object definition commands support to use nichostnameprefixes. as the sub attributes. Note: According to DNS rules a hostname must be a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-),and period (.). When you are specifying "nichostnameprefixes" or "nicaliases" make sure the resulting hostnames will conform to this naming convention @@ -598,7 +598,7 @@ group Attributes: Comma-separated list of hostname suffixes per NIC. If only one ip address is associated with each NIC: !,!,..., for example, eth0!-eth0,ib0!-ib0 - If multiple ip addresses are associcated with each NIC: + If multiple ip addresses are associated with each NIC: !|,!|,..., for example, eth0!-eth0|-eth0-ipv6,ib0!-ib0|-ib0-ipv6. The xCAT object definition commands support to use nichostnamesuffixes. as the sub attributes. Note: According to DNS rules a hostname must be a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-),and period (.). When you are specifying "nichostnamesuffixes" or "nicaliases" make sure the resulting hostnames will conform to this naming convention @@ -685,7 +685,7 @@ group Attributes: \ **ou**\ (domain.ou) - For an LDAP described machine account (i.e. Active Directory), the orginaztional unit to place the system. If not set, defaults to cn=Computers,dc=your,dc=domain + For an LDAP described machine account (i.e. Active Directory), the organizational unit to place the system. If not set, defaults to cn=Computers,dc=your,dc=domain @@ -751,7 +751,7 @@ group Attributes: \ **postscripts**\ (postscripts.postscripts) - Comma separated list of scripts that should be run on this node after diskful installation or diskless boot. Each script can take zero or more parameters. For example: "script1 p1 p2,script2,...". xCAT automatically adds the postscripts from the xcatdefaults.postscripts attribute of the table to run first on the nodes after install or diskless boot. For installation of RedHat, CentOS, Fedora, the scripts will be run before the reboot. For installation of SLES, the scripts will be run after the reboot but before the init.d process. For diskless deployment, the scripts will be run at the init.d time, and xCAT will automatically add the list of scripts from the postbootscripts attribute to run after postscripts list. For installation of AIX, the scripts will run after the reboot and acts the same as the postbootscripts attribute. For AIX, use the postbootscripts attribute. Support will be added in the future for the postscripts attribute to run the scripts before the reboot in AIX. + Comma separated list of scripts that should be run on this node after diskful installation or diskless boot. Each script can take zero or more parameters. For example: "script1 p1 p2,script2,...". xCAT automatically adds the postscripts from the xcatdefaults.postscripts attribute of the table to run first on the nodes after install or diskless boot. For installation of RedHat, CentOS, Fedora, the scripts will be run before the reboot. For installation of SLES, the scripts will be run after the reboot but before the init.d process. For diskless deployment, the scripts will be run at the init.d time, and xCAT will automatically add the list of scripts from the postbootscripts attribute to run after postscripts list. For installation of AIX, the scripts will run after the reboot and acts the same as the postbootscripts attribute. For AIX, use the postbootscripts attribute. @@ -820,7 +820,7 @@ group Attributes: \ **protocol**\ (switches.protocol) - Prorocol for running remote commands for the switch. The valid values are: ssh, telnet. ssh is the default. If the sshusername is blank, the username, password and protocol will be retrieved from the passwd table with "switch" as the key. The passwd.comments attribute is used for protocol. + Protocol for running remote commands for the switch. The valid values are: ssh, telnet. ssh is the default. If the sshusername is blank, the username, password and protocol will be retrieved from the passwd table with "switch" as the key. The passwd.comments attribute is used for protocol. @@ -990,7 +990,7 @@ group Attributes: \ **snmppassword**\ (switches.password) - The password strinng for SNMPv3 or community string for SNMPv1/SNMPv2. Falls back to passwd table, and site snmpc value if using SNMPv1/SNMPv2. + The password string for SNMPv3 or community string for SNMPv1/SNMPv2. Falls back to passwd table, and site snmpc value if using SNMPv1/SNMPv2. @@ -1064,7 +1064,7 @@ group Attributes: \ **switchtype**\ (switches.switchtype) - The type of switch. It is used to identify the file name that implements the functions for this swithc. The valid values are: Mellanox, Cisco, BNT and Juniper. + The type of switch. It is used to identify the file name that implements the functions for this switch. The valid values are: Mellanox, Cisco, BNT and Juniper. @@ -1160,7 +1160,7 @@ group Attributes: \ **vmcfgstore**\ (vm.cfgstore) - Optional location for persistant storage separate of emulated hard drives for virtualization solutions that require persistant store to place configuration data + Optional location for persistent storage separate of emulated hard drives for virtualization solutions that require persistant store to place configuration data @@ -1214,7 +1214,7 @@ group Attributes: \ **vmothersetting**\ (vm.othersettings) - This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:"vcpupin:'0-15,^8'",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0',the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively,the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running \ **virsh nodedev-list**\ on the host. + This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:"vcpupin:'0-15,^8'",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0',the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively, the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running \ **virsh nodedev-list**\ on the host. diff --git a/docs/source/guides/admin-guides/references/man7/monitoring.7.rst b/docs/source/guides/admin-guides/references/man7/monitoring.7.rst index b77bae541..8c7953e7f 100644 --- a/docs/source/guides/admin-guides/references/man7/monitoring.7.rst +++ b/docs/source/guides/admin-guides/references/man7/monitoring.7.rst @@ -53,7 +53,7 @@ monitoring Attributes: \ **name**\ (monitoring.name) - The name of the mornitoring plug-in module. The plug-in must be put in /lib/perl/xCAT_monitoring/. See the man page for monstart for details. + The name of the monitoring plug-in module. The plug-in must be put in /lib/perl/xCAT_monitoring/. See the man page for monstart for details. diff --git a/docs/source/guides/admin-guides/references/man7/node.7.rst b/docs/source/guides/admin-guides/references/man7/node.7.rst index a0484fe5d..19171544f 100644 --- a/docs/source/guides/admin-guides/references/man7/node.7.rst +++ b/docs/source/guides/admin-guides/references/man7/node.7.rst @@ -71,7 +71,7 @@ node Attributes: \ **bmc**\ (ipmi.bmc) - The hostname of the BMC adapater. + The hostname of the BMC adapter. @@ -237,7 +237,7 @@ node Attributes: \ **dockerflag**\ (vm.othersettings) - This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:"vcpupin:'0-15,^8'",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0',the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively,the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running \ **virsh nodedev-list**\ on the host. + This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:"vcpupin:'0-15,^8'",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0',the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively, the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running \ **virsh nodedev-list**\ on the host. @@ -503,7 +503,7 @@ node Attributes: \ **mpa**\ (mp.mpa) - The managment module used to control this blade. + The management module used to control this blade. @@ -586,7 +586,7 @@ node Attributes: Comma-separated list of hostname prefixes per NIC. If only one ip address is associated with each NIC: !,!,..., for example, eth0!eth0-,ib0!ib- - If multiple ip addresses are associcated with each NIC: + If multiple ip addresses are associated with each NIC: !|,!|,..., for example, eth0!eth0-|eth0-ipv6i-,ib0!ib-|ib-ipv6-. The xCAT object definition commands support to use nichostnameprefixes. as the sub attributes. Note: According to DNS rules a hostname must be a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-),and period (.). When you are specifying "nichostnameprefixes" or "nicaliases" make sure the resulting hostnames will conform to this naming convention @@ -598,7 +598,7 @@ node Attributes: Comma-separated list of hostname suffixes per NIC. If only one ip address is associated with each NIC: !,!,..., for example, eth0!-eth0,ib0!-ib0 - If multiple ip addresses are associcated with each NIC: + If multiple ip addresses are associated with each NIC: !|,!|,..., for example, eth0!-eth0|-eth0-ipv6,ib0!-ib0|-ib0-ipv6. The xCAT object definition commands support to use nichostnamesuffixes. as the sub attributes. Note: According to DNS rules a hostname must be a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-),and period (.). When you are specifying "nichostnamesuffixes" or "nicaliases" make sure the resulting hostnames will conform to this naming convention @@ -691,7 +691,7 @@ node Attributes: \ **ou**\ (domain.ou) - For an LDAP described machine account (i.e. Active Directory), the orginaztional unit to place the system. If not set, defaults to cn=Computers,dc=your,dc=domain + For an LDAP described machine account (i.e. Active Directory), the organizational unit to place the system. If not set, defaults to cn=Computers,dc=your,dc=domain @@ -757,7 +757,7 @@ node Attributes: \ **postscripts**\ (postscripts.postscripts) - Comma separated list of scripts that should be run on this node after diskful installation or diskless boot. Each script can take zero or more parameters. For example: "script1 p1 p2,script2,...". xCAT automatically adds the postscripts from the xcatdefaults.postscripts attribute of the table to run first on the nodes after install or diskless boot. For installation of RedHat, CentOS, Fedora, the scripts will be run before the reboot. For installation of SLES, the scripts will be run after the reboot but before the init.d process. For diskless deployment, the scripts will be run at the init.d time, and xCAT will automatically add the list of scripts from the postbootscripts attribute to run after postscripts list. For installation of AIX, the scripts will run after the reboot and acts the same as the postbootscripts attribute. For AIX, use the postbootscripts attribute. Support will be added in the future for the postscripts attribute to run the scripts before the reboot in AIX. + Comma separated list of scripts that should be run on this node after diskful installation or diskless boot. Each script can take zero or more parameters. For example: "script1 p1 p2,script2,...". xCAT automatically adds the postscripts from the xcatdefaults.postscripts attribute of the table to run first on the nodes after install or diskless boot. For installation of RedHat, CentOS, Fedora, the scripts will be run before the reboot. For installation of SLES, the scripts will be run after the reboot but before the init.d process. For diskless deployment, the scripts will be run at the init.d time, and xCAT will automatically add the list of scripts from the postbootscripts attribute to run after postscripts list. For installation of AIX, the scripts will run after the reboot and acts the same as the postbootscripts attribute. For AIX, use the postbootscripts attribute. @@ -832,7 +832,7 @@ node Attributes: \ **protocol**\ (switches.protocol) - Prorocol for running remote commands for the switch. The valid values are: ssh, telnet. ssh is the default. If the sshusername is blank, the username, password and protocol will be retrieved from the passwd table with "switch" as the key. The passwd.comments attribute is used for protocol. + Protocol for running remote commands for the switch. The valid values are: ssh, telnet. ssh is the default. If the sshusername is blank, the username, password and protocol will be retrieved from the passwd table with "switch" as the key. The passwd.comments attribute is used for protocol. @@ -1002,7 +1002,7 @@ node Attributes: \ **snmppassword**\ (switches.password) - The password strinng for SNMPv3 or community string for SNMPv1/SNMPv2. Falls back to passwd table, and site snmpc value if using SNMPv1/SNMPv2. + The password string for SNMPv3 or community string for SNMPv1/SNMPv2. Falls back to passwd table, and site snmpc value if using SNMPv1/SNMPv2. @@ -1026,7 +1026,7 @@ node Attributes: \ **status**\ (nodelist.status) - The current status of this node. This attribute will be set by xCAT software. Valid values: defined, booting, netbooting, booted, discovering, configuring, installing, alive, standingby, powering-off, unreachable. If blank, defined is assumed. The possible status change sequenses are: For installaton: defined->[discovering]->[configuring]->[standingby]->installing->booting->booted->[alive], For diskless deployment: defined->[discovering]->[configuring]->[standingby]->netbooting->booted->[alive], For booting: [alive/unreachable]->booting->[alive], For powering off: [alive]->powering-off->[unreachable], For monitoring: alive->unreachable. Discovering and configuring are for x Series dicovery process. Alive and unreachable are set only when there is a monitoring plug-in start monitor the node status for xCAT. Please note that the status values will not reflect the real node status if you change the state of the node from outside of xCAT (i.e. power off the node using HMC GUI). + The current status of this node. This attribute will be set by xCAT software. Valid values: defined, booting, netbooting, booted, discovering, configuring, installing, alive, standingby, powering-off, unreachable. If blank, defined is assumed. The possible status change sequences are: For installation: defined->[discovering]->[configuring]->[standingby]->installing->booting->booted->[alive], For diskless deployment: defined->[discovering]->[configuring]->[standingby]->netbooting->booted->[alive], For booting: [alive/unreachable]->booting->[alive], For powering off: [alive]->powering-off->[unreachable], For monitoring: alive->unreachable. Discovering and configuring are for x Series discovery process. Alive and unreachable are set only when there is a monitoring plug-in start monitor the node status for xCAT. Please note that the status values will not reflect the real node status if you change the state of the node from outside of xCAT (i.e. power off the node using HMC GUI). @@ -1088,7 +1088,7 @@ node Attributes: \ **switchtype**\ (switches.switchtype) - The type of switch. It is used to identify the file name that implements the functions for this swithc. The valid values are: Mellanox, Cisco, BNT and Juniper. + The type of switch. It is used to identify the file name that implements the functions for this switch. The valid values are: Mellanox, Cisco, BNT and Juniper. @@ -1196,7 +1196,7 @@ node Attributes: \ **vmcfgstore**\ (vm.cfgstore) - Optional location for persistant storage separate of emulated hard drives for virtualization solutions that require persistant store to place configuration data + Optional location for persistent storage separate of emulated hard drives for virtualization solutions that require persistant store to place configuration data @@ -1250,7 +1250,7 @@ node Attributes: \ **vmothersetting**\ (vm.othersettings) - This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:"vcpupin:'0-15,^8'",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0',the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively,the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running \ **virsh nodedev-list**\ on the host. + This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:"vcpupin:'0-15,^8'",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0',the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively, the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running \ **virsh nodedev-list**\ on the host. diff --git a/docs/source/guides/admin-guides/references/man7/osimage.7.rst b/docs/source/guides/admin-guides/references/man7/osimage.7.rst index 308479527..a88927474 100644 --- a/docs/source/guides/admin-guides/references/man7/osimage.7.rst +++ b/docs/source/guides/admin-guides/references/man7/osimage.7.rst @@ -261,7 +261,7 @@ osimage Attributes: \ **otherpkglist**\ (linuximage.otherpkglist) - The fully qualified name of the file that stores non-distro package lists that will be included in the image. It could be set multiple paths.The multiple paths must be seperated by ",". + The fully qualified name of the file that stores non-distro package lists that will be included in the image. It could be set to multiple paths. The multiple paths must be separated by ",". @@ -295,7 +295,7 @@ osimage Attributes: \ **pkgdir**\ (linuximage.pkgdir) - The name of the directory where the distro packages are stored. It could be set multiple paths.The multiple paths must be seperated by ",". The first path in the value of osimage.pkgdir must be the OS base pkg dir path, such as pkgdir=/install/rhels6.2/x86_64,/install/updates . In the os base pkg path, there are default repository data. And in the other pkg path(s), the users should make sure there are repository data. If not, use "createrepo" command to create them. For ubuntu, multiple mirrors can be specified in the pkgdir attribute, the mirrors must be prefixed by the protocol(http/ssh) and delimited with "," between each other. + The name of the directory where the distro packages are stored. It could be set to multiple paths. The multiple paths must be separated by ",". The first path in the value of osimage.pkgdir must be the OS base pkg dir path, such as pkgdir=/install/rhels6.2/x86_64,/install/updates . In the os base pkg path, there are default repository data. And in the other pkg path(s), the users should make sure there are repository data. If not, use "createrepo" command to create them. For ubuntu, multiple mirrors can be specified in the pkgdir attribute, the mirrors must be prefixed by the protocol(http/ssh) and delimited with "," between each other. @@ -313,13 +313,13 @@ osimage Attributes: \ **postinstall**\ (linuximage.postinstall) - The fully qualified name of the script file that will be run at the end of the genimage command. It could be set multiple paths.The multiple paths must be seperated by ",". It is used for diskless image only. + The fully qualified name of the script file that will be run at the end of the genimage command. It could be set to multiple paths. The multiple paths must be separated by ",". It is used for diskless image only. \ **postscripts**\ (osimage.postscripts) - Comma separated list of scripts that should be run on this image after diskful installation or diskless boot. For installation of RedHat, CentOS, Fedora, the scripts will be run before the reboot. For installation of SLES, the scripts will be run after the reboot but before the init.d process. For diskless deployment, the scripts will be run at the init.d time, and xCAT will automatically add the list of scripts from the postbootscripts attribute to run after postscripts list. For installation of AIX, the scripts will run after the reboot and acts the same as the postbootscripts attribute. For AIX, use the postbootscripts attribute. See the site table runbootscripts attribute. Support will be added in the future for the postscripts attribute to run the scripts before the reboot in AIX. + Comma separated list of scripts that should be run on this image after diskful installation or diskless boot. For installation of RedHat, CentOS, Fedora, the scripts will be run before the reboot. For installation of SLES, the scripts will be run after the reboot but before the init.d process. For diskless deployment, the scripts will be run at the init.d time, and xCAT will automatically add the list of scripts from the postbootscripts attribute to run after postscripts list. For installation of AIX, the scripts will run after the reboot and acts the same as the postbootscripts attribute. For AIX, use the postbootscripts attribute. See the site table runbootscripts attribute. diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index c1541f6d2..cfc75585c 100755 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -50,7 +50,7 @@ use xCAT::ExtTab; descriptions => { node => 'The name of the node or group that will use this location.', image => "Reserved for future development, not used. ", - statemnt => "The persistant read/write area where a node's persistent files will be written to, e.g: 10.0.0.1/state/. The node name will be automatically added to the pathname, so 10.0.0.1:/state, will become 10.0.0.1:/state/.", + statemnt => "The persistent read/write area where a node's persistent files will be written to, e.g: 10.0.0.1/state/. The node name will be automatically added to the pathname, so 10.0.0.1:/state, will become 10.0.0.1:/state/.", mntopts => "A comma-separated list of options to use when mounting the persistent directory. (Ex. 'soft') The default is to do a 'hard' mount. ", comments => 'Any user-written notes.', disable => "Set to 'yes' or '1' to comment out this row.", @@ -70,7 +70,7 @@ use xCAT::ExtTab; # domain => 'The name of the domain it is a member of, such as "example.com". Defaults to domain value from the site table', # the above column is unimplemented by anything, so leave it out for this pass - ou => 'For an LDAP described machine account (i.e. Active Directory), the orginaztional unit to place the system. If not set, defaults to cn=Computers,dc=your,dc=domain', + ou => 'For an LDAP described machine account (i.e. Active Directory), the organizational unit to place the system. If not set, defaults to cn=Computers,dc=your,dc=domain', authdomain => 'If a node should participate in an AD domain or Kerberos realm distinct from domain indicated in site, this field can be used to specify that', adminuser => 'Allow a node specific indication of Administrative user. Most will want to just use passwd table to indicate this once rather than by node.', adminpassword => 'Allow a node specific indication of Administrative user password for the domain. Most will want to ignore this in favor of passwd table.', @@ -87,7 +87,7 @@ use xCAT::ExtTab; cols => [qw(node xml comments disable)], keys => [qw(node)], required => [qw(node)], - table_desc => 'Persistant store for KVM plugin, not intended for manual modification.', + table_desc => 'Persistent store for KVM plugin, not intended for manual modification.', types => { xml => 'VARCHAR(16000)', }, @@ -102,7 +102,7 @@ use xCAT::ExtTab; cols => [qw(name xml comments disable)], keys => [qw(name)], nodecol => 'name', - table_desc => 'Persistant store for KVM plugin for masters', + table_desc => 'Persistent store for KVM plugin for masters', types => { xml => 'VARCHAR(16000)', }, @@ -205,7 +205,7 @@ use xCAT::ExtTab; 'migrationdest' => 'A noderange representing candidate destinations for migration (i.e. similar systems, same SAN, or other criteria that xCAT can use', 'storage' => 'A list of storage files or devices to be used. i.e. dir:///cluster/vm/ or nfs:///path/to/folder/', 'storagemodel' => 'Model of storage devices to provide to guest', - 'cfgstore' => 'Optional location for persistant storage separate of emulated hard drives for virtualization solutions that require persistant store to place configuration data', + 'cfgstore' => 'Optional location for persistent storage separate of emulated hard drives for virtualization solutions that require persistant store to place configuration data', 'memory' => 'Megabytes of memory the VM currently should be set to.', 'master' => 'The name of a master image, if any, this virtual machine is linked to. This is generally set by clonevm and indicates the deletion of a master that would invalidate the storage of this virtual machine', 'cpus' => 'Number of CPUs the node should see.', @@ -226,7 +226,7 @@ use xCAT::ExtTab; 'vncport' => 'Tracks the current VNC display port (currently not meant to be set', 'textconsole' => 'Tracks the Psuedo-TTY that maps to the serial port or console of a VM', 'powerstate' => "This flag is used by xCAT to track the last known power state of the VM.", - 'othersettings' => "This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:\"vcpupin:'0-15,^8'\",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0',the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively,the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running B on the host.", + 'othersettings' => "This allows specifying a semicolon delimited list of key->value pairs to include in a vmx file of VMware or KVM. For partitioning on normal power machines, this option is used to specify the hugepage and/or bsr information, the value is like:'hugepage:1,bsr=2'. For KVM cpu pinning, this option is used to specify the physical cpu set on the host, the value is like:\"vcpupin:'0-15,^8'\",Its syntax is a comma separated list and a special markup using '-' and '^' (ex. '0-4', '0-3,^2') can also be allowed, the '-' denotes the range and the '^' denotes exclusive. For KVM memory binding, the value is like:'membind:0', restrict a guest to allocate memory from the specified set of NUMA nodes. For PCI passthrough, the value is like:'devpassthrough:pci_0001_01_00_0,pci_0000_03_00_0',the PCI devices are assigned to a virtual machine, and the virtual machine can use this I/O exclusively, the devices list are a list of PCI device names delimited with comma, the PCI device names can be obtained by running B on the host.", 'guestostype' => "This allows administrator to specify an identifier for OS to pass through to virtualization stack. Normally this should be ignored as xCAT will translate from nodetype.os rather than requiring this field be used\n", 'beacon' => "This flag is used by xCAT to track the state of the identify LED with respect to the VM.", 'datacenter' => "Optionally specify a datacenter for the VM to exist in (only applicable to VMWare)", @@ -373,7 +373,7 @@ passed as argument rather than by table value', node => 'The node name or group name.', nodedep => 'Comma-separated list of nodes or node groups it is dependent on.', msdelay => 'How long to wait between operating on the dependent nodes and the primary nodes.', - cmd => 'Comma-seperated list of which operation this dependency applies to.', + cmd => 'Comma-separated list of which operation this dependency applies to.', comments => 'Any user-written notes.', disable => "Set to 'yes' or '1' to comment out this row.", }, @@ -397,7 +397,7 @@ passed as argument rather than by table value', 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.', + bmc => 'The hostname of the BMC adapter.', bmcport => 'In systems with selectable shared/dedicated ethernet ports, this parameter can be used to specify the preferred port. 0 means use the shared port, 1 means dedicated, blank is to not assign. The following special cases exist for IBM System x servers: @@ -483,7 +483,7 @@ passed as argument rather than by table value', required => [qw(name)], table_desc => 'Controls what external monitoring tools xCAT sets up and uses. Entries should be added and removed from this table using the provided xCAT commands monstart and monstop.', descriptions => { - name => "The name of the mornitoring plug-in module. The plug-in must be put in $ENV{XCATROOT}/lib/perl/xCAT_monitoring/. See the man page for monstart for details.", + name => "The name of the monitoring plug-in module. The plug-in must be put in $ENV{XCATROOT}/lib/perl/xCAT_monitoring/. See the man page for monstart for details.", 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.", @@ -495,7 +495,7 @@ passed as argument rather than by table value', required => [qw(name key)], table_desc => 'Specifies the monitoring plug-in specific settings. These settings will be used by the monitoring plug-in to customize the behavior such as event filter, sample interval, responses etc. Entries should be added, removed or modified by chtab command. Entries can also be added or modified by the monstart command when a monitoring plug-in is brought up.', descriptions => { - name => "The name of the mornitoring plug-in module. The plug-in must be put in $ENV{XCATROOT}/lib/perl/xCAT_monitoring/. See the man page for monstart for details.", + name => "The name of the monitoring plug-in module. The plug-in must be put in $ENV{XCATROOT}/lib/perl/xCAT_monitoring/. See the man page for monstart for details.", key => 'Specifies the name of the attribute. The valid values are specified by each monitoring plug-in. Use "monls name -d" to get a list of valid keys.', value => 'Specifies the value of the attribute.', comments => 'Any user-written notes.', @@ -508,7 +508,7 @@ passed as argument rather than by table value', 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.', + mpa => 'The management module used to control this blade.', id => 'The slot number of this blade in the BladeCenter chassis.', nodetype => 'The hardware type for mp node. Valid values: mm,cmm, blade.', comments => 'Any user-written notes.', @@ -608,7 +608,7 @@ passed as argument rather than by table value', descriptions => { node => 'The hostname of a node in the cluster.', 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. Internal group names are designated by using __. For example, __Unmanaged, could be the internal name for a group of nodes that is not managed by xCAT. Admins should avoid using the __ characters when defining their groups.", - status => 'The current status of this node. This attribute will be set by xCAT software. Valid values: defined, booting, netbooting, booted, discovering, configuring, installing, alive, standingby, powering-off, unreachable. If blank, defined is assumed. The possible status change sequenses are: For installaton: defined->[discovering]->[configuring]->[standingby]->installing->booting->booted->[alive], For diskless deployment: defined->[discovering]->[configuring]->[standingby]->netbooting->booted->[alive], For booting: [alive/unreachable]->booting->[alive], For powering off: [alive]->powering-off->[unreachable], For monitoring: alive->unreachable. Discovering and configuring are for x Series dicovery process. Alive and unreachable are set only when there is a monitoring plug-in start monitor the node status for xCAT. Please note that the status values will not reflect the real node status if you change the state of the node from outside of xCAT (i.e. power off the node using HMC GUI).', + status => 'The current status of this node. This attribute will be set by xCAT software. Valid values: defined, booting, netbooting, booted, discovering, configuring, installing, alive, standingby, powering-off, unreachable. If blank, defined is assumed. The possible status change sequences are: For installation: defined->[discovering]->[configuring]->[standingby]->installing->booting->booted->[alive], For diskless deployment: defined->[discovering]->[configuring]->[standingby]->netbooting->booted->[alive], For booting: [alive/unreachable]->booting->[alive], For powering off: [alive]->powering-off->[unreachable], For monitoring: alive->unreachable. Discovering and configuring are for x Series discovery process. Alive and unreachable are set only when there is a monitoring plug-in start monitor the node status for xCAT. Please note that the status values will not reflect the real node status if you change the state of the node from outside of xCAT (i.e. power off the node using HMC GUI).', statustime => "The data and time when the status was updated.", appstatus => "A comma-delimited list of application status. For example: 'sshd=up,ftp=down,ll=down'", appstatustime => 'The date and time when appstatus was updated.', @@ -686,14 +686,14 @@ passed as argument rather than by table value', switch => 'The hostname/address of the switch to which the settings apply', snmpversion => 'The version to use to communicate with switch. SNMPv1 is assumed by default.', username => 'The username to use for SNMPv3 communication, ignored for SNMPv1', - password => 'The password strinng for SNMPv3 or community string for SNMPv1/SNMPv2. Falls back to passwd table, and site snmpc value if using SNMPv1/SNMPv2.', + password => 'The password string for SNMPv3 or community string for SNMPv1/SNMPv2. Falls back to passwd table, and site snmpc value if using SNMPv1/SNMPv2.', privacy => 'The privacy protocol to use for v3. xCAT will use authNoPriv if this is unspecified. DES is recommended to use if v3 enabled, as it is the most readily available.', auth => 'The authentication protocol to use for SNMPv3. SHA is assumed if v3 enabled and this is unspecified', linkports => 'The ports that connect to other switches. Currently, this column is only used by vlan configuration. The format is: "port_number:switch,port_number:switch...". Please refer to the switch table for details on how to specify the port numbers.', sshusername => 'The remote login user name. It can be for ssh or telnet. If it is for telnet, please set protocol to "telnet". If the sshusername is blank, the username, password and protocol will be retrieved from the passwd table with "switch" as the key.', sshpassword => 'The remote login password. It can be for ssh or telnet. If it is for telnet, please set protocol to "telnet". If the sshusername is blank, the username, password and protocol will be retrieved from the passwd table with "switch" as the key.', - protocol => 'Prorocol for running remote commands for the switch. The valid values are: ssh, telnet. ssh is the default. If the sshusername is blank, the username, password and protocol will be retrieved from the passwd table with "switch" as the key. The passwd.comments attribute is used for protocol.', - switchtype => 'The type of switch. It is used to identify the file name that implements the functions for this swithc. The valid values are: Mellanox, Cisco, BNT and Juniper.', + protocol => 'Protocol for running remote commands for the switch. The valid values are: ssh, telnet. ssh is the default. If the sshusername is blank, the username, password and protocol will be retrieved from the passwd table with "switch" as the key. The passwd.comments attribute is used for protocol.', + switchtype => 'The type of switch. It is used to identify the file name that implements the functions for this switch. The valid values are: Mellanox, Cisco, BNT and Juniper.', }, }, nodetype => { @@ -749,7 +749,7 @@ passed as argument rather than by table value', osvers => 'The Linux operating system deployed on this node. Valid values: rhels*,rhelc*, rhas*,centos*,SL*, fedora*, sles* (where * is the version #).', osarch => 'The hardware architecture of this node. Valid values: x86_64, ppc64, x86, ia64.', synclists => 'The fully qualified name of a file containing a list of files to synchronize on the nodes. Can be a comma separated list of multiple synclist files. The synclist generated by PCM named /install/osimages//synclist.cfm is reserved for use only by PCM and should not be edited by the admin.', - postscripts => 'Comma separated list of scripts that should be run on this image after diskful installation or diskless boot. For installation of RedHat, CentOS, Fedora, the scripts will be run before the reboot. For installation of SLES, the scripts will be run after the reboot but before the init.d process. For diskless deployment, the scripts will be run at the init.d time, and xCAT will automatically add the list of scripts from the postbootscripts attribute to run after postscripts list. For installation of AIX, the scripts will run after the reboot and acts the same as the postbootscripts attribute. For AIX, use the postbootscripts attribute. See the site table runbootscripts attribute. Support will be added in the future for the postscripts attribute to run the scripts before the reboot in AIX. ', + postscripts => 'Comma separated list of scripts that should be run on this image after diskful installation or diskless boot. For installation of RedHat, CentOS, Fedora, the scripts will be run before the reboot. For installation of SLES, the scripts will be run after the reboot but before the init.d process. For diskless deployment, the scripts will be run at the init.d time, and xCAT will automatically add the list of scripts from the postbootscripts attribute to run after postscripts list. For installation of AIX, the scripts will run after the reboot and acts the same as the postbootscripts attribute. For AIX, use the postbootscripts attribute. See the site table runbootscripts attribute.' , postbootscripts => 'Comma separated list of scripts that should be run on this after diskful installation or diskless boot. On AIX these scripts are run during the processing of /etc/inittab. On Linux they are run at the init.d time. xCAT automatically adds the scripts in the xcatdefaults.postbootscripts attribute to run first in the list. See the site table runbootscripts attribute.', serverrole => 'The role of the server created by this osimage. Default roles: mgtnode, servicenode, compute, login, storage, utility.', isdeletable => 'A flag to indicate whether this image profile can be deleted. This attribute is only used by PCM.', @@ -769,11 +769,11 @@ passed as argument rather than by table value', boottarget => 'The name of the boottarget definition. When this attribute is set, xCAT will use the kernel, initrd and kernel params defined in the boottarget definition instead of the default.', addkcmdline => 'User specified arguments to be passed to the kernel. The user arguments are appended to xCAT.s default kernel arguments. For the kernel options need to be persistent after installation, specify them with prefix "R::". This attribute is ignored if linuximage.boottarget is set.', pkglist => 'The fully qualified name of the file that stores the distro packages list that will be included in the image. Make sure that if the pkgs in the pkglist have dependency pkgs, the dependency pkgs should be found in one of the pkgdir', - pkgdir => 'The name of the directory where the distro packages are stored. It could be set multiple paths.The multiple paths must be seperated by ",". The first path in the value of osimage.pkgdir must be the OS base pkg dir path, such as pkgdir=/install/rhels6.2/x86_64,/install/updates . In the os base pkg path, there are default repository data. And in the other pkg path(s), the users should make sure there are repository data. If not, use "createrepo" command to create them. For ubuntu, multiple mirrors can be specified in the pkgdir attribute, the mirrors must be prefixed by the protocol(http/ssh) and delimited with "," between each other.', - otherpkglist => 'The fully qualified name of the file that stores non-distro package lists that will be included in the image. It could be set multiple paths.The multiple paths must be seperated by ",".', + pkgdir => 'The name of the directory where the distro packages are stored. It could be set to multiple paths. The multiple paths must be separated by ",". The first path in the value of osimage.pkgdir must be the OS base pkg dir path, such as pkgdir=/install/rhels6.2/x86_64,/install/updates . In the os base pkg path, there are default repository data. And in the other pkg path(s), the users should make sure there are repository data. If not, use "createrepo" command to create them. For ubuntu, multiple mirrors can be specified in the pkgdir attribute, the mirrors must be prefixed by the protocol(http/ssh) and delimited with "," between each other.', + otherpkglist => 'The fully qualified name of the file that stores non-distro package lists that will be included in the image. It could be set to multiple paths. The multiple paths must be separated by ",".', otherpkgdir => 'The base directory where the non-distro packages are stored. Only 1 local directory supported at present.', exlist => 'The fully qualified name of the file that stores the file names and directory names that will be excluded from the image during packimage command. It is used for diskless image only.', - postinstall => 'The fully qualified name of the script file that will be run at the end of the genimage command. It could be set multiple paths.The multiple paths must be seperated by ",". It is used for diskless image only.', + postinstall => 'The fully qualified name of the script file that will be run at the end of the genimage command. It could be set to multiple paths. The multiple paths must be separated by ",". It is used for diskless image only.', rootimgdir => 'The directory name where the image is stored. It is generally used for diskless image. it also can be used in sysclone environment to specify where the image captured from golden client is stored. in sysclone environment, rootimgdir is generally assigned to some default value by xcat, but you can specify your own store directory. just one thing need to be noticed, wherever you save the image, the name of last level directory must be the name of image. for example, if your image name is testimage and you want to save this image under home directoy, rootimgdir should be assigned to value /home/testimage/', kerneldir => 'The directory name where the 3rd-party kernel is stored. It is used for diskless image only.', nodebootif => 'The network interface the stateless/statelite node will boot over (e.g. eth0)', @@ -843,7 +843,7 @@ passed as argument rather than by table value', table_desc => '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 diskful installation or diskless boot. Each script can take zero or more parameters. For example: "script1 p1 p2,script2,...". xCAT automatically adds the postscripts from the xcatdefaults.postscripts attribute of the table to run first on the nodes after install or diskless boot. For installation of RedHat, CentOS, Fedora, the scripts will be run before the reboot. For installation of SLES, the scripts will be run after the reboot but before the init.d process. For diskless deployment, the scripts will be run at the init.d time, and xCAT will automatically add the list of scripts from the postbootscripts attribute to run after postscripts list. For installation of AIX, the scripts will run after the reboot and acts the same as the postbootscripts attribute. For AIX, use the postbootscripts attribute. Support will be added in the future for the postscripts attribute to run the scripts before the reboot in AIX. ', + postscripts => 'Comma separated list of scripts that should be run on this node after diskful installation or diskless boot. Each script can take zero or more parameters. For example: "script1 p1 p2,script2,...". xCAT automatically adds the postscripts from the xcatdefaults.postscripts attribute of the table to run first on the nodes after install or diskless boot. For installation of RedHat, CentOS, Fedora, the scripts will be run before the reboot. For installation of SLES, the scripts will be run after the reboot but before the init.d process. For diskless deployment, the scripts will be run at the init.d time, and xCAT will automatically add the list of scripts from the postbootscripts attribute to run after postscripts list. For installation of AIX, the scripts will run after the reboot and acts the same as the postbootscripts attribute. For AIX, use the postbootscripts attribute.', postbootscripts => 'Comma separated list of scripts that should be run on this node after diskful installation or diskless boot. Each script can take zero or more parameters. For example: "script1 p1 p2,script2,...". On AIX these scripts are run during the processing of /etc/inittab. On Linux they are run at the init.d time. xCAT automatically adds the scripts in the xcatdefaults.postbootscripts attribute to run first in the list.', comments => 'Any user-written notes.', disable => "Set to 'yes' or '1' to comment out this row.", @@ -1132,7 +1132,7 @@ passed as argument rather than by table value', " currently supported values:\n". " '0': disable debug mode\n". " '1': enable basic debug mode\n". -" '2': enalbe expert debug mode\n". +" '2': enable expert debug mode\n". " For the details on 'basic debug mode' and 'expert debug mode',\n". " please refer to xCAT documentation.\n\n". " --------------------\n" . @@ -1258,7 +1258,7 @@ passed as argument rather than by table value', serial => 'The serial number of the node.', mtm => 'The machine type and model number of the node. E.g. 7984-6BU', side => '- or -. The side information for the BPA/FSP. The side attribute refers to which BPA/FSP, A or B, which is determined by the slot value returned from lsslp command. It also lists the physical port within each BPA/FSP which is determined by the IP address order from the lsslp response. This information is used internally when communicating with the BPAs/FSPs', - asset => 'A field for administators to use to correlate inventory numbers they may have to accomodate', + asset => 'A field for administrators to use to correlate inventory numbers they may have to accommodate', uuid => 'The UUID applicable to the node', comments => 'Any user-written notes.', disable => "Set to 'yes' or '1' to comment out this row.", @@ -1417,7 +1417,7 @@ passed as argument rather than by table value', routes => { cols => [qw(routename net mask gateway ifname comments disable)], keys => [qw(routename)], - table_desc => 'Describes the additional routes needed to be setup in the os routing table. These routes usually are used to connect the management node to the compute node using the servie node as gateway.', + table_desc => 'Describes the additional routes needed to be setup in the os routing table. These routes usually are used to connect the management node to the compute node using the service node as gateway.', descriptions => { routename => 'Name used to identify this route.', net => 'The network address.', @@ -1473,14 +1473,14 @@ passed as argument rather than by table value', nichostnamesuffixes => 'Comma-separated list of hostname suffixes per NIC. If only one ip address is associated with each NIC: !,!,..., for example, eth0!-eth0,ib0!-ib0 - If multiple ip addresses are associcated with each NIC: + If multiple ip addresses are associated with each NIC: !|,!|,..., for example, eth0!-eth0|-eth0-ipv6,ib0!-ib0|-ib0-ipv6. The xCAT object definition commands support to use nichostnamesuffixes. as the sub attributes. Note: According to DNS rules a hostname must be a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-),and period (.). When you are specifying "nichostnamesuffixes" or "nicaliases" make sure the resulting hostnames will conform to this naming convention', nichostnameprefixes => 'Comma-separated list of hostname prefixes per NIC. If only one ip address is associated with each NIC: !,!,..., for example, eth0!eth0-,ib0!ib- - If multiple ip addresses are associcated with each NIC: + If multiple ip addresses are associated with each NIC: !|,!|,..., for example, eth0!eth0-|eth0-ipv6i-,ib0!ib-|ib-ipv6-. The xCAT object definition commands support to use nichostnameprefixes. as the sub attributes. Note: According to DNS rules a hostname must be a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-),and period (.). When you are specifying "nichostnameprefixes" or "nicaliases" make sure the resulting hostnames will conform to this naming convention', @@ -1663,7 +1663,7 @@ passed as argument rather than by table value', mic => { cols => [qw(node host id nodetype bridge onboot vlog powermgt comments disable)], keys => [qw(node)], - table_desc => 'The host, slot id and configuraton of the mic (Many Integrated Core).', + table_desc => 'The host, slot id and configuration of the mic (Many Integrated Core).', descriptions => { node => 'The node name or group name.', host => 'The host node which the mic card installed on.', @@ -1794,6 +1794,8 @@ foreach my $tabname (keys(%xCAT::ExtTab::ext_tabspec)) { osdistro => { attrs => [], attrhash => {}, objkey => 'osdistroname' }, osdistroupdate => { attrs => [], attrhash => {}, objkey => 'osupdatename' }, zone => { attrs => [], attrhash => {}, objkey => 'zonename' }, + firmware => { attrs => [], attrhash => {}, objkey => 'cfgfile' }, + taskstate => { attrs => [], attrhash => {}, objkey => 'node' }, ); @@ -3958,6 +3960,35 @@ push(@{ $defspec{group}->{'attrs'} }, @nodeattrs); ); +############################# +# boottarget object # +############################# +# boottarget table # +############################# + +@{ $defspec{boottarget}->{'attrs'} } = + ( + { attr_name => 'bprofile', + tabentry => 'boottarget.bprofile', + access_tabentry => 'boottarget.bprofile=attr:bprofile', + }, + { attr_name => 'kernel', + tabentry => 'boottarget.kernel', + access_tabentry => 'boottarget.bprofile=attr:bprofile', + }, + { attr_name => 'initrd', + tabentry => 'boottarget.initrd', + access_tabentry => 'boottarget.bprofile=attr:bprofile', + }, + { attr_name => 'kcmdline', + tabentry => 'boottarget.kcmdline', + access_tabentry => 'boottarget.bprofile=attr:bprofile', + }, + { attr_name => 'comments', + tabentry => 'boottarget.comments', + access_tabentry => 'boottarget.bprofile=attr:bprofile', + }, + ); ################################################### From c519024679714b610cbc3d59cfeef23011007f1b Mon Sep 17 00:00:00 2001 From: XuWei Date: Mon, 6 Jun 2016 03:50:00 -0400 Subject: [PATCH 079/310] Fix issue 846, update mknb doc --- .../guides/admin-guides/references/man8/mknb.8.rst | 12 ++++++------ xCAT-client/pods/man8/mknb.8.pod | 13 ++++++------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man8/mknb.8.rst b/docs/source/guides/admin-guides/references/man8/mknb.8.rst index e7753beb2..119a369ef 100644 --- a/docs/source/guides/admin-guides/references/man8/mknb.8.rst +++ b/docs/source/guides/admin-guides/references/man8/mknb.8.rst @@ -27,14 +27,14 @@ DESCRIPTION *********** -The \ **mknb**\ command is run by xCAT automatically, when xCAT is installed on the management node. +The \ **mknb**\ command is run by xCAT automatically when xCAT is installed on the management node. It creates a network boot root image (used for node discovery, BMC programming, and flashing) -for the same architecture that the management node is. So you normally do not need to run the \ **mknb**\ -command yourself. +for the same architecture that the management node is. So you normally do not need to run the +\ **mknb**\ command yourself. -If you do run \ **mknb**\ to add custom utilities to your boot root image, and you have an xCAT Hierarchical Cluster with service nodes that each have a local /tftpboot directory (site sharedtftp=0), you will also need to copy the generated root image to each service node. +If you make custom changes to the network boot root image, you will need to run \ **mknb**\ again to regenerate the diskless image to include your changes. If you have an xCAT Hierarchical Cluster with Service Nodes having local /tftpboot directories (site.sharedtftp=0), you will need to copy the generated root image to each Service Node. -Presently, only the arch x86_64 is supported. +Presently, the architectures x86_64 and ppc64 are supported. For ppc64le, use the ppc64 architecture. ******* @@ -45,7 +45,7 @@ OPTIONS \ *arch*\ - The hardware architecture for which to build the boot image: x86_64 + The hardware architecture for which to build the boot image. diff --git a/xCAT-client/pods/man8/mknb.8.pod b/xCAT-client/pods/man8/mknb.8.pod index 476ce19a3..47ca88c04 100644 --- a/xCAT-client/pods/man8/mknb.8.pod +++ b/xCAT-client/pods/man8/mknb.8.pod @@ -9,15 +9,14 @@ B I =head1 DESCRIPTION -The B command is run by xCAT automatically, when xCAT is installed on the management node. +The B command is run by xCAT automatically when xCAT is installed on the management node. It creates a network boot root image (used for node discovery, BMC programming, and flashing) -for the same architecture that the management node is. So you normally do not need to run the B -command yourself. +for the same architecture that the management node is. So you normally do not need to run the +B command yourself. -If you do run B to add custom utilities to your boot root image, and you have an xCAT Hierarchical Cluster with service nodes that each have a local /tftpboot directory (site sharedtftp=0), you will also need to copy the generated root image to each service node. +If you make custom changes to the network boot root image, you will need to run B again to regenerate the diskless image to include your changes. If you have an xCAT Hierarchical Cluster with Service Nodes having local /tftpboot directories (site.sharedtftp=0), you will need to copy the generated root image to each Service Node. - -Presently, only the arch x86_64 is supported. +Presently, the architectures x86_64 and ppc64 are supported. For ppc64le, use the ppc64 architecture. =head1 OPTIONS @@ -25,7 +24,7 @@ Presently, only the arch x86_64 is supported. =item I -The hardware architecture for which to build the boot image: x86_64 +The hardware architecture for which to build the boot image. =back From bbf151bf629dd5ee71b095948c20a6c2b35216fa Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Tue, 7 Jun 2016 22:17:54 -0400 Subject: [PATCH 080/310] Use get_mac_by_arp subroutine from SvrUtil.pm --- perl-xCAT/xCAT/Utils.pm | 33 --------------- xCAT-server/lib/perl/xCAT/SvrUtils.pm | 25 ++++++----- .../lib/xcat/plugins/switchdiscover.pm | 41 ++++++++++++++----- 3 files changed, 45 insertions(+), 54 deletions(-) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index f92a9f1c2..831bae20a 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -4711,37 +4711,4 @@ sub get_nmapversion { return $nmap_version; } -#-------------------------------------------------------------------------------- -=head3 get_macbyarp - Get Mac address by arp -n - Returns: - mac: Mac address -=cut -#-------------------------------------------------------------------------------- - -sub get_macbyarp { - my $arptable; - my $mac; - my $ip = shift; - if ($ip =~ /xCAT::Utils/) - { - $ip = shift; - } - if ( -x "/usr/sbin/arp") { - $arptable = `/usr/sbin/arp -n`; - } - else{ - $arptable = `/sbin/arp -n`; - } - my @arpents = split /\n/,$arptable; - foreach (@arpents) { - if (m/^($ip)\s+\S+\s+(\S+)\s/) { - $mac=$2; - last; - } - } - - return $mac; -} - 1; diff --git a/xCAT-server/lib/perl/xCAT/SvrUtils.pm b/xCAT-server/lib/perl/xCAT/SvrUtils.pm index 4d0a99052..a02ca4d1c 100755 --- a/xCAT-server/lib/perl/xCAT/SvrUtils.pm +++ b/xCAT-server/lib/perl/xCAT/SvrUtils.pm @@ -1163,6 +1163,7 @@ sub update_tables_with_diskless_image nodes: a reference to nodes array display: whether just display the result, if not 'yes', the result will be written to the mac table. + nopping: will not call pping subroutine if it set as "nopping" Returns: Return a hash with node name as key Globals: @@ -1170,7 +1171,7 @@ sub update_tables_with_diskless_image Error: none Example: - xCAT::Utils->get_mac_by_arp($nodes, $display); + xCAT::Utils->get_mac_by_arp($nodes, $display, $nopping); Comments: =cut @@ -1178,26 +1179,28 @@ sub update_tables_with_diskless_image #------------------------------------------------------------------------------- sub get_mac_by_arp () { - my ($class, $nodes, $display) = @_; + my ($class, $nodes, $display, $nopping) = @_; my $node; my $data; my %ret = (); my $unreachable_nodes = ""; my $noderange = join (',', @$nodes); - my @output = xCAT::Utils->runcmd("/opt/xcat/bin/pping $noderange", -1); - - foreach my $line (@output) { - my ($hostname, $result) = split ':', $line; - my ($token, $status) = split ' ', $result; - chomp($token); - if ($token eq 'ping') { - $node->{$hostname}->{reachable} = 1; + + if ( $nopping ne "nopping" ) { + my @output = xCAT::Utils->runcmd("/opt/xcat/bin/pping $noderange", -1); + foreach my $line (@output) { + my ($hostname, $result) = split ':', $line; + my ($token, $status) = split ' ', $result; + chomp($token); + if ($token eq 'ping') { + $node->{$hostname}->{reachable} = 1; + } } } foreach my $n ( @$nodes ) { - if ( $node->{$n}->{reachable} ) { + if ( ( $node->{$n}->{reachable} ) || ( $nopping eq "nopping" ) ){ my $output; my $IP = xCAT::NetworkUtils::toIP( $n ); if ( xCAT::Utils->isAIX() ) { diff --git a/xCAT-server/lib/xcat/plugins/switchdiscover.pm b/xCAT-server/lib/xcat/plugins/switchdiscover.pm index ae7a70827..94c194168 100644 --- a/xCAT-server/lib/xcat/plugins/switchdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/switchdiscover.pm @@ -13,6 +13,7 @@ use xCAT::Usage; use xCAT::NodeRange; use xCAT::NetworkUtils; use xCAT::Utils; +use xCAT::SvrUtils; use XML::Simple; no strict; use Data::Dumper; @@ -826,13 +827,17 @@ sub snmp_scan { my $ranges = get_ip_ranges($request); - #use nmap to find if snmp port is enabled - # only open port will be scan + ########################################################## + #use nmap to parse the ip range and possible output from the command: + # Nmap scan report for switch-10-5-22-1 (10.5.22.1) 161/udp open snmp + # Nmap scan report for 10.5.23.1 161/udp open snmp + # Nmap scan report for 10.5.24.1 161/udp closed snmp + ########################################################## my $nmap_version = xCAT::Utils->get_nmapversion(); if (xCAT::Utils->version_cmp($nmap_version,"5.10") < 0) { - $ccmd = "/usr/bin/nmap -P0 -v -sU -p 161 -oA snmp_scan @$ranges | grep up | grep good "; + $ccmd = "/usr/bin/nmap -P0 -v -sU -p 161 -oA snmp_scan @$ranges | grep -E 'appears to be up|^161' | perl -pe 's/\\n/ / if \$. % 2'"; } else { - $ccmd = "/usr/bin/nmap -P0 -v -sU -p 161 -oA snmp_scan @$ranges | grep 'open port 161' "; + $ccmd = "/usr/bin/nmap -P0 -v -sU -p 161 -oA snmp_scan @$ranges | grep -v 'host down' | grep -E 'Nmap scan report|^161' | perl -pe 's/\\n/ / if \$. % 2'"; } if (exists($globalopt{verbose})) { send_msg($request, 0, "Process command: $ccmd\n"); @@ -855,19 +860,35 @@ sub snmp_scan { foreach my $line (@lines) { my @array = split / /, $line; - my $ip; - if (xCAT::Utils->version_cmp($nmap_version,"5.10") < 0) { - $ip = $array[1]; - } else { - $ip = $array[5]; + if ($line =~ /\b(\d{1,3}(?:\.\d{1,3}){3})\b/) + { + $ip = $1; } if (exists($globalopt{verbose})) { send_msg($request, 0, "Run snmpwalk command to get information for $ip"); } + if ($line =~ /close/) { + send_msg($request, 0, "*** snmp port is disabled for $ip ***"); + next; + } + my $vendor = get_snmpvendorinfo($request, $ip); if ($vendor) { - my $mac = xCAT::Utils->get_macbyarp($ip); + my $display = ""; + my $nopping = "nopping"; + my $output = xCAT::SvrUtils->get_mac_by_arp([$ip], $display, $nopping); + my $mac; + foreach my $node (keys %{$output}) { + if ($node eq $ip) { + my ($desc,$mac_arp) = split /: /, $output->{$node}; + $mac = $mac_arp; + last; + } + } + if (exists($globalopt{verbose})) { + send_msg($request, 0, "node: $ip, mac: $mac"); + } if (!$mac) { $mac="nomac_nmap_$counter"; $counter++; From b2aeb152c66525ca0e0fa8687e594f3a3921e3f6 Mon Sep 17 00:00:00 2001 From: "litingt@cn.ibm.com" Date: Wed, 8 Jun 2016 03:19:58 -0400 Subject: [PATCH 081/310] add a case to clean up the test environment and update the bundle files --- .../autotest/bundle/rhels6.7_ppc64.bundle | 1 + .../autotest/bundle/rhels6.7_x86_64.bundle | 1 + .../autotest/bundle/rhels6.8_ppc64.bundle | 1 + .../autotest/bundle/rhels6.8_x86_64.bundle | 1 + .../autotest/bundle/rhels7.2_ppc64.bundle | 1 + .../autotest/bundle/rhels7.2_ppc64le.bundle | 1 + .../autotest/bundle/rhels7.2_x86_64.bundle | 1 + .../autotest/bundle/sles11.4_ppc64.bundle | 1 + .../autotest/bundle/sles11.4_x86_64.bundle | 1 + xCAT-test/autotest/testcase/testenv/case0 | 23 +++++++++++++++++++ 10 files changed, 32 insertions(+) create mode 100644 xCAT-test/autotest/testcase/testenv/case0 diff --git a/xCAT-test/autotest/bundle/rhels6.7_ppc64.bundle b/xCAT-test/autotest/bundle/rhels6.7_ppc64.bundle index 243184594..ac261710d 100644 --- a/xCAT-test/autotest/bundle/rhels6.7_ppc64.bundle +++ b/xCAT-test/autotest/bundle/rhels6.7_ppc64.bundle @@ -303,3 +303,4 @@ reg_linux_statelite_installation_hierarchy_by_ramdisk reg_linux_statelite_installation_hierarchy_by_nfs redhat_migration1 redhat_migration2 +clean_up_env diff --git a/xCAT-test/autotest/bundle/rhels6.7_x86_64.bundle b/xCAT-test/autotest/bundle/rhels6.7_x86_64.bundle index 2e7b87490..3fbc91c8b 100644 --- a/xCAT-test/autotest/bundle/rhels6.7_x86_64.bundle +++ b/xCAT-test/autotest/bundle/rhels6.7_x86_64.bundle @@ -206,3 +206,4 @@ reg_linux_statelite_installation_hierarchy_by_ramdisk reg_linux_statelite_installation_hierarchy_by_nfs redhat_migration1 redhat_migration2 +clean_up_env diff --git a/xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle b/xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle index 81ede5553..2763e12c7 100644 --- a/xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle +++ b/xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle @@ -301,3 +301,4 @@ reg_linux_diskfull_installation_hierarchy reg_linux_diskless_installation_hierarchy reg_linux_statelite_installation_hierarchy_by_ramdisk reg_linux_statelite_installation_hierarchy_by_nfs +clean_up_env diff --git a/xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle b/xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle index cec465f07..f207c7154 100644 --- a/xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle +++ b/xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle @@ -204,3 +204,4 @@ reg_linux_diskfull_installation_hierarchy reg_linux_diskless_installation_hierarchy reg_linux_statelite_installation_hierarchy_by_ramdisk reg_linux_statelite_installation_hierarchy_by_nfs +clean_up_env diff --git a/xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle b/xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle index 243184594..ac261710d 100644 --- a/xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle +++ b/xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle @@ -303,3 +303,4 @@ reg_linux_statelite_installation_hierarchy_by_ramdisk reg_linux_statelite_installation_hierarchy_by_nfs redhat_migration1 redhat_migration2 +clean_up_env diff --git a/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle b/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle index 401756957..a23e9e257 100644 --- a/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle @@ -194,3 +194,4 @@ switchdiscover_range_z switchdiscover_range_z_V redhat_migration1 redhat_migration2 +clean_up_env diff --git a/xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle b/xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle index 2e7b87490..3fbc91c8b 100644 --- a/xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle +++ b/xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle @@ -206,3 +206,4 @@ reg_linux_statelite_installation_hierarchy_by_ramdisk reg_linux_statelite_installation_hierarchy_by_nfs redhat_migration1 redhat_migration2 +clean_up_env diff --git a/xCAT-test/autotest/bundle/sles11.4_ppc64.bundle b/xCAT-test/autotest/bundle/sles11.4_ppc64.bundle index b46de71a3..75ffb4dde 100644 --- a/xCAT-test/autotest/bundle/sles11.4_ppc64.bundle +++ b/xCAT-test/autotest/bundle/sles11.4_ppc64.bundle @@ -267,3 +267,4 @@ reg_linux_statelite_installation_hierarchy_by_ramdisk reg_linux_statelite_installation_hierarchy_by_nfs sles_migration1 sles_migration2 +clean_up_env diff --git a/xCAT-test/autotest/bundle/sles11.4_x86_64.bundle b/xCAT-test/autotest/bundle/sles11.4_x86_64.bundle index 8fd6db580..76fa7c6de 100644 --- a/xCAT-test/autotest/bundle/sles11.4_x86_64.bundle +++ b/xCAT-test/autotest/bundle/sles11.4_x86_64.bundle @@ -216,3 +216,4 @@ reg_linux_statelite_installation_hierarchy_by_ramdisk reg_linux_statelite_installation_hierarchy_by_nfs sles_migration1 sles_migration2 +clean_up_env diff --git a/xCAT-test/autotest/testcase/testenv/case0 b/xCAT-test/autotest/testcase/testenv/case0 new file mode 100644 index 000000000..7ecb5609f --- /dev/null +++ b/xCAT-test/autotest/testcase/testenv/case0 @@ -0,0 +1,23 @@ +start:clean_up_env +description:power off service node and compute node for next test usage +cmd:rpower $$SN stat >> /tmp/snstat +cmd:if [[ ! `cat /tmp/snstat |grep -i "Not Activated"` ]]; then rpower $$SN off;fi +check:rc==0 +cmd:rm -rf /tmp/snstat +cmd:if [[ "__GETNODEATTR($$SN,mgt)__" =~ "ipmi" ]]; then sleep 1800;else sleep 180;fi +cmd:rpower $$SN stat >> /tmp/snstat +check:rc==0 +cmd:if [[ "__GETNODEATTR($$SN,arch)__" = "ppc64" ]]; then cat /tmp/snstat |grep -i "Not Activated";else cat /tmp/snstat|grep off;fi +check:rc==0 +cmd:rm -rf /tmp/snstat +cmd:rpower $$CN stat >> /tmp/cnstat +cmd:if [[ ! `cat /tmp/cnstat |grep -i "Not Activated"` ]]; then rpower $$CN off;fi +check:rc==0 +cmd:rm -rf /tmp/cnstat +cmd:if [[ "__GETNODEATTR($$CN,mgt)__" =~ "ipmi" ]]; then sleep 1800;else sleep 180;fi +cmd:rpower $$CN stat >> /tmp/cnstat +check:rc==0 +cmd:if [[ "__GETNODEATTR($$CN,arch)__" = "ppc64" ]]; then cat /tmp/cnstat |grep "Not Activated";else cat /tmp/cnstat|grep off;fi +check:rc==0 +cmd:rm -rf /tmp/cnstat +end From 8c645eb941ff0724a4926630c604d6c8ed09e276 Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Wed, 8 Jun 2016 04:12:39 -0400 Subject: [PATCH 082/310] completed --- xCAT-test/autotest/bundle/aixnim.bundle | 18 -- xCAT-test/autotest/bundle/bat.bundle | 254 ------------------ xCAT-test/autotest/bundle/def.bundle | 36 --- xCAT-test/autotest/bundle/p_aix_cmd.bundle | 249 ----------------- xCAT-test/autotest/bundle/p_ubunut.cmd.bundle | 199 -------------- .../autotest/bundle/sles11.4_ppc64le.bundle | 199 -------------- xCAT-test/autotest/bundle/x86.bundle | 214 --------------- .../installation/aix_diskless_installation | 56 ---- .../installation/aix_full_installation | 53 ---- .../installation/aix_statelite_installation | 92 ------- ...ith_sn_diskless_installation_x86_64_redhat | 67 ----- ..._sn_diskless_installation_x86_64_redhat_vm | 51 ---- ...th_sn_diskless_installation_x86_64_sles_vm | 50 ---- ...cn_with_sn_full_installation_x86_64_redhat | 51 ---- ...with_sn_full_installation_x86_64_redhat_vm | 47 ---- ...n_with_sn_full_installation_x86_64_sles_vm | 47 ---- ...th_sn_statelite_installation_x86_64_redhat | 94 ------- ...sn_statelite_installation_x86_64_redhat_vm | 88 ------ ...h_sn_statelite_installation_x86_64_sles_vm | 88 ------ .../installation/linux_diskless_installation | 50 ---- .../linux_diskless_installation_x86_64_redhat | 46 ---- .../linux_diskless_installation_x86_64_sles | 55 ---- .../installation/linux_full_installation | 48 ---- .../linux_full_installation_x86_64_redhat | 57 ---- .../linux_full_installation_x86_64_sles | 44 --- .../linux_sles_diskless_installation_ppc64 | 56 ---- .../linux_sles_statelite_installation_ppc64 | 83 ------ .../installation/linux_sn_installation_x86_64 | 53 ---- .../linux_sn_installation_x86_64_redhat | 53 ---- .../linux_sn_installation_x86_64_redhat_vm | 53 ---- .../linux_sn_installation_x86_64_sles | 53 ---- .../linux_sn_installation_x86_64_sles_vm | 63 ----- .../installation/linux_statelite_installation | 77 ------ ...linux_statelite_installation_x86_64_redhat | 66 ----- .../linux_statelite_installation_x86_64_sles | 66 ----- ...ux_diskfull_installation_flat_confignics_s | 71 ----- ...reg_linux_statelite_installation_hierarchy | 141 ---------- .../installation/sles_full_installation_p8le | 42 --- .../ubuntu_diskless_installation_cudafull | 39 --- .../ubuntu_diskless_installation_cudaruntime | 39 --- .../ubuntu_full_installation_cudafull | 35 --- .../ubuntu_full_installation_cudaruntime | 38 --- .../ubuntu_full_installation_vm_confignics_s | 49 ---- 43 files changed, 3330 deletions(-) delete mode 100644 xCAT-test/autotest/bundle/aixnim.bundle delete mode 100644 xCAT-test/autotest/bundle/bat.bundle delete mode 100644 xCAT-test/autotest/bundle/def.bundle delete mode 100644 xCAT-test/autotest/bundle/p_aix_cmd.bundle delete mode 100644 xCAT-test/autotest/bundle/p_ubunut.cmd.bundle delete mode 100644 xCAT-test/autotest/bundle/sles11.4_ppc64le.bundle delete mode 100644 xCAT-test/autotest/bundle/x86.bundle delete mode 100644 xCAT-test/autotest/testcase/installation/aix_diskless_installation delete mode 100644 xCAT-test/autotest/testcase/installation/aix_full_installation delete mode 100644 xCAT-test/autotest/testcase/installation/aix_statelite_installation delete mode 100644 xCAT-test/autotest/testcase/installation/linux_cn_with_sn_diskless_installation_x86_64_redhat delete mode 100644 xCAT-test/autotest/testcase/installation/linux_cn_with_sn_diskless_installation_x86_64_redhat_vm delete mode 100644 xCAT-test/autotest/testcase/installation/linux_cn_with_sn_diskless_installation_x86_64_sles_vm delete mode 100644 xCAT-test/autotest/testcase/installation/linux_cn_with_sn_full_installation_x86_64_redhat delete mode 100644 xCAT-test/autotest/testcase/installation/linux_cn_with_sn_full_installation_x86_64_redhat_vm delete mode 100644 xCAT-test/autotest/testcase/installation/linux_cn_with_sn_full_installation_x86_64_sles_vm delete mode 100644 xCAT-test/autotest/testcase/installation/linux_cn_with_sn_statelite_installation_x86_64_redhat delete mode 100644 xCAT-test/autotest/testcase/installation/linux_cn_with_sn_statelite_installation_x86_64_redhat_vm delete mode 100644 xCAT-test/autotest/testcase/installation/linux_cn_with_sn_statelite_installation_x86_64_sles_vm delete mode 100644 xCAT-test/autotest/testcase/installation/linux_diskless_installation delete mode 100644 xCAT-test/autotest/testcase/installation/linux_diskless_installation_x86_64_redhat delete mode 100644 xCAT-test/autotest/testcase/installation/linux_diskless_installation_x86_64_sles delete mode 100644 xCAT-test/autotest/testcase/installation/linux_full_installation delete mode 100644 xCAT-test/autotest/testcase/installation/linux_full_installation_x86_64_redhat delete mode 100644 xCAT-test/autotest/testcase/installation/linux_full_installation_x86_64_sles delete mode 100644 xCAT-test/autotest/testcase/installation/linux_sles_diskless_installation_ppc64 delete mode 100644 xCAT-test/autotest/testcase/installation/linux_sles_statelite_installation_ppc64 delete mode 100644 xCAT-test/autotest/testcase/installation/linux_sn_installation_x86_64 delete mode 100644 xCAT-test/autotest/testcase/installation/linux_sn_installation_x86_64_redhat delete mode 100644 xCAT-test/autotest/testcase/installation/linux_sn_installation_x86_64_redhat_vm delete mode 100644 xCAT-test/autotest/testcase/installation/linux_sn_installation_x86_64_sles delete mode 100644 xCAT-test/autotest/testcase/installation/linux_sn_installation_x86_64_sles_vm delete mode 100644 xCAT-test/autotest/testcase/installation/linux_statelite_installation delete mode 100644 xCAT-test/autotest/testcase/installation/linux_statelite_installation_x86_64_redhat delete mode 100644 xCAT-test/autotest/testcase/installation/linux_statelite_installation_x86_64_sles delete mode 100644 xCAT-test/autotest/testcase/installation/reg_linux_diskfull_installation_flat_confignics_s delete mode 100644 xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy delete mode 100644 xCAT-test/autotest/testcase/installation/sles_full_installation_p8le delete mode 100644 xCAT-test/autotest/testcase/installation/ubuntu_diskless_installation_cudafull delete mode 100644 xCAT-test/autotest/testcase/installation/ubuntu_diskless_installation_cudaruntime delete mode 100644 xCAT-test/autotest/testcase/installation/ubuntu_full_installation_cudafull delete mode 100644 xCAT-test/autotest/testcase/installation/ubuntu_full_installation_cudaruntime delete mode 100644 xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_confignics_s diff --git a/xCAT-test/autotest/bundle/aixnim.bundle b/xCAT-test/autotest/bundle/aixnim.bundle deleted file mode 100644 index 24eaeb8ce..000000000 --- a/xCAT-test/autotest/bundle/aixnim.bundle +++ /dev/null @@ -1,18 +0,0 @@ -mknimimage_h -mknimimage_s -mknimimage_s_iamgename_attr -mknimimage_t_s -mknimimage_t_i -rmnimimage_imagename -rmnimimage_d_imagename -rmnimimage_x_imagename -rmnimimage_h -mkdsklsnode_h -mkdsklsnode_i_f -mkdsklsnode_i_f_V -mkdsklsnode_n_i -mkdsklsnode_node -mkdsklsnode_i_psize_sparse_paging -rmdsklsnode_h -rmdsklsnode_node -rmdsklsnode_i diff --git a/xCAT-test/autotest/bundle/bat.bundle b/xCAT-test/autotest/bundle/bat.bundle deleted file mode 100644 index 09a290afa..000000000 --- a/xCAT-test/autotest/bundle/bat.bundle +++ /dev/null @@ -1,254 +0,0 @@ -chdef_null -chdef_t_node -chdef_t_network -chdef_p -chdef_m -chdef_z -chdef_group -chdef_group_p -chdef_dynamic_group -chdef_multiple_keys -chdef_n -chdef_t_o_error -chtab_null -chtab_delete -chtab_modify -chtab_d -chtab_modify_node -chtab_modify_key -chtab_err_symble -chtab_err_table -chtab_h -chtab_v -copycds_iso -copycds_n -copycds_a -copycds_n_a -copycds_a_err -copycds_n_err -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_all -pping_node -getmacs_noderange -getmacs_d -getmacs_f_D -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -lslite_i -lslite_noderange -lslite_h -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a -makedhcp_a_d -makedhcp_d -mkdef_null -mkdef_t_o_attr -mkdef_f_t_o_attr -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_delete_error -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_normal -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_tab -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_specificvalue -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_noderange -nodestat_err_node -rinv_null -rinv_bus -rinv_config -rinv_serial -rinv_model -rinv_firm -rinv_all -rinv_noderange_err -rmdef_null -rmdef_t_o_attr -rmdef_f_all -rmdef_t_err -rpower_off -rpower_stat -rpower_boot -rpower_on -rpower_reset -rpower_noderange -rpower_noderange_nodeps -rpower_err_noderange -rscan_noderange -rscan_x -rscan_z -rscan_w -rscan_x_w -rscan_z_w -mvitals_state -rvitals_lcds -rvitals_all -rvitals_noderange_err -sinv_c_p_t_r_o -sinv_c_s_p_t_o -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_p_auditlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -makehosts_h -makehosts_help -makehosts_null -makehosts_l -makehosts_d -makehosts_n -makehosts_n_noderange -xcatstart -xcatstop -xdcp_src_dst -xdcp_P -makedns_h -makedns_n_node -makedns_d_node -makedns_n -makedns -noderange_individual_node -noderange_individual_grp -noderange_node01-node10 -noderange_node[01-10] -noderange_node[01 -noderange_f[1-2]n[1-3] -noderange_group1-group3 -noderange_node001-node200 -noderange_node10+3 -noderange_10-20 -noderange_XCAT_NODE_PREFIX -noderange_XCAT_NODE_SUFFIX -noderange_/nrtestnode.* -noderange_/tmp/nodelistfile -noderange_exclusion -noderange_group_intersection - diff --git a/xCAT-test/autotest/bundle/def.bundle b/xCAT-test/autotest/bundle/def.bundle deleted file mode 100644 index e8fd7d40a..000000000 --- a/xCAT-test/autotest/bundle/def.bundle +++ /dev/null @@ -1,36 +0,0 @@ -def_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_s -lsdef_t_err -chdef_null -chdef_t_o_attr -chdef_p_t_o_attr -chdef_m_t_o_attr -chdef_z -chdef_t_o_attr_noderange -chdef_group -chdef_dynamic_group -chdef_multiple_keys -chdef_t_o_error -mkdef_null -mkdef_t_o_attr -mkdef_f_t_o_attr -mkdef_z -mkdef_group -mkdef_dynamic_group -mkdef_multiple_keys -mkdef_t_o_error -rmdef_null -rmdef_t_o_node -rmdef_t_node -rmdef_node -rmdef_t_o_network -rmdef_group -rmdef_dynamic_group -rmdef_f_all -rmdef_t_err diff --git a/xCAT-test/autotest/bundle/p_aix_cmd.bundle b/xCAT-test/autotest/bundle/p_aix_cmd.bundle deleted file mode 100644 index 6ef8fc841..000000000 --- a/xCAT-test/autotest/bundle/p_aix_cmd.bundle +++ /dev/null @@ -1,249 +0,0 @@ -chdef_null -chdef_t_node -chdef_t_network -chdef_p -chdef_m -chdef_z -chdef_group -chdef_group_p -chdef_dynamic_group -chdef_multiple_keys -chdef_n -chdef_t_o_error -chtab_null -chtab_delete -chtab_modify -chtab_d -chtab_modify_node -chtab_modify_key -chtab_h -chtab_v -copycds_iso -copycds_n -copycds_a -copycds_n_a -copycds_a_err -copycds_n_err -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_node -getmacs_noderange -getmacs_d -getmacs_f_D -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -lslite_i -lslite_noderange -lslite_h -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a -makedhcp_a_d -makedhcp_d -mkdef_null -mkdef_t_o_attr -mkdef_f_t_o_attr -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_delete_error -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_normal -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_tab -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_specificvalue -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_noderange -nodestat_err_node -rinv_null -rinv_bus -rinv_config -rinv_serial -rinv_model -rinv_firm -rinv_all -rinv_noderange_err -rmdef_null -rmdef_t_o_attr -rmdef_f_all -rmdef_t_err -rpower_off -rpower_stat -rpower_boot -rpower_on -rpower_reset -rpower_noderange -rpower_noderange_nodeps -rpower_err_noderange -rscan_noderange -rscan_x -rscan_z -rscan_w -rscan_x_w -rscan_z_w -mvitals_state -rvitals_lcds -rvitals_all -rvitals_noderange_err -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_p_auditlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -makehosts_h -makehosts_help -makehosts_null -makehosts_l -makehosts_d -makehosts_n -makehosts_n_noderange -xcatstart -xcatstop -xdcp_src_dst -xdcp_P -makedns_h -makedns_n_node -makedns_d_node -makedns_n -makedns -noderange_individual_node -noderange_individual_grp -noderange_node01-node10 -noderange_node[01-10] -noderange_node[01 -noderange_f[1-2]n[1-3] -noderange_group1-group3 -noderange_node001-node200 -noderange_node10+3 -noderange_10-20 -noderange_XCAT_NODE_PREFIX -noderange_XCAT_NODE_SUFFIX -noderange_/nrtestnode.* -noderange_/tmp/nodelistfile -noderange_exclusion -noderange_group_intersection - diff --git a/xCAT-test/autotest/bundle/p_ubunut.cmd.bundle b/xCAT-test/autotest/bundle/p_ubunut.cmd.bundle deleted file mode 100644 index ca61c55ca..000000000 --- a/xCAT-test/autotest/bundle/p_ubunut.cmd.bundle +++ /dev/null @@ -1,199 +0,0 @@ -makehosts_h -makehosts_help -makehosts_n -makehosts_n_noderange -chdef_null -chdef_t_o_attr -chdef_p_t_o_attr -chdef_m_t_o_attr -chdef_z -chdef_t_o_attr_noderange -chdef_t_o_error -chtab_null -chtab_delete -chtab_modify -chtab_d -chtab_modify_node -chtab_modify_key -chtab_h -chtab_v -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_node -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -lslite_i -lslite_noderange -lslite_h -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a_ubuntu -makedhcp_a_ubuntu_d -makedhcp_d -mkdef_null -mkdef_t_o_attr -mkdef_f_t_o_attr -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_delete_error -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_normal -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_tab -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_specificvalue -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_noderange -nodestat_err_node -rmdef_null -rmdef_t_o_attr -rmdef_f_all -rmdef_t_err -rpower_err_noderange -rscan_noderange -rscan_x -rscan_z -rscan_w -rscan_x_w -rscan_z_w -mvitals_state -rvitals_lcds -rvitals_noderange_err -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -xcatstart -xcatstop -xdcp_P -makedns_n_node -makedns_d_node -makedns_ubuntu_n -copycds_iso -copycds_n -copycds_a -copycds_n_a diff --git a/xCAT-test/autotest/bundle/sles11.4_ppc64le.bundle b/xCAT-test/autotest/bundle/sles11.4_ppc64le.bundle deleted file mode 100644 index ed800847f..000000000 --- a/xCAT-test/autotest/bundle/sles11.4_ppc64le.bundle +++ /dev/null @@ -1,199 +0,0 @@ -Diskless_installation_flat_p8_le -Full_installation_flat_p8_le -makehosts_h -makehosts_help -makehosts_n -makehosts_n_noderange -chdef_null -chdef_z -chdef_t_o_error -chtab_null -chtab_d -chtab_modify_node -chtab_modify_key -chtab_err_symble -chtab_err_table -chtab_h -chtab_v -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_node -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a -makedhcp_a_d -makedhcp_d -mkdef_null -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_tab -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_specificvalue -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_err_node -rinv_noderange_err -rmdef_null -rmdef_t_err -rpower_err_noderange -rvitals_noderange_err -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -makedns_d_node -makedns_n -makedns -copycds_iso -copycds_n -copycds_a -copycds_n_a -copycds_a_err -copycds_n_err -xdsh_h -xdsh_V -xdsh_regular_command -xdsh_Q_command -xdsh_c_cn -xdsh_e_filename -xdsh_E -xdsh_i_linux -xdsh_t -xdsh_q -xdsh_T -xdsh_o -switchdiscover_range_default -switchdiscover_h -switchdiscover_range_s -switchdiscover_range_default_w -switchdiscover_range_r -switchdiscover_range_x -switchdiscover_range_z -switchdiscover_range_z_V - diff --git a/xCAT-test/autotest/bundle/x86.bundle b/xCAT-test/autotest/bundle/x86.bundle deleted file mode 100644 index d0f887f73..000000000 --- a/xCAT-test/autotest/bundle/x86.bundle +++ /dev/null @@ -1,214 +0,0 @@ -makehosts_h -makehosts_help -makehosts_n -makehosts_n_noderange -chdef_null -chdef_t_o_attr -chdef_p_t_o_attr -chdef_m_t_o_attr -chdef_z -chdef_t_o_attr_noderange -chdef_t_o_error -chtab_null -chtab_delete -chtab_modify -chtab_d -chtab_modify_node -chtab_modify_key -chtab_err_symble -chtab_err_table -chtab_h -chtab_v -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_all -pping_node -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -lslite_i -lslite_noderange -lslite_h -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a -makedhcp_a_d -makedhcp_d -mkdef_null -mkdef_t_o_attr -mkdef_f_t_o_attr -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_delete_error -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_normal -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_tab -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_specificvalue -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_noderange -nodestat_err_node -rinv_null -rinv_bus -rinv_config -rinv_serial -rinv_model -rinv_firm -rinv_all -rinv_noderange_err -rmdef_null -rmdef_t_o_attr -rmdef_f_all -rmdef_t_err -rpower_err_noderange -rscan_noderange -rscan_x -rscan_z -rscan_w -rscan_x_w -rscan_z_w -mvitals_state -rvitals_lcds -rvitals_noderange_err -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -xcatstart -xcatstop -xdcp_P -makedns_n_node -makedns_d_node -makedns_n -makedns -copycds_iso -copycds_n -copycds_a -copycds_n_a -copycds_a_err -copycds_n_err - diff --git a/xCAT-test/autotest/testcase/installation/aix_diskless_installation b/xCAT-test/autotest/testcase/installation/aix_diskless_installation deleted file mode 100644 index f5334c712..000000000 --- a/xCAT-test/autotest/testcase/installation/aix_diskless_installation +++ /dev/null @@ -1,56 +0,0 @@ -start:aix_diskless_installation_flat -os:AIX -cmd:mknimimage -V -r -t diskless -s $$SOURCE autotestcosi -check:rc==0 -cmd:lsnim | grep autotestcosi -check:rc==0 -check:output=~lpp_source -check:output=~spot -check:output=~paging -check:output=~shared_root -cmd:nim -o update -a packages=all -a source=$$SSHPKG autotestcosi_lpp_source -check:rc==0 -cmd:mkdir -p /install/nim/installp_bundle -cmd:cp $$SSHPKG/xCATaixCN71.bnd /install/nim/installp_bundle/ -check:rc==0 -cmd:nim -o define -t installp_bundle -a server=master -a location=/install/nim/installp_bundle/xCATaixCN71.bnd xCATaixCN71 -cmd:chdef -t osimage -o autotestcosi installp_bundle="xCATaixCN71" -check:rc==0 -cmd:xcatchroot -i autotestcosi "/usr/bin/echo root:cluster|/usr/bin/chpasswd -c" -check:rc==0 -cmd:mknimimage -u autotestcosi -check:rc==0 -cmd:rscan __GETNODEATTR($$CN, hcp)__ -z > test.node -check:rc==0 -cmd:sleep 60 -cmd:cat test.node|mkdef -z -cmd:makeconservercf $$CN -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$CN -check:output=~$$CN -cmd:sleep 60 -cmd:getmacs $$CN -f -D -check:rc==0 -cmd:mkdsklsnode -i autotestcosi $$CN -f -check:rc==0 -cmd:lsnim | grep $$CN -check:output=~machines -cmd:lsnim -l $$CN -check:output=~diskless or dataless boot is enabled -cmd:cat /etc/bootptab | grep $$CN -check:output=~__GETNODEATTR($$CN, mac)__ -cmd:ls -l /tftpboot/$$CN* -check:output=~$$CN -cmd:cat /etc/exports | grep $$CN -check:output=~autotestcosi_shared_root -check:output=~spot/autotestcosi/usr -check:output=~autotestcosi_paging -cmd:rnetboot $$CN -check:rc==0 -cmd:sleep 300 -cmd:lsdef -l $$CN| grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -end diff --git a/xCAT-test/autotest/testcase/installation/aix_full_installation b/xCAT-test/autotest/testcase/installation/aix_full_installation deleted file mode 100644 index 7a3f96a30..000000000 --- a/xCAT-test/autotest/testcase/installation/aix_full_installation +++ /dev/null @@ -1,53 +0,0 @@ -start:aix_full_installation_flat -os:AIX -cmd:mknimimage -V -s $$SOURCE autotest -check:rc==0 -cmd:lsnim | grep autotest -check:rc==0 -check:output=~lpp_source -check:output=~spot -check:output=~bosinst_data -cmd:nim -o update -a packages=all -a source=$$SSHPKG autotest_lpp_source -check:rc==0 -cmd:mkdir -p /install/nim/installp_bundle -cmd:cp $$SSHPKG/xCATaixCN71.bnd /install/nim/installp_bundle/ -check:rc==0 -cmd:nim -o define -t installp_bundle -a server=master -a location=/install/nim/installp_bundle/xCATaixCN71.bnd xCATaixCN71 -cmd:chdef -t osimage -o autotest installp_bundle="xCATaixCN71" -check:rc==0 -cmd:rscan __GETNODEATTR($$CN, hcp)__ -w -check:rc==0 -cmd:makeconservercf $$CN -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$CN -check:output=~$$CN -cmd:sleep 60 -cmd:getmacs $$CN -f -D -check:rc==0 -cmd:xcat2nim -t node -o $$CN -check:rc==0 -cmd:lsnim | grep $$CN -check:output=~machines -cmd:nimnodeset -i autotest $$CN -check:rc==0 -cmd:lsnim -l $$CN -check:output=~BOS installation has been enabled -cmd:cat /etc/bootptab | grep $$CN -check:output=~__GETNODEATTR($$CN, mac)__ -cmd:ls -l /tftpboot/$$CN* -check:output=~$$CN -cmd:cat /etc/exports | grep $$CN -check:output=~autotest_bosinst_data -check:output=~spot/autotest/usr -check:output=~xcataixscript -check:output=~xCATaixCN71.bnd -check:output=~autotest_lpp_source -cmd:rnetboot $$CN -check:rc==0 -cmd:sleep 1800 -cmd:lsdef -l $$CN| grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -end diff --git a/xCAT-test/autotest/testcase/installation/aix_statelite_installation b/xCAT-test/autotest/testcase/installation/aix_statelite_installation deleted file mode 100644 index e28ff3933..000000000 --- a/xCAT-test/autotest/testcase/installation/aix_statelite_installation +++ /dev/null @@ -1,92 +0,0 @@ -start:aix_statelite_installation_flat -os:AIX -cmd:chtab priority=1 litetree.image="autotestcosi" litetree.directory="$$MN:/mydata" -check:rc==0 -cmd:chtab node=$$CN statelite.statemnt="$$MN:/nodedata" -check:rc==0 -cmd:chtab litefile.image="ALL" litefile.file="/logs/" litefile.options="persistent" -check:rc==0 -cmd:chtab litefile.image="ALL" litefile.file="/ro/" litefile.options="ro" -check:rc==0 -cmd:chtab litefile.image="ALL" litefile.file="/rw/" litefile.options="rw" -check:rc==0 -cmd:tabdump litefile -check:rc==0 -cmd:chtab priority=4.7 policy.commands=litefile policy.rule=allow -check:rc==0 -cmd:chtab priority=4.8 policy.commands=litetree policy.rule=allow -check:rc==0 -cmd:mkdir -p /nodedata -check:rc==0 -cmd:mkdir -p /mydata/ro -check:rc==0 -cmd:mkdir -p /mydata/rw -check:rc==0 -cmd:chmod -R 555 /mydata/ro -check:rc==0 -cmd:chmod -R 777 /mydata/rw -check:rc==0 -cmd:chmod 755 /etc/exports -cmd:cat /etc/exports|grep nodedata; if [ "$?" -ne "0" ]; then echo "/nodedata -vers=3:4,sec=sys:none,anon=0,rw " >> /etc/exports; fi -check:rc==0 -cmd:cat /etc/exports|grep mydata; if [ "$?" -ne "0" ]; then echo "/mydata -vers=3:4,sec=sys:none,anon=0,rw " >> /etc/exports; fi -check:rc==0 -cmd:exportfs -a -check:rc==0 -cmd:nim -o update -a packages=all -a source=$$SSHPKG autotestcosi_lpp_source -check:rc==0 -cmd:mkdir -p /install/nim/installp_bundle -cmd:cp $$SSHPKG/xCATaixCN71.bnd /install/nim/installp_bundle/ -check:rc==0 -cmd:nim -o define -t installp_bundle -a server=master -a location=/install/nim/installp_bundle/xCATaixCN71.bnd xCATaixCN71 -cmd:chdef -t osimage -o autotestcosi installp_bundle="xCATaixCN71" -check:rc==0 -cmd:xcatchroot -i autotestcosi "/usr/bin/echo root:cluster|/usr/bin/chpasswd -c" -check:rc==0 -cmd:mknimimage -u autotestcosi -V -check:rc==0 -check:output=~Installing installp filesets in SPOT -check:output=~Installing RPM packages in SPOT -check:output=~Completed Installing RPM packages in SPOT -check:output=~Updated software in the NIM SPOT called -cmd:lsnim | grep autotestcosi -check:rc==0 -check:output=~lpp_source -check:output=~spot -check:output=~paging -check:output=~shared_root -cmd:rscan __GETNODEATTR($$CN, hcp)__ -z > test.node -check:rc==0 -cmd:sleep 60 -cmd:cat test.node|mkdef -z -cmd:makeconservercf $$CN -check:rc==0 -cmd:sleep 90 -cmd:cat /etc/conserver.cf | grep $$CN -check:output=~$$CN -cmd:getmacs $$CN -f -D -check:rc==0 -cmd:mkdsklsnode -f -i autotestcosi $$CN -check:rc==0 -cmd:lsnim | grep $$CN -check:output=~machines -cmd:lsnim -l $$CN -check:output=~diskless or dataless boot is enabled -cmd:cat /etc/bootptab | grep $$CN -check:output=~__GETNODEATTR($$CN, mac)__ -cmd:ls -l /tftpboot/$$CN* -check:output=~$$CN -cmd:cat /etc/exports | grep $$CN -check:output=~autotestcosi_shared_root -check:output=~spot/autotestcosi/usr -check:output=~autotestcosi_paging -cmd:rnetboot $$CN -check:rc==0 -cmd:sleep 400 -cmd:lsdef -l $$CN| grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -end - diff --git a/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_diskless_installation_x86_64_redhat b/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_diskless_installation_x86_64_redhat deleted file mode 100644 index d0a67d785..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_diskless_installation_x86_64_redhat +++ /dev/null @@ -1,67 +0,0 @@ -start:linux_cn_with_sn_diskless_installation_flat_x86_64_redhat -os:Linux -cmd:makedns -n -check:rc==0 -cmd:sleep 10 -cmd:service named restart -check:rc==0 -cmd:makeconservercf -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$CNWITHSN -check:output=~$$CNWITHSN -cmd:sleep 60 -cmd:chdef $$CNWITHSN servicenode=$$SN xcatmaster=$$SN -check:rc==0 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:service dhcpd restart -check:rc==0 -cmd:cat /var/lib/dhcpd/dhcpd.leases| grep $$CNWITHSN -check:output=~$$CNWITHSN -cmd:rm -rf /install/netboot/__GETNODEATTR($$CNWITHSN,os)__/x86_64/compute -check:rc==0 -cmd:genimage __GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-netboot-compute -check:rc==0 -cmd:packimage -o __GETNODEATTR($$CNWITHSN,os)__ -p compute -a __GETNODEATTR($$CNWITHSN,arch)__ -check:rc==0 -cmd:xdsh $$SN df|grep /install;if [ $? -ne 0 ] ;then xdsh $$SN mount $$MN:/install /install;fi -check:rc==0 -cmd:nodeset $$CNWITHSN osimage=__GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-netboot-compute -check:rc==0 -cmd:rsetboot $$CNWITHSN net -check:rc==0 -cmd:rpower $$CNWITHSN reset -check:rc==0 -cmd:sleep 200 -cmd:lsdef -l $$CNWITHSN | grep status -check:output=~booted -cmd:xdsh $$CNWITHSN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:nodeset $$CNWITHSN osimage -check:rc==0 -cmd:rsetboot $$CNWITHSN net -check:rc==0 -cmd:rpower $$CNWITHSN reset -check:rc==0 -cmd:sleep 200 -cmd:lsdef -l $$CNWITHSN | grep status -check:output=~booted -cmd:xdsh $$CNWITHSN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:nodeset $$CNWITHSN netboot -check:rc==0 -cmd:rsetboot $$CNWITHSN net -check:rc==0 -cmd:rpower $$CNWITHSN reset -check:rc==0 -cmd:sleep 200 -cmd:lsdef -l $$CNWITHSN | grep status -check:output=~booted -cmd:xdsh $$CNWITHSN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -end diff --git a/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_diskless_installation_x86_64_redhat_vm b/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_diskless_installation_x86_64_redhat_vm deleted file mode 100644 index 85a8b3f20..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_diskless_installation_x86_64_redhat_vm +++ /dev/null @@ -1,51 +0,0 @@ -start:Linux_cn_with_sn_diskless_installation_flat_x86_64_redhat_vm -os:Linux -cmd:makedns -n -check:rc==0 -cmd:sleep 10 -cmd:service named restart -check:rc==0 -cmd:makeconservercf -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$CNWITHSN -check:output=~$$CNWITHSN -cmd:sleep 60 -cmd:chdef $$CNWITHSN servicenode=$$SN xcatmaster=$$SN -check:rc==0 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:service dhcpd restart -check:rc==0 -cmd:cat /var/lib/dhcpd/dhcpd.leases| grep $$CNWITHSN -check:output=~$$CNWITHSN -cmd:rm -rf /install/netboot/__GETNODEATTR($$CNWITHSN,os)__/x86_64/compute -check:rc==0 -cmd:genimage __GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-netboot-compute -check:rc==0 -cmd:packimage -o __GETNODEATTR($$CNWITHSN,os)__ -p compute -a __GETNODEATTR($$CNWITHSN,arch)__ -check:rc==0 -cmd:xdsh $$SN df|grep /install;if [ $? -ne 0 ] ;then xdsh $$SN mount $$MN:/install /install;fi -check:rc==0 -cmd:nodeset $$CNWITHSN osimage=__GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-netboot-compute -check:rc==0 -cmd:rpower $$CNWITHSN reset -check:rc==0 -cmd:sleep 300 -cmd:lsdef -l $$CNWITHSN | grep status -check:output=~booted -cmd:xdsh $$CNWITHSN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:nodeset $$CNWITHSN osimage -check:rc==0 -cmd:rpower $$CNWITHSN reset -check:rc==0 -cmd:sleep 300 -cmd:lsdef -l $$CNWITHSN | grep status -check:output=~booted -cmd:xdsh $$CNWITHSN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -end diff --git a/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_diskless_installation_x86_64_sles_vm b/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_diskless_installation_x86_64_sles_vm deleted file mode 100644 index b4d4bd1fc..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_diskless_installation_x86_64_sles_vm +++ /dev/null @@ -1,50 +0,0 @@ -start:Linux_cn_with_sn_diskless_installation_flat_x86_sles_vm -os:Linux -cmd:makedns -check:rc==0 -cmd:service named restart -check:rc==0 -cmd:makeconservercf -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$CNWITHSN -check:output=~$$CNWITHSN -cmd:sleep 60 -cmd:chdef $$CNWITHSN servicenode=$$SN xcatmaster=$$SN -check:rc==0 -cmd:makedhcp -n -#check:rc==0 -cmd:makedhcp -a -#check:rc==0 -cmd:service dhcpd restart -check:rc==0 -#cmd:cat /var/lib/dhcpd/dhcpd.leases| grep $$CNWITHSN -#check:output=~$$CNWITHSN -cmd:rm -rf /install/netboot/__GETNODEATTR($$CNWITHSN,os)__/x86_64/compute -check:rc==0 -cmd:genimage __GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-netboot-compute -check:rc==0 -cmd:packimage __GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-netboot-compute -check:rc==0 -cmd:xdsh $$SN df|grep /install;if [ $? -ne 0 ] ;then xdsh $$SN mount $$MN:/install /install;fi -check:rc==0 -cmd:nodeset $$CNWITHSN osimage=__GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-netboot-compute -check:rc==0 -cmd:rpower $$CNWITHSN reset -check:rc==0 -cmd:sleep 300 -cmd:lsdef -l $$CNWITHSN | grep status -check:output=~booted -cmd:xdsh $$CNWITHSN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:nodeset $$CNWITHSN osimage -check:rc==0 -cmd:rpower $$CNWITHSN reset -check:rc==0 -cmd:sleep 300 -cmd:lsdef -l $$CNWITHSN | grep status -check:output=~booted -cmd:xdsh $$CNWITHSN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -end diff --git a/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_full_installation_x86_64_redhat b/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_full_installation_x86_64_redhat deleted file mode 100644 index df0816007..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_full_installation_x86_64_redhat +++ /dev/null @@ -1,51 +0,0 @@ -start:Linux_cn_with_sn_full_installation_flat_x86_64_redhat -os:Linux -cmd:makedns -n -check:rc==0 -cmd:service named restart -check:rc==0 -cmd:makeconservercf $$CNWITHSN -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$CNWITHSN -check:output=~$$CNWITHSN -cmd:sleep 60 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:service dhcpd restart -check:rc==0 -cmd:chdef $$CNWITHSN servicenode=$$SN xcatmaster=$$SN -cmd:chdef -t osimage __GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-install-compute synclists=/install/custom/install/rh/compute.synclist -check:rc==0 -cmd:xdsh $$SN df|grep /install;if [ $? -ne 0 ] ; then xdsh $$SN mount $$MN:/install /install;fi -check:rc==0 -cmd:nodeset $$CNWITHSN osimage=__GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-install-compute -check:rc==0 -cmd:rsetboot $$CNWITHSN net -check:rc==0 -cmd:rpower $$CNWITHSN reset -check:rc==0 -cmd:sleep 1200 -cmd:ping $$CNWITHSN -c 3 -check:output=~64 bytes from $$CNWITHSN -cmd:lsdef -l $$CNWITHSN | grep status -check:output=~booted -cmd:xdsh $$CNWITHSN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:nodeset $$CNWITHSN osimage -check:rc==0 -cmd:rsetboot $$CNWITHSN net -check:rc==0 -cmd:rpower $$CNWITHSN reset -check:rc==0 -cmd:sleep 1200 -cmd:ping $$CNWITHSN -c 3 -check:output=~64 bytes from $$CNWITHSN -cmd:lsdef -l $$CNWITHSN | grep status -check:output=~booted -cmd:xdsh $$CNWITHSN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -end diff --git a/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_full_installation_x86_64_redhat_vm b/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_full_installation_x86_64_redhat_vm deleted file mode 100644 index d3dc53604..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_full_installation_x86_64_redhat_vm +++ /dev/null @@ -1,47 +0,0 @@ -start:Linux_cn_with_sn_full_installation_flat_x86_64_redhat_vm -os:Linux -cmd:makedns -check:rc==0 -cmd:service named restart -check:rc==0 -cmd:makeconservercf $$CNWITHSN -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$CNWITHSN -check:output=~$$CNWITHSN -cmd:sleep 60 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:service dhcpd restart -check:rc==0 -cmd:chdef $$CNWITHSN servicenode=$$SN xcatmaster=$$SN -cmd:chdef -t osimage __GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-install-compute synclists=/install/custom/install/rh/compute.synclist -check:rc==0 -cmd:xdsh $$SN df|grep /install;if [ $? -ne 0 ] ; then xdsh $$SN mount $$MN:/install /install;fi -check:rc==0 -cmd:nodeset $$CNWITHSN osimage=__GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-install-compute -check:rc==0 -cmd:rpower $$CNWITHSN reset -check:rc==0 -cmd:sleep 1200 -cmd:ping $$CNWITHSN -c 3 -check:output=~64 bytes from $$CNWITHSN -cmd:lsdef -l $$CNWITHSN | grep status -check:output=~booted -cmd:xdsh $$CNWITHSN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:nodeset $$CNWITHSN osimage -check:rc==0 -cmd:rpower $$CNWITHSN reset -check:rc==0 -cmd:sleep 1200 -cmd:ping $$CNWITHSN -c 3 -check:output=~64 bytes from $$CNWITHSN -cmd:lsdef -l $$CNWITHSN | grep status -check:output=~booted -cmd:xdsh $$CNWITHSN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -end diff --git a/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_full_installation_x86_64_sles_vm b/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_full_installation_x86_64_sles_vm deleted file mode 100644 index 7ff98c331..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_full_installation_x86_64_sles_vm +++ /dev/null @@ -1,47 +0,0 @@ -start:Linux_cn_with_sn_full_installation_flat_x86_64_sles_vm -os:Linux -cmd:makedns -check:rc==0 -cmd:service named restart -check:rc==0 -cmd:makeconservercf $$CNWITHSN -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$CNWITHSN -check:output=~$$CNWITHSN -cmd:sleep 60 -cmd:makedhcp -n -#check:rc==0 -cmd:makedhcp -a -#check:rc==0 -cmd:service dhcpd restart -check:rc==0 -cmd:chdef $$CNWITHSN servicenode=$$SN xcatmaster=$$SN -cmd:chdef -t osimage __GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-install-compute synclists=/install/custom/install/rh/compute.synclist -check:rc==0 -cmd:xdsh $$SN df|grep /install;if [ $? -ne 0 ] ; then xdsh $$SN mount $$MN:/install /install;fi -check:rc==0 -cmd:nodeset $$CNWITHSN osimage=__GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-install-compute -check:rc==0 -cmd:rpower $$CNWITHSN reset -check:rc==0 -cmd:sleep 2500 -cmd:ping $$CNWITHSN -c 3 -check:output=~64 bytes from $$CNWITHSN -cmd:lsdef -l $$CNWITHSN | grep status -check:output=~booted -cmd:xdsh $$CNWITHSN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:nodeset $$CNWITHSN osimage -check:rc==0 -cmd:rpower $$CNWITHSN reset -check:rc==0 -cmd:sleep 2500 -cmd:ping $$CNWITHSN -c 3 -check:output=~64 bytes from $$CNWITHSN -cmd:lsdef -l $$CNWITHSN | grep status -check:output=~booted -cmd:xdsh $$CNWITHSN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -end diff --git a/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_statelite_installation_x86_64_redhat b/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_statelite_installation_x86_64_redhat deleted file mode 100644 index 169cea3d6..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_statelite_installation_x86_64_redhat +++ /dev/null @@ -1,94 +0,0 @@ -start:Linux_cn_with_sn_statelite_installation_flat_x86_64_redhat -os:Linux -cmd:makedns -n -check:rc==0 -cmd:service named restart -check:rc==0 -cmd:makeconservercf $$CNWITHSN -check:rc==0 -cmd:sleep 90 -cmd:chdef $$CNWITHSN servicenode=$$SN xcatmaster=$$SN -check:rc==0 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:service dhcpd restart -check:rc==0 -cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/x86_64/compute -check:rc==0 -cmd:chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute rootfstype= -check:rc==0 -cmd:genimage __GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-statelite-compute -check:rc==0 -cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__ -check:rc==0 -cmd:tabrestore /opt/xcat/share/xcat/tools/autotest/testcase/installation/litefile.csv -check:rc==0 -cmd:tabdump litefile -check:rc==0 -cmd:mkdir -p /nodedata -cmd:chmod 755 /etc/exports -cmd:cat /etc/exports|grep nodedata; if [ "$?" -ne "0" ]; then echo "/nodedata *(rw,no_root_squash,sync,no_subtree_check)" >> /etc/exports; fi -check:rc==0 -cmd:cd /etc; export exports;cd - -check:rc==0 -cmd:service nfs restart -cmd:chtab node=$$CNWITHSN statelite.statemnt="$$MN:/nodedata" -check:rc==0 -cmd:chtab priority=4.7 policy.commands=litefile policy.rule=allow -check:rc==0 -cmd:chtab priority=4.8 policy.commands=litetree policy.rule=allow -check:rc==0 -cmd:liteimg -p compute -a __GETNODEATTR($$CNWITHSN,arch)__ -o __GETNODEATTR($$CNWITHSN,os)__ -check:rc==0 -cmd:xdsh $$SN df|grep /install;if [ $? -eq 0 ] ;then xdsh $$SN umount /install;fi -check:rc==0 -cmd:prsync /install $$SN:/ -check:rc==0 -cmd:nodeset $$CNWITHSN osimage=__GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-statelite-compute -check:rc==0 -cmd:rsetboot $$CNWITHSN net -check:rc==0 -cmd:rpower $$CNWITHSN reset -check:rc==0 -cmd:sleep 300 -cmd:lsdef -l $$CNWITHSN | grep status -check:output=~booted -cmd:xdsh $$CNWITHSN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:xdsh $$SN df|grep /install;if [ $? -ne 0 ] ;then xdsh $$SN mount $$MN:/install /install;fi -check:rc==0 -cmd:chdef -t osimage -o __GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-statelite-compute rootfstype=ramdisk -check:rc==0 -cmd:genimage __GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-statelite-compute -check:rc==0 -cmd:liteimg -p compute -a __GETNODEATTR($$CNWITHSN,arch)__ -o __GETNODEATTR($$CNWITHSN,os)__ -t ramdisk -check:rc==0 -cmd:nodeset $$CNWITHSN osimage=__GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-statelite-compute -check:rc==0 -cmd:rsetboot $$CNWITHSN net -check:rc==0 -cmd:rpower $$CNWITHSN reset -check:rc==0 -cmd:sleep 250 -cmd:lsdef -l $$CNWITHSN | grep status -check:output=~booted -cmd:xdsh $$CNWITHSN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:nodeset $$CNWITHSN osimage -check:rc==0 -cmd:rsetboot $$CNWITHSN net -check:rc==0 -cmd:rpower $$CNWITHSN reset -check:rc==0 -cmd:sleep 250 -cmd:lsdef -l $$CNWITHSN | grep status -check:output=~booted -cmd:xdsh $$CNWITHSN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -end - diff --git a/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_statelite_installation_x86_64_redhat_vm b/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_statelite_installation_x86_64_redhat_vm deleted file mode 100644 index 1c46f21b7..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_statelite_installation_x86_64_redhat_vm +++ /dev/null @@ -1,88 +0,0 @@ -start:Linux_cn_with_sn_statelite_installation_flat_x86_64_redhat_vm -os:Linux -cmd:makedns -check:rc==0 -cmd:service named restart -check:rc==0 -cmd:makeconservercf $$CNWITHSN -check:rc==0 -cmd:sleep 90 -cmd:chdef $$CNWITHSN servicenode=$$SN xcatmaster=$$SN -check:rc==0 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:service dhcpd restart -check:rc==0 -cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/x86_64/compute -check:rc==0 -cmd:chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute rootfstype= -check:rc==0 -cmd:genimage __GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-statelite-compute -check:rc==0 -cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__ -check:rc==0 -cmd:tabrestore /opt/xcat/share/xcat/tools/autotest/testcase/installation/litefile.csv -check:rc==0 -cmd:tabdump litefile -check:rc==0 -cmd:mkdir -p /nodedata -cmd:chmod 755 /etc/exports -cmd:cat /etc/exports|grep nodedata; if [ "$?" -ne "0" ]; then echo "/nodedata *(rw,no_root_squash,sync,no_subtree_check)" >> /etc/exports; fi -check:rc==0 -cmd:cd /etc; export exports;cd - -check:rc==0 -cmd:service nfs restart -cmd:chtab node=$$CNWITHSN statelite.statemnt="$$MN:/nodedata" -check:rc==0 -cmd:chtab priority=4.7 policy.commands=litefile policy.rule=allow -check:rc==0 -cmd:chtab priority=4.8 policy.commands=litetree policy.rule=allow -check:rc==0 -cmd:liteimg -p compute -a __GETNODEATTR($$CNWITHSN,arch)__ -o __GETNODEATTR($$CNWITHSN,os)__ -check:rc==0 -cmd:xdsh $$SN df|grep /install;if [ $? -eq 0 ] ;then xdsh $$SN umount /install;fi -check:rc==0 -cmd:prsync /install rhsnauto:/ -check:rc==0 -cmd:nodeset $$CNWITHSN osimage=__GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-statelite-compute -check:rc==0 -cmd:rpower $$CNWITHSN reset -check:rc==0 -cmd:sleep 350 -cmd:lsdef -l $$CNWITHSN | grep status -check:output=~booted -cmd:xdsh $$CNWITHSN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:chdef -t osimage -o __GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-statelite-compute rootfstype=ramdisk -check:rc==0 -cmd:xdsh $$SN df|grep /install;if [ $? -ne 0 ] ;then xdsh $$SN mount $$MN:/install /install;fi -check:rc==0 -cmd:genimage __GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-statelite-compute -check:rc==0 -cmd:liteimg __GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-statelite-compute -check:rc==0 -cmd:nodeset $$CNWITHSN osimage=__GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-statelite-compute -check:rc==0 -cmd:rpower $$CNWITHSN reset -check:rc==0 -cmd:sleep 350 -cmd:lsdef -l $$CNWITHSN | grep status -check:output=~booted -cmd:xdsh $$CNWITHSN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:nodeset $$CNWITHSN osimage -check:rc==0 -cmd:rpower $$CNWITHSN reset -check:rc==0 -cmd:sleep 350 -cmd:lsdef -l $$CNWITHSN | grep status -check:output=~booted -cmd:xdsh $$CNWITHSN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -end - diff --git a/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_statelite_installation_x86_64_sles_vm b/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_statelite_installation_x86_64_sles_vm deleted file mode 100644 index e4327e5ef..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_cn_with_sn_statelite_installation_x86_64_sles_vm +++ /dev/null @@ -1,88 +0,0 @@ -start:Linux_cn_with_sn_statelite_installation_flat_x86_sels_vm -os:Linux -cmd:makedns -check:rc==0 -cmd:service named restart -check:rc==0 -cmd:makeconservercf $$CNWITHSN -check:rc==0 -cmd:sleep 90 -cmd:chdef $$CNWITHSN servicenode=$$SN xcatmaster=$$SN -check:rc==0 -cmd:makedhcp -n -#check:rc==0 -cmd:makedhcp -a -#check:rc==0 -cmd:service dhcpd restart -check:rc==0 -cmd:rm -rf /install/netboot/__GETNODEATTR($$CNWITHSN,os)__/x86_64/compute -check:rc==0 -cmd:chdef -t osimage -o __GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-statelite-compute rootfstype= -check:rc==0 -cmd:genimage __GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-statelite-compute -check:rc==0 -cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__ -check:rc==0 -cmd:tabrestore /autotest/litefile_sles.csv -check:rc==0 -cmd:tabdump litefile -check:rc==0 -cmd:mkdir -p /nodedata -cmd:chmod 755 /etc/exports -cmd:cat /etc/exports|grep nodedata; if [ "$?" -ne "0" ]; then echo "/nodedata *(rw,no_root_squash,sync,no_subtree_check)" >> /etc/exports; fi -check:rc==0 -cmd:cd /etc; export exports;cd - -check:rc==0 -cmd:service nfs restart -cmd:chtab node=$$CNWITHSN statelite.statemnt="$$MN:/nodedata" -check:rc==0 -cmd:chtab priority=4.7 policy.commands=litefile policy.rule=allow -check:rc==0 -cmd:chtab priority=4.8 policy.commands=litetree policy.rule=allow -check:rc==0 -cmd:liteimg -p compute -a __GETNODEATTR($$CNWITHSN,arch)__ -o __GETNODEATTR($$CNWITHSN,os)__ -check:rc==0 -cmd:xdsh $$SN df|grep /install;if [ $? -eq 0 ] ;then xdsh $$SN umount /install;fi -check:rc==0 -cmd:prsync /install $$SN:/ -check:rc==0 -cmd:nodeset $$CNWITHSN osimage=__GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-statelite-compute -check:rc==0 -cmd:rpower $$CNWITHSN reset -check:rc==0 -cmd:sleep 240 -cmd:lsdef -l $$CNWITHSN | grep status -check:output=~booted -cmd:xdsh $$CNWITHSN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:xdsh $$SN df|grep /install;if [ $? -ne 0 ] ;then xdsh $$SN mount $$MN:/install /install;fi -check:rc==0 -cmd:chdef -t osimage -o __GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-statelite-compute rootfstype=ramdisk -check:rc==0 -cmd:genimage __GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-statelite-compute -check:rc==0 -cmd:liteimg __GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-statelite-compute -check:rc==0 -cmd:nodeset $$CNWITHSN osimage=__GETNODEATTR($$CNWITHSN,os)__-__GETNODEATTR($$CNWITHSN,arch)__-statelite-compute -check:rc==0 -cmd:rpower $$CNWITHSN reset -check:rc==0 -cmd:sleep 250 -cmd:lsdef -l $$CNWITHSN | grep status -check:output=~booted -cmd:xdsh $$CNWITHSN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:nodeset $$CNWITHSN osimage -check:rc==0 -cmd:rpower $$CNWITHSN reset -check:rc==0 -cmd:sleep 250 -cmd:lsdef -l $$CNWITHSN | grep status -check:output=~booted -cmd:xdsh $$CNWITHSN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -end - diff --git a/xCAT-test/autotest/testcase/installation/linux_diskless_installation b/xCAT-test/autotest/testcase/installation/linux_diskless_installation deleted file mode 100644 index 8665f6588..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_diskless_installation +++ /dev/null @@ -1,50 +0,0 @@ -start:Linux_diskless_installation_flat_ppc64 -os:Linux -cmd:rscan __GETNODEATTR($$CN,hcp)__ -w -check:rc==0 -cmd:makedns -check:rc==0 -cmd:service named restart -check:rc==0 -cmd:makeconservercf $$CN -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$CN -check:output=~$$CN -cmd:sleep 60 -cmd:getmacs $$CN -f -D -check:rc==0 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:service dhcpd restart -check:rc==0 -cmd:cat /var/lib/dhcpd/dhcpd.leases| grep $$CN -check:output=~$$CN -cmd:copycds $$ISO -check:rc==0 -cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -check:rc==0 -cmd:packimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -check:rc==0 -cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -check:rc==0 -cmd:rnetboot $$CN -check:rc==0 -cmd:sleep 300 -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:nodeset $$CN osimage -check:rc==0 -cmd:rnetboot $$CN -check:rc==0 -cmd:sleep 300 -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -end diff --git a/xCAT-test/autotest/testcase/installation/linux_diskless_installation_x86_64_redhat b/xCAT-test/autotest/testcase/installation/linux_diskless_installation_x86_64_redhat deleted file mode 100644 index 4d7331da2..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_diskless_installation_x86_64_redhat +++ /dev/null @@ -1,46 +0,0 @@ -start:Linux_diskless_installation_flat_x86_redhat -os:Linux -cmd:makedns -n -check:rc==0 -cmd:service named restart -check:rc==0 -cmd:makeconservercf $$CN -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$CN -check:output=~$$CN -cmd:sleep 60 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:service dhcpd restart -check:rc==0 -cmd:cat /var/lib/dhcpd/dhcpd.leases| grep $$CN -check:output=~$$CN -cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -check:rc==0 -cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__ -check:rc==0 -cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -check:rc==0 -cmd:rpower $$CN boot -check:rc==0 -cmd:sleep 300 -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:nodeset $$CN osimage -check:rc==0 -cmd:rpower $$CN reset -check:rc==0 -cmd:sleep 300 -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -end -~ - diff --git a/xCAT-test/autotest/testcase/installation/linux_diskless_installation_x86_64_sles b/xCAT-test/autotest/testcase/installation/linux_diskless_installation_x86_64_sles deleted file mode 100644 index e4e53ecf2..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_diskless_installation_x86_64_sles +++ /dev/null @@ -1,55 +0,0 @@ -start:Linux_diskless_installation_flat_x86_64_sles -os:Linux -cmd:makedns -n -check:rc==0 -cmd:service named restart -check:rc==0 -cmd:makeconservercf $$CN -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$CN -check:output=~$$CN -cmd:sleep 60 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:service dhcpd restart -check:rc==0 -cmd:cat /var/lib/dhcp/db/dhcpd.leases| grep $$CN -check:output=~$$CN -cmd:if [ ! -d /install/custom/netboot/sles ]; then mkdir -p /install/custom/netboot/sles; fi -check:rc==0 -cmd:if [ ! -e /install/custom/netboot/sles/compute.synclist ]; then echo "/etc/resolv.conf -> /etc/resolv.conf" > /install/custom/netboot/sles/compute.synclist; fi -check:rc==0 -cmd:chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute synclists=/install/custom/netboot/sles/compute.synclist -cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/x86_64/compute -check:rc==0 -cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -check:rc==0 -cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__ -check:rc==0 -cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -check:rc==0 -cmd:rsetboot $$CN net -check:rc==0 -cmd:rpower $$CN reset -check:rc==0 -cmd:sleep 200 -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:nodeset $$CN osimage -check:rc==0 -cmd:rsetboot $$CN net -check:rc==0 -cmd:rpower $$CN reset -check:rc==0 -cmd:sleep 200 -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -end diff --git a/xCAT-test/autotest/testcase/installation/linux_full_installation b/xCAT-test/autotest/testcase/installation/linux_full_installation deleted file mode 100644 index 1b927c496..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_full_installation +++ /dev/null @@ -1,48 +0,0 @@ -start:Linux_full_installation_flat_ppc64 -os:Linux -cmd:rscan __GETNODEATTR($$CN,hcp)__ -w -check:rc==0 -cmd:makedns -n -check:rc==0 -cmd:service named restart -check:rc==0 -cmd:makeconservercf $$CN -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$CN -check:output=~$$CN -cmd:sleep 60 -cmd:getmacs $$CN -f -D -check:rc==0 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:service dhcpd restart -check:rc==0 -cmd:copycds $$ISO -check:rc==0 -cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute -check:rc==0 -cmd:rnetboot $$CN -check:rc==0 -cmd:sleep 1800 -cmd:ping $$CN -c 3 -check:output=~64 bytes from $$CN -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:nodeset $$CN osimage -check:rc==0 -cmd:rnetboot $$CN -check:rc==0 -cmd:sleep 1200 -cmd:ping $$CN -c 3 -check:output=~64 bytes from $$CN -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -end diff --git a/xCAT-test/autotest/testcase/installation/linux_full_installation_x86_64_redhat b/xCAT-test/autotest/testcase/installation/linux_full_installation_x86_64_redhat deleted file mode 100644 index e18280099..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_full_installation_x86_64_redhat +++ /dev/null @@ -1,57 +0,0 @@ -start:Linux_full_installation_flat_x86_redhat -os:Linux -cmd:makedns -n -check:rc==0 -cmd:service named restart -check:rc==0 -cmd:sleep 60 -cmd:makedhcp -n -check:rc==0 -cmd:service named restart -check:rc==0 -cmd:makeconservercf $$CN -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$CN -check:output=~$$CN -cmd:getmacs $$CN -f -D -check:rc==0 -cmd:sleep 60 -cmd:makedns -a -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:copycds $$ISO -check: rc==0 -cmd:chdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute synclists=/install/custom/install/rh/compute.synclist -check:rc==0 -cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute -check:rc==0 -cmd:rsetboot $$CN net -check:rc==0 -cmd:rpower $$CN boot -check:rc==0 -cmd:sleep 1200 -cmd:ping $$CN -c 3 -check:output=~64 bytes from $$CN -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:nodeset $$CN osimage -check:rc==0 -cmd:rsetboot $$CN net -check:rc==0 -cmd:rpower $$CN boot -check:rc==0 -cmd:sleep 1200 -cmd:ping $$CN -c 3 -check:output=~64 bytes from $$CN -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -end - - diff --git a/xCAT-test/autotest/testcase/installation/linux_full_installation_x86_64_sles b/xCAT-test/autotest/testcase/installation/linux_full_installation_x86_64_sles deleted file mode 100644 index d9953a0b4..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_full_installation_x86_64_sles +++ /dev/null @@ -1,44 +0,0 @@ -start:Linux_full_installation_flat_x86_64_sles -os:Linux -cmd:makedhcp -n -check:rc==0 -cmd:makedns -n -check:rc==0 -cmd:service named restart -check:rc==0 -cmd:makeconservercf $$CN -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$CN -check:output=~$$CN -cmd:getmacs $$CN -f -D -check:rc==0 -cmd:sleep 60 -cmd:makedhcp -a -check:rc==0 -cmd:chdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute synclists=/install/custom/install/sles/compute.synclist -check:rc==0 -cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute -check:rc==0 -cmd:rpower $$CN boot -check:rc==0 -cmd:sleep 2000 -cmd:ping $$CN -c 3 -check:output=~64 bytes from $$CN -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:nodeset $$CN osimage -check:rc==0 -cmd:rpower $$CN boot -check:rc==0 -cmd:sleep 2000 -cmd:ping $$CN -c 3 -check:output=~64 bytes from $$CN -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -end diff --git a/xCAT-test/autotest/testcase/installation/linux_sles_diskless_installation_ppc64 b/xCAT-test/autotest/testcase/installation/linux_sles_diskless_installation_ppc64 deleted file mode 100644 index 85f550d77..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_sles_diskless_installation_ppc64 +++ /dev/null @@ -1,56 +0,0 @@ -start:Linux_sles_diskless_installation_ppc64_flat -os:Linux -cmd:rscan __GETNODEATTR($$CN,hcp)__ -w -check:rc==0 -cmd:makedns -n -check:rc==0 -cmd:service named restart -check:rc==0 -cmd:makeconservercf $$CN -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$CN -check:output=~$$CN -cmd:sleep 60 -cmd:getmacs $$CN -f -D -check:rc==0 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:service dhcpd restart -check:rc==0 -cmd:cat /var/lib/dhcp/db/dhcpd.leases| grep $$CN -check:output=~$$CN -cmd:copycds $$ISO -check:rc==0 -cmd:if [ ! -d /install/custom/netboot/sles ]; then mkdir -p /install/custom/netboot/sles; fi -check:rc==0 -cmd:if [ ! -e /install/custom/netboot/sles/compute.synclist ]; then echo "/etc/resolv.conf -> /etc/resolv.conf" > /install/custom/netboot/sles/compute.synclist; fi -check:rc==0 -cmd:chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute synclists=/install/custom/netboot/sles/compute.synclist -check:rc==0 -cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -check:rc==0 -cmd:packimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -check:rc==0 -cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -check:rc==0 -cmd:rnetboot $$CN -check:rc==0 -cmd:sleep 600 -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:nodeset $$CN osimage -check:rc==0 -cmd:rnetboot $$CN -check:rc==0 -cmd:sleep 600 -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -end diff --git a/xCAT-test/autotest/testcase/installation/linux_sles_statelite_installation_ppc64 b/xCAT-test/autotest/testcase/installation/linux_sles_statelite_installation_ppc64 deleted file mode 100644 index 6a56a3e60..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_sles_statelite_installation_ppc64 +++ /dev/null @@ -1,83 +0,0 @@ -start:Linux_sles_statelite_installation_flat_ppc64 -os:Linux -cmd:rm -rf /install/netboot -check:rc==0 -cmd:if [ ! -d /install/custom/netboot/sles ]; then mkdir -p /install/custom/netboot/sles; fi -check:rc==0 -cmd:if [ ! -e /install/custom/netboot/sles/compute.synclist ]; then echo "/etc/resolv.conf -> /etc/resolv.conf" > /install/custom/netboot/sles/compute.synclist; fi -check:rc==0 -cmd:tabrestore /opt/xcat/share/xcat/tools/autotest/testcase/installation/litefile_sles.csv -check:rc==0 -cmd:tabdump litefile -check:rc==0 -cmd:mkdir -p /nodedata -cmd:chmod 755 /etc/exports -cmd:cat /etc/exports|grep nodedata; if [ "$?" -ne "0" ]; then echo "/nodedata *(rw,no_root_squash,sync,no_subtree_check)" >> /etc/exports; fi -check:rc==0 -cmd:cd /etc; export exports;cd - -check:rc==0 -cmd:service nfsserver restart -cmd:chtab node=$$CN statelite.statemnt="$$MN:/nodedata" -check:rc==0 -cmd:chtab priority=4.7 policy.commands=litefile policy.rule=allow -check:rc==0 -cmd:chtab priority=4.8 policy.commands=litetree policy.rule=allow -check:rc==0 -cmd:makedns -n -check:rc==0 -cmd:service named restart -check:rc==0 -cmd:makeconservercf $$CN -check:rc==0 -cmd:sleep 60 -cmd:getmacs $$CN -D -check:rc==0 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:service dhcpd restart -check:rc==0 -cmd:copycds $$ISO -check:rc==0 -cmd:chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute synclists=/install/custom/netboot/sles/compute.synclist -check:rc==0 -cmd:genimage -n $$NETDRIVER __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -check:rc==0 -cmd:liteimg __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -check:rc==0 -cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -check:rc==0 -cmd:rnetboot $$CN -check:rc==0 -cmd:sleep 400 -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute rootfstype=ramdisk -check:rc==0 -cmd:liteimg __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -check:rc==0 -cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -check:rc==0 -cmd:rnetboot $$CN -check:rc==0 -cmd:sleep 400 -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:nodeset $$CN osimage -check:rc==0 -cmd:rnetboot $$CN -check:rc==0 -cmd:sleep 400 -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -end diff --git a/xCAT-test/autotest/testcase/installation/linux_sn_installation_x86_64 b/xCAT-test/autotest/testcase/installation/linux_sn_installation_x86_64 deleted file mode 100644 index 9e27c806a..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_sn_installation_x86_64 +++ /dev/null @@ -1,53 +0,0 @@ -#first define -start:Linux_sn_installation_flat_x86_64_redhat -os:Linux -cmd:makedns -n -check:rc==0 -cmd:chdef $$SN groups=service,all -check:rc==0 -cmd:chdef -t group service arch=__GETNODEATTR($$SN,arch)__ os=__GETNODEATTR($$SN,os)__ profile=service netboot=xnba primarynic=eth0 -check:rc==0 -cmd:chdef -t group -o service setupnfs=1 setupdhcp=1 setuptftp=1 setupnameserver=1 setupconserver=1 -check:rc==0 -cmd:chdef $$SN nfsserver=$$MN tftpserver=$$MN xcatmaster=$$MN -check:rc==0 -cmd:makeconservercf -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$SN -check:output=~$$SN -cmd:sleep 60 -cmd:makedhcp -n -cmd:makedhcp -a -check:rc==0 -cmd:service dhcpd restart -check:rc==0 -cmd:chdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-service synclists=/install/custom/install/rh/service.synclist -check:rc==0 -cmd:chdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-service otherpkglist=/opt/xcat/share/xcat/install/rh/service.rhels6.x86_64.otherpkgs.pkglist -check:rc==0 -cmd:mkdir -p /install/post/otherpkgs/rhels6.3/x86_64/xcat/ -check:rc==0 -cmd:cp -rf /xcat-core /install/post/otherpkgs/__GETNODEATTR($$CN,os)__/x86_64/xcat/ -check:rc==0 -cmd:createrepo /install/post/otherpkgs/__GETNODEATTR($$CN,os)__/x86_64/xcat/xcat-core -check:rc==0 -cmd:for i in mysql-server mysql mysql-bench mysql-devel mysql-connector-odbc; do cat /opt/xcat/share/xcat/install/rh/service.rhels6.x86_64.pkglist|grep "$i$";if [ $? -ne 0 ] ; then echo "$i" >> /opt/xcat/share/xcat/install/rh/service.rhels6.x86_64.pkglist; fi done -cmd:chtab node=service postscripts.postscripts="servicenode,odbcsetup" -check:rc==0 -cmd:nodeset $$SN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-service -check:rc==0 -cmd:rsetboot $$SN net -check:rc==0 -cmd:rpower $$SN reset -check:rc==0 -cmd:sleep 700 -cmd:ping $$SN -c 3 -check:output=~64 bytes from $$SN -cmd:lsdef -l $$SN | grep status -check:output=~booted -cmd:xdsh $$SN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:xdsh $$SN nodels -check:rc==0 -end diff --git a/xCAT-test/autotest/testcase/installation/linux_sn_installation_x86_64_redhat b/xCAT-test/autotest/testcase/installation/linux_sn_installation_x86_64_redhat deleted file mode 100644 index 66815d00e..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_sn_installation_x86_64_redhat +++ /dev/null @@ -1,53 +0,0 @@ -#first define -start:Linux_sn_installation_flat_x86_64_redhat -os:Linux -cmd:makedns -n -check:rc==0 -cmd:chdef $$SN groups=service,all -check:rc==0 -cmd:chdef -t group service arch=__GETNODEATTR($$SN,arch)__ os=__GETNODEATTR($$SN,os)__ profile=service netboot=xnba primarynic=eth0 -check:rc==0 -cmd:chdef -t group -o service setupnfs=1 setupdhcp=1 setuptftp=1 setupnameserver=1 setupconserver=1 -check:rc==0 -cmd:chdef $$SN nfsserver=$$MN tftpserver=$$MN xcatmaster=$$MN -check:rc==0 -cmd:makeconservercf -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$SN -check:output=~$$SN -cmd:sleep 60 -cmd:makedhcp -n -cmd:makedhcp -a -check:rc==0 -cmd:service dhcpd restart -check:rc==0 -cmd:chdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-service synclists=/install/custom/install/rh/service.synclist -check:rc==0 -cmd:chdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-service otherpkglist=/opt/xcat/share/xcat/install/rh/service.rhels6.x86_64.otherpkgs.pkglist -check:rc==0 -cmd:mkdir -p /install/post/otherpkgs/__GETNODEATTR($$CN,os)__/x86_64/xcat/ -check:rc==0 -cmd:cp -rf /xcat-core /install/post/otherpkgs/__GETNODEATTR($$CN,os)__/x86_64/xcat/ -check:rc==0 -cmd:createrepo /install/post/otherpkgs/__GETNODEATTR($$CN,os)__/x86_64/xcat/xcat-core -check:rc==0 -cmd:for i in mysql-server mysql mysql-bench mysql-devel mysql-connector-odbc; do cat /opt/xcat/share/xcat/install/rh/service.rhels6.x86_64.pkglist|grep "$i$";if [ $? -ne 0 ] ; then echo "$i" >> /opt/xcat/share/xcat/install/rh/service.rhels6.x86_64.pkglist; fi done -cmd:chtab node=service postscripts.postscripts="servicenode,odbcsetup" -check:rc==0 -cmd:nodeset $$SN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-service -check:rc==0 -cmd:rsetboot $$SN net -check:rc==0 -cmd:rpower $$SN reset -check:rc==0 -cmd:sleep 700 -cmd:ping $$SN -c 3 -check:output=~64 bytes from $$SN -cmd:lsdef -l $$SN | grep status -check:output=~booted -cmd:xdsh $$SN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:xdsh $$SN nodels -check:rc==0 -end diff --git a/xCAT-test/autotest/testcase/installation/linux_sn_installation_x86_64_redhat_vm b/xCAT-test/autotest/testcase/installation/linux_sn_installation_x86_64_redhat_vm deleted file mode 100644 index 8b145f4a8..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_sn_installation_x86_64_redhat_vm +++ /dev/null @@ -1,53 +0,0 @@ -#first define -start:Linux_sn_installation_flat_x86_64_redhat_vm -os:Linux -cmd:makedns -check:rc==0 -cmd:chdef $$SN groups=service,kvm,vm,all -check:rc==0 -cmd:chdef -t group service arch=__GETNODEATTR($$SN,arch)__ os=__GETNODEATTR($$SN,os)__ profile=service netboot=xnba primarynic=eth0 -check:rc==0 -cmd:chdef -t group -o service setupnfs=1 setupdhcp=1 setuptftp=1 setupnameserver=1 setupconserver=1 -check:rc==0 -cmd:chdef $$SN nfsserver=$$MN tftpserver=$$MN xcatmaster=$$MN -check:rc==0 -cmd:makeconservercf -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$SN -check:output=~$$SN -cmd:sleep 60 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:service dhcpd restart -check:rc==0 -cmd:chdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-service synclists=/install/custom/install/rh/service.synclist -check:rc==0 -cmd:chdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-service otherpkglist=/opt/xcat/share/xcat/install/rh/service.rhels6.x86_64.otherpkgs.pkglist -check:rc==0 -cmd:mkdir -p /install/post/otherpkgs/__GETNODEATTR($$CN,os)__/x86_64/xcat/ -check:rc==0 -cmd:cp -rf /2.8/xcat-core /install/post/otherpkgs/__GETNODEATTR($$CN,os)__/x86_64/xcat/ -check:rc==0 -cmd:createrepo /install/post/otherpkgs/__GETNODEATTR($$CN,os)__/x86_64/xcat/xcat-core -check:rc==0 -cmd:for i in mysql-server mysql mysql-bench mysql-devel mysql-connector-odbc iscsi-initiator-utils bridge-utils kvm perl-Sys-Virt; do cat /opt/xcat/share/xcat/install/rh/service.rhels6.x86_64.pkglist|grep "$i$";if [ $? -ne 0 ] ; then echo "$i" >> /opt/xcat/share/xcat/install/rh/service.rhels6.x86_64.pkglist; fi done -cmd:chtab node=service postscripts.postscripts="servicenode,odbcsetup" -check:rc==0 -cmd:nodeset $$SN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-service -check:rc==0 -cmd:rpower $$SN off -cmd:rpower $$SN on -check:rc==0 -cmd:sleep 1200 -cmd:ping $$SN -c 3 -check:output=~64 bytes from $$SN -cmd:lsdef -l $$SN | grep status -check:output=~booted -cmd:xdsh $$SN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:xdsh $$SN nodels -check:rc==0 -end diff --git a/xCAT-test/autotest/testcase/installation/linux_sn_installation_x86_64_sles b/xCAT-test/autotest/testcase/installation/linux_sn_installation_x86_64_sles deleted file mode 100644 index 74600f1e7..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_sn_installation_x86_64_sles +++ /dev/null @@ -1,53 +0,0 @@ -#first define -start:Linux_sn_installation_flat_x86_64_sles -os:Linux -cmd:makedns -n -check:rc==0 -cmd:chdef $$SN groups=ipmi,service,all -check:rc==0 -cmd:chdef -t group service arch=__GETNODEATTR($$SN,arch)__ os=__GETNODEATTR($$SN,os)__ profile=service netboot=xnba primarynic=eth0 -check:rc==0 -cmd:chdef -t group -o service setupnfs=1 setupdhcp=1 setuptftp=1 setupnameserver=1 setupconserver=1 -check:rc==0 -cmd:chdef $$SN nfsserver=$$MN tftpserver=$$MN xcatmaster=$$MN -check:rc==0 -cmd:makeconservercf -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$SN -check:output=~$$SN -cmd:sleep 60 -cmd:makedhcp -n -cmd:makedhcp -a -check:rc==0 -cmd:service dhcpd restart -check:rc==0 -cmd:chdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-service synclists=/install/custom/install/sles/service.synclist -check:rc==0 -cmd:chdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-service otherpkglist=/opt/xcat/share/xcat/install/sles/service.sles11.x86_64.otherpkgs.pkglist -check:rc==0 -cmd:mkdir -p /install/post/otherpkgs/sles11.2/x86_64/xcat/ -check:rc==0 -cmd:cp -rf /xcat-core /install/post/otherpkgs/sles11.2/x86_64/xcat/ -check:rc==0 -cmd:createrepo /install/post/otherpkgs/sles11.2/x86_64/xcat/xcat-core -check:rc==0 -cmd:for i in mysql-client libmysqlclient_r15 libqt4-sql-mysql libmysqlclient15 perl-DBD-mysql mysql iscsi-initiator-utils bridge-utils kvm perl-Sys-Virt; do cat /opt/xcat/share/xcat/install/sles/service.sles11.pkglist|grep "$i$";if [ $? -ne 0 ] ; then echo "$i" >> /opt/xcat/share/xcat/install/sles/service.sles11.pkglist; fi done -cmd:chtab node=service postscripts.postscripts="servicenode,odbcsetup" -check:rc==0 -cmd:nodeset $$SN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-service -check:rc==0 -cmd:rsetboot $$SN net -check:rc==0 -cmd:rpower $$SN reset -check:rc==0 -cmd:sleep 3000 -cmd:ping $$SN -c 3 -check:output=~64 bytes from $$SN -cmd:lsdef -l $$SN | grep status -check:output=~booted -cmd:xdsh $$SN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:xdsh $$SN nodels -check:rc==0 -end diff --git a/xCAT-test/autotest/testcase/installation/linux_sn_installation_x86_64_sles_vm b/xCAT-test/autotest/testcase/installation/linux_sn_installation_x86_64_sles_vm deleted file mode 100644 index 573c7032f..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_sn_installation_x86_64_sles_vm +++ /dev/null @@ -1,63 +0,0 @@ -#first define -start:Linux_sn_installation_flat_x86_64_sles_vm -os:Linux -cmd:makedns -n -check:rc==0 -cmd:chdef $$SN groups=service,kvm,vm,all -check:rc==0 -cmd:chdef -t group service arch=__GETNODEATTR($$SN,arch)__ os=__GETNODEATTR($$SN,os)__ profile=service netboot=xnba primarynic=eth0 -check:rc==0 -cmd:chdef -t group -o service setupnfs=1 setupdhcp=1 setuptftp=1 setupnameserver=1 setupconserver=1 -check:rc==0 -cmd:chdef $$SN nfsserver=$$MN tftpserver=$$MN xcatmaster=$$MN -check:rc==0 -cmd:makeconservercf -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$SN -check:output=~$$SN -cmd:sleep 60 -cmd:makedhcp -n -cmd:makedhcp -a -#check:rc==0 -cmd:service dhcpd restart -check:rc==0 -cmd:chdef -t osimage __GETNODEATTR($$SN,os)__-__GETNODEATTR($$SN,arch)__-install-service synclists=/install/custom/install/sles/service.synclist -check:rc==0 -cmd:chdef -t osimage __GETNODEATTR($$SN,os)__-__GETNODEATTR($$SN,arch)__-install-service pkgdir="/install/__GETNODEATTR($$SN,os)__/x86_64,/install/__GETNODEATTR($$SN,os)__/x86_64/sdk1" -check:rc==0 -cmd:chdef -t osimage __GETNODEATTR($$SN,os)__-__GETNODEATTR($$SN,arch)__-install-service otherpkglist=/opt/xcat/share/xcat/install/sles/service.sles11.x86_64.otherpkgs.pkglist -check:rc==0 -cmd:mkdir -p /install/post/otherpkgs/__GETNODEATTR($$SN,os)__/x86_64/xcat/ -check:rc==0 -cmd:cp -rf /xcat-core /install/post/otherpkgs/__GETNODEATTR($$SN,os)__/x86_64/xcat/ -check:rc==0 -cmd:createrepo /install/post/otherpkgs/__GETNODEATTR($$SN,os)__/x86_64/xcat/xcat-core -check:rc==0 -cmd:for i in mysql-client libmysqlclient_r15 libqt4-sql-mysql libmysqlclient15 perl-DBD-mysql mysql bridge-utils iscsitarget libvirt kvm libvirt-devel gcc; do cat /opt/xcat/share/xcat/install/sles/service.sles11.pkglist|grep "$i$";if [ $? -ne 0 ] ; then echo "$i" >> /opt/xcat/share/xcat/install/sles/service.sles11.pkglist; fi done -cmd:chtab node=service postscripts.postscripts="servicenode,odbcsetup" -check:rc==0 -cmd:nodeset $$SN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-service -check:rc==0 -cmd:rpower $$SN reset -check:rc==0 -cmd:sleep 2400 -cmd:ping $$SN -c 3 -check:output=~64 bytes from $$SN -cmd:lsdef -l $$SN | grep status -check:output=~booted -cmd:xdsh $$SN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:xdsh $$SN nodels -check:rc==0 -cmd:xdsh $$SN mkdir -p /autotest -check:rc==0 -cmd:scp /autotest/Sys-Virt-0.9.5.tar slessnauto:/autotest/ -check:rc==0 -cmd:xdsh $$SN tar xvf /autotest/Sys-Virt-0.9.5.tar -check:rc==0 -cmd:xdsh $$SN "cd /root/Sys-Virt-0.9.5/; perl Makefile.PL" -check:rc==0 -cmd:xdsh $$SN "cd Sys-Virt-0.9.5 ;perl Makefile.PL; sleep 10; make" -cmd:xdsh $$SN "cd Sys-Virt-0.9.5 ;sudo make install" -end diff --git a/xCAT-test/autotest/testcase/installation/linux_statelite_installation b/xCAT-test/autotest/testcase/installation/linux_statelite_installation deleted file mode 100644 index 286506fc7..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_statelite_installation +++ /dev/null @@ -1,77 +0,0 @@ -start:Linux_statelite_installation_flat_ppc64 -os:Linux -cmd:makedns -n -check:rc==0 -cmd:service named restart -check:rc==0 -cmd:makeconservercf $$CN -check:rc==0 -cmd:sleep 90 -cmd:getmacs $$CN -D -check:rc==0 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:service dhcpd restart -check:rc==0 -cmd:copycds $$ISO -check:rc==0 -cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -check:rc==0 -cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__ -check:rc==0 -cmd:tabrestore /opt/xcat/share/xcat/tools/autotest/testcase/installation/litefile.csv -check:rc==0 -cmd:tabdump litefile -check:rc==0 -cmd:mkdir -p /nodedata -cmd:chmod 755 /etc/exports -cmd:cat /etc/exports|grep nodedata; if [ "$?" -ne "0" ]; then echo "/nodedata *(rw,no_root_squash,sync,no_subtree_check)" >> /etc/exports; fi -check:rc==0 -cmd:cd /etc; export exports;cd - -check:rc==0 -cmd:service nfs restart -cmd:chtab node=$$CN statelite.statemnt="$$MN:/nodedata" -check:rc==0 -cmd:chtab priority=4.7 policy.commands=litefile policy.rule=allow -check:rc==0 -cmd:chtab priority=4.8 policy.commands=litetree policy.rule=allow -check:rc==0 -cmd:liteimg -p compute -a __GETNODEATTR($$CN,arch)__ -o __GETNODEATTR($$CN,os)__ -check:rc==0 -cmd:nodeset $$CN statelite -check:rc==0 -cmd:rnetboot $$CN -check:rc==0 -cmd:sleep 400 -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute rootfstype=ramdisk -check:rc==0 -cmd:liteimg -p compute -a __GETNODEATTR($$CN,arch)__ -o __GETNODEATTR($$CN,os)__ -t ramdisk -check:rc==0 -cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -check:rc==0 -cmd:rnetboot $$CN -check:rc==0 -cmd:sleep 400 -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:nodeset $$CN osimage -check:rc==0 -cmd:rnetboot $$CN -check:rc==0 -cmd:sleep 400 -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -end diff --git a/xCAT-test/autotest/testcase/installation/linux_statelite_installation_x86_64_redhat b/xCAT-test/autotest/testcase/installation/linux_statelite_installation_x86_64_redhat deleted file mode 100644 index 23a7ce894..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_statelite_installation_x86_64_redhat +++ /dev/null @@ -1,66 +0,0 @@ -start:Linux_statelite_installation_flat_x86_64_redhat -os:Linux -cmd:makedns -n -check:rc==0 -cmd:service named restart -check:rc==0 -cmd:makeconservercf $$CN -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$CN -check:output=~$$CN -cmd:sleep 60 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:service dhcpd restart -check:rc==0 -cmd:cat /var/lib/dhcp/db/dhcpd.leases| grep $$CN -check:output=~$$CN -cmd:tabrestore /opt/xcat/share/xcat/tools/autotest/testcase/installation/litefile.csv -check:rc==0 -cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -check:rc==0 -cmd:mkdir -p /nodedata -check:rc==0 -cmd:chmod 755 /etc/exports -check:rc==0 -cmd:cat /etc/exports|grep nodedata; if [ "$?" -ne "0" ]; then echo "/nodedata *(rw,no_root_squash,sync,no_subtree_check)" >> /etc/exports; fi -check:rc==0 -cmd:cd /etc; export exports;cd - -check:rc==0 -cmd:service nfs restart -check:rc==0 -cmd:chtab node=$$CN statelite.statemnt="$$MN:/nodedata" -check:rc==0 -cmd:chtab priority=4.7 policy.commands=litefile policy.rule=allow -check:rc==0 -cmd:chtab priority=4.8 policy.commands=litetree policy.rule=allow -check:rc==0 -cmd:liteimg __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -check:rc==0 -cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -check:rc==0 -cmd:rpower $$CN reset -check:rc==0 -cmd:sleep 200 -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute rootfstype=ramdisk -check:rc==0 -cmd:liteimg -p compute -a __GETNODEATTR($$CN,arch)__ -o __GETNODEATTR($$CN,os)__ -t ramdisk -check:rc==0 -cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -check:rc==0 -cmd:rpower $$CN reset -check:rc==0 -cmd:sleep 200 -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -end diff --git a/xCAT-test/autotest/testcase/installation/linux_statelite_installation_x86_64_sles b/xCAT-test/autotest/testcase/installation/linux_statelite_installation_x86_64_sles deleted file mode 100644 index 631a1d225..000000000 --- a/xCAT-test/autotest/testcase/installation/linux_statelite_installation_x86_64_sles +++ /dev/null @@ -1,66 +0,0 @@ -start:Linux_statelite_installation_flat_x86_64_sles -os:Linux -cmd:makedns -n -check:rc==0 -cmd:service named restart -check:rc==0 -cmd:makeconservercf $$CN -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$CN -check:output=~$$CN -cmd:sleep 60 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:service dhcpd restart -check:rc==0 -cmd:cat /var/lib/dhcp/db/dhcpd.leases| grep $$CN -check:output=~$$CN -cmd:tabrestore /opt/xcat/share/xcat/tools/autotest/testcase/installation/litefile_sles.csv -check:rc==0 -cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -check:rc==0 -cmd:mkdir -p /nodedata -check:rc==0 -cmd:chmod 755 /etc/exports -check:rc==0 -cmd:cat /etc/exports|grep nodedata; if [ "$?" -ne "0" ]; then echo "/nodedata *(rw,no_root_squash,sync,no_subtree_check)" >> /etc/exports; fi -check:rc==0 -cmd:cd /etc; export exports;cd - -check:rc==0 -cmd:service nfsserver restart -check:rc==0 -cmd:chtab node=$$CN statelite.statemnt="$$MN:/nodedata" -check:rc==0 -cmd:chtab priority=4.7 policy.commands=litefile policy.rule=allow -check:rc==0 -cmd:chtab priority=4.8 policy.commands=litetree policy.rule=allow -check:rc==0 -cmd:liteimg __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -check:rc==0 -cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -check:rc==0 -cmd:rpower $$CN reset -check:rc==0 -cmd:sleep 200 -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute rootfstype=ramdisk -check:rc==0 -cmd:liteimg -p compute -a __GETNODEATTR($$CN,arch)__ -o __GETNODEATTR($$CN,os)__ -t ramdisk -check:rc==0 -cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -check:rc==0 -cmd:rpower $$CN reset -check:rc==0 -cmd:sleep 200 -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -end diff --git a/xCAT-test/autotest/testcase/installation/reg_linux_diskfull_installation_flat_confignics_s b/xCAT-test/autotest/testcase/installation/reg_linux_diskfull_installation_flat_confignics_s deleted file mode 100644 index 2b9c7c948..000000000 --- a/xCAT-test/autotest/testcase/installation/reg_linux_diskfull_installation_flat_confignics_s +++ /dev/null @@ -1,71 +0,0 @@ -start:reg_linux_diskfull_installation_flat_confignics_s -os:Linux - -cmd:if ping -c 1 $$SN > /dev/null;then rpower $$SN off > /dev/null;fi - -cmd:chdef -t node -o $$CN servicenode= monserver=$$MN nfsserver=$$MN tftpserver=$$MN xcatmaster=$$MN -check:rc==0 - -cmd:makedns -n -check:rc==0 -cmd:makeconservercf -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$CN -check:output=~$$CN -cmd:sleep 20 -cmd:if [[ "__GETNODEATTR($$CN,arch)__" =~ "ppc64" ]]; then getmacs -D $$CN; fi -check:rc==0 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:if cat /etc/*release |grep SUSE >/dev/null;then cat /var/lib/dhcp/db/dhcpd.leases|grep $$CN;elif cat /etc/*release |grep "Red Hat" >/dev/null;then cat /var/lib/dhcpd/dhcpd.leases|grep $$CN;fi -check:output=~$$CN - -cmd:copycds $$ISO -check:rc==0 - -cmd:chdef $$CN postscripts="confignics -s" -check:rc==0 - -cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute -check:rc==0 -cmd:lsdef $$CN |grep provmethod -check:rc==0 -check:output=~__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute -cmd:if [[ "__GETNODEATTR($$CN,arch)__" =~ "ppc64" ]]; then rnetboot $$CN;elif [[ "__GETNODEATTR($$CN,arch)__" =~ "x86_64" ]];then rpower $$CN boot; fi -check:rc==0 - -cmd:if [[ "__GETNODEATTR($$CN,arch)__" =~ "ppc" ]]; then sleep 120;elif [[ "__GETNODEATTR($$CN,arch)__" =~ "x86_64" ]];then sleep 80;else sleep 180;fi - -cmd:lsdef -l $$CN | grep status -check:rc==0 -check:output!~booted - -cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 300 ];then break;fi done - -cmd:ping $$CN -c 3 -check:rc==0 -check:output=~64 bytes from $$CN -cmd:lsdef -l $$CN | grep status -check:rc==0 -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:xdsh $$CN mount -check:rc==0 -check:output=~on / type ext - -cmd:port=`xdsh $$CN ip addr |grep $$INSTALLNICIP |cut -f 12 -d ' '`;if [ "$$OS" = "ubuntu" ];then xdsh $$CN cat /etc/network/interfaces.d/$port ; elif [ "$$OS" = "rhels" ]; then xdsh $$CN cat /etc/sysconfig/network-scripts/ifcfg-$port;else xdsh $$CN cat /etc/sysconfig/network/ifcfg-$port; fi -check:output=~$$INSTALLNICIP -check:output=~static -check:output!=\d\d:\d\d:\d\d - - -cmd:if [ "$$OS" = "ubuntu" ];then xdsh $$CN cat /etc/network/interfaces ; elif [ "$$OS" = "rhels" ]; then xdsh $$CN cat /etc/sysconfig/network;else xdsh $$CN cat /etc/sysconfig/network/routes; fi -check:rc==0 -check:output=~$$GATEWAY - - -end diff --git a/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy b/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy deleted file mode 100644 index 6ffbfddd4..000000000 --- a/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy +++ /dev/null @@ -1,141 +0,0 @@ -start:reg_linux_statelite_installation_hierarchy -os:Linux -stop:yes - -cmd:MNIP=`cat /etc/hosts|grep $$MN|awk '{print $1}'`;sed -i "s:nameserver .*:nameserver $MNIP:g" /etc/resolv.conf - -cmd:chdef -t node -o $$CN servicenode=$$SN monserver=$$SN nfsserver=$$SN tftpserver=$$SN xcatmaster=$$SN -check:rc==0 -cmd:chdef -t node $$SN groups=service,all -check:rc==0 - -cmd:makedns -n -check:rc==0 -cmd:makeconservercf -check:rc==0 -cmd:sleep 20 -cmd:if [[ "__GETNODEATTR($$CN,arch)__" =~ "ppc64" ]]; then getmacs -D $$CN; fi -check:rc==0 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 - -cmd:copycds $$ISO -check:rc==0 -cmd:mkdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -u profile=compute provmethod=statelite osvers=__GETNODEATTR($$CN,os)__ -check:rc==0 -cmd:xdsh $$SN df|grep /install;if [ $? -eq 0 ] ;then xdsh $$SN umount /install;fi -check:rc==0 -cmd:xdsh $$SN 'cat /etc/exports|grep install; if [ "$?" -ne "0" ]; then echo "/install *(rw,no_root_squash,sync,no_subtree_check)" >> /etc/exports; fi' -check:rc==0 - -cmd:xdsh $$SN "mkdir -p /nodedata" -check:rc==0 -cmd:xdsh $$SN "chmod 755 /etc/exports" -check:rc==0 -cmd:xdsh $$SN 'cat /etc/exports|grep nodedata; if [ "$?" -ne "0" ]; then echo "/nodedata *(rw,no_root_squash,sync,no_subtree_check)" >> /etc/exports; fi' -check:rc==0 -cmd:xdsh $$SN 'cd /etc; export exports;cd -' -check:rc==0 -cmd:if cat /etc/*release |grep SUSE >/dev/null;then xdsh $$SN 'service nfsserver restart'; elif cat /etc/*release |grep "Red Hat" >/dev/null;then xdsh $$SN 'service nfs restart'; fi -check:rc==0 - -cmd:chtab node=$$CN statelite.statemnt="$$SN:/nodedata" -check:rc==0 - -cmd:if cat /etc/*release |grep SUSE >/dev/null; then cp /opt/xcat/share/xcat/tools/autotest/testcase/installation/litefile_sles.csv /tmp/litefile.csv; tabrestore /tmp/litefile.csv; elif cat /etc/*release |grep "Red Hat" >/dev/null; then tabrestore /opt/xcat/share/xcat/tools/autotest/testcase/installation/litefile.csv; fi -check:rc==0 -cmd:tabdump litefile -check:rc==0 - -cmd:chtab priority=4.7 policy.commands=litefile policy.rule=allow -check:rc==0 -cmd:chtab priority=4.8 policy.commands=litetree policy.rule=allow -check:rc==0 - -cmd:rootimgdir=`lsdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute|grep rootimgdir|awk -F'=' '{print $2}'`; if [ -d $rootimgdir ]; then mv $rootimgdir $rootimgdir.regbak;fi -check:rc==0 - -cmd:if cat /etc/*release |grep SUSE >/dev/null;then if [ ! -d /install/custom/netboot/sles ]; then mkdir -p /install/custom/netboot/sles; fi; elif cat /etc/*release |grep "Red Hat" >/dev/null;then if [ ! -d /install/custom/netboot/rh ]; then mkdir -p /install/custom/netboot/rh; fi;fi -check:rc==0 -cmd:if cat /etc/*release |grep SUSE >/dev/null;then if [ ! -e /install/custom/netboot/sles/compute.synclist ]; then echo "/etc/resolv.conf -> /etc/resolv.conf" > /install/custom/netboot/sles/compute.synclist; fi; elif cat /etc/*release |grep "Red Hat" >/dev/null;then if [ ! -e /install/custom/netboot/rh/compute.synclist ]; then echo "/etc/resolv.conf -> /etc/resolv.conf" > /install/custom/netboot/rh/compute.synclist; fi;fi -check:rc==0 -cmd:if cat /etc/*release |grep SUSE >/dev/null;then chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute synclists=/install/custom/netboot/sles/compute.synclist rootfstype=; elif cat /etc/*release |grep "Red Hat" >/dev/null;then chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute synclists=/install/custom/netboot/rh/compute.synclist rootfstype=; fi -check:rc==0 - -cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -check:rc==0 -cmd:liteimg __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -check:rc==0 -cmd:prsync /install $$SN:/ -check:rc==0 - -cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -check:rc==0 -cmd:lsdef $$CN |grep provmethod -check:rc==0 -check:output=~statelite -cmd:if [[ "__GETNODEATTR($$CN,arch)__" =~ "ppc64" ]]; then rnetboot $$CN;elif [[ "__GETNODEATTR($$CN,arch)__" =~ "x86_64" ]];then rpower $$CN boot; fi -check:rc==0 - -cmd:sleep 900 -cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 60 ];then break;fi done - -cmd:ping $$CN -c 3 -check:rc==0 -check:output=~64 bytes from $$CN -cmd:lsdef -l $$CN | grep status -check:rc==0 -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:xdsh $$CN mount -check:rc==0 -check:output=~/nodedata/$$CN on /.statelite/persistent -check:output=~compute/rootimg on / type nfs - - -cmd:rootimgdir=`lsdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute|grep rootimgdir|awk -F'=' '{print $2}'`; if [ -d $rootimgdir ]; then rm -rf $rootimgdir;fi -check:rc==0 - -cmd:chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute rootfstype=ramdisk -check:rc==0 -cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -check:rc==0 -cmd:liteimg __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -check:rc==0 -cmd:prsync /install $$SN:/ -check:rc==0 - -cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -check:rc==0 -cmd:lsdef $$CN |grep provmethod -check:rc==0 -check:output=~__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -cmd:if [[ "__GETNODEATTR($$CN,arch)__" =~ "ppc64" ]]; then rnetboot $$CN;elif [[ "__GETNODEATTR($$CN,arch)__" =~ "x86_64" ]];then rpower $$CN boot; fi -check:rc==0 - -cmd:sleep 900 -cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 60 ];then break;fi done - -cmd:ping $$CN -c 3 -check:rc==0 -check:output=~64 bytes from $$CN -cmd:lsdef -l $$CN | grep status -check:rc==0 -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:xdsh $$CN mount -check:rc==0 -check:output=~/nodedata/$$CN on /.statelite/persistent -check:output=~rootfs on / type - -cmd:rootimgdir=`lsdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute|grep rootimgdir|awk -F'=' '{print $2}'`; if [ -d $rootimgdir.regbak ]; then rm -rf $rootimgdir; mv $rootimgdir.regbak $rootimgdir; fi -check:rc==0 -cmd:rmdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute -check:rc==0 -end diff --git a/xCAT-test/autotest/testcase/installation/sles_full_installation_p8le b/xCAT-test/autotest/testcase/installation/sles_full_installation_p8le deleted file mode 100644 index 989225fa1..000000000 --- a/xCAT-test/autotest/testcase/installation/sles_full_installation_p8le +++ /dev/null @@ -1,42 +0,0 @@ -start:sles_full_installation_flat_p8le_vm -os:Linux -cmd:makedns -n -check:rc==0 -cmd:makeconservercf $$CN -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$CN -check:output=~$$CN -cmd:sleep 60 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:if [ ! -e /install/custom/netboot/sles/compute.synclist ]; then echo "/etc/resolv.conf -> /etc/resolv.conf" > /install/custom/netboot/sles/compute.synclist; fi -check:rc==0 -cmd:chdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute synclists=/install/custom/install/sles/compute.synclist -check:rc==0 -cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute -check:rc==0 -cmd:rpower $$CN reset -check:rc==0 -cmd:sleep 2000 -cmd:ping $$CN -c 3 -check:output=~64 bytes from $$CN -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:nodeset $$CN osimage -check:rc==0 -cmd:rpower $$CN boot -check:rc==0 -cmd:sleep 2000 -cmd:ping $$CN -c 3 -check:output=~64 bytes from $$CN -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -end diff --git a/xCAT-test/autotest/testcase/installation/ubuntu_diskless_installation_cudafull b/xCAT-test/autotest/testcase/installation/ubuntu_diskless_installation_cudafull deleted file mode 100644 index b9335eeb7..000000000 --- a/xCAT-test/autotest/testcase/installation/ubuntu_diskless_installation_cudafull +++ /dev/null @@ -1,39 +0,0 @@ -start:Ubuntu_diskless_installation_p8le_vm_cudafull -os:Linux -cmd:if [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu14.04" ]];then ver=ubuntu1404;elif [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu14.10" ]];then ver=ubuntu1410; fi;echo "deb http://developer.download.nvidia.com/compute/cuda/repos/$ver/__GETNODEATTR($$CN,arch)__ /" >> /etc/apt/sources.list -cmd:makedns -n -check:rc==0 -cmd:makeconservercf $$CN -check:rc==0 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:if [ ! -d /install/custom/netboot/ubuntu ]; then mkdir -p /install/custom/netboot/ubuntu; fi -check:rc==0 -cmd:if [ ! -e /install/custom/netboot/ubuntu/compute.synclist ]; then echo "/etc/resolv.conf -> /etc/resolv.conf" > /install/custom/netboot/ubuntu/compute.synclist; fi -check:rc==0 -cmd:chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -p pkgdir="http://ports.ubuntu.com/ubuntu-ports trusty main,http://ports.ubuntu.com/ubuntu-ports trusty-updates main" -cmd:if [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu14.04" ]];then ver=ubuntu1404;elif [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu14.10" ]];then ver=ubuntu1410; fi;chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute otherpkgdir="http://developer.download.nvidia.com/compute/cuda/repos/$ver/__GETNODEATTR($$CN,arch)__ /" otherpkglist="/opt/xcat/share/xcat/netboot/ubuntu/cudafull.otherpkgs.pkglist" pkglist="/opt/xcat/share/xcat/netboot/ubuntu/cudafull.__GETNODEATTR($$CN,os)__.__GETNODEATTR($$CN,arch)__-.pkglist" rootimgdir="/install/netboot/ __GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/cudafull" -cmd:apt-get install -y acpid -check:rc==0 -cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/x86_64/compute -check:rc==0 -cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -check:rc==0 -cmd:packimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -check:rc==0 -cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -check:rc==0 -cmd:rpower $$CN reset -check:rc==0 -cmd:sleep 200 -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:xdsh $$CN dpkg -l |grep cuda -check:rc==0 -check:output=~cuda -end diff --git a/xCAT-test/autotest/testcase/installation/ubuntu_diskless_installation_cudaruntime b/xCAT-test/autotest/testcase/installation/ubuntu_diskless_installation_cudaruntime deleted file mode 100644 index 777916ec6..000000000 --- a/xCAT-test/autotest/testcase/installation/ubuntu_diskless_installation_cudaruntime +++ /dev/null @@ -1,39 +0,0 @@ -start:Ubuntu_diskless_installation_vm_cudaruntime -os:Linux -cmd:if [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu14.04" ]];then ver=ubuntu1404;elif [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu14.10" ]];then ver=ubuntu1410; fi;echo "deb http://developer.download.nvidia.com/compute/cuda/repos/$ver/__GETNODEATTR($$CN,arch)__ /" >> /etc/apt/sources.list -cmd:makedns -n -check:rc==0 -cmd:makeconservercf $$CN -check:rc==0 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:if [ ! -d /install/custom/netboot/ubuntu ]; then mkdir -p /install/custom/netboot/ubuntu; fi -check:rc==0 -cmd:if [ ! -e /install/custom/netboot/ubuntu/compute.synclist ]; then echo "/etc/resolv.conf -> /etc/resolv.conf" > /install/custom/netboot/ubuntu/compute.synclist; fi -check:rc==0 -cmd:chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -p pkgdir="http://ports.ubuntu.com/ubuntu-ports trusty main,http://ports.ubuntu.com/ubuntu-ports trusty-updates main " -cmd:if [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu14.04" ]];then ver=ubuntu1404;elif [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu14.10" ]];then ver=ubuntu1410; fi;chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute otherpkgdir="http://developer.download.nvidia.com/compute/cuda/repos/$ver/__GETNODEATTR($$CN,arch)__ /" otherpkglist="/opt/xcat/share/xcat/netboot/ubuntu/cudaruntime.otherpkgs.pkglist" pkglist="/opt/xcat/share/xcat/netboot/ubuntu/cudaruntime.__GETNODEATTR($$CN,os)__.__GETNODEATTR($$CN,arch)__-.pkglist" rootimgdir="/install/netboot/ __GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/cudaruntime" -cmd:apt-get install -y acpid -check:rc==0 -cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/x86_64/compute -check:rc==0 -cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -check:rc==0 -cmd:packimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -check:rc==0 -cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -check:rc==0 -cmd:rpower $$CN reset -check:rc==0 -cmd:sleep 200 -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:xdsh $$CN dpkg -l |grep cuda -check:rc==0 -check:output=~cuda -end diff --git a/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_cudafull b/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_cudafull deleted file mode 100644 index 24f9b4827..000000000 --- a/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_cudafull +++ /dev/null @@ -1,35 +0,0 @@ -start:Ubuntu_full_installation_flat_cudafull -os:Linux -cmd:if [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu14.04" ]];then ver=ubuntu1404;elif [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu14.10" ]];then ver=ubuntu1410; fi;echo "deb http://developer.download.nvidia.com/compute/cuda/repos/$ver/__GETNODEATTR($$CN,arch)__ /" >> /etc/apt/sources.list -cmd:makedns -n -check:rc==0 -cmd:makeconservercf $$CN -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$CN -check:output=~$$CN -cmd:sleep 60 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:copycds $$ISO -check:rc==0 -cmd:if [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu14.04" ]];then ver=ubuntu1404;elif [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu14.10" ]];then ver=ubuntu1410; fi;chdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute -p pkgdir="http://ports.ubuntu.com/ubuntu-ports trusty main,http://ports.ubuntu.com/ubuntu-ports trusty-updates main,http://developer.download.nvidia.com/compute/cuda/repos/$ver/__GETNODEATTR($$CN,arch)__/ /" -cmd:chdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute pkglist="/opt/xcat/share/xcat/install/ubuntu/cudafull.__GETNODEATTR($$CN,os)__.__GETNODEATTR($$CN,arch)__.pkglist" -cmd:chdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute template="/opt/xcat/share/xcat/install/ubuntu/cudafull.tmpl" -cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute -check:rc==0 -cmd:rpower $$CN reset -check:rc==0 -cmd:sleep 2000 -cmd:ping $$CN -c 3 -check:output=~64 bytes from $$CN -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:xdsh $$CN dpkg -l |grep cuda -check:rc==0 -check:output=~cuda -end diff --git a/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_cudaruntime b/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_cudaruntime deleted file mode 100644 index 1695429e1..000000000 --- a/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_cudaruntime +++ /dev/null @@ -1,38 +0,0 @@ -start:Ubuntu_full_installation_flat_cudaruntime -os:Linux -cmd:if [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu14.04" ]];then ver=ubuntu1404;elif [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu14.10" ]];then ver=ubuntu1410; fi;echo "deb http://developer.download.nvidia.com/compute/cuda/repos/$ver/__GETNODEATTR($$CN,arch)__ /" >> /etc/apt/sources.list -cmd:makedns -n -check:rc==0 -cmd:makeconservercf $$CN -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$CN -check:output=~$$CN -cmd:sleep 60 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:copycds $$ISO -check:rc==0 -cmd:if [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu14.04" ]];then ver=ubuntu1404;elif [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu14.10" ]];then ver=ubuntu1410; fi;chdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute -p pkgdir="/install/__GETNODEATTR($$CN,os)__/ppc64el,http://ports.ubuntu.com/ubuntu-ports trusty main,http://ports.ubuntu.com/ubuntu-ports trusty-updates main, http://developer.download.nvidia.com/compute/cuda/repos/__GETNODEATTR($$CN,os)__/$ver /" -cmd:chdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute pkglist="/opt/xcat/share/xcat/install/ubuntu/cudaruntime.__GETNODEATTR($$CN,os)__.__GETNODEATTR($$CN,arch)__.pkglist" -cmd:chdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute template="/opt/xcat/share/xcat/install/ubuntu/cudaruntime.tmpl" -cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute -check:rc==0 -cmd:rpower $$CN reset -check:rc==0 -cmd:sleep 2000 -cmd:ping $$CN -c 3 -check:output=~64 bytes from $$CN -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:xdsh $$CN dpkg -l |grep cuda -check:rc==0 -check:output=~cuda -cmd:xdsh $$CN dpkg -l |grep cuda -check:rc==0 -check:output=~cuda -end diff --git a/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_confignics_s b/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_confignics_s deleted file mode 100644 index 8c208998d..000000000 --- a/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_confignics_s +++ /dev/null @@ -1,49 +0,0 @@ -start:Ubuntu_full_installation_flat_x86_vm_confignics -os:Linux -cmd:copycds $$ISO -check:rc==0 -cmd:chdef $$CN postscripts="confignics -s" -check:rc==0 -cmd:makedns -n -check:rc==0 -cmd:sleep 60 -cmd:makedhcp -n -check:rc==0 -cmd:makedhcp -a -check:rc==0 -cmd:makeconservercf $$CN -check:rc==0 -cmd:cat /etc/conserver.cf | grep $$CN -check:output=~$$CN -cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-compute -check:rc==0 -cmd:rpower $$CN boot -check:rc==0 -cmd:sleep 2000 -cmd:ping $$CN -c 3 -check:output=~64 bytes from $$CN -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:nodeset $$CN osimage -check:rc==0 -cmd:rpower $$CN reset -check:rc==0 -cmd:sleep 2000 -cmd:ping $$CN -c 3 -check:output=~64 bytes from $$CN -cmd:lsdef -l $$CN | grep status -check:output=~booted -cmd:xdsh $$CN date -check:rc==0 -check:output=~\d\d:\d\d:\d\d -cmd:port=`xdsh $$CN ip addr |grep $$INSTALLNICIP |cut -f 12 -d ' '`;if [ "$$OS" = "ubuntu" ];then xdsh $$CN cat /etc/network/interfaces.d/$port ; elif [ "$$OS" = "rhels" ]; then xdsh $$CN cat /etc/sysconfig/network-scripts/ifcfg-$port;else xdsh $$CN cat /etc/sysconfig/network/ifcfg-$port; fi -check:output=~$$INSTALLNICIP -check:output=~static -check:output!=\d\d:\d\d:\d\d -cmd:if [ "$$OS" = "ubuntu" ];then xdsh $$CN cat /etc/network/interfaces ; elif [ "$$OS" = "rhels" ]; then xdsh $$CN cat /etc/sysconfig/network;else xdsh $$CN cat /etc/sysconfig/network/routes; fi -check:rc==0 -check:output=~$$GATEWAY -end From fec8d6addcbed9ffd0acc1d3a9de37d8f883baf6 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Wed, 8 Jun 2016 10:09:22 -0400 Subject: [PATCH 083/310] more modification --- xCAT-server/lib/xcat/plugins/switchdiscover.pm | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/switchdiscover.pm b/xCAT-server/lib/xcat/plugins/switchdiscover.pm index 94c194168..38c7e3546 100644 --- a/xCAT-server/lib/xcat/plugins/switchdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/switchdiscover.pm @@ -832,6 +832,8 @@ sub snmp_scan { # Nmap scan report for switch-10-5-22-1 (10.5.22.1) 161/udp open snmp # Nmap scan report for 10.5.23.1 161/udp open snmp # Nmap scan report for 10.5.24.1 161/udp closed snmp + # Host 10.5.23.1 appears to be up ... good. 161/udp open|filtered snmp + # Host 10.5.24.1 appears to be up ... good. 161/udp closed snmp ########################################################## my $nmap_version = xCAT::Utils->get_nmapversion(); if (xCAT::Utils->version_cmp($nmap_version,"5.10") < 0) { @@ -878,14 +880,7 @@ sub snmp_scan { my $display = ""; my $nopping = "nopping"; my $output = xCAT::SvrUtils->get_mac_by_arp([$ip], $display, $nopping); - my $mac; - foreach my $node (keys %{$output}) { - if ($node eq $ip) { - my ($desc,$mac_arp) = split /: /, $output->{$node}; - $mac = $mac_arp; - last; - } - } + my ($desc,$mac) = split /: /, $output->{$ip}; if (exists($globalopt{verbose})) { send_msg($request, 0, "node: $ip, mac: $mac"); } From 6c4668840bc483fa8c5b17b425b5458aec1c8eaf Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Wed, 8 Jun 2016 16:05:51 -0400 Subject: [PATCH 084/310] Remove only xCAT entries from rsyslog.conf file --- xCAT/postscripts/syslog | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/xCAT/postscripts/syslog b/xCAT/postscripts/syslog index 183344238..b8f19ef2a 100755 --- a/xCAT/postscripts/syslog +++ b/xCAT/postscripts/syslog @@ -34,6 +34,8 @@ isSN=0 isLinux=1 isRsyslog=0 isC3=0 +xCATSettingsSTART="xCAT settings START" +xCATSettingsEND="xCAT settings END" #systemdEnabled=0 # pmatch determines if 1st argument string is matched by 2nd argument pattern @@ -87,13 +89,14 @@ config_Rsyslog_C3() cp -f $2 $2.XCATORIG fi - grep "xCAT settings" $conf_file 2>&1 1> /dev/null + grep "$xCATSettingsSTART" $conf_file 2>&1 1> /dev/null if [ $? -eq 0 ]; then #remove the previous syslog rule generated by xCAT - sed -i "/# xCAT settings/,$ d" $2 + sed -i "/$xCATSettingsSTART/,/$xCATSettingsEND/ d" $2 fi - echo "# xCAT settings" >> $2 + # Mark the start of xCAT section + echo "# $xCATSettingsSTART" >> $2 #enable to receive remote logging if [ $isReceiving -eq 1 ]; then #listen on the udp and tcp port to receive the remote logs @@ -119,6 +122,8 @@ config_Rsyslog_C3() s/^\(news\|local7\|mail\|authpriv\|cron\|kern\)\./\#\1\./' $2 echo "*.* @$master" >> $2 fi + # Mark the end of xCAT section + echo "# $xCATSettingsEND" >> $2 } # This sets up rsyslog 8.x, different from the previous rsyslog versions. @@ -157,15 +162,15 @@ config_rsyslog_V8() cp -f $conf_file $conf_file.XCATORIG fi - # check if already an entry by xCAT. If so, we need to replace it - grep "xCAT settings" $conf_file 2>&1 1> /dev/null + # check if already an entry by xCAT. If so, we need to remove it + grep "$xCATSettingsSTART" $conf_file 2>&1 1> /dev/null if [ $? -eq 0 ]; then - sed -i "/# xCAT settings/,$ d" $conf_file + sed -i "/$xCATSettingsSTART/,/$xCATSettingsEND/ d" $conf_file fi - grep "xCAT settings" $remoteconf 2>&1 1> /dev/null + grep "$xCATSettingsSTART" $remoteconf 2>&1 1> /dev/null if [ $? -eq 0 ]; then - sed -i "/# xCAT settings/,$ d" $remoteconf + sed -i "/$xCATSettingsSTART/,/$xCATSettingsEND/ d" $remoteconf fi if [ $goLocal -eq 1 ]; then @@ -182,7 +187,8 @@ config_rsyslog_V8() # to prevent duplicate logs after "syslog" script is run sed -i '/^[^#].*\/var\/log\/messages/s/^/#/' $conf_file - echo "# xCAT settings" >> $conf_file + # Mark the start of xCAT section + echo "# $xCATSettingsSTART" >> $conf_file echo "#*.debug /var/log/messages" >> $conf_file # Need to uncomment the lines $ModLoad imudp.so and $UDPServerRun 514, # to make the MN be able to receive syslog from remote hosts @@ -205,6 +211,8 @@ config_rsyslog_V8() s/#input(type="imtcp" port="514")/input(type="imtcp" port="514")/' $conf_file fi + # Mark the end of xCAT section + echo "# $xCATSettingsEND" >> $conf_file else # not logging local, forward logging # backup the existing remote.conf file from the install @@ -223,8 +231,9 @@ config_rsyslog_V8() # add xCAT entries - echo "# xCAT settings" >> $remoteconf + echo "# $xCATSettingsSTART" >> $remoteconf echo "*.* @$master" >> $remoteconf + echo "# $xCATSettingsEND" >> $remoteconf fi # restart syslog ( could be service or systemctl call depending on the OS) restartservice syslog From 8d0bc5dee81c5c9c2b3a209ba02f900c6f6cba39 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Thu, 9 Jun 2016 13:11:29 -0400 Subject: [PATCH 085/310] Give user info about replacement of entries --- xCAT/postscripts/syslog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xCAT/postscripts/syslog b/xCAT/postscripts/syslog index b8f19ef2a..d9ee73d0b 100755 --- a/xCAT/postscripts/syslog +++ b/xCAT/postscripts/syslog @@ -36,6 +36,7 @@ isRsyslog=0 isC3=0 xCATSettingsSTART="xCAT settings START" xCATSettingsEND="xCAT settings END" +xCATSettingsInfo="Entries between the START and END lines will be replaced on the next xCAT install or update" #systemdEnabled=0 # pmatch determines if 1st argument string is matched by 2nd argument pattern @@ -97,6 +98,7 @@ config_Rsyslog_C3() # Mark the start of xCAT section echo "# $xCATSettingsSTART" >> $2 + echo "# $xCATSettingsInfo" >> $2 #enable to receive remote logging if [ $isReceiving -eq 1 ]; then #listen on the udp and tcp port to receive the remote logs @@ -189,6 +191,7 @@ config_rsyslog_V8() # Mark the start of xCAT section echo "# $xCATSettingsSTART" >> $conf_file + echo "# $xCATSettingsInfo" >> $conf_file echo "#*.debug /var/log/messages" >> $conf_file # Need to uncomment the lines $ModLoad imudp.so and $UDPServerRun 514, # to make the MN be able to receive syslog from remote hosts @@ -232,6 +235,7 @@ config_rsyslog_V8() # add xCAT entries echo "# $xCATSettingsSTART" >> $remoteconf + echo "# $xCATSettingsInfo" >> $remoteconf echo "*.* @$master" >> $remoteconf echo "# $xCATSettingsEND" >> $remoteconf fi From f265429548adf0b2316c606f79c4e4669cce1b00 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Thu, 9 Jun 2016 13:48:45 -0400 Subject: [PATCH 086/310] Replace some die calls with exit and add undef for global --- xCAT-server/lib/xcat/plugins/kvm.pm | 36 ++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index bc8e305fb..6bd27bb04 100755 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -235,6 +235,7 @@ sub get_storage_pool_by_url { if ($@) { my $error = $@; unless ($error =~ /vgcreate.*exit status 3/ or $error =~ /pvcreate.*exit status 5/) { + undef $hypconn; die $@; } } @@ -250,7 +251,11 @@ sub get_multiple_paths_by_url { my $url = $args{url}; my $node = $args{node}; my $poolobj = get_storage_pool_by_url($url); - unless ($poolobj) { die "Cound not get storage pool for $url"; } + unless ($poolobj) { + my $exit_message = "Could not get storage pool for $url"; + xCAT::SvrUtils::sendmsg($exit_message, $callback); + exit 1; + } eval { #refresh() can 'die' if cloning in progress, accept stale data then $poolobj->refresh(); #if volumes change on nfs storage, libvirt is too dumb to notice }; @@ -295,7 +300,11 @@ sub get_filepath_by_url { #at the end of the day, the libvirt storage api gives #print "url=$url, dev=$dev,create=$create, force=$force, format=$format\n"; #ok, now that we have the pool, we need the storage volume from the pool for the node/dev my $poolobj = get_storage_pool_by_url($url); - unless ($poolobj) { die "Could not get storage pool for $url"; } + unless ($poolobj) { + my $exit_message = "Could not get storage pool for $url"; + xCAT::SvrUtils::sendmsg($exit_message, $callback); + exit 1; + } eval { #make a refresh attempt non-fatal to fail, since cloning can block it $poolobj->refresh(); #if volumes change on nfs storage, libvirt is too dumb to notice }; @@ -309,7 +318,9 @@ sub get_filepath_by_url { #at the end of the day, the libvirt storage api gives if ($force) { #must destroy the storage $_->delete(); } else { - die "Path already exists"; + my $exit_message = "Path $desiredname already exists"; + xCAT::SvrUtils::sendmsg($exit_message, $callback); + exit 1; } } else { return $_->get_path(); @@ -533,7 +544,9 @@ sub build_diskstruct { } elsif ($disk_parts[0] =~ m/^nfs:\/\/(.*)$/ or $disk_parts[0] =~ m/^dir:\/\/(.*)$/ or $disk_parts[0] =~ m/^lvm:\/\/(.*)$/) { my %disks = %{ get_multiple_paths_by_url(url => $disk_parts[0], node => $node) }; unless (keys %disks) { - die "Unable to find any persistent disks at " . $disk_parts[0]; + my $exit_message = "Unable to find any persistent disks at $disk_parts[0] for $node"; + xCAT::SvrUtils::sendmsg($exit_message, $callback); + exit 1; } foreach (keys %disks) { my $tdiskhash; @@ -2026,21 +2039,30 @@ sub chvm { $url =~ s!([^/]+)\z!!; my $imagename = $1; my $poolobj = get_storage_pool_by_url($url); - unless ($poolobj) { die "Cound not get storage pool for $url"; } + unless ($poolobj) { + my $exit_message = "Could not get storage pool for $url"; + xCAT::SvrUtils::sendmsg($exit_message, $callback); + exit 1; + } my $poolxml = $poolobj->get_xml_description(); #yes, I have to XML parse for even this... my $parsedpool = $parser->parse_string($poolxml); $cdpath = $parsedpool->findnodes("/pool/target/path/text()")->[0]->data; $cdpath .= "/" . $imagename; } else { if ($cdrom =~ m!^/dev/!) { + undef $hypconn; die "TODO: device pass through if anyone cares"; } elsif ($cdrom =~ m!^/!) { #full path... I guess $cdpath = $cdrom; } else { + undef $hypconn; die "TODO: relative paths, use client cwd as hint?"; } } - unless ($cdpath) { die "unable to understand cd path specification"; } + unless ($cdpath) { + undef $hypconn; + die "unable to understand cd path specification"; + } $newcdxml = ""; } elsif ($eject) { $newcdxml = ""; @@ -2056,6 +2078,7 @@ sub chvm { my $domparsed = $parser->parse_string($vmxml); my $candidatenodes = $domparsed->findnodes("//disk[\@device='cdrom']"); if (scalar(@$candidatenodes) != 1) { + undef $hypconn; die "shouldn't be possible, should only have one cdrom"; } my $newcd = $parser->parse_balanced_chunk($newcdxml); @@ -2772,6 +2795,7 @@ sub clone_vm_from_master { my $url; if ($confdata->{vm}->{$node}->[0]->{storage}) { unless ($confdata->{vm}->{$node}->[0]->{storage} =~ /^nfs:/) { + undef $hypconn; die "not implemented"; } $url = $confdata->{vm}->{$node}->[0]->{storage}; From e0848cf56d6ed20eea4a86bbe74f7e3a7d44c8f9 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Fri, 10 Jun 2016 09:40:24 -0400 Subject: [PATCH 087/310] Doc updates for rmigrate command --- .../ppc64le/virtual_machines/FAQ.rst | 25 +++++++++++++++++++ .../references/man1/rmigrate.1.rst | 20 ++++++++++++--- xCAT-client/pods/man1/rmigrate.1.pod | 10 +++++--- 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/docs/source/guides/admin-guides/manage_clusters/ppc64le/virtual_machines/FAQ.rst b/docs/source/guides/admin-guides/manage_clusters/ppc64le/virtual_machines/FAQ.rst index f11b0a282..32686df62 100644 --- a/docs/source/guides/admin-guides/manage_clusters/ppc64le/virtual_machines/FAQ.rst +++ b/docs/source/guides/admin-guides/manage_clusters/ppc64le/virtual_machines/FAQ.rst @@ -45,6 +45,31 @@ rpower fails with "Error: internal error: process exited while connecting to mon Then reboot the hypervisor... +rmigrate fails with "Error: libvirt error code: 38, message: unable to connect to server at 'c910f05c35:49152': No route to host." +---------------------------------------------------------------------------------------------------------------------------------- + + **Issue**: :: + + #rmigrate vm1 kvmhost2 + vm1: Error: libvirt error code: 38, message: unable to connect to server at 'kvmhost2:49152': No route to host: Failed migration of vm1 from kvmhost1 to kvmhost2 + + **Solution**: + Usually caused by active firewall. To disable the firewall issue: :: + + systemctl disable firewalld + +rmigrate fails with "Error: 38, message: failed to create directory '': File exists: Unknown issue libvirt error code." +--------------------------------------------------------------------------------------------------------------------------------- + + **Issue**: :: + + #rmigrate vm1 kvmhost2 + vm1: Error: 38, message: failed to create directory '': File exists: Unknown issue libvirt error code. + + **Solution**: + Ususally happens when `nfs:` is specified for vmstorage attribute but that NFS directory is no longer mounted. Make sure the directory /var/lib/xcat/pools is empty on the destination kvmhost. + + Error: Cannot communicate via libvirt to kvmhost1 ------------------------------------------------- diff --git a/docs/source/guides/admin-guides/references/man1/rmigrate.1.rst b/docs/source/guides/admin-guides/references/man1/rmigrate.1.rst index f119cf28d..d6b67dfcb 100644 --- a/docs/source/guides/admin-guides/references/man1/rmigrate.1.rst +++ b/docs/source/guides/admin-guides/references/man1/rmigrate.1.rst @@ -36,6 +36,8 @@ For zVM: \ **rmigrate**\ requests that a guest VM to be moved from the current hypervisor to another. It will request a live migration if possible. The vmstorage directory should be shared between the source and destination hypervisors. +Note: Make sure SELINUX is disabled and firewall is turned off on source and destination hypervisors. + For zVM: ======== @@ -97,17 +99,29 @@ This is used to determine the current host to migrate from. 1. To migrate kvm guest "kvm1" from hypervisor "hyp01" to hypervisor "hyp02", run: -\ **rmigrate**\ \ *kvm1*\ \ *hyp02*\ + +.. code-block:: perl + + rmigrate kvm1 hyp02 + 2. To migrate kvm guest "kvm1" to hypervisor "hyp02", which is already on host "hyp02", enter: -\ **rmigrate**\ \ *kvm1*\ \ *hyp02*\ + +.. code-block:: perl + + rmigrate kvm1 hyp02 + zVM specific: ============= -\ **rmigrate**\ \ *ihost123*\ destination=\ *pokdev62*\ + +.. code-block:: perl + + rmigrate ihost123 destination=pokdev62 + diff --git a/xCAT-client/pods/man1/rmigrate.1.pod b/xCAT-client/pods/man1/rmigrate.1.pod index 083d2f9e9..fea02a867 100644 --- a/xCAT-client/pods/man1/rmigrate.1.pod +++ b/xCAT-client/pods/man1/rmigrate.1.pod @@ -12,7 +12,9 @@ B I [BI] [BI] [ =head1 B -B requests that a guest VM to be moved from the current hypervisor to another. It will request a live migration if possible. The vmstorage directory should be shared between the source and destination hypervisors. +B requests that a guest VM to be moved from the current hypervisor to another. It will request a live migration if possible. The vmstorage directory should be shared between the source and destination hypervisors. + +Note: Make sure SELINUX is disabled and firewall is turned off on source and destination hypervisors. =head2 For zVM: @@ -54,16 +56,16 @@ This is used to determine the current host to migrate from. 1. To migrate kvm guest "kvm1" from hypervisor "hyp01" to hypervisor "hyp02", run: -B I I + rmigrate kvm1 hyp02 2. To migrate kvm guest "kvm1" to hypervisor "hyp02", which is already on host "hyp02", enter: -B I I + rmigrate kvm1 hyp02 =head2 zVM specific: =over 4 -B I destination=I + rmigrate ihost123 destination=pokdev62 =back From d1c1aad5c572ccf5430dd710aba60ac2872a1c5f Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Tue, 7 Jun 2016 16:55:12 -0400 Subject: [PATCH 088/310] Add comments into bmcsetup to better understand the actions of the ipmitool raw commands --- xCAT-genesis-scripts/bin/bmcsetup | 61 +++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 15 deletions(-) diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index 2998b1c28..1194828ce 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -44,11 +44,15 @@ while [ -z "$BMCIP" -a $IPCFGMETHOD="static" ]; do done kill $CREDPID NUMBMCS=`grep bmcip /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'|wc -l` +# +# Get the BMC Version and Manufacturer ID +# IPMIVER=`ipmitool mc info|grep ^IPMI|awk '{print $4}'` IPMIMFG=`ipmitool mc info|grep "^Manufacturer ID"|awk '{print $4}'` logger -t $log_label -p local4.info "NUMBMCS is $NUMBMCS, IPMIVER is $IPMIVER, IPMIMFG is $IPMIMFG" if [ "$IPMIMFG" == 2 ]; then #IBM + # Get the BMC Product ID XPROD=`ipmitool mc info|grep "^Product ID"|awk '{print $4}'` logger -t $log_label -p local4.info "XPROD is $XPROD" if [ "$XPROD" == "220" ]; then @@ -59,12 +63,15 @@ if [ "$IPMIMFG" == 2 ]; then #IBM let idev=0 IFS=',' for p in $BMCPORT; do + # Set the LAN Configuration Parameters (OEM) ipmitool -d $idev raw 0xc 1 1 0xc0 $p > /dev/null + # Set the PEF Configuration Parameters (Platform Event Filtering) ipmitool -d $idev raw 0x04 0x12 0x09 0x01 0x18 0x${p}1 0x00 > /dev/null CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` logger -t $log_label -p local4.info "CURBMCPORT is $CURBMCPORT" while [ "$CURBMCPORT" -ne "$BMCPORT" ]; do sleep 1 + # Get the LAN Configuration Parameters (OEM) CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` done let idev=idev+1 @@ -74,6 +81,7 @@ if [ "$IPMIMFG" == 2 ]; then #IBM elif [ "$XPROD" == "291" ]; then LOCKEDUSERS=1 else + # Get a ID for the server IBMFAM=`ipmitool raw 0x3a 0x50 |head -n 1| awk '{print $1 $2 $3 $4}'` logger -t $log_label -p local4.info "IBMFAM is $IBMFAM" if [ "$IBMFAM" == "59554f4f" ]; then @@ -134,7 +142,8 @@ fi logger -s -t $log_label -p local4.info "Auto detecting LAN channel..." while [ -z "$LANCHAN" ]; do - for TLANCHAN in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do + for TLANCHAN in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do + # Try to get the channel information; then get the MAC which is used for the channel if ipmitool channel info $TLANCHAN 2> /dev/null | grep 802.3 > /dev/null 2>&1 && ipmitool raw 0xc 2 $TLANCHAN 5 0 0 > /dev/null 2>&1; then LANCHAN=$TLANCHAN @@ -154,6 +163,7 @@ if [ $IPCFGMETHOD="static" ]; then while [ $idev -gt 0 ]; do let idev=idev-1 TRIES=0 + # Set the channel to use STATIC IP address while ! ipmitool -d $idev lan set $LANCHAN ipsrc static; do sleep 1 let TRIES=TRIES+1 @@ -165,6 +175,7 @@ if [ $IPCFGMETHOD="static" ]; then let idev=0 for b in $BMCIP; do TRIES=0 + # Set the IP for the current channel while ! ipmitool -d $idev lan set $LANCHAN ipaddr $b; do sleep 1 let TRIES=TRIES+1 @@ -177,6 +188,7 @@ if [ $IPCFGMETHOD="static" ]; then let idev=0 for m in $BMCNM; do TRIES=0 + # Set the NETMASK for the current channel while ! ipmitool -d $idev lan set $LANCHAN netmask $m; do sleep 1 let TRIES=TRIES+1 @@ -191,6 +203,7 @@ if [ $IPCFGMETHOD="static" ]; then let idev=0 for g in $BMCGW; do TRIES=0 + # Set the GATEWAY for the current channel while ! ipmitool -d $idev lan set $LANCHAN defgw ipaddr $g; do sleep 1 let TRIES=TRIES+1 @@ -207,6 +220,7 @@ else while [ $idev -gt 0 ]; do let idev=idev-1 TRIES=0 + # Set the method to get IP for the current channel, if required. while ! ipmitool -d $idev lan set $LANCHAN ipsrc $IPCFGMETHOD; do sleep 1 let TRIES=TRIES+1 @@ -220,6 +234,7 @@ fi let idev=0 for b in $BMCVLAN; do TRIES=0 + # Set VLAN for the current channel while ! ipmitool -d $idev lan set $LANCHAN vlan id $b; do sleep 1 let TRIES=TRIES+1 @@ -235,6 +250,7 @@ for bmcu in $BMCUS; do if [ "$bmcu" = "" ]; then continue; fi DISABLEUSERS="1 2 3 4" if [ ! -z "$LOCKEDUSERS" ]; then + # Get the User Slots USERSLOT=`ipmitool -d $idev user list $LANCHAN |grep -v ^ID|awk '{print $1 " " $2}'|grep -w "$BMCUS"|awk '{print $1}'` if [ -z "$USERSLOT" ]; then USERSLOT=4 @@ -251,10 +267,13 @@ if [ "$ISITE" = 1 ]; then done kill $CREDPID fi + +# Get the specified user CURRENTUSER=`ipmitool -d $idev user list $LANCHAN|grep ^$USERSLOT|awk '{print $2}'` DISABLEUSERS=`echo 1 2 3 4|sed -e s/$USERSLOT//` logger -t $log_label -p local4.info "CURRENTUSER is $CURRENTUSER, DISABLEUSERS is $DISABLEUSERS" for user in $DISABLEUSERS; do + # Disable the non-specified user while ! ipmitool -d $idev user disable $user; do sleep 1 let TRIES=TRIES+1 @@ -263,6 +282,7 @@ for user in $DISABLEUSERS; do TRIES=0 done TRIES=0 +# Enable the specified user while ! ipmitool -d $idev user enable $USERSLOT; do sleep 1 let TRIES=TRIES+1 @@ -271,9 +291,13 @@ done TRIES=0 # Last param in ipmitool user priv is the channel to set it on. # Penguin boxes are all channel 2 +# +# Get privilege for the specified user +# CURRPRIV=`ipmitool -d $idev user list $LANCHAN|grep ^$USERSLOT|awk '{print $6}'` logger -t $log_label -p local4.info "CURRPRIV is $CURRPRIV" if [ "$CURRPRIV" != "ADMINISTRATOR" ]; then + # Set the ADMIN privilege for the specified user while ! ipmitool -d $idev user priv $USERSLOT 4 $LANCHAN; do sleep 1 let TRIES=TRIES+1 @@ -282,6 +306,7 @@ if [ "$CURRPRIV" != "ADMINISTRATOR" ]; then TRIES=0 fi TRIES=0 +# Enable the channel link for the specified user while ! ipmitool -d $idev channel setaccess $LANCHAN $USERSLOT link=on; do sleep 1 let TRIES=TRIES+1 @@ -289,6 +314,7 @@ while ! ipmitool -d $idev channel setaccess $LANCHAN $USERSLOT link=on; do done TRIES=0 if [ "$CURRENTUSER" != "$bmcu" ]; then + # Change the user name, if necessary while ! ipmitool -d $idev user set name $USERSLOT $bmcu; do sleep 1 let TRIES=TRIES+1 @@ -301,6 +327,7 @@ let idev=NUMBMCS-1 for bmcp in $BMCPW; do if [ "$bmcp" = "" ]; then continue; fi TRIES=0 +# Set the password for the specified user while ! ipmitool -d $idev user set password $USERSLOT $bmcp; do sleep 1 let TRIES=TRIES+1 @@ -308,6 +335,7 @@ while ! ipmitool -d $idev user set password $USERSLOT $bmcp; do done TRIES=0 logger -s -t $log_label -p local4.info "Set up following user table: " +# Display the user list ipmitool -d $idev user list $LANCHAN let idev=idev-1 done @@ -317,12 +345,14 @@ while [ $idev -gt 0 ]; do let idev=idev-1 logger -s -t $log_label -p local4.info "Enabling Channel $LANCHAN: " +# Set the non-volatile channel access: enable and privilege while ! ipmitool -d $idev raw 0x6 0x40 $LANCHAN 0x42 0x44 > /dev/null; do sleep 1 let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; fi done TRIES=0 +# Set the volatile channel access: enable and privilege while ! ipmitool -d $idev raw 0x6 0x40 $LANCHAN 0x82 0x84 > /dev/null; do sleep 1 let TRIES=TRIES+1 @@ -332,6 +362,7 @@ if [ $TRIES -gt $TIMEOUT ]; then logger -s -t $log_label -p local4.err "ERROR"; TRIES=0 logger -s -t $log_label -p local4.info "Enabling ARP responses: " +# enable the ARP response on the channel while ! ipmitool -d $idev lan set $LANCHAN arp respond on > /dev/null; do sleep 1 let TRIES=TRIES+1 @@ -342,6 +373,7 @@ if [ $TRIES -gt $TIMEOUT ]; then logger -s -t $log_label -p local4.err "ERROR"; TRIES=0 logger -s -t $log_label -p local4.info "Enabling IPMI v 1.5 MD5 LAN access:" +# Set the auth level to md5 for the channel while ! ipmitool -d $idev lan set $LANCHAN auth admin md5 > /dev/null; do sleep 1 let TRIES=TRIES+1 @@ -357,6 +389,9 @@ if [ ! "$IPMIVER" == "1.5" ]; then #enable cipher suite 2 (scenarios without perl Rijndael) #enable cipher suite 3 #ignore the rest + # + # Read the LAN info + # ZEROIDX=$(ipmitool lan print $LANCHAN|grep ^RMCP+|cut -d: -f 2|sed -e 's/ //' -e 's/,/\n/g'|grep -n '%0$'|sed -e 's/:.*//') ONEIDX=$(ipmitool lan print $LANCHAN|grep ^RMCP+|cut -d: -f 2|sed -e 's/ //' -e 's/,/\n/g'|grep -n '^1$'|sed -e 's/:.*//') TWOIDX=$(ipmitool lan print $LANCHAN|grep ^RMCP+|cut -d: -f 2|sed -e 's/ //' -e 's/,/\n/g'|grep -n '^2$'|sed -e 's/:.*//') @@ -376,6 +411,7 @@ if [ ! "$IPMIVER" == "1.5" ]; then fi i=$((i+1)) done + # Set the cipher_privileges for the channel if ipmitool lan set $LANCHAN cipher_privs $NEWACCESS > /dev/null; then logger -s -t $log_label -p local4.info "OK" else @@ -384,6 +420,7 @@ if [ ! "$IPMIVER" == "1.5" ]; then TRIES=0 logger -s -t $log_label -p local4.info "Enabling SOL for channel $LANCHAN:" + # Enable the SOL for the channel while ! ipmitool -d $idev raw 0xc 0x21 $LANCHAN 0x1 0x1 > /dev/null; do sleep 1 let TRIES=TRIES+1 @@ -393,25 +430,18 @@ if [ ! "$IPMIVER" == "1.5" ]; then TRIES=0 logger -s -t $log_label -p local4.info "Enabling SOL for $BMCUS:" + # Enable the SOL for the USER and set the payload 1 while ! ipmitool -d $idev raw 6 0x4c $LANCHAN $USERSLOT 2 0 0 0 > /dev/null; do sleep 1 let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; fi done - if [ $TRIES -gt $TIMEOUT ]; then logger -s -t $log_label -p local4.err "ERROR"; else logger -s -t $log_label -p local4.info "OK"; fi - - # 0xc 0x21 with data 7 is used to set payload channel, it is readonly in the ipmiv2.0 doc, so comment this section out. - #echo -n "Putting SOL on channel $LANCHAN:" - #while ! OUTPUT=`ipmitool -d $idev raw 0xc 0x21 $LANCHAN 7 $LANCHAN 2>&1 > /dev/null`; do - # if echo $OUTPUT|grep "Unknown (0x80)" > /dev/null; then - # echo "Not Needed" - # break - # fi - # sleep 1 - # let TRIES=TRIES+1 - # if [ $TRIES -gt $TIMEOUT ]; then break; fi - #done - #if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi + + if [ $TRIES -gt $TIMEOUT ]; then + logger -s -t $log_label -p local4.err "ERROR Tried $TIMEOUT times, could not enable SOL for $BMCUS" + else + logger -s -t $log_label -p local4.info "Enabling SOL for $BMCUS: OK" + fi fi # @@ -454,6 +484,7 @@ fi logger -s -t $log_label -p local4.info "Lighting Identify Light" while : + # Identify the server by turning on the LED light do ipmitool -d $idev raw 0 4 10 > /dev/null sleep 7 done & From 0f2b4be4c966793be0079d1fe423c373c4f42efc Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Tue, 7 Jun 2016 16:58:12 -0400 Subject: [PATCH 089/310] Add workaround code specific to OpenPower BMC where the BMC requires more time to boot into a "ready" state after doing a cold reset --- xCAT-genesis-scripts/bin/bmcsetup | 91 ++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 31 deletions(-) diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index 1194828ce..7ef181c4e 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -14,6 +14,58 @@ # log_label="xcat.genesis.bmcsetup" +# Cold reset the BMC for certain servers +# Product ID: 309 - x3755 M4 (8722) +# Product ID: 43707 - IBM Power S822LC and S812LC +# +# Otherwise the BMC will not respond to ping after running the ipmitool commands in this script +# +function cold_reset_bmc() { + PROD=$1 + if [ "$PROD" = "309" -o "$PROD" = "43707" ] ; then + if [ "$PROD" = "43707" ]; then + # OpenPower SPECIFIC, the OpenPower machines with AMI BMC should NOT need a + # reset after applying ipmitool commands. However, it seems there is a problem with + # the BMC where after 15 seconds, it stops responding. To work around, sleep 30 + # seconds before issuing the reset of the BMC. + sleep 30 + fi + logger -s -t $log_label -p local4.info "Resetting BMC ..." + echo "Resetting BMC ..." + ipmitool mc reset cold + + logger -s -t $log_label -p local4.info "Waiting for the BMC to appear ..." + if [ "$PROD" = "43707" ]; then + # OpenPower SPECIFIC, check the BMC with the following raw command to + # make sure that the bmc is really in a "ready" state before continuing + SLEEP_INTERVAL=3 + MAX_ITERATION=100 + tries=0 + while [ $tries -lt ${MAX_ITERATION} ] ; do + sleep ${SLEEP_INTERVAL} + ret=`ipmitool raw 0x3a 0x0a 2> /dev/null` + if [ "$ret" == " 00" ]; then + return + fi + tries=$(($tries+1)) + done + TOTAL_SEC=$((${SLEEP_INTERVAL} * ${MAX_ITERATION})) + echo "ERROR, After waiting ${TOTAL_SEC} seconds, the BMC is not in a ready state." + else + # for Non OpenPower servers, just sleep for some set time. + sleep 15 + fi + + TRIES=0 + # Get the LAN information + while ! ipmitool lan print $LANCHAN > /dev/null; do + sleep 3 + let TRIES=TRIES+1 + if [ $TRIES -gt $TIMEOUT ]; then break; fi + done + fi +} + allowcred.awk & CREDPID=$! sleep 5 @@ -44,17 +96,19 @@ while [ -z "$BMCIP" -a $IPCFGMETHOD="static" ]; do done kill $CREDPID NUMBMCS=`grep bmcip /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'|wc -l` +logger -t $log_label -p local4.info "NUMBMCS=$NUMBMCS" # # Get the BMC Version and Manufacturer ID # IPMIVER=`ipmitool mc info|grep ^IPMI|awk '{print $4}'` IPMIMFG=`ipmitool mc info|grep "^Manufacturer ID"|awk '{print $4}'` -logger -t $log_label -p local4.info "NUMBMCS is $NUMBMCS, IPMIVER is $IPMIVER, IPMIMFG is $IPMIMFG" +logger -t $log_label -p local4.info "IPMIVER=$IPMIVER" +logger -t $log_label -p local4.info "IPMIMFG=$IPMIMFG" +# Get the BMC Product ID +XPROD=`ipmitool mc info|grep "^Product ID"|awk '{print $4}'` +logger -t $log_label -p local4.info "XPROD=$XPROD" if [ "$IPMIMFG" == 2 ]; then #IBM - # Get the BMC Product ID - XPROD=`ipmitool mc info|grep "^Product ID"|awk '{print $4}'` - logger -t $log_label -p local4.info "XPROD is $XPROD" if [ "$XPROD" == "220" ]; then LOCKEDUSERS=1 BMCPORT=`grep bmcport /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'` @@ -104,7 +158,6 @@ if [ "$IPMIMFG" == 2 ]; then #IBM fi fi elif [ "$IPMIMFG" == 20301 -o "$IPMIMFG" == 19046 ] ; then - XPROD=`ipmitool mc info|grep "^Product ID"|awk '{print $4}'` IBMVPDV=`ipmitool raw 0x3a 0xb 2 0 16 1` logger -t $log_label -p local4.info "XPROD is $XPROD, IBMVPDV is $IBMVPDV" if [ $IBMVPDV -eq 2 ]; then @@ -444,32 +497,8 @@ if [ ! "$IPMIVER" == "1.5" ]; then fi fi -# -# Cold Reset the BMC for: -# Product ID: 309 - x3755 M4 (8722) -# Product ID: 43707 - IBM Power S822LC and S812LC -# Otherwise the BMC will not respond to ping after running bmcsetup -# -XPROD=`ipmitool mc info|grep "^Product ID"|awk '{print $4}'` -if [ "$XPROD" = "309" -o "$XPROD" = "43707" ] ; then - if [ "$XPROD" = "43707" ]; then - # The IBM Power S822LC and S812LC should NOT need a reset to apply changes - # to the BMC. However, it seems there's a problem with the BMC where after - # 15 seconds, it stops responding. To work around until the firmware is fixed, - # have a sleep here for 30 seconds, then issue the reset of the BMC - sleep 30 - fi - logger -s -t $log_label -p local4.info "Resetting BMC ..." - ipmitool mc reset cold - logger -s -t $log_label -p local4.info "Waiting for the BMC to appear ..." - sleep 15 - TRIES=0 - while ! ipmitool lan print $LANCHAN > /dev/null; do - sleep 3 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done -fi +# Cold reset the BMC +cold_reset_bmc ${XPROD} # update the node status to 'bmcready' for parm in `cat /proc/cmdline`; do From fb931548068b58aa61030619e67f5a30f38a192e Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Tue, 7 Jun 2016 17:21:20 -0400 Subject: [PATCH 090/310] Fix the formatting of this file, the indentations were incorrect --- xCAT-genesis-scripts/bin/bmcsetup | 385 ++++++++++++++++-------------- 1 file changed, 202 insertions(+), 183 deletions(-) diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index 7ef181c4e..c1651f364 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -300,222 +300,241 @@ done let idev=NUMBMCS-1 for bmcu in $BMCUS; do - if [ "$bmcu" = "" ]; then continue; fi -DISABLEUSERS="1 2 3 4" -if [ ! -z "$LOCKEDUSERS" ]; then - # Get the User Slots - USERSLOT=`ipmitool -d $idev user list $LANCHAN |grep -v ^ID|awk '{print $1 " " $2}'|grep -w "$BMCUS"|awk '{print $1}'` - if [ -z "$USERSLOT" ]; then - USERSLOT=4 + if [ "$bmcu" = "" ]; then + continue + fi + DISABLEUSERS="1 2 3 4" + if [ ! -z "$LOCKEDUSERS" ]; then + # Get the User Slots + USERSLOT=`ipmitool -d $idev user list $LANCHAN |grep -v ^ID|awk '{print $1 " " $2}'|grep -w "$BMCUS"|awk '{print $1}'` + if [ -z "$USERSLOT" ]; then + USERSLOT=4 + fi + else + USERSLOT=2 + fi + if [ "$ISITE" = 1 ]; then + allowcred.awk & + CREDPID=$! + while ! remoteimmsetup + do + logger -s -t $log_label -p local4.info "Waiting for xCAT remote configuration of service processor via CMM.." + done + kill $CREDPID fi -else - USERSLOT=2 -fi -if [ "$ISITE" = 1 ]; then - allowcred.awk & - CREDPID=$! - while ! remoteimmsetup - do - logger -s -t $log_label -p local4.info "Waiting for xCAT remote configuration of service processor via CMM.." - done - kill $CREDPID -fi -# Get the specified user -CURRENTUSER=`ipmitool -d $idev user list $LANCHAN|grep ^$USERSLOT|awk '{print $2}'` -DISABLEUSERS=`echo 1 2 3 4|sed -e s/$USERSLOT//` -logger -t $log_label -p local4.info "CURRENTUSER is $CURRENTUSER, DISABLEUSERS is $DISABLEUSERS" -for user in $DISABLEUSERS; do - # Disable the non-specified user - while ! ipmitool -d $idev user disable $user; do + # Get the specified user + CURRENTUSER=`ipmitool -d $idev user list $LANCHAN|grep ^$USERSLOT|awk '{print $2}'` + DISABLEUSERS=`echo 1 2 3 4|sed -e s/$USERSLOT//` + logger -t $log_label -p local4.info "CURRENTUSER=$CURRENTUSER, DISABLEUSERS=$DISABLEUSERS" + for user in $DISABLEUSERS; do + # Disable the non-specified user + while ! ipmitool -d $idev user disable $user; do + sleep 1 + let TRIES=TRIES+1 + if [ $TRIES -gt $TIMEOUT ]; then break; fi + done + TRIES=0 + done + TRIES=0 + # Enable the specified user + while ! ipmitool -d $idev user enable $USERSLOT; do sleep 1 let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; fi done TRIES=0 -done -TRIES=0 -# Enable the specified user -while ! ipmitool -d $idev user enable $USERSLOT; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi -done -TRIES=0 -# Last param in ipmitool user priv is the channel to set it on. -# Penguin boxes are all channel 2 -# -# Get privilege for the specified user -# -CURRPRIV=`ipmitool -d $idev user list $LANCHAN|grep ^$USERSLOT|awk '{print $6}'` -logger -t $log_label -p local4.info "CURRPRIV is $CURRPRIV" -if [ "$CURRPRIV" != "ADMINISTRATOR" ]; then - # Set the ADMIN privilege for the specified user - while ! ipmitool -d $idev user priv $USERSLOT 4 $LANCHAN; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done + # Last param in ipmitool user priv is the channel to set it on. + # Penguin boxes are all channel 2 + # + # Get privilege for the specified user + # + CURRPRIV=`ipmitool -d $idev user list $LANCHAN|grep ^$USERSLOT|awk '{print $6}'` + logger -t $log_label -p local4.info "CURRPRIV=$CURRPRIV" + if [ "$CURRPRIV" != "ADMINISTRATOR" ]; then + # Set the ADMIN privilege for the specified user + while ! ipmitool -d $idev user priv $USERSLOT 4 $LANCHAN; do + sleep 1 + let TRIES=TRIES+1 + if [ $TRIES -gt $TIMEOUT ]; then break; fi + done + fi TRIES=0 -fi -TRIES=0 -# Enable the channel link for the specified user -while ! ipmitool -d $idev channel setaccess $LANCHAN $USERSLOT link=on; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi -done -TRIES=0 -if [ "$CURRENTUSER" != "$bmcu" ]; then - # Change the user name, if necessary - while ! ipmitool -d $idev user set name $USERSLOT $bmcu; do + # Enable the channel link for the specified user + while ! ipmitool -d $idev channel setaccess $LANCHAN $USERSLOT link=on; do sleep 1 let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; fi done -fi -let idev=idev-1 + TRIES=0 + if [ "$CURRENTUSER" != "$bmcu" ]; then + # Change the user name, if necessary + while ! ipmitool -d $idev user set name $USERSLOT $bmcu; do + sleep 1 + let TRIES=TRIES+1 + if [ $TRIES -gt $TIMEOUT ]; then break; fi + done + fi + let idev=idev-1 done + let idev=NUMBMCS-1 for bmcp in $BMCPW; do if [ "$bmcp" = "" ]; then continue; fi -TRIES=0 -# Set the password for the specified user -while ! ipmitool -d $idev user set password $USERSLOT $bmcp; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi -done -TRIES=0 -logger -s -t $log_label -p local4.info "Set up following user table: " -# Display the user list -ipmitool -d $idev user list $LANCHAN -let idev=idev-1 + TRIES=0 + # Set the password for the specified user + while ! ipmitool -d $idev user set password $USERSLOT $bmcp; do + sleep 1 + let TRIES=TRIES+1 + if [ $TRIES -gt $TIMEOUT ]; then break; fi + done + TRIES=0 + logger -s -t $log_label -p local4.info "Set up following user table: " + # Display the user list + ipmitool -d $idev user list $LANCHAN + let idev=idev-1 done let idev=NUMBMCS while [ $idev -gt 0 ]; do -let idev=idev-1 - -logger -s -t $log_label -p local4.info "Enabling Channel $LANCHAN: " -# Set the non-volatile channel access: enable and privilege -while ! ipmitool -d $idev raw 0x6 0x40 $LANCHAN 0x42 0x44 > /dev/null; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi -done -TRIES=0 -# Set the volatile channel access: enable and privilege -while ! ipmitool -d $idev raw 0x6 0x40 $LANCHAN 0x82 0x84 > /dev/null; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi -done -if [ $TRIES -gt $TIMEOUT ]; then logger -s -t $log_label -p local4.err "ERROR"; else logger -s -t $log_label -p local4.info "OK"; fi -TRIES=0 - -logger -s -t $log_label -p local4.info "Enabling ARP responses: " -# enable the ARP response on the channel -while ! ipmitool -d $idev lan set $LANCHAN arp respond on > /dev/null; do - sleep 1 - let TRIES=TRIES+1 - echo -n "." - if [ $TRIES -gt $TIMEOUT ]; then break; fi -done -if [ $TRIES -gt $TIMEOUT ]; then logger -s -t $log_label -p local4.err "ERROR"; else logger -s -t $log_label -p local4.info "OK"; fi -TRIES=0 - -logger -s -t $log_label -p local4.info "Enabling IPMI v 1.5 MD5 LAN access:" -# Set the auth level to md5 for the channel -while ! ipmitool -d $idev lan set $LANCHAN auth admin md5 > /dev/null; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi -done -if [ $TRIES -gt $TIMEOUT ]; then logger -s -t $log_label -p local4.err "ERROR"; else logger -s -t $log_label -p local4.info "OK"; fi -TRIES=0 -if [ ! "$IPMIVER" == "1.5" ]; then - logger -s -t $log_label -p local4.info "Enabling IPMI v 2.0 LAN access: " - #the following goals: - #disable cipher suite 0 (if present, avoid password bypass) - #disable cipher suite 1 (if present, to avoid weaking Kg if used) - #enable cipher suite 2 (scenarios without perl Rijndael) - #enable cipher suite 3 - #ignore the rest - # - # Read the LAN info - # - ZEROIDX=$(ipmitool lan print $LANCHAN|grep ^RMCP+|cut -d: -f 2|sed -e 's/ //' -e 's/,/\n/g'|grep -n '%0$'|sed -e 's/:.*//') - ONEIDX=$(ipmitool lan print $LANCHAN|grep ^RMCP+|cut -d: -f 2|sed -e 's/ //' -e 's/,/\n/g'|grep -n '^1$'|sed -e 's/:.*//') - TWOIDX=$(ipmitool lan print $LANCHAN|grep ^RMCP+|cut -d: -f 2|sed -e 's/ //' -e 's/,/\n/g'|grep -n '^2$'|sed -e 's/:.*//') - THREEIDX=$(ipmitool lan print $LANCHAN|grep ^RMCP+|cut -d: -f 2|sed -e 's/ //' -e 's/,/\n/g'|grep -n '^3$'|sed -e 's/:.*//') - ACCESS=$(ipmitool lan print $LANCHAN|grep 'Cipher Suite Priv Max'|cut -d: -f 2|sed -e 's/ //g' -e 's/\(.\)/\1\n/g'|grep -v '^$') - NEWACCESS="" - logger -t $log_label -p local4.info "ZEROIDX is $ZEROIDX, ONEIDX is $ONEIDX, TWOIDX is $TWOIDX, THREEIDX is $THREEIDX, ACCESS is $ACCESS" - i=1 - for elem in $ACCESS; do - if [ $i = "$ZEROIDX" -o $i = "$ONEIDX" ]; then - NEWACCESS="$NEWACCESS"X - elif [ $i = "$TWOIDX" -o $i = "$THREEIDX" ]; then - #do not *downgrade* from OEM priv - if [ "$elem" != "O" ]; then NEWACCESS="$NEWACCESS"a; else NEWACCESS="$NEWACCESS"$elem; fi - else - NEWACCESS="$NEWACCESS"$elem - fi - i=$((i+1)) - done - # Set the cipher_privileges for the channel - if ipmitool lan set $LANCHAN cipher_privs $NEWACCESS > /dev/null; then - logger -s -t $log_label -p local4.info "OK" - else - logger -s -t $log_label -p local4.err "ERROR" - fi + let idev=idev-1 + logger -s -t $log_label -p local4.info "Enabling Channel $LANCHAN: " TRIES=0 - logger -s -t $log_label -p local4.info "Enabling SOL for channel $LANCHAN:" - # Enable the SOL for the channel - while ! ipmitool -d $idev raw 0xc 0x21 $LANCHAN 0x1 0x1 > /dev/null; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done - if [ $TRIES -gt $TIMEOUT ]; then logger -s -t $log_label -p local4.err "ERROR"; else logger -s -t $log_label -p local4.info "OK"; fi - TRIES=0 - - logger -s -t $log_label -p local4.info "Enabling SOL for $BMCUS:" - # Enable the SOL for the USER and set the payload 1 - while ! ipmitool -d $idev raw 6 0x4c $LANCHAN $USERSLOT 2 0 0 0 > /dev/null; do + # Set the non-volatile channel access: enable and privilege + while ! ipmitool -d $idev raw 0x6 0x40 $LANCHAN 0x42 0x44 > /dev/null; do sleep 1 let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; fi done + TRIES=0 + # Set the volatile channel access: enable and privilege + while ! ipmitool -d $idev raw 0x6 0x40 $LANCHAN 0x82 0x84 > /dev/null; do + sleep 1 + let TRIES=TRIES+1 + if [ $TRIES -gt $TIMEOUT ]; then break; fi + done if [ $TRIES -gt $TIMEOUT ]; then - logger -s -t $log_label -p local4.err "ERROR Tried $TIMEOUT times, could not enable SOL for $BMCUS" + logger -s -t $log_label -p local4.err "ERROR - Setting the volatile channel access." + else + logger -s -t $log_label -p local4.info "OK" + fi + + logger -s -t $log_label -p local4.info "Enabling ARP responses: " + TRIES=0 + # enable the ARP response on the channel + while ! ipmitool -d $idev lan set $LANCHAN arp respond on > /dev/null; do + sleep 1 + let TRIES=TRIES+1 + echo -n . + if [ $TRIES -gt $TIMEOUT ]; then break; fi + done + if [ $TRIES -gt $TIMEOUT ]; then + logger -s -t $log_label -p local4.err "ERROR - Enabling ARP Responses." + else + logger -s -t $log_label -p local4.info "OK" + fi + + logger -s -t $log_label -p local4.info "Enabling IPMI v 1.5 MD5 LAN access:" + TRIES=0 + # Set the auth level to md5 for the channel + while ! ipmitool -d $idev lan set $LANCHAN auth admin md5 > /dev/null; do + sleep 1 + let TRIES=TRIES+1 + if [ $TRIES -gt $TIMEOUT ]; then break; fi + done + if [ $TRIES -gt $TIMEOUT ]; then + logger -s -t $log_label -p local4.err "ERROR - Enabling MD5 for the channel." else - logger -s -t $log_label -p local4.info "Enabling SOL for $BMCUS: OK" + logger -s -t $log_label -p local4.info "OK" fi -fi -# Cold reset the BMC -cold_reset_bmc ${XPROD} + if [ ! "$IPMIVER" == "1.5" ]; then + logger -s -t $log_label -p local4.info "Enabling IPMI v 2.0 LAN access: " + # the following goals: + # - disable cipher suite 0 (if present, avoid password bypass) + # - disable cipher suite 1 (if present, to avoid weaking Kg if used) + # - enable cipher suite 2 (scenarios without perl Rijndael) + # - enable cipher suite 3 + # - ignore the rest + # + # Read the LAN info + # + ZEROIDX=$(ipmitool lan print $LANCHAN|grep ^RMCP+|cut -d: -f 2|sed -e 's/ //' -e 's/,/\n/g'|grep -n '%0$'|sed -e 's/:.*//') + ONEIDX=$(ipmitool lan print $LANCHAN|grep ^RMCP+|cut -d: -f 2|sed -e 's/ //' -e 's/,/\n/g'|grep -n '^1$'|sed -e 's/:.*//') + TWOIDX=$(ipmitool lan print $LANCHAN|grep ^RMCP+|cut -d: -f 2|sed -e 's/ //' -e 's/,/\n/g'|grep -n '^2$'|sed -e 's/:.*//') + THREEIDX=$(ipmitool lan print $LANCHAN|grep ^RMCP+|cut -d: -f 2|sed -e 's/ //' -e 's/,/\n/g'|grep -n '^3$'|sed -e 's/:.*//') + ACCESS=$(ipmitool lan print $LANCHAN|grep 'Cipher Suite Priv Max'|cut -d: -f 2|sed -e 's/ //g' -e 's/\(.\)/\1\n/g'|grep -v '^$') + logger -t $log_label -p local4.info "ZEROIDX is $ZEROIDX, ONEIDX is $ONEIDX, TWOIDX is $TWOIDX, THREEIDX is $THREEIDX, ACCESS is $ACCESS" + NEWACCESS="" + i=1 + for elem in $ACCESS; do + if [ $i = "$ZEROIDX" -o $i = "$ONEIDX" ]; then + NEWACCESS="$NEWACCESS"X + elif [ $i = "$TWOIDX" -o $i = "$THREEIDX" ]; then + #do not *downgrade* from OEM priv + if [ "$elem" != "O" ]; then NEWACCESS="$NEWACCESS"a; else NEWACCESS="$NEWACCESS"$elem; fi + else + NEWACCESS="$NEWACCESS"$elem + fi + i=$((i+1)) + done + # Set the cipher_privileges for the channel + if ipmitool lan set $LANCHAN cipher_privs $NEWACCESS > /dev/null; then + logger -s -t $log_label -p local4.info "OK" + else + logger -s -t $log_label -p local4.info "ERROR - Setting cipher privileges for the channel." + fi -# update the node status to 'bmcready' -for parm in `cat /proc/cmdline`; do - key=`echo $parm|awk -F= '{print $1}'` - if [ "$key" = "xcatd" ]; then - XCATMASTER=`echo $parm|awk -F= '{print $2}'|awk -F: '{print $1}'` + logger -s -t $log_label -p local4.info "Enabling SOL for channel $LANCHAN:" + TRIES=0 + # Enable the SOL for the channel + while ! ipmitool -d $idev raw 0xc 0x21 $LANCHAN 0x1 0x1 > /dev/null; do + sleep 1 + let TRIES=TRIES+1 + if [ $TRIES -gt $TIMEOUT ]; then break; fi + done + if [ $TRIES -gt $TIMEOUT ]; then + logger -s -t $log_label -p local4.info "ERROR - Enabling SOL for the channel: $LANCHAN" + else + logger -s -t $log_label -p local4.info "OK" + fi + + TRIES=0 + logger -s -t $log_label -p local4.info "Enabling SOL for $BMCUS:" + # Enable the SOL for the USER and set the payload 1 + while ! ipmitool -d $idev raw 6 0x4c $LANCHAN $USERSLOT 2 0 0 0 > /dev/null; do + sleep 1 + let TRIES=TRIES+1 + if [ $TRIES -gt $TIMEOUT ]; then break; fi + done + if [ $TRIES -gt $TIMEOUT ]; then + logger -s -t $log_label -p local4.info "ERROR - Enabling SOL for BMC User: $BMCUS" + else + echo "OK" + fi fi -done -if [ ! -z "$XCATMASTER" ]; then - updateflag.awk $XCATMASTER 3002 "installstatus bmcready" -fi -logger -s -t $log_label -p local4.info "Lighting Identify Light" -while : - # Identify the server by turning on the LED light - do ipmitool -d $idev raw 0 4 10 > /dev/null - sleep 7 -done & + # Cold reset the BMC + cold_reset_bmc ${XPROD} + + # update the node status to 'bmcready' + for parm in `cat /proc/cmdline`; do + key=`echo $parm|awk -F= '{print $1}'` + if [ "$key" = "xcatd" ]; then + XCATMASTER=`echo $parm|awk -F= '{print $2}'|awk -F: '{print $1}'` + fi + done + if [ ! -z "$XCATMASTER" ]; then + updateflag.awk $XCATMASTER 3002 "installstatus bmcready" + fi + + logger -s -t $log_label -p local4.info "Lighting Identify Light" + while : + # Identify the server by turning on the LED light + do ipmitool -d $idev raw 0 4 10 > /dev/null + sleep 7 + done & done From 08e6606dca871426f514e9fdd9ff642613581047 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Tue, 7 Jun 2016 17:25:50 -0400 Subject: [PATCH 091/310] Use a different ipmitool command for the OpenPower BMC to identify the light --- xCAT-genesis-scripts/bin/bmcsetup | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index c1651f364..76302a190 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -531,10 +531,16 @@ while [ $idev -gt 0 ]; do fi logger -s -t $log_label -p local4.info "Lighting Identify Light" - while : - # Identify the server by turning on the LED light - do ipmitool -d $idev raw 0 4 10 > /dev/null - sleep 7 - done & + if [ "$XPROD" = "43707" ]; then + # OpenPower BMC specific, turn on the LED beacon for 5 minutes + ipmitool chassis identify 300 + else + # All other BMCs + while : + # Identify the server by turning on the LED light + do ipmitool -d $idev raw 0 4 10 > /dev/null + sleep 7 + done & + fi done From e8b6841eb18f3dd34c16ba9a4bd2695c62a59d90 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Wed, 8 Jun 2016 13:40:31 -0400 Subject: [PATCH 092/310] Additional enhancement/cleanup for the bmcsetup scripts - Move the TIMEOUT to be a global at the to of the script - Ensure we are resetting the TRIES=0 right before using it (clean up some code format) - Clean up the code for detecting the LAN channel, print out the detected channel - Create a snooze function for OpenPower to sleep longer after network commands are issued --- xCAT-genesis-scripts/bin/bmcsetup | 84 +++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 26 deletions(-) diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index 76302a190..fc0c64691 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -14,6 +14,11 @@ # log_label="xcat.genesis.bmcsetup" +TIMEOUT=15 + +# +# Function: cold_reset_bmc +# # Cold reset the BMC for certain servers # Product ID: 309 - x3755 M4 (8722) # Product ID: 43707 - IBM Power S822LC and S812LC @@ -21,9 +26,13 @@ log_label="xcat.genesis.bmcsetup" # Otherwise the BMC will not respond to ping after running the ipmitool commands in this script # function cold_reset_bmc() { - PROD=$1 - if [ "$PROD" = "309" -o "$PROD" = "43707" ] ; then - if [ "$PROD" = "43707" ]; then + if [ -z $XPROD ]; then + echo "FATAL ERROR - XPROD must be set before calling cold_reset_bmc()" + exit 1 + fi + + if [ "$XPROD" = "309" -o "$XPROD" = "43707" ] ; then + if [ "$XPROD" = "43707" ]; then # OpenPower SPECIFIC, the OpenPower machines with AMI BMC should NOT need a # reset after applying ipmitool commands. However, it seems there is a problem with # the BMC where after 15 seconds, it stops responding. To work around, sleep 30 @@ -35,7 +44,7 @@ function cold_reset_bmc() { ipmitool mc reset cold logger -s -t $log_label -p local4.info "Waiting for the BMC to appear ..." - if [ "$PROD" = "43707" ]; then + if [ "$XPROD" = "43707" ]; then # OpenPower SPECIFIC, check the BMC with the following raw command to # make sure that the bmc is really in a "ready" state before continuing SLEEP_INTERVAL=3 @@ -66,6 +75,26 @@ function cold_reset_bmc() { fi } +# +# Function snooze() +# +# The purpose of this is to work around the issue with OpenPower BMCs after +# making a change to network configuration, sleep 30 to be sure the changes apply. +# +function snooze() { + if [ -z $XPROD ]; then + echo "FATAL ERROR - XPROD must be set before calling snooze()" + exit 1 + fi + + if [ "$XPROD" = "43707" ]; then + # For OpenPower Machines + sleep 30 + else + sleep 1 + fi +} + allowcred.awk & CREDPID=$! sleep 5 @@ -75,7 +104,6 @@ while [ -z "$BMCIP" -a $IPCFGMETHOD="static" ]; do do logger -s -t $log_label -p local4.info "Retrying retrieval of IPMI settings from server" done - TIMEOUT=15 BMCIP=`grep bmcip /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'` BMCVLAN=`grep taggedvlan /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'` if [ -z "$BMCVLAN" ]; then @@ -193,12 +221,11 @@ elif [ "$IPMIMFG" == "47488" ]; then LOCKEDUSERS=1 fi -logger -s -t $log_label -p local4.info "Auto detecting LAN channel..." while [ -z "$LANCHAN" ]; do - for TLANCHAN in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do + logger -s -t $log_label -p local4.info "Auto detecting LAN channel..." + for TLANCHAN in {1..16}; do # Try to get the channel information; then get the MAC which is used for the channel - if ipmitool channel info $TLANCHAN 2> /dev/null | grep 802.3 > /dev/null 2>&1 && ipmitool raw 0xc 2 $TLANCHAN 5 0 0 > /dev/null 2>&1; - then + if ipmitool channel info $TLANCHAN 2> /dev/null | grep 802.3 > /dev/null 2>&1 && ipmitool raw 0xc 2 $TLANCHAN 5 0 0 > /dev/null 2>&1; then LANCHAN=$TLANCHAN break; fi; @@ -218,7 +245,7 @@ if [ $IPCFGMETHOD="static" ]; then TRIES=0 # Set the channel to use STATIC IP address while ! ipmitool -d $idev lan set $LANCHAN ipsrc static; do - sleep 1 + snooze let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; @@ -230,7 +257,7 @@ if [ $IPCFGMETHOD="static" ]; then TRIES=0 # Set the IP for the current channel while ! ipmitool -d $idev lan set $LANCHAN ipaddr $b; do - sleep 1 + snooze let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; @@ -243,7 +270,7 @@ if [ $IPCFGMETHOD="static" ]; then TRIES=0 # Set the NETMASK for the current channel while ! ipmitool -d $idev lan set $LANCHAN netmask $m; do - sleep 1 + snooze let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; @@ -251,14 +278,14 @@ if [ $IPCFGMETHOD="static" ]; then done let idev=idev+1 done - TRIES=0 + if [ ! -z "$BMCGW" ]; then let idev=0 for g in $BMCGW; do TRIES=0 # Set the GATEWAY for the current channel while ! ipmitool -d $idev lan set $LANCHAN defgw ipaddr $g; do - sleep 1 + snooze let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; @@ -266,7 +293,6 @@ if [ $IPCFGMETHOD="static" ]; then done let idev=idev+1 done - TRIES=0 fi else let idev=NUMBMCS @@ -275,7 +301,7 @@ else TRIES=0 # Set the method to get IP for the current channel, if required. while ! ipmitool -d $idev lan set $LANCHAN ipsrc $IPCFGMETHOD; do - sleep 1 + snooze let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; @@ -289,7 +315,7 @@ for b in $BMCVLAN; do TRIES=0 # Set VLAN for the current channel while ! ipmitool -d $idev lan set $LANCHAN vlan id $b; do - sleep 1 + snooze let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; @@ -299,8 +325,8 @@ for b in $BMCVLAN; do done let idev=NUMBMCS-1 -for bmcu in $BMCUS; do - if [ "$bmcu" = "" ]; then +for user in $BMCUS; do + if [ "$user" = "" ]; then continue fi DISABLEUSERS="1 2 3 4" @@ -328,14 +354,15 @@ for bmcu in $BMCUS; do DISABLEUSERS=`echo 1 2 3 4|sed -e s/$USERSLOT//` logger -t $log_label -p local4.info "CURRENTUSER=$CURRENTUSER, DISABLEUSERS=$DISABLEUSERS" for user in $DISABLEUSERS; do + TRIES=0 # Disable the non-specified user while ! ipmitool -d $idev user disable $user; do sleep 1 let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; fi done - TRIES=0 done + TRIES=0 # Enable the specified user while ! ipmitool -d $idev user enable $USERSLOT; do @@ -343,6 +370,7 @@ for bmcu in $BMCUS; do let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; fi done + TRIES=0 # Last param in ipmitool user priv is the channel to set it on. # Penguin boxes are all channel 2 @@ -359,6 +387,7 @@ for bmcu in $BMCUS; do if [ $TRIES -gt $TIMEOUT ]; then break; fi done fi + TRIES=0 # Enable the channel link for the specified user while ! ipmitool -d $idev channel setaccess $LANCHAN $USERSLOT link=on; do @@ -366,10 +395,11 @@ for bmcu in $BMCUS; do let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; fi done + TRIES=0 - if [ "$CURRENTUSER" != "$bmcu" ]; then + if [ "$CURRENTUSER" != "$user" ]; then # Change the user name, if necessary - while ! ipmitool -d $idev user set name $USERSLOT $bmcu; do + while ! ipmitool -d $idev user set name $USERSLOT $user; do sleep 1 let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; fi @@ -381,6 +411,7 @@ done let idev=NUMBMCS-1 for bmcp in $BMCPW; do if [ "$bmcp" = "" ]; then continue; fi + TRIES=0 # Set the password for the specified user while ! ipmitool -d $idev user set password $USERSLOT $bmcp; do @@ -388,8 +419,9 @@ for bmcp in $BMCPW; do let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; fi done - TRIES=0 + logger -s -t $log_label -p local4.info "Set up following user table: " + TRIES=0 # Display the user list ipmitool -d $idev user list $LANCHAN let idev=idev-1 @@ -501,9 +533,9 @@ while [ $idev -gt 0 ]; do logger -s -t $log_label -p local4.info "OK" fi - TRIES=0 logger -s -t $log_label -p local4.info "Enabling SOL for $BMCUS:" - # Enable the SOL for the USER and set the payload 1 + TRIES=0 + # Enabl the SOL for the USER and set the payload 1 while ! ipmitool -d $idev raw 6 0x4c $LANCHAN $USERSLOT 2 0 0 0 > /dev/null; do sleep 1 let TRIES=TRIES+1 @@ -517,7 +549,7 @@ while [ $idev -gt 0 ]; do fi # Cold reset the BMC - cold_reset_bmc ${XPROD} + cold_reset_bmc # update the node status to 'bmcready' for parm in `cat /proc/cmdline`; do From 7f818a70662833a1fe59920097359609a7ba8710 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Fri, 10 Jun 2016 15:22:30 -0400 Subject: [PATCH 093/310] Change the logging messages to reuse a single message for each IPMITOOL command --- xCAT-genesis-scripts/bin/bmcsetup | 60 ++++++++++++++----------------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index fc0c64691..194e7373a 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -431,7 +431,8 @@ let idev=NUMBMCS while [ $idev -gt 0 ]; do let idev=idev-1 - logger -s -t $log_label -p local4.info "Enabling Channel $LANCHAN: " + MSG="Enabling the non-volatile channel access ($LANCHAN)" + logger -s -t $log_label -p local4.info "$MSG" TRIES=0 # Set the non-volatile channel access: enable and privilege while ! ipmitool -d $idev raw 0x6 0x40 $LANCHAN 0x42 0x44 > /dev/null; do @@ -439,7 +440,10 @@ while [ $idev -gt 0 ]; do let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; fi done + if [ $TRIES -gt $TIMEOUT ]; then logger -s -t $log_label -p local4.err "$MSG: ERROR"; else logger -s -t $log_label -p local4.info "$MSG: OK"; fi + MSG="Enabling the volatile channel access ($LANCHAN)" + logger -s -t $log_label -p local4.info "$MSG" TRIES=0 # Set the volatile channel access: enable and privilege while ! ipmitool -d $idev raw 0x6 0x40 $LANCHAN 0x82 0x84 > /dev/null; do @@ -447,13 +451,10 @@ while [ $idev -gt 0 ]; do let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; fi done - if [ $TRIES -gt $TIMEOUT ]; then - logger -s -t $log_label -p local4.err "ERROR - Setting the volatile channel access." - else - logger -s -t $log_label -p local4.info "OK" - fi + if [ $TRIES -gt $TIMEOUT ]; then logger -s -t $log_label -p local4.err "$MSG: ERROR"; else logger -s -t $log_label -p local4.info "$MSG: OK"; fi - logger -s -t $log_label -p local4.info "Enabling ARP responses: " + MSG="Enabling ARP responses" + logger -s -t $log_label -p local4.info "$MSG" TRIES=0 # enable the ARP response on the channel while ! ipmitool -d $idev lan set $LANCHAN arp respond on > /dev/null; do @@ -462,13 +463,10 @@ while [ $idev -gt 0 ]; do echo -n . if [ $TRIES -gt $TIMEOUT ]; then break; fi done - if [ $TRIES -gt $TIMEOUT ]; then - logger -s -t $log_label -p local4.err "ERROR - Enabling ARP Responses." - else - logger -s -t $log_label -p local4.info "OK" - fi + if [ $TRIES -gt $TIMEOUT ]; then logger -s -t $log_label -p local4.err "$MSG: ERROR"; else logger -s -t $log_label -p local4.info "$MSG: OK"; fi - logger -s -t $log_label -p local4.info "Enabling IPMI v 1.5 MD5 LAN access:" + MSG="Enabling IPMI v 1.5 MD5 LAN access" + logger -s -t $log_label -p local4.info "$MSG" TRIES=0 # Set the auth level to md5 for the channel while ! ipmitool -d $idev lan set $LANCHAN auth admin md5 > /dev/null; do @@ -476,14 +474,11 @@ while [ $idev -gt 0 ]; do let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; fi done - if [ $TRIES -gt $TIMEOUT ]; then - logger -s -t $log_label -p local4.err "ERROR - Enabling MD5 for the channel." - else - logger -s -t $log_label -p local4.info "OK" - fi + if [ $TRIES -gt $TIMEOUT ]; then logger -s -t $log_label -p local4.err "$MSG: ERROR"; else logger -s -t $log_label -p local4.info "$MSG: OK"; fi if [ ! "$IPMIVER" == "1.5" ]; then - logger -s -t $log_label -p local4.info "Enabling IPMI v 2.0 LAN access: " + MSG="Enabling IPMI v 2.0 LAN access" + logger -s -t $log_label -p local4.info "$MSG" # the following goals: # - disable cipher suite 0 (if present, avoid password bypass) # - disable cipher suite 1 (if present, to avoid weaking Kg if used) @@ -512,14 +507,18 @@ while [ $idev -gt 0 ]; do fi i=$((i+1)) done + + MSG="Set the cipher_privileges for the channel" + logger -s -t $log_label -p local4.info "$MSG" # Set the cipher_privileges for the channel if ipmitool lan set $LANCHAN cipher_privs $NEWACCESS > /dev/null; then - logger -s -t $log_label -p local4.info "OK" + logger -s -t $log_label -p local4.info "$MSG: OK" else - logger -s -t $log_label -p local4.info "ERROR - Setting cipher privileges for the channel." + logger -s -t $log_label -p local4.info "$MSG: ERROR" fi - logger -s -t $log_label -p local4.info "Enabling SOL for channel $LANCHAN:" + MSG="Enabling SOL for channel $LANCHAN" + logger -s -t $log_label -p local4.info "$MSG" TRIES=0 # Enable the SOL for the channel while ! ipmitool -d $idev raw 0xc 0x21 $LANCHAN 0x1 0x1 > /dev/null; do @@ -527,25 +526,18 @@ while [ $idev -gt 0 ]; do let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; fi done - if [ $TRIES -gt $TIMEOUT ]; then - logger -s -t $log_label -p local4.info "ERROR - Enabling SOL for the channel: $LANCHAN" - else - logger -s -t $log_label -p local4.info "OK" - fi + if [ $TRIES -gt $TIMEOUT ]; then logger -s -t $log_label -p local4.err "$MSG: ERROR"; else logger -s -t $log_label -p local4.info "$MSG: OK"; fi - logger -s -t $log_label -p local4.info "Enabling SOL for $BMCUS:" + MSG="Enabling SOL for $BMCUS" + logger -s -t $log_label -p local4.info "$MSG" TRIES=0 - # Enabl the SOL for the USER and set the payload 1 + # Enable the SOL for the USER and set the payload 1 while ! ipmitool -d $idev raw 6 0x4c $LANCHAN $USERSLOT 2 0 0 0 > /dev/null; do sleep 1 let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; fi done - if [ $TRIES -gt $TIMEOUT ]; then - logger -s -t $log_label -p local4.info "ERROR - Enabling SOL for BMC User: $BMCUS" - else - echo "OK" - fi + if [ $TRIES -gt $TIMEOUT ]; then logger -s -t $log_label -p local4.err "$MSG: ERROR"; else logger -s -t $log_label -p local4.info "$MSG: OK"; fi fi # Cold reset the BMC From 5860235832ace55304c7b5595a940fe8e83cc96f Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Fri, 10 Jun 2016 15:40:29 -0400 Subject: [PATCH 094/310] The xCAT-nbroot has been replaced by xCAT-genesis Removing the old files associated with nbroot/nbroot2 --- build-debs-all | 88 --- build-ubunturepo | 4 +- makerpm | 28 +- xCAT-genesis-scripts/bin/doxcat | 2 +- xCAT-nbroot/LICENSE.html | 326 --------- xCAT-nbroot/debian/changelog | 11 - xCAT-nbroot/debian/compat | 1 - xCAT-nbroot/debian/control | 27 - xCAT-nbroot/debian/copyright | 88 --- xCAT-nbroot/debian/docs | 1 - xCAT-nbroot/debian/rules | 69 -- xCAT-nbroot/debian/source/format | 1 - .../debian/xcat-nbroot-core-amd64.dirs | 1 - .../debian/xcat-nbroot-core-amd64.install | 1 - .../debian/xcat-nbroot-core-amd64.postinst | 43 -- .../debian/xcat-nbroot-core-amd64.substvars | 2 - .../debian/xcat-nbroot-core-ppc64.dirs | 1 - .../debian/xcat-nbroot-core-ppc64.install | 1 - .../debian/xcat-nbroot-core-ppc64.postinst | 43 -- .../debian/xcat-nbroot-core-ppc64.substvars | 2 - xCAT-nbroot/debian/xcat-nbroot-core-x86.dirs | 1 - .../debian/xcat-nbroot-core-x86.install | 1 - .../debian/xcat-nbroot-core-x86.postinst | 43 -- .../debian/xcat-nbroot-core-x86.substvars | 2 - xCAT-nbroot/overlay/bin/allowcred.awk | 15 - xCAT-nbroot/overlay/bin/bmcsetup | 290 -------- xCAT-nbroot/overlay/bin/dodestiny | 195 ------ xCAT-nbroot/overlay/bin/frume.awk | 26 - xCAT-nbroot/overlay/bin/getdestiny | 10 - xCAT-nbroot/overlay/bin/getdestiny.awk | 26 - xCAT-nbroot/overlay/bin/getipmi | 24 - xCAT-nbroot/overlay/bin/getipmi.awk | 26 - xCAT-nbroot/overlay/bin/minixcatd.awk | 19 - xCAT-nbroot/overlay/bin/nextdestiny | 10 - xCAT-nbroot/overlay/bin/nextdestiny.awk | 26 - xCAT-nbroot/overlay/bin/rebootnode | 6 - xCAT-nbroot/overlay/bin/restart | 38 - xCAT-nbroot/overlay/bin/udpcat.awk | 12 - xCAT-nbroot/overlay/etc/init.d/S10autodetect | 122 ---- xCAT-nbroot/overlay/etc/init.d/S11stunnel | 35 - xCAT-nbroot/overlay/etc/init.d/S40network | 2 - xCAT-nbroot/overlay/etc/init.d/S99xcat.sh | 10 - xCAT-nbroot/overlay/etc/profile | 0 xCAT-nbroot/overlay/init | 36 - .../overlay/usr/share/udhcpc/default.script | 25 - xCAT-nbroot/xcat-core-nbroot.spec | 61 -- xCAT-nbroot2/98-mlx.rules | 1 - xCAT-nbroot2/99-imm.rules | 1 - xCAT-nbroot2/LICENSE.html | 326 --------- xCAT-nbroot2/allowcred.awk | 15 - xCAT-nbroot2/bmcsetup | 353 ---------- xCAT-nbroot2/buildrpm | 12 - xCAT-nbroot2/check | 3 - xCAT-nbroot2/debian/changelog | 77 -- xCAT-nbroot2/debian/compat | 1 - xCAT-nbroot2/debian/control | 14 - xCAT-nbroot2/debian/copyright | 88 --- xCAT-nbroot2/debian/docs | 1 - xCAT-nbroot2/debian/rules | 85 --- xCAT-nbroot2/debian/source/format | 1 - xCAT-nbroot2/debian/xcat-genesis-amd64.dirs | 1 - .../debian/xcat-genesis-amd64.postinst | 46 -- xCAT-nbroot2/debian/xcat-genesis-amd64.prerm | 41 -- xCAT-nbroot2/dhclient-script | 68 -- xCAT-nbroot2/dhclient.conf | 2 - xCAT-nbroot2/dodiscovery | 127 ---- xCAT-nbroot2/doxcat | 179 ----- xCAT-nbroot2/getcert | 41 -- xCAT-nbroot2/getdestiny | 30 - xCAT-nbroot2/getipmi | 46 -- xCAT-nbroot2/ifup | 4 - xCAT-nbroot2/install | 639 ----------------- xCAT-nbroot2/install.debian | 639 ----------------- xCAT-nbroot2/install.ubuntu | 661 ------------------ xCAT-nbroot2/installkernel | 7 - xCAT-nbroot2/loadmlxeth | 2 - xCAT-nbroot2/minixcatd.awk | 18 - xCAT-nbroot2/nextdestiny | 29 - xCAT-nbroot2/remoteimmsetup | 43 -- xCAT-nbroot2/restart | 64 -- xCAT-nbroot2/rsyslog.conf | 5 - xCAT-nbroot2/setupimmnic | 4 - xCAT-nbroot2/udpcat.awk | 12 - xCAT-nbroot2/xCAT-genesis-builder.spec | 44 -- xCAT-nbroot2/xCAT-genesis.spec | 61 -- xCAT-nbroot2/xcat-cmdline.sh | 27 - xCAT-nbroot2/xcatroot | 8 - 87 files changed, 4 insertions(+), 5623 deletions(-) delete mode 100755 build-debs-all delete mode 100644 xCAT-nbroot/LICENSE.html delete mode 100644 xCAT-nbroot/debian/changelog delete mode 100644 xCAT-nbroot/debian/compat delete mode 100644 xCAT-nbroot/debian/control delete mode 100644 xCAT-nbroot/debian/copyright delete mode 100644 xCAT-nbroot/debian/docs delete mode 100755 xCAT-nbroot/debian/rules delete mode 100644 xCAT-nbroot/debian/source/format delete mode 100644 xCAT-nbroot/debian/xcat-nbroot-core-amd64.dirs delete mode 100644 xCAT-nbroot/debian/xcat-nbroot-core-amd64.install delete mode 100644 xCAT-nbroot/debian/xcat-nbroot-core-amd64.postinst delete mode 100644 xCAT-nbroot/debian/xcat-nbroot-core-amd64.substvars delete mode 100644 xCAT-nbroot/debian/xcat-nbroot-core-ppc64.dirs delete mode 100644 xCAT-nbroot/debian/xcat-nbroot-core-ppc64.install delete mode 100644 xCAT-nbroot/debian/xcat-nbroot-core-ppc64.postinst delete mode 100644 xCAT-nbroot/debian/xcat-nbroot-core-ppc64.substvars delete mode 100644 xCAT-nbroot/debian/xcat-nbroot-core-x86.dirs delete mode 100644 xCAT-nbroot/debian/xcat-nbroot-core-x86.install delete mode 100644 xCAT-nbroot/debian/xcat-nbroot-core-x86.postinst delete mode 100644 xCAT-nbroot/debian/xcat-nbroot-core-x86.substvars delete mode 100755 xCAT-nbroot/overlay/bin/allowcred.awk delete mode 100755 xCAT-nbroot/overlay/bin/bmcsetup delete mode 100755 xCAT-nbroot/overlay/bin/dodestiny delete mode 100755 xCAT-nbroot/overlay/bin/frume.awk delete mode 100644 xCAT-nbroot/overlay/bin/getdestiny delete mode 100755 xCAT-nbroot/overlay/bin/getdestiny.awk delete mode 100644 xCAT-nbroot/overlay/bin/getipmi delete mode 100755 xCAT-nbroot/overlay/bin/getipmi.awk delete mode 100755 xCAT-nbroot/overlay/bin/minixcatd.awk delete mode 100755 xCAT-nbroot/overlay/bin/nextdestiny delete mode 100755 xCAT-nbroot/overlay/bin/nextdestiny.awk delete mode 100755 xCAT-nbroot/overlay/bin/rebootnode delete mode 100755 xCAT-nbroot/overlay/bin/restart delete mode 100755 xCAT-nbroot/overlay/bin/udpcat.awk delete mode 100755 xCAT-nbroot/overlay/etc/init.d/S10autodetect delete mode 100755 xCAT-nbroot/overlay/etc/init.d/S11stunnel delete mode 100644 xCAT-nbroot/overlay/etc/init.d/S40network delete mode 100755 xCAT-nbroot/overlay/etc/init.d/S99xcat.sh delete mode 100644 xCAT-nbroot/overlay/etc/profile delete mode 100755 xCAT-nbroot/overlay/init delete mode 100755 xCAT-nbroot/overlay/usr/share/udhcpc/default.script delete mode 100644 xCAT-nbroot/xcat-core-nbroot.spec delete mode 100644 xCAT-nbroot2/98-mlx.rules delete mode 100644 xCAT-nbroot2/99-imm.rules delete mode 100644 xCAT-nbroot2/LICENSE.html delete mode 100755 xCAT-nbroot2/allowcred.awk delete mode 100755 xCAT-nbroot2/bmcsetup delete mode 100755 xCAT-nbroot2/buildrpm delete mode 100755 xCAT-nbroot2/check delete mode 100644 xCAT-nbroot2/debian/changelog delete mode 100644 xCAT-nbroot2/debian/compat delete mode 100644 xCAT-nbroot2/debian/control delete mode 100644 xCAT-nbroot2/debian/copyright delete mode 100644 xCAT-nbroot2/debian/docs delete mode 100755 xCAT-nbroot2/debian/rules delete mode 100644 xCAT-nbroot2/debian/source/format delete mode 100644 xCAT-nbroot2/debian/xcat-genesis-amd64.dirs delete mode 100644 xCAT-nbroot2/debian/xcat-genesis-amd64.postinst delete mode 100644 xCAT-nbroot2/debian/xcat-genesis-amd64.prerm delete mode 100755 xCAT-nbroot2/dhclient-script delete mode 100644 xCAT-nbroot2/dhclient.conf delete mode 100755 xCAT-nbroot2/dodiscovery delete mode 100755 xCAT-nbroot2/doxcat delete mode 100755 xCAT-nbroot2/getcert delete mode 100755 xCAT-nbroot2/getdestiny delete mode 100755 xCAT-nbroot2/getipmi delete mode 100755 xCAT-nbroot2/ifup delete mode 100755 xCAT-nbroot2/install delete mode 100755 xCAT-nbroot2/install.debian delete mode 100755 xCAT-nbroot2/install.ubuntu delete mode 100755 xCAT-nbroot2/installkernel delete mode 100755 xCAT-nbroot2/loadmlxeth delete mode 100755 xCAT-nbroot2/minixcatd.awk delete mode 100755 xCAT-nbroot2/nextdestiny delete mode 100755 xCAT-nbroot2/remoteimmsetup delete mode 100755 xCAT-nbroot2/restart delete mode 100644 xCAT-nbroot2/rsyslog.conf delete mode 100755 xCAT-nbroot2/setupimmnic delete mode 100755 xCAT-nbroot2/udpcat.awk delete mode 100644 xCAT-nbroot2/xCAT-genesis-builder.spec delete mode 100644 xCAT-nbroot2/xCAT-genesis.spec delete mode 100644 xCAT-nbroot2/xcat-cmdline.sh delete mode 100755 xCAT-nbroot2/xcatroot diff --git a/build-debs-all b/build-debs-all deleted file mode 100755 index 70f71933a..000000000 --- a/build-debs-all +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash -########### -# -# This script call makedeb and create the deb packages -# for xCAT -# -# Author: Leonardo Tonetto -# Revisor: Adalberto Medeiros -# Revisor2: Arif Ali -# -# Input: -# -# $1 is the build type/location -# $2 is the string added to the debian/changelog of each package -# -############ - -############## -# Get input -############## - -PKG_LOCATION=$1 # local | snap | alpha -if [ -z $PKG_LOCATION ]; then - PKG_LOCATION="local" -fi -BUILD_STRING=$2 -if [ -z $BUILD_STRING ]; then - BUILD_STRING="Personal Build" -fi -XCAT_VERSION=`cat Version` -TRUNK_REVISION=`svnversion | cut -d ":" -f1` -CUR_DATE=`date +%Y%m%d` -VERSION="${XCAT_VERSION}-${PKG_LOCATION}${CUR_DATE}" - -function makedeb { - SRC_ROOT=$1 - PKG_LOCATION=$2 - BUILD_STRING=$3 - VERSION=$4 - - # - # Make DEBs - # - # build perl-xCAT - deps are libsoap-lite-perl, libdigest-sha1-perl, libdbi-perl - # - - find $SRC_ROOT -maxdepth 2 -name debian -type d | while read DEBIAN_DIR - do - DIR=`echo ${DEBIAN_DIR} | sed -e 's/[/]debian$//'` - cd ${DIR} - dch -v $VERSION -b -c debian/changelog "$BUILD_STRING" - dpkg-buildpackage - cd - - RC=$? - if [ ${RC} -gt 0 ] - then - echo "Warning: ${DEBIAN_DIR} failed exit code ${RC}" - fi - done - - # - # Clean up - # - # Eliminate unnecessary directories and debian/files made by dpkg-buildpackage - - find $SRC_ROOT -maxdepth 3 -type d -name "xcat-*" | grep debian | xargs rm -rf - find $SRC_ROOT -maxdepth 3 -type f -name "files" | grep debian | xargs rm -f -} - -# build all debian packages -packages="xCAT-client xCAT-nbroot xCAT-nbroot2 perl-xCAT xCAT-server xCAT-UI xCAT xCATsn xCAT-test xCAT-IBMhpc xCAT-rmc xCAT-vlan xCAT-confluent" - -for file in `echo $packages` -do - makedeb $file $PKG_LOCATION "$BUILD_STRING" $VERSION -done - -if [ -d debs ]; then - rm -rf debs -fi - -mkdir debs -mv xcat* debs/ -mv perl-xcat* debs/ - -echo $VERSION > latest_version - -exit 0 diff --git a/build-ubunturepo b/build-ubunturepo index 3678dc71e..153b2f986 100755 --- a/build-ubunturepo +++ b/build-ubunturepo @@ -35,8 +35,8 @@ printusage() { printf "Usage: %s {-c | -d} \n" $(basename $0) >&2 - echo " -c : Build the xcat core packages and create the repo" - echo " -d : Create the xcat dep repo. Building the xcat dep packages can refer \"build-debs-all\" from svn" + echo " -c : Build the xcat-core packages and create the repo" + echo " -d : Create the xcat-dep repo." } # For the purpose of getting the distribution name if [[ ! -f /etc/lsb-release ]]; then diff --git a/makerpm b/makerpm index 355e236bf..3aae57418 100755 --- a/makerpm +++ b/makerpm @@ -146,30 +146,6 @@ function makeironic { rm -rf /tmp/ironic_baremetal } - -# Make the xCAT-nbroot-core rpm -function makenbroot { - if [ -z "$2" ]; then - echo 'Usage: makerpm xCAT-nbroot-core []' - exit 1 - fi - - DIR="xCAT-nbroot" - ARCH="$2" - RPMNAME="xCAT-nbroot-core-$ARCH" - SPEC="xcat-core-nbroot" - cd `dirname $0`/$DIR - tar --exclude .svn -czf $RPMROOT/SOURCES/xcat-nbrootoverlay.tar.gz -C overlay/ . - cp LICENSE.html $RPMROOT/BUILD - cp $SPEC.spec $RPMROOT/SOURCES - cd - >/dev/null - rm -f $RPMROOT/SRPMS/$RPMNAME-$VER*rpm $RPMROOT/RPMS/noarch/$RPMNAME-$VER*rpm - echo "Building $RPMROOT/RPMS/noarch/$RPMNAME-$VER-snap*.noarch.rpm $EMBEDTXT..." - rpmbuild $QUIET -ba $DIR/$SPEC.spec --target $ARCH -} - - - # Make the xCAT-genesis rpm function makegenesis { DIR="xCAT-genesis-builder" @@ -183,6 +159,7 @@ function makegenesis { echo "Building $RPMROOT/RPMS/noarch/$RPMNAME-$VER-snap*.noarch.rpm $EMBEDTXT..." rpmbuild $QUIET -ba $DIR/$RPMNAME.spec } + function makegenesisscripts { DIR="xCAT-genesis-scripts" if [ -z "$2" ]; then @@ -248,9 +225,6 @@ fi if [ "$1" = "xCAT" -o "$1" = "xCATsn" -o "$1" = "xCAT-buildkit" -o "$1" = "xCAT-OpenStack" ]; then exportEmbed $3 makexcat $1 $2 -elif [ "$1" = "xCAT-nbroot" -o "$1" = "xCAT-nbroot-core" ]; then - exportEmbed $3 - makenbroot xCAT-nbroot-core $2 elif [ "$1" = "xCAT-genesis-builder" ]; then exportEmbed $2 makegenesis $1 diff --git a/xCAT-genesis-scripts/bin/doxcat b/xCAT-genesis-scripts/bin/doxcat index 3de9edcc6..d1c2964cf 100755 --- a/xCAT-genesis-scripts/bin/doxcat +++ b/xCAT-genesis-scripts/bin/doxcat @@ -33,7 +33,7 @@ if [ ! -z "$BOOTIF" ]; then bootnic=`ip link show|grep -B1 $BOOTIF|grep mtu|awk '{print $2}'|sed -e 's/:$//'` sleep 0.1 if [ $gripeiter = 0 ]; then - logger -s -t $log_label -p local4.err "Unable to find boot device (maybe the nbroot is missing the driver for your nic?)" + logger -s -t $log_label -p local4.err "Unable to find boot device (Maybe the xCAT genesis kernel is missing the driver for your NIC?)" while :; do sleep 365d; done fi gripeiter=$((gripeiter-1)) diff --git a/xCAT-nbroot/LICENSE.html b/xCAT-nbroot/LICENSE.html deleted file mode 100644 index 83d0eebb0..000000000 --- a/xCAT-nbroot/LICENSE.html +++ /dev/null @@ -1,326 +0,0 @@ - - - - - - - -Eclipse Public License - Version 1.0 - - - - - - -
- -

Eclipse Public License - v 1.0 -

- -

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER -THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, -REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE -OF THIS AGREEMENT.

- -

1. DEFINITIONS

- -

"Contribution" means:

- -

a) -in the case of the initial Contributor, the initial code and documentation -distributed under this Agreement, and
-b) in the case of each subsequent Contributor:

- -

i) -changes to the Program, and

- -

ii) -additions to the Program;

- -

where -such changes and/or additions to the Program originate from and are distributed -by that particular Contributor. A Contribution 'originates' from a Contributor -if it was added to the Program by such Contributor itself or anyone acting on -such Contributor's behalf. Contributions do not include additions to the -Program which: (i) are separate modules of software distributed in conjunction -with the Program under their own license agreement, and (ii) are not derivative -works of the Program.

- -

"Contributor" means any person or -entity that distributes the Program.

- -

"Licensed Patents " mean patent -claims licensable by a Contributor which are necessarily infringed by the use -or sale of its Contribution alone or when combined with the Program.

- -

"Program" means the Contributions -distributed in accordance with this Agreement.

- -

"Recipient" means anyone who -receives the Program under this Agreement, including all Contributors.

- -

2. GRANT OF RIGHTS

- -

a) -Subject to the terms of this Agreement, each Contributor hereby grants Recipient -a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly -display, publicly perform, distribute and sublicense the Contribution of such -Contributor, if any, and such derivative works, in source code and object code -form.

- -

b) -Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide, royalty-free -patent license under Licensed Patents to make, use, sell, offer to sell, import -and otherwise transfer the Contribution of such Contributor, if any, in source -code and object code form. This patent license shall apply to the combination -of the Contribution and the Program if, at the time the Contribution is added -by the Contributor, such addition of the Contribution causes such combination -to be covered by the Licensed Patents. The patent license shall not apply to -any other combinations which include the Contribution. No hardware per se is -licensed hereunder.

- -

c) -Recipient understands that although each Contributor grants the licenses to its -Contributions set forth herein, no assurances are provided by any Contributor -that the Program does not infringe the patent or other intellectual property -rights of any other entity. Each Contributor disclaims any liability to Recipient -for claims brought by any other entity based on infringement of intellectual -property rights or otherwise. As a condition to exercising the rights and -licenses granted hereunder, each Recipient hereby assumes sole responsibility -to secure any other intellectual property rights needed, if any. For example, -if a third party patent license is required to allow Recipient to distribute -the Program, it is Recipient's responsibility to acquire that license before -distributing the Program.

- -

d) -Each Contributor represents that to its knowledge it has sufficient copyright -rights in its Contribution, if any, to grant the copyright license set forth in -this Agreement.

- -

3. REQUIREMENTS

- -

A Contributor may choose to distribute the -Program in object code form under its own license agreement, provided that: -

- -

a) -it complies with the terms and conditions of this Agreement; and

- -

b) -its license agreement:

- -

i) -effectively disclaims on behalf of all Contributors all warranties and -conditions, express and implied, including warranties or conditions of title -and non-infringement, and implied warranties or conditions of merchantability -and fitness for a particular purpose;

- -

ii) -effectively excludes on behalf of all Contributors all liability for damages, -including direct, indirect, special, incidental and consequential damages, such -as lost profits;

- -

iii) -states that any provisions which differ from this Agreement are offered by that -Contributor alone and not by any other party; and

- -

iv) -states that source code for the Program is available from such Contributor, and -informs licensees how to obtain it in a reasonable manner on or through a -medium customarily used for software exchange.

- -

When the Program is made available in source -code form:

- -

a) -it must be made available under this Agreement; and

- -

b) a -copy of this Agreement must be included with each copy of the Program.

- -

Contributors may not remove or alter any -copyright notices contained within the Program.

- -

Each Contributor must identify itself as the -originator of its Contribution, if any, in a manner that reasonably allows -subsequent Recipients to identify the originator of the Contribution.

- -

4. COMMERCIAL DISTRIBUTION

- -

Commercial distributors of software may -accept certain responsibilities with respect to end users, business partners -and the like. While this license is intended to facilitate the commercial use -of the Program, the Contributor who includes the Program in a commercial -product offering should do so in a manner which does not create potential -liability for other Contributors. Therefore, if a Contributor includes the -Program in a commercial product offering, such Contributor ("Commercial -Contributor") hereby agrees to defend and indemnify every other -Contributor ("Indemnified Contributor") against any losses, damages and -costs (collectively "Losses") arising from claims, lawsuits and other -legal actions brought by a third party against the Indemnified Contributor to -the extent caused by the acts or omissions of such Commercial Contributor in -connection with its distribution of the Program in a commercial product -offering. The obligations in this section do not apply to any claims or Losses -relating to any actual or alleged intellectual property infringement. In order -to qualify, an Indemnified Contributor must: a) promptly notify the Commercial -Contributor in writing of such claim, and b) allow the Commercial Contributor -to control, and cooperate with the Commercial Contributor in, the defense and -any related settlement negotiations. The Indemnified Contributor may participate -in any such claim at its own expense.

- -

For example, a Contributor might include the -Program in a commercial product offering, Product X. That Contributor is then a -Commercial Contributor. If that Commercial Contributor then makes performance -claims, or offers warranties related to Product X, those performance claims and -warranties are such Commercial Contributor's responsibility alone. Under this -section, the Commercial Contributor would have to defend claims against the -other Contributors related to those performance claims and warranties, and if a -court requires any other Contributor to pay any damages as a result, the -Commercial Contributor must pay those damages.

- -

5. NO WARRANTY

- -

EXCEPT AS EXPRESSLY SET FORTH IN THIS -AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, -WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, -MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely -responsible for determining the appropriateness of using and distributing the -Program and assumes all risks associated with its exercise of rights under this -Agreement , including but not limited to the risks and costs of program errors, -compliance with applicable laws, damage to or loss of data, programs or -equipment, and unavailability or interruption of operations.

- -

6. DISCLAIMER OF LIABILITY

- -

EXCEPT AS EXPRESSLY SET FORTH IN THIS -AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY -OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF -THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF -THE POSSIBILITY OF SUCH DAMAGES.

- -

7. GENERAL

- -

If any provision of this Agreement is invalid -or unenforceable under applicable law, it shall not affect the validity or -enforceability of the remainder of the terms of this Agreement, and without -further action by the parties hereto, such provision shall be reformed to the -minimum extent necessary to make such provision valid and enforceable.

- -

If Recipient institutes patent litigation -against any entity (including a cross-claim or counterclaim in a lawsuit) -alleging that the Program itself (excluding combinations of the Program with -other software or hardware) infringes such Recipient's patent(s), then such -Recipient's rights granted under Section 2(b) shall terminate as of the date -such litigation is filed.

- -

All Recipient's rights under this Agreement -shall terminate if it fails to comply with any of the material terms or -conditions of this Agreement and does not cure such failure in a reasonable -period of time after becoming aware of such noncompliance. If all Recipient's -rights under this Agreement terminate, Recipient agrees to cease use and -distribution of the Program as soon as reasonably practicable. However, -Recipient's obligations under this Agreement and any licenses granted by -Recipient relating to the Program shall continue and survive.

- -

Everyone is permitted to copy and distribute -copies of this Agreement, but in order to avoid inconsistency the Agreement is -copyrighted and may only be modified in the following manner. The Agreement -Steward reserves the right to publish new versions (including revisions) of -this Agreement from time to time. No one other than the Agreement Steward has -the right to modify this Agreement. The Eclipse Foundation is the initial -Agreement Steward. The Eclipse Foundation may assign the responsibility to -serve as the Agreement Steward to a suitable separate entity. Each new version -of the Agreement will be given a distinguishing version number. The Program -(including Contributions) may always be distributed subject to the version of -the Agreement under which it was received. In addition, after a new version of -the Agreement is published, Contributor may elect to distribute the Program -(including its Contributions) under the new version. Except as expressly stated -in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to -the intellectual property of any Contributor under this Agreement, whether -expressly, by implication, estoppel or otherwise. All rights in the Program not -expressly granted under this Agreement are reserved.

- -

This Agreement is governed by the laws of the -State of New York and the intellectual property laws of the United States of -America. No party to this Agreement will bring a legal action under this -Agreement more than one year after the cause of action arose. Each party waives -its rights to a jury trial in any resulting litigation.

- -

 

- -
- - - - diff --git a/xCAT-nbroot/debian/changelog b/xCAT-nbroot/debian/changelog deleted file mode 100644 index dd1b561be..000000000 --- a/xCAT-nbroot/debian/changelog +++ /dev/null @@ -1,11 +0,0 @@ -xcat-nbroot-core (2.5.0-1) stable; urgency=low - - * Initial Debian build - - -- Mark Hamzy Fri, 29 Apr 2011 14:40:34 -0500 - -xcat-nbroot-core (2.5.0-1) stable; urgency=low - - * Initial Release - - -- OCF xCAT Mon, 25 Oct 2010 09:00:00 -0000 diff --git a/xCAT-nbroot/debian/compat b/xCAT-nbroot/debian/compat deleted file mode 100644 index 7ed6ff82d..000000000 --- a/xCAT-nbroot/debian/compat +++ /dev/null @@ -1 +0,0 @@ -5 diff --git a/xCAT-nbroot/debian/control b/xCAT-nbroot/debian/control deleted file mode 100644 index c72d11134..000000000 --- a/xCAT-nbroot/debian/control +++ /dev/null @@ -1,27 +0,0 @@ -Source: xcat-nbroot-core -Section: admin -Priority: extra -Maintainer: Arif Ali -Build-Depends: debhelper (>= 5) -Standards-Version: 3.7.2 - -Package: xcat-nbroot-core-amd64 -Architecture: all -Depends: ${perl:Depends} -Description: xCAT-nbroot-core provides opensource components of the netboot image - xcat-nbroot-core provides the xCAT scripts for the mini-root environment - All files included are as they were downloadable on 4/7/2007 - -Package: xcat-nbroot-core-x86 -Architecture: all -Depends: ${perl:Depends} -Description: xCAT-nbroot-core provides opensource components of the netboot image - xcat-nbroot-core provides the xCAT scripts for the mini-root environment - All files included are as they were downloadable on 4/7/2007 - -Package: xcat-nbroot-core-ppc64 -Architecture: all -Depends: ${perl:Depends}, yaboot-xcat -Description: xCAT-nbroot-core provides opensource components of the netboot image - xcat-nbroot-core provides the xCAT scripts for the mini-root environment - All files included are as they were downloadable on 4/7/2007 diff --git a/xCAT-nbroot/debian/copyright b/xCAT-nbroot/debian/copyright deleted file mode 100644 index f61d34dfe..000000000 --- a/xCAT-nbroot/debian/copyright +++ /dev/null @@ -1,88 +0,0 @@ -Eclipse Public License - v 1.0 - -THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. - -1. DEFINITIONS - -"Contribution" means: - -a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and -b) in the case of each subsequent Contributor: - -i) changes to the Program, and - -ii) additions to the Program; - -where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. - -"Contributor" means any person or entity that distributes the Program. - -"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. - -"Program" means the Contributions distributed in accordance with this Agreement. - -"Recipient" means anyone who receives the Program under this Agreement, including all Contributors. - -2. GRANT OF RIGHTS - -a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form. - -b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. - -c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program. - -d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. - -3. REQUIREMENTS - -A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: - -a) it complies with the terms and conditions of this Agreement; and - -b) its license agreement: - -i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; - -ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; - -iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and - -iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. - -When the Program is made available in source code form: - -a) it must be made available under this Agreement; and - -b) a copy of this Agreement must be included with each copy of the Program. - -Contributors may not remove or alter any copyright notices contained within the Program. - -Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. - -4. COMMERCIAL DISTRIBUTION - -Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. - -For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. - -5. NO WARRANTY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. - -6. DISCLAIMER OF LIABILITY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -7. GENERAL - -If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. - -If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. - -All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. - -Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. - -This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. - - diff --git a/xCAT-nbroot/debian/docs b/xCAT-nbroot/debian/docs deleted file mode 100644 index 9c734aebd..000000000 --- a/xCAT-nbroot/debian/docs +++ /dev/null @@ -1 +0,0 @@ -LICENSE.html diff --git a/xCAT-nbroot/debian/rules b/xCAT-nbroot/debian/rules deleted file mode 100755 index ce79be57f..000000000 --- a/xCAT-nbroot/debian/rules +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- -# Sample debian/rules that uses debhelper. -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -export DH_COMPAT=5 - - -build: - pwd - -clean: - dh_testdir - dh_testroot - dh_clean -d - -install: - pwd - dh_testdir - dh_testroot - dh_installdirs - dh_install -X".svn" - dh_link - - -# Build architecture-independent files here. -binary-indep: build install -# We have nothing to do by default. - -# Build architecture-dependent files here. -binary-arch: - pwd - dh_testdir - dh_testroot - dh_installchangelogs - dh_installdocs -# dh_installexamples - dh_install -X".svn" -# dh_installmenu -# dh_installdebconf -# dh_installlogrotate -# dh_installemacsen -# dh_installpam -# dh_installmime -# dh_python -# dh_installinit -# dh_installcron -# dh_installinfo - dh_installman -# dh_link -# dh_strip - dh_compress -# dh_fixperms - dh_perl - dh_makeshlibs - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/xCAT-nbroot/debian/source/format b/xCAT-nbroot/debian/source/format deleted file mode 100644 index d3827e75a..000000000 --- a/xCAT-nbroot/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -1.0 diff --git a/xCAT-nbroot/debian/xcat-nbroot-core-amd64.dirs b/xCAT-nbroot/debian/xcat-nbroot-core-amd64.dirs deleted file mode 100644 index b479d6a61..000000000 --- a/xCAT-nbroot/debian/xcat-nbroot-core-amd64.dirs +++ /dev/null @@ -1 +0,0 @@ -opt/xcat/share/xcat/netboot/x86_64/nbroot diff --git a/xCAT-nbroot/debian/xcat-nbroot-core-amd64.install b/xCAT-nbroot/debian/xcat-nbroot-core-amd64.install deleted file mode 100644 index 5807c1b6d..000000000 --- a/xCAT-nbroot/debian/xcat-nbroot-core-amd64.install +++ /dev/null @@ -1 +0,0 @@ -overlay/* opt/xcat/share/xcat/netboot/x86_64/nbroot diff --git a/xCAT-nbroot/debian/xcat-nbroot-core-amd64.postinst b/xCAT-nbroot/debian/xcat-nbroot-core-amd64.postinst deleted file mode 100644 index c0d508cda..000000000 --- a/xCAT-nbroot/debian/xcat-nbroot-core-amd64.postinst +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# postinst script for openmpi -# -# see: dh_installdeb(1) - -set -e - -# summary of how this script can be called: -# * `configure' -# * `abort-upgrade' -# * `abort-remove' `in-favour' -# -# * `abort-remove' -# * `abort-deconfigure' `in-favour' -# `removing' -# -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package - - -case "$1" in - configure) - if [ -f "/proc/cmdline" ]; then # prevent running it during install into chroot image - . /etc/profile.d/xcat.sh - mknb x86_64 - fi - ;; - - abort-upgrade|abort-remove|abort-deconfigure) - ;; - - *) - echo "postinst called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - -exit 0 diff --git a/xCAT-nbroot/debian/xcat-nbroot-core-amd64.substvars b/xCAT-nbroot/debian/xcat-nbroot-core-amd64.substvars deleted file mode 100644 index e4d74a396..000000000 --- a/xCAT-nbroot/debian/xcat-nbroot-core-amd64.substvars +++ /dev/null @@ -1,2 +0,0 @@ -misc:Depends= -perl:Depends=perl diff --git a/xCAT-nbroot/debian/xcat-nbroot-core-ppc64.dirs b/xCAT-nbroot/debian/xcat-nbroot-core-ppc64.dirs deleted file mode 100644 index 257b5f43e..000000000 --- a/xCAT-nbroot/debian/xcat-nbroot-core-ppc64.dirs +++ /dev/null @@ -1 +0,0 @@ -opt/xcat/share/xcat/netboot/ppc64/nbroot diff --git a/xCAT-nbroot/debian/xcat-nbroot-core-ppc64.install b/xCAT-nbroot/debian/xcat-nbroot-core-ppc64.install deleted file mode 100644 index a6af43ea1..000000000 --- a/xCAT-nbroot/debian/xcat-nbroot-core-ppc64.install +++ /dev/null @@ -1 +0,0 @@ -overlay/* opt/xcat/share/xcat/netboot/ppc64/nbroot diff --git a/xCAT-nbroot/debian/xcat-nbroot-core-ppc64.postinst b/xCAT-nbroot/debian/xcat-nbroot-core-ppc64.postinst deleted file mode 100644 index d247b154e..000000000 --- a/xCAT-nbroot/debian/xcat-nbroot-core-ppc64.postinst +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# postinst script for openmpi -# -# see: dh_installdeb(1) - -set -e - -# summary of how this script can be called: -# * `configure' -# * `abort-upgrade' -# * `abort-remove' `in-favour' -# -# * `abort-remove' -# * `abort-deconfigure' `in-favour' -# `removing' -# -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package - - -case "$1" in - configure) - if [ -f "/proc/cmdline" ]; then # prevent running it during install into chroot image - . /etc/profile.d/xcat.sh - mknb ppc64 - fi - ;; - - abort-upgrade|abort-remove|abort-deconfigure) - ;; - - *) - echo "postinst called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - -exit 0 diff --git a/xCAT-nbroot/debian/xcat-nbroot-core-ppc64.substvars b/xCAT-nbroot/debian/xcat-nbroot-core-ppc64.substvars deleted file mode 100644 index e4d74a396..000000000 --- a/xCAT-nbroot/debian/xcat-nbroot-core-ppc64.substvars +++ /dev/null @@ -1,2 +0,0 @@ -misc:Depends= -perl:Depends=perl diff --git a/xCAT-nbroot/debian/xcat-nbroot-core-x86.dirs b/xCAT-nbroot/debian/xcat-nbroot-core-x86.dirs deleted file mode 100644 index c70a89b4a..000000000 --- a/xCAT-nbroot/debian/xcat-nbroot-core-x86.dirs +++ /dev/null @@ -1 +0,0 @@ -opt/xcat/share/xcat/netboot/x86/nbroot diff --git a/xCAT-nbroot/debian/xcat-nbroot-core-x86.install b/xCAT-nbroot/debian/xcat-nbroot-core-x86.install deleted file mode 100644 index cabfbc1d6..000000000 --- a/xCAT-nbroot/debian/xcat-nbroot-core-x86.install +++ /dev/null @@ -1 +0,0 @@ -overlay/* opt/xcat/share/xcat/netboot/x86/nbroot diff --git a/xCAT-nbroot/debian/xcat-nbroot-core-x86.postinst b/xCAT-nbroot/debian/xcat-nbroot-core-x86.postinst deleted file mode 100644 index 76ba3d6bb..000000000 --- a/xCAT-nbroot/debian/xcat-nbroot-core-x86.postinst +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# postinst script for openmpi -# -# see: dh_installdeb(1) - -set -e - -# summary of how this script can be called: -# * `configure' -# * `abort-upgrade' -# * `abort-remove' `in-favour' -# -# * `abort-remove' -# * `abort-deconfigure' `in-favour' -# `removing' -# -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package - - -case "$1" in - configure) - if [ -f "/proc/cmdline" ]; then # prevent running it during install into chroot image - . /etc/profile.d/xcat.sh - mknb x86 - fi - ;; - - abort-upgrade|abort-remove|abort-deconfigure) - ;; - - *) - echo "postinst called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - -exit 0 diff --git a/xCAT-nbroot/debian/xcat-nbroot-core-x86.substvars b/xCAT-nbroot/debian/xcat-nbroot-core-x86.substvars deleted file mode 100644 index e4d74a396..000000000 --- a/xCAT-nbroot/debian/xcat-nbroot-core-x86.substvars +++ /dev/null @@ -1,2 +0,0 @@ -misc:Depends= -perl:Depends=perl diff --git a/xCAT-nbroot/overlay/bin/allowcred.awk b/xCAT-nbroot/overlay/bin/allowcred.awk deleted file mode 100755 index 341138d3e..000000000 --- a/xCAT-nbroot/overlay/bin/allowcred.awk +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/awk -f -BEGIN { - listener = "/inet/tcp/300/0/0" - quit = "no" - - - while (match(quit,"no")) { - while ((listener |& getline) > 0) { - if (match($0,"CREDOKBYYOU?")) { - print "CREDOKBYME" |& listener - } - } - close(listener) - } -} diff --git a/xCAT-nbroot/overlay/bin/bmcsetup b/xCAT-nbroot/overlay/bin/bmcsetup deleted file mode 100755 index 81cf9a2df..000000000 --- a/xCAT-nbroot/overlay/bin/bmcsetup +++ /dev/null @@ -1,290 +0,0 @@ -# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html -# -# Raw commands to set BMCs to defaults -# dx320 -# 0x2e 0x10 0x4d 0x4f 0x00 0xff -# -# dx340 -# 0x30 0x13 0xff 0x00 0x00 0x00 -# -# dx360/x3450 -# 0x30 0x02 0x43 0x4c 0x52 0xaa -# 0x08 0x00 0x49 0x4e 0x54 0x45 0x4c -# 0x08 0x04 -# -allowcred.awk & -CREDPID=$! -sleep 2 -modprobe ipmi_si -modprobe ipmi_devintf -while [ -z "$BMCIP" ]; do - while ! getipmi - do - echo "Retrying retrieval of IPMI settings from server" - done - TIMEOUT=15 - BMCIP=`grep bmcip /tmp/ipmi.data |awk -F\> '{print $2}'|awk -F\< '{print $1}'` - BMCGW=`grep gateway /tmp/ipmi.data |awk -F\> '{print $2}'|awk -F\< '{print $1}'` - BMCNM=`grep netmask /tmp/ipmi.data |awk -F\> '{print $2}'|awk -F\< '{print $1}'` - BMCUS=`grep username /tmp/ipmi.data |awk -F\> '{print $2}'|awk -F\< '{print $1}'` - BMCPW=`grep password /tmp/ipmi.data |awk -F\> '{print $2}'|awk -F\< '{print $1}'` - if [ -z "$BMCIP" ]; then - echo "FAILED TO RETRIEVE SETTINGS, RETRYING in 15 seconds" - sleep 15 - fi -done -kill $CREDPID -NUMBMCS=`grep bmcip /tmp/ipmi.data |awk -F\> '{print $2}'|awk -F\< '{print $1}'|wc -l` -IPMIVER=`ipmitool mc info|grep ^IPMI|awk '{print $4}'` -IPMIMFG=`ipmitool mc info|grep "^Manufacturer ID"|awk '{print $4}'` -if [ "$IPMIMFG" == 2 ]; then #IBM - XPROD=`ipmitool mc info|grep "^Product ID"|awk '{print $4}'` - if [ "$XPROD" == "220" ]; then - LOCKEDUSERS=1 - BMCPORT=`grep bmcport /tmp/ipmi.data |awk -F\> '{print $2}'|awk -F\< '{print $1}'` - if [ ! -z "$BMCPORT" ]; then - let idev=NUMBMCS-1 - for p in $BMCPORT; do - ipmitool -d $idev raw 0xc 1 1 0xc0 $p > /dev/null - ipmitool -d $idev raw 0x04 0x12 0x09 0x01 0x18 0x${p}1 0x00 > /dev/null - let idev=idev-1 - done - fi - else - IBMFAM=`ipmitool raw 0x3a 0x50 |head -n 1| awk '{print $1 $2 $3 $4}'` - if [ "$IBMFAM" == "59554f4f" ]; then - BMCPORT=`grep bmcport /tmp/ipmi.data |awk -F\> '{print $2}'|awk -F\< '{print $1}'` - if [ ! -z "$BMCPORT" ]; then - let idev=NUMBMCS-1 - for p in $BMCPORT; do - ipmitool -d $idev raw 0xc 1 1 0xc0 $BMCPORT > /dev/null - let idev=idev-1 - done - fi - fi - fi -elif [ "$IPMIMFG" == 20301 ] ; then - XPROD=`ipmitool mc info|grep "^Product ID"|awk '{print $4}'` - if [ "$XPROD" == "220" ]; then - LOCKEDUSERS=1 - BMCPORT=`grep bmcport /tmp/ipmi.data |awk -F\> '{print $2}'|awk -F\< '{print $1}'` - if [ ! -z "$BMCPORT" ]; then - let idev=NUMBMCS-1 - for p in $BMCPORT; do - ipmitool -d $idev raw 0xc 1 1 0xc0 $BMCPORT > /dev/null - let idev=idev-1 - done - fi - fi -fi -echo -n "Auto detecting LAN channel..." - -for LANCHAN in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do - if ipmitool channel info $LANCHAN 2> /dev/null | grep 802.3 > /dev/null 2>&1 && ipmitool raw 0xc 2 $LANCHAN 5 0 0 > /dev/null 2>&1; - then break; - fi; - echo -n "." -done -echo "Detected LAN channel $LANCHAN" - -let idev=NUMBMCS -while [ $idev -gt 0 ]; do - let idev=idev-1 - TRIES=0 - while ! ipmitool -d $idev lan set $LANCHAN ipsrc static; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done -done -let idev=NUMBMCS-1 -for b in $BMCIP; do - TRIES=0 - while ! ipmitool -d $idev lan set $LANCHAN ipaddr $b; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done - let idev=idev-1 -done -let idev=NUMBMCS-1 -for m in $BMCNM; do - TRIES=0 - while ! ipmitool -d $idev lan set $LANCHAN netmask $m; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done - let idev=idev-1 -done -TRIES=0 -if [ ! -z "$BMCGW" ]; then - let idev=NUMBMCS-1 - for g in $BMCGW; do - TRIES=0 - while ! ipmitool -d $idev lan set $LANCHAN defgw ipaddr $g; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done - let idev=idev-1 - done - TRIES=0 -fi -let idev=NUMBMCS-1 -for bmcu in $BMCUS; do -DISABLEUSERS="1 2 3 4" -if [ ! -z "$LOCKEDUSERS" ]; then - USERSLOT=`ipmitool -d $idev user list $LANCHAN |grep -v ^ID|awk '{print $1 " " $2}'|grep " $BMCUS"|awk '{print $1}'` - if [ -z "$USERSLOT" ]; then - USERSLOT=4 - fi -else - USERSLOT=2 -fi -CURRENTUSER=`ipmitool -d $idev user list $LANCHAN|grep ^$USERSLOT|awk '{print $2}'` -DISABLEUSERS=`echo 1 2 3 4|sed -e s/$USERSLOT//` -for user in $DISABLEUSERS; do - while ! ipmitool -d $idev user disable $user; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done - TRIES=0 -done -TRIES=0 -while ! ipmitool -d $idev user enable $USERSLOT; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi -done -TRIES=0 -# Last param in ipmitool user priv is the channel to set it on. -# Penguin boxes are all channel 2 -CURRPRIV=`ipmitool -d $idev user list 1|grep ^$USERSLOT|awk '{print $6}'` -if [ "$CURRPRIV" != "ADMINISTRATOR" ]; then - while ! ipmitool -d $idev user priv $USERSLOT 4 $LANCHAN; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done - TRIES=0 -fi -if [ "$CURRENTUSER" != "$bmcu" ]; then - while ! ipmitool -d $idev user set name $USERSLOT $bmcu; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done -fi -let idev=idev-1 -done -let idev=NUMBMCS-1 -for bmcp in $BMCPW; do -TRIES=0 -while ! ipmitool -d $idev user set password $USERSLOT $bmcp; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi -done -TRIES=0 -echo "Set up following user table: " -ipmitool -d $idev user list $LANCHAN -let idev=idev-1 -done - -let idev=NUMBMCS -while [ $idev -gt 0 ]; do -let idev=idev-1 - - -echo -n "Enabling Channel $LANCHAN: " -while ! ipmitool -d $idev raw 0x6 0x40 $LANCHAN 0x42 0x44 > /dev/null; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi -done -TRIES=0 -while ! ipmitool -d $idev raw 0x6 0x40 $LANCHAN 0x82 0x84 > /dev/null; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi -done -if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi -TRIES=0 - -echo -n "Enabling ARP responses: " -while ! ipmitool -d $idev lan set $LANCHAN arp respond on > /dev/null; do - sleep 1 - let TRIES=TRIES+1 - echo -n . - if [ $TRIES -gt $TIMEOUT ]; then break; fi -done -if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi -TRIES=0 - -echo -n "Enabling IPMI v 1.5 MD5 LAN access:" -while ! ipmitool -d $idev lan set $LANCHAN auth admin md5 > /dev/null; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi -done -if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi -TRIES=0 -if [ ! "$IPMIVER" == "1.5" ]; then - echo -n "Enabling IPMI v 2.0 LAN access:" - SUPPORTEDSUITES=`ipmitool -d $idev lan print $LANCHAN|grep Suites|awk -F: '{print $2}'|sed -e 's/ 0//'` - PRIVS="X" - for priv in 1 2 3 4 5 6 7 8 9 10 11 12 13 14; do - if echo $SUPPORTEDSUITES|grep $priv > /dev/null; then - PRIVS="$PRIVS"a - else - PRIVS="$PRIVS"X - fi - done - while ! ipmitool -d $idev lan set $LANCHAN cipher_privs $PRIVS > /dev/null; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done - if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi - TRIES=0 - - echo -n "Enabling SOL for channel $LANCHAN:" - while ! ipmitool -d $idev raw 0xc 0x21 $LANCHAN 0x1 0x1 > /dev/null; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done - if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi - TRIES=0 - - echo -n "Enabling SOL for $BMCUS:" - while ! ipmitool -d $idev raw 6 0x4c $LANCHAN $USERSLOT 2 0 0 0 > /dev/null; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done - if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi - echo -n "Putting SOL on channel $LANCHAN:" - while ! OUTPUT=`ipmitool -d $idev raw 0xc 0x21 $LANCHAN 7 $LANCHAN 2>&1 > /dev/null`; do - if echo $OUTPUT|grep "Unknown (0x80)" > /dev/null; then - echo "Not Needed" - break - fi - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done - if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi -fi - -#frume.awk - -echo "Lighting Identify Light" -while : - do ipmitool -d $idev raw 0 4 10 > /dev/null - sleep 7 -done & -done - diff --git a/xCAT-nbroot/overlay/bin/dodestiny b/xCAT-nbroot/overlay/bin/dodestiny deleted file mode 100755 index a04ab69dd..000000000 --- a/xCAT-nbroot/overlay/bin/dodestiny +++ /dev/null @@ -1,195 +0,0 @@ -#!/bin/sh -# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html -if dmidecode|grep Vendor|grep QEMU; then #for now, reboot - IAMAVM=1 -fi -if dmidecode|grep VMware; then #for now, reboot - IAMAVM=1 -fi -if dmidecode|grep "Product Name: KVM"; then #for now, reboot - IAMAVM=1 -fi -for parm in `cat /proc/cmdline`; do - key=`echo $parm|awk -F= '{print $1}'` - if [ "$key" == "xcatd" ]; then - XCATDEST=`echo $parm|awk -F= '{print $2}'` - fi -done -export XCATPORT=3001 -if [ ! -z "$XCATDEST" ]; then - export XCATMASTER=`echo $XCATDEST | awk -F: '{print $1}'` - export XCATPORT=`echo $XCATDEST | awk -F: '{print $2}'` -fi - -while :; do - DESTINY=`grep destiny /tmp/destiny | awk -F'>' '{print $2}'|awk -F'<' '{print $1}'` - DEST=`echo $DESTINY|awk -F= '{print $1}'` #No bash, no tricks - TARG=`echo $DESTINY|awk -F= '{print $2}'` #No bash, no tricks - DESTINY=`echo $DESTINY|awk '{print $1}'` #No bash, no tricks - if [ "$DESTINY" == "standby" ]; then - echo "Server notified us of standby condition, please check chain table". - let STSLEEP=15+$RANDOM%15 - echo "Retrying destiny in $STSLEEP seconds" - sleep $STSLEEP # something may be transiently wrong, check back in 15 seconds - while ! getdestiny; do - echo "Retrying destiny retrieval" - let RTSLEEP=$RANDOM%5 - sleep $RTSLEEP - done - exec /bin/dodestiny - fi - if [ "$DESTINY" == "shell" ]; then - echo "Server notified us to stay in shell state, stopping destiny requests" - while :; do /bin/sh; done #exit - fi - if [ "$DESTINY" == "discover" ]; then - echo "MAC discovery begins" - minixcatd.awk & - sleep 1 #Mitigate occurrances of 'failed to notify node' - while [ ! -r /restart ]; do - let myr=$RANDOM%10 - sleep $myr #Stagger discovery requests from many nodes - ifconfig -a|grep HWaddr|grep -v sit|awk '{print $1 "|" $5}' - sleep 1 - MTM="unknown" - SERIAL="unknown" - ARCH="unknown" - if uname -m | grep i686 > /dev/null || uname -m | grep x86_64 > /dev/null; then - if grep ^flags /proc/cpuinfo |head -n 1|grep " lm " > /dev/null; then - ARCH=x86_64 - else - ARCH=x86 - fi - else - ARCH=`uname -m` - fi - - if [ -x /bin/vpddecode ]; then - MTM=`(/bin/vpddecode|grep Type || echo "unknown unknown: unknown")|awk '{print $3}'` - SERIAL=`(/bin/vpddecode|grep "Box Serial" || echo "unknown unknown unknown: unknown")|awk '{print $4}'` - fi - if [ "$MTM" == "unknown" -a -x /bin/dmidecode ]; then #This gets a bit hackish... iDataplex - MTM=`dmidecode |grep -A4 "^System Information"|grep "Product Name"|awk -F'[' '{print $2}'|awk -F']' '{print $1}'|head -n 1|sed -e 's/^ //'` - SERIAL=`dmidecode |grep -A4 "^System Information"|grep "Serial Number"|awk -F: '{print $2}'|head -n 1|sed -e 's/^ //'` - fi - if [ -r /proc/device-tree/model ]; then - MTM=`cat /proc/device-tree/model |awk -F, '{print $2}'` - fi - ( - echo "" - echo "findme" - echo "$ARCH" - if [ ! -z "$IAMAVM" ]; then - echo "virtual" - fi - for i in `ifconfig -a|grep HWaddr|grep -v sit|awk '{print $1 "|" $5}'`; do - IFACE=`echo $i|awk -F'|' '{print $1}'` - DRIVER=`ethtool -i $IFACE|grep ^driver|awk '{print $2}'` - ADDRESS=`ip address show dev $IFACE|grep 'inet '|awk '{print $2}'` - echo "$DRIVER|$i|$ADDRESS" - done - modprobe ipmi_devintf - if modprobe ipmi_si; then - echo "bmc|bmc|"`ipmitool lan print 1|grep ^MAC|awk '{print $4}'`"" - fi - rmmod ipmi_si - rmmod ipmi_devintf - if [ "$MTM" != "unknown" ]; then - echo "$MTM" - fi - if [ "$SERIAL" != "unknown" ]; then - echo "$SERIAL" - fi - echo "" ) > /tmp/discout - if [ ! -z "$XCATMASTER" ]; then - ping -c 1 $XCATMASTER - cat /tmp/discout | udpcat.awk $XCATMASTER $XCATPORT & #can't figure out how to make a hung gawk behave.. - fi - if [ -z "$XCATMASTER" ] || sleep 8 > /dev/null 2>&1 #Give the preferred method 8 seconds to complete before resorting - then - #if sleep succeeded, that means it wasn't killed and therefore, no answer yet - killall udpcat.awk > /dev/null 2>&1 #reap hung ones - for nic in `ifconfig -a|grep HWaddr|grep -v sit|awk '{print $1}'`; do #also, bring down interfaces to make sure that we send from the 'right' nic - MYB=`ifconfig $nic|grep "Bcast"|awk '{print $3}'|awk -F: '{print $2}'` - for dnic in `ifconfig -a|grep HWaddr|grep -v sit|awk '{print $1}'|grep -v $nic`; do - OTB=`ifconfig $dnic|grep "Bcast"|awk '{print $3}'|awk -F: '{print $2}'` - if [ ! -z "$MYB" -a "$OTB" == "$MYB" ]; then # if broadcasts match, down the other nic - ifconfig $dnic down - fi - done - if [ ! -z "$XCATMASTER" ]; then - (ping -c 1 $XCATMASTER - cat /tmp/discout | udpcat.awk $XCATMASTER $XCATPORT ) & #can't figure out how to make a hung gawk behave.. - fi - for dhcps in `cat /tmp/dhcpserver`; do - ( ping -c 1 $dhcps - cat /tmp/discout | udpcat.awk $dhcps $XCATPORT )& - done - for dnic in `ifconfig -a|grep HWaddr|grep -v sit|awk '{print $1}'|grep -v $nic`; do - ifconfig $dnic up - done - if ! sleep 5 > /dev/null 2>&1; then break; fi # give management server a chance to get to minixcatd.awk - done - fi - killall udpcat.awk > /dev/null 2>&1 #reap hung ones - done - #Discovery complete, restart requested. - exec /bin/restart - fi - if [ "$DESTINY" == "reboot" -o "$DESTINY" == "boot" ]; then - while ! nextdestiny ; do - echo "Retrying next destiny..." - done - /bin/rebootnode - fi - if [ "$DEST" == "runcmd" ]; then - while ! nextdestiny ; do - echo "Retrying next destiny..." - done - $TARG - fi - if [ "$DESTINY" == "install" -o "$DESTINY" == "netboot" ]; then - /bin/rebootnode #If script is here, kexec failed, reboot in case it wasn't a linux kernel and let the boot loader handle it instead - IMGSERVER=`grep imgserver /tmp/destiny | awk -F'>' '{print $2}'|awk -F'<' '{print $1}'` - INITRD=`grep initrd /tmp/destiny | awk -F'>' '{print $2}'|awk -F'<' '{print $1}'` - KERNEL=`grep kernel /tmp/destiny | awk -F'>' '{print $2}'|awk -F'<' '{print $1}'` - KCMD=`grep kcmdline /tmp/destiny | awk -F'>' '{print $2}'|awk -F'<' '{print $1}'` - ERROR=`wget http://$IMGSERVER/tftpboot/$KERNEL -O /tmp/kernel 2>&1` - while [ $? == 1 ] && echo $ERROR|grep -v 416; do - sleep 10 - ERROR=`wget -c http://$IMGSERVER/tftpboot/$KERNEL -O /tmp/kernel 2>&1` - done - ERROR=`wget -c http://$IMGSERVER/tftpboot/$INITRD -O /tmp/initrd 2>&1` - while [ $? == 1 ] && echo $ERROR|grep -v 416; do - sleep 10 - ERROR=`wget -c http://$IMGSERVER/tftpboot/$INITRD -O /tmp/initrd 2>&1` - done - #START getting ready for kexec - for mod in `lsmod|awk '{print $1}'|grep -v Module`; do - rmmod $mod - done - #kexec -f --append="$KCMD" --initrd=/tmp/initrd /tmp/kernel - /bin/rebootnode #If script is here, kexec failed, reboot in case it wasn't a linux kernel and let the boot loader handle it instead - fi - if [ "$DEST" == "runimage" ]; then - mkdir /tmp/`basename $TARG` - cd /tmp/`basename $TARG` - ERROR=`wget $TARG` - while [ $? == 1 ] && echo $ERROR|grep -v 416; do - sleep 10 - ERROR=`wget -c $TARG 2>&1` - done - while ! nextdestiny ; do - echo "Retrying next destiny..." - done - tar zxvf `basename $TARG` - cd /tmp/`basename $TARG` - ./runme.sh - cd - - fi - sleep 5 # something may be transiently wrong, check back in 5 seconds - getdestiny - if grep error /tmp/destiny; then - echo ERROR: see above - fi -done diff --git a/xCAT-nbroot/overlay/bin/frume.awk b/xCAT-nbroot/overlay/bin/frume.awk deleted file mode 100755 index 09090bcec..000000000 --- a/xCAT-nbroot/overlay/bin/frume.awk +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/awk -f -# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html -BEGIN { - localport = ARGV[1] - ns = "/inet/tcp/0/127.0.0.1/" localport - canexit = 0 - - print "" |& ns - print "rewritemyfru" |& ns - print "" |& ns - - while (1) { - if ((ns |& getline) > 0) { - print $0 > "/tmp/fru.status" - if ($0 ~ /<\/serverdone>/) - canexit = 1 - if (canexit == 1 && $0 == "") - break - } else { - close(ns) - exit 1 - } - } - close(ns) - exit 0 -} diff --git a/xCAT-nbroot/overlay/bin/getdestiny b/xCAT-nbroot/overlay/bin/getdestiny deleted file mode 100644 index 11dea4b40..000000000 --- a/xCAT-nbroot/overlay/bin/getdestiny +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -if ! getdestiny.awk 301 > /dev/null 2>&1; then - let i=400 - for srv in `cat /tmp/dhcpserver`; do - if getdestiny.awk $i > /dev/null 2>&1; then - exit - fi - let i=i+1 - done -fi diff --git a/xCAT-nbroot/overlay/bin/getdestiny.awk b/xCAT-nbroot/overlay/bin/getdestiny.awk deleted file mode 100755 index df58c12e9..000000000 --- a/xCAT-nbroot/overlay/bin/getdestiny.awk +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/awk -f -# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html -BEGIN { - localport = ARGV[1] - ns = "/inet/tcp/0/127.0.0.1/" localport - canexit = 0 - - print "" |& ns - print "getdestiny" |& ns - print "" |& ns - - while (1) { - if ((ns |& getline) > 0) { - print $0 > "/tmp/destiny" - if ($0 ~ /<\/serverdone>/) - canexit = 1 - if (canexit == 1 && $0 == "") - break - } else { #Timeout - close(ns) - exit 1 - } - } - close(ns) - exit 0 -} diff --git a/xCAT-nbroot/overlay/bin/getipmi b/xCAT-nbroot/overlay/bin/getipmi deleted file mode 100644 index 0f50d4349..000000000 --- a/xCAT-nbroot/overlay/bin/getipmi +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -if ! getipmi.awk 301 > /dev/null 2>&1; then - let i=400 - for srv in `cat /tmp/dhcpserver`; do - if getipmi.awk $i > /dev/null 2>&1 ; then - while grep '' /tmp/ipmi.data; do - echo "ERROR RETRIEVING BMC CONFIGURATION, CHECK SERVER LOGS AND TABLES!"; - let sleepy=$RANDOM%60+60 - echo "Retrying in $sleepy seconds" - sleep $sleepy - getipmi.awk $i - done - exit - fi - let i=i+1 - done -fi -while grep '' /tmp/ipmi.data; do - echo "ERROR RETRIEVING BMC CONFIGURATION, CHECK SERVER LOGS AND TABLES!"; - let sleepy=$RANDOM%60+60 - echo "Retrying in $sleepy seconds" - sleep $sleepy - getipmi.awk 301 -done diff --git a/xCAT-nbroot/overlay/bin/getipmi.awk b/xCAT-nbroot/overlay/bin/getipmi.awk deleted file mode 100755 index 57778ca08..000000000 --- a/xCAT-nbroot/overlay/bin/getipmi.awk +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/awk -f -# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html -BEGIN { - localport = ARGV[1] - ns = "/inet/tcp/0/127.0.0.1/" localport - canexit = 0 - - print "" |& ns - print "getbmcconfig" |& ns - print "" |& ns - - while (1) { - if ((ns |& getline) > 0) { - print $0 > "/tmp/ipmi.data" - if ($0 ~ /<\/serverdone>/) - canexit = 1 - if (canexit == 1 && $0 == "") - break - } else { - close(ns) - exit 1 - } - } - close(ns) - exit 0 -} diff --git a/xCAT-nbroot/overlay/bin/minixcatd.awk b/xCAT-nbroot/overlay/bin/minixcatd.awk deleted file mode 100755 index ef0352ded..000000000 --- a/xCAT-nbroot/overlay/bin/minixcatd.awk +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/awk -f -# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html -BEGIN { - port = 3001 - listener = "/inet/tcp/" port "/0/0" - quit = "no" - while (match(quit,"no")) { - while (match(quit,"no") && (listener |& getline) > 0) { - if (match($0,"restart")) { - print "restarting bootstrap process" |& listener - quit="yes" - system("echo \"" $0 "\" > /restart") - system("killall sleep") - close(listener) - } - } - close(listener) - } -} diff --git a/xCAT-nbroot/overlay/bin/nextdestiny b/xCAT-nbroot/overlay/bin/nextdestiny deleted file mode 100755 index 9f3e27a1e..000000000 --- a/xCAT-nbroot/overlay/bin/nextdestiny +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -if ! nextdestiny.awk 301 > /dev/null 2>&1 ; then - let i=400 - for srv in `cat /tmp/dhcpserver`; do - if nextdestiny.awk $i > /dev/null 2>&1 ; then - exit - fi - let i=i+1 - done -fi diff --git a/xCAT-nbroot/overlay/bin/nextdestiny.awk b/xCAT-nbroot/overlay/bin/nextdestiny.awk deleted file mode 100755 index 5488b2293..000000000 --- a/xCAT-nbroot/overlay/bin/nextdestiny.awk +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/awk -f -# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html -BEGIN { - localport = ARGV[1] - ns = "/inet/tcp/0/127.0.0.1/" localport - canexit = 0 - - print "" |& ns - print "nextdestiny" |& ns - print "" |& ns - - while (1) { - if ((ns |& getline) > 0) { - print $0 > "/tmp/destiny" - if ($0 ~ /<\/serverdone>/) - canexit = 1 - if (canexit == 1 && $0 == "") - break - } else { - close(ns) - exit 1 - } - } - close(ns) - exit 0 -} diff --git a/xCAT-nbroot/overlay/bin/rebootnode b/xCAT-nbroot/overlay/bin/rebootnode deleted file mode 100755 index 92f5f5ec6..000000000 --- a/xCAT-nbroot/overlay/bin/rebootnode +++ /dev/null @@ -1,6 +0,0 @@ -for udhcpc in `ps axf|grep -i udhcpc|grep -v grep|awk '{print $1}'`; do - kill -USR2 $udhcpc -done -sleep 5 -reboot -f - diff --git a/xCAT-nbroot/overlay/bin/restart b/xCAT-nbroot/overlay/bin/restart deleted file mode 100755 index 6e1bcd790..000000000 --- a/xCAT-nbroot/overlay/bin/restart +++ /dev/null @@ -1,38 +0,0 @@ -# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html -#Redhcp, do the xcat part again -FORCENICS=`cat /restart|awk '{print $2}'` -rm /restart -echo -n > /tmp/dhcpserver -if [ ! -z "$FORCENICS" ]; then - echo "Forcing down nics aside from $FORCENICS due to discoverynics setting" - kill `ps axf|grep udhcpc|egrep -v "$FORCENICS"|grep -v grep|awk '{print $1}'` - for nic in `ifconfig|grep HWaddr|awk '{print $1}'|egrep -v "$FORCENICS"`; do - ifconfig $nic down - done -fi -WAITING=1 -while [ $WAITING -gt 0 ]; do - killall -12 udhcpc;killall -10 udhcpc - echo -n "Waiting 10 seconds for DHCP changes to take effect " - for i in 1 2 3 4 5 6 7 8 9 10; do - sleep 1 - echo -n . - done - WAITING=0 - if [ ! -z "$FORCENICS" ]; then - for nic in `ifconfig|grep HWaddr|awk '{print $1}'|egrep "$FORCENICS"`; do - if ! ifconfig $nic|grep "inet addr" > /dev/null; then - WAITING=1 - fi - done - if [ $WAITING -gt 0 ]; then - echo -n "Not all of the nics $FORCENICS managed to acquire an address, retrying in 30 seconds..." - sleep 30 - echo "now retrying" - fi - fi -done - -echo "Done waiting" -/etc/init.d/S11stunnel #redo stunnel config -exec /etc/init.d/S99xcat.sh diff --git a/xCAT-nbroot/overlay/bin/udpcat.awk b/xCAT-nbroot/overlay/bin/udpcat.awk deleted file mode 100755 index 6a3c2c166..000000000 --- a/xCAT-nbroot/overlay/bin/udpcat.awk +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/awk -f -# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html -BEGIN { - xcatdport = ARGV[2] - xcatdhost = ARGV[1] - delete ARGV[1] - delete ARGV[2] - RS="" -} -END { - print $0 |& "/inet/udp/301/"xcatdhost"/"xcatdport -} diff --git a/xCAT-nbroot/overlay/etc/init.d/S10autodetect b/xCAT-nbroot/overlay/etc/init.d/S10autodetect deleted file mode 100755 index 6fcdc791d..000000000 --- a/xCAT-nbroot/overlay/etc/init.d/S10autodetect +++ /dev/null @@ -1,122 +0,0 @@ -#!/bin/sh -# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html -nic=0 -hba=0 - -MOD="" -NICSTOWAIT="" -touch /etc/motd -echo "cat /etc/motd" >> /etc/profile - -#Load common usb drivers -modprobe ohci-hcd -modprobe uhci-hcd -modprobe ehci-hcd - - -for d in /proc/sys/net/ipv4/conf/*; do - echo 1 > $d/arp_filter - echo 1 > $d/arp_ignore -done -for i in $(lspci -n | awk '{print $1 "%" $3}') -do - PCI=$(echo $i | awk -F% '{print $1}') - VID="0x0000$(echo $i | awk -F% '{print $2}' |awk -F: '{print $1}')" - DID="0x0000$(echo $i | awk -F% '{print $2}' |awk -F: '{print $2}')" - if egrep "^[^ ]*[ ]*$VID[ ]*$DID" /lib/modules/`uname -r`/modules.pcimap >/dev/null - then - TYPE=$( - lspci | \ - grep "^$PCI " | \ - awk '{print $2}' | \ - tr '[A-Z]' '[a-z]' - ) - DESC=$( - lspci | \ - grep "^$PCI " | \ - awk -F: '{print $3}' | \ - sed 's/^ *//' - ) - MOD=$( - egrep "^[^ ]*[ ]*$VID[ ]*$DID" /lib/modules/`uname -r`/modules.pcimap | \ - head -1 | \ - awk '{print $1}' | \ - tr -d '"' - ) - case "$TYPE" in - ethernet|network) - echo "Found ($MOD) $DESC" - GOTNIC=1 - if [ "$MOD" = "gm" ] - then - echo "alias myri0 $MOD" - echo "alias myri0 $MOD" >>/etc/modules.conf - echo "alias myri0 $MOD" >>/etc/modprobe.conf - else - modprobe $MOD - if [ "mlx4_core" = "$MOD" ]; then - modprobe mlx4_en - fi - fi - ;; - scsi|raid) - echo "Found ($MOD) $DESC" - GOTHBA=1 - modprobe $MOD & #We background so that messed up SANs don't stop shell - modprobe sd_mod - modprobe scsi_mod - hba=$(($hba + 1)) - ;; - *) - continue - ;; - esac - fi -done -NEEDVETH=0; -for dir in /proc/device-tree/vdevice/l-lan*; do - if [ -d $dir ]; then NEEDVETH=1; fi -done -if [ $NEEDVETH = 1 ]; then - modprobe ibmveth -fi -NEEDEHEA=0; -for dir in /proc/device-tree/lhea*; do - if [ -d $dir ]; then NEEDEHEA=1; fi -done -if [ $NEEDEHEA = 1 ]; then - modprobe ehea -fi - -NICSTOWAIT=`/sbin/ifconfig -a|grep HWaddr|grep ^eth|sed -e 's/ .*//'` -for nic in $NICSTOWAIT; do - ifconfig $nic up - udhcpc -i $nic -R & -done - - - -extrat=0 -until [ $extrat = 80 -o -z "$NICSTOWAIT" ]; do - sleep 1 - extrat=$(($extrat+1)) - for nic in $NICSTOWAIT; do - if ifconfig $nic|grep "inet addr"; then - NICSTOWAIT=`echo $NICSTOWAIT|sed -e s/$nic//` - if [ $extrat -gt 45 ]; then - echo "Warning: $nic took more than 45 seconds to receive DHCP reply, spanning-tree may not be configured well, examine switch configuration" >> /etc/motd - echo "Warning: $nic took more than 45 seconds to receive DHCP reply, spanning-tree may not be configured well, examine switch configuration" - fi - elif [ $extrat = 15 ]; then - if ethtool $nic | grep "Link detected: no"; then - echo "$nic did not have any link when bringing up network" - echo "$nic did not have any link when bringing up network" >> /etc/motd - NICSTOWAIT=`echo $NICSTOWAIT|sed -e s/$nic//` - fi - fi - done -done -if [ ! -z "$NICSTOWAIT" ]; then - echo "Warning: the following network devices appeared to be connected to networks, but received no DHCP response: $NICSTOWAIT" >> /etc/motd - echo "Warning: the following network devices appeared to be connected to networks, but received no DHCP response: $NICSTOWAIT" -fi diff --git a/xCAT-nbroot/overlay/etc/init.d/S11stunnel b/xCAT-nbroot/overlay/etc/init.d/S11stunnel deleted file mode 100755 index 8b4b7ed03..000000000 --- a/xCAT-nbroot/overlay/etc/init.d/S11stunnel +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html -#Stunnel init for xcat: -XCATDEST="" -XCATPORT=3001 -killall stunnel > /dev/null 2>&1 -for parm in `cat /proc/cmdline`; do - key=`echo $parm|awk -F= '{print $1}'` - if [ "$key" = "xcatd" ]; then - XCATDEST=`echo $parm|awk -F= '{print $2}'` - XCATPORT=`echo $XCATDEST|awk -F: '{print $2}'` - fi -done -mkdir -p /etc/stunnel -echo 'client=yes' > /etc/stunnel/stunnel.conf -echo 'foreground=yes' >> /etc/stunnel/stunnel.conf -echo 'output=/dev/null' >> /etc/stunnel/stunnel.conf -echo 'verify=0' >> /etc/stunnel/stunnel.conf -if [ ! -z "$XCATDEST" ]; then - echo '[xcatds]' >> /etc/stunnel/stunnel.conf - echo 'accept=127.0.0.1:301' >> /etc/stunnel/stunnel.conf - echo 'connect='$XCATDEST >> /etc/stunnel/stunnel.conf -fi -if [ -r /tmp/dhcpserver ]; then - i=400; - for srv in `cat /tmp/dhcpserver`; do - echo "[xcatd$i]" >> /etc/stunnel/stunnel.conf - echo "accept=127.0.0.1:$i" >> /etc/stunnel/stunnel.conf - echo "connect="$srv":"$XCATPORT >> /etc/stunnel/stunnel.conf - i=$(($i+1)) - done -fi -mkdir -p /usr/var/run/stunnel -stunnel & -sleep 2 diff --git a/xCAT-nbroot/overlay/etc/init.d/S40network b/xCAT-nbroot/overlay/etc/init.d/S40network deleted file mode 100644 index a81246f91..000000000 --- a/xCAT-nbroot/overlay/etc/init.d/S40network +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exit diff --git a/xCAT-nbroot/overlay/etc/init.d/S99xcat.sh b/xCAT-nbroot/overlay/etc/init.d/S99xcat.sh deleted file mode 100755 index 35e748979..000000000 --- a/xCAT-nbroot/overlay/etc/init.d/S99xcat.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html - -while ! /bin/getdestiny -do - echo "Retrying destiny retrieval" - sleep 3 - ifconfig -done -. /bin/dodestiny diff --git a/xCAT-nbroot/overlay/etc/profile b/xCAT-nbroot/overlay/etc/profile deleted file mode 100644 index e69de29bb..000000000 diff --git a/xCAT-nbroot/overlay/init b/xCAT-nbroot/overlay/init deleted file mode 100755 index f3e2e829c..000000000 --- a/xCAT-nbroot/overlay/init +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -PATH=/sbin:/bin:/usr/bin:/usr/sbin -export PATH -/bin/mount -t proc none /proc -/bin/mount -t sysfs none /sys -/bin/mount -t tmpfs -o size=64k,mode=0755 none /dev -/bin/mkdir /dev/pts -/bin/mount -t devpts devpts /dev/pts -/bin/echo /sbin/mdev > /proc/sys/kernel/hotplug -/sbin/mdev -s -/bin/mount -o remount,rw / -/bin/mount -a -/bin/hostname -F /etc/hostname -/sbin/ifconfig lo 127.0.0.1 up -/sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo -# now run any rc scripts -for i in /etc/init.d/S??* ;do - - # Ignore dangling symlinks (if any). - [ ! -f "$i" ] && continue - - case "$i" in - *.sh) - # Source shell script for speed. - ( - trap - INT QUIT TSTP - set start - . $i - ) - ;; - *) - # No sh extension, so fork subprocess. - $i start - ;; - esac -done diff --git a/xCAT-nbroot/overlay/usr/share/udhcpc/default.script b/xCAT-nbroot/overlay/usr/share/udhcpc/default.script deleted file mode 100755 index 892342782..000000000 --- a/xCAT-nbroot/overlay/usr/share/udhcpc/default.script +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -case $1 in -deconfig) - /sbin/ifconfig $interface up - /sbin/ifconfig $interface 0.0.0.0 - ;; -bound|renew) - echo $siaddr >> /tmp/dhcpserver - /sbin/ifconfig $interface $ip netmask $subnet - if [ -n "$router" ] ; then - while route del default gw 0.0.0.0 dev $interface > /dev/null 2>&1; do - : - done - - for i in $router ; do - route add default gw $i dev $interface - done - fi - echo -n > /etc/resolv.conf - [ -n "$domain" ] && echo search $domain >> /etc/resolv.conf - for i in $dns ; do - echo nameserver $i >> /etc/resolv.conf - done - ;; -esac diff --git a/xCAT-nbroot/xcat-core-nbroot.spec b/xCAT-nbroot/xcat-core-nbroot.spec deleted file mode 100644 index 9afcc5e73..000000000 --- a/xCAT-nbroot/xcat-core-nbroot.spec +++ /dev/null @@ -1,61 +0,0 @@ -%define version %(cat Version) -%ifarch i386 i586 i686 x86 -%define tarch x86 -%endif -%ifarch x86_64 -%define tarch x86_64 -%endif -%ifarch ppc ppc64 -%define tarch ppc64 -%endif -BuildArch: noarch -%define name xCAT-nbroot-core-%{tarch} -Release: snap%(date +"%Y%m%d%H%M") -Epoch: 4 -AutoReq: false -Prefix: /opt/xcat -AutoProv: false - - - -Name: %{name} -Version: %{version} -Group: System/Utilities -License: EPL -Vendor: IBM Corp. -Summary: xCAT-nbroot-core provides opensource components of the netboot image -URL: http://xcat.org -Source1: xcat-nbrootoverlay.tar.gz - -Buildroot: %{_localstatedir}/tmp/xCAT-nbroot-core -Packager: IBM Corp. - -%Description -xcat-nbroot-core provides the xCAT scripts for the mini-root environment -All files included are as they were downloadable on 4/7/2007 -%Prep - - -%Build - -%Install -rm -rf $RPM_BUILD_ROOT -mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/netboot/%{tarch}/nbroot -cd $RPM_BUILD_ROOT/%{prefix}/share/xcat/netboot/%{tarch}/nbroot -tar zxf %{SOURCE1} -chmod 755 etc/init.d/S40network bin/getdestiny bin/getdestiny.awk bin/getipmi bin/getipmi.awk -cd - - - -%post -if [ "$1" == "2" ]; then #only on upgrade, as on install it's probably not going to work... - if [ -f "/proc/cmdline" ]; then # prevent running it during install into chroot image - . /etc/profile.d/xcat.sh - mknb %{tarch} - fi -fi - -%Files -%defattr(-,root,root) -%doc LICENSE.html -/ diff --git a/xCAT-nbroot2/98-mlx.rules b/xCAT-nbroot2/98-mlx.rules deleted file mode 100644 index 6d7ccc953..000000000 --- a/xCAT-nbroot2/98-mlx.rules +++ /dev/null @@ -1 +0,0 @@ -SUBSYSTEM=="pci", ATTRS{subsystem_vendor}=="0x15b3", ATTRS{class}=="0x020000", RUN+="/sbin/loadmlxeth" diff --git a/xCAT-nbroot2/99-imm.rules b/xCAT-nbroot2/99-imm.rules deleted file mode 100644 index cbac9801a..000000000 --- a/xCAT-nbroot2/99-imm.rules +++ /dev/null @@ -1 +0,0 @@ -SUBSYSTEM=="usb", ATTRS{idVendor}=="04b3", ATTRS{idProduct}=="4010", RUN+="/sbin/setupimmnic" diff --git a/xCAT-nbroot2/LICENSE.html b/xCAT-nbroot2/LICENSE.html deleted file mode 100644 index 83d0eebb0..000000000 --- a/xCAT-nbroot2/LICENSE.html +++ /dev/null @@ -1,326 +0,0 @@ - - - - - - - -Eclipse Public License - Version 1.0 - - - - - - -
- -

Eclipse Public License - v 1.0 -

- -

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER -THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, -REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE -OF THIS AGREEMENT.

- -

1. DEFINITIONS

- -

"Contribution" means:

- -

a) -in the case of the initial Contributor, the initial code and documentation -distributed under this Agreement, and
-b) in the case of each subsequent Contributor:

- -

i) -changes to the Program, and

- -

ii) -additions to the Program;

- -

where -such changes and/or additions to the Program originate from and are distributed -by that particular Contributor. A Contribution 'originates' from a Contributor -if it was added to the Program by such Contributor itself or anyone acting on -such Contributor's behalf. Contributions do not include additions to the -Program which: (i) are separate modules of software distributed in conjunction -with the Program under their own license agreement, and (ii) are not derivative -works of the Program.

- -

"Contributor" means any person or -entity that distributes the Program.

- -

"Licensed Patents " mean patent -claims licensable by a Contributor which are necessarily infringed by the use -or sale of its Contribution alone or when combined with the Program.

- -

"Program" means the Contributions -distributed in accordance with this Agreement.

- -

"Recipient" means anyone who -receives the Program under this Agreement, including all Contributors.

- -

2. GRANT OF RIGHTS

- -

a) -Subject to the terms of this Agreement, each Contributor hereby grants Recipient -a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly -display, publicly perform, distribute and sublicense the Contribution of such -Contributor, if any, and such derivative works, in source code and object code -form.

- -

b) -Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide, royalty-free -patent license under Licensed Patents to make, use, sell, offer to sell, import -and otherwise transfer the Contribution of such Contributor, if any, in source -code and object code form. This patent license shall apply to the combination -of the Contribution and the Program if, at the time the Contribution is added -by the Contributor, such addition of the Contribution causes such combination -to be covered by the Licensed Patents. The patent license shall not apply to -any other combinations which include the Contribution. No hardware per se is -licensed hereunder.

- -

c) -Recipient understands that although each Contributor grants the licenses to its -Contributions set forth herein, no assurances are provided by any Contributor -that the Program does not infringe the patent or other intellectual property -rights of any other entity. Each Contributor disclaims any liability to Recipient -for claims brought by any other entity based on infringement of intellectual -property rights or otherwise. As a condition to exercising the rights and -licenses granted hereunder, each Recipient hereby assumes sole responsibility -to secure any other intellectual property rights needed, if any. For example, -if a third party patent license is required to allow Recipient to distribute -the Program, it is Recipient's responsibility to acquire that license before -distributing the Program.

- -

d) -Each Contributor represents that to its knowledge it has sufficient copyright -rights in its Contribution, if any, to grant the copyright license set forth in -this Agreement.

- -

3. REQUIREMENTS

- -

A Contributor may choose to distribute the -Program in object code form under its own license agreement, provided that: -

- -

a) -it complies with the terms and conditions of this Agreement; and

- -

b) -its license agreement:

- -

i) -effectively disclaims on behalf of all Contributors all warranties and -conditions, express and implied, including warranties or conditions of title -and non-infringement, and implied warranties or conditions of merchantability -and fitness for a particular purpose;

- -

ii) -effectively excludes on behalf of all Contributors all liability for damages, -including direct, indirect, special, incidental and consequential damages, such -as lost profits;

- -

iii) -states that any provisions which differ from this Agreement are offered by that -Contributor alone and not by any other party; and

- -

iv) -states that source code for the Program is available from such Contributor, and -informs licensees how to obtain it in a reasonable manner on or through a -medium customarily used for software exchange.

- -

When the Program is made available in source -code form:

- -

a) -it must be made available under this Agreement; and

- -

b) a -copy of this Agreement must be included with each copy of the Program.

- -

Contributors may not remove or alter any -copyright notices contained within the Program.

- -

Each Contributor must identify itself as the -originator of its Contribution, if any, in a manner that reasonably allows -subsequent Recipients to identify the originator of the Contribution.

- -

4. COMMERCIAL DISTRIBUTION

- -

Commercial distributors of software may -accept certain responsibilities with respect to end users, business partners -and the like. While this license is intended to facilitate the commercial use -of the Program, the Contributor who includes the Program in a commercial -product offering should do so in a manner which does not create potential -liability for other Contributors. Therefore, if a Contributor includes the -Program in a commercial product offering, such Contributor ("Commercial -Contributor") hereby agrees to defend and indemnify every other -Contributor ("Indemnified Contributor") against any losses, damages and -costs (collectively "Losses") arising from claims, lawsuits and other -legal actions brought by a third party against the Indemnified Contributor to -the extent caused by the acts or omissions of such Commercial Contributor in -connection with its distribution of the Program in a commercial product -offering. The obligations in this section do not apply to any claims or Losses -relating to any actual or alleged intellectual property infringement. In order -to qualify, an Indemnified Contributor must: a) promptly notify the Commercial -Contributor in writing of such claim, and b) allow the Commercial Contributor -to control, and cooperate with the Commercial Contributor in, the defense and -any related settlement negotiations. The Indemnified Contributor may participate -in any such claim at its own expense.

- -

For example, a Contributor might include the -Program in a commercial product offering, Product X. That Contributor is then a -Commercial Contributor. If that Commercial Contributor then makes performance -claims, or offers warranties related to Product X, those performance claims and -warranties are such Commercial Contributor's responsibility alone. Under this -section, the Commercial Contributor would have to defend claims against the -other Contributors related to those performance claims and warranties, and if a -court requires any other Contributor to pay any damages as a result, the -Commercial Contributor must pay those damages.

- -

5. NO WARRANTY

- -

EXCEPT AS EXPRESSLY SET FORTH IN THIS -AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, -WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, -MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely -responsible for determining the appropriateness of using and distributing the -Program and assumes all risks associated with its exercise of rights under this -Agreement , including but not limited to the risks and costs of program errors, -compliance with applicable laws, damage to or loss of data, programs or -equipment, and unavailability or interruption of operations.

- -

6. DISCLAIMER OF LIABILITY

- -

EXCEPT AS EXPRESSLY SET FORTH IN THIS -AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY -OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF -THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF -THE POSSIBILITY OF SUCH DAMAGES.

- -

7. GENERAL

- -

If any provision of this Agreement is invalid -or unenforceable under applicable law, it shall not affect the validity or -enforceability of the remainder of the terms of this Agreement, and without -further action by the parties hereto, such provision shall be reformed to the -minimum extent necessary to make such provision valid and enforceable.

- -

If Recipient institutes patent litigation -against any entity (including a cross-claim or counterclaim in a lawsuit) -alleging that the Program itself (excluding combinations of the Program with -other software or hardware) infringes such Recipient's patent(s), then such -Recipient's rights granted under Section 2(b) shall terminate as of the date -such litigation is filed.

- -

All Recipient's rights under this Agreement -shall terminate if it fails to comply with any of the material terms or -conditions of this Agreement and does not cure such failure in a reasonable -period of time after becoming aware of such noncompliance. If all Recipient's -rights under this Agreement terminate, Recipient agrees to cease use and -distribution of the Program as soon as reasonably practicable. However, -Recipient's obligations under this Agreement and any licenses granted by -Recipient relating to the Program shall continue and survive.

- -

Everyone is permitted to copy and distribute -copies of this Agreement, but in order to avoid inconsistency the Agreement is -copyrighted and may only be modified in the following manner. The Agreement -Steward reserves the right to publish new versions (including revisions) of -this Agreement from time to time. No one other than the Agreement Steward has -the right to modify this Agreement. The Eclipse Foundation is the initial -Agreement Steward. The Eclipse Foundation may assign the responsibility to -serve as the Agreement Steward to a suitable separate entity. Each new version -of the Agreement will be given a distinguishing version number. The Program -(including Contributions) may always be distributed subject to the version of -the Agreement under which it was received. In addition, after a new version of -the Agreement is published, Contributor may elect to distribute the Program -(including its Contributions) under the new version. Except as expressly stated -in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to -the intellectual property of any Contributor under this Agreement, whether -expressly, by implication, estoppel or otherwise. All rights in the Program not -expressly granted under this Agreement are reserved.

- -

This Agreement is governed by the laws of the -State of New York and the intellectual property laws of the United States of -America. No party to this Agreement will bring a legal action under this -Agreement more than one year after the cause of action arose. Each party waives -its rights to a jury trial in any resulting litigation.

- -

 

- -
- - - - diff --git a/xCAT-nbroot2/allowcred.awk b/xCAT-nbroot2/allowcred.awk deleted file mode 100755 index 341138d3e..000000000 --- a/xCAT-nbroot2/allowcred.awk +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/awk -f -BEGIN { - listener = "/inet/tcp/300/0/0" - quit = "no" - - - while (match(quit,"no")) { - while ((listener |& getline) > 0) { - if (match($0,"CREDOKBYYOU?")) { - print "CREDOKBYME" |& listener - } - } - close(listener) - } -} diff --git a/xCAT-nbroot2/bmcsetup b/xCAT-nbroot2/bmcsetup deleted file mode 100755 index 3ede13582..000000000 --- a/xCAT-nbroot2/bmcsetup +++ /dev/null @@ -1,353 +0,0 @@ -# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html -# -# Raw commands to set BMCs to defaults -# dx320 -# 0x2e 0x10 0x4d 0x4f 0x00 0xff -# -# dx340 -# 0x30 0x13 0xff 0x00 0x00 0x00 -# -# dx360/x3450 -# 0x30 0x02 0x43 0x4c 0x52 0xaa -# 0x08 0x00 0x49 0x4e 0x54 0x45 0x4c -# 0x08 0x04 -# -allowcred.awk & -CREDPID=$! -sleep 5 -modprobe ipmi_si -modprobe ipmi_devintf -IPCFGMETHOD=static -while [ -z "$BMCIP" -a $IPCFGMETHOD="static" ]; do - while ! getipmi - do - echo "Retrying retrieval of IPMI settings from server" - done - TIMEOUT=15 - BMCIP=`grep bmcip /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'` - BMCVLAN=`grep taggedvlan /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'` - if [ -z "$BMCVLAN" ]; then BMCVLAN=off; fi - BMCGW=`grep gateway /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'` - BMCNM=`grep netmask /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'` - BMCUS=`grep username /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'` - BMCPW=`grep password /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'` - IPCFGMETHOD=`grep ipcfgmethod /tmp/ipmicfg.xml|awk -F\> '{print $2}'|awk -F\< '{print $1}'` - if [ -z "$IPCFGMETHOD" ]; then - IPCFGMETHOD="static" - fi - if [ -z "$BMCIP" -a $IPCFGMETHOD="static" ]; then - echo "FAILED TO RETRIEVE SETTINGS, RETRYING in 15 seconds" - sleep 15 - fi -done -kill $CREDPID -NUMBMCS=`grep bmcip /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'|wc -l` -IPMIVER=`ipmitool mc info|grep ^IPMI|awk '{print $4}'` -IPMIMFG=`ipmitool mc info|grep "^Manufacturer ID"|awk '{print $4}'` -if [ "$IPMIMFG" == 2 ]; then #IBM - XPROD=`ipmitool mc info|grep "^Product ID"|awk '{print $4}'` - if [ "$XPROD" == "220" ]; then - LOCKEDUSERS=1 - BMCPORT=`grep bmcport /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'` - if [ ! -z "$BMCPORT" ]; then - let idev=NUMBMCS-1 - for p in $BMCPORT; do - ipmitool -d $idev raw 0xc 1 1 0xc0 $p > /dev/null - ipmitool -d $idev raw 0x04 0x12 0x09 0x01 0x18 0x${p}1 0x00 > /dev/null - let idev=idev-1 - done - fi - elif [ "$XPROD" == "291" ]; then - LOCKEDUSERS=1 - else - IBMFAM=`ipmitool raw 0x3a 0x50 |head -n 1| awk '{print $1 $2 $3 $4}'` - if [ "$IBMFAM" == "59554f4f" ]; then - BMCPORT=`grep bmcport /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'` - if [ ! -z "$BMCPORT" ]; then - let idev=NUMBMCS-1 - for p in $BMCPORT; do - ipmitool -d $idev raw 0xc 1 1 0xc0 $BMCPORT > /dev/null - let idev=idev-1 - done - fi - fi - fi -elif [ "$IPMIMFG" == 20301 ] ; then - XPROD=`ipmitool mc info|grep "^Product ID"|awk '{print $4}'` - IBMVPDV=`ipmitool raw 0x3a 0xb 2 0 16 1` - if [ $IBMVPDV -eq 2 ]; then - ISITE=1; - fi - LOCKEDUSERS=1 - BMCPORT=`grep bmcport /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'` - if [ ! -z "$BMCPORT" ]; then - let idev=NUMBMCS-1 - for p in $BMCPORT; do - ipmitool -d $idev raw 0xc 1 1 0xc0 $BMCPORT > /dev/null - NEWPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0|awk '{print $2}'` - sleep 10 - - let idev=idev-1 - done - fi -elif [ "$IPMIMFG" == "47488" ]; then - LOCKEDUSERS=1 -fi -echo -n "Auto detecting LAN channel..." - -for LANCHAN in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do - if ipmitool channel info $LANCHAN 2> /dev/null | grep 802.3 > /dev/null 2>&1 && ipmitool raw 0xc 2 $LANCHAN 5 0 0 > /dev/null 2>&1; - then break; - fi; - echo -n "." -done -echo "Detected LAN channel $LANCHAN" - -let idev=NUMBMCS -if [ $IPCFGMETHOD="static" ]; then - while [ $idev -gt 0 ]; do - let idev=idev-1 - TRIES=0 - while ! ipmitool -d $idev lan set $LANCHAN ipsrc static; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done - done - let idev=NUMBMCS-1 - for b in $BMCIP; do - TRIES=0 - while ! ipmitool -d $idev lan set $LANCHAN ipaddr $b; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done - let idev=idev-1 - done - let idev=NUMBMCS-1 - for m in $BMCNM; do - TRIES=0 - while ! ipmitool -d $idev lan set $LANCHAN netmask $m; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done - let idev=idev-1 - done - TRIES=0 - if [ ! -z "$BMCGW" ]; then - let idev=NUMBMCS-1 - for g in $BMCGW; do - TRIES=0 - while ! ipmitool -d $idev lan set $LANCHAN defgw ipaddr $g; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done - let idev=idev-1 - done - TRIES=0 - fi -else - let idev=NUMBMCS - while [ $idev -gt 0 ]; do - let idev=idev-1 - TRIES=0 - while ! ipmitool -d $idev lan set $LANCHAN ipsrc $IPCFGMETHOD; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done - done -fi - -let idev=NUMBMCS -while [ $idev -gt 0 ]; do - let idev=idev-1 - TRIES=0 - ipmitool -d $idev lan set $LANCHAN vlan id $BMCVLAN -done - -let idev=NUMBMCS-1 -for bmcu in $BMCUS; do - if [ "$bmcu" = "" ]; then continue; fi -DISABLEUSERS="1 2 3 4" -if [ ! -z "$LOCKEDUSERS" ]; then - USERSLOT=`ipmitool -d $idev user list $LANCHAN |grep -v ^ID|awk '{print $1 " " $2}'|grep " $BMCUS"|awk '{print $1}'` - if [ -z "$USERSLOT" ]; then - USERSLOT=4 - fi -else - USERSLOT=2 -fi -if [ "$ISITE" = 1 ]; then - allowcred.awk & - CREDPID=$! - while ! remoteimmsetup - do - echo "Waiting for xCAT remote configuration of service processor via CMM.." - done - kill $CREDPID -fi -CURRENTUSER=`ipmitool -d $idev user list $LANCHAN|grep ^$USERSLOT|awk '{print $2}'` -DISABLEUSERS=`echo 1 2 3 4|sed -e s/$USERSLOT//` -for user in $DISABLEUSERS; do - while ! ipmitool -d $idev user disable $user; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done - TRIES=0 -done -TRIES=0 -while ! ipmitool -d $idev user enable $USERSLOT; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi -done -TRIES=0 -# Last param in ipmitool user priv is the channel to set it on. -# Penguin boxes are all channel 2 -CURRPRIV=`ipmitool -d $idev user list 1|grep ^$USERSLOT|awk '{print $6}'` -if [ "$CURRPRIV" != "ADMINISTRATOR" ]; then - while ! ipmitool -d $idev user priv $USERSLOT 4 $LANCHAN; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done - TRIES=0 -fi -TRIES=0 -while ! ipmitool -d $idev channel setaccess $LANCHAN $USERSLOT link=on; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi -done -TRIES=0 -if [ "$CURRENTUSER" != "$bmcu" ]; then - while ! ipmitool -d $idev user set name $USERSLOT $bmcu; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done -fi -let idev=idev-1 -done -let idev=NUMBMCS-1 -for bmcp in $BMCPW; do - if [ "$bmcp" = "" ]; then continue; fi -TRIES=0 -while ! ipmitool -d $idev user set password $USERSLOT $bmcp; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi -done -TRIES=0 -echo "Set up following user table: " -ipmitool -d $idev user list $LANCHAN -let idev=idev-1 -done - -let idev=NUMBMCS -while [ $idev -gt 0 ]; do -let idev=idev-1 - - -echo -n "Enabling Channel $LANCHAN: " -while ! ipmitool -d $idev raw 0x6 0x40 $LANCHAN 0x42 0x44 > /dev/null; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi -done -TRIES=0 -while ! ipmitool -d $idev raw 0x6 0x40 $LANCHAN 0x82 0x84 > /dev/null; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi -done -if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi -TRIES=0 - -echo -n "Enabling ARP responses: " -while ! ipmitool -d $idev lan set $LANCHAN arp respond on > /dev/null; do - sleep 1 - let TRIES=TRIES+1 - echo -n . - if [ $TRIES -gt $TIMEOUT ]; then break; fi -done -if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi -TRIES=0 - -echo -n "Enabling IPMI v 1.5 MD5 LAN access:" -while ! ipmitool -d $idev lan set $LANCHAN auth admin md5 > /dev/null; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi -done -if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi -TRIES=0 -if [ ! "$IPMIVER" == "1.5" ]; then - echo -n "Enabling IPMI v 2.0 LAN access: " - #two goals here, make sure cipher suite 0 does not work as it is insecure - #mae sure cipher suite 3 does work because we will use it - #leave every thing else alone. - ACCESS=`ipmitool raw 0xc 2 1 24 0 0 ` - NEWACCESS="" - i=0 - for elem in $ACCESS; do - if [ $i = 2 ]; then - NEWACCESS=`printf "$NEWACCESS 0x%02x" $((0x$elem&0xf0))` - elif [ $i = 3 ]; then - NEWACCESS=`printf "$NEWACCESS 0x%02x" $((0x$elem|0x44))` - elif [ $i != 0 ]; then - NEWACCESS="$NEWACCESS 0x$elem" - fi - i=$((i+1)) - done - if ipmitool raw 0xc 1 1 24 $NEWACCESS > /dev/null; then - echo OK - else - echo ERROR - fi - - - TRIES=0 - - echo -n "Enabling SOL for channel $LANCHAN:" - while ! ipmitool -d $idev raw 0xc 0x21 $LANCHAN 0x1 0x1 > /dev/null; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done - if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi - TRIES=0 - - echo -n "Enabling SOL for $BMCUS:" - while ! ipmitool -d $idev raw 6 0x4c $LANCHAN $USERSLOT 2 0 0 0 > /dev/null; do - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done - if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi - echo -n "Putting SOL on channel $LANCHAN:" - while ! OUTPUT=`ipmitool -d $idev raw 0xc 0x21 $LANCHAN 7 $LANCHAN 2>&1 > /dev/null`; do - if echo $OUTPUT|grep "Unknown (0x80)" > /dev/null; then - echo "Not Needed" - break - fi - sleep 1 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done - if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi -fi - -#frume.awk - -echo "Lighting Identify Light" -while : - do ipmitool -d $idev raw 0 4 10 > /dev/null - sleep 7 -done & -done - diff --git a/xCAT-nbroot2/buildrpm b/xCAT-nbroot2/buildrpm deleted file mode 100755 index 1dddba6a2..000000000 --- a/xCAT-nbroot2/buildrpm +++ /dev/null @@ -1,12 +0,0 @@ -DIR=`dirname $0` -mkdir -p /usr/share/dracut/modules.d/97xcat -cp $DIR/* /usr/share/dracut/modules.d/97xcat -mkdir -p /tmp/xcatgenesis.$$/opt/xcat/share/xcat/netboot/genesis/`uname -m`/fs -dracut -m "xcat base" -f /tmp/xcatgenesis.$$.rfs -cd /tmp/xcatgenesis.$$/opt/xcat/share/xcat/netboot/genesis/`uname -m`/fs -zcat /tmp/xcatgenesis.$$.rfs|cpio -dumi -cp /boot/vmlinuz-`uname -r` /tmp/xcatgenesis.$$/opt/xcat/share/xcat/netboot/genesis/`uname -m`/kernel -cd - -cd /tmp/xcatgenesis.$$ -tar jcf ~/rpmbuild/SOURCES/xCAT-genesis-`uname -m`.tar.bz2 opt -rpmbuild -ba $DIR/xCAT-genesis.spec diff --git a/xCAT-nbroot2/check b/xCAT-nbroot2/check deleted file mode 100755 index ad76f12ff..000000000 --- a/xCAT-nbroot2/check +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -#[ "$1" = "-d" ] && echo network #they pull in too much -exit 0 diff --git a/xCAT-nbroot2/debian/changelog b/xCAT-nbroot2/debian/changelog deleted file mode 100644 index b9e8f45dc..000000000 --- a/xCAT-nbroot2/debian/changelog +++ /dev/null @@ -1,77 +0,0 @@ -xcat-genesis (2.8-snap20130118) stable; urgency=low - - * Nightly_Builds - - -- root Fri, 18 Jan 2013 22:45:30 -0500 - -xcat-genesis (2.8-snap20130118) stable; urgency=low - - * Nightly_Builds - - -- root Fri, 18 Jan 2013 22:04:43 -0500 - -xcat-genesis (2.8-snap20130118) stable; urgency=low - - * Nightly_Builds - - -- root Fri, 18 Jan 2013 21:59:29 -0500 - -xcat-genesis (2.8-local20130118) stable; urgency=low - - * Personal Build - - -- root Fri, 18 Jan 2013 09:53:50 -0500 - -xcat-genesis (2.8-local20130118) stable; urgency=low - - * Personal Build - - -- root Fri, 18 Jan 2013 09:50:10 -0500 - -xcat-genesis (2.8-snap20130109) stable; urgency=low - - * Nightly_Builds - - -- root Wed, 09 Jan 2013 02:47:44 -0500 - -xcat-genesis (2.8-snap20130109) stable; urgency=low - - * Nightly_Builds - - -- root Wed, 09 Jan 2013 01:51:17 -0500 - -xcat-genesis (2.8-snap20130106) stable; urgency=low - - * Nightly_Builds - - -- root Sun, 06 Jan 2013 01:22:57 -0500 - -xcat-genesis (2.8-snap20130106) stable; urgency=low - - * Nightly_Builds - - -- root Sun, 06 Jan 2013 01:09:11 -0500 - -xcat-genesis (2.8-snap20130106) stable; urgency=low - - * Nightly_Builds - - -- root Sun, 06 Jan 2013 00:26:37 -0500 - -xcat-genesis (2.8-snap20130105) stable; urgency=low - - * Nightly_Builds - - -- root Sat, 05 Jan 2013 01:38:55 -0500 - -xcat-genesis (2.8-snap20130105) stable; urgency=low - - * Nightly_Builds - - -- root Sat, 05 Jan 2013 01:32:17 -0500 - -xcat-genesis (2.8.0-1) stable; urgency=low - - * Initial Release - - -- OCF xCAT Thu, 05 Apr 2012 00:00:00 +0100 diff --git a/xCAT-nbroot2/debian/compat b/xCAT-nbroot2/debian/compat deleted file mode 100644 index 7ed6ff82d..000000000 --- a/xCAT-nbroot2/debian/compat +++ /dev/null @@ -1 +0,0 @@ -5 diff --git a/xCAT-nbroot2/debian/control b/xCAT-nbroot2/debian/control deleted file mode 100644 index 151f7af7c..000000000 --- a/xCAT-nbroot2/debian/control +++ /dev/null @@ -1,14 +0,0 @@ -Source: xcat-genesis -Section: admin -Priority: extra -Maintainer: Arif Ali -Build-Depends: debhelper (>= 5), dracut, ethtool, bridge-utils, ifenslave, vlan, rpm, libc6-i386, hwdata, screen, ntp, ncurses-term, btrfs-tools, libstdc++5, libldap-2.4-2, libsasl2-2, libtirpc1, nfs-common -Standards-Version: 3.7.2 - -Package: xcat-genesis-amd64 -Architecture: all -Depends: ${perl:Depends} -Description: xCAT Genesis netboot image - xCAT genesis (Genesis Enhanced Netboot Environment for System Information - and Servicing) is a small, embedded-like environment for xCAT's use in - discovery and management actions when interaction with an OS is infeasible. diff --git a/xCAT-nbroot2/debian/copyright b/xCAT-nbroot2/debian/copyright deleted file mode 100644 index f61d34dfe..000000000 --- a/xCAT-nbroot2/debian/copyright +++ /dev/null @@ -1,88 +0,0 @@ -Eclipse Public License - v 1.0 - -THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. - -1. DEFINITIONS - -"Contribution" means: - -a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and -b) in the case of each subsequent Contributor: - -i) changes to the Program, and - -ii) additions to the Program; - -where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. - -"Contributor" means any person or entity that distributes the Program. - -"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. - -"Program" means the Contributions distributed in accordance with this Agreement. - -"Recipient" means anyone who receives the Program under this Agreement, including all Contributors. - -2. GRANT OF RIGHTS - -a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form. - -b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. - -c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program. - -d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. - -3. REQUIREMENTS - -A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: - -a) it complies with the terms and conditions of this Agreement; and - -b) its license agreement: - -i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; - -ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; - -iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and - -iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. - -When the Program is made available in source code form: - -a) it must be made available under this Agreement; and - -b) a copy of this Agreement must be included with each copy of the Program. - -Contributors may not remove or alter any copyright notices contained within the Program. - -Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. - -4. COMMERCIAL DISTRIBUTION - -Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. - -For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. - -5. NO WARRANTY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. - -6. DISCLAIMER OF LIABILITY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -7. GENERAL - -If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. - -If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. - -All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. - -Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. - -This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. - - diff --git a/xCAT-nbroot2/debian/docs b/xCAT-nbroot2/debian/docs deleted file mode 100644 index 9c734aebd..000000000 --- a/xCAT-nbroot2/debian/docs +++ /dev/null @@ -1 +0,0 @@ -LICENSE.html diff --git a/xCAT-nbroot2/debian/rules b/xCAT-nbroot2/debian/rules deleted file mode 100755 index 1938e1654..000000000 --- a/xCAT-nbroot2/debian/rules +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- -# Sample debian/rules that uses debhelper. -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -export DH_COMPAT=5 - -export buildroot=$(PWD)/debian/xcat-genesis-$(DEB_BUILD_ARCH) - -build: - mkdir -p /usr/share/dracut/modules.d/97xcat - cp -r * /usr/share/dracut/modules.d/97xcat - rm -rf /usr/share/dracut/modules.d/97xcat/debian - version=`head -n 1 /etc/issue | awk '{print $$1}'`;if [ $$version = 'Debian' ]; then\ - mkdir -p /usr/lib/dracut/modules.d/97xcat;\ - cp -r * /usr/lib/dracut/modules.d/97xcat;\ - rm -rf /usr/lib/dracut/modules.d/97xcat/debian;\ - mv /usr/share/dracut/modules.d/97xcat/install.debian /usr/share/dracut/modules.d/97xcat/install; \ - mv /usr/lib/dracut/modules.d/97xcat/install.debian /usr/lib/dracut/modules.d/97xcat/install; \ - else\ - mv /usr/share/dracut/modules.d/97xcat/install.ubuntu /usr/share/dracut/modules.d/97xcat/install;\ - fi - mkdir -p $(buildroot)/opt/xcat/share/xcat/netboot/genesis/$(DEB_BUILD_GNU_CPU)/fs - dracut -m "xcat base" -f /tmp/xcatgenesis.tmp.rfs - (cd $(buildroot)/opt/xcat/share/xcat/netboot/genesis/$(DEB_BUILD_GNU_CPU)/fs/ && zcat /tmp/xcatgenesis.tmp.rfs|cpio -dumi) - cp /boot/vmlinuz-`uname -r` $(buildroot)/opt/xcat/share/xcat/netboot/genesis/$(DEB_BUILD_GNU_CPU)/kernel - chmod a+r $(buildroot)/opt/xcat/share/xcat/netboot/genesis/$(DEB_BUILD_GNU_CPU)/kernel - -clean: - dh_testdir - dh_testroot - dh_clean -d - -install: - pwd - dh_testdir - dh_testroot - dh_installdirs -# dh_install -X".svn" -# dh_link - - -# Build architecture-independent files here. -binary-indep: build install -# We have nothing to do by default. - -# Build architecture-dependent files here. -binary-arch: - dh_testdir - dh_testroot - dh_installchangelogs - dh_installdocs -# dh_installexamples -# dh_install -X".svn" -# dh_installmenu -# dh_installdebconf -# dh_installlogrotate -# dh_installemacsen -# dh_installpam -# dh_installmime -# dh_python -# dh_installinit -# dh_installcron -# dh_installinfo - dh_installman -# dh_link -# dh_strip - dh_compress -# dh_fixperms - dh_perl - dh_makeshlibs - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/xCAT-nbroot2/debian/source/format b/xCAT-nbroot2/debian/source/format deleted file mode 100644 index d3827e75a..000000000 --- a/xCAT-nbroot2/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -1.0 diff --git a/xCAT-nbroot2/debian/xcat-genesis-amd64.dirs b/xCAT-nbroot2/debian/xcat-genesis-amd64.dirs deleted file mode 100644 index a940a8b7f..000000000 --- a/xCAT-nbroot2/debian/xcat-genesis-amd64.dirs +++ /dev/null @@ -1 +0,0 @@ -opt/xcat/share/xcat/netboot/genesis/x86_64 diff --git a/xCAT-nbroot2/debian/xcat-genesis-amd64.postinst b/xCAT-nbroot2/debian/xcat-genesis-amd64.postinst deleted file mode 100644 index 35bf74c2d..000000000 --- a/xCAT-nbroot2/debian/xcat-genesis-amd64.postinst +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh -# postinst script for xcat-genesis -# -# see: dh_installdeb(1) - -set -e - -# summary of how this script can be called: -# * `configure' -# * `abort-upgrade' -# * `abort-remove' `in-favour' -# -# * `abort-remove' -# * `abort-deconfigure' `in-favour' -# `removing' -# -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package - - -case "$1" in - configure) - if [ -f /tmp/xCAT-genesis_upgrade.tmp ];then - if [ -f "/proc/cmdline" ]; then # prevent running it during install into chroot image - . /etc/profile.d/xcat.sh - mknb x86_64 - fi - rm /tmp/xCAT-genesis_upgrade.tmp - fi - ;; - - abort-upgrade|abort-remove|abort-deconfigure) - ;; - - *) - echo "postinst called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - -exit 0 diff --git a/xCAT-nbroot2/debian/xcat-genesis-amd64.prerm b/xCAT-nbroot2/debian/xcat-genesis-amd64.prerm deleted file mode 100644 index 155110d63..000000000 --- a/xCAT-nbroot2/debian/xcat-genesis-amd64.prerm +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# prerm script for xCAT-nbroot2 -# -# see: dh_installdeb(1) - -set -e - -# summary of how this script can be called: -# * `remove' -# * `upgrade' -# * `failed-upgrade' -# * `remove' `in-favour' -# * `deconfigure' `in-favour' -# `removing' -# -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package - - -case "$1" in - upgrade) - touch /tmp/xCAT-genesis_upgrade.tmp - ;; - remove|deconfigure) - ;; - - failed-upgrade) - ;; - - *) - echo "prerm called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - -exit 0 diff --git a/xCAT-nbroot2/dhclient-script b/xCAT-nbroot2/dhclient-script deleted file mode 100755 index 48a42161f..000000000 --- a/xCAT-nbroot2/dhclient-script +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/sh -PATH=/bin:/sbin:/usr/bin:/usr/sbin -if [ $reason = "PREINIT" -o $reason = "PREINIT6" ]; then - ip link set $interface up - tries=50 - while ! (ip link show $interface|grep LOWER_UP > /dev/null 2>&1); do - sleep 0.1 - if [ $tries = 0 ]; then - break - fi - tries=$((tries-1)) - done -elif [ $reason = "BOUND" ]; then - if [ ! -z "$old_ip_address" ]; then - ip addr del dev $interface $old_ip_address/$old_subnet_mask - fi - for oldip in `ip addr show dev $interface|grep 'inet '|awk '{print $2}'`; do - ip addr del dev $interface $oldip - done - if [ ! -z "$new_ip_address" -a ! -z "$new_subnet_mask" ]; then - ip addr add dev $interface $new_ip_address/$new_subnet_mask - fi - if [ ! -z "$new_host_name" ]; then - hostname $new_host_name - lldptool -T -i $interface -V 5 enableTx=yes >& /dev/null - fi - if [ ! -z "$new_domain_name" ]; then - echo search $new_domain_name >> /etc/resolv.conf - fi - for ns in $new_domain_name_servers; do - echo nameserver $ns >> /etc/resolv.conf - done - for ntp in $new_ntp_servers; do - echo server $ntp iburst >> /etc/ntp.conf - done - for gw in $new_routers; do - ip route add default via $gw - done - if [ ! -z "$new_log_servers" ]; then - head -n -1 /etc/rsyslog.conf > /etc/rsyslog.conf.new - cp /etc/rsyslog.conf.new /etc/rsyslog.conf - fi - for ls in $new_log_servers; do - echo *.* @$ls >> /etc/rsyslog.conf - done - kill -1 `cat /var/run/syslogd.pid` - - if [ ! -z "$new_tcode" -a -r "/usr/share/zoneinfo/posix/$new_tcode" ]; then - cp "/usr/share/zoneinfo/posix/$new_tcode" /etc/localtime - rm -rf /usr/share/zoneinfo #free up ramdisk - fi -elif [ $reason = "BOUND6" ]; then - if [ ! -z "$old_ip6_address" ]; then - ip addr del dev $interface $old_ip6_address/$old_ip6_prefixlen - fi - if [ ! -z "$new_ip6_address" ]; then - ip addr add dev $interface $new_ip6_address/$new_ip6_prefixlen - fi -elif [ $reason = "RELEASE" ]; then - if [ ! -z "$old_ip_address" ]; then - ip addr del dev $interface $old_ip_address/$old_subnet_mask - fi -elif [ $reason = "RELEASE6" ]; then - if [ ! -z "$old_ip6_address" ]; then - ip addr del dev $interface $old_ip6_address/$old_ip6_prefixlen - fi -fi -exit 0 diff --git a/xCAT-nbroot2/dhclient.conf b/xCAT-nbroot2/dhclient.conf deleted file mode 100644 index 53e8b1a74..000000000 --- a/xCAT-nbroot2/dhclient.conf +++ /dev/null @@ -1,2 +0,0 @@ -option tcode code 101 = text; -request subnet-mask, routers, domain-name, domain-search, domain-name-servers, host-name, ntp-servers, interface-mtu, tcode, log-servers; diff --git a/xCAT-nbroot2/dodiscovery b/xCAT-nbroot2/dodiscovery deleted file mode 100755 index c0e18b8c0..000000000 --- a/xCAT-nbroot2/dodiscovery +++ /dev/null @@ -1,127 +0,0 @@ -#!/bin/sh -minixcatd.awk & -PUBKEY=`openssl rsa -in /etc/xcat/privkey.pem -pubout 2> /dev/null|grep -v "PUBLIC KEY"` -PUBKEY=`echo $PUBKEY|sed -e 's/ //g'` -export PUBKEY - -echo "Beginning node discovery process" -waitforlink=100 -while [ ! -z "$NICSTOBRINGUP" -a $waitforlink -gt 0 ]; do - NICSTOBRINGUP=`ip link|grep mtu|grep -v LOOPBACK|grep -v usb|grep -v ,LOWER_UP|awk -F: '{print $2}'` - waitforlink=$((waitforlink - 1)) - sleep 0.1 - if [ $waitforlink = 1 ]; then - echo "No link detected on $NICSTOBRINGUP" - fi -done -NICSGETTINGADDR=`ip link|grep mtu|grep -v LOOPBACK|grep -v usb|grep ,LOWER_UP|awk -F: '{print $2}'` -timewaiting=0 -echo "Waiting for nics to get addresses" -while [ ! -z "$NICSGETTINGADDR" -a $timewaiting != 700 ]; do - NEWNICSGETTINGADDR="" - for nic in $NICSGETTINGADDR; do - if ! ip addr show dev $nic |grep -v inet6|grep inet >/dev/null; then - NEWNICSGETTINGADDR="$NEWNICSGETTINGADDR $nic" - else - echo -n "$nic|" - ip addr show dev $nic |grep -v inet6|grep inet|sed -e s/\\/.*//|awk '{print $2}' - fi - done - sleep 0.1 - timewaiting=$((timewaiting+1)) - if [ $timewaiting = 699 ]; then - echo "No DHCP answer for $nic, ignoring interface" - fi - NICSGETTINGADDR=$NEWNICSGETTINGADDR -done -if [ $timewaiting != 700 -a $timewaiting -gt 450 ]; then - echo "Got an address, but it took inordinately long, you may want to check spanning tree configuration" -fi -echo "Network configuration complete, commencing transmit of discovery packets" -XCATPORT=3001 -export XCATPORT -for parm in `cat /proc/cmdline`; do - key=`echo $parm|awk -F= '{print $1}'` - if [ "$key" = "xcatd" ]; then - XCATMASTER=`echo $parm|awk -F= '{print $2}'|awk -F: '{print $1}'` - XCATPORT=`echo $parm|awk -F= '{print $2}'|awk -F: '{print $2}'` - fi -done - - -#time to make our packet... -MTM=unknown -SERIAL=unknown -ARCH=unknown -ARCH=`uname -m` #32-bit only is old news -if [ -r /sys/devices/virtual/dmi/id/product_name ]; then #x86 - PRODNAME=`cat /sys/devices/virtual/dmi/id/product_name` - IAMAVM=0 - if [ "$PRODNAME" = "KVM" ]; then - IAMAVM=1 - MTM=KVM - elif [ "$PRODNAME" = "VMware Virtual Platform" ]; then - IAMAVM=1 - MTM=VMware - else - MTM=`cat /sys/devices/virtual/dmi/id/product_name|awk -F'[' '{print $2}'|awk -F']' '{print $1}'` - SERIAL=`cat /sys/devices/virtual/dmi/id/product_serial` - fi -elif [ -r /proc/device-tree/model ]; then #POWER - MTM=`cat /proc/device-tree/model |awk -F, '{print $2}'` -fi -CPUCOUNT=`cat /proc/cpuinfo |grep "model name"|wc -l` -MEMORY=`cat /proc/meminfo |grep MemTotal|awk '{print $2}'` -UUID=`sed -e 's/\(..\)\(..\)\(..\)\(..\)-\(..\)\(..\)-\(..\)\(..\)/\4\3\2\1-\6\5-\8\7/' /sys/devices/virtual/dmi/id/product_uuid` -grep "model name" /proc/cpuinfo | while read line; do #to avoid pulling in tail, we do a goofy thing - echo $line > /tmp/cpumod -done -CPUTYPE=`cat /tmp/cpumod|awk -F':' '{print $2}'|sed -e 's/^ //'` -echo '' > /tmp/discopacket -echo "findme" >> /tmp/discopacket -echo "$ARCH" >> /tmp/discopacket -if [ "$IAMAVM" = 1 ]; then - echo "virtual" >> /tmp/discopacket -fi -echo "$CPUCOUNT" >> /tmp/discopacket -echo "$CPUTYPE" >> /tmp/discopacket -echo "$MEMORY" >> /tmp/discopacket -echo "$UUID" >> /tmp/discopacket -if [ "$MTM" != "unknown" ]; then - echo "$MTM" >> /tmp/discopacket -fi -if [ "$SERIAL" != "unknown" ]; then - echo "$SERIAL" >> /tmp/discopacket -fi -for dev in `ip link|grep -B1 ether|grep UP|awk '{print $2}'|sed -e s/://`; do - DRIVER=`grep DRIVER /sys/class/net/$dev/device/uevent|awk -F= '{print $2}'` - ADDRESS=`ip address show dev $dev|grep "inet "|grep global|awk '{print $2}'` - MAC=`ip link show dev $dev|grep ether|awk '{print $2}'| tr /a-f/ /A-F/` - echo "$DRIVER|$dev|$MAC|$ADDRESS" >> /tmp/discopacket -done -echo "$PUBKEY" >> /tmp/discopacket #this is not secure to use by itself, switch sourced pubkey for security -echo "" >> /tmp/discopacket -echo "" >> /tmp/discopacket -echo "" >> /tmp/discopacket -openssl dgst -sha512 -out /tmp/discopacket.sha512 -sign /etc/xcat/privkey.pem /tmp/discopacket -openssl enc -e -a -in /tmp/discopacket.sha512 > /tmp/discopacket.b64sig -cat /tmp/discopacket |while read line; do - if [ "$line" = "" ]; then - cat /tmp/discopacket.b64sig >> /tmp/discopacket.new - fi - echo $line >> /tmp/discopacket.new -done -mv /tmp/discopacket.new /tmp/discopacket - - -while [ ! -r /restart ]; do - if [ ! -z "$XCATMASTER" ]; then - (cat /tmp/discopacket | udpcat.awk $XCATMASTER $XCATPORT ) & - fi - for dhcps in `grep dhcp-server /var/lib/dhclient/dhclient.leases|awk '{print $4}'|sed -s 's/;//'`; do - (cat /tmp/discopacket | udpcat.awk $dhcps $XCATPORT ) & - done - #cat /tmp/discopacket - sleep 5 -done -/bin/restart diff --git a/xCAT-nbroot2/doxcat b/xCAT-nbroot2/doxcat deleted file mode 100755 index b54335ed6..000000000 --- a/xCAT-nbroot2/doxcat +++ /dev/null @@ -1,179 +0,0 @@ -# -# 2013.02.07 Brian Elliott Finley -# - Added slash in front of "var" in the NICSTOBRINGUP dhclient section. -# Bug reported by Jeff Lang . Thanks, Jeff! -# - -if [ ! -z "$BOOTIF" ]; then - BOOTIF=`echo $BOOTIF|sed -e s/01-// -e s/-/:/g` - echo -n "Waiting for device with address $BOOTIF to appear.." - gripeiter=6000 - while [ -z "$bootnic" ]; do - bootnic=`ip link show|grep -B1 $BOOTIF|grep mtu|awk '{print $2}'|sed -e 's/:$//'` - sleep 0.1 - if [ $gripeiter = 0 ]; then - echo "ERROR" - echo "Unable to find boot device (maybe the nbroot is missing the driver for your nic?)" - while :; do sleep 365d; done - fi - gripeiter=$((gripeiter-1)) - done -fi -echo "Done" -if [ -z "$bootnic" ]; then - echo "ERROR: BOOTIF missing, can't detect boot nic" -fi - -if [ -r /sys/devices/virtual/dmi/id/product_uuid ]; then - duid='default-duid "\\000\\004'; - #product_uuid in sysfs fails to cope with endianness of SMBIOS 2.6, unconditionnaly swap. Technically leads to incorrect DUID in 'older' systems but matches MS behavior - for i in `sed -e 's/\(..\)\(..\)\(..\)\(..\)-\(..\)\(..\)-\(..\)\(..\)/\4\3\2\1-\6\5-\8\7/;s/-//g;s/\(..\)/\1 /g' /sys/devices/virtual/dmi/id/product_uuid`; do - octnum="\\"`printf "\\%03o" 0x$i` - duid=$duid$octnum - done - duid=$duid'";' - echo $duid > /var/lib/dhclient/dhclient6.leases -fi -rpcbind -rpc.statd -ssh-keygen -q -t rsa -f /etc/ssh/ssh_host_rsa_key -C '' -N '' -ssh-keygen -q -t dsa -f /etc/ssh/ssh_host_dsa_key -C '' -N '' -echo 'Protocol 2' >> /etc/ssh/sshd_config -/usr/sbin/sshd -mkdir -p /etc/xcat -mkdir -p /etc/pki/tls -echo "[ req ] -distinguished_name = nodedn - -[ nodedn ]" > /etc/pki/tls/openssl.cnf -echo -n "Generating private key..." -openssl genrsa -out /etc/xcat/privkey.pem 1024 >& /dev/null -echo "Done" -PUBKEY=`openssl rsa -in /etc/xcat/privkey.pem -pubout 2> /dev/null|grep -v "PUBLIC KEY"` -PUBKEY=`echo $PUBKEY|sed -e 's/ //g'` -export PUBKEY -/sbin/rsyslogd -c4 -mkdir -p /var/lib/lldpad -echo 'lldp :' >> /var/lib/lldpad/lldpad.conf -echo '{' >> /var/lib/lldpad/lldpad.conf -for iface in `ip link |grep -v '^ '|awk '{print $2}'|sed -e 's/:$//'|grep -v lo`; do -echo "$iface :" >> /var/lib/lldpad/lldpad.conf -echo "{" >> /var/lib/lldpad/lldpad.conf - echo "tlvid00000006 :" >> /var/lib/lldpad/lldpad.conf - echo "{" >> /var/lib/lldpad/lldpad.conf - echo info = '"'$PUBKEY'";' >> /var/lib/lldpad/lldpad.conf - echo 'enableTx = true;' >> /var/lib/lldpad/lldpad.conf - echo '};' >> /var/lib/lldpad/lldpad.conf - echo 'adminStatus = 3;' >> /var/lib/lldpad/lldpad.conf -echo '};' >> /var/lib/lldpad/lldpad.conf -done -echo '};' >> /var/lib/lldpad/lldpad.conf -lldpad -d -dhclient -cf /etc/dhclient.conf -pf /var/run/dhclient.$bootnic.pid $bootnic & -#we'll kick of IPv6 and IPv4 on all nics, but not wait for them to come up unless doing discovery, to reduce -#chances that we'll perform a partial discovery -#in other scenarios where downed non-bootnics cause issues, will rely on retries to fix things up -dhclient -6 -pf /var/run/dhclient6.$bootnic.pid $bootnic -lf /var/lib/dhclient/dhclient6.leases & -NICSTOBRINGUP=`ip link|grep mtu|grep -v LOOPBACK|grep -v $bootnic|grep -v usb|grep -v ,UP|awk -F: '{print $2}'` -export NICSTOBRINGUP -for nic in $NICSTOBRINGUP; do - dhclient -cf /etc/dhclient.conf -pf /var/run/dhclient.$nic.pid $nic & - dhclient -cf /etc/dhclient.conf -6 -pf /var/run/dhclient6.$nic.pid -lf /var/lib/dhclient/dhclient6.leases $nic & -done -openssl genrsa -out /etc/xcat/certkey.pem 4096 > /dev/null 2>&1 & - - - - -gripeiter=101 -echo -n "Acquiring network addresses.." -while ! ip addr show dev $bootnic|grep -v 'scope link'|grep -v 'dynamic'|grep -v inet6|grep inet > /dev/null; do - sleep 0.1 - if [ $gripeiter = 1 ]; then - echo - echo "It seems to be taking a while to acquire an IPv4 address, you may want to check spanning tree..." - fi - gripeiter=$((gripeiter-1)) -done -echo -n "Acquired IPv4 address on $bootnic: " -ip addr show dev $bootnic|grep -v 'scope link'|grep -v 'dynamic'|grep -v inet6|grep inet|awk '{print $2}' -ntpd -g -x -(while ! ntpq -c "rv 0 state"|grep 'state=4' > /dev/null; do sleep 1; done; hwclock --systohc) & -if dmidecode|grep IPMI > /dev/null; then - modprobe ipmi_si - modprobe ipmi_devintf -fi -XCATPORT=3001 -export XCATPORT -for parm in `cat /proc/cmdline`; do - key=`echo $parm|awk -F= '{print $1}'` - if [ "$key" = "xcatd" ]; then - XCATMASTER=`echo $parm|awk -F= '{print $2}'|awk -F: '{print $1}'` - XCATPORT=`echo $parm|awk -F= '{print $2}'|awk -F: '{print $2}'` - fi -done -if [ "$destiny" != "discover" ]; then #we aren't discoverying, we probably can and should get a cert - /bin/getcert $XCATMASTER:$XCATPORT -fi -while :; do - if [ -z "$destiny" ]; then - destiny=`getdestiny $XCATMASTER:$XCATPORT` - fi - destparameter=`echo $destiny|awk -F= '{print $2}'` - destiny=`echo $destiny|awk -F= '{print $1}'` - dest=`echo $destiny|awk '{print $1}'` #could probably use bash but oh well - if [ "$dest" = "discover" ]; then #skip a query to xCAT when /proc/cmdline will do - /bin/dodiscovery - /bin/getcert $XCATMASTER:$XCATPORT - destiny='' - dest='' - elif [ "$dest" = shell ]; then - echo "Dropping to debug shell, exit to check for further action" - destiny='' - dest='' - /bin/bash - elif [ "$dest" = runcmd ]; then - destiny=`/bin/nextdestiny $XCATMASTER:$XCATPORT` - dest=`echo $destiny|awk -F= '{print $1}'` - $destparameter - elif [ "$dest" = runimage ]; then - destiny=`/bin/nextdestiny $XCATMASTER:$XCATPORT` - dest=`echo $destiny|awk -F= '{print $1}'` - mkdir /tmp/`basename $destparameter` - cd /tmp/`basename $destparameter` - ERROR=`wget $destparameter 2>&1` - while [ $? == 1 ] && echo $ERROR|grep -v 416; do - sleep 10 - ERROR=`wget -c $destparameter 2>&1` - done - tar xvf `basename $destparameter` - ./runme.sh - cd - - elif [ "$dest" = "reboot" -o "$dest" = "boot" ]; then - /bin/nextdestiny $XCATMASTER:$XCATPORT - reboot -f - elif [ "$dest" = "install" -o "$dest" = "netboot" ]; then - reboot -f - elif [ "$dest" = standby ]; then - destiny='' - dest='' - delay=$((30+$RANDOM%270)) - while [ $delay -gt 0 ]; do - echo -en "Received request to retry in a bit, will call xCAT back in $delay seconds \r" - delay=$((delay-1)) - sleep 1 - done - echo "Retrying "; - else - echo "Unrecognized directive $dest" - destiny='' - dest='' - delay=$((30+$RANDOM%270)) - while [ $delay -gt 0 ]; do - echo -en "Will retry in $delay seconds \r" - delay=$((delay-1)) - sleep 1 - done - - fi -done diff --git a/xCAT-nbroot2/getcert b/xCAT-nbroot2/getcert deleted file mode 100755 index f00ffc5b9..000000000 --- a/xCAT-nbroot2/getcert +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -allowcred.awk & -CREDPID=$! -if [ -z "$XCATDEST" ]; then - XCATDEST=$1 -fi -#retry in case certkey.pem is not right, yet -while ! openssl req -new -key /etc/xcat/certkey.pem -out /tmp/tls.csr -subj "/CN=`hostname`" >& /dev/null; do - sleep 1 -done -echo " -getcredentials -x509cert -300 -" > /tmp/certreq.xml -cat /tmp/tls.csr >> /tmp/certreq.xml -echo " - - -" >> /tmp/certreq.xml -openssl dgst -sha512 -out /tmp/certreq.sha512 -sign /etc/xcat/privkey.pem /tmp/certreq.xml #chain off the switch published key -openssl enc -e -a -in /tmp/certreq.sha512 > /tmp/certreq.b64sig -cat /tmp/certreq.xml |while read line; do - if [ "$line" = "" ]; then - cat /tmp/certreq.b64sig >> /tmp/certreq.xml.new - fi - echo $line >> /tmp/certreq.xml.new -done -mv /tmp/certreq.xml.new /tmp/certreq.xml -rm /tmp/certreq.b64sig /tmp/certreq.sha512 -cat /tmp/certreq.xml | openssl s_client -connect $XCATDEST -quiet 2> /dev/null > /tmp/certresp.xml -if grep 'BEGIN CERTIFICATE' /tmp/certresp.xml > /dev/null; then - awk '/BEGIN CERTIFICATE/,/END CERTIFICATE/' < /tmp/certresp.xml > /etc/xcat/cert.pem - #stop transmitting sysDesc, allowing the public key to age out of validity - for iface in `grep '^ e' /var/lib/lldpad/lldpad.conf|awk '{print $1}' `; do - lldptool -T -i $iface -V sysDesc enableTx=no >& /dev/null - done -fi -rm /tmp/certreq.xml -rm /tmp/certresp.xml -kill $CREDPID diff --git a/xCAT-nbroot2/getdestiny b/xCAT-nbroot2/getdestiny deleted file mode 100755 index 15cfc1baa..000000000 --- a/xCAT-nbroot2/getdestiny +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash -if [ -z "$XCATDEST" ]; then - XCATDEST=$1 -fi -echo " -getdestiny -300 -" > /tmp/destreq.xml -if [ -f /tmp/destiny.xml ]; then rm /tmp/destiny.xml; fi -while [ ! -f /tmp/destiny.xml ] || grep error /tmp/destiny.xml; do - if [ -f /tmp/destiny.xml ]; then - timer=60 - while [ $timer -gt 0 ]; do - echo -en "Retrying in $timer seconds \r" >&2 - sleep 1 - timer=$(($timer-1)); - done - fi - echo " " >&2 - if [ -f /etc/xcat/cert.pem -a -f /etc/xcat/certkey.pem ]; then #use client cert if available - cat /tmp/destreq.xml | openssl s_client -key /etc/xcat/certkey.pem -cert /etc/xcat/cert.pem -connect $XCATDEST -quiet 2> /dev/null > /tmp/destiny.xml - else - cat /tmp/destreq.xml | openssl s_client -connect $XCATDEST -quiet 2> /dev/null > /tmp/destiny.xml - fi -done -rm /tmp/destreq.xml -DESTINY=`grep '' /tmp/destiny.xml | awk -F'>' '{print $2}'|awk -F'<' '{print $1}'` -rm /tmp/destiny.xml -echo $DESTINY - diff --git a/xCAT-nbroot2/getipmi b/xCAT-nbroot2/getipmi deleted file mode 100755 index 5e9af2590..000000000 --- a/xCAT-nbroot2/getipmi +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -allowcred.awk & -CREDPID=$! -if [ -z "$XCATDEST" ]; then - XCATDEST=$1 -fi -if [ -z "$XCATDEST" ]; then - for parm in `cat /proc/cmdline` ; do - if echo $parm |grep xcatd= > /dev/null; then - XCATDEST=`echo $parm |awk -F= '{print $2}'` - fi - done -fi -for LANCHAN in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do - if ipmitool channel info $LANCHAN 2> /dev/null | grep 802.3 > /dev/null 2>&1 && ipmitool raw 0xc 2 $LANCHAN 5 0 0 > /dev/null 2>&1; - then break; - fi; -done -BMCMAC=`ipmitool lan print $LANCHAN|grep ^MAC|awk '{print $4}'` #bmcconfig may opt to use DHCP, if so we need to feed up the mac address -#TODO: need a way to get the DUID the service processor may use, perhaps reserve that for 'ibmsetup' since spec doesn't touch ipv6? - -echo " -getbmcconfig -300 -$BMCMAC -" > /tmp/bmcreq.xml -rm /tmp/ipmicfg.xml -while [ ! -f /tmp/ipmicfg.xml ] || grep error /tmp/ipmicfg.xml; do - if [ -f /tmp/ipmicfg.xml ]; then - timer=60 - while [ $timer -gt 0 ]; do - sleep 1 - echo -en "Retrying in $timer seconds \r" - timer=$(($timer-1)); - done - fi - echo -en " \r"; - - if [ -f /etc/xcat/cert.pem -a -f /etc/xcat/certkey.pem ]; then #use client cert if available - cat /tmp/bmcreq.xml | openssl s_client -key /etc/xcat/certkey.pem -cert /etc/xcat/cert.pem -connect $XCATDEST -quiet 2> /dev/null > /tmp/ipmicfg.xml - else - cat /tmp/bmcreq.xml | openssl s_client -connect $XCATDEST -quiet 2> /dev/null > /tmp/ipmicfg.xml - fi -done -rm /tmp/bmcreq.xml -kill $CREDPID diff --git a/xCAT-nbroot2/ifup b/xCAT-nbroot2/ifup deleted file mode 100755 index e5d7491e5..000000000 --- a/xCAT-nbroot2/ifup +++ /dev/null @@ -1,4 +0,0 @@ -if [ "${1%?}" = "usb" ]; then - /sbin/setupimmnic -fi -exit 0 diff --git a/xCAT-nbroot2/install b/xCAT-nbroot2/install deleted file mode 100755 index 83de7d97c..000000000 --- a/xCAT-nbroot2/install +++ /dev/null @@ -1,639 +0,0 @@ -#!/bin/sh -echo $drivers -dracut_install wget openssl tar mstflint ipmitool cpio gzip lsmod ethtool modprobe touch echo cut wc -dracut_install netstat # broadcom update requires -dracut_install uniq # mellanox update requires -dracut_install grep ip hostname awk egrep grep dirname expr -dracut_install mount.nfs sshd vi reboot lspci parted screen mkfs mkfs.ext4 mkfs.btrfs -dracut_install efibootmgr -#dracut_install libvirtd /usr/share/libvirt/cpu_map.xml /usr/bin/qemu-img /usr/libexec/qemu-kvm -dracut_install mkswap df brctl vconfig ifenslave ssh-keygen scp clear dhclient lldpad -dracut_install lldptool /lib64/libnss_dns-2.12.so /lib64/libnss_dns.so.2 -dracut_install poweroff ntpq ntpd hwclock date /usr/share/terminfo/x/xterm /etc/nsswitch.conf /etc/services -dracut_install /sbin/rsyslogd /etc/protocols umount /bin/rpm /usr/lib/rpm/rpmrc -dracut_install chmod /lib/libc.so.6 /lib/ld-linux.so.2 /lib/libdl.so.2 /lib/libm.so.6 /sbin/route /sbin/ifconfig /usr/bin/head /etc/redhat-release ping tr lsusb /usr/share/hwdata/usb.ids #ibm fw wrapper requirements -dracut_install dmidecode /usr/lib64/libstdc++.so.6 #uxspi prereqs, but will use dmidecode to improve decision on loading ipmi_si -dracut_install dmidecode /usr/lib64/libstdc++.so.5 #broadcom firmware update links against old lib -dracut_install /lib/libpthread.so.0 #32 bit lib because UXSPI will not ship a native 64 bit build -dracut_install /lib/libncurses.so.5.7 /usr/lib/libstdc++.so.6.0.13 /lib/libgcc_s.so.1 /lib/libtinfo.so.5.7 -dracut_install /lib64/libldap-2.4.so.2 /lib64/liblber-2.4.so.2 /usr/lib64/libsasl2.so.2 #uxspi has incurred these... -dracut_install /usr/share/zoneinfo/posix/Zulu -dracut_install /usr/share/zoneinfo/posix/GMT-0 -dracut_install /usr/share/zoneinfo/posix/Europe/Istanbul -dracut_install /usr/share/zoneinfo/posix/Europe/San_Marino -dracut_install /usr/share/zoneinfo/posix/Europe/Jersey -dracut_install /usr/share/zoneinfo/posix/Europe/Bucharest -dracut_install /usr/share/zoneinfo/posix/Europe/Gibraltar -dracut_install /usr/share/zoneinfo/posix/Europe/Uzhgorod -dracut_install /usr/share/zoneinfo/posix/Europe/Moscow -dracut_install /usr/share/zoneinfo/posix/Europe/Brussels -dracut_install /usr/share/zoneinfo/posix/Europe/Nicosia -dracut_install /usr/share/zoneinfo/posix/Europe/Zurich -dracut_install /usr/share/zoneinfo/posix/Europe/Berlin -dracut_install /usr/share/zoneinfo/posix/Europe/Guernsey -dracut_install /usr/share/zoneinfo/posix/Europe/Budapest -dracut_install /usr/share/zoneinfo/posix/Europe/Kiev -dracut_install /usr/share/zoneinfo/posix/Europe/Podgorica -dracut_install /usr/share/zoneinfo/posix/Europe/Isle_of_Man -dracut_install /usr/share/zoneinfo/posix/Europe/Mariehamn -dracut_install /usr/share/zoneinfo/posix/Europe/Belgrade -dracut_install /usr/share/zoneinfo/posix/Europe/Belfast -dracut_install /usr/share/zoneinfo/posix/Europe/Ljubljana -dracut_install /usr/share/zoneinfo/posix/Europe/Chisinau -dracut_install /usr/share/zoneinfo/posix/Europe/Andorra -dracut_install /usr/share/zoneinfo/posix/Europe/Athens -dracut_install /usr/share/zoneinfo/posix/Europe/Stockholm -dracut_install /usr/share/zoneinfo/posix/Europe/Vienna -dracut_install /usr/share/zoneinfo/posix/Europe/Lisbon -dracut_install /usr/share/zoneinfo/posix/Europe/London -dracut_install /usr/share/zoneinfo/posix/Europe/Paris -dracut_install /usr/share/zoneinfo/posix/Europe/Oslo -dracut_install /usr/share/zoneinfo/posix/Europe/Zagreb -dracut_install /usr/share/zoneinfo/posix/Europe/Helsinki -dracut_install /usr/share/zoneinfo/posix/Europe/Warsaw -dracut_install /usr/share/zoneinfo/posix/Europe/Copenhagen -dracut_install /usr/share/zoneinfo/posix/Europe/Riga -dracut_install /usr/share/zoneinfo/posix/Europe/Vaduz -dracut_install /usr/share/zoneinfo/posix/Europe/Vilnius -dracut_install /usr/share/zoneinfo/posix/Europe/Volgograd -dracut_install /usr/share/zoneinfo/posix/Europe/Amsterdam -dracut_install /usr/share/zoneinfo/posix/Europe/Tiraspol -dracut_install /usr/share/zoneinfo/posix/Europe/Tallinn -dracut_install /usr/share/zoneinfo/posix/Europe/Kaliningrad -dracut_install /usr/share/zoneinfo/posix/Europe/Malta -dracut_install /usr/share/zoneinfo/posix/Europe/Sarajevo -dracut_install /usr/share/zoneinfo/posix/Europe/Madrid -dracut_install /usr/share/zoneinfo/posix/Europe/Zaporozhye -dracut_install /usr/share/zoneinfo/posix/Europe/Simferopol -dracut_install /usr/share/zoneinfo/posix/Europe/Sofia -dracut_install /usr/share/zoneinfo/posix/Europe/Skopje -dracut_install /usr/share/zoneinfo/posix/Europe/Monaco -dracut_install /usr/share/zoneinfo/posix/Europe/Rome -dracut_install /usr/share/zoneinfo/posix/Europe/Prague -dracut_install /usr/share/zoneinfo/posix/Europe/Luxembourg -dracut_install /usr/share/zoneinfo/posix/Europe/Minsk -dracut_install /usr/share/zoneinfo/posix/Europe/Vatican -dracut_install /usr/share/zoneinfo/posix/Europe/Dublin -dracut_install /usr/share/zoneinfo/posix/Europe/Samara -dracut_install /usr/share/zoneinfo/posix/Europe/Tirane -dracut_install /usr/share/zoneinfo/posix/Europe/Bratislava -dracut_install /usr/share/zoneinfo/posix/Greenwich -dracut_install /usr/share/zoneinfo/posix/US/Indiana-Starke -dracut_install /usr/share/zoneinfo/posix/US/Alaska -dracut_install /usr/share/zoneinfo/posix/US/Michigan -dracut_install /usr/share/zoneinfo/posix/US/Aleutian -dracut_install /usr/share/zoneinfo/posix/US/Hawaii -dracut_install /usr/share/zoneinfo/posix/US/Central -dracut_install /usr/share/zoneinfo/posix/US/Eastern -dracut_install /usr/share/zoneinfo/posix/US/Pacific -dracut_install /usr/share/zoneinfo/posix/US/Samoa -dracut_install /usr/share/zoneinfo/posix/US/Mountain -dracut_install /usr/share/zoneinfo/posix/US/Arizona -dracut_install /usr/share/zoneinfo/posix/US/East-Indiana -dracut_install /usr/share/zoneinfo/posix/EST -dracut_install /usr/share/zoneinfo/posix/HST -dracut_install /usr/share/zoneinfo/posix/Eire -dracut_install /usr/share/zoneinfo/posix/America/Cancun -dracut_install /usr/share/zoneinfo/posix/America/Santo_Domingo -dracut_install /usr/share/zoneinfo/posix/America/Jujuy -dracut_install /usr/share/zoneinfo/posix/America/Guatemala -dracut_install /usr/share/zoneinfo/posix/America/Monterrey -dracut_install /usr/share/zoneinfo/posix/America/Ensenada -dracut_install /usr/share/zoneinfo/posix/America/Dawson_Creek -dracut_install /usr/share/zoneinfo/posix/America/Mendoza -dracut_install /usr/share/zoneinfo/posix/America/Coral_Harbour -dracut_install /usr/share/zoneinfo/posix/America/Martinique -dracut_install /usr/share/zoneinfo/posix/America/Cordoba -dracut_install /usr/share/zoneinfo/posix/America/Recife -dracut_install /usr/share/zoneinfo/posix/America/Cayman -dracut_install /usr/share/zoneinfo/posix/America/Shiprock -dracut_install /usr/share/zoneinfo/posix/America/Tortola -dracut_install /usr/share/zoneinfo/posix/America/Lima -dracut_install /usr/share/zoneinfo/posix/America/Antigua -dracut_install /usr/share/zoneinfo/posix/America/Blanc-Sablon -dracut_install /usr/share/zoneinfo/posix/America/Nipigon -dracut_install /usr/share/zoneinfo/posix/America/Nome -dracut_install /usr/share/zoneinfo/posix/America/Montserrat -dracut_install /usr/share/zoneinfo/posix/America/Atka -dracut_install /usr/share/zoneinfo/posix/America/St_Thomas -dracut_install /usr/share/zoneinfo/posix/America/Halifax -dracut_install /usr/share/zoneinfo/posix/America/Montreal -dracut_install /usr/share/zoneinfo/posix/America/Curacao -dracut_install /usr/share/zoneinfo/posix/America/Cuiaba -dracut_install /usr/share/zoneinfo/posix/America/Winnipeg -dracut_install /usr/share/zoneinfo/posix/America/North_Dakota/New_Salem -dracut_install /usr/share/zoneinfo/posix/America/North_Dakota/Center -dracut_install /usr/share/zoneinfo/posix/America/Panama -dracut_install /usr/share/zoneinfo/posix/America/Rosario -dracut_install /usr/share/zoneinfo/posix/America/Anguilla -dracut_install /usr/share/zoneinfo/posix/America/Ojinaga -dracut_install /usr/share/zoneinfo/posix/America/Guyana -dracut_install /usr/share/zoneinfo/posix/America/Eirunepe -dracut_install /usr/share/zoneinfo/posix/America/Grand_Turk -dracut_install /usr/share/zoneinfo/posix/America/Rio_Branco -dracut_install /usr/share/zoneinfo/posix/America/Santa_Isabel -dracut_install /usr/share/zoneinfo/posix/America/Scoresbysund -dracut_install /usr/share/zoneinfo/posix/America/Adak -dracut_install /usr/share/zoneinfo/posix/America/Menominee -dracut_install /usr/share/zoneinfo/posix/America/Resolute -dracut_install /usr/share/zoneinfo/posix/America/Guadeloupe -dracut_install /usr/share/zoneinfo/posix/America/Indianapolis -dracut_install /usr/share/zoneinfo/posix/America/Vancouver -dracut_install /usr/share/zoneinfo/posix/America/Glace_Bay -dracut_install /usr/share/zoneinfo/posix/America/Buenos_Aires -dracut_install /usr/share/zoneinfo/posix/America/Virgin -dracut_install /usr/share/zoneinfo/posix/America/Belem -dracut_install /usr/share/zoneinfo/posix/America/Catamarca -dracut_install /usr/share/zoneinfo/posix/America/Bahia -dracut_install /usr/share/zoneinfo/posix/America/Fort_Wayne -dracut_install /usr/share/zoneinfo/posix/America/Hermosillo -dracut_install /usr/share/zoneinfo/posix/America/Rankin_Inlet -dracut_install /usr/share/zoneinfo/posix/America/Mexico_City -dracut_install /usr/share/zoneinfo/posix/America/Belize -dracut_install /usr/share/zoneinfo/posix/America/Maceio -dracut_install /usr/share/zoneinfo/posix/America/Dominica -dracut_install /usr/share/zoneinfo/posix/America/Swift_Current -dracut_install /usr/share/zoneinfo/posix/America/St_Johns -dracut_install /usr/share/zoneinfo/posix/America/St_Barthelemy -dracut_install /usr/share/zoneinfo/posix/America/Yellowknife -dracut_install /usr/share/zoneinfo/posix/America/Costa_Rica -dracut_install /usr/share/zoneinfo/posix/America/Pangnirtung -dracut_install /usr/share/zoneinfo/posix/America/Bogota -dracut_install /usr/share/zoneinfo/posix/America/Port-au-Prince -dracut_install /usr/share/zoneinfo/posix/America/Phoenix -dracut_install /usr/share/zoneinfo/posix/America/Port_of_Spain -dracut_install /usr/share/zoneinfo/posix/America/Matamoros -dracut_install /usr/share/zoneinfo/posix/America/Puerto_Rico -dracut_install /usr/share/zoneinfo/posix/America/Detroit -dracut_install /usr/share/zoneinfo/posix/America/Edmonton -dracut_install /usr/share/zoneinfo/posix/America/Toronto -dracut_install /usr/share/zoneinfo/posix/America/Cambridge_Bay -dracut_install /usr/share/zoneinfo/posix/America/Godthab -dracut_install /usr/share/zoneinfo/posix/America/Atikokan -dracut_install /usr/share/zoneinfo/posix/America/Juneau -dracut_install /usr/share/zoneinfo/posix/America/Managua -dracut_install /usr/share/zoneinfo/posix/America/Anchorage -dracut_install /usr/share/zoneinfo/posix/America/Merida -dracut_install /usr/share/zoneinfo/posix/America/Thunder_Bay -dracut_install /usr/share/zoneinfo/posix/America/Porto_Velho -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Jujuy -dracut_install /usr/share/zoneinfo/posix/America/Argentina/La_Rioja -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Mendoza -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Cordoba -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Ushuaia -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Rio_Gallegos -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Buenos_Aires -dracut_install /usr/share/zoneinfo/posix/America/Argentina/San_Juan -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Catamarca -dracut_install /usr/share/zoneinfo/posix/America/Argentina/San_Luis -dracut_install /usr/share/zoneinfo/posix/America/Argentina/ComodRivadavia -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Salta -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Tucuman -dracut_install /usr/share/zoneinfo/posix/America/Iqaluit -dracut_install /usr/share/zoneinfo/posix/America/Chicago -dracut_install /usr/share/zoneinfo/posix/America/Miquelon -dracut_install /usr/share/zoneinfo/posix/America/Havana -dracut_install /usr/share/zoneinfo/posix/America/Guayaquil -dracut_install /usr/share/zoneinfo/posix/America/St_Vincent -dracut_install /usr/share/zoneinfo/posix/America/St_Lucia -dracut_install /usr/share/zoneinfo/posix/America/Boise -dracut_install /usr/share/zoneinfo/posix/America/Yakutat -dracut_install /usr/share/zoneinfo/posix/America/Santarem -dracut_install /usr/share/zoneinfo/posix/America/Campo_Grande -dracut_install /usr/share/zoneinfo/posix/America/Santiago -dracut_install /usr/share/zoneinfo/posix/America/Porto_Acre -dracut_install /usr/share/zoneinfo/posix/America/Sao_Paulo -dracut_install /usr/share/zoneinfo/posix/America/Thule -dracut_install /usr/share/zoneinfo/posix/America/New_York -dracut_install /usr/share/zoneinfo/posix/America/Nassau -dracut_install /usr/share/zoneinfo/posix/America/Dawson -dracut_install /usr/share/zoneinfo/posix/America/Louisville -dracut_install /usr/share/zoneinfo/posix/America/Asuncion -dracut_install /usr/share/zoneinfo/posix/America/Inuvik -dracut_install /usr/share/zoneinfo/posix/America/Paramaribo -dracut_install /usr/share/zoneinfo/posix/America/Chihuahua -dracut_install /usr/share/zoneinfo/posix/America/Mazatlan -dracut_install /usr/share/zoneinfo/posix/America/Grenada -dracut_install /usr/share/zoneinfo/posix/America/Denver -dracut_install /usr/share/zoneinfo/posix/America/Los_Angeles -dracut_install /usr/share/zoneinfo/posix/America/Marigot -dracut_install /usr/share/zoneinfo/posix/America/Manaus -dracut_install /usr/share/zoneinfo/posix/America/Regina -dracut_install /usr/share/zoneinfo/posix/America/Barbados -dracut_install /usr/share/zoneinfo/posix/America/Noronha -dracut_install /usr/share/zoneinfo/posix/America/Montevideo -dracut_install /usr/share/zoneinfo/posix/America/Caracas -dracut_install /usr/share/zoneinfo/posix/America/Rainy_River -dracut_install /usr/share/zoneinfo/posix/America/La_Paz -dracut_install /usr/share/zoneinfo/posix/America/Jamaica -dracut_install /usr/share/zoneinfo/posix/America/Moncton -dracut_install /usr/share/zoneinfo/posix/America/Whitehorse -dracut_install /usr/share/zoneinfo/posix/America/Fortaleza -dracut_install /usr/share/zoneinfo/posix/America/Kentucky/Monticello -dracut_install /usr/share/zoneinfo/posix/America/Kentucky/Louisville -dracut_install /usr/share/zoneinfo/posix/America/Indiana/Marengo -dracut_install /usr/share/zoneinfo/posix/America/Indiana/Indianapolis -dracut_install /usr/share/zoneinfo/posix/America/Indiana/Knox -dracut_install /usr/share/zoneinfo/posix/America/Indiana/Tell_City -dracut_install /usr/share/zoneinfo/posix/America/Indiana/Petersburg -dracut_install /usr/share/zoneinfo/posix/America/Indiana/Winamac -dracut_install /usr/share/zoneinfo/posix/America/Indiana/Vincennes -dracut_install /usr/share/zoneinfo/posix/America/Indiana/Vevay -dracut_install /usr/share/zoneinfo/posix/America/Danmarkshavn -dracut_install /usr/share/zoneinfo/posix/America/St_Kitts -dracut_install /usr/share/zoneinfo/posix/America/Aruba -dracut_install /usr/share/zoneinfo/posix/America/Boa_Vista -dracut_install /usr/share/zoneinfo/posix/America/Bahia_Banderas -dracut_install /usr/share/zoneinfo/posix/America/Tegucigalpa -dracut_install /usr/share/zoneinfo/posix/America/Araguaina -dracut_install /usr/share/zoneinfo/posix/America/El_Salvador -dracut_install /usr/share/zoneinfo/posix/America/Cayenne -dracut_install /usr/share/zoneinfo/posix/America/Tijuana -dracut_install /usr/share/zoneinfo/posix/America/Knox_IN -dracut_install /usr/share/zoneinfo/posix/America/Goose_Bay -dracut_install /usr/share/zoneinfo/posix/EET -dracut_install /usr/share/zoneinfo/posix/EST5EDT -dracut_install /usr/share/zoneinfo/posix/Mideast/Riyadh89 -dracut_install /usr/share/zoneinfo/posix/Mideast/Riyadh88 -dracut_install /usr/share/zoneinfo/posix/Mideast/Riyadh87 -dracut_install /usr/share/zoneinfo/posix/MST -dracut_install /usr/share/zoneinfo/posix/Iceland -dracut_install /usr/share/zoneinfo/posix/Atlantic/Faeroe -dracut_install /usr/share/zoneinfo/posix/Atlantic/Stanley -dracut_install /usr/share/zoneinfo/posix/Atlantic/Reykjavik -dracut_install /usr/share/zoneinfo/posix/Atlantic/St_Helena -dracut_install /usr/share/zoneinfo/posix/Atlantic/Faroe -dracut_install /usr/share/zoneinfo/posix/Atlantic/South_Georgia -dracut_install /usr/share/zoneinfo/posix/Atlantic/Jan_Mayen -dracut_install /usr/share/zoneinfo/posix/Atlantic/Azores -dracut_install /usr/share/zoneinfo/posix/Atlantic/Cape_Verde -dracut_install /usr/share/zoneinfo/posix/Atlantic/Madeira -dracut_install /usr/share/zoneinfo/posix/Atlantic/Bermuda -dracut_install /usr/share/zoneinfo/posix/Atlantic/Canary -dracut_install /usr/share/zoneinfo/posix/GMT0 -dracut_install /usr/share/zoneinfo/posix/Poland -dracut_install /usr/share/zoneinfo/posix/Indian/Chagos -dracut_install /usr/share/zoneinfo/posix/Indian/Maldives -dracut_install /usr/share/zoneinfo/posix/Indian/Comoro -dracut_install /usr/share/zoneinfo/posix/Indian/Mauritius -dracut_install /usr/share/zoneinfo/posix/Indian/Mayotte -dracut_install /usr/share/zoneinfo/posix/Indian/Christmas -dracut_install /usr/share/zoneinfo/posix/Indian/Antananarivo -dracut_install /usr/share/zoneinfo/posix/Indian/Kerguelen -dracut_install /usr/share/zoneinfo/posix/Indian/Mahe -dracut_install /usr/share/zoneinfo/posix/Indian/Cocos -dracut_install /usr/share/zoneinfo/posix/Indian/Reunion -dracut_install /usr/share/zoneinfo/posix/Mexico/BajaNorte -dracut_install /usr/share/zoneinfo/posix/Mexico/BajaSur -dracut_install /usr/share/zoneinfo/posix/Mexico/General -dracut_install /usr/share/zoneinfo/posix/Turkey -dracut_install /usr/share/zoneinfo/posix/Egypt -dracut_install /usr/share/zoneinfo/posix/Hongkong -dracut_install /usr/share/zoneinfo/posix/GB -dracut_install /usr/share/zoneinfo/posix/GMT+0 -dracut_install /usr/share/zoneinfo/posix/ROK -dracut_install /usr/share/zoneinfo/posix/Antarctica/Mawson -dracut_install /usr/share/zoneinfo/posix/Antarctica/Macquarie -dracut_install /usr/share/zoneinfo/posix/Antarctica/South_Pole -dracut_install /usr/share/zoneinfo/posix/Antarctica/Rothera -dracut_install /usr/share/zoneinfo/posix/Antarctica/Davis -dracut_install /usr/share/zoneinfo/posix/Antarctica/DumontDUrville -dracut_install /usr/share/zoneinfo/posix/Antarctica/McMurdo -dracut_install /usr/share/zoneinfo/posix/Antarctica/Casey -dracut_install /usr/share/zoneinfo/posix/Antarctica/Vostok -dracut_install /usr/share/zoneinfo/posix/Antarctica/Palmer -dracut_install /usr/share/zoneinfo/posix/Antarctica/Syowa -dracut_install /usr/share/zoneinfo/posix/Universal -dracut_install /usr/share/zoneinfo/posix/CET -dracut_install /usr/share/zoneinfo/posix/WET -dracut_install /usr/share/zoneinfo/posix/Navajo -dracut_install /usr/share/zoneinfo/posix/UTC -dracut_install /usr/share/zoneinfo/posix/Pacific/Enderbury -dracut_install /usr/share/zoneinfo/posix/Pacific/Johnston -dracut_install /usr/share/zoneinfo/posix/Pacific/Pago_Pago -dracut_install /usr/share/zoneinfo/posix/Pacific/Saipan -dracut_install /usr/share/zoneinfo/posix/Pacific/Norfolk -dracut_install /usr/share/zoneinfo/posix/Pacific/Chuuk -dracut_install /usr/share/zoneinfo/posix/Pacific/Galapagos -dracut_install /usr/share/zoneinfo/posix/Pacific/Palau -dracut_install /usr/share/zoneinfo/posix/Pacific/Tarawa -dracut_install /usr/share/zoneinfo/posix/Pacific/Fakaofo -dracut_install /usr/share/zoneinfo/posix/Pacific/Rarotonga -dracut_install /usr/share/zoneinfo/posix/Pacific/Wake -dracut_install /usr/share/zoneinfo/posix/Pacific/Kosrae -dracut_install /usr/share/zoneinfo/posix/Pacific/Tahiti -dracut_install /usr/share/zoneinfo/posix/Pacific/Fiji -dracut_install /usr/share/zoneinfo/posix/Pacific/Ponape -dracut_install /usr/share/zoneinfo/posix/Pacific/Tongatapu -dracut_install /usr/share/zoneinfo/posix/Pacific/Efate -dracut_install /usr/share/zoneinfo/posix/Pacific/Honolulu -dracut_install /usr/share/zoneinfo/posix/Pacific/Niue -dracut_install /usr/share/zoneinfo/posix/Pacific/Kwajalein -dracut_install /usr/share/zoneinfo/posix/Pacific/Guam -dracut_install /usr/share/zoneinfo/posix/Pacific/Funafuti -dracut_install /usr/share/zoneinfo/posix/Pacific/Majuro -dracut_install /usr/share/zoneinfo/posix/Pacific/Midway -dracut_install /usr/share/zoneinfo/posix/Pacific/Nauru -dracut_install /usr/share/zoneinfo/posix/Pacific/Samoa -dracut_install /usr/share/zoneinfo/posix/Pacific/Marquesas -dracut_install /usr/share/zoneinfo/posix/Pacific/Kiritimati -dracut_install /usr/share/zoneinfo/posix/Pacific/Noumea -dracut_install /usr/share/zoneinfo/posix/Pacific/Truk -dracut_install /usr/share/zoneinfo/posix/Pacific/Guadalcanal -dracut_install /usr/share/zoneinfo/posix/Pacific/Pohnpei -dracut_install /usr/share/zoneinfo/posix/Pacific/Pitcairn -dracut_install /usr/share/zoneinfo/posix/Pacific/Port_Moresby -dracut_install /usr/share/zoneinfo/posix/Pacific/Yap -dracut_install /usr/share/zoneinfo/posix/Pacific/Easter -dracut_install /usr/share/zoneinfo/posix/Pacific/Wallis -dracut_install /usr/share/zoneinfo/posix/Pacific/Apia -dracut_install /usr/share/zoneinfo/posix/Pacific/Auckland -dracut_install /usr/share/zoneinfo/posix/Pacific/Gambier -dracut_install /usr/share/zoneinfo/posix/Pacific/Chatham -dracut_install /usr/share/zoneinfo/posix/Japan -dracut_install /usr/share/zoneinfo/posix/Libya -dracut_install /usr/share/zoneinfo/posix/ROC -dracut_install /usr/share/zoneinfo/posix/Iran -dracut_install /usr/share/zoneinfo/posix/Brazil/West -dracut_install /usr/share/zoneinfo/posix/Brazil/East -dracut_install /usr/share/zoneinfo/posix/Brazil/Acre -dracut_install /usr/share/zoneinfo/posix/Brazil/DeNoronha -dracut_install /usr/share/zoneinfo/posix/Arctic/Longyearbyen -dracut_install /usr/share/zoneinfo/posix/Portugal -dracut_install /usr/share/zoneinfo/posix/MET -dracut_install /usr/share/zoneinfo/posix/W-SU -dracut_install /usr/share/zoneinfo/posix/Kwajalein -dracut_install /usr/share/zoneinfo/posix/CST6CDT -dracut_install /usr/share/zoneinfo/posix/GB-Eire -dracut_install /usr/share/zoneinfo/posix/Australia/Melbourne -dracut_install /usr/share/zoneinfo/posix/Australia/Broken_Hill -dracut_install /usr/share/zoneinfo/posix/Australia/Queensland -dracut_install /usr/share/zoneinfo/posix/Australia/South -dracut_install /usr/share/zoneinfo/posix/Australia/Eucla -dracut_install /usr/share/zoneinfo/posix/Australia/Yancowinna -dracut_install /usr/share/zoneinfo/posix/Australia/Lord_Howe -dracut_install /usr/share/zoneinfo/posix/Australia/Hobart -dracut_install /usr/share/zoneinfo/posix/Australia/NSW -dracut_install /usr/share/zoneinfo/posix/Australia/West -dracut_install /usr/share/zoneinfo/posix/Australia/LHI -dracut_install /usr/share/zoneinfo/posix/Australia/Perth -dracut_install /usr/share/zoneinfo/posix/Australia/ACT -dracut_install /usr/share/zoneinfo/posix/Australia/Darwin -dracut_install /usr/share/zoneinfo/posix/Australia/Lindeman -dracut_install /usr/share/zoneinfo/posix/Australia/Sydney -dracut_install /usr/share/zoneinfo/posix/Australia/North -dracut_install /usr/share/zoneinfo/posix/Australia/Canberra -dracut_install /usr/share/zoneinfo/posix/Australia/Adelaide -dracut_install /usr/share/zoneinfo/posix/Australia/Brisbane -dracut_install /usr/share/zoneinfo/posix/Australia/Victoria -dracut_install /usr/share/zoneinfo/posix/Australia/Tasmania -dracut_install /usr/share/zoneinfo/posix/Australia/Currie -dracut_install /usr/share/zoneinfo/posix/UCT -dracut_install /usr/share/zoneinfo/posix/Cuba -dracut_install /usr/share/zoneinfo/posix/Singapore -dracut_install /usr/share/zoneinfo/posix/GMT -dracut_install /usr/share/zoneinfo/posix/NZ-CHAT -dracut_install /usr/share/zoneinfo/posix/Asia/Istanbul -dracut_install /usr/share/zoneinfo/posix/Asia/Kuwait -dracut_install /usr/share/zoneinfo/posix/Asia/Saigon -dracut_install /usr/share/zoneinfo/posix/Asia/Riyadh89 -dracut_install /usr/share/zoneinfo/posix/Asia/Urumqi -dracut_install /usr/share/zoneinfo/posix/Asia/Brunei -dracut_install /usr/share/zoneinfo/posix/Asia/Ujung_Pandang -dracut_install /usr/share/zoneinfo/posix/Asia/Muscat -dracut_install /usr/share/zoneinfo/posix/Asia/Kashgar -dracut_install /usr/share/zoneinfo/posix/Asia/Kamchatka -dracut_install /usr/share/zoneinfo/posix/Asia/Manila -dracut_install /usr/share/zoneinfo/posix/Asia/Vladivostok -dracut_install /usr/share/zoneinfo/posix/Asia/Jayapura -dracut_install /usr/share/zoneinfo/posix/Asia/Magadan -dracut_install /usr/share/zoneinfo/posix/Asia/Almaty -dracut_install /usr/share/zoneinfo/posix/Asia/Qyzylorda -dracut_install /usr/share/zoneinfo/posix/Asia/Anadyr -dracut_install /usr/share/zoneinfo/posix/Asia/Nicosia -dracut_install /usr/share/zoneinfo/posix/Asia/Kathmandu -dracut_install /usr/share/zoneinfo/posix/Asia/Qatar -dracut_install /usr/share/zoneinfo/posix/Asia/Jerusalem -dracut_install /usr/share/zoneinfo/posix/Asia/Yakutsk -dracut_install /usr/share/zoneinfo/posix/Asia/Karachi -dracut_install /usr/share/zoneinfo/posix/Asia/Samarkand -dracut_install /usr/share/zoneinfo/posix/Asia/Kolkata -dracut_install /usr/share/zoneinfo/posix/Asia/Ulaanbaatar -dracut_install /usr/share/zoneinfo/posix/Asia/Irkutsk -dracut_install /usr/share/zoneinfo/posix/Asia/Baku -dracut_install /usr/share/zoneinfo/posix/Asia/Gaza -dracut_install /usr/share/zoneinfo/posix/Asia/Seoul -dracut_install /usr/share/zoneinfo/posix/Asia/Chungking -dracut_install /usr/share/zoneinfo/posix/Asia/Amman -dracut_install /usr/share/zoneinfo/posix/Asia/Kuala_Lumpur -dracut_install /usr/share/zoneinfo/posix/Asia/Aqtobe -dracut_install /usr/share/zoneinfo/posix/Asia/Katmandu -dracut_install /usr/share/zoneinfo/posix/Asia/Tashkent -dracut_install /usr/share/zoneinfo/posix/Asia/Oral -dracut_install /usr/share/zoneinfo/posix/Asia/Dhaka -dracut_install /usr/share/zoneinfo/posix/Asia/Hovd -dracut_install /usr/share/zoneinfo/posix/Asia/Makassar -dracut_install /usr/share/zoneinfo/posix/Asia/Bangkok -dracut_install /usr/share/zoneinfo/posix/Asia/Tokyo -dracut_install /usr/share/zoneinfo/posix/Asia/Macao -dracut_install /usr/share/zoneinfo/posix/Asia/Riyadh -dracut_install /usr/share/zoneinfo/posix/Asia/Rangoon -dracut_install /usr/share/zoneinfo/posix/Asia/Riyadh88 -dracut_install /usr/share/zoneinfo/posix/Asia/Jakarta -dracut_install /usr/share/zoneinfo/posix/Asia/Aden -dracut_install /usr/share/zoneinfo/posix/Asia/Calcutta -dracut_install /usr/share/zoneinfo/posix/Asia/Ashkhabad -dracut_install /usr/share/zoneinfo/posix/Asia/Beirut -dracut_install /usr/share/zoneinfo/posix/Asia/Harbin -dracut_install /usr/share/zoneinfo/posix/Asia/Novosibirsk -dracut_install /usr/share/zoneinfo/posix/Asia/Omsk -dracut_install /usr/share/zoneinfo/posix/Asia/Aqtau -dracut_install /usr/share/zoneinfo/posix/Asia/Bahrain -dracut_install /usr/share/zoneinfo/posix/Asia/Dili -dracut_install /usr/share/zoneinfo/posix/Asia/Pontianak -dracut_install /usr/share/zoneinfo/posix/Asia/Singapore -dracut_install /usr/share/zoneinfo/posix/Asia/Baghdad -dracut_install /usr/share/zoneinfo/posix/Asia/Novokuznetsk -dracut_install /usr/share/zoneinfo/posix/Asia/Dubai -dracut_install /usr/share/zoneinfo/posix/Asia/Dushanbe -dracut_install /usr/share/zoneinfo/posix/Asia/Damascus -dracut_install /usr/share/zoneinfo/posix/Asia/Krasnoyarsk -dracut_install /usr/share/zoneinfo/posix/Asia/Tbilisi -dracut_install /usr/share/zoneinfo/posix/Asia/Yerevan -dracut_install /usr/share/zoneinfo/posix/Asia/Pyongyang -dracut_install /usr/share/zoneinfo/posix/Asia/Bishkek -dracut_install /usr/share/zoneinfo/posix/Asia/Colombo -dracut_install /usr/share/zoneinfo/posix/Asia/Yekaterinburg -dracut_install /usr/share/zoneinfo/posix/Asia/Chongqing -dracut_install /usr/share/zoneinfo/posix/Asia/Ho_Chi_Minh -dracut_install /usr/share/zoneinfo/posix/Asia/Hong_Kong -dracut_install /usr/share/zoneinfo/posix/Asia/Thimbu -dracut_install /usr/share/zoneinfo/posix/Asia/Thimphu -dracut_install /usr/share/zoneinfo/posix/Asia/Ashgabat -dracut_install /usr/share/zoneinfo/posix/Asia/Shanghai -dracut_install /usr/share/zoneinfo/posix/Asia/Tehran -dracut_install /usr/share/zoneinfo/posix/Asia/Tel_Aviv -dracut_install /usr/share/zoneinfo/posix/Asia/Taipei -dracut_install /usr/share/zoneinfo/posix/Asia/Kabul -dracut_install /usr/share/zoneinfo/posix/Asia/Macau -dracut_install /usr/share/zoneinfo/posix/Asia/Riyadh87 -dracut_install /usr/share/zoneinfo/posix/Asia/Choibalsan -dracut_install /usr/share/zoneinfo/posix/Asia/Vientiane -dracut_install /usr/share/zoneinfo/posix/Asia/Dacca -dracut_install /usr/share/zoneinfo/posix/Asia/Kuching -dracut_install /usr/share/zoneinfo/posix/Asia/Phnom_Penh -dracut_install /usr/share/zoneinfo/posix/Asia/Ulan_Bator -dracut_install /usr/share/zoneinfo/posix/Asia/Sakhalin -dracut_install /usr/share/zoneinfo/posix/MST7MDT -dracut_install /usr/share/zoneinfo/posix/Canada/East-Saskatchewan -dracut_install /usr/share/zoneinfo/posix/Canada/Atlantic -dracut_install /usr/share/zoneinfo/posix/Canada/Central -dracut_install /usr/share/zoneinfo/posix/Canada/Eastern -dracut_install /usr/share/zoneinfo/posix/Canada/Yukon -dracut_install /usr/share/zoneinfo/posix/Canada/Pacific -dracut_install /usr/share/zoneinfo/posix/Canada/Saskatchewan -dracut_install /usr/share/zoneinfo/posix/Canada/Mountain -dracut_install /usr/share/zoneinfo/posix/Canada/Newfoundland -dracut_install /usr/share/zoneinfo/posix/Israel -dracut_install /usr/share/zoneinfo/posix/Africa/Lagos -dracut_install /usr/share/zoneinfo/posix/Africa/Kigali -dracut_install /usr/share/zoneinfo/posix/Africa/Lome -dracut_install /usr/share/zoneinfo/posix/Africa/Niamey -dracut_install /usr/share/zoneinfo/posix/Africa/Conakry -dracut_install /usr/share/zoneinfo/posix/Africa/Asmera -dracut_install /usr/share/zoneinfo/posix/Africa/Banjul -dracut_install /usr/share/zoneinfo/posix/Africa/Abidjan -dracut_install /usr/share/zoneinfo/posix/Africa/Bujumbura -dracut_install /usr/share/zoneinfo/posix/Africa/Luanda -dracut_install /usr/share/zoneinfo/posix/Africa/Kampala -dracut_install /usr/share/zoneinfo/posix/Africa/Ouagadougou -dracut_install /usr/share/zoneinfo/posix/Africa/Libreville -dracut_install /usr/share/zoneinfo/posix/Africa/Lubumbashi -dracut_install /usr/share/zoneinfo/posix/Africa/Dakar -dracut_install /usr/share/zoneinfo/posix/Africa/Bamako -dracut_install /usr/share/zoneinfo/posix/Africa/Nairobi -dracut_install /usr/share/zoneinfo/posix/Africa/Bangui -dracut_install /usr/share/zoneinfo/posix/Africa/Johannesburg -dracut_install /usr/share/zoneinfo/posix/Africa/Accra -dracut_install /usr/share/zoneinfo/posix/Africa/Bissau -dracut_install /usr/share/zoneinfo/posix/Africa/Timbuktu -dracut_install /usr/share/zoneinfo/posix/Africa/Nouakchott -dracut_install /usr/share/zoneinfo/posix/Africa/Maputo -dracut_install /usr/share/zoneinfo/posix/Africa/Ndjamena -dracut_install /usr/share/zoneinfo/posix/Africa/Maseru -dracut_install /usr/share/zoneinfo/posix/Africa/Tripoli -dracut_install /usr/share/zoneinfo/posix/Africa/Blantyre -dracut_install /usr/share/zoneinfo/posix/Africa/Gaborone -dracut_install /usr/share/zoneinfo/posix/Africa/Addis_Ababa -dracut_install /usr/share/zoneinfo/posix/Africa/Porto-Novo -dracut_install /usr/share/zoneinfo/posix/Africa/Kinshasa -dracut_install /usr/share/zoneinfo/posix/Africa/Dar_es_Salaam -dracut_install /usr/share/zoneinfo/posix/Africa/Douala -dracut_install /usr/share/zoneinfo/posix/Africa/Mogadishu -dracut_install /usr/share/zoneinfo/posix/Africa/Monrovia -dracut_install /usr/share/zoneinfo/posix/Africa/Mbabane -dracut_install /usr/share/zoneinfo/posix/Africa/Algiers -dracut_install /usr/share/zoneinfo/posix/Africa/Lusaka -dracut_install /usr/share/zoneinfo/posix/Africa/Khartoum -dracut_install /usr/share/zoneinfo/posix/Africa/Asmara -dracut_install /usr/share/zoneinfo/posix/Africa/Tunis -dracut_install /usr/share/zoneinfo/posix/Africa/Casablanca -dracut_install /usr/share/zoneinfo/posix/Africa/Sao_Tome -dracut_install /usr/share/zoneinfo/posix/Africa/Ceuta -dracut_install /usr/share/zoneinfo/posix/Africa/El_Aaiun -dracut_install /usr/share/zoneinfo/posix/Africa/Harare -dracut_install /usr/share/zoneinfo/posix/Africa/Freetown -dracut_install /usr/share/zoneinfo/posix/Africa/Windhoek -dracut_install /usr/share/zoneinfo/posix/Africa/Djibouti -dracut_install /usr/share/zoneinfo/posix/Africa/Malabo -dracut_install /usr/share/zoneinfo/posix/Africa/Cairo -dracut_install /usr/share/zoneinfo/posix/Africa/Brazzaville -dracut_install /usr/share/zoneinfo/posix/Etc/Zulu -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-0 -dracut_install /usr/share/zoneinfo/posix/Etc/Greenwich -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+6 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+9 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-9 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+5 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT0 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-10 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+0 -dracut_install /usr/share/zoneinfo/posix/Etc/Universal -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+12 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-5 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+2 -dracut_install /usr/share/zoneinfo/posix/Etc/UTC -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+8 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-11 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-4 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-12 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+11 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+3 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+4 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+1 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-14 -dracut_install /usr/share/zoneinfo/posix/Etc/UCT -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+7 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-6 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-2 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-3 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-8 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-7 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-13 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-1 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+10 -dracut_install /usr/share/zoneinfo/posix/PST8PDT -dracut_install /usr/share/zoneinfo/posix/Jamaica -dracut_install /usr/share/zoneinfo/posix/NZ -dracut_install /usr/share/zoneinfo/posix/PRC -dracut_install /usr/share/zoneinfo/posix/Chile/EasterIsland -dracut_install /usr/share/zoneinfo/posix/Chile/Continental -inst "$moddir/xcatroot" "/sbin/xcatroot" -inst "$moddir/dodiscovery" "/bin/dodiscovery" -inst "$moddir/udpcat.awk" "/bin/udpcat.awk" -inst "$moddir/minixcatd.awk" "/bin/minixcatd.awk" -inst "$moddir/bmcsetup" "/bin/bmcsetup" -inst "$moddir/allowcred.awk" "/bin/allowcred.awk" -inst "$moddir/getipmi" "/bin/getipmi" -inst "$moddir/remoteimmsetup" "/bin/remoteimmsetup" -inst "$moddir/getdestiny" "/bin/getdestiny" -inst "$moddir/restart" "/bin/restart" -inst "$moddir/doxcat" "/bin/doxcat" -inst "$moddir/nextdestiny" "/bin/nextdestiny" -inst "$moddir/getcert" "/bin/getcert" -inst "$moddir/dhclient.conf" "/etc/dhclient.conf" -inst "$moddir/dhclient-script" "/sbin/dhclient-script" -inst "$moddir/rsyslog.conf" "/etc/rsyslog.conf" -inst "$moddir/99-imm.rules" "/etc/udev/rules.d/99-imm.rules" -inst "$moddir/98-mlx.rules" "/etc/udev/rules.d/98-mlx.rules" -inst "$moddir/setupimmnic" "/sbin/setupimmnic" -inst "$moddir/ifup" "/bin/ifup" -inst "$moddir/loadmlxeth" "/sbin/loadmlxeth" -dracut_install /sbin/rpc.statd /usr/sbin/sm-notify /etc/netconfig rpcbind /etc/host.conf /usr/sbin/rpc.idmapd -dracut_install ps free find #debug -inst_dir /var/lib/nfs -inst_dir /var/lib/nfs/statd/sm -inst_dir /var/lib/nfs/statd/sm.bak -inst_dir /var/lib/nfs/rpc_pipefs/nfs -inst "/bin/bash" "/bin/sh" -inst "/lib64/libnss_dns-2.12.so" -inst "/lib/terminfo/l/linux" "/lib/terminfo/l/linux" -inst "/lib/terminfo/v/vt100" "/lib/terminfo/v/vt100" -inst_hook cmdline 10 "$moddir/xcat-cmdline.sh" -dracut_install /lib64/rsyslog/lmtcpclt.so -dracut_install /lib64/rsyslog/omtesting.so -dracut_install /lib64/rsyslog/lmnetstrms.so -dracut_install /lib64/rsyslog/imfile.so -dracut_install /lib64/rsyslog/imklog.so -dracut_install /lib64/rsyslog/lmzlibw.so -dracut_install /lib64/rsyslog/immark.so -dracut_install /lib64/rsyslog/imudp.so -dracut_install /lib64/rsyslog/lmregexp.so -dracut_install /lib64/rsyslog/lmtcpsrv.so -dracut_install /lib64/rsyslog/lmnsd_ptcp.so -dracut_install /lib64/rsyslog/imtcp.so -dracut_install /lib64/rsyslog/lmnet.so -dracut_install /lib64/rsyslog/lmstrmsrv.so -dracut_install /lib64/rsyslog/imuxsock.so -dracut_install /usr/lib64/libnfsidmap/nsswitch.so diff --git a/xCAT-nbroot2/install.debian b/xCAT-nbroot2/install.debian deleted file mode 100755 index 94a0fff5a..000000000 --- a/xCAT-nbroot2/install.debian +++ /dev/null @@ -1,639 +0,0 @@ -#!/bin/sh -echo $drivers -dracut_install wget openssl tar mstflint ipmitool cpio gzip lsmod ethtool modprobe touch echo cut wc -dracut_install netstat # broadcom update requires -dracut_install uniq # mellanox update requires -dracut_install grep ip hostname awk egrep grep dirname expr -dracut_install mount.nfs sshd vi reboot lspci parted screen mkfs mkfs.ext4 mkfs.btrfs -dracut_install efibootmgr -#dracut_install libvirtd /usr/share/libvirt/cpu_map.xml /usr/bin/qemu-img /usr/libexec/qemu-kvm -dracut_install mkswap df brctl vconfig ifenslave ssh-keygen scp clear dhclient lldpad lldptool -#dracut_install /lib/x86_64-linux-gnu/libnss_dns-2.13.so /lib/x86_64-linux-gnu/libnss_dns.so.2 -dracut_install poweroff ntpq ntpd hwclock date /lib/terminfo/x/xterm /etc/nsswitch.conf /etc/services -dracut_install /usr/sbin/rsyslogd /etc/protocols umount /usr/bin/rpm /usr/lib/rpm/rpmrc -dracut_install chmod /lib/ld-linux.so.2 /lib/libdl.so.2 /lib/libc.so.6 /sbin/route /sbin/ifconfig /usr/bin/head /etc/issue /etc/debian_version ping tr lsusb /usr/share/hwdata/usb.ids #ibm fw wrapper requirements -dracut_install dmidecode /usr/lib/libstdc++.so.6 #uxspi prereqs, but will use dmidecode to improve decision on loading ipmi_si -dracut_install dmidecode /usr/lib/libstdc++.so.5 #broadcom firmware update links against old lib -dracut_install /lib/libpthread.so.0 #32 bit lib because UXSPI will not ship a native 64 bit build -dracut_install /lib/libncurses.so.5.7 /usr/lib/libstdc++.so.6.0.13 /lib/libgcc_s.so.1 /lib/libncurses.so.5.7 -dracut_install /usr/lib/libldap-2.4.so.2 /usr/lib/liblber-2.4.so.2 /usr/lib/libsasl2.so.2 #uxspi has incurred these... -dracut_install /usr/share/zoneinfo/posix/Zulu -dracut_install /usr/share/zoneinfo/posix/GMT-0 -dracut_install /usr/share/zoneinfo/posix/Europe/Istanbul -dracut_install /usr/share/zoneinfo/posix/Europe/San_Marino -dracut_install /usr/share/zoneinfo/posix/Europe/Jersey -dracut_install /usr/share/zoneinfo/posix/Europe/Bucharest -dracut_install /usr/share/zoneinfo/posix/Europe/Gibraltar -dracut_install /usr/share/zoneinfo/posix/Europe/Uzhgorod -dracut_install /usr/share/zoneinfo/posix/Europe/Moscow -dracut_install /usr/share/zoneinfo/posix/Europe/Brussels -dracut_install /usr/share/zoneinfo/posix/Europe/Nicosia -dracut_install /usr/share/zoneinfo/posix/Europe/Zurich -dracut_install /usr/share/zoneinfo/posix/Europe/Berlin -dracut_install /usr/share/zoneinfo/posix/Europe/Guernsey -dracut_install /usr/share/zoneinfo/posix/Europe/Budapest -dracut_install /usr/share/zoneinfo/posix/Europe/Kiev -dracut_install /usr/share/zoneinfo/posix/Europe/Podgorica -dracut_install /usr/share/zoneinfo/posix/Europe/Isle_of_Man -dracut_install /usr/share/zoneinfo/posix/Europe/Mariehamn -dracut_install /usr/share/zoneinfo/posix/Europe/Belgrade -dracut_install /usr/share/zoneinfo/posix/Europe/Belfast -dracut_install /usr/share/zoneinfo/posix/Europe/Ljubljana -dracut_install /usr/share/zoneinfo/posix/Europe/Chisinau -dracut_install /usr/share/zoneinfo/posix/Europe/Andorra -dracut_install /usr/share/zoneinfo/posix/Europe/Athens -dracut_install /usr/share/zoneinfo/posix/Europe/Stockholm -dracut_install /usr/share/zoneinfo/posix/Europe/Vienna -dracut_install /usr/share/zoneinfo/posix/Europe/Lisbon -dracut_install /usr/share/zoneinfo/posix/Europe/London -dracut_install /usr/share/zoneinfo/posix/Europe/Paris -dracut_install /usr/share/zoneinfo/posix/Europe/Oslo -dracut_install /usr/share/zoneinfo/posix/Europe/Zagreb -dracut_install /usr/share/zoneinfo/posix/Europe/Helsinki -dracut_install /usr/share/zoneinfo/posix/Europe/Warsaw -dracut_install /usr/share/zoneinfo/posix/Europe/Copenhagen -dracut_install /usr/share/zoneinfo/posix/Europe/Riga -dracut_install /usr/share/zoneinfo/posix/Europe/Vaduz -dracut_install /usr/share/zoneinfo/posix/Europe/Vilnius -dracut_install /usr/share/zoneinfo/posix/Europe/Volgograd -dracut_install /usr/share/zoneinfo/posix/Europe/Amsterdam -dracut_install /usr/share/zoneinfo/posix/Europe/Tiraspol -dracut_install /usr/share/zoneinfo/posix/Europe/Tallinn -dracut_install /usr/share/zoneinfo/posix/Europe/Kaliningrad -dracut_install /usr/share/zoneinfo/posix/Europe/Malta -dracut_install /usr/share/zoneinfo/posix/Europe/Sarajevo -dracut_install /usr/share/zoneinfo/posix/Europe/Madrid -dracut_install /usr/share/zoneinfo/posix/Europe/Zaporozhye -dracut_install /usr/share/zoneinfo/posix/Europe/Simferopol -dracut_install /usr/share/zoneinfo/posix/Europe/Sofia -dracut_install /usr/share/zoneinfo/posix/Europe/Skopje -dracut_install /usr/share/zoneinfo/posix/Europe/Monaco -dracut_install /usr/share/zoneinfo/posix/Europe/Rome -dracut_install /usr/share/zoneinfo/posix/Europe/Prague -dracut_install /usr/share/zoneinfo/posix/Europe/Luxembourg -dracut_install /usr/share/zoneinfo/posix/Europe/Minsk -dracut_install /usr/share/zoneinfo/posix/Europe/Vatican -dracut_install /usr/share/zoneinfo/posix/Europe/Dublin -dracut_install /usr/share/zoneinfo/posix/Europe/Samara -dracut_install /usr/share/zoneinfo/posix/Europe/Tirane -dracut_install /usr/share/zoneinfo/posix/Europe/Bratislava -dracut_install /usr/share/zoneinfo/posix/Greenwich -dracut_install /usr/share/zoneinfo/posix/US/Indiana-Starke -dracut_install /usr/share/zoneinfo/posix/US/Alaska -dracut_install /usr/share/zoneinfo/posix/US/Michigan -dracut_install /usr/share/zoneinfo/posix/US/Aleutian -dracut_install /usr/share/zoneinfo/posix/US/Hawaii -dracut_install /usr/share/zoneinfo/posix/US/Central -dracut_install /usr/share/zoneinfo/posix/US/Eastern -dracut_install /usr/share/zoneinfo/posix/US/Pacific -dracut_install /usr/share/zoneinfo/posix/US/Samoa -dracut_install /usr/share/zoneinfo/posix/US/Mountain -dracut_install /usr/share/zoneinfo/posix/US/Arizona -dracut_install /usr/share/zoneinfo/posix/US/East-Indiana -dracut_install /usr/share/zoneinfo/posix/EST -dracut_install /usr/share/zoneinfo/posix/HST -dracut_install /usr/share/zoneinfo/posix/Eire -dracut_install /usr/share/zoneinfo/posix/America/Cancun -dracut_install /usr/share/zoneinfo/posix/America/Santo_Domingo -dracut_install /usr/share/zoneinfo/posix/America/Jujuy -dracut_install /usr/share/zoneinfo/posix/America/Guatemala -dracut_install /usr/share/zoneinfo/posix/America/Monterrey -dracut_install /usr/share/zoneinfo/posix/America/Ensenada -dracut_install /usr/share/zoneinfo/posix/America/Dawson_Creek -dracut_install /usr/share/zoneinfo/posix/America/Mendoza -dracut_install /usr/share/zoneinfo/posix/America/Coral_Harbour -dracut_install /usr/share/zoneinfo/posix/America/Martinique -dracut_install /usr/share/zoneinfo/posix/America/Cordoba -dracut_install /usr/share/zoneinfo/posix/America/Recife -dracut_install /usr/share/zoneinfo/posix/America/Cayman -dracut_install /usr/share/zoneinfo/posix/America/Shiprock -dracut_install /usr/share/zoneinfo/posix/America/Tortola -dracut_install /usr/share/zoneinfo/posix/America/Lima -dracut_install /usr/share/zoneinfo/posix/America/Antigua -dracut_install /usr/share/zoneinfo/posix/America/Blanc-Sablon -dracut_install /usr/share/zoneinfo/posix/America/Nipigon -dracut_install /usr/share/zoneinfo/posix/America/Nome -dracut_install /usr/share/zoneinfo/posix/America/Montserrat -dracut_install /usr/share/zoneinfo/posix/America/Atka -dracut_install /usr/share/zoneinfo/posix/America/St_Thomas -dracut_install /usr/share/zoneinfo/posix/America/Halifax -dracut_install /usr/share/zoneinfo/posix/America/Montreal -dracut_install /usr/share/zoneinfo/posix/America/Curacao -dracut_install /usr/share/zoneinfo/posix/America/Cuiaba -dracut_install /usr/share/zoneinfo/posix/America/Winnipeg -dracut_install /usr/share/zoneinfo/posix/America/North_Dakota/New_Salem -dracut_install /usr/share/zoneinfo/posix/America/North_Dakota/Center -dracut_install /usr/share/zoneinfo/posix/America/Panama -dracut_install /usr/share/zoneinfo/posix/America/Rosario -dracut_install /usr/share/zoneinfo/posix/America/Anguilla -dracut_install /usr/share/zoneinfo/posix/America/Ojinaga -dracut_install /usr/share/zoneinfo/posix/America/Guyana -dracut_install /usr/share/zoneinfo/posix/America/Eirunepe -dracut_install /usr/share/zoneinfo/posix/America/Grand_Turk -dracut_install /usr/share/zoneinfo/posix/America/Rio_Branco -dracut_install /usr/share/zoneinfo/posix/America/Santa_Isabel -dracut_install /usr/share/zoneinfo/posix/America/Scoresbysund -dracut_install /usr/share/zoneinfo/posix/America/Adak -dracut_install /usr/share/zoneinfo/posix/America/Menominee -dracut_install /usr/share/zoneinfo/posix/America/Resolute -dracut_install /usr/share/zoneinfo/posix/America/Guadeloupe -dracut_install /usr/share/zoneinfo/posix/America/Indianapolis -dracut_install /usr/share/zoneinfo/posix/America/Vancouver -dracut_install /usr/share/zoneinfo/posix/America/Glace_Bay -dracut_install /usr/share/zoneinfo/posix/America/Buenos_Aires -dracut_install /usr/share/zoneinfo/posix/America/Virgin -dracut_install /usr/share/zoneinfo/posix/America/Belem -dracut_install /usr/share/zoneinfo/posix/America/Catamarca -dracut_install /usr/share/zoneinfo/posix/America/Bahia -dracut_install /usr/share/zoneinfo/posix/America/Fort_Wayne -dracut_install /usr/share/zoneinfo/posix/America/Hermosillo -dracut_install /usr/share/zoneinfo/posix/America/Rankin_Inlet -dracut_install /usr/share/zoneinfo/posix/America/Mexico_City -dracut_install /usr/share/zoneinfo/posix/America/Belize -dracut_install /usr/share/zoneinfo/posix/America/Maceio -dracut_install /usr/share/zoneinfo/posix/America/Dominica -dracut_install /usr/share/zoneinfo/posix/America/Swift_Current -dracut_install /usr/share/zoneinfo/posix/America/St_Johns -dracut_install /usr/share/zoneinfo/posix/America/St_Barthelemy -dracut_install /usr/share/zoneinfo/posix/America/Yellowknife -dracut_install /usr/share/zoneinfo/posix/America/Costa_Rica -dracut_install /usr/share/zoneinfo/posix/America/Pangnirtung -dracut_install /usr/share/zoneinfo/posix/America/Bogota -dracut_install /usr/share/zoneinfo/posix/America/Port-au-Prince -dracut_install /usr/share/zoneinfo/posix/America/Phoenix -dracut_install /usr/share/zoneinfo/posix/America/Port_of_Spain -dracut_install /usr/share/zoneinfo/posix/America/Matamoros -dracut_install /usr/share/zoneinfo/posix/America/Puerto_Rico -dracut_install /usr/share/zoneinfo/posix/America/Detroit -dracut_install /usr/share/zoneinfo/posix/America/Edmonton -dracut_install /usr/share/zoneinfo/posix/America/Toronto -dracut_install /usr/share/zoneinfo/posix/America/Cambridge_Bay -dracut_install /usr/share/zoneinfo/posix/America/Godthab -dracut_install /usr/share/zoneinfo/posix/America/Atikokan -dracut_install /usr/share/zoneinfo/posix/America/Juneau -dracut_install /usr/share/zoneinfo/posix/America/Managua -dracut_install /usr/share/zoneinfo/posix/America/Anchorage -dracut_install /usr/share/zoneinfo/posix/America/Merida -dracut_install /usr/share/zoneinfo/posix/America/Thunder_Bay -dracut_install /usr/share/zoneinfo/posix/America/Porto_Velho -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Jujuy -dracut_install /usr/share/zoneinfo/posix/America/Argentina/La_Rioja -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Mendoza -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Cordoba -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Ushuaia -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Rio_Gallegos -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Buenos_Aires -dracut_install /usr/share/zoneinfo/posix/America/Argentina/San_Juan -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Catamarca -dracut_install /usr/share/zoneinfo/posix/America/Argentina/San_Luis -dracut_install /usr/share/zoneinfo/posix/America/Argentina/ComodRivadavia -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Salta -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Tucuman -dracut_install /usr/share/zoneinfo/posix/America/Iqaluit -dracut_install /usr/share/zoneinfo/posix/America/Chicago -dracut_install /usr/share/zoneinfo/posix/America/Miquelon -dracut_install /usr/share/zoneinfo/posix/America/Havana -dracut_install /usr/share/zoneinfo/posix/America/Guayaquil -dracut_install /usr/share/zoneinfo/posix/America/St_Vincent -dracut_install /usr/share/zoneinfo/posix/America/St_Lucia -dracut_install /usr/share/zoneinfo/posix/America/Boise -dracut_install /usr/share/zoneinfo/posix/America/Yakutat -dracut_install /usr/share/zoneinfo/posix/America/Santarem -dracut_install /usr/share/zoneinfo/posix/America/Campo_Grande -dracut_install /usr/share/zoneinfo/posix/America/Santiago -dracut_install /usr/share/zoneinfo/posix/America/Porto_Acre -dracut_install /usr/share/zoneinfo/posix/America/Sao_Paulo -dracut_install /usr/share/zoneinfo/posix/America/Thule -dracut_install /usr/share/zoneinfo/posix/America/New_York -dracut_install /usr/share/zoneinfo/posix/America/Nassau -dracut_install /usr/share/zoneinfo/posix/America/Dawson -dracut_install /usr/share/zoneinfo/posix/America/Louisville -dracut_install /usr/share/zoneinfo/posix/America/Asuncion -dracut_install /usr/share/zoneinfo/posix/America/Inuvik -dracut_install /usr/share/zoneinfo/posix/America/Paramaribo -dracut_install /usr/share/zoneinfo/posix/America/Chihuahua -dracut_install /usr/share/zoneinfo/posix/America/Mazatlan -dracut_install /usr/share/zoneinfo/posix/America/Grenada -dracut_install /usr/share/zoneinfo/posix/America/Denver -dracut_install /usr/share/zoneinfo/posix/America/Los_Angeles -dracut_install /usr/share/zoneinfo/posix/America/Marigot -dracut_install /usr/share/zoneinfo/posix/America/Manaus -dracut_install /usr/share/zoneinfo/posix/America/Regina -dracut_install /usr/share/zoneinfo/posix/America/Barbados -dracut_install /usr/share/zoneinfo/posix/America/Noronha -dracut_install /usr/share/zoneinfo/posix/America/Montevideo -dracut_install /usr/share/zoneinfo/posix/America/Caracas -dracut_install /usr/share/zoneinfo/posix/America/Rainy_River -dracut_install /usr/share/zoneinfo/posix/America/La_Paz -dracut_install /usr/share/zoneinfo/posix/America/Jamaica -dracut_install /usr/share/zoneinfo/posix/America/Moncton -dracut_install /usr/share/zoneinfo/posix/America/Whitehorse -dracut_install /usr/share/zoneinfo/posix/America/Fortaleza -dracut_install /usr/share/zoneinfo/posix/America/Kentucky/Monticello -dracut_install /usr/share/zoneinfo/posix/America/Kentucky/Louisville -dracut_install /usr/share/zoneinfo/posix/America/Indiana/Marengo -dracut_install /usr/share/zoneinfo/posix/America/Indiana/Indianapolis -dracut_install /usr/share/zoneinfo/posix/America/Indiana/Knox -dracut_install /usr/share/zoneinfo/posix/America/Indiana/Tell_City -dracut_install /usr/share/zoneinfo/posix/America/Indiana/Petersburg -dracut_install /usr/share/zoneinfo/posix/America/Indiana/Winamac -dracut_install /usr/share/zoneinfo/posix/America/Indiana/Vincennes -dracut_install /usr/share/zoneinfo/posix/America/Indiana/Vevay -dracut_install /usr/share/zoneinfo/posix/America/Danmarkshavn -dracut_install /usr/share/zoneinfo/posix/America/St_Kitts -dracut_install /usr/share/zoneinfo/posix/America/Aruba -dracut_install /usr/share/zoneinfo/posix/America/Boa_Vista -dracut_install /usr/share/zoneinfo/posix/America/Bahia_Banderas -dracut_install /usr/share/zoneinfo/posix/America/Tegucigalpa -dracut_install /usr/share/zoneinfo/posix/America/Araguaina -dracut_install /usr/share/zoneinfo/posix/America/El_Salvador -dracut_install /usr/share/zoneinfo/posix/America/Cayenne -dracut_install /usr/share/zoneinfo/posix/America/Tijuana -dracut_install /usr/share/zoneinfo/posix/America/Knox_IN -dracut_install /usr/share/zoneinfo/posix/America/Goose_Bay -dracut_install /usr/share/zoneinfo/posix/EET -dracut_install /usr/share/zoneinfo/posix/EST5EDT -dracut_install /usr/share/zoneinfo/posix/Mideast/Riyadh89 -dracut_install /usr/share/zoneinfo/posix/Mideast/Riyadh88 -dracut_install /usr/share/zoneinfo/posix/Mideast/Riyadh87 -dracut_install /usr/share/zoneinfo/posix/MST -dracut_install /usr/share/zoneinfo/posix/Iceland -dracut_install /usr/share/zoneinfo/posix/Atlantic/Faeroe -dracut_install /usr/share/zoneinfo/posix/Atlantic/Stanley -dracut_install /usr/share/zoneinfo/posix/Atlantic/Reykjavik -dracut_install /usr/share/zoneinfo/posix/Atlantic/St_Helena -dracut_install /usr/share/zoneinfo/posix/Atlantic/Faroe -dracut_install /usr/share/zoneinfo/posix/Atlantic/South_Georgia -dracut_install /usr/share/zoneinfo/posix/Atlantic/Jan_Mayen -dracut_install /usr/share/zoneinfo/posix/Atlantic/Azores -dracut_install /usr/share/zoneinfo/posix/Atlantic/Cape_Verde -dracut_install /usr/share/zoneinfo/posix/Atlantic/Madeira -dracut_install /usr/share/zoneinfo/posix/Atlantic/Bermuda -dracut_install /usr/share/zoneinfo/posix/Atlantic/Canary -dracut_install /usr/share/zoneinfo/posix/GMT0 -dracut_install /usr/share/zoneinfo/posix/Poland -dracut_install /usr/share/zoneinfo/posix/Indian/Chagos -dracut_install /usr/share/zoneinfo/posix/Indian/Maldives -dracut_install /usr/share/zoneinfo/posix/Indian/Comoro -dracut_install /usr/share/zoneinfo/posix/Indian/Mauritius -dracut_install /usr/share/zoneinfo/posix/Indian/Mayotte -dracut_install /usr/share/zoneinfo/posix/Indian/Christmas -dracut_install /usr/share/zoneinfo/posix/Indian/Antananarivo -dracut_install /usr/share/zoneinfo/posix/Indian/Kerguelen -dracut_install /usr/share/zoneinfo/posix/Indian/Mahe -dracut_install /usr/share/zoneinfo/posix/Indian/Cocos -dracut_install /usr/share/zoneinfo/posix/Indian/Reunion -dracut_install /usr/share/zoneinfo/posix/Mexico/BajaNorte -dracut_install /usr/share/zoneinfo/posix/Mexico/BajaSur -dracut_install /usr/share/zoneinfo/posix/Mexico/General -dracut_install /usr/share/zoneinfo/posix/Turkey -dracut_install /usr/share/zoneinfo/posix/Egypt -dracut_install /usr/share/zoneinfo/posix/Hongkong -dracut_install /usr/share/zoneinfo/posix/GB -dracut_install /usr/share/zoneinfo/posix/GMT+0 -dracut_install /usr/share/zoneinfo/posix/ROK -dracut_install /usr/share/zoneinfo/posix/Antarctica/Mawson -dracut_install /usr/share/zoneinfo/posix/Antarctica/Macquarie -dracut_install /usr/share/zoneinfo/posix/Antarctica/South_Pole -dracut_install /usr/share/zoneinfo/posix/Antarctica/Rothera -dracut_install /usr/share/zoneinfo/posix/Antarctica/Davis -dracut_install /usr/share/zoneinfo/posix/Antarctica/DumontDUrville -dracut_install /usr/share/zoneinfo/posix/Antarctica/McMurdo -dracut_install /usr/share/zoneinfo/posix/Antarctica/Casey -dracut_install /usr/share/zoneinfo/posix/Antarctica/Vostok -dracut_install /usr/share/zoneinfo/posix/Antarctica/Palmer -dracut_install /usr/share/zoneinfo/posix/Antarctica/Syowa -dracut_install /usr/share/zoneinfo/posix/Universal -dracut_install /usr/share/zoneinfo/posix/CET -dracut_install /usr/share/zoneinfo/posix/WET -dracut_install /usr/share/zoneinfo/posix/Navajo -dracut_install /usr/share/zoneinfo/posix/UTC -dracut_install /usr/share/zoneinfo/posix/Pacific/Enderbury -dracut_install /usr/share/zoneinfo/posix/Pacific/Johnston -dracut_install /usr/share/zoneinfo/posix/Pacific/Pago_Pago -dracut_install /usr/share/zoneinfo/posix/Pacific/Saipan -dracut_install /usr/share/zoneinfo/posix/Pacific/Norfolk -dracut_install /usr/share/zoneinfo/posix/Pacific/Chuuk -dracut_install /usr/share/zoneinfo/posix/Pacific/Galapagos -dracut_install /usr/share/zoneinfo/posix/Pacific/Palau -dracut_install /usr/share/zoneinfo/posix/Pacific/Tarawa -dracut_install /usr/share/zoneinfo/posix/Pacific/Fakaofo -dracut_install /usr/share/zoneinfo/posix/Pacific/Rarotonga -dracut_install /usr/share/zoneinfo/posix/Pacific/Wake -dracut_install /usr/share/zoneinfo/posix/Pacific/Kosrae -dracut_install /usr/share/zoneinfo/posix/Pacific/Tahiti -dracut_install /usr/share/zoneinfo/posix/Pacific/Fiji -dracut_install /usr/share/zoneinfo/posix/Pacific/Ponape -dracut_install /usr/share/zoneinfo/posix/Pacific/Tongatapu -dracut_install /usr/share/zoneinfo/posix/Pacific/Efate -dracut_install /usr/share/zoneinfo/posix/Pacific/Honolulu -dracut_install /usr/share/zoneinfo/posix/Pacific/Niue -dracut_install /usr/share/zoneinfo/posix/Pacific/Kwajalein -dracut_install /usr/share/zoneinfo/posix/Pacific/Guam -dracut_install /usr/share/zoneinfo/posix/Pacific/Funafuti -dracut_install /usr/share/zoneinfo/posix/Pacific/Majuro -dracut_install /usr/share/zoneinfo/posix/Pacific/Midway -dracut_install /usr/share/zoneinfo/posix/Pacific/Nauru -dracut_install /usr/share/zoneinfo/posix/Pacific/Samoa -dracut_install /usr/share/zoneinfo/posix/Pacific/Marquesas -dracut_install /usr/share/zoneinfo/posix/Pacific/Kiritimati -dracut_install /usr/share/zoneinfo/posix/Pacific/Noumea -dracut_install /usr/share/zoneinfo/posix/Pacific/Truk -dracut_install /usr/share/zoneinfo/posix/Pacific/Guadalcanal -dracut_install /usr/share/zoneinfo/posix/Pacific/Pohnpei -dracut_install /usr/share/zoneinfo/posix/Pacific/Pitcairn -dracut_install /usr/share/zoneinfo/posix/Pacific/Port_Moresby -dracut_install /usr/share/zoneinfo/posix/Pacific/Yap -dracut_install /usr/share/zoneinfo/posix/Pacific/Easter -dracut_install /usr/share/zoneinfo/posix/Pacific/Wallis -dracut_install /usr/share/zoneinfo/posix/Pacific/Apia -dracut_install /usr/share/zoneinfo/posix/Pacific/Auckland -dracut_install /usr/share/zoneinfo/posix/Pacific/Gambier -dracut_install /usr/share/zoneinfo/posix/Pacific/Chatham -dracut_install /usr/share/zoneinfo/posix/Japan -dracut_install /usr/share/zoneinfo/posix/Libya -dracut_install /usr/share/zoneinfo/posix/ROC -dracut_install /usr/share/zoneinfo/posix/Iran -dracut_install /usr/share/zoneinfo/posix/Brazil/West -dracut_install /usr/share/zoneinfo/posix/Brazil/East -dracut_install /usr/share/zoneinfo/posix/Brazil/Acre -dracut_install /usr/share/zoneinfo/posix/Brazil/DeNoronha -dracut_install /usr/share/zoneinfo/posix/Arctic/Longyearbyen -dracut_install /usr/share/zoneinfo/posix/Portugal -dracut_install /usr/share/zoneinfo/posix/MET -dracut_install /usr/share/zoneinfo/posix/W-SU -dracut_install /usr/share/zoneinfo/posix/Kwajalein -dracut_install /usr/share/zoneinfo/posix/CST6CDT -dracut_install /usr/share/zoneinfo/posix/GB-Eire -dracut_install /usr/share/zoneinfo/posix/Australia/Melbourne -dracut_install /usr/share/zoneinfo/posix/Australia/Broken_Hill -dracut_install /usr/share/zoneinfo/posix/Australia/Queensland -dracut_install /usr/share/zoneinfo/posix/Australia/South -dracut_install /usr/share/zoneinfo/posix/Australia/Eucla -dracut_install /usr/share/zoneinfo/posix/Australia/Yancowinna -dracut_install /usr/share/zoneinfo/posix/Australia/Lord_Howe -dracut_install /usr/share/zoneinfo/posix/Australia/Hobart -dracut_install /usr/share/zoneinfo/posix/Australia/NSW -dracut_install /usr/share/zoneinfo/posix/Australia/West -dracut_install /usr/share/zoneinfo/posix/Australia/LHI -dracut_install /usr/share/zoneinfo/posix/Australia/Perth -dracut_install /usr/share/zoneinfo/posix/Australia/ACT -dracut_install /usr/share/zoneinfo/posix/Australia/Darwin -dracut_install /usr/share/zoneinfo/posix/Australia/Lindeman -dracut_install /usr/share/zoneinfo/posix/Australia/Sydney -dracut_install /usr/share/zoneinfo/posix/Australia/North -dracut_install /usr/share/zoneinfo/posix/Australia/Canberra -dracut_install /usr/share/zoneinfo/posix/Australia/Adelaide -dracut_install /usr/share/zoneinfo/posix/Australia/Brisbane -dracut_install /usr/share/zoneinfo/posix/Australia/Victoria -dracut_install /usr/share/zoneinfo/posix/Australia/Tasmania -dracut_install /usr/share/zoneinfo/posix/Australia/Currie -dracut_install /usr/share/zoneinfo/posix/UCT -dracut_install /usr/share/zoneinfo/posix/Cuba -dracut_install /usr/share/zoneinfo/posix/Singapore -dracut_install /usr/share/zoneinfo/posix/GMT -dracut_install /usr/share/zoneinfo/posix/NZ-CHAT -dracut_install /usr/share/zoneinfo/posix/Asia/Istanbul -dracut_install /usr/share/zoneinfo/posix/Asia/Kuwait -dracut_install /usr/share/zoneinfo/posix/Asia/Saigon -dracut_install /usr/share/zoneinfo/posix/Asia/Riyadh89 -dracut_install /usr/share/zoneinfo/posix/Asia/Urumqi -dracut_install /usr/share/zoneinfo/posix/Asia/Brunei -dracut_install /usr/share/zoneinfo/posix/Asia/Ujung_Pandang -dracut_install /usr/share/zoneinfo/posix/Asia/Muscat -dracut_install /usr/share/zoneinfo/posix/Asia/Kashgar -dracut_install /usr/share/zoneinfo/posix/Asia/Kamchatka -dracut_install /usr/share/zoneinfo/posix/Asia/Manila -dracut_install /usr/share/zoneinfo/posix/Asia/Vladivostok -dracut_install /usr/share/zoneinfo/posix/Asia/Jayapura -dracut_install /usr/share/zoneinfo/posix/Asia/Magadan -dracut_install /usr/share/zoneinfo/posix/Asia/Almaty -dracut_install /usr/share/zoneinfo/posix/Asia/Qyzylorda -dracut_install /usr/share/zoneinfo/posix/Asia/Anadyr -dracut_install /usr/share/zoneinfo/posix/Asia/Nicosia -dracut_install /usr/share/zoneinfo/posix/Asia/Kathmandu -dracut_install /usr/share/zoneinfo/posix/Asia/Qatar -dracut_install /usr/share/zoneinfo/posix/Asia/Jerusalem -dracut_install /usr/share/zoneinfo/posix/Asia/Yakutsk -dracut_install /usr/share/zoneinfo/posix/Asia/Karachi -dracut_install /usr/share/zoneinfo/posix/Asia/Samarkand -dracut_install /usr/share/zoneinfo/posix/Asia/Kolkata -dracut_install /usr/share/zoneinfo/posix/Asia/Ulaanbaatar -dracut_install /usr/share/zoneinfo/posix/Asia/Irkutsk -dracut_install /usr/share/zoneinfo/posix/Asia/Baku -dracut_install /usr/share/zoneinfo/posix/Asia/Gaza -dracut_install /usr/share/zoneinfo/posix/Asia/Seoul -dracut_install /usr/share/zoneinfo/posix/Asia/Chungking -dracut_install /usr/share/zoneinfo/posix/Asia/Amman -dracut_install /usr/share/zoneinfo/posix/Asia/Kuala_Lumpur -dracut_install /usr/share/zoneinfo/posix/Asia/Aqtobe -dracut_install /usr/share/zoneinfo/posix/Asia/Katmandu -dracut_install /usr/share/zoneinfo/posix/Asia/Tashkent -dracut_install /usr/share/zoneinfo/posix/Asia/Oral -dracut_install /usr/share/zoneinfo/posix/Asia/Dhaka -dracut_install /usr/share/zoneinfo/posix/Asia/Hovd -dracut_install /usr/share/zoneinfo/posix/Asia/Makassar -dracut_install /usr/share/zoneinfo/posix/Asia/Bangkok -dracut_install /usr/share/zoneinfo/posix/Asia/Tokyo -dracut_install /usr/share/zoneinfo/posix/Asia/Macao -dracut_install /usr/share/zoneinfo/posix/Asia/Riyadh -dracut_install /usr/share/zoneinfo/posix/Asia/Rangoon -dracut_install /usr/share/zoneinfo/posix/Asia/Riyadh88 -dracut_install /usr/share/zoneinfo/posix/Asia/Jakarta -dracut_install /usr/share/zoneinfo/posix/Asia/Aden -dracut_install /usr/share/zoneinfo/posix/Asia/Calcutta -dracut_install /usr/share/zoneinfo/posix/Asia/Ashkhabad -dracut_install /usr/share/zoneinfo/posix/Asia/Beirut -dracut_install /usr/share/zoneinfo/posix/Asia/Harbin -dracut_install /usr/share/zoneinfo/posix/Asia/Novosibirsk -dracut_install /usr/share/zoneinfo/posix/Asia/Omsk -dracut_install /usr/share/zoneinfo/posix/Asia/Aqtau -dracut_install /usr/share/zoneinfo/posix/Asia/Bahrain -dracut_install /usr/share/zoneinfo/posix/Asia/Dili -dracut_install /usr/share/zoneinfo/posix/Asia/Pontianak -dracut_install /usr/share/zoneinfo/posix/Asia/Singapore -dracut_install /usr/share/zoneinfo/posix/Asia/Baghdad -dracut_install /usr/share/zoneinfo/posix/Asia/Novokuznetsk -dracut_install /usr/share/zoneinfo/posix/Asia/Dubai -dracut_install /usr/share/zoneinfo/posix/Asia/Dushanbe -dracut_install /usr/share/zoneinfo/posix/Asia/Damascus -dracut_install /usr/share/zoneinfo/posix/Asia/Krasnoyarsk -dracut_install /usr/share/zoneinfo/posix/Asia/Tbilisi -dracut_install /usr/share/zoneinfo/posix/Asia/Yerevan -dracut_install /usr/share/zoneinfo/posix/Asia/Pyongyang -dracut_install /usr/share/zoneinfo/posix/Asia/Bishkek -dracut_install /usr/share/zoneinfo/posix/Asia/Colombo -dracut_install /usr/share/zoneinfo/posix/Asia/Yekaterinburg -dracut_install /usr/share/zoneinfo/posix/Asia/Chongqing -dracut_install /usr/share/zoneinfo/posix/Asia/Ho_Chi_Minh -dracut_install /usr/share/zoneinfo/posix/Asia/Hong_Kong -dracut_install /usr/share/zoneinfo/posix/Asia/Thimbu -dracut_install /usr/share/zoneinfo/posix/Asia/Thimphu -dracut_install /usr/share/zoneinfo/posix/Asia/Ashgabat -dracut_install /usr/share/zoneinfo/posix/Asia/Shanghai -dracut_install /usr/share/zoneinfo/posix/Asia/Tehran -dracut_install /usr/share/zoneinfo/posix/Asia/Tel_Aviv -dracut_install /usr/share/zoneinfo/posix/Asia/Taipei -dracut_install /usr/share/zoneinfo/posix/Asia/Kabul -dracut_install /usr/share/zoneinfo/posix/Asia/Macau -dracut_install /usr/share/zoneinfo/posix/Asia/Riyadh87 -dracut_install /usr/share/zoneinfo/posix/Asia/Choibalsan -dracut_install /usr/share/zoneinfo/posix/Asia/Vientiane -dracut_install /usr/share/zoneinfo/posix/Asia/Dacca -dracut_install /usr/share/zoneinfo/posix/Asia/Kuching -dracut_install /usr/share/zoneinfo/posix/Asia/Phnom_Penh -dracut_install /usr/share/zoneinfo/posix/Asia/Ulan_Bator -dracut_install /usr/share/zoneinfo/posix/Asia/Sakhalin -dracut_install /usr/share/zoneinfo/posix/MST7MDT -dracut_install /usr/share/zoneinfo/posix/Canada/East-Saskatchewan -dracut_install /usr/share/zoneinfo/posix/Canada/Atlantic -dracut_install /usr/share/zoneinfo/posix/Canada/Central -dracut_install /usr/share/zoneinfo/posix/Canada/Eastern -dracut_install /usr/share/zoneinfo/posix/Canada/Yukon -dracut_install /usr/share/zoneinfo/posix/Canada/Pacific -dracut_install /usr/share/zoneinfo/posix/Canada/Saskatchewan -dracut_install /usr/share/zoneinfo/posix/Canada/Mountain -dracut_install /usr/share/zoneinfo/posix/Canada/Newfoundland -dracut_install /usr/share/zoneinfo/posix/Israel -dracut_install /usr/share/zoneinfo/posix/Africa/Lagos -dracut_install /usr/share/zoneinfo/posix/Africa/Kigali -dracut_install /usr/share/zoneinfo/posix/Africa/Lome -dracut_install /usr/share/zoneinfo/posix/Africa/Niamey -dracut_install /usr/share/zoneinfo/posix/Africa/Conakry -dracut_install /usr/share/zoneinfo/posix/Africa/Asmera -dracut_install /usr/share/zoneinfo/posix/Africa/Banjul -dracut_install /usr/share/zoneinfo/posix/Africa/Abidjan -dracut_install /usr/share/zoneinfo/posix/Africa/Bujumbura -dracut_install /usr/share/zoneinfo/posix/Africa/Luanda -dracut_install /usr/share/zoneinfo/posix/Africa/Kampala -dracut_install /usr/share/zoneinfo/posix/Africa/Ouagadougou -dracut_install /usr/share/zoneinfo/posix/Africa/Libreville -dracut_install /usr/share/zoneinfo/posix/Africa/Lubumbashi -dracut_install /usr/share/zoneinfo/posix/Africa/Dakar -dracut_install /usr/share/zoneinfo/posix/Africa/Bamako -dracut_install /usr/share/zoneinfo/posix/Africa/Nairobi -dracut_install /usr/share/zoneinfo/posix/Africa/Bangui -dracut_install /usr/share/zoneinfo/posix/Africa/Johannesburg -dracut_install /usr/share/zoneinfo/posix/Africa/Accra -dracut_install /usr/share/zoneinfo/posix/Africa/Bissau -dracut_install /usr/share/zoneinfo/posix/Africa/Timbuktu -dracut_install /usr/share/zoneinfo/posix/Africa/Nouakchott -dracut_install /usr/share/zoneinfo/posix/Africa/Maputo -dracut_install /usr/share/zoneinfo/posix/Africa/Ndjamena -dracut_install /usr/share/zoneinfo/posix/Africa/Maseru -dracut_install /usr/share/zoneinfo/posix/Africa/Tripoli -dracut_install /usr/share/zoneinfo/posix/Africa/Blantyre -dracut_install /usr/share/zoneinfo/posix/Africa/Gaborone -dracut_install /usr/share/zoneinfo/posix/Africa/Addis_Ababa -dracut_install /usr/share/zoneinfo/posix/Africa/Porto-Novo -dracut_install /usr/share/zoneinfo/posix/Africa/Kinshasa -dracut_install /usr/share/zoneinfo/posix/Africa/Dar_es_Salaam -dracut_install /usr/share/zoneinfo/posix/Africa/Douala -dracut_install /usr/share/zoneinfo/posix/Africa/Mogadishu -dracut_install /usr/share/zoneinfo/posix/Africa/Monrovia -dracut_install /usr/share/zoneinfo/posix/Africa/Mbabane -dracut_install /usr/share/zoneinfo/posix/Africa/Algiers -dracut_install /usr/share/zoneinfo/posix/Africa/Lusaka -dracut_install /usr/share/zoneinfo/posix/Africa/Khartoum -dracut_install /usr/share/zoneinfo/posix/Africa/Asmara -dracut_install /usr/share/zoneinfo/posix/Africa/Tunis -dracut_install /usr/share/zoneinfo/posix/Africa/Casablanca -dracut_install /usr/share/zoneinfo/posix/Africa/Sao_Tome -dracut_install /usr/share/zoneinfo/posix/Africa/Ceuta -dracut_install /usr/share/zoneinfo/posix/Africa/El_Aaiun -dracut_install /usr/share/zoneinfo/posix/Africa/Harare -dracut_install /usr/share/zoneinfo/posix/Africa/Freetown -dracut_install /usr/share/zoneinfo/posix/Africa/Windhoek -dracut_install /usr/share/zoneinfo/posix/Africa/Djibouti -dracut_install /usr/share/zoneinfo/posix/Africa/Malabo -dracut_install /usr/share/zoneinfo/posix/Africa/Cairo -dracut_install /usr/share/zoneinfo/posix/Africa/Brazzaville -dracut_install /usr/share/zoneinfo/posix/Etc/Zulu -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-0 -dracut_install /usr/share/zoneinfo/posix/Etc/Greenwich -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+6 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+9 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-9 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+5 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT0 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-10 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+0 -dracut_install /usr/share/zoneinfo/posix/Etc/Universal -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+12 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-5 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+2 -dracut_install /usr/share/zoneinfo/posix/Etc/UTC -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+8 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-11 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-4 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-12 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+11 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+3 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+4 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+1 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-14 -dracut_install /usr/share/zoneinfo/posix/Etc/UCT -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+7 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-6 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-2 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-3 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-8 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-7 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-13 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-1 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+10 -dracut_install /usr/share/zoneinfo/posix/PST8PDT -dracut_install /usr/share/zoneinfo/posix/Jamaica -dracut_install /usr/share/zoneinfo/posix/NZ -dracut_install /usr/share/zoneinfo/posix/PRC -dracut_install /usr/share/zoneinfo/posix/Chile/EasterIsland -dracut_install /usr/share/zoneinfo/posix/Chile/Continental -dracut_install /usr/share/zoneinfo/posix/Factory -inst "$moddir/xcatroot" "/sbin/xcatroot" -inst "$moddir/dodiscovery" "/bin/dodiscovery" -inst "$moddir/udpcat.awk" "/bin/udpcat.awk" -inst "$moddir/minixcatd.awk" "/bin/minixcatd.awk" -inst "$moddir/bmcsetup" "/bin/bmcsetup" -inst "$moddir/allowcred.awk" "/bin/allowcred.awk" -inst "$moddir/getipmi" "/bin/getipmi" -inst "$moddir/remoteimmsetup" "/bin/remoteimmsetup" -inst "$moddir/getdestiny" "/bin/getdestiny" -inst "$moddir/restart" "/bin/restart" -inst "$moddir/doxcat" "/bin/doxcat" -inst "$moddir/nextdestiny" "/bin/nextdestiny" -inst "$moddir/getcert" "/bin/getcert" -inst "$moddir/dhclient.conf" "/etc/dhclient.conf" -inst "$moddir/dhclient-script" "/sbin/dhclient-script" -inst "$moddir/rsyslog.conf" "/etc/rsyslog.conf" -inst "$moddir/99-imm.rules" "/etc/udev/rules.d/99-imm.rules" -inst "$moddir/98-mlx.rules" "/etc/udev/rules.d/98-mlx.rules" -inst "$moddir/setupimmnic" "/sbin/setupimmnic" -inst "$moddir/loadmlxeth" "/sbin/loadmlxeth" -dracut_install /sbin/rpc.statd /sbin/sm-notify /etc/netconfig rpcbind /etc/host.conf /usr/sbin/rpc.idmapd -dracut_install ps free find #debug -inst_dir /var/lib/nfs -inst_dir /var/lib/nfs/statd/sm -inst_dir /var/lib/nfs/statd/sm.bak -inst_dir /var/lib/nfs/rpc_pipefs/nfs -inst "/bin/bash" "/bin/sh" -inst "/lib/libnss_dns-2.11.3.so" -inst "/lib/terminfo/l/linux" "/lib/terminfo/l/linux" -inst "/lib/terminfo/v/vt100" "/lib/terminfo/v/vt100" -inst_hook cmdline 10 "$moddir/xcat-cmdline.sh" -dracut_install /usr/lib/rsyslog/lmtcpclt.so -#dracut_install /usr/lib/rsyslog/omtesting.so -dracut_install /usr/lib/rsyslog/lmnetstrms.so -dracut_install /usr/lib/rsyslog/imfile.so -dracut_install /usr/lib/rsyslog/imklog.so -dracut_install /usr/lib/rsyslog/lmzlibw.so -dracut_install /usr/lib/rsyslog/immark.so -dracut_install /usr/lib/rsyslog/imudp.so -dracut_install /usr/lib/rsyslog/lmregexp.so -dracut_install /usr/lib/rsyslog/lmtcpsrv.so -dracut_install /usr/lib/rsyslog/lmnsd_ptcp.so -dracut_install /usr/lib/rsyslog/imtcp.so -dracut_install /usr/lib/rsyslog/lmnet.so -dracut_install /usr/lib/rsyslog/lmstrmsrv.so -dracut_install /usr/lib/rsyslog/imuxsock.so -dracut_install /usr/lib/libnfsidmap/nsswitch.so diff --git a/xCAT-nbroot2/install.ubuntu b/xCAT-nbroot2/install.ubuntu deleted file mode 100755 index ecd9fc7af..000000000 --- a/xCAT-nbroot2/install.ubuntu +++ /dev/null @@ -1,661 +0,0 @@ -#!/bin/sh -echo $drivers -version12=`awk '{print $2}' /etc/issue | grep 12` -dracut_install wget openssl tar ipmitool cpio gzip lsmod ethtool modprobe touch echo cut wc -dracut_install netstat # broadcom update requires -dracut_install uniq # mellanox update requires -dracut_install grep ip hostname awk egrep grep dirname expr -dracut_install mount.nfs sshd vi reboot lspci parted screen mkfs mkfs.ext4 mkfs.btrfs -dracut_install efibootmgr -#dracut_install libvirtd /usr/share/libvirt/cpu_map.xml /usr/bin/qemu-img /usr/libexec/qemu-kvm -dracut_install mkswap df brctl vconfig ifenslave ssh-keygen scp clear dhclient lldpad -dracut_install lldptool -dracut_install poweroff ntpq ntpd hwclock date /usr/share/terminfo/x/xterms /etc/nsswitch.conf /etc/services -dracut_install /usr/sbin/rsyslogd /etc/protocols umount /usr/bin/dpkg /usr/bin/rpm /usr/lib/rpm/rpmrc -if [ $version12 ];then - dracut_install /lib/x86_64-linux-gnu/libnss_dns-2.15.so /lib/x86_64-linux-gnu/libnss_dns.so.2 - dracut_install /lib/x86_64-linux-gnu/libdl.so.2 /lib32/libm.so.6 - dracut_install dmidecode /usr/lib/x86_64-linux-gnu/libstdc++.so.6 - dracut_install dmidecode /usr/lib/x86_64-linux-gnu/libstdc++.so.5 - dracut_install /lib32/libpthread.so.0 - dracut_install /usr/lib/x86_64-linux-gnu/libldap-2.4.so.2 /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2 /usr/lib/x86_64-linux-gnu/libsasl2.so.2 - dracut_install /lib32/libc.so.6 -else - dracut_install /lib64/libnss_dns-2.12.1.so /lib64/libnss_dns.so.2 - dracut_install /lib/libdl.so.2 /lib/libm.so.6 - dracut_install dmidecode /usr/lib64/libstdc++.so.6 - dracut_install dmidecode /usr/lib64/libstdc++.so.5 - dracut_install /lib/libpthread.so.0 #32 bit lib because UXSPI will not ship a native 64 bit build - dracut_install /usr/lib/libldap-2.4.so.2 /usr/lib/liblber-2.4.so.2 /usr/lib64/libsasl2.so.2 #uxspi has incurred these... - dracut_install /lib/libc.so.6 -fi -dracut_install chmod /lib/ld-linux.so.2 /sbin/route /sbin/ifconfig /usr/bin/head /etc/debian_version /etc/lsb-release ping tr lsusb /usr/share/hwdata/usb.ids #ibm fw wrapper requirements -dracut_install /usr/share/zoneinfo/posix/Zulu -dracut_install /usr/share/zoneinfo/posix/GMT-0 -dracut_install /usr/share/zoneinfo/posix/Europe/Istanbul -dracut_install /usr/share/zoneinfo/posix/Europe/San_Marino -dracut_install /usr/share/zoneinfo/posix/Europe/Jersey -dracut_install /usr/share/zoneinfo/posix/Europe/Bucharest -dracut_install /usr/share/zoneinfo/posix/Europe/Gibraltar -dracut_install /usr/share/zoneinfo/posix/Europe/Uzhgorod -dracut_install /usr/share/zoneinfo/posix/Europe/Moscow -dracut_install /usr/share/zoneinfo/posix/Europe/Brussels -dracut_install /usr/share/zoneinfo/posix/Europe/Nicosia -dracut_install /usr/share/zoneinfo/posix/Europe/Zurich -dracut_install /usr/share/zoneinfo/posix/Europe/Berlin -dracut_install /usr/share/zoneinfo/posix/Europe/Guernsey -dracut_install /usr/share/zoneinfo/posix/Europe/Budapest -dracut_install /usr/share/zoneinfo/posix/Europe/Kiev -dracut_install /usr/share/zoneinfo/posix/Europe/Podgorica -dracut_install /usr/share/zoneinfo/posix/Europe/Isle_of_Man -dracut_install /usr/share/zoneinfo/posix/Europe/Mariehamn -dracut_install /usr/share/zoneinfo/posix/Europe/Belgrade -dracut_install /usr/share/zoneinfo/posix/Europe/Belfast -dracut_install /usr/share/zoneinfo/posix/Europe/Ljubljana -dracut_install /usr/share/zoneinfo/posix/Europe/Chisinau -dracut_install /usr/share/zoneinfo/posix/Europe/Andorra -dracut_install /usr/share/zoneinfo/posix/Europe/Athens -dracut_install /usr/share/zoneinfo/posix/Europe/Stockholm -dracut_install /usr/share/zoneinfo/posix/Europe/Vienna -dracut_install /usr/share/zoneinfo/posix/Europe/Lisbon -dracut_install /usr/share/zoneinfo/posix/Europe/London -dracut_install /usr/share/zoneinfo/posix/Europe/Paris -dracut_install /usr/share/zoneinfo/posix/Europe/Oslo -dracut_install /usr/share/zoneinfo/posix/Europe/Zagreb -dracut_install /usr/share/zoneinfo/posix/Europe/Helsinki -dracut_install /usr/share/zoneinfo/posix/Europe/Warsaw -dracut_install /usr/share/zoneinfo/posix/Europe/Copenhagen -dracut_install /usr/share/zoneinfo/posix/Europe/Riga -dracut_install /usr/share/zoneinfo/posix/Europe/Vaduz -dracut_install /usr/share/zoneinfo/posix/Europe/Vilnius -dracut_install /usr/share/zoneinfo/posix/Europe/Volgograd -dracut_install /usr/share/zoneinfo/posix/Europe/Amsterdam -dracut_install /usr/share/zoneinfo/posix/Europe/Tiraspol -dracut_install /usr/share/zoneinfo/posix/Europe/Tallinn -dracut_install /usr/share/zoneinfo/posix/Europe/Kaliningrad -dracut_install /usr/share/zoneinfo/posix/Europe/Malta -dracut_install /usr/share/zoneinfo/posix/Europe/Sarajevo -dracut_install /usr/share/zoneinfo/posix/Europe/Madrid -dracut_install /usr/share/zoneinfo/posix/Europe/Zaporozhye -dracut_install /usr/share/zoneinfo/posix/Europe/Simferopol -dracut_install /usr/share/zoneinfo/posix/Europe/Sofia -dracut_install /usr/share/zoneinfo/posix/Europe/Skopje -dracut_install /usr/share/zoneinfo/posix/Europe/Monaco -dracut_install /usr/share/zoneinfo/posix/Europe/Rome -dracut_install /usr/share/zoneinfo/posix/Europe/Prague -dracut_install /usr/share/zoneinfo/posix/Europe/Luxembourg -dracut_install /usr/share/zoneinfo/posix/Europe/Minsk -dracut_install /usr/share/zoneinfo/posix/Europe/Vatican -dracut_install /usr/share/zoneinfo/posix/Europe/Dublin -dracut_install /usr/share/zoneinfo/posix/Europe/Samara -dracut_install /usr/share/zoneinfo/posix/Europe/Tirane -dracut_install /usr/share/zoneinfo/posix/Europe/Bratislava -dracut_install /usr/share/zoneinfo/posix/Greenwich -dracut_install /usr/share/zoneinfo/posix/US/Indiana-Starke -dracut_install /usr/share/zoneinfo/posix/US/Alaska -dracut_install /usr/share/zoneinfo/posix/US/Michigan -dracut_install /usr/share/zoneinfo/posix/US/Aleutian -dracut_install /usr/share/zoneinfo/posix/US/Hawaii -dracut_install /usr/share/zoneinfo/posix/US/Central -dracut_install /usr/share/zoneinfo/posix/US/Eastern -dracut_install /usr/share/zoneinfo/posix/US/Pacific -dracut_install /usr/share/zoneinfo/posix/US/Samoa -dracut_install /usr/share/zoneinfo/posix/US/Mountain -dracut_install /usr/share/zoneinfo/posix/US/Arizona -dracut_install /usr/share/zoneinfo/posix/US/East-Indiana -dracut_install /usr/share/zoneinfo/posix/EST -dracut_install /usr/share/zoneinfo/posix/HST -dracut_install /usr/share/zoneinfo/posix/Eire -dracut_install /usr/share/zoneinfo/posix/America/Cancun -dracut_install /usr/share/zoneinfo/posix/America/Santo_Domingo -dracut_install /usr/share/zoneinfo/posix/America/Jujuy -dracut_install /usr/share/zoneinfo/posix/America/Guatemala -dracut_install /usr/share/zoneinfo/posix/America/Monterrey -dracut_install /usr/share/zoneinfo/posix/America/Ensenada -dracut_install /usr/share/zoneinfo/posix/America/Dawson_Creek -dracut_install /usr/share/zoneinfo/posix/America/Mendoza -dracut_install /usr/share/zoneinfo/posix/America/Coral_Harbour -dracut_install /usr/share/zoneinfo/posix/America/Martinique -dracut_install /usr/share/zoneinfo/posix/America/Cordoba -dracut_install /usr/share/zoneinfo/posix/America/Recife -dracut_install /usr/share/zoneinfo/posix/America/Cayman -dracut_install /usr/share/zoneinfo/posix/America/Shiprock -dracut_install /usr/share/zoneinfo/posix/America/Tortola -dracut_install /usr/share/zoneinfo/posix/America/Lima -dracut_install /usr/share/zoneinfo/posix/America/Antigua -dracut_install /usr/share/zoneinfo/posix/America/Blanc-Sablon -dracut_install /usr/share/zoneinfo/posix/America/Nipigon -dracut_install /usr/share/zoneinfo/posix/America/Nome -dracut_install /usr/share/zoneinfo/posix/America/Montserrat -dracut_install /usr/share/zoneinfo/posix/America/Atka -dracut_install /usr/share/zoneinfo/posix/America/St_Thomas -dracut_install /usr/share/zoneinfo/posix/America/Halifax -dracut_install /usr/share/zoneinfo/posix/America/Montreal -dracut_install /usr/share/zoneinfo/posix/America/Curacao -dracut_install /usr/share/zoneinfo/posix/America/Cuiaba -dracut_install /usr/share/zoneinfo/posix/America/Winnipeg -dracut_install /usr/share/zoneinfo/posix/America/North_Dakota/New_Salem -dracut_install /usr/share/zoneinfo/posix/America/North_Dakota/Center -dracut_install /usr/share/zoneinfo/posix/America/Panama -dracut_install /usr/share/zoneinfo/posix/America/Rosario -dracut_install /usr/share/zoneinfo/posix/America/Anguilla -dracut_install /usr/share/zoneinfo/posix/America/Ojinaga -dracut_install /usr/share/zoneinfo/posix/America/Guyana -dracut_install /usr/share/zoneinfo/posix/America/Eirunepe -dracut_install /usr/share/zoneinfo/posix/America/Grand_Turk -dracut_install /usr/share/zoneinfo/posix/America/Rio_Branco -dracut_install /usr/share/zoneinfo/posix/America/Santa_Isabel -dracut_install /usr/share/zoneinfo/posix/America/Scoresbysund -dracut_install /usr/share/zoneinfo/posix/America/Adak -dracut_install /usr/share/zoneinfo/posix/America/Menominee -dracut_install /usr/share/zoneinfo/posix/America/Resolute -dracut_install /usr/share/zoneinfo/posix/America/Guadeloupe -dracut_install /usr/share/zoneinfo/posix/America/Indianapolis -dracut_install /usr/share/zoneinfo/posix/America/Vancouver -dracut_install /usr/share/zoneinfo/posix/America/Glace_Bay -dracut_install /usr/share/zoneinfo/posix/America/Buenos_Aires -dracut_install /usr/share/zoneinfo/posix/America/Virgin -dracut_install /usr/share/zoneinfo/posix/America/Belem -dracut_install /usr/share/zoneinfo/posix/America/Catamarca -dracut_install /usr/share/zoneinfo/posix/America/Bahia -dracut_install /usr/share/zoneinfo/posix/America/Fort_Wayne -dracut_install /usr/share/zoneinfo/posix/America/Hermosillo -dracut_install /usr/share/zoneinfo/posix/America/Rankin_Inlet -dracut_install /usr/share/zoneinfo/posix/America/Mexico_City -dracut_install /usr/share/zoneinfo/posix/America/Belize -dracut_install /usr/share/zoneinfo/posix/America/Maceio -dracut_install /usr/share/zoneinfo/posix/America/Dominica -dracut_install /usr/share/zoneinfo/posix/America/Swift_Current -dracut_install /usr/share/zoneinfo/posix/America/St_Johns -dracut_install /usr/share/zoneinfo/posix/America/St_Barthelemy -dracut_install /usr/share/zoneinfo/posix/America/Yellowknife -dracut_install /usr/share/zoneinfo/posix/America/Costa_Rica -dracut_install /usr/share/zoneinfo/posix/America/Pangnirtung -dracut_install /usr/share/zoneinfo/posix/America/Bogota -dracut_install /usr/share/zoneinfo/posix/America/Port-au-Prince -dracut_install /usr/share/zoneinfo/posix/America/Phoenix -dracut_install /usr/share/zoneinfo/posix/America/Port_of_Spain -dracut_install /usr/share/zoneinfo/posix/America/Matamoros -dracut_install /usr/share/zoneinfo/posix/America/Puerto_Rico -dracut_install /usr/share/zoneinfo/posix/America/Detroit -dracut_install /usr/share/zoneinfo/posix/America/Edmonton -dracut_install /usr/share/zoneinfo/posix/America/Toronto -dracut_install /usr/share/zoneinfo/posix/America/Cambridge_Bay -dracut_install /usr/share/zoneinfo/posix/America/Godthab -dracut_install /usr/share/zoneinfo/posix/America/Atikokan -dracut_install /usr/share/zoneinfo/posix/America/Juneau -dracut_install /usr/share/zoneinfo/posix/America/Managua -dracut_install /usr/share/zoneinfo/posix/America/Anchorage -dracut_install /usr/share/zoneinfo/posix/America/Merida -dracut_install /usr/share/zoneinfo/posix/America/Thunder_Bay -dracut_install /usr/share/zoneinfo/posix/America/Porto_Velho -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Jujuy -dracut_install /usr/share/zoneinfo/posix/America/Argentina/La_Rioja -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Mendoza -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Cordoba -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Ushuaia -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Rio_Gallegos -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Buenos_Aires -dracut_install /usr/share/zoneinfo/posix/America/Argentina/San_Juan -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Catamarca -dracut_install /usr/share/zoneinfo/posix/America/Argentina/San_Luis -dracut_install /usr/share/zoneinfo/posix/America/Argentina/ComodRivadavia -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Salta -dracut_install /usr/share/zoneinfo/posix/America/Argentina/Tucuman -dracut_install /usr/share/zoneinfo/posix/America/Iqaluit -dracut_install /usr/share/zoneinfo/posix/America/Chicago -dracut_install /usr/share/zoneinfo/posix/America/Miquelon -dracut_install /usr/share/zoneinfo/posix/America/Havana -dracut_install /usr/share/zoneinfo/posix/America/Guayaquil -dracut_install /usr/share/zoneinfo/posix/America/St_Vincent -dracut_install /usr/share/zoneinfo/posix/America/St_Lucia -dracut_install /usr/share/zoneinfo/posix/America/Boise -dracut_install /usr/share/zoneinfo/posix/America/Yakutat -dracut_install /usr/share/zoneinfo/posix/America/Santarem -dracut_install /usr/share/zoneinfo/posix/America/Campo_Grande -dracut_install /usr/share/zoneinfo/posix/America/Santiago -dracut_install /usr/share/zoneinfo/posix/America/Porto_Acre -dracut_install /usr/share/zoneinfo/posix/America/Sao_Paulo -dracut_install /usr/share/zoneinfo/posix/America/Thule -dracut_install /usr/share/zoneinfo/posix/America/New_York -dracut_install /usr/share/zoneinfo/posix/America/Nassau -dracut_install /usr/share/zoneinfo/posix/America/Dawson -dracut_install /usr/share/zoneinfo/posix/America/Louisville -dracut_install /usr/share/zoneinfo/posix/America/Asuncion -dracut_install /usr/share/zoneinfo/posix/America/Inuvik -dracut_install /usr/share/zoneinfo/posix/America/Paramaribo -dracut_install /usr/share/zoneinfo/posix/America/Chihuahua -dracut_install /usr/share/zoneinfo/posix/America/Mazatlan -dracut_install /usr/share/zoneinfo/posix/America/Grenada -dracut_install /usr/share/zoneinfo/posix/America/Denver -dracut_install /usr/share/zoneinfo/posix/America/Los_Angeles -dracut_install /usr/share/zoneinfo/posix/America/Marigot -dracut_install /usr/share/zoneinfo/posix/America/Manaus -dracut_install /usr/share/zoneinfo/posix/America/Regina -dracut_install /usr/share/zoneinfo/posix/America/Barbados -dracut_install /usr/share/zoneinfo/posix/America/Noronha -dracut_install /usr/share/zoneinfo/posix/America/Montevideo -dracut_install /usr/share/zoneinfo/posix/America/Caracas -dracut_install /usr/share/zoneinfo/posix/America/Rainy_River -dracut_install /usr/share/zoneinfo/posix/America/La_Paz -dracut_install /usr/share/zoneinfo/posix/America/Jamaica -dracut_install /usr/share/zoneinfo/posix/America/Moncton -dracut_install /usr/share/zoneinfo/posix/America/Whitehorse -dracut_install /usr/share/zoneinfo/posix/America/Fortaleza -dracut_install /usr/share/zoneinfo/posix/America/Kentucky/Monticello -dracut_install /usr/share/zoneinfo/posix/America/Kentucky/Louisville -dracut_install /usr/share/zoneinfo/posix/America/Indiana/Marengo -dracut_install /usr/share/zoneinfo/posix/America/Indiana/Indianapolis -dracut_install /usr/share/zoneinfo/posix/America/Indiana/Knox -dracut_install /usr/share/zoneinfo/posix/America/Indiana/Tell_City -dracut_install /usr/share/zoneinfo/posix/America/Indiana/Petersburg -dracut_install /usr/share/zoneinfo/posix/America/Indiana/Winamac -dracut_install /usr/share/zoneinfo/posix/America/Indiana/Vincennes -dracut_install /usr/share/zoneinfo/posix/America/Indiana/Vevay -dracut_install /usr/share/zoneinfo/posix/America/Danmarkshavn -dracut_install /usr/share/zoneinfo/posix/America/St_Kitts -dracut_install /usr/share/zoneinfo/posix/America/Aruba -dracut_install /usr/share/zoneinfo/posix/America/Boa_Vista -dracut_install /usr/share/zoneinfo/posix/America/Bahia_Banderas -dracut_install /usr/share/zoneinfo/posix/America/Tegucigalpa -dracut_install /usr/share/zoneinfo/posix/America/Araguaina -dracut_install /usr/share/zoneinfo/posix/America/El_Salvador -dracut_install /usr/share/zoneinfo/posix/America/Cayenne -dracut_install /usr/share/zoneinfo/posix/America/Tijuana -dracut_install /usr/share/zoneinfo/posix/America/Knox_IN -dracut_install /usr/share/zoneinfo/posix/America/Goose_Bay -dracut_install /usr/share/zoneinfo/posix/EET -dracut_install /usr/share/zoneinfo/posix/EST5EDT -dracut_install /usr/share/zoneinfo/posix/Mideast/Riyadh89 -dracut_install /usr/share/zoneinfo/posix/Mideast/Riyadh88 -dracut_install /usr/share/zoneinfo/posix/Mideast/Riyadh87 -dracut_install /usr/share/zoneinfo/posix/MST -dracut_install /usr/share/zoneinfo/posix/Iceland -dracut_install /usr/share/zoneinfo/posix/Atlantic/Faeroe -dracut_install /usr/share/zoneinfo/posix/Atlantic/Stanley -dracut_install /usr/share/zoneinfo/posix/Atlantic/Reykjavik -dracut_install /usr/share/zoneinfo/posix/Atlantic/St_Helena -dracut_install /usr/share/zoneinfo/posix/Atlantic/Faroe -dracut_install /usr/share/zoneinfo/posix/Atlantic/South_Georgia -dracut_install /usr/share/zoneinfo/posix/Atlantic/Jan_Mayen -dracut_install /usr/share/zoneinfo/posix/Atlantic/Azores -dracut_install /usr/share/zoneinfo/posix/Atlantic/Cape_Verde -dracut_install /usr/share/zoneinfo/posix/Atlantic/Madeira -dracut_install /usr/share/zoneinfo/posix/Atlantic/Bermuda -dracut_install /usr/share/zoneinfo/posix/Atlantic/Canary -dracut_install /usr/share/zoneinfo/posix/GMT0 -dracut_install /usr/share/zoneinfo/posix/Poland -dracut_install /usr/share/zoneinfo/posix/Indian/Chagos -dracut_install /usr/share/zoneinfo/posix/Indian/Maldives -dracut_install /usr/share/zoneinfo/posix/Indian/Comoro -dracut_install /usr/share/zoneinfo/posix/Indian/Mauritius -dracut_install /usr/share/zoneinfo/posix/Indian/Mayotte -dracut_install /usr/share/zoneinfo/posix/Indian/Christmas -dracut_install /usr/share/zoneinfo/posix/Indian/Antananarivo -dracut_install /usr/share/zoneinfo/posix/Indian/Kerguelen -dracut_install /usr/share/zoneinfo/posix/Indian/Mahe -dracut_install /usr/share/zoneinfo/posix/Indian/Cocos -dracut_install /usr/share/zoneinfo/posix/Indian/Reunion -dracut_install /usr/share/zoneinfo/posix/Mexico/BajaNorte -dracut_install /usr/share/zoneinfo/posix/Mexico/BajaSur -dracut_install /usr/share/zoneinfo/posix/Mexico/General -dracut_install /usr/share/zoneinfo/posix/Turkey -dracut_install /usr/share/zoneinfo/posix/Egypt -dracut_install /usr/share/zoneinfo/posix/Hongkong -dracut_install /usr/share/zoneinfo/posix/GB -dracut_install /usr/share/zoneinfo/posix/GMT+0 -dracut_install /usr/share/zoneinfo/posix/ROK -dracut_install /usr/share/zoneinfo/posix/Antarctica/Mawson -dracut_install /usr/share/zoneinfo/posix/Antarctica/Macquarie -dracut_install /usr/share/zoneinfo/posix/Antarctica/South_Pole -dracut_install /usr/share/zoneinfo/posix/Antarctica/Rothera -dracut_install /usr/share/zoneinfo/posix/Antarctica/Davis -dracut_install /usr/share/zoneinfo/posix/Antarctica/DumontDUrville -dracut_install /usr/share/zoneinfo/posix/Antarctica/McMurdo -dracut_install /usr/share/zoneinfo/posix/Antarctica/Casey -dracut_install /usr/share/zoneinfo/posix/Antarctica/Vostok -dracut_install /usr/share/zoneinfo/posix/Antarctica/Palmer -dracut_install /usr/share/zoneinfo/posix/Antarctica/Syowa -dracut_install /usr/share/zoneinfo/posix/Universal -dracut_install /usr/share/zoneinfo/posix/CET -dracut_install /usr/share/zoneinfo/posix/WET -dracut_install /usr/share/zoneinfo/posix/Navajo -dracut_install /usr/share/zoneinfo/posix/UTC -dracut_install /usr/share/zoneinfo/posix/Pacific/Enderbury -dracut_install /usr/share/zoneinfo/posix/Pacific/Johnston -dracut_install /usr/share/zoneinfo/posix/Pacific/Pago_Pago -dracut_install /usr/share/zoneinfo/posix/Pacific/Saipan -dracut_install /usr/share/zoneinfo/posix/Pacific/Norfolk -dracut_install /usr/share/zoneinfo/posix/Pacific/Chuuk -dracut_install /usr/share/zoneinfo/posix/Pacific/Galapagos -dracut_install /usr/share/zoneinfo/posix/Pacific/Palau -dracut_install /usr/share/zoneinfo/posix/Pacific/Tarawa -dracut_install /usr/share/zoneinfo/posix/Pacific/Fakaofo -dracut_install /usr/share/zoneinfo/posix/Pacific/Rarotonga -dracut_install /usr/share/zoneinfo/posix/Pacific/Wake -dracut_install /usr/share/zoneinfo/posix/Pacific/Kosrae -dracut_install /usr/share/zoneinfo/posix/Pacific/Tahiti -dracut_install /usr/share/zoneinfo/posix/Pacific/Fiji -dracut_install /usr/share/zoneinfo/posix/Pacific/Ponape -dracut_install /usr/share/zoneinfo/posix/Pacific/Tongatapu -dracut_install /usr/share/zoneinfo/posix/Pacific/Efate -dracut_install /usr/share/zoneinfo/posix/Pacific/Honolulu -dracut_install /usr/share/zoneinfo/posix/Pacific/Niue -dracut_install /usr/share/zoneinfo/posix/Pacific/Kwajalein -dracut_install /usr/share/zoneinfo/posix/Pacific/Guam -dracut_install /usr/share/zoneinfo/posix/Pacific/Funafuti -dracut_install /usr/share/zoneinfo/posix/Pacific/Majuro -dracut_install /usr/share/zoneinfo/posix/Pacific/Midway -dracut_install /usr/share/zoneinfo/posix/Pacific/Nauru -dracut_install /usr/share/zoneinfo/posix/Pacific/Samoa -dracut_install /usr/share/zoneinfo/posix/Pacific/Marquesas -dracut_install /usr/share/zoneinfo/posix/Pacific/Kiritimati -dracut_install /usr/share/zoneinfo/posix/Pacific/Noumea -dracut_install /usr/share/zoneinfo/posix/Pacific/Truk -dracut_install /usr/share/zoneinfo/posix/Pacific/Guadalcanal -dracut_install /usr/share/zoneinfo/posix/Pacific/Pohnpei -dracut_install /usr/share/zoneinfo/posix/Pacific/Pitcairn -dracut_install /usr/share/zoneinfo/posix/Pacific/Port_Moresby -dracut_install /usr/share/zoneinfo/posix/Pacific/Yap -dracut_install /usr/share/zoneinfo/posix/Pacific/Easter -dracut_install /usr/share/zoneinfo/posix/Pacific/Wallis -dracut_install /usr/share/zoneinfo/posix/Pacific/Apia -dracut_install /usr/share/zoneinfo/posix/Pacific/Auckland -dracut_install /usr/share/zoneinfo/posix/Pacific/Gambier -dracut_install /usr/share/zoneinfo/posix/Pacific/Chatham -dracut_install /usr/share/zoneinfo/posix/Japan -dracut_install /usr/share/zoneinfo/posix/Libya -dracut_install /usr/share/zoneinfo/posix/ROC -dracut_install /usr/share/zoneinfo/posix/Iran -dracut_install /usr/share/zoneinfo/posix/Brazil/West -dracut_install /usr/share/zoneinfo/posix/Brazil/East -dracut_install /usr/share/zoneinfo/posix/Brazil/Acre -dracut_install /usr/share/zoneinfo/posix/Brazil/DeNoronha -dracut_install /usr/share/zoneinfo/posix/Arctic/Longyearbyen -dracut_install /usr/share/zoneinfo/posix/Portugal -dracut_install /usr/share/zoneinfo/posix/MET -dracut_install /usr/share/zoneinfo/posix/W-SU -dracut_install /usr/share/zoneinfo/posix/Kwajalein -dracut_install /usr/share/zoneinfo/posix/CST6CDT -dracut_install /usr/share/zoneinfo/posix/GB-Eire -dracut_install /usr/share/zoneinfo/posix/Australia/Melbourne -dracut_install /usr/share/zoneinfo/posix/Australia/Broken_Hill -dracut_install /usr/share/zoneinfo/posix/Australia/Queensland -dracut_install /usr/share/zoneinfo/posix/Australia/South -dracut_install /usr/share/zoneinfo/posix/Australia/Eucla -dracut_install /usr/share/zoneinfo/posix/Australia/Yancowinna -dracut_install /usr/share/zoneinfo/posix/Australia/Lord_Howe -dracut_install /usr/share/zoneinfo/posix/Australia/Hobart -dracut_install /usr/share/zoneinfo/posix/Australia/NSW -dracut_install /usr/share/zoneinfo/posix/Australia/West -dracut_install /usr/share/zoneinfo/posix/Australia/LHI -dracut_install /usr/share/zoneinfo/posix/Australia/Perth -dracut_install /usr/share/zoneinfo/posix/Australia/ACT -dracut_install /usr/share/zoneinfo/posix/Australia/Darwin -dracut_install /usr/share/zoneinfo/posix/Australia/Lindeman -dracut_install /usr/share/zoneinfo/posix/Australia/Sydney -dracut_install /usr/share/zoneinfo/posix/Australia/North -dracut_install /usr/share/zoneinfo/posix/Australia/Canberra -dracut_install /usr/share/zoneinfo/posix/Australia/Adelaide -dracut_install /usr/share/zoneinfo/posix/Australia/Brisbane -dracut_install /usr/share/zoneinfo/posix/Australia/Victoria -dracut_install /usr/share/zoneinfo/posix/Australia/Tasmania -dracut_install /usr/share/zoneinfo/posix/Australia/Currie -dracut_install /usr/share/zoneinfo/posix/UCT -dracut_install /usr/share/zoneinfo/posix/Cuba -dracut_install /usr/share/zoneinfo/posix/Singapore -dracut_install /usr/share/zoneinfo/posix/GMT -dracut_install /usr/share/zoneinfo/posix/NZ-CHAT -dracut_install /usr/share/zoneinfo/posix/Asia/Istanbul -dracut_install /usr/share/zoneinfo/posix/Asia/Kuwait -dracut_install /usr/share/zoneinfo/posix/Asia/Saigon -dracut_install /usr/share/zoneinfo/posix/Asia/Riyadh89 -dracut_install /usr/share/zoneinfo/posix/Asia/Urumqi -dracut_install /usr/share/zoneinfo/posix/Asia/Brunei -dracut_install /usr/share/zoneinfo/posix/Asia/Ujung_Pandang -dracut_install /usr/share/zoneinfo/posix/Asia/Muscat -dracut_install /usr/share/zoneinfo/posix/Asia/Kashgar -dracut_install /usr/share/zoneinfo/posix/Asia/Kamchatka -dracut_install /usr/share/zoneinfo/posix/Asia/Manila -dracut_install /usr/share/zoneinfo/posix/Asia/Vladivostok -dracut_install /usr/share/zoneinfo/posix/Asia/Jayapura -dracut_install /usr/share/zoneinfo/posix/Asia/Magadan -dracut_install /usr/share/zoneinfo/posix/Asia/Almaty -dracut_install /usr/share/zoneinfo/posix/Asia/Qyzylorda -dracut_install /usr/share/zoneinfo/posix/Asia/Anadyr -dracut_install /usr/share/zoneinfo/posix/Asia/Nicosia -dracut_install /usr/share/zoneinfo/posix/Asia/Kathmandu -dracut_install /usr/share/zoneinfo/posix/Asia/Qatar -dracut_install /usr/share/zoneinfo/posix/Asia/Jerusalem -dracut_install /usr/share/zoneinfo/posix/Asia/Yakutsk -dracut_install /usr/share/zoneinfo/posix/Asia/Karachi -dracut_install /usr/share/zoneinfo/posix/Asia/Samarkand -dracut_install /usr/share/zoneinfo/posix/Asia/Kolkata -dracut_install /usr/share/zoneinfo/posix/Asia/Ulaanbaatar -dracut_install /usr/share/zoneinfo/posix/Asia/Irkutsk -dracut_install /usr/share/zoneinfo/posix/Asia/Baku -dracut_install /usr/share/zoneinfo/posix/Asia/Gaza -dracut_install /usr/share/zoneinfo/posix/Asia/Seoul -dracut_install /usr/share/zoneinfo/posix/Asia/Chungking -dracut_install /usr/share/zoneinfo/posix/Asia/Amman -dracut_install /usr/share/zoneinfo/posix/Asia/Kuala_Lumpur -dracut_install /usr/share/zoneinfo/posix/Asia/Aqtobe -dracut_install /usr/share/zoneinfo/posix/Asia/Katmandu -dracut_install /usr/share/zoneinfo/posix/Asia/Tashkent -dracut_install /usr/share/zoneinfo/posix/Asia/Oral -dracut_install /usr/share/zoneinfo/posix/Asia/Dhaka -dracut_install /usr/share/zoneinfo/posix/Asia/Hovd -dracut_install /usr/share/zoneinfo/posix/Asia/Makassar -dracut_install /usr/share/zoneinfo/posix/Asia/Bangkok -dracut_install /usr/share/zoneinfo/posix/Asia/Tokyo -dracut_install /usr/share/zoneinfo/posix/Asia/Macao -dracut_install /usr/share/zoneinfo/posix/Asia/Riyadh -dracut_install /usr/share/zoneinfo/posix/Asia/Rangoon -dracut_install /usr/share/zoneinfo/posix/Asia/Riyadh88 -dracut_install /usr/share/zoneinfo/posix/Asia/Jakarta -dracut_install /usr/share/zoneinfo/posix/Asia/Aden -dracut_install /usr/share/zoneinfo/posix/Asia/Calcutta -dracut_install /usr/share/zoneinfo/posix/Asia/Ashkhabad -dracut_install /usr/share/zoneinfo/posix/Asia/Beirut -dracut_install /usr/share/zoneinfo/posix/Asia/Harbin -dracut_install /usr/share/zoneinfo/posix/Asia/Novosibirsk -dracut_install /usr/share/zoneinfo/posix/Asia/Omsk -dracut_install /usr/share/zoneinfo/posix/Asia/Aqtau -dracut_install /usr/share/zoneinfo/posix/Asia/Bahrain -dracut_install /usr/share/zoneinfo/posix/Asia/Dili -dracut_install /usr/share/zoneinfo/posix/Asia/Pontianak -dracut_install /usr/share/zoneinfo/posix/Asia/Singapore -dracut_install /usr/share/zoneinfo/posix/Asia/Baghdad -dracut_install /usr/share/zoneinfo/posix/Asia/Novokuznetsk -dracut_install /usr/share/zoneinfo/posix/Asia/Dubai -dracut_install /usr/share/zoneinfo/posix/Asia/Dushanbe -dracut_install /usr/share/zoneinfo/posix/Asia/Damascus -dracut_install /usr/share/zoneinfo/posix/Asia/Krasnoyarsk -dracut_install /usr/share/zoneinfo/posix/Asia/Tbilisi -dracut_install /usr/share/zoneinfo/posix/Asia/Yerevan -dracut_install /usr/share/zoneinfo/posix/Asia/Pyongyang -dracut_install /usr/share/zoneinfo/posix/Asia/Bishkek -dracut_install /usr/share/zoneinfo/posix/Asia/Colombo -dracut_install /usr/share/zoneinfo/posix/Asia/Yekaterinburg -dracut_install /usr/share/zoneinfo/posix/Asia/Chongqing -dracut_install /usr/share/zoneinfo/posix/Asia/Ho_Chi_Minh -dracut_install /usr/share/zoneinfo/posix/Asia/Hong_Kong -dracut_install /usr/share/zoneinfo/posix/Asia/Thimbu -dracut_install /usr/share/zoneinfo/posix/Asia/Thimphu -dracut_install /usr/share/zoneinfo/posix/Asia/Ashgabat -dracut_install /usr/share/zoneinfo/posix/Asia/Shanghai -dracut_install /usr/share/zoneinfo/posix/Asia/Tehran -dracut_install /usr/share/zoneinfo/posix/Asia/Tel_Aviv -dracut_install /usr/share/zoneinfo/posix/Asia/Taipei -dracut_install /usr/share/zoneinfo/posix/Asia/Kabul -dracut_install /usr/share/zoneinfo/posix/Asia/Macau -dracut_install /usr/share/zoneinfo/posix/Asia/Riyadh87 -dracut_install /usr/share/zoneinfo/posix/Asia/Choibalsan -dracut_install /usr/share/zoneinfo/posix/Asia/Vientiane -dracut_install /usr/share/zoneinfo/posix/Asia/Dacca -dracut_install /usr/share/zoneinfo/posix/Asia/Kuching -dracut_install /usr/share/zoneinfo/posix/Asia/Phnom_Penh -dracut_install /usr/share/zoneinfo/posix/Asia/Ulan_Bator -dracut_install /usr/share/zoneinfo/posix/Asia/Sakhalin -dracut_install /usr/share/zoneinfo/posix/MST7MDT -dracut_install /usr/share/zoneinfo/posix/Canada/East-Saskatchewan -dracut_install /usr/share/zoneinfo/posix/Canada/Atlantic -dracut_install /usr/share/zoneinfo/posix/Canada/Central -dracut_install /usr/share/zoneinfo/posix/Canada/Eastern -dracut_install /usr/share/zoneinfo/posix/Canada/Yukon -dracut_install /usr/share/zoneinfo/posix/Canada/Pacific -dracut_install /usr/share/zoneinfo/posix/Canada/Saskatchewan -dracut_install /usr/share/zoneinfo/posix/Canada/Mountain -dracut_install /usr/share/zoneinfo/posix/Canada/Newfoundland -dracut_install /usr/share/zoneinfo/posix/Israel -dracut_install /usr/share/zoneinfo/posix/Africa/Lagos -dracut_install /usr/share/zoneinfo/posix/Africa/Kigali -dracut_install /usr/share/zoneinfo/posix/Africa/Lome -dracut_install /usr/share/zoneinfo/posix/Africa/Niamey -dracut_install /usr/share/zoneinfo/posix/Africa/Conakry -dracut_install /usr/share/zoneinfo/posix/Africa/Asmera -dracut_install /usr/share/zoneinfo/posix/Africa/Banjul -dracut_install /usr/share/zoneinfo/posix/Africa/Abidjan -dracut_install /usr/share/zoneinfo/posix/Africa/Bujumbura -dracut_install /usr/share/zoneinfo/posix/Africa/Luanda -dracut_install /usr/share/zoneinfo/posix/Africa/Kampala -dracut_install /usr/share/zoneinfo/posix/Africa/Ouagadougou -dracut_install /usr/share/zoneinfo/posix/Africa/Libreville -dracut_install /usr/share/zoneinfo/posix/Africa/Lubumbashi -dracut_install /usr/share/zoneinfo/posix/Africa/Dakar -dracut_install /usr/share/zoneinfo/posix/Africa/Bamako -dracut_install /usr/share/zoneinfo/posix/Africa/Nairobi -dracut_install /usr/share/zoneinfo/posix/Africa/Bangui -dracut_install /usr/share/zoneinfo/posix/Africa/Johannesburg -dracut_install /usr/share/zoneinfo/posix/Africa/Accra -dracut_install /usr/share/zoneinfo/posix/Africa/Bissau -dracut_install /usr/share/zoneinfo/posix/Africa/Timbuktu -dracut_install /usr/share/zoneinfo/posix/Africa/Nouakchott -dracut_install /usr/share/zoneinfo/posix/Africa/Maputo -dracut_install /usr/share/zoneinfo/posix/Africa/Ndjamena -dracut_install /usr/share/zoneinfo/posix/Africa/Maseru -dracut_install /usr/share/zoneinfo/posix/Africa/Tripoli -dracut_install /usr/share/zoneinfo/posix/Africa/Blantyre -dracut_install /usr/share/zoneinfo/posix/Africa/Gaborone -dracut_install /usr/share/zoneinfo/posix/Africa/Addis_Ababa -dracut_install /usr/share/zoneinfo/posix/Africa/Porto-Novo -dracut_install /usr/share/zoneinfo/posix/Africa/Kinshasa -dracut_install /usr/share/zoneinfo/posix/Africa/Dar_es_Salaam -dracut_install /usr/share/zoneinfo/posix/Africa/Douala -dracut_install /usr/share/zoneinfo/posix/Africa/Mogadishu -dracut_install /usr/share/zoneinfo/posix/Africa/Monrovia -dracut_install /usr/share/zoneinfo/posix/Africa/Mbabane -dracut_install /usr/share/zoneinfo/posix/Africa/Algiers -dracut_install /usr/share/zoneinfo/posix/Africa/Lusaka -dracut_install /usr/share/zoneinfo/posix/Africa/Khartoum -dracut_install /usr/share/zoneinfo/posix/Africa/Asmara -dracut_install /usr/share/zoneinfo/posix/Africa/Tunis -dracut_install /usr/share/zoneinfo/posix/Africa/Casablanca -dracut_install /usr/share/zoneinfo/posix/Africa/Sao_Tome -dracut_install /usr/share/zoneinfo/posix/Africa/Ceuta -dracut_install /usr/share/zoneinfo/posix/Africa/El_Aaiun -dracut_install /usr/share/zoneinfo/posix/Africa/Harare -dracut_install /usr/share/zoneinfo/posix/Africa/Freetown -dracut_install /usr/share/zoneinfo/posix/Africa/Windhoek -dracut_install /usr/share/zoneinfo/posix/Africa/Djibouti -dracut_install /usr/share/zoneinfo/posix/Africa/Malabo -dracut_install /usr/share/zoneinfo/posix/Africa/Cairo -dracut_install /usr/share/zoneinfo/posix/Africa/Brazzaville -dracut_install /usr/share/zoneinfo/posix/Etc/Zulu -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-0 -dracut_install /usr/share/zoneinfo/posix/Etc/Greenwich -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+6 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+9 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-9 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+5 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT0 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-10 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+0 -dracut_install /usr/share/zoneinfo/posix/Etc/Universal -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+12 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-5 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+2 -dracut_install /usr/share/zoneinfo/posix/Etc/UTC -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+8 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-11 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-4 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-12 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+11 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+3 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+4 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+1 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-14 -dracut_install /usr/share/zoneinfo/posix/Etc/UCT -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+7 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-6 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-2 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-3 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-8 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-7 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-13 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT-1 -dracut_install /usr/share/zoneinfo/posix/Etc/GMT+10 -dracut_install /usr/share/zoneinfo/posix/PST8PDT -dracut_install /usr/share/zoneinfo/posix/Jamaica -dracut_install /usr/share/zoneinfo/posix/NZ -dracut_install /usr/share/zoneinfo/posix/PRC -dracut_install /usr/share/zoneinfo/posix/Chile/EasterIsland -dracut_install /usr/share/zoneinfo/posix/Chile/Continental -dracut_install /usr/share/zoneinfo/posix/Factory -inst "$moddir/xcatroot" "/sbin/xcatroot" -inst "$moddir/dodiscovery" "/bin/dodiscovery" -inst "$moddir/udpcat.awk" "/bin/udpcat.awk" -inst "$moddir/minixcatd.awk" "/bin/minixcatd.awk" -inst "$moddir/bmcsetup" "/bin/bmcsetup" -inst "$moddir/allowcred.awk" "/bin/allowcred.awk" -inst "$moddir/getipmi" "/bin/getipmi" -inst "$moddir/remoteimmsetup" "/bin/remoteimmsetup" -inst "$moddir/getdestiny" "/bin/getdestiny" -inst "$moddir/restart" "/bin/restart" -inst "$moddir/doxcat" "/bin/doxcat" -inst "$moddir/nextdestiny" "/bin/nextdestiny" -inst "$moddir/getcert" "/bin/getcert" -inst "$moddir/dhclient.conf" "/etc/dhclient.conf" -inst "$moddir/dhclient-script" "/sbin/dhclient-script" -inst "$moddir/rsyslog.conf" "/etc/rsyslog.conf" -inst "$moddir/99-imm.rules" "/etc/udev/rules.d/99-imm.rules" -inst "$moddir/98-mlx.rules" "/etc/udev/rules.d/98-mlx.rules" -inst "$moddir/setupimmnic" "/sbin/setupimmnic" -inst "$moddir/loadmlxeth" "/sbin/loadmlxeth" -if [ $version12 ];then -dracut_install rpcbind -else -dracut_install portmap -fi -dracut_install /sbin/rpc.statd /sbin/sm-notify /etc/netconfig /etc/host.conf /usr/sbin/rpc.idmapd -dracut_install ps free find #debug -inst_dir /var/lib/nfs -inst_dir /var/lib/nfs/statd/sm -inst_dir /var/lib/nfs/statd/sm.bak -inst_dir /var/lib/nfs/rpc_pipefs/nfs -inst "/bin/bash" "/bin/sh" -inst "/lib64/libnss_dns-2.12.so" -inst "/lib/terminfo/l/linux" "/lib/terminfo/l/linux" -inst "/lib/terminfo/v/vt100" "/lib/terminfo/v/vt100" -inst_hook cmdline 10 "$moddir/xcat-cmdline.sh" -dracut_install /usr/lib/rsyslog/lmtcpclt.so -#dracut_install /usr/lib/rsyslog/omtesting.so -dracut_install /usr/lib/rsyslog/lmnetstrms.so -dracut_install /usr/lib/rsyslog/imfile.so -dracut_install /usr/lib/rsyslog/imklog.so -#dracut_install /usr/lib/rsyslog/lmzlibw.so -dracut_install /usr/lib/rsyslog/immark.so -dracut_install /usr/lib/rsyslog/imudp.so -dracut_install /usr/lib/rsyslog/lmregexp.so -dracut_install /usr/lib/rsyslog/lmtcpsrv.so -dracut_install /usr/lib/rsyslog/lmnsd_ptcp.so -dracut_install /usr/lib/rsyslog/imtcp.so -dracut_install /usr/lib/rsyslog/lmnet.so -#dracut_install /usr/lib/rsyslog/lmstrmsrv.so -dracut_install /usr/lib/rsyslog/imuxsock.so -if [ $version12 ];then -dracut_install /lib/libnfsidmap/nsswitch.so -else -dracut_install /usr/lib64/libnfsidmap/nsswitch.so -fi diff --git a/xCAT-nbroot2/installkernel b/xCAT-nbroot2/installkernel deleted file mode 100755 index 25c52f8bd..000000000 --- a/xCAT-nbroot2/installkernel +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -instmods nfs sunrpc -instmods e1000 e1000e virtio_net igb ines sfc mlx4_en cxgb3 cxgb4 tg3 bnx2 bnx2x bna ixgb qlge mptsas mpt2sas ata_piix megaraid_sas virtio_blk ahci ibmaem xhci-hcd sd_mod pmcraid be2net ext3 ext4 btrfs reiserfs usb_storage scsi_wait_scan kvm kvm-intel kvm-amd ipmi_si ipmi_devintf -instmods macvlan macvtap 8021q bridge bonding vmxnet3 acpi-cpufreq powernow-k8 cdc_ether -instmods mptctl #LSI firmware management requires this -instmods sg # Lenovo Thinkserver firmware management uses sg interface -instmods mlx4_ib ib_umad #make the mellanox ib available enough to examine /sys diff --git a/xCAT-nbroot2/loadmlxeth b/xCAT-nbroot2/loadmlxeth deleted file mode 100755 index 3cb42b14d..000000000 --- a/xCAT-nbroot2/loadmlxeth +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -/sbin/modprobe mlx4_en diff --git a/xCAT-nbroot2/minixcatd.awk b/xCAT-nbroot2/minixcatd.awk deleted file mode 100755 index 5f71623a2..000000000 --- a/xCAT-nbroot2/minixcatd.awk +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/awk -f -# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html -BEGIN { - port = 3001 - listener = "/inet/tcp/" port "/0/0" - quit = "no" - while (match(quit,"no")) { - while (match(quit,"no") && (listener |& getline) > 0) { - if (match($0,"restart")) { - print "restarting bootstrap process" |& listener - quit="yes" - system("echo \"" $0 "\" > /restart") - close(listener) - } - } - close(listener) - } -} diff --git a/xCAT-nbroot2/nextdestiny b/xCAT-nbroot2/nextdestiny deleted file mode 100755 index 193c811ef..000000000 --- a/xCAT-nbroot2/nextdestiny +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -if [ -z "$XCATDEST" ]; then - XCATDEST=$1 -fi -echo " -nextdestiny -300 -" > /tmp/destreq.xml -if [ -f /tmp/destiny.xml ]; then rm /tmp/destiny.xml; fi -while [ ! -f /tmp/destiny.xml ] || grep error /tmp/destiny.xml; do - if [ -f /tmp/destiny.xml ]; then - timer=60 - while [ $timer -gt 0 ]; do - echo -en "Retrying in $timer seconds \r" >&2 - sleep 1 - timer=$(($timer-1)); - done - fi - echo " " >&2; - if [ -f /etc/xcat/cert.pem -a -f /etc/xcat/certkey.pem ]; then #use client cert if available - cat /tmp/destreq.xml | openssl s_client -key /etc/xcat/certkey.pem -cert /etc/xcat/cert.pem -connect $XCATDEST -quiet 2> /dev/null > /tmp/destiny.xml - else - cat /tmp/destreq.xml | openssl s_client -connect $XCATDEST -quiet 2> /dev/null > /tmp/destiny.xml - fi -done -rm /tmp/destreq.xml -DESTINY=`grep destiny /tmp/destiny.xml | awk -F'>' '{print $2}'|awk -F'<' '{print $1}'` -rm /tmp/destiny.xml -echo $DESTINY diff --git a/xCAT-nbroot2/remoteimmsetup b/xCAT-nbroot2/remoteimmsetup deleted file mode 100755 index 7be13ab60..000000000 --- a/xCAT-nbroot2/remoteimmsetup +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -CREDPID=$! -if [ -z "$XCATDEST" ]; then - XCATDEST=$1 -fi -if [ -z "$XCATDEST" ]; then - for parm in `cat /proc/cmdline` ; do - if echo $parm |grep xcatd= > /dev/null; then - XCATDEST=`echo $parm |awk -F= '{print $2}'` - fi - done -fi -for LANCHAN in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do - if ipmitool channel info $LANCHAN 2> /dev/null | grep 802.3 > /dev/null 2>&1 && ipmitool raw 0xc 2 $LANCHAN 5 0 0 > /dev/null 2>&1; - then break; - fi; -done -BMCMAC=`ipmitool lan print $LANCHAN|grep ^MAC|awk '{print $4}'` #bmcconfig may opt to use DHCP, if so we need to feed up the mac address -#TODO: need a way to get the DUID the service processor may use, perhaps reserve that for 'ibmsetup' since spec doesn't touch ipv6? - -echo " -remoteimmsetup -$BMCMAC -" > /tmp/bmcreq.xml -rm /tmp/remsetup.xml -while [ ! -f /tmp/remsetup.xml ] || grep error /tmp/remsetup.xml; do - if [ -f /tmp/remsetup.xml ]; then - timer=60 - while [ $timer -gt 0 ]; do - sleep 1 - echo -en "Retrying in $timer seconds \r" - timer=$(($timer-1)); - done - fi - echo -en " \r"; - - if [ -f /etc/xcat/cert.pem -a -f /etc/xcat/certkey.pem ]; then #use client cert if available - cat /tmp/bmcreq.xml | openssl s_client -key /etc/xcat/certkey.pem -cert /etc/xcat/cert.pem -connect $XCATDEST -quiet 2> /dev/null > /tmp/remsetup.xml - else - cat /tmp/bmcreq.xml | openssl s_client -connect $XCATDEST -quiet 2> /dev/null > /tmp/remsetup.xml - fi -done -rm /tmp/bmcreq.xml diff --git a/xCAT-nbroot2/restart b/xCAT-nbroot2/restart deleted file mode 100755 index 19a624f6e..000000000 --- a/xCAT-nbroot2/restart +++ /dev/null @@ -1,64 +0,0 @@ -# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html -#Redhcp, do the xcat part again -FORCENICS=`cat /restart|awk '{print $2}'` -rm /restart -if [ ! -z "$FORCENICS" ]; then - echo "Forcing down nics aside from $FORCENICS due to discoverynics setting" - for pidfile in /var/run/dhclient.*.pid; do - NIC=`echo $pidfile|awk -F. '{print $2}'` - if [ ! -z "$NIC" ] && echo $NIC | egrep -v "$FORCENICS"; then - dhclient -r -1 -cf /etc/dhclient.conf -pf $pidfile $NIC - rm $pidfile - ip link set $NIC down - fi - done - for pidfile in /var/run/dhclient6.*.pid; do - NIC=`echo $pidfile|awk -F. '{print $2}'` - if [ ! -z "$NIC" ] && echo $NIC | egrep -v "$FORCENICS"; then - dhclient -6 -r -1 -pf $pidfile -lf /var/lib/dhclient/dhclient6.leases $NIC - rm $pidfile - ip link set $NIC down - fi - done -fi -WAITING=1 -while [ $WAITING -gt 0 ]; do - for pidfile in /var/run/dhclient.*.pid; do - NIC=`echo $pidfile|awk -F. '{print $2}'` - dhclient -r -1 -cf /etc/dhclient.conf -pf $pidfile $NIC - ip -4 addr flush dev $NIC - dhclient -cf /etc/dhclient.conf -nw -pf $pidfile $NIC - done - for pidfile in /var/run/dhclient6.*.pid; do - NIC=`echo $pidfile|awk -F. '{print $2}'` - dhclient -6 -r -1 -pf $pidfile -lf /var/lib/dhclient/dhclient6.leases $NIC - ip -6 addr flush dev $NIC scope global - ip -6 addr flush dev $NIC scope site - dhclient -6 -pf $pidfile -nw -lf /var/lib/dhclient/dhclient6.leases $NIC - done - - echo -en "Waiting 10 seconds for DHCP changes to take effect \r" - for i in 9 8 7 6 5 4 3 2 1; do - sleep 1 - echo -en "Waiting $i seconds for DHCP changes to take effect \r" - done - WAITING=0 - if [ ! -z "$FORCENICS" ]; then - for nic in `ifconfig|grep HWaddr|awk '{print $1}'|egrep "$FORCENICS"`; do - if ! ifconfig $nic|grep "inet addr" > /dev/null; then - WAITING=1 - fi - done - if [ $WAITING -gt 0 ]; then - delay=30 - while [ $delay -gt 0 ]; do - echo -en "Not all of the nics $FORCENICS managed to acquire an address, retrying in $delay seconds... \r" - done - echo " \r" - fi - fi -done - -echo "Done waiting "; -#/etc/init.d/S11stunnel #redo stunnel config -#exec /etc/init.d/S99xcat.sh diff --git a/xCAT-nbroot2/rsyslog.conf b/xCAT-nbroot2/rsyslog.conf deleted file mode 100644 index bf62f99e0..000000000 --- a/xCAT-nbroot2/rsyslog.conf +++ /dev/null @@ -1,5 +0,0 @@ -$ModLoad imuxsock -$ModLoad immark -$MarkMessagePeriod 1200 -*.emerg * -*.* ~ diff --git a/xCAT-nbroot2/setupimmnic b/xCAT-nbroot2/setupimmnic deleted file mode 100755 index 339adbac9..000000000 --- a/xCAT-nbroot2/setupimmnic +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -/sbin/ip link set usb0 up -/sbin/ip addr add dev usb0 169.254.95.120/24 -/sbin/ip route add 169.254.95.0/24 dev usb0 diff --git a/xCAT-nbroot2/udpcat.awk b/xCAT-nbroot2/udpcat.awk deleted file mode 100755 index 6a3c2c166..000000000 --- a/xCAT-nbroot2/udpcat.awk +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/awk -f -# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html -BEGIN { - xcatdport = ARGV[2] - xcatdhost = ARGV[1] - delete ARGV[1] - delete ARGV[2] - RS="" -} -END { - print $0 |& "/inet/udp/301/"xcatdhost"/"xcatdport -} diff --git a/xCAT-nbroot2/xCAT-genesis-builder.spec b/xCAT-nbroot2/xCAT-genesis-builder.spec deleted file mode 100644 index 87d2ea198..000000000 --- a/xCAT-nbroot2/xCAT-genesis-builder.spec +++ /dev/null @@ -1,44 +0,0 @@ -%define version %(cat Version) -BuildArch: noarch -%define name xCAT-genesis-builder -Release: snap%(date +"%Y%m%d%H%M") -Epoch: 1 -AutoReq: false -Requires: efibootmgr ipmitool screen btrfs-progs lldpad rpm-build compat-libstdc++-33 -Prefix: /opt/xcat -AutoProv: false - - - -Name: %{name} -Version: %{version} -Group: System/Utilities -License: EPL -Vendor: IBM Corp. -Summary: Tooling to create xCAT's discovery/maintenance/debugging environment -URL: http://xcat.org -Source1: xCAT-genesis-builder.tar.bz2 - -Buildroot: %{_localstatedir}/tmp/xCAT-genesis-builder -Packager: IBM Corp. - -%Description -Genesis (Genesis Enhanced Netboot Environment for System Information and Servicing) is xCAT's netboot environment designed to perform hardware and firmware inventory, perform firmware updates/configuration, and perform troubleshooting. -%Prep - - -%Build - -%Install -rm -rf $RPM_BUILD_ROOT -mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/netboot/genesis/builder -cd $RPM_BUILD_ROOT/%{prefix}/share/xcat/netboot/genesis/builder -tar jxvf %{SOURCE1} -chmod +x $RPM_BUILD_ROOT/%{prefix}/share/xcat/netboot/genesis/builder/buildrpm -cd - - - -%Files -%defattr(-,root,root) -%doc LICENSE.html -/ diff --git a/xCAT-nbroot2/xCAT-genesis.spec b/xCAT-nbroot2/xCAT-genesis.spec deleted file mode 100644 index 58d4a5a09..000000000 --- a/xCAT-nbroot2/xCAT-genesis.spec +++ /dev/null @@ -1,61 +0,0 @@ -%define version 2.7.7 -%ifarch i386 i586 i686 x86 -%define tarch x86 -%endif -%ifarch x86_64 -%define tarch x86_64 -%endif -%ifarch ppc ppc64 -%define tarch ppc64 -%endif -BuildArch: noarch -%define name xCAT-genesis-%{tarch} -%define __spec_install_post : -%define debug_package %{nil} -%define __prelink_undo_cmd %{nil} -Release: snap%(date +"%Y%m%d%H%M") -Epoch: 1 -AutoReq: false -Prefix: /opt/xcat -AutoProv: false - - - -Name: %{name} -Version: %{version} -Group: System/Utilities -License: Various (see individual packages for details) -Vendor: IBM Corp. -Summary: xCAT Genesis netboot image -URL: http://xcat.org -Source1: xCAT-genesis-%{tarch}.tar.bz2 - -Buildroot: %{_localstatedir}/tmp/xCAT-genesis -Packager: IBM Corp. - -%Description -xCAT genesis (Genesis Enhanced Netboot Environment for System Information and Servicing) is a small, embedded-like environment for xCAT's use in discovery and management actions when interaction with an OS is infeasible. -%Prep - - -%Build - -%Install -rm -rf $RPM_BUILD_ROOT -mkdir -p $RPM_BUILD_ROOT -cd $RPM_BUILD_ROOT -tar jxf %{SOURCE1} -cd - - - -%post -if [ "$1" == "2" ]; then #only on upgrade, as on install it's probably not going to work... - if [ -f "/proc/cmdline" ]; then # prevent running it during install into chroot image - . /etc/profile.d/xcat.sh - mknb %{tarch} - fi -fi - -%Files -%defattr(-,root,root) -/ diff --git a/xCAT-nbroot2/xcat-cmdline.sh b/xCAT-nbroot2/xcat-cmdline.sh deleted file mode 100644 index 00914979e..000000000 --- a/xCAT-nbroot2/xcat-cmdline.sh +++ /dev/null @@ -1,27 +0,0 @@ -root=1 -rootok=1 -netroot=xcat -clear -echo PS1="'"'[xCAT Genesis running on \H \w]\$ '"'" > /.bashrc -echo PS1="'"'[xCAT Genesis running on \H \w]\$ '"'" > /.bash_profile -mkdir -p /etc/ssh -mkdir -p /var/empty/sshd -echo root:x:0:0::/:/bin/bash >> /etc/passwd -echo sshd:x:30:30:SSH User:/var/empty/sshd:/sbin/nologin >> /etc/passwd -echo rpc:x:32:32:Rpcbind Daemon:/var/cache/rpcbind:/sbin/nologin >> /etc/passwd -echo rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin >> /etc/passwd -echo qemu:x:107:107:qemu user:/:/sbin/nologin >> /etc/passwd -echo '[ -e $NEWROOT/proc ]' > /initqueue-finished/xcatroot.sh -mkdir /dev/cgroup -mount -t cgroup -o cpu,memory,devices cgroup /dev/cgroup -udevd --daemon -udevadm trigger -mkdir -p /var/lib/dhclient/ -mkdir -p /var/log -ip link set lo up -echo '127.0.0.1 localhost' >> /etc/hosts -if grep console=ttyS /proc/cmdline > /dev/null; then - while :; do sleep 1; screen -x console < /dev/tty1 > /dev/tty1 2>&1; clear; done & -fi -while :; do screen -ln < /dev/tty2 > /dev/tty2 2>&1; done & -while :; do screen -ln doxcat; done diff --git a/xCAT-nbroot2/xcatroot b/xCAT-nbroot2/xcatroot deleted file mode 100755 index fc506fb3b..000000000 --- a/xCAT-nbroot2/xcatroot +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -echo "Starting xCAT mini-environment" -NEWROOT=$3 -XCATMASTER=$XCAT -while : -do - /bin/sh -done From a5ea31642712a4f3503439e3ed921ea4681af6a0 Mon Sep 17 00:00:00 2001 From: wangxiaopeng Date: Sun, 12 Jun 2016 21:27:51 -0400 Subject: [PATCH 095/310] issue 1292: added missing attribute disable for taskstate table --- perl-xCAT/xCAT/Schema.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index cfc75585c..8e90b5fb6 100755 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -1704,7 +1704,7 @@ passed as argument rather than by table value', }, }, taskstate => { - cols => [qw(node command state pid reserve)], + cols => [qw(node command state pid reserve disable)], keys => [qw(node)], table_desc => 'The task state for the node.', descriptions => { From be9293ab6df0132b449c900902e2db8796da1ada Mon Sep 17 00:00:00 2001 From: ertaozh Date: Wed, 1 Jun 2016 05:46:54 -0400 Subject: [PATCH 096/310] add switchprobe subcommand for xcatprobe --- xCAT-probe/subcmds/switch-macmap | 124 +++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100755 xCAT-probe/subcmds/switch-macmap diff --git a/xCAT-probe/subcmds/switch-macmap b/xCAT-probe/subcmds/switch-macmap new file mode 100755 index 000000000..45eedbb2a --- /dev/null +++ b/xCAT-probe/subcmds/switch-macmap @@ -0,0 +1,124 @@ +#! /usr/bin/perl +# IBM(c) 2016 EPL license http://www.eclipse.org/legal/epl-v10.html +BEGIN { $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; } + +use lib "$::XCATROOT/probe/lib/perl"; +use Cwd 'abs_path'; +use Cwd; +use File::Basename; +use File::Path; +use probe_utils; +use Getopt::Long qw(:config no_ignore_case); + +my $proname = basename("$0"); +my $currdir = dirname(abs_path($0)); +my $output = "stdout"; + +$::USAGE = "Usage: + $proname -h + $proname -t + $proname [-c] [-V] + +Description: + To retrieve MAC address mapping for the specified switch, or all the switches defined in switches table in xCAT db. + +Options: + -t: Check whether this script is OK to run. + -c: To check whether the switch is OK to retrieve MAC address mapping. + -V: Output verbose information when accessing switch +"; + +my $help; +my $test; +my $check; +my @nodes = (); +my $verbose = ''; +if (!GetOptions("help|h" => \$help, + "t" => \$test, + "c" => \$check, + "V" => \$verbose)) { + probe_utils->send_msg("$output", "f", "Option not support"); + probe_utils->send_msg("$output", "d", $::USAGE); + exit 1; +} +foreach (@ARGV) { + if (/^-\w*/) { + probe_utils->send_msg("$output", "f", "Option $_ not support"); + exit 1; + } else { + push @nodes, $_; + } +} +if ($help) { + probe_utils->send_msg("$output", "d", $::USAGE); + exit 0; +} +if ($test) { + if (! -d "$currdir/bin") { + mkpath("$currdir/bin/"); + } + if (! -e "$currdir/bin/switchprobe") { + link("$::XCATROOT/bin/xcatclient", "$currdir/bin/switchprobe"); + } + `$currdir/bin/switchprobe -h`; + if ($?) { + probe_utils->send_msg("$output", "f", "No switchprobe tool is available at $currdir/bin/"); + exit 1; + } else { + probe_utils->send_msg("$output", "o", "To retrieve MAC address mapping for the specified switch, or all the switches defined in switches table in xCAT db."); + exit 0; + } +} +if ($verbose) { + $verbose = "-V"; +} +my $noderange = join(',',@nodes); +my $normal_file = "/tmp/result_normal"; +my $error_file = "/tmp/result_error"; +if (-f $normal_file) { + unlink($normal_file); +} +if (-f $error_file) { + unlink($error_file); +} +if ($check) { + `$currdir/bin/switchprobe $noderange -c $verbose >$normal_file 2>$error_file`; +} +else { + `$currdir/bin/switchprobe $noderange $verbose >$normal_file 2>$error_file`; +} +if (-f $error_file) { + `cat $error_file >> $normal_file`; +} +my $fd; +open($fd, "<", "$normal_file"); +my %fails = (); +foreach (<$fd>) { + chomp($_); + if (/^(\S*):\s*(.*)/) { + my $switch = $1; + my $info = $2; + if (/PASS/) { + probe_utils->send_msg("$output", "o", "$switch"); + } elsif (/Error:/) { + $info =~ s/Error://; + $fails{$switch} = $info; + } else { + probe_utils->send_msg("$output", "d", "$_"); + } + } + else { + probe_utils->send_msg("$output", "d", $_); + } +} +close ($fd); +if (-f $normal_file) { + unlink($normal_file); +} +if (-f $error_file) { + unlink($error_file); +} +foreach (keys %fails) { + probe_utils->send_msg("$output", "f", "$_ - $fails{$_}"); +} +exit 0; From 0f16057f6445570327c9bc769dfa7f4824c01fd5 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 13 Jun 2016 14:35:47 -0400 Subject: [PATCH 097/310] use return instead of exit to return an error --- xCAT-server/lib/xcat/plugins/kvm.pm | 59 +++++++++++++---------------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index 6bd27bb04..60a12f8e3 100755 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -235,7 +235,6 @@ sub get_storage_pool_by_url { if ($@) { my $error = $@; unless ($error =~ /vgcreate.*exit status 3/ or $error =~ /pvcreate.*exit status 5/) { - undef $hypconn; die $@; } } @@ -251,11 +250,7 @@ sub get_multiple_paths_by_url { my $url = $args{url}; my $node = $args{node}; my $poolobj = get_storage_pool_by_url($url); - unless ($poolobj) { - my $exit_message = "Could not get storage pool for $url"; - xCAT::SvrUtils::sendmsg($exit_message, $callback); - exit 1; - } + unless ($poolobj) { die "Cound not get storage pool for $url"; } eval { #refresh() can 'die' if cloning in progress, accept stale data then $poolobj->refresh(); #if volumes change on nfs storage, libvirt is too dumb to notice }; @@ -300,11 +295,7 @@ sub get_filepath_by_url { #at the end of the day, the libvirt storage api gives #print "url=$url, dev=$dev,create=$create, force=$force, format=$format\n"; #ok, now that we have the pool, we need the storage volume from the pool for the node/dev my $poolobj = get_storage_pool_by_url($url); - unless ($poolobj) { - my $exit_message = "Could not get storage pool for $url"; - xCAT::SvrUtils::sendmsg($exit_message, $callback); - exit 1; - } + unless ($poolobj) { die "Could not get storage pool for $url"; } eval { #make a refresh attempt non-fatal to fail, since cloning can block it $poolobj->refresh(); #if volumes change on nfs storage, libvirt is too dumb to notice }; @@ -318,9 +309,7 @@ sub get_filepath_by_url { #at the end of the day, the libvirt storage api gives if ($force) { #must destroy the storage $_->delete(); } else { - my $exit_message = "Path $desiredname already exists"; - xCAT::SvrUtils::sendmsg($exit_message, $callback); - exit 1; + die "Path $desiredname already exists"; } } else { return $_->get_path(); @@ -544,9 +533,7 @@ sub build_diskstruct { } elsif ($disk_parts[0] =~ m/^nfs:\/\/(.*)$/ or $disk_parts[0] =~ m/^dir:\/\/(.*)$/ or $disk_parts[0] =~ m/^lvm:\/\/(.*)$/) { my %disks = %{ get_multiple_paths_by_url(url => $disk_parts[0], node => $node) }; unless (keys %disks) { - my $exit_message = "Unable to find any persistent disks at $disk_parts[0] for $node"; - xCAT::SvrUtils::sendmsg($exit_message, $callback); - exit 1; + return(1,"Unable to find any persistent disks at $disk_parts[0] for $node"); } foreach (keys %disks) { my $tdiskhash; @@ -869,7 +856,10 @@ sub build_xmldesc { $xtree{features}->{acpi} = {}; $xtree{features}->{apic} = {}; $xtree{features}->{content} = "\n"; - $xtree{devices}->{disk} = build_diskstruct($cdloc); + ($xtree{devices}->{disk}, my $errstr) = build_diskstruct($cdloc); + if ($errstr) { + return (-1, $errstr); + } $xtree{devices}->{interface} = build_nicstruct($node); #use content to force xml simple to not make model the 'name' of video @@ -1341,6 +1331,7 @@ sub makedom { my $cdloc = shift; my $xml = shift; my $dom; + my $errstr; if (not $xml and $confdata->{kvmnodedata}->{$node} and $confdata->{kvmnodedata}->{$node}->[0] and $confdata->{kvmnodedata}->{$node}->[0]->{xml}) { #we do this to trigger storage prereq fixup @@ -1370,7 +1361,10 @@ sub makedom { $xml = $newxml; } } elsif (not $xml) { - $xml = build_xmldesc($node, cd => $cdloc); + ($xml, $errstr) = build_xmldesc($node, cd => $cdloc); + if ($errstr) { + return (1, $errstr); + } } my $parseddom = $parser->parse_string($xml); my ($graphics) = $parseddom->findnodes("//graphics"); @@ -1381,7 +1375,6 @@ sub makedom { } $graphics->setAttribute("listen", '0.0.0.0'); $xml = $parseddom->toString(); - my $errstr; eval { if ($::XCATSITEVALS{persistkvmguests}) { $dom = $hypconn->define_domain($xml); @@ -2039,28 +2032,21 @@ sub chvm { $url =~ s!([^/]+)\z!!; my $imagename = $1; my $poolobj = get_storage_pool_by_url($url); - unless ($poolobj) { - my $exit_message = "Could not get storage pool for $url"; - xCAT::SvrUtils::sendmsg($exit_message, $callback); - exit 1; - } + unless ($poolobj) { die "Cound not get storage pool for $url"; } my $poolxml = $poolobj->get_xml_description(); #yes, I have to XML parse for even this... my $parsedpool = $parser->parse_string($poolxml); $cdpath = $parsedpool->findnodes("/pool/target/path/text()")->[0]->data; $cdpath .= "/" . $imagename; } else { if ($cdrom =~ m!^/dev/!) { - undef $hypconn; die "TODO: device pass through if anyone cares"; } elsif ($cdrom =~ m!^/!) { #full path... I guess $cdpath = $cdrom; } else { - undef $hypconn; die "TODO: relative paths, use client cwd as hint?"; } } unless ($cdpath) { - undef $hypconn; die "unable to understand cd path specification"; } $newcdxml = ""; @@ -2078,7 +2064,6 @@ sub chvm { my $domparsed = $parser->parse_string($vmxml); my $candidatenodes = $domparsed->findnodes("//disk[\@device='cdrom']"); if (scalar(@$candidatenodes) != 1) { - undef $hypconn; die "shouldn't be possible, should only have one cdrom"; } my $newcd = $parser->parse_balanced_chunk($newcdxml); @@ -2795,7 +2780,6 @@ sub clone_vm_from_master { my $url; if ($confdata->{vm}->{$node}->[0]->{storage}) { unless ($confdata->{vm}->{$node}->[0]->{storage} =~ /^nfs:/) { - undef $hypconn; die "not implemented"; } $url = $confdata->{vm}->{$node}->[0]->{storage}; @@ -2922,6 +2906,7 @@ sub mkvm { require Getopt::Long; my $memory; my $cpucount; + my $errstr; GetOptions( 'master|m=s' => \$mastername, 'size|s=s' => \$disksize, @@ -2953,7 +2938,12 @@ sub mkvm { unless ($confdata->{kvmnodedata}->{$node} and $confdata->{kvmnodedata}->{$node}->[0] and $confdata->{kvmnodedata}->{$node}->[0]->{xml}) { my $xml; - $xml = build_xmldesc($node, cpus => $cpucount, memory => $memory); + ($xml, $errstr) = build_xmldesc($node, cpus => $cpucount, memory => $memory); + if ($errstr) { + # The caller splits the error message on ":", prepend ":" so that if actual + # error message contains ":" it will not be split in the middle + return (1, ":" . $errstr); + } $updatetable->{kvm_nodedata}->{$node}->{xml} = $xml; } } @@ -2961,7 +2951,12 @@ sub mkvm { if ($confdata->{kvmnodedata}->{$node} and $confdata->{kvmnodedata}->{$node}->[0] and $confdata->{kvmnodedata}->{$node}->[0]->{xml}) { $xml = $confdata->{kvmnodedata}->{$node}->[0]->{xml}; } else { # ($confdata->{kvmnodedata}->{$node} and $confdata->{kvmnodedata}->{$node}->[0] and $confdata->{kvmnodedata}->{$node}->[0]->{xml}) { - $xml = build_xmldesc($node, cpus => $cpucount, memory => $memory); + ($xml, $errstr) = build_xmldesc($node, cpus => $cpucount, memory => $memory); + if ($errstr) { + # The caller splits the error message on ":", prepend ":" so that if actual + # error message contains ":" it will not be split in the middle + return (1, ":" . $errstr); + } $updatetable->{kvm_nodedata}->{$node}->{xml} = $xml; } if ($::XCATSITEVALS{persistkvmguests}) { From 3b9eddc6d2a307b181d868c42a19e360f74a419d Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Mon, 13 Jun 2016 14:40:50 -0400 Subject: [PATCH 098/310] Add uuid into /opt/xcat/xcatinfo --- xCAT-server/lib/xcat/plugins/packimage.pm | 6 +++++- .../share/xcat/install/scripts/post.debian | 7 ++++++- .../share/xcat/install/scripts/post.xcat | 17 +++++++++++++++-- xCAT/postscripts/xcatdsklspost | 9 +++++++-- xCAT/postscripts/xcatinstallpost | 8 +++++++- 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/packimage.pm b/xCAT-server/lib/xcat/plugins/packimage.pm index 3d57db8c2..979d4b72f 100755 --- a/xCAT-server/lib/xcat/plugins/packimage.pm +++ b/xCAT-server/lib/xcat/plugins/packimage.pm @@ -181,8 +181,12 @@ sub process_request { system("mkdir -p $rootimg_dir/xcatpost"); system("cp -r $installroot/postscripts/* $rootimg_dir/xcatpost/"); - #put the image name and timestamp into diskless image when it is packed. + #put the image name, uuid and timestamp into diskless image when it is packed. `echo IMAGENAME="'$imagename'" > $rootimg_dir/opt/xcat/xcatinfo`; + + my $uuid = `uuidgen`; + chomp $uuid; + `echo IMAGEUUID="'$uuid'" >> $rootimg_dir/opt/xcat/xcatinfo`; my $timestamp = `date`; chomp $timestamp; diff --git a/xCAT-server/share/xcat/install/scripts/post.debian b/xCAT-server/share/xcat/install/scripts/post.debian index a6cb2f9e3..c6e0c42ca 100644 --- a/xCAT-server/share/xcat/install/scripts/post.debian +++ b/xCAT-server/share/xcat/install/scripts/post.debian @@ -89,7 +89,12 @@ do mkdir -p /opt/xcat touch /opt/xcat/xcatinfo fi - echo "XCATSERVER=$i" > /opt/xcat/xcatinfo + grep 'XCATSERVER' /opt/xcat/xcatinfo 2>&1 > /dev/null + if [ $? -eq 0 ]; then + sed -i "s/XCATSERVER=.*/XCATSERVER=$i/" /opt/xcat/xcatinfo + else + echo "XCATSERVER=$i" >> /opt/xcat/xcatinfo + fi break fi RAND=$(perl -e 'print int(rand(5)). "\n"') diff --git a/xCAT-server/share/xcat/install/scripts/post.xcat b/xCAT-server/share/xcat/install/scripts/post.xcat index 7faefb438..0c26973b1 100755 --- a/xCAT-server/share/xcat/install/scripts/post.xcat +++ b/xCAT-server/share/xcat/install/scripts/post.xcat @@ -47,8 +47,21 @@ if [ ! -f /opt/xcat/xcatinfo ]; then mkdir -p /opt/xcat touch /opt/xcat/xcatinfo fi -echo "XCATSERVER=$MASTER_IP" > /opt/xcat/xcatinfo -echo "INSTALLDIR=$INSTALLDIR" >> /opt/xcat/xcatinfo + +grep 'XCATSERVER' /opt/xcat/xcatinfo 2>&1 > /dev/null +if [ $? -eq 0 ]; then + sed -i "s/XCATSERVER=.*/XCATSERVER=$MASTER_IP/" /opt/xcat/xcatinfo +else + echo "XCATSERVER=$MASTER_IP" >> /opt/xcat/xcatinfo +fi + +grep 'INSTALLDIR' /opt/xcat/xcatinfo 2>&1 > /dev/null +if [ $? -eq 0 ]; then + sed -i "s/INSTALLDIR=.*/INSTALLDIR=$INSTALLDIR/" /opt/xcat/xcatinfo +else + echo "INSTALLDIR=$INSTALLDIR" >> /opt/xcat/xcatinfo +fi + if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then msgutil_r "$MASTER_IP" "debug" "/opt/xcat/xcatinfo generated" "/var/log/xcat/xcat.log" fi diff --git a/xCAT/postscripts/xcatdsklspost b/xCAT/postscripts/xcatdsklspost index e58e34264..28489c947 100755 --- a/xCAT/postscripts/xcatdsklspost +++ b/xCAT/postscripts/xcatdsklspost @@ -322,7 +322,12 @@ if [ "$MODE" = "4" ]; then # for statelite mode if [ "$KEY" = "XCAT" ]; then TMP=`echo $i | awk -F= '{print $2}'` XCATSERVER=`echo $TMP | cut -d: -f1` - echo "XCATSERVER=$XCATSERVER" > /opt/xcat/xcatinfo + grep 'XCATSERVER' /opt/xcat/xcatinfo 2>&1 > /dev/null + if [ $? -eq 0 ]; then + sed -i "s/XCATSERVER=.*/XCATSERVER=$XCATSERVER/" /opt/xcat/xcatinfo + else + echo "XCATSERVER=$XCATSERVER" >> /opt/xcat/xcatinfo + fi break fi done @@ -627,7 +632,7 @@ fi #save the MASTER into the xcatinfo file for node deployment case, #for updatenode case, only save it when -M is specified if [ $NODE_DEPLOYMENT -eq 1 ] || [ "$MODE" = "4" ]; then - new_ms=`grep '^MASTER' /$xcatpost/mypostscript |cut -d= -f2` + new_ms=`grep '^MASTER' /$xcatpost/mypostscript |head -n 1 |cut -d= -f2` fi if [ -n "$new_ms" ]; then if [ ! -f /opt/xcat/xcatinfo ]; then diff --git a/xCAT/postscripts/xcatinstallpost b/xCAT/postscripts/xcatinstallpost index 83d9a8eb9..48d495042 100755 --- a/xCAT/postscripts/xcatinstallpost +++ b/xCAT/postscripts/xcatinstallpost @@ -75,7 +75,13 @@ DHCP_TMP=`sed 's/\(DHCPINTERFACES=\)\(.*\)$/\1"\2"/' /xcatpost/mypostscript.post echo "$DHCP_TMP" > /xcatpost/mypostscript.post #mark that the first reboot after installation is finished -echo "REBOOT=TRUE" >> /opt/xcat/xcatinfo +grep 'REBOOT' /opt/xcat/xcatinfo 2>&1 > /dev/null +if [ $? -eq 0 ]; then + sed -i "s/REBOOT=.*/REBOOT=TRUE/" /opt/xcat/xcatinfo +else + echo "REBOOT=TRUE" >> /opt/xcat/xcatinfo +fi + CNS=`grep NODESTATUS= /xcatpost/mypostscript.post |awk -F = '{print $2}'` if [ -z "$CNS" ] || [ "$CNS" != "'0'" -a "$CNS" != "'N'" -a "$CNS" != "'n'" ]; then From 295e3bf835b23300570c1bac53001d029b25ce4c Mon Sep 17 00:00:00 2001 From: XuWei Date: Mon, 13 Jun 2016 02:21:27 -0400 Subject: [PATCH 099/310] Modified documents related with mknb --- .../mgmt_node/changing_hostname_ip.rst | 5 +++++ docs/source/advanced/mixed_cluster/power/diskful.rst | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/docs/source/advanced/cluster_maintenance/mgmt_node/changing_hostname_ip.rst b/docs/source/advanced/cluster_maintenance/mgmt_node/changing_hostname_ip.rst index 85bbe9886..fda96e1ad 100644 --- a/docs/source/advanced/cluster_maintenance/mgmt_node/changing_hostname_ip.rst +++ b/docs/source/advanced/cluster_maintenance/mgmt_node/changing_hostname_ip.rst @@ -270,3 +270,8 @@ If it exists, then use the return name and do the following: makeconservercf +Update the genesis packages +--------------------------- + +Run ``mknb `` after changing the ip of MN. + diff --git a/docs/source/advanced/mixed_cluster/power/diskful.rst b/docs/source/advanced/mixed_cluster/power/diskful.rst index 423c0ceba..40f9d4cb3 100644 --- a/docs/source/advanced/mixed_cluster/power/diskful.rst +++ b/docs/source/advanced/mixed_cluster/power/diskful.rst @@ -44,6 +44,15 @@ Create a node definition for the x86_64 compute node, here is a sample: :: serialport=0 serialspeed=115200 +Verify the genesis packages: + +* **[RHEL/SLES]**: ``rpm -qa | grep -i genesis`` + +* **[Ubuntu]**: ``dpkg -l | grep -i genesis`` + +If missing, install the packages ``xCAT-genesis-base`` and ``xCAT-genesis-scripts`` from ``xcat-deps`` repository and run ``mknb `` to create the genesis network boot root image. + + Provision the node using the following commands: :: # The following prepares the boot files in /install and /tftpboot From 3a194e989b4f7a0ea85b9e4917d82e2f9dfcc984 Mon Sep 17 00:00:00 2001 From: immarvin Date: Mon, 13 Jun 2016 23:14:36 -0400 Subject: [PATCH 100/310] fix xcat-server can not be upgraded #1295 --- docs/source/guides/install-guides/apt/update_xcat.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/guides/install-guides/apt/update_xcat.rst b/docs/source/guides/install-guides/apt/update_xcat.rst index 44412b88b..dfa08f6f5 100644 --- a/docs/source/guides/install-guides/apt/update_xcat.rst +++ b/docs/source/guides/install-guides/apt/update_xcat.rst @@ -3,6 +3,6 @@ Updating xCAT If at a later date you want to update xCAT, first, update the software repositories and then run: :: apt-get update - apt-get upgrade xcat + apt-get --only-upgrade install xcat* From ef724b0e6fd7bdfea20f8746db33065f677aecf9 Mon Sep 17 00:00:00 2001 From: chenglch Date: Tue, 14 Jun 2016 01:52:17 -0400 Subject: [PATCH 101/310] Improve the error message for getadapter command 1. Add allow policy for getadapter 2. enhance the error message for different mgt when running getadapter partial-issue: #1174 --- xCAT-server/lib/xcat/plugins/getadapter.pm | 28 +++++++++++++++++++--- xCAT-server/sbin/xcatconfig | 2 ++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/getadapter.pm b/xCAT-server/lib/xcat/plugins/getadapter.pm index b977088c7..5e73b4107 100644 --- a/xCAT-server/lib/xcat/plugins/getadapter.pm +++ b/xCAT-server/lib/xcat/plugins/getadapter.pm @@ -310,9 +310,10 @@ sub deploy_genesis { }, $subreq, 0, 1); if ($::RUNCMD_RC != 0) { - $callback->({ error => "failed to run command: nodeset $node rumcmd=getadapter", errorcode => 1 }); + $callback->({ error => "failed to run command: nodeset $node runcmd=getadapter", errorcode => 1 }); return 1; } + # TODO: use rinstall to replace the following code when rinstall is ready. if ($node_desc_ptr->{mgt} eq "ipmi") { $outref = xCAT::Utils->runxcmd( { @@ -325,7 +326,6 @@ sub deploy_genesis { $callback->({ error => "failed to run command: rsetboot $node net", errorcode => 1 }); return 1; } - $outref = xCAT::Utils->runxcmd( { command => ['rpower'], @@ -337,7 +337,19 @@ sub deploy_genesis { $callback->({ error => "failed to run command: rpower $node reset", errorcode => 1 }); return 1; } - } else { + } elsif ($node_desc_ptr->{mgt} eq "kvm") { + $outref = xCAT::Utils->runxcmd( + { + command => ['rpower'], + node => ["$node"], + arg => ['reset'], + }, + $subreq, 0, 1); + if ($::RUNCMD_RC != 0) { + $callback->({ error => "failed to run command: rpower $node reset", errorcode => 1 }); + return 1; + } + } elsif ($node_desc_ptr->{mgt} eq "hmc") { $outref = xCAT::Utils->runxcmd( { command => ["rnetboot"], @@ -348,7 +360,12 @@ sub deploy_genesis { $callback->({ error => "failed to run command: rnetboot $node", errorcode => 1 }); return 1; } + } else { + $callback->({ error => "$node: The mgt configuration is not supported by getadapter.", + errorcode => 1 }); + return 1; } + $callback->({data=>"$node: Booting into genesis, this could take several minutes..."}); return 0; }; # end of child_process_func @@ -476,6 +493,11 @@ sub update_adapter_result { $output .= "\n"; } $callback->({ data => "$output" }); + if (!$has_nic) { + $callback->({ data => "$node: Couldn't find interface name information detected by udevadm," + ." the nics table will not be updated." }); + return 0; + } my $nics_table = xCAT::Table->new('nics'); unless ($nics_table) { xCAT::MsgUtils->message("S", "Unable to open nics table, denying"); diff --git a/xCAT-server/sbin/xcatconfig b/xCAT-server/sbin/xcatconfig index 099a3e06c..1dc1e8a45 100755 --- a/xCAT-server/sbin/xcatconfig +++ b/xCAT-server/sbin/xcatconfig @@ -1304,6 +1304,8 @@ sub initDB "$::XCATROOT/sbin/chtab priority=4.7 policy.commands=litefile policy.rule=allow;"; $chtabcmds .= "$::XCATROOT/sbin/chtab priority=4.8 policy.commands=litetree policy.rule=allow;"; + $chtabcmds .= + "$::XCATROOT/sbin/chtab priority=4.9 policy.commands=getadapter policy.rule=allow;"; } my $outref = xCAT::Utils->runcmd("$chtabcmds", 0); if ($::RUNCMD_RC != 0) From 680ba9f157eb9a52ac933d30a074d143cf139cc7 Mon Sep 17 00:00:00 2001 From: chenglch Date: Mon, 13 Jun 2016 23:12:21 -0400 Subject: [PATCH 102/310] Change the ref type of errorcode in xcmdoutput to array Currently runxcmd can not work with kvm when running rpower command as `runxcmd_output` subroutine just apply array type for `node->{errorcode}`. close-issue: #1298 --- xCAT-server/lib/xcat/plugins/kvm.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index bc8e305fb..788201159 100755 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -3987,7 +3987,7 @@ sub dohyp { } $text =~ s/^\s+//; $text =~ s/\s+$//; - $output{node}->[0]->{errorcode} = $rc; + $output{node}->[0]->{errorcode} = [$rc]; $output{node}->[0]->{name}->[0] = $node; if ($rc == 0) { $output{node}->[0]->{data}->[0]->{contents}->[0] = $text; From 0dbdd8d5de594590af5a1f58e1d8870b84d73cce Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Tue, 14 Jun 2016 11:46:04 -0400 Subject: [PATCH 103/310] Fixed the code based on Er Tao's code review to put the status check for non OpenPower based servers. OpenPower will use a different method to check that bmc is ready --- xCAT-genesis-scripts/bin/bmcsetup | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index 194e7373a..83981024d 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -63,15 +63,15 @@ function cold_reset_bmc() { else # for Non OpenPower servers, just sleep for some set time. sleep 15 - fi - TRIES=0 - # Get the LAN information - while ! ipmitool lan print $LANCHAN > /dev/null; do - sleep 3 - let TRIES=TRIES+1 - if [ $TRIES -gt $TIMEOUT ]; then break; fi - done + TRIES=0 + # Get the LAN information + while ! ipmitool lan print $LANCHAN > /dev/null; do + sleep 3 + let TRIES=TRIES+1 + if [ $TRIES -gt $TIMEOUT ]; then break; fi + done + fi fi } From 2aef0c78aa4d63aa2d4494667225e3a1c3f8b8f4 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Tue, 14 Jun 2016 15:51:24 -0400 Subject: [PATCH 104/310] Add new subroutine and filter out disable networks for switchdiscover command --- .../lib/xcat/plugins/switchdiscover.pm | 219 ++++++++++++------ 1 file changed, 143 insertions(+), 76 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/switchdiscover.pm b/xCAT-server/lib/xcat/plugins/switchdiscover.pm index 38c7e3546..0211fe402 100644 --- a/xCAT-server/lib/xcat/plugins/switchdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/switchdiscover.pm @@ -14,6 +14,7 @@ use xCAT::NodeRange; use xCAT::NetworkUtils; use xCAT::Utils; use xCAT::SvrUtils; +use xCAT::Table; use XML::Simple; no strict; use Data::Dumper; @@ -33,12 +34,13 @@ my %global_switch_type = ( Juniper => "Juniper", juniper => "Juniper", Cisco => "Cisco", + cisco => "Cisco", BNT => "BNT", + Blade => "BNT", Mellanox => "Mellanox", mellanox => "Mellanox", MLNX => "Mellanox", - MELLAN => "Mellanox", - IBM => "BNT" + MELLAN => "Mellanox" ); @@ -683,6 +685,7 @@ sub nmap_scan { my $switches; my $found; my $counter=0; + my $osguess_ips=[]; if ($result_ref) { if (exists($result_ref->{host})) { my $host_ref = $result_ref->{host}; @@ -716,67 +719,8 @@ sub nmap_scan { } } } - ########################################################## - # If there is no vendor or other than %global_switch_type, - # issue the nmap again to do more aggresively discovery - # Choose best guess from osscan - # only search port 22 and 23 for fast performance - ########################################################### if ( ($found == 0) && ($type eq "mac") ) { - if (exists($globalopt{verbose})) { - send_msg($request, 0, "*********************************"); - send_msg($request, 0, "Couldn't find vendor info, use nmap osscan command to choose best guess"); - } - $ccmd = "/usr/bin/nmap -O --osscan-guess -A -p 22,23 -oX - $ip | grep osclass | grep -v embedded "; - if (exists($globalopt{verbose})) { - send_msg($request, 0, "Process command: $ccmd"); - } - my $os_result = xCAT::Utils->runcmd($ccmd, 0); - if ($::RUNCMD_RC == 0) - { - if (exists($globalopt{verbose})) { - send_msg($request, 0, "$os_result\n"); - } - my $os_vendor; - my @lines = split /\n/ => $os_result; - foreach my $line (@lines) { - # pick the first one if found osclass type = switch - if ($line =~ /switch/) { - if ($line =~ /vendor=\"(\S*)\"/) { - $os_vendor = $1; - last; - } - } - # if didn't find switch type, choose router as switch - if ($line =~ /router/) { - if ($line =~ /vendor=\"(\S*)\"/) { - if (!($os_vendor)) { - $os_vendor = $1; - } - } - } - } - if ($os_vendor) { - $switches->{$mac}->{ip} = $ip; - $switches->{$mac}->{vendor} = $os_vendor; - $switches->{$mac}->{name} = $host->{hostname}; - $found = 1; - if (exists($globalopt{verbose})) { - send_msg($request, 0, "Choose best guess: ip=$ip, mac=$mac, vendor=$os_vendor"); - send_msg($request, 0, "*********************************\n"); - } - } else { - if (exists($globalopt{verbose})) { - send_msg($request, 0, "ip=$ip, mac=$mac is not switch"); - send_msg($request, 0, "*********************************\n"); - } - } - } else { - if (exists($globalopt{verbose})) { - send_msg($request, 0, "ip=$ip, mac=$mac is not switch"); - send_msg($request, 0, "*********************************\n"); - } - } + push(@$osguess_ips, $ip); } # end nmap osscan command } #end for each address } @@ -784,9 +728,106 @@ sub nmap_scan { } } - return $switches + my $guess_switches = nmap_osguess($request, $osguess_ips); + foreach my $guess_mac ( keys %$guess_switches ) { + $switches->{$guess_mac}->{ip} = $guess_switches->{$guess_mac}->{ip};; + $switches->{$guess_mac}->{vendor} = $guess_switches->{$guess_mac}->{vendor}; + } + + return $switches; } +########################################################## +# If there is no vendor or other than %global_switch_type, +# issue the nmap again to do more aggresively discovery +# Choose best guess from osscan +# only search port 22 and 23 for fast performance +########################################################### +sub nmap_osguess { + my $request = shift; + my $ranges = shift; + my $switches; + my $cmd; + + if (exists($globalopt{verbose})) { + send_msg($request, 0, "Couldn't find vendor info, use nmap osscan command to choose best guess"); + } + + my $nmap_version = xCAT::Utils->get_nmapversion(); + if (xCAT::Utils->version_cmp($nmap_version,"5.10") < 0) { + $cmd = "/usr/bin/nmap -O --osscan-guess -A -p 22,23 @$ranges | grep -E 'Interesting ports on|MAC Addres|Device|Running|Aggressive OS guesses' "; + } else { + $cmd = "/usr/bin/nmap -O --osscan-guess -A -p 22,23 @$ranges | grep -E 'Nmap scan report|MAC Addres|Device|Running|Aggressive OS guesses' "; + } + if (exists($globalopt{verbose})) { + send_msg($request, 0, "Process command: $cmd"); + } + my $result = xCAT::Utils->runcmd($cmd, 0); + if (defined($globalopt{r}) || defined($globalopt{verbose})) { + send_msg($request, 0, "$result\n" ); + } + if ($::RUNCMD_RC == 0) + { + my @lines; + if (xCAT::Utils->version_cmp($nmap_version,"5.10") < 0) { + @lines = split /Interesting ports /, $result; + } else { + @lines = split /Nmap scan /, $result; + } + foreach my $lines_per_ip (@lines) { + my @lines2 = split /\n/, $lines_per_ip; + my $isswitch=0; + my $ip; + my $mac; + my $vendor; + foreach my $line (@lines2) { + if ($line =~ /\b(\d{1,3}(?:\.\d{1,3}){3})\b/) + { + $ip = $1; + } + + if ($line =~ /MAC Address/) { + my @array = split / /, $line; + $mac = $array[2]; + } + if ( $line =~ /Device type/ ) { + if ( ( $line =~ /switch/) || ( $line =~ /router/) ) { + $isswitch=1; + } else { + last; + } + } + my $search_string = join '|', keys(%global_switch_type); + if ($line =~ /Running/) { + if ($line =~ /($search_string)/){ + $vendor = $1; + last; + } + } + if ($line =~ /Aggressive OS/) { + if ($line =~ /($search_string)/){ + $vendor = $1; + $isswitch=1; + } + } + + } + if ($isswitch == 1) { + $switches->{$mac}->{ip} = $ip; + $switches->{$mac}->{vendor} = $vendor; + if (exists($globalopt{verbose})) { + send_msg($request, 0, "FOUND switch from osscan-guess: $ip, $mac, $vendor"); + } + } + } + + } + + return $switches; + +} + + #-------------------------------------------------------------------------------- @@ -811,14 +852,6 @@ sub snmp_scan { my $switches; my $counter = 0; - # snmpwalk command has to be available for snmp_scan - if (-x "/usr/bin/snmpwalk" ){ - send_msg($request, 0, "Discovering switches using snmpwalk....."); - } else { - send_msg($request, 0, "snmpwalk is not available, please install snmpwalk command first"); - return 1; - } - ################################################# # If --range options, take iprange, if noderange is defined # us the ip addresses of the nodes. If none is define, use the @@ -826,14 +859,19 @@ sub snmp_scan { ################################################## my $ranges = get_ip_ranges($request); + # snmpwalk command has to be available for snmp_scan + if (-x "/usr/bin/snmpwalk" ){ + send_msg($request, 0, "Discovering switches using snmpwalk for @$ranges ....."); + } else { + send_msg($request, 0, "snmpwalk is not available, please install snmpwalk command first"); + return 1; + } ########################################################## #use nmap to parse the ip range and possible output from the command: # Nmap scan report for switch-10-5-22-1 (10.5.22.1) 161/udp open snmp # Nmap scan report for 10.5.23.1 161/udp open snmp # Nmap scan report for 10.5.24.1 161/udp closed snmp - # Host 10.5.23.1 appears to be up ... good. 161/udp open|filtered snmp - # Host 10.5.24.1 appears to be up ... good. 161/udp closed snmp ########################################################## my $nmap_version = xCAT::Utils->get_nmapversion(); if (xCAT::Utils->version_cmp($nmap_version,"5.10") < 0) { @@ -1164,13 +1202,42 @@ sub get_ip_ranges { } # for default, use the subnets for all the live nics on the mn + # my_nets will return all the networks defined in the networks + # table, we need to exclude disable networks here. my $nets = xCAT::NetworkUtils->my_nets(); my $ranges=[]; - foreach my $net (keys %$nets) { - if ($net !~ /127\.0\.0\.0/) { - push(@$ranges, $net); + my $nettab = xCAT::Table->new('networks'); + my $disable_nets=[]; + if ($nettab) { + my $netents = $nettab->getAllEntries("all"); + foreach (@$netents) { + if ($_->{disable} =~ /1|YES|Yes|yes|Y|n/) { + push(@$disable_nets, $_->{'net'}); + if (exists($globalopt{verbose})) { + send_msg($request, 1, "network is disabled for $_->{'net'}, $_->{'mask'}"); + } + } } } + foreach my $net (keys %$nets) { + my $netdisabled=0; + if ($net !~ /127\.0\.0\.0/) { + my ($nt, $nm) = split (/\//, $net); + foreach (@$disable_nets) { + if ( $nt == $_) { + $netdisabled = 1; + } + } + if ($netdisabled != 1) { + push(@$ranges, $net); + } + } + } + + if (!@$ranges) { + send_msg($request, 1, "ip range is empty, nothing to discover" ); + exit 0; + } return $ranges; From 761ff38a2ecca48a3f1c152ff221b3c83ce2256e Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Tue, 14 Jun 2016 14:39:31 -0400 Subject: [PATCH 105/310] Change the echo messages to logger messages Add the -s option to logger to output the message to stderr --- xCAT-genesis-scripts/bin/bmcsetup | 40 +++++++++++++++++-------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index 83981024d..7acbbc09a 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -27,7 +27,7 @@ TIMEOUT=15 # function cold_reset_bmc() { if [ -z $XPROD ]; then - echo "FATAL ERROR - XPROD must be set before calling cold_reset_bmc()" + logger -s -t $log_label -p local4.crit "FATAL ERROR - XPROD must be set before calling ${FUNCNAME[0]}" exit 1 fi @@ -40,7 +40,6 @@ function cold_reset_bmc() { sleep 30 fi logger -s -t $log_label -p local4.info "Resetting BMC ..." - echo "Resetting BMC ..." ipmitool mc reset cold logger -s -t $log_label -p local4.info "Waiting for the BMC to appear ..." @@ -59,7 +58,7 @@ function cold_reset_bmc() { tries=$(($tries+1)) done TOTAL_SEC=$((${SLEEP_INTERVAL} * ${MAX_ITERATION})) - echo "ERROR, After waiting ${TOTAL_SEC} seconds, the BMC is not in a ready state." + logger -s -t $log_label -p local4.error "ERROR, After waiting ${TOTAL_SEC} seconds, the BMC is not in a ready state." else # for Non OpenPower servers, just sleep for some set time. sleep 15 @@ -83,7 +82,7 @@ function cold_reset_bmc() { # function snooze() { if [ -z $XPROD ]; then - echo "FATAL ERROR - XPROD must be set before calling snooze()" + logger -s -t $log_label -p local4.crit "FATAL ERROR - XPROD must be set before calling ${FUNCNAME[0]}" exit 1 fi @@ -124,23 +123,28 @@ while [ -z "$BMCIP" -a $IPCFGMETHOD="static" ]; do done kill $CREDPID NUMBMCS=`grep bmcip /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'|wc -l` -logger -t $log_label -p local4.info "NUMBMCS=$NUMBMCS" +logger -s -t $log_label -p local4.debug "BMC IP=$BMCIP, NETMASK=$BMCNM, GATEWAY=$BMCGW, VLAN=$BMCVLAN, USER=$BMCUS, PASSWORD=$BMCPW" +logger -s -t $log_label -p local4.info "NUMBMCS=$NUMBMCS" # # Get the BMC Version and Manufacturer ID # IPMIVER=`ipmitool mc info|grep ^IPMI|awk '{print $4}'` IPMIMFG=`ipmitool mc info|grep "^Manufacturer ID"|awk '{print $4}'` -logger -t $log_label -p local4.info "IPMIVER=$IPMIVER" -logger -t $log_label -p local4.info "IPMIMFG=$IPMIMFG" +logger -s -t $log_label -p local4.info "IPMIVER=$IPMIVER, IPMIMFG=$IPMIMFG" + # Get the BMC Product ID XPROD=`ipmitool mc info|grep "^Product ID"|awk '{print $4}'` -logger -t $log_label -p local4.info "XPROD=$XPROD" +logger -s -t $log_label -p local4.info "XPROD=$XPROD" +# +# IPMIMFG=2 = IBM +# IPMIMFG=0 = OpenPower +# if [ "$IPMIMFG" == 2 ]; then #IBM if [ "$XPROD" == "220" ]; then LOCKEDUSERS=1 BMCPORT=`grep bmcport /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'` - logger -t $log_label -p local4.info "BMCPORT is $BMCPORT" + logger -s -t $log_label -p local4.info "BMCPORT is $BMCPORT" if [ ! -z "$BMCPORT" ]; then let idev=0 IFS=',' @@ -150,7 +154,7 @@ if [ "$IPMIMFG" == 2 ]; then #IBM # Set the PEF Configuration Parameters (Platform Event Filtering) ipmitool -d $idev raw 0x04 0x12 0x09 0x01 0x18 0x${p}1 0x00 > /dev/null CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` - logger -t $log_label -p local4.info "CURBMCPORT is $CURBMCPORT" + logger -s -t $log_label -p local4.info "CURBMCPORT is $CURBMCPORT" while [ "$CURBMCPORT" -ne "$BMCPORT" ]; do sleep 1 # Get the LAN Configuration Parameters (OEM) @@ -165,7 +169,7 @@ if [ "$IPMIMFG" == 2 ]; then #IBM else # Get a ID for the server IBMFAM=`ipmitool raw 0x3a 0x50 |head -n 1| awk '{print $1 $2 $3 $4}'` - logger -t $log_label -p local4.info "IBMFAM is $IBMFAM" + logger -s -t $log_label -p local4.info "IBMFAM is $IBMFAM" if [ "$IBMFAM" == "59554f4f" ]; then BMCPORT=`grep bmcport /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'` if [ ! -z "$BMCPORT" ]; then @@ -174,7 +178,7 @@ if [ "$IPMIMFG" == 2 ]; then #IBM for p in $BMCPORT; do ipmitool -d $idev raw 0xc 1 1 0xc0 $p > /dev/null CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` - logger -t $log_label -p local4.info "CURBMCPORT is $CURBMCPORT" + logger -s -t $log_label -p local4.info "CURBMCPORT is $CURBMCPORT" while [ "$CURBMCPORT" -ne "$BMCPORT" ]; do sleep 1 CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` @@ -187,13 +191,13 @@ if [ "$IPMIMFG" == 2 ]; then #IBM fi elif [ "$IPMIMFG" == 20301 -o "$IPMIMFG" == 19046 ] ; then IBMVPDV=`ipmitool raw 0x3a 0xb 2 0 16 1` - logger -t $log_label -p local4.info "XPROD is $XPROD, IBMVPDV is $IBMVPDV" + logger -s -t $log_label -p local4.info "XPROD is $XPROD, IBMVPDV is $IBMVPDV" if [ $IBMVPDV -eq 2 ]; then ISITE=1; fi LOCKEDUSERS=1 BMCPORT=`grep bmcport /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'` - logger -t $log_label -p local4.info "BMCPORT is $BMCPORT" + logger -s -t $log_label -p local4.info "BMCPORT is $BMCPORT" if [ ! -z "$BMCPORT" ]; then let idev=0 IFS=',' @@ -208,7 +212,7 @@ elif [ "$IPMIMFG" == 20301 -o "$IPMIMFG" == 19046 ] ; then # reverts to dhcp then static, which setting a static ip for is # considered invalid CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` - logger -t $log_label -p local4.info "CURBMCPORT is $CURBMCPORT" + logger -s -t $log_label -p local4.info "CURBMCPORT is $CURBMCPORT" while [ -z "$CURBMCPORT" -o 0"$CURBMCPORT" -ne "$BMCPORT" ]; do sleep 1 CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'` @@ -352,7 +356,7 @@ for user in $BMCUS; do # Get the specified user CURRENTUSER=`ipmitool -d $idev user list $LANCHAN|grep ^$USERSLOT|awk '{print $2}'` DISABLEUSERS=`echo 1 2 3 4|sed -e s/$USERSLOT//` - logger -t $log_label -p local4.info "CURRENTUSER=$CURRENTUSER, DISABLEUSERS=$DISABLEUSERS" + logger -s -t $log_label -p local4.info "CURRENTUSER=$CURRENTUSER, DISABLEUSERS=$DISABLEUSERS" for user in $DISABLEUSERS; do TRIES=0 # Disable the non-specified user @@ -378,7 +382,7 @@ for user in $BMCUS; do # Get privilege for the specified user # CURRPRIV=`ipmitool -d $idev user list $LANCHAN|grep ^$USERSLOT|awk '{print $6}'` - logger -t $log_label -p local4.info "CURRPRIV=$CURRPRIV" + logger -s -t $log_label -p local4.info "CURRPRIV=$CURRPRIV" if [ "$CURRPRIV" != "ADMINISTRATOR" ]; then # Set the ADMIN privilege for the specified user while ! ipmitool -d $idev user priv $USERSLOT 4 $LANCHAN; do @@ -493,7 +497,7 @@ while [ $idev -gt 0 ]; do TWOIDX=$(ipmitool lan print $LANCHAN|grep ^RMCP+|cut -d: -f 2|sed -e 's/ //' -e 's/,/\n/g'|grep -n '^2$'|sed -e 's/:.*//') THREEIDX=$(ipmitool lan print $LANCHAN|grep ^RMCP+|cut -d: -f 2|sed -e 's/ //' -e 's/,/\n/g'|grep -n '^3$'|sed -e 's/:.*//') ACCESS=$(ipmitool lan print $LANCHAN|grep 'Cipher Suite Priv Max'|cut -d: -f 2|sed -e 's/ //g' -e 's/\(.\)/\1\n/g'|grep -v '^$') - logger -t $log_label -p local4.info "ZEROIDX is $ZEROIDX, ONEIDX is $ONEIDX, TWOIDX is $TWOIDX, THREEIDX is $THREEIDX, ACCESS is $ACCESS" + logger -s -t $log_label -p local4.info "ZEROIDX is $ZEROIDX, ONEIDX is $ONEIDX, TWOIDX is $TWOIDX, THREEIDX is $THREEIDX, ACCESS is $ACCESS" NEWACCESS="" i=1 for elem in $ACCESS; do From 4a03ed50dd01ef29555659b6c905e191e7bed000 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Tue, 14 Jun 2016 21:03:47 -0400 Subject: [PATCH 106/310] After the network commands are issued, pause for OpenPower case --- xCAT-genesis-scripts/bin/bmcsetup | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index 7acbbc09a..d3bfae78f 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -27,7 +27,7 @@ TIMEOUT=15 # function cold_reset_bmc() { if [ -z $XPROD ]; then - logger -s -t $log_label -p local4.crit "FATAL ERROR - XPROD must be set before calling ${FUNCNAME[0]}" + logger -s -t $log_label -p local4.crit "CRITICAL ERROR - XPROD must be set before calling ${FUNCNAME[0]}" exit 1 fi @@ -82,14 +82,16 @@ function cold_reset_bmc() { # function snooze() { if [ -z $XPROD ]; then - logger -s -t $log_label -p local4.crit "FATAL ERROR - XPROD must be set before calling ${FUNCNAME[0]}" + logger -s -t $log_label -p local4.crit "CRITICAL ERROR - XPROD must be set before calling ${FUNCNAME[0]}" exit 1 fi if [ "$XPROD" = "43707" ]; then # For OpenPower Machines + logger -s -t $log_label -p local4.debug "OpenPower, snooze for 30 seconds..." sleep 30 else + logger -s -t $log_label -p local4.debug "snooze for 1 second..." sleep 1 fi } @@ -328,6 +330,9 @@ for b in $BMCVLAN; do let idev=idev+1 done +# After network commands are issued, pause to allow the BMC to apply (OpenPower) +snooze + let idev=NUMBMCS-1 for user in $BMCUS; do if [ "$user" = "" ]; then From 4e8ae1653e4f90def6728def7c8a0c1726e3fca5 Mon Sep 17 00:00:00 2001 From: penguhyang Date: Tue, 14 Jun 2016 00:46:47 -0400 Subject: [PATCH 107/310] powerkvm,diskfull,enable access the installer via ssh --- xCAT-server/share/xcat/install/scripts/pre.pkvm3 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xCAT-server/share/xcat/install/scripts/pre.pkvm3 b/xCAT-server/share/xcat/install/scripts/pre.pkvm3 index 632f08197..098311e58 100755 --- a/xCAT-server/share/xcat/install/scripts/pre.pkvm3 +++ b/xCAT-server/share/xcat/install/scripts/pre.pkvm3 @@ -3,6 +3,10 @@ if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then set -x fi +if [ "$XCATDEBUGMODE" = "2" ]; then + echo 'root:cluster' | chpasswd +fi + #find first available block device (sda or vda likely) #TODO: pick a likely non-SAN target if possible From 4100a8085ca2cf264bf4f1c40b0fc60d3b9ce613 Mon Sep 17 00:00:00 2001 From: "litingt@cn.ibm.com" Date: Tue, 14 Jun 2016 01:28:05 -0400 Subject: [PATCH 108/310] modify the way to check the sync file --- .../reg_linux_statelite_installation_hierarchy_by_nfs | 7 +++++-- .../reg_linux_statelite_installation_hierarchy_by_ramdisk | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_nfs b/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_nfs index 7a5ce51da..0c0f1fd51 100644 --- a/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_nfs +++ b/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_nfs @@ -92,8 +92,11 @@ cmd:xdsh $$CN mount check:rc==0 check:output=~/nodedata/$$CN on /.statelite/persistent check:output=~compute/rootimg on / type nfs -cmd:MNIP=`cat /etc/hosts|grep $$MN|awk '{print $1}'`; result=`xdsh $$CN "cat /etc/resolv.conf|grep $MNIP"`; if [ "$result" = "$$CN: nameserver $MNIP" ]; then echo "sync file works well"; fi; -check:output=~sync file works well +cmd:scp $$CN:/etc/resolv.conf /tmp/resolv.conf +check:rc==0 +cmd:diff /etc/resolv.conf /tmp/resolv.conf +check:rc==0 +cmd:rm -f /tmp/resolv.conf cmd:rootimgdir=`lsdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute|grep rootimgdir|awk -F'=' '{print $2}'`; if [ -d $rootimgdir ]; then rm -rf $rootimgdir;fi check:rc==0 diff --git a/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_ramdisk b/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_ramdisk index a1a1b3dac..0477ac566 100644 --- a/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_ramdisk +++ b/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_ramdisk @@ -94,8 +94,11 @@ cmd:xdsh $$CN mount check:rc==0 check:output=~/nodedata/$$CN on /.statelite/persistent check:output=~rootfs on / type -cmd:MNIP=`cat /etc/hosts|grep $$MN|awk '{print $1}'`; result=`xdsh $$CN "cat /etc/resolv.conf|grep $MNIP"`; if [ "$result" = "$$CN: nameserver $MNIP" ]; then echo "sync file works well"; fi; -check:output=~sync file works well +cmd:scp $$CN:/etc/resolv.conf /tmp/resolv.conf +check:rc==0 +cmd:diff /etc/resolv.conf /tmp/resolv.conf +check:rc==0 +cmd:rm -f /tmp/resolv.conf cmd:rootimgdir=`lsdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute|grep rootimgdir|awk -F'=' '{print $2}'`; if [ -d $rootimgdir.regbak ]; then rm -rf $rootimgdir; mv $rootimgdir.regbak $rootimgdir; fi check:rc==0 From 57478143d92a011d54217b749cea3c366da31ef4 Mon Sep 17 00:00:00 2001 From: zet809 Date: Wed, 15 Jun 2016 15:15:27 +0800 Subject: [PATCH 109/310] Fix variable user using issue The variable (user) whose value is BMC username is reset as userid in line 365 --- xCAT-genesis-scripts/bin/bmcsetup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index d3bfae78f..ddef2655a 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -362,10 +362,10 @@ for user in $BMCUS; do CURRENTUSER=`ipmitool -d $idev user list $LANCHAN|grep ^$USERSLOT|awk '{print $2}'` DISABLEUSERS=`echo 1 2 3 4|sed -e s/$USERSLOT//` logger -s -t $log_label -p local4.info "CURRENTUSER=$CURRENTUSER, DISABLEUSERS=$DISABLEUSERS" - for user in $DISABLEUSERS; do + for userid in $DISABLEUSERS; do TRIES=0 # Disable the non-specified user - while ! ipmitool -d $idev user disable $user; do + while ! ipmitool -d $idev user disable $userid; do sleep 1 let TRIES=TRIES+1 if [ $TRIES -gt $TIMEOUT ]; then break; fi From e2b3183cfb0f62402be6f11fc4f72f4b8e1b8e82 Mon Sep 17 00:00:00 2001 From: penguhyang Date: Tue, 24 May 2016 05:52:06 -0400 Subject: [PATCH 110/310] fix #954, ubuntu, diskfull, enable the pre-script log and post-script-log can be forwarded to the MN --- xCAT-server/share/xcat/install/scripts/pre.ubuntu | 5 +++++ .../share/xcat/install/scripts/pre.ubuntu.ppc64 | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/xCAT-server/share/xcat/install/scripts/pre.ubuntu b/xCAT-server/share/xcat/install/scripts/pre.ubuntu index edbf17beb..3ca5e4515 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.ubuntu +++ b/xCAT-server/share/xcat/install/scripts/pre.ubuntu @@ -5,6 +5,11 @@ fi #!/bin/sh +if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then + killall syslogd + syslogd -R #XCATVAR:XCATMASTER# +fi + if [ ! -c /dev/vcs ]; then mknod /dev/vcs c 7 0 fi diff --git a/xCAT-server/share/xcat/install/scripts/pre.ubuntu.ppc64 b/xCAT-server/share/xcat/install/scripts/pre.ubuntu.ppc64 index 81d44053a..7fe22bf84 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.ubuntu.ppc64 +++ b/xCAT-server/share/xcat/install/scripts/pre.ubuntu.ppc64 @@ -1,5 +1,15 @@ +export XCATDEBUGMODE="#TABLEBLANKOKAY:site:key=xcatdebugmode:value#" +if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then + set -x +fi + #!/bin/sh +if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then + killall syslogd + syslogd -R #XCATVAR:XCATMASTER# +fi + if [ ! -c /dev/vcs ]; then mknod /dev/vcs c 7 0 fi @@ -222,3 +232,7 @@ echo " ." >> /tmp/partitionfile exit 0 +if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then +then + set +x +fi From 183440cd6727d1503678ce956a532c793ade30b8 Mon Sep 17 00:00:00 2001 From: penguhyang Date: Wed, 15 Jun 2016 04:29:37 -0400 Subject: [PATCH 111/310] update Log Collecting content for xcat docs --- docs/source/troubleshooting/os_installation/log_to_mn_cn.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/troubleshooting/os_installation/log_to_mn_cn.rst b/docs/source/troubleshooting/os_installation/log_to_mn_cn.rst index 8b19712b3..cc39421f7 100644 --- a/docs/source/troubleshooting/os_installation/log_to_mn_cn.rst +++ b/docs/source/troubleshooting/os_installation/log_to_mn_cn.rst @@ -22,7 +22,7 @@ The following behavior is observed during OS install: + log +----+----+----+----+----+----+----+----+----+----+ | | CN | Y1 | Y2 | Y2 | +-------------+----+----+----+----+----+----+----+----+----+----+ -| Installer | MN | N | N | N | Y6 | Y6 | N | Y6 | Y6 | N | +| Installer | MN | N | N | N | Y6 | Y6 | Y6 | Y6 | Y6 | Y6 | + log +----+----+----+----+----+----+----+----+----+----+ | | CN | Y5 | Y5 | Y5 | Y5 | Y5 | Y5 | Y5 | Y5 | Y5 | +-------------+----+----+----+----+----+----+----+----+----+----+ From 7fa07c687e1511b88b34dfc2a4713234e99cfa88 Mon Sep 17 00:00:00 2001 From: wangxiaopeng Date: Wed, 15 Jun 2016 10:13:06 -0400 Subject: [PATCH 112/310] issue 1191: do retry when update dns record replies NOTAUTH --- xCAT-server/lib/xcat/plugins/ddns.pm | 49 ++++++++++++++++------------ 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ddns.pm b/xCAT-server/lib/xcat/plugins/ddns.pm index fd061ffb8..580667c29 100755 --- a/xCAT-server/lib/xcat/plugins/ddns.pm +++ b/xCAT-server/lib/xcat/plugins/ddns.pm @@ -1439,38 +1439,45 @@ sub add_or_delete_records { } $numreqs -= 1; if ($numreqs == 0) { - $update->sign_tsig("xcat_key",$ctx->{privkey}); - $numreqs=300; - my $reply = $resolver->send($update); - if ($reply) - { - if ($reply->header->rcode ne 'NOERROR') - { - xCAT::SvrUtils::sendmsg([1,"Failure encountered updating $zone, error was ".$reply->header->rcode.". See more details in system log."], $callback); + # sometimes even the xcat_key is correct, but named still replies NOTAUTH, so retry + for (1..3) { + $update->sign_tsig("xcat_key",$ctx->{privkey}); + $numreqs=300; + my $reply = $resolver->send($update); + if ($reply) { + if ($reply->header->rcode eq 'NOTAUTH' ) { + continue; + } + if ($reply->header->rcode ne 'NOERROR') { + xCAT::SvrUtils::sendmsg([1,"Failure encountered updating $zone, error was ".$reply->header->rcode.". See more details in system log."], $callback); + } } + else { + xCAT::SvrUtils::sendmsg([1,"No reply received when sending DNS update to zone $zone"], $callback); + } + last; } - else - { - xCAT::SvrUtils::sendmsg([1,"No reply received when sending DNS update to zone $zone"], $callback); - } - $update = Net::DNS::Update->new($zone); #new empty request } } if ($numreqs != 300) { #either no entries at all to begin with or a perfect multiple of 300 - $update->sign_tsig("xcat_key",$ctx->{privkey}); - my $reply = $resolver->send($update); - if ($reply) - { - if ($reply->header->rcode ne 'NOERROR') - { + # sometimes even the xcat_key is correct, but named still replies NOTAUTH, so retry + for (1..3) { + $update->sign_tsig("xcat_key",$ctx->{privkey}); + my $reply = $resolver->send($update); + if ($reply) { + if ($reply->header->rcode eq 'NOTAUTH' ) { + continue; + } + if ($reply->header->rcode ne 'NOERROR') { xCAT::SvrUtils::sendmsg([1,"Failure encountered updating $zone, error was ".$reply->header->rcode.". See more details in system log."], $callback); } } - else - { + else { xCAT::SvrUtils::sendmsg([1,"No reply received when sending DNS update to zone $zone"], $callback); } + last; + } # sometimes resolver does not work if the update zone request sent so quick sleep 1; From 36581095279c7ef420d82a14490e7cbfc8e50e19 Mon Sep 17 00:00:00 2001 From: wangxiaopeng Date: Wed, 15 Jun 2016 20:37:16 -0400 Subject: [PATCH 113/310] issue 1304: fix the issue confignics -s cannot get the correct netmask for installnic --- xCAT/postscripts/configeth | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xCAT/postscripts/configeth b/xCAT/postscripts/configeth index 915d5e840..6e82999e3 100755 --- a/xCAT/postscripts/configeth +++ b/xCAT/postscripts/configeth @@ -428,7 +428,7 @@ elif [ "$1" = "-s" ];then if [ ! -z "str_inst_ip" ];then inst_ip_pre=`ip ro ls|grep -i ${str_inst_ip}|awk '{print $1}'|awk -F/ '{print $1}'` if [ ! -z "inst_ip_pre" ];then - str_inst_mask=`route |grep ${inst_ip_pre}|awk '{print $3}'|head -1` + str_inst_mask=`route |grep ^${inst_ip_pre}|awk '{print $3}'|head -1` fi fi fi @@ -450,7 +450,7 @@ elif [ "$1" = "-s" ];then if [ ! -z "str_inst_ip" ];then inst_ip_pre=`ip ro ls|grep -i ${str_inst_ip}|awk '{print $1}'|awk -F/ '{print $1}'` if [ ! -z "inst_ip_pre" ];then - str_inst_mask=`route |grep ${inst_ip_pre}|awk '{print $3}'|head -1` + str_inst_mask=`route |grep ^${inst_ip_pre}|awk '{print $3}'|head -1` fi fi fi @@ -473,7 +473,7 @@ elif [ "$1" = "-s" ];then if [ ! -z "str_inst_ip" ];then inst_ip_pre=`ip ro ls|grep -i ${str_inst_ip}|awk '{print $1}'|awk -F/ '{print $1}'` if [ ! -z "inst_ip_pre" ];then - str_inst_mask=`route |grep ${inst_ip_pre}|awk '{print $3}'|head -1` + str_inst_mask=`route |grep ^${inst_ip_pre}|awk '{print $3}'|head -1` fi fi fi From 04bd59443c95432b9a1798ddaccad988acd8ad4e Mon Sep 17 00:00:00 2001 From: immarvin Date: Wed, 15 Jun 2016 05:13:00 -0400 Subject: [PATCH 114/310] fix nicips.enP5p7s0f1 can not removed from node definition. #1276 --- perl-xCAT/xCAT/DBobjUtils.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/perl-xCAT/xCAT/DBobjUtils.pm b/perl-xCAT/xCAT/DBobjUtils.pm index 1cbaeac1d..f71625898 100755 --- a/perl-xCAT/xCAT/DBobjUtils.pm +++ b/perl-xCAT/xCAT/DBobjUtils.pm @@ -2541,10 +2541,8 @@ sub collapsenicsattr() if ($1 && $2) { # chdef nicips.eth2= to remove the definition for eth2 # in this case, the $nodeattrhash->{'nicips.eth0'} is blank - if ($nodeattrhash->{$nodeattr}) { - # $nicattrs{nicips}{eth0} = "1.1.1.1|1.2.1.1" - $nicattrs{$1}{$2} = $nodeattrhash->{$nodeattr}; - } + # $nicattrs{nicips}{eth0} = "1.1.1.1|1.2.1.1" + $nicattrs{$1}{$2} = $nodeattrhash->{$nodeattr}; # remove nicips.eth0 from the %::FILEATTRS delete $nodeattrhash->{$nodeattr}; @@ -2557,7 +2555,9 @@ sub collapsenicsattr() my @tmparray = (); foreach my $nicname (keys %{$nicattrs{$nicattr}}) { # eth0!1.1.1.1|1.2.1.1 - push @tmparray, "$nicname!$nicattrs{$nicattr}{$nicname}"; + if($nicattrs{$nicattr}{$nicname}){ + push @tmparray, "$nicname!$nicattrs{$nicattr}{$nicname}"; + } } # eth0!1.1.1.1|1.2.1.1,eth1!2.1.1.1|2.2.1.1 $nodeattrhash->{$nicattr} = join(',', @tmparray); From 0a0f1d76d7f2888ab7f2ff332ccdfbe4a4f634f4 Mon Sep 17 00:00:00 2001 From: penguhyang Date: Tue, 24 May 2016 06:44:05 -0400 Subject: [PATCH 115/310] fix #1083, redhat sles, diskless, enable the diskless installation can be forwarded to MN when xcatdebugmode=2 --- perl-xCAT/xCAT/Schema.pm | 2 +- xCAT-server/lib/xcat/plugins/anaconda.pm | 30 ++++++------- xCAT-server/lib/xcat/plugins/sles.pm | 32 +++++++------- .../share/xcat/netboot/rh/dracut_033/xcatroot | 40 +++++++++--------- .../xcat/netboot/sles/dracut_033/xcatroot | 42 +++++++++---------- 5 files changed, 72 insertions(+), 74 deletions(-) diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index e7b7b0d97..fb486ad38 100755 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -1131,7 +1131,7 @@ use xCAT::ExtTab; " currently supported values:\n". " '0': disable debug mode\n". " '1': enable basic debug mode\n". -" '2': enalbe expert debug mode\n". +" '2': enable expert debug mode\n". " For the details on 'basic debug mode' and 'expert debug mode',\n". " please refer to xCAT documentation.\n\n". " --------------------\n" . diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index fa5c05c15..00590ba7b 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -745,24 +745,24 @@ sub mknetboot $kcmdline .= " nonodestatus "; } - if($::XCATSITEVALS{xcatdebugmode} eq "1"){ + if (($::XCATSITEVALS{xcatdebugmode} eq "1") or ($::XCATSITEVALS{xcatdebugmode} eq "2")) { - my ($host, $ipaddr) = xCAT::NetworkUtils->gethostnameandip($xcatmaster); - if($ipaddr){ - #for use in postscript and postbootscript in xcatdsklspost in the rootimg - $kcmdline .=" LOGSERVER=$ipaddr "; - - #for use in syslog dracut module in the initrd - $kcmdline .=" syslog.server=$ipaddr syslog.type=rsyslogd syslog.filter=*.* "; - }else{ - #for use in postscript and postbootscript in xcatdsklspost in the rootimg - $kcmdline .=" LOGSERVER=$xcatmaster "; + my ($host, $ipaddr) = xCAT::NetworkUtils->gethostnameandip($xcatmaster); + if ($ipaddr) { + #for use in postscript and postbootscript in xcatdsklspost in the rootimg + $kcmdline .=" LOGSERVER=$ipaddr "; - #for use in syslog dracut module in the initrd - $kcmdline .=" syslog.server=$xcatmaster syslog.type=rsyslogd syslog.filter=*.* "; - } + #for use in syslog dracut module in the initrd + $kcmdline .=" syslog.server=$ipaddr syslog.type=rsyslogd syslog.filter=*.* "; + } + else { + #for use in postscript and postbootscript in xcatdsklspost in the rootimg + $kcmdline .=" LOGSERVER=$xcatmaster "; - $kcmdline .= " xcatdebugmode=1 "; + #for use in syslog dracut module in the initrd + $kcmdline .=" syslog.server=$xcatmaster syslog.type=rsyslogd syslog.filter=*.* "; + } + $kcmdline .= " xcatdebugmode=$::XCATSITEVALS{xcatdebugmode} "; } # Add kernel parameters to specify the boot network interface diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index b3d501559..aa9227b40 100644 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -576,28 +576,26 @@ sub mknetboot $kcmdline .= " nonodestatus "; } + if (($::XCATSITEVALS{xcatdebugmode} eq "1") or ($::XCATSITEVALS{xcatdebugmode} eq "2")) { - if($::XCATSITEVALS{xcatdebugmode} eq "1"){ + my ($host, $ipaddr) = xCAT::NetworkUtils->gethostnameandip($xcatmaster); + if ($ipaddr) { + #for use in postscript and postbootscript in xcatdsklspost in the rootimg + $kcmdline .=" LOGSERVER=$ipaddr "; - my ($host, $ipaddr) = xCAT::NetworkUtils->gethostnameandip($xcatmaster); - if($ipaddr){ - #for use in postscript and postbootscript in xcatdsklspost in the rootimg - $kcmdline .=" LOGSERVER=$ipaddr "; + #for use in syslog dracut module in the initrd + $kcmdline .=" syslog.server=$ipaddr syslog.type=rsyslogd syslog.filter=*.* "; + } + else { + #for use in postscript and postbootscript in xcatdsklspost in the rootimg + $kcmdline .=" LOGSERVER=$xcatmaster "; - #for use in syslog dracut module in the initrd - $kcmdline .=" syslog.server=$ipaddr syslog.type=rsyslogd syslog.filter=*.* "; - }else{ - #for use in postscript and postbootscript in xcatdsklspost in the rootimg - $kcmdline .=" LOGSERVER=$xcatmaster "; - - #for use in syslog dracut module in the initrd - $kcmdline .=" syslog.server=$xcatmaster syslog.type=rsyslogd syslog.filter=*.* "; - } - - $kcmdline .= " xcatdebugmode=1 "; + #for use in syslog dracut module in the initrd + $kcmdline .=" syslog.server=$xcatmaster syslog.type=rsyslogd syslog.filter=*.* "; + } + $kcmdline .= " xcatdebugmode=$::XCATSITEVALS{xcatdebugmode} "; } - $kcmdline .= "NODE=$node "; # add flow control setting $kcmdline .= "FC=$useflowcontrol "; diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot index a5d8e8e63..5ac7233a9 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot @@ -22,12 +22,12 @@ fi xcatdebugmode="$(getarg xcatdebugmode=)" -[ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "running xcatroot...." -[ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "MASTER=$MASTER XCATIPORT=$XCATIPORT" +[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "running xcatroot...." +[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "MASTER=$MASTER XCATIPORT=$XCATIPORT" if [ $NODESTATUS -ne 0 ];then -[ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "nodestatus: netbooting,reporting..." +[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "nodestatus: netbooting,reporting..." /tmp/updateflag $MASTER $XCATIPORT "installstatus netbooting" fi @@ -36,10 +36,10 @@ if [ ! -z "$imgurl" ]; then NFS=0 FILENAME=${imgurl##*/} while [ ! -r "$FILENAME" ]; do - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "downloading $imgurl...." + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "downloading $imgurl...." echo Getting $imgurl... if ! wget $imgurl; then - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "downloading $imgurl failed,retrying...." + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "downloading $imgurl failed,retrying...." rm -f $FILENAME sleep 27 fi @@ -70,7 +70,7 @@ if [ -r /rootimg.sfs ]; then mount --move /ro $NEWROOT/ro mount --move /rw $NEWROOT/rw elif [ -r /rootimg.gz ]; then - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "rootimg.gz downloaded,setting up RAM-root tmpfs...." + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg.gz downloaded,setting up RAM-root tmpfs...." echo Setting up RAM-root tmpfs. if [ -z $rootlimit ];then mount -t tmpfs -o mode=755 rootfs $NEWROOT @@ -79,7 +79,7 @@ elif [ -r /rootimg.gz ]; then fi cd $NEWROOT - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "Extracting root filesystem:" + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Extracting root filesystem:" echo -n "Extracting root filesystem:" if [ -x /bin/cpio ]; then gzip -cd /rootimg.gz |/bin/cpio -idum @@ -87,7 +87,7 @@ elif [ -r /rootimg.gz ]; then gzip -cd /rootimg.gz |cpio -idum fi $NEWROOT/etc/init.d/localdisk - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "Done...." + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...." echo Done elif [ -r /rootimg.txz ]; then echo Setting up RAM-root tmpfs. @@ -225,17 +225,17 @@ elif [ -r /rootimg-statelite.gz ]; then mount -n --bind /sys $NEWROOT/sys else - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "Failed to download image, panicing in 5..." + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Failed to download image, panicing in 5..." echo -n Failed to download image, panicing in 5... for i in 4 3 2 1 0; do /bin/sleep 1 - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "$i..." + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "$i..." echo -n $i... done - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "You're dead. rpower nodename reset to play again." - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "* Did you packimage with -m cpio, -m squashfs, or -m nfs?" - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "* If using -m squashfs did you include aufs.ko with geninitrd? e.g.: -n tg3,squashfs,aufs,loop" - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "If using -m nfs did you export NFS and sync rootimg? And did you include the aufs and nfs modules in the proper order: e.g.: -n tg3,aufs,loop,sunrpc,lockd,nfs_acl,nfs" + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "You're dead. rpower nodename reset to play again." + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "* Did you packimage with -m cpio, -m squashfs, or -m nfs?" + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "* If using -m squashfs did you include aufs.ko with geninitrd? e.g.: -n tg3,squashfs,aufs,loop" + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "If using -m nfs did you export NFS and sync rootimg? And did you include the aufs and nfs modules in the proper order: e.g.: -n tg3,aufs,loop,sunrpc,lockd,nfs_acl,nfs" echo echo "You're dead. rpower nodename reset to play again. @@ -277,7 +277,7 @@ if [ -z $STATEMNT ]; then netif=${lf#*.} netif=${netif%.*} cp $lf "$NEWROOT/var/lib/dhclient/dhclient-$netif.leases" - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "saving $NEWROOT/var/lib/dhclient/dhclient-$netif.leases" + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "saving $NEWROOT/var/lib/dhclient/dhclient-$netif.leases" done if [ ! -z "$ifname" ]; then @@ -296,10 +296,10 @@ if [ -z $STATEMNT ]; then if [ ! -z "$MACX" ] && [ ! -z "$ETHX" ]; then if [ ! -e $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX ]; then - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "creating $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX" + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "creating $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX" touch $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX fi - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "writing $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX: DEVICE=$ETHX;BOOTPROTO=dhcp;HWADDR=$MACX;ONBOOT=yes" + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "writing $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX: DEVICE=$ETHX;BOOTPROTO=dhcp;HWADDR=$MACX;ONBOOT=yes" echo "DEVICE=$ETHX" > $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX echo "BOOTPROTO=dhcp" >> $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX echo "HWADDR=$MACX" >> $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX @@ -307,15 +307,15 @@ if [ -z $STATEMNT ]; then fi fi -[ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "saving $NEWROOT/etc/resolv.conf" +[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "saving $NEWROOT/etc/resolv.conf" cp /etc/resolv.conf "$NEWROOT/etc/" if [ -d "$NEWROOT/etc/sysconfig" -a ! -e "$NEWROOT/etc/sysconfig/selinux" ]; then - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "disable selinux ..." + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "disable selinux ..." echo "SELINUX=disabled" >> "$NEWROOT/etc/sysconfig/selinux" fi -[ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "exiting xcatroot..." +[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "exiting xcatroot..." # inject new exit_if_exists echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm "$job"' > $hookdir/initqueue/xcat.sh # force udevsettle to break diff --git a/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot b/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot index a1a42566c..c02971ef7 100755 --- a/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot +++ b/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot @@ -20,12 +20,12 @@ fi xcatdebugmode="$(getarg xcatdebugmode=)" -[ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "running xcatroot...." +[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "running xcatroot...." -[ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "MASTER=$MASTER XCATIPORT=$XCATIPORT" +[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "MASTER=$MASTER XCATIPORT=$XCATIPORT" if [ $NODESTATUS -ne 0 ];then -[ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "nodestatus: netbooting,reporting..." +[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "nodestatus: netbooting,reporting..." /tmp/updateflag $MASTER $XCATIPORT "installstatus netbooting" fi @@ -34,10 +34,10 @@ if [ ! -z "$imgurl" ]; then NFS=0 FILENAME=${imgurl##*/} while [ ! -r "$FILENAME" ]; do - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "downloading $imgurl...." + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "downloading $imgurl...." echo Getting $imgurl... if ! wget $imgurl; then - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "downloading $imgurl failed,retrying...." + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "downloading $imgurl failed,retrying...." rm -f $FILENAME sleep 27 fi @@ -68,7 +68,7 @@ if [ -r /rootimg.sfs ]; then mount --move /ro $NEWROOT/ro mount --move /rw $NEWROOT/rw elif [ -r /rootimg.gz ]; then - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "rootimg.gz downloaded,setting up RAM-root tmpfs...." + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg.gz downloaded,setting up RAM-root tmpfs...." echo Setting up RAM-root tmpfs. if [ -z $rootlimit ];then mount -t tmpfs -o mode=755 rootfs $NEWROOT @@ -77,7 +77,7 @@ elif [ -r /rootimg.gz ]; then fi cd $NEWROOT - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "Extracting root filesystem:" + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Extracting root filesystem:" echo -n "Extracting root filesystem:" if [ -x /bin/cpio ]; then gzip -cd /rootimg.gz |/bin/cpio -idum @@ -85,7 +85,7 @@ elif [ -r /rootimg.gz ]; then gzip -cd /rootimg.gz |cpio -idum fi $NEWROOT/etc/init.d/localdisk - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "Done...." + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...." echo Done elif [ -r /rootimg-statelite.gz ]; then echo Setting up RAM-root tmpfs for statelite mode. @@ -210,18 +210,18 @@ elif [ -r /rootimg-statelite.gz ]; then mount -n --bind /sys $NEWROOT/sys else - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "Failed to download image, panicing in 5..." + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Failed to download image, panicing in 5..." echo -n Failed to download image, panicing in 5... for i in 4 3 2 1 0; do /bin/sleep 1 - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "$i..." + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "$i..." echo -n $i... done - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "You're dead. rpower nodename reset to play again." - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "* Did you packimage with -m cpio, -m squashfs, or -m nfs?" - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "* If using -m squashfs did you include aufs.ko with geninitrd? e.g.: -n tg3,squashfs,aufs,loop" - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "If using -m nfs did you export NFS and sync rootimg? And did you include the aufs and nfs modules in the proper order: e.g.: -n tg3,aufs,loop,sunrpc,lockd,nfs_acl,nfs" + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "You're dead. rpower nodename reset to play again." + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "* Did you packimage with -m cpio, -m squashfs, or -m nfs?" + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "* If using -m squashfs did you include aufs.ko with geninitrd? e.g.: -n tg3,squashfs,aufs,loop" + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "If using -m nfs did you export NFS and sync rootimg? And did you include the aufs and nfs modules in the proper order: e.g.: -n tg3,aufs,loop,sunrpc,lockd,nfs_acl,nfs" echo echo "You're dead. rpower nodename reset to play again. @@ -262,7 +262,7 @@ if [ -z $STATEMNT ]; then netif=${lf#*.} netif=${netif%.*} cp $lf "$NEWROOT/var/lib/dhclient/dhclient-$netif.leases" - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "saving $NEWROOT/var/lib/dhclient/dhclient-$netif.leases" + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "saving $NEWROOT/var/lib/dhclient/dhclient-$netif.leases" done if [ ! -z "$ifname" ]; then @@ -278,10 +278,10 @@ if [ -z $STATEMNT ]; then if [ ! -z "$MACX" ] && [ ! -z "$ETHX" ]; then if [ ! -e $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX ]; then - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "creating $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX" + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "creating $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX" touch $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX fi - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "writing $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX: DEVICE=$ETHX;BOOTPROTO=dhcp;HWADDR=$MACX;ONBOOT=yes" + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "writing $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX: DEVICE=$ETHX;BOOTPROTO=dhcp;HWADDR=$MACX;ONBOOT=yes" echo "DEVICE=$ETHX" > $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX echo "BOOTPROTO=dhcp" >> $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX echo "HWADDR=$MACX" >> $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX @@ -289,18 +289,18 @@ if [ -z $STATEMNT ]; then fi fi -[ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "saving $NEWROOT/etc/resolv.conf" +[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "saving $NEWROOT/etc/resolv.conf" cp /etc/resolv.conf "$NEWROOT/etc/" if [ -d "$NEWROOT/etc/sysconfig" -a ! -e "$NEWROOT/etc/sysconfig/selinux" ]; then - [ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "disable selinux ..." + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "disable selinux ..." echo "SELINUX=disabled" >> "$NEWROOT/etc/sysconfig/selinux" fi -[ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "setting hostname..." +[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "setting hostname..." echo `hostname` > $NEWROOT/etc/hostname -[ "$xcatdebugmode" = "1" ] && logger -t xcat -p debug "exiting xcatroot..." +[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "exiting xcatroot..." # inject new exit_if_exists echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm "$job"' > $hookdir/initqueue/xcat.sh From e3bb8433df3725948fc651042ed72695d0d05ab4 Mon Sep 17 00:00:00 2001 From: XuWei Date: Thu, 16 Jun 2016 03:06:44 -0400 Subject: [PATCH 116/310] Fix issue 1204, rm /xcatpost folder before wget postscripts --- xCAT/postscripts/xcatdsklspost | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xCAT/postscripts/xcatdsklspost b/xCAT/postscripts/xcatdsklspost index 28489c947..de49ba994 100755 --- a/xCAT/postscripts/xcatdsklspost +++ b/xCAT/postscripts/xcatdsklspost @@ -112,8 +112,12 @@ download_postscripts() retry=0 rc=1 # this is a fail return while [ 0 -eq 0 ]; do - - export LANG=C; wget -l inf -nH -N -r --waitretry=10 --random-wait -e robots=off -T 60 -nH --cut-dirs=2 --reject "index.html*" --no-parent http://$server$INSTALLDIR/postscripts/ -P /$xcatpost 2> /tmp/wget.log + + if [ -e "\/$xcatpost" ]; then + rm -rf "\/$xcatpost" + fi + + export LANG=C; wget -l inf -nH -N -r --waitretry=10 --random-wait -e robots=off -T 60 -nH --cut-dirs=2 --reject "index.html*" --no-parent http://$server$INSTALLDIR/postscripts/ -P /$xcatpost 2> /tmp/wget.log rc=$? if [ $rc -eq 0 ]; then # return from wget was 0 but some OS do not return errors, so we From f6543e83903f24687c0194783c50ceeada38058a Mon Sep 17 00:00:00 2001 From: penguhyang Date: Tue, 24 May 2016 06:10:27 -0400 Subject: [PATCH 117/310] fix #1083, ubuntu, diskless, enable the diskless installation log can be forwarded to the MN --- xCAT-server/lib/xcat/plugins/debian.pm | 17 +- .../share/xcat/netboot/ubuntu/genimage | 212 ++++++++++-------- 2 files changed, 126 insertions(+), 103 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/debian.pm b/xCAT-server/lib/xcat/plugins/debian.pm index 44f54b0ad..4610c6ca0 100644 --- a/xCAT-server/lib/xcat/plugins/debian.pm +++ b/xCAT-server/lib/xcat/plugins/debian.pm @@ -1431,16 +1431,17 @@ sub mknetboot } - if($::XCATSITEVALS{xcatdebugmode} eq "1"){ + if (($::XCATSITEVALS{xcatdebugmode} eq "1") or ($::XCATSITEVALS{xcatdebugmode} eq "2")) { - my ($host, $ipaddr) = xCAT::NetworkUtils->gethostnameandip($xcatmaster); - if($ipaddr){ - $kcmdline .=" LOGSERVER=$ipaddr "; - }else{ - $kcmdline .=" LOGSERVER=$xcatmaster "; - } + my ($host, $ipaddr) = xCAT::NetworkUtils->gethostnameandip($xcatmaster); + if ($ipaddr) { + $kcmdline .=" LOGSERVER=$ipaddr "; + } + else { + $kcmdline .=" LOGSERVER=$xcatmaster "; + } - $kcmdline .= " xcatdebugmode=1 "; + $kcmdline .= " xcatdebugmode=$::XCATSITEVALS{xcatdebugmode} "; } diff --git a/xCAT-server/share/xcat/netboot/ubuntu/genimage b/xCAT-server/share/xcat/netboot/ubuntu/genimage index efbdb4e52..1a18df1b1 100755 --- a/xCAT-server/share/xcat/netboot/ubuntu/genimage +++ b/xCAT-server/share/xcat/netboot/ubuntu/genimage @@ -998,15 +998,15 @@ NORMAL=\$RESET # over the root directory. # This function is stolen from redhat shell() { - echo '' - echo -e "\$YELLOW Entering rescue/debug init shell." - echo -e " Exit shell to continue booting.\$RESET" - \$SHELL + echo '' + echo -e "\$YELLOW Entering rescue/debug init shell." + echo -e " Exit shell to continue booting.\$RESET" + \$SHELL } fancydisplay () { - clear - echo -e "\$CYAN" + clear + echo -e "\$CYAN" echo ' .. :iiii, :tLL; .,:...,. @@ -1032,8 +1032,8 @@ echo ' ;fGGGf, ,;;;;,: tf;jL, ;.:::, Powered by xCAT ,j.:; ' - echo -e "\$RESET" - echo -e "\$YELLOW" + echo -e "\$RESET" + echo -e "\$YELLOW" echo ' _________ ________________ ___ __\\_ ___ \\ / _ \\__ ___/ @@ -1042,7 +1042,7 @@ echo ' /__/\\_ \\\\______ /\\____|__ /____| \\/ \\/ \\/ ' - echo -e "\$RESET" + echo -e "\$RESET" } EOS1 @@ -1145,13 +1145,15 @@ for i in `cat /proc/cmdline`; do VALUE=`echo \$i |awk -F= '{print \$2}'` # format: XCAT=xcatmaster:3001 XCATIPORT=\$VALUE + elif [ "\$KEY" = 'xcatdebugmode' ]; then + VALUE=`echo \$i |awk -F= '{print \$2}'` + xcatdebugmode=\$VALUE fi #if "nonodestatus" specified,do not update the nodestatus - if [ \$i == 'nonodestatus' ]; then + if [ "\$i" = 'nonodestatus' ]; then NODESTATUS='n' fi - done if [ -z "\$IFACE" ]; then @@ -1183,64 +1185,73 @@ ifconfig lo up XCATMASTER=`echo \$XCATSERVER|awk -F: '{print \$1}'` +if [ "\$xcatdebugmode" = "1" ] || [ "\$xcatdebugmode" = "2" ]; then + PORT="514" + syslogd -R \$XCATMASTER:\$PORT +fi + +([ "\$xcatdebugmode" = "1" ] || [ "\$xcatdebugmode" = "2" ]) && logger -t xcat -p debug "running init script..." +([ "\$xcatdebugmode" = "1" ] || [ "\$xcatdebugmode" = "2" ]) && logger -t xcat -p debug "MASTER=\$XCATMASTER XCATIPORT=\$XCATIPORT" #update nodelist.nodestatus to "netbooting" if [ \$NODESTATUS != 'n' ]; then + ([ "\$xcatdebugmode" = "1" ] || [ "\$xcatdebugmode" = "2" ]) && logger -t xcat -p debug "nodestatus: netbooting,reporting..." /tmp/updateflag \$XCATMASTER \$XCATIPORT "installstatus netbooting" fi cd / for i in `cat /proc/cmdline`; do - KEY=`echo \$i |awk -F= '{print \$1}'` - if [ "\$KEY" == 'imgurl' ]; then - VALUE=`echo \$i |awk -F= '{print \$2}'` - if [ "http" == "`echo \$VALUE|awk -F: '{print \$1}'`" ]; then - #NOTE needs FT retry code to scale - #NOTE: should prob have max count - FILENAME=`echo \$VALUE|awk -F/ '{print \$NF}'` - - MAXTRIES=5 - ITER=0 - while [ ! -r "\$FILENAME" ]; do - echo Getting \$VALUE... - if ! /usr/bin/wget \$VALUE; then - ST=`expr \$RANDOM % 5` - sleep \$ST - rm -f \$FILENAME - ITER=\$(expr \$ITER + 1 ) - if [ "\$ITER" == "\$MAXTRIES" ]; then - /bin/busybox telnetd -l /bin/sh - shell + KEY=`echo \$i |awk -F= '{print \$1}'` + if [ "\$KEY" = 'imgurl' ]; then + VALUE=`echo \$i |awk -F= '{print \$2}'` + if [ "http" = "`echo \$VALUE|awk -F: '{print \$1}'`" ]; then + #NOTE needs FT retry code to scale + #NOTE: should prob have max count + FILENAME=`echo \$VALUE|awk -F/ '{print \$NF}'` + + MAXTRIES=5 + ITER=0 + while [ ! -r "\$FILENAME" ]; do + ([ "\$xcatdebugmode" = "1" ] || [ "\$xcatdebugmode" = "2" ]) && logger -t xcat -p debug "downloading \$VALUE..." + echo Getting \$VALUE... + if ! /usr/bin/wget \$VALUE; then + ([ "\$xcatdebugmode" = "1" ] || [ "\$xcatdebugmode" = "2" ]) && logger -t xcat -p debug "downloading \$VALUE failed,retrying..." + ST=`expr \$RANDOM % 5` + sleep \$ST + rm -f \$FILENAME + ITER=\$(expr \$ITER + 1 ) + if [ "\$ITER" = "\$MAXTRIES" ]; then + /bin/busybox telnetd -l /bin/sh + shell + fi + fi + done + fi + if [ "nfs" = "`echo \$VALUE|awk -F: '{print \$1}'`" ]; then + NFS=1 + SERVER=`echo \$VALUE|awk -F/ '{print \$3}'` + ROOTDIR=`echo \$VALUE|awk -F/ '{for(i=4;i<=NF;i++) printf "/%s",\$i}'` + fi + # for NFS root + elif [ "\$KEY" = 'NFSROOT' ]; then + NFSROOT=1 + VALUE=`echo \$i |awk -F= '{print \$2}'` + SERVER=`echo \$VALUE|awk -F: '{print \$1}'` + ROOTDIR=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'` + elif [ "\$KEY" = 'STATEMNT' ]; then + STATELITE=1 + VALUE=`echo \$i |awk -F= '{print \$2}'` + # the VALUE may be null + if [ ! -z "\$VALUE" ]; then + SNAPSHOTSERVER=`echo \$VALUE|awk -F: '{print \$1}'` + SNAPSHOTROOT=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'` + # may be that there is not server and just a directory. + if [ -z "\$SNAPSHOTROOT" ]; then + SNAPSHOTROOT=\$SNAPSHOTSERVER + SNAPSHOTSERVER= fi - fi - done - fi - if [ "nfs" == "`echo \$VALUE|awk -F: '{print \$1}'`" ]; then - NFS=1 - SERVER=`echo \$VALUE|awk -F/ '{print \$3}'` - ROOTDIR=`echo \$VALUE|awk -F/ '{for(i=4;i<=NF;i++) printf "/%s",\$i}'` - fi - # for NFS root - elif [ "\$KEY" == 'NFSROOT' ]; then - NFSROOT=1 - VALUE=`echo \$i |awk -F= '{print \$2}'` - SERVER=`echo \$VALUE|awk -F: '{print \$1}'` - ROOTDIR=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'` - elif [ "\$KEY" == 'STATEMNT' ]; then - STATELITE=1 - VALUE=`echo \$i |awk -F= '{print \$2}'` - # the VALUE may be null - if [ ! -z \$VALUE ]; then - SNAPSHOTSERVER=`echo \$VALUE|awk -F: '{print \$1}'` - SNAPSHOTROOT=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'` - # may be that there is not server and just a directory. - if [ -z \$SNAPSHOTROOT ] - then - SNAPSHOTROOT=\$SNAPSHOTSERVER - SNAPSHOTSERVER= - fi + fi fi - fi done # show xCAT logo @@ -1282,12 +1293,12 @@ if [ "\$STATELITE" = "1" ]; then else # for statelite mode on top of the ramdisk EOMS - print $inifile "if [ -r /rootimg-statelite.gz ]; then\n"; - print $inifile "echo Setting up RAM-root tmpfs.\n"; + print $inifile " if [ -r /rootimg-statelite.gz ]; then\n"; + print $inifile " echo Setting up RAM-root tmpfs.\n"; if ($rootlimit) { - print $inifile " mount -o \"size=$rootlimit,mode=755\" -t tmpfs rootfs \$NEWROOT \n"; + print $inifile " mount -o \"size=$rootlimit,mode=755\" -t tmpfs rootfs \$NEWROOT \n"; } else { - print $inifile " mount -o mode=755 -t tmpfs rootfs \$NEWROOT\n"; + print $inifile " mount -o mode=755 -t tmpfs rootfs \$NEWROOT\n"; } print $inifile < Date: Thu, 16 Jun 2016 03:47:51 -0400 Subject: [PATCH 118/310] issue1308 lsdef and Rest API issues with regex on nicks --- perl-xCAT/xCAT/DBobjUtils.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/perl-xCAT/xCAT/DBobjUtils.pm b/perl-xCAT/xCAT/DBobjUtils.pm index f71625898..780f5fbcc 100755 --- a/perl-xCAT/xCAT/DBobjUtils.pm +++ b/perl-xCAT/xCAT/DBobjUtils.pm @@ -2458,6 +2458,10 @@ sub expandnicsattr() # Value: eth0!1.1.1.1|2.1.1.1,eth1!3.1.1.1|4.1.1.1 my $nicval=$2; + #In the lsdef, remove the ^| and |$ before displaying + $nicval=~s/(^\||\|$)//g; + + # $nicarr[0]: eth0!1.1.1.1|2.1.1.1 # $nicarr[1]: eth1!3.1.1.1|4.1.1.1 my @nicarr = split(/,/, $nicval); From 66b81e7a0a27cc6bd7209642925cc1c6a41c7999 Mon Sep 17 00:00:00 2001 From: wangxiaopeng Date: Mon, 2 May 2016 05:09:22 -0400 Subject: [PATCH 119/310] bug 1017: make a sleep before retrying too much when xcatd trys to read the request data from an xcatd client, if there are too many retry, sleep for a while before retrying too much. --- xCAT-server/sbin/xcatd | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/xCAT-server/sbin/xcatd b/xCAT-server/sbin/xcatd index 2a6ee47cc..9a9b0a745 100644 --- a/xCAT-server/sbin/xcatd +++ b/xCAT-server/sbin/xcatd @@ -2465,23 +2465,41 @@ sub get_request { my $sock = shift; my $encode = shift; my $request = shift; + if ($encode eq "xml") { - my $line = $request; + my $readtry = 0; while ((!$request) || ($request !~ m/<\/xcatrequest>/)) { + if ($readtry > 10) { + # if retry too much, sleep for a while and try again + # otherwise it will use too much cpu + sleep 1; + $readtry = 0; + } my $flags=fcntl($sock,F_GETFL,0); $flags |= O_NONBLOCK; # we want sysread to bail on us, select seems to be evil to us still.. fcntl($sock,F_SETFL,$flags); my $bytesread; - if (!($line) ) { $line = ''; } + my $line = ''; do { $bytesread=sysread($sock,$line,65536,length($line)) } while ($bytesread); if (length($line)==0) { - if (not defined $bytesread and ($! == EAGAIN or $! == ECHILD)) { next; } # ECHILD makes no sense, but some platform does it + if (not defined $bytesread and ($! == EAGAIN or $! == ECHILD)) { + # retry when an error happens + # ECHILD makes no sense, but some platform does it + $readtry++; + next; + } return undef; } $flags=fcntl($sock,F_GETFL,0); $flags &= ~O_NONBLOCK; # now we want *print* to be blocking IO fcntl($sock,F_SETFL,$flags); - $request = $line; + $request .= $line; + + # check the validity of the request message + if ($request and length($request) > 15 and ($request !~ m//)) { + xCAT::MsgUtils->message("S", "xcatd: Close an invalid connection."); + return undef; + } } return eval { XMLin($request, SuppressEmpty=>undef,ForceArray=>1) }; } elsif ($encode eq "storable") { From 6f0083dd8e01e0fcdfecd9c1da80cf04ae48e242 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Thu, 16 Jun 2016 11:44:08 +0800 Subject: [PATCH 120/310] A tool to install xCAT automatically --- xCAT-server/share/xcat/tools/go-xcat | 946 +++++++++++++++++++++++++++ 1 file changed, 946 insertions(+) create mode 100755 xCAT-server/share/xcat/tools/go-xcat diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat new file mode 100755 index 000000000..69077f5cf --- /dev/null +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -0,0 +1,946 @@ +#!/bin/bash + +function usage() +{ + local script="${0##*/}" + + while read ; do echo "${REPLY}" ; done <<-EOF + Usage: ${script} [--install] + + Options: + --help display this help and exit + --install installs all the latest versions from the + repository + --xcat-version=[VERSION] specify the version of xCAT + -y, --yes answer yes for all questions + + Examples: + + ${script} + ${script} --install + ${script} --install --yes + ${script} --install --xcat-version=2.12 --yes + EOF +} + +PATH="/usr/sbin:/usr/bin:/sbin:/bin" +export PATH + +# +# warn_if_bad Put out warning message(s) if $1 has bad RC. +# +# $1 0 (pass) or non-zero (fail). +# $2+ Remaining arguments printed only if the $1 is non-zero. +# +# Incoming $1 is returned unless it is 0 +# +function warn_if_bad() +{ + local -i rc="$1" + local script="${0##*/}" + + # Ignore if no problems + [ "${rc}" -eq "0" ] && return 0 + + # Broken + shift + echo "${script}: $@" >&2 + return "${rc}" +} + +# +# exit_if_bad Put out error message(s) if $1 has bad RC. +# +# $1 0 (pass) or non-zero (fail). +# $2+ Remaining arguments printed only if the $1 is non-zero. +# +# Exits with 1 unless $1 is 0 +# +function exit_if_bad() +{ + warn_if_bad "$@" || exit 1 + return 0 +} + +# +# check_root_or_exit +# +# Breaks the script if not running as root. +# +# If this returns 1, the invoker MUST abort the script. +# +# Returns 0 if running as root +# Returns 1 if not (and breaks the script) +# +function check_root_or_exit() +{ + [ "${UID}" -eq "0" ] + exit_if_bad "$?" "Must be run by UID=0. Actual UID=${UID}." + return 0 +} + +# +# check_executes Check for executable(s) +# +# Returns 0 if true. +# Returns 1 if not. +# +function check_executes() +{ + local cmd + local all_ok="yes" + for cmd in "$@" + do + if ! type "${cmd}" &>/dev/null + then + echo "Command \"${cmd}\" not found." >&2 + all_ok="no" + fi + done + [ "${all_ok}" = "yes" ] +} + +# +# check_exec_or_exit Check for required executables. +# +# Exits (not returns) if commands listed on command line do not exist. +# +# Returns 0 if true. +# Exits with 1 if not. +# +function check_exec_or_exit() +{ + check_executes "$@" + exit_if_bad "$?" "Above listed required command(s) not found." + return 0 +} + +TMP_DIR="" + +# +# internal_setup Script setup +# +# Returns 0 on success. +# Exits (not returns) with 1 on failure. +# +function internal_setup() +{ + shopt -s extglob + + # Trap exit for internal_cleanup function. + trap "internal_cleanup" EXIT + + check_exec_or_exit mktemp rm + + umask 0077 + + TMP_DIR="$(mktemp -d "/tmp/${0##*/}.XXXXXXXX" 2>/dev/null)" + [ -d "${TMP_DIR}" ] + exit_if_bad "$?" "Make temporary directory failed." + + custom_setup +} + +# +# internal_cleanup Script cleanup (reached via trap 0) +# +# Destory any temporarily facility created by internal_setup. +# +function internal_cleanup() +{ + custom_cleanup + + [ -d "${TMP_DIR}" ] && rm -rf "${TMP_DIR}" +} + +# +# custom_setup +# +function custom_setup() +{ + check_exec_or_exit awk printf sort + check_root_or_exit +} + +# +# custom_cleanup +# +function custom_cleanup() +{ + : +} + +# +# cleanup_n_exec Do the cleanup, then execute the command +# +# $1+ The command to execute +# +function cleanup_n_exec() +{ + internal_cleanup + + exec "$@" +} + +internal_setup + +# Check operating system +function check_os() +{ + case "${OSTYPE}" in + "aix"*) # AIX + echo "aix" + ;; + "darwin"*) # OS X + echo "darwin" + ;; + "linux"*) # Linux + echo "linux" + ;; + *) + # Unknown + echo "${OSTYPE}" + ;; + esac +} + +# Check instruction set architecture +function check_arch() +{ + case "${HOSTTYPE}" in + "powerpc64") + echo "ppc64" + ;; + "powerpc64le") + echo "ppc64le" + ;; + "mipsel") + echo "mips" + ;; + "i"?"86") + echo "i386" + ;; + *) + echo "${HOSTTYPE}" + ;; + esac +} + +function check_linux_distro() +{ + local distro="$(source /etc/os-release >/dev/null 2>&1 && + echo "${ID}")" + [[ -z "${distro}" ]] && [[ -f /etc/redhat-release ]] && distro="rhel" + [[ -z "${distro}" ]] && [[ -f /etc/SuSE-release ]] && distro="sles" + echo "${distro}" +} + +function check_linux_version() +{ + local ver="$(source /etc/os-release >/dev/null 2>&1 && + echo "${VERSION_ID}")" + [[ -z "${ver}" ]] && [[ -f /etc/redhat-release ]] && + ver="$(awk '{ print $(NF - 1) }' /etc/redhat-release)" + [[ -z "${ver}" ]] && [[ -f /etc/SuSE-release ]] && + ver="$(awk '/VERSION/ { print $NF }' /etc/SuSE-release)" + echo "${ver}" +} + +function function_dispatch() +{ + local base="$1" + local cmd="" + local ret="" + shift + for cmd in $(compgen -A function "${base}_") + do + "${cmd}" "$@" + ret="$?" + [[ "${ret}" -ne "255" ]] && break + done + [[ "${ret}" -ne "255" ]] + exit_if_bad "$?" "${base}: unsupported function" + return "${ret}" +} + +# $@ package names +function check_package_version_rpm() +{ + ! type rpm >/dev/null 2>&1 && return 255 + local ver="" + while read ver + do + if [[ -z "${ver}" || "${ver}" =~ not\ installed ]] + then + echo "(not installed)" + else + echo "${ver}" + fi + done < <(rpm -q --qf '%{version}-%{release}\n' "$@") + return 0 +} + +# $@ package names +function check_package_version_deb() +{ + ! type dpkg-query >/dev/null 2>&1 && return 255 + local name="" + local ver="" + while read name ver + do + name+=("${name}") + ver+=("${ver}") + done < <(dpkg-query --show '--showformat=${Package} ${Version}\n' \ + "$@" 2>/dev/null) + local -i i + while [[ -n "$1" ]] + do + for i in "${!name[@]}" + do + if [[ "$1" = "${name[i]}" ]] + then + echo "${ver[i]}" + unset "name[${i}]" "ver[${i}]" + shift && continue 2 + fi + done + echo "(not installed)" + shift + done + return 0 +} + +function check_package_version() +{ + function_dispatch "${FUNCNAME}" "$@" +} + +# $@ package names +function check_repo_version_yum() +{ + ! type repoquery >/dev/null 2>&1 && return 255 + local -a name=() + local -a ver=() + while read name ver + do + name+=("${name}") + ver+=("${ver}") + done < <(repoquery --qf '%{name} %{version}-%{release}' "$@" 2>/dev/null) + local -i i + while [[ -n "$1" ]] + do + for i in "${!name[@]}" + do + if [[ "$1" = "${name[i]}" ]] + then + echo "${ver[i]}" + unset "name[${i}]" "ver[${i}]" + shift && continue 2 + fi + done + echo "(not found)" + shift + done + return 0 +} + +# $@ package names +function check_repo_version_zypper() +{ + ! type zypper >/dev/null 2>&1 && return 255 + local -a name=() + local -a ver=() + while read name ver + do + name+=("${name}") + ver+=("${ver}") + done < <(zypper --no-gpg-checks -n search -s --match-exact "$@" \ + 2>/dev/null | awk -F ' *\\| *' '/ package / { print $2, $4 }') + local -i i + while [[ -n "$1" ]] + do + for i in "${!name[@]}" + do + if [[ "$1" = "${name[i]}" ]] + then + echo "${ver[i]}" + unset "name[${i}]" "ver[${i}]" + shift && continue 2 + fi + done + echo "(not found)" + shift + done + return 0 +} + +# $@ package names +function check_repo_version_apt() +{ + ! type apt-cache >/dev/null 2>&1 && return 255 + local name="" + local ver="" + while read name ver + do + if [[ "${name}" =~ ^[a-z] ]] + then + while [[ -n "$1" ]] + do + [[ "${name}" = "${1}:" ]] && break + echo "(not found)" + shift + done + fi + if [[ "${name}" = "Candidate:" ]] + then + echo "$ver" + shift + fi + done < <(apt-cache policy "$@" 2>/dev/null) + while [[ -n "$1" ]] + do + echo "(not found)" + shift + done + return 0 +} + +function check_repo_version() +{ + function_dispatch "${FUNCNAME}" "$@" +} + +# $1 repo_id +function get_package_list_yum() +{ + ! type repoquery >/dev/null 2>&1 && return 255 + local repo_id="$1" + [[ -z "${repo_id}" ]] && return 1 + repoquery -qa "--repoid=${repo_id}" --qf "%{name}" 2>/dev/null +} + +# $1 repo_id +function get_package_list_zypper() +{ + ! type zypper >/dev/null 2>&1 && return 255 + local repo_id="$1" + [[ -z "${repo_id}" ]] && return 1 + zypper --no-gpg-checks -n search -r "${repo_id}" 2>/dev/null | + awk -F ' *\\| *' '/ package$/ { print $2 }' +} + +# $1 repo_id +function get_package_list_apt() +{ + [[ ! -d /var/lib/apt/lists ]] && return 255 + local repo_id="$1" + [[ -z "${repo_id}" ]] && return 1 + awk '/^Package: / { print $2 }' \ + <"/var/lib/apt/lists/"*"_${repo_id}_dists"*"_main_binary-"*"_Packages" \ + 2>/dev/null +} + +# $1 repo_id +function get_package_list() +{ + function_dispatch "${FUNCNAME}" "$@" +} + +function download_file() +{ + local url="$1" + local local_file="$2" + ! type wget >/dev/null 2>&1 && return 255 + wget -q "${url}" -O "${local_file}" +} + +# $1 repo file +# $2 repo_id +function add_repo_by_file_yum() +{ + ! type yum-config-manager >/dev/null 2>&1 && return 255 + local repo_file="$1" + local repo_id="$2" + [[ -f "${repo_file}" ]] + exit_if_bad "$?" "${repo_file}: no such file" + [[ -r "${repo_file}" ]] + exit_if_bad "$?" "${repo_file}: permission denied" + [[ -n "${repo_id}" ]] + exit_if_bad "$?" "empty repo id" + [[ "${repo_id}" =~ ^[a-zA-Z][0-9a-zA-Z-]*$ ]] + exit_if_bad "$?" "${repo_id} illigal character in repo id" + local tmp_repo_file="${TMP_DIR}/${repo_id}.repo" + { + echo "[${repo_id}]" + grep -v '^\[' "${repo_file}" + } >"${tmp_repo_file}" + remove_repo_yum "${repo_id}" + yum-config-manager "--add-repo=${tmp_repo_file}" >/dev/null 2>&1 +} + +# $1 repo file +# $2 repo_id +function add_repo_by_file_zypper() +{ + ! type zypper >/dev/null 2>&1 && return 255 + local repo_file="$1" + local repo_id="$2" + [[ -f "${repo_file}" ]] + exit_if_bad "$?" "${repo_file}: no such file" + [[ -r "${repo_file}" ]] + exit_if_bad "$?" "${repo_file}: permission denied" + [[ -n "${repo_id}" ]] + exit_if_bad "$?" "empty repo id" + [[ "${repo_id}" =~ ^[a-zA-Z][0-9a-zA-Z-]*$ ]] + exit_if_bad "$?" "${repo_id} illigal character in repo id" + local tmp_repo_file="${TMP_DIR}/${repo_id}.repo" + { + echo "[${repo_id}]" + grep -v '^\[' "${repo_file}" + } >"${tmp_repo_file}" + remove_repo_zypper "${repo_id}" + zypper addrepo "${tmp_repo_file}" >/dev/null 2>&1 +} + +# $1 repo file +# $2 repo_id +function add_repo_by_file_apt() +{ + [[ -d /etc/apt/sources.list.d/ ]] || return 255 + local repo_file="$1" + local repo_id="$2" + [[ -f "${repo_file}" ]] + exit_if_bad "$?" "${repo_file}: no such file" + [[ -r "${repo_file}" ]] + exit_if_bad "$?" "${repo_file}: permission denied" + [[ -n "${repo_id}" ]] + exit_if_bad "$?" "empty repo id" + [[ "${repo_id}" =~ ^[a-zA-Z][0-9a-zA-Z-]*$ ]] + exit_if_bad "$?" "${repo_id} illigal character in repo id" + cp "${repo_file}" "/etc/apt/sources.list.d/${repo_id}.list" +} + +function add_repo_by_file() +{ + function_dispatch "${FUNCNAME}" "$@" +} + +# $1 base url +# $2 repo_id +function add_repo_by_url_yum_or_zypper() +{ + local base_url="$1" + local repo_id="$2" + local tmp_repo_file="${TMP_DIR}/tmp_repo_file" + while read ; do echo "${REPLY}" ; done >"${tmp_repo_file}" <<-EOF + [${repo_id}] + name=${repo_id} + baseurl=${base_url} + enabled=1 + gpgcheck=0 + EOF + add_repo_by_file "${tmp_repo_file}" "${repo_id}" +} + +# $1 base url +# $2 repo_id +function add_repo_by_url_apt() +{ + [[ -d /etc/apt/sources.list.d/ ]] || return 255 + local base_url="$1" + local repo_id="$2" + local codename="$(source /etc/lsb-release && echo "${DISTRIB_CODENAME}")" + [[ -n "${codename}" ]] + exit_if_bad "$?" "unknown debian/ubuntu codename" + local tmp_repo_file="${TMP_DIR}/tmp_repo_file" + echo "deb ${base_url} ${codename} main" >"${tmp_repo_file}" + add_repo_by_file_apt "${tmp_repo_file}" "${repo_id}" +} + +function add_repo_by_url() +{ + function_dispatch "${FUNCNAME}" "$@" +} + +# $1 repo_id +function remove_repo_yum() +{ + [[ -d "/etc/yum.repos.d" ]] || return 255 + local repo_id="$1" + [[ -f "/etc/yum.repos.d/${repo_id}.repo" ]] && + rm -f "/etc/yum.repos.d/${repo_id}.repo" && + yum clean metadata >/dev/null 2>&1 +} + +function remove_repo_zypper() +{ + ! type zypper >/dev/null 2>&1 && return 255 + local repo_id="$1" + zypper removerepo "${repo_id}" +} + +function remove_repo_apt() +{ + [[ -d "/etc/apt/sources.list.d" ]] || return 255 + local repo_id="$1" + rm -f "/etc/apt/sources.list.d/${repo_id}.list" +} + +function remove_repo() +{ + function_dispatch "${FUNCNAME}" "$@" +} + +# $1 version +# can be "2.10", "2.11", "2.12" or "latest" +function add_xcat_core_repo_yum_or_zypper() +{ + ! type rpm >/dev/null 2>&1 && return 255 + local ver="$1" + [[ -z "${ver}" ]] && ver="latest" + local online_repo_file="http://xcat.org/files/xcat/repos/yum/${ver}/xcat-core/xCAT-core.repo" + local tmp_repo_file="${TMP_DIR}/tmp_repo_file" + download_file "${online_repo_file}" "${tmp_repo_file}" + exit_if_bad "$?" "download xcat-core repo file failed" + add_repo_by_file "${tmp_repo_file}" "xcat-core" +} + +# $1 version +# can be "2.10", "2.11", "2.12" or "latest" +function add_xcat_core_repo_apt() +{ + [[ -d "/etc/apt/sources.list.d" ]] || return 255 + local ver="$1" + [[ -z "${ver}" ]] && ver="latest" + local apt_key_url="http://xcat.org/files/xcat/repos/apt/apt.key" + local apt_key_file="${TMP_DIR}/xcat.key" + download_file "${apt_key_url}" "${apt_key_file}" + exit_if_bad "$?" "download xcat apt key failed" + apt-key add "${apt_key_file}" >/dev/null 2>&1 + local online_repo_base_url="http://xcat.org/files/xcat/repos/apt/${ver}/xcat-core" + add_repo_by_url_apt "${online_repo_base_url}" "xcat-core" +} + +function add_xcat_core_repo() +{ + function_dispatch "${FUNCNAME}" "$@" +} + +function remove_xcat_core_repo_yum() +{ + rm -f /etc/yum.repos.d/xCAT-core.repo +} + +function add_xcat_dep_repo_yum_or_zypper() +{ + ! type rpm >/dev/null 2>&1 && return 255 + local distro="${GO_XCAT_LINUX_DISTRO}" + case "${distro}" in + "fedora") ;; + "rhel") distro="rh" ;; + "sles") ;; + *) exit_if_bad 1 "${distro}: unsupported Linux distro" + esac + local online_repo_file="http://xcat.org/files/xcat/repos/yum/xcat-dep/${distro}${GO_XCAT_LINUX_VERSION%%.*}/${GO_XCAT_ARCH}/xCAT-dep.repo" + local tmp_repo_file="${TMP_DIR}/tmp_repo_file" + download_file "${online_repo_file}" "${tmp_repo_file}" + exit_if_bad "$?" "download xcat-dep repo file failed" + add_repo_by_file "${tmp_repo_file}" "xcat-dep" +} + +function add_xcat_dep_repo_apt() +{ + ! type dpkg >/dev/null 2>&1 && return 255 + local online_repo_base_url="http://xcat.org/files/xcat/repos/apt/xcat-dep" + add_repo_by_url_apt "${online_repo_base_url}" "xcat-dep" +} + +function add_xcat_dep_repo() +{ + function_dispatch "${FUNCNAME}" "$@" +} + +function update_repo_yum() +{ + ! type yum >/dev/null 2>&1 && return 255 + yum --nogpgcheck updateinfo /dev/null 2>&1 +} + +function update_repo_zypper() +{ + ! type zypper >/dev/null 2>&1 && return 255 + zypper --gpg-auto-import-keys refresh /dev/null 2>&1 +} + +function update_repo_apt() +{ + ! type apt-get >/dev/null 2>&1 && return 255 + apt-get update /dev/null 2>&1 +} + +function update_repo() +{ + function_dispatch "${FUNCNAME}" "$@" +} + +function install_xcat_yum() +{ + ! type yum >/dev/null 2>&1 && return 255 + local -a yes=() + [[ "$1" = "-y" ]] && yes=("-y") + yum --nogpgcheck "${yes[@]}" install xCAT +} + +function install_xcat_zypper() +{ + ! type zypper >/dev/null 2>&1 && return 255 + local -a yes=() + [[ "$1" = "-y" ]] && yes=("-n") + zypper --no-gpg-checks "${yes[@]}" install xCAT +} + +function install_xcat_apt() +{ + ! type apt-get >/dev/null 2>&1 && return 255 + local -a yes=() + [[ "$1" = "-y" ]] && yes=("-y") + apt-get install "${yes[@]}" xcat +} + +function install_xcat() +{ + function_dispatch "${FUNCNAME}" "$@" +} + +GO_XCAT_CORE_PACKAGE_LIST=(perl-xCAT xCAT xCAT-SoftLayer xCAT-buildkit + xCAT-client xCAT-confluent xCAT-genesis-scripts-ppc64 + xCAT-genesis-scripts-x86_64 xCAT-server xCAT-test xCAT-vlan xCATsn) +# For Debian/Ubuntu, it need a different package list +type dpkg >/dev/null 2>&1 && +GO_XCAT_CORE_PACKAGE_LIST=(perl-xcat xcat xcat-buildkit xcat-client + xcat-confluent xcat-genesis-scripts xcat-server xcat-test xcat-vlan + xcatsn) + +GO_XCAT_DEP_PACKAGE_LIST=() + +function list_packages() +{ + GO_XCAT_CORE_PACKAGE_LIST=($( + for p in "${GO_XCAT_CORE_PACKAGE_LIST[@]}" \ + $(get_package_list xcat-core) + do + echo "${p}" + done | sort -u + )) + GO_XCAT_DEP_PACKAGE_LIST=($(get_package_list xcat-dep)) + + local -i columns="$(type tput >/dev/null 2>&1 && tput cols)" + [[ "${columns}" -lt 80 ]] && columns=80 + [[ "${columns}" -gt 90 ]] && columns=90 + local -a format=(27 25 25) + format[1]=$(( ( columns - 30 ) / 2 )) + format[2]="${format[1]}" + local pkg="" + + exec 42< <(check_package_version "${GO_XCAT_CORE_PACKAGE_LIST[@]}") + exec 43< <(check_repo_version "${GO_XCAT_CORE_PACKAGE_LIST[@]}") + + echo + echo "xCAT Core Packages" + echo "==================" + echo + + printf "%-${format[0]}s %-${format[1]}s %-${format[2]}s\n" \ + "Package Name" "Installed" "In Repository" + printf "%-${format[0]}s %-${format[1]}s %-${format[2]}s\n" \ + "------------" "---------" "-------------" + for pkg in "${GO_XCAT_CORE_PACKAGE_LIST[@]}" + do + read -u 42 i_ver + read -u 43 r_ver + printf "%-${format[0]}s %-${format[1]}s %-${format[2]}s\n" \ + "${pkg:0:${format[0]}}" \ + "${i_ver:0:${format[1]}}" \ + "${r_ver:0:${format[2]}}" + done + + exec 42<&- + exec 43<&- + + exec 42< <(check_package_version "${GO_XCAT_DEP_PACKAGE_LIST[@]}") + exec 43< <(check_repo_version "${GO_XCAT_DEP_PACKAGE_LIST[@]}") + + echo + echo "xCAT Dependency Packages" + echo "========================" + echo + + printf "%-${format[0]}s %-${format[1]}s %-${format[2]}s\n" \ + "Package Name" "Installed" "In Repository" + printf "%-${format[0]}s %-${format[1]}s %-${format[2]}s\n" \ + "------------" "---------" "-------------" + + for pkg in "${GO_XCAT_DEP_PACKAGE_LIST[@]}" + do + read -u 42 i_ver + read -u 43 r_ver + printf "%-${format[0]}s %-${format[1]}s %-${format[2]}s\n" \ + "${pkg:0:${format[0]}}" \ + "${i_ver:0:${format[1]}}" \ + "${r_ver:0:${format[2]}}" + done + + exec 42<&- + exec 43<&- +} + +GO_XCAT_METERS="" + +function show_progress_meters() +{ + ! tty -s 2>/dev/null && return 0 + # Show the progress meters + ( + declare -i length=0 + + while : + do + for bar in \ + "...... " \ + ".o..o. " \ + "oOooOo " \ + "OoUUoO " \ + "ooUUoo " \ + "oOooOo " \ + "Oo..oO " \ + "o....o " + #12345678901234567890123456789012345678901 + do + + msg="${bar}" + for (( i = 0; i < length; ++i )) + do + echo -ne "\b" + done + length=${#msg} + echo -n "${msg}" + + sleep 0.1 2>/dev/null || sleep 1 + kill -0 "$$" &>/dev/null || break 2 + done + done + ) >&2 & + GO_XCAT_METERS="$!" + disown "${GO_XCAT_METERS}" +} + +function stop_progress_meters() +{ + ! tty -s 2>/dev/null && echo -n "...... " && return 0 + kill "${GO_XCAT_METERS}" >/dev/null 2>&1 + echo -ne "\b\b\b\b\b\b " >&2 + echo -ne "...... " +} + +declare -a GO_XCAT_YES=() +GO_XCAT_ACTION="" +GO_XCAT_VERSION="latest" + +while [ "$#" -gt "0" ] +do + case "$1" in + "--help") + usage + exit 0 + ;; + "--install") + GO_XCAT_ACTION="install" + ;; + "--xcat-version="*) + GO_XCAT_VERSION="${1##--xcat-version=}" + ;; + "-y"|"--yes") + GO_XCAT_YES=("-y") + ;; + *) + [ "$1" == "--" ] && shift + ;; + esac + shift +done + +GO_XCAT_OS="$(check_os)" +GO_XCAT_ARCH="$(check_arch)" + +while read ; do echo "${REPLY}" ; done <&1)" +RET="$?" +stop_progress_meters +if [[ "${RET}" -ne 0 ]] +then + echo "failed" + echo "${ERR_MSG}" >&2 + exit "${RET}" +fi +echo "done" + +case "${GO_XCAT_ACTION}" in +"install") + install_xcat "${GO_XCAT_YES[@]}" + ;; +*) + list_packages + ;; +esac + +exit 0 From 47d3c0581e239bd7c593ada3f1ca75da381e654f Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Thu, 16 Jun 2016 23:15:01 +0800 Subject: [PATCH 121/310] [go-xcat] Add massive logs for debugging --- xCAT-server/share/xcat/tools/go-xcat | 307 +++++++++++++++++++++------ 1 file changed, 240 insertions(+), 67 deletions(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index 69077f5cf..a02c5117e 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -1,11 +1,15 @@ #!/bin/bash +# +# go-xcat - Install xCAT automatically. +# function usage() { local script="${0##*/}" while read ; do echo "${REPLY}" ; done <<-EOF - Usage: ${script} [--install] + Usage: ${script} [OPTION]... + Install xCAT automatically Options: --help display this help and exit @@ -15,7 +19,6 @@ function usage() -y, --yes answer yes for all questions Examples: - ${script} ${script} --install ${script} --install --yes @@ -23,6 +26,29 @@ function usage() EOF } +# The package list of xcat-core +GO_XCAT_CORE_PACKAGE_LIST=(perl-xCAT xCAT xCAT-SoftLayer xCAT-buildkit + xCAT-client xCAT-confluent xCAT-genesis-scripts-ppc64 + xCAT-genesis-scripts-x86_64 xCAT-server xCAT-test xCAT-vlan xCATsn) +# For Debian/Ubuntu, it will need a sight different package list +type dpkg >/dev/null 2>&1 && +GO_XCAT_CORE_PACKAGE_LIST=(perl-xcat xcat xcat-buildkit xcat-client + xcat-confluent xcat-genesis-scripts xcat-server xcat-test xcat-vlan + xcatsn) +GO_XCAT_DEP_PACKAGE_LIST=() + +# The package list of all the packages should be installed +GO_XCAT_CORE_INSTALL_LIST=(perl-xCAT xCAT xCAT-buildkit xCAT-client + xCAT-genesis-scripts-ppc64 xCAT-genesis-scripts-x86_64 xCAT-server + conserver-xcat elilo-xcat grub2-xcat ipmitool-xcat syslinux-xcat + xCAT-genesis-base-ppc64 xCAT-genesis-base-x86_64 xnba-undi yaboot-xcat) +# For Debian/Ubuntu, it will need a sight different package list +type dpkg >/dev/null 2>&1 && +GO_XCAT_CORE_INSTALL_LIST=(perl-xcat xcat xcat-buildkit xcat-client + xcat-genesis-scripts xcat-server + conserver-xcat elilo-xcat grub2-xcat ipmitool-xcat syslinux-xcat + xcat-genesis-base-amd64 xcat-genesis-base-ppc64 xnba-undi) + PATH="/usr/sbin:/usr/bin:/sbin:/bin" export PATH @@ -158,7 +184,7 @@ function internal_cleanup() # function custom_setup() { - check_exec_or_exit awk printf sort + check_exec_or_exit awk cat printf sort sleep tee check_root_or_exit } @@ -683,47 +709,41 @@ function update_repo() function_dispatch "${FUNCNAME}" "$@" } -function install_xcat_yum() +function install_packages_yum() { ! type yum >/dev/null 2>&1 && return 255 local -a yes=() - [[ "$1" = "-y" ]] && yes=("-y") - yum --nogpgcheck "${yes[@]}" install xCAT + [[ "$1" = "-y" ]] && yes=("-y") && shift + yum --nogpgcheck "${yes[@]}" install "$@" } -function install_xcat_zypper() +function install_packages_zypper() { ! type zypper >/dev/null 2>&1 && return 255 local -a yes=() - [[ "$1" = "-y" ]] && yes=("-n") - zypper --no-gpg-checks "${yes[@]}" install xCAT + [[ "$1" = "-y" ]] && yes=("-n") && shift + zypper --no-gpg-checks "${yes[@]}" install "$@" } -function install_xcat_apt() +function install_packages_apt() { ! type apt-get >/dev/null 2>&1 && return 255 local -a yes=() - [[ "$1" = "-y" ]] && yes=("-y") - apt-get install "${yes[@]}" xcat + [[ "$1" = "-y" ]] && yes=("-y") && shift + apt-get install "${yes[@]}" "$@" } -function install_xcat() +function install_packages() { function_dispatch "${FUNCNAME}" "$@" } -GO_XCAT_CORE_PACKAGE_LIST=(perl-xCAT xCAT xCAT-SoftLayer xCAT-buildkit - xCAT-client xCAT-confluent xCAT-genesis-scripts-ppc64 - xCAT-genesis-scripts-x86_64 xCAT-server xCAT-test xCAT-vlan xCATsn) -# For Debian/Ubuntu, it need a different package list -type dpkg >/dev/null 2>&1 && -GO_XCAT_CORE_PACKAGE_LIST=(perl-xcat xcat xcat-buildkit xcat-client - xcat-confluent xcat-genesis-scripts xcat-server xcat-test xcat-vlan - xcatsn) +function install_xcat() +{ + install_packages "$@" "${GO_XCAT_CORE_INSTALL_LIST[@]}" +} -GO_XCAT_DEP_PACKAGE_LIST=() - -function list_packages() +function list_xcat_packages() { GO_XCAT_CORE_PACKAGE_LIST=($( for p in "${GO_XCAT_CORE_PACKAGE_LIST[@]}" \ @@ -734,64 +754,117 @@ function list_packages() )) GO_XCAT_DEP_PACKAGE_LIST=($(get_package_list xcat-dep)) - local -i columns="$(type tput >/dev/null 2>&1 && tput cols)" - [[ "${columns}" -lt 80 ]] && columns=80 - [[ "${columns}" -gt 90 ]] && columns=90 - local -a format=(27 25 25) - format[1]=$(( ( columns - 30 ) / 2 )) - format[2]="${format[1]}" + local -i cols="$(type tput >/dev/null 2>&1 && tput cols)" + [[ "${cols}" -lt 80 ]] && cols=80 + [[ "${cols}" -gt 90 ]] && cols=90 + local -i first_col=27 + local -i second_col=$(( ( cols - 30 ) / 2 )) + local -i third_col=${second_col} local pkg="" - exec 42< <(check_package_version "${GO_XCAT_CORE_PACKAGE_LIST[@]}") - exec 43< <(check_repo_version "${GO_XCAT_CORE_PACKAGE_LIST[@]}") - echo echo "xCAT Core Packages" echo "==================" echo - printf "%-${format[0]}s %-${format[1]}s %-${format[2]}s\n" \ + printf "%-${first_col}s %-${second_col}s %-${third_col}s\n" \ "Package Name" "Installed" "In Repository" - printf "%-${format[0]}s %-${format[1]}s %-${format[2]}s\n" \ + printf "%-${first_col}s %-${second_col}s %-${third_col}s\n" \ "------------" "---------" "-------------" for pkg in "${GO_XCAT_CORE_PACKAGE_LIST[@]}" do - read -u 42 i_ver - read -u 43 r_ver - printf "%-${format[0]}s %-${format[1]}s %-${format[2]}s\n" \ - "${pkg:0:${format[0]}}" \ - "${i_ver:0:${format[1]}}" \ - "${r_ver:0:${format[2]}}" - done - - exec 42<&- - exec 43<&- - - exec 42< <(check_package_version "${GO_XCAT_DEP_PACKAGE_LIST[@]}") - exec 43< <(check_repo_version "${GO_XCAT_DEP_PACKAGE_LIST[@]}") + read i_ver && read -u 42 r_ver + printf "%-${first_col}s %-${second_col}s %-${third_col}s\n" \ + "${pkg:0:${first_col}}" \ + "${i_ver:0:${second_col}}" \ + "${r_ver:0:${third_col}}" + done < <(check_package_version "${GO_XCAT_CORE_PACKAGE_LIST[@]}") \ + 42< <(check_repo_version "${GO_XCAT_CORE_PACKAGE_LIST[@]}") echo echo "xCAT Dependency Packages" echo "========================" echo - printf "%-${format[0]}s %-${format[1]}s %-${format[2]}s\n" \ + printf "%-${first_col}s %-${second_col}s %-${third_col}s\n" \ "Package Name" "Installed" "In Repository" - printf "%-${format[0]}s %-${format[1]}s %-${format[2]}s\n" \ + printf "%-${first_col}s %-${second_col}s %-${third_col}s\n" \ "------------" "---------" "-------------" for pkg in "${GO_XCAT_DEP_PACKAGE_LIST[@]}" do - read -u 42 i_ver - read -u 43 r_ver - printf "%-${format[0]}s %-${format[1]}s %-${format[2]}s\n" \ - "${pkg:0:${format[0]}}" \ - "${i_ver:0:${format[1]}}" \ - "${r_ver:0:${format[2]}}" - done + read i_ver + read -u 42 r_ver + printf "%-${first_col}s %-${second_col}s %-${third_col}s\n" \ + "${pkg:0:${first_col}}" \ + "${i_ver:0:${second_col}}" \ + "${r_ver:0:${third_col}}" + done < <(check_package_version "${GO_XCAT_DEP_PACKAGE_LIST[@]}") \ + 42< <(check_repo_version "${GO_XCAT_DEP_PACKAGE_LIST[@]}") +} - exec 42<&- - exec 43<&- +# Test case 001 +# Check if xcatd is running +function test_case_001_xcatd() +{ + local pid_file="" + local pid="" + local -i ret=0 + for pid_file in /var/run/xcat/{installservice.pid,mainservice.pid,udpservice.pid} + do + [[ -f "${pid_file}" ]] + warn_if_bad "$?" "${pid_file} not found" + [[ "$?" -ne 0 ]] && (( ++ret )) + pid="$(<"${pid_file}")" + kill -0 "${pid}" + warn_if_bad "$?" "process ${pid} is not running" + [[ "$?" -ne 0 ]] && (( ++ret )) + done + for pid_file in /var/run/xcat/cmdlogservice.pid + do + [[ -f "${pid_file}" ]] || continue + pid="$(<"${pid_file}")" + kill -0 "${pid}" + warn_if_bad "$?" "process ${pid} is not running" + [[ "$?" -ne 0 ]] && (( ++ret )) + done + return "${ret}" +} + +# Test case 002 +# Check if command lsdef can be run +function test_case_002_lsdef() +{ + (source /etc/profile.d/xcat.sh && lsdef) +} + +# Preform basic test +function perform_smoke_test() +{ + local test_case="" + local -i ret=0 + for test_case in $(compgen -A function "test_case_") + do + "${test_case}" >"${TMP_DIR}/${test_case}.stdout" \ + 2>"${TMP_DIR}/${test_case}.stderr" + ret="$?" + if [[ "${ret}" -ne "0" || -s "${TMP_DIR}/${test_case}.stderr" ]] + then + # Something went wrong + echo "-- 8< -- -- -- -- -- -- -- -- -- -- -- -- -- -- --" + echo "==== ${test_case} failed with exit code ${ret} ====" + echo "-- 8< ${test_case} stdout -- --" + while read ; do echo "${REPLY}" ; done \ + <"${TMP_DIR}/${test_case}.stdout" + echo "-- 8< ${test_case} stderr -- --" + while read ; do echo "${REPLY}" ; done \ + <"${TMP_DIR}/${test_case}.stderr" + echo "-- 8< -- -- -- -- -- -- -- -- -- -- -- -- -- -- --" + (( ++ret )) + fi >&2 + done + [[ "${ret}" -eq "0" ]] && echo "It seems everything went well. :)" + return "${ret}" } GO_XCAT_METERS="" @@ -802,7 +875,6 @@ function show_progress_meters() # Show the progress meters ( declare -i length=0 - while : do for bar in \ @@ -816,7 +888,6 @@ function show_progress_meters() "o....o " #12345678901234567890123456789012345678901 do - msg="${bar}" for (( i = 0; i < length; ++i )) do @@ -838,10 +909,15 @@ function stop_progress_meters() { ! tty -s 2>/dev/null && echo -n "...... " && return 0 kill "${GO_XCAT_METERS}" >/dev/null 2>&1 - echo -ne "\b\b\b\b\b\b " >&2 - echo -ne "...... " + echo -ne "\b\b\b\b\b\b\b" >&2 + echo -n "...... " } +# +# |\/| _.o._ ._ .__ _ .__.._ _ _ _ _ _ |_ _ .__ +# | |(_||| | |_)|(_)(_||(_|| | | (_|(_)(/__> | |(/_|(/_ o +# | _| _| + declare -a GO_XCAT_YES=() GO_XCAT_ACTION="" GO_XCAT_VERSION="latest" @@ -849,6 +925,10 @@ GO_XCAT_VERSION="latest" while [ "$#" -gt "0" ] do case "$1" in + "--smoke-test") + perform_smoke_test + exit "$?" + ;; "--help") usage exit 0 @@ -872,7 +952,8 @@ done GO_XCAT_OS="$(check_os)" GO_XCAT_ARCH="$(check_arch)" -while read ; do echo "${REPLY}" ; done <&2 + done 2>"${TMP_DIR}/go-xcat.log.000" <&2 + done 2>"${TMP_DIR}/go-xcat.log.001" <&1 1>&42 | + tee "${TMP_DIR}/install_xcat.stderr" >&2 + exit "${PIPESTATUS[0]}" + ) 42>&1 | tee "${TMP_DIR}/install_xcat.stdout" + RET="${PIPESTATUS[0]}" + { + # Creating logs + echo "-- 8< -- -- -- -- -- -- -- -- -- -- -- -- -- -- --" + echo "==== install_xcat exited with exit code ${RET} ====" + echo "-- 8< install_xcat stdout -- --" + while read ; do echo "${REPLY}" ; done \ + <"${TMP_DIR}/install_xcat.stdout" + echo "-- 8< install_xcat stderr -- --" + while read ; do echo "${REPLY}" ; done \ + <"${TMP_DIR}/install_xcat.stderr" + echo "-- 8< -- -- -- -- -- -- -- -- -- -- -- -- -- -- --" + } >"${TMP_DIR}/go-xcat.log.005" + if [[ "${RET}" -eq "0" && ! -s "${TMP_DIR}/install_xcat.stderr" ]] + then + # xCAT has been installed and so far so good + perform_smoke_test >"${TMP_DIR}/perform_smoke_test.stdout" \ + 2>"${TMP_DIR}/perform_smoke_test.stderr" + RET="$?" + if [[ "${RET}" -ne "0" || -s "${TMP_DIR}/perform_smoke_test.stderr" ]] + then + # Smoke test failed + echo "-- 8< -- -- -- -- vv -- -- -- vv -- -- -- -- 8< --" + echo "==== perform_smoke_test failed with exit code ${RET} ====" + echo "-- 8< perform_smoke_test stdout -- --" + while read ; do echo "${REPLY}" ; done \ + <"${TMP_DIR}/perform_smoke_test.stdout" + echo "-- 8< perform_smoke_test stderr -- --" + while read ; do echo "${REPLY}" ; done \ + <"${TMP_DIR}/perform_smoke_test.stderr" + echo "-- 8< -- -- -- -- ^^ -- -- -- ^^ -- -- -- -- 8< --" + fi + fi >"${TMP_DIR}/go-xcat.log.008" + + list_xcat_packages | tee "${TMP_DIR}/go-xcat.log.099" + + if [[ "${RET}" -ne "0" ]] + then + GO_XCAT_LOG="/tmp/go-xcat.log" + cat "${TMP_DIR}/go-xcat.log."* >"${GO_XCAT_LOG}" 2>/dev/null + while read ; do echo "${REPLY}" ; done >&2 <<-EOF + + + Boo-boo + ======= + + Something went wrong. :( + + Please check log file \`${GO_XCAT_LOG}' for more details. + EOF + + exit "${RET}" + fi + + while read ; do echo "${REPLY}" ; done <<-EOF + + + Congratulations + =============== + + The fact that you got this far is a strong indication that xCAT bas been + installed correctly. + + Please notice if this is the first time you install xCAT. You need to do one + of the following. + + 1. Log out and then log in again, or + 2. run the following command to set the environment variables. + + for sh, + \`source /etc/profile.d/xcat.sh\` + or csh, + \`source /etc/profile.d/xcat.csh\` + EOF ;; *) - list_packages + list_xcat_packages ;; esac From 6eba8b92872e29aeba3932b3856c0bfe7d636bf4 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Thu, 16 Jun 2016 14:37:50 -0400 Subject: [PATCH 122/310] change syntax of /dev/null --- xCAT-server/share/xcat/install/scripts/post.debian | 2 +- xCAT-server/share/xcat/install/scripts/post.xcat | 4 ++-- xCAT/postscripts/xcatdsklspost | 10 +++++----- xCAT/postscripts/xcatinstallpost | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/xCAT-server/share/xcat/install/scripts/post.debian b/xCAT-server/share/xcat/install/scripts/post.debian index c6e0c42ca..13c45fc78 100644 --- a/xCAT-server/share/xcat/install/scripts/post.debian +++ b/xCAT-server/share/xcat/install/scripts/post.debian @@ -89,7 +89,7 @@ do mkdir -p /opt/xcat touch /opt/xcat/xcatinfo fi - grep 'XCATSERVER' /opt/xcat/xcatinfo 2>&1 > /dev/null + grep 'XCATSERVER' /opt/xcat/xcatinfo > /dev/null 2>&1 if [ $? -eq 0 ]; then sed -i "s/XCATSERVER=.*/XCATSERVER=$i/" /opt/xcat/xcatinfo else diff --git a/xCAT-server/share/xcat/install/scripts/post.xcat b/xCAT-server/share/xcat/install/scripts/post.xcat index 0c26973b1..7303b00df 100755 --- a/xCAT-server/share/xcat/install/scripts/post.xcat +++ b/xCAT-server/share/xcat/install/scripts/post.xcat @@ -48,14 +48,14 @@ if [ ! -f /opt/xcat/xcatinfo ]; then touch /opt/xcat/xcatinfo fi -grep 'XCATSERVER' /opt/xcat/xcatinfo 2>&1 > /dev/null +grep 'XCATSERVER' /opt/xcat/xcatinfo > /dev/null 2>&1 if [ $? -eq 0 ]; then sed -i "s/XCATSERVER=.*/XCATSERVER=$MASTER_IP/" /opt/xcat/xcatinfo else echo "XCATSERVER=$MASTER_IP" >> /opt/xcat/xcatinfo fi -grep 'INSTALLDIR' /opt/xcat/xcatinfo 2>&1 > /dev/null +grep 'INSTALLDIR' /opt/xcat/xcatinfo > /dev/null 2>&1 if [ $? -eq 0 ]; then sed -i "s/INSTALLDIR=.*/INSTALLDIR=$INSTALLDIR/" /opt/xcat/xcatinfo else diff --git a/xCAT/postscripts/xcatdsklspost b/xCAT/postscripts/xcatdsklspost index 28489c947..dfebd6565 100755 --- a/xCAT/postscripts/xcatdsklspost +++ b/xCAT/postscripts/xcatdsklspost @@ -322,7 +322,7 @@ if [ "$MODE" = "4" ]; then # for statelite mode if [ "$KEY" = "XCAT" ]; then TMP=`echo $i | awk -F= '{print $2}'` XCATSERVER=`echo $TMP | cut -d: -f1` - grep 'XCATSERVER' /opt/xcat/xcatinfo 2>&1 > /dev/null + grep 'XCATSERVER' /opt/xcat/xcatinfo > /dev/null 2>&1 if [ $? -eq 0 ]; then sed -i "s/XCATSERVER=.*/XCATSERVER=$XCATSERVER/" /opt/xcat/xcatinfo else @@ -365,7 +365,7 @@ else # for common mode MODE=1,2,3,5 (updatenode,moncfg,node deployment) break fi done - grep 'NODE' /opt/xcat/xcatinfo 2>&1 > /dev/null + grep 'NODE' /opt/xcat/xcatinfo > /dev/null 2>&1 if [ $? -eq 0 ]; then sed -i "s/NODE=.*/NODE=$NODE/" /opt/xcat/xcatinfo else @@ -639,7 +639,7 @@ if [ -n "$new_ms" ]; then mkdir -p /opt/xcat touch /opt/xcat/xcatinfo fi - grep 'XCATSERVER' /opt/xcat/xcatinfo 2>&1 > /dev/null + grep 'XCATSERVER' /opt/xcat/xcatinfo > /dev/null 2>&1 if [ $? -eq 0 ]; then sed -i "s/XCATSERVER=.*/XCATSERVER=$new_ms/" /opt/xcat/xcatinfo else @@ -663,7 +663,7 @@ if [ -n "$useflowcontrol" ]; then else new_fc="NO" fi - grep 'USEFLOWCONTROL' /opt/xcat/xcatinfo 2>&1 > /dev/null + grep 'USEFLOWCONTROL' /opt/xcat/xcatinfo > /dev/null 2>&1 if [ $? -eq 0 ]; then sed -i "s/USEFLOWCONTROL=.*/USEFLOWCONTROL=$new_fc/" /opt/xcat/xcatinfo else @@ -687,7 +687,7 @@ if [ "$MODE" = "1" ] || [ "$MODE" = "2" ]; then mkdir -p /opt/xcat touch /opt/xcat/xcatinfo fi - grep 'NODE' /opt/xcat/xcatinfo 2>&1 > /dev/null + grep 'NODE' /opt/xcat/xcatinfo > /dev/null 2>&1 if [ $? -eq 0 ]; then sed -i "s/NODE=.*/NODE=$NODE/" /opt/xcat/xcatinfo else diff --git a/xCAT/postscripts/xcatinstallpost b/xCAT/postscripts/xcatinstallpost index 48d495042..72ce250d5 100755 --- a/xCAT/postscripts/xcatinstallpost +++ b/xCAT/postscripts/xcatinstallpost @@ -75,7 +75,7 @@ DHCP_TMP=`sed 's/\(DHCPINTERFACES=\)\(.*\)$/\1"\2"/' /xcatpost/mypostscript.post echo "$DHCP_TMP" > /xcatpost/mypostscript.post #mark that the first reboot after installation is finished -grep 'REBOOT' /opt/xcat/xcatinfo 2>&1 > /dev/null +grep 'REBOOT' /opt/xcat/xcatinfo > /dev/null 2>&1 if [ $? -eq 0 ]; then sed -i "s/REBOOT=.*/REBOOT=TRUE/" /opt/xcat/xcatinfo else From 477bd807529af7271c6fdba7ff42736bb51623a2 Mon Sep 17 00:00:00 2001 From: frey Date: Thu, 16 Jun 2016 16:00:15 -0400 Subject: [PATCH 123/310] Altered statelite behavior w.r.t. /etc/mtab on RHEL7 distros --- xCAT-server/lib/xcat/plugins/statelite.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/statelite.pm b/xCAT-server/lib/xcat/plugins/statelite.pm index d355d9bee..48b20eba3 100644 --- a/xCAT-server/lib/xcat/plugins/statelite.pm +++ b/xCAT-server/lib/xcat/plugins/statelite.pm @@ -797,6 +797,18 @@ sub liteItem { # the /etc/mtab should be handled every time even the parent /etc/ has been handled. # if adding /etc/ to litefile, only tmpfs should be used. if ($entry[1] eq "/etc/mtab") { + # + # In RHEL7 /etc/mtab is a symlink to /proc/self/mounts and not a regular file. + # If that's the case, then we skip forcing /etc/mtab into the .statelite path + # and symlink'ing /etc/mtab to that file. Otherwise, since the OS isn't updating + # /etc/mtab commands like "df" will not be happy. + # + my $ret=`readlink $rootimg_dir/etc/mtab`; + chomp($ret); + if ($? == 0 and ($ret eq '/proc/self/mounts') ) { + $verbose && $callback->({info=>["skipping /etc/mtab (symlink to /proc/self/mounts)"]}); + next; + } $isChild = 0; } From 195f80ee6e544d500545dd00e7b9357498ba872f Mon Sep 17 00:00:00 2001 From: Kilian Cavalotti Date: Thu, 16 Jun 2016 15:12:54 -0700 Subject: [PATCH 124/310] bmcsetup: add support for Dell iDRAC Sets the BMC NIC selection to either dedicated (ipmi.bmcport=1) or shared with failover all LOMs (ipmi.bmcport=0) --- xCAT-genesis-scripts/bin/bmcsetup | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index ddef2655a..149cb2ab1 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -225,6 +225,16 @@ elif [ "$IPMIMFG" == 20301 -o "$IPMIMFG" == 19046 ] ; then fi elif [ "$IPMIMFG" == "47488" ]; then LOCKEDUSERS=1 +elif [ "$IPMIMFG" == "674" ]; then # DELL + BMCPORT=`grep bmcport /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'` + logger -s -t $log_label -p local4.info "BMCPORT is $BMCPORT" + if [ "$BMCPORT" == "0" ]; then # shared with all loms + ipmitool delloem lan set shared &>/dev/null + ipmitool delloem lan set shared with lom1 &>/dev/null + ipmitool delloem lan set shared with failover all loms &>dev/null + elif [ "$BMCPORT" == "1" ]; then # dedicated + ipmitool delloem lan set dedicated &>/dev/null + fi fi while [ -z "$LANCHAN" ]; do From 39e8480ade83e3eb321cc692ed4ceff8ccb13fdc Mon Sep 17 00:00:00 2001 From: Kilian Cavalotti Date: Thu, 16 Jun 2016 15:18:06 -0700 Subject: [PATCH 125/310] bmcsetup: remove &> bash-ism --- xCAT-genesis-scripts/bin/bmcsetup | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index 149cb2ab1..92da8215b 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -229,11 +229,11 @@ elif [ "$IPMIMFG" == "674" ]; then # DELL BMCPORT=`grep bmcport /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'` logger -s -t $log_label -p local4.info "BMCPORT is $BMCPORT" if [ "$BMCPORT" == "0" ]; then # shared with all loms - ipmitool delloem lan set shared &>/dev/null - ipmitool delloem lan set shared with lom1 &>/dev/null - ipmitool delloem lan set shared with failover all loms &>dev/null + ipmitool delloem lan set shared >/dev/null 2>&1 + ipmitool delloem lan set shared with lom1 >/dev/null 2>&1 + ipmitool delloem lan set shared with failover all loms >dev/null 2>&1 elif [ "$BMCPORT" == "1" ]; then # dedicated - ipmitool delloem lan set dedicated &>/dev/null + ipmitool delloem lan set dedicated >/dev/null 2>&1 fi fi From 8dd105afb992debb9b4aabbe1bbcbd9ff1ee9f6b Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Thu, 16 Jun 2016 22:14:48 -0400 Subject: [PATCH 126/310] implement discovery basic function --- xCAT-probe/lib/perl/probe_utils.pm | 100 +++- xCAT-probe/subcmds/discovery | 760 +++++++++++++++++++++++++++-- xCAT-probe/xcatprobe | 93 +++- 3 files changed, 897 insertions(+), 56 deletions(-) diff --git a/xCAT-probe/lib/perl/probe_utils.pm b/xCAT-probe/lib/perl/probe_utils.pm index c4ed6ddaf..e0d5b7074 100644 --- a/xCAT-probe/lib/perl/probe_utils.pm +++ b/xCAT-probe/lib/perl/probe_utils.pm @@ -5,7 +5,7 @@ package probe_utils; use strict; use File::Path; use File::Copy; - +use Socket; #----------------------------------------- =head3 @@ -341,4 +341,102 @@ sub is_dns_ready { } } +#------------------------------------------ + +=head3 + Description: + Convert host name to ip address + Arguments: + hostname: The hostname need to convert + Returns: + ip: The ip address +=cut + +#------------------------------------------ +sub get_ip_from_hostname{ + my $hostname = shift; + $hostname=shift if(($hostname) && ($hostname =~ /probe_utils/)); + my $ip = ""; + + my @output = `ping -c 1 $hostname 2>&1`; + if(!$?){ + if($output[0] =~ /^PING.+\s+\((\d+\.\d+\.\d+\.\d+)\).+/){ + $ip=$1; + } + } + return $ip; +} + +#------------------------------------------ + +=head3 + Description: + Calculate network address from ip and netmask + Arguments: + ip: ip address + mask: network mask + Returns: + network : The network address +=cut + +#------------------------------------------ +sub get_network{ + my $ip = shift; + $ip=shift if(($ip) && ($ip =~ /probe_utils/)); + my $mask = shift; + my $net=""; + + return $net if (!is_ip_addr($ip)); + return $net if ($mask !~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/); + + my $bin_mask = 0; + $bin_mask = (($1 + 0) << 24) + (($2 + 0) << 16) + (($3 + 0) << 8) + ($4 + 0) if ($mask =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/); + + my $bin_ip = 0; + $bin_ip = (($1 + 0) << 24) + (($2 + 0) << 16) + (($3 + 0) << 8) + ($4 + 0) if ($ip =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/); + + my $net_int32 = $bin_mask & $bin_ip; + $net = ($net_int32 >> 24) . "." . (($net_int32 >> 16) & 0xff) . "." . (($net_int32 >> 8) & 0xff) . "." . ($net_int32 & 0xff); + return "$net/$mask"; +} + +#------------------------------------------ + +=head3 + Description: + Convert ip to hostname + Arguments: + ip: The ip need to convert + Returns: + hostname: hostname or "" +=cut + +#------------------------------------------ +sub get_hostname_from_ip{ + my $ip = shift; + $ip=shift if(($ip) && ($ip =~ /probe_utils/)); + my $dns_server = shift; + my $hostname=""; + my $output=""; + + `which nslookup > /dev/null 2>&1`; + if(!$?){ + $output = `nslookup $ip $dns_server 2>&1`; + if (!$?) { + chomp($output); + my $rc = $hostname = `echo "$output"|awk -F" " '/name =/ {print \$4}'|awk -F"." '{print \$1}'`; + chomp($hostname); + return $hostname if (!$rc); + } + } + if(($hostname eq "") && (-e "/etc/hosts")){ + $output = `cat /etc/hosts 2>&1 |grep $ip`; + if(!$?){ + my @splitoutput = split(" ", $output); + $hostname = $splitoutput[1]; + } + } + return $hostname; +} + 1; diff --git a/xCAT-probe/subcmds/discovery b/xCAT-probe/subcmds/discovery index be50a3efd..dfae06764 100755 --- a/xCAT-probe/subcmds/discovery +++ b/xCAT-probe/subcmds/discovery @@ -6,38 +6,71 @@ BEGIN { $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/o use lib "$::XCATROOT/probe/lib/perl"; use probe_utils; use File::Basename; +use IO::Select; use Getopt::Long qw(:config no_ignore_case); +use Data::Dumper; my $program_name = basename("$0"); my $help; my $test; -my $output = "stdout"; -my $verbose = 0; -my $rst = 0; +my $output = "stdout"; +my $verbose = 0; +my $rst = 0; +my $pre_check = 0; +my $monitor = 0; +my $discovery_type; +my @valid_discovery_type = ("mtms", "switch"); +my $valid_discovery_type_str = join(",", @valid_discovery_type); +my $noderange; +my $nics; + +#used for discovery monitor +my %rawdata; +my %ipmacmap; +my $terminal = 0; +my %monitor_nodes; $::USAGE = "Usage: $program_name -h $program_name -t - $program_name [-V] - $program_name -s + $program_name -p [-V] [-T ] [-n ] + $program_name -m + $program_name [-V] [-T ] [-n ] Description: - Check discovery files or process. + Do probe for discovery process, including pro-check for required configuration and realtime monitor of discovery process. + If without any option, $program_name will do pro-check first, if all checking point pass, then goes to monitor directly. Options: - -h : Get usage information of $program_name - -t : To verify if $program_name can work, reserve option for probe framework - -V : Output more information for debug - -s : Discovery static check, check whether genesis files are ready + -h : Get usage information of $program_name. + -t : To verify if $program_name can work, reserve option for probe framework. + -V : Output more information for debug. + -p : Do pre-check for disvoery, check whether required configuration have been done ahead. + -T : The type of discovery, the valid values are $valid_discovery_type_str. + -n : The range of predefined node, must used with option -m. + -m : Do realtime monitor for discovery process. "; +#------------------------------------------ + +=head3 + Description: + Check if all genesis files are available. + Arguments: + arch: valid value are ppc64 and x86_64 + Returns: + 0 : pass + 1 : failed +=cut + +#------------------------------------------ sub check_genesis_file { - my $arch = shift; + my $arch = shift; if (($arch ne "ppc64") and ($arch ne "x86_64")) { - probe_utils->send_msg("$output", "f", "Please input correct arch type"); + probe_utils->send_msg("$output", "d", "Please input correct arch type") if ($verbose); return 1; } - + my $rst_f = 0; probe_utils->send_msg("$output", "d", "Start to check genesis files for $arch...") if ($verbose); @@ -229,14 +262,669 @@ sub check_genesis_file { return $rst_f; } +#------------------------------------------ + +=head3 + Description: + 1. check if there are dynamic range for specific networks defineded in dhcp conf file + 2. check if these specific networks have corresponding genesis configuration + Arguments: + networks: A Comma separated list of networks. Every network is combined by network address and mask(i.e. network/mask). + For example: 10.0.0.0/255.0.0.0,50.1.0.0/255.255.0.0 + Returns: + 0 : pass + 1 : failed +=cut + +#------------------------------------------ +sub dhcp_dynamic_range_check { + my $nets = shift; + my $rst = 0; + + return $rst; +} + +#------------------------------------------ + +=head3 + Description: + Handle one line log come from tftp log file + Arguments: + msg: one line tftp log + Returns: + 0 : pass + 1 : failed +=cut + +#------------------------------------------ +sub handle_tftp_msg { + my $msg = shift; + if ($msg =~ /RRQ\s+from\s+(.+)\s+filename\s+(.+)/i) { + my $ip = $1; + my $file = $2; + my $record = "Via TFTP $ip download $file"; + probe_utils->send_msg("$output", "d", "$record"); + if (exists($rawdata{"$ipmacmap{$ip}"})) { + + #push(@{$rawdata{$ipmacmap{$ip}}{"history"}}, $record) unless (/^$record$/ ~~ @{$rawdata{$ipmacmap{$ip}}{"history"}}); + push(@{ $rawdata{ $ipmacmap{$ip} }{"history"} }, $record); + } + } + return 0; +} + +#------------------------------------------ + +=head3 + Description: + Handle one line log come from http log file + Arguments: + msg: one line http log + Returns: + 0 : pass + 1 : failed +=cut + +#------------------------------------------ +sub handle_http_msg { + my $msg = shift; + if ($msg =~ /(\d+\.\d+.\d+.\d+)\s.+GET\s+(.+)\s+HTTP.+/) { + my $ip = $1; + my $file = $2; + my $record = "Via HTTP $ip download $file"; + probe_utils->send_msg("$output", "d", "$record"); + if (exists($rawdata{"$ipmacmap{$ip}"})) { + push(@{ $rawdata{ $ipmacmap{$ip} }{"history"} }, $record); + } + } + return 0; +} + +#------------------------------------------ + +=head3 + Description: + Handle one line log come from dhcp log file + Arguments: + msg: one line http log + nics: target network interfaces + Returns: + 0 : pass + 1 : failed +=cut + +#------------------------------------------ +sub handle_dhcp_msg { + my $msg = shift; + my $nics = shift; + my @nicarray = split(",", $nics); + if ($msg =~ /.+DHCPDISCOVER\s+from\s+(.+)\s+via\s+(.+)/i) { + my @tmpmsg = split(" ", $msg); + my $mac = $tmpmsg[7]; + my $nic = $tmpmsg[9]; + $nic =~ s/(.+):/$1/g if ($nic =~ /:$/); + return 0 unless (@nicarray ~~ /^$nic$/); + if ($msg =~ /no free leases/) { + probe_utils->send_msg("$output", "d", "Receive DHCPDISCOVER from $mac via $nic, no free leases"); + return 0; + } + my $record = "Receive DHCPDISCOVER from $mac via $nic"; + probe_utils->send_msg("$output", "d", "$record"); + if (!exists($rawdata{$mac})) { + my @history; + push(@history, $record); + $rawdata{$mac}{"history"} = \@history; + } else { + push(@{ $rawdata{$mac}{"history"} }, $record); + } + } elsif ($msg =~ /.+DHCPOFFER\s+on\s+(.+)\s+to\s+(.+)\s+via\s+(.+)/i) { + my $ip = $1; + my $mac = $2; + my $nic = $3; + return 0 unless (@nicarray ~~ /^$nic$/); + my $record = "Send DHCPOFFER on $ip back to $mac via $nic"; + probe_utils->send_msg("$output", "d", "$record"); + if (exists($rawdata{$mac})) { + push(@{ $rawdata{$mac}{"history"} }, $record); + } + } elsif ($msg !~ /unknown lease/ && $msg !~ /ignored/ && $msg =~ /.+DHCPREQUEST\s+for\s+(.+)\s\((.+)\)\s+from\s+(.+)\s+via\s+(.+)/) { + my $ip = $1; + my $server = $2; + my $mac = $3; + my $nic = $4; + return 0 unless (@nicarray ~~ /^$nic$/); + my $record = "Receive DHCPREQUEST from $mac for $ip via $nic"; + probe_utils->send_msg("$output", "d", "$record"); + if (exists($rawdata{$mac})) { + push(@{ $rawdata{$mac}{"history"} }, $record); + } + } elsif ($msg =~ /.+DHCPACK\s+on\s+(.+)\s+to\s+(.+)\s+via\s+(.+)/) { + my $ip = $1; + my $mac = $2; + my $nic = $3; + return 0 unless (@nicarray ~~ /^$nic$/); + my $record = "Send DHCPACK on $ip back to $mac via $nic"; + probe_utils->send_msg("$output", "d", "$record"); + if (exists($rawdata{$mac})) { + $rawdata{$mac}{"ip"} = $ip; + push(@{ $rawdata{$mac}{"history"} }, $record); + $ipmacmap{$ip} = $mac; + } + } elsif ($msg =~ /.+BOOTREQUEST\s+from\s+(.+)\s+via\s+(.+)/) { + my @tmpmsg = split(" ", $msg); + my $mac = $tmpmsg[7]; + my $nic = $tmpmsg[9]; + $nic =~ s/(.+):/$1/g if ($nic =~ /:$/); + return 0 unless (@nicarray ~~ /^$nic$/); + if ($msg =~ /no dynamic leases/) { + probe_utils->send_msg("$output", "d", "Receive DHCPDISCOVER from $mac via $nic, no dynamic leases"); + return 0; + } + my $record = "Receive BOOTREQUEST from $mac via $nic"; + probe_utils->send_msg("$output", "d", "$record"); + if (!exists($rawdata{$mac})) { + my @history; + push(@history, $record); + $rawdata{$mac}{"history"} = \@history; + } else { + push(@{ $rawdata{$mac}{"history"} }, $record); + } + } elsif ($msg =~ /.+BOOTREPLY\s+for\s+(.+)\s+to\s+.+(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w).+via\s+(.+)/) { + my $ip = $1; + my $mac = $2; + my $nic = $3; + return 0 unless (@nicarray ~~ /^$nic$/); + my $record = "Send BOOTREPLY on $ip back to $mac via $nic"; + probe_utils->send_msg("$output", "d", "$record"); + if (exists($rawdata{$mac})) { + $rawdata{$mac}{"ip"} = $ip; + push(@{ $rawdata{$mac}{"history"} }, $record); + $ipmacmap{$ip} = $mac; + } + } + return 0; +} + +#------------------------------------------ + +=head3 + Description: + Handle one line log come from computes.log + Arguments: + msg: one line compute log + Returns: + 0 : pass + 1 : failed +=cut + +#------------------------------------------ +sub handle_compute_msg { + + my $line = shift; + my $sender = ""; + my $ip = ""; + my $msg; + + my @splitline = split(" ", $line); + if (($splitline[4] =~ /^xcat/i) || ($splitline[5] =~ /^xcat/i)) { + $sender = $splitline[3]; + for (my $i = 0 ; $i < 5 ; $i++) { + shift(@splitline); + } + $msg = join(" ", @splitline); + if (!probe_utils->is_ip_addr("$sender")) { + $ip = probe_utils->get_ip_from_hostname("$sender"); + } else { + $ip = $sender; + } + if ($ip ne "" && exists($ipmacmap{$ip})) { + my $record = "Recv from $ipmacmap{$ip}($ip) : $msg"; + probe_utils->send_msg("$output", "d", "$record"); + push(@{ $rawdata{ $ipmacmap{$ip} }{"history"} }, $record); + } + } + return 0; +} + +#------------------------------------------ + +=head3 + Description: + Handle one line log come from cluster.log + Arguments: + msg: one line log + Returns: + 0 : pass + 1 : failed +=cut + +#------------------------------------------ +sub handle_cluster_msg { + my $line = shift; + my $sender = ""; + my $ip = ""; + my $msg; + + if ($line =~ /.+\d+:\d+:\d+\s+(.+)\s+(xcat.+)/i) { + $sender = $1; + $msg = $2; + if (!probe_utils->is_ip_addr("$sender")) { + $ip = probe_utils->get_ip_from_hostname("$sender"); + } else { + $ip = $sender; + } + if ($ip ne "" && exists($ipmacmap{$ip})) { + my $record = "Recv from $ipmacmap{$ip}($ip) : $msg"; + probe_utils->send_msg("$output", "d", "$record"); + push(@{ $rawdata{ $ipmacmap{$ip} }{"history"} }, $record); + } + } + return 0; +} + +#------------------------------------------ + +=head3 + Description: + Dump monitor history, categorised by mac address. + Arguments: + NULL + Returns: +=cut + +#------------------------------------------ +sub dump_history { + probe_utils->send_msg("$output", "d", "======================================="); + probe_utils->send_msg("$output", "d", "= The summary of discovery:"); + probe_utils->send_msg("$output", "d", "======================================="); + + my $masterip = `tabdump site 2>&1 | awk -F',' '/master/ { gsub(/"/, "", \$2) ; print \$2 }'`; + chomp($masterip); + foreach $mac (keys %rawdata) { + my $nodehostname = probe_utils->get_hostname_from_ip($rawdata{$mac}{"ip"}, $masterip); + if ($nodehostname ne "") { + probe_utils->send_msg("$output", "d", "[$mac ($nodehostname)]"); + } else { + probe_utils->send_msg("$output", "d", "[$mac]:"); + } + foreach my $line (@{ $rawdata{$mac}{"history"} }) { + probe_utils->send_msg("$output", "d", "| $line"); + } + } +} + +#------------------------------------------ + +=head3 + Description: + Check if all predefined node are valid + Arguments: + discovery_type: valid value are mtms and switch + noderange: node range + Returns: + 0: pass + 1: failed +=cut + +#------------------------------------------ +sub check_pre_defined_node { + my $discovery_type = shift; + my $noderange = shift; + + my $rst = 0; + my @cmdoutput; + my %nodecheckrst; + my $currentnode = ""; + + @cmdoutput = `lsdef $noderange 2>&1`; + foreach (@cmdoutput) { + if ($_ =~ /^Error: Could not find an object named '(\w+)' .+/i) { + $currentnode = $1; + $nodecheckrst{$currentnode}{"error"} = "Could not find node definition"; + $rst = 1; + } elsif ($_ =~ /^\s*Object name: (\w+)/i) { + $currentnode = $1; + } elsif ($_ =~ /^\s+(\w+)\s*=\s*(\w+)/) { + $nodecheckrst{$currentnode}{$1} = $2; + } + } + + #print Dumper(%nodecheckrst); + + foreach my $node (keys %nodecheckrst) { + if (!exists($nodecheckrst{$node}{error})) { + if ($discovery_type eq "mtms") { + if (exists($nodecheckrst{$node}{"mtm"}) && exists($nodecheckrst{$node}{"serial"})) { + $nodecheckrst{$node}{"error"} = "node definition is good for '$discovery_type' type discovery"; + } else { + $nodecheckrst{$node}{"error"} = "node definition is wrong for '$discovery_type' type discovery"; + $rst = 1; + } + } + + if ($discovery_type eq "switch") { + if (exists($nodecheckrst{$node}{"switch"}) && exists($nodecheckrst{$node}{"switchport"})) { + $nodecheckrst{$node}{"error"} = "node definition is good for '$discovery_type' type discovery"; + } else { + $nodecheckrst{$node}{"error"} = "node definition is wrong for '$discovery_type' type discovery"; + $rst = 1; + } + } + } + } + + if ($verbose) { + foreach my $node (keys %nodecheckrst) { + probe_utils->send_msg("$output", "d", "$node : $nodecheckrst{$node}{error}"); + } + } + + return $rst; +} + +#------------------------------------------ + +=head3 + Description: + Get monitor nodes list + Arguments: + One golble attribute %monitor_nodes; + Returns: +=cut + +#------------------------------------------ +sub get_monitor_nodes_list { + my @cmdoutput = `lsdef $noderange 2>&1`; + foreach (@cmdoutput) { + if ($_ =~ /^Error: Could not find an object named '(\w+)' .+/i) { + $monitor_nodes{$1} = 0; + } elsif ($_ =~ /^\s*Object name: (\w+)/i) { + $monitor_nodes{$1} = 0; + } + } +} + +#------------------------------------------ + +=head3 + Description: + Test if all nodes have finished job + Arguments: + One golble attribute %monitor_nodes; + Returns: +=cut + +#------------------------------------------ +sub all_monitor_node_done { + my $done = 1; + foreach my $node (keys %monitor_nodes) { + $done = 0 if ($monitor_nodes{$node} == 0); + } + return $done; +} + +#------------------------------------------ + +=head3 + Description: + Do pre_checking + Arguments: + nics: target network interface + if not specified, using the network which master belongs to + Returns: + 0: pass + 1: failed +=cut + +#------------------------------------------ +sub do_pre_check { + my $nics = shift; + my @nets = (); + my $rst = 0; + my $msg; + + if (defined($noderange) && defined($discovery_type)) { + $msg = "All pre_defined nodes are valid"; + my $rc = check_pre_defined_node($discovery_type, $noderange); + if ($rc) { + probe_utils->send_msg("$output", "f", $msg); + $rst = 1; + } else { + probe_utils->send_msg("$output", "o", $msg); + } + } + + + if ($nics) { + if ($nics =~ /[^\w,]/) { + probe_utils->send_msg("$output", "f", "Invalid NIC list"); + probe_utils->send_msg("$output", "d", "$::USAGE"); + exit 1; + } + + $msg = "The input network interfaces $nics exist and are configured well on current server"; + my $miss = 0; + my @nic_array = split(",", $nics); + foreach my $nic (@nic_array) { + my $tmp_nic = `ip addr show $nic >/dev/null 2>&1`; + if ($?) { + probe_utils->send_msg("$output", "d", "Network interface $nic doesn't exist on current server") if ($verbose); + $miss = 1; + } else { + my $tmp = `ifconfig $nic|awk -F" " '/inet / {print \$2,\$4}'`; + chomp($tmp); + if (!$tmp) { + probe_utils->send_msg("$output", "d", "Network interface $nic isn't set IP address") if ($verbose); + $miss = 1; + } else { + my ($ip, $mask) = split(" ", $tmp); + push(@nets, probe_utils->get_network($ip, $mask)); + } + } + } + if ($miss) { + probe_utils->send_msg("$output", "f", $msg); + $rst = 1; + } else { + probe_utils->send_msg("$output", "o", $msg); + } + } else { + $msg = "Attribute 'master' in 'site' table is configured well"; + my $masteripinsite = `tabdump site | awk -F',' '/master/ { gsub(/"/, "", \$2) ; print \$2 }'`; + chomp($masteripinsite); + if ($masteripinsite eq "") { + probe_utils->send_msg("$output", "d", "There isn't 'master' definition in 'site' talbe") if ($verbose); + probe_utils->send_msg("$output", "f", $msg); + exit 1; + } + if (!probe_utils->is_ip_addr("$masteripinsite")) { + probe_utils->send_msg("$output", "d", "The value of 'master' in 'site' table isn't a IP address") if ($verbose); + probe_utils->send_msg("$output", "f", $msg); + exit 1; + } + `ifconfig -a 2>&1 |grep $masteripinsite`; + if ($?) { + probe_utils->send_msg("$output", "d", "The IP $masteripinsite of 'master' in 'site' table dosen't belong to any network on current server") if ($verbose); + probe_utils->send_msg("$output", "f", $msg); + exit 1; + } + probe_utils->send_msg("$output", "o", $msg); + my $tmp = `ifconfig -a|awk -F" " '/$masteripinsite/ {print \$2,\$4}'`; + chomp($tmp); + my ($ip, $mask) = split(" ", $tmp); + push(@nets, probe_utils->get_network($ip, $mask)); + } + + my $arch = `uname -i`; + chomp($arch); + $msg = "Genesis files for $arch are available"; + if ($arch =~ /ppc64/i) { + if (check_genesis_file("ppc64")) { + probe_utils->send_msg("$output", "f", $msg); + $rst = 1; + } else { + probe_utils->send_msg("$output", "o", $msg); + if (check_genesis_file("x86_64")) { + probe_utils->send_msg("$output", "w", "Genesis files for x86 are not available"); + probe_utils->send_msg("$output", "i", "If don't plan to manage a x86 server, please ignore above warning"); + } else { + probe_utils->send_msg("$output", "o", "Genesis files for x86 are available"); + } + } + } elsif ($arch =~ /x86/i) { + if (check_genesis_file("x86_64")) { + probe_utils->send_msg("$output", "f", $msg); + $rst = 1; + } else { + probe_utils->send_msg("$output", "o", $msg); + if (check_genesis_file("ppc64")) { + probe_utils->send_msg("$output", "w", "Genesis files for ppc64/ppc64le are not available"); + probe_utils->send_msg("$output", "i", "If don't plan to manage a ppc64/ppc64le server, please ignore above warning"); + } else { + probe_utils->send_msg("$output", "o", "Genesis files for ppc64/ppc64le are available"); + } + } + } + + $msg = "DHCP dynamic range is configured well"; + if (dhcp_dynamic_range_check(\@nets)) { + probe_utils->send_msg("$output", "f", $msg); + $rst = 1; + } else { + probe_utils->send_msg("$output", "o", $msg); + } + + return $rst; +} + +#------------------------------------------ + +=head3 + Description: + Monitor the process of discovery + Arguments: + nics: target network interface + if not specified, using the network which master belongs to + Returns: + 0: pass + 1: failed +=cut + +#------------------------------------------ +sub do_monitor { + $SIG{TERM} = $SIG{INT} = sub { + $terminal = 1; + }; + + if ($monitor && !$pre_check && defined($noderange) && defined($discovery_type)) { + $msg = "All pre_defined nodes are valid"; + my $rc = check_pre_defined_node($discovery_type, $noderange); + if ($rc) { + probe_utils->send_msg("$output", "f", $msg); + exit 1; + } else { + probe_utils->send_msg("$output", "o", $msg); + } + } + + &get_monitor_nodes_list if (defined($noderange) && defined($discovery_type)); + + if (!$nics) { + my $masteripinsite = `tabdump site | awk -F',' '/master/ { gsub(/"/, "", \$2) ; print \$2 }'`; + chomp($masteripinsite); + $nics = `ip addr |grep -B2 $masteripinsite|awk -F" " '/mtu/{gsub(/:/,"",\$2); print \$2}'`; + chomp($nics); + if (!$nics) { + probe_utils->send_msg("$output", "f", "The value of master in site table is $masteripinsite, can't get corresponding network interface"); + exit 1; + } + } + + probe_utils->send_msg("$output", "d", "Start to capture every message during discovery process......"); + + my $varlogmsg = "/var/log/messages"; + my $clusterlog = "/var/log/xcat/cluster.log"; + my $computelog = "/var/log/xcat/computes.log"; + + my $httplog; + my $os = probe_utils->get_os(); + if ($os eq "redhat") { + $httplog = "/var/log/httpd/access_log"; + } elsif ($os eq "sles") { + $httplog = "/var/log/apache2access_log"; + } elsif ($os eq "ubuntu") { + $httplog = "/var/log/apache2/access.log"; + } + + open(VARLOGMSGFILE, "tail -f $varlogmsg 2>&1 |"); + open(CLUSTERLOGFILE, "tail -f $clusterlog 2>&1 |"); + open(HTTPLOGFILE, "tail -f $httplog 2>&1 |"); + open(COMPUTERFILE, "tail -f $computelog 2>&1 |"); + + my $select = new IO::Select; + $select->add(\*VARLOGMSGFILE); + $select->add(\*CLUSTERLOGFILE); + $select->add(\*HTTPLOGFILE); + $select->add(\*COMPUTERFILE); + $| = 1; + + my $line = ""; + my @hdls; + my $hdl; + for (; ;) { + if (@hdls = $select->can_read(0)) { + foreach $hdl (@hdls) { + if ($hdl == \*VARLOGMSGFILE) { + chomp($line = ); + my @tmp = split(/ /, $line); + if ($tmp[4] =~ /dhcpd:/i) { + handle_dhcp_msg("$line", $nics); + } elsif ($tmp[4] =~ /in.tftpd/i) { + handle_tftp_msg("$line"); + } + } elsif ($hdl == \*CLUSTERLOGFILE) { + chomp($line = ); + handle_cluster_msg("$line"); + } elsif ($hdl == \*HTTPLOGFILE) { + chomp($line = ); + handle_http_msg("$line"); + } elsif ($hdl == \*COMPUTERFILE) { + chomp($line = ); + handle_compute_msg("$line"); + } + } + } + + if ($terminal || (%monitor_nodes && all_monitor_node_done())) { + &dump_history; + close(VARLOGMSGFILE); + close(CLUSTERLOGFILE); + close(HTTPLOGFILE); + close(COMPUTERFILE); + exit 0; + } + sleep 0.01; + } + + close(VARLOGMSGFILE); + close(CLUSTERLOGFILE); + close(HTTPLOGFILE); + close(COMPUTERFILE); + return 0; +} + #------------------------------------- # main process #------------------------------------- if ( !GetOptions("--help|h|?" => \$help, - "t" => \$test, - "V" => \$verbose, - "s" => \$static)) + "t" => \$test, + "V" => \$verbose, + "m" => \$monitor, + "p" => \$pre_check, + "T=s" => \$discovery_type, + "n=s" => \$noderange, + "N=s" => \$nics)) { probe_utils->send_msg("$output", "f", "Invalid parameter for $program_name"); probe_utils->send_msg("$output", "d", "$::USAGE"); @@ -253,23 +941,37 @@ if ($help) { } if ($test) { - probe_utils->send_msg("$output", "o", "Discovery Check."); + probe_utils->send_msg("$output", "o", "Do probe for discovery process, including pro-check for required configuration and realtime monitor of discovery process.Before using this command, please install nslookup command ahead."); exit 0; } -if ($static) { - $rst = check_genesis_file("ppc64"); - if ($rst) { - probe_utils->send_msg("$output", "f", "Genesis files for ppc64/ppc64le failed."); - } else { - probe_utils->send_msg("$output", "o", "Genesis files for ppc64/ppc64le success."); - } - $rst = check_genesis_file("x86_64"); - if ($rst) { - probe_utils->send_msg("$output", "f", "Genesis files for x86_64 failed."); - } else { - probe_utils->send_msg("$output", "o", "Genesis files for x86_64 success."); +if (defined($noderange) && !defined($discovery_type)) { + probe_utils->send_msg("$output", "f", "Option '-n' must used with '-m'"); + probe_utils->send_msg("$output", "d", "$::USAGE"); + exit 1; +} + +if (defined($discovery_type)) { + unless (@valid_discovery_type ~~ /^$discovery_type$/) { + probe_utils->send_msg("$output", "f", "Invalid discovery type. the vaild types are $valid_discovery_type_str"); + probe_utils->send_msg("$output", "d", "$::USAGE"); + exit 1; } } +if ($pre_check) { + exit 1 if (do_pre_check($nics)); +} + +if ($monitor) { + $rst = do_monitor(); +} + +if (!$monitor && !$pre_check) { + $rst = do_pre_check(); + exit 1 if ($rst); + + $rst = do_monitor(); +} + exit $rst; diff --git a/xCAT-probe/xcatprobe b/xCAT-probe/xcatprobe index 99b3c4b62..c911c23a3 100755 --- a/xCAT-probe/xcatprobe +++ b/xCAT-probe/xcatprobe @@ -84,34 +84,54 @@ sub loadsubcmds { sub format_cmd_output { my $line = shift; my $nocolor = shift; - if ($line =~ /\[(\w+)\]\s*:\s*(.+)/) { - my $flag = $1; - my $msg = $2; - if ($flag =~ /failed/i) { - if ($nocolor) { - print "[FAIL] "; - } else { - print BOLD RED "[FAIL] "; + my $flag = $1; + my $msg = $2; + my @tmpmsg = split(" ", $msg); + my $maxlen = 80; + my @finalmsg = (); + my $str = ""; + foreach my $word (@tmpmsg) { + $str .= $word . " "; + if (length($str) > $maxlen) { + push @finalmsg, $str; + $str = ""; + } + } + push @finalmsg, $str if ($str ne ""); + + for (my $i = 0 ; $i < $#finalmsg + 1 ; $i++) { + if ($i ne $#finalmsg) { + print "$finalmsg[$i]\n"; + next; + } + my $space = " " x ($maxlen - length($finalmsg[$i]) + 5); + print "$finalmsg[$i]$space"; + + if ($flag =~ /failed/i) { + if ($nocolor) { + print "[FAIL]\n"; + } else { + print BOLD RED "[FAIL]\n"; + } + } elsif ($flag =~ /warning/i) { + if ($nocolor) { + print "[WARN]\n"; + } else { + print BOLD BLUE "[WARN]\n"; + } + } elsif ($flag =~ /ok/i) { + if ($nocolor) { + print "[ OK ]\n"; + } else { + print BOLD GREEN "[ OK ]\n"; + } + } elsif ($flag =~ /debug/i) { + print "\n"; + } elsif ($flag =~ /info/i) { + print "[INFO]\n"; } - } elsif ($flag =~ /warning/i) { - if ($nocolor) { - print "[WARN] "; - } else { - print BOLD BLUE "[WARN] "; - } - } elsif ($flag =~ /ok/i) { - if ($nocolor) { - print "[ OK ] "; - } else { - print BOLD GREEN "[ OK ] "; - } - } elsif ($flag =~ /debug/i) { - print " "; - } elsif ($flag =~ /info/i) { - print "[INFO] "; } - print "$msg\n"; } else { print "$line\n"; } @@ -210,10 +230,11 @@ if ($ARGV[0] eq "-l") { } if (!defined($pluginname)) { - print "There isn't sub command input from command line\n"; + print "There isn't sub command input from command line, please use '-l' to list all valid subcommand\n"; exit 0; } + for (my $i = 0 ; $i < $optnum + 1 ; $i++) { shift @tmpargv; } @@ -223,9 +244,29 @@ my $subcmd = "$plugin_dir/$pluginname $pluginattrs"; print "\nsubcmd = $subcmd\n" if ($verbose); open(PIPE, "$subcmd |"); + +my $terminal = 0; +my $subcmdpid = 0; +my @tmpoutput = `ps axjf |grep -v grep|grep -v ps|grep -v bash|grep $$`; +foreach (@tmpoutput) { + @psline = split(" ", $_); $subcmdpid = $psline[1] if (($psline[0] eq $$) && ($psline[1] ne $$) && ($psline[2] eq $$)); +} +$SIG{TERM} = $SIG{INT} = sub { + $terminal = 1; +}; + while () { chomp; format_cmd_output($_, $nocolor); + if ($terminal && $subcmdpid) { + kill 'INT', $subcmdpid; + while () { + chomp; + format_cmd_output($_, $nocolor); + } + close(PIPE); + exit $?; + } } close(PIPE); # This will set the $? properly From 705a45b6d92b8cc22805560c4e8a6e8e2b9bf6fa Mon Sep 17 00:00:00 2001 From: bybai Date: Fri, 17 Jun 2016 03:01:39 -0400 Subject: [PATCH 127/310] polish --- perl-xCAT/xCAT/DBobjUtils.pm | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/perl-xCAT/xCAT/DBobjUtils.pm b/perl-xCAT/xCAT/DBobjUtils.pm index 780f5fbcc..65843aacd 100755 --- a/perl-xCAT/xCAT/DBobjUtils.pm +++ b/perl-xCAT/xCAT/DBobjUtils.pm @@ -2458,9 +2458,22 @@ sub expandnicsattr() # Value: eth0!1.1.1.1|2.1.1.1,eth1!3.1.1.1|4.1.1.1 my $nicval=$2; - #In the lsdef, remove the ^| and |$ before displaying - $nicval=~s/(^\||\|$)//g; - + #if there is regrex in nicips + if (($nicval) && ($nicval =~ /^\|(.*?)\|$/)) { + + #$nicval Value: |node(d+)|eth0!192.1.1.($1+10)| or + # |eth0!192.1.1.($1+10),bond0!10.28.41.($1+10)| + #In the lsdef, remove the ^| and |$ before displaying + $nicval=~s/(^\||\|$)//g; + + #$nicval Value: node(d+)|eth0!192.1.1.($1+10) + if (($nicval) && ($nicval =~ /\|/)) { + my ($str1,$str2)=split('\|', $nicval); + + #$nivval Value: eth0!192.1.1.($1+10) + $nicval=$str2; + } + } # $nicarr[0]: eth0!1.1.1.1|2.1.1.1 # $nicarr[1]: eth1!3.1.1.1|4.1.1.1 From 837d81e6fad7d45553cf235c704a6dcc6ddf3927 Mon Sep 17 00:00:00 2001 From: "litingt@cn.ibm.com" Date: Fri, 17 Jun 2016 03:19:28 -0400 Subject: [PATCH 128/310] add case for defect The '/dev' file system is changed to ready-only(ro) --- .../installation/Diskless_installation_flat_p8_le | 8 ++++++++ .../installation/reg_linux_diskless_installation_flat | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/xCAT-test/autotest/testcase/installation/Diskless_installation_flat_p8_le b/xCAT-test/autotest/testcase/installation/Diskless_installation_flat_p8_le index 3ec67dfeb..07052ec7e 100644 --- a/xCAT-test/autotest/testcase/installation/Diskless_installation_flat_p8_le +++ b/xCAT-test/autotest/testcase/installation/Diskless_installation_flat_p8_le @@ -19,8 +19,16 @@ cmd:if cat /etc/*release |grep SUSE >/dev/null;then if [ ! -e /install/custom/ne check:rc==0 cmd:if cat /etc/*release |grep SUSE >/dev/null;then chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute synclists=/install/custom/netboot/sles/compute.synclist; elif cat /etc/*release |grep "Red Hat" >/dev/null;then chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute synclists=/install/custom/netboot/rh/compute.synclist;elif cat /etc/*release |grep "Ubuntu" >/dev/null; then chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute synclists=/install/custom/netboot/ubuntu/compute.synclist;fi check:rc==0 +cmd:if [ ! -d /tmp/mountoutput ]; then mkdir -p /tmp/mountoutput; fi +cmd:mount |sort > /tmp/mountoutput/file.org +cmd:cat /tmp/mountoutput/file.org cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute check:rc==0 +cmd:mount |sort > /tmp/mountoutput/file.new +cmd:cat /tmp/mountoutput/file.new +cmd:diff /tmp/mountoutput/file.org /tmp/mountoutput/file.new +check:rc==0 +cmd:rm -rf /tmp/mountoutput cmd:packimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute check:rc==0 cmd:chdef $$CN status= diff --git a/xCAT-test/autotest/testcase/installation/reg_linux_diskless_installation_flat b/xCAT-test/autotest/testcase/installation/reg_linux_diskless_installation_flat index f6c69169d..2f1b61b8b 100644 --- a/xCAT-test/autotest/testcase/installation/reg_linux_diskless_installation_flat +++ b/xCAT-test/autotest/testcase/installation/reg_linux_diskless_installation_flat @@ -33,8 +33,16 @@ check:rc==0 cmd:if cat /etc/*release |grep SUSE >/dev/null;then chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute synclists=/install/custom/netboot/sles/compute.synclist; elif cat /etc/*release |grep "Red Hat" >/dev/null;then chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute synclists=/install/custom/netboot/rh/compute.synclist;fi check:rc==0 +cmd:if [ ! -d /tmp/mountoutput ]; then mkdir -p /tmp/mountoutput; fi +cmd:mount |sort > /tmp/mountoutput/file.org +cmd:cat /tmp/mountoutput/file.org cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute check:rc==0 +cmd:mount |sort > /tmp/mountoutput/file.new +cmd:cat /tmp/mountoutput/file.new +cmd:diff /tmp/mountoutput/file.org /tmp/mountoutput/file.new +check:rc==0 +cmd:rm -rf /tmp/mountoutput cmd:packimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute check:rc==0 From 1df5e756de8bfde00456d2a425dda9960b1914e1 Mon Sep 17 00:00:00 2001 From: "litingt@cn.ibm.com" Date: Fri, 17 Jun 2016 05:40:12 -0400 Subject: [PATCH 129/310] adjust the sequence to power off the sn and cn --- xCAT-test/autotest/testcase/testenv/case0 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/xCAT-test/autotest/testcase/testenv/case0 b/xCAT-test/autotest/testcase/testenv/case0 index 7ecb5609f..4d482e503 100644 --- a/xCAT-test/autotest/testcase/testenv/case0 +++ b/xCAT-test/autotest/testcase/testenv/case0 @@ -1,15 +1,5 @@ start:clean_up_env description:power off service node and compute node for next test usage -cmd:rpower $$SN stat >> /tmp/snstat -cmd:if [[ ! `cat /tmp/snstat |grep -i "Not Activated"` ]]; then rpower $$SN off;fi -check:rc==0 -cmd:rm -rf /tmp/snstat -cmd:if [[ "__GETNODEATTR($$SN,mgt)__" =~ "ipmi" ]]; then sleep 1800;else sleep 180;fi -cmd:rpower $$SN stat >> /tmp/snstat -check:rc==0 -cmd:if [[ "__GETNODEATTR($$SN,arch)__" = "ppc64" ]]; then cat /tmp/snstat |grep -i "Not Activated";else cat /tmp/snstat|grep off;fi -check:rc==0 -cmd:rm -rf /tmp/snstat cmd:rpower $$CN stat >> /tmp/cnstat cmd:if [[ ! `cat /tmp/cnstat |grep -i "Not Activated"` ]]; then rpower $$CN off;fi check:rc==0 @@ -20,4 +10,14 @@ check:rc==0 cmd:if [[ "__GETNODEATTR($$CN,arch)__" = "ppc64" ]]; then cat /tmp/cnstat |grep "Not Activated";else cat /tmp/cnstat|grep off;fi check:rc==0 cmd:rm -rf /tmp/cnstat +cmd:rpower $$SN stat >> /tmp/snstat +cmd:if [[ ! `cat /tmp/snstat |grep -i "Not Activated"` ]]; then rpower $$SN off;fi +check:rc==0 +cmd:rm -rf /tmp/snstat +cmd:if [[ "__GETNODEATTR($$SN,mgt)__" =~ "ipmi" ]]; then sleep 1800;else sleep 180;fi +cmd:rpower $$SN stat >> /tmp/snstat +check:rc==0 +cmd:if [[ "__GETNODEATTR($$SN,arch)__" = "ppc64" ]]; then cat /tmp/snstat |grep -i "Not Activated";else cat /tmp/snstat|grep off;fi +check:rc==0 +cmd:rm -rf /tmp/snstat end From 65246bdc017bf2753f3de573cbb0be8e2af704b6 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Fri, 17 Jun 2016 10:35:03 -0400 Subject: [PATCH 130/310] Ignore 'File exists' error from storage pool build --- xCAT-server/lib/xcat/plugins/kvm.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index 90fe46524..5c0aee544 100755 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -234,7 +234,10 @@ sub get_storage_pool_by_url { eval { $poolobj->build(); }; if ($@) { my $error = $@; - unless ($error =~ /vgcreate.*exit status 3/ or $error =~ /pvcreate.*exit status 5/) { + # Some errors from building storage pool object are safe to ignore. + # For example, "File exists" is returned when a directory location for storage pool is already there. + # The storage pool still gets built, and the next statement to create storage pool will work. + unless ($error =~ /vgcreate.*exit status 3/ or $error =~ /pvcreate.*exit status 5/ or $error =~ /File exists/) { die $@; } } From 771a7a4a2498afd0f5ec174af09d1f9bb3c8774b Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Fri, 17 Jun 2016 16:25:18 +0800 Subject: [PATCH 131/310] [go-xcat] Some minor changes, according to comments on Gitgub. --- xCAT-server/share/xcat/tools/go-xcat | 155 +++++++++++++-------------- 1 file changed, 76 insertions(+), 79 deletions(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index a02c5117e..c8206a91d 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -8,21 +8,22 @@ function usage() local script="${0##*/}" while read ; do echo "${REPLY}" ; done <<-EOF - Usage: ${script} [OPTION]... + Usage: ${script} [OPTION]... [ACTION] Install xCAT automatically Options: --help display this help and exit - --install installs all the latest versions from the - repository --xcat-version=[VERSION] specify the version of xCAT -y, --yes answer yes for all questions + Actions: + install installs all the latest versions from the + repository Examples: ${script} - ${script} --install - ${script} --install --yes - ${script} --install --xcat-version=2.12 --yes + ${script} install + ${script} --yes install + ${script} --xcat-version=2.12 --yes install EOF } @@ -256,8 +257,8 @@ function check_linux_distro() { local distro="$(source /etc/os-release >/dev/null 2>&1 && echo "${ID}")" - [[ -z "${distro}" ]] && [[ -f /etc/redhat-release ]] && distro="rhel" - [[ -z "${distro}" ]] && [[ -f /etc/SuSE-release ]] && distro="sles" + [[ -z "${distro}" && -f /etc/redhat-release ]] && distro="rhel" + [[ -z "${distro}" && -f /etc/SuSE-release ]] && distro="sles" echo "${distro}" } @@ -265,9 +266,9 @@ function check_linux_version() { local ver="$(source /etc/os-release >/dev/null 2>&1 && echo "${VERSION_ID}")" - [[ -z "${ver}" ]] && [[ -f /etc/redhat-release ]] && + [[ -z "${ver}" && -f /etc/redhat-release ]] && ver="$(awk '{ print $(NF - 1) }' /etc/redhat-release)" - [[ -z "${ver}" ]] && [[ -f /etc/SuSE-release ]] && + [[ -z "${ver}" && -f /etc/SuSE-release ]] && ver="$(awk '/VERSION/ { print $NF }' /etc/SuSE-release)" echo "${ver}" } @@ -292,7 +293,7 @@ function function_dispatch() # $@ package names function check_package_version_rpm() { - ! type rpm >/dev/null 2>&1 && return 255 + type rpm >/dev/null 2>&1 || return 255 local ver="" while read ver do @@ -302,14 +303,14 @@ function check_package_version_rpm() else echo "${ver}" fi - done < <(rpm -q --qf '%{version}-%{release}\n' "$@") + done < <(rpm -q --qf '%{version}-%{release}\n' "$@" 2>/dev/null) return 0 } # $@ package names function check_package_version_deb() { - ! type dpkg-query >/dev/null 2>&1 && return 255 + type dpkg-query >/dev/null 2>&1 || return 255 local name="" local ver="" while read name ver @@ -344,7 +345,7 @@ function check_package_version() # $@ package names function check_repo_version_yum() { - ! type repoquery >/dev/null 2>&1 && return 255 + type repoquery >/dev/null 2>&1 || return 255 local -a name=() local -a ver=() while read name ver @@ -373,7 +374,7 @@ function check_repo_version_yum() # $@ package names function check_repo_version_zypper() { - ! type zypper >/dev/null 2>&1 && return 255 + type zypper >/dev/null 2>&1 || return 255 local -a name=() local -a ver=() while read name ver @@ -403,7 +404,7 @@ function check_repo_version_zypper() # $@ package names function check_repo_version_apt() { - ! type apt-cache >/dev/null 2>&1 && return 255 + type apt-cache >/dev/null 2>&1 || return 255 local name="" local ver="" while read name ver @@ -439,7 +440,7 @@ function check_repo_version() # $1 repo_id function get_package_list_yum() { - ! type repoquery >/dev/null 2>&1 && return 255 + type repoquery >/dev/null 2>&1 || return 255 local repo_id="$1" [[ -z "${repo_id}" ]] && return 1 repoquery -qa "--repoid=${repo_id}" --qf "%{name}" 2>/dev/null @@ -448,7 +449,7 @@ function get_package_list_yum() # $1 repo_id function get_package_list_zypper() { - ! type zypper >/dev/null 2>&1 && return 255 + type zypper >/dev/null 2>&1 || return 255 local repo_id="$1" [[ -z "${repo_id}" ]] && return 1 zypper --no-gpg-checks -n search -r "${repo_id}" 2>/dev/null | @@ -458,7 +459,7 @@ function get_package_list_zypper() # $1 repo_id function get_package_list_apt() { - [[ ! -d /var/lib/apt/lists ]] && return 255 + [[ -d /var/lib/apt/lists ]] || return 255 local repo_id="$1" [[ -z "${repo_id}" ]] && return 1 awk '/^Package: / { print $2 }' \ @@ -474,9 +475,9 @@ function get_package_list() function download_file() { + type wget >/dev/null 2>&1 || return 255 local url="$1" local local_file="$2" - ! type wget >/dev/null 2>&1 && return 255 wget -q "${url}" -O "${local_file}" } @@ -484,7 +485,7 @@ function download_file() # $2 repo_id function add_repo_by_file_yum() { - ! type yum-config-manager >/dev/null 2>&1 && return 255 + type yum-config-manager >/dev/null 2>&1 || return 255 local repo_file="$1" local repo_id="$2" [[ -f "${repo_file}" ]] @@ -508,7 +509,7 @@ function add_repo_by_file_yum() # $2 repo_id function add_repo_by_file_zypper() { - ! type zypper >/dev/null 2>&1 && return 255 + type zypper >/dev/null 2>&1 || return 255 local repo_file="$1" local repo_id="$2" [[ -f "${repo_file}" ]] @@ -575,7 +576,8 @@ function add_repo_by_url_apt() [[ -d /etc/apt/sources.list.d/ ]] || return 255 local base_url="$1" local repo_id="$2" - local codename="$(source /etc/lsb-release && echo "${DISTRIB_CODENAME}")" + local codename="$(source /etc/lsb-release >/dev/null 2>&1 && + echo "${DISTRIB_CODENAME}")" [[ -n "${codename}" ]] exit_if_bad "$?" "unknown debian/ubuntu codename" local tmp_repo_file="${TMP_DIR}/tmp_repo_file" @@ -600,7 +602,7 @@ function remove_repo_yum() function remove_repo_zypper() { - ! type zypper >/dev/null 2>&1 && return 255 + type zypper >/dev/null 2>&1 || return 255 local repo_id="$1" zypper removerepo "${repo_id}" } @@ -621,7 +623,8 @@ function remove_repo() # can be "2.10", "2.11", "2.12" or "latest" function add_xcat_core_repo_yum_or_zypper() { - ! type rpm >/dev/null 2>&1 && return 255 + type yum-config-manager >/dev/null 2>&1 || + type zypper >/dev/null 2>&1 || return 255 local ver="$1" [[ -z "${ver}" ]] && ver="latest" local online_repo_file="http://xcat.org/files/xcat/repos/yum/${ver}/xcat-core/xCAT-core.repo" @@ -652,14 +655,10 @@ function add_xcat_core_repo() function_dispatch "${FUNCNAME}" "$@" } -function remove_xcat_core_repo_yum() -{ - rm -f /etc/yum.repos.d/xCAT-core.repo -} - function add_xcat_dep_repo_yum_or_zypper() { - ! type rpm >/dev/null 2>&1 && return 255 + type yum-config-manager >/dev/null 2>&1 || + type zypper >/dev/null 2>&1 || return 255 local distro="${GO_XCAT_LINUX_DISTRO}" case "${distro}" in "fedora") ;; @@ -676,7 +675,7 @@ function add_xcat_dep_repo_yum_or_zypper() function add_xcat_dep_repo_apt() { - ! type dpkg >/dev/null 2>&1 && return 255 + [[ -d "/etc/apt/sources.list.d" ]] || return 255 local online_repo_base_url="http://xcat.org/files/xcat/repos/apt/xcat-dep" add_repo_by_url_apt "${online_repo_base_url}" "xcat-dep" } @@ -688,19 +687,19 @@ function add_xcat_dep_repo() function update_repo_yum() { - ! type yum >/dev/null 2>&1 && return 255 + type yum >/dev/null 2>&1 || return 255 yum --nogpgcheck updateinfo /dev/null 2>&1 } function update_repo_zypper() { - ! type zypper >/dev/null 2>&1 && return 255 + type zypper >/dev/null 2>&1 || return 255 zypper --gpg-auto-import-keys refresh /dev/null 2>&1 } function update_repo_apt() { - ! type apt-get >/dev/null 2>&1 && return 255 + type apt-get >/dev/null 2>&1 || return 255 apt-get update /dev/null 2>&1 } @@ -711,26 +710,26 @@ function update_repo() function install_packages_yum() { - ! type yum >/dev/null 2>&1 && return 255 - local -a yes=() - [[ "$1" = "-y" ]] && yes=("-y") && shift - yum --nogpgcheck "${yes[@]}" install "$@" + type yum >/dev/null 2>&1 || return 255 + local -a args=() + [[ "$1" = "-y" ]] && args=("-y") && shift + yum --nogpgcheck "${args[@]}" install "$@" } function install_packages_zypper() { - ! type zypper >/dev/null 2>&1 && return 255 - local -a yes=() - [[ "$1" = "-y" ]] && yes=("-n") && shift - zypper --no-gpg-checks "${yes[@]}" install "$@" + type zypper >/dev/null 2>&1 || return 255 + local -a args=() + [[ "$1" = "-y" ]] && args=("-n") && shift + zypper --no-gpg-checks "${args[@]}" install "$@" } function install_packages_apt() { - ! type apt-get >/dev/null 2>&1 && return 255 - local -a yes=() - [[ "$1" = "-y" ]] && yes=("-y") && shift - apt-get install "${yes[@]}" "$@" + type apt-get >/dev/null 2>&1 || return 255 + local -a args=() + [[ "$1" = "-y" ]] && args=("-y") && shift + apt-get install "${args[@]}" "$@" } function install_packages() @@ -757,6 +756,7 @@ function list_xcat_packages() local -i cols="$(type tput >/dev/null 2>&1 && tput cols)" [[ "${cols}" -lt 80 ]] && cols=80 [[ "${cols}" -gt 90 ]] && cols=90 + [[ -t 1 ]] || cols=90 local -i first_col=27 local -i second_col=$(( ( cols - 30 ) / 2 )) local -i third_col=${second_col} @@ -807,26 +807,18 @@ function list_xcat_packages() # Check if xcatd is running function test_case_001_xcatd() { - local pid_file="" - local pid="" + local f="" local -i ret=0 - for pid_file in /var/run/xcat/{installservice.pid,mainservice.pid,udpservice.pid} + for f in /var/run/xcat/{main,install,udp}service.pid do - [[ -f "${pid_file}" ]] - warn_if_bad "$?" "${pid_file} not found" - [[ "$?" -ne 0 ]] && (( ++ret )) - pid="$(<"${pid_file}")" - kill -0 "${pid}" - warn_if_bad "$?" "process ${pid} is not running" - [[ "$?" -ne 0 ]] && (( ++ret )) + kill -0 "$(<"${f}")" + (( ret += $? )) done - for pid_file in /var/run/xcat/cmdlogservice.pid + for f in /var/run/xcat/cmdlogservice.pid do - [[ -f "${pid_file}" ]] || continue - pid="$(<"${pid_file}")" - kill -0 "${pid}" - warn_if_bad "$?" "process ${pid} is not running" - [[ "$?" -ne 0 ]] && (( ++ret )) + [[ -f "${f}" ]] || continue + kill -0 "$(<"${f}")" + (( ret += $? )) done return "${ret}" } @@ -860,18 +852,19 @@ function perform_smoke_test() while read ; do echo "${REPLY}" ; done \ <"${TMP_DIR}/${test_case}.stderr" echo "-- 8< -- -- -- -- -- -- -- -- -- -- -- -- -- -- --" - (( ++ret )) + # skip all the remain test cases + return "${ret}" fi >&2 done - [[ "${ret}" -eq "0" ]] && echo "It seems everything went well. :)" - return "${ret}" + echo "It seems everything went well. :)" + return 0 } GO_XCAT_METERS="" function show_progress_meters() { - ! tty -s 2>/dev/null && return 0 + [[ -t 2 ]] || return 0 # Show the progress meters ( declare -i length=0 @@ -897,7 +890,7 @@ function show_progress_meters() echo -n "${msg}" sleep 0.1 2>/dev/null || sleep 1 - kill -0 "$$" &>/dev/null || break 2 + kill -0 "$$" >/dev/null 2>&1 || break 2 done done ) >&2 & @@ -907,9 +900,11 @@ function show_progress_meters() function stop_progress_meters() { - ! tty -s 2>/dev/null && echo -n "...... " && return 0 - kill "${GO_XCAT_METERS}" >/dev/null 2>&1 - echo -ne "\b\b\b\b\b\b\b" >&2 + if [[ -t 2 ]] + then + kill "${GO_XCAT_METERS}" >/dev/null 2>&1 + echo -ne "\b\b\b\b\b\b\b" >&2 + fi echo -n "...... " } @@ -925,17 +920,10 @@ GO_XCAT_VERSION="latest" while [ "$#" -gt "0" ] do case "$1" in - "--smoke-test") - perform_smoke_test - exit "$?" - ;; "--help") usage exit 0 ;; - "--install") - GO_XCAT_ACTION="install" - ;; "--xcat-version="*) GO_XCAT_VERSION="${1##--xcat-version=}" ;; @@ -944,11 +932,20 @@ do ;; *) [ "$1" == "--" ] && shift + GO_XCAT_ACTION="$1" + shift ;; esac shift done +case "${GO_XCAT_ACTION}" in +"smoke-test") + perform_smoke_test + exit "$?" + ;; +esac + GO_XCAT_OS="$(check_os)" GO_XCAT_ARCH="$(check_arch)" @@ -1114,6 +1111,6 @@ case "${GO_XCAT_ACTION}" in *) list_xcat_packages ;; -esac +esac # case "${GO_XCAT_ACTION}" in exit 0 From 231435896f7c027c1a78b2199b7621240b17c643 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Fri, 17 Jun 2016 12:46:44 -0400 Subject: [PATCH 132/310] xCAT probe subcommand to check consistency of os images on compute nodes --- xCAT-probe/subcmds/image | 239 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 239 insertions(+) create mode 100755 xCAT-probe/subcmds/image diff --git a/xCAT-probe/subcmds/image b/xCAT-probe/subcmds/image new file mode 100755 index 000000000..ad6c45fe3 --- /dev/null +++ b/xCAT-probe/subcmds/image @@ -0,0 +1,239 @@ +#! /usr/bin/perl +# IBM(c) 2016 EPL license http://www.eclipse.org/legal/epl-v10.html + +BEGIN { $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; } + +use lib "$::XCATROOT/probe/lib/perl"; +use probe_utils; +use File::Basename; +use Net::Ping; +use Getopt::Long qw(:config no_ignore_case); +use Data::Dumper; +use warnings; + +my $proname = basename("$0"); +my $help; +my $installnic; +my $test; +my $output = "stdout"; +my $verbose = 0; +my $rst = 0; + +$::USAGE = "Usage: + $proname -h + $proname -t + +Description: + Use this command to check if compute nodes have the same images installed as defines in xCAT DB. + Use this command to check if all compute nodes have the same identical installed. + +Options: + -h : Get usage information of $proname + -t : To verify if $proname can work, reserve option for probe framework + -d : To verify compute nodes have the same images installed as defines in xCAT DB. + -c : To verify compute nodes have the identical images installed. + -V : To print additional debug information. +"; + +sub returncmdoutput { + my $rst = shift; + chomp($rst); + my @lines = split("[\n\r]", $rst); + foreach my $line (@lines) { + probe_utils->send_msg("$output", "d", "$line"); + } +} + + +#------------------------------------- +# main process +#------------------------------------- +if ( + !GetOptions("--help|h" => \$help, + "t" => \$test, + "V" => \$VERBOSE, + "c" => \$CONSISTENCY_CHECK, + "d" => \$DEFINITION_CHECK)) +{ + probe_utils->send_msg("$output", "f", "Invalid parameter for $proname"); + probe_utils->send_msg("$output", "d", "$::USAGE"); + exit 1; +} + +if ($help) { + if ($output ne "stdout") { + probe_utils->send_msg("$output", "d", "$::USAGE"); + } else { + print "$::USAGE"; + } + exit 0; +} + +if ($test) { + probe_utils->send_msg("$output", "o", "Use this command to check if all compute nodes have the same images installed or if compute nodes are installed with the same image as defined on MN."); + exit 0; +} + +unless(defined($CONSISTENCY_CHECK) || defined($DEFINITION_CHECK)) { + print "At least one of -c or -d flags is required"; + exit 1; +} + +my $lsdef_cmd = `lsdef`; +chomp($lsdef_cmd); + +my @nodes = split('\(node\)', $lsdef_cmd); +@nodes = grep(s/^[\s]+|[\s]*$//g, @nodes); + +my @pingable_nodes; +my @diskless_nodes; +my $na = "N/A"; + +# First, extract diskless nodes +foreach (@nodes) { + my $lsdef_provmethod = `lsdef $_ -i provmethod -c`; + if ($lsdef_provmethod =~ /netboot/) { + push(@diskless_nodes, $_); + print "$_ is diskless\n"; + } +} +# Next, check if all diskless nodes are pingable +my $p = Net::Ping->new(); +foreach (@diskless_nodes) { + if ($p->ping($_, 2)) { + probe_utils->send_msg("$output", "o", "Pinging $_"); + push(@pingable_nodes, $_); + } + else { + probe_utils->send_msg("$output", "f", "Pinging $_"); + } + sleep(1); +} +$p->close(); + +my $defined_UUID = $na; +my %node_running_image_uuid_hash; +my %node_defined_image_uuid_hash; +my %node_running_image_name_hash; +my %node_defined_image_name_hash; + +foreach (@pingable_nodes) { + print "---- Gathering information from node $_ ----\n"; + # Next, from all pingable nodes get the IMAGENAME and IMAGEUUID entries from xcatinfo file + my $xcatinfo_image_UUID = `xdsh $_ "cat /opt/xcat/xcatinfo | grep IMAGEUUID | cut -d '=' -f 2" | cut -d ':' -f 2`; + my $xcatinfo_image_name = `xdsh $_ "cat /opt/xcat/xcatinfo | grep IMAGENAME | cut -d '=' -f 2" | cut -d ':' -f 2`; + $xcatinfo_image_UUID =~ s/'//; + $xcatinfo_image_UUID =~ s/'//; + $xcatinfo_image_UUID =~ s/ //; + $xcatinfo_image_name =~ s/'//; + $xcatinfo_image_name =~ s/'//; + $xcatinfo_image_name =~ s/ //; + chomp($xcatinfo_image_UUID); + chomp($xcatinfo_image_name); + if (length($xcatinfo_image_UUID) <= 0) { + $xcatinfo_image_UUID = $na; + } + if (length($xcatinfo_image_name) <= 0) { + $xcatinfo_image_name = $na; + } + $node_running_image_uuid_hash{$_} = $xcatinfo_image_UUID; + $node_running_image_name_hash{$_} = $xcatinfo_image_name; + print "Node $_ is running image $node_running_image_name_hash{$_} with UUID $node_running_image_uuid_hash{$_} \n" if ($VERBOSE); + + # Next, get UUID from rootimg directory xcatinfo file of the provmethod osimage + my $lsdef_provmethod = `lsdef $_ -i provmethod -c | cut -d "=" -f 2`; + chomp($lsdef_provmethod); + my $rootimagedir = $na; + if (length($lsdef_provmethod) > 0) { + $rootimagedir = `lsdef -t osimage $lsdef_provmethod -i rootimgdir -c | cut -d "=" -f 2`; + chomp($rootimagedir); + if (length($rootimagedir) > 0) { + $defined_UUID = `grep IMAGEUUID $rootimagedir/rootimg/opt/xcat/xcatinfo | cut -d "=" -f 2`; + chomp($defined_UUID); + $defined_UUID =~ s/'//; + $defined_UUID =~ s/'//; + if (length($defined_UUID) < 1) { + $defined_UUID = $na; + } + } + } + else { + $lsdef_provmethod = $na; + } + $node_defined_image_uuid_hash{$_} = $defined_UUID; + $node_defined_image_name_hash{$_} = $lsdef_provmethod; + print "Node $_ has defined image $lsdef_provmethod at $rootimagedir with UUID $defined_UUID\n" if ($VERBOSE); +} + +# Information gathering is done. Now do veification checking. + +# Probe verification step 1 - make sure all nodes are running the osimage name and imageUUID as defined on MN +if ($DEFINITION_CHECK) { + foreach (@pingable_nodes) { + my $msg; + my $status; + if (($node_running_image_name_hash{$_} eq $node_defined_image_name_hash{$_}) && + ($node_running_image_uuid_hash{$_} eq $node_defined_image_uuid_hash{$_})) { + if ($node_running_image_uuid_hash{$_} eq $na) { + $msg = "$_: Not able to determing running image name or uuid"; + $status = "f"; + } + else { + $msg = "$_: Matches running and defined image name and UUID"; + $status = "o"; + } + } + else { + $msg = "$_: Unmatched image name or image UUID.\n Defined: name = $node_defined_image_name_hash{$_}" . + " uuid = $node_defined_image_uuid_hash{$_}\n Running: name = $node_running_image_name_hash{$_}" . + " uuid = $node_running_image_uuid_hash{$_}"; + $status = "f"; + } + probe_utils->send_msg("$output", "$status", "$msg"); + } +} + +# Probe verification step 2 - make sure all nodes are running the same osimage name and imageUUID +if ($CONSISTENCY_CHECK) { + my $msg = "Undefined"; + my $status = "f"; + my $image_name_and_uuid; + my $image_uuid; + my %unique_image_hash; + + # Go throug the nodes and build a hash of key=image_name+image_uuid and value of nodename + foreach (@pingable_nodes) { + $image_name_and_uuid = $node_running_image_name_hash{$_} . ":" . $node_running_image_uuid_hash{$_}; + unless (exists $unique_image_hash{$image_name_and_uuid}) { + $unique_image_hash{$image_name_and_uuid} = $_; + } + } + + # print Dumper(\%unique_image_hash); + # If there is more then one key in the hash, nodes have multiple images. + my $number_of_keys = keys %unique_image_hash; + my @image_names = keys %unique_image_hash; + my $node_image_table; + if ($number_of_keys == 1) { + if ($image_names[0] =~ /$na/) { + $msg = "Not able to determine image name or uuid of the image installed on any compute node."; + $status = "f"; + } + else { + $msg = "All compute nodes have the same image installed: @image_names."; + $status = "o"; + } + } + else { + foreach $compute_node (keys %node_running_image_name_hash) { + # $node_image_table .= "$compute_node -- $node_running_image_name_hash{$compute_node}" . ":" . "$node_running_image_uuid_hash{$compute_node}\n" + $node_image_table .= sprintf("%-15s %-30s : %-20s\n", $compute_node, $node_running_image_name_hash{$compute_node}, $node_running_image_uuid_hash{$compute_node}); + } + $msg = "Not all compute nodes are running the same os image.\n" . $node_image_table; + $status = "f"; + } + + probe_utils->send_msg("$output", "$status", "$msg"); +} + +exit 0; From 8c112d34137fc348b95a79c9b05198c62480946f Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Fri, 17 Jun 2016 13:59:58 -0400 Subject: [PATCH 133/310] Get enabled networks from networks table --- .../lib/xcat/plugins/switchdiscover.pm | 45 ++++++++----------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/switchdiscover.pm b/xCAT-server/lib/xcat/plugins/switchdiscover.pm index 0211fe402..f9f571909 100644 --- a/xCAT-server/lib/xcat/plugins/switchdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/switchdiscover.pm @@ -867,6 +867,16 @@ sub snmp_scan { return 1; } + # handle ctrl-c + $SIG{TERM} = $SIG{INT} = sub { + #clean up the nmap processes + my $nmap_pid = `ps -ef | grep /usr/bin/nmap | grep -v grep | grep -v "sh -c" |awk '{print \$2}'`; + if ($nmap_pid) { + system("kill -9 $nmap_pid >/dev/null 2>&1"); + exit 0; + } + }; + ########################################################## #use nmap to parse the ip range and possible output from the command: # Nmap scan report for switch-10-5-22-1 (10.5.22.1) 161/udp open snmp @@ -1201,36 +1211,19 @@ sub get_ip_ranges { return \@ipranges; } - # for default, use the subnets for all the live nics on the mn - # my_nets will return all the networks defined in the networks - # table, we need to exclude disable networks here. - my $nets = xCAT::NetworkUtils->my_nets(); + # for default, use the subnets for all the enabled networks + # defined in the networks table. my $ranges=[]; my $nettab = xCAT::Table->new('networks'); - my $disable_nets=[]; if ($nettab) { - my $netents = $nettab->getAllEntries("all"); + my $netents = $nettab->getAllEntries(); foreach (@$netents) { - if ($_->{disable} =~ /1|YES|Yes|yes|Y|n/) { - push(@$disable_nets, $_->{'net'}); - if (exists($globalopt{verbose})) { - send_msg($request, 1, "network is disabled for $_->{'net'}, $_->{'mask'}"); - } - } - } - } - foreach my $net (keys %$nets) { - my $netdisabled=0; - if ($net !~ /127\.0\.0\.0/) { - my ($nt, $nm) = split (/\//, $net); - foreach (@$disable_nets) { - if ( $nt == $_) { - $netdisabled = 1; - } - } - if ($netdisabled != 1) { - push(@$ranges, $net); - } + my $net = $_->{'net'}; + my $nm = $_->{'mask'}; + my $fnm = xCAT::NetworkUtils::formatNetmask($nm, 0 , 1); + $net .="/$fnm"; + push(@$ranges, $net); + } } From 3112a006d0b607250f8313eeba7defa04198b783 Mon Sep 17 00:00:00 2001 From: Kilian Cavalotti Date: Fri, 17 Jun 2016 16:34:35 -0700 Subject: [PATCH 134/310] bmcsetup: allow to specify which port to share the BMC with it would actually make sense to reverse the logic, and keep ipmi.bmcport="0" for dedicated mode, and ipmi.bmcport="1" (or "2", "3", "4") for shared with LOM1 (or LOM2, LOM3, LOM4) modes --- xCAT-genesis-scripts/bin/bmcsetup | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index 92da8215b..247ffe80f 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -228,12 +228,12 @@ elif [ "$IPMIMFG" == "47488" ]; then elif [ "$IPMIMFG" == "674" ]; then # DELL BMCPORT=`grep bmcport /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'` logger -s -t $log_label -p local4.info "BMCPORT is $BMCPORT" - if [ "$BMCPORT" == "0" ]; then # shared with all loms - ipmitool delloem lan set shared >/dev/null 2>&1 - ipmitool delloem lan set shared with lom1 >/dev/null 2>&1 - ipmitool delloem lan set shared with failover all loms >dev/null 2>&1 - elif [ "$BMCPORT" == "1" ]; then # dedicated - ipmitool delloem lan set dedicated >/dev/null 2>&1 + if [ "$BMCPORT" == "0" ]; then # dedicated + ipmitool delloem lan set dedicated &>/dev/null + elif [ "$BMCPORT" == "1" -o "$BMCPORT" == "2" -o "$BMCPORT" == "3" -o "$BMCPORT" == "4"]; then # shared + ipmitool delloem lan set shared &>/dev/null + ipmitool delloem lan set shared with lom$BMCPORT &>/dev/null + ipmitool delloem lan set shared with failover all loms &>dev/null fi fi From 58df59a7b09b03a416962703eba4febf529b9c27 Mon Sep 17 00:00:00 2001 From: immarvin Date: Sun, 19 Jun 2016 05:14:13 -0400 Subject: [PATCH 135/310] fix issue [Customer] The postscript syncfiles does not work when enabled the xcatdebugmode for rh7.2 #1169;process the (sshd) service management in chrooted environment --- xCAT/postscripts/remoteshell | 33 ++++++++++++++++---------------- xCAT/postscripts/xcatlib.sh | 37 ++++++++++++++++++++++++++++++------ 2 files changed, 48 insertions(+), 22 deletions(-) diff --git a/xCAT/postscripts/remoteshell b/xCAT/postscripts/remoteshell index 82a3f6fab..0fb111bf7 100755 --- a/xCAT/postscripts/remoteshell +++ b/xCAT/postscripts/remoteshell @@ -460,15 +460,18 @@ logger -t xcat -p local4.info "start up sshd" if [[ $OSVER == ubuntu* || $OSVER == debian* ]] then - if [ ! -d /var/run/sshd ] - then - mkdir /var/run/sshd - chmod 0755 /var/run/sshd - /usr/sbin/sshd -f /etc/ssh/sshd_config - else - #service ssh restart - restartservice ssh + if [ ! -d /var/run/sshd ];then + #"/var/run/sshd": + #Contains the process ID of the sshd listening for connections + #(if there are several daemons running concurrently for different ports, + #this contains the process ID of the one started last). + #The content of this file is not sensitive; it can be world-read-able. + #prepare the "/var/run/sshd" for ubuntu + mkdir /var/run/sshd + chmod 0755 /var/run/sshd fi + #service ssh restart + restartservice ssh else #service sshd restart # sshd is not enabled on SLES 12 by default @@ -477,14 +480,12 @@ else restartservice sshd fi -# check whether the sshd daemon has been started successfully -# As we known that for rh7 the sshd cannot be started by systemctl in chroot mode -ps aux | grep -v grep | grep sshd - -if [ $? -ne 0 ]; then - if [ -e "/usr/sbin/sshd" ]; then - /usr/sbin/sshd - fi +#if the service restart with "service/systemctl" failed +#try to kill the process and start +if [ "$?" != "0" ];then + PIDLIST=`ps aux | grep -v grep | grep "/usr/sbin/sshd"|awk -F" " '{print $2}'|xargs` + [ -n "$PIDLIST" ] && kill 9 $PIDLIST + /usr/sbin/sshd fi kill -9 $CREDPID diff --git a/xCAT/postscripts/xcatlib.sh b/xCAT/postscripts/xcatlib.sh index fa238a852..de54c3f90 100755 --- a/xCAT/postscripts/xcatlib.sh +++ b/xCAT/postscripts/xcatlib.sh @@ -423,7 +423,15 @@ function startservice { return 127 fi - eval $cmd + #for the linux distributions with systemd support + #In the chrooted env, the system management commands(start/stop/restart) will be ignored and the return code is 0 + #need to return the proper code in the chrooted scenario + local retmsg + retmsg=`$cmd 2>&1` + retval=$? + [ "$retval" = "0" ] && (echo "$retmsg" | grep -i "Running in chroot,\s*ignoring request.*" >/dev/null 2>&1) && retval=1 + + return $retval } @@ -461,8 +469,16 @@ function stopservice { if [ -z "$cmd" ];then return 127 fi - - eval $cmd + + #for the linux distributions with systemd support + #In the chrooted env, the system management commands(start/stop/restart) will be ignored and the return code is 0 + #need to return the proper code in the chrooted scenario + local retmsg + retmsg=`$cmd 2>&1` + retval=$? + [ "$retval" = "0" ] && (echo "$retmsg" | grep -i "Running in chroot,\s*ignoring request.*" >/dev/null 2>&1) && retval=1 + + return $retval } @@ -499,7 +515,15 @@ function restartservice { return 127 fi - eval $cmd + #for the linux distributions with systemd support + #In the chrooted env, the system management commands(start/stop/restart) will be ignored and the return code is 0 + #need to return the proper code in the chrooted scenario + local retmsg + retmsg=`$cmd 2>&1` + retval=$? + [ "$retval" = "0" ] && (echo "$retmsg" | grep -i "Running in chroot,\s*ignoring request.*" >/dev/null 2>&1) && retval=1 + + return $retval } @@ -589,7 +613,7 @@ function enableservice { if [ -z "$cmd" ];then return 127 fi - + eval $cmd } @@ -628,7 +652,7 @@ function disableservice { if [ -z "$cmd" ];then return 127 fi - + eval $cmd } @@ -780,3 +804,4 @@ function msgutil_r { function msgutil { msgutil_r "" "$@" } + From f7700925dcf56b7177f98959381fdafe4d61b37d Mon Sep 17 00:00:00 2001 From: immarvin Date: Tue, 7 Jun 2016 04:38:32 -0400 Subject: [PATCH 136/310] support mkdef/lsdef --template --- .../admin-guides/references/man1/lsdef.1.rst | 47 +++++- .../admin-guides/references/man1/mkdef.1.rst | 32 +++- xCAT-client/pods/man1/lsdef.1.pod | 26 +++- xCAT-client/pods/man1/mkdef.1.pod | 20 ++- xCAT-server/lib/xcat/plugins/DBobjectdefs.pm | 144 +++++++++++++----- xCAT/templates/objects/node/cec.stanza | 12 ++ xCAT/templates/objects/node/hmc.stanza | 12 ++ xCAT/templates/objects/node/ppc64le.stanza | 18 +++ .../objects/node/ppc64lekvmguest.stanza | 17 +++ xCAT/templates/objects/node/switch.stanza | 11 ++ xCAT/templates/objects/node/x86_64.stanza | 19 +++ .../objects/node/x86_64kvmguest.stanza | 19 +++ 12 files changed, 336 insertions(+), 41 deletions(-) create mode 100644 xCAT/templates/objects/node/cec.stanza create mode 100644 xCAT/templates/objects/node/hmc.stanza create mode 100644 xCAT/templates/objects/node/ppc64le.stanza create mode 100644 xCAT/templates/objects/node/ppc64lekvmguest.stanza create mode 100644 xCAT/templates/objects/node/switch.stanza create mode 100644 xCAT/templates/objects/node/x86_64.stanza create mode 100644 xCAT/templates/objects/node/x86_64kvmguest.stanza diff --git a/docs/source/guides/admin-guides/references/man1/lsdef.1.rst b/docs/source/guides/admin-guides/references/man1/lsdef.1.rst index 2f4edb8ac..77bf058d0 100644 --- a/docs/source/guides/admin-guides/references/man1/lsdef.1.rst +++ b/docs/source/guides/admin-guides/references/man1/lsdef.1.rst @@ -26,6 +26,9 @@ SYNOPSIS [\ **-c | -**\ **-compress**\ ] [\ **-**\ **-osimage**\ ] [\ **-**\ **-nics**\ ] [[\ **-w**\ \ *attr*\ ==\ *val*\ ] [\ **-w**\ \ *attr*\ =~\ *val*\ ] ...] [\ *noderange*\ ] +\ **lsdef**\ [\ **-l | -**\ **-long**\ ] [\ **-a | -**\ **-all**\ ] [\ **-t**\ \ *object-types*\ ] [\ **-z | -**\ **-stanza**\ ] +[\ **-i**\ \ *attr-list*\ ] [\ **-**\ **-template**\ [\ *template-object-name*\ ]] + *********** DESCRIPTION @@ -33,7 +36,7 @@ DESCRIPTION This command is used to display xCAT object definitions which are stored -in the xCAT database. +in the xCAT database and xCAT object definition templates shipped in xCAT. ******* @@ -101,6 +104,12 @@ OPTIONS +\ **-**\ **-template**\ [\ *template-object-name*\ ] + + Show the object definition templates \ *template-object-name*\ shipped in xCAT. If no \ *template-object-name*\ is specified, all the object definition templates of the specified type \ **-t**\ \ *object-types*\ will be listed. Use \ **-a|-**\ **-all**\ option to list all the object definition templates. + + + \ **-**\ **-osimage**\ Show all the osimage information for the node. @@ -376,6 +385,42 @@ EXAMPLES +18. + + To list all the object definition templates shipped in xCAT. + + + .. code-block:: perl + + lsdef --template -a + + + + +19. + + To display the details of "node" object definition template "powerLEnv" shipped in xCAT. + + + .. code-block:: perl + + lsdef -t node --template powerLEnv + + + + +20. + + To list all the "node" object definition templates shipped in xCAT. + + + .. code-block:: perl + + lsdef -t node --template + + + + ***** FILES diff --git a/docs/source/guides/admin-guides/references/man1/mkdef.1.rst b/docs/source/guides/admin-guides/references/man1/mkdef.1.rst index 353da0498..83091d7f3 100644 --- a/docs/source/guides/admin-guides/references/man1/mkdef.1.rst +++ b/docs/source/guides/admin-guides/references/man1/mkdef.1.rst @@ -21,7 +21,7 @@ SYNOPSIS \ **mkdef**\ [\ **-h | -**\ **-help**\ ] [\ **-t**\ \ *object-types*\ ] -\ **mkdef**\ [\ **-V | -**\ **-verbose**\ ] [\ **-t**\ \ *object-types*\ ] [\ **-o**\ \ *object-names*\ ] [\ **-z | -**\ **-stanza**\ ] [\ **-d | -**\ **-dynamic**\ ] [\ **-f | -**\ **-force**\ ] [[\ **-w**\ \ *attr*\ ==\ *val*\ ] [\ **-w**\ \ *attr*\ =~\ *val*\ ] ...] [\ *noderange*\ ] [\ *attr*\ =\ *val*\ [\ *attr*\ =\ *val...*\ ]] [\ **-u**\ \ **provmethod**\ ={\ **install**\ | \ **netboot**\ | \ **statelite**\ } \ **profile=**\ \ *xxx*\ [\ **osvers=**\ \ *value*\ ] [\ **osarch=**\ \ *value*\ ]] +\ **mkdef**\ [\ **-V | -**\ **-verbose**\ ] [\ **-t**\ \ *object-types*\ ] [\ **-**\ **-template**\ \ *template-object-name*\ ] [\ **-o**\ \ *object-names*\ ] [\ **-z | -**\ **-stanza**\ ] [\ **-d | -**\ **-dynamic**\ ] [\ **-f | -**\ **-force**\ ] [[\ **-w**\ \ *attr*\ ==\ *val*\ ] [\ **-w**\ \ *attr*\ =~\ *val*\ ] ...] [\ *noderange*\ ] [\ *attr*\ =\ *val*\ [\ *attr*\ =\ *val...*\ ]] [\ **-u**\ \ **provmethod**\ ={\ **install**\ | \ **netboot**\ | \ **statelite**\ } \ **profile=**\ \ *xxx*\ [\ **osvers=**\ \ *value*\ ] [\ **osarch=**\ \ *value*\ ]] *********** @@ -82,6 +82,12 @@ OPTIONS +\ **-**\ **-template**\ \ *template-object-name*\ + + Name of the xCAT shipped object definition template or an existing object, from which the new object definition will be created from. The newly created object will inherit the attributes of the template definition unless the attribute is specified in the arguments of \ **mkdef**\ command. For the details of xCAT shipped object definition templates, please refer to the manpage of \ **-**\ **-template**\ option in lsdef(1)|lsdef.1. + + + \ **-V|-**\ **-verbose**\ Verbose mode. @@ -280,6 +286,30 @@ EXAMPLES +13 + + To create a PowerLE kvm node definition with the xCAT shipped template "powerLEkvm". + + + .. code-block:: perl + + mkdef -t node cn1 --template powerLEkvm ip=1.1.1.1 mac=42:3d:0a:05:27:0b vmhost=1.1.0.1 vmnics=br0 + + + + +14 + + To create a node definition from an existing node definition "cn1" + + + .. code-block:: perl + + mkdef -t node cn2 --template cn1 ip=1.1.1.2 mac=42:3d:0a:05:27:0c + + + + ***** FILES diff --git a/xCAT-client/pods/man1/lsdef.1.pod b/xCAT-client/pods/man1/lsdef.1.pod index 39093757a..70b96b4d2 100644 --- a/xCAT-client/pods/man1/lsdef.1.pod +++ b/xCAT-client/pods/man1/lsdef.1.pod @@ -11,11 +11,13 @@ B [B<-V>|B<--verbose>] [B<-l>|B<--long>] [B<-s>|B<--short>] [B<-a>|B<--al [B<-c>|B<--compress>] [B<--osimage>] [B<--nics>] [[B<-w> I==I] [B<-w> I=~I] ...] [I] +B [B<-l>|B<--long>] [B<-a>|B<--all>] [B<-t> I] [B<-z>|B<--stanza>] +[B<-i> I] [B<--template> [I]] =head1 DESCRIPTION This command is used to display xCAT object definitions which are stored -in the xCAT database. +in the xCAT database and xCAT object definition templates shipped in xCAT. =head1 OPTIONS @@ -63,6 +65,10 @@ See the "noderange" man page for details on supported formats. A set of comma delimited object names. +=item B<--template> [I] + +Show the object definition templates I shipped in xCAT. If no I is specified, all the object definition templates of the specified type B<-t> I will be listed. Use B<-a|--all> option to list all the object definition templates. + =item B<--osimage> Show all the osimage information for the node. @@ -222,6 +228,24 @@ To display the nics configuration information for node cn1. lsdef cn1 --nics +=item 18. + +To list all the object definition templates shipped in xCAT. + + lsdef --template -a + +=item 19. + +To display the details of "node" object definition template "powerLEnv" shipped in xCAT. + + lsdef -t node --template powerLEnv + +=item 20. + +To list all the "node" object definition templates shipped in xCAT. + + lsdef -t node --template + =back =head1 FILES diff --git a/xCAT-client/pods/man1/mkdef.1.pod b/xCAT-client/pods/man1/mkdef.1.pod index d7b534898..ca32b11d4 100644 --- a/xCAT-client/pods/man1/mkdef.1.pod +++ b/xCAT-client/pods/man1/mkdef.1.pod @@ -6,12 +6,12 @@ B - Use this command to create xCAT data object definitions. B [B<-h>|B<--help>] [B<-t> I] -B [B<-V>|B<--verbose>] [B<-t> I] [B<-o> I] [B<-z>|B<--stanza>] [B<-d>|B<--dynamic>] [B<-f>|B<--force>] [[B<-w> I==I] [B<-w> I=~I] ...] [I] [I=I [I=I]] [B<-u> B={B | B | B} B I [B I] [B I]] +B [B<-V>|B<--verbose>] [B<-t> I] [B<--template> I] [B<-o> I] [B<-z>|B<--stanza>] [B<-d>|B<--dynamic>] [B<-f>|B<--force>] [[B<-w> I==I] [B<-w> I=~I] ...] [I] [I=I [I=I]] [B<-u> B={B | B | B} B I [B I] [B I]] =head1 DESCRIPTION -This command is used to create xCAT object definitions which are stored in the xCAT database. If the definition already exists it will return an error message. The force option may be used to re-create a definition. In this case the old definition will be remove and the new definition will be created. +This command is used to create xCAT object definitions which are stored in the xCAT database. If the definition already exists it will return an error message. The force option may be used to re-create a definition. In this case the old definition will be remove and the new definition will be created. =head1 OPTIONS @@ -48,6 +48,10 @@ A set of comma delimited object names. A set of comma delimited object types. Use the help option to get a list of valid object types. +=item B<--template> I + +Name of the xCAT shipped object definition template or an existing object, from which the new object definition will be created from. The newly created object will inherit the attributes of the template definition unless the attribute is specified in the arguments of B command. For the details of xCAT shipped object definition templates, please refer to the manpage of B<--template> option in L. + =item B<-V|--verbose> Verbose mode. @@ -163,6 +167,18 @@ To create an osimage definition and fill in attributes automatically. mkdef redhat6img -u profile=compute provmethod=statelite +=item 13 + +To create a PowerLE kvm node definition with the xCAT shipped template "powerLEkvm". + + mkdef -t node cn1 --template powerLEkvm ip=1.1.1.1 mac=42:3d:0a:05:27:0b vmhost=1.1.0.1 vmnics=br0 + +=item 14 + +To create a node definition from an existing node definition "cn1" + + mkdef -t node cn2 --template cn1 ip=1.1.1.2 mac=42:3d:0a:05:27:0c + =back diff --git a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm index 78b771b79..915ffb9f2 100755 --- a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm +++ b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm @@ -604,20 +604,42 @@ sub processArgs return 2; } - + #it is illegal to specify no object template for "mkdef --template", + if($::command eq "mkdef" and defined $::opt_template and !$::opt_template){ + my $rsp; + $rsp->{data}->[0] = "no object definition template specified for mkdef --template!"; + xCAT::MsgUtils->message("E", $rsp, $::callback); + return 2; + } + if($::opt_template){ + #for mkdef --template , multiple template/nodes are illegal if($::opt_template =~ /,/ and $::command eq "mkdef"){ my $rsp; - $rsp->{data}->[0] = "mkdef: multiple templates specified!"; + $rsp->{data}->[0] = "Only 1 template object definition should be specified for mkdef!"; + xCAT::MsgUtils->message("E", $rsp, $::callback); + return 2; + } + + #when --template is specified, + #the piped stdin, such as "cat xx.stanza|mkdef -z -t node --template ...." is not supported + if($::filedata){ + my $rsp; + $rsp->{data}->[0] = "The file input can not be used with --template option!"; xCAT::MsgUtils->message("E", $rsp, $::callback); return 2; } } - + if (defined $::opt_template and ($::command eq "mkdef" or $::command eq "lsdef")){ + #all the xCAT shipped object definition templates are installed + #under directory /opt/xcat/share/xcat/templates/objects// my $objtmpldir="$::XCATROOT/share/xcat/templates/objects/"; - + + #the path list to search the object definition templates + #for specified object types,the path is like /opt/xcat/share/xcat/templates/objects// + #for "-a" option, the path is /opt/xcat/share/xcat/templates/objects/ my @tmpldirlist; if($::command eq "lsdef"){ if (!$::opt_a){ @@ -628,15 +650,24 @@ sub processArgs } } }else{ + #if "-a" is specified, read all the object templates + #under /opt/xcat/share/xcat/templates/objects/ push(@tmpldirlist,$objtmpldir); } }elsif($::command eq "mkdef"){ if($::opt_t){ push(@tmpldirlist,$objtmpldir.$::opt_t); }else{ + #if "-t" is not specified, take the object type as "node" push(@tmpldirlist,$objtmpldir."node"); } } + + #walk through the path list and get all the object templates file content; + #for "lsdef -a --template" read all the content of template files + #under "/opt/xcat/share/xcat/templates/objects/"; + #if "-a" is not specified, read the template files content + #under "/opt/xcat/share/xcat/templates/objects/" my $objfiledata; find(\&wanted,@tmpldirlist); sub wanted{ @@ -649,7 +680,9 @@ sub processArgs close(FH) } } - + + #save the template definitions in global variable $::filedata + #for the later parse $::filedata=$objfiledata; } @@ -804,11 +837,15 @@ sub processArgs } # - # process the input file - if provided + # process the input file or object definition template files - if provided # if ($::filedata) { - + + #parse the $::filedata and initialize the following global variables + # %::FILEATTRS : a global hash with the strcture =>{=>} + # @::fileobjtypes : a list of the object types in %::FILEATTRS + # @::fileobjnames : a list of the object names in %::FILEATTRS my $rc = xCAT::DBobjUtils->readFileInput($::filedata); if ($rc) @@ -816,10 +853,13 @@ sub processArgs my $rsp; $rsp->{data}->[0] = "Could not process file input data."; xCAT::MsgUtils->message("I", $rsp, $::callback); - return 1; + return 3; } if($::opt_template){ + #some xCAT shipped object definition templates are specified + #like "lsdef/mkdef --template xxxx" + #filter out the keys(template name) which are not specified from %::FILEATTRS my %tmpfileattr; my @tmpfileobjtypes; my @tmpfileobjnames; @@ -830,26 +870,29 @@ sub processArgs push(@tmpfileobjnames,$key); push(@tmpfileobjtypes,$tmpfileattr{$key}{objtype}); }else{ - delete $::FILEATTRS{$key}; - my $rsp; - $rsp->{data}->[0] = "Could not find $key in xCAT templates, checking whether it is an existing object definition... "; - xCAT::MsgUtils->message("I", $rsp, $::callback); + if($::command eq "lsdef"){ + my $rsp; + $rsp->{data}->[0] = "Could not find $key in xCAT templates."; + xCAT::MsgUtils->message("E", $rsp, $::callback); + return 3; + } } } if(@tmpfileobjnames){ + #flag: some template object definitions are parsed from $::filedata %::FILEATTRS=%tmpfileattr; @::fileobjtypes=@tmpfileobjtypes; @::fileobjnames=@tmpfileobjnames; $::objectsfrom_file = 1; }else{ + #the specified template can not be found in the pared $::filedata + %::FILEATTRS=(); @::fileobjtypes=(); @::fileobjnames=(); } }else{ - # - %::FILEATTRS{fileobjname}{attr}=val - # set @::fileobjtypes, @::fileobjnames, %::FILEATTRS - + #flag: some object definitions are parsed from $::filedata $::objectsfrom_file = 1; } } @@ -1260,6 +1303,7 @@ sub processArgs if ($::opt_template && ($::command eq 'mkdef') ) { unless($::objectsfrom_file){ + #"mkdef --template" specifies an existing object as the template to create new object definition my @myobjlist = xCAT::DBobjUtils->getObjectsOfType($::clobjtypes[0]); unless (@myobjlist) { @@ -1280,24 +1324,53 @@ sub processArgs my $rsp; $rsp->{data}->[0] = "The template node cannot be the same as the node to create."; xCAT::MsgUtils->message("E", $rsp, $::callback); - return 1; + return 3; } - + my %objtypehash; $objtypehash{$::opt_template} = $::clobjtypes[0]; $::ATTRLIST="all"; + #the template object is an existing object, get the object definition my %objattrhash = xCAT::DBobjUtils->getobjdefs(\%objtypehash); + #the object attributes specified in the arguments of "mkdef" has been saved in %::ATTRS + #inherit the attributes not specified in arguments of "mkdef" from the template object definition foreach my $key(keys %{$objattrhash{$::opt_template}}){ if($key ne "objtype" and not $::ATTRS{$key}){ $::ATTRS{$key}=$objattrhash{$::opt_template}{$key}; } } }else{ + #the object attribute specified in the arguments of "mkdef" has been saved in %::ATTRS + #the specified object template definition shipped by xCAT is save in %::FILEATTRS + #inherit the attributes which are not specified in arguments of "mkdef" from template + #"objtype" is not an object attribite, it is a field in stanza file foreach my $key(keys %{$::FILEATTRS{$::opt_template}}){ - if($key ne "objtype" and not $::ATTRS{$key}){ - $::ATTRS{$key}=$::FILEATTRS{$::opt_template}{$key}; + if($key ne "objtype"){ + my $temlattr=$::FILEATTRS{$::opt_template}{$key}; + if($temlattr =~ /^OPTIONAL:/){ + #the attributes with "(OPTIONAL)" in the template + #can be specified on mkdef + $temlattr =""; + } + elsif($temlattr =~ /^MANDATORY:/){ + unless($::ATTRS{$key}){ + #the attributes with "(MANDATORY)" in the template + #must be specified on mkdef + my $rsp; + $rsp->{data}->[0] = "The attribute \"$key\" must be specified!"; + xCAT::MsgUtils->message("E", $rsp, $::callback); + return 3; + } + $temlattr =""; + } + + unless($::ATTRS{$key}){ + $::ATTRS{$key}=$temlattr; + } } } + + #delete the template definition from %::FILEATTRS delete $::FILEATTRS{$::opt_template}; @::fileobjtypes=(); @::fileobjnames=(); @@ -2996,19 +3069,15 @@ sub defls } if (defined $::opt_template){ - unless ($::opt_template){ + #when the "--template" option is specified, but no object template is specified %myhash=%::FILEATTRS; }else{ + #some object template are specified my @templatelist=split(",",$::opt_template); foreach my $mytemplate (@templatelist){ if(exists $::FILEATTRS{$mytemplate}){ $myhash{$mytemplate}= \%{$::FILEATTRS{$mytemplate}}; - }else{ - my $rsp; - $rsp->{data}->[0] = "Could not find the specified $::opt_t template $mytemplate."; - xCAT::MsgUtils->message("I", $rsp, $::callback); - return 1; } } } @@ -3062,7 +3131,6 @@ sub defls # could be modified by type if ($::opt_t) { - # get all objects matching type list # Get all object in this type list foreach my $t (@::clobjtypes) @@ -3112,7 +3180,9 @@ sub defls { push(@::clobjtypes, $t); } - }elsif( defined $::opt_template){ + } + else{ + #push the unique object types from @::fileobjtypes to @::clobjtypes push @::clobjtypes, keys { map { $_ => 1 } @::fileobjtypes }; } } # end - if specify all @@ -3140,7 +3210,6 @@ sub defls } } - my %nodeosimagehash = (); if ($getnodes) { @@ -4169,10 +4238,11 @@ sub defmk_usage my $rsp; $rsp->{data}->[0] = "\nUsage: mkdef - Create xCAT data object definitions.\n"; $rsp->{data}->[1] = " mkdef [-h | --help ] [-t object-types]\n"; - $rsp->{data}->[2] = " mkdef [-V | --verbose] [-t object-types] [-o object-names] [-z|--stanza ]"; - $rsp->{data}->[3] = " [-d | --dynamic] [-w attr==val [-w attr=~val] ...]"; - $rsp->{data}->[4] = " [-f | --force] [noderange] [attr=val [attr=val...]]"; - $rsp->{data}->[5] = "\nThe following data object types are supported by xCAT.\n"; + $rsp->{data}->[2] = " mkdef [-V | --verbose] [-t object-types] [--template template-object-name]"; + $rsp->{data}->[3] = " [-o object-names] [-z|--stanza ]"; + $rsp->{data}->[4] = " [-d | --dynamic] [-w attr==val [-w attr=~val] ...]"; + $rsp->{data}->[5] = " [-f | --force] [noderange] [attr=val [attr=val...]]"; + $rsp->{data}->[6] = "\nThe following data object types are supported by xCAT.\n"; my $n = 6; foreach my $t (sort(keys %{xCAT::Schema::defspec})) @@ -4250,10 +4320,12 @@ sub defls_usage my $rsp; $rsp->{data}->[0] = "\nUsage: lsdef - List xCAT data object definitions.\n"; $rsp->{data}->[1] = " lsdef [-h | --help ] [-t object-types]\n"; - $rsp->{data}->[2] = " lsdef [-V | --verbose] [-t object-types] [-o object-names]"; - $rsp->{data}->[3] = " [ -l | --long] [-s | --short] [-a | --all] [-z | --stanza ] [-S]"; - $rsp->{data}->[4] = " [-i attr-list] [-w attr==val [-w attr=~val] ...] [noderange]\n"; - $rsp->{data}->[5] = "\nThe following data object types are supported by xCAT.\n"; + $rsp->{data}->[2] = " lsdef [-l|--long] [-a|--all] [-t *object-types*] [-z|--stanza]"; + $rsp->{data}->[3] = " [-i attr-list] [--template [template-object-name]] \n"; + $rsp->{data}->[4] = " lsdef [-V | --verbose] [-t object-types] [-o object-names]"; + $rsp->{data}->[5] = " [ -l | --long] [-s | --short] [-a | --all] [-z | --stanza ] [-S]"; + $rsp->{data}->[6] = " [-i attr-list] [-w attr==val [-w attr=~val] ...] [noderange]\n"; + $rsp->{data}->[7] = "\nThe following data object types are supported by xCAT.\n"; my $n = 6; foreach my $t (sort(keys %{xCAT::Schema::defspec})) diff --git a/xCAT/templates/objects/node/cec.stanza b/xCAT/templates/objects/node/cec.stanza new file mode 100644 index 000000000..b0dbf4e53 --- /dev/null +++ b/xCAT/templates/objects/node/cec.stanza @@ -0,0 +1,12 @@ +# + +cec: + objtype=node + groups=cec,all + hcp="MANDATORY:The hardware control point(HMC) for the node" + hwtype=cec + mgt=hmc + mtm="MANDATORY:The machine type and model number of the node" + nodetype=ppc + serial="MANDATORY:The serial number of the node" + usercomment="the cec definition template" diff --git a/xCAT/templates/objects/node/hmc.stanza b/xCAT/templates/objects/node/hmc.stanza new file mode 100644 index 000000000..de7b91a94 --- /dev/null +++ b/xCAT/templates/objects/node/hmc.stanza @@ -0,0 +1,12 @@ +# + +hmc: + objtype=node + groups=hmc + hwtype=hmc + mgt=hmc + nodetype=hmc + ip="MANDATORY:the ip address of the hmc" + password="MANDATORY:the password of the hmc" + username="MANDATORY:the username on the hmc" + usercomment="the template for hmc definition" diff --git a/xCAT/templates/objects/node/ppc64le.stanza b/xCAT/templates/objects/node/ppc64le.stanza new file mode 100644 index 000000000..d212de973 --- /dev/null +++ b/xCAT/templates/objects/node/ppc64le.stanza @@ -0,0 +1,18 @@ +# + +ppc64le: + objtype=node + arch=ppc64le + bmc="MANDATORY:The hostname or ip address of the BMC adapater" + bmcpassword="MANDATORY:the password of the BMC" + bmcusername="MANDATORY:the username of the BMC" + cons=ipmi + groups=all + ip=OPTIONAL:the ip address of the node + mac=OPTIONAL:the mac of the node + mgt=ipmi + netboot=petitboot + nodetype=mp + serialport=0 + serialspeed=115200 + usercomment="the template for PowerLE NV node definition" diff --git a/xCAT/templates/objects/node/ppc64lekvmguest.stanza b/xCAT/templates/objects/node/ppc64lekvmguest.stanza new file mode 100644 index 000000000..24fc4e558 --- /dev/null +++ b/xCAT/templates/objects/node/ppc64lekvmguest.stanza @@ -0,0 +1,17 @@ +# + +ppc64lekvmguest: + objtype=node + arch=ppc64le + groups=all + ip="OPTIONAL:the ip address of the kvm guest" + mac="OPTIONAL:the mac of the kvm guest" + mgt=kvm + netboot=grub2 + vmcpus=2 + vmhost="MANDATORY:the hostname or ip address of the KVM hypervisor" + vmmemory=4096 + vmnicnicmodel=virtio + vmnics="MANDATORY:the hypervisor nics used to create the kvm guest network" + vmstorage=dir:///var/lib/libvirt/images + usercomment="the power LE kvm node definition template" diff --git a/xCAT/templates/objects/node/switch.stanza b/xCAT/templates/objects/node/switch.stanza new file mode 100644 index 000000000..059186a40 --- /dev/null +++ b/xCAT/templates/objects/node/switch.stanza @@ -0,0 +1,11 @@ +# + +switch: + objtype=node + groups=switch + ip="OPTIONAL:the ip address of the switch" + mac="OPTIONAL:the MAC address of the switch" + mgt=switch + nodetype=switch + switchtype="OPTIONAL:The type of switch. It is used to identify the file name that implements the functions for this swithc. The valid values are: Mellanox, Cisco, BNT and Juniper." + usercomment="the switch definition template" diff --git a/xCAT/templates/objects/node/x86_64.stanza b/xCAT/templates/objects/node/x86_64.stanza new file mode 100644 index 000000000..d1ab8bd24 --- /dev/null +++ b/xCAT/templates/objects/node/x86_64.stanza @@ -0,0 +1,19 @@ +# + +x86_64: + objtype=node + arch=x86_64 + bmc="MANDATORY:The hostname or ip address of the BMC adapater" + bmcpassword="MANDATORY:the password of the BMC" + bmcusername="MANDATORY:the username of the BMC" + cons=ipmi + getmac=ipmi + groups=all + hcp= + ip="OPTIONAL:the ip address of the node" + mac="OPTIONAL:the mac of the node" + mgt=ipmi + netboot=xnba + serialport=0 + serialspeed=115200 + usercomment="the system X node definition" diff --git a/xCAT/templates/objects/node/x86_64kvmguest.stanza b/xCAT/templates/objects/node/x86_64kvmguest.stanza new file mode 100644 index 000000000..9397e933f --- /dev/null +++ b/xCAT/templates/objects/node/x86_64kvmguest.stanza @@ -0,0 +1,19 @@ +# + +x86_64kvmguest: + objtype=node + arch=x86_64 + groups=all + ip="OPTIONAL:the ip address of the kvm guest" + mac="OPTIONAL:the mac of the kvm guest" + mgt=kvm + netboot=xnba + serialport=0 + serialspeed=115200 + vmcpus=2 + vmhost="MANDATORY:the hostname or ip address of the KVM hypervisor" + vmmemory=4096 + vmnicnicmodel=virtio + vmnics="MANDATORY:the hypervisor nics used to create the kvm guest network" + vmstorage=dir:///var/lib/libvirt/images + usercomment="the system X kvm node definition" From 5942dfdc99b42939238ea52a196a32c5dd70e187 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 20 Jun 2016 03:08:00 -0400 Subject: [PATCH 137/310] Check if the postscript is only for diskless --- xCAT-server/lib/xcat/plugins/kit.pm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index d9f32a853..81525eaef 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -436,6 +436,13 @@ sub assign_to_osimage } if ( $osimagetable->{provmethod} =~ /install/ ) { + # If the script is only for diskless node + my $cmd = "grep \"#FLAG FOR DISKLESS ONLY#\" $installdir/postscripts/$kitcompscript"; + my $res = xCAT::Utils->runcmd($cmd, -1); + if ($res eq "#FLAG FOR DISKLESS ONLY#"){ + next; + } + # for diskfull node my $match = 0; my @scripts = split ',', $osimagetable->{postbootscripts}; From e48a9c4599ba5ff9c499dcc33bf9ddcbe3ded87f Mon Sep 17 00:00:00 2001 From: root Date: Mon, 20 Jun 2016 03:57:37 -0400 Subject: [PATCH 138/310] support buildkit for centos mn --- xCAT-buildkit/bin/buildkit | 3 +++ xCAT-buildkit/share/xcat/kits/kit_template/buildkit.conf | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/xCAT-buildkit/bin/buildkit b/xCAT-buildkit/bin/buildkit index 2caafaa2d..8944b1f49 100755 --- a/xCAT-buildkit/bin/buildkit +++ b/xCAT-buildkit/bin/buildkit @@ -1184,6 +1184,9 @@ sub edit_bldkitconf if ($debianflag){ s/(filename=.*?)\-(.*)\.noarch\.rpm/$1_$2_all.deb/; } + if ($osbasename =~ /rh/){ + s/.*<<>>/ compat_osbasenames=centos/; + } } # Write the buildkit.conf back out diff --git a/xCAT-buildkit/share/xcat/kits/kit_template/buildkit.conf b/xCAT-buildkit/share/xcat/kits/kit_template/buildkit.conf index 5f375942a..edeeb644b 100644 --- a/xCAT-buildkit/share/xcat/kits/kit_template/buildkit.conf +++ b/xCAT-buildkit/share/xcat/kits/kit_template/buildkit.conf @@ -107,7 +107,7 @@ kitrepo: osmajorversion=<<>> osminorversion=<<>> osarch=<<>> - # compat_osbasenames= + # compat_osbasenames=<<>> # # kitcomponent: This stanza defines one Kit Component. # There can be zero or more kitcomponent stanzas. From e21dbea0b42c40a12740eeecdd43830cfd66c893 Mon Sep 17 00:00:00 2001 From: junxiawang Date: Mon, 20 Jun 2016 06:53:54 -0400 Subject: [PATCH 139/310] modify docker setup case according to issue 1336 --- .../testcase/installation/ubuntu_full_installation_vm_docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_docker b/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_docker index 56f5d9953..15dcce60a 100644 --- a/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_docker +++ b/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_docker @@ -14,7 +14,7 @@ cmd:mkdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-inst check:rc==0 cmd:if [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu" ]];then ver=`cat /etc/*-release |grep "VERSION_ID"| awk -F '"' '{print $2}'| awk -F"." '{printf "%s%s\n",$1,$2}'` ; chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-dockerhost otherpkgdir="https://apt.dockerproject.org/repo ubuntu-trusty main,http://cz.archive.ubuntu.com/ubuntu trusty main" otherpkglist="/install/custom/ubuntu$ver/ubuntu"$ver"_docker.pkglist" osdistroname="__GETNODEATTR($$CN,os)__ ";fi check:rc==0 -cmd:if [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu" ]];then ver=`cat /etc/*-release |grep "VERSION_ID"| awk -F '"' '{print $2}'| awk -F"." '{printf "%s%s\n",$1,$2}'` ; mkdir -p /install/custom/ubuntu$ver/ ; chdef -t osimage -o __GETNODEATTR($$DOCKERHOST,os)__-__GETNODEATTR($$DOCKERHOST,arch)__-install-dockerhost otherpkglist="/install/custom/ubuntu$ver/ubuntu"$ver"_docker.pkglist" pkglist="/install/custom/ubuntu$ver/ubuntu$ver.pkglist";fi +cmd:if [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu" ]];then ver=`cat /etc/*-release |grep "VERSION_ID"| awk -F '"' '{print $2}'| awk -F"." '{printf "%s%s\n",$1,$2}'` ; mkdir -p /install/custom/ubuntu$ver/ ; chdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-install-dockerhost otherpkglist="/install/custom/ubuntu$ver/ubuntu"$ver"_docker.pkglist" pkglist="/install/custom/ubuntu$ver/ubuntu$ver.pkglist";fi check:rc==0 cmd:if [[ "__GETNODEATTR($$CN,os)__" =~ "ubuntu" ]];then ver=`cat /etc/*-release |grep "VERSION_ID"| awk -F '"' '{print $2}'| awk -F"." '{printf "%s%s\n",$1,$2}'` ;for i in openssh-server ntp gawk nfs-common snmpd bridge-utils; do cat /install/custom/ubuntu$ver/ubuntu$ver.pkglist|grep "$i$";if [ $? -ne 0 ] ; then echo "$i" >> /install/custom/ubuntu$ver/ubuntu$ver.pkglist; fi done;fi check:rc==0 From 785f75f82572c432fbb8aed5700aec520bdb743f Mon Sep 17 00:00:00 2001 From: root Date: Mon, 20 Jun 2016 07:06:18 -0400 Subject: [PATCH 140/310] fix a typo --- perl-xCAT/xCAT/ProfiledNodeUtils.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/ProfiledNodeUtils.pm b/perl-xCAT/xCAT/ProfiledNodeUtils.pm index bf8a88547..0148aa664 100644 --- a/perl-xCAT/xCAT/ProfiledNodeUtils.pm +++ b/perl-xCAT/xCAT/ProfiledNodeUtils.pm @@ -1356,7 +1356,7 @@ sub gen_chain_for_profiles{ } if ((exists $netprofileattr->{"bmc"}) and $hw_reconfig){ - if ((($netboot eq 'petitboot') and ($comments eq 'openpower')) or ($netboot ne 'petiboot')) + if ((($netboot eq 'petitboot') and ($comments eq 'openpower')) or ($netboot ne 'petitboot')) { if (index($final_chain, "runcmd=bmcsetup") == -1){ $final_chain = 'runcmd=bmcsetup,'.$final_chain.':reboot4deploy'; From 6d275ffab67c01e1f960320ff76c7b711f530dd9 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Mon, 20 Jun 2016 00:37:04 +0800 Subject: [PATCH 141/310] [go-xcat] Can use different URL or path for the xcat-core and/or xcat-dep repository --- xCAT-server/share/xcat/tools/go-xcat | 457 ++++++++++++++++++++++----- 1 file changed, 380 insertions(+), 77 deletions(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index c8206a91d..8dd32d21b 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -2,6 +2,15 @@ # # go-xcat - Install xCAT automatically. # +# Copyright (C) 2016 International Business Machines +# Eclipse Public License, Version 1.0 (EPL-1.0) +# +# +# 2016-06-16 GONG Jie +# - created +# 2016-06-20 GONG Jie +# - released to the field +# function usage() { @@ -12,21 +21,57 @@ function usage() Install xCAT automatically Options: - --help display this help and exit - --xcat-version=[VERSION] specify the version of xCAT + Mandatory arguments to long options are mandatory for short options too. + -h, --help display this help and exit + --xcat-core=[URL] use a different URL or path for the xcat-core + repository + --xcat-dep=[URL] use a different URL or path for the xcat-dep + repository + -x, --xcat-version=[VERSION] specify the version of xCAT; cannot use with + --xcat-core -y, --yes answer yes for all questions Actions: - install installs all the latest versions from the - repository + install installs all the latest versions of xcat-core + and xcat-dep packages from the repository + Examples: ${script} ${script} install ${script} --yes install - ${script} --xcat-version=2.12 --yes install + ${script} -x 2.12 -y install + ${script} --xcat-version=devel install + ${script} --xcat-core=/path/to/xcat-core.repo install + ${script} --xcat-core=/path/to/xcat-core install + ${script} --xcat-core=/path/to/xcat-core.tar install + ${script} --xcat-core=/path/to/xcat-core.tar.Z install + ${script} --xcat-core=/path/to/xcat-core.tar.gz install + ${script} --xcat-core=/path/to/xcat-core.tar.bz2 install + ${script} --xcat-core=/path/to/xcat-core.tar.xz install + ${script} --xcat-core=http://xcat.org/path/to/xcat-core.repo install + ${script} --xcat-core=http://xcat.org/path/to/xcat-core install + ${script} --xcat-core=http://xcat.org/path/to/xcat-core.tar.bz2 install + ${script} --xcat-core=/path/to/xcat-core.repo \\\\ + --xcat-dep=/path/to/xcat-dep.repo install + ${script} --xcat-core=/path/to/xcat-core \\\\ + --xcat-dep=/path/to/xcat-dep install + ${script} --xcat-core=/path/to/xcat-core.tar.bz2 \\\\ + --xcat-dep=/path/to/xcat-dep.tar.bz2 install + ${script} --xcat-core=http://xcat.org/path/to/xcat-core.repo \\\\ + --xcat-dep=http://xcat.org/path/to/xcat-dep.repo install + ${script} --xcat-core=http://xcat.org/path/to/xcat-core \\\\ + --xcat-dep=http://xcat.org/path/to/xcat-dep install + ${script} --xcat-core=http://xcat.org/path/to/xcat-core.tar.bz2 \\\\ + --xcat-dep=http://xcat.org/path/to/xcat-dep.tar.bz2 install + + xCAT (Extreme Cloud/Cluster Administration Toolkit): + Full documentation at: EOF } +GO_XCAT_DEFAULT_BASE_URL="http://xcat.org/files/xcat/repos" +GO_XCAT_DEFAULT_INSTALL_PATH="/install/xcat" + # The package list of xcat-core GO_XCAT_CORE_PACKAGE_LIST=(perl-xCAT xCAT xCAT-SoftLayer xCAT-buildkit xCAT-client xCAT-confluent xCAT-genesis-scripts-ppc64 @@ -290,7 +335,7 @@ function function_dispatch() return "${ret}" } -# $@ package names +# $@ package names function check_package_version_rpm() { type rpm >/dev/null 2>&1 || return 255 @@ -307,7 +352,7 @@ function check_package_version_rpm() return 0 } -# $@ package names +# $@ package names function check_package_version_deb() { type dpkg-query >/dev/null 2>&1 || return 255 @@ -342,7 +387,7 @@ function check_package_version() function_dispatch "${FUNCNAME}" "$@" } -# $@ package names +# $@ package names function check_repo_version_yum() { type repoquery >/dev/null 2>&1 || return 255 @@ -371,7 +416,7 @@ function check_repo_version_yum() return 0 } -# $@ package names +# $@ package names function check_repo_version_zypper() { type zypper >/dev/null 2>&1 || return 255 @@ -401,7 +446,7 @@ function check_repo_version_zypper() return 0 } -# $@ package names +# $@ package names function check_repo_version_apt() { type apt-cache >/dev/null 2>&1 || return 255 @@ -437,7 +482,7 @@ function check_repo_version() function_dispatch "${FUNCNAME}" "$@" } -# $1 repo_id +# $1 repo id function get_package_list_yum() { type repoquery >/dev/null 2>&1 || return 255 @@ -446,7 +491,7 @@ function get_package_list_yum() repoquery -qa "--repoid=${repo_id}" --qf "%{name}" 2>/dev/null } -# $1 repo_id +# $1 repo id function get_package_list_zypper() { type zypper >/dev/null 2>&1 || return 255 @@ -456,7 +501,7 @@ function get_package_list_zypper() awk -F ' *\\| *' '/ package$/ { print $2 }' } -# $1 repo_id +# $1 repo id function get_package_list_apt() { [[ -d /var/lib/apt/lists ]] || return 255 @@ -467,7 +512,7 @@ function get_package_list_apt() 2>/dev/null } -# $1 repo_id +# $1 repo id function get_package_list() { function_dispatch "${FUNCNAME}" "$@" @@ -481,8 +526,8 @@ function download_file() wget -q "${url}" -O "${local_file}" } -# $1 repo file -# $2 repo_id +# $1 repo file +# $2 repo id function add_repo_by_file_yum() { type yum-config-manager >/dev/null 2>&1 || return 255 @@ -495,7 +540,7 @@ function add_repo_by_file_yum() [[ -n "${repo_id}" ]] exit_if_bad "$?" "empty repo id" [[ "${repo_id}" =~ ^[a-zA-Z][0-9a-zA-Z-]*$ ]] - exit_if_bad "$?" "${repo_id} illigal character in repo id" + exit_if_bad "$?" "${repo_id} illegal character in repo id" local tmp_repo_file="${TMP_DIR}/${repo_id}.repo" { echo "[${repo_id}]" @@ -505,8 +550,8 @@ function add_repo_by_file_yum() yum-config-manager "--add-repo=${tmp_repo_file}" >/dev/null 2>&1 } -# $1 repo file -# $2 repo_id +# $1 repo file +# $2 repo id function add_repo_by_file_zypper() { type zypper >/dev/null 2>&1 || return 255 @@ -519,7 +564,7 @@ function add_repo_by_file_zypper() [[ -n "${repo_id}" ]] exit_if_bad "$?" "empty repo id" [[ "${repo_id}" =~ ^[a-zA-Z][0-9a-zA-Z-]*$ ]] - exit_if_bad "$?" "${repo_id} illigal character in repo id" + exit_if_bad "$?" "${repo_id} illegal character in repo id" local tmp_repo_file="${TMP_DIR}/${repo_id}.repo" { echo "[${repo_id}]" @@ -529,8 +574,8 @@ function add_repo_by_file_zypper() zypper addrepo "${tmp_repo_file}" >/dev/null 2>&1 } -# $1 repo file -# $2 repo_id +# $1 repo file +# $2 repo id function add_repo_by_file_apt() { [[ -d /etc/apt/sources.list.d/ ]] || return 255 @@ -543,7 +588,7 @@ function add_repo_by_file_apt() [[ -n "${repo_id}" ]] exit_if_bad "$?" "empty repo id" [[ "${repo_id}" =~ ^[a-zA-Z][0-9a-zA-Z-]*$ ]] - exit_if_bad "$?" "${repo_id} illigal character in repo id" + exit_if_bad "$?" "${repo_id} illegal character in repo id" cp "${repo_file}" "/etc/apt/sources.list.d/${repo_id}.list" } @@ -552,37 +597,202 @@ function add_repo_by_file() function_dispatch "${FUNCNAME}" "$@" } -# $1 base url -# $2 repo_id -function add_repo_by_url_yum_or_zypper() +# $1 archive +# $2 repo id +# $3 install path +function extract_archive() { - local base_url="$1" + local archive="$1" local repo_id="$2" - local tmp_repo_file="${TMP_DIR}/tmp_repo_file" - while read ; do echo "${REPLY}" ; done >"${tmp_repo_file}" <<-EOF - [${repo_id}] - name=${repo_id} - baseurl=${base_url} - enabled=1 - gpgcheck=0 - EOF - add_repo_by_file "${tmp_repo_file}" "${repo_id}" + local install_path="$3" + [[ -f "${archive}" ]] + warn_if_bad "$?" "${archive}: archive file not found!" || return 1 + mkdir -p "${install_path}" 2>/dev/null + warn_if_bad "$?" "create directory \`${install_path}\' failed" || + return 1 + case "${archive##*.}" in + "Z") + check_executes uncompress tar grep || return 1 + uncompress -c "${archive}" | tar -t -f - | grep -v "^${repo_id}/" + [[ "${PIPESTATUS[0]}" -eq 0 && "${PIPESTATUS[1]}" -eq 0 && + "${PIPESTATUS[2]}" -eq 1 ]] + warn_if_bad "$?" "${archive}: bad compressed tarball" || return 1 + rm -rf "${install_path}/${repo_id}" + uncompress -c "${archive}" | ( cd "${install_path}" && tar -x -f - ) + ;; + "tz"|"tgz"|"gz") + check_executes gzip tar grep || return 1 + gzip -d -c "${archive}" | tar -t -f - | grep -v "^${repo_id}/" + [[ "${PIPESTATUS[0]}" -eq 0 && "${PIPESTATUS[1]}" -eq 0 && + "${PIPESTATUS[2]}" -eq 1 ]] + exit_if_bad "$?" "${archive}: bad gzipped tarball" + rm -rf "${install_path}/${repo_id}" + gzip -d -c "${archive}" | ( cd "${install_path}" && tar -x -f - ) + ;; + "tbz"|"tbz2"|"bz"|"bz2") + check_executes bzip2 tar grep || return 1 + bzip2 -d -c "${archive}" | tar -t -f - | grep -v "^${repo_id}/" + [[ "${PIPESTATUS[0]}" -eq 0 && "${PIPESTATUS[1]}" -eq 0 && + "${PIPESTATUS[2]}" -eq 1 ]] + warn_if_bad "$?" "${archive}: bad bzipped tarball" || return 1 + rm -rf "${install_path}/${repo_id}" + bzip2 -d -c "${archive}" | ( cd "${install_path}" && tar -x -f - ) + ;; + "txz"|"xz") + check_executes xz tar grep || return 1 + xz -d -c "${archive}" | tar -t -f - | grep -v "^${repo_id}/" + [[ "${PIPESTATUS[0]}" -eq 0 && "${PIPESTATUS[1]}" -eq 0 && + "${PIPESTATUS[2]}" -eq 1 ]] + warn_if_bad "$?" "${archive}: bad xzed tarball" || return 1 + rm -rf "${install_path}/${repo_id}" + xz -d -c "${archive}" | ( cd "${install_path}" && tar -x -f - ) + ;; + "tar") + check_executes tar grep || return 1 + tar -t -f "${archive}" | grep -v "^${repo_id}/" + [[ "${PIPESTATUS[0]}" -eq 0 && "${PIPESTATUS[1]}" -eq 1 ]] + warn_if_bad "$?" "${archive}: bad tarball" || return 1 + rm -rf "${install_path}/${repo_id}" + ( cd "${install_path}" && tar -x -f - ) <"${archive}" + ;; + *) + warn_if_bad "1" "${archive}: unknown archive file" + return 1 + ;; + esac + [[ -d "${install_path}/${repo_id}" ]] + warn_if_bad "$?" "${install_path}/${repo_id}: no such directory" } -# $1 base url -# $2 repo_id +# $1 URL +# $2 repo id +function add_repo_by_url_yum_or_zypper() +{ + local url="$1" + local repo_id="$2" + local tmp="" + local install_path="${GO_XCAT_DEFAULT_INSTALL_PATH}" + case "${url%%://*}" in + "ftp"|"http"|"https") + case "${url##*.}" in + "repo"|"Z"|"bz"|"bz2"|"gz"|"tar"|"tbz"|"tbz2"|"tgz"|"tz"|"txz"|"xz") + # an online repo or tarball + tmp="${TMP_DIR}/tmp_${url##*/}" + download_file "${url}" "${tmp}" + warn_if_bad "$?" \ + "download ${repo_id} resource failed" || + return 1 + url="${tmp}" + ;; + *) # assume it is the base url of the repo + tmp="${TMP_DIR}/tmp_repo.repo" + while read ; do echo "${REPLY}" ; done >"${tmp}" <<-EOF + [${repo_id}] + name=${repo_id} + baseurl=${url} + enabled=1 + gpgcheck=0 + EOF + url="${tmp}" + ;; + esac + ;; + "file") + url="${url#file://}" + ;; + esac + if [[ -f "${url}" ]] + then + case "${url##*.}" in + "repo") # local repo file + add_repo_by_file "${url}" "${repo_id}" + return "$?" + ;; + esac + extract_archive "${url}" "${repo_id}" "${install_path}" + warn_if_bad "$?" "extract ${repo_id} archive file failed" || + return 1 + url="${install_path}/${repo_id}" + fi + if [[ -d "${url}" ]] + then + # make sure it is an absolute pathname. + [[ "${url:0:1}" = "/" ]] || url="${PWD}/${url}" + # directory + tmp="${TMP_DIR}/tmp_repo.repo" + while read ; do echo "${REPLY}" ; done >"${tmp}" <<-EOF + [${repo_id}] + name=${repo_id} + baseurl=file://${url} + enabled=1 + gpgcheck=0 + EOF + add_repo_by_file "${tmp}" "${repo_id}" + return "$?" + fi + warn_if_bad "1" "invalid ${repo_id} URL" +} + +# $1 URL +# $2 repo id function add_repo_by_url_apt() { [[ -d /etc/apt/sources.list.d/ ]] || return 255 local base_url="$1" local repo_id="$2" + local tmp="" + local install_path="${GO_XCAT_DEFAULT_INSTALL_PATH}" local codename="$(source /etc/lsb-release >/dev/null 2>&1 && echo "${DISTRIB_CODENAME}")" [[ -n "${codename}" ]] - exit_if_bad "$?" "unknown debian/ubuntu codename" - local tmp_repo_file="${TMP_DIR}/tmp_repo_file" - echo "deb ${base_url} ${codename} main" >"${tmp_repo_file}" - add_repo_by_file_apt "${tmp_repo_file}" "${repo_id}" + warn_if_bad "$?" "unknown debian/ubuntu codename" || return 1 + case "${url%%://*}" in + "ftp"|"http"|"https"|"ssh") + case "${url##*.}" in + "Z"|"bz"|"bz2"|"gz"|"tar"|"tbz"|"tbz2"|"tgz"|"tz"|"txz"|"xz") + # an online tarball + tmp="${TMP_DIR}/tmp_${url##*/}" + download_file "${url}" "${tmp}" + warn_if_bad "$?" \ + "download ${repo_id} resource failed" || + return 1 + url="${tmp}" + ;; + *) # assume it is the base url of the repo + tmp="${TMP_DIR}/tmp_repo.list" + echo "deb ${base_url} ${codename} main" >"${tmp}" + url="${tmp}" + ;; + esac + ;; + "file") + url="${url#file://}" + ;; + esac + if [[ -f "${url}" ]] + then + case "${url##*.}" in + "list") # local repo file + add_repo_by_file_apt "${url}" "${repo_id}" + return "$?" + ;; + esac + extract_archive "${url}" "${repo_id}" "${install_path}" + warn_if_bad "$?" "extract ${repo_id} archive file failed" || + return 1 + url="${install_path}/${repo_id}" + fi + if [[ -d "${url}" ]] + then + # make sure it is an absolute pathname. + [[ "${url:0:1}" = "/" ]] || url="${PWD}/${url}" + # directory + tmp="${TMP_DIR}/tmp_repo.list" + echo "deb file://${url} ${codename} main" >"${tmp}" + add_repo_by_file_apt "${tmp}" "${repo_id}" + return "$?" + fi + warn_if_bad "1" "invalid ${repo_id} URL" } function add_repo_by_url() @@ -590,7 +800,7 @@ function add_repo_by_url() function_dispatch "${FUNCNAME}" "$@" } -# $1 repo_id +# $1 repo id function remove_repo_yum() { [[ -d "/etc/yum.repos.d" ]] || return 255 @@ -600,6 +810,7 @@ function remove_repo_yum() yum clean metadata >/dev/null 2>&1 } +# $1 repo id function remove_repo_zypper() { type zypper >/dev/null 2>&1 || return 255 @@ -607,6 +818,7 @@ function remove_repo_zypper() zypper removerepo "${repo_id}" } +# $1 repo id function remove_repo_apt() { [[ -d "/etc/apt/sources.list.d" ]] || return 255 @@ -619,35 +831,60 @@ function remove_repo() function_dispatch "${FUNCNAME}" "$@" } -# $1 version -# can be "2.10", "2.11", "2.12" or "latest" +# $1 URL +# $2 version +# can be "2.10", "2.11", "2.12", "latest" or "devel" function add_xcat_core_repo_yum_or_zypper() { type yum-config-manager >/dev/null 2>&1 || type zypper >/dev/null 2>&1 || return 255 - local ver="$1" + local url="$1" + local ver="$2" + local tmp="" [[ -z "${ver}" ]] && ver="latest" - local online_repo_file="http://xcat.org/files/xcat/repos/yum/${ver}/xcat-core/xCAT-core.repo" - local tmp_repo_file="${TMP_DIR}/tmp_repo_file" - download_file "${online_repo_file}" "${tmp_repo_file}" - exit_if_bad "$?" "download xcat-core repo file failed" - add_repo_by_file "${tmp_repo_file}" "xcat-core" + if [[ -z "${url}" ]] + then + case "${ver}" in + "devel") + url="${GO_XCAT_DEFAULT_BASE_URL}/yum/devel/core-snap/xCAT-core.repo" + ;; + *) + url="${GO_XCAT_DEFAULT_BASE_URL}/yum/${ver}/xcat-core/xCAT-core.repo" + ;; + esac + fi + add_repo_by_url_yum_or_zypper "${url}" "xcat-core" } -# $1 version -# can be "2.10", "2.11", "2.12" or "latest" +# $1 URL +# $2 version +# can be "2.10", "2.11", "2.12", "latest" or "devel" function add_xcat_core_repo_apt() { [[ -d "/etc/apt/sources.list.d" ]] || return 255 - local ver="$1" + local url="$1" + local ver="$2" + local tmp="" [[ -z "${ver}" ]] && ver="latest" - local apt_key_url="http://xcat.org/files/xcat/repos/apt/apt.key" - local apt_key_file="${TMP_DIR}/xcat.key" - download_file "${apt_key_url}" "${apt_key_file}" - exit_if_bad "$?" "download xcat apt key failed" - apt-key add "${apt_key_file}" >/dev/null 2>&1 - local online_repo_base_url="http://xcat.org/files/xcat/repos/apt/${ver}/xcat-core" - add_repo_by_url_apt "${online_repo_base_url}" "xcat-core" + if [[ -z "${url}" ]] + then + # get the apt.key + local url="${GO_XCAT_DEFAULT_BASE_URL}/apt/apt.key" + local tmp="${TMP_DIR}/tmp_xcat.key" + download_file "${url}" "${tmp}" + warn_if_bad "$?" "download xcat apt key failed" || return 1 + apt-key add "${tmp}" >/dev/null 2>&1 + warn_if_bad "$?" "import xcat apt key failed" || return 1 + case "${ver}" in + "devel") + url="${GO_XCAT_DEFAULT_BASE_URL}/apt/devel/core-snap" + ;; + *) + url="${GO_XCAT_DEFAULT_BASE_URL}/apt/${ver}/xcat-core" + ;; + esac + fi + add_repo_by_url_apt "${url}" "xcat-core" } function add_xcat_core_repo() @@ -659,25 +896,71 @@ function add_xcat_dep_repo_yum_or_zypper() { type yum-config-manager >/dev/null 2>&1 || type zypper >/dev/null 2>&1 || return 255 + local url="$1" + local tmp="" + local install_path="${GO_XCAT_DEFAULT_INSTALL_PATH}" local distro="${GO_XCAT_LINUX_DISTRO}" case "${distro}" in "fedora") ;; "rhel") distro="rh" ;; "sles") ;; - *) exit_if_bad 1 "${distro}: unsupported Linux distro" + *) warn_if_bad 1 "${distro}: unsupported Linux distro" || return 1 esac - local online_repo_file="http://xcat.org/files/xcat/repos/yum/xcat-dep/${distro}${GO_XCAT_LINUX_VERSION%%.*}/${GO_XCAT_ARCH}/xCAT-dep.repo" - local tmp_repo_file="${TMP_DIR}/tmp_repo_file" - download_file "${online_repo_file}" "${tmp_repo_file}" - exit_if_bad "$?" "download xcat-dep repo file failed" - add_repo_by_file "${tmp_repo_file}" "xcat-dep" + [[ -z "${url}" ]] && + url="${GO_XCAT_DEFAULT_BASE_URL}/yum/xcat-dep/${distro}${GO_XCAT_LINUX_VERSION%%.*}/${GO_XCAT_ARCH}/xCAT-dep.repo" + case "${url##*.}" in + "repo") # local repo file + add_repo_by_url_yum_or_zypper "${url}" "xcat-dep" + return "$?" + ;; + esac + case "${url%%://*}" in + "ftp"|"http"|"https") + case "${url##*.}" in + "Z"|"bz"|"bz2"|"gz"|"tar"|"tbz"|"tbz2"|"tgz"|"tz"|"txz"|"xz") + # an online archive file + tmp="${TMP_DIR}/tmp_${url##*/}" + download_file "${url}" "${tmp}" + warn_if_bad "$?" "download xcat-dep archive file failed" \ + || return 1 + url="${tmp}" + ;; + *) + url="${url}/${distro}${GO_XCAT_LINUX_VERSION%%.*}/${GO_XCAT_ARCH}/xCAT-dep.repo" + add_repo_by_url_yum_or_zypper "${url}" "xcat-dep" + return "$?" + ;; + esac + ;; + "file") + url="${url#file://}" + ;; + esac + if [[ -f "${url}" ]] + then + extract_archive "${url}" "xcat-dep" "${install_path}" + warn_if_bad "$?" "extract xcat-dep archive file failed" || + return 1 + url="${install_path}/xcat-dep" + fi + if [[ -d "${url}" ]] + then + # make sure it is an absolute pathname. + [[ "${url:0:1}" = "/" ]] || url="${PWD}/${url}" + url="${url}/${distro}${GO_XCAT_LINUX_VERSION%%.*}/${GO_XCAT_ARCH}" + add_repo_by_url_yum_or_zypper "${url}" "xcat-dep" + return "$?" + fi + warn_if_bad "1" "invalid xcat-dep URL" } function add_xcat_dep_repo_apt() { [[ -d "/etc/apt/sources.list.d" ]] || return 255 - local online_repo_base_url="http://xcat.org/files/xcat/repos/apt/xcat-dep" - add_repo_by_url_apt "${online_repo_base_url}" "xcat-dep" + local url="$1" + [[ -z "${url}" ]] && + url="${GO_XCAT_DEFAULT_BASE_URL}/apt/xcat-dep" + add_repo_by_url_apt "${url}" "xcat-dep" } function add_xcat_dep_repo() @@ -912,21 +1195,35 @@ function stop_progress_meters() # |\/| _.o._ ._ .__ _ .__.._ _ _ _ _ _ |_ _ .__ # | |(_||| | |_)|(_)(_||(_|| | | (_|(_)(/__> | |(/_|(/_ o # | _| _| +# +# Main program goes here. declare -a GO_XCAT_YES=() GO_XCAT_ACTION="" +GO_XCAT_CORE_URL="" +GO_XCAT_DEP_URL="" GO_XCAT_VERSION="latest" while [ "$#" -gt "0" ] do case "$1" in - "--help") + "-h"|"--help") usage exit 0 ;; + "--xcat-core="*) + GO_XCAT_CORE_URL="${1##--xcat-core=}" + ;; + "--xcat-dep="*) + GO_XCAT_DEP_URL="${1##--xcat-dep=}" + ;; "--xcat-version="*) GO_XCAT_VERSION="${1##--xcat-version=}" ;; + "-x") + shift + GO_XCAT_VERSION="$1" + ;; "-y"|"--yes") GO_XCAT_YES=("-y") ;; @@ -992,16 +1289,16 @@ echo echo -n "Reading repositories " show_progress_meters ERR_MSG="$({ - add_xcat_core_repo "${GO_XCAT_VERSION}" - add_xcat_dep_repo - update_repo - RET="$?" - if [[ "${RET}" -ne "0" ]] + if add_xcat_core_repo "${GO_XCAT_CORE_URL}" "${GO_XCAT_VERSION}" then + if add_xcat_dep_repo "${GO_XCAT_DEP_URL}" + then + update_repo && exit 0 + remove_repo "xcat-dep" + fi remove_repo "xcat-core" - remove_repo "xcat-dep" fi - exit "${RET}" + exit 1 } 2>&1)" RET="$?" stop_progress_meters @@ -1114,3 +1411,9 @@ case "${GO_XCAT_ACTION}" in esac # case "${GO_XCAT_ACTION}" in exit 0 + +# vim: set filetype=bash +# vim: set noautoindent +# vim: set tabstop=4 shiftwidth=4 softtabstop=4 + +# End of file From 2ce5afe57679fa35693599f7db7b3fa01acc39be Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Mon, 20 Jun 2016 21:21:17 +0800 Subject: [PATCH 142/310] [go-xcat] Add another small test case to check if all the xcat-core packages are on the same version --- xCAT-server/share/xcat/tools/go-xcat | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index 8dd32d21b..648749f80 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -1086,6 +1086,22 @@ function list_xcat_packages() 42< <(check_repo_version "${GO_XCAT_DEP_PACKAGE_LIST[@]}") } +# Test case 000 +# Check if all the xcat-core packages are on the same version +function test_case_000_version() +{ + local ver="" + local -i ret=0 + while read + do + [[ "${REPLY}" = "(not installed)" ]] && continue + [[ -z "${ver}" ]] && ver="${REPLY%%-*}" + [[ "${ver}" = "${REPLY%%-*}" ]] + (( ret += $? )) + done < <(check_package_version "${GO_XCAT_CORE_PACKAGE_LIST[@]}") + return "${ret}" +} + # Test case 001 # Check if xcatd is running function test_case_001_xcatd() @@ -1113,7 +1129,7 @@ function test_case_002_lsdef() (source /etc/profile.d/xcat.sh && lsdef) } -# Preform basic test +# Perform basic smoke test function perform_smoke_test() { local test_case="" From dfead7e17c833270f3c07febf06a7c6c7ebe9d03 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 20 Jun 2016 10:44:00 -0400 Subject: [PATCH 143/310] image subcommand probe suggested updates --- xCAT-probe/subcmds/image | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/xCAT-probe/subcmds/image b/xCAT-probe/subcmds/image index ad6c45fe3..6f1c478ad 100755 --- a/xCAT-probe/subcmds/image +++ b/xCAT-probe/subcmds/image @@ -11,7 +11,7 @@ use Getopt::Long qw(:config no_ignore_case); use Data::Dumper; use warnings; -my $proname = basename("$0"); +my $program_name = basename("$0"); my $help; my $installnic; my $test; @@ -20,16 +20,16 @@ my $verbose = 0; my $rst = 0; $::USAGE = "Usage: - $proname -h - $proname -t + $program_name -h + $program_name -t Description: Use this command to check if compute nodes have the same images installed as defines in xCAT DB. Use this command to check if all compute nodes have the same identical installed. Options: - -h : Get usage information of $proname - -t : To verify if $proname can work, reserve option for probe framework + -h : Get usage information of $program_name + -t : To verify if $program_name can work, reserve option for probe framework -d : To verify compute nodes have the same images installed as defines in xCAT DB. -c : To verify compute nodes have the identical images installed. -V : To print additional debug information. @@ -55,7 +55,7 @@ if ( "c" => \$CONSISTENCY_CHECK, "d" => \$DEFINITION_CHECK)) { - probe_utils->send_msg("$output", "f", "Invalid parameter for $proname"); + probe_utils->send_msg("$output", "f", "Invalid parameter for $program_name"); probe_utils->send_msg("$output", "d", "$::USAGE"); exit 1; } @@ -75,7 +75,8 @@ if ($test) { } unless(defined($CONSISTENCY_CHECK) || defined($DEFINITION_CHECK)) { - print "At least one of -c or -d flags is required"; + probe_utils->send_msg("$output", "f", "At least one of -c or -d flags is required"); + probe_utils->send_msg("$output", "d", "$::USAGE"); exit 1; } From 17d6cd35d04cf1a2e06eda0584998c625ec5dbb6 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 20 Jun 2016 15:31:39 -0400 Subject: [PATCH 144/310] Correct the count of removed objects --- xCAT-server/lib/xcat/plugins/DBobjectdefs.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm index 40285f360..5e0f04abb 100755 --- a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm +++ b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm @@ -3818,6 +3818,7 @@ sub defrm # the memberlist nodes must be updated. my $numobjects = 0; + my $numobjects_not_removed = 0; my %objTypeLists; foreach my $obj (keys %objhash) { @@ -3831,6 +3832,7 @@ sub defrm my $rsp; $rsp->{data}->[0] = "Could not find an object named \'$obj\' of type \'$objtype\'."; xCAT::MsgUtils->message("E", $rsp, $::callback); + $numobjects_not_removed++; next; } $numobjects++; @@ -3848,6 +3850,7 @@ sub defrm my $rsp; $rsp->{data}->[0] = "Could not get xCAT object definition for \'$obj\'."; xCAT::MsgUtils->message("I", $rsp, $::callback); + $numobjects_not_removed++; next; } @@ -3887,6 +3890,7 @@ sub defrm my $m = join ',', @nodes; $rsp->{data}->[0] = "Could not get xCAT object definition for \'$m\'."; xCAT::MsgUtils->message("I", $rsp, $::callback); + $numobjects_not_removed++; next; } @@ -3985,7 +3989,7 @@ sub defrm else { my $rsp; - my $nodenum = scalar(keys %objhash); + my $nodenum = scalar(keys %objhash) - $numobjects_not_removed; $rsp->{data}->[0] = "$nodenum object definitions have been removed."; xCAT::MsgUtils->message("I", $rsp, $::callback); } From 90cede03a7ca238c0947675a364c45b72d8b6b83 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 20 Jun 2016 23:13:34 -0400 Subject: [PATCH 145/310] Add the centos7.2-ppc64's discinfo --- perl-xCAT/xCAT/data/discinfo.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/perl-xCAT/xCAT/data/discinfo.pm b/perl-xCAT/xCAT/data/discinfo.pm index e44fcdb6e..1520f34e9 100755 --- a/perl-xCAT/xCAT/data/discinfo.pm +++ b/perl-xCAT/xCAT/data/discinfo.pm @@ -21,6 +21,7 @@ require Exporter; "1438724467.511049" => "centos6.7",#x86_64 "1404489053.504589" => "centos7.0", "1427495138.035654" => "centos7.1", + "1450147276.351714" => "centos7.2", #ppc64le "1176234647.982657" => "centos5", "1156364963.862322" => "centos4.4", "1178480581.024704" => "centos4.5", From 5ba0427b483a9993c2e69d2309ecf7116605bd3f Mon Sep 17 00:00:00 2001 From: WangXiaoPeng Date: Tue, 21 Jun 2016 02:56:18 -0400 Subject: [PATCH 146/310] fix a typo that perl sentence: continue does not work in sles11.4 --- xCAT-server/lib/xcat/plugins/ddns.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ddns.pm b/xCAT-server/lib/xcat/plugins/ddns.pm index 580667c29..522a33054 100755 --- a/xCAT-server/lib/xcat/plugins/ddns.pm +++ b/xCAT-server/lib/xcat/plugins/ddns.pm @@ -1446,7 +1446,7 @@ sub add_or_delete_records { my $reply = $resolver->send($update); if ($reply) { if ($reply->header->rcode eq 'NOTAUTH' ) { - continue; + next; } if ($reply->header->rcode ne 'NOERROR') { xCAT::SvrUtils::sendmsg([1,"Failure encountered updating $zone, error was ".$reply->header->rcode.". See more details in system log."], $callback); @@ -1467,7 +1467,7 @@ sub add_or_delete_records { my $reply = $resolver->send($update); if ($reply) { if ($reply->header->rcode eq 'NOTAUTH' ) { - continue; + next; } if ($reply->header->rcode ne 'NOERROR') { xCAT::SvrUtils::sendmsg([1,"Failure encountered updating $zone, error was ".$reply->header->rcode.". See more details in system log."], $callback); From e1c25c317b5dea533495d876fd8a8f29eda19237 Mon Sep 17 00:00:00 2001 From: bybai Date: Tue, 21 Jun 2016 03:30:43 -0400 Subject: [PATCH 147/310] update makentp man page --- docs/source/guides/admin-guides/references/man1/makentp.1.rst | 4 ++-- xCAT-client/pods/man1/makentp.1.pod | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/makentp.1.rst b/docs/source/guides/admin-guides/references/man1/makentp.1.rst index b67c1af83..34f143dc1 100644 --- a/docs/source/guides/admin-guides/references/man1/makentp.1.rst +++ b/docs/source/guides/admin-guides/references/man1/makentp.1.rst @@ -97,7 +97,7 @@ EXAMPLES .. code-block:: perl - setupntp -a + makentp -a @@ -108,7 +108,7 @@ FILES ***** -/opt/xcat/bin/setupntp +/opt/xcat/bin/makentp ******** diff --git a/xCAT-client/pods/man1/makentp.1.pod b/xCAT-client/pods/man1/makentp.1.pod index 6dfa322c2..81bae817b 100755 --- a/xCAT-client/pods/man1/makentp.1.pod +++ b/xCAT-client/pods/man1/makentp.1.pod @@ -74,14 +74,14 @@ To setup NTP server on the management node: =item 2. To setup NTP servers on both management node and the service node: - setupntp -a + makentp -a =back =head1 FILES -/opt/xcat/bin/setupntp +/opt/xcat/bin/makentp =head1 SEE ALSO From 604f6f338e135d9a7f766f994e6766308cf58652 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Tue, 21 Jun 2016 15:45:53 +0800 Subject: [PATCH 148/310] [go-xcat] Fix a bug of command line argument processing --- xCAT-server/share/xcat/tools/go-xcat | 1 - 1 file changed, 1 deletion(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index 648749f80..e658bd79d 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -1246,7 +1246,6 @@ do *) [ "$1" == "--" ] && shift GO_XCAT_ACTION="$1" - shift ;; esac shift From 99e4522fde5f4b337e28180349def688a1314eef Mon Sep 17 00:00:00 2001 From: bybai Date: Tue, 21 Jun 2016 04:29:57 -0400 Subject: [PATCH 149/310] fix 1342 setupntp need enhance to support sles12 --- xCAT/postscripts/setupntp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/xCAT/postscripts/setupntp b/xCAT/postscripts/setupntp index e1de5be59..b45372705 100755 --- a/xCAT/postscripts/setupntp +++ b/xCAT/postscripts/setupntp @@ -164,6 +164,15 @@ restrict 127.0.0.1" >>$conf_file else echo "SYNC_HWCLOCK=yes" >> /etc/sysconfig/ntpd fi + elif [ -f /etc/sysconfig/ntp ];then + grep -i "NTPD_FORCE_SYNC_ON_STARTUP" /etc/sysconfig/ntp + if [ $? -eq 0 ];then + sed -i 's/NTPD_FORCE_SYNC_ON_STARTUP="no"/NTPD_FORCE_SYNC_ON_STARTUP="yes"/' /etc/sysconfig/ntp + fi + grep -i "NTPD_FORCE_SYNC_HWCLOCK_ON_STARTUP" /etc/sysconfig/ntp + if [ $? -eq 0 ];then + sed -i 's/NTPD_FORCE_SYNC_HWCLOCK_ON_STARTUP="no"/NTPD_FORCE_SYNC_HWCLOCK_ON_STARTUP="yes"/' /etc/sysconfig/ntp + fi else cron_file="/etc/cron.daily/xcatsethwclock" if [ ! -f "$cron_file" ];then From b57db4ef31b5484b3e9b3f4b941ef0b779580b9e Mon Sep 17 00:00:00 2001 From: chenglch Date: Tue, 21 Jun 2016 04:41:56 -0400 Subject: [PATCH 150/310] Wait the completion of UDP process to avoid of DB Magic error close-issue: #1008 --- xCAT-server/sbin/xcatd | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xCAT-server/sbin/xcatd b/xCAT-server/sbin/xcatd index 9a9b0a745..d891dcd64 100644 --- a/xCAT-server/sbin/xcatd +++ b/xCAT-server/sbin/xcatd @@ -1469,10 +1469,12 @@ if (open($mainpidfile,"<","/var/run/xcat/mainservice.pid")) { } if ($listener) { $listener->close; } my $lastpid; -while (keys %immediatechildren) { +while (keys %immediatechildren || $pid_UDP) { $lastpid=wait(); if ($immediatechildren{$lastpid}) { delete $immediatechildren{$lastpid}; + } elsif ($lastpid == $pid_UDP) { + $pid_UDP = 0; } } xCAT::Table::shut_dbworker; From 475636a6fd60a8d54b07c4e8ef464aa8cfc5d504 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Tue, 21 Jun 2016 17:54:19 +0800 Subject: [PATCH 151/310] [go-xcat] Add xCAT updating support. --- xCAT-server/share/xcat/tools/go-xcat | 56 ++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index e658bd79d..737fcc14d 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -33,11 +33,14 @@ function usage() Actions: install installs all the latest versions of xcat-core - and xcat-dep packages from the repository + end xcat-dep packages from the repository + update updates installed xcat-core packages to the + latest version from the repository Examples: ${script} ${script} install + ${script} update ${script} --yes install ${script} -x 2.12 -y install ${script} --xcat-version=devel install @@ -84,13 +87,13 @@ GO_XCAT_CORE_PACKAGE_LIST=(perl-xcat xcat xcat-buildkit xcat-client GO_XCAT_DEP_PACKAGE_LIST=() # The package list of all the packages should be installed -GO_XCAT_CORE_INSTALL_LIST=(perl-xCAT xCAT xCAT-buildkit xCAT-client +GO_XCAT_INSTALL_LIST=(perl-xCAT xCAT xCAT-buildkit xCAT-client xCAT-genesis-scripts-ppc64 xCAT-genesis-scripts-x86_64 xCAT-server conserver-xcat elilo-xcat grub2-xcat ipmitool-xcat syslinux-xcat xCAT-genesis-base-ppc64 xCAT-genesis-base-x86_64 xnba-undi yaboot-xcat) # For Debian/Ubuntu, it will need a sight different package list type dpkg >/dev/null 2>&1 && -GO_XCAT_CORE_INSTALL_LIST=(perl-xcat xcat xcat-buildkit xcat-client +GO_XCAT_INSTALL_LIST=(perl-xcat xcat xcat-buildkit xcat-client xcat-genesis-scripts xcat-server conserver-xcat elilo-xcat grub2-xcat ipmitool-xcat syslinux-xcat xcat-genesis-base-amd64 xcat-genesis-base-ppc64 xnba-undi) @@ -1020,9 +1023,31 @@ function install_packages() function_dispatch "${FUNCNAME}" "$@" } +# $1 -y function install_xcat() { - install_packages "$@" "${GO_XCAT_CORE_INSTALL_LIST[@]}" + install_packages "$@" "${GO_XCAT_INSTALL_LIST[@]}" +} + +# $1 -y +function update_xcat() +{ + local -i i=0 + local ver="" + local -a install_list=($( + for p in "${GO_XCAT_INSTALL_LIST[@]}" \ + $(get_package_list xcat-core) + do + echo "${p}" + done | sort -u + )) + for i in "${!install_list[@]}" + do + read ver + [[ "${ver}" = "(not installed)" ]] && + unset "install_list[${i}]" + done < <(check_package_version "${install_list[@]}") + install_packages "$@" "${install_list[@]}" } function list_xcat_packages() @@ -1326,11 +1351,12 @@ fi echo "done" case "${GO_XCAT_ACTION}" in -"install") +"install"|"update") + GO_XCAT_INSTALLER="${GO_XCAT_ACTION}_xcat" if [[ "${#GO_XCAT_YES[@]}" -eq "0" ]] then echo - echo "xCAT is going to be installed." + echo "xCAT is going to be ${GO_XCAT_ACTION/%e/}ed." read -p "Continue? [y/n] " case "${REPLY}" in "Y"*|"y"*) @@ -1341,24 +1367,24 @@ case "${GO_XCAT_ACTION}" in esac fi ( - install_xcat -y 2>&1 1>&42 | - tee "${TMP_DIR}/install_xcat.stderr" >&2 + "${GO_XCAT_INSTALLER}" -y 2>&1 1>&42 | + tee "${TMP_DIR}/${GO_XCAT_INSTALLER}.stderr" >&2 exit "${PIPESTATUS[0]}" - ) 42>&1 | tee "${TMP_DIR}/install_xcat.stdout" + ) 42>&1 | tee "${TMP_DIR}/${GO_XCAT_INSTALLER}.stdout" RET="${PIPESTATUS[0]}" { # Creating logs echo "-- 8< -- -- -- -- -- -- -- -- -- -- -- -- -- -- --" - echo "==== install_xcat exited with exit code ${RET} ====" - echo "-- 8< install_xcat stdout -- --" + echo "==== ${GO_XCAT_INSTALLER} exited with exit code ${RET} ====" + echo "-- 8< ${GO_XCAT_INSTALLER} stdout -- --" while read ; do echo "${REPLY}" ; done \ - <"${TMP_DIR}/install_xcat.stdout" - echo "-- 8< install_xcat stderr -- --" + <"${TMP_DIR}/${GO_XCAT_INSTALLER}.stdout" + echo "-- 8< ${GO_XCAT_INSTALLER} stderr -- --" while read ; do echo "${REPLY}" ; done \ - <"${TMP_DIR}/install_xcat.stderr" + <"${TMP_DIR}/${GO_XCAT_INSTALLER}.stderr" echo "-- 8< -- -- -- -- -- -- -- -- -- -- -- -- -- -- --" } >"${TMP_DIR}/go-xcat.log.005" - if [[ "${RET}" -eq "0" && ! -s "${TMP_DIR}/install_xcat.stderr" ]] + if [[ "${RET}" -eq "0" && ! -s "${TMP_DIR}/${GO_XCAT_INSTALLER}.stderr" ]] then # xCAT has been installed and so far so good perform_smoke_test >"${TMP_DIR}/perform_smoke_test.stdout" \ From 52798de7c4118239144aef8d52c5ee2e35ed3125 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 21 Jun 2016 14:57:32 -0400 Subject: [PATCH 152/310] Simplify solution and handle verbose option --- xCAT-server/lib/xcat/plugins/DBobjectdefs.pm | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm index 5e0f04abb..c6bab0dbe 100755 --- a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm +++ b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm @@ -3818,7 +3818,6 @@ sub defrm # the memberlist nodes must be updated. my $numobjects = 0; - my $numobjects_not_removed = 0; my %objTypeLists; foreach my $obj (keys %objhash) { @@ -3832,7 +3831,9 @@ sub defrm my $rsp; $rsp->{data}->[0] = "Could not find an object named \'$obj\' of type \'$objtype\'."; xCAT::MsgUtils->message("E", $rsp, $::callback); - $numobjects_not_removed++; + # Remove the object we could not find from the hash, this way the count of the objects + # and the content of the hash (for the verbose option), can be used for printing results at the end + delete($objhash{$obj}); next; } $numobjects++; @@ -3850,7 +3851,6 @@ sub defrm my $rsp; $rsp->{data}->[0] = "Could not get xCAT object definition for \'$obj\'."; xCAT::MsgUtils->message("I", $rsp, $::callback); - $numobjects_not_removed++; next; } @@ -3890,7 +3890,6 @@ sub defrm my $m = join ',', @nodes; $rsp->{data}->[0] = "Could not get xCAT object definition for \'$m\'."; xCAT::MsgUtils->message("I", $rsp, $::callback); - $numobjects_not_removed++; next; } @@ -3989,7 +3988,7 @@ sub defrm else { my $rsp; - my $nodenum = scalar(keys %objhash) - $numobjects_not_removed; + my $nodenum = scalar(keys %objhash); $rsp->{data}->[0] = "$nodenum object definitions have been removed."; xCAT::MsgUtils->message("I", $rsp, $::callback); } From cdeca9da04b6bcee639908ba9daddfb2436319b7 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 21 Jun 2016 16:25:01 -0400 Subject: [PATCH 153/310] Code changes suggested by review --- xCAT-probe/subcmds/image | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/xCAT-probe/subcmds/image b/xCAT-probe/subcmds/image index 6f1c478ad..a345866a3 100755 --- a/xCAT-probe/subcmds/image +++ b/xCAT-probe/subcmds/image @@ -22,6 +22,7 @@ my $rst = 0; $::USAGE = "Usage: $program_name -h $program_name -t + $program_name {-c|-d} [-V] Description: Use this command to check if compute nodes have the same images installed as defines in xCAT DB. @@ -35,16 +36,6 @@ Options: -V : To print additional debug information. "; -sub returncmdoutput { - my $rst = shift; - chomp($rst); - my @lines = split("[\n\r]", $rst); - foreach my $line (@lines) { - probe_utils->send_msg("$output", "d", "$line"); - } -} - - #------------------------------------- # main process #------------------------------------- @@ -80,10 +71,7 @@ unless(defined($CONSISTENCY_CHECK) || defined($DEFINITION_CHECK)) { exit 1; } -my $lsdef_cmd = `lsdef`; -chomp($lsdef_cmd); - -my @nodes = split('\(node\)', $lsdef_cmd); +my @nodes = `nodels`; @nodes = grep(s/^[\s]+|[\s]*$//g, @nodes); my @pingable_nodes; @@ -95,7 +83,7 @@ foreach (@nodes) { my $lsdef_provmethod = `lsdef $_ -i provmethod -c`; if ($lsdef_provmethod =~ /netboot/) { push(@diskless_nodes, $_); - print "$_ is diskless\n"; + probe_utils->send_msg("$output", "d", "$_ is diskless"); } } # Next, check if all diskless nodes are pingable @@ -119,16 +107,11 @@ my %node_running_image_name_hash; my %node_defined_image_name_hash; foreach (@pingable_nodes) { - print "---- Gathering information from node $_ ----\n"; + probe_utils->send_msg("$output", "d", "---- Gathering information from node $_ ----"); # Next, from all pingable nodes get the IMAGENAME and IMAGEUUID entries from xcatinfo file - my $xcatinfo_image_UUID = `xdsh $_ "cat /opt/xcat/xcatinfo | grep IMAGEUUID | cut -d '=' -f 2" | cut -d ':' -f 2`; - my $xcatinfo_image_name = `xdsh $_ "cat /opt/xcat/xcatinfo | grep IMAGENAME | cut -d '=' -f 2" | cut -d ':' -f 2`; - $xcatinfo_image_UUID =~ s/'//; - $xcatinfo_image_UUID =~ s/'//; - $xcatinfo_image_UUID =~ s/ //; - $xcatinfo_image_name =~ s/'//; - $xcatinfo_image_name =~ s/'//; - $xcatinfo_image_name =~ s/ //; + my $output = `xdsh $_ "cat /opt/xcat/xcatinfo"`; + my $xcatinfo_image_UUID = ` echo "$output" | awk -F"=" '/IMAGEUUID/ {gsub(/'"'"'/,"",\$2); print \$2}'`; + my $xcatinfo_image_name = ` echo "$output" | awk -F"=" '/IMAGENAME/ {gsub(/'"'"'/,"",\$2); print \$2}'`; chomp($xcatinfo_image_UUID); chomp($xcatinfo_image_name); if (length($xcatinfo_image_UUID) <= 0) { @@ -149,10 +132,8 @@ foreach (@pingable_nodes) { $rootimagedir = `lsdef -t osimage $lsdef_provmethod -i rootimgdir -c | cut -d "=" -f 2`; chomp($rootimagedir); if (length($rootimagedir) > 0) { - $defined_UUID = `grep IMAGEUUID $rootimagedir/rootimg/opt/xcat/xcatinfo | cut -d "=" -f 2`; + $defined_UUID = `awk -F"'" '/IMAGEUUID/ {print \$2}' $rootimagedir/rootimg/opt/xcat/xcatinfo`; chomp($defined_UUID); - $defined_UUID =~ s/'//; - $defined_UUID =~ s/'//; if (length($defined_UUID) < 1) { $defined_UUID = $na; } @@ -213,9 +194,8 @@ if ($CONSISTENCY_CHECK) { # print Dumper(\%unique_image_hash); # If there is more then one key in the hash, nodes have multiple images. my $number_of_keys = keys %unique_image_hash; - my @image_names = keys %unique_image_hash; - my $node_image_table; if ($number_of_keys == 1) { + my @image_names = keys %unique_image_hash; if ($image_names[0] =~ /$na/) { $msg = "Not able to determine image name or uuid of the image installed on any compute node."; $status = "f"; @@ -226,8 +206,8 @@ if ($CONSISTENCY_CHECK) { } } else { + my $node_image_table; foreach $compute_node (keys %node_running_image_name_hash) { - # $node_image_table .= "$compute_node -- $node_running_image_name_hash{$compute_node}" . ":" . "$node_running_image_uuid_hash{$compute_node}\n" $node_image_table .= sprintf("%-15s %-30s : %-20s\n", $compute_node, $node_running_image_name_hash{$compute_node}, $node_running_image_uuid_hash{$compute_node}); } $msg = "Not all compute nodes are running the same os image.\n" . $node_image_table; From 75f8fe246d37e387eeda4960d4546709d457c235 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 21 Jun 2016 16:35:46 -0400 Subject: [PATCH 154/310] perltidy formatting --- xCAT-probe/subcmds/image | 232 ++++++++++++++++++++------------------- 1 file changed, 117 insertions(+), 115 deletions(-) diff --git a/xCAT-probe/subcmds/image b/xCAT-probe/subcmds/image index a345866a3..f3784e090 100755 --- a/xCAT-probe/subcmds/image +++ b/xCAT-probe/subcmds/image @@ -41,10 +41,10 @@ Options: #------------------------------------- if ( !GetOptions("--help|h" => \$help, - "t" => \$test, - "V" => \$VERBOSE, - "c" => \$CONSISTENCY_CHECK, - "d" => \$DEFINITION_CHECK)) + "t" => \$test, + "V" => \$VERBOSE, + "c" => \$CONSISTENCY_CHECK, + "d" => \$DEFINITION_CHECK)) { probe_utils->send_msg("$output", "f", "Invalid parameter for $program_name"); probe_utils->send_msg("$output", "d", "$::USAGE"); @@ -65,10 +65,10 @@ if ($test) { exit 0; } -unless(defined($CONSISTENCY_CHECK) || defined($DEFINITION_CHECK)) { - probe_utils->send_msg("$output", "f", "At least one of -c or -d flags is required"); - probe_utils->send_msg("$output", "d", "$::USAGE"); - exit 1; +unless (defined($CONSISTENCY_CHECK) || defined($DEFINITION_CHECK)) { + probe_utils->send_msg("$output", "f", "At least one of -c or -d flags is required"); + probe_utils->send_msg("$output", "d", "$::USAGE"); + exit 1; } my @nodes = `nodels`; @@ -80,23 +80,24 @@ my $na = "N/A"; # First, extract diskless nodes foreach (@nodes) { - my $lsdef_provmethod = `lsdef $_ -i provmethod -c`; - if ($lsdef_provmethod =~ /netboot/) { - push(@diskless_nodes, $_); - probe_utils->send_msg("$output", "d", "$_ is diskless"); - } + my $lsdef_provmethod = `lsdef $_ -i provmethod -c`; + if ($lsdef_provmethod =~ /netboot/) { + push(@diskless_nodes, $_); + probe_utils->send_msg("$output", "d", "$_ is diskless"); + } } + # Next, check if all diskless nodes are pingable my $p = Net::Ping->new(); foreach (@diskless_nodes) { - if ($p->ping($_, 2)) { - probe_utils->send_msg("$output", "o", "Pinging $_"); - push(@pingable_nodes, $_); - } - else { - probe_utils->send_msg("$output", "f", "Pinging $_"); - } - sleep(1); + if ($p->ping($_, 2)) { + probe_utils->send_msg("$output", "o", "Pinging $_"); + push(@pingable_nodes, $_); + } + else { + probe_utils->send_msg("$output", "f", "Pinging $_"); + } + sleep(1); } $p->close(); @@ -107,114 +108,115 @@ my %node_running_image_name_hash; my %node_defined_image_name_hash; foreach (@pingable_nodes) { - probe_utils->send_msg("$output", "d", "---- Gathering information from node $_ ----"); - # Next, from all pingable nodes get the IMAGENAME and IMAGEUUID entries from xcatinfo file - my $output = `xdsh $_ "cat /opt/xcat/xcatinfo"`; - my $xcatinfo_image_UUID = ` echo "$output" | awk -F"=" '/IMAGEUUID/ {gsub(/'"'"'/,"",\$2); print \$2}'`; - my $xcatinfo_image_name = ` echo "$output" | awk -F"=" '/IMAGENAME/ {gsub(/'"'"'/,"",\$2); print \$2}'`; - chomp($xcatinfo_image_UUID); - chomp($xcatinfo_image_name); - if (length($xcatinfo_image_UUID) <= 0) { - $xcatinfo_image_UUID = $na; - } - if (length($xcatinfo_image_name) <= 0) { - $xcatinfo_image_name = $na; - } - $node_running_image_uuid_hash{$_} = $xcatinfo_image_UUID; - $node_running_image_name_hash{$_} = $xcatinfo_image_name; - print "Node $_ is running image $node_running_image_name_hash{$_} with UUID $node_running_image_uuid_hash{$_} \n" if ($VERBOSE); + probe_utils->send_msg("$output", "d", "---- Gathering information from node $_ ----"); - # Next, get UUID from rootimg directory xcatinfo file of the provmethod osimage - my $lsdef_provmethod = `lsdef $_ -i provmethod -c | cut -d "=" -f 2`; - chomp($lsdef_provmethod); - my $rootimagedir = $na; - if (length($lsdef_provmethod) > 0) { - $rootimagedir = `lsdef -t osimage $lsdef_provmethod -i rootimgdir -c | cut -d "=" -f 2`; - chomp($rootimagedir); - if (length($rootimagedir) > 0) { - $defined_UUID = `awk -F"'" '/IMAGEUUID/ {print \$2}' $rootimagedir/rootimg/opt/xcat/xcatinfo`; - chomp($defined_UUID); - if (length($defined_UUID) < 1) { - $defined_UUID = $na; - } - } - } - else { - $lsdef_provmethod = $na; - } - $node_defined_image_uuid_hash{$_} = $defined_UUID; - $node_defined_image_name_hash{$_} = $lsdef_provmethod; - print "Node $_ has defined image $lsdef_provmethod at $rootimagedir with UUID $defined_UUID\n" if ($VERBOSE); + # Next, from all pingable nodes get the IMAGENAME and IMAGEUUID entries from xcatinfo file + my $output = `xdsh $_ "cat /opt/xcat/xcatinfo"`; + my $xcatinfo_image_UUID = ` echo "$output" | awk -F"=" '/IMAGEUUID/ {gsub(/'"'"'/,"",\$2); print \$2}'`; + my $xcatinfo_image_name = ` echo "$output" | awk -F"=" '/IMAGENAME/ {gsub(/'"'"'/,"",\$2); print \$2}'`; + chomp($xcatinfo_image_UUID); + chomp($xcatinfo_image_name); + if (length($xcatinfo_image_UUID) <= 0) { + $xcatinfo_image_UUID = $na; + } + if (length($xcatinfo_image_name) <= 0) { + $xcatinfo_image_name = $na; + } + $node_running_image_uuid_hash{$_} = $xcatinfo_image_UUID; + $node_running_image_name_hash{$_} = $xcatinfo_image_name; + print "Node $_ is running image $node_running_image_name_hash{$_} with UUID $node_running_image_uuid_hash{$_} \n" if ($VERBOSE); + + # Next, get UUID from rootimg directory xcatinfo file of the provmethod osimage + my $lsdef_provmethod = `lsdef $_ -i provmethod -c | cut -d "=" -f 2`; + chomp($lsdef_provmethod); + my $rootimagedir = $na; + if (length($lsdef_provmethod) > 0) { + $rootimagedir = `lsdef -t osimage $lsdef_provmethod -i rootimgdir -c | cut -d "=" -f 2`; + chomp($rootimagedir); + if (length($rootimagedir) > 0) { + $defined_UUID = `awk -F"'" '/IMAGEUUID/ {print \$2}' $rootimagedir/rootimg/opt/xcat/xcatinfo`; + chomp($defined_UUID); + if (length($defined_UUID) < 1) { + $defined_UUID = $na; + } + } + } + else { + $lsdef_provmethod = $na; + } + $node_defined_image_uuid_hash{$_} = $defined_UUID; + $node_defined_image_name_hash{$_} = $lsdef_provmethod; + print "Node $_ has defined image $lsdef_provmethod at $rootimagedir with UUID $defined_UUID\n" if ($VERBOSE); } # Information gathering is done. Now do veification checking. # Probe verification step 1 - make sure all nodes are running the osimage name and imageUUID as defined on MN if ($DEFINITION_CHECK) { - foreach (@pingable_nodes) { - my $msg; - my $status; - if (($node_running_image_name_hash{$_} eq $node_defined_image_name_hash{$_}) && - ($node_running_image_uuid_hash{$_} eq $node_defined_image_uuid_hash{$_})) { - if ($node_running_image_uuid_hash{$_} eq $na) { - $msg = "$_: Not able to determing running image name or uuid"; - $status = "f"; - } - else { - $msg = "$_: Matches running and defined image name and UUID"; - $status = "o"; - } - } - else { - $msg = "$_: Unmatched image name or image UUID.\n Defined: name = $node_defined_image_name_hash{$_}" . - " uuid = $node_defined_image_uuid_hash{$_}\n Running: name = $node_running_image_name_hash{$_}" . - " uuid = $node_running_image_uuid_hash{$_}"; - $status = "f"; - } - probe_utils->send_msg("$output", "$status", "$msg"); - } + foreach (@pingable_nodes) { + my $msg; + my $status; + if (($node_running_image_name_hash{$_} eq $node_defined_image_name_hash{$_}) && + ($node_running_image_uuid_hash{$_} eq $node_defined_image_uuid_hash{$_})) { + if ($node_running_image_uuid_hash{$_} eq $na) { + $msg = "$_: Not able to determing running image name or uuid"; + $status = "f"; + } + else { + $msg = "$_: Matches running and defined image name and UUID"; + $status = "o"; + } + } + else { + $msg = "$_: Unmatched image name or image UUID.\n Defined: name = $node_defined_image_name_hash{$_}" . +" uuid = $node_defined_image_uuid_hash{$_}\n Running: name = $node_running_image_name_hash{$_}" . + " uuid = $node_running_image_uuid_hash{$_}"; + $status = "f"; + } + probe_utils->send_msg("$output", "$status", "$msg"); + } } # Probe verification step 2 - make sure all nodes are running the same osimage name and imageUUID if ($CONSISTENCY_CHECK) { - my $msg = "Undefined"; - my $status = "f"; - my $image_name_and_uuid; - my $image_uuid; - my %unique_image_hash; + my $msg = "Undefined"; + my $status = "f"; + my $image_name_and_uuid; + my $image_uuid; + my %unique_image_hash; - # Go throug the nodes and build a hash of key=image_name+image_uuid and value of nodename - foreach (@pingable_nodes) { - $image_name_and_uuid = $node_running_image_name_hash{$_} . ":" . $node_running_image_uuid_hash{$_}; - unless (exists $unique_image_hash{$image_name_and_uuid}) { - $unique_image_hash{$image_name_and_uuid} = $_; - } - } + # Go throug the nodes and build a hash of key=image_name+image_uuid and value of nodename + foreach (@pingable_nodes) { + $image_name_and_uuid = $node_running_image_name_hash{$_} . ":" . $node_running_image_uuid_hash{$_}; + unless (exists $unique_image_hash{$image_name_and_uuid}) { + $unique_image_hash{$image_name_and_uuid} = $_; + } + } - # print Dumper(\%unique_image_hash); - # If there is more then one key in the hash, nodes have multiple images. - my $number_of_keys = keys %unique_image_hash; - if ($number_of_keys == 1) { - my @image_names = keys %unique_image_hash; - if ($image_names[0] =~ /$na/) { - $msg = "Not able to determine image name or uuid of the image installed on any compute node."; - $status = "f"; - } - else { - $msg = "All compute nodes have the same image installed: @image_names."; - $status = "o"; - } - } - else { - my $node_image_table; - foreach $compute_node (keys %node_running_image_name_hash) { - $node_image_table .= sprintf("%-15s %-30s : %-20s\n", $compute_node, $node_running_image_name_hash{$compute_node}, $node_running_image_uuid_hash{$compute_node}); - } - $msg = "Not all compute nodes are running the same os image.\n" . $node_image_table; - $status = "f"; - } + # print Dumper(\%unique_image_hash); + # If there is more then one key in the hash, nodes have multiple images. + my $number_of_keys = keys %unique_image_hash; + if ($number_of_keys == 1) { + my @image_names = keys %unique_image_hash; + if ($image_names[0] =~ /$na/) { + $msg = "Not able to determine image name or uuid of the image installed on any compute node."; + $status = "f"; + } + else { + $msg = "All compute nodes have the same image installed: @image_names."; + $status = "o"; + } + } + else { + my $node_image_table; + foreach $compute_node (keys %node_running_image_name_hash) { + $node_image_table .= sprintf("%-15s %-30s : %-20s\n", $compute_node, $node_running_image_name_hash{$compute_node}, $node_running_image_uuid_hash{$compute_node}); + } + $msg = "Not all compute nodes are running the same os image.\n" . $node_image_table; + $status = "f"; + } - probe_utils->send_msg("$output", "$status", "$msg"); + probe_utils->send_msg("$output", "$status", "$msg"); } exit 0; From bf8d91d4e18963c9dda9f5761e71e88a1e687016 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Wed, 22 Jun 2016 10:10:40 +0800 Subject: [PATCH 155/310] [go-xcat] Fix typo --- xCAT-server/share/xcat/tools/go-xcat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index 737fcc14d..2b43dfea3 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -33,7 +33,7 @@ function usage() Actions: install installs all the latest versions of xcat-core - end xcat-dep packages from the repository + and xcat-dep packages from the repository update updates installed xcat-core packages to the latest version from the repository From fba782257ed917595dcb210604a87dcc3d8e5b93 Mon Sep 17 00:00:00 2001 From: penguhyang Date: Mon, 20 Jun 2016 02:10:38 -0400 Subject: [PATCH 156/310] update the doc to add description of how to use diskless log --- .../os_installation/log_to_mn_cn.rst | 96 ++++++++++++------- 1 file changed, 62 insertions(+), 34 deletions(-) diff --git a/docs/source/troubleshooting/os_installation/log_to_mn_cn.rst b/docs/source/troubleshooting/os_installation/log_to_mn_cn.rst index cc39421f7..a36ebe473 100644 --- a/docs/source/troubleshooting/os_installation/log_to_mn_cn.rst +++ b/docs/source/troubleshooting/os_installation/log_to_mn_cn.rst @@ -1,51 +1,79 @@ Log Collecting: Collecting logs of the whole installation process ----------------------------------------------------------------- -The ability to collect logs during the installation process can be helpful when debugging installation problems. +The ability to collect logs during the installation(diskfull and diskless) can be enabled by setting the "site.xcatdebugmode" to different levels(0,1,2), which is quite helpful when debugging installation problems. -Pre-Install: the logs of pre-installation scripts, the pre-installation scripts include "%pre" section in anaconda, "" section for SUSE and "partman/early_command" and "preseed/early_command" sections for ubuntu. The logs include the STDOUT and STDERR of the scripts as well as the debug trace output of bash scripts with "set -x" +The logs during diskfull provision: +``````````````````````````````````` -Installer: the logs from the os installer itself, i.e, the logs of installation program(anaconda, autoyast and preseed,etc.) +* Pre-Install logs: the logs of pre-installation scripts, the pre-installation scripts include "%pre" section in anaconda, "" section for SUSE and "partman/early_command" and "preseed/early_command" sections for ubuntu. The logs include the STDOUT and STDERR of the scripts as well as the debug trace output of bash scripts with "set -x" -Post-Install: the logs of post-installation scripts, the post-installation scripts include "%post" section in anaconda, "" and "" sections for SUSE and "preseed/late_command" section for ubuntu. The logs include the STDOUT and STDERR of the scripts as well as the debug trace output of bash scripts with "set -x" +* Installer logs: the logs from the os installer itself, i.e, the logs of installation program(anaconda, autoyast and preseed,etc.) -Post-Script: This section is useful for functions such as updating node status. This section contains the postbootscripts. +* Post-Install logs: the logs of post-installation scripts, the post-installation scripts include "%post" section in anaconda, "" and "" sections for SUSE and "preseed/late_command" section for ubuntu. The logs include the STDOUT and STDERR of the scripts as well as the debug trace output of bash scripts with "set -x" -The following behavior is observed during OS install: +* PostBootScript logs: the logs during the post boot scripts execution, which are specified in "postbootscripts" attribute of node and osimage definition and run during the 1st reboot after installation. -+------------------+--------------+--------------+--------------+ -|**xcatdebugmode** | 0 | 1 | 2 | -+------------------+----+----+----+----+----+----+----+----+----+ -| |RHEL|SLES|UBT |RHEL|SLES|UBT |RHEL|SLES|UBT | -+=============+====+====+====+====+====+====+====+====+====+====+ -| Pre-Install | MN | N | N | N | -+ log +----+----+----+----+----+----+----+----+----+----+ -| | CN | Y1 | Y2 | Y2 | -+-------------+----+----+----+----+----+----+----+----+----+----+ -| Installer | MN | N | N | N | Y6 | Y6 | Y6 | Y6 | Y6 | Y6 | -+ log +----+----+----+----+----+----+----+----+----+----+ -| | CN | Y5 | Y5 | Y5 | Y5 | Y5 | Y5 | Y5 | Y5 | Y5 | -+-------------+----+----+----+----+----+----+----+----+----+----+ -| Post-Install| MN | Y4 | Y3 | Y3 | -+ log +----+----+----+----+----+----+----+----+----+----+ -| | CN | Y1 | Y2 | Y2 | -+-------------+----+----+----+----+----+----+----+----+----+----+ -| Post-Script | MN | Y4 | Y3 | Y3 | -+ log +----+----+----+----+----+----+----+----+----+----+ -| | CN | Y1 | Y2 | Y2 | -+-------------+----+----+----+----+----+----+----+----+----+----+ ++------------------------+-----------------------+-----------------------+-----------------------+ +| **xcatdebugmode** | 0 | 1 | 2 | ++------------------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ +| OS Distribution | RHEL | SLES | UBT | RHEL | SLES | UBT | RHEL | SLES | UBT | ++================+=======+=======+=======+=======+=======+=======+=======+=======+=======+=======+ +| Pre-Install | [MN]_ | [N]_ | [N]_ | [N]_ | ++ logs +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ +| | [CN]_ | [Y1]_ | [Y2]_ | [Y2]_ | ++----------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ +| Installer | [MN]_ | [N]_ | [N]_ | [N]_ | [Y7]_ | [Y7]_ | [Y7]_ | [Y7]_ | [Y7]_ | [Y7]_ | ++ logs +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ +| | [CN]_ | [Y6]_ | [Y6]_ | [Y6]_ | [Y6]_ | [Y6]_ | [Y6]_ | [Y6]_ | [Y6]_ | [Y6]_ | ++----------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ +| Post-Install | [MN]_ | [Y5]_ | [Y3]_ | [Y3]_ | ++ logs +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ +| | [CN]_ | [Y1]_ | [Y2]_ | [Y2]_ | ++----------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ +| PostBootScript | [MN]_ | [Y5]_ | [Y3]_ | [Y3]_ | ++ logs +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ +| | [CN]_ | [Y1]_ | [Y2]_ | [Y2]_ | ++----------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ -Y1 means the installation logs can be saved to ``/var/log/xcat/xcat.log`` file on CN. +The logs during diskless provision: +``````````````````````````````````` -Y2 means the installation logs and debug trace("set -x" or "-o xtrace") of bash scripts can be saved to ``/var/log/xcat/xcat.log`` file on CN. +* Provision logs: the logs during the diskless provision. -Y3 means the installation logs can be forwarded to ``/var/log/xcat/computes.log`` file on MN. +* PostBootScript logs: the logs during the post boot scripts execution, which are specified in "postbootscripts" attribute of node and osimage definition and run during the 1st reboot after installation. -Y4 means the error messages can be forwarded to ``/var/log/xcat/computes.log`` file on MN only when critical error happens. ++------------------------+--------------+--------------+--------------+ +| **xcatdebugmode** | 0 | 1 | 2 | ++------------------------+----+----+----+----+----+----+----+----+----+ +| OS Distribution |RHEL|SLES|UBT |RHEL|SLES|UBT |RHEL|SLES|UBT | ++================+=======+====+====+====+====+====+====+====+====+====+ +| Provision | [MN]_ | [N]_ | [Y3]_ | [Y3]_ | ++ logs +-------+----+----+----+----+----+----+----+----+----+ +| | [CN]_ | [N]_ | [N]_ | [N]_ | ++----------------+-------+----+----+----+----+----+----+----+----+----+ +| PostBootScript | [MN]_ | [Y3]_ | [Y4]_ | [Y4]_ | ++ logs +-------+----+----+----+----+----+----+----+----+----+ +| | [CN]_ | [Y1]_ | [Y2]_ | [Y2]_ | ++----------------+-------+----+----+----+----+----+----+----+----+----+ -Y5 means the installer log can be saved to the CN in ``/var/log/anaconda`` for RHEL, ``/var/log/YaST2`` for SLES, ``/var/log/installer`` for UBT. +.. [MN] means the logs forwarded to management node. -Y6 means the installer log can be forwarded to the MN in ``/var/log/xcat/computes.log`` file. +.. [CN] means the logs on compute node. -N means the logs can not be forwarded or saved. +.. [Y1] means the installation logs can be saved to ``/var/log/xcat/xcat.log`` file on CN. + +.. [Y2] means the installation logs and debug trace("set -x" or "-o xtrace") of bash scripts can be saved to ``/var/log/xcat/xcat.log`` file on CN. + +.. [Y3] means the installation logs can be forwarded to ``/var/log/xcat/computes.log`` file on MN. + +.. [Y4] means the installation logs and debug trace("set -x" or "-o xtrace") of bash scripts can be forwarded to ``/var/log/xcat/computes.log`` file on MN. + +.. [Y5] means the error messages can be forwarded to ``/var/log/xcat/computes.log`` file on MN only when critical error happens. + +.. [Y6] means the installer log can be saved to the CN in ``/var/log/anaconda`` for RHEL, ``/var/log/YaST2`` for SLES, ``/var/log/installer`` for UBT. + +.. [Y7] means the installer log can be forwarded to the MN in ``/var/log/xcat/computes.log`` file. + +.. [N] means the logs can not be forwarded or saved. From 704f03bcd0b07b6ae76b21fcb11f41e93843dc75 Mon Sep 17 00:00:00 2001 From: XuWei Date: Tue, 21 Jun 2016 22:47:35 -0400 Subject: [PATCH 157/310] Fix issue 980, add status powering-on --- perl-xCAT/xCAT/GlobalDef.pm | 11 ++++--- xCAT-server/lib/xcat/plugins/kvm.pm | 46 +++++++++++------------------ 2 files changed, 24 insertions(+), 33 deletions(-) diff --git a/perl-xCAT/xCAT/GlobalDef.pm b/perl-xCAT/xCAT/GlobalDef.pm index 872433cb8..31bf9de71 100644 --- a/perl-xCAT/xCAT/GlobalDef.pm +++ b/perl-xCAT/xCAT/GlobalDef.pm @@ -48,6 +48,7 @@ $::STATUS_INSTALLED="installed"; $::STATUS_BOOTING="booting"; $::STATUS_NETBOOTING="netbooting"; $::STATUS_BOOTED="booted"; +$::STATUS_POWERING_ON="powering-on"; $::STATUS_POWERING_OFF="powering-off"; $::STATUS_DISCOVERING="discovering"; $::STATUS_CONFIGURING="configuring"; @@ -65,6 +66,7 @@ $::STATUS_BMCREADY="bmcready"; $::STATUS_BOOTING=>1, $::STATUS_NETBOOTING=>1, $::STATUS_BOOTED=>1, + $::STATUS_POWERING_ON=>1, $::STATUS_POWERING_OFF=>1, $::STATUS_DISCOVERING=>1, $::STATUS_CONFIGURING=>1, @@ -82,7 +84,7 @@ $::STATUS_BMCREADY="bmcready"; #defined->[discovering]->[configuring]->[standingby]->installing->[installed]->booting->alive, defined->[discovering]->[configuring]-[standingby]->netbooting->booted->alive, alive/unreachable->booting->alive, powering-off->unreachable, alive->unreachable %::NEXT_NODESTAT_VAL=( - $::STATUS_DEFINED=>{$::STATUS_DISCOVERING=>1, $::STATUS_INSTALLING=>1, $::STATUS_NETBOOTING=>1, $::STATUS_POWERING_OFF=>1, $::STATUS_BOOTING=>1, $::STATUS_CONFIGURING=>1}, + $::STATUS_DEFINED=>{$::STATUS_DISCOVERING=>1, $::STATUS_INSTALLING=>1, $::STATUS_NETBOOTING=>1, $::STATUS_POWERING_OFF=>1, $::STATUS_POWERING_ON=>1, $::STATUS_BOOTING=>1, $::STATUS_CONFIGURING=>1}, $::STATUS_DISCOVERING=>{$::STATUS_INSTALLING=>1, $::STATUS_NETBOOTING=>1, $::STATUS_CONFIGURING=>1, $::STATUS_BOOTING=>1}, $::STATUS_CONFIGURING=>{$::STATUS_INSTALLING=>1, $::STATUS_NETBOOTING=>1, $::STATUS_STANDING_BY=>1}, $::STATUS_INSTALLING =>{$::STATUS_INSTALLED=>1, $::STATUS_BOOTING=>1}, @@ -90,9 +92,10 @@ $::STATUS_BMCREADY="bmcready"; $::STATUS_BOOTING=>{$::STATUS_BOOTED=>1, $::STATUS_ACTIVE=>1, $::STATUS_INACTIVE=>1}, $::STATUS_NETBOOTING=>{$::STATUS_BOOTED=>1}, $::STATUS_BOOTED=>{$::STATUS_ACTIVE=>1, $::STATUS_INACTIVE=>1}, - $::STATUS_ACTIVE=>{$::STATUS_INACTIVE=>1, $::STATUS_DISCOVERING=>1, $::STATUS_CONFIGURING=>1, $::STATUS_INSTALLING=>1, $::STATUS_NETBOOTING=>1, $::STATUS_POWERING_OFF=>1, $::STATUS_BOOTING=>1}, - $::STATUS_INACTIVE=>{$::STATUS_ACTIVE=>1, $::STATUS_DISCOVERING=>1, $::STATUS_CONFIGURING=>1, $::STATUS_INSTALLING=>1, $::STATUS_NETBOOTING=>1, $::STATUS_POWERING_OFF=>1, $::STATUS_BOOTING=>1}, - $::STATUS_POWERING_OFF=>{$::STATUS_INACTIVE=>1} + $::STATUS_ACTIVE=>{$::STATUS_INACTIVE=>1, $::STATUS_DISCOVERING=>1, $::STATUS_CONFIGURING=>1, $::STATUS_INSTALLING=>1, $::STATUS_NETBOOTING=>1, $::STATUS_POWERING_OFF=>1, $::STATUS_POWERING_ON=>1}, + $::STATUS_INACTIVE=>{$::STATUS_ACTIVE=>1, $::STATUS_DISCOVERING=>1, $::STATUS_CONFIGURING=>1, $::STATUS_INSTALLING=>1, $::STATUS_NETBOOTING=>1, $::STATUS_POWERING_OFF=>1, $::STATUS_POWERING_ON=>1}, + $::STATUS_POWERING_OFF=>{$::STATUS_INACTIVE=>1}, + $::STATUS_POWERING_ON=>{$::STATUS_BOOTED=>1} ); diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index 90fe46524..1775a558d 100755 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -2997,6 +2997,9 @@ sub power { } } my $errstr; + my $newstat; + my %newnodestatus=(); + if ($subcommand eq 'on') { unless ($dom) { if ($use_xhrm) { @@ -3009,6 +3012,9 @@ sub power { #this worked before I started doing the offline xml store because every rpower on tried to rebuild ($dom, $errstr) = makedom($node, $cdloc); if ($errstr) { return (1, $errstr); } + else { + $newstat = $::STATUS_POWERING_ON; + } } elsif (not $dom->is_active()) { $dom->create(); } else { @@ -3020,6 +3026,7 @@ sub power { $updatetable->{kvm_nodedata}->{$node}->{xml} = $newxml; if ($dom->is_active()) { $dom->destroy(); + $newstat=$::STATUS_POWERING_OFF; } undef $dom; } else { $retstring .= "$status_noop"; } @@ -3028,6 +3035,7 @@ sub power { my $newxml = $dom->get_xml_description(); $updatetable->{kvm_nodedata}->{$node}->{xml} = $newxml; $dom->shutdown(); + $newstat=$::STATUS_POWERING_OFF; } else { $retstring .= "$status_noop"; } } elsif ($subcommand eq 'reset') { if ($dom && $dom->is_active()) { @@ -3040,6 +3048,7 @@ sub power { $updatetable->{kvm_nodedata}->{$node}->{xml} = $newxml; my $persist = $dom->is_persistent(); $dom->destroy(); + $newstat=$::STATUS_POWERING_OFF; if ($persist) { $dom->undefine(); } undef $dom; if ($use_xhrm) { @@ -3047,6 +3056,10 @@ sub power { } ($dom, $errstr) = makedom($node, $cdloc, $newxml); if ($errstr) { return (1, $errstr); } + else { + $newstat=$::STATUS_POWERING_ON; + } + } else { #no changes, just restart the domain TODO when possible, stupid lack of feature... } $retstring .= "reset"; @@ -3057,6 +3070,10 @@ sub power { } } + $newnodestatus{$newstat}=[$node]; + xCAT::Utils->filter_nostatusupdate(\%newnodestatus); + xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); + unless ($retstring =~ /reset/) { $retstring = $retstring . getpowstate($dom); } @@ -3771,35 +3788,6 @@ sub process_request { } #print "oldstatus:" . Dumper(\%oldnodestatus); - - #set the new status to the nodelist.status - my %newnodestatus = (); - my $newstat; - if (($subcommand eq 'off') || ($subcommand eq 'softoff')) { - my $newstat = $::STATUS_POWERING_OFF; - $newnodestatus{$newstat} = \@allnodes; - } else { - - #get the current nodeset stat - if (@allnodes > 0) { - my $nsh = {}; - my ($ret, $msg) = xCAT::SvrUtils->getNodesetStates(\@allnodes, $nsh); - if (!$ret) { - foreach (keys %$nsh) { - my $newstat = xCAT_monitoring::monitorctrl->getNodeStatusFromNodesetState($_, "rpower"); - $newnodestatus{$newstat} = $nsh->{$_}; - } - } else { - $callback->({ data => $msg }); - } - } - } - - #donot update node provision status (installing or netbooting) here - xCAT::Utils->filter_nostatusupdate(\%newnodestatus); - - #print "newstatus" . Dumper(\%newnodestatus); - xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); } } From ca7c9ad69a36e66998d93b1659099695126c14f2 Mon Sep 17 00:00:00 2001 From: wangxiaopeng Date: Wed, 22 Jun 2016 10:04:04 -0400 Subject: [PATCH 158/310] issue 1171: set SSL_verifycn_scheme => none for IO::Socket::SSL->new --- perl-xCAT/xCAT/Client.pm | 1 + xCAT-client/bin/pasu | 6 ++++-- xCAT-client/bin/pping | 3 ++- xCAT-client/bin/ppping | 1 + xCAT-client/bin/prsync | 3 ++- xCAT-client/bin/pscp | 3 ++- xCAT-client/bin/psh | 3 ++- xCAT-server/xCAT-wsapi/restapi.pl | 2 ++ xCAT-server/xCAT-wsapi/xcatws.cgi | 2 ++ 9 files changed, 18 insertions(+), 6 deletions(-) diff --git a/perl-xCAT/xCAT/Client.pm b/perl-xCAT/xCAT/Client.pm index c6966e978..467e703d0 100644 --- a/perl-xCAT/xCAT/Client.pm +++ b/perl-xCAT/xCAT/Client.pm @@ -249,6 +249,7 @@ if (ref($request) eq 'HASH') { # the request is an array, not pure XML SSL_cert_file => $certfile, SSL_ca_file => $cafile, SSL_verify_mode => SSL_VERIFY_PEER, + SSL_verifycn_scheme => "none", SSL_use_cert => 1, Timeout => 0, %sslargs, diff --git a/xCAT-client/bin/pasu b/xCAT-client/bin/pasu index 2027ef1aa..c04d9b59f 100755 --- a/xCAT-client/bin/pasu +++ b/xCAT-client/bin/pasu @@ -242,7 +242,8 @@ sub expandnoderange { SSL_cert_file=>$homedir."/.xcat/client-cred.pem", SSL_ca_file => $homedir."/.xcat/ca.pem", SSL_use_cert => 1, - SSL_verify_mode => 1, + SSL_verify_mode => SSL_VERIFY_PEER, + SSL_verifycn_scheme => "none", %sslargs, ); die "Connection failure: $!\n" unless ($client); @@ -297,7 +298,8 @@ sub getipmiattrs { SSL_cert_file=>$homedir."/.xcat/client-cred.pem", SSL_ca_file => $homedir."/.xcat/ca.pem", SSL_use_cert => 1, - SSL_verify_mode => 1, + SSL_verify_mode => SSL_VERIFY_PEER, + SSL_verifycn_scheme => "none", %sslargs, ); die "Connection failure: $!\n" unless ($client); diff --git a/xCAT-client/bin/pping b/xCAT-client/bin/pping index e82da4313..5193acd0e 100755 --- a/xCAT-client/bin/pping +++ b/xCAT-client/bin/pping @@ -72,7 +72,8 @@ else { # the normal case of the user running the cmd - expand the noderange us SSL_cert_file=> xCAT::Utils->getHomeDir()."/.xcat/client-cred.pem", SSL_ca_file => xCAT::Utils->getHomeDir()."/.xcat/ca.pem", SSL_use_cert => 1, - SSL_verify_mode => 1, + SSL_verify_mode => SSL_VERIFY_PEER, + SSL_verifycn_scheme => "none", %sslargs, ); die "Connection failure: $!\n" unless ($client); diff --git a/xCAT-client/bin/ppping b/xCAT-client/bin/ppping index a5371ec26..4ad7b21f2 100755 --- a/xCAT-client/bin/ppping +++ b/xCAT-client/bin/ppping @@ -90,6 +90,7 @@ my $client = IO::Socket::SSL->new( SSL_use_cert => 1, %sslargs, SSL_verify_mode => SSL_VERIFY_PEER, + SSL_verifycn_scheme => "none", ); die "Connection failure: $!\n" unless ($client); my %cmdref = (command => 'noderange', noderange => $noderange); diff --git a/xCAT-client/bin/prsync b/xCAT-client/bin/prsync index b1bc0be50..049de4b7e 100755 --- a/xCAT-client/bin/prsync +++ b/xCAT-client/bin/prsync @@ -74,7 +74,8 @@ my $client = IO::Socket::SSL->new( SSL_cert_file=>$homedir."/.xcat/client-cred.pem", SSL_ca_file => $homedir."/.xcat/ca.pem", SSL_use_cert => 1, - SSL_verify_mode => 1, + SSL_verify_mode => SSL_VERIFY_PEER, + SSL_verifycn_scheme => "none", %sslargs, ); die "Connection failure: $!\n" unless ($client); diff --git a/xCAT-client/bin/pscp b/xCAT-client/bin/pscp index 51603f1d1..60b33fa2e 100755 --- a/xCAT-client/bin/pscp +++ b/xCAT-client/bin/pscp @@ -71,7 +71,8 @@ my $client = IO::Socket::SSL->new( SSL_cert_file=>$homedir."/.xcat/client-cred.pem", SSL_ca_file => $homedir."/.xcat/ca.pem", SSL_use_cert => 1, - SSL_verify_mode => 1, + SSL_verify_mode => SSL_VERIFY_PEER, + SSL_verifycn_scheme => "none", %sslargs, ); die "Connection failure: $!\n" unless ($client); diff --git a/xCAT-client/bin/psh b/xCAT-client/bin/psh index ef00375b6..03f53a7e2 100755 --- a/xCAT-client/bin/psh +++ b/xCAT-client/bin/psh @@ -71,7 +71,8 @@ else { SSL_cert_file=>$homedir."/.xcat/client-cred.pem", SSL_ca_file => $homedir."/.xcat/ca.pem", SSL_use_cert => 1, - SSL_verify_mode => 1, + SSL_verify_mode => SSL_VERIFY_PEER, + SSL_verifycn_scheme => "none", %sslargs, ); die "Connection failure: $!\n" unless ($client); diff --git a/xCAT-server/xCAT-wsapi/restapi.pl b/xCAT-server/xCAT-wsapi/restapi.pl index 5ba02750a..d5ddffdd3 100755 --- a/xCAT-server/xCAT-wsapi/restapi.pl +++ b/xCAT-server/xCAT-wsapi/restapi.pl @@ -2477,6 +2477,8 @@ sub sendRequest { SSL_key_file => $keyfile, SSL_cert_file => $certfile, SSL_ca_file => $cafile, + SSL_verify_mode => SSL_VERIFY_PEER, + SSL_verifycn_scheme => "none", SSL_use_cert => 1, Timeout => 15,); } diff --git a/xCAT-server/xCAT-wsapi/xcatws.cgi b/xCAT-server/xCAT-wsapi/xcatws.cgi index dee357b30..d0fa35d62 100755 --- a/xCAT-server/xCAT-wsapi/xcatws.cgi +++ b/xCAT-server/xCAT-wsapi/xcatws.cgi @@ -2991,6 +2991,8 @@ sub sendRequest { SSL_key_file => $keyfile, SSL_cert_file => $certfile, SSL_ca_file => $cafile, + SSL_verify_mode => SSL_VERIFY_PEER, + SSL_verifycn_scheme => "none", SSL_use_cert => 1, Timeout => 15,); } From 32743771ffad8944d82793ee9215ad45400cb847 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Wed, 22 Jun 2016 12:34:26 -0400 Subject: [PATCH 159/310] Clean up some of the messages in doxcat - clean up some messages logged to syslog to help debugging - Only start rsyslog and dhclient if not already started --- xCAT-genesis-scripts/bin/doxcat | 91 +++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 37 deletions(-) diff --git a/xCAT-genesis-scripts/bin/doxcat b/xCAT-genesis-scripts/bin/doxcat index d1c2964cf..ce51a6792 100755 --- a/xCAT-genesis-scripts/bin/doxcat +++ b/xCAT-genesis-scripts/bin/doxcat @@ -8,12 +8,17 @@ log_label="xcat.genesis.doxcat" # Start rsyslogd and log into a local file specified in /etc/rsyslog.conf # Later, once xCAT MN is known, dhclient-script will change # rsyslog.conf file to send log entries to xCAT MN -RSYSLOGD_VERSION=`rsyslogd -v | grep "rsyslogd" | cut -d" " -f2 | cut -d"." -f1` -if [ $RSYSLOGD_VERSION -ge 8 ]; then - /sbin/rsyslogd - # Newer vers of rsyslogd (8 and higher) do not support -c flag anymore -else - /sbin/rsyslogd -c4 +if [ ! -f /var/run/syslogd.pid ]; then + # + # start rsyslog ONLY if not already started + # + RSYSLOGD_VERSION=`rsyslogd -v | grep "rsyslogd" | cut -d" " -f2 | cut -d"." -f1` + if [ $RSYSLOGD_VERSION -ge 8 ]; then + /sbin/rsyslogd + # Newer vers of rsyslogd (8 and higher) do not support -c flag anymore + else + /sbin/rsyslogd -c4 + fi fi logger -t $log_label -p local4.info "Beginning doxcat process..." @@ -39,7 +44,7 @@ if [ ! -z "$BOOTIF" ]; then gripeiter=$((gripeiter-1)) done fi -echo "Done" + if [ -z "$bootnic" ]; then logger -s -t $log_label -p local4.err "BOOTIF missing, can't detect boot nic" fi @@ -82,22 +87,24 @@ PUBKEY=`openssl rsa -in /etc/xcat/privkey.pem -pubout 2> /dev/null|grep -v "PUBL PUBKEY=`echo $PUBKEY|sed -e 's/ //g'` export PUBKEY -logger -t $log_label -p local4.info "Creating /var/lib/lldpad file..." -mkdir -p /var/lib/lldpad -echo 'lldp :' >> /var/lib/lldpad/lldpad.conf -echo '{' >> /var/lib/lldpad/lldpad.conf +LLDP_DIR="/var/lib/lldpad" + +logger -t $log_label -p local4.info "Creating ${LLDP_DIR} directory and config files..." +mkdir -p ${LLDP_DIR} +echo 'lldp :' >> ${LLDP_DIR}/lldpad.conf +echo '{' >> ${LLDP_DIR}/lldpad.conf for iface in `ip link |grep -v '^ '|awk '{print $2}'|sed -e 's/:$//'|grep -v lo`; do -echo "$iface :" >> /var/lib/lldpad/lldpad.conf -echo "{" >> /var/lib/lldpad/lldpad.conf - echo "tlvid00000006 :" >> /var/lib/lldpad/lldpad.conf - echo "{" >> /var/lib/lldpad/lldpad.conf - echo info = '"'$PUBKEY'";' >> /var/lib/lldpad/lldpad.conf - echo 'enableTx = true;' >> /var/lib/lldpad/lldpad.conf - echo '};' >> /var/lib/lldpad/lldpad.conf - echo 'adminStatus = 3;' >> /var/lib/lldpad/lldpad.conf -echo '};' >> /var/lib/lldpad/lldpad.conf + echo "$iface :" >> ${LLDP_DIR}/lldpad.conf + echo "{" >> ${LLDP_DIR}/lldpad.conf + echo "tlvid00000006 :" >> ${LLDP_DIR}/lldpad.conf + echo "{" >> ${LLDP_DIR}/lldpad.conf + echo info = '"'$PUBKEY'";' >> ${LLDP_DIR}/lldpad.conf + echo 'enableTx = true;' >> ${LLDP_DIR}/lldpad.conf + echo '};' >> ${LLDP_DIR}/lldpad.conf + echo 'adminStatus = 3;' >> ${LLDP_DIR}/lldpad.conf + echo '};' >> ${LLDP_DIR}/lldpad.conf done -echo '};' >> /var/lib/lldpad/lldpad.conf +echo '};' >> ${LLDP_DIR}/lldpad.conf lldpad -d logger -t $log_label -p local4.info "lldpad started." @@ -184,8 +191,12 @@ else while [ $tries -lt 100 ]; do ALLUP_NICS=`ip link show | grep -v "^ " | grep "state UP" | awk '{print $2}' | sed -e 's/:$//'|grep -v lo | sort -n -r` for tmp1 in $ALLUP_NICS; do - dhclient -cf /etc/dhclient.conf -pf /var/run/dhclient.$tmp1.pid $tmp1 & - dhclient -6 -pf /var/run/dhclient6.$tmp1.pid $tmp1 -lf /var/lib/dhclient/dhclient6.leases & + if [ ! -f /var/run/dhclient.$tmp1.pid ]; then + dhclient -cf /etc/dhclient.conf -pf /var/run/dhclient.$tmp1.pid $tmp1 & + fi + if [ ! -f /var/run/dhclient6.$tmp1.pid $tmp1 ]; then + dhclient -6 -pf /var/run/dhclient6.$tmp1.pid $tmp1 -lf /var/lib/dhclient/dhclient6.leases & + fi #bootnic=$tmp1 #break done @@ -274,7 +285,7 @@ if [ -e "/dev/rtc" ]; then hwclock --systohc fi HOST_ARCH=`uname -m` -if echo $HOST_ARCH | grep "ppc64"; then +if [ `echo $HOST_ARCH | grep "bac" > /dev/null; echo $?` == 0 ]; then modprobe ipmi_powernv else modprobe ipmi_si @@ -290,20 +301,21 @@ fi DEVICE=$bootnic export DEVICE +logger -t $log_label -p local4.info "IPMI SUPPORT=${IPMI_SUPPORT}, DEVICE=$bootnic" + if [ "$destiny" != "discover" ]; then #we aren't discoverying, we probably can and should get a cert - logger -t $log_label -p local4.info "Run getcert $XCATMASTER:$XCATPORT..." + logger -t $log_label -p local4.info "Run /bin/getcert to xCAT Master ($XCATMASTER:$XCATPORT)..." /bin/getcert $XCATMASTER:$XCATPORT - logger -t $log_label -p local4.info "Getcert done." fi + while :; do grepconfigraid=`echo $destiny|grep "configraid"` if [ -z "$destiny" -o -n "$grepconfigraid" ]; then - logger -t $log_label -p local4.info "Run getdestiny $XCATMASTER:$XCATPORT..." + logger -t $log_label -p local4.info "Run getdestiny to xCAT Master ($XCATMASTER:$XCATPORT)..." destiny=`getdestiny $XCATMASTER:$XCATPORT` - logger -t $log_label -p local4.info "Getdestiny done." fi - + destparameter=`echo $destiny|cut -d '=' -f 2-` logger -t $log_label -p local4.info "The destparameter is $destparameter" @@ -311,15 +323,16 @@ while :; do logger -t $log_label -p local4.info "The destiny is $destiny" dest=`echo $destiny|awk '{print $1}'` #could probably use bash but oh well - logger -t $log_label -p local4.info "The dest is $dest" + logger -t $log_label -p local4.info "The destiny is $dest" + + if [ "$dest" = "discover" ]; then #skip a query to xCAT when /proc/cmdline will do - logger -t $log_label -p local4.info "Run dodiscovery..." + logger -t $log_label -p local4.info "Run Discovery..." /bin/dodiscovery - logger -t $log_label -p local4.info "Dodiscovery done." - logger -t $log_label -p local4.info "Run getcert $XCATMASTER:$XCATPORT..." + logger -t $log_label -p local4.info "... Discovery complete." + logger -t $log_label -p local4.info "Run /bin/getcert to xCAT Master ($XCATMASTER:$XCATPORT)..." /bin/getcert $XCATMASTER:$XCATPORT - logger -t $log_label -p local4.info "Getcert done." destiny='' dest='' elif [ "$dest" = shell ]; then @@ -327,7 +340,7 @@ while :; do destiny='' dest='' /bin/bash - logger -t $log_label -p local4.info "Exit shell." + logger -t $log_label -p local4.info "Exiting shell." logger -t $log_label -p local4.info "Run nextdestiny $XCATMASTER:$XCATPORT..." /bin/nextdestiny $XCATMASTER:$XCATPORT logger -t $log_label -p local4.info "Nextdestiny done." @@ -386,7 +399,9 @@ while :; do dest='' delay=$((30+$RANDOM%270)) while [ $delay -gt 0 ]; do - logger -s -t $log_label -p local4.info "Received request to retry in a bit, will call xCAT back in $delay seconds" + if [ $((delay%10)) == 0 ]; then + logger -s -t $log_label -p local4.info "Received request to retry in a bit, will call xCAT back in $delay seconds" + fi delay=$((delay-1)) sleep 1 done @@ -400,7 +415,9 @@ while :; do dest='' delay=$((30+$RANDOM%270)) while [ $delay -gt 0 ]; do - logger -s -t $log_label -p local4.info "Will retry in $delay seconds" + if [ $((delay%10)) == 0 ]; then + logger -s -t $log_label -p local4.info "Will retry in $delay seconds" + fi delay=$((delay-1)) sleep 1 done From fd888249402d3dd71f75b16be971cb4f57c69899 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Wed, 22 Jun 2016 14:11:41 -0400 Subject: [PATCH 160/310] Improve messages --- xCAT-probe/subcmds/image | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/xCAT-probe/subcmds/image b/xCAT-probe/subcmds/image index f3784e090..bc390ed81 100755 --- a/xCAT-probe/subcmds/image +++ b/xCAT-probe/subcmds/image @@ -8,7 +8,7 @@ use probe_utils; use File::Basename; use Net::Ping; use Getopt::Long qw(:config no_ignore_case); -use Data::Dumper; +#use Data::Dumper; use warnings; my $program_name = basename("$0"); @@ -151,7 +151,7 @@ foreach (@pingable_nodes) { # Information gathering is done. Now do veification checking. -# Probe verification step 1 - make sure all nodes are running the osimage name and imageUUID as defined on MN +# Probe verification step 1 - make sure all nodes are installed with the osimage name and imageUUID as defined on MN if ($DEFINITION_CHECK) { foreach (@pingable_nodes) { my $msg; @@ -159,17 +159,17 @@ if ($DEFINITION_CHECK) { if (($node_running_image_name_hash{$_} eq $node_defined_image_name_hash{$_}) && ($node_running_image_uuid_hash{$_} eq $node_defined_image_uuid_hash{$_})) { if ($node_running_image_uuid_hash{$_} eq $na) { - $msg = "$_: Not able to determing running image name or uuid"; + $msg = "$_: Not able to determine installed os image name or uuid"; $status = "f"; } else { - $msg = "$_: Matches running and defined image name and UUID"; + $msg = "OS image installed on compute node $_ matches the image defined for it on management node"; $status = "o"; } } else { - $msg = "$_: Unmatched image name or image UUID.\n Defined: name = $node_defined_image_name_hash{$_}" . -" uuid = $node_defined_image_uuid_hash{$_}\n Running: name = $node_running_image_name_hash{$_}" . + $msg = "$_: Unmatched os image name or image UUID.\n Defined: name = $node_defined_image_name_hash{$_}" . +" uuid = $node_defined_image_uuid_hash{$_}\n Installed: name = $node_running_image_name_hash{$_}" . " uuid = $node_running_image_uuid_hash{$_}"; $status = "f"; } @@ -177,7 +177,7 @@ if ($DEFINITION_CHECK) { } } -# Probe verification step 2 - make sure all nodes are running the same osimage name and imageUUID +# Probe verification step 2 - make sure all nodes are installed with the same osimage name and imageUUID if ($CONSISTENCY_CHECK) { my $msg = "Undefined"; my $status = "f"; @@ -199,11 +199,11 @@ if ($CONSISTENCY_CHECK) { if ($number_of_keys == 1) { my @image_names = keys %unique_image_hash; if ($image_names[0] =~ /$na/) { - $msg = "Not able to determine image name or uuid of the image installed on any compute node."; + $msg = "Not able to determine os image name or uuid of the image installed on any compute node."; $status = "f"; } else { - $msg = "All compute nodes have the same image installed: @image_names."; + $msg = "All compute nodes have the same os image installed: @image_names."; $status = "o"; } } @@ -212,7 +212,7 @@ if ($CONSISTENCY_CHECK) { foreach $compute_node (keys %node_running_image_name_hash) { $node_image_table .= sprintf("%-15s %-30s : %-20s\n", $compute_node, $node_running_image_name_hash{$compute_node}, $node_running_image_uuid_hash{$compute_node}); } - $msg = "Not all compute nodes are running the same os image.\n" . $node_image_table; + $msg = "Not all compute nodes are installed with the same os image.\n" . $node_image_table; $status = "f"; } From 41b755a4139ba1449b30b518c4ce53a0d81fb5bb Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Wed, 22 Jun 2016 14:21:14 -0400 Subject: [PATCH 161/310] For getipmi script, change the rm to use the -f option so that we avoid a warning message that the file does not exists. Add a log label for logger messages --- xCAT-genesis-scripts/bin/getipmi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xCAT-genesis-scripts/bin/getipmi b/xCAT-genesis-scripts/bin/getipmi index 5e9af2590..f129cb382 100755 --- a/xCAT-genesis-scripts/bin/getipmi +++ b/xCAT-genesis-scripts/bin/getipmi @@ -1,4 +1,6 @@ #!/bin/bash +log_label="xcat.genesis.getipmi" + allowcred.awk & CREDPID=$! if [ -z "$XCATDEST" ]; then @@ -24,7 +26,7 @@ echo " 300 $BMCMAC " > /tmp/bmcreq.xml -rm /tmp/ipmicfg.xml +rm -f /tmp/ipmicfg.xml while [ ! -f /tmp/ipmicfg.xml ] || grep error /tmp/ipmicfg.xml; do if [ -f /tmp/ipmicfg.xml ]; then timer=60 From 3d2605c2f231e943098682748467973f6e922cb5 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Wed, 22 Jun 2016 15:50:25 -0400 Subject: [PATCH 162/310] Clean up some errors in bmcsetup script - update some log messages - do not run the mc reset cold for openPower systems - create the 'mc info' output in a file in /tmp to reduce the number of ipmitool calls - 300 is too large for chassis identify, change to 275 --- xCAT-genesis-scripts/bin/bmcsetup | 39 ++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index ddef2655a..e99fe4b19 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -37,12 +37,13 @@ function cold_reset_bmc() { # reset after applying ipmitool commands. However, it seems there is a problem with # the BMC where after 15 seconds, it stops responding. To work around, sleep 30 # seconds before issuing the reset of the BMC. - sleep 30 + snooze + else + logger -s -t $log_label -p local4.info "Resetting BMC ..." + ipmitool mc reset cold + logger -s -t $log_label -p local4.info "Waiting for the BMC to appear ..." fi - logger -s -t $log_label -p local4.info "Resetting BMC ..." - ipmitool mc reset cold - logger -s -t $log_label -p local4.info "Waiting for the BMC to appear ..." if [ "$XPROD" = "43707" ]; then # OpenPower SPECIFIC, check the BMC with the following raw command to # make sure that the bmc is really in a "ready" state before continuing @@ -125,18 +126,22 @@ while [ -z "$BMCIP" -a $IPCFGMETHOD="static" ]; do done kill $CREDPID NUMBMCS=`grep bmcip /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'|wc -l` -logger -s -t $log_label -p local4.debug "BMC IP=$BMCIP, NETMASK=$BMCNM, GATEWAY=$BMCGW, VLAN=$BMCVLAN, USER=$BMCUS, PASSWORD=$BMCPW" -logger -s -t $log_label -p local4.info "NUMBMCS=$NUMBMCS" +logger -s -t $log_label -p local4.debug "BMC Information obtained from xCAT" +logger -s -t $log_label -p local4.debug "NUMBMCS=$NUMBMCS ==> BMC IP=$BMCIP/$BMCNM, GW=$BMCGW, VLAN=$BMCVLAN, USER=$BMCUS, PASSWORD=$BMCPW" + # # Get the BMC Version and Manufacturer ID # -IPMIVER=`ipmitool mc info|grep ^IPMI|awk '{print $4}'` -IPMIMFG=`ipmitool mc info|grep "^Manufacturer ID"|awk '{print $4}'` -logger -s -t $log_label -p local4.info "IPMIVER=$IPMIVER, IPMIMFG=$IPMIMFG" +MC_INFO=/tmp/xcat.ipmitool.mcinfo + +ipmitool mc info > ${MC_INFO} +IPMIVER=`cat ${MC_INFO} |grep ^IPMI|awk '{print $4}'` +IPMIMFG=`cat ${MC_INFO} |grep "^Manufacturer ID"|awk '{print $4}'` # Get the BMC Product ID -XPROD=`ipmitool mc info|grep "^Product ID"|awk '{print $4}'` -logger -s -t $log_label -p local4.info "XPROD=$XPROD" +XPROD=`cat ${MC_INFO} |grep "^Product ID"|awk '{print $4}'` + +logger -s -t $log_label -p local4.info "IPMIVER=$IPMIVER, IPMIMFG=$IPMIMFG, XPROD=$XPROD" # # IPMIMFG=2 = IBM @@ -474,7 +479,7 @@ while [ $idev -gt 0 ]; do done if [ $TRIES -gt $TIMEOUT ]; then logger -s -t $log_label -p local4.err "$MSG: ERROR"; else logger -s -t $log_label -p local4.info "$MSG: OK"; fi - MSG="Enabling IPMI v 1.5 MD5 LAN access" + MSG="Enabling IPMI MD5 LAN access" logger -s -t $log_label -p local4.info "$MSG" TRIES=0 # Set the auth level to md5 for the channel @@ -517,6 +522,8 @@ while [ $idev -gt 0 ]; do i=$((i+1)) done + logger -s -t $log_label -p local4.info "ACCESS=$NEWACCESS" + MSG="Set the cipher_privileges for the channel" logger -s -t $log_label -p local4.info "$MSG" # Set the cipher_privileges for the channel @@ -565,8 +572,12 @@ while [ $idev -gt 0 ]; do logger -s -t $log_label -p local4.info "Lighting Identify Light" if [ "$XPROD" = "43707" ]; then - # OpenPower BMC specific, turn on the LED beacon for 5 minutes - ipmitool chassis identify 300 + # OpenPower BMC specific, turn on the LED beacon light. + # - default interval, # ipmitool chassis identify + # Chassis identify interval: default (15 seconds) + # - 275 is too large, # ipmitool chassis identify 275 + # Given interval is too big. + ipmitool chassis identify 250 else # All other BMCs while : From 1846de82059a5d14156dbc2821c84848df712b52 Mon Sep 17 00:00:00 2001 From: immarvin Date: Wed, 22 Jun 2016 04:58:40 -0400 Subject: [PATCH 163/310] restruct the runcmdinstaller with netcat --- xCAT-server/sbin/runcmdinstaller | 72 ++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 21 deletions(-) diff --git a/xCAT-server/sbin/runcmdinstaller b/xCAT-server/sbin/runcmdinstaller index 438db3f31..12875267f 100755 --- a/xCAT-server/sbin/runcmdinstaller +++ b/xCAT-server/sbin/runcmdinstaller @@ -1,32 +1,62 @@ -#!/bin/sh +#!/bin/bash #usage: #runcmdinstaller: issue command which run in the installer and print the command output #runcmdinstaller "" +node=$1 +shift +cmd=$* + +function print_usage { + echo "Usage:" + echo " runcmdinstaller " + echo " runcmdinstaller [-h] [--help]" + echo "Description:" + echo " A debug tool to run commands inside the os installer of a node" + echo "Notice:" + echo " 1. runcmdinstaller is only available against the node provisioned with xcatdebugmode turned on(1 or 2)" + echo " 2. can not be multiple nodes or node group" + echo " 3. must be the node in 'installing' status" + echo " 4. must be the commads which will return immediately, otherwise, runcmdinstaller will be blocked" + echo " 5. runcmdinstaller can not be run concurrently" -awk -v argc="$#" -v node="$1" -v cmd="$2" 'BEGIN { -port = 3001 -action = "sh" -if(node=="-h"){ - print "Usage:\n\n runcmdinstaller \"\"\n" - print " make sure all the commands are quoted by \"\"\n"; - exit 0; -} -if(argc !=2 || ! node || ! cmd){ - print "Usage:\n\n runcmdinstaller \"\"\n" - print " make sure all the commands are quoted by \"\"\n"; - exit 1; } -ns = "/inet/tcp/0/" node "/" port +if [ "$node" = "-h" ] || [ "$node" = "--help" ]; then + print_usage + exit 0 +fi -#print "sh " |& ns -print action " " cmd " " |& ns +if [ -z "$node" ] || [ -z "$cmd" ];then + print_usage + exit 1 +fi -while((ns |& getline) > 0) -print $0 -close(ns) +XCATDEBUGMODE=$(lsdef -t site -o clustersite -i xcatdebugmode 2>/dev/null | grep "xcatdebugmode="|cut -d= -f2) +if [[ -z "$XCATDEBUGMODE" || "$XCATDEBUGMODE" == "0" ]];then + echo "Warning:" + echo " The xcatdebugmode is disabled" + echo " runcmdinstaller is only available against the node provisioned with xcatdebugmode enabled( +1 or 2)" +else + NSupdate=$(lsdef -t site -o clustersite -i nodestatus 2>/dev/null | grep "nodestatus="|cut -d= -f2) + nodestatus=$(lsdef $node -i status 2>/dev/null | grep "status="|cut -d= -f2) + + if [[ "$NSupdate" != "n" && "$NSupdate" != "N" && "$NSupdate" != "0" && "$nodestatus" != "installing" ]];then + echo "Warning:" + echo " The node status update is enabled and the 'nodestatus' of $node is $nodestatus" + echo " runcmdinstaller can only be run against the node in 'installing' status!" + fi +fi + +type -p nc >/dev/null 2>&1 +retcode=$? +if [ "$retcode" != "0" ];then + echo "Error:" + echo "nc(netcat) is not installed, please install it first!" + exit $retcode +fi + +echo "sh $cmd 2>&1" | nc -w 20 $node 3001 -exit 0 -}' From e7f3446bd4b5266acc232f2551149ac631a4d116 Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 23 Jun 2016 02:09:24 -0400 Subject: [PATCH 164/310] fix issue [FVT]lsdef/mkdef commands on rh6.8 ppc64 #1369 @github --- xCAT-server/lib/xcat/plugins/DBobjectdefs.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm index 915ffb9f2..554c9ea5f 100755 --- a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm +++ b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm @@ -669,8 +669,7 @@ sub processArgs #if "-a" is not specified, read the template files content #under "/opt/xcat/share/xcat/templates/objects/" my $objfiledata; - find(\&wanted,@tmpldirlist); - sub wanted{ + my $wanted= sub { if (-f $_){ my $line; open(FH,$_); @@ -679,7 +678,9 @@ sub processArgs } close(FH) } - } + }; + find($wanted,@tmpldirlist); + #save the template definitions in global variable $::filedata #for the later parse @@ -3183,7 +3184,8 @@ sub defls } else{ #push the unique object types from @::fileobjtypes to @::clobjtypes - push @::clobjtypes, keys { map { $_ => 1 } @::fileobjtypes }; + my %objtypehash=map { $_ => 1 } @::fileobjtypes; + push @::clobjtypes, keys(%objtypehash); } } # end - if specify all From 34abeed36cb64a4f402e62c5ac21c01cd45345db Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Thu, 23 Jun 2016 16:00:51 +0800 Subject: [PATCH 165/310] [go-xcat] Fix a bug on Ubuntu. On amd64, apt is configured for bi-arch, while xcat repository is not bi-arch. --- xCAT-server/share/xcat/tools/go-xcat | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index 2b43dfea3..205358d50 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -741,7 +741,7 @@ function add_repo_by_url_yum_or_zypper() function add_repo_by_url_apt() { [[ -d /etc/apt/sources.list.d/ ]] || return 255 - local base_url="$1" + local url="$1" local repo_id="$2" local tmp="" local install_path="${GO_XCAT_DEFAULT_INSTALL_PATH}" @@ -763,7 +763,7 @@ function add_repo_by_url_apt() ;; *) # assume it is the base url of the repo tmp="${TMP_DIR}/tmp_repo.list" - echo "deb ${base_url} ${codename} main" >"${tmp}" + echo "deb [arch=$(dpkg --print-architecture)] ${url} ${codename} main" >"${tmp}" url="${tmp}" ;; esac @@ -791,7 +791,7 @@ function add_repo_by_url_apt() [[ "${url:0:1}" = "/" ]] || url="${PWD}/${url}" # directory tmp="${TMP_DIR}/tmp_repo.list" - echo "deb file://${url} ${codename} main" >"${tmp}" + echo "deb [arch=$(dpkg --print-architechure)] file://${url} ${codename} main" >"${tmp}" add_repo_by_file_apt "${tmp}" "${repo_id}" return "$?" fi From e64d09c9b92735c6c1eccf4777b935d0a572040b Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Thu, 23 Jun 2016 18:06:19 +0800 Subject: [PATCH 166/310] [go-xcat] Get rid of yum-config-manager, it make things easier if package yum-utils is not installed --- xCAT-server/share/xcat/tools/go-xcat | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index 205358d50..8eba3f99e 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -533,7 +533,7 @@ function download_file() # $2 repo id function add_repo_by_file_yum() { - type yum-config-manager >/dev/null 2>&1 || return 255 + [[ -d /etc/yum.repos.d ]] || return 255 local repo_file="$1" local repo_id="$2" [[ -f "${repo_file}" ]] @@ -544,13 +544,11 @@ function add_repo_by_file_yum() exit_if_bad "$?" "empty repo id" [[ "${repo_id}" =~ ^[a-zA-Z][0-9a-zA-Z-]*$ ]] exit_if_bad "$?" "${repo_id} illegal character in repo id" - local tmp_repo_file="${TMP_DIR}/${repo_id}.repo" + remove_repo_yum "${repo_id}" { echo "[${repo_id}]" grep -v '^\[' "${repo_file}" - } >"${tmp_repo_file}" - remove_repo_yum "${repo_id}" - yum-config-manager "--add-repo=${tmp_repo_file}" >/dev/null 2>&1 + } >"/etc/yum.repos.d/${repo_id}.repo" } # $1 repo file @@ -806,11 +804,13 @@ function add_repo_by_url() # $1 repo id function remove_repo_yum() { - [[ -d "/etc/yum.repos.d" ]] || return 255 + type yum >/dev/null 2>&1 || return 255 local repo_id="$1" - [[ -f "/etc/yum.repos.d/${repo_id}.repo" ]] && - rm -f "/etc/yum.repos.d/${repo_id}.repo" && - yum clean metadata >/dev/null 2>&1 + # This deleting method is not good enough. Since there could be more + # than one repostory definitions in a single repo file. + # This is a quick and dirty method. + rm -f $(grep -l "^\[${repo_id}\]$" "/etc/yum.repos.d/"*".repo") + yum clean metadata >/dev/null 2>&1 } # $1 repo id @@ -839,8 +839,7 @@ function remove_repo() # can be "2.10", "2.11", "2.12", "latest" or "devel" function add_xcat_core_repo_yum_or_zypper() { - type yum-config-manager >/dev/null 2>&1 || - type zypper >/dev/null 2>&1 || return 255 + type yum >/dev/null 2>&1 || type zypper >/dev/null 2>&1 || return 255 local url="$1" local ver="$2" local tmp="" @@ -897,8 +896,7 @@ function add_xcat_core_repo() function add_xcat_dep_repo_yum_or_zypper() { - type yum-config-manager >/dev/null 2>&1 || - type zypper >/dev/null 2>&1 || return 255 + type yum >/dev/null 2>&1 || type zypper >/dev/null 2>&1 || return 255 local url="$1" local tmp="" local install_path="${GO_XCAT_DEFAULT_INSTALL_PATH}" From 9232e7eac13e12e87bf40b021d58b83ff0b3519a Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Thu, 23 Jun 2016 07:45:54 -0400 Subject: [PATCH 167/310] Fix a typo in the doxcat script to grep ppc64 --- xCAT-genesis-scripts/bin/doxcat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-genesis-scripts/bin/doxcat b/xCAT-genesis-scripts/bin/doxcat index ce51a6792..17d293dc2 100755 --- a/xCAT-genesis-scripts/bin/doxcat +++ b/xCAT-genesis-scripts/bin/doxcat @@ -285,7 +285,7 @@ if [ -e "/dev/rtc" ]; then hwclock --systohc fi HOST_ARCH=`uname -m` -if [ `echo $HOST_ARCH | grep "bac" > /dev/null; echo $?` == 0 ]; then +if [ `echo $HOST_ARCH | grep "ppc64" > /dev/null; echo $?` == 0 ]; then modprobe ipmi_powernv else modprobe ipmi_si From de76ed3b439a88924f850b3139229e3db4acb594 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Thu, 23 Jun 2016 22:09:52 +0800 Subject: [PATCH 168/310] [go-xcat] Add fedora 24 dnf support. Now, go-xcat can work with fedora 24. --- xCAT-server/share/xcat/tools/go-xcat | 68 ++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 8 deletions(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index 8eba3f99e..f5dce83e1 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -390,6 +390,35 @@ function check_package_version() function_dispatch "${FUNCNAME}" "$@" } +# $@ package names +function check_repo_version_dnf() +{ + type dnf >/dev/null 2>&1 || return 255 + local -a name=() + local -a ver=() + while read name ver + do + name+=("${name}") + ver+=("${ver}") + done < <(dnf repoquery -q --qf '%{name} %{version}-%{release}' "$@" 2>/dev/null) + local -i i + while [[ -n "$1" ]] + do + for i in "${!name[@]}" + do + if [[ "$1" = "${name[i]}" ]] + then + echo "${ver[i]}" + unset "name[${i}]" "ver[${i}]" + shift && continue 2 + fi + done + echo "(not found)" + shift + done + return 0 +} + # $@ package names function check_repo_version_yum() { @@ -485,6 +514,15 @@ function check_repo_version() function_dispatch "${FUNCNAME}" "$@" } +# $1 repo id +function get_package_list_dnf() +{ + type dnf >/dev/null 2>&1 || return 255 + local repo_id="$1" + [[ -z "${repo_id}" ]] && return 1 + dnf repoquery -q "--repoid=${repo_id}" --qf "%{name}" 2>/dev/null +} + # $1 repo id function get_package_list_yum() { @@ -900,15 +938,15 @@ function add_xcat_dep_repo_yum_or_zypper() local url="$1" local tmp="" local install_path="${GO_XCAT_DEFAULT_INSTALL_PATH}" - local distro="${GO_XCAT_LINUX_DISTRO}" + local distro="${GO_XCAT_LINUX_DISTRO}${GO_XCAT_LINUX_VERSION%%.*}" case "${distro}" in - "fedora") ;; - "rhel") distro="rh" ;; - "sles") ;; + "fedora2"?) distro="rh7" ;; + "rhel"*) distro="rh${distro#rhel}" ;; + "sles"*) ;; *) warn_if_bad 1 "${distro}: unsupported Linux distro" || return 1 esac [[ -z "${url}" ]] && - url="${GO_XCAT_DEFAULT_BASE_URL}/yum/xcat-dep/${distro}${GO_XCAT_LINUX_VERSION%%.*}/${GO_XCAT_ARCH}/xCAT-dep.repo" + url="${GO_XCAT_DEFAULT_BASE_URL}/yum/xcat-dep/${distro}/${GO_XCAT_ARCH}/xCAT-dep.repo" case "${url##*.}" in "repo") # local repo file add_repo_by_url_yum_or_zypper "${url}" "xcat-dep" @@ -927,7 +965,7 @@ function add_xcat_dep_repo_yum_or_zypper() url="${tmp}" ;; *) - url="${url}/${distro}${GO_XCAT_LINUX_VERSION%%.*}/${GO_XCAT_ARCH}/xCAT-dep.repo" + url="${url}/${distro}/${GO_XCAT_ARCH}/xCAT-dep.repo" add_repo_by_url_yum_or_zypper "${url}" "xcat-dep" return "$?" ;; @@ -948,7 +986,7 @@ function add_xcat_dep_repo_yum_or_zypper() then # make sure it is an absolute pathname. [[ "${url:0:1}" = "/" ]] || url="${PWD}/${url}" - url="${url}/${distro}${GO_XCAT_LINUX_VERSION%%.*}/${GO_XCAT_ARCH}" + url="${url}/${distro}/${GO_XCAT_ARCH}" add_repo_by_url_yum_or_zypper "${url}" "xcat-dep" return "$?" fi @@ -969,6 +1007,12 @@ function add_xcat_dep_repo() function_dispatch "${FUNCNAME}" "$@" } +function update_repo_dnf() +{ + type dnf >/dev/null 2>&1 || return 255 + dnf --nogpgcheck updateinfo /dev/null 2>&1 +} + function update_repo_yum() { type yum >/dev/null 2>&1 || return 255 @@ -992,6 +1036,14 @@ function update_repo() function_dispatch "${FUNCNAME}" "$@" } +function install_packages_dnf() +{ + type dnf >/dev/null 2>&1 || return 255 + local -a args=() + [[ "$1" = "-y" ]] && args=("-y") && shift + dnf --nogpgcheck "${args[@]}" install "$@" +} + function install_packages_yum() { type yum >/dev/null 2>&1 || return 255 @@ -1316,7 +1368,7 @@ Version: ${GO_XCAT_LINUX_VERSION} EOF case "${GO_XCAT_LINUX_DISTRO}" in -"rhel"|"sles"|"ubuntu") +"fedora"|"rhel"|"sles"|"ubuntu") ;; *) warn_if_bad 1 "${GO_XCAT_LINUX_DISTRO}: unsupported Linux distro" From 27f23d33b9237672b7e2e225e054dc514cd09e20 Mon Sep 17 00:00:00 2001 From: Patrick Lundgren Date: Thu, 23 Jun 2016 10:37:50 -0400 Subject: [PATCH 169/310] Handle commas in --range for nmap --- xCAT-server/lib/xcat/plugins/bmcdiscover.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm index 02469dde2..259454659 100644 --- a/xCAT-server/lib/xcat/plugins/bmcdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/bmcdiscover.pm @@ -450,6 +450,8 @@ sub scan_process{ { $method="nmap"; } + # Handle commas in $range for nmap + $range =~ tr/,/ /; my $ip_list; ############################################################ From 668177b82634502c8ca91f7e186a32df57d174e2 Mon Sep 17 00:00:00 2001 From: bybai Date: Thu, 23 Jun 2016 22:07:16 -0400 Subject: [PATCH 170/310] issue1326 rmkit -f essl failed to remove the essl kit --- xCAT-server/lib/xcat/plugins/kit.pm | 6 ------ 1 file changed, 6 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index 81525eaef..357e65b91 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -1636,12 +1636,6 @@ sub rmkit # Remove this component from osimage.kitcomponents. Mark here. my $ret = xCAT::Utils->runxcmd({ command => ['rmkitcomp'], arg => ['-f','-i',$entry->{imagename}, $kitcompname] }, $request_command, 0, 1); - if ( $::RUNCMD_RC ) { - my %rsp; - push@{ $rsp{data} }, "Failed to remove kit component $kitcomponent from $entry->{imagename}"; - xCAT::MsgUtils->message( "E", \%rsp, $callback ); - return 1; - } } } } From 7e0700f1adc0bf37c0dd59d102e1b7b6ebd43790 Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Thu, 23 Jun 2016 22:40:17 -0400 Subject: [PATCH 171/310] update runcmdinstaller case and related bundle files --- xCAT-test/autotest/bundle/rhels6.7_ppc64.bundle | 2 +- xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle | 2 +- xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle | 2 +- xCAT-test/autotest/testcase/runcmdinstaller/cases0 | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/xCAT-test/autotest/bundle/rhels6.7_ppc64.bundle b/xCAT-test/autotest/bundle/rhels6.7_ppc64.bundle index ac261710d..7c2237687 100644 --- a/xCAT-test/autotest/bundle/rhels6.7_ppc64.bundle +++ b/xCAT-test/autotest/bundle/rhels6.7_ppc64.bundle @@ -276,7 +276,7 @@ makentp_V makentp makentp_a nodeset_check_warninginfo -runcmdinstaller +runcmdinstaller_h runcmdinstaller_command get_xcat_postscripts_loginfo updatenode_postscripts_loginfo diff --git a/xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle b/xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle index 2763e12c7..9d4e27652 100644 --- a/xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle +++ b/xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle @@ -276,7 +276,7 @@ makentp_V makentp makentp_a nodeset_check_warninginfo -runcmdinstaller +runcmdinstaller_h runcmdinstaller_command get_xcat_postscripts_loginfo updatenode_postscripts_loginfo diff --git a/xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle b/xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle index ac261710d..7c2237687 100644 --- a/xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle +++ b/xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle @@ -276,7 +276,7 @@ makentp_V makentp makentp_a nodeset_check_warninginfo -runcmdinstaller +runcmdinstaller_h runcmdinstaller_command get_xcat_postscripts_loginfo updatenode_postscripts_loginfo diff --git a/xCAT-test/autotest/testcase/runcmdinstaller/cases0 b/xCAT-test/autotest/testcase/runcmdinstaller/cases0 index 94eb7aacd..f39db8a1a 100644 --- a/xCAT-test/autotest/testcase/runcmdinstaller/cases0 +++ b/xCAT-test/autotest/testcase/runcmdinstaller/cases0 @@ -1,8 +1,8 @@ -start:runcmdinstaller +start:runcmdinstaller_h descriptiop:runcmdinstaller -h -cmd:runcmdinstaller -##check:rc==0 -check:output=~runcmdinstaller "" +cmd:runcmdinstaller -h +check:rc==0 +check:output=~runcmdinstaller end start:runcmdinstaller_command descriptiop:runcmdinstaller From a9249a25a5103923b90f632db344a17893131ab9 Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Thu, 23 Jun 2016 22:41:20 -0400 Subject: [PATCH 172/310] update bundle file --- xCAT-test/autotest/bundle/p_rhels_cmd.bundle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-test/autotest/bundle/p_rhels_cmd.bundle b/xCAT-test/autotest/bundle/p_rhels_cmd.bundle index 02e1164b2..32095c6cc 100644 --- a/xCAT-test/autotest/bundle/p_rhels_cmd.bundle +++ b/xCAT-test/autotest/bundle/p_rhels_cmd.bundle @@ -275,7 +275,7 @@ makentp_V makentp makentp_a nodeset_check_warninginfo -runcmdinstaller +runcmdinstaller_h runcmdinstaller_command get_xcat_postscripts_loginfo updatenode_postscripts_loginfo From 75bc7d91f43a07a64a1a34e3c6944f597f938043 Mon Sep 17 00:00:00 2001 From: ertaozh Date: Fri, 24 Jun 2016 01:58:34 -0400 Subject: [PATCH 173/310] refine hardware discovery framework, put mtms based hardware discovery to typemtms.pm module --- xCAT-genesis-scripts/bin/dodiscovery | 13 +++- xCAT-server/lib/perl/xCAT/PPC.pm | 48 +------------ xCAT-server/lib/xcat/plugins/aaadiscovery.pm | 38 ++++++++++ xCAT-server/lib/xcat/plugins/blade.pm | 9 +++ xCAT-server/lib/xcat/plugins/fsp.pm | 1 - xCAT-server/lib/xcat/plugins/hpblade.pm | 9 +++ xCAT-server/lib/xcat/plugins/profilednodes.pm | 8 +++ xCAT-server/lib/xcat/plugins/seqdiscovery.pm | 36 ++++++---- xCAT-server/lib/xcat/plugins/switch.pm | 32 ++++++--- xCAT-server/lib/xcat/plugins/typemtms.pm | 71 +++++++++++++++++++ xCAT-server/lib/xcat/plugins/zzzdiscovery.pm | 34 +++++++++ 11 files changed, 227 insertions(+), 72 deletions(-) create mode 100644 xCAT-server/lib/xcat/plugins/aaadiscovery.pm create mode 100644 xCAT-server/lib/xcat/plugins/typemtms.pm create mode 100644 xCAT-server/lib/xcat/plugins/zzzdiscovery.pm diff --git a/xCAT-genesis-scripts/bin/dodiscovery b/xCAT-genesis-scripts/bin/dodiscovery index 3d5e3c522..5148e1dab 100755 --- a/xCAT-genesis-scripts/bin/dodiscovery +++ b/xCAT-genesis-scripts/bin/dodiscovery @@ -91,7 +91,9 @@ elif [ -r /proc/device-tree/model ]; then #POWER done CPUTYPE=`cat /tmp/cpumod|awk -F':' '{print $2}'|sed -e 's/^ //'` SERIAL=`cat /proc/device-tree/system-id -vT | sed -e 's/^.*,//' | sed -e 's/^[\t ]*//'| sed -e 's/[\t ]*\^@//'` - UUID=`sed -e 's/\(..\)\(..\)\(..\)\(..\)-\(..\)\(..\)-\(..\)\(..\)/\4\3\2\1-\6\5-\8\7/' /proc/sys/kernel/random/uuid` + # For POWER servers, the /proc/sys/kernel/random/uuid is changing for each query, so use mtms + mac of first up nic as the UUID + #UUID=`sed -e 's/\(..\)\(..\)\(..\)\(..\)-\(..\)\(..\)-\(..\)\(..\)/\4\3\2\1-\6\5-\8\7/' /proc/sys/kernel/random/uuid` + UUID=unknown fi #CPUCOUNT=`cat /proc/cpuinfo |grep "model name"|wc -l` @@ -115,6 +117,7 @@ DISKSIZE=`cat /proc/partitions |grep -e "sd.\>" |awk -F' ' '{printf "%s:%.0fGB\n logger -t $log_label -p local4.info "Beginning echo infomation to discovery packet file..." echo '' > /tmp/discopacket echo "findme" >> /tmp/discopacket +echo "1" >> /tmp/discopacket echo "$ARCH" >> /tmp/discopacket if [ "$IAMAVM" = 1 ]; then echo "virtual" >> /tmp/discopacket @@ -166,6 +169,7 @@ if [ -f "/usr/sbin/dmidecode" ]; then fi done fi +MAC_OF_FIRST_UP_NIC=unknown #TODO: downed nics, also examine /sys/bus/pci/*/ for more network class devices that might not have driver suppert for dev in `ip link|grep -B1 ether|grep UP|awk '{print $2}'|sed -e s/://|grep -v usb0`; do FIRMDESC="" @@ -174,6 +178,9 @@ for dev in `ip link|grep -B1 ether|grep UP|awk '{print $2}'|sed -e s/://|grep -v PCI_SLOT=`grep PCI_SLOT_NAME /sys/class/net/$dev/device/uevent|awk -F= '{print $2}'` ADDRESS=`ip address show dev $dev|grep "inet "|grep global|awk '{print $2}'` MAC=`ip link show dev $dev|grep ether|awk '{print $2}'| tr /a-f/ /A-F/` + if [ "$MAC_OF_FIRST_UP_NIC" == "unknown" ]; then + MAC_OF_FIRST_UP_NIC=`echo $MAC | sed -e s/://g` + fi if [[ ! -z "$PCI_SLOT" && -f "/usr/sbin/dmidecode" ]]; then SLOTNAME=`dmidecode -t 9|egrep '(Designation|Address)'|grep -B1 $PCI_SLOT|grep Designation|sed -e 's/.*Designation:[ ]*//'` if [ -z "$SLOTNAME" ]; then #check for on board device @@ -234,6 +241,10 @@ for dev in `ip link|grep -B1 ether|grep UP|awk '{print $2}'|sed -e s/://|grep -v echo "" >> /tmp/discopacket done +if [ "$UUID" == "unknown" ]; then + UUID=`echo $MTM-$SERIAL-$MAC_OF_FIRST_UP_NIC | tr /A-Z/ /a-z/` + echo "$UUID" >> /tmp/discopacket +fi echo "$PUBKEY" >> /tmp/discopacket #this is not secure to use by itself, switch sourced pubkey for security echo "" >> /tmp/discopacket echo "" >> /tmp/discopacket diff --git a/xCAT-server/lib/perl/xCAT/PPC.pm b/xCAT-server/lib/perl/xCAT/PPC.pm index 9c7c3ba52..afd458a39 100644 --- a/xCAT-server/lib/perl/xCAT/PPC.pm +++ b/xCAT-server/lib/perl/xCAT/PPC.pm @@ -2135,44 +2135,7 @@ sub parse_args } -sub findme { - my $request = shift; - my $callback = shift; - my $subreq = shift; - if (!defined $request->{'mtm'} or !defined $request->{'serial'}) { - xCAT::MsgUtils->message("S", "Discovery Error: 'mtm' or 'serial' not found."); - return; - } - my @attr_array = (); - my $mtms = $request->{'mtm'}->[0]."*".$request->{'serial'}->[0]; - my $tmp_nodes = $::XCATVPDHASH{$mtms}; - my @nodes = (); - my $pbmc_node; - foreach (@$tmp_nodes) { - if ($::XCATMPHASH{$_}) { - $pbmc_node = $_; - } else { - push @nodes, $_; - } - } - my $nodenum = $#nodes; - if ($nodenum < 0) { - xCAT::MsgUtils->message("S", "Discovery Error: Could not find any node."); - return; - } elsif ($nodenum > 0) { - xCAT::MsgUtils->message("S", "Discovery Error: More than one node were found."); - return; - } - { - my $req = {%$request}; - $req->{command} = ['discovered']; - $req->{noderange} = [$nodes[0]]; - $req->{pbmc_node} = [$pbmc_node]; - $req->{discoverymethod} = ['mtms']; - $subreq->($req); - %{$req} = (); - } -} + ########################################################################## # Process request from xCat daemon @@ -2188,15 +2151,6 @@ sub process_request { # Get hwtype #################################### $package =~ s/xCAT_plugin:://; - - #################################### - # Deal with findme request - #################################### - if ($req->{command}->[0] eq 'findme') { - # Need to support both ppc64 and ppc64le, maybe also x86_64. Will be move out later. - &findme($req, $callback, $subreq); - return; - } #################################### # Build hash to pass around #################################### diff --git a/xCAT-server/lib/xcat/plugins/aaadiscovery.pm b/xCAT-server/lib/xcat/plugins/aaadiscovery.pm new file mode 100644 index 000000000..23a74091b --- /dev/null +++ b/xCAT-server/lib/xcat/plugins/aaadiscovery.pm @@ -0,0 +1,38 @@ +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html +package xCAT_plugin::aaadiscovery; +BEGIN +{ + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; +} +use lib "$::XCATROOT/lib/perl"; +use xCAT::DiscoveryUtils; + +sub handled_commands { + return { + findme => 'aaadiscovery', + }; +} + +sub process_request { + my $req = shift; + my $cb = shift; + my $doreq = shift; + if ($req->{command}->[0] eq 'findme') { + # The findme request is supposed to be dealt with in the first loop that cacheonly attribute is set for a request + if (!($req->{cacheonly}) or !($req->{cacheonly}->[0])) { + return; + } + if (defined($req->{discoverymethod}) and defined($req->{discoverymethod}->[0])) { + my $rsp = {}; + $rsp->{error}->[0] = "The findme request had been processed by ".$req->{discoverymethod}->[0] ." module"; + $cb->($rsp); + return; + } + xCAT::MsgUtils->message("S", __PACKAGE__.": Processing findme request, writting it into 'discoverydata' table"); + $req->{discoverymethod}->[0] = 'undef'; + xCAT::DiscoveryUtils->update_discovery_data($req); + return; + } +} + +1; diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index b34da65aa..bca8d4cb4 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -4359,6 +4359,15 @@ sub process_request { } } if ($request->{command}->[0] eq "findme") { + # The findme request is supposed to be dealt with in the first loop that cacheonly attribute is set for a request + if (!($request->{cacheonly}) or !($request->{cacheonly}->[0])) { + return; + } + if (defined($request->{discoverymethod}) and defined($request->{discoverymethod}->[0])) { + # The findme request had been processed by other module, just return + return; + } + my $mptab = xCAT::Table->new("mp"); unless ($mptab) { return 2; } my @bladents = $mptab->getAllNodeAttribs([qw(node)]); diff --git a/xCAT-server/lib/xcat/plugins/fsp.pm b/xCAT-server/lib/xcat/plugins/fsp.pm index 9726685b6..53708d120 100644 --- a/xCAT-server/lib/xcat/plugins/fsp.pm +++ b/xCAT-server/lib/xcat/plugins/fsp.pm @@ -32,7 +32,6 @@ sub handled_commands { rscan => 'nodehm:mgt', getfspcon => 'nodehm:cons', getmulcon => 'fsp', - findme => 'fsp', }; } diff --git a/xCAT-server/lib/xcat/plugins/hpblade.pm b/xCAT-server/lib/xcat/plugins/hpblade.pm index 156de8071..76b257abc 100755 --- a/xCAT-server/lib/xcat/plugins/hpblade.pm +++ b/xCAT-server/lib/xcat/plugins/hpblade.pm @@ -685,6 +685,15 @@ sub process_request { } } if ($request->{command}->[0] eq "findme") { + # The findme request is supposed to be dealt with in the first loop that cacheonly attribute is set for a request + if (!($request->{cacheonly}) or !($request->{cacheonly}->[0])) { + return; + } + if (defined($request->{discoverymethod}) and defined($request->{discoverymethod}->[0])) { + # The findme request had been processed by other module, just return + return; + } + my $mptab = xCAT::Table->new("mp"); unless ($mptab) { return 2; } my @bladents = $mptab->getAllNodeAttribs([qw(node)]); diff --git a/xCAT-server/lib/xcat/plugins/profilednodes.pm b/xCAT-server/lib/xcat/plugins/profilednodes.pm index 69067866a..818da4c21 100644 --- a/xCAT-server/lib/xcat/plugins/profilednodes.pm +++ b/xCAT-server/lib/xcat/plugins/profilednodes.pm @@ -1816,6 +1816,14 @@ Usage: #------------------------------------------------------- sub findme{ + # The findme request is supposed to be dealt with in the first loop that cacheonly attribute is set for a request + if (!($request->{cacheonly}) or !($request->{cacheonly}->[0])) { + return; + } + if (defined($request->{discoverymethod}) and defined($request->{discoverymethod}->[0])) { + # The findme request had been processed by other module, just return + return; + } # re-initalize the global variable %args_dict = (); # Read DB to confirm the discover is started. diff --git a/xCAT-server/lib/xcat/plugins/seqdiscovery.pm b/xCAT-server/lib/xcat/plugins/seqdiscovery.pm index dad597b05..64a0e8138 100755 --- a/xCAT-server/lib/xcat/plugins/seqdiscovery.pm +++ b/xCAT-server/lib/xcat/plugins/seqdiscovery.pm @@ -50,17 +50,27 @@ sub findme { my $request = shift; my $callback = shift; my $subreq = shift; - + my @SEQdiscover = xCAT::TableUtils->get_site_attribute("__SEQDiscover"); my @PCMdiscover = xCAT::TableUtils->get_site_attribute("__PCMDiscover"); + + # The findme request is supposed to be dealt with in the first loop that cacheonly attribute is set for a request + if (!($request->{cacheonly}) or !($request->{cacheonly}->[0])) { + return; + } + if (defined($request->{discoverymethod}) and defined($request->{discoverymethod}->[0])) { + # The findme request had been processed by other module, just return + return; + } unless ($SEQdiscover[0]) { - if ($PCMdiscover[0]) { + #if ($PCMdiscover[0]) { #profile disocvery is running, then just return to make profile discovery to handle it - return; - } + #return; + #} + # The request data have been write into discoverydata table within aaadiscover.pm, just return here # update the discoverydata table to have an undefined node - $request->{discoverymethod}->[0] = 'undef'; - xCAT::DiscoveryUtils->update_discovery_data($request); + #$request->{discoverymethod}->[0] = 'undef'; + #xCAT::DiscoveryUtils->update_discovery_data($request); return; } @@ -375,16 +385,18 @@ sub findme { # call the discovered command to update the discovery request to a node - $request->{command}=['discovered']; - $request->{noderange} = [$node]; + xCAT::MsgUtils->message("S", __PACKAGE__.": Find a node for the findme request"); + $request->{discoverymethod} = ['sequential']; + my $req = {%$request}; + $req->{command}=['discovered']; + $req->{noderange} = [$node]; if ($pbmc_node) { $request->{pbmc_node} = [$pbmc_node]; } - $request->{discoverymethod} = ['sequential']; - $request->{updateswitch} = ['yes']; - $subreq->($request); - %{$request}=();#Clear req structure, it's done.. + $req->{updateswitch} = ['yes']; + $subreq->($req); + %{$req}=();#Clear req structure, it's done.. undef $mactab; } else { nodediscoverstop($callback, undef, "node names"); diff --git a/xCAT-server/lib/xcat/plugins/switch.pm b/xCAT-server/lib/xcat/plugins/switch.pm index 1ae78f71a..ce47596be 100644 --- a/xCAT-server/lib/xcat/plugins/switch.pm +++ b/xCAT-server/lib/xcat/plugins/switch.pm @@ -268,6 +268,15 @@ sub process_request { } return; } elsif ($req->{command}->[0] eq 'findme') { + # The findme request is supposed to be dealt with in the first loop that cacheonly attribute is set for a request + if (!($req->{cacheonly}) or !($req->{cacheonly}->[0])) { + return; + } + if (defined($req->{discoverymethod}) and defined($req->{discoverymethod}->[0])) { + # The findme request had been processed by other module, just return + return; + } + xCAT::MsgUtils->message("S", __PACKAGE__.": Processing findme request"); my $ip = $req->{'_xcat_clientip'}; if (defined $req->{nodetype} and $req->{nodetype}->[0] eq 'virtual') { #Don't attempt switch discovery of a VM Guest @@ -317,22 +326,23 @@ sub process_request { } if ($node) { - my $mactab = xCAT::Table->new('mac',-create=>1); - $mactab->setNodeAttribs($node,{mac=>$mac}); - $mactab->close(); + xCAT::MsgUtils->message("S", __PACKAGE__.": Find a node for the findme request"); + # No need to write mac table here, 'discovered' command will write + # my $mactab = xCAT::Table->new('mac',-create=>1); + # $mactab->setNodeAttribs($node,{mac=>$mac}); + # $mactab->close(); #my %request = ( # command => ['makedhcp'], # node => [$node] #); #$doreq->(\%request); - $req->{command}=['discovered']; - $req->{noderange} = [$node]; - if ($pbmc_node) { - $req->{pbmc_node} = [$pbmc_node]; - } - $req->{discoverymethod} = ['switch']; - $doreq->($req); - %{$req}=();#Clear req structure, it's done.. + $req->{discoverymethod}->[0] = 'switch'; + my $request = {%$req}; + $request->{command}=['discovered']; + $request->{noderange} = [$node]; + $request->{pbmc_node} = [$pbmc_node]; + $doreq->($request); + %{$request}=();#Clear req structure, it's done.. undef $mactab; } else { #Shouldn't complain, might be blade, but how to log total failures? diff --git a/xCAT-server/lib/xcat/plugins/typemtms.pm b/xCAT-server/lib/xcat/plugins/typemtms.pm new file mode 100644 index 000000000..63c69b492 --- /dev/null +++ b/xCAT-server/lib/xcat/plugins/typemtms.pm @@ -0,0 +1,71 @@ +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html +package xCAT_plugin::typemtms; +BEGIN +{ + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; +} +use lib "$::XCATROOT/lib/perl"; + +sub handled_commands { + return { + findme => 'typemtms', + }; +} +sub findme { + my $request = shift; + my $callback = shift; + my $subreq = shift; + if (!defined $request->{'mtm'} or !defined $request->{'serial'}) { + xCAT::MsgUtils->message("S", "Discovery Error: 'mtm' or 'serial' not found."); + return; + } + my @attr_array = (); + my $mtms = $request->{'mtm'}->[0]."*".$request->{'serial'}->[0]; + my $tmp_nodes = $::XCATVPDHASH{$mtms}; + my @nodes = (); + my $pbmc_node; + foreach (@$tmp_nodes) { + if ($::XCATMPHASH{$_}) { + $pbmc_node = $_; + } else { + push @nodes, $_; + } + } + my $nodenum = $#nodes; + if ($nodenum < 0) { + xCAT::MsgUtils->message("S", "Discovery Error: Could not find any node."); + return; + } elsif ($nodenum > 0) { + xCAT::MsgUtils->message("S", "Discovery Error: More than one node were found."); + return; + } + { + xCAT::MsgUtils->message("S", __PACKAGE__.": Find a node for the findme request"); + $request->{discoverymethod}->[0] = 'mtms'; + my $req = {%$request}; + $req->{command} = ['discovered']; + $req->{noderange} = [$nodes[0]]; + $req->{pbmc_node} = [$pbmc_node]; + $subreq->($req); + %{$req} = (); + } +} +sub process_request { + my $req = shift; + my $cb = shift; + my $doreq = shift; + if ($req->{command}->[0] eq 'findme') { + # The findme request is supposed to be dealt with in the first loop that cacheonly attribute is set for a request + if (!($req->{cacheonly}) or !($req->{cacheonly}->[0])) { + return; + } + if (defined($req->{discoverymethod}) and defined($req->{discoverymethod}->[0])) { + # The findme request had been processed by other module, just return + return; + } + xCAT::MsgUtils->message("S", __PACKAGE__.": Processing findme request"); + &findme($req, $callback, $doreq); + return; + } +} +1; diff --git a/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm b/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm new file mode 100644 index 000000000..8de0e5eaa --- /dev/null +++ b/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm @@ -0,0 +1,34 @@ +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html +package xCAT_plugin::zzzdiscovery; +BEGIN +{ + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; +} +use lib "$::XCATROOT/lib/perl"; + +sub handled_commands { + return { + findme => 'zzzdiscovery', + }; +} +sub process_request { + my $req = shift; + my $cb = shift; + my $doreq = shift; + if ($req->{command}->[0] eq 'findme') { + # The findme request is supposed to be dealt with in the first loop that cacheonly attribute is set for a request + if (!($req->{cacheonly}) or !($req->{cacheonly}->[0])) { + return; + } + xCAT::MsgUtils->message("S", __PACKAGE__.": Processing findme request"); + if (!defined($req->{discoverymethod}) or !defined($req->{discoverymethod}->[0])) { + my $rsp = {}; + $rsp->{error}->[0] = "The findme request can not be processed"; + $cb->($rsp); + return; + } + xCAT::MsgUtils->message("S", __PACKAGE__.": This findme request had been processed by $req->{discoverymethod}->[0] module"); + return; + } +} +1; From 3e57820ee6f6a68edb02fc790f7887c8a8e9dd20 Mon Sep 17 00:00:00 2001 From: wangxiaopeng Date: Fri, 24 Jun 2016 02:02:50 -0400 Subject: [PATCH 174/310] issue 1361: check the export sentence in the mypostscript to make sure no - is used in the variable name --- xCAT-server/lib/perl/xCAT/Postage.pm | 21 ++++++++++++++++++++- xCAT-server/lib/xcat/plugins/updatenode.pm | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/Postage.pm b/xCAT-server/lib/perl/xCAT/Postage.pm index 6fac85cb1..46c1b93a3 100644 --- a/xCAT-server/lib/perl/xCAT/Postage.pm +++ b/xCAT-server/lib/perl/xCAT/Postage.pm @@ -570,6 +570,7 @@ sub makescript { # This line only is used to compatible with the old code $inc =~ s/#Subroutine:([^:]+)::([^:]+)::([^:]+):([^#]+)#/runsubroutine($1,$2,$3,$4)/eg; + # we will create a file in /tftboot/mypostscript/mypostscript_ if ((!defined($nofiles)) || ($nofiles == 0)) { # my $script; @@ -596,7 +597,25 @@ sub makescript { close($script_fp{$node}); # TODO remove the blank lines } - + + # Check the validity of new generated mypostscirpt + # export does not support - in the environment variable name + my @invalid_var_name; + foreach my $line (split(/\n/, $inc)) { + if ($line =~ /export +(.*)/) { + my $varname = $1; + if ($varname =~ /-/) { + push @invalid_var_name, $varname; + } + } + } + if (@invalid_var_name) { + my $rsp; + push @{$rsp->{data}}, "In your configuration, the invalid charactor '-' is used in the following names: " . join(',', @invalid_var_name); + xCAT::MsgUtils->message("E", $rsp, $callback); + push @::exclude_nodes, $node; + } + } #end foreach node undef(%::GLOBAL_TAB_HASH); diff --git a/xCAT-server/lib/xcat/plugins/updatenode.pm b/xCAT-server/lib/xcat/plugins/updatenode.pm index fdd503bc5..0e0dbe1ae 100644 --- a/xCAT-server/lib/xcat/plugins/updatenode.pm +++ b/xCAT-server/lib/xcat/plugins/updatenode.pm @@ -1242,7 +1242,7 @@ sub updatenode if (@exclude_nodes > 0) { my $rsp = {}; $rsp->{error}->[0] = - "Following nodes will be ignored bacause they are missing some attribute definitions: @exclude_nodes"; + "Following nodes will be ignored bacause they are missing some attributes or have incorrect configuration: @exclude_nodes"; $rsp->{errorcode}->[0] =1; $callback->($rsp); } From 0e606e2b6ac315098a0a4fa01bb34987cbc94413 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Fri, 24 Jun 2016 14:35:20 +0800 Subject: [PATCH 175/310] [go-xcat] Add better support for earlier Fedora Linux release. And add CentOS Linux support. --- xCAT-server/share/xcat/tools/go-xcat | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index f5dce83e1..458877d0c 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -940,9 +940,12 @@ function add_xcat_dep_repo_yum_or_zypper() local install_path="${GO_XCAT_DEFAULT_INSTALL_PATH}" local distro="${GO_XCAT_LINUX_DISTRO}${GO_XCAT_LINUX_VERSION%%.*}" case "${distro}" in - "fedora2"?) distro="rh7" ;; - "rhel"*) distro="rh${distro#rhel}" ;; - "sles"*) ;; + "centos"*) distro="rh${distro#centos}" ;; + "fedora10"|"fedora11") distro="fedora9" ;; + "fedora1"[678]) distro="rh6" ;; + "fedora19"|"fedora2"?) distro="rh7" ;; + "rhel"*) distro="rh${distro#rhel}" ;; + "sles"*) ;; *) warn_if_bad 1 "${distro}: unsupported Linux distro" || return 1 esac [[ -z "${url}" ]] && @@ -1368,7 +1371,7 @@ Version: ${GO_XCAT_LINUX_VERSION} EOF case "${GO_XCAT_LINUX_DISTRO}" in -"fedora"|"rhel"|"sles"|"ubuntu") +"centos"|"fedora"|"rhel"|"sles"|"ubuntu") ;; *) warn_if_bad 1 "${GO_XCAT_LINUX_DISTRO}: unsupported Linux distro" From 00584f537081ffb93f8a325f94a233a02551c7cf Mon Sep 17 00:00:00 2001 From: immarvin Date: Fri, 24 Jun 2016 03:44:11 -0400 Subject: [PATCH 176/310] fix issue [Customer] bootloader is not grabbing the addkcmdline from osimage #1185 --- xCAT-server/lib/perl/xCAT/Template.pm | 15 +++++++-- .../xcat/install/centos/compute.centos6.tmpl | 2 +- .../xcat/install/centos/compute.centos7.tmpl | 4 +-- .../xcat/install/centos/kvm.centos6.tmpl | 2 +- .../xcat/install/fedora/compute.fedora19.tmpl | 2 +- .../xcat/install/fedora/compute.fedora20.tmpl | 2 +- .../xcat/install/fedora/compute.fedora21.tmpl | 2 +- .../install/pkvm/compute.pkvm3.ppc64le.tmpl | 2 +- .../xcat/install/rh/compute.rhelhpc6.tmpl | 2 +- .../share/xcat/install/rh/compute.rhels6.tmpl | 2 +- .../install/rh/compute.rhels6.x86_64.tmpl | 2 +- .../share/xcat/install/rh/compute.rhels7.tmpl | 4 +-- .../xcat/install/rh/compute_ad.rhels6.tmpl | 2 +- .../share/xcat/install/rh/hpc.rhels6.tmpl | 2 +- .../share/xcat/install/rh/kvm.rhels6.tmpl | 2 +- .../share/xcat/install/rh/kvm.rhels7.tmpl | 2 +- .../install/rh/service.rhels6.x86_64.tmpl | 2 +- .../share/xcat/install/rh/service.rhels7.tmpl | 4 +-- .../share/xcat/install/scripts/pre.pkvm3 | 4 +-- xCAT-server/share/xcat/install/scripts/pre.rh | 14 ++++---- .../share/xcat/install/scripts/pre.rh.rhels7 | 32 ++++++++++++------- 21 files changed, 61 insertions(+), 44 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index 3d4225a06..9f584ab9f 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -370,10 +370,9 @@ sub subvars { #for redhat/sl/centos/kvm/fedora if ($inc =~ /#XCAT_PARTITION_START#/) { - my $tempstr = "%include /tmp/partitionfile\n"; - $inc =~ s/#XCAT_PARTITION_START#[\s\S]*#XCAT_PARTITION_END#/$tempstr/; # Put the base64 coded partitionfile into %pre part $partcontent = "cat > /tmp/partscript.enc << EOFEOF\n" . $partcontent . "\nEOFEOF\n"; + $partcontent .= "rm -rf /tmp/partitionfile\n"; # Put the code to decode the partitionfile $partcontent .= "python -c 'import base64; print base64.b64decode(open(\"/tmp/partscript.enc\",\"rb\").read())' >/tmp/partscript\n"; $partcontent .= "chmod 755 /tmp/partscript\n"; @@ -416,7 +415,17 @@ sub subvars { else{ $partcontent =~ s/\s$//; if ($inc =~ /#XCAT_PARTITION_START#/){ - $inc =~ s/#XCAT_PARTITION_START#[\s\S]*#XCAT_PARTITION_END#/$partcontent/; + # %pre and decode it out during the running time. + use MIME::Base64; + $partcontent = encode_base64($partcontent); + $partcontent =~ s/\n//g; + # Put the base64 coded partitionfile into %pre part + $partcontent = "cat > /tmp/partitionfile.enc << EOFEOF\n" . $partcontent . "\nEOFEOF\n"; + $partcontent .= "rm -rf /tmp/partitionfile\n"; + # Put the code to decode the partitionfile + $partcontent .= "python -c 'import base64; print base64.b64decode(open(\"/tmp/partitionfile.enc\",\"rb\").read())' >/tmp/partitionfile\n"; + #replace the #XCA_PARTITION_SCRIPT# + $inc =~ s/#XCA_PARTITION_SCRIPT#/$partcontent/; } elsif ($inc =~ //){ $inc =~ s/[\s\S]*/$partcontent/; diff --git a/xCAT-server/share/xcat/install/centos/compute.centos6.tmpl b/xCAT-server/share/xcat/install/centos/compute.centos6.tmpl index 12b3e64f4..ae594f700 100644 --- a/xCAT-server/share/xcat/install/centos/compute.centos6.tmpl +++ b/xCAT-server/share/xcat/install/centos/compute.centos6.tmpl @@ -33,7 +33,7 @@ clearpart --all --initlabel #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #XCAT_PARTITION_END# #RAID 0 /scr for performance diff --git a/xCAT-server/share/xcat/install/centos/compute.centos7.tmpl b/xCAT-server/share/xcat/install/centos/compute.centos7.tmpl index 04240e78e..d48755fe0 100644 --- a/xCAT-server/share/xcat/install/centos/compute.centos7.tmpl +++ b/xCAT-server/share/xcat/install/centos/compute.centos7.tmpl @@ -35,7 +35,7 @@ clearpart --all --initlabel #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #part swap --size 1024 #part / --size 1 --grow --fstype ext4 #XCAT_PARTITION_END# @@ -79,7 +79,7 @@ clearpart --all --initlabel #The bootloader config here is commented out #For user customized partition file or partition script, #the bootloader configuration should be specified in the user customized partition file/script -#For the xCAT default partition scheme, the bootloader configuration is in /tmp/partitioning +#For the xCAT default partition scheme, the bootloader configuration is in /tmp/partitionfile #which is generated in %pre section ##KICKSTARTBOOTLOADER# diff --git a/xCAT-server/share/xcat/install/centos/kvm.centos6.tmpl b/xCAT-server/share/xcat/install/centos/kvm.centos6.tmpl index 72e8f16c9..bba1f46b0 100644 --- a/xCAT-server/share/xcat/install/centos/kvm.centos6.tmpl +++ b/xCAT-server/share/xcat/install/centos/kvm.centos6.tmpl @@ -31,7 +31,7 @@ clearpart --all --initlabel #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #XCAT_PARTITION_END# #RAID 0 /scr for performance diff --git a/xCAT-server/share/xcat/install/fedora/compute.fedora19.tmpl b/xCAT-server/share/xcat/install/fedora/compute.fedora19.tmpl index c7dbef826..d023171a4 100644 --- a/xCAT-server/share/xcat/install/fedora/compute.fedora19.tmpl +++ b/xCAT-server/share/xcat/install/fedora/compute.fedora19.tmpl @@ -35,7 +35,7 @@ clearpart --all --initlabel #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #XCAT_PARTITION_END# #RAID 0 /scr for performance diff --git a/xCAT-server/share/xcat/install/fedora/compute.fedora20.tmpl b/xCAT-server/share/xcat/install/fedora/compute.fedora20.tmpl index c7dbef826..d023171a4 100644 --- a/xCAT-server/share/xcat/install/fedora/compute.fedora20.tmpl +++ b/xCAT-server/share/xcat/install/fedora/compute.fedora20.tmpl @@ -35,7 +35,7 @@ clearpart --all --initlabel #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #XCAT_PARTITION_END# #RAID 0 /scr for performance diff --git a/xCAT-server/share/xcat/install/fedora/compute.fedora21.tmpl b/xCAT-server/share/xcat/install/fedora/compute.fedora21.tmpl index f3b3d2416..5462e1304 100644 --- a/xCAT-server/share/xcat/install/fedora/compute.fedora21.tmpl +++ b/xCAT-server/share/xcat/install/fedora/compute.fedora21.tmpl @@ -35,7 +35,7 @@ clearpart --all --initlabel #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #XCAT_PARTITION_END# #RAID 0 /scr for performance diff --git a/xCAT-server/share/xcat/install/pkvm/compute.pkvm3.ppc64le.tmpl b/xCAT-server/share/xcat/install/pkvm/compute.pkvm3.ppc64le.tmpl index ca50f7631..b6e72556d 100644 --- a/xCAT-server/share/xcat/install/pkvm/compute.pkvm3.ppc64le.tmpl +++ b/xCAT-server/share/xcat/install/pkvm/compute.pkvm3.ppc64le.tmpl @@ -31,7 +31,7 @@ rootpw --iscrypted #CRYPT:passwd:key=system,username=root:password# #XCAT_PARTITION_START# -%include /tmp/partitioning +%include /tmp/partitionfile #XCAT_PARTITION_END# %pre diff --git a/xCAT-server/share/xcat/install/rh/compute.rhelhpc6.tmpl b/xCAT-server/share/xcat/install/rh/compute.rhelhpc6.tmpl index 5e550a79c..8d2ab086d 100644 --- a/xCAT-server/share/xcat/install/rh/compute.rhelhpc6.tmpl +++ b/xCAT-server/share/xcat/install/rh/compute.rhelhpc6.tmpl @@ -33,7 +33,7 @@ key --skip #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #part swap --size 1024 #part / --size 1 --grow --fstype ext4 #XCAT_PARTITION_END# diff --git a/xCAT-server/share/xcat/install/rh/compute.rhels6.tmpl b/xCAT-server/share/xcat/install/rh/compute.rhels6.tmpl index 3d9ec8f2a..a466a2cc3 100644 --- a/xCAT-server/share/xcat/install/rh/compute.rhels6.tmpl +++ b/xCAT-server/share/xcat/install/rh/compute.rhels6.tmpl @@ -34,7 +34,7 @@ key --skip #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #part swap --size 1024 #part / --size 1 --grow --fstype ext4 #XCAT_PARTITION_END# diff --git a/xCAT-server/share/xcat/install/rh/compute.rhels6.x86_64.tmpl b/xCAT-server/share/xcat/install/rh/compute.rhels6.x86_64.tmpl index f0934b98c..32f356a45 100644 --- a/xCAT-server/share/xcat/install/rh/compute.rhels6.x86_64.tmpl +++ b/xCAT-server/share/xcat/install/rh/compute.rhels6.x86_64.tmpl @@ -37,7 +37,7 @@ key --skip #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #XCAT_PARTITION_END# #RAID 0 /scr for performance diff --git a/xCAT-server/share/xcat/install/rh/compute.rhels7.tmpl b/xCAT-server/share/xcat/install/rh/compute.rhels7.tmpl index c049da798..1c346428d 100644 --- a/xCAT-server/share/xcat/install/rh/compute.rhels7.tmpl +++ b/xCAT-server/share/xcat/install/rh/compute.rhels7.tmpl @@ -34,7 +34,7 @@ clearpart --all --initlabel #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #part swap --size 1024 #part / --size 1 --grow --fstype ext4 #XCAT_PARTITION_END# @@ -78,7 +78,7 @@ clearpart --all --initlabel #The bootloader config here is commented out #For user customized partition file or partition script, #the bootloader configuration should be specified in the user customized partition file/script -#For the xCAT default partition scheme, the bootloader configuration is in /tmp/partitioning +#For the xCAT default partition scheme, the bootloader configuration is in /tmp/partitionfile #which is generated in %pre section ##KICKSTARTBOOTLOADER# diff --git a/xCAT-server/share/xcat/install/rh/compute_ad.rhels6.tmpl b/xCAT-server/share/xcat/install/rh/compute_ad.rhels6.tmpl index d44bf0d8e..4b89b4c77 100644 --- a/xCAT-server/share/xcat/install/rh/compute_ad.rhels6.tmpl +++ b/xCAT-server/share/xcat/install/rh/compute_ad.rhels6.tmpl @@ -33,7 +33,7 @@ key --skip #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #part swap --size 1024 #part / --size 1 --grow --fstype ext4 #XCAT_PARTITION_END# diff --git a/xCAT-server/share/xcat/install/rh/hpc.rhels6.tmpl b/xCAT-server/share/xcat/install/rh/hpc.rhels6.tmpl index 5e550a79c..8d2ab086d 100644 --- a/xCAT-server/share/xcat/install/rh/hpc.rhels6.tmpl +++ b/xCAT-server/share/xcat/install/rh/hpc.rhels6.tmpl @@ -33,7 +33,7 @@ key --skip #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #part swap --size 1024 #part / --size 1 --grow --fstype ext4 #XCAT_PARTITION_END# diff --git a/xCAT-server/share/xcat/install/rh/kvm.rhels6.tmpl b/xCAT-server/share/xcat/install/rh/kvm.rhels6.tmpl index ad0e932f9..cdf799122 100644 --- a/xCAT-server/share/xcat/install/rh/kvm.rhels6.tmpl +++ b/xCAT-server/share/xcat/install/rh/kvm.rhels6.tmpl @@ -35,7 +35,7 @@ key --skip #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #part swap --size 1024 #part / --size 1 --grow --fstype ext4 #XCAT_PARTITION_END# diff --git a/xCAT-server/share/xcat/install/rh/kvm.rhels7.tmpl b/xCAT-server/share/xcat/install/rh/kvm.rhels7.tmpl index 302bf8cc5..338cdc5da 100644 --- a/xCAT-server/share/xcat/install/rh/kvm.rhels7.tmpl +++ b/xCAT-server/share/xcat/install/rh/kvm.rhels7.tmpl @@ -34,7 +34,7 @@ clearpart --all --initlabel #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #part swap --size 1024 #part / --size 1 --grow --fstype ext4 #XCAT_PARTITION_END# diff --git a/xCAT-server/share/xcat/install/rh/service.rhels6.x86_64.tmpl b/xCAT-server/share/xcat/install/rh/service.rhels6.x86_64.tmpl index 4ccebc3f4..5b8b12d25 100644 --- a/xCAT-server/share/xcat/install/rh/service.rhels6.x86_64.tmpl +++ b/xCAT-server/share/xcat/install/rh/service.rhels6.x86_64.tmpl @@ -35,7 +35,7 @@ key --skip #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #XCAT_PARTITION_END# #RAID 0 /scr for performance diff --git a/xCAT-server/share/xcat/install/rh/service.rhels7.tmpl b/xCAT-server/share/xcat/install/rh/service.rhels7.tmpl index c7977d4ec..37a5ee1b2 100644 --- a/xCAT-server/share/xcat/install/rh/service.rhels7.tmpl +++ b/xCAT-server/share/xcat/install/rh/service.rhels7.tmpl @@ -34,7 +34,7 @@ clearpart --all --initlabel #No RAID #/boot really significant for this sort of setup nowadays? #part /boot --size 50 --fstype ext3 -%include /tmp/partitioning +%include /tmp/partitionfile #part swap --size 1024 #part / --size 1 --grow --fstype ext4 #XCAT_PARTITION_END# @@ -78,7 +78,7 @@ clearpart --all --initlabel #The bootloader config here is commented out #For user customized partition file or partition script, #the bootloader configuration should be specified in the user customized partition file/script -#For the xCAT default partition scheme, the bootloader configuration is in /tmp/partitioning +#For the xCAT default partition scheme, the bootloader configuration is in /tmp/partitionfile #which is generated in %pre section ##KICKSTARTBOOTLOADER# diff --git a/xCAT-server/share/xcat/install/scripts/pre.pkvm3 b/xCAT-server/share/xcat/install/scripts/pre.pkvm3 index 266a19a75..1b5ccd45c 100755 --- a/xCAT-server/share/xcat/install/scripts/pre.pkvm3 +++ b/xCAT-server/share/xcat/install/scripts/pre.pkvm3 @@ -21,8 +21,8 @@ if [ -e "/tmp/xcat.install_disk" ]; then instdisk=`cat /tmp/xcat.install_disk` fi -echo "part PV.01 --ondisk=$instdisk" >> /tmp/partitioning -echo "volgroup ibmpkvm_rootvg PV.01" >> /tmp/partitioning +echo "part PV.01 --ondisk=$instdisk" >> /tmp/partitionfile +echo "volgroup ibmpkvm_rootvg PV.01" >> /tmp/partitionfile if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then set +x diff --git a/xCAT-server/share/xcat/install/scripts/pre.rh b/xCAT-server/share/xcat/install/scripts/pre.rh index 79b28a57d..65f66380d 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.rh +++ b/xCAT-server/share/xcat/install/scripts/pre.rh @@ -207,19 +207,19 @@ BOOTFSTYPE=ext3 EFIFSTYPE=vfat if [ `uname -m` = "ppc64" ]; then - echo 'part None --fstype "PPC PReP Boot" --ondisk '$instdisk' --size 8' >> /tmp/partitioning + echo 'part None --fstype "PPC PReP Boot" --ondisk '$instdisk' --size 8' >> /tmp/partitionfile fi if [ -d /sys/firmware/efi ]; then - echo 'bootloader --driveorder='$instdisk >> /tmp/partitioning - echo 'part /boot/efi --size 50 --ondisk '$instdisk' --fstype '$EFIFSTYPE >> /tmp/partitioning + echo 'bootloader --driveorder='$instdisk >> /tmp/partitionfile + echo 'part /boot/efi --size 50 --ondisk '$instdisk' --fstype '$EFIFSTYPE >> /tmp/partitionfile else - echo 'bootloader' >> /tmp/partitioning + echo 'bootloader' >> /tmp/partitionfile fi #TODO: ondisk detection, /dev/disk/by-id/edd-int13_dev80 for legacy maybe, and no idea about efi. at least maybe blacklist SAN if mptsas/mpt2sas/megaraid_sas seen... -echo "part /boot --size 256 --fstype $BOOTFSTYPE --ondisk $instdisk" >> /tmp/partitioning -echo "part swap --recommended --ondisk $instdisk" >> /tmp/partitioning -echo "part / --size 1 --grow --ondisk $instdisk --fstype $FSTYPE" >> /tmp/partitioning +echo "part /boot --size 256 --fstype $BOOTFSTYPE --ondisk $instdisk" >> /tmp/partitionfile +echo "part swap --recommended --ondisk $instdisk" >> /tmp/partitionfile +echo "part / --size 1 --grow --ondisk $instdisk --fstype $FSTYPE" >> /tmp/partitionfile #XCA_PARTITION_SCRIPT# diff --git a/xCAT-server/share/xcat/install/scripts/pre.rh.rhels7 b/xCAT-server/share/xcat/install/scripts/pre.rh.rhels7 index 9864063fa..f9125de9d 100755 --- a/xCAT-server/share/xcat/install/scripts/pre.rh.rhels7 +++ b/xCAT-server/share/xcat/install/scripts/pre.rh.rhels7 @@ -176,33 +176,41 @@ if uname -r|grep -q '^3.*el7'; then fi if [ `uname -m` = "ppc64" -o `uname -m` = "ppc64le" ]; then - echo 'part None --fstype "PPC PReP Boot" --ondisk '$instdisk' --size 8' >> /tmp/partitioning + echo 'part None --fstype "PPC PReP Boot" --ondisk '$instdisk' --size 8' >> /tmp/partitionfile fi if [ -d /sys/firmware/efi ]; then - echo 'part /boot/efi --size 50 --ondisk '$instdisk' --fstype '$EFIFSTYPE >> /tmp/partitioning + echo 'part /boot/efi --size 50 --ondisk '$instdisk' --fstype '$EFIFSTYPE >> /tmp/partitionfile fi #TODO: ondisk detection, /dev/disk/by-id/edd-int13_dev80 for legacy maybe, and no idea about efi. at least maybe blacklist SAN if mptsas/mpt2sas/megaraid_sas seen... -echo "part /boot --size 256 --fstype $BOOTFSTYPE --ondisk $instdisk" >> /tmp/partitioning -echo "part swap --recommended --ondisk $instdisk" >> /tmp/partitioning -echo "part pv.01 --size 1 --grow --ondisk $instdisk" >> /tmp/partitioning -echo "volgroup system pv.01" >> /tmp/partitioning -echo "logvol / --vgname=system --name=root --size 1 --grow --fstype $FSTYPE" >> /tmp/partitioning +echo "part /boot --size 256 --fstype $BOOTFSTYPE --ondisk $instdisk" >> /tmp/partitionfile +echo "part swap --recommended --ondisk $instdisk" >> /tmp/partitionfile +echo "part pv.01 --size 1 --grow --ondisk $instdisk" >> /tmp/partitionfile +echo "volgroup system pv.01" >> /tmp/partitionfile +echo "logvol / --vgname=system --name=root --size 1 --grow --fstype $FSTYPE" >> /tmp/partitionfile -#specify "bootloader" configuration in "/tmp/partitioning" if there is no user customized partition file +#specify "bootloader" configuration in "/tmp/partitionfile" if there is no user customized partition file BOOTLOADER="bootloader " -#specify the kernel options which will be persistent after installation -[ -n "#ENV:PERSKCMDLINE#" ] && BOOTLOADER=$BOOTLOADER" --append=#ENV:PERSKCMDLINE#" - #Specifies which drive the boot loader should be written to #and therefore which drive the computer will boot from. [ -n "$instdisk" ] && BOOTLOADER=$BOOTLOADER" --boot-drive=$(basename $instdisk)" -echo "$BOOTLOADER" >> /tmp/partitioning +echo "$BOOTLOADER" >> /tmp/partitionfile #XCA_PARTITION_SCRIPT# +#specify the kernel options which will be persistent after installation +if [ -n "#ENV:PERSKCMDLINE#" ];then + #append the persistent kernel options to the lines including "bootloader --append" + sed -i -e /bootloader/s#\'#\"#g -e '/bootloader/s/--append=\([^"]\S*[^"]\)/--append="\1"/g' -e '/bootloader/s/--append="\(.*\)"/--append="\1 #ENV:PERSKCMDLINE#"/g' /tmp/partitionfile + #append the persistent kernel options to the lines including "bootloader" without "--append" + sed -i -e '/bootloader/{/append=/!s/$/& --append="#ENV:PERSKCMDLINE#" /}' /tmp/partitionfile + #append the persistent kernel options to /tmp/partitionfile if it does not include "bootloader" + grep bootloader /tmp/partitionfile >/dev/null 2>&1|| echo -e "bootloader --append=\"#ENV:PERSKCMDLINE#\"" >>/tmp/partitionfile +fi + + # The following code is to generate the repository for the installation cat /proc/cmdline From 4c7148e8ed5ca0bd9cf10530ccc9b47b0ca0befb Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Fri, 24 Jun 2016 13:16:38 -0400 Subject: [PATCH 177/310] Nodeset offline for ppc64 --- .../references/man8/nodeset.8.rst | 8 +- perl-xCAT/xCAT/Usage.pm | 2 +- xCAT-client/pods/man8/nodeset.8.pod | 8 +- xCAT-server/lib/xcat/plugins/grub2.pm | 94 ++++++++++++------- xCAT-server/lib/xcat/plugins/petitboot.pm | 50 +++++----- 5 files changed, 89 insertions(+), 73 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man8/nodeset.8.rst b/docs/source/guides/admin-guides/references/man8/nodeset.8.rst index d8c0be67f..23ec24e23 100644 --- a/docs/source/guides/admin-guides/references/man8/nodeset.8.rst +++ b/docs/source/guides/admin-guides/references/man8/nodeset.8.rst @@ -19,7 +19,7 @@ Name **************** -\ **nodeset**\ \ *noderange*\ [\ **boot**\ | \ **stat**\ | \ **iscsiboot**\ | \ **offline**\ | \ **runcmd=bmcsetup**\ | \ **osimage**\ [=\ *imagename*\ ] | \ **shell**\ | \ **shutdown**\ ] +\ **nodeset**\ \ *noderange*\ [\ **boot**\ | \ **stat**\ | \ **offline**\ | \ **runcmd=bmcsetup**\ | \ **osimage**\ [=\ *imagename*\ ] | \ **shell**\ | \ **shutdown**\ ] \ **nodeset**\ \ *noderange*\ \ **osimage**\ [=\ *imagename*\ ] [\ **-**\ **-noupdateinitrd**\ ] [\ **-**\ **-ignorekernelchk**\ ] @@ -50,7 +50,7 @@ Assume that /tftpboot is the root for tftpd (set in site(5)|site.5). \ **nodeset**\ only sets the next boot state, but does not reboot. -\ **nodeset**\ is called by rinstall and winstall and is also called by the +\ **nodeset**\ is called by \ **rinstall**\ and \ **winstall**\ and is also called by the installation process remotely to set the boot state back to "boot". A user can supply their own scripts to be run on the mn or on the service node (if a hierarchical cluster) for a node when the nodeset command is run. Such scripts are called \ **prescripts**\ . They should be copied to /install/prescripts dirctory. A table called \ *prescripts*\ is used to specify the scripts and their associated actions. The scripts to be run at the beginning of the nodeset command are stored in the 'begin' column of \ *prescripts*\ table. The scripts to be run at the end of the nodeset command are stored in the 'end' column of \ *prescripts*\ table. You can run 'tabdump -d prescripts' command for details. The following two environment variables will be passed to each script: NODES contains all the names of the nodes that need to run the script for and ACTION contains the current nodeset action. If \ *#xCAT setting:MAX_INSTANCE=number*\ is specified in the script, the script will get invoked for each node in parallel, but no more than \ *number*\ of instances will be invoked at at a time. If it is not specified, the script will be invoked once for all the nodes. @@ -82,8 +82,8 @@ A user can supply their own scripts to be run on the mn or on the service node ( \ **-**\ **-noupdateinitrd**\ - Skip the rebuilding of initrd when the 'netdrivers', 'drvierupdatesrc' or 'osupdatename' were set for injecting new drviers to initrd. But, the geninitrd command - should be run to rebuild the initrd for new drivers injecting. This is used to improve the performance of nodeset command. + Skip the rebuilding of initrd when the 'netdrivers', 'drvierupdatesrc' or 'osupdatename' were set for injecting new drivers to initrd. But, the \ **geninitrd**\ command + should be run to rebuild the initrd for new drivers injecting. This is used to improve the performance of \ **nodeset**\ command. diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index e4ce30329..89be4615e 100755 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -461,7 +461,7 @@ Options: "Usage: Common: nodeset [-h|--help|-v|--version] - nodeset [shell|boot|runcmd=bmcsetup|iscsiboot|osimage[=]|offline|shutdown|stat]", + nodeset [shell|boot|runcmd=bmcsetup|osimage[=]|offline|shutdown|stat]", "rmflexnode" => "Usage: rmflexnode [-h|--help|-v|--version] diff --git a/xCAT-client/pods/man8/nodeset.8.pod b/xCAT-client/pods/man8/nodeset.8.pod index 835b7de8a..bc8e2fb46 100644 --- a/xCAT-client/pods/man8/nodeset.8.pod +++ b/xCAT-client/pods/man8/nodeset.8.pod @@ -4,7 +4,7 @@ B - set the boot state for a noderange =head1 B -B I [B | B | B | B | B | B[=I] | B | B] +B I [B | B | B | B | B[=I] | B | B] B I B[=I] [B<--noupdateinitrd>] [B<--ignorekernelchk>] @@ -31,7 +31,7 @@ B for yaboot makes changes to /tftpboot/etc/{node hex ip} B only sets the next boot state, but does not reboot. -B is called by rinstall and winstall and is also called by the +B is called by B and B and is also called by the installation process remotely to set the boot state back to "boot". A user can supply their own scripts to be run on the mn or on the service node (if a hierarchical cluster) for a node when the nodeset command is run. Such scripts are called B. They should be copied to /install/prescripts dirctory. A table called I is used to specify the scripts and their associated actions. The scripts to be run at the beginning of the nodeset command are stored in the 'begin' column of I table. The scripts to be run at the end of the nodeset command are stored in the 'end' column of I table. You can run 'tabdump -d prescripts' command for details. The following two environment variables will be passed to each script: NODES contains all the names of the nodes that need to run the script for and ACTION contains the current nodeset action. If I<#xCAT setting:MAX_INSTANCE=number> is specified in the script, the script will get invoked for each node in parallel, but no more than I of instances will be invoked at at a time. If it is not specified, the script will be invoked once for all the nodes. @@ -55,8 +55,8 @@ Prepare server for installing a node using the specified os image. The os image =item B<--noupdateinitrd> -Skip the rebuilding of initrd when the 'netdrivers', 'drvierupdatesrc' or 'osupdatename' were set for injecting new drviers to initrd. But, the geninitrd command -should be run to rebuild the initrd for new drivers injecting. This is used to improve the performance of nodeset command. +Skip the rebuilding of initrd when the 'netdrivers', 'drvierupdatesrc' or 'osupdatename' were set for injecting new drivers to initrd. But, the B command +should be run to rebuild the initrd for new drivers injecting. This is used to improve the performance of B command. =item B<--ignorekernelchk> diff --git a/xCAT-server/lib/xcat/plugins/grub2.pm b/xCAT-server/lib/xcat/plugins/grub2.pm index 15267f0da..d476df491 100644 --- a/xCAT-server/lib/xcat/plugins/grub2.pm +++ b/xCAT-server/lib/xcat/plugins/grub2.pm @@ -23,7 +23,7 @@ my $globaltftpdir = xCAT::TableUtils->getTftpDir(); my %usage = ( -"nodeset" => "Usage: nodeset [shell|boot|runcmd=bmcsetup|iscsiboot|osimage[=]|offline|shutdown|stat]", +"nodeset" => "Usage: nodeset [shell|boot|runcmd=bmcsetup|osimage[=]|offline|shutdown|stat]", ); sub handled_commands { @@ -78,7 +78,8 @@ sub getstate { chomp($headline); return $headline; } else { - return "boot"; + # There is no boot configuration file, node must be offline + return "offline"; } } else { return "discover"; @@ -181,19 +182,21 @@ sub setstate { my $nodemac; my %client_nethash = xCAT::DBobjUtils->getNetwkInfo([$node]); - open($pcfg, '>', $tftpdir . "/boot/grub2/" . $node); my $cref = $chainhash{$node}->[0]; #$chaintab->getNodeAttribs($node,['currstate']); - if ($cref->{currstate}) { + + # remove the old boot configuration file and create a new one, but only if not offline directive + unlink($tftpdir . "/boot/grub2/" . $node); + if ($cref and $cref->{currstate} ne "offline") { + open($pcfg, '>', $tftpdir . "/boot/grub2/" . $node); print $pcfg "#" . $cref->{currstate} . "\n"; + + if (($::XCATSITEVALS{xcatdebugmode} eq "1") or ($::XCATSITEVALS{xcatdebugmode} eq "2")) { + print $pcfg "set debug=all\n"; + } + + print $pcfg "set timeout=5\n"; } - - if (($::XCATSITEVALS{xcatdebugmode} eq "1") or ($::XCATSITEVALS{xcatdebugmode} eq "2")) { - print $pcfg "set debug=all\n"; - } - - print $pcfg "set timeout=5\n"; - $normalnodes{$node} = 1; #Assume a normal netboot (well, normal dhcp, #which is normally with a valid 'filename' field, #but the typical ppc case will be 'special' makedhcp @@ -247,32 +250,34 @@ sub setstate { return; } + # write entries to boot config file, but only if not offline directive + if ($cref and $cref->{currstate} ne "offline") { + print $pcfg "set default=\"xCAT OS Deployment\"\n"; + print $pcfg "menuentry \"xCAT OS Deployment\" {\n"; + print $pcfg " insmod http\n"; + print $pcfg " insmod tftp\n"; + print $pcfg " set root=$grub2protocol,$serverip\n"; + print $pcfg " echo Loading Install kernel ...\n"; - print $pcfg "set default=\"xCAT OS Deployment\"\n"; - print $pcfg "menuentry \"xCAT OS Deployment\" {\n"; - print $pcfg " insmod http\n"; - print $pcfg " insmod tftp\n"; - print $pcfg " set root=$grub2protocol,$serverip\n"; - print $pcfg " echo Loading Install kernel ...\n"; + my $protocolrootdir = ""; + if ($grub2protocol =~ /^http$/) + { + $protocolrootdir = $tftpdir; + } - my $protocolrootdir = ""; - if ($grub2protocol =~ /^http$/) - { - $protocolrootdir = $tftpdir; + if ($kern and $kern->{kcmdline}) { + print $pcfg " linux $protocolrootdir/$kern->{kernel} $kern->{kcmdline}\n"; + } else { + print $pcfg " linux $protocolrootdir/$kern->{kernel}\n"; + } + print $pcfg " echo Loading initial ramdisk ...\n"; + if ($kern and $kern->{initrd}) { + print $pcfg " initrd $protocolrootdir/$kern->{initrd}\n"; + } + + print $pcfg "}"; + close($pcfg); } - - if ($kern and $kern->{kcmdline}) { - print $pcfg " linux $protocolrootdir/$kern->{kernel} $kern->{kcmdline}\n"; - } else { - print $pcfg " linux $protocolrootdir/$kern->{kernel}\n"; - } - print $pcfg " echo Loading initial ramdisk ...\n"; - if ($kern and $kern->{initrd}) { - print $pcfg " initrd $protocolrootdir/$kern->{initrd}\n"; - } - - print $pcfg "}"; - close($pcfg); my $inetn = xCAT::NetworkUtils->getipaddr($node); unless ($inetn) { syslog("local1|err", "xCAT unable to resolve IP for $node in grub2 plugin"); @@ -312,8 +317,11 @@ sub setstate { foreach $ip (keys %ipaddrs) { my @ipa = split(/\./, $ip); my $pname = "grub.cfg-" . sprintf("%02x%02x%02x%02x", @ipa); + # remove the old boot configuration file and copy (link) a new one, but only if not offline directive unlink($tftpdir . "/boot/grub2/" . $pname); - link($tftpdir . "/boot/grub2/" . $node, $tftpdir . "/boot/grub2/" . $pname); + if ($cref and $cref->{currstate} ne "offline") { + link($tftpdir . "/boot/grub2/" . $node, $tftpdir . "/boot/grub2/" . $pname); + } } if ($macstring) { $nodemac = xCAT::Utils->parseMacTabEntry($macstring, $node); @@ -323,8 +331,11 @@ sub setstate { my $tmp = lc($nodemac); $tmp =~ s/(..):(..):(..):(..):(..):(..)/$1-$2-$3-$4-$5-$6/g; my $pname = "grub.cfg-01-" . $tmp; + # remove the old boot configuration file and copy (link) a new one, but only if not offline directive unlink($tftpdir . "/boot/grub2/" . $pname); - link($tftpdir . "/boot/grub2/" . $node, $tftpdir . "/boot/grub2/" . $pname); + if ($cref and $cref->{currstate} ne "offline") { + link($tftpdir . "/boot/grub2/" . $node, $tftpdir . "/boot/grub2/" . $pname); + } } return; } @@ -713,6 +724,17 @@ sub process_request { } } + if ($args[0] eq 'offline') { + # If nodeset directive was offline we need to remove the architecture file link and remove dhcp entries + foreach my $osimage (keys %osimagenodehash) { + foreach my $tmp_node (@{ $osimagenodehash{$osimage} }) { + unlink( "$tftpdir/boot/grub2/grub2-$tmp_node"); + $sub_req->({ command => ['makedhcp'],arg=>['-d'], + node => \@{ $osimagenodehash{$osimage} } }, $callback); + } + } + } + #now run the end part of the prescripts unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') $errored = 0; diff --git a/xCAT-server/lib/xcat/plugins/petitboot.pm b/xCAT-server/lib/xcat/plugins/petitboot.pm index 8e082dd95..9409e1caf 100644 --- a/xCAT-server/lib/xcat/plugins/petitboot.pm +++ b/xCAT-server/lib/xcat/plugins/petitboot.pm @@ -63,7 +63,8 @@ sub getstate { chomp($headline); return $headline; } else { - return "boot"; + # There is no boot configuration file, node must be offline + return "offline"; } } else { return "discover"; @@ -168,10 +169,13 @@ sub setstate { } my $nodemac; - open($pcfg,'>',$tftpdir."/petitboot/".$node); my $cref=$chainhash{$node}->[0]; #$chaintab->getNodeAttribs($node,['currstate']); - if ($cref->{currstate}) { - print $pcfg "#".$cref->{currstate}."\n"; + + # remove the old boot configuration file and create a new one, but only if not offline directive + unlink($tftpdir . "/petitboot/" . $node); + if ($cref and $cref->{currstate} ne "offline") { + open($pcfg,'>',$tftpdir."/petitboot/".$node); + print $pcfg "#".$cref->{currstate}."\n"; } $normalnodes{$node}=1; #Assume a normal netboot (well, normal dhcp, #which is normally with a valid 'filename' field, @@ -188,8 +192,8 @@ sub setstate { # arg=>['-s','filename = \"xcat/nonexistant_file_to_intentionally_break_netboot_for_localboot_to_work\";']},$callback); #print $pcfg "bye\n"; close($pcfg); - } elsif ($kern and $kern->{kernel}) { - #It's time to set yaboot for this node to boot the kernel.. + } elsif ($kern and $kern->{kernel} and $cref and $cref->{currstate} ne "offline") { + #It's time to set yaboot for this node to boot the kernel, but only if not offline directive print $pcfg "default xCAT\n"; print $pcfg "label xCAT\n"; print $pcfg "\tkernel $kern->{kernel}\n"; @@ -218,8 +222,11 @@ sub setstate { my @ipa=split(/\./,$ip); my $pname = sprintf("%02x%02x%02x%02x",@ipa); $pname = uc($pname); + # remove the old boot configuration file and copy (link) a new one, but only if not offline directive unlink($tftpdir."/".$pname); - link($tftpdir."/petitboot/".$node,$tftpdir."/".$pname); + if ($cref and $cref->{currstate} ne "offline") { + link($tftpdir."/petitboot/".$node,$tftpdir."/".$pname); + } return; } @@ -535,6 +542,14 @@ sub process_request { } } } + + if ($args[0] eq 'offline') { + # If nodeset directive was offline we need to remove dhcp entries + foreach my $node (@normalnodeset) { + $sub_req->({ command => ['makedhcp'],arg=>['-d'], + node => [$node] }, $callback); + } + } #now run the end part of the prescripts unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') @@ -560,27 +575,6 @@ sub process_request { } } -sub getstate { - my $node = shift; - my $tftpdir = shift; - unless ($tftpdir) { $tftpdir = _slow_get_tftpdir($node); } - if (check_dhcp($node)) { - if (-r $tftpdir . "/petitboot/".$node) { - my $fhand; - open ($fhand,$tftpdir . "/petitboot/".$node); - my $headline = <$fhand>; - close $fhand; - $headline =~ s/^#//; - chomp($headline); - return $headline; - } else { - return "boot"; - } - } else { - return "discover"; - } -} - #---------------------------------------------------------------------------- =head3 getNodesetStates returns the nodeset state for the given nodes. The possible nodeset From 1f121f11d93ed78fa1e728fd53320a8b20997479 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Fri, 24 Jun 2016 16:00:31 -0400 Subject: [PATCH 178/310] Change the logger commands to print to stderr so that the SOL console will record the messages --- xCAT-genesis-scripts/bin/dodiscovery | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/xCAT-genesis-scripts/bin/dodiscovery b/xCAT-genesis-scripts/bin/dodiscovery index 3d5e3c522..76510c8d0 100755 --- a/xCAT-genesis-scripts/bin/dodiscovery +++ b/xCAT-genesis-scripts/bin/dodiscovery @@ -112,7 +112,7 @@ DISKSIZE=`cat /proc/partitions |grep -e "sd.\>" |awk -F' ' '{printf "%s:%.0fGB\n #done #CPUTYPE=`cat /tmp/cpumod|awk -F':' '{print $2}'|sed -e 's/^ //'` -logger -t $log_label -p local4.info "Beginning echo infomation to discovery packet file..." +logger -s -t $log_label -p local4.info "Beginning echo infomation to discovery packet file..." echo '' > /tmp/discopacket echo "findme" >> /tmp/discopacket echo "$ARCH" >> /tmp/discopacket @@ -247,20 +247,20 @@ cat /tmp/discopacket |while read line; do echo $line >> /tmp/discopacket.new done mv /tmp/discopacket.new /tmp/discopacket -logger -t $log_label -p local4.info "Discovery packet file is ready." +logger -s -t $log_label -p local4.info "Discovery packet file is ready." rm -f /tmp/discopacket.gz gzip -9 /tmp/discopacket if [ ! -z "$XCATMASTER" ]; then - logger -t $log_label -p local4.info "Sending the discovery packet to xCAT ($XCATMASTER:$XCATPORT)..." + logger -s -t $log_label -p local4.info "Sending the discovery packet to xCAT ($XCATMASTER:$XCATPORT)..." (cat /tmp/discopacket.gz | udpcat.awk $XCATMASTER $XCATPORT ) & fi for dhcps in `grep dhcp-server /var/lib/dhclient/dhclient.leases|awk '{print $4}'|sed -s 's/;//'`; do - logger -t $log_label -p local4.info "Sending the discovery packet to xCAT ($dhcps:$XCATPORT)..." + logger -s -t $log_label -p local4.info "Sending the discovery packet to xCAT ($dhcps:$XCATPORT)..." (cat /tmp/discopacket.gz | udpcat.awk $dhcps $XCATPORT ) & done #cat /tmp/discopacket - logger -t $log_label -p local4.info "Sleeping 5 seconds..." + logger -s -t $log_label -p local4.info "Sleeping 5 seconds..." sleep 5 done -logger -t $log_label -p local4.info "Restart..." +logger -s -t $log_label -p local4.info "Restart network interfaces..." /bin/restart From ce00394dff95e296b59ceff7cc3bd4b30e6826c4 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Fri, 24 Jun 2016 16:01:32 -0400 Subject: [PATCH 179/310] - Undo some changes in doxcat that was causing problems. - clean up some of the logging messages --- xCAT-genesis-scripts/bin/doxcat | 134 +++++++++++++++----------------- 1 file changed, 63 insertions(+), 71 deletions(-) diff --git a/xCAT-genesis-scripts/bin/doxcat b/xCAT-genesis-scripts/bin/doxcat index 17d293dc2..f8fc3ac22 100755 --- a/xCAT-genesis-scripts/bin/doxcat +++ b/xCAT-genesis-scripts/bin/doxcat @@ -8,20 +8,23 @@ log_label="xcat.genesis.doxcat" # Start rsyslogd and log into a local file specified in /etc/rsyslog.conf # Later, once xCAT MN is known, dhclient-script will change # rsyslog.conf file to send log entries to xCAT MN -if [ ! -f /var/run/syslogd.pid ]; then - # - # start rsyslog ONLY if not already started - # - RSYSLOGD_VERSION=`rsyslogd -v | grep "rsyslogd" | cut -d" " -f2 | cut -d"." -f1` - if [ $RSYSLOGD_VERSION -ge 8 ]; then - /sbin/rsyslogd - # Newer vers of rsyslogd (8 and higher) do not support -c flag anymore - else - /sbin/rsyslogd -c4 - fi +logger -s -t $log_label -p local4.info "Starting syslog..." +ls /var/run/ +RSYSLOGD_VERSION=`rsyslogd -v | grep "rsyslogd" | cut -d" " -f2 | cut -d"." -f1` + +# if syslog is running and there's a pid file, kill it before restarting syslogd +if [ -f /var/run/syslogd.pid ]; then + kill -TERM `cat /var/run/syslogd.pid` +fi + +if [ $RSYSLOGD_VERSION -ge 8 ]; then + /sbin/rsyslogd + # Newer vers of rsyslogd (8 and higher) do not support -c flag anymore +else + /sbin/rsyslogd -c4 fi -logger -t $log_label -p local4.info "Beginning doxcat process..." +logger -s -t $log_label -p local4.info "Beginning doxcat process..." modprobe acpi_cpufreq 2>/dev/null # on some machines this fails modprobe cpufreq_ondemand @@ -44,7 +47,7 @@ if [ ! -z "$BOOTIF" ]; then gripeiter=$((gripeiter-1)) done fi - +echo "Done" if [ -z "$bootnic" ]; then logger -s -t $log_label -p local4.err "BOOTIF missing, can't detect boot nic" fi @@ -87,26 +90,24 @@ PUBKEY=`openssl rsa -in /etc/xcat/privkey.pem -pubout 2> /dev/null|grep -v "PUBL PUBKEY=`echo $PUBKEY|sed -e 's/ //g'` export PUBKEY -LLDP_DIR="/var/lib/lldpad" - -logger -t $log_label -p local4.info "Creating ${LLDP_DIR} directory and config files..." -mkdir -p ${LLDP_DIR} -echo 'lldp :' >> ${LLDP_DIR}/lldpad.conf -echo '{' >> ${LLDP_DIR}/lldpad.conf +logger -s -t $log_label -p local4.info "Creating /var/lib/lldpad file..." +mkdir -p /var/lib/lldpad +echo 'lldp :' >> /var/lib/lldpad/lldpad.conf +echo '{' >> /var/lib/lldpad/lldpad.conf for iface in `ip link |grep -v '^ '|awk '{print $2}'|sed -e 's/:$//'|grep -v lo`; do - echo "$iface :" >> ${LLDP_DIR}/lldpad.conf - echo "{" >> ${LLDP_DIR}/lldpad.conf - echo "tlvid00000006 :" >> ${LLDP_DIR}/lldpad.conf - echo "{" >> ${LLDP_DIR}/lldpad.conf - echo info = '"'$PUBKEY'";' >> ${LLDP_DIR}/lldpad.conf - echo 'enableTx = true;' >> ${LLDP_DIR}/lldpad.conf - echo '};' >> ${LLDP_DIR}/lldpad.conf - echo 'adminStatus = 3;' >> ${LLDP_DIR}/lldpad.conf - echo '};' >> ${LLDP_DIR}/lldpad.conf +echo "$iface :" >> /var/lib/lldpad/lldpad.conf +echo "{" >> /var/lib/lldpad/lldpad.conf + echo "tlvid00000006 :" >> /var/lib/lldpad/lldpad.conf + echo "{" >> /var/lib/lldpad/lldpad.conf + echo info = '"'$PUBKEY'";' >> /var/lib/lldpad/lldpad.conf + echo 'enableTx = true;' >> /var/lib/lldpad/lldpad.conf + echo '};' >> /var/lib/lldpad/lldpad.conf + echo 'adminStatus = 3;' >> /var/lib/lldpad/lldpad.conf +echo '};' >> /var/lib/lldpad/lldpad.conf done -echo '};' >> ${LLDP_DIR}/lldpad.conf +echo '};' >> /var/lib/lldpad/lldpad.conf lldpad -d -logger -t $log_label -p local4.info "lldpad started." +logger -s -t $log_label -p local4.info "lldpad started." # Caclulate the broadcast address of a given IP address and mask. bcastcalc(){ @@ -166,7 +167,7 @@ done export XCATPORT export XCATMASTER -logger -t $log_label -p local4.info "XCATMASTER is $XCATMASTER, XCATPORT is $XCATPORT" +logger -s -t $log_label -p local4.info "XCATMASTER is $XCATMASTER, XCATPORT is $XCATPORT" if [[ -n $hostip && -n $netmask && -n $gateway && -n $bootnic ]]; then # doing static ip @@ -191,12 +192,8 @@ else while [ $tries -lt 100 ]; do ALLUP_NICS=`ip link show | grep -v "^ " | grep "state UP" | awk '{print $2}' | sed -e 's/:$//'|grep -v lo | sort -n -r` for tmp1 in $ALLUP_NICS; do - if [ ! -f /var/run/dhclient.$tmp1.pid ]; then - dhclient -cf /etc/dhclient.conf -pf /var/run/dhclient.$tmp1.pid $tmp1 & - fi - if [ ! -f /var/run/dhclient6.$tmp1.pid $tmp1 ]; then - dhclient -6 -pf /var/run/dhclient6.$tmp1.pid $tmp1 -lf /var/lib/dhclient/dhclient6.leases & - fi + dhclient -cf /etc/dhclient.conf -pf /var/run/dhclient.$tmp1.pid $tmp1 & + dhclient -6 -pf /var/run/dhclient6.$tmp1.pid $tmp1 -lf /var/lib/dhclient/dhclient6.leases & #bootnic=$tmp1 #break done @@ -285,7 +282,7 @@ if [ -e "/dev/rtc" ]; then hwclock --systohc fi HOST_ARCH=`uname -m` -if [ `echo $HOST_ARCH | grep "ppc64" > /dev/null; echo $?` == 0 ]; then +if echo $HOST_ARCH | grep "ppc64"; then modprobe ipmi_powernv else modprobe ipmi_si @@ -301,37 +298,32 @@ fi DEVICE=$bootnic export DEVICE -logger -t $log_label -p local4.info "IPMI SUPPORT=${IPMI_SUPPORT}, DEVICE=$bootnic" - if [ "$destiny" != "discover" ]; then #we aren't discoverying, we probably can and should get a cert - logger -t $log_label -p local4.info "Run /bin/getcert to xCAT Master ($XCATMASTER:$XCATPORT)..." + logger -s -t $log_label -p local4.info "Getting initial certificate --> $XCATMASTER:$XCATPORT" /bin/getcert $XCATMASTER:$XCATPORT fi - while :; do grepconfigraid=`echo $destiny|grep "configraid"` if [ -z "$destiny" -o -n "$grepconfigraid" ]; then - logger -t $log_label -p local4.info "Run getdestiny to xCAT Master ($XCATMASTER:$XCATPORT)..." + logger -s -t $log_label -p local4.info "Running getdestiny --> $XCATMASTER:$XCATPORT" destiny=`getdestiny $XCATMASTER:$XCATPORT` + logger -s -t $log_label -p local4.info "Received destiny=$destiny" fi + # parse out some values from the destiny destparameter=`echo $destiny|cut -d '=' -f 2-` - logger -t $log_label -p local4.info "The destparameter is $destparameter" - destiny=`echo $destiny|awk -F= '{print $1}'` - logger -t $log_label -p local4.info "The destiny is $destiny" - dest=`echo $destiny|awk '{print $1}'` #could probably use bash but oh well - logger -t $log_label -p local4.info "The destiny is $dest" + logger -s -t $log_label -p local4.info "The destiny=$dest, destiny parameters=$destparameter" - if [ "$dest" = "discover" ]; then #skip a query to xCAT when /proc/cmdline will do - logger -t $log_label -p local4.info "Run Discovery..." + logger -s -t $log_label -p local4.info "Running dodiscovery..." /bin/dodiscovery - logger -t $log_label -p local4.info "... Discovery complete." - logger -t $log_label -p local4.info "Run /bin/getcert to xCAT Master ($XCATMASTER:$XCATPORT)..." + logger -s -t $log_label -p local4.info "dodiscovery - Complete." + + logger -s -t $log_label -p local4.info "Getting certificate --> $XCATMASTER:$XCATPORT" /bin/getcert $XCATMASTER:$XCATPORT destiny='' dest='' @@ -340,21 +332,21 @@ while :; do destiny='' dest='' /bin/bash - logger -t $log_label -p local4.info "Exiting shell." - logger -t $log_label -p local4.info "Run nextdestiny $XCATMASTER:$XCATPORT..." + logger -s -t $log_label -p local4.info "Exited shell." + logger -s -t $log_label -p local4.info "Running nextdestiny $XCATMASTER:$XCATPORT..." /bin/nextdestiny $XCATMASTER:$XCATPORT - logger -t $log_label -p local4.info "Nextdestiny done." + logger -s -t $log_label -p local4.info "nextdestiny - Complete." elif [ "$dest" = runcmd ]; then - logger -t $log_label -p local4.info "Run nextdestiny $XCATMASTER:$XCATPORT..." + logger -s -t $log_label -p local4.info "Running nextdestiny $XCATMASTER:$XCATPORT..." destiny=`/bin/nextdestiny $XCATMASTER:$XCATPORT` dest=`echo $destiny|awk -F= '{print $1}'` $destparameter - logger -t $log_label -p local4.info "Nextdestiny done." + logger -s -t $log_label -p local4.info "nextdestiny - Complete." elif [ "$dest" = runimage ]; then - logger -t $log_label -p local4.info "Run nextdestiny $XCATMASTER:$XCATPORT..." + logger -s -t $log_label -p local4.info "Running nextdestiny $XCATMASTER:$XCATPORT..." destiny=`/bin/nextdestiny $XCATMASTER:$XCATPORT` dest=`echo $destiny|awk -F= '{print $1}'` - logger -t $log_label -p local4.info "Nextdestiny done." + logger -s -t $log_label -p local4.info "nextdestiny - Complete." mkdir /tmp/`basename $destparameter` cd /tmp/`basename $destparameter` eval destparameter=$destparameter @@ -375,9 +367,9 @@ while :; do ./runme.sh cd - elif [ "$dest" = "reboot" -o "$dest" = "boot" ]; then - logger -t $log_label -p local4.info "Run nextdestiny $XCATMASTER:$XCATPORT..." + logger -s -t $log_label -p local4.info "Running nextdestiny $XCATMASTER:$XCATPORT..." /bin/nextdestiny $XCATMASTER:$XCATPORT - logger -t $log_label -p local4.info "Nextdestiny done." + logger -s -t $log_label -p local4.info "nextdestiny - Complete." if [ $IPMI_SUPPORT -ne 0 ]; then ipmitool chassis bootdev pxe fi @@ -386,12 +378,12 @@ while :; do if [ $IPMI_SUPPORT -ne 0 ]; then ipmitool chassis bootdev pxe fi - logger -t $log_label -p local4.info "Reboot..." + logger -s -t $log_label -p local4.info "Reboot..." reboot -f elif [ "$dest" = sysclone ]; then - logger -t $log_label -p local4.info "Run dosysclone..." + logger -s -t $log_label -p local4.info "Running dosysclone..." /bin/dosysclone - logger -t $log_label -p local4.info "Dosysclone done." + logger -s -t $log_label -p local4.info "dosysclone - Complete." destiny='' dest='' elif [ "$dest" = standby ]; then @@ -399,24 +391,24 @@ while :; do dest='' delay=$((30+$RANDOM%270)) while [ $delay -gt 0 ]; do - if [ $((delay%10)) == 0 ]; then - logger -s -t $log_label -p local4.info "Received request to retry in a bit, will call xCAT back in $delay seconds" + if [ $((delay%10)) == 0 ]; then + logger -s -t $log_label -p local4.info "Received request to retry in a bit, will call xCAT back in $delay seconds" fi delay=$((delay-1)) sleep 1 done echo "Retrying "; elif [ "$dest" = shutdown ]; then - logger -t $log_label -p local4.info "Poweroff..." + logger -s -t $log_label -p local4.info "Poweroff..." poweroff -f else - logger -s -t $log_label -p local4.err "Unrecognized directive $dest" + logger -s -t $log_label -p local4.err "Unrecognized directive (dest=$dest)" destiny='' dest='' delay=$((30+$RANDOM%270)) while [ $delay -gt 0 ]; do - if [ $((delay%10)) == 0 ]; then - logger -s -t $log_label -p local4.info "Will retry in $delay seconds" + if [ $((delay%10)) == 0 ]; then + logger -s -t $log_label -p local4.info "... Will retry xCAT in $delay seconds" fi delay=$((delay-1)) sleep 1 @@ -425,5 +417,5 @@ while :; do fi done -logger -t $log_label -p local4.info "doxcat is done" +logger -s -t $log_label -p local4.info "doxcat is complete" set +x From ba01665adbf116233a80f4a0fc43186145e4f04e Mon Sep 17 00:00:00 2001 From: ertaozh Date: Mon, 27 Jun 2016 02:51:09 -0400 Subject: [PATCH 180/310] refine hardware discovery framework, modifcation based on review comments --- perl-xCAT/xCAT/Utils.pm | 32 +++++++++---------- xCAT-server/lib/xcat/plugins/aaadiscovery.pm | 7 ++-- xCAT-server/lib/xcat/plugins/blade.pm | 16 +++++----- xCAT-server/lib/xcat/plugins/hpblade.pm | 26 +++++++-------- xCAT-server/lib/xcat/plugins/nodediscover.pm | 4 +-- xCAT-server/lib/xcat/plugins/profilednodes.pm | 4 --- xCAT-server/lib/xcat/plugins/seqdiscovery.pm | 29 +++++------------ xCAT-server/lib/xcat/plugins/switch.pm | 16 ++++------ xCAT-server/lib/xcat/plugins/typemtms.pm | 19 +++++------ xCAT-server/lib/xcat/plugins/zzzdiscovery.pm | 12 +++---- xCAT-server/sbin/xcatd | 11 ++++--- 11 files changed, 74 insertions(+), 102 deletions(-) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 831bae20a..b3ab69236 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -4442,9 +4442,9 @@ sub cleanup_for_powerLE_hardware_discovery { } my $subreq = shift; my $host_node = $request->{node}->[0]; - my $pbmc_node = undef; - if (defined($request->{pbmc_node}) and defined($request->{pbmc_node}->[0])) { - $pbmc_node = $request->{pbmc_node}->[0]; + my $bmc_node = undef; + if (defined($request->{bmc_node}) and defined($request->{bmc_node}->[0])) { + $bmc_node = $request->{bmc_node}->[0]; } my $ipmitab = xCAT::Table->new("ipmi"); @@ -4457,31 +4457,31 @@ sub cleanup_for_powerLE_hardware_discovery { my $new_bmc_ip = $ipmihash->{$host_node}->[0]->{bmc}; my $new_bmc_username = $ipmihash->{$host_node}->[0]->{username}; my $new_bmc_password = $ipmihash->{$host_node}->[0]->{password}; - if (!defined($pbmc_node)) { + if (!defined($bmc_node)) { xCAT::MsgUtils->message("S", "Discover info: configure static BMC ip:$new_bmc_ip for host_node:$host_node."); `rspconfig $host_node ip=$new_bmc_ip`; return; } - xCAT::MsgUtils->message("S", "Discovery info: configure password for pbmc_node:$pbmc_node."); + xCAT::MsgUtils->message("S", "Discovery info: configure password for bmc_node:$bmc_node."); if (defined($new_bmc_username) and $new_bmc_username ne '') { if ($new_bmc_username eq "ADMIN" or $new_bmc_username eq 'USERID') { # ADMIN is username for OpenPOWER server, it is not allowed to modify at present # USERID is username for IBM system x server, just modify password - `rspconfig $pbmc_node userid=2 password=$new_bmc_password`; + `rspconfig $bmc_node userid=2 password=$new_bmc_password`; } else { # For other username, we'd better create new user for them - `rspconfig $pbmc_node userid=3 username=$new_bmc_username password=$new_bmc_password`; + `rspconfig $bmc_node userid=3 username=$new_bmc_username password=$new_bmc_password`; } } else { - `rspconfig $pbmc_node password=$new_bmc_password`; + `rspconfig $bmc_node password=$new_bmc_password`; } # the rspconfig doesn't update node definition, need to modify manually for modifying bmc ip address - `chdef $pbmc_node bmcusername=$new_bmc_username bmcpassword=$new_bmc_password`; + `chdef $bmc_node bmcusername=$new_bmc_username bmcpassword=$new_bmc_password`; #if ($new_bmc_password) { # xCAT::Utils->runxcmd( # { # command => ["rspconfig"], - # node => ["$pbmc_node"], + # node => ["$bmc_node"], # arg => [ "password=$new_bmc_password" ], # }, # $subreq, 0,1); @@ -4491,13 +4491,13 @@ sub cleanup_for_powerLE_hardware_discovery { # } #} - xCAT::MsgUtils->message("S", "Discover info: configure ip:$new_bmc_ip for pbmc_node:$pbmc_node."); - `rspconfig $pbmc_node ip=$new_bmc_ip`; + xCAT::MsgUtils->message("S", "Discover info: configure ip:$new_bmc_ip for bmc_node:$bmc_node."); + `rspconfig $bmc_node ip=$new_bmc_ip`; #if($new_bmc_ip) { # xCAT::Utils->runxcmd( # { # command => ["rspconfig"], - # node => ["$pbmc_node"], + # node => ["$bmc_node"], # arg => [ "ip=$new_bmc_ip" ], # }, # $subreq, 0,1); @@ -4506,12 +4506,12 @@ sub cleanup_for_powerLE_hardware_discovery { # return; # } #} - xCAT::MsgUtils->message("S", "Discovery info: remove pbmc_node:$pbmc_node."); - `rmdef $pbmc_node`; + xCAT::MsgUtils->message("S", "Discovery info: remove bmc_node:$bmc_node."); + `rmdef $bmc_node`; #xCAT::Utils->runxcmd( # { # command => ["rmdef"], - # node => ["$pbmc_node"], + # node => ["$bmc_node"], # }, # $subreq, 0,1); } diff --git a/xCAT-server/lib/xcat/plugins/aaadiscovery.pm b/xCAT-server/lib/xcat/plugins/aaadiscovery.pm index 23a74091b..13ae57055 100644 --- a/xCAT-server/lib/xcat/plugins/aaadiscovery.pm +++ b/xCAT-server/lib/xcat/plugins/aaadiscovery.pm @@ -1,4 +1,5 @@ # IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html +# The first module to deal with hardware discovery request, write the request into "discoverydata" table only package xCAT_plugin::aaadiscovery; BEGIN { @@ -18,17 +19,13 @@ sub process_request { my $cb = shift; my $doreq = shift; if ($req->{command}->[0] eq 'findme') { - # The findme request is supposed to be dealt with in the first loop that cacheonly attribute is set for a request - if (!($req->{cacheonly}) or !($req->{cacheonly}->[0])) { - return; - } if (defined($req->{discoverymethod}) and defined($req->{discoverymethod}->[0])) { my $rsp = {}; $rsp->{error}->[0] = "The findme request had been processed by ".$req->{discoverymethod}->[0] ." module"; $cb->($rsp); return; } - xCAT::MsgUtils->message("S", __PACKAGE__.": Processing findme request, writting it into 'discoverydata' table"); + xCAT::MsgUtils->message("S", "xcat.discovery.aaadiscovery: ($req->{mtm}->[0]*$req->{serial}->[0]) Get a discover request"); $req->{discoverymethod}->[0] = 'undef'; xCAT::DiscoveryUtils->update_discovery_data($req); return; diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index bca8d4cb4..ea413ff69 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -4359,15 +4359,12 @@ sub process_request { } } if ($request->{command}->[0] eq "findme") { - # The findme request is supposed to be dealt with in the first loop that cacheonly attribute is set for a request - if (!($request->{cacheonly}) or !($request->{cacheonly}->[0])) { - return; - } if (defined($request->{discoverymethod}) and defined($request->{discoverymethod}->[0])) { # The findme request had been processed by other module, just return return; } + xCAT::MsgUtils->message("S", "xcat.discovery.blade: ($request->{mtm}->[0]*$request->{serial}->[0]) Processing discovery request"); my $mptab = xCAT::Table->new("mp"); unless ($mptab) { return 2; } my @bladents = $mptab->getAllNodeAttribs([qw(node)]); @@ -4446,6 +4443,7 @@ sub process_request { } } unless ($node) { + xCAT::MsgUtils->message("S", "xcat.discovery.blade: ($request->{mtm}->[0]*$request->{serial}->[0]) Error: Could not find any node"); return 1; #failure } if ($request->{mtm} and $request->{mtm} =~ /^(\w{4})/) { @@ -4461,16 +4459,18 @@ sub process_request { undef $mactab; } + xCAT::MsgUtils->message("S", "xcat.discovery.blade: ($request->{mtm}->[0]*$request->{serial}->[0]) Find node $node for the discovery request"); #my %request = ( # command => ['makedhcp'], # node => [$macmap{$mac}] # ); #$doreq->(\%request); $request->{command}=['discovered']; - $request->{noderange} = [$node]; - $request->{discoverymethod} = ['blade']; - $doreq->($request); - %{$request}=(); #Clear request. it is done + my $req = {%$request}; + $req->{noderange} = [$node]; + $req->{discoverymethod} = ['blade']; + $doreq->($req); + %{$req}=(); #Clear request. it is done return 0; } diff --git a/xCAT-server/lib/xcat/plugins/hpblade.pm b/xCAT-server/lib/xcat/plugins/hpblade.pm index 76b257abc..6328f8b95 100755 --- a/xCAT-server/lib/xcat/plugins/hpblade.pm +++ b/xCAT-server/lib/xcat/plugins/hpblade.pm @@ -685,15 +685,11 @@ sub process_request { } } if ($request->{command}->[0] eq "findme") { - # The findme request is supposed to be dealt with in the first loop that cacheonly attribute is set for a request - if (!($request->{cacheonly}) or !($request->{cacheonly}->[0])) { - return; - } if (defined($request->{discoverymethod}) and defined($request->{discoverymethod}->[0])) { # The findme request had been processed by other module, just return return; } - + xCAT::MsgUtils->message("S", "xcat.discovery.hpblade: ($request->{mtm}->[0]*$request->{serial}->[0]) Processing discovery request"); my $mptab = xCAT::Table->new("mp"); unless ($mptab) { return 2; } my @bladents = $mptab->getAllNodeAttribs([qw(node)]); @@ -737,21 +733,25 @@ sub process_request { } } unless ($macmap{$mac}) { + xCAT::MsgUtils->message("S", "xcat.discovery.hpblade: ($request->{mtm}->[0]*$request->{serial}->[0]) Error: Could not find any node"); return 1; #failure } - my $mactab = xCAT::Table->new('mac',-create=>1); - $mactab->setNodeAttribs($macmap{$mac},{mac=>$mac}); - $mactab->close(); + # The discovered command will update mac table, no need to update here + #my $mactab = xCAT::Table->new('mac',-create=>1); + #$mactab->setNodeAttribs($macmap{$mac},{mac=>$mac}); + #$mactab->close(); #my %request = ( # command => ['makedhcp'], # node => [$macmap{$mac}] # ); #$doreq->(\%request); - $request->{command}=['discovered']; - $request->{noderange} = [$macmap{$mac}]; - $doreq->($request); - %{$request}=(); #Clear request. it is done - undef $mactab; + xCAT::MsgUtils->message("S", "xcat.discovery.hpblade: ($request->{mtm}->[0]*$request->{serial}->[0]) Find node:$macmap{$mac} for the discovery request"); + my $req={%$request}; + $req->{command}=['discovered']; + $req->{noderange} = [$macmap{$mac}]; + $doreq->($req); + %{$req}=(); #Clear request. it is done + #undef $mactab; return 0; } diff --git a/xCAT-server/lib/xcat/plugins/nodediscover.pm b/xCAT-server/lib/xcat/plugins/nodediscover.pm index 2f52069b2..058d0401a 100644 --- a/xCAT-server/lib/xcat/plugins/nodediscover.pm +++ b/xCAT-server/lib/xcat/plugins/nodediscover.pm @@ -373,8 +373,8 @@ sub process_request { } if (defined($request->{bmcinband})) { syslog("local4|info", "The attribute bmcinband is specified, just remove the temp BMC node if there is"); - if (defined($request->{pbmc_node}) and defined($request->{pbmc_node}->[0])) { - my $bmc_node = $request->{pbmc_node}->[0]; + if (defined($request->{bmc_node}) and defined($request->{bmc_node}->[0])) { + my $bmc_node = $request->{bmc_node}->[0]; syslog("local4|info", "Find BMC $bmc_node, so remove it"); $doreq->({ command => ['rmdef'], arg => [$bmc_node]}); } diff --git a/xCAT-server/lib/xcat/plugins/profilednodes.pm b/xCAT-server/lib/xcat/plugins/profilednodes.pm index 818da4c21..242216f82 100644 --- a/xCAT-server/lib/xcat/plugins/profilednodes.pm +++ b/xCAT-server/lib/xcat/plugins/profilednodes.pm @@ -1816,10 +1816,6 @@ Usage: #------------------------------------------------------- sub findme{ - # The findme request is supposed to be dealt with in the first loop that cacheonly attribute is set for a request - if (!($request->{cacheonly}) or !($request->{cacheonly}->[0])) { - return; - } if (defined($request->{discoverymethod}) and defined($request->{discoverymethod}->[0])) { # The findme request had been processed by other module, just return return; diff --git a/xCAT-server/lib/xcat/plugins/seqdiscovery.pm b/xCAT-server/lib/xcat/plugins/seqdiscovery.pm index 64a0e8138..87d1d5281 100755 --- a/xCAT-server/lib/xcat/plugins/seqdiscovery.pm +++ b/xCAT-server/lib/xcat/plugins/seqdiscovery.pm @@ -54,28 +54,16 @@ sub findme { my @SEQdiscover = xCAT::TableUtils->get_site_attribute("__SEQDiscover"); my @PCMdiscover = xCAT::TableUtils->get_site_attribute("__PCMDiscover"); - # The findme request is supposed to be dealt with in the first loop that cacheonly attribute is set for a request - if (!($request->{cacheonly}) or !($request->{cacheonly}->[0])) { - return; - } if (defined($request->{discoverymethod}) and defined($request->{discoverymethod}->[0])) { # The findme request had been processed by other module, just return return; } unless ($SEQdiscover[0]) { - #if ($PCMdiscover[0]) { - #profile disocvery is running, then just return to make profile discovery to handle it - #return; - #} - # The request data have been write into discoverydata table within aaadiscover.pm, just return here - # update the discoverydata table to have an undefined node - #$request->{discoverymethod}->[0] = 'undef'; - #xCAT::DiscoveryUtils->update_discovery_data($request); return; } # do the sequential discovery - xCAT::MsgUtils->message("S", "Sequential Discovery: Processing"); + xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{mtm}->[0]*$request->{serial}->[0]) Processing discovery request"); # Get the parameters for the sequential discovery my %param; @@ -88,7 +76,7 @@ sub findme { my $mac; my $ip = $request->{'_xcat_clientip'}; if (defined $request->{nodetype} and $request->{nodetype}->[0] eq 'virtual') { - xCAT::MsgUtils->message("S", "Sequential discovery does not support virtual machines, exiting..."); + xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{mtm}->[0]*$request->{serial}->[0]) Error: virtual machines is not supported"); return; } my $arptable; @@ -108,7 +96,7 @@ sub findme { } unless ($mac) { - xCAT::MsgUtils->message("S", "Discovery Error: Could not find the mac of the $ip."); + xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{mtm}->[0]*$request->{serial}->[0]) Error: Could not find mac of the $ip"); return; } @@ -140,13 +128,13 @@ sub findme { $node = $allnodes[0]; } } - my $pbmc_node = undef; + my $bmc_node = undef; if ($request->{'mtm'}->[0] and $request->{'serial'}->[0]) { my $mtms = $request->{'mtm'}->[0]."*".$request->{'serial'}->[0]; my $tmp_nodes = $::XCATVPDHASH{$mtms}; foreach (@$tmp_nodes) { if ($::XCATMPHASH{$_}) { - $pbmc_node = $_; + $bmc_node = $_; } } } @@ -385,14 +373,12 @@ sub findme { # call the discovered command to update the discovery request to a node - xCAT::MsgUtils->message("S", __PACKAGE__.": Find a node for the findme request"); + xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{mtm}->[0]*$request->{serial}->[0]) Find node:$node for the discovery request"); $request->{discoverymethod} = ['sequential']; my $req = {%$request}; $req->{command}=['discovered']; $req->{noderange} = [$node]; - if ($pbmc_node) { - $request->{pbmc_node} = [$pbmc_node]; - } + $request->{bmc_node} = [$bmc_node]; $req->{updateswitch} = ['yes']; $subreq->($req); @@ -400,6 +386,7 @@ sub findme { undef $mactab; } else { nodediscoverstop($callback, undef, "node names"); + xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{mtm}->[0]*$request->{serial}->[0]) Error: Could not find any node"); return; } diff --git a/xCAT-server/lib/xcat/plugins/switch.pm b/xCAT-server/lib/xcat/plugins/switch.pm index ce47596be..12024e6d1 100644 --- a/xCAT-server/lib/xcat/plugins/switch.pm +++ b/xCAT-server/lib/xcat/plugins/switch.pm @@ -268,15 +268,11 @@ sub process_request { } return; } elsif ($req->{command}->[0] eq 'findme') { - # The findme request is supposed to be dealt with in the first loop that cacheonly attribute is set for a request - if (!($req->{cacheonly}) or !($req->{cacheonly}->[0])) { - return; - } if (defined($req->{discoverymethod}) and defined($req->{discoverymethod}->[0])) { # The findme request had been processed by other module, just return return; } - xCAT::MsgUtils->message("S", __PACKAGE__.": Processing findme request"); + xCAT::MsgUtils->message("S", "xcat.discovery.switch: ($req->{mtm}->[0]*$req->{serial}->[0]) Processing discovery request"); my $ip = $req->{'_xcat_clientip'}; if (defined $req->{nodetype} and $req->{nodetype}->[0] eq 'virtual') { #Don't attempt switch discovery of a VM Guest @@ -314,19 +310,19 @@ sub process_request { if ($node) { last; } } } - my $pbmc_node = undef; + my $bmc_node = undef; if ($req->{'mtm'}->[0] and $req->{'serial'}->[0]) { my $mtms = $req->{'mtm'}->[0]."*".$req->{'serial'}->[0]; my $tmp_nodes = $::XCATVPDHASH{$mtms}; foreach (@$tmp_nodes) { if ($::XCATMPHASH{$_}) { - $pbmc_node = $_; + $bmc_node = $_; } } } if ($node) { - xCAT::MsgUtils->message("S", __PACKAGE__.": Find a node for the findme request"); + xCAT::MsgUtils->message("S", "xcat.discovery.switch: ($req->{mtm}->[0]*$req->{serial}->[0]) Find node:$node for the discovery request"); # No need to write mac table here, 'discovered' command will write # my $mactab = xCAT::Table->new('mac',-create=>1); # $mactab->setNodeAttribs($node,{mac=>$mac}); @@ -340,12 +336,12 @@ sub process_request { my $request = {%$req}; $request->{command}=['discovered']; $request->{noderange} = [$node]; - $request->{pbmc_node} = [$pbmc_node]; + $request->{bmc_node} = [$bmc_node]; $doreq->($request); %{$request}=();#Clear req structure, it's done.. undef $mactab; } else { - #Shouldn't complain, might be blade, but how to log total failures? + xCAT::MsgUtils->message("S", "xcat.discovery.switch: ($req->{mtm}->[0]*$req->{serial}->[0]) Error: Could not find any node"); } } } diff --git a/xCAT-server/lib/xcat/plugins/typemtms.pm b/xCAT-server/lib/xcat/plugins/typemtms.pm index 63c69b492..53e5cc29d 100644 --- a/xCAT-server/lib/xcat/plugins/typemtms.pm +++ b/xCAT-server/lib/xcat/plugins/typemtms.pm @@ -1,4 +1,5 @@ # IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html +# Used to deal with MTMS(machine-type/model and serial) based hardware discovery package xCAT_plugin::typemtms; BEGIN { @@ -21,31 +22,32 @@ sub findme { } my @attr_array = (); my $mtms = $request->{'mtm'}->[0]."*".$request->{'serial'}->[0]; + xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($mtms) Processing discovery request"); my $tmp_nodes = $::XCATVPDHASH{$mtms}; my @nodes = (); - my $pbmc_node; + my $bmc_node; foreach (@$tmp_nodes) { if ($::XCATMPHASH{$_}) { - $pbmc_node = $_; + $bmc_node = $_; } else { push @nodes, $_; } } my $nodenum = $#nodes; if ($nodenum < 0) { - xCAT::MsgUtils->message("S", "Discovery Error: Could not find any node."); + xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($mtms) Error: Could not find any node"); return; } elsif ($nodenum > 0) { - xCAT::MsgUtils->message("S", "Discovery Error: More than one node were found."); + xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($mtms) Error: More than one node were found"); return; } { - xCAT::MsgUtils->message("S", __PACKAGE__.": Find a node for the findme request"); + xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($mtms) Find node:$nodes[0] for the discovery request"); $request->{discoverymethod}->[0] = 'mtms'; my $req = {%$request}; $req->{command} = ['discovered']; $req->{noderange} = [$nodes[0]]; - $req->{pbmc_node} = [$pbmc_node]; + $req->{bmc_node} = [$bmc_node]; $subreq->($req); %{$req} = (); } @@ -55,15 +57,10 @@ sub process_request { my $cb = shift; my $doreq = shift; if ($req->{command}->[0] eq 'findme') { - # The findme request is supposed to be dealt with in the first loop that cacheonly attribute is set for a request - if (!($req->{cacheonly}) or !($req->{cacheonly}->[0])) { - return; - } if (defined($req->{discoverymethod}) and defined($req->{discoverymethod}->[0])) { # The findme request had been processed by other module, just return return; } - xCAT::MsgUtils->message("S", __PACKAGE__.": Processing findme request"); &findme($req, $callback, $doreq); return; } diff --git a/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm b/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm index 8de0e5eaa..643b178c8 100644 --- a/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm +++ b/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm @@ -1,4 +1,5 @@ # IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html +# The last module to deal with hardware discovery request, write information that which module can deal with this request or no module can deal with it at all package xCAT_plugin::zzzdiscovery; BEGIN { @@ -16,18 +17,15 @@ sub process_request { my $cb = shift; my $doreq = shift; if ($req->{command}->[0] eq 'findme') { - # The findme request is supposed to be dealt with in the first loop that cacheonly attribute is set for a request - if (!($req->{cacheonly}) or !($req->{cacheonly}->[0])) { - return; - } - xCAT::MsgUtils->message("S", __PACKAGE__.": Processing findme request"); + xCAT::MsgUtils->message("S", "xcat.discovery.zzzdiscovery: ($req->{mtm}->[0]*$req->{serial}->[0]) Finish to process the discovery request"); if (!defined($req->{discoverymethod}) or !defined($req->{discoverymethod}->[0])) { my $rsp = {}; - $rsp->{error}->[0] = "The findme request can not be processed"; + $rsp->{error}->[0] = "The discovery request can not be processed"; $cb->($rsp); + xCAT::MsgUtils->message("S", "xcat.discovery.zzzdiscovery: ($req->{mtm}->[0]*$req->{serial}->[0]) Failed to be processed"); return; } - xCAT::MsgUtils->message("S", __PACKAGE__.": This findme request had been processed by $req->{discoverymethod}->[0] module"); + xCAT::MsgUtils->message("S", "xcat.discovery.zzzdiscovery: ($req->{mtm}->[0]*$req->{serial}->[0]) Successfully processed by $req->{discoverymethod}->[0] method"); return; } } diff --git a/xCAT-server/sbin/xcatd b/xCAT-server/sbin/xcatd index d891dcd64..ab6abd7c1 100644 --- a/xCAT-server/sbin/xcatd +++ b/xCAT-server/sbin/xcatd @@ -625,12 +625,13 @@ sub do_discovery_process { $req->{'_xcat_clientport'}=$sport; if (defined($cmd_handlers{"findme"}) and xCAT::NetworkUtils->nodeonmynet($clientip)) { # only discover from ips that appear to be on a managed network xCAT::MsgUtils->message("S","xcatd: Processing discovery request from ".$req->{'_xcat_clientip'}); - $req->{cacheonly}->[0] = 1; + # Using cacheonly will cause the discovery processing running 2 times, cacheonly seems useless for switch.pm, so remove it + #$req->{cacheonly}->[0] = 1; + #plugin_command($req,undef,\&build_response); + #if ($req->{cacheonly}->[0]) { + #delete $req->{cacheonly}; plugin_command($req,undef,\&build_response); - if ($req->{cacheonly}->[0]) { - delete $req->{cacheonly}; - plugin_command($req,undef,\&build_response); - } + #} } else { xCAT::MsgUtils->message("S","xcatd: Skipping discovery from ".$client." because we either have no discovery plugins or the client address does not match an IP network that xCAT is managing"); } From 54581229cd78db1b93053969be8828474070f4ca Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Mon, 27 Jun 2016 15:16:01 +0800 Subject: [PATCH 181/310] [go-xcat] Fix typo --- xCAT-server/share/xcat/tools/go-xcat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index 458877d0c..ca81ccd57 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -827,7 +827,7 @@ function add_repo_by_url_apt() [[ "${url:0:1}" = "/" ]] || url="${PWD}/${url}" # directory tmp="${TMP_DIR}/tmp_repo.list" - echo "deb [arch=$(dpkg --print-architechure)] file://${url} ${codename} main" >"${tmp}" + echo "deb [arch=$(dpkg --print-architecture)] file://${url} ${codename} main" >"${tmp}" add_repo_by_file_apt "${tmp}" "${repo_id}" return "$?" fi From f203009cea34411a235f7f007f462d340c1cd31d Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Mon, 27 Jun 2016 16:51:20 +0800 Subject: [PATCH 182/310] [go-xcat] Fix issue #1398. Remove the support of local repoitory file on Debian/Ubuntu --- xCAT-server/share/xcat/tools/go-xcat | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index 458877d0c..e4314f4a5 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -582,11 +582,13 @@ function add_repo_by_file_yum() exit_if_bad "$?" "empty repo id" [[ "${repo_id}" =~ ^[a-zA-Z][0-9a-zA-Z-]*$ ]] exit_if_bad "$?" "${repo_id} illegal character in repo id" - remove_repo_yum "${repo_id}" + local tmp="${TMP_DIR}/tmp_repo_file_${repo_id}.repo" { echo "[${repo_id}]" grep -v '^\[' "${repo_file}" - } >"/etc/yum.repos.d/${repo_id}.repo" + } >"${tmp}" + remove_repo_yum "${repo_id}" && + cp "${tmp}" "/etc/yum.repos.d/${repo_id}.repo" } # $1 repo file @@ -604,13 +606,13 @@ function add_repo_by_file_zypper() exit_if_bad "$?" "empty repo id" [[ "${repo_id}" =~ ^[a-zA-Z][0-9a-zA-Z-]*$ ]] exit_if_bad "$?" "${repo_id} illegal character in repo id" - local tmp_repo_file="${TMP_DIR}/${repo_id}.repo" + local tmp="${TMP_DIR}/tmp_repo_file_${repo_id}.repo" { echo "[${repo_id}]" grep -v '^\[' "${repo_file}" - } >"${tmp_repo_file}" - remove_repo_zypper "${repo_id}" - zypper addrepo "${tmp_repo_file}" >/dev/null 2>&1 + } >"${tmp}" + remove_repo_zypper "${repo_id}" && + zypper addrepo "${tmp}" >/dev/null 2>&1 } # $1 repo file @@ -810,12 +812,6 @@ function add_repo_by_url_apt() esac if [[ -f "${url}" ]] then - case "${url##*.}" in - "list") # local repo file - add_repo_by_file_apt "${url}" "${repo_id}" - return "$?" - ;; - esac extract_archive "${url}" "${repo_id}" "${install_path}" warn_if_bad "$?" "extract ${repo_id} archive file failed" || return 1 From cc4e412029dbf48478d206fe11e373c925752b1d Mon Sep 17 00:00:00 2001 From: penguhyang Date: Mon, 27 Jun 2016 01:50:15 -0400 Subject: [PATCH 183/310] update docs about xcatdebugmode usage --- .../os_installation/log_to_mn_cn.rst | 90 ++++++++++--------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/docs/source/troubleshooting/os_installation/log_to_mn_cn.rst b/docs/source/troubleshooting/os_installation/log_to_mn_cn.rst index a36ebe473..54f3827a5 100644 --- a/docs/source/troubleshooting/os_installation/log_to_mn_cn.rst +++ b/docs/source/troubleshooting/os_installation/log_to_mn_cn.rst @@ -14,27 +14,27 @@ The logs during diskfull provision: * PostBootScript logs: the logs during the post boot scripts execution, which are specified in "postbootscripts" attribute of node and osimage definition and run during the 1st reboot after installation. -+------------------------+-----------------------+-----------------------+-----------------------+ -| **xcatdebugmode** | 0 | 1 | 2 | -+------------------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ -| OS Distribution | RHEL | SLES | UBT | RHEL | SLES | UBT | RHEL | SLES | UBT | -+================+=======+=======+=======+=======+=======+=======+=======+=======+=======+=======+ -| Pre-Install | [MN]_ | [N]_ | [N]_ | [N]_ | -+ logs +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ -| | [CN]_ | [Y1]_ | [Y2]_ | [Y2]_ | -+----------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ -| Installer | [MN]_ | [N]_ | [N]_ | [N]_ | [Y7]_ | [Y7]_ | [Y7]_ | [Y7]_ | [Y7]_ | [Y7]_ | -+ logs +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ -| | [CN]_ | [Y6]_ | [Y6]_ | [Y6]_ | [Y6]_ | [Y6]_ | [Y6]_ | [Y6]_ | [Y6]_ | [Y6]_ | -+----------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ -| Post-Install | [MN]_ | [Y5]_ | [Y3]_ | [Y3]_ | -+ logs +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ -| | [CN]_ | [Y1]_ | [Y2]_ | [Y2]_ | -+----------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ -| PostBootScript | [MN]_ | [Y5]_ | [Y3]_ | [Y3]_ | -+ logs +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ -| | [CN]_ | [Y1]_ | [Y2]_ | [Y2]_ | -+----------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ ++---------------------+--------------+--------------+--------------+ +| **xcatdebugmode** | 0 | 1 | 2 | ++---------------------+----+----+----+----+----+----+----+----+----+ +| OS Distribution |RHEL|SLES|UBT |RHEL|SLES|UBT |RHEL|SLES|UBT | ++================+====+====+====+====+====+====+====+====+====+====+ +| Pre-Install | MN | N | N | N | ++ logs +----+----+----+----+----+----+----+----+----+----+ +| | CN | C1 | C1 C2 | C1 C2 | ++----------------+----+----+----+----+----+----+----+----+----+----+ +| Installer | MN | N | N | N | M1 | M1 | M1 | M1 | M1 | M1 | ++ logs +----+----+----+----+----+----+----+----+----+----+ +| | CN | C3 | C3 | C3 | C3 | C3 | C3 | C3 | C3 | C3 | ++----------------+----+----+----+----+----+----+----+----+----+----+ +| Post-Install | MN | M2 | M3 | M3 | ++ logs +----+----+----+----+----+----+----+----+----+----+ +| | CN | C1 | C1 C2 | C1 C2 | ++----------------+----+----+----+----+----+----+----+----+----+----+ +| PostBootScript | MN | M2 | M3 | M3 | ++ logs +----+----+----+----+----+----+----+----+----+----+ +| | CN | C1 | C1 C2 | C1 C2 | ++----------------+----+----+----+----+----+----+----+----+----+----+ The logs during diskless provision: ``````````````````````````````````` @@ -43,37 +43,39 @@ The logs during diskless provision: * PostBootScript logs: the logs during the post boot scripts execution, which are specified in "postbootscripts" attribute of node and osimage definition and run during the 1st reboot after installation. -+------------------------+--------------+--------------+--------------+ -| **xcatdebugmode** | 0 | 1 | 2 | -+------------------------+----+----+----+----+----+----+----+----+----+ -| OS Distribution |RHEL|SLES|UBT |RHEL|SLES|UBT |RHEL|SLES|UBT | -+================+=======+====+====+====+====+====+====+====+====+====+ -| Provision | [MN]_ | [N]_ | [Y3]_ | [Y3]_ | -+ logs +-------+----+----+----+----+----+----+----+----+----+ -| | [CN]_ | [N]_ | [N]_ | [N]_ | -+----------------+-------+----+----+----+----+----+----+----+----+----+ -| PostBootScript | [MN]_ | [Y3]_ | [Y4]_ | [Y4]_ | -+ logs +-------+----+----+----+----+----+----+----+----+----+ -| | [CN]_ | [Y1]_ | [Y2]_ | [Y2]_ | -+----------------+-------+----+----+----+----+----+----+----+----+----+ ++---------------------+--------------+--------------+--------------+ +| **xcatdebugmode** | 0 | 1 | 2 | ++---------------------+----+----+----+----+----+----+----+----+----+ +| OS Distribution |RHEL|SLES|UBT |RHEL|SLES|UBT |RHEL|SLES|UBT | ++================+====+====+====+====+====+====+====+====+====+====+ +| Provision | MN | N | M3 | M3 | ++ logs +----+----+----+----+----+----+----+----+----+----+ +| | CN | N | N | N | ++----------------+----+----+----+----+----+----+----+----+----+----+ +| PostBootScript | MN | M3 | M3 M4 | M3 M4 | ++ logs +----+----+----+----+----+----+----+----+----+----+ +| | CN | C1 | C1 C2 | C1 C2 | ++----------------+----+----+----+----+----+----+----+----+----+----+ -.. [MN] means the logs forwarded to management node. +MN: the logs forwarded to management node(M1-M4 is the operation for MN). :: -.. [CN] means the logs on compute node. + M1 means the installer logs can be forwarded to the MN in ``/var/log/xcat/computes.log`` file. -.. [Y1] means the installation logs can be saved to ``/var/log/xcat/xcat.log`` file on CN. + M2 means the error messages can be forwarded to ``/var/log/xcat/computes.log`` file on MN only when critical error happens. -.. [Y2] means the installation logs and debug trace("set -x" or "-o xtrace") of bash scripts can be saved to ``/var/log/xcat/xcat.log`` file on CN. + M3 means the installation logs can be forwarded to ``/var/log/xcat/computes.log`` file on MN. -.. [Y3] means the installation logs can be forwarded to ``/var/log/xcat/computes.log`` file on MN. + M4 means the debug trace("set -x" or "-o xtrace") of bash scripts enabled. -.. [Y4] means the installation logs and debug trace("set -x" or "-o xtrace") of bash scripts can be forwarded to ``/var/log/xcat/computes.log`` file on MN. + N means the logs can not be forwarded to MN. -.. [Y5] means the error messages can be forwarded to ``/var/log/xcat/computes.log`` file on MN only when critical error happens. +CN: the logs on compute node(C1-C3 is the operation for CN). :: -.. [Y6] means the installer log can be saved to the CN in ``/var/log/anaconda`` for RHEL, ``/var/log/YaST2`` for SLES, ``/var/log/installer`` for UBT. + C1 means the installation logs can be saved to ``/var/log/xcat/xcat.log`` file on CN. -.. [Y7] means the installer log can be forwarded to the MN in ``/var/log/xcat/computes.log`` file. + C2 means the debug trace("set -x" or "-o xtrace") of bash scripts enabled. -.. [N] means the logs can not be forwarded or saved. + C3 means the installer logs can be saved to the CN in ``/var/log/anaconda`` for RHEL, ``/var/log/YaST2`` for SLES, ``/var/log/installer`` for UBT. + + N means the logs can not be saved to CN. From 5cb37dd2355dc232f50a63f9756be911ef6d4e7c Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 27 Jun 2016 14:59:57 -0400 Subject: [PATCH 184/310] xcatprobe image improvements based on code review suggestions --- xCAT-probe/subcmds/image | 169 ++++++++++++++++++++++++++------------- 1 file changed, 113 insertions(+), 56 deletions(-) diff --git a/xCAT-probe/subcmds/image b/xCAT-probe/subcmds/image index bc390ed81..68f14b84f 100755 --- a/xCAT-probe/subcmds/image +++ b/xCAT-probe/subcmds/image @@ -25,14 +25,14 @@ $::USAGE = "Usage: $program_name {-c|-d} [-V] Description: - Use this command to check if compute nodes have the same images installed as defines in xCAT DB. - Use this command to check if all compute nodes have the same identical installed. + Use this command to check if diskless, pingable compute nodes have the same images installed as defines in xCAT DB. + Use this command to check if all diskless, pingable compute nodes have the same identical installed. Options: -h : Get usage information of $program_name -t : To verify if $program_name can work, reserve option for probe framework - -d : To verify compute nodes have the same images installed as defines in xCAT DB. - -c : To verify compute nodes have the identical images installed. + -d : To verify diskless, pingable compute nodes have the same images installed as defines in xCAT DB. + -c : To verify all diskless, pingable compute nodes have the identical images installed. -V : To print additional debug information. "; @@ -78,77 +78,134 @@ my @pingable_nodes; my @diskless_nodes; my $na = "N/A"; +my $defined_UUID = $na; +my %node_defined_image_uuid_hash; +my %node_defined_image_name_hash; + # First, extract diskless nodes foreach (@nodes) { - my $lsdef_provmethod = `lsdef $_ -i provmethod -c`; - if ($lsdef_provmethod =~ /netboot/) { - push(@diskless_nodes, $_); - probe_utils->send_msg("$output", "d", "$_ is diskless"); + # Get osimage name for the node + my $node_provmethod = `lsdef $_ -i provmethod -c`; + my ($junk, $node_osimage_name) = split "=", $node_provmethod; + chomp($node_osimage_name); + + if (length($node_osimage_name) > 0) { + # Get provmethod for the osimage + my $osimage_provmethod = `lsdef -t osimage $node_osimage_name -i provmethod -c`; + if (length($osimage_provmethod) <= 0) { + next; + } + my ($junk2, $osimage_provmethod_type) = split "=", $osimage_provmethod; + chomp($osimage_provmethod_type); + + # Check if it is netboot, meaning diskless + if ($osimage_provmethod_type eq 'netboot') { + push(@diskless_nodes, $_); + probe_utils->send_msg("$output", "o", "$_ is diskless"); + # For this diskless node, get UUID from rootimg directory xcatinfo file of the provmethod osimage + $rootimagedir = `lsdef -t osimage $node_osimage_name -i rootimgdir -c | cut -d "=" -f 2`; + chomp($rootimagedir); + if (length($rootimagedir) > 0) { + my $xcatinfo_file = $rootimagedir . "/rootimg/opt/xcat/xcatinfo"; + if (-r $xcatinfo_file) { + $defined_UUID = `awk -F"'" '/IMAGEUUID/ {print \$2}' $xcatinfo_file`; + chomp($defined_UUID); + if (length($defined_UUID) < 1) { + $defined_UUID = $na; + } + } + } + $node_defined_image_uuid_hash{$_} = $defined_UUID; + $node_defined_image_name_hash{$_} = $node_osimage_name; + print "Node $_ has defined image $node_osimage_name at $rootimagedir with UUID $defined_UUID\n" if ($VERBOSE); + } + else { + probe_utils->send_msg("$output", "w", "$_ is not diskless. No image consistency verification will be performed."); + } } } +if (scalar(@diskless_nodes) <=0) { + # There were no diskless nodes found. Issue a warning and exit. + probe_utils->send_msg("$output", "w", "No diskless compute nodes were found"); + exit 1; +} + # Next, check if all diskless nodes are pingable -my $p = Net::Ping->new(); -foreach (@diskless_nodes) { - if ($p->ping($_, 2)) { - probe_utils->send_msg("$output", "o", "Pinging $_"); - push(@pingable_nodes, $_); +my $ping_hosts = join ",",@diskless_nodes; +my $pping_output = `pping $ping_hosts`; +chomp($pping_output); +my @pping_lines = split("[\n\r]", $pping_output); +foreach (@pping_lines) { + my ($hostname, $result) = split ":", $_; + my ($token, $status) = split ' ', $result; + chomp($token); + if ($token ne 'ping') { + probe_utils->send_msg("$output", "f", "Pinging $hostname"); } else { - probe_utils->send_msg("$output", "f", "Pinging $_"); + probe_utils->send_msg("$output", "o", "Pinging $hostname"); + push(@pingable_nodes, $hostname); } - sleep(1); } -$p->close(); -my $defined_UUID = $na; +if (scalar(@pingable_nodes) <=0) { + # There were no pingable, diskless nodes found. Issue a warning and exit. + probe_utils->send_msg("$output", "w", "No diskless, pingable compute nodes were found"); + exit 1; +} + +# Next, from all pingable nodes get the IMAGENAME and IMAGEUUID entries from xcatinfo file +probe_utils->send_msg("$output", "d", "---- Gathering information from all diskless pingable compute nodes ----"); + +my $pingable_hostname_list = join ",", @pingable_nodes; +my $all_xdsh_output = `xdsh $pingable_hostname_list "cat /opt/xcat/xcatinfo"`; +my $xcatinfo_image_UUID = ` echo "$all_xdsh_output" | awk -F"=" '/IMAGEUUID/ {gsub(/IMAGEUUID/,"",\$1); gsub(/'"'"'/,"",\$2);; print \$1 \$2}'`; +my @xdsh_UUID_lines = split("[\n\r]", $xcatinfo_image_UUID); + +my $xcatinfo_image_name = ` echo "$all_xdsh_output" | awk -F"=" '/IMAGENAME/ {gsub(/IMAGENAME/,"",\$1); gsub(/'"'"'/,"",\$2); print \$1 \$2}'`; +my @xdsh_name_lines = split("[\n\r]", $xcatinfo_image_name); + my %node_running_image_uuid_hash; -my %node_defined_image_uuid_hash; my %node_running_image_name_hash; -my %node_defined_image_name_hash; -foreach (@pingable_nodes) { - probe_utils->send_msg("$output", "d", "---- Gathering information from node $_ ----"); - - # Next, from all pingable nodes get the IMAGENAME and IMAGEUUID entries from xcatinfo file - my $output = `xdsh $_ "cat /opt/xcat/xcatinfo"`; - my $xcatinfo_image_UUID = ` echo "$output" | awk -F"=" '/IMAGEUUID/ {gsub(/'"'"'/,"",\$2); print \$2}'`; - my $xcatinfo_image_name = ` echo "$output" | awk -F"=" '/IMAGENAME/ {gsub(/'"'"'/,"",\$2); print \$2}'`; - chomp($xcatinfo_image_UUID); - chomp($xcatinfo_image_name); - if (length($xcatinfo_image_UUID) <= 0) { - $xcatinfo_image_UUID = $na; - } - if (length($xcatinfo_image_name) <= 0) { - $xcatinfo_image_name = $na; - } - $node_running_image_uuid_hash{$_} = $xcatinfo_image_UUID; - $node_running_image_name_hash{$_} = $xcatinfo_image_name; - print "Node $_ is running image $node_running_image_name_hash{$_} with UUID $node_running_image_uuid_hash{$_} \n" if ($VERBOSE); - - # Next, get UUID from rootimg directory xcatinfo file of the provmethod osimage - my $lsdef_provmethod = `lsdef $_ -i provmethod -c | cut -d "=" -f 2`; - chomp($lsdef_provmethod); - my $rootimagedir = $na; - if (length($lsdef_provmethod) > 0) { - $rootimagedir = `lsdef -t osimage $lsdef_provmethod -i rootimgdir -c | cut -d "=" -f 2`; - chomp($rootimagedir); - if (length($rootimagedir) > 0) { - $defined_UUID = `awk -F"'" '/IMAGEUUID/ {print \$2}' $rootimagedir/rootimg/opt/xcat/xcatinfo`; - chomp($defined_UUID); - if (length($defined_UUID) < 1) { - $defined_UUID = $na; - } - } +# Build a hash of key=hostname, value=running UUID +foreach (@xdsh_UUID_lines) { + my ($hostname, $uuid) = split ": ", $_; + chomp($hostname); + chomp($uuid); + if (length($uuid) > 0) { + $node_running_image_uuid_hash{$hostname} = $uuid; } else { - $lsdef_provmethod = $na; + $node_running_image_uuid_hash{$hostname} = $na; } - $node_defined_image_uuid_hash{$_} = $defined_UUID; - $node_defined_image_name_hash{$_} = $lsdef_provmethod; - print "Node $_ has defined image $lsdef_provmethod at $rootimagedir with UUID $defined_UUID\n" if ($VERBOSE); } +# It is possible that some older version xCAT compute nodes will not have an IMAGEUUID line in +# the xcatinfo file, for those nodes insert $na as the running UUID value +foreach (@pingable_nodes) { + unless (exists($node_running_image_uuid_hash{$_})) { + $node_running_image_uuid_hash{$_} = $na; + } +} + +# Build a hash of key=hostname, value=running OS image name +foreach (@xdsh_name_lines) { + my ($hostname, $osimage_name) = split ": ", $_; + chomp($hostname); + chomp($osimage_name); + if (length($osimage_name) > 0) { + $node_running_image_name_hash{$hostname} = $osimage_name; + } + else { + $node_running_image_name_hash{$hostname} = $na; + } +} + +# print Dumper(\%node_running_image_uuid_hash); +# print Dumper(\%node_running_image_name_hash); + # Information gathering is done. Now do veification checking. # Probe verification step 1 - make sure all nodes are installed with the osimage name and imageUUID as defined on MN From a067a1491ea57734757711cf2e6e81f44c089e9a Mon Sep 17 00:00:00 2001 From: Xiaopeng Wang Date: Tue, 28 Jun 2016 09:31:43 +0800 Subject: [PATCH 185/310] add new supported version rh7 and sles12 for restapi setup doc --- docs/source/advanced/restapi/restapi_setup/restapi_setup.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/advanced/restapi/restapi_setup/restapi_setup.rst b/docs/source/advanced/restapi/restapi_setup/restapi_setup.rst index da560ffd9..a2abb4498 100644 --- a/docs/source/advanced/restapi/restapi_setup/restapi_setup.rst +++ b/docs/source/advanced/restapi/restapi_setup/restapi_setup.rst @@ -3,7 +3,7 @@ Enable the HTTPS service for REST API To improve the security between the REST API client and server, enabling the HTTPS service on the xCAT MN is recommended. And the REST API client should use the 'https' to access web server instead of the 'http'. -* **[RHEL6 (x86_64/ppc64) and RHEL5 (x86_64)]** :: +* **[RHEL6/7 (x86_64/ppc64) and RHEL5 (x86_64)]** :: yum install mod_ssl service httpd restart @@ -16,7 +16,7 @@ To improve the security between the REST API client and server, enabling the HTT rpm -e --nodeps httpd.ppc64 rpm -i httpd.ppc mod_ssl.ppc -* **[SLES10/11 (x86_64/ppc64)]** :: +* **[SLES10/11/12 (x86_64/ppc64)]** :: a2enmod ssl a2enflag SSL From 4967f9b80c628ee40cccdeb699ca2e467ce4a331 Mon Sep 17 00:00:00 2001 From: immarvin Date: Mon, 27 Jun 2016 22:24:52 -0400 Subject: [PATCH 186/310] save the content of the partition file to xcat.log to inspect the partition scheme after installation --- xCAT-server/share/xcat/install/scripts/pre.rh | 5 +++++ xCAT-server/share/xcat/install/scripts/pre.rh.rhels7 | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/install/scripts/pre.rh b/xCAT-server/share/xcat/install/scripts/pre.rh index 65f66380d..0e95da4e4 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.rh +++ b/xCAT-server/share/xcat/install/scripts/pre.rh @@ -223,6 +223,11 @@ echo "part / --size 1 --grow --ondisk $instdisk --fstype $FSTYPE" >> /tmp/partit #XCA_PARTITION_SCRIPT# +#save the content of /tmp/partitionfile in /var/log/xcat/xcat.log +#so that we can inspect the partition scheme after installation +echo "=================The Partition Scheme================" +cat /tmp/partitionfile +echo "=====================================================" # The following code is to generate the repository for the installation cat /proc/cmdline diff --git a/xCAT-server/share/xcat/install/scripts/pre.rh.rhels7 b/xCAT-server/share/xcat/install/scripts/pre.rh.rhels7 index f9125de9d..9bdb9552d 100755 --- a/xCAT-server/share/xcat/install/scripts/pre.rh.rhels7 +++ b/xCAT-server/share/xcat/install/scripts/pre.rh.rhels7 @@ -210,7 +210,11 @@ if [ -n "#ENV:PERSKCMDLINE#" ];then grep bootloader /tmp/partitionfile >/dev/null 2>&1|| echo -e "bootloader --append=\"#ENV:PERSKCMDLINE#\"" >>/tmp/partitionfile fi - +#save the content of /tmp/partitionfile in /var/log/xcat/xcat.log +#so that we can inspect the partition scheme after installation +echo "=================The Partition Scheme================" +cat /tmp/partitionfile +echo "=====================================================" # The following code is to generate the repository for the installation cat /proc/cmdline From 394eca0f5046ea6cfa41f923a206913baa2cad8c Mon Sep 17 00:00:00 2001 From: penguhyang Date: Tue, 7 Jun 2016 05:36:29 -0400 Subject: [PATCH 187/310] fix #1157, enhance rinstall command --- .../references/man8/rinstall.8.rst | 62 +- .../references/man8/winstall.8.rst | 79 +- xCAT-client/pods/man8/rinstall.8.pod | 48 +- xCAT-client/pods/man8/winstall.8.pod | 59 +- xCAT-server/lib/xcat/plugins/rinstall.pm | 794 ++++++++++-------- 5 files changed, 644 insertions(+), 398 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man8/rinstall.8.rst b/docs/source/guides/admin-guides/references/man8/rinstall.8.rst index 73ffc705d..0e06cd9e6 100644 --- a/docs/source/guides/admin-guides/references/man8/rinstall.8.rst +++ b/docs/source/guides/admin-guides/references/man8/rinstall.8.rst @@ -19,7 +19,11 @@ Name **************** -\ **rinstall**\ [\ **-O | -**\ **-osimage**\ ] [\ **-c | -**\ **-console**\ ] [\ *noderange*\ ] +\ **rinstall**\ \ *noderange*\ \ **boot**\ | \ **shell**\ | \ **runcmd=bmcsetup**\ [\ **-c | -**\ **-console**\ ] [\ **-V | -**\ **-verbose**\ ] + +\ **rinstall**\ \ *noderange*\ \ **osimage**\ =\ *imagename*\ | [\ **-O**\ ] \ *imagename*\ [\ **-**\ **-ignorekernelchk**\ ] [\ **-c | -**\ **-console**\ ] [\ **-u | -**\ **-uefimode**\ ] [\ **-V | -**\ **-verbose**\ ] + +\ **rinstall**\ [\ **-h | -**\ **-help | -v | -**\ **-version**\ ] ******************* @@ -27,9 +31,9 @@ Name ******************* -\ **rinstall**\ is a convenience command that will change tables as requested for operating system version, profile, and architecture, call \ **nodeset**\ to modify the network boot configuration, call \ **rsetboot**\ net to set the next boot over network (only support nodes with "nodetype.mgt=ipmi", for other nodes, make sure the correct boot order has been set before \ **rinstall**\ ), and \ **rpower**\ to begin a boot cycle. +\ **rinstall**\ is a convenience command to begin OS provision on a noderange(support nodes with "nodetype.mgt=ipmi,blade,hmc,ivm,fsp,kvm,esx,rhevm"). -If [\ **-O | -**\ **-osimage**\ ] is specified or nodetype.provmethod=\ **osimage**\ is set, provision the noderange with the osimage specified/configured, ignore the table change options if specified. +If \ **osimage**\ =\ *imagename*\ | \ **-O**\ \ *imagename*\ is specified or nodetype.provmethod=\ **osimage**\ is set, provision the noderange with the osimage specified/configured. If -c is specified, it will then run rcons on the node. This is allowed only if one node in the noderange. If need consoles on multiple nodes , see winstall(8)|winstall.8. @@ -40,6 +44,44 @@ If -c is specified, it will then run rcons on the node. This is allowed only if +\ **boot**\ + + Instruct network boot loader to be skipped, generally meaning boot to hard disk + + + +\ **osimage | osimage=**\ \ *imagename*\ |\ **-O**\ \ *imagename*\ + + Prepare server for installing a node using the specified os image. The os image is defined in the \ *osimage*\ table and \ *linuximage*\ table. If the is omitted, the os image name will be obtained from \ *nodetype.provmethod*\ for the node. + + + +\ **-**\ **-ignorekernelchk**\ + + Skip the kernel version checking when injecting drivers from osimage.driverupdatesrc. That means all drivers from osimage.driverupdatesrc will be injected to initrd for the specific target kernel. + + + +\ **runimage**\ =\ *task*\ + + If you would like to run a task after deployment, you can define that task with this attribute. + + + +\ **runcmd=bmcsetup**\ + + This instructs the node to boot to the xCAT nbfs environment and proceed to configure BMC + for basic remote access. This causes the IP, netmask, gateway, username, and password to be programmed according to the configuration table. + + + +\ **shell**\ + + This instructs tho node to boot to the xCAT genesis environment, and present a shell prompt on console. + The node will also be able to be sshed into and have utilities such as wget, tftp, scp, nfs, and cifs. It will have storage drivers available for many common systems. + + + \ **-h | -**\ **-help**\ Display usage message. @@ -52,15 +94,21 @@ If -c is specified, it will then run rcons on the node. This is allowed only if -\ **-O | -**\ **-osimage**\ +\ **-u | -**\ **-uefimode**\ - Specifies the osimage to provision. + For BMC-based servers, to specify the next boot mode to be "UEFI Mode". + + + +\ **-V | -**\ **-Verbose**\ + + Verbose output. \ **-c | -**\ **-console**\ - Requests that rinstall runs rcons once the provision starts. This will only work if there is only one node in the noderange. See winstall(8)|winstall.8 for starting nsoles on multiple nodes. + Requests that rinstall runs rcons once the provision starts. This will only work if there is only one node in the noderange. See winstall(8)|winstall.8 for starting consoles on multiple nodes. @@ -86,7 +134,7 @@ If -c is specified, it will then run rcons on the node. This is allowed only if .. code-block:: perl - rinstall node1-node20 -O rhels6.4-ppc64-netboot-compute + rinstall node1-node20 osimage=rhels6.4-ppc64-netboot-compute diff --git a/docs/source/guides/admin-guides/references/man8/winstall.8.rst b/docs/source/guides/admin-guides/references/man8/winstall.8.rst index d1c5aa91e..cfe21170c 100644 --- a/docs/source/guides/admin-guides/references/man8/winstall.8.rst +++ b/docs/source/guides/admin-guides/references/man8/winstall.8.rst @@ -19,9 +19,11 @@ Name **************** -\ **winstall**\ [\ **-o | -**\ **-osver**\ ] [\ **-p | -**\ **-profile**\ ] [\ **-a | -**\ **-arch**\ ] [\ *noderange*\ ] +\ **rinstall**\ \ *noderange*\ \ **boot**\ | \ **shell**\ | \ **runcmd=bmcsetup**\ [\ **-c | -**\ **-console**\ ] [\ **-V | -**\ **-verbose**\ ] -\ **winstall**\ [\ **-O | -**\ **-osimage**\ ] [\ *noderange*\ ] +\ **rinstall**\ \ *noderange*\ \ **osimage**\ =\ *imagename*\ | [\ **-O**\ ] \ *imagename*\ [\ **-**\ **-ignorekernelchk**\ ] [\ **-c | -**\ **-console**\ ] [\ **-u | -**\ **-uefimode**\ ] [\ **-V | -**\ **-verbose**\ ] + +\ **rinstall**\ [\ **-h | -**\ **-help | -v | -**\ **-version**\ ] ******************* @@ -29,10 +31,9 @@ Name ******************* -\ **winstall**\ is a convenience tool that will change attributes as requested for operating system version, profile, and architecture, call \ **nodeset**\ to modify the network boot configuration, call \ **rsetboot**\ net to set the next boot over network (only support nodes -with "nodetype.mgt=ipmi", for other nodes, make sure the correct boot order has been set before \ **winstall**\ ), and \ **rpower**\ to begin a boot cycle. +\ **winstall**\ is a convenience command to begin OS provision on a noderange(support nodes with "nodetype.mgt=ipmi,blade,hmc,ivm,fsp,kvm,esx,rhevm"). -If [\ **-O | -**\ **-osimage**\ ] is specified or nodetype.provmethod=\ *osimage*\ is set, provision the noderange with the osimage specified/configured, ignore the table change options if specified. +If \ **osimage**\ =\ *imagename*\ | \ **-O**\ \ *imagename*\ is specified or nodetype.provmethod=\ **osimage**\ is set, provision the noderange with the osimage specified/configured. It will then run wcons on the nodes. @@ -43,6 +44,44 @@ It will then run wcons on the nodes. +\ **boot**\ + + Instruct network boot loader to be skipped, generally meaning boot to hard disk + + + +\ **osimage | osimage=**\ \ *imagename*\ |\ **-O**\ \ *imagename*\ + + Prepare server for installing a node using the specified os image. The os image is defined in the \ *osimage*\ table and \ *linuximage*\ table. If the is omitted, the os image name will be obtained from \ *nodetype.provmethod*\ for the node. + + + +\ **-**\ **-ignorekernelchk**\ + + Skip the kernel version checking when injecting drivers from osimage.driverupdatesrc. That means all drivers from osimage.driverupdatesrc will be injected to initrd for the specific target kernel. + + + +\ **runimage**\ =\ *task*\ + + If you would like to run a task after deployment, you can define that task with this attribute. + + + +\ **runcmd=bmcsetup**\ + + This instructs the node to boot to the xCAT nbfs environment and proceed to configure BMC + for basic remote access. This causes the IP, netmask, gateway, username, and password to be programmed according to the configuration table. + + + +\ **shell**\ + + This instructs tho node to boot to the xCAT genesis environment, and present a shell prompt on console. + The node will also be able to be sshed into and have utilities such as wget, tftp, scp, nfs, and cifs. It will have storage drivers available for many common systems. + + + \ **-h | -**\ **-help**\ Display usage message. @@ -55,27 +94,21 @@ It will then run wcons on the nodes. -\ **-o | -**\ **-osver**\ +\ **-u | -**\ **-uefimode**\ - Specifies which os version to provision. If unspecified, the current node os setting is used. Will be ignored if [\ *-O*\ | \ *--osimage*\ ] is specified or nodetype.provmethod=\ *osimage*\ . + For BMC-based servers, to specify the next boot mode to be "UEFI Mode". -\ **-p | -**\ **-profile**\ +\ **-V | -**\ **-Verbose**\ - Specifies what profile should be used of the operating system. If not specified the current node profile setting is used. Will be ignored if [\ **-O | -**\ **-osimage**\ ] is specified or nodetype.provmethod=\ *osimage*\ . + Verbose output. -\ **-a | -**\ **-arch**\ +\ **-c | -**\ **-console**\ - Specifies what architecture of the OS to provision. Typically this is unneeded, but if provisioning between x86_64 and x86 frequently, this may be a useful flag. Will be ignored if [\ **-O | -**\ **-osimage**\ ] is specified or nodetype.provmethod=\ *osimage*\ . - - - -\ **-O | -**\ **-osimage**\ - - Specifies the osimage to provision. + Requests that rinstall runs rcons once the provision starts. This will only work if there is only one node in the noderange. See winstall(8)|winstall.8 for starting consoles on multiple nodes. @@ -96,17 +129,7 @@ It will then run wcons on the nodes. -2. Provision nodes 1 through 20, forcing rhels5.1 and compute profile. - - - .. code-block:: perl - - winstall node1-node20 -o rhels5.1 -p compute - - - - -3. Provision nodes 1 through 20 with the osimage rhels6.4-ppc64-netboot-compute. +2. Provision nodes 1 through 20 with the osimage rhels6.4-ppc64-netboot-compute. .. code-block:: perl diff --git a/xCAT-client/pods/man8/rinstall.8.pod b/xCAT-client/pods/man8/rinstall.8.pod index 306539161..f7060e929 100644 --- a/xCAT-client/pods/man8/rinstall.8.pod +++ b/xCAT-client/pods/man8/rinstall.8.pod @@ -4,13 +4,17 @@ B - Begin OS provision on a noderange =head1 B -B [B<-O>|B<--osimage>] [B<-c>|B<--console>] [I] +B I B | B | B [B<-c>|B<--console>] [B<-V>|B<--verbose>] + +B I B=I | [B<-O>] I [B<--ignorekernelchk>] [B<-c>|B<--console>] [B<-u>|B<--uefimode>] [B<-V>|B<--verbose>] + +B [B<-h>|B<--help>|B<-v>|B<--version>] =head1 B -B is a convenience command that will change tables as requested for operating system version, profile, and architecture, call B to modify the network boot configuration, call B net to set the next boot over network (only support nodes with "nodetype.mgt=ipmi", for other nodes, make sure the correct boot order has been set before B), and B to begin a boot cycle. +B is a convenience command to begin OS provision on a noderange(support nodes with "nodetype.mgt=ipmi,blade,hmc,ivm,fsp,kvm,esx,rhevm"). -If [B<-O>|B<--osimage>] is specified or nodetype.provmethod=B is set, provision the noderange with the osimage specified/configured, ignore the table change options if specified. +If B=I | B<-O> I is specified or nodetype.provmethod=B is set, provision the noderange with the osimage specified/configured. If -c is specified, it will then run rcons on the node. This is allowed only if one node in the noderange. If need consoles on multiple nodes , see L. @@ -18,6 +22,32 @@ If -c is specified, it will then run rcons on the node. This is allowed only if =over 7 +=item B + +Instruct network boot loader to be skipped, generally meaning boot to hard disk + +=item B|BI|B<-O>I + +Prepare server for installing a node using the specified os image. The os image is defined in the I table and I table. If the is omitted, the os image name will be obtained from I for the node. + +=item B<--ignorekernelchk> + +Skip the kernel version checking when injecting drivers from osimage.driverupdatesrc. That means all drivers from osimage.driverupdatesrc will be injected to initrd for the specific target kernel. + +=item B=I + +If you would like to run a task after deployment, you can define that task with this attribute. + +=item B + +This instructs the node to boot to the xCAT nbfs environment and proceed to configure BMC +for basic remote access. This causes the IP, netmask, gateway, username, and password to be programmed according to the configuration table. + +=item B + +This instructs tho node to boot to the xCAT genesis environment, and present a shell prompt on console. +The node will also be able to be sshed into and have utilities such as wget, tftp, scp, nfs, and cifs. It will have storage drivers available for many common systems. + =item B<-h>|B<--help> Display usage message. @@ -26,13 +56,17 @@ Display usage message. Display version. -=item B<-O>|B<--osimage> +=item B<-u>|B<--uefimode> -Specifies the osimage to provision. +For BMC-based servers, to specify the next boot mode to be "UEFI Mode". + +=item B<-V>|B<--Verbose> + +Verbose output. =item B<-c>|B<--console> -Requests that rinstall runs rcons once the provision starts. This will only work if there is only one node in the noderange. See L for starting nsoles on multiple nodes. +Requests that rinstall runs rcons once the provision starts. This will only work if there is only one node in the noderange. See L for starting consoles on multiple nodes. =back @@ -49,7 +83,7 @@ Provision nodes 1 through 20, using their current configuration. =item 2. Provision nodes 1 through 20 with the osimage rhels6.4-ppc64-netboot-compute. - rinstall node1-node20 -O rhels6.4-ppc64-netboot-compute + rinstall node1-node20 osimage=rhels6.4-ppc64-netboot-compute =item 3. Provision node1 and start a console to monitor the process. diff --git a/xCAT-client/pods/man8/winstall.8.pod b/xCAT-client/pods/man8/winstall.8.pod index 5059fcbf4..e8f25bb3c 100644 --- a/xCAT-client/pods/man8/winstall.8.pod +++ b/xCAT-client/pods/man8/winstall.8.pod @@ -4,16 +4,17 @@ B - Begin OS provision on a noderange =head1 B -B [B<-o>|B<--osver>] [B<-p>|B<--profile>] [B<-a>|B<--arch>] [I] +B I B | B | B [B<-c>|B<--console>] [B<-V>|B<--verbose>] -B [B<-O>|B<--osimage>] [I] +B I B=I | [B<-O>] I [B<--ignorekernelchk>] [B<-c>|B<--console>] [B<-u>|B<--uefimode>] [B<-V>|B<--verbose>] + +B [B<-h>|B<--help>|B<-v>|B<--version>] =head1 B -B is a convenience tool that will change attributes as requested for operating system version, profile, and architecture, call B to modify the network boot configuration, call B net to set the next boot over network (only support nodes -with "nodetype.mgt=ipmi", for other nodes, make sure the correct boot order has been set before B), and B to begin a boot cycle. +B is a convenience command to begin OS provision on a noderange(support nodes with "nodetype.mgt=ipmi,blade,hmc,ivm,fsp,kvm,esx,rhevm"). -If [B<-O>|B<--osimage>] is specified or nodetype.provmethod=I is set, provision the noderange with the osimage specified/configured, ignore the table change options if specified. +If B=I | B<-O> I is specified or nodetype.provmethod=B is set, provision the noderange with the osimage specified/configured. It will then run wcons on the nodes. @@ -21,6 +22,32 @@ It will then run wcons on the nodes. =over 7 +=item B + +Instruct network boot loader to be skipped, generally meaning boot to hard disk + +=item B|BI|B<-O>I + +Prepare server for installing a node using the specified os image. The os image is defined in the I table and I table. If the is omitted, the os image name will be obtained from I for the node. + +=item B<--ignorekernelchk> + +Skip the kernel version checking when injecting drivers from osimage.driverupdatesrc. That means all drivers from osimage.driverupdatesrc will be injected to initrd for the specific target kernel. + +=item B=I + +If you would like to run a task after deployment, you can define that task with this attribute. + +=item B + +This instructs the node to boot to the xCAT nbfs environment and proceed to configure BMC +for basic remote access. This causes the IP, netmask, gateway, username, and password to be programmed according to the configuration table. + +=item B + +This instructs tho node to boot to the xCAT genesis environment, and present a shell prompt on console. +The node will also be able to be sshed into and have utilities such as wget, tftp, scp, nfs, and cifs. It will have storage drivers available for many common systems. + =item B<-h>|B<--help> Display usage message. @@ -29,22 +56,17 @@ Display usage message. Display version. -=item B<-o>|B<--osver> +=item B<-u>|B<--uefimode> -Specifies which os version to provision. If unspecified, the current node os setting is used. Will be ignored if [I<-O> | I<--osimage>] is specified or nodetype.provmethod=I. +For BMC-based servers, to specify the next boot mode to be "UEFI Mode". -=item B<-p>|B<--profile> +=item B<-V>|B<--Verbose> -Specifies what profile should be used of the operating system. If not specified the current node profile setting is used. Will be ignored if [B<-O>|B<--osimage>] is specified or nodetype.provmethod=I. +Verbose output. +=item B<-c>|B<--console> -=item B<-a>|B<--arch> - -Specifies what architecture of the OS to provision. Typically this is unneeded, but if provisioning between x86_64 and x86 frequently, this may be a useful flag. Will be ignored if [B<-O>|B<--osimage>] is specified or nodetype.provmethod=I. - -=item B<-O>|B<--osimage> - -Specifies the osimage to provision. +Requests that rinstall runs rcons once the provision starts. This will only work if there is only one node in the noderange. See L for starting consoles on multiple nodes. =back @@ -58,11 +80,6 @@ Provison nodes 1 through 20, using their current configuration. winstall node1-node20 =item 2. -Provision nodes 1 through 20, forcing rhels5.1 and compute profile. - - winstall node1-node20 -o rhels5.1 -p compute - -=item 3. Provision nodes 1 through 20 with the osimage rhels6.4-ppc64-netboot-compute. winstall node1-node20 -O rhels6.4-ppc64-netboot-compute diff --git a/xCAT-server/lib/xcat/plugins/rinstall.pm b/xCAT-server/lib/xcat/plugins/rinstall.pm index 3add7f2a6..78f758e3f 100644 --- a/xCAT-server/lib/xcat/plugins/rinstall.pm +++ b/xCAT-server/lib/xcat/plugins/rinstall.pm @@ -2,11 +2,11 @@ #------------------------------------------------------- =head1 - xCAT plugin package to handle rinstall and winstall + xCAT plugin package to handle rinstall and winstall - Supported command: - rinstall - runs nodeset, rsetboot,rpower commands - winstall - also opens the console + Supported command: + rinstall - runs nodeset, rsetboot, rpower commands + winstall - also opens the console =cut @@ -26,18 +26,16 @@ use Getopt::Long; =head3 handled_commands -Return list of commands handled by this plugin + Return list of commands handled by this plugin =cut #------------------------------------------------------- - -sub handled_commands -{ +sub handled_commands { return { - rinstall => "rinstall", - winstall => "rinstall", - }; + rinstall => "rinstall", + winstall => "rinstall", + }; } #------------------------------------------------------- @@ -47,353 +45,509 @@ sub handled_commands =cut #------------------------------------------------------- -sub process_request -{ - - my $request = shift; +sub process_request { + my $request = shift; my $callback = shift; - my $subreq = shift; + my $subreq = shift; rinstall($request, $callback, $subreq); } #------------------------------------------------------- -=head3 rinstall - - Wrapper around nodeset, rsetboot, rpower for the admin convenience +=head3 rinstall + Wrapper around nodeset, rsetboot, rpower for the admin convenience =cut #------------------------------------------------------- -sub rinstall -{ +sub rinstall { my ($req, $callback, $subreq) = @_; $::CALLBACK=$callback; - my $OSVER; - my $PROFILE; - my $ARCH; my $CONSOLE; my $OSIMAGE; + my $STATES; + my $ignorekernelchk; + my $VERBOSE; my $HELP; my $VERSION; - my $command = $req->{command}->[0]; # could be rinstall on winstall - my $args; - if (defined($req->{arg}) ) { # there are arguments - $args=$req->{arg}; # argument - @ARGV = @{$args}; - } + my $UEFIMODE; + # Could be rinstall or winstall + my $command = $req->{command}->[0]; + my $nodes; my @nodes; - if (defined ($req->{node})) { # there are nodes - $nodes = $req->{node}; - @nodes=@$nodes; + my %nodes; + # There are nodes + if (defined($req->{node})) { + $nodes = $req->{node}; + @nodes = @$nodes; } - # no arguments, no nodes then input wrong - if ((scalar(@nodes) == 0) && (scalar(@ARGV) == 0)){ - &usage($command,$callback); - return 1; - } - #print Dumper($req); - Getopt::Long::Configure("bundling"); - unless ( - GetOptions( - 'o|osver=s' => \$OSVER, - 'p|profile=s' => \$PROFILE, - 'a|arch=s' => \$ARCH, - 'O|osimage=s' => \$OSIMAGE, - 'h|help' => \$HELP, - 'v|version' => \$VERSION, - 'c|console' => \$CONSOLE - ) - ) - { - &usage($command,$callback); - return 1; + my $args; + # There are arguments + if (defined($req->{arg})) { + $args = $req->{arg}; + @ARGV = @{$args}; } - if ($HELP) - { - &usage($command,$callback); - return 0; + + if (($command =~ /rinstall/) or ($command =~ /winstall/)) { + my $state = $ARGV[0]; + my $reststates; + ($state, $reststates) = split (/,/, $state, 2); + chomp($state); + if ($state eq "image" or $state eq "winshell" or $state =~ /^osimage/) { + my $target; + my $action; + if ($state =~ /=/) { + ($state,$target) = split '=',$state,2; + if ($target =~ /:/) { + ($target, $action) = split ':',$target,2; + } + } + else { + if ($state =~ /:/) { + ($state, $action) = split ':',$state,2; + } + } + if ($state eq 'osimage') { + $OSIMAGE = $target; + } + } + else { + unless ($state =~ /-/) { + $STATES = $state; + } + } + + Getopt::Long::Configure("bundling"); + Getopt::Long::Configure("no_pass_through"); + unless ( + GetOptions ('O|osimage=s' => \$OSIMAGE, + 'ignorekernelchk' => \$ignorekernelchk, + 'V|verbose' => \$VERBOSE, + 'h|help' => \$HELP, + 'v|version' => \$VERSION, + 'u|uefimode' => \$UEFIMODE, + 'c|console' => \$CONSOLE) + ) { + &usage($command,$callback); + return 1; + } } - if ($VERSION) - { + if ($HELP) { + &usage($command,$callback); + return 0; + } + if ($VERSION) { my $version = xCAT::Utils->Version(); my $rsp = {}; $rsp->{data}->[0] = "$version"; xCAT::MsgUtils->message("I", $rsp, $callback); - return (0); + return 0; } - - if (scalar @$nodes eq 0) - { - my $rsp = {}; - $rsp->{error}->[0] ="noderange not supplied"; - xCAT::MsgUtils->message("E", $rsp, $callback); + if (scalar(@nodes) == 0) { + &usage($command,$callback); return 1; } - my $rc = 0; - my %pnhash; + my $rc = 0; + my @parameter; - - if ($OSIMAGE) - { + my $nodehmtable = xCAT::Table->new("nodehm"); + my $nodehmcache = $nodehmtable->getNodesAttribs(\@nodes, ['mgt']); + $nodehmtable->close(); - # -O|--osimage is specified, ignore any -a,-p,-o options, + if ($OSIMAGE) { + + # if -O|--osimage or osimage= is specified, # call "nodeset ... osimage= ..." to set the boot state of the noderange to the specified osimage, - # "nodeset" will handle the updating of node attributes such as os,arch,profile,provmethod - # verify input - &checkoption("[-O|--osimage] $OSIMAGE",$OSVER,$PROFILE,$ARCH,$callback); + # "nodeset" will handle the updating of node attributes such as os,arch,profile,provmethod. - # run nodeset $noderange osimage=$OSIMAGE - my @osimageargs; - push @osimageargs,"osimage=$OSIMAGE" ; - my $res = - xCAT::Utils->runxcmd( - { - command => ["nodeset"], - node => \@nodes, - arg => \@osimageargs - }, - $subreq, -1, 1); - $rc=$::RUNCMD_RC; - my $rsp = {}; - foreach my $line (@$res) { - $rsp->{data} ->[0] = $line; - xCAT::MsgUtils->message("I", $rsp, $callback); - } + my $noderestable = xCAT::Table->new("noderes"); + my $noderescache = $noderestable->getNodesAttribs(\@nodes, ['netboot']); + $noderestable->close(); + my $nodetypetable = xCAT::Table->new("nodetype"); + my $nodetypecache = $nodetypetable->getNodesAttribs(\@nodes, ['arch']); + $nodetypetable->close(); + my $osimagetable = xCAT::Table->new("osimage"); + (my $ref) = $osimagetable->getAttribs({imagename => $OSIMAGE}, 'osvers', 'osarch','imagetype'); + $osimagetable->close(); + unless (defined($ref->{osarch})) { + my $rsp = {}; + $rsp->{error}->[0] = "$OSIMAGE 'osarch' attribute not defined in 'osimage' table."; + $rsp->{errorcode}->[0] = 1; + xCAT::MsgUtils->message("E", $rsp, $callback); + return 1; + } + my $osimagearch = $ref->{osarch}; + my $netbootval = xCAT::Utils->lookupNetboot($ref->{osvers},$ref->{osarch},$ref->{imagetype}); + my @validnodes; + foreach my $node (@nodes) { + unless ($noderescache) { next; } + unless ($nodetypecache) { next; } + unless ($nodehmcache) { next; } + my $noderesattribs = $noderescache->{$node}->[0]; + my $nodetypeattribs = $nodetypecache->{$node}->[0]; + my $nodehmattribs = $nodehmcache->{$node}->[0]; + unless (defined($noderesattribs) and defined($noderesattribs->{'netboot'})) { + my $rsp = {}; + $rsp->{error}->[0] = "$node: Missing the 'netboot' attribute."; + $rsp->{errorcode}->[0] = 1; + xCAT::MsgUtils->message("E", $rsp, $callback); + next; + } + else { + unless($netbootval =~ /$noderesattribs->{'netboot'}/i){ + $callback->({warning=> [$node.": $noderesattribs->{'netboot'} might be invalid when provisioning $OSIMAGE,valid options: \"$netbootval\". For more details see the 'netboot' description in the output of \"tabdump -d noderes\"."]}); + next; + } + } + + unless (defined($nodetypeattribs) and defined($nodetypeattribs->{'arch'})) { + my $rsp = {}; + $rsp->{error}->[0] = "$node: 'arch' attribute not defined in 'nodetype' table."; + $rsp->{errorcode}->[0] = 1; + xCAT::MsgUtils->message("E", $rsp, $callback); + next; + } + my $nodetypearch = $nodetypeattribs->{'arch'}; + if ($nodetypearch ne $osimagearch) { + unless ((($nodetypearch =~ /ppc64le/) or ($nodetypearch =~ /ppc64el/)) and (($osimagearch =~ /ppc64le/) or ($osimagearch =~ /ppc64el/))) { + my $rsp = {}; + $rsp->{error}->[0] = "$node: The value of 'arch' attribute is not same as the 'osarch' attribute for osimage."; + $rsp->{errorcode}->[0] = 1; + xCAT::MsgUtils->message("E", $rsp, $callback); + next; + } + } + + unless (defined($nodehmattribs) and defined($nodehmattribs->{'mgt'})) { + my $rsp = {}; + $rsp->{error}->[0] = "$node: 'mgt' attribute not defined in 'nodehm' table."; + $rsp->{errorcode}->[0] = 1; + xCAT::MsgUtils->message("E", $rsp, $callback); + next; + } + push @validnodes, $node; + } + #only provision the normal nodes + @nodes = @validnodes; + + push @parameter,"osimage=$OSIMAGE"; + if ($ignorekernelchk) { + push @parameter," --ignorekernelchk"; + } } - else - { + elsif ($STATES) { + push @parameter,"$STATES"; + } + else { - # no osimage specified, update the node attributes specified by -a,-p,-o options thru "nodech", - # then set the boot state of each node based on the nodetype.provmethod: - # 1) if nodetype.provmethod = , ignore any -p,-o,-a option, + # No osimage specified, set the boot state of each node based on the nodetype.provmethod: + # 1) if nodetype.provmethod = [install/netboot/statelite], + # then output error message. + # 2) if nodetype.provmethod = , # then call "nodeset ... osimage" - # 2) if nodetype.provmethod = [install/netboot/statelite], - # update the node attributes specified by -a,-p,-o options thru "nodech", - # call "nodeset ... [install/netboot/statelite]" - # 3) if nodetype.provmethod is not set, use 'install' as the default value - # group the nodes according to the nodetype.provmethod - - foreach (@$nodes) - { - my $tab = xCAT::Table->new("nodetype"); - my $nthash = $tab->getNodeAttribs($_, ['provmethod']); - $tab->close(); - if (defined($nthash) and defined($nthash->{'provmethod'})) - { - push(@{$pnhash{$nthash->{'provmethod'}}}, $_); + # Group the nodes according to the nodetype.provmethod + my %tphash; + my $nodetypetable = xCAT::Table->new("nodetype"); + my $nodetypecache = $nodetypetable->getNodesAttribs(\@nodes, ['provmethod']); + $nodetypetable->close(); + foreach my $node (@nodes) { + unless ($nodetypecache) { next; } + my $nodetypeattribs = $nodetypecache->{$node}->[0]; + unless (defined($nodetypeattribs) and defined($nodetypeattribs->{'provmethod'})) { + my $rsp = {}; + $rsp->{error}->[0] = "$node: 'provmethod' attribute not defined in 'nodetype' table."; + $rsp->{errorcode}->[0] = 1; + xCAT::MsgUtils->message("E", $rsp, $callback); + next; } - else - { - - #if nodetype.provmethod is not specified, - push(@{$pnhash{'install'}}, $_); + else { + push(@{$tphash{$nodetypeattribs->{'provmethod'}}}, $node); } } - # Now for each group based on provmethod - foreach my $key (keys %pnhash) - { - $::RUNCMD_RC =0; - my $nodes = join(',', @{$pnhash{$key}}); - if ($key =~ /^(install|netboot|statelite)$/) - { - # nodetype.provmethod = [install|netboot|statelite] - my @nodechline; - if ($OSVER) - { - push @nodechline, "nodetype.os=$OSVER"; - } - if ($PROFILE) - { - push @nodechline, "nodetype.profile=$PROFILE"; - } - if ($ARCH) - { - push @nodechline, "nodetype.arch=$ARCH"; - } - if (@nodechline) - { - # run nodech $nodes $nodechline - my $res = - xCAT::Utils->runxcmd( - { - command => ["nodech"], - node => \@nodes, - arg => \@nodechline - }, - $subreq, -1, 1); - - my $rsp = {}; - $rc=$::RUNCMD_RC; - if ($rc == 0 ) { - foreach my $line (@$res) { - $rsp->{data} ->[0] = $line; - xCAT::MsgUtils->message("I", $rsp, $callback); - } - } else { # error - $rsp->{error} ->[0] = "nodech error"; - xCAT::MsgUtils->message("E", $rsp, $callback); - foreach my $line (@$res) { - $rsp->{error} ->[0] = $line; - xCAT::MsgUtils->message("E", $rsp, $callback); - } - } - } # end nodechline - - if ($rc == 0) # if no error from nodech then run nodeset - { - # run nodeset $nodes $key ( where key is install/netboot/statelite) - my @nodesetarg; - push @nodesetarg, "$key"; - my $res = - xCAT::Utils->runxcmd( - { - command => ["nodeset"], - node => \@nodes, - arg => \@nodesetarg - }, - $subreq, -1, 1); - - $rc = $::RUNCMD_RC; - my $rsp = {}; - foreach my $line (@$res) { - $rsp->{data} ->[0] = $line; - xCAT::MsgUtils->message("I", $rsp, $callback); - } - } + # Now for each group based on provmethod + my @validnodes; + foreach my $key (keys %tphash) { + $::RUNCMD_RC = 0; + my @pnnodes = @{$tphash{$key}}; + # If nodetype.provmethod = [install|netboot|statelite] + if ($key =~ /^(install|netboot|statelite)$/) { + my $rsp = {}; + $rsp->{error}->[0] = "@pnnodes: The options 'install', 'netboot', and 'statelite' have been deprecated, use 'nodeset osimage=' instead."; + $rsp->{errorcode}->[0] = 1; + xCAT::MsgUtils->message("E", $rsp, $callback); + next; } - else # if not install/netboot/statelite - { - - # nodetype.provmethod = - &checkoption("nodetype.provmethod=$key",$OSVER,$PROFILE,$ARCH,$callback); - # run nodeset $nodes osimage - my @nodesetarg; - push @nodesetarg, "osimage"; - my $res = - xCAT::Utils->runxcmd( - { - command => ["nodeset"], - node => \@nodes, - arg => \@nodesetarg - }, - $subreq, -1, 1); - - $rc = $::RUNCMD_RC; - my $rsp = {}; - foreach my $line (@$res) { - $rsp->{data} ->[0] = $line; - xCAT::MsgUtils->message("I", $rsp, $callback); - } + # If nodetype.provmethod != [install|netboot|statelite] + else { + push @validnodes, @pnnodes; } - } - } # end nodech/nodeset for each group + #only provision the normal nodes + @nodes = @validnodes; - if ($rc != 0) # we got an error with the nodeset - { - my $rsp = {}; - $rsp->{error}->[0] = "nodeset failed on certain nodes."; - xCAT::MsgUtils->message("E", $rsp, $callback); + push @parameter, "osimage"; } - # call "rsetboot" to set the boot order of the nodehm.mgt=ipmi nodes,for others, - # assume user has set the correct boot order before "rinstall" + if (scalar(@nodes) == 0) { + my $rsp = {}; + $rsp->{error}->[0] = "No available nodes for provision."; + $rsp->{errorcode}->[0] = 1; + xCAT::MsgUtils->message("E", $rsp, $callback); + return 1; + } + else { + my $rsp = {}; + $rsp->{data} ->[0] = "Provision node(s): @nodes"; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + %nodes = map { $_, 1 } @nodes; - # run rsetboot $noderange net - - my @rsetbootarg; - push @rsetbootarg, "net"; - push @rsetbootarg, "-u"; - my $res = - xCAT::Utils->runxcmd( - { - command => ["rsetboot"], - node => \@nodes, - arg => \@rsetbootarg - }, - $subreq, -1, 1); + # Run nodeset $noderange $parameter + my $res = + xCAT::Utils->runxcmd( + { + command => ["nodeset"], + node => \@nodes, + arg => \@parameter + }, + $subreq, -1, 1); $rc = $::RUNCMD_RC; - # fix output it is a hash and you must get error out of the hash. my $rsp = {}; - foreach my $line (@$res) { - $rsp->{data} ->[0] = $line; - xCAT::MsgUtils->message("I", $rsp, $callback); - } - - if ($rc != 0) # we got an error with the rsetboot - { - my $rsp = {}; - $rsp->{error}->[0] = "rsetboot failed on certain nodes."; - xCAT::MsgUtils->message("E", $rsp, $callback); - } - - - # call "rpower" to start the node provision process - - #run rpower $noderange boot - my @rpowerarg; - push @rpowerarg, "boot"; - my $res = - xCAT::Utils->runxcmd( - { - command => ["rpower"], - node => \@nodes, - arg => \@rpowerarg - }, - $subreq, -1, 1); - - $rc = $::RUNCMD_RC; - my $rsp = {}; - foreach my $line (@$res) { - $rsp->{data} ->[0] = $line; - xCAT::MsgUtils->message("I", $rsp, $callback); - } - - if ($rc != 0) # we got an error with the rsetboot - { - my $rsp = {}; - $rsp->{error}->[0] = "rpower failed on certain nodes."; - xCAT::MsgUtils->message("E", $rsp, $callback); - } - - - # Check if they asked to bring up a console ( -c) from rinstall always for winstall - $req->{startconsole}->[0] =0; - if ($command =~ /rinstall/) - { - - # for rinstall, the -c|--console option can provide the remote console for only 1 node - if ($CONSOLE) - { - if (scalar @$nodes ne 1) - { - my $rsp = {}; - $rsp->{error}->[0] = "rinstall -c only accepts one node in the noderange. See winstall for support for support of consoles on multiple nodes."; - xCAT::MsgUtils->message("E", $rsp, $callback); - return 1; - } else { # tell rinstall client ok to start rcons - $req->{startconsole}->[0] =1; - } - + if ($rc == 0) { + if ($VERBOSE) { + my @cmd = "Run command: nodeset @nodes @parameter"; + push @{$rsp->{data}}, @cmd; + push @{$rsp->{data}}, @$res; + xCAT::MsgUtils->message("I", $rsp, $callback); } } - elsif ($command =~ /winstall/) - { - - # winstall can start a wcons command to multiple nodes for monitoring the provision cycle - $req->{startconsole}->[0] =1; - + else { + # We got an error with the nodeset + my @successnodes; + my @failurenodes; + foreach my $line (@$res) { + $rsp->{data} ->[0] = $line; + if (($line =~ /: install/) or ($line =~ /: netboot/)) { + my $successnode; + my $restline; + ($successnode, $restline) = split (/:/, $line, 2); + $nodes{$successnode} = 0; + push @successnodes, $successnode; + } + xCAT::MsgUtils->message("I", $rsp, $callback); + } + foreach my $node (@nodes) { + if ($nodes{$node} = 1) { + push @failurenodes, $node; + } + } + my $rsp = {}; + $rsp->{error}->[0] = "failed to run 'nodeset' against the following nodes: @failurenodes"; + $rsp->{errorcode}->[0] = 1; + xCAT::MsgUtils->message("E", $rsp, $callback); + @nodes = @successnodes; } + # Group the nodes according to the nodehm.mgt + my %hmhash; + foreach my $node (@nodes) { + unless ($nodehmcache) { next; } + my $nodehmattribs = $nodehmcache->{$node}->[0]; + push(@{$hmhash{$nodehmattribs->{'mgt'}}}, $node); + } + + # Now for each group based on mgt + foreach my $hmkey (keys %hmhash) { + $::RUNCMD_RC = 0; + my @nodes = @{$hmhash{$hmkey}}; + unless (($hmkey =~ /^ipmi$/) or ($hmkey =~ /^blade$/) or ($hmkey =~ /^hmc$/) or ($hmkey =~ /^ivm$/) or ($hmkey =~ /^fsp$/) or ($hmkey =~ /^kvm$/) or ($hmkey =~ /^esx$/) or ($hmkey =~ /^rhevm$/)) { + my $rsp = {}; + $rsp->{error}->[0] = "@nodes: rinstall only support nodehm.mgt type 'ipmi', 'blade', 'hmc', 'ivm', 'fsp', 'kvm', 'esx', 'rhevm'."; + $rsp->{errorcode}->[0] = 1; + xCAT::MsgUtils->message("E", $rsp, $callback); + next; + } + if (($hmkey =~ /^ivm$/) or ($hmkey =~ /^fsp$/) or ($hmkey =~ /^hmc$/)) { + %nodes = map { $_, 1 } @nodes; + # Run rnetboot $noderange + my $res = + xCAT::Utils->runxcmd( + { + command => ["rnetboot"], + node => \@nodes + }, + $subreq, -1, 1); + + $rc = $::RUNCMD_RC; + my $rsp = {}; + if ($rc == 0) { + if ($VERBOSE) { + my @cmd = "Run command: rnetboot @nodes"; + push @{$rsp->{data}}, @cmd; + push @{$rsp->{data}}, @$res; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + } + else { + # We got an error with the rnetboot + my @failurenodes; + foreach my $line (@$res) { + $rsp->{data} ->[0] = $line; + if ($line =~ /: Success/) { + my $successnode; + my $restline; + ($successnode, $restline) = split (/:/, $line, 2); + $nodes{$successnode} = 0; + } + xCAT::MsgUtils->message("I", $rsp, $callback); + } + foreach my $node (@nodes) { + if ($nodes{$node} = 1) { + push @failurenodes, $node; + } + } + my $rsp = {}; + $rsp->{error}->[0] = "failed to run 'rnetboot' against the following nodes: @failurenodes"; + $rsp->{errorcode}->[0] = 1; + xCAT::MsgUtils->message("E", $rsp, $callback); + } + } + else { + # Call "rsetboot" to set the boot order of the nodehm.mgt=ipmi nodes + if ($hmkey =~ /^ipmi$/) { + %nodes = map { $_, 1 } @nodes; + # Run rsetboot $noderange net + my @rsetbootarg; + push @rsetbootarg, "net"; + if ($UEFIMODE) { + push @rsetbootarg, "-u"; + } + my $res = + xCAT::Utils->runxcmd( + { + command => ["rsetboot"], + node => \@nodes, + arg => \@rsetbootarg + }, + $subreq, -1, 1); + + $rc = $::RUNCMD_RC; + my $rsp = {}; + if ($rc == 0) { + if ($VERBOSE) { + my @cmd = "Run command: rsetboot @nodes @rsetbootarg"; + push @{$rsp->{data}}, @cmd; + push @{$rsp->{data}}, @$res; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + } + else { + # We got an error with the rsetboot + my @successnodes; + my @failurenodes; + foreach my $line (@$res) { + $rsp->{data} ->[0] = $line; + if ($line =~ /: Network/) { + my $successnode; + my $restline; + ($successnode, $restline) = split (/:/, $line, 2); + $nodes{$successnode} = 0; + push @successnodes, $successnode; + } + xCAT::MsgUtils->message("I", $rsp, $callback); + } + foreach my $node (@nodes) { + if ($nodes{$node} = 1) { + push @failurenodes, $node; + } + } + my $rsp = {}; + $rsp->{error}->[0] = "failed to run 'rsetboot' against the following nodes: @failurenodes"; + $rsp->{errorcode}->[0] = 1; + xCAT::MsgUtils->message("E", $rsp, $callback); + @nodes = @successnodes; + } + } + # Call "rpower" to start the node provision process + %nodes = map { $_, 1 } @nodes; + # Run rpower $noderange boot + my @rpowerarg; + push @rpowerarg, "boot"; + my $res = + xCAT::Utils->runxcmd( + { + command => ["rpower"], + node => \@nodes, + arg => \@rpowerarg + }, + $subreq, -1, 1); + + $rc = $::RUNCMD_RC; + my $rsp = {}; + if ($rc == 0) { + if ($VERBOSE) { + my @cmd = "Run command: rpower @nodes @rpowerarg"; + push @{$rsp->{data}}, @cmd; + push @{$rsp->{data}}, @$res; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + } + else { + # We got an error with the rpower + my @failurenodes; + foreach my $line (@$res) { + $rsp->{data} ->[0] = $line; + if (($line =~ /: on reset/) or ($line =~ /: off on/)) { + my $successnode; + my $restline; + ($successnode, $restline) = split (/:/, $line, 2); + $nodes{$successnode} = 0; + } + xCAT::MsgUtils->message("I", $rsp, $callback); + } + foreach my $node (@nodes) { + if ($nodes{$node} = 1) { + push @failurenodes, $node; + } + } + my $rsp = {}; + $rsp->{error}->[0] = "failed to run 'rpower' against the following nodes: @failurenodes"; + $rsp->{errorcode}->[0] = 1; + xCAT::MsgUtils->message("E", $rsp, $callback); + } + } + } + + # Check if they asked to bring up a console (-c) from rinstall always for winstall + $req->{startconsole}->[0] = 0; + if ($command =~ /rinstall/) { + # For rinstall, the -c|--console option can provide the remote console for only 1 node + if ($CONSOLE) { + if (scalar @nodes != 1) { + my $rsp = {}; + $rsp->{error}->[0] = "rinstall -c only accepts one node in the noderange. See winstall for support of consoles on multiple nodes."; + $rsp->{errorcode}->[0] = 1; + xCAT::MsgUtils->message("E", $rsp, $callback); + return 1; + } + else { + # Tell rinstall client ok to start rcons + $req->{startconsole}->[0] = 1; + } + } + } + elsif ($command =~ /winstall/) { + # Command winstall can start a wcons command to multiple nodes for monitoring the provision cycle + $req->{startconsole}->[0] = 1; + } return 0; } @@ -405,47 +559,17 @@ sub rinstall =cut #------------------------------------------------------- - -sub usage -{ +sub usage { my $command = shift; my $callback = shift; my $rsp = {}; - $rsp->{data}->[0] = "$command usage:"; - if ($command =~ /rinstall/) { - $rsp->{data}->[1] = " [-O|--osimage] [-c|--console] "; - } else { # wininstall - $rsp->{data}->[1] = " [-O|--osimage] "; - } - - $rsp->{data}->[2] = " [-h|--help]"; - $rsp->{data}->[3] = " [-v|--version]"; + $rsp->{data}->[0] = "Usage:"; + $rsp->{data}->[1] = " $command boot | shell | runcmd=bmcsetup [-c|--console] [-u|--uefimode] [-V|--verbose]"; + $rsp->{data}->[2] = " $command osimage= | -O [--ignorekernelchk] [-c|--console] [-u|--uefimode] [-V|--verbose]"; + $rsp->{data}->[3] = " $command [-h|--help|-v|--version]"; xCAT::MsgUtils->message("I", $rsp, $callback); } -# check and complain about the invalid combination of the options, -# ignore -o,-p and -a options and prompt a warning message when provmethod=osimagename -sub checkoption{ - my $optstring=shift; - my $OSVER=shift; - my $PROFILE=shift; - my $ARCH=shift; - my $callback=shift; - my $rsp = {}; - if($OSVER) { - $rsp->{data}->[0] = "-o option not valid with $optstring. It is ignored."; - xCAT::MsgUtils->message("I", $rsp, $callback); - } - if($PROFILE) { - $rsp->{data}->[0] = "-p option not valid with $optstring. It is ignored."; - xCAT::MsgUtils->message("I", $rsp, $callback); - } - if($ARCH) { - $rsp->{data}->[0] = "-a option not valid with $optstring. It is ignored."; - xCAT::MsgUtils->message("I", $rsp, $callback); - } -} - 1; From b9baa8b6ddabdc65a633833606afea79b8562e6b Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Mon, 27 Jun 2016 23:03:33 -0400 Subject: [PATCH 188/310] add bundle files --- xCAT-test/autotest/bundle/sles12.1_ppc64.bundle | 3 +++ xCAT-test/autotest/bundle/sles12.1_x86_64.bundle | 7 +++++-- xCAT-test/autotest/bundle/sles12_ppc64.bundle | 3 +++ xCAT-test/autotest/bundle/sles12_x86_64.bundle | 4 ++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/xCAT-test/autotest/bundle/sles12.1_ppc64.bundle b/xCAT-test/autotest/bundle/sles12.1_ppc64.bundle index 04a1ebe34..1437440d1 100644 --- a/xCAT-test/autotest/bundle/sles12.1_ppc64.bundle +++ b/xCAT-test/autotest/bundle/sles12.1_ppc64.bundle @@ -260,3 +260,6 @@ makentp_a nodeset_check_warninginfo reg_linux_diskless_installation_flat reg_linux_statelite_installation_flat +SN_setup_case +reg_linux_diskfull_installation_hierarchy +reg_linux_diskless_installation_hierarchy diff --git a/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle b/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle index 11a149192..5a593f1f3 100644 --- a/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle +++ b/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle @@ -207,7 +207,10 @@ xcatd_restart_systemd run_command_with_XCATBYPASS_systemd disable_root_permission_in_policy_table_systemd assign_certain_command_permission_systemd -reg_linux_diskless_installation_flat -reg_linux_statelite_installation_flat sles_migration1 sles_migration2 +reg_linux_diskless_installation_flat +reg_linux_statelite_installation_flat +SN_setup_case +reg_linux_diskfull_installation_hierarchy +reg_linux_diskless_installation_hierarchy diff --git a/xCAT-test/autotest/bundle/sles12_ppc64.bundle b/xCAT-test/autotest/bundle/sles12_ppc64.bundle index 04a1ebe34..1437440d1 100644 --- a/xCAT-test/autotest/bundle/sles12_ppc64.bundle +++ b/xCAT-test/autotest/bundle/sles12_ppc64.bundle @@ -260,3 +260,6 @@ makentp_a nodeset_check_warninginfo reg_linux_diskless_installation_flat reg_linux_statelite_installation_flat +SN_setup_case +reg_linux_diskfull_installation_hierarchy +reg_linux_diskless_installation_hierarchy diff --git a/xCAT-test/autotest/bundle/sles12_x86_64.bundle b/xCAT-test/autotest/bundle/sles12_x86_64.bundle index 1cac18c63..34b44fe00 100644 --- a/xCAT-test/autotest/bundle/sles12_x86_64.bundle +++ b/xCAT-test/autotest/bundle/sles12_x86_64.bundle @@ -209,3 +209,7 @@ disable_root_permission_in_policy_table_systemd assign_certain_command_permission_systemd reg_linux_diskless_installation_flat reg_linux_statelite_installation_flat +SN_setup_case +reg_linux_diskfull_installation_hierarchy +reg_linux_diskless_installation_hierarchy + From 1a2be7240633c2637c36d9e22bae47d858a8628b Mon Sep 17 00:00:00 2001 From: chenglch Date: Tue, 28 Jun 2016 02:20:26 -0400 Subject: [PATCH 189/310] Wait the completion of monitor and cmdlog process close-issue: #1008 #537 --- xCAT-server/sbin/xcatd | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/xCAT-server/sbin/xcatd b/xCAT-server/sbin/xcatd index ab6abd7c1..4781e0a2d 100644 --- a/xCAT-server/sbin/xcatd +++ b/xCAT-server/sbin/xcatd @@ -915,6 +915,13 @@ sub ssl_reaper { if (($CHILDPID == $pid_UDP) && ($udpctl)) { # got here because UDP child is gone close($udpctl); $udpctl=0; + $pid_UDP = 0; + } + if ($CHILDPID == $cmdlog_svrpid) { + $cmdlog_svrpid = 0; + } + if ($CHILDPID == $pid_MON) { + $pid_MON = 0; } } $SIG{CHLD} = \&ssl_reaper; @@ -1470,12 +1477,16 @@ if (open($mainpidfile,"<","/var/run/xcat/mainservice.pid")) { } if ($listener) { $listener->close; } my $lastpid; -while (keys %immediatechildren || $pid_UDP) { +while (keys %immediatechildren || $pid_UDP || $cmdlog_svrpid || $pid_MON) { $lastpid=wait(); if ($immediatechildren{$lastpid}) { delete $immediatechildren{$lastpid}; } elsif ($lastpid == $pid_UDP) { $pid_UDP = 0; + } elsif ($lastpid == $cmdlog_svrpid) { + $cmdlog_svrpid = 0; + } elsif ($lastpid == $pid_MON) { + $pid_MON = 0; } } xCAT::Table::shut_dbworker; From 48422f11de7f0977e288d9cd8bd76eb4607a1fa2 Mon Sep 17 00:00:00 2001 From: bybai Date: Tue, 28 Jun 2016 04:10:52 -0400 Subject: [PATCH 190/310] update issue 1326 --- xCAT-server/lib/xcat/plugins/kit.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index 357e65b91..9188ca729 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -1636,6 +1636,12 @@ sub rmkit # Remove this component from osimage.kitcomponents. Mark here. my $ret = xCAT::Utils->runxcmd({ command => ['rmkitcomp'], arg => ['-f','-i',$entry->{imagename}, $kitcompname] }, $request_command, 0, 1); + if ( $::RUNCMD_RC ) { + my %rsp; + push@{ $rsp{data} }, "Failed to remove kit component $kitcomponent from $entry->{imagename}"; + xCAT::MsgUtils->message( "E", \%rsp, $callback ); + return 1; + } } } } @@ -2640,7 +2646,7 @@ sub rmkitcomp unless (@entries) { my %rsp; push@{ $rsp{data} }, "kitcomponent $kitcompdep basename does not exist"; - xCAT::MsgUtils->message( "E", \%rsp, $callback ); + xCAT::MsgUtils->message( "W", \%rsp, $callback ); } my $kitcompdepname = get_highest_version('kitcompname', 'version', 'release', @entries); From 1542879a7b823f5a56b892868086325f0d3dbbfb Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Fri, 24 Jun 2016 04:34:48 -0400 Subject: [PATCH 191/310] modify depending on comments --- xCAT-probe/lib/perl/probe_utils.pm | 12 +- xCAT-probe/lib/perl/xCAT/NetworkUtils.pm | 2620 ++++++++++++++++++++++ xCAT-probe/subcmds/discovery | 461 ++-- xCAT-probe/xcatprobe | 177 +- 4 files changed, 2977 insertions(+), 293 deletions(-) create mode 100644 xCAT-probe/lib/perl/xCAT/NetworkUtils.pm diff --git a/xCAT-probe/lib/perl/probe_utils.pm b/xCAT-probe/lib/perl/probe_utils.pm index e0d5b7074..729dcebad 100644 --- a/xCAT-probe/lib/perl/probe_utils.pm +++ b/xCAT-probe/lib/perl/probe_utils.pm @@ -48,12 +48,12 @@ sub send_msg { } if ($output eq "stdout") { - print "$flag $msg\n"; + print "$flag$msg\n"; } else { if (!open(LOGFILE, ">> $output")) { return 1; } - print LOGFILE "$flag $msg\n"; + print LOGFILE "$flag$msg\n"; close LOGFILE; } return 0; @@ -389,12 +389,8 @@ sub get_network{ return $net if (!is_ip_addr($ip)); return $net if ($mask !~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/); - my $bin_mask = 0; - $bin_mask = (($1 + 0) << 24) + (($2 + 0) << 16) + (($3 + 0) << 8) + ($4 + 0) if ($mask =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/); - - my $bin_ip = 0; - $bin_ip = (($1 + 0) << 24) + (($2 + 0) << 16) + (($3 + 0) << 8) + ($4 + 0) if ($ip =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/); - + my $bin_mask = unpack("N", inet_aton($mask)); + my $bin_ip = unpack("N", inet_aton($ip));; my $net_int32 = $bin_mask & $bin_ip; $net = ($net_int32 >> 24) . "." . (($net_int32 >> 16) & 0xff) . "." . (($net_int32 >> 8) & 0xff) . "." . ($net_int32 & 0xff); return "$net/$mask"; diff --git a/xCAT-probe/lib/perl/xCAT/NetworkUtils.pm b/xCAT-probe/lib/perl/xCAT/NetworkUtils.pm new file mode 100644 index 000000000..2f699c8fa --- /dev/null +++ b/xCAT-probe/lib/perl/xCAT/NetworkUtils.pm @@ -0,0 +1,2620 @@ +#!/usr/bin/env perl +# IBM(c) 2010 EPL license http://www.eclipse.org/legal/epl-v10.html +package xCAT::NetworkUtils; + +BEGIN +{ + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; +} + +# if AIX - make sure we include perl 5.8.2 in INC path. +# Needed to find perl dependencies shipped in deps tarball. +if ($^O =~ /^aix/i) { + unshift(@INC, qw(/usr/opt/perl5/lib/5.8.2/aix-thread-multi /usr/opt/perl5/lib/5.8.2 /usr/opt/perl5/lib/site_perl/5.8.2/aix-thread-multi /usr/opt/perl5/lib/site_perl/5.8.2)); +} + +use lib "$::XCATROOT/lib/perl"; +use POSIX qw(ceil); +use File::Path; +use Math::BigInt; +use Socket; +use xCAT::GlobalDef; +#use Data::Dumper; +use strict; +use warnings "all"; +my $socket6support = eval { require Socket6 }; + +our @ISA = qw(Exporter); +our @EXPORT_OK = qw(getipaddr); + +my $utildata; #data to persist locally +#-------------------------------------------------------------------------------- + +=head1 xCAT::NetworkUtils + +=head2 Package Description + +This program module file, is a set of network utilities used by xCAT commands. + +=cut + +#------------------------------------------------------------- + +#------------------------------------------------------------------------------- + +=head3 getNodeDomains + + Gets the network domain for a list of nodes + + The domain value comes from the network definition + associated with the node ip address. + + If the network domain is not set then the default is to + use the site.domain value + + Arguments: + list of nodes + Returns: + error - undef + success - hash ref of domains for each node + Globals: + $::VERBOSE + Error: + Example: + my $nodedomains = xCAT::NetworkUtils->getNodeDomains(\@nodes, $callback); + Comments: + none +=cut + +#------------------------------------------------------------------------------- +sub getNodeDomains() +{ + my $class = shift; + my $nodes = shift; + + my @nodelist = @$nodes; + my %nodedomains; + + # Get the network info for each node + my %nethash = xCAT::DBobjUtils->getNetwkInfo(\@nodelist); + + # get the site domain value + my @domains = xCAT::TableUtils->get_site_attribute("domain"); + my $sitedomain = $domains[0]; + + # for each node - set hash value to network domain or default + # to site domain + foreach my $node (@nodelist) { + unless (defined($node)) {next;} + if (defined($nethash{$node}) && $nethash{$node}{domain}) { + $nodedomains{$node} = $nethash{$node}{domain}; + } else { + $nodedomains{$node} = $sitedomain; + } + } + + return \%nodedomains; +} + +#------------------------------------------------------------------------------- + +=head3 gethostnameandip + Works for both IPv4 and IPv6. + Takes either a host name or an IP address string + and performs a lookup on that name, + returns an array with two elements: the hostname, the ip address + if the host name or ip address can not be resolved, + the corresponding element in the array will be undef + Arguments: + hostname or ip address + Returns: the hostname and the ip address + Globals: + + Error: + none + Example: + my ($host, $ip) = xCAT::NetworkUtils->gethostnameandip($iporhost); + Comments: + none +=cut + +#------------------------------------------------------------------------------- +sub gethostnameandip() +{ + my ($class, $iporhost) = @_; + + if (($iporhost =~ /\d+\.\d+\.\d+\.\d+/) || ($iporhost =~ /:/)) #ip address + { + return (xCAT::NetworkUtils->gethostname($iporhost), $iporhost); + } + else #hostname + { + return ($iporhost, xCAT::NetworkUtils->getipaddr($iporhost)); + } +} + +#------------------------------------------------------------------------------- + +=head3 gethostname + Works for both IPv4 and IPv6. + Takes an IP address string and performs a lookup on that name, + returns the hostname of the ip address + if the ip address can not be resolved, returns undef + Arguments: + ip address + Returns: the hostname + Globals: + cache: %::iphosthash + Error: + none + Example: + my $host = xCAT::NetworkUtils->gethostname($ip); + Comments: + none +=cut + +#------------------------------------------------------------------------------- +sub gethostname() +{ + my ($class, $iporhost) = @_; + + if (!defined($iporhost)) + { + return undef; + } + + if (ref($iporhost) eq 'ARRAY') + { + $iporhost = @{$iporhost}[0]; + if (!$iporhost) + { + return undef; + } + } + + if (($iporhost !~ /\d+\.\d+\.\d+\.\d+/) && ($iporhost !~ /:/)) + { + #why you do so? pass in a hostname and only want a hostname?? + return $iporhost; + } + #cache, do not lookup DNS each time + if (defined($::iphosthash{$iporhost}) && $::iphosthash{$iporhost}) + { + return $::iphosthash{$iporhost}; + } + else + { + if ($socket6support) # the getaddrinfo and getnameinfo supports both IPv4 and IPv6 + { + my ($family, $socket, $protocol, $ip, $name) = Socket6::getaddrinfo($iporhost,0,AF_UNSPEC,SOCK_STREAM,6); #specifically ask for TCP capable records, maximizing chance of no more than one return per v4/v6 + my $host = (Socket6::getnameinfo($ip))[0]; + if ($host eq $iporhost) # can not resolve + { + return undef; + } + if ($host) + { + $host =~ s/\..*//; #short hostname + } + return $host; + } + else + { + #it is possible that no Socket6 available, + #but passing in IPv6 address, such as ::1 on loopback + if ($iporhost =~ /:/) + { + return undef; + } + my $hostname = gethostbyaddr(inet_aton($iporhost), AF_INET); + if ( $hostname ) { + $hostname =~ s/\..*//; #short hostname + } + return $hostname; + } + } +} + +#------------------------------------------------------------------------------- + +=head3 getipaddr + Works for both IPv4 and IPv6. + Takes a hostname string and performs a lookup on that name, + returns the the ip address of the hostname + if the hostname can not be resolved, returns undef + Arguments: + hostname + Optional: + GetNumber=>1 (return the address as a BigInt instead of readable string) + Returns: ip address + Globals: + cache: %::hostiphash + Error: + none + Example: + my $ip = xCAT::NetworkUtils->getipaddr($hostname); + Comments: + none +=cut + +#------------------------------------------------------------------------------- +sub getipaddr +{ + my $iporhost = shift; + if ($iporhost eq 'xCAT::NetworkUtils') { #was called with -> syntax + $iporhost = shift; + } + my %extraarguments = @_; + + if (!defined($iporhost)) + { + return undef; + } + + if (ref($iporhost) eq 'ARRAY') + { + $iporhost = @{$iporhost}[0]; + if (!$iporhost) + { + return undef; + } + } + + #go ahead and do the reverse lookup on ip, useful to 'frontend' aton/pton and also to + #spit out a common abbreviation if leading zeroes or using different ipv6 presentation rules + #if ($iporhost and ($iporhost =~ /\d+\.\d+\.\d+\.\d+/) || ($iporhost =~ /:/)) + #{ + # #pass in an ip and only want an ip?? + # return $iporhost; + #} + + #cache, do not lookup DNS each time + if ($::hostiphash and defined($::hostiphash{$iporhost}) && $::hostiphash{$iporhost}) + { + return $::hostiphash{$iporhost}; + } + else + { + if ($socket6support) # the getaddrinfo and getnameinfo supports both IPv4 and IPv6 + { + my @returns; + my $reqfamily=AF_UNSPEC; + if ($extraarguments{OnlyV6}) { + $reqfamily=AF_INET6; + } elsif ($extraarguments{OnlyV4}) { + $reqfamily=AF_INET; + } + my @addrinfo = Socket6::getaddrinfo($iporhost,0,$reqfamily,SOCK_STREAM,6); + my ($family, $socket, $protocol, $ip, $name) = splice(@addrinfo,0,5); + while ($ip) + { + if ($extraarguments{GetNumber}) { #return a BigInt for compare, e.g. for comparing ip addresses for determining if they are in a common network or range + my $ip = (Socket6::getnameinfo($ip, Socket6::NI_NUMERICHOST()))[0]; + my $bignumber = Math::BigInt->new(0); + foreach (unpack("N*",Socket6::inet_pton($family,$ip))) { #if ipv4, loop will iterate once, for v6, will go 4 times + $bignumber->blsft(32); + $bignumber->badd($_); + } + push(@returns,$bignumber); + } else { + push @returns,(Socket6::getnameinfo($ip, Socket6::NI_NUMERICHOST()))[0]; + } + if (scalar @addrinfo and $extraarguments{GetAllAddresses}) { + ($family, $socket, $protocol, $ip, $name) = splice(@addrinfo,0,5); + } else { + $ip=0; + } + } + unless ($extraarguments{GetAllAddresses}) { + return $returns[0]; + } + return @returns; + } + else + { + #return inet_ntoa(inet_aton($iporhost)) + #TODO, what if no scoket6 support, but passing in a IPv6 hostname? + if ($iporhost =~ /:/) { #ipv6 + return undef; + #die "Attempt to process IPv6 address, but system does not have requisite IPv6 perl support"; + } + my $packed_ip; + $iporhost and $packed_ip = inet_aton($iporhost); + if (!$packed_ip) + { + return undef; + } + if ($extraarguments{GetNumber}) { #only 32 bits, no for loop needed. + return Math::BigInt->new(unpack("N*",$packed_ip)); + } + return inet_ntoa($packed_ip); + } + } +} + +#------------------------------------------------------------------------------- + +=head3 linklocaladdr + Only for IPv6. + Takes a mac address, calculate the IPv6 link local address + Arguments: + mac address + Returns: + ipv6 link local address. returns undef if passed in a invalid mac address + Globals: + Error: + none + Example: + my $linklocaladdr = xCAT::NetworkUtils->linklocaladdr($mac); + Comments: + none +=cut + +#------------------------------------------------------------------------------- +sub linklocaladdr { + my ($class, $mac) = @_; + $mac = lc($mac); + my $localprefix = "fe80"; + + my ($m1, $m2, $m3, $m6, $m7, $m8); + # mac address can be 00215EA376B0 or 00:21:5E:A3:76:B0 + if($mac =~ /^([0-9A-Fa-f]{2}).*?([0-9A-Fa-f]{2}).*?([0-9A-Fa-f]{2}).*?([0-9A-Fa-f]{2}).*?([0-9A-Fa-f]{2}).*?([0-9A-Fa-f]{2})$/) + { + ($m1, $m2, $m3, $m6, $m7, $m8) = ($1, $2, $3, $4, $5, $6); + } + else + { + #not a valid mac address + return undef; + } + my ($m4, $m5) = ("ff","fe"); + + #my $bit = (int $m1) & 2; + #if ($bit) { + # $m1 = $m1 - 2; + #} else { + # $m1 = $m1 + 2; + #} + $m1 = hex($m1); + $m1 = $m1 ^ 2; + $m1 = sprintf("%x", $m1); + + $m1 = $m1 . $m2; + $m3 = $m3 . $m4; + $m5 = $m5 . $m6; + $m7 = $m7 . $m8; + + my $laddr = join ":", $m1, $m3, $m5, $m7; + $laddr = join "::", $localprefix, $laddr; + + return $laddr; +} + + +#------------------------------------------------------------------------------- + +=head3 ishostinsubnet + Works for both IPv4 and IPv6. + Takes an ip address, the netmask and a subnet, + chcek if the ip address is in the subnet + Arguments: + ip address, netmask, subnet + Returns: + 1 - if the ip address is in the subnet + 0 - if the ip address is NOT in the subnet + Globals: + Error: + none + Example: + if(xCAT::NetworkUtils->ishostinsubnet($ip, $netmask, $subnet); + Comments: + none +=cut + +#------------------------------------------------------------------------------- +sub ishostinsubnet { + my ($class, $ip, $mask, $subnet) = @_; + + #safe guard + if (!defined($ip) || !defined($mask) || !defined($subnet)) + { + return 0; + } + my $numbits=32; + if ($ip =~ /:/) {#ipv6 + $numbits=128; + } + if ($mask) { + if ($mask =~ /\//) { + $mask =~ s/^\///; + $mask=Math::BigInt->new("0b".("1"x$mask).("0"x($numbits-$mask))); + } else { + $mask=getipaddr($mask,GetNumber=>1); + } + } else { #CIDR notation supported + if ($subnet && ($subnet =~ /\//)) { + ($subnet,$mask) = split /\//,$subnet,2; + $mask=Math::BigInt->new("0b".("1"x$mask).("0"x($numbits-$mask))); + } else { + die "ishostinsubnet must either be called with a netmask or CIDR /bits notation"; + } + } + if ($subnet && ($subnet =~ /\//)) #remove CIDR suffix from subnet + { + $subnet =~ s/\/.*$//; + } + $ip = getipaddr($ip,GetNumber=>1); + $subnet = getipaddr($subnet,GetNumber=>1); + $ip &= $mask; + if ($ip && $subnet && ($ip == $subnet)) { + return 1; + } else { + return 0; + } +} + +#----------------------------------------------------------------------------- + +=head3 setup_ip_forwarding + + Sets up ip forwarding on localhost + +=cut + +#----------------------------------------------------------------------------- +sub setup_ip_forwarding +{ + my ($class, $enable)=@_; + if (xCAT::Utils->isLinux()) { + my $conf_file="/etc/sysctl.conf"; + `grep "net.ipv4.ip_forward" $conf_file`; + if ($? == 0) { + `sed -i "s/^net.ipv4.ip_forward = .*/net.ipv4.ip_forward = $enable/" $conf_file`; + `sed -i "s/^#net.ipv4.ip_forward *= *.*/net.ipv4.ip_forward = $enable/" $conf_file`; #debian/ubuntu have different default format + } else { + `echo "net.ipv4.ip_forward = $enable" >> $conf_file`; + } + `sysctl -e -p $conf_file`; # workaround for redhat bug 639821 + } + else + { + `no -o ipforwarding=$enable`; + } + return 0; +} + +#----------------------------------------------------------------------------- + +=head3 setup_ipv6_forwarding + + Sets up ipv6 forwarding on localhost + +=cut + +#----------------------------------------------------------------------------- +sub setup_ipv6_forwarding +{ + my ($class, $enable)=@_; + if (xCAT::Utils->isLinux()) { + my $conf_file="/etc/sysctl.conf"; + `grep "net.ipv6.conf.all.forwarding" $conf_file`; + if ($? == 0) { + `sed -i "s/^net.ipv6.conf.all.forwarding = .*/net.ipv6.conf.all.forwarding = $enable/" $conf_file`; + } else { + `echo "net.ipv6.conf.all.forwarding = $enable" >> $conf_file`; + } + `sysctl -e -p $conf_file`; + } + else + { + `no -o ip6forwarding=$enable`; + } + return 0; +} + +#------------------------------------------------------------------------------- + +=head3 prefixtomask + Convert the IPv6 prefix length(e.g. 64) to the netmask(e.g. ffff:ffff:ffff:ffff:0000:0000:0000:0000). + Till now, the netmask format ffff:ffff:ffff:: only works for AIX NIM + + Arguments: + prefix length + Returns: + netmask - netmask like ffff:ffff:ffff:ffff:0000:0000:0000:0000 + 0 - if the prefix length is not correct + Globals: + Error: + none + Example: + my #netmask = xCAT::NetworkUtils->prefixtomask($prefixlength); + Comments: + none +=cut + +#------------------------------------------------------------------------------- +sub prefixtomask { + my ($class, $prefixlength) = @_; + + if (($prefixlength < 1) || ($prefixlength > 128)) + { + return 0; + } + + my $number=Math::BigInt->new("0b".("1"x$prefixlength).("0"x(128-$prefixlength))); + my $mask = $number->as_hex(); + $mask =~ s/^0x//; + $mask =~ s/(....)/$1/g; + return $mask; +} + +#------------------------------------------------------------------------------- + +=head3 my_ip_in_subnet + Get the facing ip for some specific network + + Arguments: + net - subnet, such as 192.168.0.01 + mask - netmask, such as 255.255.255.0 + Returns: + facing_ip - The local ip address in the subnet, + returns undef if no local ip address is in the subnet + Globals: + Error: + none + Example: + my $facingip = xCAT::NetworkUtils->my_ip_in_subnet($net, $mask); + Comments: + none +=cut + +#------------------------------------------------------------------------------- +sub my_ip_in_subnet +{ + my ($class, $net, $mask) = @_; + + if (!$net || !$mask) + { + return undef; + } + + my $fmask = xCAT::NetworkUtils::formatNetmask($mask, 0, 1); + + my $localnets = xCAT::NetworkUtils->my_nets(); + + return $localnets->{"$net\/$fmask"}; +} + +#------------------------------------------------------------------------------- + +=head3 ip_forwarding_enabled + Check if the ip_forward enabled on the system + + Arguments: + Returns: + 1 - The ip_forwarding is eanbled + 0 - The ip_forwarding is not eanbled + Globals: + Error: + none + Example: + if(xCAT::NetworkUtils->ip_forwarding_enabled()) + Comments: + none +=cut + +#------------------------------------------------------------------------------- +sub ip_forwarding_enabled +{ + + my $enabled; + if (xCAT::Utils->isLinux()) + { + $enabled = `sysctl -n net.ipv4.ip_forward`; + chomp($enabled); + } + else + { + $enabled = `no -o ipforwarding`; + chomp($enabled); + $enabled =~ s/ipforwarding\s+=\s+//; + } + return $enabled; +} +#------------------------------------------------------------------------------- + +=head3 get_nic_ip + Get the ip address for the node nics + + Arguments: + Returns: + Hash of the mapping of the nic and the ip addresses + Globals: + Error: + none + Example: + xCAT::NetworkUtils->get_nic_ip() + Comments: + none +=cut + +#------------------------------------------------------------------------------- + +sub get_nic_ip +{ + my $nic; + my %iphash; + my $mode = "MULTICAST"; + my $payingattention=0; + my $interface; + my $keepcurrentiface; + + + if (xCAT::Utils->isAIX()) { + ############################################################## + # Should look like this for AIX: + # en0: flags=4e080863,80 + # inet 30.0.0.1 netmask 0xffffff00 broadcast 30.0.0.255 + # inet 192.168.2.1 netmask 0xffffff00 broadcast 192.168.2.255 + # en1: ... + # + ############################################################## + my $cmd = "ifconfig -a"; + my $result = `$cmd`; + ############################################# + # Error running command + ############################################# + if ( !$result ) { + return undef; + } + my @adapter = split /(\w+\d+):\s+flags=/, $result; + foreach ( @adapter ) { + if ($_ =~ /^(en\d)/) { + $nic = $1; + next; + } + if ( !($_ =~ /LOOPBACK/ ) and + $_ =~ /UP(,|>)/ and + $_ =~ /$mode/ ) { + my @ip = split /\n/; + for my $ent ( @ip ) { + if ( $ent =~ /^\s*inet\s+(\d+\.\d+\.\d+\.\d+)/ ) { + $iphash{$nic} = $1; + next; + } + } + } + } + } + else { # linux + my @ipoutput = `ip addr`; + ############################################# + # Error running command + ############################################# + if ( !@ipoutput ) { + return undef; + } + foreach my $line (@ipoutput) { + if ($line =~ /^\d/) { # new interface, new context.. + if ($interface and not $keepcurrentiface) { + #don't bother reporting unusable nics + delete $iphash{$interface}; + } + $keepcurrentiface=0; + if ( !($line =~ /LOOPBACK/ ) and + $line =~ /UP( |,|>)/ and + $line =~ /$mode/ ) { + + $payingattention=1; + $line =~ /^([^:]*): ([^:]*):/; + $interface=$2; + } else { + $payingattention=0; + next; + } + } + unless ($payingattention) { next; } + if ($line =~ /inet/) { + $keepcurrentiface=1; + } + if ( $line =~ /^\s*inet \s*(\d+\.\d+\.\d+\.\d+)/ ) { + $iphash{$interface} = $1; + } + } + } + return \%iphash; +} + +#------------------------------------------------------------------------------- + +=head3 classful_networks_for_net_and_mask + + Arguments: + network and mask + Returns: + a list of classful subnets that constitute the entire potentially classless arguments + Globals: + none + Error: + none + Example: + Comments: + none +=cut + +#------------------------------------------------------------------------------- +sub classful_networks_for_net_and_mask +{ + my $network = shift; + my $mask = shift; + my $given_mask = 0; + if ($mask =~ /\./) + { + $given_mask = 1; + my $masknumber = unpack("N", inet_aton($mask)); + $mask = 32; + until ($masknumber % 2) + { + $masknumber = $masknumber >> 1; + $mask--; + } + } + + my @results; + my $bitstoeven = (8 - ($mask % 8)); + if ($bitstoeven eq 8) { $bitstoeven = 0; } + my $resultmask = $mask + $bitstoeven; + if ($given_mask) + { + $resultmask = + inet_ntoa(pack("N", (2**$resultmask - 1) << (32 - $resultmask))); + } + push @results, $resultmask; + + my $padbits = (32 - ($bitstoeven + $mask)); + my $numchars = int(($mask + $bitstoeven) / 4); + my $curmask = 2**$mask - 1 << (32 - $mask); + my $nown = unpack("N", inet_aton($network)); + $nown = $nown & $curmask; + my $highn = $nown + ((2**$bitstoeven - 1) << (32 - $mask - $bitstoeven)); + + while ($nown <= $highn) + { + push @results, inet_ntoa(pack("N", $nown)); + + #$rethash->{substr($nowhex, 0, $numchars)} = $network; + $nown += 1 << (32 - $mask - $bitstoeven); + } + return @results; +} + + +#------------------------------------------------------------------------------- + +=head3 my_hexnets + + Arguments: + none + Returns: + Globals: + none + Error: + none + Example: + xCAT::NetworkUtils->my_hexnets + Comments: + none +=cut + +#------------------------------------------------------------------------------- +sub my_hexnets +{ + my $rethash; + my @nets = split /\n/, `/sbin/ip addr`; + foreach (@nets) + { + my @elems = split /\s+/; + unless (/^\s*inet\s/) + { + next; + } + (my $curnet, my $maskbits) = split /\//, $elems[2]; + my $bitstoeven = (4 - ($maskbits % 4)); + if ($bitstoeven eq 4) { $bitstoeven = 0; } + my $padbits = (32 - ($bitstoeven + $maskbits)); + my $numchars = int(($maskbits + $bitstoeven) / 4); + my $curmask = 2**$maskbits - 1 << (32 - $maskbits); + my $nown = unpack("N", inet_aton($curnet)); + $nown = $nown & $curmask; + my $highn = + $nown + ((2**$bitstoeven - 1) << (32 - $maskbits - $bitstoeven)); + + while ($nown <= $highn) + { + my $nowhex = sprintf("%08x", $nown); + $rethash->{substr($nowhex, 0, $numchars)} = $curnet; + $nown += 1 << (32 - $maskbits - $bitstoeven); + } + } + return $rethash; +} + +#------------------------------------------------------------------------------- + +=head3 get_host_from_ip + Description: + Get the hostname of an IP addresses. First from hosts table, and then try system resultion. + If there is a shortname, it will be returned. Otherwise it will return long name. If the IP cannot be resolved, return undef; + + Arguments: + $ip: the IP to get; + + Returns: + Return: the hostname. +For an example + + Globals: + none + + Error: + none + + Example: + xCAT::NetworkUtils::get_host_from_ip('192.168.200.1') + + Comments: +=cut + +#----------------------------------------------------------------------- +sub get_host_from_ip +{ + my $ip = shift; +} + +#------------------------------------------------------------------------------- + +=head3 isPingable + Description: + Check if an IP address can be pinged + + Arguments: + $ip: the IP to ping; + + Returns: + Return: 1 indicates yes; 0 indicates no. +For an example + + Globals: + none + + Error: + none + + Example: + xCAT::NetworkUtils::isPingable('192.168.200.1') + + Comments: + none +=cut + +#----------------------------------------------------------------------- +my %PING_CACHE; +sub isPingable +{ + my $ip = shift; + + my $rc; + if ( exists $PING_CACHE{ $ip}) + { + $rc = $PING_CACHE{ $ip}; + } + else + { + my $res = `LANG=C ping -c 1 -w 5 $ip 2>&1`; + if ( $res =~ /100% packet loss/g) + { + $rc = 1; + } + else + { + $rc = 0; + } + $PING_CACHE{ $ip} = $rc; + } + + return ! $rc; +} + +#------------------------------------------------------------------------------- + +=head3 my_nets + Description: + Return a hash ref that contains all subnet and netmask on the mn (or sn). This subroutine can be invoked on both Linux and AIX. + + Arguments: + none. + + Returns: + Return a hash ref. Each entry will be: =>; + For an example: + '192.168.200.0/255.255.255.0' => '192.168.200.246'; +For an example + + Globals: + none + + Error: + none + + Example: + xCAT::NetworkUtils::my_nets(). + + Comments: + none +=cut +#----------------------------------------------------------------------- +sub my_nets +{ + require xCAT::Table; + my $rethash; + my @nets; + my $v6net; + my $v6ip; + if ( $^O eq 'aix') + { + @nets = split /\n/, `/usr/sbin/ifconfig -a`; + } + else + { + @nets = split /\n/, `/sbin/ip addr`; #could use ip route, but to match hexnets... + } + foreach (@nets) + { + $v6net = ''; + my @elems = split /\s+/; + unless (/^\s*inet/) + { + next; + } + my $curnet; my $maskbits; + if ( $^O eq 'aix') + { + if ($elems[1] eq 'inet6') + { + $v6net=$elems[2]; + $v6ip=$elems[2]; + $v6ip =~ s/\/.*//; # ipv6 address 4000::99/64 + $v6ip =~ s/\%.*//; # ipv6 address ::1%1/128 + } + else + { + $curnet = $elems[2]; + $maskbits = formatNetmask( $elems[4], 2, 1); + } + } + else + { + if ($elems[1] eq 'inet6') + { + next; #Linux IPv6 TODO, do not return IPv6 networks on Linux for now + } + ($curnet, $maskbits) = split /\//, $elems[2]; + } + if (!$v6net) + { + my $curmask = 2**$maskbits - 1 << (32 - $maskbits); + my $nown = unpack("N", inet_aton($curnet)); + $nown = $nown & $curmask; + my $textnet=inet_ntoa(pack("N",$nown)); + $textnet.="/$maskbits"; + $rethash->{$textnet} = $curnet; + } + else + { + $rethash->{$v6net} = $v6ip; + } + } + + + # now get remote nets + my $nettab = xCAT::Table->new("networks"); + #my $sitetab = xCAT::Table->new("site"); + #my $master = $sitetab->getAttribs({key=>'master'},'value'); + #$master = $master->{value}; + my @masters = xCAT::TableUtils->get_site_attribute("master"); + my $master = $masters[0]; + my @vnets = $nettab->getAllAttribs('net','mgtifname','mask'); + + foreach(@vnets){ + my $n = $_->{net}; + my $if = $_->{mgtifname}; + my $nm = $_->{mask}; + if (!$n || !$if || !$nm) + { + next; #incomplete network + } + if ($if =~ /!remote!/) { #only take in networks with special interface + $nm = formatNetmask($nm, 0 , 1); + $n .="/$nm"; + #$rethash->{$n} = $if; + $rethash->{$n} = $master; + } + } + return $rethash; +} +#------------------------------------------------------------------------------- + +=head3 my_if_netmap + Arguments: + none + Returns: + hash of networks to interface names + Globals: + none + Error: + none + Comments: + none +=cut + +#------------------------------------------------------------------------------- +sub my_if_netmap +{ + my $net; + if (scalar(@_)) + { #called with the other syntax + $net = shift; + } + my @rtable = split /\n/, `netstat -rn`; + if ($?) + { + return "Unable to run netstat, $?"; + } + my %retmap; + foreach (@rtable) + { + if (/^\D/) { next; } #skip headers + if (/^\S+\s+\S+\s+\S+\s+\S*G/) + { + next; + } #Skip networks that require gateways to get to + /^(\S+)\s.*\s(\S+)$/; + $retmap{$1} = $2; + } + return \%retmap; +} + +#------------------------------------------------------------------------------- + +=head3 my_ip_facing + Returns my ip address in the same network with the specified node + Linux only + Arguments: + nodename + Returns: + result and error message or my ip address + 1. If node can not be resolved, the return info will be like this: + [1, "The $node can not be resolved"]. + 2. If no IP found that matching the giving node, the return info will be: + [2, "The IP address of node $node is in an undefined subnet"]. + 3. If IP found: + [0,ip1,ip2,...] + Globals: + none + Error: + none + Example: + my @ip = xCAT::NetworkUtils->my_ip_facing($peerip) # return multiple + Comments: + none +=cut + +#------------------------------------------------------------------------------- +sub my_ip_facing +{ + my $peer = shift; + if (@_) + { + $peer = shift; + } + + return my_ip_facing_aix( $peer) if ( $^O eq 'aix'); + my @rst; + my $peernumber = inet_aton($peer); #TODO: IPv6 support + unless ($peernumber) { + $rst[0] = 1; + $rst[1] = "The $peer can not be resolved"; + return @rst; } + my $noden = unpack("N", $peernumber); + my @nets = split /\n/, `/sbin/ip addr`; + + my @ips; + foreach (@nets) + { + my @elems = split /\s+/; + unless (/^\s*inet\s/) + { + next; + } + (my $curnet, my $maskbits) = split /\//, $elems[2]; + my $curmask = 2**$maskbits - 1 << (32 - $maskbits); + my $curn = unpack("N", inet_aton($curnet)); + if (($noden & $curmask) == ($curn & $curmask)) + { + push @ips, $curnet; + } + } + + if (@ips) { + $rst[0] = 0; + push @rst, @ips; + } else { + $rst[0] = 2; + $rst[1] = "The IP address of node $peer is in an undefined subnet"; + } + return @rst; +} + +#------------------------------------------------------------------------------- + +=head3 my_ip_facing_aix + Returns my ip address + AIX only + Arguments: + nodename + Returns: + Globals: + none + Error: + none + Example: + Comments: + none +=cut + +#------------------------------------------------------------------------------- +sub my_ip_facing_aix +{ + my $peer = shift; + my @nets = `ifconfig -a`; + chomp @nets; + my @ips; + my @rst; + foreach my $net (@nets) + { + my ($curnet,$netmask); + if ( $net =~ /^\s*inet\s+([\d\.]+)\s+netmask\s+(\w+)\s+broadcast/) + { + ($curnet,$netmask) = ($1,$2); + } + elsif ($net =~ /^\s*inet6\s+(.*)$/) + { + ($curnet,$netmask) = split('/', $1); + } + else + { + next; + } + if (isInSameSubnet($peer, $curnet, $netmask, 2)) + { + push @ips, $curnet; + } + } + if (@ips) + { + $rst[0] = 0; + push @rst, @ips; + } + else + { + $rst[0] = 2; + $rst[1] = "The IP address of node $peer is in an undefined subnet"; + } + return @rst; +} + +#------------------------------------------------------------------------------- + +=head3 formatNetmask + Description: + Transform netmask to one of 3 formats (255.255.255.0, 24, 0xffffff00). + + Arguments: + $netmask: the original netmask + $origType: the original netmask type. The valid value can be 0, 1, 2: + Type 0: 255.255.255.0 + Type 1: 24 + Type 2: 0xffffff00 + $newType: the new netmask type, valid values can be 0,1,2, as above. + + Returns: + Return undef if any error. Otherwise return the netmask in new format. + + Globals: + none + + Error: + none + + Example: + xCAT::NetworkUtils::formatNetmask( '24', 1, 0); #return '255.255.255.0'. + + Comments: + none +=cut +#----------------------------------------------------------------------- +sub formatNetmask +{ + my $mask = shift; + my $origType = shift; + my $newType = shift; + my $maskn; + if ( $origType == 0) + { + $maskn = unpack("N", inet_aton($mask)); + } + elsif ( $origType == 1) + { + $maskn = 2**$mask - 1 << (32 - $mask); + } + elsif( $origType == 2) + { + $maskn = hex $mask; + } + else + { + return undef; + } + + if ( $newType == 0) + { + return inet_ntoa( pack('N', $maskn)); + } + if ( $newType == 1) + { + my $bin = unpack ("B32", pack("N", $maskn)); + my @dup = ( $bin =~ /(1{1})0*/g); + return scalar ( @dup); + } + if ( $newType == 2) + { + return sprintf "0x%1x", $maskn; + } + return undef; +} + +#------------------------------------------------------------------------------- + +=head3 isInSameSubnet + Description: + Check if 2 given IP addresses are in same subnet + + Arguments: + $ip1: the first IP + $ip2: the second IP + $mask: the netmask, here are 3 possible netmask types, following are examples for these 3 types: + Type 0: 255.255.255.0 + Type 1: 24 + Type 2: 0xffffff00 + $masktype: the netmask type, 3 possible values: 0,1,2, as indicated above + + Returns: + 1: they are in same subnet + 2: not in same subnet + + Globals: + none + + Error: + none + + Example: + xCAT::NetworkUtils::isInSameSubnet( '192.168.10.1', '192.168.10.2', '255.255.255.0', 0); + + Comments: + none +=cut +#----------------------------------------------------------------------- +sub isInSameSubnet +{ + my $ip1 = shift; + my $ip2 = shift; + my $mask = shift; + my $maskType = shift; + + $ip1 = xCAT::NetworkUtils->getipaddr($ip1); + $ip2 = xCAT::NetworkUtils->getipaddr($ip2); + + if (!defined($ip1) || !defined($ip2)) + { + return undef; + } + + if ((($ip1 =~ /\d+\.\d+\.\d+\.\d+/) && ($ip2 !~ /\d+\.\d+\.\d+\.\d+/)) + ||(($ip1 !~ /\d+\.\d+\.\d+\.\d+/) && ($ip2 =~ /\d+\.\d+\.\d+\.\d+/))) + { + #ipv4 and ipv6 can not be in the same subnet + return undef; + } + + if (($ip1 =~ /\d+\.\d+\.\d+\.\d+/) && ($ip2 =~ /\d+\.\d+\.\d+\.\d+/)) + { + my $maskn; + if ( $maskType == 0) + { + $maskn = unpack("N", inet_aton($mask)); + } + elsif ( $maskType == 1) + { + $maskn = 2**$mask - 1 << (32 - $mask); + } + elsif( $maskType == 2) + { + $maskn = hex $mask; + } + else + { + return undef; + } + + my $ip1n = unpack("N", inet_aton($ip1)); + my $ip2n = unpack("N", inet_aton($ip2)); + + return ( ( $ip1n & $maskn) == ( $ip2n & $maskn) ); + } + else + { + #ipv6 + if (($ip1 =~ /\%/) || ($ip2 =~ /\%/)) + { + return undef; + } + my $netipmodule = eval {require Net::IP;}; + if ($netipmodule) { + my $eip1 = Net::IP::ip_expand_address ($ip1,6); + my $eip2 = Net::IP::ip_expand_address ($ip2,6); + my $bmask = Net::IP::ip_get_mask($mask,6); + my $bip1 = Net::IP::ip_iptobin($eip1,6); + my $bip2 = Net::IP::ip_iptobin($eip2,6); + if (($bip1 & $bmask) == ($bip2 & $bmask)) { + return 1; + } + } # else, can not check without Net::IP module + return undef; + } +} +#------------------------------------------------------------------------------- + +=head3 nodeonmynet - checks to see if node is on any network this server is attached to or remote network potentially managed by this system + Arguments: + Node name + Returns: 1 if node is on the network + Globals: + none + Error: + none + Example: + xCAT::NetworkUtils->nodeonmynet + Comments: + none +=cut + +#------------------------------------------------------------------------------- + +sub nodeonmynet +{ + require xCAT::Table; + my $nodetocheck = shift; + if (scalar(@_)) + { + $nodetocheck = shift; + } + + my $nodeip = getNodeIPaddress( $nodetocheck ); + if (!$nodeip) + { + return 0; + } + unless ($nodeip =~ /\d+\.\d+\.\d+\.\d+/) + { + #IPv6 + if ( $^O eq 'aix') + { + my @subnets = get_subnet_aix(); + for my $net_ent (@subnets) + { + if ($net_ent !~ /-/) + { + #ipv4 + next; + } + my ($net, $interface, $mask, $flag) = split/-/ , $net_ent; + if (xCAT::NetworkUtils->ishostinsubnet($nodeip, $mask, $net)) + { + return 1; + } + } + + } else { + my @v6routes = split /\n/,`ip -6 route`; + foreach (@v6routes) { + if (/via/ or /^unreachable/ or /^fe80::\/64/) { + #only count local ones, remote ones can be caught in next loop + #also, link-local would be a pitfall, + #since more context than address is + #needed to determine locality + next; + } + s/ .*//; #remove all after the space + if (xCAT::NetworkUtils->ishostinsubnet($nodeip,'',$_)) { #bank on CIDR support + return 1; + } + } + } + my $nettab=xCAT::Table->new("networks"); + my @vnets = $nettab->getAllAttribs('net','mgtifname','mask'); + foreach (@vnets) { + if ((defined $_->{mgtifname}) && ($_->{mgtifname} eq '!remote!')) + { + if (xCAT::NetworkUtils->ishostinsubnet($nodeip, $_->{mask}, $_->{net})) + { + return 1; + } + } + } + return 0; + } + my $noden = unpack("N", inet_aton($nodeip)); + my @nets; + if ($utildata->{nodeonmynetdata} and $utildata->{nodeonmynetdata}->{pid} == $$) { + @nets = @{$utildata->{nodeonmynetdata}->{nets}}; + } else { + if ( $^O eq 'aix') + { + my @subnets = get_subnet_aix(); + for my $net_ent (@subnets) + { + if ($net_ent =~ /-/) + { + #ipv6 + next; + } + my @ents = split /:/ , $net_ent; + push @nets, $ents[0] . '/' . $ents[2] . ' dev ' . $ents[1]; + } + + } + else + { + @nets = split /\n/, `/sbin/ip route`; + } + my $nettab=xCAT::Table->new("networks"); + my @vnets = $nettab->getAllAttribs('net','mgtifname','mask'); + foreach (@vnets) { + if ((defined $_->{mgtifname}) && ($_->{mgtifname} eq '!remote!')) + { #global scoped network + my $curm = unpack("N", inet_aton($_->{mask})); + my $bits=32; + until ($curm & 1) { + $bits--; + $curm=$curm>>1; + } + push @nets,$_->{'net'}."/".$bits." dev remote"; + } + } + $utildata->{nodeonmynetdata}->{pid}=$$; + $utildata->{nodeonmynetdata}->{nets} = \@nets; + } + foreach (@nets) + { + my @elems = split /\s+/; + unless ($elems[1] =~ /dev/) + { + next; + } + (my $curnet, my $maskbits) = split /\//, $elems[0]; + my $curmask = 2**$maskbits - 1 << (32 - $maskbits); + my $curn = unpack("N", inet_aton($curnet)); + if (($noden & $curmask) == $curn) + { + return 1; + } + } + return 0; +} + +#------------------------------------------------------------------------------- + +=head3 getNodeIPaddress + Arguments: + Node name only one at a time + Returns: ip address(s) + Globals: + none + Error: + none + Example: my $c1 = xCAT::NetworkUtils::getNodeIPaddress($nodetocheck); + +=cut + +#------------------------------------------------------------------------------- + +sub getNodeIPaddress +{ + require xCAT::Table; + my $nodetocheck = shift; + my $port = shift; + my $nodeip; + + $nodeip = xCAT::NetworkUtils->getipaddr($nodetocheck); + if (!$nodeip) + { + my $hoststab = xCAT::Table->new( 'hosts'); + my $ent = $hoststab->getNodeAttribs( $nodetocheck, ['ip'] ); + if ( $ent->{'ip'} ) { + $nodeip = $ent->{'ip'}; + } + } + + if ( $nodeip ) { + return $nodeip; + } else { + return undef; + } +} + + + +#------------------------------------------------------------------------------- + +=head3 thishostisnot + returns 0 if host is not the same + Arguments: + hostname + Returns: + Globals: + none + Error: + none + Example: + xCAT::NetworkUtils->thishostisnot + Comments: + none +=cut + +#------------------------------------------------------------------------------- + +sub thishostisnot +{ + my $comparison = shift; + if (scalar(@_)) + { + $comparison = shift; + } + + my @ips; + if ( $^O eq 'aix') + { + @ips = split /\n/, `/usr/sbin/ifconfig -a`; + } + else + { + @ips = split /\n/, `/sbin/ip addr`; + } + my $comp = xCAT::NetworkUtils->getipaddr($comparison); + if ($comp) + { + foreach (@ips) + { + if (/^\s*inet.?\s+/) + { + my @ents = split(/\s+/); + my $ip = $ents[2]; + $ip =~ s/\/.*//; + $ip =~ s/\%.*//; + if ($ip eq $comp) + { + return 0; + } + } + } + } + return 1; +} + +#----------------------------------------------------------------------------- + +=head3 gethost_ips (AIX and Linux) + Will use ifconfig to determine all possible ip addresses for the + host it is running on and then gethostbyaddr to get all possible hostnames + + input: + output: array of ipaddress(s) and hostnames + example: @ips=xCAT::NetworkUtils->gethost_ips(); + +=cut + +#----------------------------------------------------------------------------- +#sub gethost_ips1 +#{ +# my ($class) = @_; +# my $cmd; +# my @ipaddress; +# $cmd = "ifconfig" . " -a"; +# $cmd = $cmd . "| grep \"inet\""; +# my @result = xCAT::Utils->runcmd($cmd, 0); +# if ($::RUNCMD_RC != 0) +# { +# xCAT::MsgUtils->message("S", "Error from $cmd\n"); +# exit $::RUNCMD_RC; +# } +# foreach my $addr (@result) +# { +# my @ip; +# if (xCAT::Utils->isLinux()) +# { +# if ($addr =~ /inet6/) +# { +# #TODO, Linux ipv6 +# } +# else +# { +# my ($inet, $addr1, $Bcast, $Mask) = split(" ", $addr); +# #@ip = split(":", $addr1); +# #push @ipaddress, $ip[1]; +# $addr1 =~ s/.*://; +# push @ipaddress, $addr1; +# } +# } +# else +# { #AIX +# if ($addr =~ /inet6/) +# { +# $addr =~ /\s*inet6\s+([\da-fA-F:]+).*\/(\d+)/; +# my $v6ip = $1; +# my $v6mask = $2; +# if ($v6ip) +# { +# push @ipaddress, $v6ip; +# } +# } +# else +# { +# my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) = +# split(" ", $addr); +# push @ipaddress, $addr1; +# } +# +# } +# } +# my @names = @ipaddress; +# foreach my $ipaddr (@names) +# { +# my $hostname = xCAT::NetworkUtils->gethostname($ipaddr); +# if ($hostname) +# { +# my @shorthost = split(/\./, $hostname); +# push @ipaddress, $shorthost[0]; +# } +# } +# +# return @ipaddress; +#} + + +sub gethost_ips +{ + my ($class) = @_; + my $cmd; + my @ipaddress; + if (xCAT::Utils->isLinux()) + { + $cmd="ip -4 --oneline addr show |awk -F ' ' '{print \$4}'|awk -F '/' '{print \$1}'"; + my @result =xCAT::Utils->runcmd($cmd); + if ($::RUNCMD_RC != 0) + { + xCAT::MsgUtils->message("S", "Error from $cmd\n"); + exit $::RUNCMD_RC; + } + + push @ipaddress, @result; + } + else + { #AIX + + $cmd = "ifconfig" . " -a"; + $cmd = $cmd . "| grep \"inet\""; + my @result = xCAT::Utils->runcmd($cmd, 0); + if ($::RUNCMD_RC != 0) + { + xCAT::MsgUtils->message("S", "Error from $cmd\n"); + exit $::RUNCMD_RC; + } + + foreach my $addr (@result) + { + if ($addr =~ /inet6/) + { + $addr =~ /\s*inet6\s+([\da-fA-F:]+).*\/(\d+)/; + my $v6ip = $1; + my $v6mask = $2; + if ($v6ip) + { + push @ipaddress, $v6ip; + } + } + else + { + my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) = + split(" ", $addr); + push @ipaddress, $addr1; + } + + } + } + + my @names = @ipaddress; + foreach my $ipaddr (@names) + { + my $hostname = xCAT::NetworkUtils->gethostname($ipaddr); + if ($hostname) + { + my @shorthost = split(/\./, $hostname); + push @ipaddress, $shorthost[0]; + } + } + return @ipaddress; +} + +#------------------------------------------------------------------------------- + +=head3 get_subnet_aix + Description: + To get present subnet configuration by parsing the output of 'netstat'. Only designed for AIX. + Arguments: + None + Returns: + @aix_nrn : An array with entries in format "net:nic:netmask:flag". Following is an example entry: + 9.114.47.224:en0:27:U + Globals: + none + Error: + none + Example: + my @nrn =xCAT::NetworkUtils::get_subnet_aix + Comments: + none + +=cut + +#------------------------------------------------------------------------------- +sub get_subnet_aix +{ + my @netstat_res = `/usr/bin/netstat -rn`; + chomp @netstat_res; + my @aix_nrn; + for my $entry ( @netstat_res) + { +#We need to find entries like: +#Destination Gateway Flags Refs Use If Exp Groups +#9.114.47.192/27 9.114.47.205 U 1 1 en0 +#4000::/64 link#4 UCX 1 0 en2 - - + my ( $net, $netmask, $flag, $nic); + if ( $entry =~ /^\s*([\d\.]+)\/(\d+)\s+[\d\.]+\s+(\w+)\s+\d+\s+\d+\s(\w+)/) + { + ( $net, $netmask, $flag, $nic) = ($1,$2,$3,$4); + my @dotsec = split /\./, $net; + for ( my $i = 4; $i > scalar(@dotsec); $i--) + { + $net .= '.0'; + } + push @aix_nrn, "$net:$nic:$netmask:$flag" if ($net ne '127.0.0.0'); + } + elsif ($entry =~ /^\s*([\dA-Fa-f\:]+)\/(\d+)\s+.*?\s+(\w+)\s+\d+\s+\d+\s(\w+)/) + { + #print "=====$entry====\n"; + ( $net, $netmask, $flag, $nic) = ($1,$2,$3,$4); + # for ipv6, can not use : as the delimiter + push @aix_nrn, "$net-$nic-$netmask-$flag" if ($net ne '::') + } + } + return @aix_nrn; +} + +#----------------------------------------------------------------------------- + +=head3 determinehostname and ip address(s) + + Used on the service node to figure out what hostname and ip address(s) + are valid names and addresses + Input: None + Output: ipaddress(s),nodename +=cut + +#----------------------------------------------------------------------------- +sub determinehostname +{ + my $hostname; + my $hostnamecmd = "/bin/hostname"; + my @thostname = xCAT::Utils->runcmd($hostnamecmd, 0); + if ($::RUNCMD_RC != 0) + { # could not get hostname + xCAT::MsgUtils->message("S", + "Error $::RUNCMD_RC from $hostnamecmd command\n"); + exit $::RUNCMD_RC; + } + $hostname = $thostname[0]; + + #get all potentially valid abbreviations, and pick the one that is ok + #by 'noderange' + my @hostnamecandidates; + my $nodename; + while ($hostname =~ /\./) { + push @hostnamecandidates,$hostname; + $hostname =~ s/\.[^\.]*//; + } + push @hostnamecandidates,$hostname; + my $checkhostnames = join(',',@hostnamecandidates); + my @validnodenames = xCAT::NodeRange::noderange($checkhostnames); + unless (scalar @validnodenames) { #If the node in question is not in table, take output literrally. + push @validnodenames,$hostnamecandidates[0]; + } + #now, noderange doesn't guarantee the order, so we search the preference order, most to least specific. + foreach my $host (@hostnamecandidates) { + if (grep /^$host$/,@validnodenames) { + $nodename = $host; + last; + } + } + my @ips = xCAT::NetworkUtils->gethost_ips; + my @hostinfo = (@ips, $nodename); + + return @hostinfo; +} + +#----------------------------------------------------------------------------- + +=head3 toIP + + IPv4 function to convert hostname to IP address + +=cut + +#----------------------------------------------------------------------------- +sub toIP +{ + + if (($_[0] =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/) || ($_[0] =~ /:/)) + { + return ([0, $_[0]]); + } + my $ip = xCAT::NetworkUtils->getipaddr($_[0]); + if (!$ip) + { + return ([1, "Cannot Resolve: $_[0]\n"]); + } + return ([0, $ip]); +} + +#------------------------------------------------------------------------------- + +=head3 validate_ip + Validate list of IPs + Arguments: + List of IPs + Returns: + 1 - Invalid IP address in the list + 0 - IP addresses are all valid + Globals: + none + Error: + none + Example: + if (xCAT::NetworkUtils->validate_ip($IP)) {} + Comments: + none +=cut + +#------------------------------------------------------------------------------- +sub validate_ip +{ + my ($class, @IPs) = @_; + foreach (@IPs) { + my $ip = $_; + #TODO need more check for IPv6 address + if ($ip =~ /:/) + { + return([0]); + } + ################################### + # Length is 4 for IPv4 addresses + ################################### + my (@octets) = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/; + if ( scalar(@octets) != 4 ) { + return( [1,"Invalid IP address1: $ip"] ); + } + foreach my $octet ( @octets ) { + if (( $octet < 0 ) or ( $octet > 255 )) { + return( [1,"Invalid IP address2: $ip"] ); + } + } + } + return([0]); +} +#------------------------------------------------------------------------------- + +=head3 isIpaddr + + returns 1 if parameter is has a valid IP address form. + + Arguments: + dot qulaified IP address: e.g. 1.2.3.4 + Returns: + 1 - if legal IP address + 0 - if not legal IP address. + Globals: + none + Error: + none + Example: + if ($ipAddr) { blah; } + Comments: + Doesn't test if the IP address is on the network, + just tests its form. + +=cut + +#------------------------------------------------------------------------------- +sub isIpaddr +{ + my $addr = shift; + if (($addr) && ($addr =~ /xCAT::NetworkUtils/)) + { + $addr = shift; + } + + unless ( $addr ) + { + return 0; + } + #print "addr=$addr\n"; + if ($addr !~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) + { + return 0; + } + + if ($1 > 255 || $1 == 0 || $2 > 255 || $3 > 255 || $4 > 255) + { + return 0; + } + else + { + return 1; + } +} + + + + +#------------------------------------------------------------------------------- +=head3 getNodeNameservers + Description: + Get nameservers of specified nodes. + The priority: noderes.nameservers > networks.nameservers > site.nameservers + Arguments: + node: node name list + Returns: + Return a hash ref, of the $nameservers{$node} + undef - Failed to get the nameservers + Globals: + none + Error: + none + Example: + my $nameservers = xCAT::NetworkUtils::getNodeNameservers(\@node); + Comments: + none + +=cut +#------------------------------------------------------------------------------- +sub getNodeNameservers{ + my $nodes=shift; + if( $nodes =~ /xCAT::NetworkUtils/) + { + $nodes=shift; + } + my @nodelist = @$nodes; + my %nodenameservers; + my $nrtab = xCAT::Table->new('noderes',-create=>0); + my %nrhash = %{$nrtab->getNodesAttribs(\@nodelist,['nameservers'])}; + + my $nettab = xCAT::Table->new("networks"); + my %nethash = xCAT::DBobjUtils->getNetwkInfo( \@nodelist ); + + my @nameservers = xCAT::TableUtils->get_site_attribute("nameservers"); + my $sitenameservers=$nameservers[0]; + + + foreach my $node (@nodelist){ + if ($nrhash{$node} and $nrhash{$node}->[0] and $nrhash{$node}->[0]->{nameservers}) + { + $nodenameservers{$node}=$nrhash{$node}->[0]->{nameservers}; + }elsif($nethash{$node}{nameservers}) + { + $nodenameservers{$node}=$nethash{$node}{nameservers}; + }elsif($sitenameservers) + { + $nodenameservers{$node}=$sitenameservers; + } + } + + return \%nodenameservers; +} + + +#------------------------------------------------------------------------------- + +=head3 getNodeNetworkCfg + Description: + Get node network configuration, including "IP, hostname(the nodename),and netmask" by this node's name. + + Arguments: + node: the nodename + Returns: + Return an array, which contains (IP,hostname,gateway,netmask'). + undef - Failed to get the network configuration info + Globals: + none + Error: + none + Example: + my ($ip,$host,undef,$mask) = xCAT::NetworkUtils::getNodeNetworkCfg('node1'); + Comments: + Presently gateway is always blank. Need to be improved. + +=cut + +#------------------------------------------------------------------------------- +sub getNodeNetworkCfg +{ + my $node = shift; + if( $node =~ /xCAT::NetworkUtils/) + { + $node =shift; + } + + my $ip = xCAT::NetworkUtils->getipaddr($node); + my $mask = undef; + my $gateway = undef; + + my $nettab = xCAT::Table->new("networks"); + if ($nettab) { + my @nets = $nettab->getAllAttribs('net','mask','gateway'); + foreach my $net (@nets) { + if (xCAT::NetworkUtils::isInSameSubnet( $net->{'net'}, $ip, $net->{'mask'}, 0)) { + $gateway=$net->{'gateway'}; + $mask=$net->{'mask'}; + } + } + } + + return ($ip, $node, $gateway, xCAT::NetworkUtils::formatNetmask($mask,0,0)); +} +#------------------------------------------------------------------------------- + +=head3 getNodesNetworkCfg + Description: + Get network configuration (ip,netmask,gateway) for a group of nodes + + Arguments: + nodes: the group of nodes + Returns: + If failed: (1, error_msg) + If success: (0, the hash variable store network configuration info for nodes that get matching network entry) + Error: + none + Example: + my ($ret, $hash) = xCAT::NetworkUtils::getNodesNetworkCfg($noderange); + Comments: + +=cut + +#------------------------------------------------------------------------------- + +sub getNodesNetworkCfg +{ + my $nodes = shift; + if ($nodes =~ /xCAT::NetworkUtils/) { + $nodes = shift; + } + my @nets = (); + my $nettab = xCAT::Table->new("networks"); + if($nettab) { + my @error_net = (); + my @all_nets = $nettab->getAllAttribs('net','mask','gateway'); + foreach my $net (@all_nets) { + my $gateway = $net->{gateway}; + if (defined($gateway) and ($gateway eq '')) { + my @gatewayd = xCAT::NetworkUtils->my_ip_facing($net->{'net'}); + unless ($gatewayd[0]) { + $gateway = $gatewayd[1]; + } + } + push @nets, {net=>$net->{net}, mask=>$net->{mask}, gateway=>$gateway}; + } + $nettab->close; + } + else { + return (1, "Open \"networks\" table failed"); + } + if (!scalar(@nets)) { + return (1, "No entry find in \"networks\" table"); + } + my %rethash = (); + foreach my $node (@$nodes) { + my $ip = xCAT::NetworkUtils->getipaddr($node); + foreach my $net (@nets) { + if (xCAT::NetworkUtils::isInSameSubnet( $net->{'net'}, $ip, $net->{'mask'}, 0)) { + $rethash{$node}->{ip} = $ip; + $rethash{$node}->{mask} = $net->{'mask'}; + $rethash{$node}->{gateway} = $net->{'gateway'}; + last; + } + } + } + return (0, \%rethash); +} + +#------------------------------------------------------------------------------- + +=head3 get_hdwr_ip + Description: + Get hardware(CEC, BPA) IP from the hosts table, and then /etc/hosts. + + Arguments: + node: the nodename(cec, or bpa) + Returns: + Return the node IP + -1 - Failed to get the IP. + Globals: + none + Error: + none + Example: + my $ip = xCAT::NetworkUtils::get_hdwr_ip('node1'); + Comments: + Used in FSPpower FSPflash, FSPinv. + +=cut + +#------------------------------------------------------------------------------- +sub get_hdwr_ip +{ + require xCAT::Table; + my $node = shift; + my $ip = undef; + my $Rc = undef; + + my $ip_tmp_res = xCAT::NetworkUtils::toIP($node); + ($Rc, $ip) = @$ip_tmp_res; + if ( $Rc ) { + my $hosttab = xCAT::Table->new( 'hosts' ); + if ( $hosttab) { + my $node_ip_hash = $hosttab->getNodeAttribs( $node,[qw(ip)]); + $ip = $node_ip_hash->{ip}; + } + + } + + if (!$ip) { + return undef; + } + + return $ip; +} + +#-------------------------------------------------------------------------------- +=head3 pingNodeStatus + This function takes an array of nodes and returns their status using nmap or fping. + Arguments: + nodes-- an array of nodes. + Returns: + a hash that has the node status. The format is: + {alive=>[node1, node3,...], unreachable=>[node4, node2...]} +=cut +#-------------------------------------------------------------------------------- +sub pingNodeStatus { + my ($class, @mon_nodes)=@_; + my %status=(); + my @active_nodes=(); + my @inactive_nodes=(); + #print "NetworkUtils->pingNodeStatus called, nodes=@mon_nodes\n"; + if ((@mon_nodes)&& (@mon_nodes > 0)) { + #get all the active nodes + my $nodes= join(' ', @mon_nodes); + if (-x '/usr/bin/nmap' or -x '/usr/local/bin/nmap') { #use nmap + #print "use nmap\n"; + my %deadnodes; + foreach (@mon_nodes) { + $deadnodes{$_}=1; + } + + # get additional options from site table + my @nmap_options = xCAT::TableUtils->get_site_attribute("nmapoptions"); + my $more_options = $nmap_options[0]; + + #call namp + open (NMAP, "nmap -PE --system-dns --send-ip -sP $more_options ". $nodes . " 2> /dev/null|") or die("Cannot open nmap pipe: $!"); + my $node; + while () { + if (/Host (.*) \(.*\) appears to be up/) { + $node=$1; + unless ($deadnodes{$node}) { + foreach (keys %deadnodes) { + if ($node =~ /^$_\./) { + $node = $_; + last; + } + } + } + delete $deadnodes{$node}; + push(@active_nodes, $node); + } elsif (/Nmap scan report for ([^ ]*) /) { + $node=$1; + } elsif (/Host is up./) { + unless ($deadnodes{$node}) { + foreach (keys %deadnodes) { + if ($node =~ /^$_\./) { + $node = $_; + last; + } + } + } + delete $deadnodes{$node}; + push(@active_nodes, $node); + } + } + foreach (sort keys %deadnodes) { + push(@inactive_nodes, $_); + } + } else { #use fping + #print "use fping\n"; + + my $temp=`fping -a $nodes 2> /dev/null`; + chomp($temp); + @active_nodes=split(/\n/, $temp); + + #get all the inactive nodes by substracting the active nodes from all. + my %temp2; + if ((@active_nodes) && ( @active_nodes > 0)) { + foreach(@active_nodes) { $temp2{$_}=1}; + foreach(@mon_nodes) { + if (!$temp2{$_}) { push(@inactive_nodes, $_);} + } + } + else {@inactive_nodes=@mon_nodes;} + } + } + + $status{$::STATUS_ACTIVE}=\@active_nodes; + $status{$::STATUS_INACTIVE}=\@inactive_nodes; + #use Data::Dumper; + #print Dumper(%status); + + return %status; +} + +#------------------------------------------------------------------------------- + +=head3 isValidMAC + Description : Validate whether specified string is a MAC string. + Arguments : macstr - the string to be validated. + Returns : 1 - valid MAC String. + 0 - invalid MAC String. +=cut + +#------------------------------------------------------------------------------- +sub isValidMAC +{ + my ($class, $macstr) = @_; + if ($macstr =~ /^[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}$/){ + return 1; + } + return 0; +} + +#------------------------------------------------------------------------------- + +=head3 isValidHostname + Description : Validate whether specified string is a valid hostname. + Arguments : hostname - the string to be validated. + Returns : 1 - valid hostname String. + 0 - invalid hostname String. +=cut + +#------------------------------------------------------------------------------- +sub isValidHostname +{ + my ($class, $hostname) = @_; + if ($hostname =~ /^[a-z0-9]/){ + if ($hostname =~ /[a-z0-9]$/){ + if ($hostname =~ /^[\-a-z0-9]+$/){ + return 1; + } + } + } + return 0; +} + + +#------------------------------------------------------------------------------- + +=head3 isValidFQDN + Description : Validate whether specified string is a valid FQDN. + Arguments : hostname - the string to be validated. + Returns : 1 - valid hostname FQDN. + 0 - invalid hostname FQDN. +=cut + +#------------------------------------------------------------------------------- +sub isValidFQDN +{ + my ($class, $hostname) = @_; + if ($hostname =~ /^[a-z0-9][\.\-a-z0-9]+[a-z0-9]$/){ + return 1; + } + return 0; +} + + +#------------------------------------------------------------------------------- + +=head3 ip_to_int + Description : convert an IPv4 string into int. + Arguments : ipstr - the IPv4 string. + Returns : ipint - int number +=cut + +#------------------------------------------------------------------------------- +sub ip_to_int +{ + my ($class, $ipstr) = @_; + my $ipint = 0; + my @ipnums = split('\.', $ipstr); + $ipint += $ipnums[0] << 24; + $ipint += $ipnums[1] << 16; + $ipint += $ipnums[2] << 8; + $ipint += $ipnums[3]; + return $ipint; +} + +#------------------------------------------------------------------------------- + +=head3 int_to_ip + Description : convert an int into IPv4 String. + Arguments : ipnit - the input int number. + Returns : ipstr - IPv4 String. +=cut + +#------------------------------------------------------------------------------- +sub int_to_ip +{ + my ($class, $ipint) = @_; + return inet_ntoa(inet_aton($ipint)); +} + +#------------------------------------------------------------------------------- + +=head3 getBroadcast + Description : Get the broadcast ips + Arguments : ipstr - the IPv4 string ip. + netmask - the subnet mask of network + Returns : bcipint - the IPv4 string of broadcast ip. +=cut + +#------------------------------------------------------------------------------- +sub getBroadcast +{ + my ($class, $ipstr, $netmask) = @_; + my $ipint = xCAT::NetworkUtils->ip_to_int($ipstr); + my $maskint = xCAT::NetworkUtils->ip_to_int($netmask); + my $tmp = sprintf("%d", ~$maskint); + my $bcnum = sprintf("%d", ($ipint | $tmp) & hex('0x00000000FFFFFFFF')); + return xCAT::NetworkUtils->int_to_ip($bcnum); +} + +#------------------------------------------------------------------------------- + +=head3 get_allips_in_range + Description : Get all IPs in a IP range, return in a list. + Arguments : $startip - start IP address + $endip - end IP address + $increment - increment factor + Returns : IP list in this range. + Example : + my $startip = "192.168.0.1"; + my $endip = "192.168.0.100"; + xCAT::NetworkUtils->get_allips_in_range($startip, $endip, 1); +=cut + +#------------------------------------------------------------------------------- +sub get_allips_in_range +{ + my $class = shift; + my $startip = shift; + my $endip = shift; + my $increment = shift; + my @iplist = (); + my $tmpip; + + my $startipnum = xCAT::NetworkUtils->ip_to_int($startip); + my $endipnum = xCAT::NetworkUtils->ip_to_int($endip); + + if ($increment > 0){ + while ($startipnum <= $endipnum){ + $tmpip = xCAT::NetworkUtils->int_to_ip($startipnum); + $startipnum += $increment; + push (@iplist, $tmpip); + } + }elsif($increment < 0){ + while ($endipnum >= $startipnum){ + $tmpip = xCAT::NetworkUtils->int_to_ip($endipnum); + $endipnum += $increment; + push (@iplist, $tmpip); + } + } + return \@iplist; +} + +#------------------------------------------------------------------------------- + +=head3 get_all_ips + Description : Get all IP addresses from table nics, column nicips. + Arguments : hashref - if not set, will return a reference of list, + if set, will return a reference of hash. + Returns : All IPs reference. +=cut + +#------------------------------------------------------------------------------- +sub get_all_nicips{ + my ($class, $hashref) = @_; + my %allipshash; + my @allipslist; + + my $table = xCAT::Table->new('nics'); + my @entries = $table->getAllNodeAttribs(['nicips']); + foreach (@entries){ + # $_->{nicips} looks like "eth0:ip1,eth1:ip2,bmc:ip3..." + if($_->{nicips}){ + my @nicandiplist = split(',', $_->{nicips}); + # Each record in @nicandiplist looks like "eth0:ip1" + # delimiter has been changed to use "!" in xCAT 2.8 + foreach (@nicandiplist){ + my @nicandip; + if ($_ =~ /!/) { + @nicandip = split('!', $_); + } else { + @nicandip = split(':', $_); + } + if ($hashref){ + $allipshash{$nicandip[1]} = 0; + } else{ + push (@allipslist, $nicandip[1]); + } + } + } + } + if ($hashref){ + return \%allipshash; + } else{ + return \@allipslist; + } +} + +#------------------------------------------------------------------------------- + +=head3 gen_net_boot_params + + Description: + This subroutine is used to generate all possible kernel parameters for network boot (rh/sles/ubuntu + diskfull/diskless) + The supported network boot parameters: + ksdevice - Specify network device for Anaconda. For rh6 and earlier. Format: 'ksdevice={$mac|$nicname}' + BOOTIF - Specify network device for Anaconda. The boot device which set by pxe. xCAT also set it if the bootload is not pxe. Format 'BOOTIF={$mac}' + ifname - Specify a interfacename<->mac pair, it will set the interfacename to the interface which has the . Format 'ifname=$ifname:$mac' + # This will only be generated when linuximage.nodebootif is set. + bootdev - Specify the boot device. Mostly it's used with parameter and when there are multiple params. Format 'bootdev={$mac|$ifname} + ip - Specify the network configuration for an interface. Format: 'ip=dhcp', 'ip=$ifname:dhcp' + + netdevice - Specify network device for Linuxrc (Suse bootloader). Format: 'netdevice={$mac|$nicname}' + + netdev - Specify the interfacename which is used by xCAT diskless boot script to select the network interface. Format: 'netdev=$nicname' + + Reference: + Redhat anaconda doc: https://github.com/rhinstaller/anaconda/blob/master/docs/boot-options.txt + Suse Linuxrc do: https://en.opensuse.org/SDB:Linuxrc + + Arguments: + $installnic <- node.installnic + $primarynic <- node.primarynic + $macmac <- node.mac + $nodebootif <- linuximage.nodebootif + + Returns: + $net_params - The key will be the parameter name, the value for the key will be the parameter value. + Valid Parameter Name: + ksdevice + netdev + netdevice + ip + ifname + BOOTIF + + And following two keys also will be returned for reference + mac + nicname + + Example: + my $netparams = xCAT::NetworkUtils->gen_net_boot_params($installnic, $primmarynic, $macmac, $nodebootif); + +=cut + +#------------------------------------------------------------------------------- + +sub gen_net_boot_params +{ + my $class = shift; + my $installnic = shift; + my $primarynic = shift; + my $macmac = shift; + my $nodebootif = shift; + + my $net_params; + + # arbitrary use primarynic if installnic is not set + unless ($installnic) { + $installnic = $primarynic; + } + + # just use the installnic to generate the nic related kernel parameters + my $mac; + my $nicname; + + # set the default nicname to nodebootif from image definition + if ($nodebootif) { + $nicname = $nodebootif; + } + + if ((! defined ($installnic)) || ($installnic eq "") || ($installnic =~ /^mac$/i)) { + $mac = $macmac; + $net_params->{mac} = $mac; + } elsif ($installnic =~ /^[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}$/) { + $mac = $installnic; + $net_params->{mac} = $mac; + $net_params->{setmac} = $mac; + } else { + $mac = $macmac; + $nicname = $installnic; + $net_params->{nicname} = $nicname; + $net_params->{mac} = $mac; + } + + # if nicname is set and mac.mac is NOT set to , use nicname in the boot parameters + if ($nicname && ! defined ($net_params->{setmac})) { + $net_params->{ksdevice} = "ksdevice=$nicname"; + $net_params->{ip} = "ip=$nicname:dhcp"; + $net_params->{netdev} = "netdev=$nicname"; + $net_params->{netdevice} = "netdevice=$nicname"; + $net_params->{ifname} = "ifname=$nicname:$mac"; # todo: may not use mac arbitrary + } elsif ($mac) { + $net_params->{ksdevice} = "ksdevice=$mac"; + $net_params->{BOOTIF} = "BOOTIF=$mac"; + $net_params->{bootdev} = "bootdev=$mac"; + $net_params->{ip} = "ip=dhcp"; + $net_params->{netdevice} = "netdevice=$mac"; + } + + return $net_params; +} + +1; diff --git a/xCAT-probe/subcmds/discovery b/xCAT-probe/subcmds/discovery index dfae06764..59791c9f5 100755 --- a/xCAT-probe/subcmds/discovery +++ b/xCAT-probe/subcmds/discovery @@ -5,6 +5,7 @@ BEGIN { $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/o use lib "$::XCATROOT/probe/lib/perl"; use probe_utils; +use xCAT::NetworkUtils; use File::Basename; use IO::Select; use Getopt::Long qw(:config no_ignore_case); @@ -13,16 +14,15 @@ use Data::Dumper; my $program_name = basename("$0"); my $help; my $test; -my $output = "stdout"; -my $verbose = 0; -my $rst = 0; -my $pre_check = 0; -my $monitor = 0; +my $output = "stdout"; +my $verbose = 0; +my $rst = 0; +my $no_pre_check = 0; my $discovery_type; my @valid_discovery_type = ("mtms", "switch"); my $valid_discovery_type_str = join(",", @valid_discovery_type); my $noderange; -my $nics; +my $nics; #reservation attribute, format : xxx|xxx|xxx #used for discovery monitor my %rawdata; @@ -32,23 +32,20 @@ my %monitor_nodes; $::USAGE = "Usage: $program_name -h - $program_name -t - $program_name -p [-V] [-T ] [-n ] - $program_name -m - $program_name [-V] [-T ] [-n ] + $program_name -T + $program_name [-V] [-m -n ] [--noprecheck] Description: - Do probe for discovery process, including pro-check for required configuration and realtime monitor of discovery process. - If without any option, $program_name will do pro-check first, if all checking point pass, then goes to monitor directly. + Do probe for discovery process, including pre-check for required configuration and realtime monitor of discovery process. + If all pre-check items pass, $program_name will go to monitor directly, otherwise $program_name exit for error. Options: -h : Get usage information of $program_name. - -t : To verify if $program_name can work, reserve option for probe framework. + -T : To verify if $program_name can work, reserve option for probe framework. -V : Output more information for debug. - -p : Do pre-check for disvoery, check whether required configuration have been done ahead. - -T : The type of discovery, the valid values are $valid_discovery_type_str. + -m : The method of discovery, the valid values are $valid_discovery_type_str. -n : The range of predefined node, must used with option -m. - -m : Do realtime monitor for discovery process. + --noprecheck : skip pre-checking discovery to validate correct configuration. "; #------------------------------------------ @@ -161,8 +158,15 @@ sub check_genesis_file { return 1; } - my @host_ip_arr = `ifconfig -a |awk -F" " '/inet / {gsub(/\w+:/,"",\$2);print \$2}'`; - my @netmask_arr = `ifconfig -a |awk -F" " '/inet / {gsub(/\w+:/,"",\$4);print \$4}'`; + my @host_ip_arr; + my @netmask_arr; + my @output = `ip addr show|awk -F" " '/inet / {print \$2}'`; + foreach (@output) { + my ($ip, $mask) = split("/", $_); + my $strmask = xCAT::NetworkUtils::formatNetmask($mask, 1, 0); + push(@host_ip_arr, $ip); + push(@netmask_arr, $strmask); + } @genesis_files = glob("$genesis_folder/*"); foreach (@genesis_files) { @@ -174,7 +178,7 @@ sub check_genesis_file { my $netmask_num = 0; foreach (@host_ip_arr) { chomp($_); - if (probe_utils->is_ip_belong_to_net($ip_range, $netmask_arr[$netmask_num], $_)) { + if (xCAT::NetworkUtils->ishostinsubnet($_, $netmask_arr[$netmask_num], $ip_range)) { $host_ip = $_; } $netmask_num++; @@ -280,7 +284,6 @@ sub check_genesis_file { sub dhcp_dynamic_range_check { my $nets = shift; my $rst = 0; - return $rst; } @@ -305,8 +308,6 @@ sub handle_tftp_msg { my $record = "Via TFTP $ip download $file"; probe_utils->send_msg("$output", "d", "$record"); if (exists($rawdata{"$ipmacmap{$ip}"})) { - - #push(@{$rawdata{$ipmacmap{$ip}}{"history"}}, $record) unless (/^$record$/ ~~ @{$rawdata{$ipmacmap{$ip}}{"history"}}); push(@{ $rawdata{ $ipmacmap{$ip} }{"history"} }, $record); } } @@ -355,33 +356,22 @@ sub handle_http_msg { #------------------------------------------ sub handle_dhcp_msg { - my $msg = shift; - my $nics = shift; - my @nicarray = split(",", $nics); - if ($msg =~ /.+DHCPDISCOVER\s+from\s+(.+)\s+via\s+(.+)/i) { - my @tmpmsg = split(" ", $msg); - my $mac = $tmpmsg[7]; - my $nic = $tmpmsg[9]; - $nic =~ s/(.+):/$1/g if ($nic =~ /:$/); - return 0 unless (@nicarray ~~ /^$nic$/); - if ($msg =~ /no free leases/) { + my $msg = shift; + + if ($msg =~ /.+DHCPDISCOVER\s+from\s+(.+)\s+via\s+([^:]+)(.*)/i) { + my $mac = $1; + my $nic = $2; + if ($3 =~ /no free leases/) { probe_utils->send_msg("$output", "d", "Receive DHCPDISCOVER from $mac via $nic, no free leases"); return 0; } my $record = "Receive DHCPDISCOVER from $mac via $nic"; probe_utils->send_msg("$output", "d", "$record"); - if (!exists($rawdata{$mac})) { - my @history; - push(@history, $record); - $rawdata{$mac}{"history"} = \@history; - } else { - push(@{ $rawdata{$mac}{"history"} }, $record); - } + push(@{ $rawdata{$mac}{"history"} }, $record); } elsif ($msg =~ /.+DHCPOFFER\s+on\s+(.+)\s+to\s+(.+)\s+via\s+(.+)/i) { - my $ip = $1; - my $mac = $2; - my $nic = $3; - return 0 unless (@nicarray ~~ /^$nic$/); + my $ip = $1; + my $mac = $2; + my $nic = $3; my $record = "Send DHCPOFFER on $ip back to $mac via $nic"; probe_utils->send_msg("$output", "d", "$record"); if (exists($rawdata{$mac})) { @@ -392,17 +382,15 @@ sub handle_dhcp_msg { my $server = $2; my $mac = $3; my $nic = $4; - return 0 unless (@nicarray ~~ /^$nic$/); my $record = "Receive DHCPREQUEST from $mac for $ip via $nic"; probe_utils->send_msg("$output", "d", "$record"); if (exists($rawdata{$mac})) { push(@{ $rawdata{$mac}{"history"} }, $record); } } elsif ($msg =~ /.+DHCPACK\s+on\s+(.+)\s+to\s+(.+)\s+via\s+(.+)/) { - my $ip = $1; - my $mac = $2; - my $nic = $3; - return 0 unless (@nicarray ~~ /^$nic$/); + my $ip = $1; + my $mac = $2; + my $nic = $3; my $record = "Send DHCPACK on $ip back to $mac via $nic"; probe_utils->send_msg("$output", "d", "$record"); if (exists($rawdata{$mac})) { @@ -410,30 +398,20 @@ sub handle_dhcp_msg { push(@{ $rawdata{$mac}{"history"} }, $record); $ipmacmap{$ip} = $mac; } - } elsif ($msg =~ /.+BOOTREQUEST\s+from\s+(.+)\s+via\s+(.+)/) { - my @tmpmsg = split(" ", $msg); - my $mac = $tmpmsg[7]; - my $nic = $tmpmsg[9]; - $nic =~ s/(.+):/$1/g if ($nic =~ /:$/); - return 0 unless (@nicarray ~~ /^$nic$/); - if ($msg =~ /no dynamic leases/) { + } elsif ($msg =~ /.+BOOTREQUEST\s+from\s+(.+)\s+via\s+([^:]+)(.*)/) { + my $mac = $1; + my $nic = $2; + if ($3 =~ /no dynamic leases/) { probe_utils->send_msg("$output", "d", "Receive DHCPDISCOVER from $mac via $nic, no dynamic leases"); return 0; } my $record = "Receive BOOTREQUEST from $mac via $nic"; probe_utils->send_msg("$output", "d", "$record"); - if (!exists($rawdata{$mac})) { - my @history; - push(@history, $record); - $rawdata{$mac}{"history"} = \@history; - } else { - push(@{ $rawdata{$mac}{"history"} }, $record); - } + push(@{ $rawdata{$mac}{"history"} }, $record); } elsif ($msg =~ /.+BOOTREPLY\s+for\s+(.+)\s+to\s+.+(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w).+via\s+(.+)/) { - my $ip = $1; - my $mac = $2; - my $nic = $3; - return 0 unless (@nicarray ~~ /^$nic$/); + my $ip = $1; + my $mac = $2; + my $nic = $3; my $record = "Send BOOTREPLY on $ip back to $mac via $nic"; probe_utils->send_msg("$output", "d", "$record"); if (exists($rawdata{$mac})) { @@ -468,20 +446,30 @@ sub handle_compute_msg { my @splitline = split(" ", $line); if (($splitline[4] =~ /^xcat/i) || ($splitline[5] =~ /^xcat/i)) { $sender = $splitline[3]; - for (my $i = 0 ; $i < 5 ; $i++) { - shift(@splitline); - } + splice(@splitline, 0, 5); $msg = join(" ", @splitline); - if (!probe_utils->is_ip_addr("$sender")) { - $ip = probe_utils->get_ip_from_hostname("$sender"); + + if (!xCAT::NetworkUtils->isIpaddr($sender)) { + $ip = xCAT::NetworkUtils->getipaddr($sender); } else { $ip = $sender; } - if ($ip ne "" && exists($ipmacmap{$ip})) { - my $record = "Recv from $ipmacmap{$ip}($ip) : $msg"; + + if ($ip ne "" && defined($ipmacmap{$ip})) { + my $record = "Recv from $ip : $msg"; probe_utils->send_msg("$output", "d", "$record"); push(@{ $rawdata{ $ipmacmap{$ip} }{"history"} }, $record); } + + # There is a node finish discovry process + if ($msg =~ /xcat.genesis.dodiscovery: Restart/) { + my $node = `lsdef -i mac -c 2>&1 | awk -F: '/$ipmacmap{$ip}/ {print \$1}'`; + chomp($node); + $monitor_nodes{$node} = 1 if (defined($monitor_nodes{$node})); + probe_utils->send_msg("$output", "o", "Node $node has finished it's discovery process"); + my $output = `lsdef $node 2>&1`; + print "-------------------\n$output-------------------\n"; + } } return 0; } @@ -508,13 +496,14 @@ sub handle_cluster_msg { if ($line =~ /.+\d+:\d+:\d+\s+(.+)\s+(xcat.+)/i) { $sender = $1; $msg = $2; - if (!probe_utils->is_ip_addr("$sender")) { - $ip = probe_utils->get_ip_from_hostname("$sender"); + + if (!xCAT::NetworkUtils->isIpaddr($sender)) { + $ip = xCAT::NetworkUtils->getipaddr($sender); } else { $ip = $sender; } - if ($ip ne "" && exists($ipmacmap{$ip})) { - my $record = "Recv from $ipmacmap{$ip}($ip) : $msg"; + if ($ip ne "" && defined($ipmacmap{$ip})) { + my $record = "Recv from $ip : $msg"; probe_utils->send_msg("$output", "d", "$record"); push(@{ $rawdata{ $ipmacmap{$ip} }{"history"} }, $record); } @@ -534,22 +523,26 @@ sub handle_cluster_msg { #------------------------------------------ sub dump_history { - probe_utils->send_msg("$output", "d", "======================================="); - probe_utils->send_msg("$output", "d", "= The summary of discovery:"); - probe_utils->send_msg("$output", "d", "======================================="); - my $masterip = `tabdump site 2>&1 | awk -F',' '/master/ { gsub(/"/, "", \$2) ; print \$2 }'`; - chomp($masterip); + my $title = " +============================================================= += The summary of discovery: +============================================================= +"; + print "$title\n"; + foreach $mac (keys %rawdata) { - my $nodehostname = probe_utils->get_hostname_from_ip($rawdata{$mac}{"ip"}, $masterip); + my $nodehostname = `lsdef -i mac -c 2>&1 | awk -F: '/$mac/ {print \$1}'`; + chomp($nodehostname); if ($nodehostname ne "") { probe_utils->send_msg("$output", "d", "[$mac ($nodehostname)]"); } else { probe_utils->send_msg("$output", "d", "[$mac]:"); } foreach my $line (@{ $rawdata{$mac}{"history"} }) { - probe_utils->send_msg("$output", "d", "| $line"); + probe_utils->send_msg("$output", "d", "\t$line"); } + print "\n"; } } @@ -584,6 +577,7 @@ sub check_pre_defined_node { $rst = 1; } elsif ($_ =~ /^\s*Object name: (\w+)/i) { $currentnode = $1; + $monitor_nodes{$1} = 0; } elsif ($_ =~ /^\s+(\w+)\s*=\s*(\w+)/) { $nodecheckrst{$currentnode}{$1} = $2; } @@ -594,29 +588,47 @@ sub check_pre_defined_node { foreach my $node (keys %nodecheckrst) { if (!exists($nodecheckrst{$node}{error})) { if ($discovery_type eq "mtms") { - if (exists($nodecheckrst{$node}{"mtm"}) && exists($nodecheckrst{$node}{"serial"})) { - $nodecheckrst{$node}{"error"} = "node definition is good for '$discovery_type' type discovery"; - } else { + if (!(exists($nodecheckrst{$node}{"mtm"}) && exists($nodecheckrst{$node}{"serial"}))) { $nodecheckrst{$node}{"error"} = "node definition is wrong for '$discovery_type' type discovery"; $rst = 1; } - } + } elsif ($discovery_type eq "switch") { + { #important to hold a block + if (!(exists($nodecheckrst{$node}{"switch"}) && exists($nodecheckrst{$node}{"switchport"}))) { + $nodecheckrst{$node}{"error"} = "Atrribute 'switch' or 'switchport' isn't defined for '$discovery_type' type discovery"; + $rst = 1; + last; + } - if ($discovery_type eq "switch") { - if (exists($nodecheckrst{$node}{"switch"}) && exists($nodecheckrst{$node}{"switchport"})) { - $nodecheckrst{$node}{"error"} = "node definition is good for '$discovery_type' type discovery"; - } else { - $nodecheckrst{$node}{"error"} = "node definition is wrong for '$discovery_type' type discovery"; - $rst = 1; + my $tmpoutput = `lsdef $nodecheckrst{$node}{"switch"} 2>&1`; + if ($?) { + $nodecheckrst{$node}{"error"} = "Miss definition for related switch $nodeswitch"; + $rst = 1; + last; + } + + if ($tmpoutput !~ /snmpversion=/) { + $nodecheckrst{$node}{"error"} = "Miss attribute 'snmpversion' definition for related switch $nodeswitch"; + $rst = 1; + last; + } + if ($tmpoutput !~ /username=/) { + $nodecheckrst{$node}{"error"} = "Miss attribute 'username' definition for related switch $nodeswitch"; + $rst = 1; + last; + } + if ($tmpoutput !~ /password=/) { + $nodecheckrst{$node}{"error"} = "Miss attribute 'password' definition for related switch $nodeswitch"; + $rst = 1; + last; + } } } } } - if ($verbose) { - foreach my $node (keys %nodecheckrst) { - probe_utils->send_msg("$output", "d", "$node : $nodecheckrst{$node}{error}"); - } + foreach my $node (keys %nodecheckrst) { + probe_utils->send_msg("$output", "d", "$node : $nodecheckrst{$node}{error}") if (exists($nodecheckrst{$node}{error})); } return $rst; @@ -624,28 +636,6 @@ sub check_pre_defined_node { #------------------------------------------ -=head3 - Description: - Get monitor nodes list - Arguments: - One golble attribute %monitor_nodes; - Returns: -=cut - -#------------------------------------------ -sub get_monitor_nodes_list { - my @cmdoutput = `lsdef $noderange 2>&1`; - foreach (@cmdoutput) { - if ($_ =~ /^Error: Could not find an object named '(\w+)' .+/i) { - $monitor_nodes{$1} = 0; - } elsif ($_ =~ /^\s*Object name: (\w+)/i) { - $monitor_nodes{$1} = 0; - } - } -} - -#------------------------------------------ - =head3 Description: Test if all nodes have finished job @@ -658,7 +648,10 @@ sub get_monitor_nodes_list { sub all_monitor_node_done { my $done = 1; foreach my $node (keys %monitor_nodes) { - $done = 0 if ($monitor_nodes{$node} == 0); + if ($monitor_nodes{$node} == 0) { + $done = 0; + last; + } } return $done; } @@ -684,7 +677,7 @@ sub do_pre_check { my $msg; if (defined($noderange) && defined($discovery_type)) { - $msg = "All pre_defined nodes are valid"; + $msg = "All pre_defined nodes '$noderange' are valid"; my $rc = check_pre_defined_node($discovery_type, $noderange); if ($rc) { probe_utils->send_msg("$output", "f", $msg); @@ -694,9 +687,9 @@ sub do_pre_check { } } - + #The block of $nics is ture is a reservation part, this part don't show up in usage if ($nics) { - if ($nics =~ /[^\w,]/) { + if ($nics =~ /[^\w|]/) { probe_utils->send_msg("$output", "f", "Invalid NIC list"); probe_utils->send_msg("$output", "d", "$::USAGE"); exit 1; @@ -711,14 +704,15 @@ sub do_pre_check { probe_utils->send_msg("$output", "d", "Network interface $nic doesn't exist on current server") if ($verbose); $miss = 1; } else { - my $tmp = `ifconfig $nic|awk -F" " '/inet / {print \$2,\$4}'`; + my $tmp = `echo $tmp_nic |awk -F" " '/inet / {print \$2}'`; chomp($tmp); - if (!$tmp) { + if (!length($tmp)) { probe_utils->send_msg("$output", "d", "Network interface $nic isn't set IP address") if ($verbose); $miss = 1; } else { - my ($ip, $mask) = split(" ", $tmp); - push(@nets, probe_utils->get_network($ip, $mask)); + my ($ip, $mask) = split("/", $tmp); + my $strmask = xCAT::NetworkUtils::formatNetmask($mask, 1, 0); + push(@nets, probe_utils->get_network($ip, $strmask)); } } } @@ -737,22 +731,26 @@ sub do_pre_check { probe_utils->send_msg("$output", "f", $msg); exit 1; } - if (!probe_utils->is_ip_addr("$masteripinsite")) { + + if (!xCAT::NetworkUtils->isIpaddr("$masteripinsite")) { probe_utils->send_msg("$output", "d", "The value of 'master' in 'site' table isn't a IP address") if ($verbose); probe_utils->send_msg("$output", "f", $msg); exit 1; } - `ifconfig -a 2>&1 |grep $masteripinsite`; + my $tmpoutput = `ip addr 2>&1 |grep $masteripinsite`; if ($?) { probe_utils->send_msg("$output", "d", "The IP $masteripinsite of 'master' in 'site' table dosen't belong to any network on current server") if ($verbose); probe_utils->send_msg("$output", "f", $msg); exit 1; } probe_utils->send_msg("$output", "o", $msg); - my $tmp = `ifconfig -a|awk -F" " '/$masteripinsite/ {print \$2,\$4}'`; + + chomp($tmpoutput); + my $tmp = `echo $tmpoutput | awk -F" " '{print \$2}'`; chomp($tmp); - my ($ip, $mask) = split(" ", $tmp); - push(@nets, probe_utils->get_network($ip, $mask)); + my ($ip, $mask) = split("/", $tmp); + my $strmask = xCAT::NetworkUtils::formatNetmask($mask, 1, 0); + push(@nets, probe_utils->get_network($ip, $strmask)); } my $arch = `uname -i`; @@ -812,23 +810,22 @@ sub do_pre_check { #------------------------------------------ sub do_monitor { + $SIG{TERM} = $SIG{INT} = sub { $terminal = 1; }; - if ($monitor && !$pre_check && defined($noderange) && defined($discovery_type)) { + if ($no_pre_check && defined($noderange) && defined($discovery_type)) { $msg = "All pre_defined nodes are valid"; my $rc = check_pre_defined_node($discovery_type, $noderange); if ($rc) { probe_utils->send_msg("$output", "f", $msg); - exit 1; + return 1; } else { probe_utils->send_msg("$output", "o", $msg); } } - &get_monitor_nodes_list if (defined($noderange) && defined($discovery_type)); - if (!$nics) { my $masteripinsite = `tabdump site | awk -F',' '/master/ { gsub(/"/, "", \$2) ; print \$2 }'`; chomp($masteripinsite); @@ -836,95 +833,147 @@ sub do_monitor { chomp($nics); if (!$nics) { probe_utils->send_msg("$output", "f", "The value of master in site table is $masteripinsite, can't get corresponding network interface"); - exit 1; + return 1; } } - probe_utils->send_msg("$output", "d", "Start to capture every message during discovery process......"); + my $startline = " +------------------------------------------------------------- + ___ + ____ _ _____ _.-| | |\\__/,| (`\\ + __ __/ ___| / \\|_ _| { | | |x x |__ _) ) + \\ \\/ / | / _ \\ | | \"-.|___| _.( T ) ` / + > <| |___ / ___ \\| | .--'-`-. _((_ `^--' /_< \\ + /_/\\_\\\\____/_/ \\_\\_| .+|______|__.-||__)`-'(((/ (((/ +------------------------------------------------------------- +"; + print "$startline\nStart to capture every message during discovery process......\n"; my $varlogmsg = "/var/log/messages"; my $clusterlog = "/var/log/xcat/cluster.log"; my $computelog = "/var/log/xcat/computes.log"; + #http logs are saved in different file in different distro my $httplog; - my $os = probe_utils->get_os(); - if ($os eq "redhat") { + if (-e "/var/log/httpd/access_log") { $httplog = "/var/log/httpd/access_log"; - } elsif ($os eq "sles") { - $httplog = "/var/log/apache2access_log"; - } elsif ($os eq "ubuntu") { + } elsif (-e "/var/log/apache2/access_log") { + $httplog = "/var/log/apache2/access_log"; + } elsif (-e "/var/log/apache2/access.log") { $httplog = "/var/log/apache2/access.log"; } - open(VARLOGMSGFILE, "tail -f $varlogmsg 2>&1 |"); - open(CLUSTERLOGFILE, "tail -f $clusterlog 2>&1 |"); - open(HTTPLOGFILE, "tail -f $httplog 2>&1 |"); - open(COMPUTERFILE, "tail -f $computelog 2>&1 |"); + my $clusterpid; + my $httppid; + my $computerpid; + my $varlogpid; + my $rst = 0; + { #important to hold a block + # start ot obtain logs from every log file + if (!($varlogpid = open(VARLOGMSGFILE, "tail -f $varlogmsg 2>&1 |"))) { + probe_utils->send_msg("$output", "f", "Can't open $varlogmsg to get logs"); + $rst = 1; + last; + } + if (!($clusterpid = open(CLUSTERLOGFILE, "tail -f $clusterlog 2>&1 |"))) { + probe_utils->send_msg("$output", "f", "Can't open $clusterlog to get logs"); + $rst = 1; + last; + } + if (!($httppid = open(HTTPLOGFILE, "tail -f $httplog 2>&1 |"))) { + probe_utils->send_msg("$output", "f", "Can't open $httplog to get logs"); + $rst = 1; + last; + } + if (!($computerpid = open(COMPUTERFILE, "tail -f $computelog 2>&1 |"))) { + probe_utils->send_msg("$output", "f", "Can't open $computelog to get logs"); + $rst = 1; + last; + } - my $select = new IO::Select; - $select->add(\*VARLOGMSGFILE); - $select->add(\*CLUSTERLOGFILE); - $select->add(\*HTTPLOGFILE); - $select->add(\*COMPUTERFILE); - $| = 1; + my $select = new IO::Select; + $select->add(\*VARLOGMSGFILE); + $select->add(\*CLUSTERLOGFILE); + $select->add(\*HTTPLOGFILE); + $select->add(\*COMPUTERFILE); + $| = 1; - my $line = ""; - my @hdls; - my $hdl; - for (; ;) { - if (@hdls = $select->can_read(0)) { - foreach $hdl (@hdls) { - if ($hdl == \*VARLOGMSGFILE) { - chomp($line = ); - my @tmp = split(/ /, $line); - if ($tmp[4] =~ /dhcpd:/i) { - handle_dhcp_msg("$line", $nics); - } elsif ($tmp[4] =~ /in.tftpd/i) { - handle_tftp_msg("$line"); + my $line = ""; + my @hdls; + my $hdl; + my $oldlines = 10; + my $varlogmsgcnt = 0; + my $clusterlogcnt = 0; + my $httplogcnt = 0; + my $computercnt = 0; + for (; ;) { + + if (@hdls = $select->can_read(0)) { + foreach $hdl (@hdls) { + if ($hdl == \*VARLOGMSGFILE) { + chomp($line = ); + ++$varlogmsgcnt; + last if ($varlogmsgcnt <= $oldlines); + my @tmp = split(/ /, $line); + if ($tmp[4] =~ /dhcpd:/i && $line =~ /$nics/) { + handle_dhcp_msg("$line"); + } elsif ($tmp[4] =~ /in.tftpd/i) { + handle_tftp_msg("$line"); + } + } elsif ($hdl == \*CLUSTERLOGFILE) { + chomp($line = ); + ++$clusterlogcnt; + last if ($clusterlogcnt <= $oldlines); + handle_cluster_msg("$line"); + } elsif ($hdl == \*HTTPLOGFILE) { + chomp($line = ); + ++$httplogcnt; + last if ($httplogcnt <= $oldlines); + handle_http_msg("$line"); + } elsif ($hdl == \*COMPUTERFILE) { + chomp($line = ); + ++$computercnt; + last if ($computercnt <= $oldlines); + handle_compute_msg("$line"); } - } elsif ($hdl == \*CLUSTERLOGFILE) { - chomp($line = ); - handle_cluster_msg("$line"); - } elsif ($hdl == \*HTTPLOGFILE) { - chomp($line = ); - handle_http_msg("$line"); - } elsif ($hdl == \*COMPUTERFILE) { - chomp($line = ); - handle_compute_msg("$line"); } } - } - if ($terminal || (%monitor_nodes && all_monitor_node_done())) { - &dump_history; - close(VARLOGMSGFILE); - close(CLUSTERLOGFILE); - close(HTTPLOGFILE); - close(COMPUTERFILE); - exit 0; + if ($terminal || (%monitor_nodes && all_monitor_node_done())) { + if ($terminal) { + probe_utils->send_msg("$output", "d", "Got from STDIN"); + } else { + probe_utils->send_msg("$output", "o", "All nodes need to monitor have finished discovery process"); + } + last; + } sleep 0.01; } - sleep 0.01; + &dump_history; } - close(VARLOGMSGFILE); - close(CLUSTERLOGFILE); - close(HTTPLOGFILE); - close(COMPUTERFILE); - return 0; + kill 'INT', $clusterpid if ($clusterpid); + kill 'INT', $httppid if ($httppid); + kill 'INT', $computerpid if ($computerpid); + kill 'INT', $varlogpid if ($varlogpid); + close(VARLOGMSGFILE) if (VARLOGMSGFILE); + close(CLUSTERLOGFILE) if (CLUSTERLOGFILE); + close(COMPUTERFILE) if (COMPUTERFILE); + close(HTTPLOGFILE) if (HTTPLOGFILE); + + return $rst; } #------------------------------------- -# main process +## main process #------------------------------------- if ( !GetOptions("--help|h|?" => \$help, - "t" => \$test, - "V" => \$verbose, - "m" => \$monitor, - "p" => \$pre_check, - "T=s" => \$discovery_type, - "n=s" => \$noderange, - "N=s" => \$nics)) + "T" => \$test, + "V" => \$verbose, + "--noprecheck" => \$no_pre_check, + "m=s" => \$discovery_type, + "n=s" => \$noderange, + "N=s" => \$nics)) #option N is a reservation option, dosen't show up in usage now { probe_utils->send_msg("$output", "f", "Invalid parameter for $program_name"); probe_utils->send_msg("$output", "d", "$::USAGE"); @@ -941,7 +990,7 @@ if ($help) { } if ($test) { - probe_utils->send_msg("$output", "o", "Do probe for discovery process, including pro-check for required configuration and realtime monitor of discovery process.Before using this command, please install nslookup command ahead."); + probe_utils->send_msg("$output", "o", "Do probe for discovery process, including pre-check for required configuration and realtime monitor of discovery process.Before using this command, please install nslookup command ahead."); exit 0; } @@ -959,19 +1008,11 @@ if (defined($discovery_type)) { } } -if ($pre_check) { - exit 1 if (do_pre_check($nics)); -} - -if ($monitor) { - $rst = do_monitor(); -} - -if (!$monitor && !$pre_check) { +if (!$no_pre_check) { $rst = do_pre_check(); exit 1 if ($rst); - - $rst = do_monitor(); } +$rst = do_monitor(); + exit $rst; diff --git a/xCAT-probe/xcatprobe b/xCAT-probe/xcatprobe index c911c23a3..2ed2da37d 100755 --- a/xCAT-probe/xcatprobe +++ b/xCAT-probe/xcatprobe @@ -10,27 +10,27 @@ $Term::ANSIColor::AUTORESET = 1; $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; -my $pro_name = basename($0); +my $program_name = basename($0); -my $pro_dir="$::XCATROOT/probe/"; +my $pro_dir = "$::XCATROOT/probe/"; my $plugin_dir = "$pro_dir/subcmds"; my %cmds = (); my $verbose = 0; -my $nocolor = 0; +my $color = (-t *STDOUT); +my $fullmsg = 0; my $help = 0; my $list = 0; $::USAGE = "Usage: xcatprobe -h xcatprobe -l -xcatprobe [-n] [-V] +xcatprobe [-V] Options: - -h : get usage information of $pro_name + -h : get usage information of $program_name -l : list all valid sub commands - -V : print verbose information of $pro_name - -n : print output without colors + -V : print verbose information of $program_name "; #----------------------------------- @@ -52,17 +52,17 @@ sub loadsubcmds { foreach (@candidate) { my $cmdname = basename("$_"); - $output = `$_ -t 2>&1`; + $output = `$_ -T 2>&1`; chomp($output); print "\n-->$_\n[OUTPUT]:\n$output\n" if ($verbose); if ($output !~ /\[(\w+)\]\s*:\s*(.+)/) { - print "skip $_ for doing '$_ -t' failed, bad format\n" if ($verbose); + print "skip $_ for doing '$_ -T' failed, bad format\n" if ($verbose); next; } else { my $desc = $2; unless ($1 ~~ /^ok$/) { - print "skip $_ for doing '$_ -t' failed, invalid flag\n" if ($verbose); + print "skip $_ for doing '$_ -T' failed, invalid flag\n" if ($verbose); next; } $cmds{$cmdname} = $desc; @@ -83,57 +83,93 @@ sub loadsubcmds { #---------------------------------- sub format_cmd_output { my $line = shift; - my $nocolor = shift; - if ($line =~ /\[(\w+)\]\s*:\s*(.+)/) { - my $flag = $1; - my $msg = $2; - my @tmpmsg = split(" ", $msg); - my $maxlen = 80; - my @finalmsg = (); - my $str = ""; - foreach my $word (@tmpmsg) { - $str .= $word . " "; - if (length($str) > $maxlen) { - push @finalmsg, $str; - $str = ""; + my $color = shift; + my $fullmsg = shift; + + my $msg; + my $flag; + + if ($line =~ /\[(\w+)\]\s*:(.+)/) { + $flag = $1; + $msg = $2; + } else { + $msg = $line; + } + + $msg =~ s/\t/ /g; + my $flaglen = 6; + my $desiredwidth = 120; + my $screenwidth = (`tput cols` + 0); + my $maxlen = ($screenwidth > $desiredwidth ? $desiredwidth : $screenwidth); + + my @finalmsg = (); + my $msglen = length($msg); + if ($msglen <= $maxlen) { + if (!$fullmsg && $flag) { + my $leftspace = $maxlen - length($msg); + if ($leftspace < $flaglen) { + $msg = substr($msg, 0, $maxlen - $flaglen); + $msg =~ s/(.*).../$1\.\.\./g; } } - push @finalmsg, $str if ($str ne ""); - - for (my $i = 0 ; $i < $#finalmsg + 1 ; $i++) { - if ($i ne $#finalmsg) { - print "$finalmsg[$i]\n"; - next; + push @finalmsg, $msg; + } else { + my @tmpmsg = split("", $msg); + my $head = 0; + my $tail = $maxlen; + while ($head < $msglen) { + push @finalmsg, substr($msg, $head, ($tail - $head)); + if (!$fullmsg) { + if ($flag) { + $finalmsg[0] =~ s/(.*).........$/$1\.\.\./g; + } else { + $finalmsg[0] =~ s/(.*)...$/$1\.\.\./g; + } + last; } - my $space = " " x ($maxlen - length($finalmsg[$i]) + 5); - print "$finalmsg[$i]$space"; + $head = $tail; + $tail = $head + ($maxlen <= ($msglen - $tail) ? $maxlen : ($msglen - $tail)); + } + } + + for (my $i = 0 ; $i < $#finalmsg + 1 ; ++$i) { + if ($i ne $#finalmsg) { + print "$finalmsg[$i]\n"; + next; + } + + if ($flag) { + my $leftspace = $maxlen - length($finalmsg[$i]); + my $spacenum = (($leftspace >= $flaglen) ? ($leftspace - $flaglen) : ($screenwidth - length($finalmsg[$i]) + $maxlen - $flaglen)); + my $spacestr = " " x $spacenum; + print "$finalmsg[$i]$spacestr"; if ($flag =~ /failed/i) { - if ($nocolor) { - print "[FAIL]\n"; - } else { + if ($color) { print BOLD RED "[FAIL]\n"; + } else { + print "[FAIL]\n"; } } elsif ($flag =~ /warning/i) { - if ($nocolor) { - print "[WARN]\n"; - } else { + if ($color) { print BOLD BLUE "[WARN]\n"; + } else { + print "[WARN]\n"; } } elsif ($flag =~ /ok/i) { - if ($nocolor) { - print "[ OK ]\n"; - } else { + if ($color) { print BOLD GREEN "[ OK ]\n"; + } else { + print "[ OK ]\n"; } } elsif ($flag =~ /debug/i) { print "\n"; } elsif ($flag =~ /info/i) { print "[INFO]\n"; } + } else { + print "$finalmsg[$i]\n"; } - } else { - print "$line\n"; } return 0; } @@ -152,32 +188,39 @@ sub listvalidsubcmd { $maxlen = length($key) if (length($key) > $maxlen); } $maxlen += 4; + + my $desiredwidth = 100; + my $screenwidth = (`tput cols` + 0); + my $finallen = ($screenwidth > $desiredwidth ? $desiredwidth : $screenwidth); + print "Supported sub commands are:\n"; foreach my $key (keys %cmds) { my @desc = split(" ", $cmds{$key}); my $str = ""; my @formatdesc = (); foreach my $word (@desc) { - $str .= $word . " "; - if (length($str) > 100) { + if (length($str) + length($word) > $finallen - $maxlen) { + $str =~ s/([^\s]+)\s$/$1/g; push @formatdesc, $str; $str = ""; } + $str .= $word . " "; } + $str =~ s/([^\s]+)\s$/$1/g; push @formatdesc, $str; - if ($nocolor) { - print "$key"; - } else { + + if ($color) { print BOLD GREEN "$key"; + } else { + print "$key"; } my $space = " " x ($maxlen - length($key)); - print "$space $formatdesc[0]\n"; + print "$space$formatdesc[0]\n"; delete $formatdesc[0]; $space = " " x $maxlen; foreach my $line (@formatdesc) { - print "$space $line\n" if (length($line)); + print "$space$line\n" if (length($line)); } - } } @@ -185,7 +228,7 @@ sub listvalidsubcmd { # main ####################################### my @tmpargv = @ARGV; -my @supportopt = ("-V", "-h", "-l", "-n"); +my @supportopt = ("-V", "-h", "-l", "-w"); my $pluginname; my $optnum = 0; foreach my $attr (@tmpargv) { @@ -199,13 +242,14 @@ foreach my $attr (@tmpargv) { $help = 1 if ($attr eq "-h"); $verbose = 1 if ($attr eq "-V"); $list = 1 if ($attr eq "-l"); - $nocolor = 1 if ($attr eq "-n"); + $fullmsg = 1 if ($attr eq "-w"); } else { $pluginname = $attr; last; } } + &loadsubcmds; if (defined($pluginname)) { my $hit = 0; @@ -234,39 +278,22 @@ if (!defined($pluginname)) { exit 0; } - -for (my $i = 0 ; $i < $optnum + 1 ; $i++) { - shift @tmpargv; -} +splice(@tmpargv, 0, $optnum + 1); my $pluginattrs = join(" ", @tmpargv); my $subcmd = "$plugin_dir/$pluginname $pluginattrs"; - print "\nsubcmd = $subcmd\n" if ($verbose); -open(PIPE, "$subcmd |"); - -my $terminal = 0; my $subcmdpid = 0; -my @tmpoutput = `ps axjf |grep -v grep|grep -v ps|grep -v bash|grep $$`; -foreach (@tmpoutput) { - @psline = split(" ", $_); $subcmdpid = $psline[1] if (($psline[0] eq $$) && ($psline[1] ne $$) && ($psline[2] eq $$)); -} $SIG{TERM} = $SIG{INT} = sub { - $terminal = 1; + $subcmdpid or exit 0; + kill 'INT', $subcmdpid; }; +$subcmdpid = open(PIPE, "$subcmd |") or die("Something went wrong while fork()ing to handle subcommand $subcmd: $!"); + while () { chomp; - format_cmd_output($_, $nocolor); - if ($terminal && $subcmdpid) { - kill 'INT', $subcmdpid; - while () { - chomp; - format_cmd_output($_, $nocolor); - } - close(PIPE); - exit $?; - } + format_cmd_output($_, $color, $fullmsg); } close(PIPE); # This will set the $? properly From 3090e6849abc7c0f492937bfe836c8534bf61174 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 28 Jun 2016 13:56:35 -0400 Subject: [PATCH 192/310] improve extraction of rootimgdir value --- xCAT-probe/subcmds/image | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/xCAT-probe/subcmds/image b/xCAT-probe/subcmds/image index 68f14b84f..5b2e4bfd0 100755 --- a/xCAT-probe/subcmds/image +++ b/xCAT-probe/subcmds/image @@ -91,21 +91,22 @@ foreach (@nodes) { if (length($node_osimage_name) > 0) { # Get provmethod for the osimage - my $osimage_provmethod = `lsdef -t osimage $node_osimage_name -i provmethod -c`; + my $osimage_provmethod = `lsdef -t osimage $node_osimage_name -i provmethod,rootimgdir -c`; if (length($osimage_provmethod) <= 0) { next; } - my ($junk2, $osimage_provmethod_type) = split "=", $osimage_provmethod; + my ($line1, $line2) = split("[\n\r]", $osimage_provmethod); + ($junk, my $osimage_provmethod_type) = split "=", $line1; + ($junk, my $rootimagedir) = split "=", $line2; chomp($osimage_provmethod_type); + chomp($rootimagedir); # Check if it is netboot, meaning diskless if ($osimage_provmethod_type eq 'netboot') { push(@diskless_nodes, $_); probe_utils->send_msg("$output", "o", "$_ is diskless"); - # For this diskless node, get UUID from rootimg directory xcatinfo file of the provmethod osimage - $rootimagedir = `lsdef -t osimage $node_osimage_name -i rootimgdir -c | cut -d "=" -f 2`; - chomp($rootimagedir); if (length($rootimagedir) > 0) { + # For this diskless node, get UUID from rootimg directory xcatinfo file of the provmethod osimage my $xcatinfo_file = $rootimagedir . "/rootimg/opt/xcat/xcatinfo"; if (-r $xcatinfo_file) { $defined_UUID = `awk -F"'" '/IMAGEUUID/ {print \$2}' $xcatinfo_file`; @@ -225,7 +226,7 @@ if ($DEFINITION_CHECK) { } } else { - $msg = "$_: Unmatched os image name or image UUID.\n Defined: name = $node_defined_image_name_hash{$_}" . + $msg = "$_: Unmatched os image name or image UUID.\n Defined: name = $node_defined_image_name_hash{$_}" . " uuid = $node_defined_image_uuid_hash{$_}\n Installed: name = $node_running_image_name_hash{$_}" . " uuid = $node_running_image_uuid_hash{$_}"; $status = "f"; @@ -267,7 +268,7 @@ if ($CONSISTENCY_CHECK) { else { my $node_image_table; foreach $compute_node (keys %node_running_image_name_hash) { - $node_image_table .= sprintf("%-15s %-30s : %-20s\n", $compute_node, $node_running_image_name_hash{$compute_node}, $node_running_image_uuid_hash{$compute_node}); + $node_image_table .= sprintf(" %-15s %-30s : %-20s\n", $compute_node, $node_running_image_name_hash{$compute_node}, $node_running_image_uuid_hash{$compute_node}); } $msg = "Not all compute nodes are installed with the same os image.\n" . $node_image_table; $status = "f"; From 5d45460c1bc9eab15cbab880465065cc21e6e207 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Tue, 28 Jun 2016 22:17:04 -0400 Subject: [PATCH 193/310] modify depending on xiaopeng's new comments --- xCAT-probe/subcmds/discovery | 6 +++++- xCAT-probe/xcatprobe | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/xCAT-probe/subcmds/discovery b/xCAT-probe/subcmds/discovery index 59791c9f5..7e9e232ed 100755 --- a/xCAT-probe/subcmds/discovery +++ b/xCAT-probe/subcmds/discovery @@ -814,7 +814,11 @@ sub do_monitor { $SIG{TERM} = $SIG{INT} = sub { $terminal = 1; }; - + + #check pre_defined node should be done during "do_pre_check" part. + #if we use '--noprecheck' to skip pre_check(include pre_defined node checking) + #then go to monitor directly, we should do pre_defined node checking + #here if noderange and discovery_type are specified. if ($no_pre_check && defined($noderange) && defined($discovery_type)) { $msg = "All pre_defined nodes are valid"; my $rc = check_pre_defined_node($discovery_type, $noderange); diff --git a/xCAT-probe/xcatprobe b/xCAT-probe/xcatprobe index 2ed2da37d..9e25e8da4 100755 --- a/xCAT-probe/xcatprobe +++ b/xCAT-probe/xcatprobe @@ -189,7 +189,7 @@ sub listvalidsubcmd { } $maxlen += 4; - my $desiredwidth = 100; + my $desiredwidth = 120; my $screenwidth = (`tput cols` + 0); my $finallen = ($screenwidth > $desiredwidth ? $desiredwidth : $screenwidth); From 1aba72dac21fad6035dd1d53d2982d085108c7b0 Mon Sep 17 00:00:00 2001 From: penguhyang Date: Tue, 28 Jun 2016 23:07:38 -0400 Subject: [PATCH 194/310] add logs in the deployment phase --- xCAT/postscripts/xcatdsklspost | 9 +++++---- xCAT/postscripts/xcatinstallpost | 17 +++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/xCAT/postscripts/xcatdsklspost b/xCAT/postscripts/xcatdsklspost index 0c87f6aaf..c7c182d78 100755 --- a/xCAT/postscripts/xcatdsklspost +++ b/xCAT/postscripts/xcatdsklspost @@ -880,11 +880,12 @@ if [ $NODE_DEPLOYMENT -eq 1 ] || [ "$MODE" = "4" ] || [ "$MODE" = "6" ]; then # echo "$TMP"> /$xcatpost/mypostscript echo " if [ \"\$return_value\" -eq \"0\" ]; then - msgutil_r \$MASTER_IP \"debug\" \"node booted successfully,reporting status...\" \"/var/log/xcat/xcat.log\" - updateflag.awk \$MASTER 3002 \"installstatus booted\" + msgutil_r \$MASTER_IP \"debug\" \"node booted successfully,reporting status...\" \"/var/log/xcat/xcat.log\" + updateflag.awk \$MASTER 3002 \"installstatus booted\" + logger -t xcat.provision -p local4.info \"provision completed.(\$NODE)\" else - msgutil_r \$MASTER_IP \"debug\" \"node boot failed,reporting status...\" \"/var/log/xcat/xcat.log\" - updateflag.awk \$MASTER 3002 \"installstatus failed\" + msgutil_r \$MASTER_IP \"debug\" \"node boot failed,reporting status...\" \"/var/log/xcat/xcat.log\" + updateflag.awk \$MASTER 3002 \"installstatus failed\" fi " >> /$xcatpost/mypostscript fi diff --git a/xCAT/postscripts/xcatinstallpost b/xCAT/postscripts/xcatinstallpost index 72ce250d5..8a874bcbf 100755 --- a/xCAT/postscripts/xcatinstallpost +++ b/xCAT/postscripts/xcatinstallpost @@ -92,15 +92,16 @@ if [ -z "$CNS" ] || [ "$CNS" != "'0'" -a "$CNS" != "'N'" -a "$CNS" != "'n'" echo " if [ \"\$return_value\" -eq \"0\" ]; then - if [ \"\$XCATDEBUGMODE\" = \"1\" ] || [ \"\$XCATDEBUGMODE\" = \"2\" ]; then - msgutil_r \"\$MASTER_IP\" \"info\" \"node booted, reporting status...\" \"/var/log/xcat/xcat.log\" - fi - updateflag.awk \$MASTER 3002 \"installstatus booted\" + if [ \"\$XCATDEBUGMODE\" = \"1\" ] || [ \"\$XCATDEBUGMODE\" = \"2\" ]; then + msgutil_r \"\$MASTER_IP\" \"info\" \"node booted, reporting status...\" \"/var/log/xcat/xcat.log\" + fi + updateflag.awk \$MASTER 3002 \"installstatus booted\" + logger -t xcat.provision -p local4.info \"provision completed.(\$NODE)\" else - if [ \"\$XCATDEBUGMODE\" = \"1\" ] || [ \"\$XCATDEBUGMODE\" = \"2\" ]; then - msgutil_r \"\$MASTER_IP\" \"info\" \"node boot failed, reporting status...\" \"/var/log/xcat/xcat.log\" - fi - updateflag.awk \$MASTER 3002 \"installstatus failed\" + if [ \"\$XCATDEBUGMODE\" = \"1\" ] || [ \"\$XCATDEBUGMODE\" = \"2\" ]; then + msgutil_r \"\$MASTER_IP\" \"info\" \"node boot failed, reporting status...\" \"/var/log/xcat/xcat.log\" + fi + updateflag.awk \$MASTER 3002 \"installstatus failed\" fi " >> /xcatpost/mypostscript.post fi From c7ac6b3d11a3e17f485b714dc92b0c8d8524f3d1 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Wed, 29 Jun 2016 12:28:29 +0800 Subject: [PATCH 195/310] [go-xcat] Print more friendly error message, when command `repoquery' is not found --- xCAT-server/share/xcat/tools/go-xcat | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index ca81ccd57..73a8e05e9 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -422,7 +422,8 @@ function check_repo_version_dnf() # $@ package names function check_repo_version_yum() { - type repoquery >/dev/null 2>&1 || return 255 + type yum >/dev/null 2>&1 || return 255 + check_exec_or_exit repoquery local -a name=() local -a ver=() while read name ver @@ -526,7 +527,8 @@ function get_package_list_dnf() # $1 repo id function get_package_list_yum() { - type repoquery >/dev/null 2>&1 || return 255 + type yum >/dev/null 2>&1 || return 255 + check_exec_or_exit repoquery local repo_id="$1" [[ -z "${repo_id}" ]] && return 1 repoquery -qa "--repoid=${repo_id}" --qf "%{name}" 2>/dev/null From cdfae3d40d84dcb0ebfa70a7ca484d2695d41026 Mon Sep 17 00:00:00 2001 From: XuWei Date: Wed, 29 Jun 2016 03:47:18 -0400 Subject: [PATCH 196/310] add status powering-on for ipmi mgt --- xCAT-server/lib/xcat/plugins/ipmi.pm | 44 +++++++++++----------------- 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 72217b903..8fe02dcb5 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -2150,6 +2150,9 @@ sub power_with_context { sub power_response { my $rsp = shift; my $sessdata = shift; + my $newstat; + my %newnodestatus=(); + if($rsp->{error}) { xCAT::SvrUtils::sendmsg([1,$rsp->{error}],$callback,$sessdata->{node},%allerrornodes); return; @@ -2159,7 +2162,20 @@ sub power_response { my $text = $codes{$rsp->{code}}; unless ($text) { $text = sprintf("Unknown response %02xh",$rsp->{code}); } xCAT::SvrUtils::sendmsg([1,$text],$callback,$sessdata->{node},%allerrornodes); - } + } else { + my $command = $sessdata->{subcommand}; + my $status = $sessdata->{powerstatus}; + if ($command eq "on") { $newstat = $::STATUS_POWERING_ON; } + if ($command eq "off" or $command eq "softoff") { $newstat = $::STATUS_POWERING_OFF; } + if ($command eq "reset" and $status eq "on"){$newstat = $::STATUS_POWERING_ON; } + if ($command eq "boot"){$newstat = $::STATUS_POWERING_ON; } + + if ($newstat) { + $newnodestatus{$newstat}=[$sessdata->{node}]; + xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); + } + } + if ($sessdata->{waitforsuspend}) { #have to repeatedly power stat until happy or timeout exceeded $sessdata->{ipmisession}->subcmd(netfn=>0x3a,command=>0x1d,data=>[1],callback=>\&power_wait_for_suspend,callback_args=>$sessdata); return; @@ -7911,33 +7927,7 @@ sub process_request { } } #print "oldstatus:" . Dumper(\%oldnodestatus); - - #set the new status to the nodelist.status - my %newnodestatus=(); - my $newstat; - if (($extrargs->[0] eq 'off') || ($extrargs->[0] eq 'softoff')) { - my $newstat=$::STATUS_POWERING_OFF; - $newnodestatus{$newstat}=\@allnodes; - } else { - #get the current nodeset stat - if (@allnodes>0) { - my $nsh={}; - my ($ret, $msg)=xCAT::SvrUtils->getNodesetStates(\@allnodes, $nsh); - if (!$ret) { - foreach (keys %$nsh) { - my $newstat=xCAT_monitoring::monitorctrl->getNodeStatusFromNodesetState($_, "rpower"); - $newnodestatus{$newstat}=$nsh->{$_}; - } - } else { - $callback->({data=>$msg}); - } - } } - #donot update node provision status (installing or netbooting) here - xCAT::Utils->filter_nostatusupdate(\%newnodestatus); - #print "newstatus" . Dumper(\%newnodestatus); - xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); - } } # NOTE (chenglch) rflash for one node need about 5-10 minutes. There is no need to rflash node From 03a54985344fa07c304a2727b4f387879fd4fd63 Mon Sep 17 00:00:00 2001 From: immarvin Date: Wed, 29 Jun 2016 04:39:19 -0400 Subject: [PATCH 197/310] fix issue Ubuntu Xenial: xcat-server needs to depend on openssh-server #1419 ; remove sshd from xcatd sysvinit file --- xCAT-server/etc/init.d/xcatd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/etc/init.d/xcatd b/xCAT-server/etc/init.d/xcatd index 1334c0ac2..512bb3a91 100755 --- a/xCAT-server/etc/init.d/xcatd +++ b/xCAT-server/etc/init.d/xcatd @@ -6,7 +6,7 @@ ### BEGIN INIT INFO # Provides: xcatd -# Required-Start: $network $syslog sshd +# Required-Start: $network $syslog # Required-Stop: # Should-Start: mysql # Default-Start: 3 4 5 From 9459d05025a247a06de86d5cc62edd8f2c3df035 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Wed, 29 Jun 2016 05:45:49 -0400 Subject: [PATCH 198/310] modify depending on ertao's comment --- xCAT-probe/subcmds/discovery | 37 +++++++++++------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/xCAT-probe/subcmds/discovery b/xCAT-probe/subcmds/discovery index 7e9e232ed..b0a43e958 100755 --- a/xCAT-probe/subcmds/discovery +++ b/xCAT-probe/subcmds/discovery @@ -676,17 +676,6 @@ sub do_pre_check { my $rst = 0; my $msg; - if (defined($noderange) && defined($discovery_type)) { - $msg = "All pre_defined nodes '$noderange' are valid"; - my $rc = check_pre_defined_node($discovery_type, $noderange); - if ($rc) { - probe_utils->send_msg("$output", "f", $msg); - $rst = 1; - } else { - probe_utils->send_msg("$output", "o", $msg); - } - } - #The block of $nics is ture is a reservation part, this part don't show up in usage if ($nics) { if ($nics =~ /[^\w|]/) { @@ -815,21 +804,6 @@ sub do_monitor { $terminal = 1; }; - #check pre_defined node should be done during "do_pre_check" part. - #if we use '--noprecheck' to skip pre_check(include pre_defined node checking) - #then go to monitor directly, we should do pre_defined node checking - #here if noderange and discovery_type are specified. - if ($no_pre_check && defined($noderange) && defined($discovery_type)) { - $msg = "All pre_defined nodes are valid"; - my $rc = check_pre_defined_node($discovery_type, $noderange); - if ($rc) { - probe_utils->send_msg("$output", "f", $msg); - return 1; - } else { - probe_utils->send_msg("$output", "o", $msg); - } - } - if (!$nics) { my $masteripinsite = `tabdump site | awk -F',' '/master/ { gsub(/"/, "", \$2) ; print \$2 }'`; chomp($masteripinsite); @@ -1012,6 +986,17 @@ if (defined($discovery_type)) { } } +if (defined($noderange) && defined($discovery_type)) { + $msg = "All pre_defined nodes are valid"; + my $rc = check_pre_defined_node($discovery_type, $noderange); + if ($rc) { + probe_utils->send_msg("$output", "f", $msg); + return 1; + } else { + probe_utils->send_msg("$output", "o", $msg); + } +} + if (!$no_pre_check) { $rst = do_pre_check(); exit 1 if ($rst); From e354783c7677482c62ca11796501609ebcced7d7 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Wed, 29 Jun 2016 11:36:29 -0400 Subject: [PATCH 199/310] Grammar and formatting changes to troubleshooting doc --- docs/source/troubleshooting/index.rst | 2 +- .../os_installation/debug_port.rst | 24 +++++++------- .../troubleshooting/os_installation/index.rst | 24 +++++++------- .../os_installation/log_to_mn_cn.rst | 32 +++++++++---------- .../os_installation/ssh_enable.rst | 8 ++--- 5 files changed, 45 insertions(+), 45 deletions(-) diff --git a/docs/source/troubleshooting/index.rst b/docs/source/troubleshooting/index.rst index 5d1f1124c..cc481d124 100644 --- a/docs/source/troubleshooting/index.rst +++ b/docs/source/troubleshooting/index.rst @@ -1,7 +1,7 @@ Troubleshooting =============== -This chapter introduces the methods of how to troubleshoot a real cluster. Basically, it includes the following parts. +This chapter introduces the methods of troubleshooting a real cluster. It includes the following parts. .. toctree:: :maxdepth: 2 diff --git a/docs/source/troubleshooting/os_installation/debug_port.rst b/docs/source/troubleshooting/os_installation/debug_port.rst index c80d891be..e7264b252 100644 --- a/docs/source/troubleshooting/os_installation/debug_port.rst +++ b/docs/source/troubleshooting/os_installation/debug_port.rst @@ -1,21 +1,21 @@ -Enable Debug Port: Running commands in the installer from MN ------------------------------------------------------------- +Enabling Debug Port: Running commands in the installer from MN +-------------------------------------------------------------- -**This mode is only supported with debug level set to 1 or 2** +**This mode is supported with debug level set to 1 or 2** -xCAT creates a server in the **installer** listening on port ``3001``. It executes commands sent to it from the xCAT MN and returns the response output. +xCAT creates a server in the **installer**, listening on port ``3001``. It executes commands sent to it from the xCAT MN and returns the response output. -The command ``runcmdinstaller`` can be used to send request to installer: :: +The command ``runcmdinstaller`` can be used to send request to installer: - Usage: +Usage: :: - runcmdinstaller "" + runcmdinstaller "" - make sure all the commands are quoted by "" +make sure all the commands are quoted by ``""`` - Example: +Example: - To list all the items under the /etc directory in the installer - - runcmdinstaller c910f03c01p03 "ls /etc" +To list all the items under the /etc directory in the installer :: + runcmdinstaller c910f03c01p03 "ls /etc" + diff --git a/docs/source/troubleshooting/os_installation/index.rst b/docs/source/troubleshooting/os_installation/index.rst index dfdff4a0c..4330f5080 100644 --- a/docs/source/troubleshooting/os_installation/index.rst +++ b/docs/source/troubleshooting/os_installation/index.rst @@ -3,19 +3,19 @@ Operating System Installation The ability to access the installer or to collect logs during the installation process can be helpful when debugging installation problems. -A new attribute is provided in the site table called ``xcatdebugmode``. :: +A new attribute is provided in the **site** table called ``xcatdebugmode``. - xcatdebugmode=0: Only diagnose Log will be show in corresponding files. - xcatdebugmode=1: Diagnose Log will be show in corresponding files and debug port will be opened. - xcatdebugmode=2: SSH is supported while installing also with diagnose log show and debug port enable. +* xcatdebugmode=0: Diagnose Log will be shown in corresponding files. +* xcatdebugmode=1: Diagnose Log will be shown in corresponding files and debug port will be opened. +* xcatdebugmode=2: Diagnose Log will be shown in corresponding files, debug port will be opened and SSH access is enabled. -List of Supported OS. :: +Supported OS: - RHEL: 6.7 and above - SLES: 11.4 and above - UBT: 14.04.3 and above +* RHEL: 6.7 and above +* SLES: 11.4 and above +* UBT: 14.04.3 and above -The following behavior is observed during OS install: +The following behavior is supported during OS installation: +-----------------+--------------+--------------+--------------+ |**xcatdebugmode**| 0 | 1 | 2 | @@ -29,11 +29,11 @@ The following behavior is observed during OS install: | SSH Access | N | N | N | N | N | N | Y | Y | Y | +-----------------+----+----+----+----+----+----+----+----+----+ -Y means the behavior is supported by OS at current xcatdebugmode. +* Y - the behavior is supported by OS at specified **xcatdebugmode** level. -N means the opposite meaning. +* N - the behavior is not supported. -This chapter introduces the procedures of how to troubleshoot operating system installation. Basically, it includes the following parts. +Next chapter introduces the procedures on how to troubleshoot operating system installation. .. toctree:: :maxdepth: 2 diff --git a/docs/source/troubleshooting/os_installation/log_to_mn_cn.rst b/docs/source/troubleshooting/os_installation/log_to_mn_cn.rst index 54f3827a5..334ad5274 100644 --- a/docs/source/troubleshooting/os_installation/log_to_mn_cn.rst +++ b/docs/source/troubleshooting/os_installation/log_to_mn_cn.rst @@ -1,14 +1,14 @@ -Log Collecting: Collecting logs of the whole installation process +Log Collection: Collecting logs of the whole installation process ----------------------------------------------------------------- -The ability to collect logs during the installation(diskfull and diskless) can be enabled by setting the "site.xcatdebugmode" to different levels(0,1,2), which is quite helpful when debugging installation problems. +The ability to collect logs during the installation (diskful and diskless) can be enabled by setting the "site.xcatdebugmode" to different levels (0,1,2), which is quite helpful when debugging installation problems. -The logs during diskfull provision: -``````````````````````````````````` +The logs during diskful provision: +`````````````````````````````````` * Pre-Install logs: the logs of pre-installation scripts, the pre-installation scripts include "%pre" section in anaconda, "" section for SUSE and "partman/early_command" and "preseed/early_command" sections for ubuntu. The logs include the STDOUT and STDERR of the scripts as well as the debug trace output of bash scripts with "set -x" -* Installer logs: the logs from the os installer itself, i.e, the logs of installation program(anaconda, autoyast and preseed,etc.) +* Installer logs: the logs from the os installer itself, i.e, the logs of installation program (anaconda, autoyast and preseed,etc.) * Post-Install logs: the logs of post-installation scripts, the post-installation scripts include "%post" section in anaconda, "" and "" sections for SUSE and "preseed/late_command" section for ubuntu. The logs include the STDOUT and STDERR of the scripts as well as the debug trace output of bash scripts with "set -x" @@ -57,25 +57,25 @@ The logs during diskless provision: | | CN | C1 | C1 C2 | C1 C2 | +----------------+----+----+----+----+----+----+----+----+----+----+ -MN: the logs forwarded to management node(M1-M4 is the operation for MN). :: +MN: the logs forwarded to management node (M1-M4 is the operation for MN). - M1 means the installer logs can be forwarded to the MN in ``/var/log/xcat/computes.log`` file. +* M1: the installer logs will be forwarded to the MN in ``/var/log/xcat/computes.log`` file. - M2 means the error messages can be forwarded to ``/var/log/xcat/computes.log`` file on MN only when critical error happens. +* M2: the error messages will be forwarded to ``/var/log/xcat/computes.log`` file on MN only when critical error happens. - M3 means the installation logs can be forwarded to ``/var/log/xcat/computes.log`` file on MN. +* M3: the installation logs will be forwarded to ``/var/log/xcat/computes.log`` file on MN. - M4 means the debug trace("set -x" or "-o xtrace") of bash scripts enabled. +* M4: the debug trace("set -x" or "-o xtrace") of bash scripts enabled. - N means the logs can not be forwarded to MN. +* N: the logs will not be forwarded to MN. -CN: the logs on compute node(C1-C3 is the operation for CN). :: +CN: the logs on compute node (C1-C3 is the operation for CN). - C1 means the installation logs can be saved to ``/var/log/xcat/xcat.log`` file on CN. +* C1 - the installation logs will be saved to ``/var/log/xcat/xcat.log`` file on CN. - C2 means the debug trace("set -x" or "-o xtrace") of bash scripts enabled. +* C2 - the debug trace("set -x" or "-o xtrace") of bash scripts enabled. - C3 means the installer logs can be saved to the CN in ``/var/log/anaconda`` for RHEL, ``/var/log/YaST2`` for SLES, ``/var/log/installer`` for UBT. +* C3 - the installer logs will be saved to the CN in ``/var/log/anaconda`` for RHEL, ``/var/log/YaST2`` for SLES, ``/var/log/installer`` for UBT. - N means the logs can not be saved to CN. +* N - the logs will not be saved to CN. diff --git a/docs/source/troubleshooting/os_installation/ssh_enable.rst b/docs/source/troubleshooting/os_installation/ssh_enable.rst index 5d1bebd3a..8f2e94b80 100644 --- a/docs/source/troubleshooting/os_installation/ssh_enable.rst +++ b/docs/source/troubleshooting/os_installation/ssh_enable.rst @@ -1,9 +1,9 @@ SSH Access: Accessing the installer via "ssh" --------------------------------------------- -**This mode is only supported with debug level set to 2** +**This mode is supported with debug level set to 2** -The ssh access to the installer is enabled, the admin can login into the installer through: +When ssh access to the installer is enabled, the admin can login into the installer through: #. For RHEL, the installation won't halt, just login into the installer with ``ssh root@``. @@ -28,7 +28,7 @@ The ssh access to the installer is enabled, the admin can login into the install SYSTEMCTL_OPTIONS=--ignore-dependencies yast.ssh -#. For UBT, the installation will halt on the following similar message in the console: :: +#. For UBT, the installation will halt on the message in the console similar to: :: ┌───────────┤ [!!] Continue installation remotely using SSH ├───────────┠│ │ @@ -49,7 +49,7 @@ The ssh access to the installer is enabled, the admin can login into the install │ │ └───────────────────────────────────────────────────────────────────────┘ - Just as the message show, the admin can run ``ssh installer@`` with the password "cluster" to login into the installer, the following message shows on login: :: + Just as the message above suggests, the admin can run ``ssh installer@`` with the password "cluster" to login into the installer, the following message shows on login: :: ┌────────────────────┤ [!!] Configuring d-i ├─────────────────────┠│ │ From 5db2a6755391530672d592797ce711438754d179 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Wed, 29 Jun 2016 13:52:07 -0400 Subject: [PATCH 200/310] Add mysql user to localhost account --- xCAT-client/bin/mysqlsetup | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/xCAT-client/bin/mysqlsetup b/xCAT-client/bin/mysqlsetup index 23e0c371d..408580e11 100755 --- a/xCAT-client/bin/mysqlsetup +++ b/xCAT-client/bin/mysqlsetup @@ -914,6 +914,7 @@ sub initmysqldb exit(1); } + } #----------------------------------------------------------------------------- @@ -1213,6 +1214,14 @@ sub setupxcatdb $grantall .= "\'"; $grantall .= " IDENTIFIED BY \'$::adminpassword\';\r"; + #GRAND user xcatadmin to localhost account + my $grantall_localhost= ""; + $grantall_localhost = "GRANT ALL on xcatdb.* TO xcatadmin@"; + $grantall_localhost .= "\'"; + $grantall_localhost .= "localhost"; + $grantall_localhost .= "\'"; + $grantall_localhost .= " IDENTIFIED BY \'$::adminpassword\';\r"; + # # -re $pwd_prompt # Enter the password for root @@ -1279,6 +1288,8 @@ sub setupxcatdb $mysql->clear_accum(); $mysql->send("$grantall"); $mysql->clear_accum(); + $mysql->send("$grantall_localhost"); + $mysql->clear_accum(); $mysql->send("exit;\r"); } From 4fe66724095eb4f1360434752e9c755bec1f40d0 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Wed, 29 Jun 2016 14:57:42 -0400 Subject: [PATCH 201/310] Eliminate another command call in the loop --- xCAT-probe/subcmds/image | 52 +++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/xCAT-probe/subcmds/image b/xCAT-probe/subcmds/image index 5b2e4bfd0..5218156ef 100755 --- a/xCAT-probe/subcmds/image +++ b/xCAT-probe/subcmds/image @@ -71,9 +71,6 @@ unless (defined($CONSISTENCY_CHECK) || defined($DEFINITION_CHECK)) { exit 1; } -my @nodes = `nodels`; -@nodes = grep(s/^[\s]+|[\s]*$//g, @nodes); - my @pingable_nodes; my @diskless_nodes; my $na = "N/A"; @@ -81,30 +78,37 @@ my $na = "N/A"; my $defined_UUID = $na; my %node_defined_image_uuid_hash; my %node_defined_image_name_hash; +my %osimage_defined_provmethod_hash; + +my $all_nodes_provmethod = `lsdef -i provmethod -c`; +my $all_osimage_provmethod = `lsdef -t osimage -i provmethod,rootimgdir -c`; +chomp($all_nodes_provmethod); +my @all_nodes_provmethod_lines = split("[\n\r]", $all_nodes_provmethod); +my @all_osimage_provmethod_lines = split("[\n\r]", $all_osimage_provmethod); + +# Build a hash of key="osimage name + attribute name" value="provmethod and rootimgdir attribute value" +foreach (@all_osimage_provmethod_lines) { + my ($osimage_name, $values) = split "=", $_; + $osimage_defined_provmethod_hash{$osimage_name} = $values; +} # First, extract diskless nodes -foreach (@nodes) { +foreach (@all_nodes_provmethod_lines) { # Get osimage name for the node - my $node_provmethod = `lsdef $_ -i provmethod -c`; - my ($junk, $node_osimage_name) = split "=", $node_provmethod; + my ($node_name, $junk, $node_osimage_name) = split "[:=]", $_; chomp($node_osimage_name); if (length($node_osimage_name) > 0) { - # Get provmethod for the osimage - my $osimage_provmethod = `lsdef -t osimage $node_osimage_name -i provmethod,rootimgdir -c`; - if (length($osimage_provmethod) <= 0) { - next; - } - my ($line1, $line2) = split("[\n\r]", $osimage_provmethod); - ($junk, my $osimage_provmethod_type) = split "=", $line1; - ($junk, my $rootimagedir) = split "=", $line2; - chomp($osimage_provmethod_type); - chomp($rootimagedir); + # Get provmethod and rootimgdir for the osimage + my $osimage_provmethod_type = $osimage_defined_provmethod_hash{$node_osimage_name . ": provmethod"}; + my $rootimagedir= $osimage_defined_provmethod_hash{$node_osimage_name . ": rootimgdir"}; + chomp($osimage_provmethod_type) if ($osimage_provmethod_type); + chomp($rootimagedir) if ($rootimagedir); # Check if it is netboot, meaning diskless - if ($osimage_provmethod_type eq 'netboot') { - push(@diskless_nodes, $_); - probe_utils->send_msg("$output", "o", "$_ is diskless"); + if ($osimage_provmethod_type && $osimage_provmethod_type eq 'netboot') { + push(@diskless_nodes, $node_name); + probe_utils->send_msg("$output", "o", "$node_name is diskless"); if (length($rootimagedir) > 0) { # For this diskless node, get UUID from rootimg directory xcatinfo file of the provmethod osimage my $xcatinfo_file = $rootimagedir . "/rootimg/opt/xcat/xcatinfo"; @@ -116,12 +120,12 @@ foreach (@nodes) { } } } - $node_defined_image_uuid_hash{$_} = $defined_UUID; - $node_defined_image_name_hash{$_} = $node_osimage_name; - print "Node $_ has defined image $node_osimage_name at $rootimagedir with UUID $defined_UUID\n" if ($VERBOSE); + $node_defined_image_uuid_hash{$node_name} = $defined_UUID; + $node_defined_image_name_hash{$node_name} = $node_osimage_name; + print "Node $node_name has defined image $node_osimage_name at $rootimagedir with UUID $defined_UUID\n" if ($VERBOSE); } else { - probe_utils->send_msg("$output", "w", "$_ is not diskless. No image consistency verification will be performed."); + probe_utils->send_msg("$output", "w", "$node_name is not diskless. No image consistency verification will be performed."); } } } @@ -191,7 +195,7 @@ foreach (@pingable_nodes) { } } -# Build a hash of key=hostname, value=running OS image name +# Build a hash of key="hostname", value="running OS image name" foreach (@xdsh_name_lines) { my ($hostname, $osimage_name) = split ": ", $_; chomp($hostname); From de876776366cb95b4351011a0eec740eb4d0d34b Mon Sep 17 00:00:00 2001 From: bybai Date: Thu, 30 Jun 2016 01:24:44 -0400 Subject: [PATCH 202/310] fix 1439 confignics fails on CentOS 7.2 --- xCAT/postscripts/configeth | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/xCAT/postscripts/configeth b/xCAT/postscripts/configeth index 6e82999e3..94b3fea5e 100755 --- a/xCAT/postscripts/configeth +++ b/xCAT/postscripts/configeth @@ -425,9 +425,9 @@ elif [ "$1" = "-s" ];then inst_nic=`ip -o link |grep -i ${str_inst_mac} |awk '{print $2}'|sed 's/://g'` if [ ! -z "${inst_nic}" ];then str_inst_ip=`ip -4 -o addr|grep -i ${inst_nic} |awk '{print $4}'|awk -F/ '{print $1}'` - if [ ! -z "str_inst_ip" ];then + if [ ! -z "$str_inst_ip" ];then inst_ip_pre=`ip ro ls|grep -i ${str_inst_ip}|awk '{print $1}'|awk -F/ '{print $1}'` - if [ ! -z "inst_ip_pre" ];then + if [ ! -z "$inst_ip_pre" ];then str_inst_mask=`route |grep ^${inst_ip_pre}|awk '{print $3}'|head -1` fi fi @@ -447,9 +447,9 @@ elif [ "$1" = "-s" ];then inst_nic=`ip -o link |grep -i ${str_inst_mac} |awk '{print $2}'|sed 's/://g'` if [ ! -z "${inst_nic}" ];then str_inst_ip=`ip -4 -o addr|grep -i ${inst_nic} |awk '{print $4}'|awk -F/ '{print $1}'` - if [ ! -z "str_inst_ip" ];then + if [ ! -z "$str_inst_ip" ];then inst_ip_pre=`ip ro ls|grep -i ${str_inst_ip}|awk '{print $1}'|awk -F/ '{print $1}'` - if [ ! -z "inst_ip_pre" ];then + if [ ! -z "$inst_ip_pre" ];then str_inst_mask=`route |grep ^${inst_ip_pre}|awk '{print $3}'|head -1` fi fi @@ -459,7 +459,7 @@ elif [ "$1" = "-s" ];then fi fi else - str_lease_file=`ls /var/lib/dhclient/*$str_inst_nic* | grep leases` + str_lease_file=`ls /var/lib/dhclient/*$str_inst_nic* | grep lease` if [ -e "$str_lease_file" ];then str_inst_ip=`grep fixed-address $str_lease_file | tail -n 1 | awk '{print $2}' | sed 's/;$//'` str_inst_mask=`grep subnet-mask $str_lease_file | tail -n 1 | awk '{print $3}' | sed 's/;$//'` @@ -470,9 +470,9 @@ elif [ "$1" = "-s" ];then inst_nic=`ip -o link |grep -i ${str_inst_mac} |awk '{print $2}'|sed 's/://g'` if [ ! -z "${inst_nic}" ];then str_inst_ip=`ip -4 -o addr|grep -i ${inst_nic} |awk '{print $4}'|awk -F/ '{print $1}'` - if [ ! -z "str_inst_ip" ];then + if [ ! -z "$str_inst_ip" ];then inst_ip_pre=`ip ro ls|grep -i ${str_inst_ip}|awk '{print $1}'|awk -F/ '{print $1}'` - if [ ! -z "inst_ip_pre" ];then + if [ ! -z "$inst_ip_pre" ];then str_inst_mask=`route |grep ^${inst_ip_pre}|awk '{print $3}'|head -1` fi fi From 80e6a947b8e2b2207ec3c1ef73b5610d848090be Mon Sep 17 00:00:00 2001 From: ertaozh Date: Thu, 30 Jun 2016 01:44:24 -0400 Subject: [PATCH 203/310] Fix issue 1371: xcatprobe switch - could not get valid information while using switch-macmap --- perl-xCAT/xCAT/MacMap.pm | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/perl-xCAT/xCAT/MacMap.pm b/perl-xCAT/xCAT/MacMap.pm index 74c6b8afc..bc78f8630 100644 --- a/perl-xCAT/xCAT/MacMap.pm +++ b/perl-xCAT/xCAT/MacMap.pm @@ -16,6 +16,7 @@ use xCAT::Table; use xCAT::Utils; use xCAT::MsgUtils; use xCAT::TableUtils; +use xCAT::NetworkUtils; use IO::Select; use IO::Handle; use Sys::Syslog; @@ -573,10 +574,14 @@ sub getsnmpsession { $snmpver=$swent->{snmpversion}; $community=$swent->{password}; } + my $switch_ip = xCAT::NetworkUtils->getipaddr($switch); + unless ($switch_ip) { + return ({"ErrorStr"=>"Can not resolve IP address for $switch"}); + } if ($snmpver ne '3') { if ($vlanid) { $community .= '@'.$vlanid; } $session = new SNMP::Session( - DestHost => $switch, + DestHost => $switch_ip, Version => $snmpver, Community => $community, UseNumeric => 1 @@ -587,7 +592,7 @@ sub getsnmpsession { } else { #we have snmp3 my %args= ( - DestHost => $switch, + DestHost => $switch_ip, SecName => $swent->{username}, AuthProto => uc($swent->{auth}), AuthPass => $community, @@ -629,8 +634,11 @@ sub refresh_switch { } return; } - elsif ($session->{ErrorStr} and $self->{collect_mac_info}) { - $self->{macinfo}->{$switch}->{ErrorStr} = $session->{ErrorStr}; + elsif ($session->{ErrorStr}) { + if ($self->{collect_mac_info}) { + $self->{macinfo}->{$switch}->{ErrorStr} = $session->{ErrorStr}; + } + return; } my $namemap = walkoid($session,'.1.3.6.1.2.1.31.1.1.1.1', verbose=>$self->{show_verbose_info}, switch=>$switch, callback=>$self->{callback}); #namemap is the mapping of ifIndex->(human readable name) @@ -695,6 +703,12 @@ sub refresh_switch { $session = $self->getsnmpsession('switch'=>$switch,'community'=>$community,'vlanid'=>$vlan); } unless ($session) { return; } + elsif ($session->{ErrorStr}) { + if ($self->{collect_mac_info}) { + $self->{macinfo}->{$switch}->{ErrorStr} = $session->{ErrorStr}; + } + return; + } my $bridgetoifmap = walkoid($session,'.1.3.6.1.2.1.17.1.4.1.2', ciscowarn=>$iscisco, verbose=>$self->{show_verbose_info}, switch=>$switch, callback=>$self->{callback}); # Good for all switches if (not ref $bridgetoifmap or !keys %{$bridgetoifmap}) { xCAT::MsgUtils->message("S","Error communicating with ".$session->{DestHost}.": failed to get a valid response to BRIDGE-MIB request"); From 027101f1ce6521f640187eae41e281598efb0e86 Mon Sep 17 00:00:00 2001 From: penguhyang Date: Thu, 30 Jun 2016 01:20:52 -0400 Subject: [PATCH 204/310] record the status change of CN --- .../lib/xcat/monitoring/monitorctrl.pm | 166 ++++++++++-------- 1 file changed, 89 insertions(+), 77 deletions(-) diff --git a/xCAT-server/lib/xcat/monitoring/monitorctrl.pm b/xCAT-server/lib/xcat/monitoring/monitorctrl.pm index 65848d01b..251bf54f3 100644 --- a/xCAT-server/lib/xcat/monitoring/monitorctrl.pm +++ b/xCAT-server/lib/xcat/monitoring/monitorctrl.pm @@ -7,6 +7,7 @@ BEGIN } use lib "$::XCATROOT/lib/perl"; use strict; +use Sys::Syslog qw(:standard :extended); use xCAT::NodeRange; use xCAT::Table; use xCAT::MsgUtils; @@ -592,85 +593,96 @@ sub getNodeStatusFromNodesetState { =cut #-------------------------------------------------------------------------------- sub setNodeStatusAttributes { - print "monitorctrl::setNodeStatusAttributes called\n"; - my $temp=shift; - if ($temp =~ /xCAT_monitoring::monitorctrl/) { - $temp=shift; - } - my $force=shift; - my $tab = xCAT::Table->new('nodelist',-create=>1,-autocommit=>1); - my $nttab = xCAT::Table->new('nodetype',-create=>1,-autocommit=>1); - - my %status_hash=%$temp; - - #check if the next value is valid or not - if (!$force) { - foreach my $s (keys %status_hash) { - my @new_nodes=(); - my $nodes=$status_hash{$s}; - if ($nodes && (@$nodes>0)) { - my $tabdata=$tab->getNodesAttribs($nodes,['node', 'status']); - my $nttabdata=$nttab->getNodesAttribs($nodes,['node', 'nodetype']); - foreach my $node (@$nodes) { - my $tmp1=$tabdata->{$node}->[0]; - if ($tmp1) { - my $status=$tmp1->{status}; - if (!$status) {$status=$::STATUS_DEFINED; } #default is 'defined' - if ($::NEXT_NODESTAT_VAL{$status}->{$s}==1) { push(@new_nodes,$node); } - else { - #for non-osi type, always change - my $type; - my $nttmp1=$nttabdata->{$node}->[0]; - if ($nttmp1) { - $type=$nttmp1->{nodetype}; - } - if ((!$type) || ($type !~ /osi/)) {push(@new_nodes,$node);} - } - } - } - } - #print "newnodes=@new_nodes\n"; - $status_hash{$s}=\@new_nodes; - } #end foreach - } - - my %updates; - my ( - $sec, $min, $hour, $mday, $mon, - $year, $wday, $yday, $isdst - ) - = localtime(time); - my $currtime = sprintf("%02d-%02d-%04d %02d:%02d:%02d", - $mon + 1, $mday, $year + 1900, - $hour, $min, $sec); - if ($tab) { - foreach (keys %status_hash) { - my $nodes=$status_hash{$_}; - if (@$nodes > 0) { - $updates{'status'} = $_; - $updates{'statustime'} = $currtime; - my $where_clause; - my $dbname=xCAT::Utils->get_DBName() ; - if ($dbname eq 'DB2') { - $where_clause="\"node\" in ('" . join("','", @$nodes) . "')"; - } else { - $where_clause="node in ('" . join("','", @$nodes) . "')"; - } - $tab->setAttribsWhere($where_clause, \%updates ); - } + print "monitorctrl::setNodeStatusAttributes called\n"; + my $temp = shift; + if ($temp =~ /xCAT_monitoring::monitorctrl/) { + $temp = shift; } - } - else { - xCAT::MsgUtils->message("S", "Could not read the nodelist table\n"); - } + my $force = shift; + my $nltab = xCAT::Table->new('nodelist',-create=>1,-autocommit=>1); + my $nttab = xCAT::Table->new('nodetype',-create=>1,-autocommit=>1); - if ($tab) { - $tab->close; - } - if ($nttab) { - $nttab->close; - } - return 0; + my %status_hash = %$temp; + + #check if the next value is valid or not + if (!$force) { + foreach my $s (keys %status_hash) { + my @new_nodes = (); + my $nodes = $status_hash{$s}; + if ($nodes && (@$nodes>0)) { + my $tabdata = $nltab->getNodesAttribs($nodes,['node', 'status']); + my $nttabdata = $nttab->getNodesAttribs($nodes,['node', 'nodetype']); + foreach my $node (@$nodes) { + my $tmp1 = $tabdata->{$node}->[0]; + if ($tmp1) { + my $status = $tmp1->{status}; + if (!$status) { + #default is 'defined' + $status = $::STATUS_DEFINED; + } + if ($::NEXT_NODESTAT_VAL{$status}->{$s} == 1) { + push(@new_nodes,$node); + } + else { + #for non-osi type, always change + my $type; + my $nttmp1 = $nttabdata->{$node}->[0]; + if ($nttmp1) { + $type = $nttmp1->{nodetype}; + } + if ((!$type) || ($type !~ /osi/)) {push(@new_nodes,$node);} + } + } + } + } + #print "newnodes=@new_nodes\n"; + $status_hash{$s} = \@new_nodes; + #end foreach + } + } + + my %updates; + my ( + $sec, $min, $hour, $mday, $mon, + $year, $wday, $yday, $isdst + ) + = localtime(time); + my $currtime = sprintf("%02d-%02d-%04d %02d:%02d:%02d", + $mon + 1, $mday, $year + 1900, + $hour, $min, $sec); + if ($nltab) { + foreach (keys %status_hash) { + my $nodes = $status_hash{$_}; + if (@$nodes > 0) { + $updates{'status'} = $_; + $updates{'statustime'} = $currtime; + my $nodestate = "@$nodes status: $updates{'status'} statustime: $updates{'statustime'}"; + openlog('xcat', 'ndelay', 'local4'); + syslog('local4|info', '%s', $nodestate); + closelog(); + my $where_clause; + my $dbname = xCAT::Utils->get_DBName() ; + if ($dbname eq 'DB2') { + $where_clause = "\"node\" in ('" . join("','", @$nodes) . "')"; + } + else { + $where_clause = "node in ('" . join("','", @$nodes) . "')"; + } + $nltab->setAttribsWhere($where_clause, \%updates ); + } + } + } + else { + xCAT::MsgUtils->message("S", "Could not read the nodelist table\n"); + } + + if ($nltab) { + $nltab->close; + } + if ($nttab) { + $nttab->close; + } + return 0; } #-------------------------------------------------------------------------------- From 643e16b248aead3ef5ba139c5548712afad6c933 Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Thu, 30 Jun 2016 03:14:08 -0400 Subject: [PATCH 205/310] delete unused files --- xCAT-test/autotest/bundle/sles12_ppc64.bundle | 265 ------------------ .../autotest/bundle/sles12_ppc64le.bundle | 96 ++----- 2 files changed, 17 insertions(+), 344 deletions(-) delete mode 100644 xCAT-test/autotest/bundle/sles12_ppc64.bundle diff --git a/xCAT-test/autotest/bundle/sles12_ppc64.bundle b/xCAT-test/autotest/bundle/sles12_ppc64.bundle deleted file mode 100644 index 1437440d1..000000000 --- a/xCAT-test/autotest/bundle/sles12_ppc64.bundle +++ /dev/null @@ -1,265 +0,0 @@ -reg_linux_diskfull_installation_flat -chdef_null -chdef_t_node -chdef_t_network -chdef_p -chdef_m -chdef_z -chdef_group -chdef_group_p -chdef_dynamic_group -chdef_multiple_keys -chdef_n -chdef_t_o_error -chtab_null -chtab_d -chtab_modify_node -chtab_modify_key -chtab_h -chtab_v -copycds_iso -copycds_n -copycds_a -copycds_n_a -copycds_a_err -copycds_n_err -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_node -getmacs_noderange -getmacs_d -getmacs_f_D -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -lslite_i -lslite_noderange -lslite_h -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a -makedhcp_a_d -makedhcp_d -mkdef_null -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_normal -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_tab -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_specificvalue -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_err_node -rinv_bus -rinv_config -rinv_serial -rinv_model -rinv_firm -rinv_all -rinv_noderange_err -rmdef_null -rmdef_t_err -rpower_off -rpower_stat -rpower_boot -rpower_on -rpower_reset -rpower_noderange -rpower_noderange_nodeps -rpower_err_noderange -rscan_noderange -rscan_x -rscan_z -rscan_w -rscan_x_w -rscan_z_w -rvitals_lcds -rvitals_all -rvitals_noderange_err -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_p_auditlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -makehosts_h -makehosts_help -makehosts_null -makehosts_l -makehosts_d -makehosts_n -makehosts_n_noderange -xdcp_src_dst -makedns_h -makedns_d_node -makedns_n -makedns -noderange_individual_node -noderange_individual_grp -noderange_node01-node10 -noderange_group1-group3 -noderange_10-20 -noderange_XCAT_NODE_PREFIX -noderange_XCAT_NODE_SUFFIX -noderange_exclusion -noderange_group_intersection -confignics_config_one_port_single_value -confignics_config_multiple_ports_single_value -confignics_config_multiple_ports_multiple_value -confignics_config_multiple_port_withnichostnamesuffixes_multiple_value -confignics_config_multiple_port_withnicaliases_multiple_value -confignics_disable_set_to_yes -confignics_disable_set_to_1 -confignics_s -xdsh_h -xdsh_V -xdsh_regular_command -xdsh_Q_command -xdsh_c_cn -xdsh_e_filename -xdsh_E -xdsh_t -xdsh_q -xdsh_T -xdsh_o -switchdiscover_range_default -switchdiscover_h -switchdiscover_range_s -switchdiscover_range_default_w -switchdiscover_range_r -switchdiscover_range_x -switchdiscover_range_z -switchdiscover_range_z_V -makentp_v -makentp_h -makentp_V -makentp -makentp_a -nodeset_check_warninginfo -reg_linux_diskless_installation_flat -reg_linux_statelite_installation_flat -SN_setup_case -reg_linux_diskfull_installation_hierarchy -reg_linux_diskless_installation_hierarchy diff --git a/xCAT-test/autotest/bundle/sles12_ppc64le.bundle b/xCAT-test/autotest/bundle/sles12_ppc64le.bundle index 25688bf6f..4435fbcc2 100644 --- a/xCAT-test/autotest/bundle/sles12_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/sles12_ppc64le.bundle @@ -1,28 +1,20 @@ -reg_linux_diskfull_installation_flat +Diskless_installation_flat_p8_le +Full_installation_flat_p8_le +makehosts_h +makehosts_help +makehosts_n +makehosts_n_noderange chdef_null -chdef_t_node -chdef_t_network -chdef_p -chdef_m chdef_z -chdef_group -chdef_group_p -chdef_dynamic_group -chdef_multiple_keys -chdef_n chdef_t_o_error chtab_null chtab_d chtab_modify_node chtab_modify_key +chtab_err_symble +chtab_err_table chtab_h chtab_v -copycds_iso -copycds_n -copycds_a -copycds_n_a -copycds_a_err -copycds_n_err packimage_o_p_a_m packimage_p_a_o packimage_imagename @@ -31,9 +23,6 @@ packimage_v pping_h pping_v pping_node -getmacs_noderange -getmacs_d -getmacs_f_D gettab_key_table gettab_H gettab_err @@ -46,9 +35,6 @@ lsdef_t lsdef_t_i_o lsdef_t_w lsdef_t_err -lslite_i -lslite_noderange -lslite_h makeconservercf_null makeconservercf_noderange makeconservercf_d @@ -106,7 +92,6 @@ nodels_noderange_tablecolumn nodels_tablevalue_tablecolumn nodels_h nodels_v -xcatstanzafile_normal xcatstanzafile_colon xcatstanzafile_attribute xcatstanzafile_objtype @@ -121,31 +106,10 @@ noderm_err_node nodeset_stat nodeset_noderange nodestat_err_node -rinv_bus -rinv_config -rinv_serial -rinv_model -rinv_firm -rinv_all rinv_noderange_err rmdef_null rmdef_t_err -rpower_off -rpower_stat -rpower_boot -rpower_on -rpower_reset -rpower_noderange -rpower_noderange_nodeps rpower_err_noderange -rscan_noderange -rscan_x -rscan_z -rscan_w -rscan_x_w -rscan_z_w -rvitals_lcds -rvitals_all rvitals_noderange_err tabdump_table tabdump_d @@ -166,7 +130,6 @@ tabprune_h tabprune_v tabprune_a_eventlog tabprune_V_a_eventlog -tabprune_p_auditlog tabprune_i_auditlog tabprune_V_n_auditlog tabgrep_node @@ -204,35 +167,15 @@ lsxcatd_null lsxcatd_h lsxcatd_d lsxcatd_a -makehosts_h -makehosts_help -makehosts_null -makehosts_l -makehosts_d -makehosts_n -makehosts_n_noderange -xdcp_src_dst -makedns_h makedns_d_node makedns_n makedns -noderange_individual_node -noderange_individual_grp -noderange_node01-node10 -noderange_group1-group3 -noderange_10-20 -noderange_XCAT_NODE_PREFIX -noderange_XCAT_NODE_SUFFIX -noderange_exclusion -noderange_group_intersection -confignics_config_one_port_single_value -confignics_config_multiple_ports_single_value -confignics_config_multiple_ports_multiple_value -confignics_config_multiple_port_withnichostnamesuffixes_multiple_value -confignics_config_multiple_port_withnicaliases_multiple_value -confignics_disable_set_to_yes -confignics_disable_set_to_1 -confignics_s +copycds_iso +copycds_n +copycds_a +copycds_n_a +copycds_a_err +copycds_n_err xdsh_h xdsh_V xdsh_regular_command @@ -240,6 +183,7 @@ xdsh_Q_command xdsh_c_cn xdsh_e_filename xdsh_E +xdsh_i_linux xdsh_t xdsh_q xdsh_T @@ -258,11 +202,5 @@ xcatd_restart_systemd run_command_with_XCATBYPASS_systemd disable_root_permission_in_policy_table_systemd assign_certain_command_permission_systemd -makentp_v -makentp_h -makentp_V -makentp -makentp_a -nodeset_check_warninginfo -reg_linux_diskless_installation_flat -reg_linux_statelite_installation_flat +sles_migration1 +sles_migration2 From 30d4ddfdc6eebd2b045beee5de4b3dcbef8d6bdb Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Thu, 30 Jun 2016 03:18:07 -0400 Subject: [PATCH 206/310] change cases order --- xCAT-test/autotest/bundle/sles12.1_ppc64.bundle | 3 --- xCAT-test/autotest/bundle/sles12.1_x86_64.bundle | 3 --- xCAT-test/autotest/bundle/sles12_x86_64.bundle | 4 ---- 3 files changed, 10 deletions(-) diff --git a/xCAT-test/autotest/bundle/sles12.1_ppc64.bundle b/xCAT-test/autotest/bundle/sles12.1_ppc64.bundle index 1437440d1..04a1ebe34 100644 --- a/xCAT-test/autotest/bundle/sles12.1_ppc64.bundle +++ b/xCAT-test/autotest/bundle/sles12.1_ppc64.bundle @@ -260,6 +260,3 @@ makentp_a nodeset_check_warninginfo reg_linux_diskless_installation_flat reg_linux_statelite_installation_flat -SN_setup_case -reg_linux_diskfull_installation_hierarchy -reg_linux_diskless_installation_hierarchy diff --git a/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle b/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle index 5a593f1f3..fc971be5b 100644 --- a/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle +++ b/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle @@ -211,6 +211,3 @@ sles_migration1 sles_migration2 reg_linux_diskless_installation_flat reg_linux_statelite_installation_flat -SN_setup_case -reg_linux_diskfull_installation_hierarchy -reg_linux_diskless_installation_hierarchy diff --git a/xCAT-test/autotest/bundle/sles12_x86_64.bundle b/xCAT-test/autotest/bundle/sles12_x86_64.bundle index 34b44fe00..1cac18c63 100644 --- a/xCAT-test/autotest/bundle/sles12_x86_64.bundle +++ b/xCAT-test/autotest/bundle/sles12_x86_64.bundle @@ -209,7 +209,3 @@ disable_root_permission_in_policy_table_systemd assign_certain_command_permission_systemd reg_linux_diskless_installation_flat reg_linux_statelite_installation_flat -SN_setup_case -reg_linux_diskfull_installation_hierarchy -reg_linux_diskless_installation_hierarchy - From 28bb64214488f1994420aaa984c41fb6e0057e05 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Thu, 30 Jun 2016 14:44:50 -0400 Subject: [PATCH 207/310] Suggested improvements --- docs/source/troubleshooting/index.rst | 2 +- .../os_installation/debug_port.rst | 12 ++--- .../troubleshooting/os_installation/index.rst | 6 +-- .../os_installation/log_to_mn_cn.rst | 46 +++++++++++-------- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/docs/source/troubleshooting/index.rst b/docs/source/troubleshooting/index.rst index cc481d124..d8f69a11b 100644 --- a/docs/source/troubleshooting/index.rst +++ b/docs/source/troubleshooting/index.rst @@ -1,7 +1,7 @@ Troubleshooting =============== -This chapter introduces the methods of troubleshooting a real cluster. It includes the following parts. +This chapter introduces the methods of troubleshooting a xCAT cluster. It includes the following parts. .. toctree:: :maxdepth: 2 diff --git a/docs/source/troubleshooting/os_installation/debug_port.rst b/docs/source/troubleshooting/os_installation/debug_port.rst index e7264b252..f5d043892 100644 --- a/docs/source/troubleshooting/os_installation/debug_port.rst +++ b/docs/source/troubleshooting/os_installation/debug_port.rst @@ -7,15 +7,9 @@ xCAT creates a server in the **installer**, listening on port ``3001``. It execu The command ``runcmdinstaller`` can be used to send request to installer: -Usage: :: +Usage: ``runcmdinstaller ""`` - runcmdinstaller "" +Note: Make sure all the commands are quoted by ``""`` -make sure all the commands are quoted by ``""`` - -Example: - -To list all the items under the /etc directory in the installer :: - - runcmdinstaller c910f03c01p03 "ls /etc" +To list all the items under the /etc directory in the installer: ``runcmdinstaller c910f03c01p03 "ls /etc"`` diff --git a/docs/source/troubleshooting/os_installation/index.rst b/docs/source/troubleshooting/os_installation/index.rst index 4330f5080..6a263c5f3 100644 --- a/docs/source/troubleshooting/os_installation/index.rst +++ b/docs/source/troubleshooting/os_installation/index.rst @@ -5,9 +5,9 @@ The ability to access the installer or to collect logs during the installation p A new attribute is provided in the **site** table called ``xcatdebugmode``. -* xcatdebugmode=0: Diagnose Log will be shown in corresponding files. -* xcatdebugmode=1: Diagnose Log will be shown in corresponding files and debug port will be opened. -* xcatdebugmode=2: Diagnose Log will be shown in corresponding files, debug port will be opened and SSH access is enabled. +* xcatdebugmode=0: Diagnostic entries will be shown in corresponding log files. +* xcatdebugmode=1: Diagnostic entries will be shown in corresponding log files and debug port will be opened. +* xcatdebugmode=2: Diagnostic entries will be shown in corresponding log files, debug port will be opened and SSH access is enabled. Supported OS: diff --git a/docs/source/troubleshooting/os_installation/log_to_mn_cn.rst b/docs/source/troubleshooting/os_installation/log_to_mn_cn.rst index 334ad5274..007142084 100644 --- a/docs/source/troubleshooting/os_installation/log_to_mn_cn.rst +++ b/docs/source/troubleshooting/os_installation/log_to_mn_cn.rst @@ -3,17 +3,8 @@ Log Collection: Collecting logs of the whole installation process The ability to collect logs during the installation (diskful and diskless) can be enabled by setting the "site.xcatdebugmode" to different levels (0,1,2), which is quite helpful when debugging installation problems. -The logs during diskful provision: +The diskful provision logs: `````````````````````````````````` - -* Pre-Install logs: the logs of pre-installation scripts, the pre-installation scripts include "%pre" section in anaconda, "" section for SUSE and "partman/early_command" and "preseed/early_command" sections for ubuntu. The logs include the STDOUT and STDERR of the scripts as well as the debug trace output of bash scripts with "set -x" - -* Installer logs: the logs from the os installer itself, i.e, the logs of installation program (anaconda, autoyast and preseed,etc.) - -* Post-Install logs: the logs of post-installation scripts, the post-installation scripts include "%post" section in anaconda, "" and "" sections for SUSE and "preseed/late_command" section for ubuntu. The logs include the STDOUT and STDERR of the scripts as well as the debug trace output of bash scripts with "set -x" - -* PostBootScript logs: the logs during the post boot scripts execution, which are specified in "postbootscripts" attribute of node and osimage definition and run during the 1st reboot after installation. - +---------------------+--------------+--------------+--------------+ | **xcatdebugmode** | 0 | 1 | 2 | +---------------------+----+----+----+----+----+----+----+----+----+ @@ -36,13 +27,8 @@ The logs during diskful provision: | | CN | C1 | C1 C2 | C1 C2 | +----------------+----+----+----+----+----+----+----+----+----+----+ -The logs during diskless provision: +The diskless provision logs: ``````````````````````````````````` - -* Provision logs: the logs during the diskless provision. - -* PostBootScript logs: the logs during the post boot scripts execution, which are specified in "postbootscripts" attribute of node and osimage definition and run during the 1st reboot after installation. - +---------------------+--------------+--------------+--------------+ | **xcatdebugmode** | 0 | 1 | 2 | +---------------------+----+----+----+----+----+----+----+----+----+ @@ -57,7 +43,27 @@ The logs during diskless provision: | | CN | C1 | C1 C2 | C1 C2 | +----------------+----+----+----+----+----+----+----+----+----+----+ -MN: the logs forwarded to management node (M1-M4 is the operation for MN). +* **Pre-Install** logs: the logs of pre-installation scripts, including: + + * ``%pre`` section in anaconda, + * ```` section for SUSE and ``partman/early_command`` and ``preseed/early_command`` sections for ubuntu. + * STDOUT and STDERR of the scripts + * debug trace output of bash scripts with ``set -x`` + +* **Installer** logs: the logs from the os installer itself, i.e, the logs of installation program (anaconda, autoyast and preseed,etc.) + +* **Post-Install** logs: the logs of post-installation scripts, including + + * ``%post`` section in anaconda, + * ```` and ```` sections for SUSE and ``preseed/late_command`` section for ubuntu. + * STDOUT and STDERR of the scripts + * debug trace output of bash scripts with ``set -x`` + +* **Provision** logs: the logs during the diskless provision. + +* **PostBootScript** logs: the logs during the post boot scripts execution, which are specified in ``postbootscripts`` attribute of node and osimage definition and run during the 1st reboot after installation. + +MN: the logs forwarded to management node: * M1: the installer logs will be forwarded to the MN in ``/var/log/xcat/computes.log`` file. @@ -65,15 +71,15 @@ MN: the logs forwarded to management node (M1-M4 is the operation for MN). * M3: the installation logs will be forwarded to ``/var/log/xcat/computes.log`` file on MN. -* M4: the debug trace("set -x" or "-o xtrace") of bash scripts enabled. +* M4: the debug trace(``set -x`` or ``-o xtrace``) of bash scripts enabled. * N: the logs will not be forwarded to MN. -CN: the logs on compute node (C1-C3 is the operation for CN). +CN: the logs on compute node: * C1 - the installation logs will be saved to ``/var/log/xcat/xcat.log`` file on CN. -* C2 - the debug trace("set -x" or "-o xtrace") of bash scripts enabled. +* C2 - the debug trace(``set -x`` or ``-o xtrace``) of bash scripts enabled. * C3 - the installer logs will be saved to the CN in ``/var/log/anaconda`` for RHEL, ``/var/log/YaST2`` for SLES, ``/var/log/installer`` for UBT. From 2a4b0a9caab144722acf7bf6a960ded2fabe4c7f Mon Sep 17 00:00:00 2001 From: XuWei Date: Wed, 29 Jun 2016 02:38:45 -0400 Subject: [PATCH 208/310] add powering-on status for PPC-HMC --- perl-xCAT/xCAT/PPCboot.pm | 4 +++ perl-xCAT/xCAT/PPCpower.pm | 49 ++++++++++++++++++++++++++++- xCAT-server/lib/perl/xCAT/PPC.pm | 26 --------------- xCAT-server/lib/xcat/plugins/kvm.pm | 1 - 4 files changed, 52 insertions(+), 28 deletions(-) diff --git a/perl-xCAT/xCAT/PPCboot.pm b/perl-xCAT/xCAT/PPCboot.pm index 1f5b9e776..1c58f559e 100644 --- a/perl-xCAT/xCAT/PPCboot.pm +++ b/perl-xCAT/xCAT/PPCboot.pm @@ -596,6 +596,10 @@ sub rnetboot { # ##################################### if ( $data =~ /Finished/) { + my $newstat = $::STATUS_POWERING_ON; + my %newnodestatus=(); + $newnodestatus{$newstat}=[$node]; + xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); return( [[$node,"Success",$Rc]] ); } ##################################### diff --git a/perl-xCAT/xCAT/PPCpower.pm b/perl-xCAT/xCAT/PPCpower.pm index a37453305..0ee082f51 100644 --- a/perl-xCAT/xCAT/PPCpower.pm +++ b/perl-xCAT/xCAT/PPCpower.pm @@ -8,6 +8,9 @@ use xCAT::Usage; use xCAT::MsgUtils; use xCAT::FSPpower; +use xCAT::GlobalDef; +use xCAT_monitoring::monitorctrl; + ########################################################################## # Parse the command line for options and operands ########################################################################## @@ -183,6 +186,9 @@ sub powercmd_boot { my $Rc = shift(@$stat); my $data = @$stat[0]; + my $newstat; + my %newnodestatus = (); + while (my ($name,$d) = each(%$hash) ) { ################################## # Look up by lparid @@ -197,6 +203,7 @@ sub powercmd_boot { push @output, [$name,$data,$Rc]; next; } + ################################## # Node not found ################################## @@ -210,6 +217,10 @@ sub powercmd_boot { my $state = power_status($data->{$id}); my $op = ($state =~ /^off$/) ? "on" : "reset"; + if ($state =~ /^off$/) { + $newstat = $::STATUS_POWERING_ON; + } + # Attribute powerinterval in site table, # to control the rpower forking speed if ((defined($request->{op})) && ($request->{op} ne 'stat') && ($request->{op} ne 'status') @@ -225,6 +236,9 @@ sub powercmd_boot { $exp, $op, $d ); + unless (@$result[0] != SUCCESS) { + $newnodestatus{$newstat}=[$name] if ($newstat); + } push @output, [$name,@$result[1],@$result[0]]; } if (defined($request->{opt}->{m})) { @@ -283,6 +297,8 @@ sub powercmd_boot { } } } + + xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); return( \@output ); } @@ -298,6 +314,14 @@ sub powercmd { my @result = (); my $callback = $request->{'callback'}; + my ($name) = keys %$hash; + my $mtms = @{$hash->{$name}}[2]; + my $stat = enumerate( $exp, $hash, $mtms ); + my $Rc = shift(@$stat); + my $data = @$stat[0]; + + my $newstat; + my %newnodestatus=(); #################################### # Power commands are grouped by CEC @@ -305,6 +329,7 @@ sub powercmd { #################################### while (my ($name,$d) = each(%$hash) ) { + $newstat = ""; # Attribute powerinterval in site table, # to control the rpower forking speed if ((defined($request->{op})) && ($request->{op} ne 'stat') && ($request->{op} ne 'status') @@ -313,6 +338,21 @@ sub powercmd { Time::HiRes::sleep($request->{'powerinterval'}); } } + if (($request->{op} eq 'off') || ($request->{op} ne 'softoff')) { + $newstat = $::STATUS_POWERING_OFF; + } + if ($request->{op} eq 'on') { + $newstat = $::STATUS_POWERING_ON; + } + + if ($request->{op} eq 'reset') { + my $type = @$d[4]; + my $id = ($type=~/^(fsp|bpa|frame|cec)$/) ? $type : @$d[0]; + my $state = power_status($data->{$id}); + if ($state !~ /^off$/) { + $newstat = $::STATUS_POWERING_ON; + } + } ################################ # Send command to each LPAR ################################ @@ -320,7 +360,13 @@ sub powercmd { $exp, $request->{op}, $d ); - my $Rc = shift(@$values); + my $Rc = shift(@$values); + + unless ($Rc != SUCCESS) { + if ($newstat) { + $newnodestatus{$newstat}=[$name]; + } + } ################################ # Return result @@ -371,6 +417,7 @@ sub powercmd { } } } + xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); return( \@result ); } diff --git a/xCAT-server/lib/perl/xCAT/PPC.pm b/xCAT-server/lib/perl/xCAT/PPC.pm index 9c7c3ba52..4facbde0b 100644 --- a/xCAT-server/lib/perl/xCAT/PPC.pm +++ b/xCAT-server/lib/perl/xCAT/PPC.pm @@ -250,32 +250,6 @@ sub process_command { } } #print "oldstatus:" . Dumper(\%oldnodestatus); - - #set the new status to the nodelist.status - my %newnodestatus=(); - my $newstat; - if (($subcommand eq 'off') || ($subcommand eq 'softoff')) { - my $newstat=$::STATUS_POWERING_OFF; - $newnodestatus{$newstat}=\@allnodes; - } else { - #get the current nodeset stat - if (@allnodes>0) { - my $nsh={}; - my ($ret, $msg)=xCAT::SvrUtils->getNodesetStates(\@allnodes, $nsh); - if (!$ret) { - foreach (keys %$nsh) { - my $newstat=xCAT_monitoring::monitorctrl->getNodeStatusFromNodesetState($_, $command); - $newnodestatus{$newstat}=$nsh->{$_}; - } - } else { - trace( $request, $msg ); - } - } - } - #donot update node provision status (installing or netbooting) here - xCAT::Utils->filter_nostatusupdate(\%newnodestatus); - #print "newstatus" . Dumper(\%newnodestatus); - xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); } } diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index 50e2d40d0..52260c41b 100755 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -3074,7 +3074,6 @@ sub power { } $newnodestatus{$newstat}=[$node]; - xCAT::Utils->filter_nostatusupdate(\%newnodestatus); xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); unless ($retstring =~ /reset/) { From 0fafd7fab660ac66d532d4514083943214d54f14 Mon Sep 17 00:00:00 2001 From: XuWei Date: Thu, 30 Jun 2016 21:45:44 -0400 Subject: [PATCH 209/310] xCAT probe discovery dhcp dynamic check --- xCAT-probe/subcmds/discovery | 82 +++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/xCAT-probe/subcmds/discovery b/xCAT-probe/subcmds/discovery index b0a43e958..8e037b96d 100755 --- a/xCAT-probe/subcmds/discovery +++ b/xCAT-probe/subcmds/discovery @@ -284,6 +284,86 @@ sub check_genesis_file { sub dhcp_dynamic_range_check { my $nets = shift; my $rst = 0; + + my $dhcpconfig = "/etc/dhcp/dhcpd.conf"; + my $os = probe_utils->get_os(); + + if ($os =~ "unknown") { + probe_utils->send_msg("$output", "d", "The OS is not supported.") if ($verbose); + return 1; + } elsif ($os =~ "ubuntu") { + if (! -e "/etc/dhcp") { + $dhcpconfig = "/etc/dhcp3/dhcpd.conf"; + } + } + + my $config_line; + my $net_ip; + my $net_mask; + my $is_match; + my $dynamic_range; + my $net_file; + my $arch = `uname -i`; + chomp($arch); + my $tftpdir = `tabdump site | grep "tftpdir" | awk -F "," '{print \$2}'`; + chomp($tftpdir); + $tftpdir =~ s/"//g; + + foreach $net (@$nets){ + ($net_ip, $net_mask) = split ('/', $net); + $net_str = "subnet $net_ip netmask $net_mask"; + + $is_match = 0; + $dynamic_range = ""; + + unless (open (FILE, $dhcpconfig)) { + probe_utils->send_msg("$output", "d", "Cannot open file $dhcpconfig.") if ($verbose); + return 1; + } + + while ($config_line = ) { + chomp($config_line); + $config_line =~ s/^\s+|\s+$//g; + + if ($config_line =~ /^$net_str/) { + $is_match = 1; + probe_utils->send_msg("$output", "d", "The net $net is matched.") if ($verbose); + } + + if ($config_line =~ /subnet_end/) { + if ($is_match eq 0) { + probe_utils->send_msg("$output", "d", "There is no subnet match net $net.") if ($verbose); + $rst = 1; + next; + } + unless ($dynamic_range) { + probe_utils->send_msg("$output", "d", "Dynamic range for net $net did not be configured.") if ($verbose); + $rst = 1; + } + } + + if (($config_line =~ /^range dynamic-bootp/) and ($is_match eq 1)) { + my @range_tmp = split(' ', $config_line); + $dynamic_range = "$range_tmp[2]-$range_tmp[3]"; + probe_utils->send_msg("$output", "d", "Dynamic range for net $net is $dynamic_range.") if ($verbose); + } + } + + my $net_cdir = xCAT::NetworkUtils::formatNetmask($net_mask, 0, 1); + if ($arch =~ /ppc64/i) { + $net_file = "$tftpdir/pxelinux.cfg/p/$net_ip"."_$net_cdir"; + } else { + $net_file = "$tftpdir/xcat/xnba/nets/$net_ip"."_$net_cdir.uefi"; + } + + if (-e "$net_file") { + probe_utils->send_msg("$output", "d", "The genesis file $net_file for net $net exists.") if ($verbose); + } else { + probe_utils->send_msg("$output", "d", "The genesis file $net_file for net $net dose not exist.") if ($verbose); + $rst = 1; + } + } + return $rst; } @@ -1001,7 +1081,7 @@ if (!$no_pre_check) { $rst = do_pre_check(); exit 1 if ($rst); } - +exit; $rst = do_monitor(); exit $rst; From 227b8f6c9440ceee9f93b1656771e345d2134a6a Mon Sep 17 00:00:00 2001 From: penguhyang Date: Thu, 30 Jun 2016 21:45:47 -0400 Subject: [PATCH 210/310] fix #1409, can't find expected logs --- xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist | 1 + 1 file changed, 1 insertion(+) diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist index 3f6a557e3..076e5d9a7 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist @@ -18,6 +18,7 @@ dracut dracut-network e2fsprogs bc +file lsvpd irqbalance procps-ng From 44506cbfe0e187a0103823598998835636a0af8a Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 30 Jun 2016 22:52:06 -0400 Subject: [PATCH 211/310] fix issue [FVT]Please update the 'chdef template' return message #1440 --- xCAT-server/lib/xcat/plugins/DBobjectdefs.pm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm index 1bd4e47b4..ddde968b2 100755 --- a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm +++ b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm @@ -604,6 +604,14 @@ sub processArgs return 2; } + #"--template" can only be used with "mkdef" and "lsdef" command + if(defined $::opt_template && ($::command ne "mkdef" && $::command ne "lsdef")){ + my $rsp; + $rsp->{data}->[0] = "The option \'--template\' can not be used with \'$::command\'."; + xCAT::MsgUtils->message("E", $rsp, $::callback); + return 2; + } + #it is illegal to specify no object template for "mkdef --template", if($::command eq "mkdef" and defined $::opt_template and !$::opt_template){ my $rsp; From c6c8f2b838881e0d174b00e85951022a48d4958c Mon Sep 17 00:00:00 2001 From: immarvin Date: Fri, 1 Jul 2016 03:21:10 -0400 Subject: [PATCH 212/310] fix issue [FVT]It is no unified for template, node, osimage while running lsdef #1437 --- xCAT/templates/objects/node/cec.stanza | 2 +- xCAT/templates/objects/node/hmc.stanza | 2 +- xCAT/templates/objects/node/ppc64le.stanza | 2 +- xCAT/templates/objects/node/ppc64lekvmguest.stanza | 2 +- xCAT/templates/objects/node/switch.stanza | 2 +- xCAT/templates/objects/node/x86_64.stanza | 2 +- xCAT/templates/objects/node/x86_64kvmguest.stanza | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/xCAT/templates/objects/node/cec.stanza b/xCAT/templates/objects/node/cec.stanza index b0dbf4e53..a60f1f936 100644 --- a/xCAT/templates/objects/node/cec.stanza +++ b/xCAT/templates/objects/node/cec.stanza @@ -1,6 +1,6 @@ # -cec: +cec-template: objtype=node groups=cec,all hcp="MANDATORY:The hardware control point(HMC) for the node" diff --git a/xCAT/templates/objects/node/hmc.stanza b/xCAT/templates/objects/node/hmc.stanza index de7b91a94..09eb8bfff 100644 --- a/xCAT/templates/objects/node/hmc.stanza +++ b/xCAT/templates/objects/node/hmc.stanza @@ -1,6 +1,6 @@ # -hmc: +hmc-template: objtype=node groups=hmc hwtype=hmc diff --git a/xCAT/templates/objects/node/ppc64le.stanza b/xCAT/templates/objects/node/ppc64le.stanza index d212de973..f0a72bf23 100644 --- a/xCAT/templates/objects/node/ppc64le.stanza +++ b/xCAT/templates/objects/node/ppc64le.stanza @@ -1,6 +1,6 @@ # -ppc64le: +ppc64le-template: objtype=node arch=ppc64le bmc="MANDATORY:The hostname or ip address of the BMC adapater" diff --git a/xCAT/templates/objects/node/ppc64lekvmguest.stanza b/xCAT/templates/objects/node/ppc64lekvmguest.stanza index 24fc4e558..b6e28d1f2 100644 --- a/xCAT/templates/objects/node/ppc64lekvmguest.stanza +++ b/xCAT/templates/objects/node/ppc64lekvmguest.stanza @@ -1,6 +1,6 @@ # -ppc64lekvmguest: +ppc64lekvmguest-template: objtype=node arch=ppc64le groups=all diff --git a/xCAT/templates/objects/node/switch.stanza b/xCAT/templates/objects/node/switch.stanza index 059186a40..8950e1037 100644 --- a/xCAT/templates/objects/node/switch.stanza +++ b/xCAT/templates/objects/node/switch.stanza @@ -1,6 +1,6 @@ # -switch: +switch-template: objtype=node groups=switch ip="OPTIONAL:the ip address of the switch" diff --git a/xCAT/templates/objects/node/x86_64.stanza b/xCAT/templates/objects/node/x86_64.stanza index d1ab8bd24..b59a46066 100644 --- a/xCAT/templates/objects/node/x86_64.stanza +++ b/xCAT/templates/objects/node/x86_64.stanza @@ -1,6 +1,6 @@ # -x86_64: +x86_64-template: objtype=node arch=x86_64 bmc="MANDATORY:The hostname or ip address of the BMC adapater" diff --git a/xCAT/templates/objects/node/x86_64kvmguest.stanza b/xCAT/templates/objects/node/x86_64kvmguest.stanza index 9397e933f..52d8efb5c 100644 --- a/xCAT/templates/objects/node/x86_64kvmguest.stanza +++ b/xCAT/templates/objects/node/x86_64kvmguest.stanza @@ -1,6 +1,6 @@ # -x86_64kvmguest: +x86_64kvmguest-template: objtype=node arch=x86_64 groups=all From 6845606f294842ecc734480f931b11f0e70f6456 Mon Sep 17 00:00:00 2001 From: chenglch Date: Fri, 1 Jul 2016 04:07:54 -0400 Subject: [PATCH 213/310] Add restapi for console Provide the interface for xcat web GUI to control console resource. --- xCAT-server/xCAT-wsapi/xcatws.cgi | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/xCAT-server/xCAT-wsapi/xcatws.cgi b/xCAT-server/xCAT-wsapi/xcatws.cgi index d0fa35d62..54e3ca8a9 100755 --- a/xCAT-server/xCAT-wsapi/xcatws.cgi +++ b/xCAT-server/xCAT-wsapi/xcatws.cgi @@ -217,6 +217,18 @@ my %URIdef = ( outhdler => \&noout, } }, + console => { + desc => "[URI:/nodes/{noderange}/console] - The console configuration for the node {noderange}", + matcher => '^/nodes/[^/]*/console$', + PUT => { + desc => "Update conserver configuration for the node {noderange}.", + usage => "|Json Formatted DataBody: {action:on/off}.|$usagemsg{non_getreturn}|", + example => "|Enable the console capability for node1|PUT|/nodes/node1/console {\"action\":\"on\"}||", + cmd => "makeconservercf", + fhandler => \&actionhdl, + outhdler => \&noout, + } + }, energy => { desc => "[URI:/nodes/{noderange}/energy] - The energy resource for the node {noderange}", matcher => '^/nodes/[^/]*/energy$', @@ -2119,6 +2131,14 @@ sub actionhdl { } } + } elsif ($params->{'resourcename'} eq "console") { + if ($paramhash->{'action'}) { + my $option = $paramhash->{'action'}; + my %op_hash = ('on' => '', 'off' => '-d'); + push @args, $op_hash{$paramhash->{'action'}}; + } else { + error("Missed Action.",$STATUS_NOT_FOUND); + } } push @{$request->{arg}}, @args; From ac1c213e62d8f3eedda10518a2967c89c44c5a5d Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Fri, 1 Jul 2016 05:19:27 -0400 Subject: [PATCH 214/310] package xcat-probe --- build-ubunturepo | 8 ++++- buildcore.sh | 4 +-- makerpm | 6 ++++ xCAT-probe/xCAT-probe.spec | 66 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 xCAT-probe/xCAT-probe.spec diff --git a/build-ubunturepo b/build-ubunturepo index 153b2f986..e9e2e854c 100755 --- a/build-ubunturepo +++ b/build-ubunturepo @@ -223,7 +223,7 @@ then if [ ! -d ../../$package_dir_name ];then mkdir -p "../../$package_dir_name" fi - packages="xCAT-client xCAT-genesis-scripts perl-xCAT xCAT-server xCAT xCATsn xCAT-test xCAT-buildkit xCAT-vlan xCAT-confluent" + packages="xCAT-client xCAT-genesis-scripts perl-xCAT xCAT-server xCAT xCATsn xCAT-test xCAT-buildkit xCAT-vlan xCAT-confluent xCAT-probe" target_archs=(amd64 ppc64el) for file in `echo $packages` do @@ -242,6 +242,12 @@ then cd $file dch -v $pkg_version -b -c debian/changelog $build_string if [ "$target_arch" = "all" ]; then + if [ $file_low = "xcat-probe" ]; then + CURDIR=$(pwd) + mkdir -p ${CURDIR}/xCAT-probe/lib/perl/xCAT/ + cp -f ${CURDIR}/perl-xCAT/xCAT/NetworkUtils.pm ${CURDIR}/xCAT-probe/lib/perl/xCAT/ + cp -f ${CURDIR}/perl-xCAT/xCAT/GlobalDef.pm ${CURDIR}/xCAT-probe/lib/perl/xCAT/ + fi dpkg-buildpackage -uc -us else dpkg-buildpackage -uc -us -a$target_arch diff --git a/buildcore.sh b/buildcore.sh index 13494774c..9f3d3aec0 100755 --- a/buildcore.sh +++ b/buildcore.sh @@ -67,7 +67,7 @@ if [ -z "$UP" ]; then fi # These are the rpms that should be built for each kind of xcat build -ALLBUILD="perl-xCAT xCAT-client xCAT-server xCAT-test xCAT-buildkit xCAT xCATsn xCAT-genesis-scripts xCAT-SoftLayer xCAT-vlan xCAT-confluent" +ALLBUILD="perl-xCAT xCAT-client xCAT-server xCAT-test xCAT-buildkit xCAT xCATsn xCAT-genesis-scripts xCAT-SoftLayer xCAT-vlan xCAT-confluent xCAT-probe" ZVMBUILD="perl-xCAT xCAT-server xCAT-UI" ZVMLINK="xCAT-client xCAT xCATsn" # xCAT and xCATsn have PCM specific configuration - conserver-xcat, syslinux-xcat @@ -288,7 +288,7 @@ if [ "$OSNAME" = "AIX" ]; then fi # Build the rest of the noarch rpms -for rpmname in xCAT-client xCAT-server xCAT-IBMhpc xCAT-rmc xCAT-UI xCAT-test xCAT-buildkit xCAT-SoftLayer xCAT-vlan xCAT-confluent; do +for rpmname in xCAT-client xCAT-server xCAT-IBMhpc xCAT-rmc xCAT-UI xCAT-test xCAT-buildkit xCAT-SoftLayer xCAT-vlan xCAT-confluent xCAT-probe; do if [[ " $EMBEDBUILD " != *\ $rpmname\ * ]]; then continue; fi if [ "$OSNAME" = "AIX" -a "$rpmname" = "xCAT-buildkit" ]; then continue; fi # do not build xCAT-buildkit on aix if [ "$OSNAME" = "AIX" -a "$rpmname" = "xCAT-SoftLayer" ]; then continue; fi # do not build xCAT-softlayer on aix diff --git a/makerpm b/makerpm index 3aae57418..b14bf907e 100755 --- a/makerpm +++ b/makerpm @@ -40,6 +40,12 @@ function makenoarch { fi fi fi + if [ $RPMNAME = "xCAT-probe" ]; then + CURDIR=$(pwd) + mkdir -p ${CURDIR}/xCAT-probe/lib/perl/xCAT/ + cp -f ${CURDIR}/perl-xCAT/xCAT/NetworkUtils.pm ${CURDIR}/xCAT-probe/lib/perl/xCAT/ + cp -f ${CURDIR}/perl-xCAT/xCAT/GlobalDef.pm ${CURDIR}/xCAT-probe/lib/perl/xCAT/ + fi tar --exclude .svn -czf $RPMROOT/SOURCES/$RPMNAME-$VER.tar.gz $RPMNAME rm -f $RPMROOT/SRPMS/$RPMNAME-$VER*rpm $RPMROOT/RPMS/noarch/$RPMNAME-$VER*rpm rpmbuild $QUIET -ta $RPMROOT/SOURCES/$RPMNAME-$VER.tar.gz diff --git a/xCAT-probe/xCAT-probe.spec b/xCAT-probe/xCAT-probe.spec new file mode 100644 index 000000000..be947916e --- /dev/null +++ b/xCAT-probe/xCAT-probe.spec @@ -0,0 +1,66 @@ +Summary: xCAT automated test tool +Name: xCAT-probe +Version: %(cat Version) +Release: snap%(date +"%Y%m%d%H%M") +Epoch: 4 +License: EPL +Group: Applications/System +Source: xCAT-probe-%(cat Version).tar.gz +Packager: IBM Corp. +Vendor: IBM Corp. +Distribution: %{?_distribution:%{_distribution}}%{!?_distribution:%{_vendor}} +Prefix: /opt/xcat +BuildRoot: /var/tmp/%{name}-%{version}-%{release}-root + +# AIX will build with an arch of "ppc" +%ifos linux +BuildArch: noarch +%endif + +Provides: xCAT-probe = %{version} + +%description +Provides a toolkits to help probe all the possible issues in xCAT + +%prep +%setup -q -n xCAT-probe +%build + +# Convert pods to man pages and html pages + +%install +# The install phase puts all of the files in the paths they should be in when the rpm is +# installed on a system. The RPM_BUILD_ROOT is a simulated root file system and usually +# has a value like: /var/tmp/xCAT-probe-2.0-snap200802270932-root +rm -rf $RPM_BUILD_ROOT + +mkdir -p $RPM_BUILD_ROOT/%{prefix}/bin +mkdir -p $RPM_BUILD_ROOT/%{prefix}/probe/ + +cp xcatprobe $RPM_BUILD_ROOT/%{prefix}/bin +chmod 755 $RPM_BUILD_ROOT/%{prefix}/bin/* + +cp -r subcmds $RPM_BUILD_ROOT/%{prefix}/probe/ +chmod 755 $RPM_BUILD_ROOT/%{prefix}/probe/subcmds/* + +cp -r lib $RPM_BUILD_ROOT/%{prefix}/probe/ +chmod 644 $RPM_BUILD_ROOT/%{prefix}/probe/lib/perl/* +chmod 644 $RPM_BUILD_ROOT/%{prefix}/probe/lib/perl/xCAT/* + +%clean +# This step does not happen until *after* the %files packaging below +rm -rf $RPM_BUILD_ROOT + +%files +%defattr(-,root,root) +#%doc LICENSE.html +# Just package everything that has been copied into RPM_BUILD_ROOT +%{prefix} + +%changelog +* Tue Sep 14 2010 - Airong Zheng +- "Create xCAT autotest package" + +%post + +%preun From 4baac6278c4bb728bcc86fdcc589f7514a12d19b Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Fri, 1 Jul 2016 05:20:08 -0400 Subject: [PATCH 215/310] package xcat-probe --- xCAT-probe/debian/changelog | 5 ++ xCAT-probe/debian/compat | 1 + xCAT-probe/debian/control | 11 +++++ xCAT-probe/debian/copyright | 88 +++++++++++++++++++++++++++++++++ xCAT-probe/debian/dirs | 2 + xCAT-probe/debian/install | 3 ++ xCAT-probe/debian/postinst | 39 +++++++++++++++ xCAT-probe/debian/rules | 75 ++++++++++++++++++++++++++++ xCAT-probe/debian/source/format | 1 + 9 files changed, 225 insertions(+) create mode 100644 xCAT-probe/debian/changelog create mode 100644 xCAT-probe/debian/compat create mode 100644 xCAT-probe/debian/control create mode 100644 xCAT-probe/debian/copyright create mode 100644 xCAT-probe/debian/dirs create mode 100644 xCAT-probe/debian/install create mode 100644 xCAT-probe/debian/postinst create mode 100755 xCAT-probe/debian/rules create mode 100644 xCAT-probe/debian/source/format diff --git a/xCAT-probe/debian/changelog b/xCAT-probe/debian/changelog new file mode 100644 index 000000000..7f9c4414a --- /dev/null +++ b/xCAT-probe/debian/changelog @@ -0,0 +1,5 @@ +xcat-probe (2.7) maverick; urgency=low + + * initial build + + -- tonetto Thu, 22 Sep 2011 19:42:58 -0300 diff --git a/xCAT-probe/debian/compat b/xCAT-probe/debian/compat new file mode 100644 index 000000000..7ed6ff82d --- /dev/null +++ b/xCAT-probe/debian/compat @@ -0,0 +1 @@ +5 diff --git a/xCAT-probe/debian/control b/xCAT-probe/debian/control new file mode 100644 index 000000000..e61da9c6c --- /dev/null +++ b/xCAT-probe/debian/control @@ -0,0 +1,11 @@ +Source: xcat-probe +Section: admin +Priority: extra +Maintainer: xCAT +Build-Depends: debhelper (>= 5) +Standards-Version: 3.7.2 + +Package: xcat-probe +Architecture: all +Depends: ${perl:Depends} +Description: Provides a toolkits to help probe all the possible issues in xCAT diff --git a/xCAT-probe/debian/copyright b/xCAT-probe/debian/copyright new file mode 100644 index 000000000..f61d34dfe --- /dev/null +++ b/xCAT-probe/debian/copyright @@ -0,0 +1,88 @@ +Eclipse Public License - v 1.0 + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and +b) in the case of each subsequent Contributor: + +i) changes to the Program, and + +ii) additions to the Program; + +where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. + +"Program" means the Contributions distributed in accordance with this Agreement. + +"Recipient" means anyone who receives the Program under this Agreement, including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form. + +b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. + +c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program. + +d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: + +a) it complies with the terms and conditions of this Agreement; and + +b) its license agreement: + +i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; + +ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; + +iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and + +iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. + +When the Program is made available in source code form: + +a) it must be made available under this Agreement; and + +b) a copy of this Agreement must be included with each copy of the Program. + +Contributors may not remove or alter any copyright notices contained within the Program. + +Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. + +Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. + + diff --git a/xCAT-probe/debian/dirs b/xCAT-probe/debian/dirs new file mode 100644 index 000000000..728459eec --- /dev/null +++ b/xCAT-probe/debian/dirs @@ -0,0 +1,2 @@ +opt/xcat/bin +opt/xcat/probe diff --git a/xCAT-probe/debian/install b/xCAT-probe/debian/install new file mode 100644 index 000000000..b51d5a3fb --- /dev/null +++ b/xCAT-probe/debian/install @@ -0,0 +1,3 @@ +xcatprobe opt/xcat/bin +subcmds opt/xcat/probe +lib opt/xcat/probe diff --git a/xCAT-probe/debian/postinst b/xCAT-probe/debian/postinst new file mode 100644 index 000000000..5ced18096 --- /dev/null +++ b/xCAT-probe/debian/postinst @@ -0,0 +1,39 @@ +#!/bin/sh +# postinst script for openmpi +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + configure) + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/xCAT-probe/debian/rules b/xCAT-probe/debian/rules new file mode 100755 index 000000000..cb48348a6 --- /dev/null +++ b/xCAT-probe/debian/rules @@ -0,0 +1,75 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +export DH_COMPAT=5 + + +build: + dh_testdir + pwd + +clean: + dh_testdir + dh_testroot + dh_clean -d + +install: + pwd + dh_testdir + dh_testroot + dh_installdirs + dh_install -X".svn" + dh_link + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: + pwd + export + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs +# dh_installexamples + dh_install -X".svn" + chmod 755 `pwd`/debian/xcat-probe/opt/xcat/bin/* + chmod 755 `pwd`/debian/xcat-probe/opt/xcat/probe/subcmds/* + chmod 644 `pwd`/debian/xcat-probe/opt/xcat/probe/lib/perl/* + chmod 644 `pwd`/debian/xcat-probe/opt/xcat/probe/lib/perl/xCAT/* +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_python +# dh_installinit +# dh_installcron +# dh_installinfo + dh_installman +# dh_link +# dh_strip + dh_compress +# dh_fixperms + dh_perl + dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/xCAT-probe/debian/source/format b/xCAT-probe/debian/source/format new file mode 100644 index 000000000..d3827e75a --- /dev/null +++ b/xCAT-probe/debian/source/format @@ -0,0 +1 @@ +1.0 From cc47d51ff67d59d31d4b099b03c8f3ead36d36a2 Mon Sep 17 00:00:00 2001 From: XuWei Date: Fri, 1 Jul 2016 03:59:23 -0400 Subject: [PATCH 216/310] add status powering-on for blade --- xCAT-server/lib/xcat/plugins/blade.pm | 53 ++++++--------------------- xCAT-server/lib/xcat/plugins/kvm.pm | 8 ++-- 2 files changed, 16 insertions(+), 45 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index ea413ff69..6fe41a86e 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -2330,10 +2330,13 @@ sub power { } my $old_stat=$stat; + my $newstat; + my %newnodestatus=(); if ($subcommand eq "softoff") { $validsub=1; $data = $session->set(new SNMP::Varbind([".".$powerchangeoid,$slot,2,'INTEGER'])); unless ($data) { return (1,$session->{ErrorStr}); } + $newstat = $::STATUS_POWERING_OFF; $stat = "softoff"; if ($old_stat eq "off") { $stat .= " $status_noop"; } } @@ -2341,12 +2344,14 @@ sub power { $validsub=1; $data = $session->set(new SNMP::Varbind([".".$powerchangeoid,$slot,0,'INTEGER'])); unless ($data) { return (1,$session->{ErrorStr}); } + $newstat = $::STATUS_POWERING_OFF; $stat = "off"; if ($old_stat eq "off") { $stat .= " $status_noop"; } } if ($subcommand eq "on" or ($subcommand eq "boot" and $stat eq "off")) { $data = $session->set(new SNMP::Varbind([".".$powerchangeoid,$slot,1,'INTEGER'])); unless ($data) { return (1,$session->{ErrorStr}); } + $newstat = $::STATUS_POWERING_ON; if ($subcommand eq "boot") { $stat .= " " . ($data ? "on" : "off"); } if ($subcommand eq "on") { $stat = ($data ? "on" : "off"); @@ -2355,11 +2360,17 @@ sub power { } elsif ($subcommand eq "reset" or ($subcommand eq "boot" and $stat eq "on")) { $data = $session->set(new SNMP::Varbind([".".$powerresetoid,$slot ,1,'INTEGER'])); unless ($data) { return (1,$session->{ErrorStr}); } + $newstat = $::STATUS_POWERING_ON; if ($subcommand eq "boot") { $stat = "on reset"; } else { $stat = "reset"; } } elsif (not $validsub) { return 1,"Unknown/Unsupported power command $subcommand"; } if ($session->{ErrorStr}) { return (1,$session->{ErrorStr}); } + if ($newstat) { + $newnodestatus{$newstat}=[$currnode]; + xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); + } + if ($stat) { return (0,$stat); } } @@ -5963,32 +5974,6 @@ sub dompa { } } #print "oldstatus:" . Dumper(\%oldnodestatus); - - #set the new status to the nodelist.status - my %newnodestatus=(); - my $newstat; - if (($args->[0] eq 'off') || ($args->[0] eq 'softoff')) { - my $newstat=$::STATUS_POWERING_OFF; - $newnodestatus{$newstat}=\@allnodes; - } else { - #get the current nodeset stat - if (@allnodes>0) { - my $nsh={}; - my ($ret, $msg)=xCAT::SvrUtils->getNodesetStates(\@allnodes, $nsh); - if (!$ret) { - foreach (keys %$nsh) { - my $newstat=xCAT_monitoring::monitorctrl->getNodeStatusFromNodesetState($_, "rpower"); - $newnodestatus{$newstat}=$nsh->{$_}; - } - } - } - } - - - #donot update node provision status (installing or netbooting) here - xCAT::Utils->filter_nostatusupdate(\%newnodestatus); - #print "newstatus" . Dumper(\%newnodestatus); - xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); } } if ($command eq "rvitals") { @@ -6054,22 +6039,6 @@ sub dompa { yield; } - if ($check) { - #print "allerrornodes=@allerrornodes\n"; - #revert the status back for there is no-op for the nodes - my %old=(); - foreach my $node (@allerrornodes) { - my $stat=$oldnodestatus{$node}; - if (exists($old{$stat})) { - my $pa=$old{$stat}; - push(@$pa, $node); - } - else { - $old{$stat}=[$node]; - } - } - xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%old, 1); - } verbose_message("SNMP session completed."); #my $msgtoparent=freeze(\@outhashes); # = XMLout(\%output,RootName => 'xcatresponse'); #print $out $msgtoparent; #$node.": $_\n"; diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index 52260c41b..dae497285 100755 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -3020,6 +3020,7 @@ sub power { } } elsif (not $dom->is_active()) { $dom->create(); + $newstat = $::STATUS_POWERING_ON; } else { $retstring .= "$status_noop"; } @@ -3072,9 +3073,10 @@ sub power { return (1, "Unsupported power directive '$subcommand'"); } } - - $newnodestatus{$newstat}=[$node]; - xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); + if ($newstat) { + $newnodestatus{$newstat}=[$node]; + xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); + } unless ($retstring =~ /reset/) { $retstring = $retstring . getpowstate($dom); From 4646631416e03a6b26a4629f052fa2ff777611e1 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Fri, 1 Jul 2016 11:17:38 -0400 Subject: [PATCH 217/310] Remove old version xCAT settings from rsyslog.conf file --- xCAT/postscripts/syslog | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/xCAT/postscripts/syslog b/xCAT/postscripts/syslog index d9ee73d0b..35889640b 100755 --- a/xCAT/postscripts/syslog +++ b/xCAT/postscripts/syslog @@ -36,6 +36,7 @@ isRsyslog=0 isC3=0 xCATSettingsSTART="xCAT settings START" xCATSettingsEND="xCAT settings END" +xCATSettingsOLD="xCAT settings" xCATSettingsInfo="Entries between the START and END lines will be replaced on the next xCAT install or update" #systemdEnabled=0 # pmatch determines if 1st argument string is matched by 2nd argument pattern @@ -90,6 +91,12 @@ config_Rsyslog_C3() cp -f $2 $2.XCATORIG fi + grep "$xCATSettingsOLD$" $conf_file 2>&1 1> /dev/null + if [ $? -eq 0 ]; then + #remove the older version syslog rule generated by xCAT + sed -i "/$xCATSettingsOLD/,+1 d" $2 + fi + grep "$xCATSettingsSTART" $conf_file 2>&1 1> /dev/null if [ $? -eq 0 ]; then #remove the previous syslog rule generated by xCAT @@ -164,7 +171,18 @@ config_rsyslog_V8() cp -f $conf_file $conf_file.XCATORIG fi - # check if already an entry by xCAT. If so, we need to remove it + # check if already an old entry by xCAT. If so, we need to remove it + grep "$xCATSettingsOLD$" $conf_file 2>&1 1> /dev/null + if [ $? -eq 0 ]; then + sed -i "/$xCATSettingsOLD/,+1 d" $conf_file + fi + + grep "$xCATSettingsOLD$" $remoteconf 2>&1 1> /dev/null + if [ $? -eq 0 ]; then + sed -i "/$xCATSettingsOLD/,+1 d" $remoteconf + fi + + # check if already a previous entry by xCAT. If so, we need to remove it grep "$xCATSettingsSTART" $conf_file 2>&1 1> /dev/null if [ $? -eq 0 ]; then sed -i "/$xCATSettingsSTART/,/$xCATSettingsEND/ d" $conf_file From 05c90d4c4709b43aa4f63c7171a69d9b779e964b Mon Sep 17 00:00:00 2001 From: immarvin Date: Sat, 2 Jul 2016 07:32:52 -0400 Subject: [PATCH 218/310] fix issue [Customer]initrd stuck in loop and fails to get rootimg.gz for stateless image. #921 @github;use /install/postscripts/updateflag.awk as the script to report status in diskless and diskful provision --- .../share/xcat/install/scripts/chroot.sles | 30 +++++------------ .../share/xcat/install/scripts/post.xcat | 16 ++++++--- .../share/xcat/install/scripts/pre.sles | 33 +++++-------------- .../share/xcat/install/scripts/scriptlib | 22 ------------- .../xcat/netboot/rh/dracut/xcat-updateflag | 24 -------------- .../netboot/rh/dracut_033/xcat-updateflag | 24 -------------- xCAT-server/share/xcat/netboot/rh/genimage | 8 ++--- .../netboot/sles/dracut_033/xcat-updateflag | 24 -------------- xCAT-server/share/xcat/netboot/sles/genimage | 8 ++--- 9 files changed, 35 insertions(+), 154 deletions(-) delete mode 100755 xCAT-server/share/xcat/netboot/rh/dracut/xcat-updateflag delete mode 100755 xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-updateflag delete mode 100755 xCAT-server/share/xcat/netboot/sles/dracut_033/xcat-updateflag diff --git a/xCAT-server/share/xcat/install/scripts/chroot.sles b/xCAT-server/share/xcat/install/scripts/chroot.sles index f7cb762cb..0e3d65c95 100644 --- a/xCAT-server/share/xcat/install/scripts/chroot.sles +++ b/xCAT-server/share/xcat/install/scripts/chroot.sles @@ -23,33 +23,19 @@ fi AWK=`find / -name awk | head -1` #old awk /mounts/instsys/bin/awk -f -cat >/tmp/updateflag.awk < 0) - print \$0 - - if(\$0 == "ready") - print "next" |& ns - if(\$0 == "done") - break - } - - close(ns) - - exit 0 -} +(cat >/tmp/updateflag.awk << 'EOF' +#INCLUDE:#TABLE:site:key=installdir:value#/postscripts/updateflag.awk# EOF +) >/tmp/updateflag.awk chmod 755 /tmp/updateflag.awk -/tmp/updateflag.awk + +/tmp/updateflag.awk $XCATDHOST $XCATDPORT + export PRINIC=#TABLEBLANKOKAY:noderes:THISNODE:primarynic# if [ "$PRINIC" == "mac" ] then diff --git a/xCAT-server/share/xcat/install/scripts/post.xcat b/xCAT-server/share/xcat/install/scripts/post.xcat index 7303b00df..baa5eb200 100755 --- a/xCAT-server/share/xcat/install/scripts/post.xcat +++ b/xCAT-server/share/xcat/install/scripts/post.xcat @@ -28,6 +28,12 @@ if [[ $TFTPDIR != /* ]]; then TFTPDIR="/"$TFTPDIR fi + +(cat << 'EOF' +#INCLUDE:#TABLE:site:key=installdir:value#/postscripts/updateflag.awk# +EOF +) >/tmp/updateflag + cd /tmp RAND=$(perl -e 'print int(rand(50)). "\n"') if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then @@ -38,7 +44,7 @@ sleep $RAND # Stop if no openssl to help the next bit if [ ! -x /usr/bin/openssl ]; then msgutil_r "$MASTER_IP" "debug" "/usr/bin/openssl does not exist, halt ..." "/var/log/xcat/xcat.log" - updateflag $MASTER $XCATIPORT "installstatus failed" + /tmp/updateflag $MASTER $XCATIPORT "installstatus failed" sleep 36500d fi @@ -75,14 +81,14 @@ fi # Stop if no wget to help the next bit if [ ! -x /usr/bin/wget ]; then msgutil_r "$MASTER_IP" "debug" "/usr/bin/wget does not exist, halt ..." "/var/log/xcat/xcat.log" - updateflag $MASTER $XCATIPORT "installstatus failed" + /tmp/updateflag $MASTER $XCATIPORT "installstatus failed" sleep 36500d fi wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -e robots=off -nH --cut-dirs=2 --reject "index.html*" --no-parent -t 20 -T 60 http://$MASTER_IP$INSTALLDIR/postscripts/ -P /xcatpost if [ "$?" != "0" ]; then msgutil_r "$MASTER_IP" "debug" "failed to download postscripts from http://$MASTER_IP$INSTALLDIR/postscripts/, halt ..." "/var/log/xcat/xcat.log" - updateflag $MASTER $XCATIPORT "installstatus failed" + /tmp/updateflag $MASTER $XCATIPORT "installstatus failed" sleep 36500d fi chmod -R +x `find /xcatpost/ -maxdepth 1 -print | grep -E -v '^(/xcatpost/|/xcatpost/_xcat|/xcatpost/_ssh|/xcatpost/ca|/xcatpost/hostkeys)$'` @@ -126,7 +132,7 @@ if [ ! -x /xcatpost/mypostscript ]; then # Stop if no getpostscript.awk to help the next bit if [ ! -x /xcatpost/getpostscript.awk ]; then msgutil_r "$MASTER_IP" "debug" "/xcatpost/getpostscript.awk does not exist, halt ..." "/var/log/xcat/xcat.log" - updateflag $MASTER $XCATIPORT "installstatus failed" + /tmp/updateflag $MASTER $XCATIPORT "installstatus failed" sleep 36500d fi /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//g' -e 's/&/\&/g' -e 's/"/"/g' -e "s/'/'/g" > /xcatpost/mypostscript @@ -227,7 +233,7 @@ fi chmod +x /xcatpost/mypostscript if [ ! -x /xcatpost/mypostscript ]; then msgutil_r "$MASTER_IP" "debug" "generate mypostscript file failure, halt ..." "/var/log/xcat/xcat.log" - updateflag $MASTER $XCATIPORT "installstatus failed" + /tmp/updateflag $MASTER $XCATIPORT "installstatus failed" sleep 36500d else if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then diff --git a/xCAT-server/share/xcat/install/scripts/pre.sles b/xCAT-server/share/xcat/install/scripts/pre.sles index f11ad0517..64115e6a5 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.sles +++ b/xCAT-server/share/xcat/install/scripts/pre.sles @@ -19,32 +19,15 @@ fi AWK=`find / -name awk | tail -1` #old awk /mounts/instsys/bin/awk -f -cat >/tmp/bar.awk < /tmp/bar.awk if [ ! -c /dev/vcs ]; then @@ -123,12 +106,12 @@ chmod 755 /tmp/foo.awk chmod 755 /tmp/bar.awk -/tmp/bar.awk "installmonitor" & +/tmp/bar.awk $XCATDHOST $XCATDPORT "installmonitor" & NODESTATUS=#TABLEBLANKOKAY:site:key=nodestatus:value# if [ -z "$NODESTATUS" ] || [ "$NODESTATUS" != "0" -a "$NODESTATUS" != "N" -a "$NODESTATUS" != "n" ]; then - /tmp/bar.awk "installstatus installing" & + /tmp/bar.awk $XCATDHOST $XCATDPORT "installstatus installing" & fi /tmp/foo.awk >/tmp/foo.log 2>&1 & diff --git a/xCAT-server/share/xcat/install/scripts/scriptlib b/xCAT-server/share/xcat/install/scripts/scriptlib index dd9b3e168..8471e74f4 100644 --- a/xCAT-server/share/xcat/install/scripts/scriptlib +++ b/xCAT-server/share/xcat/install/scripts/scriptlib @@ -38,25 +38,3 @@ declare -F msgutil &>/dev/null || function msgutil { msgutil_r "" "$@" } -declare -F updateflag &>/dev/null || function updateflag { - awk -v master="$1" -v port="$2" -v flag="$3" 'BEGIN{ - ns = "/inet/tcp/0/" master "/" port - while(1) { - if((ns |& getline) > 0) - print $0 | "logger -t xcat -p local4.info" - else { - print "Retrying flag update" | "logger -t xcat -p local4.info" - close(ns) - system("sleep 10") - } - - if($0 == "ready") - print flag |& ns - if($0 == "done") - break - } - close(ns) - exit 0 - }' - return 0 -} diff --git a/xCAT-server/share/xcat/netboot/rh/dracut/xcat-updateflag b/xCAT-server/share/xcat/netboot/rh/dracut/xcat-updateflag deleted file mode 100755 index 2f9ac3165..000000000 --- a/xCAT-server/share/xcat/netboot/rh/dracut/xcat-updateflag +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/awk -f -#script to feedback the node provision status to xcatd -BEGIN { - - xcatdhost = ARGV[1] - xcatiport = ARGV[2] - - - ns = "/inet/tcp/0/" xcatdhost "/" xcatiport - print "xCAT_xcatd" |& ns - - while(1) { - ns |& getline - - if($0 == "ready") - print ARGV[3] |& ns - if($0 == "done") - break - } - - close(ns) - - exit 0 -} diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-updateflag b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-updateflag deleted file mode 100755 index 2f9ac3165..000000000 --- a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-updateflag +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/awk -f -#script to feedback the node provision status to xcatd -BEGIN { - - xcatdhost = ARGV[1] - xcatiport = ARGV[2] - - - ns = "/inet/tcp/0/" xcatdhost "/" xcatiport - print "xCAT_xcatd" |& ns - - while(1) { - ns |& getline - - if($0 == "ready") - print ARGV[3] |& ns - if($0 == "done") - break - } - - close(ns) - - exit 0 -} diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index 746172726..5c4cb53f6 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -940,8 +940,8 @@ sub mkinitrd_dracut { $perm = (stat("$fullpath/$dracutdir/install.statelite"))[2]; chmod($perm&07777, "$dracutmpath/install"); - cp("$fullpath/$dracutdir/xcat-updateflag",$dracutmpath); - $perm = (stat("$fullpath/$dracutdir/xcat-updateflag"))[2]; + cp("$installroot/postscripts/updateflag.awk","$dracutmpath/xcat-updateflag"); + $perm = (stat("$installroot/postscripts/updateflag.awk"))[2]; chmod($perm&07777, "$dracutmpath/xcat-updateflag"); cp("$fullpath/$dracutdir/xcat-prepivot.sh",$dracutmpath); @@ -972,8 +972,8 @@ sub mkinitrd_dracut { $perm = (stat("$fullpath/$dracutdir/xcat-cmdline.sh"))[2]; chmod($perm&07777, "$dracutmpath/xcat-cmdline.sh"); - cp("$fullpath/$dracutdir/xcat-updateflag",$dracutmpath); - $perm = (stat("$fullpath/$dracutdir/xcat-updateflag"))[2]; + cp("$installroot/postscripts/updateflag.awk","$dracutmpath/xcat-updateflag"); + $perm = (stat("$installroot/postscripts/updateflag.awk"))[2]; chmod($perm&07777, "$dracutmpath/xcat-updateflag"); if ($prinic) { diff --git a/xCAT-server/share/xcat/netboot/sles/dracut_033/xcat-updateflag b/xCAT-server/share/xcat/netboot/sles/dracut_033/xcat-updateflag deleted file mode 100755 index 2f9ac3165..000000000 --- a/xCAT-server/share/xcat/netboot/sles/dracut_033/xcat-updateflag +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/awk -f -#script to feedback the node provision status to xcatd -BEGIN { - - xcatdhost = ARGV[1] - xcatiport = ARGV[2] - - - ns = "/inet/tcp/0/" xcatdhost "/" xcatiport - print "xCAT_xcatd" |& ns - - while(1) { - ns |& getline - - if($0 == "ready") - print ARGV[3] |& ns - if($0 == "done") - break - } - - close(ns) - - exit 0 -} diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index 24a780a4c..f8c22a91f 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -1010,8 +1010,8 @@ sub mkinitrd_dracut { $perm = (stat("$fullpath/$dracutdir/install.statelite"))[2]; chmod($perm&07777, "$dracutmpath/install"); - cp("$fullpath/$dracutdir/xcat-updateflag",$dracutmpath); - $perm = (stat("$fullpath/$dracutdir/xcat-updateflag"))[2]; + cp("$installroot/postscripts/updateflag.awk","$dracutmpath/xcat-updateflag"); + $perm = (stat("$installroot/postscripts/updateflag.awk"))[2]; chmod($perm&07777, "$dracutmpath/xcat-updateflag"); cp("$fullpath/$dracutdir/xcat-prepivot.sh",$dracutmpath); @@ -1042,8 +1042,8 @@ sub mkinitrd_dracut { $perm = (stat("$fullpath/$dracutdir/xcat-cmdline.sh"))[2]; chmod($perm&07777, "$dracutmpath/xcat-cmdline.sh"); - cp("$fullpath/$dracutdir/xcat-updateflag",$dracutmpath); - $perm = (stat("$fullpath/$dracutdir/xcat-updateflag"))[2]; + cp("$installroot/postscripts/updateflag.awk","$dracutmpath/xcat-updateflag"); + $perm = (stat("$installroot/postscripts/updateflag.awk"))[2]; chmod($perm&07777, "$dracutmpath/xcat-updateflag"); if ($prinic) { my $optspec; From 0a5007890aea437fd8dc29f2b1ac5de3aed216c4 Mon Sep 17 00:00:00 2001 From: ertaozh Date: Sun, 3 Jul 2016 22:43:17 -0400 Subject: [PATCH 219/310] add discid for centos 6.8 x86_64 --- perl-xCAT/xCAT/data/discinfo.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/perl-xCAT/xCAT/data/discinfo.pm b/perl-xCAT/xCAT/data/discinfo.pm index 1520f34e9..b7ac47691 100755 --- a/perl-xCAT/xCAT/data/discinfo.pm +++ b/perl-xCAT/xCAT/data/discinfo.pm @@ -19,6 +19,7 @@ require Exporter; "1362445555.957609" => "centos6.4",#x86_64 "1385726732.061157" => "centos6.5",#x86_64 "1438724467.511049" => "centos6.7",#x86_64 + "1463897259.552895" => "centos6.8",#x86_64 "1404489053.504589" => "centos7.0", "1427495138.035654" => "centos7.1", "1450147276.351714" => "centos7.2", #ppc64le From 40e2a50086c4a0a35c16e416f80ed5577657be58 Mon Sep 17 00:00:00 2001 From: immarvin Date: Sun, 3 Jul 2016 22:54:15 -0400 Subject: [PATCH 220/310] rename bar.awk to updateflag --- xCAT-server/share/xcat/install/scripts/pre.sles | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xCAT-server/share/xcat/install/scripts/pre.sles b/xCAT-server/share/xcat/install/scripts/pre.sles index 64115e6a5..cccf88a3c 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.sles +++ b/xCAT-server/share/xcat/install/scripts/pre.sles @@ -27,7 +27,7 @@ XCATDHOST="#XCATVAR:XCATMASTER#" cat << 'EOF' #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/updateflag.awk# EOF -) > /tmp/bar.awk +) > /tmp/updateflag if [ ! -c /dev/vcs ]; then @@ -103,15 +103,15 @@ BEGIN { EOF chmod 755 /tmp/foo.awk -chmod 755 /tmp/bar.awk +chmod 755 /tmp/updateflag -/tmp/bar.awk $XCATDHOST $XCATDPORT "installmonitor" & +/tmp/updateflag $XCATDHOST $XCATDPORT "installmonitor" & NODESTATUS=#TABLEBLANKOKAY:site:key=nodestatus:value# if [ -z "$NODESTATUS" ] || [ "$NODESTATUS" != "0" -a "$NODESTATUS" != "N" -a "$NODESTATUS" != "n" ]; then - /tmp/bar.awk $XCATDHOST $XCATDPORT "installstatus installing" & + /tmp/updateflag $XCATDHOST $XCATDPORT "installstatus installing" & fi /tmp/foo.awk >/tmp/foo.log 2>&1 & From 3286d4a78d5d93479a8b12687ef101a88b8a8601 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Sun, 3 Jul 2016 23:29:51 -0400 Subject: [PATCH 221/310] modify depending on comments --- build-ubunturepo | 4 ++++ makerpm | 6 ++++++ xCAT-probe/debian/changelog | 4 ++-- xCAT-probe/xCAT-probe.spec | 13 ++++++------- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/build-ubunturepo b/build-ubunturepo index e9e2e854c..5acce32fb 100755 --- a/build-ubunturepo +++ b/build-ubunturepo @@ -242,6 +242,10 @@ then cd $file dch -v $pkg_version -b -c debian/changelog $build_string if [ "$target_arch" = "all" ]; then + #xcat probe use some functions shipped by xCAT, for below reasons we need to copy files to xCAT-probe directory + #1 make xcat probe code to be self-contained + #2 don't maintain two files for each script + #3 symbolic link can't work during package if [ $file_low = "xcat-probe" ]; then CURDIR=$(pwd) mkdir -p ${CURDIR}/xCAT-probe/lib/perl/xCAT/ diff --git a/makerpm b/makerpm index b14bf907e..c3cd442df 100755 --- a/makerpm +++ b/makerpm @@ -40,12 +40,18 @@ function makenoarch { fi fi fi + + #xcat probe use some functions shipped by xCAT, for below reasons we need to copy files to xCAT-probe directory + #1 make xcat probe code to be self-contained + #2 don't maintain two files for each script + #3 symbolic link can't work during package if [ $RPMNAME = "xCAT-probe" ]; then CURDIR=$(pwd) mkdir -p ${CURDIR}/xCAT-probe/lib/perl/xCAT/ cp -f ${CURDIR}/perl-xCAT/xCAT/NetworkUtils.pm ${CURDIR}/xCAT-probe/lib/perl/xCAT/ cp -f ${CURDIR}/perl-xCAT/xCAT/GlobalDef.pm ${CURDIR}/xCAT-probe/lib/perl/xCAT/ fi + tar --exclude .svn -czf $RPMROOT/SOURCES/$RPMNAME-$VER.tar.gz $RPMNAME rm -f $RPMROOT/SRPMS/$RPMNAME-$VER*rpm $RPMROOT/RPMS/noarch/$RPMNAME-$VER*rpm rpmbuild $QUIET -ta $RPMROOT/SOURCES/$RPMNAME-$VER.tar.gz diff --git a/xCAT-probe/debian/changelog b/xCAT-probe/debian/changelog index 7f9c4414a..fd4ac5c3d 100644 --- a/xCAT-probe/debian/changelog +++ b/xCAT-probe/debian/changelog @@ -1,5 +1,5 @@ -xcat-probe (2.7) maverick; urgency=low +xcat-probe (2.12) xcat; urgency=low * initial build - -- tonetto Thu, 22 Sep 2011 19:42:58 -0300 + -- huweihua Fri, 1 Jul 2016 19:42:58 -0400 diff --git a/xCAT-probe/xCAT-probe.spec b/xCAT-probe/xCAT-probe.spec index be947916e..8c5490ae8 100644 --- a/xCAT-probe/xCAT-probe.spec +++ b/xCAT-probe/xCAT-probe.spec @@ -1,4 +1,4 @@ -Summary: xCAT automated test tool +Summary: xCAT diagnostic tool Name: xCAT-probe Version: %(cat Version) Release: snap%(date +"%Y%m%d%H%M") @@ -12,7 +12,6 @@ Distribution: %{?_distribution:%{_distribution}}%{!?_distribution:%{_vendor}} Prefix: /opt/xcat BuildRoot: /var/tmp/%{name}-%{version}-%{release}-root -# AIX will build with an arch of "ppc" %ifos linux BuildArch: noarch %endif @@ -20,7 +19,7 @@ BuildArch: noarch Provides: xCAT-probe = %{version} %description -Provides a toolkits to help probe all the possible issues in xCAT +CAT-probe provides a toolkits to probe potential issues with the xCAT cluster. %prep %setup -q -n xCAT-probe @@ -44,8 +43,8 @@ cp -r subcmds $RPM_BUILD_ROOT/%{prefix}/probe/ chmod 755 $RPM_BUILD_ROOT/%{prefix}/probe/subcmds/* cp -r lib $RPM_BUILD_ROOT/%{prefix}/probe/ -chmod 644 $RPM_BUILD_ROOT/%{prefix}/probe/lib/perl/* -chmod 644 $RPM_BUILD_ROOT/%{prefix}/probe/lib/perl/xCAT/* +chmod -R 644 $RPM_BUILD_ROOT/%{prefix}/probe/lib/perl/ +chmod -R 644 $RPM_BUILD_ROOT/%{prefix}/probe/lib/perl/xCAT/ %clean # This step does not happen until *after* the %files packaging below @@ -58,8 +57,8 @@ rm -rf $RPM_BUILD_ROOT %{prefix} %changelog -* Tue Sep 14 2010 - Airong Zheng -- "Create xCAT autotest package" +* Fri Jul 1 2016 - huweihu +- "Create xCAT probe package" %post From 60d988b9d43455898c2600091dcd3eabdc4e885b Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Mon, 4 Jul 2016 13:06:19 +0800 Subject: [PATCH 222/310] Fix issue caused by pull request #1400. Add remote URL as Ubuntu repo properly. --- xCAT-server/share/xcat/tools/go-xcat | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index d1c5d7cb6..17f689f65 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -736,7 +736,8 @@ function add_repo_by_url_yum_or_zypper() enabled=1 gpgcheck=0 EOF - url="${tmp}" + add_repo_by_file "${tmp}" "${repo_id}" + return "$?" ;; esac ;; @@ -804,7 +805,8 @@ function add_repo_by_url_apt() *) # assume it is the base url of the repo tmp="${TMP_DIR}/tmp_repo.list" echo "deb [arch=$(dpkg --print-architecture)] ${url} ${codename} main" >"${tmp}" - url="${tmp}" + add_repo_by_file_apt "${tmp}" "${repo_id}" + return "$?" ;; esac ;; From de8bc849acb756324ef2b639325d1a0ff5f6d5f0 Mon Sep 17 00:00:00 2001 From: XuWei Date: Thu, 30 Jun 2016 21:47:32 -0400 Subject: [PATCH 223/310] xCAT probe discovery dhcp dynamic check --- xCAT-probe/subcmds/discovery | 120 ++++++++++++++++++----------------- 1 file changed, 63 insertions(+), 57 deletions(-) diff --git a/xCAT-probe/subcmds/discovery b/xCAT-probe/subcmds/discovery index 8e037b96d..b8ab90c5b 100755 --- a/xCAT-probe/subcmds/discovery +++ b/xCAT-probe/subcmds/discovery @@ -273,8 +273,8 @@ sub check_genesis_file { 1. check if there are dynamic range for specific networks defineded in dhcp conf file 2. check if these specific networks have corresponding genesis configuration Arguments: - networks: A Comma separated list of networks. Every network is combined by network address and mask(i.e. network/mask). - For example: 10.0.0.0/255.0.0.0,50.1.0.0/255.255.0.0 + networks: Array of networks. Every network is combined by network address and mask(i.e. network/mask). + For example: (10.0.0.0/255.0.0.0, 50.1.0.0/255.255.0.0) Returns: 0 : pass 1 : failed @@ -285,71 +285,77 @@ sub dhcp_dynamic_range_check { my $nets = shift; my $rst = 0; - my $dhcpconfig = "/etc/dhcp/dhcpd.conf"; - my $os = probe_utils->get_os(); + my $dhcpconfig; + if (-e "/etc/dhcp/dhcpd.conf"){ + $dhcpconfig = "/etc/dhcp/dhcpd.conf"; + } elsif (-e "/etc/dhcp3/dhcpd.conf"){ + $dhcpconfig = "/etc/dhcp3/dhcpd.conf"; + } - if ($os =~ "unknown") { - probe_utils->send_msg("$output", "d", "The OS is not supported.") if ($verbose); + unless ($dhcpconfig) { + probe_utils->send_msg("$output", "d", "Cannot find the dhcpd.conf file.") if ($verbose); return 1; - } elsif ($os =~ "ubuntu") { - if (! -e "/etc/dhcp") { - $dhcpconfig = "/etc/dhcp3/dhcpd.conf"; - } } my $config_line; - my $net_ip; - my $net_mask; - my $is_match; + my $subnet; my $dynamic_range; - my $net_file; + my %subnet_hash; + + unless (open (FILE, $dhcpconfig)) { + probe_utils->send_msg("$output", "d", "Cannot open file $dhcpconfig.") if ($verbose); + ($net_ip, $net_mask) = split ('/', $net); + return 1; + } + + while ($config_line = ) { + chomp($config_line); + $config_line =~ s/^\s+|\s+$//g; + + if ($config_line =~ /^subnet\s+(\d+\.\d+\.\d+\.\d+)\s+netmask\s+(\d+\.\d+\.\d+\.\d+)\s+/) { + $subnet = "$1/$2"; + $subnet_hash{$subnet} = "unknown"; + } + if ($config_line =~ /subnet_end/) { + $subnet_hash{$subnet} = $dynamic_range if ($dynamic_range); + $subnet = ""; + $dynamic_range = ""; + } + if ($config_line =~ /^range dynamic-bootp (\d+.\d+.\d+.\d+) (\d+.\d+.\d+.\d+)/) { + $dynamic_range = "$1-$2"; + } + } + + my $net_ip; + my $netmask; + my $netfile; + my $net_cdir; my $arch = `uname -i`; chomp($arch); - my $tftpdir = `tabdump site | grep "tftpdir" | awk -F "," '{print \$2}'`; + my $tftpdir = `lsdef -t site -i tftpdir -c | awk -F "=" '{print \$2}'`; chomp($tftpdir); - $tftpdir =~ s/"//g; + unless ($tftpdir) { + $tftpdir = "/tftpboot"; + } + + foreach my $net (@$nets){ + + if ( !exists($subnet_hash{$net})) { + probe_utils->send_msg("$output", "d", "The net $net is not matched.") if ($verbose); + $rst = 1; + next; + } + + if ($subnet_hash{$net} ne "unknown") { + probe_utils->send_msg("$output", "d", "Dynamic range for net $net is $subnet_hash{$net}.") if ($verbose); + } else { + probe_utils->send_msg("$output", "d", "Dynamic range for net $net did not be configured.") if ($verbose); + $rst = 1; + next; + } - foreach $net (@$nets){ ($net_ip, $net_mask) = split ('/', $net); - $net_str = "subnet $net_ip netmask $net_mask"; - - $is_match = 0; - $dynamic_range = ""; - - unless (open (FILE, $dhcpconfig)) { - probe_utils->send_msg("$output", "d", "Cannot open file $dhcpconfig.") if ($verbose); - return 1; - } - - while ($config_line = ) { - chomp($config_line); - $config_line =~ s/^\s+|\s+$//g; - - if ($config_line =~ /^$net_str/) { - $is_match = 1; - probe_utils->send_msg("$output", "d", "The net $net is matched.") if ($verbose); - } - - if ($config_line =~ /subnet_end/) { - if ($is_match eq 0) { - probe_utils->send_msg("$output", "d", "There is no subnet match net $net.") if ($verbose); - $rst = 1; - next; - } - unless ($dynamic_range) { - probe_utils->send_msg("$output", "d", "Dynamic range for net $net did not be configured.") if ($verbose); - $rst = 1; - } - } - - if (($config_line =~ /^range dynamic-bootp/) and ($is_match eq 1)) { - my @range_tmp = split(' ', $config_line); - $dynamic_range = "$range_tmp[2]-$range_tmp[3]"; - probe_utils->send_msg("$output", "d", "Dynamic range for net $net is $dynamic_range.") if ($verbose); - } - } - - my $net_cdir = xCAT::NetworkUtils::formatNetmask($net_mask, 0, 1); + $net_cdir = xCAT::NetworkUtils::formatNetmask($net_mask, 0, 1); if ($arch =~ /ppc64/i) { $net_file = "$tftpdir/pxelinux.cfg/p/$net_ip"."_$net_cdir"; } else { @@ -1081,7 +1087,7 @@ if (!$no_pre_check) { $rst = do_pre_check(); exit 1 if ($rst); } -exit; + $rst = do_monitor(); exit $rst; From 42d3deea44e3809b029210b2dca4fe3dd2c51da0 Mon Sep 17 00:00:00 2001 From: ertaozh Date: Mon, 4 Jul 2016 02:23:41 -0400 Subject: [PATCH 224/310] fix issue 1462: bmcsetup hang after commencing transmit of discovery packets --- xCAT-server/lib/xcat/plugins/blade.pm | 2 +- xCAT-server/lib/xcat/plugins/hpblade.pm | 2 +- xCAT-server/lib/xcat/plugins/profilednodes.pm | 2 +- xCAT-server/lib/xcat/plugins/seqdiscovery.pm | 2 +- xCAT-server/lib/xcat/plugins/switch.pm | 2 +- xCAT-server/lib/xcat/plugins/typemtms.pm | 2 +- xCAT-server/lib/xcat/plugins/zzzdiscovery.pm | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index 6fe41a86e..088bd09ac 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -4370,7 +4370,7 @@ sub process_request { } } if ($request->{command}->[0] eq "findme") { - if (defined($request->{discoverymethod}) and defined($request->{discoverymethod}->[0])) { + if (defined($request->{discoverymethod}) and defined($request->{discoverymethod}->[0]) and ($request->{discoverymethod}->[0] ne 'undef')) { # The findme request had been processed by other module, just return return; } diff --git a/xCAT-server/lib/xcat/plugins/hpblade.pm b/xCAT-server/lib/xcat/plugins/hpblade.pm index 6328f8b95..e6cd569ff 100755 --- a/xCAT-server/lib/xcat/plugins/hpblade.pm +++ b/xCAT-server/lib/xcat/plugins/hpblade.pm @@ -685,7 +685,7 @@ sub process_request { } } if ($request->{command}->[0] eq "findme") { - if (defined($request->{discoverymethod}) and defined($request->{discoverymethod}->[0])) { + if (defined($request->{discoverymethod}) and defined($request->{discoverymethod}->[0]) and ($request->{discoverymethod}->[0] ne 'undef')) { # The findme request had been processed by other module, just return return; } diff --git a/xCAT-server/lib/xcat/plugins/profilednodes.pm b/xCAT-server/lib/xcat/plugins/profilednodes.pm index 242216f82..54ca1f3ca 100644 --- a/xCAT-server/lib/xcat/plugins/profilednodes.pm +++ b/xCAT-server/lib/xcat/plugins/profilednodes.pm @@ -1816,7 +1816,7 @@ Usage: #------------------------------------------------------- sub findme{ - if (defined($request->{discoverymethod}) and defined($request->{discoverymethod}->[0])) { + if (defined($request->{discoverymethod}) and defined($request->{discoverymethod}->[0]) and ($request->{discoverymethod}->[0] ne 'undef')) { # The findme request had been processed by other module, just return return; } diff --git a/xCAT-server/lib/xcat/plugins/seqdiscovery.pm b/xCAT-server/lib/xcat/plugins/seqdiscovery.pm index 87d1d5281..96735ecf2 100755 --- a/xCAT-server/lib/xcat/plugins/seqdiscovery.pm +++ b/xCAT-server/lib/xcat/plugins/seqdiscovery.pm @@ -54,7 +54,7 @@ sub findme { my @SEQdiscover = xCAT::TableUtils->get_site_attribute("__SEQDiscover"); my @PCMdiscover = xCAT::TableUtils->get_site_attribute("__PCMDiscover"); - if (defined($request->{discoverymethod}) and defined($request->{discoverymethod}->[0])) { + if (defined($request->{discoverymethod}) and defined($request->{discoverymethod}->[0]) and ($request->{discoverymethod}->[0] ne 'undef')) { # The findme request had been processed by other module, just return return; } diff --git a/xCAT-server/lib/xcat/plugins/switch.pm b/xCAT-server/lib/xcat/plugins/switch.pm index 12024e6d1..c23543255 100644 --- a/xCAT-server/lib/xcat/plugins/switch.pm +++ b/xCAT-server/lib/xcat/plugins/switch.pm @@ -268,7 +268,7 @@ sub process_request { } return; } elsif ($req->{command}->[0] eq 'findme') { - if (defined($req->{discoverymethod}) and defined($req->{discoverymethod}->[0])) { + if (defined($req->{discoverymethod}) and defined($req->{discoverymethod}->[0]) and ($req->{discoverymethod}->[0] ne 'undef')) { # The findme request had been processed by other module, just return return; } diff --git a/xCAT-server/lib/xcat/plugins/typemtms.pm b/xCAT-server/lib/xcat/plugins/typemtms.pm index 53e5cc29d..8a9b350f4 100644 --- a/xCAT-server/lib/xcat/plugins/typemtms.pm +++ b/xCAT-server/lib/xcat/plugins/typemtms.pm @@ -57,7 +57,7 @@ sub process_request { my $cb = shift; my $doreq = shift; if ($req->{command}->[0] eq 'findme') { - if (defined($req->{discoverymethod}) and defined($req->{discoverymethod}->[0])) { + if (defined($req->{discoverymethod}) and defined($req->{discoverymethod}->[0]) and ($req->{discoverymethod}->[0] ne 'undef')) { # The findme request had been processed by other module, just return return; } diff --git a/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm b/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm index 643b178c8..a39f2344f 100644 --- a/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm +++ b/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm @@ -18,7 +18,7 @@ sub process_request { my $doreq = shift; if ($req->{command}->[0] eq 'findme') { xCAT::MsgUtils->message("S", "xcat.discovery.zzzdiscovery: ($req->{mtm}->[0]*$req->{serial}->[0]) Finish to process the discovery request"); - if (!defined($req->{discoverymethod}) or !defined($req->{discoverymethod}->[0])) { + if (!defined($req->{discoverymethod}) or !defined($req->{discoverymethod}->[0]) or ($req->{discoverymethod}->[0] eq 'undef')) { my $rsp = {}; $rsp->{error}->[0] = "The discovery request can not be processed"; $cb->($rsp); From 547a82d46417a02a5970d11e00fcf0d9ad60a7e2 Mon Sep 17 00:00:00 2001 From: immarvin Date: Sat, 2 Jul 2016 22:52:32 -0400 Subject: [PATCH 225/310] fix [DEV] kernel parameters 'console=tty0 console=ttyS0' are not passed to the installed Ubuntu 16.04 LTS node #731@github;enable bootup information display on console during ubuntu 16.04 reboot --- xCAT-server/share/xcat/install/scripts/post.xcat | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/xCAT-server/share/xcat/install/scripts/post.xcat b/xCAT-server/share/xcat/install/scripts/post.xcat index baa5eb200..6e573c979 100755 --- a/xCAT-server/share/xcat/install/scripts/post.xcat +++ b/xCAT-server/share/xcat/install/scripts/post.xcat @@ -385,6 +385,16 @@ if [[ $OSVER == ubuntu* ]]; then elif [[ -r /boot/grub/grub.cfg ]] ; then update-grub fi + + #print the kernel messages and service start messages with systemd on the console during system bootup + [ -f /etc/default/grub ] && sed -i -e '/GRUB_CMDLINE_LINUX_DEFAULT=/s/quiet//;s/splash//' -e '/#GRUB_TERMINAL=/s/#//' -e 's/#GRUB_GFXMODE=.*/GRUB_GFXMODE=text/' /etc/default/grub && update-grub + + if echo "$ARCH" | grep -i 'x86_64'; then + #grab the install-time console configuration from /proc/cmdline inside os installer + CONSOLECFG=$(awk 'BEGIN{RS="[ \n]" ;ORS=" "} $0 ~ /^console=/{print $0}' /proc/cmdline) + #if the console configuration is not applied to the grub configuration,apply it + cat /boot/grub/grub.cfg |grep "$CONSOLECFG" >/dev/null 2>&1 || ([ -f /etc/default/grub ] && sed -i -e "/GRUB_CMDLINE_LINUX_DEFAULT=/s/=\"/=\" $CONSOLECFG /" /etc/default/grub && update-grub) + fi if echo "$ARCH" | grep -i 'ppc64'; then if [ -z "$CONSOLEPORT" ] ; then export CONSOLEPORT=0 From 84a1793a593baded6d6ed7f7978ab89dc86cd13c Mon Sep 17 00:00:00 2001 From: XuWei Date: Mon, 4 Jul 2016 02:16:32 -0400 Subject: [PATCH 226/310] xcatprobe osdeploy for monitoring os provision --- xCAT-probe/subcmds/osdeploy | 390 ++++++++++++++++++++++++++++++++++++ 1 file changed, 390 insertions(+) create mode 100755 xCAT-probe/subcmds/osdeploy diff --git a/xCAT-probe/subcmds/osdeploy b/xCAT-probe/subcmds/osdeploy new file mode 100755 index 000000000..57b0f8470 --- /dev/null +++ b/xCAT-probe/subcmds/osdeploy @@ -0,0 +1,390 @@ +#! /usr/bin/perl +# IBM(c) 2016 EPL license http://www.eclipse.org/legal/epl-v10.html + +BEGIN { $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; } + +use lib "$::XCATROOT/probe/lib/perl"; + +use probe_utils; +use xCAT::NetworkUtils; +use File::Basename; +use IO::Select; +use Getopt::Long qw(:config no_ignore_case); + +my $program_name = basename("$0"); +my $help; +my $test; +my $output = "stdout"; +my $verbose = 0; +my $rst = 0; +my $noderange; +my %rawdata; +my %ipnodemap; +my %macmap; +my $terminal = 0; +my %monitor_nodes; + +$::USAGE = "Usage: + $program_name -h + $program_name -T + $program_name [-V] + $program_name -n + +Description: + Do probe for os provision process, realtime monitor of os provision process. + +Options: + -h : Get usage information of $program_name + -T : To verify if $program_name can work, reserve option for probe framework + -V : Output more information for debug + -n : The range of monitored node. +"; + +sub check_noderange{ + my $node_range = shift; + my @cmdoutput = `lsdef $node_range 2>&1`; + my $rst = 0; + my $currentnode = ""; + my %nodecheckrst; + my $ip; + + foreach (@cmdoutput) { + chomp($_); + $_ =~ s/^\s+|\s+$//g; + if ($_ =~ /^Error: Could not find an object named '(\w+)' .+/i) { + $currentnode = $1; + $nodecheckrst{$currentnode}{"error"} = "Could not find node definition"; + $rst = 1; + } elsif ($_ =~ /^\s*Object name: (\w+)/i) { + $monitor_nodes{$1} = 0; + $currentnode = $1; + } elsif ($_ =~ /^ip=(.+)/i) { + $ip = $1; + } elsif ($_ =~ /^mac=(.+)\|(.+)!\*NOIP\*/i) { + $macmap{$1}{"ip"} = $ip; + $macmap{$2}{"ip"} = $ip; + $macmap{$1}{"node"} = $currentnode; + $macmap{$2}{"node"} = $currentnode; + } elsif ($_ =~ /^mac=(.+)\|(.+)/i) { + $macmap{$1}{"ip"} = $ip; + $macmap{$2}{"ip"} = $ip; + $macmap{$1}{"node"} = $currentnode; + $macmap{$2}{"node"} = $currentnode; + } elsif ($_ =~ /^mac=(.+)/i) { + $macmap{$1}{"ip"} = $ip; + $macmap{$1}{"node"} = $currentnode; + } + } + + foreach my $node (keys %nodecheckrst) { + probe_utils->send_msg("$output", "d", "$node : $nodecheckrst{$node}{error}") if(exists($nodecheckrst{$node}{error})); + } + return $rst; +} + +sub handle_dhcp_msg { + my $msg = shift; + + if ($msg !~ /unknown lease/ && $msg !~ /ignored/ && $msg =~ /.+DHCPREQUEST\s+for\s+(.+)\s\((.+)\)\s+from\s+(.+)\s+via\s+(.+)/) { + my $ip = $1; + my $server = $2; + my $mac = $3; + my $nic = $4; + my $record = "Receive DHCPREQUEST from $mac for $ip via $nic"; + + if (exists $macmap{$mac}) { + my $node = $macmap{$mac}{"node"}; + probe_utils->send_msg("$output", "d", "$record"); + push(@{ $rawdata{$node}{"history"} }, $record); + + if ($macmap{$mac}{"ip"} != $ip) { + my $warn_msg = "The ip of $mac from DHCP $ip is different with definition $macmap{$mac}{'ip'}."; + probe_utils->send_msg("$output", "w", "$warn_msg"); + if (exists($rawdata{$node})) { + push(@{ $rawdata{$node}{"history"} }, $warn_msg); + } + } + } + } elsif ($msg =~ /.+DHCPACK\s+on\s+(.+)\s+to\s+(.+)\s+via\s+(.+)/) { + my $ip = $1; + my $mac = $2; + my $nic = $3; + my $record = "Send DHCPACK on $ip back to $mac via $nic"; + + if (exists $macmap{$mac}) { + my $node = $macmap{$mac}{"node"}; + if (exists($rawdata{$node})) { + probe_utils->send_msg("$output", "d", "$record"); + push(@{ $rawdata{$node}{"history"} }, $record); + $ipnodemap{$ip} = $node; + } + } + } + return 0; +} + +sub handle_http_msg { + my $msg = shift; + if ($msg =~ /(\d+\.\d+.\d+.\d+)\s.+GET\s+(.+)\s+HTTP.+/) { + my $ip = $1; + my $file = $2; + my $record = "Via HTTP $ip download $file"; + + if (exists($rawdata{"$ipnodemap{$ip}"})) { + probe_utils->send_msg("$output", "d", "$record"); + push(@{ $rawdata{ $ipnodemap{$ip} }{"history"} }, $record); + } + } + return 0; +} + +sub handle_cluster_msg { + my $line = shift; + my $sender = ""; + my $node = ""; + my $msg; + my $status; + + if ($line =~ /.+\d+:\d+:\d+\s+(.+)\s+(xcat.+)/i) { + $sender = $1; + $msg = $2; + + if (!xCAT::NetworkUtils->isIpaddr($sender)) { + $node = $sender; + } else { + $node = $ipnodemap{$sender}; + } + if ($node ne "" && exists($rawdata{$node})) { + my $record = "Recv from $node : $msg"; + probe_utils->send_msg("$output", "d", "$record"); + push(@{ $rawdata{ $node }{"history"} }, $record); + } + } + + if ($line =~ /.+\s+xcat:\s+(.+)\s+status:\s+(.+)\s+statustime:\s(.+)/) { + $node = $1; + $status = $2; + + if (exists($rawdata{$node})) { + my $record = "Recv from $node : xcat: status is $status"; + probe_utils->send_msg("$output", "d", "$record"); + push(@{ $rawdata{ $node }{"history"} }, $record); + } + + if (exists($rawdata{$node}) and ($status eq "booted")) { + $monitor_nodes{$node} = 1 if (defined($monitor_nodes{$node})); + probe_utils->send_msg("$output", "o", "Node $node has finished it's os provision process"); + } + } + return 0; +} + +sub all_monitor_node_done { + my $done = 1; + foreach my $node (keys %monitor_nodes) { + if ($monitor_nodes{$node} == 0) { + $done = 0; + last; + } + } + + return $done; +} + +sub dump_history { + + my $title = " +============================================================= += The summary of os provision: +============================================================= +"; + print "$title\n"; + + foreach $node (keys %rawdata) { + my $line_num = 0; + my $http_num = 0; + my $length_http; + for (my $i = @{ $rawdata{$node}{"history"} }; $i >=0; $i--) { + if (${ $rawdata{$node}{"history"} }[$i] =~ /Via HTTP/) { + $length_http = $i; + last; + } + } + foreach my $line (@{ $rawdata{$node}{"history"} }) { + if ($line =~ /Via HTTP/) + { + if (($http_num <= 4) or ($length_http - $line_num <= 4)){ + probe_utils->send_msg("$output", "d", "\t$line"); + } else { + probe_utils->send_msg("$output", "d", "\t......") if ($http_num ==5); + } + $http_num++; + } else { + probe_utils->send_msg("$output", "d", "\t$line"); + } + $line_num++; + } + } +} + +sub do_monitor{ + $SIG{TERM} = $SIG{INT} = sub { + $terminal = 1; + }; + + my $msg = "All pre_defined nodes are valid"; + my $rc = check_noderange($noderange); + if ($rc) { + probe_utils->send_msg("$output", "f", $msg); + $rst = 1; + unless (%monitor_nodes) { + return $rst; + } + } else { + probe_utils->send_msg("$output", "o", $msg); + } + + if (!$nics) { + my $masteripinsite = `tabdump site | awk -F',' '/master/ { gsub(/"/, "", \$2) ; print \$2 }'`; + chomp($masteripinsite); + $nics = `ip addr |grep -B2 $masteripinsite|awk -F" " '/mtu/{gsub(/:/,"",\$2); print \$2}'`; + chomp($nics); + if (!$nics) { + probe_utils->send_msg("$output", "f", "The value of master in site table is $masteripinsite, can't get corresponding network interface"); + return 1; + } + } + + my $rst = 0; + my $startline = "------------------------------------------------------------- +Start to capture every message during os provision process...... +------------------------------------------------------------- +"; + + probe_utils->send_msg("$output", "d", "$startline"); + + my $varlogmsg = "/var/log/messages"; + my $clusterlog = "/var/log/xcat/cluster.log"; + + my $httplog; + if (-e "/var/log/httpd/access_log") { + $httplog = "/var/log/httpd/access_log"; + } elsif (-e "/var/log/apache2/access_log") { + $httplog = "/var/log/apache2/access_log"; + } elsif (-e "/var/log/apache2/access.log") { + $httplog = "/var/log/apache2/access.log"; + } + + my $varlogpid; + my $clusterpid; + my $httppid; + + if (!($varlogpid = open(VARLOGMSGFILE, "tail -f $varlogmsg 2>&1 |"))) { + probe_utils->send_msg("$output", "f", "Can't open $varlogmsg to get logs"); + $rst = 1; + last; + } + if (!($clusterpid = open(CLUSTERLOGFILE, "tail -f $clusterlog 2>&1 |"))) { + probe_utils->send_msg("$output", "f", "Can't open $clusterlog to get logs"); + $rst = 1; + last; + } + if (!($httppid = open(HTTPLOGFILE, "tail -f $httplog 2>&1 |"))) { + probe_utils->send_msg("$output", "f", "Can't open $httplog to get logs"); + $rst = 1; + last; + } + + my $select = new IO::Select; + $select->add(\*VARLOGMSGFILE); + $select->add(\*CLUSTERLOGFILE); + $select->add(\*HTTPLOGFILE); + $| = 1; + + my $line = ""; + my @hdls; + my $hdl; + my $oldlines = 10; + my $varlogmsgcnt = 0; + my $clusterlogcnt = 0; + my $httplogcnt = 0; + + for (; ;){ + if (@hdls = $select->can_read(0)) { + foreach $hdl (@hdls) { + if ($hdl == \*VARLOGMSGFILE) { + chomp($line = ); + ++$varlogmsgcnt; + last if ($varlogmsgcnt <= $oldlines); + my @tmp = split(/\s+/, $line); + if ($tmp[4] =~ /dhcpd:/i && $line =~ /$nics/) { + handle_dhcp_msg("$line"); + } + } elsif ($hdl == \*CLUSTERLOGFILE) { + chomp($line = ); + ++$clusterlogcnt; + last if ($clusterlogcnt <= $oldlines); + handle_cluster_msg("$line"); + } elsif ($hdl == \*HTTPLOGFILE) { + chomp($line = ); + ++$httplogcnt; + last if ($httplogcnt <= $oldlines); + handle_http_msg("$line"); + } + } + } + + if ($terminal || (%monitor_nodes && all_monitor_node_done())) { + if ($terminal) { + probe_utils->send_msg("$output", "d", "Get INT or TERM signal from STDIN"); + } else { + probe_utils->send_msg("$output", "o", "All nodes need to monitor have finished os provision process"); + } + last; + } sleep 0.01; + } + &dump_history; + + kill 'INT', $varlogpid if ($varlogpid); + kill 'INT', $clusterpid if ($clusterpid); + kill 'INT', $httppid if ($httppid); + close(VARLOGMSGFILE) if (VARLOGMSGFILE); + close(CLUSTERLOGFILE) if(CLUSTERLOGFILE); + close(HTTPLOGFILE) if(HTTPLOGFILE); + + return $rst; +} + +#------------------------------------- +# main process +#------------------------------------- +if ( + !GetOptions("--help|h|?" => \$help, + "T" => \$test, + "V" => \$verbose, + "n=s" => \$noderange)) +{ + probe_utils->send_msg("$output", "f", "Invalid parameter for $program_name"); + probe_utils->send_msg("$output", "d", "$::USAGE"); + exit 1; +} + +if ($help) { + if ($output ne "stdout") { + probe_utils->send_msg("$output", "d", "$::USAGE"); + } else { + print "$::USAGE"; + } + exit 0; +} + +if ($test) { + probe_utils->send_msg("$output", "o", "Do probe for os provision process, realtime monitor of os provision process."); + exit 0; +} + +$rst = do_monitor(); + +exit $rst; + + From d4775db253cc80d9b28c4e947a312782be31d378 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Mon, 4 Jul 2016 14:45:21 +0800 Subject: [PATCH 227/310] [go-xcat] Change all `read' to `read -r' to make the script more robust --- xCAT-server/share/xcat/tools/go-xcat | 62 ++++++++++++++-------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index 17f689f65..3a8301e75 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -16,7 +16,7 @@ function usage() { local script="${0##*/}" - while read ; do echo "${REPLY}" ; done <<-EOF + while read -r ; do echo "${REPLY}" ; done <<-EOF Usage: ${script} [OPTION]... [ACTION] Install xCAT automatically @@ -54,17 +54,17 @@ function usage() ${script} --xcat-core=http://xcat.org/path/to/xcat-core.repo install ${script} --xcat-core=http://xcat.org/path/to/xcat-core install ${script} --xcat-core=http://xcat.org/path/to/xcat-core.tar.bz2 install - ${script} --xcat-core=/path/to/xcat-core.repo \\\\ + ${script} --xcat-core=/path/to/xcat-core.repo \\ --xcat-dep=/path/to/xcat-dep.repo install - ${script} --xcat-core=/path/to/xcat-core \\\\ + ${script} --xcat-core=/path/to/xcat-core \\ --xcat-dep=/path/to/xcat-dep install - ${script} --xcat-core=/path/to/xcat-core.tar.bz2 \\\\ + ${script} --xcat-core=/path/to/xcat-core.tar.bz2 \\ --xcat-dep=/path/to/xcat-dep.tar.bz2 install - ${script} --xcat-core=http://xcat.org/path/to/xcat-core.repo \\\\ + ${script} --xcat-core=http://xcat.org/path/to/xcat-core.repo \\ --xcat-dep=http://xcat.org/path/to/xcat-dep.repo install - ${script} --xcat-core=http://xcat.org/path/to/xcat-core \\\\ + ${script} --xcat-core=http://xcat.org/path/to/xcat-core \\ --xcat-dep=http://xcat.org/path/to/xcat-dep install - ${script} --xcat-core=http://xcat.org/path/to/xcat-core.tar.bz2 \\\\ + ${script} --xcat-core=http://xcat.org/path/to/xcat-core.tar.bz2 \\ --xcat-dep=http://xcat.org/path/to/xcat-dep.tar.bz2 install xCAT (Extreme Cloud/Cluster Administration Toolkit): @@ -343,7 +343,7 @@ function check_package_version_rpm() { type rpm >/dev/null 2>&1 || return 255 local ver="" - while read ver + while read -r ver do if [[ -z "${ver}" || "${ver}" =~ not\ installed ]] then @@ -361,7 +361,7 @@ function check_package_version_deb() type dpkg-query >/dev/null 2>&1 || return 255 local name="" local ver="" - while read name ver + while read -r name ver do name+=("${name}") ver+=("${ver}") @@ -396,7 +396,7 @@ function check_repo_version_dnf() type dnf >/dev/null 2>&1 || return 255 local -a name=() local -a ver=() - while read name ver + while read -r name ver do name+=("${name}") ver+=("${ver}") @@ -426,7 +426,7 @@ function check_repo_version_yum() check_exec_or_exit repoquery local -a name=() local -a ver=() - while read name ver + while read -r name ver do name+=("${name}") ver+=("${ver}") @@ -455,7 +455,7 @@ function check_repo_version_zypper() type zypper >/dev/null 2>&1 || return 255 local -a name=() local -a ver=() - while read name ver + while read -r name ver do name+=("${name}") ver+=("${ver}") @@ -485,7 +485,7 @@ function check_repo_version_apt() type apt-cache >/dev/null 2>&1 || return 255 local name="" local ver="" - while read name ver + while read -r name ver do if [[ "${name}" =~ ^[a-z] ]] then @@ -729,7 +729,7 @@ function add_repo_by_url_yum_or_zypper() ;; *) # assume it is the base url of the repo tmp="${TMP_DIR}/tmp_repo.repo" - while read ; do echo "${REPLY}" ; done >"${tmp}" <<-EOF + while read -r ; do echo "${REPLY}" ; done >"${tmp}" <<-EOF [${repo_id}] name=${repo_id} baseurl=${url} @@ -764,7 +764,7 @@ function add_repo_by_url_yum_or_zypper() [[ "${url:0:1}" = "/" ]] || url="${PWD}/${url}" # directory tmp="${TMP_DIR}/tmp_repo.repo" - while read ; do echo "${REPLY}" ; done >"${tmp}" <<-EOF + while read -r ; do echo "${REPLY}" ; done >"${tmp}" <<-EOF [${repo_id}] name=${repo_id} baseurl=file://${url} @@ -1096,7 +1096,7 @@ function update_xcat() )) for i in "${!install_list[@]}" do - read ver + read -r ver [[ "${ver}" = "(not installed)" ]] && unset "install_list[${i}]" done < <(check_package_version "${install_list[@]}") @@ -1134,7 +1134,7 @@ function list_xcat_packages() "------------" "---------" "-------------" for pkg in "${GO_XCAT_CORE_PACKAGE_LIST[@]}" do - read i_ver && read -u 42 r_ver + read -r i_ver && read -u 42 -r r_ver printf "%-${first_col}s %-${second_col}s %-${third_col}s\n" \ "${pkg:0:${first_col}}" \ "${i_ver:0:${second_col}}" \ @@ -1154,8 +1154,8 @@ function list_xcat_packages() for pkg in "${GO_XCAT_DEP_PACKAGE_LIST[@]}" do - read i_ver - read -u 42 r_ver + read -r i_ver + read -u 42 -r r_ver printf "%-${first_col}s %-${second_col}s %-${third_col}s\n" \ "${pkg:0:${first_col}}" \ "${i_ver:0:${second_col}}" \ @@ -1170,7 +1170,7 @@ function test_case_000_version() { local ver="" local -i ret=0 - while read + while read -r do [[ "${REPLY}" = "(not installed)" ]] && continue [[ -z "${ver}" ]] && ver="${REPLY%%-*}" @@ -1223,10 +1223,10 @@ function perform_smoke_test() echo "-- 8< -- -- -- -- -- -- -- -- -- -- -- -- -- -- --" echo "==== ${test_case} failed with exit code ${ret} ====" echo "-- 8< ${test_case} stdout -- --" - while read ; do echo "${REPLY}" ; done \ + while read -r ; do echo "${REPLY}" ; done \ <"${TMP_DIR}/${test_case}.stdout" echo "-- 8< ${test_case} stderr -- --" - while read ; do echo "${REPLY}" ; done \ + while read -r ; do echo "${REPLY}" ; done \ <"${TMP_DIR}/${test_case}.stderr" echo "-- 8< -- -- -- -- -- -- -- -- -- -- -- -- -- -- --" # skip all the remain test cases @@ -1339,7 +1339,7 @@ esac GO_XCAT_OS="$(check_os)" GO_XCAT_ARCH="$(check_arch)" -while read ; do echo "${REPLY}" ; echo "${REPLY}" >&2 +while read -r ; do echo "${REPLY}" ; echo "${REPLY}" >&2 done 2>"${TMP_DIR}/go-xcat.log.000" <&2 +while read -r ; do echo "${REPLY}" ; echo "${REPLY}" >&2 done 2>"${TMP_DIR}/go-xcat.log.001" <"${TMP_DIR}/go-xcat.log.005" @@ -1449,10 +1449,10 @@ case "${GO_XCAT_ACTION}" in echo "-- 8< -- -- -- -- vv -- -- -- vv -- -- -- -- 8< --" echo "==== perform_smoke_test failed with exit code ${RET} ====" echo "-- 8< perform_smoke_test stdout -- --" - while read ; do echo "${REPLY}" ; done \ + while read -r ; do echo "${REPLY}" ; done \ <"${TMP_DIR}/perform_smoke_test.stdout" echo "-- 8< perform_smoke_test stderr -- --" - while read ; do echo "${REPLY}" ; done \ + while read -r ; do echo "${REPLY}" ; done \ <"${TMP_DIR}/perform_smoke_test.stderr" echo "-- 8< -- -- -- -- ^^ -- -- -- ^^ -- -- -- -- 8< --" fi @@ -1464,7 +1464,7 @@ case "${GO_XCAT_ACTION}" in then GO_XCAT_LOG="/tmp/go-xcat.log" cat "${TMP_DIR}/go-xcat.log."* >"${GO_XCAT_LOG}" 2>/dev/null - while read ; do echo "${REPLY}" ; done >&2 <<-EOF + while read -r ; do echo "${REPLY}" ; done >&2 <<-EOF Boo-boo @@ -1478,7 +1478,7 @@ case "${GO_XCAT_ACTION}" in exit "${RET}" fi - while read ; do echo "${REPLY}" ; done <<-EOF + while read -r ; do echo "${REPLY}" ; done <<-EOF Congratulations From 0441a8d713d53de07a7e801fdd0c46528e745129 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Mon, 4 Jul 2016 02:54:14 -0400 Subject: [PATCH 228/310] modify depending on TingTing's comments --- xCAT-probe/debian/changelog | 4 ++-- xCAT-probe/xCAT-probe.spec | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/xCAT-probe/debian/changelog b/xCAT-probe/debian/changelog index fd4ac5c3d..050572c17 100644 --- a/xCAT-probe/debian/changelog +++ b/xCAT-probe/debian/changelog @@ -1,5 +1,5 @@ -xcat-probe (2.12) xcat; urgency=low +xcat-probe (2.12) unstable; urgency=low - * initial build + * Initial build -- huweihua Fri, 1 Jul 2016 19:42:58 -0400 diff --git a/xCAT-probe/xCAT-probe.spec b/xCAT-probe/xCAT-probe.spec index 8c5490ae8..146b08c7a 100644 --- a/xCAT-probe/xCAT-probe.spec +++ b/xCAT-probe/xCAT-probe.spec @@ -19,7 +19,7 @@ BuildArch: noarch Provides: xCAT-probe = %{version} %description -CAT-probe provides a toolkits to probe potential issues with the xCAT cluster. +xCAT-probe provides a toolkits to probe potential issues with the xCAT cluster. %prep %setup -q -n xCAT-probe @@ -57,7 +57,7 @@ rm -rf $RPM_BUILD_ROOT %{prefix} %changelog -* Fri Jul 1 2016 - huweihu +* Fri Jul 1 2016 - huweihua - "Create xCAT probe package" %post From 58c17f69d15cd7d51849ce33e485cafcbfaac668 Mon Sep 17 00:00:00 2001 From: immarvin Date: Mon, 4 Jul 2016 02:58:08 -0400 Subject: [PATCH 229/310] refine the doc on xCAT object template --- docs/source/guides/admin-guides/references/man1/lsdef.1.rst | 4 ++-- docs/source/guides/admin-guides/references/man1/mkdef.1.rst | 4 ++-- xCAT-client/pods/man1/lsdef.1.pod | 4 ++-- xCAT-client/pods/man1/mkdef.1.pod | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/lsdef.1.rst b/docs/source/guides/admin-guides/references/man1/lsdef.1.rst index 77bf058d0..5e4bbe84d 100644 --- a/docs/source/guides/admin-guides/references/man1/lsdef.1.rst +++ b/docs/source/guides/admin-guides/references/man1/lsdef.1.rst @@ -399,12 +399,12 @@ EXAMPLES 19. - To display the details of "node" object definition template "powerLEnv" shipped in xCAT. + To display the details of "node" object definition template "ppc64le-template" shipped in xCAT. .. code-block:: perl - lsdef -t node --template powerLEnv + lsdef -t node --template ppc64le-template diff --git a/docs/source/guides/admin-guides/references/man1/mkdef.1.rst b/docs/source/guides/admin-guides/references/man1/mkdef.1.rst index 83091d7f3..694517181 100644 --- a/docs/source/guides/admin-guides/references/man1/mkdef.1.rst +++ b/docs/source/guides/admin-guides/references/man1/mkdef.1.rst @@ -288,12 +288,12 @@ EXAMPLES 13 - To create a PowerLE kvm node definition with the xCAT shipped template "powerLEkvm". + To create a PowerLE kvm node definition with the xCAT shipped template "ppc64lekvmguest-template". .. code-block:: perl - mkdef -t node cn1 --template powerLEkvm ip=1.1.1.1 mac=42:3d:0a:05:27:0b vmhost=1.1.0.1 vmnics=br0 + mkdef -t node cn1 --template ppc64lekvmguest-template ip=1.1.1.1 mac=42:3d:0a:05:27:0b vmhost=1.1.0.1 vmnics=br0 diff --git a/xCAT-client/pods/man1/lsdef.1.pod b/xCAT-client/pods/man1/lsdef.1.pod index 70b96b4d2..1a1b23f9f 100644 --- a/xCAT-client/pods/man1/lsdef.1.pod +++ b/xCAT-client/pods/man1/lsdef.1.pod @@ -236,9 +236,9 @@ To list all the object definition templates shipped in xCAT. =item 19. -To display the details of "node" object definition template "powerLEnv" shipped in xCAT. +To display the details of "node" object definition template "ppc64le-template" shipped in xCAT. - lsdef -t node --template powerLEnv + lsdef -t node --template ppc64le-template =item 20. diff --git a/xCAT-client/pods/man1/mkdef.1.pod b/xCAT-client/pods/man1/mkdef.1.pod index ca32b11d4..ad0758101 100644 --- a/xCAT-client/pods/man1/mkdef.1.pod +++ b/xCAT-client/pods/man1/mkdef.1.pod @@ -169,9 +169,9 @@ To create an osimage definition and fill in attributes automatically. =item 13 -To create a PowerLE kvm node definition with the xCAT shipped template "powerLEkvm". +To create a PowerLE kvm node definition with the xCAT shipped template "ppc64lekvmguest-template". - mkdef -t node cn1 --template powerLEkvm ip=1.1.1.1 mac=42:3d:0a:05:27:0b vmhost=1.1.0.1 vmnics=br0 + mkdef -t node cn1 --template ppc64lekvmguest-template ip=1.1.1.1 mac=42:3d:0a:05:27:0b vmhost=1.1.0.1 vmnics=br0 =item 14 From a74af859ecee48e0010c7b38f9de1ff1f1c2f9e7 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Mon, 4 Jul 2016 14:53:12 +0800 Subject: [PATCH 230/310] [go-xcat] Add version number --- xCAT-server/share/xcat/tools/go-xcat | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index 3a8301e75..8c43440bf 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -2,6 +2,8 @@ # # go-xcat - Install xCAT automatically. # +# Version 1.0.0 +# # Copyright (C) 2016 International Business Machines # Eclipse Public License, Version 1.0 (EPL-1.0) # @@ -17,6 +19,14 @@ function usage() local script="${0##*/}" while read -r ; do echo "${REPLY}" ; done <<-EOF + ${script} version $( + for i in {0..9} + do + read -r + [[ ${REPLY} =~ \#\ +[Vv]ersion ]] && echo "${REPLY##* }" + done <"$0" + ) + Usage: ${script} [OPTION]... [ACTION] Install xCAT automatically From 6c67f700e1e0b81e3547864554076993323f4c26 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Mon, 4 Jul 2016 05:18:55 -0400 Subject: [PATCH 231/310] fix some bugs and change -t to -T --- xCAT-probe/lib/perl/probe_utils.pm | 23 +++++++++++------------ xCAT-probe/subcmds/detect_dhcpd | 5 +++-- xCAT-probe/subcmds/discovery | 4 ++-- xCAT-probe/subcmds/image | 6 +++--- xCAT-probe/subcmds/switch-macmap | 6 +++--- xCAT-probe/subcmds/xcatmn | 11 +++++------ xCAT-probe/xcatprobe | 4 ++-- 7 files changed, 29 insertions(+), 30 deletions(-) diff --git a/xCAT-probe/lib/perl/probe_utils.pm b/xCAT-probe/lib/perl/probe_utils.pm index 729dcebad..c12d505f9 100644 --- a/xCAT-probe/lib/perl/probe_utils.pm +++ b/xCAT-probe/lib/perl/probe_utils.pm @@ -223,23 +223,22 @@ sub is_selinux_enable { #------------------------------------------ sub is_firewall_open { - my $os = get_os(); my $output; my $rst = 0; - if ($os =~ /redhat/) { - $output = `service iptables status 2>&1`; - $rst = 1 if ($output =~ /running/i); - } elsif ($os =~ /sles/) { - $output = `service SuSEfirewall2_setup status`; - $rst = 1 if ($output =~ /running/i); - } elsif ($os =~ /ubuntu/) { - $output = `ufw status`; - $rst = 1 if ($output =~ /Status: active/i); - } + my $output =`iptables -nvL -t filter 2>&1`; + + `echo "$output" |grep "Chain INPUT (policy ACCEPT" > /dev/null 2>&1`; + $rst=1 if($?); + + `echo "$output" |grep "Chain FORWARD (policy ACCEPT" > /dev/null 2>&1`; + $rst=1 if($?); + + `echo "$output" |grep "Chain OUTPUT (policy ACCEPT" > /dev/null 2>&1`; + $rst=1 if($?); + return $rst; } - #------------------------------------------ =head3 diff --git a/xCAT-probe/subcmds/detect_dhcpd b/xCAT-probe/subcmds/detect_dhcpd index 45714dc60..8c8759132 100755 --- a/xCAT-probe/subcmds/detect_dhcpd +++ b/xCAT-probe/subcmds/detect_dhcpd @@ -29,7 +29,8 @@ Options: -i interface: Required. The interface which facing the target network. -m macaddress: The mac that will be used to detect dhcp server. Recommend to use the real mac of the node that will be netboot. If no specified, the mac of interface which specified by -i will be used. -d duration: The time to wait to detect the dhcp messages. The default value is 10s. - -t : To verify if $program_name can work, reserve option for probe framework. + -V verbose: To print additional debug information. + -T : To verify if $program_name can work, reserve option for probe framework. "; #--------------------------- @@ -40,7 +41,7 @@ if (!GetOptions( 'i=s' => \$::IF, 'm=s' => \$::MACADD, 'd=s' => \$::DURATION, - 't' => \$::TEST, + 'T' => \$::TEST, 'V|verbose' => \$::VERBOSE, 'h|help' => \$::HELP,)) { diff --git a/xCAT-probe/subcmds/discovery b/xCAT-probe/subcmds/discovery index b8ab90c5b..245557c50 100755 --- a/xCAT-probe/subcmds/discovery +++ b/xCAT-probe/subcmds/discovery @@ -978,7 +978,7 @@ sub do_monitor { chomp($line = ); ++$varlogmsgcnt; last if ($varlogmsgcnt <= $oldlines); - my @tmp = split(/ /, $line); + my @tmp = split(/\s+/, $line); if ($tmp[4] =~ /dhcpd:/i && $line =~ /$nics/) { handle_dhcp_msg("$line"); } elsif ($tmp[4] =~ /in.tftpd/i) { @@ -1065,7 +1065,7 @@ if (defined($noderange) && !defined($discovery_type)) { } if (defined($discovery_type)) { - unless (@valid_discovery_type ~~ /^$discovery_type$/) { + unless (grep(/^$discovery_type$/, @valid_discovery_type)){ probe_utils->send_msg("$output", "f", "Invalid discovery type. the vaild types are $valid_discovery_type_str"); probe_utils->send_msg("$output", "d", "$::USAGE"); exit 1; diff --git a/xCAT-probe/subcmds/image b/xCAT-probe/subcmds/image index 5218156ef..b224437f4 100755 --- a/xCAT-probe/subcmds/image +++ b/xCAT-probe/subcmds/image @@ -21,7 +21,7 @@ my $rst = 0; $::USAGE = "Usage: $program_name -h - $program_name -t + $program_name -T $program_name {-c|-d} [-V] Description: @@ -30,7 +30,7 @@ Description: Options: -h : Get usage information of $program_name - -t : To verify if $program_name can work, reserve option for probe framework + -T : To verify if $program_name can work, reserve option for probe framework -d : To verify diskless, pingable compute nodes have the same images installed as defines in xCAT DB. -c : To verify all diskless, pingable compute nodes have the identical images installed. -V : To print additional debug information. @@ -41,7 +41,7 @@ Options: #------------------------------------- if ( !GetOptions("--help|h" => \$help, - "t" => \$test, + "T" => \$test, "V" => \$VERBOSE, "c" => \$CONSISTENCY_CHECK, "d" => \$DEFINITION_CHECK)) diff --git a/xCAT-probe/subcmds/switch-macmap b/xCAT-probe/subcmds/switch-macmap index 45eedbb2a..1461cf5b0 100755 --- a/xCAT-probe/subcmds/switch-macmap +++ b/xCAT-probe/subcmds/switch-macmap @@ -16,14 +16,14 @@ my $output = "stdout"; $::USAGE = "Usage: $proname -h - $proname -t + $proname -T $proname [-c] [-V] Description: To retrieve MAC address mapping for the specified switch, or all the switches defined in switches table in xCAT db. Options: - -t: Check whether this script is OK to run. + -T: Check whether this script is OK to run. -c: To check whether the switch is OK to retrieve MAC address mapping. -V: Output verbose information when accessing switch "; @@ -34,7 +34,7 @@ my $check; my @nodes = (); my $verbose = ''; if (!GetOptions("help|h" => \$help, - "t" => \$test, + "T" => \$test, "c" => \$check, "V" => \$verbose)) { probe_utils->send_msg("$output", "f", "Option not support"); diff --git a/xCAT-probe/subcmds/xcatmn b/xCAT-probe/subcmds/xcatmn index aacf18b84..a9814cfc1 100755 --- a/xCAT-probe/subcmds/xcatmn +++ b/xCAT-probe/subcmds/xcatmn @@ -18,15 +18,15 @@ my $rst = 0; $::USAGE = "Usage: $proname -h - $proname -t - $proname [-n] [-V] + $proname -T + $proname [-n ] [-V] Description: After xcat installation, use this command to check if xcat has been installed correctly and is ready for use. Options: -h : Get usage information of $proname - -t : To verify if $proname can work, reserve option for probe framework + -T : To verify if $proname can work, reserve option for probe framework -n : Required. Specify the network interface name of provision network -V : Output more information for debug "; @@ -46,7 +46,7 @@ sub returncmdoutput { #------------------------------------- if ( !GetOptions("--help|h" => \$help, - "t" => \$test, + "T" => \$test, "V" => \$verbose, "n=s" => \$installnic)) { @@ -354,8 +354,7 @@ if (probe_utils->is_selinux_enable()) { $msg = "Firewall is closed on current server"; if (probe_utils->is_firewall_open()) { - probe_utils->send_msg("$output", "f", "$msg"); - $rst = 1; + probe_utils->send_msg("$output", "w", "Firewall is configured on current server"); } else { probe_utils->send_msg("$output", "o", "$msg"); } diff --git a/xCAT-probe/xcatprobe b/xCAT-probe/xcatprobe index 9e25e8da4..de624515e 100755 --- a/xCAT-probe/xcatprobe +++ b/xCAT-probe/xcatprobe @@ -61,7 +61,7 @@ sub loadsubcmds { next; } else { my $desc = $2; - unless ($1 ~~ /^ok$/) { + unless ($1 =~ /^ok$/) { print "skip $_ for doing '$_ -T' failed, invalid flag\n" if ($verbose); next; } @@ -233,7 +233,7 @@ my $pluginname; my $optnum = 0; foreach my $attr (@tmpargv) { if ($attr =~ /^-/) { - unless (@supportopt ~~ /^$attr$/) { + unless (grep(/^$attr$/, @supportopt)){ print "Unsupported attribute: $attr\n"; print $::USAGE; exit 1; From 45e364d1235e7742c6911398ea04517ebccb3e07 Mon Sep 17 00:00:00 2001 From: penguhyang Date: Mon, 4 Jul 2016 04:55:15 -0400 Subject: [PATCH 232/310] fix rinstall bug for #1461 --- xCAT-server/lib/xcat/plugins/rinstall.pm | 71 ++++++++++++------------ 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/rinstall.pm b/xCAT-server/lib/xcat/plugins/rinstall.pm index 78f758e3f..4f33187c1 100644 --- a/xCAT-server/lib/xcat/plugins/rinstall.pm +++ b/xCAT-server/lib/xcat/plugins/rinstall.pm @@ -321,15 +321,13 @@ sub rinstall { $rc = $::RUNCMD_RC; my $rsp = {}; - if ($rc == 0) { - if ($VERBOSE) { - my @cmd = "Run command: nodeset @nodes @parameter"; - push @{$rsp->{data}}, @cmd; - push @{$rsp->{data}}, @$res; - xCAT::MsgUtils->message("I", $rsp, $callback); - } + if ($VERBOSE) { + my @cmd = "Run command: nodeset @nodes @parameter"; + push @{$rsp->{data}}, @cmd; + push @{$rsp->{data}}, @$res; + xCAT::MsgUtils->message("I", $rsp, $callback); } - else { + unless ($rc == 0) { # We got an error with the nodeset my @successnodes; my @failurenodes; @@ -342,10 +340,17 @@ sub rinstall { $nodes{$successnode} = 0; push @successnodes, $successnode; } + if ($line =~ /dhcp server is not running/) { + my $rsp = {}; + $rsp->{error}->[0] = "Fatal error"; + $rsp->{errorcode}->[0] = 1; + xCAT::MsgUtils->message("E", $rsp, $callback); + return 1; + } xCAT::MsgUtils->message("I", $rsp, $callback); } foreach my $node (@nodes) { - if ($nodes{$node} = 1) { + if ($nodes{$node} == 1) { push @failurenodes, $node; } } @@ -388,15 +393,13 @@ sub rinstall { $rc = $::RUNCMD_RC; my $rsp = {}; - if ($rc == 0) { - if ($VERBOSE) { - my @cmd = "Run command: rnetboot @nodes"; - push @{$rsp->{data}}, @cmd; - push @{$rsp->{data}}, @$res; - xCAT::MsgUtils->message("I", $rsp, $callback); - } + if ($VERBOSE) { + my @cmd = "Run command: rnetboot @nodes"; + push @{$rsp->{data}}, @cmd; + push @{$rsp->{data}}, @$res; + xCAT::MsgUtils->message("I", $rsp, $callback); } - else { + unless ($rc == 0) { # We got an error with the rnetboot my @failurenodes; foreach my $line (@$res) { @@ -410,7 +413,7 @@ sub rinstall { xCAT::MsgUtils->message("I", $rsp, $callback); } foreach my $node (@nodes) { - if ($nodes{$node} = 1) { + if ($nodes{$node} == 1) { push @failurenodes, $node; } } @@ -441,15 +444,13 @@ sub rinstall { $rc = $::RUNCMD_RC; my $rsp = {}; - if ($rc == 0) { - if ($VERBOSE) { - my @cmd = "Run command: rsetboot @nodes @rsetbootarg"; - push @{$rsp->{data}}, @cmd; - push @{$rsp->{data}}, @$res; - xCAT::MsgUtils->message("I", $rsp, $callback); - } + if ($VERBOSE) { + my @cmd = "Run command: rsetboot @nodes @rsetbootarg"; + push @{$rsp->{data}}, @cmd; + push @{$rsp->{data}}, @$res; + xCAT::MsgUtils->message("I", $rsp, $callback); } - else { + unless ($rc == 0) { # We got an error with the rsetboot my @successnodes; my @failurenodes; @@ -465,7 +466,7 @@ sub rinstall { xCAT::MsgUtils->message("I", $rsp, $callback); } foreach my $node (@nodes) { - if ($nodes{$node} = 1) { + if ($nodes{$node} == 1) { push @failurenodes, $node; } } @@ -492,15 +493,13 @@ sub rinstall { $rc = $::RUNCMD_RC; my $rsp = {}; - if ($rc == 0) { - if ($VERBOSE) { - my @cmd = "Run command: rpower @nodes @rpowerarg"; - push @{$rsp->{data}}, @cmd; - push @{$rsp->{data}}, @$res; - xCAT::MsgUtils->message("I", $rsp, $callback); - } + if ($VERBOSE) { + my @cmd = "Run command: rpower @nodes @rpowerarg"; + push @{$rsp->{data}}, @cmd; + push @{$rsp->{data}}, @$res; + xCAT::MsgUtils->message("I", $rsp, $callback); } - else { + unless ($rc == 0) { # We got an error with the rpower my @failurenodes; foreach my $line (@$res) { @@ -514,7 +513,7 @@ sub rinstall { xCAT::MsgUtils->message("I", $rsp, $callback); } foreach my $node (@nodes) { - if ($nodes{$node} = 1) { + if ($nodes{$node} == 1) { push @failurenodes, $node; } } From 434db38a10f554cb2f0ddb9395fd4ffae0748440 Mon Sep 17 00:00:00 2001 From: immarvin Date: Mon, 4 Jul 2016 22:03:51 -0400 Subject: [PATCH 233/310] fix issue [FVT]Please make the priority clearly as node name can be the same with template #1471 --- docs/source/guides/admin-guides/references/man1/mkdef.1.rst | 2 +- xCAT-client/pods/man1/mkdef.1.pod | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/mkdef.1.rst b/docs/source/guides/admin-guides/references/man1/mkdef.1.rst index 694517181..c3849d38c 100644 --- a/docs/source/guides/admin-guides/references/man1/mkdef.1.rst +++ b/docs/source/guides/admin-guides/references/man1/mkdef.1.rst @@ -84,7 +84,7 @@ OPTIONS \ **-**\ **-template**\ \ *template-object-name*\ - Name of the xCAT shipped object definition template or an existing object, from which the new object definition will be created from. The newly created object will inherit the attributes of the template definition unless the attribute is specified in the arguments of \ **mkdef**\ command. For the details of xCAT shipped object definition templates, please refer to the manpage of \ **-**\ **-template**\ option in lsdef(1)|lsdef.1. + Name of the xCAT shipped object definition template or an existing object, from which the new object definition will be created from. The newly created object will inherit the attributes of the template definition unless the attribute is specified in the arguments of \ **mkdef**\ command. If there are an existing object and a template with the same name \ *template-object-name*\ , the existing object takes precedence over the object definition template. For the details of xCAT shipped object definition templates, please refer to the manpage of \ **-**\ **-template**\ option in lsdef(1)|lsdef.1. diff --git a/xCAT-client/pods/man1/mkdef.1.pod b/xCAT-client/pods/man1/mkdef.1.pod index ad0758101..e24a54b46 100644 --- a/xCAT-client/pods/man1/mkdef.1.pod +++ b/xCAT-client/pods/man1/mkdef.1.pod @@ -50,7 +50,7 @@ A set of comma delimited object types. Use the help option to get a list of val =item B<--template> I -Name of the xCAT shipped object definition template or an existing object, from which the new object definition will be created from. The newly created object will inherit the attributes of the template definition unless the attribute is specified in the arguments of B command. For the details of xCAT shipped object definition templates, please refer to the manpage of B<--template> option in L. +Name of the xCAT shipped object definition template or an existing object, from which the new object definition will be created from. The newly created object will inherit the attributes of the template definition unless the attribute is specified in the arguments of B command. If there are an existing object and a template with the same name I, the existing object takes precedence over the object definition template. For the details of xCAT shipped object definition templates, please refer to the manpage of B<--template> option in L. =item B<-V|--verbose> From 663e41e0d361673a4291332b25242704ae04b33f Mon Sep 17 00:00:00 2001 From: XuWei Date: Mon, 4 Jul 2016 22:14:53 -0400 Subject: [PATCH 234/310] Fix issue 1468, modified to check the value of array element --- xCAT-server/lib/xcat/plugins/kvm.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index dae497285..5ae79f980 100755 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -3899,7 +3899,7 @@ sub forward_data { #save the nodes that has errors and the ones that has no-op for use by the node status monitoring my $no_op = 0; - if ($_->{node}->[0]->{errorcode}) { $no_op = 1; } + if ($_->{node}->[0]->{errorcode}->[0]) { $no_op = 1; } else { my $text = $_->{node}->[0]->{data}->[0]->{contents}->[0]; From 40930090829aaccf5d03c33cc7d27ebd01013c31 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Tue, 5 Jul 2016 03:59:20 -0400 Subject: [PATCH 235/310] Make xcat-porbe as xcat's dependency --- xCAT/debian/control | 2 +- xCAT/xCAT.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT/debian/control b/xCAT/debian/control index 6a6fe41aa..c5051a272 100644 --- a/xCAT/debian/control +++ b/xCAT/debian/control @@ -7,6 +7,6 @@ Standards-Version: 3.7.2 Package: xcat Architecture: amd64 ppc64el -Depends: ${perl:Depends}, xcat-server, xcat-client, libdbd-sqlite3-perl, isc-dhcp-server, apache2, nfs-kernel-server, nmap, bind9, libxml-parser-perl, xinetd, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, ipmitool-xcat (>=1.8.9), syslinux[any-amd64], libsys-virt-perl, syslinux-xcat[any-amd64], xnba-undi, xcat-genesis-scripts, elilo-xcat, xcat-buildkit +Depends: ${perl:Depends}, xcat-server, xcat-client, libdbd-sqlite3-perl, isc-dhcp-server, apache2, nfs-kernel-server, nmap, bind9, libxml-parser-perl, xinetd, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, ipmitool-xcat (>=1.8.9), syslinux[any-amd64], libsys-virt-perl, syslinux-xcat[any-amd64], xnba-undi, xcat-genesis-scripts, elilo-xcat, xcat-buildkit, xcat-probe (>=2.12) Description: Server and configuration utilities of the xCAT management project xcat-server provides the core server and configuration management components of xCAT. This package should be installed on your management server diff --git a/xCAT/xCAT.spec b/xCAT/xCAT.spec index 0fdab697e..789cbb06b 100644 --- a/xCAT/xCAT.spec +++ b/xCAT/xCAT.spec @@ -25,7 +25,7 @@ Source7: xcat.conf.apach24 Provides: xCAT = %{version} Conflicts: xCATsn -Requires: xCAT-server xCAT-client perl-DBD-SQLite +Requires: xCAT-server xCAT-client perl-DBD-SQLite xCAT-probe >= 2.12.1 %define pcm %(if [ "$pcm" = "1" ];then echo 1; else echo 0; fi) %define notpcm %(if [ "$pcm" = "1" ];then echo 0; else echo 1; fi) From 79f93dac3cc369b274ee712a7d6c4bf5ee60a6e7 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 5 Jul 2016 15:28:39 -0400 Subject: [PATCH 236/310] Small grammar and formatting fixes for mkdef command --- docs/source/guides/admin-guides/references/man1/mkdef.1.rst | 6 +++--- xCAT-client/pods/man1/mkdef.1.pod | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/mkdef.1.rst b/docs/source/guides/admin-guides/references/man1/mkdef.1.rst index c3849d38c..38b38dce5 100644 --- a/docs/source/guides/admin-guides/references/man1/mkdef.1.rst +++ b/docs/source/guides/admin-guides/references/man1/mkdef.1.rst @@ -84,7 +84,7 @@ OPTIONS \ **-**\ **-template**\ \ *template-object-name*\ - Name of the xCAT shipped object definition template or an existing object, from which the new object definition will be created from. The newly created object will inherit the attributes of the template definition unless the attribute is specified in the arguments of \ **mkdef**\ command. If there are an existing object and a template with the same name \ *template-object-name*\ , the existing object takes precedence over the object definition template. For the details of xCAT shipped object definition templates, please refer to the manpage of \ **-**\ **-template**\ option in lsdef(1)|lsdef.1. + Name of the xCAT shipped object definition template or an existing object, from which the new object definition will be created. The newly created object will inherit the attributes of the template definition unless the attribute is specified in the arguments of \ **mkdef**\ command. If there are an existing object and a template with the same name \ *template-object-name*\ , the existing object takes precedence over the object definition template. For the details of xCAT shipped object definition templates, refer to the manpage of \ **-**\ **-template**\ option in lsdef(1)|lsdef.1. @@ -286,7 +286,7 @@ EXAMPLES -13 +13. To create a PowerLE kvm node definition with the xCAT shipped template "ppc64lekvmguest-template". @@ -298,7 +298,7 @@ EXAMPLES -14 +14. To create a node definition from an existing node definition "cn1" diff --git a/xCAT-client/pods/man1/mkdef.1.pod b/xCAT-client/pods/man1/mkdef.1.pod index e24a54b46..d433869fb 100644 --- a/xCAT-client/pods/man1/mkdef.1.pod +++ b/xCAT-client/pods/man1/mkdef.1.pod @@ -50,7 +50,7 @@ A set of comma delimited object types. Use the help option to get a list of val =item B<--template> I -Name of the xCAT shipped object definition template or an existing object, from which the new object definition will be created from. The newly created object will inherit the attributes of the template definition unless the attribute is specified in the arguments of B command. If there are an existing object and a template with the same name I, the existing object takes precedence over the object definition template. For the details of xCAT shipped object definition templates, please refer to the manpage of B<--template> option in L. +Name of the xCAT shipped object definition template or an existing object, from which the new object definition will be created. The newly created object will inherit the attributes of the template definition unless the attribute is specified in the arguments of B command. If there are an existing object and a template with the same name I, the existing object takes precedence over the object definition template. For the details of xCAT shipped object definition templates, refer to the manpage of B<--template> option in L. =item B<-V|--verbose> @@ -167,13 +167,13 @@ To create an osimage definition and fill in attributes automatically. mkdef redhat6img -u profile=compute provmethod=statelite -=item 13 +=item 13. To create a PowerLE kvm node definition with the xCAT shipped template "ppc64lekvmguest-template". mkdef -t node cn1 --template ppc64lekvmguest-template ip=1.1.1.1 mac=42:3d:0a:05:27:0b vmhost=1.1.0.1 vmnics=br0 -=item 14 +=item 14. To create a node definition from an existing node definition "cn1" From 77a563ed89f1a3607f4118dd3d4097a06b042678 Mon Sep 17 00:00:00 2001 From: ertaozh Date: Tue, 5 Jul 2016 05:37:38 -0400 Subject: [PATCH 237/310] Fix issue 1371: xcatprobe switch-macmap - could not get valid information --- perl-xCAT/xCAT/MacMap.pm | 12 +++++--- xCAT-probe/subcmds/switch-macmap | 42 +++++++++++++++----------- xCAT-server/lib/xcat/plugins/switch.pm | 35 ++++++++++++--------- 3 files changed, 52 insertions(+), 37 deletions(-) diff --git a/perl-xCAT/xCAT/MacMap.pm b/perl-xCAT/xCAT/MacMap.pm index bc78f8630..55f2c8c94 100644 --- a/perl-xCAT/xCAT/MacMap.pm +++ b/perl-xCAT/xCAT/MacMap.pm @@ -570,10 +570,14 @@ sub getsnmpsession { my $snmpver='1'; my $swent = $self->{switchparmhash}->{$switch}; - if ($swent) { - $snmpver=$swent->{snmpversion}; - $community=$swent->{password}; - } + if ($swent) { + if ($swent->{snmpversion}) { + $snmpver=$swent->{snmpversion}; + } + if ($swent->{password}) { + $community=$swent->{password}; + } + } my $switch_ip = xCAT::NetworkUtils->getipaddr($switch); unless ($switch_ip) { return ({"ErrorStr"=>"Can not resolve IP address for $switch"}); diff --git a/xCAT-probe/subcmds/switch-macmap b/xCAT-probe/subcmds/switch-macmap index 1461cf5b0..5fe02e147 100755 --- a/xCAT-probe/subcmds/switch-macmap +++ b/xCAT-probe/subcmds/switch-macmap @@ -53,13 +53,15 @@ if ($help) { probe_utils->send_msg("$output", "d", $::USAGE); exit 0; } + +if (! -d "$currdir/bin") { + mkpath("$currdir/bin/"); +} +if (! -e "$currdir/bin/switchprobe") { + link("$::XCATROOT/bin/xcatclient", "$currdir/bin/switchprobe"); +} + if ($test) { - if (! -d "$currdir/bin") { - mkpath("$currdir/bin/"); - } - if (! -e "$currdir/bin/switchprobe") { - link("$::XCATROOT/bin/xcatclient", "$currdir/bin/switchprobe"); - } `$currdir/bin/switchprobe -h`; if ($?) { probe_utils->send_msg("$output", "f", "No switchprobe tool is available at $currdir/bin/"); @@ -92,21 +94,25 @@ if (-f $error_file) { } my $fd; open($fd, "<", "$normal_file"); -my %fails = (); +my @fails = (); +# There is 2 kinds of error message: +# 1. Error: The nodetype is not 'switch' for nodes: switch1 +# Error: No switch configuration info find for switch-10-5-23-1 +# 2. switch-10-5-23-1: Error: Timeout foreach (<$fd>) { chomp($_); - if (/^(\S*):\s*(.*)/) { - my $switch = $1; - my $info = $2; - if (/PASS/) { - probe_utils->send_msg("$output", "o", "$switch"); - } elsif (/Error:/) { - $info =~ s/Error://; - $fails{$switch} = $info; + if (/Error:/) { + if (/^(\S*):\s*Error:\s*(.*)/) { + push @fails, "$1 - $2"; + } elsif (/^Error:\s*(.*)/) { + push @fails, $1; } else { - probe_utils->send_msg("$output", "d", "$_"); + push @fails, $_; } } + elsif (/^(\S*):\s*PASS/) { + probe_utils->send_msg("$output", "o", "$1"); + } else { probe_utils->send_msg("$output", "d", $_); } @@ -118,7 +124,7 @@ if (-f $normal_file) { if (-f $error_file) { unlink($error_file); } -foreach (keys %fails) { - probe_utils->send_msg("$output", "f", "$_ - $fails{$_}"); +foreach (@fails) { + probe_utils->send_msg("$output", "f", "$_"); } exit 0; diff --git a/xCAT-server/lib/xcat/plugins/switch.pm b/xCAT-server/lib/xcat/plugins/switch.pm index c23543255..ed2719eed 100644 --- a/xCAT-server/lib/xcat/plugins/switch.pm +++ b/xCAT-server/lib/xcat/plugins/switch.pm @@ -130,9 +130,21 @@ sub preprocess_request { if (defined($check)) { $request->{opt}->{check} = $check; } + my $switchestab = xCAT::Table->new('switches', -create=>0); + my $swhash = undef; + if ($switchestab) { + $swhash = $switchestab->getAllNodeAttribs(['switch'], 1); + if (!defined($swhash)) { + $callback->({error=>["Get attributes from table 'switches' failed"],errorcode=>1}); + return; + } + } + else { + $callback->({error=>["Open table 'switches' failed"],errorcode=>1}); + return; + } if (defined($noderange)) { my $nthash = undef; - my $swhash = undef; my $nodetypetab=xCAT::Table->new('nodetype',-create=>0); if ($nodetypetab) { $nthash = $nodetypetab->getNodesAttribs($noderange, ['nodetype']); @@ -145,19 +157,6 @@ sub preprocess_request { $callback->({error=>["Open table 'nodetype' failed"],errorcode=>1}); return; } - my $switchestab = xCAT::Table->new('switches', -create=>0); - if ($switchestab) { - $swhash = $switchestab->getNodesAttribs($noderange, ['switch']); - if (!defined($swhash)) { - $callback->({error=>["Get attributes from table 'switches' failed"],errorcode=>1}); - return; - } - } - else { - $callback->({error=>["Open table 'switches' failed"],errorcode=>1}); - return; - - } my @switchnode = (); my @errswnode = (); my @errornode = (); @@ -165,7 +164,7 @@ sub preprocess_request { if (!defined($nthash->{$node}) or $nthash->{$node}->[0]->{nodetype} ne 'switch') { push @errornode, $node; } - elsif (!defined($swhash->{$node})) { + elsif (!defined($swhash->{$node}) or !defined($swhash->{$node}->[0])) { push @errswnode, $node; } else { @@ -183,6 +182,12 @@ sub preprocess_request { return [$request]; } return; + } + else { + if (!scalar(keys %$swhash)) { + $callback->({error=>["No switch configuration info get from 'switches' table"],errorcode=>1}); + return; + } } } return [$request]; From d1e63367f5b4c39b9043fb4c3afc4d9cf5afea15 Mon Sep 17 00:00:00 2001 From: WangXiaoPeng Date: Tue, 5 Jul 2016 22:58:01 -0400 Subject: [PATCH 238/310] issue 1245, add the missing $ in the regular expression --- xCAT/postscripts/syslog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT/postscripts/syslog b/xCAT/postscripts/syslog index 35889640b..4c4006ae7 100755 --- a/xCAT/postscripts/syslog +++ b/xCAT/postscripts/syslog @@ -94,7 +94,7 @@ config_Rsyslog_C3() grep "$xCATSettingsOLD$" $conf_file 2>&1 1> /dev/null if [ $? -eq 0 ]; then #remove the older version syslog rule generated by xCAT - sed -i "/$xCATSettingsOLD/,+1 d" $2 + sed -i "/$xCATSettingsOLD$/,+1 d" $2 fi grep "$xCATSettingsSTART" $conf_file 2>&1 1> /dev/null From 66f0701b4d3b328f14bc6bc8fcce5c080ae289f6 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Wed, 6 Jul 2016 01:44:51 -0400 Subject: [PATCH 239/310] Fix one bug and refine some code --- xCAT-probe/subcmds/discovery | 32 ++++++++++---------------------- xCAT-probe/subcmds/xcatmn | 12 ++++++------ 2 files changed, 16 insertions(+), 28 deletions(-) diff --git a/xCAT-probe/subcmds/discovery b/xCAT-probe/subcmds/discovery index 245557c50..9192114d1 100755 --- a/xCAT-probe/subcmds/discovery +++ b/xCAT-probe/subcmds/discovery @@ -1,4 +1,4 @@ -#! /usr/bin/perl +#!/usr/bin/perl # IBM(c) 2016 EPL license http://www.eclipse.org/legal/epl-v10.html BEGIN { $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; } @@ -38,6 +38,7 @@ $::USAGE = "Usage: Description: Do probe for discovery process, including pre-check for required configuration and realtime monitor of discovery process. If all pre-check items pass, $program_name will go to monitor directly, otherwise $program_name exit for error. + In order to do realtime monitor, $program_name probe program must be run along with the node discovery procedure. Plese trigger this command before trigger node discovery procedure. Options: -h : Get usage information of $program_name. @@ -98,7 +99,7 @@ sub check_genesis_file { probe_utils->send_msg("$output", "d", "xCAT-genesis for $arch installed, start to check files...") if ($verbose); - my $tftpdir = `tabdump site | grep "tftpdir" | awk -F "," '{print \$2}'`; + my $tftpdir = `tabdump site | awk -F',' '/^"tftpdir",/ { gsub(/"/, "", \$2) ; print \$2 }'`; chomp($tftpdir); $tftpdir =~ s/"//g; my $genesis_folder; @@ -529,7 +530,7 @@ sub handle_compute_msg { my $ip = ""; my $msg; - my @splitline = split(" ", $line); + my @splitline = split(/\s+/, $line); if (($splitline[4] =~ /^xcat/i) || ($splitline[5] =~ /^xcat/i)) { $sender = $splitline[3]; splice(@splitline, 0, 5); @@ -799,7 +800,7 @@ sub do_pre_check { } } else { $msg = "Attribute 'master' in 'site' table is configured well"; - my $masteripinsite = `tabdump site | awk -F',' '/master/ { gsub(/"/, "", \$2) ; print \$2 }'`; + my $masteripinsite = `tabdump site | awk -F',' '/^"master",/ { gsub(/"/, "", \$2) ; print \$2 }'`; chomp($masteripinsite); if ($masteripinsite eq "") { probe_utils->send_msg("$output", "d", "There isn't 'master' definition in 'site' talbe") if ($verbose); @@ -891,7 +892,7 @@ sub do_monitor { }; if (!$nics) { - my $masteripinsite = `tabdump site | awk -F',' '/master/ { gsub(/"/, "", \$2) ; print \$2 }'`; + my $masteripinsite = `tabdump site | awk -F',' '/^"master",/ { gsub(/"/, "", \$2) ; print \$2 }'`; chomp($masteripinsite); $nics = `ip addr |grep -B2 $masteripinsite|awk -F" " '/mtu/{gsub(/:/,"",\$2); print \$2}'`; chomp($nics); @@ -934,22 +935,22 @@ sub do_monitor { my $rst = 0; { #important to hold a block # start ot obtain logs from every log file - if (!($varlogpid = open(VARLOGMSGFILE, "tail -f $varlogmsg 2>&1 |"))) { + if (!($varlogpid = open(VARLOGMSGFILE, "tail -f -n 0 $varlogmsg 2>&1 |"))) { probe_utils->send_msg("$output", "f", "Can't open $varlogmsg to get logs"); $rst = 1; last; } - if (!($clusterpid = open(CLUSTERLOGFILE, "tail -f $clusterlog 2>&1 |"))) { + if (!($clusterpid = open(CLUSTERLOGFILE, "tail -f -n 0 $clusterlog 2>&1 |"))) { probe_utils->send_msg("$output", "f", "Can't open $clusterlog to get logs"); $rst = 1; last; } - if (!($httppid = open(HTTPLOGFILE, "tail -f $httplog 2>&1 |"))) { + if (!($httppid = open(HTTPLOGFILE, "tail -f -n 0 $httplog 2>&1 |"))) { probe_utils->send_msg("$output", "f", "Can't open $httplog to get logs"); $rst = 1; last; } - if (!($computerpid = open(COMPUTERFILE, "tail -f $computelog 2>&1 |"))) { + if (!($computerpid = open(COMPUTERFILE, "tail -f -n 0 $computelog 2>&1 |"))) { probe_utils->send_msg("$output", "f", "Can't open $computelog to get logs"); $rst = 1; last; @@ -965,19 +966,12 @@ sub do_monitor { my $line = ""; my @hdls; my $hdl; - my $oldlines = 10; - my $varlogmsgcnt = 0; - my $clusterlogcnt = 0; - my $httplogcnt = 0; - my $computercnt = 0; for (; ;) { if (@hdls = $select->can_read(0)) { foreach $hdl (@hdls) { if ($hdl == \*VARLOGMSGFILE) { chomp($line = ); - ++$varlogmsgcnt; - last if ($varlogmsgcnt <= $oldlines); my @tmp = split(/\s+/, $line); if ($tmp[4] =~ /dhcpd:/i && $line =~ /$nics/) { handle_dhcp_msg("$line"); @@ -986,18 +980,12 @@ sub do_monitor { } } elsif ($hdl == \*CLUSTERLOGFILE) { chomp($line = ); - ++$clusterlogcnt; - last if ($clusterlogcnt <= $oldlines); handle_cluster_msg("$line"); } elsif ($hdl == \*HTTPLOGFILE) { chomp($line = ); - ++$httplogcnt; - last if ($httplogcnt <= $oldlines); handle_http_msg("$line"); } elsif ($hdl == \*COMPUTERFILE) { chomp($line = ); - ++$computercnt; - last if ($computercnt <= $oldlines); handle_compute_msg("$line"); } } diff --git a/xCAT-probe/subcmds/xcatmn b/xCAT-probe/subcmds/xcatmn index a9814cfc1..0bfd233db 100755 --- a/xCAT-probe/subcmds/xcatmn +++ b/xCAT-probe/subcmds/xcatmn @@ -148,7 +148,7 @@ if ($xcatdproc =~ /xcatd: Command log writer/) { exit 1 if ($rst); -my $xcatdport = `tabdump site 2>&1 | awk -F',' '/xcatdport/ { gsub(/"/, "", \$2) ; print \$2 }'`; +my $xcatdport = `tabdump site 2>&1 | awk -F',' '/^"xcatdport",/ { gsub(/"/, "", \$2) ; print \$2 }'`; chomp($xcatdport); probe_utils->send_msg("$output", "d", "The port used by the xcatd daemon for client/server communication is $xcatdport") if ($verbose); $msg = "xcatd is listening on port $xcatdport"; @@ -160,7 +160,7 @@ if ($?) { probe_utils->send_msg("$output", "o", "$msg"); } -my $xcatiport = `tabdump site 2>&1| awk -F',' '/xcatiport/ { gsub(/"/, "", \$2) ; print \$2 }'`; +my $xcatiport = `tabdump site 2>&1| awk -F',' '/^"xcatiport",/ { gsub(/"/, "", \$2) ; print \$2 }'`; chomp($xcatiport); probe_utils->send_msg("$output", "d", "The port used by xcatd to receive install status updates from nodes is $xcatiport") if ($verbose); $msg = "xcatd is listening on port $xcatiport"; @@ -184,7 +184,7 @@ if ($rst) { probe_utils->send_msg("$output", "o", "$msg"); } -my $masteripinsite = `tabdump site | awk -F',' '/master/ { gsub(/"/, "", \$2) ; print \$2 }'`; +my $masteripinsite = `tabdump site | awk -F',' '/^"master",/ { gsub(/"/, "", \$2) ; print \$2 }'`; chomp($masteripinsite); probe_utils->send_msg("$output", "d", "The value of 'master' in 'site' table is $masteripinsite") if ($verbose); probe_utils->send_msg("$output", "f", "There isn't 'master' definition in 'site' talbe") if ($masteripinsite eq ""); @@ -234,7 +234,7 @@ if ($hit) { } $msg = "There is domain definition in 'site' table"; -my $domain = `tabdump site | awk -F',' '/domain/ { gsub(/"/, "", \$2) ; print \$2 }'`; +my $domain = `tabdump site | awk -F',' '/^"domain",/ { gsub(/"/, "", \$2) ; print \$2 }'`; chomp($domain); if ($domain) { probe_utils->send_msg("$output", "d", "The value of 'domain' in 'site' table is $domain") if ($verbose); @@ -256,10 +256,10 @@ if ($username eq "" || $pw eq "") { probe_utils->send_msg("$output", "o", "$msg"); } -my $installdir = `tabdump site 2>&1 | awk -F',' '/installdir/ { gsub(/"/, "", \$2) ; print \$2 }'`; +my $installdir = `tabdump site 2>&1 | awk -F',' '/^"installdir"/ { gsub(/"/, "", \$2) ; print \$2 }'`; chomp($installdir); probe_utils->send_msg("$output", "d", "The 'install' directory is set to $installdir in 'site' table on current server") if ($verbose); -my $tftpdir = `tabdump site 2>&1 | awk -F',' '/tftpdir/ { gsub(/"/, "", \$2) ; print \$2 }'`; +my $tftpdir = `tabdump site 2>&1 | awk -F',' '/^"tftpdir",/ { gsub(/"/, "", \$2) ; print \$2 }'`; chomp($tftpdir); probe_utils->send_msg("$output", "d", "The 'tftp' directory is set to $tftpdir in 'site' talbe on current server") if ($verbose); From 6a18a0845105bd3678284daf60daa344a73768d1 Mon Sep 17 00:00:00 2001 From: XuWei Date: Tue, 5 Jul 2016 05:34:17 -0400 Subject: [PATCH 240/310] xcatprobe add monitoring computes.log --- xCAT-probe/subcmds/osdeploy | 208 +++++++++++++++++++++++++++--------- 1 file changed, 156 insertions(+), 52 deletions(-) diff --git a/xCAT-probe/subcmds/osdeploy b/xCAT-probe/subcmds/osdeploy index 57b0f8470..644de4003 100755 --- a/xCAT-probe/subcmds/osdeploy +++ b/xCAT-probe/subcmds/osdeploy @@ -27,11 +27,11 @@ my %monitor_nodes; $::USAGE = "Usage: $program_name -h $program_name -T - $program_name [-V] - $program_name -n + $program_name -n [-V] Description: Do probe for os provision process, realtime monitor of os provision process. + Please run this before rpower node. Options: -h : Get usage information of $program_name @@ -42,11 +42,13 @@ Options: sub check_noderange{ my $node_range = shift; - my @cmdoutput = `lsdef $node_range 2>&1`; + my @cmdoutput = `lsdef $node_range -i ip,mac 2>&1`; my $rst = 0; my $currentnode = ""; + my $ip = "NOIP"; my %nodecheckrst; - my $ip; + my $mac_line; + my @macs; foreach (@cmdoutput) { chomp($_); @@ -58,68 +60,126 @@ sub check_noderange{ } elsif ($_ =~ /^\s*Object name: (\w+)/i) { $monitor_nodes{$1} = 0; $currentnode = $1; + $ip = "NOIP"; } elsif ($_ =~ /^ip=(.+)/i) { $ip = $1; - } elsif ($_ =~ /^mac=(.+)\|(.+)!\*NOIP\*/i) { - $macmap{$1}{"ip"} = $ip; - $macmap{$2}{"ip"} = $ip; - $macmap{$1}{"node"} = $currentnode; - $macmap{$2}{"node"} = $currentnode; - } elsif ($_ =~ /^mac=(.+)\|(.+)/i) { - $macmap{$1}{"ip"} = $ip; - $macmap{$2}{"ip"} = $ip; - $macmap{$1}{"node"} = $currentnode; - $macmap{$2}{"node"} = $currentnode; } elsif ($_ =~ /^mac=(.+)/i) { - $macmap{$1}{"ip"} = $ip; - $macmap{$1}{"node"} = $currentnode; + $mac_line = $1; + @macs = split(/\|/, $mac_line); + foreach my $mac(@macs) { + if ($mac =~ /\!\*NOIP\*/) { + $mac =~ s/\!\*NOIP\*//g; + $macmap{$mac}{"ip"} = "NOIP"; + $macmap{$mac}{"node"} = $currentnode; + } + else { + $macmap{$mac}{"ip"} = $ip; + $macmap{$mac}{"node"} = $currentnode; + } + } } } foreach my $node (keys %nodecheckrst) { probe_utils->send_msg("$output", "d", "$node : $nodecheckrst{$node}{error}") if(exists($nodecheckrst{$node}{error})); } + + unless (%monitor_nodes) { + probe_utils->send_msg("$output", "d", "There is no node to be monitored"); + $rst = 1; + } return $rst; } sub handle_dhcp_msg { my $msg = shift; - if ($msg !~ /unknown lease/ && $msg !~ /ignored/ && $msg =~ /.+DHCPREQUEST\s+for\s+(.+)\s\((.+)\)\s+from\s+(.+)\s+via\s+(.+)/) { + if ($msg =~ /.+DHCPDISCOVER\s+from\s+(.+)\s+via\s+([^:]+)(.*)/i) { + my $mac = $1; + my $nic = $2; + + if (exists $macmap{$mac}) { + my $node = $macmap{$mac}{"node"}; + my $record = "Receive DHCPDISCOVER from [$node] $mac via $nic"; + probe_utils->send_msg("$output", "d", "$record"); + push(@{ $rawdata{$node}{"history"} }, $record); + } + } elsif ($msg =~ /.+DHCPOFFER\s+on\s+(.+)\s+to\s+(.+)\s+via\s+(.+)/i) { + my $ip = $1; + my $mac = $2; + my $nic = $3; + + if (exists $macmap{$mac}) { + my $node = $macmap{$mac}{"node"}; + my $record = "Send DHCPOFFER on $ip back to [$node] $mac via $nic"; + probe_utils->send_msg("$output", "d", "$record"); + push(@{ $rawdata{$node}{"history"} }, $record); + } + + } elsif ($msg !~ /unknown lease/ && $msg !~ /ignored/ && $msg =~ /.+DHCPREQUEST\s+for\s+(.+)\s\((.+)\)\s+from\s+(.+)\s+via\s+(.+)/) { my $ip = $1; my $server = $2; my $mac = $3; my $nic = $4; - my $record = "Receive DHCPREQUEST from $mac for $ip via $nic"; if (exists $macmap{$mac}) { - my $node = $macmap{$mac}{"node"}; + my $node = $macmap{$mac}{"node"}; + my $record = "Receive DHCPREQUEST from [$node] $mac for $ip via $nic"; probe_utils->send_msg("$output", "d", "$record"); push(@{ $rawdata{$node}{"history"} }, $record); - if ($macmap{$mac}{"ip"} != $ip) { - my $warn_msg = "The ip of $mac from DHCP $ip is different with definition $macmap{$mac}{'ip'}."; + if ($macmap{$mac}{"ip"} != "NOIP" and $macmap{$mac}{"ip"} != $ip) { + my $warn_msg = "The ip of [$node] $mac from DHCP $ip is different with definition $macmap{$mac}{'ip'}."; probe_utils->send_msg("$output", "w", "$warn_msg"); - if (exists($rawdata{$node})) { - push(@{ $rawdata{$node}{"history"} }, $warn_msg); - } + push(@{ $rawdata{$node}{"history"} }, $warn_msg); } } } elsif ($msg =~ /.+DHCPACK\s+on\s+(.+)\s+to\s+(.+)\s+via\s+(.+)/) { my $ip = $1; my $mac = $2; my $nic = $3; - my $record = "Send DHCPACK on $ip back to $mac via $nic"; if (exists $macmap{$mac}) { my $node = $macmap{$mac}{"node"}; - if (exists($rawdata{$node})) { - probe_utils->send_msg("$output", "d", "$record"); - push(@{ $rawdata{$node}{"history"} }, $record); + my $record = "Send DHCPACK on $ip back to [$node] $mac via $nic"; + probe_utils->send_msg("$output", "d", "$record"); + push(@{ $rawdata{$node}{"history"} }, $record); + if ($macmap{$mac}{"ip"} != "NOIP") { $ipnodemap{$ip} = $node; } } + } elsif ($msg =~ /.+BOOTREQUEST\s+from\s+(.+)\s+via\s+([^:]+)(.*)/) { + my $mac = $1; + my $nic = $2; + + if (exists $macmap{$mac}) { + my $node = $macmap{$mac}{"node"}; + my $record = "Receive BOOTREQUEST from [$node] $mac via $nic"; + probe_utils->send_msg("$output", "d", "$record"); + push(@{ $rawdata{$node}{"history"} }, $record); + } + } elsif ($msg =~ /.+BOOTREPLY\s+for\s+(.+)\s+to\s+.+(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w).+via\s+(.+)/) { + my $ip = $1; + my $mac = $2; + my $nic = $3; + + if (exists $macmap{$mac}) { + my $node = $macmap{$mac}{"node"}; + my $record = "Send BOOTREPLY on $ip back to [$node] $mac via $nic"; + probe_utils->send_msg("$output", "d", "$record"); + push(@{ $rawdata{$node}{"history"} }, $record); + if ($macmap{$mac}{"ip"} != "NOIP") { + $ipnodemap{$ip} = $node; + } + + if ($macmap{$mac}{"ip"} != "NOIP" and $macmap{$mac}{"ip"} != $ip) { + my $warn_msg = "The ip of [$node] $mac from DHCP $ip is different with definition $macmap{$mac}{'ip'}."; + probe_utils->send_msg("$output", "w", "$warn_msg"); + push(@{ $rawdata{$node}{"history"} }, $warn_msg); + } + } } + return 0; } @@ -128,7 +188,7 @@ sub handle_http_msg { if ($msg =~ /(\d+\.\d+.\d+.\d+)\s.+GET\s+(.+)\s+HTTP.+/) { my $ip = $1; my $file = $2; - my $record = "Via HTTP $ip download $file"; + my $record = "[$ipnodemap{$ip}] Via HTTP $ip GET $file"; if (exists($rawdata{"$ipnodemap{$ip}"})) { probe_utils->send_msg("$output", "d", "$record"); @@ -145,7 +205,7 @@ sub handle_cluster_msg { my $msg; my $status; - if ($line =~ /.+\d+:\d+:\d+\s+(.+)\s+(xcat.+)/i) { + if ($line =~ /.+\d{2}:\d{2}:\d{2}\s+(.+)\s+(xcat.+)/i) { $sender = $1; $msg = $2; @@ -155,7 +215,7 @@ sub handle_cluster_msg { $node = $ipnodemap{$sender}; } if ($node ne "" && exists($rawdata{$node})) { - my $record = "Recv from $node : $msg"; + my $record = "Receive from $node : $msg"; probe_utils->send_msg("$output", "d", "$record"); push(@{ $rawdata{ $node }{"history"} }, $record); } @@ -166,7 +226,7 @@ sub handle_cluster_msg { $status = $2; if (exists($rawdata{$node})) { - my $record = "Recv from $node : xcat: status is $status"; + my $record = "Receive from $node : status is $status"; probe_utils->send_msg("$output", "d", "$record"); push(@{ $rawdata{ $node }{"history"} }, $record); } @@ -174,11 +234,39 @@ sub handle_cluster_msg { if (exists($rawdata{$node}) and ($status eq "booted")) { $monitor_nodes{$node} = 1 if (defined($monitor_nodes{$node})); probe_utils->send_msg("$output", "o", "Node $node has finished it's os provision process"); + } elsif (exists($rawdata{$node}) and ($status eq "failed")) { + $monitor_nodes{$node} = 1 if (defined($monitor_nodes{$node})); + probe_utils->send_msg("$output", "f", "Node $node has finished it's os provision process"); } } return 0; } +sub handle_compute_msg { + my $line = shift; + my $sender; + my $node; + my $msg; + + if ($line =~ /.+\d{2}:\d{2}:\d{2}\s+(.+)\s+(xcat.+)/i) { + $sender = $1; + $msg = $2; + + if (!xCAT::NetworkUtils->isIpaddr($sender)) { + $node = $sender; + } else { + $node = $ipnodemap{$sender}; + } + if ($node ne "" && exists($rawdata{$node})) { + my $record = "Receive from $node : $msg"; + probe_utils->send_msg("$output", "d", "$record"); + push(@{ $rawdata{ $node }{"history"} }, $record); + } + } + + return 0; +} + sub all_monitor_node_done { my $done = 1; foreach my $node (keys %monitor_nodes) { @@ -211,6 +299,7 @@ sub dump_history { } } foreach my $line (@{ $rawdata{$node}{"history"} }) { + # Print http message less than 10 lines if ($line =~ /Via HTTP/) { if (($http_num <= 4) or ($length_http - $line_num <= 4)){ @@ -245,7 +334,7 @@ sub do_monitor{ } if (!$nics) { - my $masteripinsite = `tabdump site | awk -F',' '/master/ { gsub(/"/, "", \$2) ; print \$2 }'`; + my $masteripinsite = `tabdump site | awk -F',' '/^"master",/ { gsub(/"/, "", \$2) ; print \$2 }'`; chomp($masteripinsite); $nics = `ip addr |grep -B2 $masteripinsite|awk -F" " '/mtu/{gsub(/:/,"",\$2); print \$2}'`; chomp($nics); @@ -256,8 +345,14 @@ sub do_monitor{ } my $rst = 0; - my $startline = "------------------------------------------------------------- -Start to capture every message during os provision process...... + my $startline = " +------------------------------------------------------------- + ___ + ____ _ _____ _.-| | |\\__/,| (`\\ + __ __/ ___| / \\|_ _| { | | |x x |__ _) ) + \\ \\/ / | / _ \\ | | \"-.|___| _.( T ) ` / + > <| |___ / ___ \\| | .--'-`-. _((_ `^--' /_< \\ + /_/\\_\\\\____/_/ \\_\\_| .+|______|__.-||__)`-'(((/ (((/ ------------------------------------------------------------- "; @@ -265,6 +360,7 @@ Start to capture every message during os provision process...... my $varlogmsg = "/var/log/messages"; my $clusterlog = "/var/log/xcat/cluster.log"; + my $computelog = "/var/log/xcat/computes.log"; my $httplog; if (-e "/var/log/httpd/access_log") { @@ -278,58 +374,58 @@ Start to capture every message during os provision process...... my $varlogpid; my $clusterpid; my $httppid; + my $computerpid; - if (!($varlogpid = open(VARLOGMSGFILE, "tail -f $varlogmsg 2>&1 |"))) { + if (!($varlogpid = open(VARLOGMSGFILE, "tail -f -n 0 $varlogmsg 2>&1 |"))) { probe_utils->send_msg("$output", "f", "Can't open $varlogmsg to get logs"); $rst = 1; last; } - if (!($clusterpid = open(CLUSTERLOGFILE, "tail -f $clusterlog 2>&1 |"))) { + if (!($clusterpid = open(CLUSTERLOGFILE, "tail -f -n 0 $clusterlog 2>&1 |"))) { probe_utils->send_msg("$output", "f", "Can't open $clusterlog to get logs"); $rst = 1; last; } - if (!($httppid = open(HTTPLOGFILE, "tail -f $httplog 2>&1 |"))) { + if (!($httppid = open(HTTPLOGFILE, "tail -f -n 0 $httplog 2>&1 |"))) { probe_utils->send_msg("$output", "f", "Can't open $httplog to get logs"); $rst = 1; last; } + if (!($computerpid = open(COMPUTERFILE, "tail -f -n 0 $computelog 2>&1 |"))) { + probe_utils->send_msg("$output", "f", "Can't open $computelog to get logs"); + $rst = 1; + last; + } my $select = new IO::Select; $select->add(\*VARLOGMSGFILE); $select->add(\*CLUSTERLOGFILE); $select->add(\*HTTPLOGFILE); + $select->add(\*COMPUTERFILE); $| = 1; my $line = ""; my @hdls; my $hdl; - my $oldlines = 10; - my $varlogmsgcnt = 0; - my $clusterlogcnt = 0; - my $httplogcnt = 0; for (; ;){ if (@hdls = $select->can_read(0)) { foreach $hdl (@hdls) { if ($hdl == \*VARLOGMSGFILE) { chomp($line = ); - ++$varlogmsgcnt; - last if ($varlogmsgcnt <= $oldlines); my @tmp = split(/\s+/, $line); if ($tmp[4] =~ /dhcpd:/i && $line =~ /$nics/) { handle_dhcp_msg("$line"); } } elsif ($hdl == \*CLUSTERLOGFILE) { chomp($line = ); - ++$clusterlogcnt; - last if ($clusterlogcnt <= $oldlines); handle_cluster_msg("$line"); } elsif ($hdl == \*HTTPLOGFILE) { chomp($line = ); - ++$httplogcnt; - last if ($httplogcnt <= $oldlines); handle_http_msg("$line"); + } elsif ($hdl == \*COMPUTERFILE) { + chomp($line = ); + handle_compute_msg("$line"); } } } @@ -345,12 +441,14 @@ Start to capture every message during os provision process...... } &dump_history; - kill 'INT', $varlogpid if ($varlogpid); + kill 'INT', $varlogpid if ($varlogpid); kill 'INT', $clusterpid if ($clusterpid); kill 'INT', $httppid if ($httppid); - close(VARLOGMSGFILE) if (VARLOGMSGFILE); - close(CLUSTERLOGFILE) if(CLUSTERLOGFILE); - close(HTTPLOGFILE) if(HTTPLOGFILE); + kill 'INT', $computerpid if ($computerpid); + close(VARLOGMSGFILE) if (VARLOGMSGFILE); + close(CLUSTERLOGFILE) if (CLUSTERLOGFILE); + close(HTTPLOGFILE) if (HTTPLOGFILE); + close(COMPUTERFILE) if (COMPUTERFILE); return $rst; } @@ -383,6 +481,12 @@ if ($test) { exit 0; } +unless ( $noderange ) { + probe_utils->send_msg("$output", "f", "Option -n is required"); + probe_utils->send_msg("$output", "d", "$::USAGE"); + exit 1; +} + $rst = do_monitor(); exit $rst; From cf9636ae45b616f445701368bb2462539b08a579 Mon Sep 17 00:00:00 2001 From: bybai Date: Wed, 6 Jul 2016 03:36:16 -0400 Subject: [PATCH 241/310] fix 1327 after pessl kitcomponents are removed from osimage, the INCLUDE env file for pessl are not cleaned up. --- xCAT-server/lib/xcat/plugins/kit.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index 9188ca729..74f1c3e78 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -3205,7 +3205,7 @@ sub rmkitcomp #check if the parameter is used by other kitcomponent foreach my $otherline ( @otherlines ) { chomp $otherline; - if ( $line =~ m!$otherline! ) { + if ( $otherline && $line =~ m!$otherline! ) { $found = 1; last; } @@ -3216,7 +3216,7 @@ sub rmkitcomp } else { foreach my $content ( @contents ) { chomp $content; - if ( $line =~ m!$content! ) { + if ( $content && $line =~ m!$content! ) { $found = 1; last; } From e80517eb6e009406d526f44bda0aaa7c00f947c2 Mon Sep 17 00:00:00 2001 From: ertaozh Date: Wed, 6 Jul 2016 06:20:18 -0400 Subject: [PATCH 242/310] modify the pattern for xcat.discovery.xxx from MTMS to mac address --- xCAT-server/lib/xcat/plugins/aaadiscovery.pm | 20 +++++++++++++++++- xCAT-server/lib/xcat/plugins/blade.pm | 6 +++--- xCAT-server/lib/xcat/plugins/hpblade.pm | 6 +++--- xCAT-server/lib/xcat/plugins/seqdiscovery.pm | 10 ++++----- xCAT-server/lib/xcat/plugins/switch.pm | 22 ++++---------------- xCAT-server/lib/xcat/plugins/typemtms.pm | 8 +++---- xCAT-server/lib/xcat/plugins/zzzdiscovery.pm | 6 +++--- 7 files changed, 41 insertions(+), 37 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/aaadiscovery.pm b/xCAT-server/lib/xcat/plugins/aaadiscovery.pm index 13ae57055..479945a44 100644 --- a/xCAT-server/lib/xcat/plugins/aaadiscovery.pm +++ b/xCAT-server/lib/xcat/plugins/aaadiscovery.pm @@ -25,8 +25,26 @@ sub process_request { $cb->($rsp); return; } - xCAT::MsgUtils->message("S", "xcat.discovery.aaadiscovery: ($req->{mtm}->[0]*$req->{serial}->[0]) Get a discover request"); + my $client_ip = $req->{'_xcat_clientip'}; + my $arptable; + if ( -x "/usr/sbin/arp") { + $arptable = `/usr/sbin/arp -n`; + } + else{ + $arptable = `/sbin/arp -n`; + } + my @arpents = split /\n/,$arptable; + my $mac = "$req->{mtm}->[0]*$req->{serial}->[0]"; + foreach (@arpents) { + if (m/^($client_ip)\s+\S+\s+(\S+)\s/) { + $mac=$2; + last; + } + } + + xCAT::MsgUtils->message("S", "xcat.discovery.aaadiscovery: ($mac) Get a discover request"); $req->{discoverymethod}->[0] = 'undef'; + $req->{_xcat_clientmac}->[0] = $mac; xCAT::DiscoveryUtils->update_discovery_data($req); return; } diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index 088bd09ac..3e651c41b 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -4375,7 +4375,7 @@ sub process_request { return; } - xCAT::MsgUtils->message("S", "xcat.discovery.blade: ($request->{mtm}->[0]*$request->{serial}->[0]) Processing discovery request"); + xCAT::MsgUtils->message("S", "xcat.discovery.blade: ($request->{_xcat_clientmac}->[0]) Processing discovery request"); my $mptab = xCAT::Table->new("mp"); unless ($mptab) { return 2; } my @bladents = $mptab->getAllNodeAttribs([qw(node)]); @@ -4454,7 +4454,7 @@ sub process_request { } } unless ($node) { - xCAT::MsgUtils->message("S", "xcat.discovery.blade: ($request->{mtm}->[0]*$request->{serial}->[0]) Error: Could not find any node"); + xCAT::MsgUtils->message("S", "xcat.discovery.blade: ($request->{_xcat_clientmac}->[0]) Error: Could not find any node"); return 1; #failure } if ($request->{mtm} and $request->{mtm} =~ /^(\w{4})/) { @@ -4470,7 +4470,7 @@ sub process_request { undef $mactab; } - xCAT::MsgUtils->message("S", "xcat.discovery.blade: ($request->{mtm}->[0]*$request->{serial}->[0]) Find node $node for the discovery request"); + xCAT::MsgUtils->message("S", "xcat.discovery.blade: ($request->{_xcat_clientmac}->[0]) Find node $node for the discovery request"); #my %request = ( # command => ['makedhcp'], # node => [$macmap{$mac}] diff --git a/xCAT-server/lib/xcat/plugins/hpblade.pm b/xCAT-server/lib/xcat/plugins/hpblade.pm index e6cd569ff..12cd8fe17 100755 --- a/xCAT-server/lib/xcat/plugins/hpblade.pm +++ b/xCAT-server/lib/xcat/plugins/hpblade.pm @@ -689,7 +689,7 @@ sub process_request { # The findme request had been processed by other module, just return return; } - xCAT::MsgUtils->message("S", "xcat.discovery.hpblade: ($request->{mtm}->[0]*$request->{serial}->[0]) Processing discovery request"); + xCAT::MsgUtils->message("S", "xcat.discovery.hpblade: ($request->{_xcat_clientmac}->[0]) Processing discovery request"); my $mptab = xCAT::Table->new("mp"); unless ($mptab) { return 2; } my @bladents = $mptab->getAllNodeAttribs([qw(node)]); @@ -733,7 +733,7 @@ sub process_request { } } unless ($macmap{$mac}) { - xCAT::MsgUtils->message("S", "xcat.discovery.hpblade: ($request->{mtm}->[0]*$request->{serial}->[0]) Error: Could not find any node"); + xCAT::MsgUtils->message("S", "xcat.discovery.hpblade: ($request->{_xcat_clientmac}->[0]) Error: Could not find any node"); return 1; #failure } # The discovered command will update mac table, no need to update here @@ -745,7 +745,7 @@ sub process_request { # node => [$macmap{$mac}] # ); #$doreq->(\%request); - xCAT::MsgUtils->message("S", "xcat.discovery.hpblade: ($request->{mtm}->[0]*$request->{serial}->[0]) Find node:$macmap{$mac} for the discovery request"); + xCAT::MsgUtils->message("S", "xcat.discovery.hpblade: ($request->{_xcat_clientmac}->[0]) Find node:$macmap{$mac} for the discovery request"); my $req={%$request}; $req->{command}=['discovered']; $req->{noderange} = [$macmap{$mac}]; diff --git a/xCAT-server/lib/xcat/plugins/seqdiscovery.pm b/xCAT-server/lib/xcat/plugins/seqdiscovery.pm index 96735ecf2..aae688064 100755 --- a/xCAT-server/lib/xcat/plugins/seqdiscovery.pm +++ b/xCAT-server/lib/xcat/plugins/seqdiscovery.pm @@ -63,7 +63,7 @@ sub findme { } # do the sequential discovery - xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{mtm}->[0]*$request->{serial}->[0]) Processing discovery request"); + xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{_xcat_clientmac}->[0]) Processing discovery request"); # Get the parameters for the sequential discovery my %param; @@ -76,7 +76,7 @@ sub findme { my $mac; my $ip = $request->{'_xcat_clientip'}; if (defined $request->{nodetype} and $request->{nodetype}->[0] eq 'virtual') { - xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{mtm}->[0]*$request->{serial}->[0]) Error: virtual machines is not supported"); + xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{_xcat_clientmac}->[0]) Error: virtual machines is not supported"); return; } my $arptable; @@ -96,7 +96,7 @@ sub findme { } unless ($mac) { - xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{mtm}->[0]*$request->{serial}->[0]) Error: Could not find mac of the $ip"); + xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{_xcat_clientmac}->[0]) Error: Could not find mac of the $ip"); return; } @@ -373,7 +373,7 @@ sub findme { # call the discovered command to update the discovery request to a node - xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{mtm}->[0]*$request->{serial}->[0]) Find node:$node for the discovery request"); + xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{_xcat_clientmac}->[0]) Find node:$node for the discovery request"); $request->{discoverymethod} = ['sequential']; my $req = {%$request}; $req->{command}=['discovered']; @@ -386,7 +386,7 @@ sub findme { undef $mactab; } else { nodediscoverstop($callback, undef, "node names"); - xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{mtm}->[0]*$request->{serial}->[0]) Error: Could not find any node"); + xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{_xcat_clientmac}->[0]) Error: Could not find any node"); return; } diff --git a/xCAT-server/lib/xcat/plugins/switch.pm b/xCAT-server/lib/xcat/plugins/switch.pm index ed2719eed..9f1d53a7c 100644 --- a/xCAT-server/lib/xcat/plugins/switch.pm +++ b/xCAT-server/lib/xcat/plugins/switch.pm @@ -277,8 +277,8 @@ sub process_request { # The findme request had been processed by other module, just return return; } - xCAT::MsgUtils->message("S", "xcat.discovery.switch: ($req->{mtm}->[0]*$req->{serial}->[0]) Processing discovery request"); - my $ip = $req->{'_xcat_clientip'}; + $mac = $req->{_xcat_clientmac}->[0]; + xCAT::MsgUtils->message("S", "xcat.discovery.switch: ($mac) Processing discovery request"); if (defined $req->{nodetype} and $req->{nodetype}->[0] eq 'virtual') { #Don't attempt switch discovery of a VM Guest #TODO: in this case, we could/should find the host system @@ -288,20 +288,6 @@ sub process_request { #discovery working. Food for thought. return; } - my $arptable; - if ( -x "/usr/sbin/arp") { - $arptable = `/usr/sbin/arp -n`; - } - else{ - $arptable = `/sbin/arp -n`; - } - my @arpents = split /\n/,$arptable; - foreach (@arpents) { - if (m/^($ip)\s+\S+\s+(\S+)\s/) { - $mac=$2; - last; - } - } my $firstpass=1; if ($mac) { $node = $macmap->find_mac($mac,$req->{cacheonly}->[0]); @@ -327,7 +313,7 @@ sub process_request { } if ($node) { - xCAT::MsgUtils->message("S", "xcat.discovery.switch: ($req->{mtm}->[0]*$req->{serial}->[0]) Find node:$node for the discovery request"); + xCAT::MsgUtils->message("S", "xcat.discovery.switch: ($req->{_xcat_clientmac}->[0]) Find node:$node for the discovery request"); # No need to write mac table here, 'discovered' command will write # my $mactab = xCAT::Table->new('mac',-create=>1); # $mactab->setNodeAttribs($node,{mac=>$mac}); @@ -346,7 +332,7 @@ sub process_request { %{$request}=();#Clear req structure, it's done.. undef $mactab; } else { - xCAT::MsgUtils->message("S", "xcat.discovery.switch: ($req->{mtm}->[0]*$req->{serial}->[0]) Error: Could not find any node"); + xCAT::MsgUtils->message("S", "xcat.discovery.switch: ($req->{_xcat_clientmac}->[0]) Error: Could not find any node"); } } } diff --git a/xCAT-server/lib/xcat/plugins/typemtms.pm b/xCAT-server/lib/xcat/plugins/typemtms.pm index 8a9b350f4..c1c1226df 100644 --- a/xCAT-server/lib/xcat/plugins/typemtms.pm +++ b/xCAT-server/lib/xcat/plugins/typemtms.pm @@ -22,7 +22,7 @@ sub findme { } my @attr_array = (); my $mtms = $request->{'mtm'}->[0]."*".$request->{'serial'}->[0]; - xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($mtms) Processing discovery request"); + xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($request->{_xcat_clientmac}->[0]) Processing discovery request"); my $tmp_nodes = $::XCATVPDHASH{$mtms}; my @nodes = (); my $bmc_node; @@ -35,14 +35,14 @@ sub findme { } my $nodenum = $#nodes; if ($nodenum < 0) { - xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($mtms) Error: Could not find any node"); + xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($request->{_xcat_clientmac}->[0]) Error: Could not find any node"); return; } elsif ($nodenum > 0) { - xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($mtms) Error: More than one node were found"); + xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($request->{_xcat_clientmac}->[0]) Error: More than one node were found"); return; } { - xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($mtms) Find node:$nodes[0] for the discovery request"); + xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($request->{_xcat_clientmac}->[0]) Find node:$nodes[0] for the discovery request"); $request->{discoverymethod}->[0] = 'mtms'; my $req = {%$request}; $req->{command} = ['discovered']; diff --git a/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm b/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm index a39f2344f..71b804829 100644 --- a/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm +++ b/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm @@ -17,15 +17,15 @@ sub process_request { my $cb = shift; my $doreq = shift; if ($req->{command}->[0] eq 'findme') { - xCAT::MsgUtils->message("S", "xcat.discovery.zzzdiscovery: ($req->{mtm}->[0]*$req->{serial}->[0]) Finish to process the discovery request"); + xCAT::MsgUtils->message("S", "xcat.discovery.zzzdiscovery: ($req->{_xcat_clientmac}->[0]) Finish to process the discovery request"); if (!defined($req->{discoverymethod}) or !defined($req->{discoverymethod}->[0]) or ($req->{discoverymethod}->[0] eq 'undef')) { my $rsp = {}; $rsp->{error}->[0] = "The discovery request can not be processed"; $cb->($rsp); - xCAT::MsgUtils->message("S", "xcat.discovery.zzzdiscovery: ($req->{mtm}->[0]*$req->{serial}->[0]) Failed to be processed"); + xCAT::MsgUtils->message("S", "xcat.discovery.zzzdiscovery: ($req->{_xcat_clientmac}->[0]) Failed to be processed"); return; } - xCAT::MsgUtils->message("S", "xcat.discovery.zzzdiscovery: ($req->{mtm}->[0]*$req->{serial}->[0]) Successfully processed by $req->{discoverymethod}->[0] method"); + xCAT::MsgUtils->message("S", "xcat.discovery.zzzdiscovery: ($req->{_xcat_clientmac}->[0]) Successfully processed by $req->{discoverymethod}->[0] method"); return; } } From b2280b469bce441bcc90a2491a506b89c16cc604 Mon Sep 17 00:00:00 2001 From: XuWei Date: Wed, 6 Jul 2016 22:43:05 -0400 Subject: [PATCH 243/310] fix bug, update ipnodemap --- xCAT-probe/subcmds/osdeploy | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/xCAT-probe/subcmds/osdeploy b/xCAT-probe/subcmds/osdeploy index 644de4003..9cfecd7b7 100755 --- a/xCAT-probe/subcmds/osdeploy +++ b/xCAT-probe/subcmds/osdeploy @@ -144,9 +144,7 @@ sub handle_dhcp_msg { my $record = "Send DHCPACK on $ip back to [$node] $mac via $nic"; probe_utils->send_msg("$output", "d", "$record"); push(@{ $rawdata{$node}{"history"} }, $record); - if ($macmap{$mac}{"ip"} != "NOIP") { - $ipnodemap{$ip} = $node; - } + $ipnodemap{$ip} = $node; } } elsif ($msg =~ /.+BOOTREQUEST\s+from\s+(.+)\s+via\s+([^:]+)(.*)/) { my $mac = $1; @@ -168,9 +166,7 @@ sub handle_dhcp_msg { my $record = "Send BOOTREPLY on $ip back to [$node] $mac via $nic"; probe_utils->send_msg("$output", "d", "$record"); push(@{ $rawdata{$node}{"history"} }, $record); - if ($macmap{$mac}{"ip"} != "NOIP") { - $ipnodemap{$ip} = $node; - } + $ipnodemap{$ip} = $node; if ($macmap{$mac}{"ip"} != "NOIP" and $macmap{$mac}{"ip"} != $ip) { my $warn_msg = "The ip of [$node] $mac from DHCP $ip is different with definition $macmap{$mac}{'ip'}."; From 7ac29379b087aa159afeb0d3d7c7f31e9aa17a46 Mon Sep 17 00:00:00 2001 From: Samveen Gulati Date: Thu, 7 Jul 2016 03:48:25 +0000 Subject: [PATCH 244/310] xCAT-server: Fix exclude list for RH7 - Vim >= 7.4 --- xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.exlist | 2 +- xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.exlist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.exlist b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.exlist index ccad8b8c8..cdef4819d 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.exlist +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.exlist @@ -28,7 +28,7 @@ ./usr/share/man* ./usr/share/omf* ./usr/share/vim/site/doc* -./usr/share/vim/vim72/doc* +./usr/share/vim/vim74/doc* ./usr/share/zoneinfo* ./var/cache/man* ./var/lib/yum* diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.exlist b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.exlist index ccad8b8c8..cdef4819d 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.exlist +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.exlist @@ -28,7 +28,7 @@ ./usr/share/man* ./usr/share/omf* ./usr/share/vim/site/doc* -./usr/share/vim/vim72/doc* +./usr/share/vim/vim74/doc* ./usr/share/zoneinfo* ./var/cache/man* ./var/lib/yum* From e12eea4a8b7c2a48f77d16e425aac2fb90612b41 Mon Sep 17 00:00:00 2001 From: XuWei Date: Thu, 7 Jul 2016 00:35:51 -0400 Subject: [PATCH 245/310] fix issue 1494 modified osdeploy message --- xCAT-probe/subcmds/osdeploy | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/xCAT-probe/subcmds/osdeploy b/xCAT-probe/subcmds/osdeploy index 9cfecd7b7..e2a2e10ba 100755 --- a/xCAT-probe/subcmds/osdeploy +++ b/xCAT-probe/subcmds/osdeploy @@ -341,18 +341,13 @@ sub do_monitor{ } my $rst = 0; - my $startline = " -------------------------------------------------------------- - ___ - ____ _ _____ _.-| | |\\__/,| (`\\ - __ __/ ___| / \\|_ _| { | | |x x |__ _) ) - \\ \\/ / | / _ \\ | | \"-.|___| _.( T ) ` / - > <| |___ / ___ \\| | .--'-`-. _((_ `^--' /_< \\ - /_/\\_\\\\____/_/ \\_\\_| .+|______|__.-||__)`-'(((/ (((/ + my $startline = +"------------------------------------------------------------- +Start to capture every message during os provision process...... ------------------------------------------------------------- "; - probe_utils->send_msg("$output", "d", "$startline"); + print("$startline\n"); my $varlogmsg = "/var/log/messages"; my $clusterlog = "/var/log/xcat/cluster.log"; From f66297abc5c9604d96b1151fed5894f75a837b3e Mon Sep 17 00:00:00 2001 From: wangxiaopeng Date: Thu, 7 Jul 2016 03:52:01 -0400 Subject: [PATCH 246/310] issue 1493, we made a change that include the updateflag from /install/postscripts/updateflag.awk. But the shebang in /install/postscripts/updateflag.awk points to the /usr/bin/awk which does not exist in sles11.x installer. This fix is to make a link to the installer shipped awk. --- xCAT-server/share/xcat/install/scripts/chroot.sles | 12 +++++++----- xCAT-server/share/xcat/install/scripts/pre.sles | 4 +++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/xCAT-server/share/xcat/install/scripts/chroot.sles b/xCAT-server/share/xcat/install/scripts/chroot.sles index 0e3d65c95..b8f4ce36a 100644 --- a/xCAT-server/share/xcat/install/scripts/chroot.sles +++ b/xCAT-server/share/xcat/install/scripts/chroot.sles @@ -22,19 +22,21 @@ fi AWK=`find / -name awk | head -1` #old awk /mounts/instsys/bin/awk -f - +if [ ! -e /usr/bin/awk ]; then + ln -s $AWK /usr/bin/awk +fi XCATDPORT=#TABLE:site:key=xcatiport:value# XCATDHOST="#XCATVAR:XCATMASTER#" -(cat >/tmp/updateflag.awk << 'EOF' +(cat >/tmp/updateflag << 'EOF' #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/updateflag.awk# EOF -) >/tmp/updateflag.awk +) >/tmp/updateflag -chmod 755 /tmp/updateflag.awk +chmod 755 /tmp/updateflag -/tmp/updateflag.awk $XCATDHOST $XCATDPORT +/tmp/updateflag $XCATDHOST $XCATDPORT export PRINIC=#TABLEBLANKOKAY:noderes:THISNODE:primarynic# if [ "$PRINIC" == "mac" ] diff --git a/xCAT-server/share/xcat/install/scripts/pre.sles b/xCAT-server/share/xcat/install/scripts/pre.sles index cccf88a3c..21b2c6de7 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.sles +++ b/xCAT-server/share/xcat/install/scripts/pre.sles @@ -18,7 +18,9 @@ fi AWK=`find / -name awk | tail -1` #old awk /mounts/instsys/bin/awk -f - +if [ ! -e /usr/bin/awk ]; then + ln -s $AWK /usr/bin/awk +fi XCATDPORT=#TABLE:site:key=xcatiport:value# XCATDHOST="#XCATVAR:XCATMASTER#" From 03d26341f3ff0889712a38f8733849fa3d64a84d Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Thu, 7 Jul 2016 03:59:55 -0400 Subject: [PATCH 247/310] refine discovery probe code --- xCAT-probe/subcmds/discovery | 91 ++++++++++++++++++++++-------------- 1 file changed, 56 insertions(+), 35 deletions(-) diff --git a/xCAT-probe/subcmds/discovery b/xCAT-probe/subcmds/discovery index 9192114d1..0bfe2a9e5 100755 --- a/xCAT-probe/subcmds/discovery +++ b/xCAT-probe/subcmds/discovery @@ -287,11 +287,11 @@ sub dhcp_dynamic_range_check { my $rst = 0; my $dhcpconfig; - if (-e "/etc/dhcp/dhcpd.conf"){ + if (-e "/etc/dhcp/dhcpd.conf") { $dhcpconfig = "/etc/dhcp/dhcpd.conf"; - } elsif (-e "/etc/dhcp3/dhcpd.conf"){ + } elsif (-e "/etc/dhcp3/dhcpd.conf") { $dhcpconfig = "/etc/dhcp3/dhcpd.conf"; - } + } unless ($dhcpconfig) { probe_utils->send_msg("$output", "d", "Cannot find the dhcpd.conf file.") if ($verbose); @@ -303,13 +303,13 @@ sub dhcp_dynamic_range_check { my $dynamic_range; my %subnet_hash; - unless (open (FILE, $dhcpconfig)) { + unless (open(FILE, $dhcpconfig)) { probe_utils->send_msg("$output", "d", "Cannot open file $dhcpconfig.") if ($verbose); - ($net_ip, $net_mask) = split ('/', $net); + ($net_ip, $net_mask) = split('/', $net); return 1; } - while ($config_line = ) { + while ($config_line = ) { chomp($config_line); $config_line =~ s/^\s+|\s+$//g; @@ -319,8 +319,8 @@ sub dhcp_dynamic_range_check { } if ($config_line =~ /subnet_end/) { $subnet_hash{$subnet} = $dynamic_range if ($dynamic_range); - $subnet = ""; - $dynamic_range = ""; + $subnet = ""; + $dynamic_range = ""; } if ($config_line =~ /^range dynamic-bootp (\d+.\d+.\d+.\d+) (\d+.\d+.\d+.\d+)/) { $dynamic_range = "$1-$2"; @@ -335,13 +335,14 @@ sub dhcp_dynamic_range_check { chomp($arch); my $tftpdir = `lsdef -t site -i tftpdir -c | awk -F "=" '{print \$2}'`; chomp($tftpdir); + unless ($tftpdir) { - $tftpdir = "/tftpboot"; + $tftpdir = "/tftpboot"; } - foreach my $net (@$nets){ + foreach my $net (@$nets) { - if ( !exists($subnet_hash{$net})) { + if (!exists($subnet_hash{$net})) { probe_utils->send_msg("$output", "d", "The net $net is not matched.") if ($verbose); $rst = 1; next; @@ -355,12 +356,12 @@ sub dhcp_dynamic_range_check { next; } - ($net_ip, $net_mask) = split ('/', $net); + ($net_ip, $net_mask) = split('/', $net); $net_cdir = xCAT::NetworkUtils::formatNetmask($net_mask, 0, 1); if ($arch =~ /ppc64/i) { - $net_file = "$tftpdir/pxelinux.cfg/p/$net_ip"."_$net_cdir"; + $net_file = "$tftpdir/pxelinux.cfg/p/$net_ip" . "_$net_cdir"; } else { - $net_file = "$tftpdir/xcat/xnba/nets/$net_ip"."_$net_cdir.uefi"; + $net_file = "$tftpdir/xcat/xnba/nets/$net_ip" . "_$net_cdir.uefi"; } if (-e "$net_file") { @@ -533,7 +534,11 @@ sub handle_compute_msg { my @splitline = split(/\s+/, $line); if (($splitline[4] =~ /^xcat/i) || ($splitline[5] =~ /^xcat/i)) { $sender = $splitline[3]; - splice(@splitline, 0, 5); + if (($splitline[4] =~ /^xcat/i) && ($splitline[5] !~ /^xcat/i)) { + splice(@splitline, 0, 4); + } else { + splice(@splitline, 0, 5); + } $msg = join(" ", @splitline); if (!xCAT::NetworkUtils->isIpaddr($sender)) { @@ -580,19 +585,22 @@ sub handle_cluster_msg { my $ip = ""; my $msg; - if ($line =~ /.+\d+:\d+:\d+\s+(.+)\s+(xcat.+)/i) { - $sender = $1; - $msg = $2; - - if (!xCAT::NetworkUtils->isIpaddr($sender)) { - $ip = xCAT::NetworkUtils->getipaddr($sender); - } else { - $ip = $sender; - } - if ($ip ne "" && defined($ipmacmap{$ip})) { - my $record = "Recv from $ip : $msg"; - probe_utils->send_msg("$output", "d", "$record"); - push(@{ $rawdata{ $ipmacmap{$ip} }{"history"} }, $record); + my @splitline = split(/\s+/, $line); + if (($splitline[4] =~ /^xcat/i) || ($splitline[5] =~ /^xcat/i)) { + if (($splitline[5] =~ /^xcat.discovery/i) && ($splitline[6] =~ /^\((.+)\)$/)) { + my $mac = $1; + if (xCAT::NetworkUtils->isValidMAC($mac) && defined($rawdata{$mac})) { + splice(@splitline, 0, 5); + splice(@splitline, 1, 1); + $msg = join(" ", @splitline); + if (defined($rawdata{$mac}{"ip"})) { + $record = "Recv from $rawdata{$mac}{ip} : $msg"; + } else { + $record = "Recv from $mac : $msg"; + } + probe_utils->send_msg("$output", "d", "$record"); + push(@{ $rawdata{$mac}{"history"} }, $record); + } } } return 0; @@ -890,7 +898,7 @@ sub do_monitor { $SIG{TERM} = $SIG{INT} = sub { $terminal = 1; }; - + if (!$nics) { my $masteripinsite = `tabdump site | awk -F',' '/^"master",/ { gsub(/"/, "", \$2) ; print \$2 }'`; chomp($masteripinsite); @@ -933,8 +941,21 @@ sub do_monitor { my $computerpid; my $varlogpid; my $rst = 0; - { #important to hold a block - # start ot obtain logs from every log file + { #important to hold a block + if(! -e "$varlogmsg"){ + probe_utils->send_msg("$output", "w", "$varlogmsg doesn't exist"); + } + if(! -e "$clusterlog"){ + probe_utils->send_msg("$output", "w", "$clusterlog doesn't exist"); + } + if(! -e "$computelog"){ + probe_utils->send_msg("$output", "w", "$computelog doesn't exist"); + } + if(! -e "$httplog"){ + probe_utils->send_msg("$output", "w", "$httplog doesn't exist"); + } + + # start ot obtain logs from every log file if (!($varlogpid = open(VARLOGMSGFILE, "tail -f -n 0 $varlogmsg 2>&1 |"))) { probe_utils->send_msg("$output", "f", "Can't open $varlogmsg to get logs"); $rst = 1; @@ -967,7 +988,6 @@ sub do_monitor { my @hdls; my $hdl; for (; ;) { - if (@hdls = $select->can_read(0)) { foreach $hdl (@hdls) { if ($hdl == \*VARLOGMSGFILE) { @@ -998,7 +1018,8 @@ sub do_monitor { probe_utils->send_msg("$output", "o", "All nodes need to monitor have finished discovery process"); } last; - } sleep 0.01; + } + sleep 0.01; } &dump_history; } @@ -1053,7 +1074,7 @@ if (defined($noderange) && !defined($discovery_type)) { } if (defined($discovery_type)) { - unless (grep(/^$discovery_type$/, @valid_discovery_type)){ + unless (grep(/^$discovery_type$/, @valid_discovery_type)) { probe_utils->send_msg("$output", "f", "Invalid discovery type. the vaild types are $valid_discovery_type_str"); probe_utils->send_msg("$output", "d", "$::USAGE"); exit 1; @@ -1065,7 +1086,7 @@ if (defined($noderange) && defined($discovery_type)) { my $rc = check_pre_defined_node($discovery_type, $noderange); if ($rc) { probe_utils->send_msg("$output", "f", $msg); - return 1; + exit 1; } else { probe_utils->send_msg("$output", "o", $msg); } From 9cfc24fbadacb9e399eb09bf73f302d5a0c8a3fa Mon Sep 17 00:00:00 2001 From: ertaozh Date: Thu, 7 Jul 2016 05:18:28 -0400 Subject: [PATCH 248/310] Fix the issue that discovery request is cut when sending to xcatd --- xCAT-genesis-scripts/bin/udpcat.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-genesis-scripts/bin/udpcat.awk b/xCAT-genesis-scripts/bin/udpcat.awk index 6a3c2c166..2a688c735 100755 --- a/xCAT-genesis-scripts/bin/udpcat.awk +++ b/xCAT-genesis-scripts/bin/udpcat.awk @@ -5,7 +5,7 @@ BEGIN { xcatdhost = ARGV[1] delete ARGV[1] delete ARGV[2] - RS="" + RS=rand() } END { print $0 |& "/inet/udp/301/"xcatdhost"/"xcatdport From 39955c0cb5db39b9d1f36f15b585645bb35910d6 Mon Sep 17 00:00:00 2001 From: wangxiaopeng Date: Thu, 7 Jul 2016 06:13:19 -0400 Subject: [PATCH 249/310] issue 1471: fix the mistake in the man page for mkdef --template --- .../guides/admin-guides/references/man1/mkdef.1.rst | 2 +- .../guides/admin-guides/references/man5/monitoring.5.rst | 2 +- .../guides/admin-guides/references/man5/monsetting.5.rst | 2 +- .../guides/admin-guides/references/man5/taskstate.5.rst | 8 +++++++- .../guides/admin-guides/references/man7/monitoring.7.rst | 2 +- xCAT-client/pods/man1/mkdef.1.pod | 2 +- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/mkdef.1.rst b/docs/source/guides/admin-guides/references/man1/mkdef.1.rst index 38b38dce5..41084a288 100644 --- a/docs/source/guides/admin-guides/references/man1/mkdef.1.rst +++ b/docs/source/guides/admin-guides/references/man1/mkdef.1.rst @@ -84,7 +84,7 @@ OPTIONS \ **-**\ **-template**\ \ *template-object-name*\ - Name of the xCAT shipped object definition template or an existing object, from which the new object definition will be created. The newly created object will inherit the attributes of the template definition unless the attribute is specified in the arguments of \ **mkdef**\ command. If there are an existing object and a template with the same name \ *template-object-name*\ , the existing object takes precedence over the object definition template. For the details of xCAT shipped object definition templates, refer to the manpage of \ **-**\ **-template**\ option in lsdef(1)|lsdef.1. + Name of the xCAT shipped object definition template or an existing object, from which the new object definition will be created. The newly created object will inherit the attributes of the template definition unless the attribute is specified in the arguments of \ **mkdef**\ command. If there are a template and an existing object with the same name \ *template-object-name*\ , the tempalte object takes precedence over the existing object. For the details of xCAT shipped object definition templates, refer to the manpage of \ **-**\ **-template**\ option in lsdef(1)|lsdef.1. diff --git a/docs/source/guides/admin-guides/references/man5/monitoring.5.rst b/docs/source/guides/admin-guides/references/man5/monitoring.5.rst index 6ea1f73d3..1f8176938 100644 --- a/docs/source/guides/admin-guides/references/man5/monitoring.5.rst +++ b/docs/source/guides/admin-guides/references/man5/monitoring.5.rst @@ -38,7 +38,7 @@ monitoring Attributes: \ **name**\ - The name of the monitoring plug-in module. The plug-in must be put in /lib/perl/xCAT_monitoring/. See the man page for monstart for details. + The name of the monitoring plug-in module. The plug-in must be put in /opt/xcat/lib/perl/xCAT_monitoring/. See the man page for monstart for details. diff --git a/docs/source/guides/admin-guides/references/man5/monsetting.5.rst b/docs/source/guides/admin-guides/references/man5/monsetting.5.rst index d14541ee0..6200b8925 100644 --- a/docs/source/guides/admin-guides/references/man5/monsetting.5.rst +++ b/docs/source/guides/admin-guides/references/man5/monsetting.5.rst @@ -38,7 +38,7 @@ monsetting Attributes: \ **name**\ - The name of the monitoring plug-in module. The plug-in must be put in /lib/perl/xCAT_monitoring/. See the man page for monstart for details. + The name of the monitoring plug-in module. The plug-in must be put in /opt/xcat/lib/perl/xCAT_monitoring/. See the man page for monstart for details. diff --git a/docs/source/guides/admin-guides/references/man5/taskstate.5.rst b/docs/source/guides/admin-guides/references/man5/taskstate.5.rst index 44fb0ee01..1d7fc2e4f 100644 --- a/docs/source/guides/admin-guides/references/man5/taskstate.5.rst +++ b/docs/source/guides/admin-guides/references/man5/taskstate.5.rst @@ -19,7 +19,7 @@ SYNOPSIS ******** -\ **taskstate Attributes:**\ \ *node*\ , \ *command*\ , \ *state*\ , \ *pid*\ , \ *reserve*\ +\ **taskstate Attributes:**\ \ *node*\ , \ *command*\ , \ *state*\ , \ *pid*\ , \ *reserve*\ , \ *disable*\ *********** @@ -66,6 +66,12 @@ taskstate Attributes: +\ **disable**\ + + Set to 'yes' or '1' to comment out this row. + + + ******** SEE ALSO diff --git a/docs/source/guides/admin-guides/references/man7/monitoring.7.rst b/docs/source/guides/admin-guides/references/man7/monitoring.7.rst index 8c7953e7f..8f74ca22c 100644 --- a/docs/source/guides/admin-guides/references/man7/monitoring.7.rst +++ b/docs/source/guides/admin-guides/references/man7/monitoring.7.rst @@ -53,7 +53,7 @@ monitoring Attributes: \ **name**\ (monitoring.name) - The name of the monitoring plug-in module. The plug-in must be put in /lib/perl/xCAT_monitoring/. See the man page for monstart for details. + The name of the monitoring plug-in module. The plug-in must be put in /opt/xcat/lib/perl/xCAT_monitoring/. See the man page for monstart for details. diff --git a/xCAT-client/pods/man1/mkdef.1.pod b/xCAT-client/pods/man1/mkdef.1.pod index d433869fb..8f5cdb899 100644 --- a/xCAT-client/pods/man1/mkdef.1.pod +++ b/xCAT-client/pods/man1/mkdef.1.pod @@ -50,7 +50,7 @@ A set of comma delimited object types. Use the help option to get a list of val =item B<--template> I -Name of the xCAT shipped object definition template or an existing object, from which the new object definition will be created. The newly created object will inherit the attributes of the template definition unless the attribute is specified in the arguments of B command. If there are an existing object and a template with the same name I, the existing object takes precedence over the object definition template. For the details of xCAT shipped object definition templates, refer to the manpage of B<--template> option in L. +Name of the xCAT shipped object definition template or an existing object, from which the new object definition will be created. The newly created object will inherit the attributes of the template definition unless the attribute is specified in the arguments of B command. If there are a template and an existing object with the same name I, the tempalte object takes precedence over the existing object. For the details of xCAT shipped object definition templates, refer to the manpage of B<--template> option in L. =item B<-V|--verbose> From af5a4c667043dc278813e842979006868251e5bd Mon Sep 17 00:00:00 2001 From: chenglch Date: Thu, 7 Jul 2016 23:10:58 -0400 Subject: [PATCH 250/310] Only try to kill ssl listener process at first Previously service xcatd stop or systemctl stop xcatd.service will send TERM signal to all the processes of xcatd on some platform which support this feature. Close-issue: #1008 #537 --- xCAT-server/etc/init.d/xcatd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/etc/init.d/xcatd b/xCAT-server/etc/init.d/xcatd index 512bb3a91..309d29e99 100755 --- a/xCAT-server/etc/init.d/xcatd +++ b/xCAT-server/etc/init.d/xcatd @@ -101,7 +101,7 @@ stop) echo exit 0 fi - kill -TERM -`cat /var/run/xcatd.pid` + kill -TERM `cat /var/run/xcatd.pid` i=0; while $STATUS > /dev/null 2>&1 && [ $i -lt 30 ]; do sleep .1 From 4bc7a3a2a3b16f5f4d41274015fddb369632651c Mon Sep 17 00:00:00 2001 From: wangxiaopeng Date: Fri, 8 Jul 2016 02:02:57 -0400 Subject: [PATCH 251/310] add release info in RTD --- docs/source/overview/xcat2_release.rst | 34 ++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/docs/source/overview/xcat2_release.rst b/docs/source/overview/xcat2_release.rst index 7ed15f5b3..110120e86 100644 --- a/docs/source/overview/xcat2_release.rst +++ b/docs/source/overview/xcat2_release.rst @@ -7,6 +7,33 @@ The following table is a summary of the new operating system (OS), hardware, and * **SLES** - Suse Linux Enterprise Server * **UBT** - Ubuntu +xCAT 2.12.x +----------- + ++---------------------------------+---------------+-------------+----------------------------------+ +|xCAT |New OS |New |New Feature | +|Version | |Hardware | | ++=================================+===============+=============+==================================+ +|| xCAT 2.12.1 | | |- New xCAT install tool: go-xcat | +|| 2016/07/08 | | |- New opt: mkdef/lsdef --template | +|| | | |- Support rinstall for all OS/ARCH| +| `2.12.1 Release Notes `_ | | |- rscan | +| | | |- New: xcatprobe (experimental) | ++---------------------------------+---------------+-------------+----------------------------------+ +|| xCAT 2.12 |- RHEL 6.8 | |- Docker: xCAT in Docker | +|| 2016/5/20 |- UBT 14.4.4 LE| |- Docker: container life cycle mgt| +|| |- UBT 14.04 | |- Docker: Set up Docker Registry | +| `2.12 Release Notes `_ | | |- Add site.xcatdebugmode | +| | | |- Add switchdiscover -s snmp | +| | | |- Disable auditlog by default | +| | | |- Add site.hierarchicalattrs | ++---------------------------------+---------------+-------------+----------------------------------+ + + xCAT 2.11.x ----------- @@ -14,6 +41,13 @@ xCAT 2.11.x |xCAT |New OS |New |New Feature | |Version | |Hardware | | +=================================+===============+=============+==================================+ +|| xCAT 2.11.1 | | |- Bug fix | +|| 2016/04/22 | | | | +|| | | | | +| `2.11.1 Release Notes `_ | | | | ++---------------------------------+---------------+-------------+----------------------------------+ || xCAT 2.11 |- RHEL 7.2 LE |- S822LC(GCA)|- NVIDIA GPU for OpenPOWER | || 2015/12/11 |- UBT 14.4.3 LE|- S822LC(GTA)|- Infiniband for OpenPOWER | || |- UBT 15.10 LE |- S812LC |- SW KIT support for OpenPOWER | From 368500d531be0cfc8b0e4bb5bb555391aa4edc90 Mon Sep 17 00:00:00 2001 From: immarvin Date: Mon, 11 Jul 2016 01:29:11 -0400 Subject: [PATCH 252/310] fix issue Updating xCAT on OS that uses systemctl has a warning message #1509 ; run systemctl daemon-reload on xcat upgrade --- xCAT-server/sbin/xcatconfig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xCAT-server/sbin/xcatconfig b/xCAT-server/sbin/xcatconfig index 1dc1e8a45..8d9d84b37 100755 --- a/xCAT-server/sbin/xcatconfig +++ b/xCAT-server/sbin/xcatconfig @@ -448,6 +448,12 @@ if ($::INITIALINSTALL || $::FORCE || $::UPDATEINSTALL || $::genCredentials) } else { + #since the xcatd service unit file is updated on xcat upgrade + #"systemctl daemon-reload" need to be run to update the service unit + if ($::UPDATEINSTALL){ + $xcmd="type systemctl >/dev/null 2>&1 && systemctl daemon-reload"; + xCAT::Utils->runcmd("$xcmd", 0); + } #$xcmd = "/etc/init.d/xcatd restart"; xCAT::Utils->restartservice("xcatd"); } From 2ba87088c3842e092e5fb9d638bfc671f39233a2 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Mon, 11 Jul 2016 13:57:48 +0800 Subject: [PATCH 253/310] [go-xcat] Use a different user-agent for wget --- xCAT-server/share/xcat/tools/go-xcat | 30 +++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index 8c43440bf..ec0b52bf4 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -2,7 +2,7 @@ # # go-xcat - Install xCAT automatically. # -# Version 1.0.0 +# Version 1.0.1 # # Copyright (C) 2016 International Business Machines # Eclipse Public License, Version 1.0 (EPL-1.0) @@ -17,15 +17,10 @@ function usage() { local script="${0##*/}" + local version="$(version)" while read -r ; do echo "${REPLY}" ; done <<-EOF - ${script} version $( - for i in {0..9} - do - read -r - [[ ${REPLY} =~ \#\ +[Vv]ersion ]] && echo "${REPLY##* }" - done <"$0" - ) + ${script} version ${version} Usage: ${script} [OPTION]... [ACTION] Install xCAT automatically @@ -82,6 +77,20 @@ function usage() EOF } +# +# version Print out the version number. +# +function version() +{ + # Read the first ten lines of this script + for i in {0..9} + do + read -r + [[ ${REPLY} =~ \#\ +[Vv]ersion ]] && echo "${REPLY##* }" && return 0 + done <"$0" + return 1 +} + GO_XCAT_DEFAULT_BASE_URL="http://xcat.org/files/xcat/repos" GO_XCAT_DEFAULT_INSTALL_PATH="/install/xcat" @@ -573,10 +582,13 @@ function get_package_list() function download_file() { + local script="${0##*/}" + local version="$(version)" + local user_agent="${script}/${version} (${GO_XCAT_OS}; ${GO_XCAT_ARCH}; ${GO_XCAT_LINUX_DISTRO} ${GO_XCAT_LINUX_VERSION})" type wget >/dev/null 2>&1 || return 255 local url="$1" local local_file="$2" - wget -q "${url}" -O "${local_file}" + wget -U "${user_agent}" -q "${url}" -O "${local_file}" } # $1 repo file From 123f9bc400677696a9a2571e3642d12fb7c5281e Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Mon, 11 Jul 2016 14:08:13 +0800 Subject: [PATCH 254/310] [go-xcat] Print out more error messages when reading repository failed. --- xCAT-server/share/xcat/tools/go-xcat | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index ec0b52bf4..0f17c7aa5 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -1035,25 +1035,25 @@ function add_xcat_dep_repo() function update_repo_dnf() { type dnf >/dev/null 2>&1 || return 255 - dnf --nogpgcheck updateinfo /dev/null 2>&1 + dnf --nogpgcheck updateinfo } function update_repo_yum() { type yum >/dev/null 2>&1 || return 255 - yum --nogpgcheck updateinfo /dev/null 2>&1 + yum --nogpgcheck updateinfo } function update_repo_zypper() { type zypper >/dev/null 2>&1 || return 255 - zypper --gpg-auto-import-keys refresh /dev/null 2>&1 + zypper --gpg-auto-import-keys refresh } function update_repo_apt() { type apt-get >/dev/null 2>&1 || return 255 - apt-get update /dev/null 2>&1 + apt-get --allow-unauthenticated update } function update_repo() @@ -1090,7 +1090,7 @@ function install_packages_apt() type apt-get >/dev/null 2>&1 || return 255 local -a args=() [[ "$1" = "-y" ]] && args=("-y") && shift - apt-get install "${args[@]}" "$@" + apt-get --allow-unauthenticated install "${args[@]}" "$@" } function install_packages() From a7dc03884d3ddd57f3bcd763a57549d9541a85a6 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 11 Jul 2016 11:26:03 -0400 Subject: [PATCH 255/310] Noderange and error checking --- xCAT-probe/subcmds/image | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/xCAT-probe/subcmds/image b/xCAT-probe/subcmds/image index b224437f4..b480324a9 100755 --- a/xCAT-probe/subcmds/image +++ b/xCAT-probe/subcmds/image @@ -22,7 +22,7 @@ my $rst = 0; $::USAGE = "Usage: $program_name -h $program_name -T - $program_name {-c|-d} [-V] + $program_name {-c|-d} [-V] [noderange] Description: Use this command to check if diskless, pingable compute nodes have the same images installed as defines in xCAT DB. @@ -61,7 +61,7 @@ if ($help) { } if ($test) { - probe_utils->send_msg("$output", "o", "Use this command to check if all compute nodes have the same images installed or if compute nodes are installed with the same image as defined on MN."); + probe_utils->send_msg("$output", "o", "Use this command to check if specified compute nodes have the same images installed or if compute nodes are installed with the same image as defined on MN."); exit 0; } @@ -80,12 +80,25 @@ my %node_defined_image_uuid_hash; my %node_defined_image_name_hash; my %osimage_defined_provmethod_hash; -my $all_nodes_provmethod = `lsdef -i provmethod -c`; +my $all_nodes_provmethod = `lsdef -i provmethod -c @ARGV`; my $all_osimage_provmethod = `lsdef -t osimage -i provmethod,rootimgdir -c`; chomp($all_nodes_provmethod); my @all_nodes_provmethod_lines = split("[\n\r]", $all_nodes_provmethod); my @all_osimage_provmethod_lines = split("[\n\r]", $all_osimage_provmethod); +if ($all_nodes_provmethod =~ /Usage:/) { + # lsdef command displayed a Usage message. Must be some noderange formatting problem. + # Issue a warning and exit. + probe_utils->send_msg("$output", "w", "Can not get a list of nodes from specified noderange."); + exit 1; +} + +if (scalar(@all_nodes_provmethod_lines) <=0) { + # There were no nodes matching the noderange. Issue a warning and exit. + probe_utils->send_msg("$output", "w", "No nodes matching the noderange were found."); + exit 1; +} + # Build a hash of key="osimage name + attribute name" value="provmethod and rootimgdir attribute value" foreach (@all_osimage_provmethod_lines) { my ($osimage_name, $values) = split "=", $_; @@ -128,6 +141,15 @@ foreach (@all_nodes_provmethod_lines) { probe_utils->send_msg("$output", "w", "$node_name is not diskless. No image consistency verification will be performed."); } } + else { + probe_utils->send_msg("$output", "w", "$node_name has no provision method defined. No image consistency verification will be performed."); + } +} + +if (scalar(@diskless_nodes) <=0) { + # There were no diskless nodes found. Issue a warning and exit. + probe_utils->send_msg("$output", "w", "No diskless compute nodes were found."); + exit 1; } if (scalar(@diskless_nodes) <=0) { @@ -160,6 +182,13 @@ if (scalar(@pingable_nodes) <=0) { exit 1; } +if ((scalar(@pingable_nodes) == 1) && ($CONSISTENCY_CHECK)) { + # There was only one node in noderange and comparison check was requested. + # Nothing to compare the single node to. + probe_utils->send_msg("$output", "w", "Comparison check for a single diskless pingable node will not be performed. Minimum of 2 nodes are needed for that."); + exit 1; +} + # Next, from all pingable nodes get the IMAGENAME and IMAGEUUID entries from xcatinfo file probe_utils->send_msg("$output", "d", "---- Gathering information from all diskless pingable compute nodes ----"); From 861e60b3e0a751c0ca222fb8dfa42f8417dc1c95 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 11 Jul 2016 14:29:57 -0400 Subject: [PATCH 256/310] code review suggestions --- xCAT-server/lib/xcat/plugins/grub2.pm | 5 +- xCAT-server/lib/xcat/plugins/petitboot.pm | 117 +++++++++++----------- 2 files changed, 60 insertions(+), 62 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/grub2.pm b/xCAT-server/lib/xcat/plugins/grub2.pm index d476df491..8d0aecd57 100644 --- a/xCAT-server/lib/xcat/plugins/grub2.pm +++ b/xCAT-server/lib/xcat/plugins/grub2.pm @@ -724,15 +724,16 @@ sub process_request { } } + my @makedhcp_nodes; if ($args[0] eq 'offline') { # If nodeset directive was offline we need to remove the architecture file link and remove dhcp entries foreach my $osimage (keys %osimagenodehash) { foreach my $tmp_node (@{ $osimagenodehash{$osimage} }) { unlink( "$tftpdir/boot/grub2/grub2-$tmp_node"); - $sub_req->({ command => ['makedhcp'],arg=>['-d'], - node => \@{ $osimagenodehash{$osimage} } }, $callback); + push(@makedhcp_nodes, $tmp_node); } } + $sub_req->({ command => ['makedhcp'],arg=>['-d'], node => \@makedhcp_nodes }, $callback); } #now run the end part of the prescripts diff --git a/xCAT-server/lib/xcat/plugins/petitboot.pm b/xCAT-server/lib/xcat/plugins/petitboot.pm index 9409e1caf..745580a3f 100644 --- a/xCAT-server/lib/xcat/plugins/petitboot.pm +++ b/xCAT-server/lib/xcat/plugins/petitboot.pm @@ -185,48 +185,48 @@ sub setstate { # $sub_req->({command=>['makedhcp'], #This is currently batched elswhere # node=>[$node]},$callback); #It hopefully will perform correctly if ($cref and $cref->{currstate} eq "boot") { - $breaknetbootnodes{$node}=1; - delete $normalnodes{$node}; #Signify to omit this from one makedhcp command - #$sub_req->({command=>['makedhcp'], #batched elsewhere, this code is stale, hopefully - # node=>[$node], - # arg=>['-s','filename = \"xcat/nonexistant_file_to_intentionally_break_netboot_for_localboot_to_work\";']},$callback); - #print $pcfg "bye\n"; - close($pcfg); + $breaknetbootnodes{$node}=1; + delete $normalnodes{$node}; #Signify to omit this from one makedhcp command + #$sub_req->({command=>['makedhcp'], #batched elsewhere, this code is stale, hopefully + # node=>[$node], + # arg=>['-s','filename = \"xcat/nonexistant_file_to_intentionally_break_netboot_for_localboot_to_work\";']},$callback); + #print $pcfg "bye\n"; + close($pcfg); } elsif ($kern and $kern->{kernel} and $cref and $cref->{currstate} ne "offline") { - #It's time to set yaboot for this node to boot the kernel, but only if not offline directive - print $pcfg "default xCAT\n"; - print $pcfg "label xCAT\n"; - print $pcfg "\tkernel $kern->{kernel}\n"; - if ($kern and $kern->{initrd}) { - print $pcfg "\tinitrd ".$kern->{initrd}."\n"; - } - if ($kern and $kern->{kcmdline}) { - print $pcfg "\tappend \"".$kern->{kcmdline}."\"\n"; - } - close($pcfg); - my $inetn = xCAT::NetworkUtils->getipaddr($node); - unless ($inetn) { - syslog("local1|err","xCAT unable to resolve IP for $node in petitboot plugin"); - return; - } + #It's time to set petitboot for this node to boot the kernel, but only if not offline directive + print $pcfg "default xCAT\n"; + print $pcfg "label xCAT\n"; + print $pcfg "\tkernel $kern->{kernel}\n"; + if ($kern and $kern->{initrd}) { + print $pcfg "\tinitrd ".$kern->{initrd}."\n"; + } + if ($kern and $kern->{kcmdline}) { + print $pcfg "\tappend \"".$kern->{kcmdline}."\"\n"; + } + close($pcfg); + my $inetn = xCAT::NetworkUtils->getipaddr($node); + unless ($inetn) { + syslog("local1|err","xCAT unable to resolve IP for $node in petitboot plugin"); + return; + } } else { #TODO: actually, should possibly default to xCAT image? - #print $pcfg "bye\n"; - close($pcfg); + #print $pcfg "bye\n"; + close($pcfg); } my $ip = xCAT::NetworkUtils->getipaddr($node); unless ($ip) { - syslog("local1|err","xCAT unable to resolve IP in petitboot plugin"); - return; + syslog("local1|err","xCAT unable to resolve IP in petitboot plugin"); + return; } - my @ipa=split(/\./,$ip); - my $pname = sprintf("%02x%02x%02x%02x",@ipa); - $pname = uc($pname); - # remove the old boot configuration file and copy (link) a new one, but only if not offline directive - unlink($tftpdir."/".$pname); - if ($cref and $cref->{currstate} ne "offline") { - link($tftpdir."/petitboot/".$node,$tftpdir."/".$pname); - } + my @ipa=split(/\./,$ip); + my $pname = sprintf("%02x%02x%02x%02x",@ipa); + $pname = uc($pname); + # remove the old boot configuration file and copy (link) a new one, but only if not offline directive + unlink($tftpdir."/".$pname); + if ($cref and $cref->{currstate} ne "offline") { + link($tftpdir."/petitboot/".$node,$tftpdir."/".$pname); + } return; } @@ -480,29 +480,29 @@ sub process_request { my $tftpdir; foreach (@nodes) { - my %response; - if ($nodereshash->{$_} and $nodereshash->{$_}->[0] and $nodereshash->{$_}->[0]->{tftpdir}) { - $tftpdir = $nodereshash->{$_}->[0]->{tftpdir}; - } else { - $tftpdir = $globaltftpdir; - } - $response{node}->[0]->{name}->[0]=$_; - if ($args[0] eq 'stat') { - $response{node}->[0]->{data}->[0]= getstate($_,$tftpdir); - $callback->(\%response); - } elsif ($args[0]) { #If anything else, send it on to the destiny plugin, then setstate - my $ent = $typehash->{$_}->[0]; - my $osimgname = $ent->{'provmethod'}; - my $linuximghash = $linuximghash = $linuximgtab->getAttribs({imagename => $osimgname}, 'boottarget', 'addkcmdline'); + my %response; + if ($nodereshash->{$_} and $nodereshash->{$_}->[0] and $nodereshash->{$_}->[0]->{tftpdir}) { + $tftpdir = $nodereshash->{$_}->[0]->{tftpdir}; + } else { + $tftpdir = $globaltftpdir; + } + $response{node}->[0]->{name}->[0]=$_; + if ($args[0] eq 'stat') { + $response{node}->[0]->{data}->[0]= getstate($_,$tftpdir); + $callback->(\%response); + } elsif ($args[0]) { #If anything else, send it on to the destiny plugin, then setstate + my $ent = $typehash->{$_}->[0]; + my $osimgname = $ent->{'provmethod'}; + my $linuximghash = $linuximghash = $linuximgtab->getAttribs({imagename => $osimgname}, 'boottarget', 'addkcmdline'); - ($rc,$errstr) = setstate($_,$bphash,$chainhash,$machash,$tftpdir,$nodereshash,$linuximghash); - if ($rc) { - $response{node}->[0]->{errorcode}->[0]= $rc; - $response{node}->[0]->{errorc}->[0]= $errstr; - $callback->(\%response); + ($rc,$errstr) = setstate($_,$bphash,$chainhash,$machash,$tftpdir,$nodereshash,$linuximghash); + if ($rc) { + $response{node}->[0]->{errorcode}->[0]= $rc; + $response{node}->[0]->{errorc}->[0]= $errstr; + $callback->(\%response); + } } - } }# end of foreach node my @normalnodeset = keys %normalnodes; @@ -544,11 +544,8 @@ sub process_request { } if ($args[0] eq 'offline') { - # If nodeset directive was offline we need to remove dhcp entries - foreach my $node (@normalnodeset) { - $sub_req->({ command => ['makedhcp'],arg=>['-d'], - node => [$node] }, $callback); - } + # If nodeset directive was offline we need to remove dhcp entries + $sub_req->({ command => ['makedhcp'],arg=>['-d'], node => \@normalnodeset }, $callback); } #now run the end part of the prescripts From 05f2832e7de901a5dd1fa0a171735e5a35793393 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Mon, 11 Jul 2016 15:12:13 -0400 Subject: [PATCH 257/310] Remove dhcp entry for x86_64 node when nodeset offline is issued --- xCAT-server/lib/xcat/plugins/xnba.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/xnba.pm b/xCAT-server/lib/xcat/plugins/xnba.pm index 467ba9a2c..d3b4c4d51 100644 --- a/xCAT-server/lib/xcat/plugins/xnba.pm +++ b/xCAT-server/lib/xcat/plugins/xnba.pm @@ -18,7 +18,7 @@ my $globaltftpdir = xCAT::TableUtils->getTftpDir(); #my $dhcpver = 3; my %usage = ( - "nodeset" => "Usage: nodeset [shell|boot|runcmd=bmcsetup|iscsiboot|osimage[=]|offline]", + "nodeset" => "Usage: nodeset [shell|boot|runcmd=bmcsetup|osimage[=]|offline]", ); sub handled_commands { return { @@ -76,7 +76,8 @@ sub getstate { chomp($headline); return $headline; } else { - return "boot"; + # There is no boot configuration file, node must be offline + return "offline"; } } else { return "discover"; @@ -531,6 +532,7 @@ sub process_request { my $linuximgtab=xCAT::Table->new('linuximage',-create=>1); my %machash = %{$mactab->getNodesAttribs(\@nodes,[qw(mac)])}; + my @makedhcp_nodes; foreach (@nodes) { my $tftpdir; if ($nrhash{$_}->[0] and $nrhash{$_}->[0]->{tftpdir}) { @@ -565,9 +567,14 @@ sub process_request { unlink($tftpdir."/xcat/xnba/nodes/".$_.".pxelinux"); unlink($tftpdir."/xcat/xnba/nodes/".$_.".uefi"); unlink($tftpdir."/xcat/xnba/nodes/".$_.".elilo"); + push(@makedhcp_nodes, $_); } } } + # for offline operation, remove the dhcp entries + if ($args[0] eq 'offline') { + $sub_req->({ command => ['makedhcp'],arg=>['-d'],node => \@makedhcp_nodes }, $::XNBA_callback); + } #dhcp stuff -- inittime is set when xcatd on sn is started From 78e9094258f225683cbaedea836981355fdef10d Mon Sep 17 00:00:00 2001 From: junxiawang Date: Tue, 12 Jul 2016 05:28:58 -0400 Subject: [PATCH 258/310] add genesis test case --- xCAT-test/autotest/testcase/genesis/cases0 | 42 ++++++ .../autotest/testcase/genesis/cmdtest.pl | 128 ++++++++++++++++++ 2 files changed, 170 insertions(+) create mode 100644 xCAT-test/autotest/testcase/genesis/cases0 create mode 100755 xCAT-test/autotest/testcase/genesis/cmdtest.pl diff --git a/xCAT-test/autotest/testcase/genesis/cases0 b/xCAT-test/autotest/testcase/genesis/cases0 new file mode 100644 index 000000000..c324de5ff --- /dev/null +++ b/xCAT-test/autotest/testcase/genesis/cases0 @@ -0,0 +1,42 @@ +start:nodeset_shell +description: verify could log in genesis shell +cmd:nodeset $$CN shell +check:rc==0 +cmd:rpower $$CN boot +cmd: perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/cmdtest.pl -t $$CN +cmd:xdsh $$CN cat /proc/cmdline +check:rc==0 +check:output=~BOOT_IMAGE=/xcat/genesis.kernel +cmd:nodeset $$CN boot +check:rc==0 +end +start:nodeset_cmdline +description:verify could run cmdline successfully +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/cmdtest.pl -c __GETNODEATTR($$CN,arch)__ +cmd:nodeset $$CN runcmd="cmdtest,shell" +check:rc==0 +cmd:rpower $$CN boot +check:rc==0 +cmd: perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/cmdtest.pl -t $$CN +cmd:xdsh $$CN "cat /tmp/cmdtest" +check:rc==0 +check:output=~test +cmd:nodeset $$CN boot +check:rc==0 +cmd:rm -rf /tmp/cmdtest +end +start:nodeset_runimg +description:verify runimg could work +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/cmdtest.pl -i $$CN $$imgdirip +check:rc==0 +cmd:rpower $$CN boot +check:rc==0 +cmd: perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/cmdtest.pl -t $$CN +check:rc==0 +cmd:xdsh $$CN "cat /tmp/cmdtest" +check:output=~test +check:rc==0 +cmd:nodeset $$CN boot +cmd:rm -rf /install/my_image +cmd:rm -rf /tmp/runme.sh +end diff --git a/xCAT-test/autotest/testcase/genesis/cmdtest.pl b/xCAT-test/autotest/testcase/genesis/cmdtest.pl new file mode 100755 index 000000000..e0be25c5e --- /dev/null +++ b/xCAT-test/autotest/testcase/genesis/cmdtest.pl @@ -0,0 +1,128 @@ +#!/usr/bin/env perl +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html + +use strict; +use warnings; +use Getopt::Long; +use Data::Dumper; +use Term::ANSIColor; +use Time::Local; +BEGIN +{ + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; +} +use lib "$::XCATROOT/lib/perl"; +my $needhelp = 0; +my $rungenesiscmd = 0; +my $rungenesisimg = 0; +my $shellmode = 0; +my $cmdtest="/tmp/cmdtest"; +my $genesisdir="/opt/xcat/share/xcat/netboot/genesis/"; +my $timesleep = 0; +my $runimgtest="/tmp/runme.sh"; +if ( + !GetOptions("h|?" => \$needhelp, + "c"=>\$rungenesiscmd, + "i"=>\$rungenesisimg, + "t"=>\$timesleep, + "s"=>\$shellmode) +) +{ + &usage; + exit 1; +} +sub usage +{ + print "Usage:run genesis cases.\n"; + print " genesistest.pl [-?|-h]\n"; + print " genesistest.pl [-s] set up genesis in shell mode \n"; + print " genesistest.pl [-i] runimg in genesis\n"; + print "\n"; + return; +} +sub runcmd +{ + my ($cmd) = @_; + my $rc = 0; + $::RUNCMD_RC = 0; + my $outref = []; + @$outref = `$cmd 2>&1`; + if ($?) + { + $rc = $? ; + $rc = $rc >> 8; + $::RUNCMD_RC = $rc; + } + chomp(@$outref); + return @$outref; + +} + +sub rungenesiscmd +{ + `echo "#!/bin/bash">>$cmdtest`; + `echo "#This is test for genesis scripts">>$cmdtest`; + `echo "echo \"test\" >> $cmdtest">>$cmdtest`; + `chmod 777 $cmdtest`; + if ($ARGV[0] =~ /ppc64/){ + `cp -rf $cmdtest "$genesisdir""ppc64"/fs/bin`; + `mknb ppc64`; + print "mknb ppc64\n"; + }else{ + `cp -rf $cmdtest "$genesisdir""$ARGV[0]"/fs/bin`; + `mknb $ARGV[0]`; + print "mkmn $ARGV[0]\n"; + } +} +sub rungenesisimg +{ + my $rc=0; + runcmd("mkdir -p /install/my_image"); + `echo "#!/bin/bash">>$runimgtest`; + `echo "#This is test for genesis scripts">>$runimgtest`; + `echo "echo "test" >> /tmp/cmdtest" >>$runimgtest`; + `chmod +x $runimgtest`; + `cp $runimgtest /install/my_image`; + `cd /install/my_image ;tar -zcvf my_image.tgz .`; + ` nodeset $ARGV[0] "runimage=http://$ARGV[1]/install/my_image/my_image.tgz",shell`; +} +sub timesleep +{ + my @output = runcmd("ping $ARGV[0] -c 10"); + my $value = 0; + print "output is $value ,@output\n"; + if ($::RUNCMD_RC){ + foreach $value (1 .. 60) { + @output = runcmd("ping $ARGV[0] -c 10"); + last if ($::RUNCMD_RC == 0); + } + } + my @output1 = runcmd("xdsh $ARGV[0] date"); + if ($::RUNCMD_RC){ + foreach $value (1 .. 60) { + @output1 = runcmd("xdsh $ARGV[0] date"); + last if ($::RUNCMD_RC == 0); + } + } + if ($::RUNCMD_RC == 0){ + print "test ok\n"; + } +} +if ($rungenesiscmd) + { + &rungenesiscmd; + } +if ($timesleep) + { + ×leep; + } +if($rungenesisimg) + { + &rungenesisimg; + } +if ($?) + { + return 0; + } + + From 81c5bd84563d68ec898c7e692bd02925532fcd5a Mon Sep 17 00:00:00 2001 From: junxiawang Date: Tue, 12 Jul 2016 05:32:19 -0400 Subject: [PATCH 259/310] modify genesis test scripts --- xCAT-test/autotest/testcase/genesis/cmdtest.pl | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/xCAT-test/autotest/testcase/genesis/cmdtest.pl b/xCAT-test/autotest/testcase/genesis/cmdtest.pl index e0be25c5e..7422961d7 100755 --- a/xCAT-test/autotest/testcase/genesis/cmdtest.pl +++ b/xCAT-test/autotest/testcase/genesis/cmdtest.pl @@ -109,9 +109,9 @@ sub timesleep } } if ($rungenesiscmd) - { - &rungenesiscmd; - } + { + &rungenesiscmd; + } if ($timesleep) { ×leep; @@ -120,9 +120,5 @@ if($rungenesisimg) { &rungenesisimg; } -if ($?) - { - return 0; - } From 8a4d0b9956464dc70a937e0b4ae64f5344c56649 Mon Sep 17 00:00:00 2001 From: ertaozh Date: Tue, 12 Jul 2016 04:43:24 -0400 Subject: [PATCH 260/310] Fix issue 1495: Provision Dell PowerEdge M605 compute node hangs while setup BMC --- xCAT-genesis-scripts/bin/bmcsetup | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/xCAT-genesis-scripts/bin/bmcsetup b/xCAT-genesis-scripts/bin/bmcsetup index 6aeb489d2..63608d5dd 100755 --- a/xCAT-genesis-scripts/bin/bmcsetup +++ b/xCAT-genesis-scripts/bin/bmcsetup @@ -20,17 +20,19 @@ TIMEOUT=15 # Function: cold_reset_bmc # # Cold reset the BMC for certain servers -# Product ID: 309 - x3755 M4 (8722) -# Product ID: 43707 - IBM Power S822LC and S812LC +# Product ID: 309 - x3755 M4 (8722) +# Product ID: 43707 and Manufacturer ID: 0 - IBM Power S822LC and S812LC # # Otherwise the BMC will not respond to ping after running the ipmitool commands in this script -# +# It is found that Dell PowerEdge M605 server have the same product ID '43707', but its 'Manufacturer ID' is '674' function cold_reset_bmc() { if [ -z $XPROD ]; then logger -s -t $log_label -p local4.crit "CRITICAL ERROR - XPROD must be set before calling ${FUNCNAME[0]}" exit 1 fi - + if [ "$XPROD" = "43707" -a "$IPMIMFG" != '0' ]; then + return + fi if [ "$XPROD" = "309" -o "$XPROD" = "43707" ] ; then if [ "$XPROD" = "43707" ]; then # OpenPower SPECIFIC, the OpenPower machines with AMI BMC should NOT need a @@ -86,7 +88,9 @@ function snooze() { logger -s -t $log_label -p local4.crit "CRITICAL ERROR - XPROD must be set before calling ${FUNCNAME[0]}" exit 1 fi - + if [ "$XPROD" = "43707" -a "$IPMIMFG" != '0' ]; then + return + fi if [ "$XPROD" = "43707" ]; then # For OpenPower Machines logger -s -t $log_label -p local4.debug "OpenPower, snooze for 30 seconds..." @@ -581,7 +585,7 @@ while [ $idev -gt 0 ]; do fi logger -s -t $log_label -p local4.info "Lighting Identify Light" - if [ "$XPROD" = "43707" ]; then + if [ "$XPROD" = "43707" -a "$IPMIMFG" = '0' ]; then # OpenPower BMC specific, turn on the LED beacon light. # - default interval, # ipmitool chassis identify # Chassis identify interval: default (15 seconds) From 97a159d47a1aff120c40f984f274ac2bc67157c4 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 12 Jul 2016 09:13:40 -0400 Subject: [PATCH 261/310] More fixes due to review comments --- xCAT-server/lib/xcat/plugins/grub2.pm | 6 +++--- xCAT-server/lib/xcat/plugins/xnba.pm | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/grub2.pm b/xCAT-server/lib/xcat/plugins/grub2.pm index 8d0aecd57..993c8bbe7 100644 --- a/xCAT-server/lib/xcat/plugins/grub2.pm +++ b/xCAT-server/lib/xcat/plugins/grub2.pm @@ -724,16 +724,16 @@ sub process_request { } } - my @makedhcp_nodes; if ($args[0] eq 'offline') { + my @rmdhcp_nodes; # If nodeset directive was offline we need to remove the architecture file link and remove dhcp entries foreach my $osimage (keys %osimagenodehash) { foreach my $tmp_node (@{ $osimagenodehash{$osimage} }) { unlink( "$tftpdir/boot/grub2/grub2-$tmp_node"); - push(@makedhcp_nodes, $tmp_node); + push(@rmdhcp_nodes, $tmp_node); } } - $sub_req->({ command => ['makedhcp'],arg=>['-d'], node => \@makedhcp_nodes }, $callback); + $sub_req->({ command => ['makedhcp'],arg=>['-d'], node => \@rmdhcp_nodes }, $callback); } #now run the end part of the prescripts diff --git a/xCAT-server/lib/xcat/plugins/xnba.pm b/xCAT-server/lib/xcat/plugins/xnba.pm index d3b4c4d51..9741a23d9 100644 --- a/xCAT-server/lib/xcat/plugins/xnba.pm +++ b/xCAT-server/lib/xcat/plugins/xnba.pm @@ -532,7 +532,6 @@ sub process_request { my $linuximgtab=xCAT::Table->new('linuximage',-create=>1); my %machash = %{$mactab->getNodesAttribs(\@nodes,[qw(mac)])}; - my @makedhcp_nodes; foreach (@nodes) { my $tftpdir; if ($nrhash{$_}->[0] and $nrhash{$_}->[0]->{tftpdir}) { @@ -567,13 +566,12 @@ sub process_request { unlink($tftpdir."/xcat/xnba/nodes/".$_.".pxelinux"); unlink($tftpdir."/xcat/xnba/nodes/".$_.".uefi"); unlink($tftpdir."/xcat/xnba/nodes/".$_.".elilo"); - push(@makedhcp_nodes, $_); } } } # for offline operation, remove the dhcp entries if ($args[0] eq 'offline') { - $sub_req->({ command => ['makedhcp'],arg=>['-d'],node => \@makedhcp_nodes }, $::XNBA_callback); + $sub_req->({ command => ['makedhcp'],arg=>['-d'],node => \@nodes }, $::XNBA_callback); } From c487d612c4b8e39b76df54f9ae960e7ff67aa62e Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 12 Jul 2016 09:51:17 -0400 Subject: [PATCH 262/310] Process noderange with -n flag --- xCAT-probe/subcmds/image | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/xCAT-probe/subcmds/image b/xCAT-probe/subcmds/image index b480324a9..c9837ac89 100755 --- a/xCAT-probe/subcmds/image +++ b/xCAT-probe/subcmds/image @@ -13,7 +13,7 @@ use warnings; my $program_name = basename("$0"); my $help; -my $installnic; +my $noderange = ""; my $test; my $output = "stdout"; my $verbose = 0; @@ -22,7 +22,7 @@ my $rst = 0; $::USAGE = "Usage: $program_name -h $program_name -T - $program_name {-c|-d} [-V] [noderange] + $program_name {-c|-d} [-n noderange] [-V] Description: Use this command to check if diskless, pingable compute nodes have the same images installed as defines in xCAT DB. @@ -31,6 +31,7 @@ Description: Options: -h : Get usage information of $program_name -T : To verify if $program_name can work, reserve option for probe framework + -n : Range of nodes to check -d : To verify diskless, pingable compute nodes have the same images installed as defines in xCAT DB. -c : To verify all diskless, pingable compute nodes have the identical images installed. -V : To print additional debug information. @@ -41,10 +42,11 @@ Options: #------------------------------------- if ( !GetOptions("--help|h" => \$help, - "T" => \$test, - "V" => \$VERBOSE, - "c" => \$CONSISTENCY_CHECK, - "d" => \$DEFINITION_CHECK)) + "T" => \$test, + "V" => \$VERBOSE, + "n=s" => \$noderange, + "c" => \$CONSISTENCY_CHECK, + "d" => \$DEFINITION_CHECK)) { probe_utils->send_msg("$output", "f", "Invalid parameter for $program_name"); probe_utils->send_msg("$output", "d", "$::USAGE"); @@ -71,6 +73,14 @@ unless (defined($CONSISTENCY_CHECK) || defined($DEFINITION_CHECK)) { exit 1; } +if (scalar(@ARGV) >= 1) { + # After processing all the expected flags and arguments, + # there is still left over stuff on the command line + probe_utils->send_msg("$output", "f", "Invalid flag or parameter: @ARGV"); + probe_utils->send_msg("$output", "d", "$::USAGE"); + exit 1; +} + my @pingable_nodes; my @diskless_nodes; my $na = "N/A"; @@ -80,7 +90,7 @@ my %node_defined_image_uuid_hash; my %node_defined_image_name_hash; my %osimage_defined_provmethod_hash; -my $all_nodes_provmethod = `lsdef -i provmethod -c @ARGV`; +my $all_nodes_provmethod = `lsdef -i provmethod -c $noderange`; my $all_osimage_provmethod = `lsdef -t osimage -i provmethod,rootimgdir -c`; chomp($all_nodes_provmethod); my @all_nodes_provmethod_lines = split("[\n\r]", $all_nodes_provmethod); From 74f67dfc7e77aba23c2e3370023b5d59d224d8ee Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 12 Jul 2016 13:47:19 -0400 Subject: [PATCH 263/310] Update README file --- docs/README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 05e277f85..175295970 100644 --- a/docs/README.md +++ b/docs/README.md @@ -13,10 +13,19 @@ The documentation project is written in restructured text (.rst) using Sphinx an * Clone the project -* Using pip, install sphinx (See: http://pip.readthedocs.org/) +* Using pip, install or update sphinx (See: http://pip.readthedocs.org/) ``` pip install sphinx ``` + or + ``` + pip install sphinx --upgrade + ``` + +* Using pip, install ReadTheDocs theme + ``` + pip install sphinx_rtd_theme + ``` * Build the Docs ``` From 52ec24a9b13c41b74e3a4a81f0416e610a5a416a Mon Sep 17 00:00:00 2001 From: XuWei Date: Wed, 13 Jul 2016 01:32:02 -0400 Subject: [PATCH 264/310] Improve the performance for ipmi mgt(powering-on) --- xCAT-server/lib/xcat/plugins/ipmi.pm | 59 ++++++++-------------------- 1 file changed, 16 insertions(+), 43 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 8fe02dcb5..725180286 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -37,6 +37,7 @@ use Time::HiRes qw/time/; my $iem_support; my $vpdhash; my %allerrornodes=(); +my %newnodestatus=(); my $global_sessdata; my %child_pids; @@ -2151,7 +2152,6 @@ sub power_response { my $rsp = shift; my $sessdata = shift; my $newstat; - my %newnodestatus=(); if($rsp->{error}) { xCAT::SvrUtils::sendmsg([1,$rsp->{error}],$callback,$sessdata->{node},%allerrornodes); @@ -2165,14 +2165,18 @@ sub power_response { } else { my $command = $sessdata->{subcommand}; my $status = $sessdata->{powerstatus}; - if ($command eq "on") { $newstat = $::STATUS_POWERING_ON; } + if ($command eq "on" or $command eq "boot") { $newstat = $::STATUS_POWERING_ON; } if ($command eq "off" or $command eq "softoff") { $newstat = $::STATUS_POWERING_OFF; } - if ($command eq "reset" and $status eq "on"){$newstat = $::STATUS_POWERING_ON; } - if ($command eq "boot"){$newstat = $::STATUS_POWERING_ON; } - + if ($command eq "reset") { + if ($status eq "off"){ + $newstat = $::STATUS_POWERING_OFF; + } else { + $newstat = $::STATUS_POWERING_ON; + } + } + if ($newstat) { - $newnodestatus{$newstat}=[$sessdata->{node}]; - xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); + push @{ $newnodestatus{$newstat} }, $sessdata->{node}; } } @@ -7907,28 +7911,9 @@ sub process_request { if (defined $::XCATSITEVALS{nodestatus} and $::XCATSITEVALS{nodestatus} =~ /0|n|N/) { $global_check=0; } - if ($command eq 'rpower') { - if (($global_check) && ($extrargs->[0] ne 'stat') && ($extrargs->[0] ne 'status') && ($extrargs->[0] ne 'state') && ($extrargs->[0] ne 'suspend') && ($extrargs->[0] ne 'wake')) { - $check=1; - my @allnodes=(); - foreach (@donargs) { push(@allnodes, $_->[0]); } - - #save the old status - my $nodelisttab = xCAT::Table->new('nodelist'); - if ($nodelisttab) { - my $tabdata = $nodelisttab->getNodesAttribs(\@allnodes, ['node', 'status']); - foreach my $node (@allnodes) - { - my $tmp1 = $tabdata->{$node}->[0]; - if ($tmp1) { - if ($tmp1->{status}) { $oldnodestatus{$node}=$tmp1->{status}; } - else { $oldnodestatus{$node}=""; } - } - } - } - #print "oldstatus:" . Dumper(\%oldnodestatus); - } - } + if ($command eq 'rpower') { + %newnodestatus = (); + } # NOTE (chenglch) rflash for one node need about 5-10 minutes. There is no need to rflash node # one by one, fork a process for each node. @@ -7950,20 +7935,8 @@ sub process_request { } while (xCAT::IPMI->waitforrsp()) { yield }; - if ($check) { - #print "allerrornodes=@allerrornodes\n"; - #revert the status back for there is no-op for the nodes - my %old=(); - foreach my $node (keys %allerrornodes) { - my $stat=$oldnodestatus{$node}; - if (exists($old{$stat})) { - my $pa=$old{$stat}; - push(@$pa, $node); - } else { - $old{$stat}=[$node]; - } - } - xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%old, 1); + if ($command eq 'rpower' and %newnodestatus) { + xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); } } From 82515b50c8af3c0868311ea3914ec6f32a9e723e Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Wed, 13 Jul 2016 16:32:28 +0800 Subject: [PATCH 265/310] [doc] Fix a typo in xCAT 2.12.x Release Information --- docs/source/overview/xcat2_release.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/overview/xcat2_release.rst b/docs/source/overview/xcat2_release.rst index 110120e86..1f128f855 100644 --- a/docs/source/overview/xcat2_release.rst +++ b/docs/source/overview/xcat2_release.rst @@ -24,7 +24,7 @@ xCAT 2.12.x +---------------------------------+---------------+-------------+----------------------------------+ || xCAT 2.12 |- RHEL 6.8 | |- Docker: xCAT in Docker | || 2016/5/20 |- UBT 14.4.4 LE| |- Docker: container life cycle mgt| -|| |- UBT 14.04 | |- Docker: Set up Docker Registry | +|| |- UBT 16.04 | |- Docker: Set up Docker Registry | | `2.12 Release Notes `_ | | |- Add site.xcatdebugmode | From 831cc7641074f0253ebd3dfcd108a86fe8e56aee Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Wed, 13 Jul 2016 09:05:06 -0400 Subject: [PATCH 266/310] Update Version Update Version to 2.12.2 --- Version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Version b/Version index 3cf561c0b..371a952d6 100644 --- a/Version +++ b/Version @@ -1 +1 @@ -2.12.1 +2.12.2 From 7a7c187e3243d7517d8effffbcb8d9320169f6e2 Mon Sep 17 00:00:00 2001 From: junxiawang Date: Wed, 13 Jul 2016 10:33:27 -0400 Subject: [PATCH 267/310] modify genesis test case --- xCAT-test/autotest/testcase/genesis/cases0 | 46 +++-- .../autotest/testcase/genesis/genesistest.pl | 185 ++++++++++++++++++ 2 files changed, 211 insertions(+), 20 deletions(-) create mode 100755 xCAT-test/autotest/testcase/genesis/genesistest.pl diff --git a/xCAT-test/autotest/testcase/genesis/cases0 b/xCAT-test/autotest/testcase/genesis/cases0 index c324de5ff..a42c2101a 100644 --- a/xCAT-test/autotest/testcase/genesis/cases0 +++ b/xCAT-test/autotest/testcase/genesis/cases0 @@ -3,40 +3,46 @@ description: verify could log in genesis shell cmd:nodeset $$CN shell check:rc==0 cmd:rpower $$CN boot -cmd: perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/cmdtest.pl -t $$CN +check:rc==0 +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -t -n $$CN cmd:xdsh $$CN cat /proc/cmdline check:rc==0 check:output=~BOOT_IMAGE=/xcat/genesis.kernel cmd:nodeset $$CN boot +cmd:rpower $$CN boot check:rc==0 end + start:nodeset_cmdline description:verify could run cmdline successfully -cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/cmdtest.pl -c __GETNODEATTR($$CN,arch)__ +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -d -r __GETNODEATTR($$CN,arch)__ cmd:nodeset $$CN runcmd="cmdtest,shell" check:rc==0 cmd:rpower $$CN boot check:rc==0 -cmd: perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/cmdtest.pl -t $$CN -cmd:xdsh $$CN "cat /tmp/cmdtest" +cmd: perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -t -n $$CN +cmd:xdsh $$CN "cat /tmp/testresult" check:rc==0 -check:output=~test -cmd:nodeset $$CN boot -check:rc==0 -cmd:rm -rf /tmp/cmdtest -end -start:nodeset_runimg -description:verify runimg could work -cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/cmdtest.pl -i $$CN $$imgdirip +check:output=~testcmd +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -c -n $$CN -r __GETNODEATTR($$CN,arch)__ +check:rc==0 +cmd:rpower $$CN boot +check:rc==0 +end + +start:nodeset_runimg +description:verify runimg could work +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -g -n $$CN -i $$imgip +check:rc==0 +cmd:rpower $$CN boot +check:rc==0 +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -t -n $$CN +check:rc==0 +cmd:xdsh $$CN "cat /tmp/testresult" +check:output=~testimg +check:rc==0 +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -c -n $$CN -r __GETNODEATTR($$CN,arch)__ check:rc==0 cmd:rpower $$CN boot check:rc==0 -cmd: perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/cmdtest.pl -t $$CN -check:rc==0 -cmd:xdsh $$CN "cat /tmp/cmdtest" -check:output=~test -check:rc==0 -cmd:nodeset $$CN boot -cmd:rm -rf /install/my_image -cmd:rm -rf /tmp/runme.sh end diff --git a/xCAT-test/autotest/testcase/genesis/genesistest.pl b/xCAT-test/autotest/testcase/genesis/genesistest.pl new file mode 100755 index 000000000..187b04187 --- /dev/null +++ b/xCAT-test/autotest/testcase/genesis/genesistest.pl @@ -0,0 +1,185 @@ +#!/usr/bin/env perl +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html + +use strict; +use warnings; +use Getopt::Long; +use Data::Dumper; +use Term::ANSIColor; +use Time::Local; +use File::Basename; +use File::Path; +use File::Copy; +BEGIN +{ + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; +} +use lib "$::XCATROOT/lib/perl"; +my $needhelp = 0; +my $rungenesiscmd = 0; +my $rungenesisimg = 0; +my $shellmode = 0; +my $cmdtest="/tmp/cmdtest"; +my $timesleep = 0; +my $noderange = 0; +my $clearenv = 0; +my $arch = 0; +my $imgip ; +my $runimgtest="/tmp/imgtest"; +my $testresult="/tmp/testresult"; +my $genesisdir="/opt/xcat/share/xcat/netboot/genesis"; +my $genesisfiledir="$genesisdir/$arch/fs/bin"; + +if ( + !GetOptions("h|?" => \$::HELP, + "d"=>\$rungenesiscmd, + "g"=>\$rungenesisimg, + "t"=>\$timesleep, + "c"=>\$clearenv, + "n=s"=>\$::NODE, + "i=s"=>\$::IMGIP, + "r=s"=>\$::ARCH) +) +{ + &usage; + exit 1; +} +sub usage +{ + print "Usage:run genesis cases.\n"; + print " genesistest.pl [-?|-h]\n"; + print " genesistest.pl [-d] [-n node] [-r arch] Test runcmd for genesis \n"; + print " genesistest.pl [-g] [-n ndoe] [-i imgip] Test runimg for genesis\n"; + print " genesistest.pl [-t] [-n node] Sleep for genesis test\n"; + print " genesistest.pl [-c] [-n node][-r arch] Clear environment for genesis test\n"; + print "\n"; + return; +} +sub runcmd +{ + my ($cmd) = @_; + my $rc = 0; + $::RUNCMD_RC = 0; + my $outref = []; + @$outref = `$cmd 2>&1`; + if ($?) + { + $rc = $? ; + $rc = $rc >> 8; + $::RUNCMD_RC = $rc; + } + chomp(@$outref); + return @$outref; + +} +sub rungenesiscmd +{ + open(TESTCMD, ">$cmdtest") + or die "Can't open testscripts for writing: $!"; + print TESTCMD join("\n", "#!/bin/bash"), "\n"; + print TESTCMD join("\n", "#This is test for genesis scripts"), "\n"; + print TESTCMD join("\n", "echo \"testcmd\" >> $testresult"), "\n"; + close(TESTCMD); + if ($arch =~ /ppc64/) + { + $arch = "ppc64"; + } + $genesisfiledir="$genesisdir/$arch/fs/bin"; + copy("$cmdtest" ,"$genesisfiledir"); + chmod 0755, "$genesisfiledir/cmdtest"; + `mknb $arch`; + print "mknb $arch\n"; +} +sub rungenesisimg +{ + mkdir("/install/my_image"); + open(TESTIMG, ">$runimgtest") + or die "Can't open testscripts for writing: $!"; + print TESTIMG join("\n", "#!/bin/bash"), "\n"; + print TESTIMG join("\n", "#This is test for genesis scripts"), "\n"; + print TESTIMG join("\n", "echo \"testimg\" >> $testresult"), "\n"; + close(TESTIMG); + copy("$runimgtest" ,"/install/my_image/runme.sh" ) or die "Copy failed: $!"; + chmod 0755,"/install/my_image/runme.sh"; + `cd /install/my_image ;tar -zcvf my_image.tgz .`; + `nodeset $noderange "runimage=http://$imgip/install/my_image/my_image.tgz",shell`; +} +sub timesleep +{ + my @output = runcmd("ping $noderange -c 10"); + my $value = 0; + print "output is $value ,@output\n"; + if ($::RUNCMD_RC){ + foreach $value (1 .. 60) { + @output = runcmd("ping $noderange -c 10"); + last if ($::RUNCMD_RC == 0); + } + } + my @output1 = runcmd("xdsh $noderange date"); + if ($::RUNCMD_RC){ + foreach $value (1 .. 60) { + @output1 = runcmd("xdsh $noderange -t 1 date"); + print "sleep $value\n"; + last if ($::RUNCMD_RC == 0); + } + } + if ($::RUNCMD_RC == 0){ + print "test ok\n"; + } +} +sub clearenv +{ + if (-f "/tmp/imgtest"){ + unlink("/install/my_image/runme.sh"); + unlink("/install/my_image/my_image.tgz"); + unlink("$runimgtest"); + rmdir("/install/my_image"); + print "img del ok\n"; + } + if (-f "/tmp/cmdtest"){ + if ($arch =~ /ppc64/) + { + $arch = "ppc64"; + } + + $genesisfiledir="$genesisdir/$arch/fs/bin"; + my $genesisfile = "$genesisfiledir/cmdtest"; + print "genesis file is $genesisfile\n"; + unlink("$genesisfile"); + unlink("$cmdtest"); + `mknb $arch`; + print "mknb $arch\n"; + } + `nodeset $noderange boot`; +} +if ($::NODE) +{ + $noderange = $::NODE; +} +if($::ARCH) +{ + $arch = $::ARCH; +} +if($::IMGIP) +{ + $imgip = $::IMGIP; +} +if ($::HELP) { +usage; +} +if ($rungenesiscmd) +{ + &rungenesiscmd; +} +if ($timesleep) +{ + ×leep; +} +if($rungenesisimg) + { + &rungenesisimg; + } +if($clearenv) +{ + &clearenv; +} From a89875b26a36fdf88238646b605665541c0c4a5a Mon Sep 17 00:00:00 2001 From: XuWei Date: Mon, 11 Jul 2016 02:07:51 -0400 Subject: [PATCH 268/310] Fix xcatprobe issue, discovery and osdeploy --- xCAT-probe/subcmds/discovery | 88 +++++++- xCAT-probe/subcmds/osdeploy | 427 ++++++++++++++++++++++++----------- 2 files changed, 377 insertions(+), 138 deletions(-) diff --git a/xCAT-probe/subcmds/discovery b/xCAT-probe/subcmds/discovery index 0bfe2a9e5..e0a40201d 100755 --- a/xCAT-probe/subcmds/discovery +++ b/xCAT-probe/subcmds/discovery @@ -86,8 +86,8 @@ sub check_genesis_file { probe_utils->send_msg("$output", "d", "The OS is not supported.") if ($verbose); return 1; } elsif ($os =~ "ubuntu") { - $genesis_base = `dpkg -l | grep -i "xcat-genesis-base" | grep -i "$arch_tmp"`; - $genesis_scripts = `dpkg -l | grep -i "xcat-genesis-scripts" | grep -i "$arch_tmp"`; + $genesis_base = `dpkg -l | grep -iE "ii\\s+xcat-genesis-base" | grep -i "$arch_tmp"`; + $genesis_scripts = `dpkg -l | grep -iE "ii\\s+xcat-genesis-scripts" | grep -i "$arch_tmp"`; } else { $genesis_base = `rpm -qa | grep -i "xcat-genesis-base" | grep -i "$arch"`; $genesis_scripts = `rpm -qa | grep -i "xcat-genesis-scripts" | grep -i "$arch"`; @@ -267,6 +267,55 @@ sub check_genesis_file { return $rst_f; } +sub get_node_ip { + my $ip_net; + my @node_info = `lsdef $noderange -i ip -c 2>&1`; + my %nodeip; + my %nodecheckrst; + + foreach (@node_info) { + chomp($_); + $_ =~ s/^\s+|\s+$//g; + if ($_ =~ /^Error: Could not find an object named '(\w+)' .+/i) { + $nodecheckrst{$1}{"error"} = "Could not find node definition"; + $rst = 1; + } elsif ($_ =~ /^(\w+): ip=(.+)/i) { + $nodeip{$1} = $2; + } + } + + foreach my $node (keys %nodeip) { + $ip_net = xCAT::NetworkUtils->getipaddr($node); + if ($nodeip{$node} and ($nodeip{$node} ne $ip_net)) { + probe_utils->send_msg("$output", "d", "IP $nodeip{$node} of definition for $node is not correct") if ($verbose); + } + $nodeip{$node} = $ip_net; + } + + foreach my $node (keys %nodecheckrst) { + probe_utils->send_msg("$output", "d", "$node : $nodecheckrst{$node}{error}") if(exists($nodecheckrst{$node}{error})); + } + + return %nodeip; +} + +sub compare_ip_value { + my $ip1 = shift; + my $ip2 = shift; + + my @ip_arr1 = split(/\./, $ip1); + my @ip_arr2 = split(/\./, $ip2); + + my $ip_num1 = ($ip_arr1[0] << 24) | ($ip_arr1[1] << 16) | ($ip_arr1[2] << 8) | $ip_arr1[3]; + my $ip_num2 = ($ip_arr2[0] << 24) | ($ip_arr2[1] << 16) | ($ip_arr2[2] << 8) | $ip_arr2[3]; + + if ($ip_num1 <= $ip_num2) { + return 1; + } + + return 0; +} + #------------------------------------------ =head3 @@ -291,6 +340,8 @@ sub dhcp_dynamic_range_check { $dhcpconfig = "/etc/dhcp/dhcpd.conf"; } elsif (-e "/etc/dhcp3/dhcpd.conf") { $dhcpconfig = "/etc/dhcp3/dhcpd.conf"; + } elsif (-e "/etc/dhcpd.conf") { + $dhcpconfig = "/etc/dhcpd.conf"; } unless ($dhcpconfig) { @@ -300,7 +351,7 @@ sub dhcp_dynamic_range_check { my $config_line; my $subnet; - my $dynamic_range; + my @dynamic_range; my %subnet_hash; unless (open(FILE, $dhcpconfig)) { @@ -318,12 +369,17 @@ sub dhcp_dynamic_range_check { $subnet_hash{$subnet} = "unknown"; } if ($config_line =~ /subnet_end/) { - $subnet_hash{$subnet} = $dynamic_range if ($dynamic_range); + $subnet_hash{$subnet} = [@dynamic_range] if (@dynamic_range); $subnet = ""; - $dynamic_range = ""; + @dynamic_range = ""; } if ($config_line =~ /^range dynamic-bootp (\d+.\d+.\d+.\d+) (\d+.\d+.\d+.\d+)/) { - $dynamic_range = "$1-$2"; + if (compare_ip_value($1, $2)) { + push @dynamic_range, "$1-$2"; + } else { + push @dynamic_range, "$2-$1"; + } + } } @@ -340,6 +396,11 @@ sub dhcp_dynamic_range_check { $tftpdir = "/tftpboot"; } + my %node_ip; + if ($noderange) { + %node_ip = get_node_ip(); + } + foreach my $net (@$nets) { if (!exists($subnet_hash{$net})) { @@ -349,7 +410,20 @@ sub dhcp_dynamic_range_check { } if ($subnet_hash{$net} ne "unknown") { - probe_utils->send_msg("$output", "d", "Dynamic range for net $net is $subnet_hash{$net}.") if ($verbose); + probe_utils->send_msg("$output", "d", "Dynamic range for net $net is @{$subnet_hash{$net}}.") if ($verbose); + + if (%node_ip) { + foreach my $node (keys %node_ip) { + foreach my $dr (@{$subnet_hash{$net}}) { + my @dr_ip = split(/-/, $dr); + + if (compare_ip_value($dr_ip[0], $node_ip{$node}) and compare_ip_value($node_ip{$node}, $dr_ip[1])) { + probe_utils->send_msg("$output", "d", "$node ip $node_ip{$node} is conflicting with dynamic range.") if ($verbose); + $rst = 1; + } + } + } + } } else { probe_utils->send_msg("$output", "d", "Dynamic range for net $net did not be configured.") if ($verbose); $rst = 1; diff --git a/xCAT-probe/subcmds/osdeploy b/xCAT-probe/subcmds/osdeploy index e2a2e10ba..3040efa22 100755 --- a/xCAT-probe/subcmds/osdeploy +++ b/xCAT-probe/subcmds/osdeploy @@ -14,14 +14,14 @@ use Getopt::Long qw(:config no_ignore_case); my $program_name = basename("$0"); my $help; my $test; -my $output = "stdout"; -my $verbose = 0; -my $rst = 0; +my $output = "stdout"; +my $verbose = 0; +my $rst = 0; my $noderange; my %rawdata; my %ipnodemap; my %macmap; -my $terminal = 0; +my $terminal = 0; my %monitor_nodes; $::USAGE = "Usage: @@ -40,7 +40,19 @@ Options: -n : The range of monitored node. "; -sub check_noderange{ +#------------------------------------------ +=head3 + Description: + Check if all nodes are valid + Arguments: + node_range: node range + Returns: + 0 : pass + 1 : failed +=cut + +#------------------------------------------ +sub check_noderange { my $node_range = shift; my @cmdoutput = `lsdef $node_range -i ip,mac 2>&1`; my $rst = 0; @@ -58,30 +70,34 @@ sub check_noderange{ $nodecheckrst{$currentnode}{"error"} = "Could not find node definition"; $rst = 1; } elsif ($_ =~ /^\s*Object name: (\w+)/i) { - $monitor_nodes{$1} = 0; - $currentnode = $1; - $ip = "NOIP"; + # 'rst' is used to check whether the node process finished, 1 is finished. + $monitor_nodes{$1}{"rst"} = 0; + $currentnode = $1; + $ip = "NOIP"; } elsif ($_ =~ /^ip=(.+)/i) { - $ip = $1; + if ($1) { + $ip = $1; + } } elsif ($_ =~ /^mac=(.+)/i) { + next unless ($1); $mac_line = $1; @macs = split(/\|/, $mac_line); - foreach my $mac(@macs) { + foreach my $mac (@macs) { if ($mac =~ /\!\*NOIP\*/) { $mac =~ s/\!\*NOIP\*//g; - $macmap{$mac}{"ip"} = "NOIP"; + $macmap{$mac}{"ip"} = "NOIP"; $macmap{$mac}{"node"} = $currentnode; } else { - $macmap{$mac}{"ip"} = $ip; + $macmap{$mac}{"ip"} = $ip; $macmap{$mac}{"node"} = $currentnode; } } } - } + } foreach my $node (keys %nodecheckrst) { - probe_utils->send_msg("$output", "d", "$node : $nodecheckrst{$node}{error}") if(exists($nodecheckrst{$node}{error})); + probe_utils->send_msg("$output", "d", "$node : $nodecheckrst{$node}{error}") if (exists($nodecheckrst{$node}{error})); } unless (%monitor_nodes) { @@ -91,31 +107,45 @@ sub check_noderange{ return $rst; } +#------------------------------------------ + +=head3 + Description: + Handle one line log come from dhcp log file + Arguments: + msg: one line http log + nics: target network interfaces + Returns: + 0 : pass + 1 : failed +=cut + +#------------------------------------------ sub handle_dhcp_msg { my $msg = shift; - if ($msg =~ /.+DHCPDISCOVER\s+from\s+(.+)\s+via\s+([^:]+)(.*)/i) { - my $mac = $1; - my $nic = $2; + if ($msg =~ /.+DHCPDISCOVER\s+from\s+(.+)\s+via\s+([^:]+)(.*)/i) { + my $mac = $1; + my $nic = $2; if (exists $macmap{$mac}) { - my $node = $macmap{$mac}{"node"}; + my $node = $macmap{$mac}{"node"}; my $record = "Receive DHCPDISCOVER from [$node] $mac via $nic"; probe_utils->send_msg("$output", "d", "$record"); push(@{ $rawdata{$node}{"history"} }, $record); } } elsif ($msg =~ /.+DHCPOFFER\s+on\s+(.+)\s+to\s+(.+)\s+via\s+(.+)/i) { - my $ip = $1; - my $mac = $2; - my $nic = $3; + my $ip = $1; + my $mac = $2; + my $nic = $3; if (exists $macmap{$mac}) { - my $node = $macmap{$mac}{"node"}; + my $node = $macmap{$mac}{"node"}; my $record = "Send DHCPOFFER on $ip back to [$node] $mac via $nic"; probe_utils->send_msg("$output", "d", "$record"); push(@{ $rawdata{$node}{"history"} }, $record); } - + } elsif ($msg !~ /unknown lease/ && $msg !~ /ignored/ && $msg =~ /.+DHCPREQUEST\s+for\s+(.+)\s\((.+)\)\s+from\s+(.+)\s+via\s+(.+)/) { my $ip = $1; my $server = $2; @@ -125,7 +155,7 @@ sub handle_dhcp_msg { if (exists $macmap{$mac}) { my $node = $macmap{$mac}{"node"}; my $record = "Receive DHCPREQUEST from [$node] $mac for $ip via $nic"; - probe_utils->send_msg("$output", "d", "$record"); + probe_utils->send_msg("$output", "d", "$record"); push(@{ $rawdata{$node}{"history"} }, $record); if ($macmap{$mac}{"ip"} != "NOIP" and $macmap{$mac}{"ip"} != $ip) { @@ -135,9 +165,9 @@ sub handle_dhcp_msg { } } } elsif ($msg =~ /.+DHCPACK\s+on\s+(.+)\s+to\s+(.+)\s+via\s+(.+)/) { - my $ip = $1; - my $mac = $2; - my $nic = $3; + my $ip = $1; + my $mac = $2; + my $nic = $3; if (exists $macmap{$mac}) { my $node = $macmap{$mac}{"node"}; @@ -157,12 +187,12 @@ sub handle_dhcp_msg { push(@{ $rawdata{$node}{"history"} }, $record); } } elsif ($msg =~ /.+BOOTREPLY\s+for\s+(.+)\s+to\s+.+(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w).+via\s+(.+)/) { - my $ip = $1; - my $mac = $2; - my $nic = $3; + my $ip = $1; + my $mac = $2; + my $nic = $3; if (exists $macmap{$mac}) { - my $node = $macmap{$mac}{"node"}; + my $node = $macmap{$mac}{"node"}; my $record = "Send BOOTREPLY on $ip back to [$node] $mac via $nic"; probe_utils->send_msg("$output", "d", "$record"); push(@{ $rawdata{$node}{"history"} }, $record); @@ -179,13 +209,54 @@ sub handle_dhcp_msg { return 0; } +#------------------------------------------ + +=head3 + Description: + Handle one line log come from tftp log file + Arguments: + msg: one line tftp log + Returns: + 0 : pass + 1 : failed +=cut + +#------------------------------------------ +sub handle_tftp_msg { + my $msg = shift; + + if ($msg =~ /RRQ\s+from\s+(.+)\s+filename\s+(.+)/i) { + my $ip = $1; + my $file = $2; + my $record = "[$ipnodemap{$ip}] Via TFTP $ip download $file"; + + if (exists($rawdata{"$ipnodemap{$ip}"})) { + probe_utils->send_msg("$output", "d", "$record"); + push(@{ $rawdata{ $ipnodemap{$ip} }{"history"} }, $record); + } + } +} + +#------------------------------------------ + +=head3 + Description: + Handle one line log come from http log file + Arguments: + msg: one line http log + Returns: + 0 : pass + 1 : failed +=cut + +#------------------------------------------ sub handle_http_msg { my $msg = shift; if ($msg =~ /(\d+\.\d+.\d+.\d+)\s.+GET\s+(.+)\s+HTTP.+/) { my $ip = $1; my $file = $2; my $record = "[$ipnodemap{$ip}] Via HTTP $ip GET $file"; - + if (exists($rawdata{"$ipnodemap{$ip}"})) { probe_utils->send_msg("$output", "d", "$record"); push(@{ $rawdata{ $ipnodemap{$ip} }{"history"} }, $record); @@ -194,50 +265,73 @@ sub handle_http_msg { return 0; } +#------------------------------------------ + +=head3 + Description: + Handle one line log come from cluster.log + Arguments: + msg: one line log + Returns: + 0 : pass + 1 : failed +=cut + +#------------------------------------------ sub handle_cluster_msg { - my $line = shift; - my $sender = ""; - my $node = ""; + my $line = shift; + my $node = ""; my $msg; my $status; - if ($line =~ /.+\d{2}:\d{2}:\d{2}\s+(.+)\s+(xcat.+)/i) { - $sender = $1; - $msg = $2; - - if (!xCAT::NetworkUtils->isIpaddr($sender)) { - $node = $sender; - } else { - $node = $ipnodemap{$sender}; - } - if ($node ne "" && exists($rawdata{$node})) { - my $record = "Receive from $node : $msg"; - probe_utils->send_msg("$output", "d", "$record"); - push(@{ $rawdata{ $node }{"history"} }, $record); - } - } - if ($line =~ /.+\s+xcat:\s+(.+)\s+status:\s+(.+)\s+statustime:\s(.+)/) { - $node = $1; + $node = $1; $status = $2; if (exists($rawdata{$node})) { my $record = "Receive from $node : status is $status"; probe_utils->send_msg("$output", "d", "$record"); - push(@{ $rawdata{ $node }{"history"} }, $record); + push(@{ $rawdata{$node}{"history"} }, $record); } - + + # When receive 'status is booted', check whether the $monitor_nodes{$node}{"status"} is installing. + # If so, the node has finished its os provision. if (exists($rawdata{$node}) and ($status eq "booted")) { - $monitor_nodes{$node} = 1 if (defined($monitor_nodes{$node})); - probe_utils->send_msg("$output", "o", "Node $node has finished it's os provision process"); + if ($monitor_nodes{$node}{"status"} eq "installing") { + $record = "Node $node has finished it's os provision process"; + probe_utils->send_msg("$output", "o", "$record"); + push(@{ $rawdata{$node}{"history"} }, $record); + } else { + $record = "NO installing process detected for node $node"; + probe_utils->send_msg("$output", "f", "$record"); + push(@{ $rawdata{$node}{"history"} }, $record); + } + $monitor_nodes{$node}{"rst"} = 1 if (defined($monitor_nodes{$node})); } elsif (exists($rawdata{$node}) and ($status eq "failed")) { - $monitor_nodes{$node} = 1 if (defined($monitor_nodes{$node})); + $monitor_nodes{$node}{"rst"} = 1 if (defined($monitor_nodes{$node})); probe_utils->send_msg("$output", "f", "Node $node has finished it's os provision process"); + push(@{ $rawdata{$node}{"history"} }, "Node $node os provision failed"); + } elsif (exists($rawdata{$node}) and ($status eq "installing")) { + # record 'installing' status, to check when receive 'booted' status + $monitor_nodes{$node}{"status"} = "installing"; } } return 0; } +#----------------------------------------- + +=head3 + Description: + Handle one line log come from computes.log + Arguments: + msg: one line compute log + Returns: + 0 : pass + 1 : failed +=cut + +#----------------------------------------- sub handle_compute_msg { my $line = shift; my $sender; @@ -256,25 +350,50 @@ sub handle_compute_msg { if ($node ne "" && exists($rawdata{$node})) { my $record = "Receive from $node : $msg"; probe_utils->send_msg("$output", "d", "$record"); - push(@{ $rawdata{ $node }{"history"} }, $record); + push(@{ $rawdata{$node}{"history"} }, $record); } } return 0; } +#------------------------------------------ + +=head3 + Description: + Test if all nodes have finished job + Arguments: + One golble attribute %monitor_nodes; + Returns: + 1: all nodes finished + 0: not all nodes finished +=cut + +#------------------------------------------ sub all_monitor_node_done { my $done = 1; + foreach my $node (keys %monitor_nodes) { - if ($monitor_nodes{$node} == 0) { + if ($monitor_nodes{$node}{"rst"} == 0) { $done = 0; last; } } - + return $done; } +#------------------------------------------ + +=head3 + Description: + Dump monitor history, categorised by mac address. + Arguments: + NULL + Returns: +=cut + +#------------------------------------------ sub dump_history { my $title = " @@ -288,20 +407,21 @@ sub dump_history { my $line_num = 0; my $http_num = 0; my $length_http; - for (my $i = @{ $rawdata{$node}{"history"} }; $i >=0; $i--) { + for (my $i = @{ $rawdata{$node}{"history"} } ; $i >= 0 ; $i--) { if (${ $rawdata{$node}{"history"} }[$i] =~ /Via HTTP/) { $length_http = $i; last; } } foreach my $line (@{ $rawdata{$node}{"history"} }) { + # Print http message less than 10 lines if ($line =~ /Via HTTP/) { - if (($http_num <= 4) or ($length_http - $line_num <= 4)){ + if (($http_num <= 4) or ($length_http - $line_num <= 4)) { probe_utils->send_msg("$output", "d", "\t$line"); } else { - probe_utils->send_msg("$output", "d", "\t......") if ($http_num ==5); + probe_utils->send_msg("$output", "d", "\t......") if ($http_num == 5); } $http_num++; } else { @@ -312,13 +432,24 @@ sub dump_history { } } -sub do_monitor{ +#------------------------------------------ + +=head3 + Description: + Monitor the process of os provision + Returns: + 0: pass + 1: failed +=cut + +#------------------------------------------ +sub do_monitor { $SIG{TERM} = $SIG{INT} = sub { $terminal = 1; }; my $msg = "All pre_defined nodes are valid"; - my $rc = check_noderange($noderange); + my $rc = check_noderange($noderange); if ($rc) { probe_utils->send_msg("$output", "f", $msg); $rst = 1; @@ -341,17 +472,17 @@ sub do_monitor{ } my $rst = 0; - my $startline = -"------------------------------------------------------------- + my $startline = + "------------------------------------------------------------- Start to capture every message during os provision process...... ------------------------------------------------------------- "; print("$startline\n"); - my $varlogmsg = "/var/log/messages"; + my $varlogmsg = "/var/log/messages"; my $clusterlog = "/var/log/xcat/cluster.log"; - my $computelog = "/var/log/xcat/computes.log"; + my $computelog = "/var/log/xcat/computes.log"; my $httplog; if (-e "/var/log/httpd/access_log") { @@ -367,71 +498,105 @@ Start to capture every message during os provision process...... my $httppid; my $computerpid; - if (!($varlogpid = open(VARLOGMSGFILE, "tail -f -n 0 $varlogmsg 2>&1 |"))) { - probe_utils->send_msg("$output", "f", "Can't open $varlogmsg to get logs"); - $rst = 1; - last; - } - if (!($clusterpid = open(CLUSTERLOGFILE, "tail -f -n 0 $clusterlog 2>&1 |"))) { - probe_utils->send_msg("$output", "f", "Can't open $clusterlog to get logs"); - $rst = 1; - last; - } - if (!($httppid = open(HTTPLOGFILE, "tail -f -n 0 $httplog 2>&1 |"))) { - probe_utils->send_msg("$output", "f", "Can't open $httplog to get logs"); - $rst = 1; - last; - } - if (!($computerpid = open(COMPUTERFILE, "tail -f -n 0 $computelog 2>&1 |"))) { - probe_utils->send_msg("$output", "f", "Can't open $computelog to get logs"); - $rst = 1; - last; - } - - my $select = new IO::Select; - $select->add(\*VARLOGMSGFILE); - $select->add(\*CLUSTERLOGFILE); - $select->add(\*HTTPLOGFILE); - $select->add(\*COMPUTERFILE); - $| = 1; - - my $line = ""; - my @hdls; - my $hdl; - - for (; ;){ - if (@hdls = $select->can_read(0)) { - foreach $hdl (@hdls) { - if ($hdl == \*VARLOGMSGFILE) { - chomp($line = ); - my @tmp = split(/\s+/, $line); - if ($tmp[4] =~ /dhcpd:/i && $line =~ /$nics/) { - handle_dhcp_msg("$line"); - } - } elsif ($hdl == \*CLUSTERLOGFILE) { - chomp($line = ); - handle_cluster_msg("$line"); - } elsif ($hdl == \*HTTPLOGFILE) { - chomp($line = ); - handle_http_msg("$line"); - } elsif ($hdl == \*COMPUTERFILE) { - chomp($line = ); - handle_compute_msg("$line"); - } + { + if (!-e $varlogmsg) { + probe_utils->send_msg("$output", "w", "$varlogmsg doesn't exist"); + } else { + if (!($varlogpid = open(VARLOGMSGFILE, "tail -f -n 0 $varlogmsg 2>&1 |"))) { + probe_utils->send_msg("$output", "f", "Can't open $varlogmsg to get logs"); + $rst = 1; + last; } } - if ($terminal || (%monitor_nodes && all_monitor_node_done())) { - if ($terminal) { - probe_utils->send_msg("$output", "d", "Get INT or TERM signal from STDIN"); - } else { - probe_utils->send_msg("$output", "o", "All nodes need to monitor have finished os provision process"); + if (!-e "$clusterlog") { + probe_utils->send_msg("$output", "w", "$clusterlog doesn't exist"); + } else { + if (!($clusterpid = open(CLUSTERLOGFILE, "tail -f -n 0 $clusterlog 2>&1 |"))) { + probe_utils->send_msg("$output", "f", "Can't open $clusterlog to get logs"); + $rst = 1; + last; } - last; - } sleep 0.01; - } - &dump_history; + } + if (!-e "$httplog") { + probe_utils->send_msg("$output", "w", "$httplog doesn't exist"); + } else { + if (!($httppid = open(HTTPLOGFILE, "tail -f -n 0 $httplog 2>&1 |"))) { + probe_utils->send_msg("$output", "f", "Can't open $httplog to get logs"); + $rst = 1; + last; + } + } + if (!-e "$computelog") { + probe_utils->send_msg("$output", "w", "$computelog doesn't exist"); + } else { + if (!($computerpid = open(COMPUTERFILE, "tail -f -n 0 $computelog 2>&1 |"))) { + probe_utils->send_msg("$output", "f", "Can't open $computelog to get logs"); + $rst = 1; + last; + } + } + my $select = new IO::Select; + $select->add(\*VARLOGMSGFILE); + $select->add(\*CLUSTERLOGFILE); + $select->add(\*HTTPLOGFILE); + $select->add(\*COMPUTERFILE); + $| = 1; + + my $line = ""; + my @hdls; + my $hdl; + + my @candidate_svr_hostname_inlog; + my $svr_hostname_short = `hostname -s`; + chomp($svr_hostname_short); + my $svr_hostname_domain = `hostname -d`; + chomp($svr_hostname_domain); + push(@candidate_svr_hostname_inlog, $svr_hostname_short); + push(@candidate_svr_hostname_inlog, "$svr_hostname_short.$svr_hostname_domain"); + + for (; ;) { + if (@hdls = $select->can_read(0)) { + foreach $hdl (@hdls) { + if ($hdl == \*VARLOGMSGFILE) { + chomp($line = ); + my @tmp = split(/\s+/, $line); + if ($tmp[4] =~ /dhcpd:/i && $line =~ /$nics/) { + handle_dhcp_msg("$line"); + } elsif ($tmp[4] =~ /in.tftpd/i) { + handle_tftp_msg("$line"); + } elsif (($tmp[4] =~ /^xcat/i) || ($tmp[5] =~ /^xcat/i)) { + if (grep(/^$tmp[3]$/, @candidate_svr_hostname_inlog)) { + handle_cluster_msg("$line"); + } else { + handle_compute_msg("$line"); + } + } + } elsif ($hdl == \*CLUSTERLOGFILE) { + chomp($line = ); + handle_cluster_msg("$line"); + } elsif ($hdl == \*HTTPLOGFILE) { + chomp($line = ); + handle_http_msg("$line"); + } elsif ($hdl == \*COMPUTERFILE) { + chomp($line = ); + handle_compute_msg("$line"); + } + } + } + + if ($terminal || (%monitor_nodes && all_monitor_node_done())) { + if ($terminal) { + probe_utils->send_msg("$output", "d", "Get INT or TERM signal from STDIN"); + } else { + probe_utils->send_msg("$output", "o", "All nodes need to monitor have finished os provision process"); + } + last; + } sleep 0.01; + } + &dump_history; + } kill 'INT', $varlogpid if ($varlogpid); kill 'INT', $clusterpid if ($clusterpid); kill 'INT', $httppid if ($httppid); @@ -472,8 +637,8 @@ if ($test) { exit 0; } -unless ( $noderange ) { - probe_utils->send_msg("$output", "f", "Option -n is required"); +unless ($noderange) { + probe_utils->send_msg("$output", "f", "Option -n is required"); probe_utils->send_msg("$output", "d", "$::USAGE"); exit 1; } From 7b9224a6a45467a1cc713290cd73f6e93d6f463c Mon Sep 17 00:00:00 2001 From: XuWei Date: Mon, 11 Jul 2016 03:41:42 -0400 Subject: [PATCH 269/310] add powering-on status for fsp --- perl-xCAT/xCAT/FSPpower.pm | 130 +++++++++++++++++++++++-------------- 1 file changed, 81 insertions(+), 49 deletions(-) diff --git a/perl-xCAT/xCAT/FSPpower.pm b/perl-xCAT/xCAT/FSPpower.pm index c5be978a4..4b9d1517d 100644 --- a/perl-xCAT/xCAT/FSPpower.pm +++ b/perl-xCAT/xCAT/FSPpower.pm @@ -6,6 +6,8 @@ use strict; use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR); use xCAT::PPCpower; use xCAT::FSPUtils; +use xCAT::GlobalDef; +use xCAT_monitoring::monitorctrl; #use Data::Dumper; ########################################################################## @@ -51,7 +53,7 @@ sub enumerate { } foreach my $type ( keys %cmds ) { my $action = $cmds{$type}; - #my $values = xCAT::FSPUtils::fsp_state_action ($request, $cec_bpa, $type, $action, $tooltype); + #my $values = xCAT::FSPUtils::fsp_state_action ($request, $cec_bpa, $type, $action, $tooltype); my $values = xCAT::FSPUtils::fsp_state_action ($request, $cec_bpa, $tmp_d, $action, $tooltype); my $Rc = shift(@$values); ################################## @@ -89,11 +91,6 @@ sub enumerate { return( [0,\%outhash] ); } - - - - - ########################################################################## # Performs boot operation (Off->On, On->Reset) ########################################################################## @@ -103,7 +100,8 @@ sub powercmd_boot { my $hash = shift; my @output = (); - + my $newstat; + my %newnodestatus=(); ###################################### # Power commands are grouped by CEC # not Hardware Control Point @@ -153,24 +151,31 @@ sub powercmd_boot { #print "boot:state:$state\n"; my $op = ($state =~ /^off$/) ? "on" : "reset"; + $newstat = $::STATUS_POWERING_ON; + # Attribute powerinterval in site table, # to control the rpower speed if( defined($request->{'powerinterval'}) ) { Time::HiRes::sleep($request->{'powerinterval'}); } - $res = xCAT::FSPUtils::fsp_api_action ($request,$node_name, $d, $op); # @output ... $Rc = @$res[2]; $data = @$res[1]; if ( $Rc != SUCCESS ) { - push @output, [$node_name,$data,$Rc]; - next; - } - push @output,[$node_name, "Success", 0]; - + push @output, [$node_name,$data,$Rc]; + next; + } + + push @output,[$node_name, "Success", 0]; + if ($newstat) { + push @{ $newnodestatus{$newstat} }, $node_name; + } + } + if (%newnodestatus) { + xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); } return( \@output ); } @@ -215,50 +220,70 @@ sub powercmd { # 0 # ] # }; - + my $newstat; + my @updatenode; + my %newnodestatus=(); foreach $node_name ( keys %$hash) { - $action = $request->{'op'}; + $action = $request->{'op'}; my $d = $hash->{$node_name}; - if ($$d[4] =~ /^lpar$/) { - if( !($action =~ /^(on|off|of|reset|sms)$/)) { - push @output, [$node_name, "\'$action\' command not supported for LPAR", -1 ]; + if ($$d[4] =~ /^lpar$/) { + if( !($action =~ /^(on|off|of|reset|sms)$/)) { + push @output, [$node_name, "\'$action\' command not supported for LPAR", -1 ]; return (\@output); - } - $newids .= "$$d[0],"; - $newnames .="$node_name,"; - $newd = $d; - $lpar_flag = 1; - } elsif ($$d[4] =~ /^(fsp|cec|blade)$/) { - if($action =~ /^on$/) { $action = "cec_on_autostart"; } - if($action =~ /^off$/) { $action = "cec_off"; } - if($action =~ /^resetsp$/) { $action = "reboot_service_processor"; } - if($action =~ /^lowpower$/) { $action = "cec_on_low_power"; } - #if($action =~ /^cycle$/) {$action = "cec_reboot";} - if($action =~ /^cycle$/) {$action = "reset";} - if($action !~ /^cec_on_autostart$/ && $action !~ /^cec_off$/ && $action !~ /^cec_on_low_power$/ && $action !~ /^onstandby$/ && $action !~ /^reboot_service_processor$/ && $action !~ /^reset$/ && $action !~ /^sms$/) { - push @output, [$node_name, "\'$action\' command not supported for $$d[4]", -1 ]; - return (\@output); - } - $newids = $$d[0]; - $newnames = $node_name; - $newd = $d; - $cec_flag = 1; + } + $newids .= "$$d[0],"; + $newnames .="$node_name,"; + $newd = $d; + $lpar_flag = 1; + if($action =~ /^on$/) { + $newstat = $::STATUS_POWERING_ON; + push @updatenode, $node_name; + } + if($action =~ /^(off|of$)/) { + $newstat = $::STATUS_POWERING_OFF; + push @updatenode, $node_name; + } + if($action =~ /^reset$/) { + my $res = xCAT::FSPUtils::fsp_api_action ($request,$node_name, $d, "state"); + my $Rc = @$res[2]; + my $data = @$res[1]; + if ( $Rc != SUCCESS ) { next; } + my $state = power_status($data); + if ($state =~ /^off$/) { next; } + $newstat = $::STATUS_POWERING_ON; + push @updatenode, $node_name; + } + } elsif ($$d[4] =~ /^(fsp|cec|blade)$/) { + if($action =~ /^on$/) { $action = "cec_on_autostart"; } + if($action =~ /^off$/) { $action = "cec_off"; } + if($action =~ /^resetsp$/) { $action = "reboot_service_processor"; } + if($action =~ /^lowpower$/) { $action = "cec_on_low_power"; } + #if($action =~ /^cycle$/) {$action = "cec_reboot";} + if($action =~ /^cycle$/) { $action = "reset"; } + if($action !~ /^cec_on_autostart$/ && $action !~ /^cec_off$/ && $action !~ /^cec_on_low_power$/ && $action !~ /^onstandby$/ && $action !~ /^reboot_service_processor$/ && $action !~ /^reset$/ && $action !~ /^sms$/) { + push @output, [$node_name, "\'$action\' command not supported for $$d[4]", -1 ]; + return (\@output); + } + $newids = $$d[0]; + $newnames = $node_name; + $newd = $d; + $cec_flag = 1; } else { - if ( $action =~ /^rackstandby$/) { - $action = "enter_rack_standby"; - } elsif ( $action=~/^exit_rackstandby$/) { - $action = "exit_rack_standby"; - } elsif ($action =~ /^resetsp$/) { - $action = "reboot_service_processor"; - } else { - push @output, [$node_name, "$node_name\'s type isn't fsp or lpar. Not allow doing this operation", -1 ]; - return (\@output); - } + if ( $action =~ /^rackstandby$/) { + $action = "enter_rack_standby"; + } elsif ( $action=~/^exit_rackstandby$/) { + $action = "exit_rack_standby"; + } elsif ($action =~ /^resetsp$/) { + $action = "reboot_service_processor"; + } else { + push @output, [$node_name, "$node_name\'s type isn't fsp or lpar. Not allow doing this operation", -1 ]; + return (\@output); + } $newids = $$d[0]; $newnames = $node_name; $newd = $d; - $frame_flag = 1; + $frame_flag = 1; } if( $lpar_flag && $cec_flag) { @@ -319,7 +344,14 @@ sub powercmd { } push @output, [$node_name,"Success", 0]; #push @output, [$node_name,$msg, 0]; + if (($newstat) and (grep{$_ eq $node_name}@updatenode)) { + push @{ $newnodestatus{$newstat} }, $node_name; + } } + } + + if (%newnodestatus) { + xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); } return( \@output ); } From b1c9c2f7e305d12c9ff5300a14440a70d4793f3c Mon Sep 17 00:00:00 2001 From: XuWei Date: Wed, 13 Jul 2016 23:19:21 -0400 Subject: [PATCH 270/310] Improve performance for hmc mgt --- perl-xCAT/xCAT/PPCpower.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/perl-xCAT/xCAT/PPCpower.pm b/perl-xCAT/xCAT/PPCpower.pm index 0ee082f51..817c4738c 100644 --- a/perl-xCAT/xCAT/PPCpower.pm +++ b/perl-xCAT/xCAT/PPCpower.pm @@ -237,7 +237,9 @@ sub powercmd_boot { $op, $d ); unless (@$result[0] != SUCCESS) { - $newnodestatus{$newstat}=[$name] if ($newstat); + if ($newstat) { + push @{ $newnodestatus{$newstat} }, $name; + } } push @output, [$name,@$result[1],@$result[0]]; } @@ -364,7 +366,7 @@ sub powercmd { unless ($Rc != SUCCESS) { if ($newstat) { - $newnodestatus{$newstat}=[$name]; + push @{ $newnodestatus{$newstat} }, $name; } } From ff60c99248802a0a17bb19e2b20381f3fa3691bd Mon Sep 17 00:00:00 2001 From: junxiawang Date: Thu, 14 Jul 2016 01:01:27 -0400 Subject: [PATCH 271/310] modify genesis test case --- .../autotest/testcase/genesis/genesistest.pl | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/xCAT-test/autotest/testcase/genesis/genesistest.pl b/xCAT-test/autotest/testcase/genesis/genesistest.pl index 187b04187..570374923 100755 --- a/xCAT-test/autotest/testcase/genesis/genesistest.pl +++ b/xCAT-test/autotest/testcase/genesis/genesistest.pl @@ -15,20 +15,19 @@ BEGIN $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; } use lib "$::XCATROOT/lib/perl"; -my $needhelp = 0; my $rungenesiscmd = 0; my $rungenesisimg = 0; my $shellmode = 0; -my $cmdtest="/tmp/cmdtest"; +my $cmdtest = "/tmp/cmdtest"; my $timesleep = 0; -my $noderange = 0; +my $noderange ; my $clearenv = 0; -my $arch = 0; +my $arch ; my $imgip ; -my $runimgtest="/tmp/imgtest"; -my $testresult="/tmp/testresult"; -my $genesisdir="/opt/xcat/share/xcat/netboot/genesis"; -my $genesisfiledir="$genesisdir/$arch/fs/bin"; +my $runimgtest = "/tmp/imgtest"; +my $testresult = "/tmp/testresult"; +my $genesisdir = "/opt/xcat/share/xcat/netboot/genesis"; +my $genesisfiledir ; if ( !GetOptions("h|?" => \$::HELP, @@ -46,7 +45,7 @@ if ( } sub usage { - print "Usage:run genesis cases.\n"; + print "Usage:run for genesis cases.\n"; print " genesistest.pl [-?|-h]\n"; print " genesistest.pl [-d] [-n node] [-r arch] Test runcmd for genesis \n"; print " genesistest.pl [-g] [-n ndoe] [-i imgip] Test runimg for genesis\n"; From 4ae87b1b53c412b1f35c35b36183a5c17a4217cb Mon Sep 17 00:00:00 2001 From: Xiaopeng Wang Date: Thu, 14 Jul 2016 13:53:30 +0800 Subject: [PATCH 272/310] remove an useless file --- .../autotest/testcase/genesis/cmdtest.pl | 124 ------------------ 1 file changed, 124 deletions(-) delete mode 100755 xCAT-test/autotest/testcase/genesis/cmdtest.pl diff --git a/xCAT-test/autotest/testcase/genesis/cmdtest.pl b/xCAT-test/autotest/testcase/genesis/cmdtest.pl deleted file mode 100755 index 7422961d7..000000000 --- a/xCAT-test/autotest/testcase/genesis/cmdtest.pl +++ /dev/null @@ -1,124 +0,0 @@ -#!/usr/bin/env perl -# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html - -use strict; -use warnings; -use Getopt::Long; -use Data::Dumper; -use Term::ANSIColor; -use Time::Local; -BEGIN -{ - $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; -} -use lib "$::XCATROOT/lib/perl"; -my $needhelp = 0; -my $rungenesiscmd = 0; -my $rungenesisimg = 0; -my $shellmode = 0; -my $cmdtest="/tmp/cmdtest"; -my $genesisdir="/opt/xcat/share/xcat/netboot/genesis/"; -my $timesleep = 0; -my $runimgtest="/tmp/runme.sh"; -if ( - !GetOptions("h|?" => \$needhelp, - "c"=>\$rungenesiscmd, - "i"=>\$rungenesisimg, - "t"=>\$timesleep, - "s"=>\$shellmode) -) -{ - &usage; - exit 1; -} -sub usage -{ - print "Usage:run genesis cases.\n"; - print " genesistest.pl [-?|-h]\n"; - print " genesistest.pl [-s] set up genesis in shell mode \n"; - print " genesistest.pl [-i] runimg in genesis\n"; - print "\n"; - return; -} -sub runcmd -{ - my ($cmd) = @_; - my $rc = 0; - $::RUNCMD_RC = 0; - my $outref = []; - @$outref = `$cmd 2>&1`; - if ($?) - { - $rc = $? ; - $rc = $rc >> 8; - $::RUNCMD_RC = $rc; - } - chomp(@$outref); - return @$outref; - -} - -sub rungenesiscmd -{ - `echo "#!/bin/bash">>$cmdtest`; - `echo "#This is test for genesis scripts">>$cmdtest`; - `echo "echo \"test\" >> $cmdtest">>$cmdtest`; - `chmod 777 $cmdtest`; - if ($ARGV[0] =~ /ppc64/){ - `cp -rf $cmdtest "$genesisdir""ppc64"/fs/bin`; - `mknb ppc64`; - print "mknb ppc64\n"; - }else{ - `cp -rf $cmdtest "$genesisdir""$ARGV[0]"/fs/bin`; - `mknb $ARGV[0]`; - print "mkmn $ARGV[0]\n"; - } -} -sub rungenesisimg -{ - my $rc=0; - runcmd("mkdir -p /install/my_image"); - `echo "#!/bin/bash">>$runimgtest`; - `echo "#This is test for genesis scripts">>$runimgtest`; - `echo "echo "test" >> /tmp/cmdtest" >>$runimgtest`; - `chmod +x $runimgtest`; - `cp $runimgtest /install/my_image`; - `cd /install/my_image ;tar -zcvf my_image.tgz .`; - ` nodeset $ARGV[0] "runimage=http://$ARGV[1]/install/my_image/my_image.tgz",shell`; -} -sub timesleep -{ - my @output = runcmd("ping $ARGV[0] -c 10"); - my $value = 0; - print "output is $value ,@output\n"; - if ($::RUNCMD_RC){ - foreach $value (1 .. 60) { - @output = runcmd("ping $ARGV[0] -c 10"); - last if ($::RUNCMD_RC == 0); - } - } - my @output1 = runcmd("xdsh $ARGV[0] date"); - if ($::RUNCMD_RC){ - foreach $value (1 .. 60) { - @output1 = runcmd("xdsh $ARGV[0] date"); - last if ($::RUNCMD_RC == 0); - } - } - if ($::RUNCMD_RC == 0){ - print "test ok\n"; - } -} -if ($rungenesiscmd) - { - &rungenesiscmd; - } -if ($timesleep) - { - ×leep; - } -if($rungenesisimg) - { - &rungenesisimg; - } - - From 7a6c9e72f2d3800da45cd5b0d1a962b3745bc784 Mon Sep 17 00:00:00 2001 From: XuWei Date: Thu, 14 Jul 2016 02:07:19 -0400 Subject: [PATCH 273/310] Improve performance of blade (powering-on) --- xCAT-server/lib/xcat/plugins/blade.pm | 32 ++++++++------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index 3e651c41b..9a9b44a3e 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -54,6 +54,7 @@ my $verbose_cmd = undef; my $vitals_info = undef; #used by 'rvitals all' to show lcds info for Firebird blade my %x222_info = (); #used to collect x222 infomations my $has_x222 = undef; +my %newnodestatus=(); sub handled_commands { return { @@ -2331,7 +2332,6 @@ sub power { my $old_stat=$stat; my $newstat; - my %newnodestatus=(); if ($subcommand eq "softoff") { $validsub=1; $data = $session->set(new SNMP::Varbind([".".$powerchangeoid,$slot,2,'INTEGER'])); @@ -2367,8 +2367,7 @@ sub power { } if ($session->{ErrorStr}) { return (1,$session->{ErrorStr}); } if ($newstat) { - $newnodestatus{$newstat}=[$currnode]; - xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); + push @{ $newnodestatus{$newstat} }, $currnode; } if ($stat) { return (0,$stat); } @@ -5955,27 +5954,10 @@ sub dompa { #} - if ($command eq 'rpower') { - if (($global_check) && ($args->[0] ne 'stat') && ($args->[0] ne 'status') && ($args->[0] ne 'state')) { - $check=1; - my @allnodes=keys %{$mpahash->{$mpa}->{nodes}}; - - #save the old status - my $nodelisttab = xCAT::Table->new('nodelist'); - if ($nodelisttab) { - my $tabdata = $nodelisttab->getNodesAttribs(\@allnodes, ['node', 'status']); - foreach my $node (@allnodes) - { - my $tmp1 = $tabdata->{$node}->[0]; - if ($tmp1) { - if ($tmp1->{status}) { $oldnodestatus{$node}=$tmp1->{status}; } - else { $oldnodestatus{$node}=""; } - } - } - } - #print "oldstatus:" . Dumper(\%oldnodestatus); + if ($command eq 'rpower') { + %newnodestatus = (); } - } + if ($command eq "rvitals") { if ((scalar(@$args) == 1 and $args->[0] eq '') or grep (/all/,@$args)) { $vitals_info = &get_blades_for_mpa($mpa); @@ -6039,6 +6021,10 @@ sub dompa { yield; } + if ($command eq 'rpower' and %newnodestatus) { + xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); + } + verbose_message("SNMP session completed."); #my $msgtoparent=freeze(\@outhashes); # = XMLout(\%output,RootName => 'xcatresponse'); #print $out $msgtoparent; #$node.": $_\n"; From 89fb46a37977edb67fd1bc0d2e182d52aa912b53 Mon Sep 17 00:00:00 2001 From: junxiawang Date: Thu, 14 Jul 2016 08:41:15 -0400 Subject: [PATCH 274/310] add genesis testcase for autotest --- xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle | 3 +++ xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle | 3 +++ xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle | 3 +++ xCAT-test/autotest/bundle/sles11.4_x86_64.bundle | 3 +++ xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle | 3 +++ xCAT-test/autotest/bundle/sles12.1_x86_64.bundle | 3 +++ xCAT-test/autotest/bundle/sles12_ppc64le.bundle | 3 +++ xCAT-test/autotest/bundle/sles12_x86_64.bundle | 3 +++ xCAT-test/autotest/bundle/ubuntu14.04.3_ppc64le.bundle | 3 +++ xCAT-test/autotest/bundle/ubuntu14.04.3_x86_64.bundle | 3 +++ xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle | 3 +++ xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle | 3 +++ xCAT-test/autotest/bundle/ubuntu16.04_ppc64le.bundle | 3 +++ xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle | 3 +++ xCAT-test/autotest/testcase/genesis/cases0 | 2 +- 15 files changed, 43 insertions(+), 1 deletion(-) diff --git a/xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle b/xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle index f207c7154..61895f193 100644 --- a/xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle +++ b/xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle @@ -196,6 +196,9 @@ switchdiscover_range_r switchdiscover_range_x switchdiscover_range_z switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg nodeset_check_warninginfo reg_linux_diskless_installation_flat reg_linux_statelite_installation_flat diff --git a/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle b/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle index a23e9e257..3eb078815 100644 --- a/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle @@ -192,6 +192,9 @@ switchdiscover_range_r switchdiscover_range_x switchdiscover_range_z switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg redhat_migration1 redhat_migration2 clean_up_env diff --git a/xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle b/xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle index 3fbc91c8b..88c8dec6c 100644 --- a/xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle +++ b/xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle @@ -197,6 +197,9 @@ switchdiscover_range_x switchdiscover_range_z switchdiscover_range_z_V nodeset_check_warninginfo +nodeset_shell +nodeset_cmdline +nodeset_runimg reg_linux_diskless_installation_flat reg_linux_statelite_installation_flat SN_setup_case diff --git a/xCAT-test/autotest/bundle/sles11.4_x86_64.bundle b/xCAT-test/autotest/bundle/sles11.4_x86_64.bundle index 76fa7c6de..c2bdbc84b 100644 --- a/xCAT-test/autotest/bundle/sles11.4_x86_64.bundle +++ b/xCAT-test/autotest/bundle/sles11.4_x86_64.bundle @@ -200,6 +200,9 @@ switchdiscover_range_r switchdiscover_range_x switchdiscover_range_z switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg nodeset_check_warninginfo xcatd_start xcatd_stop diff --git a/xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle b/xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle index 4435fbcc2..fbe5b25ca 100644 --- a/xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle @@ -196,6 +196,9 @@ switchdiscover_range_r switchdiscover_range_x switchdiscover_range_z switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg xcatd_start_systemd xcatd_stop_systemd xcatd_restart_systemd diff --git a/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle b/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle index fc971be5b..1381b3c1b 100644 --- a/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle +++ b/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle @@ -200,6 +200,9 @@ switchdiscover_range_r switchdiscover_range_x switchdiscover_range_z switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg nodeset_check_warninginfo xcatd_start_systemd xcatd_stop_systemd diff --git a/xCAT-test/autotest/bundle/sles12_ppc64le.bundle b/xCAT-test/autotest/bundle/sles12_ppc64le.bundle index 4435fbcc2..fbe5b25ca 100644 --- a/xCAT-test/autotest/bundle/sles12_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/sles12_ppc64le.bundle @@ -196,6 +196,9 @@ switchdiscover_range_r switchdiscover_range_x switchdiscover_range_z switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg xcatd_start_systemd xcatd_stop_systemd xcatd_restart_systemd diff --git a/xCAT-test/autotest/bundle/sles12_x86_64.bundle b/xCAT-test/autotest/bundle/sles12_x86_64.bundle index 1cac18c63..e0714d5ad 100644 --- a/xCAT-test/autotest/bundle/sles12_x86_64.bundle +++ b/xCAT-test/autotest/bundle/sles12_x86_64.bundle @@ -200,6 +200,9 @@ switchdiscover_range_r switchdiscover_range_x switchdiscover_range_z switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg nodeset_check_warninginfo xcatd_start_systemd xcatd_stop_systemd diff --git a/xCAT-test/autotest/bundle/ubuntu14.04.3_ppc64le.bundle b/xCAT-test/autotest/bundle/ubuntu14.04.3_ppc64le.bundle index 43e2804ee..c15d8835d 100644 --- a/xCAT-test/autotest/bundle/ubuntu14.04.3_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/ubuntu14.04.3_ppc64le.bundle @@ -234,6 +234,9 @@ switchdiscover_range_r switchdiscover_range_x switchdiscover_range_z switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg xcatd_start xcatd_stop xcatd_restart diff --git a/xCAT-test/autotest/bundle/ubuntu14.04.3_x86_64.bundle b/xCAT-test/autotest/bundle/ubuntu14.04.3_x86_64.bundle index d7c88748f..9847cc792 100644 --- a/xCAT-test/autotest/bundle/ubuntu14.04.3_x86_64.bundle +++ b/xCAT-test/autotest/bundle/ubuntu14.04.3_x86_64.bundle @@ -242,6 +242,9 @@ switchdiscover_range_r switchdiscover_range_x switchdiscover_range_z switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg nodeset_check_warninginfo Full_installation_flat_docker rpower_stop diff --git a/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle b/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle index 9990fb91d..90028983a 100644 --- a/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle @@ -234,6 +234,9 @@ switchdiscover_range_r switchdiscover_range_x switchdiscover_range_z switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg xcatd_start xcatd_stop xcatd_restart diff --git a/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle b/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle index 7c70fa1b9..f8e5006ad 100644 --- a/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle +++ b/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle @@ -242,6 +242,9 @@ switchdiscover_range_r switchdiscover_range_x switchdiscover_range_z switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg nodeset_check_warninginfo Full_installation_flat_docker rpower_stop diff --git a/xCAT-test/autotest/bundle/ubuntu16.04_ppc64le.bundle b/xCAT-test/autotest/bundle/ubuntu16.04_ppc64le.bundle index cbe8a9844..0857fb8ae 100644 --- a/xCAT-test/autotest/bundle/ubuntu16.04_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/ubuntu16.04_ppc64le.bundle @@ -234,6 +234,9 @@ switchdiscover_range_r switchdiscover_range_x switchdiscover_range_z switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg xcatd_start_systemd xcatd_stop_systemd xcatd_restart_systemd diff --git a/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle b/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle index d1affab41..15c77f4a6 100644 --- a/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle +++ b/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle @@ -242,6 +242,9 @@ switchdiscover_range_r switchdiscover_range_x switchdiscover_range_z switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg xcatd_start_systemd xcatd_stop_systemd xcatd_restart_systemd diff --git a/xCAT-test/autotest/testcase/genesis/cases0 b/xCAT-test/autotest/testcase/genesis/cases0 index a42c2101a..9459ff83d 100644 --- a/xCAT-test/autotest/testcase/genesis/cases0 +++ b/xCAT-test/autotest/testcase/genesis/cases0 @@ -7,7 +7,7 @@ check:rc==0 cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -t -n $$CN cmd:xdsh $$CN cat /proc/cmdline check:rc==0 -check:output=~BOOT_IMAGE=/xcat/genesis.kernel +check:output=~destiny=shell cmd:nodeset $$CN boot cmd:rpower $$CN boot check:rc==0 From 97de4408ba10923d45564390926af4e712df5384 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Thu, 14 Jul 2016 10:38:39 -0400 Subject: [PATCH 275/310] Only display OK messages with -V option or if all compute nodes are OK --- xCAT-probe/subcmds/image | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/xCAT-probe/subcmds/image b/xCAT-probe/subcmds/image index c9837ac89..68316ba74 100755 --- a/xCAT-probe/subcmds/image +++ b/xCAT-probe/subcmds/image @@ -131,7 +131,7 @@ foreach (@all_nodes_provmethod_lines) { # Check if it is netboot, meaning diskless if ($osimage_provmethod_type && $osimage_provmethod_type eq 'netboot') { push(@diskless_nodes, $node_name); - probe_utils->send_msg("$output", "o", "$node_name is diskless"); + probe_utils->send_msg("$output", "o", "$node_name is diskless") if ($VERBOSE); if (length($rootimagedir) > 0) { # For this diskless node, get UUID from rootimg directory xcatinfo file of the provmethod osimage my $xcatinfo_file = $rootimagedir . "/rootimg/opt/xcat/xcatinfo"; @@ -181,7 +181,7 @@ foreach (@pping_lines) { probe_utils->send_msg("$output", "f", "Pinging $hostname"); } else { - probe_utils->send_msg("$output", "o", "Pinging $hostname"); + probe_utils->send_msg("$output", "o", "Pinging $hostname") if ($VERBOSE); push(@pingable_nodes, $hostname); } } @@ -254,27 +254,31 @@ foreach (@xdsh_name_lines) { # Probe verification step 1 - make sure all nodes are installed with the osimage name and imageUUID as defined on MN if ($DEFINITION_CHECK) { + my $success_nodes = 0; + my $msg; foreach (@pingable_nodes) { - my $msg; - my $status; if (($node_running_image_name_hash{$_} eq $node_defined_image_name_hash{$_}) && ($node_running_image_uuid_hash{$_} eq $node_defined_image_uuid_hash{$_})) { if ($node_running_image_uuid_hash{$_} eq $na) { $msg = "$_: Not able to determine installed os image name or uuid"; - $status = "f"; } else { - $msg = "OS image installed on compute node $_ matches the image defined for it on management node"; - $status = "o"; + $msg = "OS image installed on compute node $_ matches the image defined for it on management node"; + probe_utils->send_msg("$output", "o", "$msg") if ($VERBOSE); + $success_nodes++; + next; } } else { $msg = "$_: Unmatched os image name or image UUID.\n Defined: name = $node_defined_image_name_hash{$_}" . " uuid = $node_defined_image_uuid_hash{$_}\n Installed: name = $node_running_image_name_hash{$_}" . " uuid = $node_running_image_uuid_hash{$_}"; - $status = "f"; } - probe_utils->send_msg("$output", "$status", "$msg"); + probe_utils->send_msg("$output", "f", "$msg"); + } + if (scalar(@pingable_nodes) eq $success_nodes) { + # All pingable nodes were tested with success + probe_utils->send_msg("$output", "o", "OS image installed on each diskless compute node matches the image defined for it on management node"); } } From 9344ec55587ce13380f62f3a8b4685a267b703e5 Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 14 Jul 2016 04:34:13 -0400 Subject: [PATCH 276/310] fix issue geninitrd fails when pkgdir has more than one directory #1538 ; fix geninitrd fails to identify a ppc64le kernel #1539 --- xCAT-server/lib/xcat/plugins/anaconda.pm | 4 ++-- xCAT-server/lib/xcat/plugins/geninitrd.pm | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index 00590ba7b..3d5dc6f93 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -2564,7 +2564,7 @@ sub insert_dd { my @osupdirs = split (/,/, $osupdirlist); foreach my $osupdir (@osupdirs) { # find all the rpms start with kernel.* - my @kernel_rpms = `find $osupdir -name kernel-*.rpm`; + my @kernel_rpms = `find $osupdir -name 'kernel-*.rpm'`; push @rpm_list, @kernel_rpms; } } @@ -2706,7 +2706,7 @@ sub insert_dd { # and copy it to the /tftpboot my @new_kernels = <$dd_dir/rpm/boot/vmlinuz*>; foreach my $new_kernel (@new_kernels) { - if (-r $new_kernel && $new_kernel =~ /\/vmlinuz-(.*(x86_64|ppc64|el\d+))$/) { + if (-r $new_kernel && $new_kernel =~ /\/vmlinuz-(.*(x86_64|ppc64|el\d+|ppc64le))$/) { $new_kernel_ver = $1; $cmd = "/bin/mv -f $new_kernel $kernelpath"; xCAT::Utils->runcmd($cmd, -1); diff --git a/xCAT-server/lib/xcat/plugins/geninitrd.pm b/xCAT-server/lib/xcat/plugins/geninitrd.pm index 967ea5392..8e8afd872 100644 --- a/xCAT-server/lib/xcat/plugins/geninitrd.pm +++ b/xCAT-server/lib/xcat/plugins/geninitrd.pm @@ -123,6 +123,8 @@ sub geninitrd { return; } $pkgdir = $lient->{'pkgdir'}; + my @srcdir=split(/,/,$pkgdir); + $pkgdir = $srcdir[0]; $driverupdatesrc = $lient->{'driverupdatesrc'}; $netdrivers = $lient->{'netdrivers'}; From d8b7a2904d87f01015488b4b793fc90b3b52ac06 Mon Sep 17 00:00:00 2001 From: junxiawang Date: Fri, 15 Jul 2016 03:30:47 -0400 Subject: [PATCH 277/310] add description for linux.conf.template --- xCAT-test/autotest/linux.conf.template | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/xCAT-test/autotest/linux.conf.template b/xCAT-test/autotest/linux.conf.template index c5db1c1d5..90671f8b0 100644 --- a/xCAT-test/autotest/linux.conf.template +++ b/xCAT-test/autotest/linux.conf.template @@ -84,7 +84,9 @@ LATEST_VERSION=2.12.1 DOCKERIMAGE=ubuntu DOCKERCOMMAND=/bin/bash DOCKERCONIP=10.4.27.100 +#container on CN so the ip should be same network section with CN DOCKERHOSIP=10.4.27.10 +#should be same with CN's ip DOCKERMNXCAT=xcatmn MYNET0VALUE=10.0.0.0/8 DOCKERCN=host05c08 @@ -101,12 +103,15 @@ range=10.4-5.24-25.1 #End #For ntp case start extntpserversip=10.2.1.12 +###the extntpserversip should be sure have ntp server on it DATE=2016 #End #For bmc test case start bmcrange=10.4.30.254 +#bmc ip bmcusername=USERID bmcpasswd=PASSW0RD +#For bmc case u need to set username and passwd first #End [Custom] @@ -129,4 +134,8 @@ bmcpasswd=PASSW0RD #commands run after test [Script_Post] - +NODEIP=10.4.27.10 +#should same with CN's ip this ip is set for CN's confignics' set up +#genesis testcase +imgip=10.4.27.10 +#imgip should be same with CN's ip From d9914b5df322b1e47c9ef046de67f291026ee0f1 Mon Sep 17 00:00:00 2001 From: XuWei Date: Fri, 15 Jul 2016 04:35:54 -0400 Subject: [PATCH 278/310] Fix bug, probe discovery get node ip --- xCAT-probe/subcmds/discovery | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-probe/subcmds/discovery b/xCAT-probe/subcmds/discovery index e0a40201d..38359562b 100755 --- a/xCAT-probe/subcmds/discovery +++ b/xCAT-probe/subcmds/discovery @@ -279,7 +279,7 @@ sub get_node_ip { if ($_ =~ /^Error: Could not find an object named '(\w+)' .+/i) { $nodecheckrst{$1}{"error"} = "Could not find node definition"; $rst = 1; - } elsif ($_ =~ /^(\w+): ip=(.+)/i) { + } elsif ($_ =~ /^(\w+): ip=(.*)/i) { $nodeip{$1} = $2; } } From 65bfb783d2f15686b92c5001194c2a8caa67c9a4 Mon Sep 17 00:00:00 2001 From: ertaozh Date: Mon, 18 Jul 2016 01:53:00 -0400 Subject: [PATCH 279/310] modify xcat to depended on ipmitool-xcat-1.8.15-2 and higher --- xCAT/debian/control | 2 +- xCAT/xCAT.spec | 4 ++-- xCATsn/debian/control | 2 +- xCATsn/xCATsn.spec | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/xCAT/debian/control b/xCAT/debian/control index c5051a272..c897efd07 100644 --- a/xCAT/debian/control +++ b/xCAT/debian/control @@ -7,6 +7,6 @@ Standards-Version: 3.7.2 Package: xcat Architecture: amd64 ppc64el -Depends: ${perl:Depends}, xcat-server, xcat-client, libdbd-sqlite3-perl, isc-dhcp-server, apache2, nfs-kernel-server, nmap, bind9, libxml-parser-perl, xinetd, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, ipmitool-xcat (>=1.8.9), syslinux[any-amd64], libsys-virt-perl, syslinux-xcat[any-amd64], xnba-undi, xcat-genesis-scripts, elilo-xcat, xcat-buildkit, xcat-probe (>=2.12) +Depends: ${perl:Depends}, xcat-server, xcat-client, libdbd-sqlite3-perl, isc-dhcp-server, apache2, nfs-kernel-server, nmap, bind9, libxml-parser-perl, xinetd, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, ipmitool-xcat (>=1.8.15-2), syslinux[any-amd64], libsys-virt-perl, syslinux-xcat[any-amd64], xnba-undi, xcat-genesis-scripts, elilo-xcat, xcat-buildkit, xcat-probe (>=2.12) Description: Server and configuration utilities of the xCAT management project xcat-server provides the core server and configuration management components of xCAT. This package should be installed on your management server diff --git a/xCAT/xCAT.spec b/xCAT/xCAT.spec index 789cbb06b..c800f288d 100644 --- a/xCAT/xCAT.spec +++ b/xCAT/xCAT.spec @@ -61,13 +61,13 @@ Requires: conserver-xcat %ifarch i386 i586 i686 x86 x86_64 Requires: syslinux xCAT-genesis-scripts-x86_64 elilo-xcat -Requires: ipmitool-xcat >= 1.8.11 +Requires: ipmitool-xcat >= 1.8.15-2 Requires: xnba-undi %endif %ifos linux %ifarch ppc ppc64 ppc64le Requires: xCAT-genesis-scripts-ppc64 -Requires: ipmitool-xcat >= 1.8.15 +Requires: ipmitool-xcat >= 1.8.15-2 %endif %endif diff --git a/xCATsn/debian/control b/xCATsn/debian/control index 604590bc5..70ecda665 100644 --- a/xCATsn/debian/control +++ b/xCATsn/debian/control @@ -7,7 +7,7 @@ Standards-Version: 3.7.2 Package: xcatsn Architecture: all -Depends: ${perl:Depends}, xcat-server, perl-xcat, xcat-client, libdbd-sqlite3-perl, libxml-parser-perl, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, dhcp3-server, apache2, expect, nfs-kernel-server, nmap, bind9, ipmitool-xcat (>=1.8.9), syslinux-xcat, xnba-undi, xcat-genesis-scripts, elilo-xcat,libsys-virt-perl +Depends: ${perl:Depends}, xcat-server, perl-xcat, xcat-client, libdbd-sqlite3-perl, libxml-parser-perl, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, dhcp3-server, apache2, expect, nfs-kernel-server, nmap, bind9, ipmitool-xcat (>=1.8.15-2), syslinux-xcat, xnba-undi, xcat-genesis-scripts, elilo-xcat,libsys-virt-perl Recommends: yaboot-xcat Description: Metapackage for a common, default xCAT service node setup xCATsn is a service node management package intended for at-scale management, including hardware management and software management. diff --git a/xCATsn/xCATsn.spec b/xCATsn/xCATsn.spec index 560c09f19..ffcf1e5eb 100644 --- a/xCATsn/xCATsn.spec +++ b/xCATsn/xCATsn.spec @@ -56,13 +56,13 @@ Requires: conserver-xcat %ifarch i386 i586 i686 x86 x86_64 Requires: syslinux xCAT-genesis-scripts-x86_64 elilo-xcat -Requires: ipmitool-xcat >= 1.8.11 +Requires: ipmitool-xcat >= 1.8.15-2 Requires: xnba-undi %endif %ifos linux %ifarch ppc ppc64 ppc64le Requires: xCAT-genesis-scripts-ppc64 -Requires: ipmitool-xcat >= 1.8.15 +Requires: ipmitool-xcat >= 1.8.15-2 %endif %endif From 87ba36dfa786d95b2bfc2b562295c42e680939cf Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Mon, 18 Jul 2016 17:22:31 +0800 Subject: [PATCH 280/310] Delete blank line for daily run delete useless blank lines for daily run --- xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle | 1 - 1 file changed, 1 deletion(-) diff --git a/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle b/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle index 90028983a..d93f4ad1d 100644 --- a/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle @@ -243,4 +243,3 @@ xcatd_restart run_command_with_XCATBYPASS disable_root_permission_in_policy_table assign_certain_command_permission - From 35cfdd56ba9febb07be542f2f6b027ae48d40435 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Mon, 18 Jul 2016 13:08:18 -0400 Subject: [PATCH 281/310] Added some code to create a buildinfo file included in the tar.bz2 file that contains information about the current xCAT build --- buildcore.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/buildcore.sh b/buildcore.sh index 9f3d3aec0..a2422ce7f 100755 --- a/buildcore.sh +++ b/buildcore.sh @@ -175,6 +175,9 @@ function setversionvars { VER=`cat Version` SHORTVER=`cat Version|cut -d. -f 1,2` SHORTSHORTVER=`cat Version|cut -d. -f 1` + BUILD_TIME=`date` + BUILD_MACHINE=`hostname` + COMMIT_ID=`git rev-parse --short HEAD` } @@ -504,6 +507,16 @@ if [ -n "$VERBOSEMODE" ]; then else verboseflag="" fi + +# +# Add a VERSION file into the tar.bz2 file to track information about the build +# +BUILDINFO=$XCATCORE/buildinfo +echo "VERSION=$VER" > $BUILDINFO +echo "BUILD_TIME=$BUILD_TIME" >> $BUILDINFO +echo "BUILD_MACHINE=$BUILD_MACHINE" >> $BUILDINFO +echo "COMMIT_ID=$COMMIT_ID" >> $BUILDINFO + echo "Creating $(dirname $DESTDIR)/$TARNAME ..." if [[ -e $TARNAME ]]; then mkdir -p previous From d6f0c89d435d353161fadbd2fd5286c6b82c82a5 Mon Sep 17 00:00:00 2001 From: Patrick Lundgren Date: Wed, 13 Jul 2016 14:36:30 -0400 Subject: [PATCH 282/310] Added block to restart rsyslogd after dhclient has been restarted. Moved restart to xCAT-genesis-scripts --- .../bin}/restart | 12 ++++++++++++ xCAT-genesis-scripts/xCAT-genesis-scripts.spec | 1 + 2 files changed, 13 insertions(+) rename {xCAT-genesis-builder => xCAT-genesis-scripts/bin}/restart (88%) diff --git a/xCAT-genesis-builder/restart b/xCAT-genesis-scripts/bin/restart similarity index 88% rename from xCAT-genesis-builder/restart rename to xCAT-genesis-scripts/bin/restart index 2a235c788..a51157e4a 100755 --- a/xCAT-genesis-builder/restart +++ b/xCAT-genesis-scripts/bin/restart @@ -42,6 +42,18 @@ while [ $WAITING -gt 0 ]; do sleep 1 echo -en "Waiting $i seconds for DHCP changes to take effect \r" done + + # restart rsyslog after dhclient + kill -9 `cat /var/run/syslogd.pid` + sleep 3 + RSYSLOGD_VERSION=`rsyslogd -v | grep "rsyslogd" | cut -d" " -f2 | cut -d"." -f1` + if [ $RSYSLOGD_VERSION -ge 8 ]; then + # Newer versions of rsyslogd do not support -c flag anymore + /sbin/rsyslogd + else + /sbin/rsyslogd -c4 + fi + WAITING=0 if [ ! -z "$FORCENICS" ]; then #for nic in `ifconfig|grep HWaddr|awk '{print $1}'|egrep "$FORCENICS"`; do diff --git a/xCAT-genesis-scripts/xCAT-genesis-scripts.spec b/xCAT-genesis-scripts/xCAT-genesis-scripts.spec index e37fe4995..0ffa1c825 100755 --- a/xCAT-genesis-scripts/xCAT-genesis-scripts.spec +++ b/xCAT-genesis-scripts/xCAT-genesis-scripts.spec @@ -98,6 +98,7 @@ touch /etc/xcat/genesis-scripts-updated %{rpminstallroot}/bin/pseries_platform %{rpminstallroot}/bin/update_flash %{rpminstallroot}/bin/update_flash_nv +%{rpminstallroot}/bin/restart %{rpminstallroot}/debian/changelog %{rpminstallroot}/debian/compat %{rpminstallroot}/debian/control From bf80c45c01f9fb3eb1093e44e5b3bde63626c804 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Mon, 18 Jul 2016 15:54:13 -0400 Subject: [PATCH 283/310] Fix some wording in the log messages during discovery. Simplify the messages so that it does not take up too many lines in the log file --- xCAT-server/lib/xcat/plugins/aaadiscovery.pm | 2 +- xCAT-server/lib/xcat/plugins/blade.pm | 5 ++--- xCAT-server/lib/xcat/plugins/hpblade.pm | 5 ++--- xCAT-server/lib/xcat/plugins/nodediscover.pm | 2 +- xCAT-server/lib/xcat/plugins/seqdiscovery.pm | 7 ++----- xCAT-server/lib/xcat/plugins/switch.pm | 5 ++--- xCAT-server/lib/xcat/plugins/typemtms.pm | 5 ++--- xCAT-server/lib/xcat/plugins/zzzdiscovery.pm | 5 ++--- 8 files changed, 14 insertions(+), 22 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/aaadiscovery.pm b/xCAT-server/lib/xcat/plugins/aaadiscovery.pm index 479945a44..26dc30107 100644 --- a/xCAT-server/lib/xcat/plugins/aaadiscovery.pm +++ b/xCAT-server/lib/xcat/plugins/aaadiscovery.pm @@ -42,7 +42,7 @@ sub process_request { } } - xCAT::MsgUtils->message("S", "xcat.discovery.aaadiscovery: ($mac) Get a discover request"); + xCAT::MsgUtils->message("S", "xcat.discovery.aaadiscovery: ($mac) Got a discovery request, attempting to discover the node..."); $req->{discoverymethod}->[0] = 'undef'; $req->{_xcat_clientmac}->[0] = $mac; xCAT::DiscoveryUtils->update_discovery_data($req); diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index 3e651c41b..5c4f8dc87 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -4375,7 +4375,6 @@ sub process_request { return; } - xCAT::MsgUtils->message("S", "xcat.discovery.blade: ($request->{_xcat_clientmac}->[0]) Processing discovery request"); my $mptab = xCAT::Table->new("mp"); unless ($mptab) { return 2; } my @bladents = $mptab->getAllNodeAttribs([qw(node)]); @@ -4454,7 +4453,7 @@ sub process_request { } } unless ($node) { - xCAT::MsgUtils->message("S", "xcat.discovery.blade: ($request->{_xcat_clientmac}->[0]) Error: Could not find any node"); + xCAT::MsgUtils->message("S", "xcat.discovery.blade: ($request->{_xcat_clientmac}->[0]) Warning: Could not find any nodes using blade-based discovery"); return 1; #failure } if ($request->{mtm} and $request->{mtm} =~ /^(\w{4})/) { @@ -4470,7 +4469,7 @@ sub process_request { undef $mactab; } - xCAT::MsgUtils->message("S", "xcat.discovery.blade: ($request->{_xcat_clientmac}->[0]) Find node $node for the discovery request"); + xCAT::MsgUtils->message("S", "xcat.discovery.blade: ($request->{_xcat_clientmac}->[0]) Found node: $node"); #my %request = ( # command => ['makedhcp'], # node => [$macmap{$mac}] diff --git a/xCAT-server/lib/xcat/plugins/hpblade.pm b/xCAT-server/lib/xcat/plugins/hpblade.pm index 12cd8fe17..f46075c78 100755 --- a/xCAT-server/lib/xcat/plugins/hpblade.pm +++ b/xCAT-server/lib/xcat/plugins/hpblade.pm @@ -689,7 +689,6 @@ sub process_request { # The findme request had been processed by other module, just return return; } - xCAT::MsgUtils->message("S", "xcat.discovery.hpblade: ($request->{_xcat_clientmac}->[0]) Processing discovery request"); my $mptab = xCAT::Table->new("mp"); unless ($mptab) { return 2; } my @bladents = $mptab->getAllNodeAttribs([qw(node)]); @@ -733,7 +732,7 @@ sub process_request { } } unless ($macmap{$mac}) { - xCAT::MsgUtils->message("S", "xcat.discovery.hpblade: ($request->{_xcat_clientmac}->[0]) Error: Could not find any node"); + xCAT::MsgUtils->message("S", "xcat.discovery.hpblade: ($request->{_xcat_clientmac}->[0]) Warning: Could not find any nodes using hpblade-based discovery"); return 1; #failure } # The discovered command will update mac table, no need to update here @@ -745,7 +744,7 @@ sub process_request { # node => [$macmap{$mac}] # ); #$doreq->(\%request); - xCAT::MsgUtils->message("S", "xcat.discovery.hpblade: ($request->{_xcat_clientmac}->[0]) Find node:$macmap{$mac} for the discovery request"); + xCAT::MsgUtils->message("S", "xcat.discovery.hpblade: ($request->{_xcat_clientmac}->[0]) Found node: $macmap{$mac}"); my $req={%$request}; $req->{command}=['discovered']; $req->{noderange} = [$macmap{$mac}]; diff --git a/xCAT-server/lib/xcat/plugins/nodediscover.pm b/xCAT-server/lib/xcat/plugins/nodediscover.pm index 058d0401a..59950db68 100644 --- a/xCAT-server/lib/xcat/plugins/nodediscover.pm +++ b/xCAT-server/lib/xcat/plugins/nodediscover.pm @@ -375,7 +375,7 @@ sub process_request { syslog("local4|info", "The attribute bmcinband is specified, just remove the temp BMC node if there is"); if (defined($request->{bmc_node}) and defined($request->{bmc_node}->[0])) { my $bmc_node = $request->{bmc_node}->[0]; - syslog("local4|info", "Find BMC $bmc_node, so remove it"); + syslog("local4|info", "Found node corresponding to BMC=$bmc_node, removing it..."); $doreq->({ command => ['rmdef'], arg => [$bmc_node]}); } } else { diff --git a/xCAT-server/lib/xcat/plugins/seqdiscovery.pm b/xCAT-server/lib/xcat/plugins/seqdiscovery.pm index aae688064..7fae62b54 100755 --- a/xCAT-server/lib/xcat/plugins/seqdiscovery.pm +++ b/xCAT-server/lib/xcat/plugins/seqdiscovery.pm @@ -62,9 +62,6 @@ sub findme { return; } - # do the sequential discovery - xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{_xcat_clientmac}->[0]) Processing discovery request"); - # Get the parameters for the sequential discovery my %param; my @params = split (',', $SEQdiscover[0]); @@ -373,7 +370,7 @@ sub findme { # call the discovered command to update the discovery request to a node - xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{_xcat_clientmac}->[0]) Find node:$node for the discovery request"); + xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{_xcat_clientmac}->[0]) Found node: $node"); $request->{discoverymethod} = ['sequential']; my $req = {%$request}; $req->{command}=['discovered']; @@ -386,7 +383,7 @@ sub findme { undef $mactab; } else { nodediscoverstop($callback, undef, "node names"); - xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{_xcat_clientmac}->[0]) Error: Could not find any node"); + xCAT::MsgUtils->message("S", "xcat.discovery.seqdiscovery: ($request->{_xcat_clientmac}->[0]) Warning: Could not find any nodes using sequential-based discovery"); return; } diff --git a/xCAT-server/lib/xcat/plugins/switch.pm b/xCAT-server/lib/xcat/plugins/switch.pm index 9f1d53a7c..2c6cb0b23 100644 --- a/xCAT-server/lib/xcat/plugins/switch.pm +++ b/xCAT-server/lib/xcat/plugins/switch.pm @@ -278,7 +278,6 @@ sub process_request { return; } $mac = $req->{_xcat_clientmac}->[0]; - xCAT::MsgUtils->message("S", "xcat.discovery.switch: ($mac) Processing discovery request"); if (defined $req->{nodetype} and $req->{nodetype}->[0] eq 'virtual') { #Don't attempt switch discovery of a VM Guest #TODO: in this case, we could/should find the host system @@ -313,7 +312,7 @@ sub process_request { } if ($node) { - xCAT::MsgUtils->message("S", "xcat.discovery.switch: ($req->{_xcat_clientmac}->[0]) Find node:$node for the discovery request"); + xCAT::MsgUtils->message("S", "xcat.discovery.switch: ($req->{_xcat_clientmac}->[0]) Found node: $node"); # No need to write mac table here, 'discovered' command will write # my $mactab = xCAT::Table->new('mac',-create=>1); # $mactab->setNodeAttribs($node,{mac=>$mac}); @@ -332,7 +331,7 @@ sub process_request { %{$request}=();#Clear req structure, it's done.. undef $mactab; } else { - xCAT::MsgUtils->message("S", "xcat.discovery.switch: ($req->{_xcat_clientmac}->[0]) Error: Could not find any node"); + xCAT::MsgUtils->message("S", "xcat.discovery.switch: ($req->{_xcat_clientmac}->[0]) Warning: Could not find any nodes using switch-based discovery"); } } } diff --git a/xCAT-server/lib/xcat/plugins/typemtms.pm b/xCAT-server/lib/xcat/plugins/typemtms.pm index c1c1226df..9a97254f9 100644 --- a/xCAT-server/lib/xcat/plugins/typemtms.pm +++ b/xCAT-server/lib/xcat/plugins/typemtms.pm @@ -22,7 +22,6 @@ sub findme { } my @attr_array = (); my $mtms = $request->{'mtm'}->[0]."*".$request->{'serial'}->[0]; - xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($request->{_xcat_clientmac}->[0]) Processing discovery request"); my $tmp_nodes = $::XCATVPDHASH{$mtms}; my @nodes = (); my $bmc_node; @@ -35,14 +34,14 @@ sub findme { } my $nodenum = $#nodes; if ($nodenum < 0) { - xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($request->{_xcat_clientmac}->[0]) Error: Could not find any node"); + xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($request->{_xcat_clientmac}->[0]) Warning: Could not find any nodes using mtms-based discovery"); return; } elsif ($nodenum > 0) { xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($request->{_xcat_clientmac}->[0]) Error: More than one node were found"); return; } { - xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($request->{_xcat_clientmac}->[0]) Find node:$nodes[0] for the discovery request"); + xCAT::MsgUtils->message("S", "xcat.discovery.mtms: ($request->{_xcat_clientmac}->[0]) Found node: $nodes[0]"); $request->{discoverymethod}->[0] = 'mtms'; my $req = {%$request}; $req->{command} = ['discovered']; diff --git a/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm b/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm index 71b804829..dc5b82fc7 100644 --- a/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm +++ b/xCAT-server/lib/xcat/plugins/zzzdiscovery.pm @@ -17,15 +17,14 @@ sub process_request { my $cb = shift; my $doreq = shift; if ($req->{command}->[0] eq 'findme') { - xCAT::MsgUtils->message("S", "xcat.discovery.zzzdiscovery: ($req->{_xcat_clientmac}->[0]) Finish to process the discovery request"); if (!defined($req->{discoverymethod}) or !defined($req->{discoverymethod}->[0]) or ($req->{discoverymethod}->[0] eq 'undef')) { my $rsp = {}; $rsp->{error}->[0] = "The discovery request can not be processed"; $cb->($rsp); - xCAT::MsgUtils->message("S", "xcat.discovery.zzzdiscovery: ($req->{_xcat_clientmac}->[0]) Failed to be processed"); + xCAT::MsgUtils->message("S", "xcat.discovery.zzzdiscovery: ($req->{_xcat_clientmac}->[0]) Failed to discover the node."); return; } - xCAT::MsgUtils->message("S", "xcat.discovery.zzzdiscovery: ($req->{_xcat_clientmac}->[0]) Successfully processed by $req->{discoverymethod}->[0] method"); + xCAT::MsgUtils->message("S", "xcat.discovery.zzzdiscovery: ($req->{_xcat_clientmac}->[0]) Successfully discovered the node using $req->{discoverymethod}->[0] discovery method."); return; } } From 15dd9113728f2145e9ce1f9017d8590daec32d27 Mon Sep 17 00:00:00 2001 From: ertaozh Date: Mon, 18 Jul 2016 03:20:49 -0400 Subject: [PATCH 284/310] Modify xcat-genesis-scripts-ppc64 depend on xcat-genesis-base-ppc64 and xcat-genesis-scripts-x86-64 depend on xcat-genesis-base-x86-64 for ubuntu --- build-ubunturepo | 10 ++++++++++ .../debian/{control => control-amd64} | 8 ++++---- xCAT-genesis-scripts/debian/control-ppc64el | 13 +++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) rename xCAT-genesis-scripts/debian/{control => control-amd64} (73%) create mode 100644 xCAT-genesis-scripts/debian/control-ppc64el diff --git a/build-ubunturepo b/build-ubunturepo index 5acce32fb..275a95347 100755 --- a/build-ubunturepo +++ b/build-ubunturepo @@ -254,7 +254,17 @@ then fi dpkg-buildpackage -uc -us else + if [ "$file" = "xCAT-genesis-scripts" ]; then + CURDIR=$(pwd) + echo "Rename control file to build pkg: mv ${CURDIR}/debian/control-${target_arch} ${CURDIR}/debian/control" + mv ${CURDIR}/debian/control-${target_arch} ${CURDIR}/debian/control + fi dpkg-buildpackage -uc -us -a$target_arch + if [ "$file" = "xCAT-genesis-scripts" ]; then + CURDIR=$(pwd) + echo "Move control file back: mv ${CURDIR}/debian/control ${CURDIR}/debian/control-${target_arch}" + mv ${CURDIR}/debian/control ${CURDIR}/debian/control-${target_arch} + fi fi rc=$? if [ $rc -gt 0 ]; then diff --git a/xCAT-genesis-scripts/debian/control b/xCAT-genesis-scripts/debian/control-amd64 similarity index 73% rename from xCAT-genesis-scripts/debian/control rename to xCAT-genesis-scripts/debian/control-amd64 index a8e44e30b..67f8c7bf3 100644 --- a/xCAT-genesis-scripts/debian/control +++ b/xCAT-genesis-scripts/debian/control-amd64 @@ -5,10 +5,10 @@ Maintainer: xCAT Build-Depends: debhelper (>= 8.0.0) Standards-Version: 3.9.2 -Package: xcat-genesis-scripts -Architecture: amd64 ppc64el -Depends: xcat-genesis-base-amd64[any-amd64],xcat-genesis-base-ppc64[any-ppc64el] -Replaces: xcat-genesis-scripts-amd64[any-amd64] +Package: xcat-genesis-scripts-x86-64 +Architecture: all +Depends: xcat-genesis-base-x86-64 +Replaces: xcat-genesis-scripts-amd64 Description: xCAT genesis (Genesis Enhanced Netboot Environment for System Information and Servicing) is a small, embedded-like environment for xCAT's use in discovery and management actions when interaction with an OS is infeasible. This package reperesents the EPL content that is more tightly bound to specific xcat-core versions diff --git a/xCAT-genesis-scripts/debian/control-ppc64el b/xCAT-genesis-scripts/debian/control-ppc64el new file mode 100644 index 000000000..a76515dfa --- /dev/null +++ b/xCAT-genesis-scripts/debian/control-ppc64el @@ -0,0 +1,13 @@ +Source: xcat-genesis-scripts +Section: admin +Priority: extra +Maintainer: xCAT +Build-Depends: debhelper (>= 8.0.0) +Standards-Version: 3.9.2 + +Package: xcat-genesis-scripts-ppc64 +Architecture: all +Depends: xcat-genesis-base-ppc64 +Description: xCAT genesis + (Genesis Enhanced Netboot Environment for System Information and Servicing) is a small, embedded-like environment for xCAT's use in discovery and management actions when interaction with an OS is infeasible. This package reperesents the EPL content that is more tightly bound to specific xcat-core versions + From d6e7b250f98ddd2c57d8b2b3e7160c851440ca99 Mon Sep 17 00:00:00 2001 From: XuWei Date: Mon, 18 Jul 2016 22:21:12 -0400 Subject: [PATCH 285/310] Improve performance of kvm (powering-on) --- xCAT-server/lib/xcat/plugins/kvm.pm | 102 ++++++++-------------------- 1 file changed, 29 insertions(+), 73 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index 5ae79f980..686dcfa40 100755 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -39,6 +39,7 @@ my $parser; my @destblacklist; my $updatetable; #when a function is performing per-node operations, it can queue up a table update by populating parts of this hash my $confdata; #a reference to serve as a common pointer betweer VMCommon functions and this plugin +my %allnodestatus; require Sys::Virt; if (Sys::Virt->VERSION =~ /^0\.[10]\./) { @@ -3000,8 +3001,6 @@ sub power { } } my $errstr; - my $newstat; - my %newnodestatus=(); if ($subcommand eq 'on') { unless ($dom) { @@ -3016,11 +3015,11 @@ sub power { ($dom, $errstr) = makedom($node, $cdloc); if ($errstr) { return (1, $errstr); } else { - $newstat = $::STATUS_POWERING_ON; + $allnodestatus{$node} = $::STATUS_POWERING_ON; } } elsif (not $dom->is_active()) { $dom->create(); - $newstat = $::STATUS_POWERING_ON; + $allnodestatus{$node} = $::STATUS_POWERING_ON; } else { $retstring .= "$status_noop"; } @@ -3030,7 +3029,7 @@ sub power { $updatetable->{kvm_nodedata}->{$node}->{xml} = $newxml; if ($dom->is_active()) { $dom->destroy(); - $newstat=$::STATUS_POWERING_OFF; + $allnodestatus{$node} = $::STATUS_POWERING_OFF; } undef $dom; } else { $retstring .= "$status_noop"; } @@ -3039,7 +3038,7 @@ sub power { my $newxml = $dom->get_xml_description(); $updatetable->{kvm_nodedata}->{$node}->{xml} = $newxml; $dom->shutdown(); - $newstat=$::STATUS_POWERING_OFF; + $allnodestatus{$node} = $::STATUS_POWERING_OFF; } else { $retstring .= "$status_noop"; } } elsif ($subcommand eq 'reset') { if ($dom && $dom->is_active()) { @@ -3052,7 +3051,7 @@ sub power { $updatetable->{kvm_nodedata}->{$node}->{xml} = $newxml; my $persist = $dom->is_persistent(); $dom->destroy(); - $newstat=$::STATUS_POWERING_OFF; + $allnodestatus{$node} = $::STATUS_POWERING_OFF; if ($persist) { $dom->undefine(); } undef $dom; if ($use_xhrm) { @@ -3061,7 +3060,7 @@ sub power { ($dom, $errstr) = makedom($node, $cdloc, $newxml); if ($errstr) { return (1, $errstr); } else { - $newstat=$::STATUS_POWERING_ON; + $allnodestatus{$node} = $::STATUS_POWERING_ON; } } else { #no changes, just restart the domain TODO when possible, stupid lack of feature... @@ -3073,10 +3072,6 @@ sub power { return (1, "Unsupported power directive '$subcommand'"); } } - if ($newstat) { - $newnodestatus{$newstat}=[$node]; - xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); - } unless ($retstring =~ /reset/) { $retstring = $retstring . getpowstate($dom); @@ -3763,51 +3758,12 @@ sub process_request { return; } - #get new node status - my %oldnodestatus = (); #saves the old node status - my @allerrornodes = (); - my $check = 0; - my $global_check = 1; - if ($::XCATSITEVALS{nodestatus} =~ /0|n|N/) { $global_check = 0; } - - - if ($command eq 'rpower') { - my $subcommand = $exargs[0]; - if (($global_check) && ($subcommand ne 'stat') && ($subcommand ne 'status')) { - $check = 1; - my @allnodes = @$noderange; - - #save the old status - my $nodelisttab = xCAT::Table->new('nodelist'); - if ($nodelisttab) { - my $tabdata = $nodelisttab->getNodesAttribs(\@allnodes, [ 'node', 'status' ]); - foreach my $node (@allnodes) - { - my $tmp1 = $tabdata->{$node}->[0]; - if ($tmp1) { - if ($tmp1->{status}) { $oldnodestatus{$node} = $tmp1->{status}; } - else { $oldnodestatus{$node} = ""; } - } - } - } - - #print "oldstatus:" . Dumper(\%oldnodestatus); - } - } - if ($::XCATSITEVALS{masterimgdir}) { $xCAT_plugin::kvm::masterdir = $::XCATSITEVALS{masterimgdir} } - - foreach $hyp (sort (keys %hyphash)) { while ($children > $vmmaxp) { my $handlednodes = {}; forward_data($callback, $sub_fds, $handlednodes); - - #update the node status to the nodelist.status table - if ($check) { - updateNodeStatus($handlednodes, \@allerrornodes); - } } $children++; my $cfd; @@ -3830,11 +3786,6 @@ sub process_request { while ($sub_fds->count > 0) { # or $children > 0) { #if count is zero, even if we have live children, we can't possibly get data from them my $handlednodes = {}; forward_data($callback, $sub_fds, $handlednodes); - - #update the node status to the nodelist.status table - if ($check) { - updateNodeStatus($handlednodes, \@allerrornodes); - } } #while (wait() > -1) { } #keep around just in case we find the absolute need to wait for children to be gone @@ -3850,23 +3801,6 @@ sub process_request { # } #} - if ($check) { - - #print "allerrornodes=@allerrornodes\n"; - #revert the status back for there is no-op for the nodes - my %old = (); - foreach my $node (@allerrornodes) { - my $stat = $oldnodestatus{$node}; - if (exists($old{$stat})) { - my $pa = $old{$stat}; - push(@$pa, $node); - } - else { - $old{$stat} = [$node]; - } - } - xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%old, 1); - } } sub updateNodeStatus { @@ -3997,6 +3931,15 @@ sub dohyp { } } + if ($command eq 'rpower') { + my $subcommand = $exargs[0]; + if (($subcommand ne 'stat') && ($subcommand ne 'status')) { + %allnodestatus = (); + } + } + + my %newnodestatus; + foreach $node (sort (keys %{ $hyphash{$hyp}->{nodes} })) { if ($confdata->{$hyp}->{cpumodel} and $confdata->{$hyp}->{cpumodel} =~ /ppc64/i) { $confdata->{vm}->{$node}->[0]->{storagemodel} = "scsi"; @@ -4038,12 +3981,25 @@ sub dohyp { } else { $output{node}->[0]->{error} = $text; } + + if ($command eq 'rpower') { + if (!$rc and $text !~ /$status_noop/) { + if (%allnodestatus) { + push @{ $newnodestatus{$allnodestatus{$node}} }, $node; + } + } + } store_fd([ \%output ], $out); yield(); waitforack($out); } yield(); } + + if ($command eq 'rpower') { + xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); + } + foreach (keys %$updatetable) { my $tabhandle = xCAT::Table->new($_, -create => 1); my $updates = $updatetable->{$_}; From 51f69458fa16179cd0698942dcd0ba655ca465d4 Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Tue, 19 Jul 2016 02:10:09 -0400 Subject: [PATCH 286/310] delete synced file check point --- .../reg_linux_statelite_installation_hierarchy_by_nfs | 11 ++++++----- ..._linux_statelite_installation_hierarchy_by_ramdisk | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_nfs b/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_nfs index 0c0f1fd51..0923a1381 100644 --- a/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_nfs +++ b/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_nfs @@ -92,11 +92,12 @@ cmd:xdsh $$CN mount check:rc==0 check:output=~/nodedata/$$CN on /.statelite/persistent check:output=~compute/rootimg on / type nfs -cmd:scp $$CN:/etc/resolv.conf /tmp/resolv.conf -check:rc==0 -cmd:diff /etc/resolv.conf /tmp/resolv.conf -check:rc==0 -cmd:rm -f /tmp/resolv.conf + +#cmd:scp $$CN:/etc/resolv.conf /tmp/resolv.conf +#check:rc==0 +#cmd:diff /etc/resolv.conf /tmp/resolv.conf +#check:rc==0 +#cmd:rm -f /tmp/resolv.conf cmd:rootimgdir=`lsdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute|grep rootimgdir|awk -F'=' '{print $2}'`; if [ -d $rootimgdir ]; then rm -rf $rootimgdir;fi check:rc==0 diff --git a/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_ramdisk b/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_ramdisk index 0477ac566..ddafeeca8 100644 --- a/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_ramdisk +++ b/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_ramdisk @@ -94,11 +94,12 @@ cmd:xdsh $$CN mount check:rc==0 check:output=~/nodedata/$$CN on /.statelite/persistent check:output=~rootfs on / type -cmd:scp $$CN:/etc/resolv.conf /tmp/resolv.conf -check:rc==0 -cmd:diff /etc/resolv.conf /tmp/resolv.conf -check:rc==0 -cmd:rm -f /tmp/resolv.conf + +#cmd:scp $$CN:/etc/resolv.conf /tmp/resolv.conf +#check:rc==0 +#cmd:diff /etc/resolv.conf /tmp/resolv.conf +#check:rc==0 +#cmd:rm -f /tmp/resolv.conf cmd:rootimgdir=`lsdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute|grep rootimgdir|awk -F'=' '{print $2}'`; if [ -d $rootimgdir.regbak ]; then rm -rf $rootimgdir; mv $rootimgdir.regbak $rootimgdir; fi check:rc==0 From 1d3a1633245d1155ef8c07d75ea0b024ae8177de Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Tue, 19 Jul 2016 02:16:13 -0400 Subject: [PATCH 287/310] delete synced file check points --- .../reg_linux_statelite_installation_hierarchy_by_nfs | 6 ------ .../reg_linux_statelite_installation_hierarchy_by_ramdisk | 6 ------ 2 files changed, 12 deletions(-) diff --git a/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_nfs b/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_nfs index 0923a1381..5606477b8 100644 --- a/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_nfs +++ b/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_nfs @@ -93,12 +93,6 @@ check:rc==0 check:output=~/nodedata/$$CN on /.statelite/persistent check:output=~compute/rootimg on / type nfs -#cmd:scp $$CN:/etc/resolv.conf /tmp/resolv.conf -#check:rc==0 -#cmd:diff /etc/resolv.conf /tmp/resolv.conf -#check:rc==0 -#cmd:rm -f /tmp/resolv.conf - cmd:rootimgdir=`lsdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute|grep rootimgdir|awk -F'=' '{print $2}'`; if [ -d $rootimgdir ]; then rm -rf $rootimgdir;fi check:rc==0 cmd:rmdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute diff --git a/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_ramdisk b/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_ramdisk index ddafeeca8..9392285ae 100644 --- a/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_ramdisk +++ b/xCAT-test/autotest/testcase/installation/reg_linux_statelite_installation_hierarchy_by_ramdisk @@ -95,12 +95,6 @@ check:rc==0 check:output=~/nodedata/$$CN on /.statelite/persistent check:output=~rootfs on / type -#cmd:scp $$CN:/etc/resolv.conf /tmp/resolv.conf -#check:rc==0 -#cmd:diff /etc/resolv.conf /tmp/resolv.conf -#check:rc==0 -#cmd:rm -f /tmp/resolv.conf - cmd:rootimgdir=`lsdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute|grep rootimgdir|awk -F'=' '{print $2}'`; if [ -d $rootimgdir.regbak ]; then rm -rf $rootimgdir; mv $rootimgdir.regbak $rootimgdir; fi check:rc==0 cmd:rmdef -t osimage -o __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-statelite-compute From 7e737f695bde2b7ebc364adfcba29f63cb9233fa Mon Sep 17 00:00:00 2001 From: ertaozh Date: Mon, 18 Jul 2016 22:33:42 -0400 Subject: [PATCH 288/310] add the notification that need to install newer mlxen driver for xcat-genesis-base-ppc64 --- xCAT-genesis-builder/buildrpm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/xCAT-genesis-builder/buildrpm b/xCAT-genesis-builder/buildrpm index 66a89eb14..e82e90591 100755 --- a/xCAT-genesis-builder/buildrpm +++ b/xCAT-genesis-builder/buildrpm @@ -18,6 +18,30 @@ if [ $BUILDARCH = "ppc64le" ]; then BUILDARCH="ppc64" fi +# For xcat-genesis-base-ppc64, we need to update mlx4-en driver for Mellanox ethernet nics. +# IF you are sure you have installed newer driver on the build server you can use 'buildrpm -y' to skip the nodification +if [ -z $1 ]; then + HOSTOS="fedora23" +fi +if [ $BUILDARCH = 'ppc64' -a $HOSTOS != 'mcp' -a $HOSTOS != '-y' ]; then + echo "The steps below is used to installed mlnx driver 3.2-1, if you are sure you have it or newer driver, pls use \"-y\" to skip!" + echo "1. Install OS related packages" + echo " yum install kernel-devel-`uname -r`" + echo " yum install kernel-headers-`uname -r`" + echo " yum install gcc-c++" + echo "2. Download Mellanox EN Driver for Linux from http://www.mellanox.com/downloads/Drivers/mlnx-en-3.2-1.0.1.1.tgz" + echo "3. Extract it and run ./install.sh from the extracted directory" + echo " tar -xvf mlnx-en-3.2-1.0.1.1.tgz" + echo " ./mlnx-en-3.2-1.0.1/install.sh" + echo "4. Check whether the mlx4 driver is updated" + echo " modprobe mlx4-en" + echo " modinfo mlx4-en | grep version" + echo " version: 3.2-1.0.1.1 (31 Jan 2016)" + echo "5. Once the steps above done, run \"$0 -y\" to build xCAT-genesis-base-ppc64" + exit 0 +fi + + # get the input files for dracut in the right place # Fedora 20 ppc64 uses /usr/lib/dracut/modules.d # CentOS 7 probably uses /usr/lib/dracut/modules.d also From 88ea55bfe5035a996874e2b91de6240279a9f692 Mon Sep 17 00:00:00 2001 From: ertaozh Date: Tue, 19 Jul 2016 05:56:31 -0400 Subject: [PATCH 289/310] modify depends on xcat-genesis-scripts to xcat-genesis-scripts-ppc64 and xcat-genesis-scripts-x86-64 --- xCAT/debian/control | 2 +- xCATsn/debian/control | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT/debian/control b/xCAT/debian/control index c5051a272..69dd56b0e 100644 --- a/xCAT/debian/control +++ b/xCAT/debian/control @@ -7,6 +7,6 @@ Standards-Version: 3.7.2 Package: xcat Architecture: amd64 ppc64el -Depends: ${perl:Depends}, xcat-server, xcat-client, libdbd-sqlite3-perl, isc-dhcp-server, apache2, nfs-kernel-server, nmap, bind9, libxml-parser-perl, xinetd, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, ipmitool-xcat (>=1.8.9), syslinux[any-amd64], libsys-virt-perl, syslinux-xcat[any-amd64], xnba-undi, xcat-genesis-scripts, elilo-xcat, xcat-buildkit, xcat-probe (>=2.12) +Depends: ${perl:Depends}, xcat-server, xcat-client, libdbd-sqlite3-perl, isc-dhcp-server, apache2, nfs-kernel-server, nmap, bind9, libxml-parser-perl, xinetd, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, ipmitool-xcat (>=1.8.15-2), syslinux[any-amd64], libsys-virt-perl, syslinux-xcat[any-amd64], xnba-undi, xcat-genesis-scripts-ppc64, xcat-genesis-scripts-x86-64, elilo-xcat, xcat-buildkit, xcat-probe (>=2.12) Description: Server and configuration utilities of the xCAT management project xcat-server provides the core server and configuration management components of xCAT. This package should be installed on your management server diff --git a/xCATsn/debian/control b/xCATsn/debian/control index 604590bc5..8283481f1 100644 --- a/xCATsn/debian/control +++ b/xCATsn/debian/control @@ -7,7 +7,7 @@ Standards-Version: 3.7.2 Package: xcatsn Architecture: all -Depends: ${perl:Depends}, xcat-server, perl-xcat, xcat-client, libdbd-sqlite3-perl, libxml-parser-perl, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, dhcp3-server, apache2, expect, nfs-kernel-server, nmap, bind9, ipmitool-xcat (>=1.8.9), syslinux-xcat, xnba-undi, xcat-genesis-scripts, elilo-xcat,libsys-virt-perl +Depends: ${perl:Depends}, xcat-server, perl-xcat, xcat-client, libdbd-sqlite3-perl, libxml-parser-perl, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, dhcp3-server, apache2, expect, nfs-kernel-server, nmap, bind9, ipmitool-xcat (>=1.8.15-2), syslinux-xcat, xnba-undi, xcat-genesis-scripts-ppc64, xcat-genesis-scripts-x86-64, elilo-xcat,libsys-virt-perl Recommends: yaboot-xcat Description: Metapackage for a common, default xCAT service node setup xCATsn is a service node management package intended for at-scale management, including hardware management and software management. From 3d0d83c8914c8518d7cc4adeab740deae25a5494 Mon Sep 17 00:00:00 2001 From: Patrick Lundgren Date: Tue, 19 Jul 2016 10:14:40 -0400 Subject: [PATCH 290/310] Removed /bin/restart from install config files --- xCAT-genesis-builder/install | 1 - xCAT-genesis-builder/install.ubuntu | 1 - 2 files changed, 2 deletions(-) diff --git a/xCAT-genesis-builder/install b/xCAT-genesis-builder/install index c5020fc42..67e6950fa 100755 --- a/xCAT-genesis-builder/install +++ b/xCAT-genesis-builder/install @@ -584,7 +584,6 @@ dracut_install /usr/share/zoneinfo/posix/PRC dracut_install /usr/share/zoneinfo/posix/Chile/EasterIsland dracut_install /usr/share/zoneinfo/posix/Chile/Continental inst "$moddir/xcatroot" "/sbin/xcatroot" -inst "$moddir/restart" "/bin/restart" inst "$moddir/dhclient.conf" "/etc/dhclient.conf" inst "$moddir/dhclient-script" "/sbin/dhclient-script" inst "$moddir/rsyslog.conf" "/etc/rsyslog.conf" diff --git a/xCAT-genesis-builder/install.ubuntu b/xCAT-genesis-builder/install.ubuntu index a329cd0cc..9ae3f5af2 100755 --- a/xCAT-genesis-builder/install.ubuntu +++ b/xCAT-genesis-builder/install.ubuntu @@ -612,7 +612,6 @@ inst "$moddir/allowcred.awk" "/bin/allowcred.awk" inst "$moddir/getipmi" "/bin/getipmi" inst "$moddir/remoteimmsetup" "/bin/remoteimmsetup" inst "$moddir/getdestiny" "/bin/getdestiny" -inst "$moddir/restart" "/bin/restart" inst "$moddir/doxcat" "/bin/doxcat" inst "$moddir/nextdestiny" "/bin/nextdestiny" inst "$moddir/getcert" "/bin/getcert" From 797a64131be99bd4491d5361057c5dca4a010ba3 Mon Sep 17 00:00:00 2001 From: penguhyang Date: Mon, 11 Jul 2016 22:09:37 -0400 Subject: [PATCH 291/310] add syslog module to realize the log forward --- .../xcat/netboot/rh/dracut/patch/syslog/check | 3 ++ .../netboot/rh/dracut/patch/syslog/install | 22 +++++++++++ .../dracut/patch/syslog/parse-syslog-opts.sh | 21 ++++++++++ .../share/xcat/netboot/rh/dracut/xcatroot | 27 ++++++++++++- .../share/xcat/netboot/rh/dracut_033/xcatroot | 2 +- xCAT-server/share/xcat/netboot/rh/genimage | 38 +++++++++++-------- 6 files changed, 94 insertions(+), 19 deletions(-) create mode 100755 xCAT-server/share/xcat/netboot/rh/dracut/patch/syslog/check create mode 100755 xCAT-server/share/xcat/netboot/rh/dracut/patch/syslog/install create mode 100755 xCAT-server/share/xcat/netboot/rh/dracut/patch/syslog/parse-syslog-opts.sh diff --git a/xCAT-server/share/xcat/netboot/rh/dracut/patch/syslog/check b/xCAT-server/share/xcat/netboot/rh/dracut/patch/syslog/check new file mode 100755 index 000000000..c52d3c26b --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/dracut/patch/syslog/check @@ -0,0 +1,3 @@ +#!/bin/sh + +exit 0 diff --git a/xCAT-server/share/xcat/netboot/rh/dracut/patch/syslog/install b/xCAT-server/share/xcat/netboot/rh/dracut/patch/syslog/install new file mode 100755 index 000000000..b8904154d --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/dracut/patch/syslog/install @@ -0,0 +1,22 @@ +#!/bin/sh +if which rsyslogd >/dev/null; then + installs="rsyslogd /lib64/rsyslog/lmnet.so /lib64/rsyslog/imklog.so /lib64/rsyslog/imuxsock.so" +elif which syslogd >/dev/null; then + installs="syslogd" +elif which syslog-ng >/dev/null; then + installs="syslog-ng" +else + dwarn "Could not find any syslog binary although the syslogmodule is selected to be installed. Please check." +fi +if [ -n "$installs" ]; then + dracut_install cat + dracut_install logger + dracut_install $installs + inst_hook cmdline 90 "$moddir/parse-syslog-opts.sh" + inst_hook pre-udev 61 "$moddir/syslog-genrules.sh" + inst_hook pre-pivot 99 "$moddir/syslog-cleanup.sh" + inst_simple "$moddir/rsyslogd-start.sh" /sbin/rsyslogd-start + inst_simple "$moddir/rsyslogd-stop.sh" /sbin/rsyslogd-stop + mkdir -m 0755 -p ${initdir}/etc/templates + inst_simple "${moddir}/rsyslog.conf" /etc/templates/rsyslog.conf +fi diff --git a/xCAT-server/share/xcat/netboot/rh/dracut/patch/syslog/parse-syslog-opts.sh b/xCAT-server/share/xcat/netboot/rh/dracut/patch/syslog/parse-syslog-opts.sh new file mode 100755 index 000000000..6c070fbd6 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/rh/dracut/patch/syslog/parse-syslog-opts.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offs +et: 4; -*- +# ex: ts=8 sw=4 sts=4 et filetype=sh + +# Parses the syslog commandline options +# +#Bootparameters: +#syslogserver=ip Where to syslog to +#sysloglevel=level What level has to be logged +#syslogtype=rsyslog|syslog|syslogng +# Don't auto detect syslog but set it +type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh + +syslogserver=$(getarg syslog.server -d syslog) +syslogfilters=$(getargs syslog.filter -d filter) +syslogtype=$(getarg syslog.type -d syslogtype) + +[ -n "$syslogserver" ] && echo $syslogserver > /tmp/syslog.server +[ -n "$syslogfilters" ] && echo "$syslogfilters" > /tmp/syslog.filters +[ -n "$syslogtype" ] && echo "$syslogtype" > /tmp/syslog.type diff --git a/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot b/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot index 6820233ca..71e63af69 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot +++ b/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot @@ -16,9 +16,14 @@ if [ $? -ne 0 ]; then XCATIPORT="3002" fi +xcatdebugmode="$(getarg xcatdebugmode=)" -if [ $NODESTATUS -ne 0 ];then -/tmp/updateflag $MASTER $XCATIPORT "installstatus netbooting" +[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "running xcatroot...." +[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "MASTER=$MASTER XCATIPORT=$XCATIPORT" + +if [ "$NODESTATUS" != "0" ]; then + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "nodestatus: netbooting,reporting..." + /tmp/updateflag $MASTER $XCATIPORT "installstatus netbooting" fi if [ ! -z "$imgurl" ]; then @@ -26,8 +31,10 @@ if [ ! -z "$imgurl" ]; then NFS=0 FILENAME=${imgurl##*/} while [ ! -r "$FILENAME" ]; do + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "downloading $imgurl...." echo Getting $imgurl... if ! wget $imgurl; then + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "downloading $imgurl failed,retrying...." rm -f $FILENAME sleep 27 fi @@ -61,6 +68,7 @@ if [ -r /rootimg.sfs ]; then mount --move /ro $NEWROOT/ro mount --move /rw $NEWROOT/rw elif [ -r /rootimg.gz ]; then + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg.gz downloaded,setting up RAM-root tmpfs...." echo Setting up RAM-root tmpfs. if [ -z $rootlimit ];then mount -t tmpfs -o mode=755 rootfs $NEWROOT @@ -69,6 +77,7 @@ elif [ -r /rootimg.gz ]; then fi cd $NEWROOT + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Extracting root filesystem:" echo -n "Extracting root filesystem:" if [ -x /bin/cpio ]; then gzip -cd /rootimg.gz |/bin/cpio -idum @@ -76,6 +85,7 @@ elif [ -r /rootimg.gz ]; then gzip -cd /rootimg.gz |cpio -idum fi $NEWROOT/etc/init.d/localdisk + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...." echo Done elif [ -r /rootimg.txz ]; then echo Setting up RAM-root tmpfs. @@ -213,11 +223,18 @@ elif [ -r /rootimg-statelite.gz ]; then mount -n --bind /sys $NEWROOT/sys else + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Failed to download image, panicing in 5..." echo -n Failed to download image, panicing in 5... for i in 4 3 2 1 0; do /bin/sleep 1 + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "$i..." echo -n $i... done + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "You're dead. rpower nodename reset to play again." + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "* Did you packimage with -m cpio, -m squashfs, or -m nfs?" + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "* If using -m squashfs did you include aufs.ko with geninitrd? e.g.: -n tg3,squashfs,aufs,loop" + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "If using -m nfs did you export NFS and sync rootimg? And did you include the aufs and nfs modules in the proper order: e.g.: -n tg3,aufs,loop,sunrpc,lockd,nfs_acl,nfs" + echo echo "You're dead. rpower nodename reset to play again. @@ -239,6 +256,7 @@ if [ -z $STATEMNT ]; then netif=${lf#*.} netif=${netif%.*} cp $lf "$NEWROOT/var/lib/dhclient/dhclient-$netif.leases" + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "saving $NEWROOT/var/lib/dhclient/dhclient-$netif.leases" done if [ ! -z "$ifname" ]; then @@ -255,8 +273,10 @@ if [ -z $STATEMNT ]; then if [ ! -z "$MACX" ] && [ ! -z "$ETHX" ]; then if [ ! -e $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX ]; then + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "creating $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX" touch $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX fi + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "writing $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX: DEVICE=$ETHX;BOOTPROTO=dhcp;HWADDR=$MACX;ONBOOT=yes" echo "DEVICE=$ETHX" > $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX echo "BOOTPROTO=dhcp" >> $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX echo "HWADDR=$MACX" >> $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX @@ -264,12 +284,15 @@ if [ -z $STATEMNT ]; then fi fi +[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "saving $NEWROOT/etc/resolv.conf" cp /etc/resolv.conf "$NEWROOT/etc/" if [ -d "$NEWROOT/etc/sysconfig" -a ! -e "$NEWROOT/etc/sysconfig/selinux" ]; then + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "disable selinux ..." echo "SELINUX=disabled" >> "$NEWROOT/etc/sysconfig/selinux" fi +[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "exiting xcatroot..." # inject new exit_if_exists echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm "$job"' > /initqueue/xcat.sh # force udevsettle to break diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot index 5ac7233a9..bcb9a911a 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot @@ -26,7 +26,7 @@ xcatdebugmode="$(getarg xcatdebugmode=)" [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "MASTER=$MASTER XCATIPORT=$XCATIPORT" -if [ $NODESTATUS -ne 0 ];then +if [ "$NODESTATUS" != "0" ]; then [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "nodestatus: netbooting,reporting..." /tmp/updateflag $MASTER $XCATIPORT "installstatus netbooting" fi diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index 5c4cb53f6..a7d598294 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -895,19 +895,29 @@ sub mkinitrd_dracut { if ($dracutver >= "033") { + my $perm = (stat("$fullpath/$dracutdir/patch/syslog/module-setup.sh"))[2]; + cp("$fullpath/$dracutdir/patch/syslog/module-setup.sh", $dracutmoduledir."98syslog/"); + chmod($perm&07777, $dracutmoduledir."98syslog/"."module-setup.sh"); - my $perm = (stat("$fullpath/$dracutdir/patch/syslog/module-setup.sh"))[2]; - cp("$fullpath/$dracutdir/patch/syslog/module-setup.sh", $dracutmoduledir."98syslog/"); - chmod($perm&07777, $dracutmoduledir."98syslog/"."module-setup.sh"); + $perm = (stat("$fullpath/$dracutdir/patch/syslog/rsyslogd-start.sh"))[2]; + cp("$fullpath/$dracutdir/patch/syslog/rsyslogd-start.sh", $dracutmoduledir."98syslog/"); + chmod($perm&07777, $dracutmoduledir."98syslog/"."rsyslogd-start.sh"); - $perm = (stat("$fullpath/$dracutdir/patch/syslog/rsyslogd-start.sh"))[2]; - cp("$fullpath/$dracutdir/patch/syslog/rsyslogd-start.sh", $dracutmoduledir."98syslog/"); - chmod($perm&07777, $dracutmoduledir."98syslog/"."rsyslogd-start.sh"); + $perm = (stat("$fullpath/$dracutdir/patch/syslog/syslog-genrules.sh"))[2]; + cp("$fullpath/$dracutdir/patch/syslog/syslog-genrules.sh", $dracutmoduledir."98syslog/"); + chmod($perm&07777, $dracutmoduledir."98syslog/"."syslog-genrules.sh"); + } else { + my $perm = (stat("$fullpath/$dracutdir/patch/syslog/check"))[2]; + cp("$fullpath/$dracutdir/patch/syslog/check", $dracutmoduledir."98syslog/"); + chmod($perm&07777, $dracutmoduledir."98syslog/"."check"); - $perm = (stat("$fullpath/$dracutdir/patch/syslog/syslog-genrules.sh"))[2]; - cp("$fullpath/$dracutdir/patch/syslog/syslog-genrules.sh", $dracutmoduledir."98syslog/"); - chmod($perm&07777, $dracutmoduledir."98syslog/"."syslog-genrules.sh"); + $perm = (stat("$fullpath/$dracutdir/patch/syslog/install"))[2]; + cp("$fullpath/$dracutdir/patch/syslog/install", $dracutmoduledir."98syslog/"); + chmod($perm&07777, $dracutmoduledir."98syslog/"."install"); + $perm = (stat("$fullpath/$dracutdir/patch/syslog/parse-syslog-opts.sh"))[2]; + cp("$fullpath/$dracutdir/patch/syslog/parse-syslog-opts.sh", $dracutmoduledir."98syslog/"); + chmod($perm&07777, $dracutmoduledir."98syslog/"."parse-syslog-opts.sh"); } my $dracutmpath = $dracutmoduledir."97xcat/"; @@ -955,10 +965,10 @@ sub mkinitrd_dracut { #update etc/dracut.conf open($DRACUTCONF, '>', "$rootimg_dir/etc/dracut.conf"); if (-d glob($dracutmoduledir."[0-9]*fadump")){ - print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules fadump"\n}; + print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules syslog fadump"\n}; } else{ - print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules"\n}; + print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules syslog"\n}; } print $DRACUTCONF qq{add_drivers+="$add_drivers"\n}; print $DRACUTCONF qq{filesystems+="nfs"\n}; @@ -991,16 +1001,12 @@ sub mkinitrd_dracut { $perm = (stat("$fullpath/$dracutdir/installkernel"))[2]; chmod($perm&07777, "$dracutmpath/installkernel"); - my $dracutmodulelist=" xcat nfs base network kernel-modules "; + my $dracutmodulelist=" xcat nfs base network kernel-modules syslog "; if (-d glob($dracutmoduledir."[0-9]*fadump")){ $dracutmodulelist .=" fadump "; } - if ($dracutver >= "033") { - $dracutmodulelist .= " syslog "; - } - # update etc/dracut.conf open($DRACUTCONF, '>', "$rootimg_dir/etc/dracut.conf"); print $DRACUTCONF qq{dracutmodules+="$dracutmodulelist"\n}; From 8187e3efa1f8f405620bc74446f93321d7408a3d Mon Sep 17 00:00:00 2001 From: chenglch Date: Thu, 14 Jul 2016 04:47:05 -0400 Subject: [PATCH 292/310] Add rest api helper interface to access non-xcat resource Currently xcat rest service is running with apache user who do not have the privilege to manage some local resource like credential files needed by xcat web ui to get the conserver access. This patch add scripts in xcatconfig to generate credential files for conserver user. This patch also add a work around framework for xcat restapi to provide the interface to get or set the system resource so that restapi with apache privilege can retrieve the credential files. --- xCAT-server/lib/xcat/plugins/localrest.pm | 211 ++++++++++++++++++++++ xCAT-server/sbin/xcatconfig | 48 ++++- xCAT-server/xCAT-wsapi/xcatws.cgi | 78 +++++++- 3 files changed, 328 insertions(+), 9 deletions(-) create mode 100644 xCAT-server/lib/xcat/plugins/localrest.pm diff --git a/xCAT-server/lib/xcat/plugins/localrest.pm b/xCAT-server/lib/xcat/plugins/localrest.pm new file mode 100644 index 000000000..8474acad3 --- /dev/null +++ b/xCAT-server/lib/xcat/plugins/localrest.pm @@ -0,0 +1,211 @@ +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html +#------------------------------------------------------- + +=head1 + xCAT plugin package to non xcat resource + +=cut + +#------------------------------------------------------- +package xCAT_plugin::localrest; + +BEGIN { + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; +} +use lib "$::XCATROOT/lib/perl"; + +use xCAT::Utils; +use xCAT::MsgUtils; +use File::Basename; +use strict; + +#------------------------------------------------------- + +=head3 handled_commands + +Return list of commands handled by this plugin + +=cut + +#------------------------------------------------------- + +sub handled_commands +{ + return { + localrest => "localrest", + }; +} + +#------------------------------------------------------- + +=head3 process_request + + Process the command. + +=cut + +#------------------------------------------------------- +sub process_request +{ + my $request = shift; + $::callback = shift; + my $subreq = shift; + my $command = $request->{command}->[0]; + + if ($command eq "localrest") { + return handle_rest_request($request, $subreq); + } +} + +#------------------------------------------------------- + +=head3 handle_rest_request + + This function check the command option, then call the + related function to complete the request. + + Usage example: + This function is called from process_request, + do not call it directly. +=cut + +#------------------------------------------------------- + +sub handle_rest_request { + my ($request, $subreq) = @_; + my ($method, $resource, @params, $subroutine, $rsp, $rc); + require JSON; + my $JSON = JSON->new(); + + my @args = @{ $request->{arg} }; + if (scalar(@args) < 2) { + $rsp->{data}->[0] = "Local rest api take at least two parameter."; + xCAT::MsgUtils->message("E", $rsp, $::callback); + return 1; + } + $method = shift @args; + $resource = shift @args; + $subroutine = $method . '_' . $resource; + @params = @args; + + # if related subroutine found, call it + # subroutine for rest handler must return a ref to HASH or ARRAY + # comtaining the data that should be return to the CGI + if (__PACKAGE__->can({$subroutine})) { + $rsp->{data}->[0] = "Unsupported request: $subroutine."; + xCAT::MsgUtils->message("E", $rsp, $::callback); + return 1; + } + no strict 'refs'; + my $result = $subroutine->(@params); + + # handle the result from the rest subroutine + if (ref($result) eq 'HASH') { + if (defined($result->{'type'}) && $result->{'type'} eq 'stream' + && defined($result->{'filename'})) { + $rsp->{data}->[0] = "stream"; + $rsp->{data}->[1] = $result->{'filename'}; + $rsp->{data}->[2] = $result->{'data'}; + } else { + my $json = $JSON->encode($result); + $rsp->{data}->[0] = "json"; + $rsp->{data}->[1] = $json; + } + xCAT::MsgUtils->message("I", $rsp, $::callback); + $rc = 0; + } elsif (ref($result) eq 'ARRAY') { + my $json = $JSON->encode($result); + $rsp->{data}->[0] = "json"; + $rsp->{data}->[1] = $json; + xCAT::MsgUtils->message("I", $rsp, $::callback); + $rc = 0; + } elsif ($result == 1 || $result == 0) { + $rc = $result; + } else { + $rc = 1; + $rsp->{data}->[0] = "Internal error, result value is unacceptable"; + xCAT::MsgUtils->message("E", $rsp, $::callback); + } + return $rc; +} + +#------------------------------------------------------- + +=head3 handler to list network adapters + + Subroutine to handle rest request + GET /localres/adapter/ + + Usage example: + This function is called from handle_rest_request, + do not call it directly. +=cut + +#------------------------------------------------------- +sub list_adapter { + my ($rsp, $result, $i); + if (!opendir DIR, "/sys/class/net") { + $rsp->{data}->[0] = "Unable open /sys/class/net dir."; + xCAT::MsgUtils->message("E", $rsp, $::callback); + return 1; + } + my @dir = readdir(DIR); + closedir(DIR); + $i = 0; + foreach my $item (@dir) { + if ($item eq '.' || $item eq '..') { + next; + } + $result->[ $i++ ] = $item; + } + return $result; +} + +#------------------------------------------------------- + +=head3 handler to download credential files + + Subroutine to handle rest request + GET /localres/credential/conserver/file + GET /localres/credential/ca/file + + Usage example: + This function is called from handle_rest_request, + do not call it directly. +=cut + +#------------------------------------------------------- +sub download_credential { + my @params = @_; + my ($rsp, $buf, $fpath, $fd, $data, $result, $n); + if (!@params) { + $rsp->{data}->[0] = "Argmument error."; + xCAT::MsgUtils->message("E", $rsp, $::callback); + return 1; + } + my %filemap = ( + 'conserver' => "/home/conserver/.xcat/client-cred.pem", + 'ca' => "/home/conserver/.xcat/ca.pem", + ); + $fpath = $filemap{ $params[0] }; + if (!$fpath || !-e $fpath) { + $rsp->{data}->[0] = "File resource for " . $params[0] . " unavailable."; + xCAT::MsgUtils->message("E", $rsp, $::callback); + return 1; + } + + if (!($n = open($fd, '<', $fpath))) { + $rsp->{data}->[0] = "Coundn't open file $fpath."; + xCAT::MsgUtils->message("E", $rsp, $::callback); + return 1; + } + while ($n = read($fd, $buf, 8192)) { + $data .= $buf; + } + close($fd); + $result->{'type'} = 'stream'; + $result->{'filename'} = basename($fpath); + $result->{'data'} = $data; + return $result; +} +1; diff --git a/xCAT-server/sbin/xcatconfig b/xCAT-server/sbin/xcatconfig index 8d9d84b37..ac57971a6 100755 --- a/xCAT-server/sbin/xcatconfig +++ b/xCAT-server/sbin/xcatconfig @@ -448,12 +448,6 @@ if ($::INITIALINSTALL || $::FORCE || $::UPDATEINSTALL || $::genCredentials) } else { - #since the xcatd service unit file is updated on xcat upgrade - #"systemctl daemon-reload" need to be run to update the service unit - if ($::UPDATEINSTALL){ - $xcmd="type systemctl >/dev/null 2>&1 && systemctl daemon-reload"; - xCAT::Utils->runcmd("$xcmd", 0); - } #$xcmd = "/etc/init.d/xcatd restart"; xCAT::Utils->restartservice("xcatd"); } @@ -1507,8 +1501,30 @@ sub checkotherpkgs #----------------------------------------------------------------------------- sub genCredentials - { + my $add_user_func = sub { + my $user = shift; + my ($cmd, $outref, $rc); + $rc = getgrnam($user); + if (!$rc) { + $cmd = "groupadd $user"; + $outref = xCAT::Utils->runcmd("$cmd", 0); + if ($::RUNCMD_RC != 0) { + xCAT::MsgUtils->message('E',"$cmd failed"); + return; + } + } + $rc = getpwnam($user); + if (!$rc) { + $cmd = "useradd -g $user -s /bin/bash -d /home/$user -m $user"; + $outref = xCAT::Utils->runcmd("$cmd", 0); + if ($::RUNCMD_RC != 0) { + xCAT::MsgUtils->message('E',"$cmd failed"); + return; + } + } + }; + my $hname = `hostname`; chomp $hname; if ((!-d "/etc/xcat/ca") || $::FORCE || $::genCredentials) @@ -1616,6 +1632,24 @@ sub genCredentials } } + if ((!-r "/home/conserver/.xcat/client-key.pem") || $::FORCE || $::genCredentials) + { + $add_user_func->('conserver'); + my $cmd = + "echo 'y\ny\ny\ny' |$::XCATROOT/share/xcat/scripts/setup-local-client.sh conserver"; + verbose("Running $cmd"); + my $rc = system($cmd); + if ($rc >> 8) + { + xCAT::MsgUtils->message('E', + "Could not create xCAT certificate in /home/conserver/.xcat/client-key.pem."); + } + else + { + xCAT::MsgUtils->message('I', "Created xCAT certificate."); + } + } + # copy to postscript directory $cmd = "/bin/rm -rf $::INSTALLDIR/postscripts/_xcat >/dev/null 2>&1"; $outref = xCAT::Utils->runcmd("$cmd", 0); diff --git a/xCAT-server/xCAT-wsapi/xcatws.cgi b/xCAT-server/xCAT-wsapi/xcatws.cgi index 54e3ca8a9..55a4adbed 100755 --- a/xCAT-server/xCAT-wsapi/xcatws.cgi +++ b/xCAT-server/xCAT-wsapi/xcatws.cgi @@ -1230,6 +1230,24 @@ my %URIdef = ( }, }, }, + + ### interface to access local system resource which is not managed by xcat directly + ### localres can be looked as a top level non-xcat resource pool + ### rest operation will trasfer the target resource to xcatd plugin to handle the non-xcat resource + localres => { + localres => { + desc => "[URI:/localres/*] - The local non-xcat resource.", + matcher => '^/localres(/[^/]*)+$', + GET => { + desc => "List information for the target system resource.", + usage => "||For target resource can match any resource type which can be proccssed by the resthelper plugin.|", + example => qq(|List adapters on MN machine|GET|/localres/interface/|{\n \"interfaces\":[\n\"eth0\",\n \"eth1\",\n]"|), + cmd => "localrest", + fhandler => \&localreshdl, + outhdler => \&localresout, + }, + } + } ); # supported formats @@ -1288,6 +1306,7 @@ my @path = split(/\//, $pathInfo); # The uri path like /nodes/node1/... # Define the golbal variables which will be used through the handling process my $pageContent = ''; # Global var containing the ouptut back to the rest client +my %header_info; #Global var containing the extra info to the http header my $request = {clienttype => 'ws'}; # Global var that holds the request to send to xcatd my $format = 'json'; # The output format for a request invoke my $xmlinstalled; # Global var to speicfy whether the xml modules have been loaded @@ -1649,6 +1668,17 @@ sub defout_remove_appended_info { } +sub localresout { + my $data = shift; + my $json; + if ($data->[0]->{info}->[0] eq 'stream') { + $format = 'stream'; + $header_info{'attachment'} = $data->[0]->{info}->[1]; + addPageContent($data->[0]->{info}->[2]); + } elsif ($data->[0]->{info}->[0] eq 'json') { + addPageContent($data->[0]->{info}->[1]); + } +} # hanlde the output which has the node irrelevant message (e.g. the output for updatenode command) # handle the input like @@ -2148,6 +2178,39 @@ sub actionhdl { return $responses; } +sub localreshdl { + my $params = shift; + my @args; + my @urilayers = @{$params->{'layers'}}; + + # set the command name + $request->{command} = $params->{'cmd'}; + + if (isGET() && scalar(@urilayers) > 1 && $urilayers[-1] eq "detail") { + push @args, "show"; + } elsif (isGET() && scalar(@urilayers) > 1 && $urilayers[-1] eq "file") { + push @args, "download"; + } elsif (isGET()) { + push @args, "list"; + } elsif (isPost()) { + push @args, "create"; + } elsif (isPut()) { + push @args, "update"; + } elsif (isDelete()) { + push @args, "delete"; + } + shift @urilayers; + foreach my $item (@urilayers) { + push @args, $item if $item ne 'detail' && $item ne 'file'; + } + push @{$request->{arg}}, @args; + # localrest is single plugin handler, use sequntial to avoid of multi-level processes + $request->{'sequential'}->[0] = 1; + my $req = genRequest(); + my $responses = sendRequest($req); + return $responses; +} + # The operation callback subroutine for node irrelevant commands like makedns -n and makedhcp -n # assembe the xcat request, send it to xcatd and get response sub nonobjhdl { @@ -2965,11 +3028,22 @@ sub sendResponseMsg { elsif ('xml' eq $format) { $tempFormat = 'text/xml'; } + elsif ('stream' eq $format) { + $tempFormat = 'application/octet-stream'; + } else { $tempFormat = 'text/html'; } - print $q->header(-status => $code, -type => $tempFormat); - if ($pageContent) { $pageContent .= "\n"; } # if there is any content, append a newline + + if ($header_info{attachment}) { + print $q->header(-status => $code, + -type => $tempFormat, + -attachment => $header_info{attachment}, + -Content_length => length($pageContent)); + } else { + print $q->header(-status => $code, -type => $tempFormat); + if ($pageContent) { $pageContent .= "\n"; } # if there is any content, append a newline + } print $pageContent; exit(0); } From afd2ce56ecf4352e51404d50e038e494d5794883 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Tue, 19 Jul 2016 23:19:43 -0400 Subject: [PATCH 293/310] fix issue1544 and issue1545 --- xCAT-test/autotest/bundle/le_rhels_cmd.bundle | 1 - xCAT-test/autotest/bundle/le_sles_cmd.bundle | 1 - .../autotest/bundle/le_ubuntu_cmd.bundle | 2 - xCAT-test/autotest/bundle/p_rhels_cmd.bundle | 1 - xCAT-test/autotest/bundle/p_sles_cmd.bundle | 1 - .../autotest/bundle/rhels6.7_ppc64.bundle | 611 +++++++++--------- .../autotest/bundle/rhels6.7_x86_64.bundle | 417 ++++++------ .../autotest/bundle/rhels6.8_ppc64.bundle | 607 +++++++++-------- .../autotest/bundle/rhels6.8_x86_64.bundle | 419 ++++++------ .../autotest/bundle/rhels7.2_ppc64.bundle | 611 +++++++++--------- .../autotest/bundle/rhels7.2_ppc64le.bundle | 399 ++++++------ .../autotest/bundle/rhels7.2_x86_64.bundle | 423 ++++++------ .../autotest/bundle/sles11.4_ppc64.bundle | 539 ++++++++------- .../autotest/bundle/sles11.4_x86_64.bundle | 443 +++++++------ .../autotest/bundle/sles12.1_ppc64.bundle | 523 ++++++++------- .../autotest/bundle/sles12.1_ppc64le.bundle | 417 ++++++------ .../autotest/bundle/sles12.1_x86_64.bundle | 431 ++++++------ .../autotest/bundle/sles12_ppc64le.bundle | 417 ++++++------ .../autotest/bundle/sles12_x86_64.bundle | 427 ++++++------ .../bundle/ubuntu14.04.3_ppc64le.bundle | 492 +++++++------- .../bundle/ubuntu14.04.3_x86_64.bundle | 526 ++++++++------- .../bundle/ubuntu14.04.4_ppc64le.bundle | 488 +++++++------- .../bundle/ubuntu14.04.4_x86_64.bundle | 522 ++++++++------- .../bundle/ubuntu16.04_ppc64le.bundle | 488 +++++++------- .../autotest/bundle/ubuntu16.04_x86_64.bundle | 506 ++++++++------- xCAT-test/autotest/bundle/x_rhels_cmd.bundle | 1 - xCAT-test/autotest/bundle/x_sles_cmd.bundle | 1 - xCAT-test/autotest/bundle/x_ubuntu_cmd.bundle | 2 - 28 files changed, 4840 insertions(+), 4876 deletions(-) diff --git a/xCAT-test/autotest/bundle/le_rhels_cmd.bundle b/xCAT-test/autotest/bundle/le_rhels_cmd.bundle index 742b6066c..dce4dad64 100644 --- a/xCAT-test/autotest/bundle/le_rhels_cmd.bundle +++ b/xCAT-test/autotest/bundle/le_rhels_cmd.bundle @@ -85,7 +85,6 @@ nodels_noderange_table nodels_tablevalue nodels_tablevalue_tablecolumn nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn nodels_h nodels_v xcatstanzafile_colon diff --git a/xCAT-test/autotest/bundle/le_sles_cmd.bundle b/xCAT-test/autotest/bundle/le_sles_cmd.bundle index ee0f0e23e..f6173e756 100644 --- a/xCAT-test/autotest/bundle/le_sles_cmd.bundle +++ b/xCAT-test/autotest/bundle/le_sles_cmd.bundle @@ -87,7 +87,6 @@ nodels_noderange_table nodels_tablevalue nodels_tablevalue_tablecolumn nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn nodels_h nodels_v xcatstanzafile_colon diff --git a/xCAT-test/autotest/bundle/le_ubuntu_cmd.bundle b/xCAT-test/autotest/bundle/le_ubuntu_cmd.bundle index 452f1e480..80fccf734 100644 --- a/xCAT-test/autotest/bundle/le_ubuntu_cmd.bundle +++ b/xCAT-test/autotest/bundle/le_ubuntu_cmd.bundle @@ -84,7 +84,6 @@ nodels_noderange_table nodels_tablevalue nodels_tablevalue_tablecolumn nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn nodels_h nodels_v xcatstanzafile_colon @@ -198,7 +197,6 @@ lskit_C lskitcomp_v lskitcomp_h lskitcomp_C -lskitcomp_C lskitcomp_S lskitdeployparam_v lskitdeployparam_h diff --git a/xCAT-test/autotest/bundle/p_rhels_cmd.bundle b/xCAT-test/autotest/bundle/p_rhels_cmd.bundle index 32095c6cc..886f512ba 100644 --- a/xCAT-test/autotest/bundle/p_rhels_cmd.bundle +++ b/xCAT-test/autotest/bundle/p_rhels_cmd.bundle @@ -120,7 +120,6 @@ nodels_noderange_table nodels_tablevalue nodels_tablevalue_tablecolumn nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn nodels_h nodels_v xcatstanzafile_normal diff --git a/xCAT-test/autotest/bundle/p_sles_cmd.bundle b/xCAT-test/autotest/bundle/p_sles_cmd.bundle index 00d550171..3e9509dcb 100644 --- a/xCAT-test/autotest/bundle/p_sles_cmd.bundle +++ b/xCAT-test/autotest/bundle/p_sles_cmd.bundle @@ -102,7 +102,6 @@ nodels_noderange_table nodels_tablevalue nodels_tablevalue_tablecolumn nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn nodels_h nodels_v xcatstanzafile_normal diff --git a/xCAT-test/autotest/bundle/rhels6.7_ppc64.bundle b/xCAT-test/autotest/bundle/rhels6.7_ppc64.bundle index 7c2237687..ee6a786f9 100644 --- a/xCAT-test/autotest/bundle/rhels6.7_ppc64.bundle +++ b/xCAT-test/autotest/bundle/rhels6.7_ppc64.bundle @@ -1,306 +1,305 @@ -reg_linux_diskfull_installation_flat -updatenode_h -updatenode_v -updatenode_diskful_syncfiles -updatenode_diskful_syncfiles_rename -updatenode_diskful_syncfiles_dir -updatenode_diskful_syncfiles_multi_files -updatenode_syncfile_EXECUTE -updatenode_syncfile_EXECUTEALWAYS -updatenode_syncfile_APPEND -updatenode_syncfile_MERGE -updatenode_P_script1 -updatenode_P_script2 -updatenode_f_incompatible_flags -updatenode_k_incompatible_flags -updatenode_diskful_syncfiles_P_script1 -updatenode_script3 -updatenode_P_script1_script2 -updatenode_without_flag -chdef_null -chdef_t_node -chdef_t_network -chdef_p -chdef_m -chdef_z -chdef_group -chdef_group_p -chdef_dynamic_group -chdef_multiple_keys -chdef_n -chdef_t_o_error -chtab_null -chtab_d -chtab_modify_node -chtab_modify_key -chtab_h -chtab_v -copycds_iso -copycds_n -copycds_a -copycds_n_a -copycds_a_err -copycds_n_err -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_node -getmacs_noderange -getmacs_d -getmacs_f_D -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -lslite_i -lslite_noderange -lslite_h -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a -makedhcp_a_d -makedhcp_d -mkdef_null -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_normal -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_tab -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_specificvalue -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_err_node -rinv_bus -rinv_config -rinv_serial -rinv_model -rinv_firm -rinv_all -rinv_noderange_err -rmdef_null -rmdef_t_err -rpower_off -rpower_stat -rpower_boot -rpower_on -rpower_reset -rpower_noderange -rpower_noderange_nodeps -rpower_err_noderange -rscan_noderange -rscan_x -rscan_z -rscan_w -rscan_x_w -rscan_z_w -rvitals_lcds -rvitals_all -rvitals_noderange_err -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_p_auditlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -makehosts_h -makehosts_help -makehosts_null -makehosts_l -makehosts_d -makehosts_n -makehosts_n_noderange -xdcp_src_dst -makedns_h -makedns_d_node -makedns_n -makedns -noderange_individual_node -noderange_individual_grp -noderange_node01-node10 -noderange_group1-group3 -noderange_10-20 -noderange_XCAT_NODE_PREFIX -noderange_XCAT_NODE_SUFFIX -noderange_exclusion -noderange_group_intersection -confignics_config_one_port_single_value -confignics_config_multiple_ports_single_value -confignics_config_multiple_ports_multiple_value -confignics_config_multiple_port_withnichostnamesuffixes_multiple_value -confignics_config_multiple_port_withnicaliases_multiple_value -confignics_disable_set_to_yes -confignics_disable_set_to_1 -confignics_s -xdsh_h -xdsh_V -xdsh_regular_command -xdsh_Q_command -xdsh_c_cn -xdsh_e_filename -xdsh_E -xdsh_t -xdsh_q -xdsh_T -xdsh_o -switchdiscover_range_default -switchdiscover_h -switchdiscover_range_s -switchdiscover_range_default_w -switchdiscover_range_r -switchdiscover_range_x -switchdiscover_range_z -switchdiscover_range_z_V -makentp_v -makentp_h -makentp_V -makentp -makentp_a -nodeset_check_warninginfo -runcmdinstaller_h -runcmdinstaller_command -get_xcat_postscripts_loginfo -updatenode_postscripts_loginfo -bmcdiscover_h -bmcdiscover_nmap_range -bmcdiscover_v -bmcdiscover_check_paswd -bmcdiscover_check_passwd_wrong -bmcdiscover_get_ipsource -bmcdiscover_range_w -bmcdiscover_range_z -xcatd_start -xcatd_stop -xcatd_restart -run_command_with_XCATBYPASS -disable_root_permission_in_policy_table -assign_certain_command_permission -reg_linux_diskless_installation_flat -reg_linux_statelite_installation_flat -SN_setup_case -reg_linux_diskfull_installation_hierarchy -reg_linux_diskless_installation_hierarchy -reg_linux_statelite_installation_hierarchy_by_ramdisk -reg_linux_statelite_installation_hierarchy_by_nfs -redhat_migration1 -redhat_migration2 -clean_up_env +reg_linux_diskfull_installation_flat +updatenode_h +updatenode_v +updatenode_diskful_syncfiles +updatenode_diskful_syncfiles_rename +updatenode_diskful_syncfiles_dir +updatenode_diskful_syncfiles_multi_files +updatenode_syncfile_EXECUTE +updatenode_syncfile_EXECUTEALWAYS +updatenode_syncfile_APPEND +updatenode_syncfile_MERGE +updatenode_P_script1 +updatenode_P_script2 +updatenode_f_incompatible_flags +updatenode_k_incompatible_flags +updatenode_diskful_syncfiles_P_script1 +updatenode_script3 +updatenode_P_script1_script2 +updatenode_without_flag +chdef_null +chdef_t_node +chdef_t_network +chdef_p +chdef_m +chdef_z +chdef_group +chdef_group_p +chdef_dynamic_group +chdef_multiple_keys +chdef_n +chdef_t_o_error +chtab_null +chtab_d +chtab_modify_node +chtab_modify_key +chtab_h +chtab_v +copycds_iso +copycds_n +copycds_a +copycds_n_a +copycds_a_err +copycds_n_err +packimage_o_p_a_m +packimage_p_a_o +packimage_imagename +packimage_h +packimage_v +pping_h +pping_v +pping_node +getmacs_noderange +getmacs_d +getmacs_f_D +gettab_key_table +gettab_H +gettab_err +gettab_h +lsdef_null +lsdef_a +lsdef_t_o_l +lsdef_t_o_l_z +lsdef_t +lsdef_t_i_o +lsdef_t_w +lsdef_t_err +lslite_i +lslite_noderange +lslite_h +makeconservercf_null +makeconservercf_noderange +makeconservercf_d +makedhcp_n +makedhcp_a +makedhcp_a_d +makedhcp_d +mkdef_null +mkdef_z +mkdef_t_o_error +nodeadd_noderange +nodeadd_err_symbol +nodeadd_null +nodeadd_noderange_nodetype +nodeadd_v +nodeadd_h +nodegrpch_v +nodegrpch_h +nodegrpch_groups +nodegrpch_err +nodech_noderange_table +nodech_noderange_table_comma +nodech_noderange_table_arrow +nodech_noderanage_table_at +nodech_delete +nodech_error_node +nodech_error_table +nodech_h +nodech_v +nodech_noderange_table_include +nodech_noderange_table_uninclude +nodech_noderange_table_equal +nodech_noderange_table_unequal +nodech_noderange_shortname_groups +nodech_noderange_shortname_tags +nodech_noderange_shortname_mgt +nodels_null +nodels_H +nodels_noderange +nodels_err_symbol +nodels_err_noderange +nodels_noderange_shortname_groups +nodels_noderange_shortname_tags +nodels_noderange_shortname_mgt +nodels_table_include +nodels_noderange_table_uninclude +nodels_noderange_table_equal +nodels_noderange_table_unequal +nodels_b +nodels_S +nodels_noderange_table +nodels_tablevalue +nodels_tablevalue_tablecolumn +nodels_noderange_tablecolumn +nodels_h +nodels_v +xcatstanzafile_normal +xcatstanzafile_colon +xcatstanzafile_attribute +xcatstanzafile_objtype +xcatstanzafile_tab +xcatstanzafile_multattr +xcatstanzafile_defaultvalue +xcatstanzafile_specificvalue +noderm_noderange +noderm_h +noderm_null +noderm_err_node +nodeset_stat +nodeset_noderange +nodestat_err_node +rinv_bus +rinv_config +rinv_serial +rinv_model +rinv_firm +rinv_all +rinv_noderange_err +rmdef_null +rmdef_t_err +rpower_off +rpower_stat +rpower_boot +rpower_on +rpower_reset +rpower_noderange +rpower_noderange_nodeps +rpower_err_noderange +rscan_noderange +rscan_x +rscan_z +rscan_w +rscan_x_w +rscan_z_w +rvitals_lcds +rvitals_all +rvitals_noderange_err +tabdump_table +tabdump_d +tabdump_v +tabdump_h +tabdump_help +tabdump_w_match +tabdump_w_equal +tabdump_w_ne +tabdump_w_notmatch +tabdump_w_gt +tabdump_w_ge +tabdump_w_lt +tabdump_w_le +tabdump_f_d +tabdump_d_nodehm +tabprune_h +tabprune_v +tabprune_a_eventlog +tabprune_V_a_eventlog +tabprune_p_auditlog +tabprune_i_auditlog +tabprune_V_n_auditlog +tabgrep_node +tabgrep_null +tabgrep_h +tabgrep_err +tabrestore_table +tabrestore_null +tabrestore_h +tabrestore_err +dumpxCATdb_h +dumpxCATdb_v +dumpxCATdb_p_nullskiptables +dumpxCATdb_a_p_nullskiptables +dumpxCATdb_p_skiptables +dumpxCATdb_a_p_skiptables +dumpxCATdb_p_nullskiptables_V +dumpxCATdb_a_p_nullskiptables_V +dumpxCATdb_p_V +restorexCAT_h +restorexCATdb_v +restorexCATdb_p_V +restorexCATdb_a_p_V +restorexCATdb_wrongpath +regnotif_null +regnotif_o +regnotif_err +regnotif_h +regnotif_v +unregnotif_null +unregnotif_f +unregnotif_h +unregnotif_v +lsxcatd_null +lsxcatd_h +lsxcatd_d +lsxcatd_a +makehosts_h +makehosts_help +makehosts_null +makehosts_l +makehosts_d +makehosts_n +makehosts_n_noderange +xdcp_src_dst +makedns_h +makedns_d_node +makedns_n +makedns +noderange_individual_node +noderange_individual_grp +noderange_node01-node10 +noderange_group1-group3 +noderange_10-20 +noderange_XCAT_NODE_PREFIX +noderange_XCAT_NODE_SUFFIX +noderange_exclusion +noderange_group_intersection +confignics_config_one_port_single_value +confignics_config_multiple_ports_single_value +confignics_config_multiple_ports_multiple_value +confignics_config_multiple_port_withnichostnamesuffixes_multiple_value +confignics_config_multiple_port_withnicaliases_multiple_value +confignics_disable_set_to_yes +confignics_disable_set_to_1 +confignics_s +xdsh_h +xdsh_V +xdsh_regular_command +xdsh_Q_command +xdsh_c_cn +xdsh_e_filename +xdsh_E +xdsh_t +xdsh_q +xdsh_T +xdsh_o +switchdiscover_range_default +switchdiscover_h +switchdiscover_range_s +switchdiscover_range_default_w +switchdiscover_range_r +switchdiscover_range_x +switchdiscover_range_z +switchdiscover_range_z_V +makentp_v +makentp_h +makentp_V +makentp +makentp_a +nodeset_check_warninginfo +runcmdinstaller_h +runcmdinstaller_command +get_xcat_postscripts_loginfo +updatenode_postscripts_loginfo +bmcdiscover_h +bmcdiscover_nmap_range +bmcdiscover_v +bmcdiscover_check_paswd +bmcdiscover_check_passwd_wrong +bmcdiscover_get_ipsource +bmcdiscover_range_w +bmcdiscover_range_z +xcatd_start +xcatd_stop +xcatd_restart +run_command_with_XCATBYPASS +disable_root_permission_in_policy_table +assign_certain_command_permission +reg_linux_diskless_installation_flat +reg_linux_statelite_installation_flat +SN_setup_case +reg_linux_diskfull_installation_hierarchy +reg_linux_diskless_installation_hierarchy +reg_linux_statelite_installation_hierarchy_by_ramdisk +reg_linux_statelite_installation_hierarchy_by_nfs +redhat_migration1 +redhat_migration2 +clean_up_env diff --git a/xCAT-test/autotest/bundle/rhels6.7_x86_64.bundle b/xCAT-test/autotest/bundle/rhels6.7_x86_64.bundle index 3fbc91c8b..01a401041 100644 --- a/xCAT-test/autotest/bundle/rhels6.7_x86_64.bundle +++ b/xCAT-test/autotest/bundle/rhels6.7_x86_64.bundle @@ -1,209 +1,208 @@ -reg_linux_diskfull_installation_flat -makehosts_h -makehosts_help -makehosts_n -makehosts_n_noderange -chdef_null -chdef_z -chdef_t_o_error -chtab_null -chtab_d -chtab_modify_node -chtab_modify_key -chtab_h -chtab_v -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_node -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -lslite_i -lslite_noderange -lslite_h -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a -makedhcp_a_d -makedhcp_d -mkdef_null -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_normal -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_tab -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_specificvalue -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_noderange -nodestat_err_node -rinv_noderange_err -rmdef_null -rmdef_t_err -rpower_err_noderange -rvitals_noderange_err -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -makedns_d_node -makedns_n -makedns -copycds_iso -copycds_n -copycds_a -copycds_n_a -xdsh_h -xdsh_V -xdsh_regular_command -xdsh_Q_command -xdsh_c_cn -xdsh_e_filename -xdsh_E -xdsh_i_linux -xdsh_t -xdsh_q -xdsh_T -xdsh_o -switchdiscover_range_default -switchdiscover_h -switchdiscover_range_s -switchdiscover_range_default_w -switchdiscover_range_r -switchdiscover_range_x -switchdiscover_range_z -switchdiscover_range_z_V -nodeset_check_warninginfo -reg_linux_diskless_installation_flat -reg_linux_statelite_installation_flat -SN_setup_case -reg_linux_diskfull_installation_hierarchy -reg_linux_diskless_installation_hierarchy -reg_linux_statelite_installation_hierarchy_by_ramdisk -reg_linux_statelite_installation_hierarchy_by_nfs -redhat_migration1 -redhat_migration2 -clean_up_env +reg_linux_diskfull_installation_flat +makehosts_h +makehosts_help +makehosts_n +makehosts_n_noderange +chdef_null +chdef_z +chdef_t_o_error +chtab_null +chtab_d +chtab_modify_node +chtab_modify_key +chtab_h +chtab_v +packimage_o_p_a_m +packimage_p_a_o +packimage_imagename +packimage_h +packimage_v +pping_h +pping_v +pping_node +gettab_key_table +gettab_H +gettab_err +gettab_h +lsdef_null +lsdef_a +lsdef_t_o_l +lsdef_t_o_l_z +lsdef_t +lsdef_t_i_o +lsdef_t_w +lsdef_t_err +lslite_i +lslite_noderange +lslite_h +makeconservercf_null +makeconservercf_noderange +makeconservercf_d +makedhcp_n +makedhcp_a +makedhcp_a_d +makedhcp_d +mkdef_null +mkdef_z +mkdef_t_o_error +nodeadd_noderange +nodeadd_err_symbol +nodeadd_null +nodeadd_noderange_nodetype +nodeadd_v +nodeadd_h +nodegrpch_v +nodegrpch_h +nodegrpch_groups +nodegrpch_err +nodech_noderange_table +nodech_noderange_table_comma +nodech_noderange_table_arrow +nodech_noderanage_table_at +nodech_delete +nodech_error_node +nodech_error_table +nodech_h +nodech_v +nodech_noderange_table_include +nodech_noderange_table_uninclude +nodech_noderange_table_equal +nodech_noderange_table_unequal +nodech_noderange_shortname_groups +nodech_noderange_shortname_tags +nodech_noderange_shortname_mgt +nodels_null +nodels_H +nodels_noderange +nodels_err_symbol +nodels_err_noderange +nodels_noderange_shortname_groups +nodels_noderange_shortname_tags +nodels_noderange_shortname_mgt +nodels_table_include +nodels_noderange_table_uninclude +nodels_noderange_table_equal +nodels_noderange_table_unequal +nodels_b +nodels_S +nodels_noderange_table +nodels_tablevalue +nodels_tablevalue_tablecolumn +nodels_noderange_tablecolumn +nodels_h +nodels_v +xcatstanzafile_normal +xcatstanzafile_colon +xcatstanzafile_attribute +xcatstanzafile_objtype +xcatstanzafile_tab +xcatstanzafile_multattr +xcatstanzafile_defaultvalue +xcatstanzafile_specificvalue +noderm_noderange +noderm_h +noderm_null +noderm_err_node +nodeset_stat +nodeset_noderange +nodestat_noderange +nodestat_err_node +rinv_noderange_err +rmdef_null +rmdef_t_err +rpower_err_noderange +rvitals_noderange_err +tabdump_table +tabdump_d +tabdump_v +tabdump_h +tabdump_help +tabdump_w_match +tabdump_w_equal +tabdump_w_ne +tabdump_w_notmatch +tabdump_w_gt +tabdump_w_ge +tabdump_w_lt +tabdump_w_le +tabdump_f_d +tabdump_d_nodehm +tabprune_h +tabprune_v +tabprune_a_eventlog +tabprune_V_a_eventlog +tabprune_i_auditlog +tabprune_V_n_auditlog +tabgrep_node +tabgrep_null +tabgrep_h +tabgrep_err +tabrestore_table +tabrestore_null +tabrestore_h +tabrestore_err +dumpxCATdb_h +dumpxCATdb_v +dumpxCATdb_p_nullskiptables +dumpxCATdb_a_p_nullskiptables +dumpxCATdb_p_skiptables +dumpxCATdb_a_p_skiptables +dumpxCATdb_p_nullskiptables_V +dumpxCATdb_a_p_nullskiptables_V +dumpxCATdb_p_V +restorexCAT_h +restorexCATdb_v +restorexCATdb_p_V +restorexCATdb_a_p_V +restorexCATdb_wrongpath +regnotif_null +regnotif_o +regnotif_err +regnotif_h +regnotif_v +unregnotif_null +unregnotif_f +unregnotif_h +unregnotif_v +lsxcatd_null +lsxcatd_h +lsxcatd_d +lsxcatd_a +makedns_d_node +makedns_n +makedns +copycds_iso +copycds_n +copycds_a +copycds_n_a +xdsh_h +xdsh_V +xdsh_regular_command +xdsh_Q_command +xdsh_c_cn +xdsh_e_filename +xdsh_E +xdsh_i_linux +xdsh_t +xdsh_q +xdsh_T +xdsh_o +switchdiscover_range_default +switchdiscover_h +switchdiscover_range_s +switchdiscover_range_default_w +switchdiscover_range_r +switchdiscover_range_x +switchdiscover_range_z +switchdiscover_range_z_V +nodeset_check_warninginfo +reg_linux_diskless_installation_flat +reg_linux_statelite_installation_flat +SN_setup_case +reg_linux_diskfull_installation_hierarchy +reg_linux_diskless_installation_hierarchy +reg_linux_statelite_installation_hierarchy_by_ramdisk +reg_linux_statelite_installation_hierarchy_by_nfs +redhat_migration1 +redhat_migration2 +clean_up_env diff --git a/xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle b/xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle index 9d4e27652..d75468017 100644 --- a/xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle +++ b/xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle @@ -1,304 +1,303 @@ -reg_linux_diskfull_installation_flat -updatenode_h -updatenode_v -updatenode_diskful_syncfiles -updatenode_diskful_syncfiles_rename -updatenode_diskful_syncfiles_dir -updatenode_diskful_syncfiles_multi_files -updatenode_syncfile_EXECUTE -updatenode_syncfile_EXECUTEALWAYS -updatenode_syncfile_APPEND -updatenode_syncfile_MERGE -updatenode_P_script1 -updatenode_P_script2 -updatenode_f_incompatible_flags -updatenode_k_incompatible_flags -updatenode_diskful_syncfiles_P_script1 -updatenode_script3 -updatenode_P_script1_script2 -updatenode_without_flag -chdef_null -chdef_t_node -chdef_t_network -chdef_p -chdef_m -chdef_z -chdef_group -chdef_group_p -chdef_dynamic_group -chdef_multiple_keys -chdef_n -chdef_t_o_error -chtab_null -chtab_d -chtab_modify_node -chtab_modify_key -chtab_h -chtab_v -copycds_iso -copycds_n -copycds_a -copycds_n_a -copycds_a_err -copycds_n_err -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_node -getmacs_noderange -getmacs_d -getmacs_f_D -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -lslite_i -lslite_noderange -lslite_h -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a -makedhcp_a_d -makedhcp_d -mkdef_null -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_normal -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_tab -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_specificvalue -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_err_node -rinv_bus -rinv_config -rinv_serial -rinv_model -rinv_firm -rinv_all -rinv_noderange_err -rmdef_null -rmdef_t_err -rpower_off -rpower_stat -rpower_boot -rpower_on -rpower_reset -rpower_noderange -rpower_noderange_nodeps -rpower_err_noderange -rscan_noderange -rscan_x -rscan_z -rscan_w -rscan_x_w -rscan_z_w -rvitals_lcds -rvitals_all -rvitals_noderange_err -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_p_auditlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -makehosts_h -makehosts_help -makehosts_null -makehosts_l -makehosts_d -makehosts_n -makehosts_n_noderange -xdcp_src_dst -makedns_h -makedns_d_node -makedns_n -makedns -noderange_individual_node -noderange_individual_grp -noderange_node01-node10 -noderange_group1-group3 -noderange_10-20 -noderange_XCAT_NODE_PREFIX -noderange_XCAT_NODE_SUFFIX -noderange_exclusion -noderange_group_intersection -confignics_config_one_port_single_value -confignics_config_multiple_ports_single_value -confignics_config_multiple_ports_multiple_value -confignics_config_multiple_port_withnichostnamesuffixes_multiple_value -confignics_config_multiple_port_withnicaliases_multiple_value -confignics_disable_set_to_yes -confignics_disable_set_to_1 -confignics_s -xdsh_h -xdsh_V -xdsh_regular_command -xdsh_Q_command -xdsh_c_cn -xdsh_e_filename -xdsh_E -xdsh_t -xdsh_q -xdsh_T -xdsh_o -switchdiscover_range_default -switchdiscover_h -switchdiscover_range_s -switchdiscover_range_default_w -switchdiscover_range_r -switchdiscover_range_x -switchdiscover_range_z -switchdiscover_range_z_V -makentp_v -makentp_h -makentp_V -makentp -makentp_a -nodeset_check_warninginfo -runcmdinstaller_h -runcmdinstaller_command -get_xcat_postscripts_loginfo -updatenode_postscripts_loginfo -bmcdiscover_h -bmcdiscover_nmap_range -bmcdiscover_v -bmcdiscover_check_paswd -bmcdiscover_check_passwd_wrong -bmcdiscover_get_ipsource -bmcdiscover_range_w -bmcdiscover_range_z -xcatd_start -xcatd_stop -xcatd_restart -run_command_with_XCATBYPASS -disable_root_permission_in_policy_table -assign_certain_command_permission -reg_linux_diskless_installation_flat -reg_linux_statelite_installation_flat -SN_setup_case -reg_linux_diskfull_installation_hierarchy -reg_linux_diskless_installation_hierarchy -reg_linux_statelite_installation_hierarchy_by_ramdisk -reg_linux_statelite_installation_hierarchy_by_nfs -clean_up_env +reg_linux_diskfull_installation_flat +updatenode_h +updatenode_v +updatenode_diskful_syncfiles +updatenode_diskful_syncfiles_rename +updatenode_diskful_syncfiles_dir +updatenode_diskful_syncfiles_multi_files +updatenode_syncfile_EXECUTE +updatenode_syncfile_EXECUTEALWAYS +updatenode_syncfile_APPEND +updatenode_syncfile_MERGE +updatenode_P_script1 +updatenode_P_script2 +updatenode_f_incompatible_flags +updatenode_k_incompatible_flags +updatenode_diskful_syncfiles_P_script1 +updatenode_script3 +updatenode_P_script1_script2 +updatenode_without_flag +chdef_null +chdef_t_node +chdef_t_network +chdef_p +chdef_m +chdef_z +chdef_group +chdef_group_p +chdef_dynamic_group +chdef_multiple_keys +chdef_n +chdef_t_o_error +chtab_null +chtab_d +chtab_modify_node +chtab_modify_key +chtab_h +chtab_v +copycds_iso +copycds_n +copycds_a +copycds_n_a +copycds_a_err +copycds_n_err +packimage_o_p_a_m +packimage_p_a_o +packimage_imagename +packimage_h +packimage_v +pping_h +pping_v +pping_node +getmacs_noderange +getmacs_d +getmacs_f_D +gettab_key_table +gettab_H +gettab_err +gettab_h +lsdef_null +lsdef_a +lsdef_t_o_l +lsdef_t_o_l_z +lsdef_t +lsdef_t_i_o +lsdef_t_w +lsdef_t_err +lslite_i +lslite_noderange +lslite_h +makeconservercf_null +makeconservercf_noderange +makeconservercf_d +makedhcp_n +makedhcp_a +makedhcp_a_d +makedhcp_d +mkdef_null +mkdef_z +mkdef_t_o_error +nodeadd_noderange +nodeadd_err_symbol +nodeadd_null +nodeadd_noderange_nodetype +nodeadd_v +nodeadd_h +nodegrpch_v +nodegrpch_h +nodegrpch_groups +nodegrpch_err +nodech_noderange_table +nodech_noderange_table_comma +nodech_noderange_table_arrow +nodech_noderanage_table_at +nodech_delete +nodech_error_node +nodech_error_table +nodech_h +nodech_v +nodech_noderange_table_include +nodech_noderange_table_uninclude +nodech_noderange_table_equal +nodech_noderange_table_unequal +nodech_noderange_shortname_groups +nodech_noderange_shortname_tags +nodech_noderange_shortname_mgt +nodels_null +nodels_H +nodels_noderange +nodels_err_symbol +nodels_err_noderange +nodels_noderange_shortname_groups +nodels_noderange_shortname_tags +nodels_noderange_shortname_mgt +nodels_table_include +nodels_noderange_table_uninclude +nodels_noderange_table_equal +nodels_noderange_table_unequal +nodels_b +nodels_S +nodels_noderange_table +nodels_tablevalue +nodels_tablevalue_tablecolumn +nodels_noderange_tablecolumn +nodels_h +nodels_v +xcatstanzafile_normal +xcatstanzafile_colon +xcatstanzafile_attribute +xcatstanzafile_objtype +xcatstanzafile_tab +xcatstanzafile_multattr +xcatstanzafile_defaultvalue +xcatstanzafile_specificvalue +noderm_noderange +noderm_h +noderm_null +noderm_err_node +nodeset_stat +nodeset_noderange +nodestat_err_node +rinv_bus +rinv_config +rinv_serial +rinv_model +rinv_firm +rinv_all +rinv_noderange_err +rmdef_null +rmdef_t_err +rpower_off +rpower_stat +rpower_boot +rpower_on +rpower_reset +rpower_noderange +rpower_noderange_nodeps +rpower_err_noderange +rscan_noderange +rscan_x +rscan_z +rscan_w +rscan_x_w +rscan_z_w +rvitals_lcds +rvitals_all +rvitals_noderange_err +tabdump_table +tabdump_d +tabdump_v +tabdump_h +tabdump_help +tabdump_w_match +tabdump_w_equal +tabdump_w_ne +tabdump_w_notmatch +tabdump_w_gt +tabdump_w_ge +tabdump_w_lt +tabdump_w_le +tabdump_f_d +tabdump_d_nodehm +tabprune_h +tabprune_v +tabprune_a_eventlog +tabprune_V_a_eventlog +tabprune_p_auditlog +tabprune_i_auditlog +tabprune_V_n_auditlog +tabgrep_node +tabgrep_null +tabgrep_h +tabgrep_err +tabrestore_table +tabrestore_null +tabrestore_h +tabrestore_err +dumpxCATdb_h +dumpxCATdb_v +dumpxCATdb_p_nullskiptables +dumpxCATdb_a_p_nullskiptables +dumpxCATdb_p_skiptables +dumpxCATdb_a_p_skiptables +dumpxCATdb_p_nullskiptables_V +dumpxCATdb_a_p_nullskiptables_V +dumpxCATdb_p_V +restorexCAT_h +restorexCATdb_v +restorexCATdb_p_V +restorexCATdb_a_p_V +restorexCATdb_wrongpath +regnotif_null +regnotif_o +regnotif_err +regnotif_h +regnotif_v +unregnotif_null +unregnotif_f +unregnotif_h +unregnotif_v +lsxcatd_null +lsxcatd_h +lsxcatd_d +lsxcatd_a +makehosts_h +makehosts_help +makehosts_null +makehosts_l +makehosts_d +makehosts_n +makehosts_n_noderange +xdcp_src_dst +makedns_h +makedns_d_node +makedns_n +makedns +noderange_individual_node +noderange_individual_grp +noderange_node01-node10 +noderange_group1-group3 +noderange_10-20 +noderange_XCAT_NODE_PREFIX +noderange_XCAT_NODE_SUFFIX +noderange_exclusion +noderange_group_intersection +confignics_config_one_port_single_value +confignics_config_multiple_ports_single_value +confignics_config_multiple_ports_multiple_value +confignics_config_multiple_port_withnichostnamesuffixes_multiple_value +confignics_config_multiple_port_withnicaliases_multiple_value +confignics_disable_set_to_yes +confignics_disable_set_to_1 +confignics_s +xdsh_h +xdsh_V +xdsh_regular_command +xdsh_Q_command +xdsh_c_cn +xdsh_e_filename +xdsh_E +xdsh_t +xdsh_q +xdsh_T +xdsh_o +switchdiscover_range_default +switchdiscover_h +switchdiscover_range_s +switchdiscover_range_default_w +switchdiscover_range_r +switchdiscover_range_x +switchdiscover_range_z +switchdiscover_range_z_V +makentp_v +makentp_h +makentp_V +makentp +makentp_a +nodeset_check_warninginfo +runcmdinstaller_h +runcmdinstaller_command +get_xcat_postscripts_loginfo +updatenode_postscripts_loginfo +bmcdiscover_h +bmcdiscover_nmap_range +bmcdiscover_v +bmcdiscover_check_paswd +bmcdiscover_check_passwd_wrong +bmcdiscover_get_ipsource +bmcdiscover_range_w +bmcdiscover_range_z +xcatd_start +xcatd_stop +xcatd_restart +run_command_with_XCATBYPASS +disable_root_permission_in_policy_table +assign_certain_command_permission +reg_linux_diskless_installation_flat +reg_linux_statelite_installation_flat +SN_setup_case +reg_linux_diskfull_installation_hierarchy +reg_linux_diskless_installation_hierarchy +reg_linux_statelite_installation_hierarchy_by_ramdisk +reg_linux_statelite_installation_hierarchy_by_nfs +clean_up_env diff --git a/xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle b/xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle index 61895f193..3e6821598 100644 --- a/xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle +++ b/xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle @@ -1,210 +1,209 @@ -reg_linux_diskfull_installation_flat -makehosts_h -makehosts_help -makehosts_n -makehosts_n_noderange -chdef_null -chdef_z -chdef_t_o_error -chtab_null -chtab_d -chtab_modify_node -chtab_modify_key -chtab_h -chtab_v -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_node -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -lslite_i -lslite_noderange -lslite_h -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a -makedhcp_a_d -makedhcp_d -mkdef_null -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_normal -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_tab -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_specificvalue -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_noderange -nodestat_err_node -rinv_noderange_err -rmdef_null -rmdef_t_err -rpower_err_noderange -rvitals_noderange_err -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -makedns_d_node -makedns_n -makedns -copycds_iso -copycds_n -copycds_a -copycds_n_a -xdsh_h -xdsh_V -xdsh_regular_command -xdsh_Q_command -xdsh_c_cn -xdsh_e_filename -xdsh_E -xdsh_i_linux -xdsh_t -xdsh_q -xdsh_T -xdsh_o -switchdiscover_range_default -switchdiscover_h -switchdiscover_range_s -switchdiscover_range_default_w -switchdiscover_range_r -switchdiscover_range_x -switchdiscover_range_z -switchdiscover_range_z_V -nodeset_shell -nodeset_cmdline -nodeset_runimg -nodeset_check_warninginfo -reg_linux_diskless_installation_flat -reg_linux_statelite_installation_flat -SN_setup_case -reg_linux_diskfull_installation_hierarchy -reg_linux_diskless_installation_hierarchy -reg_linux_statelite_installation_hierarchy_by_ramdisk -reg_linux_statelite_installation_hierarchy_by_nfs -clean_up_env +reg_linux_diskfull_installation_flat +makehosts_h +makehosts_help +makehosts_n +makehosts_n_noderange +chdef_null +chdef_z +chdef_t_o_error +chtab_null +chtab_d +chtab_modify_node +chtab_modify_key +chtab_h +chtab_v +packimage_o_p_a_m +packimage_p_a_o +packimage_imagename +packimage_h +packimage_v +pping_h +pping_v +pping_node +gettab_key_table +gettab_H +gettab_err +gettab_h +lsdef_null +lsdef_a +lsdef_t_o_l +lsdef_t_o_l_z +lsdef_t +lsdef_t_i_o +lsdef_t_w +lsdef_t_err +lslite_i +lslite_noderange +lslite_h +makeconservercf_null +makeconservercf_noderange +makeconservercf_d +makedhcp_n +makedhcp_a +makedhcp_a_d +makedhcp_d +mkdef_null +mkdef_z +mkdef_t_o_error +nodeadd_noderange +nodeadd_err_symbol +nodeadd_null +nodeadd_noderange_nodetype +nodeadd_v +nodeadd_h +nodegrpch_v +nodegrpch_h +nodegrpch_groups +nodegrpch_err +nodech_noderange_table +nodech_noderange_table_comma +nodech_noderange_table_arrow +nodech_noderanage_table_at +nodech_delete +nodech_error_node +nodech_error_table +nodech_h +nodech_v +nodech_noderange_table_include +nodech_noderange_table_uninclude +nodech_noderange_table_equal +nodech_noderange_table_unequal +nodech_noderange_shortname_groups +nodech_noderange_shortname_tags +nodech_noderange_shortname_mgt +nodels_null +nodels_H +nodels_noderange +nodels_err_symbol +nodels_err_noderange +nodels_noderange_shortname_groups +nodels_noderange_shortname_tags +nodels_noderange_shortname_mgt +nodels_table_include +nodels_noderange_table_uninclude +nodels_noderange_table_equal +nodels_noderange_table_unequal +nodels_b +nodels_S +nodels_noderange_table +nodels_tablevalue +nodels_tablevalue_tablecolumn +nodels_noderange_tablecolumn +nodels_h +nodels_v +xcatstanzafile_normal +xcatstanzafile_colon +xcatstanzafile_attribute +xcatstanzafile_objtype +xcatstanzafile_tab +xcatstanzafile_multattr +xcatstanzafile_defaultvalue +xcatstanzafile_specificvalue +noderm_noderange +noderm_h +noderm_null +noderm_err_node +nodeset_stat +nodeset_noderange +nodestat_noderange +nodestat_err_node +rinv_noderange_err +rmdef_null +rmdef_t_err +rpower_err_noderange +rvitals_noderange_err +tabdump_table +tabdump_d +tabdump_v +tabdump_h +tabdump_help +tabdump_w_match +tabdump_w_equal +tabdump_w_ne +tabdump_w_notmatch +tabdump_w_gt +tabdump_w_ge +tabdump_w_lt +tabdump_w_le +tabdump_f_d +tabdump_d_nodehm +tabprune_h +tabprune_v +tabprune_a_eventlog +tabprune_V_a_eventlog +tabprune_i_auditlog +tabprune_V_n_auditlog +tabgrep_node +tabgrep_null +tabgrep_h +tabgrep_err +tabrestore_table +tabrestore_null +tabrestore_h +tabrestore_err +dumpxCATdb_h +dumpxCATdb_v +dumpxCATdb_p_nullskiptables +dumpxCATdb_a_p_nullskiptables +dumpxCATdb_p_skiptables +dumpxCATdb_a_p_skiptables +dumpxCATdb_p_nullskiptables_V +dumpxCATdb_a_p_nullskiptables_V +dumpxCATdb_p_V +restorexCAT_h +restorexCATdb_v +restorexCATdb_p_V +restorexCATdb_a_p_V +restorexCATdb_wrongpath +regnotif_null +regnotif_o +regnotif_err +regnotif_h +regnotif_v +unregnotif_null +unregnotif_f +unregnotif_h +unregnotif_v +lsxcatd_null +lsxcatd_h +lsxcatd_d +lsxcatd_a +makedns_d_node +makedns_n +makedns +copycds_iso +copycds_n +copycds_a +copycds_n_a +xdsh_h +xdsh_V +xdsh_regular_command +xdsh_Q_command +xdsh_c_cn +xdsh_e_filename +xdsh_E +xdsh_i_linux +xdsh_t +xdsh_q +xdsh_T +xdsh_o +switchdiscover_range_default +switchdiscover_h +switchdiscover_range_s +switchdiscover_range_default_w +switchdiscover_range_r +switchdiscover_range_x +switchdiscover_range_z +switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg +nodeset_check_warninginfo +reg_linux_diskless_installation_flat +reg_linux_statelite_installation_flat +SN_setup_case +reg_linux_diskfull_installation_hierarchy +reg_linux_diskless_installation_hierarchy +reg_linux_statelite_installation_hierarchy_by_ramdisk +reg_linux_statelite_installation_hierarchy_by_nfs +clean_up_env diff --git a/xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle b/xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle index 7c2237687..ee6a786f9 100644 --- a/xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle +++ b/xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle @@ -1,306 +1,305 @@ -reg_linux_diskfull_installation_flat -updatenode_h -updatenode_v -updatenode_diskful_syncfiles -updatenode_diskful_syncfiles_rename -updatenode_diskful_syncfiles_dir -updatenode_diskful_syncfiles_multi_files -updatenode_syncfile_EXECUTE -updatenode_syncfile_EXECUTEALWAYS -updatenode_syncfile_APPEND -updatenode_syncfile_MERGE -updatenode_P_script1 -updatenode_P_script2 -updatenode_f_incompatible_flags -updatenode_k_incompatible_flags -updatenode_diskful_syncfiles_P_script1 -updatenode_script3 -updatenode_P_script1_script2 -updatenode_without_flag -chdef_null -chdef_t_node -chdef_t_network -chdef_p -chdef_m -chdef_z -chdef_group -chdef_group_p -chdef_dynamic_group -chdef_multiple_keys -chdef_n -chdef_t_o_error -chtab_null -chtab_d -chtab_modify_node -chtab_modify_key -chtab_h -chtab_v -copycds_iso -copycds_n -copycds_a -copycds_n_a -copycds_a_err -copycds_n_err -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_node -getmacs_noderange -getmacs_d -getmacs_f_D -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -lslite_i -lslite_noderange -lslite_h -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a -makedhcp_a_d -makedhcp_d -mkdef_null -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_normal -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_tab -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_specificvalue -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_err_node -rinv_bus -rinv_config -rinv_serial -rinv_model -rinv_firm -rinv_all -rinv_noderange_err -rmdef_null -rmdef_t_err -rpower_off -rpower_stat -rpower_boot -rpower_on -rpower_reset -rpower_noderange -rpower_noderange_nodeps -rpower_err_noderange -rscan_noderange -rscan_x -rscan_z -rscan_w -rscan_x_w -rscan_z_w -rvitals_lcds -rvitals_all -rvitals_noderange_err -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_p_auditlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -makehosts_h -makehosts_help -makehosts_null -makehosts_l -makehosts_d -makehosts_n -makehosts_n_noderange -xdcp_src_dst -makedns_h -makedns_d_node -makedns_n -makedns -noderange_individual_node -noderange_individual_grp -noderange_node01-node10 -noderange_group1-group3 -noderange_10-20 -noderange_XCAT_NODE_PREFIX -noderange_XCAT_NODE_SUFFIX -noderange_exclusion -noderange_group_intersection -confignics_config_one_port_single_value -confignics_config_multiple_ports_single_value -confignics_config_multiple_ports_multiple_value -confignics_config_multiple_port_withnichostnamesuffixes_multiple_value -confignics_config_multiple_port_withnicaliases_multiple_value -confignics_disable_set_to_yes -confignics_disable_set_to_1 -confignics_s -xdsh_h -xdsh_V -xdsh_regular_command -xdsh_Q_command -xdsh_c_cn -xdsh_e_filename -xdsh_E -xdsh_t -xdsh_q -xdsh_T -xdsh_o -switchdiscover_range_default -switchdiscover_h -switchdiscover_range_s -switchdiscover_range_default_w -switchdiscover_range_r -switchdiscover_range_x -switchdiscover_range_z -switchdiscover_range_z_V -makentp_v -makentp_h -makentp_V -makentp -makentp_a -nodeset_check_warninginfo -runcmdinstaller_h -runcmdinstaller_command -get_xcat_postscripts_loginfo -updatenode_postscripts_loginfo -bmcdiscover_h -bmcdiscover_nmap_range -bmcdiscover_v -bmcdiscover_check_paswd -bmcdiscover_check_passwd_wrong -bmcdiscover_get_ipsource -bmcdiscover_range_w -bmcdiscover_range_z -xcatd_start -xcatd_stop -xcatd_restart -run_command_with_XCATBYPASS -disable_root_permission_in_policy_table -assign_certain_command_permission -reg_linux_diskless_installation_flat -reg_linux_statelite_installation_flat -SN_setup_case -reg_linux_diskfull_installation_hierarchy -reg_linux_diskless_installation_hierarchy -reg_linux_statelite_installation_hierarchy_by_ramdisk -reg_linux_statelite_installation_hierarchy_by_nfs -redhat_migration1 -redhat_migration2 -clean_up_env +reg_linux_diskfull_installation_flat +updatenode_h +updatenode_v +updatenode_diskful_syncfiles +updatenode_diskful_syncfiles_rename +updatenode_diskful_syncfiles_dir +updatenode_diskful_syncfiles_multi_files +updatenode_syncfile_EXECUTE +updatenode_syncfile_EXECUTEALWAYS +updatenode_syncfile_APPEND +updatenode_syncfile_MERGE +updatenode_P_script1 +updatenode_P_script2 +updatenode_f_incompatible_flags +updatenode_k_incompatible_flags +updatenode_diskful_syncfiles_P_script1 +updatenode_script3 +updatenode_P_script1_script2 +updatenode_without_flag +chdef_null +chdef_t_node +chdef_t_network +chdef_p +chdef_m +chdef_z +chdef_group +chdef_group_p +chdef_dynamic_group +chdef_multiple_keys +chdef_n +chdef_t_o_error +chtab_null +chtab_d +chtab_modify_node +chtab_modify_key +chtab_h +chtab_v +copycds_iso +copycds_n +copycds_a +copycds_n_a +copycds_a_err +copycds_n_err +packimage_o_p_a_m +packimage_p_a_o +packimage_imagename +packimage_h +packimage_v +pping_h +pping_v +pping_node +getmacs_noderange +getmacs_d +getmacs_f_D +gettab_key_table +gettab_H +gettab_err +gettab_h +lsdef_null +lsdef_a +lsdef_t_o_l +lsdef_t_o_l_z +lsdef_t +lsdef_t_i_o +lsdef_t_w +lsdef_t_err +lslite_i +lslite_noderange +lslite_h +makeconservercf_null +makeconservercf_noderange +makeconservercf_d +makedhcp_n +makedhcp_a +makedhcp_a_d +makedhcp_d +mkdef_null +mkdef_z +mkdef_t_o_error +nodeadd_noderange +nodeadd_err_symbol +nodeadd_null +nodeadd_noderange_nodetype +nodeadd_v +nodeadd_h +nodegrpch_v +nodegrpch_h +nodegrpch_groups +nodegrpch_err +nodech_noderange_table +nodech_noderange_table_comma +nodech_noderange_table_arrow +nodech_noderanage_table_at +nodech_delete +nodech_error_node +nodech_error_table +nodech_h +nodech_v +nodech_noderange_table_include +nodech_noderange_table_uninclude +nodech_noderange_table_equal +nodech_noderange_table_unequal +nodech_noderange_shortname_groups +nodech_noderange_shortname_tags +nodech_noderange_shortname_mgt +nodels_null +nodels_H +nodels_noderange +nodels_err_symbol +nodels_err_noderange +nodels_noderange_shortname_groups +nodels_noderange_shortname_tags +nodels_noderange_shortname_mgt +nodels_table_include +nodels_noderange_table_uninclude +nodels_noderange_table_equal +nodels_noderange_table_unequal +nodels_b +nodels_S +nodels_noderange_table +nodels_tablevalue +nodels_tablevalue_tablecolumn +nodels_noderange_tablecolumn +nodels_h +nodels_v +xcatstanzafile_normal +xcatstanzafile_colon +xcatstanzafile_attribute +xcatstanzafile_objtype +xcatstanzafile_tab +xcatstanzafile_multattr +xcatstanzafile_defaultvalue +xcatstanzafile_specificvalue +noderm_noderange +noderm_h +noderm_null +noderm_err_node +nodeset_stat +nodeset_noderange +nodestat_err_node +rinv_bus +rinv_config +rinv_serial +rinv_model +rinv_firm +rinv_all +rinv_noderange_err +rmdef_null +rmdef_t_err +rpower_off +rpower_stat +rpower_boot +rpower_on +rpower_reset +rpower_noderange +rpower_noderange_nodeps +rpower_err_noderange +rscan_noderange +rscan_x +rscan_z +rscan_w +rscan_x_w +rscan_z_w +rvitals_lcds +rvitals_all +rvitals_noderange_err +tabdump_table +tabdump_d +tabdump_v +tabdump_h +tabdump_help +tabdump_w_match +tabdump_w_equal +tabdump_w_ne +tabdump_w_notmatch +tabdump_w_gt +tabdump_w_ge +tabdump_w_lt +tabdump_w_le +tabdump_f_d +tabdump_d_nodehm +tabprune_h +tabprune_v +tabprune_a_eventlog +tabprune_V_a_eventlog +tabprune_p_auditlog +tabprune_i_auditlog +tabprune_V_n_auditlog +tabgrep_node +tabgrep_null +tabgrep_h +tabgrep_err +tabrestore_table +tabrestore_null +tabrestore_h +tabrestore_err +dumpxCATdb_h +dumpxCATdb_v +dumpxCATdb_p_nullskiptables +dumpxCATdb_a_p_nullskiptables +dumpxCATdb_p_skiptables +dumpxCATdb_a_p_skiptables +dumpxCATdb_p_nullskiptables_V +dumpxCATdb_a_p_nullskiptables_V +dumpxCATdb_p_V +restorexCAT_h +restorexCATdb_v +restorexCATdb_p_V +restorexCATdb_a_p_V +restorexCATdb_wrongpath +regnotif_null +regnotif_o +regnotif_err +regnotif_h +regnotif_v +unregnotif_null +unregnotif_f +unregnotif_h +unregnotif_v +lsxcatd_null +lsxcatd_h +lsxcatd_d +lsxcatd_a +makehosts_h +makehosts_help +makehosts_null +makehosts_l +makehosts_d +makehosts_n +makehosts_n_noderange +xdcp_src_dst +makedns_h +makedns_d_node +makedns_n +makedns +noderange_individual_node +noderange_individual_grp +noderange_node01-node10 +noderange_group1-group3 +noderange_10-20 +noderange_XCAT_NODE_PREFIX +noderange_XCAT_NODE_SUFFIX +noderange_exclusion +noderange_group_intersection +confignics_config_one_port_single_value +confignics_config_multiple_ports_single_value +confignics_config_multiple_ports_multiple_value +confignics_config_multiple_port_withnichostnamesuffixes_multiple_value +confignics_config_multiple_port_withnicaliases_multiple_value +confignics_disable_set_to_yes +confignics_disable_set_to_1 +confignics_s +xdsh_h +xdsh_V +xdsh_regular_command +xdsh_Q_command +xdsh_c_cn +xdsh_e_filename +xdsh_E +xdsh_t +xdsh_q +xdsh_T +xdsh_o +switchdiscover_range_default +switchdiscover_h +switchdiscover_range_s +switchdiscover_range_default_w +switchdiscover_range_r +switchdiscover_range_x +switchdiscover_range_z +switchdiscover_range_z_V +makentp_v +makentp_h +makentp_V +makentp +makentp_a +nodeset_check_warninginfo +runcmdinstaller_h +runcmdinstaller_command +get_xcat_postscripts_loginfo +updatenode_postscripts_loginfo +bmcdiscover_h +bmcdiscover_nmap_range +bmcdiscover_v +bmcdiscover_check_paswd +bmcdiscover_check_passwd_wrong +bmcdiscover_get_ipsource +bmcdiscover_range_w +bmcdiscover_range_z +xcatd_start +xcatd_stop +xcatd_restart +run_command_with_XCATBYPASS +disable_root_permission_in_policy_table +assign_certain_command_permission +reg_linux_diskless_installation_flat +reg_linux_statelite_installation_flat +SN_setup_case +reg_linux_diskfull_installation_hierarchy +reg_linux_diskless_installation_hierarchy +reg_linux_statelite_installation_hierarchy_by_ramdisk +reg_linux_statelite_installation_hierarchy_by_nfs +redhat_migration1 +redhat_migration2 +clean_up_env diff --git a/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle b/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle index 3eb078815..2b2bb560c 100644 --- a/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle @@ -1,200 +1,199 @@ -Diskless_installation_flat_p8_le -Full_installation_flat_p8_le -makehosts_h -makehosts_help -makehosts_n -makehosts_n_noderange -chdef_null -chdef_z -chdef_t_o_error -chtab_null -chtab_d -chtab_modify_node -chtab_modify_key -chtab_h -chtab_v -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_node -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a -makedhcp_a_d -makedhcp_d -mkdef_null -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_tab -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_specificvalue -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_err_node -rinv_noderange_err -rmdef_null -rmdef_t_err -rpower_err_noderange -rvitals_noderange_err -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -makedns_d_node -makedns_n -makedns -copycds_iso -copycds_n -copycds_a -copycds_n_a -xdsh_h -xdsh_V -xdsh_regular_command -xdsh_Q_command -xdsh_c_cn -xdsh_e_filename -xdsh_E -xdsh_i_linux -xdsh_t -xdsh_q -xdsh_T -xdsh_o -switchdiscover_range_default -switchdiscover_h -switchdiscover_range_s -switchdiscover_range_default_w -switchdiscover_range_r -switchdiscover_range_x -switchdiscover_range_z -switchdiscover_range_z_V -nodeset_shell -nodeset_cmdline -nodeset_runimg -redhat_migration1 -redhat_migration2 -clean_up_env +Diskless_installation_flat_p8_le +Full_installation_flat_p8_le +makehosts_h +makehosts_help +makehosts_n +makehosts_n_noderange +chdef_null +chdef_z +chdef_t_o_error +chtab_null +chtab_d +chtab_modify_node +chtab_modify_key +chtab_h +chtab_v +packimage_o_p_a_m +packimage_p_a_o +packimage_imagename +packimage_h +packimage_v +pping_h +pping_v +pping_node +gettab_key_table +gettab_H +gettab_err +gettab_h +lsdef_null +lsdef_a +lsdef_t_o_l +lsdef_t_o_l_z +lsdef_t +lsdef_t_i_o +lsdef_t_w +lsdef_t_err +makeconservercf_null +makeconservercf_noderange +makeconservercf_d +makedhcp_n +makedhcp_a +makedhcp_a_d +makedhcp_d +mkdef_null +mkdef_z +mkdef_t_o_error +nodeadd_noderange +nodeadd_err_symbol +nodeadd_null +nodeadd_noderange_nodetype +nodeadd_v +nodeadd_h +nodegrpch_v +nodegrpch_h +nodegrpch_groups +nodegrpch_err +nodech_noderange_table +nodech_noderange_table_comma +nodech_noderange_table_arrow +nodech_noderanage_table_at +nodech_delete +nodech_error_node +nodech_error_table +nodech_h +nodech_v +nodech_noderange_table_include +nodech_noderange_table_uninclude +nodech_noderange_table_equal +nodech_noderange_table_unequal +nodech_noderange_shortname_groups +nodech_noderange_shortname_tags +nodech_noderange_shortname_mgt +nodels_null +nodels_H +nodels_noderange +nodels_err_symbol +nodels_err_noderange +nodels_noderange_shortname_groups +nodels_noderange_shortname_tags +nodels_noderange_shortname_mgt +nodels_table_include +nodels_noderange_table_uninclude +nodels_noderange_table_equal +nodels_noderange_table_unequal +nodels_b +nodels_S +nodels_noderange_table +nodels_tablevalue +nodels_tablevalue_tablecolumn +nodels_noderange_tablecolumn +nodels_h +nodels_v +xcatstanzafile_colon +xcatstanzafile_attribute +xcatstanzafile_objtype +xcatstanzafile_tab +xcatstanzafile_multattr +xcatstanzafile_defaultvalue +xcatstanzafile_specificvalue +noderm_noderange +noderm_h +noderm_null +noderm_err_node +nodeset_stat +nodeset_noderange +nodestat_err_node +rinv_noderange_err +rmdef_null +rmdef_t_err +rpower_err_noderange +rvitals_noderange_err +tabdump_table +tabdump_d +tabdump_v +tabdump_h +tabdump_help +tabdump_w_match +tabdump_w_equal +tabdump_w_ne +tabdump_w_notmatch +tabdump_w_gt +tabdump_w_ge +tabdump_w_lt +tabdump_w_le +tabdump_f_d +tabdump_d_nodehm +tabprune_h +tabprune_v +tabprune_a_eventlog +tabprune_V_a_eventlog +tabprune_i_auditlog +tabprune_V_n_auditlog +tabgrep_node +tabgrep_null +tabgrep_h +tabgrep_err +tabrestore_table +tabrestore_null +tabrestore_h +tabrestore_err +dumpxCATdb_h +dumpxCATdb_v +dumpxCATdb_p_nullskiptables +dumpxCATdb_a_p_nullskiptables +dumpxCATdb_p_skiptables +dumpxCATdb_a_p_skiptables +dumpxCATdb_p_nullskiptables_V +dumpxCATdb_a_p_nullskiptables_V +dumpxCATdb_p_V +restorexCAT_h +restorexCATdb_v +restorexCATdb_p_V +restorexCATdb_a_p_V +restorexCATdb_wrongpath +regnotif_null +regnotif_o +regnotif_err +regnotif_h +regnotif_v +unregnotif_null +unregnotif_f +unregnotif_h +unregnotif_v +lsxcatd_null +lsxcatd_h +lsxcatd_d +lsxcatd_a +makedns_d_node +makedns_n +makedns +copycds_iso +copycds_n +copycds_a +copycds_n_a +xdsh_h +xdsh_V +xdsh_regular_command +xdsh_Q_command +xdsh_c_cn +xdsh_e_filename +xdsh_E +xdsh_i_linux +xdsh_t +xdsh_q +xdsh_T +xdsh_o +switchdiscover_range_default +switchdiscover_h +switchdiscover_range_s +switchdiscover_range_default_w +switchdiscover_range_r +switchdiscover_range_x +switchdiscover_range_z +switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg +redhat_migration1 +redhat_migration2 +clean_up_env diff --git a/xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle b/xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle index 88c8dec6c..0025be4bd 100644 --- a/xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle +++ b/xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle @@ -1,212 +1,211 @@ -reg_linux_diskfull_installation_flat -makehosts_h -makehosts_help -makehosts_n -makehosts_n_noderange -chdef_null -chdef_z -chdef_t_o_error -chtab_null -chtab_d -chtab_modify_node -chtab_modify_key -chtab_h -chtab_v -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_node -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -lslite_i -lslite_noderange -lslite_h -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a -makedhcp_a_d -makedhcp_d -mkdef_null -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_normal -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_tab -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_specificvalue -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_noderange -nodestat_err_node -rinv_noderange_err -rmdef_null -rmdef_t_err -rpower_err_noderange -rvitals_noderange_err -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -makedns_d_node -makedns_n -makedns -copycds_iso -copycds_n -copycds_a -copycds_n_a -xdsh_h -xdsh_V -xdsh_regular_command -xdsh_Q_command -xdsh_c_cn -xdsh_e_filename -xdsh_E -xdsh_i_linux -xdsh_t -xdsh_q -xdsh_T -xdsh_o -switchdiscover_range_default -switchdiscover_h -switchdiscover_range_s -switchdiscover_range_default_w -switchdiscover_range_r -switchdiscover_range_x -switchdiscover_range_z -switchdiscover_range_z_V -nodeset_check_warninginfo -nodeset_shell -nodeset_cmdline -nodeset_runimg -reg_linux_diskless_installation_flat -reg_linux_statelite_installation_flat -SN_setup_case -reg_linux_diskfull_installation_hierarchy -reg_linux_diskless_installation_hierarchy -reg_linux_statelite_installation_hierarchy_by_ramdisk -reg_linux_statelite_installation_hierarchy_by_nfs -redhat_migration1 -redhat_migration2 -clean_up_env +reg_linux_diskfull_installation_flat +makehosts_h +makehosts_help +makehosts_n +makehosts_n_noderange +chdef_null +chdef_z +chdef_t_o_error +chtab_null +chtab_d +chtab_modify_node +chtab_modify_key +chtab_h +chtab_v +packimage_o_p_a_m +packimage_p_a_o +packimage_imagename +packimage_h +packimage_v +pping_h +pping_v +pping_node +gettab_key_table +gettab_H +gettab_err +gettab_h +lsdef_null +lsdef_a +lsdef_t_o_l +lsdef_t_o_l_z +lsdef_t +lsdef_t_i_o +lsdef_t_w +lsdef_t_err +lslite_i +lslite_noderange +lslite_h +makeconservercf_null +makeconservercf_noderange +makeconservercf_d +makedhcp_n +makedhcp_a +makedhcp_a_d +makedhcp_d +mkdef_null +mkdef_z +mkdef_t_o_error +nodeadd_noderange +nodeadd_err_symbol +nodeadd_null +nodeadd_noderange_nodetype +nodeadd_v +nodeadd_h +nodegrpch_v +nodegrpch_h +nodegrpch_groups +nodegrpch_err +nodech_noderange_table +nodech_noderange_table_comma +nodech_noderange_table_arrow +nodech_noderanage_table_at +nodech_delete +nodech_error_node +nodech_error_table +nodech_h +nodech_v +nodech_noderange_table_include +nodech_noderange_table_uninclude +nodech_noderange_table_equal +nodech_noderange_table_unequal +nodech_noderange_shortname_groups +nodech_noderange_shortname_tags +nodech_noderange_shortname_mgt +nodels_null +nodels_H +nodels_noderange +nodels_err_symbol +nodels_err_noderange +nodels_noderange_shortname_groups +nodels_noderange_shortname_tags +nodels_noderange_shortname_mgt +nodels_table_include +nodels_noderange_table_uninclude +nodels_noderange_table_equal +nodels_noderange_table_unequal +nodels_b +nodels_S +nodels_noderange_table +nodels_tablevalue +nodels_tablevalue_tablecolumn +nodels_noderange_tablecolumn +nodels_h +nodels_v +xcatstanzafile_normal +xcatstanzafile_colon +xcatstanzafile_attribute +xcatstanzafile_objtype +xcatstanzafile_tab +xcatstanzafile_multattr +xcatstanzafile_defaultvalue +xcatstanzafile_specificvalue +noderm_noderange +noderm_h +noderm_null +noderm_err_node +nodeset_stat +nodeset_noderange +nodestat_noderange +nodestat_err_node +rinv_noderange_err +rmdef_null +rmdef_t_err +rpower_err_noderange +rvitals_noderange_err +tabdump_table +tabdump_d +tabdump_v +tabdump_h +tabdump_help +tabdump_w_match +tabdump_w_equal +tabdump_w_ne +tabdump_w_notmatch +tabdump_w_gt +tabdump_w_ge +tabdump_w_lt +tabdump_w_le +tabdump_f_d +tabdump_d_nodehm +tabprune_h +tabprune_v +tabprune_a_eventlog +tabprune_V_a_eventlog +tabprune_i_auditlog +tabprune_V_n_auditlog +tabgrep_node +tabgrep_null +tabgrep_h +tabgrep_err +tabrestore_table +tabrestore_null +tabrestore_h +tabrestore_err +dumpxCATdb_h +dumpxCATdb_v +dumpxCATdb_p_nullskiptables +dumpxCATdb_a_p_nullskiptables +dumpxCATdb_p_skiptables +dumpxCATdb_a_p_skiptables +dumpxCATdb_p_nullskiptables_V +dumpxCATdb_a_p_nullskiptables_V +dumpxCATdb_p_V +restorexCAT_h +restorexCATdb_v +restorexCATdb_p_V +restorexCATdb_a_p_V +restorexCATdb_wrongpath +regnotif_null +regnotif_o +regnotif_err +regnotif_h +regnotif_v +unregnotif_null +unregnotif_f +unregnotif_h +unregnotif_v +lsxcatd_null +lsxcatd_h +lsxcatd_d +lsxcatd_a +makedns_d_node +makedns_n +makedns +copycds_iso +copycds_n +copycds_a +copycds_n_a +xdsh_h +xdsh_V +xdsh_regular_command +xdsh_Q_command +xdsh_c_cn +xdsh_e_filename +xdsh_E +xdsh_i_linux +xdsh_t +xdsh_q +xdsh_T +xdsh_o +switchdiscover_range_default +switchdiscover_h +switchdiscover_range_s +switchdiscover_range_default_w +switchdiscover_range_r +switchdiscover_range_x +switchdiscover_range_z +switchdiscover_range_z_V +nodeset_check_warninginfo +nodeset_shell +nodeset_cmdline +nodeset_runimg +reg_linux_diskless_installation_flat +reg_linux_statelite_installation_flat +SN_setup_case +reg_linux_diskfull_installation_hierarchy +reg_linux_diskless_installation_hierarchy +reg_linux_statelite_installation_hierarchy_by_ramdisk +reg_linux_statelite_installation_hierarchy_by_nfs +redhat_migration1 +redhat_migration2 +clean_up_env diff --git a/xCAT-test/autotest/bundle/sles11.4_ppc64.bundle b/xCAT-test/autotest/bundle/sles11.4_ppc64.bundle index 75ffb4dde..74d153401 100644 --- a/xCAT-test/autotest/bundle/sles11.4_ppc64.bundle +++ b/xCAT-test/autotest/bundle/sles11.4_ppc64.bundle @@ -1,270 +1,269 @@ -reg_linux_diskfull_installation_flat -chdef_null -chdef_t_node -chdef_t_network -chdef_p -chdef_m -chdef_z -chdef_group -chdef_group_p -chdef_dynamic_group -chdef_multiple_keys -chdef_n -chdef_t_o_error -chtab_null -chtab_d -chtab_modify_node -chtab_modify_key -chtab_h -chtab_v -copycds_iso -copycds_n -copycds_a -copycds_n_a -copycds_a_err -copycds_n_err -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_node -getmacs_noderange -getmacs_d -getmacs_f_D -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -lslite_i -lslite_noderange -lslite_h -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a -makedhcp_a_d -makedhcp_d -mkdef_null -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_normal -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_tab -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_specificvalue -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_err_node -rinv_bus -rinv_config -rinv_serial -rinv_model -rinv_firm -rinv_all -rinv_noderange_err -rmdef_null -rmdef_t_err -rpower_off -rpower_stat -rpower_boot -rpower_on -rpower_reset -rpower_noderange -rpower_noderange_nodeps -rpower_err_noderange -rscan_noderange -rscan_x -rscan_z -rscan_w -rscan_x_w -rscan_z_w -rvitals_lcds -rvitals_all -rvitals_noderange_err -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_p_auditlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -makehosts_h -makehosts_help -makehosts_null -makehosts_l -makehosts_d -makehosts_n -makehosts_n_noderange -xdcp_src_dst -makedns_h -makedns_d_node -makedns_n -makedns -noderange_individual_node -noderange_individual_grp -noderange_node01-node10 -noderange_group1-group3 -noderange_10-20 -noderange_XCAT_NODE_PREFIX -noderange_XCAT_NODE_SUFFIX -noderange_exclusion -noderange_group_intersection -confignics_config_one_port_single_value -confignics_config_multiple_ports_single_value -confignics_config_multiple_ports_multiple_value -confignics_config_multiple_port_withnichostnamesuffixes_multiple_value -confignics_config_multiple_port_withnicaliases_multiple_value -confignics_disable_set_to_yes -confignics_disable_set_to_1 -confignics_s -xdsh_h -xdsh_V -xdsh_regular_command -xdsh_Q_command -xdsh_c_cn -xdsh_e_filename -xdsh_E -xdsh_t -xdsh_q -xdsh_T -xdsh_o -switchdiscover_range_default -switchdiscover_h -switchdiscover_range_s -switchdiscover_range_default_w -switchdiscover_range_r -switchdiscover_range_x -switchdiscover_range_z -switchdiscover_range_z_V -makentp_v -makentp_h -makentp_V -makentp -makentp_a -nodeset_check_warninginfo -reg_linux_diskless_installation_flat -reg_linux_statelite_installation_flat -SN_setup_case -reg_linux_diskfull_installation_hierarchy -reg_linux_diskless_installation_hierarchy -reg_linux_statelite_installation_hierarchy_by_ramdisk -reg_linux_statelite_installation_hierarchy_by_nfs -sles_migration1 -sles_migration2 -clean_up_env +reg_linux_diskfull_installation_flat +chdef_null +chdef_t_node +chdef_t_network +chdef_p +chdef_m +chdef_z +chdef_group +chdef_group_p +chdef_dynamic_group +chdef_multiple_keys +chdef_n +chdef_t_o_error +chtab_null +chtab_d +chtab_modify_node +chtab_modify_key +chtab_h +chtab_v +copycds_iso +copycds_n +copycds_a +copycds_n_a +copycds_a_err +copycds_n_err +packimage_o_p_a_m +packimage_p_a_o +packimage_imagename +packimage_h +packimage_v +pping_h +pping_v +pping_node +getmacs_noderange +getmacs_d +getmacs_f_D +gettab_key_table +gettab_H +gettab_err +gettab_h +lsdef_null +lsdef_a +lsdef_t_o_l +lsdef_t_o_l_z +lsdef_t +lsdef_t_i_o +lsdef_t_w +lsdef_t_err +lslite_i +lslite_noderange +lslite_h +makeconservercf_null +makeconservercf_noderange +makeconservercf_d +makedhcp_n +makedhcp_a +makedhcp_a_d +makedhcp_d +mkdef_null +mkdef_z +mkdef_t_o_error +nodeadd_noderange +nodeadd_err_symbol +nodeadd_null +nodeadd_noderange_nodetype +nodeadd_v +nodeadd_h +nodegrpch_v +nodegrpch_h +nodegrpch_groups +nodegrpch_err +nodech_noderange_table +nodech_noderange_table_comma +nodech_noderange_table_arrow +nodech_noderanage_table_at +nodech_delete +nodech_error_node +nodech_error_table +nodech_h +nodech_v +nodech_noderange_table_include +nodech_noderange_table_uninclude +nodech_noderange_table_equal +nodech_noderange_table_unequal +nodech_noderange_shortname_groups +nodech_noderange_shortname_tags +nodech_noderange_shortname_mgt +nodels_null +nodels_H +nodels_noderange +nodels_err_symbol +nodels_err_noderange +nodels_noderange_shortname_groups +nodels_noderange_shortname_tags +nodels_noderange_shortname_mgt +nodels_table_include +nodels_noderange_table_uninclude +nodels_noderange_table_equal +nodels_noderange_table_unequal +nodels_b +nodels_S +nodels_noderange_table +nodels_tablevalue +nodels_tablevalue_tablecolumn +nodels_noderange_tablecolumn +nodels_h +nodels_v +xcatstanzafile_normal +xcatstanzafile_colon +xcatstanzafile_attribute +xcatstanzafile_objtype +xcatstanzafile_tab +xcatstanzafile_multattr +xcatstanzafile_defaultvalue +xcatstanzafile_specificvalue +noderm_noderange +noderm_h +noderm_null +noderm_err_node +nodeset_stat +nodeset_noderange +nodestat_err_node +rinv_bus +rinv_config +rinv_serial +rinv_model +rinv_firm +rinv_all +rinv_noderange_err +rmdef_null +rmdef_t_err +rpower_off +rpower_stat +rpower_boot +rpower_on +rpower_reset +rpower_noderange +rpower_noderange_nodeps +rpower_err_noderange +rscan_noderange +rscan_x +rscan_z +rscan_w +rscan_x_w +rscan_z_w +rvitals_lcds +rvitals_all +rvitals_noderange_err +tabdump_table +tabdump_d +tabdump_v +tabdump_h +tabdump_help +tabdump_w_match +tabdump_w_equal +tabdump_w_ne +tabdump_w_notmatch +tabdump_w_gt +tabdump_w_ge +tabdump_w_lt +tabdump_w_le +tabdump_f_d +tabdump_d_nodehm +tabprune_h +tabprune_v +tabprune_a_eventlog +tabprune_V_a_eventlog +tabprune_p_auditlog +tabprune_i_auditlog +tabprune_V_n_auditlog +tabgrep_node +tabgrep_null +tabgrep_h +tabgrep_err +tabrestore_table +tabrestore_null +tabrestore_h +tabrestore_err +dumpxCATdb_h +dumpxCATdb_v +dumpxCATdb_p_nullskiptables +dumpxCATdb_a_p_nullskiptables +dumpxCATdb_p_skiptables +dumpxCATdb_a_p_skiptables +dumpxCATdb_p_nullskiptables_V +dumpxCATdb_a_p_nullskiptables_V +dumpxCATdb_p_V +restorexCAT_h +restorexCATdb_v +restorexCATdb_p_V +restorexCATdb_a_p_V +restorexCATdb_wrongpath +regnotif_null +regnotif_o +regnotif_err +regnotif_h +regnotif_v +unregnotif_null +unregnotif_f +unregnotif_h +unregnotif_v +lsxcatd_null +lsxcatd_h +lsxcatd_d +lsxcatd_a +makehosts_h +makehosts_help +makehosts_null +makehosts_l +makehosts_d +makehosts_n +makehosts_n_noderange +xdcp_src_dst +makedns_h +makedns_d_node +makedns_n +makedns +noderange_individual_node +noderange_individual_grp +noderange_node01-node10 +noderange_group1-group3 +noderange_10-20 +noderange_XCAT_NODE_PREFIX +noderange_XCAT_NODE_SUFFIX +noderange_exclusion +noderange_group_intersection +confignics_config_one_port_single_value +confignics_config_multiple_ports_single_value +confignics_config_multiple_ports_multiple_value +confignics_config_multiple_port_withnichostnamesuffixes_multiple_value +confignics_config_multiple_port_withnicaliases_multiple_value +confignics_disable_set_to_yes +confignics_disable_set_to_1 +confignics_s +xdsh_h +xdsh_V +xdsh_regular_command +xdsh_Q_command +xdsh_c_cn +xdsh_e_filename +xdsh_E +xdsh_t +xdsh_q +xdsh_T +xdsh_o +switchdiscover_range_default +switchdiscover_h +switchdiscover_range_s +switchdiscover_range_default_w +switchdiscover_range_r +switchdiscover_range_x +switchdiscover_range_z +switchdiscover_range_z_V +makentp_v +makentp_h +makentp_V +makentp +makentp_a +nodeset_check_warninginfo +reg_linux_diskless_installation_flat +reg_linux_statelite_installation_flat +SN_setup_case +reg_linux_diskfull_installation_hierarchy +reg_linux_diskless_installation_hierarchy +reg_linux_statelite_installation_hierarchy_by_ramdisk +reg_linux_statelite_installation_hierarchy_by_nfs +sles_migration1 +sles_migration2 +clean_up_env diff --git a/xCAT-test/autotest/bundle/sles11.4_x86_64.bundle b/xCAT-test/autotest/bundle/sles11.4_x86_64.bundle index c2bdbc84b..4af6e5508 100644 --- a/xCAT-test/autotest/bundle/sles11.4_x86_64.bundle +++ b/xCAT-test/autotest/bundle/sles11.4_x86_64.bundle @@ -1,222 +1,221 @@ -reg_linux_diskfull_installation_flat -makehosts_h -makehosts_help -makehosts_n -makehosts_n_noderange -chdef_null -chdef_z -chdef_t_o_error -chtab_null -chtab_d -chtab_modify_node -chtab_modify_key -chtab_err_symble -chtab_err_table -chtab_h -chtab_v -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_node -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -lslite_i -lslite_noderange -lslite_h -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a -makedhcp_a_d -makedhcp_d -mkdef_null -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_normal -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_tab -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_specificvalue -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_noderange -nodestat_err_node -rinv_noderange_err -rmdef_null -rmdef_t_err -rpower_err_noderange -rvitals_noderange_err -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -makedns_d_node -makedns_n -makedns -copycds_iso -copycds_n -copycds_a -copycds_n_a -copycds_a_err -copycds_n_err -xdsh_h -xdsh_V -xdsh_regular_command -xdsh_Q_command -xdsh_c_cn -xdsh_e_filename -xdsh_E -xdsh_i_linux -xdsh_t -xdsh_q -xdsh_T -xdsh_o -switchdiscover_range_default -switchdiscover_h -switchdiscover_range_s -switchdiscover_range_default_w -switchdiscover_range_r -switchdiscover_range_x -switchdiscover_range_z -switchdiscover_range_z_V -nodeset_shell -nodeset_cmdline -nodeset_runimg -nodeset_check_warninginfo -xcatd_start -xcatd_stop -xcatd_restart -run_command_with_XCATBYPASS -disable_root_permission_in_policy_table -assign_certain_command_permission -reg_linux_diskless_installation_flat -reg_linux_statelite_installation_flat -SN_setup_case -reg_linux_diskfull_installation_hierarchy -reg_linux_diskless_installation_hierarchy -reg_linux_statelite_installation_hierarchy_by_ramdisk -reg_linux_statelite_installation_hierarchy_by_nfs -sles_migration1 -sles_migration2 -clean_up_env +reg_linux_diskfull_installation_flat +makehosts_h +makehosts_help +makehosts_n +makehosts_n_noderange +chdef_null +chdef_z +chdef_t_o_error +chtab_null +chtab_d +chtab_modify_node +chtab_modify_key +chtab_err_symble +chtab_err_table +chtab_h +chtab_v +packimage_o_p_a_m +packimage_p_a_o +packimage_imagename +packimage_h +packimage_v +pping_h +pping_v +pping_node +gettab_key_table +gettab_H +gettab_err +gettab_h +lsdef_null +lsdef_a +lsdef_t_o_l +lsdef_t_o_l_z +lsdef_t +lsdef_t_i_o +lsdef_t_w +lsdef_t_err +lslite_i +lslite_noderange +lslite_h +makeconservercf_null +makeconservercf_noderange +makeconservercf_d +makedhcp_n +makedhcp_a +makedhcp_a_d +makedhcp_d +mkdef_null +mkdef_z +mkdef_t_o_error +nodeadd_noderange +nodeadd_err_symbol +nodeadd_null +nodeadd_noderange_nodetype +nodeadd_v +nodeadd_h +nodegrpch_v +nodegrpch_h +nodegrpch_groups +nodegrpch_err +nodech_noderange_table +nodech_noderange_table_comma +nodech_noderange_table_arrow +nodech_noderanage_table_at +nodech_delete +nodech_error_node +nodech_error_table +nodech_h +nodech_v +nodech_noderange_table_include +nodech_noderange_table_uninclude +nodech_noderange_table_equal +nodech_noderange_table_unequal +nodech_noderange_shortname_groups +nodech_noderange_shortname_tags +nodech_noderange_shortname_mgt +nodels_null +nodels_H +nodels_noderange +nodels_err_symbol +nodels_err_noderange +nodels_noderange_shortname_groups +nodels_noderange_shortname_tags +nodels_noderange_shortname_mgt +nodels_table_include +nodels_noderange_table_uninclude +nodels_noderange_table_equal +nodels_noderange_table_unequal +nodels_b +nodels_S +nodels_noderange_table +nodels_tablevalue +nodels_tablevalue_tablecolumn +nodels_noderange_tablecolumn +nodels_h +nodels_v +xcatstanzafile_normal +xcatstanzafile_colon +xcatstanzafile_attribute +xcatstanzafile_objtype +xcatstanzafile_tab +xcatstanzafile_multattr +xcatstanzafile_defaultvalue +xcatstanzafile_specificvalue +noderm_noderange +noderm_h +noderm_null +noderm_err_node +nodeset_stat +nodeset_noderange +nodestat_noderange +nodestat_err_node +rinv_noderange_err +rmdef_null +rmdef_t_err +rpower_err_noderange +rvitals_noderange_err +tabdump_table +tabdump_d +tabdump_v +tabdump_h +tabdump_help +tabdump_w_match +tabdump_w_equal +tabdump_w_ne +tabdump_w_notmatch +tabdump_w_gt +tabdump_w_ge +tabdump_w_lt +tabdump_w_le +tabdump_f_d +tabdump_d_nodehm +tabprune_h +tabprune_v +tabprune_a_eventlog +tabprune_V_a_eventlog +tabprune_i_auditlog +tabprune_V_n_auditlog +tabgrep_node +tabgrep_null +tabgrep_h +tabgrep_err +tabrestore_table +tabrestore_null +tabrestore_h +tabrestore_err +dumpxCATdb_h +dumpxCATdb_v +dumpxCATdb_p_nullskiptables +dumpxCATdb_a_p_nullskiptables +dumpxCATdb_p_skiptables +dumpxCATdb_a_p_skiptables +dumpxCATdb_p_nullskiptables_V +dumpxCATdb_a_p_nullskiptables_V +dumpxCATdb_p_V +restorexCAT_h +restorexCATdb_v +restorexCATdb_p_V +restorexCATdb_a_p_V +restorexCATdb_wrongpath +regnotif_null +regnotif_o +regnotif_err +regnotif_h +regnotif_v +unregnotif_null +unregnotif_f +unregnotif_h +unregnotif_v +lsxcatd_null +lsxcatd_h +lsxcatd_d +lsxcatd_a +makedns_d_node +makedns_n +makedns +copycds_iso +copycds_n +copycds_a +copycds_n_a +copycds_a_err +copycds_n_err +xdsh_h +xdsh_V +xdsh_regular_command +xdsh_Q_command +xdsh_c_cn +xdsh_e_filename +xdsh_E +xdsh_i_linux +xdsh_t +xdsh_q +xdsh_T +xdsh_o +switchdiscover_range_default +switchdiscover_h +switchdiscover_range_s +switchdiscover_range_default_w +switchdiscover_range_r +switchdiscover_range_x +switchdiscover_range_z +switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg +nodeset_check_warninginfo +xcatd_start +xcatd_stop +xcatd_restart +run_command_with_XCATBYPASS +disable_root_permission_in_policy_table +assign_certain_command_permission +reg_linux_diskless_installation_flat +reg_linux_statelite_installation_flat +SN_setup_case +reg_linux_diskfull_installation_hierarchy +reg_linux_diskless_installation_hierarchy +reg_linux_statelite_installation_hierarchy_by_ramdisk +reg_linux_statelite_installation_hierarchy_by_nfs +sles_migration1 +sles_migration2 +clean_up_env diff --git a/xCAT-test/autotest/bundle/sles12.1_ppc64.bundle b/xCAT-test/autotest/bundle/sles12.1_ppc64.bundle index 04a1ebe34..f7f478c0a 100644 --- a/xCAT-test/autotest/bundle/sles12.1_ppc64.bundle +++ b/xCAT-test/autotest/bundle/sles12.1_ppc64.bundle @@ -1,262 +1,261 @@ -reg_linux_diskfull_installation_flat -chdef_null -chdef_t_node -chdef_t_network -chdef_p -chdef_m -chdef_z -chdef_group -chdef_group_p -chdef_dynamic_group -chdef_multiple_keys -chdef_n -chdef_t_o_error -chtab_null -chtab_d -chtab_modify_node -chtab_modify_key -chtab_h -chtab_v -copycds_iso -copycds_n -copycds_a -copycds_n_a -copycds_a_err -copycds_n_err -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_node -getmacs_noderange -getmacs_d -getmacs_f_D -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -lslite_i -lslite_noderange -lslite_h -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a -makedhcp_a_d -makedhcp_d -mkdef_null -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_normal -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_tab -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_specificvalue -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_err_node -rinv_bus -rinv_config -rinv_serial -rinv_model -rinv_firm -rinv_all -rinv_noderange_err -rmdef_null -rmdef_t_err -rpower_off -rpower_stat -rpower_boot -rpower_on -rpower_reset -rpower_noderange -rpower_noderange_nodeps -rpower_err_noderange -rscan_noderange -rscan_x -rscan_z -rscan_w -rscan_x_w -rscan_z_w -rvitals_lcds -rvitals_all -rvitals_noderange_err -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_p_auditlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -makehosts_h -makehosts_help -makehosts_null -makehosts_l -makehosts_d -makehosts_n -makehosts_n_noderange -xdcp_src_dst -makedns_h -makedns_d_node -makedns_n -makedns -noderange_individual_node -noderange_individual_grp -noderange_node01-node10 -noderange_group1-group3 -noderange_10-20 -noderange_XCAT_NODE_PREFIX -noderange_XCAT_NODE_SUFFIX -noderange_exclusion -noderange_group_intersection -confignics_config_one_port_single_value -confignics_config_multiple_ports_single_value -confignics_config_multiple_ports_multiple_value -confignics_config_multiple_port_withnichostnamesuffixes_multiple_value -confignics_config_multiple_port_withnicaliases_multiple_value -confignics_disable_set_to_yes -confignics_disable_set_to_1 -confignics_s -xdsh_h -xdsh_V -xdsh_regular_command -xdsh_Q_command -xdsh_c_cn -xdsh_e_filename -xdsh_E -xdsh_t -xdsh_q -xdsh_T -xdsh_o -switchdiscover_range_default -switchdiscover_h -switchdiscover_range_s -switchdiscover_range_default_w -switchdiscover_range_r -switchdiscover_range_x -switchdiscover_range_z -switchdiscover_range_z_V -makentp_v -makentp_h -makentp_V -makentp -makentp_a -nodeset_check_warninginfo -reg_linux_diskless_installation_flat -reg_linux_statelite_installation_flat +reg_linux_diskfull_installation_flat +chdef_null +chdef_t_node +chdef_t_network +chdef_p +chdef_m +chdef_z +chdef_group +chdef_group_p +chdef_dynamic_group +chdef_multiple_keys +chdef_n +chdef_t_o_error +chtab_null +chtab_d +chtab_modify_node +chtab_modify_key +chtab_h +chtab_v +copycds_iso +copycds_n +copycds_a +copycds_n_a +copycds_a_err +copycds_n_err +packimage_o_p_a_m +packimage_p_a_o +packimage_imagename +packimage_h +packimage_v +pping_h +pping_v +pping_node +getmacs_noderange +getmacs_d +getmacs_f_D +gettab_key_table +gettab_H +gettab_err +gettab_h +lsdef_null +lsdef_a +lsdef_t_o_l +lsdef_t_o_l_z +lsdef_t +lsdef_t_i_o +lsdef_t_w +lsdef_t_err +lslite_i +lslite_noderange +lslite_h +makeconservercf_null +makeconservercf_noderange +makeconservercf_d +makedhcp_n +makedhcp_a +makedhcp_a_d +makedhcp_d +mkdef_null +mkdef_z +mkdef_t_o_error +nodeadd_noderange +nodeadd_err_symbol +nodeadd_null +nodeadd_noderange_nodetype +nodeadd_v +nodeadd_h +nodegrpch_v +nodegrpch_h +nodegrpch_groups +nodegrpch_err +nodech_noderange_table +nodech_noderange_table_comma +nodech_noderange_table_arrow +nodech_noderanage_table_at +nodech_delete +nodech_error_node +nodech_error_table +nodech_h +nodech_v +nodech_noderange_table_include +nodech_noderange_table_uninclude +nodech_noderange_table_equal +nodech_noderange_table_unequal +nodech_noderange_shortname_groups +nodech_noderange_shortname_tags +nodech_noderange_shortname_mgt +nodels_null +nodels_H +nodels_noderange +nodels_err_symbol +nodels_err_noderange +nodels_noderange_shortname_groups +nodels_noderange_shortname_tags +nodels_noderange_shortname_mgt +nodels_table_include +nodels_noderange_table_uninclude +nodels_noderange_table_equal +nodels_noderange_table_unequal +nodels_b +nodels_S +nodels_noderange_table +nodels_tablevalue +nodels_tablevalue_tablecolumn +nodels_noderange_tablecolumn +nodels_h +nodels_v +xcatstanzafile_normal +xcatstanzafile_colon +xcatstanzafile_attribute +xcatstanzafile_objtype +xcatstanzafile_tab +xcatstanzafile_multattr +xcatstanzafile_defaultvalue +xcatstanzafile_specificvalue +noderm_noderange +noderm_h +noderm_null +noderm_err_node +nodeset_stat +nodeset_noderange +nodestat_err_node +rinv_bus +rinv_config +rinv_serial +rinv_model +rinv_firm +rinv_all +rinv_noderange_err +rmdef_null +rmdef_t_err +rpower_off +rpower_stat +rpower_boot +rpower_on +rpower_reset +rpower_noderange +rpower_noderange_nodeps +rpower_err_noderange +rscan_noderange +rscan_x +rscan_z +rscan_w +rscan_x_w +rscan_z_w +rvitals_lcds +rvitals_all +rvitals_noderange_err +tabdump_table +tabdump_d +tabdump_v +tabdump_h +tabdump_help +tabdump_w_match +tabdump_w_equal +tabdump_w_ne +tabdump_w_notmatch +tabdump_w_gt +tabdump_w_ge +tabdump_w_lt +tabdump_w_le +tabdump_f_d +tabdump_d_nodehm +tabprune_h +tabprune_v +tabprune_a_eventlog +tabprune_V_a_eventlog +tabprune_p_auditlog +tabprune_i_auditlog +tabprune_V_n_auditlog +tabgrep_node +tabgrep_null +tabgrep_h +tabgrep_err +tabrestore_table +tabrestore_null +tabrestore_h +tabrestore_err +dumpxCATdb_h +dumpxCATdb_v +dumpxCATdb_p_nullskiptables +dumpxCATdb_a_p_nullskiptables +dumpxCATdb_p_skiptables +dumpxCATdb_a_p_skiptables +dumpxCATdb_p_nullskiptables_V +dumpxCATdb_a_p_nullskiptables_V +dumpxCATdb_p_V +restorexCAT_h +restorexCATdb_v +restorexCATdb_p_V +restorexCATdb_a_p_V +restorexCATdb_wrongpath +regnotif_null +regnotif_o +regnotif_err +regnotif_h +regnotif_v +unregnotif_null +unregnotif_f +unregnotif_h +unregnotif_v +lsxcatd_null +lsxcatd_h +lsxcatd_d +lsxcatd_a +makehosts_h +makehosts_help +makehosts_null +makehosts_l +makehosts_d +makehosts_n +makehosts_n_noderange +xdcp_src_dst +makedns_h +makedns_d_node +makedns_n +makedns +noderange_individual_node +noderange_individual_grp +noderange_node01-node10 +noderange_group1-group3 +noderange_10-20 +noderange_XCAT_NODE_PREFIX +noderange_XCAT_NODE_SUFFIX +noderange_exclusion +noderange_group_intersection +confignics_config_one_port_single_value +confignics_config_multiple_ports_single_value +confignics_config_multiple_ports_multiple_value +confignics_config_multiple_port_withnichostnamesuffixes_multiple_value +confignics_config_multiple_port_withnicaliases_multiple_value +confignics_disable_set_to_yes +confignics_disable_set_to_1 +confignics_s +xdsh_h +xdsh_V +xdsh_regular_command +xdsh_Q_command +xdsh_c_cn +xdsh_e_filename +xdsh_E +xdsh_t +xdsh_q +xdsh_T +xdsh_o +switchdiscover_range_default +switchdiscover_h +switchdiscover_range_s +switchdiscover_range_default_w +switchdiscover_range_r +switchdiscover_range_x +switchdiscover_range_z +switchdiscover_range_z_V +makentp_v +makentp_h +makentp_V +makentp +makentp_a +nodeset_check_warninginfo +reg_linux_diskless_installation_flat +reg_linux_statelite_installation_flat diff --git a/xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle b/xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle index fbe5b25ca..2caa4876b 100644 --- a/xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle @@ -1,209 +1,208 @@ -Diskless_installation_flat_p8_le -Full_installation_flat_p8_le -makehosts_h -makehosts_help -makehosts_n -makehosts_n_noderange -chdef_null -chdef_z -chdef_t_o_error -chtab_null -chtab_d -chtab_modify_node -chtab_modify_key -chtab_err_symble -chtab_err_table -chtab_h -chtab_v -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_node -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a -makedhcp_a_d -makedhcp_d -mkdef_null -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_tab -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_specificvalue -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_err_node -rinv_noderange_err -rmdef_null -rmdef_t_err -rpower_err_noderange -rvitals_noderange_err -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -makedns_d_node -makedns_n -makedns -copycds_iso -copycds_n -copycds_a -copycds_n_a -copycds_a_err -copycds_n_err -xdsh_h -xdsh_V -xdsh_regular_command -xdsh_Q_command -xdsh_c_cn -xdsh_e_filename -xdsh_E -xdsh_i_linux -xdsh_t -xdsh_q -xdsh_T -xdsh_o -switchdiscover_range_default -switchdiscover_h -switchdiscover_range_s -switchdiscover_range_default_w -switchdiscover_range_r -switchdiscover_range_x -switchdiscover_range_z -switchdiscover_range_z_V -nodeset_shell -nodeset_cmdline -nodeset_runimg -xcatd_start_systemd -xcatd_stop_systemd -xcatd_restart_systemd -run_command_with_XCATBYPASS_systemd -disable_root_permission_in_policy_table_systemd -assign_certain_command_permission_systemd -sles_migration1 -sles_migration2 +Diskless_installation_flat_p8_le +Full_installation_flat_p8_le +makehosts_h +makehosts_help +makehosts_n +makehosts_n_noderange +chdef_null +chdef_z +chdef_t_o_error +chtab_null +chtab_d +chtab_modify_node +chtab_modify_key +chtab_err_symble +chtab_err_table +chtab_h +chtab_v +packimage_o_p_a_m +packimage_p_a_o +packimage_imagename +packimage_h +packimage_v +pping_h +pping_v +pping_node +gettab_key_table +gettab_H +gettab_err +gettab_h +lsdef_null +lsdef_a +lsdef_t_o_l +lsdef_t_o_l_z +lsdef_t +lsdef_t_i_o +lsdef_t_w +lsdef_t_err +makeconservercf_null +makeconservercf_noderange +makeconservercf_d +makedhcp_n +makedhcp_a +makedhcp_a_d +makedhcp_d +mkdef_null +mkdef_z +mkdef_t_o_error +nodeadd_noderange +nodeadd_err_symbol +nodeadd_null +nodeadd_noderange_nodetype +nodeadd_v +nodeadd_h +nodegrpch_v +nodegrpch_h +nodegrpch_groups +nodegrpch_err +nodech_noderange_table +nodech_noderange_table_comma +nodech_noderange_table_arrow +nodech_noderanage_table_at +nodech_delete +nodech_error_node +nodech_error_table +nodech_h +nodech_v +nodech_noderange_table_include +nodech_noderange_table_uninclude +nodech_noderange_table_equal +nodech_noderange_table_unequal +nodech_noderange_shortname_groups +nodech_noderange_shortname_tags +nodech_noderange_shortname_mgt +nodels_null +nodels_H +nodels_noderange +nodels_err_symbol +nodels_err_noderange +nodels_noderange_shortname_groups +nodels_noderange_shortname_tags +nodels_noderange_shortname_mgt +nodels_table_include +nodels_noderange_table_uninclude +nodels_noderange_table_equal +nodels_noderange_table_unequal +nodels_b +nodels_S +nodels_noderange_table +nodels_tablevalue +nodels_tablevalue_tablecolumn +nodels_noderange_tablecolumn +nodels_h +nodels_v +xcatstanzafile_colon +xcatstanzafile_attribute +xcatstanzafile_objtype +xcatstanzafile_tab +xcatstanzafile_multattr +xcatstanzafile_defaultvalue +xcatstanzafile_specificvalue +noderm_noderange +noderm_h +noderm_null +noderm_err_node +nodeset_stat +nodeset_noderange +nodestat_err_node +rinv_noderange_err +rmdef_null +rmdef_t_err +rpower_err_noderange +rvitals_noderange_err +tabdump_table +tabdump_d +tabdump_v +tabdump_h +tabdump_help +tabdump_w_match +tabdump_w_equal +tabdump_w_ne +tabdump_w_notmatch +tabdump_w_gt +tabdump_w_ge +tabdump_w_lt +tabdump_w_le +tabdump_f_d +tabdump_d_nodehm +tabprune_h +tabprune_v +tabprune_a_eventlog +tabprune_V_a_eventlog +tabprune_i_auditlog +tabprune_V_n_auditlog +tabgrep_node +tabgrep_null +tabgrep_h +tabgrep_err +tabrestore_table +tabrestore_null +tabrestore_h +tabrestore_err +dumpxCATdb_h +dumpxCATdb_v +dumpxCATdb_p_nullskiptables +dumpxCATdb_a_p_nullskiptables +dumpxCATdb_p_skiptables +dumpxCATdb_a_p_skiptables +dumpxCATdb_p_nullskiptables_V +dumpxCATdb_a_p_nullskiptables_V +dumpxCATdb_p_V +restorexCAT_h +restorexCATdb_v +restorexCATdb_p_V +restorexCATdb_a_p_V +restorexCATdb_wrongpath +regnotif_null +regnotif_o +regnotif_err +regnotif_h +regnotif_v +unregnotif_null +unregnotif_f +unregnotif_h +unregnotif_v +lsxcatd_null +lsxcatd_h +lsxcatd_d +lsxcatd_a +makedns_d_node +makedns_n +makedns +copycds_iso +copycds_n +copycds_a +copycds_n_a +copycds_a_err +copycds_n_err +xdsh_h +xdsh_V +xdsh_regular_command +xdsh_Q_command +xdsh_c_cn +xdsh_e_filename +xdsh_E +xdsh_i_linux +xdsh_t +xdsh_q +xdsh_T +xdsh_o +switchdiscover_range_default +switchdiscover_h +switchdiscover_range_s +switchdiscover_range_default_w +switchdiscover_range_r +switchdiscover_range_x +switchdiscover_range_z +switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg +xcatd_start_systemd +xcatd_stop_systemd +xcatd_restart_systemd +run_command_with_XCATBYPASS_systemd +disable_root_permission_in_policy_table_systemd +assign_certain_command_permission_systemd +sles_migration1 +sles_migration2 diff --git a/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle b/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle index 1381b3c1b..757cbc2bf 100644 --- a/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle +++ b/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle @@ -1,216 +1,215 @@ -reg_linux_diskfull_installation_flat -makehosts_h -makehosts_help -makehosts_n -makehosts_n_noderange -chdef_null -chdef_z -chdef_t_o_error -chtab_null -chtab_d -chtab_modify_node -chtab_modify_key -chtab_err_symble -chtab_err_table -chtab_h -chtab_v -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_node -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -lslite_i -lslite_noderange -lslite_h -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a -makedhcp_a_d -makedhcp_d -mkdef_null -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_normal -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_tab -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_specificvalue -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_noderange -nodestat_err_node -rinv_noderange_err -rmdef_null -rmdef_t_err -rpower_err_noderange -rvitals_noderange_err -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -makedns_d_node -makedns_n -makedns -copycds_iso -copycds_n -copycds_a -copycds_n_a -copycds_a_err -copycds_n_err -xdsh_h -xdsh_V -xdsh_regular_command -xdsh_Q_command -xdsh_c_cn -xdsh_e_filename -xdsh_E -xdsh_i_linux -xdsh_t -xdsh_q -xdsh_T -xdsh_o -switchdiscover_range_default -switchdiscover_h -switchdiscover_range_s -switchdiscover_range_default_w -switchdiscover_range_r -switchdiscover_range_x -switchdiscover_range_z -switchdiscover_range_z_V -nodeset_shell -nodeset_cmdline -nodeset_runimg -nodeset_check_warninginfo -xcatd_start_systemd -xcatd_stop_systemd -xcatd_restart_systemd -run_command_with_XCATBYPASS_systemd -disable_root_permission_in_policy_table_systemd -assign_certain_command_permission_systemd -sles_migration1 -sles_migration2 -reg_linux_diskless_installation_flat -reg_linux_statelite_installation_flat +reg_linux_diskfull_installation_flat +makehosts_h +makehosts_help +makehosts_n +makehosts_n_noderange +chdef_null +chdef_z +chdef_t_o_error +chtab_null +chtab_d +chtab_modify_node +chtab_modify_key +chtab_err_symble +chtab_err_table +chtab_h +chtab_v +packimage_o_p_a_m +packimage_p_a_o +packimage_imagename +packimage_h +packimage_v +pping_h +pping_v +pping_node +gettab_key_table +gettab_H +gettab_err +gettab_h +lsdef_null +lsdef_a +lsdef_t_o_l +lsdef_t_o_l_z +lsdef_t +lsdef_t_i_o +lsdef_t_w +lsdef_t_err +lslite_i +lslite_noderange +lslite_h +makeconservercf_null +makeconservercf_noderange +makeconservercf_d +makedhcp_n +makedhcp_a +makedhcp_a_d +makedhcp_d +mkdef_null +mkdef_z +mkdef_t_o_error +nodeadd_noderange +nodeadd_err_symbol +nodeadd_null +nodeadd_noderange_nodetype +nodeadd_v +nodeadd_h +nodegrpch_v +nodegrpch_h +nodegrpch_groups +nodegrpch_err +nodech_noderange_table +nodech_noderange_table_comma +nodech_noderange_table_arrow +nodech_noderanage_table_at +nodech_delete +nodech_error_node +nodech_error_table +nodech_h +nodech_v +nodech_noderange_table_include +nodech_noderange_table_uninclude +nodech_noderange_table_equal +nodech_noderange_table_unequal +nodech_noderange_shortname_groups +nodech_noderange_shortname_tags +nodech_noderange_shortname_mgt +nodels_null +nodels_H +nodels_noderange +nodels_err_symbol +nodels_err_noderange +nodels_noderange_shortname_groups +nodels_noderange_shortname_tags +nodels_noderange_shortname_mgt +nodels_table_include +nodels_noderange_table_uninclude +nodels_noderange_table_equal +nodels_noderange_table_unequal +nodels_b +nodels_S +nodels_noderange_table +nodels_tablevalue +nodels_tablevalue_tablecolumn +nodels_noderange_tablecolumn +nodels_h +nodels_v +xcatstanzafile_normal +xcatstanzafile_colon +xcatstanzafile_attribute +xcatstanzafile_objtype +xcatstanzafile_tab +xcatstanzafile_multattr +xcatstanzafile_defaultvalue +xcatstanzafile_specificvalue +noderm_noderange +noderm_h +noderm_null +noderm_err_node +nodeset_stat +nodeset_noderange +nodestat_noderange +nodestat_err_node +rinv_noderange_err +rmdef_null +rmdef_t_err +rpower_err_noderange +rvitals_noderange_err +tabdump_table +tabdump_d +tabdump_v +tabdump_h +tabdump_help +tabdump_w_match +tabdump_w_equal +tabdump_w_ne +tabdump_w_notmatch +tabdump_w_gt +tabdump_w_ge +tabdump_w_lt +tabdump_w_le +tabdump_f_d +tabdump_d_nodehm +tabprune_h +tabprune_v +tabprune_a_eventlog +tabprune_V_a_eventlog +tabprune_i_auditlog +tabprune_V_n_auditlog +tabgrep_node +tabgrep_null +tabgrep_h +tabgrep_err +tabrestore_table +tabrestore_null +tabrestore_h +tabrestore_err +dumpxCATdb_h +dumpxCATdb_v +dumpxCATdb_p_nullskiptables +dumpxCATdb_a_p_nullskiptables +dumpxCATdb_p_skiptables +dumpxCATdb_a_p_skiptables +dumpxCATdb_p_nullskiptables_V +dumpxCATdb_a_p_nullskiptables_V +dumpxCATdb_p_V +restorexCAT_h +restorexCATdb_v +restorexCATdb_p_V +restorexCATdb_a_p_V +restorexCATdb_wrongpath +regnotif_null +regnotif_o +regnotif_err +regnotif_h +regnotif_v +unregnotif_null +unregnotif_f +unregnotif_h +unregnotif_v +lsxcatd_null +lsxcatd_h +lsxcatd_d +lsxcatd_a +makedns_d_node +makedns_n +makedns +copycds_iso +copycds_n +copycds_a +copycds_n_a +copycds_a_err +copycds_n_err +xdsh_h +xdsh_V +xdsh_regular_command +xdsh_Q_command +xdsh_c_cn +xdsh_e_filename +xdsh_E +xdsh_i_linux +xdsh_t +xdsh_q +xdsh_T +xdsh_o +switchdiscover_range_default +switchdiscover_h +switchdiscover_range_s +switchdiscover_range_default_w +switchdiscover_range_r +switchdiscover_range_x +switchdiscover_range_z +switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg +nodeset_check_warninginfo +xcatd_start_systemd +xcatd_stop_systemd +xcatd_restart_systemd +run_command_with_XCATBYPASS_systemd +disable_root_permission_in_policy_table_systemd +assign_certain_command_permission_systemd +sles_migration1 +sles_migration2 +reg_linux_diskless_installation_flat +reg_linux_statelite_installation_flat diff --git a/xCAT-test/autotest/bundle/sles12_ppc64le.bundle b/xCAT-test/autotest/bundle/sles12_ppc64le.bundle index fbe5b25ca..2caa4876b 100644 --- a/xCAT-test/autotest/bundle/sles12_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/sles12_ppc64le.bundle @@ -1,209 +1,208 @@ -Diskless_installation_flat_p8_le -Full_installation_flat_p8_le -makehosts_h -makehosts_help -makehosts_n -makehosts_n_noderange -chdef_null -chdef_z -chdef_t_o_error -chtab_null -chtab_d -chtab_modify_node -chtab_modify_key -chtab_err_symble -chtab_err_table -chtab_h -chtab_v -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_node -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a -makedhcp_a_d -makedhcp_d -mkdef_null -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_tab -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_specificvalue -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_err_node -rinv_noderange_err -rmdef_null -rmdef_t_err -rpower_err_noderange -rvitals_noderange_err -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -makedns_d_node -makedns_n -makedns -copycds_iso -copycds_n -copycds_a -copycds_n_a -copycds_a_err -copycds_n_err -xdsh_h -xdsh_V -xdsh_regular_command -xdsh_Q_command -xdsh_c_cn -xdsh_e_filename -xdsh_E -xdsh_i_linux -xdsh_t -xdsh_q -xdsh_T -xdsh_o -switchdiscover_range_default -switchdiscover_h -switchdiscover_range_s -switchdiscover_range_default_w -switchdiscover_range_r -switchdiscover_range_x -switchdiscover_range_z -switchdiscover_range_z_V -nodeset_shell -nodeset_cmdline -nodeset_runimg -xcatd_start_systemd -xcatd_stop_systemd -xcatd_restart_systemd -run_command_with_XCATBYPASS_systemd -disable_root_permission_in_policy_table_systemd -assign_certain_command_permission_systemd -sles_migration1 -sles_migration2 +Diskless_installation_flat_p8_le +Full_installation_flat_p8_le +makehosts_h +makehosts_help +makehosts_n +makehosts_n_noderange +chdef_null +chdef_z +chdef_t_o_error +chtab_null +chtab_d +chtab_modify_node +chtab_modify_key +chtab_err_symble +chtab_err_table +chtab_h +chtab_v +packimage_o_p_a_m +packimage_p_a_o +packimage_imagename +packimage_h +packimage_v +pping_h +pping_v +pping_node +gettab_key_table +gettab_H +gettab_err +gettab_h +lsdef_null +lsdef_a +lsdef_t_o_l +lsdef_t_o_l_z +lsdef_t +lsdef_t_i_o +lsdef_t_w +lsdef_t_err +makeconservercf_null +makeconservercf_noderange +makeconservercf_d +makedhcp_n +makedhcp_a +makedhcp_a_d +makedhcp_d +mkdef_null +mkdef_z +mkdef_t_o_error +nodeadd_noderange +nodeadd_err_symbol +nodeadd_null +nodeadd_noderange_nodetype +nodeadd_v +nodeadd_h +nodegrpch_v +nodegrpch_h +nodegrpch_groups +nodegrpch_err +nodech_noderange_table +nodech_noderange_table_comma +nodech_noderange_table_arrow +nodech_noderanage_table_at +nodech_delete +nodech_error_node +nodech_error_table +nodech_h +nodech_v +nodech_noderange_table_include +nodech_noderange_table_uninclude +nodech_noderange_table_equal +nodech_noderange_table_unequal +nodech_noderange_shortname_groups +nodech_noderange_shortname_tags +nodech_noderange_shortname_mgt +nodels_null +nodels_H +nodels_noderange +nodels_err_symbol +nodels_err_noderange +nodels_noderange_shortname_groups +nodels_noderange_shortname_tags +nodels_noderange_shortname_mgt +nodels_table_include +nodels_noderange_table_uninclude +nodels_noderange_table_equal +nodels_noderange_table_unequal +nodels_b +nodels_S +nodels_noderange_table +nodels_tablevalue +nodels_tablevalue_tablecolumn +nodels_noderange_tablecolumn +nodels_h +nodels_v +xcatstanzafile_colon +xcatstanzafile_attribute +xcatstanzafile_objtype +xcatstanzafile_tab +xcatstanzafile_multattr +xcatstanzafile_defaultvalue +xcatstanzafile_specificvalue +noderm_noderange +noderm_h +noderm_null +noderm_err_node +nodeset_stat +nodeset_noderange +nodestat_err_node +rinv_noderange_err +rmdef_null +rmdef_t_err +rpower_err_noderange +rvitals_noderange_err +tabdump_table +tabdump_d +tabdump_v +tabdump_h +tabdump_help +tabdump_w_match +tabdump_w_equal +tabdump_w_ne +tabdump_w_notmatch +tabdump_w_gt +tabdump_w_ge +tabdump_w_lt +tabdump_w_le +tabdump_f_d +tabdump_d_nodehm +tabprune_h +tabprune_v +tabprune_a_eventlog +tabprune_V_a_eventlog +tabprune_i_auditlog +tabprune_V_n_auditlog +tabgrep_node +tabgrep_null +tabgrep_h +tabgrep_err +tabrestore_table +tabrestore_null +tabrestore_h +tabrestore_err +dumpxCATdb_h +dumpxCATdb_v +dumpxCATdb_p_nullskiptables +dumpxCATdb_a_p_nullskiptables +dumpxCATdb_p_skiptables +dumpxCATdb_a_p_skiptables +dumpxCATdb_p_nullskiptables_V +dumpxCATdb_a_p_nullskiptables_V +dumpxCATdb_p_V +restorexCAT_h +restorexCATdb_v +restorexCATdb_p_V +restorexCATdb_a_p_V +restorexCATdb_wrongpath +regnotif_null +regnotif_o +regnotif_err +regnotif_h +regnotif_v +unregnotif_null +unregnotif_f +unregnotif_h +unregnotif_v +lsxcatd_null +lsxcatd_h +lsxcatd_d +lsxcatd_a +makedns_d_node +makedns_n +makedns +copycds_iso +copycds_n +copycds_a +copycds_n_a +copycds_a_err +copycds_n_err +xdsh_h +xdsh_V +xdsh_regular_command +xdsh_Q_command +xdsh_c_cn +xdsh_e_filename +xdsh_E +xdsh_i_linux +xdsh_t +xdsh_q +xdsh_T +xdsh_o +switchdiscover_range_default +switchdiscover_h +switchdiscover_range_s +switchdiscover_range_default_w +switchdiscover_range_r +switchdiscover_range_x +switchdiscover_range_z +switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg +xcatd_start_systemd +xcatd_stop_systemd +xcatd_restart_systemd +run_command_with_XCATBYPASS_systemd +disable_root_permission_in_policy_table_systemd +assign_certain_command_permission_systemd +sles_migration1 +sles_migration2 diff --git a/xCAT-test/autotest/bundle/sles12_x86_64.bundle b/xCAT-test/autotest/bundle/sles12_x86_64.bundle index e0714d5ad..8e3413dd1 100644 --- a/xCAT-test/autotest/bundle/sles12_x86_64.bundle +++ b/xCAT-test/autotest/bundle/sles12_x86_64.bundle @@ -1,214 +1,213 @@ -reg_linux_diskfull_installation_flat -makehosts_h -makehosts_help -makehosts_n -makehosts_n_noderange -chdef_null -chdef_z -chdef_t_o_error -chtab_null -chtab_d -chtab_modify_node -chtab_modify_key -chtab_err_symble -chtab_err_table -chtab_h -chtab_v -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_node -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -lslite_i -lslite_noderange -lslite_h -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a -makedhcp_a_d -makedhcp_d -mkdef_null -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_normal -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_tab -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_specificvalue -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_noderange -nodestat_err_node -rinv_noderange_err -rmdef_null -rmdef_t_err -rpower_err_noderange -rvitals_noderange_err -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -makedns_d_node -makedns_n -makedns -copycds_iso -copycds_n -copycds_a -copycds_n_a -copycds_a_err -copycds_n_err -xdsh_h -xdsh_V -xdsh_regular_command -xdsh_Q_command -xdsh_c_cn -xdsh_e_filename -xdsh_E -xdsh_i_linux -xdsh_t -xdsh_q -xdsh_T -xdsh_o -switchdiscover_range_default -switchdiscover_h -switchdiscover_range_s -switchdiscover_range_default_w -switchdiscover_range_r -switchdiscover_range_x -switchdiscover_range_z -switchdiscover_range_z_V -nodeset_shell -nodeset_cmdline -nodeset_runimg -nodeset_check_warninginfo -xcatd_start_systemd -xcatd_stop_systemd -xcatd_restart_systemd -run_command_with_XCATBYPASS_systemd -disable_root_permission_in_policy_table_systemd -assign_certain_command_permission_systemd -reg_linux_diskless_installation_flat -reg_linux_statelite_installation_flat +reg_linux_diskfull_installation_flat +makehosts_h +makehosts_help +makehosts_n +makehosts_n_noderange +chdef_null +chdef_z +chdef_t_o_error +chtab_null +chtab_d +chtab_modify_node +chtab_modify_key +chtab_err_symble +chtab_err_table +chtab_h +chtab_v +packimage_o_p_a_m +packimage_p_a_o +packimage_imagename +packimage_h +packimage_v +pping_h +pping_v +pping_node +gettab_key_table +gettab_H +gettab_err +gettab_h +lsdef_null +lsdef_a +lsdef_t_o_l +lsdef_t_o_l_z +lsdef_t +lsdef_t_i_o +lsdef_t_w +lsdef_t_err +lslite_i +lslite_noderange +lslite_h +makeconservercf_null +makeconservercf_noderange +makeconservercf_d +makedhcp_n +makedhcp_a +makedhcp_a_d +makedhcp_d +mkdef_null +mkdef_z +mkdef_t_o_error +nodeadd_noderange +nodeadd_err_symbol +nodeadd_null +nodeadd_noderange_nodetype +nodeadd_v +nodeadd_h +nodegrpch_v +nodegrpch_h +nodegrpch_groups +nodegrpch_err +nodech_noderange_table +nodech_noderange_table_comma +nodech_noderange_table_arrow +nodech_noderanage_table_at +nodech_delete +nodech_error_node +nodech_error_table +nodech_h +nodech_v +nodech_noderange_table_include +nodech_noderange_table_uninclude +nodech_noderange_table_equal +nodech_noderange_table_unequal +nodech_noderange_shortname_groups +nodech_noderange_shortname_tags +nodech_noderange_shortname_mgt +nodels_null +nodels_H +nodels_noderange +nodels_err_symbol +nodels_err_noderange +nodels_noderange_shortname_groups +nodels_noderange_shortname_tags +nodels_noderange_shortname_mgt +nodels_table_include +nodels_noderange_table_uninclude +nodels_noderange_table_equal +nodels_noderange_table_unequal +nodels_b +nodels_S +nodels_noderange_table +nodels_tablevalue +nodels_tablevalue_tablecolumn +nodels_noderange_tablecolumn +nodels_h +nodels_v +xcatstanzafile_normal +xcatstanzafile_colon +xcatstanzafile_attribute +xcatstanzafile_objtype +xcatstanzafile_tab +xcatstanzafile_multattr +xcatstanzafile_defaultvalue +xcatstanzafile_specificvalue +noderm_noderange +noderm_h +noderm_null +noderm_err_node +nodeset_stat +nodeset_noderange +nodestat_noderange +nodestat_err_node +rinv_noderange_err +rmdef_null +rmdef_t_err +rpower_err_noderange +rvitals_noderange_err +tabdump_table +tabdump_d +tabdump_v +tabdump_h +tabdump_help +tabdump_w_match +tabdump_w_equal +tabdump_w_ne +tabdump_w_notmatch +tabdump_w_gt +tabdump_w_ge +tabdump_w_lt +tabdump_w_le +tabdump_f_d +tabdump_d_nodehm +tabprune_h +tabprune_v +tabprune_a_eventlog +tabprune_V_a_eventlog +tabprune_i_auditlog +tabprune_V_n_auditlog +tabgrep_node +tabgrep_null +tabgrep_h +tabgrep_err +tabrestore_table +tabrestore_null +tabrestore_h +tabrestore_err +dumpxCATdb_h +dumpxCATdb_v +dumpxCATdb_p_nullskiptables +dumpxCATdb_a_p_nullskiptables +dumpxCATdb_p_skiptables +dumpxCATdb_a_p_skiptables +dumpxCATdb_p_nullskiptables_V +dumpxCATdb_a_p_nullskiptables_V +dumpxCATdb_p_V +restorexCAT_h +restorexCATdb_v +restorexCATdb_p_V +restorexCATdb_a_p_V +restorexCATdb_wrongpath +regnotif_null +regnotif_o +regnotif_err +regnotif_h +regnotif_v +unregnotif_null +unregnotif_f +unregnotif_h +unregnotif_v +lsxcatd_null +lsxcatd_h +lsxcatd_d +lsxcatd_a +makedns_d_node +makedns_n +makedns +copycds_iso +copycds_n +copycds_a +copycds_n_a +copycds_a_err +copycds_n_err +xdsh_h +xdsh_V +xdsh_regular_command +xdsh_Q_command +xdsh_c_cn +xdsh_e_filename +xdsh_E +xdsh_i_linux +xdsh_t +xdsh_q +xdsh_T +xdsh_o +switchdiscover_range_default +switchdiscover_h +switchdiscover_range_s +switchdiscover_range_default_w +switchdiscover_range_r +switchdiscover_range_x +switchdiscover_range_z +switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg +nodeset_check_warninginfo +xcatd_start_systemd +xcatd_stop_systemd +xcatd_restart_systemd +run_command_with_XCATBYPASS_systemd +disable_root_permission_in_policy_table_systemd +assign_certain_command_permission_systemd +reg_linux_diskless_installation_flat +reg_linux_statelite_installation_flat diff --git a/xCAT-test/autotest/bundle/ubuntu14.04.3_ppc64le.bundle b/xCAT-test/autotest/bundle/ubuntu14.04.3_ppc64le.bundle index c15d8835d..c369a3c47 100644 --- a/xCAT-test/autotest/bundle/ubuntu14.04.3_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/ubuntu14.04.3_ppc64le.bundle @@ -1,247 +1,245 @@ -Diskless_installation_flat_p8_le -Full_installation_flat_p8_le -makehosts_h -makehosts_help -makehosts_n_noderange -makehosts_n -chdef_null -chdef_z -chdef_t_o_error -chtab_null -chtab_d -chtab_modify_node -chtab_modify_key -chtab_h -chtab_v -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_node -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a_ubuntu -makedhcp_d -mkdef_null -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_specificvalue -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_tab -xcatstanzafile_normal -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_err_node -rmdef_null -rmdef_t_err -rpower_err_noderange -rvitals_noderange_err -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -makedns_d_node -makedns_ubuntu_n -copycds_iso -copycds_n -copycds_a -copycds_n_a -copycds_a_err -copycds_n_err -addkit_v -addkit_h -addkit_kit -addkit_i -addkit_multikit -addkit_p -addkitcomp_v -addkitcomp_h -addkitcomp_i -addkitcomp_f -buildkit_v -buildkit_h -buildkit_create -buildkit_create_l -buildkit_cleanrepo_all -buildkit_buildtar -chkkitcomp_v -chkkitcomp_h -chkkitcomp_V -lskit_v -lskit_h -lskit_F -lskit_K -lskit_R -lskit_C -lskitcomp_v -lskitcomp_h -lskitcomp_C -lskitcomp_C -lskitcomp_S -lskitdeployparam_v -lskitdeployparam_h -lskitdeployparam_no_param -lskitdeployparam_k_1 -lskitdeployparam_c_1 -rmkit_v -rmkit_h -rmkit_t_no -rmkit_t_yes -rmkit_f -rmkit_V -rmkitcomp_v -rmkitcomp_h -xdsh_h -xdsh_V -xdsh_regular_command -xdsh_Q_command -xdsh_c_cn -xdsh_e_filename -xdsh_E -xdsh_t -xdsh_q -xdsh_T -xdsh_o -switchdiscover_range_default -switchdiscover_h -switchdiscover_range_s -switchdiscover_range_default_w -switchdiscover_range_r -switchdiscover_range_x -switchdiscover_range_z -switchdiscover_range_z_V -nodeset_shell -nodeset_cmdline -nodeset_runimg -xcatd_start -xcatd_stop -xcatd_restart -run_command_with_XCATBYPASS -disable_root_permission_in_policy_table -assign_certain_command_permission -ubuntu_migration1_p8le -ubuntu_migration2_p8le +Diskless_installation_flat_p8_le +Full_installation_flat_p8_le +makehosts_h +makehosts_help +makehosts_n_noderange +makehosts_n +chdef_null +chdef_z +chdef_t_o_error +chtab_null +chtab_d +chtab_modify_node +chtab_modify_key +chtab_h +chtab_v +packimage_o_p_a_m +packimage_p_a_o +packimage_imagename +packimage_h +packimage_v +pping_h +pping_v +pping_node +gettab_key_table +gettab_H +gettab_err +gettab_h +lsdef_null +lsdef_a +lsdef_t_o_l +lsdef_t_o_l_z +lsdef_t +lsdef_t_i_o +lsdef_t_w +lsdef_t_err +makeconservercf_null +makeconservercf_noderange +makeconservercf_d +makedhcp_n +makedhcp_a_ubuntu +makedhcp_d +mkdef_null +mkdef_z +mkdef_t_o_error +nodeadd_noderange +nodeadd_err_symbol +nodeadd_null +nodeadd_noderange_nodetype +nodeadd_v +nodeadd_h +nodegrpch_v +nodegrpch_h +nodegrpch_groups +nodegrpch_err +nodech_noderange_table +nodech_noderange_table_comma +nodech_noderange_table_arrow +nodech_noderanage_table_at +nodech_delete +nodech_error_node +nodech_error_table +nodech_h +nodech_v +nodech_noderange_table_include +nodech_noderange_table_uninclude +nodech_noderange_table_equal +nodech_noderange_table_unequal +nodech_noderange_shortname_groups +nodech_noderange_shortname_tags +nodech_noderange_shortname_mgt +nodels_null +nodels_H +nodels_noderange +nodels_err_symbol +nodels_err_noderange +nodels_noderange_shortname_groups +nodels_noderange_shortname_tags +nodels_noderange_shortname_mgt +nodels_table_include +nodels_noderange_table_uninclude +nodels_noderange_table_equal +nodels_noderange_table_unequal +nodels_b +nodels_S +nodels_noderange_table +nodels_tablevalue +nodels_tablevalue_tablecolumn +nodels_noderange_tablecolumn +nodels_h +nodels_v +xcatstanzafile_colon +xcatstanzafile_attribute +xcatstanzafile_objtype +xcatstanzafile_specificvalue +xcatstanzafile_multattr +xcatstanzafile_defaultvalue +xcatstanzafile_tab +xcatstanzafile_normal +noderm_noderange +noderm_h +noderm_null +noderm_err_node +nodeset_stat +nodeset_noderange +nodestat_err_node +rmdef_null +rmdef_t_err +rpower_err_noderange +rvitals_noderange_err +tabdump_table +tabdump_d +tabdump_v +tabdump_h +tabdump_help +tabdump_w_match +tabdump_w_equal +tabdump_w_ne +tabdump_w_notmatch +tabdump_w_gt +tabdump_w_ge +tabdump_w_lt +tabdump_w_le +tabdump_f_d +tabdump_d_nodehm +tabprune_h +tabprune_v +tabprune_a_eventlog +tabprune_V_a_eventlog +tabprune_i_auditlog +tabprune_V_n_auditlog +tabgrep_node +tabgrep_null +tabgrep_h +tabgrep_err +tabrestore_table +tabrestore_null +tabrestore_h +tabrestore_err +dumpxCATdb_h +dumpxCATdb_v +dumpxCATdb_p_nullskiptables +dumpxCATdb_a_p_nullskiptables +dumpxCATdb_p_skiptables +dumpxCATdb_a_p_skiptables +dumpxCATdb_p_nullskiptables_V +dumpxCATdb_a_p_nullskiptables_V +dumpxCATdb_p_V +restorexCAT_h +restorexCATdb_v +restorexCATdb_p_V +restorexCATdb_a_p_V +restorexCATdb_wrongpath +regnotif_null +regnotif_o +regnotif_err +regnotif_h +regnotif_v +unregnotif_null +unregnotif_f +unregnotif_h +unregnotif_v +lsxcatd_null +lsxcatd_h +lsxcatd_d +lsxcatd_a +makedns_d_node +makedns_ubuntu_n +copycds_iso +copycds_n +copycds_a +copycds_n_a +copycds_a_err +copycds_n_err +addkit_v +addkit_h +addkit_kit +addkit_i +addkit_multikit +addkit_p +addkitcomp_v +addkitcomp_h +addkitcomp_i +addkitcomp_f +buildkit_v +buildkit_h +buildkit_create +buildkit_create_l +buildkit_cleanrepo_all +buildkit_buildtar +chkkitcomp_v +chkkitcomp_h +chkkitcomp_V +lskit_v +lskit_h +lskit_F +lskit_K +lskit_R +lskit_C +lskitcomp_v +lskitcomp_h +lskitcomp_C +lskitcomp_S +lskitdeployparam_v +lskitdeployparam_h +lskitdeployparam_no_param +lskitdeployparam_k_1 +lskitdeployparam_c_1 +rmkit_v +rmkit_h +rmkit_t_no +rmkit_t_yes +rmkit_f +rmkit_V +rmkitcomp_v +rmkitcomp_h +xdsh_h +xdsh_V +xdsh_regular_command +xdsh_Q_command +xdsh_c_cn +xdsh_e_filename +xdsh_E +xdsh_t +xdsh_q +xdsh_T +xdsh_o +switchdiscover_range_default +switchdiscover_h +switchdiscover_range_s +switchdiscover_range_default_w +switchdiscover_range_r +switchdiscover_range_x +switchdiscover_range_z +switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg +xcatd_start +xcatd_stop +xcatd_restart +run_command_with_XCATBYPASS +disable_root_permission_in_policy_table +assign_certain_command_permission +ubuntu_migration1_p8le +ubuntu_migration2_p8le diff --git a/xCAT-test/autotest/bundle/ubuntu14.04.3_x86_64.bundle b/xCAT-test/autotest/bundle/ubuntu14.04.3_x86_64.bundle index 9847cc792..a43d7cf69 100644 --- a/xCAT-test/autotest/bundle/ubuntu14.04.3_x86_64.bundle +++ b/xCAT-test/autotest/bundle/ubuntu14.04.3_x86_64.bundle @@ -1,264 +1,262 @@ -Ubuntu_diskless_installation_flat_x86_vm -Ubuntu_full_installation_flat_x86_vm -makehosts_h -makehosts_help -makehosts_n_noderange -makehosts_n -chdef_null -chdef_z -chdef_t_o_error -chtab_null -chtab_d -chtab_modify_node -chtab_modify_key -chtab_h -chtab_v -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_node -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a_ubuntu -makedhcp_d -mkdef_null -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_normal -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_tab -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_specificvalue -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_noderange -nodestat_err_node -rmdef_null -rmdef_t_err -rpower_err_noderange -rvitals_noderange_err -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -makedns_d_node -makedns_ubuntu_n -copycds_iso -copycds_n -copycds_a -copycds_n_a -copycds_a_err -copycds_n_err -addkit_v -addkit_h -addkit_kit -addkit_i -addkit_multikit -addkit_p -addkitcomp_v -addkitcomp_h -addkitcomp_i -addkitcomp_f -buildkit_v -buildkit_h -buildkit_create -buildkit_create_l -buildkit_buildrepo_all -buildkit_buildrepo_ubuntu -buildkit_cleanrepo_all -buildkit_cleanrepo_ubuntu -buildkit_listrepo -buildkit_buildtar -buildkit_cleantar -buildkit_partialkit_ubuntu -buildkit_partialkit_completekit -chkkitcomp_v -chkkitcomp_h -chkkitcomp_V -lskit_v -lskit_h -lskit_F -lskit_K -lskit_R -lskit_C -lskitcomp_v -lskitcomp_h -lskitcomp_C -lskitcomp_C -lskitcomp_S -lskitdeployparam_v -lskitdeployparam_h -lskitdeployparam_no_param -lskitdeployparam_k_1 -lskitdeployparam_c_1 -rmkit_v -rmkit_h -rmkit_t_no -rmkit_t_yes -rmkit_f -rmkit_V -rmkitcomp_v -rmkitcomp_h -xdsh_h -xdsh_V -xdsh_regular_command -xdsh_Q_command -xdsh_c_cn -xdsh_e_filename -xdsh_E -xdsh_t -xdsh_q -xdsh_T -xdsh_o -switchdiscover_range_default -switchdiscover_h -switchdiscover_range_s -switchdiscover_range_default_w -switchdiscover_range_r -switchdiscover_range_x -switchdiscover_range_z -switchdiscover_range_z_V -nodeset_shell -nodeset_cmdline -nodeset_runimg -nodeset_check_warninginfo -Full_installation_flat_docker -rpower_stop -rpower_start -rpower_state -rpower_restart -rpower_pause -rpower_unpause -mkdocker_h -mkdocker_command -rmdocker_h -rmdocker_command -rmdocker_f_command -lsdocker_h_command -lsdocker_l_command -ubuntux_migration1_vm -ubuntux_migration2_vm +Ubuntu_diskless_installation_flat_x86_vm +Ubuntu_full_installation_flat_x86_vm +makehosts_h +makehosts_help +makehosts_n_noderange +makehosts_n +chdef_null +chdef_z +chdef_t_o_error +chtab_null +chtab_d +chtab_modify_node +chtab_modify_key +chtab_h +chtab_v +packimage_o_p_a_m +packimage_p_a_o +packimage_imagename +packimage_h +packimage_v +pping_h +pping_v +pping_node +gettab_key_table +gettab_H +gettab_err +gettab_h +lsdef_null +lsdef_a +lsdef_t_o_l +lsdef_t_o_l_z +lsdef_t +lsdef_t_i_o +lsdef_t_w +lsdef_t_err +makeconservercf_null +makeconservercf_noderange +makeconservercf_d +makedhcp_n +makedhcp_a_ubuntu +makedhcp_d +mkdef_null +mkdef_z +mkdef_t_o_error +nodeadd_noderange +nodeadd_err_symbol +nodeadd_null +nodeadd_noderange_nodetype +nodeadd_v +nodeadd_h +nodegrpch_v +nodegrpch_h +nodegrpch_groups +nodegrpch_err +nodech_noderange_table +nodech_noderange_table_comma +nodech_noderange_table_arrow +nodech_noderanage_table_at +nodech_delete +nodech_error_node +nodech_error_table +nodech_h +nodech_v +nodech_noderange_table_include +nodech_noderange_table_uninclude +nodech_noderange_table_equal +nodech_noderange_table_unequal +nodech_noderange_shortname_groups +nodech_noderange_shortname_tags +nodech_noderange_shortname_mgt +nodels_null +nodels_H +nodels_noderange +nodels_err_symbol +nodels_err_noderange +nodels_noderange_shortname_groups +nodels_noderange_shortname_tags +nodels_noderange_shortname_mgt +nodels_table_include +nodels_noderange_table_uninclude +nodels_noderange_table_equal +nodels_noderange_table_unequal +nodels_b +nodels_S +nodels_noderange_table +nodels_tablevalue +nodels_tablevalue_tablecolumn +nodels_noderange_tablecolumn +nodels_h +nodels_v +xcatstanzafile_normal +xcatstanzafile_colon +xcatstanzafile_attribute +xcatstanzafile_objtype +xcatstanzafile_tab +xcatstanzafile_multattr +xcatstanzafile_defaultvalue +xcatstanzafile_specificvalue +noderm_noderange +noderm_h +noderm_null +noderm_err_node +nodeset_stat +nodeset_noderange +nodestat_noderange +nodestat_err_node +rmdef_null +rmdef_t_err +rpower_err_noderange +rvitals_noderange_err +tabdump_table +tabdump_d +tabdump_v +tabdump_h +tabdump_help +tabdump_w_match +tabdump_w_equal +tabdump_w_ne +tabdump_w_notmatch +tabdump_w_gt +tabdump_w_ge +tabdump_w_lt +tabdump_w_le +tabdump_f_d +tabdump_d_nodehm +tabprune_h +tabprune_v +tabprune_a_eventlog +tabprune_V_a_eventlog +tabprune_i_auditlog +tabprune_V_n_auditlog +tabgrep_node +tabgrep_null +tabgrep_h +tabgrep_err +tabrestore_table +tabrestore_null +tabrestore_h +tabrestore_err +dumpxCATdb_h +dumpxCATdb_v +dumpxCATdb_p_nullskiptables +dumpxCATdb_a_p_nullskiptables +dumpxCATdb_p_skiptables +dumpxCATdb_a_p_skiptables +dumpxCATdb_p_nullskiptables_V +dumpxCATdb_a_p_nullskiptables_V +dumpxCATdb_p_V +restorexCAT_h +restorexCATdb_v +restorexCATdb_p_V +restorexCATdb_a_p_V +restorexCATdb_wrongpath +regnotif_null +regnotif_o +regnotif_err +regnotif_h +regnotif_v +unregnotif_null +unregnotif_f +unregnotif_h +unregnotif_v +lsxcatd_null +lsxcatd_h +lsxcatd_d +lsxcatd_a +makedns_d_node +makedns_ubuntu_n +copycds_iso +copycds_n +copycds_a +copycds_n_a +copycds_a_err +copycds_n_err +addkit_v +addkit_h +addkit_kit +addkit_i +addkit_multikit +addkit_p +addkitcomp_v +addkitcomp_h +addkitcomp_i +addkitcomp_f +buildkit_v +buildkit_h +buildkit_create +buildkit_create_l +buildkit_buildrepo_all +buildkit_buildrepo_ubuntu +buildkit_cleanrepo_all +buildkit_cleanrepo_ubuntu +buildkit_listrepo +buildkit_buildtar +buildkit_cleantar +buildkit_partialkit_ubuntu +buildkit_partialkit_completekit +chkkitcomp_v +chkkitcomp_h +chkkitcomp_V +lskit_v +lskit_h +lskit_F +lskit_K +lskit_R +lskit_C +lskitcomp_v +lskitcomp_h +lskitcomp_C +lskitcomp_S +lskitdeployparam_v +lskitdeployparam_h +lskitdeployparam_no_param +lskitdeployparam_k_1 +lskitdeployparam_c_1 +rmkit_v +rmkit_h +rmkit_t_no +rmkit_t_yes +rmkit_f +rmkit_V +rmkitcomp_v +rmkitcomp_h +xdsh_h +xdsh_V +xdsh_regular_command +xdsh_Q_command +xdsh_c_cn +xdsh_e_filename +xdsh_E +xdsh_t +xdsh_q +xdsh_T +xdsh_o +switchdiscover_range_default +switchdiscover_h +switchdiscover_range_s +switchdiscover_range_default_w +switchdiscover_range_r +switchdiscover_range_x +switchdiscover_range_z +switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg +nodeset_check_warninginfo +Full_installation_flat_docker +rpower_stop +rpower_start +rpower_state +rpower_restart +rpower_pause +rpower_unpause +mkdocker_h +mkdocker_command +rmdocker_h +rmdocker_command +rmdocker_f_command +lsdocker_h_command +lsdocker_l_command +ubuntux_migration1_vm +ubuntux_migration2_vm diff --git a/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle b/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle index d93f4ad1d..36ec63e99 100644 --- a/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle @@ -1,245 +1,243 @@ -Diskless_installation_flat_p8_le -Full_installation_flat_p8_le -makehosts_h -makehosts_help -makehosts_n_noderange -makehosts_n -chdef_null -chdef_z -chdef_t_o_error -chtab_null -chtab_d -chtab_modify_node -chtab_modify_key -chtab_h -chtab_v -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_node -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a_ubuntu -makedhcp_d -mkdef_null -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_specificvalue -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_tab -xcatstanzafile_normal -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_err_node -rmdef_null -rmdef_t_err -rpower_err_noderange -rvitals_noderange_err -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -makedns_d_node -makedns_ubuntu_n -copycds_iso -copycds_n -copycds_a -copycds_n_a -copycds_a_err -copycds_n_err -addkit_v -addkit_h -addkit_kit -addkit_i -addkit_multikit -addkit_p -addkitcomp_v -addkitcomp_h -addkitcomp_i -addkitcomp_f -buildkit_v -buildkit_h -buildkit_create -buildkit_create_l -buildkit_cleanrepo_all -buildkit_buildtar -chkkitcomp_v -chkkitcomp_h -chkkitcomp_V -lskit_v -lskit_h -lskit_F -lskit_K -lskit_R -lskit_C -lskitcomp_v -lskitcomp_h -lskitcomp_C -lskitcomp_C -lskitcomp_S -lskitdeployparam_v -lskitdeployparam_h -lskitdeployparam_no_param -lskitdeployparam_k_1 -lskitdeployparam_c_1 -rmkit_v -rmkit_h -rmkit_t_no -rmkit_t_yes -rmkit_f -rmkit_V -rmkitcomp_v -rmkitcomp_h -xdsh_h -xdsh_V -xdsh_regular_command -xdsh_Q_command -xdsh_c_cn -xdsh_e_filename -xdsh_E -xdsh_t -xdsh_q -xdsh_T -xdsh_o -switchdiscover_range_default -switchdiscover_h -switchdiscover_range_s -switchdiscover_range_default_w -switchdiscover_range_r -switchdiscover_range_x -switchdiscover_range_z -switchdiscover_range_z_V -nodeset_shell -nodeset_cmdline -nodeset_runimg -xcatd_start -xcatd_stop -xcatd_restart -run_command_with_XCATBYPASS -disable_root_permission_in_policy_table -assign_certain_command_permission +Diskless_installation_flat_p8_le +Full_installation_flat_p8_le +makehosts_h +makehosts_help +makehosts_n_noderange +makehosts_n +chdef_null +chdef_z +chdef_t_o_error +chtab_null +chtab_d +chtab_modify_node +chtab_modify_key +chtab_h +chtab_v +packimage_o_p_a_m +packimage_p_a_o +packimage_imagename +packimage_h +packimage_v +pping_h +pping_v +pping_node +gettab_key_table +gettab_H +gettab_err +gettab_h +lsdef_null +lsdef_a +lsdef_t_o_l +lsdef_t_o_l_z +lsdef_t +lsdef_t_i_o +lsdef_t_w +lsdef_t_err +makeconservercf_null +makeconservercf_noderange +makeconservercf_d +makedhcp_n +makedhcp_a_ubuntu +makedhcp_d +mkdef_null +mkdef_z +mkdef_t_o_error +nodeadd_noderange +nodeadd_err_symbol +nodeadd_null +nodeadd_noderange_nodetype +nodeadd_v +nodeadd_h +nodegrpch_v +nodegrpch_h +nodegrpch_groups +nodegrpch_err +nodech_noderange_table +nodech_noderange_table_comma +nodech_noderange_table_arrow +nodech_noderanage_table_at +nodech_delete +nodech_error_node +nodech_error_table +nodech_h +nodech_v +nodech_noderange_table_include +nodech_noderange_table_uninclude +nodech_noderange_table_equal +nodech_noderange_table_unequal +nodech_noderange_shortname_groups +nodech_noderange_shortname_tags +nodech_noderange_shortname_mgt +nodels_null +nodels_H +nodels_noderange +nodels_err_symbol +nodels_err_noderange +nodels_noderange_shortname_groups +nodels_noderange_shortname_tags +nodels_noderange_shortname_mgt +nodels_table_include +nodels_noderange_table_uninclude +nodels_noderange_table_equal +nodels_noderange_table_unequal +nodels_b +nodels_S +nodels_noderange_table +nodels_tablevalue +nodels_tablevalue_tablecolumn +nodels_noderange_tablecolumn +nodels_h +nodels_v +xcatstanzafile_colon +xcatstanzafile_attribute +xcatstanzafile_objtype +xcatstanzafile_specificvalue +xcatstanzafile_multattr +xcatstanzafile_defaultvalue +xcatstanzafile_tab +xcatstanzafile_normal +noderm_noderange +noderm_h +noderm_null +noderm_err_node +nodeset_stat +nodeset_noderange +nodestat_err_node +rmdef_null +rmdef_t_err +rpower_err_noderange +rvitals_noderange_err +tabdump_table +tabdump_d +tabdump_v +tabdump_h +tabdump_help +tabdump_w_match +tabdump_w_equal +tabdump_w_ne +tabdump_w_notmatch +tabdump_w_gt +tabdump_w_ge +tabdump_w_lt +tabdump_w_le +tabdump_f_d +tabdump_d_nodehm +tabprune_h +tabprune_v +tabprune_a_eventlog +tabprune_V_a_eventlog +tabprune_i_auditlog +tabprune_V_n_auditlog +tabgrep_node +tabgrep_null +tabgrep_h +tabgrep_err +tabrestore_table +tabrestore_null +tabrestore_h +tabrestore_err +dumpxCATdb_h +dumpxCATdb_v +dumpxCATdb_p_nullskiptables +dumpxCATdb_a_p_nullskiptables +dumpxCATdb_p_skiptables +dumpxCATdb_a_p_skiptables +dumpxCATdb_p_nullskiptables_V +dumpxCATdb_a_p_nullskiptables_V +dumpxCATdb_p_V +restorexCAT_h +restorexCATdb_v +restorexCATdb_p_V +restorexCATdb_a_p_V +restorexCATdb_wrongpath +regnotif_null +regnotif_o +regnotif_err +regnotif_h +regnotif_v +unregnotif_null +unregnotif_f +unregnotif_h +unregnotif_v +lsxcatd_null +lsxcatd_h +lsxcatd_d +lsxcatd_a +makedns_d_node +makedns_ubuntu_n +copycds_iso +copycds_n +copycds_a +copycds_n_a +copycds_a_err +copycds_n_err +addkit_v +addkit_h +addkit_kit +addkit_i +addkit_multikit +addkit_p +addkitcomp_v +addkitcomp_h +addkitcomp_i +addkitcomp_f +buildkit_v +buildkit_h +buildkit_create +buildkit_create_l +buildkit_cleanrepo_all +buildkit_buildtar +chkkitcomp_v +chkkitcomp_h +chkkitcomp_V +lskit_v +lskit_h +lskit_F +lskit_K +lskit_R +lskit_C +lskitcomp_v +lskitcomp_h +lskitcomp_C +lskitcomp_S +lskitdeployparam_v +lskitdeployparam_h +lskitdeployparam_no_param +lskitdeployparam_k_1 +lskitdeployparam_c_1 +rmkit_v +rmkit_h +rmkit_t_no +rmkit_t_yes +rmkit_f +rmkit_V +rmkitcomp_v +rmkitcomp_h +xdsh_h +xdsh_V +xdsh_regular_command +xdsh_Q_command +xdsh_c_cn +xdsh_e_filename +xdsh_E +xdsh_t +xdsh_q +xdsh_T +xdsh_o +switchdiscover_range_default +switchdiscover_h +switchdiscover_range_s +switchdiscover_range_default_w +switchdiscover_range_r +switchdiscover_range_x +switchdiscover_range_z +switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg +xcatd_start +xcatd_stop +xcatd_restart +run_command_with_XCATBYPASS +disable_root_permission_in_policy_table +assign_certain_command_permission diff --git a/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle b/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle index f8e5006ad..7a307a29d 100644 --- a/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle +++ b/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle @@ -1,262 +1,260 @@ -Ubuntu_diskless_installation_flat_x86_vm -Ubuntu_full_installation_flat_x86_vm -makehosts_h -makehosts_help -makehosts_n_noderange -makehosts_n -chdef_null -chdef_z -chdef_t_o_error -chtab_null -chtab_d -chtab_modify_node -chtab_modify_key -chtab_h -chtab_v -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_node -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a_ubuntu -makedhcp_d -mkdef_null -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_normal -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_tab -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_specificvalue -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_noderange -nodestat_err_node -rmdef_null -rmdef_t_err -rpower_err_noderange -rvitals_noderange_err -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -makedns_d_node -makedns_ubuntu_n -copycds_iso -copycds_n -copycds_a -copycds_n_a -copycds_a_err -copycds_n_err -addkit_v -addkit_h -addkit_kit -addkit_i -addkit_multikit -addkit_p -addkitcomp_v -addkitcomp_h -addkitcomp_i -addkitcomp_f -buildkit_v -buildkit_h -buildkit_create -buildkit_create_l -buildkit_buildrepo_all -buildkit_buildrepo_ubuntu -buildkit_cleanrepo_all -buildkit_cleanrepo_ubuntu -buildkit_listrepo -buildkit_buildtar -buildkit_cleantar -buildkit_partialkit_ubuntu -buildkit_partialkit_completekit -chkkitcomp_v -chkkitcomp_h -chkkitcomp_V -lskit_v -lskit_h -lskit_F -lskit_K -lskit_R -lskit_C -lskitcomp_v -lskitcomp_h -lskitcomp_C -lskitcomp_C -lskitcomp_S -lskitdeployparam_v -lskitdeployparam_h -lskitdeployparam_no_param -lskitdeployparam_k_1 -lskitdeployparam_c_1 -rmkit_v -rmkit_h -rmkit_t_no -rmkit_t_yes -rmkit_f -rmkit_V -rmkitcomp_v -rmkitcomp_h -xdsh_h -xdsh_V -xdsh_regular_command -xdsh_Q_command -xdsh_c_cn -xdsh_e_filename -xdsh_E -xdsh_t -xdsh_q -xdsh_T -xdsh_o -switchdiscover_range_default -switchdiscover_h -switchdiscover_range_s -switchdiscover_range_default_w -switchdiscover_range_r -switchdiscover_range_x -switchdiscover_range_z -switchdiscover_range_z_V -nodeset_shell -nodeset_cmdline -nodeset_runimg -nodeset_check_warninginfo -Full_installation_flat_docker -rpower_stop -rpower_start -rpower_state -rpower_restart -rpower_pause -rpower_unpause -mkdocker_h -mkdocker_command -rmdocker_h -rmdocker_command -rmdocker_f_command -lsdocker_h_command -lsdocker_l_command +Ubuntu_diskless_installation_flat_x86_vm +Ubuntu_full_installation_flat_x86_vm +makehosts_h +makehosts_help +makehosts_n_noderange +makehosts_n +chdef_null +chdef_z +chdef_t_o_error +chtab_null +chtab_d +chtab_modify_node +chtab_modify_key +chtab_h +chtab_v +packimage_o_p_a_m +packimage_p_a_o +packimage_imagename +packimage_h +packimage_v +pping_h +pping_v +pping_node +gettab_key_table +gettab_H +gettab_err +gettab_h +lsdef_null +lsdef_a +lsdef_t_o_l +lsdef_t_o_l_z +lsdef_t +lsdef_t_i_o +lsdef_t_w +lsdef_t_err +makeconservercf_null +makeconservercf_noderange +makeconservercf_d +makedhcp_n +makedhcp_a_ubuntu +makedhcp_d +mkdef_null +mkdef_z +mkdef_t_o_error +nodeadd_noderange +nodeadd_err_symbol +nodeadd_null +nodeadd_noderange_nodetype +nodeadd_v +nodeadd_h +nodegrpch_v +nodegrpch_h +nodegrpch_groups +nodegrpch_err +nodech_noderange_table +nodech_noderange_table_comma +nodech_noderange_table_arrow +nodech_noderanage_table_at +nodech_delete +nodech_error_node +nodech_error_table +nodech_h +nodech_v +nodech_noderange_table_include +nodech_noderange_table_uninclude +nodech_noderange_table_equal +nodech_noderange_table_unequal +nodech_noderange_shortname_groups +nodech_noderange_shortname_tags +nodech_noderange_shortname_mgt +nodels_null +nodels_H +nodels_noderange +nodels_err_symbol +nodels_err_noderange +nodels_noderange_shortname_groups +nodels_noderange_shortname_tags +nodels_noderange_shortname_mgt +nodels_table_include +nodels_noderange_table_uninclude +nodels_noderange_table_equal +nodels_noderange_table_unequal +nodels_b +nodels_S +nodels_noderange_table +nodels_tablevalue +nodels_tablevalue_tablecolumn +nodels_noderange_tablecolumn +nodels_h +nodels_v +xcatstanzafile_normal +xcatstanzafile_colon +xcatstanzafile_attribute +xcatstanzafile_objtype +xcatstanzafile_tab +xcatstanzafile_multattr +xcatstanzafile_defaultvalue +xcatstanzafile_specificvalue +noderm_noderange +noderm_h +noderm_null +noderm_err_node +nodeset_stat +nodeset_noderange +nodestat_noderange +nodestat_err_node +rmdef_null +rmdef_t_err +rpower_err_noderange +rvitals_noderange_err +tabdump_table +tabdump_d +tabdump_v +tabdump_h +tabdump_help +tabdump_w_match +tabdump_w_equal +tabdump_w_ne +tabdump_w_notmatch +tabdump_w_gt +tabdump_w_ge +tabdump_w_lt +tabdump_w_le +tabdump_f_d +tabdump_d_nodehm +tabprune_h +tabprune_v +tabprune_a_eventlog +tabprune_V_a_eventlog +tabprune_i_auditlog +tabprune_V_n_auditlog +tabgrep_node +tabgrep_null +tabgrep_h +tabgrep_err +tabrestore_table +tabrestore_null +tabrestore_h +tabrestore_err +dumpxCATdb_h +dumpxCATdb_v +dumpxCATdb_p_nullskiptables +dumpxCATdb_a_p_nullskiptables +dumpxCATdb_p_skiptables +dumpxCATdb_a_p_skiptables +dumpxCATdb_p_nullskiptables_V +dumpxCATdb_a_p_nullskiptables_V +dumpxCATdb_p_V +restorexCAT_h +restorexCATdb_v +restorexCATdb_p_V +restorexCATdb_a_p_V +restorexCATdb_wrongpath +regnotif_null +regnotif_o +regnotif_err +regnotif_h +regnotif_v +unregnotif_null +unregnotif_f +unregnotif_h +unregnotif_v +lsxcatd_null +lsxcatd_h +lsxcatd_d +lsxcatd_a +makedns_d_node +makedns_ubuntu_n +copycds_iso +copycds_n +copycds_a +copycds_n_a +copycds_a_err +copycds_n_err +addkit_v +addkit_h +addkit_kit +addkit_i +addkit_multikit +addkit_p +addkitcomp_v +addkitcomp_h +addkitcomp_i +addkitcomp_f +buildkit_v +buildkit_h +buildkit_create +buildkit_create_l +buildkit_buildrepo_all +buildkit_buildrepo_ubuntu +buildkit_cleanrepo_all +buildkit_cleanrepo_ubuntu +buildkit_listrepo +buildkit_buildtar +buildkit_cleantar +buildkit_partialkit_ubuntu +buildkit_partialkit_completekit +chkkitcomp_v +chkkitcomp_h +chkkitcomp_V +lskit_v +lskit_h +lskit_F +lskit_K +lskit_R +lskit_C +lskitcomp_v +lskitcomp_h +lskitcomp_C +lskitcomp_S +lskitdeployparam_v +lskitdeployparam_h +lskitdeployparam_no_param +lskitdeployparam_k_1 +lskitdeployparam_c_1 +rmkit_v +rmkit_h +rmkit_t_no +rmkit_t_yes +rmkit_f +rmkit_V +rmkitcomp_v +rmkitcomp_h +xdsh_h +xdsh_V +xdsh_regular_command +xdsh_Q_command +xdsh_c_cn +xdsh_e_filename +xdsh_E +xdsh_t +xdsh_q +xdsh_T +xdsh_o +switchdiscover_range_default +switchdiscover_h +switchdiscover_range_s +switchdiscover_range_default_w +switchdiscover_range_r +switchdiscover_range_x +switchdiscover_range_z +switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg +nodeset_check_warninginfo +Full_installation_flat_docker +rpower_stop +rpower_start +rpower_state +rpower_restart +rpower_pause +rpower_unpause +mkdocker_h +mkdocker_command +rmdocker_h +rmdocker_command +rmdocker_f_command +lsdocker_h_command +lsdocker_l_command diff --git a/xCAT-test/autotest/bundle/ubuntu16.04_ppc64le.bundle b/xCAT-test/autotest/bundle/ubuntu16.04_ppc64le.bundle index 0857fb8ae..32328d594 100644 --- a/xCAT-test/autotest/bundle/ubuntu16.04_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/ubuntu16.04_ppc64le.bundle @@ -1,245 +1,243 @@ -Diskless_installation_flat_p8_le -Full_installation_flat_p8_le -makehosts_h -makehosts_help -makehosts_n_noderange -makehosts_n -chdef_null -chdef_z -chdef_t_o_error -chtab_null -chtab_d -chtab_modify_node -chtab_modify_key -chtab_h -chtab_v -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_node -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a_ubuntu -makedhcp_d -mkdef_null -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_specificvalue -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_tab -xcatstanzafile_normal -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_err_node -rmdef_null -rmdef_t_err -rpower_err_noderange -rvitals_noderange_err -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -makedns_d_node -makedns_ubuntu_n -copycds_iso -copycds_n -copycds_a -copycds_n_a -copycds_a_err -copycds_n_err -addkit_v -addkit_h -addkit_kit -addkit_i -addkit_multikit -addkit_p -addkitcomp_v -addkitcomp_h -addkitcomp_i -addkitcomp_f -buildkit_v -buildkit_h -buildkit_create -buildkit_create_l -buildkit_cleanrepo_all -buildkit_buildtar -chkkitcomp_v -chkkitcomp_h -chkkitcomp_V -lskit_v -lskit_h -lskit_F -lskit_K -lskit_R -lskit_C -lskitcomp_v -lskitcomp_h -lskitcomp_C -lskitcomp_C -lskitcomp_S -lskitdeployparam_v -lskitdeployparam_h -lskitdeployparam_no_param -lskitdeployparam_k_1 -lskitdeployparam_c_1 -rmkit_v -rmkit_h -rmkit_t_no -rmkit_t_yes -rmkit_f -rmkit_V -rmkitcomp_v -rmkitcomp_h -xdsh_h -xdsh_V -xdsh_regular_command -xdsh_Q_command -xdsh_c_cn -xdsh_e_filename -xdsh_E -xdsh_t -xdsh_q -xdsh_T -xdsh_o -switchdiscover_range_default -switchdiscover_h -switchdiscover_range_s -switchdiscover_range_default_w -switchdiscover_range_r -switchdiscover_range_x -switchdiscover_range_z -switchdiscover_range_z_V -nodeset_shell -nodeset_cmdline -nodeset_runimg -xcatd_start_systemd -xcatd_stop_systemd -xcatd_restart_systemd -run_command_with_XCATBYPASS_systemd -disable_root_permission_in_policy_table_systemd -assign_certain_command_permission_systemd +Diskless_installation_flat_p8_le +Full_installation_flat_p8_le +makehosts_h +makehosts_help +makehosts_n_noderange +makehosts_n +chdef_null +chdef_z +chdef_t_o_error +chtab_null +chtab_d +chtab_modify_node +chtab_modify_key +chtab_h +chtab_v +packimage_o_p_a_m +packimage_p_a_o +packimage_imagename +packimage_h +packimage_v +pping_h +pping_v +pping_node +gettab_key_table +gettab_H +gettab_err +gettab_h +lsdef_null +lsdef_a +lsdef_t_o_l +lsdef_t_o_l_z +lsdef_t +lsdef_t_i_o +lsdef_t_w +lsdef_t_err +makeconservercf_null +makeconservercf_noderange +makeconservercf_d +makedhcp_n +makedhcp_a_ubuntu +makedhcp_d +mkdef_null +mkdef_z +mkdef_t_o_error +nodeadd_noderange +nodeadd_err_symbol +nodeadd_null +nodeadd_noderange_nodetype +nodeadd_v +nodeadd_h +nodegrpch_v +nodegrpch_h +nodegrpch_groups +nodegrpch_err +nodech_noderange_table +nodech_noderange_table_comma +nodech_noderange_table_arrow +nodech_noderanage_table_at +nodech_delete +nodech_error_node +nodech_error_table +nodech_h +nodech_v +nodech_noderange_table_include +nodech_noderange_table_uninclude +nodech_noderange_table_equal +nodech_noderange_table_unequal +nodech_noderange_shortname_groups +nodech_noderange_shortname_tags +nodech_noderange_shortname_mgt +nodels_null +nodels_H +nodels_noderange +nodels_err_symbol +nodels_err_noderange +nodels_noderange_shortname_groups +nodels_noderange_shortname_tags +nodels_noderange_shortname_mgt +nodels_table_include +nodels_noderange_table_uninclude +nodels_noderange_table_equal +nodels_noderange_table_unequal +nodels_b +nodels_S +nodels_noderange_table +nodels_tablevalue +nodels_tablevalue_tablecolumn +nodels_noderange_tablecolumn +nodels_h +nodels_v +xcatstanzafile_colon +xcatstanzafile_attribute +xcatstanzafile_objtype +xcatstanzafile_specificvalue +xcatstanzafile_multattr +xcatstanzafile_defaultvalue +xcatstanzafile_tab +xcatstanzafile_normal +noderm_noderange +noderm_h +noderm_null +noderm_err_node +nodeset_stat +nodeset_noderange +nodestat_err_node +rmdef_null +rmdef_t_err +rpower_err_noderange +rvitals_noderange_err +tabdump_table +tabdump_d +tabdump_v +tabdump_h +tabdump_help +tabdump_w_match +tabdump_w_equal +tabdump_w_ne +tabdump_w_notmatch +tabdump_w_gt +tabdump_w_ge +tabdump_w_lt +tabdump_w_le +tabdump_f_d +tabdump_d_nodehm +tabprune_h +tabprune_v +tabprune_a_eventlog +tabprune_V_a_eventlog +tabprune_i_auditlog +tabprune_V_n_auditlog +tabgrep_node +tabgrep_null +tabgrep_h +tabgrep_err +tabrestore_table +tabrestore_null +tabrestore_h +tabrestore_err +dumpxCATdb_h +dumpxCATdb_v +dumpxCATdb_p_nullskiptables +dumpxCATdb_a_p_nullskiptables +dumpxCATdb_p_skiptables +dumpxCATdb_a_p_skiptables +dumpxCATdb_p_nullskiptables_V +dumpxCATdb_a_p_nullskiptables_V +dumpxCATdb_p_V +restorexCAT_h +restorexCATdb_v +restorexCATdb_p_V +restorexCATdb_a_p_V +restorexCATdb_wrongpath +regnotif_null +regnotif_o +regnotif_err +regnotif_h +regnotif_v +unregnotif_null +unregnotif_f +unregnotif_h +unregnotif_v +lsxcatd_null +lsxcatd_h +lsxcatd_d +lsxcatd_a +makedns_d_node +makedns_ubuntu_n +copycds_iso +copycds_n +copycds_a +copycds_n_a +copycds_a_err +copycds_n_err +addkit_v +addkit_h +addkit_kit +addkit_i +addkit_multikit +addkit_p +addkitcomp_v +addkitcomp_h +addkitcomp_i +addkitcomp_f +buildkit_v +buildkit_h +buildkit_create +buildkit_create_l +buildkit_cleanrepo_all +buildkit_buildtar +chkkitcomp_v +chkkitcomp_h +chkkitcomp_V +lskit_v +lskit_h +lskit_F +lskit_K +lskit_R +lskit_C +lskitcomp_v +lskitcomp_h +lskitcomp_C +lskitcomp_S +lskitdeployparam_v +lskitdeployparam_h +lskitdeployparam_no_param +lskitdeployparam_k_1 +lskitdeployparam_c_1 +rmkit_v +rmkit_h +rmkit_t_no +rmkit_t_yes +rmkit_f +rmkit_V +rmkitcomp_v +rmkitcomp_h +xdsh_h +xdsh_V +xdsh_regular_command +xdsh_Q_command +xdsh_c_cn +xdsh_e_filename +xdsh_E +xdsh_t +xdsh_q +xdsh_T +xdsh_o +switchdiscover_range_default +switchdiscover_h +switchdiscover_range_s +switchdiscover_range_default_w +switchdiscover_range_r +switchdiscover_range_x +switchdiscover_range_z +switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg +xcatd_start_systemd +xcatd_stop_systemd +xcatd_restart_systemd +run_command_with_XCATBYPASS_systemd +disable_root_permission_in_policy_table_systemd +assign_certain_command_permission_systemd diff --git a/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle b/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle index 15c77f4a6..8413bfedc 100644 --- a/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle +++ b/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle @@ -1,254 +1,252 @@ -Ubuntu_diskless_installation_flat_x86_vm -Ubuntu_full_installation_flat_x86_vm -makehosts_h -makehosts_help -makehosts_n_noderange -makehosts_n -chdef_null -chdef_z -chdef_t_o_error -chtab_null -chtab_d -chtab_modify_node -chtab_modify_key -chtab_h -chtab_v -packimage_o_p_a_m -packimage_p_a_o -packimage_imagename -packimage_h -packimage_v -pping_h -pping_v -pping_node -gettab_key_table -gettab_H -gettab_err -gettab_h -lsdef_null -lsdef_a -lsdef_t_o_l -lsdef_t_o_l_z -lsdef_t -lsdef_t_i_o -lsdef_t_w -lsdef_t_err -makeconservercf_null -makeconservercf_noderange -makeconservercf_d -makedhcp_n -makedhcp_a_ubuntu -makedhcp_d -mkdef_null -mkdef_z -mkdef_t_o_error -nodeadd_noderange -nodeadd_err_symbol -nodeadd_null -nodeadd_noderange_nodetype -nodeadd_v -nodeadd_h -nodegrpch_v -nodegrpch_h -nodegrpch_groups -nodegrpch_err -nodech_noderange_table -nodech_noderange_table_comma -nodech_noderange_table_arrow -nodech_noderanage_table_at -nodech_delete -nodech_error_node -nodech_error_table -nodech_h -nodech_v -nodech_noderange_table_include -nodech_noderange_table_uninclude -nodech_noderange_table_equal -nodech_noderange_table_unequal -nodech_noderange_shortname_groups -nodech_noderange_shortname_tags -nodech_noderange_shortname_mgt -nodels_null -nodels_H -nodels_noderange -nodels_err_symbol -nodels_err_noderange -nodels_noderange_shortname_groups -nodels_noderange_shortname_tags -nodels_noderange_shortname_mgt -nodels_table_include -nodels_noderange_table_uninclude -nodels_noderange_table_equal -nodels_noderange_table_unequal -nodels_b -nodels_S -nodels_noderange_table -nodels_tablevalue -nodels_tablevalue_tablecolumn -nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn -nodels_h -nodels_v -xcatstanzafile_normal -xcatstanzafile_colon -xcatstanzafile_attribute -xcatstanzafile_objtype -xcatstanzafile_tab -xcatstanzafile_multattr -xcatstanzafile_defaultvalue -xcatstanzafile_specificvalue -noderm_noderange -noderm_h -noderm_null -noderm_err_node -nodeset_stat -nodeset_noderange -nodestat_noderange -nodestat_err_node -rmdef_null -rmdef_t_err -rpower_err_noderange -rvitals_noderange_err -tabdump_table -tabdump_d -tabdump_v -tabdump_h -tabdump_help -tabdump_w_match -tabdump_w_equal -tabdump_w_ne -tabdump_w_notmatch -tabdump_w_gt -tabdump_w_ge -tabdump_w_lt -tabdump_w_le -tabdump_f_d -tabdump_d_nodehm -tabprune_h -tabprune_v -tabprune_a_eventlog -tabprune_V_a_eventlog -tabprune_i_auditlog -tabprune_V_n_auditlog -tabgrep_node -tabgrep_null -tabgrep_h -tabgrep_err -tabrestore_table -tabrestore_null -tabrestore_h -tabrestore_err -dumpxCATdb_h -dumpxCATdb_v -dumpxCATdb_p_nullskiptables -dumpxCATdb_a_p_nullskiptables -dumpxCATdb_p_skiptables -dumpxCATdb_a_p_skiptables -dumpxCATdb_p_nullskiptables_V -dumpxCATdb_a_p_nullskiptables_V -dumpxCATdb_p_V -restorexCAT_h -restorexCATdb_v -restorexCATdb_p_V -restorexCATdb_a_p_V -restorexCATdb_wrongpath -regnotif_null -regnotif_o -regnotif_err -regnotif_h -regnotif_v -unregnotif_null -unregnotif_f -unregnotif_h -unregnotif_v -lsxcatd_null -lsxcatd_h -lsxcatd_d -lsxcatd_a -makedns_d_node -makedns_ubuntu_n -copycds_iso -copycds_n -copycds_a -copycds_n_a -copycds_a_err -copycds_n_err -addkit_v -addkit_h -addkit_kit -addkit_i -addkit_multikit -addkit_p -addkitcomp_v -addkitcomp_h -addkitcomp_i -addkitcomp_f -buildkit_v -buildkit_h -buildkit_create -buildkit_create_l -buildkit_buildrepo_all -buildkit_buildrepo_ubuntu -buildkit_cleanrepo_all -buildkit_cleanrepo_ubuntu -buildkit_listrepo -buildkit_buildtar -buildkit_cleantar -buildkit_partialkit_ubuntu -buildkit_partialkit_completekit -chkkitcomp_v -chkkitcomp_h -chkkitcomp_V -lskit_v -lskit_h -lskit_F -lskit_K -lskit_R -lskit_C -lskitcomp_v -lskitcomp_h -lskitcomp_C -lskitcomp_C -lskitcomp_S -lskitdeployparam_v -lskitdeployparam_h -lskitdeployparam_no_param -lskitdeployparam_k_1 -lskitdeployparam_c_1 -rmkit_v -rmkit_h -rmkit_t_no -rmkit_t_yes -rmkit_f -rmkit_V -rmkitcomp_v -rmkitcomp_h -xdsh_h -xdsh_V -xdsh_regular_command -xdsh_Q_command -xdsh_c_cn -xdsh_e_filename -xdsh_E -xdsh_t -xdsh_q -xdsh_T -xdsh_o -switchdiscover_range_default -switchdiscover_h -switchdiscover_range_s -switchdiscover_range_default_w -switchdiscover_range_r -switchdiscover_range_x -switchdiscover_range_z -switchdiscover_range_z_V -nodeset_shell -nodeset_cmdline -nodeset_runimg -xcatd_start_systemd -xcatd_stop_systemd -xcatd_restart_systemd -run_command_with_XCATBYPASS_systemd -disable_root_permission_in_policy_table_systemd -assign_certain_command_permission_systemd -nodeset_check_warninginfo +Ubuntu_diskless_installation_flat_x86_vm +Ubuntu_full_installation_flat_x86_vm +makehosts_h +makehosts_help +makehosts_n_noderange +makehosts_n +chdef_null +chdef_z +chdef_t_o_error +chtab_null +chtab_d +chtab_modify_node +chtab_modify_key +chtab_h +chtab_v +packimage_o_p_a_m +packimage_p_a_o +packimage_imagename +packimage_h +packimage_v +pping_h +pping_v +pping_node +gettab_key_table +gettab_H +gettab_err +gettab_h +lsdef_null +lsdef_a +lsdef_t_o_l +lsdef_t_o_l_z +lsdef_t +lsdef_t_i_o +lsdef_t_w +lsdef_t_err +makeconservercf_null +makeconservercf_noderange +makeconservercf_d +makedhcp_n +makedhcp_a_ubuntu +makedhcp_d +mkdef_null +mkdef_z +mkdef_t_o_error +nodeadd_noderange +nodeadd_err_symbol +nodeadd_null +nodeadd_noderange_nodetype +nodeadd_v +nodeadd_h +nodegrpch_v +nodegrpch_h +nodegrpch_groups +nodegrpch_err +nodech_noderange_table +nodech_noderange_table_comma +nodech_noderange_table_arrow +nodech_noderanage_table_at +nodech_delete +nodech_error_node +nodech_error_table +nodech_h +nodech_v +nodech_noderange_table_include +nodech_noderange_table_uninclude +nodech_noderange_table_equal +nodech_noderange_table_unequal +nodech_noderange_shortname_groups +nodech_noderange_shortname_tags +nodech_noderange_shortname_mgt +nodels_null +nodels_H +nodels_noderange +nodels_err_symbol +nodels_err_noderange +nodels_noderange_shortname_groups +nodels_noderange_shortname_tags +nodels_noderange_shortname_mgt +nodels_table_include +nodels_noderange_table_uninclude +nodels_noderange_table_equal +nodels_noderange_table_unequal +nodels_b +nodels_S +nodels_noderange_table +nodels_tablevalue +nodels_tablevalue_tablecolumn +nodels_noderange_tablecolumn +nodels_h +nodels_v +xcatstanzafile_normal +xcatstanzafile_colon +xcatstanzafile_attribute +xcatstanzafile_objtype +xcatstanzafile_tab +xcatstanzafile_multattr +xcatstanzafile_defaultvalue +xcatstanzafile_specificvalue +noderm_noderange +noderm_h +noderm_null +noderm_err_node +nodeset_stat +nodeset_noderange +nodestat_noderange +nodestat_err_node +rmdef_null +rmdef_t_err +rpower_err_noderange +rvitals_noderange_err +tabdump_table +tabdump_d +tabdump_v +tabdump_h +tabdump_help +tabdump_w_match +tabdump_w_equal +tabdump_w_ne +tabdump_w_notmatch +tabdump_w_gt +tabdump_w_ge +tabdump_w_lt +tabdump_w_le +tabdump_f_d +tabdump_d_nodehm +tabprune_h +tabprune_v +tabprune_a_eventlog +tabprune_V_a_eventlog +tabprune_i_auditlog +tabprune_V_n_auditlog +tabgrep_node +tabgrep_null +tabgrep_h +tabgrep_err +tabrestore_table +tabrestore_null +tabrestore_h +tabrestore_err +dumpxCATdb_h +dumpxCATdb_v +dumpxCATdb_p_nullskiptables +dumpxCATdb_a_p_nullskiptables +dumpxCATdb_p_skiptables +dumpxCATdb_a_p_skiptables +dumpxCATdb_p_nullskiptables_V +dumpxCATdb_a_p_nullskiptables_V +dumpxCATdb_p_V +restorexCAT_h +restorexCATdb_v +restorexCATdb_p_V +restorexCATdb_a_p_V +restorexCATdb_wrongpath +regnotif_null +regnotif_o +regnotif_err +regnotif_h +regnotif_v +unregnotif_null +unregnotif_f +unregnotif_h +unregnotif_v +lsxcatd_null +lsxcatd_h +lsxcatd_d +lsxcatd_a +makedns_d_node +makedns_ubuntu_n +copycds_iso +copycds_n +copycds_a +copycds_n_a +copycds_a_err +copycds_n_err +addkit_v +addkit_h +addkit_kit +addkit_i +addkit_multikit +addkit_p +addkitcomp_v +addkitcomp_h +addkitcomp_i +addkitcomp_f +buildkit_v +buildkit_h +buildkit_create +buildkit_create_l +buildkit_buildrepo_all +buildkit_buildrepo_ubuntu +buildkit_cleanrepo_all +buildkit_cleanrepo_ubuntu +buildkit_listrepo +buildkit_buildtar +buildkit_cleantar +buildkit_partialkit_ubuntu +buildkit_partialkit_completekit +chkkitcomp_v +chkkitcomp_h +chkkitcomp_V +lskit_v +lskit_h +lskit_F +lskit_K +lskit_R +lskit_C +lskitcomp_v +lskitcomp_h +lskitcomp_C +lskitcomp_S +lskitdeployparam_v +lskitdeployparam_h +lskitdeployparam_no_param +lskitdeployparam_k_1 +lskitdeployparam_c_1 +rmkit_v +rmkit_h +rmkit_t_no +rmkit_t_yes +rmkit_f +rmkit_V +rmkitcomp_v +rmkitcomp_h +xdsh_h +xdsh_V +xdsh_regular_command +xdsh_Q_command +xdsh_c_cn +xdsh_e_filename +xdsh_E +xdsh_t +xdsh_q +xdsh_T +xdsh_o +switchdiscover_range_default +switchdiscover_h +switchdiscover_range_s +switchdiscover_range_default_w +switchdiscover_range_r +switchdiscover_range_x +switchdiscover_range_z +switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg +xcatd_start_systemd +xcatd_stop_systemd +xcatd_restart_systemd +run_command_with_XCATBYPASS_systemd +disable_root_permission_in_policy_table_systemd +assign_certain_command_permission_systemd +nodeset_check_warninginfo diff --git a/xCAT-test/autotest/bundle/x_rhels_cmd.bundle b/xCAT-test/autotest/bundle/x_rhels_cmd.bundle index aac12e801..ed6ca7d43 100644 --- a/xCAT-test/autotest/bundle/x_rhels_cmd.bundle +++ b/xCAT-test/autotest/bundle/x_rhels_cmd.bundle @@ -88,7 +88,6 @@ nodels_noderange_table nodels_tablevalue nodels_tablevalue_tablecolumn nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn nodels_h nodels_v xcatstanzafile_normal diff --git a/xCAT-test/autotest/bundle/x_sles_cmd.bundle b/xCAT-test/autotest/bundle/x_sles_cmd.bundle index fe978e117..eb160f912 100644 --- a/xCAT-test/autotest/bundle/x_sles_cmd.bundle +++ b/xCAT-test/autotest/bundle/x_sles_cmd.bundle @@ -90,7 +90,6 @@ nodels_noderange_table nodels_tablevalue nodels_tablevalue_tablecolumn nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn nodels_h nodels_v xcatstanzafile_normal diff --git a/xCAT-test/autotest/bundle/x_ubuntu_cmd.bundle b/xCAT-test/autotest/bundle/x_ubuntu_cmd.bundle index fe3665fb8..4b6fe505a 100644 --- a/xCAT-test/autotest/bundle/x_ubuntu_cmd.bundle +++ b/xCAT-test/autotest/bundle/x_ubuntu_cmd.bundle @@ -84,7 +84,6 @@ nodels_noderange_table nodels_tablevalue nodels_tablevalue_tablecolumn nodels_noderange_tablecolumn -nodels_tablevalue_tablecolumn nodels_h nodels_v xcatstanzafile_normal @@ -206,7 +205,6 @@ lskit_C lskitcomp_v lskitcomp_h lskitcomp_C -lskitcomp_C lskitcomp_S lskitdeployparam_v lskitdeployparam_h From d5674fc7121b68f4c3b99e3d892ea2c67f00a78d Mon Sep 17 00:00:00 2001 From: zet809 Date: Wed, 20 Jul 2016 12:59:51 +0800 Subject: [PATCH 294/310] Update control --- xCAT/debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT/debian/control b/xCAT/debian/control index 69dd56b0e..35b1b9328 100644 --- a/xCAT/debian/control +++ b/xCAT/debian/control @@ -7,6 +7,6 @@ Standards-Version: 3.7.2 Package: xcat Architecture: amd64 ppc64el -Depends: ${perl:Depends}, xcat-server, xcat-client, libdbd-sqlite3-perl, isc-dhcp-server, apache2, nfs-kernel-server, nmap, bind9, libxml-parser-perl, xinetd, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, ipmitool-xcat (>=1.8.15-2), syslinux[any-amd64], libsys-virt-perl, syslinux-xcat[any-amd64], xnba-undi, xcat-genesis-scripts-ppc64, xcat-genesis-scripts-x86-64, elilo-xcat, xcat-buildkit, xcat-probe (>=2.12) +Depends: ${perl:Depends}, xcat-server, xcat-client, libdbd-sqlite3-perl, isc-dhcp-server, apache2, nfs-kernel-server, nmap, bind9, libxml-parser-perl, xinetd, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, ipmitool-xcat (>=1.8.9), syslinux[any-amd64], libsys-virt-perl, syslinux-xcat[any-amd64], xnba-undi, xcat-genesis-scripts-ppc64, xcat-genesis-scripts-x86-64, elilo-xcat, xcat-buildkit, xcat-probe (>=2.12) Description: Server and configuration utilities of the xCAT management project xcat-server provides the core server and configuration management components of xCAT. This package should be installed on your management server From fcf8f693531793d3166d3ae0ea4aa0ff57879455 Mon Sep 17 00:00:00 2001 From: zet809 Date: Wed, 20 Jul 2016 13:00:17 +0800 Subject: [PATCH 295/310] Update control --- xCATsn/debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCATsn/debian/control b/xCATsn/debian/control index 8283481f1..154ba3fd5 100644 --- a/xCATsn/debian/control +++ b/xCATsn/debian/control @@ -7,7 +7,7 @@ Standards-Version: 3.7.2 Package: xcatsn Architecture: all -Depends: ${perl:Depends}, xcat-server, perl-xcat, xcat-client, libdbd-sqlite3-perl, libxml-parser-perl, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, dhcp3-server, apache2, expect, nfs-kernel-server, nmap, bind9, ipmitool-xcat (>=1.8.15-2), syslinux-xcat, xnba-undi, xcat-genesis-scripts-ppc64, xcat-genesis-scripts-x86-64, elilo-xcat,libsys-virt-perl +Depends: ${perl:Depends}, xcat-server, perl-xcat, xcat-client, libdbd-sqlite3-perl, libxml-parser-perl, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, dhcp3-server, apache2, expect, nfs-kernel-server, nmap, bind9, ipmitool-xcat (>=1.8.9), syslinux-xcat, xnba-undi, xcat-genesis-scripts-ppc64, xcat-genesis-scripts-x86-64, elilo-xcat,libsys-virt-perl Recommends: yaboot-xcat Description: Metapackage for a common, default xCAT service node setup xCATsn is a service node management package intended for at-scale management, including hardware management and software management. From f7581c4c8224cb9c6359be83b35b93a7548f56f5 Mon Sep 17 00:00:00 2001 From: zet809 Date: Wed, 20 Jul 2016 13:05:12 +0800 Subject: [PATCH 296/310] Update control --- xCATsn/debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCATsn/debian/control b/xCATsn/debian/control index 154ba3fd5..604590bc5 100644 --- a/xCATsn/debian/control +++ b/xCATsn/debian/control @@ -7,7 +7,7 @@ Standards-Version: 3.7.2 Package: xcatsn Architecture: all -Depends: ${perl:Depends}, xcat-server, perl-xcat, xcat-client, libdbd-sqlite3-perl, libxml-parser-perl, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, dhcp3-server, apache2, expect, nfs-kernel-server, nmap, bind9, ipmitool-xcat (>=1.8.9), syslinux-xcat, xnba-undi, xcat-genesis-scripts-ppc64, xcat-genesis-scripts-x86-64, elilo-xcat,libsys-virt-perl +Depends: ${perl:Depends}, xcat-server, perl-xcat, xcat-client, libdbd-sqlite3-perl, libxml-parser-perl, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, dhcp3-server, apache2, expect, nfs-kernel-server, nmap, bind9, ipmitool-xcat (>=1.8.9), syslinux-xcat, xnba-undi, xcat-genesis-scripts, elilo-xcat,libsys-virt-perl Recommends: yaboot-xcat Description: Metapackage for a common, default xCAT service node setup xCATsn is a service node management package intended for at-scale management, including hardware management and software management. From b622997ba0eb25b2ec3796d1008ccdc6cf112679 Mon Sep 17 00:00:00 2001 From: zet809 Date: Wed, 20 Jul 2016 13:05:36 +0800 Subject: [PATCH 297/310] Update control --- xCAT/debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT/debian/control b/xCAT/debian/control index 35b1b9328..c5051a272 100644 --- a/xCAT/debian/control +++ b/xCAT/debian/control @@ -7,6 +7,6 @@ Standards-Version: 3.7.2 Package: xcat Architecture: amd64 ppc64el -Depends: ${perl:Depends}, xcat-server, xcat-client, libdbd-sqlite3-perl, isc-dhcp-server, apache2, nfs-kernel-server, nmap, bind9, libxml-parser-perl, xinetd, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, ipmitool-xcat (>=1.8.9), syslinux[any-amd64], libsys-virt-perl, syslinux-xcat[any-amd64], xnba-undi, xcat-genesis-scripts-ppc64, xcat-genesis-scripts-x86-64, elilo-xcat, xcat-buildkit, xcat-probe (>=2.12) +Depends: ${perl:Depends}, xcat-server, xcat-client, libdbd-sqlite3-perl, isc-dhcp-server, apache2, nfs-kernel-server, nmap, bind9, libxml-parser-perl, xinetd, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, ipmitool-xcat (>=1.8.9), syslinux[any-amd64], libsys-virt-perl, syslinux-xcat[any-amd64], xnba-undi, xcat-genesis-scripts, elilo-xcat, xcat-buildkit, xcat-probe (>=2.12) Description: Server and configuration utilities of the xCAT management project xcat-server provides the core server and configuration management components of xCAT. This package should be installed on your management server From cd471d112debb9592242074a005192fd16cefe85 Mon Sep 17 00:00:00 2001 From: ertaozh Date: Wed, 20 Jul 2016 01:17:45 -0400 Subject: [PATCH 298/310] modify dependency xcat-genesis-scripts to xcat-genesis-scripts-ppc64 and xcat-genesis-scripts-x86-64 for xcatsn and xcat --- xCAT/debian/control | 2 +- xCATsn/debian/control | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT/debian/control b/xCAT/debian/control index c897efd07..69dd56b0e 100644 --- a/xCAT/debian/control +++ b/xCAT/debian/control @@ -7,6 +7,6 @@ Standards-Version: 3.7.2 Package: xcat Architecture: amd64 ppc64el -Depends: ${perl:Depends}, xcat-server, xcat-client, libdbd-sqlite3-perl, isc-dhcp-server, apache2, nfs-kernel-server, nmap, bind9, libxml-parser-perl, xinetd, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, ipmitool-xcat (>=1.8.15-2), syslinux[any-amd64], libsys-virt-perl, syslinux-xcat[any-amd64], xnba-undi, xcat-genesis-scripts, elilo-xcat, xcat-buildkit, xcat-probe (>=2.12) +Depends: ${perl:Depends}, xcat-server, xcat-client, libdbd-sqlite3-perl, isc-dhcp-server, apache2, nfs-kernel-server, nmap, bind9, libxml-parser-perl, xinetd, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, ipmitool-xcat (>=1.8.15-2), syslinux[any-amd64], libsys-virt-perl, syslinux-xcat[any-amd64], xnba-undi, xcat-genesis-scripts-ppc64, xcat-genesis-scripts-x86-64, elilo-xcat, xcat-buildkit, xcat-probe (>=2.12) Description: Server and configuration utilities of the xCAT management project xcat-server provides the core server and configuration management components of xCAT. This package should be installed on your management server diff --git a/xCATsn/debian/control b/xCATsn/debian/control index 70ecda665..8283481f1 100644 --- a/xCATsn/debian/control +++ b/xCATsn/debian/control @@ -7,7 +7,7 @@ Standards-Version: 3.7.2 Package: xcatsn Architecture: all -Depends: ${perl:Depends}, xcat-server, perl-xcat, xcat-client, libdbd-sqlite3-perl, libxml-parser-perl, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, dhcp3-server, apache2, expect, nfs-kernel-server, nmap, bind9, ipmitool-xcat (>=1.8.15-2), syslinux-xcat, xnba-undi, xcat-genesis-scripts, elilo-xcat,libsys-virt-perl +Depends: ${perl:Depends}, xcat-server, perl-xcat, xcat-client, libdbd-sqlite3-perl, libxml-parser-perl, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, dhcp3-server, apache2, expect, nfs-kernel-server, nmap, bind9, ipmitool-xcat (>=1.8.15-2), syslinux-xcat, xnba-undi, xcat-genesis-scripts-ppc64, xcat-genesis-scripts-x86-64, elilo-xcat,libsys-virt-perl Recommends: yaboot-xcat Description: Metapackage for a common, default xCAT service node setup xCATsn is a service node management package intended for at-scale management, including hardware management and software management. From 1829169839fd008baa46726bf8db9478a5b6a96e Mon Sep 17 00:00:00 2001 From: immarvin Date: Wed, 20 Jul 2016 03:59:54 -0400 Subject: [PATCH 299/310] fix issue [customer] the rhels7.2 diskful installation with kernel and kernel modules updated by"geninitrd" failed with "Pane is dead" inside anaconda #1562; add a dracut hook in intrd to update the kernle modules inside the stage2 installer LiveOs --- xCAT-server/lib/xcat/plugins/anaconda.pm | 41 ++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index 3d5dc6f93..d47a9311f 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -2892,6 +2892,47 @@ sub insert_dd { } } } + + #insert a dracut pre-pivot hook to update the kernel modules in the stage2 LiveOS image + #with the kernel modules inside initrd + if (-d "$dd_dir/initrd_img/usr/lib/dracut/hooks/pre-pivot"){ + my $hookcopykmod; + open($hookcopykmod,">","$dd_dir/initrd_img/usr/lib/dracut/hooks/pre-pivot/01-anaconda-copy-kernelmodules.sh"); + print $hookcopykmod <<'EOMS'; +#!/bin/sh +# Copy over kernel module files under /usr/lib/modules/ from the initrd to /run before pivot + +function mycopytree { + SRCPATH=$1 + DSTPATH=$2 + + [ -d "$SRCPATH" ] || return 1 + + # avoid overwriting symlinks (e.g. /lib -> /usr/lib) with directories + mkdir -p $DSTPATH + cd $SRCPATH + find . -depth -type d | while read dir; do + mkdir -p "$DSTPATH/$dir" + done + find . -depth \! -type d | while read file; do + \cp -a "$file" "$DSTPATH/$file" + done + + return 0 +} + +KVERSION=$(uname -r) +if [ -b /dev/mapper/live-rw ] && [ -d "/usr/lib/modules/$KVERSION" ]; then + info "Applying updated kernel modules to live image..." + mount -o bind /run $NEWROOT/run + mycopytree "/usr/lib/modules/$KVERSION" "$NEWROOT/usr/lib/modules/$KVERSION" + umount $NEWROOT/run +fi +EOMS + close($hookcopykmod); + chmod(0755,"$dd_dir/initrd_img/usr/lib/dracut/hooks/pre-pivot/01-anaconda-copy-kernelmodules.sh"); + } + } else {# non dracut mode, for rh5, fedora12 ... # For non-dracut mode, the drviers need to be merged into the initrd with the specific format From 967ff2a33a754811f87fa66ce4a846080491e476 Mon Sep 17 00:00:00 2001 From: ertaozh Date: Wed, 20 Jul 2016 04:08:44 -0400 Subject: [PATCH 300/310] modify genesis scripts spec for debian/control to be debian/control-amd64 and debian/control-ppc64elwq --- xCAT-genesis-scripts/xCAT-genesis-scripts.spec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xCAT-genesis-scripts/xCAT-genesis-scripts.spec b/xCAT-genesis-scripts/xCAT-genesis-scripts.spec index 0ffa1c825..02d8292df 100755 --- a/xCAT-genesis-scripts/xCAT-genesis-scripts.spec +++ b/xCAT-genesis-scripts/xCAT-genesis-scripts.spec @@ -101,7 +101,8 @@ touch /etc/xcat/genesis-scripts-updated %{rpminstallroot}/bin/restart %{rpminstallroot}/debian/changelog %{rpminstallroot}/debian/compat -%{rpminstallroot}/debian/control +%{rpminstallroot}/debian/control-amd64 +%{rpminstallroot}/debian/control-ppc64el %{rpminstallroot}/debian/copyright #%{rpminstallroot}/debian/dirs %{rpminstallroot}/debian/docs From 5d46d48f6a4a4dc79b1d921967d77a78de491cae Mon Sep 17 00:00:00 2001 From: penguhyang Date: Wed, 20 Jul 2016 20:06:33 +0800 Subject: [PATCH 301/310] Fix issue of packimage -m txc (#1554) * redefine the code to make distint * fix issue of packimage -m txc --- .../references/man1/packimage.1.rst | 2 +- xCAT-client/pods/man1/packimage.1.pod | 2 +- xCAT-server/lib/xcat/plugins/anaconda.pm | 3 +- xCAT-server/lib/xcat/plugins/debian.pm | 7 +- xCAT-server/lib/xcat/plugins/packimage.pm | 228 +++++++++++------- xCAT-server/lib/xcat/plugins/sles.pm | 12 +- .../netboot/rh/compute.rhels7.ppc64.pkglist | 1 + .../netboot/rh/compute.rhels7.x86_64.pkglist | 1 + .../xcat/netboot/rh/dracut/install.netboot | 2 +- .../netboot/rh/dracut_033/install.netboot | 2 +- .../share/xcat/netboot/rh/dracut_033/xcatroot | 3 + xCAT-server/share/xcat/netboot/rh/genimage | 13 +- .../sles/compute.sles12.ppc64le.pkglist | 1 + .../sles/compute.sles12.x86_64.pkglist | 1 + .../netboot/sles/dracut_033/install.netboot | 2 +- .../xcat/netboot/sles/dracut_033/xcatroot | 16 ++ xCAT-server/share/xcat/netboot/sles/genimage | 15 +- .../compute.ubuntu14.04.4.ppc64el.pkglist | 1 + .../compute.ubuntu14.04.4.x86_64.pkglist | 1 + .../compute.ubuntu16.04.ppc64el.pkglist | 1 + .../ubuntu/compute.ubuntu16.04.x86_64.pkglist | 1 + .../netboot/ubuntu/dracut/install.netboot | 2 +- .../share/xcat/netboot/ubuntu/dracut/xcatroot | 7 + .../share/xcat/netboot/ubuntu/genimage | 16 +- 24 files changed, 235 insertions(+), 105 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/packimage.1.rst b/docs/source/guides/admin-guides/references/man1/packimage.1.rst index 705880797..13510d4b1 100644 --- a/docs/source/guides/admin-guides/references/man1/packimage.1.rst +++ b/docs/source/guides/admin-guides/references/man1/packimage.1.rst @@ -62,7 +62,7 @@ OPTIONS \ **-a**\ Architecture (ppc64,x86_64,etc) -\ **-m**\ Method (default cpio) +\ **-m**\ Method (cpio,txc,squashfs, default is cpio) ************ diff --git a/xCAT-client/pods/man1/packimage.1.pod b/xCAT-client/pods/man1/packimage.1.pod index 90154394d..c2f8bdc5c 100644 --- a/xCAT-client/pods/man1/packimage.1.pod +++ b/xCAT-client/pods/man1/packimage.1.pod @@ -36,7 +36,7 @@ B<-p> Profile (compute,service) B<-a> Architecture (ppc64,x86_64,etc) -B<-m> Method (default cpio) +B<-m> Method (cpio,txc,squashfs, default is cpio) =head1 RETURN VALUE diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index d47a9311f..e48700aa4 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -450,6 +450,7 @@ sub mknetboot $platform=xCAT_plugin::anaconda::getplatform($osver); my $suffix = 'gz'; $suffix = 'sfs' if (-r "$rootimgdir/rootimg.sfs"); + $suffix = 'txz' if (-r "$rootimgdir/rootimg.txz"); # statelite images are not packed. if ($statelite) { unless ( -r "$rootimgdir/kernel") { @@ -497,7 +498,7 @@ sub mknetboot copy("$rootimgdir/initrd.gz", "$rootimgdir/initrd-stateless.gz"); } } - unless ( -r "$rootimgdir/rootimg.gz" or -r "$rootimgdir/rootimg.sfs" ) { + unless ( -r "$rootimgdir/rootimg.gz" or -r "$rootimgdir/rootimg.txz" or -r "$rootimgdir/rootimg.sfs" ) { $callback->({ error=>["No packed image for platform $osver, architecture $arch, and profile $profile found at $rootimgdir/rootimg.gz or $rootimgdir/rootimg.sfs on $myname, please run packimage (e.g. packimage -o $osver -p $profile -a $arch"], errorcode => [1]}); diff --git a/xCAT-server/lib/xcat/plugins/debian.pm b/xCAT-server/lib/xcat/plugins/debian.pm index 4610c6ca0..6d081b5d2 100644 --- a/xCAT-server/lib/xcat/plugins/debian.pm +++ b/xCAT-server/lib/xcat/plugins/debian.pm @@ -1152,8 +1152,9 @@ sub mknetboot $platform=xCAT_plugin::debian::getplatform($osver); my $suffix = 'gz'; - $suffix = 'sfs' if (-r "$rootimgdir/rootimg.sfs"); - # statelite images are not packed. + $suffix = 'sfs' if (-r "$rootimgdir/rootimg.sfs"); + $suffix = 'txz' if (-r "$rootimgdir/rootimg.txz"); + # statelite images are not packed. if ($statelite) { unless ( -r "$rootimgdir/kernel") { $callback->({ @@ -1201,7 +1202,7 @@ sub mknetboot copy("$rootimgdir/initrd.gz", "$rootimgdir/initrd-stateless.gz"); } } - unless ( -r "$rootimgdir/rootimg.gz" or -r "$rootimgdir/rootimg.sfs" ) { + unless ( -r "$rootimgdir/rootimg.gz" or -r "$rootimgdir/rootimg.txz" or -r "$rootimgdir/rootimg.sfs" ) { $callback->({ error=>["No packed image for platform $osver, architecture $arch, and profile $profile, please run packimage (e.g. packimage -o $osver -p $profile -a $arch"], errorcode => [1]}); diff --git a/xCAT-server/lib/xcat/plugins/packimage.pm b/xCAT-server/lib/xcat/plugins/packimage.pm index 979d4b72f..4983341dc 100755 --- a/xCAT-server/lib/xcat/plugins/packimage.pm +++ b/xCAT-server/lib/xcat/plugins/packimage.pm @@ -1,8 +1,26 @@ +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html +#------------------------------------------------------- + +=head1 + xCAT plugin package to pack the stateless image + + Supported options: + -h Display usage message + -v Command Version + -o Operating system (fedora8, rhel5, sles10,etc) + -p Profile (compute,service) + -a Architecture (ppc64,x86_64,etc) + -m Method (default cpio) + +=cut + +#------------------------------------------------------- package xCAT_plugin::packimage; BEGIN { $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; } +use strict; use lib "$::XCATROOT/lib/perl"; use Data::Dumper; use xCAT::Table; @@ -24,24 +42,44 @@ Getopt::Long::Configure("pass_through"); my $verbose = 0; #$verbose = 1; +#------------------------------------------------------- + +=head3 handled_commands + + Return list of commands handled by this plugin + +=cut + +#------------------------------------------------------- sub handled_commands { return { packimage => "packimage", } } +#------------------------------------------------------- + +=head3 Process the command + +=cut + +#------------------------------------------------------- sub process_request { my $request = shift; my $callback = shift; my $doreq = shift; my $installroot = xCAT::TableUtils->getInstallDir(); - @ARGV = @{$request->{arg}}; - my $argc = scalar @ARGV; - if ($argc == 0) { - $callback->({info=>["packimage -h \npackimage -v \npackimage imagename"]}); - return; + my $args; + if (defined($request->{arg})) { + $args = $request->{arg}; + @ARGV = @{$args}; } + if (scalar(@ARGV) == 0) { + $callback->({info=>["Usage:\n packimage \n packimage [-h| --help]\n packimage [-v| --version]"]}); + return 0; + } + my $osver; my $arch; my $profile; @@ -52,6 +90,9 @@ sub process_request { my $destdir; my $imagename; my $dotorrent; + my $provmethod; + my $help; + my $version; GetOptions( "profile|p=s" => \$profile, @@ -65,62 +106,62 @@ sub process_request { if ($version) { my $version = xCAT::Utils->Version(); $callback->({info=>[$version]}); - return; + return 0; } if ($help) { - $callback->({info=>["packimage -h \npackimage -v \npackimage imagename"]}); - return; + $callback->({info=>["Usage:\n packimage \n packimage [-h| --help]\n packimage [-v| --version]"]}); + return 0; } if (@ARGV > 0) { $imagename=$ARGV[0]; if ($arch or $osver or $profile) { $callback->({error=>["-o, -p and -a options are not allowed when a image name is specified."],errorcode=>[1]}); - return; + return 1; } # load the module in memory eval {require("$::XCATROOT/lib/perl/xCAT/Table.pm")}; if ($@) { $callback->({error=>[$@],errorcode=>[1]}); - return; + return 1; } # get the info from the osimage and linux my $osimagetab=xCAT::Table->new('osimage', -create=>1); unless ($osimagetab) { $callback->({error=>["The osimage table cannot be opened."],errorcode=>[1]}); - return; + return 1; } my $linuximagetab=xCAT::Table->new('linuximage', -create=>1); unless ($linuximagetab) { $callback->({error=>["The linuximage table cannot be opened."],errorcode=>[1]}); - return; + return 1; } (my $ref) = $osimagetab->getAttribs({imagename => $imagename}, 'osvers', 'osarch', 'profile', 'provmethod', 'synclists'); unless ($ref) { $callback->({error=>["Cannot find image \'$imagename\' from the osimage table."],errorcode=>[1]}); - return; + return 1; } (my $ref1) = $linuximagetab->getAttribs({imagename => $imagename}, 'exlist', 'rootimgdir'); unless ($ref1) { $callback->({error=>["Cannot find $imagename from the linuximage table."],errorcode=>[1]}); - return; + return 1; } $osver=$ref->{'osvers'}; $arch=$ref->{'osarch'}; $profile=$ref->{'profile'}; $syncfile=$ref->{'synclists'}; - my $provmethod=$ref->{'provmethod'}; + $provmethod=$ref->{'provmethod'}; unless ($osver and $arch and $profile and $provmethod) { $callback->({error=>["osimage.osvers, osimage.osarch, osimage.profile and osimage.provmethod must be specified for the image $imagename in the database."],errorcode=>[1]}); - return; + return 1; } if ($provmethod ne 'netboot') { $callback->({error=>["\'$imagename\' cannot be used to build diskless image. Make sure osimage.provmethod is 'netboot'."],errorcode=>[1]}); - return; + return 1; } $exlistloc =$ref1->{'exlist'}; @@ -129,7 +170,7 @@ sub process_request { $provmethod="netboot"; unless ($osver) { $callback->({error=>["Please specify a os version with the -o flag"],errorcode=>[1]}); - return; + return 1; } unless ($arch) { $arch = `uname -m`; @@ -139,7 +180,7 @@ sub process_request { unless ($profile) { $callback->({error=>["Please specify a profile name with -p flag"],errorcode=>[1]}); - return; + return 1; } } @@ -154,11 +195,11 @@ sub process_request { } unless ($distname) { $callback->({error=>["Unable to find $::XCATROOT/share/xcat/netboot directory for $osver"],errorcode=>[1]}); - return; + return 1; } unless ($installroot) { $callback->({error=>["No installdir defined in site table"],errorcode=>[1]}); - return; + return 1; } my $oldpath=cwd(); unless ($imagename) { @@ -169,7 +210,7 @@ sub process_request { my @ret = xCAT::SvrUtils->update_tables_with_diskless_image($osver, $arch, $profile, "netboot"); unless ($ret[0] eq 0) { $callback->({error=>["Error when updating the osimage tables: " . $ret[1]], errorcode=>[1]}); - return; + return 1; } } @@ -205,7 +246,7 @@ sub process_request { my %liteHash; # create hash table for the entries in @listList if (parseLiteFiles($ref_liteList, \%liteHash)) { $callback->({error=>["Failed for parsing litefile table!"], errorcode=>[1]}); - return; + return 1; } $verbose && $callback->({data=>["rootimg_status = $rootimg_status at line " . __LINE__ ]}); @@ -317,7 +358,7 @@ sub process_request { # add the xCAT post scripts to the image unless ( -d "$rootimg_dir") { $callback->({error=>["$rootimg_dir does not exist, run genimage -o $osver -p $profile on a server with matching architecture"], errorcode=>[1]}); - return; + return 1; } # some rpms like atftp mount the rootimg/proc to /proc, we need to make sure rootimg/proc is free of junk @@ -359,31 +400,27 @@ sub process_request { system("$::XCATROOT/bin/xdcp -i $rootimg_dir -F $syncfile"); } - my $verb = "Packing"; - my $temppath; my $oldmask; unless ( -d $rootimg_dir) { $callback->({error=>["$rootimg_dir does not exist, run genimage -o $osver -p $profile on a server with matching architecture"]}); - return; + return 1; } - $callback->({data=>["$verb contents of $rootimg_dir"]}); + $callback->({data=>["Packing contents of $rootimg_dir"]}); unlink("$destdir/rootimg.gz"); unlink("$destdir/rootimg.sfs"); - my $compress="gzip"; - #use "pigz" as the compress tool instead of gzip if "pigz" exist - my $ispigz=system("bash -c 'type -p pigz' >/dev/null 2>&1"); - if($ispigz == 0){ - $compress="pigz"; - } - - $callback->({info=>["compress method:$compress"]}); - + $callback->({info=>["compress method:$method"]}); if ($method =~ /cpio/) { + my $compress="gzip"; + #use "pigz" as the compress tool instead of gzip if "pigz" exist + my $ispigz=system("bash -c 'type -p pigz' >/dev/null 2>&1"); + if($ispigz == 0){ + $compress="pigz"; + } if ( ! $exlistloc ) { $excludestr = "find . -xdev |cpio -H newc -o | $compress -c - > ../rootimg.gz"; - }else { + } else { chdir("$rootimg_dir"); system("$excludestr >> $xcat_packimg_tmpfile"); if ($includestr) { @@ -393,15 +430,21 @@ sub process_request { } $oldmask = umask 0077; } elsif ($method =~ /txc/) { + my $isxz=system("bash -c 'type -p xz' >/dev/null 2>&1"); + unless($isxz == 0) { + $callback->({error=>["Command xz does not exist, please make sure it works."]}); + return 1; + } + $callback->({info=>["It will take several minutes to complete. So please wait for several minutes, then the other operations could be done. Otherwise, the other operation will fail."]}); if ( ! $exlistloc ) { - $excludestr = "find . -xdev | tar --selinux --xattr-include='*' -T - -Jcvf ../rootimg.txz"; - }else { + $excludestr = "find . -xdev | tar --selinux --xattrs-include='*' -T - -Jcvf ../rootimg.txz"; + } else { chdir("$rootimg_dir"); - system("$excludestr >> $xcat_packimg_tmpfile"); + system("$excludestr >> $xcat_packimg_tmpfile"); if ($includestr) { - system("$includestr >> $xcat_packimg_tmpfile"); + system("$includestr >> $xcat_packimg_tmpfile"); } - $excludestr = "cat $xcat_packimg_tmpfile| tar --selinux --xattr-include='*' -T -Jcvf ../rootimg.txz"; + $excludestr = "cat $xcat_packimg_tmpfile| tar --selinux --xattrs-include='*' -T - -Jcvf ../rootimg.txz"; } $oldmask = umask 0077; } elsif ($method =~ /squashfs/) { @@ -429,6 +472,9 @@ sub process_request { chdir($currdir); } umask $oldmask; + } elsif ($method =~ /txc/) { + chmod 0644,"$destdir/rootimg.txz"; + umask $oldmask; } elsif ($method =~ /squashfs/) { my $flags; if ($arch =~ /x86/) { @@ -443,17 +489,17 @@ sub process_request { if (! -x "/sbin/mksquashfs" && ! -x "/usr/bin/mksquashfs" ) { $callback->({error=>["mksquashfs not found, squashfs-tools rpm should be installed on the management node"],errorcode=>[1]}); - return; + return 1; } my $rc = system("mksquashfs $temppath ../rootimg.sfs $flags"); if ($rc) { $callback->({error=>["mksquashfs could not be run successfully"],errorcode=>[1]}); - return; + return 1; } $rc = system("rm -rf $temppath"); if ($rc) { $callback->({error=>["Failed to clean up temp space"],errorcode=>[1]}); - return; + return 1; } chmod(0644,"../rootimg.sfs"); } @@ -481,11 +527,15 @@ sub process_request { chdir($oldpath); } -########################################################### -# -# copybootscript - copy the xCAT diskless init scripts to the image -# -############################################################# +#------------------------------------------------------- + +=head3 copybootscript + + copy the xCAT diskless init scripts to the image + +=cut + +#------------------------------------------------------- sub copybootscript { my $installroot = shift; @@ -546,6 +596,14 @@ sub copybootscript { return 0; } +#------------------------------------------------------- + +=head3 include_file + + +=cut + +#------------------------------------------------------- sub include_file { my $file = shift; @@ -570,45 +628,47 @@ sub include_file return join("\n", @text); } -=head3 parseLiteFiles -In the liteentry table, one directory and its sub-items (including sub-directory and entries) can co-exist; -In order to handle such a scenario, one hash is generated to show the hirarachy relationship +#------------------------------------------------------- -For example, one array with entry names is used as the input: -my @entries = ( - "imagename bind,persistent /var/", - "imagename bind /var/tmp/", - "imagename tmpfs,rw /root/", - "imagename tmpfs,rw /root/.bashrc", - "imagename tmpfs,rw /root/test/", - "imagename bind /etc/resolv.conf", - "imagename bind /var/run/" -); -Then, one hash will generated as: -%hashentries = { - 'bind,persistent /var/' => [ - 'bind /var/tmp/', - 'bind /var/run/' - ], - 'bind /etc/resolv.conf' => undef, - 'tmpfs,rw /root/' => [ - 'tmpfs,rw /root/.bashrc', - 'tmpfs,rw /root/test/' - ] - }; +=head3 parseLiteFiles -Arguments: - one array with entrynames, - one hash to hold the entries parsed + In the liteentry table, one directory and its sub-items (including sub-directory and entries) can co-exist; + In order to handle such a scenario, one hash is generated to show the hirarachy relationship -Returns: - 0 if sucucess - 1 if fail + For example, one array with entry names is used as the input: + my @entries = ( + "imagename bind,persistent /var/", + "imagename bind /var/tmp/", + "imagename tmpfs,rw /root/", + "imagename tmpfs,rw /root/.bashrc", + "imagename tmpfs,rw /root/test/", + "imagename bind /etc/resolv.conf", + "imagename bind /var/run/" + ); + Then, one hash will generated as: + %hashentries = { + 'bind,persistent /var/' => [ + 'bind /var/tmp/', + 'bind /var/run/' + ], + 'bind /etc/resolv.conf' => undef, + 'tmpfs,rw /root/' => [ + 'tmpfs,rw /root/.bashrc', + 'tmpfs,rw /root/test/' + ] + }; + + Arguments: + one array with entrynames, + one hash to hold the entries parsed + + Returns: + 0 if sucucess + 1 if fail =cut - - +#------------------------------------------------------- sub parseLiteFiles { my ($flref, $dhref) = @_; my @entries = @{$flref}; diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index aa9227b40..6ee9bfb23 100644 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -314,14 +314,12 @@ sub mknetboot $pkgdir = "$installroot/$osver/$arch"; }elsif($osver =~ /suse.*/){ $platform = "sles"; - } - - my $suffix = 'gz'; - if (-r "$rootimgdir/rootimg.sfs") - { - $suffix = 'sfs'; } + my $suffix = 'gz'; + $suffix = 'sfs' if (-r "$rootimgdir/rootimg.sfs"); + $suffix = 'txz' if (-r "$rootimgdir/rootimg.txz"); + if ($statelite) { unless ( -r "$rootimgdir/kernel") { $callback->({ @@ -372,7 +370,7 @@ sub mknetboot } } - unless ( -r "$rootimgdir/rootimg.gz" or -r "$rootimgdir/rootimg.sfs" ) { + unless ( -r "$rootimgdir/rootimg.gz" or -r "$rootimgdir/rootimg.txz" or -r "$rootimgdir/rootimg.sfs" ) { $callback->({ error=>[qq{No packed image for platform $osver, architecture $arch, and profile $profile, please run packimage before nodeset}], errorcode=>[1] diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist index 076e5d9a7..7f576221b 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist @@ -24,3 +24,4 @@ irqbalance procps-ng parted net-tools +xz diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.pkglist index 87a71d977..409531cdf 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.pkglist @@ -19,3 +19,4 @@ rsyslog e2fsprogs parted net-tools +xz diff --git a/xCAT-server/share/xcat/netboot/rh/dracut/install.netboot b/xCAT-server/share/xcat/netboot/rh/dracut/install.netboot index a0899f3f4..706a14d12 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut/install.netboot +++ b/xCAT-server/share/xcat/netboot/rh/dracut/install.netboot @@ -1,6 +1,6 @@ #!/bin/sh echo $drivers -dracut_install wget tar xz cpio gzip dash modprobe touch echo cut wc +dracut_install wget tar xz cpio gzip dash modprobe touch echo cut wc xz dracut_install -o ctorrent dracut_install grep ifconfig hostname awk egrep grep dirname expr dracut_install mount.nfs diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/install.netboot b/xCAT-server/share/xcat/netboot/rh/dracut_033/install.netboot index b52b6690f..9bae9d704 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut_033/install.netboot +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/install.netboot @@ -1,6 +1,6 @@ #!/bin/sh echo $drivers -dracut_install wget cpio gzip modprobe touch echo cut wc +dracut_install wget cpio gzip modprobe touch echo cut wc xz dracut_install grep ifconfig hostname awk egrep grep dirname expr dracut_install mount.nfs dracut_install parted mke2fs bc mkswap swapon chmod diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot index bcb9a911a..2344938dc 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot @@ -90,6 +90,7 @@ elif [ -r /rootimg.gz ]; then [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...." echo Done elif [ -r /rootimg.txz ]; then + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg.txz downloaded,setting up RAM-root tmpfs...." echo Setting up RAM-root tmpfs. if [ -z $rootlimit ];then mount -t tmpfs -o mode=755 rootfs $NEWROOT @@ -98,9 +99,11 @@ elif [ -r /rootimg.txz ]; then fi cd $NEWROOT + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Extracting root filesystem:" echo -n "Extracting root filesystem:" tar -Jxvf /rootimg.txz $NEWROOT/etc/init.d/localdisk + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...." echo Done elif [ -r /rootimg-statelite.gz ]; then echo Setting up RAM-root tmpfs for statelite mode. diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index a7d598294..af7224cde 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -1583,6 +1583,17 @@ EOMS print $inifile " zcat /rootimg.gz |cpio -idum\n"; print $inifile " fi\n"; print $inifile " echo Done\n"; + print $inifile "elif [ -r /rootimg.txz ]; then\n"; + print $inifile " echo Setting up RAM-root tmpfs.\n"; + if ($rootlimit) { + print $inifile " mount -o \"size=$rootlimit,mode=755\" -t tmpfs rootfs \$NEWROOT\n"; + } else { + print $inifile " mount -o mode=755 -t tmpfs rootfs \$NEWROOT\n"; + } + print $inifile " cd \$NEWROOT\n"; + print $inifile " echo -n \"Extracting root filesystem:\"\n"; + print $inifile " tar -Jxvf /rootimg.txz\n"; + print $inifile " echo Done\n"; print $inifile "else\n"; print $inifile " echo -n Failed to download image, panicing in 5...\n"; print $inifile " for i in 4 3 2 1 0; do\n"; @@ -1657,7 +1668,7 @@ EOMS } } # add rsync for statelite - foreach ("bin/cpio","sbin/nash","sbin/busybox.anaconda","sbin/rmmod", "bin/bash", "usr/sbin/chroot", "sbin/mount.nfs", "usr/bin/rsync", "usr/bin/wc") { + foreach ("bin/cpio","sbin/nash","sbin/busybox.anaconda","sbin/rmmod", "bin/bash", "usr/sbin/chroot", "sbin/mount.nfs", "usr/bin/rsync", "usr/bin/wc", "usr/bin/xz") { getlibs($_); push @filestoadd,$_; } diff --git a/xCAT-server/share/xcat/netboot/sles/compute.sles12.ppc64le.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sles12.ppc64le.pkglist index 1eebf1414..d0b4c3a0e 100644 --- a/xCAT-server/share/xcat/netboot/sles/compute.sles12.ppc64le.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/compute.sles12.ppc64le.pkglist @@ -41,3 +41,4 @@ udev kernel-default kernel-firmware adaptec-firmware +xz diff --git a/xCAT-server/share/xcat/netboot/sles/compute.sles12.x86_64.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sles12.x86_64.pkglist index 1eebf1414..d0b4c3a0e 100644 --- a/xCAT-server/share/xcat/netboot/sles/compute.sles12.x86_64.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/compute.sles12.x86_64.pkglist @@ -41,3 +41,4 @@ udev kernel-default kernel-firmware adaptec-firmware +xz diff --git a/xCAT-server/share/xcat/netboot/sles/dracut_033/install.netboot b/xCAT-server/share/xcat/netboot/sles/dracut_033/install.netboot index b52b6690f..9bae9d704 100755 --- a/xCAT-server/share/xcat/netboot/sles/dracut_033/install.netboot +++ b/xCAT-server/share/xcat/netboot/sles/dracut_033/install.netboot @@ -1,6 +1,6 @@ #!/bin/sh echo $drivers -dracut_install wget cpio gzip modprobe touch echo cut wc +dracut_install wget cpio gzip modprobe touch echo cut wc xz dracut_install grep ifconfig hostname awk egrep grep dirname expr dracut_install mount.nfs dracut_install parted mke2fs bc mkswap swapon chmod diff --git a/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot b/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot index c02971ef7..c9775a412 100755 --- a/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot +++ b/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot @@ -87,6 +87,22 @@ elif [ -r /rootimg.gz ]; then $NEWROOT/etc/init.d/localdisk [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...." echo Done +elif [ -r /rootimg.txz ]; then + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg.txz downloaded,setting up RAM-root tmpfs...." + echo Setting up RAM-root tmpfs. + if [ -z $rootlimit ];then + mount -t tmpfs -o mode=755 rootfs $NEWROOT + else + mount -t tmpfs -o mode=755,size=$rootlimit rootfs $NEWROOT + fi + + cd $NEWROOT + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Extracting root filesystem:" + echo -n "Extracting root filesystem:" + tar -Jxvf /rootimg.txz + $NEWROOT/etc/init.d/localdisk + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...." + echo Done elif [ -r /rootimg-statelite.gz ]; then echo Setting up RAM-root tmpfs for statelite mode. diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index f8c22a91f..64e628aae 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -1621,6 +1621,17 @@ EOMS print $inifile " zcat /rootimg.gz |cpio -idum\n"; print $inifile " fi\n"; print $inifile " echo Done\n"; + print $inifile "elif [ -r /rootimg.txz ]; then\n"; + print $inifile " echo Setting up RAM-root tmpfs.\n"; + if ($rootlimit) { + print $inifile " mount -o \"size=$rootlimit,mode=755\" -t tmpfs rootfs \$NEWROOT\n"; + } else { + print $inifile " mount -o mode=755 -t tmpfs rootfs \$NEWROOT\n"; + } + print $inifile " cd \$NEWROOT\n"; + print $inifile " echo -n \"Extracting root filesystem:\"\n"; + print $inifile " tar -Jxvf /rootimg.txz\n"; + print $inifile " echo Done\n"; print $inifile "else\n"; print $inifile " echo -n Failed to download image, panicing in 5...\n"; print $inifile " for i in 4 3 2 1 0; do\n"; @@ -1728,7 +1739,7 @@ EOMS } } if($mode eq "statelite") { - foreach ("sbin/ifconfig", "usr/bin/clear","usr/bin/touch","bin/hostname","usr/bin/egrep","bin/ln","bin/ls","usr/bin/dirname","usr/bin/expr","usr/bin/chroot","usr/bin/grep","bin/cpio","bin/sleep","bin/mount","bin/umount","sbin/dhcpcd","bin/bash","sbin/insmod","bin/mkdir","bin/mknod","sbin/ip","bin/cat","usr/bin/awk","usr/bin/wget","bin/cp","usr/bin/cpio","usr/bin/zcat","usr/bin/gzip","lib/mkinitrd/bin/run-init","usr/bin/uniq","usr/bin/sed","usr/bin/wc", "bin/sed","sbin/udevd", "usr/bin/readlink", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc") { + foreach ("sbin/ifconfig", "usr/bin/clear","usr/bin/touch","bin/hostname","usr/bin/egrep","bin/ln","bin/ls","usr/bin/dirname","usr/bin/expr","usr/bin/chroot","usr/bin/grep","bin/cpio","bin/sleep","bin/mount","bin/umount","sbin/dhcpcd","bin/bash","sbin/insmod","bin/mkdir","bin/mknod","sbin/ip","bin/cat","usr/bin/awk","usr/bin/wget","bin/cp","usr/bin/cpio","usr/bin/zcat","usr/bin/gzip","lib/mkinitrd/bin/run-init","usr/bin/uniq","usr/bin/sed","usr/bin/wc", "bin/sed","sbin/udevd", "usr/bin/readlink", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/xz") { getlibs($_); push @filestoadd,$_; } @@ -1740,7 +1751,7 @@ EOMS } }else { - foreach ("sbin/ifconfig","usr/bin/clear","usr/bin/touch","usr/bin/grep","usr/bin/egrep","bin/cpio","bin/sleep","bin/mount","sbin/dhcpcd","bin/bash","sbin/insmod","bin/mkdir","bin/mknod","sbin/ip","bin/cat","usr/bin/awk","usr/bin/wget","bin/cp","usr/bin/cpio","usr/bin/zcat","usr/bin/gzip","lib/mkinitrd/bin/run-init","usr/bin/uniq","usr/bin/sed","sbin/udevd", "usr/bin/readlink", "usr/bin/expr", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc") { + foreach ("sbin/ifconfig","usr/bin/clear","usr/bin/touch","usr/bin/grep","usr/bin/egrep","bin/cpio","bin/sleep","bin/mount","sbin/dhcpcd","bin/bash","sbin/insmod","bin/mkdir","bin/mknod","sbin/ip","bin/cat","usr/bin/awk","usr/bin/wget","bin/cp","usr/bin/cpio","usr/bin/zcat","usr/bin/gzip","lib/mkinitrd/bin/run-init","usr/bin/uniq","usr/bin/sed","sbin/udevd", "usr/bin/readlink", "usr/bin/expr", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/xz") { getlibs($_); push @filestoadd,$_; } diff --git a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.4.ppc64el.pkglist b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.4.ppc64el.pkglist index a6543075b..971deec45 100644 --- a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.4.ppc64el.pkglist +++ b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.4.ppc64el.pkglist @@ -13,3 +13,4 @@ rsync busybox-static gawk dnsutils +xz-utils diff --git a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.4.x86_64.pkglist b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.4.x86_64.pkglist index a6543075b..971deec45 100644 --- a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.4.x86_64.pkglist +++ b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.4.x86_64.pkglist @@ -13,3 +13,4 @@ rsync busybox-static gawk dnsutils +xz-utils diff --git a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.ppc64el.pkglist b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.ppc64el.pkglist index a2b1afbdc..07e8c4b1b 100644 --- a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.ppc64el.pkglist +++ b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.ppc64el.pkglist @@ -14,3 +14,4 @@ rsync busybox-static gawk dnsutils +xz-utils diff --git a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.x86_64.pkglist b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.x86_64.pkglist index a2b1afbdc..07e8c4b1b 100644 --- a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.x86_64.pkglist +++ b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.x86_64.pkglist @@ -14,3 +14,4 @@ rsync busybox-static gawk dnsutils +xz-utils diff --git a/xCAT-server/share/xcat/netboot/ubuntu/dracut/install.netboot b/xCAT-server/share/xcat/netboot/ubuntu/dracut/install.netboot index 6436b7302..a16bd719e 100755 --- a/xCAT-server/share/xcat/netboot/ubuntu/dracut/install.netboot +++ b/xCAT-server/share/xcat/netboot/ubuntu/dracut/install.netboot @@ -1,6 +1,6 @@ #!/bin/sh echo $drivers -dracut_install wget cpio gzip dash modprobe touch echo cut wc +dracut_install wget cpio gzip dash modprobe touch echo cut wc xz dracut_install grep ifconfig hostname awk egrep grep dirname expr dracut_install mount.nfs inst "$moddir/xcatroot" "/sbin/xcatroot" diff --git a/xCAT-server/share/xcat/netboot/ubuntu/dracut/xcatroot b/xCAT-server/share/xcat/netboot/ubuntu/dracut/xcatroot index 894a86a1c..6d9a3cbd0 100755 --- a/xCAT-server/share/xcat/netboot/ubuntu/dracut/xcatroot +++ b/xCAT-server/share/xcat/netboot/ubuntu/dracut/xcatroot @@ -50,6 +50,13 @@ elif [ -r /rootimg.gz ]; then gzip -cd /rootimg.gz |cpio -idum fi echo Done +elif [ -r /rootimg.txz ]; then + echo Setting up RAM-root tmpfs. + mount -t tmpfs -o mode=755 rootfs $NEWROOT + cd $NEWROOT + echo -n "Extracting root filesystem:" + tar -Jxvf /rootimg.txz + echo Done elif [ -r /rootimg-statelite.gz ]; then echo Setting up RAM-root tmpfs for statelite mode. mount -t tmpfs -o mode=755 rootfs $NEWROOT diff --git a/xCAT-server/share/xcat/netboot/ubuntu/genimage b/xCAT-server/share/xcat/netboot/ubuntu/genimage index 1a18df1b1..b1641a240 100755 --- a/xCAT-server/share/xcat/netboot/ubuntu/genimage +++ b/xCAT-server/share/xcat/netboot/ubuntu/genimage @@ -1436,6 +1436,20 @@ EOMS print $inifile " fi\n"; print $inifile " ([ \"\$xcatdebugmode\" = \"1\" ] || [ \"\$xcatdebugmode\" = \"2\" ]) && logger -t xcat -p debug \"Done...\"\n"; print $inifile " echo Done\n"; + print $inifile "elif [ -r /rootimg.txz ]; then\n"; + print $inifile " ([ \"\$xcatdebugmode\" = \"1\" ] || [ \"\$xcatdebugmode\" = \"2\" ]) && logger -t xcat -p debug \"rootimg.txz downloaded,setting up RAM-root tmpfs...\"\n"; + print $inifile " echo Setting up RAM-root tmpfs.\n"; + if ($rootlimit) { + print $inifile " mount -o \"size=$rootlimit,mode=755\" -t tmpfs rootfs \$NEWROOT\n"; + } else { + print $inifile " mount -o mode=755 -t tmpfs rootfs \$NEWROOT\n"; + } + print $inifile " cd \$NEWROOT\n"; + print $inifile " ([ \"\$xcatdebugmode\" = \"1\" ] || [ \"\$xcatdebugmode\" = \"2\" ]) && logger -t xcat -p debug \"Extracting root filesystem:\"\n"; + print $inifile " echo -n \"Extracting root filesystem:\"\n"; + print $inifile " tar -Jxvf /rootimg.txz\n"; + print $inifile " ([ \"\$xcatdebugmode\" = \"1\" ] || [ \"\$xcatdebugmode\" = \"2\" ]) && logger -t xcat -p debug \"Done...\"\n"; + print $inifile " echo Done\n"; print $inifile "else\n"; print $inifile " ([ \"\$xcatdebugmode\" = \"1\" ] || [ \"\$xcatdebugmode\" = \"2\" ]) && logger -t xcat -p debug \"Failed to download image, panicing in 5...\"\n"; print $inifile " echo -n Failed to download image, panicing in 5...\n"; @@ -1573,7 +1587,7 @@ EOMS } } # add rsync for statelite - foreach ( "usr/bin/dig","bin/busybox","bin/bash", "sbin/mount.nfs", "usr/bin/rsync", "sbin/insmod", "sbin/udevd", "sbin/udevadm", "sbin/modprobe", "sbin/blkid", "sbin/depmod","usr/bin/wget") { + foreach ( "usr/bin/dig","bin/busybox","bin/bash", "sbin/mount.nfs", "usr/bin/rsync", "sbin/insmod", "sbin/udevd", "sbin/udevadm", "sbin/modprobe", "sbin/blkid", "sbin/depmod","usr/bin/wget","usr/bin/xz") { getlibs($_); push @filestoadd,$_; } From 0a3fbd8d51457e2dd48cffdd411e32d82dd2ac3a Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Wed, 20 Jul 2016 11:40:27 -0400 Subject: [PATCH 302/310] perltidy all perl files --- perl-xCAT/xCAT/CFMUtils.pm | 261 +- perl-xCAT/xCAT/CIMUtils.pm | 161 +- perl-xCAT/xCAT/Client.pm | 2100 +-- perl-xCAT/xCAT/Common.pm | 202 +- perl-xCAT/xCAT/DBobjUtils.pm | 771 +- perl-xCAT/xCAT/DSHCLI.pm | 2753 ++-- perl-xCAT/xCAT/DSHContext.pm | 36 +- perl-xCAT/xCAT/DSHCore.pm | 108 +- perl-xCAT/xCAT/DSHRemoteShell.pm | 5 +- perl-xCAT/xCAT/DiscoveryUtils.pm | 26 +- perl-xCAT/xCAT/Enabletrace.pm | 66 +- perl-xCAT/xCAT/ExtTab.pm | 183 +- perl-xCAT/xCAT/FSPUtils.pm | 541 +- perl-xCAT/xCAT/FSPboot.pm | 210 +- perl-xCAT/xCAT/FSPbootseq.pm | 240 +- perl-xCAT/xCAT/FSPcfg.pm | 661 +- perl-xCAT/xCAT/FSPconn.pm | 552 +- perl-xCAT/xCAT/FSPflash.pm | 456 +- perl-xCAT/xCAT/FSPinv.pm | 362 +- perl-xCAT/xCAT/FSPmac.pm | 562 +- perl-xCAT/xCAT/FSPpower.pm | 565 +- perl-xCAT/xCAT/FSPscan.pm | 439 +- perl-xCAT/xCAT/FSPvitals.pm | 377 +- perl-xCAT/xCAT/FSPvm.pm | 2352 ++-- perl-xCAT/xCAT/GlobalDef.pm | 138 +- perl-xCAT/xCAT/InstUtils.pm | 1102 +- perl-xCAT/xCAT/KitPluginUtils.pm | 26 +- perl-xCAT/xCAT/LparNetbootExp.pm | 2166 +-- perl-xCAT/xCAT/MacMap.pm | 1050 +- perl-xCAT/xCAT/MsgUtils.pm | 210 +- perl-xCAT/xCAT/NetworkUtils.pm | 1055 +- perl-xCAT/xCAT/NodeRange.pm | 1021 +- perl-xCAT/xCAT/NotifHandler.pm | 372 +- perl-xCAT/xCAT/PPCboot.pm | 301 +- perl-xCAT/xCAT/PPCcfg.pm | 1040 +- perl-xCAT/xCAT/PPCcli.pm | 798 +- perl-xCAT/xCAT/PPCconn.pm | 469 +- perl-xCAT/xCAT/PPCdb.pm | 1052 +- perl-xCAT/xCAT/PPCenergy.pm | 353 +- perl-xCAT/xCAT/PPCfsp.pm | 1389 +- perl-xCAT/xCAT/PPCinv.pm | 406 +- perl-xCAT/xCAT/PPClog.pm | 38 +- perl-xCAT/xCAT/PPCmac.pm | 659 +- perl-xCAT/xCAT/PPCpower.pm | 394 +- perl-xCAT/xCAT/PPCrflash.pm | 755 +- perl-xCAT/xCAT/PPCscan.pm | 476 +- perl-xCAT/xCAT/PPCvitals.pm | 276 +- perl-xCAT/xCAT/PPCvm.pm | 1368 +- perl-xCAT/xCAT/ProfiledNodeUtils.pm | 789 +- perl-xCAT/xCAT/RSH.pm | 95 +- perl-xCAT/xCAT/RSYNC.pm | 140 +- perl-xCAT/xCAT/RemoteShellExp.pm | 1154 +- perl-xCAT/xCAT/SINV.pm | 258 +- perl-xCAT/xCAT/SLP.pm | 650 +- perl-xCAT/xCAT/SPD.pm | 231 +- perl-xCAT/xCAT/SSH.pm | 115 +- perl-xCAT/xCAT/Schema.pm | 344 +- perl-xCAT/xCAT/Scope.pm | 57 +- perl-xCAT/xCAT/ServiceNodeUtils.pm | 311 +- perl-xCAT/xCAT/Table.pm | 2876 ++-- perl-xCAT/xCAT/TableUtils.pm | 1033 +- perl-xCAT/xCAT/Usage.pm | 232 +- perl-xCAT/xCAT/Utils.pm | 2498 ++-- perl-xCAT/xCAT/VMCommon.pm | 301 +- perl-xCAT/xCAT/Version.pm | 12 +- perl-xCAT/xCAT/Yum.pm | 142 +- perl-xCAT/xCAT/Zone.pm | 453 +- perl-xCAT/xCAT/data/discinfo.pm | 228 +- perl-xCAT/xCAT/data/ibmhwtypes.pm | 20 +- perl-xCAT/xCAT/data/ibmleds.pm | 164 +- perl-xCAT/xCAT/data/ipmigenericevents.pm | 114 +- perl-xCAT/xCAT/data/ipmisensorevents.pm | 440 +- perl-xCAT/xCAT/hpoa.pm | 372 +- perl-xCAT/xCAT/vboxService.pm | 1678 +-- perl-xCAT/xCAT/zvmCPUtils.pm | 224 +- perl-xCAT/xCAT/zvmUtils.pm | 869 +- .../lib/perl/xCAT_plugin/openstack.pm | 1383 +- xCAT-OpenStack/lib/perl/xCAT/Cloud.pm | 91 +- xCAT-OpenStack/lib/perl/xCAT_plugin/cloud.pm | 166 +- xCAT-OpenStack/lib/perl/xCAT_schema/Clouds.pm | 138 +- xCAT-UI/xcat/plugins/web.pm | 5405 ++++---- xCAT-UI/xcat/plugins/webportal.pm | 1785 +-- xCAT-buildkit/lib/perl/xCAT/BuildKitUtils.pm | 287 +- .../plugins/sample/imageprofile.pm | 137 +- .../kit_template/plugins/sample/nodemgmt.pm | 30 +- xCAT-client/bin/xtcd.pl | 176 +- xCAT-probe/lib/perl/probe_utils.pm | 58 +- xCAT-probe/lib/perl/xCAT/GlobalDef.pm | 103 + xCAT-probe/lib/perl/xCAT/NetworkUtils.pm | 1055 +- xCAT-rmc/lib/perl/TEAL/Semaphore.pm | 12 +- xCAT-rmc/lib/perl/TEAL/event_id.pm | 80 +- xCAT-rmc/plugin/rmcmetrix.pm | 718 +- xCAT-rmc/plugin/rmcmon.pm | 2616 ++-- .../mn/IBM.Condition/AIXNodeCoreDump.pm | 14 +- .../mn/IBM.Condition/AIXNodeCoreDump_H.pm | 18 +- .../mn/IBM.Condition/AllServiceableEvents.pm | 14 +- .../IBM.Condition/AllServiceableEvents_H.pm | 18 +- .../IBM.Condition/AllServiceableEvents_HB.pm | 12 +- .../mn/IBM.Condition/AnyNodeAnyLoggedError.pm | 14 +- .../IBM.Condition/AnyNodeAnyLoggedError_H.pm | 18 +- .../AnyNodeFileSystemInodesUsed.pm | 16 +- .../AnyNodeFileSystemInodesUsed_H.pm | 20 +- .../AnyNodeFileSystemSpaceUsed.pm | 16 +- .../AnyNodeFileSystemSpaceUsed_H.pm | 20 +- .../AnyNodeNetworkInterfaceStatus.pm | 16 +- .../AnyNodeNetworkInterfaceStatus_H.pm | 20 +- .../AnyNodePagingPercentSpaceFree.pm | 16 +- .../AnyNodePagingPercentSpaceFree_H.pm | 20 +- .../AnyNodeProcessorsIdleTime.pm | 16 +- .../AnyNodeProcessorsIdleTime_H.pm | 20 +- .../mn/IBM.Condition/AnyNodeRealMemFree.pm | 16 +- .../mn/IBM.Condition/AnyNodeRealMemFree_H.pm | 20 +- .../mn/IBM.Condition/AnyNodeTmpSpaceUsed.pm | 18 +- .../mn/IBM.Condition/AnyNodeTmpSpaceUsed_H.pm | 20 +- .../mn/IBM.Condition/AnyNodeVarSpaceUsed.pm | 18 +- .../mn/IBM.Condition/AnyNodeVarSpaceUsed_H.pm | 20 +- .../mn/IBM.Condition/CheckCONSonSN.pm | 18 +- .../mn/IBM.Condition/CheckDHCPonSN.pm | 18 +- .../mn/IBM.Condition/CheckFTPonSN.pm | 18 +- .../mn/IBM.Condition/CheckFTPonSN_AIX.pm | 18 +- .../mn/IBM.Condition/CheckNAMEDonSN.pm | 18 +- .../mn/IBM.Condition/CheckNFSonSN.pm | 18 +- .../mn/IBM.Condition/CheckNTPonSN.pm | 18 +- .../mn/IBM.Condition/CheckTFTPonSN.pm | 28 +- .../mn/IBM.Condition/CheckxCATonSN.pm | 18 +- .../mn/IBM.Condition/Drawer_not_configured.pm | 20 +- .../resources/mn/IBM.Condition/HFI_down.pm | 20 +- .../mn/IBM.Condition/HFI_not_configured.pm | 20 +- .../resources/mn/IBM.Condition/IBSwitchLog.pm | 12 +- .../mn/IBM.Condition/NodeReachability.pm | 12 +- .../mn/IBM.Condition/NodeReachability_B.pm | 24 +- .../mn/IBM.Condition/NodeReachability_H.pm | 20 +- .../mn/IBM.Condition/VarSpaceUsed.pm | 16 +- .../BroadcastEventsAnyTime.pm | 6 +- .../IBM.EventResponse/DisplayEventsAnyTime.pm | 6 +- .../mn/IBM.EventResponse/EmailRootAnyTime.pm | 6 +- .../IBM.EventResponse/EmailRootAnyTime_H.pm | 6 +- .../IBM.EventResponse/EmailRootAnyTime_HB.pm | 6 +- .../mn/IBM.EventResponse/EmailRootOffShift.pm | 6 +- .../LogEventToTealEvenetLog.pm | 6 +- .../LogEventToTealEvenetLog_B.pm | 16 +- .../LogEventToxCATDatabase.pm | 6 +- .../LogEventToxCATDatabase_B.pm | 16 +- .../mn/IBM.EventResponse/LogEvents.pm | 6 +- .../mn/IBM.EventResponse/LogEvents_H.pm | 6 +- .../mn/IBM.EventResponse/LogEvents_HB.pm | 6 +- .../LogOnlyToAuditLogAnyTime.pm | 6 +- .../MsgEventsToRootAnyTime.pm | 6 +- .../MsgEventsToRootAnyTime_H.pm | 6 +- .../MsgEventsToRootAnyTime_HB.pm | 6 +- .../IBM.EventResponse/UpdatexCATNodeStatus.pm | 6 +- .../UpdatexCATNodeStatus_B.pm | 14 +- .../mn/IBM.Sensor/CheckFTPSensor_AIX.pm | 18 +- .../mn/IBM.Sensor/CheckxCATSensor.pm | 18 +- .../mn/IBM.Sensor/Drawer_configuration.pm | 14 +- .../mn/IBM.Sensor/HFI_configuration.pm | 14 +- .../resources/mn/IBM.Sensor/HFI_status.pm | 14 +- .../mn/IBM.Sensor/IBSwitchLogSensor.pm | 20 +- .../node/IBM.Sensor/ErrorLogSensor.pm | 14 +- .../sn/IBM.Condition/AIXNodeCoreDump.pm | 14 +- .../sn/IBM.Condition/AllServiceableEvents.pm | 14 +- .../IBM.Condition/AllServiceableEvents_HB.pm | 12 +- .../sn/IBM.Condition/AnyNodeAnyLoggedError.pm | 14 +- .../AnyNodeFileSystemInodesUsed.pm | 16 +- .../AnyNodeFileSystemSpaceUsed.pm | 16 +- .../AnyNodeNetworkInterfaceStatus.pm | 16 +- .../AnyNodePagingPercentSpaceFree.pm | 16 +- .../AnyNodeProcessorsIdleTime.pm | 16 +- .../sn/IBM.Condition/AnyNodeRealMemFree.pm | 16 +- .../sn/IBM.Condition/AnyNodeTmpSpaceUsed.pm | 18 +- .../sn/IBM.Condition/AnyNodeVarSpaceUsed.pm | 18 +- .../resources/sn/IBM.Condition/IBSwitchLog.pm | 12 +- .../sn/IBM.Condition/NodeReachability.pm | 12 +- .../sn/IBM.Condition/NodeReachability_B.pm | 24 +- .../LogEventToTealEvenetLog.pm | 6 +- .../LogEventToTealEvenetLog_B.pm | 16 +- .../LogEventToxCATDatabase.pm | 6 +- .../LogEventToxCATDatabase_B.pm | 16 +- .../UpdatexCATNodeStatus_B.pm | 14 +- .../sn/IBM.Sensor/CheckFTPSensor_AIX.pm | 18 +- .../sn/IBM.Sensor/CheckxCATSensor.pm | 18 +- .../resources/sn/IBM.Sensor/ErrorLogSensor.pm | 14 +- .../sn/IBM.Sensor/IBSwitchLogSensor.pm | 20 +- xCAT-server/lib/perl/xCAT/ADUtils.pm | 269 +- xCAT-server/lib/perl/xCAT/IMMUtils.pm | 210 +- xCAT-server/lib/perl/xCAT/IPMI.pm | 1133 +- xCAT-server/lib/perl/xCAT/MellanoxIB.pm | 1047 +- xCAT-server/lib/perl/xCAT/PPC.pm | 2208 +-- xCAT-server/lib/perl/xCAT/PasswordUtils.pm | 194 +- xCAT-server/lib/perl/xCAT/Postage.pm | 2063 +-- xCAT-server/lib/perl/xCAT/RShellAPI.pm | 606 +- xCAT-server/lib/perl/xCAT/SSHInteract.pm | 123 +- xCAT-server/lib/perl/xCAT/SvrUtils.pm | 1734 +-- xCAT-server/lib/perl/xCAT/TZUtils.pm | 1381 +- xCAT-server/lib/perl/xCAT/Template.pm | 2603 ++-- xCAT-server/lib/perl/xCAT/WinUtils.pm | 38 +- xCAT-server/lib/perl/xCAT/xcatd.pm | 509 +- xCAT-server/lib/xcat/Confluent/Client.pm | 53 +- xCAT-server/lib/xcat/Confluent/TLV.pm | 12 +- xCAT-server/lib/xcat/dsh/Context/DSH.pm | 380 +- xCAT-server/lib/xcat/dsh/Context/XCAT.pm | 47 +- xCAT-server/lib/xcat/monitoring/bootttmon.pm | 108 +- xCAT-server/lib/xcat/monitoring/gangliamon.pm | 317 +- .../lib/xcat/monitoring/monitorctrl.pm | 1759 +-- .../lib/xcat/monitoring/montbhandler.pm | 75 +- xCAT-server/lib/xcat/monitoring/nagiosmon.pm | 1396 +- xCAT-server/lib/xcat/monitoring/pcpmon.pm | 521 +- xCAT-server/lib/xcat/monitoring/rrdutil.pm | 464 +- .../lib/xcat/monitoring/samples/mycode.pm | 112 +- .../xcat/monitoring/samples/templatemon.pm | 334 +- xCAT-server/lib/xcat/monitoring/snmpmon.pm | 1810 +-- xCAT-server/lib/xcat/monitoring/xcatmon.pm | 377 +- xCAT-server/lib/xcat/plugins/00kitnodebase.pm | 154 +- xCAT-server/lib/xcat/plugins/AAAusage.pm | 118 +- xCAT-server/lib/xcat/plugins/AAsn.pm | 605 +- xCAT-server/lib/xcat/plugins/DBobjectdefs.pm | 848 +- xCAT-server/lib/xcat/plugins/FIP.pm | 377 +- xCAT-server/lib/xcat/plugins/aaadiscovery.pm | 29 +- .../lib/xcat/plugins/activedirectory.pm | 474 +- xCAT-server/lib/xcat/plugins/aixinstall.pm | 11271 ++++++++-------- xCAT-server/lib/xcat/plugins/anaconda.pm | 3015 +++-- xCAT-server/lib/xcat/plugins/blade.pm | 9404 ++++++------- xCAT-server/lib/xcat/plugins/bmcconfig.pm | 303 +- xCAT-server/lib/xcat/plugins/bmcdiscover.pm | 556 +- xCAT-server/lib/xcat/plugins/boottarget.pm | 178 +- xCAT-server/lib/xcat/plugins/bpa.pm | 30 +- xCAT-server/lib/xcat/plugins/configfpc.pm | 809 +- xCAT-server/lib/xcat/plugins/confluent.pm | 853 +- xCAT-server/lib/xcat/plugins/conserver.pm | 1009 +- xCAT-server/lib/xcat/plugins/copycds.pm | 335 +- xCAT-server/lib/xcat/plugins/credentials.pm | 551 +- xCAT-server/lib/xcat/plugins/ddns.pm | 1257 +- xCAT-server/lib/xcat/plugins/debian.pm | 1312 +- xCAT-server/lib/xcat/plugins/destiny.pm | 1326 +- xCAT-server/lib/xcat/plugins/dhcp.pm | 2178 +-- xCAT-server/lib/xcat/plugins/docker.pm | 459 +- xCAT-server/lib/xcat/plugins/energy.pm | 611 +- xCAT-server/lib/xcat/plugins/esx.pm | 6290 ++++----- xCAT-server/lib/xcat/plugins/frusetter.pm | 73 +- xCAT-server/lib/xcat/plugins/fsp.pm | 316 +- xCAT-server/lib/xcat/plugins/genimage.pm | 883 +- xCAT-server/lib/xcat/plugins/geninitrd.pm | 96 +- xCAT-server/lib/xcat/plugins/getadapter.pm | 21 +- xCAT-server/lib/xcat/plugins/getpartition.pm | 58 +- xCAT-server/lib/xcat/plugins/getpostscript.pm | 75 +- xCAT-server/lib/xcat/plugins/grub2.pm | 12 +- xCAT-server/lib/xcat/plugins/hmc.pm | 225 +- xCAT-server/lib/xcat/plugins/hosts.pm | 322 +- xCAT-server/lib/xcat/plugins/hpblade.pm | 3512 ++--- xCAT-server/lib/xcat/plugins/hpilo.pm | 1233 +- xCAT-server/lib/xcat/plugins/imgcapture.pm | 429 +- xCAT-server/lib/xcat/plugins/imgport.pm | 1984 +-- xCAT-server/lib/xcat/plugins/ipmi.pm | 9250 ++++++------- xCAT-server/lib/xcat/plugins/iscsi.pm | 302 +- xCAT-server/lib/xcat/plugins/ivm.pm | 184 +- xCAT-server/lib/xcat/plugins/kit.pm | 2815 ++-- xCAT-server/lib/xcat/plugins/kmodules.pm | 670 +- xCAT-server/lib/xcat/plugins/kvm.pm | 261 +- xCAT-server/lib/xcat/plugins/litetree.pm | 720 +- xCAT-server/lib/xcat/plugins/lsslp.pm | 1958 +-- .../lib/xcat/plugins/makeknownhosts.pm | 44 +- xCAT-server/lib/xcat/plugins/makentp.pm | 194 +- xCAT-server/lib/xcat/plugins/mic.pm | 452 +- xCAT-server/lib/xcat/plugins/mknb.pm | 588 +- xCAT-server/lib/xcat/plugins/monctrlcmds.pm | 3001 ++-- xCAT-server/lib/xcat/plugins/networks.pm | 793 +- xCAT-server/lib/xcat/plugins/nimol.pm | 373 +- xCAT-server/lib/xcat/plugins/nodediscover.pm | 275 +- xCAT-server/lib/xcat/plugins/nodestat.pm | 2093 +-- xCAT-server/lib/xcat/plugins/notification.pm | 370 +- xCAT-server/lib/xcat/plugins/offline.pm | 59 +- xCAT-server/lib/xcat/plugins/ontap.pm | 218 +- xCAT-server/lib/xcat/plugins/osdistro.pm | 330 +- xCAT-server/lib/xcat/plugins/packimage.pm | 727 +- xCAT-server/lib/xcat/plugins/petitboot.pm | 1016 +- xCAT-server/lib/xcat/plugins/prescripts.pm | 562 +- xCAT-server/lib/xcat/plugins/profilednodes.pm | 1530 ++- xCAT-server/lib/xcat/plugins/pxe.pm | 1096 +- .../lib/xcat/plugins/remoteimmsetup.pm | 410 +- xCAT-server/lib/xcat/plugins/rescanplugins.pm | 95 +- xCAT-server/lib/xcat/plugins/rhevm.pm | 2064 +-- xCAT-server/lib/xcat/plugins/rinstall.pm | 136 +- xCAT-server/lib/xcat/plugins/rmimage.pm | 430 +- xCAT-server/lib/xcat/plugins/rollupdate.pm | 2014 +-- xCAT-server/lib/xcat/plugins/route.pm | 1270 +- xCAT-server/lib/xcat/plugins/seqdiscovery.pm | 655 +- xCAT-server/lib/xcat/plugins/setup.pm | 2869 ++-- xCAT-server/lib/xcat/plugins/sinv.pm | 10 +- xCAT-server/lib/xcat/plugins/sles.pm | 2211 +-- xCAT-server/lib/xcat/plugins/slpdiscover.pm | 509 +- xCAT-server/lib/xcat/plugins/snmove.pm | 1666 +-- xCAT-server/lib/xcat/plugins/statelite.pm | 799 +- xCAT-server/lib/xcat/plugins/svc.pm | 262 +- xCAT-server/lib/xcat/plugins/switch.pm | 559 +- xCAT-server/lib/xcat/plugins/syncfiles.pm | 60 +- xCAT-server/lib/xcat/plugins/tabutils.pm | 2651 ++-- xCAT-server/lib/xcat/plugins/toolscenter.pm | 291 +- xCAT-server/lib/xcat/plugins/tree.pm | 252 +- xCAT-server/lib/xcat/plugins/typemtms.pm | 28 +- xCAT-server/lib/xcat/plugins/updatenode.pm | 2278 ++-- xCAT-server/lib/xcat/plugins/vbox.pm | 1390 +- xCAT-server/lib/xcat/plugins/vsmppxe.pm | 831 +- xCAT-server/lib/xcat/plugins/windows.pm | 735 +- xCAT-server/lib/xcat/plugins/xCATWorld.pm | 93 +- xCAT-server/lib/xcat/plugins/xcat2nim.pm | 1801 +-- xCAT-server/lib/xcat/plugins/xdsh.pm | 942 +- xCAT-server/lib/xcat/plugins/xen.pm | 1344 +- xCAT-server/lib/xcat/plugins/xnba.pm | 1104 +- xCAT-server/lib/xcat/plugins/yaboot.pm | 1422 +- xCAT-server/lib/xcat/plugins/zone.pm | 1043 +- xCAT-server/lib/xcat/plugins/zvm.pm | 4984 +++---- xCAT-server/lib/xcat/plugins/zzzdiscovery.pm | 12 +- xCAT-server/lib/xcat/schema/samples/Sample.pm | 146 +- .../xcat/netboot/add-on/autogpfs/autogpfsc.pl | 182 +- .../xcat/netboot/add-on/autogpfs/autogpfsd.pl | 565 +- .../share/xcat/netboot/imgutils/imgutils.pm | 228 +- xCAT-server/share/xcat/scripts/bitscount.pl | 10 +- xCAT-server/share/xcat/scripts/countbits.pl | 2 +- .../share/xcat/scripts/extractefiboot.pl | 141 +- .../share/xcat/tools/powervm/configcec.pm | 536 +- xCAT-server/xCAT-wsapi/genrestapidoc.pm | 254 +- xCAT-server/xCAT-wsapi/restapi.pl | 1041 +- xCAT-server/xCAT-wsapi/xcatws-test.pl | 56 +- .../autotest/testcase/genesis/genesistest.pl | 173 +- xCAT-vlan/xCAT/SwitchHandler.pm | 362 +- xCAT-vlan/xCAT_plugin/vlan.pm | 3289 ++--- xCAT-vlan/xCAT_plugin/vlan/BNTSwitch.pm | 804 +- xCAT-vlan/xCAT_plugin/vlan/CiscoSwitch.pm | 889 +- xCAT/postscripts/cvs_template.pl | 5 +- 329 files changed, 109527 insertions(+), 104006 deletions(-) create mode 100644 xCAT-probe/lib/perl/xCAT/GlobalDef.pm diff --git a/perl-xCAT/xCAT/CFMUtils.pm b/perl-xCAT/xCAT/CFMUtils.pm index 2c66e0004..e2563cfa4 100644 --- a/perl-xCAT/xCAT/CFMUtils.pm +++ b/perl-xCAT/xCAT/CFMUtils.pm @@ -4,7 +4,7 @@ package xCAT::CFMUtils; BEGIN { - $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; } use lib "$::XCATROOT/lib/perl"; @@ -58,11 +58,11 @@ sub initCFMdir # below system files will be synced to all compute nodes my @sysfiles = ("/etc/hosts"); - # the /etc/passwd, shadow, group files will be merged + # the /etc/passwd, shadow, group files will be merged my @userfiles = ("/etc/passwd", "/etc/shadow", "/etc/group"); # create the cfmdir - if (! -d $cfmdir) + if (!-d $cfmdir) { mkpath $cfmdir; } @@ -70,20 +70,20 @@ sub initCFMdir # backup the OS files and create links under cfmdir foreach my $file (@userfiles) { - my $backup = $file.".OS"; - if (! -e $backup) + my $backup = $file . ".OS"; + if (!-e $backup) { copy($file, $backup); } - if (! -e "$cfmdir/".basename($backup)) + if (!-e "$cfmdir/" . basename($backup)) { - symlink($backup, "$cfmdir/".basename($backup)); + symlink($backup, "$cfmdir/" . basename($backup)); } } # Initialize CFM directory and related files - if (! -d "$cfmdir/etc") + if (!-d "$cfmdir/etc") { mkpath "$cfmdir/etc"; } @@ -93,16 +93,17 @@ sub initCFMdir { symlink($file, "$cfmdir/$file"); } + # touch and link the merge files for /etc/passwd, shadow, group foreach my $file (@userfiles) { - my $merge = $file.".merge"; - if (! -e "$merge") + my $merge = $file . ".merge"; + if (!-e "$merge") { xCAT::Utils->runcmd("touch $merge", -1); } - if (! -e "$cfmdir/$merge") + if (!-e "$cfmdir/$merge") { symlink($merge, "$cfmdir/$merge"); } @@ -143,18 +144,18 @@ sub updateUserInfo { $rsp->{data}->[0] = "Skiping the update of the /etc/passwd, shadow, group merge files under the CFM directory."; xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); } - return 0; + return 0; } foreach my $file (@userfiles) { my @oldrecords = (); my @newrecords = (); - my $backup = basename($file).".OS"; + my $backup = basename($file) . ".OS"; # get the records from /etc/passwd, shadow, group file and backup files(.OS files) - # and all the files from /install/osimages/$imgname/cfmdir directory - foreach my $userinfo ($file, "$cfmdir/$backup") + # and all the files from /install/osimages/$imgname/cfmdir directory + foreach my $userinfo ($file, "$cfmdir/$backup") { my $fp; open($fp, $userinfo); @@ -162,18 +163,18 @@ sub updateUserInfo { while (<$fp>) { my $line = xCAT::CFMUtils->trim($_); - if (($line =~ /^#/) || ($line =~ /^\s*$/ )) - { #comment line or blank line + if (($line =~ /^#/) || ($line =~ /^\s*$/)) + { #comment line or blank line next; } else - { + { push @records, $line; - } + } } close($fp); # check the records from /etc/passwd, shadow, group file or backup - if ($userinfo =~ /^\/etc/ ) + if ($userinfo =~ /^\/etc/) { @newrecords = @records; } else { @@ -182,8 +183,9 @@ sub updateUserInfo { } # update the merge file - my $mergefile = $cfmdir."/".$file.".merge"; + my $mergefile = $cfmdir . "/" . $file . ".merge"; my @diff = xCAT::CFMUtils->arrayops("D", \@newrecords, \@oldrecords); + # output the diff to merge files my $fp; open($fp, '>', $mergefile); @@ -199,8 +201,8 @@ sub updateUserInfo { print $fp "$record\n"; } } - close ($fp); - + close($fp); + } return 0; @@ -208,6 +210,7 @@ sub updateUserInfo { #----------------------------------------------------------------------------- + =head3 setCFMSynclistFile Set osimage synclists attribute for CFM function, the CMF synclist file is: /install/osimages//synclist.cfm @@ -224,6 +227,7 @@ sub updateUserInfo { my $cfmdir = xCAT::CFMUtils->setCFMSynclistFile($imagename); if ($cfmdir) { # update the CFM synclist file } =cut + #----------------------------------------------------------------------------- sub setCFMSynclistFile { my ($class, $img) = @_; @@ -234,18 +238,19 @@ sub setCFMSynclistFile { # get the cfmdir and synclists attributes my $osimage_t = xCAT::Table->new('osimage'); - my $records = $osimage_t->getAttribs({imagename=>$img}, 'cfmdir', 'synclists'); - if (defined ($records->{'cfmdir'})) + my $records = $osimage_t->getAttribs({ imagename => $img }, 'cfmdir', 'synclists'); + if (defined($records->{'cfmdir'})) { $cfmdir = $records->{'cfmdir'}; - if (defined ($records->{'synclists'})) {$synclists = $records->{'synclists'}} + if (defined($records->{'synclists'})) { $synclists = $records->{'synclists'} } } else { + # no cfmdir defined, return directly return 0; } my $found = 0; - my $index = 0; + my $index = 0; if ($synclists) { # the synclists is a comma separated list @@ -253,7 +258,7 @@ sub setCFMSynclistFile { foreach my $synclist (@lists) { # find the synclist configuration for CFM - if ($synclist eq $cfmsynclist) + if ($synclist eq $cfmsynclist) { $found = 1; last; @@ -263,17 +268,19 @@ sub setCFMSynclistFile { if ($found == 0) { # the CFM synclist is not defined, append it to $synclists - $synclists = "$synclists,$cfmsynclist"; - # set the synclists attribute - $osimage_t->setAttribs({imagename=>$img}, {'synclists' => $synclists}); + $synclists = "$synclists,$cfmsynclist"; + + # set the synclists attribute + $osimage_t->setAttribs({ imagename => $img }, { 'synclists' => $synclists }); } } else { + # no synclists defined, set it to CFM synclist file if ($cfmdir) { $synclists = $cfmsynclist; } - $osimage_t->setAttribs({imagename=>$img}, {'synclists' => $synclists}); + $osimage_t->setAttribs({ imagename => $img }, { 'synclists' => $synclists }); } - return $cfmdir; + return $cfmdir; } @@ -335,60 +342,62 @@ sub updateCFMSynclistFile { { my $cfmdir; $cfmdir = xCAT::CFMUtils->setCFMSynclistFile($osimg); - if ($cfmdir) # check for /install/osiamges/$osimg/cfmdir + if ($cfmdir) # check for /install/osiamges/$osimg/cfmdir { my $cfmsynclist = "/install/osimages/$osimg/synclist.cfm"; - if (! -d $cfmdir) + if (!-d $cfmdir) { - # skip this one go on to the next image, nothing to do for + # skip this one go on to the next image, nothing to do for # CFMUtils in this image next; } + # create the parent directory of CFM synclist file - if (! -d dirname($cfmsynclist)) + if (!-d dirname($cfmsynclist)) { mkpath dirname($cfmsynclist); } # update /etc/passwd, shadow, group merge files my $ret = xCAT::CFMUtils->updateUserInfo($cfmdir); - if ($ret !=0 ) + if ($ret != 0) { my $rsp = {}; - $rsp->{error}->[0] = - "Update /etc/passwd, shadow, group merge files failed."; + $rsp->{error}->[0] = + "Update /etc/passwd, shadow, group merge files failed."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); return 1; } - # recursively list the files under cfm directory + # recursively list the files under cfm directory my @files = (); - find ( { wanted => sub { push @files, $File::Find::name if -f }, follow => 1 }, $cfmdir); - if (!@files) # not files under cfm directory, skip to next loop + find({ wanted => sub { push @files, $File::Find::name if -f }, follow => 1 }, $cfmdir); + if (!@files) # not files under cfm directory, skip to next loop { next; } my $fp; open($fp, '>', $cfmsynclist); - my @mergefiles = (); + my @mergefiles = (); my @appendfiles = (); foreach my $file (@files) { my $name = basename($file); - #TODO: find a better way to get the suffix + + #TODO: find a better way to get the suffix my $suffix = ($name =~ m/([^.]+)$/)[0]; my $dest = substr($file, length($cfmdir)); - if ($suffix eq "OS") # skip the backup files + if ($suffix eq "OS") # skip the backup files { next; - } elsif ($suffix eq "merge") # merge file + } elsif ($suffix eq "merge") # merge file { push(@mergefiles, $file); - } elsif ($suffix eq "append") { # append file - push(@appendfiles, $file); - } else { # output the syncing files maintained by CFM + } elsif ($suffix eq "append") { # append file + push(@appendfiles, $file); + } else { # output the syncing files maintained by CFM print $fp "$file -> $dest\n"; } } @@ -398,7 +407,7 @@ sub updateCFMSynclistFile { print $fp "APPEND:\n"; } foreach my $file (@appendfiles) - { + { my $dest = substr($file, length($cfmdir), length($file) - length(".append") - length($cfmdir)); print $fp "$file -> $dest\n"; } @@ -411,21 +420,23 @@ sub updateCFMSynclistFile { { my @userfiles = ("/etc/passwd", "/etc/shadow", "/etc/group"); my $dest = substr($file, length($cfmdir), length($file) - length(".merge") - length($cfmdir)); + # only /etc/passwd, /etc/shadow, /etc/groups merging is supported - if (grep(/$dest/, @userfiles)) { + if (grep(/$dest/, @userfiles)) { print $fp "$file -> $dest\n"; } } - - # close the file - close($fp); + + # close the file + close($fp); } } - + return 0; } #----------------------------------------------------------------------------- + =head3 setCFMPkglistFile Set the pkglist attribute of linuximage object for CFM function @@ -441,20 +452,21 @@ sub updateCFMSynclistFile { Example: my $ret = xCAT::CFMUtils->setCFMPkglistFile($imagename); =cut + #----------------------------------------------------------------------------- sub setCFMPkglistFile { my ($class, $img) = @_; - my $pkglists = ""; + my $pkglists = ""; my $cfmpkglist = "/install/osimages/$img/pkglist.cfm"; # get the pkglist files my $linuximage_t = xCAT::Table->new('linuximage'); - my $records = $linuximage_t->getAttribs({imagename => $img}, 'pkglist'); + my $records = $linuximage_t->getAttribs({ imagename => $img }, 'pkglist'); if ($records) { if ($records->{'pkglist'}) { $pkglists = $records->{'pkglist'}; } - } else + } else { if ($::VERBOSE) { @@ -469,27 +481,29 @@ sub setCFMPkglistFile { { foreach my $pkglist (split(/,/, $pkglists)) { - if ($pkglist eq $cfmpkglist) # the pkglist file for CFM is found, exit the loop + if ($pkglist eq $cfmpkglist) # the pkglist file for CFM is found, exit the loop { $found = 1; last; } } - # the pkglist file for CFM is not found, append it to $pkglits - if (!$found) + + # the pkglist file for CFM is not found, append it to $pkglits + if (!$found) { - $pkglists = "$pkglists,$cfmpkglist"; + $pkglists = "$pkglists,$cfmpkglist"; + # set the pkglist attribute for linuximage - $linuximage_t->setAttribs({imagename => $img}, {'pkglist' => $pkglists}); - } - } else + $linuximage_t->setAttribs({ imagename => $img }, { 'pkglist' => $pkglists }); + } + } else { # the pkglist file for linuximage is not defined, set it to $cfmpkglist $pkglists = $cfmpkglist; - $linuximage_t->setAttribs({imagename => $img}, {'pkglist' => $pkglists}); + $linuximage_t->setAttribs({ imagename => $img }, { 'pkglist' => $pkglists }); } - return 0; + return 0; } #----------------------------------------------------------------------------- @@ -517,17 +531,19 @@ sub setCFMPkglistFile { #----------------------------------------------------------------------------- sub updateCFMPkglistFile { my ($class, $img, $ospkgs, $mode) = @_; - - if(defined($mode)){ + + if (defined($mode)) { + # Exact Matching $mode = 1; - }else { + } else { + # Fuzzy Matching $mode = 0; } - + my @cur_selected = @$ospkgs; - my $cfmpkglist = "/install/osimages/$img/pkglist.cfm"; + my $cfmpkglist = "/install/osimages/$img/pkglist.cfm"; my $ret = xCAT::CFMUtils->setCFMPkglistFile($img); if ($ret) @@ -539,7 +555,7 @@ sub updateCFMPkglistFile { } # check the parent directory of cfmpkglist file - if (! -d dirname($cfmpkglist)) + if (!-d dirname($cfmpkglist)) { mkpath dirname($cfmpkglist); } @@ -547,10 +563,11 @@ sub updateCFMPkglistFile { # get previous selected and removed OS packages list from pkglist file my ($pre_selected_ref, $pre_removed_ref) = xCAT::CFMUtils->getPreOSpkgsList($cfmpkglist); my @pre_selected = @$pre_selected_ref; - my @pre_removed = @$pre_removed_ref; + my @pre_removed = @$pre_removed_ref; # get the #INCLUDE file from cfmpkglist file my @incfiles = xCAT::CFMUtils->getIncludefiles($cfmpkglist); + # get the packages list in the #INCLUDE files my @basepkgs = (); foreach my $inc (@incfiles) @@ -559,18 +576,18 @@ sub updateCFMPkglistFile { my @selected = @$selected_ref; @basepkgs = xCAT::CFMUtils->arrayops("U", \@basepkgs, \@selected); } - + # Fuzzy Matching - if (not $mode){ + if (not $mode) { my ($ref1, $ref2, $ref3) = xCAT::CFMUtils->updateSelectedPkgs(\@pre_selected, \@pre_removed, \@cur_selected); @pre_selected = @$ref1; - @pre_removed = @$ref2; + @pre_removed = @$ref2; @cur_selected = @$ref3; } - # get diff between previous and current selected OS packages lists + # get diff between previous and current selected OS packages lists my @diff = xCAT::CFMUtils->getPkgsDiff(\@pre_selected, \@cur_selected); - + # merge the diff to previous removed OS packages list my @all_removed = xCAT::CFMUtils->arrayops("U", \@pre_removed, \@diff); @@ -590,6 +607,7 @@ sub updateCFMPkglistFile { { print $fp "#INCLUDE:$inc#\n"; } + # the pacakges be installed if (@cur_selected) { @@ -598,6 +616,7 @@ sub updateCFMPkglistFile { print $fp "$pkg\n"; } } + # the packages be removed if (@cur_removed) { @@ -606,6 +625,7 @@ sub updateCFMPkglistFile { print $fp "-$pkg\n"; } } + # close the file close($fp); @@ -635,8 +655,8 @@ sub updateCFMPkglistFile { #----------------------------------------------------------------------------- sub getPreOSpkgsList { my ($class, $pkglist) = @_; - my @selected = (); - my @removed = (); + my @selected = (); + my @removed = (); my @pkglistfiles = (); # get the #INCLUDE file from cfmpkglist file @@ -645,6 +665,7 @@ sub getPreOSpkgsList { { push @pkglistfiles, $inc; } + # assume the #INCLUDE file includes the BASE packages push @pkglistfiles, $pkglist; @@ -655,20 +676,20 @@ sub getPreOSpkgsList { while (<$pkglistfp>) { my $line = xCAT::CFMUtils->trim($_); - if (($line =~ /^#/) || ($line =~ /^\s*$/ ) || ($line =~ /^@/)) - { #comment line or blank line + if (($line =~ /^#/) || ($line =~ /^\s*$/) || ($line =~ /^@/)) + { #comment line or blank line next; } else { if ($line =~ /^-/) - { # the package be removed + { # the package be removed push @removed, substr($line, 1); } else - { # the package be installed + { # the package be installed push @selected, $line; - } + } } - } + } close($pkglistfp); } @@ -700,21 +721,21 @@ sub getPreOSpkgsList { #----------------------------------------------------------------------------- sub getPreBaseOSpkgsList { my ($class, $pkglist) = @_; - - my ($pre_selected_ref, $pre_removed_ref) = xCAT::CFMUtils->getPreOSpkgsList($pkglist); - + + my ($pre_selected_ref, $pre_removed_ref) = xCAT::CFMUtils->getPreOSpkgsList($pkglist); + my %pre_selected_hash = (); foreach (@$pre_selected_ref) { my @names = split(/\./, $_); my $basename = $names[0]; - + if ($_ =~ /^$basename\.([^\.]+)$/) { $pre_selected_hash{$basename} = 1; - }else { + } else { $pre_selected_hash{$_} = 1; } } - + my @pre_selected = keys %pre_selected_hash; return \@pre_selected; @@ -749,6 +770,7 @@ sub getPkgsDiff { # get the difference my @diff = xCAT::CFMUtils->arrayops("D", \@$pre, \@tmp); + #print Dumper(@diff); return @diff; @@ -783,14 +805,15 @@ sub getIncludefiles { { my $line = xCAT::CFMUtils->trim($_); if ($line =~ /^\s*$/) - { # blank line + { # blank line next; } + # find the #INCLUDE line if ($line =~ /^\s*#INCLUDE:[^#^\n]+#/) { #print "The line is: [$line]\n"; - my $incfile = substr($line, length("#INCLUDE:"), length($line)-length("#INCLUDE:")-1); + my $incfile = substr($line, length("#INCLUDE:"), length($line) - length("#INCLUDE:") - 1); push @files, $incfile; } } @@ -857,13 +880,13 @@ sub trim { sub arrayops { my ($class, $ops, $array1, $array2) = @_; - my @union = (); + my @union = (); my @intersection = (); - my @difference = (); - my %count = (); - foreach my $element (@$array1, @$array2) - { - $count{$element}++ + my @difference = (); + my %count = (); + foreach my $element (@$array1, @$array2) + { + $count{$element}++ } foreach my $element (keys %count) { @@ -872,7 +895,7 @@ sub arrayops { } if ($ops eq "U") { return @union; } - + if ($ops eq "I") { return @intersection; } if ($ops eq "D") { return @difference; } @@ -903,19 +926,19 @@ sub arrayops { #----------------------------------------------------------------------------- sub updateSelectedPkgs() { - my ($class, $pre_selected_ref, $pre_removed_ref, $cur_selected_ref) = @_; - - my %pre_selected_hash = map{$_ => 1} @$pre_selected_ref; - my %pre_removed_hash = map{$_ => 1} @$pre_removed_ref; - my %cur_selected_hash = map{$_ => 1} @$cur_selected_ref; - + my ($class, $pre_selected_ref, $pre_removed_ref, $cur_selected_ref) = @_; + + my %pre_selected_hash = map { $_ => 1 } @$pre_selected_ref; + my %pre_removed_hash = map { $_ => 1 } @$pre_removed_ref; + my %cur_selected_hash = map { $_ => 1 } @$cur_selected_ref; + my %new_pre_selected_hash = %pre_selected_hash; - my %new_pre_removed_hash = %pre_removed_hash; + my %new_pre_removed_hash = %pre_removed_hash; my %new_cur_selected_hash = %cur_selected_hash; - + foreach (keys %cur_selected_hash) { my $father = $_; - my $flag = 0; + my $flag = 0; foreach (keys %pre_selected_hash) { my $child = $_; if ($child =~ /^$father\.([^\.]+)$/) { @@ -923,10 +946,10 @@ sub updateSelectedPkgs() { $flag = 1; } } - if ($flag and not exists $pre_selected_hash{$father}){ + if ($flag and not exists $pre_selected_hash{$father}) { delete $new_cur_selected_hash{$father} if exists $new_cur_selected_hash{$father}; } - + foreach (keys %pre_removed_hash) { my $child = $_; if ($child =~ /^$father\.([^\.]+)$/) { @@ -934,11 +957,11 @@ sub updateSelectedPkgs() { } } } - + my @new_cur_selected = keys %new_cur_selected_hash; my @new_pre_selected = keys %new_pre_selected_hash; - my @new_pre_removed = keys %new_pre_removed_hash; - - - return (\@new_pre_selected, \@new_pre_removed, \@new_cur_selected); + my @new_pre_removed = keys %new_pre_removed_hash; + + + return (\@new_pre_selected, \@new_pre_removed, \@new_cur_selected); } diff --git a/perl-xCAT/xCAT/CIMUtils.pm b/perl-xCAT/xCAT/CIMUtils.pm index 1c49f0102..d13a2e93a 100644 --- a/perl-xCAT/xCAT/CIMUtils.pm +++ b/perl-xCAT/xCAT/CIMUtils.pm @@ -63,74 +63,74 @@ sub enum_instance unless (ref($http_params)) { $http_params = shift; } - + my $cim_params = shift; - # This is a mandatory parameter + # This is a mandatory parameter unless ($cim_params->{classname}) { - return ({rc => 1, msg => "Missed the classname"}); + return ({ rc => 1, msg => "Missed the classname" }); } unless ($cim_params->{namespace}) { $cim_params->{namespace} = "ibmsd"; } - + # prepare the CIM payload my $tmpnode; # create a new doc - my $doc = XML::LibXML->createDocument('1.0','UTF-8'); - + my $doc = XML::LibXML->createDocument('1.0', 'UTF-8'); + # create and add the root element my $root = $doc->createElement("CIM"); $root->setAttribute("CIMVERSION", "2.0"); $root->setAttribute("DTDVERSION", "2.0"); - + $doc->setDocumentElement($root); - + # create and add the MESSAGE element my $message = $doc->createElement("MESSAGE"); - $message->setAttribute("ID", "1000"); + $message->setAttribute("ID", "1000"); $message->setAttribute("PROTOCOLVERSION", "1.0"); - + $root->addChild($message); - + # add a SIMPLE REQUEST my $simple_request = $doc->createElement("SIMPLEREQ"); $message->addChild($simple_request); - + # add an IMETHOD CALL my $imethod_call = $doc->createElement("IMETHODCALL"); $imethod_call->setAttribute("NAME", "EnumerateInstances"); - + $simple_request->addChild($imethod_call); - + # add the local name space path my $localnamespacepath = $doc->createElement("LOCALNAMESPACEPATH"); $tmpnode = $doc->createElement("NAMESPACE"); $tmpnode->setAttribute("NAME", "root"); $localnamespacepath->addChild($tmpnode); - + $tmpnode = $doc->createElement("NAMESPACE"); $tmpnode->setAttribute("NAME", $cim_params->{namespace}); $localnamespacepath->addChild($tmpnode); - + $imethod_call->addChild($localnamespacepath); - + # add the target class name my $param_classname = $doc->createElement("IPARAMVALUE"); $param_classname->setAttribute("NAME", "ClassName"); $imethod_call->addChild($param_classname); - + my $classname = $doc->createElement("CLASSNAME"); $classname->setAttribute("NAME", $cim_params->{classname}); $param_classname->addChild($classname); - + # add several common parameters $imethod_call->appendWellBalancedChunk('TRUEFALSEFALSETRUE'); - + my $payload = $doc->toString(); - + # generate http request my $ret = gen_http_request($http_params, $payload); @@ -146,15 +146,15 @@ sub enum_instance # parse the http response my $ret_value; - my $parser = XML::LibXML->new(); + my $parser = XML::LibXML->new(); my $resp_doc = $parser->parse_string($ret->{payload}); # check the error message from CIM my $error_node = $resp_doc->getElementsByTagName("ERROR"); if ($error_node) { - my $msg = $error_node->[0]->getAttribute("DESCRIPTION"); + my $msg = $error_node->[0]->getAttribute("DESCRIPTION"); my $errorcode = $error_node->[0]->getAttribute("CODE"); - return ({rc => 1, cim_rc => $errorcode, msg => $error_node->[0]->getAttribute("DESCRIPTION")." [cim return code: $errorcode]"}); + return ({ rc => 1, cim_rc => $errorcode, msg => $error_node->[0]->getAttribute("DESCRIPTION") . " [cim return code: $errorcode]" }); } # get the name path of the instance, which is used to set property @@ -167,6 +167,7 @@ sub enum_instance # get all the instance elements my @instances = $resp_doc->getElementsByTagName("VALUE.NAMEDINSTANCE"); foreach my $instance (@instances) { + # get all the property element for each instance my @properties = $instance->getElementsByTagName("PROPERTY"); if (my @property_arrays = $instance->getElementsByTagName("PROPERTY.ARRAY")) { @@ -174,18 +175,19 @@ sub enum_instance } my $ins_value; foreach my $property (@properties) { + # get name, vlaue and type for each property. (only the one which has value) if (my $pname = $property->getAttribute("NAME")) { if (my $pvalue = $property->getAttribute("TYPE")) { $ins_value->{property}->{$pname}->{type} = $pvalue; } if ($property->getElementsByTagName("VALUE.ARRAY")) { - my @nodelist = $property->getElementsByTagName("VALUE"); + my @nodelist = $property->getElementsByTagName("VALUE"); my @value_array = (); foreach my $n (@nodelist) { push @value_array, $n->textContent; } - $ins_value->{property}->{$pname}->{value} = join(',',@value_array); + $ins_value->{property}->{$pname}->{value} = join(',', @value_array); } elsif (my $node = $property->getElementsByTagName("VALUE")) { $ins_value->{property}->{$pname}->{value} = $node->[0]->textContent; } @@ -193,8 +195,8 @@ sub enum_instance } push @{$ret_value}, $ins_value; } - - return ({rc =>0}, $ret_value, $namepath_string); + + return ({ rc => 0 }, $ret_value, $namepath_string); } =head1 set_property () @@ -213,71 +215,72 @@ sub enum_instance cim_rc - The return code from CIM server. msg - Output message. =cut + sub set_property { my $http_params = shift; unless (ref($http_params)) { $http_params = shift; } - + my $cim_params = shift; # This is a mandatory parameter unless ($cim_params->{namepath}) { - return ({rc => 1, msg => "Missed the name path for the instance"}); + return ({ rc => 1, msg => "Missed the name path for the instance" }); } unless ($cim_params->{namespace}) { $cim_params->{namespace} = "ibmsd"; } - + # prepare the CIM payload my $tmpnode; # create a new doc - my $doc = XML::LibXML->createDocument('1.0','UTF-8'); - + my $doc = XML::LibXML->createDocument('1.0', 'UTF-8'); + # create and add the root element my $root = $doc->createElement("CIM"); $root->setAttribute("CIMVERSION", "2.0"); $root->setAttribute("DTDVERSION", "2.0"); - + $doc->setDocumentElement($root); - + # create and add the MESSAGE element my $message = $doc->createElement("MESSAGE"); - $message->setAttribute("ID", "1000"); + $message->setAttribute("ID", "1000"); $message->setAttribute("PROTOCOLVERSION", "1.0"); - + $root->addChild($message); - + # add a SIMPLE REQUEST my $simple_request = $doc->createElement("SIMPLEREQ"); $message->addChild($simple_request); - + # add an IMETHOD CALL my $imethod_call = $doc->createElement("IMETHODCALL"); $imethod_call->setAttribute("NAME", "SetProperty"); - + $simple_request->addChild($imethod_call); - + # add the local name space path my $localnamespacepath = $doc->createElement("LOCALNAMESPACEPATH"); $tmpnode = $doc->createElement("NAMESPACE"); $tmpnode->setAttribute("NAME", "root"); $localnamespacepath->addChild($tmpnode); - + $tmpnode = $doc->createElement("NAMESPACE"); $tmpnode->setAttribute("NAME", $cim_params->{namespace}); $localnamespacepath->addChild($tmpnode); - + $imethod_call->addChild($localnamespacepath); - + # add the target property name my $param_propertyname = $doc->createElement("IPARAMVALUE"); $param_propertyname->setAttribute("NAME", "PropertyName"); $imethod_call->addChild($param_propertyname); - + $tmpnode = $doc->createElement("VALUE"); $tmpnode->appendTextNode($cim_params->{propertyname}); $param_propertyname->addChild($tmpnode); @@ -286,19 +289,19 @@ sub set_property my $param_newvaluename = $doc->createElement("IPARAMVALUE"); $param_newvaluename->setAttribute("NAME", "NewValue"); $imethod_call->addChild($param_newvaluename); - + $tmpnode = $doc->createElement("VALUE"); $tmpnode->appendTextNode($cim_params->{propertyvalue}); $param_newvaluename->addChild($tmpnode); - + # add parameters of instance name path my $param_namepath = $doc->createElement("IPARAMVALUE"); $param_namepath->setAttribute("NAME", "InstanceName"); $param_namepath->appendWellBalancedChunk($cim_params->{namepath}); $imethod_call->addChild($param_namepath); - + my $payload = $doc->toString(); - + # generate http request my $ret = gen_http_request($http_params, $payload); @@ -314,15 +317,15 @@ sub set_property # parse the http response my $ret_value; - my $parser = XML::LibXML->new(); + my $parser = XML::LibXML->new(); my $resp_doc = $parser->parse_string($ret->{payload}); # check the error message from CIM my $error_node = $resp_doc->getElementsByTagName("ERROR"); if ($error_node) { - my $msg = $error_node->[0]->getAttribute("DESCRIPTION"); + my $msg = $error_node->[0]->getAttribute("DESCRIPTION"); my $errorcode = $error_node->[0]->getAttribute("CODE"); - return ({rc => 1, cim_rc => $errorcode, msg => $error_node->[0]->getAttribute("DESCRIPTION")." [cim return code: $errorcode]"}); + return ({ rc => 1, cim_rc => $errorcode, msg => $error_node->[0]->getAttribute("DESCRIPTION") . " [cim return code: $errorcode]" }); } @@ -347,40 +350,40 @@ sub set_property sub gen_http_request { - my $http_params = shift; + my $http_params = shift; my $http_payload = shift; - + # check the mandatory parameters - unless (defined ($http_params->{ip}) && defined ($http_params->{port}) && defined($http_params->{user}) && defined($http_params->{password})) { - return ({rc => 1, msg => "Missed the mandatory parameters: ip, port, user or password"}); + unless (defined($http_params->{ip}) && defined($http_params->{port}) && defined($http_params->{user}) && defined($http_params->{password})) { + return ({ rc => 1, msg => "Missed the mandatory parameters: ip, port, user or password" }); } # set the default value for parameters - unless (defined ($http_params->{protocol})) { + unless (defined($http_params->{protocol})) { $http_params->{protocol} = 'https'; } - unless (defined ($http_params->{format})) { + unless (defined($http_params->{format})) { $http_params->{format} = 'xml'; } - unless (defined ($http_params->{method})) { + unless (defined($http_params->{method})) { $http_params->{method} = 'GET'; } my $payload = ''; - if (defined ($http_params->{payload})) { + if (defined($http_params->{payload})) { $payload = $http_params->{payload}; } - if (defined ($http_payload)) { - unless (ref($http_payload)) { #Todo: support payloasd to be a hash + if (defined($http_payload)) { + unless (ref($http_payload)) { #Todo: support payloasd to be a hash $payload = $http_payload; } } # create the http head my $header = HTTP::Headers->new('content-type' => "application/$http_params->{format}", - 'Accept' => "application/$http_params->{format}", - 'User-Agent' => "xCAT/2", - 'Host' => "$http_params->{ip}:$http_params->{port}"); + 'Accept' => "application/$http_params->{format}", + 'User-Agent' => "xCAT/2", + 'Host' => "$http_params->{ip}:$http_params->{port}"); # set the user & password $header->authorization_basic($http_params->{user}, $http_params->{password}); @@ -396,7 +399,7 @@ sub gen_http_request # set the http version $request->protocol('HTTP/1.1'); - return ({rc => 0, request => $request}); + return ({ rc => 0, request => $request }); } @@ -418,44 +421,44 @@ sub gen_http_request sub send_http_request { - my $http_params = shift; + my $http_params = shift; my $http_request = shift; # Load the library LWP::Protocol::https for https support if ($http_params->{protocol} eq 'https') { - eval { require LWP::Protocol::https}; + eval { require LWP::Protocol::https }; if ($@) { - return ({rc => 1, msg => "Failed to load perl library LWP::Protocol::https"}); + return ({ rc => 1, msg => "Failed to load perl library LWP::Protocol::https" }); } } # create a new HTTP User Agent Object - my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0, SSL_verify_mode => 0}); + my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0, SSL_verify_mode => 0 }); if ($http_params->{timeout}) { $ua->timeout($http_params->{timeout}); } else { - $ua->timeout(10); # the default timeout is 10s + $ua->timeout(10); # the default timeout is 10s } - if (defined($http_params->{verbose}) && defined ($http_params->{callback})) { - $http_params->{callback}({data => ["\n========CIM Request Start========", $http_request->as_string(), "=======CIM Request End======="]}); + if (defined($http_params->{verbose}) && defined($http_params->{callback})) { + $http_params->{callback}({ data => [ "\n========CIM Request Start========", $http_request->as_string(), "=======CIM Request End=======" ] }); } # send request and receive the response my $response = $ua->request($http_request); - if (defined($http_params->{verbose}) && defined ($http_params->{callback}) && defined ($response->{_content})) { - $http_params->{callback}({data => ["\n========CIM Response Start========", $response->{_content}, "=======CIM Response End======="]}); + if (defined($http_params->{verbose}) && defined($http_params->{callback}) && defined($response->{_content})) { + $http_params->{callback}({ data => [ "\n========CIM Response Start========", $response->{_content}, "=======CIM Response End=======" ] }); } # check the http response - if (defined ($response) && defined ($response->{_rc}) && defined ($response->{_msg})) { + if (defined($response) && defined($response->{_rc}) && defined($response->{_msg})) { if ($response->{_rc} eq "200" && $response->{_msg} eq "OK") { - return ({rc => 0, http_rc => $response->{_rc}, msg => "$response->{_msg} [http return code: $response->{_rc}]", payload => $response->{_content}}); + return ({ rc => 0, http_rc => $response->{_rc}, msg => "$response->{_msg} [http return code: $response->{_rc}]", payload => $response->{_content} }); } } - - return ({rc => 1, http_rc => $response->{_rc}, msg => $response->{_msg}}); + + return ({ rc => 1, http_rc => $response->{_rc}, msg => $response->{_msg} }); } diff --git a/perl-xCAT/xCAT/Client.pm b/perl-xCAT/xCAT/Client.pm index 467e703d0..b460d5f38 100644 --- a/perl-xCAT/xCAT/Client.pm +++ b/perl-xCAT/xCAT/Client.pm @@ -1,35 +1,37 @@ #!/usr/bin/env perl # IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html package xCAT::Client; + BEGIN { - $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; } # if AIX - make sure we include perl 5.8.2 in INC path. # Needed to find perl dependencies shipped in deps tarball. use Storable qw/nstore_fd fd_retrieve/; if ($^O =~ /^aix/i) { - unshift(@INC, qw(/usr/opt/perl5/lib/5.8.2/aix-thread-multi /usr/opt/perl5/lib/5.8.2 /usr/opt/perl5/lib/site_perl/5.8.2/aix-thread-multi /usr/opt/perl5/lib/site_perl/5.8.2)); + unshift(@INC, qw(/usr/opt/perl5/lib/5.8.2/aix-thread-multi /usr/opt/perl5/lib/5.8.2 /usr/opt/perl5/lib/site_perl/5.8.2/aix-thread-multi /usr/opt/perl5/lib/site_perl/5.8.2)); } use IO::Handle; use MIME::Base64 qw(decode_base64); use IO::Socket::SSL; my $inet6support; -if ($^O =~ /^aix/i) { # disable AIX IPV6 TODO fix - $inet6support = 0; +if ($^O =~ /^aix/i) { # disable AIX IPV6 TODO fix + $inet6support = 0; } else { - $inet6support=eval { require Socket6; 1; }; + $inet6support = eval { require Socket6; 1; }; } if ($inet6support) { - $inet6support = eval { require IO::Socket::INET6; 1; }; + $inet6support = eval { require IO::Socket::INET6; 1; }; } if ($inet6support) { - $inet6support = eval { require IO::Socket::SSL; IO::Socket::SSL->import('inet6'); 1;}; + $inet6support = eval { require IO::Socket::SSL; IO::Socket::SSL->import('inet6'); 1; }; } if ($^O =~ /^linux/i) { + # Is IPv6 enabled on the MN or xcat client node at all? my $ipv6enabled = `ip addr 2> /dev/null | grep inet6`; if (!$ipv6enabled) { @@ -38,63 +40,66 @@ if ($^O =~ /^linux/i) { } unless ($inet6support) { - eval { require Socket }; - eval { require IO::Socket::INET }; - eval { require IO::Socket::SSL; IO::Socket::SSL->import('inet4') }; + eval { require Socket }; + eval { require IO::Socket::INET }; + eval { require IO::Socket::SSL; IO::Socket::SSL->import('inet4') }; } -use XML::Simple; #smaller than libxml.... +use XML::Simple; #smaller than libxml.... use Fcntl; use POSIX qw/:errno_h/; use IO::Select; -$XML::Simple::PREFERRED_PARSER='XML::Parser'; +$XML::Simple::PREFERRED_PARSER = 'XML::Parser'; + #require Data::Dumper; -my $xcathost='localhost:3001'; +my $xcathost = 'localhost:3001'; my $plugins_dir; my %resps; -my $EXITCODE; # save the bitmask of all exit codes returned by calls to handle_response() +my $EXITCODE; # save the bitmask of all exit codes returned by calls to handle_response() 1; sub rspclean { - my $response = shift; - my $callback = shift; - my $rsps = XMLin($response,SuppressEmpty=>undef,ForceArray=>1); - foreach my $rsp (@{$rsps->{xcatresponse}}) { - #add ESC back - foreach my $key (keys %$rsp) { - if (ref($rsp->{$key}) eq 'ARRAY') { - foreach my $text (@{$rsp->{$key}}) { - next unless defined $text; - $text =~ s/xxxxESCxxxx/\e/g; - } - } - else { - $rsp->{$key} =~ s/xxxxESCxxxx/\e/g; - } - } - $callback->($rsp); - if ($rsp->{serverdone}) { - return 1; - } - } - return 0; + my $response = shift; + my $callback = shift; + my $rsps = XMLin($response, SuppressEmpty => undef, ForceArray => 1); + foreach my $rsp (@{ $rsps->{xcatresponse} }) { + + #add ESC back + foreach my $key (keys %$rsp) { + if (ref($rsp->{$key}) eq 'ARRAY') { + foreach my $text (@{ $rsp->{$key} }) { + next unless defined $text; + $text =~ s/xxxxESCxxxx/\e/g; + } + } + else { + $rsp->{$key} =~ s/xxxxESCxxxx/\e/g; + } + } + $callback->($rsp); + if ($rsp->{serverdone}) { + return 1; + } + } + return 0; } + sub send_request { my $request = shift; - my $sock = shift; - my $encode = shift; + my $sock = shift; + my $encode = shift; if ($encode eq "xml") { - my $msg=XMLout($request,RootName=>'xcatrequest',NoAttr=>1,KeyAttr=>[]); + my $msg = XMLout($request, RootName => 'xcatrequest', NoAttr => 1, KeyAttr => []); if ($ENV{XCATXMLTRACE}) { print $msg; } - if($ENV{XCATXMLWARNING}) { + if ($ENV{XCATXMLWARNING}) { validateXML($msg); } print $sock $msg; $sock->flush(); } else { - nstore_fd($request,$sock); + nstore_fd($request, $sock); $sock->flush(); } } @@ -133,846 +138,881 @@ sub send_request { # always create hashes with array values. ################################# sub submit_request { - my $request = shift; - my $callback = shift; - my $keyfile = shift; - my $certfile = shift; - my $cafile = shift; - # get home directory - my @user = getpwuid($>); - my $homedir=$user[7]; - unless ($keyfile) { $keyfile = $homedir."/.xcat/client-cred.pem"; } - unless ($certfile) { $certfile = $homedir."/.xcat/client-cred.pem"; } - unless ($cafile) { $cafile = $homedir."/.xcat/ca.pem"; } - $xCAT::Client::EXITCODE = 0; # clear out exit code before invoking the plugin -if (ref($request) eq 'HASH') { # the request is an array, not pure XML - $request->{clienttype}->[0] = "cli"; # setup clienttype for auditlog -} -# If XCATBYPASS is set, invoke the plugin process_request method directly -# without going through the socket connection to the xcatd daemon - if ($ENV{XCATBYPASS}) { - #add current userid to the request - if (ref($request) eq 'HASH') { # the request is an array, not pure XML - if (!(defined($request->{username}))) { - $request->{username}->[0] = getpwuid($>); - } + my $request = shift; + my $callback = shift; + my $keyfile = shift; + my $certfile = shift; + my $cafile = shift; - # only allow root to run - unless ($request->{username}->[0] =~ /root/) { - print ("WARNING: Only allow root to run XCATBYPASS mode, your current user ID is $request->{username}->[0].\n"); - return 0; - } - } - # Load plugins from either specified or default dir - require xCAT::Table; - my %cmd_handlers; - my @plugins_dirs = split('\:',$ENV{XCATBYPASS}); - if (-d $plugins_dirs[0]) { - foreach (@plugins_dirs) { - $plugins_dir = $_; - scan_plugins(); - } + # get home directory + my @user = getpwuid($>); + my $homedir = $user[7]; + unless ($keyfile) { $keyfile = $homedir . "/.xcat/client-cred.pem"; } + unless ($certfile) { $certfile = $homedir . "/.xcat/client-cred.pem"; } + unless ($cafile) { $cafile = $homedir . "/.xcat/ca.pem"; } + $xCAT::Client::EXITCODE = 0; # clear out exit code before invoking the plugin + if (ref($request) eq 'HASH') { # the request is an array, not pure XML + $request->{clienttype}->[0] = "cli"; # setup clienttype for auditlog + } + + # If XCATBYPASS is set, invoke the plugin process_request method directly + # without going through the socket connection to the xcatd daemon + if ($ENV{XCATBYPASS}) { + + #add current userid to the request + if (ref($request) eq 'HASH') { # the request is an array, not pure XML + if (!(defined($request->{username}))) { + $request->{username}->[0] = getpwuid($>); + } + + # only allow root to run + unless ($request->{username}->[0] =~ /root/) { + print("WARNING: Only allow root to run XCATBYPASS mode, your current user ID is $request->{username}->[0].\n"); + return 0; + } + } + + # Load plugins from either specified or default dir + require xCAT::Table; + my %cmd_handlers; + my @plugins_dirs = split('\:', $ENV{XCATBYPASS}); + if (-d $plugins_dirs[0]) { + foreach (@plugins_dirs) { + $plugins_dir = $_; + scan_plugins(); + } + } else { + + # figure out default plugins dir + #my $sitetab=xCAT::Table->new('site'); + #unless ($sitetab) { + # print ("ERROR: Unable to open basic site table for configuration\n"); + #} + $plugins_dir = $::XCATROOT . '/lib/perl/xCAT_plugin'; + scan_plugins(); + } + + populate_site_hash(); + + # don't do XML transformation -- assume request is well-formed + # my $xmlreq=XMLout($request,RootName=>xcatrequest,NoAttr=>1,KeyAttr=>[]); + # $request = XMLin($xmlreq,SuppressEmpty=>undef,ForceArray=>1) ; + + + # Call the plugin directly + # ${"xCAT_plugin::".$modname."::"}{process_request}->($request,$callback); + plugin_command($request, undef, $callback); + return 0; + } + + # No XCATBYPASS, so establish a socket connection with the xcatd daemon + # and submit the request + if ($ENV{XCATHOST}) { + $xcathost = $ENV{XCATHOST}; + } + my %connargs = (); + if ($xcathost =~ s/%([^\]|:]*)//) { + $connargs{PeerScope} = $1; + } + $connargs{PeerAddr} = $xcathost; + $connargs{Timeout} = 15; + if ($connargs{PeerScope} and $connargs{PeerScope} =~ /[a-zA-Z]/) { #non-numeric, need to translate... + my @ipdata = `ip link`; + @ipdata = grep(/[^@]$connargs{PeerScope}(:|@)/, @ipdata); + if (scalar(@ipdata) != 1) { + print STDERR "Unable to identify scope " . $connargs{PeerScope} . "\n"; + exit(1); + } + $connargs{PeerScope} = $ipdata[0]; + $connargs{PeerScope} =~ s/:.*//; + } + + + my $pclient; + if ($inet6support) { + $pclient = IO::Socket::INET6->new( + %connargs, + ); } else { - # figure out default plugins dir - #my $sitetab=xCAT::Table->new('site'); - #unless ($sitetab) { - # print ("ERROR: Unable to open basic site table for configuration\n"); - #} - $plugins_dir=$::XCATROOT.'/lib/perl/xCAT_plugin'; - scan_plugins(); + $pclient = IO::Socket::INET->new( + PeerAddr => $xcathost, + Timeout => 15, + ); + } + unless ($pclient) { + print "Unable to open socket connection to xcatd daemon on $xcathost.\n"; + print "Verify that the xcatd daemon is running and that your SSL setup is correct.\n"; + if ($@ =~ /SSL Timeout/) { + die "Connection failure: SSL Timeout or incorrect certificates in ~/.xcat"; + } else { + die "Connection failure: $@" + } + } + my $client; + my %sslargs; + if (defined($ENV{'XCATSSLVER'})) { + $sslargs{SSL_version} = $ENV{'XCATSSLVER'}; + } + if (-r $keyfile and -r $certfile and -r $cafile) { + $client = IO::Socket::SSL->start_SSL($pclient, + SSL_key_file => $keyfile, + SSL_cert_file => $certfile, + SSL_ca_file => $cafile, + SSL_verify_mode => SSL_VERIFY_PEER, + SSL_verifycn_scheme => "none", + SSL_use_cert => 1, + Timeout => 0, + %sslargs, + ); + } else { + $client = IO::Socket::SSL->start_SSL($pclient, + Timeout => 0, + ); + } + unless ($client) { + print "Unable to open socket connection to xcatd daemon on $xcathost.\n"; + print "Verify that the xcatd daemon is running and that your SSL setup is correct.\n"; + if ($@ =~ /SSL Timeout/) { + die "Connection failure: SSL Timeout or incorrect certificates in ~/.xcat"; + } else { + die "Connection failure: $@" + } } - populate_site_hash(); + my $msg; + my $encode = "xml"; - # don't do XML transformation -- assume request is well-formed - # my $xmlreq=XMLout($request,RootName=>xcatrequest,NoAttr=>1,KeyAttr=>[]); - # $request = XMLin($xmlreq,SuppressEmpty=>undef,ForceArray=>1) ; - - - # Call the plugin directly - # ${"xCAT_plugin::".$modname."::"}{process_request}->($request,$callback); - plugin_command($request,undef,$callback); - return 0; - } - -# No XCATBYPASS, so establish a socket connection with the xcatd daemon -# and submit the request - if ($ENV{XCATHOST}) { - $xcathost=$ENV{XCATHOST}; - } - my %connargs=(); - if ($xcathost =~ s/%([^\]|:]*)//) { - $connargs{PeerScope} = $1; - } - $connargs{PeerAddr} = $xcathost; - $connargs{Timeout} = 15; - if ($connargs{PeerScope} and $connargs{PeerScope} =~ /[a-zA-Z]/) { #non-numeric, need to translate... - my @ipdata = `ip link`; - @ipdata = grep(/[^@]$connargs{PeerScope}(:|@)/,@ipdata); - if (scalar(@ipdata) != 1) { - print STDERR "Unable to identify scope ".$connargs{PeerScope}."\n"; - exit(1); - } - $connargs{PeerScope} = $ipdata[0]; - $connargs{PeerScope} =~ s/:.*//; - } - - - my $pclient; - if ($inet6support) { - $pclient = IO::Socket::INET6->new( - %connargs, - ); - } else { - $pclient = IO::Socket::INET->new( - PeerAddr => $xcathost, - Timeout => 15, - ); - } - unless ($pclient) { - print "Unable to open socket connection to xcatd daemon on $xcathost.\n"; - print "Verify that the xcatd daemon is running and that your SSL setup is correct.\n"; - if ($@ =~ /SSL Timeout/) { - die "Connection failure: SSL Timeout or incorrect certificates in ~/.xcat"; - } else { - die "Connection failure: $@" - } - } - my $client; - my %sslargs; - if (defined($ENV{'XCATSSLVER'})) { - $sslargs{SSL_version} = $ENV{'XCATSSLVER'}; - } - if (-r $keyfile and -r $certfile and -r $cafile) { - $client = IO::Socket::SSL->start_SSL($pclient, - SSL_key_file => $keyfile, - SSL_cert_file => $certfile, - SSL_ca_file => $cafile, - SSL_verify_mode => SSL_VERIFY_PEER, - SSL_verifycn_scheme => "none", - SSL_use_cert => 1, - Timeout => 0, - %sslargs, - ); - } else { - $client = IO::Socket::SSL->start_SSL($pclient, - Timeout => 0, - ); - } - unless ($client) { - print "Unable to open socket connection to xcatd daemon on $xcathost.\n"; - print "Verify that the xcatd daemon is running and that your SSL setup is correct.\n"; - if ($@ =~ /SSL Timeout/) { - die "Connection failure: SSL Timeout or incorrect certificates in ~/.xcat"; - } else { - die "Connection failure: $@" - } - } - - my $msg; - my $encode = "xml"; - #storable encoding is unsafe, carry on with the unsafe xml scheme - #perhaps one day will support faster schemes - #my $encode = "storable"; - #my $straightprint=0; - #if ($ENV{XCATXMLTRACE} or $ENV{XCATXMLWARNING}) { $encode="xml"; } - if (ref($request) eq 'HASH') { # the request is an array, not pure XML - #print $client "xcatencoding: $encode\n"; - #my $encok=<$client>; - send_request($request,$client,$encode); - } else { #XML - $straightprint=1; - $msg=$request; - print $client $msg; - } - # when receive TERM or INT (ctrl^c) from user, sleep 2s before exit to make - # sure the server (xcatd) has recevied 'abortcommand' command - $SIG{TERM} = $SIG{INT} = sub { send_request({abortcommand=>[1]},$client,$encode); sleep 2; exit 0; }; - my $response; - my $rsp; - my $cleanexit=0; - if ($encode eq 'xml') { - my $massresponse=""; - my $nextcoalescetime=time()+1; - my $coalescenow=0; - my $flags=fcntl($client,F_GETFL,0); - $flags |= O_NONBLOCK; #select can be a bit.. fickle, make sysread work more easily... - fcntl($client,F_SETFL,$flags); - my $clientsel = new IO::Select; - $clientsel->add($client); - my $line; - my $newdata=0; - while (1) { - my $shouldexit; - if ($newdata and ($coalescenow or time() > $nextcoalescetime)) { - $coalescenow=0; - $newdata=0; - $nextcoalescetime=time()+1; - $massresponse .= ""; - $shouldexit = rspclean($massresponse,$callback); - $massresponse=""; - } - - if ($shouldexit) { - $cleanexit=1; - last; - } - $line = ""; - $clientsel->can_read(0.5); - my $readbytes; - do { $readbytes=sysread($client,$line,65535,length($line)); } while ($readbytes); - unless (length($line)) { - if (not defined $readbytes and $! == EAGAIN) { next; } - last; + #storable encoding is unsafe, carry on with the unsafe xml scheme + #perhaps one day will support faster schemes + #my $encode = "storable"; + #my $straightprint=0; + #if ($ENV{XCATXMLTRACE} or $ENV{XCATXMLWARNING}) { $encode="xml"; } + if (ref($request) eq 'HASH') { # the request is an array, not pure XML + #print $client "xcatencoding: $encode\n"; + #my $encok=<$client>; + send_request($request, $client, $encode); + } else { #XML + $straightprint = 1; + $msg = $request; + print $client $msg; } - $newdata=1; - $response .= $line; - if ($line =~ m/<\/xcatresponse>\s*\z/) { - if ($line =~ /serverdone/) { $coalescenow=1; } #if serverdone was detected, hint at coalesce code to flush things out now - #this means that coalesce can be triggered by stray words in the output prematurely, but that's harmless - #replace ESC with xxxxESCxxx because XMLin cannot handle it - $response =~ s/\e/xxxxESCxxxx/g; - if ($ENV{XCATXMLTRACE}) { print $response; } - $massresponse.=$response; - $response=''; - if($ENV{XCATXMLWARNING}) { - validateXML($response); - } - } - } - if (not $cleanexit and $massresponse ne "") { - $massresponse .= ""; - $cleanexit = rspclean($massresponse,$callback); - } - } else { #storable encode + # when receive TERM or INT (ctrl^c) from user, sleep 2s before exit to make + # sure the server (xcatd) has recevied 'abortcommand' command + $SIG{TERM} = $SIG{INT} = sub { send_request({ abortcommand => [1] }, $client, $encode); sleep 2; exit 0; }; + my $response; my $rsp; - eval { $rsp = fd_retrieve($client); }; - SERVERINPUT: while ($rsp) { - my @rsps; - if (ref $rsp eq 'ARRAY') { - @rsps = @$rsp; - } else { - @rsps = ($rsp); - } - foreach (@rsps) { - $callback->($_); - if ($_->{serverdone}) { - $cleanexit=1; - last SERVERINPUT; - } - } - $rsp = undef; - eval { $rsp = fd_retrieve($client); }; - } - } - $massresponse=""; - unless ($cleanexit) { - print STDERR "ERROR/WARNING: communication with the xCAT server seems to have been ended prematurely\n"; - $xCAT::Client::EXITCODE = 1; - } + my $cleanexit = 0; + if ($encode eq 'xml') { + my $massresponse = ""; + my $nextcoalescetime = time() + 1; + my $coalescenow = 0; + my $flags = fcntl($client, F_GETFL, 0); + $flags |= O_NONBLOCK; #select can be a bit.. fickle, make sysread work more easily... + fcntl($client, F_SETFL, $flags); + my $clientsel = new IO::Select; + $clientsel->add($client); + my $line; + my $newdata = 0; -sub validateXML { - my $xml = shift; - my @lines = split /\n/, $xml; - my $invalidNewline = 0; - my $contentsColon = 0; - my $contentsLine; - - foreach (@lines) { - if(!$invalidNewline) { - if( ($_ =~ // && $_ !~ /<\/contents>/) || - ($_ =~ // && $_ !~ /<\/desc>/)) { - $invalidNewline = 1; - print "Possible invalid XML using newlines found: \n$xml\n"; - } - } - if($_ =~ /.+:.+<\/contents>/) { - $contentsColon = 1; - $contentsLine = $_; - } - if($_ =~ /.+<\/desc>/) { - $contentsColon = 0; - } - if($contentsColon && $_ =~ /<\/desc>/) { - print "Possible invalid XML found(data contents using colon and blank description): \n$contentsLine\n$_\n"; - $contentsColon = 0; - } - } -} - -################################### -# scan_plugins -# will load all plugin perl modules and build a list of supported -# commands -# -# NOTE: This is copied from xcatd (last merge 11/23/09). -# TODO: Will eventually move to using common source.... -################################### -sub scan_plugins { - my @plugins=glob($plugins_dir."/*.pm"); - foreach (@plugins) { - /.*\/([^\/]*).pm$/; - my $modname = $1; - unless ( eval { require "$_" }) { -# xCAT::MsgUtils->message("S","Error loading module ".$_." ...skipping"); - print "Error loading module $_ ...skipping\n"; - next; - } - no strict 'refs'; - my $cmd_adds=${"xCAT_plugin::".$modname."::"}{handled_commands}->(); - foreach (keys %$cmd_adds) { - my $value = $_; - if (defined($cmd_handlers{$_})) { - push @{$cmd_handlers{$_}},[$modname,$cmd_adds->{$_}]; - } else { - $cmd_handlers{$_} = [ [$modname,$cmd_adds->{$_}] ]; - } - } - } - foreach (@plugins) { - no strict 'refs'; - /.*\/([^\/]*).pm$/; - my $modname = $1; - unless (defined(${"xCAT_plugin::".$modname."::"}{init_plugin})) { - next; - } - ${"xCAT_plugin::".$modname."::"}{init_plugin}->(\&do_request); - } -} - - - - -################################### -# plugin_command -# will invoke the correct plugin -# -# NOTE: This is copied from xcatd (last merge 11/23/09). -# TODO: Will eventually move to using common source.... -################################### -sub plugin_command { - my $req = shift; - my $sock = shift; - my $callback = shift; - my %handler_hash; - my $usesiteglobal = 0; - # We require these only in bypass mode to reduce start up time for the normal case - #use lib "$::XCATROOT/lib/perl"; - #use xCAT::NodeRange; - require lib; - lib->import("$::XCATROOT/lib/perl"); - require xCAT::NodeRange; - require xCAT::Table; - - $Main::resps={}; - my $xmlreq; - if (ref($req) ne 'HASH') { # the request XML, get an array - $xmlreq=$req; # save the original XML - $req = XMLin($xmlreq,SuppressEmpty=>undef,ForceArray=>1) ; - - } - my @nodes; - if ($req->{node}) { - @nodes = @{$req->{node}}; - } elsif ($req->{noderange} and $req->{noderange}->[0]) { - @nodes = xCAT::NodeRange::noderange($req->{noderange}->[0]); - if (xCAT::NodeRange::nodesmissed()) { -# my $rsp = {errorcode=>1,error=>"Invalid nodes in noderange:".join(',',xCAT::NodeRange::nodesmissed)}; -# my $rsp->{serverdone} = {}; - print "Invalid nodes in noderange:".join(',',xCAT::NodeRange::nodesmissed())."\n"; -# if ($sock) { -# print $sock XMLout($rsp,RootName=>'xcatresponse' ,NoAttr=>1); -# } -# return ($rsp); - return 1; - } - unless (@nodes) { - $req->{emptynoderange} = [1]; - } - } - if (@nodes) { $req->{node} = \@nodes; } - my %unhandled_nodes; - foreach (@nodes) { - $unhandled_nodes{$_}=1; - } - my $useunhandled=0; - if (defined($cmd_handlers{$req->{command}->[0]})) { - my $hdlspec; - my @globalhandlers=(); - my $useglobals=1; #If it stays 1, then use globals normally, if 0, use only for 'unhandled_nodes, if -1, don't do at all - foreach (@{$cmd_handlers{$req->{command}->[0]}}) { - $hdlspec =$_->[1]; - my $ownmod = $_->[0]; - if ($hdlspec =~ /^site:/) { #A site entry specifies a plugin - my $sitekey = $hdlspec; - $sitekey =~ s/^site://; - #$sitetab = xCAT::Table->new('site'); - #my $sent = $sitetab->getAttribs({key=>$sitekey},['value']); - #if ($sent and $sent->{value}) { #A site style plugin specification is just like - if ($::XCATSITEVALS{$sitekey}) { #A site style plugin specification is just like - #a static global, it grabs all nodes rather than some - $useglobals = -1; #If they tried to specify anything, don't use the default global handlers at all - unless (@nodes) { - $handler_hash{$::XCATSITEVALS{$sitekey}} = 1; - $usesiteglobal = 1; + while (1) { + my $shouldexit; + if ($newdata and ($coalescenow or time() > $nextcoalescetime)) { + $coalescenow = 0; + $newdata = 0; + $nextcoalescetime = time() + 1; + $massresponse .= ""; + $shouldexit = rspclean($massresponse, $callback); + $massresponse = ""; } - foreach (@nodes) { #Specified a specific plugin, not a table lookup - $handler_hash{$::XCATSITEVALS{$sitekey}}->{$_} = 1; + + if ($shouldexit) { + $cleanexit = 1; + last; } - } - } elsif ($hdlspec =~ /:/) { #Specificed a table lookup path for plugin name - if (@nodes) { # only use table lookup plugin if nodelist exists - # Usage will be handled in common AAAhelp plugin - - $useglobals = 0; #Only contemplate nodes that aren't caught through searching below in the global handler - $useunhandled=1; - my $table; - my $cols; - ($table,$cols) = split(/:/,$hdlspec); - my @colmns=split(/,/,$cols); - my @columns; - my $hdlrtable=xCAT::Table->new($table); - unless ($hdlrtable) { - #TODO: proper error handling - } - my $node; - my $colvals = {}; - foreach my $colu (@colmns) { - if ($colu =~ /=/) { #a value redirect to a pattern/specific name - my $coln; my $colv; - ($coln,$colv) = split(/=/,$colu,2); - $colvals->{$coln} = $colv; - push (@columns,$coln); - } else { - push (@columns,$colu); + $line = ""; + $clientsel->can_read(0.5); + my $readbytes; + do { $readbytes = sysread($client, $line, 65535, length($line)); } while ($readbytes); + unless (length($line)) { + if (not defined $readbytes and $! == EAGAIN) { next; } + last; } - } + $newdata = 1; + $response .= $line; + if ($line =~ m/<\/xcatresponse>\s*\z/) { + if ($line =~ /serverdone/) { $coalescenow = 1; } #if serverdone was detected, hint at coalesce code to flush things out now + #this means that coalesce can be triggered by stray words in the output prematurely, but that's harmless + #replace ESC with xxxxESCxxx because XMLin cannot handle it + $response =~ s/\e/xxxxESCxxxx/g; - - unless (@nodes) { #register the plugin in the event of usage - $handler_hash{$ownmod} = 1; - $useglobals = 1; - } - my $hdlrcache; - if ($hdlrtable) { - $hdlrcache = $hdlrtable->getNodesAttribs(\@nodes,\@columns); - } - foreach $node (@nodes) { - unless ($hdlrcache) { next; } - my $attribs = $hdlrcache->{$node}->[0]; #$hdlrtable->getNodeAttribs($node,\@columns); - unless (defined($attribs)) { next; } - foreach (@columns) { - my $col=$_; - if (defined($attribs->{$col})) { - if ($colvals->{$col}) { #A pattern match style request. - if ($attribs->{$col} =~ /$colvals->{$col}/) { - $handler_hash{$ownmod}->{$node} = 1; - delete $unhandled_nodes{$node}; - last; - } - } else { - # call the plugin that matches the table value for that node - if ($attribs->{$col} =~ /$ownmod/) { - $handler_hash{$attribs->{$col}}->{$node} = 1; - delete $unhandled_nodes{$node}; - last; - } + if ($ENV{XCATXMLTRACE}) { print $response; } + $massresponse .= $response; + $response = ''; + if ($ENV{XCATXMLWARNING}) { + validateXML($response); } - } } - } - $hdlrtable->close; - } # end if (@nodes) - - } else { - push @globalhandlers,$hdlspec; - } + } + if (not $cleanexit and $massresponse ne "") { + $massresponse .= ""; + $cleanexit = rspclean($massresponse, $callback); + } + } else { #storable encode + my $rsp; + eval { $rsp = fd_retrieve($client); }; + SERVERINPUT: while ($rsp) { + my @rsps; + if (ref $rsp eq 'ARRAY') { + @rsps = @$rsp; + } else { + @rsps = ($rsp); + } + foreach (@rsps) { + $callback->($_); + if ($_->{serverdone}) { + $cleanexit = 1; + last SERVERINPUT; + } + } + $rsp = undef; + eval { $rsp = fd_retrieve($client); }; + } } - if ($useglobals == 1) { #Behavior when globals have not been overriden - my $hdlspec; - foreach $hdlspec (@globalhandlers) { + $massresponse = ""; + unless ($cleanexit) { + print STDERR "ERROR/WARNING: communication with the xCAT server seems to have been ended prematurely\n"; + $xCAT::Client::EXITCODE = 1; + } + + sub validateXML { + my $xml = shift; + my @lines = split /\n/, $xml; + my $invalidNewline = 0; + my $contentsColon = 0; + my $contentsLine; + + foreach (@lines) { + if (!$invalidNewline) { + if (($_ =~ // && $_ !~ /<\/contents>/) || + ($_ =~ // && $_ !~ /<\/desc>/)) { + $invalidNewline = 1; + print "Possible invalid XML using newlines found: \n$xml\n"; + } + } + if ($_ =~ /.+:.+<\/contents>/) { + $contentsColon = 1; + $contentsLine = $_; + } + if ($_ =~ /.+<\/desc>/) { + $contentsColon = 0; + } + if ($contentsColon && $_ =~ /<\/desc>/) { + print "Possible invalid XML found(data contents using colon and blank description): \n$contentsLine\n$_\n"; + $contentsColon = 0; + } + } + } + +################################### + # scan_plugins + # will load all plugin perl modules and build a list of supported + # commands + # + # NOTE: This is copied from xcatd (last merge 11/23/09). + # TODO: Will eventually move to using common source.... +################################### + sub scan_plugins { + my @plugins = glob($plugins_dir . "/*.pm"); + foreach (@plugins) { + /.*\/([^\/]*).pm$/; + my $modname = $1; + unless (eval { require "$_" }) { + + # xCAT::MsgUtils->message("S","Error loading module ".$_." ...skipping"); + print "Error loading module $_ ...skipping\n"; + next; + } + no strict 'refs'; + my $cmd_adds = ${ "xCAT_plugin::" . $modname . "::" }{handled_commands}->(); + foreach (keys %$cmd_adds) { + my $value = $_; + if (defined($cmd_handlers{$_})) { + push @{ $cmd_handlers{$_} }, [ $modname, $cmd_adds->{$_} ]; + } else { + $cmd_handlers{$_} = [ [ $modname, $cmd_adds->{$_} ] ]; + } + } + } + foreach (@plugins) { + no strict 'refs'; + /.*\/([^\/]*).pm$/; + my $modname = $1; + unless (defined(${ "xCAT_plugin::" . $modname . "::" }{init_plugin})) { + next; + } + ${ "xCAT_plugin::" . $modname . "::" }{init_plugin}->(\&do_request); + } + } + + + + +################################### + # plugin_command + # will invoke the correct plugin + # + # NOTE: This is copied from xcatd (last merge 11/23/09). + # TODO: Will eventually move to using common source.... +################################### + sub plugin_command { + my $req = shift; + my $sock = shift; + my $callback = shift; + my %handler_hash; + my $usesiteglobal = 0; + + # We require these only in bypass mode to reduce start up time for the normal case + #use lib "$::XCATROOT/lib/perl"; + #use xCAT::NodeRange; + require lib; + lib->import("$::XCATROOT/lib/perl"); + require xCAT::NodeRange; + require xCAT::Table; + + $Main::resps = {}; + my $xmlreq; + if (ref($req) ne 'HASH') { # the request XML, get an array + $xmlreq = $req; # save the original XML + $req = XMLin($xmlreq, SuppressEmpty => undef, ForceArray => 1); + + } + my @nodes; + if ($req->{node}) { + @nodes = @{ $req->{node} }; + } elsif ($req->{noderange} and $req->{noderange}->[0]) { + @nodes = xCAT::NodeRange::noderange($req->{noderange}->[0]); + if (xCAT::NodeRange::nodesmissed()) { + + # my $rsp = {errorcode=>1,error=>"Invalid nodes in noderange:".join(',',xCAT::NodeRange::nodesmissed)}; + # my $rsp->{serverdone} = {}; + print "Invalid nodes in noderange:" . join(',', xCAT::NodeRange::nodesmissed()) . "\n"; + + # if ($sock) { + # print $sock XMLout($rsp,RootName=>'xcatresponse' ,NoAttr=>1); + # } + # return ($rsp); + return 1; + } unless (@nodes) { - $handler_hash{$hdlspec} = 1; + $req->{emptynoderange} = [1]; } - foreach (@nodes) { #Specified a specific plugin, not a table lookup - $handler_hash{$hdlspec}->{$_} = 1; + } + if (@nodes) { $req->{node} = \@nodes; } + my %unhandled_nodes; + foreach (@nodes) { + $unhandled_nodes{$_} = 1; + } + my $useunhandled = 0; + if (defined($cmd_handlers{ $req->{command}->[0] })) { + my $hdlspec; + my @globalhandlers = (); + my $useglobals = 1; #If it stays 1, then use globals normally, if 0, use only for 'unhandled_nodes, if -1, don't do at all + foreach (@{ $cmd_handlers{ $req->{command}->[0] } }) { + $hdlspec = $_->[1]; + my $ownmod = $_->[0]; + if ($hdlspec =~ /^site:/) { #A site entry specifies a plugin + my $sitekey = $hdlspec; + $sitekey =~ s/^site://; + + #$sitetab = xCAT::Table->new('site'); + #my $sent = $sitetab->getAttribs({key=>$sitekey},['value']); + #if ($sent and $sent->{value}) { #A site style plugin specification is just like + if ($::XCATSITEVALS{$sitekey}) { #A site style plugin specification is just like + #a static global, it grabs all nodes rather than some + $useglobals = -1; #If they tried to specify anything, don't use the default global handlers at all + unless (@nodes) { + $handler_hash{ $::XCATSITEVALS{$sitekey} } = 1; + $usesiteglobal = 1; + } + foreach (@nodes) { #Specified a specific plugin, not a table lookup + $handler_hash{ $::XCATSITEVALS{$sitekey} }->{$_} = 1; + } + } + } elsif ($hdlspec =~ /:/) { #Specificed a table lookup path for plugin name + if (@nodes) { # only use table lookup plugin if nodelist exists + # Usage will be handled in common AAAhelp plugin + + $useglobals = 0; #Only contemplate nodes that aren't caught through searching below in the global handler + $useunhandled = 1; + my $table; + my $cols; + ($table, $cols) = split(/:/, $hdlspec); + my @colmns = split(/,/, $cols); + my @columns; + my $hdlrtable = xCAT::Table->new($table); + unless ($hdlrtable) { + + #TODO: proper error handling + } + my $node; + my $colvals = {}; + foreach my $colu (@colmns) { + if ($colu =~ /=/) { #a value redirect to a pattern/specific name + my $coln; my $colv; + ($coln, $colv) = split(/=/, $colu, 2); + $colvals->{$coln} = $colv; + push(@columns, $coln); + } else { + push(@columns, $colu); + } + } + + + unless (@nodes) { #register the plugin in the event of usage + $handler_hash{$ownmod} = 1; + $useglobals = 1; + } + my $hdlrcache; + if ($hdlrtable) { + $hdlrcache = $hdlrtable->getNodesAttribs(\@nodes, \@columns); + } + foreach $node (@nodes) { + unless ($hdlrcache) { next; } + my $attribs = $hdlrcache->{$node}->[0]; #$hdlrtable->getNodeAttribs($node,\@columns); + unless (defined($attribs)) { next; } + foreach (@columns) { + my $col = $_; + if (defined($attribs->{$col})) { + if ($colvals->{$col}) { #A pattern match style request. + if ($attribs->{$col} =~ /$colvals->{$col}/) { + $handler_hash{$ownmod}->{$node} = 1; + delete $unhandled_nodes{$node}; + last; + } + } else { + + # call the plugin that matches the table value for that node + if ($attribs->{$col} =~ /$ownmod/) { + $handler_hash{ $attribs->{$col} }->{$node} = 1; + delete $unhandled_nodes{$node}; + last; + } + } + } + } + } + $hdlrtable->close; + } # end if (@nodes) + + } else { + push @globalhandlers, $hdlspec; + } } - } - } elsif ($useglobals == 0) { - unless (@nodes or $usesiteglobal) { #if something like 'makedhcp -n', - foreach (keys %handler_hash) { - if ($handler_hash{$_} == 1) { - delete ($handler_hash{$_}) - } - } - } - foreach $hdlspec (@globalhandlers) { - unless (@nodes or $usesiteglobal) { - $handler_hash{$hdlspec} = 1; + if ($useglobals == 1) { #Behavior when globals have not been overriden + my $hdlspec; + foreach $hdlspec (@globalhandlers) { + unless (@nodes) { + $handler_hash{$hdlspec} = 1; + } + foreach (@nodes) { #Specified a specific plugin, not a table lookup + $handler_hash{$hdlspec}->{$_} = 1; + } + } + } elsif ($useglobals == 0) { + unless (@nodes or $usesiteglobal) { #if something like 'makedhcp -n', + foreach (keys %handler_hash) { + if ($handler_hash{$_} == 1) { + delete($handler_hash{$_}) + } + } + } + foreach $hdlspec (@globalhandlers) { + unless (@nodes or $usesiteglobal) { + $handler_hash{$hdlspec} = 1; + } + foreach (keys %unhandled_nodes) { #Specified a specific plugin, not a table lookup + $handler_hash{$hdlspec}->{$_} = 1; + } + } + } #Otherwise, global handler is implicitly disabled + } else { + print "Error request: $req->{command}->[0] has no known plugin for it.\n"; + return 1; + } + if ($useunhandled) { + my $queuelist; + foreach (@{ $cmd_handlers{ $req->{command}->[0] } }) { + my $queueitem = $_->[1]; + if (($queueitem =~ /:/) and !($queuelist =~ /($queueitem)/)) { + $queuelist .= "$_->[1];"; + } } - foreach (keys %unhandled_nodes) { #Specified a specific plugin, not a table lookup - $handler_hash{$hdlspec}->{$_} = 1; + $queuelist =~ s/;$//; + $queuelist =~ s/:/./g; + foreach (keys %unhandled_nodes) { + + # if ($sock) { + # print $sock XMLout({node=>[{name=>[$_],data=>["Unable to identify plugin for this command, check relevant tables: $queuelist"],errorcode=>[1]}]},NoAttr=>1,RootName=>'xcatresponse'); + # } else { + my $tabdesc = $queuelist; + $tabdesc =~ s/=.*$//; + $callback->({ node => [ { name => [$_], error => [ 'Unable to identify plugin for this command, check relevant tables: ' . $tabdesc ], errorcode => [1] } ] }); + + # } } - } - } #Otherwise, global handler is implicitly disabled - } else { - print "Error request: $req->{command}->[0] has no known plugin for it.\n"; - return 1; - } - if ($useunhandled) { - my $queuelist; - foreach (@{$cmd_handlers{$req->{command}->[0]}}) { - my $queueitem = $_->[1]; - if (($queueitem =~ /:/) and !($queuelist =~ /($queueitem)/)) { - $queuelist .= "$_->[1];"; - } - } - $queuelist =~ s/;$//; - $queuelist =~ s/:/./g; - foreach (keys %unhandled_nodes) { -# if ($sock) { -# print $sock XMLout({node=>[{name=>[$_],data=>["Unable to identify plugin for this command, check relevant tables: $queuelist"],errorcode=>[1]}]},NoAttr=>1,RootName=>'xcatresponse'); -# } else { - my $tabdesc = $queuelist; - $tabdesc =~ s/=.*$//; - $callback->({node=>[{name=>[$_],error=>['Unable to identify plugin for this command, check relevant tables: '.$tabdesc],errorcode=>[1]}]}); -# } - } - } + } ## FOR NOW, DON'T FORK CHILD PROCESS TO MAKE BYPASS SIMPLER AND EASIER TO DEBUG -# $plugin_numchildren=0; -# %plugin_children=(); -# $SIG{CHLD} = \&plugin_reaper; #sub {my $plugpid; while (($plugpid = waitpid(-1, WNOHANG)) > 0) { if ($plugin_children{$plugpid}) { delete $plugin_children{$plugpid}; $plugin_numchildren--; } } }; -# my $check_fds; -# if ($sock) { -# $check_fds = new IO::Select; -# } - foreach (keys %handler_hash) { - my $modname = $_; -# my $shouldbealivepid=$$; - if (-r $plugins_dir."/".$modname.".pm") { - require $plugins_dir."/".$modname.".pm"; -# $plugin_numchildren++; -# my $pfd; #will be referenced for inter-process messaging. -# my $parfd; #not causing a problem that I discern yet, but theoretically -# my $child; -# if ($sock) { #If $sock not passed in, don't fork.. -# socketpair($pfd, $parfd,AF_UNIX,SOCK_STREAM,PF_UNSPEC) or die "socketpair: $!"; -# #pipe($pfd,$cfd); -# $parfd->autoflush(1); -# $pfd->autoflush(1); -# $child = xCAT::Utils->xfork; -# } else { -# $child = 0; -# } -# unless (defined $child) { die "Fork failed"; } -# if ($child == 0) { -# if ($parfd) { #If xCAT is doing multiple requests in same communication PID, things would get unfortunate otherwise -# $parent_fd = $parfd; -# } - my $oldprogname=$$progname; - $$progname=$oldprogname.": $modname instance"; -# if ($sock) { close $pfd; } - unless ($handler_hash{$_} == 1) { - my @nodes = sort {($a =~ /(\d+)/)[0] <=> ($b =~ /(\d+)/)[0] || $a cmp $b } (keys %{$handler_hash{$_}}); - $req->{node}=\@nodes; + # $plugin_numchildren=0; + # %plugin_children=(); + # $SIG{CHLD} = \&plugin_reaper; #sub {my $plugpid; while (($plugpid = waitpid(-1, WNOHANG)) > 0) { if ($plugin_children{$plugpid}) { delete $plugin_children{$plugpid}; $plugin_numchildren--; } } }; + # my $check_fds; + # if ($sock) { + # $check_fds = new IO::Select; + # } + foreach (keys %handler_hash) { + my $modname = $_; + + # my $shouldbealivepid=$$; + if (-r $plugins_dir . "/" . $modname . ".pm") { + require $plugins_dir . "/" . $modname . ".pm"; + + # $plugin_numchildren++; + # my $pfd; #will be referenced for inter-process messaging. + # my $parfd; #not causing a problem that I discern yet, but theoretically + # my $child; + # if ($sock) { #If $sock not passed in, don't fork.. + # socketpair($pfd, $parfd,AF_UNIX,SOCK_STREAM,PF_UNSPEC) or die "socketpair: $!"; + # #pipe($pfd,$cfd); + # $parfd->autoflush(1); + # $pfd->autoflush(1); + # $child = xCAT::Utils->xfork; + # } else { + # $child = 0; + # } + # unless (defined $child) { die "Fork failed"; } + # if ($child == 0) { + # if ($parfd) { #If xCAT is doing multiple requests in same communication PID, things would get unfortunate otherwise + # $parent_fd = $parfd; + # } + my $oldprogname = $$progname; + $$progname = $oldprogname . ": $modname instance"; + + # if ($sock) { close $pfd; } + unless ($handler_hash{$_} == 1) { + my @nodes = sort { ($a =~ /(\d+)/)[0] <=> ($b =~ /(\d+)/)[0] || $a cmp $b } (keys %{ $handler_hash{$_} }); + $req->{node} = \@nodes; + } + no strict "refs"; + + # eval { #REMOVEEVALFORDEBUG + # if ($dispatch_requests) { + # backup the original req and recover it after the a run + my $org_req = {%$req}; + dispatch_request($req, $callback, $modname); + $req = {%$org_req}; + + # } else { + # $SIG{CHLD}='DEFAULT'; + # ${"xCAT_plugin::".$modname."::"}{process_request}->($req,$callback,\&do_request); + # } + $$progname = $oldprogname; + + # if ($sock) { + # close($parent_fd); + # xexit(0); + # } + # }; #REMOVEEVALFORDEBUG + # if ($sock or $shouldbealivepid != $$) { #We shouldn't still be alive, try to send as much detail to parent as possible as to why + # my $error= "$modname plugin bug, pid $$, process description: '$$progname'"; + # if ($@) { + # $error .= " with error '$@'"; + # } else { #Sys::Virt and perhaps Net::SNMP sometimes crashes in a way $@ won't catch.. + # $error .= " with missing eval error, probably due to special manipulation of $@ or strange circumstances in an XS library, remove evals in xcatd marked 'REMOVEEVALFORDEBUG and run xcatd -f for more info"; + # } + # if (scalar (@nodes)) { #Don't know which of the nodes, so one error message warning about the possibliity.. + # $error .= " while trying to fulfill request for the following nodes: ".join(",",@nodes); + # } + # xCAT::MsgUtils->message("S","xcatd: $error"); + # $callback->({error=>[$error],errorcode=>[1]}); + # xexit(0); #Die like we should have done + # } elsif ($@) { #We are still alive, should be alive, but yet we have an error. This means we are in the case of 'do_request' or something similar. Forward up the death since our communication channel is intact.. + # die $@; + # } + # } else { + # $plugin_children{$child}=1; + # close $parfd; + # $check_fds->add($pfd); + # } + } else { + my $pm_name = $plugins_dir . "/" . $modname . ".pm"; + foreach my $node (keys %{ $handler_hash{$_} }) { + if ($sock) { + print $sock XMLout({ node => [ { name => [$node], data => ["Cannot find the perl module to complete the operation: $pm_name"], errorcode => [1] } ] }, NoAttr => 1, RootName => 'xcatresponse'); + } else { + $callback->({ node => [ { name => [$node], data => ["Cannot find the perl module to complete the operation: $pm_name"], errorcode => [1] } ] }); + } + } + } } - no strict "refs"; -# eval { #REMOVEEVALFORDEBUG -# if ($dispatch_requests) { - # backup the original req and recover it after the a run - my $org_req = {%$req}; - dispatch_request($req,$callback,$modname); - $req = {%$org_req}; -# } else { -# $SIG{CHLD}='DEFAULT'; -# ${"xCAT_plugin::".$modname."::"}{process_request}->($req,$callback,\&do_request); -# } - $$progname=$oldprogname; -# if ($sock) { -# close($parent_fd); -# xexit(0); -# } -# }; #REMOVEEVALFORDEBUG -# if ($sock or $shouldbealivepid != $$) { #We shouldn't still be alive, try to send as much detail to parent as possible as to why -# my $error= "$modname plugin bug, pid $$, process description: '$$progname'"; -# if ($@) { -# $error .= " with error '$@'"; -# } else { #Sys::Virt and perhaps Net::SNMP sometimes crashes in a way $@ won't catch.. -# $error .= " with missing eval error, probably due to special manipulation of $@ or strange circumstances in an XS library, remove evals in xcatd marked 'REMOVEEVALFORDEBUG and run xcatd -f for more info"; -# } -# if (scalar (@nodes)) { #Don't know which of the nodes, so one error message warning about the possibliity.. -# $error .= " while trying to fulfill request for the following nodes: ".join(",",@nodes); -# } -# xCAT::MsgUtils->message("S","xcatd: $error"); -# $callback->({error=>[$error],errorcode=>[1]}); -# xexit(0); #Die like we should have done -# } elsif ($@) { #We are still alive, should be alive, but yet we have an error. This means we are in the case of 'do_request' or something similar. Forward up the death since our communication channel is intact.. -# die $@; -# } -# } else { -# $plugin_children{$child}=1; -# close $parfd; -# $check_fds->add($pfd); -# } - } else { - my $pm_name = $plugins_dir."/".$modname.".pm"; - foreach my $node (keys %{$handler_hash{$_}}) { - if ($sock) { - print $sock XMLout({node=>[{name=>[$node],data=>["Cannot find the perl module to complete the operation: $pm_name"],errorcode=>[1]}]},NoAttr=>1,RootName=>'xcatresponse'); + unless ($sock) { return $Main::resps } + + # while (($plugin_numchildren > 0) and ($check_fds->count > 0)) { #this tracks end of useful data from children much more closely + # relay_fds($check_fds,$sock); + # } + # #while (relay_fds($check_fds,$sock)) {} + # my %done; + # $done{serverdone} = {}; + # if ($req->{transid}) { + # $done{transid}=$req->{transid}->[0]; + # } + # if ($sock) { + # my $clientpresence = new IO::Select; #The client may have gone away without confirmation, don't PIPE over this trivial thing + # $clientpresence->add($sock); + # if ($clientpresence->can_write(5)) { + # print $sock XMLout(\%done,RootName => 'xcatresponse',NoAttr=>1); + # } + # } + } + + + + +################################### + # dispatch_request + # dispatch the requested command + # + # NOTE: This is copied from xcatd (last merge 11/23/09). + # All we really need from this subroutine is to call preprocess_request + # and to only run the command for nodes handled by the local server + # Will eventually move to using common source.... +################################### + sub dispatch_request { + + # %dispatched_children=(); + require xCAT::Utils; + my $req = shift; + $dispatch_cb = shift; + + my $modname = shift; + my $reqs = []; + + # my $child_fdset = new IO::Select; + no strict "refs"; + + #Hierarchy support. Originally, the default scope for noderange commands was + #going to be the servicenode associated unless overriden. + #However, assume for example that you have blades and a blade is the service node + #rpower being executed by the servicenode for one of its subnodes would have to + #reach it's own management module. This has the potential to be non-trivial for some quite possible network configurations. + #Since plugins may commonly experience this, a preprocess_request implementation + #will for now be required for a command to be scaled through service nodes + #If the plugin offers a preprocess method, use it to set the request array + if (defined(${ "xCAT_plugin::" . $modname . "::" }{preprocess_request})) { + $SIG{CHLD} = 'DEFAULT'; + $reqs = ${ "xCAT_plugin::" . $modname . "::" }{preprocess_request}->($req, $dispatch_cb, \&do_request); + } else { #otherwise, pass it in without hierarchy support + $reqs = [$req]; + } + + # $dispatch_children=0; + # $SIG{CHLD} = \&dispatch_reaper; #sub {my $cpid; while (($cpid =waitpid(-1, WNOHANG)) > 0) { if ($dispatched_children{$cpid}) { delete $dispatched_children{$cpid}; $dispatch_children--; } } }; + my $onlyone = 0; + if (defined $reqs and (scalar(@{$reqs}) == 1)) { + $onlyone = 1; + } + + foreach (@{$reqs}) { + + # my $pfd; + # my $parfd; #use a private variable so it won't trounce itself recursively + # my $child; + delete $_->{noderange}; + + #----- added to Client.pm -----# + if ($_->{node}) { + $_->{noderange}->[0] = join(',', @{ $_->{node} }); + } + + #----- end added to Client.pm -----# + + if (ref $_->{'_xcatdest'} and (ref $_->{'_xcatdest'}) eq 'ARRAY') { + _->{'_xcatdest'} = $_->{'_xcatdest'}->[0]; + } + if ($onlyone and not($_->{'_xcatdest'} and xCAT::NetworkUtils->thishostisnot($_->{'_xcatdest'}))) { + $SIG{CHLD} = 'DEFAULT'; + ${ "xCAT_plugin::" . $modname . "::" }{process_request}->($_, $dispatch_cb, \&do_request); + return; + } + + # socketpair($pfd, $parfd,AF_UNIX,SOCK_STREAM,PF_UNSPEC) or die "socketpair: $!"; + # $parfd->autoflush(1); + # $pfd->autoflush(1); + # $child = xCAT::Utils->xfork; + # if ($child) { + # $dispatch_children++; + # $dispatched_children{$child}=1; + # $child_fdset->add($pfd); + # next; + # } + # unless (defined $child) { + # $dispatch_cb->({error=>['Fork failure dispatching request'],errorcode=>[1]}); + # } + # undef $SIG{CHLD}; + # $dispatch_parentfd = $parfd; + my @prexcatdests = (); + my @xcatdests = (); + if (ref($_->{'_xcatdest'}) eq 'ARRAY') { #If array, consider it an 'anycast' operation, broadcast done through dupe + #requests, or an alternative join '&' maybe? + @prexcatdests = @{ $_->{'_xcatdest'} }; + } else { + @prexcatdests = ($_->{'_xcatdest'}); + } + foreach (@prexcatdests) { + if ($_ and /,/) { + push @xcatdests, split /,/, $_; + } else { + push @xcatdests, $_; + } + } + my $xcatdest; + my $numdests = scalar(@xcatdests); + my $request_satisfied = 0; + foreach $xcatdest (@xcatdests) { + my $dlock; + if ($xcatdest and xCAT::NetworkUtils->thishostisnot($xcatdest)) { + + #----- added to Client.pm -----# + $dispatch_cb->({ warning => [ 'XCATBYPASS is set, skipping hierarchy call to ' . $_->{'_xcatdest'} . '' ] }); + + #----- end added to Client.pm -----# + + # #mkpath("/var/lock/xcat/"); #For now, limit intra-xCAT requests to one at a time, to mitigate DB handle usage + # #open($dlock,">","/var/lock/xcat/dispatchto_$xcatdest"); + # #flock($dlock,LOCK_EX); + # $ENV{XCATHOST} = ($xcatdest =~ /:/ ? $xcatdest : $xcatdest.":3001" ); + # $$progname.=": connection to ".$ENV{XCATHOST}; + # my $errstr; + # eval { + # undef $_->{'_xcatdest'}; + # xCAT::Client::submit_request($_,\&dispatch_callback,$xcatdir."/cert/server-cred.pem",$xcatdir."/cert/server-cred.pem",$xcatdir."/cert/ca.pem"); + # }; + # if ($@) { + # $errstr=$@; + # } + # #unlink("/var/lock/xcat/dispatchto_$xcatdest"); + # #flock($dlock,LOCK_UN); + # if ($errstr) { + # if ($numdests == 1) { + # dispatch_callback({error=>["Unable to dispatch command to ".$ENV{XCATHOST}.", command will not make changes to that server ($errstr)"],errorcode=>[1]}); + # xCAT::MsgUtils->message("S","Error dispatching request to ".$ENV{XCATHOST}.": ".$errstr); + # } else { + # xCAT::MsgUtils->message("S","Error dispatching request to ".$ENV{XCATHOST}.", trying other service nodes: ".$errstr); + # } + # next; + # } else { + # $request_satisfied=1; + # last; + # } + } else { + $$progname .= ": locally executing"; + $SIG{CHLD} = 'DEFAULT'; + + # ${"xCAT_plugin::".$modname."::"}{process_request}->($_,\&dispatch_callback,\&do_request); + #----- changed in Client.pm -----# + ${ "xCAT_plugin::" . $modname . "::" }{process_request}->($_, $dispatch_cb, \&do_request); + + #----- end changed in Client.pm -----# + last; + } + } + + # if ($numdests > 1 and not $request_satisfied) { + # xCAT::MsgUtils->message("S","Error dispatching a request to all possible service nodes for request"); + # dispatch_callback({error=>["Failed to dispatch command to any of the following service nodes: ".join(",",@xcatdests)],errorcode=>[1]}); + # } + + # xexit; + } + + #while (($dispatch_children > 0) and ($child_fdset->count > 0)) { relay_dispatch($child_fdset) } + #while (relay_dispatch($child_fdset)) { } #Potentially useless drain. + } + + + +################################### + # do_request + # called from a plugin to execute another xCAT plugin command internally + # + # NOTE: This is copied from xcatd (last merge 11/23/09). + # Will eventually move to using common source.... +################################### + sub do_request { + my $req = shift; + my $second = shift; + my $rsphandler = \&build_response; + my $sock = undef; + if ($second) { + if (ref($second) eq "CODE") { + $rsphandler = $second; + } elsif (ref($second) eq "GLOB") { + $sock = $second; + } + } + + #my $sock = shift; #If no sock, will return a response hash + if ($cmd_handlers{ $req->{command}->[0] }) { + return plugin_command($req, $sock, $rsphandler); + } elsif ($req->{command}->[0] eq "noderange" and $req->{noderange}) { + my @nodes = xCAT::NodeRange::noderange($req->{noderange}->[0]); + my %resp; + if (xCAT::NodeRange::nodesmissed()) { + $resp{warning} = "Invalid nodes in noderange:" . join ',', xCAT::NodeRange::nodesmissed() . "\n"; + } + $resp{serverdone} = {}; + @{ $resp{node} } = @nodes; + if ($req->{transid}) { + $resp{transid} = $req->{transid}->[0]; + } + if ($sock) { + print $sock XMLout(\%resp, RootName => 'xcatresponse', NoAttr => 1); + } else { + return (\%resp); + } } else { - $callback->({node=>[{name=>[$node],data=>["Cannot find the perl module to complete the operation: $pm_name"],errorcode=>[1]}]}); + my %resp = (error => "Unsupported request"); + $resp{serverdone} = {}; + if ($req->{transid}) { + $resp{transid} = $req->{transid}->[0]; + } + if ($sock) { + print $sock XMLout(\%resp, RootName => 'xcatresponse', NoAttr => 1); + } else { + return (\%resp); + } } - } } - } - unless ($sock) { return $Main::resps }; -# while (($plugin_numchildren > 0) and ($check_fds->count > 0)) { #this tracks end of useful data from children much more closely -# relay_fds($check_fds,$sock); -# } -# #while (relay_fds($check_fds,$sock)) {} -# my %done; -# $done{serverdone} = {}; -# if ($req->{transid}) { -# $done{transid}=$req->{transid}->[0]; -# } -# if ($sock) { -# my $clientpresence = new IO::Select; #The client may have gone away without confirmation, don't PIPE over this trivial thing -# $clientpresence->add($sock); -# if ($clientpresence->can_write(5)) { -# print $sock XMLout(\%done,RootName => 'xcatresponse',NoAttr=>1); -# } -# } -} - - ################################### -# dispatch_request -# dispatch the requested command -# -# NOTE: This is copied from xcatd (last merge 11/23/09). -# All we really need from this subroutine is to call preprocess_request -# and to only run the command for nodes handled by the local server -# Will eventually move to using common source.... + # build_response + # This callback handles responses from nested level plugin calls. + # It builds a merged hash of all responses that gets passed back + # to the calling plugin. + # Note: Need to create a "deep clone" of this response to add to the + # return, otherwise next time through the referenced data is overwritten + # ################################### -sub dispatch_request { -# %dispatched_children=(); - require xCAT::Utils; - my $req = shift; - $dispatch_cb = shift; - - my $modname = shift; - my $reqs = []; -# my $child_fdset = new IO::Select; - no strict "refs"; - - #Hierarchy support. Originally, the default scope for noderange commands was - #going to be the servicenode associated unless overriden. - #However, assume for example that you have blades and a blade is the service node - #rpower being executed by the servicenode for one of its subnodes would have to - #reach it's own management module. This has the potential to be non-trivial for some quite possible network configurations. - #Since plugins may commonly experience this, a preprocess_request implementation - #will for now be required for a command to be scaled through service nodes - #If the plugin offers a preprocess method, use it to set the request array - if (defined(${"xCAT_plugin::".$modname."::"}{preprocess_request})) { - $SIG{CHLD}='DEFAULT'; - $reqs = ${"xCAT_plugin::".$modname."::"}{preprocess_request}->($req,$dispatch_cb,\&do_request); - } else { #otherwise, pass it in without hierarchy support - $reqs = [$req]; - } - -# $dispatch_children=0; -# $SIG{CHLD} = \&dispatch_reaper; #sub {my $cpid; while (($cpid =waitpid(-1, WNOHANG)) > 0) { if ($dispatched_children{$cpid}) { delete $dispatched_children{$cpid}; $dispatch_children--; } } }; - my $onlyone=0; - if (defined $reqs and (scalar(@{$reqs}) == 1)) { - $onlyone=1; - } - - foreach (@{$reqs}) { -# my $pfd; -# my $parfd; #use a private variable so it won't trounce itself recursively -# my $child; - delete $_->{noderange}; -#----- added to Client.pm -----# - if ($_->{node}) { - $_->{noderange}->[0]=join(',',@{$_->{node}}); - } -#----- end added to Client.pm -----# - - if (ref $_->{'_xcatdest'} and (ref $_->{'_xcatdest'}) eq 'ARRAY') { - _->{'_xcatdest'} = $_->{'_xcatdest'}->[0]; - } - if ($onlyone and not ($_->{'_xcatdest'} and xCAT::NetworkUtils->thishostisnot($_->{'_xcatdest'}))) { - $SIG{CHLD}='DEFAULT'; - ${"xCAT_plugin::".$modname."::"}{process_request}->($_,$dispatch_cb,\&do_request); - return; - } - -# socketpair($pfd, $parfd,AF_UNIX,SOCK_STREAM,PF_UNSPEC) or die "socketpair: $!"; -# $parfd->autoflush(1); -# $pfd->autoflush(1); -# $child = xCAT::Utils->xfork; -# if ($child) { -# $dispatch_children++; -# $dispatched_children{$child}=1; -# $child_fdset->add($pfd); -# next; -# } -# unless (defined $child) { -# $dispatch_cb->({error=>['Fork failure dispatching request'],errorcode=>[1]}); -# } -# undef $SIG{CHLD}; -# $dispatch_parentfd = $parfd; - my @prexcatdests=(); - my @xcatdests=(); - if (ref($_->{'_xcatdest'}) eq 'ARRAY') { #If array, consider it an 'anycast' operation, broadcast done through dupe - #requests, or an alternative join '&' maybe? - @prexcatdests=@{$_->{'_xcatdest'}}; - } else { - @prexcatdests=($_->{'_xcatdest'}); - } - foreach (@prexcatdests) { - if ($_ and /,/) { - push @xcatdests,split /,/,$_; - } else { - push @xcatdests,$_; - } - } - my $xcatdest; - my $numdests=scalar(@xcatdests); - my $request_satisfied=0; - foreach $xcatdest (@xcatdests) { - my $dlock; - if ($xcatdest and xCAT::NetworkUtils->thishostisnot($xcatdest)) { -#----- added to Client.pm -----# - $dispatch_cb->({warning=>['XCATBYPASS is set, skipping hierarchy call to '.$_->{'_xcatdest'}.'']}); -#----- end added to Client.pm -----# - -# #mkpath("/var/lock/xcat/"); #For now, limit intra-xCAT requests to one at a time, to mitigate DB handle usage -# #open($dlock,">","/var/lock/xcat/dispatchto_$xcatdest"); -# #flock($dlock,LOCK_EX); -# $ENV{XCATHOST} = ($xcatdest =~ /:/ ? $xcatdest : $xcatdest.":3001" ); -# $$progname.=": connection to ".$ENV{XCATHOST}; -# my $errstr; -# eval { -# undef $_->{'_xcatdest'}; -# xCAT::Client::submit_request($_,\&dispatch_callback,$xcatdir."/cert/server-cred.pem",$xcatdir."/cert/server-cred.pem",$xcatdir."/cert/ca.pem"); -# }; -# if ($@) { -# $errstr=$@; -# } -# #unlink("/var/lock/xcat/dispatchto_$xcatdest"); -# #flock($dlock,LOCK_UN); -# if ($errstr) { -# if ($numdests == 1) { -# dispatch_callback({error=>["Unable to dispatch command to ".$ENV{XCATHOST}.", command will not make changes to that server ($errstr)"],errorcode=>[1]}); -# xCAT::MsgUtils->message("S","Error dispatching request to ".$ENV{XCATHOST}.": ".$errstr); -# } else { -# xCAT::MsgUtils->message("S","Error dispatching request to ".$ENV{XCATHOST}.", trying other service nodes: ".$errstr); -# } -# next; -# } else { -# $request_satisfied=1; -# last; -# } - } else { - $$progname.=": locally executing"; - $SIG{CHLD}='DEFAULT'; -# ${"xCAT_plugin::".$modname."::"}{process_request}->($_,\&dispatch_callback,\&do_request); -#----- changed in Client.pm -----# - ${"xCAT_plugin::".$modname."::"}{process_request}->($_,$dispatch_cb,\&do_request); -#----- end changed in Client.pm -----# - last; + sub build_response { + my $rsp = shift; + require Storable; + foreach (keys %$rsp) { + my $subresp = Storable::dclone($rsp->{$_}); + push(@{ $Main::resps->{$_} }, @{$subresp}); } - } -# if ($numdests > 1 and not $request_satisfied) { -# xCAT::MsgUtils->message("S","Error dispatching a request to all possible service nodes for request"); -# dispatch_callback({error=>["Failed to dispatch command to any of the following service nodes: ".join(",",@xcatdests)],errorcode=>[1]}); -# } - -# xexit; - } -#while (($dispatch_children > 0) and ($child_fdset->count > 0)) { relay_dispatch($child_fdset) } -#while (relay_dispatch($child_fdset)) { } #Potentially useless drain. -} - - - -################################### -# do_request -# called from a plugin to execute another xCAT plugin command internally -# -# NOTE: This is copied from xcatd (last merge 11/23/09). -# Will eventually move to using common source.... -################################### -sub do_request { - my $req = shift; - my $second = shift; - my $rsphandler = \&build_response; - my $sock = undef; - if ($second) { - if (ref($second) eq "CODE") { - $rsphandler = $second; - } elsif (ref($second) eq "GLOB") { - $sock = $second; } - } - - #my $sock = shift; #If no sock, will return a response hash - if ($cmd_handlers{$req->{command}->[0]}) { - return plugin_command($req,$sock,$rsphandler); - } elsif ($req->{command}->[0] eq "noderange" and $req->{noderange}) { - my @nodes = xCAT::NodeRange::noderange($req->{noderange}->[0]); - my %resp; - if (xCAT::NodeRange::nodesmissed()) { - $resp{warning}="Invalid nodes in noderange:".join ',',xCAT::NodeRange::nodesmissed() ."\n"; - } - $resp{serverdone} = {}; - @{$resp{node}}=@nodes; - if ($req->{transid}) { - $resp{transid}=$req->{transid}->[0]; - } - if ($sock) { - print $sock XMLout(\%resp,RootName => 'xcatresponse',NoAttr=>1); - } else { - return (\%resp); - } - } else { - my %resp=(error=>"Unsupported request"); - $resp{serverdone} = {}; - if ($req->{transid}) { - $resp{transid}=$req->{transid}->[0]; - } - if ($sock) { - print $sock XMLout(\%resp,RootName => 'xcatresponse',NoAttr=>1); - } else { - return (\%resp); - } - } -} - - -################################### -# build_response -# This callback handles responses from nested level plugin calls. -# It builds a merged hash of all responses that gets passed back -# to the calling plugin. -# Note: Need to create a "deep clone" of this response to add to the -# return, otherwise next time through the referenced data is overwritten -# -################################### -sub build_response { - my $rsp = shift; - require Storable; - foreach (keys %$rsp) { - my $subresp = Storable::dclone($rsp->{$_}); - push (@{$Main::resps->{$_}}, @{$subresp}); - } -} @@ -983,15 +1023,15 @@ sub build_response { # This is used with XCATBYPASS=1 ################################### sub populate_site_hash { - %::XCATSITEVALS=(); - my $sitetab = xCAT::Table->new('site',-create=>0); - unless ($sitetab) { - print ("ERROR: Unable to open basic site table for configuration\n"); - return; + %::XCATSITEVALS = (); + my $sitetab = xCAT::Table->new('site', -create => 0); + unless ($sitetab) { + print("ERROR: Unable to open basic site table for configuration\n"); + return; } my @records = $sitetab->getAllAttribs(qw/key value/); foreach (@records) { - $::XCATSITEVALS{$_->{key}}=$_->{value}; + $::XCATSITEVALS{ $_->{key} } = $_->{value}; } } @@ -1078,188 +1118,194 @@ sub populate_site_hash { # node_name: desc: contents ########################################## sub handle_response { - my $rsp = shift; - if ($ENV{'XCATSHOWXML'}) { - my $xmlrec=XMLout($rsp,RootName=>'xcatresponse',NoAttr=>1,KeyAttr=>[]); - print "$xmlrec\n"; - return; - } -#print "in handle_response\n"; - # Handle errors - if (defined($rsp->{errorcode})) { - if (ref($rsp->{errorcode}) eq 'ARRAY') { - foreach my $ecode (@{$rsp->{errorcode}}) { - $xCAT::Client::EXITCODE |= $ecode; - } + my $rsp = shift; + if ($ENV{'XCATSHOWXML'}) { + my $xmlrec = XMLout($rsp, RootName => 'xcatresponse', NoAttr => 1, KeyAttr => []); + print "$xmlrec\n"; + return; } - else { - $xCAT::Client::EXITCODE |= $rsp->{errorcode}; - } # assume it is a non-reference scalar - } - if ($rsp->{error}) { -#print "printing error\n"; - if (ref($rsp->{error}) eq 'ARRAY') { - foreach my $text (@{$rsp->{error}}) { - if ($rsp->{NoErrorPrefix}) { - print STDERR "$text\n"; - } else { - print STDERR "Error: $text\n"; - } - } - } - else { - if ($rsp->{NoErrorPrefix}) { - print STDERR ($rsp->{error}."\n"); - } else { - print STDERR ("Error: ".$rsp->{error}."\n"); - } - } - } - if ($rsp->{warning}) { -#print "printing warning\n"; - if (ref($rsp->{warning}) eq 'ARRAY') { - foreach my $text (@{$rsp->{warning}}) { - if ($rsp->{NoWarnPrefix}) { - print STDERR "$text\n"; - } else { - print STDERR "Warning: $text\n"; - } - } - } - else { - if ($rsp->{NoWarnPrefix}) { - print STDERR ($rsp->{warning}."\n"); - } else { - print STDERR ("Warning: ".$rsp->{warning}."\n"); - } - } - } - if ($rsp->{info}) { -#print "printing info\n"; - if (ref($rsp->{info}) eq 'ARRAY') { - foreach my $text (@{$rsp->{info}}) { - print "$text\n"; - } - } - else { - print ($rsp->{info}."\n"); - } - } - if ($rsp->{sinfo}) { - if (ref($rsp->{sinfo}) eq 'ARRAY') { - foreach my $text (@{$rsp->{sinfo}}) { - print "$text\r"; $|++; - } - } - else { - print ($rsp->{sinfo}."\r"); $|++; - } - } - - - - # Handle {node} structure - my $errflg=0; - my $nodes=($rsp->{node}); - unless (ref $nodes eq 'ARRAY') { - $nodes = [$nodes]; - } - if (scalar @{$nodes}) { -#print "printing node\n"; - my $node; - foreach $node (@$nodes) { - my $desc; - if (ref($node->{name}) eq 'ARRAY') { - $desc=$node->{name}->[0]; - } else { - $desc=$node->{name}; - } - if ($node->{errorcode}) { - if (ref($node->{errorcode}) eq 'ARRAY') { - foreach my $ecode (@{$node->{errorcode}}) { - $xCAT::Client::EXITCODE |= $ecode; - } - } - else { - $xCAT::Client::EXITCODE |= $node->{errorcode}; - } # assume it is a non-reference scalar - } - if ($node->{error}) { - $desc.=": Error: ".$node->{error}->[0]; - $errflg=1; - } - if ($node->{warning}) { - $desc.=": Warning: ".$node->{warning}->[0]; - $errflg=1; - } - if ($node->{data}) { - if (ref(\($node->{data})) eq 'SCALAR') { - $desc=$desc.": ".$node->{data}; - } elsif (ref($node->{data}) eq 'HASH') { - if ($node->{data}->{desc}) { - if (ref($node->{data}->{desc}) eq 'ARRAY') { - $desc=$desc.": ".$node->{data}->{desc}->[0]; - } else { - $desc=$desc.": ".$node->{data}->{desc}; - } + #print "in handle_response\n"; + # Handle errors + if (defined($rsp->{errorcode})) { + if (ref($rsp->{errorcode}) eq 'ARRAY') { + foreach my $ecode (@{ $rsp->{errorcode} }) { + $xCAT::Client::EXITCODE |= $ecode; } - if ($node->{data}->{contents}) { - if (ref($node->{data}->{contents}) eq 'ARRAY') { - $desc="$desc: ".$node->{data}->{contents}->[0]; + } + else { + $xCAT::Client::EXITCODE |= $rsp->{errorcode}; + } # assume it is a non-reference scalar + } + if ($rsp->{error}) { + + #print "printing error\n"; + if (ref($rsp->{error}) eq 'ARRAY') { + foreach my $text (@{ $rsp->{error} }) { + if ($rsp->{NoErrorPrefix}) { + print STDERR "$text\n"; } else { - $desc="$desc: ".$node->{data}->{contents}; + print STDERR "Error: $text\n"; } } - } elsif (ref(\($node->{data}->[0])) eq 'SCALAR') { - $desc=$desc.": ".$node->{data}->[0]; - } else { - if ($node->{data}->[0]->{desc}) { - $desc=$desc.": ".$node->{data}->[0]->{desc}->[0]; - } - if ($node->{data}->[0]->{contents}) { - $desc="$desc: ".$node->{data}->[0]->{contents}->[0]; - } - } - } - if ($node->{base64_data}) { - $desc = $desc . ": " . decode_base64($node->{base64_data}->[0]); - } - if ($desc) { - if ($errflg == 1) { - print STDERR ("$desc\n"); - } else { - print "$desc\n"; } - } - } - } - - # Handle {data} structure with no nodes - if ($rsp->{data}) { -#print "printing data\n"; - my $data=($rsp->{data}); - my $data_entry; - foreach $data_entry (@$data) { - my $desc; - if (ref(\($data_entry)) eq 'SCALAR') { - $desc=$data_entry; - } else { - if ($data_entry->{desc}) { - $desc=$data_entry->{desc}->[0]; + else { + if ($rsp->{NoErrorPrefix}) { + print STDERR ($rsp->{error} . "\n"); + } else { + print STDERR ("Error: " . $rsp->{error} . "\n"); } - if ($data_entry->{contents}) { - if ($desc) { - $desc="$desc: ".$data_entry->{contents}->[0]; - } else { - $desc=$data_entry->{contents}->[0]; - } - } - } - if ($desc) { print "$desc\n"; } + } } - } -} # end of handle_response + if ($rsp->{warning}) { + + #print "printing warning\n"; + if (ref($rsp->{warning}) eq 'ARRAY') { + foreach my $text (@{ $rsp->{warning} }) { + if ($rsp->{NoWarnPrefix}) { + print STDERR "$text\n"; + } else { + print STDERR "Warning: $text\n"; + } + } + } + else { + if ($rsp->{NoWarnPrefix}) { + print STDERR ($rsp->{warning} . "\n"); + } else { + print STDERR ("Warning: " . $rsp->{warning} . "\n"); + } + } + } + if ($rsp->{info}) { + + #print "printing info\n"; + if (ref($rsp->{info}) eq 'ARRAY') { + foreach my $text (@{ $rsp->{info} }) { + print "$text\n"; + } + } + else { + print($rsp->{info} . "\n"); + } + } + + if ($rsp->{sinfo}) { + if (ref($rsp->{sinfo}) eq 'ARRAY') { + foreach my $text (@{ $rsp->{sinfo} }) { + print "$text\r"; $|++; + } + } + else { + print($rsp->{sinfo} . "\r"); $|++; + } + } + + + + # Handle {node} structure + my $errflg = 0; + my $nodes = ($rsp->{node}); + unless (ref $nodes eq 'ARRAY') { + $nodes = [$nodes]; + } + if (scalar @{$nodes}) { + + #print "printing node\n"; + my $node; + foreach $node (@$nodes) { + my $desc; + if (ref($node->{name}) eq 'ARRAY') { + $desc = $node->{name}->[0]; + } else { + $desc = $node->{name}; + } + if ($node->{errorcode}) { + if (ref($node->{errorcode}) eq 'ARRAY') { + foreach my $ecode (@{ $node->{errorcode} }) { + $xCAT::Client::EXITCODE |= $ecode; + } + } + else { + $xCAT::Client::EXITCODE |= $node->{errorcode}; + } # assume it is a non-reference scalar + } + if ($node->{error}) { + $desc .= ": Error: " . $node->{error}->[0]; + $errflg = 1; + } + if ($node->{warning}) { + $desc .= ": Warning: " . $node->{warning}->[0]; + $errflg = 1; + } + if ($node->{data}) { + if (ref(\($node->{data})) eq 'SCALAR') { + $desc = $desc . ": " . $node->{data}; + } elsif (ref($node->{data}) eq 'HASH') { + if ($node->{data}->{desc}) { + if (ref($node->{data}->{desc}) eq 'ARRAY') { + $desc = $desc . ": " . $node->{data}->{desc}->[0]; + } else { + $desc = $desc . ": " . $node->{data}->{desc}; + } + } + if ($node->{data}->{contents}) { + if (ref($node->{data}->{contents}) eq 'ARRAY') { + $desc = "$desc: " . $node->{data}->{contents}->[0]; + } else { + $desc = "$desc: " . $node->{data}->{contents}; + } + } + } elsif (ref(\($node->{data}->[0])) eq 'SCALAR') { + $desc = $desc . ": " . $node->{data}->[0]; + } else { + if ($node->{data}->[0]->{desc}) { + $desc = $desc . ": " . $node->{data}->[0]->{desc}->[0]; + } + if ($node->{data}->[0]->{contents}) { + $desc = "$desc: " . $node->{data}->[0]->{contents}->[0]; + } + } + } + if ($node->{base64_data}) { + $desc = $desc . ": " . decode_base64($node->{base64_data}->[0]); + } + if ($desc) { + if ($errflg == 1) { + print STDERR ("$desc\n"); + } else { + print "$desc\n"; + } + } + } + } + + # Handle {data} structure with no nodes + if ($rsp->{data}) { + + #print "printing data\n"; + my $data = ($rsp->{data}); + my $data_entry; + foreach $data_entry (@$data) { + my $desc; + if (ref(\($data_entry)) eq 'SCALAR') { + $desc = $data_entry; + } else { + if ($data_entry->{desc}) { + $desc = $data_entry->{desc}->[0]; + } + if ($data_entry->{contents}) { + if ($desc) { + $desc = "$desc: " . $data_entry->{contents}->[0]; + } else { + $desc = $data_entry->{contents}->[0]; + } + } + } + if ($desc) { print "$desc\n"; } + } + } +} # end of handle_response diff --git a/perl-xCAT/xCAT/Common.pm b/perl-xCAT/xCAT/Common.pm index 0ec8ac046..fedb1ebf1 100644 --- a/perl-xCAT/xCAT/Common.pm +++ b/perl-xCAT/xCAT/Common.pm @@ -12,40 +12,40 @@ use Storable qw/store_fd fd_retrieve/; BEGIN { - $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; } -# forward_data is a function used to aggregate output passed up from a set of -# children. This is commonly used due to make absolutely certain multiple +# forward_data is a function used to aggregate output passed up from a set of +# children. This is commonly used due to make absolutely certain multiple # writers trying to use a common file descriptor wouldn't corrupt each other. -# So instead, each child is given a dedicated filehandle and the parent +# So instead, each child is given a dedicated filehandle and the parent # uses this function to organize child data and send it up. # locking might be a more straightforward approach, but locking experiments # weren't as successful. sub forward_data { - my $callback = shift; - my $fds = shift; - my @ready_fds = $fds->can_read(1); - my $rfh; - my $rc = @ready_fds; - foreach $rfh (@ready_fds) { - my $responses; - eval { - $responses = fd_retrieve($rfh); - }; - if ($@ and $@ =~ /^Magic number checking on storable file/) { #this most likely means we ran over the end of available input - $fds->remove($rfh); - close($rfh); - } else { - eval { print $rfh "ACK\n"; }; #Ignore ack loss due to child giving up and exiting, we don't actually explicitly care about the acks - foreach (@$responses) { - $callback->($_); - } + my $callback = shift; + my $fds = shift; + my @ready_fds = $fds->can_read(1); + my $rfh; + my $rc = @ready_fds; + foreach $rfh (@ready_fds) { + my $responses; + eval { + $responses = fd_retrieve($rfh); + }; + if ($@ and $@ =~ /^Magic number checking on storable file/) { #this most likely means we ran over the end of available input + $fds->remove($rfh); + close($rfh); + } else { + eval { print $rfh "ACK\n"; }; #Ignore ack loss due to child giving up and exiting, we don't actually explicitly care about the acks + foreach (@$responses) { + $callback->($_); + } + } } - } - yield(); #Try to avoid useless iterations as much as possible - return $rc; + yield(); #Try to avoid useless iterations as much as possible + return $rc; } #This function pairs with the above. @@ -59,100 +59,100 @@ sub send_data { if (not ref $_[0]) { $node = shift; } - foreach(@_) { - my %output; - if (ref($_) eq HASH) { - store_fd([$_],$out); - yield(); - waitforack($out); - next; - } - my $line; - my $rc; - if (ref($_) eq ARRAY) { - $rc = $_->[0]; - $line = $_->[1]; - } else { - $line = $_; - } - - - (my $desc,my $text) = split (/:/,$line,2); - unless ($text) { - $text=$desc; - } else { - $desc =~ s/^\s+//; - $desc =~ s/\s+$//; - if ($desc) { - $output{node}->[0]->{data}->[0]->{desc}->[0]=$desc; + foreach (@_) { + my %output; + if (ref($_) eq HASH) { + store_fd([$_], $out); + yield(); + waitforack($out); + next; } - } - $text =~ s/^\s+//; - $text =~ s/\s+$//; - $output{node}->[0]->{name}->[0]=$node; - if ($rc) { - $output{node}->[0]->{errorcode} = $rc; - $output{node}->[0]->{error}->[0]->{contents}->[0]=$text; - } else { - $output{node}->[0]->{data}->[0]->{contents}->[0]=$text; - } - store_fd([\%output],$out); - yield(); - waitforack($out); + my $line; + my $rc; + if (ref($_) eq ARRAY) { + $rc = $_->[0]; + $line = $_->[1]; + } else { + $line = $_; + } + + + (my $desc, my $text) = split(/:/, $line, 2); + unless ($text) { + $text = $desc; + } else { + $desc =~ s/^\s+//; + $desc =~ s/\s+$//; + if ($desc) { + $output{node}->[0]->{data}->[0]->{desc}->[0] = $desc; + } + } + $text =~ s/^\s+//; + $text =~ s/\s+$//; + $output{node}->[0]->{name}->[0] = $node; + if ($rc) { + $output{node}->[0]->{errorcode} = $rc; + $output{node}->[0]->{error}->[0]->{contents}->[0] = $text; + } else { + $output{node}->[0]->{data}->[0]->{contents}->[0] = $text; + } + store_fd([ \%output ], $out); + yield(); + waitforack($out); } } #This function is intended to be used to process a request through the usage #module. -sub usage_noderange { - my $request = shift; - my $callback=shift; +sub usage_noderange { + my $request = shift; + my $callback = shift; - #display usage statement if -h is present or no noderage is specified - my $noderange = $request->{node}; #Should be arrayref - my $command = $request->{command}->[0]; - my $extrargs = $request->{arg}; - my @exargs=($request->{arg}); - if (ref($extrargs)) { - @exargs=@$extrargs; - } + #display usage statement if -h is present or no noderage is specified + my $noderange = $request->{node}; #Should be arrayref + my $command = $request->{command}->[0]; + my $extrargs = $request->{arg}; + my @exargs = ($request->{arg}); + if (ref($extrargs)) { + @exargs = @$extrargs; + } - my $usage_string=xCAT::Usage->parseCommand($command, @exargs); - if ($usage_string) { - $callback->({data=>$usage_string}); - $request = {}; - return; - } + my $usage_string = xCAT::Usage->parseCommand($command, @exargs); + if ($usage_string) { + $callback->({ data => $usage_string }); + $request = {}; + return; + } - if (!$noderange) { - $usage_string="Missing Noderange\n"; - $usage_string .=xCAT::Usage->getUsage($command); - $callback->({error=>[$usage_string],errorcode=>[1]}); - $request = {}; - return; - } + if (!$noderange) { + $usage_string = "Missing Noderange\n"; + $usage_string .= xCAT::Usage->getUsage($command); + $callback->({ error => [$usage_string], errorcode => [1] }); + $request = {}; + return; + } } # copy, overwriting only if the source file is newer sub copy_if_newer { - my ($source, $dest) = @_; + my ($source, $dest) = @_; - die "ERROR: source file doesn't exist\n" unless (-e $source); + die "ERROR: source file doesn't exist\n" unless (-e $source); - # resolve destination path - if ($dest =~ m/\/$/ || -d $dest) { - $dest .= '/' if ($dest !~ m/\/$/); - $dest .= $1 if $source =~ m/([^\/]+)$/; - } + # resolve destination path + if ($dest =~ m/\/$/ || -d $dest) { + $dest .= '/' if ($dest !~ m/\/$/); + $dest .= $1 if $source =~ m/([^\/]+)$/; + } - if (-e $dest) { - my $smtime = stat($source)->mtime; - my $dmtime = stat($dest)->mtime; + if (-e $dest) { + my $smtime = stat($source)->mtime; + my $dmtime = stat($dest)->mtime; - return if ($smtime < $dmtime); - } + return if ($smtime < $dmtime); + } - copy($source, $dest); + copy($source, $dest); } 1; diff --git a/perl-xCAT/xCAT/DBobjUtils.pm b/perl-xCAT/xCAT/DBobjUtils.pm index 65843aacd..6f9c9e3f5 100755 --- a/perl-xCAT/xCAT/DBobjUtils.pm +++ b/perl-xCAT/xCAT/DBobjUtils.pm @@ -57,7 +57,7 @@ sub getObjectsOfType # The database may be changed between getObjectsOfType calls # do not use cache %::saveObjList if --nocache is specified if ($::saveObjList{$type} && !$::opt_nc) { - @objlist = @{$::saveObjList{$type}}; + @objlist = @{ $::saveObjList{$type} }; } else { # get the key for this type object @@ -71,9 +71,10 @@ sub getObjectsOfType my $table; my $tabkey; - foreach my $this_attr (@{$datatype->{'attrs'}}) { + foreach my $this_attr (@{ $datatype->{'attrs'} }) { my $attr = $this_attr->{attr_name}; if ($attr eq $objkey) { + # get the table & key for to lookup # get the actual attr name to use in the table # - may be different then the attr name used for the object. @@ -91,22 +92,22 @@ sub getObjectsOfType } # if this is type "group" we need to check the nodelist table - my @nodeGroupList=(); + my @nodeGroupList = (); if ($type eq 'group') { - my $table = "nodelist"; + my $table = "nodelist"; my @TableRowArray = xCAT::DBobjUtils->getDBtable($table); foreach (@TableRowArray) { my @tmplist = split(',', $_->{'groups'}); push(@nodeGroupList, @tmplist); } foreach my $n (@nodeGroupList) { - if (!grep(/^$n$/, @objlist) ) { + if (!grep(/^$n$/, @objlist)) { push(@objlist, $n); } } } - @{$::saveObjList{$type}} = @objlist; + @{ $::saveObjList{$type} } = @objlist; } return @objlist; @@ -138,12 +139,13 @@ sub getObjectsOfType #----------------------------------------------------------------------------- sub getobjattrs { - my $class = shift; + my $class = shift; my $ref_hash = shift; my @attrs; + # The $attrs is an optional argument if (ref $_[0]) { - @attrs = @{shift()}; + @attrs = @{ shift() }; } my %typehash = %$ref_hash; @@ -153,9 +155,10 @@ sub getobjattrs # get a list of object names for each type my %objtypelist; foreach my $objname (sort (keys %typehash)) { + # get list of objects for each type # $objtypelist{$typehash{$objname}}=$objname; - push @{$objtypelist{$typehash{$objname}}}, $objname; + push @{ $objtypelist{ $typehash{$objname} } }, $objname; } # go through each object type and look up all the info for each object @@ -163,15 +166,16 @@ sub getobjattrs # only do node type for now if ($objtype eq 'node') { + # find the list of tables and corresponding attrs # - for this object type # get the object type decription from Schema.pm my $datatype = $xCAT::Schema::defspec{$objtype}; - foreach my $this_attr (@{$datatype->{'attrs'}}) { + foreach my $this_attr (@{ $datatype->{'attrs'} }) { my $attr = $this_attr->{attr_name}; - if (scalar(@attrs) > 0) { # Only query specific attributes + if (scalar(@attrs) > 0) { # Only query specific attributes if (!grep(/^$attr$/, @attrs)) { - next; # This attribute is not needed + next; # This attribute is not needed } } @@ -180,14 +184,15 @@ sub getobjattrs # used in the node def # ex. 'nodetype.arch' my ($lookup_table, $table_attr) = split('\.', $this_attr->{tabentry}); - if (!grep(/^$table_attr$/, @{$tableattrs{$lookup_table}})) { - push @{$tableattrs{$lookup_table}}, $table_attr; + if (!grep(/^$table_attr$/, @{ $tableattrs{$lookup_table} })) { + push @{ $tableattrs{$lookup_table} }, $table_attr; } } # foreach table look up the list of attrs for this # list of object names foreach my $table (keys %tableattrs) { + # open the table # with autocommit => 0, it does not work on Ubuntu running mysql my $thistable = xCAT::Table->new($table, -create => 1, -autocommit => 1); @@ -198,23 +203,26 @@ sub getobjattrs next; } - my @objlist = @{$objtypelist{$objtype}}; + my @objlist = @{ $objtypelist{$objtype} }; - my $rec = $thistable->getNodesAttribs(\@objlist, @{$tableattrs{$table}}); + my $rec = $thistable->getNodesAttribs(\@objlist, @{ $tableattrs{$table} }); # fill in %tabhash with any values that are set foreach my $n (@objlist) { - my $tmp1=$rec->{$n}->[0]; - foreach $a (@{$tableattrs{$table}}) { + my $tmp1 = $rec->{$n}->[0]; + foreach $a (@{ $tableattrs{$table} }) { if (defined($tmp1->{$a})) { $tabhash{$table}{$n}{$a} = $tmp1->{$a}; + #print "obj = $n, table = $table, attr =$a, val = $tabhash{$table}{$n}{$a}\n"; } else { + # Add a has been searched flag to improve the performance - $tabhash{$table}{$n}{"$a"."_hassearched"} = 1; + $tabhash{$table}{$n}{ "$a" . "_hassearched" } = 1; } } } + #$thistable->commit; } } @@ -266,6 +274,7 @@ sub getobjdefs @::foundTableList = (); if ($::ATTRLIST eq "none") { + # just return the list of obj names foreach my $objname (sort (keys %typehash)) { my $type = $typehash{$objname}; @@ -275,10 +284,10 @@ sub getobjdefs } # see if we need to get any objects of type 'node' - my $getnodes=0; + my $getnodes = 0; foreach my $objname (keys %typehash) { if ($typehash{$objname} eq 'node') { - $getnodes=1; + $getnodes = 1; } } @@ -288,10 +297,10 @@ sub getobjdefs # values from when using 'only_if' - see below # - but this saves lots of time if ($getnodes) { - if (scalar(@attrs) > 0) { # Only get specific attributes of the node - # find the onlyif key for the attributes - REDO: my $datatype = $xCAT::Schema::defspec{'node'}; - foreach my $this_attr (@{$datatype->{'attrs'}}) { + if (scalar(@attrs) > 0) { # Only get specific attributes of the node + # find the onlyif key for the attributes + REDO: my $datatype = $xCAT::Schema::defspec{'node'}; + foreach my $this_attr (@{ $datatype->{'attrs'} }) { my $attr = $this_attr->{attr_name}; if (exists($this_attr->{only_if})) { my ($onlyif_key, $onlyif_value) = split('\=', $this_attr->{only_if}); @@ -310,23 +319,23 @@ sub getobjdefs # Classify the nodes with type my %type_obj = (); foreach my $objname (keys %typehash) { - push @{$type_obj{$typehash{$objname}}}, $objname; + push @{ $type_obj{ $typehash{$objname} } }, $objname; } foreach my $objtype (sort (keys %type_obj)) { if ($objtype eq 'site') { my @TableRowArray = xCAT::DBobjUtils->getDBtable('site'); - foreach my $objname (sort @{$type_obj{$objtype}}) { + foreach my $objname (sort @{ $type_obj{$objtype} }) { if (@TableRowArray) { my $foundinfo = 0; foreach (@TableRowArray) { if ($_->{key}) { - if (defined($_->{value}) ) { + if (defined($_->{value})) { $foundinfo++; if ($verbose == 1) { - $objhash{$objname}{$_->{key}} = "$_->{value}\t(Table:site - Key:$_->{key})"; + $objhash{$objname}{ $_->{key} } = "$_->{value}\t(Table:site - Key:$_->{key})"; } else { - $objhash{$objname}{$_->{key}} = $_->{value}; + $objhash{$objname}{ $_->{key} } = $_->{value}; } } } @@ -336,27 +345,28 @@ sub getobjdefs } } else { my $rsp; - $rsp->{data}->[0] ="Could not read the \'$objname\' object from the \'site\' table."; + $rsp->{data}->[0] = "Could not read the \'$objname\' object from the \'site\' table."; xCAT::MsgUtils->message("E", $rsp, $::callback); } } } elsif ($objtype eq 'monitoring') { + # need a special case for the monitoring table # - need to check the monsetting table for entries that contain # the same name as the monitoring table entry. my @TableRowArray = xCAT::DBobjUtils->getDBtable('monsetting'); - foreach my $objname (sort @{$type_obj{$objtype}}) { + foreach my $objname (sort @{ $type_obj{$objtype} }) { if (@TableRowArray) { my $foundinfo = 0; foreach (@TableRowArray) { - if ($_->{name} eq $objname ) { + if ($_->{name} eq $objname) { if ($_->{key}) { - if (defined($_->{value}) ) { + if (defined($_->{value})) { $foundinfo++; if ($verbose == 1) { - $objhash{$objname}{$_->{key}} = "$_->{value}\t(Table:monsetting)"; + $objhash{$objname}{ $_->{key} } = "$_->{value}\t(Table:monsetting)"; } else { - $objhash{$objname}{$_->{key}} = $_->{value}; + $objhash{$objname}{ $_->{key} } = $_->{value}; } } } @@ -367,26 +377,28 @@ sub getobjdefs } } else { my $rsp; - $rsp->{data}->[0] ="Could not read the \'$objname\' object from the \'monsetting\' table."; + $rsp->{data}->[0] = "Could not read the \'$objname\' object from the \'monsetting\' table."; xCAT::MsgUtils->message("E", $rsp, $::callback); } } } elsif (($objtype eq 'auditlog') || ($objtype eq 'eventlog')) { + # Special case for auditlog/eventlog # All the auditlog/eventlog attributes are in auditlog/eventlog table, # Do not need to read the table multiple times for each attribute. # The auditlog/eventlog is likely be very big over time, # performance is a big concern with the general logic my @TableRowArray = xCAT::DBobjUtils->getDBtable($objtype); - foreach my $objname (sort @{$type_obj{$objtype}}) { + foreach my $objname (sort @{ $type_obj{$objtype} }) { if (@TableRowArray) { my $foundinfo = 0; foreach my $entry (@TableRowArray) { if ($entry->{recid} eq $objname) { foreach my $k (keys %{$entry}) { + # recid is the object name, do not need to be in the attributes list if ($k eq 'recid') { next; } - if (defined($entry->{$k}) ) { + if (defined($entry->{$k})) { $foundinfo++; if ($verbose == 1) { $objhash{$objname}{$k} = "$entry->{$k}\t(Table:$objtype - Key:$k)"; @@ -398,20 +410,23 @@ sub getobjdefs if ($foundinfo) { $objhash{$objname}{'objtype'} = $objtype; } + # There should not be multiple entries with the same recid last; - } # end if($entry-> - } # end foreach my $entry - } # end if(@TableTowArray - } # end foreach my $objname + } # end if($entry-> + } # end foreach my $entry + } # end if(@TableTowArray + } # end foreach my $objname } else { + # get the object type decription from Schema.pm my $datatype = $xCAT::Schema::defspec{$objtype}; + # get the key to look for, for this object type my $objkey = $datatype->{'objkey'}; # go through the list of valid attrs - foreach my $this_attr (@{$datatype->{'attrs'}}) { + foreach my $this_attr (@{ $datatype->{'attrs'} }) { my $ent; my $attr = $this_attr->{attr_name}; @@ -419,6 +434,7 @@ sub getobjdefs if ($attr eq $objkey) { next; } + # skip the attributes that does not needed for node type if ($getnodes) { if (scalar(@attrs) > 0 && !grep(/^$attr$/, @attrs)) { @@ -434,7 +450,8 @@ sub getobjdefs # ex. noderes.nfsdir my ($tab, $tabattr) = split('\.', $this_attr->{tabentry}); - foreach my $objname (sort @{$type_obj{$objtype}}) { + foreach my $objname (sort @{ $type_obj{$objtype} }) { + # get table lookup info from Schema.pm # !!!! some tables depend on the value of certain attrs # we need to look up attrs in the correct order or we will @@ -442,22 +459,24 @@ sub getobjdefs # in for some attrs. if (exists($this_attr->{only_if})) { my ($check_attr, $check_value) = split('\=', $this_attr->{only_if}); + # if the object value is not the value we need # to match then try the next only_if value - next if ( !($objhash{$objname}{$check_attr} =~ /\b$check_value\b/) ); + next if (!($objhash{$objname}{$check_attr} =~ /\b$check_value\b/)); } $objhash{$objname}{'objtype'} = $objtype; my %tabentry = (); + # def commands need to support multiple keys in one table # the subroutine parse_access_tabentry is used for supporting multiple keys my $rc = xCAT::DBobjUtils->parse_access_tabentry($objname, - $this_attr->{access_tabentry}, \%tabentry); + $this_attr->{access_tabentry}, \%tabentry); if ($rc != 0) { my $rsp; $rsp->{data}->[0] = - "access_tabentry \'$this_attr->{access_tabentry}\' is not valid."; +"access_tabentry \'$this_attr->{access_tabentry}\' is not valid."; xCAT::MsgUtils->message("E", $rsp, $::callback); next; } @@ -465,12 +484,13 @@ sub getobjdefs # Only allow one table in the access_tabentry # use multiple tables to look up tabentry does not make any sense my $lookup_table = $tabentry{'lookup_table'}; - my $intabhash = 0; - my $notsearched = 0; - foreach my $lookup_attr (keys %{$tabentry{'lookup_attrs'}}) { + my $intabhash = 0; + my $notsearched = 0; + foreach my $lookup_attr (keys %{ $tabentry{'lookup_attrs'} }) { + # Check whether the attribute is already in %tabhash # The %tabhash is for performance considerations - if ( ($lookup_attr eq 'node') && ($objtype eq 'node') ) { + if (($lookup_attr eq 'node') && ($objtype eq 'node')) { if (defined($tabhash{$lookup_table}{$objname}{$tabattr})) { if ($verbose == 1) { $objhash{$objname}{$attr} = "$tabhash{$lookup_table}{$objname}{$tabattr}\t(Table:$lookup_table - Key:$lookup_attr - Column:$tabattr)"; @@ -478,11 +498,11 @@ sub getobjdefs $objhash{$objname}{$attr} = $tabhash{$lookup_table}{$objname}{$tabattr}; } if (defined $chname_ref) { - push @{$chname_ref->{$lookup_table}}, ($tabentry{'lookup_attrs'}, $lookup_attr); + push @{ $chname_ref->{$lookup_table} }, ($tabentry{'lookup_attrs'}, $lookup_attr); } $intabhash = 1; last; - } elsif (! defined($tabhash{$lookup_table}{$objname}{"$tabattr"."_hassearched"})) { + } elsif (!defined($tabhash{$lookup_table}{$objname}{ "$tabattr" . "_hassearched" })) { $notsearched = 1; } } else { @@ -493,14 +513,16 @@ sub getobjdefs # Not in tabhash, # Need to lookup the table if ($intabhash == 0 && $notsearched == 1) { + # look up attr values my @rows = xCAT::DBobjUtils->getDBtable($lookup_table); if (@rows) { foreach my $rowent (@rows) { my $match = 1; my $matchedattr; + # Again, multiple keys support needs the "foreach" - foreach my $lookup_attr (keys %{$tabentry{'lookup_attrs'}}) { + foreach my $lookup_attr (keys %{ $tabentry{'lookup_attrs'} }) { if ($rowent->{$lookup_attr} ne $tabentry{'lookup_attrs'}{$lookup_attr}) { $match = 0; last; @@ -508,24 +530,24 @@ sub getobjdefs } if ($match == 1) { if ($verbose == 1) { - my @lookup_attrs = keys %{$tabentry{'lookup_attrs'}}; + my @lookup_attrs = keys %{ $tabentry{'lookup_attrs'} }; $objhash{$objname}{$attr} = "$rowent->{$tabattr}\t(Table:$lookup_table - Key: @lookup_attrs - Column:$tabattr)"; } else { $objhash{$objname}{$attr} = $rowent->{$tabattr}; } if (defined $chname_ref) { - push @{$chname_ref->{$lookup_table}}, ($tabentry{'lookup_attrs'}, (keys %{$tabentry{'lookup_attrs'}}) [0]); + push @{ $chname_ref->{$lookup_table} }, ($tabentry{'lookup_attrs'}, (keys %{ $tabentry{'lookup_attrs'} })[0]); } - } #end if ($match... - } #end foreach - } # end if (defined... - } #end if ($intabhash... + } #end if ($match... + } #end foreach + } # end if (defined... + } #end if ($intabhash... } } } - } #foreach my $objtype + } #foreach my $objtype return %objhash; } @@ -562,7 +584,7 @@ sub getDBtable if (grep(/^$table$/, @::foundTableList) && !$::opt_nc) { # already have this - @rows = @{$::TableHash{$table}}; + @rows = @{ $::TableHash{$table} }; } else { @@ -573,7 +595,7 @@ sub getDBtable } #@rows = $thistable->getTable; - @rows = @{$thistable->getAllEntries()}; + @rows = @{ $thistable->getAllEntries() }; # !!!! this routine returns rows even if the table is empty!!!!!! @@ -581,11 +603,11 @@ sub getDBtable # - even if it's empty! push(@::foundTableList, $thistable->{tabname}); - @{$::TableHash{$table}} = @rows; + @{ $::TableHash{$table} } = @rows; #$thistable->commit; - } # end if not cached + } # end if not cached if (@rows) { return @rows; @@ -628,7 +650,7 @@ sub setobjdefs my %settableref; my $ret = 0; my %allupdates; - my $setattrs=0; + my $setattrs = 0; # get the attr=vals for these objects from the DB - if any # - so we can figure out where to put additional attrs @@ -641,7 +663,7 @@ sub setobjdefs foreach my $objname (keys %objhash) { my $type = $objhash{$objname}{objtype}; $DBhash{$objname} = $type; - @attrs = keys %{$objhash{$objname}}; + @attrs = keys %{ $objhash{$objname} }; } my %DBattrvals; @@ -667,7 +689,7 @@ sub setobjdefs # get a list of valid attr names # for this type object my @attrlist; - foreach my $entry (@{$datatype->{'attrs'}}) { + foreach my $entry (@{ $datatype->{'attrs'} }) { push(@attrlist, $entry->{'attr_name'}); } @@ -679,6 +701,7 @@ sub setobjdefs xCAT::MsgUtils->message("E", $rsp, $::callback); return 1; } + # open the table my $monsettable = xCAT::Table->new('monsetting', -create => 1, -autocommit => 0); if (!$monsettable) { @@ -691,7 +714,7 @@ sub setobjdefs my %keyhash; my %updates; - foreach my $attr (keys %{$objhash{$objname}}) { + foreach my $attr (keys %{ $objhash{$objname} }) { my $val; if ($attr eq 'objtype') { next; @@ -699,6 +722,7 @@ sub setobjdefs # determine the value if we have plus or minus if ($::plus_option) { + # add new to existing - at the end - comma separated if (defined($DBattrvals{$objname}{$attr})) { $val = "$DBattrvals{$objname}{$attr},$objhash{$objname}{$attr}"; @@ -706,12 +730,14 @@ sub setobjdefs $val = "$objhash{$objname}{$attr}"; } } elsif ($::minus_option) { + # remove the specified list of values from the current # attr values. if ($DBattrvals{$objname}{$attr}) { + # get the list of attrs to remove my @currentList = split(/,/, $DBattrvals{$objname}{$attr}); - my @minusList = split(/,/, $objhash{$objname}{$attr}); + my @minusList = split(/,/, $objhash{$objname}{$attr}); # make a new list without the one specified my $first = 1; @@ -719,6 +745,7 @@ sub setobjdefs foreach my $i (@currentList) { chomp $i; if (!grep(/^$i$/, @minusList)) { + # set new groups list for node if (!$first) { $newlist .= ","; @@ -730,19 +757,22 @@ sub setobjdefs $val = $newlist; } } else { + #just set the attr to what was provided! - replace $val = $objhash{$objname}{$attr}; } if (grep(/^$attr$/, @attrlist)) { + # if the attr belong in the monitoring tabel - %keyhash=(name=>$objname); - %updates=($attr=>$val); + %keyhash = (name => $objname); + %updates = ($attr => $val); $montable->setAttribs(\%keyhash, \%updates); } else { + # else it belongs in the monsetting table - $keyhash{name} = $objname; - $keyhash{key} = $attr; + $keyhash{name} = $objname; + $keyhash{key} = $attr; $updates{value} = $val; $monsettable->setAttribs(\%keyhash, \%updates); } @@ -751,13 +781,14 @@ sub setobjdefs $montable->commit; $monsettable->commit; next; - } #if ($type eq 'monitoring') + } #if ($type eq 'monitoring') # handle the site table as a special case !!!!! if ($type eq 'site') { + # open the table my $thistable = - xCAT::Table->new('site', -create => 1, -autocommit => 0); + xCAT::Table->new('site', -create => 1, -autocommit => 0); if (!$thistable) { my $rsp; $rsp->{data}->[0] = "Could not set the \'$thistable\' table."; @@ -765,7 +796,7 @@ sub setobjdefs return 1; } - foreach my $attr (keys %{$objhash{$objname}}) { + foreach my $attr (keys %{ $objhash{$objname} }) { if ($attr eq 'objtype') { next; } @@ -775,20 +806,23 @@ sub setobjdefs my $val; if ($::plus_option) { + # add new to existing - at the end - comma separated if (defined($DBattrvals{$objname}{$attr})) { $val = - "$DBattrvals{$objname}{$attr},$objhash{$objname}{$attr}"; +"$DBattrvals{$objname}{$attr},$objhash{$objname}{$attr}"; } else { $val = "$objhash{$objname}{$attr}"; } } elsif ($::minus_option) { + # remove the specified list of values from the current # attr values. if ($DBattrvals{$objname}{$attr}) { + # get the list of attrs to remove my @currentList = split(/,/, $DBattrvals{$objname}{$attr}); - my @minusList = split(/,/, $objhash{$objname}{$attr}); + my @minusList = split(/,/, $objhash{$objname}{$attr}); # make a new list without the one specified my $first = 1; @@ -796,6 +830,7 @@ sub setobjdefs foreach my $i (@currentList) { chomp $i; if (!grep(/^$i$/, @minusList)) { + # set new groups list for node if (!$first) { $newlist .= ","; @@ -813,9 +848,9 @@ sub setobjdefs } - if ( $val eq "") { # delete the line + if ($val eq "") { # delete the line $thistable->delEntries(\%keyhash); - } else { # change the attr + } else { # change the attr my %updates; $updates{value} = $val; @@ -825,9 +860,9 @@ sub setobjdefs if ($::verbose) { my $rsp; $rsp->{data}->[0] = - "Could not set the \'$attr\' attribute of the \'$objname\' object in the xCAT database."; +"Could not set the \'$attr\' attribute of the \'$objname\' object in the xCAT database."; $rsp->{data}->[1] = - "Error returned is \'$str->errstr\'."; + "Error returned is \'$str->errstr\'."; xCAT::MsgUtils->message("I", $rsp, $::callback); } $ret = 1; @@ -839,7 +874,7 @@ sub setobjdefs $thistable->commit; next; - } #if ($type eq 'site') + } #if ($type eq 'site') @@ -856,21 +891,23 @@ sub setobjdefs # get a list of valid attr names # for this type object my %attrlist; - foreach my $entry (@{$datatype->{'attrs'}}) { + foreach my $entry (@{ $datatype->{'attrs'} }) { + #push(@{$attrlist{$type}}, $entry->{'attr_name'}); - $attrlist{$type}{$entry->{'attr_name'}} = 1; + $attrlist{$type}{ $entry->{'attr_name'} } = 1; } - my @attrprovided=(); + my @attrprovided = (); # check FINALATTRS to see if all the attrs are valid - foreach my $attr (keys %{$objhash{$objname}}) { + foreach my $attr (keys %{ $objhash{$objname} }) { if ($attr eq $objkey) { next; } if ($attr eq "objtype") { + # objtype not stored in object definition next; } @@ -892,11 +929,11 @@ sub setobjdefs # store each attr # And we must do this in the order given in defspec!! - my @setattrlist=(); + my @setattrlist = (); my %checkedattrs; my $invalidattr; - foreach my $this_attr (@{$datatype->{'attrs'}}) { + foreach my $this_attr (@{ $datatype->{'attrs'} }) { my %keyhash; my %updates; my %tabentry; @@ -910,6 +947,7 @@ sub setobjdefs # if we have a value for this attribute then process it # - otherwise go to the next attr if (defined($objhash{$objname}{$attr_name})) { + # check the defspec to see where this attr goes # the table for this attr might depend on the @@ -933,25 +971,26 @@ sub setobjdefs # as well as the attrs for this object that may be # already set in DB - if ( !($objhash{$objname}{$check_attr}) && !($DBattrvals{$objname}{$check_attr}) ) { + if (!($objhash{$objname}{$check_attr}) && !($DBattrvals{$objname}{$check_attr})) { + # if I didn't already check for this attr my $rsp; if (!defined($checkedattrs{$attr_name})) { - push @{$rsp->{data}}, "Cannot set the \'$attr_name\' attribute unless a value is provided for \'$check_attr\'."; + push @{ $rsp->{data} }, "Cannot set the \'$attr_name\' attribute unless a value is provided for \'$check_attr\'."; - foreach my $tmp_attr (@{$datatype->{'attrs'}}) { + foreach my $tmp_attr (@{ $datatype->{'attrs'} }) { my $attr = $tmp_attr->{attr_name}; if ($attr eq $check_attr) { my ($tab, $at) = split(/\./, $tmp_attr->{tabentry}); my $schema = xCAT::Table->getTableSchema($tab); my $desc = $schema->{descriptions}->{$at}; - push @{$rsp->{data}}, "$check_attr => $desc"; + push @{ $rsp->{data} }, "$check_attr => $desc"; } } } xCAT::MsgUtils->message("I", $rsp, $::callback); $checkedattrs{$attr_name} = 1; - if ( $invalidattr->{$attr_name}->{valid} ne 1 ) { + if ($invalidattr->{$attr_name}->{valid} ne 1) { $invalidattr->{$attr_name}->{valid} = 0; $invalidattr->{$attr_name}->{condition} = "\'$check_attr=$check_value\'"; } @@ -959,8 +998,8 @@ sub setobjdefs next; } - if ( !($objhash{$objname}{$check_attr} =~ /\b$check_value\b/) && !($DBattrvals{$objname}{$check_attr} =~ /\b$check_value\b/) ) { - if ( $invalidattr->{$attr_name}->{valid} ne 1 ) { + if (!($objhash{$objname}{$check_attr} =~ /\b$check_value\b/) && !($DBattrvals{$objname}{$check_attr} =~ /\b$check_value\b/)) { + if ($invalidattr->{$attr_name}->{valid} ne 1) { $invalidattr->{$attr_name}->{valid} = 0; $invalidattr->{$attr_name}->{condition} = "\'$check_attr=$check_value\'"; @@ -979,20 +1018,21 @@ sub setobjdefs ($ntab, $::tabattr) = split('\.', $this_attr->{tabentry}); my $rc = xCAT::DBobjUtils->parse_access_tabentry($objname, - $this_attr->{access_tabentry}, \%tabentry); + $this_attr->{access_tabentry}, \%tabentry); if ($rc != 0) { my $rsp; $rsp->{data}->[0] = - "access_tabentry \'$this_attr->{access_tabentry}\' is not valid."; +"access_tabentry \'$this_attr->{access_tabentry}\' is not valid."; xCAT::MsgUtils->message("E", $rsp, $::callback); next; } $lookup_table = $tabentry{'lookup_table'}; + # Set the lookup criteria for this attribute into %allupdates # the key is 'lookup_attrs' - foreach my $lookup_attr (keys %{$tabentry{'lookup_attrs'}}) { + foreach my $lookup_attr (keys %{ $tabentry{'lookup_attrs'} }) { $allupdates{$lookup_table}{$objname}{$attr_name}{'lookup_attrs'}{$lookup_attr} - =$tabentry{'lookup_attrs'}{$lookup_attr}; + = $tabentry{'lookup_attrs'}{$lookup_attr}; } } else { next; @@ -1000,7 +1040,8 @@ sub setobjdefs my $val; my $delim = ','; - if(($type eq 'group') && ($DBattrvals{$objname}{'grouptype'} eq 'dynamic')) { + if (($type eq 'group') && ($DBattrvals{$objname}{'grouptype'} eq 'dynamic')) { + # dynamic node group selection string use "::" as delimiter $delim = '::'; } @@ -1009,6 +1050,7 @@ sub setobjdefs # add new to existing - at the end - comma separated if (defined($DBattrvals{$objname}{$attr_name})) { + # add the attr into the list if it's not already in the list! # and avoid the duplicate values my @DBattrarray = split(/$delim/, $DBattrvals{$objname}{$attr_name}); @@ -1035,7 +1077,7 @@ sub setobjdefs my @minusList = split(/$delim/, $objhash{$objname}{$attr_name}); foreach my $em (@minusList) { - if (!(grep {$_ eq $em} @currentList)) { + if (!(grep { $_ eq $em } @currentList)) { if (($::opt_t eq 'group') && ($DBattrvals{$objname}{'grouptype'} ne 'dynamic')) { my $rsp; $rsp->{data}->[0] = "$objname is not a member of \'$em\'."; @@ -1047,6 +1089,7 @@ sub setobjdefs } } } + # make a new list without the one specified my $first = 1; my $newlist; @@ -1075,7 +1118,7 @@ sub setobjdefs # Set the values into %allupdates # the key is 'tabattrs' $allupdates{$lookup_table}{$objname}{$attr_name}{'tabattrs'}{$::tabattr} = $val; - $setattrs=1; + $setattrs = 1; push(@setattrlist, $attr_name); @@ -1083,9 +1126,9 @@ sub setobjdefs my $rsp; foreach my $att (keys %$invalidattr) { - if ( $invalidattr->{$att}->{valid} ne 1) { -my $tt = $invalidattr->{$att}->{valid}; - push @{$rsp->{data}}, "Cannot set the attr=\'$att\' attribute unless $invalidattr->{$att}->{condition}."; + if ($invalidattr->{$att}->{valid} ne 1) { + my $tt = $invalidattr->{$att}->{valid}; + push @{ $rsp->{data} }, "Cannot set the attr=\'$att\' attribute unless $invalidattr->{$att}->{condition}."; xCAT::MsgUtils->message("E", $rsp, $::callback); } } @@ -1099,6 +1142,7 @@ my $tt = $invalidattr->{$att}->{valid}; my @errlist; foreach $a (@attrprovided) { + # is this attr was not set then add it to the error list if (!grep(/^$a$/, @setattrlist)) { push(@errlist, $a); @@ -1115,55 +1159,56 @@ my $tt = $invalidattr->{$att}->{valid}; } } # end - foreach object -#==========================================================# -#%allupdates structure: -# for command: chdef -t node -o node1 groups=all -# usercomment=ddee passwd.HMC=HMC -# passwd.admin=cluster passwd.general=abc123 -# the %allupdates will be: -#0 'ppcdirect' -#1 HASH(0x12783d30) -# 'node1' => HASH(0x12783cc4) -# 'passwd.HMC' => HASH(0x12783ed4) -# 'lookup_attrs' => HASH(0x12783f70) -# 'hcp' => 'node1' -# 'username' => 'HMC' -# 'tabattrs' => HASH(0x12783e8c) -# 'password' => 'HMC' -# 'passwd.admin' => HASH(0x12783c64) -# 'lookup_attrs' => HASH(0x12784000) -# 'hcp' => 'node1' -# 'username' => 'admin' -# 'tabattrs' => HASH(0x12783f64) -# 'password' => 'cluster' -# 'passwd.general' => HASH(0x12783a6c) -# 'lookup_attrs' => HASH(0x12784198) -# 'hcp' => 'node1' -# 'username' => 'general' -# 'tabattrs' => HASH(0x12783aa8) -# 'password' => 'abc123' -#2 'nodelist' -#3 HASH(0x127842b8) -# 'node1' => HASH(0x12784378) -# 'groups' => HASH(0x12784090) -# 'lookup_attrs' => HASH(0x127844bc) -# 'node' => 'node1' -# 'tabattrs' => HASH(0x1277fd34) -# 'groups' => 'all' -# 'usercomment' => HASH(0x12784318) -# 'lookup_attrs' => HASH(0x12780550) -# 'node' => 'node1' -# 'tabattrs' => HASH(0x127842f4) -# 'comments' => 'ddee' -#=================================================================# + + #==========================================================# + #%allupdates structure: + # for command: chdef -t node -o node1 groups=all + # usercomment=ddee passwd.HMC=HMC + # passwd.admin=cluster passwd.general=abc123 + # the %allupdates will be: + #0 'ppcdirect' + #1 HASH(0x12783d30) + # 'node1' => HASH(0x12783cc4) + # 'passwd.HMC' => HASH(0x12783ed4) + # 'lookup_attrs' => HASH(0x12783f70) + # 'hcp' => 'node1' + # 'username' => 'HMC' + # 'tabattrs' => HASH(0x12783e8c) + # 'password' => 'HMC' + # 'passwd.admin' => HASH(0x12783c64) + # 'lookup_attrs' => HASH(0x12784000) + # 'hcp' => 'node1' + # 'username' => 'admin' + # 'tabattrs' => HASH(0x12783f64) + # 'password' => 'cluster' + # 'passwd.general' => HASH(0x12783a6c) + # 'lookup_attrs' => HASH(0x12784198) + # 'hcp' => 'node1' + # 'username' => 'general' + # 'tabattrs' => HASH(0x12783aa8) + # 'password' => 'abc123' + #2 'nodelist' + #3 HASH(0x127842b8) + # 'node1' => HASH(0x12784378) + # 'groups' => HASH(0x12784090) + # 'lookup_attrs' => HASH(0x127844bc) + # 'node' => 'node1' + # 'tabattrs' => HASH(0x1277fd34) + # 'groups' => 'all' + # 'usercomment' => HASH(0x12784318) + # 'lookup_attrs' => HASH(0x12780550) + # 'node' => 'node1' + # 'tabattrs' => HASH(0x127842f4) + # 'comments' => 'ddee' + #=================================================================# # now set the attribute values in the tables # - handles all except site, monitoring & monsetting for now if ($setattrs) { foreach my $table (keys %allupdates) { - # get the keys for this table + # get the keys for this table my $schema = xCAT::Table->getTableSchema($table); - my $keys = $schema->{keys}; + my $keys = $schema->{keys}; # open the table my $thistable = xCAT::Table->new($table, -create => 1, -autocommit => 0); @@ -1186,23 +1231,24 @@ my $tt = $invalidattr->{$att}->{valid}; my @TableRowArray = xCAT::DBobjUtils->getDBtable('postscripts'); if (@TableRowArray) { foreach my $tablerow (@TableRowArray) { - if(($tablerow->{node} eq 'xcatdefaults') && !($tablerow->{disable})) { - $xcatdefaultsps = $tablerow->{postscripts}; + if (($tablerow->{node} eq 'xcatdefaults') && !($tablerow->{disable})) { + $xcatdefaultsps = $tablerow->{postscripts}; $xcatdefaultspbs = $tablerow->{postbootscripts}; last; } } } - my @xcatdefps = split(/,/, $xcatdefaultsps); + my @xcatdefps = split(/,/, $xcatdefaultsps); my @xcatdefpbs = split(/,/, $xcatdefaultspbs); - foreach my $obj(keys %{$allupdates{$table}}) { + foreach my $obj (keys %{ $allupdates{$table} }) { if ($obj eq 'xcatdefaults') { + #xcatdefaults can be treated as a node? next; } my @newps; if (defined($allupdates{$table}{$obj}{'postscripts'}) - && defined($allupdates{$table}{$obj}{'postscripts'}{'tabattrs'}{'postscripts'})) { + && defined($allupdates{$table}{$obj}{'postscripts'}{'tabattrs'}{'postscripts'})) { foreach my $tempps (split(/,/, $allupdates{$table}{$obj}{'postscripts'}{'tabattrs'}{'postscripts'})) { if (grep(/^$tempps$/, @xcatdefps)) { my $rsp; @@ -1216,7 +1262,7 @@ my $tt = $invalidattr->{$att}->{valid}; } my @newpbs; if (defined($allupdates{$table}{$obj}{'postbootscripts'}) - && defined($allupdates{$table}{$obj}{'postbootscripts'}{'tabattrs'}{'postbootscripts'})) { + && defined($allupdates{$table}{$obj}{'postbootscripts'}{'tabattrs'}{'postbootscripts'})) { foreach my $temppbs (split(/,/, $allupdates{$table}{$obj}{'postbootscripts'}{'tabattrs'}{'postbootscripts'})) { if (grep(/^$temppbs$/, @xcatdefpbs)) { my $rsp; @@ -1233,11 +1279,12 @@ my $tt = $invalidattr->{$att}->{valid}; my $commit_manually = 0; my %node_updates; - OBJ: foreach my $obj (keys %{$allupdates{$table}}) { + OBJ: foreach my $obj (keys %{ $allupdates{$table} }) { my %keyhash; my %updates; my $firsttime = 1; - ROW: foreach my $row (keys %{$allupdates{$table}{$obj}}) { + ROW: foreach my $row (keys %{ $allupdates{$table}{$obj} }) { + # make sure we have a value for each key foreach my $k (@$keys) { if (!$allupdates{$table}{$obj}{$row}{'lookup_attrs'}) { @@ -1250,26 +1297,30 @@ my $tt = $invalidattr->{$att}->{valid}; } if ($firsttime) { + # lookup keys in %hashkey # ex. $keyhash{'hcp'} = node1 - foreach my $key (keys %{$allupdates{$table}{$obj}{$row}{'lookup_attrs'}}) { + foreach my $key (keys %{ $allupdates{$table}{$obj}{$row}{'lookup_attrs'} }) { $keyhash{$key} = $allupdates{$table}{$obj}{$row}{'lookup_attrs'}{$key}; } $firsttime = 0; } else { + # check if the look_attrs is the same as the %keyhash - foreach my $key (keys %{$allupdates{$table}{$obj}{$row}{'lookup_attrs'}}) { + foreach my $key (keys %{ $allupdates{$table}{$obj}{$row}{'lookup_attrs'} }) { + # The lookup_attrs can be different for tables with more than one keys such as ppcdirect - if ((scalar(keys %keyhash) != scalar(keys %{$allupdates{$table}{$obj}{$row}{'lookup_attrs'}})) - || !defined($keyhash{$key}) - ||($keyhash{$key} ne $allupdates{$table}{$obj}{$row}{'lookup_attrs'}{$key})) { + if ((scalar(keys %keyhash) != scalar(keys %{ $allupdates{$table}{$obj}{$row}{'lookup_attrs'} })) + || !defined($keyhash{$key}) + || ($keyhash{$key} ne $allupdates{$table}{$obj}{$row}{'lookup_attrs'}{$key})) { + # different keys, set the existing attributes into database # update the %keyhash and clean up the %updates hash if (%updates) { $commit_manually = 1; my ($rc, $str) = $thistable->setAttribs(\%keyhash, \%updates); } - foreach my $key (keys %{$allupdates{$table}{$obj}{$row}{'lookup_attrs'}}) { + foreach my $key (keys %{ $allupdates{$table}{$obj}{$row}{'lookup_attrs'} }) { $keyhash{$key} = $allupdates{$table}{$obj}{$row}{'lookup_attrs'}{$key}; } %updates = (); @@ -1279,7 +1330,7 @@ my $tt = $invalidattr->{$att}->{valid}; # set values in %updates # ex. $updates{'groups'} = 'all,lpar' - foreach my $attr (keys %{$allupdates{$table}{$obj}{$row}{'tabattrs'}}) { + foreach my $attr (keys %{ $allupdates{$table}{$obj}{$row}{'tabattrs'} }) { if (scalar(keys %keyhash) == 0 && $keyhash{'node'} && $keyhash{'node'} eq "node") { $node_updates{$obj}{$attr} = $allupdates{$table}{$obj}{$row}{'tabattrs'}{$attr}; } else { @@ -1287,20 +1338,20 @@ my $tt = $invalidattr->{$att}->{valid}; } } - } #end foreach my $row - # only uses the setAttribs to set attribute one by one when the obj type is NOT 'node' + } #end foreach my $row + # only uses the setAttribs to set attribute one by one when the obj type is NOT 'node' if (%updates) { $commit_manually = 1; my ($rc, $str) = $thistable->setAttribs(\%keyhash, \%updates); } - } #end foreach my $obj + } #end foreach my $obj if ($commit_manually) { $thistable->commit; } if (%node_updates) { $thistable->setNodesAttribs(\%node_updates); } - } #end forach my $table + } #end forach my $table } return $ret; } @@ -1349,7 +1400,7 @@ sub rmobjdefs my $thistable = xCAT::Table->new('site', -create => 1, -autocommit => 0); my %keyhash; - foreach my $attr (keys %{$DBattrvals{$objname}}) { + foreach my $attr (keys %{ $DBattrvals{$objname} }) { # ex. key = attr $keyhash{key} = $attr; @@ -1367,7 +1418,7 @@ sub rmobjdefs # go through the list of valid attrs # - need to delete the row with a $key value of $objname from $table # - make a hash containing $delhash{$table}{$key}= $objname - foreach my $this_attr (@{$datatype->{'attrs'}}) { + foreach my $this_attr (@{ $datatype->{'attrs'} }) { my $attr = $this_attr->{attr_name}; # get table lookup info from Schema.pm @@ -1378,7 +1429,7 @@ sub rmobjdefs if ($rc != 0) { my $rsp; $rsp->{data}->[0] = - "access_tabentry \'$this_attr->{access_tabentry}\' is not valid."; +"access_tabentry \'$this_attr->{access_tabentry}\' is not valid."; xCAT::MsgUtils->message("E", $rsp, $::callback); next; } @@ -1386,64 +1437,67 @@ sub rmobjdefs # Only allow one table in the access_tabentry # use multiple tables to look up tabentry does not make any sense my $lookup_table = $tabentry{'lookup_table'}; + # The attr_name is the *def attribute name instead of db column my $attr_name = $this_attr->{'attr_name'}; + # we'll need table name, object name, attribute name and the lookup entries # put this info in a hash - we'll process it later - below - foreach my $lookup_attr (keys %{$tabentry{'lookup_attrs'}}) { + foreach my $lookup_attr (keys %{ $tabentry{'lookup_attrs'} }) { $tablehash{$lookup_table}{$objname}{$attr_name}{$lookup_attr} - = $tabentry{'lookup_attrs'}{$lookup_attr}; + = $tabentry{'lookup_attrs'}{$lookup_attr}; } } } -#=============================================# -# The tablehash looks like this - # DB<5> x %tablehash - # 'bootparams' - # HASH(0x1280828c) - # 'node1' => HASH(0x127bca50) - # 'addkcmdline' => HASH(0x127fb114) - # 'node' => 'node1' - # 'initrd' => HASH(0x127bcb40) - # 'node' => 'node1' - # 'kcmdline' => HASH(0x127fb24c) - # 'node' => 'node1' - # 'kernel' => HASH(0x127b2e80) - # 'node' => 'node1' - # 'testfsp' => HASH(0x1280e71c) - # 'addkcmdline' => HASH(0x1280e7a0) - # 'node' => 'testfsp' - # 'initrd' => HASH(0x1280e740) - # 'node' => 'testfsp' - # 'kcmdline' => HASH(0x1280e77c) - # 'node' => 'testfsp' - # 'kernel' => HASH(0x1280e758) - # 'node' => 'testfsp' - #... - # 'ppcdirect' - # HASH(0x1278fe1c) - # 'node1' => HASH(0x12808370) - # 'passwd.HMC' => HASH(0x128083e8) - # 'hcp' => 'node1' - # 'username' => 'HMC' - # 'passwd.admin' => HASH(0x128081c0) - # 'hcp' => 'node1' - # 'username' => 'admin' - # 'passwd.general' => HASH(0x128075d8) - # 'hcp' => 'node1' - # 'username' => 'general' - # 'testfsp' => HASH(0x12790620) - # 'passwd.HMC' => HASH(0x1280ee84) - # 'hcp' => 'testfsp' - # 'username' => 'HMC' - # 'passwd.admin' => HASH(0x128082f8) - # 'hcp' => 'testfsp' - # 'username' => 'admin' - # 'passwd.general' => HASH(0x1280843c) - # 'hcp' => 'testfsp' - # 'username' => 'general' - #... + + #=============================================# + # The tablehash looks like this + # DB<5> x %tablehash + # 'bootparams' + # HASH(0x1280828c) + # 'node1' => HASH(0x127bca50) + # 'addkcmdline' => HASH(0x127fb114) + # 'node' => 'node1' + # 'initrd' => HASH(0x127bcb40) + # 'node' => 'node1' + # 'kcmdline' => HASH(0x127fb24c) + # 'node' => 'node1' + # 'kernel' => HASH(0x127b2e80) + # 'node' => 'node1' + # 'testfsp' => HASH(0x1280e71c) + # 'addkcmdline' => HASH(0x1280e7a0) + # 'node' => 'testfsp' + # 'initrd' => HASH(0x1280e740) + # 'node' => 'testfsp' + # 'kcmdline' => HASH(0x1280e77c) + # 'node' => 'testfsp' + # 'kernel' => HASH(0x1280e758) + # 'node' => 'testfsp' + #... + # 'ppcdirect' + # HASH(0x1278fe1c) + # 'node1' => HASH(0x12808370) + # 'passwd.HMC' => HASH(0x128083e8) + # 'hcp' => 'node1' + # 'username' => 'HMC' + # 'passwd.admin' => HASH(0x128081c0) + # 'hcp' => 'node1' + # 'username' => 'admin' + # 'passwd.general' => HASH(0x128075d8) + # 'hcp' => 'node1' + # 'username' => 'general' + # 'testfsp' => HASH(0x12790620) + # 'passwd.HMC' => HASH(0x1280ee84) + # 'hcp' => 'testfsp' + # 'username' => 'HMC' + # 'passwd.admin' => HASH(0x128082f8) + # 'hcp' => 'testfsp' + # 'username' => 'admin' + # 'passwd.general' => HASH(0x1280843c) + # 'hcp' => 'testfsp' + # 'username' => 'general' + #... ##=========================================================# # now for each table - clear the entry foreach my $table (keys %tablehash) { @@ -1452,27 +1506,31 @@ sub rmobjdefs my $thistable = xCAT::Table->new($table, -create => 1, -autocommit => 0); - foreach my $obj (keys %{$tablehash{$table}}) { + foreach my $obj (keys %{ $tablehash{$table} }) { my %keyhash; - foreach my $attr (keys %{$tablehash{$table}{$obj}}) { - foreach my $key (keys %{$tablehash{$table}{$obj}{$attr}}) { + foreach my $attr (keys %{ $tablehash{$table}{$obj} }) { + foreach my $key (keys %{ $tablehash{$table}{$obj}{$attr} }) { #multiple keys support if (defined($keyhash{$key}) && ($keyhash{$key} ne $tablehash{$table}{$obj}{$attr}{$key})) { my %tmpkeyhash; + # copy hash foreach my $hashkey (keys %keyhash) { $tmpkeyhash{$hashkey} = $keyhash{$hashkey}; } push @all_keyhash, \%tmpkeyhash; + #$thistable->delEntries(\@all_keyhash); } + # ex. $keyhash{node}=c68m3hvp01 $keyhash{$key} = $tablehash{$table}{$obj}{$attr}{$key}; } } push @all_keyhash, \%keyhash; } + # ex. delete the c68m3hvp01 entry of the node column in the # nodelist table $thistable->delEntries(\@all_keyhash); @@ -1578,8 +1636,8 @@ sub readFileInput my $val = $2; $attr =~ s/^\s*//; # Remove any leading whitespace $attr =~ s/\s*$//; # Remove any trailing whitespace - $val =~ s/^\s*//; - $val =~ s/\s*$//; + $val =~ s/^\s*//; + $val =~ s/\s*$//; # remove spaces and quotes so createnode won't get upset $val =~ s/^\s*"\s*//; @@ -1604,7 +1662,7 @@ sub readFileInput push(@::fileobjtypes, $val); # $val will be the object type ex. site, node etc. - foreach my $a (keys %{$::defAttrs{$val}}) { + foreach my $a (keys %{ $::defAttrs{$val} }) { # set the default values for this object hash $::FILEATTRS{$objectname}{$a} = $::defAttrs{$val}{$a}; @@ -1662,7 +1720,7 @@ sub getGroupMembers # set 'static' as the dafault of nodetype if (!defined($objhash{$objectname}{'grouptype'}) || - $objhash{$objectname}{'grouptype'} eq "") { + $objhash{$objectname}{'grouptype'} eq "") { $objhash{$objectname}{'grouptype'} = 'static'; } @@ -1769,21 +1827,21 @@ sub getGroupMembers sub getNetwkInfo { my ($class, $ref_nodes) = @_; - my @nodelist = @$ref_nodes; + my @nodelist = @$ref_nodes; my %nethash; my @attrnames; # get the current list of network attrs (networks table columns) my $datatype = $xCAT::Schema::defspec{'network'}; - foreach my $a (@{$datatype->{'attrs'}}) { + foreach my $a (@{ $datatype->{'attrs'} }) { my $attr = $a->{attr_name}; push(@attrnames, $attr); } # read the networks table my @TableRowArray = xCAT::DBobjUtils->getDBtable('networks'); - if (! @TableRowArray) { + if (!@TableRowArray) { return undef; } @@ -1802,34 +1860,38 @@ sub getNetwkInfo # - if the bitwise AND of the IP and the netmask gives you # the "net" name then that is the entry you want. foreach (@TableRowArray) { - my $NM = $_->{'mask'}; - my $net=$_->{'net'}; + my $NM = $_->{'mask'}; + my $net = $_->{'net'}; chomp $NM; chomp $net; - if(xCAT::NetworkUtils->ishostinsubnet($IP, $NM, $net)) { + if (xCAT::NetworkUtils->ishostinsubnet($IP, $NM, $net)) { + # fill in the hash - foreach my $attr (@attrnames) { - if ( defined($_->{$attr}) ) { + if (defined($_->{$attr})) { $nethash{$node}{$attr} = $_->{$attr}; } } - if($nethash{$node}{'gateway'} eq '') { - if(xCAT::NetworkUtils->ip_forwarding_enabled()) { + if ($nethash{$node}{'gateway'} eq '') { + if (xCAT::NetworkUtils->ip_forwarding_enabled()) { $nethash{$node}{'gateway'} = xCAT::NetworkUtils->my_ip_in_subnet($net, $NM); } else { $nethash{$node}{'gateway'} = ''; } $nethash{$node}{'myselfgw'} = 1; + # For hwctrl commands, it is possible that this subroutine is called # on MN instead of SN, if the hcp SN is not set if (xCAT::Utils->isMN() && !$nethash{$node}{'gateway'}) { + # does not have ip address in this subnet, # use the node attribute 'xcatmaster' or site.master my @nodes = ("$node"); - my $sn = xCAT::ServiceNodeUtils->get_ServiceNode(\@nodes,"xcat","Node"); + my $sn = xCAT::ServiceNodeUtils->get_ServiceNode(\@nodes, "xcat", "Node"); my $snkey = (keys %{$sn})[0]; - my $gw = xCAT::NetworkUtils->getipaddr($snkey); + my $gw = xCAT::NetworkUtils->getipaddr($snkey); + # two possible cases when this code is run: # 1. flat cluster: ip forwarding is not enabled on MN # 2. hw ctrl in hierarchy cluster, in which HCP SN is not set @@ -1845,10 +1907,11 @@ sub getNetwkInfo } - } #end - for each node + } #end - for each node return %nethash; } + #---------------------------------------------------------------------------- =head3 parse_access_tabentry @@ -1891,6 +1954,7 @@ sub parse_access_tabentry() # ex. 'nodelist.node', 'attr:node' foreach my $ent (split('::', $access_tabentry)) { + # ex. 'nodelist.node', 'attr:node' my ($lookup_key, $lookup_value) = split('\=', $ent); @@ -1910,12 +1974,13 @@ sub parse_access_tabentry() if ($lookup_table ne $tabentry_ref->{'lookup_table'}) { my $rsp; $rsp->{data}->[0] = - "The access_tabentry \"$access_tabentry\" is not valid, can not specify more than one tables to look up."; +"The access_tabentry \"$access_tabentry\" is not valid, can not specify more than one tables to look up."; xCAT::MsgUtils->message("E", $rsp, $::callback); return 1; } if ($lookup_type eq 'attr') { + # TODO: may need to update in the future # for now, the "val" in attr:val in # Schema.pm can only be the object name @@ -1928,13 +1993,14 @@ sub parse_access_tabentry() } else { my $rsp; $rsp->{data}->[0] = - "The access_tabentry \"$access_tabentry\" is not valid, the lookup type can only be 'attr' or 'str'."; +"The access_tabentry \"$access_tabentry\" is not valid, the lookup type can only be 'attr' or 'str'."; xCAT::MsgUtils->message("E", $rsp, $::callback); return 1; } } return 0; } + #------------------------------------------------------------------------------- =head3 getchildren @@ -1960,6 +2026,7 @@ sub parse_access_tabentry() #------------------------------------------------------------------------------- my %PPCHASH; + sub getchildren { my $parent = shift; @@ -1967,65 +2034,69 @@ sub getchildren $parent = shift; } $::RUNCMD_RC = 0; - my $port = shift; - my @tabletype = qw(ppc zvm); - my @children = (); + my $port = shift; + my @tabletype = qw(ppc zvm); + my @children = (); my @children_port = (); if (!%PPCHASH) { - my $ppctab = xCAT::Table->new( 'ppc' ); - unless ($ppctab) { # cannot open the table return with error + my $ppctab = xCAT::Table->new('ppc'); + unless ($ppctab) { # cannot open the table return with error xCAT::MsgUtils->message('S', "getchildren:Unable to open ppc table.\n"); $::RUNCMD_RC = 1; return undef; } - my @ps = $ppctab->getAllNodeAttribs(['node','parent','nodetype','hcp']); - foreach my $entry ( @ps ) { + my @ps = $ppctab->getAllNodeAttribs([ 'node', 'parent', 'nodetype', 'hcp' ]); + foreach my $entry (@ps) { my $p = $entry->{parent}; my $c = $entry->{node}; my $t = $entry->{nodetype}; - if ( $p and $c) { - if ($t) { # the nodetype exists in the ppc table, use it - if ( $t eq 'fsp' or $t eq 'bpa') { + if ($p and $c) { + if ($t) { # the nodetype exists in the ppc table, use it + if ($t eq 'fsp' or $t eq 'bpa') { + # build hash of ppc.parent -> ppc.node - push @{$PPCHASH{$p}}, $c; + push @{ $PPCHASH{$p} }, $c; } elsif ($t eq 'blade') { - push @{$PPCHASH{$c}}, $entry->{hcp}; + push @{ $PPCHASH{$c} }, $entry->{hcp}; } - } else { # go look in the nodetype table to find nodetype + } else { # go look in the nodetype table to find nodetype my $type = getnodetype($c, "ppc"); - if ( $type eq 'fsp' or $type eq 'bpa') { + if ($type eq 'fsp' or $type eq 'bpa') { + # build hash of ppc.parent -> ppc.node - push @{$PPCHASH{$p}}, $c; + push @{ $PPCHASH{$p} }, $c; } elsif ($type eq "blade") { - push @{$PPCHASH{$c}}, $entry->{hcp}; + push @{ $PPCHASH{$c} }, $entry->{hcp}; } } - } # not $p and $c + } # not $p and $c } + # Find parent in the hash and build return values - foreach (@{$PPCHASH{$parent}}) { + foreach (@{ $PPCHASH{$parent} }) { push @children, $_; } } else { if (exists($PPCHASH{$parent})) { - foreach (@{$PPCHASH{$parent}}) { + foreach (@{ $PPCHASH{$parent} }) { push @children, $_; } } } + # if port not input - if ( !defined($port )) { + if (!defined($port)) { return \@children; } else { if (@children) { - my $vpdtab = xCAT::Table->new( 'vpd' ); - unless ($vpdtab) { # cannot open the table return with error + my $vpdtab = xCAT::Table->new('vpd'); + unless ($vpdtab) { # cannot open the table return with error xCAT::MsgUtils->message('S', "getchildren:Unable to open vpd table.\n"); $::RUNCMD_RC = 1; return undef; } my $sides = $vpdtab->getNodesAttribs(\@children, ['side']); - if(!$sides) { + if (!$sides) { return undef; } foreach my $n (@children) { @@ -2035,11 +2106,12 @@ sub getchildren } } return \@children_port; - } else { # no children + } else { # no children return undef; } } } + #------------------------------------------------------------------------------- =head3 getnodetype @@ -2067,6 +2139,7 @@ sub getchildren #------------------------------------------------------------------------------- my %NODETYPEHASH; + sub getnodetype { my $nodes = shift; @@ -2087,11 +2160,11 @@ sub getnodetype # if can't get anything from the specified table, go to nodetype table ###################################################################### if ($table) { - my $nodetypetab = xCAT::Table->new( $table ); + my $nodetypetab = xCAT::Table->new($table); unless ($nodetypetab) { xCAT::MsgUtils->message('S', "getnodetype:Unable to open $table table.\n"); $::RUNCMD_RC = 1; - if ( $nodes =~ /^ARRAY/) { + if ($nodes =~ /^ARRAY/) { foreach my $tn (@$nodes) { $typehash{$tn} = undef; } @@ -2104,13 +2177,13 @@ sub getnodetype # if the input node arg is an array, # query table and don't use the global hash ############################################ - if ( $nodes =~ /^ARRAY/) { + if ($nodes =~ /^ARRAY/) { my $nodetypes = $nodetypetab->getNodesAttribs($nodes, ['nodetype']); foreach my $tn (@$nodes) { my $gottype = $nodetypes->{$tn}->[0]->{'nodetype'}; - if ( $gottype ) { + if ($gottype) { $NODETYPEHASH{$tn} = $gottype; - $typehash{$tn} = $gottype; + $typehash{$tn} = $gottype; } else { push @failnodes, $tn; } @@ -2118,9 +2191,9 @@ sub getnodetype ################################################ # for the failed nodes, go to nodetype table ################################################ - if ( @failnodes ) { - my $typetable = xCAT::Table->new( 'nodetype' ); - unless ($typetable) { # cannot open the table return with error + if (@failnodes) { + my $typetable = xCAT::Table->new('nodetype'); + unless ($typetable) { # cannot open the table return with error xCAT::MsgUtils->message('S', "getnodetype:Unable to open nodetype table.\n"); $::RUNCMD_RC = 1; foreach my $tn (@failnodes) { @@ -2128,8 +2201,8 @@ sub getnodetype } } else { my $nodetypes = $nodetypetab->getNodesAttribs(\@failnodes, ['nodetype']); - foreach my $tn ( @failnodes ) { - if ( $nodetypes->{$tn}->[0] ) { + foreach my $tn (@failnodes) { + if ($nodetypes->{$tn}->[0]) { $NODETYPEHASH{$tn} = $nodetypes->{$tn}->[0]->{'nodetype'}; $typehash{$tn} = $nodetypes->{$tn}->[0]->{'nodetype'}; } else { @@ -2140,8 +2213,8 @@ sub getnodetype # give error msg for the nodes can't get nodetype ################################################## } - if ( @failnodes1 ) { - my $nodelist = join(",", @failnodes1); + if (@failnodes1) { + my $nodelist = join(",", @failnodes1); xCAT::MsgUtils->message('S', "getnodetype:Can't find these nodes' type: $nodelist.\n"); } } @@ -2152,28 +2225,28 @@ sub getnodetype return \%typehash; } else { - ############################################ - # if the input node arg is not an array, - # query table and use the global hash first - ############################################ - if ( $NODETYPEHASH{$nodes} ) { + ############################################ + # if the input node arg is not an array, + # query table and use the global hash first + ############################################ + if ($NODETYPEHASH{$nodes}) { return $NODETYPEHASH{$nodes}; } else { my $typep = $nodetypetab->getNodeAttribs($nodes, ['nodetype']); - if ( $typep->{nodetype} ) { + if ($typep->{nodetype}) { $NODETYPEHASH{$nodes} = $typep->{nodetype}; return $typep->{nodetype}; } else { #if not find in the specified table, go to nodetype table - my $typetable = xCAT::Table->new( 'nodetype' ); - unless ($typetable) { # cannot open the table return with error + my $typetable = xCAT::Table->new('nodetype'); + unless ($typetable) { # cannot open the table return with error xCAT::MsgUtils->message('S', "getnodetype:Unable to open nodetype table.\n"); $::RUNCMD_RC = 1; return undef; } - my $typep = $typetable->getNodeAttribs($nodes, ['nodetype']); - if ( $typep->{nodetype} ) { + my $typep = $typetable->getNodeAttribs($nodes, ['nodetype']); + if ($typep->{nodetype}) { $NODETYPEHASH{$nodes} = $typep->{nodetype}; - return $typep->{nodetype}; + return $typep->{nodetype}; } else { return undef; } @@ -2181,15 +2254,15 @@ sub getnodetype } } } else { - ###################################################################### - # if the table arg is not set, go to the nodetype table first - # if can't get anything from the specified table, go to nodetype table - ###################################################################### - my $nodetypetab = xCAT::Table->new( 'nodetype' ); + ###################################################################### + # if the table arg is not set, go to the nodetype table first + # if can't get anything from the specified table, go to nodetype table + ###################################################################### + my $nodetypetab = xCAT::Table->new('nodetype'); unless ($nodetypetab) { xCAT::MsgUtils->message('S', "getnodetype:Unable to open $table table.\n"); $::RUNCMD_RC = 1; - if ( $nodes =~ /^ARRAY/) { + if ($nodes =~ /^ARRAY/) { foreach my $tn (@$nodes) { $typehash{$tn} = undef; } @@ -2202,33 +2275,33 @@ sub getnodetype # if the input node arg is an array, # query table and don't use the global hash ############################################ - if ( $nodes =~ /^ARRAY/) { + if ($nodes =~ /^ARRAY/) { my $nodetypes = $nodetypetab->getNodesAttribs($nodes, ['nodetype']); foreach my $tn (@$nodes) { my $gottype = $nodetypes->{$tn}->[0]->{'nodetype'}; - if ( $gottype) { - if ($gottype =~ /,/) { #if find ppc,osi + if ($gottype) { + if ($gottype =~ /,/) { #if find ppc,osi my @tbty = split /,/, $gottype; - foreach my $ttable (@tbty){ - if (grep(/$ttable/, @tabletype)){ - $tablehash{ $tn } = $ttable; - last; + foreach my $ttable (@tbty) { + if (grep(/$ttable/, @tabletype)) { + $tablehash{$tn} = $ttable; + last; } } - } elsif (grep(/$gottype/, @tabletype)){ #if find ppc or zvm - $tablehash{ $tn } = $gottype; + } elsif (grep(/$gottype/, @tabletype)) { #if find ppc or zvm + $tablehash{$tn} = $gottype; } else { - $NODETYPEHASH{ $tn } = $gottype; - $typehash{ $tn } = $gottype; + $NODETYPEHASH{$tn} = $gottype; + $typehash{$tn} = $gottype; } } else { - $typehash{ $tn } = undef; + $typehash{$tn} = undef; } } ################################################ # for the failed nodes, go to related tables ################################################ - if ( %tablehash ) { + if (%tablehash) { foreach my $ttable (@tabletype) { my @nodegroup; foreach my $fnode (keys %tablehash) { @@ -2237,7 +2310,7 @@ sub getnodetype } } next unless (@nodegroup); - my $typetable = xCAT::Table->new( $ttable); + my $typetable = xCAT::Table->new($ttable); unless ($typetable) { my $failnodes = join(",", @nodegroup); xCAT::MsgUtils->message('S', "getnodetype:Unable to open $ttable table, can't find $failnodes type.\n"); @@ -2246,9 +2319,9 @@ sub getnodetype $typehash{$_} = undef; } } else { - my $typep = $typetable->getNodesAttribs(\@nodegroup, ['nodetype']); + my $typep = $typetable->getNodesAttribs(\@nodegroup, ['nodetype']); foreach my $fn (@nodegroup) { - if ( $typep->{$fn}->[0]->{'nodetype'} ) { + if ($typep->{$fn}->[0]->{'nodetype'}) { $typehash{$fn} = $typep->{$fn}->[0]->{'nodetype'}; $NODETYPEHASH{$fn} = $typep->{$fn}->[0]->{'nodetype'}; } else { @@ -2259,23 +2332,23 @@ sub getnodetype } } return \%typehash; - } else { # if not an array - if ( $NODETYPEHASH{$nodes} ) { + } else { # if not an array + if ($NODETYPEHASH{$nodes}) { return $NODETYPEHASH{$nodes}; } else { my $typep = $nodetypetab->getNodeAttribs($nodes, ["nodetype"]); - if ( $typep->{nodetype} and !(grep(/$typep->{nodetype}/, @tabletype))) { + if ($typep->{nodetype} and !(grep(/$typep->{nodetype}/, @tabletype))) { $NODETYPEHASH{$nodes} = $typep->{nodetype}; return $typep->{nodetype}; - } elsif ( grep(/$typep->{nodetype}/, @tabletype) ) { - my $typetable = xCAT::Table->new( $typep->{nodetype} ); + } elsif (grep(/$typep->{nodetype}/, @tabletype)) { + my $typetable = xCAT::Table->new($typep->{nodetype}); unless ($typetable) { xCAT::MsgUtils->message('S', "getnodetype:Unable to open nodetype table.\n"); $::RUNCMD_RC = 1; return undef; } my $typep = $typetable->getNodeAttribs($nodes, ["nodetype"]); - if ( $typep->{nodetype} ) { + if ($typep->{nodetype}) { $NODETYPEHASH{$nodes} = $typep->{nodetype}; return $typep->{nodetype}; } else { @@ -2286,6 +2359,7 @@ sub getnodetype } } } + #------------------------------------------------------------------------------- =head3 getcecchildren @@ -2306,6 +2380,7 @@ sub getnodetype #------------------------------------------------------------------------------- my %PARENT_CHILDREN_CEC; + sub getcecchildren { my $parent = shift; @@ -2314,41 +2389,43 @@ sub getcecchildren } my @children = (); if (!%PARENT_CHILDREN_CEC) { - my $ppctab = xCAT::Table->new( 'ppc' ); - unless ($ppctab) { # cannot open the table return with error + my $ppctab = xCAT::Table->new('ppc'); + unless ($ppctab) { # cannot open the table return with error xCAT::MsgUtils->message('S', "getcecchildren:Unable to open ppc table.\n"); $::RUNCMD_RC = 1; return undef; } if ($ppctab) { - my @ps = $ppctab->getAllNodeAttribs(['node','parent','nodetype']); - foreach my $entry ( @ps ) { + my @ps = $ppctab->getAllNodeAttribs([ 'node', 'parent', 'nodetype' ]); + foreach my $entry (@ps) { my $p = $entry->{parent}; my $c = $entry->{node}; my $t = $entry->{nodetype}; - if ( $p and $c) { - if ($t) { # the nodetype exists in the ppc table, use it - if ( $t eq 'cec') { + if ($p and $c) { + if ($t) { # the nodetype exists in the ppc table, use it + if ($t eq 'cec') { + # build hash of ppc.parent -> ppc.node - push @{$PARENT_CHILDREN_CEC{$p}}, $c; + push @{ $PARENT_CHILDREN_CEC{$p} }, $c; } - } else { # go look in the nodetype table to find nodetype + } else { # go look in the nodetype table to find nodetype my $type = getnodetype($c); - if ( $type eq 'cec') { - push @{$PARENT_CHILDREN_CEC{$p}}, $c; + if ($type eq 'cec') { + push @{ $PARENT_CHILDREN_CEC{$p} }, $c; } } } } + # find a match for the parent and build the return array - foreach (@{$PARENT_CHILDREN_CEC{$parent}}) { + foreach (@{ $PARENT_CHILDREN_CEC{$parent} }) { push @children, $_; } return \@children; } - } else { # already built the HASH + } else { # already built the HASH if (exists($PARENT_CHILDREN_CEC{$parent})) { - foreach (@{$PARENT_CHILDREN_CEC{$parent}}) { + foreach (@{ $PARENT_CHILDREN_CEC{$parent} }) { push @children, $_; } return \@children; @@ -2356,6 +2433,7 @@ sub getcecchildren } return undef; } + #------------------------------------------------------------------------------- =head3 judge_node @@ -2385,8 +2463,8 @@ sub judge_node my $flag = 0; my $parenttype; my $nodeparent; - my $ppctab = xCAT::Table->new( 'ppc' ); - if ( $ppctab ) { + my $ppctab = xCAT::Table->new('ppc'); + if ($ppctab) { $nodeparent = $ppctab->getNodeAttribs($node, ["parent"]); if ($nodeparent and $nodeparent->{parent}) { $parenttype = getnodetype($nodeparent->{parent}); @@ -2456,22 +2534,22 @@ sub expandnicsattr() my $nicattr = $1; # Value: eth0!1.1.1.1|2.1.1.1,eth1!3.1.1.1|4.1.1.1 - my $nicval=$2; + my $nicval = $2; #if there is regrex in nicips if (($nicval) && ($nicval =~ /^\|(.*?)\|$/)) { - + #$nicval Value: |node(d+)|eth0!192.1.1.($1+10)| or # |eth0!192.1.1.($1+10),bond0!10.28.41.($1+10)| #In the lsdef, remove the ^| and |$ before displaying - $nicval=~s/(^\||\|$)//g; - + $nicval =~ s/(^\||\|$)//g; + #$nicval Value: node(d+)|eth0!192.1.1.($1+10) if (($nicval) && ($nicval =~ /\|/)) { - my ($str1,$str2)=split('\|', $nicval); - + my ($str1, $str2) = split('\|', $nicval); + #$nivval Value: eth0!192.1.1.($1+10) - $nicval=$str2; + $nicval = $str2; } } @@ -2480,6 +2558,7 @@ sub expandnicsattr() my @nicarr = split(/,/, $nicval); foreach my $nicentry (@nicarr) { + #nicentry: eth0!1.1.1.1|2.1.1.1 # $nicv[0]: eth0 # $nicv[1]: 1.1.1.1|2.1.1.1 @@ -2489,6 +2568,7 @@ sub expandnicsattr() if ($nicnames) { my @nics = split(/,/, $nicnames); if ($nicv[0]) { + # Do not need to return the nic attr for this nic if (!grep(/^$nicv[0]$/, @nics)) { next; @@ -2551,11 +2631,13 @@ sub collapsenicsattr() my %nicattrs = (); foreach my $nodeattr (keys %{$nodeattrhash}) { + # e.g nicips.eth0 # do not need to handle nic attributes without the postfix .ethx, # it will be overwritten by the attributes with the postfix .ethx, if ($nodeattr =~ /^(nic\w+)\.(.*)$/) { if ($1 && $2) { + # chdef nicips.eth2= to remove the definition for eth2 # in this case, the $nodeattrhash->{'nicips.eth0'} is blank # $nicattrs{nicips}{eth0} = "1.1.1.1|1.2.1.1" @@ -2566,16 +2648,19 @@ sub collapsenicsattr() } } } + # $nicattrs{'nicips'}{'eth0'} = "1.1.1.1|1.2.1.1" # $nicattrs{'nicips'}{'eth1'} = "2.1.1.1|2.2.1.1" foreach my $nicattr (keys %nicattrs) { my @tmparray = (); - foreach my $nicname (keys %{$nicattrs{$nicattr}}) { + foreach my $nicname (keys %{ $nicattrs{$nicattr} }) { + # eth0!1.1.1.1|1.2.1.1 - if($nicattrs{$nicattr}{$nicname}){ + if ($nicattrs{$nicattr}{$nicname}) { push @tmparray, "$nicname!$nicattrs{$nicattr}{$nicname}"; } } + # eth0!1.1.1.1|1.2.1.1,eth1!2.1.1.1|2.2.1.1 $nodeattrhash->{$nicattr} = join(',', @tmparray); } diff --git a/perl-xCAT/xCAT/DSHCLI.pm b/perl-xCAT/xCAT/DSHCLI.pm index 8dc10874b..a0b5788c9 100644 --- a/perl-xCAT/xCAT/DSHCLI.pm +++ b/perl-xCAT/xCAT/DSHCLI.pm @@ -2,6 +2,7 @@ # IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html package xCAT::DSHCLI; + BEGIN { $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; @@ -39,18 +40,18 @@ $::CONTEXT_DIR = "/opt/xcat/xdsh/Context/"; $::__DCP_DELIM = 'Xcat,DELIMITER,Xcat'; our @dsh_valid_env = ( - 'DCP_NODE_OPTS', 'DCP_NODE_RCP', - 'DSH_ENVIRONMENT', 'DSH_FANOUT', - 'DSH_LOG', 'DSH_NODEGROUP_PATH', - 'DSH_NODE_LIST', 'DSH_NODE_OPTS', - 'DSH_NODE_RCP', 'DSH_NODE_RSH', - 'DSH_OUTPUT', 'DSH_PATH', - 'DSH_SYNTAX', 'DSH_TIMEOUT', - 'DSH_REMOTE_PASSWORD', 'DSH_TO_USERID', - 'DSH_FROM_USERID', 'DEVICETYPE', - 'RSYNCSN', 'DSH_RSYNC_FILE', - 'RSYNCSNONLY', - ); + 'DCP_NODE_OPTS', 'DCP_NODE_RCP', + 'DSH_ENVIRONMENT', 'DSH_FANOUT', + 'DSH_LOG', 'DSH_NODEGROUP_PATH', + 'DSH_NODE_LIST', 'DSH_NODE_OPTS', + 'DSH_NODE_RCP', 'DSH_NODE_RSH', + 'DSH_OUTPUT', 'DSH_PATH', + 'DSH_SYNTAX', 'DSH_TIMEOUT', + 'DSH_REMOTE_PASSWORD', 'DSH_TO_USERID', + 'DSH_FROM_USERID', 'DEVICETYPE', + 'RSYNCSN', 'DSH_RSYNC_FILE', + 'RSYNCSNONLY', +); select(STDERR); $| = 1; select(STDOUT); @@ -101,7 +102,7 @@ sub execute_dcp my %unresolved_targets = (); my %context_targets = (); xCAT::DSHCLI->resolve_targets($options, \%resolved_targets, - \%unresolved_targets, \%context_targets); + \%unresolved_targets, \%context_targets); if (!scalar(%resolved_targets)) { @@ -147,11 +148,11 @@ sub execute_dcp !$$options{'silent'} && push @error_files, *STDERR; xCAT::DSHCLI->fork_fanout_dcp( - $options, \%resolved_targets, - \%forked_process, \%pid_targets, - \%outfh_targets, \%errfh_targets, - \@targets_waiting, \%targets_active - ); + $options, \%resolved_targets, + \%forked_process, \%pid_targets, + \%outfh_targets, \%errfh_targets, + \@targets_waiting, \%targets_active + ); while (keys(%targets_active)) { @@ -165,7 +166,7 @@ sub execute_dcp my @active_list = keys(%targets_active); my $rsp = {}; $rsp->{error}->[0] = - " Timed out waiting for response from child processes for the following nodes."; +" Timed out waiting for response from child processes for the following nodes."; $rsp->{error}->[1] = " @active_list"; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); kill 'INT', keys(%pid_targets); @@ -178,26 +179,26 @@ sub execute_dcp (@select_out_fhs) && xCAT::DSHCLI->buffer_output( - $options, \%resolved_targets, \%targets_active, - \@targets_finished, \@targets_failed, \%targets_buffered, - \%pid_targets, \%forked_process, \%outfh_targets, - \%output_buffers, \%error_buffers, \@output_files, - \@error_files, \@select_out_fhs - ); + $options, \%resolved_targets, \%targets_active, + \@targets_finished, \@targets_failed, \%targets_buffered, + \%pid_targets, \%forked_process, \%outfh_targets, + \%output_buffers, \%error_buffers, \@output_files, + \@error_files, \@select_out_fhs + ); my @select_err_fhs = xCAT::DSHCLI->util_bit_indexes($rout & $errfh_targets{'bitmap'}, 1); (@select_err_fhs) && xCAT::DSHCLI->buffer_error( - $options, \%resolved_targets, - \%targets_active, \@targets_finished, - \@targets_failed, \%targets_buffered, - \%pid_targets, \%forked_process, - \%errfh_targets, \%output_buffers, - \%error_buffers, \@output_files, - \@error_files, \@select_err_fhs - ); + $options, \%resolved_targets, + \%targets_active, \@targets_finished, + \@targets_failed, \%targets_buffered, + \%pid_targets, \%forked_process, + \%errfh_targets, \%output_buffers, + \%error_buffers, \@output_files, + \@error_files, \@select_err_fhs + ); my @targets_buffered_keys = sort keys(%targets_buffered); @@ -210,13 +211,13 @@ sub execute_dcp if ($::DCP_API) { $::DCP_API_MESSAGE .= - join("", @{$output_buffers{$user_target}}) - . join("", @{$error_buffers{$user_target}}); + join("", @{ $output_buffers{$user_target} }) + . join("", @{ $error_buffers{$user_target} }); } else { - print STDOUT @{$output_buffers{$user_target}}; - print STDERR @{$error_buffers{$user_target}}; + print STDOUT @{ $output_buffers{$user_target} }; + print STDERR @{ $error_buffers{$user_target} }; } } @@ -224,65 +225,65 @@ sub execute_dcp delete $error_buffers{$user_target}; my $exit_code = $targets_buffered{$user_target}{'exit-code'}; - + if ($exit_code != 0) { # report error status --nodestatus # Note the message below for node status must - # not be NLS translated. Code depends on the English. + # not be NLS translated. Code depends on the English. if ($$options{'nodestatus'}) { - my $rsp={}; - $rsp->{data}->[0] = - "$user_target: Remote_command_failed, error_code=$exit_code"; - xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); + my $rsp = {}; + $rsp->{data}->[0] = +"$user_target: Remote_command_failed, error_code=$exit_code"; + xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); } push @targets_failed, $user_target; - push @{$dsh_target_status{'failed'}}, $user_target; + push @{ $dsh_target_status{'failed'} }, $user_target; } else { # Note the message below for node status must - # not be NLS translated. Code depends on the English. + # not be NLS translated. Code depends on the English. if ($$options{'nodestatus'}) { - my $rsp={}; - $rsp->{data}->[0] = - "$user_target: Remote_command_successful"; - xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); + my $rsp = {}; + $rsp->{data}->[0] = + "$user_target: Remote_command_successful"; + xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); } push @targets_finished, $user_target; } - + # return list of badnodes and goodnodes if ($$options{'monitor'}) { - foreach my $badnode (@targets_failed) { - my $rsp={}; - $rsp->{data}->[0] = - "dsh> Remote_command_failed $badnode"; - xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); - } - foreach my $goodnode (@targets_finished) { - my $rsp={}; - $rsp->{data}->[0] = - "dsh> Remote_command_successful $goodnode"; - xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); - } + foreach my $badnode (@targets_failed) { + my $rsp = {}; + $rsp->{data}->[0] = + "dsh> Remote_command_failed $badnode"; + xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); + } + foreach my $goodnode (@targets_finished) { + my $rsp = {}; + $rsp->{data}->[0] = + "dsh> Remote_command_successful $goodnode"; + xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); + } } delete $targets_buffered{$user_target}; } (@targets_waiting) && xCAT::DSHCLI->fork_fanout_dcp( - $options, \%resolved_targets, \%forked_process, - \%pid_targets, \%outfh_targets, \%errfh_targets, - \@targets_waiting, \%targets_active - ); + $options, \%resolved_targets, \%forked_process, + \%pid_targets, \%outfh_targets, \%errfh_targets, + \@targets_waiting, \%targets_active + ); } if (scalar(@targets_failed) > 0) { - #$::DCP_NODES_FAILED = join ",", @targets_failed; - @::DCP_NODES_FAILED = @targets_failed; + #$::DCP_NODES_FAILED = join ",", @targets_failed; + @::DCP_NODES_FAILED = @targets_failed; } return (scalar(@targets_failed) + scalar(keys(%unresolved_targets))); @@ -345,7 +346,7 @@ sub execute_dsh $dsh_unresolved_targets = \%unresolved_targets; my %context_targets = (); xCAT::DSHCLI->resolve_targets($options, \%resolved_targets, - \%unresolved_targets, \%context_targets); + \%unresolved_targets, \%context_targets); my @canceled_targets = (); $dsh_target_status{'canceled'} = \@canceled_targets; my $rsp = {}; @@ -395,11 +396,11 @@ sub execute_dsh $dsh_target_status{'failed'} = \@targets_failed; @targets_failed = xCAT::DSHCLI->_execute_dsh($options, \%resolved_targets, - \%unresolved_targets, \%context_targets); + \%unresolved_targets, \%context_targets); if (scalar(@targets_failed) > 0) { - # $::DSH_NODES_FAILED = join ",", @targets_failed; - @::DSH_NODES_FAILED = @targets_failed; + # $::DSH_NODES_FAILED = join ",", @targets_failed; + @::DSH_NODES_FAILED = @targets_failed; } return (scalar(@targets_failed) + scalar(keys(%unresolved_targets))); @@ -473,11 +474,11 @@ sub _execute_dsh $dsh_exec_state++; xCAT::DSHCLI->fork_fanout_dsh( - $options, $resolved_targets, - \%forked_process, \%pid_targets, - \%outfh_targets, \%errfh_targets, - \@targets_waiting, \%targets_active - ); + $options, $resolved_targets, + \%forked_process, \%pid_targets, + \%outfh_targets, \%errfh_targets, + \@targets_waiting, \%targets_active + ); while (keys(%targets_active)) { @@ -490,9 +491,9 @@ sub _execute_dsh if ($fh_count == 0) { my @active_list = keys(%targets_active); - my $rsp = {}; + my $rsp = {}; $rsp->{error}->[0] = - " Timed out waiting for response from child processes for the following nodes. Terminating the child processes. "; +" Timed out waiting for response from child processes for the following nodes. Terminating the child processes. "; $rsp->{error}->[1] = " @active_list"; xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); @targets_failed = keys(%targets_active); @@ -511,22 +512,22 @@ sub _execute_dsh if ($$options{'streaming'}) { xCAT::DSHCLI->stream_output( - $options, $resolved_targets, \%targets_active, - \@targets_finished, \@targets_failed, \%pid_targets, - \%forked_process, \%outfh_targets, \%output_buffers, - \@output_files, \@select_out_fhs - ); + $options, $resolved_targets, \%targets_active, + \@targets_finished, \@targets_failed, \%pid_targets, + \%forked_process, \%outfh_targets, \%output_buffers, + \@output_files, \@select_out_fhs + ); } else { xCAT::DSHCLI->buffer_output( - $options, $resolved_targets, \%targets_active, - \@targets_finished, \@targets_failed, \%targets_buffered, - \%pid_targets, \%forked_process, \%outfh_targets, - \%output_buffers, \%error_buffers, \@output_files, - \@error_files, \@select_out_fhs - ); + $options, $resolved_targets, \%targets_active, + \@targets_finished, \@targets_failed, \%targets_buffered, + \%pid_targets, \%forked_process, \%outfh_targets, + \%output_buffers, \%error_buffers, \@output_files, + \@error_files, \@select_out_fhs + ); } } @@ -538,24 +539,25 @@ sub _execute_dsh if ($$options{'streaming'}) { xCAT::DSHCLI->stream_error( - $options, $resolved_targets, \%targets_active, - \@targets_finished, \@targets_failed, \%pid_targets, - \%forked_process, \%errfh_targets, \%error_buffers, - \@error_files, \@select_err_fhs - ); + $options, $resolved_targets, \%targets_active, + \@targets_finished, \@targets_failed, \%pid_targets, + \%forked_process, \%errfh_targets, \%error_buffers, + \@error_files, \@select_err_fhs + ); } else { xCAT::DSHCLI->buffer_error( - $options, $resolved_targets, \%targets_active, - \@targets_finished, \@targets_failed, \%targets_buffered, - \%pid_targets, \%forked_process, \%errfh_targets, - \%output_buffers, \%error_buffers, \@output_files, - \@error_files, \@select_err_fhs - ); + $options, $resolved_targets, \%targets_active, + \@targets_finished, \@targets_failed, \%targets_buffered, + \%pid_targets, \%forked_process, \%errfh_targets, + \%output_buffers, \%error_buffers, \@output_files, + \@error_files, \@select_err_fhs + ); } } + # This is only if you are not streaming ( -s) my @targets_buffered_keys = sort keys(%targets_buffered); @@ -573,24 +575,24 @@ sub _execute_dsh if ($::DSH_API) { $::DSH_API_MESSAGE = - $::DSH_API_MESSAGE - . join("", @{$output_buffers{$user_target}}) - . join("", @{$error_buffers{$user_target}}); + $::DSH_API_MESSAGE + . join("", @{ $output_buffers{$user_target} }) + . join("", @{ $error_buffers{$user_target} }); } else { # HERE: This is where the output shows up #print STDOUT @{$output_buffers{$user_target}}; #print STDERR @{$error_buffers{$user_target}}; - chomp(@{$output_buffers{$user_target}}); - chomp(@{$error_buffers{$user_target}}); + chomp(@{ $output_buffers{$user_target} }); + chomp(@{ $error_buffers{$user_target} }); my $rsp = {}; - push @{$rsp->{data}}, @{$output_buffers{$user_target}}; + push @{ $rsp->{data} }, @{ $output_buffers{$user_target} }; xCAT::MsgUtils->message("D", $rsp, $::CALLBACK); $rsp = {}; - push @{$rsp->{error}}, @{$error_buffers{$user_target}}; + push @{ $rsp->{error} }, @{ $error_buffers{$user_target} }; $rsp->{NoErrorPrefix} = 1; - xCAT::MsgUtils->message("E", $rsp, $::CALLBACK,0); + xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 0); } } @@ -606,14 +608,15 @@ sub _execute_dsh { # Note the message below for node status must - # not be NLS translated. Code depends on the English. + # not be NLS translated. Code depends on the English. # report error status --nodestatus if ($$options{'nodestatus'}) { - my $rsp={}; - $rsp->{data}->[0] = - "$user_target: Remote_command_failed, error_code=$exit_code"; - xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); + my $rsp = {}; + $rsp->{data}->[0] = +"$user_target: Remote_command_failed, error_code=$exit_code"; + xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); } + # for monitoring -m my $rsp = {}; $rsp->{error}->[0] = "dsh> Remote_command_failed $user_target"; @@ -624,7 +627,7 @@ sub _execute_dsh push @targets_failed, $user_target; } - push @{$dsh_target_status{'failed'}}, $user_target + push @{ $dsh_target_status{'failed'} }, $user_target if !$signal_interrupt_flag; } @@ -633,42 +636,43 @@ sub _execute_dsh { if ($target_rc != 0) { - # Note the message below for node status must - # not be NLS translated. Code depends on the English. - # report error status --nodestatus - if ($$options{'nodestatus'}) { - my $rsp={}; - $rsp->{data}->[0] = - "$user_target: Remote_command_failed, error_code=$target_rc"; - xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); - } + # Note the message below for node status must + # not be NLS translated. Code depends on the English. + # report error status --nodestatus + if ($$options{'nodestatus'}) { + my $rsp = {}; + $rsp->{data}->[0] = +"$user_target: Remote_command_failed, error_code=$target_rc"; + xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); + } + # if monitoring - $rsp={}; + $rsp = {}; $rsp->{data}->[0] = "dsh> Remote_command_failed $user_target"; $$options{'monitor'} && xCAT::MsgUtils->message("I", $rsp, $::CALLBACK, 1); push @targets_failed, $user_target; - push @{$dsh_target_status{'failed'}}, $user_target + push @{ $dsh_target_status{'failed'} }, $user_target if !$signal_interrupt_flag; } - elsif (!defined($target_rc) && !$dsh_cmd_background && ($::DSH_MELLANOX_SWITCH==0) && ($$options{'devicetype'}!~ /EthSwitch/)) + elsif (!defined($target_rc) && !$dsh_cmd_background && ($::DSH_MELLANOX_SWITCH == 0) && ($$options{'devicetype'} !~ /EthSwitch/)) { - # report error status --nodestatus - # Note the message below for node status must - # not be NLS translated. Code depends on the English. - if ($$options{'nodestatus'}) { - my $rsp={}; - $rsp->{data}->[0] = - "$user_target: Remote_command_failed, error_code=???"; - xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); - } + # report error status --nodestatus + # Note the message below for node status must + # not be NLS translated. Code depends on the English. + if ($$options{'nodestatus'}) { + my $rsp = {}; + $rsp->{data}->[0] = + "$user_target: Remote_command_failed, error_code=???"; + xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); + } - $rsp={}; + $rsp = {}; $rsp->{error}->[0] = - " A return code for the command run on the host $user_target was not received."; +" A return code for the command run on the host $user_target was not received."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); my $rsp = {}; @@ -678,21 +682,21 @@ sub _execute_dsh && xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); push @targets_failed, $user_target; - push @{$dsh_target_status{'failed'}}, $user_target + push @{ $dsh_target_status{'failed'} }, $user_target if !$signal_interrupt_flag; } - else # it worked + else # it worked { - # Note the message below for node status must - # not be NLS translated. Code depends on the English. - if ($$options{'nodestatus'}) { - my $rsp={}; - $rsp->{data}->[0] = - "$user_target: Remote_command_successful"; - xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); + # Note the message below for node status must + # not be NLS translated. Code depends on the English. + if ($$options{'nodestatus'}) { + my $rsp = {}; + $rsp->{data}->[0] = + "$user_target: Remote_command_successful"; + xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); } - $rsp={}; + $rsp = {}; $rsp->{data}->[0] = "dsh> Remote_command_successful $user_target"; $$options{'monitor'} @@ -707,10 +711,10 @@ sub _execute_dsh (@targets_waiting) && xCAT::DSHCLI->fork_fanout_dsh( - $options, $resolved_targets, \%forked_process, - \%pid_targets, \%outfh_targets, \%errfh_targets, - \@targets_waiting, \%targets_active - ); + $options, $resolved_targets, \%forked_process, + \%pid_targets, \%outfh_targets, \%errfh_targets, + \@targets_waiting, \%targets_active + ); } @@ -724,7 +728,7 @@ sub _execute_dsh && ($dsh_stats{'successful-targets'} = \@targets_finished); if (scalar(@targets_failed)) { - if (scalar(@{$dsh_target_status{'failed'}})) + if (scalar(@{ $dsh_target_status{'failed'} })) { $dsh_stats{'failed-targets'} = $dsh_target_status{'failed'}; } @@ -733,7 +737,7 @@ sub _execute_dsh $dsh_stats{'failed-targets'} = \@targets_failed; } } - scalar(@{$dsh_target_status{'canceled'}}) + scalar(@{ $dsh_target_status{'canceled'} }) && ($dsh_stats{'canceled-targets'} = $dsh_target_status{'canceled'}); } my $rsp = {}; @@ -790,7 +794,7 @@ sub fork_fanout_dcp = @_; while (@$targets_waiting - && (keys(%$targets_active) < $$options{'fanout'})) + && (keys(%$targets_active) < $$options{'fanout'})) { my $user_target = shift @$targets_waiting; my $target_properties = $$resolved_targets{$user_target}; @@ -798,7 +802,7 @@ sub fork_fanout_dcp my @dcp_command; my $rsyncfile; - if (!$$target_properties{'localhost'}) # this is to a remote host + if (!$$target_properties{'localhost'}) # this is to a remote host { my $target_type = $$target_properties{'type'}; @@ -810,17 +814,17 @@ sub fork_fanout_dcp if ($target_type eq 'node') { $remote_copy = - $$options{'node-rcp'}{$$target_properties{'context'}} + $$options{'node-rcp'}{ $$target_properties{'context'} } || $$target_properties{'remote-copy'}; ($remote_copy =~ /\/scp$/) && ($rsh_extension = 'SSH'); ($remote_copy =~ /\/rsync$/) && ($rsh_extension = 'RSYNC'); $rcp_config{'options'} = - $$options{'node-options'}{$$target_properties{'context'}}; + $$options{'node-options'}{ $$target_properties{'context'} }; } $rcp_config{'preserve'} = $$options{'preserve'}; $rcp_config{'recursive'} = $$options{'recursive'}; - $rcp_config{'sudo'} = $$options{'sudo'}; + $rcp_config{'sudo'} = $$options{'sudo'}; if ($$options{'pull'}) { @@ -831,7 +835,7 @@ sub fork_fanout_dcp my @target_file = split '/', $$options{'source'}; $rcp_config{'dest-file'} = - "$$options{'target'}/$target_file[$#target_file]._$$target_properties{'hostname'}"; +"$$options{'target'}/$target_file[$#target_file]._$$target_properties{'hostname'}"; } @@ -849,63 +853,66 @@ sub fork_fanout_dcp #eval "require RemoteShell::$rsh_extension"; eval "require xCAT::$rsh_extension"; my $remoteshell = "xCAT::$rsh_extension"; + # HERE: Build the dcp command based on the arguments - my $localhost=0; # this is from the MN to another node + my $localhost = 0; # this is from the MN to another node @dcp_command = $remoteshell->remote_copy_command(\%rcp_config, $remote_copy); + # add sudo for non-root users if ($$options{'sudo'}) { - unshift (@dcp_command,'sudo'); + unshift(@dcp_command, 'sudo'); } } - else # this is the local host ( running on the Management Node) + else # this is the local host ( running on the Management Node) { if ($$options{'destDir_srcFile'}{$user_target}) { - my $target_type = $$target_properties{'type'}; + my $target_type = $$target_properties{'type'}; - my %rcp_config = (); + my %rcp_config = (); - my $remote_copy; - my $rsh_extension = 'RSH'; + my $remote_copy; + my $rsh_extension = 'RSH'; - if ($target_type eq 'node') - { - $remote_copy = - $$options{'node-rcp'}{$$target_properties{'context'}} - || $$target_properties{'remote-copy'}; - ($remote_copy =~ /\/scp$/) && ($rsh_extension = 'SSH'); - ($remote_copy =~ /\/rsync$/) && ($rsh_extension = 'RSYNC'); - $rcp_config{'options'} = - $$options{'node-options'}{$$target_properties{'context'}}; - } + if ($target_type eq 'node') + { + $remote_copy = + $$options{'node-rcp'}{ $$target_properties{'context'} } + || $$target_properties{'remote-copy'}; + ($remote_copy =~ /\/scp$/) && ($rsh_extension = 'SSH'); + ($remote_copy =~ /\/rsync$/) && ($rsh_extension = 'RSYNC'); + $rcp_config{'options'} = + $$options{'node-options'}{ $$target_properties{'context'} }; + } - $rcp_config{'preserve'} = $$options{'preserve'}; - $rcp_config{'recursive'} = $$options{'recursive'}; + $rcp_config{'preserve'} = $$options{'preserve'}; + $rcp_config{'recursive'} = $$options{'recursive'}; - $rcp_config{'src-file'} = $$options{'source'}; - $rcp_config{'dest-host'} = $$target_properties{'hostname'}; - $rcp_config{'dest-file'} = $$options{'target'}; - $rcp_config{'dest-user'} = $$target_properties{'user'} + $rcp_config{'src-file'} = $$options{'source'}; + $rcp_config{'dest-host'} = $$target_properties{'hostname'}; + $rcp_config{'dest-file'} = $$options{'target'}; + $rcp_config{'dest-user'} = $$target_properties{'user'} || $$options{'user'}; - $rcp_config{'destDir_srcFile'} = + $rcp_config{'destDir_srcFile'} = $$options{'destDir_srcFile'}{$user_target}; - eval "require xCAT::$rsh_extension"; - my $remoteshell = "xCAT::$rsh_extension"; - # HERE: Build the dcp command based on the arguments - my $localhost=1; # this is on the MN to the MN - @dcp_command = - $remoteshell->remote_copy_command(\%rcp_config, $remote_copy,$localhost); - - } - else # just a copy not a sync - { + eval "require xCAT::$rsh_extension"; + my $remoteshell = "xCAT::$rsh_extension"; + + # HERE: Build the dcp command based on the arguments + my $localhost = 1; # this is on the MN to the MN + @dcp_command = + $remoteshell->remote_copy_command(\%rcp_config, $remote_copy, $localhost); + + } + else # just a copy not a sync + { @dcp_command = ('/bin/cp', '-r', $$options{'source'}, $$options{'target'}); - } + } } my $rsp = {}; @@ -917,12 +924,12 @@ sub fork_fanout_dcp xCAT::DSHCore->fork_output($user_target, @dcp_command); vec($$outfh_targets{'bitmap'}, fileno($process_info[1]), 1) = 1; vec($$errfh_targets{'bitmap'}, fileno($process_info[2]), 1) = 1; - $$outfh_targets{fileno($process_info[1])} = $user_target; - $$errfh_targets{fileno($process_info[2])} = $user_target; + $$outfh_targets{ fileno($process_info[1]) } = $user_target; + $$errfh_targets{ fileno($process_info[2]) } = $user_target; $$forked_process{$user_target} = \@process_info; $$targets_active{$user_target}++; - $$pid_targets{$process_info[0]} = $user_target; + $$pid_targets{ $process_info[0] } = $user_target; } } @@ -977,73 +984,77 @@ sub fork_fanout_dsh if (@$targets_waiting > 0) { if ($ENV{'DSH_REMOTE_PASSWORD'}) { foreach my $t (keys(%$resolved_targets)) { - $resolved_targets->{$t}->{'password'}=$ENV{'DSH_REMOTE_PASSWORD'}; - $resolved_targets->{$t}->{'user'}=$$options{'user'}; + $resolved_targets->{$t}->{'password'} = $ENV{'DSH_REMOTE_PASSWORD'}; + $resolved_targets->{$t}->{'user'} = $$options{'user'}; } } else { + #get user name and password from the switches table - my $passwdtab=xCAT::Table->new('passwd',-create=>1); - my @passwd_ent = $passwdtab->getAttribs({key => "switch"}, ['username', 'password', 'comments']); - my $switchestab=xCAT::Table->new('switches',-create=>0); - my $switchents = $switchestab->getNodesAttribs($targets_waiting,[qw/switch sshusername sshpassword protocol/]); - foreach my $entry (values %$switchents) { - my $switch=$entry->[0]->{switch}; - my $username; - my $password; + my $passwdtab = xCAT::Table->new('passwd', -create => 1); + my @passwd_ent = $passwdtab->getAttribs({ key => "switch" }, [ 'username', 'password', 'comments' ]); + my $switchestab = xCAT::Table->new('switches', -create => 0); + my $switchents = $switchestab->getNodesAttribs($targets_waiting, [qw/switch sshusername sshpassword protocol/]); + foreach my $entry (values %$switchents) { + my $switch = $entry->[0]->{switch}; + my $username; + my $password; my $protocol; - + # use switches table first - if (defined($entry->[0]->{sshusername})) { - $username = $entry->[0]->{sshusername}; + if (defined($entry->[0]->{sshusername})) { + $username = $entry->[0]->{sshusername}; } - if (defined($entry->[0]->{sshpassword})) { - $password = $entry->[0]->{sshpassword}; - } - if (defined($entry->[0]->{protocol})) { - $protocol = $entry->[0]->{protocol}; - } - if ((!$username) && (!$password) && (!$protocol)) { #use passwd table as default - if (defined($passwd_ent[0]->{username})) { - $username=$passwd_ent[0]->{username}; + if (defined($entry->[0]->{sshpassword})) { + $password = $entry->[0]->{sshpassword}; + } + if (defined($entry->[0]->{protocol})) { + $protocol = $entry->[0]->{protocol}; + } + if ((!$username) && (!$password) && (!$protocol)) { #use passwd table as default + if (defined($passwd_ent[0]->{username})) { + $username = $passwd_ent[0]->{username}; } - if (defined($passwd_ent[0]->{password})) { - $password = $passwd_ent[0]->{password}; - } - if (defined($passwd_ent[0]->{comments}) && ($passwd_ent[0]->{comments} eq "telnet")) { - $protocol = $passwd_ent[0]->{comments}; - } - } - - if ($username) { - $resolved_targets->{$switch}->{'user'} = $username; - } - if ($password) { - $resolved_targets->{$switch}->{'password'} = $password; - } - if ($protocol) { - $resolved_targets->{$switch}->{'remotecmdproto'} = $protocol; - } - #print "username=$username, password=$password, protocol=$protocol\n"; - } + if (defined($passwd_ent[0]->{password})) { + $password = $passwd_ent[0]->{password}; + } + if (defined($passwd_ent[0]->{comments}) && ($passwd_ent[0]->{comments} eq "telnet")) { + $protocol = $passwd_ent[0]->{comments}; + } + } + + if ($username) { + $resolved_targets->{$switch}->{'user'} = $username; + } + if ($password) { + $resolved_targets->{$switch}->{'password'} = $password; + } + if ($protocol) { + $resolved_targets->{$switch}->{'remotecmdproto'} = $protocol; + } + + #print "username=$username, password=$password, protocol=$protocol\n"; + } } } } + # save the original exports, we are going to add the unique node name below - my $firstpass=0; + my $firstpass = 0; while (@$targets_waiting - && (keys(%$targets_active) < $$options{'fanout'})) + && (keys(%$targets_active) < $$options{'fanout'})) { - my $user_target = shift @$targets_waiting; + my $user_target = shift @$targets_waiting; + # now add export NODE=nodename to the pre-command, if not a device; my $exportnode; if (($$options{'devicetype'})) { - $exportnode=""; - } else{ - $exportnode="export NODE=$user_target; "; + $exportnode = ""; + } else { + $exportnode = "export NODE=$user_target; "; } my $target_properties = $$resolved_targets{$user_target}; my @commands; - my $localShell = + my $localShell = ($$options{'syntax'} eq 'csh') ? '/bin/csh' : '/bin/sh'; my @dsh_command = ($localShell, '-c'); $$options{'command'} =~ s/\s*$//; @@ -1056,40 +1067,41 @@ sub fork_fanout_dsh } if ($$options{'environment'}) { - if ($firstpass ==0) { # do the servicenode stuff only once - # if we are on a servicenode need to get the environment file - # from the SNsyncfiledir, not local - if (xCAT::Utils->isServiceNode()) { - my $newenvfile; - my $synfiledir = "/var/xcat/syncfiles"; #default + if ($firstpass == 0) { # do the servicenode stuff only once + # if we are on a servicenode need to get the environment file + # from the SNsyncfiledir, not local + if (xCAT::Utils->isServiceNode()) { + my $newenvfile; + my $synfiledir = "/var/xcat/syncfiles"; #default - # get the directory on the servicenode to and add to filepath - my @syndir= xCAT::TableUtils->get_site_attribute("SNsyncfiledir"); - if ($syndir[0]) - { - $synfiledir = $syndir[0]; - } - $newenvfile = $synfiledir; - $newenvfile .= $$options{'environment'}; - $$options{'environment'} = $newenvfile; + # get the directory on the servicenode to and add to filepath + my @syndir = xCAT::TableUtils->get_site_attribute("SNsyncfiledir"); + if ($syndir[0]) + { + $synfiledir = $syndir[0]; + } + $newenvfile = $synfiledir; + $newenvfile .= $$options{'environment'}; + $$options{'environment'} = $newenvfile; + } + if (!(-e $$options{'environment'})) + { + my $rsp = {}; + $rsp->{error}->[0] = "File $$options{'environment'} does not exist"; + xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); + } + $firstpass = 1; } - if (!(-e $$options{'environment'})) - { - my $rsp={}; - $rsp->{error}->[0] = "File $$options{'environment'} does not exist"; - xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); - } - $firstpass=1; - } - # build the xdsh command - push @dsh_command, - "$exportnode$$options{'pre-command'} . $$options{'environment'} ; $$options{'command'}$$options{'post-command'}"; + + # build the xdsh command + push @dsh_command, +"$exportnode$$options{'pre-command'} . $$options{'environment'} ; $$options{'command'}$$options{'post-command'}"; } else { push @dsh_command, - "$exportnode$$options{'pre-command'}$$options{'command'}$$options{'post-command'}"; +"$exportnode$$options{'pre-command'}$$options{'command'}$$options{'post-command'}"; } if ($$target_properties{'localhost'}) @@ -1122,22 +1134,22 @@ sub fork_fanout_dsh if ($target_type eq 'node') { my $context = $$target_properties{'context'}; - $remote_shell = $$options{'node-rsh'}{$context} + $remote_shell = $$options{'node-rsh'}{$context} || $$options{'node-rsh'}{'none'} || $$target_properties{'remote-shell'} || $$options{'node-rsh-defaults'}{$context}; ($remote_shell =~ /\/ssh$/) && ($rsh_extension = 'SSH'); if ($$options{'devicetype'} =~ /EthSwitch/) { - $remote_shell = "$::XCATROOT/sbin/rshell_api"; - $rsh_extension='RShellAPI'; - $rsh_config{'password'}=$$target_properties{'password'}; - if ($$target_properties{'remotecmdproto'}) { - $rsh_config{'remotecmdproto'}=$$target_properties{'remotecmdproto'}; - } - if ($$options{'trace'}) { - $rsh_config{'trace'}=1; - } + $remote_shell = "$::XCATROOT/sbin/rshell_api"; + $rsh_extension = 'RShellAPI'; + $rsh_config{'password'} = $$target_properties{'password'}; + if ($$target_properties{'remotecmdproto'}) { + $rsh_config{'remotecmdproto'} = $$target_properties{'remotecmdproto'}; + } + if ($$options{'trace'}) { + $rsh_config{'trace'} = 1; + } } # will not set -n for any command, causing problems @@ -1146,7 +1158,7 @@ sub fork_fanout_dsh #if (($$options{'devicetype'})) { $rsh_config{'options'} = - $$options{'node-options'}{$$target_properties{'context'}}; + $$options{'node-options'}{ $$target_properties{'context'} }; #} else { # not a device # $rsh_config{'options'} = "-n " @@ -1159,11 +1171,12 @@ sub fork_fanout_dsh $rsh_config{'command'} = "$exportnode$$options{'pre-command'}"; my $tmp_env_file; + # for the -E flag here we build and copy the -E env variable # file to the nodes if ($$options{'environment'}) { - + my $rsp = {}; $rsp->{data}->[0] = "TRACE: Environment option specified"; $dsh_trace && (xCAT::MsgUtils->message("I", $rsp, $::CALLBACK)); @@ -1193,7 +1206,7 @@ sub fork_fanout_dsh #eval "require RemoteShell::$env_rcp_extension"; eval "require xCAT::$env_rcp_extension"; - my $rcp = "xCAT::$env_rcp_extension"; + my $rcp = "xCAT::$env_rcp_extension"; my @env_rcp_command = $rcp->remote_copy_command(\%env_rcp_config); @@ -1201,31 +1214,34 @@ sub fork_fanout_dsh $rsp->{data}->[0] = "TRACE:Environment: Exporting File.@env_rcp_command "; $dsh_trace && (xCAT::MsgUtils->message("I", $rsp, $::CALLBACK)); + # copy the Env Variable input file to the nodes my @env_rcp_process = xCAT::DSHCore->fork_no_output($user_target, @env_rcp_command); waitpid($env_rcp_process[0], undef); + #push @commands, \@env_rcp_command; } my $tmp_cmd_file; if ($$options{'execute'}) { # first build the scp command to copy the file to execute - # down to the node into /tmp/*.dsh + # down to the node into /tmp/*.dsh my $rsp = {}; $rsp->{data}->[0] = "TRACE: Execute option specified."; $dsh_trace && (xCAT::MsgUtils->message("I", $rsp, $::CALLBACK)); my %exe_rcp_config = (); - $tmp_cmd_file = POSIX::tmpnam . ".dsh"; + $tmp_cmd_file = POSIX::tmpnam . ".dsh"; - my ($exe_cmd, @args) = @{$$options{'execute'}}; + my ($exe_cmd, @args) = @{ $$options{'execute'} }; my $chmod_cmd = ""; + # now build the xdsh of the file buffer # add sudo for non-root users if ($$options{'sudo'}) { - $rsh_config{'command'} .= "sudo "; - $rsh_config{'sudo'} = "sudo "; + $rsh_config{'command'} .= "sudo "; + $rsh_config{'sudo'} = "sudo "; } $rsh_config{'command'} .= "$chmod_cmd $tmp_cmd_file @args$$options{'post-command'}"; @@ -1251,7 +1267,7 @@ sub fork_fanout_dsh #eval "require RemoteShell::$exe_rcp_extension"; eval "require xCAT::$exe_rcp_extension"; - my $rcp = "xCAT::$exe_rcp_extension"; + my $rcp = "xCAT::$exe_rcp_extension"; my @exe_rcp_command = $rcp->remote_copy_command(\%exe_rcp_config); @@ -1259,6 +1275,7 @@ sub fork_fanout_dsh $rsp->{data}->[0] = "TRACE:Execute: Exporting File:@exe_rcp_command"; $dsh_trace && (xCAT::MsgUtils->message("I", $rsp, $::CALLBACK)); + #my @exe_rcp_process = # xCAT::DSHCore->fork_no_output($user_target, @exe_rcp_command); #waitpid($exe_rcp_process[0], undef); @@ -1268,10 +1285,10 @@ sub fork_fanout_dsh else { # add sudo for non-root users - if ($$options{'sudo'}) { - $rsh_config{'command'} .= "sudo "; - $rsh_config{'sudo'} = "sudo "; - } + if ($$options{'sudo'}) { + $rsh_config{'command'} .= "sudo "; + $rsh_config{'sudo'} = "sudo "; + } $rsh_config{'command'} .= "$$options{'command'}$$options{'post-command'}"; } @@ -1281,7 +1298,7 @@ sub fork_fanout_dsh } if ($$options{'execute'}) { - $rsh_config{'command'} .= ";rm $tmp_cmd_file"; + $rsh_config{'command'} .= ";rm $tmp_cmd_file"; } #eval "require RemoteShell::$rsh_extension"; @@ -1301,19 +1318,19 @@ sub fork_fanout_dsh my $rsp = {}; $rsp->{data}->[0] = "dsh> Remote_command_started $user_target"; $$options{'monitor'} && xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); - + # execute and remove the /tmp file build which is a copy of the # input -E file #print "Command=@dsh_command\n"; #@process_info = xCAT::DSHCore->fork_output($user_target, @dsh_command); - push (@commands, \@dsh_command); #print Dumper(\@commands); - @process_info = xCAT::DSHCore->fork_output_for_commands($user_target, @commands); + push(@commands, \@dsh_command); #print Dumper(\@commands); + @process_info = xCAT::DSHCore->fork_output_for_commands($user_target, @commands); if ($process_info[0] == -2) { my $rsp = {}; $rsp->{error}->[0] = - "$user_target could not execute this command $dsh_command[0] - $$options{'command'} , $! "; +"$user_target could not execute this command $dsh_command[0] - $$options{'command'} , $! "; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); } @@ -1337,12 +1354,12 @@ sub fork_fanout_dsh vec($$outfh_targets{'bitmap'}, fileno($process_info[1]), 1) = 1; vec($$errfh_targets{'bitmap'}, fileno($process_info[2]), 1) = 1; - $$outfh_targets{fileno($process_info[1])} = $user_target; - $$errfh_targets{fileno($process_info[2])} = $user_target; + $$outfh_targets{ fileno($process_info[1]) } = $user_target; + $$errfh_targets{ fileno($process_info[2]) } = $user_target; $$forked_process{$user_target} = \@process_info; $$targets_active{$user_target}++; - $$pid_targets{$process_info[0]} = $user_target; + $$pid_targets{ $process_info[0] } = $user_target; } } @@ -1420,11 +1437,11 @@ sub buffer_output my $eof_output = xCAT::DSHCore->pipe_handler_buffer( - $target_properties, $output_fh, 4096, - "$user_target: ", - $$output_buffers{"${user_target}_tmp"}, - $$output_buffers{$user_target} - ); + $target_properties, $output_fh, 4096, + "$user_target: ", + $$output_buffers{"${user_target}_tmp"}, + $$output_buffers{$user_target} + ); if ($eof_output) { @@ -1447,26 +1464,26 @@ sub buffer_output { # check return code $exit_code = $? >> 8; } - if (scalar(@{$$output_buffers{$user_target}}) == 1) + if (scalar(@{ $$output_buffers{$user_target} }) == 1) { ($$output_buffers{$user_target}[0] eq '') - && (@{$$output_buffers{$user_target}} = ()); + && (@{ $$output_buffers{$user_target} } = ()); } - if (scalar(@{$$error_buffers{$user_target}}) == 1) + if (scalar(@{ $$error_buffers{$user_target} }) == 1) { ($$error_buffers{$user_target}[0] eq '') - && (@{$$error_buffers{$user_target}} = ()); + && (@{ $$error_buffers{$user_target} } = ()); } my %exit_status = ( - 'exit-code' => $exit_code, - 'target-rc' => $$target_properties{'target-rc'} - ); + 'exit-code' => $exit_code, + 'target-rc' => $$target_properties{'target-rc'} + ); $$targets_buffered{$user_target} = \%exit_status; delete $$targets_active{$user_target}; - delete $$pid_targets{$$forked_process{$user_target}[0]}; + delete $$pid_targets{ $$forked_process{$user_target}[0] }; close $output_fh; close $error_fh; @@ -1549,11 +1566,11 @@ sub buffer_error my $eof_error = xCAT::DSHCore->pipe_handler_buffer( - $target_properties, $error_fh, 4096, - "$user_target: ", - $$error_buffers{"${user_target}_tmp"}, - $$error_buffers{$user_target} - ); + $target_properties, $error_fh, 4096, + "$user_target: ", + $$error_buffers{"${user_target}_tmp"}, + $$error_buffers{$user_target} + ); if ($eof_error) { @@ -1576,26 +1593,26 @@ sub buffer_error $exit_code = $? >> 8; } - if (scalar(@{$$output_buffers{$user_target}}) == 1) + if (scalar(@{ $$output_buffers{$user_target} }) == 1) { ($$output_buffers{$user_target}[0] eq '') - && (@{$$output_buffers{$user_target}} = ()); + && (@{ $$output_buffers{$user_target} } = ()); } - if (scalar(@{$$error_buffers{$user_target}}) == 1) + if (scalar(@{ $$error_buffers{$user_target} }) == 1) { ($$error_buffers{$user_target}[0] eq '') - && (@{$$error_buffers{$user_target}} = ()); + && (@{ $$error_buffers{$user_target} } = ()); } my %exit_status = ( - 'exit-code' => $exit_code, - 'target-rc' => $$target_properties{'target-rc'} - ); + 'exit-code' => $exit_code, + 'target-rc' => $$target_properties{'target-rc'} + ); $$targets_buffered{$user_target} = \%exit_status; delete $$targets_active{$user_target}; - delete $$pid_targets{$$forked_process{$user_target}[0]}; + delete $$pid_targets{ $$forked_process{$user_target}[0] }; close $output_fh; close $error_fh; @@ -1668,14 +1685,14 @@ sub stream_output my $eof_output = xCAT::DSHCore->pipe_handler( - $options, - $target_properties, - $output_fh, - 4096, - "$user_target: ", - $$output_buffers{$user_target}, - @$output_files - ); + $options, + $target_properties, + $output_fh, + 4096, + "$user_target: ", + $$output_buffers{$user_target}, + @$output_files + ); if ($eof_output) { @@ -1704,12 +1721,12 @@ sub stream_output { # report error status --nodestatus # Note the message below for node status must - # not be NLS translated. Code depends on the English. + # not be NLS translated. Code depends on the English. if ($$options{'nodestatus'}) { - my $rsp={}; - $rsp->{data}->[0] = - "$user_target: Remote_command_failed, error_code=$exit_code"; - xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); + my $rsp = {}; + $rsp->{data}->[0] = +"$user_target: Remote_command_failed, error_code=$exit_code"; + xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); } my $rsp = {}; $rsp->{error}->[0] = @@ -1724,7 +1741,7 @@ sub stream_output && xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); push @$targets_failed, $user_target; - push @{$dsh_target_status{'failed'}}, $user_target + push @{ $dsh_target_status{'failed'} }, $user_target if !$signal_interrupt_flag; } @@ -1733,19 +1750,19 @@ sub stream_output { if ($target_rc != 0) { - # report error status --nodestatus - # Note the message below for node status must - # not be NLS translated. Code depends on the English. - if ($$options{'nodestatus'}) { - my $rsp={}; - $rsp->{data}->[0] = - "$user_target: Remote_command_failed, error_code=$$target_properties{'target-rc'}"; - xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); - } + # report error status --nodestatus + # Note the message below for node status must + # not be NLS translated. Code depends on the English. + if ($$options{'nodestatus'}) { + my $rsp = {}; + $rsp->{data}->[0] = +"$user_target: Remote_command_failed, error_code=$$target_properties{'target-rc'}"; + xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); + } my $rsp = {}; $rsp->{error}->[0] = - " $user_target remote Command had return code: $$target_properties{'target-rc'} "; +" $user_target remote Command had return code: $$target_properties{'target-rc'} "; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); my $rsp = {}; @@ -1759,20 +1776,20 @@ sub stream_output elsif (!defined($target_rc)) { - # report error status --nodestatus - # Note the message below for node status must - # not be NLS translated. Code depends on the English. - if ($$options{'nodestatus'}) { - my $rsp={}; - $rsp->{data}->[0] = - "$user_target: Remote_command_failed, error_code=???"; - xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); - } + # report error status --nodestatus + # Note the message below for node status must + # not be NLS translated. Code depends on the English. + if ($$options{'nodestatus'}) { + my $rsp = {}; + $rsp->{data}->[0] = +"$user_target: Remote_command_failed, error_code=???"; + xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); + } my $rsp = {}; $rsp->{error}->[0] = - " $user_target a return code run on this host was not received. "; +" $user_target a return code run on this host was not received. "; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); my $rsp = {}; @@ -1784,17 +1801,17 @@ sub stream_output push @$targets_failed, $user_target; } - else # xdsh -s worked + else # xdsh -s worked { - # report error status --nodestatus - # Note the message below for node status must - # not be NLS translated. Code depends on the English. - if ($$options{'nodestatus'}) { - my $rsp={}; - $rsp->{data}->[0] = - "$user_target: Remote_command_successful"; - xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); - } + # report error status --nodestatus + # Note the message below for node status must + # not be NLS translated. Code depends on the English. + if ($$options{'nodestatus'}) { + my $rsp = {}; + $rsp->{data}->[0] = + "$user_target: Remote_command_successful"; + xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); + } my $rsp = {}; @@ -1808,7 +1825,7 @@ sub stream_output } delete $$targets_active{$user_target}; - delete $$pid_targets{$$forked_process{$user_target}[0]}; + delete $$pid_targets{ $$forked_process{$user_target}[0] }; } close $output_fh; @@ -1880,14 +1897,14 @@ sub stream_error my $eof_error = xCAT::DSHCore->pipe_handler( - $options, - $target_properties, - $error_fh, - 4096, - "$user_target: ", - $$error_buffers{$user_target}, - @$error_files - ); + $options, + $target_properties, + $error_fh, + 4096, + "$user_target: ", + $$error_buffers{$user_target}, + @$error_files + ); if ($eof_error) { @@ -1914,14 +1931,14 @@ sub stream_error if ($exit_code != 0) { - # report error status --nodestatus - # Note the message below for node status must - # not be NLS translated. Code depends on the English. - if ($$options{'nodestatus'}) { - my $rsp={}; - $rsp->{data}->[0] = - "$user_target: Remote_command_failed, error_code=$exit_code"; - xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); + # report error status --nodestatus + # Note the message below for node status must + # not be NLS translated. Code depends on the English. + if ($$options{'nodestatus'}) { + my $rsp = {}; + $rsp->{data}->[0] = +"$user_target: Remote_command_failed, error_code=$exit_code"; + xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); } my $rsp = {}; $rsp->{error}->[0] = @@ -1936,7 +1953,7 @@ sub stream_error && xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); push @$targets_failed, $user_target; - push @{$dsh_target_status{'failed'}}, $user_target + push @{ $dsh_target_status{'failed'} }, $user_target if !$signal_interrupt_flag; } @@ -1945,15 +1962,15 @@ sub stream_error { if ($target_rc != 0) { - # report error status --nodestatus - # Note the message below for node status must - # not be NLS translated. Code depends on the English. - if ($$options{'nodestatus'}) { - my $rsp={}; - $rsp->{data}->[0] = - "$user_target: Remote_command_failed, error_code=$$target_properties{'target-rc'}"; - xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); - } + # report error status --nodestatus + # Note the message below for node status must + # not be NLS translated. Code depends on the English. + if ($$options{'nodestatus'}) { + my $rsp = {}; + $rsp->{data}->[0] = +"$user_target: Remote_command_failed, error_code=$$target_properties{'target-rc'}"; + xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); + } #my $rsp = {}; #$rsp->{error}->[0] = @@ -1969,22 +1986,22 @@ sub stream_error push @$targets_failed, $user_target; } - elsif (!defined($target_rc) && ($::DSH_MELLANOX_SWITCH==0)) + elsif (!defined($target_rc) && ($::DSH_MELLANOX_SWITCH == 0)) { - # report error status --nodestatus - # Note the message below for node status must - # not be NLS translated. Code depends on the English. - if ($$options{'nodestatus'}) { - my $rsp={}; - $rsp->{data}->[0] = - "$user_target: Remote_command_failed, error_code=???}"; - xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); - } + # report error status --nodestatus + # Note the message below for node status must + # not be NLS translated. Code depends on the English. + if ($$options{'nodestatus'}) { + my $rsp = {}; + $rsp->{data}->[0] = +"$user_target: Remote_command_failed, error_code=???}"; + xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); + } my $rsp = {}; $rsp->{data}->[0] = - "A return code for the command run on $user_target was not received."; +"A return code for the command run on $user_target was not received."; xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); my $rsp = {}; @@ -1998,15 +2015,15 @@ sub stream_error else { - # report error status --nodestatus - # Note the message below for node status must - # not be NLS translated. Code depends on the English. - if ($$options{'nodestatus'}) { - my $rsp={}; - $rsp->{data}->[0] = - "$user_target: Remote_command_successful"; - xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); - } + # report error status --nodestatus + # Note the message below for node status must + # not be NLS translated. Code depends on the English. + if ($$options{'nodestatus'}) { + my $rsp = {}; + $rsp->{data}->[0] = + "$user_target: Remote_command_successful"; + xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); + } my $rsp = {}; @@ -2020,7 +2037,7 @@ sub stream_error } delete $$targets_active{$user_target}; - delete $$pid_targets{$$forked_process{$user_target}[0]}; + delete $$pid_targets{ $$forked_process{$user_target}[0] }; } close $error_fh; @@ -2123,13 +2140,13 @@ sub config_dcp && xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); !$$options{'node-rcp'} - && ( $$options{'node-rcp'} = $ENV{'DCP_NODE_RCP'} - || $ENV{'DCP_COPY_CMD'} - || undef); + && ($$options{'node-rcp'} = $ENV{'DCP_NODE_RCP'} + || $ENV{'DCP_COPY_CMD'} + || undef); if ($$options{'node-rcp'}) { - my %node_rcp = (); + my %node_rcp = (); my @remotecopy_list = split ',', $$options{'node-rcp'}; foreach my $context_remotecopy (@remotecopy_list) @@ -2171,7 +2188,7 @@ sub config_dcp $dsh_trace && xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); - if ( (!$$options{'nodes'}) + if ((!$$options{'nodes'}) && ($ENV{'DSH_NODE_LIST'} || $ENV{'DSH_LIST'})) { require Context::DSH; @@ -2198,7 +2215,7 @@ sub config_dcp if ($$options{'node-options'}) { - my %node_options = (); + my %node_options = (); my @remoteopts_list = split ',', $$options{'node-options'}; foreach my $context_remoteopts (@remoteopts_list) @@ -2230,7 +2247,7 @@ sub config_dcp { my $rsp = {}; $rsp->{error}->[0] = - "Cannot copy to target $$options{'target'}. Directory does not exist."; +"Cannot copy to target $$options{'target'}. Directory does not exist."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); return ++$result; } @@ -2285,7 +2302,7 @@ sub config_dsh $dsh_stats{'report-status-messages'} = (); $dsh_stats{'specified-targets'} = (); scalar(@dsh_valid_contexts) || xCAT::DSHCLI->get_valid_contexts; - push @{$dsh_stats{'valid-contexts'}}, @dsh_valid_contexts; + push @{ $dsh_stats{'valid-contexts'} }, @dsh_valid_contexts; foreach my $context (@dsh_valid_contexts) { @@ -2320,7 +2337,7 @@ sub config_dsh $dsh_trace && xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); - # Check devicetype attr and build command based on type + # Check devicetype attr and build command based on type $$options{'devicetype'} = $$options{'devicetype'} || $ENV{'DEVICETYPE'} || undef; @@ -2336,43 +2353,44 @@ sub config_dsh # process the config file. check /var/opt/xcat/... first, if the config # file is not found, goto /opt/xcat/share/devicetype - my $devicepath = "/var/opt/xcat/" . $devicename . "/config"; - if (! -e $devicepath) { - $devicepath="$::XCATROOT/share/xcat/devicetype/" . $devicename . "/config"; - } - # Get configuration from $::XCATDEVCFGDIR - # used for QLogic and Mellanox - if (-e $devicepath) - { - my $deviceconf = get_config($devicepath); - - # Get all dsh section configuration - foreach my $entry (keys %{$$deviceconf{'xdsh'}}) - { + my $devicepath = "/var/opt/xcat/" . $devicename . "/config"; + if (!-e $devicepath) { + $devicepath = "$::XCATROOT/share/xcat/devicetype/" . $devicename . "/config"; + } + + # Get configuration from $::XCATDEVCFGDIR + # used for QLogic and Mellanox + if (-e $devicepath) + { + my $deviceconf = get_config($devicepath); + + # Get all dsh section configuration + foreach my $entry (keys %{ $$deviceconf{'xdsh'} }) + { my $value = $$deviceconf{'xdsh'}{$entry}; if ($value) { $$options{$entry} = $value; } - - } - } - else - { - # if not Mellanox, it does not need a config file - if (!($$options{'devicetype'} =~ /IBSwitch::Mellanox/i)) { - my $rsp = {}; - $rsp->{error}->[0] = "The config file: $devicepath is missing"; - xCAT::MsgUtils->message('E', $rsp, $::CALLBACK); - } - } + } + } + else + + { + # if not Mellanox, it does not need a config file + if (!($$options{'devicetype'} =~ /IBSwitch::Mellanox/i)) { + my $rsp = {}; + $rsp->{error}->[0] = "The config file: $devicepath is missing"; + xCAT::MsgUtils->message('E', $rsp, $::CALLBACK); + } + } } !$$options{'node-rsh'} - && ( $$options{'node-rsh'} = $ENV{'DSH_NODE_RSH'} - || $ENV{'DSH_REMOTE_CMD'} - || undef); + && ($$options{'node-rsh'} = $ENV{'DSH_NODE_RSH'} + || $ENV{'DSH_REMOTE_CMD'} + || undef); my $rsp = {}; $rsp->{data}->[0] = "TRACE:Node RSH is $$options{'node-rsh'}"; @@ -2432,7 +2450,7 @@ sub config_dsh } $$options{'fanout'} = $$options{'fanout'} || $ENV{'DSH_FANOUT'} || 64; - $rsp={}; + $rsp = {}; $rsp->{data}->[0] = "TRACE: Fanout value is $$options{'fanout'}."; $dsh_trace && xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); @@ -2441,7 +2459,7 @@ sub config_dsh if ( defined($$options{'syntax'}) - && ( ($$options{'syntax'} ne 'csh') + && (($$options{'syntax'} ne 'csh') && ($$options{'syntax'} ne 'ksh')) ) { @@ -2520,12 +2538,12 @@ sub config_dsh } else { - # if entry NULL then remove - if ($$options{'pre-command'} =~ /NULL/i) { - $$options{'pre-command'} = ''; - } else { #add space between pre-command and command - $$options{'pre-command'} .=" "; - } + # if entry NULL then remove + if ($$options{'pre-command'} =~ /NULL/i) { + $$options{'pre-command'} = ''; + } else { #add space between pre-command and command + $$options{'pre-command'} .= " "; + } } # Check if $$options{'post-command'} has been overwritten. @@ -2534,18 +2552,18 @@ sub config_dsh if ($$options{'syntax'} eq 'csh') { $$options{'post-command'} = - "; $env_set DSH_TARGET_RC$env_assign\$status; echo \":DSH_TARGET_RC=\${DSH_TARGET_RC}:\""; +"; $env_set DSH_TARGET_RC$env_assign\$status; echo \":DSH_TARGET_RC=\${DSH_TARGET_RC}:\""; } else { $$options{'post-command'} = - "; $env_set DSH_TARGET_RC$env_assign\$?; echo \":DSH_TARGET_RC=\${DSH_TARGET_RC}:\""; +"; $env_set DSH_TARGET_RC$env_assign\$?; echo \":DSH_TARGET_RC=\${DSH_TARGET_RC}:\""; } $$options{'exit-status'} && ($$options{'post-command'} .= - ' ; echo "Remote_command_rc = $DSH_TARGET_RC"'); + ' ; echo "Remote_command_rc = $DSH_TARGET_RC"'); } else { @@ -2572,7 +2590,7 @@ sub config_dsh if ( !$$options{'nodes'} - && ( $ENV{'DSH_NODE_LIST'} + && ($ENV{'DSH_NODE_LIST'} || $ENV{'DSH_LIST'}) ) { @@ -2600,7 +2618,7 @@ sub config_dsh if ($$options{'node-options'}) { - my %node_options = (); + my %node_options = (); my @remoteopts_list = split ',', $$options{'node-options'}; foreach my $context_remoteopts (@remoteopts_list) @@ -2635,7 +2653,7 @@ sub config_dsh if (!(-e $exe_command[0])) { - my $rsp={}; + my $rsp = {}; $rsp->{error}->[0] = "File $exe_command[0] does not exist"; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); return ++$result; @@ -2644,7 +2662,7 @@ sub config_dsh if (-z $exe_command[0]) { - my $rsp={}; + my $rsp = {}; $rsp->{error}->[0] = "File $exe_command[0] is empty."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); return ++$result; @@ -2653,7 +2671,7 @@ sub config_dsh if (!(-x $exe_command[0])) { - my $rsp={}; + my $rsp = {}; $rsp->{error}->[0] = "File $exe_command[0] is not executable."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); return ++$result; @@ -2719,7 +2737,7 @@ sub config_signals_dsh foreach my $signal (@ignore_signals) { - if ( ($signal ne 'STOP') + if (($signal ne 'STOP') && ($signal ne 'CONT') && ($signal ne 'TSTP')) { @@ -2774,7 +2792,7 @@ sub handle_signal_dsh { my $rsp = {}; $rsp->{error}->[0] = - "Command execution ended prematurely due to a previous error or stop request from the user."; +"Command execution ended prematurely due to a previous error or stop request from the user."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); exit(1); } @@ -2783,7 +2801,7 @@ sub handle_signal_dsh { my $rsp = {}; $rsp->{error}->[0] = - "Command execution ended prematurely due to a previous error or stop request from the user."; +"Command execution ended prematurely due to a previous error or stop request from the user."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); exit(1); @@ -2797,16 +2815,16 @@ sub handle_signal_dsh $dsh_stats{'end-time'} = localtime(); } - if (@{$dsh_target_status{'waiting'}}) + if (@{ $dsh_target_status{'waiting'} }) { - foreach my $user_target (@{$dsh_target_status{'waiting'}}) + foreach my $user_target (@{ $dsh_target_status{'waiting'} }) { if ($fatal_error) { my $rsp = {}; $rsp->{error}->[0] = - "Running the command on $user_target has been cancelled due to unrecoverable error. The command was never sent to the host."; +"Running the command on $user_target has been cancelled due to unrecoverable error. The command was never sent to the host."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); } @@ -2820,13 +2838,13 @@ sub handle_signal_dsh && xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); } - push @{$dsh_target_status{'canceled'}}, $user_target; + push @{ $dsh_target_status{'canceled'} }, $user_target; } } my $rsp = {}; $rsp->{error}->[0] = - "Running commands have been cancelled due to unrecoverable error or stop request by user."; +"Running commands have been cancelled due to unrecoverable error or stop request by user."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); if ($$dsh_options{'stats'}) @@ -2855,16 +2873,16 @@ sub handle_signal_dsh $dsh_stats{'end-time'} = localtime(); } - if (@{$dsh_target_status{'waiting'}}) + if (@{ $dsh_target_status{'waiting'} }) { - foreach my $user_target (@{$dsh_target_status{'waiting'}}) + foreach my $user_target (@{ $dsh_target_status{'waiting'} }) { if ($fatal_error) { my $rsp = {}; $rsp->{error}->[0] = - "$user_target: running of the command on this host has been cancelled due to unrecoverable error.\n The command was never sent to the host."; +"$user_target: running of the command on this host has been cancelled due to unrecoverable error.\n The command was never sent to the host."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); } @@ -2873,7 +2891,7 @@ sub handle_signal_dsh my $rsp = {}; $rsp->{error}->[0] = - "$user_target: running of the command on this host has been cancelled due to unrecoverable error or stop request by user.\n The command was never sent to the host."; +"$user_target: running of the command on this host has been cancelled due to unrecoverable error or stop request by user.\n The command was never sent to the host."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); my $rsp = {}; @@ -2883,15 +2901,15 @@ sub handle_signal_dsh && xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); } - push @{$dsh_target_status{'canceled'}}, $user_target; + push @{ $dsh_target_status{'canceled'} }, $user_target; } } - @{$dsh_target_status{'waiting'}} = (); + @{ $dsh_target_status{'waiting'} } = (); my $rsp = {}; $rsp->{data}->[0] = - "Command execution ended prematurely due to a previous unrecoverable error or stop by user.\n No commands were executed on any host."; +"Command execution ended prematurely due to a previous unrecoverable error or stop by user.\n No commands were executed on any host."; if ($$dsh_options{'stats'}) { @@ -2949,7 +2967,7 @@ sub handle_signal_dsh my $rsp = {}; $rsp->{error}->[0] = - "Running the command on $user_target has been interrupted due to unrecoverable error. The command may not have completed successfully."; +"Running the command on $user_target has been interrupted due to unrecoverable error. The command may not have completed successfully."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); } @@ -2958,14 +2976,14 @@ sub handle_signal_dsh my $rsp = {}; $rsp->{error}->[0] = - "Running the command on $user_target has been interrupted due to unrecoverable error or stop request by the user. The command may not have completed successfully."; +"Running the command on $user_target has been interrupted due to unrecoverable error or stop request by the user. The command may not have completed successfully."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); } } my $target_pid = $$dsh_forked_process{$user_target}[0]; kill $target_signal, $target_pid; - push @{$dsh_target_status{'failed'}}, $user_target; + push @{ $dsh_target_status{'failed'} }, $user_target; $signal_interrupt_flag = 1; } @@ -2976,16 +2994,16 @@ sub handle_signal_dsh # not want to remove all the rest if ($fatal_error != 2) { # remove the waiting processes - if (@{$dsh_target_status{'waiting'}}) + if (@{ $dsh_target_status{'waiting'} }) { - foreach my $user_target (@{$dsh_target_status{'waiting'}}) + foreach my $user_target (@{ $dsh_target_status{'waiting'} }) { if ($fatal_error) { my $rsp = {}; $rsp->{error}->[0] = - "Running the command on $user_target has been cancelled due to unrecoverable error. The command was never sent to the host."; +"Running the command on $user_target has been cancelled due to unrecoverable error. The command was never sent to the host."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); } @@ -2994,7 +3012,7 @@ sub handle_signal_dsh my $rsp = {}; $rsp->{error}->[0] = - "Running the command on $user_target has been cancelled due to unrecoverable error or stop request by the user. The command was never sent to the host."; +"Running the command on $user_target has been cancelled due to unrecoverable error or stop request by the user. The command was never sent to the host."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); my $rsp = {}; @@ -3004,15 +3022,15 @@ sub handle_signal_dsh && xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); } - push @{$dsh_target_status{'canceled'}}, $user_target; + push @{ $dsh_target_status{'canceled'} }, $user_target; } } - @{$dsh_target_status{'waiting'}} = (); + @{ $dsh_target_status{'waiting'} } = (); my $rsp = {}; $rsp->{error}->[0] = - "Command execution ended prematurely due to a previous unrecoverable error or stop request by the user."; +"Command execution ended prematurely due to a previous unrecoverable error or stop request by the user."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); } #end fatal_error != 2 if ($$dsh_options{'stats'}) @@ -3037,7 +3055,7 @@ sub handle_signal_dsh my $rsp = {}; $rsp->{error}->[0] = - "Running the command stopped due to unrecoverable error or stop request by the user."; +"Running the command stopped due to unrecoverable error or stop request by the user."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); return; @@ -3047,7 +3065,7 @@ sub handle_signal_dsh { my $rsp = {}; $rsp->{error}->[0] = - "Running the command stopped due to unrecoverable error or stop request by the user."; +"Running the command stopped due to unrecoverable error or stop request by the user."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); exit(1); } @@ -3092,8 +3110,8 @@ sub resolve_targets = @_; $$options{'nodes'} - && xCAT::DSHCLI->resolve_nodes($options, $resolved_targets, - $unresolved_targets, $context_targets); + && xCAT::DSHCLI->resolve_nodes($options, $resolved_targets, + $unresolved_targets, $context_targets); } #---------------------------------------------------------------------------- @@ -3141,12 +3159,12 @@ sub resolve_nodes !$node && (($node = $context) && ($context = $$options{'context'})); - push @{$dsh_stats{'specified-targets'}{$context}{'nodes'}}, $node; + push @{ $dsh_stats{'specified-targets'}{$context}{'nodes'} }, $node; } xCAT::DSHCLI->_resolve_nodes($options, $resolved_targets, - $unresolved_targets, $context_targets, - @node_list); + $unresolved_targets, $context_targets, + @node_list); } #---------------------------------------------------------------------------- @@ -3251,16 +3269,16 @@ sub bld_resolve_nodes_hash # find out if we have an MN in the list, local cp and sh will be used # not remote shell # find out the names for the Management Node - my @MNnodeinfo = xCAT::NetworkUtils->determinehostname; - my $mname = pop @MNnodeinfo; # hostname - my $cmd="hostname"; - my $localhostname = xCAT::Utils->runcmd($cmd,0); + my @MNnodeinfo = xCAT::NetworkUtils->determinehostname; + my $mname = pop @MNnodeinfo; # hostname + my $cmd = "hostname"; + my $localhostname = xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) { - my $rsp = {}; - $rsp->{info}->[0] = "Command: $cmd failed. Continuing..."; - xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); - } + my $rsp = {}; + $rsp->{info}->[0] = "Command: $cmd failed. Continuing..."; + xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); + } foreach my $target (@target_list) { @@ -3269,18 +3287,19 @@ sub bld_resolve_nodes_hash my $localhost; my $user; my $context = "XCAT"; + # check to see if this node is the Management Node we are on, can run local commands (sh,cp) - if (($mname eq $target) || ($localhostname eq $target)){ - $localhost=$target; + if (($mname eq $target) || ($localhostname eq $target)) { + $localhost = $target; } my %properties = ( - 'hostname' => $hostname, - 'ip-address' => $ip_address, - 'localhost' => $localhost, - 'user' => $user, - 'context' => $context, - 'unresolved' => $target - ); + 'hostname' => $hostname, + 'ip-address' => $ip_address, + 'localhost' => $localhost, + 'user' => $user, + 'context' => $context, + 'unresolved' => $target + ); $$resolved_targets{"$target"} = \%properties; } @@ -3345,16 +3364,17 @@ sub verify_targets { my $rsp = {}; $rsp->{error}->[0] = - "$user_target is not responding. No command will be issued to this host."; +"$user_target is not responding. No command will be issued to this host."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); + # report error status --nodestatus # Note the message below for node status must # not be NLS translated. Code depends on the English. if ($$options{'nodestatus'}) { - my $rsp={}; - $rsp->{data}->[0] = - "$user_target: Remote_command_failed"; - xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); + my $rsp = {}; + $rsp->{data}->[0] = + "$user_target: Remote_command_failed"; + xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); } my $rsp = {}; @@ -3363,7 +3383,7 @@ sub verify_targets $$dsh_options{'monitor'} && xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); - push @{$dsh_target_status{'canceled'}}, $user_target; + push @{ $dsh_target_status{'canceled'} }, $user_target; $$dsh_unresolved_targets{$user_target} = $$resolved_targets{$user_target}; delete $$resolved_targets{$user_target}; @@ -3567,7 +3587,7 @@ sub util_bit_indexes my ($class, $vector, $bit) = @_; my @bit_indexes = (); - my @bits = split(//, unpack("b*", $vector)); + my @bits = split(//, unpack("b*", $vector)); my $index = 0; while (@bits) @@ -3608,23 +3628,23 @@ sub check_valid_options { my @invalid_opts; my @valid_longnames = ( - "continue", "execute", - "fanout", "help", - "user", "monitor", - "nodes", "node-options", - "node-rsh", "stream", - "timeout", "verify", - "exit-status", "context", - "environment", "ignore-sig", - "ignoresig", "no-locale", - "nodegroups", "silent", - "syntax", "trace", - "version", "command-name", - "commandName", "command-description", - "commandDescription", "noFileWriting", - "preserve", "node-rcp", - "pull", "recursive" - ); + "continue", "execute", + "fanout", "help", + "user", "monitor", + "nodes", "node-options", + "node-rsh", "stream", + "timeout", "verify", + "exit-status", "context", + "environment", "ignore-sig", + "ignoresig", "no-locale", + "nodegroups", "silent", + "syntax", "trace", + "version", "command-name", + "commandName", "command-description", + "commandDescription", "noFileWriting", + "preserve", "node-rcp", + "pull", "recursive" + ); foreach my $opt (@$options) { @@ -3941,8 +3961,8 @@ sub parse_and_run_dsh 'V|version' => \$options{'version'}, 'devicetype|devicetype=s' => \$options{'devicetype'}, - 'nodestatus|nodestatus' => \$options{'nodestatus'}, - 'sudo|sudo' => \$options{'sudo'}, + 'nodestatus|nodestatus' => \$options{'nodestatus'}, + 'sudo|sudo' => \$options{'sudo'}, 'command-name|commandName=s' => \$options{'command-name'}, 'command-description|commandDescription=s' => \$options{'command-description'}, @@ -3983,7 +4003,7 @@ sub parse_and_run_dsh { my $rsp = {}; $rsp->{error}->[0] = - "Remote command: $remotecommand should be used with the dcp command. "; +"Remote command: $remotecommand should be used with the dcp command. "; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); return; } @@ -3996,25 +4016,27 @@ sub parse_and_run_dsh # this was determined in the xdsh client code, because non-root user # actions must be taken there. For those calling xdsh plugin, default # is root - if (!($ENV{'DSH_TO_USERID'})) # env first + if (!($ENV{'DSH_TO_USERID'})) # env first { - if (!($options{'user'})) { # -l second - $options{'user'} = "root"; # default - } + if (!($options{'user'})) { # -l second + $options{'user'} = "root"; # default + } } else { $options{'user'} = $ENV{'DSH_TO_USERID'}; } if ((!(defined($nodes))) && (!(defined($options{'rootimg'})))) - { # no nodes and not -i option, error + { # no nodes and not -i option, error my $rsp = (); $rsp->{error}->[0] = "Unless using -i option, noderange is required."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); return; } + # Determine switch type, processing Mellanox not the same as QLogic my $switchtype = $options{'devicetype'}; + #$switchtype =~ s/::/\//g; # @@ -4024,16 +4046,16 @@ sub parse_and_run_dsh if (defined($options{'rootimg'})) { # running against local host # diskless image - # need directory for Linux, just osimage name for AIX + # need directory for Linux, just osimage name for AIX if (xCAT::Utils->isLinux()) { - if (!(-e ($options{'rootimg'}))) - { # directory does not exist - my $rsp = {}; - $rsp->{error}->[0] = - "Input image directory $options{'rootimg'} does not exist."; - xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); - return; - } + if (!(-e ($options{'rootimg'}))) + { # directory does not exist + my $rsp = {}; + $rsp->{error}->[0] = + "Input image directory $options{'rootimg'} does not exist."; + xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); + return; + } } # since we have no input nodes for running xdsh against the image @@ -4049,7 +4071,7 @@ sub parse_and_run_dsh { my $rsp = {}; $rsp->{error}->[0] = - "Input noderange:@$nodes and any other xdsh flags or environment variables are not valid with -i flag."; +"Input noderange:@$nodes and any other xdsh flags or environment variables are not valid with -i flag."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); return; } @@ -4066,29 +4088,29 @@ sub parse_and_run_dsh # get the actual xdsh command from the argument list $options{'command'} = join ' ', @ARGV; - + # if a Mellanox switch command we have to build - # the command xdsh will send special + # the command xdsh will send special # input will look something like this # xdsh mswitch -l admin --devicetype IBSwitch::Mellanox # enable;configure terminal;show ssh server host-keys # We will build # ssh admin@mswitch cli - # "enable" "configure terminal" "show ssh server host-keys" + # "enable" "configure terminal" "show ssh server host-keys" my @melcmds; if ($switchtype =~ /IBSwitch::Mellanox/i) { - $::DSH_MELLANOX_SWITCH=1; - @melcmds = split (/;/, $options{'command'}); - my $newcmd; - foreach my $cmd (@melcmds) { - $newcmd .= "\""; - $newcmd .= $cmd; - $newcmd .= "\" "; - } - $options{'command'} = $newcmd; + $::DSH_MELLANOX_SWITCH = 1; + @melcmds = split(/;/, $options{'command'}); + my $newcmd; + foreach my $cmd (@melcmds) { + $newcmd .= "\""; + $newcmd .= $cmd; + $newcmd .= "\" "; + } + $options{'command'} = $newcmd; } else { - $::DSH_MELLANOX_SWITCH=0; + $::DSH_MELLANOX_SWITCH = 0; } # # -K option just sets up the ssh keys on the nodes and exits @@ -4096,23 +4118,24 @@ sub parse_and_run_dsh if (defined $options{'ssh-setup'}) { - # check if any node in the noderange is the Management Node and exit + # check if any node in the noderange is the Management Node and exit # with error, if the Management Node is in the Database and in the # noderange - my @mname = xCAT::Utils->noderangecontainsMn(@nodelist); - if (@mname) { # MN in the nodelist - my $nodes=join(',', @mname); + my @mname = xCAT::Utils->noderangecontainsMn(@nodelist); + if (@mname) { # MN in the nodelist + my $nodes = join(',', @mname); my $rsp = {}; $rsp->{error}->[0] = "You must not run -K option against the Management Node:$nodes."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); return; - } + } + # if devicetype=Mellanox, xdsh does not setup ssh, rspconfig does if ($switchtype =~ /IBSwitch::Mellanox/i) { - my $rsp = {}; - $rsp->{error}->[0] = - "You do not use xdsh -K to setup the Mellanox switch ssh keys. Use rspconfig. See man page for rspconfig option sshcfg={enable|disable}."; + my $rsp = {}; + $rsp->{error}->[0] = +"You do not use xdsh -K to setup the Mellanox switch ssh keys. Use rspconfig. See man page for rspconfig option sshcfg={enable|disable}."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); return; } @@ -4131,13 +4154,13 @@ sub parse_and_run_dsh # This is checked for in the client code. # DSH_REMOTE_PASSWORD env variable must be set to the correct # password for the key update. This was setup in xdsh client - # frontend. + # frontend. if (!($ENV{'DSH_REMOTE_PASSWORD'})) { my $rsp = {}; $rsp->{error}->[0] = - "User password for ssh key exchange has not been supplied.\n Cannot complete the -K command\n"; +"User password for ssh key exchange has not been supplied.\n Cannot complete the -K command\n"; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); return; @@ -4147,7 +4170,7 @@ sub parse_and_run_dsh { my $rsp = {}; $rsp->{error}->[0] = - "Current Userid has not been supplied.\n Cannot complete the -K command.\n"; +"Current Userid has not been supplied.\n Cannot complete the -K command.\n"; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); return; @@ -4158,7 +4181,7 @@ sub parse_and_run_dsh { my $rsp = {}; $rsp->{error}->[0] = - "Logon Userid has not been supplied.\n Cannot complete the -K command.\n"; +"Logon Userid has not been supplied.\n Cannot complete the -K command.\n"; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); return; @@ -4169,12 +4192,12 @@ sub parse_and_run_dsh # if current_userid ne touserid then current_userid # must be root - if ( ($current_userid ne $to_userid) + if (($current_userid ne $to_userid) && ($current_userid ne "root")) { my $rsp = {}; $rsp->{error}->[0] = - "When touserid:$to_userid is not the same as the current user:$current_userid. The command must be run by root id."; +"When touserid:$to_userid is not the same as the current user:$current_userid. The command must be run by root id."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); return; } @@ -4188,12 +4211,13 @@ sub parse_and_run_dsh my $devicename = $options{'devicetype'}; $devicename =~ s/::/\//g; my $devicepath = "/var/opt/xcat/" . $devicename . "/config"; - # go to backup directory if the config file + + # go to backup directory if the config file # cannot be found under /var/opt/xcat/... - if (! -e $devicepath) { - $devicepath="$::XCATROOT/share/xcat/devicetype/" . $devicename . "/config"; - } - if (-e $devicepath) + if (!-e $devicepath) { + $devicepath = "$::XCATROOT/share/xcat/devicetype/" . $devicename . "/config"; + } + if (-e $devicepath) { my $deviceconf = get_config($devicepath); @@ -4206,7 +4230,7 @@ sub parse_and_run_dsh # # setup ssh keys on the nodes or ib switch # - my $rc = xCAT::TableUtils->setupSSH($options{'nodes'},$options{'timeout'}); + my $rc = xCAT::TableUtils->setupSSH($options{'nodes'}, $options{'timeout'}); my @results = "return code = $rc"; return (@results); } @@ -4287,7 +4311,7 @@ sub usage_dcp my $usagemsg5c = " xdcp <-i imagepath> -F "; my $usagemsg5d = "[-o options]"; - my $usagemsg .= $usagemsg1 .= $usagemsg2 .= $usagemsg3 .= $usagemsg4 .= + my $usagemsg .= $usagemsg1 .= $usagemsg2 .= $usagemsg3 .= $usagemsg4 .= $usagemsg5 .= $usagemsg5a .= $usagemsg5b .= $usagemsg5c .= $usagemsg5d; if ($::CALLBACK) @@ -4365,29 +4389,29 @@ sub parse_and_run_dcp } if ( !GetOptions( - 'f|fanout=i' => \$options{'fanout'}, - 'F|File=s' => \$options{'File'}, - 'h|help' => \$options{'help'}, - 'l|user=s' => \$options{'user'}, - 'm|monitor' => \$options{'monitor'}, - 'o|node-options=s' => \$options{'node-options'}, - 'q|show-config' => \$options{'show-config'}, - 'p|preserve' => \$options{'preserve'}, - 'r|c|node-rcp=s' => \$options{'node-rcp'}, - 'i|rootimg=s' => \$options{'rootimg'}, - 's' => \$options{'rsyncSN'}, - 't|timeout=i' => \$options{'timeout'}, - 'v|verify' => \$options{'verify'}, - 'B|bypass' => \$options{'bypass'}, - 'Q|silent' => \$options{'silent'}, - 'P|pull' => \$options{'pull'}, - 'R|recursive' => \$options{'recursive'}, - 'T|trace' => \$options{'trace'}, - 'V|version' => \$options{'version'}, - 'devicetype=s' => \$options{'devicetype'}, - 'nodestatus|nodestatus' => \$options{'nodestatus'}, - 'sudo|sudo' => \$options{'sudo'}, - 'X:s' => \$options{'ignore_env'} + 'f|fanout=i' => \$options{'fanout'}, + 'F|File=s' => \$options{'File'}, + 'h|help' => \$options{'help'}, + 'l|user=s' => \$options{'user'}, + 'm|monitor' => \$options{'monitor'}, + 'o|node-options=s' => \$options{'node-options'}, + 'q|show-config' => \$options{'show-config'}, + 'p|preserve' => \$options{'preserve'}, + 'r|c|node-rcp=s' => \$options{'node-rcp'}, + 'i|rootimg=s' => \$options{'rootimg'}, + 's' => \$options{'rsyncSN'}, + 't|timeout=i' => \$options{'timeout'}, + 'v|verify' => \$options{'verify'}, + 'B|bypass' => \$options{'bypass'}, + 'Q|silent' => \$options{'silent'}, + 'P|pull' => \$options{'pull'}, + 'R|recursive' => \$options{'recursive'}, + 'T|trace' => \$options{'trace'}, + 'V|version' => \$options{'version'}, + 'devicetype=s' => \$options{'devicetype'}, + 'nodestatus|nodestatus' => \$options{'nodestatus'}, + 'sudo|sudo' => \$options{'sudo'}, + 'X:s' => \$options{'ignore_env'} ) ) { @@ -4420,7 +4444,7 @@ sub parse_and_run_dcp { my $rsp = {}; $rsp->{error}->[0] = - "Input noderange:@$nodes and any other xdsh flags or environment variables are not valid with -i flag."; +"Input noderange:@$nodes and any other xdsh flags or environment variables are not valid with -i flag."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); return; } @@ -4436,7 +4460,7 @@ sub parse_and_run_dcp if ($options{'version'}) { my $version = xCAT::Utils->Version(); - my $rsp = {}; + my $rsp = {}; $rsp->{data}->[0] = "$version"; xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); return (0); @@ -4462,7 +4486,7 @@ sub parse_and_run_dcp { # File not given my $rsp = {}; $rsp->{error}->[0] = - "If -i option is use, then the -F option must input the file list.\nThe file will contain the list of files to rsync to the image."; +"If -i option is use, then the -F option must input the file list.\nThe file will contain the list of files to rsync to the image."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); return; } @@ -4473,7 +4497,7 @@ sub parse_and_run_dcp { my $rsp = {}; $rsp->{error}->[0] = - "If -F option is use, then -r is invalid. The command will always the rsync using ssh."; +"If -F option is use, then -r is invalid. The command will always the rsync using ssh."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); return; } @@ -4511,10 +4535,10 @@ sub parse_and_run_dcp my $remotecopycommand = $options{'node-rcp'}; if ($options{'node-rcp'} && (!-f $options{'node-rcp'} || !-x $options{'node-rcp'})) - { - my $rsp={}; + { + my $rsp = {}; $rsp->{error}->[0] = - "Remote command: $remotecopycommand does not exist or is not executable."; +"Remote command: $remotecopycommand does not exist or is not executable."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); return; } @@ -4566,36 +4590,38 @@ sub parse_and_run_dcp } my $synfiledir; my $nodesyncfiledir; + # set default sync dir on service node and node # right now setting the nodes and sn syncfiledir the same, leaving - # the possibility that one day we may want them to be different - $synfiledir = "/var/xcat/syncfiles"; + # the possibility that one day we may want them to be different + $synfiledir = "/var/xcat/syncfiles"; $nodesyncfiledir = "/var/xcat/node/syncfiles"; # get the directory on the servicenode to put the rsync files in my @syndir = xCAT::TableUtils->get_site_attribute("SNsyncfiledir"); if ($syndir[0]) { - $synfiledir = $syndir[0]; + $synfiledir = $syndir[0]; } + # get the directory on the node to put the rsync files in my @syndir = xCAT::TableUtils->get_site_attribute("nodesyncfiledir"); if ($syndir[0]) { - $nodesyncfiledir = $syndir[0]; + $nodesyncfiledir = $syndir[0]; } my $rc; my $syncfile; if ($options{'File'}) { - $syncfile = $options{'File'}; - if (!-f $options{'File'}) - { + $syncfile = $options{'File'}; + if (!-f $options{'File'}) + { my $rsp = (); $rsp->{error}->[0] = "File:$syncfile does not exist."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); return; - } + } } # if rsyncing the nodes or service nodes @@ -4609,38 +4635,41 @@ sub parse_and_run_dcp $::SYNCSN = 1; } - # the parsing of the file will fill in an array of postscripts + # the parsing of the file will fill in an array of postscripts # need to be run if the associated file is updated - @::postscripts=(); - @::alwayspostscripts=(); - @::appendlines=(); - @::mergelines=(); + @::postscripts = (); + @::alwayspostscripts = (); + @::appendlines = (); + @::mergelines = (); if (xCAT::Utils->isServiceNode()) { # running on service node $rc = &parse_rsync_input_file_on_SN(\@nodelist, \%options, $syncfile, - $synfiledir,$nodesyncfiledir); + $synfiledir, $nodesyncfiledir); } else { # running on MN $rc = &parse_rsync_input_file_on_MN(\@nodelist, \%options, $syncfile, - $::SYNCSN, $synfiledir,$nodesyncfiledir); - # build a temporary syncfile for the node's synclist - if ($::SYNCSN ==1) { # syncing a servicenode - # we need to make sure the latest is on the servicenode - # for running of the syncfiles postscript, which only pulls - # from the service node - my $tmpsyncfile="/tmp/xdcpsynclist.$$"; - my $syncline = "$syncfile -> $syncfile"; + $::SYNCSN, $synfiledir, $nodesyncfiledir); + + # build a temporary syncfile for the node's synclist + if ($::SYNCSN == 1) { # syncing a servicenode + # we need to make sure the latest is on the servicenode + # for running of the syncfiles postscript, which only pulls + # from the service node + my $tmpsyncfile = "/tmp/xdcpsynclist.$$"; + my $syncline = "$syncfile -> $syncfile"; open(FILE, ">$tmpsyncfile") or die "cannot open file $tmpsyncfile\n"; print FILE " $syncline"; close FILE; + # now put the original syncfile on the queue to sync to the SN's $rc = - &parse_rsync_input_file_on_MN(\@nodelist, \%options,$tmpsyncfile, - $::SYNCSN, $synfiledir,$nodesyncfiledir); + &parse_rsync_input_file_on_MN(\@nodelist, \%options, $tmpsyncfile, + $::SYNCSN, $synfiledir, $nodesyncfiledir); + # cleanup my $cmd = "rm $tmpsyncfile"; my @output = xCAT::Utils->runcmd($cmd, 0); @@ -4650,12 +4679,12 @@ sub parse_and_run_dcp $rsp->{error}->[0] = "Command: $cmd failed."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); } - } + } } if ($rc == 1) { - my $rsp={}; + my $rsp = {}; $rsp->{error}->[0] = "Error parsing the rsync file:$syncfile."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); return; @@ -4666,7 +4695,7 @@ sub parse_and_run_dcp { if (@ARGV < 1) { - my $rsp={}; + my $rsp = {}; $rsp->{error}->[0] = "Missing file arguments"; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); return; @@ -4676,7 +4705,7 @@ sub parse_and_run_dcp { if ($options{'pull'}) { - my $rsp={}; + my $rsp = {}; $rsp->{error}->[0] = "Missing target_path"; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); return; @@ -4687,7 +4716,7 @@ sub parse_and_run_dcp # HERE:only one line of input source and target in that line # such as xdcp -R " /test/* /test" my $tmparg = pop @ARGV; - my ($src,$tgt) = split " ", $tmparg; + my ($src, $tgt) = split " ", $tmparg; $options{'target'} = $tgt; $options{'source'} = join $::__DCP_DELIM, $src; } @@ -4695,7 +4724,7 @@ sub parse_and_run_dcp elsif ($options{'pull'} && (@ARGV > 2)) { - my $rsp={}; + my $rsp = {}; $rsp->{error}->[0] = "Cannot pull more than one file from targets."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); return; @@ -4703,7 +4732,7 @@ sub parse_and_run_dcp else { - # Get the source and the target + # Get the source and the target $options{'target'} = pop @ARGV; $options{'source'} = join $::__DCP_DELIM, @ARGV; } @@ -4714,49 +4743,51 @@ sub parse_and_run_dcp # HERE: Run xdcp LKV @results = xCAT::DSHCLI->runDcp_api(\%options, 0); $::FAILED_NODES = $::RUNCMD_RC; - + # if not just syncing the service node SNsyncfiledir directory, # @::postscripts should be empty in this case anyway - # if postscripts to run after rsync, process the output and + # if postscripts to run after rsync, process the output and # create the xdsh command to run the ones needed - my @results2; - my @results3; - my @results4; - my @results5; + my @results2; + my @results3; + my @results4; + my @results5; my $ranpostscripts; my $ranappendscripts; my $ranmergescripts; # if we were called with runxcmd, like by updatenode - # need to save the runxcmd buffer + # need to save the runxcmd buffer # $::xcmd_outref my $save_xcmd_outref; - if ($::xcmd_outref) { # this means we were called with runxcmd - $save_xcmd_outref = $::xcmd_outref; + if ($::xcmd_outref) { # this means we were called with runxcmd + $save_xcmd_outref = $::xcmd_outref; } if ((@::postscripts) && ($::SYNCSN == 0)) { - @results2 = &run_rsync_postscripts(\@results,$synfiledir,\%options); - $ranpostscripts=1; + @results2 = &run_rsync_postscripts(\@results, $synfiledir, \%options); + $ranpostscripts = 1; } if ((@::alwayspostscripts) && ($::SYNCSN == 0)) { - @results3 = &run_always_rsync_postscripts(\@nodelist,$synfiledir,\%options); + @results3 = &run_always_rsync_postscripts(\@nodelist, $synfiledir, \%options); } if (($::appendscript) && ($::SYNCSN == 0)) { - @results4 = &bld_and_run_append(\@nodelist,\@results,$synfiledir,$nodesyncfiledir,\%options); - $ranappendscripts=1; + @results4 = &bld_and_run_append(\@nodelist, \@results, $synfiledir, $nodesyncfiledir, \%options); + $ranappendscripts = 1; } if (($::mergescript) && ($::SYNCSN == 0)) { - @results5 = &bld_and_run_merge(\@nodelist,\@results,$synfiledir,$nodesyncfiledir,\%options); - $ranmergescripts=1; + @results5 = &bld_and_run_merge(\@nodelist, \@results, $synfiledir, $nodesyncfiledir, \%options); + $ranmergescripts = 1; } + # restore the runxcmd buffer - if ($save_xcmd_outref) { # this means we were called with runxcmd - $::xcmd_outref = $save_xcmd_outref; + if ($save_xcmd_outref) { # this means we were called with runxcmd + $::xcmd_outref = $save_xcmd_outref; } + # TODO, will we ever need to merge # if we ran a postscript and we were run - # using runxcmd, and there was previous output in the + # using runxcmd, and there was previous output in the # runxcmd buffer and we have output from the postscript # then we have to merge the outputs #if (($ranaps == 1) && ($save_xcmd_outref) && ($::xcmd_outref) ) { @@ -4764,32 +4795,33 @@ sub parse_and_run_dcp #} my @newresults; if (@results2) { - @newresults = (@results2); + @newresults = (@results2); } if (@results3) { - @newresults = (@newresults,@results3); + @newresults = (@newresults, @results3); } if (@results4) { - @newresults = (@newresults,@results3,@results4); + @newresults = (@newresults, @results3, @results4); } if (@results5) { - @newresults = (@newresults,@results3,@results4,@results5); + @newresults = (@newresults, @results3, @results4, @results5); } if (@newresults) { - if ($save_xcmd_outref) { # this means we were called with runxcmd - foreach my $line (@newresults) { - push @$::xcmd_outref,$line; + if ($save_xcmd_outref) { # this means we were called with runxcmd + foreach my $line (@newresults) { + push @$::xcmd_outref, $line; + } } - } - return (@newresults); + return (@newresults); } else { - # don't report other results for postscripts,appendscripts,mergescripts because - # you get all the rsync returned lines - if (($ranpostscripts == 0 ) && ($ranappendscripts == 0) - && ($ranmergescripts == 0)) { - return (@results); - } - } + + # don't report other results for postscripts,appendscripts,mergescripts because + # you get all the rsync returned lines + if (($ranpostscripts == 0) && ($ranappendscripts == 0) + && ($ranmergescripts == 0)) { + return (@results); + } + } } #------------------------------------------------------------------------------- @@ -4848,12 +4880,12 @@ sub rsync_to_image } # process no more lines, do not exec - # do not execute postscripts when syncing images - if (($line =~ /EXECUTE:/) || ($line =~ /EXECUTEALWAYS:/) - || ($line =~ /APPEND:/) || ($line =~ /MERGE:/)) - { # process no more lines - last; - } + # do not execute postscripts when syncing images + if (($line =~ /EXECUTE:/) || ($line =~ /EXECUTEALWAYS:/) + || ($line =~ /APPEND:/) || ($line =~ /MERGE:/)) + { # process no more lines + last; + } if ($line =~ /(.+) -> (.+)/) { my $imageupdatedir = $image; @@ -4987,203 +5019,212 @@ sub rsync_to_image sub parse_rsync_input_file_on_MN { use File::Basename; - my ($nodes, $options, $input_file, $rsyncSN, $syncdir,$nodesyncfiledir) = @_; - my @dest_host = @$nodes; + my ($nodes, $options, $input_file, $rsyncSN, $syncdir, $nodesyncfiledir) = @_; + my @dest_host = @$nodes; $::process_line = 0; my $destfileisdir; - my $clause=0; - my $addmergescript =0; - my $addappendscript =0; + my $clause = 0; + my $addmergescript = 0; + my $addappendscript = 0; open(INPUTFILE, "< $input_file") || die "File $input_file does not exist\n"; + while (my $line = ) { chomp $line; - if (($line =~ /^#/) || ( $line =~ /^\s*$/ )) - # skip commments and blanks + if (($line =~ /^#/) || ($line =~ /^\s*$/)) + + # skip commments and blanks { next; } - # Determine if processing a clause or the synclist + + # Determine if processing a clause or the synclist if (($line =~ /EXECUTE:/) || ($line =~ /EXECUTEALWAYS:/) - || ($line =~ /APPEND:/) || ($line =~ /MERGE:/)) { - $clause=$line; - next; # get the content of the clause + || ($line =~ /APPEND:/) || ($line =~ /MERGE:/)) { + $clause = $line; + next; # get the content of the clause } + # processing a clause if (($clause =~ /APPEND:/) || ($clause =~ /EXECUTEALWAYS:/) || ($clause =~ /EXECUTE:/) || ($clause =~ /MERGE:/)) { if (($::SYNCSN == 1) && (($clause =~ /EXECUTEALWAYS:/) || - ($clause =~ /EXECUTE:/))) { - # for EXECUTE and EXECUTEALWAYS skip, if syncing SN only - next; - } else { # process the clause - if ($clause =~ /EXECUTE:/) { - push @::postscripts,$line; - } - if ($clause =~ /EXECUTEALWAYS:/) { - push @::alwayspostscripts,$line; - } - if ($clause =~ /APPEND:/) { - # location of the base append script - # for APPEND we have to sync the appendscript and the - # append file to the SN - my $onServiceNode=0; - my $syncappendscript=0; - &build_append_rsync($line,$nodes, $options, $input_file,$rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncappendscript); - if ($::SYNCSN == 0) { - # this triggers the running of the appendscript - $::appendscript ="/opt/xcat/share/xcat/scripts/xdcpappend.sh"; + ($clause =~ /EXECUTE:/))) { + + # for EXECUTE and EXECUTEALWAYS skip, if syncing SN only + next; + } else { # process the clause + if ($clause =~ /EXECUTE:/) { + push @::postscripts, $line; + } + if ($clause =~ /EXECUTEALWAYS:/) { + push @::alwayspostscripts, $line; + } + if ($clause =~ /APPEND:/) { + + # location of the base append script + # for APPEND we have to sync the appendscript and the + # append file to the SN + my $onServiceNode = 0; + my $syncappendscript = 0; + &build_append_rsync($line, $nodes, $options, $input_file, $rsyncSN, $syncdir, $nodesyncfiledir, $onServiceNode, $syncappendscript); + if ($::SYNCSN == 0) { + + # this triggers the running of the appendscript + $::appendscript = "/opt/xcat/share/xcat/scripts/xdcpappend.sh"; + } + + # add the append script to the sync + if ($addappendscript == 0) { # only add once + my $appscript = "/opt/xcat/share/xcat/scripts/xdcpappend.sh"; + my $appendscriptline = "$appscript -> $appscript"; + $syncappendscript = 1; # syncing the xdcpappend.sh script + &build_append_rsync($appendscriptline, $nodes, $options, $input_file, $rsyncSN, $syncdir, $nodesyncfiledir, $onServiceNode, $syncappendscript); + $addappendscript = 1; + } + } # end APPEND clause + if ($clause =~ /MERGE:/) { + + # location of the base merge script + # for MERGE we have to sync the mergescript and the + # merge file to the SN + my $onServiceNode = 0; + my $syncmergescript = 0; + &build_merge_rsync($line, $nodes, $options, $input_file, $rsyncSN, $syncdir, $nodesyncfiledir, $onServiceNode, $syncmergescript); + if ($::SYNCSN == 0) { + + # this triggers the running of the mergescript + $::mergescript = "/opt/xcat/share/xcat/scripts/xdcpmerge.sh"; + } + + # add the merge script to the sync + if ($addmergescript == 0) { # only add once + my $mergescript = "/opt/xcat/share/xcat/scripts/xdcpmerge.sh"; + my $mergescriptline = "$mergescript -> $mergescript"; + $syncmergescript = 1; # syncing the xdcpmerge.sh script + &build_merge_rsync($mergescriptline, $nodes, $options, $input_file, $rsyncSN, $syncdir, $nodesyncfiledir, $onServiceNode, $syncmergescript); + $addmergescript = 1; + } + } # end MERGE clause + + } + } else { # not processing EXECUTE, EXECUTEALWAYS or APPEND + # otherwise it is just the synclist + # xCAT supports the syncfile format: + # file -> file + # file -> (noderange for permitted nodes) file + if ($line =~ /(.+) -> (.+)/ || $line =~ /(.+) -> +\((.+)\) +(.+)/) { + $::process_line = 1; + my $src_file; + my $dest_file; + my $dest_node; + my @dest_nodes; + if ($line =~ /(.+) -> +\((.+)\) +(.+)/) { + $src_file = $1; + $dest_node = $2; + $dest_file = $3; + } elsif ($line =~ /(.+) -> (.+)/) { + $src_file = $1; + $dest_file = $2; } - # add the append script to the sync - if ($addappendscript == 0) { # only add once - my $appscript ="/opt/xcat/share/xcat/scripts/xdcpappend.sh"; - my $appendscriptline = "$appscript -> $appscript"; - $syncappendscript=1; # syncing the xdcpappend.sh script - &build_append_rsync($appendscriptline,$nodes, $options, $input_file,$rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncappendscript); - $addappendscript=1; - } - } # end APPEND clause - if ($clause =~ /MERGE:/) { - # location of the base merge script - # for MERGE we have to sync the mergescript and the - # merge file to the SN - my $onServiceNode=0; - my $syncmergescript=0; - &build_merge_rsync($line,$nodes, $options, $input_file,$rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncmergescript); - if ($::SYNCSN == 0) { - # this triggers the running of the mergescript - $::mergescript ="/opt/xcat/share/xcat/scripts/xdcpmerge.sh"; + # get all the permitted nodes for the line + $dest_node =~ s/\s//g; + if ($dest_node) { + @dest_nodes = noderange($dest_node); } - - # add the merge script to the sync - if ($addmergescript == 0) { # only add once - my $mergescript ="/opt/xcat/share/xcat/scripts/xdcpmerge.sh"; - my $mergescriptline = "$mergescript -> $mergescript"; - $syncmergescript=1; # syncing the xdcpmerge.sh script - &build_merge_rsync($mergescriptline,$nodes, $options, $input_file,$rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncmergescript); - $addmergescript=1; + $dest_file =~ s/[\s;]//g; + my @srcfiles = (split ' ', $src_file); + my $arraysize = scalar @srcfiles; # of source files on the line + my $dest_dir; + $destfileisdir = 0; + if ($dest_file =~ /\/$/) + { # ends in / + $destfileisdir = 1; } - } # end MERGE clause - - } - } else { # not processing EXECUTE, EXECUTEALWAYS or APPEND - # otherwise it is just the synclist - # xCAT supports the syncfile format: - # file -> file - # file -> (noderange for permitted nodes) file - if ($line =~ /(.+) -> (.+)/ || $line =~ /(.+) -> +\((.+)\) +(.+)/) { - $::process_line = 1; - my $src_file; - my $dest_file; - my $dest_node; - my @dest_nodes; - if ($line =~ /(.+) -> +\((.+)\) +(.+)/) { - $src_file = $1; - $dest_node = $2; - $dest_file = $3; - } elsif ($line =~ /(.+) -> (.+)/) { - $src_file = $1; - $dest_file = $2; - } - # get all the permitted nodes for the line - $dest_node =~ s/\s//g; - if ($dest_node) { - @dest_nodes = noderange($dest_node); - } - $dest_file =~ s/[\s;]//g; - my @srcfiles = (split ' ', $src_file); - my $arraysize = scalar @srcfiles; # of source files on the line - my $dest_dir; - $destfileisdir = 0; - if ($dest_file =~ /\/$/) - { # ends in / - $destfileisdir = 1; - } - - # if more than one file on the line then - # or the destination file ends in / - # /tmp/file1 -> /tmp/ - # the destination is a directory - # else assume a file - if (($arraysize > 1) || ($destfileisdir == 1)) - { - $dest_dir = $dest_file; - $destfileisdir = 1; - } - else # get the directory name - { # strip off the file - $dest_dir = dirname($dest_file); - } - $dest_dir =~ s/\s*//g; #remove blanks - - foreach my $target_node (@dest_host) - { - # skip the node if it's NOT in the permitted list - if ($dest_node && ! grep /^$target_node$/, @dest_nodes) { - next; - } - $$options{'destDir_srcFile'}{$target_node} ||= {}; - - # for each file on the line - foreach my $srcfile (@srcfiles) + # if more than one file on the line then + # or the destination file ends in / + # /tmp/file1 -> /tmp/ + # the destination is a directory + # else assume a file + if (($arraysize > 1) || ($destfileisdir == 1)) { + $dest_dir = $dest_file; + $destfileisdir = 1; + } + else # get the directory name + { # strip off the file + $dest_dir = dirname($dest_file); + } + $dest_dir =~ s/\s*//g; #remove blanks - # if syncing the Service Node, file goes to the same place - # where it was on the MN off the syncdir on the service - # node - if ($rsyncSN == 1) - { # syncing the SN - $dest_dir = $syncdir; # the SN sync dir - $dest_dir .= dirname($srcfile); - $dest_dir =~ s/\s*//g; #remove blanks + foreach my $target_node (@dest_host) + { + # skip the node if it's NOT in the permitted list + if ($dest_node && !grep /^$target_node$/, @dest_nodes) { + next; } - $$options{'destDir_srcFile'}{$target_node}{$dest_dir} ||= - {}; + $$options{'destDir_srcFile'}{$target_node} ||= {}; - # can be full file name for destination or just the - # directory name - my $src_basename = basename($srcfile); # get file name - - my $dest_basename; # destination file name - # determine path to the file - if ($destfileisdir == 1) # if a directory + # for each file on the line + foreach my $srcfile (@srcfiles) { - $dest_basename = $src_basename; - } - else - { - $dest_basename = basename($dest_file); - } - if ($rsyncSN == 1) # dest file will be the same as src - { # syncing the SN - $dest_basename = $src_basename; - } - $$options{'destDir_srcFile'}{$target_node}{$dest_dir} ||= - $dest_basename =~ s/[\s;]//g; - # if the filename will be the same at the destination - if ($src_basename eq $dest_basename) - { - $$options{'destDir_srcFile'}{$target_node}{$dest_dir} - {'same_dest_name'} ||= []; - push @{$$options{'destDir_srcFile'}{$target_node} - {$dest_dir}{'same_dest_name'}}, $srcfile; - } - else # changing file names - { - $$options{'destDir_srcFile'}{$target_node}{$dest_dir} - {'diff_dest_name'} ||= {}; - $$options{'destDir_srcFile'}{$target_node}{$dest_dir} - {'diff_dest_name'}{$srcfile} = $dest_basename; - } + # if syncing the Service Node, file goes to the same place + # where it was on the MN off the syncdir on the service + # node + if ($rsyncSN == 1) + { # syncing the SN + $dest_dir = $syncdir; # the SN sync dir + $dest_dir .= dirname($srcfile); + $dest_dir =~ s/\s*//g; #remove blanks + } + $$options{'destDir_srcFile'}{$target_node}{$dest_dir} ||= + {}; - } # end of each srcfile - } # end of each node - } # if synclist line - } # end processing clauses EXECUTE, APPEND, etc - } #end while processing file + # can be full file name for destination or just the + # directory name + my $src_basename = basename($srcfile); # get file name + + my $dest_basename; # destination file name + # determine path to the file + if ($destfileisdir == 1) # if a directory + { + $dest_basename = $src_basename; + } + else + { + $dest_basename = basename($dest_file); + } + if ($rsyncSN == 1) # dest file will be the same as src + { # syncing the SN + $dest_basename = $src_basename; + } + $$options{'destDir_srcFile'}{$target_node}{$dest_dir} ||= + $dest_basename =~ s/[\s;]//g; + + # if the filename will be the same at the destination + if ($src_basename eq $dest_basename) + { + $$options{'destDir_srcFile'}{$target_node}{$dest_dir} + {'same_dest_name'} ||= []; + push @{ $$options{'destDir_srcFile'}{$target_node} + {$dest_dir}{'same_dest_name'} }, $srcfile; + } + else # changing file names + { + $$options{'destDir_srcFile'}{$target_node}{$dest_dir} + {'diff_dest_name'} ||= {}; + $$options{'destDir_srcFile'}{$target_node}{$dest_dir} + {'diff_dest_name'}{$srcfile} = $dest_basename; + } + + } # end of each srcfile + } # end of each node + } # if synclist line + } # end processing clauses EXECUTE, APPEND, etc + } #end while processing file close INPUTFILE; if ($::process_line == 0) { # no valid lines in the file @@ -5194,10 +5235,11 @@ sub parse_rsync_input_file_on_MN } else { - $$options{'nodes'} = join ',', keys %{$$options{'destDir_srcFile'}}; + $$options{'nodes'} = join ',', keys %{ $$options{'destDir_srcFile'} }; } return 0; } + #------------------------------------------------------------------------------- =head3 @@ -5231,72 +5273,74 @@ sub parse_rsync_input_file_on_MN #------------------------------------------------------------------------------- -sub build_append_rsync +sub build_append_rsync { use File::Basename; - my ($line,$nodes, $options,$input_file, $rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncappendscript) = @_; + my ($line, $nodes, $options, $input_file, $rsyncSN, $syncdir, $nodesyncfiledir, $onServiceNode, $syncappendscript) = @_; my @dest_host = @$nodes; my $process_line = 0; my $destfileisdir; + # add append directory to the base nodesyncfiledir $nodesyncfiledir .= "/append"; - + if ($line =~ /(.+) -> (.+)/) { - $::process_line = 1; - if ($syncappendscript == 0) { # don't add the xdcpappend.sh line - push @::appendlines,$line; + $::process_line = 1; + if ($syncappendscript == 0) { # don't add the xdcpappend.sh line + push @::appendlines, $line; + } + my $src_file = $1; # append file left of arror + my $orig_src_file = $1; # append file left of arror + # it will be sync'd to $nodesyncfiledir/$append_file + my $dest_file = $nodesyncfiledir; + $dest_file .= $src_file; + $dest_file =~ s/[\s;]//g; + my $dest_dir = dirname($dest_file); + $dest_dir =~ s/\s*//g; #remove blanks + + foreach my $target_node (@dest_host) + { + $$options{'destDir_srcFile'}{$target_node} ||= {}; + + # if syncing the Service Node, file goes to the same place + # where it was on the MN off the syncdir on the service + # node + if ($rsyncSN == 1) + { # syncing the SN + $dest_dir = $syncdir; # the SN sync dir + $dest_dir .= dirname($src_file); + $dest_dir =~ s/\s*//g; #remove blanks } - my $src_file = $1; # append file left of arror - my $orig_src_file = $1; # append file left of arror - # it will be sync'd to $nodesyncfiledir/$append_file - my $dest_file = $nodesyncfiledir; - $dest_file .= $src_file; - $dest_file =~ s/[\s;]//g; - my $dest_dir = dirname($dest_file); - $dest_dir =~ s/\s*//g; #remove blanks + $$options{'destDir_srcFile'}{$target_node}{$dest_dir} ||= + {}; - foreach my $target_node (@dest_host) - { - $$options{'destDir_srcFile'}{$target_node} ||= {}; + my $src_basename = basename($src_file); # get file name + # if this is syncing from the Service Node then we have + # to pick up files from /var/xcat/syncfiles... + if ($onServiceNode == 1) { + my $newsrcfile = $syncdir; # add SN syndir on front + $newsrcfile .= $orig_src_file; + $src_file = $newsrcfile; + } - # if syncing the Service Node, file goes to the same place - # where it was on the MN off the syncdir on the service - # node - if ($rsyncSN == 1) - { # syncing the SN - $dest_dir = $syncdir; # the SN sync dir - $dest_dir .= dirname($src_file); - $dest_dir =~ s/\s*//g; #remove blanks - } - $$options{'destDir_srcFile'}{$target_node}{$dest_dir} ||= - {}; + # destination file name + my $dest_basename = basename($dest_file); + if ($rsyncSN == 1) # dest file will be the same as src + { # syncing the SN + $dest_basename = $src_basename; + } + $$options{'destDir_srcFile'}{$target_node}{$dest_dir} ||= + $dest_basename =~ s/[\s;]//g; - my $src_basename = basename($src_file); # get file name - # if this is syncing from the Service Node then we have - # to pick up files from /var/xcat/syncfiles... - if ($onServiceNode == 1) { - my $newsrcfile = $syncdir; # add SN syndir on front - $newsrcfile .= $orig_src_file; - $src_file=$newsrcfile; - } - # destination file name - my $dest_basename = basename($dest_file); - if ($rsyncSN == 1) # dest file will be the same as src - { # syncing the SN - $dest_basename = $src_basename; - } - $$options{'destDir_srcFile'}{$target_node}{$dest_dir} ||= - $dest_basename =~ s/[\s;]//g; + $$options{'destDir_srcFile'}{$target_node}{$dest_dir} + {'same_dest_name'} ||= []; + push @{ $$options{'destDir_srcFile'}{$target_node} + {$dest_dir}{'same_dest_name'} }, $src_file; - $$options{'destDir_srcFile'}{$target_node}{$dest_dir} - {'same_dest_name'} ||= []; - push @{$$options{'destDir_srcFile'}{$target_node} - {$dest_dir}{'same_dest_name'}}, $src_file; - - } # end of each node - } # if synclist line + } # end of each node + } # if synclist line if ($::process_line == 0) { # no valid lines in the file my $rsp = {}; @@ -5306,10 +5350,11 @@ sub build_append_rsync } else { - $$options{'nodes'} = join ',', keys %{$$options{'destDir_srcFile'}}; + $$options{'nodes'} = join ',', keys %{ $$options{'destDir_srcFile'} }; } return 0; } + #------------------------------------------------------------------------------- =head3 @@ -5341,75 +5386,78 @@ sub build_append_rsync #------------------------------------------------------------------------------- -sub build_merge_rsync +sub build_merge_rsync { use File::Basename; - my ($line,$nodes, $options,$input_file, $rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncmergescript) = @_; + my ($line, $nodes, $options, $input_file, $rsyncSN, $syncdir, $nodesyncfiledir, $onServiceNode, $syncmergescript) = @_; my @dest_host = @$nodes; my $process_line = 0; my $destfileisdir; + # add merge directory to the base nodesyncfiledir - if ($syncmergescript == 1) { # syncing the xdcpmerge.sh - $nodesyncfiledir .= "/merge"; - } else { # all the other merge scripts - $nodesyncfiledir .= "/merge/mergefiles"; + if ($syncmergescript == 1) { # syncing the xdcpmerge.sh + $nodesyncfiledir .= "/merge"; + } else { # all the other merge scripts + $nodesyncfiledir .= "/merge/mergefiles"; } if ($line =~ /(.+) -> (.+)/) { - $::process_line = 1; - if ($syncmergescript == 0) { # don't add the xdcpmerge.sh line - push @::mergelines,$line; + $::process_line = 1; + if ($syncmergescript == 0) { # don't add the xdcpmerge.sh line + push @::mergelines, $line; + } + my $src_file = $1; # merge file left of arrow + my $orig_src_file = $1; + + # it will be sync'd to $nodesyncfiledir/$merge_file + my $dest_file = $nodesyncfiledir; + $dest_file .= $src_file; + $dest_file =~ s/[\s;]//g; + my $dest_dir = dirname($dest_file); + $dest_dir =~ s/\s*//g; #remove blanks + + foreach my $target_node (@dest_host) + { + $$options{'destDir_srcFile'}{$target_node} ||= {}; + + # if syncing the Service Node, file goes to the same place + # where it was on the MN off the syncdir on the service + # node + if ($rsyncSN == 1) + { # syncing the SN + $dest_dir = $syncdir; # the SN sync dir + $dest_dir .= dirname($src_file); + $dest_dir =~ s/\s*//g; #remove blanks } - my $src_file = $1; # merge file left of arrow - my $orig_src_file = $1; - # it will be sync'd to $nodesyncfiledir/$merge_file - my $dest_file = $nodesyncfiledir; - $dest_file .= $src_file; - $dest_file =~ s/[\s;]//g; - my $dest_dir = dirname($dest_file); - $dest_dir =~ s/\s*//g; #remove blanks + $$options{'destDir_srcFile'}{$target_node}{$dest_dir} ||= + {}; - foreach my $target_node (@dest_host) - { - $$options{'destDir_srcFile'}{$target_node} ||= {}; + my $src_basename = basename($src_file); # get file name + # if this is syncing from the Service Node then we have + # to pick up files from /var/xcat/syncfiles... + if ($onServiceNode == 1) { + my $newsrcfile = $syncdir; # add SN syndir on front + $newsrcfile .= $orig_src_file; + $src_file = $newsrcfile; + } - # if syncing the Service Node, file goes to the same place - # where it was on the MN off the syncdir on the service - # node - if ($rsyncSN == 1) - { # syncing the SN - $dest_dir = $syncdir; # the SN sync dir - $dest_dir .= dirname($src_file); - $dest_dir =~ s/\s*//g; #remove blanks - } - $$options{'destDir_srcFile'}{$target_node}{$dest_dir} ||= - {}; + # destination file name + my $dest_basename = basename($dest_file); + if ($rsyncSN == 1) # dest file will be the same as src + { # syncing the SN + $dest_basename = $src_basename; + } + $$options{'destDir_srcFile'}{$target_node}{$dest_dir} ||= + $dest_basename =~ s/[\s;]//g; - my $src_basename = basename($src_file); # get file name - # if this is syncing from the Service Node then we have - # to pick up files from /var/xcat/syncfiles... - if ($onServiceNode == 1) { - my $newsrcfile = $syncdir; # add SN syndir on front - $newsrcfile .= $orig_src_file; - $src_file=$newsrcfile; - } - # destination file name - my $dest_basename = basename($dest_file); - if ($rsyncSN == 1) # dest file will be the same as src - { # syncing the SN - $dest_basename = $src_basename; - } - $$options{'destDir_srcFile'}{$target_node}{$dest_dir} ||= - $dest_basename =~ s/[\s;]//g; + $$options{'destDir_srcFile'}{$target_node}{$dest_dir} + {'same_dest_name'} ||= []; + push @{ $$options{'destDir_srcFile'}{$target_node} + {$dest_dir}{'same_dest_name'} }, $src_file; - $$options{'destDir_srcFile'}{$target_node}{$dest_dir} - {'same_dest_name'} ||= []; - push @{$$options{'destDir_srcFile'}{$target_node} - {$dest_dir}{'same_dest_name'}}, $src_file; - - } # end of each node - } # if synclist line + } # end of each node + } # if synclist line if ($::process_line == 0) { # no valid lines in the file my $rsp = {}; @@ -5419,10 +5467,11 @@ sub build_merge_rsync } else { - $$options{'nodes'} = join ',', keys %{$$options{'destDir_srcFile'}}; + $$options{'nodes'} = join ',', keys %{ $$options{'destDir_srcFile'} }; } return 0; } + #------------------------------------------------------------------------------- =head3 @@ -5491,156 +5540,164 @@ sub build_merge_rsync sub parse_rsync_input_file_on_SN { use File::Basename; - my ($nodes, $options, $input_file, $syncdir,$nodesyncfiledir) = @_; + my ($nodes, $options, $input_file, $syncdir, $nodesyncfiledir) = @_; my @dest_host = @$nodes; my $process_line = 0; my $destfileisdir; my $rsyncSN; - my $clause=0; + my $clause = 0; open(INPUTFILE, "< $input_file") || die "File $input_file does not exist\n"; + while (my $line = ) { chomp $line; - if (($line =~ /^#/) || ( $line =~ /^\s*$/ )) - # skip commments and blanks + if (($line =~ /^#/) || ($line =~ /^\s*$/)) + + # skip commments and blanks { next; } + # Determine if processing a clause or the synclist if (($line =~ /EXECUTE:/) || ($line =~ /EXECUTEALWAYS:/) - || ($line =~ /APPEND:/) || ($line =~ /MERGE:/)) { - $clause=$line; - next; # get the content of the clause + || ($line =~ /APPEND:/) || ($line =~ /MERGE:/)) { + $clause = $line; + next; # get the content of the clause } + # processing a clause if (($clause =~ /APPEND:/) || ($clause =~ /MERGE:/) || ($clause =~ /EXECUTEALWAYS:/) || ($clause =~ /EXECUTE:/)) { if (($::SYNCSN == 1) && (($clause =~ /EXECUTEALWAYS:/) || - ($clause =~ /EXECUTE:/))) { # skip, if syncing SN only - next; - } else { # process the clause - if ($clause =~ /EXECUTE:/) { - push @::postscripts,$line; - } - if ($clause =~ /EXECUTEALWAYS:/) { - push @::alwayspostscripts,$line; - } - if ($clause =~ /APPEND:/) { - $process_line = 1; - my $onServiceNode=1; - my $syncappendscript=0; - &build_append_rsync($line,$nodes, $options, $input_file,$rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncappendscript); - if ($::SYNCSN == 0) { - # this triggers the running of the appendscript - $::appendscript ="/opt/xcat/share/xcat/scripts/xdcpappend.sh"; + ($clause =~ /EXECUTE:/))) { # skip, if syncing SN only + next; + } else { # process the clause + if ($clause =~ /EXECUTE:/) { + push @::postscripts, $line; } - # add the append script to the sync - my $appscript ="/opt/xcat/share/xcat/scripts/xdcpappend.sh"; - my $appendscriptline = "$appscript -> $appscript"; - $syncappendscript=1; # syncing the xdcpappend.sh script - &build_append_rsync($appendscriptline,$nodes, $options, $input_file,$rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncappendscript); - } - if ($clause =~ /MERGE:/) { - $process_line = 1; - my $onServiceNode=1; - my $syncmergescript=0; - &build_merge_rsync($line,$nodes, $options, $input_file,$rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncmergescript); - if ($::SYNCSN == 0) { - # this triggers the running of the mergescript - $::mergescript ="/opt/xcat/share/xcat/scripts/xdcpmerge.sh"; + if ($clause =~ /EXECUTEALWAYS:/) { + push @::alwayspostscripts, $line; } - # add the merge script to the sync - my $appscript ="/opt/xcat/share/xcat/scripts/xdcpmerge.sh"; - my $mergescriptline = "$appscript -> $appscript"; - $syncmergescript=1; # syncing the xdcpmerge.sh script - &build_merge_rsync($mergescriptline,$nodes, $options, $input_file,$rsyncSN, $syncdir,$nodesyncfiledir,$onServiceNode,$syncmergescript); - } - - } - } else { # not processing EXECUTE, EXECUTEALWAYS or APPEND - # otherwise it is just the synclist + if ($clause =~ /APPEND:/) { + $process_line = 1; + my $onServiceNode = 1; + my $syncappendscript = 0; + &build_append_rsync($line, $nodes, $options, $input_file, $rsyncSN, $syncdir, $nodesyncfiledir, $onServiceNode, $syncappendscript); + if ($::SYNCSN == 0) { - if ($line =~ /(.+) -> (.+)/) - { - $process_line = 1; - my $src_file = $1; - my $dest_file = $2; - $dest_file =~ s/[\s;]//g; # remove blanks + # this triggers the running of the appendscript + $::appendscript = "/opt/xcat/share/xcat/scripts/xdcpappend.sh"; + } + + # add the append script to the sync + my $appscript = "/opt/xcat/share/xcat/scripts/xdcpappend.sh"; + my $appendscriptline = "$appscript -> $appscript"; + $syncappendscript = 1; # syncing the xdcpappend.sh script + &build_append_rsync($appendscriptline, $nodes, $options, $input_file, $rsyncSN, $syncdir, $nodesyncfiledir, $onServiceNode, $syncappendscript); + } + if ($clause =~ /MERGE:/) { + $process_line = 1; + my $onServiceNode = 1; + my $syncmergescript = 0; + &build_merge_rsync($line, $nodes, $options, $input_file, $rsyncSN, $syncdir, $nodesyncfiledir, $onServiceNode, $syncmergescript); + if ($::SYNCSN == 0) { + + # this triggers the running of the mergescript + $::mergescript = "/opt/xcat/share/xcat/scripts/xdcpmerge.sh"; + } + + # add the merge script to the sync + my $appscript = "/opt/xcat/share/xcat/scripts/xdcpmerge.sh"; + my $mergescriptline = "$appscript -> $appscript"; + $syncmergescript = 1; # syncing the xdcpmerge.sh script + &build_merge_rsync($mergescriptline, $nodes, $options, $input_file, $rsyncSN, $syncdir, $nodesyncfiledir, $onServiceNode, $syncmergescript); + } - # see if destination is a directory - $destfileisdir = 0; - if ($dest_file =~ /\/$/) - { # ends in / - $destfileisdir = 1; } - my @srcfiles = (split ' ', $src_file); - my $arraysize = scalar @srcfiles; # of source files on the line - my $dest_dir; + } else { # not processing EXECUTE, EXECUTEALWAYS or APPEND + # otherwise it is just the synclist - # if only more than one file on the line or ends in / - # then the destination is a directory - # else a file, - if (($arraysize > 1) || ($destfileisdir == 1)) + if ($line =~ /(.+) -> (.+)/) { - $dest_dir = $dest_file; - $destfileisdir = 1; - } - else # a file path - { - $dest_dir = dirname($dest_file); - } - $dest_dir =~ s/\s*//g; #remove blanks + $process_line = 1; + my $src_file = $1; + my $dest_file = $2; + $dest_file =~ s/[\s;]//g; # remove blanks - foreach my $target_node (@dest_host) - { - $$options{'destDir_srcFile'}{$target_node} ||= {}; + # see if destination is a directory + $destfileisdir = 0; + if ($dest_file =~ /\/$/) + { # ends in / + $destfileisdir = 1; + } + my @srcfiles = (split ' ', $src_file); + my $arraysize = scalar @srcfiles; # of source files on the line + my $dest_dir; - # for each file on the line - foreach my $srcfile (@srcfiles) + # if only more than one file on the line or ends in / + # then the destination is a directory + # else a file, + if (($arraysize > 1) || ($destfileisdir == 1)) { - my $newsrcfile = $syncdir; # add syndir on front - $newsrcfile .= $srcfile; - $$options{'destDir_srcFile'}{$target_node}{$dest_dir} ||= - {}; + $dest_dir = $dest_file; + $destfileisdir = 1; + } + else # a file path + { + $dest_dir = dirname($dest_file); + } + $dest_dir =~ s/\s*//g; #remove blanks - # can be full file name for destination or just the - # directory name. For source must be full path - my $src_basename = basename($newsrcfile); # get file name + foreach my $target_node (@dest_host) + { + $$options{'destDir_srcFile'}{$target_node} ||= {}; - my $dest_basename; # destination file name - if ($destfileisdir == 1) # is a directory + # for each file on the line + foreach my $srcfile (@srcfiles) { - $dest_basename = $src_basename; - } - else - { - $dest_basename = basename($dest_file); - } - $$options{'destDir_srcFile'}{$target_node}{$dest_dir} ||= - $dest_basename =~ s/[\s;]//g; + my $newsrcfile = $syncdir; # add syndir on front + $newsrcfile .= $srcfile; + $$options{'destDir_srcFile'}{$target_node}{$dest_dir} ||= + {}; - # if the filename will be the same at the destination - if ($src_basename eq $dest_basename) - { - $$options{'destDir_srcFile'}{$target_node}{$dest_dir} - {'same_dest_name'} ||= []; - push @{$$options{'destDir_srcFile'}{$target_node} - {$dest_dir}{'same_dest_name'}}, $newsrcfile; - } - else # changing file names - { - $$options{'destDir_srcFile'}{$target_node}{$dest_dir} - {'diff_dest_name'} ||= {}; - $$options{'destDir_srcFile'}{$target_node}{$dest_dir} - {'diff_dest_name'}{$newsrcfile} = $dest_basename; - } + # can be full file name for destination or just the + # directory name. For source must be full path + my $src_basename = basename($newsrcfile); # get file name - } # end of srcfile - } # end of each node - } # end of synclist - }# end processing clauses EXECUTE, APPEND, etc - } #end of processing file + my $dest_basename; # destination file name + if ($destfileisdir == 1) # is a directory + { + $dest_basename = $src_basename; + } + else + { + $dest_basename = basename($dest_file); + } + $$options{'destDir_srcFile'}{$target_node}{$dest_dir} ||= + $dest_basename =~ s/[\s;]//g; + + # if the filename will be the same at the destination + if ($src_basename eq $dest_basename) + { + $$options{'destDir_srcFile'}{$target_node}{$dest_dir} + {'same_dest_name'} ||= []; + push @{ $$options{'destDir_srcFile'}{$target_node} + {$dest_dir}{'same_dest_name'} }, $newsrcfile; + } + else # changing file names + { + $$options{'destDir_srcFile'}{$target_node}{$dest_dir} + {'diff_dest_name'} ||= {}; + $$options{'destDir_srcFile'}{$target_node}{$dest_dir} + {'diff_dest_name'}{$newsrcfile} = $dest_basename; + } + + } # end of srcfile + } # end of each node + } # end of synclist + } # end processing clauses EXECUTE, APPEND, etc + } #end of processing file close INPUTFILE; if ($process_line == 0) { # no valid lines in the file @@ -5651,10 +5708,11 @@ sub parse_rsync_input_file_on_SN } else { - $$options{'nodes'} = join ',', keys %{$$options{'destDir_srcFile'}}; + $$options{'nodes'} = join ',', keys %{ $$options{'destDir_srcFile'} }; } return 0; } + #------------------------------------------------------------------------------- =head3 @@ -5688,75 +5746,79 @@ sub parse_rsync_input_file_on_SN #------------------------------------------------------------------------------- -sub run_rsync_postscripts +sub run_rsync_postscripts { - my ($rsyncoutput,$syncdir,$options) = @_; - my @rsync_output = @$rsyncoutput; - my @newoutput= (); - my $dshparms; - my $firstpass=1; + my ($rsyncoutput, $syncdir, $options) = @_; + my @rsync_output = @$rsyncoutput; + my @newoutput = (); + my $dshparms; + my $firstpass = 1; foreach my $postsfile (@::postscripts) { - my $tmppostfile = $postsfile ; + my $tmppostfile = $postsfile; # if service node need to add the SNsyncfiledir to the path if (xCAT::Utils->isServiceNode()) { - my $tmpp=$syncdir . $tmppostfile; + my $tmpp = $syncdir . $tmppostfile; $tmppostfile = $tmpp; } + # remove first character for the compare, we have to do this because the # return from rsync is tmp/file1 not /tmp/file1 - substr($tmppostfile,0,1)=""; + substr($tmppostfile, 0, 1) = ""; foreach my $line (@rsync_output) { - my($hostname,$ps) = split(/: /, $line); + my ($hostname, $ps) = split(/: /, $line); chomp $ps; chomp $hostname; - if ($ps eq "rsync") { # this is a line that is not an update - # save output , if firstpass through output + if ($ps eq "rsync") { # this is a line that is not an update + # save output , if firstpass through output if ($firstpass == 1) { push @newoutput, $line; $firstpass = 0; } next; } - if ($tmppostfile eq $ps) { - # build xdsh queue + if ($tmppostfile eq $ps) { + + # build xdsh queue # build host and all scripts to execute - push (@{$dshparms->{'postscripts'} {$postsfile}}, $hostname); + push(@{ $dshparms->{'postscripts'}{$postsfile} }, $hostname); } } } + # now if we have postscripts to run, run xdsh my $out; # my $ranaps=0; # did we run a postscript - foreach my $ps ( keys %{$$dshparms{'postscripts'}}) { + foreach my $ps (keys %{ $$dshparms{'postscripts'} }) { my @nodes; - push (@nodes, @{$$dshparms{'postscripts'}{$ps}}); - my @args=(); + push(@nodes, @{ $$dshparms{'postscripts'}{$ps} }); + my @args = (); if ($$options{'nodestatus'}) { - push @args,"--nodestatus" ; + push @args, "--nodestatus"; } - push @args,"-e"; + push @args, "-e"; # # if on the service node need to add the $syncdir directory to the path # if (xCAT::Utils->isServiceNode()) { - my $tmpp=$syncdir . $ps; - $ps=$tmpp; + my $tmpp = $syncdir . $ps; + $ps = $tmpp; } - push @args,$ps; - $out=xCAT::Utils->runxcmd( { command => ['xdsh'], - node => \@nodes, - arg => \@args, - }, $::SUBREQ, 0,1); + push @args, $ps; + $out = xCAT::Utils->runxcmd({ command => ['xdsh'], + node => \@nodes, + arg => \@args, + }, $::SUBREQ, 0, 1); foreach my $r (@$out) { push(@newoutput, $r); } } return @newoutput; } + #------------------------------------------------------------------------------- =head3 @@ -5792,100 +5854,110 @@ sub run_rsync_postscripts sub bld_and_run_append { - my ($hostnames,$rsyncoutput,$syncdir,$nodesyncfiledir,$options) = @_; - my @hosts = @$hostnames; - my @rsync_output = @$rsyncoutput; - my @newoutput= (); - my $dshparms; - my $firstpass=1; - my $headeradded=0; - my $processappend=0; - + my ($hostnames, $rsyncoutput, $syncdir, $nodesyncfiledir, $options) = @_; + my @hosts = @$hostnames; + my @rsync_output = @$rsyncoutput; + my @newoutput = (); + my $dshparms; + my $firstpass = 1; + my $headeradded = 0; + my $processappend = 0; + $::xdcpappendparms = "$nodesyncfiledir "; # directory to save the original file to append - my $nodesaveorgfiledir=$nodesyncfiledir; - $nodesaveorgfiledir .="/org"; + my $nodesaveorgfiledir = $nodesyncfiledir; + $nodesaveorgfiledir .= "/org"; + # add append directory to the base nodesyncfiledir $nodesyncfiledir .= "/append"; + # build the input appendfile:orgfile parsm foreach my $appendline (@::appendlines) { - if ($appendline =~ /(.+) -> (.+)/) - { - my $appendfile = $1; # append file left of arrow - my $filetoappend = $2; # file to append right of arrow - my $tmpappendfile = $appendfile; - # if service node need to add the syncdir to the path - # for the match - if (xCAT::Utils->isServiceNode()) { - my $tmpp=$syncdir . $tmpappendfile; - $tmpappendfile = $tmpp; - } - # remove first char for the compare, we have to do this because the - # return from rsync is tmp/file1 not /tmp/file1 - substr($tmpappendfile,0,1)=""; - # check to see if this file was rsync'd and to which hosts - foreach my $line (@rsync_output) { - my($hostname,$ps) = split(/: /, $line); - chomp $ps; - chomp $hostname; - if ($ps eq "rsync") { # this is a line that is not an update - # save output , if firstpass through output - if ($firstpass == 1) { - push @newoutput, $line; - $firstpass = 0; - } - next; - } - # build the append script (xdcpappend.sh) parameter list, - # based on all the append files - # that were rsyn'd to at least one node - if ($tmpappendfile eq $ps) { - my $parm="$appendfile:$filetoappend "; - # check to see if the parameter is already in the list - if (!($::xdcpappendparms =~ /$parm/)) { - $::xdcpappendparms .= $parm; - } - $processappend=1; + if ($appendline =~ /(.+) -> (.+)/) + { + my $appendfile = $1; # append file left of arrow + my $filetoappend = $2; # file to append right of arrow + my $tmpappendfile = $appendfile; + # if service node need to add the syncdir to the path + # for the match + if (xCAT::Utils->isServiceNode()) { + my $tmpp = $syncdir . $tmpappendfile; + $tmpappendfile = $tmpp; } - } - } - - } # end for each append line - # add append script to each host to execute. - if ($::appendscript && ($processappend==1)) { - # the append script has been sync'd to the site.nodesynfiledir - my $nodeappendscript = $nodesyncfiledir; - $nodeappendscript .= $::appendscript; - foreach my $host (@hosts) { - push (@{$dshparms->{'appendscripts'} {$nodeappendscript}}, $host); - } - # now run xdsh - my $out; - foreach my $ps ( keys %{$$dshparms{'appendscripts'}}) { - my @nodes; - push (@nodes, @{$$dshparms{'appendscripts'}{$ps}}); - my @args=(); - if ($$options{'nodestatus'}) { - push @args,"--nodestatus" ; - } - push @args,$ps; - push @args,$::xdcpappendparms; - - $out=xCAT::Utils->runxcmd( { command => ['xdsh'], - node => \@nodes, - arg => \@args, - }, $::SUBREQ, 0,1); - foreach my $r (@$out){ + + # remove first char for the compare, we have to do this because the + # return from rsync is tmp/file1 not /tmp/file1 + substr($tmpappendfile, 0, 1) = ""; + + # check to see if this file was rsync'd and to which hosts + foreach my $line (@rsync_output) { + my ($hostname, $ps) = split(/: /, $line); + chomp $ps; + chomp $hostname; + if ($ps eq "rsync") { # this is a line that is not an update + # save output , if firstpass through output + if ($firstpass == 1) { + push @newoutput, $line; + $firstpass = 0; + } + next; + } + + # build the append script (xdcpappend.sh) parameter list, + # based on all the append files + # that were rsyn'd to at least one node + if ($tmpappendfile eq $ps) { + my $parm = "$appendfile:$filetoappend "; + + # check to see if the parameter is already in the list + if (!($::xdcpappendparms =~ /$parm/)) { + $::xdcpappendparms .= $parm; + } + $processappend = 1; + + } + } + } + + } # end for each append line + # add append script to each host to execute. + if ($::appendscript && ($processappend == 1)) { + + # the append script has been sync'd to the site.nodesynfiledir + my $nodeappendscript = $nodesyncfiledir; + $nodeappendscript .= $::appendscript; + foreach my $host (@hosts) { + push(@{ $dshparms->{'appendscripts'}{$nodeappendscript} }, $host); + } + + # now run xdsh + my $out; + foreach my $ps (keys %{ $$dshparms{'appendscripts'} }) { + my @nodes; + push(@nodes, @{ $$dshparms{'appendscripts'}{$ps} }); + my @args = (); + if ($$options{'nodestatus'}) { + push @args, "--nodestatus"; + } + push @args, $ps; + push @args, $::xdcpappendparms; + + $out = xCAT::Utils->runxcmd({ command => ['xdsh'], + node => \@nodes, + arg => \@args, + }, $::SUBREQ, 0, 1); + foreach my $r (@$out) { push(@newoutput, $r); - } - } + } + } } return @newoutput; } + #------------------------------------------------------------------------------- =head3 @@ -5922,111 +5994,121 @@ sub bld_and_run_append sub bld_and_run_merge { - my ($hostnames,$rsyncoutput,$syncdir,$nodesyncfiledir,$options) = @_; - my @hosts = @$hostnames; - my @rsync_output = @$rsyncoutput; - my @newoutput= (); - my $dshparms; - my $firstpass=1; - my $headeradded=0; - my $processmerge=0; - + my ($hostnames, $rsyncoutput, $syncdir, $nodesyncfiledir, $options) = @_; + my @hosts = @$hostnames; + my @rsync_output = @$rsyncoutput; + my @newoutput = (); + my $dshparms; + my $firstpass = 1; + my $headeradded = 0; + my $processmerge = 0; + $::xdcpmergeparms = "$nodesyncfiledir "; - # directory to save the original file to merge - my $nodesaveorgfiledir=$nodesyncfiledir; - $nodesaveorgfiledir .="/org"; + # directory to save the original file to merge + my $nodesaveorgfiledir = $nodesyncfiledir; + $nodesaveorgfiledir .= "/org"; + # add merge directory to the base nodesyncfiledir $nodesyncfiledir .= "/merge"; + # build the input mergefile:orgfile parsm foreach my $mergeline (@::mergelines) { - if ($mergeline =~ /(.+) -> (.+)/) - { - my $mergefile = $1; # merge file left of arrow - my $filetomerge = $2; # file to merge right of arrow - if (($filetomerge ne "/etc/passwd") - && ($filetomerge ne "/etc/group") - && ($filetomerge ne "/etc/shadow")) { + if ($mergeline =~ /(.+) -> (.+)/) + { + my $mergefile = $1; # merge file left of arrow + my $filetomerge = $2; # file to merge right of arrow + if (($filetomerge ne "/etc/passwd") + && ($filetomerge ne "/etc/group") + && ($filetomerge ne "/etc/shadow")) { my $rsp = {}; $rsp->{error}->[0] = "$filetomerge is not either /etc/passwd, /etc/group or /etc/shadow. Those are the only supported files for MERGE"; - xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); - return 1; - - } - my $tmpmergefile = $mergefile; - # if service node need to add the syncdir to the path - # for the match - if (xCAT::Utils->isServiceNode()) { - my $tmpp=$syncdir . $tmpmergefile; - $tmpmergefile = $tmpp; - } - # remove first char for the compare, we have to do this because the - # return from rsync is tmp/file1 not /tmp/file1 - substr($tmpmergefile,0,1)=""; - # check to see if this file was rsync'd and to which hosts - foreach my $line (@rsync_output) { - my($hostname,$ps) = split(/: /, $line); - chomp $ps; - chomp $hostname; - if ($ps eq "rsync") { # this is a line that is not an update - # save output , if firstpass through output - if ($firstpass == 1) { - push @newoutput, $line; - $firstpass = 0; - } - next; - } - # build the merge script (xdcpmerge.sh) parameter list, - # based on all the merge files - # that were rsyn'd to at least one node - if ($tmpmergefile eq $ps) { - my $parm="$mergefile:$filetomerge "; - # check to see if the parameter is already in the list - if (!($::xdcpmergeparms =~ /$parm/)) { - $::xdcpmergeparms .= $parm; - } - $processmerge=1; + xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); + return 1; } - } - } - - } # end for each merge line - # add merge script to each host to execute. If we need to run anything - if ($::mergescript && ($processmerge==1)) { - # the merge script has been sync'd to the site.nodesynfiledir - my $nodemergescript = $nodesyncfiledir; - $nodemergescript .= $::mergescript; - foreach my $host (@hosts) { - push (@{$dshparms->{'mergescripts'} {$nodemergescript}}, $host); - } - # now run xdsh - my $out; - foreach my $ps ( keys %{$$dshparms{'mergescripts'}}) { - my @nodes; - push (@nodes, @{$$dshparms{'mergescripts'}{$ps}}); - - # build the argument list - my @args=(); - - if ($$options{'nodestatus'}) { - push @args,"--nodestatus" ; - } - push @args, $ps; - push @args, $::xdcpmergeparms; - $out=xCAT::Utils->runxcmd( { command => ['xdsh'], - node => \@nodes, - arg => \@args, - }, $::SUBREQ, 0,1); - foreach my $r (@$out){ + my $tmpmergefile = $mergefile; + + # if service node need to add the syncdir to the path + # for the match + if (xCAT::Utils->isServiceNode()) { + my $tmpp = $syncdir . $tmpmergefile; + $tmpmergefile = $tmpp; + } + + # remove first char for the compare, we have to do this because the + # return from rsync is tmp/file1 not /tmp/file1 + substr($tmpmergefile, 0, 1) = ""; + + # check to see if this file was rsync'd and to which hosts + foreach my $line (@rsync_output) { + my ($hostname, $ps) = split(/: /, $line); + chomp $ps; + chomp $hostname; + if ($ps eq "rsync") { # this is a line that is not an update + # save output , if firstpass through output + if ($firstpass == 1) { + push @newoutput, $line; + $firstpass = 0; + } + next; + } + + # build the merge script (xdcpmerge.sh) parameter list, + # based on all the merge files + # that were rsyn'd to at least one node + if ($tmpmergefile eq $ps) { + my $parm = "$mergefile:$filetomerge "; + + # check to see if the parameter is already in the list + if (!($::xdcpmergeparms =~ /$parm/)) { + $::xdcpmergeparms .= $parm; + } + $processmerge = 1; + + } + } + } + + } # end for each merge line + # add merge script to each host to execute. If we need to run anything + if ($::mergescript && ($processmerge == 1)) { + + # the merge script has been sync'd to the site.nodesynfiledir + my $nodemergescript = $nodesyncfiledir; + $nodemergescript .= $::mergescript; + foreach my $host (@hosts) { + push(@{ $dshparms->{'mergescripts'}{$nodemergescript} }, $host); + } + + # now run xdsh + my $out; + foreach my $ps (keys %{ $$dshparms{'mergescripts'} }) { + my @nodes; + push(@nodes, @{ $$dshparms{'mergescripts'}{$ps} }); + + # build the argument list + my @args = (); + + if ($$options{'nodestatus'}) { + push @args, "--nodestatus"; + } + push @args, $ps; + push @args, $::xdcpmergeparms; + $out = xCAT::Utils->runxcmd({ command => ['xdsh'], + node => \@nodes, + arg => \@args, + }, $::SUBREQ, 0, 1); + foreach my $r (@$out) { push(@newoutput, $r); - } - } + } + } } return @newoutput; } + #------------------------------------------------------------------------------- =head3 @@ -6040,55 +6122,59 @@ sub bld_and_run_merge #------------------------------------------------------------------------------- -sub run_always_rsync_postscripts +sub run_always_rsync_postscripts { - my ($hostnames,$syncdir,$options) = @_; - my @hosts = @$hostnames; - my @newoutput= (); - my $dshparms; + my ($hostnames, $syncdir, $options) = @_; + my @hosts = @$hostnames; + my @newoutput = (); + my $dshparms; foreach my $postsfile (@::alwayspostscripts) { - my $tmppostfile = $postsfile ; - - # if service node need to add the SNsyncfiledir to the path - if (xCAT::Utils->isServiceNode()) { - my $tmpp=$syncdir . $tmppostfile; - $tmppostfile = $tmpp; - } + my $tmppostfile = $postsfile; - foreach my $host (@hosts) { - # build xdsh queue - # build host and all scripts to execute - push (@{$dshparms->{'postscripts'} {$postsfile}}, $host); - } + # if service node need to add the SNsyncfiledir to the path + if (xCAT::Utils->isServiceNode()) { + my $tmpp = $syncdir . $tmppostfile; + $tmppostfile = $tmpp; + } + + foreach my $host (@hosts) { + + # build xdsh queue + # build host and all scripts to execute + push(@{ $dshparms->{'postscripts'}{$postsfile} }, $host); + } } + # now if we have postscripts to run, run xdsh my $out; - foreach my $ps ( keys %{$$dshparms{'postscripts'}}) { + foreach my $ps (keys %{ $$dshparms{'postscripts'} }) { my @nodes; + # build the argument list - my @args=(); + my @args = (); if ($$options{'nodestatus'}) { - push @args,"--nodestatus" ; + push @args, "--nodestatus"; } - push @args,"-e"; - # if on the service node need to add the $syncdir directory + push @args, "-e"; + + # if on the service node need to add the $syncdir directory # to the path if (xCAT::Utils->isServiceNode()) { - my $tmps=$syncdir . $ps; - push @args, $tmps; - } else{ - push @args, $ps; + my $tmps = $syncdir . $ps; + push @args, $tmps; + } else { + push @args, $ps; } - push (@nodes, @{$$dshparms{'postscripts'}{$ps}}); - - $out=xCAT::Utils->runxcmd( { command => ['xdsh'], - node => \@nodes, - arg => \@args, - }, $::SUBREQ, 0,1); - foreach my $r (@$out){ - push(@newoutput, $r); + push(@nodes, @{ $$dshparms{'postscripts'}{$ps} }); + + $out = xCAT::Utils->runxcmd({ command => ['xdsh'], + node => \@nodes, + arg => \@args, + }, $::SUBREQ, 0, 1); + foreach my $r (@$out) { + push(@newoutput, $r); } @@ -6096,6 +6182,7 @@ sub run_always_rsync_postscripts } return @newoutput; } + #------------------------------------------------------------------------------- =head3 @@ -6120,10 +6207,10 @@ sub runlocal_on_rootimg { my ($class, $options, $imagename) = @_; my $cmd; - if (xCAT::Utils->isAIX()) { # use xcatchroot - $cmd = "$::XCATROOT/bin/xcatchroot -i $$options{'rootimg'} \"$$options{'command'}\""; + if (xCAT::Utils->isAIX()) { # use xcatchroot + $cmd = "$::XCATROOT/bin/xcatchroot -i $$options{'rootimg'} \"$$options{'command'}\""; } else { - $cmd = "chroot $$options{'rootimg'} $$options{'command'}"; + $cmd = "chroot $$options{'rootimg'} $$options{'command'}"; } my @output = xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) @@ -6237,8 +6324,8 @@ sub runDsh_api { xCAT::MsgUtils->message( "E", - "xdsh command: $$optionsRef{'command'} failed on nodes:$::DSH_API_NODES_FAILED." - ); +"xdsh command: $$optionsRef{'command'} failed on nodes:$::DSH_API_NODES_FAILED." + ); } } @@ -6316,7 +6403,7 @@ sub runDcp_api elsif (ref($optionsRef->{'source'} eq "ARRAY")) { $optionsRef->{'source'} = join $::__DCP_DELIM, - @{$optionsRef->{'source'}}; + @{ $optionsRef->{'source'} }; } $::RUNCMD_RC = xCAT::DSHCLI->execute_dcp($optionsRef); @@ -6359,7 +6446,7 @@ sub runDcp_api if (!$DSHCLI::NO_MESSAGES) { xCAT::MsgUtils->message("E", - "dcp command failed, Return code=$::RUNCMD_RC."); + "dcp command failed, Return code=$::RUNCMD_RC."); } } diff --git a/perl-xCAT/xCAT/DSHContext.pm b/perl-xCAT/xCAT/DSHContext.pm index 41b22cd0a..c1fbdc37f 100644 --- a/perl-xCAT/xCAT/DSHContext.pm +++ b/perl-xCAT/xCAT/DSHContext.pm @@ -8,64 +8,64 @@ use strict; require xCAT::DSHCore; sub valid_context { - return 1; + return 1; } sub context_defaults { - my %defaults = (); + my %defaults = (); - $defaults{'NodeRemoteShell'} = '/usr/bin/rsh'; - return \%defaults; + $defaults{'NodeRemoteShell'} = '/usr/bin/rsh'; + return \%defaults; } sub context_properties { - return; + return; } sub all_devices { - return undef; + return undef; } sub all_devicegroups { - return undef; + return undef; } sub all_nodes { - return undef; + return undef; } sub all_nodegroups { - return undef; + return undef; } sub devicegroup_members { - return undef; + return undef; } sub nodegroup_members { - return undef; + return undef; } sub resolve_device { - return undef; + return undef; } sub resolve_node { - return 1; + return 1; } sub verify_target { - return 127; + return 127; } sub verify_mode { - return "NOXCAT"; + return "NOXCAT"; } sub resolve_hostnames { - my ( $class, $resolved_targets, $unresolved_targets, @target_list ) = @_; - xCAT::DSHCore->resolve_hostnames( undef, $resolved_targets, $unresolved_targets, - undef, @target_list ); + my ($class, $resolved_targets, $unresolved_targets, @target_list) = @_; + xCAT::DSHCore->resolve_hostnames(undef, $resolved_targets, $unresolved_targets, + undef, @target_list); } 1; diff --git a/perl-xCAT/xCAT/DSHCore.pm b/perl-xCAT/xCAT/DSHCore.pm index 9e940ca01..4ac392bdf 100644 --- a/perl-xCAT/xCAT/DSHCore.pm +++ b/perl-xCAT/xCAT/DSHCore.pm @@ -65,7 +65,7 @@ sub fork_no_output select(STDERR); $| = 1; - if (!(exec {$command[0]} @command)) + if (!(exec { $command[0] } @command)) { return (-4, undef); } @@ -113,7 +113,7 @@ sub fork_no_output sub fork_output { my ($class, $fork_id, @command) = @_; -no strict; + no strict; my $pid; my %pipes = (); @@ -144,7 +144,7 @@ no strict; select(STDERR); $| = 1; - if (!(exec {$command[0]} @command)) + if (!(exec { $command[0] } @command)) { return (-4, undef); } @@ -156,7 +156,7 @@ no strict; } return ($pid, *$rout_fh, *$rerr_fh, *$wout_fh, *$werr_fh); -use strict; + use strict; } @@ -197,7 +197,7 @@ use strict; sub fork_output_for_commands { my ($class, $fork_id, @commands) = @_; -no strict; + no strict; my $pid; my %pipes = (); @@ -227,15 +227,15 @@ no strict; $| = 1; select(STDERR); $| = 1; - if ( @commands > 1 ) { - my $command0 = shift(@commands); - my @exe_command0_process = xCAT::DSHCore->fork_no_output($fork_id, @$command0); + if (@commands > 1) { + my $command0 = shift(@commands); + my @exe_command0_process = xCAT::DSHCore->fork_no_output($fork_id, @$command0); waitpid($exe_command0_process[0], undef); } - + my $t_command = shift(@commands); - my @command = @$t_command; - if (!(exec {$command[0]} @command)) + my @command = @$t_command; + if (!(exec { $command[0] } @command)) { return (-4, undef); } @@ -247,7 +247,7 @@ no strict; } return ($pid, *$rout_fh, *$rerr_fh, *$wout_fh, *$werr_fh); -use strict; + use strict; } @@ -289,7 +289,8 @@ use strict; #--------------------------------------------------------------------------- # NOTE: global environment $::__DSH_LAST_LINE} only can be used in DSHCore::pipe_handler and DSHCore::pipe_handler_buffer -$::__DSH_LAST_LINE = undef; +$::__DSH_LAST_LINE = undef; + sub pipe_handler { my ($class, $options, $target_properties, $read_fh, $buffer_size, $label, @@ -298,8 +299,8 @@ sub pipe_handler my $line; my $target_hostname; - my $eof_reached = undef; - my $cust_rc_deal =0; + my $eof_reached = undef; + my $cust_rc_deal = 0; if ($::USER_POST_CMD) { @@ -316,7 +317,7 @@ sub pipe_handler } while (sysread($read_fh, $line, $buffer_size) != 0 - || ($eof_reached = 1)) + || ($eof_reached = 1)) { last if ($eof_reached && (!defined($::__DSH_LAST_LINE->{$label}))); @@ -349,13 +350,15 @@ sub pipe_handler # Dump the last line at the beginning of current buffer if ($::__DSH_LAST_LINE->{$label}) { - unshift @lines, "$::__DSH_LAST_LINE->{$label}" ; + unshift @lines, "$::__DSH_LAST_LINE->{$label}"; } + # Pop current buffer to $::__DSH_LAST_LINE->{$label} - if($line) + if ($line) { - $::__DSH_LAST_LINE->{$label} = $lines[scalar @lines - 1]; + $::__DSH_LAST_LINE->{$label} = $lines[ scalar @lines - 1 ]; pop @lines; + # Skip this loop if array @lines is empty. if (scalar @lines == 0) { @@ -377,20 +380,24 @@ sub pipe_handler $line =~ s/:DSH_TARGET_RC=$target_rc:\n//g; $$target_properties{'target-rc'} = $target_rc; } - if ( $::__DSH_LAST_LINE->{$label} =~ /DSH_RC/ && $cust_rc_deal) { + if ($::__DSH_LAST_LINE->{$label} =~ /DSH_RC/ && $cust_rc_deal) { my $target_rc = undef; + # Get the number in the last line - $line =~ /[\D]*([0-9]+)\s*$/ ; + $line =~ /[\D]*([0-9]+)\s*$/; $target_rc = $1; $$target_properties{'target-rc'} = $target_rc; + # Remove the last line $line =~ s/$target_rc\s*\n$//g; + #$line = $line . "## ret=$target_rc"; # Clean up $::__DSH_LAST_LINE->{$label} - undef $::__DSH_LAST_LINE->{$label} ; + undef $::__DSH_LAST_LINE->{$label}; + # when '-z' is specified, display return code $::DSH_EXIT_STATUS && - ($line .="Remote_command_rc = $target_rc"); + ($line .= "Remote_command_rc = $target_rc"); } if ($line ne '') @@ -417,9 +424,10 @@ sub pipe_handler $line =~ s/$label//g; } - my $rsp={}; + my $rsp = {}; $rsp->{data}->[0] = $line; xCAT::MsgUtils->message("D", $rsp, $::CALLBACK); + #print $write_fh $line; } @@ -430,10 +438,10 @@ sub pipe_handler pop @write_fhs; close $output_file || print STDOUT - "dsh> Error_file_closed $$target_properties{hostname} $output_file\n"; - my $rsp={}; +"dsh> Error_file_closed $$target_properties{hostname} $output_file\n"; + my $rsp = {}; $rsp->{error}->[0] = - "Error_file_closed $$target_properties{hostname $output_file}.\n"; +"Error_file_closed $$target_properties{hostname $output_file}.\n"; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); ($output_file == $$target_properties{'output-fh'}) && delete $$target_properties{'output-fh'}; @@ -496,7 +504,7 @@ sub pipe_handler_buffer my $line; my $eof_reached = undef; - my $cust_rc_deal =0; + my $cust_rc_deal = 0; if ($::USER_POST_CMD) { # If user provide post-command to display return code, @@ -511,8 +519,8 @@ sub pipe_handler_buffer $cust_rc_deal = 1; } - while ( (sysread($read_fh, $line, $buffer_size) != 0) - || ($eof_reached = 1)) + while ((sysread($read_fh, $line, $buffer_size) != 0) + || ($eof_reached = 1)) { last if ($eof_reached && (!defined($::__DSH_LAST_LINE->{$label}))); if ($line =~ /^\n$/ && scalar(@$write_buffer) == 0) @@ -544,13 +552,15 @@ sub pipe_handler_buffer # Dump the last line at the beginning of current buffer if ($::__DSH_LAST_LINE->{$label}) { - unshift @lines, "$::__DSH_LAST_LINE->{$label}" ; + unshift @lines, "$::__DSH_LAST_LINE->{$label}"; undef $::__DSH_LAST_LINE->{$label} } if ($line) { + # Pop current buffer to $::__DSH_LAST_LINE->{$label} - $::__DSH_LAST_LINE->{$label} = $lines[scalar @lines - 1]; + $::__DSH_LAST_LINE->{$label} = $lines[ scalar @lines - 1 ]; pop @lines; + # Skip this loop if array @lines is empty. if (scalar @lines == 0) { @@ -572,20 +582,24 @@ sub pipe_handler_buffer $line =~ s/:DSH_TARGET_RC=$target_rc:\n//g; $$target_properties{'target-rc'} = $target_rc; } - if ( $::__DSH_LAST_LINE->{$label} =~ /DSH_RC/ && $cust_rc_deal) { + if ($::__DSH_LAST_LINE->{$label} =~ /DSH_RC/ && $cust_rc_deal) { my $target_rc = undef; + # Get the number in the last line - $line =~ /[\D]*([0-9]+)\s*$/ ; + $line =~ /[\D]*([0-9]+)\s*$/; $target_rc = $1; $$target_properties{'target-rc'} = $target_rc; + # Remove the last line $line =~ s/$target_rc\s*\n$//g; + #$line = $line . "## ret=$target_rc"; # Clean up $::__DSH_LAST_LINE->{$label} - undef $::__DSH_LAST_LINE->{$label} ; + undef $::__DSH_LAST_LINE->{$label}; + # when '-z' is specified, display return code $::DSH_EXIT_STATUS && - ($line .="Remote_command_rc = $target_rc"); + ($line .= "Remote_command_rc = $target_rc"); } if ($line ne '') @@ -696,35 +710,37 @@ sub pping_hostnames my ($class, @hostnames) = @_; my $hostname_list = join ",", @hostnames; + # read site table, usefping attribute # if set then run pping -f to use fping # this fixes a broken nmap in Redhat 6.2 with ip alias (3512) - my $cmd="$::XCATROOT/bin/pping $hostname_list"; # default - my @usefping=xCAT::TableUtils->get_site_attribute("usefping"); + my $cmd = "$::XCATROOT/bin/pping $hostname_list"; # default + my @usefping = xCAT::TableUtils->get_site_attribute("usefping"); if ((defined($usefping[0])) && ($usefping[0] eq "1")) { - $cmd = "$::XCATROOT/bin/pping -f $hostname_list"; + $cmd = "$::XCATROOT/bin/pping -f $hostname_list"; } + #my $rsp={}; #$rsp->{data}->[0] = "running command $cmd"; #xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); my @output = xCAT::Utils->runcmd($cmd, -1); - if ($::RUNCMD_RC !=0) { - my $rsp={}; + if ($::RUNCMD_RC != 0) { + my $rsp = {}; $rsp->{error}->[0] = "Error from pping"; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); - } - $::RUNCMD_RC =0; # reset + } + $::RUNCMD_RC = 0; # reset my @no_response = (); foreach my $line (@output) { my ($hostname, $result) = split ':', $line; my ($token, $status) = split ' ', $result; chomp($token); - if ($token ne 'ping') { - push @no_response, $hostname; - } + if ($token ne 'ping') { + push @no_response, $hostname; + } } return @no_response; diff --git a/perl-xCAT/xCAT/DSHRemoteShell.pm b/perl-xCAT/xCAT/DSHRemoteShell.pm index b114a55c7..64523c32f 100644 --- a/perl-xCAT/xCAT/DSHRemoteShell.pm +++ b/perl-xCAT/xCAT/DSHRemoteShell.pm @@ -3,14 +3,15 @@ package xCAT::DSHRemoteShell; use strict; + sub remote_shell_command { - return undef; + return undef; } sub remote_copy_command { - return undef; + return undef; } 1; diff --git a/perl-xCAT/xCAT/DiscoveryUtils.pm b/perl-xCAT/xCAT/DiscoveryUtils.pm index 1e89fcd9d..874387517 100644 --- a/perl-xCAT/xCAT/DiscoveryUtils.pm +++ b/perl-xCAT/xCAT/DiscoveryUtils.pm @@ -5,7 +5,7 @@ package xCAT::DiscoveryUtils; use strict; use XML::Simple; -$XML::Simple::PREFERRED_PARSER='XML::Parser'; +$XML::Simple::PREFERRED_PARSER = 'XML::Parser'; use xCAT::MsgUtils; @@ -16,9 +16,9 @@ use xCAT::MsgUtils; =cut sub update_discovery_data { - my $class = shift; + my $class = shift; my $request = shift; - + my %disdata; my %otherdata; @@ -33,9 +33,9 @@ sub update_discovery_data { } #discoverytime - my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time); + my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time); my $currtime = sprintf("%02d-%02d-%04d %02d:%02d:%02d", - $mon + 1, $mday, $year + 1900, $hour, $min, $sec); + $mon + 1, $mday, $year + 1900, $hour, $min, $sec); $disdata{'discoverytime'} = $currtime; foreach my $attr (keys %$request) { @@ -44,9 +44,10 @@ sub update_discovery_data { } elsif ($attr =~ /^(node|uuid|arch|cpucount|cputype|memory|mtm|serial)$/) { $disdata{$attr} = $request->{$attr}->[0]; } elsif ($attr eq 'nic') { + # Set the nics attributes - foreach my $nic (@{$request->{nic}}) { - my $nicname = $nic->{'devname'}->[0]; + foreach my $nic (@{ $request->{nic} }) { + my $nicname = $nic->{'devname'}->[0]; foreach my $nicattr (keys %$nic) { my $tbattr; if ($nicattr eq 'driver') { @@ -69,27 +70,28 @@ sub update_discovery_data { if ($tbattr) { if ($disdata{$tbattr}) { - $disdata{$tbattr} .= ','.$nicname.'!'.$nic->{$nicattr}->[0]; + $disdata{$tbattr} .= ',' . $nicname . '!' . $nic->{$nicattr}->[0]; } else { - $disdata{$tbattr} = $nicname.'!'.$nic->{$nicattr}->[0]; + $disdata{$tbattr} = $nicname . '!' . $nic->{$nicattr}->[0]; } } } } } else { + # store to otherdata for the not parsed attributes $otherdata{$attr} = $request->{$attr}; } } if (keys %otherdata) { - $disdata{'otherdata'} = XMLout(\%otherdata,RootName=>'discoveryotherdata' ,NoAttr=>1); + $disdata{'otherdata'} = XMLout(\%otherdata, RootName => 'discoveryotherdata', NoAttr => 1); } my $distab = xCAT::Table->new('discoverydata'); if ($distab) { - $distab->setAttribs({uuid=>$request->{'uuid'}->[0]},\%disdata); - $distab->close(); + $distab->setAttribs({ uuid => $request->{'uuid'}->[0] }, \%disdata); + $distab->close(); } } diff --git a/perl-xCAT/xCAT/Enabletrace.pm b/perl-xCAT/xCAT/Enabletrace.pm index ad75a8280..3730f7cfe 100644 --- a/perl-xCAT/xCAT/Enabletrace.pm +++ b/perl-xCAT/xCAT/Enabletrace.pm @@ -7,47 +7,49 @@ use Filter::Util::Call; our @ISA = qw(Exporter); our @EXPORT_OK = qw(loadtrace filter); -sub loadtrace{ - my (undef, $filename) = caller(); - my (%args) = ( - filename => $filename, - inside => 0, - lineno => 0, - ); +sub loadtrace { + my (undef, $filename) = caller(); + my (%args) = ( + filename => $filename, + inside => 0, + lineno => 0, + ); - filter_add(bless \%args); + filter_add(bless \%args); } sub filter { - my ($self) = @_; - my $line= filter_read(); - $self->{lineno}++; - # deal with EOF/error first - if ($line<= 0) { + my ($self) = @_; + my $line = filter_read(); + $self->{lineno}++; + + # deal with EOF/error first + if ($line <= 0) { + if ($self->{inside}) { + die "Do not find the END of the trace block. [$self->{filename}:$self->{lineno}]"; + } + return $line; + } if ($self->{inside}) { - die "Do not find the END of the trace block. [$self->{filename}:$self->{lineno}]"; - } - return $line; - } - if ($self->{inside}) { - if (/^\s*##\s*TRACE_BEGIN/ ) { - die "The trace block is nested. [$self->{filename}:$self->{lineno}]"; + if (/^\s*##\s*TRACE_BEGIN/) { + die "The trace block is nested. [$self->{filename}:$self->{lineno}]"; + } elsif (/^\s*##\s*TRACE_END/) { + $self->{inside} = 0; + } else { + + # remove the #.. at the begin of the line + s/^\s*#+//; + } + } elsif (/^\s*##\s*TRACE_BEGIN/) { + $self->{inside} = 1; } elsif (/^\s*##\s*TRACE_END/) { - $self->{inside} = 0; - } else { - # remove the #.. at the begin of the line - s/^\s*#+//; + die "Do not see the BEGIN of the trace block. [$self->{filename}:$self->{lineno}]"; + } elsif (/^\s*##\s*TRACE_LINE/) { + s/^\s*##\s*TRACE_LINE//; } - } elsif ( /^\s*##\s*TRACE_BEGIN/ ) { - $self->{inside} = 1; - } elsif ( /^\s*##\s*TRACE_END/ ) { - die "Do not see the BEGIN of the trace block. [$self->{filename}:$self->{lineno}]"; - } elsif ( /^\s*##\s*TRACE_LINE/ ) { - s/^\s*##\s*TRACE_LINE//; - } return $line; - } +} 1; diff --git a/perl-xCAT/xCAT/ExtTab.pm b/perl-xCAT/xCAT/ExtTab.pm index bc0f05c9d..f97312e13 100644 --- a/perl-xCAT/xCAT/ExtTab.pm +++ b/perl-xCAT/xCAT/ExtTab.pm @@ -2,93 +2,100 @@ # IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html #------------------------------------------------------- package xCAT::ExtTab; + BEGIN { -$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; } -# + +# #NO xCAT perl library routines should be used in this begin block -#(i.e. MsgUtils,Utils, etc) -# +#(i.e. MsgUtils,Utils, etc) +# #use lib "$::XCATROOT/lib/perl"; use File::Path; -%ext_tabspec=(); -%ext_defspec=(); +%ext_tabspec = (); +%ext_defspec = (); # loads user defined table spec. They are stored under /opt/xcat/lib/perl/xCAT_schema directory -my $path="$::XCATROOT/lib/perl/xCAT_schema"; -my $filelist; # no specific files -my @extSchema = &get_filelist($path, $filelist,"pm"); +my $path = "$::XCATROOT/lib/perl/xCAT_schema"; +my $filelist; # no specific files +my @extSchema = &get_filelist($path, $filelist, "pm"); + # print "\nextSchema=@extSchema\n"; foreach (@extSchema) { /.*\/([^\/]*).pm$/; - my $file=$_; + my $file = $_; my $modname = $1; no strict 'refs'; my $warning; - # `logger -t xcat processing $_`; - eval {require($_)}; - if ($@) { - $warning ="Warning: The user defined database table schema file $file cannot be located or has compiling errors.\n"; + + # `logger -t xcat processing $_`; + eval { require($_) }; + if ($@) { + $warning = "Warning: The user defined database table schema file $file cannot be located or has compiling errors.\n"; print $warning; - `logger -p local4.warning -t xcat $warning`; - next; - } - if (${"xCAT_schema::" . "$modname" . "::"}{tabspec}) { - my %tabspec=%{${"xCAT_schema::" . "$modname" . "::"}{tabspec}}; - foreach my $tabname (keys(%tabspec)) { - if (exists($ext_tabspec{$tabname})) { - $warning = "Warning: File $file: the table name $tabname is used by other applications. Please rename the table.\n"; - print $warning; - `logger -p local4.warning -t xcat $warning`; - } else { - $ext_tabspec{$tabname}=$tabspec{$tabname}; - } - } - } else { - $warning ="\n Warning: Cannot find \%tabspec variable in the user defined database table schema file $file\n"; - print $warning; - `logger -p local4.warning -t xcat $warning`; + `logger -p local4.warning -t xcat $warning`; + next; } - + if (${ "xCAT_schema::" . "$modname" . "::" }{tabspec}) { + my %tabspec = %{ ${ "xCAT_schema::" . "$modname" . "::" }{tabspec} }; + foreach my $tabname (keys(%tabspec)) { + if (exists($ext_tabspec{$tabname})) { + $warning = "Warning: File $file: the table name $tabname is used by other applications. Please rename the table.\n"; + print $warning; + `logger -p local4.warning -t xcat $warning`; + } else { + $ext_tabspec{$tabname} = $tabspec{$tabname}; + } + } + } else { + $warning = "\n Warning: Cannot find \%tabspec variable in the user defined database table schema file $file\n"; + print $warning; + `logger -p local4.warning -t xcat $warning`; + } + #get the defspec from each file and merge them into %ext_defspec - if (${"xCAT_schema::" . "$modname" . "::"}{defspec}) { - my %defspec=%{${"xCAT_schema::" . "$modname" . "::"}{defspec}}; - foreach my $objname (keys(%defspec)) { - if (exists($defspec{$objname}->{'attrs'})) { - if (exists($ext_defspec{$objname})) { + if (${ "xCAT_schema::" . "$modname" . "::" }{defspec}) { + my %defspec = %{ ${ "xCAT_schema::" . "$modname" . "::" }{defspec} }; + foreach my $objname (keys(%defspec)) { + if (exists($defspec{$objname}->{'attrs'})) { + if (exists($ext_defspec{$objname})) { + #print "insert\n"; - my @attr_new=@{$defspec{$objname}->{'attrs'}}; - my @attr=@{$ext_defspec{$objname}->{'attrs'}}; - my %tmp_hash=(); - foreach my $orig (@attr) { - my $attrname=$orig->{attr_name}; - $tmp_hash{$attrname}=1; - } - foreach my $h (@attr_new) { - my $attrname=$h->{attr_name}; - if (exists($tmp_hash{$attrname})) { - $warning= " Warning: Conflict when adding user defined defspec from file $file. Attribute name $attrname is already defined in object $objname. \n"; + my @attr_new = @{ $defspec{$objname}->{'attrs'} }; + my @attr = @{ $ext_defspec{$objname}->{'attrs'} }; + my %tmp_hash = (); + foreach my $orig (@attr) { + my $attrname = $orig->{attr_name}; + $tmp_hash{$attrname} = 1; + } + foreach my $h (@attr_new) { + my $attrname = $h->{attr_name}; + if (exists($tmp_hash{$attrname})) { + $warning = " Warning: Conflict when adding user defined defspec from file $file. Attribute name $attrname is already defined in object $objname. \n"; print $warning; - `logger -p local4.warning -t xcat $warning`; - } else { - #print "\ngot here objname=$objname, attrname=" . $h->{attr_name} . "\n"; - push(@{$ext_defspec{$objname}->{'attrs'}}, $h); - } - } - } else { - #print "\ngot here objname=$objname, file=$file\n"; - $ext_defspec{$objname}=$defspec{$objname}; - } - } - } - } - -} #foreach + `logger -p local4.warning -t xcat $warning`; + } else { + + #print "\ngot here objname=$objname, attrname=" . $h->{attr_name} . "\n"; + push(@{ $ext_defspec{$objname}->{'attrs'} }, $h); + } + } + } else { + + #print "\ngot here objname=$objname, file=$file\n"; + $ext_defspec{$objname} = $defspec{$objname}; + } + } + } + } + +} #foreach #print out the defspec #print "\nexternal defspec:\n"; @@ -98,9 +105,10 @@ foreach (@extSchema) { # foreach my $h (@attr) { # print " " . $h->{attr_name} . "\n"; # } -#} +#} #------------------------------------------------------- + =head1 xCAT::ExtTab Handles user defined database tables. @@ -117,6 +125,7 @@ foreach (@extSchema) { =cut + #------------------------------------------------------- sub updateTables @@ -124,11 +133,12 @@ sub updateTables #print "\nupdateTables\n"; #print "\n"; foreach (keys %ext_tabspec) { - my $table= xCAT::Table->new($_,-create=>1); - my $rc=$table->updateschema(); + my $table = xCAT::Table->new($_, -create => 1); + my $rc = $table->updateschema(); $table->close(); } } + #-------------------------------------------------------------------------- =head3 @@ -159,7 +169,7 @@ sub updateTables sub get_filelist { - use File::Basename; + use File::Basename; my $directory = shift; my $files = shift; my $ext = shift; @@ -191,30 +201,31 @@ sub get_filelist my @list = glob($directory . "*.$ext"); # all files foreach my $file (@list) { - my $filename= basename($file); # strip filename - my($name,$ext1) = split '\.', $filename; - my($tmpname,$ext2) = split '\_', $name; - if ($ext2 eq $dbname) # matches the database + my $filename = basename($file); # strip filename + my ($name, $ext1) = split '\.', $filename; + my ($tmpname, $ext2) = split '\_', $name; + if ($ext2 eq $dbname) # matches the database { push @filelist, $file; } else { - if ($ext2 eq "") # no database designated + if ($ext2 eq "") # no database designated { push @filelist, $file; - } else { # if not one of the databases, they just have _ in - # the file name - if ($ext2 ne "db2" && $ext2 ne "mysql" && $ext2 ne "pgsql" && $ext2 ne "sqlite" ) { + } else { # if not one of the databases, they just have _ in + # the file name + if ($ext2 ne "db2" && $ext2 ne "mysql" && $ext2 ne "pgsql" && $ext2 ne "sqlite") { push @filelist, $file; - } + } } - } - $ext2 = ""; - $ext1 = ""; + } + $ext2 = ""; + $ext1 = ""; } return @filelist; } + #-------------------------------------------------------------------------- =head3 @@ -245,12 +256,12 @@ sub get_xcatcfg my $xcatcfg = (defined $ENV{'XCATCFG'} ? $ENV{'XCATCFG'} : ''); unless ($xcatcfg) { if (-r "/etc/xcat/cfgloc") { - my $cfgl; - open($cfgl,"<","/etc/xcat/cfgloc"); - $xcatcfg = <$cfgl>; - close($cfgl); - chomp($xcatcfg); - $ENV{'XCATCFG'}=$xcatcfg; #Store it in env to avoid many file reads + my $cfgl; + open($cfgl, "<", "/etc/xcat/cfgloc"); + $xcatcfg = <$cfgl>; + close($cfgl); + chomp($xcatcfg); + $ENV{'XCATCFG'} = $xcatcfg; #Store it in env to avoid many file reads } } if ($xcatcfg =~ /^$/) diff --git a/perl-xCAT/xCAT/FSPUtils.pm b/perl-xCAT/xCAT/FSPUtils.pm index 6072f6a25..5320078b6 100644 --- a/perl-xCAT/xCAT/FSPUtils.pm +++ b/perl-xCAT/xCAT/FSPUtils.pm @@ -10,7 +10,7 @@ BEGIN # if AIX - make sure we include perl 5.8.2 in INC path. # Needed to find perl dependencies shipped in deps tarball. if ($^O =~ /^aix/i) { - unshift(@INC, qw(/usr/opt/perl5/lib/5.8.2/aix-thread-multi /usr/opt/perl5/lib/5.8.2 /usr/opt/perl5/lib/site_perl/5.8.2/aix-thread-multi /usr/opt/perl5/lib/site_perl/5.8.2)); + unshift(@INC, qw(/usr/opt/perl5/lib/5.8.2/aix-thread-multi /usr/opt/perl5/lib/5.8.2 /usr/opt/perl5/lib/site_perl/5.8.2/aix-thread-multi /usr/opt/perl5/lib/site_perl/5.8.2)); } use lib "$::XCATROOT/lib/perl"; @@ -24,12 +24,13 @@ require xCAT::NetworkUtils; require xCAT::Schema; require xCAT::Utils; require xCAT::TableUtils; + #use Data::Dumper; require xCAT::NodeRange; use xCAT::MsgUtils qw(verbose_message); - - #------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- =head3 getHcpAttribs Description: @@ -50,58 +51,59 @@ use xCAT::MsgUtils qw(verbose_message); =cut #------------------------------------------------------------------------------- - -sub getHcpAttribs + +sub getHcpAttribs { my $request = shift; - my $tabs = shift; - my %ppchash ; - my %vpd ; - - my @vs = $tabs->{vpd}->getAllNodeAttribs(['node', 'side']); - for my $entry ( @vs ) { + my $tabs = shift; + my %ppchash; + my %vpd; + + my @vs = $tabs->{vpd}->getAllNodeAttribs([ 'node', 'side' ]); + for my $entry (@vs) { my $tmp_node = $entry->{node}; my $tmp_side = $entry->{side}; - if(defined($tmp_node) && defined($tmp_side)) { - $vpd{$tmp_node} = $tmp_side ; - } + if (defined($tmp_node) && defined($tmp_side)) { + $vpd{$tmp_node} = $tmp_side; + } } - - my @ps = $tabs->{ppc}->getAllNodeAttribs(['node','parent','nodetype','hcp','id']); - for my $entry ( @ps ) { + + my @ps = $tabs->{ppc}->getAllNodeAttribs([ 'node', 'parent', 'nodetype', 'hcp', 'id' ]); + for my $entry (@ps) { my $tmp_parent = $entry->{parent}; - my $tmp_node = $entry->{node}; - my $tmp_type = $entry->{nodetype}; - if(defined($tmp_node) && defined($tmp_type) && ($tmp_type =~ /^(fsp|bpa)$/ && $tmp_parent) ) { - push @{$ppchash{$tmp_parent}{children}}, $tmp_node; - #push @{$ppchash{$tmp_parent}}, $tmp_node; + my $tmp_node = $entry->{node}; + my $tmp_type = $entry->{nodetype}; + if (defined($tmp_node) && defined($tmp_type) && ($tmp_type =~ /^(fsp|bpa)$/ && $tmp_parent)) { + push @{ $ppchash{$tmp_parent}{children} }, $tmp_node; + + #push @{$ppchash{$tmp_parent}}, $tmp_node; } if (defined($tmp_node) && defined($tmp_type) && ($tmp_type eq "blade") && defined($entry->{hcp})) { - push @{$ppchash{$tmp_node}{children}}, $entry->{hcp}; + push @{ $ppchash{$tmp_node}{children} }, $entry->{hcp}; } if (defined($tmp_node) && defined($entry->{id}) && defined($tmp_parent) && defined($tmp_type) && ($tmp_type eq "lpar")) { $ppchash{$tmp_parent}{mapping}{$tmp_node} = $entry->{id}; } - #if(exists($ppchash{$tmp_node})) { - # if( defined($tmp_type) ) { - # #push @{$ppchash{$tmp_node}{type}}, $tmp_type; - # } else { - # my %output; - # my $msg = "no type for $tmp_type in the ppc table."; - # $output{errorcode} = 1; - # $output{data} = $msg; - # $request->{callback}->( \%output ); - # } - #} - } - - $request->{ppc}=\%ppchash ; - $request->{vpd}=\%vpd ; - + #if(exists($ppchash{$tmp_node})) { + # if( defined($tmp_type) ) { + # #push @{$ppchash{$tmp_node}{type}}, $tmp_type; + # } else { + # my %output; + # my $msg = "no type for $tmp_type in the ppc table."; + # $output{errorcode} = 1; + # $output{data} = $msg; + # $request->{callback}->( \%output ); + # } + #} + } + + $request->{ppc} = \%ppchash; + $request->{vpd} = \%vpd; + } - - #------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- =head3 getIPaddress Description: @@ -129,12 +131,12 @@ sub getHcpAttribs =cut #------------------------------------------------------------------------------- - -sub getIPaddress + +sub getIPaddress { -# require xCAT::Table; + # require xCAT::Table; my $request = shift; - my $type = shift; + my $type = shift; my $nodetocheck = shift; my $port = shift; if (xCAT::NetworkUtils::isIpaddr($nodetocheck)) { @@ -144,82 +146,85 @@ sub getIPaddress if (!defined($port)) { $port = "[0|1]"; } - + my $ppc = $request->{ppc}; my $vpd = $request->{vpd}; - -# only need to parse IP addresses for Frame/CEC/BPA/FSP + + # only need to parse IP addresses for Frame/CEC/BPA/FSP #my $type = xCAT::DBobjUtils->getnodetype($nodetocheck); - #my $type = $$attrs[4]; + #my $type = $$attrs[4]; if ($type) { my @children; my %node_side_pairs = (); - my $children_num = 0; + my $children_num = 0; my $parent; if ($type eq "bpa" or $type eq "fsp") { - + push @children, $nodetocheck; - - #my $tmp_s = $vpdtab->getNodeAttribs($nodetocheck, ['side']); - my $tmp_s = $vpd->{$nodetocheck}; + + #my $tmp_s = $vpdtab->getNodeAttribs($nodetocheck, ['side']); + my $tmp_s = $vpd->{$nodetocheck}; if ($tmp_s and $tmp_s =~ /(A|B)-\d/i) { - $side = $1; # get side for the fsp - + $side = $1; # get side for the fsp + } else { return -3; } } elsif ($type eq "frame" or $type eq "cec" or ($type =~ /lpar/i)) { + #In DFM - #1. when the node type is frame, its hcp( $nodetocheck ) is frame, - #and it will get the BPAs IPs for the Frame. - #2. when the node type is CEC, its hcp( $nodetocheck ) is CEC, - #and it will get the FSPs IPs for the CEC. - #3. when the node type is lpar, its hcp is the CEC. - #the $nodetocheck is its' hcp. So set $nodetocheck to $parent variable. - #And then get the FSPs IPs for the CEC. + #1. when the node type is frame, its hcp( $nodetocheck ) is frame, + #and it will get the BPAs IPs for the Frame. + #2. when the node type is CEC, its hcp( $nodetocheck ) is CEC, + #and it will get the FSPs IPs for the CEC. + #3. when the node type is lpar, its hcp is the CEC. + #the $nodetocheck is its' hcp. So set $nodetocheck to $parent variable. + #And then get the FSPs IPs for the CEC. $parent = $nodetocheck; } elsif ($type eq "blade") { return $ppc->{$nodetocheck}->{children}->[0]; } else { return undef; } - if( @children == 0 ) { - if( exists($ppc->{$parent} ) ) { - #for cec/frame, get the FSPs/BPAs from the hash we built in getHcpAttribs() before. - @children = @{$ppc->{$parent}->{children}}; + if (@children == 0) { + if (exists($ppc->{$parent})) { + + #for cec/frame, get the FSPs/BPAs from the hash we built in getHcpAttribs() before. + @children = @{ $ppc->{$parent}->{children} }; } else { - return undef; - } - } - foreach my $tmp_n( @children) { + return undef; + } + } + foreach my $tmp_n (@children) { my $tmp_s = $vpd->{$tmp_n}; if ($tmp_s and $tmp_s =~ /^$side-$port$/i) { $tmp_s =~ s/a/A/; $tmp_s =~ s/b/B/; if (xCAT::NetworkUtils::isIpaddr($tmp_n)) { - $node_side_pairs{$tmp_s} = $tmp_n; + $node_side_pairs{$tmp_s} = $tmp_n; $children_num++; } else { my $tmpip = xCAT::NetworkUtils->getipaddr($tmp_n); if (!$tmpip) { - #my $hoststab = xCAT::Table->new( 'hosts' ); - #my $tmp = $hoststab->getNodeAttribs($tmp_n, ['ip']); - #if ($tmp->{ip}) { - # $tmpip = $tmp->{ip}; - #} + + #my $hoststab = xCAT::Table->new( 'hosts' ); + #my $tmp = $hoststab->getNodeAttribs($tmp_n, ['ip']); + #if ($tmp->{ip}) { + # $tmpip = $tmp->{ip}; + #} } if ($tmpip) { $node_side_pairs{$tmp_s} = $tmpip; $children_num++; } - } # end of parse IP address for a fsp/bpa - } # end of parse a child's side - } #end of loop for children + } # end of parse IP address for a fsp/bpa + } # end of parse a child's side + } #end of loop for children if ($children_num == 0) { - return undef; #no children or brothers for this node. + return undef; #no children or brothers for this node. } - my @keys = qw(A-0 A-1 B-0 B-1); + my @keys = qw(A-0 A-1 B-0 B-1); my $out_strings = undef; foreach my $tmp (@keys) { if (!$node_side_pairs{$tmp}) { @@ -227,14 +232,14 @@ sub getIPaddress } } - $out_strings = $node_side_pairs{"A-0"}.','.$node_side_pairs{"A-1"}.','.$node_side_pairs{"B-0"}.','.$node_side_pairs{"B-1"}; + $out_strings = $node_side_pairs{"A-0"} . ',' . $node_side_pairs{"A-1"} . ',' . $node_side_pairs{"B-0"} . ',' . $node_side_pairs{"B-1"}; return $out_strings; } else { return undef; } } - + @@ -264,111 +269,115 @@ sub getIPaddress #------------------------------------------------------------------------------- sub fsp_api_action { - my $request = shift; - my $node_name = shift; - my $attrs = shift; - my $action = shift; - my $tooltype = shift; - my $parameter = shift; -# my $user = "HMC"; -# my $password = "abc123"; - my $fsp_api = ($::XCATROOT) ? "$::XCATROOT/sbin/fsp-api" : "/opt/xcat/sbin/fsp-api"; - my $id = 1; - my $fsp_name = (); - my $fsp_ip = (); - my $target_list=(); - my $type = (); # fsp|lpar -- 0. BPA -- 1 + my $request = shift; + my $node_name = shift; + my $attrs = shift; + my $action = shift; + my $tooltype = shift; + my $parameter = shift; + + # my $user = "HMC"; + # my $password = "abc123"; + my $fsp_api = ($::XCATROOT) ? "$::XCATROOT/sbin/fsp-api" : "/opt/xcat/sbin/fsp-api"; + my $id = 1; + my $fsp_name = (); + my $fsp_ip = (); + my $target_list = (); + my $type = (); # fsp|lpar -- 0. BPA -- 1 my @result; - my $Rc = 0 ; + my $Rc = 0; my %outhash = (); - my $res; + my $res; my $user; my $password; my $fsp_bpa_type; - - if( !defined($tooltype) ) { - $tooltype = 0; + + if (!defined($tooltype)) { + $tooltype = 0; } - $id = $$attrs[0]; - $fsp_name = $$attrs[3]; + $id = $$attrs[0]; + $fsp_name = $$attrs[3]; xCAT::MsgUtils->verbose_message($request, "fsp_api_action START node:$node_name,type:$$attrs[4]."); - if($$attrs[4] =~ /^fsp$/ || $$attrs[4] =~ /^lpar$/ || $$attrs[4] =~ /^cec$/) { - $type = 0; - $fsp_bpa_type="fsp"; - } elsif($$attrs[4] =~ /^bpa$/ || $$attrs[4] =~ /^frame$/) { - $type = 1; - $fsp_bpa_type="bpa"; - } elsif($$attrs[4] =~ /^blade$/) { - $type = 0; + if ($$attrs[4] =~ /^fsp$/ || $$attrs[4] =~ /^lpar$/ || $$attrs[4] =~ /^cec$/) { + $type = 0; + $fsp_bpa_type = "fsp"; + } elsif ($$attrs[4] =~ /^bpa$/ || $$attrs[4] =~ /^frame$/) { + $type = 1; + $fsp_bpa_type = "bpa"; + } elsif ($$attrs[4] =~ /^blade$/) { + $type = 0; $fsp_bpa_type = "blade"; - } else { + } else { $res = "$fsp_name\'s type is $$attrs[4]. Not support for $$attrs[4]"; - return ([$node_name, $res, -1]); - } - if( $action =~ /^add_connection$/) { + return ([ $node_name, $res, -1 ]); + } + if ($action =~ /^add_connection$/) { ############################ # Get IP address ############################ - $fsp_ip = getIPaddress($request, $$attrs[4], $fsp_name, $parameter ); - undef($parameter); + $fsp_ip = getIPaddress($request, $$attrs[4], $fsp_name, $parameter); + undef($parameter); } else { - $fsp_ip = getIPaddress($request, $$attrs[4], $fsp_name ); + $fsp_ip = getIPaddress($request, $$attrs[4], $fsp_name); } xCAT::MsgUtils->verbose_message($request, "fsp_api_action getIPaddress:$fsp_ip."); - if(!defined($fsp_ip)) { + if (!defined($fsp_ip)) { $res = "Failed to get IP address for $fsp_name or the related FSPs/BPAs."; - return ([$node_name, $res, -1]); + return ([ $node_name, $res, -1 ]); } - if($fsp_ip eq "-1") { + if ($fsp_ip eq "-1") { $res = "Cannot open vpd table"; - return ([$node_name, $res, -1]); - } elsif( $fsp_ip eq "-3") { + return ([ $node_name, $res, -1 ]); + } elsif ($fsp_ip eq "-3") { $res = "It doesn't have the FSPs or BPAs whose side is the value as specified or by default."; - return ([$node_name, $res, -1]); - } + return ([ $node_name, $res, -1 ]); + } #print "fsp name: $fsp_name\n"; #print "fsp ip: $fsp_ip\n"; - + #In DFM, only the add_connection action need the userid/password to create the connection - #between hdwr_svr and FSPs or BPAs. - if( $action =~ /^add_connection$/) { - my $tmp_node; - if( $$attrs[4] =~ /^cec$/ || $$attrs[4] =~ /^frame$/ ) { - $tmp_node = $node_name; - } elsif ($$attrs[4] =~ /^blade$/) { - $tmp_node = $$attrs[5]; - } else { - $tmp_node = $fsp_name; - } - - my $cred = $request->{$tmp_node}{cred}; - ($user, $password) = @$cred ; - #($user, $password) = xCAT::PPCdb::credentials( $tmp_node, $fsp_bpa_type,'HMC'); - if ( !$password) { - $res = "Cannot get password of userid 'HMC'. Please check table 'passwd' or 'ppcdirect'."; - return ([$node_name, $res, -1]); - } + #between hdwr_svr and FSPs or BPAs. + if ($action =~ /^add_connection$/) { + my $tmp_node; + if ($$attrs[4] =~ /^cec$/ || $$attrs[4] =~ /^frame$/) { + $tmp_node = $node_name; + } elsif ($$attrs[4] =~ /^blade$/) { + $tmp_node = $$attrs[5]; + } else { + $tmp_node = $fsp_name; + } + + my $cred = $request->{$tmp_node}{cred}; + ($user, $password) = @$cred; + + #($user, $password) = xCAT::PPCdb::credentials( $tmp_node, $fsp_bpa_type,'HMC'); + if (!$password) { + $res = "Cannot get password of userid 'HMC'. Please check table 'passwd' or 'ppcdirect'."; + return ([ $node_name, $res, -1 ]); + } + # The userid for creating connection only is "HMC". $user = 'HMC'; } my $cmd; my $install_dir = xCAT::TableUtils->getInstallDir(); - if( $action =~ /^(code_update|get_compatible_version_from_rpm)$/) { + if ($action =~ /^(code_update|get_compatible_version_from_rpm)$/) { $cmd = "$fsp_api -a $action -T $tooltype -t $type:$fsp_ip:$id:$node_name:$parameter -d $install_dir/packages_fw/"; - } elsif($action =~ /^code_updateD$/) { + } elsif ($action =~ /^code_updateD$/) { $cmd = "$fsp_api -a code_update -D -T $tooltype -t $type:$fsp_ip:$id:$node_name:$parameter -d $install_dir/packages_fw/"; - } elsif($action =~ /^add_connection$/) { - $cmd = "$fsp_api -a $action -u $user -p $password -T $tooltype -t $type:$fsp_ip:$id:$node_name:"; - } elsif ($action =~ /^set_frame_number$/) { - $cmd = "$fsp_api -a $action -T $tooltype -f $parameter -t $type:$fsp_ip:$id:$node_name:"; + } elsif ($action =~ /^add_connection$/) { + $cmd = "$fsp_api -a $action -u $user -p $password -T $tooltype -t $type:$fsp_ip:$id:$node_name:"; + } elsif ($action =~ /^set_frame_number$/) { + $cmd = "$fsp_api -a $action -T $tooltype -f $parameter -t $type:$fsp_ip:$id:$node_name:"; } else { - if( defined($parameter) ) { + if (defined($parameter)) { if ($action =~ /^set_(frame|cec|lpar)_name$/) { $cmd = "$fsp_api -a $action -n $parameter -T $tooltype -t $type:$fsp_ip:$id:$node_name:"; - } elsif( $parameter !=0 && $action =~ /^(on|reset)$/ ) { + } elsif ($parameter != 0 && $action =~ /^(on|reset)$/) { + #powerinterval for lpars power on $cmd = "$fsp_api -a $action -i $parameter -T $tooltype -t $type:$fsp_ip:$id:$node_name:"; } elsif ($action =~ /^part_set_lpar_def_state$/) { @@ -387,29 +396,32 @@ sub fsp_api_action { } } xCAT::MsgUtils->verbose_message($request, "fsp_api_action cmd:$cmd."); - #print "cmd: $cmd\n"; - $SIG{CHLD} = 'DEFAULT'; + + #print "cmd: $cmd\n"; + $SIG{CHLD} = 'DEFAULT'; + # secure passwords in verbose mode my $tmpv = $::VERBOSE; - if($action =~ /^add_connection$/) + if ($action =~ /^add_connection$/) { # password involved $::VERBOSE = 0; } $res = xCAT::Utils->runcmd($cmd, -1); - #$res = "good"; - $Rc = $::RUNCMD_RC; + + #$res = "good"; + $Rc = $::RUNCMD_RC; $::VERBOSE = $tmpv; - + ################## # output the prompt ################# #$outhash{ $node_name } = $res; - if(defined($res)) { + if (defined($res)) { $res =~ s/$node_name: //g; } xCAT::MsgUtils->verbose_message($request, "fsp_api_action return:$Rc."); - return( [$node_name,$res, $Rc] ); + return ([ $node_name, $res, $Rc ]); } #------------------------------------------------------------------------------- @@ -437,67 +449,72 @@ sub fsp_api_action { #------------------------------------------------------------------------------- sub fsp_state_action { - my $request = shift; - my $node_name = shift; - my $attrs = shift; - my $action = shift; - my $tooltype = shift; - my $fsp_api = ($::XCATROOT) ? "$::XCATROOT/sbin/fsp-api" : "/opt/xcat/sbin/fsp-api"; - my $id = 0; - my $fsp_name = (); - my $fsp_ip = (); - my $target_list=(); - my $type = (); # fsp|lpar -- 0. BPA -- 1 + my $request = shift; + my $node_name = shift; + my $attrs = shift; + my $action = shift; + my $tooltype = shift; + my $fsp_api = ($::XCATROOT) ? "$::XCATROOT/sbin/fsp-api" : "/opt/xcat/sbin/fsp-api"; + my $id = 0; + my $fsp_name = (); + my $fsp_ip = (); + my $target_list = (); + my $type = (); # fsp|lpar -- 0. BPA -- 1 my @result; - my $Rc = 0 ; + my $Rc = 0; my %outhash = (); - my @res; - - if( !defined($tooltype) ) { - $tooltype = 0; + my @res; + + if (!defined($tooltype)) { + $tooltype = 0; } - $fsp_name = $node_name; + $fsp_name = $node_name; + - xCAT::MsgUtils->verbose_message($request, "fsp_state_action START node:$node_name,type:$$attrs[4]."); - if( $$attrs[4] =~ /^(fsp|lpar|cec|blade)$/) { + if ($$attrs[4] =~ /^(fsp|lpar|cec|blade)$/) { $type = 0; - } else { - $type = 1; - } + } else { + $type = 1; + } ############################ # Get IP address ############################ - $fsp_ip = getIPaddress($request, $$attrs[4], $fsp_name ); - if(!defined($fsp_ip) or ($fsp_ip == -3)) { + $fsp_ip = getIPaddress($request, $$attrs[4], $fsp_name); + if (!defined($fsp_ip) or ($fsp_ip == -3)) { $res[0] = "Failed to get IP address for $fsp_name or the related FSPs/BPAs."; - return ([-1, $res[0]]); + return ([ -1, $res[0] ]); } - + xCAT::MsgUtils->verbose_message($request, "fsp_state_action getIPaddress:$fsp_ip."); + #print "fsp name: $fsp_name\n"; #print "fsp ip: $fsp_ip\n"; my $cmd; + #$cmd = "$fsp_api -a $action -u $user -p $password -T $tooltype -t $type:$fsp_ip:$id:$node_name:"; $cmd = "$fsp_api -a $action -T $tooltype -t $type:$fsp_ip:$id:$node_name:"; xCAT::MsgUtils->verbose_message($request, "fsp_state_action cmd:$cmd."); - #print "cmd: $cmd\n"; - $SIG{CHLD} = 'DEFAULT'; + + #print "cmd: $cmd\n"; + $SIG{CHLD} = 'DEFAULT'; @res = xCAT::Utils->runcmd($cmd, -1); - #$res = "good"; + + #$res = "good"; $Rc = $::RUNCMD_RC; + #$Rc = -1; ################## # output the prompt ################# #$outhash{ $node_name } = $res; - if( @res ) { + if (@res) { $res[0] =~ s/$node_name: //g; } xCAT::MsgUtils->verbose_message($request, "fsp_state_action return:$Rc."); - return( [$Rc,@res] ); + return ([ $Rc, @res ]); } @@ -526,99 +543,102 @@ sub fsp_state_action { #------------------------------------------------------------------------------- sub fsp_api_create_partition { - my $request = shift; - my $starting_lpar_id = shift; - my $octant_cfg = shift; - my $node_number = shift; - my $attrs = shift; - my $action = shift; - my $tooltype = shift; -# my $user = "HMC"; -# my $password = "abc123"; - my $fsp_api = ($::XCATROOT) ? "$::XCATROOT/sbin/fsp-api" : "/opt/xcat/sbin/fsp-api"; - my $id = 0; - my $fsp_name = (); - my $fsp_ip = (); - my $target_list=(); - my $type = (); # fsp|lpar -- 0. BPA -- 1 + my $request = shift; + my $starting_lpar_id = shift; + my $octant_cfg = shift; + my $node_number = shift; + my $attrs = shift; + my $action = shift; + my $tooltype = shift; + + # my $user = "HMC"; + # my $password = "abc123"; + my $fsp_api = ($::XCATROOT) ? "$::XCATROOT/sbin/fsp-api" : "/opt/xcat/sbin/fsp-api"; + my $id = 0; + my $fsp_name = (); + my $fsp_ip = (); + my $target_list = (); + my $type = (); # fsp|lpar -- 0. BPA -- 1 my @result; - my $Rc = 0 ; + my $Rc = 0; my %outhash = (); - my $res; + my $res; my $number_of_lpars_per_octant; my $octant_num_needed; my $starting_octant_id; my $octant_conf_value; - my $octant_cfg_value = $octant_cfg->{octant_cfg_value}; + my $octant_cfg_value = $octant_cfg->{octant_cfg_value}; my $new_pending_interleave_mode = $octant_cfg->{memory_interleave}; - - if( !defined($tooltype) ) { - $tooltype = 0; + + if (!defined($tooltype)) { + $tooltype = 0; } - - #use Data::Dumper; + + #use Data::Dumper; #print Dumper($attrs); - $fsp_name = $$attrs[3]; - $type = 0; + $fsp_name = $$attrs[3]; + $type = 0; ############################ # Get IP address ############################ - $fsp_ip = getIPaddress($request, $$attrs[4], $fsp_name ); - if(!defined($fsp_ip) or ($fsp_ip == -3)) { + $fsp_ip = getIPaddress($request, $$attrs[4], $fsp_name); + if (!defined($fsp_ip) or ($fsp_ip == -3)) { $res = "Failed to get IP address for $fsp_name."; - return ([$fsp_name, $res, -1]); + return ([ $fsp_name, $res, -1 ]); } - + #print "fsp name: $fsp_name\n"; #print "fsp ip: $fsp_ip\n"; - $starting_octant_id = int($starting_lpar_id/4); - my $lparnum_from_octant = 0; + $starting_octant_id = int($starting_lpar_id / 4); + my $lparnum_from_octant = 0; my $new_pending_pump_mode = $octant_cfg->{pendingpumpmode}; my $parameters; + #my $parameters = "$new_pending_pump_mode:$octant_num_needed"; - my $octant_id = $starting_octant_id ; - my $i = 0; - for($i=$starting_octant_id; $i < (keys %$octant_cfg_value) ; $i++) { - if(! exists($octant_cfg_value->{$i})) { - $res = "starting LPAR id is $starting_lpar_id, starting octant id is $starting_octant_id, octant configuration value isn't provided. Wrong plan."; - return ([$fsp_name, $res, -1]); + my $octant_id = $starting_octant_id; + my $i = 0; + for ($i = $starting_octant_id ; $i < (keys %$octant_cfg_value) ; $i++) { + if (!exists($octant_cfg_value->{$i})) { + $res = "starting LPAR id is $starting_lpar_id, starting octant id is $starting_octant_id, octant configuration value isn't provided. Wrong plan."; + return ([ $fsp_name, $res, -1 ]); } - my $octant_conf_value = $octant_cfg_value->{$i}; + my $octant_conf_value = $octant_cfg_value->{$i}; + #octant configuration values could be 1,2,3,4,5 ; AS following: # 1 - 1 partition with all cpus and memory of the octant # 2 - 2 partitions with a 50/50 split of cpus and memory # 3 - 3 partitions with a 25/25/50 split of cpus and memory # 4 - 4 partitions with a 25/25/25/25 split of cpus and memory # 5 - 2 partitions with a 25/75 split of cpus and memory - if($octant_conf_value == 1) { - $number_of_lpars_per_octant = 1; - } elsif($octant_conf_value == 2 ) { - $number_of_lpars_per_octant = 2; - } elsif($octant_conf_value == 3 ) { - $number_of_lpars_per_octant = 3; - } elsif($octant_conf_value == 4 ) { - $number_of_lpars_per_octant = 4; - } elsif($octant_conf_value == 5 ) { - $number_of_lpars_per_octant = 2; + if ($octant_conf_value == 1) { + $number_of_lpars_per_octant = 1; + } elsif ($octant_conf_value == 2) { + $number_of_lpars_per_octant = 2; + } elsif ($octant_conf_value == 3) { + $number_of_lpars_per_octant = 3; + } elsif ($octant_conf_value == 4) { + $number_of_lpars_per_octant = 4; + } elsif ($octant_conf_value == 5) { + $number_of_lpars_per_octant = 2; } else { $res = "octant $i, configuration values: $octant_conf_value. Wrong octant configuration values!\n"; - return ([$fsp_name, $res, -1]); - } + return ([ $fsp_name, $res, -1 ]); + } + + $lparnum_from_octant += $number_of_lpars_per_octant; + $octant_num_needed++; + $parameters .= ":$octant_id:$octant_conf_value:$new_pending_interleave_mode"; + - $lparnum_from_octant += $number_of_lpars_per_octant; - $octant_num_needed++; - $parameters .= ":$octant_id:$octant_conf_value:$new_pending_interleave_mode"; - - - } - $parameters = "$new_pending_pump_mode:$octant_num_needed".$parameters; - if($node_number != $lparnum_from_octant ) { - $res = "According to the partition split rule and the starting LPAR id, $lparnum_from_octant LPARs will be gotten. But the noderange has $node_number node. Wrong plan.\n"; - return ([$fsp_name, $res, -1]); } - + $parameters = "$new_pending_pump_mode:$octant_num_needed" . $parameters; + if ($node_number != $lparnum_from_octant) { + $res = "According to the partition split rule and the starting LPAR id, $lparnum_from_octant LPARs will be gotten. But the noderange has $node_number node. Wrong plan.\n"; + return ([ $fsp_name, $res, -1 ]); + } + #my $new_pending_pump_mode = 1; #my $parameters = "$new_pending_pump_mode:$octant_num_needed"; #my $octant_id = $starting_octant_id ; @@ -631,21 +651,24 @@ sub fsp_api_create_partition { my $cmd; $cmd = "$fsp_api -a $action -T $tooltype -t $type:$fsp_ip:0:$fsp_name:$parameters"; + #fsp-api -a set_octant_cfg -t 0:40.7.5.1:0:M019:1:1:7:4:2 - #print "cmd: $cmd\n"; - $SIG{CHLD} = 'DEFAULT'; + #print "cmd: $cmd\n"; + $SIG{CHLD} = 'DEFAULT'; $res = xCAT::Utils->runcmd($cmd, -1); - #$res = "good"; + + #$res = "good"; $Rc = $::RUNCMD_RC; + #$Rc = -1; ################## # output the prompt ################# #$outhash{ $node_name } = $res; - if( defined($res) ) { + if (defined($res)) { $res =~ s/$fsp_name: //; } - return( [$fsp_name,$res, $Rc] ); + return ([ $fsp_name, $res, $Rc ]); } diff --git a/perl-xCAT/xCAT/FSPboot.pm b/perl-xCAT/xCAT/FSPboot.pm index eaa4dd85f..fd9843611 100644 --- a/perl-xCAT/xCAT/FSPboot.pm +++ b/perl-xCAT/xCAT/FSPboot.pm @@ -11,7 +11,7 @@ use xCAT::PPCboot; use xCAT::LparNetbootExp; ########################################################################## -# Parse the command line for options and operands +# Parse the command line for options and operands ########################################################################## sub parse_args { xCAT::PPCboot::parse_args(@_); @@ -19,7 +19,7 @@ sub parse_args { ########################################################################## -# Netboot the lpar +# Netboot the lpar ########################################################################## sub do_rnetboot { @@ -36,14 +36,14 @@ sub do_rnetboot { my $Rc = SUCCESS; my $cmd; my %optarg; - + ####################################### # Disconnect Expect session ####################################### #xCAT::PPCcli::disconnect( $exp ); - + ####################################### - # Get node data + # Get node data ####################################### my $id = @$d[0]; my $pprofile = @$d[1]; @@ -51,10 +51,10 @@ sub do_rnetboot { my $hcp = @$d[3]; ######################################## - ## Find Expect script + ## Find Expect script ######################################## #$cmd = ($::XCATROOT) ? "$::XCATROOT/sbin/" : "/opt/xcat/sbin/"; - #$cmd .= "lpar_netboot.expect"; + #$cmd .= "lpar_netboot.expect"; # ######################################## ## Check command installed @@ -65,7 +65,7 @@ sub do_rnetboot { ####################################### # Save user name and passwd of hcp to # environment variables. - # lpar_netboot.expect depends on it + # lpar_netboot.expect depends on it ####################################### $ENV{HCP_USERID} = $userid; $ENV{HCP_PASSWD} = $pw; @@ -73,34 +73,40 @@ sub do_rnetboot { ####################################### # Turn on verbose and debugging ####################################### - if ( ${$request->{arg}}[0] eq '-V' ) { + if (${ $request->{arg} }[0] eq '-V') { + #$cmd.= " -v -x"; - $optarg{'v'} = 1; #for verbose - $optarg{'x'} = 1; #for debug + $optarg{'v'} = 1; #for verbose + $optarg{'x'} = 1; #for debug } ####################################### # Force LPAR shutdown ####################################### - if ( exists( $opt->{f} ) || !xCAT::Utils->isAIX() ) { + if (exists($opt->{f}) || !xCAT::Utils->isAIX()) { + #$cmd.= " -i"; $optarg{'i'} = 1; - } + } ####################################### # Write boot order ####################################### - if ( exists( $opt->{s} )) { + if (exists($opt->{s})) { foreach ($opt->{s}) { - if ( /^net$/ ) { + if (/^net$/) { + #$cmd.= " -w 1"; $optarg{'w'} = 1; - } elsif ( /^net,hd$/ ) { + } elsif (/^net,hd$/) { + #$cmd.= " -w 2"; $optarg{'w'} = 2; - } elsif ( /^hd,net$/ ) { + } elsif (/^hd,net$/) { + #$cmd.= " -w 3"; $optarg{'w'} = 3; - } elsif ( /^hd$/ ) { + } elsif (/^hd$/) { + #$cmd.= " -w 4"; $optarg{'w'} = 4; } @@ -108,7 +114,7 @@ sub do_rnetboot { } my @macs = split /\|/, $opt->{m}; - foreach my $mac ( @macs ) { + foreach my $mac (@macs) { $mac = lc($mac); ####################################### # Network specified @@ -121,20 +127,23 @@ sub do_rnetboot { $optarg{'C'} = $opt->{C}; $optarg{'N'} = $opt->{N}; $optarg{'G'} = $opt->{G}; - if ( exists( $opt->{o} )) { + if (exists($opt->{o})) { + #$cmd.= " -o"; $optarg{'o'} = 1; } - my %client_nethash = xCAT::DBobjUtils->getNetwkInfo( [$node] ); - if ( grep /hf/, $client_nethash{$node}{mgtifname} ) { + my %client_nethash = xCAT::DBobjUtils->getNetwkInfo([$node]); + if (grep /hf/, $client_nethash{$node}{mgtifname}) { + #$cmd.= " -t hfi-ent"; $optarg{'t'} = "hfi-ent"; } else { + #$cmd.= " -t ent"; $optarg{'t'} = "ent"; } - + $pprofile = "not_use"; #lpar_netboot.expect need pprofile for p5 & p6, but for p7 ih, we don't use this attribute. ####################################### @@ -142,21 +151,22 @@ sub do_rnetboot { ####################################### #$cmd.= " -f \"$name\" \"$pprofile\" \"$fsp\" $id $hcp \"$node\""; #print "cmd: $cmd\n"; - $optarg{'f'} = 1; - $optarg{'name'} = $name; + $optarg{'f'} = 1; + $optarg{'name'} = $name; $optarg{'pprofile'} = $pprofile; - $optarg{'fsp'} = $fsp; - $optarg{'id'} = $id; - $optarg{'hcp'} = $hcp; - $optarg{'node'} = $node; + $optarg{'fsp'} = $fsp; + $optarg{'id'} = $id; + $optarg{'hcp'} = $hcp; + $optarg{'node'} = $node; my $done = 0; - while ( $done < 2 ) { + + while ($done < 2) { $result = ""; - $Rc = SUCCESS; + $Rc = SUCCESS; ######################################## ## Execute command ######################################## - #print "cmd:$cmd\n"; + #print "cmd:$cmd\n"; #my $pid = open( OUTPUT, "$cmd 2>&1 |"); #$SIG{INT} = $SIG{TERM} = sub { #prepare to process job termination and propogate it down # kill 9, $pid; @@ -172,7 +182,7 @@ sub do_rnetboot { # $result.=$_; #} #close OUTPUT; - + ######################################## ## Get command exit code ######################################## @@ -188,7 +198,7 @@ sub do_rnetboot { ####################################### $result = xCAT::LparNetbootExp->lparnetbootexp(\%optarg, $request); $Rc = @$result[0]; - if ( $Rc == SUCCESS ) { + if ($Rc == SUCCESS) { $done = 2; } else { $done = $done + 1; @@ -196,7 +206,7 @@ sub do_rnetboot { } } - if ( $Rc == SUCCESS ) { + if ($Rc == SUCCESS) { last; } } @@ -215,20 +225,20 @@ sub rnetboot { my $options = $request->{opt}; my $hwtype = @$exp[2]; my $result; - my $name = $request->{node}; + my $name = $request->{node}; my $callback = $request->{callback}; ##################################### - # Get node data + # Get node data ##################################### my $lparid = @$d[0]; my $mtms = @$d[2]; my $type = @$d[4]; my $node = @$d[6]; - my $o = @$d[7]; + my $o = @$d[7]; ##################################### - # Gateway (-G) - # Server (-S) + # Gateway (-G) + # Server (-S) # Client (-C) # mac (-m) ##################################### @@ -246,31 +256,31 @@ sub rnetboot { } ##################################### - # Strip colons from mac address + # Strip colons from mac address ##################################### $opt{m} =~ s/://g; ##################################### - # Force LPAR shutdown + # Force LPAR shutdown ##################################### - if ( exists( $options->{f} )) { + if (exists($options->{f})) { $opt{f} = 1; } ##################################### # Write boot device order ##################################### - if ( exists( $options->{s} )) { + if (exists($options->{s})) { $opt{s} = $options->{s}; } - if ( exists( $options->{o} )) { + if (exists($options->{o})) { $opt{o} = $options->{o}; } ##################################### - # Invalid target hardware + # Invalid target hardware ##################################### - if ( $type !~ /^lpar$/ ) { - return( [[$name,"Not supported",RC_ERROR]] ); + if ($type !~ /^lpar$/) { + return ([ [ $name, "Not supported", RC_ERROR ] ]); } ######################################### # Get name known by HCP @@ -306,78 +316,82 @@ sub rnetboot { # It is not allowed to rinitialize node # if it is in boot state ######################################### - if ( !exists( $options->{F} ) && !xCAT::Utils->isAIX() ) { + if (!exists($options->{F}) && !xCAT::Utils->isAIX()) { my $chaintab = xCAT::Table->new('chain'); - my $vcon = $chaintab->getAttribs({ node => "$node"}, 'currstate'); - if ( $vcon and $vcon->{"currstate"} and $vcon->{"currstate"} eq "boot" ) { - return( [[$node,"Node is in boot state. Use nodeset command before rnetboot or use -F option with rnetboot",RC_ERROR]] ); + my $vcon = $chaintab->getAttribs({ node => "$node" }, 'currstate'); + if ($vcon and $vcon->{"currstate"} and $vcon->{"currstate"} eq "boot") { + return ([ [ $node, "Node is in boot state. Use nodeset command before rnetboot or use -F option with rnetboot", RC_ERROR ] ]); } } #my $sitetab = xCAT::Table->new('site'); #my $vcon = $sitetab->getAttribs({key => "conserverondemand"}, 'value'); #if ($vcon and $vcon->{"value"} and $vcon->{"value"} eq "yes" ) { - # $result = xCAT::PPCcli::lpar_netboot( - # $exp, - # $request->{verbose}, - # $name, - # $d, - # \%opt ); + # $result = xCAT::PPCcli::lpar_netboot( + # $exp, + # $request->{verbose}, + # $name, + # $d, + # \%opt ); # return( [[$node,"Not support conserverondemand's value is yes",RC_ERROR]] ); #} else { - ######################################### - # Manually perform boot. - ######################################### - $result = do_rnetboot( $request, $d, $exp, $name, $node, \%opt ); + ######################################### + # Manually perform boot. + ######################################### + $result = do_rnetboot($request, $d, $exp, $name, $node, \%opt); + #} #$sitetab->close; if (defined($request->{opt}->{m})) { - - my $retries = 0; + + my $retries = 0; my @monnodes = ($name); my $monsettings = xCAT::Utils->generate_monsettings($request, \@monnodes); - xCAT::Utils->monitor_installation($request, $monsettings);; - while ($retries++ < $monsettings->{'retrycount'} && scalar(keys %{$monsettings->{'nodes'}}) > 0) { + xCAT::Utils->monitor_installation($request, $monsettings); + while ($retries++ < $monsettings->{'retrycount'} && scalar(keys %{ $monsettings->{'nodes'} }) > 0) { ####lparnetboot can not support multiple nodes in one invocation ####for now, does not know how the $d and \%opt will be changed if ####support mulitiple nodes in one invocation, ####so just use the original node name and node attribute array and hash - - my $rsp={}; - $rsp->{data}->[0] = "$node: Reinitializing the installation: $retries retry"; - xCAT::MsgUtils->message("I", $rsp, $callback); - #if ($vcon and $vcon->{"value"} and $vcon->{"value"} eq "yes" ) { - # $result = xCAT::PPCcli::lpar_netboot( - # $exp, - # $request->{verbose}, - # $name, - # $d, - # \%opt ); + + my $rsp = {}; + $rsp->{data}->[0] = "$node: Reinitializing the installation: $retries retry"; + xCAT::MsgUtils->message("I", $rsp, $callback); + + #if ($vcon and $vcon->{"value"} and $vcon->{"value"} eq "yes" ) { + # $result = xCAT::PPCcli::lpar_netboot( + # $exp, + # $request->{verbose}, + # $name, + # $d, + # \%opt ); #return( [[$node,"Not support conserverondemand's value is yes",RC_ERROR]] ); #} else { - $result = do_rnetboot( $request, $d, $exp, $name, $node, \%opt ); + $result = do_rnetboot($request, $d, $exp, $name, $node, \%opt); + #} xCAT::Utils->monitor_installation($request, $monsettings); - + } + #failed after retries - if (scalar(keys %{$monsettings->{'nodes'}}) > 0) { - foreach my $node (keys %{$monsettings->{'nodes'}}) { - my $rsp={}; + if (scalar(keys %{ $monsettings->{'nodes'} }) > 0) { + foreach my $node (keys %{ $monsettings->{'nodes'} }) { + my $rsp = {}; $rsp->{data}->[0] = "The node \"$node\" can not reach the expected status after $monsettings->{'retrycount'} retries, the installation for this done failed"; xCAT::MsgUtils->message("E", $rsp, $callback); } - } + } } $Rc = shift(@$result); - + ################################## # Form string from array results ################################## - if ( exists($request->{verbose}) ) { - return( [[$node,join( '', @$result ),$Rc]] ); + if (exists($request->{verbose})) { + return ([ [ $node, join('', @$result), $Rc ] ]); } ################################## # Return error @@ -393,18 +407,18 @@ sub rnetboot { # lpar_netboot: can not find mac address 42DAB. # ################################## - if ( $Rc != SUCCESS ) { - if ( @$result[0] =~ /lpar_netboot (.*)/ ) { - return( [[$node,$1,$Rc]] ); + if ($Rc != SUCCESS) { + if (@$result[0] =~ /lpar_netboot (.*)/) { + return ([ [ $node, $1, $Rc ] ]); } - return( [[$node,join( '', @$result ),$Rc]] ); + return ([ [ $node, join('', @$result), $Rc ] ]); } ################################## # Split array into string ################################## my $data = @$result[0]; - if ( $hwtype eq "hmc" ) { - $data = join( '', @$result ); + if ($hwtype eq "hmc") { + $data = join('', @$result); } ################################## # lpar_netboot returns: @@ -419,8 +433,8 @@ sub rnetboot { # # Finished. # ##################################### - if ( $data =~ /Finished/) { - return( [[$node,"Success",$Rc]] ); + if ($data =~ /Finished/) { + return ([ [ $node, "Success", $Rc ] ]); } ##################################### # Can still be error w/ Rc=0: @@ -434,12 +448,12 @@ sub rnetboot { # lpar_netboot: bootp operation failed. # ##################################### - if ( $data =~ /lpar_netboot (.*)/ ) { - return( [[$node,$1,RC_ERROR]] ); + if ($data =~ /lpar_netboot (.*)/) { + return ([ [ $node, $1, RC_ERROR ] ]); } - return( [[$node,$data,RC_ERROR]] ); + return ([ [ $node, $data, RC_ERROR ] ]); } - + 1; diff --git a/perl-xCAT/xCAT/FSPbootseq.pm b/perl-xCAT/xCAT/FSPbootseq.pm index 98f3da0a6..8f6ba2e75 100644 --- a/perl-xCAT/xCAT/FSPbootseq.pm +++ b/perl-xCAT/xCAT/FSPbootseq.pm @@ -8,10 +8,11 @@ use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR); use xCAT::NetworkUtils; use xCAT::FSPUtils; use xCAT::MsgUtils qw(verbose_message); + #use Data::Dumper; ########################################################################## -# Parse the command line for options and operands +# Parse the command line for options and operands ########################################################################## sub parse_args { @@ -20,22 +21,22 @@ sub parse_args { my $cmd = $request->{command}; my $args = $request->{arg}; my $node = $request->{node}; - my $vers = - my @VERSION = qw( 2.6 ); - my @dev = qw(hfi net); - + my $vers = + my @VERSION = qw( 2.6 ); + my @dev = qw(hfi net); + ############################################# # Responds with usage statement ############################################# local *usage = sub { my $usage_string = xCAT::Usage->getUsage($cmd); - return( [ $_[0], $usage_string] ); + return ([ $_[0], $usage_string ]); }; ############################################# # Process command-line arguments ############################################# - if ( !defined( $args )) { - return(usage( "Missing command with rbootseq in DFM, net or hfi ?" )); + if (!defined($args)) { + return (usage("Missing command with rbootseq in DFM, net or hfi ?")); } ############################################# @@ -43,12 +44,12 @@ sub parse_args { # to be grouped (e.g. -vx), and terminates # at the first unrecognized option. ############################################# - @ARGV = @$args; + @ARGV = @$args; $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); + Getopt::Long::Configure("bundling"); - if ( !GetOptions( \%opt,qw(h|help V|verbose v|version ))) { - return( usage() ); + if (!GetOptions(\%opt, qw(h|help V|verbose v|version ))) { + return (usage()); } #################################### # Option -h for Help @@ -59,8 +60,8 @@ sub parse_args { #################################### # Option -v for version #################################### - if ( exists( $opt{v} )) { - return( \@VERSION ); + if (exists($opt{v})) { + return (\@VERSION); } #################################### # Check for "-" with no option @@ -76,39 +77,39 @@ sub parse_args { # return(usage( "Invalid Argument: $ARGV[0]" )); #} - my $command = grep(/^$ARGV[0]$/, @dev ); - if ( !defined( $command )) { - return(usage( "Invalid command: $ARGV[0]" )); + my $command = grep(/^$ARGV[0]$/, @dev); + if (!defined($command)) { + return (usage("Invalid command: $ARGV[0]")); } - if( $ARGV[0] =~/^hfi$/) { + if ($ARGV[0] =~ /^hfi$/) { $opt{hfi} = 1; - } elsif ( $ARGV[0] =~/^net$/) { + } elsif ($ARGV[0] =~ /^net$/) { $opt{net} = 1; } else { - return(usage( "Invalid Argument: $ARGV[0]" )); + return (usage("Invalid Argument: $ARGV[0]")); } shift @ARGV; - if ( defined( $ARGV[0] )) { - return(usage( "Invalid Argument: $ARGV[0]" )); + if (defined($ARGV[0])) { + return (usage("Invalid Argument: $ARGV[0]")); } - - + + #print "in parse_args:\n"; #print $command; - #print Dumper(\%opt); - + #print Dumper(\%opt); + my $nodetype = xCAT::DBobjUtils->getnodetype($$node[0], "ppc"); - if( $nodetype =~ /^blade$/) { - $request->{callback}->({data =>[ "After running rebootseq on the nodes successfully, it's required to run to make the setting be permanent"]}); - } + if ($nodetype =~ /^blade$/) { + $request->{callback}->({ data => ["After running rebootseq on the nodes successfully, it's required to run to make the setting be permanent"] }); + } #################################### - # Set method to invoke + # Set method to invoke #################################### - $request->{method} = $cmd; - return( \%opt ); + $request->{method} = $cmd; + return (\%opt); } @@ -120,32 +121,33 @@ sub rbootseq { my $request = shift; my $d = shift; my $opt = $request->{opt}; - my @output ; - my $tooltype = 0; + my @output; + my $tooltype = 0; my $parameter; my $bootp_retries = 5; my $tftp_retries = 5; my $blksize = 512; my $hash; - my $node_name = @$d[6]; - my $o = @$d[7]; - + my $node_name = @$d[6]; + my $o = @$d[7]; + #print "in setbootseq:\n"; #print "request\n"; #print Dumper($request); - #print "d"; + #print "d"; #print Dumper($d); - - xCAT::MsgUtils->verbose_message($request, "rbootseq START for node:$node_name, type=$$d[4]."); - if (!($$d[4] =~ /^(lpar|blade)$/)) { - push @output, [$node_name, "\'boot\' command not supported for CEC or BPA", -1 ]; + + xCAT::MsgUtils->verbose_message($request, "rbootseq START for node:$node_name, type=$$d[4]."); + if (!($$d[4] =~ /^(lpar|blade)$/)) { + push @output, [ $node_name, "\'boot\' command not supported for CEC or BPA", -1 ]; return (\@output); } - # add checking the power state of the cec - xCAT::MsgUtils->verbose_message($request, "rbootseq check machine state for node:$node_name."); - my $power_state = xCAT::FSPUtils::fsp_api_action ($request, $node_name, $d, "cec_state", $tooltype); - if ( @$power_state[2] != 0 ) { - push @output, [$node_name, @$power_state[1], -1 ]; + + # add checking the power state of the cec + xCAT::MsgUtils->verbose_message($request, "rbootseq check machine state for node:$node_name."); + my $power_state = xCAT::FSPUtils::fsp_api_action($request, $node_name, $d, "cec_state", $tooltype); + if (@$power_state[2] != 0) { + push @output, [ $node_name, @$power_state[1], -1 ]; return (\@output); } unless (@$power_state[1] and @$power_state[1] =~ /operating|standby/) { @@ -153,88 +155,90 @@ sub rbootseq { my $state; if ($$d[4] eq 'blade') { $machine = "blade"; - $state = "on"; + $state = "on"; } else { $machine = "CEC"; - $state = "power on"; + $state = "power on"; } - push @output, [$node_name, "\'boot\' command can only support while the $machine is in the \'$state\' state", -1]; + push @output, [ $node_name, "\'boot\' command can only support while the $machine is in the \'$state\' state", -1 ]; return (\@output); - } - if( $opt->{net} ) { - my $mactab = xCAT::Table->new( 'mac'); - unless($mactab) { - push @output, [$node_name, "Cannot open mac table", -1 ]; - return (\@output); - } - - my $mac_hash = $mactab->getNodeAttribs( $node_name,[qw(mac)]); - my $mac = $mac_hash->{mac}; - if( !defined($mac) ) { - push @output, [$node_name, "No mac address in mac table", -1 ]; - } - $mactab->close(); + } + if ($opt->{net}) { + my $mactab = xCAT::Table->new('mac'); + unless ($mactab) { + push @output, [ $node_name, "Cannot open mac table", -1 ]; + return (\@output); + } - if( $mac =~ /\| /) { - #01:02:03:04:05:0E!node5|01:02:03:05:0F!node6-eth1 - my @mac_t = split(/\|/,$mac); - my $m; - my $m_t; - foreach $m (@mac_t) { - if(($m =~ /([\w:]{12})!$node_name/) || ($m =~ /([\w:]{17})!$node_name/)) { - $m_t = $1; - last; - } + my $mac_hash = $mactab->getNodeAttribs($node_name, [qw(mac)]); + my $mac = $mac_hash->{mac}; + if (!defined($mac)) { + push @output, [ $node_name, "No mac address in mac table", -1 ]; + } + $mactab->close(); + + if ($mac =~ /\| /) { + + #01:02:03:04:05:0E!node5|01:02:03:05:0F!node6-eth1 + my @mac_t = split(/\|/, $mac); + my $m; + my $m_t; + foreach $m (@mac_t) { + if (($m =~ /([\w:]{12})!$node_name/) || ($m =~ /([\w:]{17})!$node_name/)) { + $m_t = $1; + last; + } } - if( !defined($m_t)) { - $mac = $mac_t[0]; - } else { - $mac = $m_t; - } - } - - if( $mac =~ /\:/) { - $mac =~ s/\://g; - } - - if($mac =~/^(\w{12})$/) { - - $parameter = "mac=$mac:speed=auto,duplex=auto,$o->{server},,$o->{client},$o->{gateway},$bootp_retries,$tftp_retries,$o->{netmask},$blksize"; - } else { - push @output, [$node_name, "The mac address in mac table could NOT be used for rbootseq with -net. HFI mac , or other wrong format?", -1 ]; - return( \@output ); - } - xCAT::MsgUtils->verbose_message($request, "rbootseq <$node_name> net=$parameter"); - } - - if( $opt->{hfi}) { - - $parameter = "/hfi-iohub/hfi-ethernet:$o->{server},,$o->{client},$o->{gateway},$bootp_retries,$tftp_retries,$o->{netmask},$blksize"; - - xCAT::MsgUtils->verbose_message($request, "rbootseq <$node_name> hfi=$parameter"); - } - - xCAT::MsgUtils->verbose_message($request, "rbootseq set_lpar_bootstring for node:$node_name."); - my $res = xCAT::FSPUtils::fsp_api_action ($request, $node_name, $d, "set_lpar_bootstring", $tooltype, $parameter); - #print "In boot, state\n"; - #print Dumper($res); - my $Rc = @$res[2]; - my $data = @$res[1]; - - ################################## - # Output error - ################################## - xCAT::MsgUtils->verbose_message($request, "rbootseq return:$Rc."); - if ( $Rc != SUCCESS ) { - push @output, [$node_name,$data,$Rc]; - } else { - push @output,[$node_name, "Success", 0]; + if (!defined($m_t)) { + $mac = $mac_t[0]; + } else { + $mac = $m_t; + } } - return( \@output ); + if ($mac =~ /\:/) { + $mac =~ s/\://g; + } + + if ($mac =~ /^(\w{12})$/) { + + $parameter = "mac=$mac:speed=auto,duplex=auto,$o->{server},,$o->{client},$o->{gateway},$bootp_retries,$tftp_retries,$o->{netmask},$blksize"; + } else { + push @output, [ $node_name, "The mac address in mac table could NOT be used for rbootseq with -net. HFI mac , or other wrong format?", -1 ]; + return (\@output); + } + xCAT::MsgUtils->verbose_message($request, "rbootseq <$node_name> net=$parameter"); + } + + if ($opt->{hfi}) { + + $parameter = "/hfi-iohub/hfi-ethernet:$o->{server},,$o->{client},$o->{gateway},$bootp_retries,$tftp_retries,$o->{netmask},$blksize"; + + xCAT::MsgUtils->verbose_message($request, "rbootseq <$node_name> hfi=$parameter"); + } + + xCAT::MsgUtils->verbose_message($request, "rbootseq set_lpar_bootstring for node:$node_name."); + my $res = xCAT::FSPUtils::fsp_api_action($request, $node_name, $d, "set_lpar_bootstring", $tooltype, $parameter); + + #print "In boot, state\n"; + #print Dumper($res); + my $Rc = @$res[2]; + my $data = @$res[1]; + + ################################## + # Output error + ################################## + xCAT::MsgUtils->verbose_message($request, "rbootseq return:$Rc."); + if ($Rc != SUCCESS) { + push @output, [ $node_name, $data, $Rc ]; + } else { + push @output, [ $node_name, "Success", 0 ]; + } + + return (\@output); } diff --git a/perl-xCAT/xCAT/FSPcfg.pm b/perl-xCAT/xCAT/FSPcfg.pm index dbefb0831..3d2a3bef3 100644 --- a/perl-xCAT/xCAT/FSPcfg.pm +++ b/perl-xCAT/xCAT/FSPcfg.pm @@ -8,6 +8,7 @@ use xCAT::Utils; use xCAT::FSPUtils; use xCAT::TableUtils; use xCAT::PPCcfg; + #use Data::Dumper; #use xCAT::PPCcli; use xCAT::MsgUtils qw(verbose_message); @@ -15,13 +16,13 @@ use xCAT::MsgUtils qw(verbose_message); ########################################## # Globals ########################################## -my %rspconfig = ( - frame => \&frame, - cec_off_policy => \&cec_off_policy, +my %rspconfig = ( + frame => \&frame, + cec_off_policy => \&cec_off_policy, ); -my %default_passwd = ( - HMC => "", +my %default_passwd = ( + HMC => "", admin => "admin", general => "general", ); @@ -30,14 +31,14 @@ my %default_passwd = ( # Parse the command line for options and operands ########################################################################## sub array_to_string { - my $array = shift; + my $array = shift; my $string = ""; - my $i = 0; + my $i = 0; if (!scalar(@$array)) { return undef; } $string .= "\'$array->[0]\'"; - for ($i = 1; $i < scalar(@$array) - 1; $i++) { + for ($i = 1 ; $i < scalar(@$array) - 1 ; $i++) { $string .= ", "; $string .= "\'$array->[$i]\'"; } @@ -48,18 +49,18 @@ sub array_to_string { } sub check_command { - my $cmd = shift; - my $rsp = shift; + my $cmd = shift; + my $rsp = shift; my @type = (); foreach my $tmp_type (keys %$rsp) { - if (grep (/^$cmd$/, @{$rsp->{$tmp_type}})) { + if (grep (/^$cmd$/, @{ $rsp->{$tmp_type} })) { push @type, $tmp_type; - } + } } if (!scalar(@type)) { return undef; } else { - return &array_to_string(\@type); + return &array_to_string(\@type); } } @@ -70,7 +71,7 @@ sub parse_args { my $args = $request->{arg}; my %opt = (); my %cmds = (); - my @fsp = ( + my @fsp = ( "HMC_passwd", "admin_passwd", "general_passwd", @@ -79,7 +80,7 @@ sub parse_args { "cec_off_policy" ); my @bpa = ( - "frame", + "frame", "HMC_passwd", "admin_passwd", "general_passwd", @@ -101,7 +102,7 @@ sub parse_args { "huge_page" ); my @frame = ( - "frame", + "frame", "HMC_passwd", "admin_passwd", "general_passwd", @@ -116,13 +117,13 @@ sub parse_args { "pending_power_on_side" ); - - + + my %rsp = ( fsp => \@fsp, bpa => \@bpa, cec => \@cec, - blade => \@blade, + blade => \@blade, frame => \@frame, ); ############################################# @@ -131,7 +132,7 @@ sub parse_args { #my $typetab = xCAT::Table->new( 'nodetype' ); #my $nodes = $request->{node}; #foreach (@$nodes) { - # if ( defined( $typetab )) { + # if ( defined( $typetab )) { # my ($ent) = $typetab->getAttribs({ node=>$_},'nodetype'); # if ( defined($ent) ) { # $request->{hwtype} = $ent->{nodetype}; @@ -141,117 +142,117 @@ sub parse_args { # } # #} - + my $nodes = $request->{node}; my $typehash = xCAT::DBobjUtils->getnodetype($nodes, "ppc"); foreach my $nn (@$nodes) { - $request->{hwtype} =$$typehash{$nn}; + $request->{hwtype} = $$typehash{$nn}; last if ($request->{hwtype}); } - - my $supported = $rsp{$request->{hwtype}}; - + + my $supported = $rsp{ $request->{hwtype} }; + ############################################# # Responds with usage statement ############################################# local *usage = sub { my $usage_string = xCAT::Usage->getUsage($command); - return( [$_[0], $usage_string] ); + return ([ $_[0], $usage_string ]); }; ############################################# # Process command-line arguments ############################################# - if ( !defined( $args )) { - return(usage( "No command specified" )); + if (!defined($args)) { + return (usage("No command specified")); } ############################################# # Checks case in GetOptions, allows opts # to be grouped (e.g. -vx), and terminates # at the first unrecognized option. ############################################# - @ARGV = @$args; + @ARGV = @$args; $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); + Getopt::Long::Configure("bundling"); $request->{method} = undef; - if ( !GetOptions( \%opt, qw(V|verbose resetnet))) { - return( usage() ); + if (!GetOptions(\%opt, qw(V|verbose resetnet))) { + return (usage()); } #################################### # Check for "-" with no option #################################### - if ( grep(/^-$/, @ARGV )) { - return(usage( "Missing option: -" )); + if (grep(/^-$/, @ARGV)) { + return (usage("Missing option: -")); } #################################### - # Check for "=" with no argument + # Check for "=" with no argument #################################### - if (my ($c) = grep(/=$/, @ARGV )) { - return(usage( "Missing argument: $c" )); + if (my ($c) = grep(/=$/, @ARGV)) { + return (usage("Missing argument: $c")); } #################################### # Check for unsupported commands #################################### my @arg_array = @ARGV; - my @fsp_cmds = (); - my @ppc_cmds = (); - foreach my $arg ( @arg_array ) { - my ($command,$value) = split( /=/, $arg ); - if ( !grep( /^$command$/, @$supported) and !$opt{resetnet}) { + my @fsp_cmds = (); + my @ppc_cmds = (); + foreach my $arg (@arg_array) { + my ($command, $value) = split(/=/, $arg); + if (!grep(/^$command$/, @$supported) and !$opt{resetnet}) { $request->{arg} = [$arg]; - my $res = xCAT::PPCcfg::parse_args($request, @_); + my $res = xCAT::PPCcfg::parse_args($request, @_); if (ref($res) eq 'ARRAY') { - my $check_cmd = &check_command($command, \%rsp); - if (!defined($check_cmd)) { + my $check_cmd = &check_command($command, \%rsp); + if (!defined($check_cmd)) { return $res; - } else { - return ([$_[0], "'$command' is only supported by type $check_cmd."]); + } else { + return ([ $_[0], "'$command' is only supported by type $check_cmd." ]); } } else { push @ppc_cmds, $command; - } + } } else { push @fsp_cmds, $command; } - if ( exists( $cmds{$command} )) { - return(usage( "Command multiple times: $command" )); + if (exists($cmds{$command})) { + return (usage("Command multiple times: $command")); } $cmds{$command} = $value; } - + $request->{arg} = \@arg_array; if (scalar(@fsp_cmds) && scalar(@ppc_cmds)) { my $fsp_cmds_string = &array_to_string(\@fsp_cmds); my $ppc_cmds_string = &array_to_string(\@ppc_cmds); return (usage("Invalid command array: $fsp_cmds_string can not execute with $ppc_cmds_string.")); - } elsif(scalar(@ppc_cmds)) { + } elsif (scalar(@ppc_cmds)) { my @enableASMI = xCAT::TableUtils->get_site_attribute("enableASMI"); if (defined($enableASMI[0])) { $enableASMI[0] =~ tr/a-z/A-Z/; # convert to upper if (($enableASMI[0] eq "1") || ($enableASMI[0] eq "YES")) { $request->{enableASMI} = 1; - } - } + } + } if ($request->{enableASMI} ne '1') { - return (usage( "You should enable \"ASMI\" first for \'$command\'.")); + return (usage("You should enable \"ASMI\" first for \'$command\'.")); } } #################################### - # Check command arguments + # Check command arguments #################################### - foreach ( keys %cmds ) { - if ( $cmds{$_} ) { - my $result = parse_option( $request, $_, $cmds{$_} ); - if ( $result ) { - return( usage($result) ); + foreach (keys %cmds) { + if ($cmds{$_}) { + my $result = parse_option($request, $_, $cmds{$_}); + if ($result) { + return (usage($result)); } } elsif ($_ =~ /_passwd$/) { - return( usage("No argument specified for '$_'")); - } + return (usage("No argument specified for '$_'")); + } } - + #################################### - # Return method to invoke + # Return method to invoke #################################### #if ( $request->{hwtype} =~ /(^hmc|ivm)$/ ) { # $request->{method} = "cfg"; @@ -260,41 +261,41 @@ sub parse_args { #################################### # Return method to invoke #################################### - if ( exists($cmds{frame}) or exists($cmds{cec_off_policy})) { + if (exists($cmds{frame}) or exists($cmds{cec_off_policy})) { $request->{hcp} = (exists($cmds{frame})) ? "bpa" : "fsp"; - $request->{method} = "cfg"; - return( \%opt ); + $request->{method} = "cfg"; + return (\%opt); } #################################### # Return method to invoke #################################### - if ( $opt{resetnet} ) { - $request->{hcp} = "fsp"; + if ($opt{resetnet}) { + $request->{hcp} = "fsp"; $request->{method} = "resetnet"; - return( \%opt ); + return (\%opt); } - if(exists($cmds{sysname}) or exists($cmds{pending_power_on_side}) or exists($cmds{BSR}) - or exists($cmds{setup_failover}) or exists($cmds{force_failover}) or exists ($cmds{huge_page})) { - $request->{hcp} = $request->{hwtype} eq 'frame' ? "bpa":"fsp"; + if (exists($cmds{sysname}) or exists($cmds{pending_power_on_side}) or exists($cmds{BSR}) + or exists($cmds{setup_failover}) or exists($cmds{force_failover}) or exists($cmds{huge_page})) { + $request->{hcp} = $request->{hwtype} eq 'frame' ? "bpa" : "fsp"; $request->{method} = "do_fspapi_function"; return (\%opt); } #################################### # Return method to invoke #################################### - if ( exists($cmds{HMC_passwd}) or exists($cmds{general_passwd}) or exists($cmds{admin_passwd}) or exists($cmds{"*_passwd"}) ) { - $request->{hcp} = "fsp"; + if (exists($cmds{HMC_passwd}) or exists($cmds{general_passwd}) or exists($cmds{admin_passwd}) or exists($cmds{"*_passwd"})) { + $request->{hcp} = "fsp"; $request->{method} = "passwd"; - return( \%opt ); + return (\%opt); } $request->{method} = \%cmds; - return( \%opt ); + return (\%opt); } ########################################################################## -# Parse the command line optional arguments +# Parse the command line optional arguments ########################################################################## sub parse_option { @@ -302,7 +303,7 @@ sub parse_option { my $command = shift; my $value = shift; - + #################################### # Password #################################### @@ -313,32 +314,32 @@ sub parse_option { # } #} - if ( $command eq 'HMC_passwd' or $command eq 'admin_passwd' or $command eq 'general_passwd' or $command eq "*_passwd" ) { - my ($passwd,$newpasswd) = split /,/, $value; - if ( !$newpasswd ) { - return( "New password couldn't be empty for user 'HMC', 'admin' or 'general'" ); + if ($command eq 'HMC_passwd' or $command eq 'admin_passwd' or $command eq 'general_passwd' or $command eq "*_passwd") { + my ($passwd, $newpasswd) = split /,/, $value; + if (!$newpasswd) { + return ("New password couldn't be empty for user 'HMC', 'admin' or 'general'"); } } - if ( $command eq 'frame' ){ - if ( $value !~ /^\d+$/i && $value ne '*' ) { - return( "Invalid frame number '$value'" ); + if ($command eq 'frame') { + if ($value !~ /^\d+$/i && $value ne '*') { + return ("Invalid frame number '$value'"); } } - if ( $command eq 'cec_off_policy' ){ - if ( $value !~ /^poweroff$/i && $value !~ /^stayon$/i ) { - return( "Invalid cec_off_policy '$value'" ); + if ($command eq 'cec_off_policy') { + if ($value !~ /^poweroff$/i && $value !~ /^stayon$/i) { + return ("Invalid cec_off_policy '$value'"); } } if ($command eq 'sysname') { if ($value ne '*') { if ($value !~ /^[a-zA-Z0-9-_]+$/) { - return( "Invalid sysname param '$value'" ); - } elsif (scalar(@{$request->{node}}) gt '1') { - return( "Invalid sysname param '$value'" ); + return ("Invalid sysname param '$value'"); + } elsif (scalar(@{ $request->{node} }) gt '1') { + return ("Invalid sysname param '$value'"); } - my $len = rindex $value."\$", "\$"; + my $len = rindex $value . "\$", "\$"; if ($len > '31') { return ("Invalid sysname param '$value', name is too long, max 31 characters"); } @@ -354,85 +355,87 @@ sub parse_option { return ("Invalid setup_failover param '$value'"); } } - if ($command =~ /^(BSR|force_failover)$/ ) { + if ($command =~ /^(BSR|force_failover)$/) { return ("BSR value can not be set"); } if ($command =~ /^huge_page$/) { - if ($value !~ /^[0-9]+$/) { - return ("Invalid huge page param '$value'"); - } + if ($value !~ /^[0-9]+$/) { + return ("Invalid huge page param '$value'"); + } } return undef; } + sub check_node_info { - my $hash = shift; - my $invalid_node = undef; - while (my ($mtsm, $h) = each (%$hash)) { - while (my ($name, $d) = each(%$h)) { - if (@$d[4] !~ /^(cec|frame|blade)$/) { - $invalid_node = $name; - last; - } - } - } - return $invalid_node; + my $hash = shift; + my $invalid_node = undef; + while (my ($mtsm, $h) = each(%$hash)) { + while (my ($name, $d) = each(%$h)) { + if (@$d[4] !~ /^(cec|frame|blade)$/) { + $invalid_node = $name; + last; + } + } + } + return $invalid_node; } my %fspapi_action = ( - sysname => { - query => { - cec => "get_cec_name", - frame => "get_frame_name" - }, - set => { - cec => "set_cec_name", - frame => "set_frame_name" - } + sysname => { + query => { + cec => "get_cec_name", + frame => "get_frame_name" }, - pending_power_on_side => { - query => { - cec => "list_firmware_level", - blade => "list_firmware_level", - frame => "list_firmware_level" - }, - set => { - cec => "set_ipl_param", - blade => "set_ipl_param", - frame => "set_ipl_param" - } + set => { + cec => "set_cec_name", + frame => "set_frame_name" + } + }, + pending_power_on_side => { + query => { + cec => "list_firmware_level", + blade => "list_firmware_level", + frame => "list_firmware_level" }, - BSR => { - query => { - cec => "get_cec_bsr" - } + set => { + cec => "set_ipl_param", + blade => "set_ipl_param", + frame => "set_ipl_param" + } + }, + BSR => { + query => { + cec => "get_cec_bsr" + } + }, + setup_failover => { + query => { + cec => "cec_setup_failover" }, - setup_failover => { - query => { - cec => "cec_setup_failover" - }, - set => { - cec => "cec_setup_failover" - } + set => { + cec => "cec_setup_failover" + } + }, + force_failover => { + query => { + cec => "cec_force_failover" + } + }, + huge_page => { + query => { + cec => "get_huge_page" }, - force_failover => { - query => { - cec => "cec_force_failover" - } - }, - huge_page => { - query => { - cec => "get_huge_page" - }, - set => { - cec => "set_huge_page" - } - } + set => { + cec => "set_huge_page" + } + } ); + sub do_process_query_res { - my $name = shift; - my $cmd = shift; + my $name = shift; + my $cmd = shift; my $result = shift; - my $res = shift; + my $res = shift; if (@$res[2] != 0) { push @$result, $res; return "Error"; @@ -443,33 +446,35 @@ sub do_process_query_res { my @values = split(/\n/, @$res[1]); foreach my $v (@values) { if ($v =~ /pend_power_on_side_(\w+)=(temp|perm),/) { - push @$result, [$name, "Pending Power On Side \L\u$1: $2", '0']; + push @$result, [ $name, "Pending Power On Side \L\u$1: $2", '0' ]; } else { - push @$result, [$name, $v, '1']; + push @$result, [ $name, $v, '1' ]; return "Error"; } } } elsif ($cmd =~ /^(BSR|huge_page)$/) { my @values = split(/\n/, @$res[1]); foreach my $v (@values) { - push @$result, [$name, $v, '0']; + push @$result, [ $name, $v, '0' ]; } } else { push @$result, $res; } return undef; } + sub do_query { my $request = shift; - my $hash = shift; - my $cmd = shift; - my @result = (); + my $hash = shift; + my $cmd = shift; + my @result = (); while (my ($mtms, $h) = each(%$hash)) { - while (my($name, $d) = each(%$h)) { - my $action = $fspapi_action{$cmd}{query}{@$d[4]}; - xCAT::MsgUtils->verbose_message($request, "rspconfig :$action for node:$name."); + while (my ($name, $d) = each(%$h)) { + my $action = $fspapi_action{$cmd}{query}{ @$d[4] }; + xCAT::MsgUtils->verbose_message($request, "rspconfig :$action for node:$name."); my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, $action); &do_process_query_res($name, $cmd, \@result, $values); + #my $res = &do_process_query_res($name, $cmd, \@result, $values); #if (defined($res)) { # last; @@ -478,47 +483,51 @@ sub do_query { } return (\@result); } + sub do_set_get_para { my $node_name = shift; - my $cmd = shift; - my $value = shift; + my $cmd = shift; + my $value = shift; if ($cmd =~ /^sysname$/) { return (($value eq '*') ? $node_name : $value); - } elsif ($cmd =~ /^pending_power_on_side$/){ + } elsif ($cmd =~ /^pending_power_on_side$/) { return ($value =~ /^perm$/) ? '0' : '1'; } elsif ($cmd =~ /^setup_failover$/) { return ($value =~ /^enable$/) ? '1' : '0'; } else { - return $value; + return $value; } } sub do_process_set_res { - my $name = shift; - my $cmd = shift; + my $name = shift; + my $cmd = shift; my $result = shift; - my $res = shift; + my $res = shift; if (@$res[1] && @$res[1] !~ /success/i) { push @$result, $res; return "Error"; } else { - push @$result, [$name, "Success", 0]; + push @$result, [ $name, "Success", 0 ]; } } + sub do_set { my $request = shift; - my $hash = shift; - my $cmd = shift; - my $value = shift; - my @result = (); + my $hash = shift; + my $cmd = shift; + my $value = shift; + my @result = (); while (my ($mtms, $h) = each(%$hash)) { - while (my($name, $d) = each(%$h)) { - my $action = $fspapi_action{$cmd}{set}{@$d[4]}; - xCAT::MsgUtils->verbose_message($request, "rspconfig :$action for node:$name, param:$value."); + while (my ($name, $d) = each(%$h)) { + my $action = $fspapi_action{$cmd}{set}{ @$d[4] }; + xCAT::MsgUtils->verbose_message($request, "rspconfig :$action for node:$name, param:$value."); my $para = &do_set_get_para($name, $cmd, $value); my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, $action, 0, $para); -# print Dumper($values); + + # print Dumper($values); &do_process_set_res($name, $cmd, \@result, $values); + #my $res = &do_process_set_res($name, $cmd, \@result, $values); #if (defined($res)) { # last; @@ -527,24 +536,26 @@ sub do_set { } return (\@result); } + sub do_fspapi_function { my $request = shift; - my $hash = shift; - my $exp = shift; - my @ret = (); + my $hash = shift; + my $exp = shift; + my @ret = (); my $res; my $args = $request->{arg}; my @fspapi_array = qw/sysname pending_power_on_side BSR setup_failover force_failover huge_page/; my $invalid_node = &check_node_info($hash); + if (defined($invalid_node)) { - return ([[$invalid_node, "Node must be CEC or Frame", '1']]); + return ([ [ $invalid_node, "Node must be CEC or Frame", '1' ] ]); } foreach my $arg (@$args) { my ($cmd, $value) = split /=/, $arg; - if (!grep(/^$cmd$/, @fspapi_array)) { + if (!grep(/^$cmd$/, @fspapi_array)) { my $fspapi_array_string = &array_to_string(\@fspapi_array); - return ([["Error", "'$cmd' can not execute with $fspapi_array_string", '1']]); - } + return ([ [ "Error", "'$cmd' can not execute with $fspapi_array_string", '1' ] ]); + } if ($value) { $res = &do_set($request, $hash, $cmd, $value) } else { @@ -568,20 +579,21 @@ sub passwd { my @output = (); my $default; - foreach my $arg ( @$args ) { - my ($user,$value) = split /=/, $arg; - if ($user !~ /_passwd$/) { - return ([["Error", "'$user' can not execute with '*_passwd' commands", '1']]); - } - my ($passwd,$newpasswd) = split /,/, $value; - $user =~ s/_passwd$//; - #$user =~ s/^HMC$/access/g; - - if( !$passwd) { - $default = 1; + foreach my $arg (@$args) { + my ($user, $value) = split /=/, $arg; + if ($user !~ /_passwd$/) { + return ([ [ "Error", "'$user' can not execute with '*_passwd' commands", '1' ] ]); } - - if ( $user eq "*" ) { + my ($passwd, $newpasswd) = split /,/, $value; + $user =~ s/_passwd$//; + + #$user =~ s/^HMC$/access/g; + + if (!$passwd) { + $default = 1; + } + + if ($user eq "*") { push @$users, "HMC"; push @$users, "admin"; push @$users, "general"; @@ -589,37 +601,37 @@ sub passwd { push @$users, $user; } - foreach my $usr ( @$users ) { - if( $default == 1 ) { - $passwd = $default_passwd{$usr}; - } - - while ( my ($cec,$h) = each(%$hash) ) { - while ( my ($node,$d) = each(%$h) ) { - my $type = @$d[4]; - my $fsp_api = ($::XCATROOT) ? "$::XCATROOT/sbin/fsp-api" : "/opt/xcat/sbin/fsp-api"; - xCAT::MsgUtils->verbose_message($request, "rspconfig :modify password of $usr for node:$node."); - my $cmd = xCAT::FSPcfg::fsp_api_passwd ($request, $node, $d, $usr, $passwd, $newpasswd); - my $Rc = @$cmd[2]; - my $data = @$cmd[1]; - my $usr_back = $usr; - $usr_back =~ s/^access$/HMC/g; - push @output,[$node,"$usr_back: $data",$Rc]; + foreach my $usr (@$users) { + if ($default == 1) { + $passwd = $default_passwd{$usr}; + } + + while (my ($cec, $h) = each(%$hash)) { + while (my ($node, $d) = each(%$h)) { + my $type = @$d[4]; + my $fsp_api = ($::XCATROOT) ? "$::XCATROOT/sbin/fsp-api" : "/opt/xcat/sbin/fsp-api"; + xCAT::MsgUtils->verbose_message($request, "rspconfig :modify password of $usr for node:$node."); + my $cmd = xCAT::FSPcfg::fsp_api_passwd($request, $node, $d, $usr, $passwd, $newpasswd); + my $Rc = @$cmd[2]; + my $data = @$cmd[1]; + my $usr_back = $usr; + $usr_back =~ s/^access$/HMC/g; + push @output, [ $node, "$usr_back: $data", $Rc ]; - ################################## - # Write the new password to table - ################################## - if ( $Rc == 0 ) { - xCAT::MsgUtils->verbose_message($request, "rspconfig :update xCATdb for node:$node,ID:$usr."); - xCAT::PPCdb::update_credentials( $node, $type, $usr, $newpasswd ); - } - } - } - } - } - - return( \@output ); + ################################## + # Write the new password to table + ################################## + if ($Rc == 0) { + xCAT::MsgUtils->verbose_message($request, "rspconfig :update xCATdb for node:$node,ID:$usr."); + xCAT::PPCdb::update_credentials($node, $type, $usr, $newpasswd); + } + } + } + } + } + + return (\@output); } ########################################################################## @@ -633,22 +645,22 @@ sub cfg { my $args = $request->{arg}; my $result; - foreach ( @$args ) { + foreach (@$args) { ################################## # Ignore switches in command-line ################################## - unless ( /^-/ ) { - my ($cmd,$value) = split /=/; - if ($cmd !~ /(frame|cec_off_policy)/) { - return ([["Error", "'$cmd' can not execute with 'frame' or 'cec_off_policy'", '1']]); - } + unless (/^-/) { + my ($cmd, $value) = split /=/; + if ($cmd !~ /(frame|cec_off_policy)/) { + return ([ [ "Error", "'$cmd' can not execute with 'frame' or 'cec_off_policy'", '1' ] ]); + } no strict 'refs'; - $result = $rspconfig{$cmd}( $request, $value, $hash ); + $result = $rspconfig{$cmd}($request, $value, $hash); use strict; } } - return( $result ); + return ($result); } sub frame { @@ -657,14 +669,14 @@ sub frame { my $hash = shift; my $arg = $request->{arg}; - foreach ( @$arg ) { + foreach (@$arg) { my $result; my $Rc; my $data; my ($cmd, $value) = split /=/, $_; - if ( $cmd ne "frame" ) { - return( [["Error","Multiple option $cmd and frame is not accepted", -1]] ); + if ($cmd ne "frame") { + return ([ [ "Error", "Multiple option $cmd and frame is not accepted", -1 ] ]); } ################################# @@ -672,91 +684,92 @@ sub frame { # the frame number between hcp # and database ################################# - my $tab = xCAT::Table->new( "ppc" ); - - while ( my ($cec,$h) = each(%$hash) ) { - while ( my ($node,$d) = each(%$h) ) { - if ( !defined($value) ) { + my $tab = xCAT::Table->new("ppc"); + + while (my ($cec, $h) = each(%$hash)) { + while (my ($node, $d) = each(%$h)) { + if (!defined($value)) { ################################# # Get frame number ################################# - #$data = xCAT::PPCcli::lssyscfg( $exp, @$d[4], @$d[2], 'frame_num' ); + #$data = xCAT::PPCcli::lssyscfg( $exp, @$d[4], @$d[2], 'frame_num' ); xCAT::MsgUtils->verbose_message($request, "rspconfig :get_frame_number for node:$node."); - $data = xCAT::FSPUtils::fsp_api_action( $request, $node, $d, "get_frame_number"); + $data = xCAT::FSPUtils::fsp_api_action($request, $node, $d, "get_frame_number"); $Rc = pop(@$data); ################################# # Return error ################################# - if ( $Rc != 0 || @$data[1] =~ /Error/ ) { - return( [[$node,"@$data[1]. If just set the frame number, please wait for 5-10 minutes. Otherwise, maybe other problems cause this failure.",$Rc]] ); + if ($Rc != 0 || @$data[1] =~ /Error/) { + return ([ [ $node, "@$data[1]. If just set the frame number, please wait for 5-10 minutes. Otherwise, maybe other problems cause this failure.", $Rc ] ]); } - push @$result, [$node,@$data[1], 0]; + push @$result, [ $node, @$data[1], 0 ]; ################################# # Set frame number to database ################################# - $tab->setNodeAttribs( $node, { id=>@$data[1] } ); + $tab->setNodeAttribs($node, { id => @$data[1] }); - } elsif ( $value eq '*' ) { + } elsif ($value eq '*') { ################################# # Set frame number - # Read the settings from database + # Read the settings from database ################################# - my $ent=$tab->getNodeAttribs( $node,['id'] ); + my $ent = $tab->getNodeAttribs($node, ['id']); ################################# # Return error ################################# - if ( !defined($ent) or !defined($ent->{id}) ) { - return( [[$node,"Cannot find frame num in database", -1]] ); + if (!defined($ent) or !defined($ent->{id})) { + return ([ [ $node, "Cannot find frame num in database", -1 ] ]); } - #$data = xCAT::PPCcli::chsyscfg( $exp, "bpa", $d, "frame_num=".$ent->{id} ); + + #$data = xCAT::PPCcli::chsyscfg( $exp, "bpa", $d, "frame_num=".$ent->{id} ); xCAT::MsgUtils->verbose_message($request, "rspconfig :set_frame_number for node:$node,id:$ent->{id}."); - $data = xCAT::FSPUtils::fsp_api_action( $request, $node, $d, "set_frame_number", 0, $ent->{id}); + $data = xCAT::FSPUtils::fsp_api_action($request, $node, $d, "set_frame_number", 0, $ent->{id}); $Rc = pop(@$data); ################################# # Return error ################################# - if ( $Rc != 0 ) { - return( [[$node,@$data[1],$Rc]] ); + if ($Rc != 0) { + return ([ [ $node, @$data[1], $Rc ] ]); } - push @$result, [$node,@$data[1], 0]; - push @$result, [$node,"It will take several minutes to complete. So please wait for 5-10 minutes, then the other operations could be done. Otherwise, the other operation will fail.", 0]; + push @$result, [ $node, @$data[1], 0 ]; + push @$result, [ $node, "It will take several minutes to complete. So please wait for 5-10 minutes, then the other operations could be done. Otherwise, the other operation will fail.", 0 ]; } else { ################################# # Set frame number # Read the frame number from opt ################################# - #$data = xCAT::PPCcli::chsyscfg( $exp, "bpa", $d, "frame_num=$value" ); + #$data = xCAT::PPCcli::chsyscfg( $exp, "bpa", $d, "frame_num=$value" ); xCAT::MsgUtils->verbose_message($request, "rspconfig :set_frame_number for node:$node,id:$value."); - $data = xCAT::FSPUtils::fsp_api_action( $request, $node, $d, "set_frame_number", 0, $value); - $Rc = pop(@$data); + $data = xCAT::FSPUtils::fsp_api_action($request, $node, $d, "set_frame_number", 0, $value); + $Rc = pop(@$data); ################################# # Return error ################################# - if ( $Rc != 0 ) { - return( [[$node,@$data[1],$Rc]] ); + if ($Rc != 0) { + return ([ [ $node, @$data[1], $Rc ] ]); } - push @$result, [$node,@$data[1],0]; - push @$result, [$node,"It will take several minutes to complete. So please wait for several minutes, then the other operations could be done. Otherwise, the other operation will fail.", 0]; + push @$result, [ $node, @$data[1], 0 ]; + push @$result, [ $node, "It will take several minutes to complete. So please wait for several minutes, then the other operations could be done. Otherwise, the other operation will fail.", 0 ]; ################################# # Set frame number to database ################################# - $tab->setNodeAttribs( $node, { id=>$value } ); + $tab->setNodeAttribs($node, { id => $value }); } } - return( [@$result] ); - } + return ([@$result]); + } } } @@ -765,67 +778,67 @@ sub cec_off_policy { my $value = shift; my $hash = shift; my $arg = $request->{arg}; - - foreach ( @$arg ) { + + foreach (@$arg) { my $result; my $Rc; my $data; my ($cmd, $value) = split /=/, $_; - if ( $cmd ne "cec_off_policy" ) { - return( [["Error","Multiple option $cmd and cec is not accepted", -1]] ); + if ($cmd ne "cec_off_policy") { + return ([ [ "Error", "Multiple option $cmd and cec is not accepted", -1 ] ]); } - while ( my ($cec,$h) = each(%$hash) ) { - while ( my ($node,$d) = each(%$h) ) { - if ( !defined($value) ) { + while (my ($cec, $h) = each(%$hash)) { + while (my ($node, $d) = each(%$h)) { + if (!defined($value)) { ################################# - # Get platform IPL parameters + # Get platform IPL parameters ################################# xCAT::MsgUtils->verbose_message($request, "rspconfig :get_phyp_cfg_power_off_policy for node:$node."); - $data = xCAT::FSPUtils::fsp_api_action( $request, $node, $d, "get_phyp_cfg_power_off_policy"); + $data = xCAT::FSPUtils::fsp_api_action($request, $node, $d, "get_phyp_cfg_power_off_policy"); $Rc = pop(@$data); ################################# # Return error ################################# - if ( $Rc != 0 ) { - return( [[$node,@$data[1],$Rc]] ); + if ($Rc != 0) { + return ([ [ $node, @$data[1], $Rc ] ]); } - - @$data[1] =~ /cec_off_policy=(\w*);/; - push @$result, [$node, $1, 0]; + @$data[1] =~ /cec_off_policy=(\w*);/; + + push @$result, [ $node, $1, 0 ]; - } else { + } else { ################################# - # Set cec off policy + # Set cec off policy ################################# xCAT::MsgUtils->verbose_message($request, "rspconfig :set power_off_policy for node:$node,policy:$value."); - if( $value eq "poweroff") { - $value = "cec_off_policy_poweroff"; - } else { - $value = "cec_off_policy_stayon"; - } - $data = xCAT::FSPUtils::fsp_api_action( $request, $node, $d, $value); - $Rc = pop(@$data); + if ($value eq "poweroff") { + $value = "cec_off_policy_poweroff"; + } else { + $value = "cec_off_policy_stayon"; + } + $data = xCAT::FSPUtils::fsp_api_action($request, $node, $d, $value); + $Rc = pop(@$data); ################################# # Return error ################################# - if ( $Rc != 0 ) { - return( [[$node,@$data[1],$Rc]] ); + if ($Rc != 0) { + return ([ [ $node, @$data[1], $Rc ] ]); } - push @$result, [$node,"Success",0]; + push @$result, [ $node, "Success", 0 ]; } } - return( [@$result] ); - } + return ([@$result]); + } } } @@ -841,29 +854,29 @@ sub cec_off_policy { # Invoke fsp_api to change the passwords and store updated passwd in db ########################################################################## sub fsp_api_passwd { - my $request = shift; - my $node_name = shift; - my $attrs = shift; - my $user = shift; - my $passwd = shift; - my $newpasswd = shift; - my $id = 1; - my $fsp_name = (); - my $fsp_ip = (); - my $type = (); # fsp|lpar -- 0. BPA -- 1 + my $request = shift; + my $node_name = shift; + my $attrs = shift; + my $user = shift; + my $passwd = shift; + my $newpasswd = shift; + my $id = 1; + my $fsp_name = (); + my $fsp_ip = (); + my $type = (); # fsp|lpar -- 0. BPA -- 1 my @result; - my $Rc = 0 ; + my $Rc = 0; my %outhash = (); - my $res = 0 ; - my $fsp_api = ($::XCATROOT) ? "$::XCATROOT/sbin/fsp-api" : "/opt/xcat/sbin/fsp-api"; + my $res = 0; + my $fsp_api = ($::XCATROOT) ? "$::XCATROOT/sbin/fsp-api" : "/opt/xcat/sbin/fsp-api"; - $id = $$attrs[0]; + $id = $$attrs[0]; $fsp_name = $$attrs[3]; ############################ # Set type for FSP or BPA ############################ - if($$attrs[4] =~ /^fsp$/ || $$attrs[4] =~ /^lpar$/ || $$attrs[4] =~ /^cec$/) { + if ($$attrs[4] =~ /^fsp$/ || $$attrs[4] =~ /^lpar$/ || $$attrs[4] =~ /^cec$/) { $type = 0; } else { $type = 1; @@ -875,26 +888,26 @@ sub fsp_api_passwd { #$fsp_ip = xCAT::NetworkUtils::get_hdwr_ip($fsp_name); #$fsp_ip = xCAT::NetworkUtils::getNodeIPaddress($fsp_name); #$fsp_ip = xCAT::Utils::getIPaddress($fsp_name); - $fsp_ip = xCAT::FSPUtils::getIPaddress($request, $$attrs[4], $fsp_name ); - if(!defined($fsp_ip) or ($fsp_ip == -3)) { + $fsp_ip = xCAT::FSPUtils::getIPaddress($request, $$attrs[4], $fsp_name); + if (!defined($fsp_ip) or ($fsp_ip == -3)) { $res = "Failed to get IP address for $fsp_name."; - return ([$node_name, $res, -1]); + return ([ $node_name, $res, -1 ]); } ################################# # Create command and run command ################################# my $cmd; - if( $passwd ne "" ) { + if ($passwd ne "") { $cmd = "$fsp_api -a set_fsp_pw -u $user -p $passwd -P $newpasswd -t $type:$fsp_ip:$id:$node_name: "; } else { - $cmd = "$fsp_api -a set_fsp_pw -u $user -P $newpasswd -t $type:$fsp_ip:$id:$node_name: "; + $cmd = "$fsp_api -a set_fsp_pw -u $user -P $newpasswd -t $type:$fsp_ip:$id:$node_name: "; } $SIG{CHLD} = (); $res = xCAT::Utils->runcmd($cmd, -1); $Rc = $::RUNCMD_RC; - if($Rc == 0) { + if ($Rc == 0) { $res = "Success"; } @@ -904,13 +917,13 @@ sub fsp_api_passwd { ################## #$outhash{ $node_name } = $res; - return( [$node_name,$res, $Rc] ); + return ([ $node_name, $res, $Rc ]); } ########################################################################## -# Do resetnet +# Do resetnet ########################################################################## sub resetnet { my $request = shift; diff --git a/perl-xCAT/xCAT/FSPconn.pm b/perl-xCAT/xCAT/FSPconn.pm index a62a5a83f..48f0e1326 100644 --- a/perl-xCAT/xCAT/FSPconn.pm +++ b/perl-xCAT/xCAT/FSPconn.pm @@ -5,6 +5,7 @@ use strict; use Getopt::Long; use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR); use xCAT::Usage; + #use Data::Dumper; use xCAT::FSPUtils; use xCAT::PPCconn; @@ -24,13 +25,13 @@ my %method = ( sub parse_args { my $request = shift; - my $cmd = $request->{command}; + my $cmd = $request->{command}; ############################### # Invoke correct parse_args ############################### - my $result = $method{$cmd}( $request, $request->{arg}); - return( $result ); + my $result = $method{$cmd}($request, $request->{arg}); + return ($result); } ########################################################################## @@ -40,57 +41,58 @@ sub mkhwconn_parse_args { my $request = shift; my $args = shift; - my %opt = (); + my %opt = (); local *usage = sub { my $usage_string = xCAT::Usage->getUsage("mkhwconn"); - return( [ $_[0], $usage_string] ); + return ([ $_[0], $usage_string ]); }; ############################################# # Process command-line arguments ############################################# - if ( !defined( $args )) { - return(usage( "No command specified" )); + if (!defined($args)) { + return (usage("No command specified")); } - local @ARGV = ref($args) eq 'ARRAY'? @$args:(); + local @ARGV = ref($args) eq 'ARRAY' ? @$args : (); $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); + Getopt::Long::Configure("bundling"); - if ( !GetOptions( \%opt, qw(V|verbose h|help t s:s T=s p=s P=s port=s ) )) { - return( usage() ); + if (!GetOptions(\%opt, qw(V|verbose h|help t s:s T=s p=s P=s port=s ))) { + return (usage()); } - if ( exists $opt{s} ) + if (exists $opt{s}) { my $opttmp = xCAT::PPCconn::mkhwconn_parse_args($request, $args); return $opttmp; } - return usage() if ( exists $opt{h}); + return usage() if (exists $opt{h}); - if ( !exists $opt{t} and !exists $opt{p}) { - return ( usage('Flag -t or -p must be used.')); + if (!exists $opt{t} and !exists $opt{p}) { + return (usage('Flag -t or -p must be used.')); } - if ( exists $opt{t} and exists $opt{p}) + if (exists $opt{t} and exists $opt{p}) { - return( usage('Flags -t and -p cannot be used together.')); + return (usage('Flags -t and -p cannot be used together.')); } - if ( (exists $opt{P} or grep(/^(-P)$/, @$args)) and !exists $opt{p}) + if ((exists $opt{P} or grep(/^(-P)$/, @$args)) and !exists $opt{p}) { - return( usage('Flags -P can only be used when flag -p is specified.')); + return (usage('Flags -P can only be used when flag -p is specified.')); } - + ########################################## # Check if CECs are controlled by a frame ########################################## - my $nodes = $request->{node}; - my $ppctab = xCAT::Table->new( 'ppc' ); + my $nodes = $request->{node}; + my $ppctab = xCAT::Table->new('ppc'); + #my $nodetypetab = xCAT::Table->new( 'nodetype'); - my $vpdtab = xCAT::Table->new( 'vpd'); + my $vpdtab = xCAT::Table->new('vpd'); my @bpa_ctrled_nodes = (); my @no_type_nodes = (); my @error_type_nodes = (); @@ -99,89 +101,91 @@ sub mkhwconn_parse_args ########################################### # mgt=fsp/bpa for PPCconn.pm ########################################## - if ( exists $opt{p} ) + if (exists $opt{p}) { #my $nodetype_hash = $nodetypetab->getNodeAttribs( $opt{p},[qw(nodetype)]); #my $nodetype = $nodetype_hash->{nodetype}; my $nodetype = xCAT::DBobjUtils->getnodetype($opt{p}, "ppc"); - if( !defined($nodetype) ) { - return(usage("Something wrong with the specified HMC (-p Option). The HMC type doesn't exist.")); + if (!defined($nodetype)) { + return (usage("Something wrong with the specified HMC (-p Option). The HMC type doesn't exist.")); } - if ( $nodetype eq 'hmc' ) + if ($nodetype eq 'hmc') { - $request->{ 'hwtype'} = 'hmc'; - } + $request->{'hwtype'} = 'hmc'; + } } - if ( $ppctab) + if ($ppctab) { my $hcp_nodetype = undef; my $typehash = xCAT::DBobjUtils->getnodetype($nodes, "ppc"); for my $node (@$nodes) { - my $node_parent = undef; - my $nodetype = undef; - my $node_hcp_nodetype = undef; + my $node_parent = undef; + my $nodetype = undef; + my $node_hcp_nodetype = undef; + #my $nodetype_hash = $nodetypetab->getNodeAttribs( $node,[qw(nodetype)]); - my $node_parent_hash = $ppctab->getNodeAttribs( $node,[qw(parent)]); - if ( exists $opt{t} ) + my $node_parent_hash = $ppctab->getNodeAttribs($node, [qw(parent)]); + if (exists $opt{t}) { - my $node_hcp_hash = $ppctab->getNodeAttribs( $node,[qw(hcp)]); - if ( $node_hcp_hash->{hcp} ) + my $node_hcp_hash = $ppctab->getNodeAttribs($node, [qw(hcp)]); + if ($node_hcp_hash->{hcp}) { #my $node_hcp_nodetype_hash = $nodetypetab->getNodeAttribs($node_hcp_hash->{hcp},[qw(nodetype)]); #$node_hcp_nodetype = $node_hcp_nodetype_hash->{nodetype}; $node_hcp_nodetype = xCAT::DBobjUtils->getnodetype($node_hcp_hash->{hcp}, "ppc"); } - if ( defined $hcp_nodetype ) + if (defined $hcp_nodetype) { - if ( $hcp_nodetype ne $node_hcp_nodetype ) - { - return( usage("Nodetype for all the nodes' hcp must be the same.") ); + if ($hcp_nodetype ne $node_hcp_nodetype) + { + return (usage("Nodetype for all the nodes' hcp must be the same.")); } } else { $hcp_nodetype = $node_hcp_nodetype; - if ( $hcp_nodetype eq 'hmc' ) - { - $request->{ 'hwtype'} = 'hmc'; + if ($hcp_nodetype eq 'hmc') + { + $request->{'hwtype'} = 'hmc'; } } - + } + #$nodetype = $nodetype_hash->{nodetype}; - $nodetype = $$typehash{$node}; + $nodetype = $$typehash{$node}; $node_parent = $node_parent_hash->{parent}; - if ( !$nodetype ) + if (!$nodetype) { push @no_type_nodes, $node; next; } else { - unless ( $nodetype =~ /^(fsp|bpa|frame|cec|hmc|blade)$/) + unless ($nodetype =~ /^(fsp|bpa|frame|cec|hmc|blade)$/) { - push @error_type_nodes, $node; - next; + push @error_type_nodes, $node; + next; } } - - if (( $nodetype eq 'fsp' or $nodetype eq 'cec') and - $node_parent and + + if (($nodetype eq 'fsp' or $nodetype eq 'cec') and + $node_parent and $node_parent ne $node) { push @bpa_ctrled_nodes, $node; } - - if ( $nodetype eq 'bpa') + + if ($nodetype eq 'bpa') { - my $my_frame_bpa_cec = getFrameMembers( $node, $vpdtab, $ppctab); + my $my_frame_bpa_cec = getFrameMembers($node, $vpdtab, $ppctab); push @frame_members, @$my_frame_bpa_cec; } - if ( $nodetype eq 'frame') + if ($nodetype eq 'frame') { - my $my_frame_bpa_cec = xCAT::DBobjUtils::getcecchildren( $node) ; - push @frame_members, @$my_frame_bpa_cec if($my_frame_bpa_cec); + my $my_frame_bpa_cec = xCAT::DBobjUtils::getcecchildren($node); + push @frame_members, @$my_frame_bpa_cec if ($my_frame_bpa_cec); push @frame_members, $node; } @@ -191,63 +195,66 @@ sub mkhwconn_parse_args if (scalar(@no_type_nodes)) { my $tmp_nodelist = join ',', @no_type_nodes; - return ( usage("Attribute nodetype.nodetype cannot be found for node(s) $tmp_nodelist. Please define first and try again.\n")); + return (usage("Attribute nodetype.nodetype cannot be found for node(s) $tmp_nodelist. Please define first and try again.\n")); } if (scalar(@error_type_nodes)) { my $tmp_nodelist = join ',', @error_type_nodes; - return ( usage("Incorrect nodetype for nodes(s): $tmp_nodelist. Please modify first and try again.\n")); + return (usage("Incorrect nodetype for nodes(s): $tmp_nodelist. Please modify first and try again.\n")); } + #if (scalar(@bpa_ctrled_nodes)) #{ # my $tmp_nodelist = join ',', @bpa_ctrled_nodes; # return ( usage("Node(s) $tmp_nodelist is(are) controlled by BPA.")); #} - - if ( scalar( @frame_members)) + + if (scalar(@frame_members)) { - my @all_nodes = xCAT::Utils::get_unique_members( @$nodes, @frame_members); + my @all_nodes = xCAT::Utils::get_unique_members(@$nodes, @frame_members); $request->{node} = \@all_nodes; } - # Set HW type to 'hmc' anyway, so that this command will not going to + + # Set HW type to 'hmc' anyway, so that this command will not going to # PPCfsp.pm # $request->{ 'hwtype'} = 'hmc'; - if( ! exists $opt{T} ) + if (!exists $opt{T}) { - $opt{T} = "lpar"; #defaut value is lpar. - #return( usage('Missing -T option. The value can be lpar or fnm.')); + $opt{T} = "lpar"; #defaut value is lpar. + #return( usage('Missing -T option. The value can be lpar or fnm.')); } - - if( $opt{T} eq "lpar") { - $opt{T} = 0; - } elsif($opt{T} eq "fnm") { - $opt{T} = 1; + + if ($opt{T} eq "lpar") { + $opt{T} = 0; + } elsif ($opt{T} eq "fnm") { + $opt{T} = 1; } else { - return( usage('Wrong value of -T option. The value can be lpar or fnm. The defaut value is lpar.')); + return (usage('Wrong value of -T option. The value can be lpar or fnm. The defaut value is lpar.')); } - - if( ! exists $opt{port} ) + + if (!exists $opt{port}) { $opt{port} = "[0|1]"; - } elsif( $opt{port} ne "0" and $opt{port} ne "1") + } elsif ($opt{port} ne "0" and $opt{port} ne "1") { if ($opt{port} eq "0,1") { - return ([0, "The option --port only be used to specify special port value, please don't specify this value if you want to use all ports."]); + return ([ 0, "The option --port only be used to specify special port value, please don't specify this value if you want to use all ports." ]); } else { - return( usage('Wrong value of --port option. The value can only be 0 or 1.')); + return (usage('Wrong value of --port option. The value can only be 0 or 1.')); } } - + $ppctab->close(); + #$nodetypetab->close(); $vpdtab->close(); - if ( scalar( @ARGV)) { - return(usage( "No additional flag is support by this command" )); + if (scalar(@ARGV)) { + return (usage("No additional flag is support by this command")); } $request->{method} = 'mkhwconn'; - return( \%opt); + return (\%opt); } #################################################### @@ -256,38 +263,39 @@ sub mkhwconn_parse_args #ppc/vpd nodes cache my @all_ppc_nodes; my @all_vpd_nodes; + sub getFrameMembers { - my $node = shift; #this a BPA node - my $vpdtab = shift; - my $ppctab = shift; + my $node = shift; #this a BPA node + my $vpdtab = shift; + my $ppctab = shift; my @frame_members = (); my @bpa_nodes = (); - my $vpdhash = $vpdtab->getNodeAttribs( $node, [qw(mtm serial)]); - my $mtm = $vpdhash->{mtm}; - my $serial = $vpdhash->{serial}; - if ( scalar( @all_vpd_nodes) == 0) + my $vpdhash = $vpdtab->getNodeAttribs($node, [qw(mtm serial)]); + my $mtm = $vpdhash->{mtm}; + my $serial = $vpdhash->{serial}; + if (scalar(@all_vpd_nodes) == 0) { - @all_vpd_nodes = $vpdtab->getAllNodeAttribs( ['node', 'mtm', 'serial']); + @all_vpd_nodes = $vpdtab->getAllNodeAttribs([ 'node', 'mtm', 'serial' ]); } for my $vpd_node (@all_vpd_nodes) { - if ( $vpd_node->{'mtm'} eq $mtm and $vpd_node->{'serial'} eq $serial) + if ($vpd_node->{'mtm'} eq $mtm and $vpd_node->{'serial'} eq $serial) { push @frame_members, $vpd_node->{'node'}; - push @bpa_nodes, $vpd_node->{'node'}; + push @bpa_nodes, $vpd_node->{'node'}; } } - if ( scalar( @all_ppc_nodes) == 0) + if (scalar(@all_ppc_nodes) == 0) { - @all_ppc_nodes = $ppctab->getAllNodeAttribs( ['node', 'parent']); + @all_ppc_nodes = $ppctab->getAllNodeAttribs([ 'node', 'parent' ]); } for my $bpa_node (@bpa_nodes) { for my $ppc_node (@all_ppc_nodes) { - if ( $ppc_node->{parent} eq $bpa_node) + if ($ppc_node->{parent} eq $bpa_node) { push @frame_members, $ppc_node->{'node'}; } @@ -303,120 +311,122 @@ sub lshwconn_parse_args { my $request = shift; my $args = shift; - my %opt = (); + my %opt = (); local *usage = sub { my $usage_string = xCAT::Usage->getUsage("lshwconn"); - return( [ $_[0], $usage_string] ); + return ([ $_[0], $usage_string ]); }; ############################################# -# Get options in command line + # Get options in command line ############################################# - local @ARGV = ref($args) eq 'ARRAY'? @$args:(); + local @ARGV = ref($args) eq 'ARRAY' ? @$args : (); $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); + Getopt::Long::Configure("bundling"); - if ( exists $opt{s} ) + if (exists $opt{s}) { my $opttmp = xCAT::PPCconn::lshwconn_parse_args($request, $args); return $opttmp; } - - if ( !GetOptions( \%opt, qw(V|verbose h|help T=s s) )) { - return( usage() ); + + if (!GetOptions(\%opt, qw(V|verbose h|help T=s s))) { + return (usage()); } - return usage() if ( exists $opt{h}); - - if( ! exists $opt{T} ) + return usage() if (exists $opt{h}); + + if (!exists $opt{T}) { - $opt{T} = "lpar"; #defaut value is lpar. - #return( usage('Missing -T option. The value can be lpar or fnm.')); + $opt{T} = "lpar"; #defaut value is lpar. + #return( usage('Missing -T option. The value can be lpar or fnm.')); } - - if( $opt{T} eq "lpar") { - $opt{T} = 0; - } elsif($opt{T} eq "fnm") { - $opt{T} = 1; + + if ($opt{T} eq "lpar") { + $opt{T} = 0; + } elsif ($opt{T} eq "fnm") { + $opt{T} = 1; } else { - return( usage('Wrong value of -T option. The value can be lpar or fnm. The defaut value is lpar.')); + return (usage('Wrong value of -T option. The value can be lpar or fnm. The defaut value is lpar.')); } - + ############################################# # Process command-line arguments ############################################# - if ( scalar( @ARGV)) { - return(usage( "No additional flag is support by this command" )); + if (scalar(@ARGV)) { + return (usage("No additional flag is support by this command")); } + #my $nodetypetab = xCAT::Table->new('nodetype'); #if (! $nodetypetab) #{ # return( ["Failed to open table 'nodetype'.\n"]); #} my $nodehmtab = xCAT::Table->new('nodehm'); - if (! $nodehmtab) + if (!$nodehmtab) { - return( ["Failed to open table 'nodehm'.\n"]); + return (["Failed to open table 'nodehm'.\n"]); } - + my $nodetype; - my @no_typenodes = (); - my @no_mgt_nodes = (); + my @no_typenodes = (); + my @no_mgt_nodes = (); my @error_type_nodes = (); - my $typehash = xCAT::DBobjUtils->getnodetype(\@{$request->{node}}, "ppc"); - for my $node ( @{$request->{node}}) + my $typehash = xCAT::DBobjUtils->getnodetype(\@{ $request->{node} }, "ppc"); + for my $node (@{ $request->{node} }) { #my $ent = $nodetypetab->getNodeAttribs( $node, [qw(nodetype)]); - my $nodehm = $nodehmtab->getNodeAttribs( $node, [qw(mgt)]); - if ( ! $nodehm) + my $nodehm = $nodehmtab->getNodeAttribs($node, [qw(mgt)]); + if (!$nodehm) { push @no_mgt_nodes, $node; - next; + next; } my $ttype = $$typehash{$node}; - if ( !$ttype) + if (!$ttype) { push @no_typenodes, $node; next; } - if ( $ttype ne 'fsp' and $ttype ne 'cec' - and $ttype ne 'bpa' and $ttype ne 'frame' and $ttype ne 'blade') + if ($ttype ne 'fsp' and $ttype ne 'cec' + and $ttype ne 'bpa' and $ttype ne 'frame' and $ttype ne 'blade') { push @error_type_nodes, $node; next; } - if ( ! $nodetype) + if (!$nodetype) { - $nodetype = $ttype; #$ent->{nodetype}; + $nodetype = $ttype; #$ent->{nodetype}; } else { - if ( $nodetype ne $ttype) #$ent->{nodetype}) + if ($nodetype ne $ttype) #$ent->{nodetype}) { - return( ["Cannot support multiple node types in this command line.\n"]); + return (["Cannot support multiple node types in this command line.\n"]); } } } if (scalar(@no_typenodes)) { my $tmp_nodelist = join ',', @no_typenodes; - return ( ["Attribute nodetype.nodetype cannot be found for node(s): $tmp_nodelist. Please define first and try again.\n"]); + return (["Attribute nodetype.nodetype cannot be found for node(s): $tmp_nodelist. Please define first and try again.\n"]); } if (scalar(@no_mgt_nodes)) { my $tmp_nodelist = join ',', @no_mgt_nodes; - return( ["Failed to get nodehm.mgt value for node(s) $tmp_nodelist. Please define first and try again.\n"]); + return (["Failed to get nodehm.mgt value for node(s) $tmp_nodelist. Please define first and try again.\n"]); } if (scalar(@error_type_nodes)) { my $tmp_nodelist = join ',', @error_type_nodes; - my $link = (scalar(@error_type_nodes) eq '1')? 'is':'are'; - return( ["Node type of node(s) $tmp_nodelist $link not supported for this command in FSPAPI.\n"]); + my $link = (scalar(@error_type_nodes) eq '1') ? 'is' : 'are'; + return (["Node type of node(s) $tmp_nodelist $link not supported for this command in FSPAPI.\n"]); } + #$nodetypetab->close(); $nodehmtab->close(); - + $request->{nodetype} = $nodetype; $request->{method} = 'lshwconn'; - return( \%opt); + return (\%opt); } ########################################################################## @@ -426,101 +436,102 @@ sub rmhwconn_parse_args { my $request = shift; my $args = shift; - my %opt = (); + my %opt = (); local *usage = sub { my $usage_string = xCAT::Usage->getUsage("rmhwconn"); - return( [ $_[0], $usage_string] ); + return ([ $_[0], $usage_string ]); }; ############################################# # Get options in command line ############################################# - local @ARGV = ref($args) eq 'ARRAY'? @$args:(); + local @ARGV = ref($args) eq 'ARRAY' ? @$args : (); $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); + Getopt::Long::Configure("bundling"); - if ( !GetOptions( \%opt, qw(V|verbose h|help T=s s) )) { - return( usage() ); + if (!GetOptions(\%opt, qw(V|verbose h|help T=s s))) { + return (usage()); } - return usage() if ( exists $opt{h}); + return usage() if (exists $opt{h}); - if ( $opt{s} ) + if ($opt{s}) { my $opttmp = xCAT::PPCconn::rmhwconn_parse_args($request, $args); return $opttmp; - } - - if( ! exists $opt{T} ) + } + + if (!exists $opt{T}) { - $opt{T} = "lpar"; #defaut value is lpar. - #return( usage('Missing -T option. The value can be lpar or fnm.')); + $opt{T} = "lpar"; #defaut value is lpar. + #return( usage('Missing -T option. The value can be lpar or fnm.')); } - - if( $opt{T} eq "lpar") { - $opt{T} = 0; - } elsif($opt{T} eq "fnm") { - $opt{T} = 1; + + if ($opt{T} eq "lpar") { + $opt{T} = 0; + } elsif ($opt{T} eq "fnm") { + $opt{T} = 1; } else { - return( usage('Wrong value of -T option. The value can be lpar or fnm. The default value is lpar.')); + return (usage('Wrong value of -T option. The value can be lpar or fnm. The default value is lpar.')); } - + ############################################# # Process command-line arguments ############################################# - if ( scalar (@ARGV)) { - return(usage( "No additional flag is support by this command" )); + if (scalar(@ARGV)) { + return (usage("No additional flag is support by this command")); } ########################################## # Check if CECs are controlled by a frame ########################################## - my $nodes = $request->{node}; - my $ppctab = xCAT::Table->new( 'ppc' ); - return( ["Failed to open table 'ppc'.\n"]) if ( ! $ppctab); + my $nodes = $request->{node}; + my $ppctab = xCAT::Table->new('ppc'); + return (["Failed to open table 'ppc'.\n"]) if (!$ppctab); + #my $nodetypetab = xCAT::Table->new( 'nodetype'); #return( ["Failed to open table 'nodetype'.\n"]) if ( ! $nodetypetab); - my $vpdtab = xCAT::Table->new( 'vpd'); - return( ["Failed to open table 'vpd'.\n"]) if ( ! $vpdtab); + my $vpdtab = xCAT::Table->new('vpd'); + return (["Failed to open table 'vpd'.\n"]) if (!$vpdtab); my $nodehmtab = xCAT::Table->new('nodehm'); - return( ["Failed to open table 'nodehm'.\n"]) if (! $nodehmtab); + return (["Failed to open table 'nodehm'.\n"]) if (!$nodehmtab); my @bpa_ctrled_nodes = (); my @no_type_nodes = (); - my @no_mgt_nodes = (); + my @no_mgt_nodes = (); my @frame_members = (); - my $nodetype_hash = xCAT::DBobjUtils->getnodetype($nodes, "ppc"); - for my $node ( @$nodes) + my $nodetype_hash = xCAT::DBobjUtils->getnodetype($nodes, "ppc"); + for my $node (@$nodes) { - my $nodehm = $nodehmtab->getNodeAttribs( $node, [qw(mgt)]); - if ( ! $nodehm) + my $nodehm = $nodehmtab->getNodeAttribs($node, [qw(mgt)]); + if (!$nodehm) { push @no_mgt_nodes, $node; next; } - - my $node_parent = undef; - my $nodetype = undef; - my $node_parent_hash = $ppctab->getNodeAttribs($node,[qw(parent)]); - $nodetype = $$nodetype_hash{$node}; + + my $node_parent = undef; + my $nodetype = undef; + my $node_parent_hash = $ppctab->getNodeAttribs($node, [qw(parent)]); + $nodetype = $$nodetype_hash{$node}; $node_parent = $node_parent_hash->{parent}; - if ( !$nodetype) + if (!$nodetype) { push @no_type_nodes, $node; next; } - if ( ($nodetype eq 'fsp' or $nodetype eq 'cec') and - $node_parent and - $node_parent ne $node) + if (($nodetype eq 'fsp' or $nodetype eq 'cec') and + $node_parent and + $node_parent ne $node) { push @bpa_ctrled_nodes, $node; } - if ( $nodetype eq 'bpa') + if ($nodetype eq 'bpa') { - my $my_frame_bpa_cec = getFrameMembers( $node, $vpdtab, $ppctab); + my $my_frame_bpa_cec = getFrameMembers($node, $vpdtab, $ppctab); push @frame_members, @$my_frame_bpa_cec; } - if ( $nodetype eq 'frame') + if ($nodetype eq 'frame') { my $my_frame_bpa_cec = xCAT::DBobjUtils::getcecchildren($node); push @frame_members, @$my_frame_bpa_cec; @@ -531,13 +542,14 @@ sub rmhwconn_parse_args if (scalar(@no_type_nodes)) { my $tmp_nodelist = join ',', @no_type_nodes; - return ( usage("Attribute nodetype.nodetype cannot be found for node(s) $tmp_nodelist. Please define first and try again.\n")); + return (usage("Attribute nodetype.nodetype cannot be found for node(s) $tmp_nodelist. Please define first and try again.\n")); } if (scalar(@no_mgt_nodes)) { my $tmp_nodelist = join ',', @no_mgt_nodes; - return( ["Failed to get nodehm.mgt value for node(s) $tmp_nodelist. Please define first and try again.\n"]); + return (["Failed to get nodehm.mgt value for node(s) $tmp_nodelist. Please define first and try again.\n"]); } $ppctab->close(); + #$nodetypetab->close(); $vpdtab->close(); $nodehmtab->close(); @@ -547,14 +559,14 @@ sub rmhwconn_parse_args # my $tmp_nodelist = join ',', @bpa_ctrled_nodes; # return ( usage("Node(s) $tmp_nodelist is(are) controlled by BPA.")); #} - - if ( scalar( @frame_members)) + + if (scalar(@frame_members)) { - my @all_nodes = xCAT::Utils::get_unique_members( @$nodes, @frame_members); + my @all_nodes = xCAT::Utils::get_unique_members(@$nodes, @frame_members); $request->{node} = \@all_nodes; } $request->{method} = 'rmhwconn'; - return( \%opt); + return (\%opt); } @@ -565,18 +577,19 @@ sub mkhwconn { my $request = shift; my $hash = shift; + #my $exp = shift; #my $hwtype = @$exp[2]; - my $opt = $request->{opt}; - my @value = (); - my $Rc = undef; - my $tooltype= $opt->{T}; - - xCAT::MsgUtils->verbose_message($request, "mkhwconn START."); - for my $cec_bpa ( keys %$hash) + my $opt = $request->{opt}; + my @value = (); + my $Rc = undef; + my $tooltype = $opt->{T}; + + xCAT::MsgUtils->verbose_message($request, "mkhwconn START."); + for my $cec_bpa (keys %$hash) { my $node_hash = $hash->{$cec_bpa}; - for my $node_name ( keys %$node_hash) + for my $node_name (keys %$node_hash) { my $d = $node_hash->{$node_name}; @@ -597,79 +610,81 @@ sub mkhwconn #} - xCAT::MsgUtils->verbose_message($request, "mkhwconn :add_connection for node:$node_name."); - my $res = xCAT::FSPUtils::fsp_api_action($request, $node_name, $d, "add_connection", $tooltype, $opt->{port} ); + xCAT::MsgUtils->verbose_message($request, "mkhwconn :add_connection for node:$node_name."); + my $res = xCAT::FSPUtils::fsp_api_action($request, $node_name, $d, "add_connection", $tooltype, $opt->{port}); $Rc = @$res[2]; - if( @$res[1] ne "") { - push @value, [$node_name, @$res[1], $Rc]; + if (@$res[1] ne "") { + push @value, [ $node_name, @$res[1], $Rc ]; } } } - xCAT::MsgUtils->verbose_message($request, "mkhwconn END."); + xCAT::MsgUtils->verbose_message($request, "mkhwconn END."); return \@value; } ########################################################################## -# List connection status for CECs/BPAs through FSPAPI +# List connection status for CECs/BPAs through FSPAPI ########################################################################## sub lshwconn { - my $request = shift; - my $hash = shift; - my $exp = shift; - my $hwtype = @$exp[2]; - my $opt = $request->{opt}; - my @value = (); - my $Rc = undef; - my $res = undef; + my $request = shift; + my $hash = shift; + my $exp = shift; + my $hwtype = @$exp[2]; + my $opt = $request->{opt}; + my @value = (); + my $Rc = undef; + my $res = undef; my $tooltype = $opt->{T}; - for my $cec_bpa ( keys %$hash) + for my $cec_bpa (keys %$hash) { - my $node_hash = $hash->{$cec_bpa}; - for my $node_name (keys %$node_hash) - { - my $d = $node_hash->{$node_name}; - my $action = "query_connection"; - my $res = xCAT::FSPUtils::fsp_api_action ($request, $node_name, $d, $action, $tooltype); - #print "in lshwconn:\n"; - #print Dumper($res); - my $Rc = @$res[2]; - my $values = @$res[1]; - - ############################################ - # If lssysconn failed, put error into all - # nodes' return values - ############################################ - #if ( $Rc ) - # { - # push @value, [$node_name, $values, $Rc]; - # next; - # } - my %rec = (); - my @data_a = split("\n", $values); - foreach my $data(@data_a) { - if( $data =~ /state/) { - $data =~ /state=([\w\s\,]+), type=([\w-]+), MTMS=([\w-\*\#]+), ([\w=]+), slot=([\w]+), ipadd=([\w.]+), alt_ipadd=([\w.]+)/ ; - #$data =~ /state=([\w\s]+),\(type=([\w-]+)\),\(serial-number=([\w]+)\),\(machinetype-model=([\w-]+)\),sp=([\w]+),\(ip-address=([\w.]+),([\w.]+)\)/ ; - print "parsing: $1,$2,$3,$4,$5,$6,$7\n"; - my $state = $1; - my $type = $2; - my $mtms = $3; - my $sp = $4; - my $slot = $5; - my $ipadd = $6; - my $alt_ipaddr = $7; - if (exists($rec{$slot})) { - next; - } - $rec{$slot} = 1; - $data = "$sp,ipadd=$ipadd,alt_ipadd=$alt_ipaddr,state=$state"; + my $node_hash = $hash->{$cec_bpa}; + for my $node_name (keys %$node_hash) + { + my $d = $node_hash->{$node_name}; + my $action = "query_connection"; + my $res = xCAT::FSPUtils::fsp_api_action($request, $node_name, $d, $action, $tooltype); + + #print "in lshwconn:\n"; + #print Dumper($res); + my $Rc = @$res[2]; + my $values = @$res[1]; + + ############################################ + # If lssysconn failed, put error into all + # nodes' return values + ############################################ + #if ( $Rc ) + # { + # push @value, [$node_name, $values, $Rc]; + # next; + # } + my %rec = (); + my @data_a = split("\n", $values); + foreach my $data (@data_a) { + if ($data =~ /state/) { + $data =~ /state=([\w\s\,]+), type=([\w-]+), MTMS=([\w-\*\#]+), ([\w=]+), slot=([\w]+), ipadd=([\w.]+), alt_ipadd=([\w.]+)/; + + #$data =~ /state=([\w\s]+),\(type=([\w-]+)\),\(serial-number=([\w]+)\),\(machinetype-model=([\w-]+)\),sp=([\w]+),\(ip-address=([\w.]+),([\w.]+)\)/ ; + print "parsing: $1,$2,$3,$4,$5,$6,$7\n"; + my $state = $1; + my $type = $2; + my $mtms = $3; + my $sp = $4; + my $slot = $5; + my $ipadd = $6; + my $alt_ipaddr = $7; + if (exists($rec{$slot})) { + next; + } + $rec{$slot} = 1; + $data = "$sp,ipadd=$ipadd,alt_ipadd=$alt_ipaddr,state=$state"; } - push @value, [$node_name, $data, $Rc]; - } - } - } + push @value, [ $node_name, $data, $Rc ]; + } + } + } return \@value; @@ -684,28 +699,29 @@ sub rmhwconn { my $request = shift; my $hash = shift; + #my $exp = shift; #my $hwtype = @$exp[2]; - my $opt = $request->{opt}; - my @value = (); - my $Rc = undef; + my $opt = $request->{opt}; + my @value = (); + my $Rc = undef; my $tooltype = $opt->{T}; - for my $cec_bpa ( keys %$hash) + for my $cec_bpa (keys %$hash) { my $node_hash = $hash->{$cec_bpa}; for my $node_name (keys %$node_hash) { my $d = $node_hash->{$node_name}; - my ( undef,undef,undef,undef,$type) = @$d; + my (undef, undef, undef, undef, $type) = @$d; - my $res = xCAT::FSPUtils::fsp_api_action($request, $node_name, $d, "rm_connection", $tooltype ); + my $res = xCAT::FSPUtils::fsp_api_action($request, $node_name, $d, "rm_connection", $tooltype); $Rc = @$res[2]; - if( @$res[1] ne "") { - push @value, [$node_name, @$res[1], $Rc]; + if (@$res[1] ne "") { + push @value, [ $node_name, @$res[1], $Rc ]; } - + } } return \@value; diff --git a/perl-xCAT/xCAT/FSPflash.pm b/perl-xCAT/xCAT/FSPflash.pm index 44c4b7ec0..aeea4d9d9 100644 --- a/perl-xCAT/xCAT/FSPflash.pm +++ b/perl-xCAT/xCAT/FSPflash.pm @@ -12,12 +12,13 @@ use xCAT::Table; use Getopt::Long; use File::Spec; use xCAT::PPCrflash; + #use Data::Dumper; use xCAT::FSPUtils; -my $packages_dir= (); -my $activate = (); -my $verbose = 0; +my $packages_dir = (); +my $activate = (); +my $verbose = 0; my $release_level; my $active_level; my @dirlist; @@ -32,19 +33,19 @@ my $housekeeping = undef; #For -V|--verbose,put the $msg into @value ################################### sub dpush { - my $value = shift; - my $msg = shift; + my $value = shift; + my $msg = shift; - if($verbose == 1) { - push(@$value,$msg); - } + if ($verbose == 1) { + push(@$value, $msg); + } } ########################################################################## -# Parse the command line for options and operands +# Parse the command line for options and operands ########################################################################## sub parse_args { - my $req = shift; + my $req = shift; $req->{mgt} = __PACKAGE__; my $opt = xCAT::PPCrflash::parse_args($req); delete($req->{mgt}); @@ -52,7 +53,7 @@ sub parse_args { } ########################################################################## -# Invokes the callback with the specified message +# Invokes the callback with the specified message ########################################################################## sub send_msg { @@ -63,23 +64,23 @@ sub send_msg { ################################################# # Called from child process - send to parent ################################################# - if ( exists( $request->{pipe} )) { + if (exists($request->{pipe})) { my $out = $request->{pipe}; $output{errorcode} = $ecode; - $output{data} = \@_; - print $out freeze( [\%output] ); + $output{data} = \@_; + print $out freeze([ \%output ]); print $out "\nENDOFFREEZE6sK4ci\n"; } ################################################# # Called from parent - invoke callback directly ################################################# - elsif ( exists( $request->{callback} )) { + elsif (exists($request->{callback})) { my $callback = $request->{callback}; $output{errorcode} = $ecode; - $output{data} = \@_; - $callback->( \%output ); + $output{data} = \@_; + $callback->(\%output); } } @@ -90,84 +91,88 @@ sub send_msg { #-------------------------------------------------------------------------# # sub get_lic_filenames { - my $mtms = shift; - my $upgrade_required = 0; - my $msg = undef; - my $filename; + my $mtms = shift; + my $upgrade_required = 0; + my $msg = undef; + my $filename; - if(! -d $packages_dir) { - $msg = "The directory $packages_dir doesn't exist!"; - return ("","","", $msg, -1); + if (!-d $packages_dir) { + $msg = "The directory $packages_dir doesn't exist!"; + return ("", "", "", $msg, -1); + } + + #print "opening directory and reading names\n"; + opendir DIRHANDLE, $packages_dir; + @dirlist = readdir DIRHANDLE; + closedir DIRHANDLE; + + @dirlist = File::Spec->no_upwards(@dirlist); + + # Make sure we have some files to process + # + if (!scalar(@dirlist)) { + $msg = "directory $packages_dir is empty"; + return ("", "", "", $msg, -1); + } + + $release_level =~ /(\w{4})(\d{3})/; + my $pns = $1; + my $fff = $2; + + #Find the latest version lic file + @dirlist = grep /\.rpm$/, @dirlist; + @dirlist = grep /$1/, @dirlist; + if (!scalar(@dirlist)) { + $msg = "There isn't a package suitable for $mtms"; + return ("", "", "", $msg, -1); + } + if (scalar(@dirlist) > 1) { + + # Need to find the latest version package. + @dirlist = reverse sort(@dirlist); + my $t = "\n"; + foreach $t (@dirlist) { + $msg = $msg . "$t\t"; } - - #print "opening directory and reading names\n"; - opendir DIRHANDLE, $packages_dir; - @dirlist= readdir DIRHANDLE; - closedir DIRHANDLE; + } - @dirlist = File::Spec->no_upwards( @dirlist ); + $filename = File::Spec->catfile($packages_dir, $dirlist[0]); + $dirlist[0] =~ /(\w{4})(\d{3})_(\w{3})_(\d{3}).rpm$/; + ############## + #If the release levels are different, it will be upgrade_required. + ############# + if ($fff ne $2) { + $upgrade_required = 1; + } else { - # Make sure we have some files to process - # - if( !scalar( @dirlist ) ) { - $msg = "directory $packages_dir is empty"; - return ("","","",$msg, -1); + if (($pns eq $1) && ($4 <= $active_level)) { + $msg = $msg . "Upgrade $mtms $activate!"; + + # if($activate ne "concurrent") { + # $msg = "Option --actviate's value should be disruptive"; + # return ("", "","", $msg, -1); + # } + } else { + $msg = $msg . "Upgrade $mtms!"; + if ($activate !~ /^(disruptive|deferred)$/) { + $msg = "Option --activate's value shouldn't be $activate, and it must be disruptive or deferred"; + return ("", "", "", $msg, -1); + } } + } - $release_level =~/(\w{4})(\d{3})/; - my $pns = $1; - my $fff = $2; - - #Find the latest version lic file - @dirlist = grep /\.rpm$/, @dirlist; - @dirlist = grep /$1/, @dirlist; - if( !scalar( @dirlist ) ) { - $msg = "There isn't a package suitable for $mtms"; - return ("","","",$msg, -1); - } - if( scalar(@dirlist) > 1) { - # Need to find the latest version package. - @dirlist =reverse sort(@dirlist); - my $t = "\n"; - foreach $t(@dirlist) { - $msg =$msg."$t\t"; - } - } + #print "filename is $filename\n"; + my $xml_file_name = $filename; + $xml_file_name =~ s/(.+\.)rpm/\1xml/; - $filename = File::Spec->catfile( $packages_dir, $dirlist[0] ); - $dirlist[0] =~ /(\w{4})(\d{3})_(\w{3})_(\d{3}).rpm$/; - ############## - #If the release levels are different, it will be upgrade_required. - ############# - if($fff ne $2) { - $upgrade_required = 1; - } else { + #print "check_licdd_update: source xml file is $xml_file_name\n"; - if(($pns eq $1) && ($4 <= $active_level)) { - $msg = $msg. "Upgrade $mtms $activate!"; - # if($activate ne "concurrent") { - # $msg = "Option --actviate's value should be disruptive"; - # return ("", "","", $msg, -1); - # } - } else { - $msg = $msg . "Upgrade $mtms!"; - if($activate !~ /^(disruptive|deferred)$/) { - $msg = "Option --activate's value shouldn't be $activate, and it must be disruptive or deferred"; - return ("", "","", $msg, -1); - } - } - } - #print "filename is $filename\n"; - my $xml_file_name = $filename; - $xml_file_name =~ s/(.+\.)rpm/\1xml/; - #print "check_licdd_update: source xml file is $xml_file_name\n"; + if ((-z $filename) || (-z $xml_file_name)) { + $msg = "The package $filename or xml $xml_file_name is empty"; + return ("", "", "", $msg, -1); + } - if( ( -z $filename)|| ( -z $xml_file_name) ) { - $msg = "The package $filename or xml $xml_file_name is empty" ; - return ("", "", "", $msg, -1); - } - - return ($filename, $xml_file_name ,$upgrade_required, $msg, 0); + return ($filename, $xml_file_name, $upgrade_required, $msg, 0); } @@ -184,38 +189,38 @@ sub rflash { my $subreq = $request->{subreq}; my $hwtype = @$exp[2]; my @result; - my $timeout = $request->{ppctimeout}; + my $timeout = $request->{ppctimeout}; my $housekeeping = $request->{housekeeping}; $packages_dir = $request->{opt}->{p}; - $activate = $request->{opt}->{activate}; + $activate = $request->{opt}->{activate}; print "housekeeping:$housekeeping\n"; my $mtms; my $h; my $user; my $action; - my $tmp_file; #the file handle of the stanza + my $tmp_file; #the file handle of the stanza my $rpm_file; my $xml_file; my @rpm_files; my @xml_files; my $upgrade_required; my $stanza = undef; - my $mtms_t; + my $mtms_t; my @value; my %infor; - my $role ; #0x01: BPC A, BPC B; 0x01: Primary or only FSP, 0x02: Backup FSP - + my $role; #0x01: BPC A, BPC B; 0x01: Primary or only FSP, 0x02: Backup FSP + #print "in Directflash \n"; #print Dumper($request); #print Dumper($hash); #################################### # Power commands are grouped by hardware control point - # In Direct attach support, the hcp is the related fsp. + # In Direct attach support, the hcp is the related fsp. #################################### - - # Example of $hash. + + # Example of $hash. #VAR1 = { # '9110-51A*1075ECF' => { # 'Server-9110-51A-SN1075ECF' => [ @@ -228,145 +233,148 @@ sub rflash { # ] # } # }; - my $flag = 0; + my $flag = 0; my $flag2 = 0; - while (my ($mtms,$h) = each(%$hash) ) { - # - #For one mtms, it just needs to do the operation one time. - # + while (my ($mtms, $h) = each(%$hash)) { + # + #For one mtms, it just needs to do the operation one time. + # $flag += 1; - if($flag > 1) { - last; - } - - $mtms =~ /(\w+)-(\w+)\*(\w+)/; - my $mtm = "$1-$2"; - my $serial = $3; - - - while (my ($name,$d) = each(%$h) ) { - $flag2 += 1; - if($flag2 > 1) { - last; - } + if ($flag > 1) { + last; + } - if( !defined($housekeeping) && ($$d[4] =~ /^fsp$/ || $$d[4] =~ /^lpar$/ || $$d[4] =~ /^cec$/)) { - $action = "get_compatible_version_from_rpm"; - my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, $action, 0, $request->{opt}->{d} ); - my $Rc = @$values[2]; - my $v = @$values[1]; - if ($Rc != 0) { - push @value, [$name, $v, -1]; - return (\@value); - } - - #if( $v !~ "nocheckversion") { - my @levels = split(/,/, $v); - - my $frame = $$d[5]; - my $type = xCAT::DBobjUtils->getnodetype($frame); - if ( ( $frame ne $name ) && ( $type eq "frame" ) && $activate !~ /^deferred$/){ - - my @frame_d = (0, 0, 0, $frame, "frame", 0); - $action = "list_firmware_level"; - $values = xCAT::FSPUtils::fsp_api_action($request, $frame, \@frame_d, $action ); - $Rc = @$values[2]; - my $frame_firmware_level = @$values[1]; - if ($Rc != 0) { - push @value, [$frame, $frame_firmware_level, -1]; - return (\@value); - } - - my $level_a; - my $level_b; - if( $frame_firmware_level =~ /curr_level_a=(\d{3}),curr_ecnumber_a=02(\w{5})/) { - $level_a = "$2_$1"; - } - - if( $frame_firmware_level =~ /curr_level_b=(\d{3}),curr_ecnumber_b=02(\w{5})/) { - $level_b = "$2_$1"; - } - - #print "frame_firmware_level=$frame_firmware_level,level_a=$level_a,level_b=$level_b\n"; - foreach my $l (@levels) { - #print "rpm requires: $l\n" ; - if( (defined($level_a) && ( $l gt $level_a )) || (defined($level_b) && ( $l gt $level_b )) ) { - my $res = "New Managed System level for $name is not compatible with current Power Subsystem level 02$level_a on $frame.\nPower Subsystem level 02$l or later is required."; - - push @value, [$name, $res, -1]; - return (\@value); - } - - } - } - #} - + $mtms =~ /(\w+)-(\w+)\*(\w+)/; + my $mtm = "$1-$2"; + my $serial = $3; + + + while (my ($name, $d) = each(%$h)) { + $flag2 += 1; + if ($flag2 > 1) { + last; } - if(!defined($housekeeping)) { - my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "list_firmware_level"); - my $Rc = @$values[2]; - my $level = @$values[1]; - ##################################### - # Return error - ##################################### - if ( $Rc != SUCCESS ) { - push @value, [$name,$level,$Rc]; - next; - } - - if ( $level =~ /ecnumber=(\w+)/ ) { - $release_level = $1; - &dpush( \@value, [$name,"$mtms :release level:$1"]); - } - - if ( $level =~ /activated_level=(\w+)/ ) { - $active_level = $1; - &dpush( \@value, [$name,"$mtms :activated level:$1"]); - } + if (!defined($housekeeping) && ($$d[4] =~ /^fsp$/ || $$d[4] =~ /^lpar$/ || $$d[4] =~ /^cec$/)) { + $action = "get_compatible_version_from_rpm"; + my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, $action, 0, $request->{opt}->{d}); + my $Rc = @$values[2]; + my $v = @$values[1]; + if ($Rc != 0) { + push @value, [ $name, $v, -1 ]; + return (\@value); + } - } - - - - if($housekeeping =~ /^commit$/) { $action = "code_commit"} - if($housekeeping =~ /^recover$/) { $action = "code_reject"} - if($housekeeping =~ /^bpa_acdl$/) { $action = "acdl"} - if($activate eq "disruptive") { - $action = "code_update"; - } elsif ($activate eq "deferred") { - $action = "code_updateD"; - } elsif (defined($activate)){ - #if($activate =~ /^concurrent$/) { - my $res = "\'$activate\' option not supported in FSPflash. Please use disruptive or deferred mode"; - push @value, [$name, $res, -1]; - next; - } - - my $msg; - if(!defined($housekeeping)) { - my $flag = 0; - ($rpm_file, $xml_file, $upgrade_required,$msg, $flag) = &get_lic_filenames($mtms); - if( $flag == -1) { - push (@value, [$name,"$mtms: $msg"]); - push (@value, [$name,"Failed to upgrade the firmware of $name"]); - return (\@value); - } - dpush ( \@value, [$name, $msg]); - } + #if( $v !~ "nocheckversion") { + my @levels = split(/,/, $v); + + my $frame = $$d[5]; + my $type = xCAT::DBobjUtils->getnodetype($frame); + if (($frame ne $name) && ($type eq "frame") && $activate !~ /^deferred$/) { + + my @frame_d = (0, 0, 0, $frame, "frame", 0); + $action = "list_firmware_level"; + $values = xCAT::FSPUtils::fsp_api_action($request, $frame, \@frame_d, $action); + $Rc = @$values[2]; + my $frame_firmware_level = @$values[1]; + if ($Rc != 0) { + push @value, [ $frame, $frame_firmware_level, -1 ]; + return (\@value); + } + + my $level_a; + my $level_b; + if ($frame_firmware_level =~ /curr_level_a=(\d{3}),curr_ecnumber_a=02(\w{5})/) { + $level_a = "$2_$1"; + } + + if ($frame_firmware_level =~ /curr_level_b=(\d{3}),curr_ecnumber_b=02(\w{5})/) { + $level_b = "$2_$1"; + } + + #print "frame_firmware_level=$frame_firmware_level,level_a=$level_a,level_b=$level_b\n"; + foreach my $l (@levels) { + + #print "rpm requires: $l\n" ; + if ((defined($level_a) && ($l gt $level_a)) || (defined($level_b) && ($l gt $level_b))) { + my $res = "New Managed System level for $name is not compatible with current Power Subsystem level 02$level_a on $frame.\nPower Subsystem level 02$l or later is required."; + + push @value, [ $name, $res, -1 ]; + return (\@value); + } + + } + } + + #} + + } + + if (!defined($housekeeping)) { + my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "list_firmware_level"); + my $Rc = @$values[2]; + my $level = @$values[1]; + ##################################### + # Return error + ##################################### + if ($Rc != SUCCESS) { + push @value, [ $name, $level, $Rc ]; + next; + } + + if ($level =~ /ecnumber=(\w+)/) { + $release_level = $1; + &dpush(\@value, [ $name, "$mtms :release level:$1" ]); + } + + if ($level =~ /activated_level=(\w+)/) { + $active_level = $1; + &dpush(\@value, [ $name, "$mtms :activated level:$1" ]); + } + + } + + + + if ($housekeeping =~ /^commit$/) { $action = "code_commit" } + if ($housekeeping =~ /^recover$/) { $action = "code_reject" } + if ($housekeeping =~ /^bpa_acdl$/) { $action = "acdl" } + if ($activate eq "disruptive") { + $action = "code_update"; + } elsif ($activate eq "deferred") { + $action = "code_updateD"; + } elsif (defined($activate)) { + + #if($activate =~ /^concurrent$/) { + my $res = "\'$activate\' option not supported in FSPflash. Please use disruptive or deferred mode"; + push @value, [ $name, $res, -1 ]; + next; + } + + my $msg; + if (!defined($housekeeping)) { + my $flag = 0; + ($rpm_file, $xml_file, $upgrade_required, $msg, $flag) = &get_lic_filenames($mtms); + if ($flag == -1) { + push(@value, [ $name, "$mtms: $msg" ]); + push(@value, [ $name, "Failed to upgrade the firmware of $name" ]); + return (\@value); + } + dpush(\@value, [ $name, $msg ]); + } + + my $res = xCAT::FSPUtils::fsp_api_action($request, $name, $d, $action, 0, $request->{opt}->{d}); + if ($action eq "acdl" && @$res[2] eq '0') { + push(@value, [ $name, "Success", '0' ]); + } else { + push(@value, [ $name, @$res[1], @$res[2] ]); + } + return (\@value); - my $res = xCAT::FSPUtils::fsp_api_action($request, $name, $d, $action, 0, $request->{opt}->{d} ); - if ($action eq "acdl" && @$res[2] eq '0') { - push(@value, [$name, "Success", '0']); - } else { - push(@value,[$name, @$res[1], @$res[2]]); - } - return (\@value); - } } push(@value, @result); - return (\@value); + return (\@value); } diff --git a/perl-xCAT/xCAT/FSPinv.pm b/perl-xCAT/xCAT/FSPinv.pm index 2825c19a1..6ab7dbd38 100644 --- a/perl-xCAT/xCAT/FSPinv.pm +++ b/perl-xCAT/xCAT/FSPinv.pm @@ -8,95 +8,98 @@ require xCAT::Usage; require xCAT::PPCinv; require xCAT::FSPUtils; use XML::Simple; + #use Data::Dumper; ########################################## # Maps fsp-api attributes to text ########################################## my @licmap = ( - ["ecnumber", "Release Level "], - ["activated_level", "Active Level "], - ["installed_level", "Installed Level"], - ["accepted_level", "Accepted Level "], - ["curr_ecnumber_a", "Release Level A"], - ["curr_level_a", "Level A "], - ["curr_power_on_side_a", "Current Power on side A"], - ["curr_ecnumber_b", "Release Level B"], - ["curr_level_b", "Level B "], - ["curr_power_on_side_b", "Current Power on side B"], - ["curr_ecnumber_primary", "Release Level Primary"], - ["curr_level_primary", "Level Primary "], - ["curr_power_on_side_primary", "Current Power on side Primary"], - ["curr_ecnumber_secondary","Release Level Secondary"], - ["curr_level_secondary", "Level Secondary"], - ["curr_power_on_side_secondary","Current Power on side Secondary"] + [ "ecnumber", "Release Level " ], + [ "activated_level", "Active Level " ], + [ "installed_level", "Installed Level" ], + [ "accepted_level", "Accepted Level " ], + [ "curr_ecnumber_a", "Release Level A" ], + [ "curr_level_a", "Level A " ], + [ "curr_power_on_side_a", "Current Power on side A" ], + [ "curr_ecnumber_b", "Release Level B" ], + [ "curr_level_b", "Level B " ], + [ "curr_power_on_side_b", "Current Power on side B" ], + [ "curr_ecnumber_primary", "Release Level Primary" ], + [ "curr_level_primary", "Level Primary " ], + [ "curr_power_on_side_primary", "Current Power on side Primary" ], + [ "curr_ecnumber_secondary", "Release Level Secondary" ], + [ "curr_level_secondary", "Level Secondary" ], + [ "curr_power_on_side_secondary", "Current Power on side Secondary" ] ); ########################################################################## -# Parse the command line for options and operands +# Parse the command line for options and operands ########################################################################## sub parse_args { -# xCAT::PPCinv::parse_args(@_); + + # xCAT::PPCinv::parse_args(@_); my $request = shift; my $command = $request->{command}; my $args = $request->{arg}; my %opt = (); -# my @rinv = qw(bus config model serial firm all); - my @rinv = qw( deconfig firm ); + + # my @rinv = qw(bus config model serial firm all); + my @rinv = qw( deconfig firm ); ############################################# # Responds with usage statement ############################################# local *usage = sub { my $usage_string = xCAT::Usage->getUsage($command); - return( [ $_[0], $usage_string] ); + return ([ $_[0], $usage_string ]); }; ############################################# # Process command-line arguments ############################################# - if ( !defined( $args )) { - return(usage( "No command specified" )); + if (!defined($args)) { + return (usage("No command specified")); } ############################################# # Checks case in GetOptions, allows opts # to be grouped (e.g. -vx), and terminates # at the first unrecognized option. ############################################# - @ARGV = @$args; + @ARGV = @$args; $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); + Getopt::Long::Configure("bundling"); - if ( !GetOptions( \%opt, qw(V|verbose x) )) { - return( usage() ); + if (!GetOptions(\%opt, qw(V|verbose x))) { + return (usage()); } #################################### # Check for "-" with no option #################################### - if ( grep(/^-$/, @ARGV )) { - return(usage( "Missing option: -" )); + if (grep(/^-$/, @ARGV)) { + return (usage("Missing option: -")); } #################################### # Unsupported command #################################### - my ($cmd) = grep(/^$ARGV[0]$/, @rinv ); - if ( !defined( $cmd )) { - return(usage( "Invalid command: $ARGV[0]" )); + my ($cmd) = grep(/^$ARGV[0]$/, @rinv); + if (!defined($cmd)) { + return (usage("Invalid command: $ARGV[0]")); } #################################### # Check for an extra argument #################################### shift @ARGV; - if ( defined( $ARGV[0] )) { - return(usage( "Invalid Argument: $ARGV[0]" )); + if (defined($ARGV[0])) { + return (usage("Invalid Argument: $ARGV[0]")); } if (exists($opt{x}) and $cmd !~ /^deconfig$/) { return (usage("Option '-x' can't work with '$cmd'")); } #################################### - # Set method to invoke + # Set method to invoke #################################### - $request->{method} = $cmd; - return( \%opt ); + $request->{method} = $cmd; + return (\%opt); } @@ -112,17 +115,17 @@ sub firmware { my $request = shift; my $hash = shift; my @result; - + # print "in FSPinv \n"; #print Dumper($request); #print Dumper($hash); #################################### # FSPinv with firm command is grouped by hardware control point - # In FSPinv, the hcp is the related fsp. + # In FSPinv, the hcp is the related fsp. #################################### - - # Example of $hash. + + # Example of $hash. #VAR1 = { # '9110-51A*1075ECF' => { # 'Server-9110-51A-SN1075ECF' => [ @@ -136,57 +139,58 @@ sub firmware { # } # }; - while (my ($mtms,$h) = each(%$hash) ) { - while (my ($name,$d) = each(%$h) ) { + while (my ($mtms, $h) = each(%$hash)) { + while (my ($name, $d) = each(%$h)) { ##################################### - # Command only supported on FSP/BPA/LPARs + # Command only supported on FSP/BPA/LPARs ##################################### - if ( @$d[4] !~ /^(cec|frame|fsp|bpa|lpar|blade)$/ ) { - push @result, - [$name,"Information only available for CEC/FSP/Frame/BPA/LPAR",RC_ERROR]; - next; + if (@$d[4] !~ /^(cec|frame|fsp|bpa|lpar|blade)$/) { + push @result, + [ $name, "Information only available for CEC/FSP/Frame/BPA/LPAR", RC_ERROR ]; + next; } - ################# - #For support on Lpars, the flag need to be changed. - ########## - if(@$d[4] eq "lpar") { - @$d[4] = "fsp"; - @$d[0] = 0; - } - my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "list_firmware_level"); - my $Rc = @$values[2]; - my $data = @$values[1]; - #print "values"; - #print Dumper($values); - ##################################### - # Return error - ##################################### - if ( $Rc != SUCCESS ) { - push @result, [$name,$data,$Rc]; - next; + ################# + #For support on Lpars, the flag need to be changed. + ########## + if (@$d[4] eq "lpar") { + @$d[4] = "fsp"; + @$d[0] = 0; } - - ##################################### + my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "list_firmware_level"); + my $Rc = @$values[2]; + my $data = @$values[1]; + + #print "values"; + #print Dumper($values); + ##################################### + # Return error + ##################################### + if ($Rc != SUCCESS) { + push @result, [ $name, $data, $Rc ]; + next; + } + + ##################################### # Format fsp-api results ##################################### my $val; - foreach $val ( @licmap ) { - if ( $data =~ /@$val[0]=(\w+)/ ) { - push @result, [$name,"@$val[1]: $1",$Rc]; + foreach $val (@licmap) { + if ($data =~ /@$val[0]=(\w+)/) { + push @result, [ $name, "@$val[1]: $1", $Rc ]; } } } } - return( \@result ); + return (\@result); } ########################################################################## -# Returns firmware version +# Returns firmware version ########################################################################## sub firm { - return( firmware(@_) ); + return (firmware(@_)); } ########################################################################## @@ -206,17 +210,17 @@ sub deconfig { my $request = shift; my $hash = shift; my @result; - + # print "in FSPinv \n"; #print Dumper($request); #print Dumper($hash); #################################### # FSPinv with deconfig command is grouped by hardware control point - # In FSPinv, the hcp is the related fsp. + # In FSPinv, the hcp is the related fsp. #################################### - - # Example of $hash. + + # Example of $hash. #VAR1 = { # '9110-51A*1075ECF' => { # 'Server-9110-51A-SN1075ECF' => [ @@ -230,114 +234,116 @@ sub deconfig { # } # }; - while (my ($mtms,$h) = each(%$hash) ) { - while (my ($name,$d) = each(%$h) ) { + while (my ($mtms, $h) = each(%$hash)) { + while (my ($name, $d) = each(%$h)) { ##################################### - # Command only supported on FSP/BPA/LPARs + # Command only supported on FSP/BPA/LPARs ##################################### - if ( @$d[4] !~ /^(cec|fsp)$/ ) { - push @result, - [$name,"Deconfigured resource information only available for CEC/FSP",RC_ERROR]; - next; + if (@$d[4] !~ /^(cec|fsp)$/) { + push @result, + [ $name, "Deconfigured resource information only available for CEC/FSP", RC_ERROR ]; + next; } - ################# - #For support on Lpars, the flag need to be changed. - ########## - #if(@$d[4] eq "lpar") { - # @$d[4] = "fsp"; - # @$d[0] = 0; - #} - my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "get_cec_deconfigured"); - my $Rc = @$values[2]; - my $data = @$values[1]; - #print "values"; - #print Dumper($values); + ################# + #For support on Lpars, the flag need to be changed. + ########## + #if(@$d[4] eq "lpar") { + # @$d[4] = "fsp"; + # @$d[0] = 0; + #} + my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "get_cec_deconfigured"); + my $Rc = @$values[2]; + my $data = @$values[1]; + + #print "values"; + #print Dumper($values); ##################################### # Return error ##################################### - if ( $Rc != SUCCESS ) { - push @result, [$name,$data,$Rc]; - next; - } - - - ##################################### - # Format fsp-api results - ##################################### - #my $decfg = XMLin($data); - my $decfg; - eval { - $decfg = XMLin($data); - }; - if( $@ ) { - push @result,[$name, "Error: there are some unreadable XML data from the firmware. It can't be parsed by 'xcatd'.", -1]; - return (\@result); - } - if( exists($request->{opt}->{x})) { - push @result, [$name, "\n".$data, -1]; - next; - } - #print "decfg"; - #print Dumper($decfg); - my $node = $decfg->{NODE}; - if( defined($node) && exists($node->{Location_code}) ) { - my $Call_Out_Hardware_State ; - my $Call_Out_Method; - my $Location_code; - my $RID; - my $TYPE; - my $dres; - if (ref($node->{GARDRECORD}) eq "ARRAY") { - $dres = $node->{GARDRECORD}; - } elsif (ref($node->{GARDRECORD}) eq "HASH") { - push @$dres, $node->{GARDRECORD}; - } else { - push @result,[$name,"NO Deconfigured resources", 0]; - return( \@result ); - } - push @result,[$name,"Deconfigured resources", 0]; - push @result,[$name,"Location_code RID Call_Out_Method Call_Out_Hardware_State TYPE", 0]; - push @result,[$name,"$node->{Location_code} $node->{RID}", 0]; - - #foreach my $unit(@{$node->{GARDRECORD}}) { - foreach my $unit(@$dres) { - while (my ($key, $unit3) = each(%$unit) ) { - - if($key eq "GARDUNIT") { - if (ref($unit3) eq "HASH") { - $Call_Out_Hardware_State = $unit3->{Call_Out_Hardware_State}; - $Call_Out_Method = $unit3->{Call_Out_Method}; - $Location_code = $unit3->{Location_code}; - $RID = $unit3->{RID}; - $TYPE = $unit3->{TYPE}; - - push @result,[$name,"$Location_code $RID $Call_Out_Method $Call_Out_Hardware_State $TYPE",0]; - } elsif(ref($unit3) eq "ARRAY") { - - foreach my $unit4(@$unit3) { - $Call_Out_Hardware_State = $unit4->{Call_Out_Hardware_State}; - $Call_Out_Method = $unit4->{Call_Out_Method}; - $Location_code = $unit4->{Location_code}; - $RID = $unit4->{RID}; - $TYPE = $unit4->{TYPE}; - push @result,[$name,"$Location_code $RID $Call_Out_Method $Call_Out_Hardware_State $TYPE",0]; - } - } - } - } + if ($Rc != SUCCESS) { + push @result, [ $name, $data, $Rc ]; + next; + } - } + ##################################### + # Format fsp-api results + ##################################### + #my $decfg = XMLin($data); + my $decfg; + eval { + $decfg = XMLin($data); + }; + if ($@) { + push @result, [ $name, "Error: there are some unreadable XML data from the firmware. It can't be parsed by 'xcatd'.", -1 ]; + return (\@result); + } + if (exists($request->{opt}->{x})) { + push @result, [ $name, "\n" . $data, -1 ]; + next; + } + + #print "decfg"; + #print Dumper($decfg); + my $node = $decfg->{NODE}; + if (defined($node) && exists($node->{Location_code})) { + my $Call_Out_Hardware_State; + my $Call_Out_Method; + my $Location_code; + my $RID; + my $TYPE; + my $dres; + if (ref($node->{GARDRECORD}) eq "ARRAY") { + $dres = $node->{GARDRECORD}; + } elsif (ref($node->{GARDRECORD}) eq "HASH") { + push @$dres, $node->{GARDRECORD}; + } else { + push @result, [ $name, "NO Deconfigured resources", 0 ]; + return (\@result); + } + push @result, [ $name, "Deconfigured resources", 0 ]; + push @result, [ $name, "Location_code RID Call_Out_Method Call_Out_Hardware_State TYPE", 0 ]; + push @result, [ $name, "$node->{Location_code} $node->{RID}", 0 ]; + + #foreach my $unit(@{$node->{GARDRECORD}}) { + foreach my $unit (@$dres) { + while (my ($key, $unit3) = each(%$unit)) { + + if ($key eq "GARDUNIT") { + if (ref($unit3) eq "HASH") { + $Call_Out_Hardware_State = $unit3->{Call_Out_Hardware_State}; + $Call_Out_Method = $unit3->{Call_Out_Method}; + $Location_code = $unit3->{Location_code}; + $RID = $unit3->{RID}; + $TYPE = $unit3->{TYPE}; + + push @result, [ $name, "$Location_code $RID $Call_Out_Method $Call_Out_Hardware_State $TYPE", 0 ]; + } elsif (ref($unit3) eq "ARRAY") { + + foreach my $unit4 (@$unit3) { + $Call_Out_Hardware_State = $unit4->{Call_Out_Hardware_State}; + $Call_Out_Method = $unit4->{Call_Out_Method}; + $Location_code = $unit4->{Location_code}; + $RID = $unit4->{RID}; + $TYPE = $unit4->{TYPE}; + push @result, [ $name, "$Location_code $RID $Call_Out_Method $Call_Out_Hardware_State $TYPE", 0 ]; + } + } + } + } + + + } + + } else { + push @result, [ $name, "NO Deconfigured resources", 0 ]; + } - } else { - push @result,[$name,"NO Deconfigured resources", 0]; - } - } } - return( \@result ); + return (\@result); } @@ -353,11 +359,11 @@ sub model { ########################################################################## sub all { - my @result = ( - @{deconfig(@_)}, - @{firmware(@_)} - ); - return( \@result ); + my @result = ( + @{ deconfig(@_) }, + @{ firmware(@_) } + ); + return (\@result); } diff --git a/perl-xCAT/xCAT/FSPmac.pm b/perl-xCAT/xCAT/FSPmac.pm index 9651363cb..b8d355203 100644 --- a/perl-xCAT/xCAT/FSPmac.pm +++ b/perl-xCAT/xCAT/FSPmac.pm @@ -9,7 +9,7 @@ use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR); use xCAT::MsgUtils qw(verbose_message); use xCAT::LparNetbootExp; ########################################################################## -# Parse the command line for options and operands +# Parse the command line for options and operands ########################################################################## sub parse_args { xCAT::PPCmac::parse_args(@_); @@ -21,21 +21,21 @@ sub parse_args { ########################################################################## sub do_getmacs { - my $request = shift; - my $d = shift; - my $exp = shift; - my $name = shift; - my $node = shift; - my $opt = $request->{opt}; - my $ssh = @$exp[0]; - my $userid = @$exp[4]; - my $pw = @$exp[5]; + my $request = shift; + my $d = shift; + my $exp = shift; + my $name = shift; + my $node = shift; + my $opt = $request->{opt}; + my $ssh = @$exp[0]; + my $userid = @$exp[4]; + my $pw = @$exp[5]; my %optarg; my $cmd; my $result; ####################################### - # Disconnect Expect session + # Disconnect Expect session ####################################### #xCAT::PPCcli::disconnect( $exp ); @@ -60,7 +60,7 @@ sub do_getmacs { # return( [RC_ERROR,"Command not installed: $cmd"] ); #} ####################################### - # Save user name and passwd of hcp to + # Save user name and passwd of hcp to # environment variables. # lpar_netboot.expect depends on this ####################################### @@ -68,17 +68,19 @@ sub do_getmacs { $ENV{HCP_PASSWD} = $pw; ####################################### - # Turn on verbose and debugging + # Turn on verbose and debugging ####################################### - if ( exists($request->{verbose}) ) { + if (exists($request->{verbose})) { + #$cmd.= " -v -x"; - $optarg{'v'} = 1; #for verbose - $optarg{'x'} = 1; #for debug + $optarg{'v'} = 1; #for verbose + $optarg{'x'} = 1; #for debug } ####################################### # Force LPAR shutdown ####################################### - if ( exists( $opt->{f} )) { + if (exists($opt->{f})) { + #$cmd.= " -i"; $optarg{'i'} = 1; } else { @@ -86,16 +88,17 @@ sub do_getmacs { # Force LPAR shutdown if LPAR is # running Linux ################################# - my $table = "nodetype"; - my $intable = 0; + my $table = "nodetype"; + my $intable = 0; my @TableRowArray = xCAT::DBobjUtils->getDBtable($table); - if ( @TableRowArray ) { - foreach ( @TableRowArray ) { + if (@TableRowArray) { + foreach (@TableRowArray) { my @nodelist = split(',', $_->{'node'}); - my @oslist = split(',', $_->{'os'}); - my $osname = "AIX"; - if ( grep(/^$node$/, @nodelist) ) { - if ( !grep(/^$osname$/, @oslist) ) { + my @oslist = split(',', $_->{'os'}); + my $osname = "AIX"; + if (grep(/^$node$/, @nodelist)) { + if (!grep(/^$osname$/, @oslist)) { + #$cmd.= " -i"; $optarg{'i'} = 1; } @@ -109,17 +112,20 @@ sub do_getmacs { # type is not assigned in table # but mnt node is running Linux ################################# - if ( xCAT::Utils->isLinux() && $intable == 0 ) { - #$cmd.= " -i"; - $optarg{'i'} = 1; + if (xCAT::Utils->isLinux() && $intable == 0) { + + #$cmd.= " -i"; + $optarg{'i'} = 1; } } - my %client_nethash = xCAT::DBobjUtils->getNetwkInfo( [$node] ); - if ( grep /hf/, $client_nethash{$node}{mgtifname} ) { + my %client_nethash = xCAT::DBobjUtils->getNetwkInfo([$node]); + if (grep /hf/, $client_nethash{$node}{mgtifname}) { + #$cmd.= " -t hfi-ent"; $optarg{'t'} = "hfi-ent"; } else { + #$cmd.= " -t ent"; $optarg{'t'} = "ent"; } @@ -127,17 +133,19 @@ sub do_getmacs { ####################################### # Network specified (-D ping test) ####################################### - if ( exists( $opt->{noping} )) { - $optarg{'D'} = 1; + if (exists($opt->{noping})) { + $optarg{'D'} = 1; $optarg{'noping'} = 1; $optarg{'pprofile'} = "not_use"; #lpar_netboot.expect need pprofile for p5 & p6, but for p7 ih, we don't use this attribute. } - if ( exists( $opt->{S} )) { - if ( exists( $opt->{o} )) { + if (exists($opt->{S})) { + if (exists($opt->{o})) { + #$cmd .=" -o"; - $optarg{'o'} = 1; + $optarg{'o'} = 1; } + #$cmd.= " -D -s auto -d auto -S $opt->{S} -G $opt->{G} -C $opt->{C}"; $optarg{'D'} = 1; $optarg{'s'} = 'auto'; @@ -146,19 +154,20 @@ sub do_getmacs { $optarg{'C'} = $opt->{C}; $optarg{'G'} = $opt->{G}; $optarg{'pprofile'} = "not_use"; #lpar_netboot.expect need pprofile for p5 & p6, but for p7 ih, we don't use this attribute. - } + } ####################################### - # Add command options + # Add command options ####################################### #$cmd.= " -f -M -A -n \"$name\" \"$pprofile\" \"$fsp\" $id $hcp \"$node\""; $optarg{'f'} = 1; $optarg{'M'} = 1; $optarg{'A'} = 1; $optarg{'n'} = $name; + #$optarg{'pprofile'} = $pprofile; - $optarg{'fsp'} = $fsp; - $optarg{'id'} = $id; - $optarg{'hcp'} = $hcp; + $optarg{'fsp'} = $fsp; + $optarg{'id'} = $id; + $optarg{'hcp'} = $hcp; $optarg{'node'} = $node; ######################################## @@ -213,238 +222,243 @@ sub getmacs { my $name; my @emptynode; my $res; - - if ( $par =~ /^HASH/ ) { - #my $t = $request->{node}; - #foreach my $n (@$t) { - # return( [[$n,"Please use -D -f options to getmacs through FSP directly",RC_ERROR]] ); - # } + + if ($par =~ /^HASH/) { + + #my $t = $request->{node}; + #foreach my $n (@$t) { + # return( [[$n,"Please use -D -f options to getmacs through FSP directly",RC_ERROR]] ); + # } ######################################### # Parse the filters specified by user ######################################### my $filter; - if ( $opt->{F} ) { - my @filters = split /,/,$opt->{F}; - foreach ( @filters ) { - my @value = split /=/,$_; - $filter->{@value[0]} = @value[1]; + if ($opt->{F}) { + my @filters = split /,/, $opt->{F}; + foreach (@filters) { + my @value = split /=/, $_; + $filter->{ @value[0] } = @value[1]; } } - ######################################### + ######################################### # A hash to save lpar attributes - ######################################### + ######################################### my %nodeatt = (); ######################################### # Cleanup old data ######################################### - my $result = (); + my $result = (); ######################################### # No ping test performed, call lshwres # to achieve the MAC address ######################################### - foreach my $hcp ( keys %$par ) { + foreach my $hcp (keys %$par) { my $hash = $par->{$hcp}; - my $cmd; + my $cmd; my @lpar_name = keys(%$hash); - $name = $lpar_name[0]; - my $d = $$hash{$name}; + $name = $lpar_name[0]; + my $d = $$hash{$name}; ######################################### # Achieve virtual ethernet MAC address ######################################### - #@$cmd[0] = ["lpar","virtualio","","eth"]; - #@$cmd[1] = ["port","hea","","logical"]; - #@$cmd[2] = ["port","hea","","phys"]; - my @cmd = ("lpar_veth_mac","lpar_lhea_mac","lpar_hfi_mac"); + #@$cmd[0] = ["lpar","virtualio","","eth"]; + #@$cmd[1] = ["port","hea","","logical"]; + #@$cmd[2] = ["port","hea","","phys"]; + my @cmd = ("lpar_veth_mac", "lpar_lhea_mac", "lpar_hfi_mac"); ######################################### # Parse the output of lshwres command ######################################### - for ( my $stat = 0; $stat < 3; $stat++ ) { - #my $output = xCAT::PPCcli::lshwres( $exp, @$cmd[$stat], $hcp); - my $output = xCAT::FSPUtils::fsp_api_action($request, $name, $d, $cmd[$stat]); - my $macs; + for (my $stat = 0 ; $stat < 3 ; $stat++) { + + #my $output = xCAT::PPCcli::lshwres( $exp, @$cmd[$stat], $hcp); + my $output = xCAT::FSPUtils::fsp_api_action($request, $name, $d, $cmd[$stat]); + my $macs; my $res = $$output[1]; - chomp($res); - my @op = split("\n", $res); - #print Dumper(\@op); - foreach my $line ( @op ) { - if ( $line =~ /^.*lpar\_id=(\d+),.*$/ ) { + chomp($res); + my @op = split("\n", $res); + + #print Dumper(\@op); + foreach my $line (@op) { + if ($line =~ /^.*lpar\_id=(\d+),.*$/) { ######################################### # For the first two commands ######################################### my $lparid = $1; $nodeatt{$hcp}{$lparid}{'num'}++; - $macs = $nodeatt{$hcp}{$lparid}{'num'}; - my @attrs = split /,/, $line; - foreach ( @attrs ) { + $macs = $nodeatt{$hcp}{$lparid}{'num'}; + my @attrs = split /,/, $line; + foreach (@attrs) { my @attr = split /=/, $_; - $nodeatt{$hcp}{$lparid}{$macs}{@attr[0]} = @attr[1]; + $nodeatt{$hcp}{$lparid}{$macs}{ @attr[0] } = @attr[1]; } - } elsif ( ($line =~ /^(.*)port\_group=(\d+),(.*),"log\_port\_ids=(.*)"/) || ($line =~ /^(.*)port\_group=(\d+),(.*),log\_port\_ids=(.*)/) ) { + } elsif (($line =~ /^(.*)port\_group=(\d+),(.*),"log\_port\_ids=(.*)"/) || ($line =~ /^(.*)port\_group=(\d+),(.*),log\_port\_ids=(.*)/)) { ######################################### # For the third command ######################################### my $port_group = $2; - if ( $4 !~ /^none$/ ) { - my @ids = split /,/, $4; - my @attrs = split /,/, $1; + if ($4 !~ /^none$/) { + my @ids = split /,/, $4; + my @attrs = split /,/, $1; foreach (@attrs) { - my @attr = split /=/,$_; + my @attr = split /=/, $_; foreach (@ids) { - $nodeatt{$hcp}{$port_group}{$_}{@attr[0]} = @attr[1]; - } - } - my @attrs = split /,/, $3; - foreach (@attrs) { - my @attr = split /=/,$_; - foreach (@ids) { - $nodeatt{$hcp}{$port_group}{$_}{@attr[0]} = @attr[1]; + $nodeatt{$hcp}{$port_group}{$_}{ @attr[0] } = @attr[1]; } } - } + my @attrs = split /,/, $3; + foreach (@attrs) { + my @attr = split /=/, $_; + foreach (@ids) { + $nodeatt{$hcp}{$port_group}{$_}{ @attr[0] } = @attr[1]; + } + } + } } } } - - foreach ( keys %$hash ) { - my $node = $_; - my $d = $hash->{$_}; - my $mtms = @$d[2]; - my $id = @$d[0]; - my $nodetype = @$d[4]; - my $mac_count = $nodeatt{$mtms}{$id}{'num'}; - my $value = (); - my $data = (); + foreach (keys %$hash) { + my $node = $_; + my $d = $hash->{$_}; + my $mtms = @$d[2]; + my $id = @$d[0]; + my $nodetype = @$d[4]; + + my $mac_count = $nodeatt{$mtms}{$id}{'num'}; + my $value = (); + my $data = (); my $type; ######################################### # Invalid target hardware ######################################### - if ( $nodetype ne "lpar" ) { - return( [[$node,"Node must be LPAR",RC_ERROR]] ); + if ($nodetype ne "lpar") { + return ([ [ $node, "Node must be LPAR", RC_ERROR ] ]); } ######################################### # Put all the attributes required # together ######################################### - push @$value,"\n#Type Phys_Port_Loc MAC_Address Adapter Port_Group Phys_Port Logical_Port VLan VSwitch Curr_Conn_Speed\n"; + push @$value, "\n#Type Phys_Port_Loc MAC_Address Adapter Port_Group Phys_Port Logical_Port VLan VSwitch Curr_Conn_Speed\n"; - for ( my $num = 1; $num <= $mac_count; $num++ ) { - my $mac_addr = $nodeatt{$mtms}{$id}{$num}{'mac_addr'}; - my $adapter_id = $nodeatt{$mtms}{$id}{$num}{'adapter_id'}; - my $port_group = $nodeatt{$mtms}{$id}{$num}{'port_group'}; - my $phys_port_id = $nodeatt{$mtms}{$id}{$num}{'phys_port_id'}; + for (my $num = 1 ; $num <= $mac_count ; $num++) { + my $mac_addr = $nodeatt{$mtms}{$id}{$num}{'mac_addr'}; + my $adapter_id = $nodeatt{$mtms}{$id}{$num}{'adapter_id'}; + my $port_group = $nodeatt{$mtms}{$id}{$num}{'port_group'}; + my $phys_port_id = $nodeatt{$mtms}{$id}{$num}{'phys_port_id'}; my $logical_port_id = $nodeatt{$mtms}{$id}{$num}{'logical_port_id'}; - my $vlan_id = $nodeatt{$mtms}{$id}{$num}{'port_vlan_id'}; - my $vswitch = $nodeatt{$mtms}{$id}{$num}{'vswitch'}; - my $phys_port_loc = $nodeatt{$mtms}{$port_group}{$logical_port_id}{'phys_port_loc'}; + my $vlan_id = $nodeatt{$mtms}{$id}{$num}{'port_vlan_id'}; + my $vswitch = $nodeatt{$mtms}{$id}{$num}{'vswitch'}; + my $phys_port_loc = $nodeatt{$mtms}{$port_group}{$logical_port_id}{'phys_port_loc'}; my $curr_conn_speed = $nodeatt{$mtms}{$port_group}{$logical_port_id}{'curr_conn_speed'}; - if ( $phys_port_loc ) { - $type = "hea"; + if ($phys_port_loc) { + $type = "hea"; } else { $type = "virtualio"; } - my $type = $nodeatt{$mtms}{$id}{$num}{'type'}; - my %att = (); - if( $mac_addr ) { - $mac_addr = format_mac($mac_addr); - } - if ( !exists( $opt->{M} )) { + my $type = $nodeatt{$mtms}{$id}{$num}{'type'}; + my %att = (); + if ($mac_addr) { + $mac_addr = format_mac($mac_addr); + } + if (!exists($opt->{M})) { my @mac_addrs = split /\|/, $mac_addr; $mac_addr = @mac_addrs[0]; } - $att{'MAC_Address'} = ($mac_addr) ? $mac_addr : "N/A"; - $att{'Adapter'} = ($adapter_id) ? $adapter_id : "N/A"; - $att{'Port_Group'} = ($port_group) ? $port_group : "N/A"; - $att{'Phys_Port'} = ($phys_port_id) ? $phys_port_id : "N/A"; - $att{'Logical_Port'} = ($logical_port_id) ? $logical_port_id : "N/A"; - $att{'VLan'} = ($vlan_id) ? $vlan_id : "N/A"; - $att{'VSwitch'} = ($vswitch) ? $vswitch : "N/A"; - $att{'Phys_Port_Loc'} = ($phys_port_loc) ? $phys_port_loc : "N/A"; - $att{'Curr_Conn_Speed'} = ($curr_conn_speed) ? $curr_conn_speed : "N/A"; - $att{'Type'} = $type; + $att{'MAC_Address'} = ($mac_addr) ? $mac_addr : "N/A"; + $att{'Adapter'} = ($adapter_id) ? $adapter_id : "N/A"; + $att{'Port_Group'} = ($port_group) ? $port_group : "N/A"; + $att{'Phys_Port'} = ($phys_port_id) ? $phys_port_id : "N/A"; + $att{'Logical_Port'} = ($logical_port_id) ? $logical_port_id : "N/A"; + $att{'VLan'} = ($vlan_id) ? $vlan_id : "N/A"; + $att{'VSwitch'} = ($vswitch) ? $vswitch : "N/A"; + $att{'Phys_Port_Loc'} = ($phys_port_loc) ? $phys_port_loc : "N/A"; + $att{'Curr_Conn_Speed'} = ($curr_conn_speed) ? $curr_conn_speed : "N/A"; + $att{'Type'} = $type; ######################################### # Parse the adapter with the filters # specified ######################################### - if ( defined($filter) ) { + if (defined($filter)) { my $matched = 0; - foreach my $key ( keys %$filter ) { - if ( $key eq "MAC_Address" ) { - my $mac = lc($att{$key}); + foreach my $key (keys %$filter) { + if ($key eq "MAC_Address") { + my $mac = lc($att{$key}); my $filter_mac = lc($filter->{$key}); $mac =~ s/://g; $filter_mac =~ s/://g; - if ( grep(/$filter_mac/, $mac) ) { + if (grep(/$filter_mac/, $mac)) { $matched = 1; last; } - } elsif ( grep(/$filter->{$key}/, $att{$key}) ) { + } elsif (grep(/$filter->{$key}/, $att{$key})) { $matched = 1; last; } } - if ( $matched ) { - push @$value,"$att{'Type'} $att{'Phys_Port_Loc'} $att{'MAC_Address'} $att{'Adapter'} $att{'Port_Group'} $att{'Phys_Port'} $att{'Logical_Port'} $att{'VLan'} $att{'VSwitch'} $att{'Curr_Conn_Speed'}\n"; + if ($matched) { + push @$value, "$att{'Type'} $att{'Phys_Port_Loc'} $att{'MAC_Address'} $att{'Adapter'} $att{'Port_Group'} $att{'Phys_Port'} $att{'Logical_Port'} $att{'VLan'} $att{'VSwitch'} $att{'Curr_Conn_Speed'}\n"; } } else { - push @$value,"$att{'Type'} $att{'Phys_Port_Loc'} $att{'MAC_Address'} $att{'Adapter'} $att{'Port_Group'} $att{'Phys_Port'} $att{'Logical_Port'} $att{'VLan'} $att{'VSwitch'} $att{'Curr_Conn_Speed'}\n"; + push @$value, "$att{'Type'} $att{'Phys_Port_Loc'} $att{'MAC_Address'} $att{'Adapter'} $att{'Port_Group'} $att{'Phys_Port'} $att{'Logical_Port'} $att{'VLan'} $att{'VSwitch'} $att{'Curr_Conn_Speed'}\n"; } } ######################################### # Write MAC address to database ######################################### - if ( !exists( $opt->{d} )) { - writemac( $node, $value ); + if (!exists($opt->{d})) { + writemac($node, $value); } - if ( scalar(@$value) < 2 ) { - #my $filter = "lpar_id,curr_profile"; - #my $prof = xCAT::PPCcli::lssyscfg( $exp, "node", $mtms, $filter, $id ); - #my $Rc = shift(@$prof); + if (scalar(@$value) < 2) { + + #my $filter = "lpar_id,curr_profile"; + #my $prof = xCAT::PPCcli::lssyscfg( $exp, "node", $mtms, $filter, $id ); + #my $Rc = shift(@$prof); ######################################### # Return error ######################################### - #if ( $Rc != SUCCESS ) { - # return( [[$node,@$prof[0],$Rc]] ); - #} + #if ( $Rc != SUCCESS ) { + # return( [[$node,@$prof[0],$Rc]] ); + #} - #foreach my $val ( @$prof ) { - # my ($lpar_id,$curr_profile) = split /,/, $val; - # if ( !length($curr_profile) || ($curr_profile =~ /^none$/) ) { - # push @emptynode,$node; - # } - #} - return( [[$node,"get NO mac address from PHYP for $node",-1]]); + #foreach my $val ( @$prof ) { + # my ($lpar_id,$curr_profile) = split /,/, $val; + # if ( !length($curr_profile) || ($curr_profile =~ /^none$/) ) { + # push @emptynode,$node; + # } + #} + return ([ [ $node, "get NO mac address from PHYP for $node", -1 ] ]); } - foreach ( @$value ) { - if ( /^#\s?Type/ ) { - $data.= "\n$_\n"; + foreach (@$value) { + if (/^#\s?Type/) { + $data .= "\n$_\n"; } else { - #$data.= format_mac( $_ ); - $data .= $_; + + #$data.= format_mac( $_ ); + $data .= $_; } } - push @$result,[$node,$data,0]; + push @$result, [ $node, $data, 0 ]; } } - if ( scalar(@emptynode) > 0 ) { - return([[join(",", @emptynode),"\nThese nodes have no active profiles. Please active the nodes to enable the default profiles",RC_ERROR]]); - } - return([@$result]); + if (scalar(@emptynode) > 0) { + return ([ [ join(",", @emptynode), "\nThese nodes have no active profiles. Please active the nodes to enable the default profiles", RC_ERROR ] ]); + } + return ([@$result]); } else { ######################################### # Connect to fsp to achieve MAC address @@ -453,108 +467,112 @@ sub getmacs { my $d = $par; ######################################### - # Get node data + # Get node data ######################################### - my $lparid = @$d[0]; - my $mtms = @$d[2]; - my $type = @$d[4]; - my $node = @$d[6]; + my $lparid = @$d[0]; + my $mtms = @$d[2]; + my $type = @$d[4]; + my $node = @$d[6]; ######################################### - # Invalid target hardware + # Invalid target hardware ######################################### - if ( $type ne "lpar" ) { - return( [[$node,"Node must be LPAR",RC_ERROR]] ); + if ($type ne "lpar") { + return ([ [ $node, "Node must be LPAR", RC_ERROR ] ]); } ######################################### # Get name known by HCP ######################################### my $filter = "name,lpar_id"; - # my $values = xCAT::PPCcli::lssyscfg( $exp, $type, $mtms, $filter ); - #my $Rc = shift(@$values); + + # my $values = xCAT::PPCcli::lssyscfg( $exp, $type, $mtms, $filter ); + #my $Rc = shift(@$values); ######################################### # Return error ######################################### - #if ( $Rc != SUCCESS ) { - # return( [[$node,@$values[0],$Rc]] ); - # } + #if ( $Rc != SUCCESS ) { + # return( [[$node,@$values[0],$Rc]] ); + # } ######################################### # Find LPARs by lpar_id ######################################### - # foreach ( @$values ) { - # if ( /^(.*),$lparid$/ ) { - # $name = $1; - # last; - # } - # } + # foreach ( @$values ) { + # if ( /^(.*),$lparid$/ ) { + # $name = $1; + # last; + # } + # } ######################################### - # Node not found by lpar_id + # Node not found by lpar_id ######################################### - # if ( !defined( $name )) { - # return( [[$node,"Node not found, lparid=$lparid",RC_ERROR]] ); + # if ( !defined( $name )) { + # return( [[$node,"Node not found, lparid=$lparid",RC_ERROR]] ); # } my $Rc; + #my $sitetab = xCAT::Table->new('site'); #my $vcon = $sitetab->getAttribs({key => "conserverondemand"}, 'value'); #if ($vcon and $vcon->{"value"} and $vcon->{"value"} eq "yes" ) { - # $result = xCAT::PPCcli::lpar_netboot( - # $exp, - # $request->{verbose}, - # $name, - # $d, - # $opt ); + # $result = xCAT::PPCcli::lpar_netboot( + # $exp, + # $request->{verbose}, + # $name, + # $d, + # $opt ); # return( [[$node,"Not support conserverondemand's value is yes",RC_ERROR]] ); #} else { - ######################################### - # Manually collect MAC addresses. - ######################################### - xCAT::MsgUtils->verbose_message($request, "getmacs :do_getmacs for node:$node."); - $result = do_getmacs( $request, $d, $exp, $name, $node ); + ######################################### + # Manually collect MAC addresses. + ######################################### + xCAT::MsgUtils->verbose_message($request, "getmacs :do_getmacs for node:$node."); + $result = do_getmacs($request, $d, $exp, $name, $node); + #} #$sitetab->close; $Rc = shift(@$result); - + my $data; - my $value; - if ( $Rc == SUCCESS ) { - foreach ( @$result ) { - if ( /^#\s?Type/ ) { - $data.= "\n$_\n"; - push @$value, "\n$_\n"; - } elsif ( /^ent\s+/ || /^hfi-ent\s+/ ) { - #my @fields = split /\s+/, $_; - #my $mac = $fields[2]; - #$mac = format_mac( $mac ); - #$fields[2] = $mac; - #$data .= join(" ",@fields)."\n"; - #push @$value, join(" ",@fields)."\n"; - $data .= "$_\n"; - push @$value, "$_\n"; - } - } - push @$res,[$node,$data,0]; - } - - ################################## - # Form string from array results - ################################## - if ( exists($request->{verbose}) ) { - if ( $Rc == SUCCESS ) { - if ( !exists( $opt->{d} )) { - writemac( $node, $value ); + my $value; + if ($Rc == SUCCESS) { + foreach (@$result) { + if (/^#\s?Type/) { + $data .= "\n$_\n"; + push @$value, "\n$_\n"; + } elsif (/^ent\s+/ || /^hfi-ent\s+/) { + + #my @fields = split /\s+/, $_; + #my $mac = $fields[2]; + #$mac = format_mac( $mac ); + #$fields[2] = $mac; + #$data .= join(" ",@fields)."\n"; + #push @$value, join(" ",@fields)."\n"; + $data .= "$_\n"; + push @$value, "$_\n"; } } - return( [[$node,join( '', @$result ),$Rc]] ); + push @$res, [ $node, $data, 0 ]; + } + + ################################## + # Form string from array results + ################################## + if (exists($request->{verbose})) { + if ($Rc == SUCCESS) { + if (!exists($opt->{d})) { + writemac($node, $value); + } + } + return ([ [ $node, join('', @$result), $Rc ] ]); } ################################## # Return error ################################## - if ( $Rc != SUCCESS ) { - if ( @$result[0] =~ /lpar_netboot (.*)/ ) { - return( [[$node,$1,$Rc]] ); + if ($Rc != SUCCESS) { + if (@$result[0] =~ /lpar_netboot (.*)/) { + return ([ [ $node, $1, $Rc ] ]); } - return( [[$node,join( '', @$result ),$Rc]] ); + return ([ [ $node, join('', @$result), $Rc ] ]); } ##################################### # lpar_netboot returns: @@ -570,24 +588,25 @@ sub getmacs { # ent U9117.MMA.10F6F3D-V5-C3-T1 1e0e122a930d /vdevice/l-lan@30000003 # ##################################### - #my $data; + #my $data; - #foreach ( @$result ) { - # if ( /^#\s?Type/ ) { - # $data.= "\n$_\n"; - # } elsif ( /^ent\s+/ or /^hfi-ent\s+/) { - # $data.= format_mac( $_ ); - # } - #} + #foreach ( @$result ) { + # if ( /^#\s?Type/ ) { + # $data.= "\n$_\n"; + # } elsif ( /^ent\s+/ or /^hfi-ent\s+/) { + # $data.= format_mac( $_ ); + # } + #} ##################################### # Write first valid adapter MAC to database ##################################### - if ( !exists( $opt->{d} )) { - writemac( $node, $value ); + if (!exists($opt->{d})) { + writemac($node, $value); } - #return( [[$node,$data,$Rc]] ); + + #return( [[$node,$data,$Rc]] ); xCAT::MsgUtils->verbose_message($request, "getmacs END."); - return $res; + return $res; } } @@ -600,11 +619,11 @@ sub cal_mac { my $mac = shift; $mac =~ s/://g; - $mac =~ /(.........)(.)(..)/; - my ($basemac, $mac_h, $mac_l) = ($1,$2, $3); + $mac =~ /(.........)(.)(..)/; + my ($basemac, $mac_h, $mac_l) = ($1, $2, $3); my $macnum_l = hex($mac_l); my $macnum_h = hex($mac_h); - $macnum_l += 1; + $macnum_l += 1; if ($macnum_l > 0xFF) { $macnum_h += 1; } @@ -612,9 +631,9 @@ sub cal_mac { $newmac_l =~ /(..)$/; $newmac_l = $1; my $newmac_h = sprintf("%01X", $macnum_h); - my $newmac = $basemac.$newmac_h.$newmac_l; + my $newmac = $basemac . $newmac_h . $newmac_l; - return( $newmac ); + return ($newmac); } ########################################################################## @@ -623,6 +642,7 @@ sub cal_mac { sub format_mac { my $mac = shift; + #my $data = shift; ##################################### @@ -632,8 +652,8 @@ sub format_mac { my $newmac = $mac; my @macs = split /\|/, $mac; - if ( !xCAT::Utils->isAIX() ) { - foreach my $mac_a ( @macs ) { + if (!xCAT::Utils->isAIX()) { + foreach my $mac_a (@macs) { ################################# # Delineate MAC with colons ################################# @@ -642,11 +662,11 @@ sub format_mac { $mac_a =~ s/:$//; push @newmacs, $mac_a; } - $newmac = join("|",@newmacs); + $newmac = join("|", @newmacs); } - return( "$newmac" ); + return ("$newmac"); } @@ -656,7 +676,7 @@ sub format_mac { sub checkmac { my $mac = shift; - if ( !xCAT::Utils->isAIX()) { + if (!xCAT::Utils->isAIX()) { if ($mac =~ /\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2}/) { return 1; } else { @@ -668,12 +688,12 @@ sub checkmac { } ########################################################################## -# Write first valid adapter MAC to database +# Write first valid adapter MAC to database ########################################################################## sub writemac { - my $name = shift; - my $data = shift; + my $name = shift; + my $data = shift; my $value; my $pingret; my $ping_test; @@ -683,18 +703,18 @@ sub writemac { ##################################### # Find first valid adapter ##################################### - foreach ( @$data ) { - if ( /^ent\s+/ or /^hfi-ent\s+/ ) { + foreach (@$data) { + if (/^ent\s+/ or /^hfi-ent\s+/) { $value = $_; ##################################### # MAC not found in output ##################################### - if ( !defined( $value )) { + if (!defined($value)) { return; } @fields = split /\s+/, $value; $pingret = $fields[4]; - if ( $pingret eq "successful" ) { + if ($pingret eq "successful") { $ping_test = 0; last; } @@ -704,17 +724,17 @@ sub writemac { ##################################### # If no valid adapter, find the first one ##################################### - if ( $pingret ne "successful" ) { - foreach ( @$data ) { + if ($pingret ne "successful") { + foreach (@$data) { unless (&checkmac($_)) { next; } - if ( /^ent\s+/ or /^hfi-ent\s+/ ) { - $value = $_; + if (/^ent\s+/ or /^hfi-ent\s+/) { + $value = $_; $ping_test = 0; last; - } elsif ( /^hea\s+/ || /^virtualio\s+/ || /^HFI\s+/ ) { - $value = $_; + } elsif (/^hea\s+/ || /^virtualio\s+/ || /^HFI\s+/) { + $value = $_; $ping_test = 1; last; } @@ -724,24 +744,24 @@ sub writemac { ##################################### # MAC not found in output ##################################### - if ( !defined( $value )) { + if (!defined($value)) { return; } ##################################### # Get adapter mac ##################################### - #$value = format_mac( $value ); + #$value = format_mac( $value ); @fields = split /\s+/, $value; - $mac = $fields[2]; + $mac = $fields[2]; ##################################### # Write adapter mac to database ##################################### - my $mactab = xCAT::Table->new( "mac", -create=>1, -autocommit=>1 ); - if ( !$mactab ) { - return( [[$name,"Error opening 'mac'",RC_ERROR]] ); + my $mactab = xCAT::Table->new("mac", -create => 1, -autocommit => 1); + if (!$mactab) { + return ([ [ $name, "Error opening 'mac'", RC_ERROR ] ]); } - $mactab->setNodeAttribs( $name,{mac=>$mac} ); + $mactab->setNodeAttribs($name, { mac => $mac }); $mactab->close(); } diff --git a/perl-xCAT/xCAT/FSPpower.pm b/perl-xCAT/xCAT/FSPpower.pm index 4b9d1517d..972c22791 100644 --- a/perl-xCAT/xCAT/FSPpower.pm +++ b/perl-xCAT/xCAT/FSPpower.pm @@ -2,19 +2,21 @@ package xCAT::FSPpower; use strict; + #use Getopt::Long; use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR); use xCAT::PPCpower; use xCAT::FSPUtils; use xCAT::GlobalDef; use xCAT_monitoring::monitorctrl; + #use Data::Dumper; ########################################################################## # Parse the command line for options and operands ########################################################################## sub parse_args { - xCAT::PPCpower::parse_args(@_); + xCAT::PPCpower::parse_args(@_); } @@ -23,58 +25,60 @@ sub parse_args { ########################################################################## sub enumerate { - my $request = shift; - my $h = shift; - my $mtms = shift; + my $request = shift; + my $h = shift; + my $mtms = shift; my $tooltype = shift; - my %outhash = (); - my %cmds = (); - my $type = (); - my $cec_bpa = (); + my %outhash = (); + my %cmds = (); + my $type = (); + my $cec_bpa = (); my $tmp_d; my $tmp_name; - + ###################################### # Check for CEC/LPAR/BPAs in list ###################################### - while (my ($name,$d) = each(%$h) ) { - $cec_bpa = @$d[3]; - $type = @$d[4]; - $tmp_d = $d; + while (my ($name, $d) = each(%$h)) { + $cec_bpa = @$d[3]; + $type = @$d[4]; + $tmp_d = $d; $tmp_name = $name; + #$cmds{$type} = ($type=~/^lpar$/) ? "all_lpars_state" : "cec_state"; - if( $type=~/^lpar$/ ) { + if ($type =~ /^lpar$/) { $cmds{$type} = "all_lpars_state"; - } elsif ($type=~/^(fsp|cec|blade)$/) { - $cmds{$type} = "cec_state"; + } elsif ($type =~ /^(fsp|cec|blade)$/) { + $cmds{$type} = "cec_state"; } else { $cmds{$type} = "bpa_state"; } } - foreach my $type ( keys %cmds ) { + foreach my $type (keys %cmds) { my $action = $cmds{$type}; + #my $values = xCAT::FSPUtils::fsp_state_action ($request, $cec_bpa, $type, $action, $tooltype); - my $values = xCAT::FSPUtils::fsp_state_action ($request, $cec_bpa, $tmp_d, $action, $tooltype); + my $values = xCAT::FSPUtils::fsp_state_action($request, $cec_bpa, $tmp_d, $action, $tooltype); my $Rc = shift(@$values); ################################## - # Return error + # Return error ################################## - if ( $Rc != 0 ) { - return( [$Rc,@$values[0]] ); + if ($Rc != 0) { + return ([ $Rc, @$values[0] ]); } ################################## - # Save LPARs by id + # Save LPARs by id ################################## - foreach ( @$values ) { - my ($state,$lparid) = split /,/; + foreach (@$values) { + my ($state, $lparid) = split /,/; ############################## - # No lparid for fsp/bpa + # No lparid for fsp/bpa ############################## - if ( $type =~ /^(fsp|bpa|cec|frame|blade)$/ ) { + if ($type =~ /^(fsp|bpa|cec|frame|blade)$/) { if ($type eq 'blade') { if ($state eq 'operating') { - my $res = xCAT::FSPUtils::fsp_api_action($request, $tmp_name,$tmp_d,'state',$tooltype); + my $res = xCAT::FSPUtils::fsp_api_action($request, $tmp_name, $tmp_d, 'state', $tooltype); if (@$res[2] == 0 and @$res[1] =~ /open-firmware/i) { $state = @$res[1]; } @@ -85,10 +89,10 @@ sub enumerate { } $lparid = $type; } - $outhash{ $lparid } = $state; + $outhash{$lparid} = $state; } } - return( [0,\%outhash] ); + return ([ 0, \%outhash ]); } ########################################################################## @@ -98,15 +102,15 @@ sub powercmd_boot { my $request = shift; my $hash = shift; - my @output = (); - - my $newstat; - my %newnodestatus=(); + my @output = (); + + my $newstat; + my %newnodestatus = (); ###################################### - # Power commands are grouped by CEC + # Power commands are grouped by CEC # not Hardware Control Point ###################################### - + #Example of $hash # $VAR1 = { # 'Server-9110-51A-SN1075ECF' => [ @@ -118,58 +122,62 @@ sub powercmd_boot { # 0 # ] # } - foreach my $node_name ( keys %$hash) + foreach my $node_name (keys %$hash) { - - my $d = $hash->{$node_name}; - if (!($$d[4] =~ /^lpar$/)) { - push @output, [$node_name, "\'boot\' command not supported for CEC or BPA", -1 ]; - #return (\@output); - next; - } - - my $res = xCAT::FSPUtils::fsp_api_action ($request,$node_name, $d, "state"); - #print "In boot, state\n"; - #print Dumper($res); - my $Rc = @$res[2]; - my $data = @$res[1]; - #my $type = @$d[4]; - #my $id = ($type=~/^(fsp|bpa)$/) ? $type : @$d[0]; - - ################################## - # Output error - ################################## - if ( $Rc != SUCCESS ) { - push @output, [$node_name,$data,$Rc]; - next; - } - - ################################## - # Convert state to on/off - ################################## - my $state = power_status($data); - #print "boot:state:$state\n"; - my $op = ($state =~ /^off$/) ? "on" : "reset"; - $newstat = $::STATUS_POWERING_ON; + my $d = $hash->{$node_name}; + if (!($$d[4] =~ /^lpar$/)) { + push @output, [ $node_name, "\'boot\' command not supported for CEC or BPA", -1 ]; - # Attribute powerinterval in site table, - # to control the rpower speed - if( defined($request->{'powerinterval'}) ) { - Time::HiRes::sleep($request->{'powerinterval'}); - } + #return (\@output); + next; + } - $res = xCAT::FSPUtils::fsp_api_action ($request,$node_name, $d, $op); - - # @output ... - $Rc = @$res[2]; - $data = @$res[1]; - if ( $Rc != SUCCESS ) { - push @output, [$node_name,$data,$Rc]; - next; - } - - push @output,[$node_name, "Success", 0]; + my $res = xCAT::FSPUtils::fsp_api_action($request, $node_name, $d, "state"); + + #print "In boot, state\n"; + #print Dumper($res); + my $Rc = @$res[2]; + my $data = @$res[1]; + + #my $type = @$d[4]; + #my $id = ($type=~/^(fsp|bpa)$/) ? $type : @$d[0]; + + ################################## + # Output error + ################################## + if ($Rc != SUCCESS) { + push @output, [ $node_name, $data, $Rc ]; + next; + } + + ################################## + # Convert state to on/off + ################################## + my $state = power_status($data); + + #print "boot:state:$state\n"; + my $op = ($state =~ /^off$/) ? "on" : "reset"; + + $newstat = $::STATUS_POWERING_ON; + + # Attribute powerinterval in site table, + # to control the rpower speed + if (defined($request->{'powerinterval'})) { + Time::HiRes::sleep($request->{'powerinterval'}); + } + + $res = xCAT::FSPUtils::fsp_api_action($request, $node_name, $d, $op); + + # @output ... + $Rc = @$res[2]; + $data = @$res[1]; + if ($Rc != SUCCESS) { + push @output, [ $node_name, $data, $Rc ]; + next; + } + + push @output, [ $node_name, "Success", 0 ]; if ($newstat) { push @{ $newnodestatus{$newstat} }, $node_name; } @@ -177,7 +185,7 @@ sub powercmd_boot { if (%newnodestatus) { xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); } - return( \@output ); + return (\@output); } @@ -187,29 +195,29 @@ sub powercmd_boot { ########################################################################## sub powercmd { - my $request = shift; - my $hash = shift; - my $tooltype = $request->{opt}->{T}; - my @result = (); + my $request = shift; + my $hash = shift; + my $tooltype = $request->{opt}->{T}; + my @result = (); my @output; my $action; my $node_name; my $newids; my $newnames; my $newd; - my $lpar_flag = 0; - my $cec_flag = 0; + my $lpar_flag = 0; + my $cec_flag = 0; my $frame_flag = 0; - #print "++++in powercmd++++\n"; + #print "++++in powercmd++++\n"; #print Dumper($hash); - + #################################### - # Power commands are grouped by cec or lpar + # Power commands are grouped by cec or lpar # not Hardware Control Point #################################### - - #Example of $hash. + + #Example of $hash. #$VAR1 = { # 'lpar01' => [ # '1', @@ -222,138 +230,143 @@ sub powercmd { # }; my $newstat; my @updatenode; - my %newnodestatus=(); - foreach $node_name ( keys %$hash) + my %newnodestatus = (); + foreach $node_name (keys %$hash) { - $action = $request->{'op'}; + $action = $request->{'op'}; my $d = $hash->{$node_name}; if ($$d[4] =~ /^lpar$/) { - if( !($action =~ /^(on|off|of|reset|sms)$/)) { - push @output, [$node_name, "\'$action\' command not supported for LPAR", -1 ]; - return (\@output); + if (!($action =~ /^(on|off|of|reset|sms)$/)) { + push @output, [ $node_name, "\'$action\' command not supported for LPAR", -1 ]; + return (\@output); } - $newids .= "$$d[0],"; - $newnames .="$node_name,"; - $newd = $d; + $newids .= "$$d[0],"; + $newnames .= "$node_name,"; + $newd = $d; $lpar_flag = 1; - if($action =~ /^on$/) { + if ($action =~ /^on$/) { $newstat = $::STATUS_POWERING_ON; push @updatenode, $node_name; } - if($action =~ /^(off|of$)/) { - $newstat = $::STATUS_POWERING_OFF; + if ($action =~ /^(off|of$)/) { + $newstat = $::STATUS_POWERING_OFF; push @updatenode, $node_name; } - if($action =~ /^reset$/) { - my $res = xCAT::FSPUtils::fsp_api_action ($request,$node_name, $d, "state"); - my $Rc = @$res[2]; + if ($action =~ /^reset$/) { + my $res = xCAT::FSPUtils::fsp_api_action($request, $node_name, $d, "state"); + my $Rc = @$res[2]; my $data = @$res[1]; - if ( $Rc != SUCCESS ) { next; } + if ($Rc != SUCCESS) { next; } my $state = power_status($data); if ($state =~ /^off$/) { next; } $newstat = $::STATUS_POWERING_ON; - push @updatenode, $node_name; - } + push @updatenode, $node_name; + } } elsif ($$d[4] =~ /^(fsp|cec|blade)$/) { - if($action =~ /^on$/) { $action = "cec_on_autostart"; } - if($action =~ /^off$/) { $action = "cec_off"; } - if($action =~ /^resetsp$/) { $action = "reboot_service_processor"; } - if($action =~ /^lowpower$/) { $action = "cec_on_low_power"; } + if ($action =~ /^on$/) { $action = "cec_on_autostart"; } + if ($action =~ /^off$/) { $action = "cec_off"; } + if ($action =~ /^resetsp$/) { $action = "reboot_service_processor"; } + if ($action =~ /^lowpower$/) { $action = "cec_on_low_power"; } + #if($action =~ /^cycle$/) {$action = "cec_reboot";} - if($action =~ /^cycle$/) { $action = "reset"; } - if($action !~ /^cec_on_autostart$/ && $action !~ /^cec_off$/ && $action !~ /^cec_on_low_power$/ && $action !~ /^onstandby$/ && $action !~ /^reboot_service_processor$/ && $action !~ /^reset$/ && $action !~ /^sms$/) { - push @output, [$node_name, "\'$action\' command not supported for $$d[4]", -1 ]; - return (\@output); - } - $newids = $$d[0]; - $newnames = $node_name; - $newd = $d; - $cec_flag = 1; + if ($action =~ /^cycle$/) { $action = "reset"; } + if ($action !~ /^cec_on_autostart$/ && $action !~ /^cec_off$/ && $action !~ /^cec_on_low_power$/ && $action !~ /^onstandby$/ && $action !~ /^reboot_service_processor$/ && $action !~ /^reset$/ && $action !~ /^sms$/) { + push @output, [ $node_name, "\'$action\' command not supported for $$d[4]", -1 ]; + return (\@output); + } + $newids = $$d[0]; + $newnames = $node_name; + $newd = $d; + $cec_flag = 1; } else { - if ( $action =~ /^rackstandby$/) { - $action = "enter_rack_standby"; - } elsif ( $action=~/^exit_rackstandby$/) { - $action = "exit_rack_standby"; - } elsif ($action =~ /^resetsp$/) { - $action = "reboot_service_processor"; - } else { - push @output, [$node_name, "$node_name\'s type isn't fsp or lpar. Not allow doing this operation", -1 ]; - return (\@output); - } - $newids = $$d[0]; - $newnames = $node_name; - $newd = $d; - $frame_flag = 1; - } + if ($action =~ /^rackstandby$/) { + $action = "enter_rack_standby"; + } elsif ($action =~ /^exit_rackstandby$/) { + $action = "exit_rack_standby"; + } elsif ($action =~ /^resetsp$/) { + $action = "reboot_service_processor"; + } else { + push @output, [ $node_name, "$node_name\'s type isn't fsp or lpar. Not allow doing this operation", -1 ]; + return (\@output); + } + $newids = $$d[0]; + $newnames = $node_name; + $newd = $d; + $frame_flag = 1; + } - if( $lpar_flag && $cec_flag) { - push @output, [$node_name," $node_name\'s type is different from the last node. The noderange of power control operation could NOT be lpar/cec mixed" , -1 ]; - return (\@output); - - } + if ($lpar_flag && $cec_flag) { + push @output, [ $node_name, " $node_name\'s type is different from the last node. The noderange of power control operation could NOT be lpar/cec mixed", -1 ]; + return (\@output); - if( $lpar_flag && $frame_flag) { - push @output, [$node_name," $node_name\'s type is different from the last node. The noderange of power control operation could NOT be lpar/frame mixed" , -1 ]; - return (\@output); - - } + } - if( $cec_flag && $frame_flag) { - push @output, [$node_name," $node_name\'s type is different from the last node. The noderange of power control operation could NOT be cec/frame mixed" , -1 ]; - return (\@output); - - } + if ($lpar_flag && $frame_flag) { + push @output, [ $node_name, " $node_name\'s type is different from the last node. The noderange of power control operation could NOT be lpar/frame mixed", -1 ]; + return (\@output); + + } + + if ($cec_flag && $frame_flag) { + push @output, [ $node_name, " $node_name\'s type is different from the last node. The noderange of power control operation could NOT be cec/frame mixed", -1 ]; + return (\@output); + + } } $$newd[0] = $newids; - + #print Dumper($newd); - my $res = xCAT::FSPUtils::fsp_api_action($request, $newnames, $newd, $action, $tooltype, $request->{'powerinterval'} ); + my $res = xCAT::FSPUtils::fsp_api_action($request, $newnames, $newd, $action, $tooltype, $request->{'powerinterval'}); + # print "In boot, state\n"; # print Dumper($res); - my $Rc = @$res[2]; + my $Rc = @$res[2]; my $data = @$res[1]; - foreach $node_name ( keys %$hash) + foreach $node_name (keys %$hash) { my $d = $hash->{$node_name}; - - if( $data =~ /Error/) { - if( $data =~ /Power interval/) { + + if ($data =~ /Error/) { + if ($data =~ /Power interval/) { $data = "Error: Invalid powerinterval value in the site table. The valid powerinerval value could be 0 to 300 ."; - push @output, [$node_name, $data, -1]; + push @output, [ $node_name, $data, -1 ]; next; - } elsif ( $data =~ /$node_name/) { - push @output, [$node_name, $data, -1]; + } elsif ($data =~ /$node_name/) { + push @output, [ $node_name, $data, -1 ]; next; } } if ((scalar(keys %$hash) == 1) and $Rc) { - push @output, [$node_name, $data, $Rc]; + push @output, [ $node_name, $data, $Rc ]; } else { - # check the state of the blade or CEC after cec_reboot in order to let HWS realize the destination CEC had been powerd off # - #my $msg = "success"; - if ($action eq 'cec_reboot') { - sleep 0.1; - xCAT::FSPUtils::fsp_state_action ($request, @$d[3], $d, "cec_state"); - #my $state_res = xCAT::FSPUtils::fsp_state_action (@$d[3], @$d[4], "cec_state"); - #my @state_state = @$state_res[1]; - #$msg = @state_state[0]; - } - push @output, [$node_name,"Success", 0]; - #push @output, [$node_name,$msg, 0]; - if (($newstat) and (grep{$_ eq $node_name}@updatenode)) { - push @{ $newnodestatus{$newstat} }, $node_name; - } + + # check the state of the blade or CEC after cec_reboot in order to let HWS realize the destination CEC had been powerd off # + #my $msg = "success"; + if ($action eq 'cec_reboot') { + sleep 0.1; + xCAT::FSPUtils::fsp_state_action($request, @$d[3], $d, "cec_state"); + + #my $state_res = xCAT::FSPUtils::fsp_state_action (@$d[3], @$d[4], "cec_state"); + #my @state_state = @$state_res[1]; + #$msg = @state_state[0]; + } + push @output, [ $node_name, "Success", 0 ]; + + #push @output, [$node_name,$msg, 0]; + if (($newstat) and (grep { $_ eq $node_name } @updatenode)) { + push @{ $newnodestatus{$newstat} }, $node_name; + } } } if (%newnodestatus) { xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); - } - return( \@output ); + } + return (\@output); } @@ -361,44 +374,44 @@ sub powercmd { # Queries CEC/LPAR power status (On or Off) for powercmd_boot ########################################################################## sub power_status { - my $value = shift; + my $value = shift; my @states = ( "Operating|operating|on", "Running|running", "standby", "Open Firmware|open-firmware" ); - foreach my $s ( @states ) { - if ($value =~ /$s/ ) { - return("on"); + foreach my $s (@states) { + if ($value =~ /$s/) { + return ("on"); } - } - return("off"); + } + return ("off"); } ########################################################################## -# Queries CEC/LPAR power status +# Queries CEC/LPAR power status ########################################################################## sub state { - my $request = shift; - my $hash = shift; - my $exp = shift; # NOt use - my $prefix = shift; - my $convert = shift; - my @output = (); - my $tooltype = $request->{opt}->{T}; - - - #print "------in state--------\n"; - #print Dumper($request); - #print Dumper($hash); + my $request = shift; + my $hash = shift; + my $exp = shift; # NOt use + my $prefix = shift; + my $convert = shift; + my @output = (); + my $tooltype = $request->{opt}->{T}; + + + #print "------in state--------\n"; + #print Dumper($request); + #print Dumper($hash); #################################### # Power commands are grouped by hardware control point - # In FSPpower, the hcp is the related fsp. + # In FSPpower, the hcp is the related fsp. #################################### - - # Example of $hash. + + # Example of $hash. #VAR1 = { # '9110-51A*1075ECF' => { # 'Server-9110-51A-SN1075ECF' => [ @@ -409,58 +422,61 @@ sub state { # 'fsp', # 0 # ] - # } + # } # }; - my @result = (); + my @result = (); - if ( !defined( $prefix )) { + if (!defined($prefix)) { $prefix = ""; } - while (my ($mtms,$h) = each(%$hash) ) { + while (my ($mtms, $h) = each(%$hash)) { ###################################### # Build CEC/LPAR information hash ###################################### my $stat = enumerate($request, $h, $mtms, $tooltype); - my $Rc = shift(@$stat); + my $Rc = shift(@$stat); my $data = @$stat[0]; + #if($Rc != 0) { # push @result,[$mtms ,$$data[0],$Rc]; # return(\@result); #} - while (my ($name,$d) = each(%$h) ) { + while (my ($name, $d) = each(%$h)) { ################################## - # Look up by lparid + # Look up by lparid ################################## my $type = @$d[4]; - my $id = ($type=~/^(fsp|bpa|cec|frame|blade)$/) ? $type : @$d[0]; - + my $id = ($type =~ /^(fsp|bpa|cec|frame|blade)$/) ? $type : @$d[0]; + ################################## # Output error ################################## - if ( $Rc != SUCCESS ) { - push @result, [$name, "$prefix$data",$Rc]; + if ($Rc != SUCCESS) { + push @result, [ $name, "$prefix$data", $Rc ]; next; } - #print Dumper($data); - my @k = keys(%$data); - if( grep(/all/, @k) == 1 ) { - $data->{$id} = $data->{all}; + + #print Dumper($data); + my @k = keys(%$data); + if (grep(/all/, @k) == 1) { + $data->{$id} = $data->{all}; } ################################## - # Node not found + # Node not found ################################## - if ($type !~ /^blade$/ and !exists( $data->{$id} )) { - my $res = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "state", $tooltype); - my $rc = @$res[2]; + if ($type !~ /^blade$/ and !exists($data->{$id})) { + my $res = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "state", $tooltype); + my $rc = @$res[2]; my $val = @$res[1]; - if( $rc != 0) { + if ($rc != 0) { + #push @result, [$name, $prefix.$val,1]; } - - if( !defined($val) || $val =~ /^error$/ ) { - push @result, [$name, $prefix."Node not found",1]; + + if (!defined($val) || $val =~ /^error$/) { + push @result, [ $name, $prefix . "Node not found", 1 ]; next; } else { $data->{$id} = $val; @@ -473,19 +489,19 @@ sub state { my $value = $data->{$id}; ############################## - # Convert state to on/off + # Convert state to on/off ############################## - if ( defined( $convert )) { - $value = power_status( $value ); + if (defined($convert)) { + $value = power_status($value); } - push @result, [$name,"$prefix$value",$Rc]; + push @result, [ $name, "$prefix$value", $Rc ]; } } - return( \@result ); - - + return (\@result); + + } @@ -493,28 +509,28 @@ sub state { ########################################################################## -# Queries CEC/LPAR power status +# Queries CEC/LPAR power status ########################################################################## sub state1 { my $request = shift; my $hash = shift; - my $exp = shift; # NOt use + my $exp = shift; # NOt use my $prefix = shift; my $convert = shift; my @output = (); - my $action = "state"; - - - #print "------in state--------\n"; - #print Dumper($request); - #print Dumper($hash); + my $action = "state"; + + + #print "------in state--------\n"; + #print Dumper($request); + #print Dumper($hash); #################################### # Power commands are grouped by hardware control point - # In FSPpower, the hcp is the related fsp. + # In FSPpower, the hcp is the related fsp. #################################### - - # Example of $hash. + + # Example of $hash. #VAR1 = { # '9110-51A*1075ECF' => { # 'Server-9110-51A-SN1075ECF' => [ @@ -525,55 +541,56 @@ sub state1 { # 'fsp', # 0 # ] - # } + # } # }; - - foreach my $cec_bpa ( keys %$hash) + + foreach my $cec_bpa (keys %$hash) { - + my $node_hash = $hash->{$cec_bpa}; - for my $node_name ( keys %$node_hash) + for my $node_name (keys %$node_hash) { my $d = $node_hash->{$node_name}; - if($$d[4] =~ /^fsp$/ || $$d[4] =~ /^bpa$/) { - $action = "cec_state"; - } - my $stat = xCAT::FSPUtils::fsp_api_action ($request, $node_name, $d, $action); - my $Rc = @$stat[2]; - my $data = @$stat[1]; + if ($$d[4] =~ /^fsp$/ || $$d[4] =~ /^bpa$/) { + $action = "cec_state"; + } + my $stat = xCAT::FSPUtils::fsp_api_action($request, $node_name, $d, $action); + my $Rc = @$stat[2]; + my $data = @$stat[1]; my $type = @$d[4]; - #my $id = ($type=~/^(fsp|bpa)$/) ? $type : @$d[0]; - ################################## + + #my $id = ($type=~/^(fsp|bpa)$/) ? $type : @$d[0]; + ################################## # Output error ################################## - if ( $Rc != SUCCESS ) { - push @output, [$node_name,$data,$Rc]; + if ($Rc != SUCCESS) { + push @output, [ $node_name, $data, $Rc ]; next; } - ############################## - # Convert state to on/off ############################## - if ( defined( $convert )) { - $data = power_status( $data ); + # Convert state to on/off + ############################## + if (defined($convert)) { + $data = power_status($data); } - #print Dumper($prefix); + #print Dumper($prefix); ################## - # state cec_state - ################# - if ( defined($prefix) ) { + # state cec_state + ################# + if (defined($prefix)) { $data = "$prefix $data"; } - - push @output,[$node_name, $data, $Rc]; - } + + push @output, [ $node_name, $data, $Rc ]; + } } - return( \@output ); - + return (\@output); + } diff --git a/perl-xCAT/xCAT/FSPscan.pm b/perl-xCAT/xCAT/FSPscan.pm index 1dacbeeb9..68f753674 100644 --- a/perl-xCAT/xCAT/FSPscan.pm +++ b/perl-xCAT/xCAT/FSPscan.pm @@ -5,7 +5,7 @@ use strict; use Getopt::Long; use Socket; use XML::Simple; -$XML::Simple::PREFERRED_PARSER='XML::Parser'; +$XML::Simple::PREFERRED_PARSER = 'XML::Parser'; use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR); use xCAT::PPCdb; use xCAT::PPCscan; @@ -14,35 +14,37 @@ use xCAT::Usage; use xCAT::NetworkUtils; use xCAT::FSPUtils; require xCAT::data::ibmhwtypes; + #use Data::Dumper; ############################################## # Globals ############################################## -my @header = ( - ["type", "%-8s" ], - ["name", "placeholder" ], - ["id", "%-8s" ], - ["type-model", "%-12s" ], - ["serial-number", "%-15s\n" ]); +my @header = ( + [ "type", "%-8s" ], + [ "name", "placeholder" ], + [ "id", "%-8s" ], + [ "type-model", "%-12s" ], + [ "serial-number", "%-15s\n" ]); + #, # ["side", "%-8s" ], # ["address", "%-20s\n" ]); my @attribs = qw(nodetype node id mtm serial side hcp pprofile parent groups mgt cons hwtype); my %globalnodetype = ( - fsp => $::NODETYPE_PPC, - bpa => $::NODETYPE_PPC, - cec => $::NODETYPE_PPC, - frame=> $::NODETYPE_PPC, - lpar =>"$::NODETYPE_PPC,$::NODETYPE_OSI" + fsp => $::NODETYPE_PPC, + bpa => $::NODETYPE_PPC, + cec => $::NODETYPE_PPC, + frame => $::NODETYPE_PPC, + lpar => "$::NODETYPE_PPC,$::NODETYPE_OSI" ); my %globalhwtype = ( - fsp => $::NODETYPE_FSP, - bpa => $::NODETYPE_BPA, - lpar => $::NODETYPE_LPAR, - cec => $::NODETYPE_CEC, - frame=> $::NODETYPE_FRAME, + fsp => $::NODETYPE_FSP, + bpa => $::NODETYPE_BPA, + lpar => $::NODETYPE_LPAR, + cec => $::NODETYPE_CEC, + frame => $::NODETYPE_FRAME, ); @@ -56,19 +58,19 @@ sub parse_args { ########################################################################## -# Returns short-hostname given an IP +# Returns short-hostname given an IP ########################################################################## sub getshorthost { my $ip = shift; my $host = xCAT::NetworkUtils->gethostname($ip); - if ( $host and !$! ) { + if ($host and !$!) { ############################## # Get short-hostname ############################## - if ( $host =~ /([^\.]+)\./ ) { - return($1); + if ($host =~ /([^\.]+)\./) { + return ($1); } } ################################## @@ -83,12 +85,12 @@ sub getshorthost { ########################################################################## sub enumerate { - my $request = shift; - my $hash = shift; - my $exp = shift; - my $hwtype = (); - my $server ; - my @values = (); + my $request = shift; + my $hash = shift; + my $exp = shift; + my $hwtype = (); + my $server; + my @values = (); my $cageid; my $server; my $prof; @@ -101,131 +103,141 @@ sub enumerate { my @output; my $ips; my $fsp; - my $model ; + my $model; my $serial; - my $side; + my $side; my $ips; - my $line; - - foreach my $cec_bpa ( keys %$hash) - { + my $line; + + foreach my $cec_bpa (keys %$hash) + { my $node_hash = $hash->{$cec_bpa}; - for my $node_name ( keys %$node_hash) + for my $node_name (keys %$node_hash) { my $d = $node_hash->{$node_name}; - if($$d[4] =~ /^lpar$/ || $$d[4] =~ /^bpa$/ || $$d[4] =~ /^frame$/ ) { - $data = "please check the $node_name; the noderange of rscan couldn't be LPAR or BPA, or frame. "; - #push @output, [$node_name,$data,$Rc]; + if ($$d[4] =~ /^lpar$/ || $$d[4] =~ /^bpa$/ || $$d[4] =~ /^frame$/) { + $data = "please check the $node_name; the noderange of rscan couldn't be LPAR or BPA, or frame. "; + + #push @output, [$node_name,$data,$Rc]; push @values, $data; next; - } - my $stat = xCAT::FSPUtils::fsp_api_action ($request, $node_name, $d, "query_connection"); - my $Rc = @$stat[2]; - my $data = @$stat[1]; - + } + my $stat = xCAT::FSPUtils::fsp_api_action($request, $node_name, $d, "query_connection"); + my $Rc = @$stat[2]; + my $data = @$stat[1]; + ################################## # Output error ################################## - if ( $Rc != SUCCESS ) { - #push @output, [$node_name,$data,$Rc]; + if ($Rc != SUCCESS) { + + #push @output, [$node_name,$data,$Rc]; push @values, $data; next; } my @data_a = split("\n", $data); - foreach $line(@data_a) { - if($line !~ "Connected" && $line !~ "LINE UP" ) { + foreach $line (@data_a) { + if ($line !~ "Connected" && $line !~ "LINE UP") { next; - } - + } + ######################################### # GET CEC's information ######################################### - #$data =~ /state=([\w\s]+),\(type=([\w-]+)\),\(serial-number=([\w]+)\),\(machinetype-model=([\w-]+)\),sp=([\w]+),\(ip-address=([\w.]+),([\w.]+)\)/ ; - $line =~ /state=([\w\s]+), type=([\w-]+), MTMS=([\w-]+)\*([\w-]+), sp=([\w=]+), slot=([\w]+), ipadd=([\w.]+), alt_ipadd=([\w.]+)/ ; - #print "parsing: $1,$2,$3,$4,$5,$6,$7,$8\n"; - - $fsp=$node_name; - $model = $3; - $serial = $4; - $side = $6; - $server = $fsp; - $fname = $fsp; - my $ip = $7; + #$data =~ /state=([\w\s]+),\(type=([\w-]+)\),\(serial-number=([\w]+)\),\(machinetype-model=([\w-]+)\),sp=([\w]+),\(ip-address=([\w.]+),([\w.]+)\)/ ; + $line =~ /state=([\w\s]+), type=([\w-]+), MTMS=([\w-]+)\*([\w-]+), sp=([\w=]+), slot=([\w]+), ipadd=([\w.]+), alt_ipadd=([\w.]+)/; + + #print "parsing: $1,$2,$3,$4,$5,$6,$7,$8\n"; + + $fsp = $node_name; + $model = $3; + $serial = $4; + $side = $6; + $server = $fsp; + $fname = $fsp; + my $ip = $7; my $ip_s = $8; - if(! defined( $ips)) { - if( $ip_s =~ /unavailable/ ) { - $ips ="$ip"; - } else { - $ips ="$ip;$ip_s"; - } + if (!defined($ips)) { + + if ($ip_s =~ /unavailable/) { + $ips = "$ip"; + } else { + $ips = "$ip;$ip_s"; + } } else { - if( $ip_s =~ /unavailable/ ) { - $ips .=";$ip"; - } else { - $ips .=";$ip;$ip_s"; - } + if ($ip_s =~ /unavailable/) { + $ips .= ";$ip"; + } else { + $ips .= ";$ip;$ip_s"; + } } } - if(!defined($fsp)) { - my $msg = "please check if the $node_name is coneected to the hardware server"; + if (!defined($fsp)) { + my $msg = "please check if the $node_name is coneected to the hardware server"; push @values, $msg; next; } - if($$d[4] =~ /^cec$/) { - $side=""; + if ($$d[4] =~ /^cec$/) { + $side = ""; } - push @values, join( ",", - $$d[4],$node_name,$cageid,$model,$serial,$side, $server,$prof,$fname); + push @values, join(",", + $$d[4], $node_name, $cageid, $model, $serial, $side, $server, $prof, $fname); + #$$d[4],$node_name,$cageid,$model,$serial,$side, $server,$prof,$fname, $ips, $$d[4]); - # $$d[4],$node_name,$cageid,$model,$serial,$side, $server,$prof,$fname, $7); + # $$d[4],$node_name,$cageid,$model,$serial,$side, $server,$prof,$fname, $7); # "fsp",$node_name,$cageid,$model,$serial,$side, $server,$prof,$fname, $7); #"fsp",$fsp,$cageid,$model,$serial,$side,$server,$prof,$fname,$ips ); - - ##################################### - # Enumerate LPARs + ##################################### - $stat = xCAT::FSPUtils::fsp_api_action ($request, $node_name, $d, "get_lpar_info"); - $Rc = @$stat[2]; - $data = @$stat[1]; - + # Enumerate LPARs + ##################################### + $stat = xCAT::FSPUtils::fsp_api_action($request, $node_name, $d, "get_lpar_info"); + $Rc = @$stat[2]; + $data = @$stat[1]; + ################################## # Output error ################################## - if ( $Rc != SUCCESS ) { - #push @output, [$node_name,$data,$Rc]; + if ($Rc != SUCCESS) { + + #push @output, [$node_name,$data,$Rc]; push @values, $data; next; } - my @list = split(/\n/,$data); - #print "list\n"; - #print Dumper(\@list); - foreach my $lpar (@list) { - $lpar =~ /lparname:\s+([\w\-]+),\s+lparid:\s+(\d+),\s+state:/; - my $name = $1; - my $lparid = $2; - my $prof = ""; # No profile for Power 775 - my $server = $fsp; - my $ips = ""; - my $port = ""; -# $name =~ s/\-//g; -# $name =~ tr/A-Z/a-z/; - - ##################################### - # Save LPAR information - ##################################### - push @values, join( ",", - "lpar",$name,$lparid,$model,$serial,$port,$server,$prof,$fsp ); - #"lpar",$name,$lparid,$model,$serial,$port,$server,$prof,$fsp,$ips,"lpar" ); - - } + my @list = split(/\n/, $data); - } - #return(\@values); + #print "list\n"; + #print Dumper(\@list); + foreach my $lpar (@list) { + $lpar =~ /lparname:\s+([\w\-]+),\s+lparid:\s+(\d+),\s+state:/; + my $name = $1; + my $lparid = $2; + my $prof = ""; # No profile for Power 775 + my $server = $fsp; + my $ips = ""; + my $port = ""; + + # $name =~ s/\-//g; + # $name =~ tr/A-Z/a-z/; + + ##################################### + # Save LPAR information + ##################################### + push @values, join(",", +"lpar", $name, $lparid, $model, $serial, $port, $server, $prof, $fsp); + + #"lpar",$name,$lparid,$model,$serial,$port,$server,$prof,$fsp,$ips,"lpar" ); + + } + + } + + #return(\@values); } - - return( \@values ); + + return (\@values); } @@ -235,23 +247,23 @@ sub enumerate { ########################################################################## sub format_output { - my $request = shift; - my $exp = shift; - my $values = shift; - my $opt = $request->{opt}; - my %output = (); - my $hwtype = "fsp"; + my $request = shift; + my $exp = shift; + my $values = shift; + my $opt = $request->{opt}; + my %output = (); + my $hwtype = "fsp"; my $max_length = 0; my $result; - + #print "In format output\n"; - #print Dumper($request); - #print Dumper($exp); - #print Dumper($values); + #print Dumper($request); + #print Dumper($exp); + #print Dumper($values); ########################################### # -w flag for write to xCat database ########################################### - if ( exists( $opt->{w} )) { + if (exists($opt->{w})) { my $server = @$exp[3]; my $uid = @$exp[4]; my $pw = @$exp[5]; @@ -259,22 +271,24 @@ sub format_output { ####################################### # Strip errors for results ####################################### - my @val = grep( !/^#.*: ERROR /, @$values ); + my @val = grep(!/^#.*: ERROR /, @$values); + #xCAT::PPCdb::add_ppc( $hwtype, \@val ); - $values = xCAT::PPCdb::update_lpar( $hwtype, \@val, "write"); + $values = xCAT::PPCdb::update_lpar($hwtype, \@val, "write"); } ########################################### # -u flag for write to xCat database ########################################### - if ( exists( $opt->{u} )) { + if (exists($opt->{u})) { ####################################### # Strip errors for results ####################################### - my @val = grep( !/^#.*: ERROR /, @$values ); + my @val = grep(!/^#.*: ERROR /, @$values); + #$values = xCAT::PPCdb::update_ppc( $hwtype, \@val ); - $values = xCAT::PPCdb::update_lpar( $hwtype, \@val ); - if ( exists( $opt->{x} ) or exists( $opt->{z} )) + $values = xCAT::PPCdb::update_lpar($hwtype, \@val); + if (exists($opt->{x}) or exists($opt->{z})) { unshift @$values, "hmc"; } @@ -283,79 +297,79 @@ sub format_output { ########################################### # -x flag for xml format ########################################### - if ( exists( $opt->{x} )) { - $result .= format_xml( $hwtype, $values ); + if (exists($opt->{x})) { + $result .= format_xml($hwtype, $values); } ########################################### # -z flag for stanza format ########################################### - elsif ( exists( $opt->{z} )) { - $result .= format_stanza( $hwtype, $values ); + elsif (exists($opt->{z})) { + $result .= format_stanza($hwtype, $values); } else { - $result = sprintf( "#Updated following nodes:\n") if ( exists( $opt->{u})); + $result = sprintf("#Updated following nodes:\n") if (exists($opt->{u})); ####################################### # Get longest name for formatting ####################################### - foreach ( @$values ) { + foreach (@$values) { ################################### # Skip error message ################################### - if ( /^#.*: ERROR / ) { + if (/^#.*: ERROR /) { next; } /[^\,]+,([^\,]+),/; - my $length = length( $1 ); + my $length = length($1); $max_length = ($length > $max_length) ? $length : $max_length; } - my $format = sprintf( "%%-%ds", ($max_length + 2 )); + my $format = sprintf("%%-%ds", ($max_length + 2)); $header[1][1] = $format; ####################################### # Add header ####################################### - foreach ( @header ) { - $result .= sprintf( @$_[1], @$_[0] ); + foreach (@header) { + $result .= sprintf(@$_[1], @$_[0]); } ####################################### # Add node information ####################################### my @errmsg; - foreach ( @$values ) { + foreach (@$values) { my @data = split /,/; - my $i = 0; + my $i = 0; ################################### # Save error messages for last ################################### - if ( /^#.*: ERROR / ) { + if (/^#.*: ERROR /) { push @errmsg, $_; next; } - foreach ( @header ) { - my $d = $data[$i++]; + foreach (@header) { + my $d = $data[ $i++ ]; ############################### - # Use IPs instead of - # hardware control address + # Use IPs instead of + # hardware control address ############################### - if ( @$_[0] eq "address" ) { - if ( $data[0] !~ /^(hmc|ivm)$/ ) { - $d = $data[9]; - } + if (@$_[0] eq "address") { + if ($data[0] !~ /^(hmc|ivm)$/) { + $d = $data[9]; + } } - $result .= sprintf( @$_[1], $d ); + $result .= sprintf(@$_[1], $d); } } ####################################### - # Add any error messages + # Add any error messages ####################################### - foreach ( @errmsg ) { - $result.= "\n$_"; + foreach (@errmsg) { + $result .= "\n$_"; } } $output{data} = [$result]; - return( [\%output] ); + return ([ \%output ]); } @@ -367,23 +381,23 @@ sub format_stanza { my $hwtype = shift; my $values = shift; - + my $result; ##################################### - # Skip hardware control point + # Skip hardware control point ##################################### shift(@$values); - foreach ( sort @$values ) { + foreach (sort @$values) { my @data = split /,/; my $type = $data[0]; - my $i = 0; + my $i = 0; ################################# - # Skip error message + # Skip error message ################################# - if ( /^#.*: ERROR / ) { + if (/^#.*: ERROR /) { next; } ################################# @@ -395,35 +409,36 @@ sub format_stanza { # Add each attribute ################################# my $mtm = undef; - foreach ( @attribs ) { - my $d = $data[$i++]; + foreach (@attribs) { + my $d = $data[ $i++ ]; - if ( /^node$/ ) { + if (/^node$/) { next; - } elsif ( /^nodetype$/ ) { + } elsif (/^nodetype$/) { $d = $globalnodetype{$type}; - } elsif ( /^hwtype$/ ) { + } elsif (/^hwtype$/) { $d = $globalhwtype{$type}; - } elsif ( /^groups$/ ) { + } elsif (/^groups$/) { next; + #$d = "$type,all"; - } elsif ( /^mgt$/ ) { + } elsif (/^mgt$/) { $d = $hwtype; - } elsif ( /^cons$/ ) { - if ( $type eq "lpar" ) { + } elsif (/^cons$/) { + if ($type eq "lpar") { $d = $hwtype; } else { $d = undef; } - - } elsif ( /^(mtm|serial)$/ ) { - if ( $type eq "lpar" ) { - $d = undef; + + } elsif (/^(mtm|serial)$/) { + if ($type eq "lpar") { + $d = undef; } elsif (/^mtm$/) { $mtm = $d; - } + } } elsif (/^side$/) { - unless ( $type =~ /^fsp|bpa$/ ) { + unless ($type =~ /^fsp|bpa$/) { next; } } @@ -434,12 +449,12 @@ sub format_stanza { my $tmp_pre = xCAT::data::ibmhwtypes::parse_group($mtm); if (defined($tmp_pre)) { $tmp_groups .= ",$tmp_pre"; - } + } } $result .= "\tgroups=$tmp_groups\n"; } - return( $result ); + return ($result); } @@ -453,60 +468,61 @@ sub format_xml { my $xml; ##################################### - # Skip hardware control point + # Skip hardware control point ##################################### #shift(@$values); ##################################### # Create XML formatted attributes ##################################### - foreach ( @$values ) { + foreach (@$values) { my @data = split /,/; my $type = $data[0]; - my $i = 0; + my $i = 0; ################################# # Skip error message ################################# - if ( /^#.*: ERROR / ) { + if (/^#.*: ERROR /) { next; } ################################# # Initialize hash reference ################################# my $href = { - Node => { } + Node => {} }; ################################# - # Add each attribute + # Add each attribute ################################# my $mtm = undef; - foreach ( @attribs ) { - my $d = $data[$i++]; + foreach (@attribs) { + my $d = $data[ $i++ ]; - if ( /^nodetype$/ ) { + if (/^nodetype$/) { $d = $globalnodetype{$type}; - } elsif ( /^hwtype$/ ) { + } elsif (/^hwtype$/) { $d = $globalhwtype{$type}; - } elsif ( /^groups$/ ) { + } elsif (/^groups$/) { next; + #$d = "$type,all"; - } elsif ( /^mgt$/ ) { + } elsif (/^mgt$/) { $d = $hwtype; - } elsif ( /^cons$/ ) { - if ( $type eq "lpar" ) { + } elsif (/^cons$/) { + if ($type eq "lpar") { $d = $hwtype; } else { $d = undef; } - } elsif ( /^(mtm|serial)$/ ) { - if ( $type eq "lpar" ) { + } elsif (/^(mtm|serial)$/) { + if ($type eq "lpar") { $d = undef; } elsif (/^mtm$/) { $mtm = $d; } } elsif (/^side$/) { - unless ( $type =~ /^fsp|bpa$/ ) { + unless ($type =~ /^fsp|bpa$/) { next; } } @@ -517,20 +533,20 @@ sub format_xml { my $tmp_pre = xCAT::data::ibmhwtypes::parse_group($mtm); if (defined($tmp_pre)) { $tmp_groups .= ",$tmp_pre"; - } + } } - $href->{Node}->{groups}=$tmp_groups; + $href->{Node}->{groups} = $tmp_groups; #print Dumper($href); ################################# # XML encoding ################################# - $xml.= XMLout($href, - NoAttr => 1, - KeyAttr => [], - RootName => undef ); + $xml .= XMLout($href, + NoAttr => 1, + KeyAttr => [], + RootName => undef); } - return( $xml ); + return ($xml); } @@ -541,7 +557,7 @@ sub format_xml { sub rscan { my $request = shift; - my $hash = shift; + my $hash = shift; my $exp = shift; my $args = $request->{arg}; my $server = @$exp[3]; @@ -550,22 +566,23 @@ sub rscan { #print Dumper($request); #print Dumper($hash); #print Dumper($exp); - + ################################### # Enumerate all the hardware ################################### - my $values = enumerate($request, $hash ); + my $values = enumerate($request, $hash); + #print "In rscan:\n"; #print Dumper($values); - if ( ref($values) ne 'ARRAY' ) { - return( [[$server,$values,1]] ); + if (ref($values) ne 'ARRAY') { + return ([ [ $server, $values, 1 ] ]); } ################################### - # Success + # Success ################################### - my $result = format_output( $request, $exp, $values ); + my $result = format_output($request, $exp, $values); unshift @$result, "FORMATDATA6sK4ci"; - return( $result ); + return ($result); } diff --git a/perl-xCAT/xCAT/FSPvitals.pm b/perl-xCAT/xCAT/FSPvitals.pm index 44549fc80..3f31bf31c 100644 --- a/perl-xCAT/xCAT/FSPvitals.pm +++ b/perl-xCAT/xCAT/FSPvitals.pm @@ -8,6 +8,7 @@ use xCAT::FSPpower; use xCAT::Usage; use xCAT::PPCvitals; use xCAT::FSPUtils; + #use Data::Dumper; @@ -27,6 +28,7 @@ sub enumerate_volt { my $d = shift; my $mtms = @$d[2]; + #my $volt = xCAT::PPCcli::lshwinfo( $exp, "frame", $mtms ); #my $Rc = shift(@$volt); my $value = "Not supported by FSPvitals"; @@ -37,16 +39,16 @@ sub enumerate_volt { # return( [RC_ERROR, $value] ); #} #################################### - # Success - return voltages + # Success - return voltages #################################### - return( [SUCCESS, $value] ); + return ([ SUCCESS, $value ]); } ########################################################################## -# Returns cage temperatures +# Returns cage temperatures ########################################################################## sub enumerate_temp { @@ -60,62 +62,63 @@ sub enumerate_temp { ########################################################################## sub enumerate_lcds { - my $request= shift; - my $name= shift; - my $d = shift; - my $action = shift; - my $only_lcds = shift; - my $prefix = "Current LCD:"; + my $request = shift; + my $name = shift; + my $d = shift; + my $action = shift; + my $only_lcds = shift; + my $prefix = "Current LCD:"; my $power_status_prefix = "Current Power Status:"; my $Rc; my @refcode; my $c = 0; - - my $values = xCAT::FSPUtils::fsp_api_action ($request, $name, $d, $action); - $Rc = @$values[2]; + + my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, $action); + $Rc = @$values[2]; my $data = @$values[1]; - my $t_n = @$values[0]; - if( $Rc != 0 ) { - my @names = split(/,/, $t_n); - my @t_data = split(/\n/, $data); + my $t_n = @$values[0]; + if ($Rc != 0) { + my @names = split(/,/, $t_n); + my @t_data = split(/\n/, $data); foreach my $n (@names) { - if( $data =~ /$n/ ) { + if ($data =~ /$n/) { chomp $t_data[$c]; + #push @refcode,[$n, "$prefix $t_data[$c]", $Rc]; - if($t_data[$c] =~ /Error/ ) { - if( $only_lcds == 0) { - push @refcode,[$n, "$power_status_prefix $t_data[$c]", $Rc]; + if ($t_data[$c] =~ /Error/) { + if ($only_lcds == 0) { + push @refcode, [ $n, "$power_status_prefix $t_data[$c]", $Rc ]; } - push @refcode,[$n, "$prefix $t_data[$c]", $Rc]; + push @refcode, [ $n, "$prefix $t_data[$c]", $Rc ]; } else { - if( $only_lcds == 0) { + if ($only_lcds == 0) { # get power status - if( $data =~ /1\|/) { - push @refcode, [$n, "$power_status_prefix on", $Rc] ; + if ($data =~ /1\|/) { + push @refcode, [ $n, "$power_status_prefix on", $Rc ]; } else { - push @refcode, [$n, "$power_status_prefix off", $Rc]; + push @refcode, [ $n, "$power_status_prefix off", $Rc ]; } } # get lcd value - if( $t_data[$c] =~ /1\|(\w[\w\s]*)/) { - push @refcode, [$n, "$prefix $1", $Rc] ; + if ($t_data[$c] =~ /1\|(\w[\w\s]*)/) { + push @refcode, [ $n, "$prefix $1", $Rc ]; } else { - push @refcode, [$n, "$prefix blank", $Rc]; + push @refcode, [ $n, "$prefix blank", $Rc ]; } - } + } $c++; } else { - push @refcode, [$n, "$prefix $data", $Rc]; - if( $only_lcds == 0) { - push @refcode, [$n, "$power_status_prefix $data", $Rc]; + push @refcode, [ $n, "$prefix $data", $Rc ]; + if ($only_lcds == 0) { + push @refcode, [ $n, "$power_status_prefix $data", $Rc ]; } } } } else { - my @array = split(/\n/, $data); - foreach my $a (@array) { + my @array = split(/\n/, $data); + foreach my $a (@array) { if ($a !~ /:\s?[^\s]*\s?[0|1]/) { next; } @@ -125,20 +128,21 @@ sub enumerate_lcds { ## it will not parse the power status if only lcds. # $only_lcds = 0, it will get the power status # $only_lcds = 0, not get the power status. - if( $only_lcds == 0) { + if ($only_lcds == 0) { + # get power status - if( $data =~ /1\|/) { - push @refcode, [$name, "$power_status_prefix on", $Rc] ; + if ($data =~ /1\|/) { + push @refcode, [ $name, "$power_status_prefix on", $Rc ]; } else { - push @refcode, [$name, "$power_status_prefix off", $Rc]; + push @refcode, [ $name, "$power_status_prefix off", $Rc ]; } } # get lcd value - if( $data =~ /1\|(\w[\w\s]*)/) { - push @refcode, [$name, "$prefix $1", $Rc] ; + if ($data =~ /1\|(\w[\w\s]*)/) { + push @refcode, [ $name, "$prefix $1", $Rc ]; } else { - push @refcode, [$name, "$prefix blank", $Rc]; + push @refcode, [ $name, "$prefix blank", $Rc ]; } } } @@ -146,43 +150,44 @@ sub enumerate_lcds { } ########################################################################## -# Returns rack environmentals +# Returns rack environmentals ########################################################################## sub enumerate_rackenv { - my $request= shift; - my $name= shift; - my $d = shift; + my $request = shift; + my $name = shift; + my $d = shift; + #my $mtms = @$d[2]; my $Rc; my $attr; my $value; my %outhash = (); - my $action = "get_rack_env"; - - my $values = xCAT::FSPUtils::fsp_api_action ($request, $name, $d, $action); - $Rc = @$values[2]; + my $action = "get_rack_env"; + + my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, $action); + $Rc = @$values[2]; my $data = @$values[1]; - if ( $Rc != 0 ) { - return( [$Rc,@$values[1]] ); + if ($Rc != 0) { + return ([ $Rc, @$values[1] ]); } - + my $i = 0; - my @t = split(/\n/, $data); - foreach my $td ( @t ) { - my ($attr,$value) = split (/:/, $td); - $outhash{ $attr } = $value; - $outhash{$i}{ $attr } = $value; - $i++; + my @t = split(/\n/, $data); + foreach my $td (@t) { + my ($attr, $value) = split(/:/, $td); + $outhash{$attr} = $value; + $outhash{$i}{$attr} = $value; + $i++; } - - return ( [0,\%outhash] ); + + return ([ 0, \%outhash ]); } ########################################################################## -# Returns voltages/currents +# Returns voltages/currents ########################################################################## sub voltage { @@ -192,7 +197,7 @@ sub voltage { my $hwtype = @$exp[2]; my @result = (); my $text = "Frame Voltages: "; - my @prefix = ( + my @prefix = ( "Frame Voltage (Vab): %sV", "Frame Voltage (Vbc): %sV", "Frame Voltage (Vca): %sV", @@ -201,40 +206,40 @@ sub voltage { "Frame Current (Ic): %sA", ); - while (my ($mtms,$h) = each(%$hash) ) { - while (my ($name,$d) = each(%$h) ) { - - ################################# + while (my ($mtms, $h) = each(%$hash)) { + while (my ($name, $d) = each(%$h)) { + + ################################# # Voltages available in frame - ################################# + ################################# #if ( @$d[4] ne "bpa" && @$d[4] ne "frame") { # push @result, [$name,"$text Only available for BPA/Frame",1]; # next; #} - #my $volt = enumerate_volt( $exp, $d ); - #my $Rc = shift(@$volt); + #my $volt = enumerate_volt( $exp, $d ); + #my $Rc = shift(@$volt); - ################################# - # Output error ################################# - #if ( $Rc != SUCCESS ) { - # push @result, [$name,"$text @$volt[0]",$Rc]; - # next; - #} + # Output error + ################################# + #if ( $Rc != SUCCESS ) { + # push @result, [$name,"$text @$volt[0]",$Rc]; + # next; + #} ################################# # Output value ################################# - #my @values = split /,/, @$volt[0]; - #my $i = 0; + #my @values = split /,/, @$volt[0]; + #my $i = 0; - #foreach ( @prefix ) { - # my $value = sprintf($_, $values[$i++]); - # push @result, [$name,$value,$Rc]; - #} - push @result, [$name,"$text: Not supported in Direct FSP Management", 1]; + #foreach ( @prefix ) { + # my $value = sprintf($_, $values[$i++]); + # push @result, [$name,$value,$Rc]; + #} + push @result, [ $name, "$text: Not supported in Direct FSP Management", 1 ]; } } - return( \@result ); + return (\@result); } @@ -251,69 +256,69 @@ sub temp { my %frame = (); my $prefix = "System Temperature:"; - ######################################### + ######################################### # Group by frame - ######################################### - while (my ($mtms,$h) = each(%$hash) ) { - while (my ($name,$d) = each(%$h) ) { + ######################################### + while (my ($mtms, $h) = each(%$hash)) { + while (my ($name, $d) = each(%$h)) { my $mtms = @$d[5]; - - push @result, [$name,"System Temperature Not support in Direct FSP Management",-1]; + + push @result, [ $name, "System Temperature Not support in Direct FSP Management", -1 ]; ################################# - # No frame commands for IVM - ################################# - if ( $hwtype eq "ivm" ) { - push @result, [$name,"$prefix Not available (No BPA)",0]; + # No frame commands for IVM + ################################# + if ($hwtype eq "ivm") { + push @result, [ $name, "$prefix Not available (No BPA)", 0 ]; next; } - ################################# - # Temperatures not available - ################################# - if ( @$d[4] !~ /^(fsp|lpar|cec)$/ ) { + ################################# + # Temperatures not available + ################################# + if (@$d[4] !~ /^(fsp|lpar|cec)$/) { my $text = "$prefix Only available for CEC/LPAR"; - push @result, [$name,$text,0]; - next; - } - ################################# - # Error - No frame - ################################# - if ( $mtms eq "0" ) { - push @result, [$name,"$prefix Not available (No BPA)",0]; + push @result, [ $name, $text, 0 ]; next; } ################################# - # Save node - ################################# + # Error - No frame + ################################# + if ($mtms eq "0") { + push @result, [ $name, "$prefix Not available (No BPA)", 0 ]; + next; + } + ################################# + # Save node + ################################# $frame{$mtms}{$name} = $d; } } - return( \@result ); + return (\@result); - while (my ($mtms,$h) = each(%frame) ) { - ################################# - # Get temperatures this frame - ################################# - my $temp = enumerate_temp( $exp, $mtms ); - my $Rc = shift(@$temp); + while (my ($mtms, $h) = each(%frame)) { + ################################# + # Get temperatures this frame + ################################# + my $temp = enumerate_temp($exp, $mtms); + my $Rc = shift(@$temp); my $data = @$temp[0]; - while (my ($name,$d) = each(%$h) ) { + while (my ($name, $d) = each(%$h)) { my $mtms = @$d[2]; ############################# # Output error ############################# - if ( $Rc != SUCCESS ) { - push @result, [$name,"$prefix $data",$Rc]; + if ($Rc != SUCCESS) { + push @result, [ $name, "$prefix $data", $Rc ]; next; } ############################# - # CEC not in frame + # CEC not in frame ############################# - if ( !exists( $data->{$mtms} )) { - push @result, [$name,"$prefix CEC '$mtms' not found",1]; + if (!exists($data->{$mtms})) { + push @result, [ $name, "$prefix CEC '$mtms' not found", 1 ]; next; } ############################# @@ -322,10 +327,10 @@ sub temp { my $cel = $data->{$mtms}; my $fah = ($cel * 1.8) + 32; my $value = "$prefix $cel C ($fah F)"; - push @result, [$name,$value,$Rc]; + push @result, [ $name, $value, $Rc ]; } } - return( \@result ); + return (\@result); } ########################################################################## @@ -339,47 +344,48 @@ sub rackenv { my %frame = (); my $prefix = "Rack Environmentals:"; - ######################################### + ######################################### # Group by frame - ######################################### - while (my ($mtms,$h) = each(%$hash) ) { - while (my ($name,$d) = each(%$h) ) { + ######################################### + while (my ($mtms, $h) = each(%$hash)) { + while (my ($name, $d) = each(%$h)) { my $mtms = @$d[5]; - - ################################# - # Temperatures not available - ################################# - if ( @$d[4] !~ /^(bpa|frame)$/ ) { + + ################################# + # Temperatures not available + ################################# + if (@$d[4] !~ /^(bpa|frame)$/) { my $text = "$prefix Only available for BPA/Frame"; - push @result, [$name,$text,0]; + push @result, [ $name, $text, 0 ]; next; } - + my $action = "get_rack_env"; - my $values = xCAT::FSPUtils::fsp_api_action ($request, $name, $d, $action); - my $Rc = @$values[2]; + my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, $action); + my $Rc = @$values[2]; my $data = @$values[1]; - if ( $Rc != 0 ) { - push @result, [$name,$data, $Rc]; + if ($Rc != 0) { + push @result, [ $name, $data, $Rc ]; next; } my @t = split(/\n/, $data); - foreach my $td ( @t ) { - push @result, [$name,$td, $Rc]; - if ( !exists($request->{verbose}) ) { + foreach my $td (@t) { + push @result, [ $name, $td, $Rc ]; + if (!exists($request->{verbose})) { + #if( $td =~ /^Rack altitude in meters/ ) { - if( $td =~ /^BPA-B total output in watts/ ) { + if ($td =~ /^BPA-B total output in watts/) { last; } - } + } } } } - return( \@result ); + return (\@result); } @@ -388,19 +394,19 @@ sub rackenv { ########################################################################## -# Returns system power status (on or off) +# Returns system power status (on or off) # This subroutine will not be used in DFM # And the power status will be returned with lcds ########################################################################## sub power { - return( xCAT::FSPpower::state(@_,"Current Power Status: ",1)); + return (xCAT::FSPpower::state(@_, "Current Power Status: ", 1)); } ########################################################################## -# Returns system state +# Returns system state ########################################################################## sub state { - return( xCAT::FSPpower::state(@_,"System State: ")); + return (xCAT::FSPpower::state(@_, "System State: ")); } ########################################################################### # Returns system LCD status and the power status @@ -416,60 +422,61 @@ sub lcds { my $action; my $type; my $only_lcds; - if( $request->{method} =~ /^lcds$/ ) { + + if ($request->{method} =~ /^lcds$/) { $only_lcds = 1; } - while (my ($mtms,$h) = each(%$hash) ) { - while(my ($name, $d) = each(%$h) ){ - $newids .="$$d[0],"; - $newnames .="$name,"; + while (my ($mtms, $h) = each(%$hash)) { + while (my ($name, $d) = each(%$h)) { + $newids .= "$$d[0],"; + $newnames .= "$name,"; $newd = $d; - if( defined( $type) && $type ne $$d[4] ) { - push @$result, [$name, "$name\'s type is $$d[4]. Please get the lcds for $type and $$d[4] seperately", -1 ]; + if (defined($type) && $type ne $$d[4]) { + push @$result, [ $name, "$name\'s type is $$d[4]. Please get the lcds for $type and $$d[4] seperately", -1 ]; return $result; - } + } $type = $$d[4]; - } + } } - - if( $type eq "lpar" ) { + + if ($type eq "lpar") { $action = "query_lcds"; } elsif ($type eq "blade") { - $action = "pblade_query_lcds"; + $action = "pblade_query_lcds"; } else { $action = "cec_query_lcds"; - } - + } + $$newd[0] = $newids; $result = enumerate_lcds($request, $newnames, $newd, $action, $only_lcds); - + return $result; } sub lcds_orig { - my $request = shift; - my $hash = shift; - my $exp = shift; - my $hwtype = @$exp[2]; - my @result = (); - my $text = "Current LCD:"; - my $prefix = "Current LCD%d: %s"; - my $rcode = undef; + my $request = shift; + my $hash = shift; + my $exp = shift; + my $hwtype = @$exp[2]; + my @result = (); + my $text = "Current LCD:"; + my $prefix = "Current LCD%d: %s"; + my $rcode = undef; my $refcodes = undef; - my $Rc = undef; - my $num = undef; - my $value = undef; + my $Rc = undef; + my $num = undef; + my $value = undef; - while (my ($mtms,$h) = each(%$hash) ) { - while(my ($name, $d) = each(%$h) ){ + while (my ($mtms, $h) = each(%$hash)) { + while (my ($name, $d) = each(%$h)) { $refcodes = enumerate_lcds($request, $name, $d); $num = 1; - foreach $rcode (@$refcodes){ + foreach $rcode (@$refcodes) { $Rc = shift(@$rcode); $value = sprintf($prefix, $num, @$rcode[0]); - push @result, [$name, $value, $Rc]; + push @result, [ $name, $value, $Rc ]; $num = $num + 1; - } + } } } return \@result; @@ -480,14 +487,14 @@ sub lcds_orig { ########################################################################## sub all { - my @values = ( - @{rackenv(@_)}, - @{state(@_)}, - @{lcds(@_)}, - ); + my @values = ( + @{ rackenv(@_) }, + @{ state(@_) }, + @{ lcds(@_) }, + ); - my @sorted_values = sort {$a->[0] cmp $b->[0]} @values; - return( \@sorted_values ); + my @sorted_values = sort { $a->[0] cmp $b->[0] } @values; + return (\@sorted_values); } diff --git a/perl-xCAT/xCAT/FSPvm.pm b/perl-xCAT/xCAT/FSPvm.pm index 16d310bac..c935b488b 100644 --- a/perl-xCAT/xCAT/FSPvm.pm +++ b/perl-xCAT/xCAT/FSPvm.pm @@ -2,7 +2,7 @@ BEGIN { - $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; } @@ -24,8 +24,8 @@ use xCAT::MsgUtils qw(verbose_message); my %method = ( mkvm => \&mkvm_parse_args, lsvm => \&lsvm_parse_args, - rmvm => \&rmvm_parse_args, - chvm => \&chvm_parse_args + rmvm => \&rmvm_parse_args, + chvm => \&chvm_parse_args ); @@ -38,56 +38,58 @@ sub parse_args { my $cmd = $request->{command}; ############################### - # Invoke correct parse_args + # Invoke correct parse_args ############################### - my $result = $method{$cmd}( $request ); - return( $result ); + my $result = $method{$cmd}($request); + return ($result); } ########################################################################## # Parse the chvm command line for options and operands ########################################################################## -my @query_array = (); +my @query_array = (); my %param_list_map = ( - 'vmcpus' => 'part_get_lpar_processing', - 'vmmemory' => 'part_get_lpar_memory', - 'add_physlots' => 'part_get_all_io_bus_info', - 'del_physlots' => 'part_get_all_io_bus_info', - 'add_vmnics' => 'part_get_all_vio_info', + 'vmcpus' => 'part_get_lpar_processing', + 'vmmemory' => 'part_get_lpar_memory', + 'add_physlots' => 'part_get_all_io_bus_info', + 'del_physlots' => 'part_get_all_io_bus_info', + 'add_vmnics' => 'part_get_all_vio_info', 'add_vmstorage' => 'part_get_all_vio_info', - 'del_vadapter' => 'part_get_all_vio_info' + 'del_vadapter' => 'part_get_all_vio_info' ); sub chvm_parse_extra_options { - my $args = shift; - my $opt = shift; + my $args = shift; + my $opt = shift; + # Partition used attributes # my @support_ops = qw(vmcpus vmmemory add_physlots vmothersetting add_vmstorage add_vmnics del_vadapter del_physlots); - if (ref($args) ne 'ARRAY') { - return "$args"; - } + if (ref($args) ne 'ARRAY') { + return "$args"; + } my %tmp_hash = (); - foreach (@$args) { - my ($cmd, $value) = split (/\=/, $_); - if (!defined($value)) { - return "no value specified"; - } - if ($cmd =~ /^lparname$/) { - if ($value ne '*' && $value !~ /^[a-zA-Z0-9-_]+$/) { - return "'$value' invalid"; - } - my $len = rindex $value."\$", "\$"; + foreach (@$args) { + my ($cmd, $value) = split(/\=/, $_); + if (!defined($value)) { + return "no value specified"; + } + if ($cmd =~ /^lparname$/) { + if ($value ne '*' && $value !~ /^[a-zA-Z0-9-_]+$/) { + return "'$value' invalid"; + } + my $len = rindex $value . "\$", "\$"; if ($len > '47') { return "'$value' is too long, max 47 characters"; } -# } elsif ($cmd =~ /^huge_page$/) { -# if ($value !~ /^\d+\/\d+\/\d+$/) { -# return "'$value' invalid"; -# } + + # } elsif ($cmd =~ /^huge_page$/) { + # if ($value !~ /^\d+\/\d+\/\d+$/) { + # return "'$value' invalid"; + # } } elsif (grep(/^$cmd$/, @support_ops)) { if (exists($param_list_map{$cmd})) { - $tmp_hash{$param_list_map{$cmd}} = 1; + $tmp_hash{ $param_list_map{$cmd} } = 1; } if (exists($opt->{p775})) { return "'$cmd' doesn't work for Power 775 machines."; @@ -96,7 +98,7 @@ sub chvm_parse_extra_options { return "Invalid param '$value', only one slot id can be specified"; } } elsif ($cmd eq "del_physlots") { - my @tmp_array = split ",",$value; + my @tmp_array = split ",", $value; foreach (@tmp_array) { unless (/(0x\w{8})/) { return "'$_' is invalid"; @@ -118,7 +120,7 @@ sub chvm_parse_extra_options { return "'$value' is invalid, must be numbers"; } else { my @array = (); - for (1..$value) { + for (1 .. $value) { push @array, 0; } $value = \@array; @@ -143,7 +145,7 @@ sub chvm_parse_extra_options { my ($mmin, $mcur, $mmax); if ($2 eq "G" or $2 eq '') { $mmin = $1 * 1024; - } + } if ($4 eq "G" or $4 eq '') { $mcur = $3 * 1024; } @@ -157,7 +159,7 @@ sub chvm_parse_extra_options { return "'$value' is invalid"; } } elsif ($cmd eq "add_physlots") { - my @tmp_array = split ",",$value; + my @tmp_array = split ",", $value; foreach (@tmp_array) { unless (/(0x\w{8})/) { return "'$_' is invalid"; @@ -180,12 +182,12 @@ sub chvm_parse_extra_options { } } else { - return "'$cmd' not support"; - } - $opt->{$cmd} = $value; - } + return "'$cmd' not support"; + } + $opt->{$cmd} = $value; + } @query_array = keys(%tmp_hash); - return undef; + return undef; } sub chvm_parse_args { @@ -200,243 +202,245 @@ sub chvm_parse_args { ############################################# local *usage = sub { my $usage_string = xCAT::Usage->getUsage($cmd); - return( [ $_[0], $usage_string] ); + return ([ $_[0], $usage_string ]); }; ############################################# # Process command-line arguments ############################################# - if ( !defined( $args )) { + if (!defined($args)) { + #$request->{method} = $cmd; #return( \%opt ); - return ( usage() ); + return (usage()); } ############################################# # Checks case in GetOptions, allows opts # to be grouped (e.g. -vx), and terminates # at the first unrecognized option. ############################################# - @ARGV = @$args; + @ARGV = @$args; $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); + Getopt::Long::Configure("bundling"); - if ( !GetOptions( \%opt, qw(V|verbose p=s i=s m=s r=s p775 vios) )) { - return( usage() ); + if (!GetOptions(\%opt, qw(V|verbose p=s i=s m=s r=s p775 vios))) { + return (usage()); } #################################### # Check for "-" with no option #################################### - if ( grep(/^-$/, @ARGV )) { - return(usage( "Missing option: -" )); + if (grep(/^-$/, @ARGV)) { + return (usage("Missing option: -")); } #################################### - # Configuration file required + # Configuration file required #################################### - #if ( !exists( $opt{p}) ) { - # if ( !defined( $request->{stdin} )) { + #if ( !exists( $opt{p}) ) { + # if ( !defined( $request->{stdin} )) { # return(usage( "Configuration file or attributes not specified" )); # } #} - if (exists($opt{p775})) { - my @cfgdata ; - if ((exists ($opt{p}) || defined($request->{stdin})) && !exists($opt{p775}) ) { - return(usage("Profile just work for Power 775")); - } - if ( exists( $opt{p})) { - - if ( exists( $opt{i} ) || exists( $opt{r}) || exists( $opt{m} ) ) { - return(usage("-p should NOT be used with -i, -r or -m.")); + if (exists($opt{p775})) { + my @cfgdata; + if ((exists($opt{p}) || defined($request->{stdin})) && !exists($opt{p775})) { + return (usage("Profile just work for Power 775")); } - - $opt{p} = $request->{cwd}->[0] . '/' . $opt{p} if ( $opt{p} !~ /^\//); - return ( usage( "Profile $opt{p} cannot be found")) if ( ! -f $opt{p}); - open (PROFFILE, "<$opt{p}") or return ( usage( "Cannot open profile $opt{p}")); - while( ) { - chomp; - if( $_ =~ /(\d+):(\s+)(\d+)\/([\w\.\-]+)\/(\w+)\//) { - push @cfgdata, $_; + if (exists($opt{p})) { + + if (exists($opt{i}) || exists($opt{r}) || exists($opt{m})) { + return (usage("-p should NOT be used with -i, -r or -m.")); + } + + $opt{p} = $request->{cwd}->[0] . '/' . $opt{p} if ($opt{p} !~ /^\//); + return (usage("Profile $opt{p} cannot be found")) if (!-f $opt{p}); + open(PROFFILE, "<$opt{p}") or return (usage("Cannot open profile $opt{p}")); + while () { + chomp; + if ($_ =~ /(\d+):(\s+)(\d+)\/([\w\.\-]+)\/(\w+)\//) { + push @cfgdata, $_; + } else { + return (usage("Invalid line in profile: $_")); + } + } + $opt{profile} = \@cfgdata; + } + + if (defined($request->{stdin})) { + $opt{p} = 1; + if (exists($opt{i}) || exists($opt{r}) || exists($opt{m})) { + return (usage("When the profile is piped into the chvm command, the -i, -r and -m could NOT be used.")); + } + } + + #if (defined( $request->{stdin} )) { + # my $p = $request->{stdin}; + # my @io = split(/\n/, $p) ; + # foreach (@io) { + # chomp; + # if( $_ =~ /(\d+):(\s+)(\d+),([\w\.\-]+),(\w+),/) { + # push @cfgdata, $_; + # } else { + # return ( usage( "Invalid line in profile: $_")); + # } + + # } + + # $opt{profile} = \@cfgdata; + #} + #print "in parse args:\n"; + #print Dumper(\%opt); + + + + if (exists($opt{i})) { + if (!exists($opt{r})) { + return (usage("Option -i should be used with option -r .")); + } + + if ($opt{i} !~ /^([1-9]{1}|[1-9]{1}[0-9]+)$/) { + return (usage("Invalid entry: $opt{i}")); + } + my @id = (1, 5, 9, 13, 17, 21, 25, 29); + my @found = grep(/^$opt{i}$/, @id); + if (@found != 1) { + return (usage("Invalid entry: $opt{i}.\n For Power 775, starting numeric id of the newly created partitions only could be 1, 5, 9, 13, 17, 21, 25 and 29.")); + } + + #if ( !exists($opt{o}) ) { + # return(usage("For Power 775, -i should be used with -o")); + #} + + #my @value = (1, 2, 3, 4, 5); + #if ( grep(/^$opt{i}$/, @id ) != 1) { + # return(usage( "Invalid entry: $opt{o}.\n For Power 775, octant configuration values only could be 1, 2, 3, 4, 5. Please see the details in manpage of mkvm." )); + #} + + + } + + + # pending memory interleaving mode (1- interleaved, 2- non-interleaved) + # non-interleaved mode means the memory cannot be shared across the processors in an octant. + # interleaved means the memory can be shared. + if (exists($opt{m})) { + if ($opt{m} =~ /^interleaved$/ || $opt{m} =~ /^1$/) { + $opt{m} = 1; + } elsif ($opt{m} =~ /^non-interleaved$/ || $opt{m} =~ /^2$/) { + $opt{m} = 2; } else { - return ( usage( "Invalid line in profile: $_")); + return (usage("Invalid entry: $opt{m}.\n For Power 775, the pending memory interleaving mode only could be interleaved(or 1), or non-interleaved(or 2).")); } + } else { + $opt{m} = 1; # interleaved, which is the default } - $opt{profile} = \@cfgdata; - } - if (defined( $request->{stdin} )) { - $opt{p} = 1; - if ( exists( $opt{i} ) || exists( $opt{r} ) || exists( $opt{m} ) ) { - return(usage("When the profile is piped into the chvm command, the -i, -r and -m could NOT be used.")); - } - } - #if (defined( $request->{stdin} )) { - # my $p = $request->{stdin}; - # my @io = split(/\n/, $p) ; - # foreach (@io) { - # chomp; - # if( $_ =~ /(\d+):(\s+)(\d+),([\w\.\-]+),(\w+),/) { - # push @cfgdata, $_; - # } else { - # return ( usage( "Invalid line in profile: $_")); - # } - - # } - - # $opt{profile} = \@cfgdata; - #} - #print "in parse args:\n"; - #print Dumper(\%opt); + my @ratio = (1, 2, 3, 4, 5); + my %octant_cfg = (); + if (exists($opt{r})) { - - - if ( exists( $opt{i} ) ) { - if( !exists( $opt{r} ) ) { - return(usage( "Option -i should be used with option -r ." )); - } - - if ( $opt{i} !~ /^([1-9]{1}|[1-9]{1}[0-9]+)$/ ) { - return(usage( "Invalid entry: $opt{i}" )); - } - my @id = (1, 5, 9, 13, 17, 21, 25, 29); - my @found = grep(/^$opt{i}$/, @id ); - if ( @found != 1) { - return(usage( "Invalid entry: $opt{i}.\n For Power 775, starting numeric id of the newly created partitions only could be 1, 5, 9, 13, 17, 21, 25 and 29." )); - } - - #if ( !exists($opt{o}) ) { - # return(usage("For Power 775, -i should be used with -o")); - #} - - #my @value = (1, 2, 3, 4, 5); - #if ( grep(/^$opt{i}$/, @id ) != 1) { - # return(usage( "Invalid entry: $opt{o}.\n For Power 775, octant configuration values only could be 1, 2, 3, 4, 5. Please see the details in manpage of mkvm." )); - #} - - - } - - - # pending memory interleaving mode (1- interleaved, 2- non-interleaved) - # non-interleaved mode means the memory cannot be shared across the processors in an octant. - # interleaved means the memory can be shared. - if( exists($opt{m}) ) { - if( $opt{m} =~ /^interleaved$/ || $opt{m} =~ /^1$/ ) { - $opt{m} = 1; - } elsif( $opt{m} =~ /^non-interleaved$/ || $opt{m} =~ /^2$/ ) { - $opt{m} = 2; - } else { - return(usage( "Invalid entry: $opt{m}.\n For Power 775, the pending memory interleaving mode only could be interleaved(or 1), or non-interleaved(or 2)." )); - } - } else { - $opt{m} = 1 ;# interleaved, which is the default - } - - my @ratio = (1, 2, 3, 4, 5); - my %octant_cfg = (); - if ( exists( $opt{r} ) ) { - - if( !exists( $opt{i} ) ) { - return(usage( "Option -r should be used with option -i ." )); - } - - my @elems = split(/\,/,$opt{r}); - my $range=""; - while (my $elem = shift @elems) { - if ($elem !~ /\:/) { - return (usage("Invalid argument $elem.\n The input format for 'r' should be like this: \"-r Octant_id:Value\".")) + if (!exists($opt{i})) { + return (usage("Option -r should be used with option -i .")); } - if($elem !~ /\-/) { - my @subelems = split(/\:/, $elem); - if( $subelems[0] < 0 || $subelems[0] > 7) { - return(usage("Octant ID only could be 0 to 7 in the octant configuration value $elem")); - } - if( grep(/^$subelems[1]$/, @ratio ) != 1) { - return(usage( "Invalid octant configuration value in $elem.\n For Power 775, octant configuration values only could be 1, 2, 3, 4, 5. Please see the details in manpage of chvm." )); - } - if( exists($octant_cfg{$subelems[0]}) && $octant_cfg{$subelems[0]} == $subelems[1] ) { - return(usage("In the octant configuration rule, same octant with different octant configuration value. Error!")); - } - $octant_cfg{$subelems[0]} = $subelems[1]; - $range .= "$elem,"; - } else { - my @subelems = split(/\:/, $elem); - my ($left,$right) = split(/\-/, $subelems[0]); - if( $left < 0 || $left > 7 || $right < 0 || $right > 7) { - return(usage("Octant ID only could be 0 to 7 in the octant configuration rule $elem")); - } - if($left == $right) { - if( grep(/^$subelems[1]$/, @ratio ) != 1) { - return(usage( "Invalid octant configuration value in $elem.\n For Power 775, octant configuration values only could be 1, 2, 3, 4, 5. Please see the details in manpage of chvm." )); - } - if( exists($octant_cfg{$left}) || $octant_cfg{$left} == $subelems[1] ) { - return(usage("In the octant configuration rule, same octant with different octant configuration value. Error!")); - } - $octant_cfg{$left} = $subelems[1]; - $range .="$left:$subelems[1]," - } elsif($left < $right ) { - my $i = $left; - for( $i; $i <=$right ; $i ++) { - if( exists($octant_cfg{$i}) || $octant_cfg{$i} == $subelems[1] ) { - return(usage("In the octant configuration rule, same octant with different octant configuration value. Error!")); - } - $octant_cfg{$i} = $subelems[1]; - $range .= "$i:$subelems[1],"; - } - } else { - return(usage("In the octant configuration rule $elem, the left octant ID could NOT be bigger than the right octant ID")); - } - } # end of "if .. else.." - } # end of while - } #end of if - - if ( exists( $opt{i} ) && exists( $opt{r} ) ) { - $opt{octant_cfg}{octant_cfg_value} = (\%octant_cfg); - $opt{octant_cfg}{memory_interleave} = $opt{m}; - - $opt{target} = \@{$request->{node}}; - my $ppctab = xCAT::Table->new( 'ppc'); - unless($ppctab) { - return(usage("Cannot open ppc table")); + my @elems = split(/\,/, $opt{r}); + my $range = ""; + while (my $elem = shift @elems) { + if ($elem !~ /\:/) { + return (usage("Invalid argument $elem.\n The input format for 'r' should be like this: \"-r Octant_id:Value\".")) + } + if ($elem !~ /\-/) { + my @subelems = split(/\:/, $elem); + if ($subelems[0] < 0 || $subelems[0] > 7) { + return (usage("Octant ID only could be 0 to 7 in the octant configuration value $elem")); + } + if (grep(/^$subelems[1]$/, @ratio) != 1) { + return (usage("Invalid octant configuration value in $elem.\n For Power 775, octant configuration values only could be 1, 2, 3, 4, 5. Please see the details in manpage of chvm.")); + } + if (exists($octant_cfg{ $subelems[0] }) && $octant_cfg{ $subelems[0] } == $subelems[1]) { + return (usage("In the octant configuration rule, same octant with different octant configuration value. Error!")); + } + $octant_cfg{ $subelems[0] } = $subelems[1]; + $range .= "$elem,"; + } else { + my @subelems = split(/\:/, $elem); + my ($left, $right) = split(/\-/, $subelems[0]); + if ($left < 0 || $left > 7 || $right < 0 || $right > 7) { + return (usage("Octant ID only could be 0 to 7 in the octant configuration rule $elem")); + } + if ($left == $right) { + if (grep(/^$subelems[1]$/, @ratio) != 1) { + return (usage("Invalid octant configuration value in $elem.\n For Power 775, octant configuration values only could be 1, 2, 3, 4, 5. Please see the details in manpage of chvm.")); + } + if (exists($octant_cfg{$left}) || $octant_cfg{$left} == $subelems[1]) { + return (usage("In the octant configuration rule, same octant with different octant configuration value. Error!")); + } + $octant_cfg{$left} = $subelems[1]; + $range .= "$left:$subelems[1]," + } elsif ($left < $right) { + my $i = $left; + for ($i ; $i <= $right ; $i++) { + if (exists($octant_cfg{$i}) || $octant_cfg{$i} == $subelems[1]) { + return (usage("In the octant configuration rule, same octant with different octant configuration value. Error!")); + } + $octant_cfg{$i} = $subelems[1]; + + $range .= "$i:$subelems[1],"; + } + } else { + return (usage("In the octant configuration rule $elem, the left octant ID could NOT be bigger than the right octant ID")); + } + } # end of "if .. else.." + } # end of while + } #end of if + + if (exists($opt{i}) && exists($opt{r})) { + $opt{octant_cfg}{octant_cfg_value} = (\%octant_cfg); + $opt{octant_cfg}{memory_interleave} = $opt{m}; + + $opt{target} = \@{ $request->{node} }; + my $ppctab = xCAT::Table->new('ppc'); + unless ($ppctab) { + return (usage("Cannot open ppc table")); + } + + my $other_p; + foreach my $node (@{ $request->{node} }) { + my $parent_hash = $ppctab->getNodeAttribs($node, [qw(parent)]); + my $p = $parent_hash->{parent}; + if (!$p) { + return (usage("Not found the parent of $node")); + } + if (!defined($other_p)) { + $other_p = $p; + } + if ($other_p ne $p) { + return (usage("For Power 775, please make sure the noderange are in one CEC ")); + } + } + $request->{node} = [$other_p]; + $request->{noderange} = $other_p; } - - my $other_p; - foreach my $node( @{$request->{node}} ) { - my $parent_hash = $ppctab->getNodeAttribs( $node,[qw(parent)]); - my $p = $parent_hash->{parent}; - if ( !$p) { - return(usage("Not found the parent of $node")); - } - if(! defined( $other_p)) { - $other_p = $p; - } - if ($other_p ne $p) { - return(usage("For Power 775, please make sure the noderange are in one CEC ")); - } - } - $request->{node} = [$other_p]; - $request->{noderange} = $other_p; - } } #################################### # Check for an extra argument #################################### - if ( defined( $ARGV[0] )) { + if (defined($ARGV[0])) { my $check_chvm_arg = chvm_parse_extra_options(\@ARGV, \%opt); if (defined($check_chvm_arg)) { return (usage("Invalid argument: $check_chvm_arg")); - } elsif (($opt{lparname}) && ($opt{lparname} ne '*') && (scalar(@{$request->{node}}) > '1')){ - return(usage( "Invalid argument: must specify '*' for more than one node" )); + } elsif (($opt{lparname}) && ($opt{lparname} ne '*') && (scalar(@{ $request->{node} }) > '1')) { + return (usage("Invalid argument: must specify '*' for more than one node")); } - if ((exists($opt{lparname}) ||exists($opt{huge_page})) && - (exists($opt{p}) || exists($opt{i}) || exists($opt{r}))) { + if ((exists($opt{lparname}) || exists($opt{huge_page})) && + (exists($opt{p}) || exists($opt{i}) || exists($opt{r}))) { return (usage("lparname should NOT be used with -p, -i or -r.")); } } #################################### - # No operands - add command name + # No operands - add command name #################################### $request->{method} = $cmd; - return( \%opt ); + return (\%opt); } @@ -447,44 +451,45 @@ sub mkvm_parse_args { my $request = shift; - my %opt = (); - my $cmd = $request->{command}; - my $args = $request->{arg}; + my %opt = (); + my $cmd = $request->{command}; + my $args = $request->{arg}; ############################################# -# Responds with usage statement + # Responds with usage statement ############################################# local *usage = sub { my $usage_string = xCAT::Usage->getUsage($cmd); - return( [ $_[0], $usage_string] ); + return ([ $_[0], $usage_string ]); }; ############################################# -# Process command-line arguments + # Process command-line arguments ############################################# #if ( !defined( $args )) { # return(usage( "No command specified" )); #} ############################################# -# Checks case in GetOptions, allows opts -# to be grouped (e.g. -vx), and terminates -# at the first unrecognized option. + # Checks case in GetOptions, allows opts + # to be grouped (e.g. -vx), and terminates + # at the first unrecognized option. ############################################# if (defined($args)) { @ARGV = @$args; } $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); -# if ( !GetOptions( \%opt, qw(V|verbose ibautocfg ibacap=s i=s l=s c=s p=s m=s r=s full) )) { -# return( usage() ); -# } - if ( !GetOptions( \%opt, qw(V|verbose full vios) )) { - return( usage() ); + Getopt::Long::Configure("bundling"); + + # if ( !GetOptions( \%opt, qw(V|verbose ibautocfg ibacap=s i=s l=s c=s p=s m=s r=s full) )) { + # return( usage() ); + # } + if (!GetOptions(\%opt, qw(V|verbose full vios))) { + return (usage()); } #################################### -# Check for "-" with no option + # Check for "-" with no option #################################### - if ( grep(/^-$/, @ARGV )) { - return(usage( "Missing option: -" )); + if (grep(/^-$/, @ARGV)) { + return (usage("Missing option: -")); } if (!exists($opt{p775})) { my @unsupport_ops = (); @@ -495,14 +500,14 @@ sub mkvm_parse_args { } my @support_ops = qw(vmcpus vmmemory vmphyslots vmothersetting vmnics vmstorage); if (defined(@ARGV[0]) and defined($opt{full})) { - return(usage("Option 'full' shall be used alone.")); + return (usage("Option 'full' shall be used alone.")); } elsif (defined(@ARGV[0])) { foreach my $arg (@ARGV) { - my ($cmd,$val) = split (/=/,$arg); - if (!grep(/^$cmd$/, @support_ops)) { + my ($cmd, $val) = split(/=/, $arg); + if (!grep(/^$cmd$/, @support_ops)) { push @unsupport_ops, $cmd; } elsif (!defined($val)) { - return(usage("The option $cmd need specific parameters.")); + return (usage("The option $cmd need specific parameters.")); } else { $opt{$cmd} = $val; } @@ -510,147 +515,149 @@ sub mkvm_parse_args { } if (@unsupport_ops) { - my $tmpops = join(",",@unsupport_ops); - return(usage( "The options $tmpops can only work(s) with Power 775 machines.")); + my $tmpops = join(",", @unsupport_ops); + return (usage("The options $tmpops can only work(s) with Power 775 machines.")); } } else { if (exists($opt{full}) or exists($opt{vios})) { - return(usage( "Option 'p775' only works for Power 775 machines.")); + return (usage("Option 'p775' only works for Power 775 machines.")); } #################################### -# Check for non-zero integer + # Check for non-zero integer #################################### - if ( exists( $opt{i} ) ) { - if ( $opt{i} !~ /^([1-9]{1}|[1-9]{1}[0-9]+)$/ ) { - return(usage( "Invalid entry: $opt{i}" )); - } - my @id = (1, 5, 9, 13, 17, 21, 25, 29); - my @found = grep(/^$opt{i}$/, @id ); - if ( @found != 1) { - return(usage( "Invalid entry: $opt{i}.\n For Power 775, starting numeric id of the newly created partitions only could be 1, 5, 9, 13, 17, 21, 25 and 29." )); - } - - #if ( !exists($opt{o}) ) { - # return(usage("For Power 775, -i should be used with -o")); - #} - - #my @value = (1, 2, 3, 4, 5); - #if ( grep(/^$opt{i}$/, @id ) != 1) { - # return(usage( "Invalid entry: $opt{o}.\n For Power 775, octant configuration values only could be 1, 2, 3, 4, 5. Please see the details in manpage of mkvm." )); - #} - - - } - - - # pending memory interleaving mode (1- interleaved, 2- non-interleaved) - # non-interleaved mode means the memory cannot be shared across the processors in an octant. - # interleaved means the memory can be shared. - if( exists($opt{m}) ) { - if( $opt{m} =~ /^interleaved$/ || $opt{m} =~ /^1$/ ) { - $opt{m} = 1; - } elsif( $opt{m} =~ /^non-interleaved$/ || $opt{m} =~ /^2$/ ) { - $opt{m} = 2; - } else { - return(usage( "Invalid entry: $opt{m}.\n For Power 775, the pending memory interleaving mode only could be interleaved(or 1), or non-interleaved(or 2)." )); - } - } elsif (exists($opt{p775})){ - $opt{m} = 2 ;# non-interleaved, which is the default - } - - if ( exists( $opt{r} ) ) { - my @ratio = (1, 2, 3, 4, 5); - my %octant_cfg = (); + if (exists($opt{i})) { + if ($opt{i} !~ /^([1-9]{1}|[1-9]{1}[0-9]+)$/) { + return (usage("Invalid entry: $opt{i}")); + } + my @id = (1, 5, 9, 13, 17, 21, 25, 29); + my @found = grep(/^$opt{i}$/, @id); + if (@found != 1) { + return (usage("Invalid entry: $opt{i}.\n For Power 775, starting numeric id of the newly created partitions only could be 1, 5, 9, 13, 17, 21, 25 and 29.")); + } + + #if ( !exists($opt{o}) ) { + # return(usage("For Power 775, -i should be used with -o")); + #} + + #my @value = (1, 2, 3, 4, 5); + #if ( grep(/^$opt{i}$/, @id ) != 1) { + # return(usage( "Invalid entry: $opt{o}.\n For Power 775, octant configuration values only could be 1, 2, 3, 4, 5. Please see the details in manpage of mkvm." )); + #} - my @elems = split(/\,/,$opt{r}); - my $range=""; - while (my $elem = shift @elems) { - if($elem !~ /\-/) { - my @subelems = split(/\:/, $elem); - if( $subelems[0] < 0 || $subelems[0] > 7) { - return(usage("Octant ID only could be 0 to 7 in the octant configuration value $elem")); - } - if( grep(/^$subelems[1]$/, @ratio ) != 1) { - return(usage( "Invalid octant configuration value in $elem.\n For Power 775, octant configuration values only could be 1, 2, 3, 4, 5. Please see the details in manpage of mkvm." )); - } - if( exists($octant_cfg{$subelems[0]}) && $octant_cfg{$subelems[0]} == $subelems[1] ) { - return(usage("In the octant configuration rule, same octant with different octant configuration value. Error!")); - } - $octant_cfg{$subelems[0]} = $subelems[1]; - $range .= "$elem,"; - } else { - my @subelems = split(/\:/, $elem); - my ($left,$right) = split(/\-/, $subelems[0]); - if( $left < 0 || $left > 7 || $right < 0 || $right > 7) { - return(usage("Octant ID only could be 0 to 7 in the octant configuration rule $elem")); - } - if($left == $right) { - if( grep(/^$subelems[1]$/, @ratio ) != 1) { - return(usage( "Invalid octant configuration value in $elem.\n For Power 775, octant configuration values only could be 1, 2, 3, 4, 5. Please see the details in manpage of mkvm." )); - } - if( exists($octant_cfg{$left}) || $octant_cfg{$left} == $subelems[1] ) { - return(usage("In the octant configuration rule, same octant with different octant configuration value. Error!")); - } - $octant_cfg{$left} = $subelems[1]; - $range .="$left:$subelems[1]," - } elsif($left < $right ) { - my $i = $left; - for( $i; $i <=$right ; $i ++) { - if( exists($octant_cfg{$i}) || $octant_cfg{$i} == $subelems[1] ) { - return(usage("In the octant configuration rule, same octant with different octant configuration value. Error!")); - } - $octant_cfg{$i} = $subelems[1]; - $range .= "$i:$subelems[1],"; - } - } else { - return(usage("In the octant configuration rule $elem, the left octant ID could NOT be bigger than the right octant ID")); - } - } # end of "if .. else.." - } # end of while - $opt{octant_cfg}{octant_cfg_value} = (\%octant_cfg); - $opt{octant_cfg}{memory_interleave} = $opt{m}; - } #end of if - - - if ( (!exists( $opt{i} ) || !exists( $opt{r} )) ) { - return(usage()); - } - $opt{target} = \@{$request->{node}}; - my $ppctab = xCAT::Table->new( 'ppc'); - unless($ppctab) { - return(usage("Cannot open ppc table")); - } - - my $other_p; - foreach my $node( @{$request->{node}} ) { - my $parent_hash = $ppctab->getNodeAttribs( $node,[qw(parent)]); - my $p = $parent_hash->{parent}; - if ( !$p) { - return(usage("Not found the parent of $node")); - } - if (exists($opt{full}) and defined($other_p) and $other_p eq $p){ - return(usage("Only one full partition can be created in one CEC")); } - if(! defined( $other_p)) { - $other_p = $p; - } - if ($other_p ne $p) { - return(usage("For Power 775, please make sure the noderange are in one CEC ")); + + # pending memory interleaving mode (1- interleaved, 2- non-interleaved) + # non-interleaved mode means the memory cannot be shared across the processors in an octant. + # interleaved means the memory can be shared. + if (exists($opt{m})) { + if ($opt{m} =~ /^interleaved$/ || $opt{m} =~ /^1$/) { + $opt{m} = 1; + } elsif ($opt{m} =~ /^non-interleaved$/ || $opt{m} =~ /^2$/) { + $opt{m} = 2; + } else { + return (usage("Invalid entry: $opt{m}.\n For Power 775, the pending memory interleaving mode only could be interleaved(or 1), or non-interleaved(or 2).")); + } + } elsif (exists($opt{p775})) { + $opt{m} = 2; # non-interleaved, which is the default } - } - #if (exists($opt{p775})) { - $request->{node} = [$other_p]; - $request->{noderange} = $other_p; - #} + + if (exists($opt{r})) { + my @ratio = (1, 2, 3, 4, 5); + my %octant_cfg = (); + + my @elems = split(/\,/, $opt{r}); + my $range = ""; + while (my $elem = shift @elems) { + if ($elem !~ /\-/) { + my @subelems = split(/\:/, $elem); + if ($subelems[0] < 0 || $subelems[0] > 7) { + return (usage("Octant ID only could be 0 to 7 in the octant configuration value $elem")); + } + if (grep(/^$subelems[1]$/, @ratio) != 1) { + return (usage("Invalid octant configuration value in $elem.\n For Power 775, octant configuration values only could be 1, 2, 3, 4, 5. Please see the details in manpage of mkvm.")); + } + if (exists($octant_cfg{ $subelems[0] }) && $octant_cfg{ $subelems[0] } == $subelems[1]) { + return (usage("In the octant configuration rule, same octant with different octant configuration value. Error!")); + } + $octant_cfg{ $subelems[0] } = $subelems[1]; + $range .= "$elem,"; + } else { + my @subelems = split(/\:/, $elem); + my ($left, $right) = split(/\-/, $subelems[0]); + if ($left < 0 || $left > 7 || $right < 0 || $right > 7) { + return (usage("Octant ID only could be 0 to 7 in the octant configuration rule $elem")); + } + if ($left == $right) { + if (grep(/^$subelems[1]$/, @ratio) != 1) { + return (usage("Invalid octant configuration value in $elem.\n For Power 775, octant configuration values only could be 1, 2, 3, 4, 5. Please see the details in manpage of mkvm.")); + } + if (exists($octant_cfg{$left}) || $octant_cfg{$left} == $subelems[1]) { + return (usage("In the octant configuration rule, same octant with different octant configuration value. Error!")); + } + $octant_cfg{$left} = $subelems[1]; + $range .= "$left:$subelems[1]," + } elsif ($left < $right) { + my $i = $left; + for ($i ; $i <= $right ; $i++) { + if (exists($octant_cfg{$i}) || $octant_cfg{$i} == $subelems[1]) { + return (usage("In the octant configuration rule, same octant with different octant configuration value. Error!")); + } + $octant_cfg{$i} = $subelems[1]; + + $range .= "$i:$subelems[1],"; + } + } else { + return (usage("In the octant configuration rule $elem, the left octant ID could NOT be bigger than the right octant ID")); + } + } # end of "if .. else.." + } # end of while + $opt{octant_cfg}{octant_cfg_value} = (\%octant_cfg); + $opt{octant_cfg}{memory_interleave} = $opt{m}; + } #end of if + + + if ((!exists($opt{i}) || !exists($opt{r}))) { + return (usage()); + } + $opt{target} = \@{ $request->{node} }; + my $ppctab = xCAT::Table->new('ppc'); + unless ($ppctab) { + return (usage("Cannot open ppc table")); + } + + my $other_p; + foreach my $node (@{ $request->{node} }) { + my $parent_hash = $ppctab->getNodeAttribs($node, [qw(parent)]); + my $p = $parent_hash->{parent}; + if (!$p) { + return (usage("Not found the parent of $node")); + } + if (exists($opt{full}) and defined($other_p) and $other_p eq $p) { + return (usage("Only one full partition can be created in one CEC")); + } + + if (!defined($other_p)) { + $other_p = $p; + } + if ($other_p ne $p) { + return (usage("For Power 775, please make sure the noderange are in one CEC ")); + } + } + + #if (exists($opt{p775})) { + $request->{node} = [$other_p]; + $request->{noderange} = $other_p; + + #} } #################################### - # No operands - add command name + # No operands - add command name #################################### $request->{method} = $cmd; - return( \%opt ); + return (\%opt); } @@ -668,51 +675,51 @@ sub rmvm_parse_args { ############################################# # Responds with usage statement ############################################# - local *usage = sub { + local *usage = sub { my $usage_string = xCAT::Usage->getUsage($cmd); - return( [ $_[0], $usage_string] ); + return ([ $_[0], $usage_string ]); }; ############################################# # Process command-line arguments ############################################# - if ( !defined( $args )) { + if (!defined($args)) { $request->{method} = $cmd; - return( \%opt ); + return (\%opt); } ############################################# # Checks case in GetOptions, allows opts # to be grouped (e.g. -vx), and terminates # at the first unrecognized option. ############################################# - @ARGV = @$args; + @ARGV = @$args; $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); + Getopt::Long::Configure("bundling"); - if ( !GetOptions( \%opt, qw(V|verbose service r p775) )) { - return( usage() ); + if (!GetOptions(\%opt, qw(V|verbose service r p775))) { + return (usage()); } if (exists($opt{p775})) { - return(usage( "rmvm doesn't support for Power 775." )); + return (usage("rmvm doesn't support for Power 775.")); } #################################### # Check for "-" with no option #################################### - if ( grep(/^-$/, @ARGV )) { - return(usage( "Missing option: -" )); + if (grep(/^-$/, @ARGV)) { + return (usage("Missing option: -")); } #################################### # Check for an extra argument #################################### - if ( defined( $ARGV[0] )) { - return(usage( "Invalid Argument: $ARGV[0]" )); + if (defined($ARGV[0])) { + return (usage("Invalid Argument: $ARGV[0]")); } #################################### - # No operands - add command name + # No operands - add command name #################################### - $request->{method} = $cmd; - return( \%opt ); + $request->{method} = $cmd; + return (\%opt); } @@ -731,114 +738,114 @@ sub lsvm_parse_args { ############################################# local *usage = sub { my $usage_string = xCAT::Usage->getUsage($cmd); - return( [ $_[0], $usage_string] ); + return ([ $_[0], $usage_string ]); }; ############################################# # Process command-line arguments ############################################# - if ( !defined( $args )) { + if (!defined($args)) { $request->{method} = $cmd; - return( \%opt ); + return (\%opt); } ############################################# # Checks case in GetOptions, allows opts # to be grouped (e.g. -vx), and terminates # at the first unrecognized option. ############################################# - @ARGV = @$args; + @ARGV = @$args; $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); + Getopt::Long::Configure("bundling"); - if ( !GetOptions( \%opt, qw(V|verbose l|long p775 updatedb) )) { - return( usage() ); + if (!GetOptions(\%opt, qw(V|verbose l|long p775 updatedb))) { + return (usage()); } if (exists($opt{l}) && !exists($opt{p775})) { - return(usage( "option 'l' only works for Power 775")); + return (usage("option 'l' only works for Power 775")); } #################################### # Check for "-" with no option #################################### - if ( grep(/^-$/, @ARGV )) { - return(usage( "Missing option: -" )); + if (grep(/^-$/, @ARGV)) { + return (usage("Missing option: -")); } #################################### # Check for an extra argument #################################### - if ( defined( $ARGV[0] )) { - return(usage( "Invalid Argument: $ARGV[0]" )); + if (defined($ARGV[0])) { + return (usage("Invalid Argument: $ARGV[0]")); } #################################### - # No operands - add command name + # No operands - add command name #################################### - $request->{method} = $cmd; - return( \%opt ); + $request->{method} = $cmd; + return (\%opt); } ########################################################################## -# Changes the configuration of an existing partition +# Changes the configuration of an existing partition ########################################################################## sub modify { - my $request = shift; - my $hash = shift; + my $request = shift; + my $hash = shift; my $usage_string = xCAT::Usage->getUsage($request->{command}); - return modify_by_prof( $request, $hash) if ( exists($request->{opt}->{p775}) and ($request->{opt}->{p} || $request->{stdin})); - return create( $request, $hash) if ( exists($request->{opt}->{p775}) and $request->{opt}->{i}); - return op_extra_cmds ($request, $hash) if (!exists($request->{opt}->{p775})); - return op_extra_cmds ($request, $hash) if ($request->{opt}->{lparname} || $request->{opt}->{huge_page}); - return ([["Error", "Miss argument\n".$usage_string, 1]]); + return modify_by_prof($request, $hash) if (exists($request->{opt}->{p775}) and ($request->{opt}->{p} || $request->{stdin})); + return create($request, $hash) if (exists($request->{opt}->{p775}) and $request->{opt}->{i}); + return op_extra_cmds($request, $hash) if (!exists($request->{opt}->{p775})); + return op_extra_cmds($request, $hash) if ($request->{opt}->{lparname} || $request->{opt}->{huge_page}); + return ([ [ "Error", "Miss argument\n" . $usage_string, 1 ] ]); } sub do_op_extra_cmds { - my $request = shift; - my $hash = shift; - my @values = (); + my $request = shift; + my $hash = shift; + my @values = (); my %lpar_hash = (); while (my ($mtms, $h) = each(%$hash)) { my $memhash; - while (my($name, $d) = each(%$h)) { - foreach my $op (keys %{$request->{opt}}) { - my $action; - my $param = $request->{opt}->{$op}; - if ($op eq "lparname") { - $action = "set_lpar_name"; - } elsif ($op eq "huge_page") { + while (my ($name, $d) = each(%$h)) { + foreach my $op (keys %{ $request->{opt} }) { + my $action; + my $param = $request->{opt}->{$op}; + if ($op eq "lparname") { + $action = "set_lpar_name"; + } elsif ($op eq "huge_page") { my @td = @$d; @td[0] = 0; my $tmphash = &query_cec_info_actions($request, $name, \@td, 1, ["get_huge_page"]); if ($tmphash->{huge_page_avail}) { if ($param > $tmphash->{huge_page_avail}) { - push @values, [$name, "No enough huge pages, only $tmphash->{huge_page_avail} pages available", 0]; + push @values, [ $name, "No enough huge pages, only $tmphash->{huge_page_avail} pages available", 0 ]; $param = $tmphash->{huge_page_avail}; } $param = "1/$param/$param"; } else { - push @values, [$name, "No huge page available to configure", 0]; + push @values, [ $name, "No huge page available to configure", 0 ]; next; } - $action = "set_huge_page"; - } elsif ($op eq "vmcpus") { + $action = "set_huge_page"; + } elsif ($op eq "vmcpus") { $action = "part_set_lpar_pending_proc"; } elsif ($op eq "add_physlots" or $op eq "del_physlots") { $action = "set_io_slot_owner_uber"; } elsif ($op eq "del_vadapter") { $action = "part_clear_vslot_config"; } elsif ($op eq "add_vmnics") { - my @vlans = split /,/,$param; + my @vlans = split /,/, $param; foreach (@vlans) { if (/vlan(\d+)/i) { my $vlanid = $1; - my $mac = lc(xCAT::VMCommon::genMac($name)); + my $mac = lc(xCAT::VMCommon::genMac($name)); if ($mac =~ /(..):(..):(..):(..):(..):(..)/) { - my $tail = hex($6)+$vlanid; - $mac = sprintf("$1$2$3$4$5%02x",$tail); + my $tail = hex($6) + $vlanid; + $mac = sprintf("$1$2$3$4$5%02x", $tail); } - my $value = xCAT::FSPUtils::fsp_api_action($request,$name, $d, "part_set_veth_slot_config",0,"0,$vlanid,$mac"); + my $value = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_veth_slot_config", 0, "0,$vlanid,$mac"); if (@$value[1] && ((@$value[1] =~ /Error/i) && (@$value[2] ne '0'))) { - return ([[$name, @$value[1], '1']]) ; + return ([ [ $name, @$value[1], '1' ] ]); } else { - push @values, [$name, "Success", '0']; - } + push @values, [ $name, "Success", '0' ]; + } } } next; @@ -848,16 +855,16 @@ sub do_op_extra_cmds { my $vios = &find_lpar_id($request, @$d[3], $2); my $r_slotid = $3; if (!defined($vios)) { - return ([[$name, "Cannot find lparid for Server lpar:$1", '1']]); + return ([ [ $name, "Cannot find lparid for Server lpar:$1", '1' ] ]); } $v_info = "$1,$vios,$r_slotid"; } - my $value = xCAT::FSPUtils::fsp_api_action($request,$name, $d, "part_set_vscsi_slot_config",0,$v_info); + my $value = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_vscsi_slot_config", 0, $v_info); if (@$value[1] && ((@$value[1] =~ /Error/i) && (@$value[2] ne '0'))) { - return ([[$name, @$value[1], '1']]) ; + return ([ [ $name, @$value[1], '1' ] ]); } else { - push @values, [$name, "Success", '0']; - } + push @values, [ $name, "Success", '0' ]; + } } next; } elsif ($op eq "vmmemory") { @@ -865,224 +872,235 @@ sub do_op_extra_cmds { @td[0] = 0; $memhash = &query_cec_info_actions($request, $name, \@td, 1, ["part_get_hyp_process_and_mem"]); unless (scalar keys(%$memhash)) { - push @values, [$mtms, "Can not get hypervisor information", 1]; + push @values, [ $mtms, "Can not get hypervisor information", 1 ]; next; } if (!exists($memhash->{run})) { if ($param =~ /(\d+)([G|M]?)\/(\d+)([G|M]?)\/(\d+)([G|M]?)/i) { my $memsize = $memhash->{mem_region_size}; - my $min = $1; + my $min = $1; if ($2 eq "G" or $2 eq '') { $min = $min * 1024; - } - $min = int($min/$memsize); + } + $min = int($min / $memsize); my $cur = $3; if ($4 eq "G" or $4 eq '') { $cur = $cur * 1024; } - $cur = int($cur/$memsize); + $cur = int($cur / $memsize); my $max = $5; if ($6 eq "G" or $6 eq '') { $max = $max * 1024; } - $max = int($max/$memsize); - $request->{opt}->{$op} ="$min/$cur/$max"; - $param = $request->{opt}->{$op}; + $max = int($max / $memsize); + $request->{opt}->{$op} = "$min/$cur/$max"; + $param = $request->{opt}->{$op}; } else { - return([[$name, "The format of param:$param is incorrect.", 1]]); + return ([ [ $name, "The format of param:$param is incorrect.", 1 ] ]); } $memhash->{run} = 1; } - $memhash->{memory} = $param; + $memhash->{memory} = $param; $memhash->{lpar_used_regions} = 0; my $ret = &deal_with_avail_mem($request, $name, $d, $memhash); if (ref($ret) eq "ARRAY") { if (@$ret[2]) { - return ([[@$ret]]); - } else { + return ([ [@$ret] ]); + } else { push @values, $ret; } } - $param = $memhash->{memory}; + $param = $memhash->{memory}; $action = "part_set_lpar_pending_mem"; } elsif ($op eq "bsr") { $action = "set_lpar_bsr"; } elsif ($op eq "vios") { - print __LINE__."=========>op=vios===\n"; + print __LINE__. "=========>op=vios===\n"; next; } else { last; } my $tmp_value = ($param eq '*') ? $name : $param; - xCAT::MsgUtils->verbose_message($request, "$request->{command} $action for node:$name, parm:$tmp_value."); + xCAT::MsgUtils->verbose_message($request, "$request->{command} $action for node:$name, parm:$tmp_value."); my @tmpd = @$d; if ($op eq "del_physlots") { @tmpd[0] = "-1"; } my $value = xCAT::FSPUtils::fsp_api_action($request, $name, \@tmpd, $action, 0, $tmp_value); if (@$value[1] && ((@$value[1] =~ /Error/i) && (@$value[2] ne '0'))) { - return ([[$name, @$value[1], '1']]) ; + return ([ [ $name, @$value[1], '1' ] ]); } else { - push @values, [$name, "Success", '0']; - } + push @values, [ $name, "Success", '0' ]; + } } if (@query_array) { my $rethash = query_cec_info_actions($request, $name, $d, 1, \@query_array); unless (scalar keys(%$rethash)) { - push @values, [$mtms, "Can not get hypervisor information", 1]; + push @values, [ $mtms, "Can not get hypervisor information", 1 ]; next; } - # need to add update db here - $lpar_hash{$name} = $rethash; + + # need to add update db here + $lpar_hash{$name} = $rethash; $lpar_hash{$name}->{parent} = @$d[3]; } } - } + } if (%lpar_hash) { update_vm_db($request, \%lpar_hash); } return \@values; } + sub check_node_info { - my $hash = shift; + my $hash = shift; my $not_lpar = undef; while (my ($mtms, $h) = each(%$hash)) { - while (my($name, $d) = each(%$h)) { + while (my ($name, $d) = each(%$h)) { my $node_type = @$d[4]; if ($node_type !~ /^lpar$/) { $not_lpar = $name; - last; + last; } - } + } } return $not_lpar; } sub op_extra_cmds { - my $request = shift; - my $hash = shift; - my $node = $request->{node}; + my $request = shift; + my $hash = shift; + my $node = $request->{node}; my $lpar_flag = &check_node_info($hash); if (defined($lpar_flag)) { - return ([[$lpar_flag,"Node must be LPAR", 1]]); + return ([ [ $lpar_flag, "Node must be LPAR", 1 ] ]); } return &do_op_extra_cmds($request, $hash); } ########################################################################## -# Changes the configuration of an existing +# Changes the configuration of an existing # partition based on the profile specified ########################################################################## sub modify_by_prof { my $request = shift; my $hash = shift; - my $name = @{$request->{node}}[0]; + my $name = @{ $request->{node} }[0]; my $opt = $request->{opt}; my @values; my $cfgdata = $opt->{profile}; my $profile; - my $cec_name; - my $td; - my %io = (); + my $cec_name; + my $td; + my %io = (); my %lpar_state = (); - my @result; - xCAT::MsgUtils->verbose_message($request, "$request->{command} START."); - if (defined( $request->{stdin} )) { - my $p = $request->{stdin}; - my @io = split(/\n/, $p) ; - foreach (@io) { - chomp; - if( $_ =~ /(\d+):(\s+)(\d+)\/([\w\.\-]+)\/(\w+)\//) { + my @result; + xCAT::MsgUtils->verbose_message($request, "$request->{command} START."); + + if (defined($request->{stdin})) { + my $p = $request->{stdin}; + my @io = split(/\n/, $p); + foreach (@io) { + chomp; + if ($_ =~ /(\d+):(\s+)(\d+)\/([\w\.\-]+)\/(\w+)\//) { push @$cfgdata, $_; - } else { - return (\["Error", "Invalid line in profile: $_", -1]); - } - - } + } else { + return (\[ "Error", "Invalid line in profile: $_", -1 ]); + } + + } } + #print Dumper($cfgdata); - while (my ($cec,$h) = each(%$hash) ) { - while (my ($lpar,$d) = each(%$h) ) { + while (my ($cec, $h) = each(%$hash)) { + while (my ($lpar, $d) = each(%$h)) { $td = $d; + #@$td[4] = "fsp"; - $cec_name = @$d[3]; + $cec_name = @$d[3]; } $td->[4] = "cec"; + #get the current I/O slot information - xCAT::MsgUtils->verbose_message($request, "$request->{command} :get_io_slot_info for node:$cec_name."); + xCAT::MsgUtils->verbose_message($request, "$request->{command} :get_io_slot_info for node:$cec_name."); my $action = "get_io_slot_info"; - my $values = xCAT::FSPUtils::fsp_api_action ($request, $cec_name, $td, $action); + my $values = xCAT::FSPUtils::fsp_api_action($request, $cec_name, $td, $action); my $Rc = $$values[2]; - if ( $Rc != 0 ) { - push @result, [$cec_name, $$values[1], $Rc]; + if ($Rc != 0) { + push @result, [ $cec_name, $$values[1], $Rc ]; return (\@result); } my @data = split(/\n/, $$values[1]); foreach my $v (@data) { my ($lparid, $busid, $location, $drc_index, $owner_type, $owner, $descr) = split(/,/, $v); - $io{$drc_index}{lparid} = $lparid; + $io{$drc_index}{lparid} = $lparid; $io{$drc_index}{owner_type} = $owner_type; - $io{$drc_index}{owner} = $owner; - } - + $io{$drc_index}{owner} = $owner; + } + #get all the nodes state in the same cec - xCAT::MsgUtils->verbose_message($request, "$request->{command} :get all the nodes state for CEC:$cec_name."); + xCAT::MsgUtils->verbose_message($request, "$request->{command} :get all the nodes state for CEC:$cec_name."); $action = "all_lpars_state"; undef($values); - my $values = xCAT::FSPUtils::fsp_state_action ($request, $cec_name, $td, $action); + my $values = xCAT::FSPUtils::fsp_state_action($request, $cec_name, $td, $action); $Rc = shift(@$values); - if ( $Rc != 0 ) { - push @result, [$cec_name, $$values[0], $Rc]; + if ($Rc != 0) { + push @result, [ $cec_name, $$values[0], $Rc ]; return (\@result); } - foreach ( @$values ) { - my ($state,$lparid) = split /,/; - $lpar_state{$lparid} = $state; - } - } - ################################## - # Check if LPAR profile exists - ################################### - while (my ($cec,$h) = each(%$hash) ) { - while (my ($lpar,$d) = each(%$h) ) { - my $id = @$d[0]; - #print Dumper($cfgdata); - my @found = grep(/^$id:/, @$cfgdata ); - #print Dumper(\@found); - my $action = "set_io_slot_owner"; - my $tooltype = 0; - foreach my $f (@found) { - #'1: 514/U78A9.001.0123456-P1-C17/0x21010202/2/1' - my ($bus,$location,$drc_index,@t) = split(/\//, $f); - my $orig_id = $io{$drc_index}{lparid}; - # the current owning lpar and the new owning lpar must be in power off state - if (($lpar_state{$orig_id} ne "Not Activated") || ($lpar_state{$id} ne "Not Activated" )){ - push @result, [$lpar, "For the I/O $location, the current owning lpar(id=$orig_id) of the I/O and the new owning lpar(id=$id) must be in Not Activated state at first. And then run chvm again", -1]; - return ( \@result ); - } - - xCAT::MsgUtils->verbose_message($request, "$request->{command} :set_io_slot_owner io_slot_info:$f,owner:$lpar."); - my $values = xCAT::FSPUtils::fsp_api_action ($request, $lpar, $d, $action, $tooltype, $drc_index); - #my $Rc = shift(@$values); - my $Rc = pop(@$values); - if ( $Rc != 0 ) { - push @result, [$lpar, $$values[1],$Rc]; - next; - } - } - + foreach (@$values) { + my ($state, $lparid) = split /,/; + $lpar_state{$lparid} = $state; } } - xCAT::MsgUtils->verbose_message($request, "$request->{command} END."); - return( \@result ); + ################################## + # Check if LPAR profile exists + ################################### + while (my ($cec, $h) = each(%$hash)) { + while (my ($lpar, $d) = each(%$h)) { + my $id = @$d[0]; + + #print Dumper($cfgdata); + my @found = grep(/^$id:/, @$cfgdata); + + #print Dumper(\@found); + my $action = "set_io_slot_owner"; + my $tooltype = 0; + foreach my $f (@found) { + + #'1: 514/U78A9.001.0123456-P1-C17/0x21010202/2/1' + my ($bus, $location, $drc_index, @t) = split(/\//, $f); + my $orig_id = $io{$drc_index}{lparid}; + + # the current owning lpar and the new owning lpar must be in power off state + if (($lpar_state{$orig_id} ne "Not Activated") || ($lpar_state{$id} ne "Not Activated")) { + push @result, [ $lpar, "For the I/O $location, the current owning lpar(id=$orig_id) of the I/O and the new owning lpar(id=$id) must be in Not Activated state at first. And then run chvm again", -1 ]; + return (\@result); + } + + xCAT::MsgUtils->verbose_message($request, "$request->{command} :set_io_slot_owner io_slot_info:$f,owner:$lpar."); + my $values = xCAT::FSPUtils::fsp_api_action($request, $lpar, $d, $action, $tooltype, $drc_index); + + #my $Rc = shift(@$values); + my $Rc = pop(@$values); + if ($Rc != 0) { + push @result, [ $lpar, $$values[1], $Rc ]; + next; + } + } + + } + } + xCAT::MsgUtils->verbose_message($request, "$request->{command} END."); + return (\@result); } sub enumerate { - my $request = shift; - my $h = shift; + my $request = shift; + my $h = shift; my $mtms = shift; my %outhash = (); my $cec; @@ -1090,180 +1108,186 @@ sub enumerate { my @td; xCAT::MsgUtils->verbose_message($request, "lsvm :enumerate START for mtms:$mtms."); - while (my ($name,$d) = each(%$h) ) { - $cec = @$d[3]; + while (my ($name, $d) = each(%$h)) { + $cec = @$d[3]; $type = @$d[4]; - @td = @$d; + @td = @$d; } - - $td[4]="cec"; + + $td[4] = "cec"; xCAT::MsgUtils->verbose_message($request, "lsvm :enumerate get_io_slot_info for node:$cec."); my $action = "get_io_slot_info"; - my $values = xCAT::FSPUtils::fsp_api_action ($request, $cec, \@td, $action); + my $values = xCAT::FSPUtils::fsp_api_action($request, $cec, \@td, $action); + #my $Rc = shift(@$values); my $Rc = $$values[2]; - if ( $Rc != 0 ) { - $outhash{ 1 } = "The LPARs' I/O slots information could NOT be listed because the cec is in power off state"; + if ($Rc != 0) { + $outhash{1} = "The LPARs' I/O slots information could NOT be listed because the cec is in power off state"; } else { - $outhash{ 0 } = $$values[1]; - } - #my @t; + $outhash{0} = $$values[1]; + } + + #my @t; #foreach my $value ( @$values ) { # my ($lparid, $busid, $slot_location_code, $drc_index,@t ) = split (/,/, $value); # push (@{$outhash{$lparid}}, $value); #} - - if( $type =~ /^(fsp|cec)$/ ) { + + if ($type =~ /^(fsp|cec)$/) { xCAT::MsgUtils->verbose_message($request, "lsvm :enumerate query_octant_cfg for node:$cec."); - $action = "query_octant_cfg"; - my $values = xCAT::FSPUtils::fsp_api_action ($request, $cec, \@td, $action); - my $Rc = pop(@$values); - if ( $Rc != 0 ) { - return( [$Rc,$$values[1]] ); - } + $action = "query_octant_cfg"; + my $values = xCAT::FSPUtils::fsp_api_action($request, $cec, \@td, $action); + my $Rc = pop(@$values); + if ($Rc != 0) { + return ([ $Rc, $$values[1] ]); + } + #$outhash{ $cec } = @$values[0]; - my $data = $$values[1]; - my @value = split(/:/, $data); - my $pendingpumpmode = $value[0]; - my $currentpumpMode = $value[1]; - my $octantcount = $value[2]; - my $j = 3; - my $res = "PendingPumpMode=$pendingpumpmode,CurrentPumpMode=$currentpumpMode,OctantCount=$octantcount:\n"; - for(my $i=0; $i < $octantcount; $i++) { - $res = $res."OctantID=".$value[$j++].",PendingOctCfg=".$value[$j++].",CurrentOctCfg=".$value[$j++].",PendingMemoryInterleaveMode=".$value[$j++].",CurrentMemoryInterleaveMode=".$value[$j++].";\n"; - } - $outhash{ $cec } = $res; - } - + my $data = $$values[1]; + my @value = split(/:/, $data); + my $pendingpumpmode = $value[0]; + my $currentpumpMode = $value[1]; + my $octantcount = $value[2]; + my $j = 3; + my $res = "PendingPumpMode=$pendingpumpmode,CurrentPumpMode=$currentpumpMode,OctantCount=$octantcount:\n"; + for (my $i = 0 ; $i < $octantcount ; $i++) { + $res = $res . "OctantID=" . $value[ $j++ ] . ",PendingOctCfg=" . $value[ $j++ ] . ",CurrentOctCfg=" . $value[ $j++ ] . ",PendingMemoryInterleaveMode=" . $value[ $j++ ] . ",CurrentMemoryInterleaveMode=" . $value[ $j++ ] . ";\n"; + } + $outhash{$cec} = $res; + } + xCAT::MsgUtils->verbose_message($request, "lsvm :enumerate END for mtms:$mtms."); - return( [0,\%outhash] ); + return ([ 0, \%outhash ]); } sub get_cec_attr_info { - my $request = shift; - my $name = shift; - my $attr = shift; - my $op = shift; - my %op_hash = ( - lpar_info => "get_lpar_info", - bsr => "get_cec_bsr", - huge_page => "get_huge_page" - ); - my $action = $op_hash{$op}; - my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $attr, $action); + my $request = shift; + my $name = shift; + my $attr = shift; + my $op = shift; + my %op_hash = ( + lpar_info => "get_lpar_info", + bsr => "get_cec_bsr", + huge_page => "get_huge_page" + ); + my $action = $op_hash{$op}; + my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $attr, $action); if (@$values[1] && ((@$values[1] =~ /Error/i) && @$values[2] ne '0')) { - return ([[$name, @$values[1], '1']]); + return ([ [ $name, @$values[1], '1' ] ]); } return @$values[1]; } sub get_cec_lpar_hugepage { - my $name = shift; - my $huge_info = shift; - my $lparid = shift; - my $lparname = shift; - my @value = split(/\n/, $huge_info); + my $name = shift; + my $huge_info = shift; + my $lparid = shift; + my $lparname = shift; + my @value = split(/\n/, $huge_info); foreach my $v (@value) { - if($v =~ /\s*([^\s]+)\s*:\s*([\d|\/]+)/) { - my $tmp_name = $1; - my $tmp_num = $2; - if($tmp_name =~ /^$lparname$/) { + if ($v =~ /\s*([^\s]+)\s*:\s*([\d|\/]+)/) { + my $tmp_name = $1; + my $tmp_num = $2; + if ($tmp_name =~ /^$lparname$/) { return $tmp_num; } } } - return ([[$name, "can not get huge page info for lpar id $lparid", '1']]); + return ([ [ $name, "can not get huge page info for lpar id $lparid", '1' ] ]); } sub get_cec_lpar_name { - my $name = shift; + my $name = shift; my $lpar_info = shift; - my $lparid = shift; - my @value = split(/\n/, $lpar_info); + my $lparid = shift; + my @value = split(/\n/, $lpar_info); foreach my $v (@value) { - if($v =~ /lparname:\s*([^\,]*),\s*lparid:\s*([\d]+),/) { - if($2 eq $lparid) { + if ($v =~ /lparname:\s*([^\,]*),\s*lparid:\s*([\d]+),/) { + if ($2 eq $lparid) { return $1; } } } - return ([[$name, "can not get lparname for lpar id $lparid", '1']]); + return ([ [ $name, "can not get lparname for lpar id $lparid", '1' ] ]); } + sub get_cec_lpar_bsr { - my $name = shift; + my $name = shift; my $lpar_info = shift; - my $lparid = shift; - my $lparname = shift; - my @value = split(/\n/, $lpar_info); + my $lparid = shift; + my $lparname = shift; + my @value = split(/\n/, $lpar_info); foreach my $v (@value) { - if($v =~ /\s*([^\s]+)\s*:\s*([\d]+)/) { - my $tmp_name = $1; - my $tmp_num = $2; - if($tmp_name =~ /^$lparname$/) { + if ($v =~ /\s*([^\s]+)\s*:\s*([\d]+)/) { + my $tmp_name = $1; + my $tmp_num = $2; + if ($tmp_name =~ /^$lparname$/) { return $tmp_num; } } } - return ([[$name, "can not get BSR info for lpar id $lparid", '1']]); + return ([ [ $name, "can not get BSR info for lpar id $lparid", '1' ] ]); } + sub get_cec_cec_bsr { - my $name = shift; + my $name = shift; my $lpar_info = shift; - my $index = 0; - my @value = split(/\n/, $lpar_info); - my $cec_bsr = ""; + my $index = 0; + my @value = split(/\n/, $lpar_info); + my $cec_bsr = ""; foreach my $v (@value) { - if ($v =~ /(Number of BSR arrays:)\s*(\d+)/i) { - $cec_bsr .= "$1 $2,"; - $index++; - } elsif ($v =~ /(Bytes per BSR array:)\s*(\d+)/i) { - $cec_bsr .= "$1 $2,"; - $index++; - } elsif ($v =~ /(Available BSR array:)\s*(\d+)/i) { - $cec_bsr .= "$1 $2;\n"; - $index++; - } + if ($v =~ /(Number of BSR arrays:)\s*(\d+)/i) { + $cec_bsr .= "$1 $2,"; + $index++; + } elsif ($v =~ /(Bytes per BSR array:)\s*(\d+)/i) { + $cec_bsr .= "$1 $2,"; + $index++; + } elsif ($v =~ /(Available BSR array:)\s*(\d+)/i) { + $cec_bsr .= "$1 $2;\n"; + $index++; + } } if ($index != 3) { - return undef; + return undef; } else { - return $cec_bsr; + return $cec_bsr; } } + sub get_cec_cec_hugepage { - my $name = shift; - my $huge_info = shift; - my $index = 0; - my @value = split (/\n/, $huge_info); - my $cec_hugepage = ""; - foreach my $v (@value) { - if ($v =~ /(Available huge page memory\(in pages\):)\s*(\d+)/i) { - my $tmp = sprintf "%-40s %s;\n", $1, $2; - $cec_hugepage .= $tmp; - $index++; - } elsif($v =~ /(Configurable huge page memory\(in pages\):)\s*(\d+)/i){ - my $tmp = sprintf "%-40s %s;\n", $1, $2; - $cec_hugepage .= $tmp; - $index++; - } elsif($v =~ /(Page Size\(in GB\):)\s*(\d+)/i) { - my $tmp = sprintf "%-40s %s;\n", $1, $2; - $cec_hugepage .= $tmp; - $index++; - } elsif($v =~ /(Maximum huge page memory\(in pages\):)\s*(\d+)/i) { - my $tmp = sprintf "%-40s %s;\n", $1, $2; - $cec_hugepage .= $tmp; - $index++; - } elsif($v =~ /(Requested huge page memory\(in pages\):)\s*(\d+)/i) { - my $tmp = sprintf "%-40s %s;\n", $1, $2; - $cec_hugepage .= $tmp; - $index++; - } - } - if ($index != 5) { - return undef; - } - return $cec_hugepage; + my $name = shift; + my $huge_info = shift; + my $index = 0; + my @value = split(/\n/, $huge_info); + my $cec_hugepage = ""; + foreach my $v (@value) { + if ($v =~ /(Available huge page memory\(in pages\):)\s*(\d+)/i) { + my $tmp = sprintf "%-40s %s;\n", $1, $2; + $cec_hugepage .= $tmp; + $index++; + } elsif ($v =~ /(Configurable huge page memory\(in pages\):)\s*(\d+)/i) { + my $tmp = sprintf "%-40s %s;\n", $1, $2; + $cec_hugepage .= $tmp; + $index++; + } elsif ($v =~ /(Page Size\(in GB\):)\s*(\d+)/i) { + my $tmp = sprintf "%-40s %s;\n", $1, $2; + $cec_hugepage .= $tmp; + $index++; + } elsif ($v =~ /(Maximum huge page memory\(in pages\):)\s*(\d+)/i) { + my $tmp = sprintf "%-40s %s;\n", $1, $2; + $cec_hugepage .= $tmp; + $index++; + } elsif ($v =~ /(Requested huge page memory\(in pages\):)\s*(\d+)/i) { + my $tmp = sprintf "%-40s %s;\n", $1, $2; + $cec_hugepage .= $tmp; + $index++; + } + } + if ($index != 5) { + return undef; + } + return $cec_hugepage; } ########################################################################## @@ -1275,50 +1299,52 @@ sub list { my $args = $request->{opt}; my $values = (); my @value = (); - my $node_name; + my $node_name; my $d; my @result; my $lpar_infos; my $bsr_infos; my $huge_infos; my %lpar_huges = (); - my $l_string = "\n"; - #print Dumper($hash); + my $l_string = "\n"; + + #print Dumper($hash); xCAT::MsgUtils->verbose_message($request, "lsvm START"); - while (my ($mtms,$h) = each(%$hash) ) { - my $info = enumerate($request, $h, $mtms ); - my $Rc = shift(@$info); - my $data = @$info[0]; - - while (($node_name,$d) = each(%$h) ) { - my $cec = @$d[3]; - my $type = @$d[4]; - + while (my ($mtms, $h) = each(%$hash)) { + my $info = enumerate($request, $h, $mtms); + my $Rc = shift(@$info); + my $data = @$info[0]; + + while (($node_name, $d) = each(%$h)) { + my $cec = @$d[3]; + my $type = @$d[4]; + my $id = @$d[0]; - - if ( $Rc != SUCCESS ) { - push @result, [$node_name, $data,$Rc]; - next; - } + + if ($Rc != SUCCESS) { + push @result, [ $node_name, $data, $Rc ]; + next; + } my $values = $data->{0}; - my $msg = $data->{1}; - - # if ( !exists( $data->{$id} )) { - # push @result, [$node_name, "Node not found",1]; - # next; - # } - xCAT::MsgUtils->verbose_message($request, "lsvm :parse io info for node:$node_name."); - if( defined($msg)) { - push @result,[$node_name, $msg, 0]; + my $msg = $data->{1}; + + # if ( !exists( $data->{$id} )) { + # push @result, [$node_name, "Node not found",1]; + # next; + # } + xCAT::MsgUtils->verbose_message($request, "lsvm :parse io info for node:$node_name."); + if (defined($msg)) { + push @result, [ $node_name, $msg, 0 ]; } else { - # get the I/O slot information - if($request->{opt}->{l}) { - if ($type =~ /^(fsp|cec)$/) { - $bsr_infos = get_cec_attr_info($request, $node_name, $d, "bsr"); - if (ref($bsr_infos) eq 'ARRAY') { - return $bsr_infos; - } - $huge_infos = get_cec_attr_info($request,$node_name, $d, "huge_page"); + + # get the I/O slot information + if ($request->{opt}->{l}) { + if ($type =~ /^(fsp|cec)$/) { + $bsr_infos = get_cec_attr_info($request, $node_name, $d, "bsr"); + if (ref($bsr_infos) eq 'ARRAY') { + return $bsr_infos; + } + $huge_infos = get_cec_attr_info($request, $node_name, $d, "huge_page"); if (ref($huge_infos) eq 'ARRAY') { return $huge_infos; } @@ -1327,30 +1353,30 @@ sub list { if (ref($lpar_infos) eq 'ARRAY') { return $lpar_infos; } - } + } my $v; - my @t; + my @t; my @value = split(/\n/, $values); foreach my $v (@value) { - my ($lparid, @t ) = split (/,/, $v); - my $ios = join('/', @t); + my ($lparid, @t) = split(/,/, $v); + my $ios = join('/', @t); if ($request->{opt}->{l}) { my $lparname = get_cec_lpar_name($node_name, $lpar_infos, $lparid); my $hugepage; if ($type =~ /^(fsp|cec)$/) { - my $lpar_bsr = get_cec_lpar_bsr($node_name, $bsr_infos, $lparid, $lparname); - if (ref($lpar_bsr) eq 'ARRAY') { - return $lpar_bsr; - } - $ios .= ": ".$lpar_bsr; + my $lpar_bsr = get_cec_lpar_bsr($node_name, $bsr_infos, $lparid, $lparname); + if (ref($lpar_bsr) eq 'ARRAY') { + return $lpar_bsr; + } + $ios .= ": " . $lpar_bsr; $hugepage = get_cec_lpar_hugepage($node_name, $huge_infos, $lparid, $lparname); if (ref($hugepage) eq 'ARRAY') { return $hugepage; } } else { - if ($lparid ne $id) { - next; - } + if ($lparid ne $id) { + next; + } if (defined($lpar_huges{$lparid})) { $hugepage = $lpar_huges{$lparid}; } else { @@ -1360,48 +1386,48 @@ sub list { } $lpar_huges{$lparid} = $hugepage; } - } - $ios .= ": ".$hugepage; + } + $ios .= ": " . $hugepage; if (ref($lparname) eq 'ARRAY') { return $lparname; } else { $lparname = "$lparname: $lparid"; } - $l_string .= "$lparname: ".$ios."\n"; + $l_string .= "$lparname: " . $ios . "\n"; } else { - if ($type=~/^(fsp|cec)$/) { - push @result,[$lparid, $ios, $Rc]; + if ($type =~ /^(fsp|cec)$/) { + push @result, [ $lparid, $ios, $Rc ]; } else { - if( $lparid eq $id) { - push @result,[$lparid, $ios, $Rc]; + if ($lparid eq $id) { + push @result, [ $lparid, $ios, $Rc ]; } } } - } + } } - - # get the octant configuration value - if ($type=~/^(fsp|cec)$/) { - xCAT::MsgUtils->verbose_message($request, "lsvm :parse octant info for $type:$node_name."); + + # get the octant configuration value + if ($type =~ /^(fsp|cec)$/) { + xCAT::MsgUtils->verbose_message($request, "lsvm :parse octant info for $type:$node_name."); my $value = $data->{$cec}; - if ($request->{opt}->{l}) { - my $cec_bsr = get_cec_cec_bsr($node_name, $bsr_infos); - my $cec_hugepage = get_cec_cec_hugepage($node_name, $huge_infos); - $l_string .= $value.$cec_bsr; - $l_string .= $cec_hugepage; - } else { + if ($request->{opt}->{l}) { + my $cec_bsr = get_cec_cec_bsr($node_name, $bsr_infos); + my $cec_hugepage = get_cec_cec_hugepage($node_name, $huge_infos); + $l_string .= $value . $cec_bsr; + $l_string .= $cec_hugepage; + } else { $l_string = $value; - } - } + } + } if ($l_string =~ /^\n$/) { next; } - push @result, [$node_name, $l_string, $Rc]; - $l_string = "\n"; - } # end of while - }# end of while + push @result, [ $node_name, $l_string, $Rc ]; + $l_string = "\n"; + } # end of while + } # end of while xCAT::MsgUtils->verbose_message($request, "lsvm END."); - return( \@result ); + return (\@result); } @@ -1416,12 +1442,12 @@ sub list_orig { my $args = $request->{opt}; my $values = (); my @value = (); - my $node_name; + my $node_name; my $d; my @result; - while (my ($mtms,$h) = each(%$hash) ) { - while (($node_name,$d) = each(%$h) ) { + while (my ($mtms, $h) = each(%$hash)) { + while (($node_name, $d) = each(%$h)) { my $lparid = @$d[0]; my $mtms = @$d[2]; my $type = @$d[4]; @@ -1430,50 +1456,53 @@ sub list_orig { #################################### # Must be CEC or LPAR #################################### - if ( $type !~ /^(lpar|fsp|cec)$/ ) { - #$values->{$lpar} = [$lpar,"Node must be LPAR or CEC",RC_ERROR]; - return ( [$node_name,"Node must be LPAR or CEC",RC_ERROR]); - #next; + if ($type !~ /^(lpar|fsp|cec)$/) { + + #$values->{$lpar} = [$lpar,"Node must be LPAR or CEC",RC_ERROR]; + return ([ $node_name, "Node must be LPAR or CEC", RC_ERROR ]); + + #next; } - + #################################### # This is a single LPAR #################################### - if ( $type eq "lpar" ) { - #$lpars[0] = "$lpar,$lparid"; + if ($type eq "lpar") { + + #$lpars[0] = "$lpar,$lparid"; } #################################### # This is a CEC #################################### else { - my $values = xCAT::FSPUtils::fsp_api_action($request, $node_name, $d, "query_octant_cfg"); - my $Rc = @$values[2]; - my $data = @$values[1]; - if ( $Rc != SUCCESS ) { - push @result, [$node_name,$data,$Rc]; - } else { - my @value = split(/,/, $data); - my $pendingpumpmode = $value[0]; - my $currentpumpMode = $value[1]; - my $octantcount = $value[2]; - my $j = 3; - my $res = "PendingPumpMode=$pendingpumpmode,CurrentPumpMode=$currentpumpMode,OctantCount=$octantcount:"; - for(my $i=0; $i < $octantcount; $i++) { - $res = $res."OctantID=".$value[$j++].",PendingOctCfg=".$value[$j++].",CurrentOctCfg=".$value[$j++].",PendingMemoryInterleaveMode=".$value[$j++].",CurrentMemoryInterleaveMode".$value[$j++].";"; - } - push @result,[$node_name, $res, $Rc]; - } + my $values = xCAT::FSPUtils::fsp_api_action($request, $node_name, $d, "query_octant_cfg"); + my $Rc = @$values[2]; + my $data = @$values[1]; + if ($Rc != SUCCESS) { + push @result, [ $node_name, $data, $Rc ]; + } else { + my @value = split(/,/, $data); + my $pendingpumpmode = $value[0]; + my $currentpumpMode = $value[1]; + my $octantcount = $value[2]; + my $j = 3; + my $res = "PendingPumpMode=$pendingpumpmode,CurrentPumpMode=$currentpumpMode,OctantCount=$octantcount:"; + for (my $i = 0 ; $i < $octantcount ; $i++) { + $res = $res . "OctantID=" . $value[ $j++ ] . ",PendingOctCfg=" . $value[ $j++ ] . ",CurrentOctCfg=" . $value[ $j++ ] . ",PendingMemoryInterleaveMode=" . $value[ $j++ ] . ",CurrentMemoryInterleaveMode" . $value[ $j++ ] . ";"; + } + push @result, [ $node_name, $res, $Rc ]; + } } - } + } } - return( \@result ); + return (\@result); } ########################################################################## -# Creates/changes logical partitions +# Creates/changes logical partitions ########################################################################## sub create { @@ -1489,128 +1518,133 @@ sub create { my $type; my $profile; my $starting_lpar_id = $opt->{i}; - my $octant_cfg = $opt->{octant_cfg}; - my $node_number =@{$opt->{target}}; - my %node_id = (); - my @nodes = @{$opt->{target}}; - - xCAT::MsgUtils->verbose_message($request, "$request->{command} START."); - #print Dumper($request); + my $octant_cfg = $opt->{octant_cfg}; + my $node_number = @{ $opt->{target} }; + my %node_id = (); + my @nodes = @{ $opt->{target} }; + + xCAT::MsgUtils->verbose_message($request, "$request->{command} START."); + + #print Dumper($request); ##################################### # Get source node information ##################################### - while ( my ($cec,$h) = each(%$hash) ) { - while ( my ($name,$data) = each(%$h) ) { - $d = $data; - $lparid = @$d[0]; - $mtms = @$d[2]; - $type = @$d[4]; + while (my ($cec, $h) = each(%$hash)) { + while (my ($name, $data) = each(%$h)) { + $d = $data; + $lparid = @$d[0]; + $mtms = @$d[2]; + $type = @$d[4]; $cec_name = $name; ##################################### - # Must be LPAR + # Must be LPAR ##################################### - if ( $type !~ /^(fsp|cec)$/ ) { - return( [[$cec_name,"Node's parent must be fsp or CEC",RC_ERROR]] ); + if ($type !~ /^(fsp|cec)$/) { + return ([ [ $cec_name, "Node's parent must be fsp or CEC", RC_ERROR ] ]); } } - - xCAT::MsgUtils->verbose_message($request, "$request->{command} :query_octant_cfg for CEC:$cec_name."); - my $values = xCAT::FSPUtils::fsp_api_action ($request, $cec_name, $d, "query_octant_cfg"); - my $Rc = shift(@$values); - if ( $Rc != 0 ) { - return( [[$cec_name,$$values[0],$Rc]] ); - } - my @v = split(/:/, $$values[0]); - $octant_cfg->{pendingpumpmode} = $v[0]; - - my $number_of_lpars_per_octant; + xCAT::MsgUtils->verbose_message($request, "$request->{command} :query_octant_cfg for CEC:$cec_name."); + my $values = xCAT::FSPUtils::fsp_api_action($request, $cec_name, $d, "query_octant_cfg"); + my $Rc = shift(@$values); + if ($Rc != 0) { + return ([ [ $cec_name, $$values[0], $Rc ] ]); + } + my @v = split(/:/, $$values[0]); + $octant_cfg->{pendingpumpmode} = $v[0]; + + + my $number_of_lpars_per_octant; my $octant_num_needed; my $starting_octant_id; my $octant_conf_value; - my $octant_cfg_value = $octant_cfg->{octant_cfg_value}; + my $octant_cfg_value = $octant_cfg->{octant_cfg_value}; my $new_pending_interleave_mode = $octant_cfg->{memory_interleave}; - - $starting_octant_id = int($starting_lpar_id/4); - my $lparnum_from_octant = 0; + + $starting_octant_id = int($starting_lpar_id / 4); + my $lparnum_from_octant = 0; my $new_pending_pump_mode = $octant_cfg->{pendingpumpmode}; my $parameters; + #my $parameters = "$new_pending_pump_mode:$octant_num_needed"; - my $octant_id = $starting_octant_id ; - my $i = 0; + my $octant_id = $starting_octant_id; + my $i = 0; my $res; - for($i=0; $i < (keys %$octant_cfg_value) ; $i++) { - if(! exists($octant_cfg_value->{$octant_id})) { - $res = "starting LPAR id is $starting_lpar_id, starting octant id is $starting_octant_id. The octants should be used continuously. Octant $octant_id configuration value isn't provided. Wrong plan."; - return ([[$cec_name, $res, -1]]); + for ($i = 0 ; $i < (keys %$octant_cfg_value) ; $i++) { + if (!exists($octant_cfg_value->{$octant_id})) { + $res = "starting LPAR id is $starting_lpar_id, starting octant id is $starting_octant_id. The octants should be used continuously. Octant $octant_id configuration value isn't provided. Wrong plan."; + return ([ [ $cec_name, $res, -1 ] ]); } - my $octant_conf_value = $octant_cfg_value->{$octant_id}; + my $octant_conf_value = $octant_cfg_value->{$octant_id}; + #octant configuration values could be 1,2,3,4,5 ; AS following: # 1 - 1 partition with all cpus and memory of the octant # 2 - 2 partitions with a 50/50 split of cpus and memory # 3 - 3 partitions with a 25/25/50 split of cpus and memory # 4 - 4 partitions with a 25/25/25/25 split of cpus and memory # 5 - 2 partitions with a 25/75 split of cpus and memory - if($octant_conf_value == 1) { - $number_of_lpars_per_octant = 1; - } elsif($octant_conf_value == 2 ) { - $number_of_lpars_per_octant = 2; - } elsif($octant_conf_value == 3 ) { - $number_of_lpars_per_octant = 3; - } elsif($octant_conf_value == 4 ) { - $number_of_lpars_per_octant = 4; - } elsif($octant_conf_value == 5 ) { - $number_of_lpars_per_octant = 2; + if ($octant_conf_value == 1) { + $number_of_lpars_per_octant = 1; + } elsif ($octant_conf_value == 2) { + $number_of_lpars_per_octant = 2; + } elsif ($octant_conf_value == 3) { + $number_of_lpars_per_octant = 3; + } elsif ($octant_conf_value == 4) { + $number_of_lpars_per_octant = 4; + } elsif ($octant_conf_value == 5) { + $number_of_lpars_per_octant = 2; } else { $res = "octant $i, configuration values: $octant_conf_value. Wrong octant configuration values!\n"; - return ([[$cec_name, $res, -1]]); - } + return ([ [ $cec_name, $res, -1 ] ]); + } my $j; - for($j = 1; $j < $number_of_lpars_per_octant+1 ; $j++) { - if(@nodes) { + for ($j = 1 ; $j < $number_of_lpars_per_octant + 1 ; $j++) { + if (@nodes) { my $node = shift(@nodes); $node_id{$node} = $j + $octant_id * 4; } } - $lparnum_from_octant += $number_of_lpars_per_octant; - $octant_num_needed++; - $parameters .= ":$octant_id:$octant_conf_value:$new_pending_interleave_mode"; - $octant_id++; - - } - $parameters = "$new_pending_pump_mode:$octant_num_needed".$parameters; - ##if($node_number != $lparnum_from_octant ) {## - if($node_number > $lparnum_from_octant ) { - $res = "According to the partition split rule and the starting LPAR id, $lparnum_from_octant LPARs will be gotten. But the noderange has $node_number node. Wrong plan.\n"; - return ([[$cec_name, $res, -1]]); + $lparnum_from_octant += $number_of_lpars_per_octant; + $octant_num_needed++; + $parameters .= ":$octant_id:$octant_conf_value:$new_pending_interleave_mode"; + $octant_id++; + + } + $parameters = "$new_pending_pump_mode:$octant_num_needed" . $parameters; + ##if($node_number != $lparnum_from_octant ) {## + if ($node_number > $lparnum_from_octant) { + $res = "According to the partition split rule and the starting LPAR id, $lparnum_from_octant LPARs will be gotten. But the noderange has $node_number node. Wrong plan.\n"; + return ([ [ $cec_name, $res, -1 ] ]); } - - - xCAT::MsgUtils->verbose_message($request, "$request->{command} :set_octant_cfg for CEC:$cec_name,param:$parameters."); - #$values = xCAT::FSPUtils::fsp_api_create_parttion( $starting_lpar_id, $octant_cfg, $node_number, $d, "set_octant_cfg"); - $values = xCAT::FSPUtils::fsp_api_action ($request,$cec_name, $d, "set_octant_cfg", 0, $parameters); - my $Rc = $$values[2]; - my $data = $$values[1]; - if ( $Rc != SUCCESS ) { - push @result, [$cec_name,$data,$Rc]; + + + xCAT::MsgUtils->verbose_message($request, "$request->{command} :set_octant_cfg for CEC:$cec_name,param:$parameters."); + + #$values = xCAT::FSPUtils::fsp_api_create_parttion( $starting_lpar_id, $octant_cfg, $node_number, $d, "set_octant_cfg"); + $values = xCAT::FSPUtils::fsp_api_action($request, $cec_name, $d, "set_octant_cfg", 0, $parameters); + my $Rc = $$values[2]; + my $data = $$values[1]; + if ($Rc != SUCCESS) { + push @result, [ $cec_name, $data, $Rc ]; } else { - foreach my $name ( @{$opt->{target}} ) { - push @result, [$name,"Success", $Rc]; - xCAT::FSPvm::xCATdB("mkvm", $name, "",$node_id{$name}, $d, "fsp", $name ); + foreach my $name (@{ $opt->{target} }) { + push @result, [ $name, "Success", $Rc ]; + xCAT::FSPvm::xCATdB("mkvm", $name, "", $node_id{$name}, $d, "fsp", $name); } - push @result, [$cec_name,"Please reboot the CEC $cec_name before using chvm to assign the I/O slots to the LPARs", "mkvm"]; - #$request->{callback}->({info => ["Please reboot the CEC $cec_name before using chvm to assign the I/O slots to the LPARs"]}); - } - + push @result, [ $cec_name, "Please reboot the CEC $cec_name before using chvm to assign the I/O slots to the LPARs", "mkvm" ]; + + #$request->{callback}->({info => ["Please reboot the CEC $cec_name before using chvm to assign the I/O slots to the LPARs"]}); + } + } - - xCAT::MsgUtils->verbose_message($request, "$request->{command} END."); - return( \@result ); + + xCAT::MsgUtils->verbose_message($request, "$request->{command} END."); + return (\@result); } @@ -1629,85 +1663,85 @@ sub xCATdB { my $parent = shift; ####################################### - # Remove entry + # Remove entry ####################################### - if ( $cmd eq "rmvm" ) { - return( xCAT::PPCdb::rm_ppc( $name )); + if ($cmd eq "rmvm") { + return (xCAT::PPCdb::rm_ppc($name)); } ####################################### - # Change entry + # Change entry ####################################### - elsif ( $cmd eq "chvm" ) { - my $ppctab = xCAT::Table->new( "ppc", -create=>1, -autocommit=>1 ); + elsif ($cmd eq "chvm") { + my $ppctab = xCAT::Table->new("ppc", -create => 1, -autocommit => 1); ################################### # Error opening ppc database ################################### - if ( !defined( $ppctab )) { - return( "Error opening 'ppc' database" ); + if (!defined($ppctab)) { + return ("Error opening 'ppc' database"); } - $ppctab->setNodeAttribs( $name, {pprofile=>$profile} ); + $ppctab->setNodeAttribs($name, { pprofile => $profile }); } ####################################### - # Add entry + # Add entry ####################################### else { - if ( !defined( $profile )) { + if (!defined($profile)) { $profile = $name; } - my ($model,$serial) = split /\*/,@$d[2]; - my $server = @$d[3]; - my $fsp = @$d[2]; - - ################################### + my ($model, $serial) = split /\*/, @$d[2]; + my $server = @$d[3]; + my $fsp = @$d[2]; + + ################################### # Find FSP name in ppc database ################################### - my $tab = xCAT::Table->new( "ppc" ); + my $tab = xCAT::Table->new("ppc"); ################################### # Error opening ppc database ################################### - if ( !defined( $tab )) { - return( "Error opening 'ppc' database" ); + if (!defined($tab)) { + return ("Error opening 'ppc' database"); } ################################### # If there is no parent provided - # this lpar should be the cloned + # this lpar should be the cloned # in the same cec - # Otherwise it should be cloned + # Otherwise it should be cloned # between cecs ################################### - if ( ! $parent) + if (!$parent) { - my ($ent) = $tab->getNodeAttribs($lpar, ['parent'] ); + my ($ent) = $tab->getNodeAttribs($lpar, ['parent']); ################################### - # Node not found + # Node not found ################################### - if ( !defined( $ent )) { - return( "'$lpar' not found in 'ppc' database" ); + if (!defined($ent)) { + return ("'$lpar' not found in 'ppc' database"); } ################################### - # Attributes not found + # Attributes not found ################################### - if ( !exists( $ent->{parent} )) { - return( "'parent' attribute not found in 'ppc' database" ); + if (!exists($ent->{parent})) { + return ("'parent' attribute not found in 'ppc' database"); } $parent = $ent->{parent}; } - my $values = join( ",", - "lpar", - $name, - $lparid, - $model, - $serial, - "", - $server, - $profile, - $parent ); - - return( xCAT::PPCdb::add_ppc( $hwtype, [$values],'','',"FSP" )); + my $values = join(",", + "lpar", + $name, + $lparid, + $model, + $serial, + "", + $server, + $profile, + $parent); + + return (xCAT::PPCdb::add_ppc($hwtype, [$values], '', '', "FSP")); } return undef; } @@ -1719,10 +1753,10 @@ sub xCATdB { my @partition_query_actions = qw(part_get_partition_cap part_get_hyp_process_and_mem part_get_all_io_bus_info get_huge_page get_cec_bsr); sub parse_part_get_info { - my $hash = shift; - my $data = shift; + my $hash = shift; + my $data = shift; my $lparid = shift; - my @array = split /\n/, $data; + my @array = split /\n/, $data; foreach my $line (@array) { chomp($line); if ($line =~ /Num of lpar slots: (\d+)/i) { @@ -1735,30 +1769,34 @@ sub parse_part_get_info { $hash->{mem_region_size} = $1; } elsif ($line =~ /HYP Configurable Processors: (\d+),\s*Avail Processors: (\d+)/i) { $hash->{process_units_config} = $1; - $hash->{process_units_avail} = $2; + $hash->{process_units_avail} = $2; } elsif ($line =~ /Authority Lpar id:(\w+)/i) { $hash->{service_lparid} = $1; } elsif ($line =~ /(\d+),(\d+),[^,]*,(\w+),\w*\(([\w| |-|_|\/]*)\)/) { $hash->{bus}->{$3}->{cur_lparid} = $1; - $hash->{bus}->{$3}->{bus_slot} = $2; - $hash->{bus}->{$3}->{des} = $4; + $hash->{bus}->{$3}->{bus_slot} = $2; + $hash->{bus}->{$3}->{des} = $4; if ($lparid and $lparid eq $1) { - push @{$hash->{lpar_phy_bus}}, $3; + push @{ $hash->{lpar_phy_bus} }, $3; } } elsif ($line =~ /Phy drc_index:(\w+), Port group: (\w+), Phy port id: (\w+)/) { $hash->{phy_drc_group_port}->{$1}->{$2}->{$3} = '1'; - #} elsif ($line =~ /adapter_id=(\w+),lpar_id=([\d|-]+).*port_group=(\d+),phys_port_id=(\d+).*drc_index=(\w+),.*/) { + + #} elsif ($line =~ /adapter_id=(\w+),lpar_id=([\d|-]+).*port_group=(\d+),phys_port_id=(\d+).*drc_index=(\w+),.*/) { if (($2 == -1) && ($4 == 255)) { $hash->{logic_drc_phydrc}->{$3}->{$5} = $1; + #$hash->{logic_drc_phydrc}->{$5}->{$1} = [$2,$3,$4]; } - #} elsif ($line =~ /lpar 0:: Curr Memory::min: 1,cur: (\d+),max:/i) { + + #} elsif ($line =~ /lpar 0:: Curr Memory::min: 1,cur: (\d+),max:/i) { } elsif ($line =~ /HYP Reserved Memory Regions:([-]?)(\d+), Min Required Regions:(\d+)/i) { if ($1 eq '-') { $hash->{lpar0_used_dec} = 1; } - $hash->{lpar0_used_mem} = $2; + $hash->{lpar0_used_mem} = $2; $hash->{phy_min_mem_req} = $3; + #print "===>lpar0_used_mem:$hash->{lpar0_used_mem}.\n"; } elsif ($line =~ /Curr Memory (Min|Req|Max):\s*([\d]*)[^\(]*\((\d+)\s*regions\)/) { if ($1 eq 'Min') { @@ -1766,7 +1804,7 @@ sub parse_part_get_info { } elsif ($1 eq 'Max') { $hash->{lpar_mem_max} = $2; } else { - $hash->{lpar_mem_req} = $2; + $hash->{lpar_mem_req} = $2; $hash->{lpar_used_regions} = $3; } } elsif ($line =~ /Curr Processor (Min|Req|Max):\s*(\d+)/) { @@ -1781,7 +1819,7 @@ sub parse_part_get_info { if ($3 eq '0') { my $lparid = hex($4); my $slotid = hex($5); - push @{$hash->{lpar_vmstorage_client}}, "$lparid:$slotid"; + push @{ $hash->{lpar_vmstorage_client} }, "$lparid:$slotid"; } else { if (exists($hash->{lpar_vmstorage_server})) { $hash->{lpar_vmstorage_server}++; @@ -1790,45 +1828,48 @@ sub parse_part_get_info { } } } elsif ($line =~ /\s*lpar_id=(\d+),type=(vEth),slot=(\d+).*port_vlan_id=(\d+),mac_addr=(\w+)/) { - push @{$hash->{lpar_vmnics}}, "vlan$4"; + push @{ $hash->{lpar_vmnics} }, "vlan$4"; } elsif ($line =~ /Available huge page memory\(in pages\):\s*(\d+)/) { $hash->{huge_page_avail} = $1; } elsif ($line =~ /Available BSR array:\s*(\d+)/) { $hash->{cec_bsr_avail} = $1; } elsif ($line =~ /^\d+\/(\d+)\/\d+$/) { if ($1 ne 0) { - push @{$hash->{lpar_othersetting}}, "hugepage:$1"; + push @{ $hash->{lpar_othersetting} }, "hugepage:$1"; } } elsif ($line =~ /^(\d+)\.$/) { if ($1 ne 0) { - push @{$hash->{lpar_othersetting}}, "bsr:$1"; + push @{ $hash->{lpar_othersetting} }, "bsr:$1"; } } } } sub query_cec_info_actions { - my $request = shift; - my $name = shift; - my $td = shift; - my $usage = shift; + my $request = shift; + my $name = shift; + my $td = shift; + my $usage = shift; my $action_array = shift; - my $lpar_hash = shift; - my $lparid = @$td[0]; + my $lpar_hash = shift; + my $lparid = @$td[0]; my $data; my @array = (); - my %hash = (); + my %hash = (); + if (!defined($action_array) or ref($action_array) ne "ARRAY") { $action_array = \@partition_query_actions; } foreach my $action (@$action_array) { - #$data .= "======> ret info for $action:\n"; + + #$data .= "======> ret info for $action:\n"; my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $td, $action); chomp(@$values[1]); + #if ($action eq "part_get_partition_cap" and (@$values[1] =~ /Error:/i or @$values[2] ne 0)) { if (@$values[1] =~ /Error:/i or @$values[2] ne 0) { - next; #return ([[@$values]]); + next; #return ([[@$values]]); } if (@$values[1] =~ /^$/) { next; @@ -1840,13 +1881,15 @@ sub query_cec_info_actions { if ($usage eq 0 or $usage eq 2) { if ($lparid) { if ($action eq "lpar_lhea_mac") { - my @output = split /\n/,@$values[1]; + my @output = split /\n/, @$values[1]; foreach my $line (@output) { if ($line =~ /adapter_id=\w+,lpar_id=$lparid,type=hea/) { + #$data .= "$line\n"; - push @array, [$name, $line, 0]; + push @array, [ $name, $line, 0 ]; } } + #$data .= "\n"; next; } @@ -1854,64 +1897,69 @@ sub query_cec_info_actions { my @output = split /\n/, @$values[1]; foreach my $line (@output) { if ($line =~ /^$lparid,/) { + #$data .= "$line\n"; - push @array, [$name, $line, 0]; + push @array, [ $name, $line, 0 ]; } } + #$data .= "\n"; next; - } + } if ($action eq "part_get_all_vio_info") { my @output = split /\n/, @$values[1]; - my ($drc_index,$drc_name); + my ($drc_index, $drc_name); foreach my $line (@output) { chomp($line); if ($line =~ /Index:.*drc_index:([^,]*),\s*drc_name:(.*)$/) { $drc_index = $1; - $drc_name = $2; + $drc_name = $2; next; } elsif ($line =~ /\s*lpar_id=(\d+),type=(vSCSI|vSerial),slot=(\d+),attr=(\d+).*remote_lpar_id=(0x\w+),remote_slot_num=(0x\w+)/) { if ($4 eq '0') { - push @array, [$name, "$1,$3,$drc_name,$drc_index,$2 Client(Server_lparid=$5,Server_slotid=$6)", 0]; + push @array, [ $name, "$1,$3,$drc_name,$drc_index,$2 Client(Server_lparid=$5,Server_slotid=$6)", 0 ]; } else { - push @array, [$name, "$1,$3,$drc_name,$drc_index,$2 Server", 0]; + push @array, [ $name, "$1,$3,$drc_name,$drc_index,$2 Server", 0 ]; } } elsif ($line =~ /\s*lpar_id=(\d+),type=(vEth),slot=(\d+).*port_vlan_id=(\d+),mac_addr=(\w+)/) { - push @array, [$name, "$1,$3,$drc_name,$drc_index,$2 (port_vlanid=$4,mac_addr=$5)", 0]; - #} elsif ($line =~ /\s*lpar_id=(\d+),type=(\w+),slot=(\d+)/) { - # push @array, [$name, "$1,$3,$drc_name,$drc_index,$2", 0]; - #} else { + push @array, [ $name, "$1,$3,$drc_name,$drc_index,$2 (port_vlanid=$4,mac_addr=$5)", 0 ]; + + #} elsif ($line =~ /\s*lpar_id=(\d+),type=(\w+),slot=(\d+)/) { + # push @array, [$name, "$1,$3,$drc_name,$drc_index,$2", 0]; + #} else { #print "=====>line:$line\n"; #push @array, [$name, $line, 0]; } $drc_index = ''; - $drc_name = ''; + $drc_name = ''; } next; } } - #$data .= "@$values[1]\n\n"; - push @array, [$name, @$values[1], @$values[2]]; - } + + #$data .= "@$values[1]\n\n"; + push @array, [ $name, @$values[1], @$values[2] ]; + } } if ($usage eq 0 or $usage eq 2) { + #return $data; if ($usage eq 2) { %$lpar_hash = %hash; } return \@array; } else { - return \%hash; + return \%hash; } } sub update_vm_db { - my $request = shift; - my $lpar_hash = shift; - my $vm_hd = xCAT::Table->new('vm'); + my $request = shift; + my $lpar_hash = shift; + my $vm_hd = xCAT::Table->new('vm'); my %name_id_map = (); - my $commit = 0; - foreach (keys (%$lpar_hash)) { + my $commit = 0; + foreach (keys(%$lpar_hash)) { my %db_update = (); my $node_hash = $lpar_hash->{$_}; if (exists($node_hash->{lpar_cpu_min})) { @@ -1924,7 +1972,7 @@ sub update_vm_db { $db_update{storage} = $node_hash->{lpar_vmstorage_server}; } elsif (exists($node_hash->{lpar_vmstorage_client})) { my @tmp_array = (); - foreach (@{$node_hash->{lpar_vmstorage_client}}) { + foreach (@{ $node_hash->{lpar_vmstorage_client} }) { if (/(\d+):(\d+)/) { if (exists($name_id_map{$1})) { push @tmp_array, "$name_id_map{$1}:$2"; @@ -1937,19 +1985,19 @@ sub update_vm_db { } } } - $db_update{storage} = join(",",@tmp_array); + $db_update{storage} = join(",", @tmp_array); } if (exists($node_hash->{lpar_vmnics})) { - $db_update{nics} = join(",",@{$node_hash->{lpar_vmnics}}); + $db_update{nics} = join(",", @{ $node_hash->{lpar_vmnics} }); } if (exists($node_hash->{lpar_phy_bus})) { - $db_update{physlots} = join(",",@{$node_hash->{lpar_phy_bus}}); + $db_update{physlots} = join(",", @{ $node_hash->{lpar_phy_bus} }); } if (exists($node_hash->{lpar_othersetting})) { - $db_update{othersettings} = join(",",@{$node_hash->{lpar_othersetting}}); + $db_update{othersettings} = join(",", @{ $node_hash->{lpar_othersetting} }); } if (%db_update) { - $vm_hd->setNodeAttribs($_,\%db_update); + $vm_hd->setNodeAttribs($_, \%db_update); $commit = 1; } } @@ -1960,49 +2008,53 @@ sub update_vm_db { #my @partition_query_actions = qw(part_get_partition_cap part_get_num_of_lpar_slots part_get_hyp_config_process_and_mem part_get_hyp_avail_process_and_mem part_get_service_authority_lpar_id part_get_shared_processing_resource part_get_all_vio_info lpar_lhea_mac part_get_all_io_bus_info part_get_lpar_processing part_get_lpar_memory get_huge_page get_cec_bsr); sub query_cec_info { - my $request = shift; - my $hash = shift; - my $args = $request->{opt}; - my @td = (); - my @result = (); - my $usage = 0; + my $request = shift; + my $hash = shift; + my $args = $request->{opt}; + my @td = (); + my @result = (); + my $usage = 0; my %lpar_hash = (); + #print Dumper($request); #print Dumper($hash); - while (my ($mtms,$h) = each(%$hash) ) { - while (my ($name, $d) = each (%$h)) { + while (my ($mtms, $h) = each(%$hash)) { + while (my ($name, $d) = each(%$h)) { my %tmp_hash = (); @td = @$d; if (@$d[0] == 0 && @$d[4] !~ /lpar|vios/) { last; } + #my $rethash = query_cec_info_actions($request, $name, $d, 0, ["part_get_lpar_processing","part_get_lpar_memory","part_get_all_vio_info","lpar_lhea_mac","part_get_all_io_bus_info","get_huge_page","get_cec_bsr"]); if ($args->{updatedb}) { $usage = 2; } - my $rethash = query_cec_info_actions($request, $name, $d, $usage, ["part_get_lpar_processing","part_get_lpar_memory","part_get_all_io_bus_info","part_get_all_vio_info","get_huge_page","get_cec_bsr"], \%tmp_hash); - #push @result, [$name, $rethash, 0]; - #push @result, @$rethash; - if (scalar (@$rethash)) { - push @result, @$rethash; - } else { - push @result, [$name, "No information got", -1]; - last; - } - $lpar_hash{$name} = \%tmp_hash; - $lpar_hash{$name}->{parent} = @$d[3]; - } - if (@td[0] == 0) { - my $rethash = query_cec_info_actions($request, @td[3],\@td, $usage); - if (scalar (@$rethash)) { + my $rethash = query_cec_info_actions($request, $name, $d, $usage, [ "part_get_lpar_processing", "part_get_lpar_memory", "part_get_all_io_bus_info", "part_get_all_vio_info", "get_huge_page", "get_cec_bsr" ], \%tmp_hash); + + #push @result, [$name, $rethash, 0]; + #push @result, @$rethash; + if (scalar(@$rethash)) { push @result, @$rethash; } else { - push @result, [@td[3], "No information got", -1]; + push @result, [ $name, "No information got", -1 ]; last; } + $lpar_hash{$name} = \%tmp_hash; + $lpar_hash{$name}->{parent} = @$d[3]; + } + if (@td[0] == 0) { + my $rethash = query_cec_info_actions($request, @td[3], \@td, $usage); + if (scalar(@$rethash)) { + push @result, @$rethash; + } else { + push @result, [ @td[3], "No information got", -1 ]; + last; + } + #push @result, [@td[3], $rethash, 0]; #push @result, @$rethash; - } + } } if ($args->{updatedb} and %lpar_hash) { update_vm_db($request, \%lpar_hash); @@ -2018,21 +2070,21 @@ my @partition_config_actions = qw/part_set_lpar_def_state part_set_lpar_pending_ sub set_lpar_undefined { my $request = shift; - my $name = shift; - my $attr = shift; - my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $attr, "part_set_lpar_def_state", 0, 0x0); + my $name = shift; + my $attr = shift; + my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $attr, "part_set_lpar_def_state", 0, 0x0); if (!@$values[2]) { - return ([$name,"Done",0]); + return ([ $name, "Done", 0 ]); } return $values; } sub clear_service_authority_lpar { my $request = shift; - my $name = shift; - my $attr = shift; + my $name = shift; + my $attr = shift; my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $attr, "part_get_service_authority_lpar_id"); - my @array = split /\n/, @$values[1]; + my @array = split /\n/, @$values[1]; my $service_lparid = undef; foreach my $line (@array) { if ($line =~ /Authority Lpar id:([-|\d]+)./i) { @@ -2046,37 +2098,38 @@ sub clear_service_authority_lpar { sub remove { my $request = shift; - my $hash = shift; - my @result = (); - while (my ($mtms, $h) = each (%$hash)) { - while (my ($name, $d) = each (%$h)) { - if (@$d[4] ne "lpar") { - push @result, [$name, "Node must be LPAR", 1]; - last; - } - &clear_service_authority_lpar($request, $name, $d); - my $values = &set_lpar_undefined($request, $name, $d); - push @result, $values; + my $hash = shift; + my @result = (); + while (my ($mtms, $h) = each(%$hash)) { + while (my ($name, $d) = each(%$h)) { + if (@$d[4] ne "lpar") { + push @result, [ $name, "Node must be LPAR", 1 ]; + last; + } + &clear_service_authority_lpar($request, $name, $d); + my $values = &set_lpar_undefined($request, $name, $d); + push @result, $values; } } return \@result; } sub deal_with_avail_mem { - my $request = shift; - my $name = shift; - my $d = shift; + my $request = shift; + my $name = shift; + my $d = shift; my $lparhash = shift; my $max_required_regions; if ($lparhash->{memory} =~ /(\d+)\/(\d+)\/(\d+)/) { - my ($min,$cur,$max); + my ($min, $cur, $max); my $used_regions = 0; - my $cur_avail = 0; + my $cur_avail = 0; $min = $1; $cur = $2; $max = $3; my %tmphash; my $values; + if (exists($lparhash->{lpar_used_regions})) { $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_get_lpar_memory"); &parse_part_get_info(\%tmphash, @$values[1]); @@ -2090,26 +2143,27 @@ sub deal_with_avail_mem { if ($min < $tmphash{phy_min_mem_req}) { $min = $tmphash{phy_min_mem_req}; } - + if (exists($lparhash->{lpar0_used_dec})) { - $cur_avail = $lparhash->{hyp_avail_mem} + $used_regions + $tmphash{lpar0_used_mem}; + $cur_avail = $lparhash->{hyp_avail_mem} + $used_regions + $tmphash{lpar0_used_mem}; } else { $cur_avail = $lparhash->{hyp_avail_mem} + $used_regions - $tmphash{lpar0_used_mem}; } - #xCAT::MsgUtils->verbose_message($request, "====****====used:$used_regions,avail:$cur_avail,($min:$cur:$max)."); + + #xCAT::MsgUtils->verbose_message($request, "====****====used:$used_regions,avail:$cur_avail,($min:$cur:$max)."); if ($cur_avail < $min) { my $cur_mem_in_G = $lparhash->{hyp_avail_mem} * $lparhash->{mem_region_size} * 1.0 / 1024; - return([$name, "Parse reserverd regions failed, no enough memory, available:$cur_mem_in_G GB.", 1]); - } + return ([ $name, "Parse reserverd regions failed, no enough memory, available:$cur_mem_in_G GB.", 1 ]); + } if (($cur_avail > 0) and ($cur > $cur_avail)) { my $cur_avail_in_G = $cur_avail * $lparhash->{mem_region_size} * 1.0 / 1024; $lparhash->{memory} = "$min/$cur_avail/$max"; - unless ($lparhash->{full_par}) { - return([$name, "Available memory is less than required, allocate $cur_avail_in_G GB.", 0]); - } + unless ($lparhash->{full_par}) { + return ([ $name, "Available memory is less than required, allocate $cur_avail_in_G GB.", 0 ]); + } } } else { - return ([$name, "Failed to get hypervisor reserved memory regions.", 1]); + return ([ $name, "Failed to get hypervisor reserved memory regions.", 1 ]); } } return 0; @@ -2117,9 +2171,9 @@ sub deal_with_avail_mem { sub find_lpar_id { my $request = shift; - my $parent = shift; - my $name = shift; - my %mapping = %{$request->{ppc}->{$parent}->{mapping}}; + my $parent = shift; + my $name = shift; + my %mapping = %{ $request->{ppc}->{$parent}->{mapping} }; if (exists($mapping{$name})) { return $mapping{$name}; } @@ -2128,9 +2182,9 @@ sub find_lpar_id { sub find_lpar_name { my $request = shift; - my $parent = shift; - my $id = shift; - my %mapping = %{$request->{ppc}->{$parent}->{mapping}}; + my $parent = shift; + my $id = shift; + my %mapping = %{ $request->{ppc}->{$parent}->{mapping} }; foreach (keys %mapping) { if ($mapping{$_} eq $id) { return $_; @@ -2140,11 +2194,11 @@ sub find_lpar_name { } sub create_lpar { - my $request = shift; - my $name = shift; - my $d = shift; + my $request = shift; + my $name = shift; + my $d = shift; my $lparhash = shift; - my @ret = (); + my @ret = (); my $values; if (exists($request->{opt}->{vios})) { $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_lpar_def_state", 0, 0x03); @@ -2152,72 +2206,78 @@ sub create_lpar { $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_lpar_def_state", 0, 0x01); } if (@$values[2] ne 0) { - return ([[$name, @$values[1], @$values[0]]]); + return ([ [ $name, @$values[1], @$values[0] ] ]); } $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "set_lpar_name", 0, $name); if (@$values[2] ne 0) { &set_lpar_undefined($request, $name, $d); - return ([[$name, @$values[1], @$values[0]]]); + return ([ [ $name, @$values[1], @$values[0] ] ]); } xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_lpar_shared_pool_util_auth"); xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_lpar_group_id"); xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_lpar_avail_priority"); + #print "======>physlots:$lparhash->{physlots}.\n"; if (exists($lparhash->{physlots})) { - $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "set_io_slot_owner_uber", 0, $lparhash->{physlots}); - #$values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "set_io_slot_owner", 0, join(",",@phy_io_array)); + $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "set_io_slot_owner_uber", 0, $lparhash->{physlots}); + + #$values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "set_io_slot_owner", 0, join(",",@phy_io_array)); if (@$values[2] ne 0) { &set_lpar_undefined($request, $name, $d); - return ([[$name, @$values[1], @$values[2]]]); + return ([ [ $name, @$values[1], @$values[2] ] ]); } } if (exists($lparhash->{nics})) { - my @vlans = split /,/,$lparhash->{nics}; + my @vlans = split /,/, $lparhash->{nics}; foreach (@vlans) { if (/vlan(\d+)/i) { my $vlanid = $1; - my $mac = lc(xCAT::VMCommon::genMac($name)); + my $mac = lc(xCAT::VMCommon::genMac($name)); if ($mac =~ /(..):(..):(..):(..):(..):(..)/) { - my $tail = hex($6)+$vlanid; - $mac = sprintf("$1$2$3$4$5%02x",$tail); + my $tail = hex($6) + $vlanid; + $mac = sprintf("$1$2$3$4$5%02x", $tail); } - $values = xCAT::FSPUtils::fsp_api_action($request,$name, $d, "part_set_veth_slot_config",0,"0,$vlanid,$mac"); + $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_veth_slot_config", 0, "0,$vlanid,$mac"); if (@$values[2] ne 0) { &set_lpar_undefined($request, $name, $d); - return ([[$name, @$values[1], @$values[2]]]); + return ([ [ $name, @$values[1], @$values[2] ] ]); } } } } if (exists($lparhash->{storage})) { - foreach my $v_info (@{$lparhash->{storage}}) { - $values = xCAT::FSPUtils::fsp_api_action($request,$name, $d, "part_set_vscsi_slot_config",0,$v_info); + foreach my $v_info (@{ $lparhash->{storage} }) { + $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_vscsi_slot_config", 0, $v_info); if (@$values[2] ne 0) { &set_lpar_undefined($request, $name, $d); - return ([[$name, @$values[1], @$values[2]]]); + return ([ [ $name, @$values[1], @$values[2] ] ]); } } } + # ====== ====== # if (exists($lparhash->{phy_hea})) { my $phy_hash = $lparhash->{phy_hea}; foreach my $phy_drc (keys %$phy_hash) { + #print "======> set_lhea_assign_info: drc_index:$phy_drc.\n"; xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_lhea_assign_info", 0, $phy_drc); my $group_hash = $phy_hash->{$phy_drc}; foreach my $group_id (keys %$group_hash) { - my @lhea_drc = (keys %{$lparhash->{logic_drc_phydrc}->{$group_id}}); - foreach my $phy_port_id (keys %{$group_hash->{$group_id}}) { + my @lhea_drc = (keys %{ $lparhash->{logic_drc_phydrc}->{$group_id} }); + foreach my $phy_port_id (keys %{ $group_hash->{$group_id} }) { my $tmp_param = "$phy_drc,$group_id,$phy_port_id"; + #print "======> set_phea_port_info: $tmp_param.\n"; xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_phea_port_info", 0, $tmp_param); - my $tmp_lhea_param = $lhea_drc[$phy_port_id].",$phy_port_id"; + my $tmp_lhea_param = $lhea_drc[$phy_port_id] . ",$phy_port_id"; + #print "======> set_lhea_port_info: $tmp_lhea_param.\n"; xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_lhea_port_info", 0, $tmp_lhea_param); } - delete ($lparhash->{logic_drc_phydrc}->{$group_id}->{$lhea_drc[0]}); - delete ($lparhash->{logic_drc_phydrc}->{$group_id}->{$lhea_drc[1]}); - } + delete($lparhash->{logic_drc_phydrc}->{$group_id}->{ $lhea_drc[0] }); + delete($lparhash->{logic_drc_phydrc}->{$group_id}->{ $lhea_drc[1] }); + } } } @@ -2225,14 +2285,14 @@ sub create_lpar { $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_lpar_pending_proc", 0, $lparhash->{cpus}); if (@$values[2] ne 0) { &set_lpar_undefined($request, $name, $d); - return ([[$name, @$values[1], @$values[2]]]); + return ([ [ $name, @$values[1], @$values[2] ] ]); } - $values = &deal_with_avail_mem($request, $name, $d,$lparhash); + $values = &deal_with_avail_mem($request, $name, $d, $lparhash); if (ref($values) eq "ARRAY") { if (@$values[2]) { &set_lpar_undefined($request, $name, $d); - return ([[@$values]]); - } else { + return ([ [@$values] ]); + } else { push @ret, $values; } } @@ -2241,64 +2301,69 @@ sub create_lpar { $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_lpar_pending_mem", 0, $lparhash->{memory}); if (@$values[2] ne 0) { &set_lpar_undefined($request, $name, $d); - return ([[$name, @$values[1], @$values[2]]]); + return ([ [ $name, @$values[1], @$values[2] ] ]); } - - xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_lpar_comp_modes"); + + xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_lpar_comp_modes"); + #print "======>memory:$lparhash->{huge_page}.\n"; xCAT::FSPUtils::fsp_api_action($request, $name, $d, "set_huge_page", 0, $lparhash->{huge_page}); + #print "======>bsr:$lparhash->{bsr_num}.\n"; xCAT::FSPUtils::fsp_api_action($request, $name, $d, "set_lpar_bsr", 0, $lparhash->{bsr_num}); xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_partition_placement"); - if (exists($request->{opt}->{vios})) { + if (exists($request->{opt}->{vios})) { $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_lpar_def_state", 0, 0x04); } else { $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "part_set_lpar_def_state", 0, 0x02); } if (@$values[2] ne 0) { - return ([[$name, @$values[1], @$values[2]]]); + return ([ [ $name, @$values[1], @$values[2] ] ]); } - push @ret, [$name, "Done", 0]; + push @ret, [ $name, "Done", 0 ]; + #return ([$name, "Done", 0]); return \@ret; } sub mkspeclpar { my $request = shift; - my $hash = shift; - my $opt = $request->{opt}; + my $hash = shift; + my $opt = $request->{opt}; my $values; - my @result = (); + my @result = (); my %lpar_hash = (); - my $vmtab = xCAT::Table->new( 'vm'); - unless($vmtab) { - return([["Error","Cannot open vm table", 1]]); + my $vmtab = xCAT::Table->new('vm'); + unless ($vmtab) { + return ([ [ "Error", "Cannot open vm table", 1 ] ]); } - while (my ($mtms, $h) = each (%$hash)) { + while (my ($mtms, $h) = each(%$hash)) { my $memhash = undef; - my @nodes = keys(%$h); - my $ent = $vmtab->getNodesAttribs(\@nodes, ['cpus', 'memory','physlots', 'othersettings', 'storage', 'nics']); - while (my ($name, $d) = each (%$h)) { + my @nodes = keys(%$h); + my $ent = $vmtab->getNodesAttribs(\@nodes, [ 'cpus', 'memory', 'physlots', 'othersettings', 'storage', 'nics' ]); + while (my ($name, $d) = each(%$h)) { if (@$d[4] ne 'lpar') { - push @result, [$name, "Node must be LPAR", 1]; + push @result, [ $name, "Node must be LPAR", 1 ]; last; } - #if (!exists($memhash->{run})) + + #if (!exists($memhash->{run})) #{ - my @td = @$d; - @td[0] = 0; - $memhash = &query_cec_info_actions($request, $name, \@td, 1, ["part_get_hyp_process_and_mem","lpar_lhea_mac","part_get_all_io_bus_info"]); - unless (scalar keys(%$memhash)) { - push @result, [$mtms, "Can not get hypervisor information", 1]; - last; - } - #$memhash->{run} = 1; + my @td = @$d; + @td[0] = 0; + $memhash = &query_cec_info_actions($request, $name, \@td, 1, [ "part_get_hyp_process_and_mem", "lpar_lhea_mac", "part_get_all_io_bus_info" ]); + unless (scalar keys(%$memhash)) { + push @result, [ $mtms, "Can not get hypervisor information", 1 ]; + last; + } + + #$memhash->{run} = 1; #} - + my $tmp_ent = $ent->{$name}->[0]; if (exists($opt->{vmcpus})) { $tmp_ent->{cpus} = $opt->{vmcpus}; - } + } if (exists($opt->{vmmemory})) { $tmp_ent->{memory} = $opt->{vmmemory}; } @@ -2317,39 +2382,41 @@ sub mkspeclpar { } - if (!defined($tmp_ent) ) { - return ([[$name, "Not find params", 1]]); - #} elsif (!exists($tmp_ent->{cpus}) || !exists($tmp_ent->{memory}) || !exists($tmp_ent->{physlots})) { - } elsif (!exists($tmp_ent->{cpus}) || !exists($tmp_ent->{memory})) { - return ([[$name, "The attribute 'vmcpus', 'vmmemory' are needed to be specified.", 1]]); - } - # FIX bug 3873 [FVT]DFM illegal action could work - # + if (!defined($tmp_ent)) { + return ([ [ $name, "Not find params", 1 ] ]); - if ($tmp_ent->{cpus} =~ /^(\d+)\/(\d+)\/(\d+)$/) { + #} elsif (!exists($tmp_ent->{cpus}) || !exists($tmp_ent->{memory}) || !exists($tmp_ent->{physlots})) { + } elsif (!exists($tmp_ent->{cpus}) || !exists($tmp_ent->{memory})) { + return ([ [ $name, "The attribute 'vmcpus', 'vmmemory' are needed to be specified.", 1 ] ]); + } + + # FIX bug 3873 [FVT]DFM illegal action could work + # + + if ($tmp_ent->{cpus} =~ /^(\d+)\/(\d+)\/(\d+)$/) { unless ($1 <= $2 and $2 <= $3) { - return([[$name, "Parameter for 'vmcpus' is invalid", 1]]); - } elsif ($memhash->{process_units_avail} eq '0') { - push @result, [$name, "No process available", 1]; + return ([ [ $name, "Parameter for 'vmcpus' is invalid", 1 ] ]); + } elsif ($memhash->{process_units_avail} eq '0') { + push @result, [ $name, "No process available", 1 ]; next; } elsif ($2 > $memhash->{process_units_avail}) { my $cur = $memhash->{process_units_avail}; my $min = $1 > $cur ? $cur : $1; $tmp_ent->{cpus} = "$min/$cur/$3"; - push @result, [$name, "Available processor is less than required, allocate $cur processors.", 0]; + push @result, [ $name, "Available processor is less than required, allocate $cur processors.", 0 ]; } } else { - return([[$name, "Parameter for 'vmcpus' is invalid", 1]]); + return ([ [ $name, "Parameter for 'vmcpus' is invalid", 1 ] ]); } if ($tmp_ent->{memory} =~ /^([\d|.]+)([G|M]?)\/([\d|.]+)([G|M]?)\/([\d|.]+)([G|M]?)$/i) { if ($memhash->{hyp_avail_mem} eq '0') { - push @result, [$name, "No memory available", 1]; + push @result, [ $name, "No memory available", 1 ]; next; } my ($mmin, $mcur, $mmax); if ($2 eq "G" or $2 eq '') { $mmin = $1 * 1024; - } + } if ($4 eq "G" or $4 eq '') { $mcur = $3 * 1024; } @@ -2357,40 +2424,40 @@ sub mkspeclpar { $mmax = $5 * 1024; } unless ($mmin <= $mcur and $mcur <= $mmax) { - return([[$name, "Parameter for 'vmmemory' is invalid", 1]]); + return ([ [ $name, "Parameter for 'vmmemory' is invalid", 1 ] ]); } my $memsize = $memhash->{mem_region_size}; - $mmin = int(($mmin + $memsize - 1) / $memsize); - $mcur = int(($mcur + $memsize - 1) / $memsize); - $mmax = int(($mmax + $memsize - 1) / $memsize); + $mmin = int(($mmin + $memsize - 1) / $memsize); + $mcur = int(($mcur + $memsize - 1) / $memsize); + $mmax = int(($mmax + $memsize - 1) / $memsize); $tmp_ent->{memory} = "$mmin/$mcur/$mmax"; $tmp_ent->{mem_region_size} = $memsize; } else { - return([[$name, "Parameter for 'vmmemory' is invalid", 1]]); + return ([ [ $name, "Parameter for 'vmmemory' is invalid", 1 ] ]); } - + if (exists($tmp_ent->{physlots})) { - my @tmp_array = split ",",$tmp_ent->{physlots}; + my @tmp_array = split ",", $tmp_ent->{physlots}; foreach (@tmp_array) { unless (/(0x\w{8})/i) { - return([[$name, "Parameter:$_ for 'vmphyslots' is invalid", 1]]); + return ([ [ $name, "Parameter:$_ for 'vmphyslots' is invalid", 1 ] ]); } } } if (exists($tmp_ent->{othersettings})) { - my @tmp_array = split ",",$tmp_ent->{othersettings}; + my @tmp_array = split ",", $tmp_ent->{othersettings}; foreach (@tmp_array) { unless (/^(bsr|hugepage):\d+$/) { - return([[$name, "Parameter:$_ for 'vmothersetting' is invalid", 1]]); + return ([ [ $name, "Parameter:$_ for 'vmothersetting' is invalid", 1 ] ]); } } } - + if (exists($tmp_ent->{nics})) { - my @tmp_array = split ",",$tmp_ent->{nics}; + my @tmp_array = split ",", $tmp_ent->{nics}; foreach (@tmp_array) { unless (/^vlan\d+$/i) { - return([[$name, "Parameter:$_ for 'vmnics' is invalid", 1]]); + return ([ [ $name, "Parameter:$_ for 'vmnics' is invalid", 1 ] ]); } } } @@ -2398,22 +2465,22 @@ sub mkspeclpar { if (exists($opt->{vios})) { if (!exists($tmp_ent->{physlots})) { - my @phy_io_array = keys(%{$memhash->{bus}}); - $tmp_ent->{physlots} = join(",", @phy_io_array); - } + my @phy_io_array = keys(%{ $memhash->{bus} }); + $tmp_ent->{physlots} = join(",", @phy_io_array); + } if (exists($tmp_ent->{storage}) and $tmp_ent->{storage} !~ /^\d+$/) { - return ([[$name, "Parameter for 'vmstorage' is invalid", 1]]); + return ([ [ $name, "Parameter for 'vmstorage' is invalid", 1 ] ]); } elsif (exists($tmp_ent->{storage})) { - my $num = $tmp_ent->{storage}; + my $num = $tmp_ent->{storage}; my @array = (); - for (1..$num) { + for (1 .. $num) { push @array, '0'; } $tmp_ent->{storage} = \@array; } } else { if (exists($tmp_ent->{storage})) { - my @tmp_array = split ",",$tmp_ent->{storage}; + my @tmp_array = split ",", $tmp_ent->{storage}; my $storage_array = undef; foreach (@tmp_array) { if (/([\w_-]*):(\d+)/) { @@ -2422,25 +2489,25 @@ sub mkspeclpar { if (defined($vios)) { push @$storage_array, "0,$vios,$r_slotid"; } else { - return ([[$name, "Cannot find lparid for Server lpar:$1"]]); + return ([ [ $name, "Cannot find lparid for Server lpar:$1" ] ]); } } else { - return ([[$name, "Parameter for 'vmstorage' is invalid", 1]]); + return ([ [ $name, "Parameter for 'vmstorage' is invalid", 1 ] ]); } } $tmp_ent->{storage} = $storage_array; - + } } $tmp_ent->{hyp_config_mem} = $memhash->{hyp_config_mem}; - $tmp_ent->{hyp_avail_mem} = $memhash->{hyp_avail_mem}; - if (exists($tmp_ent->{othersettings})) { + $tmp_ent->{hyp_avail_mem} = $memhash->{hyp_avail_mem}; + if (exists($tmp_ent->{othersettings})) { my $setting = $tmp_ent->{othersettings}; if ($setting =~ /hugepage:(\d+)/) { my $tmp = $1; if ($tmp >= 1) { - $tmp_ent->{huge_page} = "1/".$tmp."/".$tmp; + $tmp_ent->{huge_page} = "1/" . $tmp . "/" . $tmp; } } if ($setting =~ /bsr:(\d+)/) { @@ -2449,82 +2516,84 @@ sub mkspeclpar { } } } - $tmp_ent->{phy_hea} = $memhash->{phy_drc_group_port}; + $tmp_ent->{phy_hea} = $memhash->{phy_drc_group_port}; $tmp_ent->{logic_drc_phydrc} = $memhash->{logic_drc_phydrc}; - $values = &create_lpar($request, $name, $d, $tmp_ent); + $values = &create_lpar($request, $name, $d, $tmp_ent); push @result, @$values; + #need to add update db here - my $rethash = query_cec_info_actions($request, $name, $d, 1, ["part_get_lpar_processing","part_get_lpar_memory","part_get_all_vio_info","part_get_all_io_bus_info","get_huge_page","get_cec_bsr"]); + my $rethash = query_cec_info_actions($request, $name, $d, 1, [ "part_get_lpar_processing", "part_get_lpar_memory", "part_get_all_vio_info", "part_get_all_io_bus_info", "get_huge_page", "get_cec_bsr" ]); unless (scalar keys(%$rethash)) { - push @result, [$mtms, "Can not get hypervisor information", 1]; + push @result, [ $mtms, "Can not get hypervisor information", 1 ]; next; } - $lpar_hash{$name} = $rethash; + $lpar_hash{$name} = $rethash; $lpar_hash{$name}->{parent} = @$d[3]; $name = undef; - $d = undef; + $d = undef; } } if (%lpar_hash) { update_vm_db($request, \%lpar_hash); } - return \@result; + return \@result; } sub mkfulllpar { my $request = shift; - my $hash = shift; + my $hash = shift; my $values; my @result = (); - while (my ($mtms, $h) = each (%$hash)) { + while (my ($mtms, $h) = each(%$hash)) { my $rethash; - while (my ($name, $d) = each (%$h)) { + while (my ($name, $d) = each(%$h)) { if (@$d[4] ne 'lpar') { - push @result, [$name, "Node must be LPAR", 1]; + push @result, [ $name, "Node must be LPAR", 1 ]; last; } if (!exists($rethash->{run})) { my @td = @$d; @td[0] = 0; - $rethash = query_cec_info_actions($request, $name, \@td, 1); + $rethash = query_cec_info_actions($request, $name, \@td, 1); unless (scalar keys(%$rethash)) { - push @result, [$mtms, "Can not get hypervisor information", 1]; + push @result, [ $mtms, "Can not get hypervisor information", 1 ]; next; } - $rethash->{run} = 1; + $rethash->{run} = 1; + #print Dumper($rethash); } my %lpar_param = (); - $lpar_param{cpus} = "1/".$rethash->{process_units_avail}."/".$rethash->{process_units_config}; - $lpar_param{memory} = "1/".$rethash->{hyp_avail_mem}."/".$rethash->{hyp_config_mem}; - $lpar_param{hyp_config_mem} = $rethash->{hyp_config_mem}; - $lpar_param{hyp_avail_mem} = $rethash->{hyp_avail_mem}; + $lpar_param{cpus} = "1/" . $rethash->{process_units_avail} . "/" . $rethash->{process_units_config}; + $lpar_param{memory} = "1/" . $rethash->{hyp_avail_mem} . "/" . $rethash->{hyp_config_mem}; + $lpar_param{hyp_config_mem} = $rethash->{hyp_config_mem}; + $lpar_param{hyp_avail_mem} = $rethash->{hyp_avail_mem}; $lpar_param{mem_region_size} = $rethash->{mem_region_size}; - my @phy_io_array = keys(%{$rethash->{bus}}); + my @phy_io_array = keys(%{ $rethash->{bus} }); $lpar_param{physlots} = join(",", @phy_io_array); - $lpar_param{huge_page} = "1/".$rethash->{huge_page_avail}."/".$rethash->{huge_page_avail}; - $lpar_param{bsr_num} = $rethash->{cec_bsr_avail}; - $lpar_param{phy_hea} = $rethash->{phy_drc_group_port}; - $lpar_param{logic_drc_phydrc} = $rethash->{logic_drc_phydrc}; - $lpar_param{full_par} = 1; + $lpar_param{huge_page} = "1/" . $rethash->{huge_page_avail} . "/" . $rethash->{huge_page_avail}; + $lpar_param{bsr_num} = $rethash->{cec_bsr_avail}; + $lpar_param{phy_hea} = $rethash->{phy_drc_group_port}; + $lpar_param{logic_drc_phydrc} = $rethash->{logic_drc_phydrc}; + $lpar_param{full_par} = 1; $values = &create_lpar($request, $name, $d, \%lpar_param); $rethash->{logic_drc_phydrc} = $lpar_param{logic_drc_phydrc}; push @result, @$values; $name = undef; - $d = undef; - } + $d = undef; + } } return \@result; } ########################################################################## -# Creates logical partitions +# Creates logical partitions ########################################################################## sub mkvm { my $request = $_[0]; my $opt = $request->{opt}; - + # decide if issuing mkvm with the option '-f'. # if yes, mklpar will be invoked to # create a full system partition for each CECs managed by the HMC. @@ -2539,25 +2608,26 @@ sub mkvm { } ########################################################################## -# Change logical partition +# Change logical partition ########################################################################## sub chvm { - return( modify(@_) ); + return (modify(@_)); } ########################################################################## -# No rmvm for Power 775 +# No rmvm for Power 775 ########################################################################## -sub rmvm { +sub rmvm { my $request = $_[0]; - my $opt = $request->{opt}; + my $opt = $request->{opt}; if (exists($opt->{p775})) { - return ([["lpar","rmvm only support Power Partitioning.", 1]]); + return ([ [ "lpar", "rmvm only support Power Partitioning.", 1 ] ]); } else { - return( remove(@_) ); + return (remove(@_)); } -# return( remove(@_) ); + + # return( remove(@_) ); } ########################################################################## @@ -2567,10 +2637,10 @@ sub lsvm { my $request = shift; my $hash = shift; my $args = $request->{opt}; - if (exists($args->{p775})) { - return( list($request, $hash) ); + if (exists($args->{p775})) { + return (list($request, $hash)); } else { - return (query_cec_info($request, $hash)); + return (query_cec_info($request, $hash)); } } diff --git a/perl-xCAT/xCAT/GlobalDef.pm b/perl-xCAT/xCAT/GlobalDef.pm index 31bf9de71..b953a5168 100644 --- a/perl-xCAT/xCAT/GlobalDef.pm +++ b/perl-xCAT/xCAT/GlobalDef.pm @@ -17,87 +17,87 @@ This module contains all the global info for xCAT. # valid values for nodelist.hwtype column -$::NODETYPE_LPAR="lpar"; -$::NODETYPE_BPA="bpa"; -$::NODETYPE_FSP="fsp"; -$::NODETYPE_HMC="hmc"; -$::NODETYPE_IVM="ivm"; -$::NODETYPE_FRAME="frame"; -$::NODETYPE_CEC="cec"; -$::NODETYPE_BLADE="blade"; -$::NODETYPE_CMM="cmm"; +$::NODETYPE_LPAR = "lpar"; +$::NODETYPE_BPA = "bpa"; +$::NODETYPE_FSP = "fsp"; +$::NODETYPE_HMC = "hmc"; +$::NODETYPE_IVM = "ivm"; +$::NODETYPE_FRAME = "frame"; +$::NODETYPE_CEC = "cec"; +$::NODETYPE_BLADE = "blade"; +$::NODETYPE_CMM = "cmm"; # valid values for nodelist.nodetype column -$::NODETYPE_OSI="osi"; -$::NODETYPE_PPC="ppc"; -$::NODETYPE_ZVM="zvm"; -$::NODETYPE_MP="mp"; +$::NODETYPE_OSI = "osi"; +$::NODETYPE_PPC = "ppc"; +$::NODETYPE_ZVM = "zvm"; +$::NODETYPE_MP = "mp"; #valid values for nodelist.updatestatus -$::STATUS_SYNCING="syncing"; -$::STATUS_OUT_OF_SYNC="out-of-sync"; -$::STATUS_SYNCED="synced"; -$::STATUS_FAILED="failed"; +$::STATUS_SYNCING = "syncing"; +$::STATUS_OUT_OF_SYNC = "out-of-sync"; +$::STATUS_SYNCED = "synced"; +$::STATUS_FAILED = "failed"; -# valid values for nodelist.status columns or other status -$::STATUS_ACTIVE="alive"; -$::STATUS_INACTIVE="unreachable"; -$::STATUS_INSTALLING="installing"; -$::STATUS_INSTALLED="installed"; -$::STATUS_BOOTING="booting"; -$::STATUS_NETBOOTING="netbooting"; -$::STATUS_BOOTED="booted"; -$::STATUS_POWERING_ON="powering-on"; -$::STATUS_POWERING_OFF="powering-off"; -$::STATUS_DISCOVERING="discovering"; -$::STATUS_CONFIGURING="configuring"; -$::STATUS_STANDING_BY="standingby"; -$::STATUS_SHELL="shell"; -$::STATUS_DEFINED="defined"; -$::STATUS_UNKNOWN="unknown"; -$::STATUS_FAILED="failed"; -$::STATUS_BMCREADY="bmcready"; +# valid values for nodelist.status columns or other status +$::STATUS_ACTIVE = "alive"; +$::STATUS_INACTIVE = "unreachable"; +$::STATUS_INSTALLING = "installing"; +$::STATUS_INSTALLED = "installed"; +$::STATUS_BOOTING = "booting"; +$::STATUS_NETBOOTING = "netbooting"; +$::STATUS_BOOTED = "booted"; +$::STATUS_POWERING_ON = "powering-on"; +$::STATUS_POWERING_OFF = "powering-off"; +$::STATUS_DISCOVERING = "discovering"; +$::STATUS_CONFIGURING = "configuring"; +$::STATUS_STANDING_BY = "standingby"; +$::STATUS_SHELL = "shell"; +$::STATUS_DEFINED = "defined"; +$::STATUS_UNKNOWN = "unknown"; +$::STATUS_FAILED = "failed"; +$::STATUS_BMCREADY = "bmcready"; %::VALID_STATUS_VALUES = ( - $::STATUS_ACTIVE=>1, - $::STATUS_INACTIVE=>1, - $::STATUS_INSTALLING=>1, - $::STATUS_INSTALLED=>1, - $::STATUS_BOOTING=>1, - $::STATUS_NETBOOTING=>1, - $::STATUS_BOOTED=>1, - $::STATUS_POWERING_ON=>1, - $::STATUS_POWERING_OFF=>1, - $::STATUS_DISCOVERING=>1, - $::STATUS_CONFIGURING=>1, - $::STATUS_STANDING_BY=>1, - $::STATUS_SHELL=>1, - $::STATUS_DEFINED=>1, - $::STATUS_UNKNOWN=>1, - $::STATUS_FAILED=>1, - $::STATUS_BMCREADY=>1, + $::STATUS_ACTIVE => 1, + $::STATUS_INACTIVE => 1, + $::STATUS_INSTALLING => 1, + $::STATUS_INSTALLED => 1, + $::STATUS_BOOTING => 1, + $::STATUS_NETBOOTING => 1, + $::STATUS_BOOTED => 1, + $::STATUS_POWERING_ON => 1, + $::STATUS_POWERING_OFF => 1, + $::STATUS_DISCOVERING => 1, + $::STATUS_CONFIGURING => 1, + $::STATUS_STANDING_BY => 1, + $::STATUS_SHELL => 1, + $::STATUS_DEFINED => 1, + $::STATUS_UNKNOWN => 1, + $::STATUS_FAILED => 1, + $::STATUS_BMCREADY => 1, - $::STATUS_SYNCING=>1, - $::STATUS_OUT_OF_SYNC=>1, - $::STATUS_SYNCED=>1, + $::STATUS_SYNCING => 1, + $::STATUS_OUT_OF_SYNC => 1, + $::STATUS_SYNCED => 1, ); #defined->[discovering]->[configuring]->[standingby]->installing->[installed]->booting->alive, defined->[discovering]->[configuring]-[standingby]->netbooting->booted->alive, alive/unreachable->booting->alive, powering-off->unreachable, alive->unreachable -%::NEXT_NODESTAT_VAL=( - $::STATUS_DEFINED=>{$::STATUS_DISCOVERING=>1, $::STATUS_INSTALLING=>1, $::STATUS_NETBOOTING=>1, $::STATUS_POWERING_OFF=>1, $::STATUS_POWERING_ON=>1, $::STATUS_BOOTING=>1, $::STATUS_CONFIGURING=>1}, - $::STATUS_DISCOVERING=>{$::STATUS_INSTALLING=>1, $::STATUS_NETBOOTING=>1, $::STATUS_CONFIGURING=>1, $::STATUS_BOOTING=>1}, - $::STATUS_CONFIGURING=>{$::STATUS_INSTALLING=>1, $::STATUS_NETBOOTING=>1, $::STATUS_STANDING_BY=>1}, - $::STATUS_INSTALLING =>{$::STATUS_INSTALLED=>1, $::STATUS_BOOTING=>1}, - $::STATUS_INSTALLED =>{$::STATUS_BOOTING=>1}, - $::STATUS_BOOTING=>{$::STATUS_BOOTED=>1, $::STATUS_ACTIVE=>1, $::STATUS_INACTIVE=>1}, - $::STATUS_NETBOOTING=>{$::STATUS_BOOTED=>1}, - $::STATUS_BOOTED=>{$::STATUS_ACTIVE=>1, $::STATUS_INACTIVE=>1}, - $::STATUS_ACTIVE=>{$::STATUS_INACTIVE=>1, $::STATUS_DISCOVERING=>1, $::STATUS_CONFIGURING=>1, $::STATUS_INSTALLING=>1, $::STATUS_NETBOOTING=>1, $::STATUS_POWERING_OFF=>1, $::STATUS_POWERING_ON=>1}, - $::STATUS_INACTIVE=>{$::STATUS_ACTIVE=>1, $::STATUS_DISCOVERING=>1, $::STATUS_CONFIGURING=>1, $::STATUS_INSTALLING=>1, $::STATUS_NETBOOTING=>1, $::STATUS_POWERING_OFF=>1, $::STATUS_POWERING_ON=>1}, - $::STATUS_POWERING_OFF=>{$::STATUS_INACTIVE=>1}, - $::STATUS_POWERING_ON=>{$::STATUS_BOOTED=>1} +%::NEXT_NODESTAT_VAL = ( + $::STATUS_DEFINED => { $::STATUS_DISCOVERING => 1, $::STATUS_INSTALLING => 1, $::STATUS_NETBOOTING => 1, $::STATUS_POWERING_OFF => 1, $::STATUS_POWERING_ON => 1, $::STATUS_BOOTING => 1, $::STATUS_CONFIGURING => 1 }, + $::STATUS_DISCOVERING => { $::STATUS_INSTALLING => 1, $::STATUS_NETBOOTING => 1, $::STATUS_CONFIGURING => 1, $::STATUS_BOOTING => 1 }, + $::STATUS_CONFIGURING => { $::STATUS_INSTALLING => 1, $::STATUS_NETBOOTING => 1, $::STATUS_STANDING_BY => 1 }, + $::STATUS_INSTALLING => { $::STATUS_INSTALLED => 1, $::STATUS_BOOTING => 1 }, + $::STATUS_INSTALLED => { $::STATUS_BOOTING => 1 }, + $::STATUS_BOOTING => { $::STATUS_BOOTED => 1, $::STATUS_ACTIVE => 1, $::STATUS_INACTIVE => 1 }, + $::STATUS_NETBOOTING => { $::STATUS_BOOTED => 1 }, + $::STATUS_BOOTED => { $::STATUS_ACTIVE => 1, $::STATUS_INACTIVE => 1 }, + $::STATUS_ACTIVE => { $::STATUS_INACTIVE => 1, $::STATUS_DISCOVERING => 1, $::STATUS_CONFIGURING => 1, $::STATUS_INSTALLING => 1, $::STATUS_NETBOOTING => 1, $::STATUS_POWERING_OFF => 1, $::STATUS_POWERING_ON => 1 }, + $::STATUS_INACTIVE => { $::STATUS_ACTIVE => 1, $::STATUS_DISCOVERING => 1, $::STATUS_CONFIGURING => 1, $::STATUS_INSTALLING => 1, $::STATUS_NETBOOTING => 1, $::STATUS_POWERING_OFF => 1, $::STATUS_POWERING_ON => 1 }, + $::STATUS_POWERING_OFF => { $::STATUS_INACTIVE => 1 }, + $::STATUS_POWERING_ON => { $::STATUS_BOOTED => 1 } ); 1; - + diff --git a/perl-xCAT/xCAT/InstUtils.pm b/perl-xCAT/xCAT/InstUtils.pm index fcad5c651..eca717056 100755 --- a/perl-xCAT/xCAT/InstUtils.pm +++ b/perl-xCAT/xCAT/InstUtils.pm @@ -10,7 +10,7 @@ BEGIN # if AIX - make sure we include perl 5.8.2 in INC path. # Needed to find perl dependencies shipped in deps tarball. if ($^O =~ /^aix/i) { - unshift(@INC, qw(/usr/opt/perl5/lib/5.8.2/aix-thread-multi /usr/opt/perl5/lib/5.8.2 /usr/opt/perl5/lib/site_perl/5.8.2/aix-thread-multi /usr/opt/perl5/lib/site_perl/5.8.2)); + unshift(@INC, qw(/usr/opt/perl5/lib/5.8.2/aix-thread-multi /usr/opt/perl5/lib/5.8.2 /usr/opt/perl5/lib/site_perl/5.8.2/aix-thread-multi /usr/opt/perl5/lib/site_perl/5.8.2)); } use lib "$::XCATROOT/lib/perl"; @@ -24,6 +24,7 @@ use strict; require xCAT::Schema; use xCAT::NetworkUtils; use xCAT::TableUtils; + #require Data::Dumper; #use Data::Dumper; require xCAT::NodeRange; @@ -68,10 +69,11 @@ sub getnimprime # or it is the xCAT management node. my $nimprime = xCAT::TableUtils->get_site_Master(); + #my $sitetab = xCAT::Table->new('site'); #(my $et) = $sitetab->getAttribs({key => "nimprime"}, 'value'); my @nimprimes = xCAT::TableUtils->get_site_attribute("nimprime"); - my $tmp = $nimprimes[0]; + my $tmp = $nimprimes[0]; if (defined($tmp)) { $nimprime = $tmp; @@ -115,58 +117,59 @@ sub myxCATname { my ($junk, $name); - # make sure xcatd is running - & db is available - # this routine is called during initial install of xCAT - my $cmd="lsxcatd -d > /dev/null 2>&1"; - my $outref = []; - @$outref = `$cmd`; - my $rc = $? >> 8; - if ($rc == 0) - { - if (xCAT::Utils->isMN()) - { - # read the site table, master attrib - my $hostname = xCAT::TableUtils->get_site_Master(); - if (($hostname =~ /\d+\.\d+\.\d+\.\d+/) || ($hostname =~ /:/)) - { - $name = xCAT::NetworkUtils->gethostname($hostname); - } - else - { - $name = $hostname; - } - } - elsif (xCAT::Utils->isServiceNode()) - { - my $filename; - # get any files with the format myxcatpost_* - my $lscmd = qq~/bin/ls /xcatpost/myxcatpost_* 2>/dev/null~; - my $output = `$lscmd`; - my $rc = $? >> 8; - if ($rc == 0) - { - foreach my $line ( split(/\n/, $output)) { - my ($junk, $hostname) = split('myxcatpost_', $line); - if (xCAT::InstUtils->is_me($hostname)) { - $filename="/xcatpost/myxcatpost_$hostname"; - last; - } - } + # make sure xcatd is running - & db is available + # this routine is called during initial install of xCAT + my $cmd = "lsxcatd -d > /dev/null 2>&1"; + my $outref = []; + @$outref = `$cmd`; + my $rc = $? >> 8; + if ($rc == 0) + { + if (xCAT::Utils->isMN()) + { + # read the site table, master attrib + my $hostname = xCAT::TableUtils->get_site_Master(); + if (($hostname =~ /\d+\.\d+\.\d+\.\d+/) || ($hostname =~ /:/)) + { + $name = xCAT::NetworkUtils->gethostname($hostname); + } + else + { + $name = $hostname; + } + } + elsif (xCAT::Utils->isServiceNode()) + { + my $filename; - if ( -e $filename ) { - my $catcmd = qq~/bin/cat $filename | grep '^NODE=' 2>/dev/null~; - my $string = `$catcmd`; - if ($rc == 0) { - ($junk, $name) = split('=', $string); - } - } - } - } - } + # get any files with the format myxcatpost_* + my $lscmd = qq~/bin/ls /xcatpost/myxcatpost_* 2>/dev/null~; + my $output = `$lscmd`; + my $rc = $? >> 8; + if ($rc == 0) + { + foreach my $line (split(/\n/, $output)) { + my ($junk, $hostname) = split('myxcatpost_', $line); + if (xCAT::InstUtils->is_me($hostname)) { + $filename = "/xcatpost/myxcatpost_$hostname"; + last; + } + } - if (!$name) { - $name = hostname(); - } + if (-e $filename) { + my $catcmd = qq~/bin/cat $filename | grep '^NODE=' 2>/dev/null~; + my $string = `$catcmd`; + if ($rc == 0) { + ($junk, $name) = split('=', $string); + } + } + } + } + } + + if (!$name) { + $name = hostname(); + } my $shorthost; ($shorthost = $name) =~ s/\..*$//; @@ -220,7 +223,7 @@ sub is_me # this is a common subroutine for both AIX and Linux, # AIX does not have ip command my $ipcmd; - if ( -f "/sbin/ip" ) + if (-f "/sbin/ip") { $ipcmd = "ip addr | grep 'inet'"; } @@ -231,7 +234,7 @@ sub is_me my $result = xCAT::Utils->runcmd($ipcmd, -1, 1); if ($::RUNCMD_RC != 0) { - my $str="Error running ipcmd"; + my $str = "Error running ipcmd"; xCAT::MsgUtils->message("S", $str); $::VERBOSE = $verb; return 0; @@ -241,16 +244,16 @@ sub is_me { my ($inet, $myIP, $str) = split(" ", $int); chomp $myIP; - $myIP =~ s/\/.*//; # ipv6 address 4000::99/64 - $myIP =~ s/\%.*//; # ipv6 address ::1%1/128 + $myIP =~ s/\/.*//; # ipv6 address 4000::99/64 + $myIP =~ s/\%.*//; # ipv6 address ::1%1/128 if ($myIP eq $nameIP) { - $::VERBOSE = $verb; + $::VERBOSE = $verb; return 1; } } - $::VERBOSE = $verb; + $::VERBOSE = $verb; return 0; } @@ -282,58 +285,59 @@ sub is_me sub get_nim_attrs { my $class = shift; - my $resname = shift; - my $callback = shift; - my $target = shift; - my $sub_req = shift; + my $resname = shift; + my $callback = shift; + my $target = shift; + my $sub_req = shift; - my %attrvals = undef; + my %attrvals = undef; - if (!$target) - { - $target = xCAT::InstUtils->getnimprime(); - } - chomp $target; + if (!$target) + { + $target = xCAT::InstUtils->getnimprime(); + } + chomp $target; - my $cmd = "/usr/sbin/lsnim -l $resname 2>/dev/null"; + my $cmd = "/usr/sbin/lsnim -l $resname 2>/dev/null"; - my @nout = xCAT::InstUtils->xcmd($callback, $sub_req, "xdsh", $target, $cmd, 1); - if ($::RUNCMD_RC != 0) - { - my $rsp; - push @{$rsp->{data}}, "Could not run lsnim command: \'$cmd\'.\n"; - xCAT::MsgUtils->message("E", $rsp, $callback); - return undef; - } + my @nout = xCAT::InstUtils->xcmd($callback, $sub_req, "xdsh", $target, $cmd, 1); + if ($::RUNCMD_RC != 0) + { + my $rsp; + push @{ $rsp->{data} }, "Could not run lsnim command: \'$cmd\'.\n"; + xCAT::MsgUtils->message("E", $rsp, $callback); + return undef; + } - foreach my $line (@nout) { + foreach my $line (@nout) { - chomp $line; - my $junk; - my $attrval; - if ($line =~ /.*$target:(.*)/) { - ($junk, $attrval) = split(/:/, $line); - } else { - $attrval = $line; - } + chomp $line; + my $junk; + my $attrval; + if ($line =~ /.*$target:(.*)/) { + ($junk, $attrval) = split(/:/, $line); + } else { + $attrval = $line; + } - if ($attrval =~ /=/) { + if ($attrval =~ /=/) { - my ($attr, $val) = $attrval =~ /^\s*(\S+?)\s*=\s*(\S*.*)$/; + my ($attr, $val) = $attrval =~ /^\s*(\S+?)\s*=\s*(\S*.*)$/; - if ($attr && $val) { - # $attrvals{$resname}{$attr} = $val; - $attrvals{$attr} = $val; - } - } - } + if ($attr && $val) { - if (%attrvals) { - return \%attrvals; - } else { - return undef; - } + # $attrvals{$resname}{$attr} = $val; + $attrvals{$attr} = $val; + } + } + } + + if (%attrvals) { + return \%attrvals; + } else { + return undef; + } } #---------------------------------------------------------------------------- @@ -373,7 +377,7 @@ sub get_nim_attr_val } chomp $target; - my $cmd = "/usr/sbin/lsnim -a $attrname -Z $resname 2>/dev/null"; + my $cmd = "/usr/sbin/lsnim -a $attrname -Z $resname 2>/dev/null"; my $nout = xCAT::InstUtils->xcmd($callback, $sub_req, "xdsh", $target, $cmd, 0); if ($::RUNCMD_RC != 0) @@ -442,15 +446,15 @@ sub xcmd push(@snodes, $target); $output = xCAT::Utils->runxcmd( - { - command => [$xdcmd], - node => \@snodes, - arg => ["-s", $cmd] - }, - $sub_req, - $exitcode, - $returnformat - ); + { + command => [$xdcmd], + node => \@snodes, + arg => [ "-s", $cmd ] + }, + $sub_req, + $exitcode, + $returnformat + ); } } else @@ -461,15 +465,15 @@ sub xcmd @snodes = @{$target}; $output = xCAT::Utils->runxcmd( - { - command => [$xdcmd], - node => \@snodes, - arg => ["-s", $cmd] - }, - $sub_req, - $exitcode, - $returnformat - ); + { + command => [$xdcmd], + node => \@snodes, + arg => [ "-s", $cmd ] + }, + $sub_req, + $exitcode, + $returnformat + ); } if ($returnformat == 1) { @@ -503,15 +507,15 @@ sub readBNDfile # get the location of the file from the NIM resource definition my $bnd_file_name = - xCAT::InstUtils->get_nim_attr_val($BNDname, 'location', $callback, - $nimprime, $sub_req); + xCAT::InstUtils->get_nim_attr_val($BNDname, 'location', $callback, + $nimprime, $sub_req); # The boundle file may be on nimprime my $ccmd = qq~cat $bnd_file_name~; - my $output=xCAT::InstUtils->xcmd($callback, $sub_req, "xdsh", $nimprime, $ccmd, 0); + my $output = xCAT::InstUtils->xcmd($callback, $sub_req, "xdsh", $nimprime, $ccmd, 0); if ($::RUNCMD_RC != 0) { my $rsp; - push @{$rsp->{data}}, "Command: $ccmd failed."; + push @{ $rsp->{data} }, "Command: $ccmd failed."; xCAT::MsgUtils->message("E", $rsp, $callback); } @@ -521,6 +525,7 @@ sub readBNDfile { #May include xdsh prefix $nimprime: $line =~ s/$nimprime:\s+//; + # skip blank and comment lines next if ($line =~ /^\s*$/ || $line =~ /^\s*#/); push(@pkglist, $line); @@ -680,14 +685,14 @@ sub getOSnodes my @linuxnodes; my $nodetab = xCAT::Table->new('nodetype'); - my $os = $nodetab->getNodesAttribs(\@nodelist, ['node', 'os']); + my $os = $nodetab->getNodesAttribs(\@nodelist, [ 'node', 'os' ]); foreach my $n (@nodelist) { my $osname; if (defined($os->{$n}->[0]->{os})) { $osname = $os->{$n}->[0]->{os}; } else { - $osname = $^O; + $osname = $^O; } if (($osname ne "AIX") && ($osname ne "aix")) { @@ -728,47 +733,47 @@ sub getOSnodes #------------------------------------------------------------------------------- sub get_server_nodes { - my $class = shift; - my $callback = shift; - my $nodes = shift; + my $class = shift; + my $callback = shift; + my $nodes = shift; - my @nodelist; - if ($nodes) + my @nodelist; + if ($nodes) { @nodelist = @$nodes; } - # + # # get the server name for each node - as known by node # - my $noderestab = xCAT::Table->new('noderes'); - my $xcatmasters = $noderestab->getNodesAttribs(\@nodelist, ['node', 'xcatmaster']); - $noderestab->close; + my $noderestab = xCAT::Table->new('noderes'); + my $xcatmasters = $noderestab->getNodesAttribs(\@nodelist, [ 'node', 'xcatmaster' ]); + $noderestab->close; - my %servernodes; + my %servernodes; foreach my $node (@nodelist) { - my $serv; + my $serv; if ($xcatmasters->{$node}->[0]->{xcatmaster}) { - # get ip of node xcatmaster attribute - my $xcatmaster = $xcatmasters->{$node}->[0]->{xcatmaster}; - $serv = xCAT::NetworkUtils->getipaddr($xcatmaster); + # get ip of node xcatmaster attribute + my $xcatmaster = $xcatmasters->{$node}->[0]->{xcatmaster}; + $serv = xCAT::NetworkUtils->getipaddr($xcatmaster); } else { # get ip facing node - my @servd= xCAT::NetworkUtils->my_ip_facing($node); - unless ($servd[0]) { $serv = $servd[1];} + my @servd = xCAT::NetworkUtils->my_ip_facing($node); + unless ($servd[0]) { $serv = $servd[1]; } } - chomp $serv; + chomp $serv; - if (xCAT::NetworkUtils->validate_ip($serv)) { - push (@{$servernodes{$serv}}, $node); - } + if (xCAT::NetworkUtils->validate_ip($serv)) { + push(@{ $servernodes{$serv} }, $node); + } } - return \%servernodes; + return \%servernodes; } #---------------------------------------------------------------------------- @@ -790,13 +795,13 @@ sub get_server_nodes #----------------------------------------------------------------------- sub dolitesetup { - my $class = shift; - my $imagename = shift; - my $imagehash = shift; - my $nodes = shift; - my $callback = shift; - my $subreq = shift; - my @litefiles; # lists of entries in the litefile table + my $class = shift; + my $imagename = shift; + my $imagehash = shift; + my $nodes = shift; + my $callback = shift; + my $subreq = shift; + my @litefiles; # lists of entries in the litefile table my %imghash; if ($imagehash) @@ -804,347 +809,351 @@ sub dolitesetup %imghash = %$imagehash; } - # get name as known by xCAT + # get name as known by xCAT my $Sname = xCAT::InstUtils->myxCATname(); chomp $Sname; - my $nimprime = xCAT::InstUtils->getnimprime(); + my $nimprime = xCAT::InstUtils->getnimprime(); my $target; if (xCAT::Utils->isSN($Sname)) { - $target=$Sname; + $target = $Sname; } else { - $target=$nimprime; + $target = $nimprime; } - my @nodelist; - my @nodel; - my @nl; + my @nodelist; + my @nodel; + my @nl; if ($nodes) { @nl = @$nodes; - foreach my $n (@nl) { - push(@nodel, xCAT::NodeRange::noderange($n)); - } + foreach my $n (@nl) { + push(@nodel, xCAT::NodeRange::noderange($n)); + } } - # - # Need to set the "provmethod" attr of the node defs or the litetree - # cmd wil not get the info we need - # + # + # Need to set the "provmethod" attr of the node defs or the litetree + # cmd wil not get the info we need + # - my %nodeattrs; + my %nodeattrs; foreach my $node (@nodel) { - chomp $node; - $nodeattrs{$node}{objtype} = 'node'; - $nodeattrs{$node}{os} = "AIX"; + chomp $node; + $nodeattrs{$node}{objtype} = 'node'; + $nodeattrs{$node}{os} = "AIX"; $nodeattrs{$node}{profile} = $imagename; $nodeattrs{$node}{provmethod} = $imagename; } - if (xCAT::DBobjUtils->setobjdefs(\%nodeattrs) != 0) + if (xCAT::DBobjUtils->setobjdefs(\%nodeattrs) != 0) { my $rsp; - push @{$rsp->{data}}, "Could not set the \'provmethod\' attribute for nodes.\n"; + push @{ $rsp->{data} }, "Could not set the \'provmethod\' attribute for nodes.\n"; xCAT::MsgUtils->message("W", $rsp, $::callback); } - # the node list is always "all" nodes. There is only one version of the - # statelite, litefile and litetree files in an image and these files - # must always contain all the info from the corresponding database - # table. - @nodelist= xCAT::DBobjUtils->getObjectsOfType('node'); - my $noderange; - if (scalar(@nodelist) > 0) - { - $noderange = join(',',@nodelist); - } else { - my $rsp; - push @{$rsp->{data}}, "Could not get list of xCAT nodes. No statelite configuration will be done.\n"; - xCAT::MsgUtils->message("E", $rsp, $callback); - return 2; - } + # the node list is always "all" nodes. There is only one version of the + # statelite, litefile and litetree files in an image and these files + # must always contain all the info from the corresponding database + # table. + @nodelist = xCAT::DBobjUtils->getObjectsOfType('node'); + my $noderange; + if (scalar(@nodelist) > 0) + { + $noderange = join(',', @nodelist); + } else { + my $rsp; + push @{ $rsp->{data} }, "Could not get list of xCAT nodes. No statelite configuration will be done.\n"; + xCAT::MsgUtils->message("E", $rsp, $callback); + return 2; + } - # get spot inst_root loc - my $spotloc = xCAT::InstUtils->get_nim_attr_val($imghash{$imagename}{spot}, 'location', $callback, $target, $subreq); + # get spot inst_root loc + my $spotloc = xCAT::InstUtils->get_nim_attr_val($imghash{$imagename}{spot}, 'location', $callback, $target, $subreq); - my $instrootloc = $spotloc . "/lpp/bos/inst_root"; + my $instrootloc = $spotloc . "/lpp/bos/inst_root"; - # get the statelite info - put each table into it's own file - my $statelitetab = xCAT::Table->new('statelite', -create=>1); - my $litefiletab = xCAT::Table->new('litefile'); - my $litetreetab = xCAT::Table->new('litetree'); + # get the statelite info - put each table into it's own file + my $statelitetab = xCAT::Table->new('statelite', -create => 1); + my $litefiletab = xCAT::Table->new('litefile'); + my $litetreetab = xCAT::Table->new('litetree'); - # these will wind up in the root dir on the node ("/") - my $statelitetable = "$instrootloc/statelite.table"; - my $litefiletable = "$instrootloc/litefile.table"; - my $litetreetable = "$instrootloc/litetree.table"; + # these will wind up in the root dir on the node ("/") + my $statelitetable = "$instrootloc/statelite.table"; + my $litefiletable = "$instrootloc/litefile.table"; + my $litetreetable = "$instrootloc/litetree.table"; - # get rid of any old files - if (-e $statelitetable) { - my $rc = xCAT::Utils->runcmd("rm $statelitetable", -1); - if ($::RUNCMD_RC != 0) - { - my $rsp; - push @{$rsp->{data}}, "Could not remove existing $statelitetable file."; - xCAT::MsgUtils->message("E", $rsp, $callback); - return 1; - } - } + # get rid of any old files + if (-e $statelitetable) { + my $rc = xCAT::Utils->runcmd("rm $statelitetable", -1); + if ($::RUNCMD_RC != 0) + { + my $rsp; + push @{ $rsp->{data} }, "Could not remove existing $statelitetable file."; + xCAT::MsgUtils->message("E", $rsp, $callback); + return 1; + } + } - if (-e $litefiletable) { - my $rc = xCAT::Utils->runcmd("rm $litefiletable", -1); - if ($::RUNCMD_RC != 0) - { - my $rsp; - push @{$rsp->{data}}, "Could not remove existing $litefiletable file."; - xCAT::MsgUtils->message("E", $rsp, $callback); - return 1; - } - } + if (-e $litefiletable) { + my $rc = xCAT::Utils->runcmd("rm $litefiletable", -1); + if ($::RUNCMD_RC != 0) + { + my $rsp; + push @{ $rsp->{data} }, "Could not remove existing $litefiletable file."; + xCAT::MsgUtils->message("E", $rsp, $callback); + return 1; + } + } - if (-e $litetreetable) { - my $rc = xCAT::Utils->runcmd("rm $litetreetable", -1); - if ($::RUNCMD_RC != 0) - { - my $rsp; - push @{$rsp->{data}}, "Could not remove existing $litetreetable file."; - xCAT::MsgUtils->message("E", $rsp, $callback); - return 1; - } - } + if (-e $litetreetable) { + my $rc = xCAT::Utils->runcmd("rm $litetreetable", -1); + if ($::RUNCMD_RC != 0) + { + my $rsp; + push @{ $rsp->{data} }, "Could not remove existing $litetreetable file."; + xCAT::MsgUtils->message("E", $rsp, $callback); + return 1; + } + } - # - # create files for each statelite table. add them to the SPOT. - # use the "|" as a separator, remove all blanks from the entries. - # put them in $instrootloc location. they will be available as soon - # as the root dir is mounted during the boot process. + # + # create files for each statelite table. add them to the SPOT. + # use the "|" as a separator, remove all blanks from the entries. + # put them in $instrootloc location. they will be available as soon + # as the root dir is mounted during the boot process. - my $foundstatelite=0; - unless (open(STATELITE, ">$statelitetable")) + my $foundstatelite = 0; + unless (open(STATELITE, ">$statelitetable")) { my $rsp; - push @{$rsp->{data}}, "Could not open $statelitetable.\n"; + push @{ $rsp->{data} }, "Could not open $statelitetable.\n"; xCAT::MsgUtils->message("E", $rsp, $callback); return 1; } - # create the statelite table file - my $foundentry=0; - my $stateHash = $statelitetab->getNodesAttribs(\@nodelist, ['statemnt', 'mntopts']); - foreach my $node (@nodelist) { + # create the statelite table file + my $foundentry = 0; + my $stateHash = $statelitetab->getNodesAttribs(\@nodelist, [ 'statemnt', 'mntopts' ]); + foreach my $node (@nodelist) { - # process statelite entry - # add line to file for each node - # note: if statement is xcatmn:/nodedata - # /nodedata is mounted to /.statelite/persistent - # then - on node - a nodename subdir is created + # process statelite entry + # add line to file for each node + # note: if statement is xcatmn:/nodedata + # /nodedata is mounted to /.statelite/persistent + # then - on node - a nodename subdir is created - my $statemnt=""; - my $mntopts; + my $statemnt = ""; + my $mntopts; if (exists($stateHash->{$node})) { - $mntopts = $stateHash->{$node}->[0]->{mntopts}; + $mntopts = $stateHash->{$node}->[0]->{mntopts}; $statemnt = $stateHash->{$node}->[0]->{statemnt}; my ($server, $dir) = split(/:/, $statemnt); #if server is blank, then its the directory - unless($dir) { - $dir = $server; + unless ($dir) { + $dir = $server; $server = ''; } - $dir = xCAT::SvrUtils->subVars($dir, $node, 'dir', $callback); - $dir =~ s/\/\//\//g; + $dir = xCAT::SvrUtils->subVars($dir, $node, 'dir', $callback); + $dir =~ s/\/\//\//g; - if($server) { + if ($server) { $server = xCAT::SvrUtils->subVars($server, $node, 'server', $callback); - $server =~ s/\///g; # remove "/" - bug in subVars?? - my $serverIP = xCAT::NetworkUtils->getipaddr($server); - $statemnt = $serverIP . "|" . $dir; + $server =~ s/\///g; # remove "/" - bug in subVars?? + my $serverIP = xCAT::NetworkUtils->getipaddr($server); + $statemnt = $serverIP . "|" . $dir; } else { - $statemnt = $dir; - } - } + $statemnt = $dir; + } + } - my $entry = qq~$node|$statemnt~; - if ($mntopts) { - $entry = qq~$node|$statemnt|$mntopts~; - } - $entry =~ s/\s*//g; #remove blanks + my $entry = qq~$node|$statemnt~; + if ($mntopts) { + $entry = qq~$node|$statemnt|$mntopts~; + } + $entry =~ s/\s*//g; #remove blanks - if ($statemnt) { - print STATELITE $entry . "\n"; - $foundentry++; - } - } - close(STATELITE); + if ($statemnt) { + print STATELITE $entry . "\n"; + $foundentry++; + } + } + close(STATELITE); - if (!$foundentry) { - # don't leave empty file - my $rc = xCAT::Utils->runcmd("rm $statelitetable", -1); + if (!$foundentry) { + + # don't leave empty file + my $rc = xCAT::Utils->runcmd("rm $statelitetable", -1); if ($::RUNCMD_RC != 0) { my $rsp; - push @{$rsp->{data}}, "Could not remove $statelitetable file."; + push @{ $rsp->{data} }, "Could not remove $statelitetable file."; xCAT::MsgUtils->message("E", $rsp, $callback); return 1; } - } + } - unless (open(LITEFILE, ">$litefiletable")) + unless (open(LITEFILE, ">$litefiletable")) { my $rsp; - push @{$rsp->{data}}, "Could not open $litefiletable.\n"; + push @{ $rsp->{data} }, "Could not open $litefiletable.\n"; xCAT::MsgUtils->message("E", $rsp, $callback); return 1; } - my @filelist = xCAT::Utils->runcmd("/opt/xcat/bin/litefile $noderange", -1); - if (scalar(@filelist) > 0) { - foreach my $l (@filelist) { - $l =~ s/://g; # remove ":"'s - $l =~ s/\s+/|/g; # change separator to "|" - print LITEFILE $l . "\n"; - push (@litefiles, $l); - $foundstatelite++; - } - close(LITEFILE); - } else { - close(LITEFILE); - # remove empty files - my $rc = xCAT::Utils->runcmd("rm $litefiletable", -1); + my @filelist = xCAT::Utils->runcmd("/opt/xcat/bin/litefile $noderange", -1); + if (scalar(@filelist) > 0) { + foreach my $l (@filelist) { + $l =~ s/://g; # remove ":"'s + $l =~ s/\s+/|/g; # change separator to "|" + print LITEFILE $l . "\n"; + push(@litefiles, $l); + $foundstatelite++; + } + close(LITEFILE); + } else { + close(LITEFILE); + + # remove empty files + my $rc = xCAT::Utils->runcmd("rm $litefiletable", -1); if ($::RUNCMD_RC != 0) { my $rsp; - push @{$rsp->{data}}, "Could not remove $litefiletable file."; + push @{ $rsp->{data} }, "Could not remove $litefiletable file."; xCAT::MsgUtils->message("E", $rsp, $callback); return 1; } - } - - # need list for just this set of nodes!!! - my $nrange; - my @flist; - my @litef; - if (scalar(@nodel) > 0) - { - $nrange = join(',',@nodel); } - @flist = xCAT::Utils->runcmd("/opt/xcat/bin/litefile $nrange", -1); + # need list for just this set of nodes!!! + my $nrange; + my @flist; + my @litef; + if (scalar(@nodel) > 0) + { + $nrange = join(',', @nodel); + } + + @flist = xCAT::Utils->runcmd("/opt/xcat/bin/litefile $nrange", -1); if (scalar(@flist) > 0) { foreach my $l (@flist) { - my ($j1, $j2, $file) = split /\s+/, $l; - push (@litef, $file); + my ($j1, $j2, $file) = split /\s+/, $l; + push(@litef, $file); } } - my $foundras; - if (scalar(@litef) > 0) { - foreach my $f (@litef) { - chomp $f; - if (($f eq "/var/adm/ras/") || ($f eq "/var/adm/ras/conslog")) { - $foundras++; - } - } - } - if ($foundras) { - my $rsp; - push @{$rsp->{data}}, "One or more nodes is using a persistent \/var\/adm\/ras\/ directory. \nWhen the nodes boot up you will then have to move the conslog file to a \nlocation outside of the persistent directory. (Leaving the conslog \nfile in a persistent directory can occasionally lead to a deadlock situation.) \nThis can be done by using the xdsh command to run swcons on the \ncluster nodes. \n(Ex. xdsh \'\/usr\/sbin\/swcons -p \/tmp\/conslog\') \n"; - xCAT::MsgUtils->message("W", $rsp, $callback); - } + my $foundras; + if (scalar(@litef) > 0) { + foreach my $f (@litef) { + chomp $f; + if (($f eq "/var/adm/ras/") || ($f eq "/var/adm/ras/conslog")) { + $foundras++; + } + } + } + if ($foundras) { + my $rsp; + push @{ $rsp->{data} }, "One or more nodes is using a persistent \/var\/adm\/ras\/ directory. \nWhen the nodes boot up you will then have to move the conslog file to a \nlocation outside of the persistent directory. (Leaving the conslog \nfile in a persistent directory can occasionally lead to a deadlock situation.) \nThis can be done by using the xdsh command to run swcons on the \ncluster nodes. \n(Ex. xdsh \'\/usr\/sbin\/swcons -p \/tmp\/conslog\') \n"; + xCAT::MsgUtils->message("W", $rsp, $callback); + } - unless (open(LITETREE, ">$litetreetable")) + unless (open(LITETREE, ">$litetreetable")) { my $rsp; - push @{$rsp->{data}}, "Could not open $litetreetable.\n"; + push @{ $rsp->{data} }, "Could not open $litetreetable.\n"; xCAT::MsgUtils->message("E", $rsp, $callback); return 1; } - my @treelist = xCAT::Utils->runcmd("/opt/xcat/bin/litetree $noderange", -1); - if (scalar(@treelist) > 0) { - foreach my $l (@treelist) { - my ($p, $serv, $dir, $mopts) = split (/:/, $l); - $p =~ s/\s*//g; - $serv =~ s/\s*//g; - $dir =~ s/\s*//g; - $mopts =~ s/\s*//g; - my $serverIP = xCAT::NetworkUtils->getipaddr($serv); - my $entry = "$p|$serverIP|$dir|$mopts"; - print LITETREE $entry . "\n"; - $foundstatelite++; - } - close(LITETREE); - } else { - close(LITETREE); - # don't leave empty file - my $rc = xCAT::Utils->runcmd("rm $litetreetable", -1); + my @treelist = xCAT::Utils->runcmd("/opt/xcat/bin/litetree $noderange", -1); + if (scalar(@treelist) > 0) { + foreach my $l (@treelist) { + my ($p, $serv, $dir, $mopts) = split(/:/, $l); + $p =~ s/\s*//g; + $serv =~ s/\s*//g; + $dir =~ s/\s*//g; + $mopts =~ s/\s*//g; + my $serverIP = xCAT::NetworkUtils->getipaddr($serv); + my $entry = "$p|$serverIP|$dir|$mopts"; + print LITETREE $entry . "\n"; + $foundstatelite++; + } + close(LITETREE); + } else { + close(LITETREE); + + # don't leave empty file + my $rc = xCAT::Utils->runcmd("rm $litetreetable", -1); if ($::RUNCMD_RC != 0) { my $rsp; - push @{$rsp->{data}}, "Could not remove $litetreetable file."; + push @{ $rsp->{data} }, "Could not remove $litetreetable file."; xCAT::MsgUtils->message("E", $rsp, $callback); return 1; } - } + } - # if there is no statelite info then just return - if (!$foundstatelite) { + # if there is no statelite info then just return + if (!$foundstatelite) { if ($::VERBOSE) { my $rsp; - push @{$rsp->{data}}, "Please update statlite,litefile,litetree tables if you want to use AIX statelite support.\n"; + push @{ $rsp->{data} }, "Please update statlite,litefile,litetree tables if you want to use AIX statelite support.\n"; xCAT::MsgUtils->message("I", $rsp, $callback); - } + } - return 2; - } + return 2; + } - # - # ok - do more statelite setup - # + # + # ok - do more statelite setup + # - # create some local directories in the SPOT - # create .default, .statelite, - if ( ! -d "$instrootloc/.default" ) { - my $mcmd = qq~/bin/mkdir -m 644 -p $instrootloc/.default ~; - my $output = xCAT::Utils->runcmd("$mcmd", -1); + # create some local directories in the SPOT + # create .default, .statelite, + if (!-d "$instrootloc/.default") { + my $mcmd = qq~/bin/mkdir -m 644 -p $instrootloc/.default ~; + my $output = xCAT::Utils->runcmd("$mcmd", -1); if ($::RUNCMD_RC != 0) - { - my $rsp; - push @{$rsp->{data}}, "Could not create $instrootloc/.default.\n"; - xCAT::MsgUtils->message("E", $rsp, $callback); - return 1; - } - } + { + my $rsp; + push @{ $rsp->{data} }, "Could not create $instrootloc/.default.\n"; + xCAT::MsgUtils->message("E", $rsp, $callback); + return 1; + } + } - if ( ! -d "$instrootloc/.statelite" ) { + if (!-d "$instrootloc/.statelite") { my $mcmd = qq~/bin/mkdir -m 644 -p $instrootloc/.statelite ~; my $output = xCAT::Utils->runcmd("$mcmd", -1); if ($::RUNCMD_RC != 0) { my $rsp; - push @{$rsp->{data}}, "Could not create $instrootloc/.statelite.\n"; + push @{ $rsp->{data} }, "Could not create $instrootloc/.statelite.\n"; xCAT::MsgUtils->message("E", $rsp, $callback); return 1; } } - # populate the .defaults dir with files and dirs from the image - if any - my $default="$instrootloc/.default"; + # populate the .defaults dir with files and dirs from the image - if any + my $default = "$instrootloc/.default"; - # read the litefile and try to copy into $default - # everything in the litefile command output should be processed + # read the litefile and try to copy into $default + # everything in the litefile command output should be processed foreach my $line (@litefiles) { + # $file could be full path file name or dir name # ex. /foo/bar/ or /etc/lppcfg - my ($node, $option, $file) = split (/\|/, $line); + my ($node, $option, $file) = split(/\|/, $line); - if (!$file) { - next; - } + if (!$file) { + next; + } # ex. .../inst_root/foo/bar/ or .../inst_root/etc/lppcfg my $instrootfile = $instrootloc . $file; @@ -1152,230 +1161,237 @@ sub dolitesetup # there's one scenario to be handled firstly # in litefile table, there's one entry: /path/to/file, which is one file # however, there's already one directory named "/path/to/file/" - # + # # Or: # the entry in litefile is "/path/to/file/", which is one directory # however, there's already one file named "/path/to/file" - # + # # in these cases, # need to indicate the user there's already one existing file/directory in the spot # then, exit - if ($file =~ m/\/$/ and -f $instrootfile) { + if ($file =~ m/\/$/ and -f $instrootfile) { my $rsp; - push @{$rsp->{data}}, qq{there is already one file named "$file", but the entry in litefile table is set to one directory, please check it}; + push @{ $rsp->{data} }, qq{there is already one file named "$file", but the entry in litefile table is set to one directory, please check it}; xCAT::MsgUtils->message("E", $rsp, $callback); return 1; } if ($file !~ m/\/$/ and -d $instrootfile) { my $rsp; - push @{$rsp->{data}}, qq{there is already one directory named "$file", but the entry in litefile table is set to one file, please check it}; + push @{ $rsp->{data} }, qq{there is already one directory named "$file", but the entry in litefile table is set to one file, please check it}; xCAT::MsgUtils->message("E", $rsp, $callback); return 1; } } - my @copiedfiles; - foreach my $line (@litefiles) { + my @copiedfiles; + foreach my $line (@litefiles) { - # $file could be full path file name or dir name - # ex. /foo/bar/ or /etc/lppcfg - my ($node, $option, $file) = split (/\|/, $line); + # $file could be full path file name or dir name + # ex. /foo/bar/ or /etc/lppcfg + my ($node, $option, $file) = split(/\|/, $line); - # entry must be an absolute path - unless ($file =~ m{^/}) { - my $rsp; - push @{$rsp->{data}}, "The litefile entry \'$file\' is not an absolute path name.\n"; - xCAT::MsgUtils->message("E", $rsp, $callback); - return 1; - } + # entry must be an absolute path + unless ($file =~ m{^/}) { + my $rsp; + push @{ $rsp->{data} }, "The litefile entry \'$file\' is not an absolute path name.\n"; + xCAT::MsgUtils->message("E", $rsp, $callback); + return 1; + } - # ex. /foo or /etc - my $filedir = dirname($file); + # ex. /foo or /etc + my $filedir = dirname($file); - # ex. .../inst_root/foo/bar/ or .../inst_root/etc/lppcfg - my $instrootfile = $instrootloc . $file; + # ex. .../inst_root/foo/bar/ or .../inst_root/etc/lppcfg + my $instrootfile = $instrootloc . $file; - my $cpcmd; - my $mkdircmd; - my $output; + my $cpcmd; + my $mkdircmd; + my $output; - if (!grep (/^$instrootfile$/, @copiedfiles)) { - # don't copy same file twice - push (@copiedfiles, $instrootfile); - if (-e $instrootfile) { + if (!grep (/^$instrootfile$/, @copiedfiles)) { - if (-d $instrootfile) { - # it's a dir so copy everything in it - # ex. mkdir -p ../inst_root/.default/foo/bar - # ex. cp -r .../inst_root/foo/bar/ ../inst_root/.default/foo/bar + # don't copy same file twice + push(@copiedfiles, $instrootfile); + if (-e $instrootfile) { - if ( ! -e "$default$file" ) { # do mkdir - $mkdircmd = qq~mkdir -p $default$file 2>/dev/null~; - $output = xCAT::Utils->runcmd("$mkdircmd", -1); - if ($::RUNCMD_RC != 0) { - my $rsp; - push @{$rsp->{data}}, "Could not copy create $default$file."; - if ($::VERBOSE) - { - push @{$rsp->{data}}, "$output\n"; - } - xCAT::MsgUtils->message("E", $rsp, $callback); - } - } + if (-d $instrootfile) { - # ok - do copy - $cpcmd = qq~cp -p -r $instrootfile* $default$file 2>/dev/null~; - $output = xCAT::Utils->runcmd("$cpcmd", -1); + # it's a dir so copy everything in it + # ex. mkdir -p ../inst_root/.default/foo/bar + # ex. cp -r .../inst_root/foo/bar/ ../inst_root/.default/foo/bar - } else { - # copy file - # ex. mkdir -p ../inst_root/.default/etc - # ex. cp .../inst_root/etc/lppcfg ../inst_root/.default/etc - $cpcmd = qq~mkdir -p $default$filedir; cp -p $instrootfile $default$filedir 2>/dev/null~; - $output = xCAT::Utils->runcmd("$cpcmd", -1); - } - } else { + if (!-e "$default$file") { # do mkdir + $mkdircmd = qq~mkdir -p $default$file 2>/dev/null~; + $output = xCAT::Utils->runcmd("$mkdircmd", -1); + if ($::RUNCMD_RC != 0) { + my $rsp; + push @{ $rsp->{data} }, "Could not copy create $default$file."; + if ($::VERBOSE) + { + push @{ $rsp->{data} }, "$output\n"; + } + xCAT::MsgUtils->message("E", $rsp, $callback); + } + } - # could not find file or dir in ../inst_root (spot dir) - # so create empty file or dir - my $mkcmd; + # ok - do copy + $cpcmd = qq~cp -p -r $instrootfile* $default$file 2>/dev/null~; + $output = xCAT::Utils->runcmd("$cpcmd", -1); - # check if it's a dir - if(grep /\/$/, $file) { - # create dir in .default - if ( ! -d "$default$file" ) { - $mkcmd = qq~mkdir -p $default$file~; - $output = xCAT::Utils->runcmd("$mkcmd", -1); - if ($::RUNCMD_RC != 0) - { - my $rsp; - push @{$rsp->{data}}, "Could not create $default$file.\n"; - if ($::VERBOSE) - { - push @{$rsp->{data}}, "$output\n"; - } - } - } - } else { - # create dir and touch file in .default - my $dir = dirname($file); - if ( ! -d "$default$dir" ) { - $mkcmd = qq~mkdir -p $default$dir~; - $output = xCAT::Utils->runcmd("$mkcmd", -1); + } else { + + # copy file + # ex. mkdir -p ../inst_root/.default/etc + # ex. cp .../inst_root/etc/lppcfg ../inst_root/.default/etc + $cpcmd = qq~mkdir -p $default$filedir; cp -p $instrootfile $default$filedir 2>/dev/null~; + $output = xCAT::Utils->runcmd("$cpcmd", -1); + } + } else { + + # could not find file or dir in ../inst_root (spot dir) + # so create empty file or dir + my $mkcmd; + + # check if it's a dir + if (grep /\/$/, $file) { + + # create dir in .default + if (!-d "$default$file") { + $mkcmd = qq~mkdir -p $default$file~; + $output = xCAT::Utils->runcmd("$mkcmd", -1); if ($::RUNCMD_RC != 0) { my $rsp; - push @{$rsp->{data}}, "Could not create $default$dir."; + push @{ $rsp->{data} }, "Could not create $default$file.\n"; if ($::VERBOSE) { - push @{$rsp->{data}}, "$output\n"; + push @{ $rsp->{data} }, "$output\n"; } } - } + } + } else { - # touch the file - my $tcmd = qq~touch $default$file~; - $output = xCAT::Utils->runcmd("$tcmd", -1); - if ($::RUNCMD_RC != 0) - { - my $rsp; - push @{$rsp->{data}}, "Could not create $default$file.\n"; - if ($::VERBOSE) - { - push @{$rsp->{data}}, "$output\n"; - } - xCAT::MsgUtils->message("E", $rsp, $callback); - } - } - } # end - if not exist in spot - } # end - if not already copied - } # end - for each line in litefile + # create dir and touch file in .default + my $dir = dirname($file); + if (!-d "$default$dir") { + $mkcmd = qq~mkdir -p $default$dir~; + $output = xCAT::Utils->runcmd("$mkcmd", -1); + if ($::RUNCMD_RC != 0) + { + my $rsp; + push @{ $rsp->{data} }, "Could not create $default$dir."; + if ($::VERBOSE) + { + push @{ $rsp->{data} }, "$output\n"; + } + } + } - # add aixlitesetup to ..inst_root/aixlitesetup - # this will wind up in the root dir on the node ("/") - my $install_dir = xCAT::TableUtils->getInstallDir(); - my $cpcmd = "/bin/cp $install_dir/postscripts/aixlitesetup $instrootloc/aixlitesetup; chmod +x $instrootloc/aixlitesetup"; + # touch the file + my $tcmd = qq~touch $default$file~; + $output = xCAT::Utils->runcmd("$tcmd", -1); + if ($::RUNCMD_RC != 0) + { + my $rsp; + push @{ $rsp->{data} }, "Could not create $default$file.\n"; + if ($::VERBOSE) + { + push @{ $rsp->{data} }, "$output\n"; + } + xCAT::MsgUtils->message("E", $rsp, $callback); + } + } + } # end - if not exist in spot + } # end - if not already copied + } # end - for each line in litefile - my $out = xCAT::Utils->runcmd("$cpcmd", -1); + # add aixlitesetup to ..inst_root/aixlitesetup + # this will wind up in the root dir on the node ("/") + my $install_dir = xCAT::TableUtils->getInstallDir(); + my $cpcmd = "/bin/cp $install_dir/postscripts/aixlitesetup $instrootloc/aixlitesetup; chmod +x $instrootloc/aixlitesetup"; + + my $out = xCAT::Utils->runcmd("$cpcmd", -1); if ($::RUNCMD_RC != 0) { my $rsp; - push @{$rsp->{data}}, "Could not copy aixlitesetup."; + push @{ $rsp->{data} }, "Could not copy aixlitesetup."; xCAT::MsgUtils->message("E", $rsp, $callback); return 1; } - # if this is an update then we need to copy the new files to - # the shared_root location - # ??? - maybe we should try this all the time???? - if (1) { - # if we have a shared_root resource - if ($imghash{$imagename}{shared_root} ) { - my $nimprime = xCAT::InstUtils->getnimprime(); - chomp $nimprime; - # get the location of the shared_root directory - my $SRloc = xCAT::InstUtils->get_nim_attr_val($imghash{$imagename}{shared_root}, 'location', $callback, $Sname, $subreq); + # if this is an update then we need to copy the new files to + # the shared_root location + # ??? - maybe we should try this all the time???? + if (1) { - # copy the statelite table file to the shared root location - # this will not effect any running nodes that are using - # this shared_root resource. However the new table will - # include any info need for existing nodes - for when they - # need to be rebooted + # if we have a shared_root resource + if ($imghash{$imagename}{shared_root}) { + my $nimprime = xCAT::InstUtils->getnimprime(); + chomp $nimprime; - if (-d $SRloc) { - my $ccmd = "/bin/cp"; - if (-e $statelitetable) - { - $ccmd .= " $statelitetable"; - } + # get the location of the shared_root directory + my $SRloc = xCAT::InstUtils->get_nim_attr_val($imghash{$imagename}{shared_root}, 'location', $callback, $Sname, $subreq); - if (-e $litefiletable) - { - $ccmd .= " $litefiletable"; - } + # copy the statelite table file to the shared root location + # this will not effect any running nodes that are using + # this shared_root resource. However the new table will + # include any info need for existing nodes - for when they + # need to be rebooted - if (-e $litetreetable) - { - $ccmd .= " $litetreetable"; - } - - $ccmd .= " $instrootloc/aixlitesetup $SRloc"; - my $out = xCAT::Utils->runcmd("$ccmd", -1); - if ($::RUNCMD_RC != 0) - { - my $rsp; - push @{$rsp->{data}}, "Could not copy statelite files to $SRloc."; - xCAT::MsgUtils->message("E", $rsp, $callback); - return 1; - } + if (-d $SRloc) { + my $ccmd = "/bin/cp"; + if (-e $statelitetable) + { + $ccmd .= " $statelitetable"; + } - # also copy $instrootloc/.default contents - $ccmd = "/usr/bin/cp -p -r $instrootloc/.default $SRloc"; - $out = xCAT::Utils->runcmd("$ccmd", -1); - if ($::RUNCMD_RC != 0) - { - my $rsp; - push @{$rsp->{data}}, "Could not copy $instrootloc/.default to $SRloc."; - xCAT::MsgUtils->message("E", $rsp, $callback); - return 1; - } + if (-e $litefiletable) + { + $ccmd .= " $litefiletable"; + } - # also copy $instrootloc/.statelite contents - $ccmd = "/usr/bin/cp -p -r $instrootloc/.statelite $SRloc"; - $out = xCAT::Utils->runcmd("$ccmd", -1); - if ($::RUNCMD_RC != 0) - { - my $rsp; - push @{$rsp->{data}}, "Could not copy $instrootloc/.statelite to $SRloc."; - xCAT::MsgUtils->message("E", $rsp, $callback); - return 1; - } - } - } - } - return 0; + if (-e $litetreetable) + { + $ccmd .= " $litetreetable"; + } + + $ccmd .= " $instrootloc/aixlitesetup $SRloc"; + my $out = xCAT::Utils->runcmd("$ccmd", -1); + if ($::RUNCMD_RC != 0) + { + my $rsp; + push @{ $rsp->{data} }, "Could not copy statelite files to $SRloc."; + xCAT::MsgUtils->message("E", $rsp, $callback); + return 1; + } + + # also copy $instrootloc/.default contents + $ccmd = "/usr/bin/cp -p -r $instrootloc/.default $SRloc"; + $out = xCAT::Utils->runcmd("$ccmd", -1); + if ($::RUNCMD_RC != 0) + { + my $rsp; + push @{ $rsp->{data} }, "Could not copy $instrootloc/.default to $SRloc."; + xCAT::MsgUtils->message("E", $rsp, $callback); + return 1; + } + + # also copy $instrootloc/.statelite contents + $ccmd = "/usr/bin/cp -p -r $instrootloc/.statelite $SRloc"; + $out = xCAT::Utils->runcmd("$ccmd", -1); + if ($::RUNCMD_RC != 0) + { + my $rsp; + push @{ $rsp->{data} }, "Could not copy $instrootloc/.statelite to $SRloc."; + xCAT::MsgUtils->message("E", $rsp, $callback); + return 1; + } + } + } + } + return 0; } #---------------------------------------------------------------------------- @@ -1392,7 +1408,7 @@ sub dolitesetup sub convert_xcatmaster { my $shorthost = xCAT::InstUtils->myxCATname(); - my $selfip = xCAT::NetworkUtils->getipaddr($shorthost); + my $selfip = xCAT::NetworkUtils->getipaddr($shorthost); return $selfip; } diff --git a/perl-xCAT/xCAT/KitPluginUtils.pm b/perl-xCAT/xCAT/KitPluginUtils.pm index 5a612d69e..082c93b65 100644 --- a/perl-xCAT/xCAT/KitPluginUtils.pm +++ b/perl-xCAT/xCAT/KitPluginUtils.pm @@ -49,15 +49,15 @@ sub get_kits_used_by_nodes { # Group the nodes by what osimage they use my $tablename = "nodetype"; - my $table = xCAT::Table->new($tablename); - my $ent = $table->getNodesAttribs($nodes, ["provmethod"]); - + my $table = xCAT::Table->new($tablename); + my $ent = $table->getNodesAttribs($nodes, ["provmethod"]); + my $osimage_to_nodes = {}; foreach my $node (keys(%$ent)) { my $provmethod = $ent->{$node}->[0]->{"provmethod"}; if (defined($provmethod)) { push(@{ $osimage_to_nodes->{$provmethod} }, $node); - } + } } # Group the osimages by what kits they use @@ -68,9 +68,10 @@ sub get_kits_used_by_nodes { # Group nodes by kit my $kits_to_nodes = {}; foreach my $kit (keys(%$kits_to_osimages)) { - my $tmphash = {}; + my $tmphash = {}; my $osimages = $kits_to_osimages->{$kit}; foreach my $osimage (@$osimages) { + # Store nodes as hash keys to eliminate duplicates my @nodes = @{ $osimage_to_nodes->{$osimage} }; @$tmphash{@nodes} = (); @@ -111,14 +112,14 @@ sub get_kits_used_by_nodes { sub get_kits_used_by_osimages { - my $class = shift; + my $class = shift; my $osimages = shift; # Get the kit components used by each osimage my $tablename = "osimage"; - my $table = xCAT::Table->new($tablename); + my $table = xCAT::Table->new($tablename); - my $osimages_str = join ",", map {'\''.$_.'\''} @$osimages; + my $osimages_str = join ",", map { '\'' . $_ . '\'' } @$osimages; my $filter_stmt = sprintf("imagename in (%s)", $osimages_str); my @table_rows = $table->getAllAttribsWhere($filter_stmt, ("imagename", "kitcomponents")); @@ -134,15 +135,15 @@ sub get_kits_used_by_osimages { # Get the kit for each kit component $tablename = "kitcomponent"; - $table = xCAT::Table->new($tablename); + $table = xCAT::Table->new($tablename); - my $kitcomps_str = join ",", map {'\''.$_.'\''} keys(%$kitcomps_to_osimages); + my $kitcomps_str = join ",", map { '\'' . $_ . '\'' } keys(%$kitcomps_to_osimages); $filter_stmt = sprintf("kitcompname in (%s)", $kitcomps_str); @table_rows = $table->getAllAttribsWhere($filter_stmt, ("kitcompname", "kitname")); my $kits_to_kitcomps = {}; foreach my $row (@table_rows) { - my $kitname = $row->{kitname}; + my $kitname = $row->{kitname}; my $kitcompname = $row->{kitcompname}; push(@{ $kits_to_kitcomps->{$kitname} }, $kitcompname); } @@ -151,9 +152,10 @@ sub get_kits_used_by_osimages { my $kits_to_osimages = {}; foreach my $kit (keys(%$kits_to_kitcomps)) { - my $tmphash = {}; + my $tmphash = {}; my $kitcomps = $kits_to_kitcomps->{$kit}; foreach my $kitcomp (@$kitcomps) { + # Store osimages as hash keys to eliminate duplicates my @osimages = @{ $kitcomps_to_osimages->{$kitcomp} }; @$tmphash{@osimages} = (); diff --git a/perl-xCAT/xCAT/LparNetbootExp.pm b/perl-xCAT/xCAT/LparNetbootExp.pm index 1a7e0960b..56a47ce34 100755 --- a/perl-xCAT/xCAT/LparNetbootExp.pm +++ b/perl-xCAT/xCAT/LparNetbootExp.pm @@ -67,16 +67,16 @@ my $server_ip; # the script searches for in the device tree listing. dev_type is the type # of device displayed in the output. my @dev_pat = ( - "ethernet", - "token-ring", - "fddi" - ); + "ethernet", + "token-ring", + "fddi" +); my @dev_type = ( - "ent", - "tok", - "fddi" - ); -my $dev_count = scalar(@dev_type); #number of supported device type + "ent", + "tok", + "fddi" +); +my $dev_count = scalar(@dev_type); #number of supported device type #------------------------------------------------------------------------------- @@ -96,19 +96,20 @@ my $dev_count = scalar(@dev_type); #number of supported device type sub nc_msg { my $verbose = shift; - my $msg = shift; + my $msg = shift; my $rsp; - if ( $verbose eq 1 ) { + if ($verbose eq 1) { $rsp->{data}->[0] = $msg; - xCAT::MsgUtils->message("I", $rsp ,$::CALLBACK); + xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); } - if ( $verbose eq 2 ) { + if ($verbose eq 2) { $rsp->{data}->[0] = $msg; - xCAT::MsgUtils->message("E", $rsp ,$::CALLBACK); + xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); } } + #------------------------------------------------------------------------------- =head3 run_lssyscfg @@ -128,7 +129,7 @@ sub run_lssyscfg $req = shift; } my $verbose = shift; - my $node = shift; + my $node = shift; my $cmd; my $out; @@ -138,15 +139,15 @@ sub run_lssyscfg node => [$node], arg => ['state'] }, - $req, 0, 1); - if ($::RUNCMD_RC != 0) { + $req, 0, 1); + if ($::RUNCMD_RC != 0) { nc_msg($verbose, "Unable to run rpower $node state.\n"); return undef; } my $output = join ',', @$out; nc_msg($verbose, "Status: run_lssyscg : partition status : $output\n"); - nc_msg($verbose, "####msg:$output#########\n" ); + nc_msg($verbose, "####msg:$output#########\n"); ################################################################### @@ -207,6 +208,7 @@ sub usage { return 0; } + #------------------------------------------------------------------------------- =head3 ck_args @@ -227,35 +229,35 @@ sub ck_args { $opt = shift; } my $verbose = shift; - my $node = $opt->{node}; - my $mtms = $opt->{fsp}; - my $hcp = $opt->{hcp}; - my $lparid = $opt->{id}; + my $node = $opt->{node}; + my $mtms = $opt->{fsp}; + my $hcp = $opt->{hcp}; + my $lparid = $opt->{id}; my $profile = $opt->{pprofile}; - if (exists( $opt->{D}) and !exists($opt->{noping}) and (!exists ($opt->{s}) or !exists ($opt->{d} ))) { + if (exists($opt->{D}) and !exists($opt->{noping}) and (!exists($opt->{s}) or !exists($opt->{d}))) { nc_msg($verbose, "Speed and duplex required\n"); usage; return 1; } - if (exists ($opt->{D}) and !exists($opt->{noping}) and !exists ($opt->{C})) { + if (exists($opt->{D}) and !exists($opt->{noping}) and !exists($opt->{C})) { nc_msg($verbose, "Client IP is required\n"); usage; return 1; } - if (exists( $opt->{D}) and !exists($opt->{noping}) and !exists($opt->{S})) { + if (exists($opt->{D}) and !exists($opt->{noping}) and !exists($opt->{S})) { nc_msg($verbose, "Server IP is required\n"); usage; return 1; } - if (exists( $opt->{D}) and !exists($opt->{noping}) and !exists($opt->{G})) { + if (exists($opt->{D}) and !exists($opt->{noping}) and !exists($opt->{G})) { nc_msg($verbose, "Gateway IP is required\n"); usage; return 1; } - unless($node) { + unless ($node) { nc_msg($verbose, "Node is required\n"); usage; return 1; @@ -263,7 +265,7 @@ sub ck_args { nc_msg($verbose, "Node is $node\n"); } - unless($mtms) { + unless ($mtms) { nc_msg($verbose, "Managed system is required\n"); usage; return 1; @@ -324,13 +326,13 @@ sub ck_args { return 1; } - if ($opt->{M} and $opt->{D} and !exists($opt->{noping}) and (!exists($opt->{S}) or !exists($opt->{G}) or !exists($opt->{C}) or !exists( $opt->{s}) or !exists($opt->{d}))) { + if ($opt->{M} and $opt->{D} and !exists($opt->{noping}) and (!exists($opt->{S}) or !exists($opt->{G}) or !exists($opt->{C}) or !exists($opt->{s}) or !exists($opt->{d}))) { nc_msg($verbose, "Flag -M with -D require arguments for -C, -S, -G, -s and -d.\n"); usage; return 1; } - if ($opt->{M} and !exists($opt->{D}) and (!exists($opt->{S}) or !exists($opt->{G}) or !exists($opt->{C}) or !exists($opt->{s}) or !exists($opt->{d}))){ + if ($opt->{M} and !exists($opt->{D}) and (!exists($opt->{S}) or !exists($opt->{G}) or !exists($opt->{C}) or !exists($opt->{s}) or !exists($opt->{d}))) { nc_msg($verbose, "Flag -M with arguments for -C, -S, -G, -s and -d require -D flag.\n"); usage; return 1; @@ -383,10 +385,10 @@ sub ck_args { #----------------------------------------------------------------------------- -sub send_command { - my $verbose = shift; +sub send_command { + my $verbose = shift; my $rconsole = shift; - my $cmd = shift; + my $cmd = shift; nc_msg($verbose, "sending commands $cmd to expect \n"); my $msg; @@ -415,10 +417,10 @@ sub send_command { sub get_phandle { my $rconsole = shift; - my $node = shift; - my $verbose = shift; - my $timeout = 30; - my $done = 0; + my $node = shift; + my $verbose = shift; + my $timeout = 30; + my $done = 0; my @result; my $expect_out; my $retry_count; @@ -434,39 +436,40 @@ sub get_phandle { # The pwd command can be used to determine what the current device is. # - send_command($verbose, $rconsole, "dev /\r"); + send_command($verbose, $rconsole, "dev /\r"); @result = $rconsole->expect( $timeout, - [qr/ok/=> - sub { - nc_msg($verbose, "Status: at root\n"); - $rconsole->clear_accum(); - } + [ qr/ok/ => + sub { + nc_msg($verbose, "Status: at root\n"); + $rconsole->clear_accum(); + } ], - [qr/]/=> - sub { - nc_msg($verbose, "Unexpected prompt\n"); - $rconsole->clear_accum(); - $rc = 1; - } + [ qr/]/ => + sub { + nc_msg($verbose, "Unexpected prompt\n"); + $rconsole->clear_accum(); + $rc = 1; + } ], - [timeout => - sub { - $rconsole->send("\r"); - $rconsole->clear_accum(); - $rc = 1; - } + [ timeout => + sub { + $rconsole->send("\r"); + $rconsole->clear_accum(); + $rc = 1; + } ], - [eof => - sub { - nc_msg($verbose, "Cannot connect to $node"); - $rconsole->clear_accum(); - $rc = 1; - } + [ eof => + sub { + nc_msg($verbose, "Cannot connect to $node"); + $rconsole->clear_accum(); + $rc = 1; + } ], ); return 1 if ($rc eq 1); + # Next, the 'ls' command is sent. The result is a display of the entire # device tree. The code then looks at the # output from the ls command one line at a time, trying to match it with the @@ -501,11 +504,12 @@ sub get_phandle { # Using the -d flag helped a lot in finding the correct pattern. # - send_command($verbose, $rconsole, "ls \r"); + send_command($verbose, $rconsole, "ls \r"); $timeout = 60; - $done = 0; + $done = 0; while (!$done) { + # this expect call isolates single lines # This code uses the tcl regexp to parse the single line # isolated by expect. @@ -519,72 +523,75 @@ sub get_phandle { @result = (); @result = $rconsole->expect( $timeout, - [qr/(\n)([^\r]*)(\r)/=> - sub { - nc_msg($verbose, "Parsing network adapters... \n"); - #$rconsole->clear_accum(); - } + [ qr/(\n)([^\r]*)(\r)/ => + sub { + nc_msg($verbose, "Parsing network adapters... \n"); + + #$rconsole->clear_accum(); + } ], - [qr/>/=> - sub { - nc_msg($verbose, "finished \n"); - $rconsole->clear_accum(); - $done = 1; - } + [ qr/>/ => + sub { + nc_msg($verbose, "finished \n"); + $rconsole->clear_accum(); + $done = 1; + } ], - [timeout=> - sub { - nc_msg($verbose, "Timeout isolating single line of ls output\n"); - $rconsole->clear_accum(); - $rc = 1; - } + [ timeout => + sub { + nc_msg($verbose, "Timeout isolating single line of ls output\n"); + $rconsole->clear_accum(); + $rc = 1; + } ], - [eof => - sub { - nc_msg($verbose, "Cannot connect to $node"); - $rconsole->clear_accum(); - $rc = 1; - } + [ eof => + sub { + nc_msg($verbose, "Cannot connect to $node"); + $rconsole->clear_accum(); + $rc = 1; + } ], ); return 1 if ($rc eq 1); if ($result[2] =~ /(\w*)\:(\s*)\/(\S*)/) { my $x1 = $1; - my $x2 = $2; #number of space - my $x3 = $3; #device - # Each level is inspected for a match - my $level = (length($x2)-1)/2; + my $x2 = $2; #number of space + my $x3 = $3; #device + # Each level is inspected for a match + my $level = (length($x2) - 1) / 2; $path{$level} = $x3; my $j = 0; - for ($j = 0; $j < $dev_count; $j++) { + for ($j = 0 ; $j < $dev_count ; $j++) { if ($x3 =~ /$dev_pat[$j]/) { - if ( $x3 =~ /hfi-ethernet/ and $dev_pat[$j] eq "ethernet" ){ + if ($x3 =~ /hfi-ethernet/ and $dev_pat[$j] eq "ethernet") { next; } my $i = 0; - for ($i = 0; $i <= $level; $i++) + for ($i = 0 ; $i <= $level ; $i++) { $full_path_name_array[$adapter_found] .= "/" . $path{$i}; } $phandle_array[$adapter_found] = $x1; - $adap_type[$adapter_found] = $dev_type[$j]; - $adapter_found ++; + $adap_type[$adapter_found] = $dev_type[$j]; + $adapter_found++; last; } } } } + # Did we find one or more adapters? - if ( $adapter_found > 0 ) { + if ($adapter_found > 0) { return 0; } else { - nc_msg($verbose, "No network adapters found\n" ); + nc_msg($verbose, "No network adapters found\n"); return 1; } } + #------------------------------------------------------------------------------- =head3 get_adap_prop @@ -601,14 +608,14 @@ sub get_phandle { =cut #----------------------------------------------------------------------------- -sub get_adap_prop { - my $phandle = shift; +sub get_adap_prop { + my $phandle = shift; my $rconsole = shift; - my $node = shift; - my $verbose = shift; - my $timeout = 120; - my $rc = 0; - my $state = 0; + my $node = shift; + my $verbose = shift; + my $timeout = 120; + my $rc = 0; + my $state = 0; my @cmd; my @done; my @msg; @@ -627,140 +634,149 @@ sub get_adap_prop { $done[0] = 0; $cmd[0] = "\" supported-network-types\" " . $phandle . " get-package-property\r"; $msg[0] = "Status: rc and all supported network types now on stack\n"; + #$pattern[0] = "(.*)3 >(.*)"; #$pattern[0] = "3 >"; - $pattern[0] = "ok"; + $pattern[0] = "ok"; $newstate[0] = 1; # state 1, return code and string on stack $done[1] = 0; - $cmd[1] = ".\r"; - $msg[1] = "Status: All supported network types now on stack\n"; + $cmd[1] = ".\r"; + $msg[1] = "Status: All supported network types now on stack\n"; + #$pattern[1] = "(.*)2 >(.*)"; #$pattern[1] = "2 >"; - $pattern[1] = "ok"; + $pattern[1] = "ok"; $newstate[1] = 2; # state 2, data ready to decode $done[2] = 0; - $cmd[2] = "decode-string\r"; - $msg[2] = "Status: supported network type isolated on stack\n"; + $cmd[2] = "decode-string\r"; + $msg[2] = "Status: supported network type isolated on stack\n"; + #$pattern[2] = "(.*)ok(.*)4 >(.*)"; - $pattern[2] = "4 >"; + $pattern[2] = "4 >"; $newstate[2] = 3; # state 3, decoded string on stack - $done[3]= 0; - $cmd[3] = "dump\r"; - $msg[3] = "Status: supported network type off stack\n"; + $done[3] = 0; + $cmd[3] = "dump\r"; + $msg[3] = "Status: supported network type off stack\n"; + #$pattern[3] = ".*:.*:(.*):.*:.*:(.*):.*(2 >)(.*)"; - $pattern[3] = "ok"; + $pattern[3] = "ok"; $newstate[3] = 4; # state 4, need to check for more data to decode $done[4] = 0; - $cmd[4] = ".s\r"; - $msg[4] = "Status: checking for more supported network types\n"; + $cmd[4] = ".s\r"; + $msg[4] = "Status: checking for more supported network types\n"; + #$pattern[4] = ".s (\[0-9a-f]* )(.*)>"; - $pattern[4] = "ok"; - $newstate[4]= 5; + $pattern[4] = "ok"; + $newstate[4] = 5; # state 5, done decoding string, clear stack $done[5] = 0; $cmd[5] = ".\r"; $msg[5] = "Status: one entry on stack cleared\n"; + #$pattern[5] = "(.*)ok(.*)1 >(.*)"; - $pattern[5] = "ok"; + $pattern[5] = "ok"; $newstate[5] = 6; # state 6, finish clearing stack, choose correct adapter type - $done[6]= 0; - $cmd[6] = ".\r"; - $msg[6] = "Status: finished clearing stack\n"; + $done[6] = 0; + $cmd[6] = ".\r"; + $msg[6] = "Status: finished clearing stack\n"; + #$pattern[6] = "(.*)ok(.*)0 >(.*)"; - $pattern[6] = "ok"; - $newstate[6]= 7; + $pattern[6] = "ok"; + $newstate[6] = 7; # state 7, done $done[7] = 1; - while($done[$state] eq 0) { + while ($done[$state] eq 0) { nc_msg($verbose, "Status: command is $cmd[$state]\n"); send_command($verbose, $rconsole, $cmd[$state]); @result = (); @result = $rconsole->expect( - $timeout, - [ qr/$pattern[$state]/i, - sub { - if ($state eq 1) { - if ($rconsole->before() =~ /-\d+/) { - nc_msg($verbose, "Status: Error getting adapter property for phandle=$phandle.\n"); - $state = 7; - $rconsole->clear_accum(); - $rc = 1; - return 1; + $timeout, + [ qr/$pattern[$state]/i, + sub { + if ($state eq 1) { + if ($rconsole->before() =~ /-\d+/) { + nc_msg($verbose, "Status: Error getting adapter property for phandle=$phandle.\n"); + $state = 7; + $rconsole->clear_accum(); + $rc = 1; + return 1; + } } - } - nc_msg($verbose, $msg[$state]); - $state = $newstate[$state]; - $rconsole->clear_accum(); - } - ], - [ qr/]/, - sub { - nc_msg($verbose, "Unexpected prompt\n"); - $rconsole->clear_accum(); - $rc = 1; - } - ], - [ qr/(.*)DEFAULT(.*)/, - sub { - nc_msg($verbose, " Default catch error\n"); - $rconsole->clear_accum(); - $rc = 1; - } - ], - [ timeout=> - sub { - nc_msg($verbose, "Timeout in getting adapter properpties\n"); - $rconsole->clear_accum(); - $rc = 1; - } - ], - [ eof => - sub { - nc_msg($verbose, "Cannot connect to $node\n"); - $rconsole->clear_accum(); - $rc = 1; - } - ] + nc_msg($verbose, $msg[$state]); + $state = $newstate[$state]; + $rconsole->clear_accum(); + } + ], + [ qr/]/, + sub { + nc_msg($verbose, "Unexpected prompt\n"); + $rconsole->clear_accum(); + $rc = 1; + } + ], + [ qr/(.*)DEFAULT(.*)/, + sub { + nc_msg($verbose, " Default catch error\n"); + $rconsole->clear_accum(); + $rc = 1; + } + ], + [ timeout => + sub { + nc_msg($verbose, "Timeout in getting adapter properpties\n"); + $rconsole->clear_accum(); + $rc = 1; + } + ], + [ eof => + sub { + nc_msg($verbose, "Cannot connect to $node\n"); + $rconsole->clear_accum(); + $rc = 1; + } + ] ); return 1 if ($rc eq 1); + # After state 3, the network type is parsed and the connector # type extracted. If the type hasn't been found, add it to # the list of supported connector types. - if ( $state eq 4 ) { + if ($state eq 4) { + # Build the adapter properties from the string #regexp .*,(.*),(.*),(.*) $nw_type dummy nw_speed nw_conn nw_duplex #set adap_prop "$nw_speed,$nw_conn,$nw_duplex" #nc_msg "Status: Adapter properties are $adap_prop\n" # if it's not in the list, add it, otherwise continue - if ( $result[3] =~ /(\w*):(.*):(\w*)\,(\w*)\,(\w*):/) { - $nw_type = $3; + if ($result[3] =~ /(\w*):(.*):(\w*)\,(\w*)\,(\w*):/) { + $nw_type = $3; $nw_speed = $4; - $nw_conn = $5; + $nw_conn = $5; nc_msg($verbose, "nwtype is $3, nwspeed is $4, nwconn is $5\n"); } - if ( $result[3] =~ /(\w*):(.*):(\w*)\,(\w*):/) { + if ($result[3] =~ /(\w*):(.*):(\w*)\,(\w*):/) { $nw_duplex = $4; nc_msg($verbose, "nwduplex is $4\n"); } } #push @adap_prop_array, $nw_type.",".$nw_speed.",".$nw_conn.",".$nw_duplex; - push @adap_prop_array, $nw_speed.",".$nw_conn.",".$nw_duplex; + push @adap_prop_array, $nw_speed . "," . $nw_conn . "," . $nw_duplex; nc_msg($verbose, "Status: Adding adapter properties to list\n"); # After state 4, a test is done to see if all of the supported @@ -768,8 +784,8 @@ sub get_adap_prop { # state variable is left alone. if not, the state variable is # set to 2, causing a loop back to the step where the # decode-string command is sent. - if ( $state eq 5 ) { - if ($result[3] =~/2 > \.s \w+ (\w*)/) { + if ($state eq 5) { + if ($result[3] =~ /2 > \.s \w+ (\w*)/) { $state = 2 if ($1 != 0); } } @@ -806,12 +822,12 @@ sub get_adap_prop { #----------------------------------------------------------------------------- sub get_mac_addr { - my $phandle = shift; + my $phandle = shift; my $rconsole = shift; - my $node = shift; - my $verbose = shift; - my $timeout = 60; - my $state = 0; + my $node = shift; + my $verbose = shift; + my $timeout = 60; + my $state = 0; my @result; my $mac_rc; my @cmd; @@ -836,21 +852,22 @@ sub get_mac_addr { # are 3 stack entries (return code, address and length of mac-address). # state 0, stack count 0, send command $done[0] = 0; - $cmd[0] = "\" local-mac-address\" ". $phandle . " get-package-property\r"; - $msg[0] = "Status: return code and mac-address now on stack\n"; - $pattern[0] = "local-mac-address.*ok";#"\s*3 >"; + $cmd[0] = "\" local-mac-address\" " . $phandle . " get-package-property\r"; + $msg[0] = "Status: return code and mac-address now on stack\n"; + $pattern[0] = "local-mac-address.*ok"; #"\s*3 >"; $newstate[0] = 1; # cmd(1) is a dot (.). This is a stack manipulation command that removes one # thing from the stack. pattern(1) is looking for a prompt with the 2 indicating # that there are 2 things left on the stack. # state 1, return code and mac-address on stack - $done[1]= 0; - $cmd[1] = ".\r"; - $msg[1] = "Status: mac-address now on stack\n"; + $done[1] = 0; + $cmd[1] = ".\r"; + $msg[1] = "Status: mac-address now on stack\n"; + #$pattern[1] = "(.*)2 >(.*)"; - $pattern[1] = "ok"; #"2 >"; - $newstate[1]= 2; + $pattern[1] = "ok"; #"2 >"; + $newstate[1] = 2; # cmd(2) is the dump command. This takes an address and a length off the stack # and displays the contents of that storage in ascii and hex. The long pattern @@ -858,7 +875,7 @@ sub get_mac_addr { # used to eliminate the spaces put in by the dump command. # state 2, mac-address on stack $done[2] = 0; - $cmd[2] = ": dump-mac ( prop-addr prop-len -- ) \ + $cmd[2] = ": dump-mac ( prop-addr prop-len -- ) \ cr \ dup decode-bytes 2swap 2drop ( data-addr data-len ) \ ( data-len ) 0 ?do \ @@ -868,111 +885,114 @@ sub get_mac_addr { drop \ cr \ ; \r"; - $msg[2] = "Status: set command\n"; - $pattern[2] = "ok"; - $newstate[2]= 3; + $msg[2] = "Status: set command\n"; + $pattern[2] = "ok"; + $newstate[2] = 3; - $done[3]= 0; - $cmd[3] = "dump-mac\r"; - $msg[3] = "Status: mac-address displayed, stack empty\n"; - $pattern[3] = "dump-mac(\\s*)(\\w*)(\\s*)ok"; - $newstate[3] = 4 ; + $done[3] = 0; + $cmd[3] = "dump-mac\r"; + $msg[3] = "Status: mac-address displayed, stack empty\n"; + $pattern[3] = "dump-mac(\\s*)(\\w*)(\\s*)ok"; + $newstate[3] = 4; # state 4, all done $done[4] = 1; - while($done[$state] eq 0) { + while ($done[$state] eq 0) { @result = (); send_command($verbose, $rconsole, $cmd[$state]); @result = $rconsole->expect( $timeout, - [qr/$pattern[$state]/=> - sub { - if ($state eq 1) { - if ($rconsole->before() =~ /-\d+/) { - nc_msg($verbose, "Status: Error getting MAC address for phandle=$phandle.\n"); - $rconsole->clear_accum(); - $state = 4; - $rc = 1; - return undef; + [ qr/$pattern[$state]/ => + sub { + if ($state eq 1) { + if ($rconsole->before() =~ /-\d+/) { + nc_msg($verbose, "Status: Error getting MAC address for phandle=$phandle.\n"); + $rconsole->clear_accum(); + $state = 4; + $rc = 1; + return undef; + } } - } - nc_msg($verbose, $msg[$state]); - $state = $newstate[$state]; - $rconsole->clear_accum(); - } + nc_msg($verbose, $msg[$state]); + $state = $newstate[$state]; + $rconsole->clear_accum(); + } ], - [qr/1 > /=> - sub { - $rconsole->clear_accum(); - if( $state eq 0 ) { - # An error occurred while obtaining the mac address. Log the error, - # but don't quit nodecond. instead, return NA for the address - # - send_command($verbose, $rconsole, ".\r"); - $rconsole->expect( - $timeout, - #[ qr/(-*\[0-9\]*) ok(.*)0 >(.*)/i, - [ qr/0 >/i, - sub { - #$mac_rc = $expect_out; - nc_msg($verbose, "Status: Error getting MAC address for phandle=$phandle. RC=$mac_rc.\n"); - nc_msg($verbose, "Could not obtain MAC address; setting MAX to NA\n" ); - $rconsole->clear_accum(); - $rc = 1; - } - ], - [ timeout=> - sub { - nc_msg($verbose, "Timeout when getting mac address\n"); - $rconsole->clear_accum(); - $rc = 1; - } - ], - [ eof => - sub { - nc_msg($verbose, " Cannot connect to $node\n"); - $rconsole->clear_accum(); - $rc = 1; - } - ] - ); - } - } + [ qr/1 > / => + sub { + $rconsole->clear_accum(); + if ($state eq 0) { + + # An error occurred while obtaining the mac address. Log the error, + # but don't quit nodecond. instead, return NA for the address + # + send_command($verbose, $rconsole, ".\r"); + $rconsole->expect( + $timeout, + + #[ qr/(-*\[0-9\]*) ok(.*)0 >(.*)/i, + [ qr/0 >/i, + sub { + #$mac_rc = $expect_out; + nc_msg($verbose, "Status: Error getting MAC address for phandle=$phandle. RC=$mac_rc.\n"); + nc_msg($verbose, "Could not obtain MAC address; setting MAX to NA\n"); + $rconsole->clear_accum(); + $rc = 1; + } + ], + [ timeout => + sub { + nc_msg($verbose, "Timeout when getting mac address\n"); + $rconsole->clear_accum(); + $rc = 1; + } + ], + [ eof => + sub { + nc_msg($verbose, " Cannot connect to $node\n"); + $rconsole->clear_accum(); + $rc = 1; + } + ] + ); + } + } ], - [qr/]/=> - sub { - nc_msg($verbose, "Unexpected prompt\n"); - $rconsole->clear_accum(); - $rc = 1; - } + [ qr/]/ => + sub { + nc_msg($verbose, "Unexpected prompt\n"); + $rconsole->clear_accum(); + $rc = 1; + } ], - [qr/(.*)DEFAULT(.*)/=> - sub { - nc_msg($verbose, "Default catch error\n"); - $rconsole->clear_accum(); - $rc = 1; - } + [ qr/(.*)DEFAULT(.*)/ => + sub { + nc_msg($verbose, "Default catch error\n"); + $rconsole->clear_accum(); + $rc = 1; + } ], - [timeout=> - sub { - nc_msg($verbose, "Timeout in getting mac address\n"); - nc_msg($verbose, "timeout state is $state\n"); - $rconsole->clear_accum(); - $rc = 1; - } + [ timeout => + sub { + nc_msg($verbose, "Timeout in getting mac address\n"); + nc_msg($verbose, "timeout state is $state\n"); + $rconsole->clear_accum(); + $rc = 1; + } ], - [eof => - sub { - nc_msg($verbose, "Cannot connect to $node"); - $rconsole->clear_accum(); - $rc = 1; - } + [ eof => + sub { + nc_msg($verbose, "Cannot connect to $node"); + $rconsole->clear_accum(); + $rc = 1; + } ], ); return undef if ($rc eq 1); } + # if the state is 0, 1, or 2, an error occurred and the join will fail if ($state eq 4) { if ($result[2] =~ /dump-mac\s*(\w*)\s*ok/) { @@ -1007,24 +1027,25 @@ sub get_mac_addr { =cut #----------------------------------------------------------------------------- - sub get_adaptr_loc { - my $phandle = shift; +sub get_adaptr_loc { + my $phandle = shift; my $rconsole = shift; - my $node = shift; - my $verbose = shift; + my $node = shift; + my $verbose = shift; my @cmd; my @done; my @msg; my @pattern; my @newstate; - my $state = 0; - my $timeout = 60; # shouldn't take long + my $state = 0; + my $timeout = 60; # shouldn't take long my @result; my @path; my $loc_code; my $rc = 0; nc_msg($verbose, "Status: get_adaptr_loc start\n"); + # cmd(0) could have been sent as 3 commands. " ibm,loc-code" (tcl forces # the use of \") is the first command on this line. The result of entering # " ibm,loc-code" is that 2 stack entries are created, and address and a length. @@ -1036,132 +1057,137 @@ sub get_mac_addr { # are 3 stack entries (return code, address and length of mac-address). # state 0, stack count 0, send command $done[0] = 0; - $cmd[0] = "\" ibm,loc-code\" $phandle get-package-property\r"; - $msg[0] = "Status: return code and loc-code now on stack\n"; + $cmd[0] = "\" ibm,loc-code\" $phandle get-package-property\r"; + $msg[0] = "Status: return code and loc-code now on stack\n"; + #$pattern[0] = "(.*)3 >(.*)"; #$pattern[0] = "3 >"; - $pattern[0] = "ok"; + $pattern[0] = "ok"; $newstate[0] = 1; # cmd(1) is a dot (.). This is a stack manipulation command that removes one # thing from the stack. pattern(1) is looking for a prompt with the 2 indicating # that there are 2 things left on the stack. # state 1, return code and loc-code on stack - $done[1]= 0; - $cmd[1] = ".\r"; - $msg[1] = "Status: loc-code now on stack\n"; + $done[1] = 0; + $cmd[1] = ".\r"; + $msg[1] = "Status: loc-code now on stack\n"; + #$pattern[1] = "(.*)2 >(.*)"; - $pattern[1] = "ok"; #"2 >"; - $newstate[1]= 2; + $pattern[1] = "ok"; #"2 >"; + $newstate[1] = 2; # state 2, loc-code on stack - $done[2]= 0; - $cmd[2] = "dump\r"; - $msg[2] = "Status: loc-code displayed, stack empty\n"; + $done[2] = 0; + $cmd[2] = "dump\r"; + $msg[2] = "Status: loc-code displayed, stack empty\n"; + #$pattern[2] = "(.*)(: )(.*)( :)(.*)(\.: ok)"; - $pattern[2] = "ok"; - $newstate[2]= 3; + $pattern[2] = "ok"; + $newstate[2] = 3; # state 3, all done $done[3] = 1; - while($done[$state] eq 0) { + while ($done[$state] eq 0) { @result = (); nc_msg($verbose, "PROGRAM Status: command is $cmd[$state]\n"); send_command($verbose, $rconsole, $cmd[$state]); @result = $rconsole->expect( $timeout, - [qr/$pattern[$state]/=> - sub { - if ($state eq 1) { - if ($rconsole->before() =~ /-\d+/) { - nc_msg($verbose, "Status: Error getting adapter location for phandle=$phandle."); - $rconsole->clear_accum(); - $state = 3; - $rc = 1; - return undef; + [ qr/$pattern[$state]/ => + sub { + if ($state eq 1) { + if ($rconsole->before() =~ /-\d+/) { + nc_msg($verbose, "Status: Error getting adapter location for phandle=$phandle."); + $rconsole->clear_accum(); + $state = 3; + $rc = 1; + return undef; + } } - } - nc_msg($verbose, $msg[$state]); - $rconsole->clear_accum(); - $state = $newstate[$state]; - } + nc_msg($verbose, $msg[$state]); + $rconsole->clear_accum(); + $state = $newstate[$state]; + } ], - [qr/1 >/=> - sub { - $rconsole->clear_accum(); - my $exp = shift; - if($state eq 0) { - send_command($verbose, $rconsole, ".\r"); - $exp->expect( - #[qr/(-*\[0-9\]*) ok(.*)0 >(.*)/=> - [qr/0 >/=> - sub { - $rconsole->clear_accum(); - my $loc_rc = shift; - nc_msg($verbose, "Error getting adapter physical location.\n"); - nc_msg($verbose, "Status: Error getting physical location for phandle=$phandle. RC=$loc_rc.\n"); - $rc = 1; - } - ], - [timeout=> - sub { - $rconsole->clear_accum(); - nc_msg($verbose, "Timeout when openning console\n"); - $rc = 1; - } - ], - [eof=> - sub { - $rconsole->clear_accum(); - nc_msg($verbose, "Cannot connect to the $node\n"); - $rc = 1; - } - ], - ); + [ qr/1 >/ => + sub { + $rconsole->clear_accum(); + my $exp = shift; + if ($state eq 0) { + send_command($verbose, $rconsole, ".\r"); + $exp->expect( - } - } + #[qr/(-*\[0-9\]*) ok(.*)0 >(.*)/=> + [ qr/0 >/ => + sub { + $rconsole->clear_accum(); + my $loc_rc = shift; + nc_msg($verbose, "Error getting adapter physical location.\n"); + nc_msg($verbose, "Status: Error getting physical location for phandle=$phandle. RC=$loc_rc.\n"); + $rc = 1; + } + ], + [ timeout => + sub { + $rconsole->clear_accum(); + nc_msg($verbose, "Timeout when openning console\n"); + $rc = 1; + } + ], + [ eof => + sub { + $rconsole->clear_accum(); + nc_msg($verbose, "Cannot connect to the $node\n"); + $rc = 1; + } + ], + ); + + } + } ], - [qr/]/=> - sub { - $rconsole->clear_accum(); - nc_msg($verbose, "Unexpected prompt\n"); - $rc = 1; - } + [ qr/]/ => + sub { + $rconsole->clear_accum(); + nc_msg($verbose, "Unexpected prompt\n"); + $rc = 1; + } ], - [qr/(.*)DEFAULT(.*)/=> - sub { - $rconsole->clear_accum(); - nc_msg($verbose, "Default catch error\n"); - $rc = 1; - } + [ qr/(.*)DEFAULT(.*)/ => + sub { + $rconsole->clear_accum(); + nc_msg($verbose, "Default catch error\n"); + $rc = 1; + } ], - [timeout=> - sub { - $rconsole->clear_accum(); - nc_msg($verbose, "Timeout when openning console\n"); - $rc = 1; - } + [ timeout => + sub { + $rconsole->clear_accum(); + nc_msg($verbose, "Timeout when openning console\n"); + $rc = 1; + } ], - [eof => - sub { - $rconsole->clear_accum(); - nc_msg($verbose, "Cannot connect to the $node\n"); - $rc = 1; - } + [ eof => + sub { + $rconsole->clear_accum(); + nc_msg($verbose, "Cannot connect to the $node\n"); + $rc = 1; + } ], ); return undef if ($rc eq 1); } + # Did we find one or more adapters? - my @loc_array = split /\n/,$result[3]; + my @loc_array = split /\n/, $result[3]; my $found = 0; $loc_code = ''; - foreach my $line ( @loc_array ) { + foreach my $line (@loc_array) { if ($line =~ /(\w*):(.*):([\w|\.|-]*):/) { - $loc_code .= $3; + $loc_code .= $3; $found = 1; } } @@ -1192,20 +1218,21 @@ sub get_mac_addr { =cut #----------------------------------------------------------------------------- -sub ping_server{ - my $phandle = shift; +sub ping_server { + my $phandle = shift; my $full_path_name = shift; - my $rconsole = shift; - my $node = shift; - my $mac_address = shift; - my $verbose = shift; - my $adap_speed = shift; - my $adap_duplex = shift; - my $list_type = shift; - my $server_ip = shift; - my $client_ip = shift; - my $gateway_ip = shift; + my $rconsole = shift; + my $node = shift; + my $mac_address = shift; + my $verbose = shift; + my $adap_speed = shift; + my $adap_duplex = shift; + my $list_type = shift; + my $server_ip = shift; + my $client_ip = shift; + my $gateway_ip = shift; my $adap_prop_list_array; + #my %env = shift; my $command; my $linklocal_ip; @@ -1223,9 +1250,9 @@ sub ping_server{ #if (exists($env{'FIRMWARE_DUMP'})) { # $full_path_name = Firmware_Dump($phandle); #} - my $j = 0; - my $tty_do_ping = 0; - my $stack_level = 0; + my $j = 0; + my $tty_do_ping = 0; + my $stack_level = 0; my $properties_matched = 0; my $adap_conn; my $speed_list; @@ -1253,41 +1280,45 @@ sub ping_server{ # # state 0, set the current adapter $done[0] = 0; - $cmd[0] = "dev $full_path_name\r"; - $msg[0] = "Status: selected $full_path_name as the active adapter\n"; + $cmd[0] = "dev $full_path_name\r"; + $msg[0] = "Status: selected $full_path_name as the active adapter\n"; + #$pattern[0] = ".*dev(.*)0 >(.*)"; - $pattern[0] = "0 >"; + $pattern[0] = "0 >"; $newstate[0] = 1; # state 1, send property command to $selected type; $done[1] = 0; $cmd[1] = "\" ethernet,$adap_speed,$adap_conn,$adap_duplex\" encode-string \" chosen-network-type\" property\r"; $msg[1] = "Status: chosen network type set\n"; + #$pattern[1] =".*ethernet(.*)0 >(.*)"; - $pattern[1] ="0 >"; - $newstate[1]= 2; + $pattern[1] = "0 >"; + $newstate[1] = 2; # state 2, activate /packages/net $done[2] = 0; - $cmd[2] = "dev /packages/net\r"; + $cmd[2] = "dev /packages/net\r"; $msg[2] = "Status: selected the /packages/net node as the active package\n"; $pattern[2] = ".*dev.*packages.*net(.*)ok(.*)0 >(.*)"; + #$pattern[2] = "ok"; - $newstate[2]= 3; + $newstate[2] = 3; # state 3, ping the server - $done[3] = 0; - $msg[3] = "Status: ping return code now on stack\n"; + $done[3] = 0; + $msg[3] = "Status: ping return code now on stack\n"; $newstate[3] = 4; # get the timeout for ping test my $to4pt; - if ( $ENV{TIMEOUT4PINGTEST} =~ /^\d+$/ ) { + if ($ENV{TIMEOUT4PINGTEST} =~ /^\d+$/) { $to4pt = ",$ENV{TIMEOUT4PINGTEST}"; - } + } #IPv6 - if ( $server_ip =~ /:/ ) { + if ($server_ip =~ /:/) { + #::1, calculate link local address if ($client_ip eq "::1") { my $command = "/opt/xcat/share/xcat/tools/mac2linklocal -m $mac_address"; @@ -1303,10 +1334,11 @@ sub ping_server{ # state 4, all done $done[4] = 0; - $cmd[4] = "0 to my-self\r"; - $msg[4] = "Status: resetting pointer\n"; + $cmd[4] = "0 to my-self\r"; + $msg[4] = "Status: resetting pointer\n"; + #$pattern[4] = "(.*)ok(.*)0 >(.*)"; - $pattern[4] = "ok"; + $pattern[4] = "ok"; $newstate[4] = 5; # state 5, all done @@ -1315,18 +1347,18 @@ sub ping_server{ # for ping, only need to set speed and duplex for ethernet adapters # - if ( $list_type eq "ent" ) { + if ($list_type eq "ent") { $state = 0; # Get the list of properties for this adapter # $adap_prop_list_array = get_adap_prop($phandle, $rconsole, $node, $verbose); - if ( $adap_prop_list_array eq 1 ) { + if ($adap_prop_list_array eq 1) { nc_msg($verbose, "ERROR return from get_adap_prop\n"); return 1; } - if ( $adap_prop_list_array eq 0 ) { + if ($adap_prop_list_array eq 0) { nc_msg($verbose, "No properties found for adapter '$full_path_name'\n"); return 1; } @@ -1338,29 +1370,29 @@ sub ping_server{ my $a_conn; my $a_duplex; for my $prop (@$adap_prop_list_array) { - if( $prop =~ /(.*),(.*),(.*)/) { - $a_speed = $1; - $a_conn = $2; + if ($prop =~ /(.*),(.*),(.*)/) { + $a_speed = $1; + $a_conn = $2; $a_duplex = $3; - if ( ( $a_speed eq $adap_speed ) && ( $a_duplex eq $adap_duplex ) ) { + if (($a_speed eq $adap_speed) && ($a_duplex eq $adap_duplex)) { $properties_matched = 1; - if ( grep {$_ eq $a_conn } @adap_conn_list) { + if (grep { $_ eq $a_conn } @adap_conn_list) { push @adap_conn_list, $a_conn; } } } } - if ( $properties_matched eq 0 ) { - $adap_speed = $a_speed; - $adap_duplex = $a_duplex; + if ($properties_matched eq 0) { + $adap_speed = $a_speed; + $adap_duplex = $a_duplex; $properties_matched = 1; push @adap_conn_list, $a_conn; } $i = scalar(@adap_conn_list); - if ( $properties_matched eq 0 ) { + if ($properties_matched eq 0) { nc_msg($verbose, "'$adap_speed/$adap_duplex' settings are not supported on this adapter\n"); return 1; } @@ -1369,101 +1401,103 @@ sub ping_server{ } $timeout = 300; - while ( $done[$state] eq 0 ) { + while ($done[$state] eq 0) { send_command($verbose, $rconsole, $cmd[$state]); @result = $rconsole->expect( $timeout, - [qr/$pattern[$state]/s=> - sub { - nc_msg($verbose, $msg[$state]); - $rconsole->clear_accum(); - $state = $newstate[$state]; - } + [ qr/$pattern[$state]/s => + sub { + nc_msg($verbose, $msg[$state]); + $rconsole->clear_accum(); + $state = $newstate[$state]; + } ], - [qr/]/=> - sub { - nc_msg($verbose, "Unexpected prompt\n"); - $rconsole->clear_accum(); - $rc = 1; - } + [ qr/]/ => + sub { + nc_msg($verbose, "Unexpected prompt\n"); + $rconsole->clear_accum(); + $rc = 1; + } ], - [qr/(.*)DEFAULT(.*)/=> - sub { - nc_msg($verbose, "Default catch error\n"); - $rconsole->clear_accum(); - $rc = 1; - } + [ qr/(.*)DEFAULT(.*)/ => + sub { + nc_msg($verbose, "Default catch error\n"); + $rconsole->clear_accum(); + $rc = 1; + } ], - [timeout=> - sub { - nc_msg($verbose, "Timeout when openning console\n"); - $rconsole->clear_accum(); - $rc = 1; - } + [ timeout => + sub { + nc_msg($verbose, "Timeout when openning console\n"); + $rconsole->clear_accum(); + $rc = 1; + } ], - [eof=> - sub { - nc_msg($verbose, "Cannot connect to the $node\n"); - $rconsole->clear_accum(); - $rc = 1; - } + [ eof => + sub { + nc_msg($verbose, "Cannot connect to the $node\n"); + $rconsole->clear_accum(); + $rc = 1; + } ], ); - return 1 if ($rc eq 1); + return 1 if ($rc eq 1); - if ( $state eq 1 ) { + if ($state eq 1) { $adap_conn = $adap_conn_list[$j]; $cmd[1] = "\" ethernet,$adap_speed,$adap_conn,$adap_duplex\" encode-string \" chosen-network-type\" property\r"; nc_msg($verbose, "Status: Trying connector type $adap_conn\n"); $j++; } - if ((($tty_do_ping eq 1) && ($state eq 4)) || ($tty_do_ping != 1) && ($state eq 3) ) { + if ((($tty_do_ping eq 1) && ($state eq 4)) || ($tty_do_ping != 1) && ($state eq 3)) { $ping_debug = $result[2]; } - if ( ( ($tty_do_ping eq 1) && ($state eq 5) ) || ($tty_do_ping != 1) && ($state eq 4) ) { - if ( ($tty_do_ping eq 1) && ($state eq 5) ) { + if ((($tty_do_ping eq 1) && ($state eq 5)) || ($tty_do_ping != 1) && ($state eq 4)) { + if (($tty_do_ping eq 1) && ($state eq 5)) { + #$ping_rc = $result[2]; $stack_level = length($result[4]); - } elsif ( ($state eq 4) && ($tty_do_ping != 1) && ($result[2] =~ /PING SUCCESS/)) { + } elsif (($state eq 4) && ($tty_do_ping != 1) && ($result[2] =~ /PING SUCCESS/)) { $ping_rc = 0; - #} elsif ( $result[2] =~ /unknown word/ ) { - # nc_msg($verbose, "Status: try tty-do-ping.\n"); - # $ping_rc = 1; - # $tty_do_ping = 1; - # $state = 3 ; - # $cmd[3] = "\"" . $full_path_name . ":" . $client_ip . "," . $server_ip . "," . $gateway_ip . "\" tty-do-ping\r"; - # $pattern[3] = "(.*)ok(.*)(\[1-2\]) >(.*)"; - # - # # state 4, get the return code off the stack - # $done[4] = 0; - # $cmd[4] = ".\r"; - # $msg[4] = "Status: return code displayed, stack empty\n"; - # $pattern[4] = "(\[0-9\]*) ok(.*)(\[0-1\]) >(.*)"; - # $newstate[4] = 5; - # - # # this command is used to work around a default catch problem in open - # # firmware. Without it, a default catch occurs if we try to set - # # adapter properties again after a ping - # # - # # state 5, re$pointer - # $done[5] = 0; - # $cmd[5] = "0 to my-self\r"; - # $msg[5] = "Status: resetting pointer\n" ; - # $pattern[5] = "(.*)ok(.*)0 >(.*)"; - # $newstate[5] = 6 ; - # - # # state 6, all done - # $done[6] = 1; + + #} elsif ( $result[2] =~ /unknown word/ ) { + # nc_msg($verbose, "Status: try tty-do-ping.\n"); + # $ping_rc = 1; + # $tty_do_ping = 1; + # $state = 3 ; + # $cmd[3] = "\"" . $full_path_name . ":" . $client_ip . "," . $server_ip . "," . $gateway_ip . "\" tty-do-ping\r"; + # $pattern[3] = "(.*)ok(.*)(\[1-2\]) >(.*)"; + # + # # state 4, get the return code off the stack + # $done[4] = 0; + # $cmd[4] = ".\r"; + # $msg[4] = "Status: return code displayed, stack empty\n"; + # $pattern[4] = "(\[0-9\]*) ok(.*)(\[0-1\]) >(.*)"; + # $newstate[4] = 5; + # + # # this command is used to work around a default catch problem in open + # # firmware. Without it, a default catch occurs if we try to set + # # adapter properties again after a ping + # # + # # state 5, re$pointer + # $done[5] = 0; + # $cmd[5] = "0 to my-self\r"; + # $msg[5] = "Status: resetting pointer\n" ; + # $pattern[5] = "(.*)ok(.*)0 >(.*)"; + # $newstate[5] = 6 ; + # + # # state 6, all done + # $done[6] = 1; } else { $ping_rc = 1; } - if ( $ping_rc eq 0 ) { + if ($ping_rc eq 0) { nc_msg($verbose, "# $full_path_name ping successful.\n"); - } elsif ( $ping_rc eq 1 ) { + } elsif ($ping_rc eq 1) { nc_msg($verbose, "# $full_path_name ping unsuccessful.\n"); nc_msg($verbose, "# $full_path_name ping unsuccessful.\n"); nc_msg($verbose, "$ping_debug\n"); @@ -1472,55 +1506,56 @@ sub ping_server{ # be removed. Check for it, and remove if necessary my $matchexp = 0; my @exp_out; - while ( $stack_level != 0 ) { + while ($stack_level != 0) { @exp_out = (); send_command($verbose, $rconsole, ".\r"); @exp_out = $rconsole->expect( - [qr/(\[0-9\]*) ok(.*)(\[0-1\]) >(.*)/s=> - sub { - $rconsole->clear_accum(); - $matchexp = 1; - } + [ qr/(\[0-9\]*) ok(.*)(\[0-1\]) >(.*)/s => + sub { + $rconsole->clear_accum(); + $matchexp = 1; + } ], - [qr/]/=> - sub { - nc_msg($verbose, "Unexpected prompt\n"); - $rconsole->clear_accum(); - $rc = 1; - } + [ qr/]/ => + sub { + nc_msg($verbose, "Unexpected prompt\n"); + $rconsole->clear_accum(); + $rc = 1; + } ], - [qr/(.*)DEFAULT(.*)/=> - sub { - nc_msg($verbose, "Default catch error\n"); - $rconsole->clear_accum(); - $rc = 1; - } + [ qr/(.*)DEFAULT(.*)/ => + sub { + nc_msg($verbose, "Default catch error\n"); + $rconsole->clear_accum(); + $rc = 1; + } ], - [timeout=> - sub { - nc_msg($verbose, "Timeout in ping server\n"); - $rconsole->clear_accum(); - $rc = 1; - } + [ timeout => + sub { + nc_msg($verbose, "Timeout in ping server\n"); + $rconsole->clear_accum(); + $rc = 1; + } ], - [eof => - sub { - nc_msg($verbose, "Cannot connect to $node\n"); - $rconsole->clear_accum(); - $rc = 1; - } + [ eof => + sub { + nc_msg($verbose, "Cannot connect to $node\n"); + $rconsole->clear_accum(); + $rc = 1; + } ], ); if ($matchexp) { - $matchexp = 0; + $matchexp = 0; $stack_level = length($exp_out[4]); nc_msg($verbose, "Status: stack_level is <$stack_level>\n"); } } + # Check if there are any more adapter connector types # to try # - if ( ( $list_type eq "ent" ) && ( $j < $i ) ) { + if (($list_type eq "ent") && ($j < $i)) { $adap_conn = $adap_conn_list[$j]; nc_msg($verbose, "Status: Trying connector type $adap_conn\n"); $j++; @@ -1533,10 +1568,10 @@ sub ping_server{ # the array. This is OK, since we only set the current # adapter once, upon entering this procedure. # - $done[0] = 0; - $cmd[0] = "0 to my-self\r"; - $msg[0] = "Status: resetting pointer\n"; - $pattern[0] = "(.*)ok(.*)0 >(.*)"; + $done[0] = 0; + $cmd[0] = "0 to my-self\r"; + $msg[0] = "Status: resetting pointer\n"; + $pattern[0] = "(.*)ok(.*)0 >(.*)"; $newstate[0] = 1; $state = 0; @@ -1572,9 +1607,9 @@ sub ping_server{ #----------------------------------------------------------------------------- sub set_disk_boot { my @expect_out = shift; - my $rconsole = shift; - my $node = shift; - my $verbose = shift; + my $rconsole = shift; + my $node = shift; + my $verbose = shift; my $x0; my $x1; my $x2; @@ -1590,10 +1625,10 @@ sub set_disk_boot { # state 0, get SMS screen $done[0] = 0; - if($expect_out[0] =~ /(\n)(\[ ])(\[0-9])(\[.])(\[ ]+)Select Boot Options(\r)/){ - $x0 = $1; - $x1 = $2; - $x2 = $3; + if ($expect_out[0] =~ /(\n)(\[ ])(\[0-9])(\[.])(\[ ]+)Select Boot Options(\r)/) { + $x0 = $1; + $x1 = $2; + $x2 = $3; $command = $4; } $cmd[0] = "$command\r"; @@ -1602,111 +1637,111 @@ sub set_disk_boot { $newstate[0] = 1; # state 1, Multiboot - $done[1] = 0; - $msg[1] = "Status: Multiboot\n"; - $pattern[1] = "(\n)(\[ ])(\[0-9])(\[.])(\[ ]+)Select 1st Boot Device(\r)"; + $done[1] = 0; + $msg[1] = "Status: Multiboot\n"; + $pattern[1] = "(\n)(\[ ])(\[0-9])(\[.])(\[ ]+)Select 1st Boot Device(\r)"; $newstate[1] = 2; # state 2, Configure Boot Device Order - $done[2] = 0; - $msg[2] = "Status: Configure Boot Device Order"; - $pattern[2] = "(\n)(\[ ])(\[0-9])(\[.])(\[ ]+)Hard Drive(.*)"; + $done[2] = 0; + $msg[2] = "Status: Configure Boot Device Order"; + $pattern[2] = "(\n)(\[ ])(\[0-9])(\[.])(\[ ]+)Hard Drive(.*)"; $newstate[2] = 3; # state 3, Select Device Type - $done[3] = 0; - $msg[3] = "Status: Select Device Type"; - $pattern[3] = "(\n)(\[ ])(\[0-9])(\[.])(\[ ]+)SCSI(.*)"; + $done[3] = 0; + $msg[3] = "Status: Select Device Type"; + $pattern[3] = "(\n)(\[ ])(\[0-9])(\[.])(\[ ]+)SCSI(.*)"; $newstate[3] = 4; # state 4, Select Media Type - $done[4] = 0; - $msg[4] = "Status: Select Media Type"; - $pattern[4] = "(\n)(\[ ])(\[1])(\[.])(\[ ]+)(\\S+)(.*)"; - $newstate[4] = 5 ; + $done[4] = 0; + $msg[4] = "Status: Select Media Type"; + $pattern[4] = "(\n)(\[ ])(\[1])(\[.])(\[ ]+)(\\S+)(.*)"; + $newstate[4] = 5; # state 5, Select Media Adapter $done[5] = 0; - $msg[5] = "Status: Select Media Adapter"; + $msg[5] = "Status: Select Media Adapter"; $pattern[5] = "(\n)(\[ ])(\[0-9])(\[.])(\[ ]+)(\\S)(\[ ]+)SCSI (\[0-9]+) MB Harddisk(.*)loc=(.*)\[)]"; $newstate[5] = 6; # state 6, Select Device - $done[6] = 0; - $msg[6] = "Status: Select Device"; - $pattern[6] = "(\n)(\[ ])(\[0-9])(\[.])(\[ ]+)Set Boot Sequence(.*)"; + $done[6] = 0; + $msg[6] = "Status: Select Device"; + $pattern[6] = "(\n)(\[ ])(\[0-9])(\[.])(\[ ]+)Set Boot Sequence(.*)"; $newstate[6] = 7; # state 7, Select Task - $done[7] = 0; - $msg[7] = "Status: Select Task"; - $pattern[7] = "(.*)Current Boot Sequence(.*)"; - $newstate[7] = 8 ; + $done[7] = 0; + $msg[7] = "Status: Select Task"; + $pattern[7] = "(.*)Current Boot Sequence(.*)"; + $newstate[7] = 8; # state 8, Return to Main Menu - $done[8] = 0; - $cmd[8] = "M"; - $msg[8] = "Status: Restored Default Setting.\n" ; - $pattern[8] = "(.*)Navigation key(.*)"; + $done[8] = 0; + $cmd[8] = "M"; + $msg[8] = "Status: Restored Default Setting.\n"; + $pattern[8] = "(.*)Navigation key(.*)"; $newstate[8] = 9; # state 9, Getting to SMS Main Menu - $done[9] = 0; - $cmd[9] = "0\r"; - $msg[9] = "Status: Getting to SMS Main Menu.\n"; - $pattern[9] = "(.*)Exit SMS(.*)Prompt?(.*)"; + $done[9] = 0; + $cmd[9] = "0\r"; + $msg[9] = "Status: Getting to SMS Main Menu.\n"; + $pattern[9] = "(.*)Exit SMS(.*)Prompt?(.*)"; $newstate[9] = 10; # state 10, Exiting SMS - $done[10] = 0; - $cmd[10] = "Y"; - $msg[10] = "Status: Exiting SMS.\n"; - $pattern[10] = "(.*)ok(.*)0 >(.*)"; + $done[10] = 0; + $cmd[10] = "Y"; + $msg[10] = "Status: Exiting SMS.\n"; + $pattern[10] = "(.*)ok(.*)0 >(.*)"; $newstate[10] = 11; # state 11, all done $done[11] = 1; $timeout = 30; - $state = 0; + $state = 0; - while ( $done[$state] eq 0 ) { + while ($done[$state] eq 0) { send_command($verbose, $rconsole, $cmd[$state]); $rconsole->expect( - [qr/$pattern[$state]/=> - sub { + [ qr/$pattern[$state]/ => + sub { $rconsole->clear_accum(); - if ( $state eq 4 ) { - if ( $expect_out[6] eq "None" ) { + if ($state eq 4) { + if ($expect_out[6] eq "None") { $state = 8; } } $state = $newstate[$state]; - if ( ($state != 8) && ($state != 9) && ($state != 10) ) { + if (($state != 8) && ($state != 9) && ($state != 10)) { $cmd[$state] = "$expect_out[3]\r"; } - } + } ], - [qr/THE SELECTED DEVICES WERE NOT DETECTED IN THE SYSTEM/=> - sub { + [ qr/THE SELECTED DEVICES WERE NOT DETECTED IN THE SYSTEM/ => + sub { $rconsole->clear_accum(); nc_msg($verbose, " Status: THE hard disk WERE NOT DETECTED IN THE SYSTEM!\n"); $rc = 1; - } + } ], - [timeout => - sub { + [ timeout => + sub { $rconsole->clear_accum(); nc_msg($verbose, "Timeout in settin boot order\n"); $rc = 1; - } + } ], - [eof => - sub { + [ eof => + sub { $rconsole->clear_accum(); nc_msg($verbose, "Cannot connect to $node\n"); $rc = 1; - } + } ], ); if ($rc eq 1) { @@ -1737,21 +1772,21 @@ sub boot_network { { $rconsole = shift; } - my $full_path_name = shift; - my $speed = shift; - my $duplex = shift; + my $full_path_name = shift; + my $speed = shift; + my $duplex = shift; my $chosen_adap_type = shift; - my $server_ip = shift; - my $client_ip = shift; - my $gateway_ip = shift; - my $netmask = shift; - my $dump_target = shift; - my $dump_lun = shift; - my $dump_port = shift; - my $verbose = shift; - my $extra_args = shift; - my $node = shift; - my $set_boot_order = shift; + my $server_ip = shift; + my $client_ip = shift; + my $gateway_ip = shift; + my $netmask = shift; + my $dump_target = shift; + my $dump_lun = shift; + my $dump_port = shift; + my $verbose = shift; + my $extra_args = shift; + my $node = shift; + my $set_boot_order = shift; my @net_device; my @pattern; my @cmd; @@ -1790,14 +1825,14 @@ sub boot_network { $net_device[0] = "$full_path_name:iscsi,ciaddr=$client_ip,subnet-mask=$netmask,itname=dummy,iport=$dump_port,ilun=$dump_lun,iname=$dump_target,siaddr=$server_ip,2"; $pattern[0] = "iSCSI"; } else { - if ($extra_args ne "" ) { - if ( $server_ip =~ /:/ ) { #ipv6 + if ($extra_args ne "") { + if ($server_ip =~ /:/) { #ipv6 $net_device[0] = "$full_path_name:ipv6,speed=$speed,duplex=$duplex,siaddr=$server_ip,ciaddr=$client_ip,giaddr=$gateway_ip,filename=$node,$extra_args"; } else { $net_device[0] = "$full_path_name:speed=$speed,duplex=$duplex,bootp,$server_ip,,$client_ip,$gateway_ip $extra_args"; } } else { - if ( $server_ip =~ /:/ ) { #ipv6 + if ($server_ip =~ /:/) { #ipv6 $net_device[0] = "$full_path_name:ipv6,speed=$speed,duplex=$duplex,siaddr=$server_ip,ciaddr=$client_ip,giaddr=$gateway_ip,filename=$node"; } else { $net_device[0] = "$full_path_name:speed=$speed,duplex=$duplex,bootp,$server_ip,,$client_ip,$gateway_ip"; @@ -1806,29 +1841,29 @@ sub boot_network { $pattern[0] = "BOOTP"; } - $cmd[0] = "boot $net_device[0]\r"; - $msg[0] = "Status: network boot initiated\n"; + $cmd[0] = "boot $net_device[0]\r"; + $msg[0] = "Status: network boot initiated\n"; $newstate[0] = 99; # If the install adapter is FDDI, don't set the speed and duplex # state 1 - $done[1] = 0; + $done[1] = 0; $net_device[1] = "$full_path_name:bootp,$server_ip,,$client_ip,$gateway_ip"; - $cmd[1] = "boot $net_device[1]\r"; - $msg[1] = "Status: network boot initiated\n"; - $pattern[1] = "BOOTP"; - $newstate[1] = 99; + $cmd[1] = "boot $net_device[1]\r"; + $msg[1] = "Status: network boot initiated\n"; + $pattern[1] = "BOOTP"; + $newstate[1] = 99; # state 99, all done $done[99] = 1; # state -1, all done - $done[100] = 1; #-1??? + $done[100] = 1; #-1??? - if ($chosen_adap_type eq "fddi" ) { + if ($chosen_adap_type eq "fddi") { $state = 1; } else { - if ($speed eq "" || $duplex eq "" ) { + if ($speed eq "" || $duplex eq "") { nc_msg($verbose, "Cannot set speed or duplex for network boot\n"); return 1; } @@ -1837,104 +1872,105 @@ sub boot_network { ################################################################## # Set the boot device order. ################################################################## - if ( $set_boot_order > 0 ) { - $done[2] = 0; - $msg[2] = "Status: read original boot-device\n"; - $cmd[2] = "printenv boot-device\r"; - $pattern[2] = ".*boot-device\\s+(\\S+)(.*)ok(.*)"; - $newstate[2] = 3; + if ($set_boot_order > 0) { + $done[2] = 0; + $msg[2] = "Status: read original boot-device\n"; + $cmd[2] = "printenv boot-device\r"; + $pattern[2] = ".*boot-device\\s+(\\S+)(.*)ok(.*)"; + $newstate[2] = 3; - $done[3] = 0; - $msg[3] = "Status: set the environment variable boot-device\n"; - $pattern[3] = "(.*)ok(.*)(\[0-9]) >(.*)"; - if ( $state eq 0 ) { - $newstate[3] = 0; + $done[3] = 0; + $msg[3] = "Status: set the environment variable boot-device\n"; + $pattern[3] = "(.*)ok(.*)(\[0-9]) >(.*)"; + if ($state eq 0) { + $newstate[3] = 0; } else { - $newstate[3] = 1; + $newstate[3] = 1; } $state = 2; } - $timeout = 30; # shouldn't take long - while ( $done[$state] eq 0 ) { + $timeout = 30; # shouldn't take long + while ($done[$state] eq 0) { send_command($verbose, $rconsole, $cmd[$state]); $rconsole->expect( - [qr/$pattern[$state]/=> - sub { + [ qr/$pattern[$state]/ => + sub { $rconsole->clear_accum(); my @expect_out = shift; - if ( $state eq 2 ) { - if ( $set_boot_order eq 1 ) { + if ($state eq 2) { + if ($set_boot_order eq 1) { ######################################## # Set network as boot device ######################################## $cmd[3] = "setenv boot-device $net_device[$newstate[3]]\r"; - } elsif ( $set_boot_order eq 2 ) { + } elsif ($set_boot_order eq 2) { ######################################## # Set network as 1st boot device,disk as 2nd boot device ######################################## $boot_device_bk = $expect_out[1]; - $cmd[3] = "setenv boot-device $net_device[$newstate[3]] $boot_device_bk\r"; - } elsif ( $set_boot_order eq 3 ) { + $cmd[3] = "setenv boot-device $net_device[$newstate[3]] $boot_device_bk\r"; + } elsif ($set_boot_order eq 3) { ######################################## # Set disk as 1st boot device,network as 2nd boot device ######################################## $boot_device_bk = $expect_out[1]; - $cmd[3] = "setenv boot-device $boot_device_bk $net_device[$newstate[3]]\r"; - } elsif ( $set_boot_order eq 4 ) { + $cmd[3] = "setenv boot-device $boot_device_bk $net_device[$newstate[3]]\r"; + } elsif ($set_boot_order eq 4) { ######################################## # set disk as boot device ######################################## $boot_device_bk = $expect_out[1]; - $cmd[3] = "setenv boot-device $boot_device_bk\r"; + $cmd[3] = "setenv boot-device $boot_device_bk\r"; } } nc_msg($verbose, $msg[$state]); $state = $newstate[$state]; - } + } ], - [qr/----/=> - sub { - nc_msg ($verbose, $msg[$state]); - $rconsole->clear_accum(); - $state = $newstate[$state]; - } + [ qr/----/ => + sub { + nc_msg($verbose, $msg[$state]); + $rconsole->clear_accum(); + $state = $newstate[$state]; + } ], + # For some old firmware, does not output "----" - [qr/BOOTP/=> - sub { - nc_msg ($verbose, $msg[$state]); - $rconsole->clear_accum(); - $state = $newstate[$state]; - } + [ qr/BOOTP/ => + sub { + nc_msg($verbose, $msg[$state]); + $rconsole->clear_accum(); + $state = $newstate[$state]; + } ], - [qr/]/=> - sub { - nc_msg($verbose, "Unexpected prompt\n"); - $rconsole->clear_accum(); - $rc = 1; - } + [ qr/]/ => + sub { + nc_msg($verbose, "Unexpected prompt\n"); + $rconsole->clear_accum(); + $rc = 1; + } ], - [qr/(.*)DEFAULT(.*)/=> - sub { + [ qr/(.*)DEFAULT(.*)/ => + sub { nc_msg($verbose, "Default catch error\n"); $rconsole->clear_accum(); $rc = 1; - } + } ], - [timeout=> - sub { + [ timeout => + sub { nc_msg($verbose, "Timeout when openning console\n"); $rconsole->clear_accum(); $rc = 1; - } + } ], - [eof=> - sub { + [ eof => + sub { nc_msg($verbose, "Cannot connect to the $node\n"); $rconsole->clear_accum(); $rc = 1; - } + } ], ); return 1 if ($rc eq 1); @@ -1947,8 +1983,9 @@ sub boot_network { # sub Boot { my $rconsole = shift; - my $node = shift; - my $verbose = shift; + my $node = shift; + my $verbose = shift; + #my @expect_out = shift; my $rc = 0; my $timeout; @@ -1956,17 +1993,18 @@ sub Boot { nc_msg($verbose, "Status: waiting for the boot image to boot up.\n"); - $timeout = 1200; # could take a while depending on configuration + $timeout = 1200; # could take a while depending on configuration $rconsole->expect( - [qr/RESTART-CMD/=> - sub { + [ qr/RESTART-CMD/ => + sub { # If we see a "problem doing RESTART-CMD" message, we re-hit the OPEN-DEV # issue after firmware rebooted itself and we need to retry the netboot once more nc_msg($verbose, "The network boot ended in an error.\nError : RESTART-CMD\n"); $rconsole->clear_accum(); $rc = 1; - } + } ], + #[!(qr/[0-9A-F]+/)=> # sub { # nc_msg($verbose, "The network boot ended in an error.\n"); @@ -1974,58 +2012,62 @@ sub Boot { # $rc = 1; # } #], - [qr/BOOTP/=> #-ex - sub { + [ qr/BOOTP/ => #-ex + sub { nc_msg($verbose, "# Network boot proceeding - matched BOOTP, exiting.\n"); $rconsole->clear_accum(); - } + } ], + # Welcome to AIX - some old firmware does not output BOOTP or ---- - [qr/Welcome/=> #-ex - sub { + [ qr/Welcome/ => #-ex + sub { nc_msg($verbose, "# Network boot proceeding - matched Welcome, exiting.\n"); $rconsole->clear_accum(); - } + } ], + # tftp file download - some old firmware does not output BOOTP or ---- - [qr/FILE/=> #-ex - sub { + [ qr/FILE/ => #-ex + sub { nc_msg($verbose, "# Network boot proceeding - matched FILE.\n"); $rconsole->clear_accum(); - } + } ], + # some old firmware does not output BOOTP or ---- - [qr/Elapsed/=> #-ex - sub { + [ qr/Elapsed/ => #-ex + sub { nc_msg($verbose, "# Network boot proceeding - matched Elapsed, exiting.\n"); $rconsole->clear_accum(); - } + } ], - [qr/------/=> #-ex - sub { + [ qr/------/ => #-ex + sub { nc_msg($verbose, "# Network boot proceeding, exiting.\n"); $rconsole->clear_accum(); - } + } ], - [timeout=> - sub { - my $mins = $timeout/60; - nc_msg($verbose, "Timeout waiting for the boot image to boot up. \ + [ timeout => + sub { + my $mins = $timeout / 60; + nc_msg($verbose, "Timeout waiting for the boot image to boot up. \ \n waited '$mins' minutes for the boot image to boot. \ \nEither the boot up has taken longer than expected or \ \nthere is a problem with system boot. Check the boot \ \nof the node to determine if there is a problem.\n"); - $rconsole->clear_accum(); - #nc_msg($verbose, $expect_out[buffer]); - $rc = 1; - } + $rconsole->clear_accum(); + + #nc_msg($verbose, $expect_out[buffer]); + $rc = 1; + } ], - [eof=> - sub { - nc_msg($verbose, "Port closed waiting for boot image to boot.\n"); - $rconsole->clear_accum(); - $rc = 1; - } + [ eof => + sub { + nc_msg($verbose, "Port closed waiting for boot image to boot.\n"); + $rconsole->clear_accum(); + $rc = 1; + } ], ); return $rc; @@ -2048,7 +2090,7 @@ sub multiple_open_dev { { $rconsole = shift; } - my $node = shift; + my $node = shift; my $verbose = shift; my $expect_out; my $command; @@ -2059,7 +2101,7 @@ sub multiple_open_dev { send_command($verbose, $rconsole, "FALSE value OPEN-DEV_DEBUG \r"); if (exists $ENV{'OPEN_DEV_DEBUG'}) { - send_command($verbose, $rconsole, "TRUE to OPEN-DEV_DEBUG \r"); + send_command($verbose, $rconsole, "TRUE to OPEN-DEV_DEBUG \r"); } $command = ": new-open-dev ( str len -- true|false ) \ @@ -2104,33 +2146,34 @@ sub multiple_open_dev { $timeout = 30; $rconsole->expect( $timeout, - [qr/new-open-dev(.*)ok/=> - #[qr/>/=> - sub { + [ qr/new-open-dev(.*)ok/ => + + #[qr/>/=> + sub { nc_msg($verbose, "Status: at End of multiple_open_dev \n"); $rconsole->clear_accum(); - } + } ], - [qr/]/=> - sub { + [ qr/]/ => + sub { nc_msg($verbose, "Unexpected prompt\n"); $rconsole->clear_accum(); $rc = 1; - } + } ], - [timeout => - sub { + [ timeout => + sub { send_user(2, "Timeout\n"); $rconsole->clear_accum(); $rc = 1; - } + } ], - [eof => - sub { + [ eof => + sub { send_user(2, "Cannot connect to $node\n"); $rconsole->clear_accum(); $rc = 1; - } + } ], ); @@ -2139,34 +2182,35 @@ sub multiple_open_dev { $rconsole->expect( $timeout, - [qr/patch new-open-dev(.*)ok/=> - #[qr/>/=> - sub { + [ qr/patch new-open-dev(.*)ok/ => + + #[qr/>/=> + sub { nc_msg($verbose, "Status: at End of multiple_open_dev \n"); $rconsole->clear_accum(); return 0; - } + } ], - [qr/]/=> - sub { + [ qr/]/ => + sub { nc_msg($verbose, "Unexpected prompt\n"); $rconsole->clear_accum(); $rc = 1; - } + } ], - [timeout => - sub { + [ timeout => + sub { send_user(2, "Timeout\n"); $rconsole->clear_accum(); $rc = 1; - } + } ], - [eof => - sub { + [ eof => + sub { send_user(2, "Cannot connect to $node\n"); $rconsole->clear_accum(); $rc = 1; - } + } ], ); @@ -2179,12 +2223,12 @@ sub multiple_open_dev { # Declare procedure to get additional firmware debug statement. # ################################################################### -sub Firmware_Dump { - my $rconsole = shift; - my $node = shift; - my $verbose = shift; +sub Firmware_Dump { + my $rconsole = shift; + my $node = shift; + my $verbose = shift; my $device_path = shift; - my $phandle = shift; + my $phandle = shift; my $expect_out; my @done; my @cmd; @@ -2193,130 +2237,130 @@ sub Firmware_Dump { my @newstate; my $timeout; my $state = 0; - my $rc = 0; + my $rc = 0; - nc_msg($verbose,"Status: Firmware_Dump start\n"); + nc_msg($verbose, "Status: Firmware_Dump start\n"); # state 0 - $done[0] = 0; - $cmd[0] = "dev /packages/obp-tftp\r"; - $msg[0] = "Status: selected /packages/obp_tftp\n"; - $pattern[0] = "(.*)ok(.*)(\[0-9]) >(.*)"; + $done[0] = 0; + $cmd[0] = "dev /packages/obp-tftp\r"; + $msg[0] = "Status: selected /packages/obp_tftp\n"; + $pattern[0] = "(.*)ok(.*)(\[0-9]) >(.*)"; $newstate[0] = 1; # state 1 $done[1] = 0; - $cmd[1] = ": testing1 .\" OBP-TFTP entry\" cr init-nvram-adptr-parms ;\r"; - $msg[1] = "Status: running test - OBP-TFTP entry\n"; - $pattern[1] = "(.*)ok(.*)(\[0-9]) >(.*)"; + $cmd[1] = ": testing1 .\" OBP-TFTP entry\" cr init-nvram-adptr-parms ;\r"; + $msg[1] = "Status: running test - OBP-TFTP entry\n"; + $pattern[1] = "(.*)ok(.*)(\[0-9]) >(.*)"; $newstate[1] = 2; # state 2 - $done[2] = 0; - $cmd[2] = ": testing2 .\" OBP-TFTP exit, TRUE\" cr true ;\r"; - $msg[2] = "Status: running test - OBP-TFTP exit\n"; - $pattern[2] = "(.*)ok(.*)(\[0-9]) >(.*)"; + $done[2] = 0; + $cmd[2] = ": testing2 .\" OBP-TFTP exit, TRUE\" cr true ;\r"; + $msg[2] = "Status: running test - OBP-TFTP exit\n"; + $pattern[2] = "(.*)ok(.*)(\[0-9]) >(.*)"; $newstate[2] = 3; # state 3 - $done[3] = 0; - $cmd[3] = "patch testing1 init-nvram-adptr-parms open\r"; - $msg[3] = "Status: running test - patch testing1\n"; - $pattern[3] = "(.*)ok(.*)(\[0-9]) >(.*)"; + $done[3] = 0; + $cmd[3] = "patch testing1 init-nvram-adptr-parms open\r"; + $msg[3] = "Status: running test - patch testing1\n"; + $pattern[3] = "(.*)ok(.*)(\[0-9]) >(.*)"; $newstate[3] = 4; # state 4 - $done[4] = 0; - $cmd[4] = "patch testing2 true open\r"; - $msg[4] = "Status: running test - patch testing2\n"; - $pattern[4] = "(.*)ok(.*)(\[0-9]) >(.*)"; + $done[4] = 0; + $cmd[4] = "patch testing2 true open\r"; + $msg[4] = "Status: running test - patch testing2\n"; + $pattern[4] = "(.*)ok(.*)(\[0-9]) >(.*)"; $newstate[4] = 5; # state 5 - $done[5] = 0; - $cmd[5] = "dev $device_path\r"; - $msg[5] = "Status: running test - dev $device_path\n"; - $pattern[5] = "(.*)ok(.*)(\[0-9]) >(.*)"; + $done[5] = 0; + $cmd[5] = "dev $device_path\r"; + $msg[5] = "Status: running test - dev $device_path\n"; + $pattern[5] = "(.*)ok(.*)(\[0-9]) >(.*)"; $newstate[5] = 6; # state 6 - $done[6] = 0; - $cmd[6] = "true to debug-init\r"; - $msg[6] = "Status: running test - true to debug-init\n"; - $pattern[6] = "(.*)ok(.*)(\[0-9]) >(.*)"; + $done[6] = 0; + $cmd[6] = "true to debug-init\r"; + $msg[6] = "Status: running test - true to debug-init\n"; + $pattern[6] = "(.*)ok(.*)(\[0-9]) >(.*)"; $newstate[6] = 7; # state 7 - $done[7] = 0; - $cmd[7] = "true to debug-error\r"; - $msg[7] = "Status: running test - true to debug-error\n"; - $pattern[7] = "(.*)ok(.*)(\[0-9]) >(.*)"; + $done[7] = 0; + $cmd[7] = "true to debug-error\r"; + $msg[7] = "Status: running test - true to debug-error\n"; + $pattern[7] = "(.*)ok(.*)(\[0-9]) >(.*)"; $newstate[7] = 8; # state 8 - $done[8] = 0; - $cmd[8] = "$phandle to active-package\r"; - $msg[8] = "Status: running $phandle to active-package\n"; - $pattern[8] = "(.*)ok(.*)(\[0-9]) >(.*)"; + $done[8] = 0; + $cmd[8] = "$phandle to active-package\r"; + $msg[8] = "Status: running $phandle to active-package\n"; + $pattern[8] = "(.*)ok(.*)(\[0-9]) >(.*)"; $newstate[8] = 9; # state 9 - $done[9] = 0; - $cmd[9] = ".properties\r"; - $msg[9] = "Status: running .properies\n"; - $pattern[9] = "(.*)ok(.*)(\[0-9]) >(.*)"; + $done[9] = 0; + $cmd[9] = ".properties\r"; + $msg[9] = "Status: running .properies\n"; + $pattern[9] = "(.*)ok(.*)(\[0-9]) >(.*)"; $newstate[9] = 10; # state 10 - $done[10] = 0; - $cmd[10] = "clear\r"; - $msg[10] = "Status: running clear\n"; - $pattern[10] = "(.*)ok(.*)(\[0-9]) >(.*)"; + $done[10] = 0; + $cmd[10] = "clear\r"; + $msg[10] = "Status: running clear\n"; + $pattern[10] = "(.*)ok(.*)(\[0-9]) >(.*)"; $newstate[10] = 11; # state 11, all done $done[11] = 1; - $state = 0; - $timeout = 30; # shouldn't take long + $state = 0; + $timeout = 30; # shouldn't take long while ($done[$state] == 0) { send_command($verbose, $rconsole, $cmd[$state]); $rconsole->expect( - [qr/$pattern[$state]/ => - sub { - nc_msg($verbose, $msg[$state]); - $rconsole->clear_accum(); - $state = $newstate[$state]; - } + [ qr/$pattern[$state]/ => + sub { + nc_msg($verbose, $msg[$state]); + $rconsole->clear_accum(); + $state = $newstate[$state]; + } ], - [qr/]/=> - sub { - nc_msg($verbose, "Unexpected prompt\n"); - $rconsole->clear_accum(); - $rc = 1; - } + [ qr/]/ => + sub { + nc_msg($verbose, "Unexpected prompt\n"); + $rconsole->clear_accum(); + $rc = 1; + } ], - [qr/(.*)DEFAULT(.*)/=> - sub { - nc_msg($verbose, "Default catch error\n"); - $rconsole->clear_accum(); - $rc = 1; - } + [ qr/(.*)DEFAULT(.*)/ => + sub { + nc_msg($verbose, "Default catch error\n"); + $rconsole->clear_accum(); + $rc = 1; + } ], - [timeout=> - sub { - nc_msg($verbose, "Timeout\n"); - nc_msg($verbose, "Status: timeout state is $state\n"); - $rconsole->clear_accum(); - $rc = 1; - } + [ timeout => + sub { + nc_msg($verbose, "Timeout\n"); + nc_msg($verbose, "Status: timeout state is $state\n"); + $rconsole->clear_accum(); + $rc = 1; + } ], - [eof => - sub { - nc_msg($verbose, "Cannot connect to $node\n"); - $rconsole->clear_accum(); - $rc = 1; - } + [ eof => + sub { + nc_msg($verbose, "Cannot connect to $node\n"); + $rconsole->clear_accum(); + $rc = 1; + } ], ); return 1 if ($rc eq 1); @@ -2337,6 +2381,7 @@ sub Firmware_Dump { 2 - usage error =cut + #----------------------------------------------------------------------------- sub lparnetbootexp { @@ -2345,9 +2390,9 @@ sub lparnetbootexp { $opt = shift; } - my $CONSOLEBIN = "/opt/xcat/bin/rcons"; - my $PROGRAM = "lpar_netboot"; - my $noboot = 0; #default is to boot + my $CONSOLEBIN = "/opt/xcat/bin/rcons"; + my $PROGRAM = "lpar_netboot"; + my $noboot = 0; #default is to boot my $Boot_timeout = 3000; my @expect_out; my $req = shift; @@ -2368,23 +2413,24 @@ sub lparnetbootexp my $list_type; my $sysoutput; my $exp_internal; -# Flags and initial variable - my $discovery = 0; - my $discover_all = 0; - my $discoverynoping = 0; + + # Flags and initial variable + my $discovery = 0; + my $discover_all = 0; + my $discoverynoping = 0; my $discoverytimeout = 0; - my $verbose = 0; + my $verbose = 0; my $discover_macaddr = 0; - my $rc = 0; - my $debug_flag = 0; - my $rmvterm_flag = 0; - my $immed_flag = 0; - my $from_of = 0; - my $dev_type_found = 0; - my $list_physical = 0; - my $set_boot_order = 0; - my $colon = 0; - my $choice = 0; + my $rc = 0; + my $debug_flag = 0; + my $rmvterm_flag = 0; + my $immed_flag = 0; + my $from_of = 0; + my $dev_type_found = 0; + my $list_physical = 0; + my $set_boot_order = 0; + my $colon = 0; + my $choice = 0; my $full_path_name; my $adap_speed; my $adap_duplex; @@ -2400,121 +2446,121 @@ sub lparnetbootexp my $phys_loc; my $userid; my $passwd; - my $prompt = "\\\$ \$"; + my $prompt = "\\\$ \$"; my $ssh_spawn_id = 0; my $mac_address; my @outputarray; my $outputarrayindex = 0; $::CALLBACK = $req->{callback}; -# -# Log the process id -# + # + # Log the process id + # my $proc_id = getppid; nc_msg($verbose, "$PROGRAM Status: process id is $proc_id\n"); -# -# -# Process command line options and parameters -# -# -#done== + # + # + # Process command line options and parameters + # + # + #done== - if ( exists ($opt->{A})) { + if (exists($opt->{A})) { $discover_all = 1; } - if ( exists ($opt->{C})) { + if (exists($opt->{C})) { $client_ip = $opt->{C}; } - if ( exists ($opt->{D})) { + if (exists($opt->{D})) { $discovery = 1; } - if ( exists ($opt->{noping})) { + if (exists($opt->{noping})) { $discoverynoping = 1; } - if ( exists ($opt->{G})) { + if (exists($opt->{G})) { $gateway_ip = $opt->{G}; } - if ( exists ($opt->{P})) { + if (exists($opt->{P})) { $list_physical = 1; } - if ( exists ($opt->{M})) { + if (exists($opt->{M})) { $discover_macaddr = 1; } - if ( exists ($opt->{N})) { + if (exists($opt->{N})) { $netmask = $opt->{N}; } - if ( exists ($opt->{S})) { + if (exists($opt->{S})) { $server_ip = $opt->{S}; } - if ( exists ($opt->{c})) { + if (exists($opt->{c})) { $colon = 1; } - if ( exists ($opt->{d})) { + if (exists($opt->{d})) { $adap_duplex = $opt->{d}; } - if ( exists ($opt->{f})) { + if (exists($opt->{f})) { $rmvterm_flag = 1; } - if ( exists ($opt->{g})) { + if (exists($opt->{g})) { $extra_args = $opt->{g}; } - if ( exists ($opt->{i})) { + if (exists($opt->{i})) { $immed_flag = 1; } - if ( exists ($opt->{o})) { + if (exists($opt->{o})) { $from_of = 1; } - if ( exists ($opt->{w})) { + if (exists($opt->{w})) { $set_boot_order = $opt->{w}; } - if ( exists ($opt->{L})) { + if (exists($opt->{L})) { $dump_lun = $opt->{L}; } - if ( exists ($opt->{l})) { + if (exists($opt->{l})) { $phys_loc = $opt->{l}; } - if ( exists ($opt->{m})) { + if (exists($opt->{m})) { $macaddress = $opt->{m}; } - if ( exists ($opt->{n})) { + if (exists($opt->{n})) { $noboot = 1; } - if ( exists ($opt->{p})) { + if (exists($opt->{p})) { $dump_port = $opt->{p}; } - if ( exists ($opt->{s})) { + if (exists($opt->{s})) { $adap_speed = $opt->{s}; } - if ( exists ($opt->{T})) { + if (exists($opt->{T})) { $dump_target = $opt->{T}; } - if ( exists ($opt->{t})) { + if (exists($opt->{t})) { $list_type = $opt->{t}; - if ( $list_type eq "hfi-ent" ) { - $dev_pat[0] = "hfi-ethernet"; + if ($list_type eq "hfi-ent") { + $dev_pat[0] = "hfi-ethernet"; $dev_type[0] = "hfi-ent"; } # @@ -2522,29 +2568,30 @@ sub lparnetbootexp # $dev_type_found = 0; foreach my $dev (@dev_type) { - if ( $dev eq $list_type) { + if ($dev eq $list_type) { $dev_type_found = 1; last; } } - if ( $dev_type_found eq 0 ) { - nc_msg($verbose, "$PROGRAM:$dev_type_found, '$list_type' is not a valid adapter choice\n"); - return [1]; + if ($dev_type_found eq 0) { + nc_msg($verbose, "$PROGRAM:$dev_type_found, '$list_type' is not a valid adapter choice\n"); + return [1]; } } - if ( exists ($opt->{v})) { + if (exists($opt->{v})) { $verbose = 1; } else { $verbose = 0; } - if ( exists ($opt->{x})) { + if (exists($opt->{x})) { $debug_flag = 1; } - if ( exists ($opt->{help})) { + if (exists($opt->{help})) { usage; } + #set arg0 [lindex $argv 0] #set arg1 [lindex $argv 1] #if ( scalar(%$opt) > 10 ) { @@ -2552,52 +2599,54 @@ sub lparnetbootexp # usage; #} - if ( $list_physical eq 0 ) { - $dev_pat[3] = "l-lan"; + if ($list_physical eq 0) { + $dev_pat[3] = "l-lan"; $dev_type[3] = "ent"; - $dev_count = scalar(@dev_pat); + $dev_count = scalar(@dev_pat); } else { - $dev_pat[3] = ""; + $dev_pat[3] = ""; $dev_type[3] = ""; - $dev_count = scalar(@dev_pat); + $dev_count = scalar(@dev_pat); } - if ( $set_boot_order > 1 ) { - $dev_pat[4] = "scsi"; + if ($set_boot_order > 1) { + $dev_pat[4] = "scsi"; $dev_type[4] = "disk"; - $dev_count = scalar(@dev_pat); + $dev_count = scalar(@dev_pat); } - my $node = $opt->{node}; + my $node = $opt->{node}; my $profile = $opt->{pprofile}; - my $manage = $opt->{fsp}; - my $lparid = $opt->{id}; - my $hcp = $opt->{hcp}; + my $manage = $opt->{fsp}; + my $lparid = $opt->{id}; + my $hcp = $opt->{hcp}; - if ($dev_type_found) { nc_msg($verbose, "$PROGRAM Status: List only $list_type adapters\n"); } - if ($noboot) { nc_msg($verbose, "$PROGRAM Status: -n (no boot) flag detected\n"); } - if ($discovery) { nc_msg($verbose, "$PROGRAM Status: -D (discovery) flag detected\n"); } - if ($discoverynoping) { nc_msg($verbose, "$PROGRAM Status: --noping (discovery) flag detected\n"); } - if ($discover_all) { nc_msg($verbose, "$PROGRAM Status: -A (discover all) flag detected\n" ); } - if ($verbose) { nc_msg($verbose, "$PROGRAM Status: -v (verbose debug) flag detected\n"); } - if ($discover_macaddr) { nc_msg($verbose, "$PROGRAM Status: -M (discover mac address) flag detected\n"); } - if ($immed_flag) { nc_msg($verbose, "$PROGRAM Status: -i (force immediate shutdown) flag detected\n"); } - if ($list_physical) { nc_msg($verbose, "$PROGRAM Status: -P (list only phsical network) flag detected\n");} - if ($colon) { nc_msg($verbose, "$PROGRAM Status: -c (list colon separated ) flag detected\n" ); } - if ($debug_flag) { + if ($dev_type_found) { nc_msg($verbose, "$PROGRAM Status: List only $list_type adapters\n"); } + if ($noboot) { nc_msg($verbose, "$PROGRAM Status: -n (no boot) flag detected\n"); } + if ($discovery) { nc_msg($verbose, "$PROGRAM Status: -D (discovery) flag detected\n"); } + if ($discoverynoping) { nc_msg($verbose, "$PROGRAM Status: --noping (discovery) flag detected\n"); } + if ($discover_all) { nc_msg($verbose, "$PROGRAM Status: -A (discover all) flag detected\n"); } + if ($verbose) { nc_msg($verbose, "$PROGRAM Status: -v (verbose debug) flag detected\n"); } + if ($discover_macaddr) { nc_msg($verbose, "$PROGRAM Status: -M (discover mac address) flag detected\n"); } + if ($immed_flag) { nc_msg($verbose, "$PROGRAM Status: -i (force immediate shutdown) flag detected\n"); } + if ($list_physical) { nc_msg($verbose, "$PROGRAM Status: -P (list only phsical network) flag detected\n"); } + if ($colon) { nc_msg($verbose, "$PROGRAM Status: -c (list colon separated ) flag detected\n"); } + + if ($debug_flag) { nc_msg($verbose, "$PROGRAM Status: -d (debug) flag detected\n"); + #$exp_internal = 1; #$log_user = 1; } - if ($discovery and $adap_speed ) { nc_msg($verbose, "$PROGRAM Status: using adapter speed of $adap_speed\n" ); } - if ($discovery and $adap_duplex ) { nc_msg($verbose, "$PROGRAM Status: using adapter duplex of $adap_duplex\n" ); } - if ($discovery and $server_ip ) { nc_msg($verbose, "$PROGRAM Status: using server IP address of $server_ip\n"); } - if ($discovery and $client_ip) { nc_msg($verbose, "$PROGRAM Status: using client IP address of $client_ip\n" ); } - if ($discovery and $gateway_ip) { nc_msg($verbose, "$PROGRAM Status: using gateway IP address of $gateway_ip\n"); } - if ($discovery and $macaddress) { nc_msg($verbose, "$PROGRAM Status: using macaddress of $macaddress\n" ); } - if ($discovery and $phys_loc ) { nc_msg($verbose, "$PROGRAM Status: using physical location code of $phys_loc\n"); } - nc_msg($verbose, "node:".$node); + if ($discovery and $adap_speed) { nc_msg($verbose, "$PROGRAM Status: using adapter speed of $adap_speed\n"); } + if ($discovery and $adap_duplex) { nc_msg($verbose, "$PROGRAM Status: using adapter duplex of $adap_duplex\n"); } + if ($discovery and $server_ip) { nc_msg($verbose, "$PROGRAM Status: using server IP address of $server_ip\n"); } + if ($discovery and $client_ip) { nc_msg($verbose, "$PROGRAM Status: using client IP address of $client_ip\n"); } + if ($discovery and $gateway_ip) { nc_msg($verbose, "$PROGRAM Status: using gateway IP address of $gateway_ip\n"); } + if ($discovery and $macaddress) { nc_msg($verbose, "$PROGRAM Status: using macaddress of $macaddress\n"); } + if ($discovery and $phys_loc) { nc_msg($verbose, "$PROGRAM Status: using physical location code of $phys_loc\n"); } + nc_msg($verbose, "node:" . $node); #################################### # process the arguments #################################### @@ -2641,9 +2690,10 @@ sub lparnetbootexp # This corresponds to the Tcl log_user variable. ################################################## #$rconsole->log_stdout( $verbose ); #hidden information return from rcons - $rconsole->log_stdout(0); #hidden information return from rcons + $rconsole->log_stdout(0); #hidden information return from rcons my $consolefork = $rconsole->spawn($cmd); + #$rconsole->log_file("/tmp/consolelog"); my $console_pid = $rconsole->pid; unless ($console_pid) { @@ -2664,38 +2714,39 @@ sub lparnetbootexp # Send Ctrl-E, c and ? to get the help to come out to support # both confluent and conserver consoles $rconsole->send("\005c?"); - # for some reason the ctrl-e is not being sent for confluent, just getting c? + + # for some reason the ctrl-e is not being sent for confluent, just getting c? $timeout = 10; $rconsole->expect( $timeout, [ qr/c?/i => - sub { + sub { $rc = 0; $rconsole->clear_accum(); nc_msg($verbose, "Confluent -> Connected.\n"); - } + } ], [ qr/help.*/i => - sub { + sub { $rc = 0; $rconsole->clear_accum(); nc_msg($verbose, "Conserver -> Connected.\n"); - } + } ], [ timeout => - sub { + sub { $rc = 1; $rconsole->clear_accum(); nc_msg($verbose, "Timeout waiting for console connection.\n"); - } + } ], [ eof => - sub { + sub { $rc = 2; $rconsole->clear_accum(); nc_msg(1, "Please make sure rcons $node works.\n"); - } + } ], ); @@ -2716,7 +2767,7 @@ sub lparnetbootexp } if ($from_of) { - unless($output =~ /open firmware/i){ + unless ($output =~ /open firmware/i) { nc_msg(2, "You are using the -o option. Please make sure the LPAR's initial state is open firmware.\n"); return [1]; } @@ -2727,7 +2778,7 @@ sub lparnetbootexp # if -o is not used, power node of #################################### unless ($from_of) { - if (($output =~ /^off$/i) or ($output =~ /Not Activated/i) ) { + if (($output =~ /^off$/i) or ($output =~ /Not Activated/i)) { nc_msg($verbose, "# Power off complete.\n"); } else { nc_msg($verbose, "# Begin to Power off the node.\n"); @@ -2737,9 +2788,9 @@ sub lparnetbootexp node => [$node], arg => ['off'] }, - $subreq, 0, 1); + $subreq, 0, 1); $output = join ',', @$sysoutput; - if ($::RUNCMD_RC != 0) { #$::RUNCMD_RC will get its value from runxcmd_output + if ($::RUNCMD_RC != 0) { #$::RUNCMD_RC will get its value from runxcmd_output nc_msg($verbose, "Unable to run rpower $node off.\n"); return [1]; } @@ -2751,7 +2802,7 @@ sub lparnetbootexp nc_msg($verbose, "Wait for power off.\n"); } - $done = 0; + $done = 0; $query_count = 0; while (!$done) { $output = xCAT::LparNetbootExp->run_lssyscfg($subreq, $verbose, $node); @@ -2775,7 +2826,7 @@ sub lparnetbootexp # if set_boot_order is set, set the boot order # if not set, power the node to open firmware ################################################# - $done = 0; + $done = 0; $retry_count = 0; if ($set_boot_order > 1) { nc_msg($verbose, "Power on $node to SMS.\n"); @@ -2786,7 +2837,7 @@ sub lparnetbootexp node => [$node], arg => ['sms'] }, - $subreq, 0, 1); + $subreq, 0, 1); $output = join ',', @$sysoutput; nc_msg($verbose, "Waiting for power on...\n"); @@ -2800,7 +2851,7 @@ sub lparnetbootexp return [1]; } sleep 1; - $retry_count ++; + $retry_count++; } else { $done = 1; } @@ -2814,7 +2865,7 @@ sub lparnetbootexp node => [$node], arg => ['of'] }, - $subreq, 0, 1); + $subreq, 0, 1); $output = join ',', @$sysoutput; nc_msg($verbose, "Waiting for power on...\n"); @@ -2828,7 +2879,7 @@ sub lparnetbootexp return [1]; } sleep 1; - $retry_count ++; + $retry_count++; } else { $done = 1; } @@ -2839,11 +2890,11 @@ sub lparnetbootexp ########################### # Check the node state ########################### - $done = 0; + $done = 0; $query_count = 0; - $timeout = 1; + $timeout = 1; nc_msg($verbose, "Check the node state again;"); - while(!$done) { + while (!$done) { $output = xCAT::LparNetbootExp->run_lssyscfg($subreq, $verbose, $node); nc_msg($verbose, "The node state is $output.\n"); if ($output =~ /Open Firmware/i) { @@ -2853,19 +2904,21 @@ sub lparnetbootexp } $query_count++; + # if the node is not in openfirmware state, just wait for it my @result = $rconsole->expect( $timeout, - [ qr/(.*)elect this consol(.*)/=> - sub { - $rconsole->send("0\r"); - $rconsole->clear_accum(); - #$rconsole->exp_continue(); - } + [ qr/(.*)elect this consol(.*)/ => + sub { + $rconsole->send("0\r"); + $rconsole->clear_accum(); + + #$rconsole->exp_continue(); + } ], ); - if ($query_count > 300 ) { + if ($query_count > 300) { nc_msg($verbose, "Timed out waiting for power on of $node"); nc_msg($verbose, "error from rpower command : \"$output\" \n"); return [1]; @@ -2879,7 +2932,7 @@ sub lparnetbootexp # Check for active console ############################## nc_msg($verbose, "Check for active console.\n"); - $done = 0; + $done = 0; $retry_count = 0; $timeout = 10; @@ -2887,66 +2940,67 @@ sub lparnetbootexp while (!$done) { my @result = $rconsole->expect( $timeout, + #[qr/ok(.*)0 >/=> - [qr/0(.*)ok/=> - sub { - nc_msg($verbose, " at ok prompt\n"); - $rconsole->clear_accum(); - $done = 1; - } + [ qr/0(.*)ok/ => + sub { + nc_msg($verbose, " at ok prompt\n"); + $rconsole->clear_accum(); + $done = 1; + } ], - [qr/(.*)elect this consol(.*)/=> - sub { - nc_msg($verbose, " selecting active console\n"); - $rconsole->clear_accum(); - $rconsole->send("0\r"); - } + [ qr/(.*)elect this consol(.*)/ => + sub { + nc_msg($verbose, " selecting active console\n"); + $rconsole->clear_accum(); + $rconsole->send("0\r"); + } ], - [qr/English|French|German|Italian|Spanish|Portuguese|Chinese|Japanese|Korean/=> - sub { - nc_msg($verbose, "Languagae Selection Panel received\n"); - $rconsole->clear_accum(); - $rconsole->send("2\r"); - } + [ qr/English|French|German|Italian|Spanish|Portuguese|Chinese|Japanese|Korean/ => + sub { + nc_msg($verbose, "Languagae Selection Panel received\n"); + $rconsole->clear_accum(); + $rconsole->send("2\r"); + } ], - [qr/admin/=> - sub { - nc_msg($verbose, "No password specified\n"); - $rconsole->soft_close(); - $rc = 1; - } - ], - [qr/Invalid Password/=> - sub { - nc_msg($verbose, "FSP password is invalid.\n"); - $rconsole->soft_close(); - $rc = 1; - } - ], - [qr/SMS(.*)Navigation Keys/=> - sub { - nc_msg($verbose, "SMS\n"); - $rconsole->clear_accum(); - $done = 1; - } - ], - [timeout=> - sub { - $rconsole->send("\r"); - $retry_count++; - if ($retry_count eq 9) { - nc_msg($verbose, "Timeout waiting for ok prompt; exiting.\n"); + [ qr/admin/ => + sub { + nc_msg($verbose, "No password specified\n"); $rconsole->soft_close(); $rc = 1; - } - } + } ], - [eof => - sub { - nc_msg($verbose, "Cannot connect to $node"); - $rconsole->soft_close(); - $rc = 1; - } + [ qr/Invalid Password/ => + sub { + nc_msg($verbose, "FSP password is invalid.\n"); + $rconsole->soft_close(); + $rc = 1; + } + ], + [ qr/SMS(.*)Navigation Keys/ => + sub { + nc_msg($verbose, "SMS\n"); + $rconsole->clear_accum(); + $done = 1; + } + ], + [ timeout => + sub { + $rconsole->send("\r"); + $retry_count++; + if ($retry_count eq 9) { + nc_msg($verbose, "Timeout waiting for ok prompt; exiting.\n"); + $rconsole->soft_close(); + $rc = 1; + } + } + ], + [ eof => + sub { + nc_msg($verbose, "Cannot connect to $node"); + $rconsole->soft_close(); + $rc = 1; + } ], ); return [1] if ($rc eq 1); @@ -2958,10 +3012,10 @@ sub lparnetbootexp ############################## # Set the node boot order ############################## - if ($set_boot_order) { #rnetboot node will not go here + if ($set_boot_order) { #rnetboot node will not go here nc_msg($verbose, "begin to set disk boot"); - my $result = set_disk_boot( $rconsole, $node, $verbose);#@expect_out, $rconsole, $node, $verbose); - unless( $result ) { + my $result = set_disk_boot($rconsole, $node, $verbose); #@expect_out, $rconsole, $node, $verbose); + unless ($result) { nc_msg($verbose, "Unable to set $node boot order"); } } @@ -2974,15 +3028,15 @@ sub lparnetbootexp # supported network adapters # in the device tree. ############################## - $done = 0; + $done = 0; $retry_count = 0; nc_msg($verbose, "begin to run get_phandle"); while (!$done) { my $result = get_phandle($rconsole, $node, $verbose); - if ( $result eq 1) { + if ($result eq 1) { $retry_count++; $rconsole->send("\r"); - if ( $retry_count eq 3) { + if ($retry_count eq 3) { nc_msg($verbose, "Unable to obtain network adapter information. Quitting.\n"); return [1]; } @@ -2999,16 +3053,16 @@ sub lparnetbootexp ############################## nc_msg($verbose, "begin to run multiple_open_dev"); my $result = xCAT::LparNetbootExp->multiple_open_dev($rconsole, $node, $verbose); - if ( $result eq 1) { - nc_msg($verbose, "Unable to obtain network adapter information. Quitting.\n"); - return [1]; + if ($result eq 1) { + nc_msg($verbose, "Unable to obtain network adapter information. Quitting.\n"); + return [1]; } ############################## # ############################## nc_msg($verbose, "begin to process opt-discovery"); - if ($discovery && !$discoverynoping) { #rnetboot node will not go here + if ($discovery && !$discoverynoping) { #rnetboot node will not go here nc_msg($verbose, "# Client IP address is $client_ip\n"); nc_msg($verbose, "# Server IP address is $server_ip\n"); nc_msg($verbose, "# Gateway IP address is $gateway_ip\n"); @@ -3019,7 +3073,7 @@ sub lparnetbootexp # Display information for all # supported adapters ############################## - if ($noboot) { #if not do net boot + if ($noboot) { #if not do net boot if ($list_type) { $match_pat = $list_type; } else { @@ -3027,9 +3081,9 @@ sub lparnetbootexp } - if($colon) { + if ($colon) { nc_msg($verbose, "#Type:Location_Code:MAC_Address:Full_Path_Name:Ping_Result:Device_Type:Size_MB:OS:OS_Version:\n"); - $outputarrayindex++; # start from 1, 0 is used to set as 0 + $outputarrayindex++; # start from 1, 0 is used to set as 0 $outputarray[$outputarrayindex] = "#Type:Location_Code:MAC_Address:Full_Path_Name:Ping_Result:Device_Type:Size_MB:OS:OS_Version:"; } else { if ($discoverynoping) { @@ -3043,8 +3097,8 @@ sub lparnetbootexp } } - if ( $discover_all ) { #getmacs here - for( $i = 0; $i < $adapter_found; $i++) { + if ($discover_all) { #getmacs here + for ($i = 0 ; $i < $adapter_found ; $i++) { if ($adap_type[$i] =~ /$match_pat/) { if (!($adap_type[$i] eq "hfi-ent")) { $mac_address = get_mac_addr($phandle_array[$i], $rconsole, $node, $verbose); @@ -3054,19 +3108,19 @@ sub lparnetbootexp if ($discovery && !$discoverynoping) { $ping_rc = ping_server($phandle_array[$i], $full_path_name_array[$i], $rconsole, $node, $mac_address, $verbose, $adap_speed, $adap_duplex, $list_type, $server_ip, $client_ip, $gateway_ip); nc_msg($verbose, "ping_server returns $ping_rc\n"); - unless( $ping_rc eq 0) { + unless ($ping_rc eq 0) { $ping_result = "unsuccessful"; } else { $ping_result = "successful"; } } - if ( $adap_type[$i] eq "hfi-ent") { + if ($adap_type[$i] eq "hfi-ent") { $mac_address = get_mac_addr($phandle_array[$i], $rconsole, $node, $verbose); $loc_code = get_adaptr_loc($phandle_array[$i], $rconsole, $node, $verbose); } - if ($full_path_name_array[$i] =~ /vdevice/) { + if ($full_path_name_array[$i] =~ /vdevice/) { $device_type = "virtual"; } else { $device_type = "physical"; @@ -3074,20 +3128,20 @@ sub lparnetbootexp if (defined($mac_address)) { my @newmacs = (); - my @allmacs = split /\|/,$mac_address; - if ( !xCAT::Utils->isAIX() ) { - foreach my $mac_a ( @allmacs ) { + my @allmacs = split /\|/, $mac_address; + if (!xCAT::Utils->isAIX()) { + foreach my $mac_a (@allmacs) { $mac_a = lc($mac_a); $mac_a =~ s/(\w{2})/$1:/g; $mac_a =~ s/:$//; push @newmacs, $mac_a; } - $mac_address = join("|",@newmacs); - } + $mac_address = join("|", @newmacs); + } } - if($colon) { + if ($colon) { nc_msg($verbose, "$adap_type[$i]\:$loc_code\:$mac_address\:$full_path_name_array[$i]\:$ping_result\:$device_type\:\:\:\:\n"); $outputarrayindex++; $outputarray[$outputarrayindex] = "$adap_type[$i]\:$loc_code\:$mac_address\:$full_path_name_array[$i]\:$ping_result\:$device_type\:\:\:\:"; @@ -3099,7 +3153,7 @@ sub lparnetbootexp } } } else { - for( $i = 0; $i < $adapter_found; $i++) { + for ($i = 0 ; $i < $adapter_found ; $i++) { if ($adap_type[$i] =~ /$match_pat/) { if (!($adap_type[$i] eq "hfi-ent")) { $mac_address = get_mac_addr($phandle_array[$i], $rconsole, $node, $verbose); @@ -3109,25 +3163,25 @@ sub lparnetbootexp if ($discovery && !$discoverynoping) { $ping_rc = ping_server($phandle_array[$i], $full_path_name_array[$i], $rconsole, $node, $mac_address, $verbose, $adap_speed, $adap_duplex, $list_type, $server_ip, $client_ip, $gateway_ip); nc_msg($verbose, "ping_server returns $ping_rc\n"); - unless( $ping_rc eq 0) { + unless ($ping_rc eq 0) { $ping_result = "unsuccessful"; } else { $ping_result = "successful"; } } - if ( $adap_type[$i] eq "hfi-ent") { + if ($adap_type[$i] eq "hfi-ent") { $mac_address = get_mac_addr($phandle_array[$i], $rconsole, $node, $verbose); $loc_code = get_adaptr_loc($phandle_array[$i], $rconsole, $node, $verbose); } - if ($full_path_name_array[$i] =~ /vdevice/) { + if ($full_path_name_array[$i] =~ /vdevice/) { $device_type = "virtual"; } else { $device_type = "physical"; } - if($colon) { + if ($colon) { nc_msg($verbose, "$adap_type[$i]\:$loc_code\:$mac_address\:$full_path_name_array[$i]\:$ping_result\:$device_type\:\:\:\:\n"); } else { nc_msg($verbose, "$adap_type[$i] $loc_code $mac_address $full_path_name_array[$i] $ping_result $device_type\n"); @@ -3144,7 +3198,7 @@ sub lparnetbootexp node => [$node], arg => ['off'] }, - $subreq, 0, 1); + $subreq, 0, 1); $output = join ',', @$sysoutput; if ($::RUNCMD_RC != 0) { nc_msg($verbose, "Unable to run rpower $node sms.\n"); @@ -3153,52 +3207,52 @@ sub lparnetbootexp return [1]; } } - } else { # Do a network boot - # Loop throught the adapters and perform a ping test to discover an - # adapter that pings successfully, then use that adapter to network boot. - if ($discover_all) { #rnetboot should not use -A - for ($i = 0; $i < $adapter_found; $i++) { + } else { # Do a network boot + # Loop throught the adapters and perform a ping test to discover an + # adapter that pings successfully, then use that adapter to network boot. + if ($discover_all) { #rnetboot should not use -A + for ($i = 0 ; $i < $adapter_found ; $i++) { $ping_rc = ping_server($phandle_array[$i], $full_path_name_array[$i], $rconsole, $node, $mac_address, $verbose, $adap_speed, $adap_duplex, $list_type, $server_ip, $client_ip, $gateway_ip); - if ( $ping_rc eq 0) { - $phandle = $phandle_array[$i]; - $full_path_name = $full_path_name_array[$i]; + if ($ping_rc eq 0) { + $phandle = $phandle_array[$i]; + $full_path_name = $full_path_name_array[$i]; $chosen_adap_type = $adap_type[$i]; last; } } - } elsif ( $macaddress ne "" ) { #rnetboot here + } elsif ($macaddress ne "") { #rnetboot here $match = 0; - for ($i = 0; $i < $adapter_found; $i++) { + for ($i = 0 ; $i < $adapter_found ; $i++) { if ($adap_type[$i] =~ /hfi-ent/) { $ping_rc = ping_server($phandle_array[$i], $full_path_name_array[$i], $rconsole, $node, $mac_address, $verbose, $adap_speed, $adap_duplex, $list_type, $server_ip, $client_ip, $gateway_ip); } $mac_address = get_mac_addr($phandle_array[$i], $rconsole, $node, $verbose); - if ( $macaddress =~ /$mac_address/ ) { + if ($macaddress =~ /$mac_address/) { if (($discovery eq 1) && !$discoverynoping) { - unless ( $adap_type[$i] eq "hfi-ent" ) { - $ping_rc = ping_server($phandle_array[$i], $full_path_name_array[$i], $rconsole, $node, $mac_address, $verbose, $adap_speed, $adap_duplex, $list_type, $server_ip, $client_ip, $gateway_ip); + unless ($adap_type[$i] eq "hfi-ent") { + $ping_rc = ping_server($phandle_array[$i], $full_path_name_array[$i], $rconsole, $node, $mac_address, $verbose, $adap_speed, $adap_duplex, $list_type, $server_ip, $client_ip, $gateway_ip); } - unless ( $ping_rc eq 0) { - nc_msg($verbose, "Unable to boot network adapter.\n" ); + unless ($ping_rc eq 0) { + nc_msg($verbose, "Unable to boot network adapter.\n"); return [1]; } } - $phandle = $phandle_array[$i]; - $full_path_name = $full_path_name_array[$i]; - $chosen_adap_type = $adap_type[$i]; - $match = 1; - last; + $phandle = $phandle_array[$i]; + $full_path_name = $full_path_name_array[$i]; + $chosen_adap_type = $adap_type[$i]; + $match = 1; + last; } } - unless($match) { + unless ($match) { nc_msg($verbose, "Can not find mac address '$macaddress'\n"); return [1]; } - } elsif ( $phys_loc ne "") { + } elsif ($phys_loc ne "") { $match = 0; - for ($i = 0; $i < $adapter_found; $i++) { + for ($i = 0 ; $i < $adapter_found ; $i++) { $loc_code = get_adaptr_loc($phandle_array[$i], $rconsole, $node, $verbose); if ($loc_code =~ /$phys_loc/) { if ($discovery && !$discoverynoping) { @@ -3208,10 +3262,10 @@ sub lparnetbootexp return [1]; } } - $phandle = $phandle_array[$i]; - $full_path_name = $full_path_name_array[$i]; + $phandle = $phandle_array[$i]; + $full_path_name = $full_path_name_array[$i]; $chosen_adap_type = $adap_type[$i]; - $match = 1; + $match = 1; last; } } @@ -3220,21 +3274,21 @@ sub lparnetbootexp return [1]; } } else { - # - # Use the first ethernet adapter in the - # device tree. - # - for ($i = 0; $i < $adapter_found; $i++) { - nc_msg($verbose, " begint to boot from first adapter in the device tree \n"); - if ($adap_type[$i] eq $list_type ) { - if ( ($discovery eq 1) && !$discoverynoping ){ + # + # Use the first ethernet adapter in the + # device tree. + # + for ($i = 0 ; $i < $adapter_found ; $i++) { + nc_msg($verbose, " begint to boot from first adapter in the device tree \n"); + if ($adap_type[$i] eq $list_type) { + if (($discovery eq 1) && !$discoverynoping) { $ping_rc = ping_server($phandle_array[$i], $full_path_name_array[$i], $rconsole, $node, $mac_address, $verbose, $adap_speed, $adap_duplex, $list_type, $server_ip, $client_ip, $gateway_ip); unless ($ping_rc eq 0) { return [1]; } } - $phandle = $phandle_array[$i]; - $full_path_name = $full_path_name_array[$i]; + $phandle = $phandle_array[$i]; + $full_path_name = $full_path_name_array[$i]; $chosen_adap_type = $adap_type[$i]; last; } @@ -3246,13 +3300,13 @@ sub lparnetbootexp return [1]; } else { nc_msg($verbose, "# Network booting install adapter.\n"); - $result = xCAT::LparNetbootExp->boot_network($rconsole, $full_path_name, $adap_speed, $adap_duplex , $chosen_adap_type, $server_ip, $client_ip, $gateway_ip, $netmask, $dump_target, $dump_lun, $dump_port, $verbose, $extra_args, $node, $set_boot_order ); + $result = xCAT::LparNetbootExp->boot_network($rconsole, $full_path_name, $adap_speed, $adap_duplex, $chosen_adap_type, $server_ip, $client_ip, $gateway_ip, $netmask, $dump_target, $dump_lun, $dump_port, $verbose, $extra_args, $node, $set_boot_order); } if ($result eq 0) { nc_msg($verbose, "bootp sent over netowrk.\n"); - my $res = Boot($rconsole, $node, $verbose);#, @expect_out); + my $res = Boot($rconsole, $node, $verbose); #, @expect_out); unless ($res eq 0) { nc_msg($verbose, "Can not boot, result = $res. \n"); } @@ -3284,18 +3338,18 @@ sub lparnetbootexp } ], [ eof => - sub { + sub { nc_msg($verbose, "cannot connect to $node.\n"); $rconsole->clear_accum(); $rc = 1; - } + } ], [ sub { nc_msg($verbose, "# Network booting install adapter.\n"); nc_msg($verbose, "Retrying network-boot from RESTART-CMD error.\n"); $done = 0; - while (! $done ) { + while (!$done) { my $res = xCAT::LparNetbootExp->boot_network($node,); if ($res eq 0) { $done = 1; @@ -3308,7 +3362,7 @@ sub lparnetbootexp ); return [1] if ($rc eq 1); nc_msg($verbose, "# bootp sent over network.\n"); - $rc = Boot($rconsole, $node, $verbose);#, @expect_out); + $rc = Boot($rconsole, $node, $verbose); #, @expect_out); unless ($rc eq 0) { nc_msg($verbose, "Can't boot here. \n"); } @@ -3318,9 +3372,9 @@ sub lparnetbootexp ################################################ # mission accomplished, beam me up scotty. ################################################# - unless ($noboot) { #if do the rnetboot, just return - if ( $rc eq 0) { - nc_msg($verbose, "# Finished.\n" ); + unless ($noboot) { #if do the rnetboot, just return + if ($rc eq 0) { + nc_msg($verbose, "# Finished.\n"); $outputarrayindex++; $outputarray[$outputarrayindex] = "Finished."; } else { @@ -3328,26 +3382,26 @@ sub lparnetbootexp $outputarrayindex++; $outputarray[$outputarrayindex] = "Finished in an error."; } - } else { #if not rnetboot, for example, getmacs, power off the node - $done = 0; + } else { #if not rnetboot, for example, getmacs, power off the node + $done = 0; $query_count = 0; - while(!$done) { + while (!$done) { $output = xCAT::LparNetbootExp->run_lssyscfg($subreq, $verbose, $node); ############################################## # separate the nodename from the query status ############################################## if ($from_of != 1) { - if (( $output =~ /^off$/i ) or ($output =~ /Not Activated/i)) { + if (($output =~ /^off$/i) or ($output =~ /Not Activated/i)) { $done = 1; } } else { - if ( $output =~ /firmware/i ) { + if ($output =~ /firmware/i) { $done = 1; } } $query_count++; - if ( $query_count > 60 ){ + if ($query_count > 60) { $done = 1; } sleep 1; diff --git a/perl-xCAT/xCAT/MacMap.pm b/perl-xCAT/xCAT/MacMap.pm index 55f2c8c94..23eb69e91 100644 --- a/perl-xCAT/xCAT/MacMap.pm +++ b/perl-xCAT/xCAT/MacMap.pm @@ -4,13 +4,13 @@ package xCAT::MacMap; BEGIN { - $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; } use lib "$::XCATROOT/lib/perl"; require Exporter; -our @ISA=qw/Exporter/; -our @EXPORT_OK=qw/walkoid/; +our @ISA = qw/Exporter/; +our @EXPORT_OK = qw/walkoid/; use strict; use xCAT::Table; use xCAT::Utils; @@ -20,10 +20,12 @@ use xCAT::NetworkUtils; use IO::Select; use IO::Handle; use Sys::Syslog; + #use Data::Dumper; use POSIX qw/WNOHANG/; use SNMP; my %cisco_vlans; #Special hash structure to reflect discovered VLANS on Cisco equip + #use IF-MIB (1.3.6.1.2.1.2) for all switches # 1.3.6.1.2.1.31.1.1 - ifXtable # 1.3.6.1.2.1.31.1.1.1.1.N = name - ifName @@ -31,9 +33,9 @@ my %cisco_vlans; #Special hash structure to reflect discovered VLANS on Cisco eq # 1.3.6.1.2.1.17.1.4 - dot1dBasePortTable # 1.3.6.1.2.1.17.1.4.1.1.X = N - dot1dBasePort # 1.3.6.1.2.1.17.4.3 - dot1dTpFdbTable #FAILS on FORCE10, -# +# #If particular result fails, fallback to Q-BRIDGE-MIB for Force10 (1.3.6.1.2.1.17.7) -# 1.3.6.1.2.1.17.7.1.2.2 - dot1qTpFdbTable +# 1.3.6.1.2.1.17.7.1.2.2 - dot1qTpFdbTable #now for the lldp fun. lldp mib uses yet another index. The mib states @@ -82,6 +84,7 @@ my %cisco_vlans; #Special hash structure to reflect discovered VLANS on Cisco eq sub namesmatch { + =pod MacMap attempts to do it's best to determine whether or not a particular SNMP description of @@ -97,68 +100,76 @@ existing rule, it is recommended to use snmpwalk on the switch with the .1.3.6.1 OID, and have the switch table port value match exactly the format suggested by that OID. =cut - my $namepercfg = shift; - my $namepersnmp = shift; - if ($namepercfg eq $namepersnmp) { - return 1; # They matched perfectly - } - #Begin guessing, first off, all tested scenarios have likely correct guesses ending - #in the cfg string, with some non-numeric prefix before it. - #3com convention, contributed by Aaron Knister - if ( $namepersnmp =~ /^RMON Port (0?)(\d+) on unit \d+/ ) { - if ( $2 =~ $namepercfg ) { - return 1; - } - } - # dell 6248 convention - if ( $namepersnmp =~ /^Unit \d Port (\d+)$/ ) { - if ( $1 eq $namepercfg ) { - return 1; + my $namepercfg = shift; + my $namepersnmp = shift; + if ($namepercfg eq $namepersnmp) { + return 1; # They matched perfectly + } + + #Begin guessing, first off, all tested scenarios have likely correct guesses ending + #in the cfg string, with some non-numeric prefix before it. + #3com convention, contributed by Aaron Knister + if ($namepersnmp =~ /^RMON Port (0?)(\d+) on unit \d+/) { + if ($2 =~ $namepercfg) { + return 1; + } + } + + # dell 6248 convention + if ($namepersnmp =~ /^Unit \d Port (\d+)$/) { + if ($1 eq $namepercfg) { + return 1; + } } - } - unless ($namepersnmp =~ /[^0123456789]$namepercfg(\.0)?\z/) { #ensure name from user exists in the string without being preceeded immediately by a number, and allowing a .0 to exist after the cfg for juniper - #Most common case, won't match at all - return 0; - } - #at this point we know the string the user wanted does exist on this port, now we move on to non-ethernet ports that may ambiguously match the user request as well + unless ($namepersnmp =~ /[^0123456789]$namepercfg(\.0)?\z/) { #ensure name from user exists in the string without being preceeded immediately by a number, and allowing a .0 to exist after the cfg for juniper + #Most common case, won't match at all + return 0; + } - #stop contemplating vlan, Nu, stacking ports, and console interfaces - if (($namepersnmp =~ /vl/i) or ($namepersnmp =~ /Nu/) or ($namepersnmp =~ /onsole/) or ($namepersnmp =~ /Stack/) or ($namepersnmp =~ /Trunk/)) { - return 0; - } - #broken up for code readablitiy, don't check port channel numbers or CPU - #have to distinguish betweer Port and Po and PortChannel - if (($namepersnmp !~ /Port #/) and ($namepersnmp !~ /Port\d/) and ($namepersnmp =~ /Po/) or ($namepersnmp =~ /po\d/) or ($namepersnmp =~ /XGE/) or ($namepersnmp =~ /LAG/) or ($namepersnmp =~ /CPU/)) { - return 0; - } - #don't contemplate ManagementEthernet - if (($namepersnmp =~ /Management/)) { - return 0; - } - #The blacklist approach has been exhausted. For now, assuming that means good, - #if something ambiguous happens, the whitelist would have been: - #'Port','Port #','/' (if namepercfg has no /, then / would be...), - #'Gi','Te','GigabitEthernet','TenGigabitEthernet' - return 1; + #at this point we know the string the user wanted does exist on this port, now we move on to non-ethernet ports that may ambiguously match the user request as well + + #stop contemplating vlan, Nu, stacking ports, and console interfaces + if (($namepersnmp =~ /vl/i) or ($namepersnmp =~ /Nu/) or ($namepersnmp =~ /onsole/) or ($namepersnmp =~ /Stack/) or ($namepersnmp =~ /Trunk/)) { + return 0; + } + + #broken up for code readablitiy, don't check port channel numbers or CPU + #have to distinguish betweer Port and Po and PortChannel + if (($namepersnmp !~ /Port #/) and ($namepersnmp !~ /Port\d/) and ($namepersnmp =~ /Po/) or ($namepersnmp =~ /po\d/) or ($namepersnmp =~ /XGE/) or ($namepersnmp =~ /LAG/) or ($namepersnmp =~ /CPU/)) { + return 0; + } + + #don't contemplate ManagementEthernet + if (($namepersnmp =~ /Management/)) { + return 0; + } + + #The blacklist approach has been exhausted. For now, assuming that means good, + #if something ambiguous happens, the whitelist would have been: + #'Port','Port #','/' (if namepercfg has no /, then / would be...), + #'Gi','Te','GigabitEthernet','TenGigabitEthernet' + return 1; } sub new { - my $self = {}; - # Since switch.pm and lsslp.pm both create a MacMap object, SNMP is still required at xcatd start up. - # So we are going back to "use SNMP;" at the top of this file so RPM will automatically generate a prereq. - #eval { require SNMP; }; - #if ($@) { die "SNMP support required to use MacMAP"; } - my $proto = shift; - my $class = ref($proto) || $proto; + my $self = {}; - bless ($self, $class); - return $self; + # Since switch.pm and lsslp.pm both create a MacMap object, SNMP is still required at xcatd start up. + # So we are going back to "use SNMP;" at the top of this file so RPM will automatically generate a prereq. + #eval { require SNMP; }; + #if ($@) { die "SNMP support required to use MacMAP"; } + my $proto = shift; + my $class = ref($proto) || $proto; + + bless($self, $class); + return $self; } sub rvlan { + #The Q-BRIDGE way: #IF-MIB for ifName<->ifIndex (much like the find_mac code) #BRIDGE-MIB for ifIndex<->BridgeIndex (again, familiar) @@ -172,69 +183,75 @@ sub rvlan { #argument specification: # nodes => [ list reference of nodes to query/set ] # operation => "pvid= or vlan=" for now, addvlan= and delvlan= for tagged vlans, 'pvid', vlan, or stat without = checks current value - my $self=shift; + my $self = shift; my $community = "public"; + #$self->{sitetab} = xCAT::Table->new('site'); #my $tmp = $self->{sitetab}->getAttribs({key=>'snmpc'},'value'); - my @snmpcs = xCAT::TableUtils->get_site_attribute("snmpc"); - my $tmp = $snmpcs[0]; - if ( defined($tmp) ) { $community = $tmp } - my %args = @_; - my $op=$args{operation}; - my $nodes=$args{nodes}; + my @snmpcs = xCAT::TableUtils->get_site_attribute("snmpc"); + my $tmp = $snmpcs[0]; + if (defined($tmp)) { $community = $tmp } + my %args = @_; + my $op = $args{operation}; + my $nodes = $args{nodes}; + #first order of business is to identify the target switches - my $switchtab=xCAT::Table->new('switch',-create=>0); + my $switchtab = xCAT::Table->new('switch', -create => 0); unless ($switchtab) { return; } - my $switchents = $switchtab->getNodesAttribs($nodes,[qw/switch port interface/]); + my $switchents = $switchtab->getNodesAttribs($nodes, [qw/switch port interface/]); my $node; foreach $node (keys %$switchents) { my $entry; - foreach $entry (@{$switchents->{$node}}) { + foreach $entry (@{ $switchents->{$node} }) { + #skip the none primary interface. # The vlaue of the primary interface could be empty, primary or primary:ethx - if (defined($entry->{interface})) { - if ($entry->{interface} !~ /primary/) { - next; - } - } + if (defined($entry->{interface})) { + if ($entry->{interface} !~ /primary/) { + next; + } + } - $self->{switches}->{$entry->{switch}}->{$entry->{port}} = $node; + $self->{switches}->{ $entry->{switch} }->{ $entry->{port} } = $node; } - } - my $switches=[keys %{$self->{switches}}]; - my $switchestab=xCAT::Table->new('switches',-create=>0); + } + my $switches = [ keys %{ $self->{switches} } ]; + my $switchestab = xCAT::Table->new('switches', -create => 0); my @switchesents; if ($switchestab) { - foreach (values %{$switchestab->getNodesAttribs($switches,[qw(switch snmpversion username password privacy auth)])}) { - push @switchesents,@$_; + foreach (values %{ $switchestab->getNodesAttribs($switches, [qw(switch snmpversion username password privacy auth)]) }) { + push @switchesents, @$_; } } - $self->fill_switchparms(community=>$community,switchesents=>\@switchesents); + $self->fill_switchparms(community => $community, switchesents => \@switchesents); my $switch; - foreach $switch (keys %{$self->{switches}}) { #first we'll extract the lay of the land... - $self->refresh_switch(undef,$community,$switch); - unless ($self->{switchinfo}->{$switch}->{vlanidtoindex}) { #need vlan id to vlanindex map for qbridge unless cisco - $self->scan_qbridge_vlans(switch=>$switch,community=>$community); - } + foreach $switch (keys %{ $self->{switches} }) { #first we'll extract the lay of the land... + $self->refresh_switch(undef, $community, $switch); + unless ($self->{switchinfo}->{$switch}->{vlanidtoindex}) { #need vlan id to vlanindex map for qbridge unless cisco + $self->scan_qbridge_vlans(switch => $switch, community => $community); + } } + #print Dumper($self->{switchinfo}); - # $self->{switchinfo}->{$switch}->{bridgeidxtoifname}->{$boid}=$portname; - # $self->{switchinfo}->{$switch}->{ifnametobridgeidx}->{$portname}=$boid; + # $self->{switchinfo}->{$switch}->{bridgeidxtoifname}->{$boid}=$portname; + # $self->{switchinfo}->{$switch}->{ifnametobridgeidx}->{$portname}=$boid; $op =~ s/stat/pvid/; $op =~ s/vlan/pvid/; - if ($op =~ /^addpvid/) { # add tagged vlan - } elsif ($op =~ /delpvid/) { #remove tagged vlan - } else { #native vlan query or set + if ($op =~ /^addpvid/) { # add tagged vlan + } elsif ($op =~ /delpvid/) { #remove tagged vlan + } else { #native vlan query or set } } + sub scan_qbridge_vlans { - my $self = shift; - my %args = @_; - my $switch = $args{switch}; + my $self = shift; + my %args = @_; + my $switch = $args{switch}; my $session = $self->{switchsessions}->{$switch}; - $self->{switchinfo}->{vlanindextoid} = walkoid($session,'.1.3.6.1.2.1.17.7.1.4.2.1.3'); - foreach (keys %{$self->{switchinfo}->{vlanindextoid}}) { -#TODO: try to scan + $self->{switchinfo}->{vlanindextoid} = walkoid($session, '.1.3.6.1.2.1.17.7.1.4.2.1.3'); + foreach (keys %{ $self->{switchinfo}->{vlanindextoid} }) { + + #TODO: try to scan } } @@ -257,9 +274,9 @@ sub scan_qbridge_vlans { #-------------------------------------------------------------------------------- sub dump_mac_info { - my $self = shift; - my $req = shift; - my $callback = shift; + my $self = shift; + my $req = shift; + my $callback = shift; my $noderange = undef; if (defined($req->{node})) { $noderange = $req->{node}; @@ -268,11 +285,11 @@ sub dump_mac_info { $self->{collect_mac_info} = 1; if (defined($req->{opt}->{verbose})) { $self->{show_verbose_info} = 1; - $self->{callback} = $callback; + $self->{callback} = $callback; } - my $community = "public"; + my $community = "public"; my $dump_all_switches = 0; - my %switches_to_dump = (); + my %switches_to_dump = (); if (!defined($noderange)) { $dump_all_switches = 1; } @@ -281,58 +298,60 @@ sub dump_mac_info { $switches_to_dump{$_} = 1; } } - my $switchestab = xCAT::Table->new('switches', -create=>0); + my $switchestab = xCAT::Table->new('switches', -create => 0); my @switchesents = $switchestab->getAllNodeAttribs([qw(switch snmpversion username password privacy auth)]); - $self->fill_switchparms(community=>$community,switchesents=>\@switchesents); - my $switchtab = xCAT::Table->new('switch', -create=>0); + $self->fill_switchparms(community => $community, switchesents => \@switchesents); + my $switchtab = xCAT::Table->new('switch', -create => 0); my @entries = (); if ($switchtab) { - @entries = $switchtab->getAllNodeAttribs(['node','switch','port']); + @entries = $switchtab->getAllNodeAttribs([ 'node', 'switch', 'port' ]); } + #Build hash of switch port names per switch $self->{switches} = {}; foreach my $entry (@entries) { if (defined($entry->{switch}) and $entry->{switch} ne "" and defined($entry->{port}) and $entry->{port} ne "") { - if ( !$self->{switches}->{$entry->{switch}}->{$entry->{port}}) { - $self->{switches}->{$entry->{switch}}->{$entry->{port}} = $entry->{node}; + if (!$self->{switches}->{ $entry->{switch} }->{ $entry->{port} }) { + $self->{switches}->{ $entry->{switch} }->{ $entry->{port} } = $entry->{node}; } else { - $self->{switches}->{$entry->{switch}}->{$entry->{port}} .= ",$entry->{node}"; + $self->{switches}->{ $entry->{switch} }->{ $entry->{port} } .= ",$entry->{node}"; } - } + } else { - xCAT::MsgUtils->message("S","xCAT Table error:".$entry->{node}."Has missing or invalid switch.switch and/or switch.port fields"); + xCAT::MsgUtils->message("S", "xCAT Table error:" . $entry->{node} . "Has missing or invalid switch.switch and/or switch.port fields"); } } - foreach my $switch (keys %{$self->{switchparmhash}}) { + foreach my $switch (keys %{ $self->{switchparmhash} }) { if ($dump_all_switches or defined($switches_to_dump{$switch})) { if ($self->{show_verbose_info}) { - xCAT::MsgUtils->message("I",{data=>["$switch: Start to get information"]}, $self->{callback}); + xCAT::MsgUtils->message("I", { data => ["$switch: Start to get information"] }, $self->{callback}); } - $self->refresh_switch(undef,$community,$switch); + $self->refresh_switch(undef, $community, $switch); if ($self->{show_verbose_info}) { - xCAT::MsgUtils->message("I",{data=>["$switch: Finish to get information"]}, $self->{callback}); + xCAT::MsgUtils->message("I", { data => ["$switch: Finish to get information"] }, $self->{callback}); } - if (!defined($self->{macinfo}->{$switch})) { + if (!defined($self->{macinfo}->{$switch})) { $ret{$switch}->{ErrorStr} = "No information get"; - foreach my $defportname (keys %{$self->{switches}->{$switch}}) { + foreach my $defportname (keys %{ $self->{switches}->{$switch} }) { $ret{$switch}->{$defportname}->{Node} = $self->{switches}->{$switch}->{$defportname}; } - } + } elsif (defined($self->{macinfo}->{$switch}->{ErrorStr})) { - $ret{$switch}->{ErrorStr} = $self->{macinfo}->{$switch}->{ErrorStr}; - # To show the error message that the username/password related error is for SNMP only - if ($ret{$switch}->{ErrorStr} =~ /username|password/i) { - $ret{$switch}->{ErrorStr} .= " through SNMP"; - } + $ret{$switch}->{ErrorStr} = $self->{macinfo}->{$switch}->{ErrorStr}; + + # To show the error message that the username/password related error is for SNMP only + if ($ret{$switch}->{ErrorStr} =~ /username|password/i) { + $ret{$switch}->{ErrorStr} .= " through SNMP"; + } } else { - foreach my $snmpportname (keys %{$self->{macinfo}->{$switch}}) { - foreach my $defportname (keys %{$self->{switches}->{$switch}}) { + foreach my $snmpportname (keys %{ $self->{macinfo}->{$switch} }) { + foreach my $defportname (keys %{ $self->{switches}->{$switch} }) { if (namesmatch($defportname, $snmpportname)) { $ret{$switch}->{$snmpportname}->{Node} = $self->{switches}->{$switch}->{$defportname}; } } - @{$ret{$switch}->{$snmpportname}->{MACaddress}} = @{$self->{macinfo}->{$switch}->{$snmpportname}}; + @{ $ret{$switch}->{$snmpportname}->{MACaddress} } = @{ $self->{macinfo}->{$switch}->{$snmpportname} }; } } } @@ -341,450 +360,465 @@ sub dump_mac_info { } sub find_mac { -# This function is given a mac address, checks for given mac address -# and returns undef if unable to find the node, and the nodename otherwise - my $self = shift; - my $mac = shift; - my $cachedonly = shift; -# For now HARDCODE (TODO, configurable?) a cache as stale after five minutes -# Also, if things are changed in the config, our cache could be wrong, -# invalidate on switch table write? - if ($self->{mactable}->{lc($mac)} and ($self->{timestamp} > (time() - 300))) { - my $reftbl = 0; - foreach (keys %{$self->{mactable}}) { - if ((lc($mac) ne $_) and ($self->{mactable}->{lc($mac)} eq $self->{mactable}->{$_})) { - #$reftbl = 1; - #Delete *possibly* stale data, without being heavy handed.. - #But if this mac indicates multiple nodes, leave it there - if ( $self->{mactable}->{lc($mac)} !~ /,/) - { - delete $self->{mactable}->{$_}; + + # This function is given a mac address, checks for given mac address + # and returns undef if unable to find the node, and the nodename otherwise + my $self = shift; + my $mac = shift; + my $cachedonly = shift; + + # For now HARDCODE (TODO, configurable?) a cache as stale after five minutes + # Also, if things are changed in the config, our cache could be wrong, + # invalidate on switch table write? + if ($self->{mactable}->{ lc($mac) } and ($self->{timestamp} > (time() - 300))) { + my $reftbl = 0; + foreach (keys %{ $self->{mactable} }) { + if ((lc($mac) ne $_) and ($self->{mactable}->{ lc($mac) } eq $self->{mactable}->{$_})) { + + #$reftbl = 1; + #Delete *possibly* stale data, without being heavy handed.. + #But if this mac indicates multiple nodes, leave it there + if ($self->{mactable}->{ lc($mac) } !~ /,/) + { + delete $self->{mactable}->{$_}; + } + } } - } + unless ($reftbl) { return $self->{mactable}->{ lc($mac) }; } } - unless ($reftbl) { return $self->{mactable}->{lc($mac)};} - } - #If requesting a cache only check or the cache is a mere 20 seconds old - #don't bother querying switches - if ($cachedonly or ($self->{timestamp} > (time() - 20))) { return undef; } - $self->refresh_table; #not cached or stale cache, refresh - if ($self->{mactable}->{lc($mac)}) { - return $self->{mactable}->{lc($mac)}; - } - return undef; + + #If requesting a cache only check or the cache is a mere 20 seconds old + #don't bother querying switches + if ($cachedonly or ($self->{timestamp} > (time() - 20))) { return undef; } + $self->refresh_table; #not cached or stale cache, refresh + if ($self->{mactable}->{ lc($mac) }) { + return $self->{mactable}->{ lc($mac) }; + } + return undef; } sub fill_switchparms { - my $self = shift; - my %args = @_; - my $community=$args{community}; - $self->{switchparmhash}={}; - my @switchentries = @{$args{switchesents}}; - foreach (@switchentries) { - my $curswitch=$_->{switch}; - $self->{switchparmhash}->{$curswitch}=$_; - if ($_->{snmpversion}) { - if ($_->{snmpversion} =~ /3/) { #clean up to accept things like v3 or ver3 or 3, whatever. - $self->{switchparmhash}->{$curswitch}->{snmpversion}=3; - unless ($_->{auth}) { - $self->{switchparmhash}->{$curswitch}->{auth}='md5'; #Default to md5 auth if not specified but using v3 - } - } elsif ($_->{snmpversion} =~ /2/) { - $self->{switchparmhash}->{$curswitch}->{snmpversion}=2; - } else { - $self->{switchparmhash}->{$curswitch}->{snmpversion}=1; #Default to lowest common denominator, snmpv1 - } - } - unless (defined $_->{password}) { #if no password set, inherit the community - $self->{switchparmhash}->{$curswitch}->{password}=$community; - } - } + my $self = shift; + my %args = @_; + my $community = $args{community}; + $self->{switchparmhash} = {}; + my @switchentries = @{ $args{switchesents} }; + foreach (@switchentries) { + my $curswitch = $_->{switch}; + $self->{switchparmhash}->{$curswitch} = $_; + if ($_->{snmpversion}) { + if ($_->{snmpversion} =~ /3/) { #clean up to accept things like v3 or ver3 or 3, whatever. + $self->{switchparmhash}->{$curswitch}->{snmpversion} = 3; + unless ($_->{auth}) { + $self->{switchparmhash}->{$curswitch}->{auth} = 'md5'; #Default to md5 auth if not specified but using v3 + } + } elsif ($_->{snmpversion} =~ /2/) { + $self->{switchparmhash}->{$curswitch}->{snmpversion} = 2; + } else { + $self->{switchparmhash}->{$curswitch}->{snmpversion} = 1; #Default to lowest common denominator, snmpv1 + } + } + unless (defined $_->{password}) { #if no password set, inherit the community + $self->{switchparmhash}->{$curswitch}->{password} = $community; + } + } } sub refresh_table { - my $self = shift; - my $curswitch; - $self->{mactable}={}; - $self->{switchtab} = xCAT::Table->new('switch', -create => 1); - $self->{switchestab} = xCAT::Table->new('switches', -create => 1); - my @switchentries=$self->{switchestab}->getAllNodeAttribs([qw(switch snmpversion username password privacy auth)]); - my $community = "public"; - #$self->{sitetab} = xCAT::Table->new('site'); - #my $tmp = $self->{sitetab}->getAttribs({key=>'snmpc'},'value'); - #if ($tmp and $tmp->{value}) { $community = $tmp->{value} } - my @snmpcs = xCAT::TableUtils->get_site_attribute("snmpc"); - my $tmp = $snmpcs[0]; - if ( defined($tmp) ) { $community = $tmp } - else { #Would warn here.. - } - $self->{switchparmhash}={}; - foreach (@switchentries) { - $curswitch=$_->{switch}; - $self->{switchparmhash}->{$curswitch}=$_; - if ($_->{snmpversion}) { - if ($_->{snmpversion} =~ /3/) { #clean up to accept things like v3 or ver3 or 3, whatever. - $self->{switchparmhash}->{$curswitch}->{snmpversion}=3; - unless ($_->{auth}) { - $self->{switchparmhash}->{$curswitch}->{auth}='md5'; #Default to md5 auth if not specified but using v3 - } - } elsif ($_->{snmpversion} =~ /2/) { - #$self->{switchparmhash}->{$curswitch}->{snmpversion}=2; - # we have Juniper switch enabled snmp v2c, not v2 - $self->{switchparmhash}->{$curswitch}->{snmpversion}=$_->{snmpversion}; - } else { - $self->{switchparmhash}->{$curswitch}->{snmpversion}=1; #Default to lowest common denominator, snmpv1 - } + my $self = shift; + my $curswitch; + $self->{mactable} = {}; + $self->{switchtab} = xCAT::Table->new('switch', -create => 1); + $self->{switchestab} = xCAT::Table->new('switches', -create => 1); + my @switchentries = $self->{switchestab}->getAllNodeAttribs([qw(switch snmpversion username password privacy auth)]); + my $community = "public"; + + #$self->{sitetab} = xCAT::Table->new('site'); + #my $tmp = $self->{sitetab}->getAttribs({key=>'snmpc'},'value'); + #if ($tmp and $tmp->{value}) { $community = $tmp->{value} } + my @snmpcs = xCAT::TableUtils->get_site_attribute("snmpc"); + my $tmp = $snmpcs[0]; + if (defined($tmp)) { $community = $tmp } + else { #Would warn here.. + } + $self->{switchparmhash} = {}; + foreach (@switchentries) { + $curswitch = $_->{switch}; + $self->{switchparmhash}->{$curswitch} = $_; + if ($_->{snmpversion}) { + if ($_->{snmpversion} =~ /3/) { #clean up to accept things like v3 or ver3 or 3, whatever. + $self->{switchparmhash}->{$curswitch}->{snmpversion} = 3; + unless ($_->{auth}) { + $self->{switchparmhash}->{$curswitch}->{auth} = 'md5'; #Default to md5 auth if not specified but using v3 + } + } elsif ($_->{snmpversion} =~ /2/) { + + #$self->{switchparmhash}->{$curswitch}->{snmpversion}=2; + # we have Juniper switch enabled snmp v2c, not v2 + $self->{switchparmhash}->{$curswitch}->{snmpversion} = $_->{snmpversion}; + } else { + $self->{switchparmhash}->{$curswitch}->{snmpversion} = 1; #Default to lowest common denominator, snmpv1 + } } unless (defined $_->{password}) { #if no password set, inherit the community - $self->{switchparmhash}->{$curswitch}->{password}=$community; + $self->{switchparmhash}->{$curswitch}->{password} = $community; } - } - my %checked_pairs; - my @entries = $self->{switchtab}->getAllNodeAttribs(['node','port','switch']); - #Build hash of switch port names per switch - $self->{switches} = {}; - foreach my $entry (@entries) { - if (defined($entry->{switch}) and $entry->{switch} ne "" and defined($entry->{port}) and $entry->{port} ne "") { + } + my %checked_pairs; + my @entries = $self->{switchtab}->getAllNodeAttribs([ 'node', 'port', 'switch' ]); - if ( !$self->{switches}->{$entry->{switch}}->{$entry->{port}}) - { - $self->{switches}->{$entry->{switch}}->{$entry->{port}} = $entry->{node}; + #Build hash of switch port names per switch + $self->{switches} = {}; + foreach my $entry (@entries) { + if (defined($entry->{switch}) and $entry->{switch} ne "" and defined($entry->{port}) and $entry->{port} ne "") { + + if (!$self->{switches}->{ $entry->{switch} }->{ $entry->{port} }) + { + $self->{switches}->{ $entry->{switch} }->{ $entry->{port} } = $entry->{node}; + } + else + { + $self->{switches}->{ $entry->{switch} }->{ $entry->{port} } .= ",$entry->{node}"; + } + } else { + xCAT::MsgUtils->message("S", "xCAT Table error:" . $entry->{node} . "Has missing or invalid switch.switch and/or switch.port fields"); } - else - { - $self->{switches}->{$entry->{switch}}->{$entry->{port}} .= ",$entry->{node}"; + } + my $children = 0; + my $inputs = new IO::Select; + $SIG{CHLD} = sub { while (waitpid(-1, WNOHANG) > 0) { $children-- } }; + foreach my $entry (@entries) { + if ($checked_pairs{ $entry->{switch} }) { + next; } - } else { - xCAT::MsgUtils->message("S","xCAT Table error:".$entry->{node}."Has missing or invalid switch.switch and/or switch.port fields"); + while ($children > 64) { + $self->handle_output($inputs); + } + $checked_pairs{ $entry->{switch} } = 1; + pipe my $child, my $parent; + $child->autoflush(1); + $parent->autoflush(1); + $children++; + my $cpid = xCAT::Utils->xfork; + unless (defined $cpid) { die "Cannot fork" } + + if ($cpid == 0) { + close($child); + $self->refresh_switch($parent, $community, $entry->{switch}); + exit(0); + } + close($parent); + $inputs->add($child); } - } - my $children = 0; - my $inputs = new IO::Select; - $SIG{CHLD}= sub { while(waitpid(-1,WNOHANG) > 0) { $children-- } }; - foreach my $entry (@entries) { - if ($checked_pairs{$entry->{switch}}) { - next; + while ($children) { + $self->handle_output($inputs); } - while($children > 64) { - $self->handle_output($inputs); - } - $checked_pairs{$entry->{switch}}=1; - pipe my $child,my $parent; - $child->autoflush(1); - $parent->autoflush(1); - $children++; - my $cpid = xCAT::Utils->xfork; - unless (defined $cpid) { die "Cannot fork" }; - if ($cpid == 0) { - close($child); - $self->refresh_switch($parent,$community,$entry->{switch}); - exit(0); - } - close($parent); - $inputs->add($child); - } - while($children) { - $self->handle_output($inputs); - } - while ($self->handle_output($inputs)) {}; #Drain the pipes - $self->{timestamp}=time; + while ($self->handle_output($inputs)) { }; #Drain the pipes + $self->{timestamp} = time; } sub handle_output { - my $self = shift; - my $inputs = shift; - my @readied = $inputs->can_read(1); - my $rc = @readied; - my $ready; - foreach $ready (@readied) { - my $line = <$ready>; - unless ($line) { - $inputs->remove($ready); - close($ready); - next; + my $self = shift; + my $inputs = shift; + my @readied = $inputs->can_read(1); + my $rc = @readied; + my $ready; + foreach $ready (@readied) { + my $line = <$ready>; + unless ($line) { + $inputs->remove($ready); + close($ready); + next; + } + $line =~ m/^([^|]*)\|(.*)/; + $self->{mactable}->{$1} = $2; } - $line =~ m/^([^|]*)\|(.*)/; - $self->{mactable}->{$1}=$2; - } - return $rc; + return $rc; } sub walkoid { - my $session = shift; - my $oid = shift; - my %namedargs = @_; - my $retmap = undef; - my $switch = undef; - my $callback = undef; - if (defined($namedargs{verbose})) { - $switch = $namedargs{switch}; - $callback = $namedargs{callback}; - } - if ($switch) { - xCAT::MsgUtils->message("I",{data=>["$switch: SNMP Session query OID:\"$oid\""]}, $callback); - } - my $varbind = new SNMP::Varbind([$oid,'']); - $session->getnext($varbind); - if ($session->{ErrorStr}) { - unless ($namedargs{silentfail}) { - if ($namedargs{ciscowarn}) { - xCAT::MsgUtils->message("S","Error communicating with ".$session->{DestHost}." (First attempt at indexing by VLAN failed, ensure that the switch has the vlan configured such that it appears in 'show vlan'): ".$session->{ErrorStr}); - } else { - xCAT::MsgUtils->message("S","Error communicating with ".$session->{DestHost}.": ".$session->{ErrorStr}); - } + my $session = shift; + my $oid = shift; + my %namedargs = @_; + my $retmap = undef; + my $switch = undef; + my $callback = undef; + if (defined($namedargs{verbose})) { + $switch = $namedargs{switch}; + $callback = $namedargs{callback}; } if ($switch) { - xCAT::MsgUtils->message("I",{data=>["$switch: SNMP Session query OID:\"$oid\" Failed"]}, $callback); - } - return undef; - } - my $count=0; - my $data_string; - while ($varbind->[0] =~ /^$oid\.?(.*)/) { - $count++; - if ($1) { - $retmap->{$1.".".$varbind->[1]}=$varbind->[2]; #If $1 is set, means key should - $data_string .= "\t\t '".$1.".".$varbind->[1]."' => '$varbind->[2]'\n"; - } else { - $retmap->{$varbind->[1]}=$varbind->[2]; #If $1 is set, means key should - $data_string .= "\t\t '$varbind->[1]' => '$varbind->[2]'\n"; + xCAT::MsgUtils->message("I", { data => ["$switch: SNMP Session query OID:\"$oid\""] }, $callback); } + my $varbind = new SNMP::Varbind([ $oid, '' ]); $session->getnext($varbind); - } - if ($switch) { - chomp ($data_string); - xCAT::MsgUtils->message("I",{data=>["$switch: SNMP Session get data for OID:\"$oid\":\n$data_string"]}, $callback); - } - return $retmap; + if ($session->{ErrorStr}) { + unless ($namedargs{silentfail}) { + if ($namedargs{ciscowarn}) { + xCAT::MsgUtils->message("S", "Error communicating with " . $session->{DestHost} . " (First attempt at indexing by VLAN failed, ensure that the switch has the vlan configured such that it appears in 'show vlan'): " . $session->{ErrorStr}); + } else { + xCAT::MsgUtils->message("S", "Error communicating with " . $session->{DestHost} . ": " . $session->{ErrorStr}); + } + } + if ($switch) { + xCAT::MsgUtils->message("I", { data => ["$switch: SNMP Session query OID:\"$oid\" Failed"] }, $callback); + } + return undef; + } + my $count = 0; + my $data_string; + while ($varbind->[0] =~ /^$oid\.?(.*)/) { + $count++; + if ($1) { + $retmap->{ $1 . "." . $varbind->[1] } = $varbind->[2]; #If $1 is set, means key should + $data_string .= "\t\t '" . $1 . "." . $varbind->[1] . "' => '$varbind->[2]'\n"; + } else { + $retmap->{ $varbind->[1] } = $varbind->[2]; #If $1 is set, means key should + $data_string .= "\t\t '$varbind->[1]' => '$varbind->[2]'\n"; + } + $session->getnext($varbind); + } + if ($switch) { + chomp($data_string); + xCAT::MsgUtils->message("I", { data => ["$switch: SNMP Session get data for OID:\"$oid\":\n$data_string"] }, $callback); + } + return $retmap; } sub getsnmpsession { -#gets an snmp v3 session appropriate for a switch using the switches table for guidance on the hows -#arguments: switch => $switchname and optionally vlan=> $vid if needed for community string indexing - my $self = shift; - my %args = @_; - my $switch = $args{'switch'}; - my $vlanid = $args{'vlanid'}; + + #gets an snmp v3 session appropriate for a switch using the switches table for guidance on the hows + #arguments: switch => $switchname and optionally vlan=> $vid if needed for community string indexing + my $self = shift; + my %args = @_; + my $switch = $args{'switch'}; + my $vlanid = $args{'vlanid'}; my $community = $args{'community'}; my $session; - my $snmpver='1'; - my $swent = $self->{switchparmhash}->{$switch}; + my $snmpver = '1'; + my $swent = $self->{switchparmhash}->{$switch}; if ($swent) { if ($swent->{snmpversion}) { - $snmpver=$swent->{snmpversion}; + $snmpver = $swent->{snmpversion}; } if ($swent->{password}) { - $community=$swent->{password}; + $community = $swent->{password}; } } - my $switch_ip = xCAT::NetworkUtils->getipaddr($switch); - unless ($switch_ip) { - return ({"ErrorStr"=>"Can not resolve IP address for $switch"}); - } - if ($snmpver ne '3') { - if ($vlanid) { $community .= '@'.$vlanid; } - $session = new SNMP::Session( - DestHost => $switch_ip, - Version => $snmpver, - Community => $community, - UseNumeric => 1 - ); - if ($self->{show_verbose_info}) { - xCAT::MsgUtils->message("I",{data=>["$switch: Generate SNMP session with parameter: \n\t\t'Version' => '$snmpver'\n\t\t'Community' => '$community'"]}, $self->{callback}); - } + my $switch_ip = xCAT::NetworkUtils->getipaddr($switch); + unless ($switch_ip) { + return ({ "ErrorStr" => "Can not resolve IP address for $switch" }); + } + if ($snmpver ne '3') { + if ($vlanid) { $community .= '@' . $vlanid; } + $session = new SNMP::Session( + DestHost => $switch_ip, + Version => $snmpver, + Community => $community, + UseNumeric => 1 + ); + if ($self->{show_verbose_info}) { + xCAT::MsgUtils->message("I", { data => ["$switch: Generate SNMP session with parameter: \n\t\t'Version' => '$snmpver'\n\t\t'Community' => '$community'"] }, $self->{callback}); + } - } else { #we have snmp3 - my %args= ( - DestHost => $switch_ip, - SecName => $swent->{username}, - AuthProto => uc($swent->{auth}), - AuthPass => $community, - Version => $snmpver, - SecLevel => 'authNoPriv', - UseNumeric => 1 - ); - if ($vlanid) { $args{Context}="vlan-".$vlanid; } - if ($swent->{privacy}) { - $args{SecLevel}='authPriv'; - $args{PrivProto} = uc($swent->{privacy}); - $args{PrivPass} = $community; - } - if ($self->{show_verbose_info}) { - my $parameter_string = ''; - foreach (keys %args) { - $parameter_string .= "\t\t'$_' => '$args{$_}'\n"; - } - chomp($parameter_string); - xCAT::MsgUtils->message("I",{data=>["$switch: Generate SNMP session with parameter: \n$parameter_string"]}, $self->{callback}); - } + } else { #we have snmp3 + my %args = ( + DestHost => $switch_ip, + SecName => $swent->{username}, + AuthProto => uc($swent->{auth}), + AuthPass => $community, + Version => $snmpver, + SecLevel => 'authNoPriv', + UseNumeric => 1 + ); + if ($vlanid) { $args{Context} = "vlan-" . $vlanid; } + if ($swent->{privacy}) { + $args{SecLevel} = 'authPriv'; + $args{PrivProto} = uc($swent->{privacy}); + $args{PrivPass} = $community; + } + if ($self->{show_verbose_info}) { + my $parameter_string = ''; + foreach (keys %args) { + $parameter_string .= "\t\t'$_' => '$args{$_}'\n"; + } + chomp($parameter_string); + xCAT::MsgUtils->message("I", { data => ["$switch: Generate SNMP session with parameter: \n$parameter_string"] }, $self->{callback}); + } - $session = new SNMP::Session(%args); - } - return $session; + $session = new SNMP::Session(%args); + } + return $session; } sub refresh_switch { - my $self = shift; - my $output = shift; - my $community = shift; - my $switch = shift; - #if ($error) { die $error; } - my $session = $self->getsnmpsession('community'=>$community,'switch'=>$switch); - unless ($session) { - xCAT::MsgUtils->message("S","Failed to communicate with $switch"); - if ($self->{collect_mac_info}) { - $self->{macinfo}->{$switch}->{ErrorStr} = "Failed to communicate with $switch through SNMP"; - } - return; - } - elsif ($session->{ErrorStr}) { - if ($self->{collect_mac_info}) { - $self->{macinfo}->{$switch}->{ErrorStr} = $session->{ErrorStr}; - } - return; - } - my $namemap = walkoid($session,'.1.3.6.1.2.1.31.1.1.1.1', verbose=>$self->{show_verbose_info}, switch=>$switch, callback=>$self->{callback}); - #namemap is the mapping of ifIndex->(human readable name) - if ($namemap) { - my $ifnamesupport=0; #Assume broken ifnamesupport until proven good... (Nortel switch) - foreach (keys %{$namemap}) { - if ($namemap->{$_}) { - $ifnamesupport=1; - last; - } - } - unless ($ifnamesupport) { - $namemap=0; - } - } - unless ($namemap) { #Failback to ifDescr. ifDescr is close, but not perfect on some switches - $namemap = walkoid($session,'.1.3.6.1.2.1.2.2.1.2', verbose=>$self->{show_verbose_info}, switch=>$switch, callback=>$self->{callback}); - } - unless ($namemap) { - if ($session->{ErrorStr} and $self->{collect_mac_info}) { - $self->{macinfo}->{$switch}->{ErrorStr} = $session->{ErrorStr}; - } - return; - } - #Above is valid without community string indexing, on cisco, we need it on the next one and onward - my $iftovlanmap = walkoid($session,'.1.3.6.1.4.1.9.9.68.1.2.2.1.2',silentfail=>1,verbose=>$self->{show_verbose_info}, switch=>$switch, callback=>$self->{callback}); #use cisco vlan membership mib to ascertain vlan - my $trunktovlanmap = walkoid($session,'.1.3.6.1.4.1.9.9.46.1.6.1.1.5', silentfail=>1, verbose=>$self->{show_verbose_info}, switch=>$switch, callback=>$self->{callback}); #for trunk ports, we are interested in the native vlan, so we need cisco vtp mib too - my %vlans_to_check; - if (defined($iftovlanmap) or defined($trunktovlanmap)) { #We have a cisco, the intelligent thing is to do SNMP gets on the ports - $self->{switchinfo}->{$switch}->{vlanidtoindex}="NA";#mark this switch to ignore for qbridge scans -# that we can verify are populated per switch table - my $portid; - foreach $portid (keys %{$namemap}) { - my $portname; - my $switchport = $namemap->{$portid}; - foreach $portname (keys %{$self->{switches}->{$switch}}) { - unless (namesmatch($portname,$switchport)) { - next; - } - if (not defined $iftovlanmap->{$portid} and not defined $trunktovlanmap->{$portid}) { - xCAT::MsgUtils->message("S","$portid missing from switch"); - next; - } - if (defined $iftovlanmap->{$portid}) { - $vlans_to_check{"".$iftovlanmap->{$portid}} = 1; #cast to string, may not be needed - $self->{nodeinfo}->{$self->{switches}->{$switch}->{$portname}}->{vlans}->{$portname}=$iftovlanmap->{$portid}; - } else { #given above if statement, brigetovlanmap *must* be defined* - $vlans_to_check{"".$trunktovlanmap->{$portid}} = 1; #cast to string, may not be needed - $self->{nodeinfo}->{$self->{switches}->{$switch}->{$portname}}->{vlans}->{$portname}=$trunktovlanmap->{$portid}; - } - } - } - } else { - $vlans_to_check{'NA'}=1; - } + my $self = shift; + my $output = shift; + my $community = shift; + my $switch = shift; - my $vlan; - my $iscisco=0; - foreach $vlan (sort keys %vlans_to_check) { #Sort, because if numbers, we want 1 first, because that vlan should not get communiy string indexed query - unless (not $vlan or $vlan eq 'NA' or $vlan eq '1') { #don't subject users to the context pain unless needed - $iscisco=1; - $session = $self->getsnmpsession('switch'=>$switch,'community'=>$community,'vlanid'=>$vlan); + #if ($error) { die $error; } + my $session = $self->getsnmpsession('community' => $community, 'switch' => $switch); + unless ($session) { + xCAT::MsgUtils->message("S", "Failed to communicate with $switch"); + if ($self->{collect_mac_info}) { + $self->{macinfo}->{$switch}->{ErrorStr} = "Failed to communicate with $switch through SNMP"; + } + return; } - unless ($session) { return; } elsif ($session->{ErrorStr}) { - if ($self->{collect_mac_info}) { - $self->{macinfo}->{$switch}->{ErrorStr} = $session->{ErrorStr}; - } - return; - } - my $bridgetoifmap = walkoid($session,'.1.3.6.1.2.1.17.1.4.1.2', ciscowarn=>$iscisco, verbose=>$self->{show_verbose_info}, switch=>$switch, callback=>$self->{callback}); # Good for all switches - if (not ref $bridgetoifmap or !keys %{$bridgetoifmap}) { - xCAT::MsgUtils->message("S","Error communicating with ".$session->{DestHost}.": failed to get a valid response to BRIDGE-MIB request"); + if ($self->{collect_mac_info}) { + $self->{macinfo}->{$switch}->{ErrorStr} = $session->{ErrorStr}; + } return; } + my $namemap = walkoid($session, '.1.3.6.1.2.1.31.1.1.1.1', verbose => $self->{show_verbose_info}, switch => $switch, callback => $self->{callback}); - # my $mactoindexmap = walkoid($session,'.1.3.6.1.2.1.17.4.3.1.2'); - my $mactoindexmap = walkoid($session,'.1.3.6.1.2.1.17.7.1.2.2.1.2',silentfail=>1, verbose=>$self->{show_verbose_info}, switch=>$switch, callback=>$self->{callback}); - unless (defined($mactoindexmap)) { #if no qbridge defined, try bridge mib, probably cisco - #$mactoindexmap = walkoid($session,'.1.3.6.1.2.1.17.7.1.2.2.1.2'); - $mactoindexmap = walkoid($session,'.1.3.6.1.2.1.17.4.3.1.2',ciscowarn=>$iscisco, verbose=>$self->{show_verbose_info}, switch=>$switch, callback=>$self->{callback}); - } #Ok, time to process the data - if (not ref $mactoindexmap or !keys %{$mactoindexmap}) { - xCAT::MsgUtils->message("S","Error communicating with ".$session->{DestHost}.": Unable to get MAC entries via either BRIDGE or Q-BRIDE MIB"); - return; - } - if (defined($self->{collect_mac_info})) { - my %index_to_mac = (); - foreach (keys %$mactoindexmap) { - my $index = $mactoindexmap->{$_}; - my @tmp = split /\./, $_; - my @mac = @tmp[-6 .. -1]; - my $macstring=sprintf("%02x:%02x:%02x:%02x:%02x:%02x",@mac); - push @{$index_to_mac{$index}}, $macstring; + #namemap is the mapping of ifIndex->(human readable name) + if ($namemap) { + my $ifnamesupport = 0; #Assume broken ifnamesupport until proven good... (Nortel switch) + foreach (keys %{$namemap}) { + if ($namemap->{$_}) { + $ifnamesupport = 1; + last; + } } - foreach my $boid (keys %$bridgetoifmap) { - my $port_index = $boid; - my $port_name = $namemap->{$bridgetoifmap->{$port_index}}; - if (defined($index_to_mac{$port_index})) { - push @{$self->{macinfo}->{$switch}->{$port_name}}, @{$index_to_mac{$port_index}}; - } - else { - $self->{macinfo}->{$switch}->{$port_name}->[0] = ''; - } + unless ($ifnamesupport) { + $namemap = 0; + } + } + unless ($namemap) { #Failback to ifDescr. ifDescr is close, but not perfect on some switches + $namemap = walkoid($session, '.1.3.6.1.2.1.2.2.1.2', verbose => $self->{show_verbose_info}, switch => $switch, callback => $self->{callback}); + } + unless ($namemap) { + if ($session->{ErrorStr} and $self->{collect_mac_info}) { + $self->{macinfo}->{$switch}->{ErrorStr} = $session->{ErrorStr}; } return; } - foreach my $oid (keys %$namemap) { - #$oid =~ m/1.3.6.1.2.1.31.1.1.1.1.(.*)/; - my $ifindex = $oid; - my $portname; - my $switchport = $namemap->{$oid}; - foreach $portname (keys %{$self->{switches}->{$switch}}) { # a little redundant, but - # computationally trivial - unless (namesmatch($portname,$switchport)) { next } - #if still running, we have match - foreach my $boid (keys %$bridgetoifmap) { - unless ($bridgetoifmap->{$boid} == $ifindex) { next; } - $self->{switchinfo}->{$switch}->{bridgeidxtoifname}->{$boid}=$portname; - $self->{switchinfo}->{$switch}->{ifnametobridgeidx}->{$portname}=$boid; - $self->{nodeinfo}->{$self->{switches}->{$switch}->{$portname}}->{portnametobridgeindex}->{$portname}=$boid; - $self->{nodeinfo}->{$self->{switches}->{$switch}->{$portname}}->{bridgeindextoportname}->{$boid}=$portname; - my $bridgeport = $boid; - foreach (keys %$mactoindexmap) { - if ($mactoindexmap->{$_} == $bridgeport) { - my @tmp = split /\./, $_; - my @mac = @tmp[-6 .. -1]; - my $macstring=sprintf("%02x:%02x:%02x:%02x:%02x:%02x",@mac); - if ($output) { - printf $output "$macstring|%s\n",$self->{switches}->{$switch}->{$portname}; - } - push @{$self->{nodeinfo}->{$self->{switches}->{$switch}->{$portname}}->{macs}->{$portname}},$macstring; #this could be used as getmacs sort of deal + #Above is valid without community string indexing, on cisco, we need it on the next one and onward + my $iftovlanmap = walkoid($session, '.1.3.6.1.4.1.9.9.68.1.2.2.1.2', silentfail => 1, verbose => $self->{show_verbose_info}, switch => $switch, callback => $self->{callback}); #use cisco vlan membership mib to ascertain vlan + my $trunktovlanmap = walkoid($session, '.1.3.6.1.4.1.9.9.46.1.6.1.1.5', silentfail => 1, verbose => $self->{show_verbose_info}, switch => $switch, callback => $self->{callback}); #for trunk ports, we are interested in the native vlan, so we need cisco vtp mib too + my %vlans_to_check; + if (defined($iftovlanmap) or defined($trunktovlanmap)) { #We have a cisco, the intelligent thing is to do SNMP gets on the ports + $self->{switchinfo}->{$switch}->{vlanidtoindex} = "NA"; #mark this switch to ignore for qbridge scans + + # that we can verify are populated per switch table + my $portid; + foreach $portid (keys %{$namemap}) { + my $portname; + my $switchport = $namemap->{$portid}; + foreach $portname (keys %{ $self->{switches}->{$switch} }) { + unless (namesmatch($portname, $switchport)) { + next; + } + if (not defined $iftovlanmap->{$portid} and not defined $trunktovlanmap->{$portid}) { + xCAT::MsgUtils->message("S", "$portid missing from switch"); + next; + } + if (defined $iftovlanmap->{$portid}) { + $vlans_to_check{ "" . $iftovlanmap->{$portid} } = 1; #cast to string, may not be needed + $self->{nodeinfo}->{ $self->{switches}->{$switch}->{$portname} }->{vlans}->{$portname} = $iftovlanmap->{$portid}; + } else { #given above if statement, brigetovlanmap *must* be defined* + $vlans_to_check{ "" . $trunktovlanmap->{$portid} } = 1; #cast to string, may not be needed + $self->{nodeinfo}->{ $self->{switches}->{$switch}->{$portname} }->{vlans}->{$portname} = $trunktovlanmap->{$portid}; + } } - } } - } + } else { + $vlans_to_check{'NA'} = 1; } - } - $self->{switchsessions}->{$switch}=$session; #save session for future use + + my $vlan; + my $iscisco = 0; + foreach $vlan (sort keys %vlans_to_check) { #Sort, because if numbers, we want 1 first, because that vlan should not get communiy string indexed query + unless (not $vlan or $vlan eq 'NA' or $vlan eq '1') { #don't subject users to the context pain unless needed + $iscisco = 1; + $session = $self->getsnmpsession('switch' => $switch, 'community' => $community, 'vlanid' => $vlan); + } + unless ($session) { return; } + elsif ($session->{ErrorStr}) { + if ($self->{collect_mac_info}) { + $self->{macinfo}->{$switch}->{ErrorStr} = $session->{ErrorStr}; + } + return; + } + my $bridgetoifmap = walkoid($session, '.1.3.6.1.2.1.17.1.4.1.2', ciscowarn => $iscisco, verbose => $self->{show_verbose_info}, switch => $switch, callback => $self->{callback}); # Good for all switches + if (not ref $bridgetoifmap or !keys %{$bridgetoifmap}) { + xCAT::MsgUtils->message("S", "Error communicating with " . $session->{DestHost} . ": failed to get a valid response to BRIDGE-MIB request"); + return; + } + + # my $mactoindexmap = walkoid($session,'.1.3.6.1.2.1.17.4.3.1.2'); + my $mactoindexmap = walkoid($session, '.1.3.6.1.2.1.17.7.1.2.2.1.2', silentfail => 1, verbose => $self->{show_verbose_info}, switch => $switch, callback => $self->{callback}); + unless (defined($mactoindexmap)) { #if no qbridge defined, try bridge mib, probably cisco + #$mactoindexmap = walkoid($session,'.1.3.6.1.2.1.17.7.1.2.2.1.2'); + $mactoindexmap = walkoid($session, '.1.3.6.1.2.1.17.4.3.1.2', ciscowarn => $iscisco, verbose => $self->{show_verbose_info}, switch => $switch, callback => $self->{callback}); + } #Ok, time to process the data + if (not ref $mactoindexmap or !keys %{$mactoindexmap}) { + xCAT::MsgUtils->message("S", "Error communicating with " . $session->{DestHost} . ": Unable to get MAC entries via either BRIDGE or Q-BRIDE MIB"); + return; + } + if (defined($self->{collect_mac_info})) { + my %index_to_mac = (); + foreach (keys %$mactoindexmap) { + my $index = $mactoindexmap->{$_}; + my @tmp = split /\./, $_; + my @mac = @tmp[ -6 .. -1 ]; + my $macstring = sprintf("%02x:%02x:%02x:%02x:%02x:%02x", @mac); + push @{ $index_to_mac{$index} }, $macstring; + } + foreach my $boid (keys %$bridgetoifmap) { + my $port_index = $boid; + my $port_name = $namemap->{ $bridgetoifmap->{$port_index} }; + if (defined($index_to_mac{$port_index})) { + push @{ $self->{macinfo}->{$switch}->{$port_name} }, @{ $index_to_mac{$port_index} }; + } + else { + $self->{macinfo}->{$switch}->{$port_name}->[0] = ''; + } + } + return; + } + + foreach my $oid (keys %$namemap) { + + #$oid =~ m/1.3.6.1.2.1.31.1.1.1.1.(.*)/; + my $ifindex = $oid; + my $portname; + my $switchport = $namemap->{$oid}; + foreach $portname (keys %{ $self->{switches}->{$switch} }) { # a little redundant, but + # computationally trivial + unless (namesmatch($portname, $switchport)) { next } + + #if still running, we have match + foreach my $boid (keys %$bridgetoifmap) { + unless ($bridgetoifmap->{$boid} == $ifindex) { next; } + $self->{switchinfo}->{$switch}->{bridgeidxtoifname}->{$boid} = $portname; + $self->{switchinfo}->{$switch}->{ifnametobridgeidx}->{$portname} = $boid; + $self->{nodeinfo}->{ $self->{switches}->{$switch}->{$portname} }->{portnametobridgeindex}->{$portname} = $boid; + $self->{nodeinfo}->{ $self->{switches}->{$switch}->{$portname} }->{bridgeindextoportname}->{$boid} = $portname; + my $bridgeport = $boid; + foreach (keys %$mactoindexmap) { + if ($mactoindexmap->{$_} == $bridgeport) { + my @tmp = split /\./, $_; + my @mac = @tmp[ -6 .. -1 ]; + my $macstring = sprintf("%02x:%02x:%02x:%02x:%02x:%02x", @mac); + if ($output) { + printf $output "$macstring|%s\n", $self->{switches}->{$switch}->{$portname}; + } + push @{ $self->{nodeinfo}->{ $self->{switches}->{$switch}->{$portname} }->{macs}->{$portname} }, $macstring; #this could be used as getmacs sort of deal + } + } + } + } + } + } + $self->{switchsessions}->{$switch} = $session; #save session for future use } - + diff --git a/perl-xCAT/xCAT/MsgUtils.pm b/perl-xCAT/xCAT/MsgUtils.pm index d4bcc879e..b2e6484be 100644 --- a/perl-xCAT/xCAT/MsgUtils.pm +++ b/perl-xCAT/xCAT/MsgUtils.pm @@ -6,12 +6,13 @@ package xCAT::MsgUtils; # if AIX - make sure we include perl 5.8.2 in INC path. # Needed to find perl dependencies shipped in deps tarball. if ($^O =~ /^aix/i) { - unshift(@INC, qw(/usr/opt/perl5/lib/5.8.2/aix-thread-multi /usr/opt/perl5/lib/5.8.2 /usr/opt/perl5/lib/site_perl/5.8.2/aix-thread-multi /usr/opt/perl5/lib/site_perl/5.8.2)); + unshift(@INC, qw(/usr/opt/perl5/lib/5.8.2/aix-thread-multi /usr/opt/perl5/lib/5.8.2 /usr/opt/perl5/lib/site_perl/5.8.2/aix-thread-multi /usr/opt/perl5/lib/site_perl/5.8.2)); } use strict; use Sys::Syslog; use xCAT::Utils; + #use locale; use Socket; use File::Path; @@ -294,12 +295,12 @@ sub message # my $newrsp; if (($sev eq 'SA') || ($sev eq 'A')) - { # if SA ( syslog and auditlog) or A ( only auditlog)then need to pull first entry from $rsp - # for syslog, to preserve old interface + { # if SA ( syslog and auditlog) or A ( only auditlog)then need to pull first entry from $rsp + # for syslog, to preserve old interface $newrsp = $rsp; - if ($sev eq 'SA'){ # syslog and auditlog - $rsp = $newrsp->{syslogdata}->[0]; - } + if ($sev eq 'SA') { # syslog and auditlog + $rsp = $newrsp->{syslogdata}->[0]; + } } my $stdouterrf = \*STDOUT; my $stdouterrd = ''; @@ -323,17 +324,17 @@ sub message # build callback structure my $newrsp; my $sevkey = 'error'; - my $err = - "Logging requested without setting up log by calling xCAT:MsgUtils->start_logging.\n"; - push @{$newrsp->{$sevkey}}, $err; - push @{$newrsp->{errorcode}}, "1"; + my $err = +"Logging requested without setting up log by calling xCAT:MsgUtils->start_logging.\n"; + push @{ $newrsp->{$sevkey} }, $err; + push @{ $newrsp->{errorcode} }, "1"; $call_back->($newrsp); # send message to daemon/Client.pm return 1; } else { print - "Logging requested without setting up log by calling xCAT:MsgUtils->start_logging.\n"; +"Logging requested without setting up log by calling xCAT:MsgUtils->start_logging.\n"; return 1; } } @@ -369,11 +370,11 @@ sub message if ($call_back) { # callback routine provided my $sevkey; - if ($sev =~ /D/) { $sevkey = 'data'; } - elsif ($sev =~ /N/) { $sevkey = 'node'; } + if ($sev =~ /D/) { $sevkey = 'data'; } + elsif ($sev =~ /N/) { $sevkey = 'node'; } elsif ($sev =~ /IS/) { $sevkey = 'sinfo'; } - elsif ($sev =~ /I/) { $sevkey = 'info'; } - elsif ($sev =~ /W/) { $sevkey = 'warning'; } + elsif ($sev =~ /I/) { $sevkey = 'info'; } + elsif ($sev =~ /W/) { $sevkey = 'warning'; } elsif ($sev =~ /E/) { $sevkey = 'error'; @@ -388,10 +389,10 @@ sub message # build callback structure my $newrsp; my $sevkey = 'error'; - my $err = + my $err = "Invalid or no severity code passed to MsgUtils::message().\n"; - push @{$newrsp->{$sevkey}}, $err; - push @{$newrsp->{errorcode}}, "1"; + push @{ $newrsp->{$sevkey} }, $err; + push @{ $newrsp->{errorcode} }, "1"; $call_back->($newrsp); # send message to daemon/Client.pm return 1; } @@ -403,35 +404,35 @@ sub message { if ($sevkey ne 'data') { - if (!defined($rsp->{$sevkey}) || !scalar(@{$rsp->{$sevkey}})) + if (!defined($rsp->{$sevkey}) || !scalar(@{ $rsp->{$sevkey} })) { # did not pass the text in in the severity-specific field # so fix it - if (defined($rsp->{data}) && scalar(@{$rsp->{data}})) + if (defined($rsp->{data}) && scalar(@{ $rsp->{data} })) { - push @{$rsp->{$sevkey}}, @{$rsp->{data}}; + push @{ $rsp->{$sevkey} }, @{ $rsp->{data} }; # assume they passed # in the text in the data field instead - @{$rsp->{data}} = (); # clear out the data field + @{ $rsp->{data} } = (); # clear out the data field } } } # if still nothing in the array, there is nothing to print out - if (!defined($rsp->{$sevkey}) || !scalar(@{$rsp->{$sevkey}})) + if (!defined($rsp->{$sevkey}) || !scalar(@{ $rsp->{$sevkey} })) { return; } if (defined($exitcode)) { - push @{$rsp->{errorcode}}, $exitcode; + push @{ $rsp->{errorcode} }, $exitcode; } $call_back->($rsp); # send message to daemon/Client.pm - @{$rsp->{$sevkey}} = + @{ $rsp->{$sevkey} } = (); # clear out the rsp structure in case they use it again - @{$rsp->{data}} = (); - @{$rsp->{errorcode}} = (); + @{ $rsp->{data} } = (); + @{ $rsp->{errorcode} } = (); } else # logging { @@ -441,10 +442,10 @@ sub message # build callback structure my $newrsp; - push @{$newrsp->{$sevkey}}, $rsp; + push @{ $newrsp->{$sevkey} }, $rsp; if ($exitcode) { - push @{$newrsp->{errorcode}}, $exitcode; + push @{ $newrsp->{errorcode} }, $exitcode; } $call_back->($newrsp); # send message to daemon/Client.pm @@ -464,7 +465,7 @@ sub message } } - # is syslog option requested + # is syslog option requested if ($sev =~ /S/) { @@ -472,9 +473,9 @@ sub message eval { openlog("xcat", "nofatal,pid", "local4"); if ($sev eq 'SE') { - syslog("err", $rsp); + syslog("err", $rsp); } else { - syslog("info", $rsp); + syslog("info", $rsp); } closelog(); }; @@ -487,59 +488,59 @@ sub message } # if write to auditlog table requested, if not on service node - if (xCAT::Utils->isMN()){ - if (($sev eq 'SA') || ($sev eq 'A')) - { - require xCAT::Table; - my $auditlogentry; - my $tab = xCAT::Table->new("auditlog"); - if ($tab) + if (xCAT::Utils->isMN()) { + if (($sev eq 'SA') || ($sev eq 'A')) { - my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = - localtime(time); - - my $currtime = sprintf("%04d-%02d-%02d %02d:%02d:%02d", - $year + 1900, $mon + 1, $mday, - $hour, $min, $sec); - - $auditlogentry->{audittime} = $currtime; - $auditlogentry->{userid} = $newrsp->{userid}->[0]; - $auditlogentry->{clientname} = $newrsp->{clientname}->[0]; - $auditlogentry->{clienttype} = $newrsp->{clienttype}->[0]; - $auditlogentry->{command} = $newrsp->{command}->[0]; - $auditlogentry->{noderange} = $newrsp->{noderange}->[0]; - $auditlogentry->{args} = $newrsp->{args}->[0]; - $auditlogentry->{status} = $newrsp->{status}->[0]; - - my @ret = $tab->setAttribs(undef, $auditlogentry); - if (@ret > 1) + require xCAT::Table; + my $auditlogentry; + my $tab = xCAT::Table->new("auditlog"); + if ($tab) { + my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = + localtime(time); + + my $currtime = sprintf("%04d-%02d-%02d %02d:%02d:%02d", + $year + 1900, $mon + 1, $mday, + $hour, $min, $sec); + + $auditlogentry->{audittime} = $currtime; + $auditlogentry->{userid} = $newrsp->{userid}->[0]; + $auditlogentry->{clientname} = $newrsp->{clientname}->[0]; + $auditlogentry->{clienttype} = $newrsp->{clienttype}->[0]; + $auditlogentry->{command} = $newrsp->{command}->[0]; + $auditlogentry->{noderange} = $newrsp->{noderange}->[0]; + $auditlogentry->{args} = $newrsp->{args}->[0]; + $auditlogentry->{status} = $newrsp->{status}->[0]; + + my @ret = $tab->setAttribs(undef, $auditlogentry); + if (@ret > 1) + { + print $stdouterrf "Unable to open auditlog\n"; + eval { + openlog("xcat", "nofatal,pid", "local4"); + syslog("err", "Unable to write to auditlog"); + closelog(); + }; + } + else + { + my $DBname = xCAT::Utils->get_DBName; + if (!($DBname =~ /^SQLITE/)) { + $tab->commit; + } + } + } + else + { # error print $stdouterrf "Unable to open auditlog\n"; eval { openlog("xcat", "nofatal,pid", "local4"); - syslog("err", "Unable to write to auditlog"); + syslog("err", "Unable to open auditlog"); closelog(); }; - } - else - { - my $DBname = xCAT::Utils->get_DBName; - if (!($DBname =~ /^SQLITE/)) { - $tab->commit; - } - } - } - else - { # error - print $stdouterrf "Unable to open auditlog\n"; - eval { - openlog("xcat", "nofatal,pid", "local4"); - syslog("err", "Unable to open auditlog"); - closelog(); - }; + } } - } } return; } @@ -628,7 +629,8 @@ sub start_logging $::LOG_FILE_NAME = $logfile; # Make the file to be unbuffered - binmode( $::LOG_FILE_HANDLE, ":unix" ); + binmode($::LOG_FILE_HANDLE, ":unix"); + # Print the program name and date to the top of the logfile my $sdate = `/bin/date`; chomp $sdate; @@ -724,14 +726,14 @@ sub backup_logfile sub verbose_message { shift; - my $req = shift; + my $req = shift; my $data = shift; - if (!defined($req->{verbose})) { + if (!defined($req->{verbose})) { return; } - my ($sec,$min,$hour,$mday,$mon,$yr,$wday,$yday,$dst) = localtime(time); - my $time = sprintf "%04d%02d%02d.%02d:%02d:%02d", $yr+1900,$mon+1,$mday,$hour,$min,$sec; - $data = "$time ($$) ".$data; + my ($sec, $min, $hour, $mday, $mon, $yr, $wday, $yday, $dst) = localtime(time); + my $time = sprintf "%04d%02d%02d.%02d:%02d:%02d", $yr + 1900, $mon + 1, $mday, $hour, $min, $sec; + $data = "$time ($$) " . $data; if (defined($req->{callback})) { my %rsp; $rsp{data} = [$data]; @@ -779,39 +781,39 @@ sub verbose_message =cut #-------------------------------------------------------------------------------- -sub trace(){ +sub trace() { shift; - my $verbose = shift; - my $level = shift; + my $verbose = shift; + my $level = shift; my $logcontent = shift; - + my $prefix = ""; - if(($level eq "E")||($level eq "e")){$prefix="ERR";} - if(($level eq "W")||($level eq "w")){$prefix="WARNING";} - if(($level eq "I")||($level eq "i")){$prefix="INFO";} - if(($level eq "D")||($level eq "d")){$prefix="DEBUG";} + if (($level eq "E") || ($level eq "e")) { $prefix = "ERR"; } + if (($level eq "W") || ($level eq "w")) { $prefix = "WARNING"; } + if (($level eq "I") || ($level eq "i")) { $prefix = "INFO"; } + if (($level eq "D") || ($level eq "d")) { $prefix = "DEBUG"; } - my @tmp = xCAT::TableUtils->get_site_attribute("xcatdebugmode"); - my $xcatdebugmode=$tmp[0]; + my @tmp = xCAT::TableUtils->get_site_attribute("xcatdebugmode"); + my $xcatdebugmode = $tmp[0]; - if (($level eq "E") - ||($level eq "e") - ||($level eq "I") - ||($level eq "i") - ||($level eq "W") - ||($level eq "w")){ - my $msg = $prefix." ".$logcontent; + if (($level eq "E") + || ($level eq "e") + || ($level eq "I") + || ($level eq "i") + || ($level eq "W") + || ($level eq "w")) { + my $msg = $prefix . " " . $logcontent; eval { openlog("xcat", "nofatal,pid", "local4"); syslog("$prefix", $msg); closelog(); }; } - - if (($level eq "D") - ||($level eq "d")){ - if(($verbose == 1 )||($xcatdebugmode eq "1")||($xcatdebugmode eq "2")){ - my $msg = $prefix." ".$logcontent; + + if (($level eq "D") + || ($level eq "d")) { + if (($verbose == 1) || ($xcatdebugmode eq "1") || ($xcatdebugmode eq "2")) { + my $msg = $prefix . " " . $logcontent; eval { openlog("xcat", "nofatal,pid", "local4"); syslog("$prefix", $msg); diff --git a/perl-xCAT/xCAT/NetworkUtils.pm b/perl-xCAT/xCAT/NetworkUtils.pm index 2f699c8fa..d523dc8f3 100755 --- a/perl-xCAT/xCAT/NetworkUtils.pm +++ b/perl-xCAT/xCAT/NetworkUtils.pm @@ -10,7 +10,7 @@ BEGIN # if AIX - make sure we include perl 5.8.2 in INC path. # Needed to find perl dependencies shipped in deps tarball. if ($^O =~ /^aix/i) { - unshift(@INC, qw(/usr/opt/perl5/lib/5.8.2/aix-thread-multi /usr/opt/perl5/lib/5.8.2 /usr/opt/perl5/lib/site_perl/5.8.2/aix-thread-multi /usr/opt/perl5/lib/site_perl/5.8.2)); + unshift(@INC, qw(/usr/opt/perl5/lib/5.8.2/aix-thread-multi /usr/opt/perl5/lib/5.8.2 /usr/opt/perl5/lib/site_perl/5.8.2/aix-thread-multi /usr/opt/perl5/lib/site_perl/5.8.2)); } use lib "$::XCATROOT/lib/perl"; @@ -19,6 +19,7 @@ use File::Path; use Math::BigInt; use Socket; use xCAT::GlobalDef; + #use Data::Dumper; use strict; use warnings "all"; @@ -27,7 +28,8 @@ my $socket6support = eval { require Socket6 }; our @ISA = qw(Exporter); our @EXPORT_OK = qw(getipaddr); -my $utildata; #data to persist locally +my $utildata; #data to persist locally + #-------------------------------------------------------------------------------- =head1 xCAT::NetworkUtils @@ -69,31 +71,31 @@ This program module file, is a set of network utilities used by xCAT commands. #------------------------------------------------------------------------------- sub getNodeDomains() { - my $class = shift; - my $nodes = shift; + my $class = shift; + my $nodes = shift; - my @nodelist = @$nodes; - my %nodedomains; + my @nodelist = @$nodes; + my %nodedomains; - # Get the network info for each node - my %nethash = xCAT::DBobjUtils->getNetwkInfo(\@nodelist); + # Get the network info for each node + my %nethash = xCAT::DBobjUtils->getNetwkInfo(\@nodelist); - # get the site domain value - my @domains = xCAT::TableUtils->get_site_attribute("domain"); - my $sitedomain = $domains[0]; + # get the site domain value + my @domains = xCAT::TableUtils->get_site_attribute("domain"); + my $sitedomain = $domains[0]; - # for each node - set hash value to network domain or default - # to site domain - foreach my $node (@nodelist) { - unless (defined($node)) {next;} - if (defined($nethash{$node}) && $nethash{$node}{domain}) { - $nodedomains{$node} = $nethash{$node}{domain}; - } else { - $nodedomains{$node} = $sitedomain; - } + # for each node - set hash value to network domain or default + # to site domain + foreach my $node (@nodelist) { + unless (defined($node)) { next; } + if (defined($nethash{$node}) && $nethash{$node}{domain}) { + $nodedomains{$node} = $nethash{$node}{domain}; + } else { + $nodedomains{$node} = $sitedomain; } + } - return \%nodedomains; + return \%nodedomains; } #------------------------------------------------------------------------------- @@ -123,11 +125,11 @@ sub gethostnameandip() { my ($class, $iporhost) = @_; - if (($iporhost =~ /\d+\.\d+\.\d+\.\d+/) || ($iporhost =~ /:/)) #ip address + if (($iporhost =~ /\d+\.\d+\.\d+\.\d+/) || ($iporhost =~ /:/)) #ip address { return (xCAT::NetworkUtils->gethostname($iporhost), $iporhost); } - else #hostname + else #hostname { return ($iporhost, xCAT::NetworkUtils->getipaddr($iporhost)); } @@ -165,18 +167,19 @@ sub gethostname() if (ref($iporhost) eq 'ARRAY') { - $iporhost = @{$iporhost}[0]; - if (!$iporhost) - { - return undef; - } + $iporhost = @{$iporhost}[0]; + if (!$iporhost) + { + return undef; + } } - + if (($iporhost !~ /\d+\.\d+\.\d+\.\d+/) && ($iporhost !~ /:/)) { #why you do so? pass in a hostname and only want a hostname?? return $iporhost; } + #cache, do not lookup DNS each time if (defined($::iphosthash{$iporhost}) && $::iphosthash{$iporhost}) { @@ -186,15 +189,15 @@ sub gethostname() { if ($socket6support) # the getaddrinfo and getnameinfo supports both IPv4 and IPv6 { - my ($family, $socket, $protocol, $ip, $name) = Socket6::getaddrinfo($iporhost,0,AF_UNSPEC,SOCK_STREAM,6); #specifically ask for TCP capable records, maximizing chance of no more than one return per v4/v6 + my ($family, $socket, $protocol, $ip, $name) = Socket6::getaddrinfo($iporhost, 0, AF_UNSPEC, SOCK_STREAM, 6); #specifically ask for TCP capable records, maximizing chance of no more than one return per v4/v6 my $host = (Socket6::getnameinfo($ip))[0]; - if ($host eq $iporhost) # can not resolve + if ($host eq $iporhost) # can not resolve { return undef; } if ($host) { - $host =~ s/\..*//; #short hostname + $host =~ s/\..*//; #short hostname } return $host; } @@ -207,12 +210,12 @@ sub gethostname() return undef; } my $hostname = gethostbyaddr(inet_aton($iporhost), AF_INET); - if ( $hostname ) { - $hostname =~ s/\..*//; #short hostname + if ($hostname) { + $hostname =~ s/\..*//; #short hostname } return $hostname; } - } + } } #------------------------------------------------------------------------------- @@ -241,26 +244,26 @@ sub gethostname() sub getipaddr { my $iporhost = shift; - if ($iporhost eq 'xCAT::NetworkUtils') { #was called with -> syntax + if ($iporhost eq 'xCAT::NetworkUtils') { #was called with -> syntax $iporhost = shift; } my %extraarguments = @_; - if (!defined($iporhost)) - { - return undef; - } + if (!defined($iporhost)) + { + return undef; + } - if (ref($iporhost) eq 'ARRAY') - { - $iporhost = @{$iporhost}[0]; - if (!$iporhost) - { - return undef; - } - } + if (ref($iporhost) eq 'ARRAY') + { + $iporhost = @{$iporhost}[0]; + if (!$iporhost) + { + return undef; + } + } - #go ahead and do the reverse lookup on ip, useful to 'frontend' aton/pton and also to + #go ahead and do the reverse lookup on ip, useful to 'frontend' aton/pton and also to #spit out a common abbreviation if leading zeroes or using different ipv6 presentation rules #if ($iporhost and ($iporhost =~ /\d+\.\d+\.\d+\.\d+/) || ($iporhost =~ /:/)) #{ @@ -278,31 +281,31 @@ sub getipaddr if ($socket6support) # the getaddrinfo and getnameinfo supports both IPv4 and IPv6 { my @returns; - my $reqfamily=AF_UNSPEC; + my $reqfamily = AF_UNSPEC; if ($extraarguments{OnlyV6}) { - $reqfamily=AF_INET6; + $reqfamily = AF_INET6; } elsif ($extraarguments{OnlyV4}) { - $reqfamily=AF_INET; + $reqfamily = AF_INET; } - my @addrinfo = Socket6::getaddrinfo($iporhost,0,$reqfamily,SOCK_STREAM,6); - my ($family, $socket, $protocol, $ip, $name) = splice(@addrinfo,0,5); + my @addrinfo = Socket6::getaddrinfo($iporhost, 0, $reqfamily, SOCK_STREAM, 6); + my ($family, $socket, $protocol, $ip, $name) = splice(@addrinfo, 0, 5); while ($ip) { if ($extraarguments{GetNumber}) { #return a BigInt for compare, e.g. for comparing ip addresses for determining if they are in a common network or range my $ip = (Socket6::getnameinfo($ip, Socket6::NI_NUMERICHOST()))[0]; my $bignumber = Math::BigInt->new(0); - foreach (unpack("N*",Socket6::inet_pton($family,$ip))) { #if ipv4, loop will iterate once, for v6, will go 4 times + foreach (unpack("N*", Socket6::inet_pton($family, $ip))) { #if ipv4, loop will iterate once, for v6, will go 4 times $bignumber->blsft(32); $bignumber->badd($_); } - push(@returns,$bignumber); + push(@returns, $bignumber); } else { - push @returns,(Socket6::getnameinfo($ip, Socket6::NI_NUMERICHOST()))[0]; + push @returns, (Socket6::getnameinfo($ip, Socket6::NI_NUMERICHOST()))[0]; } if (scalar @addrinfo and $extraarguments{GetAllAddresses}) { - ($family, $socket, $protocol, $ip, $name) = splice(@addrinfo,0,5); + ($family, $socket, $protocol, $ip, $name) = splice(@addrinfo, 0, 5); } else { - $ip=0; + $ip = 0; } } unless ($extraarguments{GetAllAddresses}) { @@ -312,25 +315,26 @@ sub getipaddr } else { - #return inet_ntoa(inet_aton($iporhost)) - #TODO, what if no scoket6 support, but passing in a IPv6 hostname? - if ($iporhost =~ /:/) { #ipv6 - return undef; - #die "Attempt to process IPv6 address, but system does not have requisite IPv6 perl support"; - } - my $packed_ip; - $iporhost and $packed_ip = inet_aton($iporhost); - if (!$packed_ip) - { + #return inet_ntoa(inet_aton($iporhost)) + #TODO, what if no scoket6 support, but passing in a IPv6 hostname? + if ($iporhost =~ /:/) { #ipv6 return undef; - } - if ($extraarguments{GetNumber}) { #only 32 bits, no for loop needed. - return Math::BigInt->new(unpack("N*",$packed_ip)); - } - return inet_ntoa($packed_ip); + + #die "Attempt to process IPv6 address, but system does not have requisite IPv6 perl support"; + } + my $packed_ip; + $iporhost and $packed_ip = inet_aton($iporhost); + if (!$packed_ip) + { + return undef; + } + if ($extraarguments{GetNumber}) { #only 32 bits, no for loop needed. + return Math::BigInt->new(unpack("N*", $packed_ip)); + } + return inet_ntoa($packed_ip); } } -} +} #------------------------------------------------------------------------------- @@ -357,8 +361,9 @@ sub linklocaladdr { my $localprefix = "fe80"; my ($m1, $m2, $m3, $m6, $m7, $m8); + # mac address can be 00215EA376B0 or 00:21:5E:A3:76:B0 - if($mac =~ /^([0-9A-Fa-f]{2}).*?([0-9A-Fa-f]{2}).*?([0-9A-Fa-f]{2}).*?([0-9A-Fa-f]{2}).*?([0-9A-Fa-f]{2}).*?([0-9A-Fa-f]{2})$/) + if ($mac =~ /^([0-9A-Fa-f]{2}).*?([0-9A-Fa-f]{2}).*?([0-9A-Fa-f]{2}).*?([0-9A-Fa-f]{2}).*?([0-9A-Fa-f]{2}).*?([0-9A-Fa-f]{2})$/) { ($m1, $m2, $m3, $m6, $m7, $m8) = ($1, $2, $3, $4, $5, $6); } @@ -367,7 +372,7 @@ sub linklocaladdr { #not a valid mac address return undef; } - my ($m4, $m5) = ("ff","fe"); + my ($m4, $m5) = ("ff", "fe"); #my $bit = (int $m1) & 2; #if ($bit) { @@ -420,31 +425,31 @@ sub ishostinsubnet { { return 0; } - my $numbits=32; - if ($ip =~ /:/) {#ipv6 - $numbits=128; + my $numbits = 32; + if ($ip =~ /:/) { #ipv6 + $numbits = 128; } if ($mask) { - if ($mask =~ /\//) { - $mask =~ s/^\///; - $mask=Math::BigInt->new("0b".("1"x$mask).("0"x($numbits-$mask))); - } else { - $mask=getipaddr($mask,GetNumber=>1); - } - } else { #CIDR notation supported - if ($subnet && ($subnet =~ /\//)) { - ($subnet,$mask) = split /\//,$subnet,2; - $mask=Math::BigInt->new("0b".("1"x$mask).("0"x($numbits-$mask))); + if ($mask =~ /\//) { + $mask =~ s/^\///; + $mask = Math::BigInt->new("0b" . ("1" x $mask) . ("0" x ($numbits - $mask))); + } else { + $mask = getipaddr($mask, GetNumber => 1); + } + } else { #CIDR notation supported + if ($subnet && ($subnet =~ /\//)) { + ($subnet, $mask) = split /\//, $subnet, 2; + $mask = Math::BigInt->new("0b" . ("1" x $mask) . ("0" x ($numbits - $mask))); } else { die "ishostinsubnet must either be called with a netmask or CIDR /bits notation"; } } - if ($subnet && ($subnet =~ /\//)) #remove CIDR suffix from subnet + if ($subnet && ($subnet =~ /\//)) #remove CIDR suffix from subnet { $subnet =~ s/\/.*$//; } - $ip = getipaddr($ip,GetNumber=>1); - $subnet = getipaddr($subnet,GetNumber=>1); + $ip = getipaddr($ip, GetNumber => 1); + $subnet = getipaddr($subnet, GetNumber => 1); $ip &= $mask; if ($ip && $subnet && ($ip == $subnet)) { return 1; @@ -464,21 +469,21 @@ sub ishostinsubnet { #----------------------------------------------------------------------------- sub setup_ip_forwarding { - my ($class, $enable)=@_; + my ($class, $enable) = @_; if (xCAT::Utils->isLinux()) { - my $conf_file="/etc/sysctl.conf"; - `grep "net.ipv4.ip_forward" $conf_file`; + my $conf_file = "/etc/sysctl.conf"; + `grep "net.ipv4.ip_forward" $conf_file`; if ($? == 0) { - `sed -i "s/^net.ipv4.ip_forward = .*/net.ipv4.ip_forward = $enable/" $conf_file`; - `sed -i "s/^#net.ipv4.ip_forward *= *.*/net.ipv4.ip_forward = $enable/" $conf_file`; #debian/ubuntu have different default format - } else { - `echo "net.ipv4.ip_forward = $enable" >> $conf_file`; - } - `sysctl -e -p $conf_file`; # workaround for redhat bug 639821 +`sed -i "s/^net.ipv4.ip_forward = .*/net.ipv4.ip_forward = $enable/" $conf_file`; +`sed -i "s/^#net.ipv4.ip_forward *= *.*/net.ipv4.ip_forward = $enable/" $conf_file`; #debian/ubuntu have different default format + } else { + `echo "net.ipv4.ip_forward = $enable" >> $conf_file`; + } + `sysctl -e -p $conf_file`; # workaround for redhat bug 639821 } else - { - `no -o ipforwarding=$enable`; + { + `no -o ipforwarding=$enable`; } return 0; } @@ -494,19 +499,19 @@ sub setup_ip_forwarding #----------------------------------------------------------------------------- sub setup_ipv6_forwarding { - my ($class, $enable)=@_; + my ($class, $enable) = @_; if (xCAT::Utils->isLinux()) { - my $conf_file="/etc/sysctl.conf"; + my $conf_file = "/etc/sysctl.conf"; `grep "net.ipv6.conf.all.forwarding" $conf_file`; if ($? == 0) { - `sed -i "s/^net.ipv6.conf.all.forwarding = .*/net.ipv6.conf.all.forwarding = $enable/" $conf_file`; +`sed -i "s/^net.ipv6.conf.all.forwarding = .*/net.ipv6.conf.all.forwarding = $enable/" $conf_file`; } else { `echo "net.ipv6.conf.all.forwarding = $enable" >> $conf_file`; } `sysctl -e -p $conf_file`; } else - { + { `no -o ip6forwarding=$enable`; } return 0; @@ -540,8 +545,8 @@ sub prefixtomask { { return 0; } - - my $number=Math::BigInt->new("0b".("1"x$prefixlength).("0"x(128-$prefixlength))); + + my $number = Math::BigInt->new("0b" . ("1" x $prefixlength) . ("0" x (128 - $prefixlength))); my $mask = $number->as_hex(); $mask =~ s/^0x//; $mask =~ s/(....)/$1/g; @@ -576,7 +581,7 @@ sub my_ip_in_subnet if (!$net || !$mask) { return undef; - } + } my $fmask = xCAT::NetworkUtils::formatNetmask($mask, 0, 1); @@ -621,6 +626,7 @@ sub ip_forwarding_enabled } return $enabled; } + #------------------------------------------------------------------------------- =head3 get_nic_ip @@ -644,10 +650,10 @@ sub get_nic_ip { my $nic; my %iphash; - my $mode = "MULTICAST"; - my $payingattention=0; - my $interface; - my $keepcurrentiface; + my $mode = "MULTICAST"; + my $payingattention = 0; + my $interface; + my $keepcurrentiface; if (xCAT::Utils->isAIX()) { @@ -660,66 +666,67 @@ sub get_nic_ip # en1: ... # ############################################################## - my $cmd = "ifconfig -a"; - my $result = `$cmd`; + my $cmd = "ifconfig -a"; + my $result = `$cmd`; ############################################# # Error running command ############################################# - if ( !$result ) { - return undef; + if (!$result) { + return undef; } my @adapter = split /(\w+\d+):\s+flags=/, $result; - foreach ( @adapter ) { + foreach (@adapter) { if ($_ =~ /^(en\d)/) { - $nic = $1; - next; + $nic = $1; + next; } - if ( !($_ =~ /LOOPBACK/ ) and - $_ =~ /UP(,|>)/ and - $_ =~ /$mode/ ) { + if (!($_ =~ /LOOPBACK/) and + $_ =~ /UP(,|>)/ and + $_ =~ /$mode/) { my @ip = split /\n/; - for my $ent ( @ip ) { - if ( $ent =~ /^\s*inet\s+(\d+\.\d+\.\d+\.\d+)/ ) { - $iphash{$nic} = $1; + for my $ent (@ip) { + if ($ent =~ /^\s*inet\s+(\d+\.\d+\.\d+\.\d+)/) { + $iphash{$nic} = $1; next; } } } } } - else { # linux + else { # linux my @ipoutput = `ip addr`; ############################################# # Error running command ############################################# - if ( !@ipoutput ) { - return undef; + if (!@ipoutput) { + return undef; } foreach my $line (@ipoutput) { - if ($line =~ /^\d/) { # new interface, new context.. + if ($line =~ /^\d/) { # new interface, new context.. if ($interface and not $keepcurrentiface) { + #don't bother reporting unusable nics delete $iphash{$interface}; } - $keepcurrentiface=0; - if ( !($line =~ /LOOPBACK/ ) and - $line =~ /UP( |,|>)/ and - $line =~ /$mode/ ) { - - $payingattention=1; + $keepcurrentiface = 0; + if (!($line =~ /LOOPBACK/) and + $line =~ /UP( |,|>)/ and + $line =~ /$mode/) { + + $payingattention = 1; $line =~ /^([^:]*): ([^:]*):/; - $interface=$2; - } else { - $payingattention=0; + $interface = $2; + } else { + $payingattention = 0; next; - } + } } - unless ($payingattention) { next; } + unless ($payingattention) { next; } if ($line =~ /inet/) { - $keepcurrentiface=1; + $keepcurrentiface = 1; } - if ( $line =~ /^\s*inet \s*(\d+\.\d+\.\d+\.\d+)/ ) { - $iphash{$interface} = $1; + if ($line =~ /^\s*inet \s*(\d+\.\d+\.\d+\.\d+)/) { + $iphash{$interface} = $1; } } } @@ -833,7 +840,7 @@ sub my_hexnets while ($nown <= $highn) { my $nowhex = sprintf("%08x", $nown); - $rethash->{substr($nowhex, 0, $numchars)} = $curnet; + $rethash->{ substr($nowhex, 0, $numchars) } = $curnet; $nown += 1 << (32 - $maskbits - $bitstoeven); } } @@ -871,7 +878,7 @@ sub get_host_from_ip { my $ip = shift; } - + #------------------------------------------------------------------------------- =head3 isPingable @@ -900,32 +907,33 @@ For an example #----------------------------------------------------------------------- my %PING_CACHE; + sub isPingable { my $ip = shift; my $rc; - if ( exists $PING_CACHE{ $ip}) + if (exists $PING_CACHE{$ip}) { - $rc = $PING_CACHE{ $ip}; + $rc = $PING_CACHE{$ip}; } else { my $res = `LANG=C ping -c 1 -w 5 $ip 2>&1`; - if ( $res =~ /100% packet loss/g) - { + if ($res =~ /100% packet loss/g) + { $rc = 1; } else { $rc = 0; } - $PING_CACHE{ $ip} = $rc; + $PING_CACHE{$ip} = $rc; } - return ! $rc; + return !$rc; } - + #------------------------------------------------------------------------------- =head3 my_nets @@ -953,6 +961,7 @@ For an example Comments: none =cut + #----------------------------------------------------------------------- sub my_nets { @@ -961,7 +970,7 @@ sub my_nets my @nets; my $v6net; my $v6ip; - if ( $^O eq 'aix') + if ($^O eq 'aix') { @nets = split /\n/, `/usr/sbin/ifconfig -a`; } @@ -978,19 +987,19 @@ sub my_nets next; } my $curnet; my $maskbits; - if ( $^O eq 'aix') + if ($^O eq 'aix') { if ($elems[1] eq 'inet6') { - $v6net=$elems[2]; - $v6ip=$elems[2]; - $v6ip =~ s/\/.*//; # ipv6 address 4000::99/64 - $v6ip =~ s/\%.*//; # ipv6 address ::1%1/128 + $v6net = $elems[2]; + $v6ip = $elems[2]; + $v6ip =~ s/\/.*//; # ipv6 address 4000::99/64 + $v6ip =~ s/\%.*//; # ipv6 address ::1%1/128 } else { $curnet = $elems[2]; - $maskbits = formatNetmask( $elems[4], 2, 1); + $maskbits = formatNetmask($elems[4], 2, 1); } } else @@ -1003,46 +1012,49 @@ sub my_nets } if (!$v6net) { - my $curmask = 2**$maskbits - 1 << (32 - $maskbits); - my $nown = unpack("N", inet_aton($curnet)); + my $curmask = 2**$maskbits - 1 << (32 - $maskbits); + my $nown = unpack("N", inet_aton($curnet)); $nown = $nown & $curmask; - my $textnet=inet_ntoa(pack("N",$nown)); - $textnet.="/$maskbits"; + my $textnet = inet_ntoa(pack("N", $nown)); + $textnet .= "/$maskbits"; $rethash->{$textnet} = $curnet; - } - else - { - $rethash->{$v6net} = $v6ip; - } + } + else + { + $rethash->{$v6net} = $v6ip; + } } - # now get remote nets + # now get remote nets my $nettab = xCAT::Table->new("networks"); + #my $sitetab = xCAT::Table->new("site"); #my $master = $sitetab->getAttribs({key=>'master'},'value'); #$master = $master->{value}; - my @masters = xCAT::TableUtils->get_site_attribute("master"); - my $master = $masters[0]; - my @vnets = $nettab->getAllAttribs('net','mgtifname','mask'); + my @masters = xCAT::TableUtils->get_site_attribute("master"); + my $master = $masters[0]; + my @vnets = $nettab->getAllAttribs('net', 'mgtifname', 'mask'); - foreach(@vnets){ - my $n = $_->{net}; - my $if = $_->{mgtifname}; - my $nm = $_->{mask}; - if (!$n || !$if || !$nm) - { - next; #incomplete network - } - if ($if =~ /!remote!/) { #only take in networks with special interface - $nm = formatNetmask($nm, 0 , 1); - $n .="/$nm"; - #$rethash->{$n} = $if; - $rethash->{$n} = $master; - } + foreach (@vnets) { + my $n = $_->{net}; + my $if = $_->{mgtifname}; + my $nm = $_->{mask}; + if (!$n || !$if || !$nm) + { + next; #incomplete network + } + if ($if =~ /!remote!/) { #only take in networks with special interface + $nm = formatNetmask($nm, 0, 1); + $n .= "/$nm"; + + #$rethash->{$n} = $if; + $rethash->{$n} = $master; + } } return $rethash; } + #------------------------------------------------------------------------------- =head3 my_if_netmap @@ -1074,11 +1086,11 @@ sub my_if_netmap my %retmap; foreach (@rtable) { - if (/^\D/) { next; } #skip headers + if (/^\D/) { next; } #skip headers if (/^\S+\s+\S+\s+\S+\s+\S*G/) { next; - } #Skip networks that require gateways to get to + } #Skip networks that require gateways to get to /^(\S+)\s.*\s(\S+)$/; $retmap{$1} = $2; } @@ -1118,11 +1130,11 @@ sub my_ip_facing { $peer = shift; } - - return my_ip_facing_aix( $peer) if ( $^O eq 'aix'); + + return my_ip_facing_aix($peer) if ($^O eq 'aix'); my @rst; - my $peernumber = inet_aton($peer); #TODO: IPv6 support - unless ($peernumber) { + my $peernumber = inet_aton($peer); #TODO: IPv6 support + unless ($peernumber) { $rst[0] = 1; $rst[1] = "The $peer can not be resolved"; return @rst; } @@ -1137,7 +1149,7 @@ sub my_ip_facing { next; } - (my $curnet, my $maskbits) = split /\//, $elems[2]; + (my $curnet, my $maskbits) = split /\//, $elems[2]; my $curmask = 2**$maskbits - 1 << (32 - $maskbits); my $curn = unpack("N", inet_aton($curnet)); if (($noden & $curmask) == ($curn & $curmask)) @@ -1183,14 +1195,14 @@ sub my_ip_facing_aix my @rst; foreach my $net (@nets) { - my ($curnet,$netmask); - if ( $net =~ /^\s*inet\s+([\d\.]+)\s+netmask\s+(\w+)\s+broadcast/) + my ($curnet, $netmask); + if ($net =~ /^\s*inet\s+([\d\.]+)\s+netmask\s+(\w+)\s+broadcast/) { - ($curnet,$netmask) = ($1,$2); + ($curnet, $netmask) = ($1, $2); } elsif ($net =~ /^\s*inet6\s+(.*)$/) { - ($curnet,$netmask) = split('/', $1); + ($curnet, $netmask) = split('/', $1); } else { @@ -1206,7 +1218,7 @@ sub my_ip_facing_aix $rst[0] = 0; push @rst, @ips; } - else + else { $rst[0] = 2; $rst[1] = "The IP address of node $peer is in an undefined subnet"; @@ -1243,22 +1255,23 @@ sub my_ip_facing_aix Comments: none =cut + #----------------------------------------------------------------------- sub formatNetmask { - my $mask = shift; + my $mask = shift; my $origType = shift; - my $newType = shift; + my $newType = shift; my $maskn; - if ( $origType == 0) + if ($origType == 0) { $maskn = unpack("N", inet_aton($mask)); } - elsif ( $origType == 1) + elsif ($origType == 1) { $maskn = 2**$mask - 1 << (32 - $mask); } - elsif( $origType == 2) + elsif ($origType == 2) { $maskn = hex $mask; } @@ -1267,17 +1280,17 @@ sub formatNetmask return undef; } - if ( $newType == 0) + if ($newType == 0) { - return inet_ntoa( pack('N', $maskn)); + return inet_ntoa(pack('N', $maskn)); } - if ( $newType == 1) + if ($newType == 1) { - my $bin = unpack ("B32", pack("N", $maskn)); - my @dup = ( $bin =~ /(1{1})0*/g); - return scalar ( @dup); + my $bin = unpack("B32", pack("N", $maskn)); + my @dup = ($bin =~ /(1{1})0*/g); + return scalar(@dup); } - if ( $newType == 2) + if ($newType == 2) { return sprintf "0x%1x", $maskn; } @@ -1315,12 +1328,13 @@ sub formatNetmask Comments: none =cut + #----------------------------------------------------------------------- sub isInSameSubnet { - my $ip1 = shift; - my $ip2 = shift; - my $mask = shift; + my $ip1 = shift; + my $ip2 = shift; + my $mask = shift; my $maskType = shift; $ip1 = xCAT::NetworkUtils->getipaddr($ip1); @@ -1332,7 +1346,7 @@ sub isInSameSubnet } if ((($ip1 =~ /\d+\.\d+\.\d+\.\d+/) && ($ip2 !~ /\d+\.\d+\.\d+\.\d+/)) - ||(($ip1 !~ /\d+\.\d+\.\d+\.\d+/) && ($ip2 =~ /\d+\.\d+\.\d+\.\d+/))) + || (($ip1 !~ /\d+\.\d+\.\d+\.\d+/) && ($ip2 =~ /\d+\.\d+\.\d+\.\d+/))) { #ipv4 and ipv6 can not be in the same subnet return undef; @@ -1341,15 +1355,15 @@ sub isInSameSubnet if (($ip1 =~ /\d+\.\d+\.\d+\.\d+/) && ($ip2 =~ /\d+\.\d+\.\d+\.\d+/)) { my $maskn; - if ( $maskType == 0) + if ($maskType == 0) { $maskn = unpack("N", inet_aton($mask)); } - elsif ( $maskType == 1) + elsif ($maskType == 1) { $maskn = 2**$mask - 1 << (32 - $mask); } - elsif( $maskType == 2) + elsif ($maskType == 2) { $maskn = hex $mask; } @@ -1361,7 +1375,7 @@ sub isInSameSubnet my $ip1n = unpack("N", inet_aton($ip1)); my $ip2n = unpack("N", inet_aton($ip2)); - return ( ( $ip1n & $maskn) == ( $ip2n & $maskn) ); + return (($ip1n & $maskn) == ($ip2n & $maskn)); } else { @@ -1370,20 +1384,21 @@ sub isInSameSubnet { return undef; } - my $netipmodule = eval {require Net::IP;}; + my $netipmodule = eval { require Net::IP; }; if ($netipmodule) { - my $eip1 = Net::IP::ip_expand_address ($ip1,6); - my $eip2 = Net::IP::ip_expand_address ($ip2,6); - my $bmask = Net::IP::ip_get_mask($mask,6); - my $bip1 = Net::IP::ip_iptobin($eip1,6); - my $bip2 = Net::IP::ip_iptobin($eip2,6); - if (($bip1 & $bmask) == ($bip2 & $bmask)) { - return 1; - } - } # else, can not check without Net::IP module - return undef; - } + my $eip1 = Net::IP::ip_expand_address($ip1, 6); + my $eip2 = Net::IP::ip_expand_address($ip2, 6); + my $bmask = Net::IP::ip_get_mask($mask, 6); + my $bip1 = Net::IP::ip_iptobin($eip1, 6); + my $bip2 = Net::IP::ip_iptobin($eip2, 6); + if (($bip1 & $bmask) == ($bip2 & $bmask)) { + return 1; + } + } # else, can not check without Net::IP module + return undef; + } } + #------------------------------------------------------------------------------- =head3 nodeonmynet - checks to see if node is on any network this server is attached to or remote network potentially managed by this system @@ -1411,7 +1426,7 @@ sub nodeonmynet $nodetocheck = shift; } - my $nodeip = getNodeIPaddress( $nodetocheck ); + my $nodeip = getNodeIPaddress($nodetocheck); if (!$nodeip) { return 0; @@ -1419,7 +1434,7 @@ sub nodeonmynet unless ($nodeip =~ /\d+\.\d+\.\d+\.\d+/) { #IPv6 - if ( $^O eq 'aix') + if ($^O eq 'aix') { my @subnets = get_subnet_aix(); for my $net_ent (@subnets) @@ -1429,7 +1444,7 @@ sub nodeonmynet #ipv4 next; } - my ($net, $interface, $mask, $flag) = split/-/ , $net_ent; + my ($net, $interface, $mask, $flag) = split /-/, $net_ent; if (xCAT::NetworkUtils->ishostinsubnet($nodeip, $mask, $net)) { return 1; @@ -1437,23 +1452,24 @@ sub nodeonmynet } } else { - my @v6routes = split /\n/,`ip -6 route`; + my @v6routes = split /\n/, `ip -6 route`; foreach (@v6routes) { if (/via/ or /^unreachable/ or /^fe80::\/64/) { - #only count local ones, remote ones can be caught in next loop - #also, link-local would be a pitfall, + + #only count local ones, remote ones can be caught in next loop + #also, link-local would be a pitfall, #since more context than address is - #needed to determine locality + #needed to determine locality next; } - s/ .*//; #remove all after the space - if (xCAT::NetworkUtils->ishostinsubnet($nodeip,'',$_)) { #bank on CIDR support + s/ .*//; #remove all after the space + if (xCAT::NetworkUtils->ishostinsubnet($nodeip, '', $_)) { #bank on CIDR support return 1; } } } - my $nettab=xCAT::Table->new("networks"); - my @vnets = $nettab->getAllAttribs('net','mgtifname','mask'); + my $nettab = xCAT::Table->new("networks"); + my @vnets = $nettab->getAllAttribs('net', 'mgtifname', 'mask'); foreach (@vnets) { if ((defined $_->{mgtifname}) && ($_->{mgtifname} eq '!remote!')) { @@ -1468,19 +1484,19 @@ sub nodeonmynet my $noden = unpack("N", inet_aton($nodeip)); my @nets; if ($utildata->{nodeonmynetdata} and $utildata->{nodeonmynetdata}->{pid} == $$) { - @nets = @{$utildata->{nodeonmynetdata}->{nets}}; + @nets = @{ $utildata->{nodeonmynetdata}->{nets} }; } else { - if ( $^O eq 'aix') + if ($^O eq 'aix') { my @subnets = get_subnet_aix(); for my $net_ent (@subnets) { - if ($net_ent =~ /-/) + if ($net_ent =~ /-/) { #ipv6 next; } - my @ents = split /:/ , $net_ent; + my @ents = split /:/, $net_ent; push @nets, $ents[0] . '/' . $ents[2] . ' dev ' . $ents[1]; } @@ -1489,21 +1505,21 @@ sub nodeonmynet { @nets = split /\n/, `/sbin/ip route`; } - my $nettab=xCAT::Table->new("networks"); - my @vnets = $nettab->getAllAttribs('net','mgtifname','mask'); + my $nettab = xCAT::Table->new("networks"); + my @vnets = $nettab->getAllAttribs('net', 'mgtifname', 'mask'); foreach (@vnets) { if ((defined $_->{mgtifname}) && ($_->{mgtifname} eq '!remote!')) - { #global scoped network + { #global scoped network my $curm = unpack("N", inet_aton($_->{mask})); - my $bits=32; - until ($curm & 1) { + my $bits = 32; + until ($curm & 1) { $bits--; - $curm=$curm>>1; + $curm = $curm >> 1; } - push @nets,$_->{'net'}."/".$bits." dev remote"; + push @nets, $_->{'net'} . "/" . $bits . " dev remote"; } } - $utildata->{nodeonmynetdata}->{pid}=$$; + $utildata->{nodeonmynetdata}->{pid} = $$; $utildata->{nodeonmynetdata}->{nets} = \@nets; } foreach (@nets) @@ -1540,7 +1556,7 @@ sub nodeonmynet #------------------------------------------------------------------------------- -sub getNodeIPaddress +sub getNodeIPaddress { require xCAT::Table; my $nodetocheck = shift; @@ -1550,22 +1566,22 @@ sub getNodeIPaddress $nodeip = xCAT::NetworkUtils->getipaddr($nodetocheck); if (!$nodeip) { - my $hoststab = xCAT::Table->new( 'hosts'); - my $ent = $hoststab->getNodeAttribs( $nodetocheck, ['ip'] ); - if ( $ent->{'ip'} ) { + my $hoststab = xCAT::Table->new('hosts'); + my $ent = $hoststab->getNodeAttribs($nodetocheck, ['ip']); + if ($ent->{'ip'}) { $nodeip = $ent->{'ip'}; } } - - if ( $nodeip ) { + + if ($nodeip) { return $nodeip; } else { return undef; } } - - - + + + #------------------------------------------------------------------------------- =head3 thishostisnot @@ -1594,7 +1610,7 @@ sub thishostisnot } my @ips; - if ( $^O eq 'aix') + if ($^O eq 'aix') { @ips = split /\n/, `/usr/sbin/ifconfig -a`; } @@ -1656,7 +1672,7 @@ sub thishostisnot # { # if ($addr =~ /inet6/) # { -# #TODO, Linux ipv6 +# #TODO, Linux ipv6 # } # else # { @@ -1710,48 +1726,48 @@ sub gethost_ips my @ipaddress; if (xCAT::Utils->isLinux()) { - $cmd="ip -4 --oneline addr show |awk -F ' ' '{print \$4}'|awk -F '/' '{print \$1}'"; - my @result =xCAT::Utils->runcmd($cmd); - if ($::RUNCMD_RC != 0) - { - xCAT::MsgUtils->message("S", "Error from $cmd\n"); - exit $::RUNCMD_RC; - } - - push @ipaddress, @result; + $cmd = "ip -4 --oneline addr show |awk -F ' ' '{print \$4}'|awk -F '/' '{print \$1}'"; + my @result = xCAT::Utils->runcmd($cmd); + if ($::RUNCMD_RC != 0) + { + xCAT::MsgUtils->message("S", "Error from $cmd\n"); + exit $::RUNCMD_RC; + } + + push @ipaddress, @result; } else { #AIX - - $cmd = "ifconfig" . " -a"; - $cmd = $cmd . "| grep \"inet\""; - my @result = xCAT::Utils->runcmd($cmd, 0); - if ($::RUNCMD_RC != 0) - { - xCAT::MsgUtils->message("S", "Error from $cmd\n"); - exit $::RUNCMD_RC; - } - - foreach my $addr (@result) - { - if ($addr =~ /inet6/) - { - $addr =~ /\s*inet6\s+([\da-fA-F:]+).*\/(\d+)/; - my $v6ip = $1; - my $v6mask = $2; - if ($v6ip) - { - push @ipaddress, $v6ip; - } - } - else - { - my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) = - split(" ", $addr); - push @ipaddress, $addr1; - } - } + $cmd = "ifconfig" . " -a"; + $cmd = $cmd . "| grep \"inet\""; + my @result = xCAT::Utils->runcmd($cmd, 0); + if ($::RUNCMD_RC != 0) + { + xCAT::MsgUtils->message("S", "Error from $cmd\n"); + exit $::RUNCMD_RC; + } + + foreach my $addr (@result) + { + if ($addr =~ /inet6/) + { + $addr =~ /\s*inet6\s+([\da-fA-F:]+).*\/(\d+)/; + my $v6ip = $1; + my $v6mask = $2; + if ($v6ip) + { + push @ipaddress, $v6ip; + } + } + else + { + my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) = + split(" ", $addr); + push @ipaddress, $addr1; + } + + } } my @names = @ipaddress; @@ -1794,18 +1810,18 @@ sub get_subnet_aix my @netstat_res = `/usr/bin/netstat -rn`; chomp @netstat_res; my @aix_nrn; - for my $entry ( @netstat_res) + for my $entry (@netstat_res) { -#We need to find entries like: -#Destination Gateway Flags Refs Use If Exp Groups -#9.114.47.192/27 9.114.47.205 U 1 1 en0 -#4000::/64 link#4 UCX 1 0 en2 - - - my ( $net, $netmask, $flag, $nic); - if ( $entry =~ /^\s*([\d\.]+)\/(\d+)\s+[\d\.]+\s+(\w+)\s+\d+\s+\d+\s(\w+)/) + #We need to find entries like: + #Destination Gateway Flags Refs Use If Exp Groups + #9.114.47.192/27 9.114.47.205 U 1 1 en0 + #4000::/64 link#4 UCX 1 0 en2 - - + my ($net, $netmask, $flag, $nic); + if ($entry =~ /^\s*([\d\.]+)\/(\d+)\s+[\d\.]+\s+(\w+)\s+\d+\s+\d+\s(\w+)/) { - ( $net, $netmask, $flag, $nic) = ($1,$2,$3,$4); + ($net, $netmask, $flag, $nic) = ($1, $2, $3, $4); my @dotsec = split /\./, $net; - for ( my $i = 4; $i > scalar(@dotsec); $i--) + for (my $i = 4 ; $i > scalar(@dotsec) ; $i--) { $net .= '.0'; } @@ -1814,7 +1830,8 @@ sub get_subnet_aix elsif ($entry =~ /^\s*([\dA-Fa-f\:]+)\/(\d+)\s+.*?\s+(\w+)\s+\d+\s+\d+\s(\w+)/) { #print "=====$entry====\n"; - ( $net, $netmask, $flag, $nic) = ($1,$2,$3,$4); + ($net, $netmask, $flag, $nic) = ($1, $2, $3, $4); + # for ipv6, can not use : as the delimiter push @aix_nrn, "$net-$nic-$netmask-$flag" if ($net ne '::') } @@ -1841,7 +1858,7 @@ sub determinehostname if ($::RUNCMD_RC != 0) { # could not get hostname xCAT::MsgUtils->message("S", - "Error $::RUNCMD_RC from $hostnamecmd command\n"); + "Error $::RUNCMD_RC from $hostnamecmd command\n"); exit $::RUNCMD_RC; } $hostname = $thostname[0]; @@ -1851,24 +1868,25 @@ sub determinehostname my @hostnamecandidates; my $nodename; while ($hostname =~ /\./) { - push @hostnamecandidates,$hostname; + push @hostnamecandidates, $hostname; $hostname =~ s/\.[^\.]*//; } - push @hostnamecandidates,$hostname; - my $checkhostnames = join(',',@hostnamecandidates); + push @hostnamecandidates, $hostname; + my $checkhostnames = join(',', @hostnamecandidates); my @validnodenames = xCAT::NodeRange::noderange($checkhostnames); unless (scalar @validnodenames) { #If the node in question is not in table, take output literrally. - push @validnodenames,$hostnamecandidates[0]; + push @validnodenames, $hostnamecandidates[0]; } + #now, noderange doesn't guarantee the order, so we search the preference order, most to least specific. foreach my $host (@hostnamecandidates) { - if (grep /^$host$/,@validnodenames) { + if (grep /^$host$/, @validnodenames) { $nodename = $host; last; } } - my @ips = xCAT::NetworkUtils->gethost_ips; - my @hostinfo = (@ips, $nodename); + my @ips = xCAT::NetworkUtils->gethost_ips; + my @hostinfo = (@ips, $nodename); return @hostinfo; } @@ -1887,14 +1905,14 @@ sub toIP if (($_[0] =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/) || ($_[0] =~ /:/)) { - return ([0, $_[0]]); + return ([ 0, $_[0] ]); } my $ip = xCAT::NetworkUtils->getipaddr($_[0]); if (!$ip) { - return ([1, "Cannot Resolve: $_[0]\n"]); + return ([ 1, "Cannot Resolve: $_[0]\n" ]); } - return ([0, $ip]); + return ([ 0, $ip ]); } #------------------------------------------------------------------------------- @@ -1922,26 +1940,28 @@ sub validate_ip my ($class, @IPs) = @_; foreach (@IPs) { my $ip = $_; + #TODO need more check for IPv6 address if ($ip =~ /:/) { - return([0]); + return ([0]); } ################################### # Length is 4 for IPv4 addresses ################################### my (@octets) = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/; - if ( scalar(@octets) != 4 ) { - return( [1,"Invalid IP address1: $ip"] ); + if (scalar(@octets) != 4) { + return ([ 1, "Invalid IP address1: $ip" ]); } - foreach my $octet ( @octets ) { - if (( $octet < 0 ) or ( $octet > 255 )) { - return( [1,"Invalid IP address2: $ip"] ); + foreach my $octet (@octets) { + if (($octet < 0) or ($octet > 255)) { + return ([ 1, "Invalid IP address2: $ip" ]); } } } - return([0]); + return ([0]); } + #------------------------------------------------------------------------------- =head3 isIpaddr @@ -1974,10 +1994,11 @@ sub isIpaddr $addr = shift; } - unless ( $addr ) + unless ($addr) { return 0; } + #print "addr=$addr\n"; if ($addr !~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) { @@ -1998,6 +2019,7 @@ sub isIpaddr #------------------------------------------------------------------------------- + =head3 getNodeNameservers Description: Get nameservers of specified nodes. @@ -2017,36 +2039,37 @@ sub isIpaddr none =cut + #------------------------------------------------------------------------------- -sub getNodeNameservers{ - my $nodes=shift; - if( $nodes =~ /xCAT::NetworkUtils/) +sub getNodeNameservers { + my $nodes = shift; + if ($nodes =~ /xCAT::NetworkUtils/) { - $nodes=shift; + $nodes = shift; } my @nodelist = @$nodes; my %nodenameservers; - my $nrtab = xCAT::Table->new('noderes',-create=>0); - my %nrhash = %{$nrtab->getNodesAttribs(\@nodelist,['nameservers'])}; - - my $nettab = xCAT::Table->new("networks"); - my %nethash = xCAT::DBobjUtils->getNetwkInfo( \@nodelist ); + my $nrtab = xCAT::Table->new('noderes', -create => 0); + my %nrhash = %{ $nrtab->getNodesAttribs(\@nodelist, ['nameservers']) }; - my @nameservers = xCAT::TableUtils->get_site_attribute("nameservers"); - my $sitenameservers=$nameservers[0]; + my $nettab = xCAT::Table->new("networks"); + my %nethash = xCAT::DBobjUtils->getNetwkInfo(\@nodelist); + + my @nameservers = xCAT::TableUtils->get_site_attribute("nameservers"); + my $sitenameservers = $nameservers[0]; - foreach my $node (@nodelist){ - if ($nrhash{$node} and $nrhash{$node}->[0] and $nrhash{$node}->[0]->{nameservers}) - { - $nodenameservers{$node}=$nrhash{$node}->[0]->{nameservers}; - }elsif($nethash{$node}{nameservers}) - { - $nodenameservers{$node}=$nethash{$node}{nameservers}; - }elsif($sitenameservers) - { - $nodenameservers{$node}=$sitenameservers; - } + foreach my $node (@nodelist) { + if ($nrhash{$node} and $nrhash{$node}->[0] and $nrhash{$node}->[0]->{nameservers}) + { + $nodenameservers{$node} = $nrhash{$node}->[0]->{nameservers}; + } elsif ($nethash{$node}{nameservers}) + { + $nodenameservers{$node} = $nethash{$node}{nameservers}; + } elsif ($sitenameservers) + { + $nodenameservers{$node} = $sitenameservers; + } } return \%nodenameservers; @@ -2079,28 +2102,29 @@ sub getNodeNameservers{ sub getNodeNetworkCfg { my $node = shift; - if( $node =~ /xCAT::NetworkUtils/) + if ($node =~ /xCAT::NetworkUtils/) { - $node =shift; + $node = shift; } - my $ip = xCAT::NetworkUtils->getipaddr($node); - my $mask = undef; + my $ip = xCAT::NetworkUtils->getipaddr($node); + my $mask = undef; my $gateway = undef; my $nettab = xCAT::Table->new("networks"); if ($nettab) { - my @nets = $nettab->getAllAttribs('net','mask','gateway'); - foreach my $net (@nets) { - if (xCAT::NetworkUtils::isInSameSubnet( $net->{'net'}, $ip, $net->{'mask'}, 0)) { - $gateway=$net->{'gateway'}; - $mask=$net->{'mask'}; - } - } + my @nets = $nettab->getAllAttribs('net', 'mask', 'gateway'); + foreach my $net (@nets) { + if (xCAT::NetworkUtils::isInSameSubnet($net->{'net'}, $ip, $net->{'mask'}, 0)) { + $gateway = $net->{'gateway'}; + $mask = $net->{'mask'}; + } + } } - - return ($ip, $node, $gateway, xCAT::NetworkUtils::formatNetmask($mask,0,0)); + + return ($ip, $node, $gateway, xCAT::NetworkUtils::formatNetmask($mask, 0, 0)); } + #------------------------------------------------------------------------------- =head3 getNodesNetworkCfg @@ -2122,17 +2146,17 @@ sub getNodeNetworkCfg #------------------------------------------------------------------------------- -sub getNodesNetworkCfg +sub getNodesNetworkCfg { my $nodes = shift; if ($nodes =~ /xCAT::NetworkUtils/) { $nodes = shift; } - my @nets = (); + my @nets = (); my $nettab = xCAT::Table->new("networks"); - if($nettab) { + if ($nettab) { my @error_net = (); - my @all_nets = $nettab->getAllAttribs('net','mask','gateway'); + my @all_nets = $nettab->getAllAttribs('net', 'mask', 'gateway'); foreach my $net (@all_nets) { my $gateway = $net->{gateway}; if (defined($gateway) and ($gateway eq '')) { @@ -2141,7 +2165,7 @@ sub getNodesNetworkCfg $gateway = $gatewayd[1]; } } - push @nets, {net=>$net->{net}, mask=>$net->{mask}, gateway=>$gateway}; + push @nets, { net => $net->{net}, mask => $net->{mask}, gateway => $gateway }; } $nettab->close; } @@ -2155,9 +2179,9 @@ sub getNodesNetworkCfg foreach my $node (@$nodes) { my $ip = xCAT::NetworkUtils->getipaddr($node); foreach my $net (@nets) { - if (xCAT::NetworkUtils::isInSameSubnet( $net->{'net'}, $ip, $net->{'mask'}, 0)) { - $rethash{$node}->{ip} = $ip; - $rethash{$node}->{mask} = $net->{'mask'}; + if (xCAT::NetworkUtils::isInSameSubnet($net->{'net'}, $ip, $net->{'mask'}, 0)) { + $rethash{$node}->{ip} = $ip; + $rethash{$node}->{mask} = $net->{'mask'}; $rethash{$node}->{gateway} = $net->{'gateway'}; last; } @@ -2193,20 +2217,20 @@ sub get_hdwr_ip { require xCAT::Table; my $node = shift; - my $ip = undef; + my $ip = undef; my $Rc = undef; - my $ip_tmp_res = xCAT::NetworkUtils::toIP($node); + my $ip_tmp_res = xCAT::NetworkUtils::toIP($node); ($Rc, $ip) = @$ip_tmp_res; - if ( $Rc ) { - my $hosttab = xCAT::Table->new( 'hosts' ); - if ( $hosttab) { - my $node_ip_hash = $hosttab->getNodeAttribs( $node,[qw(ip)]); + if ($Rc) { + my $hosttab = xCAT::Table->new('hosts'); + if ($hosttab) { + my $node_ip_hash = $hosttab->getNodeAttribs($node, [qw(ip)]); $ip = $node_ip_hash->{ip}; } - + } - + if (!$ip) { return undef; } @@ -2215,6 +2239,7 @@ sub get_hdwr_ip } #-------------------------------------------------------------------------------- + =head3 pingNodeStatus This function takes an array of nodes and returns their status using nmap or fping. Arguments: @@ -2223,85 +2248,89 @@ sub get_hdwr_ip a hash that has the node status. The format is: {alive=>[node1, node3,...], unreachable=>[node4, node2...]} =cut + #-------------------------------------------------------------------------------- sub pingNodeStatus { - my ($class, @mon_nodes)=@_; - my %status=(); - my @active_nodes=(); - my @inactive_nodes=(); + my ($class, @mon_nodes) = @_; + my %status = (); + my @active_nodes = (); + my @inactive_nodes = (); + #print "NetworkUtils->pingNodeStatus called, nodes=@mon_nodes\n"; - if ((@mon_nodes)&& (@mon_nodes > 0)) { - #get all the active nodes - my $nodes= join(' ', @mon_nodes); - if (-x '/usr/bin/nmap' or -x '/usr/local/bin/nmap') { #use nmap - #print "use nmap\n"; - my %deadnodes; - foreach (@mon_nodes) { - $deadnodes{$_}=1; - } + if ((@mon_nodes) && (@mon_nodes > 0)) { - # get additional options from site table - my @nmap_options = xCAT::TableUtils->get_site_attribute("nmapoptions"); - my $more_options = $nmap_options[0]; + #get all the active nodes + my $nodes = join(' ', @mon_nodes); + if (-x '/usr/bin/nmap' or -x '/usr/local/bin/nmap') { #use nmap + #print "use nmap\n"; + my %deadnodes; + foreach (@mon_nodes) { + $deadnodes{$_} = 1; + } - #call namp - open (NMAP, "nmap -PE --system-dns --send-ip -sP $more_options ". $nodes . " 2> /dev/null|") or die("Cannot open nmap pipe: $!"); - my $node; - while () { - if (/Host (.*) \(.*\) appears to be up/) { - $node=$1; - unless ($deadnodes{$node}) { - foreach (keys %deadnodes) { - if ($node =~ /^$_\./) { - $node = $_; - last; - } - } - } - delete $deadnodes{$node}; - push(@active_nodes, $node); - } elsif (/Nmap scan report for ([^ ]*) /) { - $node=$1; - } elsif (/Host is up./) { - unless ($deadnodes{$node}) { - foreach (keys %deadnodes) { - if ($node =~ /^$_\./) { - $node = $_; - last; - } - } - } - delete $deadnodes{$node}; - push(@active_nodes, $node); - } - } - foreach (sort keys %deadnodes) { - push(@inactive_nodes, $_); - } - } else { #use fping - #print "use fping\n"; + # get additional options from site table + my @nmap_options = xCAT::TableUtils->get_site_attribute("nmapoptions"); + my $more_options = $nmap_options[0]; - my $temp=`fping -a $nodes 2> /dev/null`; - chomp($temp); - @active_nodes=split(/\n/, $temp); - - #get all the inactive nodes by substracting the active nodes from all. - my %temp2; - if ((@active_nodes) && ( @active_nodes > 0)) { - foreach(@active_nodes) { $temp2{$_}=1}; - foreach(@mon_nodes) { - if (!$temp2{$_}) { push(@inactive_nodes, $_);} - } - } - else {@inactive_nodes=@mon_nodes;} - } + #call namp + open(NMAP, "nmap -PE --system-dns --send-ip -sP $more_options " . $nodes . " 2> /dev/null|") or die("Cannot open nmap pipe: $!"); + my $node; + while () { + if (/Host (.*) \(.*\) appears to be up/) { + $node = $1; + unless ($deadnodes{$node}) { + foreach (keys %deadnodes) { + if ($node =~ /^$_\./) { + $node = $_; + last; + } + } + } + delete $deadnodes{$node}; + push(@active_nodes, $node); + } elsif (/Nmap scan report for ([^ ]*) /) { + $node = $1; + } elsif (/Host is up./) { + unless ($deadnodes{$node}) { + foreach (keys %deadnodes) { + if ($node =~ /^$_\./) { + $node = $_; + last; + } + } + } + delete $deadnodes{$node}; + push(@active_nodes, $node); + } + } + foreach (sort keys %deadnodes) { + push(@inactive_nodes, $_); + } + } else { #use fping + #print "use fping\n"; + + my $temp = `fping -a $nodes 2> /dev/null`; + chomp($temp); + @active_nodes = split(/\n/, $temp); + + #get all the inactive nodes by substracting the active nodes from all. + my %temp2; + if ((@active_nodes) && (@active_nodes > 0)) { + foreach (@active_nodes) { $temp2{$_} = 1 } + foreach (@mon_nodes) { + if (!$temp2{$_}) { push(@inactive_nodes, $_); } + } + } + else { @inactive_nodes = @mon_nodes; } + } } - - $status{$::STATUS_ACTIVE}=\@active_nodes; - $status{$::STATUS_INACTIVE}=\@inactive_nodes; + + $status{$::STATUS_ACTIVE} = \@active_nodes; + $status{$::STATUS_INACTIVE} = \@inactive_nodes; + #use Data::Dumper; #print Dumper(%status); - + return %status; } @@ -2318,7 +2347,7 @@ sub pingNodeStatus { sub isValidMAC { my ($class, $macstr) = @_; - if ($macstr =~ /^[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}$/){ + if ($macstr =~ /^[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}$/) { return 1; } return 0; @@ -2337,9 +2366,9 @@ sub isValidMAC sub isValidHostname { my ($class, $hostname) = @_; - if ($hostname =~ /^[a-z0-9]/){ - if ($hostname =~ /[a-z0-9]$/){ - if ($hostname =~ /^[\-a-z0-9]+$/){ + if ($hostname =~ /^[a-z0-9]/) { + if ($hostname =~ /[a-z0-9]$/) { + if ($hostname =~ /^[\-a-z0-9]+$/) { return 1; } } @@ -2361,7 +2390,7 @@ sub isValidHostname sub isValidFQDN { my ($class, $hostname) = @_; - if ($hostname =~ /^[a-z0-9][\.\-a-z0-9]+[a-z0-9]$/){ + if ($hostname =~ /^[a-z0-9][\.\-a-z0-9]+[a-z0-9]$/) { return 1; } return 0; @@ -2417,10 +2446,10 @@ sub int_to_ip sub getBroadcast { my ($class, $ipstr, $netmask) = @_; - my $ipint = xCAT::NetworkUtils->ip_to_int($ipstr); + my $ipint = xCAT::NetworkUtils->ip_to_int($ipstr); my $maskint = xCAT::NetworkUtils->ip_to_int($netmask); - my $tmp = sprintf("%d", ~$maskint); - my $bcnum = sprintf("%d", ($ipint | $tmp) & hex('0x00000000FFFFFFFF')); + my $tmp = sprintf("%d", ~$maskint); + my $bcnum = sprintf("%d", ($ipint | $tmp) & hex('0x00000000FFFFFFFF')); return xCAT::NetworkUtils->int_to_ip($bcnum); } @@ -2441,27 +2470,27 @@ sub getBroadcast #------------------------------------------------------------------------------- sub get_allips_in_range { - my $class = shift; - my $startip = shift; - my $endip = shift; + my $class = shift; + my $startip = shift; + my $endip = shift; my $increment = shift; - my @iplist = (); + my @iplist = (); my $tmpip; my $startipnum = xCAT::NetworkUtils->ip_to_int($startip); - my $endipnum = xCAT::NetworkUtils->ip_to_int($endip); + my $endipnum = xCAT::NetworkUtils->ip_to_int($endip); - if ($increment > 0){ - while ($startipnum <= $endipnum){ + if ($increment > 0) { + while ($startipnum <= $endipnum) { $tmpip = xCAT::NetworkUtils->int_to_ip($startipnum); $startipnum += $increment; - push (@iplist, $tmpip); + push(@iplist, $tmpip); } - }elsif($increment < 0){ - while ($endipnum >= $startipnum){ + } elsif ($increment < 0) { + while ($endipnum >= $startipnum) { $tmpip = xCAT::NetworkUtils->int_to_ip($endipnum); $endipnum += $increment; - push (@iplist, $tmpip); + push(@iplist, $tmpip); } } return \@iplist; @@ -2477,37 +2506,39 @@ sub get_allips_in_range =cut #------------------------------------------------------------------------------- -sub get_all_nicips{ +sub get_all_nicips { my ($class, $hashref) = @_; my %allipshash; my @allipslist; - my $table = xCAT::Table->new('nics'); + my $table = xCAT::Table->new('nics'); my @entries = $table->getAllNodeAttribs(['nicips']); - foreach (@entries){ + foreach (@entries) { + # $_->{nicips} looks like "eth0:ip1,eth1:ip2,bmc:ip3..." - if($_->{nicips}){ + if ($_->{nicips}) { my @nicandiplist = split(',', $_->{nicips}); + # Each record in @nicandiplist looks like "eth0:ip1" - # delimiter has been changed to use "!" in xCAT 2.8 - foreach (@nicandiplist){ - my @nicandip; - if ($_ =~ /!/) { - @nicandip = split('!', $_); - } else { - @nicandip = split(':', $_); - } - if ($hashref){ - $allipshash{$nicandip[1]} = 0; - } else{ - push (@allipslist, $nicandip[1]); + # delimiter has been changed to use "!" in xCAT 2.8 + foreach (@nicandiplist) { + my @nicandip; + if ($_ =~ /!/) { + @nicandip = split('!', $_); + } else { + @nicandip = split(':', $_); + } + if ($hashref) { + $allipshash{ $nicandip[1] } = 0; + } else { + push(@allipslist, $nicandip[1]); } } } } - if ($hashref){ + if ($hashref) { return \%allipshash; - } else{ + } else { return \@allipslist; } } @@ -2561,21 +2592,21 @@ sub get_all_nicips{ #------------------------------------------------------------------------------- -sub gen_net_boot_params +sub gen_net_boot_params { - my $class = shift; + my $class = shift; my $installnic = shift; my $primarynic = shift; - my $macmac = shift; + my $macmac = shift; my $nodebootif = shift; my $net_params; - + # arbitrary use primarynic if installnic is not set unless ($installnic) { - $installnic = $primarynic; + $installnic = $primarynic; } - + # just use the installnic to generate the nic related kernel parameters my $mac; my $nicname; @@ -2585,32 +2616,32 @@ sub gen_net_boot_params $nicname = $nodebootif; } - if ((! defined ($installnic)) || ($installnic eq "") || ($installnic =~ /^mac$/i)) { + if ((!defined($installnic)) || ($installnic eq "") || ($installnic =~ /^mac$/i)) { $mac = $macmac; $net_params->{mac} = $mac; } elsif ($installnic =~ /^[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}$/) { - $mac = $installnic; - $net_params->{mac} = $mac; + $mac = $installnic; + $net_params->{mac} = $mac; $net_params->{setmac} = $mac; } else { - $mac = $macmac; - $nicname = $installnic; + $mac = $macmac; + $nicname = $installnic; $net_params->{nicname} = $nicname; - $net_params->{mac} = $mac; + $net_params->{mac} = $mac; } # if nicname is set and mac.mac is NOT set to , use nicname in the boot parameters - if ($nicname && ! defined ($net_params->{setmac})) { - $net_params->{ksdevice} = "ksdevice=$nicname"; - $net_params->{ip} = "ip=$nicname:dhcp"; - $net_params->{netdev} = "netdev=$nicname"; + if ($nicname && !defined($net_params->{setmac})) { + $net_params->{ksdevice} = "ksdevice=$nicname"; + $net_params->{ip} = "ip=$nicname:dhcp"; + $net_params->{netdev} = "netdev=$nicname"; $net_params->{netdevice} = "netdevice=$nicname"; $net_params->{ifname} = "ifname=$nicname:$mac"; # todo: may not use mac arbitrary } elsif ($mac) { - $net_params->{ksdevice} = "ksdevice=$mac"; - $net_params->{BOOTIF} = "BOOTIF=$mac"; - $net_params->{bootdev} = "bootdev=$mac"; - $net_params->{ip} = "ip=dhcp"; + $net_params->{ksdevice} = "ksdevice=$mac"; + $net_params->{BOOTIF} = "BOOTIF=$mac"; + $net_params->{bootdev} = "bootdev=$mac"; + $net_params->{ip} = "ip=dhcp"; $net_params->{netdevice} = "netdevice=$mac"; } diff --git a/perl-xCAT/xCAT/NodeRange.pm b/perl-xCAT/xCAT/NodeRange.pm index 85f7bb9cf..e28bac035 100644 --- a/perl-xCAT/xCAT/NodeRange.pm +++ b/perl-xCAT/xCAT/NodeRange.pm @@ -6,20 +6,21 @@ require Exporter; use strict; #Perl implementation of noderange -our @ISA = qw(Exporter); -our @EXPORT = qw(noderange nodesmissed); +our @ISA = qw(Exporter); +our @EXPORT = qw(noderange nodesmissed); our @EXPORT_OK = qw(extnoderange abbreviate_noderange); -my $missingnodes=[]; -my $nodelist; #=xCAT::Table->new('nodelist',-create =>1); +my $missingnodes = []; +my $nodelist; #=xCAT::Table->new('nodelist',-create =>1); my $grptab; + #TODO: MEMLEAK note # I've moved grptab up here to avoid calling 'new' on it on every noderange # Something is wrong in the Table object such that it leaks # a few kilobytes of memory, even if nodelist member is not created # To reproduce the mem leak, move 'my $grptab' to the place where it is used # then call 'getAllNodesAttribs' a few thousand times on some table -# No one noticed before 2.3 because the lifetime of processes doing noderange +# No one noticed before 2.3 because the lifetime of processes doing noderange # expansion was short (seconds) # In 2.3, the problem has been 'solved' for most contexts in that the DB worker # reuses Table objects rather than ever destroying them @@ -28,7 +29,7 @@ my $grptab; # in this case, we change NodeRange to reuse the same Table object # even if not relying upon DB worker to figure it out for noderange # This may be a good idea anyway, regardless of memory leak -# It remains a good way to induce the memleak to correctly fix it +# It remains a good way to induce the memleak to correctly fix it # rather than hiding from the problem #my $nodeprefix = "node"; @@ -36,16 +37,17 @@ my @allnodeset; my %allnodehash; my @grplist; my $didgrouplist; -my $glstamp=0; -my $allnodesetstamp=0; -my $allgrphashstamp=0; +my $glstamp = 0; +my $allnodesetstamp = 0; +my $allgrphashstamp = 0; my %allgrphash; -my $retaincache=0; -my $recurselevel=0; +my $retaincache = 0; +my $recurselevel = 0; my @cachedcolumns; + #TODO: With a very large nodelist (i.e. 65k or so), deriving the members -# of a group is a little sluggish. We may want to put in a mechanism to +# of a group is a little sluggish. We may want to put in a mechanism to # maintain a two-way hash anytime nodelist or nodegroup changes, allowing # nodegroup table and nodelist to contain the same information about # group membership indexed in different ways to speed this up. @@ -54,131 +56,138 @@ my @cachedcolumns; # but many other operations would probably benefit greatly. sub subnodes (\@@) { + #Subtract set of nodes from the first list my $nodes = shift; my $node; foreach $node (@_) { - @$nodes = (grep(!/^$node$/,@$nodes)); + @$nodes = (grep(!/^$node$/, @$nodes)); } } + sub nodesmissed { - return @$missingnodes; + return @$missingnodes; } sub reset_db { -#workaround, something seems to be trying to use a corrupted reference to grptab -#this allows init_dbworker to reset the object - $grptab=0; -} -sub nodesbycriteria { - #TODO: this should be in a common place, shared by tabutils nodech/nodels and noderange - #there is a set of functions already, but the path is a little complicated and - #might be hooked into the objective usage style, which this function is not trying to match - #Return nodes by criteria. Can accept a list reference of criteria - #returns a hash reference of criteria expressions to nodes that meet - my $nodes = shift; #the set from which to match - my $critlist = shift; #list of criteria to match - my %tables; - my %shortnames = ( - groups => [qw(nodelist groups)], - tags => [qw(nodelist groups)], - mgt => [qw(nodehm mgt)], - #switch => [qw(switch switch)], - ); - unless (ref $critlist) { - $critlist = [ $critlist ]; - } - my $criteria; - my %critnodes; - my $value; - my $tabcol; - my $matchtype; - foreach $criteria (@$critlist) { - my $table; - my $column; - $tabcol=$criteria; - if ($criteria =~ /^[^=]*\!=/) { - ($criteria,$value) = split /!=/,$criteria,2; - $matchtype='natch'; - } elsif ($criteria =~ /^[^=]*=~/) { - ($criteria,$value) = split /=~/,$criteria,2; - $value =~ s/^\///; - $value =~ s/\/$//; - $matchtype='regex'; - } elsif ($criteria =~ /[^=]*==/) { - ($criteria,$value) = split /==/,$criteria,2; - $matchtype='match'; - } elsif ($criteria =~ /[^=]*=/) { - ($criteria,$value) = split /=/,$criteria,2; - $matchtype='match'; - } elsif ($criteria =~ /[^=]*!~/) { - ($criteria,$value) = split /!~/,$criteria,2; - $value =~ s/^\///; - $value =~ s/\/$//; - $matchtype='negex'; - } - if ($shortnames{$criteria}) { - ($table, $column) = @{$shortnames{$criteria}}; - } elsif ($criteria =~ /\./) { - ($table, $column) = split('\.', $criteria, 2); - } else { - return undef; - } - unless (grep /$column/,@{$xCAT::Schema::tabspec{$table}->{cols}}) { - return undef; - } - push @{$tables{$table}},[$column,$tabcol,$value,$matchtype]; #Mark this as something to get - } - my $tab; - foreach $tab (keys %tables) { - my $tabh = xCAT::Table->new($tab,-create=>0); - unless ($tabh) { next; } - my @cols; - foreach (@{$tables{$tab}}) { - push @cols, $_->[0]; + #workaround, something seems to be trying to use a corrupted reference to grptab + #this allows init_dbworker to reset the object + $grptab = 0; +} + +sub nodesbycriteria { + + #TODO: this should be in a common place, shared by tabutils nodech/nodels and noderange + #there is a set of functions already, but the path is a little complicated and + #might be hooked into the objective usage style, which this function is not trying to match + #Return nodes by criteria. Can accept a list reference of criteria + #returns a hash reference of criteria expressions to nodes that meet + my $nodes = shift; #the set from which to match + my $critlist = shift; #list of criteria to match + my %tables; + my %shortnames = ( + groups => [qw(nodelist groups)], + tags => [qw(nodelist groups)], + mgt => [qw(nodehm mgt)], + + #switch => [qw(switch switch)], + ); + + unless (ref $critlist) { + $critlist = [$critlist]; + } + my $criteria; + my %critnodes; + my $value; + my $tabcol; + my $matchtype; + foreach $criteria (@$critlist) { + my $table; + my $column; + $tabcol = $criteria; + if ($criteria =~ /^[^=]*\!=/) { + ($criteria, $value) = split /!=/, $criteria, 2; + $matchtype = 'natch'; + } elsif ($criteria =~ /^[^=]*=~/) { + ($criteria, $value) = split /=~/, $criteria, 2; + $value =~ s/^\///; + $value =~ s/\/$//; + $matchtype = 'regex'; + } elsif ($criteria =~ /[^=]*==/) { + ($criteria, $value) = split /==/, $criteria, 2; + $matchtype = 'match'; + } elsif ($criteria =~ /[^=]*=/) { + ($criteria, $value) = split /=/, $criteria, 2; + $matchtype = 'match'; + } elsif ($criteria =~ /[^=]*!~/) { + ($criteria, $value) = split /!~/, $criteria, 2; + $value =~ s/^\///; + $value =~ s/\/$//; + $matchtype = 'negex'; } - if ($tab eq "nodelist") { #fun caching interaction - my $neednewcache=0; - my $nlcol; - foreach $nlcol (@cols) { - unless (grep /^$nlcol\z/,@cachedcolumns) { - $neednewcache=1; - push @cachedcolumns,$nlcol; - } - } - if ($neednewcache) { - if ($nodelist) { - #$nodelist->_clear_cache(); - $nodelist->_build_cache(\@cachedcolumns); - } - } - } - my $rechash = $tabh->getNodesAttribs($nodes,\@cols); #TODO: if not defined nodes, getAllNodesAttribs may be faster actually... + if ($shortnames{$criteria}) { + ($table, $column) = @{ $shortnames{$criteria} }; + } elsif ($criteria =~ /\./) { + ($table, $column) = split('\.', $criteria, 2); + } else { + return undef; + } + unless (grep /$column/, @{ $xCAT::Schema::tabspec{$table}->{cols} }) { + return undef; + } + push @{ $tables{$table} }, [ $column, $tabcol, $value, $matchtype ]; #Mark this as something to get + } + my $tab; + foreach $tab (keys %tables) { + my $tabh = xCAT::Table->new($tab, -create => 0); + unless ($tabh) { next; } + my @cols; + foreach (@{ $tables{$tab} }) { + push @cols, $_->[0]; + } + if ($tab eq "nodelist") { #fun caching interaction + my $neednewcache = 0; + my $nlcol; + foreach $nlcol (@cols) { + unless (grep /^$nlcol\z/, @cachedcolumns) { + $neednewcache = 1; + push @cachedcolumns, $nlcol; + } + } + if ($neednewcache) { + if ($nodelist) { + + #$nodelist->_clear_cache(); + $nodelist->_build_cache(\@cachedcolumns); + } + } + } + my $rechash = $tabh->getNodesAttribs($nodes, \@cols); #TODO: if not defined nodes, getAllNodesAttribs may be faster actually... foreach my $node (@$nodes) { my $recs = $rechash->{$node}; my $critline; - foreach $critline (@{$tables{$tab}}) { + foreach $critline (@{ $tables{$tab} }) { foreach my $rec (@$recs) { - my $value=""; - if (defined $rec->{$critline->[0]}) { - $value = $rec->{$critline->[0]}; + my $value = ""; + if (defined $rec->{ $critline->[0] }) { + $value = $rec->{ $critline->[0] }; } my $compstring = $critline->[2]; if ($critline->[3] eq 'match' and $value eq $compstring) { - push @{$critnodes{$critline->[1]}},$node; + push @{ $critnodes{ $critline->[1] } }, $node; } elsif ($critline->[3] eq 'natch' and $value ne $compstring) { - push @{$critnodes{$critline->[1]}},$node; + push @{ $critnodes{ $critline->[1] } }, $node; } elsif ($critline->[3] eq 'regex' and $value =~ /$compstring/) { - push @{$critnodes{$critline->[1]}},$node; + push @{ $critnodes{ $critline->[1] } }, $node; } elsif ($critline->[3] eq 'negex' and $value !~ /$compstring/) { - push @{$critnodes{$critline->[1]}},$node; + push @{ $critnodes{ $critline->[1] } }, $node; } } } } - } - return \%critnodes; + } + return \%critnodes; } # Expand one part of the noderange from the noderange() function. Initially, one part means the @@ -189,53 +198,55 @@ sub nodesbycriteria { # - verify: whether or not to require that the resulting nodenames exist in the nodelist table # - options: genericrange - a purely syntactical expansion of the range, not using the db at all, e.g not expanding group names sub expandatom { - my $atom = shift; - if ($recurselevel > 4096) { die "NodeRange seems to be hung on evaluating $atom, recursion limit hit"; } - unless (scalar(@allnodeset) and (($allnodesetstamp+5) > time())) { #Build a cache of all nodes, some corner cases will perform worse, but by and large it will do better. We could do tests to see where the breaking points are, and predict how many atoms we have to evaluate to mitigate, for now, implement the strategy that keeps performance from going completely off the rails - $allnodesetstamp=time(); - $nodelist->_set_use_cache(1); - @allnodeset = $nodelist->getAllAttribs('node','groups'); + my $atom = shift; + if ($recurselevel > 4096) { die "NodeRange seems to be hung on evaluating $atom, recursion limit hit"; } + unless (scalar(@allnodeset) and (($allnodesetstamp + 5) > time())) { #Build a cache of all nodes, some corner cases will perform worse, but by and large it will do better. We could do tests to see where the breaking points are, and predict how many atoms we have to evaluate to mitigate, for now, implement the strategy that keeps performance from going completely off the rails + $allnodesetstamp = time(); + $nodelist->_set_use_cache(1); + @allnodeset = $nodelist->getAllAttribs('node', 'groups'); %allnodehash = map { $_->{node} => 1 } @allnodeset; - $nodelist->_set_use_cache(0); #The {_use_cache} for nodelist table object must be turn off, otherwise it will keep open and affect the Table.pm subroutines like getNodesAttribs when it tries to access nodelist table to get status column. + $nodelist->_set_use_cache(0); #The {_use_cache} for nodelist table object must be turn off, otherwise it will keep open and affect the Table.pm subroutines like getNodesAttribs when it tries to access nodelist table to get status column. } - my $verify = (scalar(@_) >= 1 ? shift : 1); - my %options = @_; # additional options - $options{keepmissing} = 1; - my @nodes= (); - #TODO: these env vars need to get passed by the client to xcatd - my $nprefix=(defined ($ENV{'XCAT_NODE_PREFIX'}) ? $ENV{'XCAT_NODE_PREFIX'} : 'node'); - my $nsuffix=(defined ($ENV{'XCAT_NODE_SUFFIX'}) ? $ENV{'XCAT_NODE_SUFFIX'} : ''); + my $verify = (scalar(@_) >= 1 ? shift : 1); + my %options = @_; # additional options + $options{keepmissing} = 1; + my @nodes = (); - if (not $options{genericrange} and $allnodehash{$atom}) { #The atom is a plain old nodename - return ($atom); - } - if ($atom =~ /^\(.*\)$/) { # handle parentheses by recursively calling noderange() - $atom =~ s/^\((.*)\)$/$1/; - $recurselevel++; - return noderange($atom,$verify,1,%options); + #TODO: these env vars need to get passed by the client to xcatd + my $nprefix = (defined($ENV{'XCAT_NODE_PREFIX'}) ? $ENV{'XCAT_NODE_PREFIX'} : 'node'); + my $nsuffix = (defined($ENV{'XCAT_NODE_SUFFIX'}) ? $ENV{'XCAT_NODE_SUFFIX'} : ''); + + if (not $options{genericrange} and $allnodehash{$atom}) { #The atom is a plain old nodename + return ($atom); + } + if ($atom =~ /^\(.*\)$/) { # handle parentheses by recursively calling noderange() + $atom =~ s/^\((.*)\)$/$1/; + $recurselevel++; + return noderange($atom, $verify, 1, %options); } if ($atom =~ /@/) { - $recurselevel++; - return noderange($atom,$verify,1,%options); - } + $recurselevel++; + return noderange($atom, $verify, 1, %options); + } # Try to match groups? unless ($options{genericrange}) { unless ($grptab) { - $grptab = xCAT::Table->new('nodegroup'); + $grptab = xCAT::Table->new('nodegroup'); } - if ($grptab and (($glstamp < (time()-5)) or (not $didgrouplist and not scalar @grplist))) { + if ($grptab and (($glstamp < (time() - 5)) or (not $didgrouplist and not scalar @grplist))) { $didgrouplist = 1; - $glstamp=time(); + $glstamp = time(); my $grplist_ptr = $grptab->getAllEntries(); if (!$grplist_ptr) { - return undef; + return undef; } @grplist = @{$grplist_ptr}; } my $isdynamicgrp = 0; foreach my $grpdef_ref (@grplist) { my %grpdef = %$grpdef_ref; + # Try to match a dynamic node group # do not try to match the static node group from nodegroup table, # the static node groups are stored in nodelist table. @@ -244,7 +255,7 @@ sub expandatom { $isdynamicgrp = 1; my $grpname = $atom; my %grphash; - $grphash{$grpname}{'objtype'} = 'group'; + $grphash{$grpname}{'objtype'} = 'group'; $grphash{$grpname}{'grouptype'} = 'dynamic'; $grphash{$grpname}{'wherevals'} = $grpdef{'wherevals'}; my $memberlist = xCAT::DBobjUtils->getGroupMembers($grpname, \%grphash); @@ -253,48 +264,49 @@ sub expandatom { push @nodes, $grpmember; } last; #there should not be more than one group with the same name - } - } - # The atom is not a dynamic node group, is it a static node group??? - if(!$isdynamicgrp) - { - unless (scalar %allgrphash and (time() < ($allgrphashstamp+5))) { #build a group membership cache - $allgrphashstamp=time(); - %allgrphash=(); + } + } + + # The atom is not a dynamic node group, is it a static node group??? + if (!$isdynamicgrp) + { + unless (scalar %allgrphash and (time() < ($allgrphashstamp + 5))) { #build a group membership cache + $allgrphashstamp = time(); + %allgrphash = (); my $nlent; - foreach $nlent (@allnodeset) { - my @groups=split(/,/,$nlent->{groups}); + foreach $nlent (@allnodeset) { + my @groups = split(/,/, $nlent->{groups}); my $grp; foreach $grp (@groups) { - push @{$allgrphash{$grp}},$nlent->{node}; + push @{ $allgrphash{$grp} }, $nlent->{node}; } } } - if ($allgrphash{$atom}) { - push @nodes,@{$allgrphash{$atom}}; - } - } - - # check to see if atom is a defined group name that didn't have any current members - if ( scalar @nodes == 0 ) { - if(scalar @grplist) { #Use previously constructed cache to avoid hitting DB worker so much - #my @grouplist = $grptab->getAllAttribs('groupname'); - for my $row ( @grplist ) { - if ( $row->{groupname} eq $atom ) { - return (); - } + if ($allgrphash{$atom}) { + push @nodes, @{ $allgrphash{$atom} }; + } } - } - } -} + + # check to see if atom is a defined group name that didn't have any current members + if (scalar @nodes == 0) { + if (scalar @grplist) { #Use previously constructed cache to avoid hitting DB worker so much + #my @grouplist = $grptab->getAllAttribs('groupname'); + for my $row (@grplist) { + if ($row->{groupname} eq $atom) { + return (); + } + } + } + } + } # node selection based on db attribute values (nodetype.os==rhels5.3) if ($atom =~ m/[=~]/) { #TODO: this is the clunky, slow code path to acheive the goal. It also is the easiest to write, strange coincidence. Aggregating multiples would be nice my @nodes; foreach (@allnodeset) { - push @nodes,$_->{node}; + push @nodes, $_->{node}; } - my $nbyc_ref = nodesbycriteria(\@nodes,[$atom]); + my $nbyc_ref = nodesbycriteria(\@nodes, [$atom]); if ($nbyc_ref) { my $nbyc = $nbyc_ref->{$atom}; @@ -304,214 +316,220 @@ sub expandatom { } return (); } - if ($atom =~ m/^[0-9]+\z/) { # if only numbers, then add the prefix - my $nodename=$nprefix.$atom.$nsuffix; - return expandatom($nodename,$verify,%options); - } - my $nodelen=@nodes; - if ($nodelen > 0) { - return @nodes; - } + if ($atom =~ m/^[0-9]+\z/) { # if only numbers, then add the prefix + my $nodename = $nprefix . $atom . $nsuffix; + return expandatom($nodename, $verify, %options); + } + my $nodelen = @nodes; + if ($nodelen > 0) { + return @nodes; + } - if ($atom =~ m/^\//) { # A regular expression - if ($verify==0 or $options{genericrange}) { # If not in verify mode, regex makes zero possible sense - return ($atom); - } - #TODO: check against all groups - $atom = substr($atom,1); - foreach (@allnodeset) { #$nodelist->getAllAttribs('node')) { - if ($_->{node} =~ m/^${atom}$/) { - push(@nodes,$_->{node}); - } - } - return(@nodes); - } - - if ($atom =~ m/(.+?)\[(.+?)\](.*)/) { # square bracket range - # if there is more than 1 set of [], we picked off just the 1st. If there more sets of [], we will expand - # the 1st set and create a new set of atom by concatenating each result in the 1st expandsion with the rest - # of the brackets. Then call expandatom() recursively on each new atom. - my @subelems = split(/([\,\-\:])/,$2); # $2 is the range inside the 1st set of brackets - my $subrange=""; - my $subelem; - my $start = $1; # the text before the 1st set of brackets - my $ending = $3; # the text after the 1st set of brackets (could contain more brackets) - my $morebrackets = $ending =~ /\[.+?\]/; # if there are more brackets, we have to expand just the 1st part, then add the 2nd part later - while (scalar @subelems) { # this while loop turns something like a[1-3] into a1-a3 because another section of expand atom knows how to expand that - my $subelem = shift @subelems; - my $subop=shift @subelems; - $subrange=$subrange."$start$subelem" . ($morebrackets?'':$ending) . "$subop"; - } - foreach (split /,/,$subrange) { # this foreach is in case there were commas inside the brackets originally, e.g.: a[1,3,5]b[1-2] - # this expandatom just expands the part of the noderange that contains the 1st set of brackets - # e.g. if noderange is a[1-2]b[1-2] it will create newnodes of a1 and a2 - my @newnodes=expandatom($_, ($morebrackets?0:$verify), genericrange=>($morebrackets||$options{genericrange})); - if (!$morebrackets) { push @nodes,@newnodes; } - else { - # for each of the new nodes (prefixes), add the rest of the brackets and then expand recursively - foreach my $n (@newnodes) { - push @nodes, expandatom("$n$ending", $verify, %options); - } - } - } - return @nodes; - } - - if ($atom =~ m/\+/) { # process the + operator - $atom =~ m/^(.*)([0-9]+)([^0-9\+]*)\+([0-9]+)/; - my ($front, $increment) = split(/\+/, $atom, 2); - my ($pref, $startnum, $dom) = $front =~ /^(.*?)(\d+)(\..+)?$/; - my $suf=$3; - my $end=$startnum+$increment; - my $endnum = sprintf("%d",$end); - if (length ($startnum) > length ($endnum)) { - $endnum = sprintf("%0".length($startnum)."d",$end); - } - if (($pref eq "") && ($suf eq "")) { - $pref=$nprefix; - $suf=$nsuffix; - } - foreach ("$startnum".."$endnum") { - my @addnodes=expandatom($pref.$_.$suf,$verify,%options); - @nodes=(@nodes,@addnodes); - } - return (@nodes); - } - - if ($atom =~ m/[-:]/) { # process the minus range operator - my $left; - my $right; - if ($atom =~ m/:/) { - ($left,$right)=split /:/,$atom; - } else { - my $count= ($atom =~ tr/-//); - if (($count % 2)==0) { #can't understand even numbers of - in range context - if ($verify) { - push @$missingnodes,$atom; - return (); - } else { #but we might not really be in range context, if noverify - return ($atom); - } - } - my $expr="([^-]+?".("-[^-]*"x($count/2)).")-(.*)"; - $atom =~ m/$expr/; - $left=$1; - $right=$2; - } - if ($left eq $right) { #if they said node1-node1 for some strange reason - return expandatom($left,$verify,%options); - } - my @leftarr=split(/(\d+)/,$left); - my @rightarr=split(/(\d+)/,$right); - if (scalar(@leftarr) != scalar(@rightarr)) { #Mismatch formatting.. - if ($verify) { - push @$missingnodes,$atom; - return (); #mismatched range, bail. - } else { #Not in verify mode, just have to guess it's meant to be a nodename - return ($atom); - } - } - my $prefix = ""; - my $suffix = ""; - foreach (0..$#leftarr) { - my $idx = $_; - if ($leftarr[$idx] =~ /^\d+$/ and $rightarr[$idx] =~ /^\d+$/) { #pure numeric component - if ($leftarr[$idx] ne $rightarr[$idx]) { #We have found the iterator (only supporting one for now) - my $prefix = join('',@leftarr[0..($idx-1)]); #Make a prefix of the pre-validated parts - my $luffix; #However, the remainder must still be validated to be the same - my $ruffix; - if ($idx eq $#leftarr) { - $luffix=""; - $ruffix=""; - } else { - $ruffix = join('',@rightarr[($idx+1)..$#rightarr]); - $luffix = join('',@leftarr[($idx+1)..$#leftarr]); - } - if ($luffix ne $ruffix) { #the suffixes mismatched.. - if ($verify) { - push @$missingnodes,$atom; - return (); - } else { - return ($atom); - } - } - foreach ($leftarr[$idx]..$rightarr[$idx]) { - my @addnodes=expandatom($prefix.$_.$luffix,$verify,%options); - push @nodes,@addnodes; - } - return (@nodes); #the return has been built, return, exiting loop and all - } - } elsif ($leftarr[$idx] ne $rightarr[$idx]) { - if ($verify) { - push @$missingnodes,$atom; - return (); - } else { + if ($atom =~ m/^\//) { # A regular expression + if ($verify == 0 or $options{genericrange}) { # If not in verify mode, regex makes zero possible sense return ($atom); - } } - $prefix .= $leftarr[$idx]; #If here, it means that the pieces were the same, but more to come - } - #I cannot conceive how the code could possibly be here, but whatever it is, it must be questionable - if ($verify) { - push @$missingnodes,$atom; - return (); #mismatched range, bail. - } else { #Not in verify mode, just have to guess it's meant to be a nodename - return ($atom); - } - } - if ($verify) { - push @$missingnodes,$atom; - return (); - } else { - return ($atom); - } -} + #TODO: check against all groups + $atom = substr($atom, 1); + foreach (@allnodeset) { #$nodelist->getAllAttribs('node')) { + if ($_->{node} =~ m/^${atom}$/) { + push(@nodes, $_->{node}); + } + } + return (@nodes); + } -sub retain_cache { #A semi private operation to be used *ONLY* in the interesting Table<->NodeRange module interactions. - $retaincache=shift; - unless ($retaincache) { #take a call to retain_cache(0) to also mean that any existing - #cache must be zapped - if ($nodelist) { $nodelist->_build_cache(1); } - $glstamp=0; - $allnodesetstamp=0; - $allgrphashstamp=0; - undef $nodelist; - @allnodeset=(); - %allnodehash=(); - @grplist=(); - $didgrouplist = 0; - %allgrphash=(); - } -} -sub extnoderange { #An extended noderange function. Needed by the GUI as the more straightforward function return format too simple for this. - my $range = shift; - my $namedopts = shift; - my $verify=1; - if ($namedopts->{skipnodeverify}) { - $verify=0; - } - my $return; - $retaincache=1; - $return->{node}=[noderange($range,$verify)]; - if ($namedopts->{intersectinggroups}) { - my %grouphash=(); - my $nlent; - foreach (@{$return->{node}}) { - $nlent=$nodelist->getNodeAttribs($_,['groups']); #TODO: move to noderange side cache - if ($nlent and $nlent->{groups}) { - foreach (split /,/,$nlent->{groups}) { - $grouphash{$_}=1; + if ($atom =~ m/(.+?)\[(.+?)\](.*)/) { # square bracket range + # if there is more than 1 set of [], we picked off just the 1st. If there more sets of [], we will expand + # the 1st set and create a new set of atom by concatenating each result in the 1st expandsion with the rest + # of the brackets. Then call expandatom() recursively on each new atom. + my @subelems = split(/([\,\-\:])/, $2); # $2 is the range inside the 1st set of brackets + my $subrange = ""; + my $subelem; + my $start = $1; # the text before the 1st set of brackets + my $ending = $3; # the text after the 1st set of brackets (could contain more brackets) + my $morebrackets = $ending =~ /\[.+?\]/; # if there are more brackets, we have to expand just the 1st part, then add the 2nd part later + + while (scalar @subelems) { # this while loop turns something like a[1-3] into a1-a3 because another section of expand atom knows how to expand that + my $subelem = shift @subelems; + my $subop = shift @subelems; + $subrange = $subrange . "$start$subelem" . ($morebrackets ? '' : $ending) . "$subop"; + } + foreach (split /,/, $subrange) { # this foreach is in case there were commas inside the brackets originally, e.g.: a[1,3,5]b[1-2] + # this expandatom just expands the part of the noderange that contains the 1st set of brackets + # e.g. if noderange is a[1-2]b[1-2] it will create newnodes of a1 and a2 + my @newnodes = expandatom($_, ($morebrackets ? 0 : $verify), genericrange => ($morebrackets || $options{genericrange})); + if (!$morebrackets) { push @nodes, @newnodes; } + else { + # for each of the new nodes (prefixes), add the rest of the brackets and then expand recursively + foreach my $n (@newnodes) { + push @nodes, expandatom("$n$ending", $verify, %options); } } } - $return->{intersectinggroups}=[sort keys %grouphash]; + return @nodes; + } + + if ($atom =~ m/\+/) { # process the + operator + $atom =~ m/^(.*)([0-9]+)([^0-9\+]*)\+([0-9]+)/; + my ($front, $increment) = split(/\+/, $atom, 2); + my ($pref, $startnum, $dom) = $front =~ /^(.*?)(\d+)(\..+)?$/; + my $suf = $3; + my $end = $startnum + $increment; + my $endnum = sprintf("%d", $end); + if (length($startnum) > length($endnum)) { + $endnum = sprintf("%0" . length($startnum) . "d", $end); + } + if (($pref eq "") && ($suf eq "")) { + $pref = $nprefix; + $suf = $nsuffix; + } + foreach ("$startnum" .. "$endnum") { + my @addnodes = expandatom($pref . $_ . $suf, $verify, %options); + @nodes = (@nodes, @addnodes); + } + return (@nodes); + } + + if ($atom =~ m/[-:]/) { # process the minus range operator + my $left; + my $right; + if ($atom =~ m/:/) { + ($left, $right) = split /:/, $atom; + } else { + my $count = ($atom =~ tr/-//); + if (($count % 2) == 0) { #can't understand even numbers of - in range context + if ($verify) { + push @$missingnodes, $atom; + return (); + } else { #but we might not really be in range context, if noverify + return ($atom); + } + } + my $expr = "([^-]+?" . ("-[^-]*" x ($count / 2)) . ")-(.*)"; + $atom =~ m/$expr/; + $left = $1; + $right = $2; + } + if ($left eq $right) { #if they said node1-node1 for some strange reason + return expandatom($left, $verify, %options); + } + my @leftarr = split(/(\d+)/, $left); + my @rightarr = split(/(\d+)/, $right); + if (scalar(@leftarr) != scalar(@rightarr)) { #Mismatch formatting.. + if ($verify) { + push @$missingnodes, $atom; + return (); #mismatched range, bail. + } else { #Not in verify mode, just have to guess it's meant to be a nodename + return ($atom); + } + } + my $prefix = ""; + my $suffix = ""; + foreach (0 .. $#leftarr) { + my $idx = $_; + if ($leftarr[$idx] =~ /^\d+$/ and $rightarr[$idx] =~ /^\d+$/) { #pure numeric component + if ($leftarr[$idx] ne $rightarr[$idx]) { #We have found the iterator (only supporting one for now) + my $prefix = join('', @leftarr[ 0 .. ($idx - 1) ]); #Make a prefix of the pre-validated parts + my $luffix; #However, the remainder must still be validated to be the same + my $ruffix; + if ($idx eq $#leftarr) { + $luffix = ""; + $ruffix = ""; + } else { + $ruffix = join('', @rightarr[ ($idx + 1) .. $#rightarr ]); + $luffix = join('', @leftarr[ ($idx + 1) .. $#leftarr ]); + } + if ($luffix ne $ruffix) { #the suffixes mismatched.. + if ($verify) { + push @$missingnodes, $atom; + return (); + } else { + return ($atom); + } + } + foreach ($leftarr[$idx] .. $rightarr[$idx]) { + my @addnodes = expandatom($prefix . $_ . $luffix, $verify, %options); + push @nodes, @addnodes; + } + return (@nodes); #the return has been built, return, exiting loop and all + } + } elsif ($leftarr[$idx] ne $rightarr[$idx]) { + if ($verify) { + push @$missingnodes, $atom; + return (); + } else { + return ($atom); + } + } + $prefix .= $leftarr[$idx]; #If here, it means that the pieces were the same, but more to come + } + + #I cannot conceive how the code could possibly be here, but whatever it is, it must be questionable + if ($verify) { + push @$missingnodes, $atom; + return (); #mismatched range, bail. + } else { #Not in verify mode, just have to guess it's meant to be a nodename + return ($atom); + } + } + + if ($verify) { + push @$missingnodes, $atom; + return (); + } else { + return ($atom); + } +} + +sub retain_cache { #A semi private operation to be used *ONLY* in the interesting Table<->NodeRange module interactions. + $retaincache = shift; + unless ($retaincache) { #take a call to retain_cache(0) to also mean that any existing + #cache must be zapped + if ($nodelist) { $nodelist->_build_cache(1); } + $glstamp = 0; + $allnodesetstamp = 0; + $allgrphashstamp = 0; + undef $nodelist; + @allnodeset = (); + %allnodehash = (); + @grplist = (); + $didgrouplist = 0; + %allgrphash = (); + } +} + +sub extnoderange { #An extended noderange function. Needed by the GUI as the more straightforward function return format too simple for this. + my $range = shift; + my $namedopts = shift; + my $verify = 1; + if ($namedopts->{skipnodeverify}) { + $verify = 0; + } + my $return; + $retaincache = 1; + $return->{node} = [ noderange($range, $verify) ]; + if ($namedopts->{intersectinggroups}) { + my %grouphash = (); + my $nlent; + foreach (@{ $return->{node} }) { + $nlent = $nodelist->getNodeAttribs($_, ['groups']); #TODO: move to noderange side cache + if ($nlent and $nlent->{groups}) { + foreach (split /,/, $nlent->{groups}) { + $grouphash{$_} = 1; + } + } + } + $return->{intersectinggroups} = [ sort keys %grouphash ]; } return $return; } -sub abbreviate_noderange { + +sub abbreviate_noderange { + #takes a list of nodes or a string and reduces it by replacing a list of nodes that make up a group with the group name itself - my $nodes=shift; + my $nodes = shift; my %grouphash; my %sizedgroups; my %nodesleft; @@ -520,62 +538,66 @@ sub abbreviate_noderange { $nodes = noderange($nodes); } %nodesleft = map { $_ => 1 } @{$nodes}; - unless ($nodelist) { - $nodelist =xCAT::Table->new('nodelist',-create =>1); + unless ($nodelist) { + $nodelist = xCAT::Table->new('nodelist', -create => 1); } my $group; - foreach($nodelist->getAllAttribs('node','groups')) { - my @groups=split(/,/,$_->{groups}); #The where clause doesn't guarantee the atom is a full group name, only that it could be + foreach ($nodelist->getAllAttribs('node', 'groups')) { + my @groups = split(/,/, $_->{groups}); #The where clause doesn't guarantee the atom is a full group name, only that it could be foreach $group (@groups) { - push @{$grouphash{$group}},$_->{node}; + push @{ $grouphash{$group} }, $_->{node}; } } foreach $group (keys %grouphash) { + #skip single node sized groups, these outliers frequently pasted into non-noderange capable contexts - if (scalar @{$grouphash{$group}} < 2) { next; } - push @{$sizedgroups{scalar @{$grouphash{$group}}}},$group; + if (scalar @{ $grouphash{$group} } < 2) { next; } + push @{ $sizedgroups{ scalar @{ $grouphash{$group} } } }, $group; } my $node; + #use Data::Dumper; #print Dumper(\%sizedgroups); - foreach (reverse sort {$a <=> $b} keys %sizedgroups) { - GROUP: foreach $group (@{$sizedgroups{$_}}) { - foreach $node (@{$grouphash{$group}}) { - unless (grep $node eq $_,keys %nodesleft) { + foreach (reverse sort { $a <=> $b } keys %sizedgroups) { + GROUP: foreach $group (@{ $sizedgroups{$_} }) { + foreach $node (@{ $grouphash{$group} }) { + unless (grep $node eq $_, keys %nodesleft) { + #this group contains a node that isn't left, skip it - next GROUP; - } + next GROUP; } - foreach $node (@{$grouphash{$group}}){ - delete $nodesleft{$node}; - } - $targetelems{$group}=1; + } + foreach $node (@{ $grouphash{$group} }) { + delete $nodesleft{$node}; + } + $targetelems{$group} = 1; } } - return (join ',',keys %targetelems,keys %nodesleft); + return (join ',', keys %targetelems, keys %nodesleft); } sub set_arith { my $operand = shift; - my $op = shift; - my $newset = shift; - if ($op =~ /@/) { # compute the intersection of the current atom and the node list we have received before this - foreach (keys %$operand) { - unless ($newset->{$_}) { - delete $operand->{$_}; + my $op = shift; + my $newset = shift; + if ($op =~ /@/) { # compute the intersection of the current atom and the node list we have received before this + foreach (keys %$operand) { + unless ($newset->{$_}) { + delete $operand->{$_}; + } } - } - } elsif ($op =~ /,-/) { # add the nodes from this atom to the exclude list - foreach (keys %$newset) { + } elsif ($op =~ /,-/) { # add the nodes from this atom to the exclude list + foreach (keys %$newset) { delete $operand->{$_} - } - } else { # add the nodes from this atom to the total node list - foreach (keys %$newset) { - $operand->{$_}=1; - } - } + } + } else { # add the nodes from this atom to the total node list + foreach (keys %$newset) { + $operand->{$_} = 1; + } + } } + # Expand the given noderange # Input args: # - noderange to expand @@ -583,102 +605,103 @@ sub set_arith { # - exsitenode: whether or not to honor site.excludenodes to automatically exclude those nodes from all noderanges # - options: genericrange - a purely syntactical expansion of the range, not using the db at all, e.g not expanding group names sub noderange { - #We for now just do left to right operations - my $range=shift; - $range =~ s/['"]//g; - my $verify = (scalar(@_) >= 1 ? shift : 1); - my $exsitenode = (scalar(@_) >= 1 ? shift : 1); # if 1, honor site.excludenodes - my %options = @_; # additional options - unless ($options{keepmissing}) { - $missingnodes=[]; - } - unless ($nodelist) { - $nodelist =xCAT::Table->new('nodelist',-create =>1); - $nodelist->_set_use_cache(0); #TODO: a more proper external solution - @cachedcolumns = ('node','groups'); - $nodelist->_build_cache(\@cachedcolumns,noincrementref=>1); - $nodelist->_set_use_cache(1); #TODO: a more proper external solution - } - my %nodes = (); - my %delnodes = (); - if ($range =~ /\(/) { - my ($middle, $end, $start) = - extract_bracketed($range, '()', qr/[^()]*/); - unless ($middle) { die "Unbalanced parentheses in noderange" } - $middle = substr($middle,1,-1); + #We for now just do left to right operations + my $range = shift; + $range =~ s/['"]//g; + my $verify = (scalar(@_) >= 1 ? shift : 1); + my $exsitenode = (scalar(@_) >= 1 ? shift : 1); # if 1, honor site.excludenodes + my %options = @_; # additional options + unless ($options{keepmissing}) { + $missingnodes = []; + } + + unless ($nodelist) { + $nodelist = xCAT::Table->new('nodelist', -create => 1); + $nodelist->_set_use_cache(0); #TODO: a more proper external solution + @cachedcolumns = ('node', 'groups'); + $nodelist->_build_cache(\@cachedcolumns, noincrementref => 1); + $nodelist->_set_use_cache(1); #TODO: a more proper external solution + } + my %nodes = (); + my %delnodes = (); + if ($range =~ /\(/) { + my ($middle, $end, $start) = + extract_bracketed($range, '()', qr/[^()]*/); + unless ($middle) { die "Unbalanced parentheses in noderange" } + $middle = substr($middle, 1, -1); + my $op = ","; + if ($start =~ m/-$/) { #subtract the parenthetical + $op .= "-" + } elsif ($start =~ m/\@$/) { + $op = "@" + } + $start =~ s/,-$//; + $start =~ s/,$//; + $start =~ s/\@$//; + %nodes = map { $_ => 1 } noderange($start, $verify, $exsitenode, %options, keepmissing => 1); + my %innernodes = map { $_ => 1 } noderange($middle, $verify, $exsitenode, %options, keepmissing => 1); + set_arith(\%nodes, $op, \%innernodes); + $range = $end; + } + my $op = ","; - if ($start =~ m/-$/) { #subtract the parenthetical - $op .= "-" - } elsif ($start =~ m/\@$/) { - $op = "@" + my @elems = split(/(,(?![^[]*?])(?![^\(]*?\)))/, $range); # commas outside of [] or () + if (scalar(@elems) == 1) { + @elems = split(/(@(?![^\(]*?\)))/, $range); # only split on @ when no , are present (inner recursion) } - $start =~ s/,-$//; - $start =~ s/,$//; - $start =~ s/\@$//; - %nodes = map { $_ => 1 } noderange($start,$verify,$exsitenode,%options,keepmissing=>1); - my %innernodes = map { $_ => 1 } noderange($middle,$verify,$exsitenode,%options,keepmissing=>1); - set_arith(\%nodes,$op,\%innernodes); - $range = $end; - } - my $op = ","; - my @elems = split(/(,(?![^[]*?])(?![^\(]*?\)))/,$range); # commas outside of [] or () - if (scalar(@elems)==1) { - @elems = split(/(@(?![^\(]*?\)))/,$range); # only split on @ when no , are present (inner recursion) - } - - while (defined(my $atom = shift @elems)) { - if ($atom eq '') { next; } - if ($atom eq ',') { - next; - } - if ($atom =~ /^-/) { # if this is an exclusion, strip off the minus, but remember it - $atom = substr($atom,1); - $op = $op."-"; - } elsif ($atom =~ /^\@/) { # if this is an exclusion, strip off the minus, but remember it - $atom = substr($atom,1); - $op = "@"; - } - if ($atom eq '') { next; } - - if ($atom =~ /^\^(.*)$/) { # get a list of nodes from a file - open(NRF,$1); - while () { - my $line=$_; - unless ($line =~ m/^[\^#]/) { - $line =~ m/^([^: ]*)/; - my $newrange = $1; - chomp($newrange); - $recurselevel++; - my @filenodes = noderange($newrange,$verify,$exsitenode,%options); - foreach (@filenodes) { - $nodes{$_}=1; - } + while (defined(my $atom = shift @elems)) { + if ($atom eq '') { next; } + if ($atom eq ',') { + next; } - } - close(NRF); - next; - } - - my %newset = map { $_ =>1 } expandatom($atom,$verify,%options); # expand the atom and make each entry in the resulting array a key in newset - - if ($op =~ /@/) { # compute the intersection of the current atom and the node list we have received before this - foreach (keys %nodes) { - unless ($newset{$_}) { - delete $nodes{$_}; + if ($atom =~ /^-/) { # if this is an exclusion, strip off the minus, but remember it + $atom = substr($atom, 1); + $op = $op . "-"; + } elsif ($atom =~ /^\@/) { # if this is an exclusion, strip off the minus, but remember it + $atom = substr($atom, 1); + $op = "@"; } - } - } elsif ($op =~ /,-/) { # add the nodes from this atom to the exclude list - foreach (keys %newset) { - $delnodes{$_}=1; #delay removal to end - } - } else { # add the nodes from this atom to the total node list - foreach (keys %newset) { - $nodes{$_}=1; - } - } - $op = shift @elems; + if ($atom eq '') { next; } + + if ($atom =~ /^\^(.*)$/) { # get a list of nodes from a file + open(NRF, $1); + while () { + my $line = $_; + unless ($line =~ m/^[\^#]/) { + $line =~ m/^([^: ]*)/; + my $newrange = $1; + chomp($newrange); + $recurselevel++; + my @filenodes = noderange($newrange, $verify, $exsitenode, %options); + foreach (@filenodes) { + $nodes{$_} = 1; + } + } + } + close(NRF); + next; + } + + my %newset = map { $_ => 1 } expandatom($atom, $verify, %options); # expand the atom and make each entry in the resulting array a key in newset + + if ($op =~ /@/) { # compute the intersection of the current atom and the node list we have received before this + foreach (keys %nodes) { + unless ($newset{$_}) { + delete $nodes{$_}; + } + } + } elsif ($op =~ /,-/) { # add the nodes from this atom to the exclude list + foreach (keys %newset) { + $delnodes{$_} = 1; #delay removal to end + } + } else { # add the nodes from this atom to the total node list + foreach (keys %newset) { + $nodes{$_} = 1; + } + } + $op = shift @elems; } # end of main while loop @@ -686,22 +709,22 @@ sub noderange { # Exclude the nodes in site attribute excludenodes? if ($exsitenode) { my $badnoderange = 0; - my @badnodes = (); - if ($::XCATSITEVALS{excludenodes}) { - @badnodes = noderange($::XCATSITEVALS{excludenodes}, 1, 0, %options); - foreach my $bnode (@badnodes) { - if (!$delnodes{$bnode}) { - $delnodes{$bnode} = 1; - } - } + my @badnodes = (); + if ($::XCATSITEVALS{excludenodes}) { + @badnodes = noderange($::XCATSITEVALS{excludenodes}, 1, 0, %options); + foreach my $bnode (@badnodes) { + if (!$delnodes{$bnode}) { + $delnodes{$bnode} = 1; + } + } } } # Now remove all the exclusion nodes foreach (keys %nodes) { - if ($delnodes{$_}) { - delete $nodes{$_}; - } + if ($delnodes{$_}) { + delete $nodes{$_}; + } } if ($recurselevel) { $recurselevel--; diff --git a/perl-xCAT/xCAT/NotifHandler.pm b/perl-xCAT/xCAT/NotifHandler.pm index c70b73942..44ffa80e2 100644 --- a/perl-xCAT/xCAT/NotifHandler.pm +++ b/perl-xCAT/xCAT/NotifHandler.pm @@ -1,6 +1,7 @@ #!/usr/bin/env perl # IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html package xCAT::NotifHandler; + BEGIN { $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; @@ -25,15 +26,18 @@ my $dbworkerid; 1; #------------------------------------------------------------------------------- + =head1 xCATi::NotifHandler =head2 Package Description This mondule caches the notification table and tracks the changes of it. It also handles the event notification when xCAT database changes. =cut + #------------------------------------------------------------------------------- #-------------------------------------------------------------------------------- + =head3 setup It is called by xcatd to get set the pid of the parent of all this object. Setup the signal to trap any changes in the notification table. It also @@ -45,21 +49,23 @@ my $dbworkerid; Returns: none =cut + #------------------------------------------------------------------------------- sub setup { - $masterpid=shift; - if ($masterpid =~ /xCAT::NotifHandler/) { - $masterpid=shift; - } - $dbworkerid=shift; + $masterpid = shift; + if ($masterpid =~ /xCAT::NotifHandler/) { + $masterpid = shift; + } + $dbworkerid = shift; - refreshNotification(); + refreshNotification(); - $SIG{USR1}=\&handleNotifSignal; + $SIG{USR1} = \&handleNotifSignal; } #-------------------------------------------------------------------------------- + =head3 handleNotifSignal It is called when the signal is received. It then update the cache with the latest data in the notification table. @@ -68,14 +74,17 @@ sub setup Returns: none =cut + #------------------------------------------------------------------------------- sub handleNotifSignal { - #print "handleNotifSignal pid=$$\n"; - refreshNotification(); - $SIG{USR1}=\&handleNotifSignal; + + #print "handleNotifSignal pid=$$\n"; + refreshNotification(); + $SIG{USR1} = \&handleNotifSignal; } #-------------------------------------------------------------------------------- + =head3 sendNotifSignal It is called by any module that has made changes to the notification table. Arguments: @@ -83,18 +92,20 @@ sub handleNotifSignal { Returns: none =cut + #------------------------------------------------------------------------------- sub sendNotifSignal { - if ($masterpid) { - kill('USR1', $masterpid); - } - if ($dbworkerid) { - kill('USR1', $dbworkerid); - } + if ($masterpid) { + kill('USR1', $masterpid); + } + if ($dbworkerid) { + kill('USR1', $dbworkerid); + } } #-------------------------------------------------------------------------------- + =head3 refreshNotification It loads the notification info from the "notification" table and store it into %notif variable. @@ -105,77 +116,81 @@ sub sendNotifSignal { Returns: none =cut + #------------------------------------------------------------------------------- sub refreshNotification { - #print "refreshNotification get called\n"; - #flush the cache - %notif=(); - my $table=xCAT::Table->new("notification", -create =>0); - if ($table) { - #get array of rows out of the notification table - my @row_array= $table->getTable; - if (@row_array) { - #store the information to the cache - foreach(@row_array) { - my $module=$_->{filename}; - my $ops=$_->{tableops}; - my $disable= $_->{disable}; - my @tablenames=split(/,/, $_->{tables}); + #print "refreshNotification get called\n"; + #flush the cache + %notif = (); + my $table = xCAT::Table->new("notification", -create => 0); + if ($table) { - foreach(@tablenames) { - if (!exists($notif{$_})) { - $notif{$_}={}; - } + #get array of rows out of the notification table + my @row_array = $table->getTable; + if (@row_array) { + + #store the information to the cache + foreach (@row_array) { + my $module = $_->{filename}; + my $ops = $_->{tableops}; + my $disable = $_->{disable}; + my @tablenames = split(/,/, $_->{tables}); + + foreach (@tablenames) { + if (!exists($notif{$_})) { + $notif{$_} = {}; + } - my $tempdisable=0; - if ($disable) { - if ($disable =~ m/^(yes|YES|Yes|Y|y|1)$/) { - $tempdisable=1; - } - } + my $tempdisable = 0; + if ($disable) { + if ($disable =~ m/^(yes|YES|Yes|Y|y|1)$/) { + $tempdisable = 1; + } + } - if (!$disable) { - if ($ops) { - if ($ops =~ m/a/) { - if (exists($notif{$_}->{a})) { - my $pa=$notif{$_}->{a}; - push(@$pa, $module); - } else { - $notif{$_}->{a}=[$module]; - } - } - if ($ops =~ m/d/) { - if (exists($notif{$_}->{d})) { - my $pa=$notif{$_}->{d}; - push(@$pa, $module); - } else { - $notif{$_}->{d}=[$module]; - } - } - if ($ops =~ m/u/) { - if (exists($notif{$_}->{u})) { - my $pa=$notif{$_}->{u}; - push(@$pa, $module); - } else { - $notif{$_}->{u}=[$module]; - } - } - } #end if - } - } #end foreach + if (!$disable) { + if ($ops) { + if ($ops =~ m/a/) { + if (exists($notif{$_}->{a})) { + my $pa = $notif{$_}->{a}; + push(@$pa, $module); + } else { + $notif{$_}->{a} = [$module]; + } + } + if ($ops =~ m/d/) { + if (exists($notif{$_}->{d})) { + my $pa = $notif{$_}->{d}; + push(@$pa, $module); + } else { + $notif{$_}->{d} = [$module]; + } + } + if ($ops =~ m/u/) { + if (exists($notif{$_}->{u})) { + my $pa = $notif{$_}->{u}; + push(@$pa, $module); + } else { + $notif{$_}->{u} = [$module]; + } + } + } #end if + } + } #end foreach - } #end foreach(@row_array) - }#end if (@row_array) - } #end if ($table) + } #end foreach(@row_array) + } #end if (@row_array) + } #end if ($table) - #print Dumper(%notif); - return 1; + #print Dumper(%notif); + return 1; } #-------------------------------------------------------------------------------- + =head3 dumpNotificationCache It print out the content of the notification cache for debugging purpose. Arguments: @@ -183,34 +198,36 @@ sub refreshNotification Returns: 0 =cut + #------------------------------------------------------------------------------- sub dumpNotificationCache { - print "dump the notification cache:\n"; - foreach(keys(%notif)) { - my $tmptn=$_; - print " $tmptn: \n"; + print "dump the notification cache:\n"; + foreach (keys(%notif)) { + my $tmptn = $_; + print " $tmptn: \n"; - if (exists($notif{$_}->{a})) { - print " a--:"; - my $files=$notif{$_}->{a}; - print "@$files\n"; + if (exists($notif{$_}->{a})) { + print " a--:"; + my $files = $notif{$_}->{a}; + print "@$files\n"; + } + if (exists($notif{$_}->{u})) { + print " u--:"; + my $files = $notif{$_}->{u}; + print "@$files\n"; + } + if (exists($notif{$_}->{d})) { + print " d--:"; + my $files = $notif{$_}->{d}; + print "@$files\n"; + } } - if (exists($notif{$_}->{u})) { - print " u--:"; - my $files=$notif{$_}->{u}; - print "@$files\n"; - } - if (exists($notif{$_}->{d})) { - print " d--:"; - my $files=$notif{$_}->{d}; - print "@$files\n"; - } - } - return 0; + return 0; } #-------------------------------------------------------------------------------- + =head3 needToNotify It check if the given table has interested parties watching for its changes. Arguments: @@ -221,34 +238,37 @@ sub dumpNotificationCache { 1 - if the table has interested parties. 0 - if no parties are interested in its changes. =cut + #------------------------------------------------------------------------------- sub needToNotify { - #print "needToNotify pid=$$, notify=" . Dumper(%notif) . "\n"; + #print "needToNotify pid=$$, notify=" . Dumper(%notif) . "\n"; - if (!%notif) { - # print "notif not defined\n"; - refreshNotification(); - } + if (!%notif) { - my $tablename=shift; - if ($tablename =~ /xCAT::NotifHandler/) { - $tablename=shift; - } - my $tableop=shift; - - if (%notif) { - if (exists($notif{$tablename})) { - if (exists($notif{$tablename}->{$tableop})) { - return 1; - } + # print "notif not defined\n"; + refreshNotification(); } - } - return 0; + + my $tablename = shift; + if ($tablename =~ /xCAT::NotifHandler/) { + $tablename = shift; + } + my $tableop = shift; + + if (%notif) { + if (exists($notif{$tablename})) { + if (exists($notif{$tablename}->{$tableop})) { + return 1; + } + } + } + return 0; } #-------------------------------------------------------------------------------- + =head3 notify It notifies the registered the modules with the latest changes in a DB table. @@ -284,79 +304,83 @@ sub needToNotify { ... =cut + #------------------------------------------------------------------------------- sub notify { - my $action=shift; - if ($action =~ /xCAT::NotifHandler/) { - $action=shift; - } - my $tablename=shift; - my $old_data=shift; - my $new_data=shift; - - # print "notify called: tablename=$tablename, action=$action\n"; - - my @filenames=(); - if (%notif) { - if (exists($notif{$tablename})) { - if (exists($notif{$tablename}->{$action})) { - my $pa=$notif{$tablename}->{$action}; - @filenames=@$pa; - } + my $action = shift; + if ($action =~ /xCAT::NotifHandler/) { + $action = shift; } - } + my $tablename = shift; + my $old_data = shift; + my $new_data = shift; + # print "notify called: tablename=$tablename, action=$action\n"; - foreach(@filenames) { - my ($modname, $path, $suffix) = fileparse($_, ".pm"); - # print "modname=$modname, path=$path, suffix=$suffix\n"; - if ($suffix =~ /.pm/) { #it is a perl module - my $fname; - if (($path eq "") || ($path eq ".\/")) { - #default path is /opt/xcat/lib/perl/xCAT_monitoring/ if there is no path specified - $fname = "$::XCATROOT/lib/perl/xCAT_monitoring/".$modname.".pm"; - } else { - $fname = $_; + my @filenames = (); + if (%notif) { + if (exists($notif{$tablename})) { + if (exists($notif{$tablename}->{$action})) { + my $pa = $notif{$tablename}->{$action}; + @filenames = @$pa; + } } - eval {require($fname)}; - if ($@) { - print "The file $fname cannot be located or has compiling errors.\n"; - } - else { - ${"xCAT_monitoring::".$modname."::"}{processTableChanges}->($action, $tablename, $old_data, $new_data); - } - return 0; } - else { #it is a command - my $pid; - if ($pid=xCAT::Utils->xfork()) { } - elsif (defined($pid)) { - # print "command=$_\n"; - if (open(CMD, "|$_")) { - print(CMD "$action\n"); - print(CMD "$tablename\n"); - print(CMD "[old data]\n"); - foreach (@$old_data) { - print(CMD join(',', @$_)."\n"); - } - print(CMD "[new data]\n"); - if (%$new_data) { - print(CMD join(',', keys %$new_data) . "\n"); - print(CMD join(',', values %$new_data) . "\n"); - } - close(CMD) or print "Cannot close the command $_\n"; + foreach (@filenames) { + my ($modname, $path, $suffix) = fileparse($_, ".pm"); + + # print "modname=$modname, path=$path, suffix=$suffix\n"; + if ($suffix =~ /.pm/) { #it is a perl module + my $fname; + if (($path eq "") || ($path eq ".\/")) { + + #default path is /opt/xcat/lib/perl/xCAT_monitoring/ if there is no path specified + $fname = "$::XCATROOT/lib/perl/xCAT_monitoring/" . $modname . ".pm"; + } else { + $fname = $_; + } + eval { require($fname) }; + if ($@) { + print "The file $fname cannot be located or has compiling errors.\n"; + } + else { + ${ "xCAT_monitoring::" . $modname . "::" }{processTableChanges}->($action, $tablename, $old_data, $new_data); + } + return 0; } - else { - print "Command $_ cannot be found\n"; + else { #it is a command + my $pid; + if ($pid = xCAT::Utils->xfork()) { } + elsif (defined($pid)) { + + # print "command=$_\n"; + if (open(CMD, "|$_")) { + print(CMD "$action\n"); + print(CMD "$tablename\n"); + + print(CMD "[old data]\n"); + foreach (@$old_data) { + print(CMD join(',', @$_) . "\n"); + } + + print(CMD "[new data]\n"); + if (%$new_data) { + print(CMD join(',', keys %$new_data) . "\n"); + print(CMD join(',', values %$new_data) . "\n"); + } + close(CMD) or print "Cannot close the command $_\n"; + } + else { + print "Command $_ cannot be found\n"; + } + + exit 0; + } #elsif } + } #foreach - exit 0; - } #elsif - } - } #foreach - - return 0; + return 0; } diff --git a/perl-xCAT/xCAT/PPCboot.pm b/perl-xCAT/xCAT/PPCboot.pm index 1c58f559e..c29da6816 100644 --- a/perl-xCAT/xCAT/PPCboot.pm +++ b/perl-xCAT/xCAT/PPCboot.pm @@ -13,7 +13,7 @@ use xCAT::MsgUtils; use xCAT::LparNetbootExp; ########################################################################## -# Parse the command line for options and operands +# Parse the command line for options and operands ########################################################################## sub parse_args { @@ -27,56 +27,56 @@ sub parse_args { ############################################# local *usage = sub { my $usage_string = xCAT::Usage->getUsage($cmd); - return( [ $_[0], $usage_string] ); + return ([ $_[0], $usage_string ]); }; ############################################# # Process command-line arguments ############################################# - if ( !defined( $args )) { + if (!defined($args)) { $request->{method} = $cmd; - return( \%opt ); + return (\%opt); } ############################################# # Checks case in GetOptions, allows opts # to be grouped (e.g. -vx), and terminates # at the first unrecognized option. ############################################# - @ARGV = @$args; + @ARGV = @$args; $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); + Getopt::Long::Configure("bundling"); - if ( !GetOptions( \%opt, qw(h|help V T v|version I|iscsiboot F f o s=s m:s@ r=s t=s) )) { - return( usage() ); + if (!GetOptions(\%opt, qw(h|help V T v|version I|iscsiboot F f o s=s m:s@ r=s t=s))) { + return (usage()); } #################################### # Option -h for Help #################################### - if ( exists( $opt{h} )) { - return( usage() ); + if (exists($opt{h})) { + return (usage()); } #################################### # Option -v for version #################################### - if ( exists( $opt{v} )) { + if (exists($opt{v})) { my $version = xCAT::Utils->Version(); return ([$version]); } - if ( exists( $opt{s} ) ){ + if (exists($opt{s})) { my @boot_devices = split(/,/, $opt{s}); foreach (@boot_devices) { - if ( (!/^net$/) && (!/^hd$/) ) { - return(usage( "boot device $_ is not supported" )); + if ((!/^net$/) && (!/^hd$/)) { + return (usage("boot device $_ is not supported")); } - } + } } - if (exists( $opt{m} ) ){ + if (exists($opt{m})) { my $res = xCAT::Utils->check_deployment_monitoring_settings($request, \%opt); if ($res != SUCCESS) { - return(usage()); - } + return (usage()); + } } ############################################# # T is used for trace, V is used for debug @@ -85,30 +85,30 @@ sub parse_args { $opt{V} = 1; delete $opt{T}; - }elsif(exists($opt{V})) { + } elsif (exists($opt{V})) { $opt{T} = 1; delete $opt{V}; } #################################### # Check for "-" with no option #################################### - if ( grep(/^-$/, @ARGV )) { - return(usage( "Missing option: -" )); + if (grep(/^-$/, @ARGV)) { + return (usage("Missing option: -")); } #################################### # Check for an extra argument #################################### - if ( defined( $ARGV[0] )) { - return(usage( "Invalid Argument: $ARGV[0]" )); + if (defined($ARGV[0])) { + return (usage("Invalid Argument: $ARGV[0]")); } - $request->{method} = $cmd; - return( \%opt ); + $request->{method} = $cmd; + return (\%opt); } ########################################################################## -# Netboot the lpar +# Netboot the lpar ########################################################################## sub do_rnetboot { @@ -130,10 +130,10 @@ sub do_rnetboot { ####################################### # Disconnect Expect session ####################################### - xCAT::PPCcli::disconnect( $exp ); - + xCAT::PPCcli::disconnect($exp); + ####################################### - # Get node data + # Get node data ####################################### my $id = @$d[0]; my $pprofile = @$d[1]; @@ -158,7 +158,7 @@ sub do_rnetboot { ####################################### # Save user name and passwd of hcp to # environment variables. - # lpar_netboot.expect depends on it + # lpar_netboot.expect depends on it ####################################### $ENV{HCP_USERID} = $userid; $ENV{HCP_PASSWD} = $pw; @@ -166,51 +166,59 @@ sub do_rnetboot { ####################################### # Turn on verbose and debugging ####################################### - if ( ${$request->{arg}}[0] eq '-V' ) { + if (${ $request->{arg} }[0] eq '-V') { + #$cmd.= " -v -x"; - $optarg{'v'} = 1; #for verbose - $optarg{'x'} = 1; #for debug + $optarg{'v'} = 1; #for verbose + $optarg{'x'} = 1; #for debug } ####################################### # Force LPAR shutdown ####################################### - if ( exists( $opt->{f} ) || !xCAT::Utils->isAIX() ) { + if (exists($opt->{f}) || !xCAT::Utils->isAIX()) { + #$cmd.= " -i"; $optarg{'i'} = 1; - } + } ####################################### # Write boot order ####################################### - if ( exists( $opt->{s} )) { + if (exists($opt->{s})) { foreach ($opt->{s}) { - if ( /^net$/ ) { + if (/^net$/) { + #$cmd.= " -w 1"; $optarg{'w'} = 1; - } elsif ( /^net,hd$/ ) { + } elsif (/^net,hd$/) { + #$cmd.= " -w 2"; $optarg{'w'} = 2; - } elsif ( /^hd,net$/ ) { + } elsif (/^hd,net$/) { + #$cmd.= " -w 3"; $optarg{'w'} = 3; - } elsif ( /^hd$/ ) { + } elsif (/^hd$/) { + #$cmd.= " -w 4"; $optarg{'w'} = 4; } } } - if ( exists( $opt->{o} )) { + if (exists($opt->{o})) { + #$cmd.= " -o"; $optarg{'o'} = 1; } my @macs = split /\|/, $opt->{m}; - foreach my $mac ( @macs ) { + foreach my $mac (@macs) { ####################################### # Network specified ####################################### my $mac_a = lc($mac); + #$cmd.= " -s auto -d auto -m $mac_a -S $opt->{S} -C $opt->{C} -N $opt->{N}"; $optarg{'s'} = 'auto'; @@ -224,14 +232,14 @@ sub do_rnetboot { #$cmd.= " -G $opt->{G}"; $optarg{'G'} = $opt->{G}; } - + ####################################### # Get required attributes from master # of the node if -I|--iscsiboot is # specified ####################################### - if ( exists( $opt->{I} )) { + if (exists($opt->{I})) { my $ret; my $dump_target; my $dump_lun; @@ -240,19 +248,19 @@ sub do_rnetboot { unless ($noderestab) { xCAT::MsgUtils->message('S', - "Unable to open noderes table.\n"); + "Unable to open noderes table.\n"); return 1; } my $et = $noderestab->getNodeAttribs($node, ['xcatmaster']); if ($et and $et->{'xcatmaster'}) { $ret = xCAT::Utils->runxcmd( - { - command => ['xdsh'], - node => [$et->{'xcatmaster'}], - arg => [ 'cat /tftpboot/$node.info' ] - }, - $subreq, 0, 0 ); + { + command => ['xdsh'], + node => [ $et->{'xcatmaster'} ], + arg => ['cat /tftpboot/$node.info'] + }, + $subreq, 0, 0); } else { $ret = `cat /tftpboot/$node.info`; } @@ -266,24 +274,27 @@ sub do_rnetboot { $dump_lun = $1; $dump_lun =~ s/^0x(.*)$/$1/g; } elsif (/DUMP_PORT=(.*)$/) { - $dump_port =$1; + $dump_port = $1; } } - if ( defined($dump_target) and defined($dump_lun) and defined($dump_port) ) { + if (defined($dump_target) and defined($dump_lun) and defined($dump_port)) { + #$cmd.= " -T \"$dump_target\" -L \"$dump_lun\" -p \"$dump_port\""; $optarg{'T'} = $dump_target; $optarg{'L'} = $dump_lun; $optarg{'p'} = $dump_port; } else { - return( [RC_ERROR,"Unable to find DUMP_TARGET, DUMP_LUN, DUMP_PORT for iscsi dump"] ); + return ([ RC_ERROR, "Unable to find DUMP_TARGET, DUMP_LUN, DUMP_PORT for iscsi dump" ]); } } - my %client_nethash = xCAT::DBobjUtils->getNetwkInfo( [$node] ); - if ( grep /hf/, $client_nethash{$node}{mgtifname} ) { + my %client_nethash = xCAT::DBobjUtils->getNetwkInfo([$node]); + if (grep /hf/, $client_nethash{$node}{mgtifname}) { + #$cmd.= " -t hfi-ent"; $optarg{'t'} = "hfi-ent"; } else { + #$cmd.= " -t ent"; $optarg{'t'} = "ent"; } @@ -292,18 +303,18 @@ sub do_rnetboot { # Add command options ####################################### #$cmd.= " -f \"$name\" \"$pprofile\" \"$fsp\" $id $hcp \"$node\""; - $optarg{'f'} = 1; - $optarg{'name'} = $name; + $optarg{'f'} = 1; + $optarg{'name'} = $name; $optarg{'pprofile'} = $pprofile; - $optarg{'fsp'} = $fsp; - $optarg{'id'} = $id; - $optarg{'hcp'} = $hcp; - $optarg{'node'} = $node; + $optarg{'fsp'} = $fsp; + $optarg{'id'} = $id; + $optarg{'hcp'} = $hcp; + $optarg{'node'} = $node; my $done = 0; - while ( $done < 2 ) { + while ($done < 2) { $result = ""; - $Rc = SUCCESS; + $Rc = SUCCESS; ######################################## ## Execute command ######################################## @@ -339,14 +350,14 @@ sub do_rnetboot { ####################################### $result = xCAT::LparNetbootExp->lparnetbootexp(\%optarg, $request); $Rc = @$result[0]; - if ( $Rc == SUCCESS ) { + if ($Rc == SUCCESS) { $done = 2; } else { $done = $done + 1; sleep 1; } } - if ( $Rc == SUCCESS ) { + if ($Rc == SUCCESS) { last; } } @@ -358,9 +369,10 @@ sub do_rnetboot { my $server = @$exp[3]; # creat connection first - my @newexp = xCAT::PPCcli::connect( $request, $hwtype, $server ); - if (ref($newexp[0]) eq "Expect" ) { + my @newexp = xCAT::PPCcli::connect($request, $hwtype, $server); + if (ref($newexp[0]) eq "Expect") { my $cfg = "lpar_id=@$d[0],boot_mode=norm"; + # change the boot mode to 'norm' xCAT::PPCcli::chsyscfg(\@newexp, "prof", $d, $cfg); xCAT::PPCcli::disconnect(\@newexp); @@ -371,7 +383,7 @@ sub do_rnetboot { } } - return $result; + return $result; } @@ -389,17 +401,17 @@ sub rnetboot { my $name; my $callback = $request->{callback}; ##################################### - # Get node data + # Get node data ##################################### my $lparid = @$d[0]; my $mtms = @$d[2]; my $type = @$d[4]; my $node = @$d[6]; - my $o = @$d[7]; + my $o = @$d[7]; ##################################### - # Gateway (-G) - # Server (-S) + # Gateway (-G) + # Server (-S) # Client (-C) # mac (-m) ##################################### @@ -413,58 +425,58 @@ sub rnetboot { ##################################### - # Strip colons from mac address + # Strip colons from mac address ##################################### $opt{m} =~ s/://g; ##################################### - # Force LPAR shutdown + # Force LPAR shutdown ##################################### - if ( exists( $options->{f} )) { + if (exists($options->{f})) { $opt{f} = 1; } ##################################### # Write boot device order ##################################### - if ( exists( $options->{s} )) { + if (exists($options->{s})) { $opt{s} = $options->{s}; } - - if ( exists( $options->{o} )) { + + if (exists($options->{o})) { $opt{o} = $options->{o}; } ##################################### # Do iscsi boot ##################################### - if ( exists( $options->{I} )) { - $opt{I} = 1; + if (exists($options->{I})) { + $opt{I} = 1; } ##################################### - # Invalid target hardware + # Invalid target hardware ##################################### - if ( $type !~ /^lpar$/ ) { - return( [[$name,"Not supported",RC_ERROR]] ); + if ($type !~ /^lpar$/) { + return ([ [ $name, "Not supported", RC_ERROR ] ]); } ######################################### # Get name known by HCP ######################################### my $filter = "name,lpar_id"; - my $values = xCAT::PPCcli::lssyscfg( $exp, $type, $mtms, $filter ); - my $Rc = shift(@$values); + my $values = xCAT::PPCcli::lssyscfg($exp, $type, $mtms, $filter); + my $Rc = shift(@$values); ######################################### # Return error ######################################### - if ( $Rc != SUCCESS ) { - return( [[$node,@$values[0],$Rc]] ); + if ($Rc != SUCCESS) { + return ([ [ $node, @$values[0], $Rc ] ]); } ######################################### # Find LPARs by lpar_id ######################################### - foreach ( @$values ) { - if ( /^(.*),$lparid$/ ) { + foreach (@$values) { + if (/^(.*),$lparid$/) { $name = $1; last; } @@ -472,8 +484,8 @@ sub rnetboot { ######################################### # Node not found by lpar_id ######################################### - if ( !defined( $name )) { - return( [[$node,"Node not found, lparid=$lparid",RC_ERROR]] ); + if (!defined($name)) { + return ([ [ $node, "Node not found, lparid=$lparid", RC_ERROR ] ]); } ######################################### @@ -481,79 +493,82 @@ sub rnetboot { # It is not allowed to rinitialize node # if it is in boot state ######################################### - if ( !exists( $options->{F} ) && !xCAT::Utils->isAIX() ) { + if (!exists($options->{F}) && !xCAT::Utils->isAIX()) { my $chaintab = xCAT::Table->new('chain'); - my $vcon = $chaintab->getAttribs({ node => "$node"}, 'currstate'); - if ( $vcon and $vcon->{"currstate"} and $vcon->{"currstate"} eq "boot" ) { - return( [[$node,"Node is in boot state. Use nodeset command before rnetboot or use -F option with rnetboot",RC_ERROR]] ); + my $vcon = $chaintab->getAttribs({ node => "$node" }, 'currstate'); + if ($vcon and $vcon->{"currstate"} and $vcon->{"currstate"} eq "boot") { + return ([ [ $node, "Node is in boot state. Use nodeset command before rnetboot or use -F option with rnetboot", RC_ERROR ] ]); } } #my $sitetab = xCAT::Table->new('site'); #my $vcon = $sitetab->getAttribs({key => "conserverondemand"}, 'value'); my @vcons = xCAT::TableUtils->get_site_attribute("conserverondemand"); - my $vcon = $vcons[0]; + my $vcon = $vcons[0]; + #if ($vcon and $vcon->{"value"} and $vcon->{"value"} eq "yes" ) { - if ( defined($vcon) and $vcon eq "yes" ) { + if (defined($vcon) and $vcon eq "yes") { $result = xCAT::PPCcli::lpar_netboot( - $exp, - $request->{verbose}, - $name, - $d, - \%opt ); + $exp, + $request->{verbose}, + $name, + $d, + \%opt); } else { ######################################### - # Manually perform boot. + # Manually perform boot. ######################################### - $result = do_rnetboot( $request, $d, $exp, $name, $node, \%opt ); + $result = do_rnetboot($request, $d, $exp, $name, $node, \%opt); } + #$sitetab->close; if (defined($request->{opt}->{m})) { - - my $retries = 0; + + my $retries = 0; my @monnodes = ($name); my $monsettings = xCAT::Utils->generate_monsettings($request, \@monnodes); - xCAT::Utils->monitor_installation($request, $monsettings);; - while ($retries++ < $monsettings->{'retrycount'} && scalar(keys %{$monsettings->{'nodes'}}) > 0) { + xCAT::Utils->monitor_installation($request, $monsettings); + while ($retries++ < $monsettings->{'retrycount'} && scalar(keys %{ $monsettings->{'nodes'} }) > 0) { ####lparnetboot can not support multiple nodes in one invocation ####for now, does not know how the $d and \%opt will be changed if ####support mulitiple nodes in one invocation, ####so just use the original node name and node attribute array and hash - - my $rsp={}; - $rsp->{data}->[0] = "$node: Reinitializing the installation: $retries retry"; - xCAT::MsgUtils->message("I", $rsp, $callback); - if ($vcon and $vcon->{"value"} and $vcon->{"value"} eq "yes" ) { + + my $rsp = {}; + $rsp->{data}->[0] = "$node: Reinitializing the installation: $retries retry"; + xCAT::MsgUtils->message("I", $rsp, $callback); + if ($vcon and $vcon->{"value"} and $vcon->{"value"} eq "yes") { $result = xCAT::PPCcli::lpar_netboot( - $exp, - $request->{verbose}, - $name, - $d, - \%opt ); + $exp, + $request->{verbose}, + $name, + $d, + \%opt); } else { - $result = do_rnetboot( $request, $d, $exp, $name, $node, \%opt ); + $result = do_rnetboot($request, $d, $exp, $name, $node, \%opt); } xCAT::Utils->monitor_installation($request, $monsettings); - + } + #failed after retries - if (scalar(keys %{$monsettings->{'nodes'}}) > 0) { - foreach my $node (keys %{$monsettings->{'nodes'}}) { - my $rsp={}; + if (scalar(keys %{ $monsettings->{'nodes'} }) > 0) { + foreach my $node (keys %{ $monsettings->{'nodes'} }) { + my $rsp = {}; $rsp->{data}->[0] = "The node \"$node\" can not reach the expected status after $monsettings->{'retrycount'} retries, the installation for this done failed"; xCAT::MsgUtils->message("E", $rsp, $callback); } - } + } } $Rc = shift(@$result); - + ################################## # Form string from array results ################################## - if ( exists($request->{verbose}) ) { - return( [[$node,join( '', @$result ),$Rc]] ); + if (exists($request->{verbose})) { + return ([ [ $node, join('', @$result), $Rc ] ]); } ################################## # Return error @@ -569,18 +584,18 @@ sub rnetboot { # lpar_netboot: can not find mac address 42DAB. # ################################## - if ( $Rc != SUCCESS ) { - if ( @$result[0] =~ /lpar_netboot (.*)/ ) { - return( [[$node,$1,$Rc]] ); + if ($Rc != SUCCESS) { + if (@$result[0] =~ /lpar_netboot (.*)/) { + return ([ [ $node, $1, $Rc ] ]); } - return( [[$node,join( '', @$result ),$Rc]] ); + return ([ [ $node, join('', @$result), $Rc ] ]); } ################################## # Split array into string ################################## my $data = @$result[0]; - if ( $hwtype eq "hmc" ) { - $data = join( '', @$result ); + if ($hwtype eq "hmc") { + $data = join('', @$result); } ################################## # lpar_netboot returns: @@ -595,12 +610,12 @@ sub rnetboot { # # Finished. # ##################################### - if ( $data =~ /Finished/) { - my $newstat = $::STATUS_POWERING_ON; - my %newnodestatus=(); - $newnodestatus{$newstat}=[$node]; + if ($data =~ /Finished/) { + my $newstat = $::STATUS_POWERING_ON; + my %newnodestatus = (); + $newnodestatus{$newstat} = [$node]; xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); - return( [[$node,"Success",$Rc]] ); + return ([ [ $node, "Success", $Rc ] ]); } ##################################### # Can still be error w/ Rc=0: @@ -614,12 +629,12 @@ sub rnetboot { # lpar_netboot: bootp operation failed. # ##################################### - if ( $data =~ /lpar_netboot (.*)/ ) { - return( [[$node,$1,RC_ERROR]] ); + if ($data =~ /lpar_netboot (.*)/) { + return ([ [ $node, $1, RC_ERROR ] ]); } - return( [[$node,$data,RC_ERROR]] ); + return ([ [ $node, $data, RC_ERROR ] ]); } - + 1; diff --git a/perl-xCAT/xCAT/PPCcfg.pm b/perl-xCAT/xCAT/PPCcfg.pm index 92af8e851..9c0f1c2af 100644 --- a/perl-xCAT/xCAT/PPCcfg.pm +++ b/perl-xCAT/xCAT/PPCcfg.pm @@ -16,9 +16,9 @@ use HTTP::Cookies; ########################################## # Globals ########################################## -my %rspconfig = ( - sshcfg => \&sshcfg, - frame => \&frame, +my %rspconfig = ( + sshcfg => \&sshcfg, + frame => \&frame, hostname => \&hostname ); @@ -34,7 +34,7 @@ sub parse_args { my $args = $request->{arg}; my %opt = (); my %cmds = (); - my @fsp = ( + my @fsp = ( "memdecfg", "decfg", "procdecfg", @@ -71,12 +71,12 @@ sub parse_args { "sshcfg" ); my %rsp = ( - cec=> \@fsp, - frame=>\@bpa, - fsp => \@fsp, - bpa => \@bpa, - ivm => \@ppc, - hmc => \@ppc + cec => \@fsp, + frame => \@bpa, + fsp => \@fsp, + bpa => \@bpa, + ivm => \@ppc, + hmc => \@ppc ); ############################################# # Get support command list @@ -84,7 +84,7 @@ sub parse_args { #my $typetab = xCAT::Table->new( 'nodetype' ); #my $nodes = $request->{node}; #foreach (@$nodes) { - # if ( defined( $typetab )) { + # if ( defined( $typetab )) { # my ($ent) = $typetab->getAttribs({ node=>$_},'nodetype'); # if ( defined($ent) ) { # $request->{hwtype} = $ent->{nodetype}; @@ -94,148 +94,149 @@ sub parse_args { # } # #} - - my $nodes = $request->{node}; + + my $nodes = $request->{node}; my $typehash = xCAT::DBobjUtils->getnodetype($nodes); foreach my $nn (@$nodes) { $request->{hwtype} = $$typehash{$nn}; last if ($request->{hwtype}); } - - my $supported = $rsp{$request->{hwtype}}; - + + my $supported = $rsp{ $request->{hwtype} }; + ############################################# # Responds with usage statement ############################################# local *usage = sub { my $usage_string = xCAT::Usage->getUsage($command); - return( [$_[0], $usage_string] ); + return ([ $_[0], $usage_string ]); }; ############################################# # Process command-line arguments ############################################# - if ( !defined( $args )) { - return(usage( "No command specified" )); + if (!defined($args)) { + return (usage("No command specified")); } ############################################# # Checks case in GetOptions, allows opts # to be grouped (e.g. -vx), and terminates # at the first unrecognized option. ############################################# - @ARGV = @$args; + @ARGV = @$args; $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); + Getopt::Long::Configure("bundling"); $request->{method} = undef; - if ( !GetOptions( \%opt, qw(V|verbose resetnet))) { - return( usage() ); + if (!GetOptions(\%opt, qw(V|verbose resetnet))) { + return (usage()); } #################################### # Check for "-" with no option #################################### - if ( grep(/^-$/, @ARGV )) { - return(usage( "Missing option: -" )); + if (grep(/^-$/, @ARGV)) { + return (usage("Missing option: -")); } #################################### - # Check for "=" with no argument + # Check for "=" with no argument #################################### - if (my ($c) = grep(/=$/, @ARGV )) { - return(usage( "Missing argument: $c" )); + if (my ($c) = grep(/=$/, @ARGV)) { + return (usage("Missing argument: $c")); } #################################### # Check for unsupported commands #################################### - foreach my $arg ( @ARGV ) { - my ($command,$value) = split( /=/, $arg ); - if ( !grep( /^$command$/, @$supported) and !$opt{resetnet}) { - return(usage( "Invalid command: $arg" )); - } - if ( exists( $cmds{$command} )) { - return(usage( "Command multiple times: $command" )); + foreach my $arg (@ARGV) { + my ($command, $value) = split(/=/, $arg); + if (!grep(/^$command$/, @$supported) and !$opt{resetnet}) { + return (usage("Invalid command: $arg")); + } + if (exists($cmds{$command})) { + return (usage("Command multiple times: $command")); } $cmds{$command} = $value; - } + } #################################### - # Check command arguments + # Check command arguments #################################### - foreach ( keys %cmds ) { - if ( $cmds{$_} ) { - my $result = parse_option( $request, $_, $cmds{$_} ); - if ( $result ) { - return( usage($result) ); + foreach (keys %cmds) { + if ($cmds{$_}) { + my $result = parse_option($request, $_, $cmds{$_}); + if ($result) { + return (usage($result)); } } elsif ($_ =~ /_passwd$/) { - return( usage("No argument specified for '$_'")); - } + return (usage("No argument specified for '$_'")); + } } { if ($request->{dev} eq '1' && $request->{other} eq '1') { - return ( usage("Invalid command arrays")); - } -# my $result = parse_dev_option( $request, \%cmds); -# if ($result) { -# return ( usage($result)); -# } - } - #################################### - # Return method to invoke - #################################### - if ( $request->{hwtype} =~ /(^hmc|ivm)$/ ) { - $request->{method} = "cfg"; - return( \%opt ); + return (usage("Invalid command arrays")); + } + + # my $result = parse_dev_option( $request, \%cmds); + # if ($result) { + # return ( usage($result)); + # } } #################################### # Return method to invoke #################################### - if ( exists($cmds{frame}) or exists($cmds{hostname}) ) { - $request->{hcp} = "hmc"; + if ($request->{hwtype} =~ /(^hmc|ivm)$/) { $request->{method} = "cfg"; - return( \%opt ); + return (\%opt); } #################################### # Return method to invoke #################################### - if ( $opt{resetnet} ) { - $request->{hcp} = "hmc"; + if (exists($cmds{frame}) or exists($cmds{hostname})) { + $request->{hcp} = "hmc"; + $request->{method} = "cfg"; + return (\%opt); + } + #################################### + # Return method to invoke + #################################### + if ($opt{resetnet}) { + $request->{hcp} = "hmc"; $request->{method} = "resetnet"; - return( \%opt ); + return (\%opt); } #################################### # Return method to invoke #################################### - if ( exists($cmds{HMC_passwd}) or exists($cmds{general_passwd}) or exists($cmds{admin_passwd}) or exists($cmds{"*_passwd"}) ) { - $request->{hcp} = "hmc"; + if (exists($cmds{HMC_passwd}) or exists($cmds{general_passwd}) or exists($cmds{admin_passwd}) or exists($cmds{"*_passwd"})) { + $request->{hcp} = "hmc"; $request->{method} = "passwd"; - return( \%opt ); + return (\%opt); } $request->{method} = \%cmds; - return( \%opt ); + return (\%opt); } -sub parse_dev_option{ - my $req = shift; +sub parse_dev_option { + my $req = shift; my $cmds = shift; foreach my $cmd (keys %$cmds) { - if ( $cmd =~ /^(dev|celogin1)$/ ) { - if ($cmds->{$cmd} and ($cmds->{$cmd} !~ /^(enable|disable)$/i) ) { - return( "Invalid argument ".$cmds->{$cmd}." for ".$cmd ); + if ($cmd =~ /^(dev|celogin1)$/) { + if ($cmds->{$cmd} and ($cmds->{$cmd} !~ /^(enable|disable)$/i)) { + return ("Invalid argument " . $cmds->{$cmd} . " for " . $cmd); } $req->{dev} = 1; } else { - $req->{other} = 1; + $req->{other} = 1; } } if ($req->{dev} eq '1' && $req->{other} eq '1') { return ("Invalid command arrays"); - } + } return undef; } ########################################################################## -# Parse the command line optional arguments +# Parse the command line optional arguments ########################################################################## sub parse_option { @@ -246,90 +247,90 @@ sub parse_option { #################################### # Set/get time #################################### - if ( $command =~ /^time$/ ) { - if ( $value !~ - /^([0-1]?[0-9]|2[0-3]):(0?[0-9]|[1-5][0-9]):(0?[0-9]|[1-5][0-9])$/){ - return( "Invalid time format '$value'" ); + if ($command =~ /^time$/) { + if ($value !~ +/^([0-1]?[0-9]|2[0-3]):(0?[0-9]|[1-5][0-9]):(0?[0-9]|[1-5][0-9])$/) { + return ("Invalid time format '$value'"); } } #################################### - # Set/get date + # Set/get date #################################### - if ( $command =~ /^date$/ ) { - if ( $value !~ - /^(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])-(20[0-9]{2})$/){ - return( "Invalid date format '$value'" ); + if ($command =~ /^date$/) { + if ($value !~ + /^(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])-(20[0-9]{2})$/) { + return ("Invalid date format '$value'"); } } #################################### # Set/get options #################################### - if ( $command =~ /^(autopower|iocap|sshcfg)$/ ) { - if ( $value !~ /^(enable|disable)$/i ) { - return( "Invalid argument '$value'" ); + if ($command =~ /^(autopower|iocap|sshcfg)$/) { + if ($value !~ /^(enable|disable)$/i) { + return ("Invalid argument '$value'"); } } #################################### - # Deconfiguration policy + # Deconfiguration policy #################################### - if ( $command =~ /^decfg$/ ) { - if ( $value !~ /^(enable|disable):.*$/i ) { - return( "Invalid argument '$value'" ); + if ($command =~ /^decfg$/) { + if ($value !~ /^(enable|disable):.*$/i) { + return ("Invalid argument '$value'"); } } #################################### - # Processor deconfiguration + # Processor deconfiguration #################################### - if ( $command =~ /^procdecfg$/ ) { - if ( $value !~ /^(configure|deconfigure):\d+:(all|[\d,]+)$/i ) { - return( "Invalid argument '$value'" ); + if ($command =~ /^procdecfg$/) { + if ($value !~ /^(configure|deconfigure):\d+:(all|[\d,]+)$/i) { + return ("Invalid argument '$value'"); } } ################################ - # Memory deconfiguration + # Memory deconfiguration ################################ - elsif ( $command =~ /^memdecfg$/ ) { - if ($value !~/^(configure|deconfigure):\d+:(unit|bank):(all|[\d,]+)$/i){ - return( "Invalid argument '$value'" ); - } + elsif ($command =~ /^memdecfg$/) { + if ($value !~ /^(configure|deconfigure):\d+:(unit|bank):(all|[\d,]+)$/i) { + return ("Invalid argument '$value'"); + } } - if ( $command eq 'network'){ - my ( $adapter_name, $ip, $host, $gateway, $netmask) = - split /,/, $value; - return ( "Network interface name is required") if ( ! $adapter_name); - return ( "Invalide network interface name $adapter_name") if ( $adapter_name !~ /^eth\d$/); - return undef if ( $ip eq '*'); - return ( "Invalid IP address format") if ( $ip and $ip !~ /\d+\.\d+\.\d+\.\d+/); - return ( "Invalid netmask format") if ( $netmask and $netmask !~ /\d+\.\d+\.\d+\.\d+/); + if ($command eq 'network') { + my ($adapter_name, $ip, $host, $gateway, $netmask) = + split /,/, $value; + return ("Network interface name is required") if (!$adapter_name); + return ("Invalide network interface name $adapter_name") if ($adapter_name !~ /^eth\d$/); + return undef if ($ip eq '*'); + return ("Invalid IP address format") if ($ip and $ip !~ /\d+\.\d+\.\d+\.\d+/); + return ("Invalid netmask format") if ($netmask and $netmask !~ /\d+\.\d+\.\d+\.\d+/); } - if ( $command eq 'frame' ){ - if ( $value !~ /^\d+$/i && $value ne '*' ) { - return( "Invalid frame number '$value'" ); + if ($command eq 'frame') { + if ($value !~ /^\d+$/i && $value ne '*') { + return ("Invalid frame number '$value'"); } } - if ( $command eq 'admin_passwd' or $command eq 'general_passwd' or $command eq '*_passwd' ){ - my ($passwd,$newpasswd) = split /,/, $value; - if ( !$passwd or !$newpasswd) { - return( "Current password and new password couldn't be empty" ); + if ($command eq 'admin_passwd' or $command eq 'general_passwd' or $command eq '*_passwd') { + my ($passwd, $newpasswd) = split /,/, $value; + if (!$passwd or !$newpasswd) { + return ("Current password and new password couldn't be empty"); } } - if ( $command eq 'HMC_passwd' ) { - my ($passwd,$newpasswd) = split /,/, $value; - if ( !$newpasswd ) { - return( "New password couldn't be empty for user 'HMC'" ); + if ($command eq 'HMC_passwd') { + my ($passwd, $newpasswd) = split /,/, $value; + if (!$newpasswd) { + return ("New password couldn't be empty for user 'HMC'"); } } - - if ( $command eq 'dev' or $command eq 'celogin1' ) { - if ($value !~ /^(enable|disable)$/i ) { - return( "Invalid argument '$value'" ); - } - $request->{dev} = 1; + + if ($command eq 'dev' or $command eq 'celogin1') { + if ($value !~ /^(enable|disable)$/i) { + return ("Invalid argument '$value'"); + } + $request->{dev} = 1; } else { - $request->{other} = 1; + $request->{other} = 1; } return undef; } @@ -346,13 +347,13 @@ sub passwd { my $result; my $users; - foreach my $arg ( @$args ) { - my ($user,$value) = split /=/, $arg; - my ($passwd,$newpasswd) = split /,/, $value; + foreach my $arg (@$args) { + my ($user, $value) = split /=/, $arg; + my ($passwd, $newpasswd) = split /,/, $value; $user =~ s/_passwd$//; $user =~ s/^HMC$/access/g; - if ( $user eq "*" ) { + if ($user eq "*") { push @$users, "access"; push @$users, "admin"; push @$users, "general"; @@ -360,30 +361,30 @@ sub passwd { push @$users, $user; } - foreach my $usr ( @$users ) { - while ( my ($cec,$h) = each(%$hash) ) { - while ( my ($node,$d) = each(%$h) ) { + foreach my $usr (@$users) { + while (my ($cec, $h) = each(%$hash)) { + while (my ($node, $d) = each(%$h)) { my $type = @$d[4]; xCAT::MsgUtils->verbose_message($request, "rspconfig :modify password of $usr for node:$node."); - my $data = xCAT::PPCcli::chsyspwd( $exp, $usr, $type, $cec, $passwd, $newpasswd ); - my $Rc = shift(@$data); + my $data = xCAT::PPCcli::chsyspwd($exp, $usr, $type, $cec, $passwd, $newpasswd); + my $Rc = shift(@$data); my $usr_back = $usr; $usr_back =~ s/^access$/HMC/g; - push @$result, [$node,"$usr_back: @$data[0]",$Rc]; - + push @$result, [ $node, "$usr_back: @$data[0]", $Rc ]; + ################################## # Write the new password to table ################################## - if ( $Rc == SUCCESS ) { + if ($Rc == SUCCESS) { xCAT::MsgUtils->verbose_message($request, "rspconfig :update xCATdb for node:$node,ID:$usr_back."); - xCAT::PPCdb::update_credentials( $node, $type, $usr_back, $newpasswd ); + xCAT::PPCdb::update_credentials($node, $type, $usr_back, $newpasswd); } } } } } - return( [@$result] ); + return ([@$result]); } ########################################################################## @@ -397,23 +398,23 @@ sub cfg { my $args = $request->{arg}; my $result; - foreach ( @$args ) { + foreach (@$args) { ################################## # Ignore switches in command-line ################################## - unless ( /^-/ ) { - my ($cmd,$value) = split /=/; + unless (/^-/) { + my ($cmd, $value) = split /=/; no strict 'refs'; - $result = $rspconfig{$cmd}( $request, $exp, $value, $hash ); + $result = $rspconfig{$cmd}($request, $exp, $value, $hash); use strict; } } - return( $result ); + return ($result); } ########################################################################## -# Enables/disables/displays SSH access to HMC/IVM +# Enables/disables/displays SSH access to HMC/IVM ########################################################################## sub sshcfg { my $request = shift; @@ -421,15 +422,15 @@ sub sshcfg { my $mode = shift; my $server = @$exp[3]; my $userid = @$exp[4]; - my $fname = ((xCAT::Utils::isAIX()) ? "/.ssh/":"/root/.ssh/")."id_rsa.pub"; - my $auth = "/home/$userid/.ssh/authorized_keys2"; + my $fname = ((xCAT::Utils::isAIX()) ? "/.ssh/" : "/root/.ssh/") . "id_rsa.pub"; + my $auth = "/home/$userid/.ssh/authorized_keys2"; ##################################### # Get SSH key on Management Node ##################################### - unless ( open(RSAKEY,"<$fname") ) { - return( [[$server,"Error opening '$fname'",RC_ERROR]] ); - } + unless (open(RSAKEY, "<$fname")) { + return ([ [ $server, "Error opening '$fname'", RC_ERROR ] ]); + } my ($sshkey) = ; close(RSAKEY); @@ -442,47 +443,47 @@ sub sshcfg { my $logon = $1; ##################################### - # Determine if SSH is enabled + # Determine if SSH is enabled ##################################### - if ( !defined( $mode )) { - my ($keytype, $key_string) = split /\ /, $sshkey; + if (!defined($mode)) { + my ($keytype, $key_string) = split /\ /, $sshkey; chomp($key_string); xCAT::MsgUtils->verbose_message($request, "rspconfig :check sshcfg for user:$logon on node:$server."); - my $result = xCAT::PPCcli::send_cmd( $exp, "cat $auth" ); - my $Rc = shift(@$result); + my $result = xCAT::PPCcli::send_cmd($exp, "cat $auth"); + my $Rc = shift(@$result); ################################# - # Return error + # Return error ################################# - if ( $Rc != SUCCESS ) { - return( [[$server,@$result[0],$Rc]] ); + if ($Rc != SUCCESS) { + return ([ [ $server, @$result[0], $Rc ] ]); } ################################# - # Find logon in key file + # Find logon in key file ################################# - foreach ( @$result ) { + foreach (@$result) { my ($tmp1, $tmp2) = split /\ /, $_; chomp($tmp2); - if ( "$tmp2" eq "$key_string" ) { - return( [[$server,"enabled",SUCCESS]] ); + if ("$tmp2" eq "$key_string") { + return ([ [ $server, "enabled", SUCCESS ] ]); } } - return( [[$server,"disabled",SUCCESS]] ); + return ([ [ $server, "disabled", SUCCESS ] ]); } ##################################### - # Enable/disable SSH + # Enable/disable SSH ##################################### xCAT::MsgUtils->verbose_message($request, "rspconfig :sshcfg $mode for user:$logon on node:$server."); - my $result = xCAT::PPCcli::mkauthkeys( $exp, $mode, $logon, $sshkey ); + my $result = xCAT::PPCcli::mkauthkeys($exp, $mode, $logon, $sshkey); my $Rc = shift(@$result); ################################# # Return error ################################# - if ( $Rc != SUCCESS ) { - return( [[$server,@$result[0],$Rc]] ); + if ($Rc != SUCCESS) { + return ([ [ $server, @$result[0], $Rc ] ]); } - return( [[$server,lc($mode."d"),SUCCESS]] ); + return ([ [ $server, lc($mode . "d"), SUCCESS ] ]); } sub frame { @@ -492,14 +493,14 @@ sub frame { my $hash = shift; my $arg = $request->{arg}; - foreach ( @$arg ) { + foreach (@$arg) { my $result; my $Rc; my $data; my ($cmd, $value) = split /=/, $_; - if ( $cmd ne "frame" ) { - return( [[@$exp[2],"Multiple option $cmd and frame is not accepted",SUCCESS]] ); + if ($cmd ne "frame") { + return ([ [ @$exp[2], "Multiple option $cmd and frame is not accepted", SUCCESS ] ]); } ################################# @@ -507,58 +508,58 @@ sub frame { # the frame number between hcp # and database ################################# - my $tab = xCAT::Table->new( "ppc" ); + my $tab = xCAT::Table->new("ppc"); - while ( my ($cec,$h) = each(%$hash) ) { - while ( my ($node,$d) = each(%$h) ) { - if ( !defined($value) ) { + while (my ($cec, $h) = each(%$hash)) { + while (my ($node, $d) = each(%$h)) { + if (!defined($value)) { ################################# # Get frame number ################################# xCAT::MsgUtils->verbose_message($request, "rspconfig :get frame_num for node:$node."); - $data = xCAT::PPCcli::lssyscfg( $exp, @$d[4], @$d[2], 'frame_num' ); + $data = xCAT::PPCcli::lssyscfg($exp, @$d[4], @$d[2], 'frame_num'); $Rc = shift(@$data); ################################# # Return error ################################# - if ( $Rc != SUCCESS ) { - return( [[$node,@$data[0],$Rc]] ); + if ($Rc != SUCCESS) { + return ([ [ $node, @$data[0], $Rc ] ]); } - push @$result, [$node,@$data[0],SUCCESS]; + push @$result, [ $node, @$data[0], SUCCESS ]; ################################# # Set frame number to database ################################# - $tab->setNodeAttribs( $node, { id=>@$data[0] } ); + $tab->setNodeAttribs($node, { id => @$data[0] }); - } elsif ( $value eq '*' ) { + } elsif ($value eq '*') { ################################# # Set frame number - # Read the settings from database + # Read the settings from database ################################# - my $ent=$tab->getNodeAttribs( $node,['id'] ); + my $ent = $tab->getNodeAttribs($node, ['id']); ################################# # Return error ################################# - if ( !defined($ent) or !defined($ent->{id}) ) { - return( [[$node,"Cannot find frame num in database",RC_ERROR]] ); + if (!defined($ent) or !defined($ent->{id})) { + return ([ [ $node, "Cannot find frame num in database", RC_ERROR ] ]); } - xCAT::MsgUtils->verbose_message($request, "rspconfig :set frame_num=".$ent->{id}." for node:$node."); - $data = xCAT::PPCcli::chsyscfg( $exp, "bpa", $d, "frame_num=".$ent->{id} ); + xCAT::MsgUtils->verbose_message($request, "rspconfig :set frame_num=" . $ent->{id} . " for node:$node."); + $data = xCAT::PPCcli::chsyscfg($exp, "bpa", $d, "frame_num=" . $ent->{id}); $Rc = shift(@$data); ################################# # Return error ################################# - if ( $Rc != SUCCESS ) { - return( [[$node,@$data[0],$Rc]] ); + if ($Rc != SUCCESS) { + return ([ [ $node, @$data[0], $Rc ] ]); } - push @$result, [$node,@$data[0],SUCCESS]; + push @$result, [ $node, @$data[0], SUCCESS ]; } else { ################################# @@ -566,28 +567,28 @@ sub frame { # Read the frame number from opt ################################# xCAT::MsgUtils->verbose_message($request, "rspconfig :set frame_num=$value for node:$node."); - $data = xCAT::PPCcli::chsyscfg( $exp, "bpa", $d, "frame_num=$value" ); + $data = xCAT::PPCcli::chsyscfg($exp, "bpa", $d, "frame_num=$value"); $Rc = shift(@$data); ################################# # Return error ################################# - if ( $Rc != SUCCESS ) { - return( [[$node,@$data[0],$Rc]] ); + if ($Rc != SUCCESS) { + return ([ [ $node, @$data[0], $Rc ] ]); } - push @$result, [$node,@$data[0],SUCCESS]; + push @$result, [ $node, @$data[0], SUCCESS ]; ################################# # Set frame number to database ################################# xCAT::MsgUtils->verbose_message($request, "rspconfig : set frame_num, update node:$node attr id=$value."); - $tab->setNodeAttribs( $node, { id=>$value } ); + $tab->setNodeAttribs($node, { id => $value }); } } - return( [@$result] ); - } + return ([@$result]); + } } } @@ -599,65 +600,65 @@ sub hostname { my $arg = $request->{arg}; my $result; - foreach ( @$arg ) { + foreach (@$arg) { my $data; my $Rc; my ($cmd, $value) = split /=/, $_; - if ( $cmd ne "hostname" ) { - return( [[@$exp[2],"Multiple option $cmd and hostname is not accepted",SUCCESS]] ); + if ($cmd ne "hostname") { + return ([ [ @$exp[2], "Multiple option $cmd and hostname is not accepted", SUCCESS ] ]); } - while ( my ($cec,$h) = each(%$hash) ) { - while ( my ($node,$d) = each(%$h) ) { - if ( !defined($value) ) { + while (my ($cec, $h) = each(%$hash)) { + while (my ($node, $d) = each(%$h)) { + if (!defined($value)) { ################################# # Get system name ################################# xCAT::MsgUtils->verbose_message($request, "rspconfig :get system name for node:$node."); - $data = xCAT::PPCcli::lssyscfg( $exp, @$d[4], @$d[2], 'name' ); + $data = xCAT::PPCcli::lssyscfg($exp, @$d[4], @$d[2], 'name'); $Rc = shift(@$data); ################################# # Return error ################################# - if ( $Rc != SUCCESS ) { - push @$result, [$node,@$data[0],$Rc]; + if ($Rc != SUCCESS) { + push @$result, [ $node, @$data[0], $Rc ]; } - push @$result, [$node,@$data[0],SUCCESS]; - } elsif ( $value eq '*' ) { + push @$result, [ $node, @$data[0], SUCCESS ]; + } elsif ($value eq '*') { xCAT::MsgUtils->verbose_message($request, "rspconfig :set system name:$node for node:$node."); - $data = xCAT::PPCcli::chsyscfg( $exp, @$d[4], $d, "new_name=$node" ); + $data = xCAT::PPCcli::chsyscfg($exp, @$d[4], $d, "new_name=$node"); $Rc = shift(@$data); ################################# # Return error ################################# - if ( $Rc != SUCCESS ) { - push @$result, [$node,@$data[0],$Rc]; + if ($Rc != SUCCESS) { + push @$result, [ $node, @$data[0], $Rc ]; } - push @$result, [$node,@$data[0],SUCCESS]; + push @$result, [ $node, @$data[0], SUCCESS ]; } else { xCAT::MsgUtils->verbose_message($request, "rspconfig :set system name:$value for node:$node."); - $data = xCAT::PPCcli::chsyscfg( $exp, @$d[4], $d, "new_name=$value" ); + $data = xCAT::PPCcli::chsyscfg($exp, @$d[4], $d, "new_name=$value"); $Rc = shift(@$data); ################################# # Return error ################################# - if ( $Rc != SUCCESS ) { - push @$result, [$node,@$data[0],$Rc]; + if ($Rc != SUCCESS) { + push @$result, [ $node, @$data[0], $Rc ]; } - push @$result, [$node,@$data[0],SUCCESS]; + push @$result, [ $node, @$data[0], SUCCESS ]; } } } } - return( [@$result] ); + return ([@$result]); } ########################################################################## # Do resetnet public entry @@ -680,194 +681,201 @@ sub doresetnet { my %oihash; my %machash; my %vpdhash; - - unless ($req) { - send_msg( $req, 1, "request is empty, return" ); - return; - } + + unless ($req) { + send_msg($req, 1, "request is empty, return"); + return; + } ########################################### # prepare to reset network ########################################### xCAT::MsgUtils->verbose_message($req, "rspconfig :do resetnet begin to phase nodes"); - my $hoststab = xCAT::Table->new( 'hosts' ); - if ( !$hoststab ) { - send_msg( $req, 1, "Error open hosts table" ); + my $hoststab = xCAT::Table->new('hosts'); + if (!$hoststab) { + send_msg($req, 1, "Error open hosts table"); return; } else { - my @hostslist = $hoststab->getAllNodeAttribs(['node','otherinterfaces']); - foreach my $otherentry ( @hostslist) { - $oihash{$otherentry->{node}} = $otherentry->{otherinterfaces}; + my @hostslist = $hoststab->getAllNodeAttribs([ 'node', 'otherinterfaces' ]); + foreach my $otherentry (@hostslist) { + $oihash{ $otherentry->{node} } = $otherentry->{otherinterfaces}; } - } - - my $mactab = xCAT::Table->new( 'mac' ); - if ( !$mactab ) { - send_msg( $req, 1, "Error open mac table" ); + } + + my $mactab = xCAT::Table->new('mac'); + if (!$mactab) { + send_msg($req, 1, "Error open mac table"); return; - }else{ - my @maclist = $mactab->getAllNodeAttribs(['node','mac']); + } else { + my @maclist = $mactab->getAllNodeAttribs([ 'node', 'mac' ]); foreach my $macentry (@maclist) { - $machash{$macentry->{node}} = $macentry->{mac}; + $machash{ $macentry->{node} } = $macentry->{mac}; } } $mactab = (); - my $vpdtab = xCAT::Table->new( 'vpd' ); - if ( !$vpdtab ) { - send_msg( $req, 1, "Error open vpd table" ); + my $vpdtab = xCAT::Table->new('vpd'); + if (!$vpdtab) { + send_msg($req, 1, "Error open vpd table"); return; } else { - my @vpdlist = $vpdtab->getAllNodeAttribs(['node','mtm','serial','side']); + my @vpdlist = $vpdtab->getAllNodeAttribs([ 'node', 'mtm', 'serial', 'side' ]); foreach my $vpdentry (@vpdlist) { if ($vpdentry->{side} =~ /(\w)\-\w/) { my $side = $1; - $vpdhash{$vpdentry->{node}} = $vpdentry->{mtm}."*".$vpdentry->{serial}."*".$side; - } + $vpdhash{ $vpdentry->{node} } = $vpdentry->{mtm} . "*" . $vpdentry->{serial} . "*" . $side; + } } - } + } $vpdtab = (); - unless ( $req->{node} ) { - send_msg( $req, 0, "no node specified" ); + unless ($req->{node}) { + send_msg($req, 0, "no node specified"); return; } ########################################### # Process nodes and get network information ########################################### my $nodetype = $req->{hwtype}; - if ( $nodetype =~ /^(cec|frame)$/ ) { + if ($nodetype =~ /^(cec|frame)$/) { + # this brunch is just for the xcat 2.6(or 2.6+) database - foreach my $nn ( @{ $req->{node}} ) { + foreach my $nn (@{ $req->{node} }) { my $cnodep = xCAT::DBobjUtils->getchildren($nn); - $nodetype = ( $nodetype =~ /^frame$/i ) ? "bpa" : "fsp"; + $nodetype = ($nodetype =~ /^frame$/i) ? "bpa" : "fsp"; if ($cnodep) { foreach my $cnode (@$cnodep) { - my $ip = xCAT::NetworkUtils::getNodeIPaddress( $cnode ); + my $ip = xCAT::NetworkUtils::getNodeIPaddress($cnode); my $oi = $oihash{$cnode}; - if(!defined $ip) { + if (!defined $ip) { send_msg($req, "doresetnet: can't get $cnode ip"); next; - } - if(!defined $oi) { + } + if (!defined $oi) { send_msg($req, "doresetnet: can't get $cnode hosts.otherinterfaces"); next; } - if ( exists($oihash{$cnode}) and $ip eq $oihash{$cnode}) { - send_msg( $req, 0, "$cnode: same ip address, skipping $nn network reset" ); - } elsif( ! exists $machash{$cnode}){ - send_msg( $req, 0, "$cnode: no mac defined, skipping $nn network reset" ); + if (exists($oihash{$cnode}) and $ip eq $oihash{$cnode}) { + send_msg($req, 0, "$cnode: same ip address, skipping $nn network reset"); + } elsif (!exists $machash{$cnode}) { + send_msg($req, 0, "$cnode: no mac defined, skipping $nn network reset"); } else { $iphash{$cnode}{sip} = $ip; $iphash{$cnode}{tip} = $oihash{$cnode}; - if(exists $grouphash{$vpdhash{$cnode}}) { - $grouphash{$vpdhash{$cnode}} .= ",$cnode"; + if (exists $grouphash{ $vpdhash{$cnode} }) { + $grouphash{ $vpdhash{$cnode} } .= ",$cnode"; } else { - $grouphash{$vpdhash{$cnode}} = "$cnode"; + $grouphash{ $vpdhash{$cnode} } = "$cnode"; } $targets->{$nodetype}->{$ip}->{'args'} = "0.0.0.0,$cnode"; $targets->{$nodetype}->{$ip}->{'mac'} = $machash{$cnode}; $targets->{$nodetype}->{$ip}->{'name'} = $cnode; - $targets->{$nodetype}->{$ip}->{'ip'} = $ip; + $targets->{$nodetype}->{$ip}->{'ip'} = $ip; $targets->{$nodetype}->{$ip}->{'type'} = $nodetype; - my %netinfo = xCAT::DBobjUtils->getNetwkInfo( [$ip] ); + my %netinfo = xCAT::DBobjUtils->getNetwkInfo([$ip]); $targets->{$nodetype}->{$ip}->{'args'} .= ",$netinfo{$ip}{'gateway'},$netinfo{$ip}{'mask'}"; + #xCAT::MsgUtils->verbose_message($req, "doresetnet: get node $cnode info $targets->{$nodetype}->{$ip}->{'args'}, ip is $ip"); $targets->{$nodetype}->{$oi}->{'args'} = "0.0.0.0,$cnode"; $targets->{$nodetype}->{$oi}->{'mac'} = $machash{$cnode}; $targets->{$nodetype}->{$oi}->{'name'} = $cnode; - $targets->{$nodetype}->{$oi}->{'ip'} = $oi; + $targets->{$nodetype}->{$oi}->{'ip'} = $oi; $targets->{$nodetype}->{$oi}->{'type'} = $nodetype; - %netinfo = xCAT::DBobjUtils->getNetwkInfo( [$oi] ); + %netinfo = xCAT::DBobjUtils->getNetwkInfo([$oi]); $targets->{$nodetype}->{$oi}->{'args'} .= ",$netinfo{$oi}{'gateway'},$netinfo{$oi}{'mask'}"; + #xCAT::MsgUtils->verbose_message($req, "doresetnet: get node $cnode info $targets->{$nodetype}->{$oi}->{'args'}, oi is $oi"); } } } else { - send_msg( $req, 1, "Can't get the fsp/bpa nodes for the $nn" ); + send_msg($req, 1, "Can't get the fsp/bpa nodes for the $nn"); return; - } - } - # this brunch is just for the xcat 2.5(or 2.5-) databse - } elsif ( $nodetype =~ /^(fsp|bpa)$/ ) { - foreach my $nn ( @{ $req->{node}} ) { - my $ip = xCAT::NetworkUtils::getNodeIPaddress( $nn ); - if(!defined $ip) { + } + } + + # this brunch is just for the xcat 2.5(or 2.5-) databse + } elsif ($nodetype =~ /^(fsp|bpa)$/) { + foreach my $nn (@{ $req->{node} }) { + my $ip = xCAT::NetworkUtils::getNodeIPaddress($nn); + if (!defined $ip) { send_msg($req, "doresetnet: can't get $nn ip"); next; - } - if(!exists $oihash{$nn}) { + } + if (!exists $oihash{$nn}) { send_msg($req, "doresetnet: can't get $nn hosts.otherinterfaces"); next; } my $oi = $oihash{$nn}; - if( exists($oihash{$nn}) and $ip eq $oihash{$nn}) { - send_msg( $req, 0, "$nn: same ip address, skipping network reset" ); - } elsif (!exists $machash{$nn}){ - send_msg( $req, 0, "$nn: no mac defined, skipping network reset" ); + if (exists($oihash{$nn}) and $ip eq $oihash{$nn}) { + send_msg($req, 0, "$nn: same ip address, skipping network reset"); + } elsif (!exists $machash{$nn}) { + send_msg($req, 0, "$nn: no mac defined, skipping network reset"); } else { $iphash{$nn}{sip} = $ip; $iphash{$nn}{tip} = $oihash{$nn}; - if(exists $grouphash{$vpdhash{$nn}}) { - $grouphash{$vpdhash{$nn}} .= ",$nn"; + if (exists $grouphash{ $vpdhash{$nn} }) { + $grouphash{ $vpdhash{$nn} } .= ",$nn"; } else { - $grouphash{$vpdhash{$nn}} = "$nn"; + $grouphash{ $vpdhash{$nn} } = "$nn"; } $targets->{$nodetype}->{$ip}->{'args'} = "0.0.0.0,$nn"; - $targets->{$nodetype}->{$ip}->{'mac'} = $machash{$nn}; + $targets->{$nodetype}->{$ip}->{'mac'} = $machash{$nn}; $targets->{$nodetype}->{$ip}->{'name'} = $nn; - $targets->{$nodetype}->{$ip}->{'ip'} = $ip; + $targets->{$nodetype}->{$ip}->{'ip'} = $ip; $targets->{$nodetype}->{$ip}->{'type'} = $nodetype; - my %netinfo = xCAT::DBobjUtils->getNetwkInfo( [$ip] ); + my %netinfo = xCAT::DBobjUtils->getNetwkInfo([$ip]); $targets->{$nodetype}->{$ip}->{'args'} .= ",$netinfo{$ip}{'gateway'},$netinfo{$ip}{'mask'}"; + #xCAT::MsgUtils->verbose_message($req, "doresetnet: get node $nn info $targets->{$nodetype}->{$ip}->{'args'},ip is $ip"); $targets->{$nodetype}->{$oi}->{'args'} = "0.0.0.0,$nn"; - $targets->{$nodetype}->{$oi}->{'mac'} = $machash{$nn}; + $targets->{$nodetype}->{$oi}->{'mac'} = $machash{$nn}; $targets->{$nodetype}->{$oi}->{'name'} = $nn; - $targets->{$nodetype}->{$oi}->{'ip'} = $oi; + $targets->{$nodetype}->{$oi}->{'ip'} = $oi; $targets->{$nodetype}->{$oi}->{'type'} = $nodetype; - %netinfo = xCAT::DBobjUtils->getNetwkInfo( [$oi] ); + %netinfo = xCAT::DBobjUtils->getNetwkInfo([$oi]); $targets->{$nodetype}->{$oi}->{'args'} .= ",$netinfo{$oi}{'gateway'},$netinfo{$oi}{'mask'}"; + #xCAT::MsgUtils->verbose_message($req, "doresetnet: get node $nn info $targets->{$nodetype}->{$oi}->{'args'}, oi is $oi"); } - } - } elsif ( !$nodetype ){ - send_msg( $req, 0, "no nodetype defined, skipping network reset" ); + } + } elsif (!$nodetype) { + send_msg($req, 0, "no nodetype defined, skipping network reset"); return; } else { - send_msg( $req, 0, "$nodetype not supported, skipping network reset" ); + send_msg($req, 0, "$nodetype not supported, skipping network reset"); return; } - + unless (%grouphash) { - send_msg( $req, 0, "Failed to group the nodes, skipping network reset" ); + send_msg($req, 0, "Failed to group the nodes, skipping network reset"); return; - } + } ########################################### # Update target hardware w/discovery info ########################################### - my %rsp_dev = get_rsp_dev( $req, $targets); - + my %rsp_dev = get_rsp_dev($req, $targets); + ###################################################### # Start to reset network. Fork one process per BPA/FSP ###################################################### %oihash = (); %machash = (); %vpdhash = (); - $start = Time::HiRes::gettimeofday(); + $start = Time::HiRes::gettimeofday(); my $children = 0; $SIG{CHLD} = sub { while (waitpid(-1, WNOHANG) > 0) { $children--; } }; - my $fds = new IO::Select; - my $callback = $req->{callback}; - my $ij = 0; - foreach my $node ( keys %grouphash) { + my $fds = new IO::Select; + my $callback = $req->{callback}; + my $ij = 0; + + foreach my $node (keys %grouphash) { my %iphashfornode; my $gc = $grouphash{$node}; my %rsp_devfornode; foreach my $tn (split /,/, $gc) { $iphashfornode{$tn} = $iphash{$tn}; - for my $ti (keys %{$iphash{$tn}}){ + for my $ti (keys %{ $iphash{$tn} }) { my $tip = $iphash{$tn}{$ti}; $rsp_devfornode{$tip} = $rsp_dev{$tip}; } @@ -878,9 +886,9 @@ sub doresetnet { # Begin fork ###################################################### my $pipe; - my $rspdevref = \%rsp_devfornode; + my $rspdevref = \%rsp_devfornode; my $grouphashref = $gc; - my $iphashref = \%iphashfornode; + my $iphashref = \%iphashfornode; my $result; my @data = ("RSPCONFIG6sK4ci"); @@ -890,92 +898,94 @@ sub doresetnet { my $parent; my $child; pipe $parent, $child; - $ij ++; - $ij = int($ij%60); + $ij++; + $ij = int($ij % 60); my $pid = xCAT::Utils->xfork(); - if ( !defined($pid) ) { + if (!defined($pid)) { ################################### # Fork error ################################### - send_msg( $req, 1, "Fork error: $!" ); + send_msg($req, 1, "Fork error: $!"); return undef; } - elsif ( $pid == 0 ) { + elsif ($pid == 0) { sleep $ij; ################################### # Child process, clear memory first ################################### - %rsp_dev = (); + %rsp_dev = (); %grouphash = (); - %iphash = (); - close( $parent ); + %iphash = (); + close($parent); $req->{pipe} = $child; - my $msgs; - my $report; + my $msgs; + my $report; + #try and try to avoid the fail that caused by refreshing IP when doing resetnet - my $time = 0; - while (1) { - my $erflag = 0; - $msgs = child_process($grouphashref, $iphashref, $rspdevref, $req, $node ); - foreach my $port (keys %$msgs){ + my $time = 0; + while (1) { + my $erflag = 0; + $msgs = child_process($grouphashref, $iphashref, $rspdevref, $req, $node); + foreach my $port (keys %$msgs) { unless ($msgs->{$port} =~ /successful/) { $erflag = 1; - last; - } - } - if ($erflag) { - $report = (); - foreach my $port1 (keys %$msgs){ - $report .= $port1.":".$msgs->{$port1}.";"; + last; } - xCAT::MsgUtils->verbose_message($req, "========> try again, $report"); - #send_msg( $req, 0, "========> try again, $report"); - sleep 3; - $time++; - } else { + } + if ($erflag) { + $report = (); + foreach my $port1 (keys %$msgs) { + $report .= $port1 . ":" . $msgs->{$port1} . ";"; + } + xCAT::MsgUtils->verbose_message($req, "========> try again, $report"); + + #send_msg( $req, 0, "========> try again, $report"); + sleep 3; + $time++; + } else { last; } - last if ($time > 10); - } - $report = (); - foreach my $port (keys %$msgs){ - $report .= $port.":".$msgs->{$port}.";"; + last if ($time > 10); } - send_msg( $req, 0, "Resetnet result for $node is : $report"); + $report = (); + foreach my $port (keys %$msgs) { + $report .= $port . ":" . $msgs->{$port} . ";"; + } + send_msg($req, 0, "Resetnet result for $node is : $report"); #################################### # Pass result array back to parent #################################### my %data; - $data{errorcode} = 0; + $data{errorcode} = 0; my $out = $req->{pipe}; - print $out freeze( [\%data] ); + print $out freeze([ \%data ]); print $out "\nENDOFFREEZE6sK4ci\n"; exit(0); } else { ################################### # Parent process ################################### - close( $child ); - $pipe = $parent ; + close($child); + $pipe = $parent; } - if ( $pipe ) { - $fds->add( $pipe ); + if ($pipe) { + $fds->add($pipe); $children++; } } ############################################# # Process responses from children ############################################# - while ( $children > 0 ) { - child_response( $callback, $fds ); + while ($children > 0) { + child_response($callback, $fds); } - while (child_response($callback,$fds)) {} + while (child_response($callback, $fds)) { } my $elapsed = Time::HiRes::gettimeofday() - $start; - my $msg = sprintf( "Total rspconfig Time: %.3f sec\n", $elapsed ); + my $msg = sprintf("Total rspconfig Time: %.3f sec\n", $elapsed); xCAT::MsgUtils->verbose_message($req, $msg); return undef; @@ -985,10 +995,10 @@ sub doresetnet { ########################################################################## sub child_process { my $grouphashref = shift; - my $iphashref = shift; - my $rspdevref = shift; - my $req = shift; - my $node = shift; + my $iphashref = shift; + my $rspdevref = shift; + my $req = shift; + my $node = shift; my %msginfo; my @ns = split /,/, $grouphashref; my @valid_ips; @@ -999,38 +1009,38 @@ sub child_process { # ping static ip firstly, if succesufully, skip resetnet ########################################################## foreach my $fspport (@ns) { - my $ip = ${$iphashref->{$fspport}}{sip}; + my $ip = ${ $iphashref->{$fspport} }{sip}; my $rc = system("ping -q -n -c 1 -w 1 $ip > /dev/null"); if ($rc == 0) { - xCAT::MsgUtils->verbose_message( $req, "ping static $ip successfully"); - push @valid_ips, $ip; # static ip should be used first + xCAT::MsgUtils->verbose_message($req, "ping static $ip successfully"); + push @valid_ips, $ip; # static ip should be used first push @portsuccess, $fspport; $msginfo{$fspport} = "successful"; } else { - xCAT::MsgUtils->verbose_message( $req, "ping static $ip failed, need to do resetnet for $fspport"); + xCAT::MsgUtils->verbose_message($req, "ping static $ip failed, need to do resetnet for $fspport"); push @portneedreset, $fspport; } } - if (scalar (@portneedreset) == 0) { + if (scalar(@portneedreset) == 0) { return \%msginfo; } ########################################### # ping temp ip secondary ########################################### foreach my $fspport (@ns) { - my $ip = ${$iphashref->{$fspport}}{tip}; + my $ip = ${ $iphashref->{$fspport} }{tip}; my $rc = system("ping -q -n -c 1 -w 1 $ip > /dev/null"); if ($rc == 0) { push @valid_ips, $ip; - xCAT::MsgUtils->verbose_message( $req, "ping temp $ip successfully"); + xCAT::MsgUtils->verbose_message($req, "ping temp $ip successfully"); } else { - xCAT::MsgUtils->verbose_message( $req, "ping temp $ip failed"); + xCAT::MsgUtils->verbose_message($req, "ping temp $ip failed"); } } - if (scalar (@valid_ips) == 0) { + if (scalar(@valid_ips) == 0) { foreach my $fspport (@ns) { - $msginfo{$fspport} = "failed to find valid ip to log on"; - } + $msginfo{$fspport} = "failed to find valid ip to log on"; + } return \%msginfo; } ######################################### @@ -1039,119 +1049,119 @@ sub child_process { my @exp; my $goodip; my $retry = 2; - foreach my $ip(@valid_ips) { - @exp = xCAT::PPCcfg::connect(${$rspdevref->{$ip}}{username},${$rspdevref->{$ip}}{password}, $ip); + foreach my $ip (@valid_ips) { + @exp = xCAT::PPCcfg::connect(${ $rspdevref->{$ip} }{username}, ${ $rspdevref->{$ip} }{password}, $ip); #################################### # Successfully connected #################################### - if ( ref($exp[0]) eq "LWP::UserAgent" ) { - $goodip = $ip; - xCAT::MsgUtils->verbose_message( $req, "log in successfully with $ip"); - last; - } + if (ref($exp[0]) eq "LWP::UserAgent") { + $goodip = $ip; + xCAT::MsgUtils->verbose_message($req, "log in successfully with $ip"); + last; } - my $msg = "login result is :".join(',', @exp); - xCAT::MsgUtils->verbose_message( $req, $msg); + } + my $msg = "login result is :" . join(',', @exp); + xCAT::MsgUtils->verbose_message($req, $msg); #################################### # do resetnet #################################### unless ($goodip) { foreach my $fspport (@ns) { - $msginfo{$fspport} = "failed to log on with $exp[0]"; - } + $msginfo{$fspport} = "failed to log on with $exp[0]"; + } return \%msginfo; } my %handled; my $port; - if (scalar(@portneedreset) == 2 ) { ## do resetnet for the other port first - $port = $portneedreset[0]; - my $ip = ${$iphashref->{$port}}{sip}; - if ($goodip eq $ip) { - $port = $portneedreset[1]; - } - xCAT::MsgUtils->verbose_message( $req, "begin to reset for port $port.. good ip is $goodip, ip is $ip...................................."); + if (scalar(@portneedreset) == 2) { ## do resetnet for the other port first + $port = $portneedreset[0]; + my $ip = ${ $iphashref->{$port} }{sip}; + if ($goodip eq $ip) { + $port = $portneedreset[1]; + } + xCAT::MsgUtils->verbose_message($req, "begin to reset for port $port.. good ip is $goodip, ip is $ip...................................."); my $rc = system("ping -q -n -c 1 -w 1 $ip > /dev/null"); - unless ($rc == 0) { - $ip = ${$iphashref->{$port}}{tip}; - $handled{network} = $ip.",".${$rspdevref->{$ip}}{args}; - my @cmds = ("network=$ip,${$rspdevref->{$ip}}{args}"); + unless ($rc == 0) { + $ip = ${ $iphashref->{$port} }{tip}; + $handled{network} = $ip . "," . ${ $rspdevref->{$ip} }{args}; + my @cmds = ("network=$ip,${$rspdevref->{$ip}}{args}"); my %request = ( - ppcretry => 1, - verbose => 0, - ppcmaxp => 64, - ppctimeout => 0, - fsptimeout => 0, - ppcretry => 3, - maxssh => 8, - arg => \@cmds, - method => \%handled, - command => 'rspconfig', - hwtype => ${$rspdevref->{$ip}}{type}, - ); - xCAT::MsgUtils->verbose_message( $req, "Begin to do reset for $port, nic is $ip"); - my $result = xCAT::PPCfsp::handler($ip, \%request, \@exp, 1 ); - if ($result) { - my $errcode = ${@$result[0]}{errorcode}; - if ( $errcode == 0) { - $msginfo{$port} = "successful"; - } else { - my $node = ${@$result[0]}{node}; - $msginfo{$port} = @{${@{${@$node[0]}{data}}[0]}{contents}}[0]; - } - } else { - $msginfo{$port} = "failed with unknown reason"; - } - } else { + ppcretry => 1, + verbose => 0, + ppcmaxp => 64, + ppctimeout => 0, + fsptimeout => 0, + ppcretry => 3, + maxssh => 8, + arg => \@cmds, + method => \%handled, + command => 'rspconfig', + hwtype => ${ $rspdevref->{$ip} }{type}, + ); + xCAT::MsgUtils->verbose_message($req, "Begin to do reset for $port, nic is $ip"); + my $result = xCAT::PPCfsp::handler($ip, \%request, \@exp, 1); + if ($result) { + my $errcode = ${ @$result[0] }{errorcode}; + if ($errcode == 0) { + $msginfo{$port} = "successful"; + } else { + my $node = ${ @$result[0] }{node}; + $msginfo{$port} = @{ ${ @{ ${ @$node[0] }{data} }[0] }{contents} }[0]; + } + } else { + $msginfo{$port} = "failed with unknown reason"; + } + } else { $msginfo{$port} = "successful"; } - } + } if ($port) { - if ($port eq $portneedreset[0] ) { + if ($port eq $portneedreset[0]) { $port = $portneedreset[1]; } else { $port = $portneedreset[0]; } } else { $port = $portneedreset[0]; - } - xCAT::MsgUtils->verbose_message( $req, "begin to reset for port $port......................................"); - my $ip = ${$iphashref->{$port}}{sip}; - my $rc = system("ping -q -n -c 1 -w 1 $ip > /dev/null"); - unless ($rc == 0) { #should be unless!!!!!!!!!!!!! - $ip = ${$iphashref->{$port}}{tip}; - $handled{network} = $ip.",".${$rspdevref->{$ip}}{args}; - my @cmds = ("network=$ip,${$rspdevref->{$ip}}{args}"); - my %request = ( - ppcretry => 1, - verbose => 0, - ppcmaxp => 64, - ppctimeout => 0, - fsptimeout => 0, - ppcretry => 3, - maxssh => 8, - arg => \@cmds, - method => \%handled, - command => 'rspconfig', - hwtype => ${$rspdevref->{$ip}}{type}, - ); - xCAT::MsgUtils->verbose_message( $req, "Begin to do reset for $port, nic is $ip"); - my $result = xCAT::PPCfsp::handler($ip, \%request, \@exp); - if ($result) { - my $errcode = ${@$result[0]}{errorcode}; - if ( $errcode == 0) { - $msginfo{$port} = "successful"; - } else { - my $node = ${@$result[0]}{node}; - $msginfo{$port} = @{${@{${@$node[0]}{data}}[0]}{contents}}[0]; } - } else { - $msginfo{$port} = "failed with unknown reason"; - } - } else { - xCAT::PPCfsp::disconnect( \@exp ); + xCAT::MsgUtils->verbose_message($req, "begin to reset for port $port......................................"); + my $ip = ${ $iphashref->{$port} }{sip}; + my $rc = system("ping -q -n -c 1 -w 1 $ip > /dev/null"); + unless ($rc == 0) { #should be unless!!!!!!!!!!!!! + $ip = ${ $iphashref->{$port} }{tip}; + $handled{network} = $ip . "," . ${ $rspdevref->{$ip} }{args}; + my @cmds = ("network=$ip,${$rspdevref->{$ip}}{args}"); + my %request = ( + ppcretry => 1, + verbose => 0, + ppcmaxp => 64, + ppctimeout => 0, + fsptimeout => 0, + ppcretry => 3, + maxssh => 8, + arg => \@cmds, + method => \%handled, + command => 'rspconfig', + hwtype => ${ $rspdevref->{$ip} }{type}, + ); + xCAT::MsgUtils->verbose_message($req, "Begin to do reset for $port, nic is $ip"); + my $result = xCAT::PPCfsp::handler($ip, \%request, \@exp); + if ($result) { + my $errcode = ${ @$result[0] }{errorcode}; + if ($errcode == 0) { $msginfo{$port} = "successful"; - } + } else { + my $node = ${ @$result[0] }{node}; + $msginfo{$port} = @{ ${ @{ ${ @$node[0] }{data} }[0] }{contents} }[0]; + } + } else { + $msginfo{$port} = "failed with unknown reason"; + } + } else { + xCAT::PPCfsp::disconnect(\@exp); + $msginfo{$port} = "successful"; + } return \%msginfo; } @@ -1163,15 +1173,16 @@ sub get_rsp_dev my $request = shift; my $targets = shift; - my $mm = $targets->{'mm'} ? $targets->{'mm'} : {}; - my $hmc = $targets->{'hmc'} ? $targets->{'hmc'}: {}; - my $fsp = $targets->{'fsp'} ? $targets->{'fsp'}: {}; - my $bpa = $targets->{'bpa'} ? $targets->{'bpa'}: {}; + my $mm = $targets->{'mm'} ? $targets->{'mm'} : {}; + my $hmc = $targets->{'hmc'} ? $targets->{'hmc'} : {}; + my $fsp = $targets->{'fsp'} ? $targets->{'fsp'} : {}; + my $bpa = $targets->{'bpa'} ? $targets->{'bpa'} : {}; if (%$mm) { my $bladeuser = 'USERID'; my $bladepass = 'PASSW0RD'; + #if ( $verbose ) { # trace( $request, "telneting to management-modules....." ); #} @@ -1179,10 +1190,11 @@ sub get_rsp_dev # Check passwd table for userid/password ############################################# my $passtab = xCAT::Table->new('passwd'); - if ( $passtab ) { + if ($passtab) { + #my ($ent) = $passtab->getAttribs({key=>'blade'},'username','password'); - my $ent = $passtab->getNodeAttribs('blade', ['username','password']); - if ( defined( $ent )) { + my $ent = $passtab->getNodeAttribs('blade', [ 'username', 'password' ]); + if (defined($ent)) { $bladeuser = $ent->{username}; $bladepass = $ent->{password}; } @@ -1191,54 +1203,55 @@ sub get_rsp_dev # Get userid/password ############################################# my $mpatab = xCAT::Table->new('mpa'); - for my $nd ( keys %$mm ) { + for my $nd (keys %$mm) { my $user = $bladeuser; my $pass = $bladepass; - if ( defined( $mpatab )) { + if (defined($mpatab)) { + #my ($ent) = $mpatab->getAttribs({mpa=>$_},'username','password'); - my $ent = $mpatab->getNodeAttribs($nd, ['username','password']); - if ( defined( $ent->{password} )) { $pass = $ent->{password}; } - if ( defined( $ent->{username} )) { $user = $ent->{username}; } + my $ent = $mpatab->getNodeAttribs($nd, [ 'username', 'password' ]); + if (defined($ent->{password})) { $pass = $ent->{password}; } + if (defined($ent->{username})) { $user = $ent->{username}; } } $mm->{$nd}->{username} = $user; $mm->{$nd}->{password} = $pass; } } - if (%$hmc ) + if (%$hmc) { ############################################# # Get HMC userid/password ############################################# - foreach ( keys %$hmc ) { - ( $hmc->{$_}->{username}, $hmc->{$_}->{password}) = xCAT::PPCdb::credentials( $hmc->{$_}->{name}, lc($hmc->{$_}->{'type'}), "hscroot" ); - xCAT::MsgUtils->verbose_message( $request, "user/passwd for $_ is $hmc->{$_}->{username} $hmc->{$_}->{password}"); + foreach (keys %$hmc) { + ($hmc->{$_}->{username}, $hmc->{$_}->{password}) = xCAT::PPCdb::credentials($hmc->{$_}->{name}, lc($hmc->{$_}->{'type'}), "hscroot"); + xCAT::MsgUtils->verbose_message($request, "user/passwd for $_ is $hmc->{$_}->{username} $hmc->{$_}->{password}"); } } - if ( %$fsp) + if (%$fsp) { ############################################# # Get FSP userid/password ############################################# - foreach ( keys %$fsp ) { - ( $fsp->{$_}->{username}, $fsp->{$_}->{password}) = xCAT::PPCdb::credentials( $fsp->{$_}->{name}, lc($fsp->{$_}->{'type'}), "admin"); - xCAT::MsgUtils->verbose_message( $request, "user/passwd for $_ is $fsp->{$_}->{username} $fsp->{$_}->{password}"); + foreach (keys %$fsp) { + ($fsp->{$_}->{username}, $fsp->{$_}->{password}) = xCAT::PPCdb::credentials($fsp->{$_}->{name}, lc($fsp->{$_}->{'type'}), "admin"); + xCAT::MsgUtils->verbose_message($request, "user/passwd for $_ is $fsp->{$_}->{username} $fsp->{$_}->{password}"); } } - if ( %$bpa) + if (%$bpa) { ############################################# # Get BPA userid/password ############################################# - foreach ( keys %$bpa ) { - ( $bpa->{$_}->{username}, $bpa->{$_}->{password}) = xCAT::PPCdb::credentials( $bpa->{$_}->{name}, lc($bpa->{$_}->{'type'}), "admin"); - xCAT::MsgUtils->verbose_message( $request, "user/passwd for $_ is $bpa->{$_}->{username} $bpa->{$_}->{password}"); + foreach (keys %$bpa) { + ($bpa->{$_}->{username}, $bpa->{$_}->{password}) = xCAT::PPCdb::credentials($bpa->{$_}->{name}, lc($bpa->{$_}->{'type'}), "admin"); + xCAT::MsgUtils->verbose_message($request, "user/passwd for $_ is $bpa->{$_}->{username} $bpa->{$_}->{password}"); } } - return (%$mm,%$hmc,%$fsp,%$bpa); + return (%$mm, %$hmc, %$fsp, %$bpa); } ########################################################################## # Invokes the callback with the specified message @@ -1252,22 +1265,22 @@ sub send_msg { ################################################# # Called from child process - send to parent ################################################# - if ( exists( $request->{pipe} )) { + if (exists($request->{pipe})) { my $out = $request->{pipe}; $output{errorcode} = $ecode; - $output{data} = \@_; - print $out freeze( [\%output] ); + $output{data} = \@_; + print $out freeze([ \%output ]); print $out "\nENDOFFREEZE6sK4ci\n"; } ################################################# # Called from parent - invoke callback directly ################################################# - elsif ( exists( $request->{callback} )) { + elsif (exists($request->{callback})) { my $callback = $request->{callback}; $output{errorcode} = $ecode; - $output{data} = \@_; - $callback->( \%output ); + $output{data} = \@_; + $callback->(\%output); } } ########################################################################## @@ -1275,8 +1288,8 @@ sub send_msg { ########################################################################## sub child_response { - my $callback = shift; - my $fds = shift; + my $callback = shift; + my $fds = shift; my @ready_fds = $fds->can_read(1); foreach my $rfh (@ready_fds) { @@ -1285,7 +1298,7 @@ sub child_response { ################################# # Read from child process ################################# - if ( defined( $data )) { + if (defined($data)) { while ($data !~ /ENDOFFREEZE6sK4ci/) { $data .= <$rfh>; } @@ -1294,7 +1307,8 @@ sub child_response { ############################# # rspconfig results ############################# - if ( @$responses[0] =~ /^RSPCONFIG6sK4ci$/ ) { + if (@$responses[0] =~ /^RSPCONFIG6sK4ci$/) { + #shift @$responses; #my $ip = @$responses[0]; #my @rsp1 = (@$responses[1]); @@ -1309,8 +1323,8 @@ sub child_response { ############################# # Message or verbose trace ############################# - foreach ( @$responses ) { - $callback->( $_ ); + foreach (@$responses) { + $callback->($_); } next; } @@ -1327,9 +1341,9 @@ sub child_response { sub connect { my $username = shift; - my $passwd = shift; - my $server = shift; - my $verbose = shift; + my $passwd = shift; + my $server = shift; + my $verbose = shift; my $lwp_log; ################################## @@ -1340,10 +1354,10 @@ sub connect { ################################## # Redirect STDERR to variable ################################## - if ( $verbose ) { + if ($verbose) { close STDERR; - if ( !open( STDERR, '>', \$lwp_log )) { - return( "Unable to redirect STDERR: $!" ); + if (!open(STDERR, '>', \$lwp_log)) { + return ("Unable to redirect STDERR: $!"); } } $IO::Socket::SSL::VERSION = undef; @@ -1352,14 +1366,14 @@ sub connect { ################################## # Turn on tracing ################################## - if ( $verbose ) { - LWP::Debug::level( '+' ); + if ($verbose) { + LWP::Debug::level('+'); } ################################## # Create cookie ################################## my $cookie = HTTP::Cookies->new(); - $cookie->set_cookie( 0,'asm_session','0','cgi-bin','','443',0,0,3600,0 ); + $cookie->set_cookie(0, 'asm_session', '0', 'cgi-bin', '', '443', 0, 0, 3600, 0); ################################## # Create UserAgent @@ -1370,24 +1384,24 @@ sub connect { # Set options ################################## my $url = "https://$server/cgi-bin/cgi?form=2"; - $ua->cookie_jar( $cookie ); - $ua->timeout( $timeout ); + $ua->cookie_jar($cookie); + $ua->timeout($timeout); ################################## # Submit logon ################################## - my $res = $ua->post( $url, - [ user => $username, - password => $passwd, - lang => "0", - submit => "Log in" ] + my $res = $ua->post($url, + [ user => $username, + password => $passwd, + lang => "0", + submit => "Log in" ] ); ################################## # Logon failed ################################## - if ( !$res->is_success() ) { - return( $lwp_log.$res->status_line ); + if (!$res->is_success()) { + return ($lwp_log . $res->status_line); } ################################## # To minimize number of GET/POSTs, @@ -1396,7 +1410,7 @@ sub connect { # Set-Cookie: asm_session=3038839768778613290 # ################################## - if ( $res->as_string =~ /Set-Cookie: asm_session=(\d+)/ ) { + if ($res->as_string =~ /Set-Cookie: asm_session=(\d+)/) { ############################## # Successful logon.... # Return: @@ -1405,15 +1419,15 @@ sub connect { # UserId # Redirected STDERR/STDOUT ############################## - return( $ua, - $server, - $username, - \$lwp_log ); + return ($ua, + $server, + $username, + \$lwp_log); } ############################## # Logon error ############################## - $res = $ua->get( $url ); + $res = $ua->get($url); ############################## # Check for specific failures # $res->status_line is like "200 OK" @@ -1421,15 +1435,15 @@ sub connect { # $res->base is like https://41.17.4.2/cgi-bin/cgi?form=2 ############################## my $err; - if ( $res->content =~ /Too many users/i ) { + if ($res->content =~ /Too many users/i) { $err = "Too many users"; - }elsif ( $res->content =~ /Invalid user ID or password/i ) { + } elsif ($res->content =~ /Invalid user ID or password/i) { $err = "Invalid user ID or password"; - }else{ + } else { $err = "Logon failure with unknown reason"; } - return ($lwp_log.$err); + return ($lwp_log . $err); } diff --git a/perl-xCAT/xCAT/PPCcli.pm b/perl-xCAT/xCAT/PPCcli.pm index f625560bc..f128ff341 100644 --- a/perl-xCAT/xCAT/PPCcli.pm +++ b/perl-xCAT/xCAT/PPCcli.pm @@ -3,8 +3,8 @@ package xCAT::PPCcli; use strict; require Exporter; - our @ISA = qw(Exporter); - our @EXPORT_OK = qw(SUCCESS RC_ERROR EXPECT_ERROR NR_ERROR); +our @ISA = qw(Exporter); +our @EXPORT_OK = qw(SUCCESS RC_ERROR EXPECT_ERROR NR_ERROR); use Expect; use xCAT::NetworkUtils; @@ -14,75 +14,75 @@ use xCAT::NetworkUtils; $ENV{'TERM'} = "vt100"; ############################################## -# Constants +# Constants ############################################## use constant { - SUCCESS => 0, - RC_ERROR => 1, - EXPECT_ERROR => 2, - NR_ERROR => 3, - DEFAULT_TIMEOUT => 60 + SUCCESS => 0, + RC_ERROR => 1, + EXPECT_ERROR => 2, + NR_ERROR => 3, + DEFAULT_TIMEOUT => 60 }; ############################################## -# lssyscfg supported formats +# lssyscfg supported formats ############################################## my %lssyscfg = ( - fsp =>"lssyscfg -r sys -m %s -F %s", - cec =>"lssyscfg -r sys -m %s -F %s", - fsps =>"lssyscfg -r sys -F %s", - node =>"lssyscfg -r lpar -m %s -F %s --filter lpar_ids=%s", - lpar =>"lssyscfg -r lpar -m %s -F %s", - lpar2 =>"lssyscfg -r lpar -m %s --filter %s", - bpa =>"lssyscfg -r frame -e %s -F %s", - frame =>"lssyscfg -r frame -e %s -F %s", - bpas =>"lssyscfg -r frame -F %s", - prof =>"lssyscfg -r prof -m %s --filter %s", - profs =>"lssyscfg -r prof -m %s -F %s --filter %s", - cage =>"lssyscfg -r cage -e %s -F %s" + fsp => "lssyscfg -r sys -m %s -F %s", + cec => "lssyscfg -r sys -m %s -F %s", + fsps => "lssyscfg -r sys -F %s", + node => "lssyscfg -r lpar -m %s -F %s --filter lpar_ids=%s", + lpar => "lssyscfg -r lpar -m %s -F %s", + lpar2 => "lssyscfg -r lpar -m %s --filter %s", + bpa => "lssyscfg -r frame -e %s -F %s", + frame => "lssyscfg -r frame -e %s -F %s", + bpas => "lssyscfg -r frame -F %s", + prof => "lssyscfg -r prof -m %s --filter %s", + profs => "lssyscfg -r prof -m %s -F %s --filter %s", + cage => "lssyscfg -r cage -e %s -F %s" ); my %chsyscfg = ( - prof =>"chsyscfg -r prof -m %s -i %s", - bpa =>"chsyscfg -r frame -e %s -i %s", - fsp =>"chsyscfg -r sys -m %s -i %s", - frame =>"chsyscfg -r frame -e %s -i %s", - cec =>"chsyscfg -r sys -m %s -i %s", + prof => "chsyscfg -r prof -m %s -i %s", + bpa => "chsyscfg -r frame -e %s -i %s", + fsp => "chsyscfg -r sys -m %s -i %s", + frame => "chsyscfg -r frame -e %s -i %s", + cec => "chsyscfg -r sys -m %s -i %s", ); ############################################## -# Power control supported formats +# Power control supported formats ############################################## my %powercmd = ( - lpar => { - on =>"chsysstate -r %s -m %s -o on -b norm --id %s -f %s", - of =>"chsysstate -r %s -m %s -o on --id %s -f %s -b of", - sms =>"chsysstate -r %s -m %s -o on --id %s -f %s -b sms", - reset =>"chsysstate -r %s -m %s -o shutdown --id %s --immed --restart", - off =>"chsysstate -r %s -m %s -o shutdown --id %s --immed", - softoff =>"chsysstate -r %s -m %s -o shutdown --id %s", - boot =>"undetermined" }, - sys => { - reset =>"chsysstate -r %s -m %s -o off --immed --restart", - on =>"chsysstate -r %s -m %s -o on", - onstandby =>"chsysstate -r %s -m %s -o onstandby", - off =>"chsysstate -r %s -m %s -o off", - boot =>"undetermined" } + lpar => { + on => "chsysstate -r %s -m %s -o on -b norm --id %s -f %s", + of => "chsysstate -r %s -m %s -o on --id %s -f %s -b of", + sms => "chsysstate -r %s -m %s -o on --id %s -f %s -b sms", + reset => "chsysstate -r %s -m %s -o shutdown --id %s --immed --restart", + off => "chsysstate -r %s -m %s -o shutdown --id %s --immed", + softoff => "chsysstate -r %s -m %s -o shutdown --id %s", + boot => "undetermined" }, + sys => { + reset => "chsysstate -r %s -m %s -o off --immed --restart", + on => "chsysstate -r %s -m %s -o on", + onstandby => "chsysstate -r %s -m %s -o onstandby", + off => "chsysstate -r %s -m %s -o off", + boot => "undetermined" } ); ############################################## # lsrefcode supported formats ############################################## my %lsrefcode = ( - fsp => { - pri =>"lsrefcode -r sys -m %s -s p", - sec =>"lsrefcode -r sys -m %s -s s", - }, - cec => { - pri =>"lsrefcode -r sys -m %s -s p", - sec =>"lsrefcode -r sys -m %s -s s", - }, - lpar =>"lsrefcode -r lpar -m %s --filter lpar_ids=%s", + fsp => { + pri => "lsrefcode -r sys -m %s -s p", + sec => "lsrefcode -r sys -m %s -s s", + }, + cec => { + pri => "lsrefcode -r sys -m %s -s p", + sec => "lsrefcode -r sys -m %s -s s", + }, + lpar => "lsrefcode -r lpar -m %s --filter lpar_ids=%s", ); ############################################## @@ -141,46 +141,46 @@ sub connect { my $ssh; my $expect_log = "/dev/null"; my $errmsg; - + if ($req->{command} eq 'rflash') { - $verbose = 0; + $verbose = 0; } ################################################## - # Use timeout from site table (if defined) + # Use timeout from site table (if defined) ################################################## - if ( !$timeout ) { - $timeout = DEFAULT_TIMEOUT; + if (!$timeout) { + $timeout = DEFAULT_TIMEOUT; } ################################################## - # Shell prompt regexp based on HW Type + # Shell prompt regexp based on HW Type ################################################## my %prompt = ( hmc => "~>\\s*\$", ivm => "\\\$ \$" ); ################################################## - # Get userid/password + # Get userid/password ################################################## - my $cred = $req->{$server}{cred}; + my $cred = $req->{$server}{cred}; my $parameters = "@$cred[0]\@$server"; ################################################## # Redirect STDERR to variable ################################################## - if ( $verbose ) { + if ($verbose) { close STDERR; - if ( !open( STDERR, '>', $expect_log )) { - return( "Unable to redirect STDERR: $!" ); + if (!open(STDERR, '>', $expect_log)) { + return ("Unable to redirect STDERR: $!"); } } ################################################## # Redirect STDOUT to variable ################################################## - if ( $verbose ) { + if ($verbose) { close STDOUT; - if ( !open( STDOUT, '>', $expect_log )) { - return( "Unable to redirect STDOUT: $!" ); + if (!open(STDOUT, '>', $expect_log)) { + return ("Unable to redirect STDOUT: $!"); } } ###################################################### @@ -195,10 +195,10 @@ sub connect { # sending the password. # ###################################################### - while ( $retry-- ) { + while ($retry--) { my $success = 0; my $pwd_sent = 0; - $expect_log = undef; + $expect_log = undef; $ssh = new Expect; @@ -218,41 +218,41 @@ sub connect { # exp_internal(1) sets exp_internal debugging # to STDERR. ################################################## - $ssh->exp_internal( $verbose ); + $ssh->exp_internal($verbose); ################################################## # log_stdout(0) disables logging to STDOUT. # This corresponds to the Tcl log_user variable. ################################################## - $ssh->log_stdout( $verbose ); + $ssh->log_stdout($verbose); - unless ( $ssh->spawn( "ssh", $parameters )) { - return( $expect_log."Unable to spawn ssh connection to server"); + unless ($ssh->spawn("ssh", $parameters)) { + return ($expect_log . "Unable to spawn ssh connection to server"); } - my @result = $ssh->expect( $timeout, + my @result = $ssh->expect($timeout, [ $continue, - sub { - $ssh->send( "yes\r" ); - $ssh->clear_accum(); - $ssh->exp_continue(); - } ], + sub { + $ssh->send("yes\r"); + $ssh->clear_accum(); + $ssh->exp_continue(); + } ], [ $pwd_prompt, - sub { - if ( ++$pwd_sent ) { - $ssh->send( "@$cred[1]\r" ); - $ssh->exp_continue(); - } - } ], + sub { + if (++$pwd_sent) { + $ssh->send("@$cred[1]\r"); + $ssh->exp_continue(); + } + } ], [ $prompt{$hwtype}, - sub { - $success = 1; - } ] + sub { + $success = 1; + } ] ); ########################################## # Expect error - retry ########################################## - if ( defined( $result[1] )) { - $errmsg = $expect_log.expect_error(@result); + if (defined($result[1])) { + $errmsg = $expect_log . expect_error(@result); sleep(1); next; } @@ -268,24 +268,24 @@ sub connect { # Redirected STDERR/STDOUT # Connect/Command timeout ########################################## - if ( $success ) { - return( $ssh, - $prompt{$hwtype}, - $hwtype, - $server, - @$cred[0], - @$cred[1], - \$expect_log, - $timeout ); + if ($success) { + return ($ssh, + $prompt{$hwtype}, + $hwtype, + $server, + @$cred[0], + @$cred[1], + \$expect_log, + $timeout); } ########################################## # Failed logon - kill ssh process ########################################## $ssh->hard_close(); - return( $expect_log."Invalid userid/password" ); + return ($expect_log . "Invalid userid/password"); } $ssh->hard_close(); - return( $errmsg ); + return ($errmsg); } @@ -297,8 +297,8 @@ sub disconnect { my $exp = shift; my $ssh = @$exp[0]; - if ( defined( $ssh )) { - $ssh->send( "exit\r" ); + if (defined($ssh)) { + $ssh->send("exit\r"); $ssh->hard_close(); @$exp[0] = undef; } @@ -317,15 +317,15 @@ sub lssyscfg { my $d3 = shift; ################################### - # Select command + # Select command ################################### - my $cmd = sprintf( $lssyscfg{$res}, $d1, $d2, $d3 ); + my $cmd = sprintf($lssyscfg{$res}, $d1, $d2, $d3); ################################### # Send command ################################### - my $result = send_cmd( $exp, $cmd ); - return( $result ); + my $result = send_cmd($exp, $cmd); + return ($result); } @@ -342,13 +342,13 @@ sub chsyscfg { ##################################### # Select command ##################################### - my $cmd = sprintf( $chsyscfg{$res}, @$d[2], $cfgdata ); + my $cmd = sprintf($chsyscfg{$res}, @$d[2], $cfgdata); ##################################### # Send command ##################################### - my $result = send_cmd( $exp, $cmd ); - return( $result ); + my $result = send_cmd($exp, $cmd); + return ($result); } ########################################################################## @@ -356,41 +356,41 @@ sub chsyscfg { ########################################################################## sub lsrefcode { - my $exp = shift; - my $res = shift; - my $d1 = shift; - my $d2 = shift; - my $cmd = undef; - my @cmds = undef; + my $exp = shift; + my $res = shift; + my $d1 = shift; + my $d2 = shift; + my $cmd = undef; + my @cmds = undef; my $result = undef; my @values; ################################### - # Select command + # Select command ################################### - if($res =~ /^(fsp|cec)$/) { + if ($res =~ /^(fsp|cec)$/) { $cmds[0] = sprintf($lsrefcode{$res}{pri}, $d1); $cmds[1] = sprintf($lsrefcode{$res}{sec}, $d1); - } elsif($res eq 'lpar'){ + } elsif ($res eq 'lpar') { $cmds[0] = sprintf($lsrefcode{$res}, $d1, $d2); } else { - return [[0,'Not available']]; + return [ [ 0, 'Not available' ] ]; } ################################### # Send command ################################### - foreach $cmd (@cmds){ - $result = send_cmd( $exp, $cmd ); + foreach $cmd (@cmds) { + $result = send_cmd($exp, $cmd); push @values, $result; } return \@values; } ########################################################################## -# Creates a logical partition on the managed system +# Creates a logical partition on the managed system ########################################################################## sub mksyscfg { @@ -400,21 +400,21 @@ sub mksyscfg { my $cfgdata = shift; ##################################### - # Command only support on LPARs + # Command only support on LPARs ##################################### - if ( @$d[4] ne "lpar" ) { - return( [RC_ERROR,"Command not supported on '@$d[4]'"] ); + if (@$d[4] ne "lpar") { + return ([ RC_ERROR, "Command not supported on '@$d[4]'" ]); } ##################################### # Format command based on CEC name ##################################### - my $cmd = "mksyscfg -r $res -m @$d[2] -i \"$cfgdata\""; + my $cmd = "mksyscfg -r $res -m @$d[2] -i \"$cfgdata\""; ##################################### # Send command ##################################### - my $result = send_cmd( $exp, $cmd ); - return( $result ); + my $result = send_cmd($exp, $cmd); + return ($result); } @@ -423,14 +423,14 @@ sub mksyscfg { ########################################################################## sub rmsyscfg { - my $exp = shift; - my $d = shift; + my $exp = shift; + my $d = shift; ##################################### - # Command only supported on LPARs + # Command only supported on LPARs ##################################### - if ( @$d[4] ne "lpar" ) { - return( [RC_ERROR,"Command not supported on '@$d[4]'"] ); + if (@$d[4] ne "lpar") { + return ([ RC_ERROR, "Command not supported on '@$d[4]'" ]); } ##################################### # Format command based on CEC name @@ -440,13 +440,13 @@ sub rmsyscfg { ##################################### # Send command ##################################### - my $result = send_cmd( $exp, $cmd ); - return( $result ); + my $result = send_cmd($exp, $cmd); + return ($result); } ########################################################################## -# Lists environmental information +# Lists environmental information ########################################################################## sub lshwinfo { @@ -463,8 +463,8 @@ sub lshwinfo { ##################################### # Send command ##################################### - my $result = send_cmd( $exp, $cmd ); - return( $result ); + my $result = send_cmd($exp, $cmd); + return ($result); } @@ -480,24 +480,24 @@ sub chsysstate { ##################################### # Format command based on CEC name ##################################### - my $cmd = power_cmd( $op, $d ); - if ( !defined( $cmd )) { - return( [RC_ERROR,"'$op' command not supported"] ); + my $cmd = power_cmd($op, $d); + if (!defined($cmd)) { + return ([ RC_ERROR, "'$op' command not supported" ]); } ##################################### - # Special case - return immediately + # Special case - return immediately ##################################### - if ( $cmd =~ /^reboot$/ ) { + if ($cmd =~ /^reboot$/) { my $ssh = @$exp[0]; - $ssh->send( "$cmd\r" ); - return( [SUCCESS,"Success"] ); + $ssh->send("$cmd\r"); + return ([ SUCCESS, "Success" ]); } ##################################### # Send command ##################################### - my $result = send_cmd( $exp, $cmd ); - return( $result ); + my $result = send_cmd($exp, $cmd); + return ($result); } @@ -505,7 +505,7 @@ sub chsysstate { ########################################################################## # Opens a virtual terminal session ########################################################################## -sub mkvterm { +sub mkvterm { my $exp = shift; my $type = shift; @@ -520,8 +520,8 @@ sub mkvterm { # Format command based on HW Type ########################################## my %mkvt = ( - hmc =>"mkvterm --id %s -m %s", - ivm =>"mkvt -id %s" + hmc => "mkvterm --id %s -m %s", + ivm => "mkvt -id %s" ); ########################################## # HMC returns: @@ -531,37 +531,37 @@ sub mkvterm { # Exiting...." # # HMCs may also return: - # "The open failed. - # "-The session may already be open on + # "The open failed. + # "-The session may already be open on # another management console" # # But Expect (for some reason) sees each # character preceeded with \000 (blank??) # ########################################## - my $fail_msg = "HSCL"; - my $ivm_open = "Virtual terminal is already connected"; - my $hmc_open = "\000o\000p\000e\000n\000 \000f\000a\000i\000l\000e\000d"; + my $fail_msg = "HSCL"; + my $ivm_open = "Virtual terminal is already connected"; + my $hmc_open = "\000o\000p\000e\000n\000 \000f\000a\000i\000l\000e\000d"; my $hmc_open2 = - "\000a\000l\000r\000e\000a\000d\000y\000 \000o\000p\000e\000n"; + "\000a\000l\000r\000e\000a\000d\000y\000 \000o\000p\000e\000n"; ########################################## # Set command based on HW type - # mkvterm -id lparid -m cecmtms + # mkvterm -id lparid -m cecmtms ########################################## - my $cmd = sprintf( $mkvt{$hwtype}, $lparid, $mtms ); - if ( $type ne "lpar" ) { - return( [RC_ERROR,"Command not supported on '$type'"] ); + my $cmd = sprintf($mkvt{$hwtype}, $lparid, $mtms); + if ($type ne "lpar") { + return ([ RC_ERROR, "Command not supported on '$type'" ]); } ########################################## # Close the old sessions ########################################## - if ( $hwtype eq "ivm" ) { - rmvterm( $exp, $lparid, $mtms ); + if ($hwtype eq "ivm") { + rmvterm($exp, $lparid, $mtms); sleep 1; } else { - rmvterm_noforce( $exp, $lparid, $mtms ); + rmvterm_noforce($exp, $lparid, $mtms); sleep 1; } @@ -569,25 +569,25 @@ sub mkvterm { # Send command ########################################## $ssh->clear_accum(); - $ssh->send( "$cmd\r" ); + $ssh->send("$cmd\r"); ########################################## - # Expect result + # Expect result ########################################## - my @result = $ssh->expect( $timeout, + my @result = $ssh->expect($timeout, [ "$hmc_open|$hmc_open2|$ivm_open|$fail_msg", - sub { - $failed = 1; - } ] + sub { + $failed = 1; + } ] ); - if ( $failed ) { + if ($failed) { $ssh->hard_close(); - if (grep(/$fail_msg/, @result)) { - return( [RC_ERROR, "mkvterm returns the unsuccessful value, please check your entry and retry the command."] ); - } else { - return( [RC_ERROR,"Virtual terminal is already connected"] ); - } + if (grep(/$fail_msg/, @result)) { + return ([ RC_ERROR, "mkvterm returns the unsuccessful value, please check your entry and retry the command." ]); + } else { + return ([ RC_ERROR, "Virtual terminal is already connected" ]); + } } ########################################## @@ -596,16 +596,16 @@ sub mkvterm { # the Ctrl-X (\030). ########################################## my $escape = "\030"; - $ssh->send( "\r" ); - $ssh->interact( \*STDIN, $escape ); - + $ssh->send("\r"); + $ssh->interact(\*STDIN, $escape); + ########################################## # Close session ########################################## - rmvterm( $exp, $lparid, $mtms ); + rmvterm($exp, $lparid, $mtms); $ssh->hard_close(); - return( [SUCCESS,"Success"] ); + return ([ SUCCESS, "Success" ]); } @@ -624,20 +624,20 @@ sub rmvterm { # Format command based on HW Type ##################################### my %rmvt = ( - hmc =>"rmvterm --id %s -m %s", - ivm =>"rmvt -id %s" + hmc => "rmvterm --id %s -m %s", + ivm => "rmvt -id %s" ); ##################################### # Set command based on HW type - # rmvt(erm) -id lparid -m cecmtms + # rmvt(erm) -id lparid -m cecmtms ##################################### - my $cmd = sprintf( $rmvt{$hwtype}, $lparid, $mtms ); + my $cmd = sprintf($rmvt{$hwtype}, $lparid, $mtms); ##################################### # Send command ##################################### $ssh->clear_accum(); - $ssh->send( "$cmd\r" ); + $ssh->send("$cmd\r"); } ########################################################################## @@ -655,25 +655,25 @@ sub rmvterm_noforce { # Format command based on HW Type ##################################### my %rmvt = ( - hmc =>"rmvterm --id %s -m %s", - ivm =>"rmvt -id %s" + hmc => "rmvterm --id %s -m %s", + ivm => "rmvt -id %s" ); ##################################### # Set command based on HW type # rmvt(erm) -id lparid -m cecmtms ##################################### - my $cmd = sprintf( $rmvt{$hwtype}, $lparid, $mtms ); + my $cmd = sprintf($rmvt{$hwtype}, $lparid, $mtms); ##################################### # Send command ##################################### - send_cmd( $exp, $cmd ); + send_cmd($exp, $cmd); } ########################################################################## -# Lists the hardware resources of a managed system +# Lists the hardware resources of a managed system ########################################################################## sub lshwres { @@ -688,29 +688,29 @@ sub lshwres { ##################################### # Specify Filters ##################################### - if ( $Filter ) { - $cmd .=" -F $Filter"; - } - + if ($Filter) { + $cmd .= " -F $Filter"; + } + ##################################### - # level may be "sys" or "lpar" + # level may be "sys" or "lpar" ##################################### - if ( defined( $level )) { - $cmd .=" --level $level"; + if (defined($level)) { + $cmd .= " --level $level"; } ##################################### # Specify subtype ##################################### - if ( $rsubtype ) { - $cmd .=" --rsubtype $rsubtype" + if ($rsubtype) { + $cmd .= " --rsubtype $rsubtype" } ##################################### # Send command ##################################### - my $result = send_cmd( $exp, $cmd ); - return( $result ); + my $result = send_cmd($exp, $cmd); + return ($result); } @@ -724,63 +724,63 @@ sub lpar_netboot { my $name = shift; my $d = shift; my $opt = shift; - my $timeout = my $t = @$exp[7]*10; + my $timeout = my $t = @$exp[7] * 10; my $cmd = "lpar_netboot -t ent -f"; my $gateway = $opt->{G}; my $node = @$d[6]; ##################################### - # Power6 HMCs (V7) do not support - # 0.0.0.0 gateway. + # Power6 HMCs (V7) do not support + # 0.0.0.0 gateway. ##################################### - if ( $gateway =~ /^0.0.0.0$/ ) { - my $fw = lshmc( $exp, "RM" ); + if ($gateway =~ /^0.0.0.0$/) { + my $fw = lshmc($exp, "RM"); my $Rc = shift(@$fw); - - if ( $Rc == SUCCESS ) { - if ( @$fw[0] =~ /^V(\d+)/ ) { + + if ($Rc == SUCCESS) { + if (@$fw[0] =~ /^V(\d+)/) { ######################### # Power4 not supported ######################### - if ( $1 < 6 ) { - return( [RC_ERROR,"Command not supported on V$1 HMC"] ); - } + if ($1 < 6) { + return ([ RC_ERROR, "Command not supported on V$1 HMC" ]); + } ######################### - # Use server for gateway + # Use server for gateway ######################### - elsif ( $1 >= 7 ) { + elsif ($1 >= 7) { $opt->{G} = $opt->{S}; } } } } ##################################### - # Verbose output + # Verbose output ##################################### - if ( $verbose ) { - $cmd.= " -x -v"; + if ($verbose) { + $cmd .= " -x -v"; } ##################################### # Force LPAR shutdown if -f specified ##################################### - if ( exists( $opt->{f} )) { - $cmd.= " -i"; + if (exists($opt->{f})) { + $cmd .= " -i"; } else { ################################# # Force LPAR shutdown if LPAR is # running Linux ################################# - my $table = "nodetype"; - my $intable = 0; + my $table = "nodetype"; + my $intable = 0; my @TableRowArray = xCAT::DBobjUtils->getDBtable($table); - if ( @TableRowArray ) { - foreach ( @TableRowArray ) { + if (@TableRowArray) { + foreach (@TableRowArray) { my @nodelist = split(',', $_->{'node'}); - my @oslist = split(',', $_->{'os'}); - my $osname = "AIX"; - if ( grep(/^$node$/, @nodelist) ) { - if ( !grep(/^$osname$/, @oslist) ) { - $cmd.= " -i"; + my @oslist = split(',', $_->{'os'}); + my $osname = "AIX"; + if (grep(/^$node$/, @nodelist)) { + if (!grep(/^$osname$/, @oslist)) { + $cmd .= " -i"; } $intable = 1; last; @@ -789,11 +789,11 @@ sub lpar_netboot { } ################################# # Force LPAR shutdown if LPAR OS - # type is not assigned in table + # type is not assigned in table # but mnt node is running Linux ################################# - if ( xCAT::Utils->isLinux() && $intable == 0 ) { - $cmd.= " -i"; + if (xCAT::Utils->isLinux() && $intable == 0) { + $cmd .= " -i"; } } @@ -801,45 +801,45 @@ sub lpar_netboot { # Get MAC-address or network boot ##################################### my $mac = $opt->{m}; - $cmd.= ( defined( $mac )) ? " -m $mac" : " -M -A -n"; - + $cmd .= (defined($mac)) ? " -m $mac" : " -M -A -n"; + ##################################### # Command only supported on LPARs ##################################### - if ( @$d[4] ne "lpar" ) { - return( [RC_ERROR,"Command not supported on '@$d[4]'"] ); + if (@$d[4] ne "lpar") { + return ([ RC_ERROR, "Command not supported on '@$d[4]'" ]); } ##################################### # Network specified (-D ping test) ##################################### - if ( exists( $opt->{S} )) { - my %nethash = xCAT::DBobjUtils->getNetwkInfo( [$node] ); + if (exists($opt->{S})) { + my %nethash = xCAT::DBobjUtils->getNetwkInfo([$node]); ##################################### # Network attributes undefined ##################################### - if ( !%nethash ) { - return( [RC_ERROR,"Cannot get network information for $node"] ); + if (!%nethash) { + return ([ RC_ERROR, "Cannot get network information for $node" ]); } my $netmask = $nethash{$node}{mask}; - $cmd.= (!defined( $mac )) ? " -D" : ""; - $cmd.= " -s auto -d auto -S $opt->{S} -G $opt->{G} -C $opt->{C} -K $netmask"; + $cmd .= (!defined($mac)) ? " -D" : ""; + $cmd .= " -s auto -d auto -S $opt->{S} -G $opt->{G} -C $opt->{C} -K $netmask"; } ##################################### - # Add lpar name, profile, CEC name + # Add lpar name, profile, CEC name ##################################### - $cmd.= " \"$name\" \"@$d[1]\" \"@$d[2]\""; + $cmd .= " \"$name\" \"@$d[1]\" \"@$d[2]\""; ##################################### # Send command ##################################### - my $result = send_cmd( $exp, $cmd, $timeout ); - return( $result ); + my $result = send_cmd($exp, $cmd, $timeout); + return ($result); } ########################################################################## -# List Hardware Management Console configuration information +# List Hardware Management Console configuration information ########################################################################## sub lshmc { @@ -851,36 +851,36 @@ sub lshmc { # Format command based on HW Type ##################################### my %cmd = ( - hmc =>"lshmc -v", - ivm =>"lsivm" + hmc => "lshmc -v", + ivm => "lsivm" ); ##################################### # Send command ##################################### - my $result = send_cmd( $exp, $cmd{$hwtype} ); + my $result = send_cmd($exp, $cmd{$hwtype}); ##################################### # Return error ##################################### - if ( @$result[0] != SUCCESS ) { - return( $result ); - } + if (@$result[0] != SUCCESS) { + return ($result); + } ##################################### # Only return attribute requested ##################################### - if ( defined( $attr )) { - if ( my ($vpd) = grep( /^\*$attr\s/, @$result )) { + if (defined($attr)) { + if (my ($vpd) = grep(/^\*$attr\s/, @$result)) { $vpd =~ s/\*$attr\s+//; - return( [SUCCESS, $vpd ] ); + return ([ SUCCESS, $vpd ]); } - return( [RC_ERROR, "'$attr' not found"] ); + return ([ RC_ERROR, "'$attr' not found" ]); } ##################################### # IVM returns: # 9133-55A,10B7D1G,1 # - # HMC returns: + # HMC returns: # "vpd=*FC ???????? # *VC 20.0 # *N2 Mon Sep 24 13:54:00 GMT 2007 @@ -897,19 +897,19 @@ sub lshmc { # *DS Platform Firmware # *RM V7R3.1.0.1 ##################################### - if ( $hwtype eq "ivm" ) { - my ($model,$serial,$lparid) = split /,/, @$result[1]; - return( [SUCCESS,"$model,$serial"] ); + if ($hwtype eq "ivm") { + my ($model, $serial, $lparid) = split /,/, @$result[1]; + return ([ SUCCESS, "$model,$serial" ]); } my @values; - my $vpd = join( ",", @$result ); + my $vpd = join(",", @$result); ##################################### # Power4 (and below) HMCs unsupported ##################################### - if ( $vpd =~ /\*RM V(\d+)/ ) { - if ( $1 <= 5 ) { - return( [RC_ERROR,"Command not supported on V$1 HMC"] ); + if ($vpd =~ /\*RM V(\d+)/) { + if ($1 <= 5) { + return ([ RC_ERROR, "Command not supported on V$1 HMC" ]); } } ##################################### @@ -917,18 +917,18 @@ sub lshmc { # "eserver xSeries 336 -[7310CR3]-" # "7310-CR4" ##################################### - if ( $vpd =~ /\*TM ([^,]+)/ ) { - my $temp = $1; - my $model = ($temp =~ /\[(.*)\]/) ? $1 : $temp; + if ($vpd =~ /\*TM ([^,]+)/) { + my $temp = $1; + my $model = ($temp =~ /\[(.*)\]/) ? $1 : $temp; push @values, $model; } ##################################### # Serial number ##################################### - if ( $vpd =~ /\*SE ([^,]+)/ ) { + if ($vpd =~ /\*SE ([^,]+)/) { push @values, $1; } - return( [SUCCESS,join( ",",@values)] ); + return ([ SUCCESS, join(",", @values) ]); } @@ -947,54 +947,54 @@ sub mkauthkeys { my $userid = @$exp[4]; ######################################### - # On IVM-based systems, the mkauthkeys - # command does not exist, so we have to - # include the generated key at - # /home//.ssh/authorized_keys2 - # manually. + # On IVM-based systems, the mkauthkeys + # command does not exist, so we have to + # include the generated key at + # /home//.ssh/authorized_keys2 + # manually. ######################################### - if ( $hwtype =~ /^ivm$/ ) { - my @authkey; + if ($hwtype =~ /^ivm$/) { + my @authkey; my $auth = "/home/$userid/.ssh/authorized_keys2"; - my $result = send_cmd( $exp, "cat $auth" ); - my $Rc = shift(@$result); + my $result = send_cmd($exp, "cat $auth"); + my $Rc = shift(@$result); ##################################### # Return error ##################################### - if ( $Rc != SUCCESS ) { - return( $result ); + if ($Rc != SUCCESS) { + return ($result); } ##################################### # When adding, remove old keys first ##################################### - foreach ( @$result ) { - unless ( /$logon$/ ) { + foreach (@$result) { + unless (/$logon$/) { push @authkey, $_; } } ##################################### - # Add new key + # Add new key ##################################### - if ( $option =~ /^enable$/i ) { + if ($option =~ /^enable$/i) { push @authkey, $sshkey; } ##################################### - # Rewrite the key file + # Rewrite the key file ##################################### - my $keys = join( "\n", @authkey ); - $result = send_cmd( $exp,"echo \"$keys\" | tee $auth" ); - return( $result ); + my $keys = join("\n", @authkey); + $result = send_cmd($exp, "echo \"$keys\" | tee $auth"); + return ($result); } ######################################### # When adding, remove old keys first ######################################### - my $result = send_cmd( $exp,"mkauthkeys --remove '$logon'" ); - - if ( $option =~ /^enable$/i ) { - $result = send_cmd( $exp,"mkauthkeys --add '$sshkey'" ); + my $result = send_cmd($exp, "mkauthkeys --remove '$logon'"); + + if ($option =~ /^enable$/i) { + $result = send_cmd($exp, "mkauthkeys --add '$sshkey'"); } - return( $result ); + return ($result); } @@ -1003,41 +1003,41 @@ sub mkauthkeys { ########################################################################## sub lslic { - my $exp = shift; - my $d = shift; + my $exp = shift; + my $d = shift; my $timeout = shift; - my $cmd = "lslic "; - + my $cmd = "lslic "; + ########################################## - # Use timeout from site table (if defined) + # Use timeout from site table (if defined) ########################################## - if ( !defined( $timeout ) || $timeout == 0 ) { + if (!defined($timeout) || $timeout == 0) { $timeout = @$exp[7] * 3; } ##################################### # Command only support on CEC/BPAs ##################################### - if ( @$d[4] !~ /^(fsp|bpa)$/ ) { - return( [RC_ERROR,"Command not supported on '@$d[4]'"] ); + if (@$d[4] !~ /^(fsp|bpa)$/) { + return ([ RC_ERROR, "Command not supported on '@$d[4]'" ]); } ##################################### # Format command based on name ##################################### - $cmd.= (@$d[4] =~ /^fsp$/) ? "-t sys -m " : "-t power -e "; - $cmd.= @$d[2]; + $cmd .= (@$d[4] =~ /^fsp$/) ? "-t sys -m " : "-t power -e "; + $cmd .= @$d[2]; ##################################### # Send command ##################################### - my $result = send_cmd( $exp, $cmd , $timeout); - return( $result ); + my $result = send_cmd($exp, $cmd, $timeout); + return ($result); } ########################################################################## -# Sends command and waits for response +# Sends command and waits for response ########################################################################## sub send_cmd { @@ -1048,17 +1048,17 @@ sub send_cmd { my $prompt = @$exp[1]; ########################################## - # Use timeout from site table (if defined) + # Use timeout from site table (if defined) ########################################## - if ( !defined( $timeout )) { + if (!defined($timeout)) { $timeout = @$exp[7]; } ########################################## - # Send command + # Send command ########################################## $ssh->clear_accum(); - $ssh->send( "$cmd; echo Rc=\$\?\r" ); + $ssh->send("$cmd; echo Rc=\$\?\r"); ########################################## # The first element is the number of the # pattern or string that matched, the @@ -1075,40 +1075,40 @@ sub send_cmd { # is text before the match, and the fifth # argument is text after the match. ########################################## - my @result = $ssh->expect( $timeout, "-re", "(.*$prompt)" ); - + my @result = $ssh->expect($timeout, "-re", "(.*$prompt)"); + ########################################## - # Expect error + # Expect error ########################################## - if ( defined( $result[1] )) { - return( [EXPECT_ERROR,expect_error( @result )] ); - } + if (defined($result[1])) { + return ([ EXPECT_ERROR, expect_error(@result) ]); + } ########################################## # Extract error code ########################################## - if ( $result[3] =~ s/Rc=([0-9])+\r\n// ) { - if ( $1 != 0 ) { - return( [RC_ERROR,$result[3]] ); + if ($result[3] =~ s/Rc=([0-9])+\r\n//) { + if ($1 != 0) { + return ([ RC_ERROR, $result[3] ]); } } ########################################## # No data found - return error ########################################## - if ( $result[3] =~ /No results were found/ ) { - return( [NR_ERROR,"No results were found"] ); + if ($result[3] =~ /No results were found/) { + return ([ NR_ERROR, "No results were found" ]); } ########################################## - # If no command output, return "Success" + # If no command output, return "Success" ########################################## - if ( length( $result[3] ) == 0 ) { + if (length($result[3]) == 0) { $result[3] = "Success"; } ########################################## - # Success + # Success ########################################## - my @values = ( SUCCESS ); + my @values = (SUCCESS); push @values, split /\r\n/, $result[3]; - return( \@values ); + return (\@values); } @@ -1118,7 +1118,7 @@ sub send_cmd { sub expect_error { my @error = @_; - + ########################################## # The first element is the number of the # pattern or string that matched, the @@ -1126,8 +1126,8 @@ sub expect_error { # context. The second argument is a # string indicating why expect returned. # If there were no error, the second - # argument will be undef. Possible errors - # are 1:TIMEOUT, 2:EOF, 3:spawn id(...)died, + # argument will be undef. Possible errors + # are 1:TIMEOUT, 2:EOF, 3:spawn id(...)died, # and "4:..." (see Expect (3) manpage for # the precise meaning of these messages) # The third argument of expects return list @@ -1135,16 +1135,16 @@ sub expect_error { # is text before the match, and the fifth # argument is text after the match. ########################################## - if ( $error[1] eq "1:TIMEOUT" ) { - return( "Timeout waiting for prompt" ); + if ($error[1] eq "1:TIMEOUT") { + return ("Timeout waiting for prompt"); } - if ( $error[1] eq "2:EOF" ) { - if ( $error[3] ) { - return( $error[3] ); + if ($error[1] eq "2:EOF") { + if ($error[3]) { + return ($error[3]); } - return( "ssh connection terminated unexpectedly" ); + return ("ssh connection terminated unexpectedly"); } - return( "Logon failed" ); + return ("Logon failed"); } @@ -1154,18 +1154,19 @@ sub expect_error { ########################################################################## sub power_cmd { - my $op = shift; - my $d = shift; + my $op = shift; + my $d = shift; + #my $type = (@$d[4] eq "fsp") ? "sys" : @$d[4]; - my $type = ( @$d[4] =~ /^(fsp|cec)$/ ) ? "sys" : @$d[4]; + my $type = (@$d[4] =~ /^(fsp|cec)$/) ? "sys" : @$d[4]; ############################## - # Build command + # Build command ############################## my $cmd = $powercmd{$type}{$op}; - if ( defined( $cmd )) { - return( sprintf( $cmd, $type, @$d[2],@$d[0],@$d[1] )); + if (defined($cmd)) { + return (sprintf($cmd, $type, @$d[2], @$d[0], @$d[1])); } ############################## # Command not supported @@ -1178,40 +1179,40 @@ sub power_cmd { ##################################### sub network_reset { - my $exp = shift; - my $current_ip = shift; - my $hostname_ip =shift; - my $hwtype = @$exp[2]; + my $exp = shift; + my $current_ip = shift; + my $hostname_ip = shift; + my $hwtype = @$exp[2]; - my ($ip,$hostname) = split /,/, $hostname_ip; - if ( !$hostname || !$ip) + my ($ip, $hostname) = split /,/, $hostname_ip; + if (!$hostname || !$ip) { - return ( [RC_ERROR,"No valid hostname or IP find. This could be a internal bug of xCAT."] ); + return ([ RC_ERROR, "No valid hostname or IP find. This could be a internal bug of xCAT." ]); } ##################################### -# Format command based on HW Type + # Format command based on HW Type ##################################### my %cmd = ( - hmc =>"lshmc -n -F hostname:ipaddr", - ivm =>"lsivm" #just for future consideration - ); + hmc => "lshmc -n -F hostname:ipaddr", + ivm => "lsivm" #just for future consideration + ); ##################################### -# Get current hostname and IP + # Get current hostname and IP ##################################### - my $result = send_cmd( $exp, $cmd{$hwtype} ); - if ( @$result[0] != SUCCESS ) { - return( $result ); + my $result = send_cmd($exp, $cmd{$hwtype}); + if (@$result[0] != SUCCESS) { + return ($result); } - my ($current_hostname,$current_all_ip) = split /:/, @$result[1]; + my ($current_hostname, $current_all_ip) = split /:/, @$result[1]; ##################################### -# Find the correct interface + # Find the correct interface ##################################### - my @eth_ip = split /,/,$current_all_ip; + my @eth_ip = split /,/, $current_all_ip; my $i; my $matched = 0; - for( $i=0; $i < scalar(@eth_ip); $i++) + for ($i = 0 ; $i < scalar(@eth_ip) ; $i++) { if ($eth_ip[$i] eq $current_ip) { @@ -1219,22 +1220,23 @@ sub network_reset { last; } } - if ( !$matched ) + if (!$matched) { -# What's happen? - return ( [RC_ERROR,"No appropriate IP addresses to be updated. This could be a internal bug of xCAT."]); + # What's happen? + return ([ RC_ERROR, "No appropriate IP addresses to be updated. This could be a internal bug of xCAT." ]); } %cmd = ( -# probably need update netmask also - hmc => "chhmc -c network -s modify -h $hostname -i eth$i -a $ip", - ivm => "nothing" - ); - $result = send_cmd( $exp, $cmd{$hwtype} ); + + # probably need update netmask also + hmc => "chhmc -c network -s modify -h $hostname -i eth$i -a $ip", + ivm => "nothing" + ); + $result = send_cmd($exp, $cmd{$hwtype}); ##################################### -# Return error + # Return error ##################################### - return( $result ); + return ($result); } @@ -1246,9 +1248,9 @@ sub lssysconn my $exp = shift; my $res = shift; my $filter = shift; - my $cmd = sprintf( $lssysconn{$res}, $filter ); - my $result = send_cmd( $exp, $cmd); - return ( $result); + my $cmd = sprintf($lssysconn{$res}, $filter); + my $result = send_cmd($exp, $cmd); + return ($result); } ########################################################################## @@ -1260,10 +1262,10 @@ sub mksysconn my $ip = shift; my $type = shift; my $passwd = shift; - - my $cmd = sprintf( $mksysconn{$type}, $ip, $passwd); - my $result = send_cmd( $exp, $cmd); - return ( $result); + + my $cmd = sprintf($mksysconn{$type}, $ip, $passwd); + my $result = send_cmd($exp, $cmd); + return ($result); } ########################################################################## @@ -1278,9 +1280,9 @@ sub chsyspwd my $passwd = shift; my $newpwd = shift; - my $cmd = sprintf( $chsyspwd{$type}, $user, $mtms, $passwd, $newpwd ); - my $result = send_cmd( $exp, $cmd); - return ( $result ); + my $cmd = sprintf($chsyspwd{$type}, $user, $mtms, $passwd, $newpwd); + my $result = send_cmd($exp, $cmd); + return ($result); } ########################################################################## @@ -1288,13 +1290,13 @@ sub chsyspwd ########################################################################## sub rmsysconn { - my $exp = shift; - my $type = shift; - my $name = shift; - - my $cmd = sprintf( $rmsysconn{$type}, $name); - my $result = send_cmd( $exp, $cmd); - return ( $result); + my $exp = shift; + my $type = shift; + my $name = shift; + + my $cmd = sprintf($rmsysconn{$type}, $name); + my $result = send_cmd($exp, $cmd); + return ($result); } ########################################################################## # Get FSP/BPA IP address for the redundancy FSP/BPA from HMC @@ -1310,7 +1312,7 @@ sub getHMCcontrolIP my $exp = shift; #get node type first - my $type = xCAT::DBobjUtils::getnodetype($node, "ppc"); + my $type = xCAT::DBobjUtils::getnodetype($node, "ppc"); unless ($type) { return undef; @@ -1321,32 +1323,34 @@ sub getHMCcontrolIP my $tab = xCAT::Table->new("vpd"); my $ent; if ($tab) { - $ent = $tab->getNodeAttribs($node, ['serial', 'mtm']); + $ent = $tab->getNodeAttribs($node, [ 'serial', 'mtm' ]); } my $serial = $ent->{'serial'}; - my $mtm = $ent->{'mtm'}; + my $mtm = $ent->{'mtm'}; + #my $mtms = $mtm . '*' . $serial; #my $nodes_found = lssyscfg( $exp, "$type", "$mtms"); - my $nodes_found = lssysconn ($exp, "all"); + my $nodes_found = lssysconn($exp, "all"); my @ips; my $ip_result; - if ( @$nodes_found[0] eq SUCCESS ) { + if (@$nodes_found[0] eq SUCCESS) { my $Rc = shift(@$nodes_found); + #my @newnodes = split(/,/, $nodes_found->[0]); #$Rc = shift(@newnodes); #for my $entry (@newnodes) { # if(xCAT::NetworkUtils->isIpaddr($entry)) { # push @ips,$entry; - # } + # } # $ip_result = join( ",", @ips ); - #} - foreach my $entry ( @$nodes_found ) { - if ( $entry =~ /$mtm\*$serial/) { + #} + foreach my $entry (@$nodes_found) { + if ($entry =~ /$mtm\*$serial/) { $entry =~ /ipaddr=(\d+\.\d+\.\d+\.\d+),/; push @ips, $1; } - } - $ip_result = join( ",", @ips ); + } + $ip_result = join(",", @ips); } return $ip_result; } diff --git a/perl-xCAT/xCAT/PPCconn.pm b/perl-xCAT/xCAT/PPCconn.pm index b5836beae..84c3dad9c 100644 --- a/perl-xCAT/xCAT/PPCconn.pm +++ b/perl-xCAT/xCAT/PPCconn.pm @@ -24,13 +24,13 @@ my %method = ( sub parse_args { my $request = shift; - my $cmd = $request->{command}; + my $cmd = $request->{command}; ############################### # Invoke correct parse_args ############################### - my $result = $method{$cmd}( $request, $request->{arg}); - return( $result ); + my $result = $method{$cmd}($request, $request->{arg}); + return ($result); } ########################################################################## @@ -40,40 +40,40 @@ sub mkhwconn_parse_args { my $request = shift; my $args = shift; - my %opt = (); + my %opt = (); local *usage = sub { my $usage_string = xCAT::Usage->getUsage("mkhwconn"); - return( [ $_[0], $usage_string] ); + return ([ $_[0], $usage_string ]); }; ############################################# # Process command-line arguments ############################################# - if ( !defined( $args )) { - return(usage( "No command specified" )); + if (!defined($args)) { + return (usage("No command specified")); } - local @ARGV = ref($args) eq 'ARRAY'? @$args:(); + local @ARGV = ref($args) eq 'ARRAY' ? @$args : (); $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); + Getopt::Long::Configure("bundling"); - if ( !GetOptions( \%opt, qw(V|verbose h|help t p=s P=s port=s s:s) )) { - return( usage() ); + if (!GetOptions(\%opt, qw(V|verbose h|help t p=s P=s port=s s:s))) { + return (usage()); } - return usage() if ( exists $opt{h}); + return usage() if (exists $opt{h}); - if ( !exists $opt{t} and !exists $opt{p} and !exists $opt{s}) { - return ( usage('Flag -t or -p or -s must be used.')); + if (!exists $opt{t} and !exists $opt{p} and !exists $opt{s}) { + return (usage('Flag -t or -p or -s must be used.')); } - if (( exists $opt{t} and exists $opt{p}) or (exists $opt{s} and exists $opt{p}) or (exists $opt{t} and exists $opt{p})) + if ((exists $opt{t} and exists $opt{p}) or (exists $opt{s} and exists $opt{p}) or (exists $opt{t} and exists $opt{p})) { - return( usage('Flags -t and -p cannot be used together.')); + return (usage('Flags -t and -p cannot be used together.')); } - if ( exists $opt{P} and (!exists $opt{p} and !exists $opt{s})) + if (exists $opt{P} and (!exists $opt{p} and !exists $opt{s})) { - return( usage('Flags -P can only be used when flag -p is specified.')); + return (usage('Flags -P can only be used when flag -p is specified.')); } ########################################## @@ -83,42 +83,45 @@ sub mkhwconn_parse_args ########################################## # Check if CECs are controlled by a frame ########################################## - my $nodes = $request->{node}; - my $ppctab = xCAT::Table->new( 'ppc' ); + my $nodes = $request->{node}; + my $ppctab = xCAT::Table->new('ppc'); + #my $nodetypetab = xCAT::Table->new( 'nodetype'); - my $vpdtab = xCAT::Table->new( 'vpd'); + my $vpdtab = xCAT::Table->new('vpd'); my @bpa_ctrled_nodes = (); my @no_type_nodes = (); my @frame_members = (); - if ( $ppctab) + if ($ppctab) { - for my $node ( @$nodes) + for my $node (@$nodes) { my $node_parent = undef; my $nodetype = undef; + #my $nodetype_hash = $nodetypetab->getNodeAttribs( $node,[qw(nodetype)]); - my $node_parent_hash = $ppctab->getNodeAttribs( $node,[qw(parent)]); + my $node_parent_hash = $ppctab->getNodeAttribs($node, [qw(parent)]); + #$nodetype = $nodetype_hash->{nodetype}; - $nodetype = xCAT::DBobjUtils->getnodetype($node,"ppc"); + $nodetype = xCAT::DBobjUtils->getnodetype($node, "ppc"); $node_parent = $node_parent_hash->{parent}; - if ( !$nodetype ) + if (!$nodetype) { push @no_type_nodes, $node; next; } else { - unless ( $nodetype =~ /^(blade|fsp|bpa|frame|cec|hmc)$/) + unless ($nodetype =~ /^(blade|fsp|bpa|frame|cec|hmc)$/) { - return ( usage("Node type is incorrect. \n")); + return (usage("Node type is incorrect. \n")); } } - if ( $nodetype eq 'fsp' ) + if ($nodetype eq 'fsp') { my $jr = xCAT::DBobjUtils::judge_node($node, $nodetype); unless ($jr) { - if ($node_parent and $node_parent ne $node ) + if ($node_parent and $node_parent ne $node) { push @bpa_ctrled_nodes, $node; } @@ -137,12 +140,12 @@ sub mkhwconn_parse_args ########################################## # Now we suppport the operation on sigal bpa ########################################## - if ( $nodetype eq 'bpa') + if ($nodetype eq 'bpa') { my $jr = xCAT::DBobjUtils::judge_node($node, $nodetype); - unless($jr) + unless ($jr) { - my $my_frame_bpa_cec = getFrameMembers( $node, $vpdtab, $ppctab); + my $my_frame_bpa_cec = getFrameMembers($node, $vpdtab, $ppctab); push @frame_members, @$my_frame_bpa_cec; } } @@ -150,10 +153,10 @@ sub mkhwconn_parse_args # For the Frame, we will have its CEC to do # mkhwconn at the same time ########################################## - if ( $nodetype eq 'frame') + if ($nodetype eq 'frame') { - my $my_frame_bpa_cec = xCAT::DBobjUtils::getcecchildren( $node) ; - push @frame_members, @$my_frame_bpa_cec if($my_frame_bpa_cec); + my $my_frame_bpa_cec = xCAT::DBobjUtils::getcecchildren($node); + push @frame_members, @$my_frame_bpa_cec if ($my_frame_bpa_cec); push @frame_members, $node; } } @@ -162,39 +165,40 @@ sub mkhwconn_parse_args if (scalar(@no_type_nodes)) { my $tmp_nodelist = join ',', @no_type_nodes; - return ( usage("Attribute nodetype.nodetype cannot be found for node(s) $tmp_nodelist. Please define first and try again.")); + return (usage("Attribute nodetype.nodetype cannot be found for node(s) $tmp_nodelist. Please define first and try again.")); } if (scalar(@bpa_ctrled_nodes)) { my $tmp_nodelist = join ',', @bpa_ctrled_nodes; - return ( usage("Node(s) $tmp_nodelist is(are) controlled by BPA.")); + return (usage("Node(s) $tmp_nodelist is(are) controlled by BPA.")); } - if ( scalar( @frame_members)) + if (scalar(@frame_members)) { - my @all_nodes = xCAT::Utils::get_unique_members( @$nodes, @frame_members); + my @all_nodes = xCAT::Utils::get_unique_members(@$nodes, @frame_members); $request->{node} = \@all_nodes; } + # Set HW type to 'hmc' anyway, so that this command will not going to # PPCfsp.pm - $request->{ 'hwtype'} = 'hmc'; + $request->{'hwtype'} = 'hmc'; $request->{hcp} = 'hmc'; - if( ! exists $opt{port} ) + if (!exists $opt{port}) { $opt{port} = "0"; } - if( $opt{port} ne "0" and $opt{port} ne "1") + if ($opt{port} ne "0" and $opt{port} ne "1") { - return( usage('Wrong value of --port option. The value can be 0 or 1, and the default value is 0.')); + return (usage('Wrong value of --port option. The value can be 0 or 1, and the default value is 0.')); } $request->{method} = 'mkhwconn'; - - if ( scalar( @ARGV)) { - return(usage( "No additional flag is support by this command" )); + + if (scalar(@ARGV)) { + return (usage("No additional flag is support by this command")); } - return( \%opt); + return (\%opt); } #################################################### @@ -203,38 +207,39 @@ sub mkhwconn_parse_args #ppc/vpd nodes cache my @all_ppc_nodes; my @all_vpd_nodes; + sub getFrameMembers { - my $node = shift; #this a BPA node - my $vpdtab = shift; - my $ppctab = shift; + my $node = shift; #this a BPA node + my $vpdtab = shift; + my $ppctab = shift; my @frame_members = (); my @bpa_nodes = (); - my $vpdhash = $vpdtab->getNodeAttribs( $node, [qw(mtm serial)]); - my $mtm = $vpdhash->{mtm}; - my $serial = $vpdhash->{serial}; - if ( scalar( @all_vpd_nodes) == 0) + my $vpdhash = $vpdtab->getNodeAttribs($node, [qw(mtm serial)]); + my $mtm = $vpdhash->{mtm}; + my $serial = $vpdhash->{serial}; + if (scalar(@all_vpd_nodes) == 0) { - @all_vpd_nodes = $vpdtab->getAllNodeAttribs( ['node', 'mtm', 'serial']); + @all_vpd_nodes = $vpdtab->getAllNodeAttribs([ 'node', 'mtm', 'serial' ]); } for my $vpd_node (@all_vpd_nodes) { - if ( $vpd_node->{'mtm'} eq $mtm and $vpd_node->{'serial'} eq $serial) + if ($vpd_node->{'mtm'} eq $mtm and $vpd_node->{'serial'} eq $serial) { push @frame_members, $vpd_node->{'node'}; - push @bpa_nodes, $vpd_node->{'node'}; + push @bpa_nodes, $vpd_node->{'node'}; } } - if ( scalar( @all_ppc_nodes) == 0) + if (scalar(@all_ppc_nodes) == 0) { - @all_ppc_nodes = $ppctab->getAllNodeAttribs( ['node', 'parent']); + @all_ppc_nodes = $ppctab->getAllNodeAttribs([ 'node', 'parent' ]); } for my $bpa_node (@bpa_nodes) { for my $ppc_node (@all_ppc_nodes) { - if ( $ppc_node->{parent} eq $bpa_node) + if ($ppc_node->{parent} eq $bpa_node) { push @frame_members, $ppc_node->{'node'}; } @@ -250,102 +255,103 @@ sub lshwconn_parse_args { my $request = shift; my $args = shift; - my %opt = (); + my %opt = (); local *usage = sub { my $usage_string = xCAT::Usage->getUsage("lshwconn"); - return( [ $_[0], $usage_string] ); + return ([ $_[0], $usage_string ]); }; ############################################# -# Get options in command line + # Get options in command line ############################################# - local @ARGV = ref($args) eq 'ARRAY'? @$args:(); + local @ARGV = ref($args) eq 'ARRAY' ? @$args : (); $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); + Getopt::Long::Configure("bundling"); - if ( !GetOptions( \%opt, qw(V|verbose h|help s) )) { - return( usage() ); + if (!GetOptions(\%opt, qw(V|verbose h|help s))) { + return (usage()); } - return usage() if ( exists $opt{h}); + return usage() if (exists $opt{h}); ############################################# # Process command-line arguments ############################################# - if ( scalar( @ARGV)) { - unless( $opt{s}) { - return(usage( "No additional flag is support by this command" )); - } + if (scalar(@ARGV)) { + unless ($opt{s}) { + return (usage("No additional flag is support by this command")); + } } + #my $nodetypetab = xCAT::Table->new('nodetype'); #if (! $nodetypetab) #{ # return( ["Failed to open table 'nodetype'.\n"]); #} my $nodehmtab = xCAT::Table->new('nodehm'); - if (! $nodehmtab) + if (!$nodehmtab) { - return( ["Failed to open table 'nodehm'.\n"]); + return (["Failed to open table 'nodehm'.\n"]); } my $nodetype; - my @no_type_nodes = (); - my @no_mgt_nodes = (); + my @no_type_nodes = (); + my @no_mgt_nodes = (); my @error_type_nodes = (); - for my $node ( @{$request->{node}}) + for my $node (@{ $request->{node} }) { #my $ent = $nodetypetab->getNodeAttribs( $node, [qw(nodetype)]); my $ttype = xCAT::DBobjUtils->getnodetype($node); - my $nodehm = $nodehmtab->getNodeAttribs( $node, [qw(mgt)]); - if ( ! $ttype) + my $nodehm = $nodehmtab->getNodeAttribs($node, [qw(mgt)]); + if (!$ttype) { push @no_type_nodes, $node; next; } - if ( ! $nodehm) + if (!$nodehm) { push @no_mgt_nodes, $node; next; } - elsif ( $nodehm->{mgt} ne 'hmc') + elsif ($nodehm->{mgt} ne 'hmc') { - return( ["lshwconn can only support HMC nodes, or nodes managed by HMC, i.e. nodehm.mgt should be 'hmc'. Please make sure node $node has correect nodehm.mgt and ppc.hcp value.\n"]); + return (["lshwconn can only support HMC nodes, or nodes managed by HMC, i.e. nodehm.mgt should be 'hmc'. Please make sure node $node has correect nodehm.mgt and ppc.hcp value.\n"]); } - if ( $ttype ne 'hmc' - and $ttype ne 'fsp' and $ttype ne 'cec' - and $ttype ne 'bpa' and $ttype ne 'frame') + if ($ttype ne 'hmc' + and $ttype ne 'fsp' and $ttype ne 'cec' + and $ttype ne 'bpa' and $ttype ne 'frame') { push @error_type_nodes, $node; next; } - if ( ! $nodetype) + if (!$nodetype) { $nodetype = $ttype; } else { - if ( $nodetype ne $ttype) + if ($nodetype ne $ttype) { - return( ["Cannot support multiple node types in this command line.\n"]); + return (["Cannot support multiple node types in this command line.\n"]); } } } if (scalar(@no_type_nodes)) { my $tmp_nodelist = join ',', @no_type_nodes; - return( ["Failed to get node type for node(s) $tmp_nodelist. Please define first and try again\n"]); + return (["Failed to get node type for node(s) $tmp_nodelist. Please define first and try again\n"]); } if (scalar(@no_mgt_nodes)) { my $tmp_nodelist = join ',', @no_mgt_nodes; - return( ["Failed to get nodehm.mgt value for node(s) $tmp_nodelist. Please define first and try again.\n"]); + return (["Failed to get nodehm.mgt value for node(s) $tmp_nodelist. Please define first and try again.\n"]); } if (scalar(@error_type_nodes)) { my $tmp_nodelist = join ',', @error_type_nodes; - my $link = (scalar(@error_type_nodes) eq '1')? 'is':'are'; - return( ["Node type of node(s) $tmp_nodelist $link not supported for this command.\n"]); + my $link = (scalar(@error_type_nodes) eq '1') ? 'is' : 'are'; + return (["Node type of node(s) $tmp_nodelist $link not supported for this command.\n"]); } $request->{nodetype} = $nodetype; $request->{method} = 'lshwconn'; - return( \%opt); + return (\%opt); } ########################################################################## @@ -355,47 +361,48 @@ sub rmhwconn_parse_args { my $request = shift; my $args = shift; - my %opt = (); + my %opt = (); local *usage = sub { my $usage_string = xCAT::Usage->getUsage("rmhwconn"); - return( [ $_[0], $usage_string] ); + return ([ $_[0], $usage_string ]); }; ############################################# # Get options in command line ############################################# - local @ARGV = ref($args) eq 'ARRAY'? @$args:(); + local @ARGV = ref($args) eq 'ARRAY' ? @$args : (); $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); + Getopt::Long::Configure("bundling"); - if ( !GetOptions( \%opt, qw(V|verbose h|help s) )) { - return( usage() ); + if (!GetOptions(\%opt, qw(V|verbose h|help s))) { + return (usage()); } - return usage() if ( exists $opt{h}); + return usage() if (exists $opt{h}); ############################################# # Process command-line arguments ############################################# - if ( scalar (@ARGV)) { - unless( $opt{s}) { - return(usage( "No additional flag is support by this command" )); + if (scalar(@ARGV)) { + unless ($opt{s}) { + return (usage("No additional flag is support by this command")); } } ########################################## # Check if CECs are controlled by a frame ########################################## - my $nodes = $request->{node}; - my $ppctab = xCAT::Table->new( 'ppc' ); - return( ["Failed to open table 'ppc'.\n"]) if ( ! $ppctab); - my $vpdtab = xCAT::Table->new( 'vpd'); - return( ["Failed to open table 'vpd'.\n"]) if ( ! $vpdtab); + my $nodes = $request->{node}; + my $ppctab = xCAT::Table->new('ppc'); + return (["Failed to open table 'ppc'.\n"]) if (!$ppctab); + my $vpdtab = xCAT::Table->new('vpd'); + return (["Failed to open table 'vpd'.\n"]) if (!$vpdtab); my @bpa_ctrled_nodes = (); my @no_type_nodes = (); my @frame_members = (); - for my $node ( @$nodes) + + for my $node (@$nodes) { my $node_parent = undef; - my $node_parent_hash = $ppctab->getNodeAttribs( $node,[qw(parent)]); + my $node_parent_hash = $ppctab->getNodeAttribs($node, [qw(parent)]); $node_parent = $node_parent_hash->{parent}; my $newtype = xCAT::DBobjUtils::getnodetype($node); unless ($newtype) { @@ -403,7 +410,7 @@ sub rmhwconn_parse_args next; } - if ($newtype =~ /^(fsp|bpa)$/ ) + if ($newtype =~ /^(fsp|bpa)$/) { ########################################## # We should judge if the node is defined in xCAT 2.5 @@ -412,28 +419,29 @@ sub rmhwconn_parse_args # which means we support remove a sigal connection ########################################## my $jr = xCAT::DBobjUtils::judge_node($node, $newtype); + #$jr is defined by the xCAT2.5 unless ($jr) { - if ( ($newtype eq 'fsp') and $node_parent and $node_parent ne $node) + if (($newtype eq 'fsp') and $node_parent and $node_parent ne $node) { push @bpa_ctrled_nodes, $node; } - if ( $newtype eq 'bpa') + if ($newtype eq 'bpa') { - my $my_frame_bpa_cec = getFrameMembers( $node, $vpdtab, $ppctab); + my $my_frame_bpa_cec = getFrameMembers($node, $vpdtab, $ppctab); push @frame_members, @$my_frame_bpa_cec; } } } - if (( $newtype eq 'cec') and $node_parent and $node_parent ne $node) + if (($newtype eq 'cec') and $node_parent and $node_parent ne $node) { #push @bpa_ctrled_nodes, $node; } - if ( $newtype eq 'frame') + if ($newtype eq 'frame') { my $my_frame_bpa_cec = xCAT::DBobjUtils::getcecchildren($node); push @frame_members, @$my_frame_bpa_cec; @@ -444,22 +452,22 @@ sub rmhwconn_parse_args if (scalar(@no_type_nodes)) { my $tmp_nodelist = join ',', @no_type_nodes; - return ( usage("Attribute nodetype.nodetype cannot be found for node(s) $tmp_nodelist. Please define first and try again.\n")); + return (usage("Attribute nodetype.nodetype cannot be found for node(s) $tmp_nodelist. Please define first and try again.\n")); } if (scalar(@bpa_ctrled_nodes)) { my $tmp_nodelist = join ',', @bpa_ctrled_nodes; - return ( usage("Node(s) $tmp_nodelist is(are) controlled by BPA.")); + return (usage("Node(s) $tmp_nodelist is(are) controlled by BPA.")); } - if ( scalar( @frame_members)) + if (scalar(@frame_members)) { - my @all_nodes = xCAT::Utils::get_unique_members( @$nodes, @frame_members); + my @all_nodes = xCAT::Utils::get_unique_members(@$nodes, @frame_members); $request->{node} = \@all_nodes; } $request->{method} = 'rmhwconn'; - return( \%opt); + return (\%opt); } ########################################################################## # Create connection for CECs/BPAs @@ -474,11 +482,11 @@ sub mkhwconn my @value = (); my $Rc = undef; - xCAT::MsgUtils->verbose_message($request, "mkhwconn START."); - for my $cec_bpa ( keys %$hash) + xCAT::MsgUtils->verbose_message($request, "mkhwconn START."); + for my $cec_bpa (keys %$hash) { my $node_hash = $hash->{$cec_bpa}; - for my $node_name ( keys %$node_hash) + for my $node_name (keys %$node_hash) { my $d = $node_hash->{$node_name}; @@ -486,6 +494,7 @@ sub mkhwconn # Get IP address ############################ my $cnode; + #my $ntype = xCAT::DBobjUtils::getnodetype($node_name); my $ntype = $$d[4]; if ($ntype =~ /^(cec|frame|blade)$/) @@ -499,69 +508,69 @@ sub mkhwconn } my @newnodes = (); - if ( $cnode =~ /ARRAY/ ) + if ($cnode =~ /ARRAY/) { foreach (@$cnode) { push @newnodes, $_; } } else { - push @newnodes,$cnode; + push @newnodes, $cnode; } - xCAT::MsgUtils->verbose_message($request, "mkhwconn :mksysconn for node:$node_name."); - for my $nn ( @newnodes ) + xCAT::MsgUtils->verbose_message($request, "mkhwconn :mksysconn for node:$node_name."); + for my $nn (@newnodes) { my $node_ip; - unless ( xCAT::NetworkUtils->isIpaddr($nn) ) { - $node_ip = xCAT::NetworkUtils::getNodeIPaddress( $nn ); + unless (xCAT::NetworkUtils->isIpaddr($nn)) { + $node_ip = xCAT::NetworkUtils::getNodeIPaddress($nn); } else { $node_ip = $nn; } - unless($node_ip) + unless ($node_ip) { - push @value, [$node_name, "Cannot get IP address. Please check table 'hosts' or name resolution", 1]; + push @value, [ $node_name, "Cannot get IP address. Please check table 'hosts' or name resolution", 1 ]; next; } - my ( undef,undef,$mtms,undef,$type,$bpa) = @$d; + my (undef, undef, $mtms, undef, $type, $bpa) = @$d; my ($user, $passwd); - if ( exists $opt->{P}) + if (exists $opt->{P}) { ($user, $passwd) = ('HMC', $opt->{P}); } elsif ($type eq "blade") { $user = "USERID"; - ($user, $passwd) = xCAT::PPCdb::credentials( $bpa, $type, $user); + ($user, $passwd) = xCAT::PPCdb::credentials($bpa, $type, $user); $type = "cec"; } else { - ($user, $passwd) = xCAT::PPCdb::credentials( $node_name, $type,'HMC'); - if ( !$passwd) + ($user, $passwd) = xCAT::PPCdb::credentials($node_name, $type, 'HMC'); + if (!$passwd) { - push @value, [$node_name, "Cannot get password of userid 'HMC'. Please check table 'passwd' or 'ppcdirect'.",1]; + push @value, [ $node_name, "Cannot get password of userid 'HMC'. Please check table 'passwd' or 'ppcdirect'.", 1 ]; next; } } - my $res = xCAT::PPCcli::mksysconn( $exp, $node_ip, $type, $passwd); + my $res = xCAT::PPCcli::mksysconn($exp, $node_ip, $type, $passwd); $Rc = shift @$res; - push @value, [$node_name, @$res[0], $Rc]; - if ( !$Rc and !(exists $opt->{s})) + push @value, [ $node_name, @$res[0], $Rc ]; + if (!$Rc and !(exists $opt->{s})) { - sethmcmgt( $node_name, $exp->[3]); + sethmcmgt($node_name, $exp->[3]); } } -# if ( exists $opt->{N} ) -# { -# my $newpwd = $opt->{N}; -# my $Res = xCAT::PPCcli::chsyspwd( $exp, "access", $type, $mtms, $passwd, $newpwd ); -# $Rc = shift @$Res; -# push @value, [$node_name, @$Res[0], $Rc]; -# } + # if ( exists $opt->{N} ) + # { + # my $newpwd = $opt->{N}; + # my $Res = xCAT::PPCcli::chsyspwd( $exp, "access", $type, $mtms, $passwd, $newpwd ); + # $Rc = shift @$Res; + # push @value, [$node_name, @$Res[0], $Rc]; + # } } } - xCAT::MsgUtils->verbose_message($request, "mkhwconn END."); + xCAT::MsgUtils->verbose_message($request, "mkhwconn END."); return \@value; } ########################################################################## @@ -578,35 +587,35 @@ sub lshwconn my $Rc = undef; - my $hosttab = xCAT::Table->new( 'hosts' ); - my $res = xCAT::PPCcli::lssysconn( $exp, "all" ); + my $hosttab = xCAT::Table->new('hosts'); + my $res = xCAT::PPCcli::lssysconn($exp, "all"); $Rc = shift @$res; - if ( $request->{nodetype} eq 'hmc') + if ($request->{nodetype} eq 'hmc') { - if ( $Rc) + if ($Rc) { - push @value, [$exp->[3], $res->[0], $Rc]; + push @value, [ $exp->[3], $res->[0], $Rc ]; return \@value; } - my $vpdtab = xCAT::Table->new('vpd'); + my $vpdtab = xCAT::Table->new('vpd'); my @vpdentries = $vpdtab->getAllAttribs(qw(node serial mtm)); my %node_vpd_hash; - for my $vpdent ( @vpdentries) + for my $vpdent (@vpdentries) { - if ( $vpdent->{node} and $vpdent->{serial} and $vpdent->{mtm}) + if ($vpdent->{node} and $vpdent->{serial} and $vpdent->{mtm}) { $node_vpd_hash{"$vpdent->{mtm}*$vpdent->{serial}"} = $vpdent->{node}; } } my %node_ppc_hash; - my $ppctab = xCAT::Table->new('ppc'); - for my $node ( values %node_vpd_hash) + my $ppctab = xCAT::Table->new('ppc'); + for my $node (values %node_vpd_hash) { - my $node_parent_hash = $ppctab->getNodeAttribs( $node, [qw(parent)]); + my $node_parent_hash = $ppctab->getNodeAttribs($node, [qw(parent)]); $node_ppc_hash{$node} = $node_parent_hash->{parent}; } - for my $r ( @$res) + for my $r (@$res) { $r =~ s/type_model_serial_num=([^,]*),//; my $mtms = $1; @@ -614,7 +623,7 @@ sub lshwconn $r =~ s/sp=.*?,//; $r =~ s/sp_phys_loc=.*?,//; my $node_name; - if ( exists $node_vpd_hash{$mtms}) + if (exists $node_vpd_hash{$mtms}) { $node_name = $node_vpd_hash{$mtms}; $r = "hcp=$exp->[3],parent=$node_ppc_hash{$node_name}," . $r; @@ -622,14 +631,14 @@ sub lshwconn else { $node_name = $mtms; - $r = "hcp=$exp->[3],parent=," . $r; + $r = "hcp=$exp->[3],parent=," . $r; } - push @value, [ $node_name, $r, $Rc]; + push @value, [ $node_name, $r, $Rc ]; } } else { - for my $cec_bpa ( keys %$hash) + for my $cec_bpa (keys %$hash) { my $node_hash = $hash->{$cec_bpa}; for my $node_name (keys %$node_hash) @@ -638,9 +647,9 @@ sub lshwconn # If lssysconn failed, put error into all # nodes' return values ############################################ - if ( $Rc ) + if ($Rc) { - push @value, [$node_name, @$res[0], $Rc]; + push @value, [ $node_name, @$res[0], $Rc ]; next; } @@ -648,39 +657,40 @@ sub lshwconn # Get IP address ############################ my $node_ip = undef; - if ( $hosttab) + if ($hosttab) { #my $node_ip_hash = $hosttab->getNodeAttribs( $node_name,[qw(ip)]); #$node_ip = $node_ip_hash->{ip}; #$node_ip = xCAT::NetworkUtils::getNodeIPaddress( $node_name ); - my $d = $node_hash->{$node_name}; - $node_ip = xCAT::FSPUtils::getIPaddress($request, $$d[4], $node_name ); + my $d = $node_hash->{$node_name}; + $node_ip = xCAT::FSPUtils::getIPaddress($request, $$d[4], $node_name); } if (!$node_ip || ($node_ip == -3)) { - push @value, [$node_name, "Failed to get IP address.", $Rc]; + push @value, [ $node_name, "Failed to get IP address.", $Rc ]; next; } my @nodes_ip = split(/,/, $node_ip); - for my $ip (@nodes_ip) + for my $ip (@nodes_ip) { - if ( my @res_matched = grep /\Qipaddr=$ip,\E/, @$res) + if (my @res_matched = grep /\Qipaddr=$ip,\E/, @$res) { - for my $r ( @res_matched) + for my $r (@res_matched) { $r =~ s/\Qtype_model_serial_num=$cec_bpa,\E//; + #$r =~ s/\Qresource_type=$type,\E//; $r =~ s/sp=.*?,//; $r =~ s/sp_phys_loc=.*?,//; - my $new_name = $node_name."(".$ip. ")"; - push @value, [$new_name, $r, $Rc]; + my $new_name = $node_name . "(" . $ip . ")"; + push @value, [ $new_name, $r, $Rc ]; } } else { - my $new_name = $node_name."(".$ip. ")"; - push @value, [$new_name, 'Connection not found', 1]; + my $new_name = $node_name . "(" . $ip . ")"; + push @value, [ $new_name, 'Connection not found', 1 ]; } } } @@ -702,21 +712,21 @@ sub rmhwconn my @value = (); my $Rc = undef; - my $nodes_found = xCAT::PPCcli::lssysconn ($exp, "all"); - if ( @$nodes_found[0] eq SUCCESS ) { + my $nodes_found = xCAT::PPCcli::lssysconn($exp, "all"); + if (@$nodes_found[0] eq SUCCESS) { $Rc = shift(@$nodes_found); - } else { + } else { return undef; - } - for my $cec_bpa ( keys %$hash) + } + for my $cec_bpa (keys %$hash) { my $node_hash = $hash->{$cec_bpa}; for my $node_name (keys %$node_hash) { my $d = $node_hash->{$node_name}; - my ( undef,undef,undef,undef,$type) = @$d; - if ($type eq "blade") {$type = "cec";} + my (undef, undef, undef, undef, $type) = @$d; + if ($type eq "blade") { $type = "cec"; } ############################ # Get IP address ############################ @@ -725,14 +735,14 @@ sub rmhwconn my $tab = xCAT::Table->new("vpd"); my $ent; if ($tab) { - $ent = $tab->getNodeAttribs($node_name, ['serial', 'mtm']); + $ent = $tab->getNodeAttribs($node_name, [ 'serial', 'mtm' ]); } my $serial = $ent->{'serial'}; - my $mtm = $ent->{'mtm'}; + my $mtm = $ent->{'mtm'}; my $node_ip; my @ips; - foreach my $entry ( @$nodes_found ) { + foreach my $entry (@$nodes_found) { if ($entry =~ /type_model_serial_num=([^,]*),/) { my $match_mtm1 = $1; my $match_mtm2 = $match_mtm1; @@ -742,24 +752,25 @@ sub rmhwconn push @ips, $1; } } - #if ( $entry =~ /$mtm\*$serial/) { - # $entry =~ /ipaddr=(\d+\.\d+\.\d+\.\d+),/; - # push @ips, $1; - #} - } + + #if ( $entry =~ /$mtm\*$serial/) { + # $entry =~ /ipaddr=(\d+\.\d+\.\d+\.\d+),/; + # push @ips, $1; + #} + } if (!@ips) { - push @value, [$node_name, $node_ip, $Rc]; + push @value, [ $node_name, $node_ip, $Rc ]; next; } - for my $nn ( @ips ) + for my $nn (@ips) { - my $res = xCAT::PPCcli::rmsysconn( $exp, $type, $nn); + my $res = xCAT::PPCcli::rmsysconn($exp, $type, $nn); $Rc = shift @$res; - push @value, [$node_name, @$res[0], $Rc]; - if ( !$Rc and !$opt->{s}) + push @value, [ $node_name, @$res[0], $Rc ]; + if (!$Rc and !$opt->{s}) { - rmhmcmgt( $node_name, $type); + rmhmcmgt($node_name, $type); } } } @@ -775,26 +786,26 @@ sub sethmcmgt my $node = shift; my $hcp = shift; - my $nodehm_tab = xCAT::Table->new('nodehm', -create=>1); - my $ppc_tab = xCAT::Table->new('ppc', -create=>1); + my $nodehm_tab = xCAT::Table->new('nodehm', -create => 1); + my $ppc_tab = xCAT::Table->new('ppc', -create => 1); my @nodes; push @nodes, $node; my $ntype = xCAT::DBobjUtils->getnodetype($node); - if ( $ntype =~ /^(cec|frame)$/ ) { + if ($ntype =~ /^(cec|frame)$/) { my $cnodep = xCAT::DBobjUtils->getchildren($node); if ($cnodep) { push @nodes, @$cnodep; - } - } - for my $n (@nodes) { - my $ent = $nodehm_tab->getNodeAttribs( $n, ['mgt']); - if ( !$ent or $ent->{mgt} ne 'hmc') { - $nodehm_tab->setNodeAttribs( $n, { mgt=>'hmc'}); } - my $ent = $ppc_tab->getNodeAttribs( $n, ['hcp']); - if ( !$ent or $ent->{hcp} ne $hcp) { - $ppc_tab->setNodeAttribs( $n, { hcp=>$hcp}); - } + } + for my $n (@nodes) { + my $ent = $nodehm_tab->getNodeAttribs($n, ['mgt']); + if (!$ent or $ent->{mgt} ne 'hmc') { + $nodehm_tab->setNodeAttribs($n, { mgt => 'hmc' }); + } + my $ent = $ppc_tab->getNodeAttribs($n, ['hcp']); + if (!$ent or $ent->{hcp} ne $hcp) { + $ppc_tab->setNodeAttribs($n, { hcp => $hcp }); + } } } ################################################################# @@ -802,34 +813,34 @@ sub sethmcmgt ################################################################# sub rmhmcmgt { - my $node = shift; + my $node = shift; my $hwtype = shift; - my $nodehm_tab = xCAT::Table->new('nodehm', -create=>1); - my $ppc_tab = xCAT::Table->new('ppc', -create=>1); + my $nodehm_tab = xCAT::Table->new('nodehm', -create => 1); + my $ppc_tab = xCAT::Table->new('ppc', -create => 1); my @nodes; push @nodes, $node; my $ntype = xCAT::DBobjUtils->getnodetype($node); - if ( $ntype =~ /^(cec|frame)$/ ) { + if ($ntype =~ /^(cec|frame)$/) { my $cnodep = xCAT::DBobjUtils->getchildren($node); if ($cnodep) { push @nodes, @$cnodep; - } + } } for my $n (@nodes) { - my $ent = $nodehm_tab->getNodeAttribs( $n, ['mgt']); - if ( !$ent or $ent->{mgt} ne $hwtype) { + my $ent = $nodehm_tab->getNodeAttribs($n, ['mgt']); + if (!$ent or $ent->{mgt} ne $hwtype) { if ($hwtype eq "cec" || $hwtype eq "frame") { - $nodehm_tab->setNodeAttribs( $n, { mgt=>"fsp"}); - } else { - $nodehm_tab->setNodeAttribs( $n, { mgt=>$hwtype}); - } + $nodehm_tab->setNodeAttribs($n, { mgt => "fsp" }); + } else { + $nodehm_tab->setNodeAttribs($n, { mgt => $hwtype }); + } } - my $ent = $ppc_tab->getNodeAttribs( $n, ['hcp']); - if ( !$ent or $ent->{hcp} ne $n) { - $ppc_tab->setNodeAttribs( $n, { hcp=>$n}); + my $ent = $ppc_tab->getNodeAttribs($n, ['hcp']); + if (!$ent or $ent->{hcp} ne $n) { + $ppc_tab->setNodeAttribs($n, { hcp => $n }); } - } + } } 1; diff --git a/perl-xCAT/xCAT/PPCdb.pm b/perl-xCAT/xCAT/PPCdb.pm index 2b7e30252..464ac4b34 100644 --- a/perl-xCAT/xCAT/PPCdb.pm +++ b/perl-xCAT/xCAT/PPCdb.pm @@ -13,12 +13,12 @@ require xCAT::data::ibmhwtypes; # Factory defaults ########################################### my %logon = ( - hmc => ["hscroot","abc123"], - ivm => ["padmin", "padmin"], - fsp => ["admin", "admin"], - bpa => ["admin", "admin"], - frame => ["admin", "admin"], - cec => ["admin", "admin"], + hmc => [ "hscroot", "abc123" ], + ivm => [ "padmin", "padmin" ], + fsp => [ "admin", "admin" ], + bpa => [ "admin", "admin" ], + frame => [ "admin", "admin" ], + cec => [ "admin", "admin" ], ); ########################################### @@ -31,7 +31,7 @@ my %hcptab = ( bpa => "ppcdirect", frame => "ppcdirect", cec => "ppcdirect", - blade => "mpa", + blade => "mpa", ); ########################################### @@ -44,7 +44,7 @@ my %defaultgrp = ( bpa => "bpa", frame => "frame", cec => "cec", - blade => "blade", + blade => "blade", ); my %globlehwtype = ( fsp => $::NODETYPE_FSP, @@ -57,13 +57,13 @@ my %globlehwtype = ( ); my %globalnodetype = ( - fsp => $::NODETYPE_PPC, - bpa => $::NODETYPE_PPC, - cec => $::NODETYPE_PPC, - frame=> $::NODETYPE_PPC, - hmc => $::NODETYPE_PPC, - ivm => $::NODETYPE_PPC, - lpar =>"$::NODETYPE_PPC,$::NODETYPE_OSI" + fsp => $::NODETYPE_PPC, + bpa => $::NODETYPE_PPC, + cec => $::NODETYPE_PPC, + frame => $::NODETYPE_PPC, + hmc => $::NODETYPE_PPC, + ivm => $::NODETYPE_PPC, + lpar => "$::NODETYPE_PPC,$::NODETYPE_OSI" ); ########################################################################## @@ -71,26 +71,26 @@ my %globalnodetype = ( ########################################################################## sub add_ppc { - my $hwtype = shift; - my $values = shift; - my $not_overwrite = shift; + my $hwtype = shift; + my $values = shift; + my $not_overwrite = shift; my $otherinterfaces = shift; - my $callfile = shift; - my @tabs = qw(ppc vpd nodehm nodelist nodetype hosts mac); - my %db = (); + my $callfile = shift; + my @tabs = qw(ppc vpd nodehm nodelist nodetype hosts mac); + my %db = (); ################################### # Open database needed ################################### - foreach ( @tabs ) { - $db{$_} = xCAT::Table->new( $_, -create=>1, -autocommit=>0 ); - if ( !$db{$_} ) { - return( "Error opening '$_'" ); + foreach (@tabs) { + $db{$_} = xCAT::Table->new($_, -create => 1, -autocommit => 0); + if (!$db{$_}) { + return ("Error opening '$_'"); } } ################################### - # Update tables + # Update tables ################################### - foreach ( @$values ) { + foreach (@$values) { my ($type, $name, $id, @@ -101,15 +101,15 @@ sub add_ppc { $pprofile, $parent, $ips, - $mac ) = split /,/; + $mac) = split /,/; ############################### # Update nodetype table ############################### - if ( $type =~ /^(fsp|bpa|hmc|ivm|frame|cec)$/ ) { - $db{nodetype}->setNodeAttribs( $name,{nodetype=>'ppc'} ); + if ($type =~ /^(fsp|bpa|hmc|ivm|frame|cec)$/) { + $db{nodetype}->setNodeAttribs($name, { nodetype => 'ppc' }); $db{nodetype}{commit} = 1; } elsif ($type =~ /^lpar$/) { - $db{nodetype}->setNodeAttribs( $name,{nodetype=>'ppc,osi'} ); + $db{nodetype}->setNodeAttribs($name, { nodetype => 'ppc,osi' }); $db{nodetype}{commit} = 1; } ############################### @@ -117,131 +117,131 @@ sub add_ppc { # old data firstly ############################### my $mgt = $hwtype; - + # Specify CEC and Frame's mgt as fsp and bpa - if ( $type =~ /^cec$/) { - if ( $callfile eq "PPC" ) { + if ($type =~ /^cec$/) { + if ($callfile eq "PPC") { $mgt = "hmc"; } - if ( $callfile eq "FSP" ) { + if ($callfile eq "FSP") { $mgt = "fsp"; } } - if ( $type =~ /^frame$/) { + if ($type =~ /^frame$/) { $mgt = "bpa"; - } - - - my $cons= $hwtype; - if ( $not_overwrite) + } + + + my $cons = $hwtype; + if ($not_overwrite) { - my $enthash = $db{ppc}->getNodeAttribs( $name, [qw(hcp id pprofile parent)]); - if ( $enthash ) + my $enthash = $db{ppc}->getNodeAttribs($name, [qw(hcp id pprofile parent)]); + if ($enthash) { - $server = $enthash->{hcp} if ($enthash->{hcp}); - $id = $enthash->{id} if ( $enthash->{id}); - $pprofile = $enthash->{pprofile} if ( $enthash->{pprofile}); - $parent = $enthash->{parent} if ( $enthash->{parent}); + $server = $enthash->{hcp} if ($enthash->{hcp}); + $id = $enthash->{id} if ($enthash->{id}); + $pprofile = $enthash->{pprofile} if ($enthash->{pprofile}); + $parent = $enthash->{parent} if ($enthash->{parent}); } - $enthash = $db{nodehm}->getNodeAttribs( $name, [qw(mgt)]); - if ( $enthash ) + $enthash = $db{nodehm}->getNodeAttribs($name, [qw(mgt)]); + if ($enthash) { - $mgt= $enthash->{mgt} if ( $enthash->{mgt}); - $cons= $enthash->{cons} if ( $enthash->{cons}); + $mgt = $enthash->{mgt} if ($enthash->{mgt}); + $cons = $enthash->{cons} if ($enthash->{cons}); } - $enthash = $db{vpd}->getNodeAttribs( $name, [qw(mtm serial)]); - if ( $enthash ) + $enthash = $db{vpd}->getNodeAttribs($name, [qw(mtm serial)]); + if ($enthash) { - $model = $enthash->{mtm} if ( $enthash->{mtm}); - $serial= $enthash->{serial} if ( $enthash->{serial}); + $model = $enthash->{mtm} if ($enthash->{mtm}); + $serial = $enthash->{serial} if ($enthash->{serial}); } } ############################### # Update ppc table ############################### - if ( $type =~ /^(fsp|bpa|lpar|frame|cec|hmc)$/ ) { - $db{ppc}->setNodeAttribs( $name, - { hcp=>$server, - id=>$id, - pprofile=>$pprofile, - parent=>$parent, - nodetype=>$globlehwtype{$type}, - }); + if ($type =~ /^(fsp|bpa|lpar|frame|cec|hmc)$/) { + $db{ppc}->setNodeAttribs($name, + { hcp => $server, + id => $id, + pprofile => $pprofile, + parent => $parent, + nodetype => $globlehwtype{$type}, + }); $db{ppc}{commit} = 1; ########################### # Update nodelist table ########################### - updategroups( $name, $db{nodelist}, $type ); + updategroups($name, $db{nodelist}, $type); my $tmp_group = xCAT::data::ibmhwtypes::parse_group($model); if (defined($tmp_group)) { updategroups($name, $db{nodelist}, $tmp_group); } - if ( $type =~ /^(fsp|bpa)$/ ) { - $db{nodelist}->setNodeAttribs( $name, {hidden => '1'}); + if ($type =~ /^(fsp|bpa)$/) { + $db{nodelist}->setNodeAttribs($name, { hidden => '1' }); } else { - $db{nodelist}->setNodeAttribs( $name, {hidden => '0'}); + $db{nodelist}->setNodeAttribs($name, { hidden => '0' }); } - + $db{nodelist}{commit} = 1; ########################### # Update nodehm table ########################### - if($type =~ /^lpar$/){ - $db{nodehm}->setNodeAttribs( $name, {mgt=>$mgt,cons=>$cons} ); + if ($type =~ /^lpar$/) { + $db{nodehm}->setNodeAttribs($name, { mgt => $mgt, cons => $cons }); } else { - $db{nodehm}->setNodeAttribs( $name, {mgt=>$mgt} ); + $db{nodehm}->setNodeAttribs($name, { mgt => $mgt }); } $db{nodehm}{commit} = 1; } ############################### # Update vpd table ############################### - if ( $type =~ /^(fsp|bpa)$/ ) { - $db{vpd}->setNodeAttribs( $name, - { mtm=>$model, - serial=>$serial, - side=>$side - }); - } - if ( $type =~ /^(frame|cec)$/ ) { - $db{vpd}->setNodeAttribs( $name, - { mtm=>$model, - serial=>$serial, - }); + if ($type =~ /^(fsp|bpa)$/) { + $db{vpd}->setNodeAttribs($name, + { mtm => $model, + serial => $serial, + side => $side + }); + } + if ($type =~ /^(frame|cec)$/) { + $db{vpd}->setNodeAttribs($name, + { mtm => $model, + serial => $serial, + }); } $db{vpd}{commit} = 1; ############################### # Update hosts table ############################### - if ( $otherinterfaces ) { - $db{hosts}->setNodeAttribs( $name, - { otherinterfaces=>$ips }); + if ($otherinterfaces) { + $db{hosts}->setNodeAttribs($name, + { otherinterfaces => $ips }); } else { - $db{hosts}->setNodeAttribs( $name, - { ip=>$ips }); + $db{hosts}->setNodeAttribs($name, + { ip => $ips }); } $db{hosts}{commit} = 1; - + ############################### # Update mac table ############################### - if ( $mac ) { - $db{mac}->setNodeAttribs( $name, - { mac=>$mac }); + if ($mac) { + $db{mac}->setNodeAttribs($name, + { mac => $mac }); } $db{mac}{commit} = 1; } ################################### - # Commit changes + # Commit changes ################################### - foreach ( @tabs ) { - if ( exists( $db{$_}{commit} )) { - $db{$_}->commit; + foreach (@tabs) { + if (exists($db{$_}{commit})) { + $db{$_}->commit; } } return undef; @@ -250,26 +250,27 @@ sub add_ppc { # Update lpar information in the xCAT databases ########################################################################## sub update_lpar { - my $hwtype = shift; - my $values = shift; - my $write = shift; - my @tabs = qw(ppc vpd nodehm nodelist nodetype ppcdirect hosts mac); - my %db = (); + my $hwtype = shift; + my $values = shift; + my $write = shift; + my @tabs = qw(ppc vpd nodehm nodelist nodetype ppcdirect hosts mac); + my %db = (); my @update_list = (); - my @write_list = (); + my @write_list = (); ################################### # Open database needed ################################### - foreach ( @tabs ) { - $db{$_} = xCAT::Table->new( $_, -create=>1, -autocommit=>0 ); - if ( !$db{$_} ) { - return( "Error opening '$_'" ); + foreach (@tabs) { + $db{$_} = xCAT::Table->new($_, -create => 1, -autocommit => 0); + if (!$db{$_}) { + return ("Error opening '$_'"); } } - my @vpdlist = $db{vpd}->getAllNodeAttribs(['node','serial','mtm','side']); - my @ppclist = $db{ppc}->getAllNodeAttribs(['node','hcp','id', - 'pprofile','parent','nodetype', - 'comments', 'disable']); + my @vpdlist = $db{vpd}->getAllNodeAttribs([ 'node', 'serial', 'mtm', 'side' ]); + my @ppclist = $db{ppc}->getAllNodeAttribs([ 'node', 'hcp', 'id', + 'pprofile', 'parent', 'nodetype', + 'comments', 'disable' ]); + # 'cec,cec1,,8246-L1D,100A9DA,,cec1,,cec1', # 'lpar,10-0A9DA,1,8246-L1D,100A9DA,,cec1,,cec1' my %ppchash = (); @@ -277,18 +278,18 @@ sub update_lpar { foreach my $ppcent (@ppclist) { if ($ppcent->{id} and $ppcent->{nodetype} and $ppcent->{nodetype} eq "lpar") { my $key = $ppcent->{node}; - $ppchash{$key}{id} = $ppcent->{id}; + $ppchash{$key}{id} = $ppcent->{id}; $ppchash{$key}{parent} = $ppcent->{parent}; } } foreach my $vpdent (@vpdlist) { my $key = $vpdent->{node}; - $vpdhash{$key}{mtm} = $vpdent->{mtm}; + $vpdhash{$key}{mtm} = $vpdent->{mtm}; $vpdhash{$key}{serial} = $vpdent->{serial}; } - my @ppc_lpars = keys %ppchash; - foreach my $value ( @$values ) { + my @ppc_lpars = keys %ppchash; + foreach my $value (@$values) { my ($ttype, $tname, $tid, @@ -298,40 +299,41 @@ sub update_lpar { $server, $pprofile, $parent) = split /,/, $value; - if ($ttype ne "lpar") { + + if ($ttype ne "lpar") { + push @update_list, $value; + next; + } + my $find_node = undef; + foreach my $tmp_node (@ppc_lpars) { + if ($ppchash{$tmp_node}{id} eq $tid) { + if (exists($ppchash{$tmp_node}{parent}) and $ppchash{$tmp_node}{parent} eq $parent) { + $find_node = $tmp_node; + last; + } elsif ($vpdhash{$tmp_node}{mtm} eq $tmtm and $vpdhash{$tmp_node}{serial} eq $tsn) { + $find_node = $tmp_node; + last; + } + } + } + if (defined($find_node)) { + if (update_node_attribs($hwtype, $ttype, $find_node, $tid, $tmtm, $tsn, $tside, + $server, $pprofile, $parent, "", \%db, $tname, \@ppclist)) + { + $value =~ s/^$ttype,$tname,/$ttype,$find_node,/; push @update_list, $value; - next; - } - my $find_node = undef; - foreach my $tmp_node (@ppc_lpars) { - if ($ppchash{$tmp_node}{id} eq $tid) { - if (exists($ppchash{$tmp_node}{parent}) and $ppchash{$tmp_node}{parent} eq $parent) { - $find_node = $tmp_node; - last; - } elsif ($vpdhash{$tmp_node}{mtm} eq $tmtm and $vpdhash{$tmp_node}{serial} eq $tsn) { - $find_node = $tmp_node; - last; - } - } - } - if (defined($find_node)) { - if ( update_node_attribs($hwtype, $ttype, $find_node, $tid, $tmtm, $tsn, $tside, - $server, $pprofile, $parent, "", \%db, $tname, \@ppclist)) - { - $value =~ s/^$ttype,$tname,/$ttype,$find_node,/; - push @update_list, $value; - } - } elsif (defined($write)) { - push @write_list, $value; } + } elsif (defined($write)) { + push @write_list, $value; + } } if (defined($write)) { - &add_ppc($hwtype, \@write_list,'','',"FSP"); - return ([@update_list,@write_list]); + &add_ppc($hwtype, \@write_list, '', '', "FSP"); + return ([ @update_list, @write_list ]); } else { - foreach ( @tabs ) { - if ( exists( $db{$_}{commit} )) { - $db{$_}->commit; + foreach (@tabs) { + if (exists($db{$_}{commit})) { + $db{$_}->commit; } } return \@update_list; @@ -343,32 +345,32 @@ sub update_lpar { ########################################################################## sub update_ppc { - my $hwtype = shift; - my $values = shift; + my $hwtype = shift; + my $values = shift; my $not_overwrite = shift; - my @tabs = qw(ppc vpd nodehm nodelist nodetype ppcdirect hosts mac); - my %db = (); + my @tabs = qw(ppc vpd nodehm nodelist nodetype ppcdirect hosts mac); + my %db = (); my @update_list = (); ################################### # Open database needed ################################### - foreach ( @tabs ) { - $db{$_} = xCAT::Table->new( $_, -create=>1, -autocommit=>0 ); - if ( !$db{$_} ) { - return( "Error opening '$_'" ); + foreach (@tabs) { + $db{$_} = xCAT::Table->new($_, -create => 1, -autocommit => 0); + if (!$db{$_}) { + return ("Error opening '$_'"); } } - my @vpdlist = $db{vpd}->getAllNodeAttribs(['node','serial','mtm','side']); - my @hostslist = $db{hosts}->getAllNodeAttribs(['node','ip']); - my @ppclist = $db{ppc}->getAllNodeAttribs(['node','hcp','id', - 'pprofile','parent','supernode', - 'comments', 'disable']); - my @maclist = $db{mac}->getAllNodeAttribs(['node','mac']); + my @vpdlist = $db{vpd}->getAllNodeAttribs([ 'node', 'serial', 'mtm', 'side' ]); + my @hostslist = $db{hosts}->getAllNodeAttribs([ 'node', 'ip' ]); + my @ppclist = $db{ppc}->getAllNodeAttribs([ 'node', 'hcp', 'id', + 'pprofile', 'parent', 'supernode', + 'comments', 'disable' ]); + my @maclist = $db{mac}->getAllNodeAttribs([ 'node', 'mac' ]); ################################### # Need to do database migration first ################################### - foreach my $value ( @$values ) { + foreach my $value (@$values) { my ($ttype, $tname, $tid, @@ -378,27 +380,28 @@ sub update_ppc { $server, $pprofile, $parent, - $ips ) = split /,/, $value; - if ( $ttype eq 'cec' ) + $ips) = split /,/, $value; + + if ($ttype eq 'cec') { - my $hostname = get_host($tname, "FSP", $tmtm, $tsn, "", "", $tid, "",""); - if ($hostname ne $tname) + my $hostname = get_host($tname, "FSP", $tmtm, $tsn, "", "", $tid, "", ""); + if ($hostname ne $tname) { $hostname =~ /\-(\w)$/; if ($1 =~ /^(A|B)$/) { $tside = $1; } - if ( update_node_attribs($hwtype, $ttype, $hostname, $tid, $tmtm, $tsn, $tside, - $server, $pprofile, $parent, $ips, \%db, $tname, \@ppclist)) + if (update_node_attribs($hwtype, $ttype, $hostname, $tid, $tmtm, $tsn, $tside, + $server, $pprofile, $parent, $ips, \%db, $tname, \@ppclist)) { - push @update_list, $value; + push @update_list, $value; } } - } elsif ( $ttype eq 'frame' ) + } elsif ($ttype eq 'frame') { - my $hostname = get_host($tname, "BPA", $tmtm, $tsn, "", "", $tid, "",""); - if ($hostname ne $tname) + my $hostname = get_host($tname, "BPA", $tmtm, $tsn, "", "", $tid, "", ""); + if ($hostname ne $tname) { $hostname =~ /\-(\w)$/; if ($1 =~ /^(A|B)$/) @@ -406,54 +409,19 @@ sub update_ppc { $tside = $1; } - if ( update_node_attribs($hwtype, $ttype, $hostname, $tid, $tmtm, $tsn, $tside, - $server, $pprofile, $parent, $ips, \%db, $tname, \@ppclist)) - { - push @update_list, $value; - } - } - } - } - - ################################### - # Update CEC in tables - ################################### - foreach my $value ( @$values ) { - my ($type, - $name, - $id, - $model, - $serial, - $side, - $server, - $pprofile, - $parent, - $ips ) = split /,/, $value; - next if ( $type ne 'cec' ); - my $predefined_node = undef; - foreach my $vpdent (@vpdlist) - { - if ( $vpdent->{mtm} eq $model && $vpdent->{serial} eq $serial ) - { - $predefined_node = $vpdent->{node}; - if ( update_node_attribs($hwtype, $type, $name, $id, $model, $serial, $side, - $server, $pprofile, $parent, $ips, - \%db, $predefined_node, \@ppclist)) + if (update_node_attribs($hwtype, $ttype, $hostname, $tid, $tmtm, $tsn, $tside, + $server, $pprofile, $parent, $ips, \%db, $tname, \@ppclist)) { push @update_list, $value; } } } - } - my @newppclist = $db{ppc}->getAllNodeAttribs(['node','hcp','id', - 'pprofile','parent','supernode', - 'comments', 'disable']); ################################### - # Update FRAME in tables + # Update CEC in tables ################################### - foreach my $value ( @$values ) { + foreach my $value (@$values) { my ($type, $name, $id, @@ -463,20 +431,55 @@ sub update_ppc { $server, $pprofile, $parent, - $ips ) = split /,/, $value; - - next if ( $type ne 'frame'); - + $ips) = split /,/, $value; + next if ($type ne 'cec'); my $predefined_node = undef; foreach my $vpdent (@vpdlist) { - if ( $vpdent->{mtm} eq $model && $vpdent->{serial} eq $serial && $vpdent->{side} eq $side ) + if ($vpdent->{mtm} eq $model && $vpdent->{serial} eq $serial) { $predefined_node = $vpdent->{node}; - if (update_node_attribs($hwtype, $type, $name, $id, $model, $serial, $side, - $server, $pprofile, $parent, $ips, - \%db, $predefined_node, \@newppclist)) + $server, $pprofile, $parent, $ips, + \%db, $predefined_node, \@ppclist)) + { + push @update_list, $value; + } + } + } + + } + + my @newppclist = $db{ppc}->getAllNodeAttribs([ 'node', 'hcp', 'id', + 'pprofile', 'parent', 'supernode', + 'comments', 'disable' ]); + ################################### + # Update FRAME in tables + ################################### + foreach my $value (@$values) { + my ($type, + $name, + $id, + $model, + $serial, + $side, + $server, + $pprofile, + $parent, + $ips) = split /,/, $value; + + next if ($type ne 'frame'); + + my $predefined_node = undef; + foreach my $vpdent (@vpdlist) + { + if ($vpdent->{mtm} eq $model && $vpdent->{serial} eq $serial && $vpdent->{side} eq $side) + { + $predefined_node = $vpdent->{node}; + + if (update_node_attribs($hwtype, $type, $name, $id, $model, $serial, $side, + $server, $pprofile, $parent, $ips, + \%db, $predefined_node, \@newppclist)) { push @update_list, $value; } @@ -486,11 +489,11 @@ sub update_ppc { } ################################### - # Commit changes + # Commit changes ################################### - foreach ( @tabs ) { - if ( exists( $db{$_}{commit} )) { - $db{$_}->commit; + foreach (@tabs) { + if (exists($db{$_}{commit})) { + $db{$_}->commit; } } return \@update_list; @@ -501,33 +504,33 @@ sub update_ppc { ########################################################################## sub update_node_attribs { - my $mgt = shift; - my $type = shift; - my $name = shift; - my $id = shift; - my $model = shift; - my $serial = shift; - my $side = shift; - my $server = shift; - my $pprofile = shift; - my $parent = shift; - my $ips = shift; - my $db = shift; + my $mgt = shift; + my $type = shift; + my $name = shift; + my $id = shift; + my $model = shift; + my $serial = shift; + my $side = shift; + my $server = shift; + my $pprofile = shift; + my $parent = shift; + my $ips = shift; + my $db = shift; my $predefined_node = shift; - my $ppclist = shift; + my $ppclist = shift; - my $updated = undef; + my $updated = undef; my $namediff = $name ne $predefined_node; - my $key_col = { node=>$predefined_node}; + my $key_col = { node => $predefined_node }; ############################# # update vpd table ############################# - my $vpdhash = $db->{vpd}->getNodeAttribs( $predefined_node, [qw(mtm serial)]); - if ( $model ne $vpdhash->{mtm} or $serial ne $vpdhash->{serial} or $namediff) + my $vpdhash = $db->{vpd}->getNodeAttribs($predefined_node, [qw(mtm serial)]); + if ($model ne $vpdhash->{mtm} or $serial ne $vpdhash->{serial} or $namediff) { - $db->{vpd}->delEntries( $key_col) if ( $namediff); - $db->{vpd}->setNodeAttribs( $name, { mtm=>$model, serial=>$serial, side=>$side}); + $db->{vpd}->delEntries($key_col) if ($namediff); + $db->{vpd}->setNodeAttribs($name, { mtm => $model, serial => $serial, side => $side }); $db->{vpd}->{commit} = 1; $updated = 1; } @@ -536,17 +539,17 @@ sub update_node_attribs # Update ppcdirect table ########################### my @users = qw(HMC admin general); - foreach my $user ( @users ) { - my $pwhash = $db->{ppcdirect}->getAttribs( {hcp=>$predefined_node,username=>$user}, qw(password comments disable)); # need regx - if ( $pwhash ) + foreach my $user (@users) { + my $pwhash = $db->{ppcdirect}->getAttribs({ hcp => $predefined_node, username => $user }, qw(password comments disable)); # need regx + if ($pwhash) { - if ( $namediff ) + if ($namediff) { - $db->{ppcdirect}->delEntries( {hcp=>$predefined_node,username=>$user}) if ( $namediff);; - $db->{ppcdirect}->setAttribs({hcp=>$name,username=>$user}, - {password=>$pwhash->{password}, - comments=>$pwhash->{comments}, - disable=>$pwhash->{disable}}); + $db->{ppcdirect}->delEntries({ hcp => $predefined_node, username => $user }) if ($namediff); + $db->{ppcdirect}->setAttribs({ hcp => $name, username => $user }, + { password => $pwhash->{password}, + comments => $pwhash->{comments}, + disable => $pwhash->{disable} }); $db->{ppcdirect}->{commit} = 1; $updated = 1; } @@ -556,35 +559,35 @@ sub update_node_attribs ############################# # update ppc table ############################# - my $ppchash = $db->{ppc}->getNodeAttribs( $predefined_node, [qw(hcp id pprofile parent)]); - if ( $ppchash->{parent} ne $predefined_node ) + my $ppchash = $db->{ppc}->getNodeAttribs($predefined_node, [qw(hcp id pprofile parent)]); + if ($ppchash->{parent} ne $predefined_node) { $parent = $ppchash->{parent}; } - if ( $server ne $ppchash->{hcp} or - $id ne $ppchash->{id} or - $pprofile ne $ppchash->{pprofile} or - $parent ne $ppchash->{parent} or - $type ne $ppchash->{nodetype} or - $namediff) + if ($server ne $ppchash->{hcp} or + $id ne $ppchash->{id} or + $pprofile ne $ppchash->{pprofile} or + $parent ne $ppchash->{parent} or + $type ne $ppchash->{nodetype} or + $namediff) { - $db->{ppc}->delEntries( $key_col) if ( $namediff); - $db->{ppc}->setNodeAttribs( $name, - { hcp=>$server, - id=>$id, - pprofile=>$pprofile, - parent=>$parent, - nodetype=>$globlehwtype{$type}, - }); - if ( $namediff) + $db->{ppc}->delEntries($key_col) if ($namediff); + $db->{ppc}->setNodeAttribs($name, + { hcp => $server, + id => $id, + pprofile => $pprofile, + parent => $parent, + nodetype => $globlehwtype{$type}, + }); + if ($namediff) { for my $ppcent (@$ppclist) { next if ($ppcent->{node} eq $predefined_node); if ($ppcent->{parent} eq $predefined_node) { - $db->{ppc}->setNodeAttribs( $ppcent->{node}, {parent=>$name}); + $db->{ppc}->setNodeAttribs($ppcent->{node}, { parent => $name }); } } } @@ -595,11 +598,11 @@ sub update_node_attribs ########################### # Update nodehm table ########################### - my $nodehmhash = $db->{nodehm}->getNodeAttribs( $predefined_node, [qw(mgt)]); - if ( $mgt ne $nodehmhash->{mgt} or $namediff) + my $nodehmhash = $db->{nodehm}->getNodeAttribs($predefined_node, [qw(mgt)]); + if ($mgt ne $nodehmhash->{mgt} or $namediff) { - $db->{nodehm}->delEntries( $key_col) if ( $namediff); - $db->{nodehm}->setNodeAttribs( $name, {mgt=>$mgt} ); + $db->{nodehm}->delEntries($key_col) if ($namediff); + $db->{nodehm}->setNodeAttribs($name, { mgt => $mgt }); $db->{nodehm}->{commit} = 1; $updated = 1; } @@ -607,11 +610,11 @@ sub update_node_attribs ########################### # Update nodetype table ########################### - my $nodetypehash = $db->{nodetype}->getNodeAttribs( $predefined_node, [qw(nodetype)]); - if ( $type ne $nodetypehash->{nodetype} or $namediff) + my $nodetypehash = $db->{nodetype}->getNodeAttribs($predefined_node, [qw(nodetype)]); + if ($type ne $nodetypehash->{nodetype} or $namediff) { - $db->{nodetype}->delEntries( $key_col) if ( $namediff); - $db->{nodetype}->setNodeAttribs( $name,{nodetype=>$globalnodetype{$type}} ); + $db->{nodetype}->delEntries($key_col) if ($namediff); + $db->{nodetype}->setNodeAttribs($name, { nodetype => $globalnodetype{$type} }); $db->{nodetype}->{commit} = 1; $updated = 1; } @@ -619,21 +622,21 @@ sub update_node_attribs ########################### # Update nodelist table ########################### - my $nodelisthash = $db->{nodelist}->getNodeAttribs( $predefined_node, [qw(groups status appstatus primarysn comments disable)]); - if ( $namediff) + my $nodelisthash = $db->{nodelist}->getNodeAttribs($predefined_node, [qw(groups status appstatus primarysn comments disable)]); + if ($namediff) { - updategroups( $name, $db->{nodelist}, $type ); + updategroups($name, $db->{nodelist}, $type); my $tmp_group = xCAT::data::ibmhwtypes::parse_group($model); if (defined($tmp_group)) { updategroups($name, $db->{nodelist}, $tmp_group); } - $db->{nodelist}->setNodeAttribs( $name, {status=>$nodelisthash->{status}, - appstatus=>$nodelisthash->{appstatus}, - primarysn=>$nodelisthash->{primarysn}, - comments=>$nodelisthash->{comments}, - disable=>$nodelisthash->{disable} - }); - $db->{nodelist}->delEntries( $key_col); + $db->{nodelist}->setNodeAttribs($name, { status => $nodelisthash->{status}, + appstatus => $nodelisthash->{appstatus}, + primarysn => $nodelisthash->{primarysn}, + comments => $nodelisthash->{comments}, + disable => $nodelisthash->{disable} + }); + $db->{nodelist}->delEntries($key_col); $db->{nodelist}->{commit} = 1; $updated = 1; } @@ -641,13 +644,13 @@ sub update_node_attribs ########################### # Update hosts table ########################### - my $hostslisthash = $db->{hosts}->getNodeAttribs( $predefined_node, [qw(ip otherinterfaces)]); - if ( $namediff ) + my $hostslisthash = $db->{hosts}->getNodeAttribs($predefined_node, [qw(ip otherinterfaces)]); + if ($namediff) { - $db->{hosts}->delEntries( $key_col); - $db->{hosts}->setNodeAttribs( $name,{ip=>$ips, - otherinterfaces=>$hostslisthash->{otherinterfaces} - } ); + $db->{hosts}->delEntries($key_col); + $db->{hosts}->setNodeAttribs($name, { ip => $ips, + otherinterfaces => $hostslisthash->{otherinterfaces} + }); $db->{hosts}->{commit} = 1; $updated = 1; } @@ -655,11 +658,11 @@ sub update_node_attribs ########################### # Update mac table ########################### - my $maclisthash = $db->{mac}->getNodeAttribs( $predefined_node, [qw(mac)]); - if ( $namediff ) + my $maclisthash = $db->{mac}->getNodeAttribs($predefined_node, [qw(mac)]); + if ($namediff) { - $db->{mac}->delEntries( $key_col); - $db->{mac}->setNodeAttribs( $name,{mac=>$maclisthash->{mac}} ); + $db->{mac}->delEntries($key_col); + $db->{mac}->setNodeAttribs($name, { mac => $maclisthash->{mac} }); $db->{mac}->{commit} = 1; $updated = 1; } @@ -668,7 +671,7 @@ sub update_node_attribs } ########################################################################## -# Updates the nodelist.groups attribute +# Updates the nodelist.groups attribute ########################################################################## sub updategroups { @@ -677,16 +680,16 @@ sub updategroups { my $hwtype = shift; ############################### - # Get current value + # Get current value ############################### - my ($ent) = $tab->getNodeAttribs( $name, ['groups'] ); - my @list = ( lc($hwtype), "all" ); + my ($ent) = $tab->getNodeAttribs($name, ['groups']); + my @list = (lc($hwtype), "all"); ############################### # Keep any existing groups ############################### - if ( defined($ent) and $ent->{groups} ) { - push @list, split( /,/, $ent->{groups} ); + if (defined($ent) and $ent->{groups}) { + push @list, split(/,/, $ent->{groups}); } ############################### # Remove duplicates @@ -695,7 +698,7 @@ sub updategroups { @saw{@list} = (); @list = keys %saw; - $tab->setNodeAttribs( $name, {groups=>join(",",@list)} ); + $tab->setNodeAttribs($name, { groups => join(",", @list) }); } @@ -714,47 +717,47 @@ sub add_ppchcp { ################################### # Open database needed ################################### - foreach ( @tabs ) { - $db{$_} = xCAT::Table->new( $_, -create=>1, -autocommit=>1 ); - if ( !$db{$_} ) { - return( "Error opening '$_'" ); + foreach (@tabs) { + $db{$_} = xCAT::Table->new($_, -create => 1, -autocommit => 1); + if (!$db{$_}) { + return ("Error opening '$_'"); } } ################################### # Update ppchcp table ################################### - my ($ent) = $db{ppchcp}->getNodeAttribs( $name,'hcp'); - if ( !defined($ent) ) { - $db{ppchcp}->setAttribs( {hcp=>$name}, - { username=>"", - password=>"" + my ($ent) = $db{ppchcp}->getNodeAttribs($name, 'hcp'); + if (!defined($ent)) { + $db{ppchcp}->setAttribs({ hcp => $name }, + { username => "", + password => "" }); } ################################### # Update nodehm table ################################### - $db{nodehm}->setNodeAttribs( $name, {mgt=>lc($hwtype)} ); - + $db{nodehm}->setNodeAttribs($name, { mgt => lc($hwtype) }); + ################################### # Update nodetype table ################################### - $db{nodetype}->setNodeAttribs( $name, {nodetype=>$globalnodetype{$hwtype}}); - $db{ppc}->setNodeAttribs( $name, {nodetype=>$globlehwtype{$hwtype}}); + $db{nodetype}->setNodeAttribs($name, { nodetype => $globalnodetype{$hwtype} }); + $db{ppc}->setNodeAttribs($name, { nodetype => $globlehwtype{$hwtype} }); ################################### # Update mac table ################################### - $db{mac}->setNodeAttribs( $name, {mac=>$mac}); + $db{mac}->setNodeAttribs($name, { mac => $mac }); ################################### # Update vpd table ################################### - $db{vpd}->setNodeAttribs( $name, {mtm=>$mtm}); - $db{vpd}->setNodeAttribs( $name, {serial=>$sn}); + $db{vpd}->setNodeAttribs($name, { mtm => $mtm }); + $db{vpd}->setNodeAttribs($name, { serial => $sn }); ################################### # Update nodelist table ################################### - updategroups( $name, $db{nodelist}, $hwtype ); + updategroups($name, $db{nodelist}, $hwtype); return undef; } @@ -767,18 +770,18 @@ sub rm_ppc { my $node = shift; my @tabs = qw(ppc nodehm nodelist); - foreach ( @tabs ) { + foreach (@tabs) { ################################### # Open table ################################### my $tab = xCAT::Table->new($_); - if ( !$tab ) { - return( "Error opening '$_'" ); + if (!$tab) { + return ("Error opening '$_'"); } ############################### # Remove entry ############################### - $tab->delEntries( {'node'=>$node} ); + $tab->delEntries({ 'node' => $node }); } return undef; } @@ -799,39 +802,39 @@ sub add_systemX { ################################### # Open database needed ################################### - foreach ( @tabs ) { - $db{$_} = xCAT::Table->new( $_, -create=>1, -autocommit=>1 ); - if ( !$db{$_} ) { - return( "Error opening '$_'" ); + foreach (@tabs) { + $db{$_} = xCAT::Table->new($_, -create => 1, -autocommit => 1); + if (!$db{$_}) { + return ("Error opening '$_'"); } } ################################### # Update mpa table ################################### - my ($ent) = $db{mpa}->getNodeAttribs( $name,'mpa'); - if ( !defined($ent) ) { - $db{mpa}->setAttribs( {mpa=>$name}, - { username=>"", - password=>"" + my ($ent) = $db{mpa}->getNodeAttribs($name, 'mpa'); + if (!defined($ent)) { + $db{mpa}->setAttribs({ mpa => $name }, + { username => "", + password => "" }); } ################################### # Update mp table ################################### - $db{mp}->setNodeAttribs( $name, - { mpa=>$name, - id=>"0" - }); + $db{mp}->setNodeAttribs($name, + { mpa => $name, + id => "0" + }); ################################### # Update nodehm table ################################### - $db{nodehm}->setNodeAttribs( $name, {mgt=>"blade"} ); + $db{nodehm}->setNodeAttribs($name, { mgt => "blade" }); ################################### # Update nodelist table ################################### - updategroups( $name, $db{nodelist}, $hwtype ); + updategroups($name, $db{nodelist}, $hwtype); return undef; } @@ -842,26 +845,26 @@ sub add_systemX { ########################################################################## sub credentials { - my $server = shift; - my $hwtype = shift; - my $user = shift; - my $pass = undef; + my $server = shift; + my $hwtype = shift; + my $user = shift; + my $pass = undef; my $user_specified = $user; - if ( !$user_specified or $user eq @{$logon{$hwtype}}[0]) + if (!$user_specified or $user eq @{ $logon{$hwtype} }[0]) { - $user = @{$logon{$hwtype}}[0]; - $pass = @{$logon{$hwtype}}[1]; + $user = @{ $logon{$hwtype} }[0]; + $pass = @{ $logon{$hwtype} }[1]; } ########################################### # find parent for fsp/bpa, use parent's attributes first ########################################### my $ntype = xCAT::DBobjUtils->getnodetype($server, "ppc"); - if ($ntype =~ /^(fsp|bpa)$/) { - my $ptab = xCAT::Table->new('ppc'); - if ($ptab) { + if ($ntype =~ /^(fsp|bpa)$/) { + my $ptab = xCAT::Table->new('ppc'); + if ($ptab) { my $parent = $ptab->getNodeAttribs($server, ["parent"]); - if ($parent and $parent->{parent}) { + if ($parent and $parent->{parent}) { my $ptype = xCAT::DBobjUtils->getnodetype($parent->{parent}, "ppc"); if (($ptype =~ /^cec$/ and $ntype =~ /^fsp$/) or ($ptype =~ /^frame$/ and $ntype =~ /^bpa$/)) { @@ -889,21 +892,21 @@ sub credentials { # if (defined($ent->{username})) { $user = $ent->{username}; } # } #} - my ($ent) = get_usr_passwd($hwtype, $user); + my ($ent) = get_usr_passwd($hwtype, $user); if ($ent) { - if (defined($ent->{password})) { $pass = $ent->{password};} - if (defined($ent->{username})) { $user = $ent->{username};} + if (defined($ent->{password})) { $pass = $ent->{password}; } + if (defined($ent->{username})) { $user = $ent->{username}; } } ########################################## - # Check table based on specific node + # Check table based on specific node ########################################## - my $tab = xCAT::Table->new( $hcptab{$hwtype} ); - if ( $tab ) { + my $tab = xCAT::Table->new($hcptab{$hwtype}); + if ($tab) { my $ent; - if ( $user_specified) - { # need regx - #($ent) = $tab->getAttribs( {hcp=>$server,username=>$user},qw(password)); - #($ent) = $tab->getNodeSpecAttribs( $server, {username=>$user},qw(password)); + if ($user_specified) + { # need regx + #($ent) = $tab->getAttribs( {hcp=>$server,username=>$user},qw(password)); + #($ent) = $tab->getNodeSpecAttribs( $server, {username=>$user},qw(password)); my @output = $tab->getNodeAttribs($server, qw(username password)); foreach my $tmp_entry (@output) { if ($tmp_entry->{username} =~ /^$user$/) { @@ -914,22 +917,22 @@ sub credentials { } else { - ($ent) = $tab->getNodeAttribs( $server, qw(username password)); + ($ent) = $tab->getNodeAttribs($server, qw(username password)); } - if ( $ent){ + if ($ent) { if (defined($ent->{password})) { $pass = $ent->{password}; } if (defined($ent->{username})) { $user = $ent->{username}; } } - ############################################################## - # If no user/passwd found, check if there is a default group - ############################################################## + ############################################################## + # If no user/passwd found, check if there is a default group + ############################################################## else { - if ( $user_specified) - { # need regx - #($ent) = $tab->getAllAttribs( {hcp=>$defaultgrp{$hwtype},username=>$user},qw(password)); - #($ent) = $tab->getNodeSpecAttribs( $defaultgrp{$hwtype}, {username=>$user},qw(password)); - my @output = $tab->getNodeAttribs( $defaultgrp{$hwtype}, qw(username password)); + if ($user_specified) + { # need regx + #($ent) = $tab->getAllAttribs( {hcp=>$defaultgrp{$hwtype},username=>$user},qw(password)); + #($ent) = $tab->getNodeSpecAttribs( $defaultgrp{$hwtype}, {username=>$user},qw(password)); + my @output = $tab->getNodeAttribs($defaultgrp{$hwtype}, qw(username password)); foreach my $tmp_entry (@output) { if ($tmp_entry->{username} =~ /^$user$/) { $ent = $tmp_entry; @@ -939,15 +942,15 @@ sub credentials { } else { - ($ent) = $tab->getNodeAttribs( $defaultgrp{$hwtype}, qw(username password)); + ($ent) = $tab->getNodeAttribs($defaultgrp{$hwtype}, qw(username password)); } - if ( $ent){ + if ($ent) { if (defined($ent->{password})) { $pass = $ent->{password}; } if (defined($ent->{username})) { $user = $ent->{username}; } } } } - return( $user,$pass ); + return ($user, $pass); } ########################################################################## @@ -955,23 +958,23 @@ sub credentials { # password for this user. ########################################################################## my %power_accounts = ( - HMC => 'abc123', + HMC => 'abc123', general => 'general', - admin => 'admin', + admin => 'admin', ); my %default_passwd_accounts = ( - system => { root => 'cluster',}, - hmc => { hscroot => 'abc123',}, - fsp => \%power_accounts, - bpa => \%power_accounts, - frame => \%power_accounts, - cec => \%power_accounts, - blade => { USERID => 'PASSW0RD', - HMC => 'PASSW0RD'}, - ipmi => { USERID => 'PASSW0RD',}, - ivm => { padmin => 'padmin',}, - vmware => { root => '',}, - vcenter => { Administrator => ''}, + system => { root => 'cluster', }, + hmc => { hscroot => 'abc123', }, + fsp => \%power_accounts, + bpa => \%power_accounts, + frame => \%power_accounts, + cec => \%power_accounts, + blade => { USERID => 'PASSW0RD', + HMC => 'PASSW0RD' }, + ipmi => { USERID => 'PASSW0RD', }, + ivm => { padmin => 'padmin', }, + vmware => { root => '', }, + vcenter => { Administrator => '' }, ); sub get_usr_passwd { @@ -986,7 +989,7 @@ sub get_usr_passwd { return undef; } if ($user) { - ($ent) = $passwdtab->getAttribs({key => $key, username => $user}, qw(password cryptmethod)); + ($ent) = $passwdtab->getAttribs({ key => $key, username => $user }, qw(password cryptmethod)); } else { ($ent) = $passwdtab->getNodeAttribs($key, qw(username password)); } @@ -997,7 +1000,7 @@ sub get_usr_passwd { $key = "bpa"; } if ($user) { - ($ent) = $passwdtab->getAttribs({key => $key, username => $user}, qw(password cryptmethod)); + ($ent) = $passwdtab->getAttribs({ key => $key, username => $user }, qw(password cryptmethod)); } else { ($ent) = $passwdtab->getNodeAttribs($key, qw(username password)); } @@ -1008,7 +1011,7 @@ sub get_usr_passwd { return undef; } if (!$user) { - my @tmp_keys = keys (%$hash); + my @tmp_keys = keys(%$hash); $user = $tmp_keys[0]; } $ent->{username} = $user; @@ -1020,7 +1023,7 @@ sub get_usr_passwd { ########################################################################## # Set userids and passwords to tables ########################################################################## -sub update_credentials +sub update_credentials { my $server = shift; @@ -1031,10 +1034,10 @@ sub update_credentials ########################################## # Set password to specific table ########################################## - my $tab = xCAT::Table->new( $hcptab{$hwtype} ); - if ( $tab ) { + my $tab = xCAT::Table->new($hcptab{$hwtype}); + if ($tab) { my $ent; - $tab->setAttribs( {hcp=>$server, username=>$user},{password=>$pass} ); + $tab->setAttribs({ hcp => $server, username => $user }, { password => $pass }); } return undef; @@ -1046,17 +1049,17 @@ sub update_credentials # if return undef, it means the ip is not invalid and won't make any definition ############################################################################# sub get_host { - my $nodename = shift; - my $type = shift; - my $mtm = shift; - my $sn = shift; - my $side = shift; - my $ip = shift; - my $cage_number = shift; - my $parmtm = shift; - my $parsn = shift; - my $pname = shift; - my $flagref = shift; + my $nodename = shift; + my $type = shift; + my $mtm = shift; + my $sn = shift; + my $side = shift; + my $ip = shift; + my $cage_number = shift; + my $parmtm = shift; + my $parsn = shift; + my $pname = shift; + my $flagref = shift; ####################################### # Extract IP from URL @@ -1064,29 +1067,31 @@ sub get_host { if ($ip) { my $nets = xCAT::NetworkUtils::my_nets(); - my $avip = getip_from_iplist( $ip, $nets); + my $avip = getip_from_iplist($ip, $nets); + #if ( !defined( $ip )) { # return undef; #} } + # get the information of existed nodes to do the migration read_from_table() unless (%::OLD_DATA_CACHE); - foreach my $oldnode ( keys %::OLD_DATA_CACHE ) + foreach my $oldnode (keys %::OLD_DATA_CACHE) { - my $tmpmtm = @{$::OLD_DATA_CACHE{$oldnode}}[0]; - my $tmpsn = @{$::OLD_DATA_CACHE{$oldnode}}[1]; - my $tmpside = @{$::OLD_DATA_CACHE{$oldnode}}[2]; - my $tmpip = @{$::OLD_DATA_CACHE{$oldnode}}[3]; - my $tmpid = @{$::OLD_DATA_CACHE{$oldnode}}[4]; - my $tmpparent = @{$::OLD_DATA_CACHE{$oldnode}}[5]; - my $tmptype = uc(@{$::OLD_DATA_CACHE{$oldnode}}[6]); - my $unmatched = @{$::OLD_DATA_CACHE{$oldnode}}[7]; + my $tmpmtm = @{ $::OLD_DATA_CACHE{$oldnode} }[0]; + my $tmpsn = @{ $::OLD_DATA_CACHE{$oldnode} }[1]; + my $tmpside = @{ $::OLD_DATA_CACHE{$oldnode} }[2]; + my $tmpip = @{ $::OLD_DATA_CACHE{$oldnode} }[3]; + my $tmpid = @{ $::OLD_DATA_CACHE{$oldnode} }[4]; + my $tmpparent = @{ $::OLD_DATA_CACHE{$oldnode} }[5]; + my $tmptype = uc(@{ $::OLD_DATA_CACHE{$oldnode} }[6]); + my $unmatched = @{ $::OLD_DATA_CACHE{$oldnode} }[7]; # used to match fsp defined by xcatsetup - # should return fast to save time + # should return fast to save time if (($type eq "BPA" or $type eq "FSP") and ($tmptype eq $type) and $pname and $side) { - if ($pname eq $tmpparent and $side eq $tmpside) { + if ($pname eq $tmpparent and $side eq $tmpside) { $$flagref = 1; return $oldnode; } @@ -1098,20 +1103,20 @@ sub get_host { next; } - if ( $tmpmtm eq $mtm and $tmpsn eq $sn) { + if ($tmpmtm eq $mtm and $tmpsn eq $sn) { my $ifip = xCAT::NetworkUtils->isIpaddr($oldnode); - if ( $ifip ) {# which means that the node is defined by the new lsslp - if ( $tmpside eq $side ) {# match! which means that node is the same as the new one - if ( $ip eq $tmpip ) { #which means that the ip is not changed - # maybe we should check if the ip is invalid and send a warning + if ($ifip) { # which means that the node is defined by the new lsslp + if ($tmpside eq $side) { # match! which means that node is the same as the new one + if ($ip eq $tmpip) { #which means that the ip is not changed + # maybe we should check if the ip is invalid and send a warning $$flagref = 1; return $ip; - } else { #which means that the ip is changed + } else { #which means that the ip is changed my $vip = check_ip($ip); - if ( !$vip ) { #which means the ip is changed and valid - # maybe we should check if the old ip is invalid and send a warning - # even so we should keep the definition as before - # because this case, we can't put check_ip in the end + if (!$vip) { #which means the ip is changed and valid + # maybe we should check if the old ip is invalid and send a warning + # even so we should keep the definition as before + # because this case, we can't put check_ip in the end $$flagref = 1; return $oldnode; } else { @@ -1120,56 +1125,58 @@ sub get_host { } } } - else { # name is not a ip + else { # name is not a ip $side =~ /(\w)\-(\w)/; my $slot = $1; - if ( $tmpside and $tmpside !~ /\-/ ) {# side is like A or B - if ( $slot eq $tmpside ) { - if ( $oldnode =~ /^Server\-/) {#judge if need to change node's name - if ( $ip eq $tmpip ) { - if ( $oldnode =~ /\-(A|B)$/) { - @{$::OLD_DATA_CACHE{$oldnode}}[7] = 0; + if ($tmpside and $tmpside !~ /\-/) { # side is like A or B + if ($slot eq $tmpside) { + if ($oldnode =~ /^Server\-/) { #judge if need to change node's name + if ($ip eq $tmpip) { + if ($oldnode =~ /\-(A|B)$/) { + @{ $::OLD_DATA_CACHE{$oldnode} }[7] = 0; $$flagref = 1; - return $oldnode; + return $oldnode; } else { - @{$::OLD_DATA_CACHE{$oldnode}}[7] = 0; + @{ $::OLD_DATA_CACHE{$oldnode} }[7] = 0; + #change node name, need to record the node here - $::UPDATE_CACHE{$mtm.'-'.$sn} = $oldnode; + $::UPDATE_CACHE{ $mtm . '-' . $sn } = $oldnode; $$flagref = 1; - return $oldnode.'-'.$slot; + return $oldnode . '-' . $slot; } - } else {# not find a matched definition, but need to use the old node name - if ($unmatched){ + } else { # not find a matched definition, but need to use the old node name + if ($unmatched) { $$flagref = 1; return $oldnode; } } - } elsif ( $tmpside =~ /\-/ ) {# end of if ( $oldnode =~ /^Server\-/) - if ( $ip eq $tmpip ) { - @{$::OLD_DATA_CACHE{$oldnode}}[7] = 0; + } elsif ($tmpside =~ /\-/) { # end of if ( $oldnode =~ /^Server\-/) + if ($ip eq $tmpip) { + @{ $::OLD_DATA_CACHE{$oldnode} }[7] = 0; $$flagref = 1; return $oldnode; - } else{ - if ($unmatched){ + } else { + if ($unmatched) { $$flagref = 1; return $oldnode; } } } } - } elsif ( $tmpside =~ /\-/ ){ - if ( $side eq $tmpside ) { + } elsif ($tmpside =~ /\-/) { + if ($side eq $tmpside) { $$flagref = 1; return $oldnode; } - } elsif ( !$tmpside ) { - if ( $oldnode =~ /^Server\-/) {#judge if need to change node's name - if ( $oldnode !~ /\-(A|B)$/ ) { + } elsif (!$tmpside) { + if ($oldnode =~ /^Server\-/) { #judge if need to change node's name + if ($oldnode !~ /\-(A|B)$/) { delete $::OLD_DATA_CACHE{$oldnode}; - $$flagref = 1; - return $oldnode."-".$slot; + $$flagref = 1; + return $oldnode . "-" . $slot; } } + # if mtms could match but side not defined, we will trate # it as the result by rscan. And alway use its name. delete $::OLD_DATA_CACHE{$oldnode}; @@ -1177,20 +1184,21 @@ sub get_host { return $oldnode; } } - }# end of if ($tmpmtm eq $mtm and $tmpsn eq $sn) + } # end of if ($tmpmtm eq $mtm and $tmpsn eq $sn) - } - if ( ($type eq "FRAME" or $type eq "CEC") and ($type eq $tmptype)){ - if ( !$tmpmtm and !$tmpid) { + } + if (($type eq "FRAME" or $type eq "CEC") and ($type eq $tmptype)) { + if (!$tmpmtm and !$tmpid) { next; } + # user may define cec only with parent /id /type # we should match this situation - if ( ($type eq "CEC") and $parmtm and $parsn and $cage_number ) { - my $tpparmtm = @{$::OLD_DATA_CACHE{$tmpparent}}[0]; - my $tpparsn = @{$::OLD_DATA_CACHE{$tmpparent}}[1]; - if ( ($tpparmtm eq $parmtm) and ($tpparsn eq $parsn) and ($cage_number eq $tmpid) and ($type eq $tmptype) ) { + if (($type eq "CEC") and $parmtm and $parsn and $cage_number) { + my $tpparmtm = @{ $::OLD_DATA_CACHE{$tmpparent} }[0]; + my $tpparsn = @{ $::OLD_DATA_CACHE{$tmpparent} }[1]; + if (($tpparmtm eq $parmtm) and ($tpparsn eq $parsn) and ($cage_number eq $tmpid) and ($type eq $tmptype)) { $$flagref = 1; return $oldnode; } @@ -1198,15 +1206,16 @@ sub get_host { # user may define cec/frame only with mtms # but what we consider here is just the data in xCAT 2.6 - if ($tmpmtm eq $mtm and $tmpsn eq $sn and $tmptype eq $type) { - if ( $oldnode =~ /^Server\-/) {#judge if need to change node's name - if ( $oldnode =~ /(\-A)$/) { + if ($tmpmtm eq $mtm and $tmpsn eq $sn and $tmptype eq $type) { + if ($oldnode =~ /^Server\-/) { #judge if need to change node's name + if ($oldnode =~ /(\-A)$/) { $nodename = s/(\-A)$//; + # should send a warning here $$flagref = 1; return $nodename; } - else { + else { $$flagref = 1; return $oldnode; } @@ -1215,16 +1224,16 @@ sub get_host { return $oldnode; } } - } # end of foreach my $oldnode ( keys %::OLD_DATA_CACHE ), not match + } # end of foreach my $oldnode ( keys %::OLD_DATA_CACHE ), not match } # not matched, use the new name my $ifip = xCAT::NetworkUtils->isIpaddr($nodename); unless ($ifip) { return $nodename; - }else { + } else { my $vip = check_ip($nodename); - if ( $vip ) {#which means the ip is a valid one + if ($vip) { #which means the ip is a valid one return $nodename; } else { return undef; @@ -1238,35 +1247,35 @@ sub get_host { ########################################################################## sub getip_from_iplist { - my $iplist = shift; - my $nets = shift; - my $inc = shift; + my $iplist = shift; + my $nets = shift; + my $inc = shift; - my @ips = split /,/, $iplist; + my @ips = split /,/, $iplist; my @ips2 = split /,/, $inc; - if ( $inc) + if ($inc) { for my $net (keys %$nets) { my $flag = 1; for my $einc (@ips2) { - if ( $nets->{$net} eq $einc) { + if ($nets->{$net} eq $einc) { $flag = 0; } } - delete $nets->{$net} if ($flag) ; + delete $nets->{$net} if ($flag); } } for my $ip (@ips) { - next if ( $ip =~ /:/); #skip IPV6 addresses - for my $net ( keys %$nets) + next if ($ip =~ /:/); #skip IPV6 addresses + for my $net (keys %$nets) { - my ($n,$m) = split /\//,$net; - if ( xCAT::NetworkUtils::isInSameSubnet( $n, $ip, $m, 1) and - xCAT::NetworkUtils::isPingable( $ip)) + my ($n, $m) = split /\//, $net; + if (xCAT::NetworkUtils::isInSameSubnet($n, $ip, $m, 1) and + xCAT::NetworkUtils::isPingable($ip)) { return $ip; } @@ -1280,77 +1289,78 @@ sub read_from_table { my %typehash; my %iphash; my %vpdhash; - if ( !(%::OLD_DATA_CACHE)) + if (!(%::OLD_DATA_CACHE)) { # find out all the existed nodes' ipaddresses - my $hoststab = xCAT::Table->new('hosts'); - if ( $hoststab ) { - my @ipentries = $hoststab->getAllNodeAttribs( ['node','ip'] ); - for my $ipentry ( @ipentries ) { - $iphash{$ipentry->{node}} = $ipentry->{ip}; + my $hoststab = xCAT::Table->new('hosts'); + if ($hoststab) { + my @ipentries = $hoststab->getAllNodeAttribs([ 'node', 'ip' ]); + for my $ipentry (@ipentries) { + $iphash{ $ipentry->{node} } = $ipentry->{ip}; } } else { return 1; } #find out all the existed nodes' type - my $nodetypetab = xCAT::Table->new('nodetype'); - if ( $nodetypetab ) { - my @typeentries = $nodetypetab->getAllNodeAttribs( ['node','nodetype'] ); - for my $typeentry ( @typeentries) { - $typehash{$typeentry->{node}} = $typeentry->{nodetype}; + my $nodetypetab = xCAT::Table->new('nodetype'); + if ($nodetypetab) { + my @typeentries = $nodetypetab->getAllNodeAttribs([ 'node', 'nodetype' ]); + for my $typeentry (@typeentries) { + $typehash{ $typeentry->{node} } = $typeentry->{nodetype}; } } else { return 2; } # find out all the existed nodes' mtms and side - my $vpdtab = xCAT::Table->new( 'vpd' ); - if ( $vpdtab ) { - my @vpdentries = $vpdtab->getAllNodeAttribs(['node','mtm','serial','side']); - for my $entry ( @vpdentries ) { - @{$vpdhash{$entry->{node}}}[0] = $entry->{mtm}; - @{$vpdhash{$entry->{node}}}[1] = $entry->{serial}; - @{$vpdhash{$entry->{node}}}[2] = $entry->{side}; + my $vpdtab = xCAT::Table->new('vpd'); + if ($vpdtab) { + my @vpdentries = $vpdtab->getAllNodeAttribs([ 'node', 'mtm', 'serial', 'side' ]); + for my $entry (@vpdentries) { + @{ $vpdhash{ $entry->{node} } }[0] = $entry->{mtm}; + @{ $vpdhash{ $entry->{node} } }[1] = $entry->{serial}; + @{ $vpdhash{ $entry->{node} } }[2] = $entry->{side}; } } else { return 3; } + # find out all the existed nodes' attributes - my $ppctab = xCAT::Table->new('ppc'); - if ( $ppctab ) { - my @identries = $ppctab->getAllNodeAttribs( ['node','id','parent','nodetype'] ); - for my $entry ( @identries ) { + my $ppctab = xCAT::Table->new('ppc'); + if ($ppctab) { + my @identries = $ppctab->getAllNodeAttribs([ 'node', 'id', 'parent', 'nodetype' ]); + for my $entry (@identries) { next if ($entry->{nodetype} =~ /lpar/); - @{$::OLD_DATA_CACHE{$entry->{node}}}[0] = @{$vpdhash{$entry->{node}}}[0];#mtm - @{$::OLD_DATA_CACHE{$entry->{node}}}[1] = @{$vpdhash{$entry->{node}}}[1];#sn - @{$::OLD_DATA_CACHE{$entry->{node}}}[2] = @{$vpdhash{$entry->{node}}}[2];#side - # find node ip address, check node name first, then check hosts table + @{ $::OLD_DATA_CACHE{ $entry->{node} } }[0] = @{ $vpdhash{ $entry->{node} } }[0]; #mtm + @{ $::OLD_DATA_CACHE{ $entry->{node} } }[1] = @{ $vpdhash{ $entry->{node} } }[1]; #sn + @{ $::OLD_DATA_CACHE{ $entry->{node} } }[2] = @{ $vpdhash{ $entry->{node} } }[2]; #side + # find node ip address, check node name first, then check hosts table my $ifip = xCAT::NetworkUtils->isIpaddr($entry->{node}); - if ( $ifip ) + if ($ifip) { - @{$::OLD_DATA_CACHE{$entry->{node}}}[3] = $entry->{node};#ip + @{ $::OLD_DATA_CACHE{ $entry->{node} } }[3] = $entry->{node}; #ip } else { - if ( exists ($iphash{$entry->{node}}) ) { - @{$::OLD_DATA_CACHE{$entry->{node}}}[3] = $iphash{$entry->{node}};#ip + if (exists($iphash{ $entry->{node} })) { + @{ $::OLD_DATA_CACHE{ $entry->{node} } }[3] = $iphash{ $entry->{node} }; #ip } - else { - @{$::OLD_DATA_CACHE{$entry->{node}}}[3] = "";#ip + else { + @{ $::OLD_DATA_CACHE{ $entry->{node} } }[3] = ""; #ip } } - @{$::OLD_DATA_CACHE{$entry->{node}}}[4] = $entry->{id};#id - @{$::OLD_DATA_CACHE{$entry->{node}}}[5] = $entry->{parent};#parent - if ( exists $entry->{nodetype}) { - @{$::OLD_DATA_CACHE{$entry->{node}}}[6] = $entry->{nodetype};#nodetype + @{ $::OLD_DATA_CACHE{ $entry->{node} } }[4] = $entry->{id}; #id + @{ $::OLD_DATA_CACHE{ $entry->{node} } }[5] = $entry->{parent}; #parent + if (exists $entry->{nodetype}) { + @{ $::OLD_DATA_CACHE{ $entry->{node} } }[6] = $entry->{nodetype}; #nodetype } else { - if ( exists ($typehash{$entry->{node}}) ) { - @{$::OLD_DATA_CACHE{$entry->{node}}}[6] = $typehash{$entry->{node}}; + if (exists($typehash{ $entry->{node} })) { + @{ $::OLD_DATA_CACHE{ $entry->{node} } }[6] = $typehash{ $entry->{node} }; } else { - @{$::OLD_DATA_CACHE{$entry->{node}}}[6] = ""; + @{ $::OLD_DATA_CACHE{ $entry->{node} } }[6] = ""; } - } - @{$::OLD_DATA_CACHE{$entry->{node}}}[7] = 1; + } + @{ $::OLD_DATA_CACHE{ $entry->{node} } }[7] = 1; } } else { @@ -1364,8 +1374,8 @@ sub read_from_table { # return 1 if valid, 0 if invalid ########################################################################## sub check_ip { - my $myip = shift; - my $firstoctet = $myip; + my $myip = shift; + my $firstoctet = $myip; my @invalidiplist = ( "192.168.2.144", "192.168.2.145", @@ -1383,7 +1393,7 @@ sub check_ip { "127.0.0.0", "127", 0, - ); + ); $firstoctet =~ s/^(\d+)\..*/$1/; if ($firstoctet >= 224 and $firstoctet <= 239) { @@ -1391,7 +1401,7 @@ sub check_ip { } foreach (@invalidiplist) { - if ( $myip =~ /^($_)/ ) + if ($myip =~ /^($_)/) { return 0; } diff --git a/perl-xCAT/xCAT/PPCenergy.pm b/perl-xCAT/xCAT/PPCenergy.pm index eb8c53723..0e7e7047b 100644 --- a/perl-xCAT/xCAT/PPCenergy.pm +++ b/perl-xCAT/xCAT/PPCenergy.pm @@ -16,37 +16,39 @@ use xCAT::DBobjUtils; use xCAT::FSPUtils; use xCAT::TableUtils; %::QUERY_ATTRS = ( -'savingstatus' => 1, -'dsavingstatus' => 1, -'cappingstatus' => 1, -'cappingmaxmin' => 1, -'cappingvalue' => 1, -'cappingsoftmin' => 1, -'averageAC' => 1, -'averageDC' => 1, -'ambienttemp' => 1, -'exhausttemp' => 1, -'CPUspeed' => 1, -'syssbpower' => 1, -'sysIPLtime' => 1, -# for FFO, only supported when communicating to fsp directly -'ffoMin' => 1, -'ffoVmin' => 1, -'ffoTurbo' => 1, -'ffoNorm' => 1, -'fsavingstatus' => 1, -'ffovalue' => 1, + 'savingstatus' => 1, + 'dsavingstatus' => 1, + 'cappingstatus' => 1, + 'cappingmaxmin' => 1, + 'cappingvalue' => 1, + 'cappingsoftmin' => 1, + 'averageAC' => 1, + 'averageDC' => 1, + 'ambienttemp' => 1, + 'exhausttemp' => 1, + 'CPUspeed' => 1, + 'syssbpower' => 1, + 'sysIPLtime' => 1, + + # for FFO, only supported when communicating to fsp directly + 'ffoMin' => 1, + 'ffoVmin' => 1, + 'ffoTurbo' => 1, + 'ffoNorm' => 1, + 'fsavingstatus' => 1, + 'ffovalue' => 1, ); %::SET_ATTRS = ( -'savingstatus' => 1, -'dsavingstatus' => 1, -'cappingstatus' => 1, -'cappingwatt' => 1, -'cappingperc' => 1, -# for FFO -'fsavingstatus' => 1, -'ffovalue' => 1, + 'savingstatus' => 1, + 'dsavingstatus' => 1, + 'cappingstatus' => 1, + 'cappingwatt' => 1, + 'cappingperc' => 1, + + # for FFO + 'fsavingstatus' => 1, + 'ffovalue' => 1, ); $::CIM_CLIENT_PATH = "$::XCATROOT/sbin/xCAT_cim_client"; @@ -55,30 +57,30 @@ $::CIM_CLIENT_PATH = "$::XCATROOT/sbin/xCAT_cim_client"; sub parse_args { my $request = shift; - my %opt = (); - my $cmd = $request->{command}; - my $args = $request->{arg}; - my $nodes = $request->{node}; + my %opt = (); + my $cmd = $request->{command}; + my $args = $request->{arg}; + my $nodes = $request->{node}; my $query_attrs = (); # The attributes list for query operation - my $set_pair = (); # The attribute need to be set. e.g. savingstatus=on - my $set_flag = (); # Indicate there's setting param in the argv - my $argv_flag = (); # Indicate there's param in the argv - my @notfspnodes = (); # The nodes list which are not fsp + my $set_pair = (); # The attribute need to be set. e.g. savingstatus=on + my $set_flag = (); # Indicate there's setting param in the argv + my $argv_flag = (); # Indicate there's param in the argv + my @notfspnodes = (); # The nodes list which are not fsp # set the usage subroutine local *usage = sub { my $usage_string = xCAT::Usage->getUsage($cmd); - return( [ $_[0], $usage_string ] ); + return ([ $_[0], $usage_string ]); }; if ($request->{arg}) { - @ARGV = @{$request->{arg}}; + @ARGV = @{ $request->{arg} }; $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); + Getopt::Long::Configure("bundling"); if ($nodes) { - if (!GetOptions( 'V' => \$::VERBOSE )) { + if (!GetOptions('V' => \$::VERBOSE)) { return (&usage()); } @@ -92,7 +94,7 @@ sub parse_args { # Check the validity of the parameters of Query and Set foreach my $attr (@ARGV) { - my ($set_attr, $set_value) = split (/=/, $attr); + my ($set_attr, $set_value) = split(/=/, $attr); if (defined($set_value)) { if ($argv_flag) { return (&usage()); @@ -100,24 +102,24 @@ sub parse_args { if ($::SET_ATTRS{$set_attr} != 1) { return (&usage()); } - - if (($set_attr eq "savingstatus" || $set_attr eq "fsavingstatus") - && ($set_value ne "on" && $set_value ne "off")) { + + if (($set_attr eq "savingstatus" || $set_attr eq "fsavingstatus") + && ($set_value ne "on" && $set_value ne "off")) { return (&usage()); } elsif ($set_attr eq "dsavingstatus" - && ($set_value ne "off" - && $set_value ne "on-norm" && $set_value ne "on-maxp")) { + && ($set_value ne "off" + && $set_value ne "on-norm" && $set_value ne "on-maxp")) { return (&usage()); - } elsif ($set_attr eq "cappingstatus" - && ($set_value ne "on" && $set_value ne "off")) { + } elsif ($set_attr eq "cappingstatus" + && ($set_value ne "on" && $set_value ne "off")) { return (&usage()); - } elsif ( ($set_attr eq "cappingwatt" - || $set_attr eq "cappingperc" || $set_attr eq "ffovalue") - && $set_value =~ /\D/) { + } elsif (($set_attr eq "cappingwatt" + || $set_attr eq "cappingperc" || $set_attr eq "ffovalue") + && $set_value =~ /\D/) { return (&usage()); } - - $set_pair = $set_attr."=".$set_value; + + $set_pair = $set_attr . "=" . $set_value; $set_flag = 1; } else { if ($set_flag) { @@ -130,14 +132,14 @@ sub parse_args { if (!$set_flag) { my @query_list = @ARGV; - + if ($query_list[0] eq "all" and $#query_list == 0) { $query_attrs = "all"; } else { my @no_dup_query_list = (); foreach my $q_attr (@query_list) { chomp($q_attr); - + if ($::QUERY_ATTRS{$q_attr} != 1) { return (&usage()); } @@ -146,26 +148,27 @@ sub parse_args { push @no_dup_query_list, $q_attr; } } - $query_attrs = join (',', @no_dup_query_list); + $query_attrs = join(',', @no_dup_query_list); } } } else { + # If has not nodes, the -h or -v option must be input - if (!GetOptions( 'h|help' => \$::HELP, - 'v|version' => \$::VERSION)) { + if (!GetOptions('h|help' => \$::HELP, + 'v|version' => \$::VERSION)) { return (&usage()); } - - if (! ($::HELP || $::VERSION) ) { + + if (!($::HELP || $::VERSION)) { return (&usage()); } if ($::HELP) { return (&usage()); } - + if ($::VERSION) { my $version_string = xCAT::Usage->getVersion('renergy'); - return( [ $_[0], $version_string] ); + return ([ $_[0], $version_string ]); } if (scalar(@ARGV)) { @@ -183,7 +186,7 @@ sub parse_args { #} #my $nodetype_v = $nodetype_tb->getNodesAttribs($nodes, ['nodetype']); - my $nodetyperef = xCAT::DBobjUtils->getnodetype($nodes, "ppc"); + my $nodetyperef = xCAT::DBobjUtils->getnodetype($nodes, "ppc"); my $i = 0; foreach my $node (@{$nodes}) { if ($$nodetyperef{$node} ne 'fsp' && @@ -192,10 +195,11 @@ sub parse_args { } $i++; } + #$nodetype_tb->close(); if (@notfspnodes) { - return ([undef, "Error: The hardware type of following nodes are not fsp or cec: ".join(',', @notfspnodes)]); + return ([ undef, "Error: The hardware type of following nodes are not fsp or cec: " . join(',', @notfspnodes) ]); } if ($query_attrs) { @@ -210,28 +214,28 @@ sub parse_args { # Handle the energy query and setting work sub renergy { - my $request = shift; - my $hcphost = shift; + my $request = shift; + my $hcphost = shift; my $nodehash = shift; my @return_msg = (); - my $opt = $request->{'opt'}; + my $opt = $request->{'opt'}; my $verbose = $opt->{'verbose'}; - # Get the CEC + # Get the CEC my ($node, $attrs) = %$nodehash; my $cec_name = @$attrs[2]; - my $hw_type = @$attrs[4]; - + my $hw_type = @$attrs[4]; + if (!$cec_name) { - return ([[$node, "ERROR: Cannot find the cec name, check the attributes: vpd.serial, vpd.mtm.", 1]]); + return ([ [ $node, "ERROR: Cannot find the cec name, check the attributes: vpd.serial, vpd.mtm.", 1 ] ]); } # Check the existence of cim client - if ( (! -f $::CIM_CLIENT_PATH) - || (! -x $::CIM_CLIENT_PATH) ) { - return ([[$node, "ERROR: Cannot find the Energy Management Plugin for xCAT [$::CIM_CLIENT_PATH] or it's NOT executable. Please install the xCAT-cimclient package correctly. Get more information from man page of renergy command.", 1]]); + if ((!-f $::CIM_CLIENT_PATH) + || (!-x $::CIM_CLIENT_PATH)) { + return ([ [ $node, "ERROR: Cannot find the Energy Management Plugin for xCAT [$::CIM_CLIENT_PATH] or it's NOT executable. Please install the xCAT-cimclient package correctly. Get more information from man page of renergy command.", 1 ] ]); } my $verb_arg = ""; @@ -245,123 +249,127 @@ sub renergy { my $password; if ($hcp_type eq "hmc") { ($user, $password) = xCAT::PPCdb::credentials($hcphost, $hcp_type); - } else { - ($user, $password) = xCAT::PPCdb::credentials($hcphost, $hcp_type,'HMC'); + } else { + ($user, $password) = xCAT::PPCdb::credentials($hcphost, $hcp_type, 'HMC'); } - my $fsps; #The node of fsp that belong to the cec + my $fsps; #The node of fsp that belong to the cec my @hcps_ip; if ($hcp_type ne "hmc" && $hw_type eq "cec") { $fsps = xCAT::DBobjUtils->getchildren($node); - if( !defined($fsps) ) { - return ([[$node, "Failed to get the FSPs for the cec $hcphost.", -1]]); + if (!defined($fsps)) { + return ([ [ $node, "Failed to get the FSPs for the cec $hcphost.", -1 ] ]); } + #my $hcp_ip = xCAT::NetworkUtils::getNodeIPaddress($hcphost); my $hcp_ip = xCAT::FSPUtils::getIPaddress($request, $hw_type, $hcphost); if (!defined($hcp_ip) or ($hcp_ip == -3)) { - return ([[$node, "Failed to get IP address for $hcphost.", -1]]); + return ([ [ $node, "Failed to get IP address for $hcphost.", -1 ] ]); } push @hcps_ip, split(',', $hcp_ip); my $fsp_node = $$fsps[0]; - ($user, $password) = xCAT::PPCdb::credentials( $fsp_node, "fsp",'HMC'); - if ( !$password) { - return ([[$node, "Cannot get password of userid 'HMC'. Please check table 'ppchcp' or 'ppcdirect'.", -1]]); + ($user, $password) = xCAT::PPCdb::credentials($fsp_node, "fsp", 'HMC'); + if (!$password) { + return ([ [ $node, "Cannot get password of userid 'HMC'. Please check table 'ppchcp' or 'ppcdirect'.", -1 ] ]); } } else { + # for the case that hcp is hmc or fsp push @hcps_ip, xCAT::NetworkUtils::getNodeIPaddress($hcphost); } if (!$user || !$password) { - return ([[$node, "Cannot get user:password for the node. Please check table 'ppchcp' or 'ppcdirect'.", -1]]); + return ([ [ $node, "Cannot get user:password for the node. Please check table 'ppchcp' or 'ppcdirect'.", -1 ] ]); } # secure passwd in verbose mode my $tmpv = $verbose; $verbose = 0; if ($verbose) { - push @return_msg, [$node, "Attributes of $node:\n User=$user\n Password=$password\n CEC=$cec_name\n nodetype=$hw_type\n inithcp=$hcphost\n hcps=@hcps_ip\n hcptype=$hcp_type", 0]; + push @return_msg, [ $node, "Attributes of $node:\n User=$user\n Password=$password\n CEC=$cec_name\n nodetype=$hw_type\n inithcp=$hcphost\n hcps=@hcps_ip\n hcptype=$hcp_type", 0 ]; } $verbose = $tmpv; my @pingable_hcp; - if (-x '/usr/bin/nmap' or -x '/usr/local/bin/nmap') { #use nmap - #print "use nmap\n"; - if ($verbose) { - push @return_msg, [$node, "Checking ping status using nmap for @hcps_ip", 0]; - } - my %deadnodes; - foreach (@hcps_ip) { - $deadnodes{$_}=1; - } + if (-x '/usr/bin/nmap' or -x '/usr/local/bin/nmap') { #use nmap + #print "use nmap\n"; + if ($verbose) { + push @return_msg, [ $node, "Checking ping status using nmap for @hcps_ip", 0 ]; + } + my %deadnodes; + foreach (@hcps_ip) { + $deadnodes{$_} = 1; + } - # get additional options from site table - my @nmap_options = xCAT::TableUtils->get_site_attribute("nmapoptions"); - my $more_options = $nmap_options[0]; + # get additional options from site table + my @nmap_options = xCAT::TableUtils->get_site_attribute("nmapoptions"); + my $more_options = $nmap_options[0]; - open (NMAP, "nmap -PE --system-dns --send-ip -sP $more_options ". join(' ',@hcps_ip) . " 2> /dev/null|") or die("Cannot open nmap pipe: $!"); - my $node; - while () { - #print "$_\n"; - if (/Host (.*) \((.*)\) appears to be up/) { - $node=$2; - unless ($deadnodes{$node}) { - foreach (keys %deadnodes) { - if ($node =~ /^$_\./) { - $node = $_; - last; - } - } - } - delete $deadnodes{$node}; - if ($verbose) { - push @return_msg, [$node, $_, 0]; - } - push(@pingable_hcp, $node); - } elsif (/Nmap scan report for ([^ ]*)/) { - $node=$1; - } elsif (/Host is up./) { - unless ($deadnodes{$node}) { - foreach (keys %deadnodes) { - if ($node =~ /^$_\./) { - $node = $_; - last; - } - } - } - delete $deadnodes{$node}; - push(@pingable_hcp, $node); - } - } + open(NMAP, "nmap -PE --system-dns --send-ip -sP $more_options " . join(' ', @hcps_ip) . " 2> /dev/null|") or die("Cannot open nmap pipe: $!"); + my $node; + while () { + + #print "$_\n"; + if (/Host (.*) \((.*)\) appears to be up/) { + $node = $2; + unless ($deadnodes{$node}) { + foreach (keys %deadnodes) { + if ($node =~ /^$_\./) { + $node = $_; + last; + } + } + } + delete $deadnodes{$node}; + if ($verbose) { + push @return_msg, [ $node, $_, 0 ]; + } + push(@pingable_hcp, $node); + } elsif (/Nmap scan report for ([^ ]*)/) { + $node = $1; + } elsif (/Host is up./) { + unless ($deadnodes{$node}) { + foreach (keys %deadnodes) { + if ($node =~ /^$_\./) { + $node = $_; + last; + } + } + } + delete $deadnodes{$node}; + push(@pingable_hcp, $node); + } + } } else { - #use fping - #print "use fping\n"; - my $master = xCAT::TableUtils->get_site_Master(); - my $masterip = xCAT::NetworkUtils->getipaddr($master); - if ($masterip =~ /:/) { #IPv6, needs fping6 support - if (!-x '/usr/bin/fping6') - { - push @return_msg, [$node, "fping6 is not availabe for IPv6 ping.", -1]; - return \@return_msg; - } - open (FPING, "fping6 ".join(' ',@hcps_ip). " 2>&1 |") or die("Cannot open fping pipe: $!"); - } else { - open (FPING, "fping ".join(' ',@hcps_ip). " 2>&1 |") or die("Cannot open fping pipe: $!"); - } - - while () { - if ($verbose) { - push @return_msg, [$node, $_, 0]; - } - if ($_ =~ /is alive/) { - s/ is alive//; - push @pingable_hcp, $_; - } - } + + #use fping + #print "use fping\n"; + my $master = xCAT::TableUtils->get_site_Master(); + my $masterip = xCAT::NetworkUtils->getipaddr($master); + if ($masterip =~ /:/) { #IPv6, needs fping6 support + if (!-x '/usr/bin/fping6') + { + push @return_msg, [ $node, "fping6 is not availabe for IPv6 ping.", -1 ]; + return \@return_msg; + } + open(FPING, "fping6 " . join(' ', @hcps_ip) . " 2>&1 |") or die("Cannot open fping pipe: $!"); + } else { + open(FPING, "fping " . join(' ', @hcps_ip) . " 2>&1 |") or die("Cannot open fping pipe: $!"); + } + + while () { + if ($verbose) { + push @return_msg, [ $node, $_, 0 ]; + } + if ($_ =~ /is alive/) { + s/ is alive//; + push @pingable_hcp, $_; + } + } } if (!@pingable_hcp) { - push @return_msg, [$node, "No hcp can be pinged.", -1]; + push @return_msg, [ $node, "No hcp can be pinged.", -1 ]; return \@return_msg; } @@ -370,18 +378,19 @@ sub renergy { my @noerr_msg; my @last_msg; foreach my $hcp (@pingable_hcp) { - push @noerr_msg, @lastnoerr_msg; + push @noerr_msg, @lastnoerr_msg; @lastnoerr_msg = (); - @last_msg = (); + @last_msg = (); + # Generate the url path for CIM communication chomp($hcp); - my $url_path = "https://"."$user".":"."$password"."\@"."$hcp".":5989"; + my $url_path = "https://" . "$user" . ":" . "$password" . "\@" . "$hcp" . ":5989"; # Not display password in command outupt. - my $display_url_path = "https://"."$user".":"."xxxxxx"."\@"."$hcp".":5989"; - + my $display_url_path = "https://" . "$user" . ":" . "xxxxxx" . "\@" . "$hcp" . ":5989"; + # Execute the request - my $cmd = ""; + my $cmd = ""; my $display_cmd = ""; if ($opt->{'set'}) { $cmd = "$::CIM_CLIENT_PATH $verb_arg -u $url_path -n $cec_name -o $opt->{'set'}"; @@ -390,21 +399,21 @@ sub renergy { $cmd = "$::CIM_CLIENT_PATH $verb_arg -u $url_path -n $cec_name -o $opt->{'query'}"; $display_cmd = "$::CIM_CLIENT_PATH $verb_arg -u $display_url_path -n $cec_name -o $opt->{'query'}"; } - + if ($verbose) { - push @noerr_msg, [$node, "Run following command: $display_cmd", 0]; + push @noerr_msg, [ $node, "Run following command: $display_cmd", 0 ]; } - - # Disable the CHID signal before run the command. Otherwise the + + # Disable the CHID signal before run the command. Otherwise the # $? value of `$cmd` will come from handler of CHID signal - $SIG{CHLD} = 'DEFAULT'; - + $SIG{CHLD} = 'DEFAULT'; + # Call the xCAT_cim_client to query or set the energy capabilities $cmd .= " 2>&1"; # secure passwd in verbose mode my $tmpv = $::VERBOSE; - $::VERBOSE = 0; + $::VERBOSE = 0; my @result = xCAT::Utils->runcmd("$cmd", -1); $::VERBOSE = $tmpv; @@ -413,8 +422,8 @@ sub renergy { if ($line =~ /^\s*$/) { next; } - push @lastnoerr_msg, [$node, $line, 0]; - push @last_msg, [$node, $line, $::RUNCMD_RC]; + push @lastnoerr_msg, [ $node, $line, 0 ]; + push @last_msg, [ $node, $line, $::RUNCMD_RC ]; } if (!$::RUNCMD_RC) { last; @@ -424,7 +433,7 @@ sub renergy { # only display the correct msg when getting correct result from one fsp if ($::RUNCMD_RC || $verbose) { push @return_msg, @noerr_msg; - } + } push @return_msg, @last_msg; return \@return_msg; diff --git a/perl-xCAT/xCAT/PPCfsp.pm b/perl-xCAT/xCAT/PPCfsp.pm index 9ae78cb1e..081ac4217 100644 --- a/perl-xCAT/xCAT/PPCfsp.pm +++ b/perl-xCAT/xCAT/PPCfsp.pm @@ -9,7 +9,7 @@ use HTML::Form; use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR); use xCAT::Usage; use Socket; -use xCAT::PPCdb; +use xCAT::PPCdb; use xCAT::MsgUtils qw(verbose_message); use xCAT::Utils; use xCAT::TableUtils; @@ -17,30 +17,30 @@ use xCAT::NetworkUtils; ########################################## # Globals ########################################## -my %cmds = ( - rpower => { - state => ["Power On/Off System", \&state], - powercmd => ["Power On/Off System", \&powercmd], - powercmd_boot => ["Power On/Off System", \&boot], - reset => ["System Reboot", \&reset] }, - reventlog => { - all => ["Error/Event Logs", \&all], - all_clear => ["Error/Event Logs", \&all_clear], - entries => ["Error/Event Logs", \&entries], - clear => ["Error/Event Logs", \&clear] }, - rspconfig => { - memdecfg => ["Memory Deconfiguration", \&memdecfg], - decfg => ["Deconfiguration Policies", \&decfg], - procdecfg => ["Processor Deconfiguration", \&procdecfg], - iocap => ["I/O Adapter Enlarged Capacity", \&iocap], - time => ["Time Of Day", \&time], - date => ["Time Of Day", \&date], - autopower => ["Auto Power Restart", \&autopower], - sysdump => ["System Dump", \&sysdump], - spdump => ["Service Processor Dump", \&spdump], - network => ["Network Configuration", \&netcfg], - dev => ["Service Processor Command Line", \&devenable], - celogin1 => ["Service Processor Command Line", \&ce1enable]}, +my %cmds = ( + rpower => { + state => [ "Power On/Off System", \&state ], + powercmd => [ "Power On/Off System", \&powercmd ], + powercmd_boot => [ "Power On/Off System", \&boot ], + reset => [ "System Reboot", \&reset ] }, + reventlog => { + all => [ "Error/Event Logs", \&all ], + all_clear => [ "Error/Event Logs", \&all_clear ], + entries => [ "Error/Event Logs", \&entries ], + clear => [ "Error/Event Logs", \&clear ] }, + rspconfig => { + memdecfg => [ "Memory Deconfiguration", \&memdecfg ], + decfg => [ "Deconfiguration Policies", \&decfg ], + procdecfg => [ "Processor Deconfiguration", \&procdecfg ], + iocap => [ "I/O Adapter Enlarged Capacity", \&iocap ], + time => [ "Time Of Day", \&time ], + date => [ "Time Of Day", \&date ], + autopower => [ "Auto Power Restart", \&autopower ], + sysdump => [ "System Dump", \&sysdump ], + spdump => [ "Service Processor Dump", \&spdump ], + network => [ "Network Configuration", \&netcfg ], + dev => [ "Service Processor Command Line", \&devenable ], + celogin1 => [ "Service Processor Command Line", \&ce1enable ] }, ); @@ -57,30 +57,30 @@ sub handler { ##################################### # Convert command to correct format ##################################### - if ( ref($request->{method}) ne "HASH" ) { - $request->{method} = [{$request->{method}=>undef}]; + if (ref($request->{method}) ne "HASH") { + $request->{method} = [ { $request->{method} => undef } ]; } ##################################### - # Process FSP command + # Process FSP command ##################################### my @outhash; - my $result = process_cmd( $exp, $request ); + my $result = process_cmd($exp, $request); - foreach ( @$result ) { + foreach (@$result) { my %output; $output{node}->[0]->{name}->[0] = $request->{host}; - $output{node}->[0]->{data}->[0]->{contents}->[0] = $server. ": ".@$_[1]; + $output{node}->[0]->{data}->[0]->{contents}->[0] = $server . ": " . @$_[1]; $output{node}->[0]->{cmd}->[0] = @$_[2]; $output{errorcode} = @$_[0]; push @outhash, \%output; } ##################################### - # Disconnect from FSP + # Disconnect from FSP ##################################### unless ($flag) { - xCAT::PPCfsp::disconnect( $exp ); - } - return( \@outhash ); + xCAT::PPCfsp::disconnect($exp); + } + return (\@outhash); } @@ -97,13 +97,13 @@ sub connect { my $lwp_log; ################################## - # Use timeout from site table + # Use timeout from site table ################################## - if ( !$timeout ) { + if (!$timeout) { $timeout = 30; } ################################## - # Get userid/password + # Get userid/password ################################## my $cred = undef; if (($req->{dev} eq '1') or ($req->{command} eq 'rpower')) { @@ -113,12 +113,12 @@ sub connect { $cred = $req->{$server}{cred}; } ################################## - # Redirect STDERR to variable + # Redirect STDERR to variable ################################## - if ( $verbose ) { + if ($verbose) { close STDERR; - if ( !open( STDERR, '>', \$lwp_log )) { - return( "Unable to redirect STDERR: $!" ); + if (!open(STDERR, '>', \$lwp_log)) { + return ("Unable to redirect STDERR: $!"); } } $IO::Socket::SSL::VERSION = undef; @@ -127,14 +127,14 @@ sub connect { ################################## # Turn on tracing ################################## - if ( $verbose ) { - LWP::Debug::level( '+' ); + if ($verbose) { + LWP::Debug::level('+'); } ################################## # Create cookie ################################## my $cookie = HTTP::Cookies->new(); - $cookie->set_cookie( 0,'asm_session','0','cgi-bin','','443',0,0,3600,0 ); + $cookie->set_cookie(0, 'asm_session', '0', 'cgi-bin', '', '443', 0, 0, 3600, 0); ################################## # Create UserAgent @@ -151,69 +151,71 @@ sub connect { # $server = $hostshash->{ip}; # } #} - $server = xCAT::NetworkUtils::getNodeIPaddress( $server ); + $server = xCAT::NetworkUtils::getNodeIPaddress($server); unless ($server) { - return( "Unable to get IP address for $server" ); + return ("Unable to get IP address for $server"); } -# my $serverip = inet_ntoa(inet_aton($server)); + + # my $serverip = inet_ntoa(inet_aton($server)); my $url = "https://$server/cgi-bin/cgi?form=2"; - $ua->cookie_jar( $cookie ); - $ua->timeout( $timeout ); + $ua->cookie_jar($cookie); + $ua->timeout($timeout); ################################## # Submit logon ################################## - my $res = $ua->post( $url, - [ user => @$cred[0], - password => @$cred[1], - lang => "0", - submit => "Log in" ] + my $res = $ua->post($url, + [ user => @$cred[0], + password => @$cred[1], + lang => "0", + submit => "Log in" ] ); ################################## # Logon failed ################################## - if ( !$res->is_success() ) { - return( $lwp_log.$res->status_line ); + if (!$res->is_success()) { + return ($lwp_log . $res->status_line); } ################################## # To minimize number of GET/POSTs, - # if we successfully logon, we should + # if we successfully logon, we should # get back a valid cookie: # Set-Cookie: asm_session=3038839768778613290 # ################################## - if ( $res->as_string =~ /Set-Cookie: asm_session=(\d+)/ ) { + if ($res->as_string =~ /Set-Cookie: asm_session=(\d+)/) { ############################## # Successful logon.... # Return: - # UserAgent + # UserAgent # Server hostname # UserId # Redirected STDERR/STDOUT ############################## - return( $ua, - $server, - @$cred[0], - \$lwp_log ); + return ($ua, + $server, + @$cred[0], + \$lwp_log); } ############################## - # Logon error + # Logon error ############################## - $res = $ua->get( $url ); + $res = $ua->get($url); - if ( !$res->is_success() ) { - return( $lwp_log.$res->status_line ); + if (!$res->is_success()) { + return ($lwp_log . $res->status_line); } ############################## # Check for specific failures ############################## - if ( $res->content =~ /(Invalid user ID or password|Too many users)/i ) { - return( $lwp_log.$1 . ". Please check node attribute hcp and its password settings."); + if ($res->content =~ /(Invalid user ID or password|Too many users)/i) { + return ($lwp_log . $1 . ". Please check node attribute hcp and its password settings."); } - return( $lwp_log."Logon failure" ); + return ($lwp_log . "Logon failure"); } + sub ce1enable { return &loginenable($_[0], $_[1], $_[2], "celogin1"); } @@ -223,107 +225,112 @@ sub devenable { } my %cmdline_for_log = ( dev => { - enable => "registry -Hw nets/DevEnabled 1", - disable => "registry -Hw nets/DevEnabled 0", - check_pwd => "registry -l DevPwdFile", + enable => "registry -Hw nets/DevEnabled 1", + disable => "registry -Hw nets/DevEnabled 0", + check_pwd => "registry -l DevPwdFile", create_pwd => "netsDynPwdTool --create dev FipSdev", - password => "FipSdev" + password => "FipSdev" }, celogin1 => { - enable => "registry -Hw nets/CE1Enabled 1", - disable => "registry -Hw nets/CE1Enabled 0", - check_pwd => "registry -l Ce1PwdFile", + enable => "registry -Hw nets/CE1Enabled 1", + disable => "registry -Hw nets/CE1Enabled 0", + check_pwd => "registry -l Ce1PwdFile", create_pwd => "netsDynPwdTool --create celogin1 FipSce1", - password => "FipSce1" + password => "FipSce1" }, - ); +); + sub send_command { - my $ua = shift; - my $server = shift; - my $id = shift; + my $ua = shift; + my $server = shift; + my $id = shift; my $log_name = shift; - my $cmd = shift; + my $cmd = shift; my $cmd_line = $cmdline_for_log{$log_name}{$cmd}; if (!defined($cmd_line)) { return undef; } - my $res = $ua->post( "https://$server/cgi-bin/cgi", - [ form => $id, - cmd => $cmd_line, + my $res = $ua->post("https://$server/cgi-bin/cgi", + [ form => $id, + cmd => $cmd_line, submit => "Execute" ] - ); + ); - if ( !$res->is_success() ) { + if (!$res->is_success()) { return undef; } - if ( $res->content =~ /(not allowed.*\.|Invalid entry)/ ) { + if ($res->content =~ /(not allowed.*\.|Invalid entry)/) { return undef; - } + } return $res->content; } + sub loginstate { - my $ua = shift; - my $server = shift; + my $ua = shift; + my $server = shift; my $log_name = shift; - my $url = "https://$server/cgi-bin/cgi?form=4"; - my $res = $ua->get($url); + my $url = "https://$server/cgi-bin/cgi?form=4"; + my $res = $ua->get($url); if (!$res->is_success()) { - return ([RC_ERROR, $res->status_line]); + return ([ RC_ERROR, $res->status_line ]); } if ($res->content =~ m#[\d\D]+Status[\d\D]+$log_name]*>(\w+)#) { my $out = sprintf("%9s: %8s", $log_name, $1); - return ( [SUCCESS, $out]); + return ([ SUCCESS, $out ]); } else { - return ( [RC_ERROR, "not found status for $log_name"]); + return ([ RC_ERROR, "not found status for $log_name" ]); } } sub loginenable { - my $exp = shift; - my $request = shift; - my $id = shift; + my $exp = shift; + my $request = shift; + my $id = shift; my $log_name = shift; - my $ua = @$exp[0]; - my $server = @$exp[1]; - + my $ua = @$exp[0]; + my $server = @$exp[1]; + my $value = $request->{method}{$log_name}; if (!defined($value)) { return &loginstate($ua, $server, $log_name); - } + } my $url = "https://$server/cgi-bin/cgi?form=$id"; - my $res = $ua->get( $url ); + my $res = $ua->get($url); if (!$res->is_success()) { - return( [RC_ERROR,$res->status_line] ); + return ([ RC_ERROR, $res->status_line ]); } $res = &send_command($ua, $server, $id, $log_name, $value); if (!defined($res)) { - return ([RC_ERROR, "Send command Failed"]); + return ([ RC_ERROR, "Send command Failed" ]); } - if ( $value =~ m/^disable$/ ) { + if ($value =~ m/^disable$/) { my $out = sprintf("%9s: Disabled", $log_name); - return( [SUCCESS, $out] ); + return ([ SUCCESS, $out ]); } -#check password# + + #check password# $res = &send_command($ua, $server, $id, $log_name, "check_pwd"); if (!defined($res)) { - return ([RC_ERROR, "Send command Failed"]); + return ([ RC_ERROR, "Send command Failed" ]); } - my $password = undef; + my $password = undef; if ($res =~ m/\[\d+([a-zA-Z]+)\d+\]/) { $password = $1; } else { -# create password # + + # create password # $res = &send_command($ua, $server, $id, $log_name, "create_pwd"); if (!defined($res)) { - return ([RC_ERROR, "Send command Failed"]); + return ([ RC_ERROR, "Send command Failed" ]); } $password = $cmdline_for_log{$log_name}{password}; print "create password for $log_name is '$cmdline_for_log{$log_name}{password}'\n"; } my $out = sprintf("%9s: Enabled, password: $password", $log_name); - return( [SUCCESS, $out] ); + return ([ SUCCESS, $out ]); } + sub disconnect { my $exp = shift; @@ -334,16 +341,16 @@ sub disconnect { ################################## # POST Logoff ################################## - my $res = $ua->post( "https://$server/cgi-bin/cgi?form=1", - [ submit => "Log out" ] + my $res = $ua->post("https://$server/cgi-bin/cgi?form=1", + [ submit => "Log out" ] ); ################################## # Logoff failed ################################## - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } - return( [SUCCESS,"Success"] ); + return ([ SUCCESS, "Success" ]); } @@ -357,8 +364,8 @@ sub process_cmd { my $ua = @$exp[0]; my $server = @$exp[1]; my $uid = @$exp[2]; - my $command = $request->{command}; - my $methods = $request->{method}; + my $command = $request->{command}; + my $methods = $request->{method}; my %menu = (); my @result; @@ -369,47 +376,47 @@ sub process_cmd { # same across FSP models/firmware # versions. ################################## - my $res = $ua->post( "https://$server/cgi-bin/cgi", - [ form => "2", - e => "1" ] + my $res = $ua->post("https://$server/cgi-bin/cgi", + [ form => "2", + e => "1" ] ); ################################## # Return error ################################## - if ( !$res->is_success() ) { + if (!$res->is_success()) { my @tmpres = (RC_ERROR, $res->status_line); my @rs; push @rs, \@tmpres; - return(\@rs ); + return (\@rs); } ################################## # Build hash of expanded menus ################################## - foreach ( split /\n/, $res->content ) { - if ( /form=(\d+).*window.status='(.*)'/ ) { + foreach (split /\n/, $res->content) { + if (/form=(\d+).*window.status='(.*)'/) { $menu{$2} = $1; } } - foreach ( keys %$methods ) { + foreach (keys %$methods) { ############################## - # Get form id + # Get form id ############################## - my $form = $menu{$cmds{$command}{$_}[0]}; - if ( !defined( $form )) { - my @tmpres = (RC_ERROR, "Cannot find '$cmds{$command}{$_}[0]' menu"); - my @rs; - push @rs, \@tmpres; - return(\@rs ); + my $form = $menu{ $cmds{$command}{$_}[0] }; + if (!defined($form)) { + my @tmpres = (RC_ERROR, "Cannot find '$cmds{$command}{$_}[0]' menu"); + my @rs; + push @rs, \@tmpres; + return (\@rs); } ################################## - # Run command + # Run command ################################## - xCAT::MsgUtils->verbose_message($request, "$command :$_ for node:$server."); + xCAT::MsgUtils->verbose_message($request, "$command :$_ for node:$server."); my $res = $cmds{$command}{$_}[1]($exp, $request, $form, \%menu); - push @$res, $_; + push @$res, $_; push @result, $res; } - return( \@result ); + return (\@result); } @@ -425,23 +432,23 @@ sub state { my $server = @$exp[1]; ################################## - # Get current power status + # Get current power status ################################## - my $res = $ua->get( "https://$server/cgi-bin/cgi?form=$id" ); + my $res = $ua->get("https://$server/cgi-bin/cgi?form=$id"); ################################## # Return error ################################## - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } ################################## # Get power state ################################## - if ( $res->content =~ /Current system power state: (.*)
/) { - return( [SUCCESS,$1] ); + if ($res->content =~ /Current system power state: (.*)
/) { + return ([ SUCCESS, $1 ]); } - return( [RC_ERROR,"unknown"] ); + return ([ RC_ERROR, "unknown" ]); } @@ -458,72 +465,72 @@ sub powercmd { my $server = @$exp[1]; ################################## - # Get Power On/Off System URL + # Get Power On/Off System URL ################################## - my $res = $ua->get( "https://$server/cgi-bin/cgi?form=$id" ); + my $res = $ua->get("https://$server/cgi-bin/cgi?form=$id"); ################################## # Return error ################################## - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } ################################## # Get current power state ################################## - if ( $res->content !~ /Current system power state: (.*)
/) { - return( [RC_ERROR,"Unable to determine current power state"] ); + if ($res->content !~ /Current system power state: (.*)
/) { + return ([ RC_ERROR, "Unable to determine current power state" ]); } my $state = $1; ################################## # Already in that state ################################## - if ( $op =~ /^$state$/i ) { - return( [SUCCESS,"Success"] ); + if ($op =~ /^$state$/i) { + return ([ SUCCESS, "Success" ]); } ################################## - # Get "Power On/Off System" form + # Get "Power On/Off System" form ################################## - my $form = HTML::Form->parse( $res->content, $res->base ); + my $form = HTML::Form->parse($res->content, $res->base); ################################## # Return error ################################## - if ( !defined( $form )) { - return( [RC_ERROR,"'Power On/Off System' form not found"] ); + if (!defined($form)) { + return ([ RC_ERROR, "'Power On/Off System' form not found" ]); } ################################## # Get "Save and Submit" button ################################## - my $button = ($op eq "on") ? "on" : "of"; + my $button = ($op eq "on") ? "on" : "of"; my @inputs = $form->inputs(); - if ( !grep( $_->{name} eq $button, @inputs )) { - return( [RC_ERROR,"Unable to power $op from state: $state"] ); - } + if (!grep($_->{name} eq $button, @inputs)) { + return ([ RC_ERROR, "Unable to power $op from state: $state" ]); + } ################################## - # Send command + # Send command ################################## - my $data = $form->click( $button ); - $res = $ua->request( $data ); + my $data = $form->click($button); + $res = $ua->request($data); ################################## # Return error ################################## - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } - if ( $res->content =~ /(not allowed.*\.)/ ) { - return( [RC_ERROR,$1] ); + if ($res->content =~ /(not allowed.*\.)/) { + return ([ RC_ERROR, $1 ]); } ################################## - # Success + # Success ################################## - if ( $res->content =~ /(Operation completed successfully)/ ) { - return( [SUCCESS,"Success"] ); + if ($res->content =~ /(Operation completed successfully)/) { + return ([ SUCCESS, "Success" ]); } - return( [RC_ERROR,"Unknown error"] ); + return ([ RC_ERROR, "Unknown error" ]); } @@ -539,28 +546,28 @@ sub reset { my $server = @$exp[1]; ################################## - # Send Reset command + # Send Reset command ################################## - my $res = $ua->post( "https://$server/cgi-bin/cgi", - [ form => $id, - submit => "Continue" ] + my $res = $ua->post("https://$server/cgi-bin/cgi", + [ form => $id, + submit => "Continue" ] ); ################################## # Return error ################################## - if ( !$res->is_success()) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } - if ( $res->content =~ /(This feature is only available.*)/ ) { - return( [RC_ERROR,$1] ); + if ($res->content =~ /(This feature is only available.*)/) { + return ([ RC_ERROR, $1 ]); } ################################## # Success ################################## - if ( $res->content =~ /(Operation completed successfully)/ ) { - return( [SUCCESS,"Success"] ); + if ($res->content =~ /(Operation completed successfully)/) { + return ([ SUCCESS, "Success" ]); } - return( [RC_ERROR,"Unknown error"] ); + return ([ RC_ERROR, "Unknown error" ]); } @@ -578,43 +585,43 @@ sub boot { ################################## # Check current power state ################################## - my $state = xCAT::PPCfsp::state( - $exp, - $request, - $menu->{$cmds{$command}{state}[0]}, - $menu ); + my $state = xCAT::PPCfsp::state( + $exp, + $request, + $menu->{ $cmds{$command}{state}[0] }, + $menu); my $Rc = shift(@$state); ################################## - # Return error + # Return error ################################## - if ( $Rc != SUCCESS ) { - return( [$Rc,@$state[0]] ); + if ($Rc != SUCCESS) { + return ([ $Rc, @$state[0] ]); } - if ( @$state[0] !~ /^(on|off)$/i ) { - return( [RC_ERROR,"Unable to boot in state: '@$state[0]'"] ); + if (@$state[0] !~ /^(on|off)$/i) { + return ([ RC_ERROR, "Unable to boot in state: '@$state[0]'" ]); } ################################## - # Get command + # Get command ################################## - $request->{op} = "on"; - my $method = ( $state =~ /^on$/i ) ? "reset" : "powercmd"; - + $request->{op} = "on"; + my $method = ($state =~ /^on$/i) ? "reset" : "powercmd"; + ################################## # Get command form id ################################## - $id = $menu->{$cmds{$command}{$method}[0]}; + $id = $menu->{ $cmds{$command}{$method}[0] }; ################################## # Run command ################################## - my $result = $cmds{$command}{$method}[1]( $exp, $request, $id ); - return( $result ); + my $result = $cmds{$command}{$method}[1]($exp, $request, $id); + return ($result); } ########################################################################## -# Clears Error/Event Logs +# Clears Error/Event Logs ########################################################################## sub clear { @@ -623,40 +630,40 @@ sub clear { my $id = shift; my $ua = @$exp[0]; my $server = @$exp[1]; - + ################################## - # Get Error/Event Logs URL + # Get Error/Event Logs URL ################################## - my $res = $ua->get( "https://$server/cgi-bin/cgi?form=$id" ); + my $res = $ua->get("https://$server/cgi-bin/cgi?form=$id"); ################################## # Return error ################################## - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } ################################## # Clear all error/event log entries: # Are you sure? (OK/Cancel) ################################## - my $form = HTML::Form->parse( $res->content, $res->base ); + my $form = HTML::Form->parse($res->content, $res->base); ################################## # Return error ################################## - if ( !defined( $form )) { - return( [RC_ERROR,"'Error/Event Logs' form not found"] ); + if (!defined($form)) { + return ([ RC_ERROR, "'Error/Event Logs' form not found" ]); } ################################## - # Send Clear to JavaScript + # Send Clear to JavaScript ################################## - my $data = $form->click( 'clear' ); - $res = $ua->request( $data ); + my $data = $form->click('clear'); + $res = $ua->request($data); - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } - return( [SUCCESS,"Success"] ); + return ([ SUCCESS, "Success" ]); } @@ -671,20 +678,20 @@ sub entries { my $ua = @$exp[0]; my $server = @$exp[1]; my $opt = $request->{opt}; - my $count = (exists($opt->{e})) ? $opt->{e} : -1; + my $count = (exists($opt->{e})) ? $opt->{e} : -1; my $result; my $i = 1; ################################## # Get log entries ################################## - my $res = $ua->get( "https://$server/cgi-bin/cgi?form=$id" ); - + my $res = $ua->get("https://$server/cgi-bin/cgi?form=$id"); + ################################## # Return error ################################## - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } my @entries = split /\n/, $res->content; @@ -692,29 +699,29 @@ sub entries { # Prepend header ################################## $result = (@entries) ? - "\n#Log ID Time Failing subsystem Severity SRC\n" : - "No entries"; - +"\n#Log ID Time Failing subsystem Severity SRC\n" : + "No entries"; + ################################## - # Parse log entries + # Parse log entries ################################## - foreach ( @entries ) { - if ( /tabindex=(\d+)><\/td>(.*)<\/td><\/tr>/ ){ + foreach (@entries) { + if (/tabindex=(\d+)><\/td>(.*)<\/td><\/tr>/) { my $values = $2; $values =~ s/<\/td>/ /g; - $result.= "$values\n"; + $result .= "$values\n"; - if ( $i++ == $count ) { + if ($i++ == $count) { last; } } } - return( [SUCCESS,$result] ); + return ([ SUCCESS, $result ]); } ########################################################################## -# Gets/Sets system time of day +# Gets/Sets system time of day ########################################################################## sub time { @@ -726,42 +733,42 @@ sub time { my $value = $request->{method}{time}; ############################## - # Send command + # Send command ############################## - my $result = xCAT::PPCfsp::timeofday( $exp, $request, $id ); + my $result = xCAT::PPCfsp::timeofday($exp, $request, $id); my $Rc = shift(@$result); ############################## # Return error ############################## - if ( $Rc != SUCCESS ) { - return( [$Rc,"Time: @$result[0]"] ); + if ($Rc != SUCCESS) { + return ([ $Rc, "Time: @$result[0]" ]); } ############################## # Get time ############################## - if ( !defined( $value )) { - @$result[0] =~ /(\d+) (\d+) (\d+) $/; - return( [SUCCESS,sprintf( "Time: %02d:%02d:%02d UTC",$1,$2,$3 )] ); + if (!defined($value)) { + @$result[0] =~ /(\d+) (\d+) (\d+) $/; + return ([ SUCCESS, sprintf("Time: %02d:%02d:%02d UTC", $1, $2, $3) ]); } ############################## - # Set time + # Set time ############################## my @t = split / /, @$result[0]; my @new = split /:/, $value; - splice( @t,3,3,@new ); + splice(@t, 3, 3, @new); ############################## - # Send command + # Send command ############################## - my $time = xCAT::PPCfsp::timeofday( $exp, $request, $id, \@t ); + my $time = xCAT::PPCfsp::timeofday($exp, $request, $id, \@t); $Rc = shift(@$time); - return( [$Rc,"Time: @$time[0]"] ); + return ([ $Rc, "Time: @$time[0]" ]); } ########################################################################## -# Gets/Sets system date +# Gets/Sets system date ########################################################################## sub date { @@ -773,42 +780,42 @@ sub date { my $value = $request->{method}{date}; ############################## - # Send command + # Send command ############################## - my $result = xCAT::PPCfsp::timeofday( $exp, $request, $id ); + my $result = xCAT::PPCfsp::timeofday($exp, $request, $id); my $Rc = shift(@$result); ############################## # Return error ############################## - if ( $Rc != SUCCESS ) { - return( [$Rc,"Date: @$result[0]"] ); + if ($Rc != SUCCESS) { + return ([ $Rc, "Date: @$result[0]" ]); } ############################## # Get date ############################## - if ( !defined( $value )) { - @$result[0] =~ /^(\d+) (\d+) (\d+)/; - return( [SUCCESS,sprintf( "Date: %02d-%02d-%4d",$1,$2,$3 )] ); + if (!defined($value)) { + @$result[0] =~ /^(\d+) (\d+) (\d+)/; + return ([ SUCCESS, sprintf("Date: %02d-%02d-%4d", $1, $2, $3) ]); } ############################## # Set date ############################## my @t = split / /, @$result[0]; my @new = split /-/, $value; - splice( @t,0,3,@new ); + splice(@t, 0, 3, @new); ############################## # Send command ############################## - my $date = xCAT::PPCfsp::timeofday( $exp, $request, $id, \@t ); + my $date = xCAT::PPCfsp::timeofday($exp, $request, $id, \@t); $Rc = shift(@$date); - return( [$Rc,"Date: @$date[0]"] ); + return ([ $Rc, "Date: @$date[0]" ]); } ########################################################################## -# Gets/Sets system time/date +# Gets/Sets system time/date ########################################################################## sub timeofday { @@ -820,71 +827,71 @@ sub timeofday { my $server = @$exp[1]; ###################################### - # Get time/date + # Get time/date ###################################### - my $res = $ua->get( "https://$server/cgi-bin/cgi?form=$id" ); + my $res = $ua->get("https://$server/cgi-bin/cgi?form=$id"); ################################## # Return error ################################## - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } - if ( $res->content =~ /(only when the system is powered off)/ ) { - return( [RC_ERROR,$1] ); + if ($res->content =~ /(only when the system is powered off)/) { + return ([ RC_ERROR, $1 ]); } ################################## # Get "Power On/Off System" form ################################## - my $form = HTML::Form->parse( $res->content, $res->base ); + my $form = HTML::Form->parse($res->content, $res->base); ################################## # Return error ################################## - if ( !defined( $form )) { - return( [RC_ERROR,"'Time Of Day' form not found"] ); + if (!defined($form)) { + return ([ RC_ERROR, "'Time Of Day' form not found" ]); } ###################################### - # Get time/date fields + # Get time/date fields ###################################### my $result; my @option = qw(omo od oy oh omi os); - - foreach ( @option ) { - if ( $res->content !~ /name='$_' value='(\d+)'/ ) { - return( [RC_ERROR,"Error getting time of day"] ); + + foreach (@option) { + if ($res->content !~ /name='$_' value='(\d+)'/) { + return ([ RC_ERROR, "Error getting time of day" ]); } - $result.= "$1 "; + $result .= "$1 "; } ###################################### - # Return time/date + # Return time/date ###################################### - if ( !defined( $d )) { - return( [SUCCESS,$result] ); + if (!defined($d)) { + return ([ SUCCESS, $result ]); } ###################################### - # Set time/date + # Set time/date ###################################### - $res = $ua->post( "https://$server/cgi-bin/cgi", - [ form => $id, - mo => @$d[0], - d => @$d[1], - y => @$d[2], - h => @$d[3], - mi => @$d[4], - s => @$d[5], - submit => "Save settings" ] + $res = $ua->post("https://$server/cgi-bin/cgi", + [ form => $id, + mo => @$d[0], + d => @$d[1], + y => @$d[2], + h => @$d[3], + mi => @$d[4], + s => @$d[5], + submit => "Save settings" ] ); ###################################### # Return error ###################################### - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } - if ( $res->content =~ /(not allowed.*\.|Invalid entry)/ ) { - return( [RC_ERROR,$1] ); - } - return( [SUCCESS,"Success"] ); + if ($res->content =~ /(not allowed.*\.|Invalid entry)/) { + return ([ RC_ERROR, $1 ]); + } + return ([ SUCCESS, "Success" ]); } @@ -893,73 +900,73 @@ sub timeofday { ########################################################################## sub iocap { - my $result = option( @_,"iocap" ); + my $result = option(@_, "iocap"); @$result[1] = "iocap: @$result[1]"; - return( $result ); + return ($result); } ########################################################################## -# Gets/Sets Auto Power Restart +# Gets/Sets Auto Power Restart ########################################################## sub autopower { - my $result = option( @_,"autopower" ); + my $result = option(@_, "autopower"); @$result[1] = "autopower: @$result[1]"; - return( $result ); + return ($result); } ########################################################################## -# Gets/Sets options +# Gets/Sets options ########################################################################## sub option { my $exp = shift; my $request = shift; - my $id = shift; + my $id = shift; my $menu = shift; my $command = shift; my $ua = @$exp[0]; my $server = @$exp[1]; - my $option = ($command =~ /^iocap$/) ? "pe" : "apor"; + my $option = ($command =~ /^iocap$/) ? "pe" : "apor"; my $value = $request->{method}{$command}; ###################################### # Get option URL ###################################### - if ( !defined( $value )) { - my $res = $ua->get( "https://$server/cgi-bin/cgi?form=$id" ); + if (!defined($value)) { + my $res = $ua->get("https://$server/cgi-bin/cgi?form=$id"); ################################## # Return errors ################################## - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } - if ( $res->content !~ /selected value='\d+'>(\w+)content !~ /selected value='\d+'>(\w+)post( "https://$server/cgi-bin/cgi", - [ form => $id, - $option => ($value =~ /^disable$/i) ? "0" : "1", - submit => "Save settings" ] + my $res = $ua->post("https://$server/cgi-bin/cgi", + [ form => $id, + $option => ($value =~ /^disable$/i) ? "0" : "1", + submit => "Save settings" ] ); ###################################### # Return error ###################################### - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } - if ( $res->content !~ /Operation completed successfully/i ) { - return( [RC_ERROR,"Error setting option"] ); + if ($res->content !~ /Operation completed successfully/i) { + return ([ RC_ERROR, "Error setting option" ]); } - return( [SUCCESS,"Success"] ); + return ([ SUCCESS, "Success" ]); } @@ -978,14 +985,14 @@ sub memdecfg { ################################## # Get settings ################################## - if ( !defined( $values )) { - return( readdecfg( $exp, $request, $id )); + if (!defined($values)) { + return (readdecfg($exp, $request, $id)); } ################################## # Set settings ################################## $values =~ /^(configure|deconfigure):(\d+):(unit|bank):(all|[\d,]+)$/i; - return( writedecfg( $exp, $request, $id, $1, $2, $3, $4 )); + return (writedecfg($exp, $request, $id, $1, $2, $3, $4)); } @@ -1004,14 +1011,14 @@ sub procdecfg { ################################## # Get settings ################################## - if ( !defined( $values )) { - return( readdecfg( $exp, $request, $id )); + if (!defined($values)) { + return (readdecfg($exp, $request, $id)); } ################################## # Set settings ################################## $values =~ /^(configure|deconfigure):(\d+):(all|[\d,]+)$/i; - return( writedecfg( $exp, $request, $id, $1, $2, "Processor ID",$3 )); + return (writedecfg($exp, $request, $id, $1, $2, "Processor ID", $3)); } @@ -1032,96 +1039,96 @@ sub writedecfg { my $server = @$exp[1]; ###################################### - # Command-line parameter specified + # Command-line parameter specified ###################################### - my @ids = split /,/, $id; - my $select = ($state =~ /^configure$/i) ? 0 : 1; + my @ids = split /,/, $id; + my $select = ($state =~ /^configure$/i) ? 0 : 1; ###################################### # Get Deconfiguration URL ###################################### my $url = "https://$server/cgi-bin/cgi?form=$formid"; - my $res = $ua->get( $url ); + my $res = $ua->get($url); ###################################### # Return error ###################################### - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } ###################################### - # Find unit specified by user + # Find unit specified by user ###################################### my $html = $res->content; my $value; - while ( $html =~ - s/]+><\/td>(\d+)]+><\/td>(\d+)parse( $res->content, $res->base ); + my $form = HTML::Form->parse($res->content, $res->base); my @inputs = $form->inputs(); ###################################### # Return error ###################################### - if ( !defined( $form )) { - return( [RC_ERROR,"'Deconfiguration' form not found"] ); + if (!defined($form)) { + return ([ RC_ERROR, "'Deconfiguration' form not found" ]); } ###################################### # Find radio button ###################################### - my ($radio) = grep($_->{type} eq "radio", @inputs ); - if ( !defined( $radio )) { - return( [RC_ERROR,"Radio button not found"] ); + my ($radio) = grep($_->{type} eq "radio", @inputs); + if (!defined($radio)) { + return ([ RC_ERROR, "Radio button not found" ]); } ###################################### # Select radio button ###################################### - $radio->value( $value ); + $radio->value($value); ###################################### # Send command ###################################### - my $data = $form->click( "submit" ); - $res = $ua->request( $data ); + my $data = $form->click("submit"); + $res = $ua->request($data); ###################################### # Return error ###################################### - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } ###################################### # Get current settings ###################################### - $form = HTML::Form->parse( $res->content, $res->base ); + $form = HTML::Form->parse($res->content, $res->base); @inputs = $form->inputs(); ###################################### # Return error ###################################### - if ( !defined( $form )) { - return( [RC_ERROR,"'Deconfiguration' form not found"] ); + if (!defined($form)) { + return ([ RC_ERROR, "'Deconfiguration' form not found" ]); } ###################################### - # Get options + # Get options ###################################### my %options = (); my %key = (); my $setall = 0; - foreach ( @inputs ) { - if ( $_->type eq "option" ) { - push @{$options{$_->name}}, $_->value; + foreach (@inputs) { + if ($_->type eq "option") { + push @{ $options{ $_->name } }, $_->value; } } my @units = split //, $res->content; @@ -1129,99 +1136,99 @@ sub writedecfg { $html = undef; ###################################### - # Break into unit types + # Break into unit types ###################################### - foreach ( @units ) { + foreach (@units) { /([\w\s]+)<\/th>/; - if ( $1 =~ /$type/i ) { + if ($1 =~ /$type/i) { $html = $_; last; } } ###################################### - # Look for unit type + # Look for unit type ###################################### - if ( !defined( $html )) { - return( [RC_ERROR,"unit=$unit '$type' not found"] ); + if (!defined($html)) { + return ([ RC_ERROR, "unit=$unit '$type' not found" ]); } ###################################### - # Set all IDs + # Set all IDs ###################################### - if ( $ids[0] eq "all" ) { - @ids = (); - $setall = 1; + if ($ids[0] eq "all") { + @ids = (); + $setall = 1; } ###################################### - # Associate 'option' name with ID + # Associate 'option' name with ID ###################################### - foreach ( keys %options ) { - if ( $html =~ /\n(\d+)<\/td>.*name='$_'/ ) { - if ( $setall ) { + foreach (keys %options) { + if ($html =~ /\n(\d+)<\/td>.*name='$_'/) { + if ($setall) { push @ids, $1; } - push @{$options{$_}}, $1; + push @{ $options{$_} }, $1; } } ###################################### - # Check if each specified ID exist + # Check if each specified ID exist ###################################### - foreach ( @ids ) { - foreach my $name ( keys %options ) { - my $id = @{$options{$name}}[1]; - - if ( $_ eq $id ) { - my $value = @{$options{$name}}[0]; - $key{$id} = [$value,$name]; + foreach (@ids) { + foreach my $name (keys %options) { + my $id = @{ $options{$name} }[1]; + + if ($_ eq $id) { + my $value = @{ $options{$name} }[0]; + $key{$id} = [ $value, $name ]; } } } ###################################### - # Check if ID exists + # Check if ID exists ###################################### - foreach ( @ids ) { - if ( !exists( $key{$_} )) { - return( [RC_ERROR,"Processing unit=$unit $type=$_ not found"] ); + foreach (@ids) { + if (!exists($key{$_})) { + return ([ RC_ERROR, "Processing unit=$unit $type=$_ not found" ]); } - my $value = @{$key{$_}}[0]; - if ( $value == $select ) { - delete $key{$_}; + my $value = @{ $key{$_} }[0]; + if ($value == $select) { + delete $key{$_}; } } ###################################### - # Check in already in that state + # Check in already in that state ###################################### - if ( !scalar( keys %key )) { - return( [RC_ERROR,"All $type(s) specified already in '$state' state"]); - } + if (!scalar(keys %key)) { + return ([ RC_ERROR, "All $type(s) specified already in '$state' state" ]); + } ###################################### - # Make changes to form + # Make changes to form ###################################### - foreach ( keys %key ) { - my $name = @{$key{$_}}[1]; - my ($button) = grep($_->{name} eq $name, @inputs ); - if ( !defined( $button )) { - return( [RC_ERROR,"Option=$name not found"] ); + foreach (keys %key) { + my $name = @{ $key{$_} }[1]; + my ($button) = grep($_->{name} eq $name, @inputs); + if (!defined($button)) { + return ([ RC_ERROR, "Option=$name not found" ]); } - $button->value( $select ); + $button->value($select); } ################################## # Send command ################################## - $data = $form->click( "submit" ); - $res = $ua->request( $data ); + $data = $form->click("submit"); + $res = $ua->request($data); ################################## # Return error ################################## - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } - if ( $res->content =~ /\n(.*Operation not allowed.*\.)/ ) { + if ($res->content =~ /\n(.*Operation not allowed.*\.)/) { my $result = $1; $result =~ s/

/\n/g; - return( [RC_ERROR,$result] ); + return ([ RC_ERROR, $result ]); } - return( [SUCCESS,"Success"] ); + return ([ SUCCESS, "Success" ]); } @@ -1241,18 +1248,18 @@ sub readdecfg { # Get Deconfiguration URL ###################################### my $url = "https://$server/cgi-bin/cgi?form=$id"; - my $res = $ua->get( $url ); + my $res = $ua->get($url); ###################################### # Return error ###################################### - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } ###################################### # Get current settings ###################################### - my $form = HTML::Form->parse( $res->content, $res->base ); + my $form = HTML::Form->parse($res->content, $res->base); my @inputs = $form->inputs(); my $html = $res->content; my $unit; @@ -1260,53 +1267,53 @@ sub readdecfg { ###################################### # Return error ###################################### - if ( !defined( $form )) { - return( [RC_ERROR,"'Deconfiguration' form not found"] ); + if (!defined($form)) { + return ([ RC_ERROR, "'Deconfiguration' form not found" ]); } ###################################### # Find radio button ###################################### - my ($radio) = grep($_->{type} eq "radio", @inputs ); - if ( !defined( $radio )) { - return( [RC_ERROR,"Radio button not found"] ); + my ($radio) = grep($_->{type} eq "radio", @inputs); + if (!defined($radio)) { + return ([ RC_ERROR, "Radio button not found" ]); } ###################################### # Find unit identifier ###################################### - if ( $html =~ /<\/th>([\w\s]+)<\/th>([\w\s]+){menu}} ) { + foreach (@{ $radio->{menu} }) { ################################## # Select radio button ################################## - my $value = ( ref($_) eq 'HASH' ) ? $_->{value} : $_; - $radio->value( $value ); + my $value = (ref($_) eq 'HASH') ? $_->{value} : $_; + $radio->value($value); ################################## # Send command ################################## - my $request = $form->click( "submit" ); - $res = $ua->request( $request ); + my $request = $form->click("submit"); + $res = $ua->request($request); ################################## # Return error ################################## - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } $html = $res->content; ################################## # Find unit identifier ################################## - if ( $html =~ /

([\w\s:]+)([\w\s:]+)/, $res->content; shift(@group); - foreach ( @group ) { + foreach (@group) { my @maxlen = (); my @values = (); @@ -1318,14 +1325,14 @@ sub readdecfg { pop(@heading); pop(@heading); - foreach ( @heading ) { + foreach (@heading) { push @maxlen, length($_); } ############################## # Entry values ############################## - foreach ( split /\n/ ) { - if ( s/^// ) { + foreach (split /\n/) { + if (s/^//) { s/
/ /g; my $i = 0; @@ -1336,8 +1343,8 @@ sub readdecfg { ###################### # Length formatting ###################### - foreach ( @d ) { - if ( length($_) > $maxlen[$i] ) { + foreach (@d) { + if (length($_) > $maxlen[$i]) { $maxlen[$i] = length($_); } $i++; @@ -1349,27 +1356,27 @@ sub readdecfg { # Output header ############################## my $i = 0; - foreach ( @heading ) { - my $format = sprintf( "%%-%ds",$maxlen[$i++]+2 ); - $result.= sprintf( $format, $_ ); + foreach (@heading) { + my $format = sprintf("%%-%ds", $maxlen[ $i++ ] + 2); + $result .= sprintf($format, $_); } - $result.= "\n"; + $result .= "\n"; ############################## # Output values ############################## - foreach ( @values ) { + foreach (@values) { $i = 0; - foreach ( @$_ ) { - my $format = sprintf( "%%-%ds",$maxlen[$i++]+2 ); - $result.= sprintf( $format, $_ ); + foreach (@$_) { + my $format = sprintf("%%-%ds", $maxlen[ $i++ ] + 2); + $result .= sprintf($format, $_); } - $result.= "\n"; + $result .= "\n"; } - $result.= "\n"; + $result .= "\n"; } } - return( [SUCCESS,$result] ); + return ([ SUCCESS, $result ]); } @@ -1388,13 +1395,13 @@ sub decfg { ###################################### # Get Deconfiguration Policy URL ###################################### - my $res = $ua->get( "https://$server/cgi-bin/cgi?form=$id" ); + my $res = $ua->get("https://$server/cgi-bin/cgi?form=$id"); ###################################### # Return error ###################################### - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } my %d = (); my $len = 0; @@ -1402,7 +1409,7 @@ sub decfg { my $html = $res->content; my $result; - while ( $html =~ s/
(.*:)\s+(.*:)\s+(\w+)(\w+) $len ) { - $len = length( $desc ); + if (length($desc) > $len) { + $len = length($desc); } - $d{$desc} = [$value,$name]; + $d{$desc} = [ $value, $name ]; } ###################################### # Get Deconfiguration Policy ###################################### - if ( !defined( $value )) { - my $format = sprintf( "\n%%-%ds %%s",$len ); - foreach ( keys %d ) { - $result.= sprintf( $format,$_,$d{$_}[0] ); + if (!defined($value)) { + my $format = sprintf("\n%%-%ds %%s", $len); + foreach (keys %d) { + $result .= sprintf($format, $_, $d{$_}[0]); } - return( [SUCCESS,$result] ); + return ([ SUCCESS, $result ]); } ###################################### # Set Deconfiguration Policy ###################################### - my ($op,$names) = split /:/, $value; - my @policy = split /,/, $names; - my $state = ($op =~ /^enable$/i) ? 0 : 1; + my ($op, $names) = split /:/, $value; + my @policy = split /,/, $names; + my $state = ($op =~ /^enable$/i) ? 0 : 1; ###################################### # Check for duplicate policies ###################################### - foreach my $name ( @policy ) { - if ( grep( /^$name$/, @policy ) > 1 ) { - return( [RC_ERROR,"Duplicate policy specified: $name"] ); + foreach my $name (@policy) { + if (grep(/^$name$/, @policy) > 1) { + return ([ RC_ERROR, "Duplicate policy specified: $name" ]); } } ###################################### - # Get Deconfiguration Policy form + # Get Deconfiguration Policy form ###################################### - my $form = HTML::Form->parse( $res->content, $res->base ); + my $form = HTML::Form->parse($res->content, $res->base); ###################################### # Return error ###################################### - if ( !defined( $form )) { - return( [RC_ERROR,"'Deconfiguration Policies' form not found"] ); + if (!defined($form)) { + return ([ RC_ERROR, "'Deconfiguration Policies' form not found" ]); } ###################################### - # Get hidden inputs + # Get hidden inputs ###################################### my @inputs = $form->inputs(); - my (@hidden) = grep( $_->{type} eq "hidden", @inputs ); - if ( !@hidden ) { - return( [RC_ERROR," not found"] ); + my (@hidden) = grep($_->{type} eq "hidden", @inputs); + if (!@hidden) { + return ([ RC_ERROR, " not found" ]); } ###################################### # Check for invalid policies ###################################### - foreach my $name ( @policy ) { - my @p = grep( $_->{value_name}=~/\b$name\b/i, @hidden ); + foreach my $name (@policy) { + my @p = grep($_->{value_name} =~ /\b$name\b/i, @hidden); - if ( @p > 1 ) { - return( [RC_ERROR,"Ambiguous policy: $name"] ); - } elsif ( !@p ) { - return( [RC_ERROR,"Invalid policy: $name"] ); + if (@p > 1) { + return ([ RC_ERROR, "Ambiguous policy: $name" ]); + } elsif (!@p) { + return ([ RC_ERROR, "Invalid policy: $name" ]); } my $value_name = $p[0]->{value_name}; - $policy[$i++] = @{$d{$value_name}}[1]; + $policy[ $i++ ] = @{ $d{$value_name} }[1]; } ###################################### - # Select option + # Select option ###################################### - foreach my $name ( @policy ) { - my ($in) = grep( $_->{name} eq $name, @inputs ); - $in->value( $state ); + foreach my $name (@policy) { + my ($in) = grep($_->{name} eq $name, @inputs); + $in->value($state); } ###################################### # Send command ###################################### - my $data = $form->click( "submit" ); - $res = $ua->request( $data ); + my $data = $form->click("submit"); + $res = $ua->request($data); ###################################### # Return error ###################################### - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } - return( [SUCCESS,"Success"] ); + return ([ SUCCESS, "Success" ]); } @@ -1525,40 +1532,40 @@ sub sysdump { # Get Dump URL ###################################### my $url = "https://$server/cgi-bin/cgi?form=$id"; - my $res = $ua->get( $url ); + my $res = $ua->get($url); ###################################### # Return error ###################################### - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } ###################################### - # Possible errors: + # Possible errors: # not allowed when a dump of this type exists. # not allowed when system is powered off. ###################################### - if ( $res->content =~ /(not allowed.*\.)/ ) { - return( [RC_ERROR,$1] ); + if ($res->content =~ /(not allowed.*\.)/) { + return ([ RC_ERROR, $1 ]); } my @d; my $html = $res->content; ###################################### - # Get current dump settings + # Get current dump settings ###################################### - foreach ( my $i=0; $i<3; $i++ ) { - if ($i == 0) { + foreach (my $i = 0 ; $i < 3 ; $i++) { + if ($i == 0) { if ($html !~ /Dump policy:\s+(\w+)/) { goto ERROR; } } if ($i != 0) { - if ($html !~ s/selected value='(\d+)'//) { -ERROR: - return( [RC_ERROR,"Error getting dump settings"] ); - } + if ($html !~ s/selected value='(\d+)'//) { + ERROR: + return ([ RC_ERROR, "Error getting dump settings" ]); + } } push @d, $1; @@ -1566,42 +1573,42 @@ ERROR: ###################################### # Send dump command ###################################### - $res = $ua->post( "https://$server/cgi-bin/cgi", - [ form => $id, - policy => $d[0], - content => $d[1], - phyp => $d[2], - page => "1", - takedump => "Save settings and initiate dump" ] + $res = $ua->post("https://$server/cgi-bin/cgi", + [ form => $id, + policy => $d[0], + content => $d[1], + phyp => $d[2], + page => "1", + takedump => "Save settings and initiate dump" ] ); ###################################### # Return error ###################################### - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } ###################################### - # Continue ? + # Continue ? ###################################### - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } - $res = $ua->post( "https://$server/cgi-bin/cgi", - [ form => $id, - policy => $d[0], - content => $d[1], - phyp => $d[2], - page => "2", - takedump => "Save settings and initiate dump", - submit => "Continue"] + $res = $ua->post("https://$server/cgi-bin/cgi", + [ form => $id, + policy => $d[0], + content => $d[1], + phyp => $d[2], + page => "2", + takedump => "Save settings and initiate dump", + submit => "Continue" ] ); ###################################### # Return error ###################################### - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } - return( [SUCCESS,"Success"] ); + return ([ SUCCESS, "Success" ]); } @@ -1610,88 +1617,88 @@ ERROR: ########################################################################## sub spdump { - my $exp = shift; - my $request = shift; - my $id = shift; - my $ua = @$exp[0]; - my $server = @$exp[1]; - my $button = "Save settings and initiate dump"; + my $exp = shift; + my $request = shift; + my $id = shift; + my $ua = @$exp[0]; + my $server = @$exp[1]; + my $button = "Save settings and initiate dump"; my $dump_setting = 1; ###################################### # Get Dump URL ###################################### my $url = "https://$server/cgi-bin/cgi?form=$id"; - my $res = $ua->get( $url ); + my $res = $ua->get($url); ###################################### # Return error ###################################### - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } ###################################### - # Dump disabled - enable it + # Dump disabled - enable it ###################################### - if ( $res->content =~ /selected value='0'>Disabled/ ) { - $res = $ua->post( "https://$server/cgi-bin/cgi", - [ form => $id, - bdmp => "1", - save => "Save settings" ] + if ($res->content =~ /selected value='0'>Disabled/) { + $res = $ua->post("https://$server/cgi-bin/cgi", + [ form => $id, + bdmp => "1", + save => "Save settings" ] ); ################################## # Return error ################################## - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } - if ( $res->content !~ /Operation completed successfully/ ) { - return( [RC_ERROR,"Error enabling dump setting"] ); + if ($res->content !~ /Operation completed successfully/) { + return ([ RC_ERROR, "Error enabling dump setting" ]); } ################################## # Get Dump URL again ################################## - $res = $ua->get( $url ); + $res = $ua->get($url); - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } ################################## - # Restore setting after dump + # Restore setting after dump ################################## $dump_setting = 0; } - if ( $res->content !~ /$button/ ) { + if ($res->content !~ /$button/) { ################################################################# # For some firmware levels, button is changed to "initiate dump" ################################################################# $button = "Initiate dump"; - if ( $res->content !~ /$button/ ) { - return( [RC_ERROR,"'$button' button not found"] ); + if ($res->content !~ /$button/) { + return ([ RC_ERROR, "'$button' button not found" ]); } } ###################################### - # We will lose conection after dump + # We will lose conection after dump ###################################### $ua->timeout(10); ###################################### - # Send dump command + # Send dump command ###################################### - $res = $ua->post( "https://$server/cgi-bin/cgi", - [ form => $id, - bdmp => $dump_setting, - dump => $button ] + $res = $ua->post("https://$server/cgi-bin/cgi", + [ form => $id, + bdmp => $dump_setting, + dump => $button ] ); ###################################### - # Will lose connection on success -500 + # Will lose connection on success -500 ###################################### - if ( !$res->is_success() ) { - if ( $res->code ne "500" ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + if ($res->code ne "500") { + return ([ RC_ERROR, $res->status_line ]); } } - return( [SUCCESS,"Success"] ); + return ([ SUCCESS, "Success" ]); } @@ -1699,7 +1706,7 @@ sub spdump { # Gets all Error/Event Logs entries ########################################################################## sub all { - return( entries(@_) ); + return (entries(@_)); } @@ -1708,9 +1715,9 @@ sub all { ########################################################################## sub all_clear { - my $result = entries( @_ ); - clear( @_); - return( $result ); + my $result = entries(@_); + clear(@_); + return ($result); } ########################################################################## @@ -1721,40 +1728,40 @@ sub netcfg my $exp = shift; my $request = shift; my $id = shift; - + ###################################### # Parsing arg ###################################### my $set_config = 0; my ($inc_name, $inc_ip, $inc_host, $inc_gateway, $inc_netmask) = (); my $real_inc_name = undef; - if ( $request->{'method'}->{'network'}) + if ($request->{'method'}->{'network'}) { $set_config = 1; } - + my $interfaces = undef; - my $form = undef; - - my $res = get_netcfg( $exp, $request, $id, \$interfaces, \$form); - return $res if ( $res->[0] == RC_ERROR); - + my $form = undef; + + my $res = get_netcfg($exp, $request, $id, \$interfaces, \$form); + return $res if ($res->[0] == RC_ERROR); + my $output = ""; ####################################### # Set configuration ####################################### - if ( $set_config) + if ($set_config) { - return set_netcfg( $exp, $request, $interfaces, $form); + return set_netcfg($exp, $request, $interfaces, $form); } ####################################### # Get configuration and format output ####################################### else { - return format_netcfg( $interfaces); + return format_netcfg($interfaces); } - + } ########################################################################## @@ -1770,59 +1777,60 @@ sub get_netcfg my $ua = @$exp[0]; my $server = @$exp[1]; - ###################################### + ###################################### # Get Network Configuration URL ###################################### my $url = "https://$server/cgi-bin/cgi?form=$id"; - my $res = $ua->get( $url ); - + my $res = $ua->get($url); + ################################## # Return error ################################## - if ( !$res->is_success() ) { - return( [RC_ERROR,$res->status_line] ); + if (!$res->is_success()) { + return ([ RC_ERROR, $res->status_line ]); } ################################## - # Get "Network Configuraiton" form + # Get "Network Configuraiton" form ################################## - $$form = HTML::Form->parse( $res->content, $res->base ); + $$form = HTML::Form->parse($res->content, $res->base); ################################## # Return error ################################## - if ( !defined( $$form )) { - return( [RC_ERROR,"'Network Configuration' form not found at parse"] ); - } + if (!defined($$form)) { + return ([ RC_ERROR, "'Network Configuration' form not found at parse" ]); + } ################################## # For some P6 machines ################################## - if ( $$form->find_input('ip', 'radio', 1)) - { + if ($$form->find_input('ip', 'radio', 1)) + { my $ipv4Radio = $$form->find_input('ip', 'radio', 1); if (!$ipv4Radio) { print "Cannot find IPv4 option\n"; exit; } + #$ipv4Radio->check(); my $data = $$form->click('submit'); - $res = $ua->request( $data); - $$form = HTML::Form->parse( $res->content, $res->base ); - if ( !defined( $$form )) { - return( [RC_ERROR,"'Network Configuration' form not found at submit"] ); - } - } elsif ( $$form->find_input('submit', 'submit', 1) ) { + $res = $ua->request($data); + $$form = HTML::Form->parse($res->content, $res->base); + if (!defined($$form)) { + return ([ RC_ERROR, "'Network Configuration' form not found at submit" ]); + } + } elsif ($$form->find_input('submit', 'submit', 1)) { my $data = $$form->click('submit'); sleep 5; - $res = $ua->request( $data); - $$form = HTML::Form->parse( $res->content, $res->base ); - if ( !defined( $$form )) { - return( [RC_ERROR,"'Network Configuration' form not found at submit2"] ); + $res = $ua->request($data); + $$form = HTML::Form->parse($res->content, $res->base); + if (!defined($$form)) { + return ([ RC_ERROR, "'Network Configuration' form not found at submit2" ]); } - if ( $$form->find_input('ip', 'radio', 1)) + if ($$form->find_input('ip', 'radio', 1)) { my $ipv4Radio = $$form->find_input('ip', 'radio', 1); if (!$ipv4Radio) @@ -1830,46 +1838,48 @@ sub get_netcfg print "Cannot find IPv4 option\n"; exit; } + #$ipv4Radio->check(); - + my $data = $$form->click('submit'); - $res = $ua->request( $data); - $$form = HTML::Form->parse( $res->content, $res->base ); - if ( !defined( $$form )) { - return( [RC_ERROR,"'Network Configuration' form not found at submit3"] ); + $res = $ua->request($data); + $$form = HTML::Form->parse($res->content, $res->base); + if (!defined($$form)) { + return ([ RC_ERROR, "'Network Configuration' form not found at submit3" ]); } } - } + } ####################################### # Parse the form to get the inc input ####################################### my $has_found_all = 0; - my $i = 0; - while ( not $has_found_all) + my $i = 0; + while (not $has_found_all) { - my $input = $$form->find_input( "interface$i", 'checkbox'); - if ( ! $input) + my $input = $$form->find_input("interface$i", 'checkbox'); + if (!$input) { $has_found_all = 1; } else { $$interfaces->{"interface$i"}->{'selected'} = $input; - $$interfaces->{"interface$i"}->{'type'} = $$form->find_input("ip$i", 'option'); + $$interfaces->{"interface$i"}->{'type'} = $$form->find_input("ip$i", 'option'); $$interfaces->{"interface$i"}->{'hostname'} = $$form->find_input("host$i", 'text'); - $$interfaces->{"interface$i"}->{'ip'} = $$form->find_input("static_ip$i", 'text'); - $$interfaces->{"interface$i"}->{'gateway'} = $$form->find_input("gateway$i", 'text'); - $$interfaces->{"interface$i"}->{'netmask'} = $$form->find_input("subnet$i", 'text'); + $$interfaces->{"interface$i"}->{'ip'} = $$form->find_input("static_ip$i", 'text'); + $$interfaces->{"interface$i"}->{'gateway'} = $$form->find_input("gateway$i", 'text'); + $$interfaces->{"interface$i"}->{'netmask'} = $$form->find_input("subnet$i", 'text'); + #we do not support dns yet, just in case of future support - $$interfaces->{"interface$i"}->{'dns0'} = $$form->find_input("dns0$i", 'text'); - $$interfaces->{"interface$i"}->{'dns1'} = $$form->find_input("dns1$i", 'text'); - $$interfaces->{"interface$i"}->{'dns2'} = $$form->find_input("dns2$i", 'text'); + $$interfaces->{"interface$i"}->{'dns0'} = $$form->find_input("dns0$i", 'text'); + $$interfaces->{"interface$i"}->{'dns1'} = $$form->find_input("dns1$i", 'text'); + $$interfaces->{"interface$i"}->{'dns2'} = $$form->find_input("dns2$i", 'text'); $i++; } } - return ( [RC_ERROR,"Cannot find any network interface on $server"]) if ( ! $$interfaces); - - return ( [SUCCESS, undef]); + return ([ RC_ERROR, "Cannot find any network interface on $server" ]) if (!$$interfaces); + + return ([ SUCCESS, undef ]); } ########################################################################## @@ -1877,25 +1887,25 @@ sub get_netcfg ########################################################################## sub set_netcfg { - my $exp = shift; - my $request = shift; - my $interfaces = shift; - my $form = shift; - my $ua = @$exp[0]; + my $exp = shift; + my $request = shift; + my $interfaces = shift; + my $form = shift; + my $ua = @$exp[0]; my $real_inc_name; my ($inc_name, $inc_ip, $inc_host, $inc_gateway, $inc_netmask) = split /,/, $request->{'method'}->{'network'}; - chomp ($inc_name, $inc_ip, $inc_host, $inc_gateway, $inc_netmask); - if ( $inc_name =~ /^eth(\d)$/) + chomp($inc_name, $inc_ip, $inc_host, $inc_gateway, $inc_netmask); + if ($inc_name =~ /^eth(\d)$/) { $real_inc_name = "interface$1"; } - elsif ( $inc_name =~/(\d+)\.(\d+)\.(\d+)\.(\d+)/) + elsif ($inc_name =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/) { for my $inc (keys %$interfaces) { - if ($interfaces->{ $inc}->{'ip'}->value() eq $inc_name) + if ($interfaces->{$inc}->{'ip'}->value() eq $inc_name) { $real_inc_name = $inc; last; @@ -1904,18 +1914,18 @@ sub set_netcfg } else { - return( [RC_ERROR, "Incorrect network interface name $inc_name"] ); + return ([ RC_ERROR, "Incorrect network interface name $inc_name" ]); } - return ( [RC_ERROR,"Cannot find interface $inc_name"]) if ( ! exists ($$interfaces{ $real_inc_name})); + return ([ RC_ERROR, "Cannot find interface $inc_name" ]) if (!exists($$interfaces{$real_inc_name})); my $inc_type; my @set_entries = (); - if ( $inc_ip eq '0.0.0.0') + if ($inc_ip eq '0.0.0.0') { $inc_type = 'Dynamic'; push @set_entries, 'IP type to dynamic.'; } - elsif ( $inc_ip eq '*') + elsif ($inc_ip eq '*') { $inc_type = 'Static'; ($inc_ip, $inc_host, $inc_gateway, $inc_netmask) = xCAT::NetworkUtils::getNodeNetworkCfg(@$exp[1]); @@ -1925,73 +1935,74 @@ sub set_netcfg $inc_type = 'Static'; } -#not work on AIX -# $interfaces->{ $real_inc_name}->{'selected'}->check(); - my @tmp_options = $interfaces->{ $real_inc_name}->{'selected'}->possible_values(); - $interfaces->{ $real_inc_name}->{'selected'}->value(@tmp_options[1] ); - if ( $interfaces->{ $real_inc_name}->{'type'}) + #not work on AIX + # $interfaces->{ $real_inc_name}->{'selected'}->check(); + my @tmp_options = $interfaces->{$real_inc_name}->{'selected'}->possible_values(); + $interfaces->{$real_inc_name}->{'selected'}->value(@tmp_options[1]); + if ($interfaces->{$real_inc_name}->{'type'}) { - my @type_options = @{$interfaces->{ $real_inc_name}->{'type'}->{'menu'}}; - if (ref( $type_options[0]) eq 'HASH') + my @type_options = @{ $interfaces->{$real_inc_name}->{'type'}->{'menu'} }; + if (ref($type_options[0]) eq 'HASH') { - for my $typeopt ( @type_options) + for my $typeopt (@type_options) { - if ( $typeopt->{'name'} eq $inc_type) + if ($typeopt->{'name'} eq $inc_type) { - $interfaces->{ $real_inc_name}->{'type'}->value($typeopt->{'value'}); + $interfaces->{$real_inc_name}->{'type'}->value($typeopt->{'value'}); last; } } } - else #AIX made the things more complicated, it didn't ship the - #last HTML::Form. So let's take a guess of the type value - #Not sure if it can work for all AIX version + else #AIX made the things more complicated, it didn't ship the + #last HTML::Form. So let's take a guess of the type value + #Not sure if it can work for all AIX version { - my @types = $interfaces->{ $real_inc_name}->{'type'}->possible_values(); - if ( $inc_type eq 'Dynamic') + my @types = $interfaces->{$real_inc_name}->{'type'}->possible_values(); + if ($inc_type eq 'Dynamic') { - $interfaces->{ $real_inc_name}->{'type'}->value(@types[0]); + $interfaces->{$real_inc_name}->{'type'}->value(@types[0]); } else { - $interfaces->{ $real_inc_name}->{'type'}->value(@types[1]); + $interfaces->{$real_inc_name}->{'type'}->value(@types[1]); } } -#not work on AIX -# $interfaces->{ $real_inc_name}->{'type'}->value('Static'); + + #not work on AIX + # $interfaces->{ $real_inc_name}->{'type'}->value('Static'); } else { - return ( [RC_ERROR,"Cannot change interface type"]); + return ([ RC_ERROR, "Cannot change interface type" ]); } - if ( $inc_type eq 'Static') + if ($inc_type eq 'Static') { - if ( $inc_ip) + if ($inc_ip) { - return ( [RC_ERROR,"Cannot set IP address to $inc_ip"]) if (! $interfaces->{ $real_inc_name}->{'ip'}); - $interfaces->{ $real_inc_name}->{'ip'}->value( $inc_ip); + return ([ RC_ERROR, "Cannot set IP address to $inc_ip" ]) if (!$interfaces->{$real_inc_name}->{'ip'}); + $interfaces->{$real_inc_name}->{'ip'}->value($inc_ip); push @set_entries, 'IP address'; } - if ( $inc_host) + if ($inc_host) { - return ( [RC_ERROR,"Cannot set hostname to $inc_host"]) if (! $interfaces->{ $real_inc_name}->{'hostname'}); - $interfaces->{ $real_inc_name}->{'hostname'}->value( $inc_host); + return ([ RC_ERROR, "Cannot set hostname to $inc_host" ]) if (!$interfaces->{$real_inc_name}->{'hostname'}); + $interfaces->{$real_inc_name}->{'hostname'}->value($inc_host); push @set_entries, 'hostname'; - if( ! $interfaces->{ $real_inc_name}->{'hostname'}->value()) + if (!$interfaces->{$real_inc_name}->{'hostname'}->value()) { $inc_host = $exp->[1]; } } - if ( $inc_gateway) + if ($inc_gateway) { - return ( [RC_ERROR,"Cannot set gateway to $inc_gateway"]) if (! $interfaces->{ $real_inc_name}->{'gateway'}); - $interfaces->{ $real_inc_name}->{'gateway'}->value( $inc_gateway); + return ([ RC_ERROR, "Cannot set gateway to $inc_gateway" ]) if (!$interfaces->{$real_inc_name}->{'gateway'}); + $interfaces->{$real_inc_name}->{'gateway'}->value($inc_gateway); push @set_entries, 'gateway'; } - if ( $inc_netmask) + if ($inc_netmask) { - return ( [RC_ERROR,"Cannot set netmask to $inc_netmask"]) if (! $interfaces->{ $real_inc_name}->{'netmask'}); - $interfaces->{ $real_inc_name}->{'netmask'}->value( $inc_netmask); + return ([ RC_ERROR, "Cannot set netmask to $inc_netmask" ]) if (!$interfaces->{$real_inc_name}->{'netmask'}); + $interfaces->{$real_inc_name}->{'netmask'}->value($inc_netmask); push @set_entries, 'netmask'; } } @@ -1999,39 +2010,39 @@ sub set_netcfg #Click "Continue" button sleep 2; my $data = $form->click('save'); - my $res = $ua->request( $data); + my $res = $ua->request($data); if (!$res->is_success()) { - return ( [RC_ERROR, "Failed to set " . join ',', @set_entries]); + return ([ RC_ERROR, "Failed to set " . join ',', @set_entries ]); } #Go to the confirm page - if ( $res->content !~ /content !~ /content; my @lines_to_print; for my $page_line (@page_lines) { chomp $page_line; - if ( $page_line =~ s/
$//) + if ($page_line =~ s/
$//) { push @lines_to_print, $page_line; } } - return ( [RC_ERROR,join "\n", @lines_to_print]); + return ([ RC_ERROR, join "\n", @lines_to_print ]); } - $ua->timeout( 2 ); + $ua->timeout(2); - $form = HTML::Form->parse( $res->content, $res->base ); + $form = HTML::Form->parse($res->content, $res->base); $data = $form->click('submit'); - $res = $ua->request( $data); + $res = $ua->request($data); ############################################################## # We cannot get the result of this update, since the network # is updated, the old URI is invalid anymore # Return success directory ############################################################## - return ( [SUCCESS, "Success to set " . join ',', @set_entries]); + return ([ SUCCESS, "Success to set " . join ',', @set_entries ]); } ########################################################################## @@ -2039,17 +2050,18 @@ sub set_netcfg ########################################################################## sub format_netcfg { - my $interfaces = shift; - my $output = undef; - for my $inc ( sort keys %$interfaces) + my $interfaces = shift; + my $output = undef; + for my $inc (sort keys %$interfaces) { -#improve needed: need to make the output consistent to MM + #improve needed: need to make the output consistent to MM $output .= "\n\t" . $inc . ":\n"; $output =~ s/interface(\d)/eth$1/; - # There are 2 possible value for $type, + + # There are 2 possible value for $type, # the first means "Dynamic", 2nd means "Static" # Now to find the correct type name - my $curr_type = $interfaces->{$inc}->{'type'}->value(); + my $curr_type = $interfaces->{$inc}->{'type'}->value(); my @possible_values = $interfaces->{$inc}->{'type'}->possible_values(); my $type; if ($curr_type == @possible_values[0]) @@ -2059,8 +2071,9 @@ sub format_netcfg else { $type = "Static"; - } -#not work on AIX + } + + #not work on AIX #my @possible_names = $interfaces->{$inc}->{'type'}->value_names(); #my %value_names = {}; #for ( my $i = 0; $i < scalar( @possible_values); $i++) @@ -2068,19 +2081,19 @@ sub format_netcfg # $value_names{ @possible_values[$i]} = @possible_names[$i]; #} #my $type = $interfaces->{$inc}->{'type'} ? $value_names{ $interfaces->{$inc}->{'type'}->value()} : undef;; - $type = "Static" if ( $type == 2); + $type = "Static" if ($type == 2); my $ip = $interfaces->{$inc}->{'ip'} ? $interfaces->{$inc}->{'ip'}->value() : undef; my $hostname = $interfaces->{$inc}->{'hostname'} ? $interfaces->{$inc}->{'hostname'}->value() : undef; my $gateway = $interfaces->{$inc}->{'gateway'} ? $interfaces->{$inc}->{'gateway'}->value() : undef; my $netmask = $interfaces->{$inc}->{'netmask'} ? $interfaces->{$inc}->{'netmask'}->value() : undef; - $output .= "\t\tIP Type: " . $type . "\n"; - $output .= "\t\tIP Address: " . $ip . "\n"; - $output .= "\t\tHostname: " . $hostname . "\n"; - $output .= "\t\tGateway: " . $gateway . "\n"; - $output .= "\t\tNetmask: " . $netmask . "\n"; + $output .= "\t\tIP Type: " . $type . "\n"; + $output .= "\t\tIP Address: " . $ip . "\n"; + $output .= "\t\tHostname: " . $hostname . "\n"; + $output .= "\t\tGateway: " . $gateway . "\n"; + $output .= "\t\tNetmask: " . $netmask . "\n"; } - return( [SUCCESS,$output] ); + return ([ SUCCESS, $output ]); } 1; diff --git a/perl-xCAT/xCAT/PPCinv.pm b/perl-xCAT/xCAT/PPCinv.pm index fb7860059..0012d5649 100644 --- a/perl-xCAT/xCAT/PPCinv.pm +++ b/perl-xCAT/xCAT/PPCinv.pm @@ -13,23 +13,23 @@ require xCAT::data::ibmhwtypes; # Maps HMC "lslic" attributes to text ########################################## my @licmap = ( - ["ecnumber", "Release Level "], - ["activated_level", "Active Level "], - ["installed_level", "Installed Level"], - ["accepted_level", "Accepted Level "], - ["curr_ecnumber_a", "Release Level A"], - ["curr_level_a", "Level A "], - ["curr_ecnumber_b", "Release Level B"], - ["curr_level_b", "Level B "], - ["curr_ecnumber_primary", "Release Level Primary"], - ["curr_level_primary", "Level Primary "], - ["curr_ecnumber_secondary","Release Level Secondary"], - ["curr_level_secondary", "Level Secondary"] + [ "ecnumber", "Release Level " ], + [ "activated_level", "Active Level " ], + [ "installed_level", "Installed Level" ], + [ "accepted_level", "Accepted Level " ], + [ "curr_ecnumber_a", "Release Level A" ], + [ "curr_level_a", "Level A " ], + [ "curr_ecnumber_b", "Release Level B" ], + [ "curr_level_b", "Level B " ], + [ "curr_ecnumber_primary", "Release Level Primary" ], + [ "curr_level_primary", "Level Primary " ], + [ "curr_ecnumber_secondary", "Release Level Secondary" ], + [ "curr_level_secondary", "Level Secondary" ] ); ########################################################################## -# Parse the command line for options and operands +# Parse the command line for options and operands ########################################################################## sub parse_args { @@ -44,84 +44,84 @@ sub parse_args { ############################################# local *usage = sub { my $usage_string = xCAT::Usage->getUsage($command); - return( [ $_[0], $usage_string] ); + return ([ $_[0], $usage_string ]); }; ############################################# # Process command-line arguments ############################################# - if ( !defined( $args )) { - return(usage( "No command specified" )); + if (!defined($args)) { + return (usage("No command specified")); } ############################################# # Checks case in GetOptions, allows opts # to be grouped (e.g. -vx), and terminates # at the first unrecognized option. ############################################# - @ARGV = @$args; + @ARGV = @$args; $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); + Getopt::Long::Configure("bundling"); - if ( !GetOptions( \%opt, qw(V|verbose t) )) { - return( usage() ); + if (!GetOptions(\%opt, qw(V|verbose t))) { + return (usage()); } #################################### # Check for "-" with no option #################################### - if ( grep(/^-$/, @ARGV )) { - return(usage( "Missing option: -" )); + if (grep(/^-$/, @ARGV)) { + return (usage("Missing option: -")); } #################################### # Unsupported command #################################### - my ($cmd) = grep(/^$ARGV[0]$/, @rinv ); - if ( !defined( $cmd )) { - return(usage( "Invalid command: $ARGV[0]" )); + my ($cmd) = grep(/^$ARGV[0]$/, @rinv); + if (!defined($cmd)) { + return (usage("Invalid command: $ARGV[0]")); } if (exists($opt{t}) and $cmd ne "model") { - return(["Option 't' can only work with 'model'."]); + return (["Option 't' can only work with 'model'."]); } #################################### # Check for an extra argument #################################### shift @ARGV; - if ( defined( $ARGV[0] )) { - return(usage( "Invalid Argument: $ARGV[0]" )); + if (defined($ARGV[0])) { + return (usage("Invalid Argument: $ARGV[0]")); } #################################### - # Set method to invoke + # Set method to invoke #################################### - $request->{method} = $cmd; - return( \%opt ); + $request->{method} = $cmd; + return (\%opt); } ########################################################################## -# Returns VPD (model-type,serial-number) +# Returns VPD (model-type,serial-number) ########################################################################## sub enumerate_vpd { - my $exp = shift; - my $mtms = shift; - my $hash = shift; - my $filter = "type_model,serial_num"; + my $exp = shift; + my $mtms = shift; + my $hash = shift; + my $filter = "type_model,serial_num"; my @vpd; - my ($name) = keys %{$hash->{$mtms}}; - my $type = @{$hash->{$mtms}->{$name}}[4]; + my ($name) = keys %{ $hash->{$mtms} }; + my $type = @{ $hash->{$mtms}->{$name} }[4]; ################################## - # BPAs + # BPAs ################################## - if ( $type =~ /^bpa$/ ) { + if ($type =~ /^bpa$/) { my $filter = "type_model,serial_num"; - my $frame = xCAT::PPCcli::lssyscfg( $exp, $type, $mtms, $filter ); - my $Rc = shift(@$frame); + my $frame = xCAT::PPCcli::lssyscfg($exp, $type, $mtms, $filter); + my $Rc = shift(@$frame); ############################## # Return error ############################## - if ( $Rc != SUCCESS ) { - return( [$Rc,@$frame[0]] ); + if ($Rc != SUCCESS) { + return ([ $Rc, @$frame[0] ]); } ############################## # Success @@ -129,36 +129,36 @@ sub enumerate_vpd { @vpd = split /,/, @$frame[0]; } ################################## - # CECs and LPARs + # CECs and LPARs ################################## else { ############################## # Send command for CEC only ############################## - my $cec = xCAT::PPCcli::lssyscfg( $exp, "fsp", $mtms, $filter ); + my $cec = xCAT::PPCcli::lssyscfg($exp, "fsp", $mtms, $filter); my $Rc = shift(@$cec); ############################## # Return error ############################## - if ( $Rc != SUCCESS ) { - return( [$Rc,@$cec[0]] ); + if ($Rc != SUCCESS) { + return ([ $Rc, @$cec[0] ]); } ############################## - # Success + # Success ############################## @vpd = split /,/, @$cec[0]; } my %outhash = ( model => $vpd[0], - serial => $vpd[1] + serial => $vpd[1] ); - return( [SUCCESS,\%outhash] ); + return ([ SUCCESS, \%outhash ]); } ########################################################################## -# Returns memory/processor information for CEC/LPARs +# Returns memory/processor information for CEC/LPARs ########################################################################## sub enumerate_cfg { @@ -168,26 +168,26 @@ sub enumerate_cfg { my %outhash = (); my $sys = 0; my @cmds = ( - [ "sys", "proc", "installed_sys_proc_units" ], - [ "sys", "mem", "installed_sys_mem" ], - [ "lpar","proc", "lpar_id,curr_procs" ], - [ "lpar","mem", "lpar_id,curr_mem" ] + [ "sys", "proc", "installed_sys_proc_units" ], + [ "sys", "mem", "installed_sys_mem" ], + [ "lpar", "proc", "lpar_id,curr_procs" ], + [ "lpar", "mem", "lpar_id,curr_mem" ] ); my $cec; - my ($name) = keys %{$hash->{$mtms}}; - my $type = @{$hash->{$mtms}->{$name}}[4]; + my ($name) = keys %{ $hash->{$mtms} }; + my $type = @{ $hash->{$mtms}->{$name} }[4]; ###################################### # Invalid target hardware ###################################### - if ( $type !~ /^(fsp|lpar|cec)$/ ) { - return( [RC_ERROR,"Information only available for CEC/LPAR"] ); + if ($type !~ /^(fsp|lpar|cec)$/) { + return ([ RC_ERROR, "Information only available for CEC/LPAR" ]); } ###################################### # Check for CECs in list ###################################### - while (my ($name,$d) = each(%{$hash->{$mtms}}) ) { - if ( @$d[4] =~ /^(fsp|cec)$/ ) { + while (my ($name, $d) = each(%{ $hash->{$mtms} })) { + if (@$d[4] =~ /^(fsp|cec)$/) { $cec = $name; last; } @@ -195,51 +195,51 @@ sub enumerate_cfg { ###################################### # No CECs - Skip command for CEC ###################################### - if ( !defined( $cec )) { + if (!defined($cec)) { shift @cmds; shift @cmds; } ###################################### # No LPARs - Skip command for LPAR ###################################### - if (( keys %{$hash->{$mtms}} == 1 ) and ( scalar(@cmds) == 4 )) { + if ((keys %{ $hash->{$mtms} } == 1) and (scalar(@cmds) == 4)) { pop @cmds; pop @cmds; } - - foreach my $cmd( @cmds ) { - my $result = xCAT::PPCcli::lshwres( $exp, $cmd, $mtms ); + + foreach my $cmd (@cmds) { + my $result = xCAT::PPCcli::lshwres($exp, $cmd, $mtms); my $Rc = shift(@$result); ################################## # Expect error ################################## - if ( $Rc != SUCCESS ) { - return( [$Rc,@$result[0]] ); + if ($Rc != SUCCESS) { + return ([ $Rc, @$result[0] ]); } ################################## # Success... # lshwres does not return CEC name ################################## - if ( @$cmd[0] eq "sys" ) { - foreach ( @$result[0] ) { + if (@$cmd[0] eq "sys") { + foreach (@$result[0]) { s/(.*)/0,$1/; } } ################################## - # Save by CEC/LPAR id + # Save by CEC/LPAR id ################################## - foreach ( @$result ) { - my ($id,$value) = split /,/; - push @{$outhash{$id}}, $value; + foreach (@$result) { + my ($id, $value) = split /,/; + push @{ $outhash{$id} }, $value; } } - return( [SUCCESS,\%outhash] ); + return ([ SUCCESS, \%outhash ]); } ########################################################################## -# Returns I/O bus information +# Returns I/O bus information ########################################################################## sub enumerate_bus { @@ -250,77 +250,77 @@ sub enumerate_bus { my @res = qw(lpar); my $filter = "drc_name,bus_id,description"; my @cmds = ( - undef, - "io --rsubtype slot", + undef, + "io --rsubtype slot", $filter ); my $cec; - my ($name) = keys %{$hash->{$mtms}}; - my $type = @{$hash->{$mtms}->{$name}}[4]; + my ($name) = keys %{ $hash->{$mtms} }; + my $type = @{ $hash->{$mtms}->{$name} }[4]; ################################## - # Invalid target hardware + # Invalid target hardware ################################## - if ( $type !~ /^(fsp|lpar|cec)$/ ) { - return( [RC_ERROR,"Bus information only available for CEC/LPAR"] ); + if ($type !~ /^(fsp|lpar|cec)$/) { + return ([ RC_ERROR, "Bus information only available for CEC/LPAR" ]); } ################################## - # Send command for CEC only + # Send command for CEC only ################################## - my $cecs = xCAT::PPCcli::lshwres( $exp, \@cmds, $mtms ); + my $cecs = xCAT::PPCcli::lshwres($exp, \@cmds, $mtms); my $Rc = shift(@$cecs); ################################## # Return error ################################## - if ( $Rc != SUCCESS ) { - return( [$Rc,@$cecs[0]] ); + if ($Rc != SUCCESS) { + return ([ $Rc, @$cecs[0] ]); } ################################## - # Success + # Success ################################## my @bus = @$cecs; ################################## # Check for CECs in list ################################## - foreach ( keys %{$hash->{$mtms}} ) { - if ( @{$hash->{$mtms}->{$_}}[4] =~ /^(fsp|cec)$/ ) { + foreach (keys %{ $hash->{$mtms} }) { + if (@{ $hash->{$mtms}->{$_} }[4] =~ /^(fsp|cec)$/) { $cec = $_; last; } } ################################## - # Get LPAR ids + # Get LPAR ids ################################## - my $lpars = xCAT::PPCcli::lssyscfg( $exp, "lpar", $mtms, "lpar_id" ); + my $lpars = xCAT::PPCcli::lssyscfg($exp, "lpar", $mtms, "lpar_id"); $Rc = shift(@$lpars); ################################## # Return error ################################## - if ( $Rc != SUCCESS ) { - return( [$Rc,@$lpars[0]] ); + if ($Rc != SUCCESS) { + return ([ $Rc, @$lpars[0] ]); } ################################## - # Save LPARs by id + # Save LPARs by id ################################## - foreach ( @$lpars ) { + foreach (@$lpars) { $outhash{$_} = \@bus; } ################################## # Save CEC by id ################################## - if ( defined( $cec )) { + if (defined($cec)) { $outhash{"0"} = \@bus; } - return( [SUCCESS,\%outhash] ); + return ([ SUCCESS, \%outhash ]); } ########################################################################## -# Returns I/O bus information +# Returns I/O bus information ########################################################################## sub bus { @@ -329,54 +329,54 @@ sub bus { my $exp = shift; my @result = (); - while (my ($mtms,$h) = each(%$hash) ) { + while (my ($mtms, $h) = each(%$hash)) { ##################################### # Get information for this CEC ##################################### - my $bus = enumerate_bus( $exp, $mtms, $hash ); - my $Rc = shift(@$bus); + my $bus = enumerate_bus($exp, $mtms, $hash); + my $Rc = shift(@$bus); my $data = @$bus[0]; - while (my ($name,$d) = each(%$h) ) { + while (my ($name, $d) = each(%$h)) { ################################## # Look up by lparid ################################## my $type = @$d[4]; - my $id = ($type=~/^(fsp|cec)$/) ? 0 : @$d[0]; + my $id = ($type =~ /^(fsp|cec)$/) ? 0 : @$d[0]; ################################# - # Output header + # Output header ################################# - push @result, [$name,"I/O Bus Information", 0]; + push @result, [ $name, "I/O Bus Information", 0 ]; ################################# - # Output error + # Output error ################################# - if ( $Rc != SUCCESS ) { - push @result, [$name,@$bus[0],$Rc]; + if ($Rc != SUCCESS) { + push @result, [ $name, @$bus[0], $Rc ]; next; } ################################# - # Node not found + # Node not found ################################# - if ( !exists( $data->{$id} )) { - push @result, [$name,"Node not found",1]; + if (!exists($data->{$id})) { + push @result, [ $name, "Node not found", 1 ]; next; - } + } ################################# - # Output values + # Output values ################################# - foreach ( @{$data->{$id}} ) { - push @result, [$name,$_,$Rc]; + foreach (@{ $data->{$id} }) { + push @result, [ $name, $_, $Rc ]; } } } - return( \@result ); + return (\@result); } ########################################################################## -# Returns VPD information +# Returns VPD information ########################################################################## sub vpd { @@ -386,48 +386,48 @@ sub vpd { my @cmds = $request->{method}; my @result = (); my %prefix = ( - model => ["Machine Type/Model",0], - serial => ["Serial Number", 1] + model => [ "Machine Type/Model", 0 ], + serial => [ "Serial Number", 1 ] ); - ######################################### + ######################################### # Convert "all" - ######################################### - if ( $cmds[0] eq "all" ) { + ######################################### + if ($cmds[0] eq "all") { @cmds = qw( model serial ); } - while (my ($mtms,$h) = each(%$hash) ) { + while (my ($mtms, $h) = each(%$hash)) { ##################################### # Get information for this CEC ##################################### - my $vpd = enumerate_vpd( $exp, $mtms, $hash ); - my $Rc = shift(@$vpd); + my $vpd = enumerate_vpd($exp, $mtms, $hash); + my $Rc = shift(@$vpd); my $data = @$vpd[0]; - while (my ($name) = each(%$h) ) { - foreach ( @cmds ) { + while (my ($name) = each(%$h)) { + foreach (@cmds) { ############################# # Output error ############################# - if ( $Rc != SUCCESS ) { - push @result, [$name,"@{$prefix{$_}}[0]: @$vpd[0]",$Rc]; + if ($Rc != SUCCESS) { + push @result, [ $name, "@{$prefix{$_}}[0]: @$vpd[0]", $Rc ]; next; - } + } ############################# - # Output value + # Output value ############################# if ($_ eq 'model' and exists($request->{opt}->{t})) { - my $tmp_pre = xCAT::data::ibmhwtypes::parse_group($data->{$_}); - if (defined($tmp_pre)) { - xCAT::TableUtils->updatenodegroups($name, $tmp_pre); - } - } - my $value = "@{$prefix{$_}}[0]: $data->{$_}"; - push @result, [$name,$value,$Rc]; + my $tmp_pre = xCAT::data::ibmhwtypes::parse_group($data->{$_}); + if (defined($tmp_pre)) { + xCAT::TableUtils->updatenodegroups($name, $tmp_pre); + } + } + my $value = "@{$prefix{$_}}[0]: $data->{$_}"; + push @result, [ $name, $value, $Rc ]; } } } - return( \@result ); + return (\@result); } @@ -442,66 +442,66 @@ sub firmware { my $hwtype = @$exp[2]; my @result; - while (my ($mtms,$h) = each(%$hash) ) { - while (my ($name,$d) = each(%$h) ) { + while (my ($mtms, $h) = each(%$hash)) { + while (my ($name, $d) = each(%$h)) { ##################################### - # Command only supported on FSP/BPA/LPARs + # Command only supported on FSP/BPA/LPARs ##################################### - if ( @$d[4] !~ /^(fsp|bpa|cec|frame|lpar)$/ ) { - push @result, - [$name,"Information only available for CEC/BPA/LPAR",RC_ERROR]; - next; + if (@$d[4] !~ /^(fsp|bpa|cec|frame|lpar)$/) { + push @result, + [ $name, "Information only available for CEC/BPA/LPAR", RC_ERROR ]; + next; } - ################# - #For support on Lpars, the flag need to be changed. - ########## - if(@$d[4] =~ /^(lpar|cec)$/) { - @$d[4] = "fsp"; - } - if(@$d[4] =~ /^frame$/) { - @$d[4] = "bpa"; - } - my $values = xCAT::PPCcli::lslic( $exp, $d ); + ################# + #For support on Lpars, the flag need to be changed. + ########## + if (@$d[4] =~ /^(lpar|cec)$/) { + @$d[4] = "fsp"; + } + if (@$d[4] =~ /^frame$/) { + @$d[4] = "bpa"; + } + my $values = xCAT::PPCcli::lslic($exp, $d); my $Rc = shift(@$values); - + ##################################### # Return error ##################################### - if ( $Rc != SUCCESS ) { - push @result, [$name,@$values[0],$Rc]; - next; + if ($Rc != SUCCESS) { + push @result, [ $name, @$values[0], $Rc ]; + next; } ##################################### # Success - format IVM results ##################################### - if ( $hwtype eq "ivm" ) { - if ( @$values[0] !~ - /^system:(\w+)\s+\(t\)\s+(\w+)\s+\(p\)\s+(\w+)\s+/ ) { - push @result, [$name,@$values[0],$Rc]; + if ($hwtype eq "ivm") { + if (@$values[0] !~ + /^system:(\w+)\s+\(t\)\s+(\w+)\s+\(p\)\s+(\w+)\s+/) { + push @result, [ $name, @$values[0], $Rc ]; next; } - push @result, [$name,"Activated Level: $1",$Rc]; - push @result, [$name,"Permanent Level: $2",$Rc]; - push @result, [$name,"Temporary Level: $3",$Rc]; + push @result, [ $name, "Activated Level: $1", $Rc ]; + push @result, [ $name, "Permanent Level: $2", $Rc ]; + push @result, [ $name, "Temporary Level: $3", $Rc ]; next; } ##################################### # Format HMC results ##################################### - foreach ( @licmap ) { - if ( @$values[0] =~ /@$_[0]=(\w+)/ ) { - push @result, [$name,"@$_[1]: $1",$Rc]; + foreach (@licmap) { + if (@$values[0] =~ /@$_[0]=(\w+)/) { + push @result, [ $name, "@$_[1]: $1", $Rc ]; } } } } - return( \@result ); + return (\@result); } ########################################################################## -# Returns memory/processor information +# Returns memory/processor information ########################################################################## sub config { @@ -509,79 +509,79 @@ sub config { my $hash = shift; my $exp = shift; my @result = (); - my @prefix = ( - "Number of Processors: %s", + my @prefix = ( + "Number of Processors: %s", "Total Memory (MB): %s" ); - while (my ($mtms,$h) = each(%$hash) ) { + while (my ($mtms, $h) = each(%$hash)) { ##################################### # Get information for this CEC ##################################### - my $cfg = enumerate_cfg( $exp, $mtms, $hash ); - my $Rc = shift(@$cfg); + my $cfg = enumerate_cfg($exp, $mtms, $hash); + my $Rc = shift(@$cfg); my $data = @$cfg[0]; - - while (my ($name,$d) = each(%$h) ) { + + while (my ($name, $d) = each(%$h)) { ################################## # Look up by lparid ################################## my $type = @$d[4]; - my $id = ($type=~/^(fsp|cec)$/) ? 0 : @$d[0]; + my $id = ($type =~ /^(fsp|cec)$/) ? 0 : @$d[0]; ################################# # Output header ################################# - push @result, [$name,"Machine Configuration Info", 0]; + push @result, [ $name, "Machine Configuration Info", 0 ]; my $i; - foreach ( @prefix ) { + foreach (@prefix) { ############################# # Output error ############################# - if ( $Rc != SUCCESS ) { - my $value = sprintf( "$_", $data ); - push @result, [$name,$value,$Rc]; + if ($Rc != SUCCESS) { + my $value = sprintf("$_", $data); + push @result, [ $name, $value, $Rc ]; next; } ############################# # Node not found ############################# - if (!exists( $data->{$id} )) { - push @result, [$name,"Node not found",1]; + if (!exists($data->{$id})) { + push @result, [ $name, "Node not found", 1 ]; next; } ############################# # Output value ############################# - my $value = sprintf( $_, @{$data->{$id}}[$i++] ); - push @result, [$name,$value,$Rc]; + my $value = sprintf($_, @{ $data->{$id} }[ $i++ ]); + push @result, [ $name, $value, $Rc ]; } } } - return( \@result ); + return (\@result); } ########################################################################## -# Returns firmware version +# Returns firmware version ########################################################################## sub firm { - return( firmware(@_) ); + return (firmware(@_)); } ########################################################################## # Returns serial-number ########################################################################## sub serial { - return( vpd(@_) ); + return (vpd(@_)); } ########################################################################## # Returns machine-type-model ########################################################################## sub model { - return( vpd(@_) ); + return (vpd(@_)); } ########################################################################## @@ -589,13 +589,13 @@ sub model { ########################################################################## sub all { - my @result = ( - @{vpd(@_)}, - @{bus(@_)}, - @{config(@_)}, - @{firmware(@_)} - ); - return( \@result ); + my @result = ( + @{ vpd(@_) }, + @{ bus(@_) }, + @{ config(@_) }, + @{ firmware(@_) } + ); + return (\@result); } diff --git a/perl-xCAT/xCAT/PPClog.pm b/perl-xCAT/xCAT/PPClog.pm index a95323193..720288f89 100644 --- a/perl-xCAT/xCAT/PPClog.pm +++ b/perl-xCAT/xCAT/PPClog.pm @@ -12,7 +12,7 @@ use xCAT::Usage; sub parse_args { my $request = shift; - my $command = $request->{command}; + my $command = $request->{command}; my $args = $request->{arg}; my %opt = (); my @reventlog = qw(clear all); @@ -23,60 +23,60 @@ sub parse_args { ############################################# local *usage = sub { my $usage_string = xCAT::Usage->getUsage($command); - return( [ $_[0], $usage_string] ); + return ([ $_[0], $usage_string ]); }; ############################################# # Process command-line arguments ############################################# - if ( !defined( $args )) { - return(usage( "No command specified" )); + if (!defined($args)) { + return (usage("No command specified")); } ############################################# # Checks case in GetOptions, allows opts # to be grouped (e.g. -vx), and terminates # at the first unrecognized option. ############################################# - @ARGV = @$args; + @ARGV = @$args; $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); + Getopt::Long::Configure("bundling"); - if ( !GetOptions( \%opt, qw(V|Verbose) )) { - return( usage() ); + if (!GetOptions(\%opt, qw(V|Verbose))) { + return (usage()); } #################################### # Check for "-" with no option #################################### - if ( grep(/^-$/, @ARGV )) { - return(usage( "Missing option: -" )); + if (grep(/^-$/, @ARGV)) { + return (usage("Missing option: -")); } #################################### # Unsupported commands #################################### - ($cmd) = grep(/^$ARGV[0]$/, @reventlog ); - if ( !defined( $cmd )) { + ($cmd) = grep(/^$ARGV[0]$/, @reventlog); + if (!defined($cmd)) { ################################ # Check for non-zero integer ################################ - if ( $ARGV[0] !~ /^([1-9]{1}|[1-9]{1}[0-9]+)$/ ) { - return(usage( "Invalid entry count: $ARGV[0]" )); + if ($ARGV[0] !~ /^([1-9]{1}|[1-9]{1}[0-9]+)$/) { + return (usage("Invalid entry count: $ARGV[0]")); } $cmd = "entries"; $opt{e} = $ARGV[0]; } shift @ARGV; - + #################################### # Check for an extra argument #################################### - if ( defined( $ARGV[0] )) { - return(usage( "Invalid Argument: $ARGV[0]" )); + if (defined($ARGV[0])) { + return (usage("Invalid Argument: $ARGV[0]")); } #################################### - # Set method to invoke + # Set method to invoke #################################### $request->{method} = $cmd; - return( \%opt ); + return (\%opt); } diff --git a/perl-xCAT/xCAT/PPCmac.pm b/perl-xCAT/xCAT/PPCmac.pm index c39b70b67..75b11ee0f 100644 --- a/perl-xCAT/xCAT/PPCmac.pm +++ b/perl-xCAT/xCAT/PPCmac.pm @@ -14,7 +14,7 @@ use xCAT::MsgUtils qw(verbose_message); use xCAT::LparNetbootExp; ########################################################################## -# Parse the command line for options and operands +# Parse the command line for options and operands ########################################################################## sub parse_args { @@ -23,34 +23,34 @@ sub parse_args { my $cmd = $request->{command}; my $args = $request->{arg}; my $node = $request->{node}; - my $vers = - my @VERSION = qw( 2.1 ); + my $vers = + my @VERSION = qw( 2.1 ); ############################################# # Responds with usage statement ############################################# local *usage = sub { my $usage_string = xCAT::Usage->getUsage($cmd); - return( [ $_[0], $usage_string] ); + return ([ $_[0], $usage_string ]); }; ############################################# # Process command-line arguments ############################################# - if ( !defined( $args )) { + if (!defined($args)) { $request->{method} = $cmd; - return( \%opt ); + return (\%opt); } ############################################# # Checks case in GetOptions, allows opts # to be grouped (e.g. -vx), and terminates # at the first unrecognized option. ############################################# - @ARGV = @$args; + @ARGV = @$args; $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); + Getopt::Long::Configure("bundling"); - if ( !GetOptions( \%opt,qw(h|help V|verbose v|version C=s G=s S=s D d f M o F=s arp noping))) { - return( usage() ); + if (!GetOptions(\%opt, qw(h|help V|verbose v|version C=s G=s S=s D d f M o F=s arp noping))) { + return (usage()); } #################################### # Option -h for Help @@ -61,36 +61,36 @@ sub parse_args { #################################### # Option -v for version #################################### - if ( exists( $opt{v} )) { - return( \@VERSION ); + if (exists($opt{v})) { + return (\@VERSION); } #################################### # Check for "-" with no option #################################### - if ( grep(/^-$/, @ARGV )) { - return(usage( "Missing option: -" )); + if (grep(/^-$/, @ARGV)) { + return (usage("Missing option: -")); } #################################### # Check for an extra argument #################################### - if ( defined( $ARGV[0] )) { - return(usage( "Invalid Argument: $ARGV[0]" )); + if (defined($ARGV[0])) { + return (usage("Invalid Argument: $ARGV[0]")); } #################################### - # Check -o argument + # Check -o argument #################################### - if ( exists($opt{o}) ) { - unless (exists($opt{D})){ - return(usage( "The -o flag must be used with -D flag" )); + if (exists($opt{o})) { + unless (exists($opt{D})) { + return (usage("The -o flag must be used with -D flag")); } } - + #################################### # Check --noping argument which is used to skip the ping test for -D #################################### - if ( exists($opt{noping}) ) { - unless (exists($opt{D})){ - return(usage( "The --noping flag must be used with -D flag" )); + if (exists($opt{noping})) { + unless (exists($opt{D})) { + return (usage("The --noping flag must be used with -D flag")); } } @@ -98,7 +98,7 @@ sub parse_args { # Check argument for ping test # If set --noping with -D, don't need to check the -S, -C, -G #################################### - if ( exists($opt{D}) && !exists($opt{noping})) { + if (exists($opt{D}) && !exists($opt{noping})) { my @network; my $client_ip; my $gateway; @@ -109,29 +109,29 @@ sub parse_args { #################################### # Set server IP #################################### - if ( exists($opt{S}) ) { + if (exists($opt{S})) { push @network, $_; } else { - $server = xCAT::ServiceNodeUtils->getSNformattedhash( $node, "xcat", "node", "primary" ); - foreach my $key ( keys %$server ) { - my $valid_ip = xCAT::NetworkUtils->validate_ip( $key ); - if ( $valid_ip ) { + $server = xCAT::ServiceNodeUtils->getSNformattedhash($node, "xcat", "node", "primary"); + foreach my $key (keys %$server) { + my $valid_ip = xCAT::NetworkUtils->validate_ip($key); + if ($valid_ip) { ################################################### - # Service node is returned as hostname, Convert - # hostname to IP + # Service node is returned as hostname, Convert + # hostname to IP #################################### $server_ip = xCAT::NetworkUtils->getipaddr($key); chomp $server_ip; } else { #################################### # Service node is returned as an IP - # set the IP as server + # set the IP as server #################################### $server_ip = $key; } - if ( $server_ip ) { - $opt{S} = $server_ip; + if ($server_ip) { + $opt{S} = $server_ip; push @network, $server_ip; } last; @@ -140,51 +140,56 @@ sub parse_args { #################################################################### # Fulfill in the server network information for gateway resolving #################################################################### - if ( exists($opt{S}) ) { + if (exists($opt{S})) { + # why convert to hostname?? #$server = gethostbyaddr( inet_aton($opt{S}), AF_INET ); $server = $opt{S}; - if ( $server ) { - %server_nethash = xCAT::DBobjUtils->getNetwkInfo( [$server] ); + if ($server) { + %server_nethash = xCAT::DBobjUtils->getNetwkInfo([$server]); } } - my %client_nethash = xCAT::DBobjUtils->getNetwkInfo( $node ); + my %client_nethash = xCAT::DBobjUtils->getNetwkInfo($node); ##################################### # Network attributes undefined ##################################### - if ( !%client_nethash ) { + if (!%client_nethash) { + # IPv6, the client ip address may not be available, # if the link local address is being used, # the link local address is calculated from mac address if ($opt{S} =~ /:/) { + #get the network "fe80::" my $tmpll = "fe80::1"; - %client_nethash = xCAT::DBobjUtils->getNetwkInfo( [$tmpll] ); + %client_nethash = xCAT::DBobjUtils->getNetwkInfo([$tmpll]); if (defined $client_nethash{$tmpll}) { - $client_nethash{@$node[0]} = $client_nethash{$tmpll}; + $client_nethash{ @$node[0] } = $client_nethash{$tmpll}; } } else { - my $nodes = join( ",", @$node); - return( [RC_ERROR,"Cannot get network information for $nodes, check networks table and IP address for this node to make sure there is correct network in networks table"] ); + my $nodes = join(",", @$node); + return ([ RC_ERROR, "Cannot get network information for $nodes, check networks table and IP address for this node to make sure there is correct network in networks table" ]); } } - if ( exists($opt{C}) ) { - if ( scalar(@$node) > 1 ) { - return( [RC_ERROR,"Option '-C' doesn't work with noderange\n"] ); + if (exists($opt{C})) { + if (scalar(@$node) > 1) { + return ([ RC_ERROR, "Option '-C' doesn't work with noderange\n" ]); } push @network, $_; } else { + # get, check the node IP $client_ip = xCAT::NetworkUtils->getipaddr(@$node[0]); chomp $client_ip; - if ( $client_ip ) { + if ($client_ip) { $opt{C} = $client_ip; push @network, $client_ip; } else { if ($opt{S} =~ /:/) { + # set the IPv6 loopback address, lpar_netboot will handle it $opt{C} = "::1"; push @network, "::1"; @@ -193,12 +198,12 @@ sub parse_args { } - if ( exists($opt{G}) ) { + if (exists($opt{G})) { push @network, $_; - } elsif ( $client_nethash{@$node[0]}{net} eq $server_nethash{$server}{net} ) { + } elsif ($client_nethash{ @$node[0] }{net} eq $server_nethash{$server}{net}) { #################################### - # Set gateway to service node if - # service node and client node are + # Set gateway to service node if + # service node and client node are # in the same net #################################### $gateway = $opt{S}; @@ -208,44 +213,44 @@ sub parse_args { #################################### # Set gateway in networks table #################################### - $gateway = $client_nethash{@$node[0]}{gateway}; - if ( $gateway ) { + $gateway = $client_nethash{ @$node[0] }{gateway}; + if ($gateway) { $opt{G} = $gateway; push @network, $gateway; } } - if ( @network ) { - if ( scalar(@network) != 3 ) { - return( usage() ); + if (@network) { + if (scalar(@network) != 3) { + return (usage()); } - my $result = xCAT::NetworkUtils->validate_ip( $opt{C}, $opt{G}, $opt{S} ); - if ( @$result[0] ) { - return(usage( @$result[1] )); + my $result = xCAT::NetworkUtils->validate_ip($opt{C}, $opt{G}, $opt{S}); + if (@$result[0]) { + return (usage(@$result[1])); } } - } elsif ( (exists($opt{S}) || exists($opt{G}) || exists($opt{C})) && !exists($opt{D}) ) { - return( [RC_ERROR,"Option '-D' is required for ping test\n"] ); + } elsif ((exists($opt{S}) || exists($opt{G}) || exists($opt{C})) && !exists($opt{D})) { + return ([ RC_ERROR, "Option '-D' is required for ping test\n" ]); } #################################### - # Check -F options's format + # Check -F options's format #################################### - if ( exists($opt{F}) ) { - my @filters = split /,/,$opt{F}; - foreach ( @filters ) { - my @value = split /=/,$_; - if ( !@value[1] ) { - return( usage("Option '-F' contains wrong filter format") ); + if (exists($opt{F})) { + my @filters = split /,/, $opt{F}; + foreach (@filters) { + my @value = split /=/, $_; + if (!@value[1]) { + return (usage("Option '-F' contains wrong filter format")); } } } #################################### - # Set method to invoke + # Set method to invoke #################################### - $request->{method} = $cmd; - return( \%opt ); + $request->{method} = $cmd; + return (\%opt); } @@ -254,23 +259,23 @@ sub parse_args { ########################################################################## sub do_getmacs { - my $request = shift; - my $d = shift; - my $exp = shift; - my $name = shift; - my $node = shift; - my $opt = $request->{opt}; - my $ssh = @$exp[0]; - my $userid = @$exp[4]; - my $pw = @$exp[5]; + my $request = shift; + my $d = shift; + my $exp = shift; + my $name = shift; + my $node = shift; + my $opt = $request->{opt}; + my $ssh = @$exp[0]; + my $userid = @$exp[4]; + my $pw = @$exp[5]; my %optarg; my $cmd; my $result; ####################################### - # Disconnect Expect session + # Disconnect Expect session ####################################### - xCAT::PPCcli::disconnect( $exp ); + xCAT::PPCcli::disconnect($exp); ####################################### # Get node data @@ -293,7 +298,7 @@ sub do_getmacs { # return( [RC_ERROR,"Command not installed: $cmd"] ); #} ####################################### - # Save user name and passwd of hcp to + # Save user name and passwd of hcp to # environment variables. # lpar_netboot.expect depends on this ####################################### @@ -301,17 +306,19 @@ sub do_getmacs { $ENV{HCP_PASSWD} = $pw; ####################################### - # Turn on verbose and debugging + # Turn on verbose and debugging ####################################### - if ( exists($request->{verbose}) ) { + if (exists($request->{verbose})) { + #$cmd.= " -v -x"; - $optarg{'v'} = 1; #for verbose - $optarg{'x'} = 1; #for debug + $optarg{'v'} = 1; #for verbose + $optarg{'x'} = 1; #for debug } ####################################### # Force LPAR shutdown ####################################### - if ( exists( $opt->{f} )) { + if (exists($opt->{f})) { + #$cmd.= " -i"; $optarg{'i'} = 1; } else { @@ -319,16 +326,17 @@ sub do_getmacs { # Force LPAR shutdown if LPAR is # running Linux ################################# - my $table = "nodetype"; - my $intable = 0; + my $table = "nodetype"; + my $intable = 0; my @TableRowArray = xCAT::DBobjUtils->getDBtable($table); - if ( @TableRowArray ) { - foreach ( @TableRowArray ) { + if (@TableRowArray) { + foreach (@TableRowArray) { my @nodelist = split(',', $_->{'node'}); - my @oslist = split(',', $_->{'os'}); - my $osname = "AIX"; - if ( grep(/^$node$/, @nodelist) ) { - if ( !grep(/^$osname$/, @oslist) ) { + my @oslist = split(',', $_->{'os'}); + my $osname = "AIX"; + if (grep(/^$node$/, @nodelist)) { + if (!grep(/^$osname$/, @oslist)) { + #$cmd.= " -i"; $optarg{'i'} = 1; } @@ -342,17 +350,20 @@ sub do_getmacs { # type is not assigned in table # but mnt node is running Linux ################################# - if ( xCAT::Utils->isLinux() && $intable == 0 ) { - #$cmd.= " -i"; - $optarg{'i'} = 1; + if (xCAT::Utils->isLinux() && $intable == 0) { + + #$cmd.= " -i"; + $optarg{'i'} = 1; } } - my %client_nethash = xCAT::DBobjUtils->getNetwkInfo( [$node] ); - if ( grep /hf/, $client_nethash{$node}{mgtifname} ) { + my %client_nethash = xCAT::DBobjUtils->getNetwkInfo([$node]); + if (grep /hf/, $client_nethash{$node}{mgtifname}) { + #$cmd.= " -t hfi-ent"; $optarg{'t'} = "hfi-ent"; } else { + #$cmd.= " -t ent"; $optarg{'t'} = "ent"; } @@ -360,16 +371,18 @@ sub do_getmacs { ####################################### # Network specified (-D ping test) ####################################### - if ( exists( $opt->{noping} )) { - $optarg{'D'} = 1; + if (exists($opt->{noping})) { + $optarg{'D'} = 1; $optarg{'noping'} = 1; } - if ( exists( $opt->{S} )) { - if ( exists( $opt->{o} )) { + if (exists($opt->{S})) { + if (exists($opt->{o})) { + #$cmd .=" -o"; - $optarg{'o'} = 1; + $optarg{'o'} = 1; } + #$cmd.= " -D -s auto -d auto -S $opt->{S} -G $opt->{G} -C $opt->{C}"; $optarg{'D'} = 1; $optarg{'s'} = 'auto'; @@ -377,52 +390,52 @@ sub do_getmacs { $optarg{'S'} = $opt->{S}; $optarg{'C'} = $opt->{C}; $optarg{'G'} = $opt->{G}; - } + } ####################################### - # Add command options + # Add command options ####################################### #$cmd.= " -f -M -A -n \"$name\" \"$pprofile\" \"$fsp\" $id $hcp \"$node\""; - $optarg{'f'} = 1; - $optarg{'M'} = 1; - $optarg{'A'} = 1; - $optarg{'n'} = $name; + $optarg{'f'} = 1; + $optarg{'M'} = 1; + $optarg{'A'} = 1; + $optarg{'n'} = $name; $optarg{'pprofile'} = $pprofile; - $optarg{'fsp'} = $fsp; - $optarg{'id'} = $id; - $optarg{'hcp'} = $hcp; - $optarg{'node'} = $node; + $optarg{'fsp'} = $fsp; + $optarg{'id'} = $id; + $optarg{'hcp'} = $hcp; + $optarg{'node'} = $node; - ######################################## - ## Execute command - ######################################## - #my $pid = open( OUTPUT, "$cmd 2>&1 |"); - #$SIG{INT} = $SIG{TERM} = sub { #prepare to process job termination and propogate it down - # kill 9, $pid; - # return( [RC_ERROR,"Received INT or TERM signal"] ); - #}; - #if ( !$pid ) { - # return( [RC_ERROR,"$cmd fork error: $!"] ); - #} - ######################################## - ## Get command output - ######################################## - #while ( ) { - # $result.=$_; - #} - #close OUTPUT; - # - ######################################## - ## Get command exit code - ######################################## - # - #foreach ( split /\n/, $result ) { - # if ( /^lpar_netboot / ) { - # $Rc = RC_ERROR; - # last; - # } - #} - xCAT::MsgUtils->verbose_message($request, "getmacs :lparnetbootexp for node:$node."); - my $Rc = xCAT::LparNetbootExp->lparnetbootexp(\%optarg, $request); + ######################################## + ## Execute command + ######################################## + #my $pid = open( OUTPUT, "$cmd 2>&1 |"); + #$SIG{INT} = $SIG{TERM} = sub { #prepare to process job termination and propogate it down + # kill 9, $pid; + # return( [RC_ERROR,"Received INT or TERM signal"] ); + #}; + #if ( !$pid ) { + # return( [RC_ERROR,"$cmd fork error: $!"] ); + #} + ######################################## + ## Get command output + ######################################## + #while ( ) { + # $result.=$_; + #} + #close OUTPUT; + # + ######################################## + ## Get command exit code + ######################################## + # + #foreach ( split /\n/, $result ) { + # if ( /^lpar_netboot / ) { + # $Rc = RC_ERROR; + # last; + # } + #} + xCAT::MsgUtils->verbose_message($request, "getmacs :lparnetbootexp for node:$node."); + my $Rc = xCAT::LparNetbootExp->lparnetbootexp(\%optarg, $request); ###################################### # Split results into array ###################################### @@ -444,129 +457,129 @@ sub getmacs { my $name; my @emptynode; - if ( $par =~ /^HASH/ ) { + if ($par =~ /^HASH/) { ######################################### # Parse the filters specified by user ######################################### my $filter; - if ( $opt->{F} ) { - my @filters = split /,/,$opt->{F}; - foreach ( @filters ) { - my @value = split /=/,$_; - $filter->{@value[0]} = @value[1]; + if ($opt->{F}) { + my @filters = split /,/, $opt->{F}; + foreach (@filters) { + my @value = split /=/, $_; + $filter->{ @value[0] } = @value[1]; } } - ######################################### + ######################################### # A hash to save lpar attributes - ######################################### + ######################################### my %nodeatt = (); ######################################### # Cleanup old data ######################################### - my $result = (); + my $result = (); ######################################### # No ping test performed, call lshwres # to achieve the MAC address ######################################### - foreach my $hcp ( keys %$par ) { + foreach my $hcp (keys %$par) { my $hash = $par->{$hcp}; - my $cmd; + my $cmd; ######################################### # Achieve virtual ethernet MAC address ######################################### - @$cmd[0] = ["lpar","virtualio","","eth"]; - @$cmd[1] = ["port","hea","","logical"]; - @$cmd[2] = ["port","hea","","phys"]; + @$cmd[0] = [ "lpar", "virtualio", "", "eth" ]; + @$cmd[1] = [ "port", "hea", "", "logical" ]; + @$cmd[2] = [ "port", "hea", "", "phys" ]; ######################################### # Parse the output of lshwres command ######################################### - for ( my $stat = 0; $stat < 3; $stat++ ) { - my $output = xCAT::PPCcli::lshwres( $exp, @$cmd[$stat], $hcp); - my $macs; + for (my $stat = 0 ; $stat < 3 ; $stat++) { + my $output = xCAT::PPCcli::lshwres($exp, @$cmd[$stat], $hcp); + my $macs; - foreach my $line ( @$output ) { - if ( $line =~ /^.*lpar\_id=(\d+),.*$/ ) { + foreach my $line (@$output) { + if ($line =~ /^.*lpar\_id=(\d+),.*$/) { ######################################### # For the first two commands ######################################### my $lparid = $1; $nodeatt{$hcp}{$lparid}{'num'}++; - $macs = $nodeatt{$hcp}{$lparid}{'num'}; - my @attrs = split /,/, $line; - foreach ( @attrs ) { + $macs = $nodeatt{$hcp}{$lparid}{'num'}; + my @attrs = split /,/, $line; + foreach (@attrs) { my @attr = split /=/, $_; - $nodeatt{$hcp}{$lparid}{$macs}{@attr[0]} = @attr[1]; + $nodeatt{$hcp}{$lparid}{$macs}{ @attr[0] } = @attr[1]; } - } elsif ( ($line =~ /^(.*)port\_group=(\d+),(.*),"log\_port\_ids=(.*)"/) || ($line =~ /^(.*)port\_group=(\d+),(.*),log\_port\_ids=(.*)/) ) { + } elsif (($line =~ /^(.*)port\_group=(\d+),(.*),"log\_port\_ids=(.*)"/) || ($line =~ /^(.*)port\_group=(\d+),(.*),log\_port\_ids=(.*)/)) { ######################################### # For the third command ######################################### my $port_group = $2; - if ( $4 !~ /^none$/ ) { - my @ids = split /,/, $4; - my @attrs = split /,/, $1; + if ($4 !~ /^none$/) { + my @ids = split /,/, $4; + my @attrs = split /,/, $1; foreach (@attrs) { - my @attr = split /=/,$_; + my @attr = split /=/, $_; foreach (@ids) { - $nodeatt{$hcp}{$port_group}{$_}{@attr[0]} = @attr[1]; - } - } - my @attrs = split /,/, $3; - foreach (@attrs) { - my @attr = split /=/,$_; - foreach (@ids) { - $nodeatt{$hcp}{$port_group}{$_}{@attr[0]} = @attr[1]; + $nodeatt{$hcp}{$port_group}{$_}{ @attr[0] } = @attr[1]; } } - } + my @attrs = split /,/, $3; + foreach (@attrs) { + my @attr = split /=/, $_; + foreach (@ids) { + $nodeatt{$hcp}{$port_group}{$_}{ @attr[0] } = @attr[1]; + } + } + } } } } - - foreach ( keys %$hash ) { - my $node = $_; - my $d = $hash->{$_}; - my $mtms = @$d[2]; - my $id = @$d[0]; - my $nodetype = @$d[4]; - my $mac_count = $nodeatt{$mtms}{$id}{'num'}; - my $value = (); - my $data = (); + foreach (keys %$hash) { + my $node = $_; + my $d = $hash->{$_}; + my $mtms = @$d[2]; + my $id = @$d[0]; + my $nodetype = @$d[4]; + + my $mac_count = $nodeatt{$mtms}{$id}{'num'}; + my $value = (); + my $data = (); my $type; ######################################### # Invalid target hardware ######################################### - if ( $nodetype ne "lpar" ) { - return( [[$node,"Node must be LPAR",RC_ERROR]] ); + if ($nodetype ne "lpar") { + return ([ [ $node, "Node must be LPAR", RC_ERROR ] ]); } ######################################### # Put all the attributes required # together ######################################### - push @$value,"\n#Type Phys_Port_Loc MAC_Address Adapter Port_Group Phys_Port Logical_Port VLan VSwitch Curr_Conn_Speed"; + push @$value, "\n#Type Phys_Port_Loc MAC_Address Adapter Port_Group Phys_Port Logical_Port VLan VSwitch Curr_Conn_Speed"; - for ( my $num = 1; $num <= $mac_count; $num++ ) { - my $mac_addr = $nodeatt{$mtms}{$id}{$num}{'mac_addr'}; - my $adapter_id = $nodeatt{$mtms}{$id}{$num}{'adapter_id'}; - my $port_group = $nodeatt{$mtms}{$id}{$num}{'port_group'}; - my $phys_port_id = $nodeatt{$mtms}{$id}{$num}{'phys_port_id'}; + for (my $num = 1 ; $num <= $mac_count ; $num++) { + my $mac_addr = $nodeatt{$mtms}{$id}{$num}{'mac_addr'}; + my $adapter_id = $nodeatt{$mtms}{$id}{$num}{'adapter_id'}; + my $port_group = $nodeatt{$mtms}{$id}{$num}{'port_group'}; + my $phys_port_id = $nodeatt{$mtms}{$id}{$num}{'phys_port_id'}; my $logical_port_id = $nodeatt{$mtms}{$id}{$num}{'logical_port_id'}; - my $vlan_id = $nodeatt{$mtms}{$id}{$num}{'port_vlan_id'}; - my $vswitch = $nodeatt{$mtms}{$id}{$num}{'vswitch'}; - my $phys_port_loc = $nodeatt{$mtms}{$port_group}{$logical_port_id}{'phys_port_loc'}; + my $vlan_id = $nodeatt{$mtms}{$id}{$num}{'port_vlan_id'}; + my $vswitch = $nodeatt{$mtms}{$id}{$num}{'vswitch'}; + my $phys_port_loc = $nodeatt{$mtms}{$port_group}{$logical_port_id}{'phys_port_loc'}; my $curr_conn_speed = $nodeatt{$mtms}{$port_group}{$logical_port_id}{'curr_conn_speed'}; - if ( $phys_port_loc ) { - $type = "hea "; + if ($phys_port_loc) { + $type = "hea "; } else { $type = "virtualio"; } @@ -575,89 +588,89 @@ sub getmacs { } my %att = (); - $att{'MAC_Address'} = ($mac_addr) ? $mac_addr : "N/A"; - $att{'Adapter'} = ($adapter_id) ? $adapter_id : "N/A"; - $att{'Port_Group'} = ($port_group) ? $port_group : "N/A"; - $att{'Phys_Port'} = ($phys_port_id) ? $phys_port_id : "N/A"; - $att{'Logical_Port'} = ($logical_port_id) ? $logical_port_id : "N/A"; - $att{'VLan'} = ($vlan_id) ? $vlan_id : "N/A"; - $att{'VSwitch'} = ($vswitch) ? $vswitch : "N/A"; - $att{'Phys_Port_Loc'} = ($phys_port_loc) ? $phys_port_loc : "N/A"; - $att{'Curr_Conn_Speed'} = ($curr_conn_speed) ? $curr_conn_speed : "N/A"; - $att{'Type'} = $type; + $att{'MAC_Address'} = ($mac_addr) ? $mac_addr : "N/A"; + $att{'Adapter'} = ($adapter_id) ? $adapter_id : "N/A"; + $att{'Port_Group'} = ($port_group) ? $port_group : "N/A"; + $att{'Phys_Port'} = ($phys_port_id) ? $phys_port_id : "N/A"; + $att{'Logical_Port'} = ($logical_port_id) ? $logical_port_id : "N/A"; + $att{'VLan'} = ($vlan_id) ? $vlan_id : "N/A"; + $att{'VSwitch'} = ($vswitch) ? $vswitch : "N/A"; + $att{'Phys_Port_Loc'} = ($phys_port_loc) ? $phys_port_loc : "N/A"; + $att{'Curr_Conn_Speed'} = ($curr_conn_speed) ? $curr_conn_speed : "N/A"; + $att{'Type'} = $type; ######################################### # Parse the adapter with the filters # specified ######################################### - if ( defined($filter) ) { + if (defined($filter)) { my $matched = 0; - foreach my $key ( keys %$filter ) { - if ( $key eq "MAC_Address" ) { - my $mac = lc($att{$key}); + foreach my $key (keys %$filter) { + if ($key eq "MAC_Address") { + my $mac = lc($att{$key}); my $filter_mac = lc($filter->{$key}); $mac =~ s/://g; $filter_mac =~ s/://g; - if ( grep(/$filter_mac/, $mac) ) { + if (grep(/$filter_mac/, $mac)) { $matched = 1; last; } - } elsif ( grep(/$filter->{$key}/, $att{$key}) ) { + } elsif (grep(/$filter->{$key}/, $att{$key})) { $matched = 1; last; } } - if ( $matched ) { - push @$value,"$att{'Type'} $att{'Phys_Port_Loc'} $att{'MAC_Address'} $att{'Adapter'} $att{'Port_Group'} $att{'Phys_Port'} $att{'Logical_Port'} $att{'VLan'} $att{'VSwitch'} $att{'Curr_Conn_Speed'}"; + if ($matched) { + push @$value, "$att{'Type'} $att{'Phys_Port_Loc'} $att{'MAC_Address'} $att{'Adapter'} $att{'Port_Group'} $att{'Phys_Port'} $att{'Logical_Port'} $att{'VLan'} $att{'VSwitch'} $att{'Curr_Conn_Speed'}"; } } else { - push @$value,"$att{'Type'} $att{'Phys_Port_Loc'} $att{'MAC_Address'} $att{'Adapter'} $att{'Port_Group'} $att{'Phys_Port'} $att{'Logical_Port'} $att{'VLan'} $att{'VSwitch'} $att{'Curr_Conn_Speed'}"; + push @$value, "$att{'Type'} $att{'Phys_Port_Loc'} $att{'MAC_Address'} $att{'Adapter'} $att{'Port_Group'} $att{'Phys_Port'} $att{'Logical_Port'} $att{'VLan'} $att{'VSwitch'} $att{'Curr_Conn_Speed'}"; } } ######################################### # Write MAC address to database ######################################### - if ( !exists( $opt->{d} )) { - writemac( $node, $value ); + if (!exists($opt->{d})) { + writemac($node, $value); } - if ( scalar(@$value) < 2 ) { + if (scalar(@$value) < 2) { my $filter = "lpar_id,curr_profile"; - my $prof = xCAT::PPCcli::lssyscfg( $exp, "node", $mtms, $filter, $id ); + my $prof = xCAT::PPCcli::lssyscfg($exp, "node", $mtms, $filter, $id); my $Rc = shift(@$prof); ######################################### # Return error ######################################### - if ( $Rc != SUCCESS ) { - return( [[$node,@$prof[0],$Rc]] ); + if ($Rc != SUCCESS) { + return ([ [ $node, @$prof[0], $Rc ] ]); } - foreach my $val ( @$prof ) { - my ($lpar_id,$curr_profile) = split /,/, $val; - if ( (!length($curr_profile)) || ($curr_profile =~ /^none$/) ) { - push @emptynode,$node; + foreach my $val (@$prof) { + my ($lpar_id, $curr_profile) = split /,/, $val; + if ((!length($curr_profile)) || ($curr_profile =~ /^none$/)) { + push @emptynode, $node; } } } - foreach ( @$value ) { - if ( /^#\s?Type/ ) { - $data.= "\n$_\n"; + foreach (@$value) { + if (/^#\s?Type/) { + $data .= "\n$_\n"; } else { - $data.= "$_\n"; + $data .= "$_\n"; } } - push @$result,[$node,$data,0]; + push @$result, [ $node, $data, 0 ]; } } - if ( scalar(@emptynode) > 0 ) { - return([[join(",", @emptynode),"\nThese nodes have no active profiles. Please active the nodes to enable the default profiles",RC_ERROR]]); - } - return([@$result]); + if (scalar(@emptynode) > 0) { + return ([ [ join(",", @emptynode), "\nThese nodes have no active profiles. Please active the nodes to enable the default profiles", RC_ERROR ] ]); + } + return ([@$result]); } else { ######################################### # Connect to fsp to achieve MAC address @@ -666,93 +679,95 @@ sub getmacs { my $d = $par; ######################################### - # Get node data + # Get node data ######################################### - my $lparid = @$d[0]; - my $mtms = @$d[2]; - my $type = @$d[4]; - my $node = @$d[6]; + my $lparid = @$d[0]; + my $mtms = @$d[2]; + my $type = @$d[4]; + my $node = @$d[6]; ######################################### - # Invalid target hardware + # Invalid target hardware ######################################### - if ( $type ne "lpar" ) { - return( [[$node,"Node must be LPAR",RC_ERROR]] ); + if ($type ne "lpar") { + return ([ [ $node, "Node must be LPAR", RC_ERROR ] ]); } ######################################### # Get name known by HCP ######################################### my $filter = "name,lpar_id"; xCAT::MsgUtils->verbose_message($request, "getmacs :lssyscfg filter '$filter'."); - my $values = xCAT::PPCcli::lssyscfg( $exp, $type, $mtms, $filter ); + my $values = xCAT::PPCcli::lssyscfg($exp, $type, $mtms, $filter); my $Rc = shift(@$values); ######################################### # Return error ######################################### - if ( $Rc != SUCCESS ) { - return( [[$node,@$values[0],$Rc]] ); + if ($Rc != SUCCESS) { + return ([ [ $node, @$values[0], $Rc ] ]); } ######################################### # Find LPARs by lpar_id ######################################### - foreach ( @$values ) { - if ( /^(.*),$lparid$/ ) { + foreach (@$values) { + if (/^(.*),$lparid$/) { $name = $1; last; } } ######################################### - # Node not found by lpar_id + # Node not found by lpar_id ######################################### - if ( !defined( $name )) { - return( [[$node,"Node not found, lparid=$lparid",RC_ERROR]] ); + if (!defined($name)) { + return ([ [ $node, "Node not found, lparid=$lparid", RC_ERROR ] ]); } #my $sitetab = xCAT::Table->new('site'); #my $vcon = $sitetab->getAttribs({key => "conserverondemand"}, 'value'); - #there may be something wrong with the conserverondemand attribute. + #there may be something wrong with the conserverondemand attribute. # Currently, the code is not used. So not fix this time. Just keep it here. my @vcons = xCAT::TableUtils->get_site_attribute("conserverondemand"); - my $vcon = $vcons[0]; + my $vcon = $vcons[0]; + #if ($vcon and $vcon->{"value"} and $vcon->{"value"} eq "yes" ) { - if ( defined($vcon) and $vcon eq "yes" ) { + if (defined($vcon) and $vcon eq "yes") { $result = xCAT::PPCcli::lpar_netboot( - $exp, - $request->{verbose}, - $name, - $d, - $opt ); + $exp, + $request->{verbose}, + $name, + $d, + $opt); } else { ######################################### # Manually collect MAC addresses. ######################################### xCAT::MsgUtils->verbose_message($request, "getmacs :do_getmacs for node:$node."); - $result = do_getmacs( $request, $d, $exp, $name, $node ); + $result = do_getmacs($request, $d, $exp, $name, $node); $Rc = shift(@$result); } + #$sitetab->close; - - + + ################################## - # Form string from array results + # Form string from array results ################################## - if ( exists($request->{verbose}) ) { - if ( $Rc == SUCCESS ) { - if ( !exists( $opt->{d} )) { - writemac( $node, $result ); + if (exists($request->{verbose})) { + if ($Rc == SUCCESS) { + if (!exists($opt->{d})) { + writemac($node, $result); } } - return( [[$node,join( '', @$result ),$Rc]] ); + return ([ [ $node, join('', @$result), $Rc ] ]); } ################################## # Return error ################################## - if ( $Rc != SUCCESS ) { - if ( @$result[0] =~ /lpar_netboot Status: (.*)/ ) { - return( [[$node,$1,$Rc]] ); + if ($Rc != SUCCESS) { + if (@$result[0] =~ /lpar_netboot Status: (.*)/) { + return ([ [ $node, $1, $Rc ] ]); } - return( [[$node,join( '', @$result ),$Rc]] ); + return ([ [ $node, join('', @$result), $Rc ] ]); } ##################################### # lpar_netboot returns: @@ -770,21 +785,21 @@ sub getmacs { ##################################### my $data; - foreach ( @$result ) { - if ( /^#\s?Type/ ) { - $data.= "\n$_\n"; - } elsif ( /^ent\s+/ or /^hfi-ent\s+/ ) { - $data.= "$_\n"; + foreach (@$result) { + if (/^#\s?Type/) { + $data .= "\n$_\n"; + } elsif (/^ent\s+/ or /^hfi-ent\s+/) { + $data .= "$_\n"; } } ##################################### # Write first valid adapter MAC to database ##################################### - if ( !exists( $opt->{d} )) { - writemac( $node, $result ); + if (!exists($opt->{d})) { + writemac($node, $result); } xCAT::MsgUtils->verbose_message($request, "getmacs END."); - return( [[$node,$data,$Rc]] ); + return ([ [ $node, $data, $Rc ] ]); } } @@ -797,11 +812,11 @@ sub cal_mac { my $mac = shift; $mac =~ s/://g; - $mac =~ /(.........)(.)(..)/; - my ($basemac, $mac_h, $mac_l) = ($1,$2, $3); + $mac =~ /(.........)(.)(..)/; + my ($basemac, $mac_h, $mac_l) = ($1, $2, $3); my $macnum_l = hex($mac_l); my $macnum_h = hex($mac_h); - $macnum_l += 1; + $macnum_l += 1; if ($macnum_l > 0xFF) { $macnum_h += 1; } @@ -809,9 +824,9 @@ sub cal_mac { $newmac_l =~ /(..)$/; $newmac_l = $1; my $newmac_h = sprintf("%01X", $macnum_h); - my $newmac = $basemac.$newmac_h.$newmac_l; + my $newmac = $basemac . $newmac_h . $newmac_l; - return( $newmac ); + return ($newmac); } ########################################################################## @@ -827,8 +842,8 @@ sub format_mac { my @newmacs; my @macs = split /\|/, $mac; - if ( !xCAT::Utils->isAIX() ) { - foreach my $mac_a ( @macs ) { + if (!xCAT::Utils->isAIX()) { + foreach my $mac_a (@macs) { if (&checkmac($mac_a)) { push @newmacs, $mac_a; next; @@ -841,20 +856,20 @@ sub format_mac { $mac_a =~ s/:$//; push @newmacs, $mac_a; } - $mac = join("|",@newmacs); + $mac = join("|", @newmacs); } - return( "$mac\n" ); + return ("$mac\n"); } ########################################################################## -# checkmac format +# checkmac format ########################################################################## sub checkmac { my $mac = shift; - if ( !xCAT::Utils->isAIX()) { + if (!xCAT::Utils->isAIX()) { if ($mac =~ /\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2}/) { return 1; } else { @@ -867,12 +882,12 @@ sub checkmac { ########################################################################## -# Write first valid adapter MAC to database +# Write first valid adapter MAC to database ########################################################################## sub writemac { - my $name = shift; - my $data = shift; + my $name = shift; + my $data = shift; my $value; my $pingret; my $ping_test; @@ -882,21 +897,21 @@ sub writemac { ##################################### # Find first valid adapter ##################################### - foreach ( @$data ) { + foreach (@$data) { unless (&checkmac($_)) { next; } - if ( /^ent\s+/ or /^hfi-ent\s+/ ) { + if (/^ent\s+/ or /^hfi-ent\s+/) { $value = $_; ##################################### # MAC not found in output ##################################### - if ( !defined( $value )) { + if (!defined($value)) { return; } @fields = split /\s+/, $value; $pingret = $fields[4]; - if ( $pingret eq "successful" ) { + if ($pingret eq "successful") { $ping_test = 0; last; } @@ -906,17 +921,17 @@ sub writemac { ##################################### # If no valid adapter, find the first one ##################################### - if ( $pingret ne "successful" ) { - foreach ( @$data ) { + if ($pingret ne "successful") { + foreach (@$data) { unless (&checkmac($_)) { next; } - if ( /^ent\s+/ or /^hfi-ent\s+/ ) { - $value = $_; + if (/^ent\s+/ or /^hfi-ent\s+/) { + $value = $_; $ping_test = 0; last; - } elsif ( /^hea\s+/ || /^virtualio\s+/ ) { - $value = $_; + } elsif (/^hea\s+/ || /^virtualio\s+/) { + $value = $_; $ping_test = 1; last; } @@ -926,24 +941,24 @@ sub writemac { ##################################### # MAC not found in output ##################################### - if ( !defined( $value )) { + if (!defined($value)) { return; } ##################################### # Get adapter mac ##################################### - #$value = format_mac( $value ); + #$value = format_mac( $value ); @fields = split /\s+/, $value; - $mac = $fields[2]; + $mac = $fields[2]; ##################################### # Write adapter mac to database ##################################### - my $mactab = xCAT::Table->new( "mac", -create=>1, -autocommit=>1 ); - if ( !$mactab ) { - return( [[$name,"Error opening 'mac'",RC_ERROR]] ); + my $mactab = xCAT::Table->new("mac", -create => 1, -autocommit => 1); + if (!$mactab) { + return ([ [ $name, "Error opening 'mac'", RC_ERROR ] ]); } - $mactab->setNodeAttribs( $name,{mac=>$mac} ); + $mactab->setNodeAttribs($name, { mac => $mac }); $mactab->close(); } diff --git a/perl-xCAT/xCAT/PPCpower.pm b/perl-xCAT/xCAT/PPCpower.pm index 817c4738c..e61dbbcbf 100644 --- a/perl-xCAT/xCAT/PPCpower.pm +++ b/perl-xCAT/xCAT/PPCpower.pm @@ -19,92 +19,92 @@ sub parse_args { my $command = $request->{command}; my $args = $request->{arg}; my %opt = (); - my @rpower = qw(on onstandby off softoff stat state reset boot of sms rackstandby exit_rackstandby lowpower resetsp cycle); + my @rpower = qw(on onstandby off softoff stat state reset boot of sms rackstandby exit_rackstandby lowpower resetsp cycle); ############################################# # Responds with usage statement ############################################# local *usage = sub { my $usage_string = xCAT::Usage->getUsage($command); - return( [ $_[0], $usage_string] ); + return ([ $_[0], $usage_string ]); }; ############################################# # Process command-line arguments ############################################# - if ( !defined( $args )) { - return(usage( "No command specified" )); + if (!defined($args)) { + return (usage("No command specified")); } ############################################# # Checks case in GetOptions, allows opts # to be grouped (e.g. -vx), and terminates # at the first unrecognized option. ############################################# - @ARGV = @$args; + @ARGV = @$args; $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); + Getopt::Long::Configure("bundling"); - if ( !GetOptions( \%opt, qw(V|verbose m:s@ t=s T=s r=s nodeps) )) { - return( usage() ); + if (!GetOptions(\%opt, qw(V|verbose m:s@ t=s T=s r=s nodeps))) { + return (usage()); } #################################### # Check for "-" with no option #################################### - if ( grep(/^-$/, @ARGV )) { - return(usage( "Missing option: -" )); + if (grep(/^-$/, @ARGV)) { + return (usage("Missing option: -")); } #################################### # Unsupported commands #################################### - my ($cmd) = grep(/^$ARGV[0]$/, @rpower ); - if ( !defined( $cmd )) { - return(usage( "Invalid command: $ARGV[0]" )); + my ($cmd) = grep(/^$ARGV[0]$/, @rpower); + if (!defined($cmd)) { + return (usage("Invalid command: $ARGV[0]")); } #################################### # Check for an extra argument #################################### shift @ARGV; - if ( defined( $ARGV[0] )) { - return(usage( "Invalid Argument: $ARGV[0]" )); + if (defined($ARGV[0])) { + return (usage("Invalid Argument: $ARGV[0]")); } #################################### - # Change "stat" to "state" + # Change "stat" to "state" #################################### $request->{op} = $cmd; $cmd =~ s/^stat$/state/; - + #################################### # Power commands special case #################################### - if ( $cmd ne "state" ) { - $cmd = ($cmd eq "boot") ? "powercmd_boot" : "powercmd"; + if ($cmd ne "state") { + $cmd = ($cmd eq "boot") ? "powercmd_boot" : "powercmd"; } $request->{method} = $cmd; - if (exists( $opt{m} ) ){ + if (exists($opt{m})) { my $res = xCAT::Utils->check_deployment_monitoring_settings($request, \%opt); if ($res != SUCCESS) { - return(usage()); + return (usage()); } } - if( ! exists $opt{T} ) + if (!exists $opt{T}) { - $opt{T} = "lpar"; #defaut value is lpar. + $opt{T} = "lpar"; #defaut value is lpar. } - - if( $opt{T} eq "lpar") { - $opt{T} = 0; - } elsif($opt{T} eq "fnm") { + + if ($opt{T} eq "lpar") { + $opt{T} = 0; + } elsif ($opt{T} eq "fnm") { $opt{T} = 1; - if ( $request->{op} !~ /^(onstandby|state|stat)$/) { - return(usage("The tooltype fnm only could be used with onstandby/state/stat action.")); - } + if ($request->{op} !~ /^(onstandby|state|stat)$/) { + return (usage("The tooltype fnm only could be used with onstandby/state/stat action.")); + } } else { - return( usage('Wrong value of -T option. The value can be lpar or fnm. The defaut value is lpar.')); + return (usage('Wrong value of -T option. The value can be lpar or fnm. The defaut value is lpar.')); } - return( \%opt ); + return (\%opt); } @@ -117,42 +117,42 @@ sub enumerate { my $node = shift; my $mtms = shift; my %outhash = (); - my %cmds = (); + my %cmds = (); ###################################### # Check for CEC/LPAR/BPAs in list ###################################### - while (my ($name,$d) = each(%$node) ) { + while (my ($name, $d) = each(%$node)) { my $type = @$d[4]; - $cmds{$type} = ($type=~/^lpar$/) ? "state,lpar_id" : "state"; + $cmds{$type} = ($type =~ /^lpar$/) ? "state,lpar_id" : "state"; } - foreach my $type ( keys %cmds ) { + foreach my $type (keys %cmds) { my $filter = $cmds{$type}; - my $values = xCAT::PPCcli::lssyscfg( $exp, $type, $mtms, $filter ); - my $Rc = shift(@$values); + my $values = xCAT::PPCcli::lssyscfg($exp, $type, $mtms, $filter); + my $Rc = shift(@$values); ################################## - # Return error + # Return error ################################## - if ( $Rc != SUCCESS ) { - return( [$Rc,@$values[0]] ); + if ($Rc != SUCCESS) { + return ([ $Rc, @$values[0] ]); } ################################## - # Save LPARs by id + # Save LPARs by id ################################## - foreach ( @$values ) { - my ($state,$lparid) = split /,/; + foreach (@$values) { + my ($state, $lparid) = split /,/; ############################## - # No lparid for fsp/bpa + # No lparid for fsp/bpa ############################## - if ( $type =~ /^(fsp|bpa|cec|frame)$/ ) { + if ($type =~ /^(fsp|bpa|cec|frame)$/) { $lparid = $type; } - $outhash{ $lparid } = $state; + $outhash{$lparid} = $state; } } - return( [SUCCESS,\%outhash] ); + return ([ SUCCESS, \%outhash ]); } @@ -161,61 +161,61 @@ sub enumerate { ########################################################################## sub powercmd_boot { - my $request = shift; - my $hash = shift; - my $exp = shift; - my @output = (); + my $request = shift; + my $hash = shift; + my $exp = shift; + my @output = (); my $callback = $request->{'callback'}; ###################################### - # Power commands are grouped by CEC + # Power commands are grouped by CEC # not Hardware Control Point ###################################### ###################################### - # Get CEC MTMS + # Get CEC MTMS ###################################### my ($name) = keys %$hash; - my $mtms = @{$hash->{$name}}[2]; + my $mtms = @{ $hash->{$name} }[2]; ###################################### # Build CEC/LPAR information hash ###################################### - my $stat = enumerate( $exp, $hash, $mtms ); - my $Rc = shift(@$stat); + my $stat = enumerate($exp, $hash, $mtms); + my $Rc = shift(@$stat); my $data = @$stat[0]; my $newstat; my %newnodestatus = (); - while (my ($name,$d) = each(%$hash) ) { + while (my ($name, $d) = each(%$hash)) { ################################## # Look up by lparid ################################## my $type = @$d[4]; - my $id = ($type=~/^(fsp|bpa|frame|cec)$/) ? $type : @$d[0]; + my $id = ($type =~ /^(fsp|bpa|frame|cec)$/) ? $type : @$d[0]; ################################## # Output error ################################## - if ( $Rc != SUCCESS ) { - push @output, [$name,$data,$Rc]; + if ($Rc != SUCCESS) { + push @output, [ $name, $data, $Rc ]; next; } ################################## - # Node not found + # Node not found ################################## - if ( !exists( $data->{$id} )) { - push @output, [$name,"Node not found",1]; + if (!exists($data->{$id})) { + push @output, [ $name, "Node not found", 1 ]; next; } ################################## # Convert state to on/off ################################## my $state = power_status($data->{$id}); - my $op = ($state =~ /^off$/) ? "on" : "reset"; + my $op = ($state =~ /^off$/) ? "on" : "reset"; if ($state =~ /^off$/) { $newstat = $::STATUS_POWERING_ON; @@ -223,85 +223,86 @@ sub powercmd_boot { # Attribute powerinterval in site table, # to control the rpower forking speed - if ((defined($request->{op})) && ($request->{op} ne 'stat') && ($request->{op} ne 'status') - && ($request->{op} ne 'state') && ($request->{op} ne 'off') && ($request->{op} ne 'softoff')) { - if(defined($request->{'powerinterval'}) && ($request->{'powerinterval'} ne '')) { + if ((defined($request->{op})) && ($request->{op} ne 'stat') && ($request->{op} ne 'status') + && ($request->{op} ne 'state') && ($request->{op} ne 'off') && ($request->{op} ne 'softoff')) { + if (defined($request->{'powerinterval'}) && ($request->{'powerinterval'} ne '')) { Time::HiRes::sleep($request->{'powerinterval'}); - } - } + } + } ############################## # Send power command ############################## my $result = xCAT::PPCcli::chsysstate( - $exp, - $op, - $d ); + $exp, + $op, + $d); unless (@$result[0] != SUCCESS) { if ($newstat) { push @{ $newnodestatus{$newstat} }, $name; } } - push @output, [$name,@$result[1],@$result[0]]; + push @output, [ $name, @$result[1], @$result[0] ]; } if (defined($request->{opt}->{m})) { - my $retries = 0; + my $retries = 0; my @monnodes = keys %$hash; my $monsettings = xCAT::Utils->generate_monsettings($request, \@monnodes); xCAT::Utils->monitor_installation($request, $monsettings); - while ($retries++ < $monsettings->{'retrycount'} && scalar(keys %{$monsettings->{nodes}}) > 0) { + while ($retries++ < $monsettings->{'retrycount'} && scalar(keys %{ $monsettings->{nodes} }) > 0) { - #The nodes that need to retry - my @nodesretry = keys %{$monsettings->{'nodes'}}; - my $nodes = join ',', @nodesretry; - my $rsp={}; - $rsp->{data}->[0] = "$nodes: Reinitializing the installation: $retries retry"; - xCAT::MsgUtils->message("I", $rsp, $callback); + #The nodes that need to retry + my @nodesretry = keys %{ $monsettings->{'nodes'} }; + my $nodes = join ',', @nodesretry; + my $rsp = {}; + $rsp->{data}->[0] = "$nodes: Reinitializing the installation: $retries retry"; + xCAT::MsgUtils->message("I", $rsp, $callback); - foreach my $node (keys %$hash) - { - # The installation for this node has been finished - if(!grep(/^$node$/, @nodesretry)) { - delete($hash->{$node}); - } - } - while (my ($name,$d) = each(%$hash) ) { - my $type = @$d[4]; - my $id = ($type=~/^(fsp|bpa)$/) ? $type : @$d[0]; + foreach my $node (keys %$hash) + { + # The installation for this node has been finished + if (!grep(/^$node$/, @nodesretry)) { + delete($hash->{$node}); + } + } + while (my ($name, $d) = each(%$hash)) { + my $type = @$d[4]; + my $id = ($type =~ /^(fsp|bpa)$/) ? $type : @$d[0]; - if ( $Rc != SUCCESS ) { - push @output, [$name,$data,$Rc]; - next; - } - if ( !exists( $data->{$id} )) { - push @output, [$name,"Node not found",1]; - next; - } - my $state = power_status($data->{$id}); - my $op = ($state =~ /^off$/) ? "on" : "reset"; + if ($Rc != SUCCESS) { + push @output, [ $name, $data, $Rc ]; + next; + } + if (!exists($data->{$id})) { + push @output, [ $name, "Node not found", 1 ]; + next; + } + my $state = power_status($data->{$id}); + my $op = ($state =~ /^off$/) ? "on" : "reset"; - my $result = xCAT::PPCcli::chsysstate( - $exp, - $op, - $d ); - push @output, [$name,@$result[1],@$result[0]]; - } - my @monnodes = keys %{$monsettings->{nodes}}; - xCAT::Utils->monitor_installation($request, $monsettings); + my $result = xCAT::PPCcli::chsysstate( + $exp, + $op, + $d); + push @output, [ $name, @$result[1], @$result[0] ]; + } + my @monnodes = keys %{ $monsettings->{nodes} }; + xCAT::Utils->monitor_installation($request, $monsettings); } + #failed after retries - if (scalar(keys %{$monsettings->{'nodes'}}) > 0) { - foreach my $node (keys %{$monsettings->{nodes}}) { - my $rsp={}; + if (scalar(keys %{ $monsettings->{'nodes'} }) > 0) { + foreach my $node (keys %{ $monsettings->{nodes} }) { + my $rsp = {}; $rsp->{data}->[0] = "The node \"$node\" can not reach the expected status after $monsettings->{'retrycount'} retries, the installation for this done failed"; xCAT::MsgUtils->message("E", $rsp, $callback); - } + } } - } + } xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); - return( \@output ); + return (\@output); } @@ -310,36 +311,37 @@ sub powercmd_boot { ########################################################################## sub powercmd { - my $request = shift; - my $hash = shift; - my $exp = shift; - my @result = (); + my $request = shift; + my $hash = shift; + my $exp = shift; + my @result = (); my $callback = $request->{'callback'}; my ($name) = keys %$hash; - my $mtms = @{$hash->{$name}}[2]; - my $stat = enumerate( $exp, $hash, $mtms ); - my $Rc = shift(@$stat); + my $mtms = @{ $hash->{$name} }[2]; + my $stat = enumerate($exp, $hash, $mtms); + my $Rc = shift(@$stat); my $data = @$stat[0]; my $newstat; - my %newnodestatus=(); + my %newnodestatus = (); #################################### - # Power commands are grouped by CEC + # Power commands are grouped by CEC # not Hardware Control Point #################################### - while (my ($name,$d) = each(%$hash) ) { - $newstat = ""; + while (my ($name, $d) = each(%$hash)) { + $newstat = ""; + # Attribute powerinterval in site table, # to control the rpower forking speed - if ((defined($request->{op})) && ($request->{op} ne 'stat') && ($request->{op} ne 'status') - && ($request->{op} ne 'state') && ($request->{op} ne 'off') && ($request->{op} ne 'softoff')) { - if(defined($request->{'powerinterval'}) && ($request->{'powerinterval'} ne '')) { + if ((defined($request->{op})) && ($request->{op} ne 'stat') && ($request->{op} ne 'status') + && ($request->{op} ne 'state') && ($request->{op} ne 'off') && ($request->{op} ne 'softoff')) { + if (defined($request->{'powerinterval'}) && ($request->{'powerinterval'} ne '')) { Time::HiRes::sleep($request->{'powerinterval'}); - } - } + } + } if (($request->{op} eq 'off') || ($request->{op} ne 'softoff')) { $newstat = $::STATUS_POWERING_OFF; } @@ -348,8 +350,8 @@ sub powercmd { } if ($request->{op} eq 'reset') { - my $type = @$d[4]; - my $id = ($type=~/^(fsp|bpa|frame|cec)$/) ? $type : @$d[0]; + my $type = @$d[4]; + my $id = ($type =~ /^(fsp|bpa|frame|cec)$/) ? $type : @$d[0]; my $state = power_status($data->{$id}); if ($state !~ /^off$/) { $newstat = $::STATUS_POWERING_ON; @@ -359,11 +361,11 @@ sub powercmd { # Send command to each LPAR ################################ my $values = xCAT::PPCcli::chsysstate( - $exp, - $request->{op}, - $d ); - my $Rc = shift(@$values); - + $exp, + $request->{op}, + $d); + my $Rc = shift(@$values); + unless ($Rc != SUCCESS) { if ($newstat) { push @{ $newnodestatus{$newstat} }, $name; @@ -373,54 +375,56 @@ sub powercmd { ################################ # Return result ################################ - push @result, [$name,@$values[0],$Rc]; + push @result, [ $name, @$values[0], $Rc ]; } if (defined($request->{opt}->{m})) { - my $retries = 0; + my $retries = 0; my @monnodes = keys %$hash; my $monsettings = xCAT::Utils->generate_monsettings($request, \@monnodes); xCAT::Utils->monitor_installation($request, $monsettings); - while ($retries++ < $monsettings->{'retrycount'} && scalar(keys %{$monsettings->{nodes}}) > 0) { - #The nodes that need to retry - my @nodesretry = keys %{$monsettings->{'nodes'}}; - my $nodes = join ',', @nodesretry; + while ($retries++ < $monsettings->{'retrycount'} && scalar(keys %{ $monsettings->{nodes} }) > 0) { - my $rsp={}; - $rsp->{data}->[0] = "$nodes: Reinitializing the installation: $retries retry"; - xCAT::MsgUtils->message("I", $rsp, $callback); + #The nodes that need to retry + my @nodesretry = keys %{ $monsettings->{'nodes'} }; + my $nodes = join ',', @nodesretry; - foreach my $node (keys %$hash) - { - # The installation for this node has been finished - if(!grep(/^$node$/, @nodesretry)) { - delete($hash->{$node}); - } - } - while (my ($name,$d) = each(%$hash) ) { - my $values = xCAT::PPCcli::chsysstate( - $exp, - $request->{op}, - $d ); - my $Rc = shift(@$values); + my $rsp = {}; + $rsp->{data}->[0] = "$nodes: Reinitializing the installation: $retries retry"; + xCAT::MsgUtils->message("I", $rsp, $callback); - push @result, [$name,@$values[0],$Rc]; - } - my @monnodes = keys %{$monsettings->{nodes}}; - xCAT::Utils->monitor_installation($request, $monsettings); + foreach my $node (keys %$hash) + { + # The installation for this node has been finished + if (!grep(/^$node$/, @nodesretry)) { + delete($hash->{$node}); + } + } + while (my ($name, $d) = each(%$hash)) { + my $values = xCAT::PPCcli::chsysstate( + $exp, + $request->{op}, + $d); + my $Rc = shift(@$values); + + push @result, [ $name, @$values[0], $Rc ]; + } + my @monnodes = keys %{ $monsettings->{nodes} }; + xCAT::Utils->monitor_installation($request, $monsettings); } + #failed after retries - if (scalar(keys %{$monsettings->{'nodes'}}) > 0) { - foreach my $node (keys %{$monsettings->{nodes}}) { - my $rsp={}; + if (scalar(keys %{ $monsettings->{'nodes'} }) > 0) { + foreach my $node (keys %{ $monsettings->{nodes} }) { + my $rsp = {}; $rsp->{data}->[0] = "The node \"$node\" can not reach the expected status after $monsettings->{'retrycount'} retries, the installation for this done failed"; xCAT::MsgUtils->message("E", $rsp, $callback); - } + } } - } + } xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%newnodestatus, 1); - return( \@result ); + return (\@result); } @@ -434,12 +438,12 @@ sub power_status { "Running", "Open Firmware" ); - foreach ( @states ) { - if ( /^$_[0]$/ ) { - return("on"); + foreach (@states) { + if (/^$_[0]$/) { + return ("on"); } - } - return("off"); + } + return ("off"); } @@ -456,36 +460,36 @@ sub state { my @result = (); - if ( !defined( $prefix )) { + if (!defined($prefix)) { $prefix = ""; } - while (my ($mtms,$h) = each(%$hash) ) { + while (my ($mtms, $h) = each(%$hash)) { ###################################### # Build CEC/LPAR information hash ###################################### - my $stat = enumerate( $exp, $h, $mtms ); - my $Rc = shift(@$stat); + my $stat = enumerate($exp, $h, $mtms); + my $Rc = shift(@$stat); my $data = @$stat[0]; - - while (my ($name,$d) = each(%$h) ) { + + while (my ($name, $d) = each(%$h)) { ################################## - # Look up by lparid + # Look up by lparid ################################## my $type = @$d[4]; - my $id = ($type=~/^(fsp|bpa|cec|frame)$/) ? $type : @$d[0]; - + my $id = ($type =~ /^(fsp|bpa|cec|frame)$/) ? $type : @$d[0]; + ################################## # Output error ################################## - if ( $Rc != SUCCESS ) { - push @result, [$name, "$prefix$data",$Rc]; + if ($Rc != SUCCESS) { + push @result, [ $name, "$prefix$data", $Rc ]; next; } ################################## - # Node not found + # Node not found ################################## - if ( !exists( $data->{$id} )) { - push @result, [$name, $prefix."Node not found",1]; + if (!exists($data->{$id})) { + push @result, [ $name, $prefix . "Node not found", 1 ]; next; } ################################## @@ -494,15 +498,15 @@ sub state { my $value = $data->{$id}; ############################## - # Convert state to on/off + # Convert state to on/off ############################## - if ( defined( $convert )) { - $value = power_status( $value ); + if (defined($convert)) { + $value = power_status($value); } - push @result, [$name,"$prefix$value",$Rc]; + push @result, [ $name, "$prefix$value", $Rc ]; } } - return( \@result ); + return (\@result); } diff --git a/perl-xCAT/xCAT/PPCrflash.pm b/perl-xCAT/xCAT/PPCrflash.pm index ec1f9af4e..89184a49c 100644 --- a/perl-xCAT/xCAT/PPCrflash.pm +++ b/perl-xCAT/xCAT/PPCrflash.pm @@ -14,10 +14,10 @@ use Getopt::Long; use File::Spec; use POSIX qw(tmpnam); -my $packages_dir= (); -my $activate = (); -my $verbose = 0; -$::POWER_DEST_DIR = "/tmp"; +my $packages_dir = (); +my $activate = (); +my $verbose = 0; +$::POWER_DEST_DIR = "/tmp"; my $release_level; my $active_level; my @dirlist; @@ -33,16 +33,16 @@ my $housekeeping = undef; ################################### sub dpush { my $value = shift; - my $msg = shift; + my $msg = shift; - if($verbose == 1) { - push(@$value,$msg); + if ($verbose == 1) { + push(@$value, $msg); } } ########################################################################## -# Parse the command line for options and operands +# Parse the command line for options and operands ########################################################################## sub parse_args { @@ -53,7 +53,7 @@ sub parse_args { my $args = $request->{arg}; ############################################# # Change CEC/Frame node into FSPs/BPAs - ############################################# + ############################################# #my @newnodes = (); #my $nodes = $request->{node}; #foreach my $snode(@$nodes) { @@ -71,19 +71,19 @@ sub parse_args { # } #} #$request->{node} = \@newnodes; - + ############################################# # Responds with usage statement ############################################# local *usage = sub { - my $usage_string = xCAT::Usage->getUsage($cmd); - return( [ $_[0], $usage_string] ); + my $usage_string = xCAT::Usage->getUsage($cmd); + return ([ $_[0], $usage_string ]); }; ############################################# # Process command-line arguments ############################################# - if ( !defined( $args )) { - return(usage( "No arguments specified" )); + if (!defined($args)) { + return (usage("No arguments specified")); } ############################################# @@ -91,155 +91,155 @@ sub parse_args { # to be grouped (e.g. -vx), and terminates # at the first unrecognized option. ############################################# - @ARGV = @$args; + @ARGV = @$args; $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); + Getopt::Long::Configure("bundling"); - if ( !GetOptions( \%opt, qw(h|help v|version V|verbose p=s d=s activate=s commit recover bpa_acdl) )) { - return( usage() ); + if (!GetOptions(\%opt, qw(h|help v|version V|verbose p=s d=s activate=s commit recover bpa_acdl))) { + return (usage()); } - + #################################### # Option -v for version #################################### - if ( exists( $opt{v} )) { + if (exists($opt{v})) { if (!defined($::VERSION)) { - return ([xCAT::Usage->getVersion($cmd)]); - } - return( [$::VERSION] ); + return ([ xCAT::Usage->getVersion($cmd) ]); + } + return ([$::VERSION]); } - - if ( exists( $opt{h}) || $opt{help}) { - return( usage()); + + if (exists($opt{h}) || $opt{help}) { + return (usage()); } ################################# #Option --activate not valid with --commit or --recover ################################# - if (exists($opt{bpa_acdl}) && (exists($opt{activate}) || exists($opt{commit}) || - exists($opt{recover}) || exists($opt{p}) || exists($opt{d}))) { - return ( usage("Option --bpa_acdl not valid with other options ")); + if (exists($opt{bpa_acdl}) && (exists($opt{activate}) || exists($opt{commit}) || + exists($opt{recover}) || exists($opt{p}) || exists($opt{d}))) { + return (usage("Option --bpa_acdl not valid with other options ")); + } + + if (exists($opt{activate}) && (exists($opt{commit}) || exists($opt{recover}))) { + return (usage("Option --activate not valid with --commit or --recover ")); } - - if( exists( $opt{activate} ) && (exists( $opt{commit}) || exists( $opt{recover}))) { - return( usage("Option --activate not valid with --commit or --recover ") ); - } ################################# #Option -p not valid with --commit or --recover ################################# - if( exists( $opt{p} ) && (exists( $opt{commit}) || exists( $opt{recover} ))) { - return( usage("Option -p not valid with --commit or --recover ") ); + if (exists($opt{p}) && (exists($opt{commit}) || exists($opt{recover}))) { + return (usage("Option -p not valid with --commit or --recover ")); } - + ################################# #Option -p required ################################# - if( exists( $opt{p} ) && (!exists( $opt{activate}) )) { - return( usage("Option -p must be used with --activate ") ); - } - - if ( exists( $opt{p} ) && ($opt{p} !~ /^\//) ) {#relative path - $opt{p} = xCAT::Utils->full_path($opt{p}, $request->{cwd}->[0]); - } - - if( exists( $opt{d} ) ) { - if(!exists( $opt{activate}) ) { - return( usage("Option -d must be used with --activate ") ); - } + if (exists($opt{p}) && (!exists($opt{activate}))) { + return (usage("Option -p must be used with --activate ")); } - if ( exists( $opt{d} ) && ($opt{d} !~ /^\//) ) {#relative path + if (exists($opt{p}) && ($opt{p} !~ /^\//)) { #relative path + $opt{p} = xCAT::Utils->full_path($opt{p}, $request->{cwd}->[0]); + } + + if (exists($opt{d})) { + if (!exists($opt{activate})) { + return (usage("Option -d must be used with --activate ")); + } + } + + if (exists($opt{d}) && ($opt{d} !~ /^\//)) { #relative path $opt{d} = xCAT::Utils->full_path($opt{d}, $request->{cwd}->[0]); } ############################### #--activate's value only can be concurrent and disruptive ################################ - if(exists($opt{activate})) { + if (exists($opt{activate})) { if (defined($request->{mgt}) && $request->{mgt} =~ /xCAT::FSP/i) { if ($opt{activate} !~ /deferred|disruptive/) { return (usage("--activate's value can only be deferred or disruptive.")); } } else { - if(($opt{activate} ne "disruptive") && ($opt{activate} ne "concurrent")) { + if (($opt{activate} ne "disruptive") && ($opt{activate} ne "concurrent")) { return (usage("--activate's value can only be disruptive or concurrent.")); } } - if(!exists( $opt{d} )) { + if (!exists($opt{d})) { $opt{d} = "/tmp"; } } - + #################################### # Check for "-" with no option #################################### - if ( grep(/^-$/, @ARGV )) { - return(usage( "Missing option: -" )); + if (grep(/^-$/, @ARGV)) { + return (usage("Missing option: -")); } - + #################################### # Check for an extra argument #################################### - if ( defined( $ARGV[0] )) { - return(usage( "Invalid Argument: $ARGV[0]" )); + if (defined($ARGV[0])) { + return (usage("Invalid Argument: $ARGV[0]")); } - - + + #check to see if we are housekeeping or updating # - if( defined( $opt{commit}) ) { + if (defined($opt{commit})) { print "commit flag\n"; $housekeeping = "commit"; - } elsif( defined( $opt{ recover }) ) { + } elsif (defined($opt{recover})) { print "recover flag\n"; $housekeeping = "recover"; - } elsif (defined( $opt{ bpa_acdl})) { + } elsif (defined($opt{bpa_acdl})) { print "bpa_acdl flag\n"; $housekeeping = "bpa_acdl"; } else { print "no housekeeping - update mode\n"; $housekeeping = undef; } - + $request->{housekeeping} = $housekeeping; ############################################# # Option -V for verbose output ############################################ - if ( exists( $opt{V} )) { + if (exists($opt{V})) { $verbose = 1; } - + #################### #suport for "rflash", copy the rpm and xml packages from user-spcefied-directory to /install/packages_fw - ##################### - if ( (!exists($opt{commit})) && (!exists($opt{ recover })) && (!exists($opt{bpa_acdl}))) { - if( preprocess_for_rflash($request, \%opt) == -1) { - return( usage() ); + ##################### + if ((!exists($opt{commit})) && (!exists($opt{recover})) && (!exists($opt{bpa_acdl}))) { + if (preprocess_for_rflash($request, \%opt) == -1) { + return (usage()); } } - - if(noderange_validate($request) == -1) { - return(usage()); - } - - $request->{callback}->({data =>[ "It may take considerable time to complete, depending on the number of systems being updated. In particular, power subsystem updates may take an hour or more if there are many attached managed systems. Please waiting. "]}); - if( $request->{hwtype} =~ /^(fsp|bpa)$/ && $opt{activate} =~ /^disruptive$/ ) { - $request->{callback}->({data =>[ "You can find the log files in the /var/log/xcatd/dfm/rflash/."]}); + if (noderange_validate($request) == -1) { + return (usage()); + } + + $request->{callback}->({ data => ["It may take considerable time to complete, depending on the number of systems being updated. In particular, power subsystem updates may take an hour or more if there are many attached managed systems. Please waiting. "] }); + + if ($request->{hwtype} =~ /^(fsp|bpa)$/ && $opt{activate} =~ /^disruptive$/) { + $request->{callback}->({ data => ["You can find the log files in the /var/log/xcatd/dfm/rflash/."] }); } #################################### - # No operands - add command name + # No operands - add command name #################################### $request->{method} = $cmd; - return( \%opt ); + return (\%opt); } ########################################################################## -# Invokes the callback with the specified message +# Invokes the callback with the specified message ########################################################################## sub send_msg { @@ -250,23 +250,23 @@ sub send_msg { ################################################# # Called from child process - send to parent ################################################# - if ( exists( $request->{pipe} )) { + if (exists($request->{pipe})) { my $out = $request->{pipe}; $output{errorcode} = $ecode; - $output{data} = \@_; - print $out freeze( [\%output] ); + $output{data} = \@_; + print $out freeze([ \%output ]); print $out "\nENDOFFREEZE6sK4ci\n"; } ################################################# # Called from parent - invoke callback directly ################################################# - elsif ( exists( $request->{callback} )) { + elsif (exists($request->{callback})) { my $callback = $request->{callback}; $output{errorcode} = $ecode; - $output{data} = \@_; - $callback->( \%output ); + $output{data} = \@_; + $callback->(\%output); } } @@ -275,8 +275,10 @@ sub send_msg { ##################################### sub noderange_validate { my $request = shift; - #my $opt = shift; + + #my $opt = shift; my $noderange = $request->{node}; + #my $t = print_var($request, "request"); #print $t; #################### @@ -289,8 +291,9 @@ sub noderange_validate { # Group nodes ########################################### my $mytypehash = xCAT::DBobjUtils->getnodetype($noderange, "ppc"); - foreach my $node ( @$noderange ) { + foreach my $node (@$noderange) { my $type = undef; + #my $sitetab = xCAT::Table->new( 'nodetype' ); #if ( defined( $sitetab )) { # my ($ent) = $sitetab->getAttribs({ node=>$node},'nodetype'); @@ -299,12 +302,14 @@ sub noderange_validate { # } #} $type = $$mytypehash{$node}; + #print "type:$type\n"; - if( $type =~/(fsp|lpar|cec)/) { + if ($type =~ /(fsp|lpar|cec)/) { $f1 = 1; } else { $f2 = 1; - my $exargs=$request->{arg}; + my $exargs = $request->{arg}; + #my $t = print_var($exargs, "exargs"); #print $t; #if ( grep(/commit/,@$exargs) != 0 || grep(/recover/,@$exargs) != 0) { @@ -315,103 +320,107 @@ sub noderange_validate { } } - if($f1 * $f2) { - send_msg( $request, 1, "The argument noderange of rflash can't be BPA and CEC(or LPAR) at the same time"); + if ($f1 * $f2) { + send_msg($request, 1, "The argument noderange of rflash can't be BPA and CEC(or LPAR) at the same time"); return -1; } } sub preprocess_for_rflash { - my $request = shift; - my $opt = shift; - my $callback = $request->{callback}; + my $request = shift; + my $opt = shift; + my $callback = $request->{callback}; my $install_dir = xCAT::TableUtils->getInstallDir(); my $packages_fw = "$install_dir/packages_fw"; - my $c = 0; + my $c = 0; my $packages_d; -# foreach (@$exargs) { -# $c++; -# if($_ eq "-p") { -# $packages_d = $$exargs[$c]; -# last; -# } -# } + + # foreach (@$exargs) { + # $c++; + # if($_ eq "-p") { + # $packages_d = $$exargs[$c]; + # last; + # } + # } $packages_d = $$opt{p}; - if($packages_d ne $packages_fw ) { + if ($packages_d ne $packages_fw) { $$opt{p} = $packages_fw; - if(! -d $packages_d) { + if (!-d $packages_d) { + #send_msg($request, 1, "The directory $packages_d doesn't exist!"); - $callback->({data=>["The directory $packages_d doesn't exist!"]}); - $request = (); - return -1; - } - - #print "opening directory and reading names\n"; - opendir DIRHANDLE, $packages_d; - my @dirlist= readdir DIRHANDLE; - closedir DIRHANDLE; - - @dirlist = File::Spec->no_upwards( @dirlist ); - - # Make sure we have some files to process - # - if( !scalar( @dirlist ) ) { - #send_msg($request, 1, "The directory $packages_d is empty !"); - $callback->({data=>["The directory $packages_d is empty !"]}); - $request = (); - return -1; - } - - #Find the rpm lic file - my @rpmlist = grep /\.rpm$/, @dirlist; - my @xmllist = grep /\.xml$/, @dirlist; - if( @rpmlist == 0 | @xmllist == 0) { - #send_msg($request, 1, "There isn't any rpm and xml files in the directory $packages_d!"); - $callback->({data=>["There isn't any rpm and xml files in the directory $packages_d!"]}); + $callback->({ data => ["The directory $packages_d doesn't exist!"] }); $request = (); return -1; } - - my $rpm_list = join(" ", @rpmlist); + + #print "opening directory and reading names\n"; + opendir DIRHANDLE, $packages_d; + my @dirlist = readdir DIRHANDLE; + closedir DIRHANDLE; + + @dirlist = File::Spec->no_upwards(@dirlist); + + # Make sure we have some files to process + # + if (!scalar(@dirlist)) { + + #send_msg($request, 1, "The directory $packages_d is empty !"); + $callback->({ data => ["The directory $packages_d is empty !"] }); + $request = (); + return -1; + } + + #Find the rpm lic file + my @rpmlist = grep /\.rpm$/, @dirlist; + my @xmllist = grep /\.xml$/, @dirlist; + if (@rpmlist == 0 | @xmllist == 0) { + + #send_msg($request, 1, "There isn't any rpm and xml files in the directory $packages_d!"); + $callback->({ data => ["There isn't any rpm and xml files in the directory $packages_d!"] }); + $request = (); + return -1; + } + + my $rpm_list = join(" ", @rpmlist); my $xml_list = join(" ", @xmllist); - + my $cmd; - if( -d $packages_fw) { + if (-d $packages_fw) { $cmd = "rm -rf $packages_fw/*"; xCAT::Utils->runcmd($cmd, 0); - if ($::RUNCMD_RC != 0) - { + if ($::RUNCMD_RC != 0) + { #send_msg($request, 1, "Failed to remove the old packages in $packages_fw."); - $callback->({data=>["Failed to remove the old packages in $packages_fw."]}); + $callback->({ data => ["Failed to remove the old packages in $packages_fw."] }); $request = (); return -1; - } } - + } + $cmd = "mkdir -p $packages_fw"; xCAT::Utils->runcmd("$cmd", 0); if ($::RUNCMD_RC != 0) { #send_msg($request, 1, "$cmd failed."); - $callback->({data=>["$cmd failed."]}); + $callback->({ data => ["$cmd failed."] }); $request = (); return; } - + $cmd = "cp $packages_d/*.rpm $packages_d/*.xml $packages_fw"; xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) { #send_msg($request, 1, "$cmd failed."); - $callback->({data=>["$cmd failed."]}); + $callback->({ data => ["$cmd failed."] }); $request = (); return -1; } - #$req->{arg} = $exargs; + #$req->{arg} = $exargs; } return 0; } @@ -419,61 +428,65 @@ sub preprocess_for_rflash { sub print_var { - my $j = shift; + my $j = shift; my $msg = shift; - + my $var = "+++++++++$msg start--++++\n"; - if(ref($j) eq "ARRAY") { + if (ref($j) eq "ARRAY") { my $t; - foreach $t(@$j) { - if(ref($t) eq "ARRAY") { + foreach $t (@$j) { + if (ref($t) eq "ARRAY") { my $t0 = join(" ", @$t); + #if(ref($t0) eq "SCALAR") { - $var = $var."\t$t0(array)\n"; + $var = $var . "\t$t0(array)\n"; + #} else { # &print_var($t0); #} - } elsif( ref($t) eq "HASH" ) { + } elsif (ref($t) eq "HASH") { my $t12; my $t23; - while(($t12, $t23) = each(%$t)) { - $var = $var. "\t$t12 => \n"; - #if(ref($t23) eq "SCALAR") { - $var = $var. "\t$t23(hash)\n"; - #} else { - # &print_var($t23); - #} + while (($t12, $t23) = each(%$t)) { + $var = $var . "\t$t12 => \n"; + + #if(ref($t23) eq "SCALAR") { + $var = $var . "\t$t23(hash)\n"; + + #} else { + # &print_var($t23); + #} } - - }else { - $var = $var. "$t\n"; + + } else { + $var = $var . "$t\n"; } } } elsif (ref($j) eq "HASH") { my $t1; my $t2; - while(($t1, $t2) =each (%$j)) { - $var = $var. "$t1 =>"; - if(ref($t2) eq "HASH") { + while (($t1, $t2) = each(%$j)) { + $var = $var . "$t1 =>"; + if (ref($t2) eq "HASH") { my $t12; my $t23; - while(($t12, $t23) = each(%$t2)) { - $var = $var. "\t$t12 => $t23\n"; + while (($t12, $t23) = each(%$t2)) { + $var = $var . "\t$t12 => $t23\n"; } - } elsif(ref($t2) eq "ARRAY") { + } elsif (ref($t2) eq "ARRAY") { my $t = join(" ", @$t2); - $var = $var. "$t (array)\n"; + $var = $var . "$t (array)\n"; } else { - $var = $var. "$t2\n"; + $var = $var . "$t2\n"; } } } else { - $var = $var. "$j(scalar)\n"; + $var = $var . "$j(scalar)\n"; } - $var = $var. "+++++++++++$msg end+++++++++++\n"; - + $var = $var . "+++++++++++$msg end+++++++++++\n"; + return $var; } @@ -483,88 +496,91 @@ sub print_var { #-------------------------------------------------------------------------# # sub get_lic_filenames { - my $mtms = shift; - my $upgrade_required = 0; - my $msg = undef; + my $mtms = shift; + my $upgrade_required = 0; + my $msg = undef; my $filename; - if(! -d $packages_dir) { + if (!-d $packages_dir) { $msg = "The directory $packages_dir doesn't exist!"; - return ("","","", $msg, -1); + return ("", "", "", $msg, -1); } - + #print "opening directory and reading names\n"; opendir DIRHANDLE, $packages_dir; - @dirlist= readdir DIRHANDLE; + @dirlist = readdir DIRHANDLE; closedir DIRHANDLE; - @dirlist = File::Spec->no_upwards( @dirlist ); + @dirlist = File::Spec->no_upwards(@dirlist); # Make sure we have some files to process # - if( !scalar( @dirlist ) ) { + if (!scalar(@dirlist)) { $msg = "directory $packages_dir is empty"; - return ("","","",$msg, -1); + return ("", "", "", $msg, -1); } - $release_level =~/(\w{4})(\d{3})/; + $release_level =~ /(\w{4})(\d{3})/; my $pns = $1; my $fff = $2; - + #Find the latest version lic file @dirlist = grep /\.rpm$/, @dirlist; - @dirlist = grep /$1/, @dirlist; - if( !scalar( @dirlist ) ) { - $msg = "There isn't a package suitable for $mtms"; - return ("","","",$msg, -1); + @dirlist = grep /$1/, @dirlist; + if (!scalar(@dirlist)) { + $msg = "There isn't a package suitable for $mtms"; + return ("", "", "", $msg, -1); } - if( scalar(@dirlist) > 1) { + if (scalar(@dirlist) > 1) { + # Need to find the latest version package. - @dirlist =reverse sort(@dirlist); + @dirlist = reverse sort(@dirlist); my $t = "\n"; - foreach $t(@dirlist) { - $msg =$msg."$t\t"; + foreach $t (@dirlist) { + $msg = $msg . "$t\t"; } } - $filename = File::Spec->catfile( $packages_dir, $dirlist[0] ); - $dirlist[0] =~ /(\w{4})(\d{3})_(\w{3})_(\d{3}).rpm$/; + $filename = File::Spec->catfile($packages_dir, $dirlist[0]); + $dirlist[0] =~ /(\w{4})(\d{3})_(\w{3})_(\d{3}).rpm$/; ############## #If the release levels are different, it will be upgrade_required. ############# - if($fff ne $2) { + if ($fff ne $2) { $upgrade_required = 1; - if($activate ne "disruptive") { + if ($activate ne "disruptive") { $msg = "Option --activate's value should be disruptive"; - return ("", "","", $msg, -1); + return ("", "", "", $msg, -1); } } else { - if(($pns eq $1) && ($3 > $active_level) &&($4 <= $active_level)) { - $msg = $msg. "Upgrade $mtms $activate!"; - if($activate ne "concurrent") { + if (($pns eq $1) && ($3 > $active_level) && ($4 <= $active_level)) { + $msg = $msg . "Upgrade $mtms $activate!"; + if ($activate ne "concurrent") { $msg = "Option --actviate's value should be concurrent"; - return ("", "","", $msg, -1); + return ("", "", "", $msg, -1); } } else { $msg = $msg . "Upgrade $mtms!"; - if($activate ne "disruptive") { + if ($activate ne "disruptive") { $msg = "Option --activate's value should be disruptive"; - return ("", "","", $msg, -1); + return ("", "", "", $msg, -1); } - } + } } + #print "filename is $filename\n"; my $xml_file_name = $filename; $xml_file_name =~ s/(.+\.)rpm/\1xml/; + #print "check_licdd_update: source xml file is $xml_file_name\n"; - if( ( -z $filename)|| ( -z $xml_file_name) ) { - $msg = "The package $filename or xml $xml_file_name is empty" ; + if ((-z $filename) || (-z $xml_file_name)) { + $msg = "The package $filename or xml $xml_file_name is empty"; return ("", "", "", $msg, -1); } - - return ($filename, $xml_file_name ,$upgrade_required, $msg, 0); + + return ($filename, $xml_file_name, $upgrade_required, $msg, 0); } @@ -576,27 +592,27 @@ sub get_one_mtms { my $mtms; my $msg; - my $values = xCAT::PPCcli::send_cmd( $exp, $cmd ); + my $values = xCAT::PPCcli::send_cmd($exp, $cmd); my $Rc = shift(@$values); ##################################### # Return error ##################################### - if ( $Rc != SUCCESS ) { - $msg = "ERROR: Failed to find a CEC managed by $bpa on the HMC"; - return ("", $msg); + if ($Rc != SUCCESS) { + $msg = "ERROR: Failed to find a CEC managed by $bpa on the HMC"; + return ("", $msg); } foreach (@$values) { - if( $_ =~ /cage_num=(\w*),contents=sys,type_model_serial_num=(\w+)-(\w+)\*(\w+),loc_code=(\w+).(\w+).(\w+)/) { + if ($_ =~ /cage_num=(\w*),contents=sys,type_model_serial_num=(\w+)-(\w+)\*(\w+),loc_code=(\w+).(\w+).(\w+)/) { $mtms = "$2-$3*$4"; last; } } - + # print "the managed system is $mtms!\n"; - return ($mtms, $msg); + return ($mtms, $msg); } @@ -612,115 +628,119 @@ sub rflash { my $subreq = $request->{subreq}; my $hwtype = @$exp[2]; my @result; - my $timeout = $request->{ppctimeout}; - + my $timeout = $request->{ppctimeout}; + my $housekeeping = $request->{housekeeping}; $packages_dir = $request->{opt}->{p}; - $activate = $request->{opt}->{activate}; + $activate = $request->{opt}->{activate}; my $hmc; my $mtms; - my $component; # system or power + my $component; # system or power my $h; my $user; - - my $tmp_file; #the file handle of the stanza + + my $tmp_file; #the file handle of the stanza my $rpm_file; my $xml_file; my @rpm_files; my @xml_files; my $upgrade_required; my $stanza = undef; - my $mtms_t; + my $mtms_t; my @value; my %infor; $hmc = @$exp[3]; - dpush(\@value, [$hmc, "In rflash()"]); - dpush(\@value,[$hmc, print_var($request, "request")]); - dpush(\@value,[$hmc, print_var($hash, "hash")]); - dpush(\@value,[$hmc, print_var($exp, "exp")]); + dpush(\@value, [ $hmc, "In rflash()" ]); + dpush(\@value, [ $hmc, print_var($request, "request") ]); + dpush(\@value, [ $hmc, print_var($hash, "hash") ]); + dpush(\@value, [ $hmc, print_var($exp, "exp") ]); + # print_var($t); ######################## # Now build a temporary file containing the stanzas to be run on the HMC ################### - my $tmp_file = tmpnam();# the file handle of the stanza + my $tmp_file = tmpnam(); # the file handle of the stanza ############################## # Open the temp file ########################## - - dpush(\@value,[$hmc, "opening file $tmp_file"]); - unless( open TMP, ">$tmp_file" ) { - push (@value,[ $hmc, "cannot open $tmp_file, $!\n"]); - return (\@value); + + dpush(\@value, [ $hmc, "opening file $tmp_file" ]); + unless (open TMP, ">$tmp_file") { + push(@value, [ $hmc, "cannot open $tmp_file, $!\n" ]); + return (\@value); } - while(($mtms,$h) = each(%$hash)) { - dpush(\@value,[$hmc, "mtms:$mtms"]); + while (($mtms, $h) = each(%$hash)) { + dpush(\@value, [ $hmc, "mtms:$mtms" ]); $mtms_t = "$mtms_t $mtms"; - my $lflag = 0; + my $lflag = 0; my $managed_system = $mtms; - if( defined( $housekeeping ) ) { + if (defined($housekeeping)) { + #$hmc_has_work = 1; #$::work_flag = 1; - &dpush(\@value,[$hmc,"$mtms:creating stanza for housekeeping operation\n"]); + &dpush(\@value, [ $hmc, "$mtms:creating stanza for housekeeping operation\n" ]); $stanza = "updlic::" . $managed_system . "::" . $housekeeping . "::::"; - - &dpush(\@value,[$hmc, "$mtms:Writing $stanza to file\n"]); + + &dpush(\@value, [ $hmc, "$mtms:Writing $stanza to file\n" ]); + #push(@result,[$hmc,"$mtms:$housekeeping successfully!"]); - $infor{$mtms} = [$housekeeping]; + $infor{$mtms} = [$housekeeping]; print TMP "$stanza\n"; } else { - while(my ($name, $d) = each(%$h)) { - if ( @$d[4] !~ /^(fsp|bpa|lpar|cec|frame)$/ ) { - push @value, [$name,"Information only available for LPAR/CEC/BPA/Frame",RC_ERROR]; - next; + while (my ($name, $d) = each(%$h)) { + if (@$d[4] !~ /^(fsp|bpa|lpar|cec|frame)$/) { + push @value, [ $name, "Information only available for LPAR/CEC/BPA/Frame", RC_ERROR ]; + next; } - + ############### #If $name is a Lpar, the flag will be changed from "lpar" to "fsp" ####################### - if ( @$d[4] =~ /^lpar$/ || @$d[4] =~ /^cec$/ ) { - @$d[4] = "fsp"; - $lflag = 1; + if (@$d[4] =~ /^lpar$/ || @$d[4] =~ /^cec$/) { + @$d[4] = "fsp"; + $lflag = 1; + #push (@value, [$hmc,"$name is a Lpar on MTMS $mtms", 1]); } - if( @$d[4] eq "fsp" ) { + if (@$d[4] eq "fsp") { $component = "system"; } else { $component = "power"; - } - dpush(\@value, [$hmc,"$mtms:component:$component!"]); - - my $values = xCAT::PPCcli::lslic( $exp, $d, $timeout ); + } + dpush(\@value, [ $hmc, "$mtms:component:$component!" ]); + + my $values = xCAT::PPCcli::lslic($exp, $d, $timeout); my $Rc = shift(@$values); ##################################### # Return error - ##################################### - if ( $Rc != SUCCESS ) { - push @value, [$name,@$values[0],$Rc]; + ##################################### + if ($Rc != SUCCESS) { + push @value, [ $name, @$values[0], $Rc ]; next; } - - if ( @$values[0] =~ /ecnumber=(\w+)/ ) { + + if (@$values[0] =~ /ecnumber=(\w+)/) { $release_level = $1; - &dpush( \@value, [$hmc,"$mtms :release level:$1"]); + &dpush(\@value, [ $hmc, "$mtms :release level:$1" ]); } - - if ( @$values[0] =~ /activated_level=(\w+)/ ) { + + if (@$values[0] =~ /activated_level=(\w+)/) { $active_level = $1; - &dpush( \@value, [$hmc,"$mtms :activated level:$1"]); - } - my $msg; - my $flag = 0; - ($rpm_file, $xml_file, $upgrade_required,$msg, $flag) = &get_lic_filenames($mtms); - if( $flag == -1) { - push (@value, [$hmc,"$mtms: $msg"]); - push (@value, [$hmc,"Failed to upgrade the firmware of $mtms on $hmc"]); + &dpush(\@value, [ $hmc, "$mtms :activated level:$1" ]); + } + my $msg; + my $flag = 0; + ($rpm_file, $xml_file, $upgrade_required, $msg, $flag) = &get_lic_filenames($mtms); + if ($flag == -1) { + push(@value, [ $hmc, "$mtms: $msg" ]); + push(@value, [ $hmc, "Failed to upgrade the firmware of $mtms on $hmc" ]); return (\@value); } - dpush ( \@value, [$hmc, $msg]); + dpush(\@value, [ $hmc, $msg ]); # If we get to this point, the HMC has to attempt an update on the # managed system, so set the flag. @@ -729,98 +749,102 @@ sub rflash { #::work_flag = 1; # Collect the rpm and xml file names in a list so we can dcp then - # in one call. + # in one call. # - if( scalar( grep /$rpm_file/, @rpm_files ) == 0 ) { + if (scalar(grep /$rpm_file/, @rpm_files) == 0) { push @rpm_files, $rpm_file; push @xml_files, $xml_file; } - my ($volume,$directories,$file) = File::Spec->splitpath($rpm_file); + my ($volume, $directories, $file) = File::Spec->splitpath($rpm_file); + #push(@result,[$hmc, "Upgrade $mtms from release level:$release_level activated level:$active_level to $file successfully"]); - - #If mtms is a bpa, we should change the managed_system to a cec whose parent is a bpa. - if($component eq "power") { - ($managed_system, $msg)= &get_one_mtms($exp, $managed_system); - if($managed_system eq "") { - push(@value, [$hmc, $msg]); + + #If mtms is a bpa, we should change the managed_system to a cec whose parent is a bpa. + if ($component eq "power") { + ($managed_system, $msg) = &get_one_mtms($exp, $managed_system); + if ($managed_system eq "") { + push(@value, [ $hmc, $msg ]); return (\@value); - + } - dpush(\@value,[$hmc, $msg]); - $infor{$managed_system} = ["upgrade", $release_level, $active_level, $file, "power", $mtms]; + dpush(\@value, [ $hmc, $msg ]); + $infor{$managed_system} = [ "upgrade", $release_level, $active_level, $file, "power", $mtms ]; } else { - $infor{$managed_system} = ["upgrade", $release_level, $active_level, $file]; + $infor{$managed_system} = [ "upgrade", $release_level, $active_level, $file ]; } } - - my $rpm_dest = $::POWER_DEST_DIR."/".$dirlist[0]; + + my $rpm_dest = $::POWER_DEST_DIR . "/" . $dirlist[0]; + # The contents of the stanza file are slightly different depending # on the operation being performed. # # $managed_system = "9125-F2A*0262652"; - if( $upgrade_required ) { + if ($upgrade_required) { $stanza = "updlic::" . $managed_system . "::upgrade::::$rpm_dest"; } else { - $stanza = "updlic::" . $managed_system . "::activate::" . $component . "::" .$rpm_dest; + $stanza = "updlic::" . $managed_system . "::activate::" . $component . "::" . $rpm_dest; } - dpush(\@value,[$hmc, "Writing $stanza to file"]); + dpush(\@value, [ $hmc, "Writing $stanza to file" ]); print TMP "$stanza\n"; - @dirlist = (); + @dirlist = (); $rpm_file = (); $xml_file = (); - } + } } + # Close the file. dcp the stanza file, rpm update and xml file to the # target HMC # close TMP; - + ################################## # Get userid/password ################################## my $cred = $request->{$hmc}{cred}; - $user = @$cred[0]; - - dpush(\@value, [$hmc,"user: $user"]);; - #$password = @$cred[1] - + $user = @$cred[0]; - my $rpm_file_list = join(" ", @rpm_files); - my $xml_file_list = join(" ", @xml_files); + dpush(\@value, [ $hmc, "user: $user" ]); + + #$password = @$cred[1] + + + my $rpm_file_list = join(" ", @rpm_files); + my $xml_file_list = join(" ", @xml_files); ############################### #Prepare for "xdcp"-----runDcp_api is removed. ############################## - my $source = "$tmp_file $rpm_file_list $xml_file_list"; - my $target = "/tmp"; + my $source = "$tmp_file $rpm_file_list $xml_file_list"; + my $target = "/tmp"; my $current_userid = getpwuid($>); - - my $res = xCAT::Utils->runxcmd( { - command => ['xdcp'], - node => [$hmc], - arg => [ "-l", $user, $source, $target ], - env => ["DSH_FROM_USERID=$current_userid","DSH_TO_USERID=$user"], - }, - $subreq, 0, 1); - if ($::RUNCMD_RC ) { # error from dcp - my $rsp={}; - dpush(\@value, [$hmc,"invoking xdcp"]); + my $res = xCAT::Utils->runxcmd({ + command => ['xdcp'], + node => [$hmc], + arg => [ "-l", $user, $source, $target ], + env => [ "DSH_FROM_USERID=$current_userid", "DSH_TO_USERID=$user" ], + }, + $subreq, 0, 1); + + if ($::RUNCMD_RC) { # error from dcp + my $rsp = {}; + dpush(\@value, [ $hmc, "invoking xdcp" ]); $rsp->{data}->[0] = "Error from xdcp. Return Code = $::RUNCMD_RC"; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); - push(@value,[$hmc,$rsp->{data}->[0]]); - push(@value,[$hmc,"Failed to copy $tmp_file $rpm_file_list $xml_file_list to $hmc"]); - push(@value,[$hmc,"Please check whether the HMC $hmc is configured to allow remote ssh automatic connections"]); - push (@value, [$hmc,"Failed to upgrade the firmware of $mtms_t on $hmc"]); - return(\@value); - } + push(@value, [ $hmc, $rsp->{data}->[0] ]); + push(@value, [ $hmc, "Failed to copy $tmp_file $rpm_file_list $xml_file_list to $hmc" ]); + push(@value, [ $hmc, "Please check whether the HMC $hmc is configured to allow remote ssh automatic connections" ]); + push(@value, [ $hmc, "Failed to upgrade the firmware of $mtms_t on $hmc" ]); + return (\@value); + } my $r = (); - foreach $r (@$res){ - push(@value, [$r]); + foreach $r (@$res) { + push(@value, [$r]); } - - - push(@value,[$hmc, "copy files to $hmc completely"]); + + + push(@value, [ $hmc, "copy files to $hmc completely" ]); ############################################### # Now that all the stanzas files have been built and copied to the HMCs, @@ -834,78 +858,81 @@ sub rflash { # }, # , $subreq, 0, 1); # - #$options{ 'user' } = $user; - #$options{ 'nodes' } = $hmc; + #$options{ 'user' } = $user; + #$options{ 'nodes' } = $hmc; #$options{ 'exit-status' } = 1; - #$options{ 'stream' } = 1; + #$options{ 'stream' } = 1; #$options{ 'command' } = "csmlicutil $tmp_file"; #$options{ 'command' } = "ls -al"; - + #@res = xCAT::DSHCLI->runDsh_api(\%options, 0); #my $Rc = pop(@res); #push(@value, [$Rc]); # The above code isn't supported. - + my $cmd_hmc = "csmlicutil $tmp_file"; + #my $cmd_hmc = "ls -al"; print "before runxcmd, current_userid = $current_userid; DSH_TO_USERID=$user \n"; - my $res = xCAT::Utils->runxcmd( { - command => ['xdsh'], - node => [$hmc], - arg => [ "-l", $user , $cmd_hmc ], - env => ["DSH_FROM_USERID=$current_userid","DSH_TO_USERID=$user"], - }, - $subreq, 0, 1); + my $res = xCAT::Utils->runxcmd({ + command => ['xdsh'], + node => [$hmc], + arg => [ "-l", $user, $cmd_hmc ], + env => [ "DSH_FROM_USERID=$current_userid", "DSH_TO_USERID=$user" ], + }, + $subreq, 0, 1); - if ($::RUNCMD_RC ) { # error from dsh - my $rsp={}; + if ($::RUNCMD_RC) { # error from dsh + my $rsp = {}; $rsp->{data}->[0] = "Error from xdsh. Return Code = $::RUNCMD_RC"; xCAT::MsgUtils->message("S", $rsp, $::CALLBACK, 1); - dpush(\@value,[$hmc,"failed to run xdsh"]); - push(@value,[$hmc,$rsp->{data}->[0]]); - push (@value, [$hmc,"Failed to upgrade the firmware of $mtms_t on $hmc"]); - return(\@value); + dpush(\@value, [ $hmc, "failed to run xdsh" ]); + push(@value, [ $hmc, $rsp->{data}->[0] ]); + push(@value, [ $hmc, "Failed to upgrade the firmware of $mtms_t on $hmc" ]); + return (\@value); } my $r = (); - foreach $r (@$res){ - push(@value, [$r]); + foreach $r (@$res) { + push(@value, [$r]); + #hmc1: mtms : LIC_RC = 0 -- successful #hmc1: mtms : LIC_RC = 8 -- failed #hmc1: mtms : LIC_RC = 12 -- failed - if(index($r, "LIC_RC") == -1) { - next; + if (index($r, "LIC_RC") == -1) { + next; } my @tmp1 = split(/:/, $r); $tmp1[1] =~ s/\s+//g; + # LIC_RC = 0 - # LIC_RC = 8 - $tmp1[2] =~ /LIC_RC\s=\s(\d*)/; - if($1 != 0) { # failed - my $tmp3 = $infor{$tmp1[1]}; - if($$tmp3[4] eq "power") { - $tmp1[1] = $$tmp3[5]; + # LIC_RC = 8 + $tmp1[2] =~ /LIC_RC\s=\s(\d*)/; + if ($1 != 0) { # failed + my $tmp3 = $infor{ $tmp1[1] }; + if ($$tmp3[4] eq "power") { + $tmp1[1] = $$tmp3[5]; } - if($$tmp3[0] eq "upgrade") { - push(@result,[$hmc, "failed to $$tmp3[0] $tmp1[1] from release level:$$tmp3[1] activated level:$$tmp3[2] to $$tmp3[3]"]); + if ($$tmp3[0] eq "upgrade") { + push(@result, [ $hmc, "failed to $$tmp3[0] $tmp1[1] from release level:$$tmp3[1] activated level:$$tmp3[2] to $$tmp3[3]" ]); } else { - push(@result,[$hmc, "failed to $$tmp3[0] the firmware for $tmp1[1]"] ); + push(@result, [ $hmc, "failed to $$tmp3[0] the firmware for $tmp1[1]" ]); } - } else { # successful - my $tmp3 = $infor{$tmp1[1]}; - if($$tmp3[4] eq "power") { - $tmp1[1] = $$tmp3[5]; + } else { # successful + my $tmp3 = $infor{ $tmp1[1] }; + if ($$tmp3[4] eq "power") { + $tmp1[1] = $$tmp3[5]; } - if($$tmp3[0] eq "upgrade") { - push(@result,[$hmc, "$$tmp3[0] $tmp1[1] from release level:$$tmp3[1] activated level:$$tmp3[2] to $$tmp3[3] successfully"]); + if ($$tmp3[0] eq "upgrade") { + push(@result, [ $hmc, "$$tmp3[0] $tmp1[1] from release level:$$tmp3[1] activated level:$$tmp3[2] to $$tmp3[3] successfully" ]); } else { - push(@result,[$hmc, "$$tmp3[0] the firmware for $tmp1[1] successfully"]); + push(@result, [ $hmc, "$$tmp3[0] the firmware for $tmp1[1] successfully" ]); } - } + } } push(@value, @result); - return (\@value); + return (\@value); } diff --git a/perl-xCAT/xCAT/PPCscan.pm b/perl-xCAT/xCAT/PPCscan.pm index d64f816e7..5a7f41f39 100644 --- a/perl-xCAT/xCAT/PPCscan.pm +++ b/perl-xCAT/xCAT/PPCscan.pm @@ -5,7 +5,7 @@ use strict; use Getopt::Long; use Socket; use XML::Simple; -$XML::Simple::PREFERRED_PARSER='XML::Parser'; +$XML::Simple::PREFERRED_PARSER = 'XML::Parser'; use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR); use xCAT::PPCdb; use xCAT::GlobalDef; @@ -16,28 +16,28 @@ require xCAT::data::ibmhwtypes; ############################################## # Globals ############################################## -my @header = ( - ["type", "%-8s" ], - ["name", "placeholder" ], - ["id", "%-8s" ], - ["type-model", "%-12s" ], - ["serial-number", "%-15s" ], - ["side", "%-6s\n" ]); +my @header = ( + [ "type", "%-8s" ], + [ "name", "placeholder" ], + [ "id", "%-8s" ], + [ "type-model", "%-12s" ], + [ "serial-number", "%-15s" ], + [ "side", "%-6s\n" ]); my @attribs = qw(nodetype node id mtm serial side hcp pprofile parent groups mgt cons hwtype); my %globalnodetype = ( - fsp => $::NODETYPE_PPC, - bpa => $::NODETYPE_PPC, - cec => $::NODETYPE_PPC, - frame=> $::NODETYPE_PPC, - lpar =>"$::NODETYPE_PPC,$::NODETYPE_OSI" + fsp => $::NODETYPE_PPC, + bpa => $::NODETYPE_PPC, + cec => $::NODETYPE_PPC, + frame => $::NODETYPE_PPC, + lpar => "$::NODETYPE_PPC,$::NODETYPE_OSI" ); my %globalhwtype = ( - fsp => $::NODETYPE_FSP, - bpa => $::NODETYPE_BPA, - lpar => $::NODETYPE_LPAR, - cec => $::NODETYPE_CEC, - frame=> $::NODETYPE_FRAME, + fsp => $::NODETYPE_FSP, + bpa => $::NODETYPE_BPA, + lpar => $::NODETYPE_LPAR, + cec => $::NODETYPE_CEC, + frame => $::NODETYPE_FRAME, ); @@ -56,74 +56,74 @@ sub parse_args { ############################################# local *usage = sub { my $usage_string = xCAT::Usage->getUsage($cmd); - return( [ $_[0], $usage_string] ); + return ([ $_[0], $usage_string ]); }; ############################################# # Process command-line arguments ############################################# - if ( !defined( $args )) { - $request->{method} = $cmd; - return( \%opt ); + if (!defined($args)) { + $request->{method} = $cmd; + return (\%opt); } ############################################# # Checks case in GetOptions, allows opts # to be grouped (e.g. -vx), and terminates # at the first unrecognized option. ############################################# - @ARGV = @$args; + @ARGV = @$args; $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); + Getopt::Long::Configure("bundling"); - if ( !GetOptions( \%opt, qw(V|verbose u w x z) )){ - return( usage() ); + if (!GetOptions(\%opt, qw(V|verbose u w x z))) { + return (usage()); } #################################### # Check for "-" with no option #################################### - if ( grep(/^-$/, @ARGV )) { - return(usage( "Missing option: -" )); + if (grep(/^-$/, @ARGV)) { + return (usage("Missing option: -")); } #################################### # Check for an argument #################################### - if ( defined( $ARGV[0] )) { - return(usage( "Invalid Argument: $ARGV[0]" )); + if (defined($ARGV[0])) { + return (usage("Invalid Argument: $ARGV[0]")); } ############################################# # Check for mutually-exclusive formatting ############################################# - if (( exists($opt{x}) + exists($opt{z})) > 1 ) { - return( usage() ); + if ((exists($opt{x}) + exists($opt{z})) > 1) { + return (usage()); } ############################################# # Check for mutually-exclusive flags ############################################# - if (( exists($opt{u}) + exists($opt{w})) > 1 ) { - return(usage( "Flag -u cannot be used with flag -w")); + if ((exists($opt{u}) + exists($opt{w})) > 1) { + return (usage("Flag -u cannot be used with flag -w")); } #################################### # No operands - add command name #################################### - $request->{method} = $cmd; - return( \%opt ); + $request->{method} = $cmd; + return (\%opt); } ########################################################################## -# Returns short-hostname given an IP +# Returns short-hostname given an IP ########################################################################## sub getshorthost { my $ip = shift; my $host = xCAT::NetworkUtils->gethostname($ip); - if ( $host and !$! ) { + if ($host and !$!) { ############################## # Get short-hostname ############################## - if ( $host =~ /([^\.]+)\./ ) { - return($1); + if ($host =~ /([^\.]+)\./) { + return ($1); } } ################################## @@ -141,137 +141,137 @@ sub enumerate { my $exp = shift; my $hwtype = @$exp[2]; my $server = @$exp[3]; - my @values = (); + my @values = (); my %cage = (); my %hwconn = (); my $Rc; my $filter; ######################################### - # Get hardware control point info + # Get hardware control point info ######################################### { - my $hcp = xCAT::PPCcli::lshmc( $exp ); - $Rc = shift(@$hcp); + my $hcp = xCAT::PPCcli::lshmc($exp); + $Rc = shift(@$hcp); - ######################################### - # Return error - ######################################### - if ( $Rc != SUCCESS ) { - return( @$hcp[0] ); - } - ######################################### - # Success - ######################################### - my ($model,$serial) = split /,/, @$hcp[0]; - my $id = ""; - my $prof = ""; - my $ips = ""; - my $bpa = ""; - my $side = ""; + ######################################### + # Return error + ######################################### + if ($Rc != SUCCESS) { + return (@$hcp[0]); + } + ######################################### + # Success + ######################################### + my ($model, $serial) = split /,/, @$hcp[0]; + my $id = ""; + my $prof = ""; + my $ips = ""; + my $bpa = ""; + my $side = ""; - push @values, join( ",", - $hwtype,$server,$id,$model,$serial,$side,$server,$prof,$bpa,$ips ); + push @values, join(",", + $hwtype, $server, $id, $model, $serial, $side, $server, $prof, $bpa, $ips); } ######################################### # Save hardware connections ######################################### - if ( $hwtype ne "ivm" ) { #Not applicable for IVM + if ($hwtype ne "ivm") { #Not applicable for IVM $filter = "type_model_serial_num,ipaddr,sp,side"; - my $conns = xCAT::PPCcli::lssysconn( $exp, "alls", $filter ); + my $conns = xCAT::PPCcli::lssysconn($exp, "alls", $filter); $Rc = shift(@$conns); ######################################### # Return error ######################################### - if ( $Rc != SUCCESS ) { - return( @$conns[0] ); + if ($Rc != SUCCESS) { + return (@$conns[0]); } - foreach my $con ( @$conns ) { - my ($mtms,$ipaddr,$sp,$side) = split /,/,$con; + foreach my $con (@$conns) { + my ($mtms, $ipaddr, $sp, $side) = split /,/, $con; my $value = undef; - if ( $sp =~ /^primary$/ or $side =~ /^a$/ ) { + if ($sp =~ /^primary$/ or $side =~ /^a$/) { $value = "A"; - } elsif ($sp =~ /^secondary$/ or $side =~ /^b$/ ) { + } elsif ($sp =~ /^secondary$/ or $side =~ /^b$/) { $value = "B"; } $hwconn{$ipaddr} = "$mtms,$value"; } } - + ######################################### # Enumerate frames (IVM has no frame) ######################################### - if ( $hwtype ne "ivm" ) { - $filter = "type_model,serial_num,name,frame_num,ipaddr_a,ipaddr_b"; - my $frames = xCAT::PPCcli::lssyscfg( $exp, "bpas", $filter ); + if ($hwtype ne "ivm") { + $filter = "type_model,serial_num,name,frame_num,ipaddr_a,ipaddr_b"; + my $frames = xCAT::PPCcli::lssyscfg($exp, "bpas", $filter); $Rc = shift(@$frames); ##################################### - # Expect error + # Expect error ##################################### - if ( $Rc == EXPECT_ERROR ) { - return( @$frames[0] ); + if ($Rc == EXPECT_ERROR) { + return (@$frames[0]); } ##################################### - # CLI error + # CLI error ##################################### - if ( $Rc == RC_ERROR ) { - return( @$frames[0] ); + if ($Rc == RC_ERROR) { + return (@$frames[0]); } ##################################### - # If frames found, enumerate cages + # If frames found, enumerate cages ##################################### - if ( $Rc != NR_ERROR ) { + if ($Rc != NR_ERROR) { $filter = "cage_num,type_model_serial_num"; - foreach my $val ( @$frames ) { - my ($model,$serial) = split /,/, $val; + foreach my $val (@$frames) { + my ($model, $serial) = split /,/, $val; my $mtms = "$model*$serial"; - my $cages = xCAT::PPCcli::lssyscfg($exp,"cage",$mtms,$filter); + my $cages = xCAT::PPCcli::lssyscfg($exp, "cage", $mtms, $filter); $Rc = shift(@$cages); ############################# # Skip... - # Frame in bad state + # Frame in bad state ############################# - if ( $Rc != SUCCESS ) { + if ($Rc != SUCCESS) { push @values, "# $mtms: ERROR @$cages[0]"; next; } ############################# - # Success + # Success ############################# - foreach ( @$cages ) { - my ($cageid,$mtms) = split /,/; + foreach (@$cages) { + my ($cageid, $mtms) = split /,/; $cage{$mtms} = "$cageid,$val"; - } + } } } } ######################################### - # Enumerate CECs + # Enumerate CECs ######################################### - $filter = "name,type_model,serial_num,ipaddr"; - my $cecs = xCAT::PPCcli::lssyscfg( $exp, "fsps", $filter ); + $filter = "name,type_model,serial_num,ipaddr"; + my $cecs = xCAT::PPCcli::lssyscfg($exp, "fsps", $filter); $Rc = shift(@$cecs); ######################################### # Return error ######################################### - if ( $Rc != SUCCESS ) { - return( @$cecs[0] ); + if ($Rc != SUCCESS) { + return (@$cecs[0]); } - foreach ( @$cecs ) { + foreach (@$cecs) { ##################################### # Get CEC information ##################################### - my ($fsp,$model,$serial,$ips) = split /,/; + my ($fsp, $model, $serial, $ips) = split /,/; my $mtms = "$model*$serial"; my $cageid = ""; my $fname = ""; @@ -284,19 +284,19 @@ sub enumerate { ##################################### # Save frame information ##################################### - if ( defined($frame) ) { - my ($cage,$model,$serial,$name,$id,$ipa,$ipb) = split /,/, $frame; + if (defined($frame)) { + my ($cage, $model, $serial, $name, $id, $ipa, $ipb) = split /,/, $frame; my $prof = ""; - my $bpa = ""; - $cageid = $cage; - $fname = $name; + my $bpa = ""; + $cageid = $cage; + $fname = $name; ####################################### # Convert IP-A to short-hostname. # If fails, use user-defined FSP name ####################################### - my $host = getshorthost( $ipa ); - if ( defined($host) ) { + my $host = getshorthost($ipa); + if (defined($host)) { $fname = $host; } @@ -315,9 +315,9 @@ sub enumerate { # push @values, join( ",", # "bpa",$fname,$id,$model,$serial,"B",$server,$prof,$bpa,$ipb); #} - push @values, join( ",", - "frame",$fname,$id,$model,$serial,"",$server,$prof,$bpa,""); - + push @values, join(",", +"frame", $fname, $id, $model, $serial, "", $server, $prof, $bpa, ""); + } ##################################### # Save CEC information @@ -328,59 +328,59 @@ sub enumerate { # Convert IP to short-hostname. # If fails, use user-defined FSP name ####################################### - my $host = getshorthost( $ips ); - if ( defined($host) ) { + my $host = getshorthost($ips); + if (defined($host)) { $fsp = $host; } my $mtmss = $hwconn{$ips}; - if ( $hwtype ne "ivm" ) { #Not applicable for IVM - my ($mtms,$side) = split /,/, $mtmss; + if ($hwtype ne "ivm") { #Not applicable for IVM + my ($mtms, $side) = split /,/, $mtmss; } - push @values, join( ",", - "cec",$fsp,$cageid,$model,$serial,"",$server,$prof,$fname,"" ); + push @values, join(",", +"cec", $fsp, $cageid, $model, $serial, "", $server, $prof, $fname, ""); ##################################### - # Enumerate LPARs + # Enumerate LPARs ##################################### - $filter = "name,lpar_id,default_profile,curr_profile"; - my $lpars = xCAT::PPCcli::lssyscfg( $exp, "lpar", $mtms, $filter ); - $Rc = shift(@$lpars); + $filter = "name,lpar_id,default_profile,curr_profile"; + my $lpars = xCAT::PPCcli::lssyscfg($exp, "lpar", $mtms, $filter); + $Rc = shift(@$lpars); #################################### - # Expect error + # Expect error #################################### - if ( $Rc == EXPECT_ERROR ) { - return( @$lpars[0] ); + if ($Rc == EXPECT_ERROR) { + return (@$lpars[0]); } #################################### # Skip... # CEC could be "Incomplete" state #################################### - if ( $Rc == RC_ERROR ) { + if ($Rc == RC_ERROR) { push @values, "# $mtms: ERROR @$lpars[0]"; next; } #################################### - # No results found + # No results found #################################### - if ( $Rc == NR_ERROR ) { + if ($Rc == NR_ERROR) { next; } - foreach ( @$lpars ) { - my ($name,$lparid,$dprof,$curprof) = split /,/; + foreach (@$lpars) { + my ($name, $lparid, $dprof, $curprof) = split /,/; my $prof = (length($curprof) && ($curprof !~ /^none$/)) ? $curprof : $dprof; my $ips = ""; my $port = ""; - + ##################################### # Save LPAR information ##################################### - push @values, join( ",", - "lpar",$name,$lparid,$model,$serial,$port,$server,$prof,$fsp,$ips ); + push @values, join(",", +"lpar", $name, $lparid, $model, $serial, $port, $server, $prof, $fsp, $ips); } } - return( \@values ); + return (\@values); } @@ -390,19 +390,19 @@ sub enumerate { ########################################################################## sub format_output { - my $request = shift; - my $exp = shift; - my $values = shift; - my $opt = $request->{opt}; - my %output = (); - my $hwtype = @$exp[2]; + my $request = shift; + my $exp = shift; + my $values = shift; + my $opt = $request->{opt}; + my %output = (); + my $hwtype = @$exp[2]; my $max_length = 0; my $result; ########################################### # -w flag for write to xCat database ########################################### - if ( exists( $opt->{w} )) { + if (exists($opt->{w})) { my $server = @$exp[3]; my $uid = @$exp[4]; my $pw = @$exp[5]; @@ -410,20 +410,20 @@ sub format_output { ####################################### # Strip errors for results ####################################### - my @val = grep( !/^#.*: ERROR /, @$values ); - xCAT::PPCdb::add_ppc( $hwtype, \@val ,'','',"PPC"); + my @val = grep(!/^#.*: ERROR /, @$values); + xCAT::PPCdb::add_ppc($hwtype, \@val, '', '', "PPC"); } ########################################### # -u flag for write to xCat database ########################################### - if ( exists( $opt->{u} )) { + if (exists($opt->{u})) { ####################################### # Strip errors for results ####################################### - my @val = grep( !/^#.*: ERROR /, @$values ); - $values = xCAT::PPCdb::update_ppc( $hwtype, \@val ); - if ( exists( $opt->{x} ) or exists( $opt->{z} )) + my @val = grep(!/^#.*: ERROR /, @$values); + $values = xCAT::PPCdb::update_ppc($hwtype, \@val); + if (exists($opt->{x}) or exists($opt->{z})) { unshift @$values, "hmc"; } @@ -432,75 +432,75 @@ sub format_output { ########################################### # -x flag for xml format ########################################### - if ( exists( $opt->{x} )) { - $result .= format_xml( $hwtype, $values ); + if (exists($opt->{x})) { + $result .= format_xml($hwtype, $values); } ########################################### # -z flag for stanza format ########################################### - elsif ( exists( $opt->{z} )) { - $result .= format_stanza( $hwtype, $values ); + elsif (exists($opt->{z})) { + $result .= format_stanza($hwtype, $values); } else { - $result = sprintf( "#Updated following nodes:\n") if ( exists( $opt->{u})); + $result = sprintf("#Updated following nodes:\n") if (exists($opt->{u})); ####################################### # Get longest name for formatting ####################################### - my $nodehash; + my $nodehash; my @errmsg; - foreach ( @$values ) { + foreach (@$values) { ############################################## # Skip error message after saving it for last ############################################## - if ( /^#.*: ERROR / ) { + if (/^#.*: ERROR /) { push @errmsg, $_; next; } /([^\,]+),([^\,]+),/; - $nodehash->{$1.$2} = $_; - my $length = length( $2 ); + $nodehash->{ $1 . $2 } = $_; + my $length = length($2); $max_length = ($length > $max_length) ? $length : $max_length; } - my $format = sprintf( "%%-%ds", ($max_length + 2 )); + my $format = sprintf("%%-%ds", ($max_length + 2)); $header[1][1] = $format; ####################################### # Add header ####################################### - foreach ( @header ) { - $result .= sprintf( @$_[1], @$_[0] ); + foreach (@header) { + $result .= sprintf(@$_[1], @$_[0]); } ####################################### # Add node information ####################################### - foreach ( sort keys %$nodehash ) { + foreach (sort keys %$nodehash) { my @data = split /,/, $nodehash->{$_}; my $i = 0; - foreach ( @header ) { - my $d = $data[$i++]; + foreach (@header) { + my $d = $data[ $i++ ]; ############################### - # Use IPs instead of - # hardware control address + # Use IPs instead of + # hardware control address ############################### - if ( @$_[0] eq "address" ) { - if ( $data[0] !~ /^(hmc|ivm)$/ ) { - $d = $data[8]; + if (@$_[0] eq "address") { + if ($data[0] !~ /^(hmc|ivm)$/) { + $d = $data[8]; } } - $result .= sprintf( @$_[1], $d ); + $result .= sprintf(@$_[1], $d); } } ####################################### - # Add any error messages + # Add any error messages ####################################### - foreach ( @errmsg ) { - $result.= "\n$_"; + foreach (@errmsg) { + $result .= "\n$_"; } } $output{data} = [$result]; - return( [\%output] ); + return ([ \%output ]); } @@ -512,30 +512,30 @@ sub format_stanza { my $hwtype = shift; my $values = shift; - + my $result; my $nodehash; ##################################### - # Skip hardware control point + # Skip hardware control point ##################################### shift(@$values); - foreach ( @$values ) { - ################################### - # Skip error message - ################################### - if ( /^#.*: ERROR / ) { - next; - } - /[^\,]+,([^\,]+),/; - $nodehash->{$1} = $_; + foreach (@$values) { + ################################### + # Skip error message + ################################### + if (/^#.*: ERROR /) { + next; + } + /[^\,]+,([^\,]+),/; + $nodehash->{$1} = $_; } - foreach ( sort keys %$nodehash ) { + foreach (sort keys %$nodehash) { my @data = split /,/, $nodehash->{$_}; my $type = $data[0]; - my $i = 0; + my $i = 0; ################################# # Node attributes @@ -546,35 +546,36 @@ sub format_stanza { # Add each attribute ################################# my $mtm = undef; - foreach ( @attribs ) { - my $d = $data[$i++]; + foreach (@attribs) { + my $d = $data[ $i++ ]; - if ( /^node$/ ) { + if (/^node$/) { next; - } elsif ( /^nodetype$/ ) { + } elsif (/^nodetype$/) { $d = $globalnodetype{$type}; - } elsif ( /^hwtype$/ ) { + } elsif (/^hwtype$/) { $d = $globalhwtype{$type}; - } elsif ( /^groups$/ ) { + } elsif (/^groups$/) { next; + #$d = "$type,all"; - } elsif ( /^mgt$/ ) { + } elsif (/^mgt$/) { $d = $hwtype; - } elsif ( /^cons$/ ) { - if ( $type eq "lpar" ) { + } elsif (/^cons$/) { + if ($type eq "lpar") { $d = $hwtype; } else { $d = undef; } - - } elsif ( /^(mtm|serial)$/ ) { - if ( $type eq "lpar" ) { - $d = undef; + + } elsif (/^(mtm|serial)$/) { + if ($type eq "lpar") { + $d = undef; } elsif (/^mtm$/) { $mtm = $d; } } elsif (/^side$/) { - unless ( $type =~ /^fsp|bpa$/ ) { + unless ($type =~ /^fsp|bpa$/) { next; } } @@ -585,11 +586,11 @@ sub format_stanza { my $tmp_pre = xCAT::data::ibmhwtypes::parse_group($mtm); if (defined($tmp_pre)) { $tmp_groups .= ",$tmp_pre"; - } + } } $result .= "\tgroups=$tmp_groups\n"; } - return( $result ); + return ($result); } @@ -604,64 +605,65 @@ sub format_xml { my $nodehash; ##################################### - # Skip hardware control point + # Skip hardware control point ##################################### shift(@$values); - foreach ( @$values ) { - ################################### - # Skip error message - ################################### - if ( /^#.*: ERROR / ) { - next; - } - /[^\,]+,([^\,]+),/; - $nodehash->{$1} = $_; + foreach (@$values) { + ################################### + # Skip error message + ################################### + if (/^#.*: ERROR /) { + next; + } + /[^\,]+,([^\,]+),/; + $nodehash->{$1} = $_; } ##################################### # Create XML formatted attributes ##################################### - foreach ( sort keys %$nodehash ) { + foreach (sort keys %$nodehash) { my @data = split /,/, $nodehash->{$_}; my $type = $data[0]; - my $i = 0; + my $i = 0; ################################# # Initialize hash reference ################################# my $href = { - Node => { } + Node => {} }; ################################# - # Add each attribute + # Add each attribute ################################# - my $mtm = undef; - foreach ( @attribs ) { - my $d = $data[$i++]; + my $mtm = undef; + foreach (@attribs) { + my $d = $data[ $i++ ]; - if ( /^nodetype$/ ) { + if (/^nodetype$/) { $d = $globalnodetype{$type}; - } elsif ( /^hwtype$/ ) { + } elsif (/^hwtype$/) { $d = $globalhwtype{$type}; - } elsif ( /^groups$/ ) { + } elsif (/^groups$/) { next; + #$d = "$type,all"; - } elsif ( /^mgt$/ ) { + } elsif (/^mgt$/) { $d = $hwtype; - } elsif ( /^cons$/ ) { - if ( $type eq "lpar" ) { + } elsif (/^cons$/) { + if ($type eq "lpar") { $d = $hwtype; } else { $d = undef; } - } elsif ( /^(mtm|serial)$/ ) { - if ( $type eq "lpar" ) { + } elsif (/^(mtm|serial)$/) { + if ($type eq "lpar") { $d = undef; - } elsif (/^mtm$/){ + } elsif (/^mtm$/) { $mtm = $d; } } elsif (/^side$/) { - unless ( $type =~ /^fsp|bpa$/ ) { + unless ($type =~ /^fsp|bpa$/) { next; } } @@ -672,18 +674,18 @@ sub format_xml { my $tmp_pre = xCAT::data::ibmhwtypes::parse_group($mtm); if (defined($tmp_pre)) { $tmp_groups .= ",$tmp_pre"; - } + } } - $href->{Node}->{groups}=$tmp_groups; + $href->{Node}->{groups} = $tmp_groups; ################################# # XML encoding ################################# - $xml.= XMLout($href, - NoAttr => 1, - KeyAttr => [], - RootName => undef ); + $xml .= XMLout($href, + NoAttr => 1, + KeyAttr => [], + RootName => undef); } - return( $xml ); + return ($xml); } @@ -702,16 +704,16 @@ sub rscan { ################################### # Enumerate all the hardware ################################### - my $values = enumerate( $exp ); - if ( ref($values) ne 'ARRAY' ) { - return( [[$server,$values,1]] ); + my $values = enumerate($exp); + if (ref($values) ne 'ARRAY') { + return ([ [ $server, $values, 1 ] ]); } ################################### - # Success + # Success ################################### - my $result = format_output( $request, $exp, $values ); + my $result = format_output($request, $exp, $values); unshift @$result, "FORMATDATA6sK4ci"; - return( $result ); + return ($result); } diff --git a/perl-xCAT/xCAT/PPCvitals.pm b/perl-xCAT/xCAT/PPCvitals.pm index 375a48f0b..547f23fe6 100644 --- a/perl-xCAT/xCAT/PPCvitals.pm +++ b/perl-xCAT/xCAT/PPCvitals.pm @@ -23,43 +23,43 @@ sub parse_args { ############################################# local *usage = sub { my $usage_string = xCAT::Usage->getUsage($command); - return( [ $_[0], $usage_string] ); + return ([ $_[0], $usage_string ]); }; ############################################# # Process command-line arguments ############################################# - if ( !defined( $args )) { - return(usage( "No command specified" )); + if (!defined($args)) { + return (usage("No command specified")); } ############################################# # Checks case in GetOptions, allows opts # to be grouped (e.g. -vx), and terminates # at the first unrecognized option. ############################################# - @ARGV = @$args; + @ARGV = @$args; $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); + Getopt::Long::Configure("bundling"); - if ( !GetOptions( \%opt, qw(V|verbose) )) { - return( usage() ); + if (!GetOptions(\%opt, qw(V|verbose))) { + return (usage()); } #################################### # Check for "-" with no option #################################### - if ( grep(/^-$/, @ARGV )) { - return(usage( "Missing option: -" )); + if (grep(/^-$/, @ARGV)) { + return (usage("Missing option: -")); } #################################### # Unsupported command #################################### - my ($cmd) = grep(/^$ARGV[0]$/, @rvitals ); - if ( !defined( $cmd )) { - return(usage( "Invalid command: $ARGV[0]" )); + my ($cmd) = grep(/^$ARGV[0]$/, @rvitals); + if (!defined($cmd)) { + return (usage("Invalid command: $ARGV[0]")); } - - if($ARGV[0] =~ /^rackenv$/) { - if($request->{hwtype} =~ /^hmc$/) { - return(usage( "Command $ARGV[0] is not valid when the nodes' hcp is hmc" )); + + if ($ARGV[0] =~ /^rackenv$/) { + if ($request->{hwtype} =~ /^hmc$/) { + return (usage("Command $ARGV[0] is not valid when the nodes' hcp is hmc")); } } @@ -67,14 +67,14 @@ sub parse_args { # Check for an extra argument #################################### shift @ARGV; - if ( defined( $ARGV[0] )) { - return(usage( "Invalid Argument: $ARGV[0]" )); + if (defined($ARGV[0])) { + return (usage("Invalid Argument: $ARGV[0]")); } #################################### # Set method to invoke #################################### $request->{method} = $cmd; - return( \%opt ); + return (\%opt); } @@ -87,24 +87,24 @@ sub enumerate_volt { my $d = shift; my $mtms = @$d[2]; - my $volt = xCAT::PPCcli::lshwinfo( $exp, "frame", $mtms ); - my $Rc = shift(@$volt); + my $volt = xCAT::PPCcli::lshwinfo($exp, "frame", $mtms); + my $Rc = shift(@$volt); #################################### # Return error #################################### - if ( $Rc != SUCCESS ) { - return( [RC_ERROR, @$volt[0]] ); + if ($Rc != SUCCESS) { + return ([ RC_ERROR, @$volt[0] ]); } #################################### - # Success - return voltages + # Success - return voltages #################################### - return( [SUCCESS, @$volt[0]] ); + return ([ SUCCESS, @$volt[0] ]); } ########################################################################## -# Returns cage temperatures +# Returns cage temperatures ########################################################################## sub enumerate_temp { @@ -116,23 +116,23 @@ sub enumerate_temp { # Get cage information for frame #################################### my $filter = "type_model_serial_num,temperature"; - my $cages = xCAT::PPCcli::lshwinfo( $exp, "sys", $frame, $filter ); - my $Rc = shift(@$cages); + my $cages = xCAT::PPCcli::lshwinfo($exp, "sys", $frame, $filter); + my $Rc = shift(@$cages); #################################### # Expect error #################################### - if ( $Rc == EXPECT_ERROR || $Rc == RC_ERROR ) { - return( [$Rc,@$cages[0]] ); + if ($Rc == EXPECT_ERROR || $Rc == RC_ERROR) { + return ([ $Rc, @$cages[0] ]); } #################################### # Save frame by CEC MTMS in cage #################################### - foreach ( @$cages ) { - my ($mtms,$temp) = split /,/; - $outhash{$mtms} = $temp; + foreach (@$cages) { + my ($mtms, $temp) = split /,/; + $outhash{$mtms} = $temp; } - return( [SUCCESS,\%outhash] ); + return ([ SUCCESS, \%outhash ]); } ########################################################################## @@ -140,30 +140,31 @@ sub enumerate_temp { ########################################################################## sub enumerate_lcds { - my $exp = shift; - my $d = shift; - my $mtms = @$d[2]; - my $Rc = undef; - my $value = undef; + my $exp = shift; + my $d = shift; + my $mtms = @$d[2]; + my $Rc = undef; + my $value = undef; my $nodetype = @$d[4]; - my $lpar_id = @$d[0]; - my @refcode = (); - + my $lpar_id = @$d[0]; + my @refcode = (); + my $values = xCAT::PPCcli::lsrefcode($exp, $nodetype, $mtms, $lpar_id); - foreach $value (@$values){ + foreach $value (@$values) { + #Return error $Rc = shift @$value; - if( @$value[0] =~ /refcode=(\w*)/){ + if (@$value[0] =~ /refcode=(\w*)/) { my $code = $1; - if ( ! $code) + if (!$code) { - push @refcode, [$Rc, "blank"]; + push @refcode, [ $Rc, "blank" ]; } else { - push @refcode, [$Rc, $code] ; + push @refcode, [ $Rc, $code ]; } - } + } } return \@refcode; @@ -171,7 +172,7 @@ sub enumerate_lcds { ########################################################################## -# Returns voltages/currents +# Returns voltages/currents ########################################################################## sub voltage { @@ -181,7 +182,7 @@ sub voltage { my $hwtype = @$exp[2]; my @result = (); my $text = "Frame Voltages: "; - my @prefix = ( + my @prefix = ( "Frame Voltage (Vab): %sV", "Frame Voltage (Vbc): %sV", "Frame Voltage (Vca): %sV", @@ -190,30 +191,30 @@ sub voltage { "Frame Current (Ic): %sA", ); - while (my ($mtms,$h) = each(%$hash) ) { - while (my ($name,$d) = each(%$h) ) { - ################################# - # No frame command on IVM + while (my ($mtms, $h) = each(%$hash)) { + while (my ($name, $d) = each(%$h)) { ################################# - if ( $hwtype eq "ivm" ) { - push @result, [$name,"$text Not available",1]; + # No frame command on IVM + ################################# + if ($hwtype eq "ivm") { + push @result, [ $name, "$text Not available", 1 ]; next; } - ################################# + ################################# # Voltages available in frame - ################################# - if ( @$d[4] ne "bpa" ) { - push @result, [$name,"$text Only available for BPA",0]; + ################################# + if (@$d[4] ne "bpa") { + push @result, [ $name, "$text Only available for BPA", 0 ]; next; } - my $volt = enumerate_volt( $exp, $d ); + my $volt = enumerate_volt($exp, $d); my $Rc = shift(@$volt); - ################################# - # Output error ################################# - if ( $Rc != SUCCESS ) { - push @result, [$name,"$text @$volt[0]",$Rc]; + # Output error + ################################# + if ($Rc != SUCCESS) { + push @result, [ $name, "$text @$volt[0]", $Rc ]; next; } ################################# @@ -222,13 +223,13 @@ sub voltage { my @values = split /,/, @$volt[0]; my $i = 0; - foreach ( @prefix ) { - my $value = sprintf($_, $values[$i++]); - push @result, [$name,$value,$Rc]; - } + foreach (@prefix) { + my $value = sprintf($_, $values[ $i++ ]); + push @result, [ $name, $value, $Rc ]; + } } } - return( \@result ); + return (\@result); } @@ -245,65 +246,65 @@ sub temp { my %frame = (); my $prefix = "System Temperature:"; - ######################################### + ######################################### # Group by frame - ######################################### - while (my ($mtms,$h) = each(%$hash) ) { - while (my ($name,$d) = each(%$h) ) { + ######################################### + while (my ($mtms, $h) = each(%$hash)) { + while (my ($name, $d) = each(%$h)) { my $mtms = @$d[5]; ################################# - # No frame commands for IVM - ################################# - if ( $hwtype eq "ivm" ) { - push @result, [$name,"$prefix Not available (No BPA)",0]; + # No frame commands for IVM + ################################# + if ($hwtype eq "ivm") { + push @result, [ $name, "$prefix Not available (No BPA)", 0 ]; next; } - ################################# - # Temperatures not available - ################################# - if ( @$d[4] !~ /^(fsp|cec|lpar)$/ ) { + ################################# + # Temperatures not available + ################################# + if (@$d[4] !~ /^(fsp|cec|lpar)$/) { my $text = "$prefix Only available for CEC/LPAR"; - push @result, [$name,$text,0]; - next; - } - ################################# - # Error - No frame - ################################# - if ( $mtms eq "0" ) { - push @result, [$name,"$prefix Not available (No BPA)",0]; + push @result, [ $name, $text, 0 ]; next; } ################################# - # Save node - ################################# + # Error - No frame + ################################# + if ($mtms eq "0") { + push @result, [ $name, "$prefix Not available (No BPA)", 0 ]; + next; + } + ################################# + # Save node + ################################# $frame{$mtms}{$name} = $d; } } - while (my ($mtms,$h) = each(%frame) ) { - ################################# - # Get temperatures this frame - ################################# - my $temp = enumerate_temp( $exp, $mtms ); - my $Rc = shift(@$temp); + while (my ($mtms, $h) = each(%frame)) { + ################################# + # Get temperatures this frame + ################################# + my $temp = enumerate_temp($exp, $mtms); + my $Rc = shift(@$temp); my $data = @$temp[0]; - while (my ($name,$d) = each(%$h) ) { + while (my ($name, $d) = each(%$h)) { my $mtms = @$d[2]; ############################# # Output error ############################# - if ( $Rc != SUCCESS ) { - push @result, [$name,"$prefix $data",$Rc]; + if ($Rc != SUCCESS) { + push @result, [ $name, "$prefix $data", $Rc ]; next; } ############################# - # CEC not in frame + # CEC not in frame ############################# - if ( !exists( $data->{$mtms} )) { - push @result, [$name,"$prefix CEC '$mtms' not found",1]; + if (!exists($data->{$mtms})) { + push @result, [ $name, "$prefix CEC '$mtms' not found", 1 ]; next; } ############################# @@ -312,58 +313,59 @@ sub temp { my $cel = $data->{$mtms}; my $fah = ($cel * 1.8) + 32; my $value = "$prefix $cel C ($fah F)"; - push @result, [$name,$value,$Rc]; + push @result, [ $name, $value, $Rc ]; } } - return( \@result ); + return (\@result); } ########################################################################## -# Returns system power status (on or off) +# Returns system power status (on or off) ########################################################################## sub power { - return( xCAT::PPCpower::state(@_,"Current Power Status: ",1)); + return (xCAT::PPCpower::state(@_, "Current Power Status: ", 1)); } ########################################################################## -# Returns system state +# Returns system state ########################################################################## sub state { - return( xCAT::PPCpower::state(@_,"System State: ")); + return (xCAT::PPCpower::state(@_, "System State: ")); } ########################################################################### # Returns system LCD status (LCD1, LCD2) ########################################################################## sub lcds { - my $request = shift; - my $hash = shift; - my $exp = shift; - my $hwtype = @$exp[2]; - my @result = (); - my $text = "Current LCD:"; - my $prefix = "Current LCD%d: %s"; - my $rcode = undef; + my $request = shift; + my $hash = shift; + my $exp = shift; + my $hwtype = @$exp[2]; + my @result = (); + my $text = "Current LCD:"; + my $prefix = "Current LCD%d: %s"; + my $rcode = undef; my $refcodes = undef; - my $Rc = undef; - my $num = undef; - my $value = undef; + my $Rc = undef; + my $num = undef; + my $value = undef; + + while (my ($mtms, $h) = each(%$hash)) { + while (my ($name, $d) = each(%$h)) { - while (my ($mtms,$h) = each(%$hash) ) { - while(my ($name, $d) = each(%$h) ){ #Support HMC only - if($hwtype ne 'hmc'){ - push @result, [$name, "$text Not available(NO HMC)", 1]; + if ($hwtype ne 'hmc') { + push @result, [ $name, "$text Not available(NO HMC)", 1 ]; next; } $refcodes = enumerate_lcds($exp, $d); $num = 1; - foreach $rcode (@$refcodes){ + foreach $rcode (@$refcodes) { $Rc = shift(@$rcode); $value = sprintf($prefix, $num, @$rcode[0]); - push @result, [$name, $value, $Rc]; + push @result, [ $name, $value, $Rc ]; $num = $num + 1; - } + } } } return \@result; @@ -375,16 +377,16 @@ sub lcds { ########################################################################## sub all { - my @values = ( - @{temp(@_)}, - @{voltage(@_)}, - @{state(@_)}, - @{power(@_)}, - @{lcds(@_)}, - ); + my @values = ( + @{ temp(@_) }, + @{ voltage(@_) }, + @{ state(@_) }, + @{ power(@_) }, + @{ lcds(@_) }, + ); - my @sorted_values = sort {$a->[0] cmp $b->[0]} @values; - return( \@sorted_values ); + my @sorted_values = sort { $a->[0] cmp $b->[0] } @values; + return (\@sorted_values); } diff --git a/perl-xCAT/xCAT/PPCvm.pm b/perl-xCAT/xCAT/PPCvm.pm index d753a5efb..c8229d651 100644 --- a/perl-xCAT/xCAT/PPCvm.pm +++ b/perl-xCAT/xCAT/PPCvm.pm @@ -16,8 +16,8 @@ use xCAT::MsgUtils qw(verbose_message); my %method = ( mkvm => \&mkvm_parse_args, lsvm => \&lsvm_parse_args, - rmvm => \&rmvm_parse_args, - chvm => \&chvm_parse_args + rmvm => \&rmvm_parse_args, + chvm => \&chvm_parse_args ); @@ -30,10 +30,10 @@ sub parse_args { my $cmd = $request->{command}; ############################### - # Invoke correct parse_args + # Invoke correct parse_args ############################### - my $result = $method{$cmd}( $request ); - return( $result ); + my $result = $method{$cmd}($request); + return ($result); } @@ -52,67 +52,67 @@ sub chvm_parse_args { ############################################# local *usage = sub { my $usage_string = xCAT::Usage->getUsage($cmd); - return( [ $_[0], $usage_string] ); + return ([ $_[0], $usage_string ]); }; ############################################# # Process command-line arguments ############################################# - if ( !defined( $args ) && !defined( $request->{stdin} ) ) { + if (!defined($args) && !defined($request->{stdin})) { $request->{method} = $cmd; - return( usage() ); + return (usage()); } ############################################# # Checks case in GetOptions, allows opts # to be grouped (e.g. -vx), and terminates # at the first unrecognized option. ############################################# - if ($args) { @ARGV = @$args; } - else { @ARGV = (); } + if ($args) { @ARGV = @$args; } + else { @ARGV = (); } $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); + Getopt::Long::Configure("bundling"); - if ( !GetOptions( \%opt, qw(V|verbose p=s) )) { - return( usage() ); + if (!GetOptions(\%opt, qw(V|verbose p=s))) { + return (usage()); } #################################### # Check for "-" with no option #################################### - if ( grep(/^-$/, @ARGV )) { - return(usage( "Missing option: -" )); + if (grep(/^-$/, @ARGV)) { + return (usage("Missing option: -")); } #################################### # Check for an extra argument #################################### - if ( defined( $ARGV[0] )) { + if (defined($ARGV[0])) { $opt{a} = [@ARGV]; - for my $attr ( @{$opt{a}}) + for my $attr (@{ $opt{a} }) { - if ( $attr !~ /(\w+)=(\w*)/) + if ($attr !~ /(\w+)=(\w*)/) { - return(usage( "Invalid argument or attribute: $attr" )); + return (usage("Invalid argument or attribute: $attr")); } } } #################################### - # Configuration file required + # Configuration file required #################################### - if ( !exists( $opt{p}) and !exists( $opt{a})) { - if ( !defined( $request->{stdin} )) { - return(usage( "Configuration file or attributes not specified" )); + if (!exists($opt{p}) and !exists($opt{a})) { + if (!defined($request->{stdin})) { + return (usage("Configuration file or attributes not specified")); } } #################################### # Both configuration file and # attributes are specified #################################### - if ( exists( $opt{p}) and exists( $opt{a})) { - return(usage( "Flag -p cannot be used together with attribute list")); + if (exists($opt{p}) and exists($opt{a})) { + return (usage("Flag -p cannot be used together with attribute list")); } #################################### - # No operands - add command name + # No operands - add command name #################################### $request->{method} = $cmd; - return( \%opt ); + return (\%opt); } @@ -123,39 +123,39 @@ sub mkvm_parse_args { my $request = shift; - my %opt = (); - my $cmd = $request->{command}; - my $args = $request->{arg}; + my %opt = (); + my $cmd = $request->{command}; + my $args = $request->{arg}; ############################################# # Responds with usage statement ############################################# local *usage = sub { my $usage_string = xCAT::Usage->getUsage($cmd); - return( [ $_[0], $usage_string] ); + return ([ $_[0], $usage_string ]); }; ############################################# # Process command-line arguments ############################################# - if ( !defined( $args )) { - return(usage( "No command specified" )); + if (!defined($args)) { + return (usage("No command specified")); } ############################################# # Checks case in GetOptions, allows opts # to be grouped (e.g. -vx), and terminates # at the first unrecognized option. ############################################# - @ARGV = @$args; + @ARGV = @$args; $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); - if ( !GetOptions( \%opt, qw(V|verbose ibautocfg ibacap=s i=s l=s c=s p=s full) )) { - return( usage() ); + Getopt::Long::Configure("bundling"); + if (!GetOptions(\%opt, qw(V|verbose ibautocfg ibacap=s i=s l=s c=s p=s full))) { + return (usage()); } #################################### # Check for "-" with no option #################################### - if ( grep(/^-$/, @ARGV )) { - return(usage( "Missing option: -" )); + if (grep(/^-$/, @ARGV)) { + return (usage("Missing option: -")); } ############################################################# # Check if only ibacap or ibautocfg specified with the other @@ -163,66 +163,66 @@ sub mkvm_parse_args { #if ( exists $opt{ibautocfg} and ! exists $opt{ibacap}) #{ # return(usage( "Missing option ibacap when ibautocfg is specified")); - #} + #} #elsif ( exists $opt{ibacap} and !exists $opt{ibautocfg}) #{ # return(usage( "Missing option ibautocfg when ibacap is specified")); - #} + #} #if ( $opt{ibacap} ne '1' and $opt{ibacap} ne '2' and $opt{ibacap} ne '3' and $opt{ibacap} ne '4') #{ # return(usage( "IB adapter virtual capability (option --ibacap) can only be number 1,2,3,4. \n\t 1 means 'Low utilization': 6.25% of HCA resources (1/16 of an HCA); \n\t 2 means 'Medium utilization': 12.5% of HCA resources (1/8 of an HCA); \n\t 3 means 'High utilization': 25% of HCA resources (1/4 of an HCA);\n\t 4 means 'Dedicated HCA': 100% of HCA resources (complete HCA).\n")); #} #################################### - # Check for non-zero integer + # Check for non-zero integer #################################### - if ( exists( $opt{i} )) { - if ( $opt{i} !~ /^([1-9]{1}|[1-9]{1}[0-9]+)$/ ) { - return(usage( "Invalid entry: $opt{i}" )); + if (exists($opt{i})) { + if ($opt{i} !~ /^([1-9]{1}|[1-9]{1}[0-9]+)$/) { + return (usage("Invalid entry: $opt{i}")); } } #################################### - # -i and -l not valid with -c + # -i and -l not valid with -c #################################### - if ( exists( $opt{c} ) ) { - if ( exists($opt{i}) or exists($opt{l}) or exists($opt{full})) { - return( usage() ); + if (exists($opt{c})) { + if (exists($opt{i}) or exists($opt{l}) or exists($opt{full})) { + return (usage()); } - #################################### - # -p is required for -c - #################################### - if ( !exists($opt{p})) { - return( usage() ); + #################################### + # -p is required for -c + #################################### + if (!exists($opt{p})) { + return (usage()); } } #################################### - # -i, -l and -c not valid with -f + # -i, -l and -c not valid with -f #################################### - elsif ( exists( $opt{full} ) ) { - if ( exists($opt{c}) or exists($opt{i}) or exists($opt{l})) { - return( usage() ); + elsif (exists($opt{full})) { + if (exists($opt{c}) or exists($opt{i}) or exists($opt{l})) { + return (usage()); } } #################################### # If -i and -l, both required #################################### - elsif ( !exists($opt{l}) or !exists($opt{i})) { - return( usage() ); + elsif (!exists($opt{l}) or !exists($opt{i})) { + return (usage()); } #################################### # Check for an extra argument #################################### - if ( defined( $ARGV[0] )) { - return(usage( "Invalid Argument: $ARGV[0]" )); + if (defined($ARGV[0])) { + return (usage("Invalid Argument: $ARGV[0]")); } #################################### # Expand -l noderange #################################### - if ( exists( $opt{l} )) { - my @noderange = xCAT::NodeRange::noderange( $opt{l},0 ); - if ( !@noderange ) { - return(usage( "Invalid noderange: '$opt{l}'" )); + if (exists($opt{l})) { + my @noderange = xCAT::NodeRange::noderange($opt{l}, 0); + if (!@noderange) { + return (usage("Invalid noderange: '$opt{l}'")); } @noderange = sort @noderange; $opt{lpar} = \@noderange; @@ -230,44 +230,44 @@ sub mkvm_parse_args { #################################### # Expand -c noderange #################################### - if ( exists( $opt{c} )) { - my @noderange = xCAT::NodeRange::noderange( $opt{c},0 ); - if ( !@noderange ) { - return(usage( "Invalid noderange: '$opt{l}'" )); + if (exists($opt{c})) { + my @noderange = xCAT::NodeRange::noderange($opt{c}, 0); + if (!@noderange) { + return (usage("Invalid noderange: '$opt{l}'")); } $opt{cec} = \@noderange; } ################################################# # Swap the targets to be processed in PPC.pm ################################################# - $opt{target} = [@{$request->{node}}]; - if ( $opt{l}) + $opt{target} = [ @{ $request->{node} } ]; + if ($opt{l}) { - $request->{node} = [@{$opt{lpar}}]; + $request->{node} = [ @{ $opt{lpar} } ]; $request->{noderange} = $opt{l}; } - if ( $opt{c}) + if ($opt{c}) { - $request->{node} = [@{$opt{cec}}]; + $request->{node} = [ @{ $opt{cec} } ]; $request->{noderange} = $opt{c}; - } + } ############################################# - # Only 1 node allowed + # Only 1 node allowed ############################################# - if ( !exists($opt{full}) && scalar( @{$request->{node}} ) > 1) { - return(usage( "Multiple source specified" )); - } + if (!exists($opt{full}) && scalar(@{ $request->{node} }) > 1) { + return (usage("Multiple source specified")); + } ################################################ # Check if the multiple nodes of the same CEC are specified with -f ################################################ - if ( (exists($opt{full})) && (scalar (@{$opt{target}}) > 1) ) { + if ((exists($opt{full})) && (scalar(@{ $opt{target} }) > 1)) { my $lparparent; - my $ppctab = xCAT::Table->new('ppc'); - foreach my $vnode (@{$opt{target}}) { - my $vcon = $ppctab->getNodeAttribs( $vnode, ('node','parent')); + my $ppctab = xCAT::Table->new('ppc'); + foreach my $vnode (@{ $opt{target} }) { + my $vcon = $ppctab->getNodeAttribs($vnode, ('node', 'parent')); if ($vcon and $vcon->{"node"} and $vcon->{"parent"}) { my $lparent = $vcon->{"parent"}; $lparparent->{$lparent}->{$vnode} = $vnode; @@ -275,59 +275,59 @@ sub mkvm_parse_args { } $ppctab->close; - my $cbmsg = "mkvm: multiple LPAR nodes which belong to the same CEC have been defined.\n"; - my $sameflag = 0; - foreach my $iparent (keys %$lparparent) { - if (scalar (keys %{$lparparent->{$iparent}}) > 1) { - $sameflag = 1; - $cbmsg = $cbmsg . $iparent . ":" . "\t"; - foreach my $inode (keys %{$lparparent->{$iparent}}) { - $cbmsg = $cbmsg . $inode . ","; - } - } - + my $cbmsg = "mkvm: multiple LPAR nodes which belong to the same CEC have been defined.\n"; + my $sameflag = 0; + foreach my $iparent (keys %$lparparent) { + if (scalar(keys %{ $lparparent->{$iparent} }) > 1) { + $sameflag = 1; + $cbmsg = $cbmsg . $iparent . ":" . "\t"; + foreach my $inode (keys %{ $lparparent->{$iparent} }) { + $cbmsg = $cbmsg . $inode . ","; + } + } + $cbmsg =~ s/,$/ /; $cbmsg = $cbmsg . "\n"; - } - if ($sameflag) { - return(usage( $cbmsg )); } - } + if ($sameflag) { + return (usage($cbmsg)); + } + } #################################### # Read and check profile #################################### - if ( exists( $opt{p})) { - $opt{p} = $request->{cwd}->[0] . '/' . $opt{p} if ( $opt{p} !~ /^\//); - return ( usage( "Profile $opt{p} cannot be found")) if ( ! -f $opt{p}); - open (PROFFILE, "<$opt{p}") or return ( usage( "Cannot open profile $opt{p}")); + if (exists($opt{p})) { + $opt{p} = $request->{cwd}->[0] . '/' . $opt{p} if ($opt{p} !~ /^\//); + return (usage("Profile $opt{p} cannot be found")) if (!-f $opt{p}); + open(PROFFILE, "<$opt{p}") or return (usage("Cannot open profile $opt{p}")); my @cfgdata = (); - while( ) + while () { chomp; /\w+/ or next; - if ( /name=/ and /lpar_name/ and /lpar_id/ and /lpar_env/) + if (/name=/ and /lpar_name/ and /lpar_id/ and /lpar_env/) { push @cfgdata, $_; } else { s/^[^,]*:\s*(name=.*)$/$1/; - return ( usage( "Invalid line in profile: $_")); + return (usage("Invalid line in profile: $_")); } } - return ( usage( "No valid line was found in profile $opt{p}.")) if ( scalar( @cfgdata) < 1); + return (usage("No valid line was found in profile $opt{p}.")) if (scalar(@cfgdata) < 1); - my @lpars = @{$opt{target}}; - my $min_lpar_num = scalar( @cfgdata); - if ( scalar(@cfgdata) > scalar( @lpars)) + my @lpars = @{ $opt{target} }; + my $min_lpar_num = scalar(@cfgdata); + if (scalar(@cfgdata) > scalar(@lpars)) { xCAT::MsgUtils->message('W', "Warning: Lpar configuration number in profile is greater than lpars in command line. Only first " . scalar(@lpars) . " lpars will be created.\n"); - $min_lpar_num = scalar( @lpars); + $min_lpar_num = scalar(@lpars); } - elsif ( scalar(@cfgdata) < scalar( @lpars)) + elsif (scalar(@cfgdata) < scalar(@lpars)) { - my $lparlist = join ",", @lpars[0..($min_lpar_num-1)]; + my $lparlist = join ",", @lpars[ 0 .. ($min_lpar_num - 1) ]; xCAT::MsgUtils->message('W', "Warning: Lpar number in command line is greater than lpar configuration number in profile. Only lpars " . $lparlist . " will be created.\n"); } @@ -335,10 +335,10 @@ sub mkvm_parse_args { } #################################### - # No operands - add command name + # No operands - add command name #################################### $request->{method} = $cmd; - return( \%opt ); + return (\%opt); } @@ -356,46 +356,46 @@ sub rmvm_parse_args { ############################################# # Responds with usage statement ############################################# - local *usage = sub { + local *usage = sub { my $usage_string = xCAT::Usage->getUsage($cmd); - return( [ $_[0], $usage_string] ); + return ([ $_[0], $usage_string ]); }; ############################################# # Process command-line arguments ############################################# - if ( !defined( $args )) { + if (!defined($args)) { $request->{method} = $cmd; - return( \%opt ); + return (\%opt); } ############################################# # Checks case in GetOptions, allows opts # to be grouped (e.g. -vx), and terminates # at the first unrecognized option. ############################################# - @ARGV = @$args; + @ARGV = @$args; $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); + Getopt::Long::Configure("bundling"); - if ( !GetOptions( \%opt, qw(V|verbose service r) )) { - return( usage() ); + if (!GetOptions(\%opt, qw(V|verbose service r))) { + return (usage()); } #################################### # Check for "-" with no option #################################### - if ( grep(/^-$/, @ARGV )) { - return(usage( "Missing option: -" )); + if (grep(/^-$/, @ARGV)) { + return (usage("Missing option: -")); } #################################### # Check for an extra argument #################################### - if ( defined( $ARGV[0] )) { - return(usage( "Invalid Argument: $ARGV[0]" )); + if (defined($ARGV[0])) { + return (usage("Invalid Argument: $ARGV[0]")); } #################################### - # No operands - add command name + # No operands - add command name #################################### - $request->{method} = $cmd; - return( \%opt ); + $request->{method} = $cmd; + return (\%opt); } @@ -414,90 +414,90 @@ sub lsvm_parse_args { ############################################# local *usage = sub { my $usage_string = xCAT::Usage->getUsage($cmd); - return( [ $_[0], $usage_string] ); + return ([ $_[0], $usage_string ]); }; ############################################# # Process command-line arguments ############################################# - if ( !defined( $args )) { + if (!defined($args)) { $request->{method} = $cmd; - return( \%opt ); + return (\%opt); } ############################################# # Checks case in GetOptions, allows opts # to be grouped (e.g. -vx), and terminates # at the first unrecognized option. ############################################# - @ARGV = @$args; + @ARGV = @$args; $Getopt::Long::ignorecase = 0; - Getopt::Long::Configure( "bundling" ); + Getopt::Long::Configure("bundling"); - if ( !GetOptions( \%opt, qw(V|verbose a|all) )) { - return( usage() ); + if (!GetOptions(\%opt, qw(V|verbose a|all))) { + return (usage()); } #################################### # Check for "-" with no option #################################### - if ( grep(/^-$/, @ARGV )) { - return(usage( "Missing option: -" )); + if (grep(/^-$/, @ARGV)) { + return (usage("Missing option: -")); } #################################### # Check for an extra argument #################################### - if ( defined( $ARGV[0] )) { - return(usage( "Invalid Argument: $ARGV[0]" )); + if (defined($ARGV[0])) { + return (usage("Invalid Argument: $ARGV[0]")); } #################################### - # No operands - add command name + # No operands - add command name #################################### - $request->{method} = $cmd; - return( \%opt ); + $request->{method} = $cmd; + return (\%opt); } ########################################################################## -# Clones all the LPARs from one CEC to another (must be on same HMC) +# Clones all the LPARs from one CEC to another (must be on same HMC) ########################################################################## sub clone { - my $request = shift; - my $exp = shift; - my $targets = shift; - my $profile = shift; - my $destd = shift; - my $destname= shift; - my $hwtype = @$exp[2]; - my $server = @$exp[3]; - my @values = (); - my @lpars = @$targets; + my $request = shift; + my $exp = shift; + my $targets = shift; + my $profile = shift; + my $destd = shift; + my $destname = shift; + my $hwtype = @$exp[2]; + my $server = @$exp[3]; + my @values = (); + my @lpars = @$targets; my $destcec; - my $opt = $request->{opt}; + my $opt = $request->{opt}; - ##################################### - # Always one source CEC specified - ##################################### + ##################################### + # Always one source CEC specified + ##################################### my $lparid = @$destd[0]; my $mtms = @$destd[2]; my $type = @$destd[4]; ##################################### - # Not supported on IVM + # Not supported on IVM ##################################### - if ( $hwtype eq "ivm" ) { - return( [[RC_ERROR,"Not supported for IVM"]] ); + if ($hwtype eq "ivm") { + return ([ [ RC_ERROR, "Not supported for IVM" ] ]); } ##################################### - # Source must be CEC + # Source must be CEC ##################################### #if ( $type ne "fsp" ) { - unless ( $type =~ /^(cec|fsp)$/) { - return( [[RC_ERROR,"Node must be an FSP"]] ); + unless ($type =~ /^(cec|fsp)$/) { + return ([ [ RC_ERROR, "Node must be an FSP" ] ]); } ##################################### # Attributes not found ##################################### - if ( !$mtms) { - return( [[RC_ERROR,"Cannot found serial and mtm for $destname"]] ); + if (!$mtms) { + return ([ [ RC_ERROR, "Cannot found serial and mtm for $destname" ] ]); } ##################################### @@ -505,53 +505,53 @@ sub clone { ##################################### my $filter = "type_model,serial_num"; xCAT::MsgUtils->verbose_message($request, "$request->{command} :lssyscfg fsps.filter:'$filter'."); - my $cecs = xCAT::PPCcli::lssyscfg( $exp, "fsps", $filter ); + my $cecs = xCAT::PPCcli::lssyscfg($exp, "fsps", $filter); my $Rc = shift(@$cecs); ##################################### # Return error ##################################### - if ( $Rc != SUCCESS ) { - return( [[$Rc, @$cecs[0]]] ); + if ($Rc != SUCCESS) { + return ([ [ $Rc, @$cecs[0] ] ]); } ##################################### # Get HCA info ##################################### - my $unassigned_iba = undef; + my $unassigned_iba = undef; my $iba_replace_pair = undef; - if ( exists $opt->{ibautocfg}) + if (exists $opt->{ibautocfg}) { - $unassigned_iba = get_unassigned_iba( $exp, $mtms, $opt->{ibacap}); + $unassigned_iba = get_unassigned_iba($exp, $mtms, $opt->{ibacap}); } else { - $unassigned_iba = get_unassigned_iba( $exp, $mtms, undef); - $iba_replace_pair = get_iba_replace_pair( $unassigned_iba, $profile); + $unassigned_iba = get_unassigned_iba($exp, $mtms, undef); + $iba_replace_pair = get_iba_replace_pair($unassigned_iba, $profile); } ##################################### - # Find source/dest CEC + # Find source/dest CEC ##################################### - foreach ( @$cecs ) { + foreach (@$cecs) { s/(.*),(.*)/$1*$2/; - if ( $_ eq $mtms ) { + if ($_ eq $mtms) { $destcec = $_; } } ##################################### # Destination CEC not found ##################################### - if ( !defined( $destcec )) { - return([[RC_ERROR,"Destination CEC '$destname' not found on '$server'"]]); + if (!defined($destcec)) { + return ([ [ RC_ERROR, "Destination CEC '$destname' not found on '$server'" ] ]); } ##################################### # Modify read back profile ##################################### - my $min_lpar_num = scalar(@$profile) < scalar(@$targets) ? scalar(@$profile) : scalar(@$targets) ; + my $min_lpar_num = scalar(@$profile) < scalar(@$targets) ? scalar(@$profile) : scalar(@$targets); my $i; - for ($i = 0; $i < $min_lpar_num; $i++) + for ($i = 0 ; $i < $min_lpar_num ; $i++) { my $cfg = $profile->[$i]; $cfg =~ s/^[^,]*:\s*(name=.*)$/$1/; @@ -560,20 +560,20 @@ sub clone { $cfg =~ s/\blpar_name=([^,]+|$)/name=$targets->[$i]/; - $cfg = strip_profile( $cfg, $hwtype); + $cfg = strip_profile($cfg, $hwtype); $cfg =~ /lpar_id=([^,]+)/; $lparid = $1; if (exists $opt->{ibautocfg}) { - $cfg = hcaautoconf( $cfg, $unassigned_iba); - } + $cfg = hcaautoconf($cfg, $unassigned_iba); + } else { - $cfg = hcasubst( $cfg, $iba_replace_pair); + $cfg = hcasubst($cfg, $iba_replace_pair); } ################################# - # Create new LPAR + # Create new LPAR ################################# my @temp = @$destd; $temp[0] = $lparid; @@ -581,155 +581,155 @@ sub clone { $temp[4] = 'lpar'; xCAT::MsgUtils->verbose_message($request, "$request->{command} :mksyscfg lpar.cfg:'$cfg'."); - my $result = xCAT::PPCcli::mksyscfg( $exp, "lpar", \@temp, $cfg ); + my $result = xCAT::PPCcli::mksyscfg($exp, "lpar", \@temp, $cfg); $Rc = shift(@$result); ################################# - # Success - add LPAR to database + # Success - add LPAR to database ################################# - if ( $Rc == SUCCESS ) { - my $err = xCATdB( - "mkvm", $targets->[$i], $profile, $lparid, $destd, $hwtype, $targets->[$i], $destname ); + if ($Rc == SUCCESS) { + my $err = xCATdB( +"mkvm", $targets->[$i], $profile, $lparid, $destd, $hwtype, $targets->[$i], $destname); - if ( defined( $err )) { - push @values, [$err, RC_ERROR]; + if (defined($err)) { + push @values, [ $err, RC_ERROR ]; } next; } ################################# - # Error - Save error + # Error - Save error ################################# - push @values, [@$result[0], $Rc]; + push @values, [ @$result[0], $Rc ]; } - if ( !scalar(@values) ) { - return( [[SUCCESS,"Success"]]); - } - return( \@values ); + if (!scalar(@values)) { + return ([ [ SUCCESS, "Success" ] ]); + } + return (\@values); } - ########################################################################## - # Removes logical partitions - ########################################################################## +########################################################################## +# Removes logical partitions +########################################################################## sub remove { - + my $request = shift; my $hash = shift; my $exp = shift; my $opt = $request->{opt}; my @lpars = (); my @values = (); - + xCAT::MsgUtils->verbose_message($request, "$request->{command} START."); - while (my ($mtms,$h) = each(%$hash) ) { - while (my ($lpar,$d) = each(%$h) ) { + while (my ($mtms, $h) = each(%$hash)) { + while (my ($lpar, $d) = each(%$h)) { my $lparid = @$d[0]; my $mtms = @$d[2]; my $type = @$d[4]; #################################### # Must be CEC or LPAR #################################### - if ( $type !~ /^(lpar|fsp|cec)$/ ) { - push @values, [$lpar, "Node must be LPAR or CEC", RC_ERROR]; + if ($type !~ /^(lpar|fsp|cec)$/) { + push @values, [ $lpar, "Node must be LPAR or CEC", RC_ERROR ]; next; - } + } #################################### # This is a single LPAR #################################### - if ( $type eq "lpar" ) { + if ($type eq "lpar") { $lpars[0] = "$lpar,$lparid"; } #################################### - # This is a CEC - remove all LPARs + # This is a CEC - remove all LPARs #################################### else { my $filter = "name,lpar_id"; xCAT::MsgUtils->verbose_message($request, "$request->{command} :lssyscfg lpar.filter:'$filter'."); - my $result = xCAT::PPCcli::lssyscfg( - $exp, - "lpar", - $mtms, - $filter ); + my $result = xCAT::PPCcli::lssyscfg( + $exp, + "lpar", + $mtms, + $filter); my $Rc = shift(@$result); ################################ # Expect error ################################ - if ( $Rc != SUCCESS ) { - push @values, [$lpar, @$result[0], $Rc]; + if ($Rc != SUCCESS) { + push @values, [ $lpar, @$result[0], $Rc ]; next; } ################################ - # Success - save LPARs + # Success - save LPARs ################################ - foreach ( @$result ) { - push @lpars, $_; + foreach (@$result) { + push @lpars, $_; } } #################################### # Remove the LPARs #################################### - foreach ( @lpars ) { - my $lparinfo = $_; # shift(@lpars); - my ($name,$id) = split /,/, $lparinfo; + foreach (@lpars) { + my $lparinfo = $_; # shift(@lpars); + my ($name, $id) = split /,/, $lparinfo; my $mtms = @$d[2]; - + if ($opt->{service}) { ############################################### # begin to retrieve the CEC's service lpar id - ############################################### + ############################################### xCAT::MsgUtils->verbose_message($request, "$request->{command} :lssyscfg fsp.filter:'service_lpar_id'."); my $service_lparid = xCAT::PPCcli::lssyscfg( - $exp, - "fsp", - $mtms, - "service_lpar_id" ); + $exp, + "fsp", + $mtms, + "service_lpar_id"); my $Rc = shift(@$service_lparid); - + ##################################################### # Change the CEC's state to standby and set it's service lpar id to none ##################################################### - if ( $Rc == SUCCESS ) { + if ($Rc == SUCCESS) { my $cfgdata = @$service_lparid[0]; - if ( ($id == $cfgdata) && ($cfgdata !~ /none/) ) { - $cfgdata = "service_lpar_id=none"; - xCAT::MsgUtils->verbose_message($request, "$request->{command} :lssyscfg fsp.filter:'$cfgdata'."); - my $result = xCAT::PPCcli::chsyscfg( $exp, "fsp", $d, $cfgdata ); - $Rc = shift(@$result); - if ( $Rc != SUCCESS ) { - return( [[$lpar, @$service_lparid[0], $Rc]] ); - } + if (($id == $cfgdata) && ($cfgdata !~ /none/)) { + $cfgdata = "service_lpar_id=none"; + xCAT::MsgUtils->verbose_message($request, "$request->{command} :lssyscfg fsp.filter:'$cfgdata'."); + my $result = xCAT::PPCcli::chsyscfg($exp, "fsp", $d, $cfgdata); + $Rc = shift(@$result); + if ($Rc != SUCCESS) { + return ([ [ $lpar, @$service_lparid[0], $Rc ] ]); } + } } } - - ################################ - # id profile mtms hcp type frame - ################################ - my @d = ( $id,0,$mtms,0,"lpar",0 ); + ################################ - # Send remove command + # id profile mtms hcp type frame + ################################ + my @d = ($id, 0, $mtms, 0, "lpar", 0); + ################################ + # Send remove command ################################ xCAT::MsgUtils->verbose_message($request, "$request->{command} :rmsyscfg lpar.id:$id."); - my $result = xCAT::PPCcli::rmsyscfg( $exp, \@d ); + my $result = xCAT::PPCcli::rmsyscfg($exp, \@d); my $Rc = shift(@$result); ################################ - # Remove LPAR from database + # Remove LPAR from database ################################ - if ( $Rc == SUCCESS and !exists( $opt->{r} ) ) { + if ($Rc == SUCCESS and !exists($opt->{r})) { xCAT::MsgUtils->verbose_message($request, "$request->{command} :remove lpar:$name from xCATdb."); - my $err = xCATdB( "rmvm", $name,"", $id,"", $type,"" , $lpar ); - if ( defined( $err )) { - push @values, [$lpar,$err,RC_ERROR]; + my $err = xCATdB("rmvm", $name, "", $id, "", $type, "", $lpar); + if (defined($err)) { + push @values, [ $lpar, $err, RC_ERROR ]; next; } } - push @values, [$lpar,@$result[0],$Rc]; + push @values, [ $lpar, @$result[0], $Rc ]; } } } xCAT::MsgUtils->verbose_message($request, "$request->{command} END."); - return( \@values ); + return (\@values); } @@ -738,56 +738,56 @@ sub remove { ########################################################################## sub getprofile { - my $exp = shift; + my $exp = shift; my $name = shift; ############################### # Get all CECs ############################### - my $cecs = xCAT::PPCcli::lssyscfg( $exp, "fsps", "name" ); + my $cecs = xCAT::PPCcli::lssyscfg($exp, "fsps", "name"); ############################### # Return error ############################### - if ( @$cecs[0] != NR_ERROR ) { - if ( @$cecs[0] != SUCCESS ) { - return( $cecs ); + if (@$cecs[0] != NR_ERROR) { + if (@$cecs[0] != SUCCESS) { + return ($cecs); } my $Rc = shift(@$cecs); ########################### - # List profiles for CECs + # List profiles for CECs ########################### - foreach my $mtms ( @$cecs ) { + foreach my $mtms (@$cecs) { my $prof = xCAT::PPCcli::lssyscfg( - $exp, - "prof", - $mtms, - "profile_names=$name" ); + $exp, + "prof", + $mtms, + "profile_names=$name"); my $Rc = shift(@$prof); - if ( $Rc == SUCCESS ) { - return( [SUCCESS,$mtms,@$prof[0]] ); + if ($Rc == SUCCESS) { + return ([ SUCCESS, $mtms, @$prof[0] ]); } } } - return( [RC_ERROR,"The partition profile named '$name' was not found"] ); + return ([ RC_ERROR, "The partition profile named '$name' was not found" ]); } ########################################################################## -# Changes the configuration of an existing partition +# Changes the configuration of an existing partition ########################################################################## sub modify { my $request = shift; my $hash = shift; my $exp = shift; - return modify_by_prof( $request, $hash, $exp) if ( $request->{opt}->{p}); - return modify_by_attr( $request, $hash, $exp); + return modify_by_prof($request, $hash, $exp) if ($request->{opt}->{p}); + return modify_by_attr($request, $hash, $exp); } ########################################################################## -# Changes the configuration of an existing +# Changes the configuration of an existing # partition based on the attributes specified ########################################################################## sub modify_by_attr { @@ -795,18 +795,19 @@ sub modify_by_attr { my $hash = shift; my $exp = shift; my $hwtype = @$exp[2]; - my $name = @{$request->{node}}[0]; + my $name = @{ $request->{node} }[0]; my $opt = $request->{opt}; - my $attrstr= $opt->{a}; + my $attrstr = $opt->{a}; my @values; xCAT::MsgUtils->verbose_message($request, "$request->{command} START."); + # attrstr will be in stdin for "cat vmdef | chvm nodename" if (!defined($attrstr) && defined($request->{stdin})) { my $tempattr = $request->{stdin}; $tempattr =~ s/\s+$//; $tempattr =~ s/^[\w]+: //; - my $newcfg = strip_profile( $tempattr, $hwtype ); + my $newcfg = strip_profile($tempattr, $hwtype); $newcfg =~ s/,*lpar_env=[^,]+|$//; $newcfg =~ s/,*all_resources=[^,]+|$//; $newcfg =~ s/,*lpar_name=[^,]+|$//; @@ -817,9 +818,9 @@ sub modify_by_attr { ########################################## my @newcfgarray; my $full_line; - while (my $line = shift( @cfgarray)) + while (my $line = shift(@cfgarray)) { - if ( !$full_line) + if (!$full_line) { $full_line = $line; } @@ -827,7 +828,7 @@ sub modify_by_attr { { $full_line = "$full_line,$line"; } - if ( $full_line =~ /^[^\"]/ or $full_line =~ /^\".+\"$/) + if ($full_line =~ /^[^\"]/ or $full_line =~ /^\".+\"$/) { $full_line =~ s/^\"(.+)\"$/$1/; push @newcfgarray, $full_line; @@ -837,78 +838,78 @@ sub modify_by_attr { } $attrstr = \@newcfgarray; } - if ( defined( $attrstr )) { + if (defined($attrstr)) { ################################### - # Get LPAR active profiles + # Get LPAR active profiles ################################### - while (my ($cec,$h) = each(%$hash) ) { - while (my ($lpar,$d) = each(%$h) ) { + while (my ($cec, $h) = each(%$hash)) { + while (my ($lpar, $d) = each(%$h)) { ########################### # Get current profile ########################### xCAT::MsgUtils->verbose_message($request, "$request->{command} :lssyscfg node.id:'@$d[0]'."); my $cfg_res = xCAT::PPCcli::lssyscfg( - $exp, - "node", - $cec, - 'curr_profile', - @$d[0]); + $exp, + "node", + $cec, + 'curr_profile', + @$d[0]); my $Rc = shift(@$cfg_res); - if ( $Rc != SUCCESS ) { - push @values, [$lpar, @$cfg_res[0], $Rc]; + if ($Rc != SUCCESS) { + push @values, [ $lpar, @$cfg_res[0], $Rc ]; next; } ############################################## # If there is no curr_profile, which means no - # profile has been applied yet (before first + # profile has been applied yet (before first # boot?), use the default_profile ############################################## - if ( (!@$cfg_res[0]) || (@$cfg_res[0] =~ /^none$/) ) + if ((!@$cfg_res[0]) || (@$cfg_res[0] =~ /^none$/)) { $cfg_res = xCAT::PPCcli::lssyscfg( - $exp, - "node", - $cec, - 'default_profile', - @$d[0]); + $exp, + "node", + $cec, + 'default_profile', + @$d[0]); $Rc = shift(@$cfg_res); - if ( $Rc != SUCCESS ) { - push @values, [$lpar, @$cfg_res[0], $Rc]; + if ($Rc != SUCCESS) { + push @values, [ $lpar, @$cfg_res[0], $Rc ]; next; } } - xCAT::MsgUtils->verbose_message($request, "$request->{command} :lssyscfg prof.filter:'lpar_ids=@$d[0],profile_names=@$cfg_res[0]'."); + xCAT::MsgUtils->verbose_message($request, "$request->{command} :lssyscfg prof.filter:'lpar_ids=@$d[0],profile_names=@$cfg_res[0]'."); my $prof = xCAT::PPCcli::lssyscfg( - $exp, - "prof", - $cec, - "lpar_ids=@$d[0],profile_names=@$cfg_res[0]" ); + $exp, + "prof", + $cec, + "lpar_ids=@$d[0],profile_names=@$cfg_res[0]"); $Rc = shift(@$prof); - if ( $Rc != SUCCESS ) { - push @values, [$lpar, @$prof[0], $Rc]; + if ($Rc != SUCCESS) { + push @values, [ $lpar, @$prof[0], $Rc ]; next; } my $cfgdata = @$prof[0]; ########################### # Modify profile ########################### - $cfgdata = strip_profile( $cfgdata, $hwtype ); + $cfgdata = strip_profile($cfgdata, $hwtype); $cfgdata =~ s/,*lpar_env=[^,]+|$//; $cfgdata =~ s/,*all_resources=[^,]+|$//; $cfgdata =~ s/,*lpar_name=[^,]+|$//; my $err_msg; - ($Rc, $err_msg, $cfgdata) = subst_profile( $cfgdata, $attrstr); - if ( $Rc != SUCCESS ) { - push @values, [$lpar, $err_msg, $Rc]; + ($Rc, $err_msg, $cfgdata) = subst_profile($cfgdata, $attrstr); + if ($Rc != SUCCESS) { + push @values, [ $lpar, $err_msg, $Rc ]; next; } xCAT::MsgUtils->verbose_message($request, "$request->{command} :chsyscfg prof.cfg:'$cfgdata'."); - my $result = xCAT::PPCcli::chsyscfg( $exp, "prof", $d, $cfgdata ); + my $result = xCAT::PPCcli::chsyscfg($exp, "prof", $d, $cfgdata); $Rc = shift(@$result); - push @values, [$lpar,@$result[0],$Rc]; + push @values, [ $lpar, @$result[0], $Rc ]; } } } @@ -921,7 +922,7 @@ sub modify_by_attr { ########################################################################## sub subst_profile { - my $cfgdata = shift; + my $cfgdata = shift; my $attrlist = shift; $cfgdata =~ s/\\\"/\"/g; @@ -931,9 +932,9 @@ sub subst_profile ########################################## my @newcfgarray; my $full_line; - while (my $line = shift( @cfgarray)) + while (my $line = shift(@cfgarray)) { - if ( !$full_line) + if (!$full_line) { $full_line = $line; } @@ -941,7 +942,7 @@ sub subst_profile { $full_line = "$full_line,$line"; } - if ( $full_line =~ /^[^\"]/ or $full_line =~ /^\".+\"$/) + if ($full_line =~ /^[^\"]/ or $full_line =~ /^\".+\"$/) { $full_line =~ s/^\"(.+)\"$/$1/; push @newcfgarray, $full_line; @@ -955,36 +956,37 @@ sub subst_profile ########################################## my @final_array; my @attrs = @$attrlist; - for my $cfgline ( @newcfgarray) + for my $cfgline (@newcfgarray) { - for ( my $i = 0; $i < scalar(@attrs); $i++ ) + for (my $i = 0 ; $i < scalar(@attrs) ; $i++) { my $av_pair = $attrs[$i]; - next if ( !$av_pair); + next if (!$av_pair); + #assuming there will not be too many attributes to be changed - my ($attr,$value) = $av_pair =~ /^\s*(\S+?)\s*=\s*(\S+)\s*$/; - if ( $cfgline =~ /^$attr=/) + my ($attr, $value) = $av_pair =~ /^\s*(\S+?)\s*=\s*(\S+)\s*$/; + if ($cfgline =~ /^$attr=/) { - if ( $cfgline =~ /lhea_logical_ports/) + if ($cfgline =~ /lhea_logical_ports/) { $cfgline = "$attr=\\\"\\\"$value\\\"\\\""; - } else + } else { $cfgline = "$attr=$value"; } - + delete $attrs[$i]; last; } - + } - if ( $cfgline =~ /,/) + if ($cfgline =~ /,/) { $cfgline = "\\\"$cfgline\\\""; } push @final_array, $cfgline; } - $cfgdata = join ',',@final_array; + $cfgdata = join ',', @final_array; ########################################## # Get not found attribute list @@ -992,7 +994,7 @@ sub subst_profile my %not_found = (); for (@attrs) { - if ( $_) + if ($_) { my ($a) = split /=/; $not_found{$a} = 1; @@ -1004,7 +1006,7 @@ sub subst_profile } ########################################################################## -# Changes the configuration of an existing +# Changes the configuration of an existing # partition based on the profile specified ########################################################################## sub modify_by_prof { @@ -1012,9 +1014,9 @@ sub modify_by_prof { my $hash = shift; my $exp = shift; my $hwtype = @$exp[2]; - my $name = @{$request->{node}}[0]; + my $name = @{ $request->{node} }[0]; my $opt = $request->{opt}; - my $cfgdata = $request->{stdin}; + my $cfgdata = $request->{stdin}; my $profile = $opt->{p}; my @values; @@ -1022,43 +1024,43 @@ sub modify_by_prof { ####################################### # -p flag, find profile specified ####################################### - if ( defined( $profile )) { - my $prof = getprofile( $exp, $profile ); + if (defined($profile)) { + my $prof = getprofile($exp, $profile); ################################### # Return error ################################### my $Rc = shift(@$prof); - if ( $Rc != SUCCESS ) { - return( [[$name,@$prof,RC_ERROR]] ); + if ($Rc != SUCCESS) { + return ([ [ $name, @$prof, RC_ERROR ] ]); } $cfgdata = @$prof[1]; my $mtms = @$prof[0]; ################################### - # Check if LPAR profile exists + # Check if LPAR profile exists ################################### - while (my ($cec,$h) = each(%$hash) ) { - while (my ($lpar,$d) = each(%$h) ) { + while (my ($cec, $h) = each(%$hash)) { + while (my ($lpar, $d) = each(%$h)) { ########################### - # Get LPAR profiles + # Get LPAR profiles ########################### xCAT::MsgUtils->verbose_message($request, "$request->{command} :lssyscfg prof.filter:'lpar_ids=@$d[0],profile_names=$profile'."); my $prof = xCAT::PPCcli::lssyscfg( - $exp, - "prof", - $cec, - "lpar_ids=@$d[0],profile_names=$profile" ); + $exp, + "prof", + $cec, + "lpar_ids=@$d[0],profile_names=$profile"); my $Rc = shift(@$prof); ########################### - # Already has that profile + # Already has that profile ########################### - if ( $Rc == SUCCESS ) { - push @values, [$lpar,"Success",$Rc]; - xCATdB( "chvm", $lpar, $profile ); - delete $h->{$lpar}; + if ($Rc == SUCCESS) { + push @values, [ $lpar, "Success", $Rc ]; + xCATdB("chvm", $lpar, $profile); + delete $h->{$lpar}; } } } @@ -1067,14 +1069,14 @@ sub modify_by_prof { # Remove "node: " in case the # configuration file was created as # the result of an "lsvm" command. - # "lpar9: name=lpar9, lpar_name=..." + # "lpar9: name=lpar9, lpar_name=..." ####################################### $cfgdata =~ s/^[\w]+: //; - if ( $cfgdata !~ /^name=/ ) { + if ($cfgdata !~ /^name=/) { my $text = "Invalid file format: must begin with 'name='"; - return( [[$name,$text,RC_ERROR]] ); + return ([ [ $name, $text, RC_ERROR ] ]); } - my $cfg = strip_profile( $cfgdata, $hwtype ); + my $cfg = strip_profile($cfgdata, $hwtype); $cfg =~ s/,*lpar_env=[^,]+|$//; $cfg =~ s/,*all_resources=[^,]+|$//; $cfg =~ s/,*lpar_name=[^,]+|$//; @@ -1082,62 +1084,62 @@ sub modify_by_prof { ####################################### # Send change profile command ####################################### - while (my ($cec,$h) = each(%$hash) ) { - while (my ($lpar,$d) = each(%$h) ) { - + while (my ($cec, $h) = each(%$hash)) { + while (my ($lpar, $d) = each(%$h)) { + ############################### - # Only valid for LPARs + # Only valid for LPARs ############################### - if ( @$d[4] ne "lpar" ) { - push @values, [$lpar,"Command not supported on '@$d[4]'",RC_ERROR]; + if (@$d[4] ne "lpar") { + push @values, [ $lpar, "Command not supported on '@$d[4]'", RC_ERROR ]; next; } ############################### - # Change LPAR Id + # Change LPAR Id ############################### - $cfg =~ s/lpar_id=[^,]+/lpar_id=@$d[0]/; + $cfg =~ s/lpar_id=[^,]+/lpar_id=@$d[0]/; ################################# # Modify SCSI/LHEA adapters ################################# - if ( exists( $opt->{p} )) { - if ( $cfg =~ /virtual_scsi_adapters=(\w+)/ ) { - if ( $1 !~ /^none$/i ) { - $cfg = scsi_adapter( $cfg ); + if (exists($opt->{p})) { + if ($cfg =~ /virtual_scsi_adapters=(\w+)/) { + if ($1 !~ /^none$/i) { + $cfg = scsi_adapter($cfg); } } - if ( $cfg =~ /lhea_logical_ports=(\w+)/ ) { - if ( $1 !~ /^none$/i ) { - $cfg = lhea_adapter( $cfg ); + if ($cfg =~ /lhea_logical_ports=(\w+)/) { + if ($1 !~ /^none$/i) { + $cfg = lhea_adapter($cfg); } } } ############################### - # Send command + # Send command ############################### - if ( defined( $profile )) { - xCAT::MsgUtils->verbose_message($request, "$request->{command} :mksyscfg prof.cfg:'$cfg'."); - my $result = xCAT::PPCcli::mksyscfg( $exp, "prof", $d, $cfg ); - my $Rc = shift(@$result); + if (defined($profile)) { + xCAT::MsgUtils->verbose_message($request, "$request->{command} :mksyscfg prof.cfg:'$cfg'."); + my $result = xCAT::PPCcli::mksyscfg($exp, "prof", $d, $cfg); + my $Rc = shift(@$result); - ############################ - # Update database - ############################ - if ( $Rc == SUCCESS ) { - xCATdB( "chvm", $lpar, $profile ); - } - push @values, [$lpar,@$result[0],$Rc]; + ############################ + # Update database + ############################ + if ($Rc == SUCCESS) { + xCATdB("chvm", $lpar, $profile); + } + push @values, [ $lpar, @$result[0], $Rc ]; } else { - xCAT::MsgUtils->verbose_message($request, "$request->{command} :chsyscfg prof.cfg:'$cfg'."); - my $result = xCAT::PPCcli::chsyscfg( $exp, "prof", $d, $cfg ); - my $Rc = shift(@$result); - push @values, [$lpar,@$result[0],$Rc]; + xCAT::MsgUtils->verbose_message($request, "$request->{command} :chsyscfg prof.cfg:'$cfg'."); + my $result = xCAT::PPCcli::chsyscfg($exp, "prof", $d, $cfg); + my $Rc = shift(@$result); + push @values, [ $lpar, @$result[0], $Rc ]; } } } xCAT::MsgUtils->verbose_message($request, "$request->{command} END."); - return( \@values ); + return (\@values); } @@ -1156,8 +1158,8 @@ sub list { my $result; xCAT::MsgUtils->verbose_message($request, "$request->{command} START."); - while (my ($mtms,$h) = each(%$hash) ) { - while (my ($lpar,$d) = each(%$h) ) { + while (my ($mtms, $h) = each(%$hash)) { + while (my ($lpar, $d) = each(%$h)) { my $lparid = @$d[0]; my $mtms = @$d[2]; my $type = @$d[4]; @@ -1166,14 +1168,14 @@ sub list { #################################### # Must be CEC or LPAR #################################### - if ( $type !~ /^(lpar|fsp|cec)$/ ) { - $values->{$lpar} = [$lpar,"Node must be LPAR or CEC",RC_ERROR]; + if ($type !~ /^(lpar|fsp|cec)$/) { + $values->{$lpar} = [ $lpar, "Node must be LPAR or CEC", RC_ERROR ]; next; } #################################### # This is a single LPAR #################################### - if ( $type eq "lpar" ) { + if ($type eq "lpar") { $lpars[0] = "$lpar,$lparid"; } #################################### @@ -1183,48 +1185,48 @@ sub list { my $filter = "name,lpar_id"; xCAT::MsgUtils->verbose_message($request, "$request->{command} :lssyscfg lpar.filter:'$filter'."); my $result = xCAT::PPCcli::lssyscfg( - $exp, - "lpar", - $mtms, - $filter ); + $exp, + "lpar", + $mtms, + $filter); my $Rc = shift(@$result); ################################ # Expect error ################################ - if ( $Rc != SUCCESS ) { - $values->{$lpar} = [$lpar,@$result[0], $Rc]; + if ($Rc != SUCCESS) { + $values->{$lpar} = [ $lpar, @$result[0], $Rc ]; next; } ################################ # Success - save LPARs ################################ - foreach ( @$result ) { + foreach (@$result) { push @lpars, $_; } } #################################### - # Get LPAR profile + # Get LPAR profile #################################### - foreach ( sort @lpars ) { - my ($name,$id) = split /,/; - + foreach (sort @lpars) { + my ($name, $id) = split /,/; + ################################# # Get source LPAR profile ################################# xCAT::MsgUtils->verbose_message($request, "$request->{command} :lssyscfg prof.filter:'lpar_ids=$id'."); my $prof = xCAT::PPCcli::lssyscfg( - $exp, - "prof", - $mtms, - "lpar_ids=$id" ); + $exp, + "prof", + $mtms, + "lpar_ids=$id"); my $Rc = shift(@$prof); ################################# # Return error ################################# - if ( $Rc != SUCCESS ) { - $values->{$lpar} = [$lpar,@$prof[0], $Rc]; + if ($Rc != SUCCESS) { + $values->{$lpar} = [ $lpar, @$prof[0], $Rc ]; next; } ################################# @@ -1232,21 +1234,22 @@ sub list { # or all the profiles if option # -a|--all is assigned ################################# - if (exists( $args->{a} )) { + if (exists($args->{a})) { my $count = 0; foreach (@$prof) { $pprofile .= "@$prof[$count]\n\n"; $count++; } } else { + #$pprofile .= "@$prof[0]\n\n"; my $lparprof = xCAT::PPCcli::lssyscfg( - $exp, - "lpar2", - $mtms, - "lpar_ids=$id" ); + $exp, + "lpar2", + $mtms, + "lpar_ids=$id"); my $Rc = shift(@$lparprof); - if ( $Rc != SUCCESS ) { + if ($Rc != SUCCESS) { $pprofile .= "@$lparprof[0]\n\n"; } else { @$lparprof[0] =~ /curr_profile=(\w+)/; @@ -1254,20 +1257,20 @@ sub list { foreach my $pr (@$prof) { if ($pr =~ /name=$pname/) { $pprofile .= "$pr\n\n"; - } + } } - } + } } - } - $values->{$lpar} = [$lpar, $pprofile, SUCCESS]; + } + $values->{$lpar} = [ $lpar, $pprofile, SUCCESS ]; } } - foreach ( sort keys %$values ) { - push @value,$values->{$_}; + foreach (sort keys %$values) { + push @value, $values->{$_}; } xCAT::MsgUtils->verbose_message($request, "$request->{command} END."); - return( \@value ); + return (\@value); } ########################################################################## # Increments hca adapter in partition profile @@ -1278,72 +1281,72 @@ sub hca_adapter { ######################################### # Increment HCA adapters if present - # "23001eff/2550010250300/2,23001eff/2550010250400/2" - # Increment the last 2 number of 2550010250300 and + # "23001eff/2550010250300/2,23001eff/2550010250400/2" + # Increment the last 2 number of 2550010250300 and # 2550010250400 in example above. ######################################### - if ( $cfgdata =~ /(\"*hca_adapters)/ ) { + if ($cfgdata =~ /(\"*hca_adapters)/) { ##################################### # If double-quoted, has comma- # seperated list of adapters ##################################### - my $delim = ( $1 =~ /^\"/ ) ? "\\\\\"" : ","; - $cfgdata =~ /hca_adapters=([^$delim]+)|$/; + my $delim = ($1 =~ /^\"/) ? "\\\\\"" : ","; + $cfgdata =~ /hca_adapters=([^$delim]+)|$/; my @hcas = split ",", $1; my $adapters = "hca_adapters="; - for my $hca ( @hcas) + for my $hca (@hcas) { my @hcainfo = split /\//, $hca; ###################################################### # split it to 2 part, only increase the last 2 number # otherwise it can overflow if change it to dec ###################################################### - my $portlen = length( $hcainfo[1]); - my $portprefix = substr($hcainfo[1],0,$portlen-2); - my $portpostfix = substr($hcainfo[1],$portlen-2); - my $portnum = hex $portpostfix; + my $portlen = length($hcainfo[1]); + my $portprefix = substr($hcainfo[1], 0, $portlen - 2); + my $portpostfix = substr($hcainfo[1], $portlen - 2); + my $portnum = hex $portpostfix; $portnum++; $portpostfix = sprintf '%x', $portnum; - if ( length( $portpostfix) == 1) + if (length($portpostfix) == 1) { $portpostfix = '0' . $portpostfix; - } + } $hcainfo[1] = $portprefix . $portpostfix; - - $adapters = $adapters . join( "/", @hcainfo ) . ','; + + $adapters = $adapters . join("/", @hcainfo) . ','; } $adapters =~ s/^(.*),$/$1/; $cfgdata =~ s/hca_adapters=[^$delim]+/$adapters/; } - return( $cfgdata ); + return ($cfgdata); } ########################################################################## # Get unassigned hca guid ########################################################################## sub get_unassigned_iba { - my $exp = shift; - my $mtms = shift; - my $ibacap = shift; + my $exp = shift; + my $mtms = shift; + my $ibacap = shift; my $max_ib_num = 0; - if ( ! $ibacap) + if (!$ibacap) { $ibacap = '1'; } - if ( $ibacap eq '1') + if ($ibacap eq '1') { $max_ib_num = 16; } - elsif ( $ibacap eq '2') + elsif ($ibacap eq '2') { $max_ib_num = 8; } - elsif ( $ibacap eq '3') + elsif ($ibacap eq '3') { $max_ib_num = 4; } - elsif ( $ibacap eq '4') + elsif ($ibacap eq '4') { $max_ib_num = 1; } @@ -1352,9 +1355,9 @@ sub get_unassigned_iba return undef; } - my $hwres = xCAT::PPCcli::lshwres( $exp, ['sys','hca', 'adapter_id:phys_loc:unassigned_guids'], $mtms); + my $hwres = xCAT::PPCcli::lshwres($exp, [ 'sys', 'hca', 'adapter_id:phys_loc:unassigned_guids' ], $mtms); my $Rc = shift(@$hwres); - if ( $Rc == SUCCESS) + if ($Rc == SUCCESS) { my @unassigned_ibas; my $ib_hash = {}; @@ -1366,33 +1369,33 @@ sub get_unassigned_iba my $adapter_id = $1; my $phys_loc = $2; my $unassigned_guids = $3; - if ( $phys_loc =~ /C65$/ or $phys_loc =~ /C66$/ or $phys_loc =~ /C7$/) + if ($phys_loc =~ /C65$/ or $phys_loc =~ /C66$/ or $phys_loc =~ /C7$/) { my @guids = split /,/, $unassigned_guids; - $max_ib_num = scalar( @guids) if (scalar( @guids) < $max_ib_num); - for (my $i = 0; $i < $max_ib_num; $i++) + $max_ib_num = scalar(@guids) if (scalar(@guids) < $max_ib_num); + for (my $i = 0 ; $i < $max_ib_num ; $i++) { my $guid = @guids[$i]; $guid =~ s/\s*(\S+)\s*/$1/; - unshift @{$ib_hash->{$phys_loc}->{$adapter_id}}, "$adapter_id/$guid/$ibacap"; + unshift @{ $ib_hash->{$phys_loc}->{$adapter_id} }, "$adapter_id/$guid/$ibacap"; } } } } - for my $loc ( sort keys %$ib_hash) + for my $loc (sort keys %$ib_hash) { my $min_guid_num = -1; - for my $id (keys %{$ib_hash->{$loc}}) + for my $id (keys %{ $ib_hash->{$loc} }) { - if ( $min_guid_num == -1 or $min_guid_num > scalar( @{$ib_hash->{$loc}->{$id}})) + if ($min_guid_num == -1 or $min_guid_num > scalar(@{ $ib_hash->{$loc}->{$id} })) { - $min_guid_num = scalar( @{$ib_hash->{$loc}->{$id}}); + $min_guid_num = scalar(@{ $ib_hash->{$loc}->{$id} }); } } - for (my $i = 0; $i < $min_guid_num; $i++) + for (my $i = 0 ; $i < $min_guid_num ; $i++) { my $unassigned_iba = undef; - for my $adp_id (sort keys %{$ib_hash->{$loc}}) + for my $adp_id (sort keys %{ $ib_hash->{$loc} }) { my $iba = $ib_hash->{$loc}->{$adp_id}->[$i]; $unassigned_iba .= ",$iba"; @@ -1426,15 +1429,15 @@ sub get_iba_replace_pair my @oldhca_prefixes; for my $cfg (@$profile) { - if ( $cfg =~ /(\"*hca_adapters)/ ) + if ($cfg =~ /(\"*hca_adapters)/) { - my $delim = ( $1 =~ /^\"/ ) ? "\\\\\"" : ","; - $cfg =~ /hca_adapters=([^$delim]+)|$/; + my $delim = ($1 =~ /^\"/) ? "\\\\\"" : ","; + $cfg =~ /hca_adapters=([^$delim]+)|$/; my $oldhca = $1; my @oldhcas = split /,/, $oldhca; for my $oldhca_entry (@oldhcas) { - if ( $oldhca_entry =~ /(.+\/.+)..\/\d+/) + if ($oldhca_entry =~ /(.+\/.+)..\/\d+/) { my $oldhca_prefix = $1; if (!grep /\Q$oldhca_prefix\E/, @oldhca_prefixes) @@ -1449,28 +1452,28 @@ sub get_iba_replace_pair # Get hca info from unasigned hca array ########################################### my @newhca_prefixes; - for my $newhca ( @$unassigned_iba) + for my $newhca (@$unassigned_iba) { my @newhcas = split /,/, $newhca; - for my $newhca_entry ( @newhcas) + for my $newhca_entry (@newhcas) { - if ( $newhca_entry =~ /(.+\/.+)..\/\d+/) + if ($newhca_entry =~ /(.+\/.+)..\/\d+/) { my $newhca_prefix = $1; - if (!grep /\Q$newhca_prefix\E/,@newhca_prefixes) + if (!grep /\Q$newhca_prefix\E/, @newhca_prefixes) { push @newhca_prefixes, $newhca_prefix; } } } } - ############################# + ############################# # Create replacement pair ############################# my %pair_hash; - for ( my $i = 0; $i < scalar @oldhca_prefixes; $i++) + for (my $i = 0 ; $i < scalar @oldhca_prefixes ; $i++) { - $pair_hash{ @oldhca_prefixes[$i]} = @newhca_prefixes[$i]; + $pair_hash{ @oldhca_prefixes[$i] } = @newhca_prefixes[$i]; } return \%pair_hash; @@ -1480,9 +1483,9 @@ sub get_iba_replace_pair ########################################################################## sub hcasubst { - my $cfgdata = shift; + my $cfgdata = shift; my $replace_hash = shift; - if ( $cfgdata =~ /(\"*hca_adapters)/ ) { + if ($cfgdata =~ /(\"*hca_adapters)/) { for my $oldhca_prefix (keys %$replace_hash) { $cfgdata =~ s/\Q$oldhca_prefix\E/$replace_hash->{$oldhca_prefix}/g; @@ -1495,42 +1498,42 @@ sub hcasubst ########################################################################## sub hcaautoconf { - my $cfgdata = shift; + my $cfgdata = shift; my $unassignedhca = shift; $unassignedhca = [] if (!$unassignedhca); - if ( $cfgdata =~ /(\"*hca_adapters)/ ) { - - ##################################### - # If double-quoted, has comma- - # seperated list of adapters - ##################################### - my $delim = ( $1 =~ /^\"/ ) ? "\\\\\"" : ","; - $cfgdata =~ /hca_adapters=([^$delim]+)|$/; + if ($cfgdata =~ /(\"*hca_adapters)/) { + + ##################################### + # If double-quoted, has comma- + # seperated list of adapters + ##################################### + my $delim = ($1 =~ /^\"/) ? "\\\\\"" : ","; + $cfgdata =~ /hca_adapters=([^$delim]+)|$/; my $oldhca = $1; my $newhca; $newhca = shift @$unassignedhca; - + my $adapters = undef; - if ( $newhca ) + if ($newhca) { - $adapters = "hca_adapters=$newhca"; + $adapters = "hca_adapters=$newhca"; } else { $adapters = "hca_adapters=none"; } - if ( $adapters =~ /,/ and $delim ne "\\\\\"") + if ($adapters =~ /,/ and $delim ne "\\\\\"") { $adapters = "\\\\\"" . $adapters . "\\\\\""; } $cfgdata =~ s/hca_adapters=[^$delim]+/$adapters/; } - return $cfgdata ; + return $cfgdata; } ########################################################################## -# Increments virtual lhea adapter in partition profile +# Increments virtual lhea adapter in partition profile ########################################################################## sub lhea_adapter { @@ -1538,41 +1541,42 @@ sub lhea_adapter { ######################################### # Increment LHEA adapters if present - # 23000000/2/1/7/none,23000008/2/1/4/none + # 23000000/2/1/7/none,23000008/2/1/4/none # Increment 7 and 4 in example above. ######################################### - if ( $cfgdata =~ /(\"*lhea_logical_ports)/ ) { + if ($cfgdata =~ /(\"*lhea_logical_ports)/) { ##################################### # If double-quoted, has comma- # seperated list of adapters ##################################### - #my $delim = ( $1 =~ /^\"/ ) ? "\\\\\"" : ","; + #my $delim = ( $1 =~ /^\"/ ) ? "\\\\\"" : ","; #$cfgdata =~ /lhea_logical_ports=([^$delim]+)|$/; - $cfgdata =~ /lhea_logical_ports=(.*)lhea_capabilities/; + $cfgdata =~ /lhea_logical_ports=(.*)lhea_capabilities/; my @lhea = split ",", $1; - foreach ( @lhea ) + foreach (@lhea) { - if ( /(\d+)\/(\d+)\/(\d+)\/(\d+)/) + if (/(\d+)\/(\d+)\/(\d+)\/(\d+)/) { my $id = $4; - if($id =~ /\d+/) + if ($id =~ /\d+/) { $id = $id + 1; } s/(\d+)\/(\d+)\/(\d+)\/(\d+)/$1\/$2\/$3\/$id/; - } - } - my $adapters = "lhea_logical_ports=".join( ",", @lhea ); + } + } + my $adapters = "lhea_logical_ports=" . join(",", @lhea); + #$cfgdata =~ s/lhea_logical_ports=[^$delim]+/$adapters/; - $cfgdata =~ s/lhea_logical_ports=(.*)lhea_capabilities/$adapters,lhea_capabilities/; + $cfgdata =~ s/lhea_logical_ports=(.*)lhea_capabilities/$adapters,lhea_capabilities/; } - return( $cfgdata ); + return ($cfgdata); } ########################################################################## -# Increments virtual scsi adapter in partition profile +# Increments virtual scsi adapter in partition profile ########################################################################## sub scsi_adapter { @@ -1582,34 +1586,34 @@ sub scsi_adapter { # Increment SCSI adapters if present # 15/server/6/1ae0-node1/11/1, # 14/server/5/1ae0-ms04/12/1, - # 20/server/any//any/1 + # 20/server/any//any/1 # Increment 11 and 12 in example above. ######################################### - if ( $cfgdata =~ /(\"*virtual_scsi_adapters)/ ) { + if ($cfgdata =~ /(\"*virtual_scsi_adapters)/) { ##################################### # If double-quoted, has comma- # seperated list of adapters ##################################### - my $delim = ( $1 =~ /^\"/ ) ? "\\\\\"" : ","; - $cfgdata =~ /virtual_scsi_adapters=([^$delim]+)|$/; - + my $delim = ($1 =~ /^\"/) ? "\\\\\"" : ","; + $cfgdata =~ /virtual_scsi_adapters=([^$delim]+)|$/; + my @scsi = split ",", $1; - foreach ( @scsi ) { - if ( /(\w+)\/(\w+)$/ ) { - my $id = ($1 =~ /(\d+)/) ? $1+1 : $1; + foreach (@scsi) { + if (/(\w+)\/(\w+)$/) { + my $id = ($1 =~ /(\d+)/) ? $1 + 1 : $1; s/(\w+)\/(\w+)$/$id\/$2/; - } + } } - my $adapters = "virtual_scsi_adapters=".join( ",", @scsi ); + my $adapters = "virtual_scsi_adapters=" . join(",", @scsi); $cfgdata =~ s/virtual_scsi_adapters=[^$delim]+/$adapters/; } - return( $cfgdata ); + return ($cfgdata); } ########################################################################## -# Creates/changes logical partitions +# Creates/changes logical partitions ########################################################################## sub create { @@ -1630,8 +1634,8 @@ sub create { ##################################### # Get source node information ##################################### - while ( my ($cec,$h) = each(%$hash) ) { - while ( my ($name,$data) = each(%$h) ) { + while (my ($cec, $h) = each(%$hash)) { + while (my ($name, $data) = each(%$h)) { $d = $data; $lparid = @$d[0]; $mtms = @$d[2]; @@ -1640,45 +1644,45 @@ sub create { } } ##################################### - # Must be CEC or LPAR + # Must be CEC or LPAR ##################################### - if ( $type !~ /^(lpar|fsp|cec)$/ ) { - return( [[$lpar,"Node must be LPAR or CEC",RC_ERROR]] ); + if ($type !~ /^(lpar|fsp|cec)$/) { + return ([ [ $lpar, "Node must be LPAR or CEC", RC_ERROR ] ]); } ##################################### - # Clone all the LPARs on CEC + # Clone all the LPARs on CEC ##################################### - if ( exists( $opt->{c} )) { - my $result = clone( $request, - $exp, - $opt->{target}, - $opt->{profile}, - $d, - $request->{node}->[0] - ); - foreach ( @$result ) { + if (exists($opt->{c})) { + my $result = clone($request, + $exp, + $opt->{target}, + $opt->{profile}, + $d, + $request->{node}->[0] + ); + foreach (@$result) { my $Rc = shift(@$_); - push @values, [$opt->{c}, @$_[0], $Rc]; + push @values, [ $opt->{c}, @$_[0], $Rc ]; } - return( \@values ); + return (\@values); } ##################################### - # Get source LPAR profile + # Get source LPAR profile ##################################### xCAT::MsgUtils->verbose_message($request, "$request->{command} :lssyscfg prof.filter:'lpar_ids=$lparid'."); my $prof = xCAT::PPCcli::lssyscfg( - $exp, - "prof", - $mtms, - "lpar_ids=$lparid" ); + $exp, + "prof", + $mtms, + "lpar_ids=$lparid"); my $Rc = shift(@$prof); ##################################### # Return error ##################################### - if ( $Rc != SUCCESS ) { - return( [[$lpar, @$prof[0], $Rc]] ); - } + if ($Rc != SUCCESS) { + return ([ [ $lpar, @$prof[0], $Rc ] ]); + } ##################################### # Get source node pprofile attribute ##################################### @@ -1688,25 +1692,25 @@ sub create { # Find pprofile on source node ##################################### my ($prof) = grep /^name=$pprofile\,/, @$prof; - if ( !$prof ) { - return( [[$lpar, "'pprofile=$pprofile' not found on '$lpar'", RC_ERROR]] ); + if (!$prof) { + return ([ [ $lpar, "'pprofile=$pprofile' not found on '$lpar'", RC_ERROR ] ]); } ##################################### # Get command-line options ##################################### - my $id = $opt->{i}; - my $cfgdata = strip_profile( $prof, $hwtype ); - + my $id = $opt->{i}; + my $cfgdata = strip_profile($prof, $hwtype); + ##################################### # Set profile name for all LPARs ##################################### - if ( $hwtype eq "hmc" ) { + if ($hwtype eq "hmc") { $cfgdata =~ s/^name=([^,]+|$)/profile_name=$1/; $profile = $1; $cfgdata =~ s/lpar_name=/name=/; } - - foreach my $name ( @{$opt->{target}} ) { + + foreach my $name (@{ $opt->{target} }) { ################################# # Modify read-back profile. @@ -1720,56 +1724,56 @@ sub create { ################################# # Modify LHEA adapters ################################# - if ( $cfgdata =~ /lhea_logical_ports=(\w+)/ ) { - if ( $1 !~ /^none$/i ) { - $cfgdata = lhea_adapter( $cfgdata ); + if ($cfgdata =~ /lhea_logical_ports=(\w+)/) { + if ($1 !~ /^none$/i) { + $cfgdata = lhea_adapter($cfgdata); } } ################################# # Modify HCA adapters ################################# - if ( $cfgdata =~ /hca_adapters=(\w+)/ ) { - if ( $1 !~ /^none$/i ) { - $cfgdata = hca_adapter( $cfgdata ); + if ($cfgdata =~ /hca_adapters=(\w+)/) { + if ($1 !~ /^none$/i) { + $cfgdata = hca_adapter($cfgdata); } } ################################# # Modify SCSI adapters ################################# - if ( $cfgdata =~ /virtual_scsi_adapters=(\w+)/ ) { - if ( $1 !~ /^none$/i ) { - $cfgdata = scsi_adapter( $cfgdata ); + if ($cfgdata =~ /virtual_scsi_adapters=(\w+)/) { + if ($1 !~ /^none$/i) { + $cfgdata = scsi_adapter($cfgdata); } } ################################# - # Create new LPAR + # Create new LPAR ################################# xCAT::MsgUtils->verbose_message($request, "$request->{command} :mksyscfg lpar.cfg:'$cfgdata'."); - $result = xCAT::PPCcli::mksyscfg( $exp, "lpar", $d, $cfgdata ); + $result = xCAT::PPCcli::mksyscfg($exp, "lpar", $d, $cfgdata); $Rc = shift(@$result); ################################# - # Add new LPAR to database + # Add new LPAR to database ################################# - if ( $Rc == SUCCESS ) { + if ($Rc == SUCCESS) { xCAT::MsgUtils->verbose_message($request, "$request->{command} :add lpar:$name from xCATdb."); - my $err = xCATdB( "mkvm", $name, $profile, $id, $d, $hwtype, $lpar); - if ( defined( $err )) { - push @values, [$name,$err,RC_ERROR]; + my $err = xCATdB("mkvm", $name, $profile, $id, $d, $hwtype, $lpar); + if (defined($err)) { + push @values, [ $name, $err, RC_ERROR ]; $id++; next; } } - push @values, [$name,@$result[0],$Rc]; + push @values, [ $name, @$result[0], $Rc ]; $id++; } xCAT::MsgUtils->verbose_message($request, "$request->{command} END."); - return( \@values ); + return (\@values); } ########################################################################## -# Strips attributes from profile not valid for creation +# Strips attributes from profile not valid for creation ########################################################################## sub strip_profile { @@ -1781,14 +1785,14 @@ sub strip_profile { # HMC mksyscfg man page for valid # attributes. ##################################### - if ( $hwtype eq "hmc" ) { + if ($hwtype eq "hmc") { $cfgdata =~ s/,*\"virtual_serial_adapters=[^\"]+\"//; $cfgdata =~ s/,*electronic_err_reporting=[^,]+|$//; $cfgdata =~ s/,*shared_proc_pool_id=[^,]+|$//; $cfgdata =~ s/,*lpar_proc_compat_mode=[^,]+|$//; $cfgdata =~ s/\"/\\"/g; $cfgdata =~ s/\n//g; - return( $cfgdata ); + return ($cfgdata); } ##################################### # Modify read-back profile. See @@ -1803,7 +1807,7 @@ sub strip_profile { $cfgdata =~ s/,*conn_monitoring=[^,]+|$//; $cfgdata =~ s/,*power_ctrl_lpar_ids=[^,]+|$//; $cfgdata =~ s/\"/\\"/g; - return( $cfgdata ); + return ($cfgdata); } @@ -1822,98 +1826,98 @@ sub xCATdB { my $parent = shift; ####################################### - # Remove entry + # Remove entry ####################################### - if ( $cmd eq "rmvm" ) { + if ($cmd eq "rmvm") { my $ppctab = xCAT::Table->new('ppc'); - unless ($ppctab) { # no ppc table - return( "Error opening 'ppc' database" ); + unless ($ppctab) { # no ppc table + return ("Error opening 'ppc' database"); } - my @nodes = $ppctab->getAllNodeAttribs(['node','id','parent']); + my @nodes = $ppctab->getAllNodeAttribs([ 'node', 'id', 'parent' ]); foreach my $node (@nodes) { my $type = xCAT::DBobjUtils->getnodetype($node->{node}); - if ( $type =~ /lpar/ and $lparid eq $node->{id} and $parent eq $node->{parent} ) { - return( xCAT::PPCdb::rm_ppc( $node->{node} )); + if ($type =~ /lpar/ and $lparid eq $node->{id} and $parent eq $node->{parent}) { + return (xCAT::PPCdb::rm_ppc($node->{node})); } } } ####################################### - # Change entry + # Change entry ####################################### - elsif ( $cmd eq "chvm" ) { - my $ppctab = xCAT::Table->new( "ppc", -create=>1, -autocommit=>1 ); + elsif ($cmd eq "chvm") { + my $ppctab = xCAT::Table->new("ppc", -create => 1, -autocommit => 1); ################################### # Error opening ppc database ################################### - if ( !defined( $ppctab )) { - return( "Error opening 'ppc' database" ); + if (!defined($ppctab)) { + return ("Error opening 'ppc' database"); } - $ppctab->setNodeAttribs( $name, {pprofile=>$profile} ); + $ppctab->setNodeAttribs($name, { pprofile => $profile }); } ####################################### - # Add entry + # Add entry ####################################### else { - if ( !defined( $profile )) { + if (!defined($profile)) { $profile = $name; } - my ($model,$serial) = split /\*/,@$d[2]; - my $server = @$d[3]; - my $fsp = @$d[2]; - - ################################### + my ($model, $serial) = split /\*/, @$d[2]; + my $server = @$d[3]; + my $fsp = @$d[2]; + + ################################### # Find FSP name in ppc database ################################### - my $tab = xCAT::Table->new( "ppc" ); + my $tab = xCAT::Table->new("ppc"); ################################### # Error opening ppc database ################################### - if ( !defined( $tab )) { - return( "Error opening 'ppc' database" ); + if (!defined($tab)) { + return ("Error opening 'ppc' database"); } ################################### # If there is no parent provided - # this lpar should be the cloned + # this lpar should be the cloned # in the same cec - # Otherwise it should be cloned + # Otherwise it should be cloned # between cecs ################################### - if ( ! $parent) + if (!$parent) { - my ($ent) = $tab->getNodeAttribs($lpar, ['parent'] ); + my ($ent) = $tab->getNodeAttribs($lpar, ['parent']); ################################### - # Node not found + # Node not found ################################### - if ( !defined( $ent )) { - return( "'$lpar' not found in 'ppc' database" ); + if (!defined($ent)) { + return ("'$lpar' not found in 'ppc' database"); } ################################### - # Attributes not found + # Attributes not found ################################### - if ( !exists( $ent->{parent} )) { - return( "'parent' attribute not found in 'ppc' database" ); + if (!exists($ent->{parent})) { + return ("'parent' attribute not found in 'ppc' database"); } $parent = $ent->{parent}; } - my $values = join( ",", - "lpar", - $name, - $lparid, - $model, - $serial, - "", - $server, - $profile, - $parent ); - - return( xCAT::PPCdb::add_ppc( $hwtype, [$values],'','',"PPC" )); + my $values = join(",", + "lpar", + $name, + $lparid, + $model, + $serial, + "", + $server, + $profile, + $parent); + + return (xCAT::PPCdb::add_ppc($hwtype, [$values], '', '', "PPC")); } return undef; } @@ -1942,154 +1946,156 @@ sub mkfulllpar { my $mtms; my $type; my $profile; - - my $ppctab = xCAT::Table->new('ppc'); + + my $ppctab = xCAT::Table->new('ppc'); ##################################### # Get source node information ##################################### - while ( my ($cec,$h) = each(%$hash) ) { - my ($name,$data) = each(%$h); - $d = $data; - $lparid = @$d[0]; - $mtms = @$d[2]; - $type = @$d[4]; - $lpar = $name; - ##################################### - # Must be CEC or LPAR - ##################################### - if ( $type !~ /^(lpar|fsp|cec)$/ ) { - return( [[$lpar,"Node must be LPAR or CEC",RC_ERROR]] ); - } - - my $ppctab = xCAT::Table->new('ppc'); + while (my ($cec, $h) = each(%$hash)) { + my ($name, $data) = each(%$h); + $d = $data; + $lparid = @$d[0]; + $mtms = @$d[2]; + $type = @$d[4]; + $lpar = $name; ##################################### - # Check if a existing with requested LPAR ID has existed + # Must be CEC or LPAR + ##################################### + if ($type !~ /^(lpar|fsp|cec)$/) { + return ([ [ $lpar, "Node must be LPAR or CEC", RC_ERROR ] ]); + } + + my $ppctab = xCAT::Table->new('ppc'); + ##################################### + # Check if a existing with requested LPAR ID has existed ##################################### my $value = xCAT::PPCcli::lssyscfg( - $exp, - "profs", - $mtms, - "all_resources", - "lpar_ids=$lparid" ); + $exp, + "profs", + $mtms, + "all_resources", + "lpar_ids=$lparid"); my $Rc = shift(@$value); ####################################### # make how to handle according to the result of lssyscfg ####################################### - if ( $Rc == SUCCESS ) { + if ($Rc == SUCCESS) { + # close the DB handler of the ppc table $ppctab->close; - # change the lpar's attribute before removing it. + + # change the lpar's attribute before removing it. my $all_res_flag = @$value[0]; - if ( $all_res_flag != 1 ) { - return( [[$lpar,"The LPAR ID has been occupied",RC_ERROR]] ); + if ($all_res_flag != 1) { + return ([ [ $lpar, "The LPAR ID has been occupied", RC_ERROR ] ]); } else { - return( [[$lpar,"This full LPAR has been created",RC_ERROR]] ); + return ([ [ $lpar, "This full LPAR has been created", RC_ERROR ] ]); } } - + ################################# - # Create the new full LPAR's configure data + # Create the new full LPAR's configure data ################################# my ($lpar_id, $profname); - my $vcon = $ppctab->getAttribs($name, ('id','pprofile')); - if ($vcon) { - if ($vcon->{"id"}) { + my $vcon = $ppctab->getAttribs($name, ('id', 'pprofile')); + if ($vcon) { + if ($vcon->{"id"}) { $lpar_id = $vcon->{"id"}; - } else { + } else { $lpar_id = 1; - } + } - if ($vcon->{"pprofile"}) { + if ($vcon->{"pprofile"}) { $profname = $vcon->{"pprofile"}; - } else { + } else { $profname = $name; - } - } else { - $lpar_id = 1; - $profname = $name; - } - - my $cfgdata = "name=$name,profile_name=$profname,lpar_id=$lpar_id,lpar_env=aixlinux,all_resources=1,boot_mode=norm,conn_monitoring=0"; - + } + } else { + $lpar_id = 1; + $profname = $name; + } + + my $cfgdata = "name=$name,profile_name=$profname,lpar_id=$lpar_id,lpar_env=aixlinux,all_resources=1,boot_mode=norm,conn_monitoring=0"; + ################################# # Create a new full LPAR ################################# - $result = xCAT::PPCcli::mksyscfg( $exp, "lpar", $d, $cfgdata ); - $Rc = shift(@$result); + $result = xCAT::PPCcli::mksyscfg($exp, "lpar", $d, $cfgdata); + $Rc = shift(@$result); ########################################### # Set the CEC's service_lpar_id to the lpar_id of the full LPAR ########################################### - if ( $Rc == SUCCESS) { - $cfgdata = "service_lpar_id=$lpar_id"; - $result = xCAT::PPCcli::chsyscfg( $exp, "fsp", $d, $cfgdata ); - $Rc = shift(@$result); - if ( $Rc != SUCCESS ) { + if ($Rc == SUCCESS) { + $cfgdata = "service_lpar_id=$lpar_id"; + $result = xCAT::PPCcli::chsyscfg($exp, "fsp", $d, $cfgdata); + $Rc = shift(@$result); + if ($Rc != SUCCESS) { $ppctab->close; - return( [[$lpar, @$result[0], $Rc]] ); + return ([ [ $lpar, @$result[0], $Rc ] ]); } } - + ################################# - # Add a new full LPAR to database + # Add a new full LPAR to database ################################# - if ( $Rc == SUCCESS ) { + if ($Rc == SUCCESS) { $profile = $profname; my $id = $lpar_id; - my $err = xCATdB( "mkvm", $name, $profile, $id, $d, $hwtype, $lpar); - if ( defined( $err )) { - push @values, [$name,$err,RC_ERROR]; + my $err = xCATdB("mkvm", $name, $profile, $id, $d, $hwtype, $lpar); + if (defined($err)) { + push @values, [ $name, $err, RC_ERROR ]; next; } } - push @values, [$name,@$result[0],$Rc]; + push @values, [ $name, @$result[0], $Rc ]; } $ppctab->close; - return( \@values ); + return (\@values); } ########################################################################## -# Creates logical partitions +# Creates logical partitions ########################################################################## sub mkvm { my $request = $_[0]; my $opt = $request->{opt}; - + # decide if issuing mkvm with the option '-f'. # if yes, mklpar will be invoked to # create a full system partition for each CECs managed by the HMC. - if ( exists($opt->{full})) { - return( mkfulllpar(@_) ); - } - else { + if (exists($opt->{full})) { + return (mkfulllpar(@_)); + } + else { # if no, it will execute the original function. - return( create(@_) ); + return (create(@_)); } } ########################################################################## -# Change logical partition +# Change logical partition ########################################################################## sub chvm { - return( modify(@_) ); + return (modify(@_)); } ########################################################################## -# Removes logical partitions +# Removes logical partitions ########################################################################## -sub rmvm { - return( remove(@_) ); +sub rmvm { + return (remove(@_)); } ########################################################################## # Lists logical partition profile ########################################################################## sub lsvm { - return( list(@_) ); + return (list(@_)); } diff --git a/perl-xCAT/xCAT/ProfiledNodeUtils.pm b/perl-xCAT/xCAT/ProfiledNodeUtils.pm index 0148aa664..d65ea1cdd 100644 --- a/perl-xCAT/xCAT/ProfiledNodeUtils.pm +++ b/perl-xCAT/xCAT/ProfiledNodeUtils.pm @@ -38,32 +38,33 @@ This program module file, is a set of node management utilities for Profile base #------------------------------------------------------------------------------- sub get_allocable_staticips_innet { - my $class = shift; - my $netname = shift; + my $class = shift; + my $netname = shift; my $exclude_ips_ref = shift; my %iphash; my @allocableips; - foreach (@$exclude_ips_ref){ + foreach (@$exclude_ips_ref) { $iphash{$_} = 0; } my $networkstab = xCAT::Table->new('networks'); my $netentry = ($networkstab->getAllAttribsWhere("netname = '$netname'", 'ALL'))[0]; - my ($startip, $endip) = split('-', $netentry->{'staticrange'}); + my ($startip, $endip) = split('-', $netentry->{'staticrange'}); my $incremental = $netentry->{'staticrangeincrement'}; - my $netmask = $netentry->{'mask'}; - my $gateway = $netentry->{'gateway'}; + my $netmask = $netentry->{'mask'}; + my $gateway = $netentry->{'gateway'}; my $validipsref; - if ($incremental and $startip and $endip){ + if ($incremental and $startip and $endip) { $validipsref = xCAT::NetworkUtils->get_allips_in_range($startip, $endip, $incremental); } - + my $broadcastip = xCAT::NetworkUtils->getBroadcast($startip, $netmask); - foreach (@$validipsref){ + foreach (@$validipsref) { + #Remove ip which is broadcast ip, exclude ip, ips ended with 0, gateway ip - if (exists($iphash{$_}) or $_ eq $broadcastip or $_ eq $gateway - or $_ =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(0)$/){ + if (exists($iphash{$_}) or $_ eq $broadcastip or $_ eq $gateway + or $_ =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(0)$/) { next; } push @allocableips, $_; @@ -115,11 +116,11 @@ sub split_hostname my $idx = index $format, "#$patt_char"; my @array_format = split(//, $format); - my $pos = $idx+2; - while ( $pos <= (scalar(@array_format) - 1)){ - if ($array_format[$pos] eq "$patt_char"){ + my $pos = $idx + 2; + while ($pos <= (scalar(@array_format) - 1)) { + if ($array_format[$pos] eq "$patt_char") { $pos++; - }else{ + } else { last; } } @@ -128,7 +129,7 @@ sub split_hostname my $prefix = ""; $prefix = substr $format, 0, $idx; my $appendix = ""; - if (($ridx + 1) != scalar(@array_format)){ + if (($ridx + 1) != scalar(@array_format)) { $appendix = substr $format, $ridx + 1; } return $prefix, $appendix, ($ridx - $idx); @@ -156,16 +157,16 @@ sub gen_numric_hostnames my @hostnames; my $cnt = 0; - if ($rank){ + if ($rank) { $cnt = $rank; - } - my $maxnum = 10 ** $len; - while($cnt < $maxnum) + } + my $maxnum = 10**$len; + while ($cnt < $maxnum) { my $fullnum = $maxnum + $cnt; - my $hostname = $prefix.(substr $fullnum, 1).$appendix; - push (@hostnames, $hostname); - if ($amount && (@hostnames == $amount)){ + my $hostname = $prefix . (substr $fullnum, 1) . $appendix; + push(@hostnames, $hostname); + if ($amount && (@hostnames == $amount)) { last; } $cnt++; @@ -187,38 +188,39 @@ sub gen_numric_hostnames =cut #------------------------------------------------------------------------------- -sub get_hostname_format_type{ - my ($class, $format) = @_; +sub get_hostname_format_type { + my ($class, $format) = @_; my $type; my ($prefix, $appendix, $rlen, $nlen); my $ridx = index $format, "#R"; my $nidx = index $format, "#N"; my $simpname = ""; - if ($ridx >= 0){ + if ($ridx >= 0) { ($prefix, $appendix, $rlen) = xCAT::ProfiledNodeUtils->split_hostname($format, 'R'); - $simpname = $prefix."0".$appendix; + $simpname = $prefix . "0" . $appendix; ($prefix, $appendix, $nlen) = xCAT::ProfiledNodeUtils->split_hostname($simpname, 'N'); - $simpname = $prefix."0".$appendix; - if ($rlen >= 10 || $nlen >= 10 || $nlen == 0){ + $simpname = $prefix . "0" . $appendix; + if ($rlen >= 10 || $nlen >= 10 || $nlen == 0) { $type = "unknown"; - } else{ + } else { $type = "rack"; } - } elsif ($nidx >= 0){ + } elsif ($nidx >= 0) { ($prefix, $appendix, $nlen) = xCAT::ProfiledNodeUtils->split_hostname($format, 'N'); - $simpname = $prefix."0".$appendix; - if ($nlen >= 10){ + $simpname = $prefix . "0" . $appendix; + if ($nlen >= 10) { $type = "unknown"; - } else{ + } else { $type = "numric"; } - } else{ + } else { $type = "unknown"; } + # validate whether hostname format includes other invalid characters. - if ($type ne "unknown"){ - if (! xCAT::NetworkUtils->isValidHostname($simpname)){ + if ($type ne "unknown") { + if (!xCAT::NetworkUtils->isValidHostname($simpname)) { $type = "unknown"; } } @@ -238,19 +240,19 @@ sub get_hostname_format_type{ =cut #------------------------------------------------------------------------------- -sub rackformat_to_numricformat{ +sub rackformat_to_numricformat { my ($class, $format, $rackname) = @_; my ($prefix, $appendix, $len) = xCAT::ProfiledNodeUtils->split_hostname($format, 'R'); - my %objhash = xCAT::DBobjUtils->getobjdefs({$rackname, "rack"}); + my %objhash = xCAT::DBobjUtils->getobjdefs({ $rackname, "rack" }); my $racknum = $objhash{$rackname}{"num"}; - my $maxnum = 10 ** $len; - if ($racknum >= $maxnum ){ + my $maxnum = 10**$len; + if ($racknum >= $maxnum) { return undef; } my $fullnum = $maxnum + $racknum; - return $prefix.(substr $fullnum, 1).$appendix; + return $prefix . (substr $fullnum, 1) . $appendix; } #------------------------------------------------------------------------------- @@ -272,106 +274,106 @@ sub rackformat_to_numricformat{ =cut #------------------------------------------------------------------------------- -sub get_nodes_nic_attrs{ +sub get_nodes_nic_attrs { my $class = shift; my $nodes = shift; - my $nicstab = xCAT::Table->new( 'nics'); - my $entry = $nicstab->getNodesAttribs($nodes, ['nictypes', 'nichostnamesuffixes', 'nichostnameprefixes', 'niccustomscripts', 'nicnetworks', 'nicips', 'nicextraparams']); + my $nicstab = xCAT::Table->new('nics'); + my $entry = $nicstab->getNodesAttribs($nodes, [ 'nictypes', 'nichostnamesuffixes', 'nichostnameprefixes', 'niccustomscripts', 'nicnetworks', 'nicips', 'nicextraparams' ]); my %nicsattrs; my @nicattrslist; - foreach my $node (@$nodes){ - if ($entry->{$node}->[0]->{'nictypes'}){ + foreach my $node (@$nodes) { + if ($entry->{$node}->[0]->{'nictypes'}) { @nicattrslist = split(",", $entry->{$node}->[0]->{'nictypes'}); - foreach (@nicattrslist){ - my @nicattrs; - if ($_ =~ /!/) { - @nicattrs = split("!", $_); - } else { - @nicattrs = split(":", $_); - } - $nicsattrs{$node}{$nicattrs[0]}{'type'} = $nicattrs[1]; + foreach (@nicattrslist) { + my @nicattrs; + if ($_ =~ /!/) { + @nicattrs = split("!", $_); + } else { + @nicattrs = split(":", $_); + } + $nicsattrs{$node}{ $nicattrs[0] }{'type'} = $nicattrs[1]; } } - if($entry->{$node}->[0]->{'nichostnamesuffixes'}){ + if ($entry->{$node}->[0]->{'nichostnamesuffixes'}) { @nicattrslist = split(",", $entry->{$node}->[0]->{'nichostnamesuffixes'}); - foreach (@nicattrslist){ - my @nicattrs; - if ($_ =~ /!/) { - @nicattrs = split("!", $_); - } else { - @nicattrs = split(":", $_); - } - $nicsattrs{$node}{$nicattrs[0]}{'hostnamesuffix'} = $nicattrs[1]; + foreach (@nicattrslist) { + my @nicattrs; + if ($_ =~ /!/) { + @nicattrs = split("!", $_); + } else { + @nicattrs = split(":", $_); + } + $nicsattrs{$node}{ $nicattrs[0] }{'hostnamesuffix'} = $nicattrs[1]; } } - if($entry->{$node}->[0]->{'nichostnameprefixes'}){ + if ($entry->{$node}->[0]->{'nichostnameprefixes'}) { @nicattrslist = split(",", $entry->{$node}->[0]->{'nichostnameprefixes'}); - foreach (@nicattrslist){ - my @nicattrs; - if ($_ =~ /!/) { - @nicattrs = split("!", $_); - } else { - @nicattrs = split(":", $_); - } - $nicsattrs{$node}{$nicattrs[0]}{'hostnameprefix'} = $nicattrs[1]; + foreach (@nicattrslist) { + my @nicattrs; + if ($_ =~ /!/) { + @nicattrs = split("!", $_); + } else { + @nicattrs = split(":", $_); + } + $nicsattrs{$node}{ $nicattrs[0] }{'hostnameprefix'} = $nicattrs[1]; } } - if($entry->{$node}->[0]->{'niccustomscripts'}){ + if ($entry->{$node}->[0]->{'niccustomscripts'}) { @nicattrslist = split(",", $entry->{$node}->[0]->{'niccustomscripts'}); - foreach (@nicattrslist){ - my @nicattrs; - if ($_ =~ /!/) { - @nicattrs = split("!", $_); - } else { - @nicattrs = split(":", $_); - } - $nicsattrs{$node}{$nicattrs[0]}{'customscript'} = $nicattrs[1]; + foreach (@nicattrslist) { + my @nicattrs; + if ($_ =~ /!/) { + @nicattrs = split("!", $_); + } else { + @nicattrs = split(":", $_); + } + $nicsattrs{$node}{ $nicattrs[0] }{'customscript'} = $nicattrs[1]; } } - if($entry->{$node}->[0]->{'nicnetworks'}){ + if ($entry->{$node}->[0]->{'nicnetworks'}) { @nicattrslist = split(",", $entry->{$node}->[0]->{'nicnetworks'}); - foreach (@nicattrslist){ - my @nicattrs; - if ($_ =~ /!/) { - @nicattrs = split("!", $_); - } else { - @nicattrs = split(":", $_); - } - $nicsattrs{$node}{$nicattrs[0]}{'network'} = $nicattrs[1]; + foreach (@nicattrslist) { + my @nicattrs; + if ($_ =~ /!/) { + @nicattrs = split("!", $_); + } else { + @nicattrs = split(":", $_); + } + $nicsattrs{$node}{ $nicattrs[0] }{'network'} = $nicattrs[1]; } } - if($entry->{$node}->[0]->{'nicips'}){ + if ($entry->{$node}->[0]->{'nicips'}) { @nicattrslist = split(",", $entry->{$node}->[0]->{'nicips'}); - foreach (@nicattrslist){ - my @nicattrs; - if ($_ =~ /!/) { - @nicattrs = split("!", $_); - } else { - @nicattrs = split(":", $_); - } - $nicsattrs{$node}{$nicattrs[0]}{'ip'} = $nicattrs[1]; + foreach (@nicattrslist) { + my @nicattrs; + if ($_ =~ /!/) { + @nicattrs = split("!", $_); + } else { + @nicattrs = split(":", $_); + } + $nicsattrs{$node}{ $nicattrs[0] }{'ip'} = $nicattrs[1]; } } - if($entry->{$node}->[0]->{'nicextraparams'}){ + if ($entry->{$node}->[0]->{'nicextraparams'}) { @nicattrslist = split(",", $entry->{$node}->[0]->{'nicextraparams'}); - foreach (@nicattrslist){ - my @nicattrs; - if ($_ =~ /!/) { - @nicattrs = split("!", $_); - } else { - @nicattrs = split(":", $_); - } - $nicsattrs{$node}{$nicattrs[0]}{'extraparams'} = $nicattrs[1]; + foreach (@nicattrslist) { + my @nicattrs; + if ($_ =~ /!/) { + @nicattrs = split("!", $_); + } else { + @nicattrs = split(":", $_); + } + $nicsattrs{$node}{ $nicattrs[0] }{'extraparams'} = $nicattrs[1]; } } } @@ -388,14 +390,14 @@ sub get_nodes_nic_attrs{ =cut #------------------------------------------------------------------------------- -sub get_netprofile_bmcnet{ +sub get_netprofile_bmcnet { my ($class, $netprofilename) = @_; my $netprofile_nicshash_ref = xCAT::ProfiledNodeUtils->get_nodes_nic_attrs($netprofilename)->{$netprofilename}; my %netprofile_nicshash = %$netprofile_nicshash_ref; - if (exists $netprofile_nicshash{'bmc'}{"network"}){ + if (exists $netprofile_nicshash{'bmc'}{"network"}) { return $netprofile_nicshash{'bmc'}{"network"} - }else{ + } else { return undef; } } @@ -409,17 +411,17 @@ sub get_netprofile_bmcnet{ =cut #------------------------------------------------------------------------------- -sub get_netprofile_provisionnet{ +sub get_netprofile_provisionnet { my ($class, $netprofilename) = @_; my $netprofile_nicshash_ref = xCAT::ProfiledNodeUtils->get_nodes_nic_attrs([$netprofilename])->{$netprofilename}; my %netprofile_nicshash = %$netprofile_nicshash_ref; - my $restab = xCAT::Table->new('noderes'); + my $restab = xCAT::Table->new('noderes'); my $installnicattr = $restab->getNodeAttribs($netprofilename, ['installnic']); my $installnic = $installnicattr->{'installnic'}; - if ($installnic){ - if (exists $netprofile_nicshash{$installnic}{"network"}){ + if ($installnic) { + if (exists $netprofile_nicshash{$installnic}{"network"}) { return $netprofile_nicshash{$installnic}{"network"} } } @@ -439,12 +441,12 @@ sub get_netprofile_provisionnet{ sub get_output_filename { my $installdir = xCAT::TableUtils->getInstallDir(); - my $pcmworkdir = $installdir."/pcm/work/"; - if (! -d $pcmworkdir) + my $pcmworkdir = $installdir . "/pcm/work/"; + if (!-d $pcmworkdir) { mkpath($pcmworkdir); } - return tempfile("hostinfo_result_XXXXXXX", DIR=>$pcmworkdir); + return tempfile("hostinfo_result_XXXXXXX", DIR => $pcmworkdir); } #------------------------------------------------------------------------------- @@ -466,9 +468,9 @@ sub get_output_filename #------------------------------------------------------------------------------- sub get_all_chassis { - my $class = shift; + my $class = shift; my $hashref = shift; - my $type = shift; + my $type = shift; my %chassishash; my %chassistype = ('all' => '__Chassis', 'cmm' => '__Chassis_IBM_Flex_chassis'); @@ -476,12 +478,12 @@ sub get_all_chassis $type = 'all'; } my @chassis = xCAT::NodeRange::noderange($chassistype{$type}); - if ($hashref){ - foreach (@chassis){ + if ($hashref) { + foreach (@chassis) { $chassishash{$_} = 1; } return \%chassishash; - } else{ + } else { return \@chassis; } } @@ -501,26 +503,26 @@ sub get_all_chassis #------------------------------------------------------------------------------- sub get_all_rack { - my $class = shift; - my $hashref = shift; + my $class = shift; + my $hashref = shift; my %rackhash = (); my @racklist = (); my $racktab = xCAT::Table->new('rack'); - my @racks = $racktab->getAllAttribs(('rackname')); - foreach (@racks){ - if($_->{'rackname'}){ - if ($hashref){ - $rackhash{$_->{'rackname'}} = 1; - }else { + my @racks = $racktab->getAllAttribs(('rackname')); + foreach (@racks) { + if ($_->{'rackname'}) { + if ($hashref) { + $rackhash{ $_->{'rackname'} } = 1; + } else { push @racklist, $_->{'rackname'}; } } } - - if ($hashref){ + + if ($hashref) { return \%rackhash; - }else{ + } else { return \@racklist; } } @@ -536,13 +538,13 @@ sub get_all_rack #------------------------------------------------------------------------------- sub get_racks_for_chassises { - my $class = shift; + my $class = shift; my $chassislistref = shift; - my %rackinfodict = (); + my %rackinfodict = (); my $nodepostab = xCAT::Table->new('nodepos'); my $racksref = $nodepostab->getNodesAttribs($chassislistref, ['rack']); - foreach (@$chassislistref){ + foreach (@$chassislistref) { $rackinfodict{$_} = $racksref->{$_}->[0]->{'rack'}; } return \%rackinfodict; @@ -562,15 +564,15 @@ sub get_racks_for_chassises #------------------------------------------------------------------------------- sub get_allnode_singleattrib_hash { - my $class = shift; + my $class = shift; my $tabname = shift; - my $attr = shift; - my $table = xCAT::Table->new($tabname); + my $attr = shift; + my $table = xCAT::Table->new($tabname); my @entries = $table->getAllNodeAttribs([$attr]); my %allrecords; foreach (@entries) { - if ($_->{$attr}){ - $allrecords{$_->{$attr}} = 0; + if ($_->{$attr}) { + $allrecords{ $_->{$attr} } = 0; } } return \%allrecords; @@ -587,16 +589,17 @@ sub get_allnode_singleattrib_hash #------------------------------------------------------------------------------- sub get_db_switches { - my $class = shift; - my $table = xCAT::Table->new("switches"); + my $class = shift; + my $table = xCAT::Table->new("switches"); my @attribs = ("switch"); my @entries = $table->getAllAttribs(@attribs); $table->close(); my %allrecords; - foreach (@entries) + foreach (@entries) { - if ($_->{'switch'}){ - $allrecords{$_->{'switch'}} = 0; + + if ($_->{'switch'}) { + $allrecords{ $_->{'switch'} } = 0; } } return \%allrecords; @@ -613,15 +616,15 @@ sub get_db_switches #------------------------------------------------------------------------------- sub get_db_switchports { - my $class = shift; - my $table = xCAT::Table->new("switch"); + my $class = shift; + my $table = xCAT::Table->new("switch"); my @attribs = ("switch", "port"); my @entries = $table->getAllAttribs(@attribs); $table->close(); my %allrecords; - foreach (@entries) + foreach (@entries) { - $allrecords{$_->{'switch'} . "_" . $_->{'port'}} = 0; + $allrecords{ $_->{'switch'} . "_" . $_->{'port'} } = 0; } return \%allrecords; } @@ -648,9 +651,9 @@ sub get_all_cecs my $ppctab = xCAT::Table->new('ppc'); my @cecs = $ppctab->getAllAttribsWhere("nodetype = 'cec'", 'node'); foreach (@cecs) { - if($_->{'node'}) { + if ($_->{'node'}) { if ($hashref) { - $cecshash{$_->{'node'}} = 1; + $cecshash{ $_->{'node'} } = 1; } else { push @cecslist, $_->{'node'}; } @@ -658,7 +661,7 @@ sub get_all_cecs } $ppctab->close(); - # Return the ref accordingly + # Return the ref accordingly if ($hashref) { return \%cecshash; } else { @@ -667,7 +670,7 @@ sub get_all_cecs } #------------------------------------------------------------------------------- - + =head3 get_all_lparids Description : Get all LPAR ids in system. Arguments : ref of all cecs @@ -679,22 +682,22 @@ sub get_all_cecs #------------------------------------------------------------------------------- sub get_all_lparids { - my $class= shift; + my $class = shift; my $cecsref = shift; my %allcecs = %$cecsref; my %lparids; my $ppctab = xCAT::Table->new('ppc'); - foreach my $cec (keys %allcecs) { + foreach my $cec (keys %allcecs) { my @ids = $ppctab->getAllAttribsWhere("hcp = '$cec'", 'id'); foreach (@ids) { - if ( $_->{'id'} ){ - $lparids{$cec}{$_->{'id'}} = 0; + if ($_->{'id'}) { + $lparids{$cec}{ $_->{'id'} } = 0; } } } $ppctab->close(); - + return \%lparids; } @@ -712,7 +715,7 @@ sub get_all_lparids sub is_discover_started { my @sitevalues = xCAT::TableUtils->get_site_attribute("__PCMDiscover"); - if (! $sitevalues[0]){ + if (!$sitevalues[0]) { return 0; } return 1; @@ -734,31 +737,34 @@ sub is_discover_started sub get_nodes_profiles { - my $class = shift; - my $nodelistref = shift; + my $class = shift; + my $nodelistref = shift; my $groupnamemode = shift; my %profile_dict; - my $nodelisttab = xCAT::Table->new('nodelist'); + my $nodelisttab = xCAT::Table->new('nodelist'); my $groupshashref = $nodelisttab->getNodesAttribs($nodelistref, ['groups']); - my %groupshash = %$groupshashref; + my %groupshash = %$groupshashref; - foreach (keys %groupshash){ - my $value = $groupshash{$_}; + foreach (keys %groupshash) { + my $value = $groupshash{$_}; my $groups = $value->[0]->{'groups'}; + # groups looks like "__Managed,__NetworkProfile_default_cn,__ImageProfile_rhels6.3-x86_64-install-compute" my @grouplist = split(',', $groups); my @profilelist = ("NetworkProfile", "ImageProfile", "HardwareProfile"); - foreach my $group (@grouplist){ - foreach my $profile (@profilelist){ - my $idx = index ($group, $profile); + foreach my $group (@grouplist) { + foreach my $profile (@profilelist) { + my $idx = index($group, $profile); + # The Group starts with __, so index will be 2. - if ( $idx == 2 ){ + if ($idx == 2) { + # The group string will like @NetworkProfile_ # So, index should +3, 2 for '__', 1 for _. - if ($groupnamemode) { + if ($groupnamemode) { $profile_dict{$_}{$profile} = $group; - } else{ + } else { my $append_index = length($profile) + 3; $profile_dict{$_}{$profile} = substr $group, $append_index; } @@ -785,11 +791,11 @@ sub get_imageprofile_prov_method # For imageprofile, we can get node's provisioning method through: # nodetype table: node (imageprofile name), provmethod (osimage name) # osimage table: imagename (osimage name), provmethod (node deploy method: install, netboot...) - my $class = shift; + my $class = shift; my $imgprofilename = shift; my $nodetypestab = xCAT::Table->new('nodetype'); - my $entry = ($nodetypestab->getAllAttribsWhere("node = '$imgprofilename'", 'ALL' ))[0]; + my $entry = ($nodetypestab->getAllAttribsWhere("node = '$imgprofilename'", 'ALL'))[0]; return $entry->{'provmethod'}; #my $osimgtab = xCAT::Table->new('osimage'); @@ -809,12 +815,12 @@ sub get_imageprofile_prov_method sub get_imageprofile_prov_osvers { - my $class = shift; + my $class = shift; my $imgprofilename = shift; - my $osimgtab = xCAT::Table->new('osimage'); - my $osimgentry = ($osimgtab->getAllAttribsWhere("imagename = '$imgprofilename'", 'ALL' ))[0]; + my $osimgtab = xCAT::Table->new('osimage'); + my $osimgentry = ($osimgtab->getAllAttribsWhere("imagename = '$imgprofilename'", 'ALL'))[0]; my $osversion = $osimgentry->{'osvers'}; - my $profile = $osimgentry->{'profile'}; + my $profile = $osimgentry->{'profile'}; return ($osversion, $profile); } @@ -831,86 +837,86 @@ sub get_imageprofile_prov_osvers =cut #------------------------------------------------------------------------------- -sub check_profile_consistent{ - my $class = shift; - my $imageprofile = shift; - my $networkprofile = shift; +sub check_profile_consistent { + my $class = shift; + my $imageprofile = shift; + my $networkprofile = shift; my $hardwareprofile = shift; - + # Check the profiles are existing in DB. my @nodegrps = xCAT::TableUtils->list_all_node_groups(); - unless(grep{ $_ eq $imageprofile} @nodegrps){ + unless (grep { $_ eq $imageprofile } @nodegrps) { return 0, "Image profile not defined in DB." } - unless(grep{ $_ eq $networkprofile} @nodegrps){ + unless (grep { $_ eq $networkprofile } @nodegrps) { return 0, "Network profile not defined in DB." } - if ($hardwareprofile){ - unless(grep{ $_ eq $hardwareprofile} @nodegrps){ + if ($hardwareprofile) { + unless (grep { $_ eq $hardwareprofile } @nodegrps) { return 0, "Hardware profile not defined in DB." } } # Get Imageprofile arch my $nodetypetab = xCAT::Table->new('nodetype'); - my $nodetypeentry = $nodetypetab->getNodeAttribs($imageprofile, ['os','arch']); - my $os = $nodetypeentry->{'os'}; + my $nodetypeentry = $nodetypetab->getNodeAttribs($imageprofile, [ 'os', 'arch' ]); + my $os = $nodetypeentry->{'os'}; my $arch = $nodetypeentry->{'arch'}; $nodetypetab->close(); - + # Get Imageprofile pkgdir my $osdistroname = $os . "-" . $arch; - my $osdistrotab = xCAT::Table->new('osdistro'); - my $osdistroentry = ($osdistrotab->getAllAttribsWhere("osdistroname = '$osdistroname'", 'ALL' ))[0]; + my $osdistrotab = xCAT::Table->new('osdistro'); + my $osdistroentry = ($osdistrotab->getAllAttribsWhere("osdistroname = '$osdistroname'", 'ALL'))[0]; my $pkgdir = $osdistroentry->{'dirpaths'}; $osdistrotab->close(); - + # Get networkprofile netboot and installnic my $noderestab = xCAT::Table->new('noderes'); - my $noderesentry = $noderestab->getNodeAttribs($networkprofile, ['netboot', 'installnic']); - my $netboot = $noderesentry->{'netboot'}; - my $installnic = $noderesentry->{'installnic'}; + my $noderesentry = $noderestab->getNodeAttribs($networkprofile, [ 'netboot', 'installnic' ]); + my $netboot = $noderesentry->{'netboot'}; + my $installnic = $noderesentry->{'installnic'}; $noderestab->close(); - + # Get networkprofile nictypes my $netprofile_nicshash_ref = xCAT::ProfiledNodeUtils->get_nodes_nic_attrs([$networkprofile])->{$networkprofile}; my %netprofile_nicshash = %$netprofile_nicshash_ref; - my $nictype = undef; + my $nictype = undef; foreach (keys %netprofile_nicshash) { my $value = $netprofile_nicshash{$_}{'type'}; if (($value eq 'FSP') or ($value eq 'BMC')) { $nictype = $value; } } - + #Get hardwareprofile mgt my $nodehmtab = xCAT::Table->new('nodehm'); - my $mgtentry = $nodehmtab->getNodeAttribs($hardwareprofile, ['mgt']); - my $mgt = undef; + my $mgtentry = $nodehmtab->getNodeAttribs($hardwareprofile, ['mgt']); + my $mgt = undef; $mgt = $mgtentry->{'mgt'} if ($mgtentry->{'mgt'}); $nodehmtab->close(); #Get hardwareprofile nodetype - my $ppctab = xCAT::Table->new('ppc'); - my $ntentry = $ppctab->getNodeAttribs($hardwareprofile, ['nodetype']); + my $ppctab = xCAT::Table->new('ppc'); + my $ntentry = $ppctab->getNodeAttribs($hardwareprofile, ['nodetype']); my $nodetype = undef; $nodetype = $ntentry->{'nodetype'} if ($ntentry->{'nodetype'}); - $ppctab->close(); - + $ppctab->close(); + # Checking whether netboot initrd image for Ubuntu ppc64 # This image should be downloaded from internet - if ($arch =~ /ppc64/i and $os =~ /ubuntu/i and !(-e "$pkgdir/install/netboot/initrd.gz")){ + if ($arch =~ /ppc64/i and $os =~ /ubuntu/i and !(-e "$pkgdir/install/netboot/initrd.gz")) { return 0, "The netboot initrd is not found in $pkgdir/install/netboot, please download it firstly."; } - + # Check if exists provision network - if (not ($installnic and exists $netprofile_nicshash{$installnic}{"network"})){ + if (not($installnic and exists $netprofile_nicshash{$installnic}{"network"})) { return 0, "Provisioning network not defined for network profile." } # Remove check mechanism about arch and netboot attribute # Attribute 'neboot' will be generated based on arch, management method, os - + # Profile consistent keys, arch=>netboot, mgt=>nictype #my $ppc_netboot = 'yaboot'; #if( $os =~ /rhels7/ ){ @@ -923,38 +929,39 @@ sub check_profile_consistent{ #if ($profile_dict{$arch} ne $netboot) { # return 0, "Imageprofile's arch is not consistent with networkprofile's netboot." #} - + # Check if networkprofile is consistent with hardwareprofile - if (not $hardwareprofile) { # Not define hardwareprofile - if (not $nictype) { # Networkprofile is not fsp or bmc + if (not $hardwareprofile) { # Not define hardwareprofile + if (not $nictype) { # Networkprofile is not fsp or bmc return 1, ""; - }elsif ($nictype eq 'FSP' or $nictype eq 'BMC') { + } elsif ($nictype eq 'FSP' or $nictype eq 'BMC') { return 0, "$nictype networkprofile must use with hardwareprofile."; } } - + my %mgt_dict = ('fsp' => 'FSP', 'ipmi' => 'BMC', 'kvm' => ''); - + if ($mgt eq 'vm') { return 1, ""; } - + if ($nodetype eq 'lpar') { if ($nictype) { + # Can not associate FSP/BMC network if the node type is lpar return 0, "The node with hardware type $nodetype can not use with $nictype networkprofile."; } return 1, "" } - + if ($mgt and $mgt_dict{$mgt} ne $nictype) { my $errmsg = "$mgt hardwareprofile must use with $mgt_dict{$mgt} networkprofile."; - if ( $mgt eq 'kvm' ) { + if ($mgt eq 'kvm') { $errmsg = "$mgt hardwareprofile must use with non-BMC and non-FSP networkprofile." } return 0, $errmsg; } - + return 1, ""; } @@ -970,22 +977,22 @@ sub check_profile_consistent{ #------------------------------------------------------------------------------- sub is_fsp_node { - my $class = shift; - my $node = shift; + my $class = shift; + my $node = shift; my $nicstab = xCAT::Table->new('nics'); - my $entry = $nicstab->getNodeAttribs($node, ['nictypes']); + my $entry = $nicstab->getNodeAttribs($node, ['nictypes']); $nicstab->close(); - - if ($entry->{'nictypes'}){ + + if ($entry->{'nictypes'}) { my @nicattrslist = split(",", $entry->{'nictypes'}); - foreach (@nicattrslist){ - my @nicattrs; - if ($_ =~ /!/) { - @nicattrs = split("!", $_); - } else { - @nicattrs = split(":", $_); - } - if ($nicattrs[1] eq 'FSP'){ + foreach (@nicattrslist) { + my @nicattrs; + if ($_ =~ /!/) { + @nicattrs = split("!", $_); + } else { + @nicattrs = split(":", $_); + } + if ($nicattrs[1] eq 'FSP') { return 1; } } @@ -1006,24 +1013,24 @@ sub is_fsp_node #------------------------------------------------------------------------------- sub is_kvm_node { - my $class = shift; + my $class = shift; my $hardwareprofile = shift; - + if (not $hardwareprofile) { return 0; } - + #Get hardwareprofile mgt my $nodehmtab = xCAT::Table->new('nodehm'); - my $mgtentry = $nodehmtab->getNodeAttribs($hardwareprofile, ['mgt']); - my $mgt = undef; + my $mgtentry = $nodehmtab->getNodeAttribs($hardwareprofile, ['mgt']); + my $mgt = undef; $mgt = $mgtentry->{'mgt'} if ($mgtentry->{'mgt'}); $nodehmtab->close(); - + if ($mgt eq 'kvm') { return 1; - } - + } + return 0; } @@ -1039,24 +1046,24 @@ sub is_kvm_node #------------------------------------------------------------------------------- sub is_kvm_hypv_node { - my $class = shift; + my $class = shift; my $imageprofile = shift; - + # Get provmethod my $provmethod = xCAT::ProfiledNodeUtils->get_imageprofile_prov_method($imageprofile); - unless ($provmethod ){ + unless ($provmethod) { return 0; } - + my $osimage_tab = xCAT::Table->new('osimage'); - my $osimage_tab_entry = $osimage_tab->getAttribs({'imagename'=> $provmethod},('osdistroname')); + my $osimage_tab_entry = $osimage_tab->getAttribs({ 'imagename' => $provmethod }, ('osdistroname')); my $osdistroname = $osimage_tab_entry->{'osdistroname'}; $osimage_tab->close(); - - if ($osdistroname and $osdistroname =~ /^pkvm/ ) { + + if ($osdistroname and $osdistroname =~ /^pkvm/) { return 1; } - + return 0; } @@ -1075,22 +1082,22 @@ sub is_kvm_hypv_node #------------------------------------------------------------------------------- sub get_nodes_cmm { - my $class = shift; + my $class = shift; my $nodelistref = shift; - my @nodes = @$nodelistref; + my @nodes = @$nodelistref; my %returncmm; - + my $mptab = xCAT::Table->new('mp'); my $entry = $mptab->getNodesAttribs($nodelistref, ['mpa']); $mptab->close(); - + foreach (@nodes) { my $mpa = $entry->{$_}->[0]->{'mpa'}; - if ($mpa and not exists $returncmm{$mpa}){ + if ($mpa and not exists $returncmm{$mpa}) { $returncmm{$mpa} = 1; } } - + return \%returncmm } @@ -1111,39 +1118,41 @@ sub get_nodes_cmm #------------------------------------------------------------------------------- sub parse_nodeinfo_file { - my($class, $filedata) = @_; + my ($class, $filedata) = @_; @::profiledNodeObjNames = (); - %::profiledNodeAttrs = (); + %::profiledNodeAttrs = (); - my @lines = split /\n/, $filedata; - my $obj_found = 0; + my @lines = split /\n/, $filedata; + my $obj_found = 0; my $attr_found = 0; my $null_obj; my ($objname, $append); - foreach my $line (@lines){ + foreach my $line (@lines) { + # skip blank and comment lines next if ($line =~ /^\s*$/ || $line =~ /^\s*#/); # The line ends with : - if (grep(/:\s*$/, $line)){ + if (grep(/:\s*$/, $line)) { $attr_found = 0; - $null_obj = $line; + $null_obj = $line; ($objname, $append) = split(/:/, $line); $objname =~ s/^\s*//; # Remove any leading whitespace $objname =~ s/\s*$//; # Remove any trailing whitespace # OK we've found one object. - if ($objname){ + if ($objname) { $obj_found = 1; push(@::profiledNodeObjNames, $objname); - }else{ + } else { return 0, "No node name defined in line \'$line\'"; } - } # The line has = - elsif (($line =~ /^\s*(.*?)\s*=\s*(.*)\s*/)){ + } # The line has = + elsif (($line =~ /^\s*(.*?)\s*=\s*(.*)\s*/)) { + # No one object clarified yet. So this file format is illegal. - if (! $obj_found){ + if (!$obj_found) { return 0, "No node defined before line \'$line\'"; } $attr_found = 1; @@ -1152,30 +1161,30 @@ sub parse_nodeinfo_file my $val = $2; $attr =~ s/^\s*//; # Remove any leading whitespace $attr =~ s/\s*$//; # Remove any trailing whitespace - $val =~ s/^\s*//; - $val =~ s/\s*$//; + $val =~ s/^\s*//; + $val =~ s/\s*$//; # remove spaces and quotes $val =~ s/^\s*"\s*//; $val =~ s/\s*"\s*$//; - if($attr && $val){ + if ($attr && $val) { $::profiledNodeAttrs{$objname}{$attr} = $val; - }else{ + } else { return 0, "Line \'$line\' does not contain a valid key and value"; } - } #invalid line. - else{ + } #invalid line. + else { return 0, "Invalid Line \'$line\' found"; } } - + # Defined object has no attributes - if (! $attr_found){ + if (!$attr_found) { return 0, "Invalid Line \'$null_obj\' found"; } - + return 1, ""; } @@ -1188,6 +1197,7 @@ sub parse_nodeinfo_file $retcode = 1. update failed, the value is undef $retcode = 0. save into db is OK.. =cut + #------------------------------------------------------- sub update_windows_prodkey @@ -1196,24 +1206,26 @@ sub update_windows_prodkey my $node = shift; my $product = shift; my $key = shift; - unless(defined($node) && defined($product) && defined($key)) + unless (defined($node) && defined($product) && defined($key)) { return 1; } + # please notice this db usage my %keyhash; my %updates; - $keyhash{'node'} = $node; - $updates{'product'} = $product; - $updates{'key'} = $key; - my $tab = xCAT::Table->new('prodkey', -create=>1, -autocommit=>0); - $tab->setAttribs( \%keyhash,\%updates ); + $keyhash{'node'} = $node; + $updates{'product'} = $product; + $updates{'key'} = $key; + my $tab = xCAT::Table->new('prodkey', -create => 1, -autocommit => 0); + $tab->setAttribs(\%keyhash, \%updates); $tab->commit; - $tab->close; + $tab->close; return 0; } #------------------------------------------------------------------------------- + =head3 check_nicips Description: Check if the nicips defined in MAC file is correct format @@ -1226,63 +1238,65 @@ sub update_windows_prodkey $retcode = 0. Parse success, the format of nicips is OK.. =cut + #------------------------------------------------------------------------------- -sub check_nicips{ - my $class = shift; - my $installnic = shift; +sub check_nicips { + my $class = shift; + my $installnic = shift; my $netprofileattrsref = shift; - my $freeipshash = shift; - my $othernics = shift; - - my $errmsg = ""; - my %nics_hash = (); + my $freeipshash = shift; + my $othernics = shift; + + my $errmsg = ""; + my %nics_hash = (); my %netprofileattr = %$netprofileattrsref; - + foreach my $nic_ips (split(/,/, $othernics)) { my @nic_and_ips = (); - my $nic = ""; - my $nic_ip = ""; - if($nic_ips =~ /!/ and $nic_ips !~ /!$/) { + my $nic = ""; + my $nic_ip = ""; + if ($nic_ips =~ /!/ and $nic_ips !~ /!$/) { @nic_and_ips = split(/!/, $nic_ips); my $len = @nic_and_ips; - $nic = $nic_and_ips[0]; + $nic = $nic_and_ips[0]; $nic_ip = $nic_and_ips[1]; - + if (exists $nics_hash{$nic} or $len ne 2) { $errmsg = "The specified nicips is incorrect. It must be formatted correctly, in the form: !,!,..."; return (1, "", $errmsg); } - + # Check whether other interfaces contain provision nic if ($nic eq $installnic) { $errmsg = "The specified nicips cannot contain NICs used for provisioning."; return (1, "", $errmsg); } - + # Check whether this interface is defined in networkprofile - unless (exists $netprofileattr{$nic}){ + unless (exists $netprofileattr{$nic}) { $errmsg = "The specified nicips contains NICs that are not defined in the network profile."; return (1, "", $errmsg); } - + # Check whether specified IP is in each network's static range my $nicnetwork = $netprofileattr{$nic}{'network'}; my $freeipsref = $freeipshash->{$nicnetwork}; - unless (grep{ $_ eq $nic_ip} @$freeipsref){ + unless (grep { $_ eq $nic_ip } @$freeipsref) { $errmsg = "Specified IP address $nic_ip not in static range of network $netprofileattr{$nic}{'network'}"; return (1, "", $errmsg); } - }else { + } else { $errmsg = "The specified nicips is incorrect. It must be formatted correctly, in the form: !,!,..."; return (1, "", $errmsg); } $nics_hash{$nic} = $nic_ip; } - + return (0, \%nics_hash, ""); } #------------------------------------------------------------------------------- + =head3 gen_chain_for_profiles Description: Generate a chain string based on Network/Hardware/Image profiles. Arguments: $profiles_hash: The reference for profiles hash. @@ -1298,36 +1312,38 @@ sub check_nicips{ $retcode = 0. Generate chain OK. $chain stands for the chain string. =cut + #------------------------------------------------------------------------------- -sub gen_chain_for_profiles{ - my $class = shift; +sub gen_chain_for_profiles { + my $class = shift; my $profiles_hashref = shift; - my $hw_reconfig = shift; - my $final_chain = ""; - if (! $profiles_hashref){ + my $hw_reconfig = shift; + my $final_chain = ""; + if (!$profiles_hashref) { return (1, "Missing parameter for gen_chain_for_profiles."); } + # A node must have at least imageprofile and network profile. - unless (defined $profiles_hashref->{'ImageProfile'}){ + unless (defined $profiles_hashref->{'ImageProfile'}) { return (1, "No imageprofile specified in profiles hash."); } - unless (defined $profiles_hashref->{'NetworkProfile'}){ + unless (defined $profiles_hashref->{'NetworkProfile'}) { return (1, "No networkprofile specified in profiles hash."); } - my $hwprofile = $profiles_hashref->{'HardwareProfile'}; + my $hwprofile = $profiles_hashref->{'HardwareProfile'}; my $imgprofile = $profiles_hashref->{'ImageProfile'}; my $netprofile = $profiles_hashref->{'NetworkProfile'}; # Get node's provisioning method my $provmethod = xCAT::ProfiledNodeUtils->get_imageprofile_prov_method($imgprofile); - unless ($provmethod ){ + unless ($provmethod) { return (1, "Can not get provisioning method for image profile $imgprofile"); } my $netprofileattr = xCAT::ProfiledNodeUtils->get_nodes_nic_attrs([$netprofile])->{$netprofile}; - unless ($netprofileattr){ + unless ($netprofileattr) { return (1, "Can not get attributes for network profile $netprofile"); } - + # Get node's netboot attribute my ($retcode, $retval) = xCAT::ProfiledNodeUtils->get_netboot_attr($imgprofile, $hwprofile); if (not $retcode) { @@ -1335,34 +1351,36 @@ sub gen_chain_for_profiles{ } my $netboot = $retval; - $final_chain = 'osimage='.$provmethod.":--noupdateinitrd"; + $final_chain = 'osimage=' . $provmethod . ":--noupdateinitrd"; + # get the chain attribute from hardwareprofile and insert it to node. - if (defined $hwprofile and $hwprofile and $hw_reconfig){ + if (defined $hwprofile and $hwprofile and $hw_reconfig) { my $chaintab = xCAT::Table->new('chain'); my $chain = $chaintab->getNodeAttribs($hwprofile, ['chain']); if (exists $chain->{'chain'}) { - my $hw_chain = $chain->{'chain'}; - $final_chain = $hw_chain.',osimage='.$provmethod.":--noupdateinitrd"; + my $hw_chain = $chain->{'chain'}; + $final_chain = $hw_chain . ',osimage=' . $provmethod . ":--noupdateinitrd"; } } + #run bmcsetups. #PowerNV nodes can't use 'runcmd=bmcsetup' to set BMC. #But OpenPower need to support bmcsetup - my $nodehmtab = xCAT::Table->new('nodehm'); - my $comments = ""; + my $nodehmtab = xCAT::Table->new('nodehm'); + my $comments = ""; my $nodehmtab_entry = $nodehmtab->getNodeAttribs($hwprofile, ['comments']); if (defined $nodehmtab_entry->{'comments'}) { - $comments = $nodehmtab_entry->{'comments'}; + $comments = $nodehmtab_entry->{'comments'}; } - if ((exists $netprofileattr->{"bmc"}) and $hw_reconfig){ + if ((exists $netprofileattr->{"bmc"}) and $hw_reconfig) { if ((($netboot eq 'petitboot') and ($comments eq 'openpower')) or ($netboot ne 'petitboot')) { - if (index($final_chain, "runcmd=bmcsetup") == -1){ - $final_chain = 'runcmd=bmcsetup,'.$final_chain.':reboot4deploy'; + if (index($final_chain, "runcmd=bmcsetup") == -1) { + $final_chain = 'runcmd=bmcsetup,' . $final_chain . ':reboot4deploy'; } - else{ - $final_chain = $final_chain.':reboot4deploy'; + else { + $final_chain = $final_chain . ':reboot4deploy'; } } } @@ -1385,16 +1403,17 @@ sub get_all_vmhosts my %vmhostshash; my $nodelisttab = xCAT::Table->new('nodelist'); + # groups like '__Hypervisor_pkvm' means this node is Power KVM hypervisor my @vmhosts = $nodelisttab->getAllAttribsWhere("groups like '%__Hypervisor_kvm%'", 'node'); foreach (@vmhosts) { - if($_->{'node'}) { - $vmhostshash{$_->{'node'}} = 1; + if ($_->{'node'}) { + $vmhostshash{ $_->{'node'} } = 1; } } $nodelisttab->close(); - # Return the ref accordingly + # Return the ref accordingly return \%vmhostshash; } @@ -1410,21 +1429,21 @@ sub get_all_vmhosts =cut #------------------------------------------------------------------------------- -sub get_netboot_attr{ - my $class = shift; - my $imageprofile = shift; +sub get_netboot_attr { + my $class = shift; + my $imageprofile = shift; my $hardwareprofile = shift; my $netboot; my @nodegrps = xCAT::TableUtils->list_all_node_groups(); - unless(grep{ $_ eq $imageprofile} @nodegrps) + unless (grep { $_ eq $imageprofile } @nodegrps) { return 0, "Image profile not defined in DB." } $imageprofile =~ s/^__ImageProfile_//; - if ($hardwareprofile){ - unless(grep{ $_ eq $hardwareprofile} @nodegrps) + if ($hardwareprofile) { + unless (grep { $_ eq $hardwareprofile } @nodegrps) { return 0, "Hardware profile not defined in DB." } @@ -1436,15 +1455,15 @@ sub get_netboot_attr{ # Get os name, os major version, osarch my $osimage_tab = xCAT::Table->new('osimage'); - my $osimage_tab_entry = $osimage_tab->getAttribs({'imagename'=> $imageprofile},('osdistroname')); + my $osimage_tab_entry = $osimage_tab->getAttribs({ 'imagename' => $imageprofile }, ('osdistroname')); my $osdistroname = $osimage_tab_entry->{'osdistroname'}; $osimage_tab->close(); my $osdistro_tab = xCAT::Table->new('osdistro'); - my $osdistro_tab_entry = $osdistro_tab->getAttribs({'osdistroname'=> $osdistroname},('basename', 'majorversion', 'arch')); - my $os_name = $osdistro_tab_entry->{'basename'}; + my $osdistro_tab_entry = $osdistro_tab->getAttribs({ 'osdistroname' => $osdistroname }, ('basename', 'majorversion', 'arch')); + my $os_name = $osdistro_tab_entry->{'basename'}; my $os_major_version = $osdistro_tab_entry->{'majorversion'}; - my $os_arch = $osdistro_tab_entry->{'arch'}; + my $os_arch = $osdistro_tab_entry->{'arch'}; $osdistro_tab->close; # Treate os name rhel,centos,rhelhpc same as rhels @@ -1452,17 +1471,18 @@ sub get_netboot_attr{ { $os_name = 'rhels'; } + # Treate arch ppc64el same as ppc64le,x86 same as x86_64 if ($os_arch eq 'ppc64el') { $os_arch = 'ppc64le'; - }elsif ($os_arch eq 'x86') + } elsif ($os_arch eq 'x86') { $os_arch = 'x86_64'; } - + # Identify whether this node is PowerKVM or PowerNV if os arch is ppc64le - # If hardware profile is defined + # If hardware profile is defined my $mgt = '*'; if ($os_arch eq 'ppc64le' and $hardwareprofile ne '*') { my $nodehmtab = xCAT::Table->new('nodehm'); @@ -1471,47 +1491,48 @@ sub get_netboot_attr{ $mgt = $nodehmtab_entry->{'mgt'}; } } - -# Rule for netboot attribute.If update the rule,just update %netboot_dict and @condition_array -# It's sequence sensitive: os arch -> os name -> os major version -> hardware profile -# Priority | Arch | OS Name | OS Major Version | Management method | Noderes.netboot | -# 1 | x86_64/x86 | * | * | * | xnba | -# 2 | ppc64 | rhels | 7 | * | grub2 | -# 2 | ppc64 | pkvm | * | * | petitboot | -# 3 | | * | * | * | yaboot | -# 4 | ppc64le/el | * | * | * | grub2 -# 4 | ppc64le/el | * | * | ipmi | petitboot -# arch osname version hardware netboot - my %netboot_dict = ( 'x86_64' => 'xnba', - 'ppc64' => { - 'rhels' => { - '7' => 'grub2', - '*' => 'yaboot', - }, - 'pkvm' => 'petitboot', - '*' => 'yaboot', - }, - 'ppc64le' => { - '*' => { - '*' => { - '*' => 'grub2', - 'ipmi' => 'petitboot', - }, - }, - }, - ); - my $condition_array_ref = [$os_arch, $os_name, $os_major_version, $mgt]; + + # Rule for netboot attribute.If update the rule,just update %netboot_dict and @condition_array + # It's sequence sensitive: os arch -> os name -> os major version -> hardware profile + # Priority | Arch | OS Name | OS Major Version | Management method | Noderes.netboot | + # 1 | x86_64/x86 | * | * | * | xnba | + # 2 | ppc64 | rhels | 7 | * | grub2 | + # 2 | ppc64 | pkvm | * | * | petitboot | + # 3 | | * | * | * | yaboot | + # 4 | ppc64le/el | * | * | * | grub2 + # 4 | ppc64le/el | * | * | ipmi | petitboot + # arch osname version hardware netboot + my %netboot_dict = ('x86_64' => 'xnba', + 'ppc64' => { + 'rhels' => { + '7' => 'grub2', + '*' => 'yaboot', + }, + 'pkvm' => 'petitboot', + '*' => 'yaboot', + }, + 'ppc64le' => { + '*' => { + '*' => { + '*' => 'grub2', + 'ipmi' => 'petitboot', + }, + }, + }, + ); + my $condition_array_ref = [ $os_arch, $os_name, $os_major_version, $mgt ]; $netboot = cal_netboot(\%netboot_dict, $condition_array_ref); - if($netboot eq '0') + if ($netboot eq '0') { return 0, "Can not get the netboot attribute"; } else - { + { return 1, $netboot; } } + #------------------------------------------------------------------------------- =head3 cal_netboot @@ -1523,25 +1544,25 @@ sub get_netboot_attr{ =cut #------------------------------------------------------------------------------- -sub cal_netboot{ - my $netboot_dict_ref = shift; +sub cal_netboot { + my $netboot_dict_ref = shift; my $condition_array_ref = shift; my $condition_array_len = scalar @$condition_array_ref; - - if( $condition_array_len == 0 ){ + + if ($condition_array_len == 0) { return 0; } my $condition = shift @$condition_array_ref; - if( (exists($netboot_dict_ref->{$condition})) || (exists($netboot_dict_ref->{'*'})) ) + if ((exists($netboot_dict_ref->{$condition})) || (exists($netboot_dict_ref->{'*'}))) { - if(!exists($netboot_dict_ref->{$condition})) + if (!exists($netboot_dict_ref->{$condition})) { $condition = '*'; } - if(ref($netboot_dict_ref->{$condition}) eq 'HASH') + if (ref($netboot_dict_ref->{$condition}) eq 'HASH') { - if($condition_array_len > 1) + if ($condition_array_len > 1) { return cal_netboot($netboot_dict_ref->{$condition}, $condition_array_ref); } diff --git a/perl-xCAT/xCAT/RSH.pm b/perl-xCAT/xCAT/RSH.pm index 6fdd03eb3..8a03e9db2 100644 --- a/perl-xCAT/xCAT/RSH.pm +++ b/perl-xCAT/xCAT/RSH.pm @@ -2,6 +2,7 @@ # IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html package xCAT::RSH; + # cannot use strict # cannot use strict use base xCAT::DSHRemoteShell; @@ -9,14 +10,14 @@ use base xCAT::DSHRemoteShell; # Determine if OS is AIX or Linux # Configure standard locations of commands based on OS -if ( $^O eq 'aix' ) { - our $RCP_CMD = '/bin/rcp'; - our $RSH_CMD = '/bin/rsh'; +if ($^O eq 'aix') { + our $RCP_CMD = '/bin/rcp'; + our $RSH_CMD = '/bin/rsh'; } -if ( $^O eq 'linux' ) { - our $RCP_CMD = '/usr/bin/rcp'; - our $RSH_CMD = '/usr/bin/rsh'; +if ($^O eq 'linux') { + our $RCP_CMD = '/usr/bin/rcp'; + our $RSH_CMD = '/usr/bin/rsh'; } =head3 @@ -53,28 +54,28 @@ if ( $^O eq 'linux' ) { =cut sub remote_shell_command { - my ( $class, $config, $exec_path ) = @_; + my ($class, $config, $exec_path) = @_; - $exec_path || ( $exec_path = $RSH_CMD ); + $exec_path || ($exec_path = $RSH_CMD); - my @command = (); + my @command = (); - push @command, $exec_path; - push @command, $$config{'hostname'}; + push @command, $exec_path; + push @command, $$config{'hostname'}; - if ( $$config{'user'} ) { - push @command, '-l'; - push @command, $$config{'user'}; - } + if ($$config{'user'}) { + push @command, '-l'; + push @command, $$config{'user'}; + } - if ( $$config{'options'} ) { - my @options = split ' ', $$config{'options'}; - push @command, @options; - } + if ($$config{'options'}) { + my @options = split ' ', $$config{'options'}; + push @command, @options; + } - push @command, $$config{'command'}; + push @command, $$config{'command'}; - return @command; + return @command; } =head3 @@ -117,41 +118,41 @@ sub remote_shell_command { =cut sub remote_copy_command { - my ( $class, $config, $exec_path ) = @_; + my ($class, $config, $exec_path) = @_; - $exec_path || ( $exec_path = $RCP_CMD ); + $exec_path || ($exec_path = $RCP_CMD); - my @command = (); - my @src_files = (); - my @dest_file = (); + my @command = (); + my @src_files = (); + my @dest_file = (); - my @src_file_list = split $::__DCP_DELIM, $$config{'src-file'}; + my @src_file_list = split $::__DCP_DELIM, $$config{'src-file'}; - foreach $src_file (@src_file_list) { - my @src_path = (); - $$config{'src-user'} && push @src_path, "$$config{'src-user'}@"; - $$config{'src-host'} && push @src_path, "$$config{'src-host'}:"; - $$config{'src-file'} && push @src_path, $src_file; - push @src_files, ( join '', @src_path ); - } + foreach $src_file (@src_file_list) { + my @src_path = (); + $$config{'src-user'} && push @src_path, "$$config{'src-user'}@"; + $$config{'src-host'} && push @src_path, "$$config{'src-host'}:"; + $$config{'src-file'} && push @src_path, $src_file; + push @src_files, (join '', @src_path); + } - $$config{'dest-user'} && push @dest_file, "$$config{'dest-user'}@"; - $$config{'dest-host'} && push @dest_file, "$$config{'dest-host'}:"; - $$config{'dest-file'} && push @dest_file, $$config{'dest-file'}; + $$config{'dest-user'} && push @dest_file, "$$config{'dest-user'}@"; + $$config{'dest-host'} && push @dest_file, "$$config{'dest-host'}:"; + $$config{'dest-file'} && push @dest_file, $$config{'dest-file'}; - push @command, $exec_path; - $$config{'preserve'} && push @command, '-p'; - $$config{'recursive'} && push @command, '-r'; + push @command, $exec_path; + $$config{'preserve'} && push @command, '-p'; + $$config{'recursive'} && push @command, '-r'; - if ( $$config{'options'} ) { - my @options = split ' ', $$config{'options'}; - push @command, @options; - } + if ($$config{'options'}) { + my @options = split ' ', $$config{'options'}; + push @command, @options; + } - push @command, @src_files; - push @command, ( join '', @dest_file ); + push @command, @src_files; + push @command, (join '', @dest_file); - return @command; + return @command; } 1; diff --git a/perl-xCAT/xCAT/RSYNC.pm b/perl-xCAT/xCAT/RSYNC.pm index 52b0725f4..b40158d80 100644 --- a/perl-xCAT/xCAT/RSYNC.pm +++ b/perl-xCAT/xCAT/RSYNC.pm @@ -6,6 +6,7 @@ package xCAT::RSYNC; # cannot use strict use base xCAT::DSHRemoteShell; use xCAT::TableUtils qw(get_site_attribute); + # Determine if OS is AIX or Linux # Configure standard locations of commands based on OS @@ -13,9 +14,9 @@ if ($^O eq 'aix') { if (-e ("/usr/bin/rsync")) { - our $RSYNC_CMD = '/usr/bin/rsync'; + our $RSYNC_CMD = '/usr/bin/rsync'; } else { - our $RSYNC_CMD = '/usr/local/bin/rsync'; + our $RSYNC_CMD = '/usr/local/bin/rsync'; } } @@ -23,6 +24,7 @@ if ($^O eq 'linux') { our $RSYNC_CMD = '/usr/bin/rsync'; } + #----------------------------------------------------------------------- =head3 @@ -69,22 +71,22 @@ if ($^O eq 'linux') sub remote_copy_command { - my ($class, $config, $exec_path,$localhost) = @_; + my ($class, $config, $exec_path, $localhost) = @_; $exec_path || ($exec_path = $RSYNC_CMD); # see if we are using rsh or ssh on AIX - my $usersh=0; + my $usersh = 0; if ($^O eq 'aix') { - my @useSSH = xCAT::TableUtils->get_site_attribute("useSSHonAIX"); - if (defined($useSSH[0])) { - $useSSH[0] =~ tr/a-z/A-Z/; # convert to upper - if (($useSSH[0] eq "0") || ($useSSH[0] eq "NO")) - { - $usersh=1; + my @useSSH = xCAT::TableUtils->get_site_attribute("useSSHonAIX"); + if (defined($useSSH[0])) { + $useSSH[0] =~ tr/a-z/A-Z/; # convert to upper + if (($useSSH[0] eq "0") || ($useSSH[0] eq "NO")) + { + $usersh = 1; + } } - } } @@ -97,46 +99,47 @@ sub remote_copy_command if ($^O eq 'aix') { if (-e ("/usr/bin/rsync")) { - if (($usersh == 0) || ($localhost == 1)) { # using ssh, or local - if ($$config{'sudo'}){ - $sync_opt = '--rsync-path=sudo /usr/bin/rsync '; - } else { - $sync_opt = '--rsync-path /usr/bin/rsync '; - } - } else { - $sync_opt = '--rsh /bin/rsh --rsync-path /usr/bin/rsync '; - } + if (($usersh == 0) || ($localhost == 1)) { # using ssh, or local + if ($$config{'sudo'}) { + $sync_opt = '--rsync-path=sudo /usr/bin/rsync '; + } else { + $sync_opt = '--rsync-path /usr/bin/rsync '; + } + } else { + $sync_opt = '--rsh /bin/rsh --rsync-path /usr/bin/rsync '; + } } else { - if (($usersh == 0) || ($localhost == 1)) { # using ssh, or local - if ($$config{'sudo'}){ - $sync_opt = '--rsync-path=sudo /usr/local/bin/rsync '; - } else { - $sync_opt = '--rsync-path=/usr/local/bin/rsync '; - } - } else { - $sync_opt = '--rsh /bin/rsh --rsync-path /usr/local/bin/rsync '; - } + if (($usersh == 0) || ($localhost == 1)) { # using ssh, or local + if ($$config{'sudo'}) { + $sync_opt = '--rsync-path=sudo /usr/local/bin/rsync '; + } else { + $sync_opt = '--rsync-path=/usr/local/bin/rsync '; + } + } else { + $sync_opt = '--rsh /bin/rsh --rsync-path /usr/local/bin/rsync '; + } } } - else #linux + else #linux { - if ($$config{'sudo'}) { - $sync_opt = '--rsync-path=\'sudo /usr/bin/rsync\' '; - } else { - $sync_opt = '--rsync-path /usr/bin/rsync '; - } + if ($$config{'sudo'}) { + $sync_opt = '--rsync-path=\'sudo /usr/bin/rsync\' '; + } else { + $sync_opt = '--rsync-path /usr/bin/rsync '; + } } + # if only syncing the service node or # (no postscripts and no append lines) then do not # get update file notification - if (($::SYNCSN == 1) || ((!(@::postscripts)) && (!(@::appendlines)) && (!(@::mergelines)))) { - $sync_opt .= '-Lprogtz '; + if (($::SYNCSN == 1) || ((!(@::postscripts)) && (!(@::appendlines)) && (!(@::mergelines)))) { + $sync_opt .= '-Lprogtz '; } else { - $sync_opt .= '-Liprogtz --out-format=%f%L '; # add notify of update + $sync_opt .= '-Liprogtz --out-format=%f%L '; # add notify of update } $sync_opt .= $$config{'options'}; if ($::SYNCSN == 1) - { # syncing service node + { # syncing service node $rsyncfile = "/tmp/rsync_$$config{'dest-host'}"; $rsyncfile .= "_s"; } @@ -146,7 +149,7 @@ sub remote_copy_command } open RSCYCCMDFILE, "> $rsyncfile" or die "Can not open file $rsyncfile"; - my $dest_dir_list = join ' ', keys %{$$config{'destDir_srcFile'}}; + my $dest_dir_list = join ' ', keys %{ $$config{'destDir_srcFile'} }; my $dest_user_host = $$config{'dest-host'}; if ($$config{'dest-user'}) { @@ -154,47 +157,48 @@ sub remote_copy_command "$$config{'dest-user'}@" . "$$config{'dest-host'}"; } print RSCYCCMDFILE "#!/bin/sh\n"; - if ($localhost == 1) { # running to the MN from the MN + if ($localhost == 1) { # running to the MN from the MN print RSCYCCMDFILE "/bin/mkdir -p $dest_dir_list\n"; - } else { # running to another node - if ($usersh == 0) { # using ssh - print RSCYCCMDFILE - "/usr/bin/ssh $dest_user_host '/bin/mkdir -p $dest_dir_list'\n"; - } else { - print RSCYCCMDFILE - "/usr/bin/rsh $dest_user_host '/bin/mkdir -p $dest_dir_list'\n"; - } + } else { # running to another node + if ($usersh == 0) { # using ssh + print RSCYCCMDFILE +"/usr/bin/ssh $dest_user_host '/bin/mkdir -p $dest_dir_list'\n"; + } else { + print RSCYCCMDFILE +"/usr/bin/rsh $dest_user_host '/bin/mkdir -p $dest_dir_list'\n"; + } } - foreach my $dest_dir (keys %{$$config{'destDir_srcFile'}}) + foreach my $dest_dir (keys %{ $$config{'destDir_srcFile'} }) { my @src_file = - @{$$config{'destDir_srcFile'}{$dest_dir}{'same_dest_name'}}; + @{ $$config{'destDir_srcFile'}{$dest_dir}{'same_dest_name'} }; my $src_file_list = join ' ', @src_file; if ($src_file_list) { - if ($localhost == 1) { # running local ( on MN) - print RSCYCCMDFILE - "$exec_path $sync_opt $src_file_list $dest_dir\n"; - } else { # running to another node - print RSCYCCMDFILE - "$exec_path $sync_opt $src_file_list $dest_user_host:$dest_dir\n"; - } + if ($localhost == 1) { # running local ( on MN) + print RSCYCCMDFILE + "$exec_path $sync_opt $src_file_list $dest_dir\n"; + } else { # running to another node + print RSCYCCMDFILE +"$exec_path $sync_opt $src_file_list $dest_user_host:$dest_dir\n"; + } } my %diff_dest_hash = - %{$$config{'destDir_srcFile'}{$dest_dir}{'diff_dest_name'}}; + %{ $$config{'destDir_srcFile'}{$dest_dir}{'diff_dest_name'} }; foreach my $src_file_diff_dest (keys %diff_dest_hash) { my $diff_basename = $diff_dest_hash{$src_file_diff_dest}; + # if localhost do not put in hostname: - if ($localhost == 1) { # running to the MN from the MN (local) - print RSCYCCMDFILE - "$exec_path $sync_opt $src_file_diff_dest $dest_dir/$diff_basename\n"; - } else { # running remote - print RSCYCCMDFILE - "$exec_path $sync_opt $src_file_diff_dest $dest_user_host:$dest_dir/$diff_basename\n"; + if ($localhost == 1) { # running to the MN from the MN (local) + print RSCYCCMDFILE +"$exec_path $sync_opt $src_file_diff_dest $dest_dir/$diff_basename\n"; + } else { # running remote + print RSCYCCMDFILE +"$exec_path $sync_opt $src_file_diff_dest $dest_user_host:$dest_dir/$diff_basename\n"; } } @@ -227,9 +231,9 @@ sub remote_copy_command $$config{'dest-file'} && push @dest_file, $$config{'dest-file'}; push @command, $exec_path; - if ($usersh == 1) { # using rsh - push @command, "--rsh"; - push @command, "/bin/rsh"; + if ($usersh == 1) { # using rsh + push @command, "--rsh"; + push @command, "/bin/rsh"; } $$config{'preserve'} && push @command, ('-p', '-t'); $$config{'recursive'} && push @command, '-r'; diff --git a/perl-xCAT/xCAT/RemoteShellExp.pm b/perl-xCAT/xCAT/RemoteShellExp.pm index 1991607cb..19ee11541 100755 --- a/perl-xCAT/xCAT/RemoteShellExp.pm +++ b/perl-xCAT/xCAT/RemoteShellExp.pm @@ -69,149 +69,159 @@ use Expect; use strict; #----------------------------------------------------------------------------- -sub remoteshellexp +sub remoteshellexp { - my ($class, $flag, $callback, $remoteshell, $nodes, $timeout) = @_; - my $rc=0; - $::CALLBACK = $callback; - if (!($flag)) - { - my $rsp = {}; - $rsp->{error}->[0] = - "No flag provide to remoteshellexp."; + my ($class, $flag, $callback, $remoteshell, $nodes, $timeout) = @_; + my $rc = 0; + $::CALLBACK = $callback; + if (!($flag)) + { + my $rsp = {}; + $rsp->{error}->[0] = + "No flag provide to remoteshellexp."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 2); return 2; - } - - if (($flag ne "k") && ($flag ne "t") && ($flag ne "s")) { - my $rsp = {}; - $rsp->{error}->[0] = - "Invalid flag $flag provided."; - xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); - return 2; - - } - my $expecttimeout=10; # default - if (defined($timeout)) { # value supplied - $expecttimeout=$timeout; - } - - # for -s flag must have nodes and a $to_userid password - my $to_user_password; - if ($ENV{'DSH_REMOTE_PASSWORD'}) { - $to_user_password=$ENV{'DSH_REMOTE_PASSWORD'}; - } - if ($flag eq "s"){ - if (!$to_user_password) { - my $rsp = {}; - $rsp->{error}->[0] = - "The DSH_REMOTE_PASSWORD environment variable has not been set to the user id password on the node which will have their ssh keys updated (ususally root)."; - xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); - return 2; - } - if (!$nodes) { - my $rsp = {}; - $rsp->{error}->[0] = - "No nodes were input to update the user's ssh keys."; - xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); - return 2; - } - } - my $ssh_setup_cmd; - my $from_userid; - my $to_userid; - my $home; - my $remotecopy; - # if caller input a path to ssh remote command, use it - if ($ENV{'DSH_REMOTE_CMD'}) { - $remoteshell=$ENV{'DSH_REMOTE_CMD'}; - } else { - if (!$remoteshell) { - $remoteshell="/usr/bin/ssh"; } - } - # figure out path to scp - my ($path,$ssh) = split(/ssh/,$remoteshell); - $remotecopy=$path . "scp"; - # if caller input the ssh setup command (such as for IB Switch) - if ($ENV{'SSH_SETUP_COMMAND'}) { - $ssh_setup_cmd=$ENV{'SSH_SETUP_COMMAND'}; - } - # set User on the Management node that has the ssh keys - # this id can be a local (non-root) id as well as root - if ($ENV{'DSH_FROM_USERID'}) { - $from_userid=$ENV{'DSH_FROM_USERID'}; - } else { - $from_userid="root"; - } - # set User on the node where we will send the keys - # this id can be a local id as well as root - if ($ENV{'DSH_TO_USERID'}) { - $to_userid=$ENV{'DSH_TO_USERID'}; - } else { - $to_userid="root"; - } - # set User home directory to find the ssh public key to send - # For non-root ids information may not be in /etc/passwd - # but elsewhere like LDAP - - if ($ENV{'DSH_FROM_USERID_HOME'}) { - $home=$ENV{'DSH_FROM_USERID_HOME'}; - } else { - $home=xCAT::Utils->getHomeDir($from_userid); - } - # This indicates we will generate new ssh keys for the user, - # if they are not already there - # unless using zones - my $key="$home/.ssh/id_rsa"; - my $key2="$home/.ssh/id_rsa.pub"; - # Check to see if empty - if (-z $key) { - my $rsp = {}; - $rsp->{error}->[0] = - "The $key file is empty. Remove it and rerun the command."; - xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); - return 1; - } - if (-z $key2) { - my $rsp = {}; - $rsp->{error}->[0] = - "The $key2 file is empty. Remove it and rerun the command."; - xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); - return 1; + if (($flag ne "k") && ($flag ne "t") && ($flag ne "s")) { + my $rsp = {}; + $rsp->{error}->[0] = + "Invalid flag $flag provided."; + xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); + return 2; - } - if (($flag eq "k") && (!(-e $key))) - { - # updating keys and the key file does not exist - $rc=xCAT::RemoteShellExp->gensshkeys($expecttimeout); - } - # send ssh keys to the nodes/devices, to setup passwordless ssh - if ($flag eq "s") - { - if (!($nodes)) { - my $rsp = {}; - $rsp->{error}->[0] = - "There are no nodes defined to update the ssh keys."; - xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); - return 1; } - if ($ssh_setup_cmd) { # setup ssh on devices - $rc=xCAT::RemoteShellExp->senddeviceskeys($remoteshell,$remotecopy,$to_userid,$to_user_password,$home,$ssh_setup_cmd,$nodes, $expecttimeout); - } else { #setup ssh on nodes - if ($ENV{'DSH_ZONE_SSHKEYS'}) { # if using zones the override the location of the keys - $home= $ENV{'DSH_ZONE_SSHKEYS'}; - } - $rc=xCAT::RemoteShellExp->sendnodeskeys($remoteshell,$remotecopy,$to_userid,$to_user_password,$home,$nodes, $expecttimeout); - } - } - # test ssh setup on the node - if ($flag eq "t") - { - $rc=xCAT::RemoteShellExp->testkeys($remoteshell,$to_userid,$nodes,$expecttimeout); - } - return $rc; + my $expecttimeout = 10; # default + if (defined($timeout)) { # value supplied + $expecttimeout = $timeout; + } + + # for -s flag must have nodes and a $to_userid password + my $to_user_password; + if ($ENV{'DSH_REMOTE_PASSWORD'}) { + $to_user_password = $ENV{'DSH_REMOTE_PASSWORD'}; + } + if ($flag eq "s") { + if (!$to_user_password) { + my $rsp = {}; + $rsp->{error}->[0] = +"The DSH_REMOTE_PASSWORD environment variable has not been set to the user id password on the node which will have their ssh keys updated (ususally root)."; + xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); + return 2; + } + if (!$nodes) { + my $rsp = {}; + $rsp->{error}->[0] = + "No nodes were input to update the user's ssh keys."; + xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); + return 2; + } + } + my $ssh_setup_cmd; + my $from_userid; + my $to_userid; + my $home; + my $remotecopy; + + # if caller input a path to ssh remote command, use it + if ($ENV{'DSH_REMOTE_CMD'}) { + $remoteshell = $ENV{'DSH_REMOTE_CMD'}; + } else { + if (!$remoteshell) { + $remoteshell = "/usr/bin/ssh"; + } + } + + # figure out path to scp + my ($path, $ssh) = split(/ssh/, $remoteshell); + $remotecopy = $path . "scp"; + + # if caller input the ssh setup command (such as for IB Switch) + if ($ENV{'SSH_SETUP_COMMAND'}) { + $ssh_setup_cmd = $ENV{'SSH_SETUP_COMMAND'}; + } + + # set User on the Management node that has the ssh keys + # this id can be a local (non-root) id as well as root + if ($ENV{'DSH_FROM_USERID'}) { + $from_userid = $ENV{'DSH_FROM_USERID'}; + } else { + $from_userid = "root"; + } + + # set User on the node where we will send the keys + # this id can be a local id as well as root + if ($ENV{'DSH_TO_USERID'}) { + $to_userid = $ENV{'DSH_TO_USERID'}; + } else { + $to_userid = "root"; + } + + # set User home directory to find the ssh public key to send + # For non-root ids information may not be in /etc/passwd + # but elsewhere like LDAP + + if ($ENV{'DSH_FROM_USERID_HOME'}) { + $home = $ENV{'DSH_FROM_USERID_HOME'}; + } else { + $home = xCAT::Utils->getHomeDir($from_userid); + } + + # This indicates we will generate new ssh keys for the user, + # if they are not already there + # unless using zones + my $key = "$home/.ssh/id_rsa"; + my $key2 = "$home/.ssh/id_rsa.pub"; + + # Check to see if empty + if (-z $key) { + my $rsp = {}; + $rsp->{error}->[0] = + "The $key file is empty. Remove it and rerun the command."; + xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); + return 1; + + } + if (-z $key2) { + my $rsp = {}; + $rsp->{error}->[0] = + "The $key2 file is empty. Remove it and rerun the command."; + xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); + return 1; + + } + if (($flag eq "k") && (!(-e $key))) + { + # updating keys and the key file does not exist + $rc = xCAT::RemoteShellExp->gensshkeys($expecttimeout); + } + + # send ssh keys to the nodes/devices, to setup passwordless ssh + if ($flag eq "s") + { + if (!($nodes)) { + my $rsp = {}; + $rsp->{error}->[0] = + "There are no nodes defined to update the ssh keys."; + xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); + return 1; + } + if ($ssh_setup_cmd) { # setup ssh on devices + $rc = xCAT::RemoteShellExp->senddeviceskeys($remoteshell, $remotecopy, $to_userid, $to_user_password, $home, $ssh_setup_cmd, $nodes, $expecttimeout); + } else { #setup ssh on nodes + if ($ENV{'DSH_ZONE_SSHKEYS'}) { # if using zones the override the location of the keys + $home = $ENV{'DSH_ZONE_SSHKEYS'}; + } + $rc = xCAT::RemoteShellExp->sendnodeskeys($remoteshell, $remotecopy, $to_userid, $to_user_password, $home, $nodes, $expecttimeout); + } + } + + # test ssh setup on the node + if ($flag eq "t") + { + $rc = xCAT::RemoteShellExp->testkeys($remoteshell, $to_userid, $nodes, $expecttimeout); + } + return $rc; } #----------------------------------------------------------------------------- @@ -225,25 +235,25 @@ sub remoteshellexp #----------------------------------------------------------------------------- -sub gensshkeys +sub gensshkeys { my ($class, $expecttimeout) = @_; my $keygen; - my $timeout = $expecttimeout; # sets Expect default timeout, 0 accepts immediately + my $timeout = $expecttimeout; # sets Expect default timeout, 0 accepts immediately my $keygen_sent = 0; - my $prompt1 = 'Generating public/private rsa'; - my $prompt2 = 'Enter file.*:'; - my $prompt3 = 'Enter passphrase.*:'; - my $prompt4 = 'Enter same passphrase.*:'; - my $expect_log = undef; - my $debug = 0; + my $prompt1 = 'Generating public/private rsa'; + my $prompt2 = 'Enter file.*:'; + my $prompt3 = 'Enter passphrase.*:'; + my $prompt4 = 'Enter same passphrase.*:'; + my $expect_log = undef; + my $debug = 0; if ($::VERBOSE) { $debug = 1; } $keygen = new Expect; - + # run /usr/bin/ssh-keygen -t rsa # prompt1 = 'Generating public/private rsa'; # prompt2 = 'Enter file.*:'; @@ -274,53 +284,53 @@ sub gensshkeys my $spawncmd = "/usr/bin/ssh-keygen -t rsa"; unless ($keygen->spawn($spawncmd)) { - my $rsp = {}; - $rsp->{error}->[0] = - "Unable to run $spawncmd."; - xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); - return 1; + my $rsp = {}; + $rsp->{error}->[0] = + "Unable to run $spawncmd."; + xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); + return 1; } # - #ssh-keygen prompts starts here + #ssh-keygen prompts starts here # my @result = $keygen->expect( $timeout, [ - $prompt1, # Generating public/private rsa - sub { - $keygen->send("\r"); - $keygen->clear_accum(); - $keygen->exp_continue(); - } + $prompt1, # Generating public/private rsa + sub { + $keygen->send("\r"); + $keygen->clear_accum(); + $keygen->exp_continue(); + } ], [ - $prompt2, # Enter file.*: - sub { - $keygen->send("\r"); - $keygen->clear_accum(); - $keygen->exp_continue(); - } + $prompt2, # Enter file.*: + sub { + $keygen->send("\r"); + $keygen->clear_accum(); + $keygen->exp_continue(); + } ], [ - $prompt3, # Enter passphrase.* - sub { - $keygen->send("\r"); - $keygen->clear_accum(); - $keygen->exp_continue(); - } + $prompt3, # Enter passphrase.* + sub { + $keygen->send("\r"); + $keygen->clear_accum(); + $keygen->exp_continue(); + } ], [ - $prompt4, # Enter same passphrase. - sub { - $keygen->send("\r"); - $keygen->clear_accum(); - $keygen->exp_continue(); - } + $prompt4, # Enter same passphrase. + sub { + $keygen->send("\r"); + $keygen->clear_accum(); + $keygen->exp_continue(); + } ] - ); # end prompts + ); # end prompts ########################################## # Expect error - report and quit ########################################## @@ -328,20 +338,21 @@ sub gensshkeys { my $msg = $result[1]; $keygen->soft_close(); - if ($msg =~ /status 0/i) { # no error - return 0; + if ($msg =~ /status 0/i) { # no error + return 0; } else { - my $rsp = {}; - $rsp->{error}->[0] = $msg; - xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); - return 1; + my $rsp = {}; + $rsp->{error}->[0] = $msg; + xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); + return 1; } } else { - $keygen->soft_close(); - return 0; - } + $keygen->soft_close(); + return 0; + } } + #----------------------------------------------------------------------------- =head3 testkeys @@ -352,27 +363,28 @@ sub gensshkeys #----------------------------------------------------------------------------- -sub testkeys +sub testkeys { - my ($class,$remoteshell,$to_userid,$nodes, $expecttimeout) = @_; + my ($class, $remoteshell, $to_userid, $nodes, $expecttimeout) = @_; my $testkeys; - my $timeout = $expecttimeout; # sets Expect default timeout + my $timeout = $expecttimeout; # sets Expect default timeout my $testkeys_sent = 0; - my $prompt1 = 'Are you sure you want to continue connecting (yes/no)?'; - my $prompt2 = 'ssword:'; - my $prompt3 = 'Permission denied*'; - my $prompt4 = 'test.success'; - my $expect_log = undef; - my $debug = 0; - my $rc=1; # default to error + my $prompt1 = 'Are you sure you want to continue connecting (yes/no)?'; + my $prompt2 = 'ssword:'; + my $prompt3 = 'Permission denied*'; + my $prompt4 = 'test.success'; + my $expect_log = undef; + my $debug = 0; + my $rc = 1; # default to error + if ($::VERBOSE) { $debug = 1; } $testkeys = new Expect; - - # run ssh -l to_userid echo test.success + + # run ssh -l to_userid echo test.success # possible return # bad ## Are you sure you want to continue connecting (yes/no)? @@ -401,48 +413,48 @@ sub testkeys my $spawncmd = "$remoteshell $nodes -l $to_userid echo test.success"; unless ($testkeys->spawn($spawncmd)) { - my $rsp = {}; - $rsp->{error}->[0] = - "Unable to run $spawncmd."; - xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); - return 1; + my $rsp = {}; + $rsp->{error}->[0] = + "Unable to run $spawncmd."; + xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); + return 1; } # - #testkeys prompts starts here + #testkeys prompts starts here # my @result = $testkeys->expect( $timeout, [ - $prompt1, # Are you sure you want to ... - sub { - $rc= 1; - $testkeys->hard_close(); - } + $prompt1, # Are you sure you want to ... + sub { + $rc = 1; + $testkeys->hard_close(); + } ], [ - $prompt2, # *ssword* - sub { - $rc= 1; - $testkeys->hard_close(); - } + $prompt2, # *ssword* + sub { + $rc = 1; + $testkeys->hard_close(); + } ], [ - $prompt3, # Permission denied - sub { - $rc= 1; - $testkeys->hard_close(); - } + $prompt3, # Permission denied + sub { + $rc = 1; + $testkeys->hard_close(); + } ], [ - $prompt4, # test.success - sub { - $rc= 0; - } + $prompt4, # test.success + sub { + $rc = 0; + } ] - ); # end prompts + ); # end prompts ########################################## # Expect error - report and quit ########################################## @@ -450,20 +462,21 @@ sub testkeys { my $msg = $result[1]; $testkeys->soft_close(); - if ($msg =~ /status 0/i) { # no error - return 0; + if ($msg =~ /status 0/i) { # no error + return 0; } else { - my $rsp = {}; - $rsp->{error}->[0] = $msg; - xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); - return 1; + my $rsp = {}; + $rsp->{error}->[0] = $msg; + xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); + return 1; } } else { - $testkeys->soft_close(); - return $rc; - } + $testkeys->soft_close(); + return $rc; + } } + #------------------------------------------------------------------------------- =head3 sendnodeskeys @@ -474,299 +487,303 @@ sub testkeys #----------------------------------------------------------------------------- -sub sendnodeskeys +sub sendnodeskeys { - my ($class,$remoteshell,$remotecopy,$to_userid,$to_userpassword,$home,$nodes, $expecttimeout) = @_; + my ($class, $remoteshell, $remotecopy, $to_userid, $to_userpassword, $home, $nodes, $expecttimeout) = @_; my $sendkeys; - my $timeout = $expecttimeout; # sets Expect default timeout, 0 accepts immediately + my $timeout = $expecttimeout; # sets Expect default timeout, 0 accepts immediately my $sendkeys_sent = 0; - my $prompt1 = 'Are you sure you want to continue connecting (yes/no)?'; - my $prompt2 = 'ssword:'; - my $prompt3 = 'Permission denied*'; - my $expect_log = undef; - my $debug = 0; - my $rc=0; + my $prompt1 = 'Are you sure you want to continue connecting (yes/no)?'; + my $prompt2 = 'ssword:'; + my $prompt3 = 'Permission denied*'; + my $expect_log = undef; + my $debug = 0; + my $rc = 0; if ($::VERBOSE) { $debug = 1; } + # For each node # make a temporary directory on the node - # run scp -l /bin/mkdir -p /tmp/$to_userid/.ssh - # xdsh has built an authorized_keys file for the node - # in $HOME/.ssh/tmp/authorized_keys - # copy to the node to the temp directory + # run scp -l /bin/mkdir -p /tmp/$to_userid/.ssh + # xdsh has built an authorized_keys file for the node + # in $HOME/.ssh/tmp/authorized_keys + # copy to the node to the temp directory # scp $HOME/.ssh/tmp/authorized_keys to_userid@:/tmp/$to_userid/.ssh # scp $HOME/.ssh/id_rsa.pub to_userid@:/tmp/$to_userid/.ssh # Note if using zones, the keys do not come from ~/.ssh but from the # zone table, sshkeydir attribute. For zones the userid is always root # If you are going to enable ssh to ssh between nodes, then # scp $HOME/.ssh/id_rsa to that temp directory on the node - # copy the script $HOME/.ssh/copy.sh to the node, it will do the + # copy the script $HOME/.ssh/copy.sh to the node, it will do the # the work of setting up the user's ssh keys and clean up # ssh (run) copy.sh on the node - - my @nodelist=split(/,/,$nodes); + + my @nodelist = split(/,/, $nodes); foreach my $node (@nodelist) { - $sendkeys = new Expect; + $sendkeys = new Expect; - # disable command echoing - #$sendkeys->slave->stty(qw(sane -echo)); - # - # exp_internal(1) sets exp_internal debugging - # to STDERR. - # - #$sendkeys->exp_internal(1); - $sendkeys->exp_internal($debug); - # - # log_stdout(0) prevent the program's output from being shown. - # turn on if debugging error - #$sendkeys->log_stdout(1); - $sendkeys->log_stdout($debug); - - # command to make the temp directory on the node - my $spawnmkdir= - "$remoteshell $node -l $to_userid /bin/mkdir -p /tmp/$to_userid/.ssh"; - # command to copy the needed files to the node - - # send mkdir command - unless ($sendkeys->spawn($spawnmkdir)) - { - my $rsp = {}; - $rsp->{error}->[0] = - "Unable to run $spawnmkdir on $node"; - xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); - next; - } + # disable command echoing + #$sendkeys->slave->stty(qw(sane -echo)); + # + # exp_internal(1) sets exp_internal debugging + # to STDERR. + # + #$sendkeys->exp_internal(1); + $sendkeys->exp_internal($debug); + # + # log_stdout(0) prevent the program's output from being shown. + # turn on if debugging error + #$sendkeys->log_stdout(1); + $sendkeys->log_stdout($debug); - # - #mkdir prompts starts here - # + # command to make the temp directory on the node + my $spawnmkdir = + "$remoteshell $node -l $to_userid /bin/mkdir -p /tmp/$to_userid/.ssh"; - my @result = $sendkeys->expect( - $timeout, - [ - $prompt1, # Are you sure you want to ... - sub { - $sendkeys->send("yes\r"); - $sendkeys->clear_accum(); - $sendkeys->exp_continue(); - } - ], - [ - $prompt2, # *ssword* - sub { - $sendkeys->send("$to_userpassword\r"); - $sendkeys->clear_accum(); - $sendkeys->exp_continue(); - } - ], - [ - $prompt3, # Permission denied - sub { - $rc= 1; - $sendkeys->hard_close(); - } - ], - ); # end prompts - ########################################## - # Expect error - report - ########################################## - if (defined($result[1])) + # command to copy the needed files to the node + + # send mkdir command + unless ($sendkeys->spawn($spawnmkdir)) { - my $msg = $result[1]; - if ($msg =~ /status 0/i) { # no error - $rc=0; - } else { - if ($msg =~ /2:EOF/i) { # no error - $rc=0; - } else { - my $rsp = {}; - $rsp->{error}->[0] = "mkdir:$node has error,$msg"; - xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); - $rc=1; - } - } + my $rsp = {}; + $rsp->{error}->[0] = + "Unable to run $spawnmkdir on $node"; + xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); + next; } - $sendkeys->soft_close(); - # - #copy files prompts starts here - # + # + #mkdir prompts starts here + # - $sendkeys = new Expect; - - # disable command echoing - #$sendkeys->slave->stty(qw(sane -echo)); - # - # exp_internal(1) sets exp_internal debugging - # to STDERR. - # - #$sendkeys->exp_internal(1); - $sendkeys->exp_internal($debug); - # - # log_stdout(0) prevent the program's output from being shown. - # turn on if debugging error - #$sendkeys->log_stdout(1); - $sendkeys->log_stdout($debug); - - my $spawncopyfiles; - if ($ENV{'DSH_ENABLE_SSH'}) { # we will enable node to node ssh - $spawncopyfiles= - "$remotecopy $home/.ssh/id_rsa $home/.ssh/id_rsa.pub $home/.ssh/copy.sh $home/.ssh/tmp/authorized_keys $to_userid\@$node:/tmp/$to_userid/.ssh"; - - } else { # no node to node ssh ( don't send private key) - $spawncopyfiles= - "$remotecopy $home/.ssh/id_rsa.pub $home/.ssh/copy.sh $home/.ssh/tmp/authorized_keys $to_userid\@$node:/tmp/$to_userid/.ssh"; - } - # send copy command - unless ($sendkeys->spawn($spawncopyfiles)) - { - my $rsp = {}; - $rsp->{error}->[0] = - "Unable to run $spawncopyfiles on $node."; - xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); - next; - } - - @result = $sendkeys->expect( - $timeout, - [ - $prompt1, # Are you sure you want to ... - sub { - $sendkeys->send("yes\r"); - $sendkeys->clear_accum(); - $sendkeys->exp_continue(); - } - ], - [ - $prompt2, # *ssword* - sub { - $sendkeys->send("$to_userpassword\r"); - $sendkeys->clear_accum(); - $sendkeys->exp_continue(); - } - ], - [ - $prompt3, # Permission denied - sub { - $rc= 1; - $sendkeys->hard_close(); - - } - ], - ); # end prompts + my @result = $sendkeys->expect( + $timeout, + [ + $prompt1, # Are you sure you want to ... + sub { + $sendkeys->send("yes\r"); + $sendkeys->clear_accum(); + $sendkeys->exp_continue(); + } + ], + [ + $prompt2, # *ssword* + sub { + $sendkeys->send("$to_userpassword\r"); + $sendkeys->clear_accum(); + $sendkeys->exp_continue(); + } + ], + [ + $prompt3, # Permission denied + sub { + $rc = 1; + $sendkeys->hard_close(); + } + ], + ); # end prompts ########################################## - # Expect error - report + # Expect error - report ########################################## if (defined($result[1])) { my $msg = $result[1]; - if ($msg =~ /status 0/i) { # no error - $rc=0; + if ($msg =~ /status 0/i) { # no error + $rc = 0; } else { - if ($msg =~ /2:EOF/i) { # no error - $rc=0; - } else { - my $rsp = {}; - $rsp->{error}->[0] = "copykeys:$node has error,$msg"; - xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); - $rc=1; - } + if ($msg =~ /2:EOF/i) { # no error + $rc = 0; + } else { + my $rsp = {}; + $rsp->{error}->[0] = "mkdir:$node has error,$msg"; + xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); + $rc = 1; + } } } $sendkeys->soft_close(); - # - # ssh to the node to run the copy.sh to setup the keys starts here - # - $sendkeys = new Expect; + # + #copy files prompts starts here + # - # disable command echoing - #$sendkeys->slave->stty(qw(sane -echo)); - # - # exp_internal(1) sets exp_internal debugging - # to STDERR. - # - #$sendkeys->exp_internal(1); - $sendkeys->exp_internal($debug); - # - # log_stdout(0) prevent the program's output from being shown. - # turn on if debugging error - #$sendkeys->log_stdout(1); - $sendkeys->log_stdout($debug); - - # command to run copy.sh - my $spawnruncopy= - "$remoteshell $node -l $to_userid /tmp/$to_userid/.ssh/copy.sh"; - - # send mkdir command - unless ($sendkeys->spawn($spawnruncopy)) - { - my $rsp = {}; - $rsp->{error}->[0] = - "Unable to run $spawnruncopy."; - xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); - next; # go to next node + $sendkeys = new Expect; - } + # disable command echoing + #$sendkeys->slave->stty(qw(sane -echo)); + # + # exp_internal(1) sets exp_internal debugging + # to STDERR. + # + #$sendkeys->exp_internal(1); + $sendkeys->exp_internal($debug); + # + # log_stdout(0) prevent the program's output from being shown. + # turn on if debugging error + #$sendkeys->log_stdout(1); + $sendkeys->log_stdout($debug); - # - #run copy.sh prompts starts here - # + my $spawncopyfiles; + if ($ENV{'DSH_ENABLE_SSH'}) { # we will enable node to node ssh + $spawncopyfiles = +"$remotecopy $home/.ssh/id_rsa $home/.ssh/id_rsa.pub $home/.ssh/copy.sh $home/.ssh/tmp/authorized_keys $to_userid\@$node:/tmp/$to_userid/.ssh"; + + } else { # no node to node ssh ( don't send private key) + $spawncopyfiles = +"$remotecopy $home/.ssh/id_rsa.pub $home/.ssh/copy.sh $home/.ssh/tmp/authorized_keys $to_userid\@$node:/tmp/$to_userid/.ssh"; + } + + # send copy command + unless ($sendkeys->spawn($spawncopyfiles)) + { + my $rsp = {}; + $rsp->{error}->[0] = + "Unable to run $spawncopyfiles on $node."; + xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); + next; + } @result = $sendkeys->expect( - $timeout, - [ - $prompt1, # Are you sure you want to ... - sub { - $sendkeys->send("yes\r"); - $sendkeys->clear_accum(); - $sendkeys->exp_continue(); - } - ], - [ - $prompt2, # *ssword* - sub { - $sendkeys->send("$to_userpassword\r"); - $sendkeys->clear_accum(); - $sendkeys->exp_continue(); - } - ], - [ - $prompt3, # Permission denied - sub { - $rc= 1; - $sendkeys->hard_close(); - } - ], - ); # end prompts + $timeout, + [ + $prompt1, # Are you sure you want to ... + sub { + $sendkeys->send("yes\r"); + $sendkeys->clear_accum(); + $sendkeys->exp_continue(); + } + ], + [ + $prompt2, # *ssword* + sub { + $sendkeys->send("$to_userpassword\r"); + $sendkeys->clear_accum(); + $sendkeys->exp_continue(); + } + ], + [ + $prompt3, # Permission denied + sub { + $rc = 1; + $sendkeys->hard_close(); + + } + ], + ); # end prompts ########################################## - # Expect error - report + # Expect error - report ########################################## if (defined($result[1])) { my $msg = $result[1]; - if ($msg =~ /status 0/i) { # no error - $rc=0; + if ($msg =~ /status 0/i) { # no error + $rc = 0; } else { - if ($msg =~ /2:EOF/i) { # no error - $rc=0; - } else { - my $rsp = {}; - $rsp->{error}->[0] = "copy.sh:$node has error,$msg"; - xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); - $rc=1; - } + if ($msg =~ /2:EOF/i) { # no error + $rc = 0; + } else { + my $rsp = {}; + $rsp->{error}->[0] = "copykeys:$node has error,$msg"; + xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); + $rc = 1; + } } } - $sendkeys->soft_close(); + $sendkeys->soft_close(); + + # + # ssh to the node to run the copy.sh to setup the keys starts here + # + $sendkeys = new Expect; + + # disable command echoing + #$sendkeys->slave->stty(qw(sane -echo)); + # + # exp_internal(1) sets exp_internal debugging + # to STDERR. + # + #$sendkeys->exp_internal(1); + $sendkeys->exp_internal($debug); + # + # log_stdout(0) prevent the program's output from being shown. + # turn on if debugging error + #$sendkeys->log_stdout(1); + $sendkeys->log_stdout($debug); + + # command to run copy.sh + my $spawnruncopy = + "$remoteshell $node -l $to_userid /tmp/$to_userid/.ssh/copy.sh"; + + # send mkdir command + unless ($sendkeys->spawn($spawnruncopy)) + { + my $rsp = {}; + $rsp->{error}->[0] = + "Unable to run $spawnruncopy."; + xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); + next; # go to next node + + } + + # + #run copy.sh prompts starts here + # + + @result = $sendkeys->expect( + $timeout, + [ + $prompt1, # Are you sure you want to ... + sub { + $sendkeys->send("yes\r"); + $sendkeys->clear_accum(); + $sendkeys->exp_continue(); + } + ], + [ + $prompt2, # *ssword* + sub { + $sendkeys->send("$to_userpassword\r"); + $sendkeys->clear_accum(); + $sendkeys->exp_continue(); + } + ], + [ + $prompt3, # Permission denied + sub { + $rc = 1; + $sendkeys->hard_close(); + } + ], + ); # end prompts + ########################################## + # Expect error - report + ########################################## + if (defined($result[1])) + { + my $msg = $result[1]; + if ($msg =~ /status 0/i) { # no error + $rc = 0; + } else { + if ($msg =~ /2:EOF/i) { # no error + $rc = 0; + } else { + my $rsp = {}; + $rsp->{error}->[0] = "copy.sh:$node has error,$msg"; + xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); + $rc = 1; + } + } + } + $sendkeys->soft_close(); - } # end foreach node - return $rc; + } # end foreach node + return $rc; } + #------------------------------------------------------------------------------- =head3 senddeviceskeys @@ -777,130 +794,133 @@ sub sendnodeskeys #----------------------------------------------------------------------------- -sub senddeviceskeys +sub senddeviceskeys { - my ($class,$remoteshell,$remotecopy,$to_userid,$to_userpassword,$home,$ssh_setup_cmd,$nodes, $expecttimeout) = @_; + my ($class, $remoteshell, $remotecopy, $to_userid, $to_userpassword, $home, $ssh_setup_cmd, $nodes, $expecttimeout) = @_; my $sendkeys; - my $timeout = $expecttimeout; # sets Expect default timeout, 0 accepts immediately + my $timeout = $expecttimeout; # sets Expect default timeout, 0 accepts immediately my $sendkeys_sent = 0; - my $prompt1 = 'Are you sure you want to continue connecting (yes/no)?'; - my $prompt2 = 'ssword:'; - my $prompt3 = 'Permission denied*'; - my $expect_log = undef; - my $debug = 0; - my $rc=0; + my $prompt1 = 'Are you sure you want to continue connecting (yes/no)?'; + my $prompt2 = 'ssword:'; + my $prompt3 = 'Permission denied*'; + my $expect_log = undef; + my $debug = 0; + my $rc = 0; if ($::VERBOSE) { $debug = 1; } - + # quote the setup command and key "sshKey add \"slave->stty(qw(sane -echo)); - # - # exp_internal(1) sets exp_internal debugging - # to STDERR. - # - #$sendkeys->exp_internal(1); - $sendkeys->exp_internal($debug); - # - # log_stdout(0) prevent the program's output from being shown. - # turn on if debugging error - #$sendkeys->log_stdout(1); - $sendkeys->log_stdout($debug); - - # command to send key to the device - # sshKey add "key" - my $spawnaddkey= - "$remoteshell $node -l $to_userid $setupcmd"; - - # send mkdir command - unless ($sendkeys->spawn($spawnaddkey)) - { - my $rsp = {}; - $rsp->{error}->[0] = - "Unable to run $spawnaddkey."; - xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); - next; # go to next node + # disable command echoing + #$sendkeys->slave->stty(qw(sane -echo)); + # + # exp_internal(1) sets exp_internal debugging + # to STDERR. + # + #$sendkeys->exp_internal(1); + $sendkeys->exp_internal($debug); + # + # log_stdout(0) prevent the program's output from being shown. + # turn on if debugging error + #$sendkeys->log_stdout(1); + $sendkeys->log_stdout($debug); - } + # command to send key to the device + # sshKey add "key" + my $spawnaddkey = + "$remoteshell $node -l $to_userid $setupcmd"; - # - #run copy.sh prompts starts here - # + # send mkdir command + unless ($sendkeys->spawn($spawnaddkey)) + { + my $rsp = {}; + $rsp->{error}->[0] = + "Unable to run $spawnaddkey."; + xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); + next; # go to next node - my @result = $sendkeys->expect( - $timeout, - [ - $prompt1, # Are you sure you want to ... - sub { - $sendkeys->send("yes\r"); - $sendkeys->clear_accum(); - $sendkeys->exp_continue(); - } - ], - [ - $prompt2, # *ssword* - sub { - $sendkeys->send("$to_userpassword\r"); - $sendkeys->clear_accum(); - $sendkeys->exp_continue(); - } - ], - [ - $prompt3, # Permission denied - sub { - $rc= 1; - $sendkeys->soft_close(); - next; # go to next node - } - ], - ); # end prompts + } + + # + #run copy.sh prompts starts here + # + + my @result = $sendkeys->expect( + $timeout, + [ + $prompt1, # Are you sure you want to ... + sub { + $sendkeys->send("yes\r"); + $sendkeys->clear_accum(); + $sendkeys->exp_continue(); + } + ], + [ + $prompt2, # *ssword* + sub { + $sendkeys->send("$to_userpassword\r"); + $sendkeys->clear_accum(); + $sendkeys->exp_continue(); + } + ], + [ + $prompt3, # Permission denied + sub { + $rc = 1; + $sendkeys->soft_close(); + next; # go to next node + } + ], + ); # end prompts ########################################## - # Expect error - report + # Expect error - report ########################################## if (defined($result[1])) { my $msg = $result[1]; - if ($msg =~ /status 0/i) { # no error - $rc=0; + if ($msg =~ /status 0/i) { # no error + $rc = 0; } else { - my $rsp = {}; - $rsp->{error}->[0] = "$node has error,$msg"; - xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); - $rc=1; - next; # go to next node + my $rsp = {}; + $rsp->{error}->[0] = "$node has error,$msg"; + xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); + $rc = 1; + next; # go to next node } } - $sendkeys->soft_close(); - } # end foreach node + $sendkeys->soft_close(); + } # end foreach node return $rc; } 1; diff --git a/perl-xCAT/xCAT/SINV.pm b/perl-xCAT/xCAT/SINV.pm index 2df6d6420..51852c4cd 100644 --- a/perl-xCAT/xCAT/SINV.pm +++ b/perl-xCAT/xCAT/SINV.pm @@ -16,9 +16,10 @@ the sinv command. #------------------------------------------------------------------------------ package xCAT::SINV; + BEGIN { - $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; } use strict; use xCAT::MsgUtils; @@ -27,6 +28,7 @@ use xCAT::NodeRange qw/noderange abbreviate_noderange/; use xCAT::Utils; use Fcntl qw(:flock); use Getopt::Long; + #use Data::Dumper; my $tempfile; my $errored = 0; @@ -54,14 +56,14 @@ sub usage ## usage message my $usagemsg1 = - "The sinv command is designed to check the configuration of nodes in a cluster.\nRun man sinv for more information.\n\nInput parameters are as follows:\n"; +"The sinv command is designed to check the configuration of nodes in a cluster.\nRun man sinv for more information.\n\nInput parameters are as follows:\n"; my $usagemsg1a = "sinv -h \nsinv -v \nsinv"; - my $usagemsg3 = + my $usagemsg3 = " -p