Commit Graph

454 Commits

Author SHA1 Message Date
Ghanshyam Mann 0c1e1ccf03 HyperV: Remove RDP console API
RDP console was only for HyperV driver so removing the
API. As API url stay same (because same used for other
console types API), RDP console API will return 400.

Cleaning up the related config options as well as moving its
API ref to obsolete seciton.

Keeping RPC method to avoid error when old controller is used
with new compute. It can be removed in next RPC version bump.

Change-Id: I8f5755009da4af0d12bda096d7a8e85fd41e1a8c
2024-02-13 12:24:38 -08:00
Sean Mooney f4852f4c81 [codespell] fix final typos and enable ci
This chnage adds the pre-commit config and
tox targets to run codespell both indepenetly
and via the pep8 target.

This change correct all the final typos in the
codebase as detected by codespell.

Change-Id: Ic4fb5b3a5559bc3c43aca0a39edc0885da58eaa2
2023-12-15 12:32:42 +00:00
Sean Mooney 7402822f0b [codespell] start fixing all the typos
this is the inital patch of applying codespell to nova.
codespell is a programing focused spellchecker that
looks for common typos and corrects them.

i am breaking this into multiple commits to make it simpler
to read and will automate the execution of codespell
at the end of the series.

Change-Id: If24a6c0a890f713545faa2d44b069c352655274e
2023-10-03 00:51:35 +01:00
Sylvain Bauza 2d320f9b00 Add a new policy for cold-migrate with host
We add a new specific policy when a host value is provided for cold-migrate,
but by default it will only be an admin-only rule in order to not change
the behaviour.

Change-Id: I128242d5f689fdd08d74b1dcba861177174753ff
Implements: blueprint cold-migrate-to-host-policy
2023-06-26 11:34:12 +02:00
Ghanshyam Mann 95244e089f Make tenant network policy default to PROJECT_READER_OR_ADMIN
This policy is missed to default to legacy admin in
- https://review.opendev.org/c/openstack/nova/+/849209

Making tenant network policy also default to PROJECT_READER_OR_ADMIN.

Change-Id: I1097d948f8c10ff99c54e8c369a7058ea14e6934
2022-11-19 16:09:13 -06:00
Ghanshyam Mann 909b0b0247 Keep legacy admin behaviour in new RBAC
While discussing the new RBAC (scope_type and project admin vs
system admin things) with operators in berlin ops meetup and
via emails, and policy popup meetings, we got the feedback that
we need to keep the legacy admin behaviour same as it is otherwise
it is going to be a big breaking change for many of the operators.
Same feedback for scope_type.

- https://etherpad.opendev.org/p/BER-2022-OPS-SRBAC
- https://etherpad.opendev.org/p/rbac-operator-feedback

By considering the feedback, we decided to postpone the
system scope implementation, release project reader
role and not to change the legacy admin behaviour.

To keep the legacy admin behaviour unchanged, we need to
modify our policy new default so that legacy admin continue
to have the access to the APIs they are able to access in
old RBAC. Basically the below changes:

- PROJECT_ADMIN -> ADMIN (legacy admin who can do things in all projects)
- PROJECT_MEMBER -> PROJECT_MEMBER_OR_ADMIN (give access to legacy admin too)
- PROJECT_READER -> PROJECT_READER_OR_ADMIN (give access to legacy admin too)

Complete direction on RBAC is updated in community wide goal
- https://review.opendev.org/c/openstack/governance/+/847418/13

Change-Id: I37e706f75a36fb27da1bdd5fba671cb1bcadc745
2022-08-24 16:33:27 +00:00
Dan Smith 066e1e69d1 Remove system scope from all APIs
In line with the recent RBAC working group discussion and operator
feedback, this converts all our APIs back to project-only. It leaves
the actual scope_types in place, with them all set to project. This
allows an operator to turn on scope checking to *ensure* that only
project-scoped tokens are used, in case system scope is in use
elsewhere in the deployment (i.e. for keystone or ironic). Without
this, system scoped tokens will fail some operations in strange
(read: 500 and "database error") ways.

Change-Id: I951a11affa1d1e42863967cdc713618ff0a74814
2022-08-24 13:12:16 +00:00
René Ribaud 09239fc2ea Allow unshelve to a specific host (REST API part)
This adds support to the REST API, in a new microversion, for specifying
a destination host to unshelve server action when the server
is shelved offloaded.
This patch also supports the ability to unpin the availability_zone of an
instance that is bound to it.

Note that the functional test changes are due to those tests using the
"latest" microversion 2.91.

