From f5bcecd9eb444132f2d89d85f5f039d03d9af466 Mon Sep 17 00:00:00 2001 From: Chris Hambridge Date: Mon, 24 Jul 2017 16:34:52 -0400 Subject: [PATCH] Provide uuid for the connection information in the output. Closes #81. --- doc/command_syntax_usage.rst | 1 + library/run_cmds.py | 7 +++++++ module_utils/subman_facts_command.py | 7 ++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/command_syntax_usage.rst b/doc/command_syntax_usage.rst index a33f6bd..1e5967f 100644 --- a/doc/command_syntax_usage.rst +++ b/doc/command_syntax_usage.rst @@ -76,6 +76,7 @@ this contains a large amount of information about the operating system, hardware - ``connection.host`` - The host address of the connection - ``connection.port`` - The port used for the connection +- ``connection.uuid`` - An identifier for the connection either from subscription manager or generated - ``cpu.bogomips`` - measurement of CPU speed made by the Linux kernel - ``cpu.count`` - number of processors - ``cpu.cpu_family`` - cpu family diff --git a/library/run_cmds.py b/library/run_cmds.py index ae53f10..7f4880f 100644 --- a/library/run_cmds.py +++ b/library/run_cmds.py @@ -14,6 +14,7 @@ """Commands to run on machines""" import json +import uuid import ast # pylint:disable=no-name-in-module @@ -157,6 +158,12 @@ def execute_commands(self): info_dict['connection.host'] = self.host info_dict['connection.port'] = self.port + + if info_dict['subman.virt.uuid'] == 'error': + info_dict['connection.uuid'] = str(uuid.uuid4()) + else: + info_dict['connection.uuid'] = info_dict['subman.virt.uuid'] + return info_dict diff --git a/module_utils/subman_facts_command.py b/module_utils/subman_facts_command.py index cb5a8bc..3c12e55 100644 --- a/module_utils/subman_facts_command.py +++ b/module_utils/subman_facts_command.py @@ -44,7 +44,8 @@ def __init__(self): 'subman.cpu.cpu(s)', 'subman.cpu.cpu_socket(s)', 'subman.virt.host_type', - 'subman.virt.is_guest'] + 'subman.virt.is_guest', + 'subman.virt.uuid'] self.cmd_names['subman_has_facts'] = ['subman.hash_facts_file'] self.fields = {'subman.cpu.core(s)_per_socket': _('cpu.core(s)_' @@ -69,6 +70,10 @@ def __init__(self): '(from ' 'subscription-manager ' 'facts --list)'), + 'subman.virt.uuid': _('virt.uuid ' + '(from ' + 'subscription-manager ' + 'facts --list)'), 'subman.has_facts_file': _('Whether ' 'subscription-manager' ' has a facts file')}