[5/9] incubator-ariatosca git commit: ARIA-48 Revamped ARIA CLI

2017-04-19 Thread emblemparade
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/aria/utils/http.py
--
diff --git a/aria/utils/http.py b/aria/utils/http.py
new file mode 100644
index 000..7bdfd79
--- /dev/null
+++ b/aria/utils/http.py
@@ -0,0 +1,62 @@
+# 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.
+
+import os
+import tempfile
+
+import requests
+
+
+def download_file(url, destination=None, logger=None, progress_handler=None):
+"""Download file.
+
+May raise IOError as well as requests.exceptions.RequestException
+:param url: Location of the file to download
+:type url: str
+:param destination:
+Location where the file should be saved (autogenerated by default)
+:type destination: str | None
+:returns: Location where the file was saved
+:rtype: str
+
+"""
+chunk_size = 1024
+
+if not destination:
+file_descriptor, destination = tempfile.mkstemp()
+os.close(file_descriptor)
+if logger:
+logger.info('Downloading {0} to {1}...'.format(url, destination))
+
+response = requests.get(url, stream=True)
+final_url = response.url
+if final_url != url and logger:
+logger.debug('Redirected to {0}'.format(final_url))
+
+read_bytes = 0
+total_size = int(response.headers['Content-Length']) \
+if 'Content-Length' in response.headers else None
+try:
+with open(destination, 'wb') as destination_file:
+for chunk in response.iter_content(chunk_size):
+destination_file.write(chunk)
+if total_size and progress_handler:
+# Only showing progress bar if we have the total content 
length
+read_bytes += chunk_size
+progress_handler(read_bytes, total_size)
+finally:
+response.close()
+
+return destination

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/aria/utils/threading.py
--
diff --git a/aria/utils/threading.py b/aria/utils/threading.py
index b99250d..bfd30f5 100644
--- a/aria/utils/threading.py
+++ b/aria/utils/threading.py
@@ -15,6 +15,7 @@
 
 from __future__ import absolute_import  # so we can import standard 'threading'
 
+import sys
 import itertools
 import multiprocessing
 from threading import (Thread, Lock)
@@ -255,3 +256,26 @@ class LockedList(list):
 
 def __exit__(self, the_type, value, traceback):
 return self.lock.__exit__(the_type, value, traceback)
+
+
+class ExceptionThread(Thread):
+"""
+A thread from which top level exceptions can be retrieved or reraised
+"""
+def __init__(self, *args, **kwargs):
+Thread.__init__(self, *args, **kwargs)
+self.exception = None
+
+def run(self):
+try:
+super(ExceptionThread, self).run()
+except BaseException:
+self.exception = sys.exc_info()
+
+def is_error(self):
+return self.exception is not None
+
+def raise_error_if_exists(self):
+if self.is_error():
+type_, value, trace = self.exception
+raise type_, value, trace

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/aria/utils/type.py
--
diff --git a/aria/utils/type.py b/aria/utils/type.py
new file mode 100644
index 000..dad5427
--- /dev/null
+++ b/aria/utils/type.py
@@ -0,0 +1,61 @@
+# 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 

[jira] [Commented] (ARIA-48) ARIA CLI

2017-04-19 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-48?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15975866#comment-15975866
 ] 

ASF subversion and git services commented on ARIA-48:
-

