Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP7:Update
salt.21413
xfs-do-not-fails-if-type-is-not-present.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File xfs-do-not-fails-if-type-is-not-present.patch of Package salt.21413
From fb8c573cffff1c3909cd6c84c5474193ac5588a6 Mon Sep 17 00:00:00 2001 From: Alberto Planas <aplanas@gmail.com> Date: Tue, 11 Jun 2019 17:21:05 +0200 Subject: [PATCH] xfs: do not fails if type is not present The command `blkid -o export` not always provides a 'TYPE' output for all the devices. One example is non-formatted partitions, like for example the BIOS partition. This patch do not force the presence of this field in the blkid output. (cherry picked from commit 88df6963470007aa4fe2adb09f000311f48226a8) --- salt/modules/xfs.py | 47 +++++++++++++++------------------- tests/unit/modules/test_xfs.py | 8 ------ 2 files changed, 20 insertions(+), 35 deletions(-) diff --git a/salt/modules/xfs.py b/salt/modules/xfs.py index 6782872cf7..7563bd2d65 100644 --- a/salt/modules/xfs.py +++ b/salt/modules/xfs.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # The MIT License (MIT) # Copyright (C) 2014 SUSE LLC @@ -25,8 +24,6 @@ Module for managing XFS file systems. """ -# Import Python libs -from __future__ import absolute_import, print_function, unicode_literals import logging import os @@ -34,14 +31,10 @@ import re import time import salt.utils.data - -# Import Salt libs import salt.utils.files import salt.utils.path import salt.utils.platform from salt.exceptions import CommandExecutionError - -# Import 3rd-party libs from salt.ext import six from salt.ext.six.moves import range @@ -120,7 +113,7 @@ def info(device): salt '*' xfs.info /dev/sda1 """ - out = __salt__["cmd.run_all"]("xfs_info {0}".format(device)) + out = __salt__["cmd.run_all"]("xfs_info {}".format(device)) if out.get("stderr"): raise CommandExecutionError(out["stderr"].replace("xfs_info:", "").strip()) return _parse_xfs_info(out["stdout"]) @@ -195,16 +188,16 @@ def dump(device, destination, level=0, label=None, noerase=None): label and label or time.strftime( - 'XFS dump for "{0}" of %Y.%m.%d, %H:%M'.format(device), time.localtime() + 'XFS dump for "{}" of %Y.%m.%d, %H:%M'.format(device), time.localtime() ).replace("'", '"') ) cmd = ["xfsdump"] cmd.append("-F") # Force if not noerase: cmd.append("-E") # pre-erase - cmd.append("-L '{0}'".format(label)) # Label - cmd.append("-l {0}".format(level)) # Dump level - cmd.append("-f {0}".format(destination)) # Media destination + cmd.append("-L '{}'".format(label)) # Label + cmd.append("-l {}".format(level)) # Dump level + cmd.append("-f {}".format(destination)) # Media destination cmd.append(device) # Device cmd = " ".join(cmd) @@ -220,10 +213,10 @@ def _xr_to_keyset(line): """ tkns = [elm for elm in line.strip().split(":", 1) if elm] if len(tkns) == 1: - return "'{0}': ".format(tkns[0]) + return "'{}': ".format(tkns[0]) else: key, val = tkns - return "'{0}': '{1}',".format(key.strip(), val.strip()) + return "'{}': '{}',".format(key.strip(), val.strip()) def _xfs_inventory_output(out): @@ -314,14 +307,14 @@ def prune_dump(sessionid): salt '*' xfs.prune_dump b74a3586-e52e-4a4a-8775-c3334fa8ea2c """ - out = __salt__["cmd.run_all"]("xfsinvutil -s {0} -F".format(sessionid)) + out = __salt__["cmd.run_all"]("xfsinvutil -s {} -F".format(sessionid)) _verify_run(out) data = _xfs_prune_output(out["stdout"], sessionid) if data: return data - raise CommandExecutionError('Session UUID "{0}" was not found.'.format(sessionid)) + raise CommandExecutionError('Session UUID "{}" was not found.'.format(sessionid)) def _blkid_output(out): @@ -340,7 +333,7 @@ def _blkid_output(out): data[dev.pop("devname")] = dev mounts = _get_mounts() - for device in six.iterkeys(mounts): + for device in mounts.keys(): if data.get(device): data[device].update(mounts[device]) @@ -396,9 +389,9 @@ def estimate(path): salt '*' xfs.estimate /path/to/dir/* """ if not os.path.exists(path): - raise CommandExecutionError('Path "{0}" was not found.'.format(path)) + raise CommandExecutionError('Path "{}" was not found.'.format(path)) - out = __salt__["cmd.run_all"]("xfs_estimate -v {0}".format(path)) + out = __salt__["cmd.run_all"]("xfs_estimate -v {}".format(path)) _verify_run(out) return _xfs_estimate_output(out["stdout"]) @@ -449,14 +442,14 @@ def mkfs( """ getopts = lambda args: dict( - ((args and ("=" in args) and args or None)) + (args and ("=" in args) and args or None) and [kw.split("=") for kw in args.split(",")] or [] ) cmd = ["mkfs.xfs"] if label: cmd.append("-L") - cmd.append("'{0}'".format(label)) + cmd.append("'{}'".format(label)) if ssize: cmd.append("-s") @@ -477,7 +470,7 @@ def mkfs( cmd.append(opts) except Exception: # pylint: disable=broad-except raise CommandExecutionError( - 'Wrong parameters "{0}" for option "{1}"'.format(opts, switch) + 'Wrong parameters "{}" for option "{}"'.format(opts, switch) ) if not noforce: @@ -505,13 +498,13 @@ def modify(device, label=None, lazy_counting=None, uuid=None): """ if not label and lazy_counting is None and uuid is None: raise CommandExecutionError( - 'Nothing specified for modification for "{0}" device'.format(device) + 'Nothing specified for modification for "{}" device'.format(device) ) cmd = ["xfs_admin"] if label: cmd.append("-L") - cmd.append("'{0}'".format(label)) + cmd.append("'{}'".format(label)) if lazy_counting is False: cmd.append("-c") @@ -531,7 +524,7 @@ def modify(device, label=None, lazy_counting=None, uuid=None): cmd = " ".join(cmd) _verify_run(__salt__["cmd.run_all"](cmd), cmd=cmd) - out = __salt__["cmd.run_all"]("blkid -o export {0}".format(device)) + out = __salt__["cmd.run_all"]("blkid -o export {}".format(device)) _verify_run(out) return _blkid_output(out["stdout"]) @@ -572,9 +565,9 @@ def defragment(device): raise CommandExecutionError("Root is not a device.") if not _get_mounts().get(device): - raise CommandExecutionError('Device "{0}" is not mounted'.format(device)) + raise CommandExecutionError('Device "{}" is not mounted'.format(device)) - out = __salt__["cmd.run_all"]("xfs_fsr {0}".format(device)) + out = __salt__["cmd.run_all"]("xfs_fsr {}".format(device)) _verify_run(out) return {"log": out["stdout"]} diff --git a/tests/unit/modules/test_xfs.py b/tests/unit/modules/test_xfs.py index 149f6c8f7b..778aff793d 100644 --- a/tests/unit/modules/test_xfs.py +++ b/tests/unit/modules/test_xfs.py @@ -1,14 +1,6 @@ -# -*- coding: utf-8 -*- - -# Import Python libs -from __future__ import absolute_import, print_function, unicode_literals - import textwrap -# Import Salt Libs import salt.modules.xfs as xfs - -# Import Salt Testing Libs from tests.support.mixins import LoaderModuleMockMixin from tests.support.mock import MagicMock, patch from tests.support.unit import TestCase -- 2.29.2
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