First functional version (rewritten strongly inspired from vmware.py instead)