blob: f48b25aa4ddf374a95d743a2c90fff7dec8cd220 [file] [log] [blame]
Sapan Bhatia337aacb2014-09-03 15:38:28 -04001from core.models import *
2
3def handle(network):
Sapan Bhatiabf7856b2014-11-19 15:09:38 -05004 from core.models import SliceDeployments,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 Bhatiabf7856b2014-11-19 15:09:38 -05008 slice_deployments = SliceDeployments.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()