Commit Graph

115 Commits

Author SHA1 Message Date
Dale Smith 6b1856b4eb Support tox4, update style to match Black 23.1a1
This aligns code with https://github.com/psf/black/pull/3302

Depends-On: https://review.opendev.org/866943
Change-Id: Icfbca2fab8adeb677b980d01f797f194f580838e
2023-01-04 17:06:31 +13:00
Dale Smith 8ae383f9fe Fix gates for Antelope and update Django
* Zuul deprecated (and now removed) declaring shared queues at a pipeline
  level [1]. This patch fixes the syntax to make the gate work for
  adjutant.
* Updates Django version to allow upper-constraints version
* Fix Django 3.2 warnings
* Fix flake8 errors
* Remove support for Python 3.6, Python 3.7

[1] https://lists.openstack.org/pipermail/openstack-discuss/2022-May/028603.html

Change-Id: Ic369b59bb062df867d78b006f06e48cf9c98a3ee
2022-12-07 19:52:27 +13:00
Zuul b305d7285f Merge "Fix some issues with updating user email defaults" 2021-10-26 06:52:13 +00:00
Adrian Turjak ec6c2c6d1d Fix some issues with updating user email defaults
Change-Id: I8d33f0b0f13eba64569a17836bb2ca5ffb9f1c93
2021-10-26 16:10:58 +13:00
Adrian Turjak ab7f8115d4 Fix an issue with Adjutant's Invite process not checking inherited roles
Adjutant's InviteUser action was not correctly checking inherited roles
which might allow someone to invite/create another user with roles outside
of those they inviting user can manage.

Change-Id: I1f45da4ce5ee6d1295a17767c432875c23106b15
Story: #2009326
2021-10-26 15:34:14 +13:00
Adrian Turjak bee1e42c9f Fix notification overlay not working correctly
Change-Id: If1b1421a6a9ebe054824076416f6fbc87160bc2a
2021-09-30 20:55:02 +13:00
Adrian Turjak 97880c9364 Change wrong template/subject default for quota update emails
Change-Id: I562454fc5bae4ec3d3201d22fe935cbf727cbf10
2021-09-23 21:21:57 +12:00
Jonathan Herlin 7aa1fc69c3 Change default volume API to v3
Volumes v2 API was deprecated in pike and v3(.0)
 is identical to v2 API.
v3 was introduced in Mitaka

Change-Id: I38613145ae4234956f36184eb62feb8e95647113
2021-08-30 11:02:51 +02:00
Adrian Turjak d9045e4b10 Update formatting because of black version
Change-Id: If43c4256e1b452fc160750f492d2d6fdcb44d389
2021-06-01 14:24:00 +12:00
Adrian Turjak d703a634a4 Fix a bug with feature set config not being added as expected
The feature set config group was entirely missed from the config
tree, and the group itself wasn't setup for lazy_loading despite
needing to be based on when it is meant to have config added to it.

Change-Id: Ia9569ebb76ffe91d592dbc94bc528bde4aa00fc4
2021-02-26 13:37:48 +13:00
Adrian Turjak 1795ac71c3 Fix an issue when username_is_email=False for Quotas
The email function was incorrectly trying to get the user email
when sending out a quota update email. This has been fixed, and
a test added to confirm.

Change-Id: Id76af3ff50f752764a0ea25281443104d44adeb1
2021-02-16 12:15:29 +13:00
Zuul e940fd4925 Merge "Add service helper for trove quota management" 2021-01-22 02:03:46 +00:00
Simon Merrick 45160d3378 Add service helper for trove quota management
Change-Id: Ib09692b1451f1493394af755cbcd14cc96a36b02
2021-01-22 13:39:38 +13:00
Uriel Medina 84270add34 Make identity interface configurable
Keystone middleware sets the default identity interface as "internal".
This was causing issues with DevStack where "internal" endpoints
weren't being created.

We added a new config for interface, and have it default to 'public'.

Task: 41593
Story: 2008515
Change-Id: Ib8e546d5fbfbcb561e5b139893605d05c1a8ad62
2021-01-21 00:33:55 +00:00
Kevin Masterson d2fbd63fdb Fixed typos in nova and neutron quota output
The Nova and Neutron quota helper objects output the quota data with
the word 'secuirty' instead of 'security' in the key name. Adjutant-ui,
nova and neutron (among others) look for the keys with the correct
spelling. No other instance of the typo appears to exist in other
modules.

