[yum-commits] Branch 'yum-3_2_X' - 5 commits - docs/yum.8 yum-cron/yum-cron.sysconfig yum/failover.py yum/__init__.py

James Antill james at osuosl.org
Mon Aug 1 15:06:26 UTC 2011


 docs/yum.8                  |   11 +++++
 yum-cron/yum-cron.sysconfig |    2 -
 yum/__init__.py             |   30 +++++++++++-----
 yum/failover.py             |   82 ++++++++++++++++++++++++++++++++------------
 4 files changed, 94 insertions(+), 31 deletions(-)

New commits:
commit 42225a155b371cc9e5dc3c7207c770f66c27502b
Author: James Antill <james at and.org>
Date:   Mon Aug 1 11:06:20 2011 -0400

    Add load-ts to yum man page.

diff --git a/docs/yum.8 b/docs/yum.8
index ea18f34..a1375de 100644
--- a/docs/yum.8
+++ b/docs/yum.8
@@ -71,6 +71,8 @@ gnome\-packagekit application\&.
 .br
 .I \fR * history [info|list|packages-list|summary|addon-info|redo|undo|rollback|new] 
 .br
+.I \fR * load-transaction [txfile]
+.br
 .I \fR * check
 .br 
 .I \fR * help [command] 
@@ -371,6 +373,15 @@ end of the package column in the packages-list command).
 .I \fBs\fR - The transaction completed fine, but --skip-broken was enabled and had to skip some packages.
 .br
 
+
+.IP
+.IP "\fBload-transaction\fP"
+This command will re-load a saved yum transaction file, this allows you to
+run a transaction on one machine and then use it on another.
+The two common ways to get a saved yum transaction file are from
+"yum -q history addon-info last saved_tx" or via. the automatic saves in
+$TMPDIR/yum_save_tx.* when a transaction is solved but not run.
+
 .IP
 .IP "\fBcheck\fP"
 Checks the local rpmdb and produces information on any problems it finds. You
commit e32cc19fd155d8482de6a2322767462d6c71d425
Author: Nick Jacek <njacek at redhat.com>
Date:   Fri Jul 29 15:38:14 2011 -0400

    Adds and modifies documentation for the yum/failover module.

diff --git a/yum/failover.py b/yum/failover.py
index bca9651..00c17ad 100644
--- a/yum/failover.py
+++ b/yum/failover.py
@@ -19,51 +19,80 @@
 # worry about calling get_serverurl() and server_failed() and these classes will 
 # figure out which URL to cough up based on the failover method.
 
+"""Classes for handling failovers for server URLs."""
+
 import random
 
 class baseFailOverMethod:
-
+    """A base class to provide a failover to switch to a new server if
+    the current one fails.
+    """
     def __init__(self, repo):
         self.repo = repo
         self.failures = 0
     
     def get_serverurl(self, i=None):
-        """Returns a serverurl based on this failover method or None 
-           if complete failure.  If i is given it is a direct index
-           to pull a server URL from instead of using the failures 
-           counter."""
+        """Return a server URL based on this failover method, or None
+        if there is a complete failure.  This method should always be
+        used to translate an index into a URL, as this object may
+        change how indexes map.
+
+        :param i: if given, this is the index of the server URL to
+           return, instead of using the failures counter
+        :return: the next server URL
+        """
         return None
         
     def server_failed(self):
-        "Tells the failover method that the current server is failed."
+        """Notify the failover method that the current server has
+        failed.
+        """
         self.failures = self.failures + 1
         
     def reset(self, i=0):
-        "Reset the failures counter to a given index."
+        """Reset the failures counter to the given index.
+
+        :param i: the index to reset the failures counter to
+        """
         self.failures = i
 
     def get_index(self):
-        """Returns the current number of failures which is also the
-           index into the list this object represents.  ger_serverurl()
-           should always be used to translate an index into a URL
-           as this object may change how indexs map.  (See RoundRobin)"""
+        """Return the current number of failures, which is also the
+        current index into the list of URLs that this object
+        represents.  :fun:`get_serverurl` should always be used to
+        translate an index into a URL, as this object may change how
+        indexes map.
 
+        :return: the current number of failures, which is also the
+           current index   
+        """
         return self.failures
    
     def len(self):
-        """Returns the how many URLs we've got to cycle through."""
+        """Return the total number of URLs available to cycle through
+        in this object.
 
+        :return: the total number of URLs available
+        """
         return len(self.repo.urls)
         
             
 
 class priority(baseFailOverMethod):
-
-    """Chooses server based on the first success in the list."""
-    
+    """A class to provide a failover to switch to a new server
+    if the current one fails.  This classes chooses the next server
+    based on the first success in the list of servers.
+    """
     def get_serverurl(self, i=None):
-        "Returns a serverurl based on this failover method or None if complete failure."
-        
+        """Return the next successful server URL in the list, or None
+        if there is a complete failure.  This method should always be
+        used to translate an index into a URL, as this object may
+        change how indexes map.
+
+        :param i: if given, this is the index of the server URL to
+           return, instead of using the failures counter
+        :return: the next server URL
+        """
         if i == None:
             index = self.failures
         else:
@@ -77,17 +106,28 @@ class priority(baseFailOverMethod):
         
     
 class roundRobin(baseFailOverMethod):
-
-    """Chooses server based on a round robin."""
-    
+    """A class to provide a failover to switch to a new server
+    if the current one fails.  When an object of this class is
+    created, it selects a random place in the list of URLs to begin
+    with, then each time :func:`get_serveurl` is called, the next URL
+    in the list is returned, cycling back to the beginning of the list
+    after the end is reached.
+    """
     def __init__(self, repo):
         baseFailOverMethod.__init__(self, repo)
         random.seed()
         self.offset = random.randint(0, 37)
     
     def get_serverurl(self, i=None):
