Commit Graph

90 Commits

Author SHA1 Message Date
Martin Chacon Piza 91022f3e80 Remove project content on master branch
This is step 2b of repository deprecation process as described in [1].

[1] https://docs.openstack.org/project-team-guide/repository.html#step-2b-remove-project-content

Change-Id: Ie446c1cd447789d189a9e723fff9ee783dd3cf4f
2021-02-22 14:57:15 +01:00
Hervé Beraud f73bff83cb Use unittest.mock instead of mock
The mock third party library was needed for mock support in py2
runtimes. Since we now only support py36 and later, we can use the
standard lib unittest.mock module instead.

Change-Id: I781b979d11c3b974701ae38574899e6160fdc6bb
2020-06-15 15:32:36 +02:00
Sean McGinnis b3e4ac9554 Use unittest.mock instead of third party mock
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: I9f7227ec5ed4d84efd36d87fec7f0536276fc151
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-05-28 12:33:21 +02:00
Andreas Jaeger 08739b0377 Update hacking for Python3
The repo is Python 3 now, so update hacking to version 3.0 which
supports Python 3.

Fix problems found by updated hacking version.

Remove hacking and friends from lower-constraints, they are not needed
there.

Change-Id: I7614df314c211dc3acca2e3e8cb647bddddd6c16
2020-05-26 20:18:43 +00:00
Witek Bedyk 4eccad156f Deprecate monasca-log-api
Change-Id: I2437729bd1840b7943b0883574344404827a50ea
Story: 2003881
Task: 38493
2020-05-22 10:27:17 +00:00
Martin Chacon Piza bf5a1a7adc Migrate from ujson to simplejson
The change updates the imports to use simplejson instead of ujson and
monasca_log_api.common.rest instead of monasca_common.rest

Temporarily set monascalog-python3-tempest as voting false

This is an alternative to this change
https://review.opendev.org/#/c/724658/

Change-Id: Iae94376b38cae8a1eb8aa6a704fc2ca5d383adaf
Story: 2007549
Task: 39601
2020-05-12 11:53:33 +02:00
Bharat Kunwar 2f2593fcce Return valid url when querying versions endpoint
Use rpartition instead of replace to do a more targeted stripping of
path to render a correct base_uri.

Change-Id: Idc2a5a6bd0e9e2675883f2188d4856b01ba5fdb8
Story: 2006147
Task: 35643
2019-07-25 14:42:40 +01:00
Adrian Czarnecki 29e25e6e29 Add support for using Falcon 2.0.0
Falcon 2.0.0 introduces some breaking changes. The relevant ones here are:

- falcon.testing.TestCase.api property was removed
- falcon.testing.TestBase class was removed
- falcon.HTTPRequestEntityTooLarge exception was renamed to
 falcon.HTTPPayloadTooLarge

Additionally, the default behaviour for handling trailing slashes on
URIs also changed:

https://falcon.readthedocs.io/en/latest/user/faq.html#how-does-falcon-
handle-a-trailing-slash-in-the-request-path

This commit adds support for using the new release.

Story: 2005695
Task: 33474

Change-Id: I2379522efef81b919098a0143b66cc259a184e70
2019-06-10 13:45:57 +02:00
Thomas Bechtold d8f53e80c8 Replace log-api.conf with monasca-log-api.conf
log-api.conf is the deprecated path for the configuration file. The
new path is /etc/monasca/monasca-log-api.conf .

Change-Id: Ib58d926c1551a6eade66127b7d05a16a311f87f0
Story: 2004831
Task: 29023
2019-01-22 07:06:14 +01:00
Witold Bedyk 2f94dda6ad Use oslo_utils.encodeutils.safe_encode
Change-Id: I47e3a31c7415916450455df758238e473534e735
Story: 2000975
Task: 27002
2018-10-09 11:56:50 +02:00
Dobroslaw Zybort 3ed5838fc1 Py3: Fix encoding in _verify_topics method
Change-Id: I0f75ca4505acfd7840cde7d76174bd8a32354880
2018-09-25 08:28:47 +00:00
Adrian Czarnecki 08c8709b4f Fix policy check for healthcheck and version
Change-Id: I436b7ade5ff6f890eab56439a8b2219421518ce0
2018-09-21 14:51:22 +02:00
Witold Bedyk 7d40e5d5c2 Fix default policy rules registration
The constants used for configuring default policy rules were initialized
before configuration file was parsed. As the result the configuration
options in 'roles_middleware' group didn't have effect on registered
policy rules. The behavior can be reproduced in devstack plugin where
monasca-log-agent using 'monasca-agent' role is not authorized to send
logs to the API.

The change postpones the initilization of these constants. Additionally
obsolete 'roles' filter was removed from the paste pipelines.

