Repository: pulp/pulpcore

Issue:
Add the URL of `content-app` to the pulp's status endpoint
Users who execute `pulp status` shall see the URL of content-app where all resources are served by a distribution. This might be useful for determining the URL of the Pulp Registry when using the container plugin.


Discussion:
@lubosmj  what do you think about a stanza like this : "content_path": "http://localhost:5001/pulp/content/"`

Resolving patch:
diff --git a/pulpcore/app/serializers/status.py b/pulpcore/app/serializers/status.py
--- a/pulpcore/app/serializers/status.py
+++ b/pulpcore/app/serializers/status.py
@@ -49,6 +49,19 @@ class StorageSerializer(serializers.Serializer):
     free = serializers.IntegerField(min_value=0, help_text=_("Number of free bytes"))
 
 
+class ContentSettingsSerializer(serializers.Serializer):
+    """
+    Serializer for information about content-app-settings for the pulp instance
+    """
+
+    content_origin = serializers.CharField(
+        help_text=_("The CONTENT_ORIGIN setting for this Pulp instance"),
+    )
+    content_path_prefix = serializers.CharField(
+        help_text=_("The CONTENT_PATH_PREFIX setting for this Pulp instance"),
+    )
+
+
 class StatusSerializer(serializers.Serializer):
     """
     Serializer for the status information of the app
@@ -82,3 +95,5 @@ class StatusSerializer(serializers.Serializer):
     )
 
     storage = StorageSerializer(required=False, help_text=_("Storage information"))
+
+    content_settings = ContentSettingsSerializer(help_text=_("Content-app settings"))
diff --git a/pulpcore/app/views/status.py b/pulpcore/app/views/status.py
--- a/pulpcore/app/views/status.py
+++ b/pulpcore/app/views/status.py
@@ -76,6 +76,11 @@ def get(self, request):
         except Exception:
             online_content_apps = None
 
+        content_settings = {
+            "content_origin": settings.CONTENT_ORIGIN,
+            "content_path_prefix": settings.CONTENT_PATH_PREFIX,
+        }
+
         data = {
             "versions": versions,
             "online_workers": online_workers,
@@ -83,6 +88,7 @@ def get(self, request):
             "database_connection": db_status,
             "redis_connection": redis_status,
             "storage": _disk_usage(),
+            "content_settings": content_settings,
         }
 
         context = {"request": request}


Test patch:
diff --git a/pulpcore/tests/functional/api/test_status.py b/pulpcore/tests/functional/api/test_status.py
--- a/pulpcore/tests/functional/api/test_status.py
+++ b/pulpcore/tests/functional/api/test_status.py
@@ -43,7 +43,22 @@
                 "free": {"type": "integer"},
             },
         },
+        "content_settings": {
+            "type": "object",
+            "properties": {
+                "content_origin": {"type": "string"},
+                "content_path_prefix": {"type": "string"},
+            },
+            "required": ["content_origin", "content_path_prefix"],
+        },
     },
+    "required": [
+        "content_settings",
+        "database_connection",
+        "online_workers",
+        "storage",
+        "versions",
+    ],
 }
 
 
@@ -60,9 +75,10 @@ class StatusTestCase(unittest.TestCase):
 
     def setUp(self):
         """Make an API client."""
-        self.client = api.Client(config.get_config(), api.json_handler)
+        self.cfg = config.get_config()
+        self.client = api.Client(self.cfg, api.json_handler)
         self.status_response = STATUS
-        cli_client = cli.Client(config.get_config())
+        cli_client = cli.Client(self.cfg)
         self.storage = utils.get_pulp_setting(cli_client, "DEFAULT_FILE_STORAGE")
 
         if self.storage != "pulpcore.app.models.storage.FileSystem":
@@ -113,6 +129,10 @@ def verify_get_response(self, status):
         else:
             warnings.warn("Could not connect to the Redis server")
 
+        self.assertIsNotNone(status["content_settings"])
+        self.assertIsNotNone(status["content_settings"]["content_origin"])
+        self.assertIsNotNone(status["content_settings"]["content_path_prefix"])
+
     @override_settings(CACHE_ENABLED=False)
     def verify_get_response_without_redis(self, status):
         """Verify the response to an HTTP GET call when Redis is not used.