diff options
| author | Chris Behrens <cbehrens@codestud.com> | 2010-08-16 15:56:28 -0500 |
|---|---|---|
| committer | Chris Behrens <cbehrens@codestud.com> | 2010-08-16 15:56:28 -0500 |
| commit | ad7a20231a8fb11bf7c75f2e180735e2de450102 (patch) | |
| tree | d22caa69a8fc66da6b33636299be83e962786e87 /nova/adminclient.py | |
| parent | d1982a50561f7b35ffc76ce5d45aaec11e76a23c (diff) | |
| parent | b07a85167ffde07747fc6e892df46686b95529e8 (diff) | |
merge from trunk
Diffstat (limited to 'nova/adminclient.py')
| -rw-r--r-- | nova/adminclient.py | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/nova/adminclient.py b/nova/adminclient.py index 25d5e71cb..242298a75 100644 --- a/nova/adminclient.py +++ b/nova/adminclient.py @@ -57,6 +57,28 @@ class UserInfo(object): elif name == 'secretkey': self.secretkey = str(value) +class UserRole(object): + """ + Information about a Nova user's role, as parsed through SAX. + Fields include: + role + """ + def __init__(self, connection=None): + self.connection = connection + self.role = None + + def __repr__(self): + return 'UserRole:%s' % self.role + + def startElement(self, name, attrs, connection): + return None + + def endElement(self, name, value, connection): + if name == 'role': + self.role = value + else: + setattr(self, name, str(value)) + class ProjectInfo(object): """ Information about a Nova project, as parsed through SAX @@ -114,7 +136,6 @@ class ProjectMember(object): else: setattr(self, name, str(value)) - class HostInfo(object): """ Information about a Nova Host, as parsed through SAX: @@ -196,6 +217,24 @@ class NovaAdminClient(object): """ deletes a user """ return self.apiconn.get_object('DeregisterUser', {'Name': username}, UserInfo) + def get_roles(self, project_roles=True): + """Returns a list of available roles.""" + return self.apiconn.get_list('DescribeRoles', + {'ProjectRoles': project_roles}, + [('item', UserRole)]) + + def get_user_roles(self, user, project=None): + """Returns a list of roles for the given user. + Omitting project will return any global roles that the user has. + Specifying project will return only project specific roles. + """ + params = {'User':user} + if project: + params['Project'] = project + return self.apiconn.get_list('DescribeUserRoles', + params, + [('item', UserRole)]) + def add_user_role(self, user, role, project=None): """ Add a role to a user either globally or for a specific project. |
