Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for Python < 2.6 on the server #371

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 3 additions & 29 deletions doc/development/compat.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ tool), this documentation is *not* automatically generated.

There are several basic types of symbols found in ``Bcfg2.Compat``:

* Symbols whose names have changed, e.g., ``MutableMapping``.
* Symbols whose modules have changed names, e.g., ``urljoin``/``urlparse``
* Symbols that have been added or removed, e.g., ``any``/``all``, ``reduce``,
``walk_packages``
Expand Down Expand Up @@ -112,11 +111,12 @@ The following symbols are imported or defined to provide compatibility
with Python 2.4 (and occasionally 2.5). Be sure to read the notes
below, since some of these implementations may be feature-incomplete.

As we require Python 2.6 on the server side, you should only use these
compat methods in common or client code.

+----------------+--------------------------------+--------------------------------------------+
| Name | Python 2.4 | Python 2.5+ |
+================+================================+============================================+
| formatdate | :func:`email.Utils.formatdate` | :func:`email.utils.formatdate` |
+----------------+--------------------------------+--------------------------------------------+
| walk_packages | Not implemented | :func:`pkgutil.walk_packages` (2.6+) |
+----------------+--------------------------------+--------------------------------------------+
| any | Not implemented | :func:`any` |
Expand All @@ -125,10 +125,6 @@ below, since some of these implementations may be feature-incomplete.
+----------------+--------------------------------+--------------------------------------------+
| wraps | Not implemented | :func:`functools.wraps` |
+----------------+--------------------------------+--------------------------------------------+
| md5 | :func:`md5.md5` | :class:`hashlib.md5` |
+----------------+--------------------------------+--------------------------------------------+
| MutableMapping | :class:`UserDict.DictMixin` | :class:`collections.MutableMapping` (2.6+) |
+----------------+--------------------------------+--------------------------------------------+
| literal_eval | :func:`eval` | :func:`ast.literal_eval` (2.6+) |
+----------------+--------------------------------+--------------------------------------------+

Expand All @@ -151,28 +147,6 @@ The ``wraps`` implementation for Python 2.4 is a no-op. It does not
attempt to copy the docstring or other details from the original
function to the wrapped function.

md5
~~~

:mod:`hashlib` is available for Python 2.4, but it is not part of the
standard base. If it is installed, it will be used. If you are doing
something fancy with MD5 sums, you may need to determine which object
is in use, since they are not equivalent. For the majority of simple
cases -- finding the MD5 sum of a string -- they are equivalent
enough.

MutableMapping
~~~~~~~~~~~~~~

:class:`collections.MutableMapping` provides a subset of the
functionality of :class:`UserDict.DictMixin`; that is, any object that
is written to work with ``MutableMapping`` will also work with
``DictMixin``, so you should write classes with ``MutableMapping`` in
mind.

:class:`collections.MutableMapping` is available in Python 2.6+, and
will be used if available.

literal_eval
~~~~~~~~~~~~

Expand Down
11 changes: 5 additions & 6 deletions doc/development/core.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ Bcfg2 1.3 added a pluggable server core system so that the server core
itself can be easily swapped out to use different technologies. It
currently ships with several backends: a builtin core written from
scratch using the various server tools in the Python standard library;
a variant on the builtin core that uses Python 2.6's
:mod:`multiprocessing` library to process requests in parallel; and an
experimental `CherryPy <http://www.cherrypy.org/>`_ based core. This
page documents the server core interface so that other cores can be
written to take advantage of other technologies, e.g., `Tornado
<http://www.tornadoweb.org/>`_ or `Twisted
a variant on the builtin core that uses the Python :mod:`multiprocessing`
library to process requests in parallel; and an experimental `CherryPy
<http://www.cherrypy.org/>`_ based core. This page documents the server core
interface so that other cores can be written to take advantage of other
technologies, e.g., `Tornado <http://www.tornadoweb.org/>`_ or `Twisted
<http://twistedmatrix.com/trac/>`_.

