You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ariatosca.apache.org by tliron <gi...@git.apache.org> on 2017/06/02 19:21:24 UTC

[GitHub] incubator-ariatosca pull request #146: ARIA-199 Add "services outputs" CLI c...

GitHub user tliron opened a pull request:

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

    ARIA-199 Add "services outputs" CLI command

    

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

    $ git pull https://github.com/apache/incubator-ariatosca ARIA-199-cli-service-output

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

    https://github.com/apache/incubator-ariatosca/pull/146.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 #146
    
----
commit 79b94e1f9aed3be3176b96870f7ea472146032c3
Author: Tal Liron <ta...@gmail.com>
Date:   2017-06-02T19:20:28Z

    ARIA-199 Add "services outputs" CLI command

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #146: ARIA-199 Add "services outputs" CLI c...

Posted by AviaE <gi...@git.apache.org>.
Github user AviaE commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/146#discussion_r120009119
  
    --- Diff: aria/cli/commands/services.py ---
    @@ -192,17 +192,17 @@ def outputs(service_name, model_storage, logger):
         """
         logger.info('Showing outputs for service {0}...'.format(service_name))
         service = model_storage.service.get_by_name(service_name)
    -    #TODO fix this section..
    -    outputs_def = service.outputs
    -    response = model_storage.service.outputs.get(service_name)
    -    outputs_ = StringIO()
    -    for output_name, output in response.outputs.iteritems():
    -        outputs_.write(' - "{0}":{1}'.format(output_name, os.linesep))
    -        description = outputs_def[output_name].get('description', '')
    -        outputs_.write('     Description: {0}{1}'.format(description,
    -                                                         os.linesep))
    -        outputs_.write('     Value: {0}{1}'.format(output, os.linesep))
    -    logger.info(outputs_.getvalue())
    +
    +    if service.outputs:
    +        outputs_ = StringIO()
    +        for output_name, output in service.outputs.iteritems():
    +            outputs_.write(' - "{0}":{1}'.format(output_name, os.linesep))
    +            outputs_.write('     Description: {0}{1}'.format(output.description,
    --- End diff --
    
    Put the `os.linesep` in the `Description` line in the same line. It is short enough =)


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #146: ARIA-199 Add "services outputs" CLI c...

Posted by AviaE <gi...@git.apache.org>.
Github user AviaE commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/146#discussion_r120009903
  
    --- Diff: tests/mock/models.py ---
    @@ -96,6 +97,9 @@ def create_service_with_dependencies(include_execution=False,
         if include_input:
             input = create_parameter(name='input1', value='value1')
             service.inputs = {'input1': input}
    +    if include_output:
    --- End diff --
    
    Now, that ARIA-180 was merged, we have a dedicated `create_input` function.
    Similarly, please add a `create_output` function =)
    In addition, as in `services outputs` we also print the description of the output, so it would be nice to add the description as a parameter to the `create_output` function, and to check for the existence of that printed description in the console output (`logger output string`).
    
    On another note, According to the TOSCA spec, inputs also have a description, and the is not addressed in the current `create_input` and tests for `services outputs`. You have me permission [:)] to fix it in the context of this commit, as it is very closely related to it. If you prefer not to, it will be addressed in this JIRA: https://issues.apache.org/jira/browse/ARIA-192 ("Fix output inconsistencies in CLI").


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #146: ARIA-199 Add "services outputs" CLI c...

Posted by tliron <gi...@git.apache.org>.
Github user tliron commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/146#discussion_r120391233
  
    --- Diff: tests/resources/service-templates/tosca-simple-1.0/node-cellar/node-cellar.yaml ---
    @@ -302,6 +306,14 @@ topology_template:
         capabilities:
           app_endpoint: [ loadbalancer, client ]
     
    +  outputs:
    --- End diff --
    
    Done.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #146: ARIA-199 Add "services outputs" CLI c...

Posted by tliron <gi...@git.apache.org>.
Github user tliron commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/146#discussion_r120155891
  
    --- Diff: tests/mock/models.py ---
    @@ -96,6 +97,9 @@ def create_service_with_dependencies(include_execution=False,
         if include_input:
             input = create_parameter(name='input1', value='value1')
             service.inputs = {'input1': input}
    +    if include_output:
    --- End diff --
    
    I think this should be done separately -- I'm trying to make this commit specifically about the CLI.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #146: ARIA-199 Add "services outputs" CLI c...

Posted by AviaE <gi...@git.apache.org>.
Github user AviaE commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/146#discussion_r120009913
  
    --- Diff: tests/cli/test_services.py ---
    @@ -174,7 +174,30 @@ def test_delete_available_nodes_error_with_force(self, monkeypatch, mock_storage
     
     
     class TestServicesOutputs(TestCliBase):
    -    pass
    +
    +    def test_header_string(self, monkeypatch, mock_storage):
    +        monkeypatch.setattr(_Environment, 'model_storage', mock_storage)
    +        self.invoke('services outputs test_s')
    +        assert 'Showing outputs for service test_s...' in self.logger_output_string
    +
    +    def test_outputs_no_outputs(self, monkeypatch, mock_storage):
    +        monkeypatch.setattr(_Environment, 'model_storage', mock_storage)
    +        self.invoke('services outputs service_with_no_outputs')
    +
    +        assert 'No outputs' in self.logger_output_string
    +        assert 'output1' not in self.logger_output_string
    +        assert 'value1' not in self.logger_output_string
    +
    +    def test_outputs_one_output(self, monkeypatch, mock_storage):
    +        monkeypatch.setattr(_Environment, 'model_storage', mock_storage)
    +        s = mock_models.create_service_with_dependencies(include_output=True)
    +        monkeypatch.setattr(mock_storage.service, 'get_by_name', mock.MagicMock(return_value=s))
    +
    +        self.invoke('services outputs test_s')
    +
    +        assert 'output1' in self.logger_output_string
    +        assert 'value1' in self.logger_output_string
    +        assert 'No inputs' not in self.logger_output_string
    --- End diff --
    
    `'No outputs'`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #146: ARIA-199 Add "services outputs" CLI c...

Posted by AviaE <gi...@git.apache.org>.
Github user AviaE commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/146#discussion_r120009173
  
    --- Diff: tests/cli/test_services.py ---
    @@ -174,7 +174,30 @@ def test_delete_available_nodes_error_with_force(self, monkeypatch, mock_storage
     
     
     class TestServicesOutputs(TestCliBase):
    -    pass
    +
    +    def test_header_string(self, monkeypatch, mock_storage):
    +        monkeypatch.setattr(_Environment, 'model_storage', mock_storage)
    +        self.invoke('services outputs test_s')
    +        assert 'Showing outputs for service test_s...' in self.logger_output_string
    +
    +    def test_outputs_no_outputs(self, monkeypatch, mock_storage):
    +        monkeypatch.setattr(_Environment, 'model_storage', mock_storage)
    +        self.invoke('services outputs service_with_no_outputs')
    +
    +        assert 'No outputs' in self.logger_output_string
    +        assert 'output1' not in self.logger_output_string
    +        assert 'value1' not in self.logger_output_string
    +
    +    def test_outputs_one_output(self, monkeypatch, mock_storage):
    +        monkeypatch.setattr(_Environment, 'model_storage', mock_storage)
    +        s = mock_models.create_service_with_dependencies(include_output=True)
    +        monkeypatch.setattr(mock_storage.service, 'get_by_name', mock.MagicMock(return_value=s))
    +
    +        self.invoke('services outputs test_s')
    +
    +        assert 'output1' in self.logger_output_string
    +        assert 'value1' in self.logger_output_string
    +        assert 'No inputs' not in self.logger_output_string
    --- End diff --
    
    Should be 'no outputs'.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #146: ARIA-199 Add "services outputs" CLI c...

Posted by ran-z <gi...@git.apache.org>.
Github user ran-z commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/146#discussion_r120004762
  
    --- Diff: tests/resources/service-templates/tosca-simple-1.0/node-cellar/node-cellar.yaml ---
    @@ -302,6 +306,14 @@ topology_template:
         capabilities:
           app_endpoint: [ loadbalancer, client ]
     
    +  outputs:
    --- End diff --
    
    It'd be better (or rather, also good) to have an `outputs` section appended to the `hello-world` example, and then use it in the end2end test to grab the URL of the web server.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #146: ARIA-199 Add "services outputs" CLI c...

Posted by AviaE <gi...@git.apache.org>.
Github user AviaE commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/146#discussion_r120009954
  
    --- Diff: aria/cli/commands/services.py ---
    @@ -192,17 +192,17 @@ def outputs(service_name, model_storage, logger):
         """
         logger.info('Showing outputs for service {0}...'.format(service_name))
         service = model_storage.service.get_by_name(service_name)
    -    #TODO fix this section..
    -    outputs_def = service.outputs
    -    response = model_storage.service.outputs.get(service_name)
    -    outputs_ = StringIO()
    -    for output_name, output in response.outputs.iteritems():
    -        outputs_.write(' - "{0}":{1}'.format(output_name, os.linesep))
    -        description = outputs_def[output_name].get('description', '')
    -        outputs_.write('     Description: {0}{1}'.format(description,
    -                                                         os.linesep))
    -        outputs_.write('     Value: {0}{1}'.format(output, os.linesep))
    -    logger.info(outputs_.getvalue())
    +
    +    if service.outputs:
    +        outputs_ = StringIO()
    +        for output_name, output in service.outputs.iteritems():
    +            outputs_.write(' - "{0}":{1}'.format(output_name, os.linesep))
    +            outputs_.write('     Description: {0}{1}'.format(output.description,
    --- End diff --
    
    You can put `os.linesep` in the same line as `Description`, it is short enough, and consistent with the other lines.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-ariatosca pull request #146: ARIA-199 Add "services outputs" CLI c...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

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


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---