cc_scripts_per_boot.py 1.35 KB
Newer Older
1 2 3
# vi: ts=4 expandtab
#
#    Copyright (C) 2011 Canonical Ltd.
4
#    Copyright (C) 2012 Hewlett-Packard Development Company, L.P.
5 6
#
#    Author: Scott Moser <scott.moser@canonical.com>
7
#    Author: Juerg Haefliger <juerg.haefliger@hp.com>
8 9 10 11 12 13 14 15 16 17 18 19
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License version 3, as
#    published by the Free Software Foundation.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20

21
import os
22

23
from cloudinit import util
24

25
from cloudinit.settings import PER_ALWAYS
26

27 28
frequency = PER_ALWAYS

29
SCRIPT_SUBDIR = 'per-boot'
30 31


32
def handle(name, _cfg, cloud, log, _args):
33 34
    # Comes from the following:
    # https://forums.aws.amazon.com/thread.jspa?threadID=96918
35
    runparts_path = os.path.join(cloud.get_cpath(), 'scripts', SCRIPT_SUBDIR)
36 37
    try:
        util.runparts(runparts_path)
38
    except Exception:
39
        log.warn("Failed to run module %s (%s in %s)",
40
                 name, SCRIPT_SUBDIR, runparts_path)
41
        raise