Commit Graph

56652 Commits

Author SHA1 Message Date
Balazs Gibizer 612c36034b [Community goal] Update contributor documentation
As the Ussuri goal we have an OpenStack project wide contributing
documentation template [1]. Nova has its own contributor documentation
so this patch adds the new contributing.rst according to the global
template and links the sections in it to the existing Nova contributor
documentation.

Also the top level CONTRIBUTING.rst template has been changed in the
cookiecutter repo[2]. So this patch updates the CONTRIBUTING.rst according
to the new template.

[1] https://opendev.org/openstack/cookiecutter/src/branch/master/%7b%7bcookiecutter.repo_name%7d%7d/doc/source/contributor/contributing.rst
[2] https://review.opendev.org/#/c/696001

Change-Id: Ia12cd4acbb63f192fcaf0790b72f8e977025a9dc
Story: #2007236
Task: #38541
2020-03-25 12:01:37 +00:00
Zuul 57459c3429 Merge "Don't overwrite greenthread-local context in host manager" 2020-03-11 00:28:21 +00:00
Zuul 7d30ad26ae Merge "libvirt: don't log error if guest gone during interface detach" 2020-03-09 18:44:56 +00:00
Zuul 4ef99ac453 Merge "nit: Fix NOTE error of fatal=False" 2020-03-09 18:17:53 +00:00
Zuul fa16a330f5 Merge "Validate id as integer for os-aggregates" 2020-03-09 18:17:44 +00:00
Zuul abd1f05a0b Merge "trivial: Use 'from foo import bar'" 2020-03-09 15:41:45 +00:00
Matthew Booth 8defe34e28 trivial: Use 'from foo import bar'
In some tests, we were doing an import with a full module path. This has
the side effect of importing every submodule on that path, which led to
some confusing side effects. Use 'import foo from bar' syntax instead
and clean up the damage.

Change-Id: I91a289630f31674dec1d785d67b5acda173b7d7e
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2020-03-09 14:56:02 +00:00
Zuul 6800aa0339 Merge "Add new default roles in os-atttach-inerfaces policies" 2020-03-09 12:25:25 +00:00
Zuul f3abaf4bec Merge "trivial: Rename directory for os-keypairs samples" 2020-03-09 12:25:18 +00:00
Zuul d5b75845a6 Merge "Fix os-keypairs pagination links" 2020-03-09 12:25:11 +00:00
Zuul 618abecd28 Merge "hyper-v: update support matrix" 2020-03-09 12:25:05 +00:00
Zuul 8e7b3839d0 Merge "Add new default roles in os-deferred_delete policies" 2020-03-09 11:13:10 +00:00
Zuul c7fe3b4bcb Merge "Introduce scope_types in os-deferred_delete" 2020-03-09 10:45:54 +00:00
Matt Riedemann 6c3e8bc48e libvirt: don't log error if guest gone during interface detach
Similar to change I8ae352ff3eeb760c97d1a6fa9d7a59e881d7aea1, if
we're processing a network-vif-deleted event while an instance
is being deleted, the asynchronous interface detach could fail
because the guest is gone from the hypervisor. The existing code
for handling this case was using a stale guest object so this
change tries to refresh the guest from the hypervisor and if the
guest is gone, the Host.get_guest() method should raise an
InstanceNotFound exception which we just trap, log and return.

Change-Id: Ic4c870cc5078d3f7ac6b2f96f8904c2a47de418e
Closes-Bug: #1797966
2020-03-09 09:57:47 +00:00
Zuul bb53370197 Merge "Fix hypervisors paginted collection_name." 2020-03-08 17:58:35 +00:00
zhangbailin 1ad2f558c5 nit: Fix NOTE error of fatal=False
Partial implement blueprint policy-defaults-refresh

Change-Id: I2ab6f42150afb9351bd4548b270c6a3b19909a32
2020-03-07 10:18:50 +08:00
Ghanshyam Mann 01948df1a0 Add new default roles in os-atttach-inerfaces policies
This adds new defaults roles in os-attach-interfaces API policies.
- GET rules are made granular and default to System or project reader
- Other policies are default to system admin or project member.

