Adding the prep_cache_dir function

Adding the prep_cache_dir function from the
https://review.openstack.org/#/c/74297.

Change-Id: I9b725608fb76406192481e258b00ae822531d16e
Merge "Adding the prep_cache_dir function"