ariatosca-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ran-z <...@git.apache.org>
Subject [GitHub] incubator-ariatosca pull request #95: ARIA-92 Automatic operation task confi...
Date Wed, 12 Apr 2017 15:55:06 GMT
Github user ran-z commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/95#discussion_r111189712
  
    --- Diff: aria/orchestrator/execution_plugin/instantiation.py ---
    @@ -0,0 +1,187 @@
    +# 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.
    +
    +# TODO: this module will eventually be moved to a new "aria.instantiation" package
    +
    +from ...utils.formatting import full_type_name
    +from ...utils.collections import OrderedDict
    +from ...parser import validation
    +from ...parser.consumption import ConsumptionContext
    +
    +
    +def configure_operation(operation):
    +    configuration = OrderedDict(operation.configuration) if operation.configuration else
{}
    +
    +    arguments = OrderedDict()
    +    arguments['script_path'] = operation.implementation
    +    arguments['process'] = _get_process(configuration.pop('process')) \
    +        if 'process' in configuration else None
    +
    +    host = None
    +    interface = operation.interface
    +    if interface.node is not None:
    +        host = interface.node.host
    +    elif interface.relationship is not None:
    +        if operation.relationship_edge is True:
    +            host = interface.relationship.target_node.host
    +        else: # either False or None
    +            host = interface.relationship.source_node.host
    +
    +    if host is None:
    +        _configure_local(operation)
    +    else:
    +        _configure_remote(operation, configuration, arguments)
    +
    +    # Any remaining unhandled configuration values will become extra arguments, available
as kwargs
    +    # in either "run_script_locally" or "run_script_with_ssh"
    +    arguments.update(configuration)
    +
    +    return arguments
    +
    +def _configure_local(operation):
    +    """
    +    Local operation.
    +    """
    +    from . import operations
    +    operation.implementation = '{0}.{1}'.format(operations.__name__,
    +                                                operations.run_script_locally.__name__)
    +
    +
    +def _configure_remote(operation, configuration, arguments):
    +    """
    +    Remote SSH operation via Fabric.
    +    """
    +    default_user = 'admin'
    +    default_password = 'admin'
    +    ssh = _get_ssh(configuration.pop('ssh')) if 'ssh' in configuration else {}
    +    if 'user' not in ssh:
    +        ssh['user'] = default_user
    +    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')
    --- End diff --
    
    why not use copy of some sort?


---
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.
---

Mime
View raw message