Also add tests to simulates the future where we drop the deprecation
fall back in the policy by overriding the rules with a version where
there are no deprecated rule options. Operators can do the same by
adding overrides in their policy files that match the default but
stop the rule deprecation fallback from happening.

Partial implement blueprint policy-defaults-refresh

Change-Id: Ic405544560ae75ad88c10b8ff6d5048b3728cd2b
2020-03-07 06:28:14 +08:00
Zuul eaf44304da Merge "Add new default roles in os-create-backup policies" 2020-03-06 19:53:22 +00:00
Zuul 706dd6f8d1 Merge "Introduce scope_types in os-create-backup" 2020-03-06 19:53:17 +00:00
Zuul f26d782895 Merge "Add test coverage of existing create_backup policies" 2020-03-06 19:50:35 +00:00
Zuul 9e7352c1dc Merge "Fix os-create-backup policy to be admin_or_owner" 2020-03-06 19:50:28 +00:00
Zuul 1095f04664 Merge "Name Enums" 2020-03-06 19:02:18 +00:00
Stephen Finucane f2a438aa9c trivial: Rename directory for os-keypairs samples
We have a custom of naming the directory after the API. Reinforce that
here.

Change-Id: I5bf68aacc1d987400a91467835c4b55f03c18beb
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2020-03-06 16:57:46 +00:00
Stephen Finucane f31efe0a0e Fix os-keypairs pagination links
The API URL is '/os-keypairs', not '/keypairs'. Attempting to use these
pagination links as-is will result in a HTTP 404 (Not Found).

Change-Id: Ic04568caecc138e6016418f6878d031c4a0d3fb4
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Closes-bug: #1866373
2020-03-06 16:57:44 +00:00
Zuul cbf1096040 Merge "Introduce scope_types in os-instance-action policy" 2020-03-06 15:47:27 +00:00
Zuul 38a11ed4a7 Merge "Introduce scope_types in os-aggregates policy" 2020-03-06 13:36:50 +00:00
Zuul 485a8ec519 Merge "Introduce scope_types in os-volumes-attachments policy" 2020-03-06 13:36:37 +00:00
Zuul 38f0162597 Merge "Add test coverage of existing os-volumes-attachments policies" 2020-03-06 13:32:22 +00:00
Zuul ecb1d7006d Merge "Fix os-volumes-attachments policy to be admin_or_owner" 2020-03-06 13:32:14 +00:00
Zuul e710ebe28f Merge "Add new default roles in os-console-output policies" 2020-03-06 13:32:09 +00:00
Zuul 572d8506a6 Merge "Introduce scope_types in os-console-output" 2020-03-06 13:29:36 +00:00
zhangbailin f0887e9964 Introduce scope_types in os-instance-action policy
oslo.policy introduced the scope_type feature which can
control the access level at system-level and project-level.
  - https://docs.openstack.org/oslo.policy/latest/user/usage.html#setting-scope
  - http://specs.openstack.org/openstack/keystone-specs/specs/keystone/queens/system-scope.html

Appropriate scope_type for nova case:
  - https://specs.openstack.org/openstack/nova-specs/specs/ussuri/approved/policy-defaults-refresh.html#scope

This commit introduce scope_type for os-instance-action API policy.

Partial implement blueprint policy-defaults-refresh
Change-Id: If2d878177c65c9fd6ff44c9b20c354b26d583f40
2020-03-06 12:53:40 +00:00
Zuul 8c2b03d902 Merge "Add test coverage of existing console_output policies" 2020-03-06 12:45:22 +00:00
Zuul a982f55d58 Merge "Add a tests to check when legacy access is removed" 2020-03-06 12:45:07 +00:00
Zuul 10650f2ca6 Merge "Add new default roles in os-admin-password policies" 2020-03-06 12:44:59 +00:00
Zuul 6762b36504 Merge "Introduce scope_types in os-admin-password" 2020-03-06 12:44:53 +00:00
Zuul cac294da16 Merge "Add test coverage of existing os-instance-actions policies" 2020-03-06 12:44:46 +00:00
Zuul 3a57a0eb6e Merge "Correct the actual target in os-instance-actions policy" 2020-03-06 12:44:40 +00:00
Zuul 4c117c881d Merge "Introduce scope_types in os-console-auth-tokens" 2020-03-06 11:50:15 +00:00
Zuul c1eeac897b Merge "Introduce scope_types in os-attach-interfaces" 2020-03-06 11:50:06 +00:00
Zuul 5477af7fd5 Merge "Add test coverage of existing attach_interfaces policies" 2020-03-06 11:49:58 +00:00
Zuul 9d68a5c825 Merge "Remove old policy enforcement in attach_interfaces" 2020-03-06 11:49:53 +00:00
Johannes Kulik 2e70a1717f Validate id as integer for os-aggregates
According to the api-ref, the id passed to calls in os-aggregates is
supposed to be an integer. No function validated this, so any value
passed to these functions would directly reach the DB. While this is
fine for SQLite, making a query with a string for an integer column on
other databases like PostgreSQL results in a DBError exception and thus
a HTTP 500 instead of 400 or 404.

