summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Kraft <george.kraft@calxeda.com>2013-11-05 13:55:40 -0600
committerGeorge Kraft <george.kraft@calxeda.com>2013-11-05 13:55:40 -0600
commit717ffbbd14a8669b32bb4056ba52f01b7f0c25b1 (patch)
tree5295021f86fddc85440776e820405704f3a99d9d
parent081d083cff8c9e4477a93bc1ba5dc213a867021a (diff)
downloadcxmanage-717ffbbd14a8669b32bb4056ba52f01b7f0c25b1.tar.gz
CXMAN-236: Add client-side info to tspackage
Operating system/distro, tool versions, and python packages
-rw-r--r--cxmanage_api/cli/commands/tspackage.py37
1 files changed, 36 insertions, 1 deletions
diff --git a/cxmanage_api/cli/commands/tspackage.py b/cxmanage_api/cli/commands/tspackage.py
index 10b812d..c10054a 100644
--- a/cxmanage_api/cli/commands/tspackage.py
+++ b/cxmanage_api/cli/commands/tspackage.py
@@ -41,10 +41,13 @@
import os
-import time
+import pkg_resources
import shutil
+import subprocess
+import sys
import tarfile
import tempfile
+import time
from cxmanage_api.cli import get_tftp, get_nodes, run_command, COMPONENTS
@@ -83,6 +86,8 @@ def tspackage_command(args):
quiet = args.quiet
+ write_client_info()
+
if not quiet:
print("Getting version information...")
write_version_info(args, nodes)
@@ -130,6 +135,36 @@ def tspackage_command(args):
shutil.rmtree(temp_dir)
+def write_client_info():
+ """ Write client-side info """
+ with open("client.txt", "w") as fout:
+ def write_command(command):
+ """ Safely write output from a single command to the file """
+ try:
+ fout.write(subprocess.check_output(
+ command, stderr=subprocess.STDOUT, shell=True
+ ))
+ except subprocess.CalledProcessError:
+ pass
+
+ fout.write("[ Operating System ]\n")
+ fout.write("Operating system: %s\n" % sys.platform)
+ write_command("lsb_release -a")
+ write_command("uname -a")
+
+ fout.write("\n[ Tool versions ]\n")
+ fout.write("Python %s\n" % sys.version.replace("\n", ""))
+ cxmanage_version = pkg_resources.require("cxmanage")[0].version
+ fout.write("cxmanage version %s\n" % cxmanage_version)
+ pyipmi_version = pkg_resources.require("pyipmi")[0].version
+ fout.write("pyipmi version %s\n" % pyipmi_version)
+ ipmitool_path = os.environ.get('IPMITOOL_PATH', 'ipmitool')
+ write_command("%s -V" % ipmitool_path)
+
+ fout.write("\n[ Python packages ]\n")
+ write_command("pip freeze")
+
+
def write_version_info(args, nodes):
"""Write the version info (like cxmanage info) for each node
to their respective files.