def _main(): arguments_json_path = sys.argv[1] with open(arguments_json_path) as f: arguments = pickle.loads(f.read()) # arguments_json_path is a temporary file created by the parent process. # so we remove it here os.remove(arguments_json_path) task_id = arguments['task_id'] port = arguments['port'] messenger = _Messenger(task_id=task_id, port=port) function = arguments['function'] operation_arguments = arguments['operation_arguments'] context_dict = arguments['context'] try: ctx = context_dict['context_cls'].instantiate_from_dict(**context_dict['context']) except BaseException as e: messenger.failed(e) return try: messenger.started() task_func = imports.load_attribute(function) aria.install_aria_extensions() for decorate in process_executor.decorate(): task_func = decorate(task_func) task_func(ctx=ctx, **operation_arguments) ctx.close() messenger.succeeded() except BaseException as e: ctx.close() messenger.failed(e)
def _main(): arguments_json_path = sys.argv[1] with open(arguments_json_path) as f: arguments = jsonpickle.loads(f.read()) # arguments_json_path is a temporary file created by the parent process. # so we remove it here os.remove(arguments_json_path) task_id = arguments['task_id'] port = arguments['port'] messenger = _Messenger(task_id=task_id, port=port) messenger.started() operation_mapping = arguments['operation_mapping'] operation_inputs = arguments['operation_inputs'] context_dict = arguments['context'] # This is required for the instrumentation work properly. # See docstring of `remove_mutable_association_listener` for further details storage_type.remove_mutable_association_listener() with instrumentation.track_changes() as instrument: try: ctx = serialization.operation_context_from_dict(context_dict) _patch_session(ctx=ctx, messenger=messenger, instrument=instrument) task_func = imports.load_attribute(operation_mapping) aria.install_aria_extensions() for decorate in process_executor.decorate(): task_func = decorate(task_func) task_func(ctx=ctx, **operation_inputs) messenger.succeeded(tracked_changes=instrument.tracked_changes) except BaseException as e: messenger.failed(exception=e, tracked_changes=instrument.tracked_changes)
def start(): install_aria_extensions() aria = AriaRestApi(name=OPENO_SERVICE_NAME, port=arguments.port or OPENO_SERVICE_PORT, base_path=OPENO_BASE_PATH) registration.register() start_daemon(context, aria.run)
def main(): import sys sys.argv = [ "aria", "service-template", "validate", "/home/abhishek/projects/parser/imran/sol001/test_working.yaml" ] install_aria_extensions() _register_commands() _aria()
def create(**_): env = Environment(ctx) # Make sure there is no other stored service template with the same name. # We check this here, and not catching the exception that ARIA raises in # this case since we want to preform this check before any 'heavy-lifting' # operations. if env.model_storage.service_template.list( filters={'name': env.service_template_name}): raise ServiceTemplateAlreadyExistsException( '`Install` workflow already ran on deployment(id={deployment.id}).' ' In order to run it again, please first run the `Uninstall` ' 'workflow for deployment(id={deployment.id})'.format( deployment=ctx.deployment)) # extract csar csar_path = ctx.node.properties[CSAR_PATH_PROPERTY] csar_source = generate_resource_path(csar_path, env.blueprint_dir) csar = extract_csar(csar_source, ctx.logger) files_to_remove = [csar.destination] csar_plugins_dir = os.path.join(csar.destination, 'plugins') # install plugins plugins_to_install = ctx.node.properties[PLUGINS_PROPERTY] ctx.logger.info('Installing required plugins for ARIA: {0}...'.format( plugins_to_install)) try: install_plugins(csar_plugins_dir, plugins_to_install, env.plugin_manager, ctx.logger) except PluginsAlreadyExistException as e: ctx.logger.debug(e.message) ctx.logger.info('Successfully installed required plugins') # store service template aria.install_aria_extensions(strict=False) service_template_path = os.path.join(csar.destination, csar.entry_definitions) ctx.logger.info('Storing service template {0}...'.format( env.service_template_name)) env.core.create_service_template( service_template_path=service_template_path, service_template_dir=os.path.dirname(service_template_path), service_template_name=env.service_template_name) ctx.logger.info('Successfully stored service template') # create service inputs = ctx.node.properties[INPUTS_PROPERTY] ctx.logger.info('Creating service {0} with inputs {1}...'.format( env.service_template_name, inputs)) service_template = env.core.model_storage.service_template.get_by_name( env.service_template_name) env.core.create_service(service_template.id, inputs) ctx.logger.info('Successfully created service') cleanup_files(files_to_remove)
def parse_args(args_list): """ CLI entry point """ install_aria_extensions() parser = argparse.ArgumentParser( description='VNF SDK CSAR manipulation tool') subparsers = parser.add_subparsers(help='csar-create') csar_create = subparsers.add_parser('csar-create') csar_create.set_defaults(func=csar_create_func) csar_create.add_argument( '-v', '--verbose', dest='verbosity', action='count', default=0, help='Set verbosity level (can be passed multiple times)') csar_create.add_argument('source', help='Service template directory') csar_create.add_argument( 'entry', help='Entry definition file relative to service template directory') csar_create.add_argument('-d', '--destination', help='Output CSAR zip destination', required=True) csar_open = subparsers.add_parser('csar-open') csar_open.set_defaults(func=csar_open_func) csar_open.add_argument('source', help='CSAR file location') csar_open.add_argument('-d', '--destination', help='Output directory to extract the CSAR into', required=True) csar_validate = subparsers.add_parser('csar-validate') csar_validate.set_defaults(func=csar_validate_func) csar_validate.add_argument('source', help='CSAR file location') return parser.parse_args(args_list)
# # 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. # from aria import install_aria_extensions from aria.consumption import ConsumptionContext, ConsumerChain, Read, Validate, Model, Instance from aria.loading import UriLocation, LiteralLocation from aria_extension_cloudify import ClassicDeploymentPlan from aria_extension_cloudify.v1_3 import CloudifyPresenter1_3 import os install_aria_extensions() def parse_from_path(dsl_file_path, resources_base_url=None, additional_resource_sources=(), validate_version=True, **legacy): paths = [] path = os.path.dirname(dsl_file_path) if path: paths.append(path) if resources_base_url: paths.append(resources_base_url) paths += additional_resource_sources return _parse(UriLocation(dsl_file_path), paths, validate_version)
def main(): install_aria_extensions() app.run(host='0.0.0.0', port=5000, threaded=True)
def main(): install_aria_extensions() _register_commands() _aria()
def install_aria_extensions(): aria.install_aria_extensions()
# 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. from tempfile import mkdtemp from flask_restful import Resource from aria import core, install_aria_extensions from aria import application_resource_storage from aria import storage from aria.orchestrator import plugin from manager_rest.storage import aria_model install_aria_extensions(strict=False) class BaseARIAEndpoints(Resource): def __init__(self, *args, **kwargs): super(BaseARIAEndpoints, self).__init__(*args, **kwargs) self._tmpdir = mkdtemp() self._model = None self._resource = None self._plugin_manager = None self._core = None @property def core(self): if self._core is None: self._core = core.Core(self.model, self.resource,
def create_service(self, *args, **kwargs): aria_.install_aria_extensions() kwargs.setdefault('inputs', {}) self._core.create_service(*args, **kwargs)
def create_service_template(self, path, name): aria_.install_aria_extensions() self._core.create_service_template(path, os.path.dirname(path), name) return str(self.model.service_template.get_by_name(name).id)