summaryrefslogtreecommitdiff
path: root/tools/cloudconfig-schema
blob: 32f0d61ed31791905ba0e41bc30c8f0a17271cdb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python3
# This file is part of cloud-init. See LICENSE file for license information.

"""cloudconfig-schema

Validate existing files against cloud-config schema or provide supported schema
documentation.
"""

import os
import sys


def call_entry_point(name):
    (istr, dot, ent) = name.rpartition('.')
    try:
        __import__(istr)
    except ImportError:
        # if that import failed, check dirname(__file__/..)
        # to support ./bin/program with modules in .
        _tdir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
        sys.path.insert(0, _tdir)
        try:
            __import__(istr)
        except ImportError as e:
            sys.stderr.write("Unable to find %s: %s\n" % (name, e))
            sys.exit(2)

    sys.exit(getattr(sys.modules[istr], ent)())


if __name__ == '__main__':
    call_entry_point("cloudinit.config.schema.main")

# vi: ts=4 expandtab syntax=python