On second thought, are you running this script directly in dom0?
This script meant to be run in app qube, not in dom0.