Commit 8e5a1ec2fb8d072dc9725be700fce3c570d51de3 in incubator-ariatosca's branch 
refs/heads/ARIA-139-attributes from [~ran]
[ https://git-wip-us.apache.org/repos/asf?p=incubator-ariatosca.git;h=8e5a1ec ]

ARIA-48 Revamped ARIA CLI

This is a large commit which revolves mostly around creating the
new CLI, but is also tying ARIA's various components together
for real for the first time - allowing a complete run of the
"hello-world" example and more.

This commit introduces a few other important modules:
 - aria/core.py - used for managing service-templates and services.
 - aria/orchestator/workflow_runner.py - used for managing
   a workflow execution on a service.
 - aria/orchestrator/dry.py - a "dry executor", used for
   dry-executing workflows and printing the tasks that would run.

Other fixes that were required for the successful usage of
ARIA end-to-end have also been introduced in this commit, but
there have been too many to list; Review the commit for more info.


> ARIA CLI
> 
>
> Key: ARIA-48
> URL: https://issues.apache.org/jira/browse/ARIA-48
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Ran Ziv
> Fix For: 0.1.0
>
>
> Create a CLI for ARIA (based on Cloudify's CLI)



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[8/9] incubator-ariatosca git commit: ARIA-48 Revamped ARIA CLI

2017-04-19 Thread emblemparade
ARIA-48 Revamped ARIA CLI

This is a large commit which revolves mostly around creating the
new CLI, but is also tying ARIA's various components together
for real for the first time - allowing a complete run of the
"hello-world" example and more.

This commit introduces a few other important modules:
 - aria/core.py - used for managing service-templates and services.
 - aria/orchestator/workflow_runner.py - used for managing
   a workflow execution on a service.
 - aria/orchestrator/dry.py - a "dry executor", used for
   dry-executing workflows and printing the tasks that would run.

Other fixes that were required for the successful usage of
ARIA end-to-end have also been introduced in this commit, but
there have been too many to list; Review the commit for more info.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/8e5a1ec2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/8e5a1ec2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/8e5a1ec2

Branch: refs/heads/ARIA-139-attributes
Commit: 8e5a1ec2fb8d072dc9725be700fce3c570d51de3
Parents: a7e7826
Author: Ran Ziv 
Authored: Tue Mar 28 12:17:46 2017 +0300
Committer: Ran Ziv 
Committed: Wed Apr 19 16:36:32 2017 +0300

--
 aria/.pylintrc  |   2 +-
 aria/__init__.py|   2 +-
 aria/cli/args_parser.py | 269 -
 aria/cli/cli.py | 113 
 aria/cli/commands.py| 546 ---
 aria/cli/commands/__init__.py   |  26 +
 aria/cli/commands/executions.py | 172 ++
 aria/cli/commands/logs.py   |  65 +++
 aria/cli/commands/node_templates.py |  93 
 aria/cli/commands/nodes.py  |  87 +++
 aria/cli/commands/plugins.py|  99 
 aria/cli/commands/reset.py  |  40 ++
 aria/cli/commands/service_templates.py  | 208 +++
 aria/cli/commands/services.py   | 179 ++
 aria/cli/commands/workflows.py  | 100 
 aria/cli/config.py  |  46 --
 aria/cli/config/__init__.py |  14 +
 aria/cli/config/config.py   |  73 +++
 aria/cli/config/config_template.yaml|  12 +
 aria/cli/core/__init__.py   |  14 +
 aria/cli/core/aria.py   | 429 +++
 aria/cli/csar.py|  13 +-
 aria/cli/defaults.py|  20 +
 aria/cli/dry.py |  93 
 aria/cli/env.py | 124 +
 aria/cli/exceptions.py  |  54 +-
 aria/cli/helptexts.py   |  49 ++
 aria/cli/inputs.py  | 118 
 aria/cli/logger.py  | 114 
 aria/cli/main.py|  58 ++
 aria/cli/service_template_utils.py  | 121 
 aria/cli/storage.py |  95 
 aria/cli/table.py   | 116 
 aria/cli/utils.py   | 115 
 aria/core.py| 124 +
 aria/exceptions.py  |  29 +
 aria/logger.py  |  12 +
 aria/modeling/__init__.py   |   2 +
 aria/modeling/exceptions.py |  25 +
 aria/modeling/models.py |   9 +-
 aria/modeling/orchestration.py  |  21 +-
 aria/modeling/service_changes.py|  10 +-
 aria/modeling/service_common.py |  15 +-
 aria/modeling/service_instance.py   |  16 +-
 aria/modeling/service_template.py   |  73 ++-
 aria/modeling/utils.py  |  92 +++-
 aria/orchestrator/context/common.py |  43 +-
 aria/orchestrator/context/operation.py  |   2 -
 aria/orchestrator/context/workflow.py   |  20 +-
 aria/orchestrator/exceptions.py |  28 +
 .../execution_plugin/ctx_proxy/server.py|   3 +-
 .../execution_plugin/instantiation.py   |   2 +-
 aria/orchestrator/plugin.py |  27 +-
 aria/orchestrator/runner.py | 101 
 aria/orchestrator/workflow_runner.py| 161 ++
 aria/orchestrator/workflows/api/task.py |  96 ++--
 aria/orchestrator/workflows/builtin/__init__.py |   1 +
 .../workflows/builtin/execute_operation.py  |  16 +-
 aria/orchestrator/workflows/builtin/utils.py|  82 ++-
 aria/orchestrator/workflows/core/engine.py  |   6 +-
 

[jira] [Commented] (ARIA-127) Sporadic InvocationError in test-operation

2017-04-19 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15975864#comment-15975864
 ] 

ASF subversion and git services commented on ARIA-127:
--

Commit 8e1d059f9747327b4036b98c1f842d3f05c6c5f0 in incubator-ariatosca's branch 
refs/heads/ARIA-139-attributes from [~emblemparade]
[ https://git-wip-us.apache.org/repos/asf?p=incubator-ariatosca.git;h=8e1d059 ]

ARIA-127 Make use of in-memory sqlite more robust


> Sporadic InvocationError in test-operation
> --
>
> Key: ARIA-127
> URL: https://issues.apache.org/jira/browse/ARIA-127
> Project: AriaTosca
>  Issue Type: Task
>Reporter: Ran Ziv
>Assignee: Tal Liron
>Priority: Minor
> Fix For: 0.1.0
>
>
> {{tests/orchestrator/context/test_operation.py}} fails intermittently with 
> {{InvocationError}}, both on CI and locally.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[2/9] incubator-ariatosca git commit: ARIA-92 Automatic operation task configuration

2017-04-19 Thread emblemparade
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a7e7826e/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
--
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py 
b/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
index 267f6de..0e9177f 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
@@ -23,6 +23,8 @@ import re
 from types import FunctionType
 from datetime import datetime
 
+from aria.parser.validation import Issue
+from aria.utils.collections import StrictDict
 from aria.modeling.models import (Type, ServiceTemplate, NodeTemplate,
   RequirementTemplate, RelationshipTemplate, 
CapabilityTemplate,
   GroupTemplate, PolicyTemplate, 
SubstitutionTemplate,
@@ -32,6 +34,11 @@ from aria.modeling.models import (Type, ServiceTemplate, 
NodeTemplate,
 from ..data_types import coerce_value
 
 
+# These match the first un-escaped ">"
+# See: http://stackoverflow.com/a/11819111/849021
+IMPLEMENTATION_PREFIX_REGEX = re.compile(r'(?')
+
+
 def create_service_template_model(context): # pylint: 
disable=too-many-locals,too-many-branches
 model = ServiceTemplate(created_at=datetime.now(),
 main_file_name=str(context.presentation.location))
@@ -352,20 +359,35 @@ def create_interface_template_model(context, 
service_template, interface):
 return model if model.operation_templates else None
 
 
-def create_operation_template_model(context, service_template, operation): # 
pylint: disable=unused-argument
+def create_operation_template_model(context, service_template, operation):
 model = OperationTemplate(name=operation._name)
 
 if operation.description:
 model.description = operation.description.value
 
 implementation = operation.implementation
-if (implementation is not None) and operation.implementation.primary:
-model.plugin_specification, model.implementation = \
-parse_implementation_string(context, service_template, 
operation.implementation.primary)
-
+if implementation is not None: 
+primary = implementation.primary
+parse_implementation_string(context, service_template, operation, 
model, primary)
+relationship_edge = 
operation._get_extensions(context).get('relationship_edge')
+if relationship_edge is not None:
+if relationship_edge == 'source':
+model.relationship_edge = False
+elif relationship_edge == 'target':
+model.relationship_edge = True
+
 dependencies = implementation.dependencies
-if dependencies is not None:
-model.dependencies = dependencies
+if dependencies:
+for dependency in dependencies:
+key, value = split_prefix(dependency)
+if key is not None:
+if model.configuration is None:
+model.configuration = {}
+set_nested(model.configuration, key.split('.'), value)
+else:
+if model.dependencies is None:
+model.dependencies = []
+model.dependencies.append(dependency)
 
 inputs = operation.inputs
 if inputs:
@@ -441,12 +463,13 @@ def create_substitution_template_model(context, 
service_template, substitution_m
 def create_plugin_specification_model(context, policy):
 properties = policy.properties
 
-def get(name):
+def get(name, default=None):
 prop = properties.get(name)
-return prop.value if prop is not None else None
+return prop.value if prop is not None else default
 
 model = PluginSpecification(name=policy._name,
-version=get('version'))
+version=get('version'),
+enabled=get('enabled', True))
 
 return model
 
@@ -461,8 +484,7 @@ def create_workflow_operation_template_model(context, 
service_template, policy):
 properties = policy._get_property_values(context)
 for prop_name, prop in properties.iteritems():
 if prop_name == 'implementation':
-model.plugin_specification, model.implementation = \
-parse_implementation_string(context, service_template, 
prop.value)
+parse_implementation_string(context, service_template, policy, 
model, prop.value)
 elif prop_name == 'dependencies':
 model.dependencies = prop.value
 else:
@@ -677,21 +699,47 @@ def create_constraint_clause_lambda(context, node_filter, 
constraint_clause, pro
 return None
 
 
-def parse_implementation_string(context, service_template, implementation):
-if not implementation:
-return None, 

[6/9] incubator-ariatosca git commit: ARIA-48 Revamped ARIA CLI

2017-04-19 Thread emblemparade
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/aria/modeling/service_template.py
--
diff --git a/aria/modeling/service_template.py 
b/aria/modeling/service_template.py
index 51fea2f..f1c2bcb 100644
--- a/aria/modeling/service_template.py
+++ b/aria/modeling/service_template.py
@@ -280,7 +280,7 @@ class ServiceTemplateBase(TemplateModelMixin):
 ('interface_types', formatting.as_raw(self.interface_types)),
 ('artifact_types', formatting.as_raw(self.artifact_types
 
-def instantiate(self, container):
+def instantiate(self, container, model_storage, inputs=None):  # pylint: 
disable=arguments-differ
 from . import models
 context = ConsumptionContext.get_thread_local()
 now = datetime.now()
@@ -288,13 +288,14 @@ class ServiceTemplateBase(TemplateModelMixin):
  updated_at=now,
  
description=deepcopy_with_locators(self.description),
  service_template=self)
-#service.name = '{0}_{1}'.format(self.name, service.id)
-
 context.modeling.instance = service
 
+service.inputs = utils.create_inputs(inputs or {}, self.inputs)
+# TODO: now that we have inputs, we should scan properties and inputs 
and evaluate functions
+
 for plugin_specification in self.plugin_specifications.itervalues():
 if plugin_specification.enabled:
-if plugin_specification.resolve():
+if plugin_specification.resolve(model_storage):
 plugin = plugin_specification.plugin
 service.plugins[plugin.name] = plugin
 else:
@@ -316,15 +317,8 @@ class ServiceTemplateBase(TemplateModelMixin):
 if self.substitution_template is not None:
 service.substitution = 
self.substitution_template.instantiate(container)
 
-utils.instantiate_dict(self, service.inputs, self.inputs)
 utils.instantiate_dict(self, service.outputs, self.outputs)
 
-for name, the_input in context.modeling.inputs.iteritems():
-if name not in service.inputs:
-context.validation.report('input "{0}" is not 
supported'.format(name))
-else:
-service.inputs[name].value = the_input
-
 return service
 
 def validate(self):
@@ -448,8 +442,7 @@ class NodeTemplateBase(TemplateModelMixin):
 __tablename__ = 'node_template'
 
 __private_fields__ = ['type_fk',
-  'service_template_fk',
-  'service_template_name']
+  'service_template_fk']
 
 # region foreign_keys
 
@@ -472,6 +465,11 @@ class NodeTemplateBase(TemplateModelMixin):
 """Required for use by SQLAlchemy queries"""
 return association_proxy('service_template', 'name')
 
+@declared_attr
+def type_name(cls):
+"""Required for use by SQLAlchemy queries"""
+return association_proxy('type', 'name')
+
 # endregion
 
 # region one_to_one relationships
@@ -558,6 +556,7 @@ class NodeTemplateBase(TemplateModelMixin):
type=self.type,

description=deepcopy_with_locators(self.description),
state=models.Node.INITIAL,
+   runtime_properties={},
node_template=self)
 utils.instantiate_dict(node, node.properties, self.properties)
 utils.instantiate_dict(node, node.interfaces, self.interface_templates)
@@ -1238,7 +1237,8 @@ class RequirementTemplateBase(TemplateModelMixin):
 
 # Find first node that matches the type
 elif self.target_node_type is not None:
-for target_node_template in 
context.modeling.template.node_templates.itervalues():
+for target_node_template in \
+
self.node_template.service_template.node_templates.values():
 if 
self.target_node_type.get_descendant(target_node_template.type.name) is None:
 continue
 
@@ -1865,16 +1865,22 @@ class OperationTemplateBase(TemplateModelMixin):
 
 def instantiate(self, container):
 from . import models
-if self.plugin_specification and self.plugin_specification.enabled:
-plugin = self.plugin_specification.plugin
-implementation = self.implementation if plugin is not None else 
None
-# "plugin" would be none if a match was not found. In that case, a 
validation error
-# should already have been reported in 
ServiceTemplateBase.instantiate, so we will
-# continue silently here
+if self.plugin_specification:
+if self.plugin_specification.enabled:
+plugin = self.plugin_specification.plugin
+implementation = 

[jira] [Commented] (ARIA-92) Execution plugin operations default mappings

2017-04-19 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-92?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15975865#comment-15975865
 ] 

ASF subversion and git services commented on ARIA-92:
-

Commit a7e7826ed2d8b940b9e74ca15cb0284c39b01001 in incubator-ariatosca's branch 
refs/heads/ARIA-139-attributes from [~emblemparade]
[ https://git-wip-us.apache.org/repos/asf?p=incubator-ariatosca.git;h=a7e7826 ]

ARIA-92 Automatic operation task configuration


> Execution plugin operations default mappings
> 
>
> Key: ARIA-92
> URL: https://issues.apache.org/jira/browse/ARIA-92
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Tal Liron
> Fix For: 0.1.0
>
>
> The execution plugin serves as the default plugin, i.e. if no other plugin 
> was specified, it'll be used to execute scripts in operations.
> These scripts will currently only execute locally. The execution plugin also 
> supports running scripts on remote machines (via SSH).
> One option is to have the parser recognize whether the node in question is 
> contained inside a host node, in which case the script should be executed 
> remotely (by default, yet overridable by specifying the full plugin operation 
> mapping), and if not then it should be executed locally.
> Another option is to have the user specify it using special syntax, e.g.:
> "local > script.sh" and "remote > script.sh"



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[3/9] incubator-ariatosca git commit: ARIA-92 Automatic operation task configuration

2017-04-19 Thread emblemparade
ARIA-92 Automatic operation task configuration


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/a7e7826e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/a7e7826e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/a7e7826e

Branch: refs/heads/ARIA-139-attributes
Commit: a7e7826ed2d8b940b9e74ca15cb0284c39b01001
Parents: 8e1d059
Author: Tal Liron 
Authored: Fri Mar 24 16:33:11 2017 -0500
Committer: Tal Liron 
Committed: Fri Apr 14 13:54:21 2017 -0500

--
 aria/cli/dry.py |   9 +-
 aria/modeling/models.py |  11 +-
 aria/modeling/orchestration.py  |  92 +
 aria/modeling/service_common.py |  59 +-
 aria/modeling/service_instance.py   | 199 +--
 aria/modeling/service_template.py   | 133 -
 aria/orchestrator/execution_plugin/__init__.py  |   2 +
 aria/orchestrator/execution_plugin/common.py|   2 +-
 .../execution_plugin/instantiation.py   | 191 ++
 .../execution_plugin/ssh/operations.py  |   4 +-
 aria/orchestrator/workflows/api/task.py | 131 +---
 aria/orchestrator/workflows/api/task_graph.py   |   2 +-
 aria/orchestrator/workflows/builtin/utils.py|   6 +-
 aria/orchestrator/workflows/core/engine.py  |   4 +-
 .../workflows/core/events_handler.py|   8 +-
 aria/orchestrator/workflows/core/task.py|   9 +-
 aria/orchestrator/workflows/exceptions.py   |  10 +-
 aria/orchestrator/workflows/executor/process.py |   2 +-
 aria/parser/consumption/modeling.py |  22 +-
 aria/storage/instrumentation.py |   4 +-
 .../custom_types/elasticsearch.yaml |   2 +
 .../multi-tier-1/custom_types/kibana.yaml   |   2 +
 .../multi-tier-1/custom_types/logstash.yaml |   2 +
 .../paypalpizzastore_nodejs_app.yaml|   2 +-
 .../webserver-dbms-2/webserver-dbms-2.yaml  |   6 +-
 .../profiles/aria-1.0/aria-1.0.yaml |  10 +
 .../profiles/tosca-simple-1.0/capabilities.yaml |   2 +
 .../profiles/tosca-simple-1.0/interfaces.yaml   |  16 ++
 .../profiles/tosca-simple-1.0/nodes.yaml|   1 +
 .../simple_v1_0/assignments.py  |  49 +++--
 .../simple_v1_0/modeling/__init__.py| 104 +++---
 .../simple_v1_0/modeling/capabilities.py|   5 +
 tests/modeling/test_models.py   |  65 +++---
 tests/orchestrator/context/test_operation.py|   3 +-
 tests/orchestrator/context/test_serialize.py|   3 +-
 tests/orchestrator/execution_plugin/test_ssh.py |  17 +-
 tests/orchestrator/workflows/api/test_task.py   |  24 +--
 .../orchestrator/workflows/builtin/__init__.py  |   3 -
 .../workflows/builtin/test_execute_operation.py |   3 +-
 tests/orchestrator/workflows/core/test_task.py  |  29 +--
 .../test_task_graph_into_exececution_graph.py   |   3 +-
 .../workflows/executor/test_executor.py |   1 +
 .../workflows/executor/test_process_executor.py |   1 +
 .../node-cellar/node-cellar.yaml|  36 +++-
 .../node-cellar/types/nginx.yaml|  15 +-
 45 files changed, 886 insertions(+), 418 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a7e7826e/aria/cli/dry.py
--
diff --git a/aria/cli/dry.py b/aria/cli/dry.py
index 098638f..fc6c0c5 100644
--- a/aria/cli/dry.py
+++ b/aria/cli/dry.py
@@ -43,14 +43,19 @@ def convert_to_dry(service):
 for oper in interface.operations.itervalues():
 convert_operation_to_dry(oper)
 
+for group in service.groups.itervalues():
+for interface in group.interfaces.itervalues():
+for oper in interface.operations.itervalues():
+convert_operation_to_dry(oper)
+
 
 def convert_operation_to_dry(oper):
 """
 Converts a single :class:`Operation` to run dryly.
 """
 
-plugin = oper.plugin_specification.name \
-if oper.plugin_specification is not None else None
+plugin = oper.plugin.name \
+if oper.plugin is not None else None
 if oper.inputs is None:
 oper.inputs = OrderedDict()
 oper.inputs['_implementation'] = models.Parameter(name='_implementation',

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a7e7826e/aria/modeling/models.py
--
diff --git a/aria/modeling/models.py b/aria/modeling/models.py
index a01783b..170efb2 100644
--- a/aria/modeling/models.py
+++ b/aria/modeling/models.py
@@ -48,6 +48,7 @@ __all__ = (
 

[4/9] incubator-ariatosca git commit: ARIA-48 Revamped ARIA CLI

2017-04-19 Thread emblemparade
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/tests/modeling/test_models.py
--
diff --git a/tests/modeling/test_models.py b/tests/modeling/test_models.py
index bd4eba4..d64cdba 100644
--- a/tests/modeling/test_models.py
+++ b/tests/modeling/test_models.py
@@ -100,12 +100,13 @@ def _nodes_storage():
 service = storage.service.get_by_name(mock.models.SERVICE_NAME)
 dependency_node_template = storage.node_template.get_by_name(
 mock.models.DEPENDENCY_NODE_TEMPLATE_NAME)
-mock.models.create_node(mock.models.DEPENDENCY_NODE_NAME, 
dependency_node_template, service)
+mock.models.create_node(dependency_node_template, service,
+name=mock.models.DEPENDENCY_NODE_NAME)
 
 dependent_node_template = 
mock.models.create_dependent_node_template(service.service_template,
  
dependency_node_template)
 
-mock.models.create_node(mock.models.DEPENDENT_NODE_NAME, 
dependent_node_template, service)
+mock.models.create_node(dependent_node_template, service, 
name=mock.models.DEPENDENT_NODE_NAME)
 storage.service.update(service)
 return storage
 
@@ -180,7 +181,7 @@ class TestServiceTemplate(object):
 @pytest.mark.parametrize(
 'is_valid, description, created_at, updated_at, main_file_name',
 [
-(False, {}, now, now, '/path'),
+(False, [], now, now, '/path'),
 (False, 'description', 'error', now, '/path'),
 (False, 'description', now, 'error', '/path'),
 (False, 'description', now, now, {}),
@@ -253,7 +254,7 @@ class TestService(object):
 class TestExecution(object):
 
 @pytest.mark.parametrize(
-'is_valid, created_at, started_at, ended_at, error, 
is_system_workflow, parameters, '
+'is_valid, created_at, started_at, ended_at, error, 
is_system_workflow, inputs, '
 'status, workflow_name',
 [
 (False, m_cls, now, now, 'error', False, {}, Execution.STARTED, 
'wf_name'),
@@ -268,11 +269,11 @@ class TestExecution(object):
 (True, now, None, now, 'error', False, {}, Execution.STARTED, 
'wf_name'),
 (True, now, now, None, 'error', False, {}, Execution.STARTED, 
'wf_name'),
 (True, now, now, now, None, False, {}, Execution.STARTED, 
'wf_name'),
-(True, now, now, now, 'error', False, None, Execution.STARTED, 
'wf_name'),
+(True, now, now, now, 'error', False, {}, Execution.STARTED, 
'wf_name'),
 ]
 )
 def test_execution_model_creation(self, service_storage, is_valid, 
created_at, started_at,
-  ended_at, error, is_system_workflow, 
parameters, status,
+  ended_at, error, is_system_workflow, 
inputs, status,
   workflow_name):
 execution = _test_model(
 is_valid=is_valid,
@@ -285,7 +286,7 @@ class TestExecution(object):
 ended_at=ended_at,
 error=error,
 is_system_workflow=is_system_workflow,
-parameters=parameters,
+inputs=inputs,
 status=status,
 workflow_name=workflow_name,
 ))
@@ -299,7 +300,7 @@ class TestExecution(object):
 id='e_id',
 workflow_name='w_name',
 status=status,
-parameters={},
+inputs={},
 created_at=now,
 )
 return execution

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/tests/orchestrator/context/test_operation.py
--
diff --git a/tests/orchestrator/context/test_operation.py 
b/tests/orchestrator/context/test_operation.py
index af8b454..c399474 100644
--- a/tests/orchestrator/context/test_operation.py
+++ b/tests/orchestrator/context/test_operation.py
@@ -69,16 +69,17 @@ def test_node_operation_task_execution(ctx, 
thread_executor):
 interface_name = 'Standard'
 operation_name = 'create'
 
+inputs = {'putput': True}
 node = ctx.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME)
 interface = mock.models.create_interface(
 node.service,
 interface_name,
 operation_name,
-operation_kwargs=dict(implementation=op_path(basic_operation, 
module_path=__name__))
+operation_kwargs=dict(implementation=op_path(basic_operation, 
module_path=__name__),
+  inputs=inputs)
 )
 node.interfaces[interface.name] = interface
 ctx.model.node.update(node)
-inputs = {'putput': True}
 
 @workflow
 def basic_workflow(graph, **_):
@@ -124,17 +125,18 @@ def test_relationship_operation_task_execution(ctx, 
thread_executor):
 

[9/9] incubator-ariatosca git commit: Rebase, work to use models

2017-04-19 Thread emblemparade
Rebase, work to use models


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/9de5d979
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/9de5d979
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/9de5d979

Branch: refs/heads/ARIA-139-attributes
Commit: 9de5d9799d2e5119a4b081993a02abf1f65f79a2
Parents: 8e5a1ec
Author: Tal Liron 
Authored: Wed Apr 19 20:07:33 2017 -0500
Committer: Tal Liron 
Committed: Wed Apr 19 20:07:33 2017 -0500

--
 aria/modeling/service_common.py | 32 ++--
 aria/modeling/service_instance.py   |  8 ++
 aria/modeling/service_template.py   | 16 
 .../simple_v1_0/functions.py| 80 +---
 .../simple_v1_0/modeling/__init__.py|  2 +
 .../simple_v1_0/modeling/data_types.py  |  6 +-
 .../simple_v1_0/modeling/properties.py  | 17 +++--
 .../simple_v1_0/templates.py|  7 +-
 8 files changed, 123 insertions(+), 45 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9de5d979/aria/modeling/service_common.py
--
diff --git a/aria/modeling/service_common.py b/aria/modeling/service_common.py
index 1188f34..0a7df4d 100644
--- a/aria/modeling/service_common.py
+++ b/aria/modeling/service_common.py
@@ -15,6 +15,8 @@
 
 # pylint: disable=no-self-argument, no-member, abstract-method
 
+import datetime
+
 from sqlalchemy import (
 Column,
 Text,
@@ -22,6 +24,7 @@ from sqlalchemy import (
 )
 from sqlalchemy.ext.declarative import declared_attr
 
+from ..parser import dsl_specification
 from ..parser.consumption import ConsumptionContext
 from ..utils import collections, formatting, console
 from .mixins import InstanceModelMixin, TemplateModelMixin
@@ -90,22 +93,41 @@ class ParameterBase(TemplateModelMixin):
 def unwrap(self):
 return self.name, self.value
 
+@dsl_specification('3.2.1-2', 'tosca-simple-1.0')
 @classmethod
 def wrap(cls, name, value, description=None):
 """
 Wraps an arbitrary value as a parameter. The type will be guessed via 
introspection.
 
+For primitive types, we will prefer their TOSCA aliases. See the 
`TOSCA Simple Profile v1.0
+cos01 specification 
`__
+
 :param name: Parameter name
 :type name: basestring
 :param value: Parameter value
 :param description: Description (optional)
 :type description: basestring
 """
-return cls(name=name,
-   type_name=formatting.full_type_name(value)
-   if value is not None else None,
-   value=value,
-   description=description)
+from . import models
+if value is None:
+type_name = 'null'
+elif isinstance(value, basestring):
+type_name = 'string'
+elif isinstance(value, int):
+type_name = 'integer'
+elif isinstance(value, float):
+type_name = 'float'
+elif isinstance(value, bool):
+type_name = 'boolean'
+elif isinstance(value, datetime.datetime):
+type_name = 'timestamp'
+else:
+type_name = formatting.full_type_name(value)
+return models.Parameter(name=name,
+type_name=type_name,
+value=value,
+description=description)
 
 
 class TypeBase(InstanceModelMixin):

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9de5d979/aria/modeling/service_instance.py
--
diff --git a/aria/modeling/service_instance.py 
b/aria/modeling/service_instance.py
index 6d8f3fe..b293535 100644
--- a/aria/modeling/service_instance.py
+++ b/aria/modeling/service_instance.py
@@ -515,6 +515,10 @@ class NodeBase(InstanceModelMixin):
 def properties(cls):
 return relationship.many_to_many(cls, 'parameter', 
prefix='properties', dict_key='name')
 
+@declared_attr
+def attributes(cls):
+return relationship.many_to_many(cls, 'parameter', 
prefix='attributes', dict_key='name')
+
 # endregion
 
 description = Column(Text)
@@ -649,6 +653,7 @@ class NodeBase(InstanceModelMixin):
 ('name', self.name),
 ('type_name', self.type.name),
 ('properties', formatting.as_raw_dict(self.properties)),
+('attributes', 

[1/9] incubator-ariatosca git commit: ARIA-127 Make use of in-memory sqlite more robust [Forced Update!]

2017-04-19 Thread emblemparade
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-139-attributes 3d3a446fc -> 9de5d9799 (forced update)


ARIA-127 Make use of in-memory sqlite more robust


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/8e1d059f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/8e1d059f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/8e1d059f

Branch: refs/heads/ARIA-139-attributes
Commit: 8e1d059f9747327b4036b98c1f842d3f05c6c5f0
Parents: 3dadc9f
Author: Tal Liron 
Authored: Tue Apr 11 18:19:38 2017 -0500
Committer: Tal Liron 
Committed: Thu Apr 13 10:56:31 2017 -0500

--
 tests/storage/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e1d059f/tests/storage/__init__.py
--
diff --git a/tests/storage/__init__.py b/tests/storage/__init__.py
index c5d7678..66424db 100644
--- a/tests/storage/__init__.py
+++ b/tests/storage/__init__.py
@@ -51,6 +51,6 @@ def init_inmemory_model_storage():
 
 engine = create_engine(uri, **engine_kwargs)
 session_factory = orm.sessionmaker(bind=engine)
-session = session_factory()
+session = orm.scoped_session(session_factory=session_factory)
 
 return dict(engine=engine, session=session)



[7/9] incubator-ariatosca git commit: ARIA-48 Revamped ARIA CLI

2017-04-19 Thread emblemparade
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/aria/cli/commands/workflows.py
--
diff --git a/aria/cli/commands/workflows.py b/aria/cli/commands/workflows.py
new file mode 100644
index 000..221dbc4
--- /dev/null
+++ b/aria/cli/commands/workflows.py
@@ -0,0 +1,100 @@
+# 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.
+
+from .. import table
+from ..core import aria
+from ..exceptions import AriaCliError
+
+WORKFLOW_COLUMNS = ['name', 'service_template_name', 'service_name']
+
+
+@aria.group(name='workflows')
+def workflows():
+"""Handle service workflows
+"""
+pass
+
+
+@workflows.command(name='show',
+   short_help='Show workflow information')
+@aria.argument('workflow-name')
+@aria.options.service_name(required=True)
+@aria.options.verbose()
+@aria.pass_model_storage
+@aria.pass_logger
+def show(workflow_name, service_name, model_storage, logger):
+"""Show information for a specific workflow of a specific service
+
+`WORKFLOW_NAME` is the name of the workflow to get information on.
+"""
+logger.info('Retrieving workflow {0} for service {1}'.format(
+workflow_name, service_name))
+service = model_storage.service.get_by_name(service_name)
+workflow = next((wf for wf in service.workflows.values() if
+ wf.name == workflow_name), None)
+if not workflow:
+raise AriaCliError(
+'Workflow {0} not found for service {1}'.format(workflow_name, 
service_name))
+
+defaults = {
+'service_template_name': service.service_template_name,
+'service_name': service.name
+}
+table.print_data(WORKFLOW_COLUMNS, workflow, 'Workflows:', 
defaults=defaults)
+
+# print workflow inputs
+required_inputs = dict()
+optional_inputs = dict()
+for input_name, input in workflow.inputs.iteritems():
+inputs_group = optional_inputs if input.value is not None else 
required_inputs
+inputs_group[input_name] = input
+
+logger.info('Workflow Inputs:')
+logger.info('\tMandatory Inputs:')
+for input_name, input in required_inputs.iteritems():
+if input.description is not None:
+logger.info('\t\t{0}\t({1})'.format(input_name,
+input.description))
+else:
+logger.info('\t\t{0}'.format(input_name))
+
+logger.info('\tOptional Inputs:')
+for input_name, input in optional_inputs.iteritems():
+if input.description is not None:
+logger.info('\t\t{0}: \t{1}\t({2})'.format(
+input_name, input.value, input.description))
+else:
+logger.info('\t\t{0}: \t{1}'.format(input_name,
+input.value))
+
+
+@workflows.command(name='list',
+   short_help='List workflows for a service')
+@aria.options.service_name(required=True)
+@aria.options.verbose()
+@aria.pass_model_storage
+@aria.pass_logger
+def list(service_name, model_storage, logger):
+"""List all workflows of a specific service
+"""
+logger.info('Listing workflows for service {0}...'.format(service_name))
+service = model_storage.service.get_by_name(service_name)
+workflows_list = sorted(service.workflows.values(), key=lambda w: w.name)
+
+defaults = {
+'service_template_name': service.service_template_name,
+'service_name': service.name
+}
+table.print_data(WORKFLOW_COLUMNS, workflows_list, 'Workflows:', 
defaults=defaults)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/aria/cli/config.py
--
diff --git a/aria/cli/config.py b/aria/cli/config.py
deleted file mode 100644
index d82886d..000
--- a/aria/cli/config.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# 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 

incubator-ariatosca git commit: wip [Forced Update!]

2017-04-19 Thread mxmrlv
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-138-Make-logging-more-informative e2655e48b -> 38dfa1b72 
(forced update)


wip


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/38dfa1b7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/38dfa1b7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/38dfa1b7

Branch: refs/heads/ARIA-138-Make-logging-more-informative
Commit: 38dfa1b722b21e275ea97faf8bb5353a840d4a6e
Parents: d90194d
Author: max-orlov 
Authored: Wed Apr 19 20:06:48 2017 +0300
Committer: max-orlov 
Committed: Wed Apr 19 21:34:41 2017 +0300

--
 aria/orchestrator/execution_plugin/instantiation.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/38dfa1b7/aria/orchestrator/execution_plugin/instantiation.py
--
diff --git a/aria/orchestrator/execution_plugin/instantiation.py 
b/aria/orchestrator/execution_plugin/instantiation.py
index 7627a38..db33cf3 100644
--- a/aria/orchestrator/execution_plugin/instantiation.py
+++ b/aria/orchestrator/execution_plugin/instantiation.py
@@ -73,8 +73,8 @@ def _configure_remote(operation, configuration, arguments):
 if ('password' not in ssh) and ('key' not in ssh) and ('key_filename' not 
in ssh):
 ssh['password'] = default_password
 
-arguments['use_sudo'] = ssh.get('use_sudo')
-arguments['hide_output'] = ssh.get('hide_output')
+arguments['use_sudo'] = ssh.get('use_sudo', False)
+arguments['hide_output'] = ssh.get('hide_output', dict(everything=False))
 arguments['fabric_env'] = {}
 if 'warn_only' in ssh:
 arguments['fabric_env']['warn_only'] = ssh['warn_only']



[jira] [Commented] (ARIA-142) defaults missing for execution plugin

2017-04-19 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15975251#comment-15975251
 ] 

ASF subversion and git services commented on ARIA-142:
--

Commit 109458aefcf75b48cf4cf331169960626d7c5207 in incubator-ariatosca's branch 
refs/heads/ARIA-142-defaults-missing-for-execution-plugin from [~Mxmrlv]
[ https://git-wip-us.apache.org/repos/asf?p=incubator-ariatosca.git;h=109458a ]

ARIA-142-defaults-missing-for-execution-plugin


> defaults missing for execution plugin
> -
>
> Key: ARIA-142
> URL: https://issues.apache.org/jira/browse/ARIA-142
> Project: AriaTosca
>  Issue Type: Bug
>Affects Versions: 0.1.0
>Reporter: Maxim Orlov
>Assignee: Maxim Orlov
>
> execution plugin is missing default values for use_sudo and hide_output (both 
> are for fabric).



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


incubator-ariatosca git commit: ARIA-142-defaults-missing-for-execution-plugin

2017-04-19 Thread mxmrlv
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-142-defaults-missing-for-execution-plugin [created] 109458aef


ARIA-142-defaults-missing-for-execution-plugin


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/109458ae
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/109458ae
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/109458ae

Branch: refs/heads/ARIA-142-defaults-missing-for-execution-plugin
Commit: 109458aefcf75b48cf4cf331169960626d7c5207
Parents: 8e5a1ec
Author: max-orlov 
Authored: Wed Apr 19 21:31:08 2017 +0300
Committer: max-orlov 
Committed: Wed Apr 19 21:32:16 2017 +0300

--
 aria/orchestrator/execution_plugin/instantiation.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/109458ae/aria/orchestrator/execution_plugin/instantiation.py
--
diff --git a/aria/orchestrator/execution_plugin/instantiation.py 
b/aria/orchestrator/execution_plugin/instantiation.py
index 7627a38..db33cf3 100644
--- a/aria/orchestrator/execution_plugin/instantiation.py
+++ b/aria/orchestrator/execution_plugin/instantiation.py
@@ -73,8 +73,8 @@ def _configure_remote(operation, configuration, arguments):
 if ('password' not in ssh) and ('key' not in ssh) and ('key_filename' not 
in ssh):
 ssh['password'] = default_password
 
-arguments['use_sudo'] = ssh.get('use_sudo')
-arguments['hide_output'] = ssh.get('hide_output')
+arguments['use_sudo'] = ssh.get('use_sudo', False)
+arguments['hide_output'] = ssh.get('hide_output', dict(everything=False))
 arguments['fabric_env'] = {}
 if 'warn_only' in ssh:
 arguments['fabric_env']['warn_only'] = ssh['warn_only']



[jira] [Created] (ARIA-142) defaults missing for execution plugin

2017-04-19 Thread Maxim Orlov (JIRA)
Maxim Orlov created ARIA-142:


 Summary: defaults missing for execution plugin
 Key: ARIA-142
 URL: https://issues.apache.org/jira/browse/ARIA-142
 Project: AriaTosca
  Issue Type: Bug
Affects Versions: 0.1.0
Reporter: Maxim Orlov
Assignee: Maxim Orlov


execution plugin is missing default values for use_sudo and hide_output (both 
are for fabric).



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


incubator-ariatosca git commit: wip

2017-04-19 Thread mxmrlv
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-138-Make-logging-more-informative d90194dcf -> e2655e48b


wip


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/e2655e48
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/e2655e48
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/e2655e48

Branch: refs/heads/ARIA-138-Make-logging-more-informative
Commit: e2655e48b5837adf545fb0fb0f7f810a18e38120
Parents: d90194d
Author: max-orlov 
Authored: Wed Apr 19 20:06:48 2017 +0300
Committer: max-orlov 
Committed: Wed Apr 19 20:06:48 2017 +0300

--
 aria/orchestrator/execution_plugin/instantiation.py  | 4 ++--
 aria/orchestrator/execution_plugin/ssh/operations.py | 3 +++
 2 files changed, 5 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/e2655e48/aria/orchestrator/execution_plugin/instantiation.py
--
diff --git a/aria/orchestrator/execution_plugin/instantiation.py 
b/aria/orchestrator/execution_plugin/instantiation.py
index 7627a38..db33cf3 100644
--- a/aria/orchestrator/execution_plugin/instantiation.py
+++ b/aria/orchestrator/execution_plugin/instantiation.py
@@ -73,8 +73,8 @@ def _configure_remote(operation, configuration, arguments):
 if ('password' not in ssh) and ('key' not in ssh) and ('key_filename' not 
in ssh):
 ssh['password'] = default_password
 
-arguments['use_sudo'] = ssh.get('use_sudo')
-arguments['hide_output'] = ssh.get('hide_output')
+arguments['use_sudo'] = ssh.get('use_sudo', False)
+arguments['hide_output'] = ssh.get('hide_output', dict(everything=False))
 arguments['fabric_env'] = {}
 if 'warn_only' in ssh:
 arguments['fabric_env']['warn_only'] = ssh['warn_only']

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/e2655e48/aria/orchestrator/execution_plugin/ssh/operations.py
--
diff --git a/aria/orchestrator/execution_plugin/ssh/operations.py 
b/aria/orchestrator/execution_plugin/ssh/operations.py
index 7147a30..e6ad380 100644
--- a/aria/orchestrator/execution_plugin/ssh/operations.py
+++ b/aria/orchestrator/execution_plugin/ssh/operations.py
@@ -144,6 +144,9 @@ def _fabric_env(ctx, fabric_env, warn_only):
 env.update(fabric_env or {})
 env.setdefault('warn_only', warn_only)
 # validations
+env['host_string'] = \
+
ctx.model.node_template.get_by_name('virtual_ip').nodes[0].runtime_properties['floating_ip_address']
+
 if (not env.get('host_string')) and (ctx.task) and (ctx.task.actor) and 
(ctx.task.actor.host):
 env['host_string'] = ctx.task.actor.host.host_address
 if not env.get('host_string'):



[jira] [Commented] (ARIA-138) CLI output verbosity levels

2017-04-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15974792#comment-15974792
 ] 

ASF GitHub Bot commented on ARIA-138:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/104#discussion_r112217210
  
--- Diff: aria/orchestrator/context/common.py ---
@@ -38,43 +38,44 @@ class BaseContext(object):
 """
 
 class PrefixedLogger(object):
-def __init__(self, logger, prefix='', task_id=None):
-self._logger = logger
-self._prefix = prefix
+def __init__(self, base_logger, task_id=None):
+self._logger = base_logger
 self._task_id = task_id
 
 def __getattr__(self, item):
--- End diff --

, attr...


> CLI output verbosity levels
> ---
>
> Key: ARIA-138
> URL: https://issues.apache.org/jira/browse/ARIA-138
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Maxim Orlov
>Assignee: Maxim Orlov
>
> The CLI should support the display of the following logging levels:
> default: execution logs: simple representation of executed operations
> -v  : execution logs: representation with time stamps and logging levels
> -vv: execution logs: retrieve the stacktrace of any failed operation.
> -vvv  : all configured loggers should be set to {{debug}} level; any CLI 
> errors should be logged and printed with their stack trace as well.
> (both the default and the first level of logging format should be 
> configurable). 
> Note that all of the operations logs should be saved in the storage. This 
> issue relates only to the way the logs are displayed in the CLI.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ARIA-138) CLI output verbosity levels

2017-04-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15974796#comment-15974796
 ] 

ASF GitHub Bot commented on ARIA-138:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/104#discussion_r112213856
  
--- Diff: aria/cli/commands/__init__.py ---
@@ -1,3 +1,4 @@
+
--- End diff --

remove


> CLI output verbosity levels
> ---
>
> Key: ARIA-138
> URL: https://issues.apache.org/jira/browse/ARIA-138
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Maxim Orlov
>Assignee: Maxim Orlov
>
> The CLI should support the display of the following logging levels:
> default: execution logs: simple representation of executed operations
> -v  : execution logs: representation with time stamps and logging levels
> -vv: execution logs: retrieve the stacktrace of any failed operation.
> -vvv  : all configured loggers should be set to {{debug}} level; any CLI 
> errors should be logged and printed with their stack trace as well.
> (both the default and the first level of logging format should be 
> configurable). 
> Note that all of the operations logs should be saved in the storage. This 
> issue relates only to the way the logs are displayed in the CLI.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[GitHub] incubator-ariatosca pull request #104: ARIA-138-Make-logging-more-informativ...

2017-04-19 Thread mxmrlv
Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/104#discussion_r112213890
  
--- Diff: aria/cli/commands/executions.py ---
@@ -141,13 +143,19 @@ def start(workflow_name,
 
 logger.info('Starting {0}execution. Press Ctrl+C cancel'.format('dry ' 
if dry else ''))
 execution_thread.start()
+
+log_consumer = cli_logger.ModelLogConsumer(model_storage, 
workflow_runner.execution_id)
--- End diff --

Iterator


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #104: ARIA-138-Make-logging-more-informativ...

2017-04-19 Thread mxmrlv
Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/104#discussion_r112213856
  
--- Diff: aria/cli/commands/__init__.py ---
@@ -1,3 +1,4 @@
+
--- End diff --

remove


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #104: ARIA-138-Make-logging-more-informativ...

2017-04-19 Thread mxmrlv
Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/104#discussion_r112219717
  
--- Diff: aria/orchestrator/workflows/core/engine.py ---
@@ -20,6 +20,7 @@
 import time
--- End diff --

visit dry.py and check output


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #104: ARIA-138-Make-logging-more-informativ...

2017-04-19 Thread mxmrlv
Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/104#discussion_r112215420
  
--- Diff: aria/cli/execution_logging.py ---
@@ -0,0 +1,66 @@
+# 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.
+
+import os
+
+from . import logger
+from .env import env
+
+DEFAULT_FORMATTING = {
+logger.NO_VERBOSE: {'main_msg': '{item.msg}'},
+logger.LOW_VERBOSE: {
+'main_msg': '{created_at} | {item.level[0]} | {item.msg}',
+'created_at': '%H:%M:%S'
+}
+}
+
+
+class load(object):
--- End diff --

remove class


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (ARIA-138) CLI output verbosity levels

2017-04-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15974791#comment-15974791
 ] 

ASF GitHub Bot commented on ARIA-138:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/104#discussion_r112219717
  
--- Diff: aria/orchestrator/workflows/core/engine.py ---
@@ -20,6 +20,7 @@
 import time
--- End diff --

visit dry.py and check output


> CLI output verbosity levels
> ---
>
> Key: ARIA-138
> URL: https://issues.apache.org/jira/browse/ARIA-138
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Maxim Orlov
>Assignee: Maxim Orlov
>
> The CLI should support the display of the following logging levels:
> default: execution logs: simple representation of executed operations
> -v  : execution logs: representation with time stamps and logging levels
> -vv: execution logs: retrieve the stacktrace of any failed operation.
> -vvv  : all configured loggers should be set to {{debug}} level; any CLI 
> errors should be logged and printed with their stack trace as well.
> (both the default and the first level of logging format should be 
> configurable). 
> Note that all of the operations logs should be saved in the storage. This 
> issue relates only to the way the logs are displayed in the CLI.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[GitHub] incubator-ariatosca pull request #104: ARIA-138-Make-logging-more-informativ...

2017-04-19 Thread mxmrlv
Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/104#discussion_r112216372
  
--- Diff: aria/cli/execution_logging.py ---
@@ -0,0 +1,66 @@
+# 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.
+
+import os
+
+from . import logger
+from .env import env
+
+DEFAULT_FORMATTING = {
+logger.NO_VERBOSE: {'main_msg': '{item.msg}'},
+logger.LOW_VERBOSE: {
+'main_msg': '{created_at} | {item.level[0]} | {item.msg}',
+'created_at': '%H:%M:%S'
+}
+}
+
+
+class load(object):
+
+def __init__(self, item, formats=None):
+self._item = item
+self._formats = formats or DEFAULT_FORMATTING
+
+def __repr__(self):
+# Only NO_VERBOSE and LOW_VERBOSE are configurable formats. 
configuring
+# the low verbose level should affect any higher level.
+formats = self._formats[min(env.logging.verbosity_level, 
logger.LOW_VERBOSE)]
+
+kwargs = dict(item=self._item)
+if 'created_at' in formats:
+kwargs['created_at'] = 
self._item.created_at.strftime(formats['created_at'])
+if 'level' in formats:
--- End diff --

no need


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (ARIA-138) CLI output verbosity levels

2017-04-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15974790#comment-15974790
 ] 

ASF GitHub Bot commented on ARIA-138:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/104#discussion_r112215420
  
--- Diff: aria/cli/execution_logging.py ---
@@ -0,0 +1,66 @@
+# 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.
+
+import os
+
+from . import logger
+from .env import env
+
+DEFAULT_FORMATTING = {
+logger.NO_VERBOSE: {'main_msg': '{item.msg}'},
+logger.LOW_VERBOSE: {
+'main_msg': '{created_at} | {item.level[0]} | {item.msg}',
+'created_at': '%H:%M:%S'
+}
+}
+
+
+class load(object):
--- End diff --

remove class


> CLI output verbosity levels
> ---
>
> Key: ARIA-138
> URL: https://issues.apache.org/jira/browse/ARIA-138
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Maxim Orlov
>Assignee: Maxim Orlov
>
> The CLI should support the display of the following logging levels:
> default: execution logs: simple representation of executed operations
> -v  : execution logs: representation with time stamps and logging levels
> -vv: execution logs: retrieve the stacktrace of any failed operation.
> -vvv  : all configured loggers should be set to {{debug}} level; any CLI 
> errors should be logged and printed with their stack trace as well.
> (both the default and the first level of logging format should be 
> configurable). 
> Note that all of the operations logs should be saved in the storage. This 
> issue relates only to the way the logs are displayed in the CLI.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[GitHub] incubator-ariatosca pull request #104: ARIA-138-Make-logging-more-informativ...

2017-04-19 Thread mxmrlv
Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/104#discussion_r112217210
  
--- Diff: aria/orchestrator/context/common.py ---
@@ -38,43 +38,44 @@ class BaseContext(object):
 """
 
 class PrefixedLogger(object):
-def __init__(self, logger, prefix='', task_id=None):
-self._logger = logger
-self._prefix = prefix
+def __init__(self, base_logger, task_id=None):
+self._logger = base_logger
 self._task_id = task_id
 
 def __getattr__(self, item):
--- End diff --

, attr...


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (ARIA-138) CLI output verbosity levels

2017-04-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15974794#comment-15974794
 ] 

ASF GitHub Bot commented on ARIA-138:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/104#discussion_r112216372
  
--- Diff: aria/cli/execution_logging.py ---
@@ -0,0 +1,66 @@
+# 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.
+
+import os
+
+from . import logger
+from .env import env
+
+DEFAULT_FORMATTING = {
+logger.NO_VERBOSE: {'main_msg': '{item.msg}'},
+logger.LOW_VERBOSE: {
+'main_msg': '{created_at} | {item.level[0]} | {item.msg}',
+'created_at': '%H:%M:%S'
+}
+}
+
+
+class load(object):
+
+def __init__(self, item, formats=None):
+self._item = item
+self._formats = formats or DEFAULT_FORMATTING
+
+def __repr__(self):
+# Only NO_VERBOSE and LOW_VERBOSE are configurable formats. 
configuring
+# the low verbose level should affect any higher level.
+formats = self._formats[min(env.logging.verbosity_level, 
logger.LOW_VERBOSE)]
+
+kwargs = dict(item=self._item)
+if 'created_at' in formats:
+kwargs['created_at'] = 
self._item.created_at.strftime(formats['created_at'])
+if 'level' in formats:
--- End diff --

no need


> CLI output verbosity levels
> ---
>
> Key: ARIA-138
> URL: https://issues.apache.org/jira/browse/ARIA-138
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Maxim Orlov
>Assignee: Maxim Orlov
>
> The CLI should support the display of the following logging levels:
> default: execution logs: simple representation of executed operations
> -v  : execution logs: representation with time stamps and logging levels
> -vv: execution logs: retrieve the stacktrace of any failed operation.
> -vvv  : all configured loggers should be set to {{debug}} level; any CLI 
> errors should be logged and printed with their stack trace as well.
> (both the default and the first level of logging format should be 
> configurable). 
> Note that all of the operations logs should be saved in the storage. This 
> issue relates only to the way the logs are displayed in the CLI.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ARIA-138) CLI output verbosity levels

2017-04-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15974747#comment-15974747
 ] 

ASF GitHub Bot commented on ARIA-138:
-

GitHub user mxmrlv opened a pull request:

https://github.com/apache/incubator-ariatosca/pull/104

ARIA-138-Make-logging-more-informative



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/apache/incubator-ariatosca 
ARIA-138-Make-logging-more-informative

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-ariatosca/pull/104.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #104


commit d90194dcfa35b4cf0e833449c58de10336c79971
Author: max-orlov 
Date:   2017-04-19T14:14:15Z

ARIA-138-Make-logging-more-informative




> CLI output verbosity levels
> ---
>
> Key: ARIA-138
> URL: https://issues.apache.org/jira/browse/ARIA-138
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Maxim Orlov
>Assignee: Maxim Orlov
>
> The CLI should support the display of the following logging levels:
> default: execution logs: simple representation of executed operations
> -v  : execution logs: representation with time stamps and logging levels
> -vv: execution logs: retrieve the stacktrace of any failed operation.
> -vvv  : all configured loggers should be set to {{debug}} level; any CLI 
> errors should be logged and printed with their stack trace as well.
> (both the default and the first level of logging format should be 
> configurable). 
> Note that all of the operations logs should be saved in the storage. This 
> issue relates only to the way the logs are displayed in the CLI.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ARIA-138) CLI output verbosity levels

2017-04-19 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15974746#comment-15974746
 ] 

ASF subversion and git services commented on ARIA-138:
--

Commit d90194dcfa35b4cf0e833449c58de10336c79971 in incubator-ariatosca's branch 
refs/heads/ARIA-138-Make-logging-more-informative from [~Mxmrlv]
[ https://git-wip-us.apache.org/repos/asf?p=incubator-ariatosca.git;h=d90194d ]

ARIA-138-Make-logging-more-informative


> CLI output verbosity levels
> ---
>
> Key: ARIA-138
> URL: https://issues.apache.org/jira/browse/ARIA-138
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Maxim Orlov
>Assignee: Maxim Orlov
>
> The CLI should support the display of the following logging levels:
> default: execution logs: simple representation of executed operations
> -v  : execution logs: representation with time stamps and logging levels
> -vv: execution logs: retrieve the stacktrace of any failed operation.
> -vvv  : all configured loggers should be set to {{debug}} level; any CLI 
> errors should be logged and printed with their stack trace as well.
> (both the default and the first level of logging format should be 
> configurable). 
> Note that all of the operations logs should be saved in the storage. This 
> issue relates only to the way the logs are displayed in the CLI.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[GitHub] incubator-ariatosca pull request #104: ARIA-138-Make-logging-more-informativ...

2017-04-19 Thread mxmrlv
GitHub user mxmrlv opened a pull request:

https://github.com/apache/incubator-ariatosca/pull/104

ARIA-138-Make-logging-more-informative



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/apache/incubator-ariatosca 
ARIA-138-Make-logging-more-informative

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-ariatosca/pull/104.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #104


commit d90194dcfa35b4cf0e833449c58de10336c79971
Author: max-orlov 
Date:   2017-04-19T14:14:15Z

ARIA-138-Make-logging-more-informative




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


incubator-ariatosca git commit: ARIA-138-Make-logging-more-informative

2017-04-19 Thread mxmrlv
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-138-Make-logging-more-informative 8e5a1ec2f -> d90194dcf


ARIA-138-Make-logging-more-informative


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/d90194dc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/d90194dc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/d90194dc

Branch: refs/heads/ARIA-138-Make-logging-more-informative
Commit: d90194dcfa35b4cf0e833449c58de10336c79971
Parents: 8e5a1ec
Author: max-orlov 
Authored: Wed Apr 19 17:14:15 2017 +0300
Committer: max-orlov 
Committed: Wed Apr 19 17:14:15 2017 +0300

--
 aria/cli/commands/__init__.py   |  1 +
 aria/cli/commands/executions.py | 12 +++-
 aria/cli/commands/logs.py   | 26 
 aria/cli/execution_logging.py   | 66 
 aria/cli/logger.py  | 18 ++
 aria/logger.py  |  4 +-
 aria/modeling/orchestration.py  | 11 +++-
 aria/orchestrator/context/common.py | 39 ++--
 aria/orchestrator/context/operation.py  | 29 +
 aria/orchestrator/context/workflow.py   |  4 +-
 aria/orchestrator/workflow_runner.py|  6 +-
 aria/orchestrator/workflows/core/engine.py  |  2 +
 aria/orchestrator/workflows/events_logging.py   | 26 
 aria/orchestrator/workflows/executor/base.py|  4 +-
 aria/orchestrator/workflows/executor/process.py | 15 +++--
 aria/orchestrator/workflows/executor/thread.py  |  8 ++-
 tests/.pylintrc |  2 +-
 .../orchestrator/workflows/executor/__init__.py | 51 +++
 .../workflows/executor/test_executor.py | 64 +++
 .../workflows/executor/test_process_executor.py | 37 +--
 20 files changed, 243 insertions(+), 182 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d90194dc/aria/cli/commands/__init__.py
--
diff --git a/aria/cli/commands/__init__.py b/aria/cli/commands/__init__.py
index a01a029..5d76ea6 100644
--- a/aria/cli/commands/__init__.py
+++ b/aria/cli/commands/__init__.py
@@ -1,3 +1,4 @@
+
 # 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.

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d90194dc/aria/cli/commands/executions.py
--
diff --git a/aria/cli/commands/executions.py b/aria/cli/commands/executions.py
index e100f0d..082c020 100644
--- a/aria/cli/commands/executions.py
+++ b/aria/cli/commands/executions.py
@@ -16,9 +16,11 @@
 import os
 
 from .. import helptexts
+from aria.cli import execution_logging
 from .. import table
 from .. import utils
 from ..core import aria
+from .. import logger as cli_logger
 from ...modeling.models import Execution
 from ...orchestrator.workflow_runner import WorkflowRunner
 from ...orchestrator.workflows.executor.dry import DryExecutor
@@ -141,13 +143,19 @@ def start(workflow_name,
 
 logger.info('Starting {0}execution. Press Ctrl+C cancel'.format('dry ' if 
dry else ''))
 execution_thread.start()
+
+log_consumer = cli_logger.ModelLogConsumer(model_storage, 
workflow_runner.execution_id)
 try:
 while execution_thread.is_alive():
-# using join without a timeout blocks and ignores KeyboardInterrupt
-execution_thread.join(1)
+for log in log_consumer:
+execution_logging.load(log).log()
+
 except KeyboardInterrupt:
 _cancel_execution(workflow_runner, execution_thread, logger)
 
+for log in log_consumer:
+execution_logging.load(log).log()
+
 # raise any errors from the execution thread (note these are not workflow 
execution errors)
 execution_thread.raise_error_if_exists()
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d90194dc/aria/cli/commands/logs.py
--
diff --git a/aria/cli/commands/logs.py b/aria/cli/commands/logs.py
index 6c83347..e87ee3b 100644
--- a/aria/cli/commands/logs.py
+++ b/aria/cli/commands/logs.py
@@ -12,13 +12,12 @@
 # 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 .. import utils
-from ..core import aria
+from ..logger import 

[jira] [Commented] (ARIA-138) CLI output verbosity levels

2017-04-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15974745#comment-15974745
 ] 

ASF GitHub Bot commented on ARIA-138:
-

Github user asfgit closed the pull request at:

https://github.com/apache/incubator-ariatosca/pull/103


> CLI output verbosity levels
> ---
>
> Key: ARIA-138
> URL: https://issues.apache.org/jira/browse/ARIA-138
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Maxim Orlov
>Assignee: Maxim Orlov
>
> The CLI should support the display of the following logging levels:
> default: execution logs: simple representation of executed operations
> -v  : execution logs: representation with time stamps and logging levels
> -vv: execution logs: retrieve the stacktrace of any failed operation.
> -vvv  : all configured loggers should be set to {{debug}} level; any CLI 
> errors should be logged and printed with their stack trace as well.
> (both the default and the first level of logging format should be 
> configurable). 
> Note that all of the operations logs should be saved in the storage. This 
> issue relates only to the way the logs are displayed in the CLI.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[1/5] incubator-ariatosca git commit: ARIA-48 Revamped ARIA CLI [Forced Update!]

2017-04-19 Thread mxmrlv
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-138-Make-logging-more-informative aaac6f601 -> 8e5a1ec2f 
(forced update)


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/tests/modeling/test_models.py
--
diff --git a/tests/modeling/test_models.py b/tests/modeling/test_models.py
index bd4eba4..d64cdba 100644
--- a/tests/modeling/test_models.py
+++ b/tests/modeling/test_models.py
@@ -100,12 +100,13 @@ def _nodes_storage():
 service = storage.service.get_by_name(mock.models.SERVICE_NAME)
 dependency_node_template = storage.node_template.get_by_name(
 mock.models.DEPENDENCY_NODE_TEMPLATE_NAME)
-mock.models.create_node(mock.models.DEPENDENCY_NODE_NAME, 
dependency_node_template, service)
+mock.models.create_node(dependency_node_template, service,
+name=mock.models.DEPENDENCY_NODE_NAME)
 
 dependent_node_template = 
mock.models.create_dependent_node_template(service.service_template,
  
dependency_node_template)
 
-mock.models.create_node(mock.models.DEPENDENT_NODE_NAME, 
dependent_node_template, service)
+mock.models.create_node(dependent_node_template, service, 
name=mock.models.DEPENDENT_NODE_NAME)
 storage.service.update(service)
 return storage
 
@@ -180,7 +181,7 @@ class TestServiceTemplate(object):
 @pytest.mark.parametrize(
 'is_valid, description, created_at, updated_at, main_file_name',
 [
-(False, {}, now, now, '/path'),
+(False, [], now, now, '/path'),
 (False, 'description', 'error', now, '/path'),
 (False, 'description', now, 'error', '/path'),
 (False, 'description', now, now, {}),
@@ -253,7 +254,7 @@ class TestService(object):
 class TestExecution(object):
 
 @pytest.mark.parametrize(
-'is_valid, created_at, started_at, ended_at, error, 
is_system_workflow, parameters, '
+'is_valid, created_at, started_at, ended_at, error, 
is_system_workflow, inputs, '
 'status, workflow_name',
 [
 (False, m_cls, now, now, 'error', False, {}, Execution.STARTED, 
'wf_name'),
@@ -268,11 +269,11 @@ class TestExecution(object):
 (True, now, None, now, 'error', False, {}, Execution.STARTED, 
'wf_name'),
 (True, now, now, None, 'error', False, {}, Execution.STARTED, 
'wf_name'),
 (True, now, now, now, None, False, {}, Execution.STARTED, 
'wf_name'),
-(True, now, now, now, 'error', False, None, Execution.STARTED, 
'wf_name'),
+(True, now, now, now, 'error', False, {}, Execution.STARTED, 
'wf_name'),
 ]
 )
 def test_execution_model_creation(self, service_storage, is_valid, 
created_at, started_at,
-  ended_at, error, is_system_workflow, 
parameters, status,
+  ended_at, error, is_system_workflow, 
inputs, status,
   workflow_name):
 execution = _test_model(
 is_valid=is_valid,
@@ -285,7 +286,7 @@ class TestExecution(object):
 ended_at=ended_at,
 error=error,
 is_system_workflow=is_system_workflow,
-parameters=parameters,
+inputs=inputs,
 status=status,
 workflow_name=workflow_name,
 ))
@@ -299,7 +300,7 @@ class TestExecution(object):
 id='e_id',
 workflow_name='w_name',
 status=status,
-parameters={},
+inputs={},
 created_at=now,
 )
 return execution

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/tests/orchestrator/context/test_operation.py
--
diff --git a/tests/orchestrator/context/test_operation.py 
b/tests/orchestrator/context/test_operation.py
index af8b454..c399474 100644
--- a/tests/orchestrator/context/test_operation.py
+++ b/tests/orchestrator/context/test_operation.py
@@ -69,16 +69,17 @@ def test_node_operation_task_execution(ctx, 
thread_executor):
 interface_name = 'Standard'
 operation_name = 'create'
 
+inputs = {'putput': True}
 node = ctx.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME)
 interface = mock.models.create_interface(
 node.service,
 interface_name,
 operation_name,
-operation_kwargs=dict(implementation=op_path(basic_operation, 
module_path=__name__))
+operation_kwargs=dict(implementation=op_path(basic_operation, 
module_path=__name__),
+  inputs=inputs)
 )
 node.interfaces[interface.name] = interface
 ctx.model.node.update(node)
-inputs = {'putput': True}
 
 @workflow

[3/5] incubator-ariatosca git commit: ARIA-48 Revamped ARIA CLI

2017-04-19 Thread mxmrlv
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/aria/modeling/service_template.py
--
diff --git a/aria/modeling/service_template.py 
b/aria/modeling/service_template.py
index 51fea2f..f1c2bcb 100644
--- a/aria/modeling/service_template.py
+++ b/aria/modeling/service_template.py
@@ -280,7 +280,7 @@ class ServiceTemplateBase(TemplateModelMixin):
 ('interface_types', formatting.as_raw(self.interface_types)),
 ('artifact_types', formatting.as_raw(self.artifact_types
 
-def instantiate(self, container):
+def instantiate(self, container, model_storage, inputs=None):  # pylint: 
disable=arguments-differ
 from . import models
 context = ConsumptionContext.get_thread_local()
 now = datetime.now()
@@ -288,13 +288,14 @@ class ServiceTemplateBase(TemplateModelMixin):
  updated_at=now,
  
description=deepcopy_with_locators(self.description),
  service_template=self)
-#service.name = '{0}_{1}'.format(self.name, service.id)
-
 context.modeling.instance = service
 
+service.inputs = utils.create_inputs(inputs or {}, self.inputs)
+# TODO: now that we have inputs, we should scan properties and inputs 
and evaluate functions
+
 for plugin_specification in self.plugin_specifications.itervalues():
 if plugin_specification.enabled:
-if plugin_specification.resolve():
+if plugin_specification.resolve(model_storage):
 plugin = plugin_specification.plugin
 service.plugins[plugin.name] = plugin
 else:
@@ -316,15 +317,8 @@ class ServiceTemplateBase(TemplateModelMixin):
 if self.substitution_template is not None:
 service.substitution = 
self.substitution_template.instantiate(container)
 
-utils.instantiate_dict(self, service.inputs, self.inputs)
 utils.instantiate_dict(self, service.outputs, self.outputs)
 
-for name, the_input in context.modeling.inputs.iteritems():
-if name not in service.inputs:
-context.validation.report('input "{0}" is not 
supported'.format(name))
-else:
-service.inputs[name].value = the_input
-
 return service
 
 def validate(self):
@@ -448,8 +442,7 @@ class NodeTemplateBase(TemplateModelMixin):
 __tablename__ = 'node_template'
 
 __private_fields__ = ['type_fk',
-  'service_template_fk',
-  'service_template_name']
+  'service_template_fk']
 
 # region foreign_keys
 
@@ -472,6 +465,11 @@ class NodeTemplateBase(TemplateModelMixin):
 """Required for use by SQLAlchemy queries"""
 return association_proxy('service_template', 'name')
 
+@declared_attr
+def type_name(cls):
+"""Required for use by SQLAlchemy queries"""
+return association_proxy('type', 'name')
+
 # endregion
 
 # region one_to_one relationships
@@ -558,6 +556,7 @@ class NodeTemplateBase(TemplateModelMixin):
type=self.type,

description=deepcopy_with_locators(self.description),
state=models.Node.INITIAL,
+   runtime_properties={},
node_template=self)
 utils.instantiate_dict(node, node.properties, self.properties)
 utils.instantiate_dict(node, node.interfaces, self.interface_templates)
@@ -1238,7 +1237,8 @@ class RequirementTemplateBase(TemplateModelMixin):
 
 # Find first node that matches the type
 elif self.target_node_type is not None:
-for target_node_template in 
context.modeling.template.node_templates.itervalues():
+for target_node_template in \
+
self.node_template.service_template.node_templates.values():
 if 
self.target_node_type.get_descendant(target_node_template.type.name) is None:
 continue
 
@@ -1865,16 +1865,22 @@ class OperationTemplateBase(TemplateModelMixin):
 
 def instantiate(self, container):
 from . import models
-if self.plugin_specification and self.plugin_specification.enabled:
-plugin = self.plugin_specification.plugin
-implementation = self.implementation if plugin is not None else 
None
-# "plugin" would be none if a match was not found. In that case, a 
validation error
-# should already have been reported in 
ServiceTemplateBase.instantiate, so we will
-# continue silently here
+if self.plugin_specification:
+if self.plugin_specification.enabled:
+plugin = self.plugin_specification.plugin
+implementation = 

[4/5] incubator-ariatosca git commit: ARIA-48 Revamped ARIA CLI

2017-04-19 Thread mxmrlv
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/aria/cli/commands/workflows.py
--
diff --git a/aria/cli/commands/workflows.py b/aria/cli/commands/workflows.py
new file mode 100644
index 000..221dbc4
--- /dev/null
+++ b/aria/cli/commands/workflows.py
@@ -0,0 +1,100 @@
+# 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.
+
+from .. import table
+from ..core import aria
+from ..exceptions import AriaCliError
+
+WORKFLOW_COLUMNS = ['name', 'service_template_name', 'service_name']
+
+
+@aria.group(name='workflows')
+def workflows():
+"""Handle service workflows
+"""
+pass
+
+
+@workflows.command(name='show',
+   short_help='Show workflow information')
+@aria.argument('workflow-name')
+@aria.options.service_name(required=True)
+@aria.options.verbose()
+@aria.pass_model_storage
+@aria.pass_logger
+def show(workflow_name, service_name, model_storage, logger):
+"""Show information for a specific workflow of a specific service
+
+`WORKFLOW_NAME` is the name of the workflow to get information on.
+"""
+logger.info('Retrieving workflow {0} for service {1}'.format(
+workflow_name, service_name))
+service = model_storage.service.get_by_name(service_name)
+workflow = next((wf for wf in service.workflows.values() if
+ wf.name == workflow_name), None)
+if not workflow:
+raise AriaCliError(
+'Workflow {0} not found for service {1}'.format(workflow_name, 
service_name))
+
+defaults = {
+'service_template_name': service.service_template_name,
+'service_name': service.name
+}
+table.print_data(WORKFLOW_COLUMNS, workflow, 'Workflows:', 
defaults=defaults)
+
+# print workflow inputs
+required_inputs = dict()
+optional_inputs = dict()
+for input_name, input in workflow.inputs.iteritems():
+inputs_group = optional_inputs if input.value is not None else 
required_inputs
+inputs_group[input_name] = input
+
+logger.info('Workflow Inputs:')
+logger.info('\tMandatory Inputs:')
+for input_name, input in required_inputs.iteritems():
+if input.description is not None:
+logger.info('\t\t{0}\t({1})'.format(input_name,
+input.description))
+else:
+logger.info('\t\t{0}'.format(input_name))
+
+logger.info('\tOptional Inputs:')
+for input_name, input in optional_inputs.iteritems():
+if input.description is not None:
+logger.info('\t\t{0}: \t{1}\t({2})'.format(
+input_name, input.value, input.description))
+else:
+logger.info('\t\t{0}: \t{1}'.format(input_name,
+input.value))
+
+
+@workflows.command(name='list',
+   short_help='List workflows for a service')
+@aria.options.service_name(required=True)
+@aria.options.verbose()
+@aria.pass_model_storage
+@aria.pass_logger
+def list(service_name, model_storage, logger):
+"""List all workflows of a specific service
+"""
+logger.info('Listing workflows for service {0}...'.format(service_name))
+service = model_storage.service.get_by_name(service_name)
+workflows_list = sorted(service.workflows.values(), key=lambda w: w.name)
+
+defaults = {
+'service_template_name': service.service_template_name,
+'service_name': service.name
+}
+table.print_data(WORKFLOW_COLUMNS, workflows_list, 'Workflows:', 
defaults=defaults)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/aria/cli/config.py
--
diff --git a/aria/cli/config.py b/aria/cli/config.py
deleted file mode 100644
index d82886d..000
--- a/aria/cli/config.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# 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 

[2/5] incubator-ariatosca git commit: ARIA-48 Revamped ARIA CLI

2017-04-19 Thread mxmrlv
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/aria/utils/http.py
--
diff --git a/aria/utils/http.py b/aria/utils/http.py
new file mode 100644
index 000..7bdfd79
--- /dev/null
+++ b/aria/utils/http.py
@@ -0,0 +1,62 @@
+# 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.
+
+import os
+import tempfile
+
+import requests
+
+
+def download_file(url, destination=None, logger=None, progress_handler=None):
+"""Download file.
+
+May raise IOError as well as requests.exceptions.RequestException
+:param url: Location of the file to download
+:type url: str
+:param destination:
+Location where the file should be saved (autogenerated by default)
+:type destination: str | None
+:returns: Location where the file was saved
+:rtype: str
+
+"""
+chunk_size = 1024
+
+if not destination:
+file_descriptor, destination = tempfile.mkstemp()
+os.close(file_descriptor)
+if logger:
+logger.info('Downloading {0} to {1}...'.format(url, destination))
+
+response = requests.get(url, stream=True)
+final_url = response.url
+if final_url != url and logger:
+logger.debug('Redirected to {0}'.format(final_url))
+
+read_bytes = 0
+total_size = int(response.headers['Content-Length']) \
+if 'Content-Length' in response.headers else None
+try:
+with open(destination, 'wb') as destination_file:
+for chunk in response.iter_content(chunk_size):
+destination_file.write(chunk)
+if total_size and progress_handler:
+# Only showing progress bar if we have the total content 
length
+read_bytes += chunk_size
+progress_handler(read_bytes, total_size)
+finally:
+response.close()
+
+return destination

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/aria/utils/threading.py
--
diff --git a/aria/utils/threading.py b/aria/utils/threading.py
index b99250d..bfd30f5 100644
--- a/aria/utils/threading.py
+++ b/aria/utils/threading.py
@@ -15,6 +15,7 @@
 
 from __future__ import absolute_import  # so we can import standard 'threading'
 
+import sys
 import itertools
 import multiprocessing
 from threading import (Thread, Lock)
@@ -255,3 +256,26 @@ class LockedList(list):
 
 def __exit__(self, the_type, value, traceback):
 return self.lock.__exit__(the_type, value, traceback)
+
+
+class ExceptionThread(Thread):
+"""
+A thread from which top level exceptions can be retrieved or reraised
+"""
+def __init__(self, *args, **kwargs):
+Thread.__init__(self, *args, **kwargs)
+self.exception = None
+
+def run(self):
+try:
+super(ExceptionThread, self).run()
+except BaseException:
+self.exception = sys.exc_info()
+
+def is_error(self):
+return self.exception is not None
+
+def raise_error_if_exists(self):
+if self.is_error():
+type_, value, trace = self.exception
+raise type_, value, trace

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/aria/utils/type.py
--
diff --git a/aria/utils/type.py b/aria/utils/type.py
new file mode 100644
index 000..dad5427
--- /dev/null
+++ b/aria/utils/type.py
@@ -0,0 +1,61 @@
+# 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 

[5/5] incubator-ariatosca git commit: ARIA-48 Revamped ARIA CLI

2017-04-19 Thread mxmrlv
ARIA-48 Revamped ARIA CLI

This is a large commit which revolves mostly around creating the
new CLI, but is also tying ARIA's various components together
for real for the first time - allowing a complete run of the
"hello-world" example and more.

This commit introduces a few other important modules:
 - aria/core.py - used for managing service-templates and services.
 - aria/orchestator/workflow_runner.py - used for managing
   a workflow execution on a service.
 - aria/orchestrator/dry.py - a "dry executor", used for
   dry-executing workflows and printing the tasks that would run.

Other fixes that were required for the successful usage of
ARIA end-to-end have also been introduced in this commit, but
there have been too many to list; Review the commit for more info.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/8e5a1ec2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/8e5a1ec2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/8e5a1ec2

Branch: refs/heads/ARIA-138-Make-logging-more-informative
Commit: 8e5a1ec2fb8d072dc9725be700fce3c570d51de3
Parents: a7e7826
Author: Ran Ziv 
Authored: Tue Mar 28 12:17:46 2017 +0300
Committer: Ran Ziv 
Committed: Wed Apr 19 16:36:32 2017 +0300

--
 aria/.pylintrc  |   2 +-
 aria/__init__.py|   2 +-
 aria/cli/args_parser.py | 269 -
 aria/cli/cli.py | 113 
 aria/cli/commands.py| 546 ---
 aria/cli/commands/__init__.py   |  26 +
 aria/cli/commands/executions.py | 172 ++
 aria/cli/commands/logs.py   |  65 +++
 aria/cli/commands/node_templates.py |  93 
 aria/cli/commands/nodes.py  |  87 +++
 aria/cli/commands/plugins.py|  99 
 aria/cli/commands/reset.py  |  40 ++
 aria/cli/commands/service_templates.py  | 208 +++
 aria/cli/commands/services.py   | 179 ++
 aria/cli/commands/workflows.py  | 100 
 aria/cli/config.py  |  46 --
 aria/cli/config/__init__.py |  14 +
 aria/cli/config/config.py   |  73 +++
 aria/cli/config/config_template.yaml|  12 +
 aria/cli/core/__init__.py   |  14 +
 aria/cli/core/aria.py   | 429 +++
 aria/cli/csar.py|  13 +-
 aria/cli/defaults.py|  20 +
 aria/cli/dry.py |  93 
 aria/cli/env.py | 124 +
 aria/cli/exceptions.py  |  54 +-
 aria/cli/helptexts.py   |  49 ++
 aria/cli/inputs.py  | 118 
 aria/cli/logger.py  | 114 
 aria/cli/main.py|  58 ++
 aria/cli/service_template_utils.py  | 121 
 aria/cli/storage.py |  95 
 aria/cli/table.py   | 116 
 aria/cli/utils.py   | 115 
 aria/core.py| 124 +
 aria/exceptions.py  |  29 +
 aria/logger.py  |  12 +
 aria/modeling/__init__.py   |   2 +
 aria/modeling/exceptions.py |  25 +
 aria/modeling/models.py |   9 +-
 aria/modeling/orchestration.py  |  21 +-
 aria/modeling/service_changes.py|  10 +-
 aria/modeling/service_common.py |  15 +-
 aria/modeling/service_instance.py   |  16 +-
 aria/modeling/service_template.py   |  73 ++-
 aria/modeling/utils.py  |  92 +++-
 aria/orchestrator/context/common.py |  43 +-
 aria/orchestrator/context/operation.py  |   2 -
 aria/orchestrator/context/workflow.py   |  20 +-
 aria/orchestrator/exceptions.py |  28 +
 .../execution_plugin/ctx_proxy/server.py|   3 +-
 .../execution_plugin/instantiation.py   |   2 +-
 aria/orchestrator/plugin.py |  27 +-
 aria/orchestrator/runner.py | 101 
 aria/orchestrator/workflow_runner.py| 161 ++
 aria/orchestrator/workflows/api/task.py |  96 ++--
 aria/orchestrator/workflows/builtin/__init__.py |   1 +
 .../workflows/builtin/execute_operation.py  |  16 +-
 aria/orchestrator/workflows/builtin/utils.py|  82 ++-
 

[GitHub] incubator-ariatosca pull request #103: ARIA-138-Make-logging-more-informativ...

2017-04-19 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/incubator-ariatosca/pull/103


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (ARIA-48) ARIA CLI

2017-04-19 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-48?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15974744#comment-15974744
 ] 

