3
# Copyright (C) 2011 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.settings import PER_INSTANCE
24
from cloudinit import util
26
frequency = PER_INSTANCE
28
# This is a tool that cloud init provides
29
HELPER_TOOL_TPL = '%s/cloud-init/write-ssh-key-fingerprints'
32
def _get_helper_tool_path(distro):
34
base_lib = distro.usr_lib_exec
35
except AttributeError:
37
return HELPER_TOOL_TPL % base_lib
40
def handle(name, cfg, cloud, log, _args):
41
helper_path = _get_helper_tool_path(cloud.distro)
42
if not os.path.exists(helper_path):
43
log.warn(("Unable to activate module %s,"
44
" helper tool not found at %s"), name, helper_path)
47
fp_blacklist = util.get_cfg_option_list(cfg,
48
"ssh_fp_console_blacklist", [])
49
key_blacklist = util.get_cfg_option_list(cfg,
50
"ssh_key_console_blacklist",
55
cmd.append(','.join(fp_blacklist))
56
cmd.append(','.join(key_blacklist))
57
(stdout, _stderr) = util.subp(cmd)
58
util.multi_log("%s\n" % (stdout.strip()),
59
stderr=False, console=True)
61
log.warn("Writing keys to the system console failed!")