Skip to content

Commit

Permalink
Merge branch 'fix_ordering_model' into 'hotfix'
Browse files Browse the repository at this point in the history
Fixed the order of creating jobs

See merge request arenadata/development/adcm!2569
  • Loading branch information
a-alferov committed Apr 10, 2023
2 parents a154b41 + 2c57861 commit d494240
Show file tree
Hide file tree
Showing 31 changed files with 102 additions and 47 deletions.
1 change: 1 addition & 0 deletions python/api/action/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class RunTask(GenericUIView):
queryset = TaskLog.objects.all()
serializer_class = RunTaskRetrieveSerializer
permission_classes = (IsAuthenticated,)
ordering = ["id"]

def has_action_perm(self, action: Action, obj) -> bool:
user = self.request.user
Expand Down
1 change: 1 addition & 0 deletions python/api/adcm/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class ADCMViewSet(ListModelMixin, RetrieveModelMixin, GenericUIViewSet):
queryset = ADCM.objects.select_related("prototype").all()
serializer_class = ADCMSerializer
lookup_url_kwarg = "adcm_pk"
ordering = ["id"]

def get_serializer_class(self):
if self.is_for_ui():
Expand Down
11 changes: 11 additions & 0 deletions python/api/cluster/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class ClusterList(PermissionListMixin, PaginatedView):
filterset_fields = ("name", "prototype_id")
ordering_fields = ("id", "name", "state", "prototype__display_name", "prototype__version_order")
permission_required = [VIEW_CLUSTER_PERM]
ordering = ["id"]

@audit
def post(self, request, *args, **kwargs): # pylint: disable=unused-argument
Expand All @@ -114,6 +115,7 @@ class ClusterDetail(PermissionListMixin, DetailView):
lookup_field = "id"
lookup_url_kwarg = "cluster_id"
error_code = "CLUSTER_NOT_FOUND"
ordering = ["id"]

@audit
def patch(self, request, *args, **kwargs): # pylint: disable=unused-argument
Expand Down Expand Up @@ -161,6 +163,7 @@ class ClusterImport(GenericUIView):
serializer_class = ImportSerializer
serializer_class_post = PostImportSerializer
permission_classes = (IsAuthenticated,)
ordering = ["id"]

@staticmethod
def get(request, *args, **kwargs): # pylint: disable=unused-argument
Expand Down Expand Up @@ -188,6 +191,7 @@ class ClusterBindList(GenericUIView):
serializer_class = ClusterBindSerializer
serializer_class_post = DoBindSerializer
permission_classes = (IsAuthenticated,)
ordering = ["id"]

def get(self, request, *args, **kwargs): # pylint: disable=unused-argument
cluster = get_object_for_user(request.user, VIEW_CLUSTER_PERM, Cluster, id=kwargs["cluster_id"])
Expand All @@ -210,6 +214,7 @@ class ClusterBindDetail(GenericUIView):
queryset = ClusterBind.objects.all()
serializer_class = BindSerializer
permission_classes = (IsAuthenticated,)
ordering = ["id"]

@staticmethod
def get_obj(kwargs, bind_id): # pylint: disable=unused-argument
Expand Down Expand Up @@ -241,6 +246,7 @@ class ClusterUpgrade(GenericUIView):
queryset = Upgrade.objects.all()
serializer_class = ClusterUpgradeSerializer
permission_classes = (IsAuthenticated,)
ordering = ["id"]

def get_ordering(self):
order = AdcmOrderingFilter()
Expand All @@ -260,6 +266,7 @@ class ClusterUpgradeDetail(GenericUIView):
queryset = Upgrade.objects.all()
serializer_class = ClusterUpgradeSerializer
permission_classes = (IsAuthenticated,)
ordering = ["id"]

def get(self, request, *args, **kwargs): # pylint: disable=unused-argument
cluster = get_object_for_user(request.user, VIEW_CLUSTER_PERM, Cluster, id=kwargs["cluster_id"])
Expand All @@ -274,6 +281,7 @@ class DoClusterUpgrade(GenericUIView):
queryset = Upgrade.objects.all()
serializer_class = DoClusterUpgradeSerializer
permission_classes = (IsAuthenticated,)
ordering = ["id"]

@audit
def post(self, request, *args, **kwargs): # pylint: disable=unused-argument
Expand Down Expand Up @@ -302,6 +310,7 @@ class StatusList(GenericUIView):
permission_classes = (IsAuthenticated,)
queryset = HostComponent.objects.all()
serializer_class = ClusterStatusSerializer
ordering = ["id"]

def get(self, request, *args, **kwargs): # pylint: disable=unused-argument
cluster = get_object_for_user(request.user, VIEW_CLUSTER_PERM, Cluster, id=kwargs["cluster_id"])
Expand All @@ -320,6 +329,7 @@ class HostComponentList(GenericUIView):
serializer_class_ui = HostComponentUISerializer
serializer_class_post = HostComponentSaveSerializer
permission_classes = (IsAuthenticated,)
ordering = ["id"]

