From 4fc2697fb1e4dc71b480db275aa4e54c2b66d018 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Wed, 13 Dec 2023 19:20:45 -0500 Subject: [PATCH] python-common: reformat ServiceSpec class level service type lists Reformat the ServiceSpec classes properties KNOWN_SERVICE_TYPES and REQUIRES_SERVICE_ID. These were previously strings that were converted to lists via a call to split. With a string there's very little a human or a tool can do to validate the content. Changing these into proper lists in the source code brings clarity of intent and the ability to analyze the code. Because there's no semantic difference what services are listed where (this means the type could probably be a set - a quest for another day) I also took the opportunity to sort the contents of the lists and add some basic comments for what these lists are for. It also removes the use of (ugly, IMO) line continuations. The downside is that it makes more total lines, but if that bugs you - use code folding :-). Signed-off-by: John Mulligan --- .../ceph/deployment/service_spec.py | 52 ++++++++++++++++--- 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/src/python-common/ceph/deployment/service_spec.py b/src/python-common/ceph/deployment/service_spec.py index 24f5c646461b7..c1fb11c60d785 100644 --- a/src/python-common/ceph/deployment/service_spec.py +++ b/src/python-common/ceph/deployment/service_spec.py @@ -753,12 +753,52 @@ class ServiceSpec(object): This structure is supposed to be enough information to start the services. """ - KNOWN_SERVICE_TYPES = 'alertmanager crash grafana iscsi nvmeof loki promtail mds mgr mon nfs ' \ - 'node-exporter osd prometheus rbd-mirror rgw agent ceph-exporter ' \ - 'container ingress cephfs-mirror snmp-gateway jaeger-tracing ' \ - 'elasticsearch jaeger-agent jaeger-collector jaeger-query ' \ - 'node-proxy'.split() - REQUIRES_SERVICE_ID = 'iscsi nvmeof mds nfs rgw container ingress '.split() + + # list of all service type names that a ServiceSpec can be cast info + KNOWN_SERVICE_TYPES = [ + 'agent', + 'alertmanager', + 'ceph-exporter', + 'cephfs-mirror', + 'container', + 'crash', + 'elasticsearch', + 'grafana', + 'ingress', + 'iscsi', + 'jaeger-agent', + 'jaeger-collector', + 'jaeger-query', + 'jaeger-tracing', + 'loki', + 'mds', + 'mgr', + 'mon', + 'nfs', + 'node-exporter', + 'node-proxy', + 'nvmeof', + 'osd', + 'prometheus', + 'promtail', + 'rbd-mirror', + 'rgw', + 'snmp-gateway', + ] + + # list of all service type names that require/get assigned a service_id value. + # if a service is not listed here it *will not* be assigned a service_id even + # if it is present in the JSON/YAML input + REQUIRES_SERVICE_ID = [ + 'container', + 'ingress', + 'iscsi', + 'mds', + 'nfs', + 'nvmeof', + 'rgw', + ] + MANAGED_CONFIG_OPTIONS = [ 'mds_join_fs', ] -- 2.39.5