3
# Copyright (C) 2009-2010 Canonical Ltd.
4
# Copyright (C) 2012 Hewlett-Packard Development Company, L.P.
6
# Author: Scott Moser <scott.moser@canonical.com>
7
# Author: Juerg Haefliger <juerg.haefliger@hp.com>
9
# This program is free software: you can redistribute it and/or modify
10
# it under the terms of the GNU General Public License version 3, as
11
# published by the Free Software Foundation.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
23
from cloudinit import util
26
def handle(name, cfg, cloud, log, _args):
27
if "runcmd" not in cfg:
28
log.debug(("Skipping module named %s,"
29
" no 'runcmd' key in configuration"), name)
32
out_fn = os.path.join(cloud.get_ipath('scripts'), "runcmd")
35
content = util.shellify(cmd)
36
util.write_file(out_fn, content, 0o700)
38
util.logexc(log, "Failed to shellify %s into file %s", cmd, out_fn)