A core implementation needs to:
Expand Down
44 changes: 22 additions & 22 deletions doc/installation/prerequisites.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,28 @@ Bcfg2 Client
Bcfg2 Server
------------

+-------------------------------+----------+--------------------------------+
| Software | Version | Requires |
+===============================+==========+================================+
| libxml2 | 2.6.24+ | |
+-------------------------------+----------+--------------------------------+
| libxslt | Any | libxml2 |
+-------------------------------+----------+--------------------------------+
| python | 2.2-2.7 | |
+-------------------------------+----------+--------------------------------+
| lxml | 0.9+ | lxml: libxml2, libxslt, python |
+-------------------------------+----------+--------------------------------+
| gamin or inotify | Any | |
+-------------------------------+----------+--------------------------------+
| python-gamin or pyinotify | Any | gamin or inotify, python |
+-------------------------------+----------+--------------------------------+
| python-ssl (this is included | Any | |
| in Python2.6 and later) | | |
+-------------------------------+----------+--------------------------------+
| python-setuptools | Any | |
+-------------------------------+----------+--------------------------------+
| python-genshi | Any | |
+-------------------------------+----------+--------------------------------+
+-------------------------------+-----------------+--------------------------------+
| Software | Version | Requires |
+===============================+=================+================================+
| libxml2 | 2.6.24+ | |
+-------------------------------+-----------------+--------------------------------+
| libxslt | Any | libxml2 |
+-------------------------------+-----------------+--------------------------------+
| python | 2.6 and greater | |
+-------------------------------+-----------------+--------------------------------+
| lxml | 0.9+ | lxml: libxml2, libxslt, python |
+-------------------------------+-----------------+--------------------------------+
| gamin or inotify | Any | |
+-------------------------------+-----------------+--------------------------------+
| python-gamin or pyinotify | Any | gamin or inotify, python |
+-------------------------------+-----------------+--------------------------------+
| python-ssl (this is included | Any | |
| in Python2.6 and later) | | |
+-------------------------------+-----------------+--------------------------------+
| python-setuptools | Any | |
+-------------------------------+-----------------+--------------------------------+
| python-genshi | Any | |
+-------------------------------+-----------------+--------------------------------+

Bcfg2 Reporting
---------------
Expand Down
2 changes: 2 additions & 0 deletions doc/releases/1.4.0pre2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ backwards-incompatible user-facing changes
your queries default to the class names and the Ldap plugin expires
the metadata caches if the config file changes.

* Droped support for Python 2.5 or below on the bcfg2 server.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should create release notes for pre3 (or rc1, not sure) and add this there.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should rc1 release note contain all changes since 1.3.x?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlexanderS Hmm, that's a good question. I think you may be right that rc1 should contain all changes. Especially since we haven't released something in a while.

Thanks
------

Expand Down
1 change: 0 additions & 1 deletion doc/reports/dynamic.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ Prerequisites
-------------

* sqlite3
* pysqlite2 (if using python 2.4)
* `Django <http://www.djangoproject.com>`_ >= 1.3
* mod-wsgi

Expand Down
4 changes: 1 addition & 3 deletions doc/server/configuration.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ The builtin server:

* Is very stable and mature;
* Supports certificate authentication;
* Works on Python 2.4;
* Is slow with larger numbers of clients.

The multiprocessing server:
Expand All @@ -190,15 +189,14 @@ The multiprocessing server:
* Introduces concurrent processing to Bcfg2, which may break in
various edge cases;
* Supports certificate authentication;
* Requires Python 2.6;
* Is faster with large numbers of concurrent runs.

The CherryPy server:

* Is very new and potentially buggy;
* Does not support certificate authentication yet, only password
authentication;
* Requires CherryPy 3.3, which requires Python 2.5;
* Requires CherryPy 3.3;
* Is smarter about daemonization, particularly if you are
:ref:`server-dropping-privs`;
* Is faster with large numbers of clients.
Expand Down
15 changes: 2 additions & 13 deletions doc/server/plugins/probes/ohai.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,15 @@
Ohai
====