Change-Id: I0ca38f2cc7d63b9b47eedb304ba7b00a94816f9a
Story: 2001233
Task: 24250
2018-08-03 10:29:06 +02:00
Zuul 8b6582d8d4 Merge "Using oslo.policy for monasca-log-api" 2018-07-31 14:03:04 +00:00
Amir Mofakhar 5729d7e7c8 Using oslo.policy for monasca-log-api
Added policies and used policy enforcement engine
from monasca-common.

- Updated role_middleware to remove authorization into the routes.
- Updated unit tests and implemented some new tests.
- Added a new entry point for generating sample policy file by tox.

story: 2001233
task: 22086

Change-Id: I3d199fac244eca94fc434d19c78bc5a17e804c37
Signed-off-by: Amir Mofakhar <amofakhar@op5.com>
2018-07-19 09:55:54 +02:00
Lukasz Zajaczkowski 4229bc901c Change statsd_host config type
Change oslo config to support valid IP addresses and valid
host domain names for statsd host.

Change-Id: I4f9a136f2183be8adfd1456e0e65da17e461cf56
Story: 2002596
Task: 22207
2018-06-19 13:11:02 +02:00
Doug Hellmann 0153a20201 replace use of 'unicode' builtin
The builtin type 'unicode' does not exist under python 3. The runtime
check here is already looking at the python version, but the linter
does not perform the same check and it fails because the name is not
defined. Replace the explicit use of unicode here with six.text_type
so that the linter is happy.

Change-Id: I22a13fddaed1338c0f3e670d199bb6aa5f99bbf7
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2018-06-06 17:30:58 -04:00
Adrian Czarnecki 20e63fb5b5 Set a default value for a default_roles
Story: 2001895
Task: 14418
Change-Id: Ia1c6b23a38e1b32ba2d5f37dc674275bea810a3a
2018-05-08 12:31:02 +02:00
Adrian Czarnecki 875127d283 Fix tempest test
Improve exception handling this
fix ..if_body_is_empty test

Start using temestest from
monasca-tempest-plugin repository

Story: 2001400
Task: 12524

Depends-On: Ib3ff312fdf2a1d9d22f156ff27e6e1b6c7adcb88
Change-Id: I85f36dbadef1f385907deb5672b1f75bf7f005ec
2018-04-09 10:06:55 +00:00
Adrian Czarnecki ddb16f626f Allow to disable statsd self-moniotring
Change-Id: I443a4e13b5967c7c00d81658536cefad749e4bfe
story: 2001472 
task: 6192
2018-01-16 08:13:23 +00:00
Johannes Grassler 257fb55635 Fix WSGI application
* Partial revert of 0a82af18ab
  to restore main() method
* Add global `application` variable which will be set by main method to
  problem to preserve the fix from 0a82af18ab.
* Add check for application name starting with '_mod_wsgi' to ensure
  application runs in Devstack as well (Devstack does not use the entry point)
* Modify Devstack plugin to run WSGI entry point rather than app/wsgi.py from
  module directory.

Change-Id: I07001dccb663ed4e6e3347089ab96e6f8ec196d4
Story: 2001197
Task: 5702
2017-10-18 10:03:29 +00:00
Tomasz Trębski f55f34c9c4 Refactor project tree
Old project tree had everything mixed up
in different locations. Not to mention
that actual REST controllers resided in
package that's name did not reflect the content.

Reorganized the tree to be more predictable
and easier to maintain.

Change-Id: Ic9acc80a4cf7416394702d43141c96953c03beea
2017-07-27 22:02:48 +00:00
Tomasz Trębski 138ac174c4 Allow to specify CLI arguments
Passing any CLI arguments to log-api is not possible
for the case where it runs under gunicorn server.
Gunicorn's argument parsing processes clashes with oslo's.
Effectivelly that means that either of them cannot understand
the arguments of another. However log-api is capable of being launched
under, for example, apache_mod-wsgi.
That permits passing oslo CLI arguments.

Added simple method that detect the executable that was used to run
log-api. If that is not gunicorn, CLI opts will be enabled.
Otherwise log-api will print out warning and proceed as it was.

Extra:
* reworked to use fixtures

Change-Id: I6b2fc386aeb823ab735270ffc1d3f7e15985830f
2017-07-27 07:34:02 +02:00
Thomas Bechtold d243ed35d0 Use oslo-config-generator
It is common for OpenStack projects to use oslo-config-generator to generate
a sample config file which contains all available configuration options.

Work items:

* removed etc/monasca/log-api.conf (it is autogenerated)
* keep all config in one place to mimic the configuration file
* added configuration files to documentation

Story: 2000970
Task: 4121

Change-Id: I8777ed6cd38739e87b19be248b9c120e84626ad1
2017-07-05 09:44:35 +00:00
Tomasz Trębski 29126ba9f8 Migrate documentation to Sphinx
Migration of Openstack Project is held in
*.rst files and build with Sphinx.

