rcbops-cookbooks/glance — pull request #117 by git-harry (2013-04-05 08:33:34+00:00)
Title: Comments in policy.json cause error in glance.

The glance package should create /etc/glance/policy.json when installed and so in general the version provided by this cookbook is not used. However is causes an error if used which this commit resolves.

/etc/glance/policy.json cannot be loaded if there are comments in the file, it must only contain JSON.

The exception raised is:
File "/usr/lib/python2.7/dist-packages/routes/middleware.py", line 132, in __call__
response = self.app(environ, start_response)
File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 159, in __call__
return resp(environ, start_response)
File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 147, in __call__
resp = self.call_func(req, *args, **self.kwargs)
File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 210, in call_func
return self.func(req, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/glance/common/wsgi.py", line 532, in __call__
request, **action_args)
File "/usr/lib/python2.7/dist-packages/glance/common/wsgi.py", line 549, in dispatch
return method(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/glance/api/v1/images.py", line 200, in detail
self._enforce(req, 'get_images')
File "/usr/lib/python2.7/dist-packages/glance/api/v1/images.py", line 140, in _enforce
self.policy.enforce(req.context, action, {})
File "/usr/lib/python2.7/dist-packages/glance/api/policy.py", line 102, in enforce
self.load_rules()
File "/usr/lib/python2.7/dist-packages/glance/api/policy.py", line 62, in load_rules
rules = self._read_policy_file()
File "/usr/lib/python2.7/dist-packages/glance/api/policy.py", line 89, in _read_policy_file
self.policy_file_contents = json.loads(raw_contents)
File "/usr/lib/python2.7/json/__init__.py", line 326, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
raise ValueError("No JSON object could be decoded")

This commit enforces the policy.json file defined by chef and does not allow a customised local version to be maintained. It also removes the comments from the policy.json file.

Fixes #110