cpu-parse: Wrap with python script
This changes the invocation from ./cpu-gather.py | ./cpu-parse.sh to ./cpu-gather.py [--gather] | ./cpu-gather.py --parse Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
b00a7e87f1
commit
12f01dcb04
@ -192,6 +192,15 @@ def gather(args):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def parse(args):
|
||||||
|
os.environ["CPU_GATHER_PY"] = "true"
|
||||||
|
output = subprocess.check_output(
|
||||||
|
"./cpu-parse.sh",
|
||||||
|
stderr=subprocess.STDOUT,
|
||||||
|
universal_newlines=True)
|
||||||
|
print(output)
|
||||||
|
|
||||||
|
|
||||||
def output_to_text(data):
|
def output_to_text(data):
|
||||||
output = list()
|
output = list()
|
||||||
|
|
||||||
@ -231,8 +240,21 @@ def main():
|
|||||||
"If unset, will try '/usr/bin/qemu-system-x86_64', "
|
"If unset, will try '/usr/bin/qemu-system-x86_64', "
|
||||||
"'/usr/bin/qemu-kvm', and '/usr/libexec/qemu-kvm'.")
|
"'/usr/bin/qemu-kvm', and '/usr/libexec/qemu-kvm'.")
|
||||||
|
|
||||||
|
mode = parser.add_mutually_exclusive_group()
|
||||||
|
mode.add_argument(
|
||||||
|
"--gather",
|
||||||
|
action="store_true",
|
||||||
|
help="Acquire data on target system. This is the default.")
|
||||||
|
mode.add_argument(
|
||||||
|
"--parse",
|
||||||
|
action="store_true",
|
||||||
|
help="Parse data for libvirt use.")
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if not args.gather and not args.parse:
|
||||||
|
args.gather = True
|
||||||
|
|
||||||
if not args.path_to_qemu:
|
if not args.path_to_qemu:
|
||||||
args.path_to_qemu = "qemu-system-x86_64"
|
args.path_to_qemu = "qemu-system-x86_64"
|
||||||
search = [
|
search = [
|
||||||
@ -243,8 +265,11 @@ def main():
|
|||||||
if os.path.isfile(f):
|
if os.path.isfile(f):
|
||||||
args.path_to_qemu = f
|
args.path_to_qemu = f
|
||||||
|
|
||||||
data = gather(args)
|
if args.gather:
|
||||||
print(output_to_text(data))
|
data = gather(args)
|
||||||
|
print(output_to_text(data))
|
||||||
|
else:
|
||||||
|
parse(args)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Usage:
|
if [ -z "${CPU_GATHER_PY}" ]; then
|
||||||
# ./cpu-gather.py | ./cpu-parse.sh
|
echo >&2 "Do not call this script directly. Use 'cpu-gather.py' instead."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
data=`cat`
|
data=`cat`
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user