From: Philip Joseph Date: Fri, 7 Apr 2017 10:06:32 +0000 (+0530) Subject: More changes for projects support X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F39%2F1539%2F1;p=osm%2FSO.git More changes for projects support Signed-off-by: Philip Joseph --- diff --git a/common/python/rift/mano/sdn/config.py b/common/python/rift/mano/sdn/config.py index 20b17cc4..1ae65a51 100644 --- a/common/python/rift/mano/sdn/config.py +++ b/common/python/rift/mano/sdn/config.py @@ -78,9 +78,10 @@ class SDNAccountConfigCallbacks(object): class SDNAccountConfigSubscriber(object): XPATH = "C,/rw-sdn:sdn/rw-sdn:account" - def __init__(self, dts, log, rwlog_hdl, sdn_callbacks, acctstore): + def __init__(self, dts, log, project, rwlog_hdl, sdn_callbacks, acctstore): self._dts = dts self._log = log + self._project = project self._rwlog_hdl = rwlog_hdl self._reg = None @@ -205,8 +206,9 @@ class SDNAccountConfigSubscriber(object): xact_info.respond_xpath(rwdts.XactRspCode.ACK) + xpath = self._project.add_project(SDNAccountConfigSubscriber.XPATH) self._log.debug("Registering for SDN Account config using xpath: %s", - SDNAccountConfigSubscriber.XPATH, + xpath, ) acg_handler = rift.tasklets.AppConfGroup.Handler( @@ -215,7 +217,7 @@ class SDNAccountConfigSubscriber(object): with self._dts.appconf_group_create(acg_handler) as acg: self._reg = acg.register( - xpath=SDNAccountConfigSubscriber.XPATH, + xpath=xpath, flags=rwdts.Flag.SUBSCRIBER | rwdts.Flag.DELTA_READY | rwdts.Flag.CACHE, on_prepare=on_prepare, ) diff --git a/common/python/rift/mano/sdn/operdata.py b/common/python/rift/mano/sdn/operdata.py index 094d8045..732c600f 100644 --- a/common/python/rift/mano/sdn/operdata.py +++ b/common/python/rift/mano/sdn/operdata.py @@ -29,10 +29,11 @@ class SDNAccountNotFound(Exception): class SDNAccountDtsOperdataHandler(object): - def __init__(self, dts, log, loop): + def __init__(self, dts, log, loop, project): self._dts = dts self._log = log self._loop = loop + self._project = project self.sdn_accounts = {} self._oper = None @@ -63,9 +64,10 @@ class SDNAccountDtsOperdataHandler(object): def _register_show_status(self): def get_xpath(sdn_name=None): - return "D,/rw-sdn:sdn/account{}/connection-status".format( - "[name='%s']" % sdn_name if sdn_name is not None else '' - ) + return self._project.add_project("D,/rw-sdn:sdn/account{}/connection-status". + format( + "[name='%s']" % sdn_name + if sdn_name is not None else '')) @asyncio.coroutine def on_prepare(xact_info, action, ks_path, msg): diff --git a/common/python/rift/mano/utils/project.py b/common/python/rift/mano/utils/project.py index 9157f898..96d1de5f 100644 --- a/common/python/rift/mano/utils/project.py +++ b/common/python/rift/mano/utils/project.py @@ -651,12 +651,14 @@ class ProjectHandler(object): except Exception as e: self._log.exception("Project {} create for {} failed: {}". format(name, self._get_tasklet_name(), e)) + raise e try: yield from self._get_project(name).register() except Exception as e: self._log.exception("Project {} register for tasklet {} failed: {}". format(name, self._get_tasklet_name(), e)) + raise e @asyncio.coroutine def on_delete_prepare(self, name): diff --git a/models/plugins/yang/nsr.role.xml b/models/plugins/yang/nsr.role.xml index 4353911e..0548c7b5 100644 --- a/models/plugins/yang/nsr.role.xml +++ b/models/plugins/yang/nsr.role.xml @@ -19,6 +19,7 @@ read execute /rw-project:project/nsr:ns-instance-config /rw-project:project/nsr:ns-instance-opdata + /rw-project:project/nsr:key-pair @@ -29,6 +30,7 @@ create read update delete execute /rw-project:project/nsr:ns-instance-config /rw-project:project/nsr:ns-instance-opdata + /rw-project:project/nsr:key-pair /nsr:exec-scale-out /nsr:exec-scale-in /nsr:exec-ns-service-primitive diff --git a/models/plugins/yang/nsr.yang b/models/plugins/yang/nsr.yang index 50bbc0d8..efddc777 100644 --- a/models/plugins/yang/nsr.yang +++ b/models/plugins/yang/nsr.yang @@ -112,7 +112,7 @@ module nsr leaf key-pair-ref { description "A reference to the key pair entry in the global key pair table"; type leafref { - path "/nsr:key-pair/nsr:name"; + path "../../../../key-pair/name"; } } } @@ -137,28 +137,13 @@ module nsr leaf key-pair-ref { description "A reference to the key pair entry in the global key pair table"; type leafref { - path "/nsr:key-pair/nsr:name"; + path "../../../../../key-pair/nsr:name"; } } } } } - list key-pair { - key "name"; - description "Used to configure the list of public keys to be injected as part - of ns instantiation"; - leaf name { - description "Name of this key pair"; - type string; - } - - leaf key { - description "Key associated with this key pair"; - type string; - } - } - augment "/rw-project:project" { list key-pair { key "name"; diff --git a/rwcal/plugins/vala/CMakeLists.txt b/rwcal/plugins/vala/CMakeLists.txt index 7ef9879c..9cf53f95 100644 --- a/rwcal/plugins/vala/CMakeLists.txt +++ b/rwcal/plugins/vala/CMakeLists.txt @@ -35,7 +35,7 @@ rift_add_vala( VALA_PACKAGES rw_types-1.0 rw_yang-1.0 rw_keyspec-1.0 rw_yang_pb-1.0 rw_schema_proto-1.0 rw_log_yang-1.0 rw_base_yang-1.0 rwcal_yang-1.0 rw_manifest_yang-1.0 protobuf_c-1.0 ietf_netconf_yang-1.0 - rw_log-1.0 rw_project_yang-1.0 + rw_log-1.0 rw_project_yang-1.0 rw_user_yang-1.0 VAPI_DIRS ${RIFT_SUBMODULE_BINARY_ROOT}/rwcal/plugins/yang ${RIFT_SUBMODULE_BINARY_ROOT}/models/plugins/yang ${RIFT_SUBMODULE_BINARY_ROOT}/rwvcs/plugins/yang diff --git a/rwlaunchpad/plugins/rwpkgmgr/rift/tasklets/rwpkgmgr/publisher/copy_status.py b/rwlaunchpad/plugins/rwpkgmgr/rift/tasklets/rwpkgmgr/publisher/copy_status.py index 927331c1..1fc68019 100644 --- a/rwlaunchpad/plugins/rwpkgmgr/rift/tasklets/rwpkgmgr/publisher/copy_status.py +++ b/rwlaunchpad/plugins/rwpkgmgr/rift/tasklets/rwpkgmgr/publisher/copy_status.py @@ -34,16 +34,16 @@ if sys.version_info < (3, 4, 4): class CopyStatusPublisher(mano_dts.DtsHandler, url_downloader.DownloaderProtocol): - def __init__(self, log, dts, loop, tasklet_info): - super().__init__(log, dts, loop) - self.tasks = {} - self.tasklet_info = tasklet_info + def __init__(self, log, dts, loop, project): + super().__init__(log, dts, loop, project) + self.tasks = {} + self.tasklet_info = project.tasklet.tasklet_info def xpath(self, transaction_id=None): - return ("D,/rw-pkg-mgmt:copy-jobs/rw-pkg-mgmt:job" + + return self.project.add_project("D,/rw-pkg-mgmt:copy-jobs/rw-pkg-mgmt:job" + ("[transaction-id='{}']".format(transaction_id) if transaction_id else "")) pass - + @asyncio.coroutine def register(self): self.reg = yield from self.dts.register(xpath=self.xpath(), diff --git a/rwlaunchpad/plugins/rwpkgmgr/rift/tasklets/rwpkgmgr/rpc.py b/rwlaunchpad/plugins/rwpkgmgr/rift/tasklets/rwpkgmgr/rpc.py index d3606400..e05a0425 100644 --- a/rwlaunchpad/plugins/rwpkgmgr/rift/tasklets/rwpkgmgr/rpc.py +++ b/rwlaunchpad/plugins/rwpkgmgr/rift/tasklets/rwpkgmgr/rpc.py @@ -68,12 +68,12 @@ class EndpointDiscoveryRpcHandler(mano_dts.AbstractRpcHandler): class SchemaRpcHandler(mano_dts.AbstractRpcHandler): """RPC handler to generate the schema for the packages. """ - def __init__(self, log, dts, loop, project, proxy): + def __init__(self, log, dts, loop, proxy): """ Args: proxy: Any impl of .proxy.AbstractPackageManagerProxy """ - super().__init__(log, dts, loop, project) + super().__init__(log, dts, loop) self.proxy = proxy @property diff --git a/rwlaunchpad/plugins/rwpkgmgr/rift/tasklets/rwpkgmgr/rwpkgmgr.py b/rwlaunchpad/plugins/rwpkgmgr/rift/tasklets/rwpkgmgr/rwpkgmgr.py index 0fcabe37..438f9de5 100644 --- a/rwlaunchpad/plugins/rwpkgmgr/rift/tasklets/rwpkgmgr/rwpkgmgr.py +++ b/rwlaunchpad/plugins/rwpkgmgr/rift/tasklets/rwpkgmgr/rwpkgmgr.py @@ -40,7 +40,7 @@ from rift.mano.utils.project import ( from . import rpc from .proxy import filesystem from . import publisher as pkg_publisher -from . import subscriber +from . import subscriber class PackageManagerProject(ManoProject): @@ -51,22 +51,26 @@ class PackageManagerProject(ManoProject): args = [self.log, self.dts, self.loop, self] self.job_handler = pkg_publisher.DownloadStatusPublisher(*args) - self.copy_publisher = pkg_publisher.CopyStatusPublisher(*args + [self.tasklet.tasklet_info]) + self.copy_publisher = pkg_publisher.CopyStatusPublisher(*args) - # create catalog subscribers + # create catalog subscribers self.vnfd_catalog_sub = subscriber.VnfdStatusSubscriber(*args) self.nsd_catalog_sub = subscriber.NsdStatusSubscriber(*args) - + args.append(proxy) self.copy_rpc = rpc.PackageCopyOperationsRpcHandler(*(args + [self.copy_publisher])) @asyncio.coroutine def register (self): - yield from self.vnfd_catalog_sub.register() - yield from self.nsd_catalog_sub.register() - yield from self.copy_rpc.register() - yield from self.copy_publisher.register() - yield from self.job_handler.register() + try: + yield from self.vnfd_catalog_sub.register() + yield from self.nsd_catalog_sub.register() + yield from self.copy_rpc.register() + yield from self.copy_publisher.register() + yield from self.job_handler.register() + except Exception as e: + self.log.exception("Exception registering project {}: {}". + format(self.name, e)) def deregister (self): yield from self.job_handler.deregister() @@ -135,7 +139,6 @@ class PackageManagerTasklet(rift.tasklets.Tasklet): yield from self.delete_rpc.register() self.log.debug("creating project handler") - self.project_handler = ProjectHandler(self, PackageManagerProject) self.project_handler.register() @asyncio.coroutine diff --git a/rwlaunchpad/plugins/rwvns/vala/CMakeLists.txt b/rwlaunchpad/plugins/rwvns/vala/CMakeLists.txt index d3aa299c..81e8ec44 100644 --- a/rwlaunchpad/plugins/rwvns/vala/CMakeLists.txt +++ b/rwlaunchpad/plugins/rwvns/vala/CMakeLists.txt @@ -36,7 +36,7 @@ rift_add_vala( rw_log_yang-1.0 rw_base_yang-1.0 rwcal_yang-1.0 rwsdnal_yang-1.0 rw_manifest_yang-1.0 protobuf_c-1.0 ietf_netconf_yang-1.0 ietf_network_yang-1.0 ietf_network_topology_yang-1.0 ietf_l2_topology_yang-1.0 rw_topology_yang-1.0 - rw_log-1.0 rw_project_yang-1.0 + rw_log-1.0 rw_project_yang-1.0 rw_user_yang-1.0 VAPI_DIRS ${RIFT_SUBMODULE_BINARY_ROOT}/models/plugins/yang ${RIFT_SUBMODULE_BINARY_ROOT}/rwcal/plugins/yang diff --git a/rwmon/plugins/vala/CMakeLists.txt b/rwmon/plugins/vala/CMakeLists.txt index 5fd03fcc..a30179e1 100644 --- a/rwmon/plugins/vala/CMakeLists.txt +++ b/rwmon/plugins/vala/CMakeLists.txt @@ -35,7 +35,7 @@ rift_add_vala( VALA_PACKAGES rw_types-1.0 rw_yang-1.0 rw_keyspec-1.0 rw_yang_pb-1.0 rw_schema_proto-1.0 rw_log_yang-1.0 rw_base_yang-1.0 rwmon_yang-1.0 rw_manifest_yang-1.0 protobuf_c-1.0 ietf_netconf_yang-1.0 - rw_log-1.0 rwcal_yang-1.0 rw_project_yang-1.0 + rw_log-1.0 rwcal_yang-1.0 rw_project_yang-1.0 rw_user_yang-1.0 VAPI_DIRS ${RIFT_SUBMODULE_BINARY_ROOT}/rwmon/plugins/yang ${RIFT_SUBMODULE_BINARY_ROOT}/rwcal/plugins/yang ${RIFT_SUBMODULE_BINARY_ROOT}/models/plugins/yang diff --git a/rwprojectmano/plugins/rwprojectmano/rift/tasklets/rwprojectmano/rolesmano.py b/rwprojectmano/plugins/rwprojectmano/rift/tasklets/rwprojectmano/rolesmano.py index 0083c060..2988a205 100644 --- a/rwprojectmano/plugins/rwprojectmano/rift/tasklets/rwprojectmano/rolesmano.py +++ b/rwprojectmano/plugins/rwprojectmano/rift/tasklets/rwprojectmano/rolesmano.py @@ -60,6 +60,7 @@ class ProjectConfigSubscriber(object): self.users = {} self.pub = RoleConfigPublisher(project) + self.proj_roles = [role['mano-role'] for role in MANO_PROJECT_ROLES] def get_xpath(self): return "C,/{}[name='{}']/project-config/user".format(NS_PROJECT, self.project_name) @@ -201,6 +202,17 @@ class ProjectConfigSubscriber(object): self._log.debug("User {}: on_prepare add request". format(user.key)) + for role in msg.mano_role: + if role.role not in self.proj_roles: + errmsg = "Invalid MANO role {} for user {}". \ + format(role.role, user.key) + self._log.error(errmsg) + xact_info.send_error_xpath(RwTypes.RwStatus.FAILURE, + self.get_xpath(), + errmsg) + xact_info.respond_xpath(rwdts.XactRspCode.NACK) + return + elif action == rwdts.QueryAction.DELETE: # Check if the user got deleted fref = ProtobufC.FieldReference.alloc()