diff --git a/glance/openstack/common/policy.py b/glance/openstack/common/policy.py index 8bb77be810..0b441f7792 100644 --- a/glance/openstack/common/policy.py +++ b/glance/openstack/common/policy.py @@ -57,6 +57,7 @@ as it allows particular rules to be explicitly disabled. """ import abc +import ast import re import urllib @@ -775,6 +776,13 @@ class GenericCheck(Check): # TODO(termie): do dict inspection via dot syntax match = self.match % target - if self.kind in creds: - return match == six.text_type(creds[self.kind]) - return False + + try: + # Try to interpret self.kind as a literal + leftval = ast.literal_eval(self.kind) + except ValueError: + try: + leftval = creds[self.kind] + except KeyError: + return False + return match == six.text_type(leftval)