1 # Licensed to the Apache Software Foundation (ASF) under one or more
2 # contributor license agreements. See the NOTICE file distributed with
3 # this work for additional information regarding copyright ownership.
4 # The ASF licenses this file to You under the Apache License, Version 2.0
5 # (the "License"); you may not use this file except in compliance with
6 # the License. You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 The ARIA root package provides entry points for extension and storage initialization.
23 aria_package_name = 'apache-ariatosca'
24 __version__ = pkg_resources.get_distribution(aria_package_name).version
26 from .orchestrator.decorators import workflow, operation # pylint: disable=wrong-import-position
27 from . import ( # pylint: disable=wrong-import-position
37 if sys.version_info < (2, 7):
38 # pkgutil in python2.6 has a bug where it fails to import from protected modules, which causes
39 # the entire process to fail. In order to overcome this issue we use our custom iter_modules
40 from .utils.imports import iter_modules
42 from pkgutil import iter_modules
48 'install_aria_extensions',
49 'application_model_storage',
50 'application_resource_storage'
54 def install_aria_extensions():
56 Iterates all Python packages with names beginning with ``aria_extension_`` and all
57 ``aria_extension`` entry points and loads them.
59 It then invokes all registered extension functions.
61 for loader, module_name, _ in iter_modules():
62 if module_name.startswith('aria_extension_'):
63 loader.find_module(module_name).load_module(module_name)
64 for entry_point in pkg_resources.iter_entry_points(group='aria_extension'):
69 def application_model_storage(api, api_kwargs=None, initiator=None, initiator_kwargs=None):
71 Initiate model storage.
73 return storage.ModelStorage(api_cls=api,
74 api_kwargs=api_kwargs,
75 items=modeling.models.models_to_register,
77 initiator_kwargs=initiator_kwargs or {})
80 def application_resource_storage(api, api_kwargs=None, initiator=None, initiator_kwargs=None):
82 Initiate resource storage.
85 return storage.ResourceStorage(api_cls=api,
86 api_kwargs=api_kwargs,
87 items=['service_template', 'service', 'plugin'],
89 initiator_kwargs=initiator_kwargs)