Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions plugins/modules/cml_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
version_added: '0.1.0'
options:
state:
description: The desired state of the node
description: The desired state of the node. Started, stopped and wiped are only state changes and require existing node.
required: false
type: str
choices: ['absent', 'present', 'started', 'stopped', 'wiped']
Expand Down Expand Up @@ -159,26 +159,20 @@ def run_module():
if node is None:
cml.fail_json("Node must be created before it is started")
if node.state not in ['STARTED', 'BOOTED']:
if node.state == 'DEFINED_ON_CORE' and cml.params['config']:
node.config = cml.params['config']
if cml.params['image_definition']:
node.image_definition = cml.params['image_definition']
if cml.params['wait'] is False:
lab.wait_for_covergence = False
node.start()
node.start(wait=cml.params['wait'])
cml.result['changed'] = True
elif cml.params['state'] == 'stopped':
if node is None:
cml.fail_json("Node must be created before it is stopped")
if node.state not in ['STOPPED', 'DEFINED_ON_CORE']:
if cml.params['wait'] is False:
lab.wait_for_covergence = False
node.stop()
node.stop(wait=cml.params['wait'])
cml.result['changed'] = True
elif cml.params['state'] == 'wiped':
if node is None:
cml.fail_json("Node must be created before it is wiped")
if node.state not in ['DEFINED_ON_CORE']:
if node.state != 'DEFINED_ON_CORE':
if node.state in ['STARTED', 'BOOTED']:
node.stop(wait=cml.params['wait'])
node.wipe(wait=cml.params['wait'])
cml.result['changed'] = True
cml.exit_json(**cml.result)
Expand Down