This commit adds validation for the id parameter the same way it's
already done for other endpoints.

Closes-Bug: 1865040

Change-Id: I83817f7301680801beaee375825f02eda526eda1
2020-03-06 12:46:12 +01:00
Ghanshyam Mann ac68939cc5 Introduce scope_types in os-aggregates policy
oslo.policy introduced the scope_type feature which can
control the access level at system-level and project-level.
 - https://docs.openstack.org/oslo.policy/latest/user/usage.html#setting-scope
 - http://specs.openstack.org/openstack/keystone-specs/specs/keystone/queens/system-scope.html

Appropriate scope_type for nova case:
- https://specs.openstack.org/openstack/nova-specs/specs/ussuri/approved/policy-defaults-refresh.html#scope

This commit introduce scope_type for os-aggregates API policies
as 'system'.

Also adds the test case with scope_type enabled and verify we
pass and fail the policy check with expected context.

Partial implement blueprint policy-defaults-refresh

Change-Id: Id920574fd7fa59f2a10e33dc458485bb4848347c
2020-03-06 10:02:25 +00:00
zhangbailin c80cc8926b Introduce scope_types in os-volumes-attachments policy
oslo.policy introduced the scope_type feature which can
control the access level at system-level and project-level.
  - https://docs.openstack.org/oslo.policy/latest/user/usage.html#setting-scope
  - http://specs.openstack.org/openstack/keystone-specs/specs/keystone/queens/system-scope.html

Appropriate scope_type for nova case:
  - https://specs.openstack.org/openstack/nova-specs/specs/ussuri/approved/policy-defaults-refresh.html#scope

This commit introduce scope_type for os-volumes-attachments API policy.

Change-Id: Ibe7aaef25c7eccf2ce017fc606aae9a1448d8bcb
2020-03-06 15:28:50 +08:00
zhangbailin a7d3e3a020 Add test coverage of existing os-volumes-attachments policies
Current tests do not have good test coverage of existing policies.
Either tests for policies do not exist or if they exist then they
do not cover the actual negative and positive testing.

For Example, if any policy with default rule as admin only then
test should verify:
- policy check pass with context having admin role
- policy check fail with context having any other role than admin

As discussed in policy-defaults-refresh [1], to change the policies
with new default roles and scope_type, we need to have the enough
testing coverage of existing policy behavior.
When we will add the scope_type in policies or new default roles,
then these test coverage will be extended to adopt the new changes
and also make sure we do not break the existing behavior.

This commit covers the testing coverage of existing
os-volumes-attachments policies.

[1]https://specs.openstack.org/openstack/nova-specs/specs/ussuri/approved/policy-defaults-refresh.html#testing

Partial implement blueprint policy-defaults-refresh
Change-Id: I6b232c65c83dfcf69b711b7d53e75658c9a44df4
2020-03-06 15:27:55 +08:00
zhangbailin 763d220504 Fix os-volumes-attachments policy to be admin_or_owner
os-volumes-attachments API policy is default to admin_or_owner[1]
but API is allowed for everyone.

We can see the test trying with other project context can access the API
  - https://review.opendev.org/#/c/709929/1/nova/tests/unit/policies/test_volumes.py@84

This is because API does not pass the server project_id in policy
target, impact APIs:

