Commit Graph

13 Commits

Author SHA1 Message Date
Stephen Finucane 4545fdf69f tests: Resolve various warnings
These are highlighted by the new WarningsFixture.

Change-Id: If9a27784e4f4fde61dff73c1f6fde99324e1aa07
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-12-23 02:42:08 +00:00
Stephen Finucane 94257be795 pre-commit: Update dependencies
We also bump the hacking version and remove some unnecessary notes from
the top of the requirements files: these don't apply with the dependency
resolver introduced in pip 20.3.

Change-Id: Ifebaec916264bfd10eec13040295719fd47ae107
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-12-21 09:13:09 +00:00
Jay Faulkner 636df88983 Fix compatability with new oslo.messaging
A recent change to oslo.messaging to redact contexts before sending them
to a notification bus broke masakari due to the invalid default for
read_deleted. This ensures that a "None" value for read_deleted ends up
being interpreted as a 'none'.

Related-bug: #2030976
Change-Id: Ic9b895601f301c1e9ba135766493d4234fa9b50b
2023-09-08 14:06:04 -07:00
Takashi Kajinami c9d01a5327 Fix compatibility with oslo.context >= 4.0.0
The tenant argument of RequestContext is longer available since
oslo.context 4.0.0. This change removes usage of the deprecated
argument to prepare for version bump.

Change-Id: If237c6abf791526a7c20e393525e83c0a2d1a9ed
2022-03-01 17:37:02 +09:00
Ben Nemec 49754c0d7e Use oslo.context from_dict unmodified
With the change to oslo.context in the depends-on, we no longer need
to maintain an override for the from_dict function.  We only need
to provide a list of additional keys in the appropriate class member.

NOTE(yoctozepto): This also improves the relevant testing.

Depends-On: Ib143f8a5c129dbf6711800c4d87c8830a8aa3365

Co-Authored-By: Radosław Piliszek <radoslaw.piliszek@gmail.com>

Change-Id: Ia63868567d2b771620be797596ecf3c98ab5dee5
2021-03-20 13:51:18 +00:00
jacky06 6c6d168d0e [Part5]Remove six
We don't need this in a Python 3-only world.

1. this PS just remove six from context, exception, and test moulde

Depends-On: Ibfee28132e102c40d0eb5b8dc73228ec8fb9ce98
Depends-On: Ibe08ffa9072f1f0c1090f2b9e2ab9af59474d6b1
Depends-On: Ic4d00d081699015ccc2d529b872a17565c881c4e
Depends-On: I2995305abf7cb704f0fe4db9634c87ea2ed378b4
Change-Id: Id9192849a78d57ecfefe1dc20f931406884e055e
Co-Authored-By: zhoulinhui <df.some@foxmail.com>
2020-09-11 17:28:44 +00:00
shilpa.devharakar d7592cbe25 Register and Document policy in code
Adds below things for the implementation of framework for registering and
using default policy rules.
* Policy-in-code
  The framework for registering and using default policy rules.
  Rules should be defined and returned from a module in
  masakari/policies/, and then added to the list in masakari/policies/__init__.py.
  A new context.can() method has been added for policy enforcement of
  registered rules. It has the same parameters as the enforce() method
  currently being used.
* Add policy sample generation
  The entry point and config file necessary for using the
  oslo.policy sample generation script. It also adds a tox target to
  simplify the usage of it.
* Add policy documentation and sample file
  Documentation and sample file for default policy in code feature.
* Hacking check for policy registration
  It ensures that policy registration happens in the centralized
  masakari/policies/ directory.
* Hacking check for _ENFORCER.enforce()
  Hacking check in order to ensure that only registered policies
  are used for authorization checks _ENFORCER.authorize should be used rather
  than _ENFORCER.enforce.
* Add entry_point for oslo policy scripts
  There are two helper scripts in oslo.policy to help deployers understand
  their policy configuration better. With the setup.cfg entry these can be
  called directly from oslo.policy.

Changes done here are with the reference of [1] at NOVA side
which is contributed by Andrew Laski and Claudiu Belu