Following change provides:
* technical documention
* api guide
* api ref
* releasenotes

Note:
    For now, generating codebase documentation is disabled.
    It caused gate failures because of, yet unnown, reasons.
    In order to pull this foundation, this part is skipped.

Extra:
* provided venvs descriptions to let user know what is the scope

Story: 2001058
Task: 4665

Change-Id: Ieb2b58e165de1617748d97d997af368bd91d5c0e
2017-07-03 07:38:53 +00:00
wachowskij 0a82af18ab Fix WSGI startup script
Currently mod_wsgi returns the following error:
Target WSGI script '/var/www/monasca-log-api/monasca_log_api'
does not contain WSGI application 'application'.

Also fix a type in README.

Change-Id: Ic70c3ddb8aaa076c09fc2434f6e890be24b599d5
2017-06-29 14:33:36 +02:00
Tomasz Trębski 21493ac9cf Ensure and verify utf-8 support
Added proper handling of unicode messages by expiclit
usage of unicode and utf-8 encoding for Python2.
For Python3 it was just sufficient to ensure that message
is properly UTF-8 encoded. Results of that change can be examined
inside Kibana (or using link [2]).

To prevent any regression, a set of unicode messages has been
added. It contains:

* 'Unicode is evil...' sentence translated to several languages
* border conditions of UnicodeStressTest [1]
* some funnier examples just because programming is fun

Extra:
* unified setting up API test case

[1]: http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
[2]: https://pasteboard.co/x9gQqicR.png

Story: 2001084
Task: 4734

Change-Id: I36e3c2f1ea5788ecb19089089d84924b7d6666bf
2017-06-23 09:54:04 +02:00
Artur Basiak 35e67f300a Mock monascastatsd in tests
Add mixin class to mock monascastatsd to avoid error about connection
to the daemons. Add new 2 classes which inherits from mixin class
and oslotest, falcon depending on the test.

Change-Id: Ib44357d9355400f603f76bf2a99fc89c05eae831
2017-06-22 08:56:02 +02:00
Witold Bedyk 9bb918197e Fix cross-tenant logs submission
* add 'delegate_roles' configuration option

Change-Id: If4952b84536ef058d91f6ee2332076dc448d97bd
2017-06-03 14:19:52 +02:00
Tomasz Trębski 5e7ebdd9c5 Composite paste for monasca-log-api
Following commit introduces using composite
paste file to describe application pipelines.
With the help of composite feature it was possible to
define 4 distinct supapplications, each having different
pipeline setup:

* version_app => no keystoneauth, simple data return with error trap
* healthcheck_app => no keystoneauth, simple data return with error trap
* api_v2 => as it was, added error_trap though
* api_v3 => as it was, added error_trap though

Following approach opens up the possibilities of modelling an API
in far more flexible way and removes the need of any hacking inside
the codebase.

Note:
Keeps backward compatibility with older codebase.

Extra:
* removed dirty hack around skipping certain request.path
in keystonemiddleware (now described in paste file)
* removed 404 when issuing ```curl api_host:api_port/```. Request
is redirected down to VersionApp

Depends-On: I0323eacb5cbba8418550e3322189104c35cf4c36
Change-Id: I873e1376665c8cf66c8ee503975324f9b93ddb45
2017-06-02 14:20:43 +00:00
Jenkins ad3f4db620 Merge "Replace six.iteritems() with .items()" 2017-04-05 05:53:46 +00:00
rajat29 c8e70e35d6 Replace six.iteritems() with .items()
We should avoid using six.iteritems to achieve
iterators. We can use dict.items instead, as it will return iterators
in PY3 as well. And dict.items/keys will more readable.

Change-Id: I974a9e5001266aab878bf77af001d1ba61d761e2
2017-04-04 15:07:34 +05:30
Thomas Bechtold 97de1896d0 Remove monasca_log_api/.gitignore
There is already a .gitignore in the root directory.

Change-Id: Ice2a83ef8dd08b5fe07652b2298120ad59c58186
2017-04-03 09:48:02 +02:00
Steve Simpson 631439408e Internal interfaces for log listing API implementation
Initial groundwork for the implementation of the log listing API.
This comprises interface extensions to the HTTP API, and the beginnings
of a repository model in keeping with the design of the monasca-api.

Change-Id: I5bc641b01f260c3e4e062ff8a2b4014cbe807f3c
Partially-Implements: blueprint log-query-api
Story: 2000934
Task: 4058
2017-03-24 11:19:01 +00:00
Tomasz Trębski 4ae270263d Adding WSGI support
Following commits adds possiblity to run monasca-log-api
with Apache2 (mod_wsgi) in devstack environment.

