Sync functions-common from devstack

This is a sync of functions-common from devstack, which has had multiple
fixes applied to workaround various breakages introduced by new pip.

Related-bug: #1405626

Change-Id: Ie957726c606a0f63f35629c0616155b102983d7e