Is it possible to create an ami from an openstack

2019-07-03 09:31发布

问题:

I'm creating an image from a running instance in OpenStack

nova image-create <server-name>

and i'm just wondering,can this image be uploaded to ec2? Or do i need to create an ami from it?

Can someone guide me on how to go about this?

回答1:

glance, the openstack image service is capable of storing a number of image types:

Raw
Machine (kernel/ramdisk outside of image, a.k.a. AMI)
VHD (Hyper-V)
VDI (VirtualBox)
qcow2 (Qemu/KVM)
VMDK (VMWare)
OVF (VMWare, others)

Ref: http://www.openstack.org/projects/image-service/

So basically. You can upload AMIs to openstack directly.

Example:

KERNEL_ID=`glance image-create --name="tty-linux-kernel" --disk-format=aki --container-format=aki < ttylinux-uec-amd64-12.1_2.6.35-22_1-vmlinuz | awk '/ id / { print $4 }'`
INITRD_ID=`glance image-create --name="tty-linux-ramdisk" --disk-format=ari --container-format=ari < ttylinux-uec-amd64-12.1_2.6.35-22_1-loader | awk '/ id / { print $4 }'`
glance image-create --name="tty-linux" --disk-format=ami --container-format=ami --property kernel_id=${KERNEL_ID} --property ramdisk_id=${INITRD_ID} < ttylinux-uec-amd64-12.1_2.6.35-22_1.img

When performing an image-create against a running instance

Images can only be created from running instances if Compute is configured to use qcow2 > images, which is the default setting. You can explicitly enable the use of qcow2 images > by adding the following line to nova.conf:

But assuming you are configured as such, yes it will output in AMI format.

Ref:

http://docs.openstack.org/trunk/openstack-compute/admin/content/creating-images-from-running-instances.html