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