hardware/cmdb.py: manage error using exceptions
fix import to be compatible with python 3
added state.py