forked from pulp/pulpcore
/
status.py
123 lines (90 loc) · 3.57 KB
/
status.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
from gettext import gettext as _
from rest_framework import serializers
from pulpcore.app.serializers.task import (
ApiAppStatusSerializer,
ContentAppStatusSerializer,
WorkerSerializer,
)
class VersionSerializer(serializers.Serializer):
"""
Serializer for the version information of Pulp components
"""
component = serializers.CharField(help_text=_("Name of a versioned component of Pulp"))
version = serializers.CharField(help_text=_("Version of the component (e.g. 3.0.0)"))
package = serializers.CharField(help_text=_("Python package name providing the component"))
domain_compatible = serializers.BooleanField(
help_text=_("Domain feature compatibility of component")
)
class DatabaseConnectionSerializer(serializers.Serializer):
"""
Serializer for the database connection information
"""
connected = serializers.BooleanField(
help_text=_("Info about whether the app can connect to the database")
)
class RedisConnectionSerializer(serializers.Serializer):
"""
Serializer for information about the Redis connection
"""
connected = serializers.BooleanField(
help_text=_("Info about whether the app can connect to Redis")
)
class StorageSerializer(serializers.Serializer):
"""
Serializer for information about the storage system
"""
total = serializers.IntegerField(
min_value=0, help_text=_("Total number of bytes"), allow_null=True
)
used = serializers.IntegerField(
min_value=0, help_text=_("Number of bytes in use"), allow_null=True
)
free = serializers.IntegerField(
min_value=0, help_text=_("Number of free bytes"), allow_null=True
)
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
"""
versions = VersionSerializer(help_text=_("Version information of Pulp components"), many=True)
online_workers = WorkerSerializer(
help_text=_(
"List of online workers known to the application. An online worker is actively "
"heartbeating and can respond to new work."
),
many=True,
)
online_api_apps = ApiAppStatusSerializer(
help_text=_(
"List of online api apps known to the application. An online api app "
"is actively heartbeating and can serve the rest api to clients."
),
many=True,
)
online_content_apps = ContentAppStatusSerializer(
help_text=_(
"List of online content apps known to the application. An online content app "
"is actively heartbeating and can serve data to clients."
),
many=True,
)
database_connection = DatabaseConnectionSerializer(
help_text=_("Database connection information")
)
redis_connection = RedisConnectionSerializer(
required=False,
help_text=_("Redis connection information"),
)
storage = StorageSerializer(required=False, help_text=_("Storage information"))
content_settings = ContentSettingsSerializer(help_text=_("Content-app settings"))
domain_enabled = serializers.BooleanField(help_text=_("Is Domains enabled"))