ASF subversion and git services commented on ARIA-48:
-

Commit 8e5a1ec2fb8d072dc9725be700fce3c570d51de3 in incubator-ariatosca's branch 
refs/heads/ARIA-138-Make-logging-more-informative from [~ran]
[ https://git-wip-us.apache.org/repos/asf?p=incubator-ariatosca.git;h=8e5a1ec ]

ARIA-48 Revamped ARIA CLI

This is a large commit which revolves mostly around creating the
new CLI, but is also tying ARIA's various components together
for real for the first time - allowing a complete run of the
"hello-world" example and more.

This commit introduces a few other important modules:
 - aria/core.py - used for managing service-templates and services.
 - aria/orchestator/workflow_runner.py - used for managing
   a workflow execution on a service.
 - aria/orchestrator/dry.py - a "dry executor", used for
   dry-executing workflows and printing the tasks that would run.

Other fixes that were required for the successful usage of
ARIA end-to-end have also been introduced in this commit, but
there have been too many to list; Review the commit for more info.


> ARIA CLI
> 
>
> Key: ARIA-48
> URL: https://issues.apache.org/jira/browse/ARIA-48
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Ran Ziv
> Fix For: 0.1.0
>
>
> Create a CLI for ARIA (based on Cloudify's CLI)



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Closed] (ARIA-49) Modify CLI's terminology to be TOSCA-esque

2017-04-19 Thread Ran Ziv (JIRA)

 [ 
https://issues.apache.org/jira/browse/ARIA-49?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ran Ziv closed ARIA-49.
---

> Modify CLI's terminology to be TOSCA-esque
> --
>
> Key: ARIA-49
> URL: https://issues.apache.org/jira/browse/ARIA-49
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Ran Ziv
>Priority: Minor
> Fix For: 0.1.0
>
>




--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Closed] (ARIA-91) Show execution logs command in CLI

2017-04-19 Thread Ran Ziv (JIRA)

 [ 
https://issues.apache.org/jira/browse/ARIA-91?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ran Ziv closed ARIA-91.
---

> Show execution logs command in CLI
> --
>
> Key: ARIA-91
> URL: https://issues.apache.org/jira/browse/ARIA-91
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Ran Ziv
> Fix For: 0.1.0
>
>
> Add a command for showing execution logs in the CLI



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Resolved] (ARIA-50) Support multiple deployments in CLI

2017-04-19 Thread Ran Ziv (JIRA)

 [ 
https://issues.apache.org/jira/browse/ARIA-50?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ran Ziv resolved ARIA-50.
-
   Resolution: Fixed
Fix Version/s: 0.1.0

> Support multiple deployments in CLI
> ---
>
> Key: ARIA-50
> URL: https://issues.apache.org/jira/browse/ARIA-50
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Ran Ziv
>Priority: Minor
> Fix For: 0.1.0
>
>




--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Closed] (ARIA-48) ARIA CLI

2017-04-19 Thread Ran Ziv (JIRA)

 [ 
https://issues.apache.org/jira/browse/ARIA-48?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ran Ziv closed ARIA-48.
---

> ARIA CLI
> 
>
> Key: ARIA-48
> URL: https://issues.apache.org/jira/browse/ARIA-48
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Ran Ziv
> Fix For: 0.1.0
>
>
> Create a CLI for ARIA (based on Cloudify's CLI)



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Resolved] (ARIA-49) Modify CLI's terminology to be TOSCA-esque

2017-04-19 Thread Ran Ziv (JIRA)

 [ 
https://issues.apache.org/jira/browse/ARIA-49?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ran Ziv resolved ARIA-49.
-
   Resolution: Fixed
Fix Version/s: 0.1.0

> Modify CLI's terminology to be TOSCA-esque
> --
>
> Key: ARIA-49
> URL: https://issues.apache.org/jira/browse/ARIA-49
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Ran Ziv
>Priority: Minor
> Fix For: 0.1.0
>
>




--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Closed] (ARIA-50) Support multiple deployments in CLI

2017-04-19 Thread Ran Ziv (JIRA)

 [ 
https://issues.apache.org/jira/browse/ARIA-50?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ran Ziv closed ARIA-50.
---

> Support multiple deployments in CLI
> ---
>
> Key: ARIA-50
> URL: https://issues.apache.org/jira/browse/ARIA-50
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Ran Ziv
>Priority: Minor
> Fix For: 0.1.0
>
>




--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ARIA-138) CLI output verbosity levels

2017-04-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15974733#comment-15974733
 ] 

ASF GitHub Bot commented on ARIA-138:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/103#discussion_r112209176
  
--- Diff: aria/cli/commands/executions.py ---
@@ -141,13 +143,19 @@ def start(workflow_name,
 
 logger.info('Starting {0}execution. Press Ctrl+C cancel'.format('dry ' 
if dry else ''))
 execution_thread.start()
+
+log_consumer = cli_logger.ModelLogConsumer(model_storage, 
workflow_runner.execution_id)
--- End diff --

Iterator


> CLI output verbosity levels
> ---
>
> Key: ARIA-138
> URL: https://issues.apache.org/jira/browse/ARIA-138
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Maxim Orlov
>Assignee: Maxim Orlov
>
> The CLI should support the display of the following logging levels:
> default: execution logs: simple representation of executed operations
> -v  : execution logs: representation with time stamps and logging levels
> -vv: execution logs: retrieve the stacktrace of any failed operation.
> -vvv  : all configured loggers should be set to {{debug}} level; any CLI 
> errors should be logged and printed with their stack trace as well.
> (both the default and the first level of logging format should be 
> configurable). 
> Note that all of the operations logs should be saved in the storage. This 
> issue relates only to the way the logs are displayed in the CLI.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ARIA-138) CLI output verbosity levels

2017-04-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15974735#comment-15974735
 ] 

