Comments (3)
Good catch:
This would be my patch suggestion. I would add a condition for the vm['state'], (I am unsure if the state of a destroyed VM is destroyed
or removed
):
diff --git a/cloudstack_vm.py b/cloudstack_vm.py
index bcfee85..0ee4cda 100644
--- a/cloudstack_vm.py
+++ b/cloudstack_vm.py
@@ -445,11 +445,26 @@ def remove_vm(module, cs, result, vm):
def expunge_vm(module, cs, result, vm):
if vm:
- if not module.check_mode:
- res = cs.expungeVirtualMachine(id=vm['id'])
- if 'errortext' in res:
- module.fail_json(msg="Failed: '%s'" % res['errortext'])
- result['changed'] = True
+ res = {}
+ # TODO: Is the state destroyed or removed?
+ if vm['state'] in [ 'destroying', 'destroyed']:
+ result['changed'] = True
+ if not module.check_mode:
+ res = cs.expungeVirtualMachine(id=vm['id'])
+
+ # TODO: Would we ever see a vm state expunged?
+ elif vm['state'] not in ['expunging', 'expunged' ]:
+ result['changed'] = True
+ if not module.check_mode:
+ res = cs.destroyVirtualMachine(id=vm['id'], expunge=True)
+
+ if res and 'errortext' in res:
+ module.fail_json(msg="Failed: '%s'" % res['errortext'])
+
+ poll_async = module.params.get('poll_async')
+ if poll_async:
+ vm = poll_job(cs, res, 'virtualmachine')
+
return (result, vm)
from ansible-cloudstack.
Answer: Destroyed
Answer: Expunging, then null
from ansible-cloudstack.
implemented
from ansible-cloudstack.
Related Issues (20)
- URL encode doesn't work?! HOT 4
- cloudstack_sshkey error HOT 1
- How to get a module reference of the HTML HOT 1
- cloudstack_vm ipaddress, networkids, iptonetworklist, addnictovirtualmachine HOT 1
- sshkeypair not checking finger print HOT 4
- cs_virtualmachine.py get_vm method not checking zone HOT 2
- are we going to handle egress rule as in listEgressFirewallRules etc. HOT 3
- Issue with staticnat and CloudStack 4.5: NameError: global name 'AnsibleCloudStackPortforwarding' is not defined HOT 2
- Multiple environments HOT 1
- "No networks available" error HOT 2
- VPC support in the wild
- Time out with maximum retries reached HOT 2
- Ansible does not fail when an ISO cannot be removed
- cs_loadbalancer_rule_member fails when rules have similar names
- Add support for generating additional groups based on hostname
- Userdata support in cloudstack_vm HOT 5
- Problem specifying disk size on exoscale HOT 1
- skip creating sec group if already created HOT 3
- Add tag support HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansible-cloudstack.