Merge pull request #31237 from mcalmer/zypper_py-add-OEM-product-handling

add handling for OEM products
This commit is contained in:
Mike Place 2016-02-16 08:12:20 -07:00
commit e8f3a707ae

View file

@ -1204,6 +1204,9 @@ def list_products(all=False):
all
List all products available or only installed. Default is False.
Includes handling for OEM products, which read the OEM productline file
and overwrite the release value.
CLI Examples:
.. code-block:: bash
@ -1212,6 +1215,7 @@ def list_products(all=False):
salt '*' pkg.list_products all=True
'''
ret = list()
OEM_PATH = "/var/lib/suseRegister/OEM"
doc = dom.parseString(__salt__['cmd.run'](("zypper -x products{0}".format(not all and ' -i' or '')),
output_loglevel='trace'))
for prd in doc.getElementsByTagName('product-list')[0].getElementsByTagName('product'):
@ -1225,7 +1229,13 @@ def list_products(all=False):
prd.getElementsByTagName('description')
).split(os.linesep)]
)
if 'productline' in p_nfo and p_nfo['productline']:
oem_file = os.path.join(OEM_PATH, p_nfo['productline'])
if os.path.isfile(oem_file):
with salt.utils.fopen(oem_file, 'r') as rfile:
oem_release = rfile.readline().strip()
if oem_release:
p_nfo['release'] = oem_release
ret.append(p_nfo)
return ret