-#!/usr/bin/python3
# -*- coding: utf-8 -*-
+##
+# Copyright 2018 Telefonica S.A.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+##
+
import asyncio
import yaml
import logging
# ns_name will be ignored in the current version of N2VC
# but will be implemented for the next point release.
- model_name = 'default' # TODO bug 581 : change to nsr_id
+ model_name = "default" # TODO bug 585 nsr_id
if vdu_id:
- vdu_id_text = vdu_id
+ vdu_id_text = vdu_id + "-"
else:
- vdu_id_text = "vnfd" # TODO bug 581 remove and add just an empty string ""
+ vdu_id_text = "-"
application_name = self.n2vc.FormatApplicationName(nsr_name, vnf_index, vdu_id_text)
- # TODO bug 581 Add "-" as a final argument
vca_index = len(vca_deployed_list)
# trunk name and add two char index at the end to ensure that it is unique. It is assumed no more than
# 26*26 charm in the same NS
- # TODO bug 581 uncoment
- # application_name = application_name[0:48]
- # application_name += chr(97 + vca_index / 26) + chr(97 + vca_index % 26)
+ application_name = application_name[0:48]
+ application_name += chr(97 + vca_index // 26) + chr(97 + vca_index % 26)
vca_deployed_ = {
"member-vnf-index": vnf_index,
"vdu_id": vdu_id,
db_nsr_update["detailed-status"] = "Deleting charms"
self.logger.debug(logging_text + step)
self.update_db_2("nsrs", nsr_id, db_nsr_update)
+ # for backward compatibility
+ if isinstance(nsr_deployed["VCA"], dict):
+ nsr_deployed["VCA"] = list(nsr_deployed["VCA"].values())
+ db_nsr_update["_admin.deployed.VCA"] = nsr_deployed["VCA"]
+ self.update_db_2("nsrs", nsr_id, db_nsr_update)
+
for vca_index, vca_deployed in enumerate(nsr_deployed["VCA"]):
if vca_deployed: # TODO it would be desirable having a and deploy_info.get("deployed"):
task = asyncio.ensure_future(
try:
if RO_nsr_id:
step = db_nsr_update["detailed-status"] = db_nslcmop_update["detailed-status"] = "Deleting ns at RO"
+ self.update_db_2("nslcmops", nslcmop_id, db_nslcmop_update)
+ self.update_db_2("nsrs", nsr_id, db_nsr_update)
self.logger.debug(logging_text + step)
desc = await RO.delete("ns", RO_nsr_id)
RO_delete_action = desc["action_id"]
break
else:
assert False, "ROclient.check_action_status returns unknown {}".format(ns_status)
- await asyncio.sleep(5, loop=self.loop)
- delete_timeout -= 5
if detailed_status != detailed_status_old:
- detailed_status_old = db_nslcmop_update["detailed-status"] = detailed_status
+ detailed_status_old = db_nslcmop_update["detailed-status"] = \
+ db_nsr_update["detailed-status"] = detailed_status
self.update_db_2("nslcmops", nslcmop_id, db_nslcmop_update)
+ self.update_db_2("nsrs", nsr_id, db_nsr_update)
+ await asyncio.sleep(5, loop=self.loop)
+ delete_timeout -= 5
else: # delete_timeout <= 0:
raise ROclient.ROClientException("Timeout waiting ns deleted from VIM")
if pending:
raise LcmException("Timeout waiting related tasks to be completed")
+ # for backward compatibility
+ if nsr_deployed and isinstance(nsr_deployed.get("VCA"), dict):
+ nsr_deployed["VCA"] = list(nsr_deployed["VCA"].values())
+ db_nsr_update["_admin.deployed.VCA"] = nsr_deployed["VCA"]
+ self.update_db_2("nsrs", nsr_id, db_nsr_update)
+
# TODO check if ns is in a proper status
primitive = db_nslcmop["operationParams"]["primitive"]
primitive_params = db_nslcmop["operationParams"]["primitive_params"]
scaling_type = db_nslcmop["operationParams"]["scaleVnfData"]["scaleVnfType"]
# scaling_policy = db_nslcmop["operationParams"]["scaleVnfData"]["scaleByStepData"].get("scaling-policy")
+ # for backward compatibility
+ if nsr_deployed and isinstance(nsr_deployed.get("VCA"), dict):
+ nsr_deployed["VCA"] = list(nsr_deployed["VCA"].values())
+ db_nsr_update["_admin.deployed.VCA"] = nsr_deployed["VCA"]
+ self.update_db_2("nsrs", nsr_id, db_nsr_update)
+
step = "Getting vnfr from database"
db_vnfr = self.db.get_one("vnfrs", {"member-vnf-index-ref": vnf_index, "nsr-id-ref": nsr_id})
step = "Getting vnfd from database"