5 from datetime import datetime
6 from django.db.models import F, Q
7 from planetstack.config import Config
8 from ec2_observer.syncstep import SyncStep
9 from core.models.user import User
10 from core.models.site import *
11 from ec2_observer.awslib import *
14 class SyncUsers(SyncStep):
18 def fetch_pending(self, deletion):
22 users = User.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
24 key_sig = aws_run('ec2 describe-key-pairs')
25 ec2_keys = key_sig['KeyPairs']
31 key_name = user.email.lower().replace('@', 'AT').replace('.', '')
35 if (key['KeyName']==key_name):
40 aws_run('ec2 import-key-pair --key-name %s --public-key-material "%s"'%(key_name, user.public_key))
44 def sync_record(self, node):