Skip to content

Commit

Permalink
Remove deprecated permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
elias-boulharts authored and Sispheor committed Sep 6, 2023
1 parent 3ceefde commit e4d4841
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
11 changes: 11 additions & 0 deletions service_catalog/migrations/0019_auto_20230804_1516.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
import django.db.models.deletion


deprecated_permission = ["request_operation_on_instance", "request_support_on_instance", "cancel_request",
"comment_request", "approve_request_approvalstep"]


def remove_deprecated_permissions(apps, schema_editor):
Permission = apps.get_model('profiles', 'Permission')
Permission.objects.filter(codename__in=deprecated_permission).delete()


class Migration(migrations.Migration):

dependencies = [
Expand All @@ -13,6 +22,8 @@ class Migration(migrations.Migration):
]

operations = [
migrations.RunSQL("DROP TABLE IF EXISTS guardian_userobjectpermission"),
migrations.RunPython(remove_deprecated_permissions),
migrations.AlterModelOptions(
name='instance',
options={'default_permissions': ('add', 'change', 'delete', 'view', 'list'), 'ordering': ['-last_updated'], 'permissions': [('archive_instance', 'Can archive instance'), ('unarchive_instance', 'Can unarchive instance'), ('request_on_instance', 'Can request a day2 operation on instance'), ('admin_request_on_instance', 'Can request an admin day2 operation on instance'), ('view_admin_spec_instance', 'Can view admin spec on instance'), ('change_admin_spec_instance', 'Can change admin spec on instance')]},
Expand Down
8 changes: 4 additions & 4 deletions service_catalog/models/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def check_job_status(self):
from ..mail_utils import send_mail_request_update
if self.tower_job_id is None:
logger.warning(
f"[Request][check_job_status] no tower job id for request id {self.id}. Check job status skipped")
f"[Request][check_job_status] no RHAAP/AWX job id for request id {self.id}. Check job status skipped")
return

# if the task is expired we remove the periodic task
Expand All @@ -283,9 +283,9 @@ def check_job_status(self):

tower = self.operation.job_template.tower_server.get_tower_instance()
job_object = tower.get_unified_job_by_id(self.tower_job_id)

logger.info(f"[Request][check_job_status] status of Job #{self.tower_job_id}: {job_object.status}")
if job_object.status == "successful":
logger.info(f"[Request][check_job_status] tower job status successful for request id {self.id}")
logger.info(f"[Request][check_job_status] RHAAP/AWX job status successful for request id {self.id}")
self.complete()
self.save()
self.periodic_task.delete()
Expand All @@ -301,7 +301,7 @@ def check_job_status(self):
send_mail_request_update(target_request=self)

if job_object.status in ["canceled", "failed"]:
error_message = f"Tower job {self.tower_job_id} status is '{job_object.status}'"
error_message = f"RHAAP/AWX job {self.tower_job_id} status is '{job_object.status}'"
self.has_failed(error_message)
self.save()
self.periodic_task.delete()
Expand Down

0 comments on commit e4d4841

Please sign in to comment.