-        "Returns a serverurl based on this failover method or None if complete failure."
+        """Return the next successful server URL in the list, using
+        the round robin scheme, or None if there is a complete
+        failure.  This method should always be used to translate an
+        index into a URL, as this object may change how indexes map.
 
+        :param i: if given, this is the index of the server URL to
+           return, instead of using the failures counter
+        :return: the next server URL
+        """
         if i == None:
             index = self.failures
         else:
commit 0bfd4d9f2db58c3c9babf1c13571d042553d2975
Author: Matthew Miller <mattdm at mattdm.org>
Date:   Fri Jul 29 13:55:35 2011 -0400

    Set MAILTO to root by default.
    
    This sets MAILTO to root by default, instead of empty. The script still
    checks for the presence of the mail program, so it doesn't add an additional
    dependency, and basic behavior is the same (since cron sends mail to root by
    default anyway), but the meaningful subject line is just _better_.

diff --git a/yum-cron/yum-cron.sysconfig b/yum-cron/yum-cron.sysconfig
index df1bcfc..4c8c40d 100644
--- a/yum-cron/yum-cron.sysconfig
+++ b/yum-cron/yum-cron.sysconfig
@@ -43,7 +43,7 @@ DEBUG_LEVEL=0
 # command is used to deliver yum output. If MAILTO is unset, crond will
 # send the output by itself, usually to root (but with a less useful
 # subject line).
-MAILTO=
+MAILTO=root
 
 # The reports generated by this command generally use the hostname of
 # the system as reported by the hostname command. If you'd prefer to
commit 4eaf05f120134abbe44335488a8b62a6885b79e0
Author: James Antill <james at and.org>
Date:   Fri Jul 29 12:40:30 2011 -0400

    Use pkg_warn in groupinstall, so we don't get 666 error messages.

diff --git a/yum/__init__.py b/yum/__init__.py
index d93fe8f..2149d77 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2941,7 +2941,7 @@ class YumBase(depsolve.Depsolve):
                 self.verbose_logger.log(logginglevels.DEBUG_2,
                     _('Adding package %s from group %s'), pkg, thisgroup.groupid)
                 try:
-                    txmbrs = self.install(name = pkg)
+                    txmbrs = self.install(name=pkg, pkg_warning_level='debug2')
                 except Errors.InstallError, e:
                     self.verbose_logger.debug(_('No package named %s available to be installed'),
                         pkg)
commit 8e95a485a2bc5caafd3477411ec9a2e340c0389f
Author: James Antill <james at and.org>
Date:   Fri Jul 29 12:39:29 2011 -0400

    Add a pkg_warn to install, for groupinstall.

diff --git a/yum/__init__.py b/yum/__init__.py
index f97378c..d93fe8f 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -3447,6 +3447,18 @@ class YumBase(depsolve.Depsolve):
            
            """
         
+
+        #  This is kind of hacky, we really need a better way to do errors than
+        # doing them directly from .install/etc. ... but this is easy. *sigh*.
+        pkg_warn = kwargs.get('pkg_warning_level', 'flibble')
+        def _dbg2(*args, **kwargs):
+            self.verbose_logger.log(logginglevels.DEBUG_2, *args, **kwargs)
+        level2func = {'debug2' : _dbg2,
+                      'warning' : self.verbose_logger.warning}
+        if pkg_warn not in level2func:
+            pkg_warn = 'warning'
+        pkg_warn = level2func[pkg_warn]
+
         pkgs = []
         was_pattern = False
         if po:
@@ -3602,23 +3614,23 @@ class YumBase(depsolve.Depsolve):
                     already_obs = pkgs[0]
 
                 if already_obs:
-                    self.verbose_logger.warning(_('Package %s is obsoleted by %s which is already installed'), 
-                                                po, already_obs)
+                    pkg_warn(_('Package %s is obsoleted by %s which is already installed'), 
+                             po, already_obs)
                 else:
                     if 'provides_for' in kwargs:
                         if not obsoleting_pkg.provides_for(kwargs['provides_for']):
-                            self.verbose_logger.warning(_('Package %s is obsoleted by %s, but obsoleting package does not provide for requirements'),
-                                                  po.name, obsoleting_pkg.name)
+                            pkg_warn(_('Package %s is obsoleted by %s, but obsoleting package does not provide for requirements'),
+                                     po.name, obsoleting_pkg.name)
                             continue
-                    self.verbose_logger.warning(_('Package %s is obsoleted by %s, trying to install %s instead'),
-                        po.name, obsoleting_pkg.name, obsoleting_pkg)
+                    pkg_warn(_('Package %s is obsoleted by %s, trying to install %s instead'),
+                             po.name, obsoleting_pkg.name, obsoleting_pkg)
                     tx_return.extend(self.install(po=obsoleting_pkg))
                 continue
             
             # make sure it's not already installed
             if self.rpmdb.contains(po=po):
                 if not self.tsInfo.getMembersWithState(po.pkgtup, TS_REMOVE_STATES):
-                    self.verbose_logger.warning(_('Package %s already installed and latest version'), po)
+                    pkg_warn(_('Package %s already installed and latest version'), po)
                     continue
 
             # make sure we don't have a name.arch of this already installed
@@ -3632,7 +3644,7 @@ class YumBase(depsolve.Depsolve):
                         found = True
                         break
                 if not found:
-                    self.verbose_logger.warning(_('Package matching %s already installed. Checking for update.'), po)            
+                    pkg_warn(_('Package matching %s already installed. Checking for update.'), po)            
                     txmbrs = self.update(po=po)
                     tx_return.extend(txmbrs)
                     continue


More information about the Yum-commits mailing list