def handle(slice):
- from core.models import SiteDeployments,SliceDeployments,Deployment,Network,NetworkSlice,NetworkTemplate
+ import pdb
+ pdb.set_trace()
+ from core.models import Controller, ControllerSiteDeployments, ControllerSlices,Controller,Network,NetworkSlice,NetworkTemplate
from collections import defaultdict
- site_deployments = SiteDeployments.objects.all()
+ ctrl_site_deployments = ControllerSiteDeployments.objects.all()
site_deploy_lookup = defaultdict(list)
- for site_deployment in site_deployments:
- site_deploy_lookup[site_deployment.site].append(site_deployment.deployment)
+ for ctrl_site_deployment in ctrl_site_deployments:
+ site_deploy_lookup[ctrl_site_deployment.site_deployment].append(ctrl_site_deployment)
- slice_deployments = SliceDeployments.objects.all()
+ slice_controllers = ControllerSlices.objects.all()
slice_deploy_lookup = defaultdict(list)
- for slice_deployment in slice_deployments:
- slice_deploy_lookup[slice_deployment.slice].append(slice_deployment.deployment)
+ for slice_controller in slice_controllers:
+ slice_deploy_lookup[slice_controller.slice].append(slice_controller)
- all_deployments = Deployment.objects.all()
- # slices are added to all deployments for now
- expected_deployments = all_deployments
- #expected_deployments = site_deploy_lookup[slice.site]
- for expected_deployment in expected_deployments:
+ #expected_controllers = site_deploy_lookup[slice.site]
+ all_controllers = Controller.objects.all()
+ for expected_controller in all_controllers:
if slice not in slice_deploy_lookup or \
- expected_deployment not in slice_deploy_lookup[slice]:
- sd = SliceDeployments(slice=slice, deployment=expected_deployment)
+ expected_controller not in slice_deploy_lookup[slice]:
+ sd = ControllerSlices(slice=slice, controller=expected_controller)
sd.save()
# make sure slice has at least 1 public and 1 private networkd