Fix query option use in HardwareEntity.get_unique()
Fix query option use in HardwareEntity.get_unique()

We need to run the query against the appropriate class in order to be
able to use options for attributes not defined in the base class.  Since
we still want to detect when the name already exists but belongs to a
different hardware type, we must do two queries: one against the child
class to make sure Query.options() work correctly, and one against
HardwareEntity if the first one failed.

As a side effect, make sure that the primary name is not loaded eagerly
when we already know it.

Reviewed-By: Zoltan Sebestyen <be2314d0afde2d2352aeb623a228e572c9b6cb8b@morganstanley.com>

guillaume-philippon/aquilon,stdweird/aquilon,quattor/aquilon,quattor/aquilon,stdweird/aquilon,guillaume-philippon/aquilon,guillaume-philippon/aquilon,quattor/aquilon,stdweird/aquilon