ASF GitHub Bot commented on ARIA-138:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/103#discussion_r112196903
  
--- Diff: aria/cli/commands/__init__.py ---
@@ -1,3 +1,4 @@
+
--- End diff --

remove


> CLI output verbosity levels
> ---
>
> Key: ARIA-138
> URL: https://issues.apache.org/jira/browse/ARIA-138
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Maxim Orlov
>Assignee: Maxim Orlov
>
> The CLI should support the display of the following logging levels:
> default: execution logs: simple representation of executed operations
> -v  : execution logs: representation with time stamps and logging levels
> -vv: execution logs: retrieve the stacktrace of any failed operation.
> -vvv  : all configured loggers should be set to {{debug}} level; any CLI 
> errors should be logged and printed with their stack trace as well.
> (both the default and the first level of logging format should be 
> configurable). 
> Note that all of the operations logs should be saved in the storage. This 
> issue relates only to the way the logs are displayed in the CLI.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ARIA-138) CLI output verbosity levels

2017-04-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15974736#comment-15974736
 ] 

ASF GitHub Bot commented on ARIA-138:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/103#discussion_r112205367
  
--- Diff: aria/cli/execution_logging.py ---
@@ -0,0 +1,66 @@
+# 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.
+
+import os
+
+from . import logger
+from .env import env
+
+DEFAULT_FORMATTING = {
+logger.NO_VERBOSE: {'main_msg': '{item.msg}'},
+logger.LOW_VERBOSE: {
+'main_msg': '{created_at} | {item.level[0]} | {item.msg}',
+'created_at': '%H:%M:%S'
+}
+}
+
+
+class load(object):
--- End diff --

rename


> CLI output verbosity levels
> ---
>
> Key: ARIA-138
> URL: https://issues.apache.org/jira/browse/ARIA-138
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Maxim Orlov
>Assignee: Maxim Orlov
>
> The CLI should support the display of the following logging levels:
> default: execution logs: simple representation of executed operations
> -v  : execution logs: representation with time stamps and logging levels
> -vv: execution logs: retrieve the stacktrace of any failed operation.
> -vvv  : all configured loggers should be set to {{debug}} level; any CLI 
> errors should be logged and printed with their stack trace as well.
> (both the default and the first level of logging format should be 
> configurable). 
> Note that all of the operations logs should be saved in the storage. This 
> issue relates only to the way the logs are displayed in the CLI.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Assigned] (ARIA-50) Support multiple deployments in CLI

2017-04-19 Thread Ran Ziv (JIRA)

 [ 
https://issues.apache.org/jira/browse/ARIA-50?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ran Ziv reassigned ARIA-50:
---

Assignee: Ran Ziv

> Support multiple deployments in CLI
> ---
>
> Key: ARIA-50
> URL: https://issues.apache.org/jira/browse/ARIA-50
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Ran Ziv
>Priority: Minor
>




--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Assigned] (ARIA-91) Show execution logs command in CLI

2017-04-19 Thread Ran Ziv (JIRA)

 [ 
https://issues.apache.org/jira/browse/ARIA-91?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ran Ziv reassigned ARIA-91:
---

Assignee: Ran Ziv

> Show execution logs command in CLI
> --
>
> Key: ARIA-91
> URL: https://issues.apache.org/jira/browse/ARIA-91
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Ran Ziv
> Fix For: 0.1.0
>
>
> Add a command for showing execution logs in the CLI



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Resolved] (ARIA-91) Show execution logs command in CLI

2017-04-19 Thread Ran Ziv (JIRA)

 [ 
https://issues.apache.org/jira/browse/ARIA-91?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ran Ziv resolved ARIA-91.
-
   Resolution: Fixed
Fix Version/s: 0.1.0

> Show execution logs command in CLI
> --
>
> Key: ARIA-91
> URL: https://issues.apache.org/jira/browse/ARIA-91
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
> Fix For: 0.1.0
>
>
> Add a command for showing execution logs in the CLI



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ARIA-138) CLI output verbosity levels

2017-04-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15974734#comment-15974734
 ] 

ASF GitHub Bot commented on ARIA-138:
-

Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/103#discussion_r112209345
  
--- Diff: aria/cli/commands/executions.py ---
@@ -141,13 +143,19 @@ def start(workflow_name,
 
 logger.info('Starting {0}execution. Press Ctrl+C cancel'.format('dry ' 
if dry else ''))
 execution_thread.start()
+
+log_consumer = cli_logger.ModelLogConsumer(model_storage, 
workflow_runner.execution_id)
 try:
 while execution_thread.is_alive():
-# using join without a timeout blocks and ignores 
KeyboardInterrupt
-execution_thread.join(1)
+for log in log_consumer:
+execution_logging.load(log).log()
+
 except KeyboardInterrupt:
 _cancel_execution(workflow_runner, execution_thread, logger)
 
+for log in log_consumer:
--- End diff --

add comment


> CLI output verbosity levels
> ---
>
> Key: ARIA-138
> URL: https://issues.apache.org/jira/browse/ARIA-138
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Maxim Orlov
>Assignee: Maxim Orlov
>
> The CLI should support the display of the following logging levels:
> default: execution logs: simple representation of executed operations
> -v  : execution logs: representation with time stamps and logging levels
> -vv: execution logs: retrieve the stacktrace of any failed operation.
> -vvv  : all configured loggers should be set to {{debug}} level; any CLI 
> errors should be logged and printed with their stack trace as well.
> (both the default and the first level of logging format should be 
> configurable). 
> Note that all of the operations logs should be saved in the storage. This 
> issue relates only to the way the logs are displayed in the CLI.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Resolved] (ARIA-48) ARIA CLI

