Commit Graph

141815 Commits

Author SHA1 Message Date
Nizamudeen A
2c8faf256d mgr/dashboard: generalized code-block component
Fixes: https://tracker.ceph.com/issues/63608
Signed-off-by: Nizamudeen A <nia@redhat.com>
2023-12-01 13:49:48 +05:30
John Mulligan
ed6f171ba0 cephadm: black format daemons/tracing.py
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
b0f1c7fff3 cephadm: black format daemons/snmp.py
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
bc0c9d5422 cephadm: black format daemons/nvmeof.py
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
192ff2f6ef cephadm: black format daemons/nfs.py
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
8535d57b3b cephadm: black format daemons/monitoring.py
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
196ad1855e cephadm: black format daemons/iscsi.py
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
505624de9f cephadm: black format daemons/ingress.py
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
c791915164 cephadm: black format daemons/custom.py
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
a7f5b0c20b cephadm: black format daemons/ceph.py
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
ddee9492b4 cephadm: convert all deploy tests to use funkypatch fixture
During the refactor of various daemon type classes some of the tests had
been converted to funkypatch in order to deal with imports occuring over
multiple files. However, this conversion was done piece by piece in
order to make clear what was changing. This left the functions in this
file inconsistent. Change all the remaining function to use funkypatch
for consistency.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
13baad75f5 cephadm: sort imports import daemons/__init__.py
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
31ba507cc7 cephadm: move ceph classes to a new file
Move the ceph classes (Ceph, OSD, CephExporter) along with a few heavily
linked functions to a new ceph.py file under the daemons dir.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
63a14afb5c cephadm: move snmp class to a new file
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
643dd5d0f6 cephadm: move monitoring class to a new file
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
0a6a1dfa96 cephadm: move nfs class to a new file
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
c093a1991d cephadm: move iscsi class to a new file
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
3b752dde73 cephadm: move nvmeof class to a new file
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
cb960823ba cephadm: move haproxy and keepalived classes to a new file
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
8db86d29d6 cephadm: move tracing class to a new file
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
17714889f5 cephadm: move custom container class to a new file
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
5a45aca014 cephadm: start a cephadmlib.daemons package
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
6276f74ff2 cephamd: update tests to use should_log_to_journald from context_getters
Update tests to import should_log_to_journald from context_getters - the
module that actually defines that function. This makes later refactoring
easier.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
d5ce0b7a8d cephadm: update tests to import dict_get* functions from proper module
Update the test that import dict_get and dict_get_join to use the
context_getters module - the module that actually defines the functions.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
700ea8d109 cephadm: use funkypatch for setting up common patches in deploy tests
Add a shim function and convert to the use of the FunkyPatcher class in
the test_deploy.py test functions. Use a shim as to not have to change
all the tests (yet).

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
eca9be6544 cephadm: create deployment_utils module
Create a deployment_utils module for deployment related functions that
don't have a better home.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
f25048f876 cephadm: convert test_mon_crush_location to use funkypatch fixture
The test_mon_crush_location test always seems to have me tinkering
with it during refactoring. Re-do the fixtures to use funkpatch instead
of mock.patch and normal monkeypatch. This looks nicer (IMO) and should
avoid having to frequently mess with it when moving functions during future
refactoring.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
40206912a4 cephadm: update test to use funkypatch fixture
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:59 -05:00
John Mulligan
3aa16497b3 cephadm: add a new funkypatch fixture based on mock.patch and pytest
This fixture acts like a combination of mock.patch and pytest's
monkeypatch fixture. It has the additional feature of automatically
finding and patching the same object imported in other modules.  If you
have 'from x import y', where y is a function or class, in both a.py and
b.py it will patch both instances (so long as both a and b are already
imported).
This behavior is useful for cephadm because of the heavy use of the
`from x import y` idiom and how cephadm is being actively refactored.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 16:55:50 -05:00
John Mulligan
3939201f53 cephadm: add a make_run_dir function
This function is roughly the same as make_var_run only it doesn't rely
on shelling out to the install command. Eventually, it will be used
to replace make_var_run in certain locations.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2023-11-30 14:08:58 -05:00
Casey Bodley
d962dbeb90 rgw/iam: admin/system users ignore iam policy parsing errors
allow admin users to repair broken iam policies that would otherwise
reject access on PutBucketPolicy/DeleteBucketPolicy requests

Fixes: https://tracker.ceph.com/issues/63485

Signed-off-by: Casey Bodley <cbodley@redhat.com>
2023-11-30 13:28:41 -05:00
Casey Bodley
0654b0b051 rgw/acl: remove virtual destructor of ACLGranteeType
Signed-off-by: Casey Bodley <cbodley@redhat.com>
2023-11-30 11:25:02 -05:00
Casey Bodley
7a3eb76761 rgw/acl: ACLGrant uses variant for grantee types
use of `ACLGrant::get_id()` was awkward because most grantee types
returned nothing, but emails were returned as `struct rgw_user`. change
the internal representation into a variant, and expose getters for each
grantee type so callers can handle each type specifically. the encoded
format of `ACLGrant` remains unchanged

Signed-off-by: Casey Bodley <cbodley@redhat.com>
2023-11-30 11:25:02 -05:00
Casey Bodley
ac4253b403 rgw/acl: req_state stores ACLs by value instead of unique_ptr
we no longer rely on polymorphism for the s3/swift variants of
`RGWAccessControlPolicy`, so `req_state` can store `bucket_acl`,
`object_acl` and `user_acl` by value

most functions now take these acls by const- or mutable reference
instead of pointers since they won't be nullptr

some code paths won't initialize some of these bucket/object/user acl
variables, and we rely on `RGWAccessControlPolicy::verify_permissions()`
to return false for those because we won't match an empty owner or
array of grants

in only one case, `verify_user_permissions()` has to return true when
`user_acl` is uninitialized, because S3 doesn't have user acls so
uninitialized user acls should not deny access

Signed-off-by: Casey Bodley <cbodley@redhat.com>
2023-11-30 11:25:02 -05:00
Casey Bodley
d28c05cb77 rgw/acl/s3: parse_policy() as free function
s3 acl parsing classes no longer inherit from the acl classes
themselves, and are all encapsulated in rgw_acl_s3.cc behind a single
rgw::s3::parse_policy() function

Signed-off-by: Casey Bodley <cbodley@redhat.com>
2023-11-30 11:24:59 -05:00
Casey Bodley
4ffa4498d6 rgw/acl/s3: write_policy_xml() as free function
Signed-off-by: Casey Bodley <cbodley@redhat.com>
2023-11-30 11:09:34 -05:00
Casey Bodley
3353abb549 rgw/acl/s3: create_policy_from_headers() as free function
Signed-off-by: Casey Bodley <cbodley@redhat.com>
2023-11-30 10:58:49 -05:00
Casey Bodley
bce77ab23b rgw/acl/s3: create_canned_acl() as free function
adds canned acls to base class RGWAccessControlPolicy

Signed-off-by: Casey Bodley <cbodley@redhat.com>
2023-11-30 10:58:49 -05:00
Casey Bodley
99131fc14b rgw/acl: use create_default() instead of empty canned acls
create_default() adds the same default acl, without the relation to s3
canned acls

Signed-off-by: Casey Bodley <cbodley@redhat.com>
2023-11-30 10:58:48 -05:00
Casey Bodley
2ac0daad1c rgw/acl/swift: remove RGWAccessControlPolicy subclasses
Signed-off-by: Casey Bodley <cbodley@redhat.com>
2023-11-30 10:58:48 -05:00
Casey Bodley
f646ebf543 rgw/acl/swift: format_account_acl() as free function
Signed-off-by: Casey Bodley <cbodley@redhat.com>
2023-11-30 10:58:48 -05:00
Casey Bodley
78ba3808fb rgw/acl/swift: create_account_policy() as free function
Signed-off-by: Casey Bodley <cbodley@redhat.com>
2023-11-30 10:40:45 -05:00
Casey Bodley
d2d1a87731 rgw/acl/swift: add_grants() as static free function
Signed-off-by: Casey Bodley <cbodley@redhat.com>
2023-11-30 10:40:45 -05:00
Casey Bodley
bdbace0a4c rgw/acl/swift: add_grants() uses user_to_grant() helper
Signed-off-by: Casey Bodley <cbodley@redhat.com>
2023-11-30 10:40:45 -05:00
Casey Bodley
ade871e280 rgw/acl/swift: format_container_acls() as free function
Signed-off-by: Casey Bodley <cbodley@redhat.com>
2023-11-30 10:40:45 -05:00
Casey Bodley
4e1738db99 rgw/acl/swift: merge_policy() as free function
Signed-off-by: Casey Bodley <cbodley@redhat.com>
2023-11-30 10:40:45 -05:00
Casey Bodley
33bc63e8d6 rgw/acl/swift: create_container_policy() as free function
Signed-off-by: Casey Bodley <cbodley@redhat.com>
2023-11-30 10:40:45 -05:00
Casey Bodley
064b562c2b rgw/acl/swift: parse_grant() as static function
Signed-off-by: Casey Bodley <cbodley@redhat.com>
2023-11-30 10:40:45 -05:00
Casey Bodley
8fbd1efaf0 rgw/acl/swift: parse acl header with ceph::split()
Signed-off-by: Casey Bodley <cbodley@redhat.com>
2023-11-30 10:40:45 -05:00
Casey Bodley
9bf24c0825 rgw/acl: add_grant() takes const ref
that also required fixing some const-correctness issues

Signed-off-by: Casey Bodley <cbodley@redhat.com>
2023-11-30 10:40:45 -05:00