blob: 6fd968c2e1803d47378e8dffaf09809edc3e6498 [file] [log] [blame]
Sapan Bhatiab3aeb1b2014-09-03 15:39:13 -04001
2def handle(slice):
Sapan Bhatia0e5be032014-09-15 03:48:20 -04003 from core.models import SiteDeployments,SliceDeployments,Deployment
4 from collections import defaultdict
Sapan Bhatiab3aeb1b2014-09-03 15:39:13 -04005 site_deployments = SiteDeployments.objects.all()
6 site_deploy_lookup = defaultdict(list)
7 for site_deployment in site_deployments:
8 site_deploy_lookup[site_deployment.site].append(site_deployment.deployment)
9
10 slice_deployments = SliceDeployments.objects.all()
11 slice_deploy_lookup = defaultdict(list)
12 for slice_deployment in slice_deployments:
13 slice_deploy_lookup[slice_deployment.slice].append(slice_deployment.deployment)
14
15 all_deployments = Deployment.objects.all()
16 # slices are added to all deployments for now
17 expected_deployments = all_deployments
18 #expected_deployments = site_deploy_lookup[slice.site]
19 for expected_deployment in expected_deployments:
20 if slice not in slice_deploy_lookup or \
21 expected_deployment not in slice_deploy_lookup[slice]:
22 sd = SliceDeployments(slice=slice, deployment=expected_deployment)
23 sd.save()
24