def get_sw_info(conn): res = SWInfo() res.OS_version = utils.get_os() with conn.open_sftp() as sftp: def get(fname): try: return ssh_utils.read_from_remote(sftp, fname) except: return None res.kernel_version = get('/proc/version') res.partitions = get('/etc/mtab') def rr(cmd): try: return ssh_utils.run_over_ssh(conn, cmd, nolog=True) except: return None res.libvirt_version = rr("virsh -v") res.qemu_version = rr("qemu-system-x86_64 --version") res.ceph_version = rr("ceph --version") return res
def install_utils(self, node, rossh, max_retry=3, timeout=5): need_install = [] packs = [('screen', 'screen')] os_info = get_os(rossh) if self.use_system_fio: packs.append(('fio', 'fio')) else: packs.append(('bzip2', 'bzip2')) for bin_name, package in packs: if bin_name is None: need_install.append(package) continue try: rossh('which ' + bin_name, nolog=True) except OSError: need_install.append(package) if len(need_install) != 0: if 'redhat' == os_info.distro: cmd = "sudo yum -y install " + " ".join(need_install) else: cmd = "sudo apt-get -y install " + " ".join(need_install) for _ in range(max_retry): try: rossh(cmd) break except OSError as err: time.sleep(timeout) else: raise OSError("Can't install - " + str(err)) if not self.use_system_fio: fio_dir = os.path.dirname(os.path.dirname(wally.__file__)) fio_dir = os.path.join(os.getcwd(), fio_dir) fio_dir = os.path.join(fio_dir, 'fio_binaries') fname = 'fio_{0.release}_{0.arch}.bz2'.format(os_info) fio_path = os.path.join(fio_dir, fname) if not os.path.exists(fio_path): raise RuntimeError( "No prebuild fio available for {0}".format(os_info)) bz_dest = self.join_remote('fio.bz2') with node.connection.open_sftp() as sftp: sftp.put(fio_path, bz_dest) rossh("bzip2 --decompress " + bz_dest, nolog=True) rossh("chmod a+x " + self.join_remote("fio"), nolog=True)
def install_utils(self, node, rossh, max_retry=3, timeout=5): need_install = [] packs = [('screen', 'screen')] os_info = get_os(rossh) if self.use_system_fio: packs.append(('fio', 'fio')) else: packs.append(('bzip2', 'bzip2')) for bin_name, package in packs: if bin_name is None: need_install.append(package) continue try: rossh('which ' + bin_name, nolog=True) except OSError: need_install.append(package) if len(need_install) != 0: if 'redhat' == os_info.distro: cmd = "sudo yum -y install " + " ".join(need_install) else: cmd = "sudo apt-get -y install " + " ".join(need_install) for _ in range(max_retry): try: rossh(cmd) break except OSError as err: time.sleep(timeout) else: raise OSError("Can't install - " + str(err)) if not self.use_system_fio: fio_dir = os.path.dirname(os.path.dirname(wally.__file__)) fio_dir = os.path.join(os.getcwd(), fio_dir) fio_dir = os.path.join(fio_dir, 'fio_binaries') fname = 'fio_{0.release}_{0.arch}.bz2'.format(os_info) fio_path = os.path.join(fio_dir, fname) if not os.path.exists(fio_path): raise RuntimeError("No prebuild fio available for {0}".format(os_info)) bz_dest = self.join_remote('fio.bz2') with node.connection.open_sftp() as sftp: sftp.put(fio_path, bz_dest) rossh("bzip2 --decompress " + bz_dest, nolog=True) rossh("chmod a+x " + self.join_remote("fio"), nolog=True)