Sapan Bhatia | b3aeb1b | 2014-09-03 15:39:13 -0400 | [diff] [blame^] | 1 | from core.models import * |
| 2 | |
| 3 | def handle(slice): |
| 4 | site_deployments = SiteDeployments.objects.all() |
| 5 | site_deploy_lookup = defaultdict(list) |
| 6 | for site_deployment in site_deployments: |
| 7 | site_deploy_lookup[site_deployment.site].append(site_deployment.deployment) |
| 8 | |
| 9 | slice_deployments = SliceDeployments.objects.all() |
| 10 | slice_deploy_lookup = defaultdict(list) |
| 11 | for slice_deployment in slice_deployments: |
| 12 | slice_deploy_lookup[slice_deployment.slice].append(slice_deployment.deployment) |
| 13 | |
| 14 | all_deployments = Deployment.objects.all() |
| 15 | # slices are added to all deployments for now |
| 16 | expected_deployments = all_deployments |
| 17 | #expected_deployments = site_deploy_lookup[slice.site] |
| 18 | for expected_deployment in expected_deployments: |
| 19 | if slice not in slice_deploy_lookup or \ |
| 20 | expected_deployment not in slice_deploy_lookup[slice]: |
| 21 | sd = SliceDeployments(slice=slice, deployment=expected_deployment) |
| 22 | sd.save() |
| 23 | |