mirror of
https://github.com/ansible/awx.git
synced 2026-02-19 12:10:06 -03:30
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user