There should be at most one `HardwareToChassis` with a given `hardware_type` and `hardware_id`, so you should be able to simplify this a little by using cqlengine's `get()` query method.