Hi Martyn,
On Tue, 2011-07-05 at 05:20 -0400, Martyn Taylor wrote:
Hi Mark,
So, I'm working on the aeolus-image command line tool at the moment,
and am wondering if you could give me some info (or point me towards
some) on ImageFactory API. I'm trying to work out what is actually
implemented and working, and what the calls look like.
No better reference than the code :-)
The build_image and push_image methods are implemented by
build_image_for_targets and push_image_to_providers in
BuildDispatcher.py. Feel free to prod me for more details if you
struggle to figure it out
The commands I'm looking to implement:
These look like the suggested commands I wrote up a while back. They
were meant as examples, and are mostly convenience syntax on top of what
is already supported ... so you should probably consider dropping or
rethinking some of them
aeolus-image push --build $build_id
#push all target images for a build, to same providers as previously
Okay, push_image requires the image ID and providers list, so you'll
need to get those from iwhd
1) Get the image which the build is associated with
image_id=$(curl -s
http://localhost:9090/builds/${build_id}/image)
2) Find the latest build of that image which was pushed:
latest_build=$(curl -s
http://localhost:9090/images/${image_id}/latest_build)
3) Find the target images for that build
tmp=$(curl -s -d "\$build == \"${latest_build}\""
http://localhost:9090/target_images/_query)
n_target_images=$(echo -n $tmp | xmlstarlet sel -t -v
"count(/objects/object/key)")
target_images=$(for i in $(seq ${n_target_images}); do echo -n $tmp | xmlstarlet sel -t
-v "/objects/object[${i}]/key"; done)
4) Find the providers which those target images were pushed to
for ti in $target_images; do \
tmp=$(curl -s -d "\$target_image = \"${ti}\""
http://localhost:9090/provider_images/_query); \
n_provider_images=$(echo -n $tmp | xmlstarlet sel -t -v
"count(/objects/object/key)"); \
for provider_image in $(for i in $(seq ${n_provider_images}); do echo -n $tmp |
xmlstarlet sel -t -v "/objects/object[${i}]/key"; done); do \
echo $(curl -s
http://localhost:9090/provider_images/$provider_image/provider); \
done \
done
aeolus-image push --account $provider_account --build $build_id
#ditto, using a specific provider account
Similar to above, but you only push to a specific provider
aeolus-image push --image $image_id
#push all the target images for the latest build
Similar to above, but using the latest unpushed build:
build_id=$(curl -s
http://localhost:9090/images/${image_id}/latest_unpushed)
aeolus-image build --image $image_id
#rebuild the image template and targets from latest build
This is straightforward - just call build_image with the image ID, but
no build ID, targets or template and it will work
aeolus-image delete --providerimage $provider_image # deletes a
provider image
$> curl -X DELETE
http://localhost:9090/provider_images/${provider_image}
aeolus-image delete --targetimage $target_image # deletes a
target image and its provider images
$> tmp=$(curl -s -d "\$target_image = \"${target_image}\""
http://localhost:9090/provider_images/_query)
$> n_provider_images=$(echo -n $tmp | xmlstarlet sel -t -v
"count(/objects/object/key)")
$> for provider_image in $(for i in $(seq 2); do echo -n $tmp | xmlstarlet sel -t -v
"/objects/object[${i}]/key"; done); do
$> curl -X DELETE
http://localhost:9090/provider_images/${provider_image}
done
$> curl -X DELETE
http://localhost:9090/target_images/${target_image}
aeolus-image delete --build $build_id # deletes a
build, updating latest/parent references as appropriate
You get the idea at this stage - delete all the provider images and
target images associated with the build, and then delete the build
However, you'll also want to:
1) If this ID is the same as latest_unpushed for the image, unset
latest_unpushed
2) If this ID is the same as latest_build for the image, set
latest_build to the parent build of this build
3) If any build references this build as its parent, update the
reference to point to the build's parent
Basically, image factory has what you need, but aeolus-image will need
to do a good bit more iwhd interaction to implement these commands
Cheers,
Mark.