Cleanup py27 support

This repo is now testing only with Python 3, so let's make
a few cleanups:
- Remove python 2.7 stanza from setup.py
- Add requires on python >= 3.6 to setup.cfg so that pypi and pip
  know about the requirement
- Remove obsolete sections from setup.cfg
- Update classifiers
- Update requirements, no need for python_version anymore
- Switch to using sphinx-build with warnings enabled, fix
  warnings found with autodoc
- Cleanup doc/source/conf.py to remove now obsolete content.
- Use newer openstackdocstheme version, switch to using apidoc
- Remove install_command from tox.ini, the default is fine
- Change some imports to use python3 changed names

Change-Id: Ibb2e614c7db8a01e41caed8314c1d46479c78295
This commit is contained in:
Andreas Jaeger 2020-04-12 19:26:00 +02:00
parent b9ef93c2f1
commit 72de51b01c
9 changed files with 61 additions and 84 deletions

View File

@ -14,7 +14,6 @@
import sys
import os
from freezer_dr import __version__ as FREEZER_DR_VERSION
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
@ -29,7 +28,7 @@ from freezer_dr import __version__ as FREEZER_DR_VERSION
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc',
extensions = ['sphinxcontrib.apidoc',
'sphinx.ext.viewcode',
'openstackdocstheme']
@ -49,15 +48,6 @@ master_doc = 'index'
project = u'Freezer'
copyright = u'2016, OpenStack'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = FREEZER_DR_VERSION
# The full version, including alpha/beta/rc tags.
release = FREEZER_DR_VERSION
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
@ -130,7 +120,7 @@ html_theme = 'openstackdocs'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# html_static_path = ['_static']
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
@ -263,3 +253,11 @@ texinfo_documents = [
# Example configuration for intersphinx: refer to the Python standard library.
#intersphinx_mapping = {'http://docs.python.org/': None}
# -- sphinxcontrib.apidoc configuration --------------------------------------
apidoc_module_dir = '../../freezer_dr'
apidoc_output_dir = 'api'
apidoc_excluded_paths = [
'tests',
]

View File

@ -1,8 +1,4 @@
.. Freezer Disaster Recovery documentation master file, created by
sphinx-quickstart on Thu Feb 4 22:27:35 2016.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
=====================================================
Welcome to Freezer's Disaster Recovery documentation!
=====================================================
@ -24,4 +20,4 @@ Indices and tables
.. toctree::
:maxdepth: 1
api/autoindex
api/modules

View File

@ -14,15 +14,15 @@
from freezer_dr.common.osclient import OSClient
from freezer_dr.monitors.common.driver import MonitorBaseDriver
from httplib import HTTPConnection
from httplib import HTTPSConnection
from httplib import socket
from http.client import HTTPConnection
from http.client import HTTPSConnection
from http.client import socket
from oslo_config import cfg
from oslo_log import log
from time import sleep
from urlparse import urlparse
from urllib.parse import urlparse
CONF = cfg.CONF
LOG = log.getLogger(__name__)

View File

@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import httplib
import http.client
import time
import urlparse
import urllib.parse
from monascaclient import client
from oslo_config import cfg
@ -29,9 +29,11 @@ LOG = log.getLogger(__name__)
class MonascaDriver(driver.MonitorBaseDriver):
"""Monasca monitoring driver to monitor compute nodes. It makes use of
Monasca to monitor the compute nodes. Metric information needed. 'hostname'
must be used in dimensions to filter the values in alarms. You need to
define alarms for all hosts with the required metrics."""
Monasca to monitor the compute nodes. Metric information
needed. 'hostname' must be used in dimensions to filter the
values in alarms. You need to define alarms for all hosts with
the required metrics.
"""
_OPTS = [
cfg.StrOpt('keystone_url',
@ -133,7 +135,8 @@ class MonascaDriver(driver.MonitorBaseDriver):
"""This function returns monitoring data from Monasca. It calls
_get_raw_data to get raw data and then process these data returns
a normalized dict
:return: doct contains:
:return: dict contains::
{
hostname1: {
metric_name1: ['Ok', 'ALARM', 'UNDETERMINED']
@ -267,16 +270,16 @@ class MonascaDriver(driver.MonitorBaseDriver):
return eval(aggregate)
def is_alive(self):
url = urlparse.urlparse(self.conf.monasca_url)
url = urllib.parse.urlparse(self.conf.monasca_url)
if url.scheme == 'https':
http_connector = httplib.HTTPSConnection
http_connector = http.client.HTTPSConnection
else:
http_connector = httplib.HTTPConnection
http_connector = http.client.HTTPConnection
try:
connection = http_connector(host=url.netloc)
connection.request('HEAD', url=url.path)
response = connection.getresponse()
except httplib.socket.error:
except http.client.socket.error:
return False
try:
if getattr(response, 'status') in [200, 401]:

View File

@ -50,7 +50,7 @@ msgpack==0.5.6
munch==2.2.0
netaddr==0.7.19
netifaces==0.10.6
openstackdocstheme==1.18.1
openstackdocstheme==1.31.2
openstacksdk==0.12.0
os-brick==2.2.0
os-client-config==1.29.0
@ -107,6 +107,7 @@ setuptools==21.0.0
simplejson==3.13.2
snowballstemmer==1.2.1
Sphinx==1.6.2
sphinxcontrib-apidoc==0.2.0
sphinxcontrib-websupport==1.0.1
stestr==2.0.0
stevedore==1.28.0

View File

@ -6,6 +6,7 @@ description-file =
author = Freezer Team
author-email = openstack-discuss@lists.openstack.org
home-page = https://docs.openstack.org/freezer/latest/
python-requires = >=3.6
classifier =
Environment :: OpenStack
Intended Audience :: Developers
@ -14,6 +15,8 @@ classifier =
License :: OSI Approved :: Apache Software License
Operating System :: POSIX :: Linux
Programming Language :: Python
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
@ -35,21 +38,6 @@ keywords =
packages =
freezer_dr
[global]
setup-hooks =
pbr.hooks.setup_hook
[build_sphinx]
source-dir = doc/source
build-dir = doc/build
all_files = 1
[pbr]
# Have pbr generate the module indexes like sphinx autodoc
autodoc_index_modules = True
warnerrors = True
[entry_points]
oslo.config.opts =
freezer-dr = freezer_dr.common.config:list_opts

View File

@ -13,17 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT
import setuptools
# In python < 2.7.4, a lazy loading of package `pbr` will break
# setuptools if some other modules registered functions in `atexit`.
# solution from: http://bugs.python.org/issue15881#msg170215
try:
import multiprocessing # noqa
except ImportError:
pass
setuptools.setup(
setup_requires=['pbr>=2.0.0'],
pbr=True)

View File

@ -5,12 +5,12 @@
astroid==1.6.5 # LGPLv2.1
# hacking pins flake8 etc
hacking>=1.1.0,<1.2.0 # Apache-2.0
hacking>=3.0,<3.1.0 # Apache-2.0
coverage>=4.0
mock>=2.0.0
pylint==1.9.2 # GPLv2
stestr>=2.0.0 # Apache-2.0
testtools>=2.2.0
sphinx!=1.6.6,!=1.6.7,>=1.6.2,<2.0.0;python_version=='2.7' # BSD
sphinx!=1.6.6,!=1.6.7,!=2.1.0,>=1.6.2;python_version>='3.4' # BSD
openstackdocstheme>=1.18.1 # Apache-2.0
sphinx!=1.6.6,!=1.6.7,!=2.1.0,>=1.6.2 # BSD
openstackdocstheme>=1.31.2 # Apache-2.0
sphinxcontrib-apidoc>=0.2.0

View File

@ -6,12 +6,12 @@ skipsdist = True
[testenv]
basepython = python3
usedevelop = True
deps = -r{toxinidir}/requirements.txt
deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
passenv =
http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
setenv =
VIRTUAL_ENV={envdir}
OS_TEST_PATH = ./tests/unit
@ -38,7 +38,7 @@ commands = {posargs}
[testenv:docs]
commands =
python setup.py build_sphinx
sphinx-build -W -b html doc/source doc/build/html
[testenv:py36]
basepython = python3.6