Implements: blueprint unshelve-to-host
Change-Id: I9e95428c208582741e6cd99bd3260d6742fcc6b7
2022-07-22 10:22:34 +02:00
Ghanshyam Mann f9c1d1163d Complete phase-1 of RBAC community-wide goal
After moving the nova APIs policy as per the new guidlines
where system scoped token will be only allowed to access
system level APIs and will not be allowed any operation
on project level APIs. With that we do not need below
base rules (who have hardcoded 'system_scope:all' check_str):
- system_admin_api
- system_reader_api
- system_admin_or_owner
- system_or_project_reader

At this stage (phase-1 target), we allow below roles as targeted
in phase-1 [1]
1. ADMIN(this is System Administrator with scope_type 'system'
when scope enabled otherwise legacy admin)
2. PROJECT_ADMIN
3. PROJECT_MEMBER
4. PROJECT_READER
 & below one specific to nova
5. PROJECT_READER_OR_ADMIN (to allow system admin and project reader
to list flavor extra specs)

This complete the phase-1 of RBAC community-wide goal[2] for nova.

Add release notes too.

[1] https://governance.openstack.org/tc/goals/selected/consistent-and-secure-rbac.html#how-operator
[2] https://governance.openstack.org/tc/goals/selected/consistent-and-secure-rbac.html#yoga-timeline-7th-mar-2022

Partial implement blueprint policy-defaults-refresh-2

Change-Id: I075005d13ff6bfe048bbb21d80d71bf1602e4c02
2022-02-24 16:33:34 +00:00
Ghanshyam Mann 1be007243b Separate flavor extra specs policy for server APIs
Flavor extra specs index policy is used to show flavor
extra specs in flavor as well as server APIs response.

As per RBAC new guidelines, we are restricting project level
respurces APIs to project scoped only. To do that, we are
separating the flavor extra specs index policy for server
APIs and make them only for project scoped.

Partial implement blueprint policy-defaults-refresh-2

Change-Id: I9cfb61dabe6f98cb057aad9702f9d355c415fda6
2022-02-24 16:33:26 +00:00
Ghanshyam Mann ab084d4d1d Modify remaining APIs as per RBAC new guidelines
As per the RBAC new direction, we will allow
project resources operation to be performed by
the project scoped token only and system user will
be allowed to perform system level operation only
not project resources specific.

Details about new direction can be found in community-wide
goal
- https://governance.openstack.org/tc/goals/selected/consistent-and-secure-rbac.html

This commit modify remaining APIs as per the new guidelines.

Also, allow all project admin to list the other project limits. This is
what we allowed in legacy policy and until we have domain admin or other
way to list other project resources/info, we will keep that behaviour.

Also modifying and adding tests for four cases:
1. enforce_scope=False + legacy rule (current default policies)
2. enforce_scope=False + No legacy rule
3. enforce_scope=True + legacy rule
4. enforce_scope=True + no legacy rule (end goal of new RBAC)

Partial implement blueprint policy-defaults-refresh-2

Change-Id: I006d47aa2f4678a06c78057bcf407302abbe4907
2022-02-24 10:24:55 -06:00
Ghanshyam Mann 20a07ee9a6 Server actions APIs scoped to project scope
As per the RBAC new direction, we will allow
project resources operation to be performed by
the project scoped token only and system user will
be allowed to perform system level operation only
not project resources specific.

Details about new direction can be found in community-wide
goal
- https://governance.openstack.org/tc/goals/selected/consistent-and-secure-rbac.html

This commit modify the server action APIs to be scoped
to project scope.

Fix the shelve-offload policy to pass the instance project
id as target.

Also modifying and adding tests for four cases:
1. enforce_scope=False + legacy rule (current default policies)
2. enforce_scope=False + No legacy rule
3. enforce_scope=True + legacy rule
4. enforce_scope=True + no legacy rule (end goal of new RBAC)

Partial implement blueprint policy-defaults-refresh-2

Change-Id: I5293e9aa9cb3b48f97a5a2cf272939ada1aea2db
2022-02-20 01:08:11 +00:00
Ghanshyam Mann d7be635fb4 Make more project level APIs scoped to project only
As per the RBAC new direction, we will allow
project resources operation to be performed by
the project scoped token only and system user will
be allowed to perform system level operation only
not project resources specific.

Details about new direction can be found in community-wide
goal
- https://governance.openstack.org/tc/goals/selected/consistent-and-secure-rbac.html

This commit modify more projects level APIs to be scoped
to project only.

Also modifying and adding tests for four cases:
1. enforce_scope=False + legacy rule (current default policies)
2. enforce_scope=False + No legacy rule
3. enforce_scope=True + legacy rule
4. enforce_scope=True + no legacy rule (end goal of new RBAC)