Change-Id: I4aca9bebacb4799a0e45b785ba1997003c6b7165
2017-02-22 19:14:00 +00:00
OpenStack Proposal Bot aa069b76e4 Updated from global requirements
Change-Id: I48cf071134606eabc0e412d12a94f4f2e47b8c0b
2017-01-26 08:02:03 +01:00
Tomasz Trębski 35a6314182 Make monasca-log-api work with Python 3.5
Following commits ensures that monasca-log-api
is Python 3.5 compatible.

Change-Id: If4ab448756dbc533a5c12e35415b9989db96c47d
2017-01-18 13:41:29 +01:00
Jenkins 19476cf330 Merge "Drop Java Implemention codebase" 2017-01-09 09:15:24 +00:00
Tomasz Trębski f00e8c9012 Integration with oslo.context
Similar to other openstack projects,
monasca-log-api should provide information
about request's context in the log information.

This is done by:
* implementing custom Request that creates context (oslo.context)
* changing logging configuration to use ContextLogFormatter

Additionally, since information like tenant-id can be
retrieved from the context, modified resource code to use
that.

Change-Id: I992a2f4de64b54a705cc2bafdb3e83de0b1691c7
2017-01-09 05:36:03 +00:00
Tomasz Trębski 062c929c8c Drop Java Implemention codebase
Following commits drops Java implementation of monasca-log-api,
which is no longer maintained and at given point contains
no feature that Python implemention has.

Depends-On: I892aad540a63db822e416c13f298270b33cc5f53
Change-Id: Id7b2c27136ab91fe9126585bde1bb6f0540549b8
2017-01-04 10:57:55 +01:00
Witold Bedyk 68fe277cba Add test for empty log message
Change-Id: I190c8d825d270d559eeee5fa9b17442a1107ac80
2016-12-21 16:51:33 +01:00
wachowskij 0e62eaca25 Fix tempest tests
* sending 'None' as a request body implies header
'Content-Length: 0', but the test was expecting
no header.
* invalid parameters were passed to call_until_true

Depends-On: Icce74fd6d7e674f408277e328468bedbc3d0aa6b
Change-Id: Ia4fc7cdec0a38d0b46aadfedd6cc9919edaa1963
2016-12-20 14:55:29 +01:00
gecong1973 6ed3757404 Replace LOG.warn with LOG.warning
logging.warn is deprecated in Python 3.[1]
[1] https://docs.python.org/3/library/logging.html#logging.warning

Change-Id: I0804f1dad51007e969c48c8cd4a338d002391f9e
2016-11-17 03:42:16 +00:00
Jenkins 9e94abfaa9 Merge "Change assertTrue(isinstance()) by optimal assert" 2016-11-07 18:41:47 +00:00
gecong1973 c008f8884f Change assertTrue(isinstance()) by optimal assert
Some of tests use different method of assertTrue(isinstance(A, B))
or assertEqual(type(A), B). The correct way is to use assertIsInstance(A, B)
provided by testtools

Change-Id: Ia94ff8a08d298e5e90bfdefca00a9ff0efa31053
2016-10-16 09:09:17 +08:00
Luong Anh Tuan e30e8effa1 Remove xrange for run both Python 2 and Python 3
In python 3, range() does what xrange() used to do and xrange() does not
exist. If you want to write code that will run on both Python 2 and
Python 3, you can't use xrange().

range() can actually be faster in some cases - eg. if iterating over the
same sequence multiple times. xrange() has to reconstruct the integer
object every time, but range() will have real integer objects.
(It will always perform worse in terms of memory however)

xrange() isn't usable in all cases where a real list is needed.
For instance, it doesn't support slices, or any list methods.

Change-Id: Ibe90272e96eea042f78038ec1029a5ca8e8669d8
2016-10-12 11:51:06 +07:00
Jenkins 9d90be760e Merge "TrivialFix: Remove logging import unused" 2016-09-15 08:47:56 +00:00
Jenkins 0f08c9f8ff Merge "Enable size-based log rotation for monasca-log-api" 2016-09-14 11:05:42 +00:00
wachowskij feb6897cbe Enable size-based log rotation for monasca-log-api
By default log file is rotated after reaching size of 100MB and 5 files
are archived.

Closes-Bug: 1621329
Related Change-Id: Iac7f29b3909354f75e5d3264ef2c987c9f3e2aec
Change-Id: I8d7e071e899eca1247b2db56ea348bb8775d68c3
2016-09-14 08:59:07 +02:00
Cao Xuan Hoang 58e8bbec36 TrivialFix: Remove logging import unused
This patch removes logging import unused in
monasca_log_api/reference/versions.py

Change-Id: If372601d598478f473c543bd197e4db75ea262a2
2016-09-07 17:03:14 +07:00