+ # The parameters we'll need to deploy a charm
+ number_to_configure = 0
+
+ def deploy():
+ """An inner function to deploy the charm from either vnf or vdu
+ """
+
+ # Login to the VCA.
+ # if number_to_configure == 0:
+ # self.logger.debug("Logging into N2VC...")
+ # task = asyncio.ensure_future(self.n2vc.login())
+ # yield from asyncio.wait_for(task, 30.0)
+ # self.logger.debug("Logged into N2VC!")
+
+ ## await self.n2vc.login()
+
+ # Note: The charm needs to exist on disk at the location
+ # specified by charm_path.
+ base_folder = vnfd["_admin"]["storage"]
+ storage_params = self.fs.get_params()
+ charm_path = "{}{}/{}/charms/{}".format(
+ storage_params["path"],
+ base_folder["folder"],
+ base_folder["pkg-dir"],
+ proxy_charm
+ )
+
+ # Setup the runtime parameters for this VNF
+ params['rw_mgmt_ip'] = nsr_lcm['nsr_ip'][vnf_index]
+
+ # ns_name will be ignored in the current version of N2VC
+ # but will be implemented for the next point release.
+ model_name = 'default'
+ application_name = self.n2vc.FormatApplicationName(
+ nsr_name,
+ vnf_index,
+ vnfd['name'],
+ )
+
+ nsr_lcm["VCA"][vnf_index] = {
+ "model": model_name,
+ "application": application_name,
+ "operational-status": "init",
+ "detailed-status": "",
+ "vnfd_id": vnfd_id,
+ }
+
+ self.logger.debug("Task create_ns={} Passing artifacts path '{}' for {}".format(nsr_id, charm_path, proxy_charm))
+ task = asyncio.ensure_future(
+ self.n2vc.DeployCharms(
+ model_name, # The network service name
+ application_name, # The application name
+ vnfd, # The vnf descriptor
+ charm_path, # Path to charm
+ params, # Runtime params, like mgmt ip
+ {}, # for native charms only
+ self.n2vc_callback, # Callback for status changes
+ db_nsr, # Callback parameter
+ vnf_index, # Callback parameter
+ None, # Callback parameter (task)
+ )
+ )
+ task.add_done_callback(functools.partial(self.n2vc_callback, model_name, application_name, None, db_nsr, vnf_index))
+ self.lcm_ns_tasks[nsr_id][order_id]["create_charm:" + vnf_index] = task
+
+ # TODO: Make this call inside deploy()
+ # Login to the VCA. If there are multiple calls to login(),
+ # subsequent calls will be a nop and return immediately.
+ await self.n2vc.login()
+