diff options
author | George Kraft <george.kraft@calxeda.com> | 2012-08-23 12:55:06 -0500 |
---|---|---|
committer | George Kraft <george.kraft@calxeda.com> | 2012-08-23 12:55:06 -0500 |
commit | c8f9dcbafa658ab5db1dc5f902852aa321c7edd8 (patch) | |
tree | 4f8256cbfaafb32c97cd64d2d5bc3ea7b53222c9 | |
parent | a64f60868eae4b576c88d8bc432ebd678631e6e2 (diff) | |
download | cxmanage-c8f9dcbafa658ab5db1dc5f902852aa321c7edd8.tar.gz |
cxmanage: Check ipmitool version at start
-rwxr-xr-x | scripts/cxmanage | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/scripts/cxmanage b/scripts/cxmanage index 019e3c6..b01ea7b 100755 --- a/scripts/cxmanage +++ b/scripts/cxmanage @@ -37,6 +37,7 @@ import argparse import os import pkgutil import sys +import subprocess from cxmanage.controller import Controller @@ -242,31 +243,54 @@ def validate_args(args): def main(): """Get args and go""" + # Parse arguments parser = build_parser() args = parser.parse_args() validate_args(args) + # Set ipmitool path if args.ipmipath: if os.path.isdir(args.ipmipath): args.ipmipath = args.ipmipath.rstrip('/') + '/ipmitool' print args.ipmipath os.environ['IPMITOOL_PATH'] = args.ipmipath + # Check versions + check_versions() + + # Make the controller verbosity = 1 if args.verbose: verbosity = 2 elif args.quiet: verbosity = 0 - controller = Controller(verbosity=verbosity, max_threads=args.threads, retries=args.retry) + # Set TFTP and add targets set_tftp(controller, args) add_targets(controller, args) + # Run the command sys.exit(args.func(controller, args)) +def check_versions(): + """Check versions of dependencies""" + # Check ipmitool version + if 'IPMITOOL_PATH' in os.environ: + args = [os.environ['IPMITOOL_PATH'], '-V'] + else: + args = ['ipmitool', '-V'] + ipmitool_version = subprocess.check_output(args).split()[2] + if not '-cx' in ipmitool_version: + print ('ERROR: cxmanage is not compatible with IPMItool version %s\n' + % ipmitool_version) + print 'Please make sure a Calxeda extended version of IPMItool is available' + print 'in your PATH, or point to one with the --ipmipath argument.' + sys.exit(1) + + def set_tftp(controller, args): """Set up tftp server on controller""" if args.internal_tftp: |