- # Ideally, we will create a unique model per network service.
- # This change will require all components, i.e., LCM and SO, to use
- # N2VC for 100% compatibility. If we adopt unique models for the LCM,
- # services deployed via LCM would't be manageable via SO and vice versa
+ # Currently, the call to Relate() is made automatically after the
+ # deployment of each charm; if the relation depends on a charm that
+ # hasn't been deployed yet, the call will fail silently. This will
+ # prevent an API breakage, with the intent of making this an explicitly
+ # required call in a more object-oriented refactor of the N2VC API.
+
+ configs = []
+ vnf_config = vnfd.get("vnf-configuration")
+ if vnf_config:
+ juju = vnf_config['juju']
+ if juju:
+ configs.append(vnf_config)
+
+ for vdu in vnfd['vdu']:
+ vdu_config = vdu.get('vdu-configuration')
+ if vdu_config:
+ juju = vdu_config['juju']
+ if juju:
+ configs.append(vdu_config)
+
+ def _get_application_name(name):
+ """Get the application name that's mapped to a vnf/vdu."""
+ vnf_member_index = 0
+ vnf_name = vnfd['name']
+
+ for vdu in vnfd.get('vdu'):
+ # Compare the named portion of the relation to the vdu's id
+ if vdu['id'] == name:
+ application_name = self.FormatApplicationName(
+ model_name,
+ vnf_name,
+ str(vnf_member_index),
+ )
+ return application_name
+ else:
+ vnf_member_index += 1
+
+ return None
+
+ # Loop through relations
+ for cfg in configs:
+ if 'juju' in cfg:
+ if 'relation' in juju:
+ for rel in juju['relation']:
+ try: