few deletion-commands related fixes
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/29379f0f Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/29379f0f Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/29379f0f Branch: refs/heads/ARIA-48-aria-cli Commit: 29379f0f6e6bdee126670c4d3f1b47b00a880b9c Parents: 08eb48b Author: Ran Ziv <[email protected]> Authored: Mon Apr 3 23:28:11 2017 +0300 Committer: Ran Ziv <[email protected]> Committed: Thu Apr 6 11:29:17 2017 +0300 ---------------------------------------------------------------------- aria/cli/commands/service_templates.py | 13 +++++++------ aria/cli/commands/services.py | 3 ++- aria/core.py | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/29379f0f/aria/cli/commands/service_templates.py ---------------------------------------------------------------------- diff --git a/aria/cli/commands/service_templates.py b/aria/cli/commands/service_templates.py index 6c6224b..a324131 100644 --- a/aria/cli/commands/service_templates.py +++ b/aria/cli/commands/service_templates.py @@ -126,23 +126,24 @@ def store(service_template_path, service_template_name, model_storage, resource_ @service_templates.command(name='delete', short_help='Delete a service template') [email protected]('service-template-id') [email protected]('service-template-name') @aria.options.verbose() @aria.pass_model_storage @aria.pass_resource_storage @aria.pass_plugin_manager @aria.pass_logger -def delete(service_template_id, model_storage, resource_storage, plugin_manager, logger): +def delete(service_template_name, model_storage, resource_storage, plugin_manager, logger): """Delete a service template - `SERVICE_TEMPLATE_ID` is the id of the service template to delete. + `SERVICE_TEMPLATE_NAME` is the name of the service template to delete. """ - logger.info('Deleting service template {0}...'.format(service_template_id)) + logger.info('Deleting service template {0}...'.format(service_template_name)) + service_template = model_storage.service_template.get_by_name(service_template_name) core = Core(model_storage, resource_storage, plugin_manager) try: - core.delete_service_template(service_template_id) + core.delete_service_template(service_template.id) except storage_exceptions.NotFoundError: raise AriaCliError() - logger.info('Service template {0} deleted'.format(service_template_id)) + logger.info('Service template {0} deleted'.format(service_template_name)) @service_templates.command(name='inputs', http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/29379f0f/aria/cli/commands/services.py ---------------------------------------------------------------------- diff --git a/aria/cli/commands/services.py b/aria/cli/commands/services.py index 9f9d104..e09db21 100644 --- a/aria/cli/commands/services.py +++ b/aria/cli/commands/services.py @@ -123,8 +123,9 @@ def delete(service_name, force, model_storage, resource_storage, plugin_manager, `SERVICE_NAME` is the name of the service to delete. """ logger.info('Deleting service {0}...'.format(service_name)) + service = model_storage.service.get_by_name(service_name) core = Core(model_storage, resource_storage, plugin_manager) - core.delete_service(service_name, force=force) + core.delete_service(service.id, force=force) logger.info('Service {0} deleted'.format(service_name)) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/29379f0f/aria/core.py ---------------------------------------------------------------------- diff --git a/aria/core.py b/aria/core.py index a589a8e..1fd3cf7 100644 --- a/aria/core.py +++ b/aria/core.py @@ -88,11 +88,11 @@ class Core(object): "Active execution id: {1}".format(service.name, active_executions[0].id)) if not force: - available_nodes = [n for n in service.nodes.values() if n.is_available()] + available_nodes = [str(n.id) for n in service.nodes.values() if n.is_available()] if available_nodes: raise exceptions.DependentAvailableNodesError( "Can't delete service {0} - there are available nodes for this service. " - "Available node ids: {1}".format(service.name, available_nodes)) + "Available node ids: {1}".format(service.name, ', '.join(available_nodes))) self.model_storage.service.delete(service)
