X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_lcm%2Fns.py;h=173ad887d1861263aa368a3283ed4195da62e55b;hb=refs%2Fheads%2Fbug-585;hp=6148d02aeb99d272218015444a52f23ecb9589ab;hpb=e4f7e6cc71c5e81a7f58fddab055901c5bdf64db;p=osm%2FLCM.git diff --git a/osm_lcm/ns.py b/osm_lcm/ns.py index 6148d02..173ad88 100644 --- a/osm_lcm/ns.py +++ b/osm_lcm/ns.py @@ -1,6 +1,21 @@ -#!/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 @@ -790,20 +805,18 @@ class NsLcm(LcmBase): # 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, @@ -1048,6 +1061,12 @@ class NsLcm(LcmBase): 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( @@ -1082,6 +1101,8 @@ class NsLcm(LcmBase): 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"] @@ -1107,11 +1128,13 @@ class NsLcm(LcmBase): 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") @@ -1340,6 +1363,12 @@ class NsLcm(LcmBase): 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"] @@ -1426,6 +1455,12 @@ class NsLcm(LcmBase): 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"