Diablo – openSUSE Lizards https://lizards.opensuse.org Blogs and Ramblings of the openSUSE Members Fri, 06 Mar 2020 11:29:40 +0000 en-US hourly 1 https://wordpress.org/?v=4.7.5 CLI to upload image to openstack cloud https://lizards.opensuse.org/2012/04/18/cli-to-upload-image-to-openstack-cloud/ Wed, 18 Apr 2012 11:18:39 +0000 http://lizards.opensuse.org/?p=8635 I work on automatic testing of one of our products that creates other projects.
And because there is a lot of clouds everywhere I want to use them too. We
have internally an OpenStack cloud (still Diablo release). So I need to solve
automatic uploading of images built in the Build Service. Below I describe my working version.

At first, for other cloud related tasks we are using the nova command (which
e.g. has also image-delete, but not add). For uploading we use
glance. I found a few obstacles which I separately describe and also provide
a solution.

Authentication

The first chalenge is authentication, as glance doesn`t use NOVA_*
environment variables. But it allows to use an authentication token. So we
just need to get such a token. With help of Martin Vidner we have this script,
that returns a valid token.

# cloud_auth_token.sh
OS_AUTH_URL="http://cloud.example.com:5000/v2.0"
OS_TENANT_NAME=$NOVA_USERNAME
OS_USERNAME=$NOVA_USERNAME
OS_PASSWORD=$NOVA_API_KEY
AUTH_JSON="{\"auth\":{\"passwordCredentials\":{\"username\": \"$OS_USERNAME\", \"password\":\"$OS_PASSWORD\"}, \"tenantName\":\"$OS_TENANT_NAME\"}}"
curl -s \
    -d "$AUTH_JSON" -H "Content-type: application/json" \
    $OS_AUTH_URL/tokens \
    | python -c "import sys; import json; tok = json.loads(sys.stdin.read()); print tok['access']['token']['id'];"

What does it do? It calls OpenStack Identity API, passes credentials encoded
as JSON. The response is also JSON, so we use python that is already on the
system to parse the response and get the token.

Compressing the Image

The next challenge is compression of the image. We get a raw disk from the
build service and we extend it to have more than 15GB (we mirror there rpms
so we need this space). For resizing we use qemu-img from
virt-utils. If we simply upload this image it means that we send the whole
15GB over the network. Which is fine for one-time tasks, but for regular
testing it is a problem. Thanks to Christoph Thiel we solved it with the
conversion to qcow2. Qcow2 is also supported in OpenStack and qcow2 allows
compression. The final script for conversion:

qemu-img convert -c -f raw -O qcow2 img.raw img.qcow2
qemu-img resize img.qcow2 +10G

Using it Together

Now we have prepared an image and a helper script to get a cloud auth
token. So let’s upload the image.

cat img.qcow2 | glance -H cloud.example.com -A `sh cloud_auth_token.sh` add name='testing_img' is_public=False disk_format=qcow2 container_format=bare

Cleaning Up After Testing

We use it for testing and release new versions of the testing appliance often,
therefore we need cleaning up. It is quite simple with unix text utils:

for i in `nova image-list | grep "image_name" | sed "s/^|[[:space:]]\+\([[:xdigit:]-]\+\).*$/\1/"`; do nova image-delete $i; done

I hope that it helps you with automatic uploading of images to
OpenStack. It works for me with the Diablo release and there is no guarantee that it is the best way 🙂

]]>
Build maemo-apps with openSUSE BuildService ? – It works ! https://lizards.opensuse.org/2009/01/27/build-maemo-apps-with-opensuse-buildservice-it-works/ https://lizards.opensuse.org/2009/01/27/build-maemo-apps-with-opensuse-buildservice-it-works/#comments Tue, 27 Jan 2009 18:22:01 +0000 http://lizards.opensuse.org/?p=392 build serviceThe openSUSE Build Service is an open and complete distribution development platform. It’s the infrastructure for a development of the openSUSE distributions. But this powerful tool can do much more! The upcoming version 1.5 will also have cross-build support and thus be able to build e.g. ARM packages on x86 hardware .

maemo.org loko Maemo is the platform for mobile devices like the N810 and has been developed by Nokia in collaboration with many open source projects such as the Linux kernel, GNOME and many more.

Today I succeeded in building a package of csync (the new file-sync tool) for maemo/diablo inside a local instance of the openSUSE Build Service using the cross-build and download-on-demand support. To make this happen, I imported the diablo/sdk repository from repository.maemo.org as download-on-demand target.

top qemu-arm

Then I had to write the project configuration (osc prjconf) and add some missing pieces.

top running qemu-user/arm

In the end, I was able to build iniparser, samba and cmake as dependencies of csync. Last step was csync itself. The packages are available here …

Use: deb http://www.csync.org/maemo/diablo/n810 ./ as source for apt.

More information about the cross-build support can be found on this page and here on lizards.opensuse.org [1], [2] .
There will be a talk about cross-build and download-on-demand at FOSDEM 2009.

OBS rocks !

]]> https://lizards.opensuse.org/2009/01/27/build-maemo-apps-with-opensuse-buildservice-it-works/feed/ 3