Partial implement blueprint policy-defaults-refresh-2

Change-Id: I6731aa6edd0c6bed5edb9eaaaa98b5e43aaeeb74
2022-02-19 18:19:34 -06:00
Ghanshyam Mann 60c9e3edad Convert SYSTEM_ADMIN|READER to Admin and system scope
As per the new direction, we will move all the
system level policies to system admin even GET
policies. system reader will be added in next phase
in future cycle.

To dissociate the scope checks form the new defaults,
check_str is added as 'admin' rule (role:admin) without
'system:all'. So that policy with that admin rule and
scope_type as 'system' works like:
- with enforce_scope=false, legacy or project admin still able to
 access the system level APIs.
- with enforce_scope=True, only system user with admin role can
access the system level APIs.

Also modifying and adding tests for four cases:
1. enforce_scope=False + legacy rule (current default policies)
2. enforce_scope=False + No legacy rule
3. enforce_scope=True + legacy rule
4. enforce_scope=True + no legacy rule (end goal of new RBAC)

Partial implement blueprint policy-defaults-refresh-2

Change-Id: I344276d2ab054311a4b6c34c6998e116e7507246
2022-02-17 05:20:07 +00:00
Dan Smith d9190912b9 Revert project-specific APIs for servers
This attempts to move us back to just allowing project-scoped tokens
for project resources when scope checking is enabled. It does it for
servers and flavor_extra_specs, since the latter depends on the policy
of the former.

There is a lot more churn in here than just that conversion, as I
added a helper method and moved from using two lists for everything to
one. Had I known I was going to do that initially, I would have done
it in a refactor first, but alas getting things to work ended up being
easier if I used that approach, and thus did them together. That could
be pulled out (with some effort) if people feel strongly about it,
but hopefully this can just set the base for going forward.

This also adds a new test scenario to both servers and extra_specs,
which validates that we can enable the new rules without scope
checking enabled.

Change-Id: I395d97558c36200a6f6ba7c804ab2a9ac5e51d04
2021-12-01 08:54:34 -08:00
Stephen Finucane cfa33d3b06 policy: Deprecate field from 'os-extended-server-attributes' policy
Indicate that the 'os_compute_api:os-extended-server-attributes' will no
longer control visibility of the 'OS-EXT-SRV-ATTR:hostname' attribute in
a future release, following a deprecation period.

Change-Id: I981a3bdb6c2f11f294cbb01689cf927d216b2439
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2021-08-26 10:54:25 +01:00
Stephen Finucane 5e2c31ab78 api: Add support for 'hostname' parameter
Add microversion 2.90, which allows allows users to configure the
hostname that will be exposed via the nova metadata service when
creating their instance.

Change-Id: I95047c1689ac14fa73eba48e19dc438988b78aad
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2021-01-14 11:42:43 +00:00
Ghanshyam Mann dfda0c0482 Fix oslo policy DeprecatedRule warnings
Since 3.7.0, oslo policy started the DeprecationWarning[1] if
deprecated_reason and deprecated_since param are not passed
in DeprecatedRule or they are passed in RuleDefault object.

[1] https://github.com/openstack/oslo.policy/blob/3.7.0/oslo_policy/policy.py#L1538

Change-Id: Idbbc203c6ae65aee29f9463a4911bae2bb541f41
2021-07-04 16:00:55 -05:00
Ghanshyam Mann 2c761066e0 Remove PROJECT_ADMIN limitation from zero-disk and external-network policy
In Ussuri, we added the PROJECT_ADMIN default policy for POST /servers
API in case of 1. forced_host 2. requested_destination 3. zero_disk_flavor
4. network_attach_external [1]. For 1st two we have the limitation of
project_admin to get the host name and pass it in POST /servers request.

But for last two (3. zero_disk_flavor, 4. network_attach_external) we do
not have such limitation:

3. zero disk flavor - This policy is checked to protect from the large image
 and indicating the server should be volume-backed.
 - c0c2888aca/nova/compute/api.py (L751)

4. Attach an unshared external  - It depends on neutron policy for
 get external network. If user want to create server with net id then
 they can get net id from neutron because neutron policy for GET external
 network is SYSTEM_OR_PROJECT_READER[2]. Otherwise requested projects
 (who is creating server) networks will be fetched from neutron[3]. so
 with neutron default policy there is no limitation here.

[1]
cd084aeeb8/nova/policies/servers.py (L189-L217)
cd084aeeb8/nova/policies/servers.py (L279-L314)
[2] 0bdf3b56e0/neutron/conf>
[3] 7cabd6dc40/nova/network/ne>