.. _Ohai: http://wiki.opscode.com/display/chef/Ohai
.. _Ohai-Install: http://wiki.opscode.com/display/chef/Ohai+Installation+and+Use
.. _Ohai: https://docs.chef.io/ohai.html

The `Ohai`_ plugin is used to detect information about the client
operating system. The data is reported back to the server using JSON.

Client prerequisites
--------------------

On the client, you need to install `Ohai`_. See `Ohai-Install`_ for more
information.

Server prerequisites
--------------------

If you have python 2.6 or later installed, you can continue on to
:ref:`ohai-setup`. Otherwise, you will need to install the
python-simplejson module found packaged in most distributions.

.. _ohai-setup:
On the client, you need to install `Ohai`_.

Setup
-----
Expand Down
2 changes: 0 additions & 2 deletions osx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ prepare: install
chmod 0770 "${PKGTMP}/scripts/${PREFLIGHT}"
chmod 0770 "${PKGTMP}/scripts/${POSTFLIGHT}"

# add in M2Crypto if python version is less than 2.6
if [[ ${PYMAJORVERSION} == 2 ]]; then if [[ ${PYMINORVERSION} -lt 6 ]]; then cp "M2Crypto-0.20.2-py2.5-macosx-10.5-ppc.egg" "${PKGROOT}/${SITELIBDIR}" && cp "easy-install.pth" "${PKGROOT}/${SITELIBDIR}"; fi ; fi
# add default bcfg2.conf
mkdir -p "${PKGROOT}/etc"
cp "${CONF}" "${PKGROOT}/etc/${CONF}"
Expand Down
4 changes: 0 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
'argparse'
]

# Use the backported ssl module on < python2.6
if sys.version_info[:2] < (2, 6):
inst_reqs.append('ssl')

