Tony Mack | 0b2b804 | 2013-04-07 19:55:27 -0400 | [diff] [blame] | 1 | from plstackapi.openstack.client import OpenStackClient |
| 2 | from plstackapi.openstack.driver import OpenStackDriver |
Tony Mack | 6242394 | 2013-04-08 15:14:52 -0400 | [diff] [blame] | 3 | from plstackapi.planetstack.api.auth import auth_check |
| 4 | from plstackapi.planetstack.models import * |
| 5 | |
Tony Mack | 0b2b804 | 2013-04-07 19:55:27 -0400 | [diff] [blame] | 6 | |
| 7 | def add_role(auth, name): |
| 8 | client = auth_check(auth) |
| 9 | keystone_role = client.keystone.roles.create(name) |
| 10 | role = Role(role_type=name, role_id=keystone_role.id) |
| 11 | role.save() |
| 12 | return role |
| 13 | |
| 14 | def delete_role(auth, name): |
| 15 | client = auth_check(auth) |
| 16 | role = Role.objects.filter(role_type=name) |
| 17 | client.keystone.roles.delete(role.role_id) |
| 18 | role.delete() |
| 19 | return 1 |
| 20 | |
Tony Mack | 5271d6b | 2013-04-08 00:34:24 -0400 | [diff] [blame] | 21 | def get_roles(auth, filter={}): |
Tony Mack | 0b2b804 | 2013-04-07 19:55:27 -0400 | [diff] [blame] | 22 | client = auth_check(auth) |
| 23 | roles = Role.objects.filter(**filter) |
| 24 | return roles |
| 25 | |
| 26 | |
| 27 | |