Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP1:GA
salt.3314
0068-Add-ignore_repo_failure-option-to-suppress...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0068-Add-ignore_repo_failure-option-to-suppress-zypper-s-.patch of Package salt.3314
From 4ebafe6b5f472bfc3ad0b9882d6e409a3be1c2ea Mon Sep 17 00:00:00 2001 From: Bo Maryniuk <bo@suse.de> Date: Mon, 15 Aug 2016 15:03:53 +0200 Subject: [PATCH 68/69] Add ignore_repo_failure option to suppress zypper's exit code 106 on unavailable repos --- salt/modules/zypper.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/salt/modules/zypper.py b/salt/modules/zypper.py index c686eed..8c3b78b 100644 --- a/salt/modules/zypper.py +++ b/salt/modules/zypper.py @@ -92,6 +92,18 @@ class _Zypper(object): self.__no_lock = False self.__no_raise = False self.__refresh = False + self.__ignore_repo_failure = False + + def __call__(self, *args, **kwargs): + ''' + :param args: + :param kwargs: + :return: + ''' + # Ignore exit code for 106 (repo is not available) + if 'no_repo_failure' in kwargs: + self.__ignore_repo_failure = kwargs['no_repo_failure'] + return self def __getattr__(self, item): ''' @@ -267,7 +279,7 @@ class _Zypper(object): __salt__['event.fire_master']({'success': not len(self.error_msg), 'info': self.error_msg or 'Zypper has been released'}, self.TAG_RELEASED) - if self.error_msg and not self.__no_raise: + if self.error_msg and not self.__no_raise and not self.__ignore_repo_failure: raise CommandExecutionError('Zypper command failure: {0}'.format(self.error_msg)) return self._is_xml_mode() and dom.parseString(self.__call_result['stdout']) or self.__call_result['stdout'] @@ -833,6 +845,7 @@ def install(name=None, sources=None, downloadonly=None, version=None, + ignore_repo_failure=False, **kwargs): ''' Install the passed package(s), add refresh=True to force a 'zypper refresh' @@ -896,6 +909,10 @@ def install(name=None, salt '*' pkg.install sources='[{"foo": "salt://foo.rpm"},{"bar": "salt://bar.rpm"}]' + ignore_repo_failure + Zypper returns error code 106 if one of the repositories are not available for various reasons. + In case to set strict check, this parameter needs to be set to True. Default: False. + Returns a dict containing the new package names and versions:: @@ -960,7 +977,7 @@ def install(name=None, while targets: cmd = cmd_install + targets[:500] targets = targets[500:] - for line in __zypper__.call(*cmd).splitlines(): + for line in __zypper__(no_repo_failure=ignore_repo_failure).call(*cmd).splitlines(): match = re.match(r"^The selected package '([^']+)'.+has lower version", line) if match: downgrades.append(match.group(1)) @@ -968,7 +985,7 @@ def install(name=None, while downgrades: cmd = cmd_install + ['--force'] + downgrades[:500] downgrades = downgrades[500:] - __zypper__.call(*cmd) + __zypper__(no_repo_failure=ignore_repo_failure).call(*cmd) __context__.pop('pkg.list_pkgs', None) new = list_pkgs() -- 2.9.3
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