support hardcoded suspend plan for exoscale
All checks were successful
Tests / test (push) Successful in 27s

This commit is contained in:
Tobias Brunner 2025-11-17 11:48:19 +01:00
parent 208f3c357d
commit 3e17e03da9
Signed by: tobru
SSH key fingerprint: SHA256:kOXg1R6c11XW3/Pt9dbLdQvOJGFAy+B2K6v6PtRWBGQ

View file

@ -233,9 +233,12 @@ The Servala Team"""
try: try:
service = Service.objects.get(osb_service_id=service_id) service = Service.objects.get(osb_service_id=service_id)
service_offering = ServiceOffering.objects.get( # Special handling: when plan_id is "suspend", don't lookup service_offering
osb_plan_id=plan_id, service=service service_offering = None
) if plan_id != "suspend":
service_offering = ServiceOffering.objects.get(
osb_plan_id=plan_id, service=service
)
except Service.DoesNotExist: except Service.DoesNotExist:
return self._error(f"Unknown service_id: {service_id}") return self._error(f"Unknown service_id: {service_id}")
except ServiceOffering.DoesNotExist: except ServiceOffering.DoesNotExist:
@ -258,7 +261,7 @@ The Servala Team"""
return self.request.build_absolute_uri(admin_path) return self.request.build_absolute_uri(admin_path)
def _create_action_helpdesk_ticket( def _create_action_helpdesk_ticket(
self, request, action, instance_id, service, service_offering, users=None self, request, action, instance_id, service, service_offering=None, users=None
): ):
""" """
Create an Odoo helpdesk ticket for offboarding or suspension actions. Create an Odoo helpdesk ticket for offboarding or suspension actions.
@ -269,11 +272,12 @@ The Servala Team"""
organization = None organization = None
try: try:
# Look for instances with this name in the service offering's context # Look for instances with this name in the service offering's context
filter_kwargs = {"name": instance_id}
if service_offering:
filter_kwargs["context__service_offering"] = service_offering
service_instance = ( service_instance = (
ServiceInstance.objects.filter( ServiceInstance.objects.filter(**filter_kwargs)
name=instance_id,
context__service_offering=service_offering,
)
.select_related("organization") .select_related("organization")
.first() .first()
) )
@ -302,10 +306,11 @@ The Servala Team"""
else: else:
description_parts.append(f"Instance: {instance_id}") description_parts.append(f"Instance: {instance_id}")
offering_url = self._get_admin_url( if service_offering:
"core_serviceoffering_change", service_offering.pk offering_url = self._get_admin_url(
) "core_serviceoffering_change", service_offering.pk
description_parts.append(f"Service Offering: {offering_url}") )
description_parts.append(f"Service Offering: {offering_url}")
if users: if users:
description_parts.append("<br/>Users:") description_parts.append("<br/>Users:")