diff options
author | Chris Holland <41524756+ChrisAHolland@users.noreply.github.com> | 2020-04-08 20:36:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-08 20:36:28 +0200 |
commit | c9c1146cc825886463dcf95ef2648858e9ca8bb9 (patch) | |
tree | 6cd33dcf6107ca1e8b90b1a61a19dc8092086a30 /lib/ansible/modules/packaging/os/dnf.py | |
parent | fixed fetch traversal from slurp (#68720) (diff) | |
download | ansible-c9c1146cc825886463dcf95ef2648858e9ca8bb9.tar.xz ansible-c9c1146cc825886463dcf95ef2648858e9ca8bb9.zip |
dnf: remove un-needed function (#68482)
Diffstat (limited to '')
-rw-r--r-- | lib/ansible/modules/packaging/os/dnf.py | 36 |
1 files changed, 2 insertions, 34 deletions
diff --git a/lib/ansible/modules/packaging/os/dnf.py b/lib/ansible/modules/packaging/os/dnf.py index b44ce695f9..e955ec4c82 100644 --- a/lib/ansible/modules/packaging/os/dnf.py +++ b/lib/ansible/modules/packaging/os/dnf.py @@ -286,7 +286,6 @@ EXAMPLES = ''' import os import re import sys -import tempfile try: import dnf @@ -300,16 +299,13 @@ except ImportError: HAS_DNF = False from ansible.module_utils._text import to_native, to_text -from ansible.module_utils.urls import fetch_url +from ansible.module_utils.urls import fetch_file from ansible.module_utils.six import PY2, text_type from distutils.version import LooseVersion from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.yumdnf import YumDnf, yumdnf_argument_spec -# 64k. Number of bytes to read at a time when manually downloading pkgs via a url -BUFSIZE = 65536 - class DnfModule(YumDnf): """ @@ -465,34 +461,6 @@ class DnfModule(YumDnf): # print '%s, %s, %s vs %s, %s, %s = %s' % (e1, v1, r1, e2, v2, r2, rc) return rc - def fetch_rpm_from_url(self, spec): - # FIXME: Remove this once this PR is merged: - # https://github.com/ansible/ansible/pull/19172 - - # download package so that we can query it - package_name, dummy = os.path.splitext(str(spec.rsplit('/', 1)[1])) - package_file = tempfile.NamedTemporaryFile(dir=self.module.tmpdir, prefix=package_name, suffix='.rpm', delete=False) - self.module.add_cleanup_file(package_file.name) - try: - rsp, info = fetch_url(self.module, spec) - if not rsp: - self.module.fail_json( - msg="Failure downloading %s, %s" % (spec, info['msg']), - results=[], - ) - data = rsp.read(BUFSIZE) - while data: - package_file.write(data) - data = rsp.read(BUFSIZE) - package_file.close() - except Exception as e: - self.module.fail_json( - msg="Failure downloading %s, %s" % (spec, to_native(e)), - results=[], - ) - - return package_file.name - def _ensure_dnf(self): if not HAS_DNF: if PY2: @@ -792,7 +760,7 @@ class DnfModule(YumDnf): for name in self.names: if '://' in name: - name = self.fetch_rpm_from_url(name) + name = fetch_file(self.module, name) filenames.append(name) elif name.endswith(".rpm"): filenames.append(name) |