APIImpact: some keys returned by Adjutant are now correctly spelled
Change-Id: Idf2953027765119d70720592ccc1187472854fad
2021-01-12 08:11:08 -05:00
Adrian Turjak 43e0c625e3 Allow authenticated token requirement for tasks
Tasks when defined can now set if they require the user submitting
a token to be authenticated.

keystone_user is now passed to actions when a token
is submitted. This requires all actions to update their submit
function, but a suitable fallthrough will exist for a cycle to
allow time.

Also fixes a minor issue around where error handling for
renamed or deprecated tasks is handled that cropped up
while testing this patch.

Change-Id: I4b51201872cb5a14f299f90e22a8b010d11a71cb
2020-09-17 13:01:12 +12:00
Adrian Turjak b35fdcc6ab Reformat with updated version of black formatter
Change-Id: I74aea5668c3027cff4d2f3ecb6de456e60bb6129
2020-09-17 12:56:00 +12:00
Adrian Turjak 9dd1f3a302 Update CONFspirator with example and toml support
Example config generation now is in CONFspirator so we can instead
use that.

We now also natively get toml support through the new version of the
library.

Change-Id: Ic3a46d075dd83e11ee3cccc1ad2bbdb81005c60d
2020-08-07 20:28:24 +12:00
Hervé Beraud de347e316d Stop to use the __future__ module.
The __future__ module [1] was used in this context to ensure compatibility
between python 2 and python 3.

We previously dropped the support of python 2.7 [2] and now we only support
python 3 so we don't need to continue to use this module and the imports
listed below.

Imports commonly used and their related PEPs:
- `division` is related to PEP 238 [3]
- `print_function` is related to PEP 3105 [4]
- `unicode_literals` is related to PEP 3112 [5]
- `with_statement` is related to PEP 343 [6]
- `absolute_import` is related to PEP 328 [7]

[1] https://docs.python.org/3/library/__future__.html
[2] https://governance.openstack.org/tc/goals/selected/ussuri/drop-py27.html
[3] https://www.python.org/dev/peps/pep-0238
[4] https://www.python.org/dev/peps/pep-3105
[5] https://www.python.org/dev/peps/pep-3112
[6] https://www.python.org/dev/peps/pep-0343
[7] https://www.python.org/dev/peps/pep-0328

Change-Id: Ie859ac36b1dcc4bc08e43eef3d6ed4399033f9f4
2020-06-02 19:31:59 +02:00
Adrian Turjak f61f6f25fa Fix migration ordering issue
The task model rework has some migration ordering issues,
this fixes that and ensures action migrations don't
continue until other steps are done.

Change-Id: I3c3669a12e5d5d6b11fdf0e49b14894468287b6a
2020-05-06 11:27:31 +12:00
Sean McGinnis 4b08096d23
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: Ida2ec7793c3863836e1c626eb72e0aa9f48b6810
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-03-24 07:47:24 -05:00
Adrian Turjak 2c62daf542 Reformat code using the Black style linter
Change-Id: I55cf016fe073e92fe4466f38b95ebdcd9ec58e84
2020-02-21 14:43:31 +13:00
Adrian Turjak 592e24170e Use Django's SECURE_PROXY_SSL_HEADER and add config
When behind a proxy like HAProxy, we need a way to have
Django correctly know if the incoming request was actually
coming via HTTPS so when Adjutant returns generated URLs
of itself, it can correctly mark them as HTTPS.

This fixes and issue with the version URLs not being returned
as HTTPS when they should be.

Change-Id: I9824eadb9927a5d44f11c381fbe2b1576ffb66c0
2020-02-21 11:53:19 +13:00
Adrian Turjak 994e844044 Add extra notes to EditUserRolesAction
Add an extra note which explains why the action
is invalid if not all roles are manageable, as
otherwise it is unclear why the action was invalid.

Change-Id: I4bc368cf16fca50135977b22c8a96aacd9740890
2020-02-19 15:21:22 +13:00
Adrian Turjak ad81fdf706 Update to Django 2.2, drop py2 support
OpenStack is dropping the py2.7 support in Ussuri cycle.

Adjutant is also upgrading to Django 2.2 at the same time
which is the new Django LTS, and only supports python 3.

Complete discussion & schedule can be found in
-
http://lists.openstack.org/pipermail/openstack-discuss/2019-October/010142.html
- https://etherpad.openstack.org/p/drop-python2-support

Ussuri Communtiy-wide goal:
https://governance.openstack.org/tc/goals/selected/ussuri/drop-py27.html

Ussuri Communtiy-wide goal:
https://governance.openstack.org/tc/goals/selected/ussuri/drop-py27.html

