Update API to support setting instances to Deprovisioning

- allow the node_state to be set to deprovisioning
- set the links that touch the instance to removing
- only allow on K8S
- only allow to be done to execution nodes
This commit is contained in:
Jeff Bradberry
2022-08-26 14:27:36 -04:00
parent 0b1891d82a
commit b6946c7e35
2 changed files with 19 additions and 1 deletions

View File

@@ -384,6 +384,9 @@ class InstanceDetail(RetrieveUpdateAPIView):
r = super(InstanceDetail, self).update(request, *args, **kwargs)
if status.is_success(r.status_code):
obj = self.get_object()
if obj.node_state == models.Instance.States.DEPROVISIONING:
models.InstanceLink.objects.filter(target=obj).update(link_state=models.InstanceLink.States.REMOVING)
models.InstanceLink.objects.filter(source=obj).update(link_state=models.InstanceLink.States.REMOVING)
obj.set_capacity_value()
obj.save(update_fields=['capacity'])
r.data = serializers.InstanceSerializer(obj, context=self.get_serializer_context()).to_representation(obj)