[1] https://review.openstack.org/#/q/topic:bp/policy-in-code+project:openstack/nova+status:merged

Change-Id: If885a66d92c31be440d27d6780635800a0b12e3e
2018-07-27 12:15:14 +05:30
Dinesh Bhor 5d34fb847e Send global_request_id to nova when calls are made
This patch adds the global_request_id to the constructor for nova
client, which will pass the global_request_id into nova services
on all API calls. Supporting global_request_id makes debugging [1]
easier when request touches many services in cloud. The masakari
request-id will be sent to nova in the request header like below and
it will be available with context.global_id:

-H "X-OpenStack-Request-ID: req-1a9b7b24-02ed-4400-bcc3-cc1bcbb59147"

Masakari is already using newer python-novacliant which supports
global_request_id [2].

This patch also fixes the below debug log message which gets emitted
when any argument gets dropped while creating request context:

"Arguments dropped when creating context: {u'global_request_id': None}"

As decided earlier while fixing the issue [3] this patch adds the
'global_request_id' to the base RequestContext hence removes the
earlier debug log message.

[1] I65de8261746b25d45e105394f4eeb95b9cb3bd42
[2] I5b247f75edeea9da50fe524eadf5f9a2c626d665
[3] d4dd11d7bd

Change-Id: I2139976f6774b10518c7455a9af1b32b1e7b3e7d
2017-07-27 09:53:25 +05:30
Dinesh Bhor d69cea4975 Remove unused methods
Removed following methods as these methods are not called from anywhere
in the entire code:

 * is_user_context
 * require_admin_context
 * require_context
 * authorize_project_context
 * authorize_user_context

'is_user_context' method [1] was getting used to check whether the
requested context is of normal user or not. Masakari doesn't allow
normal user to call any API so the code was unreachable. Moreover
masakari don't have any sqlalchemy model having 'project_id' as it's
attribute. So it is safe to remove this code.

[1] https://github.com/openstack/masakari/blob/master/masakari/db/sqlalchemy/api.py#L131-L136

Change-Id: I60f68cbdd80dbce9d3ea95441cf1926ebec1cc8c
2017-07-19 04:50:15 +00:00
Dinesh Bhor d4dd11d7bd Stop logging unnecessary warning on context create
Every time a message is dispatched over rpc, it serializes the context
using to_dict() method which includes "is_admin_project" key in the
serialized context which when deserialized on the receiving end calls
"from_dict" class method to build RequestContext object based on the
dictionary. At the time of creation of this RequestContext object, a
warning message is logged "Arguments dropped when creating context".

Passed "is_admin_project" to __init__() of base RequestContext class so
that the warning message will not come. Also this log message should be
logged in debug level instead of warning as it's meant for developers and
not operators. Developers can choose to see what arguments are getting
dropped so that if required later it can be passed to base RequestContext.
Kept the default value of "is_admin_project" as True [1].

[1] https://github.com/openstack/oslo.context/blob/master/oslo_context/context.py#L196

TrivialFix

Change-Id: Ie301908fd037d08998d85c46f9da567a9448fdd2
2017-01-27 11:35:01 +05:30
dineshbhor 484da30293 Add nova support in masakari
This patch allows masakari to communicate with nova using
novaclient.

Change-Id: Ia7a2c8e91811500301d5cc44dfebc9f7ca2026e9
2016-11-04 15:39:21 +05:30
Nguyen Hung Phuong 9038e8aeef TrivialFix: Merge imports in code
This patch merges all lines importing i18n into 1 line:

http://docs.openstack.org/developer/hacking/#imports

Change-Id: I6575624ae1c75ec27c9d9029c0b42fb9ae2a550b
2016-09-15 08:59:46 +07:00
Abhishek Kekane d4f055262e Add support for wsgi framework
Added wsgi framework support to create masakari-api
service using oslo_service framework. Similar to core
openstack projects, config items will be kept at centralized
location.

Refer README.rst to cofigure and run masakari-api service.

Change-Id: Idb0120b8cf3b10642c51b286d82cd0944cad5ca3
2016-07-12 13:10:10 +05:30