If the `pyvmomi` library is missing, all tests from the
tests.unit.modules.RemoveCapacityFromDiskgroupTestCase will fail:
```
ERROR: test__get_proxy_target_call
(unit.modules.test_vsphere.RemoveCapacityFromDiskgroupTestCase)
[CPU:0.0%|MEM:35.1%]
----------------------------------------------------------------------
Traceback (most recent call last):
File "salt/utils/vmware.py", line 485, in disconnect
Disconnect(service_instance)
NameError: name 'Disconnect' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "salt/modules/vsphere.py", line 381, in _gets_service_instance_via_proxy
salt.utils.vmware.disconnect(local_service_instance)
File "salt/utils/vmware.py", line 486, in disconnect
except vim.fault.NoPermission as exc:
NameError: name 'vim' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "salt/utils/vmware.py", line 485, in disconnect
Disconnect(service_instance)
NameError: name 'Disconnect' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "tests/unit/modules/test_vsphere.py", line 1568, in test__get_proxy_target_call
capacity_disk_ids=['fake_disk1', 'fake_disk2'])
File "salt/modules/vsphere.py", line 295, in __supports_proxies
return fn(*args, **salt.utils.args.clean_kwargs(**kwargs))
File "salt/modules/vsphere.py", line 386, in _gets_service_instance_via_proxy
salt.utils.vmware.disconnect(local_service_instance)
File "/home/bdrung/projects/salt/debian/salt/utils/vmware.py", line 486, in disconnect
except vim.fault.NoPermission as exc:
NameError: name 'vim' is not defined
```
Signed-off-by: Benjamin Drung <benjamin.drung@cloud.ionos.com>
pepa.key_value_to_tree only checks the name of the key when attempting
to identify the last key in a flattened key. This can lead to strange
behavior when the final key name also occurs earlier in the flatkey.
This change explicitly checks that we are the final key in flatkey
prior to setting value. Test included.
Also see mickep76/pepa#11 and mickep76/pepa#12