Change-Id: Ibf45c02fae6f6b0b39dc4de206416f03c801351b
2021-06-02 20:27:09 -05:00
Stephen Finucane 68bc87876f virt: Remove 'reset_network' API
This one is tied into an admin action in the server actions API, which
means we must remove that API action also. Otherwise, this isn't too
crazy.

Change-Id: I58343b94b67915062d044fa0f53aeab01b77738f
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2020-11-23 15:55:50 +00:00
Stephen Finucane 7ac52e643c api: Remove 'os-agents' API
This was only useful with XenAPI and can therefore be removed.

Change-Id: I9512f605dd2b3b0e88c951ed086250d57056303d
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2020-09-11 14:10:32 +01:00
Ghanshyam Mann 521ea08467 Few todo fixes for API new policies
1. Add testing context 'self.other_project_reader_context'
for remaining tests.

2. Replace REQUESTED_DESTINATION policy check_str with 'PROJECT_ADMIN'
so that it will easy to remove the deprecated RULE_ADMIN_API rule.

Partial implement blueprint policy-defaults-refresh-deprecated-apis

Change-Id: Ibf88029af32376788134427be99d219784f8e333
2020-08-22 09:35:29 -05:00
Ghanshyam Mann 08f58909bd Add new default roles in FIP policies
This adds new defaults roles in FIP API policies.
These policies are made granular and default to
PROJECT_READER_OR_SYSTEM_READER and PROJECT_MEMBER_OR_SYSTEM_ADMIN.

Partial implement blueprint policy-defaults-refresh-deprecated-apis

Change-Id: I6dcc8db9178aef59017968a3172ab463cd74754d
2020-08-17 09:56:55 -05:00
Ghanshyam Mann 558c6e752a Add new default roles in networks policies
This adds new defaults roles in networks API policies.
These policies are made granular and default to
PROJECT_READER_OR_SYSTEM_READER.

Partial implement blueprint policy-defaults-refresh-deprecated-apis

Change-Id: Idcccdf6b3a1638cf140b5c4f887abbed85c5d7dc
2020-08-17 09:51:16 -05:00
Ghanshyam Mann 284ac43f7a Add scope and new default roles in extensions policies
This adds scope_type and new defaults roles in extensions
API policies. These policies are for extensions API which are
kept only for backward compatibility of v2.0 but nova does not
have extensions concept now and return only hard-coded info. So
these policies are not made granular.

Partial implement blueprint policy-defaults-refresh-deprecated-apis

Change-Id: I062e556feb5cc85d179fed9b675e4ab33ca3365a
2020-08-17 09:40:02 -05:00
Ghanshyam Mann de2226b4b3 Add new default roles in baremetal nodes policies
This adds new defaults roles in baremetal nodes API policies.
These policies are default to SYSTEM_READER and made more
granular to adopt the new defaults.

Partial implement blueprint policy-defaults-refresh-deprecated-apis

Change-Id: Ieaad388d31fdabf0854bf7e2ed9fddf11f86bf8c
2020-08-17 14:36:38 +00:00
Ghanshyam Mann 09b2dce4c3 Introduce scope_types in FIP policy
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 FIP policies
as 'system' and 'project'

Partial implement blueprint policy-defaults-refresh-deprecated-apis

Change-Id: I1dc11c4857466a6edb7baa9ccee3dde97a54afa0
2020-08-14 02:22:08 +00:00
Zuul 2e2e8a0420 Merge "Correct the check_str and pass actual target in FIP pools policy" 2020-08-13 22:21:56 +00:00
Zuul e85792726d Merge "Add new default roles in multinic policies" 2020-08-13 22:21:50 +00:00
Zuul c5c3cee5d2 Merge "Introduce scope_types in multinic policy" 2020-08-07 21:04:02 +00:00
Zuul 50d577bd6a Merge "Introduce scope_types in baremetal node" 2020-08-07 19:38:38 +00:00
Zuul 35e10ad3b1 Merge "Introduce scope_types in FIP pools" 2020-08-07 19:30:55 +00:00
Zuul 09ed4c21db Merge "Add new default roles in hosts policies" 2020-08-07 17:54:26 +00:00
Zuul edae8889c9 Merge "Introduce scope_types in hosts policy" 2020-08-07 17:18:27 +00:00
Zuul f96e2f4f62 Merge "Add new default roles in volumes policies" 2020-08-07 15:58:05 +00:00
Zuul ce68f2a758 Merge "Introduce scope_types in volumes policy" 2020-08-07 15:53:57 +00:00
Zuul db0ba730f2 Merge "Introduce scope_types in networks policy" 2020-08-07 15:53:31 +00:00
Zuul 9031badf41 Merge "Add new default roles in security_groups policies" 2020-08-07 15:53:06 +00:00
Zuul 5d2f3e5621 Merge "Introduce scope_types in security_groups policy" 2020-08-07 14:38:33 +00:00
Ghanshyam Mann b39712f03e Add new default roles in volumes policies
This adds new defaults roles in volumes API policies.
These policies are made granular and default to
PROJECT_READER_OR_SYSTEM_READER and PROJECT_MEMBER_OR_SYSTEM_ADMIN.

