os_nova_host_aggregate - Fix aggregate delete with hosts (#53166)

Aggregate delete task will fail in case it has hosts within the aggregate.
As by the OpenStack, the hosts should be removed from the aggregate
prior aggregate delete.

Add remove host in case provided.
This commit is contained in:
Maxim Babushkin 2019-05-09 19:38:29 +03:00 committed by ansibot
parent 46c44a4359
commit 45ee165fcd

View file

@ -167,6 +167,9 @@ def main():
if aggregate is None:
changed = False
else:
if hosts:
for h in hosts:
cloud.remove_host_from_aggregate(aggregate.id, h)
cloud.delete_aggregate(aggregate.id)
changed = True
module.exit_json(changed=changed)