Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP1:GA
salt.3514
0040-Check-if-EOL-is-available-in-a-particular-...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0040-Check-if-EOL-is-available-in-a-particular-product-bs.patch of Package salt.3514
From fd9c4e96caba139921e6612c1bc731533626a801 Mon Sep 17 00:00:00 2001 From: Bo Maryniuk <bo@suse.de> Date: Tue, 12 Apr 2016 13:52:35 +0200 Subject: [PATCH 40/40] Check if EOL is available in a particular product (bsc#975093) Update SLE11 SP3 data Update SLE12 SP1 data Adjust test values according to the testing data --- salt/modules/zypper.py | 13 +++++++-- .../unit/modules/zypp/zypper-products-sle11sp3.xml | 10 +++++++ .../unit/modules/zypp/zypper-products-sle12sp1.xml | 8 ++++++ tests/unit/modules/zypper_test.py | 32 ++++++++++++---------- 4 files changed, 45 insertions(+), 18 deletions(-) diff --git a/salt/modules/zypper.py b/salt/modules/zypper.py index 416ee92..1cb8a43 100644 --- a/salt/modules/zypper.py +++ b/salt/modules/zypper.py @@ -1317,12 +1317,19 @@ def list_products(all=False, refresh=False): call = __salt__['cmd.run_all'](cmd, output_loglevel='trace') doc = dom.parseString(_zypper_check_result(call, xml=True)) - for prd in doc.getElementsByTagName('product-list')[0].getElementsByTagName('product'): + product_list = doc.getElementsByTagName('product-list') + if not product_list: + return ret # No products found + + for prd in product_list[0].getElementsByTagName('product'): p_nfo = dict() for k_p_nfo, v_p_nfo in prd.attributes.items(): p_nfo[k_p_nfo] = k_p_nfo not in ['isbase', 'installed'] and v_p_nfo or v_p_nfo in ['true', '1'] - p_nfo['eol'] = prd.getElementsByTagName('endoflife')[0].getAttribute('text') - p_nfo['eol_t'] = int(prd.getElementsByTagName('endoflife')[0].getAttribute('time_t')) + + eol = prd.getElementsByTagName('endoflife') + if eol: + p_nfo['eol'] = eol[0].getAttribute('text') + p_nfo['eol_t'] = int(eol[0].getAttribute('time_t') or 0) p_nfo['description'] = " ".join( [line.strip() for line in _get_first_aggregate_text( prd.getElementsByTagName('description') diff --git a/tests/unit/modules/zypp/zypper-products-sle11sp3.xml b/tests/unit/modules/zypp/zypper-products-sle11sp3.xml index 89a85e3..99444fe 100644 --- a/tests/unit/modules/zypp/zypper-products-sle11sp3.xml +++ b/tests/unit/modules/zypp/zypper-products-sle11sp3.xml @@ -31,7 +31,17 @@ offers common management tools and technology certifications across the platform, and each product is enterprise-class.</description></product> +<product name="SUSE_SLES" version="11.3" release="1.201" epoch="0" arch="x86_64" productline="" registerrelease="" vendor="SUSE LINUX Products GmbH, Nuernberg, Germany" summary="SUSE Linux Enterprise Server 11 SP3 No EOL" shortname="" flavor="" isbase="0" repo="nu_novell_com:SLES11-SP3-Updates" installed="0">0x7ffdb538e948<description>SUSE Linux Enterprise offers a comprehensive + suite of products built on a single code base. + The platform addresses business needs from + the smallest thin-client devices to the world’s + most powerful high-performance computing + and mainframe servers. SUSE Linux Enterprise + offers common management tools and technology + certifications across the platform, and + each product is enterprise-class.</description></product> <product name="SUSE-Manager-Server" version="2.1" release="1.2" epoch="0" arch="x86_64" productline="" registerrelease="" vendor="SUSE LINUX Products GmbH, Nuernberg, Germany" summary="SUSE Manager Server" shortname="" flavor="cd" isbase="0" repo="nu_novell_com:SUSE-Manager-Server-2.1-Pool" installed="0"><endoflife time_t="0" text="1970-01-01T01:00:00+0100"/>0x7ffdb538e948<description>SUSE Manager Server appliance</description></product> <product name="SUSE-Manager-Server" version="2.1" release="1.2" epoch="0" arch="x86_64" productline="manager" registerrelease="" vendor="SUSE LINUX Products GmbH, Nuernberg, Germany" summary="SUSE Manager Server" shortname="" flavor="cd" isbase="1" repo="@System" installed="1"><endoflife time_t="0" text="1970-01-01T01:00:00+0100"/>0x7ffdb538e948<description>SUSE Manager Server appliance</description></product> +<product name="SUSE-Manager-Server-Broken-EOL" version="2.1" release="1.2" epoch="0" arch="x86_64" productline="manager" registerrelease="" vendor="SUSE LINUX Products GmbH, Nuernberg, Germany" summary="SUSE Manager Server" shortname="" flavor="cd" isbase="1" repo="@System" installed="1"><endoflife wrong="attribute"/>0x7ffdb538e948<description>SUSE Manager Server appliance</description></product> </product-list> </stream> diff --git a/tests/unit/modules/zypp/zypper-products-sle12sp1.xml b/tests/unit/modules/zypp/zypper-products-sle12sp1.xml index 1a50363..a086058 100644 --- a/tests/unit/modules/zypp/zypper-products-sle12sp1.xml +++ b/tests/unit/modules/zypp/zypper-products-sle12sp1.xml @@ -24,6 +24,14 @@ provisioning.</description></product> SUSE Manager Tools provide packages required to connect to a SUSE Manager Server. <p></description></product> +<product name="sle-manager-tools-beta-no-eol" version="12" release="0" epoch="0" arch="x86_64" vendor="obs://build.suse.de/Devel:Galaxy:Manager:Head" summary="SUSE Manager Tools" repo="SUSE-Manager-Head" productline="" registerrelease="" shortname="Manager-Tools" flavor="POOL" isbase="false" installed="false"><registerflavor>extension</registerflavor><description><p> + SUSE Manager Tools provide packages required to connect to a + SUSE Manager Server. + <p></description></product> +<product name="sle-manager-tools-beta-broken-eol" version="12" release="0" epoch="0" arch="x86_64" vendor="obs://build.suse.de/Devel:Galaxy:Manager:Head" summary="SUSE Manager Tools" repo="SUSE-Manager-Head" productline="" registerrelease="" shortname="Manager-Tools" flavor="POOL" isbase="false" installed="false"><endoflife wrong="attribute"/><registerflavor>extension</registerflavor><description><p> + SUSE Manager Tools provide packages required to connect to a + SUSE Manager Server. + <p></description></product> <product name="SLES" version="12.1" release="0" epoch="0" arch="x86_64" vendor="SUSE" summary="SUSE Linux Enterprise Server 12 SP1" repo="@System" productline="sles" registerrelease="" shortname="SLES12-SP1" flavor="DVD" isbase="true" installed="true"><endoflife time_t="1730332800" text="2024-10-31T01:00:00+01"/><registerflavor/><description>SUSE Linux Enterprise offers a comprehensive suite of products built on a single code base. The platform addresses business needs from diff --git a/tests/unit/modules/zypper_test.py b/tests/unit/modules/zypper_test.py index 67cf52a..97e42ef 100644 --- a/tests/unit/modules/zypper_test.py +++ b/tests/unit/modules/zypper_test.py @@ -153,24 +153,26 @@ class ZypperTestCase(TestCase): for filename, test_data in { 'zypper-products-sle12sp1.xml': { 'name': ['SLES', 'SLES', 'SUSE-Manager-Proxy', - 'SUSE-Manager-Server', 'sle-manager-tools-beta'], + 'SUSE-Manager-Server', 'sle-manager-tools-beta', + 'sle-manager-tools-beta-broken-eol', 'sle-manager-tools-beta-no-eol'], 'vendor': 'SUSE LLC <https://www.suse.com/>', - 'release': ['0', '0', '0', '0', '0'], - 'productline': [False, False, False, False, 'sles'], - 'eol_t': [1509408000, 1522454400, 1522454400, 1730332800, 1730332800], - 'isbase': [False, False, False, False, True], - 'installed': [False, False, False, False, True], + 'release': ['0', '0', '0', '0', '0', '0', '0'], + 'productline': [False, False, False, False, False, False, 'sles'], + 'eol_t': [None, 0, 1509408000, 1522454400, 1522454400, 1730332800, 1730332800], + 'isbase': [False, False, False, False, False, False, True], + 'installed': [False, False, False, False, False, False, True], }, 'zypper-products-sle11sp3.xml': { - 'name': ['SUSE-Manager-Server', 'SUSE-Manager-Server', - 'SUSE_SLES', 'SUSE_SLES', 'SUSE_SLES-SP4-migration'], + 'name': ['SUSE-Manager-Server', 'SUSE-Manager-Server', 'SUSE-Manager-Server-Broken-EOL', + 'SUSE_SLES', 'SUSE_SLES', 'SUSE_SLES', 'SUSE_SLES-SP4-migration'], 'vendor': 'SUSE LINUX Products GmbH, Nuernberg, Germany', - 'release': ['1.138', '1.2', '1.2', '1.201', '1.4'], - 'productline': [False, False, False, False, 'manager'], - 'eol_t': [0, 0, 0, 0, 0], - 'isbase': [False, False, False, False, True], - 'installed': [False, False, False, False, True], + 'release': ['1.138', '1.2', '1.2', '1.2', '1.201', '1.201', '1.4'], + 'productline': [False, False, False, False, False, 'manager', 'manager'], + 'eol_t': [None, 0, 0, 0, 0, 0, 0], + 'isbase': [False, False, False, False, False, True, True], + 'installed': [False, False, False, False, False, True, True], }}.items(): + ref_out = { 'retcode': 0, 'stdout': get_test_data(filename) @@ -178,10 +180,10 @@ class ZypperTestCase(TestCase): with patch.dict(zypper.__salt__, {'cmd.run_all': MagicMock(return_value=ref_out)}): products = zypper.list_products() - self.assertEqual(len(products), 5) + self.assertEqual(len(products), 7) self.assertIn(test_data['vendor'], [product['vendor'] for product in products]) for kwd in ['name', 'isbase', 'installed', 'release', 'productline', 'eol_t']: - self.assertEqual(test_data[kwd], sorted([prod[kwd] for prod in products])) + self.assertEqual(test_data[kwd], sorted([prod.get(kwd) for prod in products])) def test_refresh_db(self): ''' -- 2.8.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor