[yum-commits] 3 commits - yumcommands.py yum/fssnapshots.py yum/__init__.py
James Antill
james at osuosl.org
Mon Jun 17 18:02:54 UTC 2013
yum/__init__.py | 16 +++++++++-------
yum/fssnapshots.py | 8 +++++++-
yumcommands.py | 9 ++++++++-
3 files changed, 24 insertions(+), 9 deletions(-)
New commits:
commit 3a899184095ded43c755d6f52fb7b4944cce00f3
Author: James Antill <james at and.org>
Date: Mon Jun 17 14:00:39 2013 -0400
Test for installed python-lvm.
diff --git a/yumcommands.py b/yumcommands.py
index f861e58..d02beb6 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -4149,7 +4149,10 @@ class FSSnapshotCommand(YumCommand):
subcommand = 'summary'
if not base.fssnap.available:
- print _("Snapshot support not available.")
+ if not base.rpmdb.searchNames(['python-lvm']):
+ print _("Snapshot support not available, no python-lvm package installed.")
+ else:
+ print _("Snapshot support not available, python-lvm is old/broken.")
return 0, [basecmd + ' ' + subcommand + ' done']
if subcommand == 'list':
commit 960e3cf3115a3049caa070141abf28b928bde395
Author: James Antill <james at and.org>
Date: Mon Jun 17 13:15:55 2013 -0400
Add .available property to fssnap object and use it.
diff --git a/yum/__init__.py b/yum/__init__.py
index 26ef1f9..4833a6e 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1692,9 +1692,9 @@ much more problems).
:raises: :class:`yum.Errors.YumRPMTransError` if there is a
transaction cannot be completed
"""
- if ((self.conf.fssnap_automatic_pre or
- self.conf.fssnap_automatic_post) and
- self.conf.fssnap_automatic_keep):
+ if self.fssnap.available and ((self.conf.fssnap_automatic_pre or
+ self.conf.fssnap_automatic_post) and
+ self.conf.fssnap_automatic_keep):
# Automatically kill old snapshots...
snaps = self.fssnap.old_snapshots()
snaps = sorted(snaps, key=lambda x: (x['ctime'], x['origin_dev']),
@@ -1715,8 +1715,9 @@ much more problems).
# Display something to the user?
self.fssnap.del_snapshots(devices=todel)
- if (not self.ts.isTsFlagSet(rpm.RPMTRANS_FLAG_TEST) and
- self.conf.fssnap_automatic_pre):
+ if (self.fssnap.available and
+ (not self.ts.isTsFlagSet(rpm.RPMTRANS_FLAG_TEST) and
+ self.conf.fssnap_automatic_pre)):
if not self.fssnap.has_space(self.conf.fssnap_percentage):
msg = _("Not enough space to create pre. FS snapshot, aborting transaction.")
raise Errors.YumRPMTransError(msg=msg, errors=[])
@@ -1855,8 +1856,9 @@ much more problems).
if self.conf.group_command == 'objects':
self.igroups.save()
- if (not self.ts.isTsFlagSet(rpm.RPMTRANS_FLAG_TEST) and
- self.conf.fssnap_automatic_post):
+ if (self.fssnap.available and
+ (not self.ts.isTsFlagSet(rpm.RPMTRANS_FLAG_TEST) and
+ self.conf.fssnap_automatic_post)):
if not self.fssnap.has_space(self.conf.fssnap_percentage):
msg = _("Not enough space to create post trans FS snapshot.")
self.logger.critical(msg)
diff --git a/yum/fssnapshots.py b/yum/fssnapshots.py
index 5e14e13..567cb65 100755
--- a/yum/fssnapshots.py
+++ b/yum/fssnapshots.py
@@ -143,6 +143,7 @@ class _FSSnap(object):
devices = []
self.version = _ver
+ self.available = bool(lvm)
self.postfix_static = "_yum_"
self._postfix = None
self._root = root
diff --git a/yumcommands.py b/yumcommands.py
index e2968b5..f861e58 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -4148,6 +4148,10 @@ class FSSnapshotCommand(YumCommand):
else:
subcommand = 'summary'
+ if not base.fssnap.available:
+ print _("Snapshot support not available.")
+ return 0, [basecmd + ' ' + subcommand + ' done']
+
if subcommand == 'list':
snaps = base.fssnap.old_snapshots()
print _("List of %u snapshosts:") % len(snaps)
@@ -4187,7 +4191,7 @@ class FSSnapshotCommand(YumCommand):
if subcommand == 'summary':
snaps = base.fssnap.old_snapshots()
if not snaps:
- print _("No snapshots")
+ print _("No snapshots, LVM version:"), base.fssnap.version
return 0, [basecmd + ' ' + subcommand + ' done']
used = 0
commit 685ce9ed0d2c68b5442b656e8aca79b658fa418a
Author: James Antill <james at and.org>
Date: Sat Jun 15 18:44:33 2013 -0400
Don't say have space, when we have no LVs.
diff --git a/yum/fssnapshots.py b/yum/fssnapshots.py
old mode 100644
new mode 100755
index 16e2595..5e14e13
--- a/yum/fssnapshots.py
+++ b/yum/fssnapshots.py
@@ -196,6 +196,7 @@ class _FSSnap(object):
def has_space(self, percentage=100):
""" See if we have enough space to try a snapshot. """
+ ret = False
for vgname in self._vgnames:
use = self._use_dev(vgname)
if use is not None and not use:
@@ -216,10 +217,14 @@ class _FSSnap(object):
vg.close()
+ if not lvssize:
+ continue
+ ret = True
+
if (lvssize * percentage) > (100*vgfsize):
return False
- return True
+ return ret
def _get_postfix(self):
if self._postfix is None:
More information about the Yum-commits
mailing list