diff options
| author | jaypipes@gmail.com <> | 2010-08-30 10:36:59 -0400 |
|---|---|---|
| committer | jaypipes@gmail.com <> | 2010-08-30 10:36:59 -0400 |
| commit | a1791cdca8dbca8f9bf3555b21324503aba58fda (patch) | |
| tree | 12f297f1616172ca7e4bce76ecac1dcd737c83af /nova/adminclient.py | |
| parent | bf2549282067a7a824ea97e66a5b2f0ca06416bd (diff) | |
| parent | 5f14a7955b9ef90afed91bda0343130d83e15a73 (diff) | |
| download | nova-a1791cdca8dbca8f9bf3555b21324503aba58fda.tar.gz nova-a1791cdca8dbca8f9bf3555b21324503aba58fda.tar.xz nova-a1791cdca8dbca8f9bf3555b21324503aba58fda.zip | |
Resolve conflicts and merge trunk
Diffstat (limited to 'nova/adminclient.py')
| -rw-r--r-- | nova/adminclient.py | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/nova/adminclient.py b/nova/adminclient.py index 25d5e71cb..0ca32b1e5 100644 --- a/nova/adminclient.py +++ b/nova/adminclient.py @@ -20,6 +20,7 @@ Nova User API client library. """ import base64 + import boto from boto.ec2.regioninfo import RegionInfo @@ -57,6 +58,30 @@ 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 @@ -92,12 +117,14 @@ class ProjectInfo(object): else: setattr(self, name, str(value)) + class ProjectMember(object): """ Information about a Nova project member, as parsed through SAX. Fields include: memberId """ + def __init__(self, connection=None): self.connection = connection self.memberId = None @@ -113,8 +140,8 @@ class ProjectMember(object): self.memberId = value else: setattr(self, name, str(value)) - + class HostInfo(object): """ Information about a Nova Host, as parsed through SAX: @@ -142,6 +169,7 @@ class HostInfo(object): def endElement(self, name, value, connection): setattr(self, name, value) + class NovaAdminClient(object): def __init__(self, clc_ip='127.0.0.1', region='nova', access_key='admin', secret_key='admin', **kwargs): @@ -196,6 +224,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. |