setup(name="Bcfg2",
version=__version__, # Defined in src/lib/Bcfg2/version.py
description="Bcfg2 Server",
Expand Down
15 changes: 0 additions & 15 deletions src/lib/Bcfg2/Compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@

# pylint: disable=E0601,E0602,E0611,W0611,W0622,C0103

try:
from email.Utils import formatdate
except ImportError:
from email.utils import formatdate

# urllib imports
try:
from urllib import quote_plus
Expand Down Expand Up @@ -123,11 +118,6 @@ def b64decode(val, **kwargs): # pylint: disable=C0111
except NameError:
from functools import reduce

try:
from collections import MutableMapping
except ImportError:
from UserDict import DictMixin as MutableMapping


class CmpMixin(object):
""" In Py3K, :meth:`object.__cmp__` is no longer magical, so this
Expand Down Expand Up @@ -252,11 +242,6 @@ def any(iterable):
return True
return False

try:
from hashlib import md5
except ImportError:
from md5 import md5


def oct_mode(mode):
""" Convert a decimal number describing a POSIX permissions mode
Expand Down
21 changes: 10 additions & 11 deletions src/lib/Bcfg2/Reporting/Collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,16 @@ def __init__(self, interaction, storage, group=None, target=None,
def run(self):
"""Call the database storage procedure (aka import)"""
try:
try:
start = time.time()
self.storage.import_interaction(self.interaction)
self.logger.info("Imported interaction for %s in %ss" %
(self.interaction.get('hostname',
'<unknown>'),
time.time() - start))
except:
#TODO requeue?
self.logger.error("Unhandled exception in import thread %s" %
sys.exc_info()[1])
start = time.time()
self.storage.import_interaction(self.interaction)
self.logger.info("Imported interaction for %s in %ss" %
(self.interaction.get('hostname',
'<unknown>'),
time.time() - start))
except:
#TODO requeue?
self.logger.error("Unhandled exception in import thread %s" %
sys.exc_info()[1])
finally:
if self.semaphore:
self.semaphore.release()
Expand Down
12 changes: 6 additions & 6 deletions src/lib/Bcfg2/Reporting/Storage/DjangoORM.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from datetime import datetime
from time import strptime
from lxml import etree
from hashlib import md5
import sys

import django
Expand All @@ -16,7 +17,7 @@

import Bcfg2.Options
import Bcfg2.DBSettings
from Bcfg2.Compat import b64decode, md5
from Bcfg2.Compat import b64decode
from Bcfg2.Reporting.Compat import transaction
from Bcfg2.Reporting.Storage.base import StorageBase, StorageError
from Bcfg2.Server.Plugin.exceptions import PluginExecutionError
Expand Down Expand Up @@ -400,11 +401,10 @@ def _import_interaction(self, interaction):
def import_interaction(self, interaction):
"""Import the data into the backend"""
try:
try:
self._import_interaction(interaction)
except:
self.logger.error("Failed to import interaction: %s" %
traceback.format_exc().splitlines()[-1])
self._import_interaction(interaction)
except:
self.logger.error("Failed to import interaction: %s" %
traceback.format_exc().splitlines()[-1])
finally:
self.logger.debug("%s: Closing database connection" %
self.__class__.__name__)
Expand Down
13 changes: 6 additions & 7 deletions src/lib/Bcfg2/Server/BuiltinCore.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,20 @@ def _dispatch(self, method, args, dispatch_dict):
raise xmlrpclib.Fault(xmlrpclib.METHOD_NOT_FOUND,
"Unknown method %s" % method)

method_start = time.time()
try:
method_start = time.time()
try:
return method_func(*args)
finally:
Bcfg2.Server.Statistics.stats.add_value(
method,
time.time() - method_start)
return method_func(*args)
except xmlrpclib.Fault:
raise
except Exception:
err = sys.exc_info()[1]
if getattr(err, "log", True):
self.logger.error(err, exc_info=True)
raise xmlrpclib.Fault(getattr(err, "fault_code", 1), str(err))
finally:
Bcfg2.Server.Statistics.stats.add_value(
method,
time.time() - method_start)

def _daemonize(self):
""" Open :attr:`context` to drop privileges, write the PID
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Bcfg2/Server/Cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

"""

from Bcfg2.Compat import MutableMapping
from collections import MutableMapping


class _Cache(MutableMapping):
Expand Down
3 changes: 2 additions & 1 deletion src/lib/Bcfg2/Server/Core.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
import Bcfg2.DBSettings
import Bcfg2.Server.Statistics
import Bcfg2.Server.FileMonitor
from functools import wraps
from itertools import chain
from Bcfg2.Server.Cache import Cache
from Bcfg2.Compat import xmlrpclib, wraps # pylint: disable=W0622
from Bcfg2.Compat import xmlrpclib
from Bcfg2.Server.Plugin.exceptions import * # pylint: disable=W0401,W0614
from Bcfg2.Server.Plugin.interfaces import * # pylint: disable=W0401,W0614
from Bcfg2.Server.Statistics import track_statistics
Expand Down
4 changes: 3 additions & 1 deletion src/lib/Bcfg2/Server/Encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
import copy
import logging
import lxml.etree
from hashlib import md5

import Bcfg2.Logger
import Bcfg2.Options
from M2Crypto import Rand
from M2Crypto.EVP import Cipher, EVPError
from Bcfg2.Utils import safe_input
from Bcfg2.Server import XMLParser
from Bcfg2.Compat import md5, b64encode, b64decode, StringIO
from Bcfg2.Compat import b64encode, b64decode, StringIO

#: Constant representing the encryption operation for
#: :class:`M2Crypto.EVP.Cipher`, which uses a simple integer. This
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Bcfg2/Server/Info.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import Bcfg2.Server.Core
import Bcfg2.Server.Plugin
import Bcfg2.Client.Tools.POSIX
from Bcfg2.Compat import any # pylint: disable=W0622


try:
try:
Expand Down
Loading