~blake-rouse/maas/fix-1353597-1.6

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
36
37
38
39
40
41
#!/usr/bin/env python2.7
# -*- mode: python -*-
# Copyright 2014 Canonical Ltd.  This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).

"""Import boot resources into MAAS cluster controller."""

from __future__ import (
    absolute_import,
    print_function,
    unicode_literals,
    )

str = None

__metaclass__ = type

from provisioningserver.import_images.boot_resources import (
    logger,
    main,
    make_arg_parser,
    NoConfigFile,
    )


if __name__ == "__main__":
    parser = make_arg_parser(__doc__)
    args = parser.parse_args()
    try:
        main(args)
    except NoConfigFile:
        logger.error("Config file %s not found." % args.config_file)
        raise SystemExit(1)
    except Exception:
        # logger.exception() will log the error message, followed by the
        # exception's stack trace. Using it here rather than allowing
        # the exception to kill the process unhandled means we can be
        # sure about where the exception ends up, rather than it
        # potentially vanishing.
        logger.exception("Unhandled exception; unable to continue.")
        raise SystemExit(2)