IMG (Image Me Give) is a small python client/server application suite, its sole job is to get a POST'd kickstart file from a user and then run Moblin-Image-Creator. It is also possible to use kickstarter yaml files to create a tailor-made image or using the default selection of yaml templates.
The application consists of two parts, django frontend and the actual image creation application. Both of them are connected via AMQP, RabbitMQ is used as the server.
So an example workflow:
See boss_client.py for example BOSS client.
Usage: boss_client.py -t|--type <imagetype> -e|--email <author@email> -s|--submit -k <kickstart_file.ks>
boss_client.py Sends a message (poll for result later) to the BOSS, using <kickstart.ks> as the kickstart file.
Options: -h, --help show this help message and exit -s, --submit Submit to BOSS, takes no options -k KICKSTART, --kickstart=KICKSTART Kickstart file -t TYPE, --type=TYPE Image type -n NAME, --name=NAME Image name -e EMAIL, --email=EMAIL Author email
url(r'submit/$', 'meego_img.app.views.submit', name='img-app-submit'), url(r'queue/$', 'meego_img.app.views.queue', name='img-app-queue'), url(r'job/(?P<msgid>\S+)$', 'meego_img.app.views.job', name='img-app-job'), url(r'images/(?P<msgid>\S+)$', 'meego_img.app.views.download',name='img-app-download'),
IMG currently has only one model, !ImageJob, here is the Django code for it:
# Create your models here. class ImageJob(models.Model): email = models.CharField(max_length=40) filename = models.CharField(max_length=40) logfile = models.CharField(max_length=50) task_id = models.CharField(max_length=30) imagefile = models.CharField(max_length=50) created = models.DateTimeField(auto_now_add=True) error = models.CharField(max_length=500) type = models.CharField(max_length=10) status = models.CharField(max_length=30) def delete(self, *args, **kwargs): if self.logfile: if os.path.exists(self.logfile): os.remove(self.logfile) os.remove(self.logfile.replace("-log", "")) print "Removed %s"%self.logfile super(ImageJob, self).delete(*args, **kwargs)
As can be seen in the delete method, this model cleans up all image creation related files, like the kickstarter file and log file.
Contains the following fields
The configuration file is to be installed in /etc/imger/img.conf and a sample file is here.
base_url: A base URL that has a direct access to the base_dir via HTTP, example http://127.0.0.1 base_dir: A directory to put the finished images, example /var/www/images num_workers: Number of workers to start, OBSOLETE, USE INITSCRIPT OR MANUALLY RUN MANY PARTICIPANTS post_creation: Path to a script to run after the image is created use_kvm: Wether to use a virtual machine, values are "yes" or "no"
mic_opts: Example, mic_opts = --save-kernel, --use_comps, so comma separated options
amqp_host: Host that runs BOSS amqp_user: Username to tap into the BOSS virtual host amqp_pwd: Password amqp_vhost: The actual virtual host to connect to
Currently, IMGer can run the MIC2 jobs inside a KVM virtual machine, the only prerequisites are that image is located in /usr/share/img/base.img (configurable in the future) path and that the virtual machine has MIC2 installed and configured.
One must also confirm that the image SSH-keys in the source distribution are configured in the virtual machine and both keys exist in /usr/share/img (configurable in the future)
The following defines the input dictionary for the participant:
"kickstart" : a kickstart file, in raw, not a path "email": email address, not parsed so can be a dummy address "id": a simple UUID, eg. from pythons uuid library "type":type, from values: livecd, liveusb, loop, raw, nand, mrstnand, vdi or vmdk "name":name, a simple string for the image name
The work item can contain the following dictionary entries:
Status: Status, is either "DONE" or "ERROR" in the final workitem, depending on success/failure URL: URL to a image/log/kickstart file location on the worker Error: An error string with details of the error, if any Image: A direct URL to the finished image Log: A direct URL to the log file of the mic2 output