Add validation when setting peers

- cannot peer to self
- cannot peer to instance that is already peered to self

Other changes:
- ReceptorAddress protocol field restricted to choices: tcp, ws, wss
- fix awx-manage list_instances when instance.last_seen is None
- InstanceLink make source and target unique together
- Add help text to the ReceptorAddress fields

Signed-off-by: Seth Foster <fosterbseth@gmail.com>
This commit is contained in:
Seth Foster
2023-11-13 11:58:05 -05:00
committed by Seth Foster
parent 7d7503279d
commit 5385eb0fb3
5 changed files with 59 additions and 18 deletions

View File

@@ -6,6 +6,7 @@ import logging
import os
from django.core.validators import MinValueValidator, MaxValueValidator
from django.core.exceptions import ValidationError
from django.db import models, connection
from django.db.models.signals import post_save, post_delete
from django.dispatch import receiver
@@ -67,6 +68,7 @@ class HasPolicyEditsMixin(HasEditsMixin):
class InstanceLink(BaseModel):
class Meta:
ordering = ("id",)
constraints = [models.UniqueConstraint(fields=['source', 'target'], name='source_target_unique_together')]
source = models.ForeignKey('Instance', on_delete=models.CASCADE)
target = models.ForeignKey('ReceptorAddress', on_delete=models.CASCADE)