blob: 0511beea16354769fa49c82f0190118e558ca913 [file] [log] [blame]
Sapan Bhatia337aacb2014-09-03 15:38:28 -04001from core.models import *
2
3def handle(network):
4 # network deployments are not visible to users. We must ensure
5 # networks are deployed at all deploymets available to their slices.
6 slice_deployments = SliceDeployments.objects.all()
7 slice_deploy_lookup = defaultdict(list)
8 for slice_deployment in slice_deployments:
9 slice_deploy_lookup[slice_deployment.slice].append(slice_deployment.deployment)
10
11 network_deployments = NetworkDeployments.objects.all()
12 network_deploy_lookup = defaultdict(list)
13 for network_deployment in network_deployments:
14 network_deploy_lookup[network_deployment.network].append(network_deployment.deployment)
15
16 expected_deployments = slice_deploy_lookup[network.owner]
17 for expected_deployment in expected_deployments:
18 if network not in network_deploy_lookup or \
19 expected_deployment not in network_deploy_lookup[network]:
20 nd = NetworkDeployments(network=network, deployment=expected_deployment)
21 nd.save()