From 63d25d978ba0a0cdb1b689cafcebdaae7d609e06 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Tue, 9 Dec 2014 15:21:22 +0000 Subject: [PATCH] Allow use of dnf instead of yum on Fedora Since Fedora 20 it has been possible to use 'dnf' as a drop-in replacement for 'yum', and it is targetted to become the default in Fedora 22 http://fedoraproject.org/wiki/Changes/ReplaceYumWithDNF There are many benefits of 'dnf' over 'yum' but the biggest from the POV of an openstack developer is its speed. Assuming an existing running devstack install ie all required RPMs already installed on the system. Now look at how long it takes to run stack.sh, during which yum does not have to actually install anything # ./unstack.sh # time ./stack.sh real 11m12.193s user 10m17.129s sys 0m15.275s Now, with 'export YUM=dnf' set in local.conf, run the same test again # ./unstack.sh # time ./stack.sh real 0m48.610s user 0m28.939s sys 0m7.801s So, this is showing that devstack is wasting 10 minutes just for yum to figure out that everything is already installed. The overhead of yum vs dnf is even worse when yum has to acutally depsolve to install new packages. Change-Id: Ia01a5f330a47b32207586902a861bedfc8a0f6e2 --- functions-common | 8 ++++---- stackrc | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/functions-common b/functions-common index 24507fef91..83db9d3667 100644 --- a/functions-common +++ b/functions-common @@ -1165,7 +1165,7 @@ function uninstall_package { if is_ubuntu; then apt_get purge "$@" elif is_fedora; then - sudo yum remove -y "$@" + sudo $YUM remove -y "$@" ||: elif is_suse; then sudo zypper rm "$@" else @@ -1174,7 +1174,7 @@ function uninstall_package { } # Wrapper for ``yum`` to set proxy environment variables -# Uses globals ``OFFLINE``, ``*_proxy`` +# Uses globals ``OFFLINE``, ``*_proxy``, ``YUM`` # yum_install package [package ...] function yum_install { [[ "$OFFLINE" = "True" ]] && return @@ -1186,7 +1186,7 @@ function yum_install { # https://bugzilla.redhat.com/show_bug.cgi?id=965567 $sudo http_proxy=$http_proxy https_proxy=$https_proxy \ no_proxy=$no_proxy \ - yum install -y "$@" 2>&1 | \ + $YUM install -y "$@" 2>&1 | \ awk ' BEGIN { fail=0 } /No package/ { fail=1 } @@ -1196,7 +1196,7 @@ function yum_install { # also ensure we catch a yum failure if [[ ${PIPESTATUS[0]} != 0 ]]; then - die $LINENO "Yum install failure" + die $LINENO "$YUM install failure" fi } diff --git a/stackrc b/stackrc index ac798894b8..2a5d877223 100644 --- a/stackrc +++ b/stackrc @@ -621,6 +621,12 @@ API_WORKERS=${API_WORKERS:=$(( ($(nproc)/2)<2 ? 2 : ($(nproc)/2) ))} # Service startup timeout SERVICE_TIMEOUT=${SERVICE_TIMEOUT:-60} +# Support alternative yum -- in future Fedora 'dnf' will become the +# only supported installer, but for now 'yum' and 'dnf' are both +# available in parallel with compatible CLIs. Allow manual switching +# till we get to the point we need to handle this automatically +YUM=${YUM:-yum} + # Following entries need to be last items in file # Local variables: