Refactor loguserdata.py so it can be tested.

- Use distutils.version.LooseVersion for cloud-init version check
- Fix bug 1100287 by setting the following modes:
  - 0600 /var/log/heat-provision.log
  - 0700 /var/lib/heat
  - 0700 /var/lib/cloud/data/cfn-userdata (was 0111!)
- Full test coverage except for where __name__ == '__main__'
- File size has gone from 1218 bytes to 1636. If necessary we could reduce size in the future by using short names

This works for me when launching a template. At least if there are any regressions they can have a test written for the fix.
Change-Id: I04e773a743ec210e90394e50d2bb70c70664e80e
Merge "Refactor loguserdata.py so it can be tested."