Pass and use the environment in validate_template

Use the environment passed in validate_template to be able to validate
template using custom resources.

Change-Id: I85e23f26f5abbafe50073c3ac023933316af05ac
Closes-Bug: #1298450
Cherry pick oslo rpc HA fixes

Get 2 commits from oslo-rpc fixing HA failover:

* Ia148baa6e1ec632789ac3621c85173c2c16f3918 (fixed HA failover, Qpid
 part)
* I67923cb024bbd143edc8edccf35b9b400df31eb3 (fixed HA failover, RabbitMQ
 part)

Change-Id: I45f679f3da720a0c28fb552d9f4cfb3d8bd21c20
Closes-Bug: #1261631
Merge "Cherry pick oslo rpc HA fixes"
Merge "Pass and use the environment in validate_template"