From 76e79792b4b94c9edac0ebf3cdf3eb49c7999398 Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Thu, 2 Feb 2012 12:06:38 -0800 Subject: [PATCH] Add comments to injected keys and network config Fixes bug 754950 Change-Id: Ib773479c3b34b9ddd322abd02b297acf5359a847 --- nova/virt/disk/api.py | 9 ++++++++- nova/virt/interfaces.template | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/nova/virt/disk/api.py b/nova/virt/disk/api.py index 8f477bcea0d0..4b1bf7f66147 100644 --- a/nova/virt/disk/api.py +++ b/nova/virt/disk/api.py @@ -300,8 +300,15 @@ def _inject_key_into_fs(key, fs, execute=None): utils.execute('chown', 'root', sshdir, run_as_root=True) utils.execute('chmod', '700', sshdir, run_as_root=True) keyfile = os.path.join(sshdir, 'authorized_keys') + key_data = [ + '\n', + '# The following ssh key was injected by Nova', + '\n', + key.strip(), + '\n', + ] utils.execute('tee', '-a', keyfile, - process_input='\n' + key.strip() + '\n', run_as_root=True) + process_input=''.join(key_data), run_as_root=True) def _inject_net_into_fs(net, fs, execute=None): diff --git a/nova/virt/interfaces.template b/nova/virt/interfaces.template index e527cf35c41d..ad8c1bcdb708 100644 --- a/nova/virt/interfaces.template +++ b/nova/virt/interfaces.template @@ -1,3 +1,5 @@ +# Injected by Nova on instance boot +# # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5).