ScaleComputing / HyperCoreAnsibleCollection

Official Ansible collection for Scale Computing SC//HyperCore (HC3) v1 API
GNU General Public License v3.0
12 stars 8 forks source link

VM rename test and fix #122

Closed justinc1 closed 1 year ago

justinc1 commented 1 year ago

Integration test is added to show that renaming VM a second time (idempotence test) does fail in current main. Problem is (in most places) we search for VM by vm_name only, but we should by vm_name xor vm_name_new. A helper function VM.get_by_old_or_new_name does this, and is used in VM module.

PR was draft:

But there is enough code for first review and comments

justinc1 commented 1 year ago

Unit test problems with TestManageVMDisks - I didn't check why I have problems with TestManageVMNics, but not with TestManageVMDisks. At first look, those two tests are not that much different.

justinc1 commented 1 year ago

One more note, there is problem in VM.str() implementation. It will push branch problem-with-power-state-mapping, to show this. It seems to me that we store in VM.power_state both VM power_state as retrieved from HyperCore, and sometimes also power_state as set in ansible module. But ansible power_state is actually a command describing transition to HyperCore power_state, not HyperCore power_state (e.g. you can get into SHUTOFF state by nice shutdown or by force shutdown - two different actions, same end state).

I noticed this only because I added debug module.warn. Module was not misbehaving.

It would be a bit of extra work and testing, so I just added a small workaround to not throw this error to module users.