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 CLI ``plugins`` sub-commands.
22 from ..core import aria
25 PLUGIN_COLUMNS = ['id', 'package_name', 'package_version', 'supported_platform',
26 'distribution', 'distribution_release', 'uploaded_at']
29 @aria.group(name='plugins')
30 @aria.options.verbose()
38 @plugins.command(name='validate',
39 short_help='Validate a plugin archive')
40 @aria.argument('plugin-path')
41 @aria.options.verbose()
42 @aria.pass_plugin_manager
44 def validate(plugin_path, plugin_manager, logger):
46 Validate a plugin archive
48 A valid plugin is a wagon (`http://github.com/cloudify-cosmo/wagon`) in the ZIP format (suffix
51 PLUGIN_PATH is the path to the wagon archive.
53 logger.info('Validating plugin {0}...'.format(plugin_path))
54 plugin_manager.validate_plugin(plugin_path)
55 logger.info('Plugin validated successfully')
58 @plugins.command(name='install',
59 short_help='Install a plugin')
60 @aria.argument('plugin-path')
61 @aria.options.verbose()
63 @aria.pass_plugin_manager
65 def install(ctx, plugin_path, plugin_manager, logger):
69 A valid plugin is a wagon (`http://github.com/cloudify-cosmo/wagon`) in the ZIP format (suffix
72 PLUGIN_PATH is the path to the wagon archive.
74 ctx.invoke(validate, plugin_path=plugin_path)
75 logger.info('Installing plugin {0}...'.format(plugin_path))
76 plugin = plugin_manager.install(plugin_path)
77 logger.info("Plugin installed. The plugin's id is {0}".format(plugin.id))
80 @plugins.command(name='show',
81 short_help='Show information for an installed plugin')
82 @aria.argument('plugin-id')
83 @aria.options.verbose()
84 @aria.pass_model_storage
86 def show(plugin_id, model_storage, logger):
88 Show information for an installed plugin
90 PLUGIN_ID is the unique installed plugin ID in this ARIA instance.
92 logger.info('Showing plugin {0}...'.format(plugin_id))
93 plugin = model_storage.plugin.get(plugin_id)
94 table.print_data(PLUGIN_COLUMNS, plugin, 'Plugin:')
97 @plugins.command(name='list',
98 short_help='List all installed plugins')
99 @aria.options.sort_by('uploaded_at')
100 @aria.options.descending
101 @aria.options.verbose()
102 @aria.pass_model_storage
104 def list(sort_by, descending, model_storage, logger):
106 List all installed plugins
108 logger.info('Listing all plugins...')
109 plugins_list = model_storage.plugin.list(
110 sort=utils.storage_sort_param(sort_by, descending)).items
111 table.print_data(PLUGIN_COLUMNS, plugins_list, 'Plugins:')