Follow-up on [1]:
We don't need an HTTP client for this, we only
need status codes. Just load that instead.
[1] https://review.opendev.org/762308
Change-Id: Ib24be88c9f33889d5ed705537b0d4c167cad5b3f
Adds two new cases: one valid, one invalid.
Ensures the tests check whether creation happens or not.
Change-Id: Ia2cb0c56d5871b573c214909bffe0c2f676765e5
Also deletes an unused helper function.
All other occurences use the method defined on the VersionedObject.
Change-Id: If4964dfdad67b794a24ef7b4dbae0a82119adb1d
This patch allows user to pass a multiline description for
a failover segment.
Closes-Bug: #1776385
Change-Id: I25afb76aec10a507312b8d99b0c882ca9f6bcd81
The repo is Python 3 now, so update hacking to version 3.0 which
supports Python 3.
Fix problems found by updated hacking version.
Update local hacking checks to work with current flake8.
Remove hacking and friends from lower-constraints, they are not needed
there.
Change-Id: I89695a03791c2de36ab015b3831c85887b27f3b8
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: Ia6927351f591be0c57fd73515b2542a0af35f82b
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
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
Masakari should use ostestr instead of testr. ostestr is more
powerful and provide much prettier output than testr. Other
projects like cinder, nova, glance, neutron etc already uses
the ostestr wrapper.
Using ostestr shows each tests execution separately because of
which it has shown errors related to "KeyError" in existing test
cases. The error looks like below:
"Exception in string format operation: KeyError: u'id'"
This happens if we don't pass keyword argument like "id" to
exception which we expect to be raised from test through
side_effect [1]. This doesn't lead to test failure but it
appears in test logs. This patch fixes such issues by passing
expected keyword arguments to exceptions.
[1] https://github.com/openstack/masakari/blob/master/masakari/tests/unit/api/openstack/ha/test_hosts.py#L364
Change-Id: I91603ea3dcf35fd20a00dcf477b93d612edca362
DDT can ease up error tracing and auto generates tests on
basis of different input data.
Reduce test code data by using DDT for segments, hosts, and
notifications.
Co-author: Dinesh Bhor <dinesh.bhor@nttdata.com>
Change-Id: Ie3ce3316c6e2fc3f98df3a51db59ca7f1f1625b8
There are several places in the source code where HTTP response
codes are used as numeric values.
All of the used status codes are replaced with symbolic constants
from six.moves.http_client to improve code readibility.
Closes-Bug: #1520159
Change-Id: Ic5e439fb1f33962979536fe1ac5e5320e2c50c40
Host and failover segments list apis return 500 InternalServerError if
you pass invalid sort_key or sort_dir.
Caught exception.InvalidSortKey at controller level and also allowed
multiple sort_keys and sort_dirs to pass.
NOTE:
Allowed to pass multiple sort keys to list apis.
Also moved the processing of request parameters from masakari/ha/api.py
to respective failover segments and hosts controllers as request parameters
should be handled in controller itself.
Closes-Bug: #1630530
Change-Id: Ib9d0faf5ca737a020099d5bac2b2ca0b03aa353e
This patch will allow masakari operators to hit following apis:
1] GET /v1/segments
2] GET /v1/segments/<segment_uuid>
3] POST /v1/segments
4] PUT /v1/segments/<segment_uuid>
5] DELETE /v1/segments/<segment_uuid>
Change-Id: I63b48bfa70db7bfacec1c8431fe48feb7aa4c7ef