def get(self, request, *args, **kwargs): # pylint: disable=unused-argument
cluster = get_object_for_user(request.user, VIEW_CLUSTER_PERM, Cluster, id=kwargs["cluster_id"])
Expand Down Expand Up @@ -358,6 +368,7 @@ class HostComponentDetail(GenericUIView):
queryset = HostComponent.objects.all()
serializer_class = HostComponentSerializer
permission_classes = (IsAuthenticated,)
ordering = ["id"]

def get_obj(self, cluster_id, hs_id):
cluster = get_object_for_user(self.request.user, VIEW_CLUSTER_PERM, Cluster, id=cluster_id)
Expand Down
6 changes: 5 additions & 1 deletion python/api/component/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class ComponentListView(PermissionListMixin, PaginatedView):
filterset_fields = ("cluster_id", "service_id")
ordering_fields = ("state", "prototype__display_name", "prototype__version_order")
permission_required = ["cm.view_servicecomponent"]
ordering = ["id"]

def get_queryset(self, *args, **kwargs):
queryset = super().get_queryset(*args, **kwargs)
Expand All @@ -76,6 +77,7 @@ class ComponentDetailView(PermissionListMixin, DetailView):
permission_required = ["cm.view_servicecomponent"]
lookup_url_kwarg = "component_id"
error_code = ServiceComponent.__error_code__
ordering = ["id"]

def get_queryset(self, *args, **kwargs):
queryset = super().get_queryset(*args, **kwargs)
Expand All @@ -89,6 +91,7 @@ class ComponentMaintenanceModeView(GenericUIView):
serializer_class = ComponentChangeMaintenanceModeSerializer
lookup_field = "id"
lookup_url_kwarg = "component_id"
ordering = ["id"]

@update_mm_objects
@audit
Expand All @@ -115,9 +118,10 @@ class StatusList(GenericUIView):
queryset = HostComponent.objects.all()
permission_classes = (permissions.IsAuthenticated,)
serializer_class = ComponentStatusSerializer
ordering = ["id"]

def get(self, request, *args, **kwargs): # pylint: disable=unused-argument
queryset = get_component_queryset(ServiceComponent.objects.all(), request.user, kwargs)
queryset = get_component_queryset(ServiceComponent.objects.order_by("id"), request.user, kwargs)
component = get_object_for_user(request.user, "cm.view_servicecomponent", queryset, id=kwargs["component_id"])
if self._is_for_ui():
host_components = self.get_queryset().filter(component=component)
Expand Down
2 changes: 2 additions & 0 deletions python/api/concern/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class ConcernItemList(PaginatedView):
permission_classes = (IsAuthenticated,)
filterset_class = ConcernFilter
ordering_fields = ("name",)
ordering = ["id"]


class ConcernItemDetail(DetailView):
Expand All @@ -106,3 +107,4 @@ class ConcernItemDetail(DetailView):
lookup_field = "id"
lookup_url_kwarg = "concern_id"
error_code = "CONCERNITEM_NOT_FOUND"
ordering = ["id"]
4 changes: 4 additions & 0 deletions python/api/config/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class ConfigView(GenericUIView):
queryset = ConfigLog.objects.all()
serializer_class = HistoryCurrentPreviousConfigSerializer
permission_classes = (IsAuthenticated,)
ordering = ["id"]

def get(self, request, *args, **kwargs): # pylint: disable=unused-argument
object_type, object_id, _ = get_object_type_id_version(**kwargs)
Expand All @@ -111,6 +112,7 @@ class ConfigHistoryView(PermissionListMixin, GenericUIView):
serializer_class = ConfigHistorySerializer
serializer_class_post = ObjectConfigUpdateSerializer
permission_required = ["cm.view_configlog"]
ordering = ["id"]

def get_queryset(self, *args, **kwargs):
if self.request.user.has_perm("cm.view_settings_of_adcm"):
Expand Down Expand Up @@ -146,6 +148,7 @@ class ConfigVersionView(PermissionListMixin, GenericUIView):
permission_classes = (DjangoOnlyObjectPermissions,)
serializer_class = ConfigObjectConfigSerializer
permission_required = ["cm.view_configlog"]
ordering = ["id"]

def get_queryset(self, *args, **kwargs):
if self.request.user.has_perm("cm.view_settings_of_adcm"):
Expand Down Expand Up @@ -189,6 +192,7 @@ class ConfigHistoryRestoreView(PermissionListMixin, GenericUIView):
serializer_class = ObjectConfigRestoreSerializer
permission_classes = (DjangoOnlyObjectPermissions,)
permission_required = ["cm.view_configlog"]
ordering = ["id"]

