mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-21 19:02:25 +00:00
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
|
||||
|
||||
|
||||
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):
|
||||
output = list()
|
||||
|
||||
@ -231,8 +240,21 @@ def main():
|
||||
"If unset, will try '/usr/bin/qemu-system-x86_64', "
|
||||
"'/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()
|
||||
|
||||
if not args.gather and not args.parse:
|
||||
args.gather = True
|
||||
|
||||
if not args.path_to_qemu:
|
||||
args.path_to_qemu = "qemu-system-x86_64"
|
||||
search = [
|
||||
@ -243,8 +265,11 @@ def main():
|
||||
if os.path.isfile(f):
|
||||
args.path_to_qemu = f
|
||||
|
||||
data = gather(args)
|
||||
print(output_to_text(data))
|
||||
if args.gather:
|
||||
data = gather(args)
|
||||
print(output_to_text(data))
|
||||
else:
|
||||
parse(args)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -1,7 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Usage:
|
||||
# ./cpu-gather.py | ./cpu-parse.sh
|
||||
if [ -z "${CPU_GATHER_PY}" ]; then
|
||||
echo >&2 "Do not call this script directly. Use 'cpu-gather.py' instead."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
data=`cat`
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user