Sapan Bhatia | b3aeb1b | 2014-09-03 15:39:13 -0400 | [diff] [blame] | 1 | |
| 2 | def handle(slice): |
Sapan Bhatia | 0e5be03 | 2014-09-15 03:48:20 -0400 | [diff] [blame] | 3 | from core.models import SiteDeployments,SliceDeployments,Deployment |
| 4 | from collections import defaultdict |
Sapan Bhatia | b3aeb1b | 2014-09-03 15:39:13 -0400 | [diff] [blame] | 5 | 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 | |