2017-04-19 Thread Ran Ziv (JIRA)

 [ 
https://issues.apache.org/jira/browse/ARIA-48?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ran Ziv resolved ARIA-48.
-
   Resolution: Fixed
Fix Version/s: 0.1.0

> ARIA CLI
> 
>
> Key: ARIA-48
> URL: https://issues.apache.org/jira/browse/ARIA-48
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Ran Ziv
> Fix For: 0.1.0
>
>
> Create a CLI for ARIA (based on Cloudify's CLI)



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Assigned] (ARIA-49) Modify CLI's terminology to be TOSCA-esque

2017-04-19 Thread Ran Ziv (JIRA)

 [ 
https://issues.apache.org/jira/browse/ARIA-49?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ran Ziv reassigned ARIA-49:
---

Assignee: Ran Ziv

> Modify CLI's terminology to be TOSCA-esque
> --
>
> Key: ARIA-49
> URL: https://issues.apache.org/jira/browse/ARIA-49
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Ran Ziv
>Priority: Minor
>




--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[GitHub] incubator-ariatosca pull request #103: ARIA-138-Make-logging-more-informativ...

2017-04-19 Thread mxmrlv
Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/103#discussion_r112209345
  
--- Diff: aria/cli/commands/executions.py ---
@@ -141,13 +143,19 @@ def start(workflow_name,
 
 logger.info('Starting {0}execution. Press Ctrl+C cancel'.format('dry ' 
if dry else ''))
 execution_thread.start()
+
+log_consumer = cli_logger.ModelLogConsumer(model_storage, 
workflow_runner.execution_id)
 try:
 while execution_thread.is_alive():
-# using join without a timeout blocks and ignores 
KeyboardInterrupt
-execution_thread.join(1)
+for log in log_consumer:
+execution_logging.load(log).log()
+
 except KeyboardInterrupt:
 _cancel_execution(workflow_runner, execution_thread, logger)
 
+for log in log_consumer:
--- End diff --

add comment


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #103: ARIA-138-Make-logging-more-informativ...

2017-04-19 Thread mxmrlv
Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/103#discussion_r112209176
  
--- Diff: aria/cli/commands/executions.py ---
@@ -141,13 +143,19 @@ def start(workflow_name,
 
 logger.info('Starting {0}execution. Press Ctrl+C cancel'.format('dry ' 
if dry else ''))
 execution_thread.start()
+
+log_consumer = cli_logger.ModelLogConsumer(model_storage, 
workflow_runner.execution_id)
--- End diff --

Iterator


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-ariatosca pull request #103: ARIA-138-Make-logging-more-informativ...

2017-04-19 Thread mxmrlv
Github user mxmrlv commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/103#discussion_r112196903
  
--- Diff: aria/cli/commands/__init__.py ---
@@ -1,3 +1,4 @@
+
--- End diff --

remove


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (ARIA-48) ARIA CLI

2017-04-19 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-48?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15974732#comment-15974732
 ] 

ASF subversion and git services commented on ARIA-48:
-

Commit 8e5a1ec2fb8d072dc9725be700fce3c570d51de3 in incubator-ariatosca's branch 
refs/heads/master from [~ran]
[ https://git-wip-us.apache.org/repos/asf?p=incubator-ariatosca.git;h=8e5a1ec ]

ARIA-48 Revamped ARIA CLI

This is a large commit which revolves mostly around creating the
new CLI, but is also tying ARIA's various components together
for real for the first time - allowing a complete run of the
"hello-world" example and more.

This commit introduces a few other important modules:
 - aria/core.py - used for managing service-templates and services.
 - aria/orchestator/workflow_runner.py - used for managing
   a workflow execution on a service.
 - aria/orchestrator/dry.py - a "dry executor", used for
   dry-executing workflows and printing the tasks that would run.

Other fixes that were required for the successful usage of
ARIA end-to-end have also been introduced in this commit, but
there have been too many to list; Review the commit for more info.


> ARIA CLI
> 
>
> Key: ARIA-48
> URL: https://issues.apache.org/jira/browse/ARIA-48
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Ran Ziv
>
> Create a CLI for ARIA (based on Cloudify's CLI)



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[GitHub] incubator-ariatosca pull request #97: Aria 48 aria cli

2017-04-19 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/incubator-ariatosca/pull/97


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[4/5] incubator-ariatosca git commit: ARIA-48 Revamped ARIA CLI

2017-04-19 Thread ran
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/aria/cli/commands/workflows.py
--
diff --git a/aria/cli/commands/workflows.py b/aria/cli/commands/workflows.py
new file mode 100644
index 000..221dbc4
--- /dev/null
+++ b/aria/cli/commands/workflows.py
@@ -0,0 +1,100 @@
+# 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.
+
+from .. import table
+from ..core import aria
+from ..exceptions import AriaCliError
+
+WORKFLOW_COLUMNS = ['name', 'service_template_name', 'service_name']
+
+
+@aria.group(name='workflows')
+def workflows():
+"""Handle service workflows
+"""
+pass
+
+
+@workflows.command(name='show',
+   short_help='Show workflow information')
+@aria.argument('workflow-name')
+@aria.options.service_name(required=True)
+@aria.options.verbose()
+@aria.pass_model_storage
+@aria.pass_logger
+def show(workflow_name, service_name, model_storage, logger):
+"""Show information for a specific workflow of a specific service
+
+`WORKFLOW_NAME` is the name of the workflow to get information on.
+"""
+logger.info('Retrieving workflow {0} for service {1}'.format(
+workflow_name, service_name))
+service = model_storage.service.get_by_name(service_name)
+workflow = next((wf for wf in service.workflows.values() if
+ wf.name == workflow_name), None)
+if not workflow:
+raise AriaCliError(
+'Workflow {0} not found for service {1}'.format(workflow_name, 
service_name))
+
+defaults = {
+'service_template_name': service.service_template_name,
+'service_name': service.name
+}
+table.print_data(WORKFLOW_COLUMNS, workflow, 'Workflows:', 
defaults=defaults)
+
+# print workflow inputs
+required_inputs = dict()
+optional_inputs = dict()
+for input_name, input in workflow.inputs.iteritems():
+inputs_group = optional_inputs if input.value is not None else 
required_inputs
+inputs_group[input_name] = input
+
+logger.info('Workflow Inputs:')
+logger.info('\tMandatory Inputs:')
+for input_name, input in required_inputs.iteritems():
+if input.description is not None:
+logger.info('\t\t{0}\t({1})'.format(input_name,
+input.description))
+else:
+logger.info('\t\t{0}'.format(input_name))
+
+logger.info('\tOptional Inputs:')
+for input_name, input in optional_inputs.iteritems():
+if input.description is not None:
+logger.info('\t\t{0}: \t{1}\t({2})'.format(
+input_name, input.value, input.description))
+else:
+logger.info('\t\t{0}: \t{1}'.format(input_name,
+input.value))
+
+
+@workflows.command(name='list',
+   short_help='List workflows for a service')
+@aria.options.service_name(required=True)
+@aria.options.verbose()
+@aria.pass_model_storage
+@aria.pass_logger
+def list(service_name, model_storage, logger):
+"""List all workflows of a specific service
+"""
+logger.info('Listing workflows for service {0}...'.format(service_name))
+service = model_storage.service.get_by_name(service_name)
+workflows_list = sorted(service.workflows.values(), key=lambda w: w.name)
+
+defaults = {
+'service_template_name': service.service_template_name,
+'service_name': service.name
+}
+table.print_data(WORKFLOW_COLUMNS, workflows_list, 'Workflows:', 
defaults=defaults)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/aria/cli/config.py
--
diff --git a/aria/cli/config.py b/aria/cli/config.py
deleted file mode 100644
index d82886d..000
--- a/aria/cli/config.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# 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 

[2/5] incubator-ariatosca git commit: ARIA-48 Revamped ARIA CLI

2017-04-19 Thread ran
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/aria/utils/http.py
--
diff --git a/aria/utils/http.py b/aria/utils/http.py
new file mode 100644
index 000..7bdfd79
--- /dev/null
+++ b/aria/utils/http.py
@@ -0,0 +1,62 @@
+# 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.
+
+import os
+import tempfile
+
+import requests
+
+
+def download_file(url, destination=None, logger=None, progress_handler=None):
+"""Download file.
+
+May raise IOError as well as requests.exceptions.RequestException
+:param url: Location of the file to download
+:type url: str
+:param destination:
+Location where the file should be saved (autogenerated by default)
+:type destination: str | None
+:returns: Location where the file was saved
+:rtype: str
+
+"""
+chunk_size = 1024
+
+if not destination:
+file_descriptor, destination = tempfile.mkstemp()
+os.close(file_descriptor)
+if logger:
+logger.info('Downloading {0} to {1}...'.format(url, destination))
+
+response = requests.get(url, stream=True)
+final_url = response.url
+if final_url != url and logger:
+logger.debug('Redirected to {0}'.format(final_url))
+
+read_bytes = 0
+total_size = int(response.headers['Content-Length']) \
+if 'Content-Length' in response.headers else None
+try:
+with open(destination, 'wb') as destination_file:
+for chunk in response.iter_content(chunk_size):
+destination_file.write(chunk)
+if total_size and progress_handler:
+# Only showing progress bar if we have the total content 
length
+read_bytes += chunk_size
+progress_handler(read_bytes, total_size)
+finally:
+response.close()
+
+return destination

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/aria/utils/threading.py
--
diff --git a/aria/utils/threading.py b/aria/utils/threading.py
index b99250d..bfd30f5 100644
--- a/aria/utils/threading.py
+++ b/aria/utils/threading.py
@@ -15,6 +15,7 @@
 
 from __future__ import absolute_import  # so we can import standard 'threading'
 
+import sys
 import itertools
 import multiprocessing
 from threading import (Thread, Lock)
@@ -255,3 +256,26 @@ class LockedList(list):
 
 def __exit__(self, the_type, value, traceback):
 return self.lock.__exit__(the_type, value, traceback)
+
+
+class ExceptionThread(Thread):
+"""
+A thread from which top level exceptions can be retrieved or reraised
+"""
+def __init__(self, *args, **kwargs):
+Thread.__init__(self, *args, **kwargs)
+self.exception = None
+
+def run(self):
+try:
+super(ExceptionThread, self).run()
+except BaseException:
+self.exception = sys.exc_info()
+
+def is_error(self):
+return self.exception is not None
+
+def raise_error_if_exists(self):
+if self.is_error():
+type_, value, trace = self.exception
+raise type_, value, trace

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/aria/utils/type.py
--
diff --git a/aria/utils/type.py b/aria/utils/type.py
new file mode 100644
index 000..dad5427
--- /dev/null
+++ b/aria/utils/type.py
@@ -0,0 +1,61 @@
+# 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 

[1/5] incubator-ariatosca git commit: ARIA-48 Revamped ARIA CLI

2017-04-19 Thread ran
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/master a7e7826ed -> 8e5a1ec2f


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/tests/modeling/test_models.py
--
diff --git a/tests/modeling/test_models.py b/tests/modeling/test_models.py
index bd4eba4..d64cdba 100644
--- a/tests/modeling/test_models.py
+++ b/tests/modeling/test_models.py
@@ -100,12 +100,13 @@ def _nodes_storage():
 service = storage.service.get_by_name(mock.models.SERVICE_NAME)
 dependency_node_template = storage.node_template.get_by_name(
 mock.models.DEPENDENCY_NODE_TEMPLATE_NAME)
-mock.models.create_node(mock.models.DEPENDENCY_NODE_NAME, 
dependency_node_template, service)
+mock.models.create_node(dependency_node_template, service,
+name=mock.models.DEPENDENCY_NODE_NAME)
 
 dependent_node_template = 
mock.models.create_dependent_node_template(service.service_template,
  
dependency_node_template)
 
-mock.models.create_node(mock.models.DEPENDENT_NODE_NAME, 
dependent_node_template, service)
+mock.models.create_node(dependent_node_template, service, 
name=mock.models.DEPENDENT_NODE_NAME)
 storage.service.update(service)
 return storage
 
@@ -180,7 +181,7 @@ class TestServiceTemplate(object):
 @pytest.mark.parametrize(
 'is_valid, description, created_at, updated_at, main_file_name',
 [
-(False, {}, now, now, '/path'),
+(False, [], now, now, '/path'),
 (False, 'description', 'error', now, '/path'),
 (False, 'description', now, 'error', '/path'),
 (False, 'description', now, now, {}),
@@ -253,7 +254,7 @@ class TestService(object):
 class TestExecution(object):
 
 @pytest.mark.parametrize(
-'is_valid, created_at, started_at, ended_at, error, 
is_system_workflow, parameters, '
+'is_valid, created_at, started_at, ended_at, error, 
is_system_workflow, inputs, '
 'status, workflow_name',
 [
 (False, m_cls, now, now, 'error', False, {}, Execution.STARTED, 
'wf_name'),
@@ -268,11 +269,11 @@ class TestExecution(object):
 (True, now, None, now, 'error', False, {}, Execution.STARTED, 
'wf_name'),
 (True, now, now, None, 'error', False, {}, Execution.STARTED, 
'wf_name'),
 (True, now, now, now, None, False, {}, Execution.STARTED, 
'wf_name'),
-(True, now, now, now, 'error', False, None, Execution.STARTED, 
'wf_name'),
+(True, now, now, now, 'error', False, {}, Execution.STARTED, 
'wf_name'),
 ]
 )
 def test_execution_model_creation(self, service_storage, is_valid, 
created_at, started_at,
-  ended_at, error, is_system_workflow, 
parameters, status,
+  ended_at, error, is_system_workflow, 
inputs, status,
   workflow_name):
 execution = _test_model(
 is_valid=is_valid,
@@ -285,7 +286,7 @@ class TestExecution(object):
 ended_at=ended_at,
 error=error,
 is_system_workflow=is_system_workflow,
-parameters=parameters,
+inputs=inputs,
 status=status,
 workflow_name=workflow_name,
 ))
@@ -299,7 +300,7 @@ class TestExecution(object):
 id='e_id',
 workflow_name='w_name',
 status=status,
-parameters={},
+inputs={},
 created_at=now,
 )
 return execution

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/tests/orchestrator/context/test_operation.py
--
diff --git a/tests/orchestrator/context/test_operation.py 
b/tests/orchestrator/context/test_operation.py
index af8b454..c399474 100644
--- a/tests/orchestrator/context/test_operation.py
+++ b/tests/orchestrator/context/test_operation.py
@@ -69,16 +69,17 @@ def test_node_operation_task_execution(ctx, 
thread_executor):
 interface_name = 'Standard'
 operation_name = 'create'
 
+inputs = {'putput': True}
 node = ctx.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME)
 interface = mock.models.create_interface(
 node.service,
 interface_name,
 operation_name,
-operation_kwargs=dict(implementation=op_path(basic_operation, 
module_path=__name__))
+operation_kwargs=dict(implementation=op_path(basic_operation, 
module_path=__name__),
+  inputs=inputs)
 )
 node.interfaces[interface.name] = interface
 ctx.model.node.update(node)
-inputs = {'putput': True}
 
 @workflow
 def basic_workflow(graph, **_):
@@ -124,17 

[jira] [Commented] (ARIA-48) ARIA CLI

2017-04-19 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-48?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15974676#comment-15974676
 ] 

ASF subversion and git services commented on ARIA-48:
-

Commit 8e5a1ec2fb8d072dc9725be700fce3c570d51de3 in incubator-ariatosca's branch 
refs/heads/ARIA-48-aria-cli from [~ran]
[ https://git-wip-us.apache.org/repos/asf?p=incubator-ariatosca.git;h=8e5a1ec ]

ARIA-48 Revamped ARIA CLI

This is a large commit which revolves mostly around creating the
new CLI, but is also tying ARIA's various components together
for real for the first time - allowing a complete run of the
"hello-world" example and more.

This commit introduces a few other important modules:
 - aria/core.py - used for managing service-templates and services.
 - aria/orchestator/workflow_runner.py - used for managing
   a workflow execution on a service.
 - aria/orchestrator/dry.py - a "dry executor", used for
   dry-executing workflows and printing the tasks that would run.

Other fixes that were required for the successful usage of
ARIA end-to-end have also been introduced in this commit, but
there have been too many to list; Review the commit for more info.


> ARIA CLI
> 
>
> Key: ARIA-48
> URL: https://issues.apache.org/jira/browse/ARIA-48
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Ran Ziv
>Assignee: Ran Ziv
>
> Create a CLI for ARIA (based on Cloudify's CLI)



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[3/5] incubator-ariatosca git commit: ARIA-48 Revamped ARIA CLI

2017-04-19 Thread ran
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/aria/modeling/service_template.py
--
diff --git a/aria/modeling/service_template.py 
b/aria/modeling/service_template.py
index 51fea2f..f1c2bcb 100644
--- a/aria/modeling/service_template.py
+++ b/aria/modeling/service_template.py
@@ -280,7 +280,7 @@ class ServiceTemplateBase(TemplateModelMixin):
 ('interface_types', formatting.as_raw(self.interface_types)),
 ('artifact_types', formatting.as_raw(self.artifact_types
 
-def instantiate(self, container):
+def instantiate(self, container, model_storage, inputs=None):  # pylint: 
disable=arguments-differ
 from . import models
 context = ConsumptionContext.get_thread_local()
 now = datetime.now()
@@ -288,13 +288,14 @@ class ServiceTemplateBase(TemplateModelMixin):
  updated_at=now,
  
description=deepcopy_with_locators(self.description),
  service_template=self)
-#service.name = '{0}_{1}'.format(self.name, service.id)
-
 context.modeling.instance = service
 
+service.inputs = utils.create_inputs(inputs or {}, self.inputs)
+# TODO: now that we have inputs, we should scan properties and inputs 
and evaluate functions
+
 for plugin_specification in self.plugin_specifications.itervalues():
 if plugin_specification.enabled:
-if plugin_specification.resolve():
+if plugin_specification.resolve(model_storage):
 plugin = plugin_specification.plugin
 service.plugins[plugin.name] = plugin
 else:
@@ -316,15 +317,8 @@ class ServiceTemplateBase(TemplateModelMixin):
 if self.substitution_template is not None:
 service.substitution = 
self.substitution_template.instantiate(container)
 
-utils.instantiate_dict(self, service.inputs, self.inputs)
 utils.instantiate_dict(self, service.outputs, self.outputs)
 
-for name, the_input in context.modeling.inputs.iteritems():
-if name not in service.inputs:
-context.validation.report('input "{0}" is not 
supported'.format(name))
-else:
-service.inputs[name].value = the_input
-
 return service
 
 def validate(self):
@@ -448,8 +442,7 @@ class NodeTemplateBase(TemplateModelMixin):
 __tablename__ = 'node_template'
 
 __private_fields__ = ['type_fk',
-  'service_template_fk',
-  'service_template_name']
+  'service_template_fk']
 
 # region foreign_keys
 
@@ -472,6 +465,11 @@ class NodeTemplateBase(TemplateModelMixin):
 """Required for use by SQLAlchemy queries"""
 return association_proxy('service_template', 'name')
 
+@declared_attr
+def type_name(cls):
+"""Required for use by SQLAlchemy queries"""
+return association_proxy('type', 'name')
+
 # endregion
 
 # region one_to_one relationships
@@ -558,6 +556,7 @@ class NodeTemplateBase(TemplateModelMixin):
type=self.type,

description=deepcopy_with_locators(self.description),
state=models.Node.INITIAL,
+   runtime_properties={},
node_template=self)
 utils.instantiate_dict(node, node.properties, self.properties)
 utils.instantiate_dict(node, node.interfaces, self.interface_templates)
@@ -1238,7 +1237,8 @@ class RequirementTemplateBase(TemplateModelMixin):
 
 # Find first node that matches the type
 elif self.target_node_type is not None:
-for target_node_template in 
context.modeling.template.node_templates.itervalues():
+for target_node_template in \
+
self.node_template.service_template.node_templates.values():
 if 
self.target_node_type.get_descendant(target_node_template.type.name) is None:
 continue
 
@@ -1865,16 +1865,22 @@ class OperationTemplateBase(TemplateModelMixin):
 
 def instantiate(self, container):
 from . import models
-if self.plugin_specification and self.plugin_specification.enabled:
-plugin = self.plugin_specification.plugin
-implementation = self.implementation if plugin is not None else 
None
-# "plugin" would be none if a match was not found. In that case, a 
validation error
-# should already have been reported in 
ServiceTemplateBase.instantiate, so we will
-# continue silently here
+if self.plugin_specification:
+if self.plugin_specification.enabled:
+plugin = self.plugin_specification.plugin
+implementation = 

[2/5] incubator-ariatosca git commit: ARIA-48 Revamped ARIA CLI

2017-04-19 Thread ran
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/aria/utils/http.py
--
diff --git a/aria/utils/http.py b/aria/utils/http.py
new file mode 100644
index 000..7bdfd79
--- /dev/null
+++ b/aria/utils/http.py
@@ -0,0 +1,62 @@
+# 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.
+
+import os
+import tempfile
+
+import requests
+
+
+def download_file(url, destination=None, logger=None, progress_handler=None):
+"""Download file.
+
+May raise IOError as well as requests.exceptions.RequestException
+:param url: Location of the file to download
+:type url: str
+:param destination:
+Location where the file should be saved (autogenerated by default)
+:type destination: str | None
+:returns: Location where the file was saved
+:rtype: str
+
+"""
+chunk_size = 1024
+
+if not destination:
+file_descriptor, destination = tempfile.mkstemp()
+os.close(file_descriptor)
+if logger:
+logger.info('Downloading {0} to {1}...'.format(url, destination))
+
+response = requests.get(url, stream=True)
+final_url = response.url
+if final_url != url and logger:
+logger.debug('Redirected to {0}'.format(final_url))
+
+read_bytes = 0
+total_size = int(response.headers['Content-Length']) \
+if 'Content-Length' in response.headers else None
+try:
+with open(destination, 'wb') as destination_file:
+for chunk in response.iter_content(chunk_size):
+destination_file.write(chunk)
+if total_size and progress_handler:
+# Only showing progress bar if we have the total content 
length
+read_bytes += chunk_size
+progress_handler(read_bytes, total_size)
+finally:
+response.close()
+
+return destination

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/aria/utils/threading.py
--
diff --git a/aria/utils/threading.py b/aria/utils/threading.py
index b99250d..bfd30f5 100644
--- a/aria/utils/threading.py
+++ b/aria/utils/threading.py
@@ -15,6 +15,7 @@
 
 from __future__ import absolute_import  # so we can import standard 'threading'
 
+import sys
 import itertools
 import multiprocessing
 from threading import (Thread, Lock)
@@ -255,3 +256,26 @@ class LockedList(list):
 
 def __exit__(self, the_type, value, traceback):
 return self.lock.__exit__(the_type, value, traceback)
+
+
+class ExceptionThread(Thread):
+"""
+A thread from which top level exceptions can be retrieved or reraised
+"""
+def __init__(self, *args, **kwargs):
+Thread.__init__(self, *args, **kwargs)
+self.exception = None
+
+def run(self):
+try:
+super(ExceptionThread, self).run()
+except BaseException:
+self.exception = sys.exc_info()
+
+def is_error(self):
+return self.exception is not None
+
+def raise_error_if_exists(self):
+if self.is_error():
+type_, value, trace = self.exception
+raise type_, value, trace

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/aria/utils/type.py
--
diff --git a/aria/utils/type.py b/aria/utils/type.py
new file mode 100644
index 000..dad5427
--- /dev/null
+++ b/aria/utils/type.py
@@ -0,0 +1,61 @@
+# 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 

[4/5] incubator-ariatosca git commit: ARIA-48 Revamped ARIA CLI

2017-04-19 Thread ran
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/aria/cli/commands/workflows.py
--
diff --git a/aria/cli/commands/workflows.py b/aria/cli/commands/workflows.py
new file mode 100644
index 000..221dbc4
--- /dev/null
+++ b/aria/cli/commands/workflows.py
@@ -0,0 +1,100 @@
+# 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.
+
+from .. import table
+from ..core import aria
+from ..exceptions import AriaCliError
+
+WORKFLOW_COLUMNS = ['name', 'service_template_name', 'service_name']
+
+
+@aria.group(name='workflows')
+def workflows():
+"""Handle service workflows
+"""
+pass
+
+
+@workflows.command(name='show',
+   short_help='Show workflow information')
+@aria.argument('workflow-name')
+@aria.options.service_name(required=True)
+@aria.options.verbose()
+@aria.pass_model_storage
+@aria.pass_logger
+def show(workflow_name, service_name, model_storage, logger):
+"""Show information for a specific workflow of a specific service
+
+`WORKFLOW_NAME` is the name of the workflow to get information on.
+"""
+logger.info('Retrieving workflow {0} for service {1}'.format(
+workflow_name, service_name))
+service = model_storage.service.get_by_name(service_name)
+workflow = next((wf for wf in service.workflows.values() if
+ wf.name == workflow_name), None)
+if not workflow:
+raise AriaCliError(
+'Workflow {0} not found for service {1}'.format(workflow_name, 
service_name))
+
+defaults = {
+'service_template_name': service.service_template_name,
+'service_name': service.name
+}
+table.print_data(WORKFLOW_COLUMNS, workflow, 'Workflows:', 
defaults=defaults)
+
+# print workflow inputs
+required_inputs = dict()
+optional_inputs = dict()
+for input_name, input in workflow.inputs.iteritems():
+inputs_group = optional_inputs if input.value is not None else 
required_inputs
+inputs_group[input_name] = input
+
+logger.info('Workflow Inputs:')
+logger.info('\tMandatory Inputs:')
+for input_name, input in required_inputs.iteritems():
+if input.description is not None:
+logger.info('\t\t{0}\t({1})'.format(input_name,
+input.description))
+else:
+logger.info('\t\t{0}'.format(input_name))
+
+logger.info('\tOptional Inputs:')
+for input_name, input in optional_inputs.iteritems():
+if input.description is not None:
+logger.info('\t\t{0}: \t{1}\t({2})'.format(
+input_name, input.value, input.description))
+else:
+logger.info('\t\t{0}: \t{1}'.format(input_name,
+input.value))
+
+
+@workflows.command(name='list',
+   short_help='List workflows for a service')
+@aria.options.service_name(required=True)
+@aria.options.verbose()
+@aria.pass_model_storage
+@aria.pass_logger
+def list(service_name, model_storage, logger):
+"""List all workflows of a specific service
+"""
+logger.info('Listing workflows for service {0}...'.format(service_name))
+service = model_storage.service.get_by_name(service_name)
+workflows_list = sorted(service.workflows.values(), key=lambda w: w.name)
+
+defaults = {
+'service_template_name': service.service_template_name,
+'service_name': service.name
+}
+table.print_data(WORKFLOW_COLUMNS, workflows_list, 'Workflows:', 
defaults=defaults)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/aria/cli/config.py
--
diff --git a/aria/cli/config.py b/aria/cli/config.py
deleted file mode 100644
index d82886d..000
--- a/aria/cli/config.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# 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 

[1/5] incubator-ariatosca git commit: ARIA-48 Revamped ARIA CLI [Forced Update!]

2017-04-19 Thread ran
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-48-aria-cli 180dab81e -> 8e5a1ec2f (forced update)


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/tests/modeling/test_models.py
--
diff --git a/tests/modeling/test_models.py b/tests/modeling/test_models.py
index bd4eba4..d64cdba 100644
--- a/tests/modeling/test_models.py
+++ b/tests/modeling/test_models.py
@@ -100,12 +100,13 @@ def _nodes_storage():
 service = storage.service.get_by_name(mock.models.SERVICE_NAME)
 dependency_node_template = storage.node_template.get_by_name(
 mock.models.DEPENDENCY_NODE_TEMPLATE_NAME)
-mock.models.create_node(mock.models.DEPENDENCY_NODE_NAME, 
dependency_node_template, service)
+mock.models.create_node(dependency_node_template, service,
+name=mock.models.DEPENDENCY_NODE_NAME)
 
 dependent_node_template = 
mock.models.create_dependent_node_template(service.service_template,
  
dependency_node_template)
 
-mock.models.create_node(mock.models.DEPENDENT_NODE_NAME, 
dependent_node_template, service)
+mock.models.create_node(dependent_node_template, service, 
name=mock.models.DEPENDENT_NODE_NAME)
 storage.service.update(service)
 return storage
 
@@ -180,7 +181,7 @@ class TestServiceTemplate(object):
 @pytest.mark.parametrize(
 'is_valid, description, created_at, updated_at, main_file_name',
 [
-(False, {}, now, now, '/path'),
+(False, [], now, now, '/path'),
 (False, 'description', 'error', now, '/path'),
 (False, 'description', now, 'error', '/path'),
 (False, 'description', now, now, {}),
@@ -253,7 +254,7 @@ class TestService(object):
 class TestExecution(object):
 
 @pytest.mark.parametrize(
-'is_valid, created_at, started_at, ended_at, error, 
is_system_workflow, parameters, '
+'is_valid, created_at, started_at, ended_at, error, 
is_system_workflow, inputs, '
 'status, workflow_name',
 [
 (False, m_cls, now, now, 'error', False, {}, Execution.STARTED, 
'wf_name'),
@@ -268,11 +269,11 @@ class TestExecution(object):
 (True, now, None, now, 'error', False, {}, Execution.STARTED, 
'wf_name'),
 (True, now, now, None, 'error', False, {}, Execution.STARTED, 
'wf_name'),
 (True, now, now, now, None, False, {}, Execution.STARTED, 
'wf_name'),
-(True, now, now, now, 'error', False, None, Execution.STARTED, 
'wf_name'),
+(True, now, now, now, 'error', False, {}, Execution.STARTED, 
'wf_name'),
 ]
 )
 def test_execution_model_creation(self, service_storage, is_valid, 
created_at, started_at,
-  ended_at, error, is_system_workflow, 
parameters, status,
+  ended_at, error, is_system_workflow, 
inputs, status,
   workflow_name):
 execution = _test_model(
 is_valid=is_valid,
@@ -285,7 +286,7 @@ class TestExecution(object):
 ended_at=ended_at,
 error=error,
 is_system_workflow=is_system_workflow,
-parameters=parameters,
+inputs=inputs,
 status=status,
 workflow_name=workflow_name,
 ))
@@ -299,7 +300,7 @@ class TestExecution(object):
 id='e_id',
 workflow_name='w_name',
 status=status,
-parameters={},
+inputs={},
 created_at=now,
 )
 return execution

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8e5a1ec2/tests/orchestrator/context/test_operation.py
--
diff --git a/tests/orchestrator/context/test_operation.py 
b/tests/orchestrator/context/test_operation.py
index af8b454..c399474 100644
--- a/tests/orchestrator/context/test_operation.py
+++ b/tests/orchestrator/context/test_operation.py
@@ -69,16 +69,17 @@ def test_node_operation_task_execution(ctx, 
thread_executor):
 interface_name = 'Standard'
 operation_name = 'create'
 
+inputs = {'putput': True}
 node = ctx.model.node.get_by_name(mock.models.DEPENDENCY_NODE_NAME)
 interface = mock.models.create_interface(
 node.service,
 interface_name,
 operation_name,
-operation_kwargs=dict(implementation=op_path(basic_operation, 
module_path=__name__))
+operation_kwargs=dict(implementation=op_path(basic_operation, 
module_path=__name__),
+  inputs=inputs)
 )
 node.interfaces[interface.name] = interface
 ctx.model.node.update(node)
-inputs = {'putput': True}
 
 @workflow
 def 

incubator-ariatosca git commit: Fix cli tests [ci-skip] [Forced Update!]

2017-04-19 Thread avia
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-48-aria-cli 8a4665a8f -> 180dab81e (forced update)


Fix cli tests [ci-skip]


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/180dab81
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/180dab81
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/180dab81

Branch: refs/heads/ARIA-48-aria-cli
Commit: 180dab81e5614751dc9009f351d7763b0d73c3be
Parents: c16166c
Author: Avia Efrat 
Authored: Wed Apr 19 16:15:57 2017 +0300
Committer: Avia Efrat 
Committed: Wed Apr 19 16:32:27 2017 +0300

--
 aria/cli/commands/node_templates.py |  2 +-
 aria/cli/commands/nodes.py  |  4 ++--
 aria/cli/commands/services.py   |  2 +-
 tests/cli/base_test.py  |  2 +-
 tests/cli/test_service_templates.py | 14 ++
 tests/cli/test_services.py  | 20 
 6 files changed, 19 insertions(+), 25 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/180dab81/aria/cli/commands/node_templates.py
--
diff --git a/aria/cli/commands/node_templates.py 
b/aria/cli/commands/node_templates.py
index 4d53f54..50c755e 100644
--- a/aria/cli/commands/node_templates.py
+++ b/aria/cli/commands/node_templates.py
@@ -88,6 +88,6 @@ def list(service_template_name, sort_by, descending, 
model_storage, logger):
 
 node_templates_list = model_storage.node_template.list(
 filters=filters,
-sort=utils.storage_sort_param(sort_by, descending)).items
+sort=utils.storage_sort_param(sort_by, descending))
 
 table.print_data(NODE_TEMPLATE_COLUMNS, node_templates_list, 'Node 
templates:')

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/180dab81/aria/cli/commands/nodes.py
--
diff --git a/aria/cli/commands/nodes.py b/aria/cli/commands/nodes.py
index eeab338..e43493f 100644
--- a/aria/cli/commands/nodes.py
+++ b/aria/cli/commands/nodes.py
@@ -43,7 +43,7 @@ def show(node_id, model_storage, logger):
 logger.info('Showing node {0}'.format(node_id))
 node = model_storage.node.get(node_id)
 
-table.print_data(NODE_COLUMNS, node, 'Node:', 50)
+table.print_data(NODE_COLUMNS, node, 'Node:', col_max_width=50)
 
 # print node attributes
 logger.info('Node attributes:')
@@ -82,6 +82,6 @@ def list(service_name,
 
 nodes_list = model_storage.node.list(
 filters=filters,
-sort=utils.storage_sort_param(sort_by, descending)).items
+sort=utils.storage_sort_param(sort_by, descending))
 
 table.print_data(NODE_COLUMNS, nodes_list, 'Nodes:')

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/180dab81/aria/cli/commands/services.py
--
diff --git a/aria/cli/commands/services.py b/aria/cli/commands/services.py
index 1aa99f3..50b530a 100644
--- a/aria/cli/commands/services.py
+++ b/aria/cli/commands/services.py
@@ -66,7 +66,7 @@ def list(service_template_name,
 
 services_list = model_storage.service.list(
 sort=utils.storage_sort_param(sort_by=sort_by, descending=descending),
-filters=filters).items
+filters=filters)
 table.print_data(SERVICE_COLUMNS, services_list, 'Services:')
 
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/180dab81/tests/cli/base_test.py
--
diff --git a/tests/cli/base_test.py b/tests/cli/base_test.py
index 4a1d4ab..da9d72c 100644
--- a/tests/cli/base_test.py
+++ b/tests/cli/base_test.py
@@ -55,7 +55,7 @@ class TestCliBase(object):
 
 def assert_exception_raised(outcome, expected_exception, expected_msg=''):
 assert isinstance(outcome.exception, expected_exception)
-assert expected_msg == str(outcome.exception)
+assert expected_msg in str(outcome.exception)
 
 
 # This exists as I wanted to mocked a function using monkeypatch to return a 
function that raises an

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/180dab81/tests/cli/test_service_templates.py
--
diff --git a/tests/cli/test_service_templates.py 
b/tests/cli/test_service_templates.py
index 058853f..01b3f67 100644
--- a/tests/cli/test_service_templates.py
+++ b/tests/cli/test_service_templates.py
@@ -18,7 +18,6 @@ import mock
 
 from aria.cli import service_template_utils, csar
 from aria.cli.env import _Environment
-from aria.cli.exceptions import AriaCliError
 from aria.core import Core
 from aria.exceptions import AriaException
 

incubator-ariatosca git commit: Fix cli tests

2017-04-19 Thread avia
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-48-aria-cli c16166c12 -> 8a4665a8f


Fix cli tests


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/8a4665a8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/8a4665a8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/8a4665a8

Branch: refs/heads/ARIA-48-aria-cli
Commit: 8a4665a8fc570c1bf88f958d65c410575b05c268
Parents: c16166c
Author: Avia Efrat 
Authored: Wed Apr 19 16:15:57 2017 +0300
Committer: Avia Efrat 
Committed: Wed Apr 19 16:15:57 2017 +0300

--
 aria/cli/commands/node_templates.py |  2 +-
 aria/cli/commands/nodes.py  |  4 ++--
 aria/cli/commands/services.py   |  2 +-
 tests/cli/base_test.py  |  2 +-
 tests/cli/test_service_templates.py | 13 ++---
 tests/cli/test_services.py  | 16 +++-
 6 files changed, 18 insertions(+), 21 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8a4665a8/aria/cli/commands/node_templates.py
--
diff --git a/aria/cli/commands/node_templates.py 
b/aria/cli/commands/node_templates.py
index 4d53f54..50c755e 100644
--- a/aria/cli/commands/node_templates.py
+++ b/aria/cli/commands/node_templates.py
@@ -88,6 +88,6 @@ def list(service_template_name, sort_by, descending, 
model_storage, logger):
 
 node_templates_list = model_storage.node_template.list(
 filters=filters,
-sort=utils.storage_sort_param(sort_by, descending)).items
+sort=utils.storage_sort_param(sort_by, descending))
 
 table.print_data(NODE_TEMPLATE_COLUMNS, node_templates_list, 'Node 
templates:')

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8a4665a8/aria/cli/commands/nodes.py
--
diff --git a/aria/cli/commands/nodes.py b/aria/cli/commands/nodes.py
index eeab338..e43493f 100644
--- a/aria/cli/commands/nodes.py
+++ b/aria/cli/commands/nodes.py
@@ -43,7 +43,7 @@ def show(node_id, model_storage, logger):
 logger.info('Showing node {0}'.format(node_id))
 node = model_storage.node.get(node_id)
 
-table.print_data(NODE_COLUMNS, node, 'Node:', 50)
+table.print_data(NODE_COLUMNS, node, 'Node:', col_max_width=50)
 
 # print node attributes
 logger.info('Node attributes:')
@@ -82,6 +82,6 @@ def list(service_name,
 
 nodes_list = model_storage.node.list(
 filters=filters,
-sort=utils.storage_sort_param(sort_by, descending)).items
+sort=utils.storage_sort_param(sort_by, descending))
 
 table.print_data(NODE_COLUMNS, nodes_list, 'Nodes:')

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8a4665a8/aria/cli/commands/services.py
--
diff --git a/aria/cli/commands/services.py b/aria/cli/commands/services.py
index 1aa99f3..50b530a 100644
--- a/aria/cli/commands/services.py
+++ b/aria/cli/commands/services.py
@@ -66,7 +66,7 @@ def list(service_template_name,
 
 services_list = model_storage.service.list(
 sort=utils.storage_sort_param(sort_by=sort_by, descending=descending),
-filters=filters).items
+filters=filters)
 table.print_data(SERVICE_COLUMNS, services_list, 'Services:')
 
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8a4665a8/tests/cli/base_test.py
--
diff --git a/tests/cli/base_test.py b/tests/cli/base_test.py
index 4a1d4ab..da9d72c 100644
--- a/tests/cli/base_test.py
+++ b/tests/cli/base_test.py
@@ -55,7 +55,7 @@ class TestCliBase(object):
 
 def assert_exception_raised(outcome, expected_exception, expected_msg=''):
 assert isinstance(outcome.exception, expected_exception)
-assert expected_msg == str(outcome.exception)
+assert expected_msg in str(outcome.exception)
 
 
 # This exists as I wanted to mocked a function using monkeypatch to return a 
function that raises an

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8a4665a8/tests/cli/test_service_templates.py
--
diff --git a/tests/cli/test_service_templates.py 
b/tests/cli/test_service_templates.py
index 058853f..1512b7d 100644
--- a/tests/cli/test_service_templates.py
+++ b/tests/cli/test_service_templates.py
@@ -142,9 +142,8 @@ class TestServiceTemplatesStore(TestCliBase):
 
 assert_exception_raised(
 self.invoke('service_templates store stubpath test_st'),
-expected_exception=AriaCliError,
-expected_msg='Could not store service 

incubator-ariatosca git commit: fixed imports style and added licenses to cli tests

2017-04-19 Thread ran
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-48-aria-cli e17916e19 -> 195597dba


fixed imports style and added licenses to cli tests


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/195597db
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/195597db
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/195597db

Branch: refs/heads/ARIA-48-aria-cli
Commit: 195597dba119fb693693ca6dd8aee9db8e46ecef
Parents: e17916e
Author: Ran Ziv 
Authored: Wed Apr 19 15:54:54 2017 +0300
Committer: Ran Ziv 
Committed: Wed Apr 19 15:54:54 2017 +0300

--
 tests/cli/base_test.py  | 35 +++-
 tests/cli/runner.py | 18 -
 tests/cli/test_node_templates.py| 62 +++--
 tests/cli/test_nodes.py | 30 +++---
 tests/cli/test_service_templates.py | 68 +---
 tests/cli/test_services.py  | 56 ++
 tests/cli/utils.py  | 18 -
 7 files changed, 210 insertions(+), 77 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/195597db/tests/cli/base_test.py
--
diff --git a/tests/cli/base_test.py b/tests/cli/base_test.py
index 9268f71..4a1d4ab 100644
--- a/tests/cli/base_test.py
+++ b/tests/cli/base_test.py
@@ -1,15 +1,30 @@
-from StringIO import StringIO
+# 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.
+
 import logging
+from StringIO import StringIO
 
 import pytest
 
-import tests.cli.runner as runner
-from tests.cli.utils import setup_logger, MockStorage
+from . import runner
+from . import utils
 
 
 @pytest.fixture
 def mock_storage():
-return MockStorage()
+return utils.MockStorage()
 
 
 @pytest.mark.usefixtures("redirect_logger")
@@ -19,13 +34,13 @@ class TestCliBase(object):
 @pytest.fixture(scope="class")
 def redirect_logger():
 
-setup_logger(logger_name='aria.cli.main',
- 
handlers=[logging.StreamHandler(TestCliBase._logger_output)],
- logger_format='%(message)s')
+utils.setup_logger(logger_name='aria.cli.main',
+   
handlers=[logging.StreamHandler(TestCliBase._logger_output)],
+   logger_format='%(message)s')
 yield
-setup_logger(logger_name='aria.cli.main',
- handlers=_default_logger_config['handlers'],
- level=_default_logger_config['level'])
+utils.setup_logger(logger_name='aria.cli.main',
+   handlers=_default_logger_config['handlers'],
+   level=_default_logger_config['level'])
 
 _logger_output = StringIO()
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/195597db/tests/cli/runner.py
--
diff --git a/tests/cli/runner.py b/tests/cli/runner.py
index 1682f95..7e4243b 100644
--- a/tests/cli/runner.py
+++ b/tests/cli/runner.py
@@ -1,6 +1,22 @@
-import aria.cli.commands as commands
+# 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.
+
 import click.testing
 

[2/4] incubator-ariatosca git commit: Add tests for logs list

2017-04-19 Thread avia
Add tests for logs list


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/da42f99d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/da42f99d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/da42f99d

Branch: refs/heads/cli-tests
Commit: da42f99d4a32fa57feeefd34a721512771dc9fe8
Parents: 82591f0
Author: Avia Efrat 
Authored: Tue Apr 18 12:28:37 2017 +0300
Committer: Avia Efrat 
Committed: Wed Apr 19 15:35:17 2017 +0300

--
 aria/cli/commands/logs.py |  2 +-
 tests/cli/test_logs.py| 23 +++
 tests/cli/utils.py| 10 ++
 tests/mock/models.py  |  9 +
 4 files changed, 43 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/da42f99d/aria/cli/commands/logs.py
--
diff --git a/aria/cli/commands/logs.py b/aria/cli/commands/logs.py
index fef..6c83347 100644
--- a/aria/cli/commands/logs.py
+++ b/aria/cli/commands/logs.py
@@ -42,7 +42,7 @@ def list(execution_id,
 # TODO: print logs nicely
 if logs_list:
 for log in logs_list:
-print log
+logger.info(log)
 else:
 logger.info('\tNo logs')
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/da42f99d/tests/cli/test_logs.py
--
diff --git a/tests/cli/test_logs.py b/tests/cli/test_logs.py
new file mode 100644
index 000..ad0c4f1
--- /dev/null
+++ b/tests/cli/test_logs.py
@@ -0,0 +1,23 @@
+from aria.cli.env import _Environment
+from tests.cli.base_test import TestCliBase, mock_storage
+
+
+class TestLogsList(TestCliBase):
+
+def test_existing_logs(self, monkeypatch, mock_storage):
+monkeypatch.setattr(_Environment, 'model_storage', mock_storage)
+self.invoke('logs list exec_id')
+
+assert 'Listing logs for execution id exec_id' in 
self.logger_output_string
+assert 'log_msg' in self.logger_output_string
+assert 'No logs' not in self.logger_output_string
+
+def test_no_logs(self, monkeypatch, mock_object):
+m = mock_object
+m.log.list.return_value = []
+monkeypatch.setattr(_Environment, 'model_storage', m)
+self.invoke('logs list exec_id')
+
+assert 'Listing logs for execution id exec_id' in 
self.logger_output_string
+assert 'log_msg' not in self.logger_output_string
+assert 'No logs' in self.logger_output_string

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/da42f99d/tests/cli/utils.py
--
diff --git a/tests/cli/utils.py b/tests/cli/utils.py
index 20fdb90..b1537c5 100644
--- a/tests/cli/utils.py
+++ b/tests/cli/utils.py
@@ -51,6 +51,7 @@ class MockStorage(object):
 self.service = MockServiceStorage()
 self.node_template = MockNodeTemplateStorage()
 self.node = MockNodeStorage()
+self.log = MockLogStorage()
 
 
 class MockServiceTemplateStorage(object):
@@ -173,3 +174,12 @@ class MockNodeStorage(object):
 elif id == '2':
 n.runtime_properties = {'attribute1': 'value1'}
 return n
+
+
+class MockLogStorage(object):
+
+def __init__(self):
+st = mock_models.create_service_template('test_st')
+s = mock_models.create_service(st, 'test_s')
+execution = mock_models.create_execution(s)
+self.list = MagicMock(return_value=[mock_models.create_log(execution)])

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/da42f99d/tests/mock/models.py
--
diff --git a/tests/mock/models.py b/tests/mock/models.py
index 8a9273b..328453a 100644
--- a/tests/mock/models.py
+++ b/tests/mock/models.py
@@ -245,6 +245,15 @@ def create_parameter(name, value):
 return p.wrap(name, value)
 
 
+def create_log(execution, msg='log_msg', level=0, 
created_at=datetime.utcnow()):
+
+return models.Log(
+execution=execution,
+msg=msg,
+level=level,
+created_at=created_at)
+
+
 def _dictify(item):
 return dict(((item.name, item),))
 



[3/3] incubator-ariatosca git commit: Partial fixes for cli tests

2017-04-19 Thread avia
Partial fixes for cli tests


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/e17916e1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/e17916e1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/e17916e1

Branch: refs/heads/ARIA-48-aria-cli
Commit: e17916e1938bb54522d1e5fb9d4d3256930486fd
Parents: 54b5a9f
Author: Avia Efrat 
Authored: Wed Apr 19 15:34:27 2017 +0300
Committer: Avia Efrat 
Committed: Wed Apr 19 15:35:57 2017 +0300

--
 aria/cli/commands/service_templates.py |  9 +
 aria/cli/commands/services.py  |  2 +-
 aria/storage/sql_mapi.py   | 22 ++
 3 files changed, 12 insertions(+), 21 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/e17916e1/aria/cli/commands/service_templates.py
--
diff --git a/aria/cli/commands/service_templates.py 
b/aria/cli/commands/service_templates.py
index 189ba51..97367c2 100644
--- a/aria/cli/commands/service_templates.py
+++ b/aria/cli/commands/service_templates.py
@@ -65,9 +65,10 @@ def show(service_template_name, model_storage, logger):
 
logger.info('{0}{1}'.format(service_template_dict['description'].encode('UTF-8')
 or '',
 os.linesep))
 
-logger.info('Existing services:')
-for service in service_template.services:
-logger.info('\t{0}'.format(service.name))
+if service_template.services:
+logger.info('Existing services:')
+for service in service_template.services:
+logger.info('\t{0}'.format(service.name))
 
 
 @service_templates.command(name='list',
@@ -83,7 +84,7 @@ def list(sort_by, descending, model_storage, logger):
 
 logger.info('Listing all service templates...')
 service_templates_list = model_storage.service_template.list(
-sort=utils.storage_sort_param(sort_by, descending)).items
+sort=utils.storage_sort_param(sort_by, descending))
 
 column_formatters = \
 
dict(description=table.trim_formatter_generator(DESCRIPTION_FIELD_LENGTH_LIMIT))

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/e17916e1/aria/cli/commands/services.py
--
diff --git a/aria/cli/commands/services.py b/aria/cli/commands/services.py
index 1aa99f3..81bef7d 100644
--- a/aria/cli/commands/services.py
+++ b/aria/cli/commands/services.py
@@ -19,9 +19,9 @@ from StringIO import StringIO
 
 from . import service_templates
 from .. import helptexts
-from .. import table
 from .. import utils
 from ..core import aria
+from ..table import print_data
 from ...core import Core
 from ...modeling import exceptions as modeling_exceptions
 from ...storage import exceptions as storage_exceptions

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/e17916e1/aria/storage/sql_mapi.py
--
diff --git a/aria/storage/sql_mapi.py b/aria/storage/sql_mapi.py
index 144c925..730d007 100644
--- a/aria/storage/sql_mapi.py
+++ b/aria/storage/sql_mapi.py
@@ -92,10 +92,8 @@ class SQLAlchemyModelAPI(api.ModelAPI):
 results, total, size, offset = self._paginate(query, pagination)
 
 return ListResult(
-items=results,
-metadata=dict(total=total,
-  size=size,
-  offset=offset)
+dict(total=total, size=size, offset=offset),
+results
 )
 
 def iter(self,
@@ -406,19 +404,11 @@ def init_storage(base_dir, filename='db.sqlite'):
 return dict(engine=engine, session=session)
 
 
-class ListResult(object):
+class ListResult(list):
 """
 a ListResult contains results about the requested items.
 """
-def __init__(self, items, metadata):
-self.items = items
+def __init__(self, metadata, *args, **qwargs):
+super(ListResult, self).__init__(*args, **qwargs)
 self.metadata = metadata
-
-def __len__(self):
-return len(self.items)
-
-def __iter__(self):
-return iter(self.items)
-
-def __getitem__(self, item):
-return self.items[item]
+self.items = self



[2/3] incubator-ariatosca git commit: Add tests for logs list

2017-04-19 Thread avia
Add tests for logs list


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/da42f99d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/da42f99d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/da42f99d

Branch: refs/heads/ARIA-48-aria-cli
Commit: da42f99d4a32fa57feeefd34a721512771dc9fe8
Parents: 82591f0
Author: Avia Efrat 
Authored: Tue Apr 18 12:28:37 2017 +0300
Committer: Avia Efrat 
Committed: Wed Apr 19 15:35:17 2017 +0300

--
 aria/cli/commands/logs.py |  2 +-
 tests/cli/test_logs.py| 23 +++
 tests/cli/utils.py| 10 ++
 tests/mock/models.py  |  9 +
 4 files changed, 43 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/da42f99d/aria/cli/commands/logs.py
--
diff --git a/aria/cli/commands/logs.py b/aria/cli/commands/logs.py
index fef..6c83347 100644
--- a/aria/cli/commands/logs.py
+++ b/aria/cli/commands/logs.py
@@ -42,7 +42,7 @@ def list(execution_id,
 # TODO: print logs nicely
 if logs_list:
 for log in logs_list:
-print log
+logger.info(log)
 else:
 logger.info('\tNo logs')
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/da42f99d/tests/cli/test_logs.py
--
diff --git a/tests/cli/test_logs.py b/tests/cli/test_logs.py
new file mode 100644
index 000..ad0c4f1
--- /dev/null
+++ b/tests/cli/test_logs.py
@@ -0,0 +1,23 @@
+from aria.cli.env import _Environment
+from tests.cli.base_test import TestCliBase, mock_storage
+
+
+class TestLogsList(TestCliBase):
+
+def test_existing_logs(self, monkeypatch, mock_storage):
+monkeypatch.setattr(_Environment, 'model_storage', mock_storage)
+self.invoke('logs list exec_id')
+
+assert 'Listing logs for execution id exec_id' in 
self.logger_output_string
+assert 'log_msg' in self.logger_output_string
+assert 'No logs' not in self.logger_output_string
+
+def test_no_logs(self, monkeypatch, mock_object):
+m = mock_object
+m.log.list.return_value = []
+monkeypatch.setattr(_Environment, 'model_storage', m)
+self.invoke('logs list exec_id')
+
+assert 'Listing logs for execution id exec_id' in 
self.logger_output_string
+assert 'log_msg' not in self.logger_output_string
+assert 'No logs' in self.logger_output_string

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/da42f99d/tests/cli/utils.py
--
diff --git a/tests/cli/utils.py b/tests/cli/utils.py
index 20fdb90..b1537c5 100644
--- a/tests/cli/utils.py
+++ b/tests/cli/utils.py
@@ -51,6 +51,7 @@ class MockStorage(object):
 self.service = MockServiceStorage()
 self.node_template = MockNodeTemplateStorage()
 self.node = MockNodeStorage()
+self.log = MockLogStorage()
 
 
 class MockServiceTemplateStorage(object):
@@ -173,3 +174,12 @@ class MockNodeStorage(object):
 elif id == '2':
 n.runtime_properties = {'attribute1': 'value1'}
 return n
+
+
+class MockLogStorage(object):
+
+def __init__(self):
+st = mock_models.create_service_template('test_st')
+s = mock_models.create_service(st, 'test_s')
+execution = mock_models.create_execution(s)
+self.list = MagicMock(return_value=[mock_models.create_log(execution)])

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/da42f99d/tests/mock/models.py
--
diff --git a/tests/mock/models.py b/tests/mock/models.py
index 8a9273b..328453a 100644
--- a/tests/mock/models.py
+++ b/tests/mock/models.py
@@ -245,6 +245,15 @@ def create_parameter(name, value):
 return p.wrap(name, value)
 
 
+def create_log(execution, msg='log_msg', level=0, 
created_at=datetime.utcnow()):
+
+return models.Log(
+execution=execution,
+msg=msg,
+level=level,
+created_at=created_at)
+
+
 def _dictify(item):
 return dict(((item.name, item),))
 



[1/3] incubator-ariatosca git commit: Refactor cli tests framework

2017-04-19 Thread avia
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-48-aria-cli 82591f06c -> e17916e19


Refactor cli tests framework


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/54b5a9f1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/54b5a9f1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/54b5a9f1

Branch: refs/heads/ARIA-48-aria-cli
Commit: 54b5a9f16b573b6614452d661814ca721609f019
Parents: da42f99
Author: Avia Efrat 
Authored: Wed Apr 19 14:17:27 2017 +0300
Committer: Avia Efrat 
Committed: Wed Apr 19 15:35:17 2017 +0300

--
 tests/cli/test_logs.py  |  23 --
 tests/cli/test_node_templates.py|  56 --
 tests/cli/test_nodes.py |  21 +++--
 tests/cli/test_service_templates.py | 124 +-
 tests/cli/test_services.py  |  93 +++---
 tests/cli/utils.py  | 128 ---
 tests/mock/models.py|  69 +
 tests/mock/topology.py  |   8 +-
 tests/modeling/test_models.py   |   5 +-
 9 files changed, 258 insertions(+), 269 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/54b5a9f1/tests/cli/test_logs.py
--
diff --git a/tests/cli/test_logs.py b/tests/cli/test_logs.py
deleted file mode 100644
index ad0c4f1..000
--- a/tests/cli/test_logs.py
+++ /dev/null
@@ -1,23 +0,0 @@
-from aria.cli.env import _Environment
-from tests.cli.base_test import TestCliBase, mock_storage
-
-
-class TestLogsList(TestCliBase):
-
-def test_existing_logs(self, monkeypatch, mock_storage):
-monkeypatch.setattr(_Environment, 'model_storage', mock_storage)
-self.invoke('logs list exec_id')
-
-assert 'Listing logs for execution id exec_id' in 
self.logger_output_string
-assert 'log_msg' in self.logger_output_string
-assert 'No logs' not in self.logger_output_string
-
-def test_no_logs(self, monkeypatch, mock_object):
-m = mock_object
-m.log.list.return_value = []
-monkeypatch.setattr(_Environment, 'model_storage', m)
-self.invoke('logs list exec_id')
-
-assert 'Listing logs for execution id exec_id' in 
self.logger_output_string
-assert 'log_msg' not in self.logger_output_string
-assert 'No logs' in self.logger_output_string

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/54b5a9f1/tests/cli/test_node_templates.py
--
diff --git a/tests/cli/test_node_templates.py b/tests/cli/test_node_templates.py
index f0ad539..931c0a4 100644
--- a/tests/cli/test_node_templates.py
+++ b/tests/cli/test_node_templates.py
@@ -1,57 +1,66 @@
-from mock import ANY
+from mock import ANY, MagicMock
 import pytest
 
 from aria.cli.env import _Environment
 from tests.cli.base_test import TestCliBase, mock_storage  # pylint: 
disable=unused-import
+from tests.mock.models import create_node_template_with_dependencies, 
NODE_NAME, \
+SERVICE_TEMPLATE_NAME, NODE_TEMPLATE_NAME
 
 
 class TestNodeTemplatesShow(TestCliBase):
 
-def test_no_properties_no_nodes(self, monkeypatch, mock_storage):
-
+def test_header_strings(self, monkeypatch, mock_storage):
 monkeypatch.setattr(_Environment, 'model_storage', mock_storage)
 self.invoke('node_templates show 1')
 assert 'Showing node template 1' in self.logger_output_string
 assert 'Node template properties:' in self.logger_output_string
+assert 'Nodes:' in self.logger_output_string
+
+def test_no_properties_no_nodes(self, monkeypatch, mock_storage):
+
+monkeypatch.setattr(_Environment, 'model_storage', mock_storage)
+self.invoke('node_templates show 1')
+
 assert 'No properties' in self.logger_output_string
 assert 'prop1' not in self.logger_output_string
 assert 'value1' not in self.logger_output_string
 assert 'No nodes' in self.logger_output_string
-assert 'node1' not in self.logger_output_string
+assert NODE_NAME not in self.logger_output_string
 
 def test_one_property_no_nodes(self, monkeypatch, mock_storage):
 
 monkeypatch.setattr(_Environment, 'model_storage', mock_storage)
+m = 
MagicMock(return_value=create_node_template_with_dependencies(include_property=True))
+monkeypatch.setattr(mock_storage.node_template, 'get', m)
 self.invoke('node_templates show 2')
-assert 'Showing node template 2' in self.logger_output_string
-assert 'Node template properties:' in 

[1/4] incubator-ariatosca git commit: final review fixes [Forced Update!]

2017-04-19 Thread avia
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/cli-tests 0a829ae9e -> e17916e19 (forced update)


final review 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/82591f06
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/82591f06
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/82591f06

Branch: refs/heads/cli-tests
Commit: 82591f06c023d93755c7cb123b1b49f5c51f5bec
Parents: a39e7d1
Author: Ran Ziv 
Authored: Wed Apr 19 15:18:08 2017 +0300
Committer: Ran Ziv 
Committed: Wed Apr 19 15:18:08 2017 +0300

--
 aria/cli/commands/executions.py |  6 +++---
 aria/cli/commands/node_templates.py |  6 +++---
 aria/cli/commands/nodes.py  |  6 +++---
 aria/cli/commands/plugins.py|  6 +++---
 aria/cli/commands/services.py   |  4 ++--
 aria/cli/commands/workflows.py  |  6 +++---
 aria/cli/core/aria.py   | 10 +-
 aria/cli/defaults.py|  8 
 aria/orchestrator/plugin.py |  1 +
 9 files changed, 27 insertions(+), 26 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/82591f06/aria/cli/commands/executions.py
--
diff --git a/aria/cli/commands/executions.py b/aria/cli/commands/executions.py
index adec56b..e100f0d 100644
--- a/aria/cli/commands/executions.py
+++ b/aria/cli/commands/executions.py
@@ -16,9 +16,9 @@
 import os
 
 from .. import helptexts
+from .. import table
 from .. import utils
 from ..core import aria
-from ..table import print_data
 from ...modeling.models import Execution
 from ...orchestrator.workflow_runner import WorkflowRunner
 from ...orchestrator.workflows.executor.dry import DryExecutor
@@ -51,7 +51,7 @@ def show(execution_id, model_storage, logger):
 logger.info('Showing execution {0}'.format(execution_id))
 execution = model_storage.execution.get(execution_id)
 
-print_data(EXECUTION_COLUMNS, execution, 'Execution:', col_max_width=50)
+table.print_data(EXECUTION_COLUMNS, execution, 'Execution:', 
col_max_width=50)
 
 # print execution parameters
 logger.info('Execution Inputs:')
@@ -96,7 +96,7 @@ def list(service_name,
 filters=filters,
 sort=utils.storage_sort_param(sort_by, descending)).items
 
-print_data(EXECUTION_COLUMNS, executions_list, 'Executions:')
+table.print_data(EXECUTION_COLUMNS, executions_list, 'Executions:')
 
 
 @executions.command(name='start',

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/82591f06/aria/cli/commands/node_templates.py
--
diff --git a/aria/cli/commands/node_templates.py 
b/aria/cli/commands/node_templates.py
index f0ca2c1..4d53f54 100644
--- a/aria/cli/commands/node_templates.py
+++ b/aria/cli/commands/node_templates.py
@@ -13,9 +13,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from .. import table
 from .. import utils
 from ..core import aria
-from ..table import print_data
 
 
 NODE_TEMPLATE_COLUMNS = ['id', 'name', 'description', 'service_template_name', 
'type_name']
@@ -44,7 +44,7 @@ def show(node_template_id, model_storage, logger):
 logger.info('Showing node template {0}'.format(node_template_id))
 node_template = model_storage.node_template.get(node_template_id)
 
-print_data(NODE_TEMPLATE_COLUMNS, node_template, 'Node template:', 
col_max_width=50)
+table.print_data(NODE_TEMPLATE_COLUMNS, node_template, 'Node template:', 
col_max_width=50)
 
 # print node template properties
 logger.info('Node template properties:')
@@ -90,4 +90,4 @@ def list(service_template_name, sort_by, descending, 
model_storage, logger):
 filters=filters,
 sort=utils.storage_sort_param(sort_by, descending)).items
 
-print_data(NODE_TEMPLATE_COLUMNS, node_templates_list, 'Node templates:')
+table.print_data(NODE_TEMPLATE_COLUMNS, node_templates_list, 'Node 
templates:')

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/82591f06/aria/cli/commands/nodes.py
--
diff --git a/aria/cli/commands/nodes.py b/aria/cli/commands/nodes.py
index 0a00478..eeab338 100644
--- a/aria/cli/commands/nodes.py
+++ b/aria/cli/commands/nodes.py
@@ -13,9 +13,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from .. import table
 from .. import utils
 from ..core import aria
-from ..table import print_data
 
 
 NODE_COLUMNS = ['id', 'name', 'service_name', 'node_template_name', 'state']
@@ -43,7 +43,7 @@ def 

[4/4] incubator-ariatosca git commit: Partial fixes for cli tests

2017-04-19 Thread avia
Partial fixes for cli tests


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/e17916e1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/e17916e1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/e17916e1

Branch: refs/heads/cli-tests
Commit: e17916e1938bb54522d1e5fb9d4d3256930486fd
Parents: 54b5a9f
Author: Avia Efrat 
Authored: Wed Apr 19 15:34:27 2017 +0300
Committer: Avia Efrat 
Committed: Wed Apr 19 15:35:57 2017 +0300

--
 aria/cli/commands/service_templates.py |  9 +
 aria/cli/commands/services.py  |  2 +-
 aria/storage/sql_mapi.py   | 22 ++
 3 files changed, 12 insertions(+), 21 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/e17916e1/aria/cli/commands/service_templates.py
--
diff --git a/aria/cli/commands/service_templates.py 
b/aria/cli/commands/service_templates.py
index 189ba51..97367c2 100644
--- a/aria/cli/commands/service_templates.py
+++ b/aria/cli/commands/service_templates.py
@@ -65,9 +65,10 @@ def show(service_template_name, model_storage, logger):
 
logger.info('{0}{1}'.format(service_template_dict['description'].encode('UTF-8')
 or '',
 os.linesep))
 
-logger.info('Existing services:')
-for service in service_template.services:
-logger.info('\t{0}'.format(service.name))
+if service_template.services:
+logger.info('Existing services:')
+for service in service_template.services:
+logger.info('\t{0}'.format(service.name))
 
 
 @service_templates.command(name='list',
@@ -83,7 +84,7 @@ def list(sort_by, descending, model_storage, logger):
 
 logger.info('Listing all service templates...')
 service_templates_list = model_storage.service_template.list(
-sort=utils.storage_sort_param(sort_by, descending)).items
+sort=utils.storage_sort_param(sort_by, descending))
 
 column_formatters = \
 
dict(description=table.trim_formatter_generator(DESCRIPTION_FIELD_LENGTH_LIMIT))

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/e17916e1/aria/cli/commands/services.py
--
diff --git a/aria/cli/commands/services.py b/aria/cli/commands/services.py
index 1aa99f3..81bef7d 100644
--- a/aria/cli/commands/services.py
+++ b/aria/cli/commands/services.py
@@ -19,9 +19,9 @@ from StringIO import StringIO
 
 from . import service_templates
 from .. import helptexts
-from .. import table
 from .. import utils
 from ..core import aria
+from ..table import print_data
 from ...core import Core
 from ...modeling import exceptions as modeling_exceptions
 from ...storage import exceptions as storage_exceptions

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/e17916e1/aria/storage/sql_mapi.py
--
diff --git a/aria/storage/sql_mapi.py b/aria/storage/sql_mapi.py
index 144c925..730d007 100644
--- a/aria/storage/sql_mapi.py
+++ b/aria/storage/sql_mapi.py
@@ -92,10 +92,8 @@ class SQLAlchemyModelAPI(api.ModelAPI):
 results, total, size, offset = self._paginate(query, pagination)
 
 return ListResult(
-items=results,
-metadata=dict(total=total,
-  size=size,
-  offset=offset)
+dict(total=total, size=size, offset=offset),
+results
 )
 
 def iter(self,
@@ -406,19 +404,11 @@ def init_storage(base_dir, filename='db.sqlite'):
 return dict(engine=engine, session=session)
 
 
-class ListResult(object):
+class ListResult(list):
 """
 a ListResult contains results about the requested items.
 """
-def __init__(self, items, metadata):
-self.items = items
+def __init__(self, metadata, *args, **qwargs):
+super(ListResult, self).__init__(*args, **qwargs)
 self.metadata = metadata
-
-def __len__(self):
-return len(self.items)
-
-def __iter__(self):
-return iter(self.items)
-
-def __getitem__(self, item):
-return self.items[item]
+self.items = self



[05/10] incubator-ariatosca git commit: fixed ssh tests

2017-04-19 Thread mxmrlv
fixed ssh tests


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/8b0e451a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/8b0e451a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/8b0e451a

Branch: refs/heads/ARIA-138-Make-logging-more-informative
Commit: 8b0e451ab3cb5dbb7dbab3c53aac6730c3ea3d64
Parents: 1bfefd1
Author: Ran Ziv 
Authored: Tue Apr 18 16:05:24 2017 +0300
Committer: Ran Ziv 
Committed: Tue Apr 18 16:05:24 2017 +0300

--
 tests/orchestrator/execution_plugin/test_ssh.py | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8b0e451a/tests/orchestrator/execution_plugin/test_ssh.py
--
diff --git a/tests/orchestrator/execution_plugin/test_ssh.py 
b/tests/orchestrator/execution_plugin/test_ssh.py
index dcfd88e..a75d59a 100644
--- a/tests/orchestrator/execution_plugin/test_ssh.py
+++ b/tests/orchestrator/execution_plugin/test_ssh.py
@@ -222,11 +222,13 @@ class TestWithActualSSHServer(object):
 'fabric_env': _FABRIC_ENV,
 'process': process,
 'use_sudo': use_sudo,
-'hide_output': hide_output,
 'custom_env_var': custom_input,
 'test_operation': '',
-'commands': commands
 }
+if hide_output:
+inputs['hide_output'] = hide_output
+if commands:
+inputs['commands'] = commands
 interface = mock.models.create_interface(
 node.service,
 'test',



[03/10] incubator-ariatosca git commit: fixed pylint issues

2017-04-19 Thread mxmrlv
fixed pylint issues


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/38f9abad
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/38f9abad
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/38f9abad

Branch: refs/heads/ARIA-138-Make-logging-more-informative
Commit: 38f9abada5f850729c46c269ee063add58d15ec0
Parents: 9f9dc3e
Author: Ran Ziv 
Authored: Tue Apr 18 14:40:14 2017 +0300
Committer: Ran Ziv 
Committed: Tue Apr 18 14:40:14 2017 +0300

--
 aria/parser/consumption/__init__.py | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/38f9abad/aria/parser/consumption/__init__.py
--
diff --git a/aria/parser/consumption/__init__.py 
b/aria/parser/consumption/__init__.py
index 8e565eb..8f6d2b6 100644
--- a/aria/parser/consumption/__init__.py
+++ b/aria/parser/consumption/__init__.py
@@ -17,10 +17,21 @@
 from .exceptions import ConsumerException
 from .context import ConsumptionContext
 from .style import Style
-from .consumer import Consumer, ConsumerChain
+from .consumer import (
+Consumer,
+ConsumerChain
+)
 from .presentation import Read
 from .validation import Validate
-from .modeling import ServiceTemplate, Types, ServiceInstance, FindHosts, 
ConfigureOperations, SatisfyRequirements, ValidateCapabilities
+from .modeling import (
+ServiceTemplate,
+Types,
+ServiceInstance,
+FindHosts,
+ConfigureOperations,
+SatisfyRequirements,
+ValidateCapabilities
+)
 from .inputs import Inputs
 
 __all__ = (
@@ -37,4 +48,4 @@ __all__ = (
 'Inputs',
 'SatisfyRequirements',
 'ValidateCapabilities'
-)
\ No newline at end of file
+)



[10/10] incubator-ariatosca git commit: ARIA-138-Make-logging-more-informative

2017-04-19 Thread mxmrlv
ARIA-138-Make-logging-more-informative


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/aaac6f60
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/aaac6f60
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/aaac6f60

Branch: refs/heads/ARIA-138-Make-logging-more-informative
Commit: aaac6f6018c878bdec6036dd2f9ab5e0662140c6
Parents: 1cbd81b
Author: max-orlov 
Authored: Mon Apr 17 18:50:58 2017 +0300
Committer: max-orlov 
Committed: Wed Apr 19 13:59:56 2017 +0300

--
 aria/cli/commands/__init__.py   |  1 +
 aria/cli/commands/executions.py | 12 +++-
 aria/cli/commands/logs.py   | 26 
 aria/cli/execution_logging.py   | 66 
 aria/cli/logger.py  | 18 ++
 aria/logger.py  |  4 +-
 aria/modeling/orchestration.py  | 11 +++-
 aria/orchestrator/context/common.py | 39 ++--
 aria/orchestrator/context/operation.py  | 29 +
 aria/orchestrator/context/workflow.py   |  4 +-
 aria/orchestrator/workflow_runner.py|  6 +-
 aria/orchestrator/workflows/core/engine.py  |  2 +
 aria/orchestrator/workflows/events_logging.py   | 26 
 aria/orchestrator/workflows/executor/base.py|  4 +-
 aria/orchestrator/workflows/executor/process.py | 15 +++--
 aria/orchestrator/workflows/executor/thread.py  |  8 ++-
 tests/.pylintrc |  2 +-
 .../orchestrator/workflows/executor/__init__.py | 51 +++
 .../workflows/executor/test_executor.py | 64 +++
 .../workflows/executor/test_process_executor.py | 37 +--
 20 files changed, 243 insertions(+), 182 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/aaac6f60/aria/cli/commands/__init__.py
--
diff --git a/aria/cli/commands/__init__.py b/aria/cli/commands/__init__.py
index a01a029..5d76ea6 100644
--- a/aria/cli/commands/__init__.py
+++ b/aria/cli/commands/__init__.py
@@ -1,3 +1,4 @@
+
 # 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.

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/aaac6f60/aria/cli/commands/executions.py
--
diff --git a/aria/cli/commands/executions.py b/aria/cli/commands/executions.py
index adec56b..b8f78d4 100644
--- a/aria/cli/commands/executions.py
+++ b/aria/cli/commands/executions.py
@@ -16,8 +16,10 @@
 import os
 
 from .. import helptexts
+from aria.cli import execution_logging
 from .. import utils
 from ..core import aria
+from .. import logger as cli_logger
 from ..table import print_data
 from ...modeling.models import Execution
 from ...orchestrator.workflow_runner import WorkflowRunner
@@ -141,13 +143,19 @@ def start(workflow_name,
 
 logger.info('Starting {0}execution. Press Ctrl+C cancel'.format('dry ' if 
dry else ''))
 execution_thread.start()
+
+log_consumer = cli_logger.ModelLogConsumer(model_storage, 
workflow_runner.execution_id)
 try:
 while execution_thread.is_alive():
-# using join without a timeout blocks and ignores KeyboardInterrupt
-execution_thread.join(1)
+for log in log_consumer:
+execution_logging.load(log).log()
+
 except KeyboardInterrupt:
 _cancel_execution(workflow_runner, execution_thread, logger)
 
+for log in log_consumer:
+execution_logging.load(log).log()
+
 # raise any errors from the execution thread (note these are not workflow 
execution errors)
 execution_thread.raise_error_if_exists()
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/aaac6f60/aria/cli/commands/logs.py
--
diff --git a/aria/cli/commands/logs.py b/aria/cli/commands/logs.py
index fef..e87ee3b 100644
--- a/aria/cli/commands/logs.py
+++ b/aria/cli/commands/logs.py
@@ -12,13 +12,12 @@
 # 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 .. import utils
-from ..core import aria
+from ..logger import ModelLogConsumer
+from ..cli import aria
+from .. import execution_logging
 
 
 @aria.group(name='logs')
-@aria.options.verbose()
 def logs():
 """Show logs from workflow executions
 

[06/10] incubator-ariatosca git commit: added aria reset cli command

2017-04-19 Thread mxmrlv
added aria reset cli command


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/3bff159e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/3bff159e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/3bff159e

Branch: refs/heads/ARIA-138-Make-logging-more-informative
Commit: 3bff159e6c3db3d855281c478c6ceab52fee6ad5
Parents: 8b0e451
Author: Ran Ziv 
Authored: Tue Apr 18 16:39:51 2017 +0300
Committer: Ran Ziv 
Committed: Tue Apr 18 16:39:51 2017 +0300

--
 aria/cli/cli/aria.py  | 12 +++-
 aria/cli/cli/helptexts.py |  6 +++---
 aria/cli/commands/__init__.py |  1 +
 aria/cli/commands/reset.py| 40 ++
 aria/cli/commands/services.py |  2 +-
 aria/cli/config/config.py |  5 -
 aria/cli/env.py   | 13 +
 aria/cli/main.py  |  1 +
 8 files changed, 66 insertions(+), 14 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3bff159e/aria/cli/cli/aria.py
--
diff --git a/aria/cli/cli/aria.py b/aria/cli/cli/aria.py
index 31d6c9b..548be23 100644
--- a/aria/cli/cli/aria.py
+++ b/aria/cli/cli/aria.py
@@ -314,16 +314,10 @@ class Options(object):
 is_flag=True,
 help=helptexts.DRY_EXECUTION)
 
-self.init_hard_reset = click.option(
-'--hard',
+self.reset_config = click.option(
+'--reset-config',
 is_flag=True,
-help=helptexts.HARD_RESET)
-
-self.reset_context = click.option(
-'-r',
-'--reset-context',
-is_flag=True,
-help=helptexts.RESET_CONTEXT)
+help=helptexts.RESET_CONFIG)
 
 self.enable_colors = click.option(
 '--enable-colors',

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3bff159e/aria/cli/cli/helptexts.py
--
diff --git a/aria/cli/cli/helptexts.py b/aria/cli/cli/helptexts.py
index c50a172..f8b315c 100644
--- a/aria/cli/cli/helptexts.py
+++ b/aria/cli/cli/helptexts.py
@@ -26,8 +26,8 @@ INPUTS_PARAMS_USAGE = (
 SERVICE_TEMPLATE_PATH = "The path to the application's service template file"
 SERVICE_TEMPLATE_ID = "The unique identifier for the service template"
 
-RESET_CONTEXT = "Reset the working environment"
-HARD_RESET = "Hard reset the configuration, including coloring and loggers"
+FORCE_RESET = "Confirmation for resetting ARIA's working directory"
+RESET_CONFIG = "Reset ARIA's user configuration"
 ENABLE_COLORS = "Enable colors in logger (use --hard when working with" \
 " an initialized environment) [default: False]"
 
@@ -47,7 +47,7 @@ JSON_OUTPUT = "Output events in a consumable JSON format"
 
 SERVICE_ID = "The unique identifier for the service"
 EXECUTION_ID = "The unique identifier for the execution"
-IGNORE_RUNNING_NODES = "Delete the service even if it has running nodes"
+IGNORE_AVAILABLE_NODES = "Delete the service even if it has available nodes"
 
 NODE_NAME = "The node's name"
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3bff159e/aria/cli/commands/__init__.py
--
diff --git a/aria/cli/commands/__init__.py b/aria/cli/commands/__init__.py
index 791..a01a029 100644
--- a/aria/cli/commands/__init__.py
+++ b/aria/cli/commands/__init__.py
@@ -19,6 +19,7 @@ from . import (
 node_templates,
 nodes,
 plugins,
+reset,
 service_templates,
 services,
 workflows

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3bff159e/aria/cli/commands/reset.py
--
diff --git a/aria/cli/commands/reset.py b/aria/cli/commands/reset.py
new file mode 100644
index 000..775f555
--- /dev/null
+++ b/aria/cli/commands/reset.py
@@ -0,0 +1,40 @@
+# 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 

[jira] [Commented] (ARIA-138) CLI output verbosity levels

2017-04-19 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/ARIA-138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15974528#comment-15974528
 ] 

ASF subversion and git services commented on ARIA-138:
--

Commit aaac6f6018c878bdec6036dd2f9ab5e0662140c6 in incubator-ariatosca's branch 
refs/heads/ARIA-138-Make-logging-more-informative from [~Mxmrlv]
[ https://git-wip-us.apache.org/repos/asf?p=incubator-ariatosca.git;h=aaac6f6 ]

ARIA-138-Make-logging-more-informative


> CLI output verbosity levels
> ---
>
> Key: ARIA-138
> URL: https://issues.apache.org/jira/browse/ARIA-138
> Project: AriaTosca
>  Issue Type: Story
>Reporter: Maxim Orlov
>Assignee: Maxim Orlov
>
> The CLI should support the display of the following logging levels:
> default: execution logs: simple representation of executed operations
> -v  : execution logs: representation with time stamps and logging levels
> -vv: execution logs: retrieve the stacktrace of any failed operation.
> -vvv  : all configured loggers should be set to {{debug}} level; any CLI 
> errors should be logged and printed with their stack trace as well.
> (both the default and the first level of logging format should be 
> configurable). 
> Note that all of the operations logs should be saved in the storage. This 
> issue relates only to the way the logs are displayed in the CLI.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[09/10] incubator-ariatosca git commit: more review fixes

2017-04-19 Thread mxmrlv
more review 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/1cbd81b3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/1cbd81b3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/1cbd81b3

Branch: refs/heads/ARIA-138-Make-logging-more-informative
Commit: 1cbd81b3bb950dd589435af4bce6f0c1c1fc6411
Parents: c1f8eb6
Author: Ran Ziv 
Authored: Wed Apr 19 13:19:26 2017 +0300
Committer: Ran Ziv 
Committed: Wed Apr 19 13:19:26 2017 +0300

--
 aria/cli/commands/executions.py |  7 +-
 aria/cli/commands/node_templates.py |  6 +-
 aria/cli/commands/nodes.py  |  7 +-
 aria/cli/commands/plugins.py| 50 ++-
 aria/cli/commands/service_templates.py  | 38 -
 aria/cli/commands/services.py   |  5 +-
 aria/cli/commands/workflows.py  |  6 +-
 aria/cli/constants.py   | 18 
 aria/cli/core/aria.py   | 10 +--
 aria/cli/defaults.py| 20 +
 aria/cli/helptexts.py   |  2 +-
 aria/cli/logger.py  | 16 ++--
 aria/cli/service_template_utils.py  | 39 +++--
 aria/cli/table.py   | 90 +---
 aria/cli/utils.py   | 88 ---
 aria/modeling/service_common.py | 10 +--
 aria/orchestrator/exceptions.py |  7 ++
 aria/orchestrator/plugin.py | 23 +
 aria/orchestrator/workflow_runner.py|  2 +-
 aria/orchestrator/workflows/executor/celery.py  |  4 +-
 aria/orchestrator/workflows/executor/dry.py |  3 +-
 aria/orchestrator/workflows/executor/process.py |  3 +-
 aria/orchestrator/workflows/executor/thread.py  |  3 +-
 aria/utils/http.py  | 62 ++
 24 files changed, 258 insertions(+), 261 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1cbd81b3/aria/cli/commands/executions.py
--
diff --git a/aria/cli/commands/executions.py b/aria/cli/commands/executions.py
index cd12ead..adec56b 100644
--- a/aria/cli/commands/executions.py
+++ b/aria/cli/commands/executions.py
@@ -51,7 +51,7 @@ def show(execution_id, model_storage, logger):
 logger.info('Showing execution {0}'.format(execution_id))
 execution = model_storage.execution.get(execution_id)
 
-print_data(EXECUTION_COLUMNS, execution.to_dict(), 'Execution:', 
max_width=50)
+print_data(EXECUTION_COLUMNS, execution, 'Execution:', col_max_width=50)
 
 # print execution parameters
 logger.info('Execution Inputs:')
@@ -63,7 +63,6 @@ def show(execution_id, model_storage, logger):
 logger.info('\t{0}: \t{1}'.format(input_name, input_value))
 else:
 logger.info('\tNo inputs')
-logger.info('')
 
 
 @executions.command(name='list',
@@ -93,9 +92,9 @@ def list(service_name,
 logger.info('Listing all executions...')
 filters = {}
 
-executions_list = [e.to_dict() for e in model_storage.execution.list(
+executions_list = model_storage.execution.list(
 filters=filters,
-sort=utils.storage_sort_param(sort_by, descending))]
+sort=utils.storage_sort_param(sort_by, descending)).items
 
 print_data(EXECUTION_COLUMNS, executions_list, 'Executions:')
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1cbd81b3/aria/cli/commands/node_templates.py
--
diff --git a/aria/cli/commands/node_templates.py 
b/aria/cli/commands/node_templates.py
index c79e125..f0ca2c1 100644
--- a/aria/cli/commands/node_templates.py
+++ b/aria/cli/commands/node_templates.py
@@ -44,7 +44,7 @@ def show(node_template_id, model_storage, logger):
 logger.info('Showing node template {0}'.format(node_template_id))
 node_template = model_storage.node_template.get(node_template_id)
 
-print_data(NODE_TEMPLATE_COLUMNS, node_template.to_dict(), 'Node 
template:', max_width=50)
+print_data(NODE_TEMPLATE_COLUMNS, node_template, 'Node template:', 
col_max_width=50)
 
 # print node template properties
 logger.info('Node template properties:')
@@ -86,8 +86,8 @@ def list(service_template_name, sort_by, descending, 
model_storage, logger):
 logger.info('Listing all node templates...')
 filters = {}
 
-node_templates_list = [nt.to_dict() for nt in 
model_storage.node_template.list(
+node_templates_list = model_storage.node_template.list(
 filters=filters,
-

[01/10] incubator-ariatosca git commit: Requirments-arent-instantiated-properly [Forced Update!]

2017-04-19 Thread mxmrlv
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-138-Make-logging-more-informative 2f038276e -> aaac6f601 
(forced update)


Requirments-arent-instantiated-properly


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/8ced0f49
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/8ced0f49
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/8ced0f49

Branch: refs/heads/ARIA-138-Make-logging-more-informative
Commit: 8ced0f49e6439aff434b7c2c09f97e9be5d2b3ea
Parents: cf80675
Author: max-orlov 
Authored: Tue Apr 18 11:03:13 2017 +0300
Committer: max-orlov 
Committed: Tue Apr 18 11:03:13 2017 +0300

--
 aria/core.py| 20 
 aria/parser/consumption/__init__.py |  7 +--
 2 files changed, 17 insertions(+), 10 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8ced0f49/aria/core.py
--
diff --git a/aria/core.py b/aria/core.py
index 365f39c..f5e2025 100644
--- a/aria/core.py
+++ b/aria/core.py
@@ -75,14 +75,18 @@ class Core(object):
 service = service_template.instantiate(None, self.model_storage, 
inputs=inputs)
 
 self.model_storage._all_api_kwargs['session'].flush()
-consumption.ConsumerChain(
-context,
-(
-consumption.FindHosts,
-consumption.ConfigureOperations
-)).consume()
-if context.validation.dump_issues():
-raise exceptions.InstantiationError('Failed to instantiate service 
template')
+
+with self.model_storage._all_api_kwargs['session'].no_autoflush:
+consumption.ConsumerChain(
+context,
+(
+consumption.SatisfyRequirements,
+consumption.ValidateCapabilities,
+consumption.FindHosts,
+consumption.ConfigureOperations
+)).consume()
+if context.validation.dump_issues():
+raise exceptions.InstantiationError('Failed to instantiate 
service template')
 
 # If the user didn't enter a name for this service, we'll want to auto 
generate it.
 # But how will we ensure a unique but simple name? We'll append the 
services' unique id

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8ced0f49/aria/parser/consumption/__init__.py
--
diff --git a/aria/parser/consumption/__init__.py 
b/aria/parser/consumption/__init__.py
index ff1b376..8e565eb 100644
--- a/aria/parser/consumption/__init__.py
+++ b/aria/parser/consumption/__init__.py
@@ -20,7 +20,7 @@ from .style import Style
 from .consumer import Consumer, ConsumerChain
 from .presentation import Read
 from .validation import Validate
-from .modeling import ServiceTemplate, Types, ServiceInstance, FindHosts, 
ConfigureOperations
+from .modeling import ServiceTemplate, Types, ServiceInstance, FindHosts, 
ConfigureOperations, SatisfyRequirements, ValidateCapabilities
 from .inputs import Inputs
 
 __all__ = (
@@ -34,4 +34,7 @@ __all__ = (
 'ServiceTemplate',
 'Types',
 'ServiceInstance',
-'Inputs')
+'Inputs',
+'SatisfyRequirements',
+'ValidateCapabilities'
+)
\ No newline at end of file



[04/10] incubator-ariatosca git commit: fix failing ssh tests

2017-04-19 Thread mxmrlv
fix failing ssh tests


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/1bfefd17
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/1bfefd17
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/1bfefd17

Branch: refs/heads/ARIA-138-Make-logging-more-informative
Commit: 1bfefd17890c7c65c12f0a943e60dc714ac95adf
Parents: 38f9aba
Author: Ran Ziv 
Authored: Tue Apr 18 15:38:41 2017 +0300
Committer: Ran Ziv 
Committed: Tue Apr 18 15:38:41 2017 +0300

--
 tests/mock/models.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1bfefd17/tests/mock/models.py
--
diff --git a/tests/mock/models.py b/tests/mock/models.py
index 38c2b28..8a9273b 100644
--- a/tests/mock/models.py
+++ b/tests/mock/models.py
@@ -190,7 +190,8 @@ def create_interface(service, interface_name, 
operation_name, operation_kwargs=N
 if operation_kwargs and operation_kwargs.get('inputs'):
 operation_kwargs['inputs'] = dict(
 (input_name, models.Parameter.wrap(input_name, input_value))
-for input_name, input_value in 
operation_kwargs['inputs'].iteritems())
+for input_name, input_value in 
operation_kwargs['inputs'].iteritems()
+if input_value is not None)
 
 operation = models.Operation(
 name=operation_name,



[07/10] incubator-ariatosca git commit: reviewed helptexts module; renamed cli.cli package to cli.core

2017-04-19 Thread mxmrlv
reviewed helptexts module; renamed cli.cli package to cli.core


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/79f5d78e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/79f5d78e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/79f5d78e

Branch: refs/heads/ARIA-138-Make-logging-more-informative
Commit: 79f5d78ebe31327e7635ae75551ba636ac5fd1dc
Parents: 3bff159
Author: Ran Ziv 
Authored: Tue Apr 18 16:55:52 2017 +0300
Committer: Ran Ziv 
Committed: Tue Apr 18 16:55:52 2017 +0300

--
 aria/cli/cli/__init__.py   |  14 -
 aria/cli/cli/aria.py   | 439 
 aria/cli/cli/helptexts.py  |  57 
 aria/cli/commands/executions.py|   5 +-
 aria/cli/commands/logs.py  |   2 +-
 aria/cli/commands/node_templates.py|   4 +-
 aria/cli/commands/nodes.py |   2 +-
 aria/cli/commands/plugins.py   |   4 +-
 aria/cli/commands/reset.py |   4 +-
 aria/cli/commands/service_templates.py |   2 +-
 aria/cli/commands/services.py  |   5 +-
 aria/cli/commands/workflows.py |   2 +-
 aria/cli/core/__init__.py  |  14 +
 aria/cli/core/aria.py  | 429 +++
 aria/cli/helptexts.py  |  49 
 aria/cli/main.py   |   2 +-
 16 files changed, 509 insertions(+), 525 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/79f5d78e/aria/cli/cli/__init__.py
--
diff --git a/aria/cli/cli/__init__.py b/aria/cli/cli/__init__.py
deleted file mode 100644
index ae1e83e..000
--- a/aria/cli/cli/__init__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/79f5d78e/aria/cli/cli/aria.py
--
diff --git a/aria/cli/cli/aria.py b/aria/cli/cli/aria.py
deleted file mode 100644
index 548be23..000
--- a/aria/cli/cli/aria.py
+++ /dev/null
@@ -1,439 +0,0 @@
-# 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.
-
-
-import os
-import sys
-import difflib
-import StringIO
-import traceback
-from functools import wraps
-
-import click
-
-from ..env import (
-env,
-logger
-)
-from ..cli import helptexts
-from ..inputs import inputs_to_dict
-from ..constants import DEFAULT_SERVICE_TEMPLATE_FILENAME
-from ...utils.exceptions import get_exception_as_string
-from ... import __version__
-
-
-CLICK_CONTEXT_SETTINGS = dict(
-help_option_names=['-h', '--help'],
-token_normalize_func=lambda param: param.lower())
-
-
-class MutuallyExclusiveOption(click.Option):
-"""Makes options mutually exclusive. The option must pass a `cls` argument
-with this class name and a `mutually_exclusive` argument with a list of
-argument names it is mutually exclusive with.
-
-NOTE: All mutually exclusive options must use this. It's not enough to
-use it in just one of the options.
-"""
-
-def __init__(self, *args, **kwargs):
-self.mutually_exclusive = set(kwargs.pop('mutually_exclusive', []))
-

[GitHub] incubator-ariatosca pull request #97: Aria 48 aria cli

2017-04-19 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/97#discussion_r112176010
  
--- Diff: aria/cli/commands/service_templates.py ---
@@ -0,0 +1,216 @@
+# 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.
+
+
+import os
+import json
+
+from .. import utils
+from .. import csar
+from .. import service_template_utils
+from ..cli import aria
+from ..table import print_data
+from ..exceptions import AriaCliError
+from ..utils import handle_storage_exception
+from ...core import Core
+from ...exceptions import AriaException
+from ...storage import exceptions as storage_exceptions
+
+
+DESCRIPTION_LIMIT = 20
+SERVICE_TEMPLATE_COLUMNS = \
+['id', 'name', 'main_file_name', 'created_at', 'updated_at']
+
+
+@aria.group(name='service-templates')
+@aria.options.verbose()
+def service_templates():
+"""Handle service templates on the manager
+"""
+pass
+
+
+@service_templates.command(name='show',
+   short_help='Show service template information')
+@aria.argument('service-template-id')
+@aria.options.verbose()
+@aria.pass_model_storage
+@aria.pass_logger
+def show(service_template_id, model_storage, logger):
+"""Show information for a specific service templates
+
+`SERVICE_TEMPLATE_ID` is the id of the service template to show 
information on.
+"""
+logger.info('Showing service template 
{0}...'.format(service_template_id))
+service_template = 
model_storage.service_template.get(service_template_id)
+services = [d.to_dict() for d in service_template.services]
+service_template_dict = service_template.to_dict()
+service_template_dict['#services'] = len(services)
+columns = SERVICE_TEMPLATE_COLUMNS + ['#services']
--- End diff --

decided not to - it would require listing all services for all service 
templates


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[01/12] incubator-ariatosca git commit: Requirments-arent-instantiated-properly [Forced Update!]

2017-04-19 Thread avia
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/cli-tests 56a4767e3 -> ed07f9f27 (forced update)


Requirments-arent-instantiated-properly


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/8ced0f49
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/8ced0f49
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/8ced0f49

Branch: refs/heads/cli-tests
Commit: 8ced0f49e6439aff434b7c2c09f97e9be5d2b3ea
Parents: cf80675
Author: max-orlov 
Authored: Tue Apr 18 11:03:13 2017 +0300
Committer: max-orlov 
Committed: Tue Apr 18 11:03:13 2017 +0300

--
 aria/core.py| 20 
 aria/parser/consumption/__init__.py |  7 +--
 2 files changed, 17 insertions(+), 10 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8ced0f49/aria/core.py
--
diff --git a/aria/core.py b/aria/core.py
index 365f39c..f5e2025 100644
--- a/aria/core.py
+++ b/aria/core.py
@@ -75,14 +75,18 @@ class Core(object):
 service = service_template.instantiate(None, self.model_storage, 
inputs=inputs)
 
 self.model_storage._all_api_kwargs['session'].flush()
-consumption.ConsumerChain(
-context,
-(
-consumption.FindHosts,
-consumption.ConfigureOperations
-)).consume()
-if context.validation.dump_issues():
-raise exceptions.InstantiationError('Failed to instantiate service 
template')
+
+with self.model_storage._all_api_kwargs['session'].no_autoflush:
+consumption.ConsumerChain(
+context,
+(
+consumption.SatisfyRequirements,
+consumption.ValidateCapabilities,
+consumption.FindHosts,
+consumption.ConfigureOperations
+)).consume()
+if context.validation.dump_issues():
+raise exceptions.InstantiationError('Failed to instantiate 
service template')
 
 # If the user didn't enter a name for this service, we'll want to auto 
generate it.
 # But how will we ensure a unique but simple name? We'll append the 
services' unique id

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8ced0f49/aria/parser/consumption/__init__.py
--
diff --git a/aria/parser/consumption/__init__.py 
b/aria/parser/consumption/__init__.py
index ff1b376..8e565eb 100644
--- a/aria/parser/consumption/__init__.py
+++ b/aria/parser/consumption/__init__.py
@@ -20,7 +20,7 @@ from .style import Style
 from .consumer import Consumer, ConsumerChain
 from .presentation import Read
 from .validation import Validate
-from .modeling import ServiceTemplate, Types, ServiceInstance, FindHosts, 
ConfigureOperations
+from .modeling import ServiceTemplate, Types, ServiceInstance, FindHosts, 
ConfigureOperations, SatisfyRequirements, ValidateCapabilities
 from .inputs import Inputs
 
 __all__ = (
@@ -34,4 +34,7 @@ __all__ = (
 'ServiceTemplate',
 'Types',
 'ServiceInstance',
-'Inputs')
+'Inputs',
+'SatisfyRequirements',
+'ValidateCapabilities'
+)
\ No newline at end of file



[05/12] incubator-ariatosca git commit: fixed ssh tests

2017-04-19 Thread avia
fixed ssh tests


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/8b0e451a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/8b0e451a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/8b0e451a

Branch: refs/heads/cli-tests
Commit: 8b0e451ab3cb5dbb7dbab3c53aac6730c3ea3d64
Parents: 1bfefd1
Author: Ran Ziv 
Authored: Tue Apr 18 16:05:24 2017 +0300
Committer: Ran Ziv 
Committed: Tue Apr 18 16:05:24 2017 +0300

--
 tests/orchestrator/execution_plugin/test_ssh.py | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/8b0e451a/tests/orchestrator/execution_plugin/test_ssh.py
--
diff --git a/tests/orchestrator/execution_plugin/test_ssh.py 
b/tests/orchestrator/execution_plugin/test_ssh.py
index dcfd88e..a75d59a 100644
--- a/tests/orchestrator/execution_plugin/test_ssh.py
+++ b/tests/orchestrator/execution_plugin/test_ssh.py
@@ -222,11 +222,13 @@ class TestWithActualSSHServer(object):
 'fabric_env': _FABRIC_ENV,
 'process': process,
 'use_sudo': use_sudo,
-'hide_output': hide_output,
 'custom_env_var': custom_input,
 'test_operation': '',
-'commands': commands
 }
+if hide_output:
+inputs['hide_output'] = hide_output
+if commands:
+inputs['commands'] = commands
 interface = mock.models.create_interface(
 node.service,
 'test',



[02/12] incubator-ariatosca git commit: Implementation-less-relationship-tasks-are-being-created

2017-04-19 Thread avia
Implementation-less-relationship-tasks-are-being-created


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/9f9dc3ec
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/9f9dc3ec
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/9f9dc3ec

Branch: refs/heads/cli-tests
Commit: 9f9dc3ec9f2980e296a293bf7793263eca01c308
Parents: 8ced0f4
Author: max-orlov 
Authored: Tue Apr 18 10:56:34 2017 +0300
Committer: max-orlov 
Committed: Tue Apr 18 11:16:34 2017 +0300

--
 aria/orchestrator/workflows/builtin/utils.py | 28 +++
 1 file changed, 14 insertions(+), 14 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9f9dc3ec/aria/orchestrator/workflows/builtin/utils.py
--
diff --git a/aria/orchestrator/workflows/builtin/utils.py 
b/aria/orchestrator/workflows/builtin/utils.py
index 722c618..2254d13 100644
--- a/aria/orchestrator/workflows/builtin/utils.py
+++ b/aria/orchestrator/workflows/builtin/utils.py
@@ -73,13 +73,13 @@ def relationship_tasks(relationship, interface_name, 
source_operation_name=None,
 try:
 if _is_empty_task(relationship, interface_name, 
source_operation_name):
 operations.append(StubTask())
-
-operations.append(
-OperationTask.for_relationship(relationship=relationship,
-   interface_name=interface_name,
-   
operation_name=source_operation_name,
-   **kwargs)
-)
+else:
+operations.append(
+OperationTask.for_relationship(relationship=relationship,
+   
interface_name=interface_name,
+   
operation_name=source_operation_name,
+   **kwargs)
+)
 except exceptions.OperationNotFoundException:
 # We will skip relationships which do not have the operation
 pass
@@ -87,13 +87,13 @@ def relationship_tasks(relationship, interface_name, 
source_operation_name=None,
 try:
 if _is_empty_task(relationship, interface_name, 
target_operation_name):
 operations.append(StubTask())
-
-operations.append(
-OperationTask.for_relationship(relationship=relationship,
-   interface_name=interface_name,
-   
operation_name=target_operation_name,
-   **kwargs)
-)
+else:
+operations.append(
+OperationTask.for_relationship(relationship=relationship,
+   
interface_name=interface_name,
+   
operation_name=target_operation_name,
+   **kwargs)
+)
 except exceptions.OperationNotFoundException:
 # We will skip relationships which do not have the operation
 pass



[09/12] incubator-ariatosca git commit: more review fixes

2017-04-19 Thread avia
more review 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/1cbd81b3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/1cbd81b3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/1cbd81b3

Branch: refs/heads/cli-tests
Commit: 1cbd81b3bb950dd589435af4bce6f0c1c1fc6411
Parents: c1f8eb6
Author: Ran Ziv 
Authored: Wed Apr 19 13:19:26 2017 +0300
Committer: Ran Ziv 
Committed: Wed Apr 19 13:19:26 2017 +0300

--
 aria/cli/commands/executions.py |  7 +-
 aria/cli/commands/node_templates.py |  6 +-
 aria/cli/commands/nodes.py  |  7 +-
 aria/cli/commands/plugins.py| 50 ++-
 aria/cli/commands/service_templates.py  | 38 -
 aria/cli/commands/services.py   |  5 +-
 aria/cli/commands/workflows.py  |  6 +-
 aria/cli/constants.py   | 18 
 aria/cli/core/aria.py   | 10 +--
 aria/cli/defaults.py| 20 +
 aria/cli/helptexts.py   |  2 +-
 aria/cli/logger.py  | 16 ++--
 aria/cli/service_template_utils.py  | 39 +++--
 aria/cli/table.py   | 90 +---
 aria/cli/utils.py   | 88 ---
 aria/modeling/service_common.py | 10 +--
 aria/orchestrator/exceptions.py |  7 ++
 aria/orchestrator/plugin.py | 23 +
 aria/orchestrator/workflow_runner.py|  2 +-
 aria/orchestrator/workflows/executor/celery.py  |  4 +-
 aria/orchestrator/workflows/executor/dry.py |  3 +-
 aria/orchestrator/workflows/executor/process.py |  3 +-
 aria/orchestrator/workflows/executor/thread.py  |  3 +-
 aria/utils/http.py  | 62 ++
 24 files changed, 258 insertions(+), 261 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1cbd81b3/aria/cli/commands/executions.py
--
diff --git a/aria/cli/commands/executions.py b/aria/cli/commands/executions.py
index cd12ead..adec56b 100644
--- a/aria/cli/commands/executions.py
+++ b/aria/cli/commands/executions.py
@@ -51,7 +51,7 @@ def show(execution_id, model_storage, logger):
 logger.info('Showing execution {0}'.format(execution_id))
 execution = model_storage.execution.get(execution_id)
 
-print_data(EXECUTION_COLUMNS, execution.to_dict(), 'Execution:', 
max_width=50)
+print_data(EXECUTION_COLUMNS, execution, 'Execution:', col_max_width=50)
 
 # print execution parameters
 logger.info('Execution Inputs:')
@@ -63,7 +63,6 @@ def show(execution_id, model_storage, logger):
 logger.info('\t{0}: \t{1}'.format(input_name, input_value))
 else:
 logger.info('\tNo inputs')
-logger.info('')
 
 
 @executions.command(name='list',
@@ -93,9 +92,9 @@ def list(service_name,
 logger.info('Listing all executions...')
 filters = {}
 
-executions_list = [e.to_dict() for e in model_storage.execution.list(
+executions_list = model_storage.execution.list(
 filters=filters,
-sort=utils.storage_sort_param(sort_by, descending))]
+sort=utils.storage_sort_param(sort_by, descending)).items
 
 print_data(EXECUTION_COLUMNS, executions_list, 'Executions:')
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1cbd81b3/aria/cli/commands/node_templates.py
--
diff --git a/aria/cli/commands/node_templates.py 
b/aria/cli/commands/node_templates.py
index c79e125..f0ca2c1 100644
--- a/aria/cli/commands/node_templates.py
+++ b/aria/cli/commands/node_templates.py
@@ -44,7 +44,7 @@ def show(node_template_id, model_storage, logger):
 logger.info('Showing node template {0}'.format(node_template_id))
 node_template = model_storage.node_template.get(node_template_id)
 
-print_data(NODE_TEMPLATE_COLUMNS, node_template.to_dict(), 'Node 
template:', max_width=50)
+print_data(NODE_TEMPLATE_COLUMNS, node_template, 'Node template:', 
col_max_width=50)
 
 # print node template properties
 logger.info('Node template properties:')
@@ -86,8 +86,8 @@ def list(service_template_name, sort_by, descending, 
model_storage, logger):
 logger.info('Listing all node templates...')
 filters = {}
 
-node_templates_list = [nt.to_dict() for nt in 
model_storage.node_template.list(
+node_templates_list = model_storage.node_template.list(
 filters=filters,
-

[08/12] incubator-ariatosca git commit: various review fixes

2017-04-19 Thread avia
various review 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/c1f8eb6a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/c1f8eb6a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/c1f8eb6a

Branch: refs/heads/cli-tests
Commit: c1f8eb6a924f93656dee6d82ded2dc83ed6b4cc9
Parents: 79f5d78
Author: Ran Ziv 
Authored: Tue Apr 18 18:44:34 2017 +0300
Committer: Ran Ziv 
Committed: Tue Apr 18 18:44:34 2017 +0300

--
 aria/cli/commands/node_templates.py|  3 ---
 aria/cli/commands/plugins.py   |  4 ++--
 aria/cli/commands/service_templates.py | 21 +
 aria/cli/commands/services.py  | 29 ++---
 aria/cli/core/aria.py  |  4 ++--
 aria/cli/inputs.py |  2 +-
 aria/cli/utils.py  | 18 --
 aria/core.py   | 19 ---
 aria/modeling/exceptions.py| 19 +--
 aria/modeling/service_template.py  |  3 ++-
 aria/orchestrator/workflow_runner.py   | 14 +++---
 tox.ini|  2 +-
 12 files changed, 63 insertions(+), 75 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c1f8eb6a/aria/cli/commands/node_templates.py
--
diff --git a/aria/cli/commands/node_templates.py 
b/aria/cli/commands/node_templates.py
index b63b630..c79e125 100644
--- a/aria/cli/commands/node_templates.py
+++ b/aria/cli/commands/node_templates.py
@@ -41,10 +41,7 @@ def show(node_template_id, model_storage, logger):
 
 `NODE_TEMPLATE_ID` is the node id to get information on.
 """
-# logger.info('Showing node template {0} for service template {1}'.format(
-# node_template_id, service_template_name))
 logger.info('Showing node template {0}'.format(node_template_id))
-#TODO get node template of a specific service template instead?
 node_template = model_storage.node_template.get(node_template_id)
 
 print_data(NODE_TEMPLATE_COLUMNS, node_template.to_dict(), 'Node 
template:', max_width=50)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c1f8eb6a/aria/cli/commands/plugins.py
--
diff --git a/aria/cli/commands/plugins.py b/aria/cli/commands/plugins.py
index 680284f..41a272e 100644
--- a/aria/cli/commands/plugins.py
+++ b/aria/cli/commands/plugins.py
@@ -15,10 +15,10 @@
 
 import zipfile
 
+from .. import utils
 from ..core import aria
 from ..exceptions import AriaCliError
 from ..table import print_data
-from ..utils import storage_sort_param
 
 
 PLUGIN_COLUMNS = ['id', 'package_name', 'package_version', 
'supported_platform',
@@ -129,5 +129,5 @@ def list(sort_by, descending, model_storage, logger):
 """
 logger.info('Listing all plugins...')
 plugins_list = [p.to_dict() for p in model_storage.plugin.list(
-sort=storage_sort_param(sort_by, descending))]
+sort=utils.storage_sort_param(sort_by, descending))]
 print_data(PLUGIN_COLUMNS, plugins_list, 'Plugins:')

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c1f8eb6a/aria/cli/commands/service_templates.py
--
diff --git a/aria/cli/commands/service_templates.py 
b/aria/cli/commands/service_templates.py
index 93dc188..2ef37c0 100644
--- a/aria/cli/commands/service_templates.py
+++ b/aria/cli/commands/service_templates.py
@@ -16,15 +16,12 @@
 
 import os
 
-from .. import utils
 from .. import csar
 from .. import service_template_utils
+from .. import utils
 from ..core import aria
 from ..table import print_data
-from ..exceptions import AriaCliError
-from ..utils import handle_storage_exception
 from ...core import Core
-from ...exceptions import AriaException
 from ...storage import exceptions as storage_exceptions
 
 
@@ -124,7 +121,8 @@ def store(service_template_path, service_template_name, 
service_template_filenam
  os.path.dirname(service_template_path),
  service_template_name)
 except storage_exceptions.StorageError as e:
-handle_storage_exception(e, 'service template', service_template_name)
+utils.check_overriding_storage_exceptions(e, 'service template', 
service_template_name)
+raise
 logger.info('Service template {0} stored'.format(service_template_name))
 
 
@@ -143,10 +141,7 @@ def delete(service_template_name, model_storage, 
resource_storage, plugin_manage
 logger.info('Deleting service template 

[06/12] incubator-ariatosca git commit: added aria reset cli command

2017-04-19 Thread avia
added aria reset cli command


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/3bff159e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/3bff159e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/3bff159e

Branch: refs/heads/cli-tests
Commit: 3bff159e6c3db3d855281c478c6ceab52fee6ad5
Parents: 8b0e451
Author: Ran Ziv 
Authored: Tue Apr 18 16:39:51 2017 +0300
Committer: Ran Ziv 
Committed: Tue Apr 18 16:39:51 2017 +0300

--
 aria/cli/cli/aria.py  | 12 +++-
 aria/cli/cli/helptexts.py |  6 +++---
 aria/cli/commands/__init__.py |  1 +
 aria/cli/commands/reset.py| 40 ++
 aria/cli/commands/services.py |  2 +-
 aria/cli/config/config.py |  5 -
 aria/cli/env.py   | 13 +
 aria/cli/main.py  |  1 +
 8 files changed, 66 insertions(+), 14 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3bff159e/aria/cli/cli/aria.py
--
diff --git a/aria/cli/cli/aria.py b/aria/cli/cli/aria.py
index 31d6c9b..548be23 100644
--- a/aria/cli/cli/aria.py
+++ b/aria/cli/cli/aria.py
@@ -314,16 +314,10 @@ class Options(object):
 is_flag=True,
 help=helptexts.DRY_EXECUTION)
 
-self.init_hard_reset = click.option(
-'--hard',
+self.reset_config = click.option(
+'--reset-config',
 is_flag=True,
-help=helptexts.HARD_RESET)
-
-self.reset_context = click.option(
-'-r',
-'--reset-context',
-is_flag=True,
-help=helptexts.RESET_CONTEXT)
+help=helptexts.RESET_CONFIG)
 
 self.enable_colors = click.option(
 '--enable-colors',

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3bff159e/aria/cli/cli/helptexts.py
--
diff --git a/aria/cli/cli/helptexts.py b/aria/cli/cli/helptexts.py
index c50a172..f8b315c 100644
--- a/aria/cli/cli/helptexts.py
+++ b/aria/cli/cli/helptexts.py
@@ -26,8 +26,8 @@ INPUTS_PARAMS_USAGE = (
 SERVICE_TEMPLATE_PATH = "The path to the application's service template file"
 SERVICE_TEMPLATE_ID = "The unique identifier for the service template"
 
-RESET_CONTEXT = "Reset the working environment"
-HARD_RESET = "Hard reset the configuration, including coloring and loggers"
+FORCE_RESET = "Confirmation for resetting ARIA's working directory"
+RESET_CONFIG = "Reset ARIA's user configuration"
 ENABLE_COLORS = "Enable colors in logger (use --hard when working with" \
 " an initialized environment) [default: False]"
 
@@ -47,7 +47,7 @@ JSON_OUTPUT = "Output events in a consumable JSON format"
 
 SERVICE_ID = "The unique identifier for the service"
 EXECUTION_ID = "The unique identifier for the execution"
-IGNORE_RUNNING_NODES = "Delete the service even if it has running nodes"
+IGNORE_AVAILABLE_NODES = "Delete the service even if it has available nodes"
 
 NODE_NAME = "The node's name"
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3bff159e/aria/cli/commands/__init__.py
--
diff --git a/aria/cli/commands/__init__.py b/aria/cli/commands/__init__.py
index 791..a01a029 100644
--- a/aria/cli/commands/__init__.py
+++ b/aria/cli/commands/__init__.py
@@ -19,6 +19,7 @@ from . import (
 node_templates,
 nodes,
 plugins,
+reset,
 service_templates,
 services,
 workflows

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3bff159e/aria/cli/commands/reset.py
--
diff --git a/aria/cli/commands/reset.py b/aria/cli/commands/reset.py
new file mode 100644
index 000..775f555
--- /dev/null
+++ b/aria/cli/commands/reset.py
@@ -0,0 +1,40 @@
+# 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
+# 

[07/12] incubator-ariatosca git commit: reviewed helptexts module; renamed cli.cli package to cli.core

2017-04-19 Thread avia
reviewed helptexts module; renamed cli.cli package to cli.core


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/79f5d78e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/79f5d78e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/79f5d78e

Branch: refs/heads/cli-tests
Commit: 79f5d78ebe31327e7635ae75551ba636ac5fd1dc
Parents: 3bff159
Author: Ran Ziv 
Authored: Tue Apr 18 16:55:52 2017 +0300
Committer: Ran Ziv 
Committed: Tue Apr 18 16:55:52 2017 +0300

--
 aria/cli/cli/__init__.py   |  14 -
 aria/cli/cli/aria.py   | 439 
 aria/cli/cli/helptexts.py  |  57 
 aria/cli/commands/executions.py|   5 +-
 aria/cli/commands/logs.py  |   2 +-
 aria/cli/commands/node_templates.py|   4 +-
 aria/cli/commands/nodes.py |   2 +-
 aria/cli/commands/plugins.py   |   4 +-
 aria/cli/commands/reset.py |   4 +-
 aria/cli/commands/service_templates.py |   2 +-
 aria/cli/commands/services.py  |   5 +-
 aria/cli/commands/workflows.py |   2 +-
 aria/cli/core/__init__.py  |  14 +
 aria/cli/core/aria.py  | 429 +++
 aria/cli/helptexts.py  |  49 
 aria/cli/main.py   |   2 +-
 16 files changed, 509 insertions(+), 525 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/79f5d78e/aria/cli/cli/__init__.py
--
diff --git a/aria/cli/cli/__init__.py b/aria/cli/cli/__init__.py
deleted file mode 100644
index ae1e83e..000
--- a/aria/cli/cli/__init__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/79f5d78e/aria/cli/cli/aria.py
--
diff --git a/aria/cli/cli/aria.py b/aria/cli/cli/aria.py
deleted file mode 100644
index 548be23..000
--- a/aria/cli/cli/aria.py
+++ /dev/null
@@ -1,439 +0,0 @@
-# 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.
-
-
-import os
-import sys
-import difflib
-import StringIO
-import traceback
-from functools import wraps
-
-import click
-
-from ..env import (
-env,
-logger
-)
-from ..cli import helptexts
-from ..inputs import inputs_to_dict
-from ..constants import DEFAULT_SERVICE_TEMPLATE_FILENAME
-from ...utils.exceptions import get_exception_as_string
-from ... import __version__
-
-
-CLICK_CONTEXT_SETTINGS = dict(
-help_option_names=['-h', '--help'],
-token_normalize_func=lambda param: param.lower())
-
-
-class MutuallyExclusiveOption(click.Option):
-"""Makes options mutually exclusive. The option must pass a `cls` argument
-with this class name and a `mutually_exclusive` argument with a list of
-argument names it is mutually exclusive with.
-
-NOTE: All mutually exclusive options must use this. It's not enough to
-use it in just one of the options.
-"""
-
-def __init__(self, *args, **kwargs):
-self.mutually_exclusive = set(kwargs.pop('mutually_exclusive', []))
-self.mutuality_error_message = 

[12/12] incubator-ariatosca git commit: Refactor cli tests framework

2017-04-19 Thread avia
Refactor cli tests framework


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/ed07f9f2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/ed07f9f2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/ed07f9f2

Branch: refs/heads/cli-tests
Commit: ed07f9f278c4752641aceac71c5988fc2e1a06d2
Parents: 9169cb3
Author: Avia Efrat 
Authored: Wed Apr 19 14:17:27 2017 +0300
Committer: Avia Efrat 
Committed: Wed Apr 19 14:20:57 2017 +0300

--
 tests/cli/test_logs.py  |  23 --
 tests/cli/test_node_templates.py|  56 --
 tests/cli/test_nodes.py |  21 +++--
 tests/cli/test_service_templates.py | 124 +-
 tests/cli/test_services.py  |  93 +++---
 tests/cli/utils.py  | 128 ---
 tests/mock/models.py|  69 +
 tests/mock/topology.py  |   8 +-
 tests/modeling/test_models.py   |   5 +-
 9 files changed, 258 insertions(+), 269 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ed07f9f2/tests/cli/test_logs.py
--
diff --git a/tests/cli/test_logs.py b/tests/cli/test_logs.py
deleted file mode 100644
index ad0c4f1..000
--- a/tests/cli/test_logs.py
+++ /dev/null
@@ -1,23 +0,0 @@
-from aria.cli.env import _Environment
-from tests.cli.base_test import TestCliBase, mock_storage
-
-
-class TestLogsList(TestCliBase):
-
-def test_existing_logs(self, monkeypatch, mock_storage):
-monkeypatch.setattr(_Environment, 'model_storage', mock_storage)
-self.invoke('logs list exec_id')
-
-assert 'Listing logs for execution id exec_id' in 
self.logger_output_string
-assert 'log_msg' in self.logger_output_string
-assert 'No logs' not in self.logger_output_string
-
-def test_no_logs(self, monkeypatch, mock_object):
-m = mock_object
-m.log.list.return_value = []
-monkeypatch.setattr(_Environment, 'model_storage', m)
-self.invoke('logs list exec_id')
-
-assert 'Listing logs for execution id exec_id' in 
self.logger_output_string
-assert 'log_msg' not in self.logger_output_string
-assert 'No logs' in self.logger_output_string

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/ed07f9f2/tests/cli/test_node_templates.py
--
diff --git a/tests/cli/test_node_templates.py b/tests/cli/test_node_templates.py
index f0ad539..931c0a4 100644
--- a/tests/cli/test_node_templates.py
+++ b/tests/cli/test_node_templates.py
@@ -1,57 +1,66 @@
-from mock import ANY
+from mock import ANY, MagicMock
 import pytest
 
 from aria.cli.env import _Environment
 from tests.cli.base_test import TestCliBase, mock_storage  # pylint: 
disable=unused-import
+from tests.mock.models import create_node_template_with_dependencies, 
NODE_NAME, \
+SERVICE_TEMPLATE_NAME, NODE_TEMPLATE_NAME
 
 
 class TestNodeTemplatesShow(TestCliBase):
 
-def test_no_properties_no_nodes(self, monkeypatch, mock_storage):
-
+def test_header_strings(self, monkeypatch, mock_storage):
 monkeypatch.setattr(_Environment, 'model_storage', mock_storage)
 self.invoke('node_templates show 1')
 assert 'Showing node template 1' in self.logger_output_string
 assert 'Node template properties:' in self.logger_output_string
+assert 'Nodes:' in self.logger_output_string
+
+def test_no_properties_no_nodes(self, monkeypatch, mock_storage):
+
+monkeypatch.setattr(_Environment, 'model_storage', mock_storage)
+self.invoke('node_templates show 1')
+
 assert 'No properties' in self.logger_output_string
 assert 'prop1' not in self.logger_output_string
 assert 'value1' not in self.logger_output_string
 assert 'No nodes' in self.logger_output_string
-assert 'node1' not in self.logger_output_string
+assert NODE_NAME not in self.logger_output_string
 
 def test_one_property_no_nodes(self, monkeypatch, mock_storage):
 
 monkeypatch.setattr(_Environment, 'model_storage', mock_storage)
+m = 
MagicMock(return_value=create_node_template_with_dependencies(include_property=True))
+monkeypatch.setattr(mock_storage.node_template, 'get', m)
 self.invoke('node_templates show 2')
-assert 'Showing node template 2' in self.logger_output_string
-assert 'Node template properties:' in self.logger_output_string
 assert 'No properties' not in self.logger_output_string
 assert 'prop1' in 

[11/12] incubator-ariatosca git commit: Add tests for logs list

2017-04-19 Thread avia
Add tests for logs list


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/9169cb35
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/9169cb35
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/9169cb35

Branch: refs/heads/cli-tests
Commit: 9169cb357adb12948f6a7ce5c97f833addd7dae8
Parents: a39e7d1
Author: Avia Efrat 
Authored: Tue Apr 18 12:28:37 2017 +0300
Committer: Avia Efrat 
Committed: Wed Apr 19 14:18:19 2017 +0300

--
 aria/cli/commands/logs.py |  2 +-
 tests/cli/test_logs.py| 23 +++
 tests/cli/utils.py| 10 ++
 tests/mock/models.py  |  9 +
 4 files changed, 43 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9169cb35/aria/cli/commands/logs.py
--
diff --git a/aria/cli/commands/logs.py b/aria/cli/commands/logs.py
index fef..6c83347 100644
--- a/aria/cli/commands/logs.py
+++ b/aria/cli/commands/logs.py
@@ -42,7 +42,7 @@ def list(execution_id,
 # TODO: print logs nicely
 if logs_list:
 for log in logs_list:
-print log
+logger.info(log)
 else:
 logger.info('\tNo logs')
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9169cb35/tests/cli/test_logs.py
--
diff --git a/tests/cli/test_logs.py b/tests/cli/test_logs.py
new file mode 100644
index 000..ad0c4f1
--- /dev/null
+++ b/tests/cli/test_logs.py
@@ -0,0 +1,23 @@
+from aria.cli.env import _Environment
+from tests.cli.base_test import TestCliBase, mock_storage
+
+
+class TestLogsList(TestCliBase):
+
+def test_existing_logs(self, monkeypatch, mock_storage):
+monkeypatch.setattr(_Environment, 'model_storage', mock_storage)
+self.invoke('logs list exec_id')
+
+assert 'Listing logs for execution id exec_id' in 
self.logger_output_string
+assert 'log_msg' in self.logger_output_string
+assert 'No logs' not in self.logger_output_string
+
+def test_no_logs(self, monkeypatch, mock_object):
+m = mock_object
+m.log.list.return_value = []
+monkeypatch.setattr(_Environment, 'model_storage', m)
+self.invoke('logs list exec_id')
+
+assert 'Listing logs for execution id exec_id' in 
self.logger_output_string
+assert 'log_msg' not in self.logger_output_string
+assert 'No logs' in self.logger_output_string

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9169cb35/tests/cli/utils.py
--
diff --git a/tests/cli/utils.py b/tests/cli/utils.py
index 20fdb90..b1537c5 100644
--- a/tests/cli/utils.py
+++ b/tests/cli/utils.py
@@ -51,6 +51,7 @@ class MockStorage(object):
 self.service = MockServiceStorage()
 self.node_template = MockNodeTemplateStorage()
 self.node = MockNodeStorage()
+self.log = MockLogStorage()
 
 
 class MockServiceTemplateStorage(object):
@@ -173,3 +174,12 @@ class MockNodeStorage(object):
 elif id == '2':
 n.runtime_properties = {'attribute1': 'value1'}
 return n
+
+
+class MockLogStorage(object):
+
+def __init__(self):
+st = mock_models.create_service_template('test_st')
+s = mock_models.create_service(st, 'test_s')
+execution = mock_models.create_execution(s)
+self.list = MagicMock(return_value=[mock_models.create_log(execution)])

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/9169cb35/tests/mock/models.py
--
diff --git a/tests/mock/models.py b/tests/mock/models.py
index 8a9273b..328453a 100644
--- a/tests/mock/models.py
+++ b/tests/mock/models.py
@@ -245,6 +245,15 @@ def create_parameter(name, value):
 return p.wrap(name, value)
 
 
+def create_log(execution, msg='log_msg', level=0, 
created_at=datetime.utcnow()):
+
+return models.Log(
+execution=execution,
+msg=msg,
+level=level,
+created_at=created_at)
+
+
 def _dictify(item):
 return dict(((item.name, item),))
 



[10/12] incubator-ariatosca git commit: final review fixes

2017-04-19 Thread avia
final review 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/a39e7d13
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/a39e7d13
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/a39e7d13

Branch: refs/heads/cli-tests
Commit: a39e7d134989b5df753a50c9bcdf9c7a34e9a03f
Parents: 1cbd81b
Author: Ran Ziv 
Authored: Wed Apr 19 14:01:41 2017 +0300
Committer: Ran Ziv 
Committed: Wed Apr 19 14:01:41 2017 +0300

--
 aria/cli/table.py| 4 ++--
 aria/modeling/orchestration.py   | 2 +-
 aria/orchestrator/workflow_runner.py | 3 +--
 3 files changed, 4 insertions(+), 5 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a39e7d13/aria/cli/table.py
--
diff --git a/aria/cli/table.py b/aria/cli/table.py
index 11d791e..408f81e 100644
--- a/aria/cli/table.py
+++ b/aria/cli/table.py
@@ -55,8 +55,8 @@ def _generate(cols, data, column_formatters=None, 
defaults=None):
 
for example: [{'id':'123', 'name':'Pete'}]
 
-column_formatters - A dictionary from a column name to a function that 
may manipulate
-the values printed for this column.
+column_formatters - A dictionary from a column name to a formatter - a 
function that
+may manipulate the string values printed for this 
column.
 (See below for a few built-in formatter examples)
 
 for example: {'created_at': timestamp_formatter}

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a39e7d13/aria/modeling/orchestration.py
--
diff --git a/aria/modeling/orchestration.py b/aria/modeling/orchestration.py
index a2f041b..01ab2e8 100644
--- a/aria/modeling/orchestration.py
+++ b/aria/modeling/orchestration.py
@@ -101,7 +101,7 @@ class ExecutionBase(ModelMixin):
 return self.status in self.END_STATES
 
 def is_active(self):
-return not self.has_ended()
+return not self.has_ended() and self.status != self.PENDING
 
 @declared_attr
 def logs(cls):

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a39e7d13/aria/orchestrator/workflow_runner.py
--
diff --git a/aria/orchestrator/workflow_runner.py 
b/aria/orchestrator/workflow_runner.py
index 8779f06..1ea60a1 100644
--- a/aria/orchestrator/workflow_runner.py
+++ b/aria/orchestrator/workflow_runner.py
@@ -129,8 +129,7 @@ class WorkflowRunner(object):
 .format(self._workflow_name, self.service.name))
 
 def _validate_no_active_executions(self, execution):
-active_executions = [e for e in self.service.executions
- if e.id != execution.id and e.is_active()]
+active_executions = [e for e in self.service.executions if 
e.is_active()]
 if active_executions:
 raise exceptions.ActiveExecutionsError(
 "Can't start execution; Service {0} has an active execution 
with id {1}"



incubator-ariatosca git commit: Refactor cli tests framework

2017-04-19 Thread avia
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/cli-tests f14efbf75 -> 56a4767e3


Refactor cli tests framework


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/56a4767e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/56a4767e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/56a4767e

Branch: refs/heads/cli-tests
Commit: 56a4767e3a22f5f9e5803f78231c27185c8974e0
Parents: f14efbf
Author: Avia Efrat 
Authored: Wed Apr 19 14:17:27 2017 +0300
Committer: Avia Efrat 
Committed: Wed Apr 19 14:17:27 2017 +0300

--
 aria/cli/commands/service_templates.py |   7 +-
 tests/cli/test_logs.py |  23 -
 tests/cli/test_node_templates.py   |  56 +++-
 tests/cli/test_nodes.py|  21 +++--
 tests/cli/test_service_templates.py| 124 +++
 tests/cli/test_services.py |  93 ++--
 tests/cli/utils.py | 128 +++-
 tests/mock/models.py   |  69 +++
 tests/mock/topology.py |   8 +-
 tests/modeling/test_models.py  |   5 +-
 10 files changed, 262 insertions(+), 272 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/56a4767e/aria/cli/commands/service_templates.py
--
diff --git a/aria/cli/commands/service_templates.py 
b/aria/cli/commands/service_templates.py
index 8e0e91c..8ee771f 100644
--- a/aria/cli/commands/service_templates.py
+++ b/aria/cli/commands/service_templates.py
@@ -65,9 +65,10 @@ def show(service_template_name, model_storage, logger):
 
logger.info('{0}{1}'.format(service_template_dict['description'].encode('UTF-8')
 or '',
 os.linesep))
 
-logger.info('Existing services:')
-logger.info('{0}{1}'.format([s['name'] for s in services],
-os.linesep))
+if services:
+logger.info('Existing services:')
+logger.info('{0}{1}'.format([s['name'] for s in services],
+os.linesep))
 
 
 @service_templates.command(name='list',

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/56a4767e/tests/cli/test_logs.py
--
diff --git a/tests/cli/test_logs.py b/tests/cli/test_logs.py
deleted file mode 100644
index ad0c4f1..000
--- a/tests/cli/test_logs.py
+++ /dev/null
@@ -1,23 +0,0 @@
-from aria.cli.env import _Environment
-from tests.cli.base_test import TestCliBase, mock_storage
-
-
-class TestLogsList(TestCliBase):
-
-def test_existing_logs(self, monkeypatch, mock_storage):
-monkeypatch.setattr(_Environment, 'model_storage', mock_storage)
-self.invoke('logs list exec_id')
-
-assert 'Listing logs for execution id exec_id' in 
self.logger_output_string
-assert 'log_msg' in self.logger_output_string
-assert 'No logs' not in self.logger_output_string
-
-def test_no_logs(self, monkeypatch, mock_object):
-m = mock_object
-m.log.list.return_value = []
-monkeypatch.setattr(_Environment, 'model_storage', m)
-self.invoke('logs list exec_id')
-
-assert 'Listing logs for execution id exec_id' in 
self.logger_output_string
-assert 'log_msg' not in self.logger_output_string
-assert 'No logs' in self.logger_output_string

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/56a4767e/tests/cli/test_node_templates.py
--
diff --git a/tests/cli/test_node_templates.py b/tests/cli/test_node_templates.py
index f0ad539..931c0a4 100644
--- a/tests/cli/test_node_templates.py
+++ b/tests/cli/test_node_templates.py
@@ -1,57 +1,66 @@
-from mock import ANY
+from mock import ANY, MagicMock
 import pytest
 
 from aria.cli.env import _Environment
 from tests.cli.base_test import TestCliBase, mock_storage  # pylint: 
disable=unused-import
+from tests.mock.models import create_node_template_with_dependencies, 
NODE_NAME, \
+SERVICE_TEMPLATE_NAME, NODE_TEMPLATE_NAME
 
 
 class TestNodeTemplatesShow(TestCliBase):
 
-def test_no_properties_no_nodes(self, monkeypatch, mock_storage):
-
+def test_header_strings(self, monkeypatch, mock_storage):
 monkeypatch.setattr(_Environment, 'model_storage', mock_storage)
 self.invoke('node_templates show 1')
 assert 'Showing node template 1' in self.logger_output_string
 assert 'Node template properties:' in self.logger_output_string
+assert 'Nodes:' in self.logger_output_string

[GitHub] incubator-ariatosca pull request #97: Aria 48 aria cli

2017-04-19 Thread ran-z
Github user ran-z commented on a diff in the pull request:

https://github.com/apache/incubator-ariatosca/pull/97#discussion_r112175262
  
--- Diff: aria/cli/cli/aria.py ---
@@ -0,0 +1,458 @@
+# 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.
+
+
+import sys
+import difflib
+import StringIO
+import traceback
+from functools import wraps
+
+import click
+
+from ..env import env, logger
+from ..cli import helptexts
+from ..inputs import inputs_to_dict
+from ..constants import SAMPLE_SERVICE_TEMPLATE_FILENAME
+from ...utils.exceptions import get_exception_as_string
+
+
+CLICK_CONTEXT_SETTINGS = dict(
+help_option_names=['-h', '--help'],
+token_normalize_func=lambda param: param.lower())
+
+
+class MutuallyExclusiveOption(click.Option):
+"""Makes options mutually exclusive. The option must pass a `cls` 
argument
+with this class name and a `mutually_exclusive` argument with a list of
+argument names it is mutually exclusive with.
+
+NOTE: All mutually exclusive options must use this. It's not enough to
+use it in just one of the options.
+"""
+
+def __init__(self, *args, **kwargs):
+self.mutually_exclusive = set(kwargs.pop('mutually_exclusive', []))
+self.mutuality_error_message = \
+kwargs.pop('mutuality_error_message',
+   helptexts.DEFAULT_MUTUALITY_MESSAGE)
+self.mutuality_string = ', '.join(self.mutually_exclusive)
+if self.mutually_exclusive:
+help = kwargs.get('help', '')
+kwargs['help'] = (
+'{0}. This argument is mutually exclusive with '
+'arguments: [{1}] ({2})'.format(
+help,
+self.mutuality_string,
+self.mutuality_error_message))
+super(MutuallyExclusiveOption, self).__init__(*args, **kwargs)
+
+def handle_parse_result(self, ctx, opts, args):
+if self.mutually_exclusive.intersection(opts) and self.name in 
opts:
+raise click.UsageError(
+'Illegal usage: `{0}` is mutually exclusive with '
+'arguments: [{1}] ({2}).'.format(
+self.name,
+self.mutuality_string,
+self.mutuality_error_message))
+return super(MutuallyExclusiveOption, self).handle_parse_result(
+ctx, opts, args)
+
+
+def _format_version_data(version_data,
+ prefix=None,
+ suffix=None,
+ infix=None):
+all_data = version_data.copy()
+all_data['prefix'] = prefix or ''
+all_data['suffix'] = suffix or ''
+all_data['infix'] = infix or ''
+output = StringIO.StringIO()
+output.write('{prefix}{version}'.format(**all_data))
+output.write('{suffix}'.format(**all_data))
+return output.getvalue()
+
+
+def show_version(ctx, param, value):
--- End diff --

:+1: 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


incubator-ariatosca git commit: final review fixes

2017-04-19 Thread ran
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-48-aria-cli 1cbd81b3b -> a39e7d134


final review 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/a39e7d13
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/a39e7d13
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/a39e7d13

Branch: refs/heads/ARIA-48-aria-cli
Commit: a39e7d134989b5df753a50c9bcdf9c7a34e9a03f
Parents: 1cbd81b
Author: Ran Ziv 
Authored: Wed Apr 19 14:01:41 2017 +0300
Committer: Ran Ziv 
Committed: Wed Apr 19 14:01:41 2017 +0300

--
 aria/cli/table.py| 4 ++--
 aria/modeling/orchestration.py   | 2 +-
 aria/orchestrator/workflow_runner.py | 3 +--
 3 files changed, 4 insertions(+), 5 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a39e7d13/aria/cli/table.py
--
diff --git a/aria/cli/table.py b/aria/cli/table.py
index 11d791e..408f81e 100644
--- a/aria/cli/table.py
+++ b/aria/cli/table.py
@@ -55,8 +55,8 @@ def _generate(cols, data, column_formatters=None, 
defaults=None):
 
for example: [{'id':'123', 'name':'Pete'}]
 
-column_formatters - A dictionary from a column name to a function that 
may manipulate
-the values printed for this column.
+column_formatters - A dictionary from a column name to a formatter - a 
function that
+may manipulate the string values printed for this 
column.
 (See below for a few built-in formatter examples)
 
 for example: {'created_at': timestamp_formatter}

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a39e7d13/aria/modeling/orchestration.py
--
diff --git a/aria/modeling/orchestration.py b/aria/modeling/orchestration.py
index a2f041b..01ab2e8 100644
--- a/aria/modeling/orchestration.py
+++ b/aria/modeling/orchestration.py
@@ -101,7 +101,7 @@ class ExecutionBase(ModelMixin):
 return self.status in self.END_STATES
 
 def is_active(self):
-return not self.has_ended()
+return not self.has_ended() and self.status != self.PENDING
 
 @declared_attr
 def logs(cls):

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/a39e7d13/aria/orchestrator/workflow_runner.py
--
diff --git a/aria/orchestrator/workflow_runner.py 
b/aria/orchestrator/workflow_runner.py
index 8779f06..1ea60a1 100644
--- a/aria/orchestrator/workflow_runner.py
+++ b/aria/orchestrator/workflow_runner.py
@@ -129,8 +129,7 @@ class WorkflowRunner(object):
 .format(self._workflow_name, self.service.name))
 
 def _validate_no_active_executions(self, execution):
-active_executions = [e for e in self.service.executions
- if e.id != execution.id and e.is_active()]
+active_executions = [e for e in self.service.executions if 
e.is_active()]
 if active_executions:
 raise exceptions.ActiveExecutionsError(
 "Can't start execution; Service {0} has an active execution 
with id {1}"



  1   2   >