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 |
Sapan Bhatia | 84ba65d | 2014-11-11 21:44:35 -0500 | [diff] [blame] | 8 | from core.models.userdeployments import UserDeployment |
| 9 | from observer.steps.sync_user_deployments import SyncUserDeployment |
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): |
Sapan Bhatia | 84ba65d | 2014-11-11 21:44:35 -0500 | [diff] [blame] | 16 | for user_deployment in UserDeployment.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 |
| 18 | # deployments. |
| 19 | user_deployment.save() |
Sapan Bhatia | 4f4591d | 2014-07-23 09:34:02 -0400 | [diff] [blame] | 20 | |
| 21 | def delete_record(self, user): |
Sapan Bhatia | 84ba65d | 2014-11-11 21:44:35 -0500 | [diff] [blame] | 22 | user_deployment_deleter = SyncUserDeployment().delete_record |
| 23 | for user_deployment in UserDeployment.objects.filter(user=user): |
Sapan Bhatia | cf219ce | 2014-08-19 03:01:37 -0400 | [diff] [blame] | 24 | user_deployment_deleter(user_deployment) |