Comment 3 for bug 678395

Revision history for this message
guanxiaohua2k6 (guanxiaohua2k6) wrote : Re: Command "sudo tee /var/lib/nova/tmp/tmpuaJWRG/etc/network/interfaces" failed when starting an instance

 Firstly this bug is related with https://bugs.launchpad.net/nova/+bug/678393.

After I installed nova on multiple machine, and created networks using "nova-mange network create ...", I failed with bug 678393. So I updated the column bridge of table networks manually. And I tried start an instance again, it failed with the messages as this bug described.

I have read the source of disk.py, it is clear that folder "/var/lib/nova/tmp/tmpuaJWRG/etc/network/" wasn't created in method _inject_net_into_fs(). So it caused the following command "tee" failed.

Contrast to _inject_net_into_fs(), in the method _inject_key_into_fs() just above, the corresponding folder is created before command tee is executed. As a reference, paste the code in following.

def _inject_key_into_fs(key, fs, execute=None):
    sshdir = os.path.join(os.path.join(fs, 'root'), '.ssh')
    yield execute('sudo mkdir -p %s' % sshdir) # existing dir doesn't matter
    yield execute('sudo chown root %s' % sshdir)
    yield execute('sudo chmod 700 %s' % sshdir)
    keyfile = os.path.join(sshdir, 'authorized_keys')
    yield execute('sudo tee -a %s' % keyfile, '\n' + key.strip() + '\n')