Compare commits

..

No commits in common. "master" and "5.0.0" have entirely different histories.

25 changed files with 117 additions and 162 deletions

@ -1,4 +1,4 @@
[gerrit]
host=review.opendev.org
host=review.openstack.org
port=29418
project=x/python-cloudpulseclient.git
project=openstack/python-cloudpulseclient.git

@ -1,7 +0,0 @@
- project:
check:
jobs:
- openstack-tox-pep8
gate:
jobs:
- openstack-tox-pep8

@ -1,13 +1,13 @@
If you would like to contribute to the development of OpenStack,
you must follow the steps in this page:
https://docs.openstack.org/infra/manual/developers.html
http://docs.openstack.org/infra/manual/developers.html
Once those steps have been completed, changes to OpenStack
should be submitted for review via the Gerrit tool, following
the workflow documented at:
https://docs.openstack.org/infra/manual/developers.html#development-workflow
http://docs.openstack.org/infra/manual/developers.html#development-workflow
Pull requests submitted through GitHub will be ignored.

@ -1,4 +1,4 @@
python-cloudpulseclient Style Commandments
===============================================
Read the OpenStack Style Commandments https://docs.openstack.org/hacking/latest/
Read the OpenStack Style Commandments http://docs.openstack.org/developer/hacking/

6
MANIFEST.in Normal file

@ -0,0 +1,6 @@
include AUTHORS
include ChangeLog
exclude .gitignore
exclude .gitreview
global-exclude *.pyc

@ -5,9 +5,9 @@ python-cloudpulseclient
A Python language binding for OpenStack CloudPulse.
* Free software: Apache license
* Documentation: https://wiki.openstack.org/wiki/Cloudpulse
* Source: http://git.openstack.org/cgit/openstack/python-cloudpulseclient
* Bugs: https://bugs.launchpad.net/python-cloudpulseclient
* Documentation: http://wiki.openstack.org/wiki/Cloudpulse
* Source: http://git.openstack.org/cgit/stackforge/python-cloudpulseclient
* Bugs: http://bugs.launchpad.net/python-cloudpulseclient
Features
--------

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
#
# Copyright 2012 OpenStack LLC.
# All Rights Reserved.
#

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
#
# Copyright 2012 OpenStack LLC.
# All Rights Reserved.
#

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
#
# Copyright 2012 OpenStack LLC.
# All Rights Reserved.
#

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at

@ -12,7 +12,7 @@
"""oslo_i18n integration module for cloudpulseclient.
See https://docs.openstack.org/oslo.i18n/latest/user/usage.html.
See http://docs.openstack.org/developer/oslo.i18n/usage.html .
"""
@ -23,3 +23,13 @@ _translators = oslo_i18n.TranslatorFactory(domain='cloudpulseclient')
# The primary translation function using the well-known name "_"
_ = _translators.primary
# Translators for log levels.
#
# The abbreviated names are meant to reflect the usual use of a short
# name like '_'. The "L" is for "log" and the other letter comes from
# the level.
_LI = _translators.log_info
_LW = _translators.log_warning
_LE = _translators.log_error
_LC = _translators.log_critical

@ -12,18 +12,34 @@
"""oslo.i18n integration module.
See https://docs.openstack.org/oslo.i18n/latest/user/usage.html
See http://docs.openstack.org/developer/oslo.i18n/usage.html
"""
import oslo_i18n
try:
import oslo_i18n
# NOTE(dhellmann): This reference to o-s-l-o will be replaced by the
# application name when this module is synced into the separate
# repository. It is OK to have more than one translation function
# using the same domain, since there will still only be one message
# catalog.
_translators = oslo_i18n.TranslatorFactory(domain='cloudpulseclient')
# NOTE(dhellmann): This reference to o-s-l-o will be replaced by the
# application name when this module is synced into the separate
# repository. It is OK to have more than one translation function
# using the same domain, since there will still only be one message
# catalog.
_translators = oslo_i18n.TranslatorFactory(domain='cloudpulseclient')
# The primary translation function using the well-known name "_"
_ = _translators.primary
# The primary translation function using the well-known name "_"
_ = _translators.primary
# Translators for log levels.
#
# The abbreviated names are meant to reflect the usual use of a short
# name like '_'. The "L" is for "log" and the other letter comes from
# the level.
_LI = _translators.log_info
_LW = _translators.log_warning
_LE = _translators.log_error
_LC = _translators.log_critical
except ImportError:
# NOTE(dims): Support for cases where a project wants to use
# code from oslo-incubator, but is not ready to be internationalized
# (like tempest)
_ = _LI = _LW = _LE = _LC = lambda x: x

@ -127,8 +127,6 @@ class BaseAuthPlugin(object):
"tenant_name",
"token",
"auth_url",
"project_domain_name",
"user_domain_name",
]
def __init__(self, auth_system=None, **kwargs):

