Sapan Bhatia | 24836f1 | 2013-08-27 10:16:05 -0400 | [diff] [blame] | 1 | import os |
| 2 | import base64 |
Sapan Bhatia | 22e0ffe | 2013-10-02 01:12:10 -0400 | [diff] [blame] | 3 | import hashlib |
Tony Mack | ae7f30c | 2013-09-25 12:46:50 -0400 | [diff] [blame] | 4 | from django.db.models import F, Q |
Sapan Bhatia | 24836f1 | 2013-08-27 10:16:05 -0400 | [diff] [blame] | 5 | from planetstack.config import Config |
Sapan Bhatia | 04c94ad | 2013-09-02 18:00:28 -0400 | [diff] [blame] | 6 | from observer.openstacksyncstep import OpenStackSyncStep |
Tony Mack | 91463d9 | 2014-06-19 20:42:03 -0400 | [diff] [blame] | 7 | from core.models.user import User |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 8 | from core.models.controllerusers import ControllerUsers |
| 9 | from observer.steps.sync_controller_users import SyncControllerUsers |
Sapan Bhatia | 24836f1 | 2013-08-27 10:16:05 -0400 | [diff] [blame] | 10 | |
| 11 | class SyncUsers(OpenStackSyncStep): |
Tony Mack | ce79de0 | 2013-09-24 10:12:33 -0400 | [diff] [blame] | 12 | provides=[User] |
| 13 | requested_interval=0 |
Tony Mack | 66646d5 | 2013-09-24 21:47:12 -0400 | [diff] [blame] | 14 | |
Tony Mack | ce79de0 | 2013-09-24 10:12:33 -0400 | [diff] [blame] | 15 | def sync_record(self, user): |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 16 | for controller_user in ControllerUsers.objects.filter(user=user): |
Tony Mack | d4a6429 | 2014-04-16 19:53:21 -0400 | [diff] [blame] | 17 | # bump the 'updated' field so user account are updated across |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 18 | # controllers. |
| 19 | controller_user.save() |
Sapan Bhatia | 4f4591d | 2014-07-23 09:34:02 -0400 | [diff] [blame] | 20 | |
| 21 | def delete_record(self, user): |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 22 | controller_user_deleter = SyncControllerUsers().delete_record |
| 23 | for controller_user in ControllerUsers.objects.filter(user=user): |
| 24 | controller_user_deleter(controller_user) |