Skip to content

Vm template development

Carolina Fernández edited this page Apr 23, 2014 · 8 revisions

This guide considers that the code of Expedient, VT AM and Agent was already modified accordingly. In order to integrate a new VM template with OFELIA LDAP and address schema, these are the steps to follow:

In Expedient (vt_plugin)

  • In src/python/plugins/vt_plugin/controller/VMcontroller/VMcontroller.py add the new VM case:

       if instance.disc_image == 'IMAGE_NAME':
            instance.operatingSystemType = 'GNU/Linux'
            instance.operatingSystemVersion = '7.0'
            instance.operatingSystemDistribution = 'Debian'
            instance.hdOriginPath = "PATH_TO_TAMPLATE_IMAGE"
            instance.virtualization_setup_type = "hvm"
    
  • In ./src/python/plugins/vt_plugin/models/VM.py: Change de following definitions accordingly

DISC_IMAGE_CHOICES = ( ('default','Default'), ('spirent','Spirent'), ('irati','IRATI'), ) HD_SETUP_TYPE_CHOICES = ( ('file-image','File Image'), #('logical-volume-image','Logical Volume'), ('full-file-image','File Image with Partitions'), ) VIRTUALIZATION_SETUP_TYPE_CHOICES = ( ('paravirtualization','Paravirtualization'), ('hvm','HVM'), ) ```

  • In ./views/templates/default/vt_plugin_aggregate_add_virtualmachines.html: If you need to restrict the available options for the new vm add a case for it:

                        } else if ($("#id_disc_image").val() == "irati") {
                                $("#id_hdSetupType").val("full-file-image");
                                $("#id_virtualizationSetupType").val("hvm");
                                $("#id_memory").val("1024");
                                $("#id_hdSetupType").prop("disabled","disabled");
                                $("#id_virtualizationSetupType").prop("disabled","disabled");
    

In VT Manager

  • In ./src/python/vt_manager/models/XenVM.py: Add the configurator if an specific one is needed:

IMAGE_CONFIGURATORS = { 'default/default.tar.gz':'', 'irati/irati.img':'IratiDebianVMConfigurator', 'spirent/spirentSTCVM.img':'SpirentCentOSVMConfigurator', } ```

##In the OFELIA XEN AGENT (OXA)

  • In /src/python/agent/xen/provisioning/hdmanagers/ Develope or modify a new HD Manager (/src/python/agent/xen/provisioning/hdmanagers/) and/or VM configurator and Xen config template file (/src/python/agent/xen/provisioning/configurators/)

  • Update the VMConfigurator file (xen/provisioning/VMConfigurator.py) with your new Configurator:

if configurator and configurator != "": if configurator == MediacatVMConfigurator.getIdentifier(): return MediacatVMConfigurator; elif configurator == IratiDebianVMConfigurator.getIdentifier(): return IratiDebianVMConfigurator; elif configurator == SpirentCentOSVMConfigurator.getIdentifier(): return SpirentCentOSVMConfigurator; elif configurator == DebianWheezyVMConfigurator.getIdentifier(): return DebianWheezyVMConfigurator ```

  • If the image you want add is using the FileFullHdManager (xen/provisioning/hdmanagers/FileFullHdManager.py), you may want to configure the offset of your image:

if vm.xen_configuration.configurator == IratiDebianVMConfigurator.getIdentifier(): FileFullHdManager.subprocessCall('/bin/mount -o loop,offset=44040192 '+str(vm_path)+" "+str(path)) ```

VM integration

  1. Convert the VM image to .img format
  2. If you want to use some Debian distro, you may create it through Xen...:
xen-create-image --hostname <hostname> --ip <ip> [ --vcpus 2 --pygrub \
--dist <lenny|squeeze|maverick|whatever> --size=<size>Gb \
--swap=<size>Gb --netmask=<netmask> --memory=<size>Mb \
--gateway=<gateway> --force ]
  1. ...And convert with the dd tool:
dd if=/dev/vserv/<vm_name>-disk of=<vm_name>.img
  1. Mount the VM image
  2. If you want to run it through Xen:
```
xm create /etc/xen/<vm_name>.cfg
```

For the config file to work you shall define the routes to the physical files `<vm_name>.img` and `<vm_name>_swap.img` first. You can use the config file generated in step _1.i_ for inspiration
  1. Install ldap module: apt-get install pam_ldap
  2. Replace the following files of the new image with the ones of a default OFELIA image:
  • /etc/pam.d
  • /etc/pam.conf
  • /etc/nsswitch.conf
  • /etc/nslcd.conf (this one may be missing)
  • /etc/nscd.conf
  1. Create ofelia/users folder: mkdir -p /ofelia/users
  2. Edit /etc/resolv.conf to have only https://ldap.ibbt.fp7-ofelia.eu
  3. Empty any logs or existing users if desired
  4. Unmount, i.e. stop the image at Xen
  5. Use the existing .img file as your new template
Clone this wiki locally