Follow up on new execution node creation

- hop nodes are descoped
- links need to be created on execution node creation
- expose the 'edit' capabilities on the instance serializer
This commit is contained in:
Jeff Bradberry
2022-08-30 12:12:03 -04:00
parent dba03616f4
commit 3bc86ca8cb
4 changed files with 9 additions and 8 deletions

View File

@@ -369,7 +369,9 @@ class InstanceList(ListCreateAPIView):
ordering = ('id',)
def perform_create(self, serializer):
serializer.save(node_state=models.Instance.States.INSTALLED)
obj = serializer.save(node_state=models.Instance.States.INSTALLED)
for instance in models.Instance.objects.filter(node_type__in=[models.Instance.Types.CONTROL, models.Instance.Types.HYBRID]):
models.InstanceLink.objects.create(source=instance, target=obj, link_state=models.InstanceLink.States.ADDING)
class InstanceDetail(RetrieveUpdateAPIView):
@@ -384,8 +386,6 @@ class InstanceDetail(RetrieveUpdateAPIView):
obj = self.get_object()
obj.set_capacity_value()
obj.save(update_fields=['capacity'])
for instance in models.Instance.objects.filter(node_type__in=['control', 'hybrid']):
models.InstanceLink.objects.create(source=instance, target=obj)
r.data = serializers.InstanceSerializer(obj, context=self.get_serializer_context()).to_representation(obj)
return r