2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-06-22 05:55:35 +00:00

Merge pull request #6080 from neo954/rhels8-tmp

Merge `master` branch to `rhels8` branch
This commit is contained in:
zet809
2019-03-12 18:04:10 +08:00
committed by GitHub
17 changed files with 63 additions and 45 deletions

View File

@ -4,6 +4,7 @@ Arif Ali <mail@arif-ali.co.uk>
Arif Ali <mail@arif-ali.co.uk> <arifali@8638fb3e-16cb-4fca-ae20-7b5d299a9bcd>
Arif Ali <mail@arif-ali.co.uk> <arif-ali@users.noreply.github.com>
BAI Yuan <bybai@cn.ibm.com>
BAI Yuan <bybai@cn.ibm.com> <root@byubu01.cluster.com>
Bill Wajda <billwajda@hotmail.com> <billwajda@8638fb3e-16cb-4fca-ae20-7b5d299a9bcd>
Bill Wajda <billwajda@hotmail.com>
Brian Elliott Finley <brian@thefinleys.com> <brianfinley@8638fb3e-16cb-4fca-ae20-7b5d299a9bcd>

View File

@ -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.
@ -74,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
------------------------------------------

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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:]))

View File

@ -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:

View File

@ -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])

View File

@ -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']

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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" });
}

View File

@ -167,7 +167,6 @@ nodeset_stat
nodeset_grub2
nodeset_petitboot
nodestat_err_node
nodestat_noderange
nodestat_usage
packimage_h
packimage_v

View File

@ -235,8 +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: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;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
@ -267,7 +267,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 +275,15 @@ 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;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: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;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
@ -309,7 +311,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 +319,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;rm -rf /tmp/testnode1.stanza;fi
end
start:nodeset_yaboot
@ -374,7 +378,7 @@ end
start:nodeset_disjointdhcps_petitboot
description: Verify the disjointdhcps feature when petitboot is used for OS loader.
label:others
cmd:rmdef testnode1
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
@ -459,7 +463,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 +472,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;rm -rf /tmp/testnode1.stanza;fi
end
start:nodeset_switch_osimage