index: https://github.com/openstack/nova/blob/c16315165ce307c605cf4b608b2df3aa06f46982/nova/api/openstack/compute/volumes.py#L282
show: https://github.com/openstack/nova/blob/c16315165ce307c605cf4b608b2df3aa06f46982/nova/api/openstack/compute/volumes.py#L307
create: https://github.com/openstack/nova/blob/c16315165ce307c605cf4b608b2df3aa06f46982/nova/api/openstack/compute/volumes.py#L337
delete: https://github.com/openstack/nova/blob/c16315165ce307c605cf4b608b2df3aa06f46982/nova/api/openstack/compute/volumes.py#L440

And if no target is passed then, policy.py add the default targets which
is nothing but context.project_id (allow for everyone try to access)
  - https://github.com/openstack/nova/blob/c16315165ce307c605cf4b608b2df3aa06f46982/nova/policy.py#L191

[1]https://github.com/openstack/nova/blob/c16315165ce307c605cf4b608b2df3aa06f46982/nova/policies/volumes_attachments.py#L21

Closes-bug: #1864776

Change-Id: Iff0d8024ee1faeaecb44d717bd870bcd32c8d99c
2020-03-06 15:25:16 +08:00
Ghanshyam Mann 4a1afcd3ce Introduce scope_types in os-create-backup
oslo.policy introduced the scope_type feature which can
control the access level at system-level and project-level.
 - https://docs.openstack.org/oslo.policy/latest/user/usage.html#setting-scope
 - http://specs.openstack.org/openstack/keystone-specs/specs/keystone/queens/system-scope.html

Appropriate scope_type for nova case:
- https://specs.openstack.org/openstack/nova-specs/specs/ussuri/approved/policy-defaults-refresh.html#scope

This commit introduce scope_type for os-create-backup API policies
as 'system' and 'project'.

Also adds the test case with scope_type enabled and verify we
pass and fail the policy check with expected context.

Partial implement blueprint policy-defaults-refresh

Change-Id: I0d526bfffe44b59a75d46e7377e705447a349b04
2020-03-06 01:40:50 +00:00
Ghanshyam Mann b6692ee48a Add test coverage of existing create_backup policies
Current tests do not have good test coverage of existing policies.
Either tests for policies do not exist or if they exist then they
do not cover the actual negative and positive testing.

For Example, if any policy with default rule as admin only then
test should verify:
- policy check pass with context having admin or server owner
- policy check fail with context having non-admin and not server owner

As discussed in policy-defaults-refresh [1], to change the policies
with new default roles and scope_type, we need to have the enough
testing coverage of existing policy behavior.

When we will add the scope_type in policies or new default roles,
then these test coverage will be extended to adopt the new changes
and also make sure we do not break the existing behavior.

This commit covers the testing coverage of existing create_backup policies.

Partial implement blueprint policy-defaults-refresh

[1] https://specs.openstack.org/openstack/nova-specs/specs/ussuri/approved/policy-defaults-refresh.html#testing

Change-Id: Iebc79fd72415603112a15a12f06153fb7a4e7fcc
2020-03-06 01:39:22 +00:00
Ghanshyam Mann 30bcb43ca5 Fix os-create-backup policy to be admin_or_owner
os-create-backup API policy is default to admin_or_owner[1] but API
is allowed for everyone.

We can see the test trying with other project context can access the API
- https://review.opendev.org/#/c/706726/

This is because API does not pass the server project_id in policy target[2]
and if no target is passed then, policy.py add the default targets which is
nothing but context.project_id (allow for everyone who try to access)[3]

This commit fix this policy by passing the server's project_id in policy
target.

[1] https://github.com/openstack/nova/blob/1fcd74730d343b7cee12a0a50ea537dc4ff87f65/nova/policies/create_backup.py#L27
[2] https://github.com/openstack/nova/blob/1fcd74730d343b7cee12a0a50ea537dc4ff87f65/nova/api/openstack/compute/create_backup.py#L50
[3] https://github.com/openstack/nova/blob/c16315165ce307c605cf4b608b2df3aa06f46982/nova/policy.py#L191

Change-Id: I36cba4c6760f8f9faa5f3039cbb11ea1dc296f68
Closes-bug: #1862561
2020-03-06 01:39:03 +00:00