Inject an ssh key failed when booting a instance by using direct image injection.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Compute (nova) |
Fix Released
|
Undecided
|
Chung Chih, Hung |
Bug Description
1. root@cling-
+------
| Name | Fingerprint |
+------
| hanrong | 57:96:f9:
+------
2. modify nova.conf
inject_partition=-1
inject_key=true
3. boot a instance with parameter --key-name
nova boot --image e39e0859-
4. vm is active, but the end of file /root/.
5. nova-compute.log is show that:
2015-09-02 10:11:00.058 8474 WARNING nova.virt.
2015-09-02 10:11:00.068 8474 WARNING nova.virt.disk.api [req-f8e65cdf-
6. fs.setup() throw exception ,log write in this code:
def inject_data(image, key=None, net=None, metadata=None, admin_password=
"""Inject the specified items into a disk image.
If an item name is not specified in the MANDATORY iterable, then a warning
is logged on failure to inject that item, rather than raising an exception.
it will mount the image as a fully partitioned disk and attempt to inject
into the specified partition number.
If PARTITION is not specified the image is mounted as a single partition.
Returns True if all requested operations completed without issue.
Raises an exception if a mandatory item can't be injected.
"""
LOG.
fmt = "raw"
if use_cow:
fmt = "qcow2"
try:
fs = vfs.VFS.
fs.setup()
except Exception as e:
# If a mandatory item is passed to this function,
# then reraise the exception to indicate the error.
for inject in mandatory:
if inject_val:
return False
try:
return inject_
finally:
tags: | added: inject libvirt permissions spawn |
tags: | added: rootwrap |
Changed in nova: | |
assignee: | nobody → Chung Chih, Hung (lyanchih) |
Changed in nova: | |
assignee: | Chung Chih, Hung (lyanchih) → nobody |
Changed in nova: | |
assignee: | nobody → Chung Chih, Hung (lyanchih) |
status: | New → In Progress |
I did an experiment, if the service of nova-compute as root permission to start, we can inject the SSH key into instance success.
stop nova-compute: nova-compute
systemctl stop openstack-
start nova-compute as root permission nova-compute
/usr/bin/python /usr/bin/