From 99361668c71d0eca7d279851b8eccf8cc650908b Mon Sep 17 00:00:00 2001 From: Philip Joseph Date: Wed, 8 Mar 2017 18:28:08 +0530 Subject: [PATCH] Update to use rw-project definition from platform Signed-off-by: Philip Joseph --- common/plugins/yang/CMakeLists.txt | 8 +- common/python/rift/mano/utils/project.py | 27 +++-- models/plugins/yang/CMakeLists.txt | 14 +-- models/plugins/yang/rw-project-mano.yang | 47 +++++++++ models/plugins/yang/rw-project.yang | 99 ------------------- rwcal/plugins/yang/CMakeLists.txt | 4 +- rwcm/plugins/yang/rw-conman.yang | 4 + .../cli/cli_launchpad_schema_listing.txt | 1 + rwlaunchpad/plugins/rwvns/yang/CMakeLists.txt | 2 +- rwlaunchpad/plugins/yang/CMakeLists.txt | 4 +- rwlaunchpad/plugins/yang/rw-image-mgmt.yang | 4 + rwlaunchpad/plugins/yang/rw-launchpad.yang | 4 + rwlaunchpad/plugins/yang/rw-monitor.yang | 4 + rwlaunchpad/plugins/yang/rw-nsm.yang | 4 + rwlaunchpad/plugins/yang/rw-pkg-mgmt.yang | 4 + rwlaunchpad/plugins/yang/rw-resource-mgr.yang | 4 + rwlaunchpad/plugins/yang/rw-staging-mgmt.yang | 4 + rwlaunchpad/plugins/yang/rw-vnfm.yang | 4 + rwlaunchpad/plugins/yang/rw-vns.yang | 4 + 19 files changed, 125 insertions(+), 121 deletions(-) create mode 100644 models/plugins/yang/rw-project-mano.yang delete mode 100644 models/plugins/yang/rw-project.yang diff --git a/common/plugins/yang/CMakeLists.txt b/common/plugins/yang/CMakeLists.txt index 69b2f99a..bc32d5db 100644 --- a/common/plugins/yang/CMakeLists.txt +++ b/common/plugins/yang/CMakeLists.txt @@ -28,12 +28,12 @@ rift_add_yang_target( LIBRARIES rwsdn_yang_gen rwcal_yang_gen - rwproject_yang_gen + rwprojectmano_yang_gen mano-types_yang_gen DEPENDS rwcal_yang rwsdn_yang - rwproject_yang + rwprojectmano_yang mano-types_yang ) @@ -43,8 +43,8 @@ rift_add_yang_target( COMPONENT ${PKG_LONG_NAME} LIBRARIES rwcal_yang_gen - rwproject_yang_gen + rwprojectmano_yang_gen DEPENDS rwcal_yang - rwproject_yang + rwprojectmano_yang ) diff --git a/common/python/rift/mano/utils/project.py b/common/python/rift/mano/utils/project.py index 65d76543..56778a9a 100644 --- a/common/python/rift/mano/utils/project.py +++ b/common/python/rift/mano/utils/project.py @@ -21,12 +21,13 @@ import asyncio import logging import gi -gi.require_version('RwProjectYang', '1.0') +gi.require_version('RwProjectManoYang', '1.0') gi.require_version('RwDtsYang', '1.0') from gi.repository import ( - RwProjectYang, + RwProjectManoYang, RwDts as rwdts, ProtobufC, + RwTypes, ) import rift.tasklets @@ -263,7 +264,7 @@ class ManoProject(object): self._prefix = "{}[{}='{}']".format(XPATH, NS_NAME, self._name) - self._pbcm = RwProjectYang.YangData_RwProject_Project( + self._pbcm = RwProjectManoYang.YangData_RwProject_Project( name=self._name) elif self._name == value: @@ -319,7 +320,7 @@ class ManoProject(object): @asyncio.coroutine def create_project(self, dts): - proj_xpath = "C,{}/project-config".format(self.prefix) + proj_xpath = "C,{}/config".format(self.prefix) self._log.info("Creating project: {} with {}". format(proj_xpath, self.config.as_dict())) @@ -395,7 +396,7 @@ class ProjectConfigCallbacks(object): class ProjectDtsHandler(object): - XPATH = "C,{}/project-config".format(XPATH) + XPATH = "C,{}/config".format(XPATH) def __init__(self, dts, log, callbacks): self._dts = dts @@ -485,10 +486,13 @@ class ProjectDtsHandler(object): for cfg in update_cfgs: self.update_project(cfg.name_ref) + return RwTypes.RwStatus.SUCCESS + @asyncio.coroutine def on_prepare(dts, acg, xact, xact_info, ks_path, msg, scratch): """ Prepare callback from DTS for Project """ + action = xact_info.query_action # xpath = ks_path.to_xpath(RwProjectYang.get_schema()) # name = ManoProject.from_xpath(xpath, self._log) # if not name: @@ -497,8 +501,18 @@ class ProjectDtsHandler(object): # xact_info.respond_xpath(rwdts.XactRspCode.NACK) # return - action = xact_info.query_action + # if name != msg.name_ref: + # self._log.error("The project name {} did not match the name {} in config". + # format(name, msg.name_ref)) + # projects = scratch.setdefault('projects', { + # 'create': [], + # 'update': [], + # 'delete': [], + # }) + + self._log.error("prepare msg type {}".format(type(msg))) name = msg.name_ref + self._log.debug("Project %s on_prepare config received (action: %s): %s", name, xact_info.query_action, msg) @@ -512,6 +526,7 @@ class ProjectDtsHandler(object): format(name)) yield from self._callbacks.on_add_prepare(name) + elif action == rwdts.QueryAction.DELETE: # Check if the entire project got deleted fref = ProtobufC.FieldReference.alloc() diff --git a/models/plugins/yang/CMakeLists.txt b/models/plugins/yang/CMakeLists.txt index 580e5565..f31fa3c2 100644 --- a/models/plugins/yang/CMakeLists.txt +++ b/models/plugins/yang/CMakeLists.txt @@ -38,11 +38,13 @@ set(source_yang_files ) rift_add_yang_target( - TARGET rwproject_yang + TARGET rwprojectmano_yang YANG_FILES - rw-project.yang + rw-project-mano.yang GIR_PATHS ${CMAKE_CURRENT_BINARY_DIR} COMPONENT ${PKG_LONG_NAME} + LIBRARIES + rw_project_yang_gen ) rift_add_yang_target( @@ -51,9 +53,7 @@ rift_add_yang_target( mano-types.yang COMPONENT ${PKG_LONG_NAME} LIBRARIES - rwproject_yang_gen - DEPENDS - rwproject_yang + rwprojectmano_yang_gen ) rift_add_yang_target( @@ -67,11 +67,11 @@ rift_add_yang_target( rwcloud_yang_gen rwconfig_agent_yang_gen mano-types_yang_gen - rwproject_yang_gen + rwprojectmano_yang_gen DEPENDS rwcloud_yang rwconfig_agent_yang - rwproject_yang + rwprojectmano_yang ) #rift_gen_yang_tree(mano-pyang-trees diff --git a/models/plugins/yang/rw-project-mano.yang b/models/plugins/yang/rw-project-mano.yang new file mode 100644 index 00000000..0b5a3341 --- /dev/null +++ b/models/plugins/yang/rw-project-mano.yang @@ -0,0 +1,47 @@ +/* + * + * Copyright 2017 RIFT.IO Inc + * + * 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. + * + */ + +module rw-project-mano +{ + namespace "http://riftio.com/ns/riftware-1.0/rw-project-mano"; + prefix "rw-project-mano"; + + import rw-pb-ext { + prefix "rw-pb-ext"; + } + + import rw-project { + prefix "rw-project"; + } + + revision 2017-03-08 { + description + "Initial revision. This YANG file defines the + MANO extentions for project based tenancy"; + reference + "Derived from earlier versions of base YANG files"; + } + + augment /rw-project:project/rw-project:config { + leaf name-ref { + type leafref { + path "../../rw-project:name"; + } + } + } +} diff --git a/models/plugins/yang/rw-project.yang b/models/plugins/yang/rw-project.yang deleted file mode 100644 index 32030d1c..00000000 --- a/models/plugins/yang/rw-project.yang +++ /dev/null @@ -1,99 +0,0 @@ -/* - * - * Copyright 2017 RIFT.IO Inc - * - * 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. - * - */ - -module rw-project -{ - namespace "http://riftio.com/ns/riftware-1.0/rw-project"; - prefix "rw-project"; - - import rw-pb-ext { - prefix "rw-pb-ext"; - } - - revision 2017-02-08 { - description - "Initial revision. This YANG file defines the - projects fo MANO to support Role Based Access - Control (RBAC)"; - reference - "Derived from earlier versions of base YANG files"; - } - - list project { - description - "Configuration for individual Projects. RIFT.ware applications - and Projects are expected to augment this list in order to add - configuration for Projects that is specific to the product or - application. As such, this list contains minimal data defined - in this yang module. When augmenting this element, other yang - modules should prefer to define containers with the same name - as the augmenting module. (Augmenting RIFT.ware modules should - prefer to augment without the rw prefix [for new features], or - should prefer to augment the augmented container of an existing - augment."; - - key name; - leaf name { - description "Name of the Project."; - type string { - length "1..255"; - } - } - - leaf description { - description "Information about Project"; - type string; - } - - container project-config { - - description "Project management related configuration."; - - leaf name-ref { - type leafref { - path "../../name"; - } - mandatory true; - } - - // list user { - // description - // "The list of Users who have been assigned Roles within this - // Project."; - - // key user-name user-domain; - // uses rw-rbac-base:user-key; - - // list role { - // description - // "The list of Roles the User has been assigned."; - - // key role key; - // uses rw-rbac-base:role-instance; - // } - // } - } - - container project-state { - - config false; - - description "Project management operational data"; - } - } -} diff --git a/rwcal/plugins/yang/CMakeLists.txt b/rwcal/plugins/yang/CMakeLists.txt index 58c5cdb9..52ad2583 100644 --- a/rwcal/plugins/yang/CMakeLists.txt +++ b/rwcal/plugins/yang/CMakeLists.txt @@ -37,12 +37,12 @@ rift_add_yang_target( COMPONENT ${PKG_LONG_NAME} DEPENDS mano-types_yang - rwproject_yang + rwprojectmano_yang LIBRARIES rwschema_yang_gen rwyang rwlog rwlog-mgmt_yang_gen mano-types_yang_gen - rwproject_yang_gen + rwprojectmano_yang_gen ) diff --git a/rwcm/plugins/yang/rw-conman.yang b/rwcm/plugins/yang/rw-conman.yang index b6cf99c2..9a29a60d 100644 --- a/rwcm/plugins/yang/rw-conman.yang +++ b/rwcm/plugins/yang/rw-conman.yang @@ -87,6 +87,10 @@ module rw-conman prefix "rw-project"; } + import rw-project-mano { + prefix "rw-project-mano"; + } + revision 2017-02-08 { description "Update model to support projects."; diff --git a/rwlaunchpad/plugins/cli/cli_launchpad_schema_listing.txt b/rwlaunchpad/plugins/cli/cli_launchpad_schema_listing.txt index c06e6b80..6bebc9d8 100644 --- a/rwlaunchpad/plugins/cli/cli_launchpad_schema_listing.txt +++ b/rwlaunchpad/plugins/cli/cli_launchpad_schema_listing.txt @@ -39,6 +39,7 @@ rw-nsm rw-nsr rw-pb-ext rw-project +rw-project-mano rw-project-nsd rw-project-vnfd rw-resource-mgr diff --git a/rwlaunchpad/plugins/rwvns/yang/CMakeLists.txt b/rwlaunchpad/plugins/rwvns/yang/CMakeLists.txt index 1c036b40..ecc180c7 100644 --- a/rwlaunchpad/plugins/rwvns/yang/CMakeLists.txt +++ b/rwlaunchpad/plugins/rwvns/yang/CMakeLists.txt @@ -29,6 +29,6 @@ rift_add_yang_target( COMPONENT ${PKG_LONG_NAME} LIBRARIES mano-types_yang_gen - rwproject_yang_gen + rwprojectmano_yang_gen ) diff --git a/rwlaunchpad/plugins/yang/CMakeLists.txt b/rwlaunchpad/plugins/yang/CMakeLists.txt index 2bfcc0d7..f4bf0071 100644 --- a/rwlaunchpad/plugins/yang/CMakeLists.txt +++ b/rwlaunchpad/plugins/yang/CMakeLists.txt @@ -71,13 +71,13 @@ rift_add_yang_target( rw_conman_yang_gen rwconfig_agent_yang_gen mano-types_yang_gen - rwproject_yang_gen + rwprojectmano_yang_gen DEPENDS mano_yang rwcloud_yang rw_conman_yang rwconfig_agent_yang mano-types_yang - rwproject_yang + rwprojectmano_yang ) diff --git a/rwlaunchpad/plugins/yang/rw-image-mgmt.yang b/rwlaunchpad/plugins/yang/rw-image-mgmt.yang index 27eab2e0..457db6de 100644 --- a/rwlaunchpad/plugins/yang/rw-image-mgmt.yang +++ b/rwlaunchpad/plugins/yang/rw-image-mgmt.yang @@ -53,6 +53,10 @@ module rw-image-mgmt prefix "rw-project"; } + import rw-project-mano { + prefix "rw-project-mano"; + } + import mano-types { prefix "mano-types"; } diff --git a/rwlaunchpad/plugins/yang/rw-launchpad.yang b/rwlaunchpad/plugins/yang/rw-launchpad.yang index 99328744..7787fa20 100644 --- a/rwlaunchpad/plugins/yang/rw-launchpad.yang +++ b/rwlaunchpad/plugins/yang/rw-launchpad.yang @@ -106,6 +106,10 @@ module rw-launchpad prefix "rw-project"; } + import rw-project-mano { + prefix "rw-project-mano"; + } + revision 2017-02-08 { description "Update model to support projects."; diff --git a/rwlaunchpad/plugins/yang/rw-monitor.yang b/rwlaunchpad/plugins/yang/rw-monitor.yang index 559880d6..e9a11124 100644 --- a/rwlaunchpad/plugins/yang/rw-monitor.yang +++ b/rwlaunchpad/plugins/yang/rw-monitor.yang @@ -63,6 +63,10 @@ module rw-monitor prefix "yang"; } + import rw-project-mano { + prefix "rw-project-mano"; + } + revision 2015-10-30 { description "Initial revision."; diff --git a/rwlaunchpad/plugins/yang/rw-nsm.yang b/rwlaunchpad/plugins/yang/rw-nsm.yang index f182114d..975bd815 100644 --- a/rwlaunchpad/plugins/yang/rw-nsm.yang +++ b/rwlaunchpad/plugins/yang/rw-nsm.yang @@ -103,6 +103,10 @@ module rw-nsm prefix "rw-project"; } + import rw-project-mano { + prefix "rw-project-mano"; + } + revision 2017-02-08 { description "Update model to support projects."; diff --git a/rwlaunchpad/plugins/yang/rw-pkg-mgmt.yang b/rwlaunchpad/plugins/yang/rw-pkg-mgmt.yang index 747fbc52..49e89256 100644 --- a/rwlaunchpad/plugins/yang/rw-pkg-mgmt.yang +++ b/rwlaunchpad/plugins/yang/rw-pkg-mgmt.yang @@ -57,6 +57,10 @@ module rw-pkg-mgmt prefix "rw-project"; } + import rw-project-mano { + prefix "rw-project-mano"; + } + revision 2017-02-08 { description "Update model to support projects."; diff --git a/rwlaunchpad/plugins/yang/rw-resource-mgr.yang b/rwlaunchpad/plugins/yang/rw-resource-mgr.yang index 0d560044..08d606d7 100644 --- a/rwlaunchpad/plugins/yang/rw-resource-mgr.yang +++ b/rwlaunchpad/plugins/yang/rw-resource-mgr.yang @@ -56,6 +56,10 @@ module rw-resource-mgr prefix "rw-project"; } + import rw-project-mano { + prefix "rw-project-mano"; + } + revision 2017-02-08 { description "Update model to support projects."; diff --git a/rwlaunchpad/plugins/yang/rw-staging-mgmt.yang b/rwlaunchpad/plugins/yang/rw-staging-mgmt.yang index 8ae1f713..2a6b37d8 100644 --- a/rwlaunchpad/plugins/yang/rw-staging-mgmt.yang +++ b/rwlaunchpad/plugins/yang/rw-staging-mgmt.yang @@ -57,6 +57,10 @@ module rw-staging-mgmt prefix "rw-project"; } + import rw-project-mano { + prefix "rw-project-mano"; + } + revision 2017-02-08 { description "Update model to support projects."; diff --git a/rwlaunchpad/plugins/yang/rw-vnfm.yang b/rwlaunchpad/plugins/yang/rw-vnfm.yang index 225633b9..dc83a4c9 100644 --- a/rwlaunchpad/plugins/yang/rw-vnfm.yang +++ b/rwlaunchpad/plugins/yang/rw-vnfm.yang @@ -71,6 +71,10 @@ module rw-vnfm prefix "rw-launchpad"; } + import rw-project-mano { + prefix "rw-project-mano"; + } + revision 2015-10-07 { description "Initial revision."; diff --git a/rwlaunchpad/plugins/yang/rw-vns.yang b/rwlaunchpad/plugins/yang/rw-vns.yang index 0036e16f..d0c9cc1a 100644 --- a/rwlaunchpad/plugins/yang/rw-vns.yang +++ b/rwlaunchpad/plugins/yang/rw-vns.yang @@ -89,6 +89,10 @@ module rw-vns prefix "rw-sdn"; } + import rw-project-mano { + prefix "rw-project-mano"; + } + revision 2015-10-05 { description "Initial revision."; -- 2.25.1