Dennis Dmitriev | e56c8b9 | 2017-06-16 01:53:16 +0300 | [diff] [blame] | 1 | # Copyright 2013 - 2016 Mirantis, Inc. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
| 14 | |
| 15 | from __future__ import print_function |
| 16 | |
| 17 | import argparse |
| 18 | import os |
| 19 | import sys |
| 20 | import yaml |
| 21 | |
| 22 | from reclass_tools import walk_models |
| 23 | |
| 24 | |
| 25 | def execute(params): |
| 26 | |
| 27 | results = walk_models.get_all_reclass_params( |
| 28 | params.paths, |
| 29 | identity_files=params.identity_files, |
| 30 | verbose=params.verbose) |
| 31 | |
| 32 | print(yaml.dump(results)) |
| 33 | |
| 34 | |
| 35 | def dump_params(args=None): |
| 36 | if args is None: |
| 37 | args = sys.argv[1:] |
| 38 | |
| 39 | parser = argparse.ArgumentParser( |
| 40 | formatter_class=argparse.RawTextHelpFormatter, |
| 41 | description="") |
| 42 | parser.add_argument('-i', dest='identity_files', |
| 43 | help=('For SSH connections, selects a file from which \n' |
| 44 | 'the identity (private key) for public key \n' |
| 45 | 'authentication is read. It is possible to have \n' |
| 46 | 'multiple -i options.'), |
| 47 | action='append') |
| 48 | parser.add_argument('--verbose', dest='verbose', action='store_const', const=True, |
| 49 | help='Show verbosed output.', default=False) |
| 50 | parser.add_argument('paths', help='Paths to search for *.yml files.', nargs='+') |
| 51 | |
| 52 | if len(args) == 0: |
| 53 | args = ['-h'] |
| 54 | |
| 55 | params = parser.parse_args(args) |
| 56 | execute(params) |