#!/usr/bin/python3
#
# Copyright (c) 2015--2021 SUSE LLC. All Rights Reserved.
#
# Licensed 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.
# pylint: disable=invalid-name

"""
Gatherer application

The input file has the following format of the array of management node definitions:

[
 {
  "id": "myvcenter",
  "module": "VMware",
  "host": "vCenter.domain.top",
  "user": "admin"
  "pass": "secret",
  "port": 443
 },
 { ... }
]
"""

from __future__ import print_function, absolute_import
import sys

sys.path.append('./lib')
# pylint: disable=no-name-in-module
from gatherer.gatherer import Gatherer, parse_options


def main():
    """
    Run Gatherer application
    :return:
    """
    # pylint: disable=broad-except
    options = parse_options()
    try:
        Gatherer(options).main()
    except Exception as ex:
        sys.stderr.write("General error: {0}\n".format(ex))
        if options.verbose > 0:
            raise
        sys.exit(1)


# Start program
if __name__ == "__main__":
    if len(sys.argv) == 1:
        sys.argv.append("-h")  # Display "help" by default.
    main()
