'learn dmi facts from system
Use dmidecode executable if available'

def get_dmi_facts(self):

    dmi_facts = {}
    dmi_bin = self.module.get_bin_path('dmidecode')
    DMI_DICT = dict(bios_date='bios-release-date', bios_version='bios-version', form_factor='chassis-type', product_name='system-product-name', product_serial='system-serial-number', product_uuid='system-uuid', product_version='system-version', system_vendor='system-manufacturer')
    for (k, v) in DMI_DICT.items():
        if (dmi_bin is not None):
            (rc, out, err) = self.module.run_command(('%s    -s    %s' % (dmi_bin, v)))
            if (rc == 0):
                dmi_facts[k] = ''.join([line for line in out.splitlines() if (not line.startswith('#'))])
                try:
                    json.dumps(dmi_facts[k])
                except UnicodeDecodeError:
                    dmi_facts[k] = 'NA'
            else:
                dmi_facts[k] = 'NA'
        else:
            dmi_facts[k] = 'NA'
    return dmi_facts