Change-Id: I2a429ebd6bc20385e814da03b222a1f61214a683
2020-02-14 10:42:27 +13:00
Adrian Turjak 0eaac89b38 Refactor the plugin layer to use entrypoints
Introduce the concept of a feature set, which can be
registered to an entrypoint.

Rework all existing core elements into a 'core' feature
set.

Remove the ability to add in random django apps, and drop
the ablity for plugins to optionally be able to great
new DB models.

Change-Id: Idc5c3bf3facc44bb615fa4006d417d6f48a16ddc
2020-02-05 19:07:54 +13:00
Adrian Turjak c750fd6d6c Rework Adjutant's config system to use CONFspirator
CONFspirator was written to just specifically for Adjutant
and it allows us to do oslo.config style config management
and definition with nested groups and for yaml.

This is a major change that touches vast amounts of the
code simply because of how much the config touches.

Actions, Tasks, DelegateAPIs, and Notification Handlers
now can define config in their own class and this will
be added to the config.

All the other config is located in `adjutant.config`,
with everything now registed nicely on the config tree,
and grouped in much saner ways.

CONFspirator will also now allow Adjutant to be entirely
configured via environment variables.

We have removed `modify_dict_settings` because that is
now entirely handled by CONFspirator's test utils.

`NotificationEngine`s are now `NotificationHandler`s.

`test_settings.py` is gone! And we now have better ways
to define test settings and defaults.

Project line length bumped to 88, and bugbear added to enforce
that instead.

Story: 2004488

Change-Id: I1d97d72d06b3a3a5df90355d3a4b4fe414381424
2020-02-05 19:07:04 +13:00
Adrian Turjak c9038dfe69 Major refactor of the Adjutant task layer
This patch splits out the Task layer and the API
layer. This will better allow us to build more logic
into the task layer, and better allow the APIs to be
more flexible.

This sets the foundations for future additions to task
definitions, async task processing, and an overhaul of
the config system for the service.

- Task model and logic moved to 'tasks' app
- TaskViews are now DelegateAPIs
- stage email templates have been moved to the tasks app
- better define Task model indexes
- rename task/action stage pre_approve to prepare
- rename task/action stage post_approve to approve
- Added new TaskManager class for handling tasks
- Removed redundant ip_address value on Task model
- Remove redundant UserSetPassword view
- Added custom exception handling for the API
- Add new exception types
- Simplified error responses by raising exceptions
- standardized task API response codes on 202 unless
  task is completed
- Use 503 Service Unavailable for service issues
- Various task_types changed:
    - create_project to create_project_and_user
    - invite_user to invite_user_to_project
    - reset_password to reset_user_password
    - edit_user to edit_user_roles
    - update_email to update_user_email
- reissuing task token now deletes old task tokens

Story: 2004489

Change-Id: I33381c1c65b28b69f6ffeb3d73b50be95ee30ba7
2019-12-04 14:24:57 +13:00
Adrian Turjak d62eada126 fix issue with iteritems still used in one place
Change-Id: If4f2ef018b6a9c5542c38e8b5722e561f4669bc1
2019-12-04 13:12:27 +13:00
Adrian Turjak 090e0af734 Fix old py2 default value for action model
This just gets rid of the byte part from:
default=b'default'
which exists in the initial migration file

Change-Id: I99c1625f27c4cf75cb8dedce6fdb46e70bb9c2ef
2019-06-26 13:03:19 +12:00
Simon Merrick 472f3c60c4 Convert setup to use pbr
Remove redundant Manifest file
Move configuration to setup.cfg
Upadate atuhor and contact informaion
Change python 3.5 classifier to python 3.6
Grab package version programtically from pbr
gitignore venv and vscode directories.

Change-Id: Iff11f5ca9ddc40e98849c384441db73e5b034ac7
2019-05-17 11:56:30 +12:00
Zuul 820bbed9cc Merge "Fix yaml.load(input) deprecation" 2019-04-02 21:11:21 +00:00
Kristi Nikolla e64b636f74 Fix yaml.load(input) deprecation
Calling yaml.load without specifying a Loader is unsafe [0].

[0]. https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation

Change-Id: I8567a7a56e28ad89d5a70482312df1e80200ea2c
2019-04-02 13:31:14 -04:00
Adrian Turjak 764399bc14 better handle empty notification confs
In some cases we do want to disable notifications a little more
selectively, but we should also log that we've done that in case
someone does so by accident and needs to debug.