@ -41,27 +41,6 @@ class MissingArgs(Exception):
super(MissingArgs, self).__init__(msg)
class InvalidNumber(Exception):
"""Supplied argument for --number is invalid"""
def __init__(self):
msg = _("Invalid input, expected a number in range 1<=number<=240")
super(InvalidNumber, self).__init__(msg)
def check_int_limit(value):
"""Check that supplied arg is of integer type and in range 1<=value<=240"""
try:
int_value = int(value)
except (ValueError, TypeError):
raise InvalidNumber()
# max_db_entries in cloudpulse is 240, hence this limit
if not 1 <= int_value <= 240:
raise InvalidNumber()
return int_value
def validate_args(fn, *args, **kwargs):
"""Check that the supplied args are sufficient for calling a function.
@ -160,7 +139,7 @@ def isunauthenticated(func):
def print_list(objs, fields, formatters=None, sortby_index=0,
mixed_case_fields=None, field_labels=None, limit_number=25):
mixed_case_fields=None, field_labels=None):
"""Print a list or objects as a table, one row per object.
:param objs: iterable of :class:`Resource`
@ -184,16 +163,10 @@ def print_list(objs, fields, formatters=None, sortby_index=0,
kwargs = {}
else:
kwargs = {'sortby': field_labels[sortby_index]}
# Limit the number to 25 (default) or provided number from user
# Show last entries after sorting
kwargs['start'] = 0
kwargs['end'] = limit_number
pt = prettytable.PrettyTable(field_labels)
pt.align = 'l'
for o in objs[::-1]:
for o in objs:
row = []
for field in fields:
if field in formatters:
@ -294,5 +267,5 @@ def pretty_choice_list(l):
def exit(msg=''):
if msg:
print(msg, file=sys.stderr)
print (msg, file=sys.stderr)
sys.exit(1)

@ -33,13 +33,6 @@ from oslo_utils import encodeutils
from oslo_utils import strutils
import six
from cloudpulseclient.openstack.common.apiclient import auth
from cloudpulseclient.openstack.common.apiclient import exceptions as exc
from cloudpulseclient.openstack.common import cliutils
from cloudpulseclient.v1 import client
from cloudpulseclient.v1 import shell as shell_v1
from cloudpulseclient import version
HAS_KEYRING = False
all_errors = ValueError
try:
@ -56,6 +49,13 @@ try:
except ImportError:
pass
from cloudpulseclient.openstack.common.apiclient import auth
from cloudpulseclient.openstack.common.apiclient import exceptions as exc
from cloudpulseclient.openstack.common import cliutils
from cloudpulseclient.v1 import client
from cloudpulseclient.v1 import shell as shell_v1
from cloudpulseclient import version
DEFAULT_API_VERSION = '1'
DEFAULT_ENDPOINT_TYPE = 'publicURL'
DEFAULT_SERVICE_TYPE = 'health'
@ -294,11 +294,9 @@ class OpenStackCloudPulseShell(object):
metavar='<endpoint-type>',
default=cliutils.env(
'CLOUDPULSE_ENDPOINT_TYPE',
default=cliutils.env(
'OS_ENDPOINT_TYPE',
default=DEFAULT_ENDPOINT_TYPE)),
help='Defaults to env[CLOUDPULSE_ENDPOINT_TYPE] '
'or' + DEFAULT_ENDPOINT_TYPE + '.')
default=DEFAULT_ENDPOINT_TYPE),
help='Defaults to env[CLOUDPULSE_ENDPOINT_TYPE] or'
+ DEFAULT_ENDPOINT_TYPE + '.')
# NOTE(dtroyer): We can't add --endpoint_type here due to argparse
# thinking usage-list --end is ambiguous; but it
# works fine with only --endpoint-type present
@ -523,20 +521,16 @@ class OpenStackCloudPulseShell(object):
'--os-password, env[OS_PASSWORD], or '
'prompted response')
self.cs = client.Client(
username=os_username,
api_key=os_password,
project_id=os_tenant_id,
project_name=os_tenant_name,
auth_url=os_auth_url,
service_type=service_type,
region_name=args.os_region_name,
project_domain_name=args.os_project_domain_name,
user_domain_name=args.os_user_domain_name,
cacert=cacert,
insecure=insecure,
cloudpulse_url=bypass_url,
endpoint_type=endpoint_type)
self.cs = client.Client(username=os_username,
api_key=os_password,
project_id=os_tenant_id,
project_name=os_tenant_name,
auth_url=os_auth_url,
service_type=service_type,
region_name=args.os_region_name,
cacert=cacert,
insecure=insecure,
cloudpulse_url=bypass_url)
args.func(self.cs, args)

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2010-2011 OpenStack Foundation
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
#

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at

