X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=NG-RO%2Fosm_ng_ro%2Fns.py;h=08ee7c44e5f386c46621964afffa546c20571d95;hb=refs%2Fchanges%2F25%2F11525%2F1;hp=ee0463a4db662f802e9c21030e72c4ebd0fe2023;hpb=a9fc6189122a4f95e8efebb70e36eb46f3613de3;p=osm%2FRO.git diff --git a/NG-RO/osm_ng_ro/ns.py b/NG-RO/osm_ng_ro/ns.py index ee0463a4..08ee7c44 100644 --- a/NG-RO/osm_ng_ro/ns.py +++ b/NG-RO/osm_ng_ro/ns.py @@ -16,38 +16,38 @@ # limitations under the License. ## -# import yaml +from http import HTTPStatus import logging +from random import choice as random_choice +from threading import Lock +from time import time from traceback import format_exc as traceback_format_exc -from osm_ng_ro.ns_thread import NsWorker, NsWorkerException, deep_get -from osm_ng_ro.validation import validate_input, deploy_schema +from uuid import uuid4 + +from cryptography.hazmat.backends import default_backend as crypto_default_backend +from cryptography.hazmat.primitives import serialization as crypto_serialization +from cryptography.hazmat.primitives.asymmetric import rsa +from jinja2 import ( + Environment, + StrictUndefined, + TemplateError, + TemplateNotFound, + UndefinedError, +) from osm_common import ( - dbmongo, dbmemory, + dbmongo, fslocal, fsmongo, - msglocal, msgkafka, + msglocal, version as common_version, ) from osm_common.dbbase import DbException from osm_common.fsbase import FsException from osm_common.msgbase import MsgException -from http import HTTPStatus -from uuid import uuid4 -from threading import Lock -from random import choice as random_choice -from time import time -from jinja2 import ( - Environment, - TemplateError, - TemplateNotFound, - StrictUndefined, - UndefinedError, -) -from cryptography.hazmat.primitives import serialization as crypto_serialization -from cryptography.hazmat.primitives.asymmetric import rsa -from cryptography.hazmat.backends import default_backend as crypto_default_backend +from osm_ng_ro.ns_thread import deep_get, NsWorker, NsWorkerException +from osm_ng_ro.validation import deploy_schema, validate_input __author__ = "Alfonso Tierno " min_common_version = "0.1.16" @@ -539,6 +539,8 @@ class Ns(object): return quota + nonlocal indata + flavor_data = { "disk": int(target_flavor["storage-gb"]), "ram": int(target_flavor["memory-mb"]), @@ -547,6 +549,26 @@ class Ns(object): numa = {} extended = {} + target_vdur = None + for vnf in indata.get("vnf", []): + for vdur in vnf.get("vdur", []): + if vdur.get("ns-flavor-id") == target_flavor["id"]: + target_vdur = vdur + + for storage in target_vdur.get("virtual-storages", []): + if ( + storage.get("type-of-storage") + == "etsi-nfv-descriptors:ephemeral-storage" + ): + flavor_data["ephemeral"] = int( + storage.get("size-of-storage", 0) + ) + elif ( + storage.get("type-of-storage") + == "etsi-nfv-descriptors:swap-storage" + ): + flavor_data["swap"] = int(storage.get("size-of-storage", 0)) + if target_flavor.get("guest-epa"): extended = {} epa_vcpu_set = False