Change-Id: I68dbf16002b9105df280261ff14de6299fe5aa78
2019-03-11 13:05:51 +13:00
Adrian Turjak ba14a45ba9 Fixed some unneeded domain_id handling
When you are acting on a user or project with an id
there is no need for a domain_id as well, since
IDs are unique across all domains. Names are not.

Change-Id: Ib49ac4d3e1d3e0869195a67ecc922aae24e2a44e
2019-02-01 13:05:50 +13:00
Adrian Turjak f5a76ce35a fix pep8 issues because of new pep8 version
Change-Id: I4740c5fc1b55d8f6b809faf2fd5248965e6f4e89
2019-01-31 14:57:54 +13:00
Adrian Turjak fef06515c9 Fix issues around LDAP backed Keystone
Invite user workflow now defaults to domain_id from
the project.

Create project workflow now default to getting domain
and parent id from config.

Identity manager now has setting to flag the inability to
edit/create users, which some actions now support.

Fix an issue with email comparison when username_is_email was true.

Change-Id: I8548914e3d2283b17f3015595ea72c4c8084d7f5
2019-01-29 13:42:01 +13:00
Adrian Turjak 6a849eec3e Fix an issue with tasks being approved when not yet valid
Our internal auto-approval logic would approve a task before
it was even actually valid. While it would still exit and not
run, the fact that it was 'approved' still caused some minor
edge cases we want to avoid.

Change-Id: I078a56bb9647ccc7caa0485f0fa2a55d2da08048
2019-01-23 15:29:51 +13:00
Adrian Turjak 3fe9d171cb Temporary fix for user enumeration via password reset API
There is a noticable delay when providing a valid username
to the password reset API. Ideally we want to fix this by handling
request in an async fashion, but that will likely have to wait
until we have moved to the planned worker/api model.

This just makes the API always take at least 3 seconds.

Change-Id: I82d46e9d64c65930dbe7d8821941ee9173431d56
2019-01-16 13:29:10 +13:00
Adrian Turjak d4ab292a6a Switch to ignoring pep W503
Change-Id: I3fe7b6f33fa327a9584bbad3c695032bc0a3e54a
2018-12-02 01:01:51 +13:00
Zuul 258abf61d3 Merge "fix typos in documentation" 2018-08-18 01:59:56 +00:00
Adrian Turjak efb6c732d1 Split quota matching functions, and fix percentage
Change-Id: I2620a6e89545f8379c01fd495331700a44028494
2018-06-20 15:25:57 +12:00
Adrian Turjak 4ee2820ebc Add util for action validation to standardise use
Adding a validation util function to help with standardising
how we do action validation, so that validation doesn't continue
after one failure.

Change-Id: I4b46fbfa1382ca94b0821a76439675120be5af60
2018-06-14 15:33:43 +12:00
melissaml e393a7ecc4 fix typos in documentation
Change-Id: I111dd574af43300c34c2a78380274ade0b57210b
2018-05-23 20:54:12 +08:00
Adrian Turjak fbe6067bdc Fix issues with missing service
When Adjutant has sizes defined for a service
that isn't in all regions, we need to skip that
service when doing size comparisons if the current
usage doesn't contain that service.

Change-Id: Iea6a03d97e03501fff6e0635d079759faafbd18b
2018-05-02 13:07:33 +12:00
Amelia Cordwell dab3938ab2 Move task error handling to function
* Replaces large amounts of repeated code on the task view with a
  _handle_task_error() function
* try and unify error handling to always return a list 'errors' or
  a dict when specific field name errors are known.

Change-Id: I9d140db0af204524eadc4ba3a6d3eb7299b239b4
2018-04-10 15:10:09 +12:00
Zuul 16be61428f Merge "Make datetime strings consistent for future parsing" 2018-04-10 00:58:34 +00:00
Adrian Turjak c569816902 Make datetime strings consistent for future parsing
Lets set a default timestamp format for any datetime
strings we know we need to parse later. While we can always
parse the direct output of what we have now, lets control it
so we always have a valid format as expected.

Change-Id: I4af359ea30ace9361c9c5d21e91a0528076eb892
2018-04-10 11:38:07 +12:00
Zuul 372d656ccf Merge "Removed unnessacary code in wsgi.py file" 2018-04-09 06:47:36 +00:00
Amelia Cordwell a6ecf47a32 Removed unnessacary code in wsgi.py file
* Code was not in use
* We are unsure why it was there in the first place

Change-Id: Iaf91e673eeab5e91e76abbd100f41db393f7183c
2018-04-05 15:21:56 +12:00