Partial implement blueprint policy-defaults-refresh-deprecated-apis

Change-Id: I37fa825b0e915e83da7023564a29811dcdfa058d
2020-07-28 15:12:02 +00:00
Ghanshyam Mann 4ef2ebe241 Add new default roles in hosts policies
This adds new defaults roles in hosts API policies.
These policies are made granular and default to
SYSTEM_READER and SYSTEM_ADMIN.
Also pass the actual targets which is empty dict in
hosts policy.

Partial implement blueprint policy-defaults-refresh-deprecated-apis

Change-Id: I159aaa37e1c238b484619a9951da7e63774024cb
2020-07-25 21:20:00 +00:00
Ghanshyam Mann 864a32bc37 Introduce scope_types in hosts policy
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 hosts policies
as 'system'.

Partial implement blueprint policy-defaults-refresh-deprecated-apis

Change-Id: I0108e11f9a75b893d221770d0bf05c39fd8fb2fc
2020-07-24 22:18:48 -05:00
Ghanshyam Mann a20ab7016e Add new default roles in security_groups policies
This adds new defaults roles in security_groups API policies.
These policies are made granular and default to
PROJECT_READER_OR_SYSTEM_READER and PROJECT_MEMBER_OR_SYSTEM_ADMIN.

Partial implement blueprint policy-defaults-refresh-deprecated-apis

Change-Id: Ie1ea066e9683fc44d486bcde1eb0f01fca7645c7
2020-07-24 01:23:21 +00:00
Ghanshyam Mann 9acbae3619 Introduce scope_types in volumes policy
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 volumes policies
as 'system' and 'project'.

Partial implement blueprint policy-defaults-refresh-deprecated-apis

Change-Id: I644afd7691e805e3ee086024c6b9c82b0a4b7bbb
2020-07-23 20:20:13 -05:00
Ghanshyam Mann cade031eb3 Add new default roles in tenant networks policies
This adds new defaults roles in tenant networks API policies.
These policies are made granular and default to
PROJECT_READER_OR_SYSTEM_READER.

Partial implement blueprint policy-defaults-refresh-deprecated-apis

Change-Id: I9b7154680b19f76cb97a6c861657ca2f5cad0004
2020-07-24 00:19:43 +00:00
Ghanshyam Mann 787e359bb1 Introduce scope_types in tenant networks policy
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 tenant networks policies
as 'system' and 'project'.

Partial implement blueprint policy-defaults-refresh-deprecated-apis

Change-Id: I71a966d23f117595e42dd1afc1e10baece9b2a25
2020-07-24 00:19:34 +00:00
Ghanshyam Mann 2e1c10e269 Introduce scope_types in networks policy
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 networks policies
as 'system' and 'project'.

Partial implement blueprint policy-defaults-refresh-deprecated-apis

Change-Id: I3835f3cc03611fe44d178c6643345ae3dfcc1995
2020-07-23 23:40:32 +00:00
Ghanshyam Mann 2939847226 Introduce scope_types in security_groups policy
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 security_groups policies
as 'system' and 'project'

Partial implement blueprint policy-defaults-refresh-deprecated-apis

Change-Id: Ibf6ba7da4bd8a3b9b3c7b112828959c2ff2b3f73
2020-07-23 17:10:30 -05:00
Ghanshyam Mann 24fe5d7dda Add new default roles in multinic policies
This adds new defaults roles in multinic API policies.
These policies are made granular and default to
PROJECT_MEMBER_OR_SYSTEM_ADMIN.

Partial implement blueprint policy-defaults-refresh-deprecated-apis

Change-Id: I1b2c741e86431963fb4f0696509bed01351afac2
2020-07-21 21:21:00 -05:00
Ghanshyam Mann 9c129ccef9 Introduce scope_types in multinic policy
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 multinic policies
as 'system' and 'project'.

Partial implement blueprint policy-defaults-refresh-deprecated-apis

Change-Id: I0ddd4a06413c2e069175a357e9baa2f3c61003cd
2020-07-22 02:18:01 +00:00