blob: bb964f1ad2d64865b930a1b217ca64d27c179f0b [file] [log] [blame]
Tony Mack0b2b8042013-04-07 19:55:27 -04001from plstackapi.openstack.client import OpenStackClient
2from plstackapi.openstack.driver import OpenStackDriver
Tony Mack62423942013-04-08 15:14:52 -04003from plstackapi.planetstack.api.auth import auth_check
4from plstackapi.planetstack.models import *
5
Tony Mack0b2b8042013-04-07 19:55:27 -04006
7def add_role(auth, name):
Tony Mackb5f339f2013-04-08 16:29:38 -04008 driver = OpenStackDriver(client = auth_check(auth))
9 keystone_role = driver.create_role(name=name)
Tony Mack0b2b8042013-04-07 19:55:27 -040010 role = Role(role_type=name, role_id=keystone_role.id)
11 role.save()
12 return role
13
Tony Mack0856d562013-04-08 21:41:31 -040014def delete_role(auth, role_id):
Tony Mackb5f339f2013-04-08 16:29:38 -040015 driver = OpenStackDriver(client = auth_check(auth))
Tony Mack414e6902013-04-08 21:44:07 -040016 role = Role.objects.filter(role_id=role_id)
Tony Macka7040532013-04-08 21:45:43 -040017 driver.delete_role({'role_id': role_id})
Tony Mack0b2b8042013-04-07 19:55:27 -040018 role.delete()
19 return 1
20
Tony Mack5271d6b2013-04-08 00:34:24 -040021def get_roles(auth, filter={}):
Tony Mack0b2b8042013-04-07 19:55:27 -040022 client = auth_check(auth)
23 roles = Role.objects.filter(**filter)
24 return roles
25
26
27