Skip to content

Commit

Permalink
build: fix some build failures on RHEL8
Browse files Browse the repository at this point in the history
Signed-off-by: Li Xi <pkuelelixi@163.com>
  • Loading branch information
LiXi-storage committed May 6, 2021
1 parent 6989a12 commit 2402d61
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
4 changes: 4 additions & 0 deletions pycoral/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
"/" + LUSTRE_RPM_DIR_BASENAME)
# Basename of SRPMS
SRPMS_DIR_BASENAME = "SRPMS"
# Basename of RPMS
RPMS_DIR_BASENAME = "RPMS"
LUSTRE_DIR_BASENAMES = [SRPMS_DIR_BASENAME, RPMS_DIR_BASENAME]
E2FSPROGS_DIR_BASENAMES = [SRPMS_DIR_BASENAME, RPMS_DIR_BASENAME]
# Lustre SRPM dir
CORAL_ISO_LUSTRE_SRPM_DIR = (CORAL_ISO_LUSTRE_DIR +
"/" + SRPMS_DIR_BASENAME)
Expand Down
13 changes: 13 additions & 0 deletions pycoral/install_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,19 @@ def _cih_services_preserve(self, log, timeout=90):
"""
Start the services after reinstallation with a timeout.
"""
if len(self.cih_preserve_services) == 0:
return 0

service_str = ""
for service in self.cih_preserve_services:
if service_str == "":
service_str = service
else:
service_str += ", " + service
if service_str != "":
log.cl_info("preserving services [%s] after reinstalling Coral RPMs "
"on host [%s]",
service_str, self.cih_host.sh_hostname)
ret = utils.wait_condition(log, self._cih_services_try_preserve,
(), timeout=timeout)
if ret:
Expand Down
31 changes: 19 additions & 12 deletions pycoral/ssh_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,7 @@ def sh_encode_remote_paths(self, paths, escape=True):
paths = [scp_remote_escape(path) for path in paths]
if self.sh_inited_as_local and not self.sh_ssh_for_local:
return '"%s"' % (" ".join(paths))
else:
return 'root@%s:"%s"' % (self.sh_hostname, " ".join(paths))
return 'root@%s:"%s"' % (self.sh_hostname, " ".join(paths))

def sh_set_umask_perms(self, dest):
"""
Expand Down Expand Up @@ -888,7 +887,7 @@ def sh_send_file(self, log, source, dest, delete_dest=False,
from_host = self.sh_hostname
ret = self.sh_run(log, rsync, timeout=timeout)
if ret.cr_exit_status:
log.cl_error("failed to send file %s on host [%s] to dest [%s] "
log.cl_error("failed to send file [%s] on host [%s] to dest [%s] "
"on host [%s], command = [%s], ret = [%d], "
"stdout = [%s], stderr = [%s]",
source, from_host, dest, remote_host.sh_hostname,
Expand Down Expand Up @@ -1721,19 +1720,27 @@ def sh_sha256sum(self, log, fpath):
return None
return retval.cr_stdout.strip()

def sh_virsh_dominfo(self, log, hostname):
def sh_virsh_dominfo(self, log, hostname, quiet=False):
"""
Get the virsh dominfo of a domain
"""
command = ("virsh dominfo %s" % hostname)
retval = self.sh_run(log, command)
if retval.cr_exit_status:
log.cl_debug("failed to run command [%s] on host [%s], "
"ret = [%d], stdout = [%s], stderr = [%s]",
command, self.sh_hostname,
retval.cr_exit_status,
retval.cr_stdout,
retval.cr_stderr)
if quiet:
log.cl_debug("failed to run command [%s] on host [%s], "
"ret = [%d], stdout = [%s], stderr = [%s]",
command, self.sh_hostname,
retval.cr_exit_status,
retval.cr_stdout,
retval.cr_stderr)
else:
log.cl_error("failed to run command [%s] on host [%s], "
"ret = [%d], stdout = [%s], stderr = [%s]",
command, self.sh_hostname,
retval.cr_exit_status,
retval.cr_stdout,
retval.cr_stderr)
return None

lines = retval.cr_stdout.splitlines()
Expand All @@ -1755,7 +1762,7 @@ def sh_virsh_dominfo_state(self, log, hostname, quiet=False):
"""
Get the state of a hostname
"""
dominfos = self.sh_virsh_dominfo(log, hostname)
dominfos = self.sh_virsh_dominfo(log, hostname, quiet=quiet)
if dominfos is None:
if quiet:
log.cl_debug("failed to get dominfo of [%s] on host [%s]",
Expand Down Expand Up @@ -3662,7 +3669,7 @@ def sh_unpack_rpm(self, log, rpm_fpath, target_dir):
def sh_sync_two_dirs(self, log, src, dest_parent):
"""
Sync a dir to another dir. dest_parent is the target parent dir. And
the existing dir will be removed
the dir with the same name under that parent will be removed.
"""
# Stripe / otherwise it will has different meaning
dest_parent = dest_parent.rstrip("/")
Expand Down

0 comments on commit 2402d61

Please sign in to comment.