From 5460a4e694fa5ac9a3eb39698a6b78f5cb015f28 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Thu, 28 Feb 2019 14:27:16 -0500 Subject: [PATCH 01/13] Add xCAT-client as dependency for xCAT-probe --- xCAT-probe/xCAT-probe.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/xCAT-probe/xCAT-probe.spec b/xCAT-probe/xCAT-probe.spec index 5c0c463b2..eeadb577a 100644 --- a/xCAT-probe/xCAT-probe.spec +++ b/xCAT-probe/xCAT-probe.spec @@ -11,6 +11,7 @@ Vendor: IBM Corp. Distribution: %{?_distribution:%{_distribution}}%{!?_distribution:%{_vendor}} Prefix: /opt/xcat BuildRoot: /var/tmp/%{name}-%{version}-%{release}-root +Requires: xCAT-client %ifos linux BuildArch: noarch From 96b7d9865fe19025e6ab1c1ff17db47fb5a93e07 Mon Sep 17 00:00:00 2001 From: litingt Date: Fri, 1 Mar 2019 02:25:37 -0500 Subject: [PATCH 02/13] update to refine cases --- xCAT-test/autotest/testcase/nodeset/cases0 | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/xCAT-test/autotest/testcase/nodeset/cases0 b/xCAT-test/autotest/testcase/nodeset/cases0 index 6080691da..01f712389 100644 --- a/xCAT-test/autotest/testcase/nodeset/cases0 +++ b/xCAT-test/autotest/testcase/nodeset/cases0 @@ -235,8 +235,7 @@ end start:nodeset_grub2 description: Verify when grub2 is used for OS loader, whether the configuration files under /tftpboot can be generated corrently label:others -cmd:rmdef testnode1 -cmd:rm -f /tftpboot/boot/grub2/{testnode1,grub.cfg-{01-e6-d4-d2-3a-ad-06,0[aA]0101[cC]8}} +cmd:lsdef testnode1 > /dev/null 2>&1;if [[ $? -eq 0 ]]; then lsdef testnode1 -z >/tmp/testnode1.stanza ;rmdef testnode1;rm -f /tftpboot/boot/grub2/{testnode1,grub.cfg-{01-e6-d4-d2-3a-ad-06,0[aA]0101[cC]8}};fi cmd:mkdef -t node -o testnode1 arch=ppc64 cons=hmc groups=lpar ip=10.1.1.200 mac=e6:d4:d2:3a:ad:06 mgt=hmc profile=compute os=rhels7.99 check:rc==0 cmd:cp -f /etc/hosts /etc/hosts.xcattestbak @@ -267,7 +266,7 @@ check:rc!=0 #check:rc!=0 cmd:chdef -t node -o testnode1 ip= check:rc==0 -cmd:cp -f /etc/hosts.xcattestbak /etc/hosts +cmd:sed -i /testnode1/d /etc/hosts cmd:getent hosts testnode1 | grep testnode1 check:rc!=0 cmd:nodeset testnode1 osimage=rhels7.99-ppc64-install-compute @@ -275,13 +274,14 @@ check:rc!=0 cmd:noderm testnode1 cmd:rmdef -t osimage -o "rhels7.99-ppc64-install-compute" cmd:rm -rf /install/rhels7.99 +cmd:cp -f /etc/hosts.xcattestbak /etc/hosts +cmd:if [[ -e /tmp/testnode1.stanza ]]; then cat /tmp/testnode1.stanza |mkdef -z -f;fi end start:nodeset_petitboot description: Verify when petitboot is used for OS loader, whether the configuration files under /tftpboot can be generated corrently label:others -cmd:rmdef testnode1 -cmd:rm -f /tftpboot/petitboot/testnode1 +cmd:lsdef testnode1 > /dev/null 2>&1;if [[ $? -eq 0 ]]; then lsdef testnode1 -z >/tmp/testnode1.stanza ;rmdef testnode 1;rm -f /tftpboot/petitboot/testnode1;fi cmd:mkdef -t node -o testnode1 arch=ppc64le cons=bmc groups=ipmi ip=10.1.1.200 mac=e6:d4:d2:3a:ad:06 mgt=ipmi profile=compute os=rhels7.99 check:rc==0 cmd:cp -f /etc/hosts /etc/hosts.xcattestbak @@ -309,7 +309,7 @@ check:rc!=0 #check:rc!=0 cmd:chdef -t node -o testnode1 ip= check:rc==0 -cmd:cp -f /etc/hosts.xcattestbak /etc/hosts +cmd:sed -i /testnode1/d /etc/hosts cmd:getent hosts testnode1 | grep testnode1 check:rc!=0 cmd:nodeset testnode1 osimage=rhels7.99-ppc64le-install-compute @@ -317,6 +317,8 @@ check:rc!=0 cmd:noderm testnode1 cmd:rmdef -t osimage -o "rhels7.99-ppc64le-install-compute" cmd:rm -rf /install/rhels7.99 +cmd:cp -f /etc/hosts.xcattestbak /etc/hosts +cmd:if [[ -e /tmp/testnode1.stanza ]]; then cat /tmp/testnode1.stanza |mkdef -z -f;fi end start:nodeset_yaboot @@ -374,8 +376,7 @@ end start:nodeset_disjointdhcps_petitboot description: Verify the disjointdhcps feature when petitboot is used for OS loader. label:others -cmd:rmdef testnode1 -cmd:rm -f /tftpboot/petitboot/testnode1 +cmd:lsdef testnode1 > /dev/null 2>&1;if [[ $? -eq 0 ]]; then lsdef testnode1 -z >/tmp/testnode1.stanza ;rmdef testnode1;rm -f /tftpboot/petitboot/testnode1;fi cmd:mkdef -t node -o testnode1 arch=ppc64le cons=bmc groups=ipmi ip=10.1.1.200 mac=e6:d4:d2:3a:ad:06 mgt=ipmi profile=compute os=rhels7.99 check:rc==0 cmd:cp -f /etc/hosts /etc/hosts.xcattestbak @@ -459,7 +460,7 @@ cmd:makedns -d testnode1 check:rc==0 cmd:chdef -t node -o testnode1 ip= check:rc==0 -cmd:cp -f /etc/hosts.xcattestbak /etc/hosts +cmd:sed -i /testnode1/d /etc/hosts cmd:getent hosts testnode1 | grep testnode1 check:rc!=0 cmd:nodeset testnode1 osimage=rhels7.99-ppc64le-install-compute @@ -468,6 +469,8 @@ cmd:noderm testnode1 cmd:rmdef -t osimage -o "rhels7.99-ppc64le-install-compute" cmd:rm -rf /install/rhels7.99 cmd:xdsh $$SN 'rm -rf /install/rhels7.99' +cmd:cp -f /etc/hosts.xcattestbak /etc/hosts +cmd:if [[ -e /tmp/testnode1.stanza ]]; then cat /tmp/testnode1.stanza |mkdef -z -f;fi end start:nodeset_switch_osimage From 4ba29c4434eae4276b8e0a4d2cb9c9ef0122cb60 Mon Sep 17 00:00:00 2001 From: litingt Date: Fri, 1 Mar 2019 03:29:26 -0500 Subject: [PATCH 03/13] update according to comments --- xCAT-test/autotest/testcase/nodeset/cases0 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xCAT-test/autotest/testcase/nodeset/cases0 b/xCAT-test/autotest/testcase/nodeset/cases0 index 01f712389..3f098b12d 100644 --- a/xCAT-test/autotest/testcase/nodeset/cases0 +++ b/xCAT-test/autotest/testcase/nodeset/cases0 @@ -275,13 +275,13 @@ cmd:noderm testnode1 cmd:rmdef -t osimage -o "rhels7.99-ppc64-install-compute" cmd:rm -rf /install/rhels7.99 cmd:cp -f /etc/hosts.xcattestbak /etc/hosts -cmd:if [[ -e /tmp/testnode1.stanza ]]; then cat /tmp/testnode1.stanza |mkdef -z -f;fi +cmd:if [[ -e /tmp/testnode1.stanza ]]; then cat /tmp/testnode1.stanza |mkdef -z -f;rm -rf /tmp/testnode1.stanza;fi end start:nodeset_petitboot description: Verify when petitboot is used for OS loader, whether the configuration files under /tftpboot can be generated corrently label:others -cmd:lsdef testnode1 > /dev/null 2>&1;if [[ $? -eq 0 ]]; then lsdef testnode1 -z >/tmp/testnode1.stanza ;rmdef testnode 1;rm -f /tftpboot/petitboot/testnode1;fi +cmd:lsdef testnode1 > /dev/null 2>&1;if [[ $? -eq 0 ]]; then lsdef testnode1 -z >/tmp/testnode1.stanza ;rmdef testnode1;rm -f /tftpboot/petitboot/testnode1;fi cmd:mkdef -t node -o testnode1 arch=ppc64le cons=bmc groups=ipmi ip=10.1.1.200 mac=e6:d4:d2:3a:ad:06 mgt=ipmi profile=compute os=rhels7.99 check:rc==0 cmd:cp -f /etc/hosts /etc/hosts.xcattestbak @@ -318,7 +318,7 @@ cmd:noderm testnode1 cmd:rmdef -t osimage -o "rhels7.99-ppc64le-install-compute" cmd:rm -rf /install/rhels7.99 cmd:cp -f /etc/hosts.xcattestbak /etc/hosts -cmd:if [[ -e /tmp/testnode1.stanza ]]; then cat /tmp/testnode1.stanza |mkdef -z -f;fi +cmd:if [[ -e /tmp/testnode1.stanza ]]; then cat /tmp/testnode1.stanza |mkdef -z -f;rm -rf /tmp/testnode1.stanza;fi end start:nodeset_yaboot @@ -470,7 +470,7 @@ cmd:rmdef -t osimage -o "rhels7.99-ppc64le-install-compute" cmd:rm -rf /install/rhels7.99 cmd:xdsh $$SN 'rm -rf /install/rhels7.99' cmd:cp -f /etc/hosts.xcattestbak /etc/hosts -cmd:if [[ -e /tmp/testnode1.stanza ]]; then cat /tmp/testnode1.stanza |mkdef -z -f;fi +cmd:if [[ -e /tmp/testnode1.stanza ]]; then cat /tmp/testnode1.stanza |mkdef -z -f;rm -rf /tmp/testnode1.stanza;fi end start:nodeset_switch_osimage From 8a6bfdf404c1eb4e75d7f92b3e975b27ac2e99d5 Mon Sep 17 00:00:00 2001 From: litingt Date: Fri, 1 Mar 2019 03:45:45 -0500 Subject: [PATCH 04/13] update according to comments --- xCAT-test/autotest/testcase/nodeset/cases0 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/xCAT-test/autotest/testcase/nodeset/cases0 b/xCAT-test/autotest/testcase/nodeset/cases0 index 3f098b12d..de7aa775e 100644 --- a/xCAT-test/autotest/testcase/nodeset/cases0 +++ b/xCAT-test/autotest/testcase/nodeset/cases0 @@ -235,7 +235,8 @@ end start:nodeset_grub2 description: Verify when grub2 is used for OS loader, whether the configuration files under /tftpboot can be generated corrently label:others -cmd:lsdef testnode1 > /dev/null 2>&1;if [[ $? -eq 0 ]]; then lsdef testnode1 -z >/tmp/testnode1.stanza ;rmdef testnode1;rm -f /tftpboot/boot/grub2/{testnode1,grub.cfg-{01-e6-d4-d2-3a-ad-06,0[aA]0101[cC]8}};fi +cmd:lsdef testnode1 > /dev/null 2>&1;if [[ $? -eq 0 ]]; then lsdef testnode1 -z >/tmp/testnode1.stanza ;rmdef testnode1;fi +cmd:rm -f /tftpboot/boot/grub2/{testnode1,grub.cfg-{01-e6-d4-d2-3a-ad-06,0[aA]0101[cC]8}} cmd:mkdef -t node -o testnode1 arch=ppc64 cons=hmc groups=lpar ip=10.1.1.200 mac=e6:d4:d2:3a:ad:06 mgt=hmc profile=compute os=rhels7.99 check:rc==0 cmd:cp -f /etc/hosts /etc/hosts.xcattestbak @@ -281,7 +282,8 @@ end start:nodeset_petitboot description: Verify when petitboot is used for OS loader, whether the configuration files under /tftpboot can be generated corrently label:others -cmd:lsdef testnode1 > /dev/null 2>&1;if [[ $? -eq 0 ]]; then lsdef testnode1 -z >/tmp/testnode1.stanza ;rmdef testnode1;rm -f /tftpboot/petitboot/testnode1;fi +cmd:lsdef testnode1 > /dev/null 2>&1;if [[ $? -eq 0 ]]; then lsdef testnode1 -z >/tmp/testnode1.stanza ;rmdef testnode1;fi +cmd:rm -f /tftpboot/petitboot/testnode1 cmd:mkdef -t node -o testnode1 arch=ppc64le cons=bmc groups=ipmi ip=10.1.1.200 mac=e6:d4:d2:3a:ad:06 mgt=ipmi profile=compute os=rhels7.99 check:rc==0 cmd:cp -f /etc/hosts /etc/hosts.xcattestbak @@ -376,7 +378,8 @@ end start:nodeset_disjointdhcps_petitboot description: Verify the disjointdhcps feature when petitboot is used for OS loader. label:others -cmd:lsdef testnode1 > /dev/null 2>&1;if [[ $? -eq 0 ]]; then lsdef testnode1 -z >/tmp/testnode1.stanza ;rmdef testnode1;rm -f /tftpboot/petitboot/testnode1;fi +cmd:lsdef testnode1 > /dev/null 2>&1;if [[ $? -eq 0 ]]; then lsdef testnode1 -z >/tmp/testnode1.stanza ;rmdef testnode1;fi +cmd:rm -f /tftpboot/petitboot/testnode1 cmd:mkdef -t node -o testnode1 arch=ppc64le cons=bmc groups=ipmi ip=10.1.1.200 mac=e6:d4:d2:3a:ad:06 mgt=ipmi profile=compute os=rhels7.99 check:rc==0 cmd:cp -f /etc/hosts /etc/hosts.xcattestbak From 8b4f07a90657ca5ae73145846d74f4afc4de64bc Mon Sep 17 00:00:00 2001 From: litingt Date: Fri, 1 Mar 2019 03:56:17 -0500 Subject: [PATCH 05/13] remove case nodestat_noderange --- xCAT-test/autotest/bundle/sles_ppcle_daily.bundle | 1 - 1 file changed, 1 deletion(-) diff --git a/xCAT-test/autotest/bundle/sles_ppcle_daily.bundle b/xCAT-test/autotest/bundle/sles_ppcle_daily.bundle index bb7201f9c..300ee1ea2 100644 --- a/xCAT-test/autotest/bundle/sles_ppcle_daily.bundle +++ b/xCAT-test/autotest/bundle/sles_ppcle_daily.bundle @@ -167,7 +167,6 @@ nodeset_stat nodeset_grub2 nodeset_petitboot nodestat_err_node -nodestat_noderange nodestat_usage packimage_h packimage_v From a7c59bd850decb4de97228e1d351a61df3828f30 Mon Sep 17 00:00:00 2001 From: xuweibj Date: Tue, 5 Mar 2019 01:10:37 -0500 Subject: [PATCH 06/13] fix rspconfig error that no executor folder --- xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py b/xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py index 3b96dca62..de8df2484 100644 --- a/xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py +++ b/xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py @@ -315,7 +315,7 @@ class OpenBMCManager(base.BaseManager): def rspconfig(self, nodesinfo, args): - from hwctl.executor.openbmc_bmcconfig import OpenBMCBmcConfigTask + from hwctl.openbmc.openbmc_bmcconfig import OpenBMCBmcConfigTask try: opts=docopt(RSPCONFIG_USAGE, argv=args) From d8f796ffcab7c74e29aa1ae52cc24e24d7cd5734 Mon Sep 17 00:00:00 2001 From: yangsong Date: Wed, 6 Mar 2019 14:56:29 +0800 Subject: [PATCH 07/13] fix issue modifies the permissions of source bin file #6049 (#6053) grant the sounce bin file correct permissions --- xCAT-server/lib/xcat/plugins/onie.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/onie.pm b/xCAT-server/lib/xcat/plugins/onie.pm index 65e49c6f8..2fb8921bc 100644 --- a/xCAT-server/lib/xcat/plugins/onie.pm +++ b/xCAT-server/lib/xcat/plugins/onie.pm @@ -18,6 +18,7 @@ use Getopt::Long; use Expect; use File::Path; use File::Basename; +use File::Copy "cp"; use xCAT::Utils; use xCAT::MsgUtils; @@ -183,11 +184,13 @@ sub copydata { #check if file exists if ( (-e "$defaultpath/$filename") && ($nooverwrite)){ + chmod 0755, "$defaultpath/$filename"; $callback->({ data => "$defaultpath/$filename is already exists, will not overwrite" }); } else { $callback->({ data => "Copying media to $defaultpath" }); mkpath ("$defaultpath"); - system("cp $file $defaultpath"); + cp "$file", "$defaultpath"; + chmod 0755, "$defaultpath/$filename"; $callback->({ data => "Media copy operation successful" }); } From f9d5469205bdc9b358a7fa6d19c54e8e5a27ab71 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 7 Mar 2019 22:31:08 -0500 Subject: [PATCH 08/13] polished --- .../common/deployment/network/cfg_second_adapter.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/source/guides/admin-guides/manage_clusters/common/deployment/network/cfg_second_adapter.rst b/docs/source/guides/admin-guides/manage_clusters/common/deployment/network/cfg_second_adapter.rst index ded30393c..23cca57cc 100644 --- a/docs/source/guides/admin-guides/manage_clusters/common/deployment/network/cfg_second_adapter.rst +++ b/docs/source/guides/admin-guides/manage_clusters/common/deployment/network/cfg_second_adapter.rst @@ -1,6 +1,8 @@ Configure Additional Network Interfaces old version - confignics - (deprecated) =============================================================================== +``confignics`` is deprecated, recommend using new version ``confignetwork`` instead. + The **nics** table and the **confignics** postscript can be used to automatically configure additional network interfaces (multiple ethernets adapters, InfiniBand, etc) on the nodes as they are being deployed. The way the confignics postscript decides what IP address to give the secondary adapter is by checking the nics table, in which the nic configuration information is stored. From 9d277074935b7fd916b75d6e2659ef888217c23e Mon Sep 17 00:00:00 2001 From: root Date: Fri, 8 Mar 2019 00:42:00 -0500 Subject: [PATCH 09/13] polished --- .../common/deployment/network/cfg_second_adapter.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/source/guides/admin-guides/manage_clusters/common/deployment/network/cfg_second_adapter.rst b/docs/source/guides/admin-guides/manage_clusters/common/deployment/network/cfg_second_adapter.rst index 23cca57cc..22ca8361a 100644 --- a/docs/source/guides/admin-guides/manage_clusters/common/deployment/network/cfg_second_adapter.rst +++ b/docs/source/guides/admin-guides/manage_clusters/common/deployment/network/cfg_second_adapter.rst @@ -76,12 +76,15 @@ Use command below to add confignics into the node's postscripts list :: chdef cn1 -p postscripts=confignics +**NOTE**: ``confignics`` is deprecated, you can also use ``chdef cn1 -p postscripts=confignetwork`` instead above ``chdef`` command. + By default, confignics does not configure the install nic. if need, using flag "-s" to allow the install nic to be configured. :: chdef cn1 -p prostscripts="confignics -s" Option "-s" writes the install nic's information into configuration file for persistence. All install nic's data defined in nics table will be written also. +**NOTE**: ``confignics`` is deprecated, you can also use ``chdef cn1 -p postscripts="confignetwork -s"`` instead above ``chdef`` command. Add network object into the networks table ------------------------------------------ From 688dcdb383668468c1e6fc9d65a06e521cb01f50 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 8 Mar 2019 01:19:18 -0500 Subject: [PATCH 10/13] polished --- .../common/deployment/network/cfg_second_adapter.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/guides/admin-guides/manage_clusters/common/deployment/network/cfg_second_adapter.rst b/docs/source/guides/admin-guides/manage_clusters/common/deployment/network/cfg_second_adapter.rst index 22ca8361a..ad4b79b25 100644 --- a/docs/source/guides/admin-guides/manage_clusters/common/deployment/network/cfg_second_adapter.rst +++ b/docs/source/guides/admin-guides/manage_clusters/common/deployment/network/cfg_second_adapter.rst @@ -1,7 +1,7 @@ Configure Additional Network Interfaces old version - confignics - (deprecated) =============================================================================== -``confignics`` is deprecated, recommend using new version ``confignetwork`` instead. +**``confignics`` is deprecated, recommend using new version ``confignetwork`` instead.** The **nics** table and the **confignics** postscript can be used to automatically configure additional network interfaces (multiple ethernets adapters, InfiniBand, etc) on the nodes as they are being deployed. From 4fbae5aeda55b94a0176c04ab1124db8c590a252 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 8 Mar 2019 01:52:58 -0500 Subject: [PATCH 11/13] polished --- .../common/deployment/network/cfg_second_adapter.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/guides/admin-guides/manage_clusters/common/deployment/network/cfg_second_adapter.rst b/docs/source/guides/admin-guides/manage_clusters/common/deployment/network/cfg_second_adapter.rst index ad4b79b25..ce6f9b801 100644 --- a/docs/source/guides/admin-guides/manage_clusters/common/deployment/network/cfg_second_adapter.rst +++ b/docs/source/guides/admin-guides/manage_clusters/common/deployment/network/cfg_second_adapter.rst @@ -1,7 +1,7 @@ Configure Additional Network Interfaces old version - confignics - (deprecated) =============================================================================== -**``confignics`` is deprecated, recommend using new version ``confignetwork`` instead.** +**"confignics" is deprecated, recommend using new version "confignetwork" instead.** The **nics** table and the **confignics** postscript can be used to automatically configure additional network interfaces (multiple ethernets adapters, InfiniBand, etc) on the nodes as they are being deployed. From cc0d1cbb38c53b6c07f74373ff2d788e7c659ca1 Mon Sep 17 00:00:00 2001 From: xuweibj Date: Fri, 8 Mar 2019 03:25:42 -0500 Subject: [PATCH 12/13] Modify openbmc python code to support python3 --- xCAT-openbmc-py/lib/python/agent/client.py | 4 ++-- .../lib/python/agent/common/rest.py | 19 ++++++++++--------- .../lib/python/agent/common/task.py | 8 ++++---- .../lib/python/agent/common/utils.py | 4 ++-- .../agent/hwctl/openbmc/openbmc_bmcconfig.py | 7 ++++--- .../agent/hwctl/openbmc/openbmc_eventlog.py | 4 ++-- .../agent/hwctl/openbmc/openbmc_flash.py | 6 +++--- .../agent/hwctl/openbmc/openbmc_inventory.py | 8 ++++---- .../lib/python/agent/hwctl/openbmc_client.py | 7 ++++--- .../lib/python/agent/xcatagent/server.py | 4 ++-- 10 files changed, 37 insertions(+), 34 deletions(-) diff --git a/xCAT-openbmc-py/lib/python/agent/client.py b/xCAT-openbmc-py/lib/python/agent/client.py index 1c8e0448e..ff2188e9e 100755 --- a/xCAT-openbmc-py/lib/python/agent/client.py +++ b/xCAT-openbmc-py/lib/python/agent/client.py @@ -55,13 +55,13 @@ class ClientShell(object): buf = json.dumps(req) s.send(utils.int2bytes(len(buf))) - s.send(buf) + s.send(buf.encode('utf-8')) while True: sz = s.recv(4) if len(sz) == 0: break sz = utils.bytes2int(sz) - data = s.recv(sz) + data = s.recv(sz).decode('utf-8') print(data) diff --git a/xCAT-openbmc-py/lib/python/agent/common/rest.py b/xCAT-openbmc-py/lib/python/agent/common/rest.py index 2d0ec5c43..e82485c6d 100644 --- a/xCAT-openbmc-py/lib/python/agent/common/rest.py +++ b/xCAT-openbmc-py/lib/python/agent/common/rest.py @@ -11,7 +11,7 @@ import urllib3 urllib3.disable_warnings() from requests.auth import AuthBase -import exceptions as xcat_exception +from . import exceptions as xcat_exception class RestSession(object): @@ -31,31 +31,32 @@ class RestSession(object): timeout=timeout) except requests.exceptions.ConnectionError as e: # Extract real reason for the exception and host/port from ConnectionError message - # Sometimes e.message is a list, sometimes is a string. Look for different patterns # to extract the data needed. + e = str(e) causing_error = "n/a" host_and_port = "n/a" - if "]" in e.message[0]: - causing_error_part1 = e.message[0].split("]")[1] + if "]" in e: + causing_error_part1 = e.split("]")[1] causing_error = causing_error_part1.split("'")[0] causing_error = causing_error.strip() - host_and_port = self.extract_server_and_port(e.message[0], "STRING") + host_and_port = self.extract_server_and_port(e, "STRING") - if "Connection aborted." in e.message[0]: + if "Connection aborted." in e: causing_error = "Connection reset by peer" host_and_port = self.extract_server_and_port(url, "URL") - if "connect timeout=" in e.message[0]: + if "connect timeout=" in e: causing_error = "timeout" - host_and_port = self.extract_server_and_port(e.message[0], "STRING") + host_and_port = self.extract_server_and_port(e, "STRING") message = 'Failed to connect to server.' # message = '\n\n--> {0} \n\n'.format(e.message[0]) raise xcat_exception.SelfServerException(message, '({0})'.format(causing_error), host_and_port) except requests.exceptions.Timeout as e: + e = str(e) causing_error = "timeout" - host_and_port = self.extract_server_and_port(e.message[0], "STRING") + host_and_port = self.extract_server_and_port(e, "STRING") message = 'Timeout to connect to server' raise xcat_exception.SelfServerException(message, '({0})'.format(causing_error), host_and_port) diff --git a/xCAT-openbmc-py/lib/python/agent/common/task.py b/xCAT-openbmc-py/lib/python/agent/common/task.py index 76f7fa04d..1f93cab0e 100644 --- a/xCAT-openbmc-py/lib/python/agent/common/task.py +++ b/xCAT-openbmc-py/lib/python/agent/common/task.py @@ -35,7 +35,7 @@ class BaseCommand(object): self._pre(op, *args, **kwargs) self._execute(op, *args, **kwargs) self._post(op, *args, **kwargs) - except Exception, e: + except Exception as e: # TODO: put e into log print(traceback.format_exc(), file=sys.stderr) return None @@ -65,7 +65,7 @@ class ParallelNodesCommand(BaseCommand): assert self.inventory and type(self.inventory) is dict func = getattr(self, '%s' % op) if len(self.inventory) == 1: - node = self.inventory.keys()[0] + node = list(self.inventory.keys())[0] func(*args, node=node, nodeinfo=self.inventory[node], **kw) return @@ -75,7 +75,7 @@ class ParallelNodesCommand(BaseCommand): for node in self.inventory.keys(): try: gevent_pool.add( gevent.spawn(func, *args, node=node, nodeinfo=self.inventory[node], **kw)) - except Exception, e: + except Exception as e: error = '%s: Internel Error occured in gevent' % node #print(traceback.format_exc(), file=sys.stderr) self.callback.error(error) @@ -89,7 +89,7 @@ class ParallelNodesCommand(BaseCommand): self._pre(op, *args, **kwargs) self._execute_in_parallel(op, *args, **kwargs) self._post(op, *args, **kwargs) - except Exception, e: + except Exception as e: # TODO: put e into log print(traceback.format_exc(), file=sys.stderr) return None diff --git a/xCAT-openbmc-py/lib/python/agent/common/utils.py b/xCAT-openbmc-py/lib/python/agent/common/utils.py index 252541b6c..bdbfba23e 100644 --- a/xCAT-openbmc-py/lib/python/agent/common/utils.py +++ b/xCAT-openbmc-py/lib/python/agent/common/utils.py @@ -63,9 +63,9 @@ def recv_all(sock, size): if left_size < recv_size: tmp_size = left_size buf_part = sock.recv(tmp_size) - buf_parts.append(buf_part) + buf_parts.append(buf_part.decode('utf-8')) buf_size += len(buf_part) - buf = ''.join(buf_parts) + buf = ''.join(str(i) for i in buf_parts) return buf diff --git a/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc/openbmc_bmcconfig.py b/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc/openbmc_bmcconfig.py index 19b990228..b7398d87c 100644 --- a/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc/openbmc_bmcconfig.py +++ b/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc/openbmc_bmcconfig.py @@ -81,7 +81,7 @@ class OpenBMCBmcConfigTask(ParallelNodesCommand): self.callback.info('%s: No attributes returned from the BMC.' % node) return dump_info - keys = dump_dict.keys() + keys = list(dump_dict.keys()) keys.sort() for key in keys: info = '[%d] Generated: %s, Size: %s' % \ @@ -140,7 +140,7 @@ class OpenBMCBmcConfigTask(ParallelNodesCommand): return dump_dict = obmc.list_dump_info() - keys = dump_dict.keys() + keys = list(dump_dict.keys()) keys.sort() for key in keys: @@ -378,6 +378,7 @@ rmdir \"/tmp/$userid\" \n") self.callback.info("%s: BMC Setting Password..." % node) except (SelfServerException, SelfClientException) as e: self.callback.error(e.message, node) + return self.callback.info("%s: BMC password changed. Update 'bmcpasswd' for the node or the 'passwd' table with the new password." % node) @@ -422,7 +423,7 @@ rmdir \"/tmp/$userid\" \n") return self.callback.error(e.message, node) if isinstance(value, dict): - str_value = str(value.values()[0]) + str_value = str(list(value.values())[0]) elif value: str_value = str(value) else: diff --git a/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc/openbmc_eventlog.py b/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc/openbmc_eventlog.py index ad7f34853..65b29f230 100644 --- a/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc/openbmc_eventlog.py +++ b/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc/openbmc_eventlog.py @@ -39,7 +39,7 @@ class OpenBMCEventlogTask(ParallelNodesCommand): # Get all eventlog records eventlog_info_dict = obmc.get_eventlog_info() - keys = eventlog_info_dict.keys() + keys = list(eventlog_info_dict.keys()) # Sort thy keys in natural order keys.sort(key=lambda x : int(x[0:])) @@ -76,7 +76,7 @@ class OpenBMCEventlogTask(ParallelNodesCommand): # Get all eventlog records eventlog_info_dict = obmc.get_eventlog_info() - keys = eventlog_info_dict.keys() + keys = list(eventlog_info_dict.keys()) # Sort the keys in natural order keys.sort(key=lambda x : int(x[0:])) diff --git a/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc/openbmc_flash.py b/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc/openbmc_flash.py index 2b4d21bf7..59e0f4153 100644 --- a/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc/openbmc_flash.py +++ b/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc/openbmc_flash.py @@ -81,7 +81,7 @@ class OpenBMCFlashTask(ParallelNodesCommand): def _get_firmware_version(self, target_file): version = purpose = None - with open(target_file, 'r') as fh: + with open(target_file, encoding="utf8", errors='ignore') as fh: for line in fh: if 'version=' in line: version = line.split('=')[-1].strip() @@ -159,7 +159,7 @@ class OpenBMCFlashTask(ParallelNodesCommand): mapping_ids = [] if self.firmware: - version_list = self.firmware.keys() + version_list = list(self.firmware.keys()) else: return [] @@ -348,7 +348,7 @@ class OpenBMCFlashTask(ParallelNodesCommand): firmware_version = '' if self.firmware_file: - firmware_version = self.firmware.keys()[0] + firmware_version = list(self.firmware.keys())[0] try: obmc.upload_firmware(self.firmware_file) except (SelfServerException, SelfClientException) as e: diff --git a/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc/openbmc_inventory.py b/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc/openbmc_inventory.py index dd9d15c76..fbf02c12f 100644 --- a/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc/openbmc_inventory.py +++ b/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc/openbmc_inventory.py @@ -29,7 +29,7 @@ class OpenBMCInventoryTask(ParallelNodesCommand): target_file = utils.get_full_path(self.cwd, target_file) version = purpose = None - with open(target_file, 'r') as fh: + with open(target_file, encoding="utf8", errors='ignore') as fh: for line in fh: if 'version=' in line: version = line.split('=')[-1].strip() @@ -44,13 +44,13 @@ class OpenBMCInventoryTask(ParallelNodesCommand): def _get_firm_info(self, firm_info_list): (has_functional, firm_obj_dict) = firm_info_list firm_info = [] - keys = firm_obj_dict.keys() + keys = list(firm_obj_dict.keys()) keys.sort() for key in keys: flag = '' if firm_obj_dict[key].functional: flag = '*' - elif firm_obj_dict[key].priority == 0: + elif firm_obj_dict[key].priority == 0: if not has_functional: flag = '*' else: @@ -115,7 +115,7 @@ class OpenBMCInventoryTask(ParallelNodesCommand): # Process returned inventory_info_dict depending on the inventory requested if all == 1: # Everything gets displayed, even firmware - keys = inventory_info_dict.keys() + keys = list(inventory_info_dict.keys()) keys.sort() for key in keys: inventory_info += utils.sort_string_with_numbers(inventory_info_dict[key]) diff --git a/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc_client.py b/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc_client.py index c244abc40..3b1fffee4 100644 --- a/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc_client.py +++ b/xCAT-openbmc-py/lib/python/agent/hwctl/openbmc_client.py @@ -450,7 +450,7 @@ class OpenBMCRest(object): payload = { "data": PROJECT_PAYLOAD + BMC_URLS['reboot']['field'] } try: self.request('PUT', BMC_URLS['reboot']['path'], payload=payload, cmd='bmc_reset') - except SelfServerException,SelfClientException: + except (SelfServerException,SelfClientException) as e: # TODO: Need special handling for bmc reset, as it is normal bmc may return error pass @@ -578,7 +578,8 @@ class OpenBMCRest(object): logger.debug('IndexError (-2) for %s' % key) continue - key_type = filter(lambda x:x not in '0123456789', key_id).upper() + key_type_list = [x for x in key_id if x not in '0123456789'] + key_type = ''.join(key_type_list).upper() if key_type == 'CORE': key_type = 'CPU' @@ -656,7 +657,7 @@ class OpenBMCRest(object): # Check if policy table file is there ras_event_mapping = {} if os.path.isfile(RAS_POLICY_TABLE): - with open(RAS_POLICY_TABLE, "r") as data_file: + with open(RAS_POLICY_TABLE, encoding="utf8", errors='ignore') as data_file: policy_hash = json.load(data_file) if policy_hash: ras_event_mapping = policy_hash['events'] diff --git a/xCAT-openbmc-py/lib/python/agent/xcatagent/server.py b/xCAT-openbmc-py/lib/python/agent/xcatagent/server.py index 85a92dddd..7a676975a 100644 --- a/xCAT-openbmc-py/lib/python/agent/xcatagent/server.py +++ b/xCAT-openbmc-py/lib/python/agent/xcatagent/server.py @@ -25,7 +25,7 @@ class XCATMessager(utils.Messager): def _send(self, d): buf = json.dumps(d) self.sem.acquire() - self.sock.sendall(utils.int2bytes(len(buf)) + buf) + self.sock.sendall(utils.int2bytes(len(buf)) + buf.encode('utf-8')) self.sem.release() def info(self, msg): @@ -101,7 +101,7 @@ class Server(object): new_args=[] if req['args']: for a in req['args']: - new_args.append(a.encode('utf-8')) + new_args.append(a) # call the function in the specified manager func(req['nodeinfo'], new_args) # after the method returns, the request should be handled From de80b54b8d4e1b748266e5cdbc7ef78593727092 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Tue, 12 Mar 2019 17:48:31 +0800 Subject: [PATCH 13/13] Add another email address for BAI Yuan --- .mailmap | 1 + 1 file changed, 1 insertion(+) diff --git a/.mailmap b/.mailmap index d01484002..2c1f4e77b 100644 --- a/.mailmap +++ b/.mailmap @@ -4,6 +4,7 @@ Arif Ali Arif Ali Arif Ali BAI Yuan +BAI Yuan Bill Wajda Bill Wajda Brian Elliott Finley