~ubuntu-branches/ubuntu/quantal/nova/quantal-proposed

« back to all changes in this revision

Viewing changes to nova/policy.py

  • Committer: Package Import Robot
  • Author(s): Adam Gandelman, Adam Gandelman, Chuck Short
  • Date: 2012-08-27 15:37:18 UTC
  • mfrom: (1.1.60)
  • Revision ID: package-import@ubuntu.com-20120827153718-lj8er44eqqz1gsrj
Tags: 2012.2~rc1~20120827.15815-0ubuntu1
[ Adam Gandelman ]
* New upstream release.

[ Chuck Short ]
* debian/patches/0001-Update-tools-hacking-for-pep8-1.2-and-
  beyond.patch: Dropped we dont run pep8 tests anymore.
* debian/control: Drop pep8 build depends
* debian/*.upstart.in: Make sure we transition correctly from runlevel
  1 to 2. (LP: #820694)

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
    match_list = ('rule:%s' % action,)
91
91
    credentials = context.to_dict()
92
92
 
 
93
    # NOTE(vish): This is to work around the following launchpad bug:
 
94
    #             https://bugs.launchpad.net/openstack-common/+bug/1039132
 
95
    #             It can be removed when that bug is fixed.
 
96
    credentials['is_admin'] = unicode(credentials['is_admin'])
 
97
 
93
98
    policy.enforce(match_list, target, credentials,
94
99
                   exception.PolicyNotAuthorized, action=action)
 
100
 
 
101
 
 
102
def check_is_admin(roles):
 
103
    """Whether or not roles contains 'admin' role according to policy setting.
 
104
 
 
105
    """
 
106
    init()
 
107
 
 
108
    action = 'context_is_admin'
 
109
    match_list = ('rule:%s' % action,)
 
110
    target = {}
 
111
    credentials = {'roles': roles}
 
112
 
 
113
    try:
 
114
        policy.enforce(match_list, target, credentials,
 
115
                       exception.PolicyNotAuthorized, action=action)
 
116
    except exception.PolicyNotAuthorized:
 
117
        return False
 
118
 
 
119
    return True