blob: 88c9f1dfc19ac44c9c389d69b60180f154b4e991 [file] [log] [blame]
Sapan Bhatia337aacb2014-09-03 15:38:28 -04001from core.models import *
2
3def handle(network):
Sapan Bhatia7a8b7e92014-11-11 21:43:31 -05004 from core.models import SliceDeployment,NetworkDeployments
Sapan Bhatia728acce2014-09-15 03:48:20 -04005 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.
Sapan Bhatia7a8b7e92014-11-11 21:43:31 -05008 slice_deployments = SliceDeployment.objects.all()
Sapan Bhatia337aacb2014-09-03 15:38:28 -04009 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()