Skip to content

Commit

Permalink
Merge pull request #31237 from mcalmer/zypper_py-add-OEM-product-hand…
Browse files Browse the repository at this point in the history
…ling

add handling for OEM products
  • Loading branch information
Mike Place committed Feb 16, 2016
2 parents 415654e + d773b73 commit e8f3a70
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion salt/modules/zypper.py
Expand Up @@ -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
Expand All @@ -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'):
Expand All @@ -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
Expand Down

0 comments on commit e8f3a70

Please sign in to comment.