From 5d732677ea16d0d40d51b041d1ce654c67e3fb2f Mon Sep 17 00:00:00 2001 From: velandy Date: Fri, 10 Mar 2017 20:50:52 +0100 Subject: [PATCH] Revert "Create folder structure in backend for onboarded descriptor - RIFT 15317" This reverts commit 8b17d18c5c0c1efb4b4f0eea2f8ad9b4c438780d. Change-Id: I6da6ca9ea4d5d0965ce72be9fe215a28b6986c21 --- .../rwlaunchpadtasklet/rift/package/store.py | 2 - .../rift/tasklets/rwpkgmgr/rwpkgmgr.py | 10 +- .../tasklets/rwpkgmgr/subscriber/__init__.py | 2 +- .../rwpkgmgr/subscriber/download_status.py | 94 +------------------ .../rwpkgmgr/test/utest_subscriber_dts.py | 2 +- rwlaunchpad/plugins/yang/rw-pkg-mgmt.yang | 9 +- 6 files changed, 8 insertions(+), 111 deletions(-) diff --git a/rwlaunchpad/plugins/rwlaunchpadtasklet/rift/package/store.py b/rwlaunchpad/plugins/rwlaunchpadtasklet/rift/package/store.py index 9ebd03c8..34fff1cd 100644 --- a/rwlaunchpad/plugins/rwlaunchpadtasklet/rift/package/store.py +++ b/rwlaunchpad/plugins/rwlaunchpadtasklet/rift/package/store.py @@ -110,8 +110,6 @@ class PackageFilesystemStore(object): Raises: PackageStoreError- The package could not be retrieved """ - self.refresh() - if package_id not in self._package_dirs: msg = "Package %s not found in %s" % (package_id, self._root_dir) raise PackageNotFoundError(msg) diff --git a/rwlaunchpad/plugins/rwpkgmgr/rift/tasklets/rwpkgmgr/rwpkgmgr.py b/rwlaunchpad/plugins/rwpkgmgr/rift/tasklets/rwpkgmgr/rwpkgmgr.py index b302b46e..d4e57367 100644 --- a/rwlaunchpad/plugins/rwpkgmgr/rift/tasklets/rwpkgmgr/rwpkgmgr.py +++ b/rwlaunchpad/plugins/rwpkgmgr/rift/tasklets/rwpkgmgr/rwpkgmgr.py @@ -30,14 +30,14 @@ gi.require_version('RwPkgMgmtYang', '1.0') from gi.repository import ( RwDts as rwdts, - RwPkgMgmtYang) + RwPkgMgmtYang) import rift.tasklets from . import rpc from .proxy import filesystem from . import publisher as pkg_publisher -from . import subscriber + class PackageManagerTasklet(rift.tasklets.Tasklet): def __init__(self, *args, **kwargs): @@ -66,10 +66,6 @@ class PackageManagerTasklet(rift.tasklets.Tasklet): args = [self.log, self.dts, self.loop] self.job_handler = pkg_publisher.DownloadStatusPublisher(*args) - # create catalog subscribers - self.vnfd_catalog_sub = subscriber.VnfdStatusSubscriber(*args) - self.nsd_catalog_sub = subscriber.NsdStatusSubscriber(*args) - args.append(proxy) self.endpoint_rpc = rpc.EndpointDiscoveryRpcHandler(*args) self.schema_rpc = rpc.SchemaRpcHandler(*args) @@ -91,8 +87,6 @@ class PackageManagerTasklet(rift.tasklets.Tasklet): yield from self.pkg_op.register() yield from self.job_handler.register() yield from self.delete_rpc.register() - yield from self.vnfd_catalog_sub.register() - yield from self.nsd_catalog_sub.register() @asyncio.coroutine def run(self): diff --git a/rwlaunchpad/plugins/rwpkgmgr/rift/tasklets/rwpkgmgr/subscriber/__init__.py b/rwlaunchpad/plugins/rwpkgmgr/rift/tasklets/rwpkgmgr/subscriber/__init__.py index 14c3dc1f..f305f2f6 100644 --- a/rwlaunchpad/plugins/rwpkgmgr/rift/tasklets/rwpkgmgr/subscriber/__init__.py +++ b/rwlaunchpad/plugins/rwpkgmgr/rift/tasklets/rwpkgmgr/subscriber/__init__.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .download_status import DownloadStatusSubscriber, VnfdStatusSubscriber, NsdStatusSubscriber +from .download_status import DownloadStatusSubscriber diff --git a/rwlaunchpad/plugins/rwpkgmgr/rift/tasklets/rwpkgmgr/subscriber/download_status.py b/rwlaunchpad/plugins/rwpkgmgr/rift/tasklets/rwpkgmgr/subscriber/download_status.py index 8fd041ec..c4a5a531 100644 --- a/rwlaunchpad/plugins/rwpkgmgr/rift/tasklets/rwpkgmgr/subscriber/download_status.py +++ b/rwlaunchpad/plugins/rwpkgmgr/rift/tasklets/rwpkgmgr/subscriber/download_status.py @@ -17,100 +17,12 @@ # Creation Date: 09/25/2016 # -import os -import io -import shutil - import rift.mano.dts as mano_dts -import rift.package.package as package -import rift.package.store as store -import rift.package.convert as convert -from gi.repository import ( - RwYang, - NsdYang, - RwNsdYang, - VnfdYang, - RwVnfdYang, - RwDts -) class DownloadStatusSubscriber(mano_dts.AbstractOpdataSubscriber): - - def __init__(self, log, dts, loop, callback): + def __init__(self, log, dts, loop, callback=None): super().__init__(log, dts, loop, callback) - - def get_xpath(self): - return ("D,/rw-pkg-mgmt:download-jobs/rw-pkg-mgmt:job") - -class VnfdStatusSubscriber(DownloadStatusSubscriber): - DOWNLOAD_DIR = store.VnfdPackageFilesystemStore.DEFAULT_ROOT_DIR - MODULE_DESC = 'vnfd rw-vnfd'.split() - DESC_TYPE = 'vnfd' - - def __init__(self, log, dts, loop): - super().__init__(log, dts, loop, self.on_change) - self.subscriber = mano_dts.VnfdCatalogSubscriber(log, dts, loop) - - def on_change(self, msg, action): - log_msg = "1. Vnfd called w/ msg attributes: {} id {} name {} action: {}".format(repr(msg), msg.id, msg.name, repr(action)) - self.log.debug(log_msg) - if action == RwDts.QueryAction.UPDATE: - actionCreate(self, msg) - - elif action == RwDts.QueryAction.DELETE: - actionDelete(self, msg) - - def get_xpath(self): - return self.subscriber.get_xpath() - - -class NsdStatusSubscriber(DownloadStatusSubscriber): - DOWNLOAD_DIR = store.NsdPackageFilesystemStore.DEFAULT_ROOT_DIR - MODULE_DESC = 'nsd rw-nsd'.split() - DESC_TYPE = 'nsd' - - def __init__(self, log, dts, loop): - super().__init__(log, dts, loop, self.on_change) - self.subscriber = mano_dts.NsdCatalogSubscriber(log, dts, loop) - - def on_change(self, msg, action): - log_msg = "1. Nsd called w/ msg attributes: {} id {} name {} action: {}".format(repr(msg), msg.id, msg.name, repr(action)) - self.log.debug(log_msg) - if action == RwDts.QueryAction.UPDATE: - actionCreate(self, msg) - - elif action == RwDts.QueryAction.DELETE: - actionDelete(self, msg) - - def get_xpath(self): - return self.subscriber.get_xpath() - - -def actionCreate(descriptor, msg): - ''' Create folder structure if it doesn't exist: id/vnf name OR id/nsd name - Serialize the Vnfd/Nsd object to yaml and store yaml file in the created folder. - ''' - - download_dir = os.path.join(descriptor.DOWNLOAD_DIR, msg.id, msg.name) - - if not os.path.exists(download_dir): - os.makedirs(download_dir) - descriptor.log.debug("Created directory {}".format(download_dir)) - - model = RwYang.Model.create_libncx() - for module in descriptor.MODULE_DESC: model.load_module(module) - - yaml_path = "{base}/{name}_{type}.yaml".format(base=download_dir, name=msg.name, type=descriptor.DESC_TYPE) - with open(yaml_path,"w") as fh: - fh.write(msg.to_yaml(model)) - -def actionDelete(descriptor, msg): - ''' Delete folder structure created above. - ''' - - download_dir = os.path.join(descriptor.DOWNLOAD_DIR, msg.id) - if os.path.exists(download_dir): - descriptor.log.debug("Removing directory {}".format(download_dir)) - shutil.rmtree(download_dir) + def get_xpath(self): + return ("D,/rw-pkg-mgmt:download-jobs/rw-pkg-mgmt:job") diff --git a/rwlaunchpad/plugins/rwpkgmgr/test/utest_subscriber_dts.py b/rwlaunchpad/plugins/rwpkgmgr/test/utest_subscriber_dts.py index 3b377c7b..4281e11d 100755 --- a/rwlaunchpad/plugins/rwpkgmgr/test/utest_subscriber_dts.py +++ b/rwlaunchpad/plugins/rwpkgmgr/test/utest_subscriber_dts.py @@ -135,4 +135,4 @@ def main(argv=sys.argv[1:]): ) if __name__ == '__main__': - main() + main() \ No newline at end of file diff --git a/rwlaunchpad/plugins/yang/rw-pkg-mgmt.yang b/rwlaunchpad/plugins/yang/rw-pkg-mgmt.yang index de56e554..8370c1b9 100644 --- a/rwlaunchpad/plugins/yang/rw-pkg-mgmt.yang +++ b/rwlaunchpad/plugins/yang/rw-pkg-mgmt.yang @@ -53,13 +53,6 @@ module rw-pkg-mgmt prefix "manotypes"; } - import rw-vnfd { - prefix "rwvnfd"; - } - import rw-nsd { - prefix "rwnsd"; - } - revision 2016-06-01 { description "Initial revision."; @@ -347,4 +340,4 @@ module rw-pkg-mgmt } } -} +} \ No newline at end of file -- 2.25.1