def get_queryset(self, *args, **kwargs):
if self.request.user.has_perm("cm.view_settings_of_adcm"):
Expand Down
1 change: 1 addition & 0 deletions python/api/config_log/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class ConfigLogViewSet( # pylint: disable=too-many-ancestors
permission_required = ["cm.view_configlog"]
filterset_fields = ("id", "obj_ref")
ordering_fields = ("id",)
ordering = ["id"]

def get_serializer_class(self):
if self.is_for_ui():
Expand Down
3 changes: 3 additions & 0 deletions python/api/group_config/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class GroupConfigHostViewSet(
permission_classes = (DjangoObjectPermissionsAudit,)
permission_required = ["view_host"]
lookup_url_kwarg = "host_id"
ordering = ["id"]

@audit
def create(self, request, *args, **kwargs):
Expand Down Expand Up @@ -165,6 +166,7 @@ class GroupConfigConfigViewSet(
serializer_class = GroupConfigConfigSerializer
permission_classes = (DjangoObjectPermissionsAudit,)
permission_required = ["view_objectconfig"]
ordering = ["id"]

def get_serializer_context(self):
context = super().get_serializer_context()
Expand Down Expand Up @@ -241,6 +243,7 @@ class GroupConfigViewSet(PermissionListMixin, NestedViewSetMixin, ModelViewSet):
filterset_class = GroupConfigFilterSet
permission_classes = (DjangoObjectPermissionsAudit,)
permission_required = ["cm.view_groupconfig"]
ordering = ["id"]

@audit
def create(self, request, *args, **kwargs):
Expand Down
10 changes: 7 additions & 3 deletions python/api/host/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,18 @@ class HostFilter(drf_filters.FilterSet):
cluster_is_null = drf_filters.BooleanFilter(field_name="cluster_id", lookup_expr="isnull")
provider_is_null = drf_filters.BooleanFilter(field_name="provider_id", lookup_expr="isnull")
group_config = drf_filters.ModelChoiceFilter(
queryset=GroupConfig.objects.all(),
queryset=GroupConfig.objects.order_by("id"),
field_name="group_config",
label="GroupConfig",
)
hostcomponent__service_id = drf_filters.ModelChoiceFilter(
queryset=ClusterObject.objects.all(),
queryset=ClusterObject.objects.order_by("id"),
field_name="hostcomponent__service_id",
label="HostComponentService",
distinct=True,
)
hostcomponent__component_id = drf_filters.ModelChoiceFilter(
queryset=ServiceComponent.objects.all(),
queryset=ServiceComponent.objects.order_by("id"),
field_name="hostcomponent__component_id",
label="HostComponentComponent",
distinct=True,
Expand Down Expand Up @@ -154,6 +154,7 @@ class HostList(PermissionListMixin, PaginatedView):
"prototype__display_name",
"prototype__version_order",
)
ordering = ["id"]

def get_queryset(self, *args, **kwargs):
queryset = super().get_queryset(*args, **kwargs)
Expand Down Expand Up @@ -229,6 +230,7 @@ class HostDetail(PermissionListMixin, DetailView):
lookup_field = "id"
lookup_url_kwarg = "host_id"
error_code = "HOST_NOT_FOUND"
ordering = ["id"]

def _update_host_object( # pylint: disable=unused-argument
self,
Expand Down Expand Up @@ -295,6 +297,7 @@ class HostMaintenanceModeView(GenericUIView):
serializer_class = HostChangeMaintenanceModeSerializer
lookup_field = "id"
lookup_url_kwarg = "host_id"
ordering = ["id"]

@update_mm_objects
@audit
Expand Down Expand Up @@ -322,6 +325,7 @@ class StatusList(GenericUIView):
queryset = HostComponent.objects.all()
permission_classes = (IsAuthenticated,)
serializer_class = HostStatusSerializer
ordering = ["id"]

def get(self, request, *args, **kwargs): # pylint: disable=unused-argument
cluster = None
Expand Down
1 change: 1 addition & 0 deletions python/api/job/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ class LogStorageViewSet(PermissionListMixin, ListModelMixin, RetrieveModelMixin,
ordering_fields = ("id", "name")
permission_required = ["cm.view_logstorage"]
lookup_url_kwarg = "log_pk"
ordering = ["id"]

def get_queryset(self, *args, **kwargs):
queryset = super().get_queryset(*args, **kwargs)
Expand Down
1 change: 1 addition & 0 deletions python/api/object_config/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ObjectConfigViewSet(PermissionListMixin, ReadOnlyModelViewSet): # pylint:
serializer_class = ObjectConfigSerializer
permission_classes = (DjangoObjectPermissions,)
permission_required = ["cm.view_objectconfig"]
ordering = ["id"]

def get_queryset(self, *args, **kwargs):
if self.request.user.has_perm("cm.view_settings_of_adcm"):
Expand Down
5 changes: 5 additions & 0 deletions python/api/provider/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class ProviderList(PermissionListMixin, PaginatedView):
filterset_fields = ("name", "prototype_id")
ordering_fields = ("id", "name", "state", "prototype__display_name", "prototype__version_order")
permission_required = ["cm.view_hostprovider"]
ordering = ["id"]

@audit
def post(self, request, *args, **kwargs): # pylint: disable=unused-argument
Expand All @@ -76,6 +77,7 @@ class ProviderDetail(PermissionListMixin, DetailView):
lookup_field = "id"
lookup_url_kwarg = "provider_id"
error_code = "PROVIDER_NOT_FOUND"
ordering = ["id"]

@audit
def delete(self, request, *args, **kwargs): # pylint: disable=unused-argument
Expand All @@ -94,6 +96,7 @@ class ProviderUpgrade(GenericUIView):
serializer_class = ProviderUpgradeSerializer
permission_classes = (permissions.IsAuthenticated,)
filter_backends = (AdcmFilterBackend, AdcmOrderingFilter)
ordering = ["id"]

def get_ordering(self):
order = AdcmOrderingFilter()
Expand All @@ -118,6 +121,7 @@ class ProviderUpgradeDetail(GenericUIView):
queryset = Upgrade.objects.all()
serializer_class = ProviderUpgradeSerializer
permission_classes = (permissions.IsAuthenticated,)
ordering = ["id"]

def get(self, request, *args, **kwargs): # pylint: disable=unused-argument
"""
Expand All @@ -136,6 +140,7 @@ class DoProviderUpgrade(GenericUIView):
queryset = Upgrade.objects.all()
serializer_class = DoProviderUpgradeSerializer
permission_classes = (permissions.IsAuthenticated,)
ordering = ["id"]

@audit
def post(self, request, *args, **kwargs): # pylint: disable=unused-argument
Expand Down
7 changes: 7 additions & 0 deletions python/api/service/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class ServiceListView(PermissionListMixin, PaginatedView):
serializer_class_cluster = ClusterServiceSerializer
filterset_fields = ("cluster_id",)
ordering_fields = ("id", "state", "prototype__display_name", "prototype__version_order")
ordering = ["id"]

def get(self, request, *args, **kwargs):
queryset = self.get_queryset()
Expand Down Expand Up @@ -106,6 +107,7 @@ class ServiceDetailView(PermissionListMixin, DetailView):
lookup_url_kwarg = "service_id"
permission_required = ["cm.view_clusterobject"]
error_code = ClusterObject.__error_code__
ordering = ["id"]

def get_queryset(self, *args, **kwargs):
queryset = super().get_queryset(*args, **kwargs)
Expand Down Expand Up @@ -173,6 +175,7 @@ class ServiceMaintenanceModeView(GenericUIView):
serializer_class = ServiceChangeMaintenanceModeSerializer
lookup_field = "id"
lookup_url_kwarg = "service_id"
ordering = ["id"]

@update_mm_objects
@audit
Expand All @@ -194,6 +197,7 @@ class ServiceImportView(GenericUIView):
serializer_class = ImportSerializer
serializer_class_post = ImportPostSerializer
permission_classes = (permissions.IsAuthenticated,)
ordering = ["id"]

@staticmethod
def get(request, *args, **kwargs): # pylint: disable=unused-argument
Expand Down Expand Up @@ -223,6 +227,7 @@ class ServiceBindView(GenericUIView):
serializer_class = ServiceBindSerializer
serializer_class_post = ServiceBindPostSerializer
permission_classes = (permissions.IsAuthenticated,)
ordering = ["id"]

def get(self, request, *args, **kwargs): # pylint: disable=unused-argument
service = get_object_for_user(request.user, "cm.view_clusterobject", ClusterObject, id=kwargs["service_id"])
Expand All @@ -246,6 +251,7 @@ class ServiceBindDetailView(GenericUIView):
queryset = ClusterBind.objects.all()
serializer_class = BindSerializer
permission_classes = (permissions.IsAuthenticated,)
ordering = ["id"]

def get_obj(self, kwargs, bind_id):
service = get_object_for_user(
Expand Down Expand Up @@ -278,6 +284,7 @@ class StatusList(GenericUIView):
permission_classes = (permissions.IsAuthenticated,)
queryset = HostComponent.objects.all()
serializer_class = ServiceStatusSerializer
ordering = ["id"]

def get(self, request, *args, **kwargs): # pylint: disable=unused-argument
service = get_object_for_user(request.user, "cm.view_clusterobject", ClusterObject, id=kwargs["service_id"])
Expand Down
Loading

0 comments on commit d494240

Please sign in to comment.