kubevirt_vm: simplify previous change + update comments (#56897)
This commit is contained in:
parent
d88d71e4b1
commit
f65df9189e
1 changed files with 5 additions and 3 deletions
|
@ -405,16 +405,18 @@ class KubeVirtVM(KubeVirtRawModule):
|
|||
if our_state != 'absent':
|
||||
self.params['state'] = k8s_state = 'present'
|
||||
|
||||
# Start with fetching the current object to make sure it exists
|
||||
# If it does, but we end up not performing any operations on it, at least we'll be able to return
|
||||
# its current contents as part of the final json
|
||||
self.client = self.get_api_client()
|
||||
self._kind_resource = self.find_supported_resource(kind)
|
||||
k8s_obj = self.get_resource(self._kind_resource)
|
||||
if not self.check_mode and not vm_spec_change and k8s_state != 'absent' and not k8s_obj:
|
||||
self.fail("It's impossible to create an empty VM or change state of a non-existent VM.")
|
||||
|
||||
# Changes in VM's spec or any changes to VMIs warrant a full CRUD, the latter because
|
||||
# VMIs don't really have states to manage; they're either present or don't exist
|
||||
# If there are (potential) changes to `spec:` or we want to delete the object, that warrants a full CRUD
|
||||
# Also check_mode always warrants a CRUD, as that'll produce a sane result
|
||||
if vm_spec_change or (ephemeral and vm_spec_change) or k8s_state == 'absent' or self.check_mode:
|
||||
if vm_spec_change or k8s_state == 'absent' or self.check_mode:
|
||||
definition = self.construct_definition(kind, our_state, ephemeral)
|
||||
result = self.execute_crud(kind, definition)
|
||||
changed = result['changed']
|
||||
|
|
Loading…
Reference in a new issue