Retire Packaging Deb project repos

This commit is part of a series to retire the Packaging Deb
project. Step 2 is to remove all content from the project
repos, replacing it with a README notification where to find
ongoing work, and how to recover the repo if needed at some
future point (as in
https://docs.openstack.org/infra/manual/drivers.html#retiring-a-project).

Change-Id: Ibc6ebd80639297149f20efd0e2ee371df7dff498
This commit is contained in:
Tony Breeds 2017-09-12 15:37:08 -06:00
parent fbd048f4c0
commit 8a34cd9d5b
38 changed files with 14 additions and 2319 deletions

View File

@ -1,7 +0,0 @@
[run]
branch = True
source = ceilometermiddleware
omit = ceilometermiddleware/tests/*
[report]
ignore_errors = True

61
.gitignore vendored
View File

@ -1,61 +0,0 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# ChangeLog
ChangeLog
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.testrepository/
.coverage
.cache
nosetests.xml
coverage.xml
# Translations
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
doc/build/
# PyBuilder
target/
# Files created by releasenotes build
releasenotes/build

View File

@ -1,4 +0,0 @@
[gerrit]
host=review.openstack.org
port=29418
project=openstack/ceilometermiddleware.git

View File

@ -1,4 +0,0 @@
[DEFAULT]
test_command=${PYTHON:-python} -m subunit.run discover -t ./ ./ceilometermiddleware/tests $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE
test_list_option=--list

View File

@ -1,16 +0,0 @@
If you would like to contribute to the development of OpenStack,
you must follow the steps in this page:
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:
http://docs.openstack.org/infra/manual/developers.html#development-workflow
Pull requests submitted through GitHub will be ignored.
Bugs should be filed on Launchpad, not GitHub:
https://bugs.launchpad.net/ceilometermiddleware

View File

@ -1,4 +0,0 @@
ceilometermiddleware Style Commandments
===============================================
Read the OpenStack Style Commandments http://docs.openstack.org/developer/hacking/

176
LICENSE
View File

@ -1,176 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

14
README Normal file
View File

@ -0,0 +1,14 @@
This project is no longer maintained.
The contents of this repository are still available in the Git
source code management system. To see the contents of this
repository before it reached its end of life, please check out the
previous commit with "git checkout HEAD^1".
For ongoing work on maintaining OpenStack packages in the Debian
distribution, please see the Debian OpenStack packaging team at
https://wiki.debian.org/OpenStack/.
For any further questions, please email
openstack-dev@lists.openstack.org or join #openstack-dev on
Freenode.

View File

@ -1,17 +0,0 @@
===============================================
Middleware for OpenStack Telemetry (Ceilometer)
===============================================
This library provides middleware modules designed to enable metric and event
data generation to be consumed by Ceilometer.
For information on contributing, see ``CONTRIBUTING.rst``.
* License: Apache License, Version 2.0
* Documentation: http://docs.openstack.org/developer/ceilometermiddleware
* Source: http://git.openstack.org/cgit/openstack/ceilometermiddleware
* Bugs: http://bugs.launchpad.net/ceilometermiddleware
For any other information, refer to the parent project, Ceilometer:
https://github.com/openstack/ceilometer

View File

@ -1,2 +0,0 @@
[python: **.py]

View File

@ -1,19 +0,0 @@
# -*- 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import pbr.version
__version__ = pbr.version.VersionInfo(
'ceilometermiddleware').version_string()

View File

@ -1,416 +0,0 @@
#
# Copyright 2012 eNovance <licensing@enovance.com>
#
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Telemetry Middleware for Swift Proxy
Configuration:
In /etc/swift/proxy-server.conf on the main pipeline add "ceilometer" just
before "proxy-server" and add the following filter in the file:
.. code-block:: python
[filter:ceilometer]
paste.filter_factory = ceilometermiddleware.swift:filter_factory
# Some optional configuration this allow to publish additional metadata
metadata_headers = X-TEST
# Set reseller prefix (defaults to "AUTH_" if not set)
reseller_prefix = AUTH_
# Set control_exchange to publish to.
control_exchange = swift
# Set transport url
url = rabbit://me:passwd@host:5672/virtual_host
# set messaging driver
driver = messagingv2
# set topic
topic = notifications
# skip metering of requests from listed project ids
ignore_projects = <proj_uuid>, <proj_uuid2>, <proj_name>
# Whether to send events to messaging driver in a background thread
nonblocking_notify = False
# Queue size for sending notifications in background thread (0=unlimited).
# New notifications will be discarded if the queue is full.
send_queue_size = 1000
# Logging level control
log_level = WARNING
# All keystoneauth1 options can be set to query project name for
# ignore_projects option, here is just a example:
auth_type = password
auth_url = https://[::1]:5000
project_name = service
project_domain_name = Default
username = user
user_domain_name = Default
password = a_big_secret
interface = public
"""
import datetime
import functools
import logging
from keystoneauth1 import exceptions as ksa_exc
from keystoneauth1.loading import adapter as ksa_adapter
from keystoneauth1.loading import base as ksa_base
from keystoneauth1.loading import session as ksa_session
from keystoneclient.v3 import client as ks_client
from oslo_config import cfg
import oslo_messaging
from oslo_utils import strutils
from pycadf import event as cadf_event
from pycadf.helper import api
from pycadf import measurement as cadf_measurement
from pycadf import metric as cadf_metric
from pycadf import resource as cadf_resource
import six
import six.moves.queue as queue
import six.moves.urllib.parse as urlparse
import threading
LOG = logging.getLogger(__name__)
def list_from_csv(comma_separated_str):
if comma_separated_str:
return list(
filter(lambda x: x,
map(lambda x: x.strip(),
comma_separated_str.split(','))))
return []
def _log_and_ignore_error(fn):
@functools.wraps(fn)
def wrapper(*args, **kwargs):
try:
return fn(*args, **kwargs)
except Exception as e:
LOG.exception('An exception occurred processing '
'the API call: %s ', e)
return wrapper
class InputProxy(object):
"""File-like object that counts bytes read.
To be swapped in for wsgi.input for accounting purposes.
Borrowed from swift.common.utils. Duplicated here to avoid
dependency on swift package.
"""
def __init__(self, wsgi_input):
self.wsgi_input = wsgi_input
self.bytes_received = 0
def read(self, *args, **kwargs):
"""Pass read request to the underlying file-like object
Add bytes read to total.
"""
chunk = self.wsgi_input.read(*args, **kwargs)
self.bytes_received += len(chunk)
return chunk
def readline(self, *args, **kwargs):
"""Pass readline request to the underlying file-like object
Add bytes read to total.
"""
line = self.wsgi_input.readline(*args, **kwargs)
self.bytes_received += len(line)
return line
class KeystoneClientLoader(ksa_adapter.Adapter):
"""Keystone client adapter loader.
Keystone client and Keystoneauth1 adapter take exactly the same options, so
it's safe to create a keystone client with keystoneauth adapter options.
"""
@property
def plugin_class(self):
return ks_client.Client
class Swift(object):
"""Swift middleware used for counting requests."""
event_queue = None
threadLock = threading.Lock()
DEFAULT_IGNORE_PROJECT_NAMES = ['service']
def __init__(self, app, conf):
self._app = app
self.ignore_projects = self._get_ignore_projects(conf)
oslo_messaging.set_transport_defaults(conf.get('control_exchange',
'swift'))
self._notifier = oslo_messaging.Notifier(
oslo_messaging.get_notification_transport(cfg.CONF,
url=conf.get('url')),
publisher_id='ceilometermiddleware',
driver=conf.get('driver', 'messagingv2'),
topics=[conf.get('topic', 'notifications')])
self.metadata_headers = [h.strip().replace('-', '_').lower()
for h in conf.get(
"metadata_headers",
"").split(",") if h.strip()]
self.reseller_prefix = conf.get('reseller_prefix', 'AUTH_')
if self.reseller_prefix and self.reseller_prefix[-1] != '_':
self.reseller_prefix += '_'
LOG.setLevel(getattr(logging, conf.get('log_level', 'WARNING')))
# NOTE: If the background thread's send queue fills up, the event will
# be discarded
#
# For backward compatibility we default to False and therefore wait for
# sending to complete. This causes swift proxy to hang if the
# destination is unavailable.
self.nonblocking_notify = strutils.bool_from_string(
conf.get('nonblocking_notify', False))
# Initialize the sending queue and thread, but only once
if self.nonblocking_notify and Swift.event_queue is None:
Swift.threadLock.acquire()
if Swift.event_queue is None:
send_queue_size = int(conf.get('send_queue_size', 1000))
Swift.event_queue = queue.Queue(send_queue_size)
self.start_sender_thread()
Swift.threadLock.release()
def _get_ignore_projects(self, conf):
if 'auth_type' not in conf:
LOG.info("'auth_type' is not set assuming ignore_projects are "
"only project uuid.")
return list_from_csv(conf.get('ignore_projects'))
if 'ignore_projects' in conf:
ignore_projects = list_from_csv(conf.get('ignore_projects'))
else:
ignore_projects = self.DEFAULT_IGNORE_PROJECT_NAMES
if not ignore_projects:
return []
def opt_getter(opt):
# TODO(sileht): This method does not support deprecated opt names
val = conf.get(opt.name)
if val is None:
val = conf.get(opt.dest)
return val
auth_type = conf.get('auth_type')
plugin = ksa_base.get_plugin_loader(auth_type)
auth = plugin.load_from_options_getter(opt_getter)
session = ksa_session.Session().load_from_options_getter(
opt_getter, auth=auth)
client = KeystoneClientLoader().load_from_options_getter(
opt_getter, session=session)
projects = []
for name_or_id in ignore_projects:
projects.extend(self._get_keystone_projects(client, name_or_id))
return projects
@staticmethod
def _get_keystone_projects(client, name_or_id):
try:
return [client.projects.get(name_or_id)]
except ksa_exc.NotFound:
pass
if isinstance(name_or_id, six.binary_type):
name_or_id = name_or_id.decode('utf-8', 'strict')
projects = client.projects.list(name=name_or_id)
if not projects:
LOG.warning("fail to find project '%s' in keystone", name_or_id)
return [p.id for p in projects]
def __call__(self, env, start_response):
start_response_args = [None]
input_proxy = InputProxy(env['wsgi.input'])
env['wsgi.input'] = input_proxy
def my_start_response(status, headers, exc_info=None):
start_response_args[0] = (status, list(headers), exc_info)
def iter_response(iterable):
iterator = iter(iterable)
try:
chunk = next(iterator)
while not chunk:
chunk = next(iterator)
except StopIteration:
chunk = ''
if start_response_args[0]:
start_response(*start_response_args[0])
bytes_sent = 0
try:
while chunk:
bytes_sent += len(chunk)
yield chunk
chunk = next(iterator)
finally:
self.emit_event(env, input_proxy.bytes_received, bytes_sent)
try:
iterable = self._app(env, my_start_response)
except Exception:
self.emit_event(env, input_proxy.bytes_received, 0, 'failure')
raise
else:
return iter_response(iterable)
@_log_and_ignore_error
def emit_event(self, env, bytes_received, bytes_sent, outcome='success'):
if ((env.get('HTTP_X_SERVICE_PROJECT_ID') or
env.get('HTTP_X_PROJECT_ID') or
env.get('HTTP_X_TENANT_ID')) in self.ignore_projects or
env.get('swift.source') is not None):
return
path = urlparse.quote(env['PATH_INFO'])
method = env['REQUEST_METHOD']
headers = {}
for header in env:
if header.startswith('HTTP_') and env[header]:
key = header[5:]
if isinstance(env[header], six.text_type):
headers[key] = six.text_type(env[header])
else:
headers[key] = str(env[header])
try:
container = obj = None
path = path.replace('/', '', 1)
version, account, remainder = path.split('/', 2)
except ValueError:
try:
version, account = path.split('/', 1)
remainder = None
except ValueError:
return
try:
if not version or not account:
raise ValueError('Invalid path: %s' % path)
if remainder:
if '/' in remainder:
container, obj = remainder.split('/', 1)
else:
container = remainder
except ValueError:
return
now = datetime.datetime.utcnow().isoformat()
resource_metadata = {
"path": path,
"version": version,
"container": container,
"object": obj,
}
for header in self.metadata_headers:
if header.upper() in headers:
resource_metadata['http_header_%s' % header] = headers.get(
header.upper())
# build object store details
target = cadf_resource.Resource(
typeURI='service/storage/object',
id=account.partition(self.reseller_prefix)[2] or path)
target.metadata = resource_metadata
target.action = method.lower()
# build user details
initiator = cadf_resource.Resource(
typeURI='service/security/account/user',
id=env.get('HTTP_X_USER_ID'))
initiator.project_id = (env.get('HTTP_X_PROJECT_ID') or
env.get('HTTP_X_TENANT_ID'))
# build notification body
event = cadf_event.Event(eventTime=now, outcome=outcome,
action=api.convert_req_action(method),
initiator=initiator, target=target,
observer=cadf_resource.Resource(id='target'))
# measurements
if bytes_received:
event.add_measurement(cadf_measurement.Measurement(
result=bytes_received,
metric=cadf_metric.Metric(
name='storage.objects.incoming.bytes', unit='B')))
if bytes_sent:
event.add_measurement(cadf_measurement.Measurement(
result=bytes_sent,
metric=cadf_metric.Metric(
name='storage.objects.outgoing.bytes', unit='B')))
if self.nonblocking_notify:
try:
Swift.event_queue.put(event, False)
if not Swift.event_sender.is_alive():
Swift.threadLock.acquire()
self.start_sender_thread()
Swift.threadLock.release()
except queue.Full:
LOG.warning('Send queue FULL: Event %s not added', event.id)
else:
Swift.send_notification(self._notifier, event)
def start_sender_thread(self):
Swift.event_sender = SendEventThread(self._notifier)
Swift.event_sender.daemon = True
Swift.event_sender.start()
@staticmethod
def send_notification(notifier, event):
notifier.info({}, 'objectstore.http.request', event.as_dict())
class SendEventThread(threading.Thread):
def __init__(self, notifier):
super(SendEventThread, self).__init__()
self.notifier = notifier
def run(self):
"""Send events without blocking swift proxy."""
while True:
try:
LOG.debug('Wait for event from send queue')
event = Swift.event_queue.get()
LOG.debug('Got event %s from queue - now send it', event.id)
Swift.send_notification(self.notifier, event)
LOG.debug('Event %s sent.', event.id)
except BaseException:
LOG.exception("SendEventThread loop exception")
def filter_factory(global_conf, **local_conf):
conf = global_conf.copy()
conf.update(local_conf)
def filter(app):
return Swift(app, conf)
return filter

View File

@ -1,23 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright 2010-2011 OpenStack Foundation
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
#
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslotest import base
class TestCase(base.BaseTestCase):
"""Test case base class for all unit tests."""

View File

@ -1,514 +0,0 @@
http_interactions:
- recorded_at: '2017-05-15T07:49:52'
request:
body:
encoding: utf-8
string: |-
{
"auth": {
"tenantName": "dummy",
"passwordCredentials": {
"username": "dummy",
"password": "********"
}
}
}
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '107'
Content-Type:
- application/json
User-Agent:
- run.py keystoneauth1/2.20.0 python-requests/2.14.2 CPython/2.7.13
method: POST
uri: https://[::1]:5000/v2.0/tokens
response:
body:
encoding: null
string: |-
{
"access": {
"serviceCatalog": [
{
"type": "compute",
"endpoints_links": [],
"name": "nova",
"endpoints": [
{
"internalURL": "https://[::1]:8774/v2.1",
"adminURL": "https://[::1]:8774/v2.1",
"id": "1e879ab434b54b8abfd275feeb2ef9f3",
"region": "RegionOne",
"publicURL": "https://[::1]:8774/v2.1"
}
]
},
{
"type": "network",
"endpoints_links": [],
"name": "neutron",
"endpoints": [
{
"internalURL": "http://[::1]:9696",
"adminURL": "http://[::1]:9696",
"id": "83fcb786f646437f9a61cef72a9e43d7",
"region": "RegionOne",
"publicURL": "http://[::1]:9696"
}
]
},
{
"type": "volumev2",
"endpoints_links": [],
"name": "cinderv2",
"endpoints": [
{
"internalURL": "https://[::1]:8776/v2/ed980105f9d047e2bee738b3f261f126",
"adminURL": "https://[::1]:8776/v2/ed980105f9d047e2bee738b3f261f126",
"id": "973ef665c2ea4ec3b5c3d48932fad7a4",
"region": "RegionOne",
"publicURL": "https://[::1]:8776/v2/ed980105f9d047e2bee738b3f261f126"
}
]
},
{
"type": "volumev3",
"endpoints_links": [],
"name": "cinderv3",
"endpoints": [
{
"internalURL": "https://[::1]:8776/v3/ed980105f9d047e2bee738b3f261f126",
"adminURL": "https://[::1]:8776/v3/ed980105f9d047e2bee738b3f261f126",
"id": "0e80fe643d4d44729db99d0a5c882d1b",
"region": "RegionOne",
"publicURL": "https://[::1]:8776/v3/ed980105f9d047e2bee738b3f261f126"
}
]
},
{
"type": "image",
"endpoints_links": [],
"name": "glance",
"endpoints": [
{
"internalURL": "http://[::1]:9292",
"adminURL": "http://[::1]:9292",
"id": "7aad24b660a94254adc3546e4de4d668",
"region": "RegionOne",
"publicURL": "http://[::1]:9292"
}
]
},
{
"type": "volume",
"endpoints_links": [],
"name": "cinder",
"endpoints": [
{
"internalURL": "https://[::1]:8776/v1/ed980105f9d047e2bee738b3f261f126",
"adminURL": "https://[::1]:8776/v1/ed980105f9d047e2bee738b3f261f126",
"id": "8191ee00b695483796a9531bca70279b",
"region": "RegionOne",
"publicURL": "https://[::1]:8776/v1/ed980105f9d047e2bee738b3f261f126"
}
]
},
{
"type": "identity",
"endpoints_links": [],
"name": "keystone",
"endpoints": [
{
"internalURL": "https://[::1]:5000",
"adminURL": "https://[::1]:35357",
"id": "24ab268f1a7b47d4af493c4c74cd6130",
"region": "RegionOne",
"publicURL": "https://[::1]:5000"
}
]
}
],
"user": {
"username": "dummy",
"roles_links": [],
"id": "f18b121edda04346b86610fa23983a0e",
"roles": [
{
"name": "admin"
}
],
"name": "dummy"
},
"token": {
"issued_at": "2017-05-15T07:49:52.000000Z",
"tenant": {
"enabled": true,
"id": "ed980105f9d047e2bee738b3f261f126",
"name": "dummy",
"description": "admin tenant"
},
"audit_ids": [
"VzK7yoNFT0qlUWg5KhDuMQ"
],
"expires": "9999-12-31T23:59:59Z",
"id": "gAAAAABZGV2gZwV0SlycA_OIohX7kRAmTp84SnzsAYD5Uhey7RTzCf0NvxNRxLk5RsjRSMncSdro7eWgtMrSblZJCPl485IvHANL3E3gsxFJP9TjebqDiF4DtGhQmc4mHPB3kOBNzg3v2FrHB2hK77Cc4M7V1Pm_-nWBHxYxVNopVhrd80Y4-2c"
},
"metadata": {
"is_admin": 0,
"roles": [
"d3b61a4656d64cbbbdb0f13690e2ffe4"
]
}
}
}
headers:
Connection:
- Keep-Alive
Content-Length:
- '3183'
Content-Type:
- application/json
Date:
- Mon, 15 May 2017 07:49:51 GMT
Keep-Alive:
- timeout=3, max=100
Server:
- Apache/2.4.18 (Ubuntu)
Strict-Transport-Security:
- max-age=15768000
Vary:
- X-Auth-Token
X-Distribution:
- Ubuntu
x-openstack-request-id:
- req-84cb5714-49dc-4bab-93ba-2b66ba566c30
status:
code: 200
message: OK
url: https://[::1]:5000/v2.0/tokens
- recorded_at: '2017-05-15T07:49:53'
request:
body:
encoding: utf-8
string: ''
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- run.py keystoneauth1/2.20.0 python-requests/2.14.2 CPython/2.7.13
method: GET
uri: https://[::1]:35357/
response:
body:
encoding: null
string: |-
{
"versions": {
"values": [
{
"status": "stable",
"updated": "2016-10-06T00:00:00Z",
"id": "v3.7",
"links": [
{
"rel": "self",
"href": "https://[::1]:35357/v3/"
}
],
"media-types": [
{
"type": "application/vnd.openstack.identity-v3+json",
"base": "application/json"
}
]
},
{
"status": "deprecated",
"updated": "2016-08-04T00:00:00Z",
"id": "v2.0",
"links": [
{
"rel": "self",
"href": "https://[::1]:35357/v2.0/"
},
{
"type": "text/html",
"rel": "describedby",
"href": "http://docs.openstack.org/"
}
],
"media-types": [
{
"type": "application/vnd.openstack.identity-v2.0+json",
"base": "application/json"
}
]
}
]
}
}
headers:
Connection:
- Keep-Alive
Content-Length:
- '627'
Content-Type:
- application/json
Date:
- Mon, 15 May 2017 07:49:52 GMT
Keep-Alive:
- timeout=3, max=100
Server:
- Apache/2.4.18 (Ubuntu)
Strict-Transport-Security:
- max-age=15768000
Vary:
- X-Auth-Token
X-Distribution:
- Ubuntu
status:
code: 300
message: Multiple Choices
url: https://[::1]:35357/
- recorded_at: '2017-05-15T07:49:53'
request:
body:
encoding: utf-8
string: ''
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- python-keystoneclient
X-Auth-Token:
- gAAAAABZGV2gZwV0SlycA_OIohX7kRAmTp84SnzsAYD5Uhey7RTzCf0NvxNRxLk5RsjRSMncSdro7eWgtMrSblZJCPl485IvHANL3E3gsxFJP9TjebqDiF4DtGhQmc4mHPB3kOBNzg3v2FrHB2hK77Cc4M7V1Pm_-nWBHxYxVNopVhrd80Y4-2c
method: GET
uri: https://[::1]:35357/v3/projects/service
response:
body:
encoding: null
string: |-
{
"error": {
"code": 404,
"title": "Not Found",
"message": "Could not find project: service"
}
}
headers:
Connection:
- Keep-Alive
Content-Length:
- '93'
Content-Type:
- application/json
Date:
- Mon, 15 May 2017 07:49:53 GMT
Keep-Alive:
- timeout=3, max=99
Server:
- Apache/2.4.18 (Ubuntu)
Strict-Transport-Security:
- max-age=15768000
Vary:
- X-Auth-Token
X-Distribution:
- Ubuntu
x-openstack-request-id:
- req-6107025c-e09e-437a-90c2-61a559154d32
status:
code: 404
message: Not Found
url: https://[::1]:35357/v3/projects/service
- recorded_at: '2017-05-15T07:49:53'
request:
body:
encoding: utf-8
string: ''
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- python-keystoneclient
X-Auth-Token:
- gAAAAABZGV2gZwV0SlycA_OIohX7kRAmTp84SnzsAYD5Uhey7RTzCf0NvxNRxLk5RsjRSMncSdro7eWgtMrSblZJCPl485IvHANL3E3gsxFJP9TjebqDiF4DtGhQmc4mHPB3kOBNzg3v2FrHB2hK77Cc4M7V1Pm_-nWBHxYxVNopVhrd80Y4-2c
method: GET
uri: https://[::1]:35357/v3/projects?name=service
response:
body:
encoding: null
string: |-
{
"projects": [
{
"enabled": true,
"id": "147cc0a9263c4964926f3ee7b6ba3685",
"domain_id": "default",
"parent_id": "default",
"is_domain": false,
"name": "service",
"links": {
"self": "https://[::1]:5000/v3/projects/147cc0a9263c4964926f3ee7b6ba3685"
},
"description": "Tenant for the openstack service"
}
],
"links": {
"self": "https://[::1]:5000/v3/projects?name=service",
"next": null,
"previous": null
}
}
headers:
Connection:
- Keep-Alive
Content-Length:
- '440'
Content-Type:
- application/json
Date:
- Mon, 15 May 2017 07:49:53 GMT
Keep-Alive:
- timeout=3, max=98
Server:
- Apache/2.4.18 (Ubuntu)
Strict-Transport-Security:
- max-age=15768000
Vary:
- X-Auth-Token
X-Distribution:
- Ubuntu
x-openstack-request-id:
- req-1915b2be-f116-4831-a7c3-5ba0a32d416f
status:
code: 200
message: OK
url: https://[::1]:35357/v3/projects?name=service
- recorded_at: '2017-05-15T07:49:53'
request:
body:
encoding: utf-8
string: ''
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- python-keystoneclient
X-Auth-Token:
- gAAAAABZGV2gZwV0SlycA_OIohX7kRAmTp84SnzsAYD5Uhey7RTzCf0NvxNRxLk5RsjRSMncSdro7eWgtMrSblZJCPl485IvHANL3E3gsxFJP9TjebqDiF4DtGhQmc4mHPB3kOBNzg3v2FrHB2hK77Cc4M7V1Pm_-nWBHxYxVNopVhrd80Y4-2c
method: GET
uri: https://[::1]:35357/v3/projects/gnocchi
response:
body:
encoding: null
string: |-
{
"error": {
"code": 404,
"title": "Not Found",
"message": "Could not find project: gnocchi"
}
}
headers:
Connection:
- Keep-Alive
Content-Length:
- '92'
Content-Type:
- application/json
Date:
- Mon, 15 May 2017 07:49:53 GMT
Keep-Alive:
- timeout=3, max=97
Server:
- Apache/2.4.18 (Ubuntu)
Strict-Transport-Security:
- max-age=15768000
Vary:
- X-Auth-Token
X-Distribution:
- Ubuntu
x-openstack-request-id:
- req-b23e72d3-742e-4e10-b9a7-d1161f1eeab4
status:
code: 404
message: Not Found
url: https://[::1]:35357/v3/projects/gnocchi
- recorded_at: '2017-05-15T07:49:53'
request:
body:
encoding: utf-8
string: ''
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- python-keystoneclient
X-Auth-Token:
- gAAAAABZGV2gZwV0SlycA_OIohX7kRAmTp84SnzsAYD5Uhey7RTzCf0NvxNRxLk5RsjRSMncSdro7eWgtMrSblZJCPl485IvHANL3E3gsxFJP9TjebqDiF4DtGhQmc4mHPB3kOBNzg3v2FrHB2hK77Cc4M7V1Pm_-nWBHxYxVNopVhrd80Y4-2c
method: GET
uri: https://[::1]:35357/v3/projects?name=gnocchi
response:
body:
encoding: null
string: |-
{
"projects": [],
"links": {
"self": "https://[::1]:5000/v3/projects?name=gnocchi",
"next": null,
"previous": null
}
}
headers:
Connection:
- Keep-Alive
Content-Length:
- '134'
Content-Type:
- application/json
Date:
- Mon, 15 May 2017 07:49:53 GMT
Keep-Alive:
- timeout=3, max=96
Server:
- Apache/2.4.18 (Ubuntu)
Strict-Transport-Security:
- max-age=15768000
Vary:
- X-Auth-Token
X-Distribution:
- Ubuntu
x-openstack-request-id:
- req-fdeed726-18a4-4e73-bf8d-d24a5b56246e
status:
code: 200
message: OK
url: https://[::1]:35357/v3/projects?name=gnocchi
recorded_with: betamax/0.8.0

View File

@ -1,461 +0,0 @@
#
# Copyright 2012 eNovance <licensing@enovance.com>
#
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import threading
import mock
from oslo_config import cfg
import six
from ceilometermiddleware import swift
from ceilometermiddleware.tests import base as tests_base
from keystoneauth1.fixture import keystoneauth_betamax as betamax
class FakeApp(object):
def __init__(self, body=None):
self.body = body or ['This string is 28 bytes long']
def __call__(self, env, start_response):
yield
start_response('200 OK', [
('Content-Type', 'text/plain'),
('Content-Length', str(sum(map(len, self.body))))
])
while env['wsgi.input'].read(5):
pass
for line in self.body:
yield line
class FakeRequest(object):
"""A bare bones request object
The middleware will inspect this for request method,
wsgi.input and headers.
"""
def __init__(self, path, environ=None, headers=None):
environ = environ or {}
headers = headers or {}
environ['PATH_INFO'] = path
if 'wsgi.input' not in environ:
environ['wsgi.input'] = six.moves.cStringIO('')
for header, value in six.iteritems(headers):
environ['HTTP_%s' % header.upper()] = value
self.environ = environ
@mock.patch('oslo_messaging.get_transport', mock.MagicMock())
class TestSwift(tests_base.TestCase):
def setUp(self):
super(TestSwift, self).setUp()
cfg.CONF([], project='ceilometermiddleware')
self.addCleanup(cfg.CONF.reset)
@staticmethod
def start_response(*args):
pass
def test_get(self):
app = swift.Swift(FakeApp(), {})
req = FakeRequest('/1.0/account/container/obj',
environ={'REQUEST_METHOD': 'GET'})
with mock.patch('oslo_messaging.Notifier.info') as notify:
resp = app(req.environ, self.start_response)
self.assertEqual(["This string is 28 bytes long"], list(resp))
self.assertEqual(1, len(notify.call_args_list))
data = notify.call_args_list[0][0]
self.assertEqual('objectstore.http.request', data[1])
self.assertEqual(28, data[2]['measurements'][0]['result'])
self.assertEqual('storage.objects.outgoing.bytes',
data[2]['measurements'][0]['metric']['name'])
metadata = data[2]['target']['metadata']
self.assertEqual('1.0', metadata['version'])
self.assertEqual('container', metadata['container'])
self.assertEqual('obj', metadata['object'])
self.assertEqual('get', data[2]['target']['action'])
def test_get_background(self):
notified = threading.Event()
app = swift.Swift(FakeApp(),
{"nonblocking_notify": "True",
"send_queue_size": "1"})
req = FakeRequest('/1.0/account/container/obj',
environ={'REQUEST_METHOD': 'GET'})
with mock.patch('oslo_messaging.Notifier.info',
side_effect=lambda *args, **kwargs: notified.set()
) as notify:
resp = app(req.environ, self.start_response)
self.assertEqual(["This string is 28 bytes long"], list(resp))
notified.wait()
self.assertEqual(1, len(notify.call_args_list))
data = notify.call_args_list[0][0]
self.assertEqual('objectstore.http.request', data[1])
self.assertEqual(28, data[2]['measurements'][0]['result'])
self.assertEqual('storage.objects.outgoing.bytes',
data[2]['measurements'][0]['metric']['name'])
metadata = data[2]['target']['metadata']
self.assertEqual('1.0', metadata['version'])
self.assertEqual('container', metadata['container'])
self.assertEqual('obj', metadata['object'])
self.assertEqual('get', data[2]['target']['action'])
def test_put(self):
app = swift.Swift(FakeApp(body=['']), {})
req = FakeRequest(
'/1.0/account/container/obj',
environ={'REQUEST_METHOD': 'PUT',
'wsgi.input':
six.moves.cStringIO('some stuff')})
with mock.patch('oslo_messaging.Notifier.info') as notify:
list(app(req.environ, self.start_response))
self.assertEqual(1, len(notify.call_args_list))
data = notify.call_args_list[0][0]
self.assertEqual('objectstore.http.request', data[1])
self.assertEqual(10, data[2]['measurements'][0]['result'])
self.assertEqual('storage.objects.incoming.bytes',
data[2]['measurements'][0]['metric']['name'])
metadata = data[2]['target']['metadata']
self.assertEqual('1.0', metadata['version'])
self.assertEqual('container', metadata['container'])
self.assertEqual('obj', metadata['object'])
self.assertEqual('put', data[2]['target']['action'])
def test_post(self):
app = swift.Swift(FakeApp(body=['']), {})
req = FakeRequest(
'/1.0/account/container/obj',
environ={'REQUEST_METHOD': 'POST',
'wsgi.input': six.moves.cStringIO('some other stuff')})
with mock.patch('oslo_messaging.Notifier.info') as notify:
list(app(req.environ, self.start_response))
self.assertEqual(1, len(notify.call_args_list))
data = notify.call_args_list[0][0]
self.assertEqual('objectstore.http.request', data[1])
self.assertEqual(16, data[2]['measurements'][0]['result'])
self.assertEqual('storage.objects.incoming.bytes',
data[2]['measurements'][0]['metric']['name'])
metadata = data[2]['target']['metadata']
self.assertEqual('1.0', metadata['version'])
self.assertEqual('container', metadata['container'])
self.assertEqual('obj', metadata['object'])
self.assertEqual('post', data[2]['target']['action'])
def test_head(self):
app = swift.Swift(FakeApp(body=['']), {})
req = FakeRequest('/1.0/account/container/obj',
environ={'REQUEST_METHOD': 'HEAD'})
with mock.patch('oslo_messaging.Notifier.info') as notify:
list(app(req.environ, self.start_response))
self.assertEqual(1, len(notify.call_args_list))
data = notify.call_args_list[0][0]
self.assertEqual('objectstore.http.request', data[1])
self.assertIsNone(data[2].get('measurements'))
metadata = data[2]['target']['metadata']
self.assertEqual('1.0', metadata['version'])
self.assertEqual('container', metadata['container'])
self.assertEqual('obj', metadata['object'])
self.assertEqual('head', data[2]['target']['action'])
def test_bogus_request(self):
"""Test even for arbitrary request method, this will still work."""
app = swift.Swift(FakeApp(body=['']), {})
req = FakeRequest('/1.0/account/container/obj',
environ={'REQUEST_METHOD': 'BOGUS'})
with mock.patch('oslo_messaging.Notifier.info') as notify:
list(app(req.environ, self.start_response))
self.assertEqual(1, len(notify.call_args_list))
data = notify.call_args_list[0][0]
self.assertEqual('objectstore.http.request', data[1])
self.assertIsNone(data[2].get('measurements'))
metadata = data[2]['target']['metadata']
self.assertEqual('1.0', metadata['version'])
self.assertEqual('container', metadata['container'])
self.assertEqual('obj', metadata['object'])
self.assertEqual('bogus', data[2]['target']['action'])
def test_get_container(self):
app = swift.Swift(FakeApp(), {})
req = FakeRequest('/1.0/account/container',
environ={'REQUEST_METHOD': 'GET'})
with mock.patch('oslo_messaging.Notifier.info') as notify:
list(app(req.environ, self.start_response))
self.assertEqual(1, len(notify.call_args_list))
data = notify.call_args_list[0][0]
self.assertEqual('objectstore.http.request', data[1])
self.assertEqual(28, data[2]['measurements'][0]['result'])
self.assertEqual('storage.objects.outgoing.bytes',
data[2]['measurements'][0]['metric']['name'])
metadata = data[2]['target']['metadata']
self.assertEqual('1.0', metadata['version'])
self.assertEqual('container', metadata['container'])
self.assertIsNone(metadata['object'])
self.assertEqual('get', data[2]['target']['action'])
def test_no_metadata_headers(self):
app = swift.Swift(FakeApp(), {})
req = FakeRequest('/1.0/account/container',
environ={'REQUEST_METHOD': 'GET'})
with mock.patch('oslo_messaging.Notifier.info') as notify:
list(app(req.environ, self.start_response))
self.assertEqual(1, len(notify.call_args_list))
data = notify.call_args_list[0][0]
self.assertEqual('objectstore.http.request', data[1])
metadata = data[2]['target']['metadata']
self.assertEqual('1.0', metadata['version'])
self.assertEqual('container', metadata['container'])
self.assertIsNone(metadata['object'])
self.assertEqual('get', data[2]['target']['action'])
http_headers = [k for k in metadata.keys()
if k.startswith('http_header_')]
self.assertEqual(0, len(http_headers))
def test_metadata_headers(self):
app = swift.Swift(FakeApp(), {
'metadata_headers': 'X_VAR1, x-var2, x-var3, token'
})
req = FakeRequest('/1.0/account/container',
environ={'REQUEST_METHOD': 'GET'},
headers={'X_VAR1': 'value1',
'X_VAR2': 'value2',
'TOKEN': 'token'})
with mock.patch('oslo_messaging.Notifier.info') as notify:
list(app(req.environ, self.start_response))
self.assertEqual(1, len(notify.call_args_list))
data = notify.call_args_list[0][0]
self.assertEqual('objectstore.http.request', data[1])
metadata = data[2]['target']['metadata']
self.assertEqual('1.0', metadata['version'])
self.assertEqual('container', metadata['container'])
self.assertIsNone(metadata['object'])
self.assertEqual('get', data[2]['target']['action'])
http_headers = [k for k in metadata.keys()
if k.startswith('http_header_')]
self.assertEqual(3, len(http_headers))
self.assertEqual('value1', metadata['http_header_x_var1'])
self.assertEqual('value2', metadata['http_header_x_var2'])
self.assertEqual('token', metadata['http_header_token'])
self.assertFalse('http_header_x_var3' in metadata)
def test_metadata_headers_unicode(self):
app = swift.Swift(FakeApp(), {
'metadata_headers': 'unicode'
})
uni = u'\xef\xbd\xa1\xef\xbd\xa5'
req = FakeRequest('/1.0/account/container',
environ={'REQUEST_METHOD': 'GET'},
headers={'UNICODE': uni})
with mock.patch('oslo_messaging.Notifier.info') as notify:
list(app(req.environ, self.start_response))
self.assertEqual(1, len(notify.call_args_list))
data = notify.call_args_list[0][0]
self.assertEqual('objectstore.http.request', data[1])
metadata = data[2]['target']['metadata']
self.assertEqual('1.0', metadata['version'])
self.assertEqual('container', metadata['container'])
self.assertIsNone(metadata['object'])
self.assertEqual('get', data[2]['target']['action'])
http_headers = [k for k in metadata.keys()
if k.startswith('http_header_')]
self.assertEqual(1, len(http_headers))
self.assertEqual(six.text_type(uni),
metadata['http_header_unicode'])
def test_metadata_headers_on_not_existing_header(self):
app = swift.Swift(FakeApp(), {
'metadata_headers': 'x-var3'
})
req = FakeRequest('/1.0/account/container',
environ={'REQUEST_METHOD': 'GET'})
with mock.patch('oslo_messaging.Notifier.info') as notify:
list(app(req.environ, self.start_response))
self.assertEqual(1, len(notify.call_args_list))
data = notify.call_args_list[0][0]
self.assertEqual('objectstore.http.request', data[1])
metadata = data[2]['target']['metadata']
self.assertEqual('1.0', metadata['version'])
self.assertEqual('container', metadata['container'])
self.assertIsNone(metadata['object'])
self.assertEqual('get', data[2]['target']['action'])
http_headers = [k for k in metadata.keys()
if k.startswith('http_header_')]
self.assertEqual(0, len(http_headers))
def test_bogus_path(self):
app = swift.Swift(FakeApp(), {})
req = FakeRequest('/5.0//',
environ={'REQUEST_METHOD': 'GET'})
with mock.patch('oslo_messaging.Notifier.info') as notify:
list(app(req.environ, self.start_response))
self.assertEqual(0, len(notify.call_args_list))
def test_missing_resource_id(self):
app = swift.Swift(FakeApp(), {})
req = FakeRequest('/v1/', environ={'REQUEST_METHOD': 'GET'})
with mock.patch('oslo_messaging.Notifier.info') as notify:
list(app(req.environ, self.start_response))
self.assertEqual(0, len(notify.call_args_list))
@mock.patch('six.moves.urllib.parse.quote')
def test_emit_event_fail(self, mocked_func):
mocked_func.side_effect = Exception("a exception")
app = swift.Swift(FakeApp(body=["test"]), {})
req = FakeRequest('/1.0/account/container',
environ={'REQUEST_METHOD': 'GET'})
with mock.patch('oslo_messaging.Notifier.info') as notify:
resp = list(app(req.environ, self.start_response))
self.assertEqual(0, len(notify.call_args_list))
self.assertEqual(["test"], resp)
def test_reseller_prefix(self):
app = swift.Swift(FakeApp(), {})
req = FakeRequest('/1.0/AUTH_account/container/obj',
environ={'REQUEST_METHOD': 'GET'})
with mock.patch('oslo_messaging.Notifier.info') as notify:
list(app(req.environ, self.start_response))
self.assertEqual(1, len(notify.call_args_list))
data = notify.call_args_list[0][0]
self.assertEqual("account", data[2]['target']['id'])
def test_custom_prefix(self):
app = swift.Swift(FakeApp(), {'reseller_prefix': 'CUSTOM_'})
req = FakeRequest('/1.0/CUSTOM_account/container/obj',
environ={'REQUEST_METHOD': 'GET'})
with mock.patch('oslo_messaging.Notifier.info') as notify:
list(app(req.environ, self.start_response))
self.assertEqual(1, len(notify.call_args_list))
data = notify.call_args_list[0][0]
self.assertEqual("account", data[2]['target']['id'])
def test_incomplete_reseller_prefix(self):
# Custom reseller prefix set, but without trailing underscore
app = swift.Swift(
FakeApp(), {'reseller_prefix': 'CUSTOM'})
req = FakeRequest('/1.0/CUSTOM_account/container/obj',
environ={'REQUEST_METHOD': 'GET'})
with mock.patch('oslo_messaging.Notifier.info') as notify:
list(app(req.environ, self.start_response))
self.assertEqual(1, len(notify.call_args_list))
data = notify.call_args_list[0][0]
self.assertEqual("account", data[2]['target']['id'])
def test_invalid_reseller_prefix(self):
app = swift.Swift(
FakeApp(), {'reseller_prefix': 'AUTH_'})
req = FakeRequest('/1.0/admin/bucket',
environ={'REQUEST_METHOD': 'GET'})
with mock.patch('oslo_messaging.Notifier.info') as notify:
list(app(req.environ, self.start_response))
self.assertEqual(1, len(notify.call_args_list))
data = notify.call_args_list[0][0]
self.assertEqual("1.0/admin/bucket", data[2]['target']['id'])
def test_ignore_requests_from_project(self):
app = swift.Swift(FakeApp(), {'ignore_projects': 'skip_proj'})
for proj_attr in ['HTTP_X_SERVICE_PROJECT_ID', 'HTTP_X_PROJECT_ID',
'HTTP_X_TENANT_ID']:
for proj, calls in [('good', 1), ('skip_proj', 0)]:
req = FakeRequest('/1.0/CUSTOM_account/container/obj',
environ={'REQUEST_METHOD': 'GET',
proj_attr: proj})
with mock.patch('oslo_messaging.Notifier.info') as notify:
list(app(req.environ, self.start_response))
self.assertEqual(calls, len(notify.call_args_list))
def test_ignore_requests_from_multiple_projects(self):
app = swift.Swift(FakeApp(), {'ignore_projects': 'skip_proj, ignore'})
for proj_attr in ['HTTP_X_SERVICE_PROJECT_ID', 'HTTP_X_PROJECT_ID',
'HTTP_X_TENANT_ID']:
for proj, calls in [('good', 1), ('skip_proj', 0),
('also_good', 1), ('ignore', 0)]:
req = FakeRequest('/1.0/CUSTOM_account/container/obj',
environ={'REQUEST_METHOD': 'GET',
proj_attr: proj})
with mock.patch('oslo_messaging.Notifier.info') as notify:
list(app(req.environ, self.start_response))
self.assertEqual(calls, len(notify.call_args_list))
def test_empty_reseller_prefix(self):
app = swift.Swift(
FakeApp(), {'reseller_prefix': 'CUSTOM'})
req = FakeRequest('/1.0/CUSTOM/container/obj',
environ={'REQUEST_METHOD': 'GET'})
with mock.patch('oslo_messaging.Notifier.info') as notify:
list(app(req.environ, self.start_response))
data = notify.call_args_list[0][0]
self.assertIsNot(0, len(data[2]['target']['id']))
def test_head_account(self):
app = swift.Swift(FakeApp(body=['']), {})
req = FakeRequest('/1.0/account',
environ={'REQUEST_METHOD': 'HEAD'})
with mock.patch('oslo_messaging.Notifier.info') as notify:
list(app(req.environ, self.start_response))
self.assertEqual(1, len(notify.call_args_list))
data = notify.call_args_list[0][0]
self.assertEqual('objectstore.http.request', data[1])
self.assertIsNone(data[2].get('measurements'))
metadata = data[2]['target']['metadata']
self.assertEqual('1.0', metadata['version'])
self.assertIsNone(metadata['container'])
self.assertIsNone(metadata['object'])
self.assertEqual('head', data[2]['target']['action'])
def test_put_with_swift_source(self):
app = swift.Swift(FakeApp(), {})
req = FakeRequest(
'/1.0/account/container/obj',
environ={'REQUEST_METHOD': 'PUT',
'wsgi.input':
six.moves.cStringIO('some stuff'),
'swift.source': 'RL'})
with mock.patch('oslo_messaging.Notifier.info') as notify:
list(app(req.environ, self.start_response))
self.assertFalse(notify.called)
def test_ignore_projects_without_keystone(self):
app = swift.Swift(FakeApp(), {
'ignore_projects': 'cf0356aaac7c42bba5a744339a6169fa,'
'18157dd635bb413c9e27686fee93c583',
})
self.assertEqual(["cf0356aaac7c42bba5a744339a6169fa",
"18157dd635bb413c9e27686fee93c583"],
app.ignore_projects)
@mock.patch.object(swift.LOG, 'warning')
def test_ignore_projects_with_keystone(self, warning):
self.useFixture(betamax.BetamaxFixture(
cassette_name='list_projects',
cassette_library_dir='ceilometermiddleware/tests/data',
))
app = swift.Swift(FakeApp(), {
'auth_type': 'v2password',
'auth_url': 'https://[::1]:5000/v2.0',
'username': 'admin',
'tenant_name': 'admin',
'password': 'secret',
'ignore_projects': 'service,gnocchi',
})
self.assertEqual(["147cc0a9263c4964926f3ee7b6ba3685"],
app.ignore_projects)
warning.assert_called_once_with(
"fail to find project '%s' in keystone", "gnocchi")

View File

@ -1,75 +0,0 @@
# -*- 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys
sys.path.insert(0, os.path.abspath('../..'))
# -- General configuration ----------------------------------------------------
# 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',
#'sphinx.ext.intersphinx',
'oslosphinx'
]
# autodoc generation is a bit aggressive and a nuisance when doing heavy
# text edit cycles.
# execute "export SPHINX_DEBUG=1" in your terminal to disable
# The suffix of source filenames.
source_suffix = '.rst'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'ceilometermiddleware'
copyright = u'2013, OpenStack Foundation'
# If true, '()' will be appended to :func: etc. cross-reference text.
add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
add_module_names = True
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# -- Options for HTML output --------------------------------------------------
# The theme to use for HTML and HTML Help pages. Major themes that come with
# Sphinx are currently 'default' and 'sphinxdoc'.
# html_theme_path = ["."]
# html_theme = '_theme'
# html_static_path = ['static']
# Output file base name for HTML help builder.
htmlhelp_basename = '%sdoc' % project
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass
# [howto/manual]).
latex_documents = [
('index',
'%s.tex' % project,
u'%s Documentation' % project,
u'OpenStack Foundation', 'manual'),
]
# Example configuration for intersphinx: refer to the Python standard library.
#intersphinx_mapping = {'http://docs.python.org/': None}

View File

@ -1,4 +0,0 @@
============
Contributing
============
.. include:: ../../CONTRIBUTING.rst

View File

@ -1,24 +0,0 @@
.. ceilometermiddleware documentation master file, created by
sphinx-quickstart on Tue Jul 9 22:26:36 2013.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to ceilometermiddleware's documentation!
========================================================
Contents:
.. toctree::
:maxdepth: 2
readme
installation
usage
contributing
Indices and tables
==================
* :ref:`genindex`
* :ref:`search`

View File

@ -1,12 +0,0 @@
============
Installation
============
At the command line::
$ pip install ceilometermiddleware
Or, if you have virtualenvwrapper installed::
$ mkvirtualenv ceilometermiddleware
$ pip install ceilometermiddleware

View File

@ -1 +0,0 @@
.. include:: ../../README.rst

View File

@ -1,7 +0,0 @@
========
Usage
========
To use ceilometermiddleware in a project::
import ceilometermiddleware

View File

@ -1,12 +0,0 @@
---
features:
- Introduced option to send notifications from a background thread
instead of blocking the service response to send the
notification. This option is disabled by default, retaining
previous behavior. Enable by setting ``nonblocking_notify`` to
``True`` in the middleware configuration. When enabled
notifications will be queued for delivery in a single thread.
Set ``send_queue_size`` to customize the length of this delivery
queue (default size 1000).
- Introduced option to customize the logging level using the
``log_level`` option (default WARNING).

View File

@ -1,5 +0,0 @@
---
fixes:
- Corrects retrieval of (notification) transport_url for oslo.messaging.
Issue would occur when oslo.messaging RPC and Notification backends were
separated.

View File

@ -1,279 +0,0 @@
#!/usr/bin/env python3
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import pbr.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
# documentation root, use os.path.abspath to make it absolute, like shown here.
# sys.path.insert(0, os.path.abspath('.'))
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'oslosphinx',
'reno.sphinxext',
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
# source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
author = 'Ceilometer Middleware Contributors'
category = 'Miscellaneous'
copyright = u'2016, Ceilometer Middleware Developers'
project = u'Ceilometer Middleware Release Notes'
description = 'Ceilometer Middleware publishes traffic measures for Swift.'
title = 'Ceilometer Middleware Release Notes'
target_name = 'ceilometermiddleware'
# The link to the browsable source code (for the left hand menu)
oslosphinx_cgit_link = 'https://git.openstack.org/cgit/openstack/' + \
target_name
# 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_info = pbr.version.VersionInfo(target_name)
# The full version, including alpha/beta/rc tags.
release = version_info.version_string_with_vcs()
# The short X.Y version.
version = version_info.canonical_version_string()
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
# language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
# today = ''
# Else, today_fmt is used as the format for a strftime call.
# today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = []
# The reST default role (used for this markup: `text`) to use for all
# documents.
# default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
# add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
# add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
# show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
# keep_warnings = False
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
# html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
# html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
# html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
# html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
# html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
# html_favicon = None
# 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']
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
# html_extra_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
html_last_updated_fmt = '%Y-%m-%d %H:%M'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
# html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
# html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
# html_additional_pages = {}
# If false, no module index is generated.
# html_domain_indices = True
# If false, no index is generated.
# html_use_index = True
# If true, the index is split into individual pages for each letter.
# html_split_index = False
# If true, links to the reST sources are added to the pages.
# html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
# html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
# html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
# html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
# html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = target_name + '-docs'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
# 'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, target_name + '.tex', title, author, 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
# latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
# latex_use_parts = False
# If true, show page references after internal links.
# latex_show_pagerefs = False
# If true, show URL addresses after external links.
# latex_show_urls = False
# Documents to append as an appendix to all manuals.
# latex_appendices = []
# If false, no module index is generated.
# latex_domain_indices = True
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, target_name, title, [author], 1),
]
# If true, show URL addresses after external links.
# man_show_urls = False
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, target_name, title, author, project, description, category),
]
# Documents to append as an appendix to all manuals.
# texinfo_appendices = []
# If false, no module index is generated.
# texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
# texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu.
# texinfo_no_detailmenu = False
# -- Options for Internationalization output ------------------------------
locale_dirs = ['locale/']

View File

@ -1,11 +0,0 @@
====================================
Ceilometer Middleware Release Notes
====================================
.. toctree::
:maxdepth: 1
unreleased
ocata
newton
mitaka

View File

@ -1,7 +0,0 @@
==============================
Mikata Series Release Notes
==============================
.. release-notes::
:branch: origin/stable/mitaka

View File

@ -1,7 +0,0 @@
==============================
Newton Series Release Notes
==============================
.. release-notes::
:branch: origin/stable/newton

View File

@ -1,6 +0,0 @@
===================================
Ocata Series Release Notes
===================================
.. release-notes::
:branch: origin/stable/ocata

View File

@ -1,5 +0,0 @@
==============================
Current Series Release Notes
==============================
.. release-notes::

View File

@ -1,12 +0,0 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
oslo.config>=3.9.0 # Apache-2.0
oslo.messaging>=5.2.0 # Apache-2.0
oslo.utils
pbr>=1.6 # Apache-2.0
pycadf!=2.0.0,>=1.1.0 # Apache-2.0
six>=1.9.0 # MIT
keystoneauth1>=2.18.0 # Apache-2.0
python-keystoneclient>=3.8.0 # Apache-2.0

View File

@ -1,49 +0,0 @@
[metadata]
name = ceilometermiddleware
summary = OpenStack Telemetry middleware for generating metrics
description-file =
README.rst
author = OpenStack
author-email = openstack-dev@lists.openstack.org
home-page = http://docs.openstack.org/developer/ceilometermiddleware
classifier =
Environment :: OpenStack
Intended Audience :: Information Technology
Intended Audience :: System Administrators
License :: OSI Approved :: Apache Software License
Operating System :: POSIX :: Linux
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.5
[files]
packages =
ceilometermiddleware
[entry_points]
paste.filter_factory =
swift = ceilometermiddleware.swift:filter_factory
[build_sphinx]
source-dir = doc/source
build-dir = doc/build
all_files = 1
[upload_sphinx]
upload-dir = doc/build/html
[compile_catalog]
directory = ceilometermiddleware/locale
domain = ceilometermiddleware
[update_catalog]
domain = ceilometermiddleware
output_dir = ceilometermiddleware/locale
input_file = ceilometermiddleware/locale/ceilometermiddleware.pot
[extract_messages]
keywords = _ gettext ngettext l_ lazy_gettext
mapping_file = babel.cfg
output_file = ceilometermiddleware/locale/ceilometermiddleware.pot

View File

@ -1,29 +0,0 @@
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
#
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# 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>=1.8'],
pbr=True)

View File

@ -1,13 +0,0 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
coverage>=3.6 # Apache-2.0
python-subunit>=0.0.18 # Apache-2.0/BSD
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 # BSD
oslosphinx!=3.4.0,>=2.5.0 # Apache-2.0
oslotest>=1.10.0 # Apache-2.0
testrepository>=0.0.18 # Apache-2.0/BSD
mock>=1.2 # BSD
reno>=0.1.1 # Apache-2.0
betamax>=0.7.0 # Apache-2.0

37
tox.ini
View File

@ -1,37 +0,0 @@
[tox]
minversion = 1.8
envlist = py35,py27,pypy,pep8,releasenotes
skipsdist = True
[testenv]
usedevelop = True
# NOTE(tonyb): This project has chosen to *NOT* consume upper-constraints.txt
install_command = pip install -U {opts} {packages}
setenv =
VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands = python setup.py testr --slowest --testr-args='{posargs}'
[testenv:pep8]
deps = hacking>=0.12,<0.13
commands = flake8
[testenv:venv]
commands = {posargs}
[testenv:cover]
commands = python setup.py testr --coverage --testr-args='{posargs}'
[testenv:docs]
commands = python setup.py build_sphinx
[testenv:debug]
commands = oslo_debug_helper {posargs}
[testenv:releasenotes]
commands = sphinx-build -a -E -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
[flake8]
show-source = True
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build