X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=azure%2Faria%2Faria-extension-cloudify%2Fsrc%2Faria%2Faria%2F__init__.py;fp=azure%2Faria%2Faria-extension-cloudify%2Fsrc%2Faria%2Faria%2F__init__.py;h=76a62ce743b4485b5713666bda2a4ba914f092e0;hb=7409dfb144cf2a06210400134d822a1393462b1f;hp=0000000000000000000000000000000000000000;hpb=9e65649dfff8f00dc0a0ef6b10d020ae0e2255ba;p=multicloud%2Fazure.git diff --git a/azure/aria/aria-extension-cloudify/src/aria/aria/__init__.py b/azure/aria/aria-extension-cloudify/src/aria/aria/__init__.py new file mode 100644 index 0000000..76a62ce --- /dev/null +++ b/azure/aria/aria-extension-cloudify/src/aria/aria/__init__.py @@ -0,0 +1,89 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. + +""" +The ARIA root package provides entry points for extension and storage initialization. +""" + +import sys + +import pkg_resources +aria_package_name = 'apache-ariatosca' +__version__ = pkg_resources.get_distribution(aria_package_name).version + +from .orchestrator.decorators import workflow, operation # pylint: disable=wrong-import-position +from . import ( # pylint: disable=wrong-import-position + extension, + utils, + parser, + storage, + modeling, + orchestrator, + cli +) + +if sys.version_info < (2, 7): + # pkgutil in python2.6 has a bug where it fails to import from protected modules, which causes + # the entire process to fail. In order to overcome this issue we use our custom iter_modules + from .utils.imports import iter_modules +else: + from pkgutil import iter_modules + +__all__ = ( + '__version__', + 'workflow', + 'operation', + 'install_aria_extensions', + 'application_model_storage', + 'application_resource_storage' +) + + +def install_aria_extensions(): + """ + Iterates all Python packages with names beginning with ``aria_extension_`` and all + ``aria_extension`` entry points and loads them. + + It then invokes all registered extension functions. + """ + for loader, module_name, _ in iter_modules(): + if module_name.startswith('aria_extension_'): + loader.find_module(module_name).load_module(module_name) + for entry_point in pkg_resources.iter_entry_points(group='aria_extension'): + entry_point.load() + extension.init() + + +def application_model_storage(api, api_kwargs=None, initiator=None, initiator_kwargs=None): + """ + Initiate model storage. + """ + return storage.ModelStorage(api_cls=api, + api_kwargs=api_kwargs, + items=modeling.models.models_to_register, + initiator=initiator, + initiator_kwargs=initiator_kwargs or {}) + + +def application_resource_storage(api, api_kwargs=None, initiator=None, initiator_kwargs=None): + """ + Initiate resource storage. + """ + + return storage.ResourceStorage(api_cls=api, + api_kwargs=api_kwargs, + items=['service_template', 'service', 'plugin'], + initiator=initiator, + initiator_kwargs=initiator_kwargs)