Skip to content

Instantly share code, notes, and snippets.

@fedir
Last active March 12, 2022 12:28
Show Gist options
  • Save fedir/a4e8cd94ba473e78b59b4076b6be7784 to your computer and use it in GitHub Desktop.
Save fedir/a4e8cd94ba473e78b59b4076b6be7784 to your computer and use it in GitHub Desktop.
Openstack export / import operations

Openstack export / import operations

Prepare environment

First of all, You should have Python and pip installed (I tested on Python 2.7 on Mac OS, it works).

After, You should install python-novaclient package :

sudo pip install python-novaclient
sudo pip install python-glanceclient

Alternatively, packages could be installed for current user only:

pip install python-novaclient  --user
pip install python-glanceclient  --user

Next point, You should configure Openstack variables.

Here's a sample for OVH's openerc.sh script :

export OS_AUTH_URL=https://auth.cloud.ovh.net/v2.0/
export OS_TENANT_ID=XXXX
export OS_TENANT_NAME="XXX"
export OS_USERNAME="XXX"
echo "Please enter your OpenStack Password: "
read -sr OS_PASSWORD_INPUT
export OS_PASSWORD=$OS_PASSWORD_INPUT
export OS_REGION_NAME="WAW1"
if [ -z "$OS_REGION_NAME" ]; then unset OS_REGION_NAME; fi

Prepare the image

nova list
nova image-create XXX-XXX-XXX-XXX imagekey

Download the image

glance image-list
glance image-download --file imagekey.qcow XXX-XXX-XXX-XXX

Import an image

glance image-create --name imagekey --disk-format qcow2 --container-format bare --file imagekey.qcow
nova boot --key_name SSHKEY --flavor YYY-YYY-YYY-YYY --image ZZZ-ZZZ-ZZZ-ZZZ imagekey

Optional convert of qcow to vdi for local usage

qemu-img convert -O vdi imagekey.qcow imagekey.vdi

Ressources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment