Categories

ID #1101

How do I know when a clone operation has completed?

We would like to know when exactly the clone of an image has completed. This is so we can automate some image update and test processes. Ie: we clone an image, apply updates to the clone, assign that updated image to a category, and reboot a node for testing the updated image.

However, the current "clone/commit" process goes into the background. This makes programmatically determining when it finished rather difficult. Can we make the commit of an image clone wait for completion in the cmsh shell so our script will wait before attempting to apply updates?

 

In 6.0 the --wait option to the commit command makes cmsh wait for any background task to complete. A list of tasks that are waiting for completion can be seen with cmsh -A -c "task list"

For versions of BCM prior to 6.0, the following technique can be used:


The CMDaemon will not start the background copy operation if the target directory already exists. So what you can do from a bash script is something like this:


cp -a /cm/images/default-image /cm/images/new-image
cmsh -c "softwareimage; clone default-image new-image; commit"

 

The first line guarantees the copy is done (and exits after the cp is done). That means that the second line  does pretty much nothing except for housekeeping, which lets cmd then know of new-image. In particular for the second line, cloning, which normally runs in the background to carry out the copy, doesn't do any copying because that was already done.

 

Applying updates to the images can then be carried out without needing to test if the clone has completed.

 

Tags: -

Related entries:

You cannot comment on this entry