@ -25,22 +25,18 @@ class Client(object):
def __init__(self, username=None, api_key=None, project_id=None,
project_name=None, auth_url=None, cloudpulse_url=None,
endpoint_type='publicURL', service_type='container',
project_domain_name=None, user_domain_name=None,
region_name=None, input_auth_token=None, insecure=False,
cacert=None):
keystone = None
if not input_auth_token:
keystone = self.get_keystone_client(
username=username,
api_key=api_key,
auth_url=auth_url,
project_id=project_id,
project_name=project_name,
project_domain_name=project_domain_name,
user_domain_name=user_domain_name,
insecure=insecure,
cacert=cacert)
keystone = self.get_keystone_client(username=username,
api_key=api_key,
auth_url=auth_url,
project_id=project_id,
project_name=project_name,
insecure=insecure,
cacert=cacert)
input_auth_token = keystone.auth_token
if not input_auth_token:
@ -84,7 +80,6 @@ class Client(object):
@staticmethod
def get_keystone_client(username=None, api_key=None, auth_url=None,
insecure=False, cacert=None, token=None,
project_domain_name=None, user_domain_name=None,
project_id=None, project_name=None):
if not auth_url:
raise RuntimeError("No auth url specified")
@ -99,8 +94,6 @@ class Client(object):
cacert=cacert,
tenant_id=project_id,
tenant_name=project_name,
project_domain_name=project_domain_name,
user_domain_name=user_domain_name,
auth_url=auth_url,
endpoint=auth_url)
client.authenticate()

@ -29,22 +29,17 @@ def _print_list_field(field):
@utils.arg('--period',
metavar='<period>',
help='List tests results that have been run in the last x minutes.')
@utils.arg('--number',
metavar='<number>',
default=25,
type=utils.check_int_limit,
help='List x number of tests (Max 240).')
def do_result(cs, args):
"""List all the test results"""
search_opts = {
'failed': args.failed,
'period': args.period
'period': args.period,
}
healtchecks = cs.healthcheck.list(search_opts=search_opts)
columns = ('uuid', 'id', 'name', 'testtype', 'state')
utils.print_list(healtchecks, columns,
{'versions': _print_list_field('versions')},
sortby_index=1, limit_number=args.number)
sortby_index=1)
@utils.arg('--name',

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

@ -2,13 +2,13 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
pbr>=1.6
Babel>=2.3.4 # BSD
oslo.config>=3.14.0 # Apache-2.0
oslo.i18n>=2.1.0 # Apache-2.0
oslo.utils>=3.16.0 # Apache-2.0
iso8601>=0.1.11 # MIT
requests>=2.10.0 # Apache-2.0
python-keystoneclient>=2.0.0,!=2.1.0 # Apache-2.0
PyYAML>=3.1.0 # MIT
stevedore>=1.16.0 # Apache-2.0
six>=1.9.0 # MIT
Babel>=1.3
oslo.config>=2.3.0 # Apache-2.0
oslo.i18n>=1.5.0 # Apache-2.0`
oslo.utils>=2.0.0,!=2.6.0 # Apache-2.0
iso8601>=0.1.9
requests>=2.5.2,!=2.8.0,!=2.9.0
python-keystoneclient>=1.6.0,!=1.8.0
PyYAML>=3.1.0
stevedore>=1.5.0 # Apache-2.0
six>=1.9.0

@ -4,7 +4,7 @@ summary = A Python language binding for OpenStack CloudPulse.
description-file =
README.rst
author = OpenStack
author-email = openstack-discuss@lists.openstack.org
author-email = openstack-dev@lists.openstack.org
home-page = http://www.openstack.org/
classifier =
Environment :: OpenStack
@ -18,8 +18,6 @@ classifier =
Programming Language :: Python :: 3
Programming Language :: Python :: 3.3
Programming Language :: Python :: 3.4
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
[files]
packages =

@ -1,20 +0,0 @@
#!/bin/sh
#
# A simple wrapper around flake8 which makes it possible
# to ask it to only verify files changed in the current
# git HEAD patch.
#
# Intended to be invoked via tox:
#
# tox -epep8 -- -HEAD
#
if test "x$1" = "x-HEAD" ; then
shift
files=$(git diff --name-only HEAD~1 | tr '\n' ' ')
echo "Running flake8 on ${files}"
diff -u --from-file /dev/null ${files} | flake8 --diff "$@"
else
echo "Running flake8 on all files"
exec flake8 "$@"
fi

32
tox.ini

@ -1,46 +1,30 @@
[tox]
minversion = 2.0
envlist = py36,pep8
minversion = 1.6
envlist = py34,py27,pep8
skipsdist = True
[testenv]
basepython = python3
usedevelop = True
install_command = pip install -U {opts} {packages}
install_command = pip install {opts} {packages}
setenv =
VIRTUAL_ENV={envdir}
PYTHONWARNINGS=default::DeprecationWarning
OS_STDOUT_CAPTURE=1
OS_STDERR_CAPTURE=1
deps =
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
passenv = TEMPEST_* OS_TEST_*
commands =
find . -type f -name "*.py[c|o]" -delete
stestr run {posargs}
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands = python setup.py test --slowest --testr-args='{posargs}'
[testenv:pep8]
commands =
bash tools/flake8wrap.sh {posargs}
commands = flake8
[testenv:venv]
basepython = python3
commands = {posargs}
[testenv:cover]
basepython = python3
commands =
python setup.py test --coverage --testr-args='{posargs}'
coverage report
commands = python setup.py test --coverage --testr-args='{posargs}'
[testenv:docs]
basepython = python3
commands = python setup.py build_sphinx
[testenv:debug]
basepython = python3
commands = oslo_debug_helper {posargs}
[flake8]