SmartDomains tutorial

SmartDomains is a tool for automated deployment and management of distributed Xen virtual machines.
Project page
Project authors: Olivier Pernet and Xavier Grehant.
Developed as part of Grid IC projects of CERN openlab second phase.

This tutorial: Xavier Grehant (xagATcernDOTch)
In sync with revision 127 (release 0.9.08)

SmartDomains is a showcase of SmartFrog, a framework for distributed configuration and deployment developed at HP Labs.

Contents


Describe a pool of virtual domains


A local pool with minimal attributes

localVirtualPool.sf describes a pool of 2 virtual domains to be deployed on the same machine: domain1 and domain2. The file's content is displayed below:

#include "org/smartfrog/components.sf" #include "ch/cern/openlab/smartdomains/components.sf" #include "org/smartfrog/services/shellscript/components.sf" #include "ch/cern/openlab/util/schemas.sf" DefaultXenDomain extends XenDomain { shell LAZY ATTRIB myShell; kernel "/boot/vmlinuz-2.6-xen"; gateway "999.999.1.1"; netmask "255.255.0.0"; } sfConfig extends Compound { sfSyncTerminate true; myShell extends BashShell; loop extends LoopbackStorageBackend { shell LAZY ATTRIB myShell; domainName "domainLoopback"; baseImage "/data/xen/slc3-smartfrog.img"; } domain1 extends DefaultXenDomain { domainName "domainLoopback"; // useless since rev 84 / release 0.9.02 ip "999.999.999.999"; hostname "machine9-dom1"; storageBackend LAZY ATTRIB loop; } lvm extends LVMStorageBackend { shell LAZY ATTRIB myShell; domainName "domainLVM"; baseImage "/data/xen/slc3-smartfrog.img"; } domain2 extends DefaultXenDomain { domainName "domainLVM"; // useless since rev 84 / release 0.9.02 ip "999.999.999.998"; hostname "machine9-dom2"; storageBackend LAZY ATTRIB lvm; } }

This description illustrates the 3 base components you can manipulate in a SmartDomains description: XenDomain, LVMStorageBackend and LoopbackStorageBackend. A virtual domain is described by extending a XenDomain component. In this description, our two virtual domains have some attributes in common. We factorized these attributes in DefaultXenDomain.

To clarify the meaning of extends, let's just observe that the description of domain1 in localVirtualPool.sf is equivalent to the one below:

domain1 extends XenDomain { shell LAZY ATTRIB myShell; kernel "/boot/vmlinuz-2.6-xen"; gateway "999.999.999.999"; netmask "255.255.0.0"; domainName "domainLoopback"; // useless since rev 84 / release 0.9.02 ip "999.999.999.999"; hostname "machine9-dom1"; storageBackend LAZY ATTRIB loop; }

In localVirtualPool.sf, loop is the StorageBackend of domain1, and lvm the StorageBackend of domain2: they handle guest filesystems setup (resp. teardown) on the physical host before (resp. after) guest domains being started (resp. shutdown). domain1 will run on a logical volume, and domain2 on a loopback-mounted image file.

Some if this description's attributes are self-explanatory: kernel, gateway, netmask, baseImage, ip, hostname, domainName. They need to be customized according to your infrastructure.

Understanding attributes sfSyncTerminate, shell and StorageBackend probably requires more explanations:

A distributed deployment

distVirtualPool.sf launches virtual domains on remote physical machines, and the management console on the host specified in sfStart command. Changes with regards to localVirtualPool.sf are displayed below.

#include ... #include "org/smartfrog/services/management/components.sf" DefaultXenDomain extends XenDomain {...} PhysicalHost extends Compound { sfSyncTerminate true; myShell extends BashShell; } sfConfig extends Compound { sfSyncTerminate true; console extends DeployManagement; computer1 extends PhysicalHost { sfProcessHost "machine9.cern.ch"; loop extends LoopbackStorageBackend {...} domain1 extends DefaultXenDomain {...} lvm extends LVMStorageBackend {...} domain2 extends DefaultXenDomain {...} } computer2 extends PhysicalHost { sfProcessHost "machine10.cern.ch"; lvm extends LVMStorageBackend {...} domain2 extends DefaultXenDomain {...} } }

sfProcessHost takes either a hostname or an ip address. A component with this attribute will be deployed on the designated host, as well as its children components (attributes in the description) and recursively their descendants.

Using all attributes

remoteConfig.sf, defaultPool.sf and selection.sf together describe a single virtual machine deployment on a remote host. This example shows other self-explanatory SmartFrog language tricks, as well as other attributes for base SmartDomains components. defaultPool.sf contains default components for possible use in sfConfig through a direct include of selection.sf. To launch the example after adapting values to your setup, you need to call sfStart command on the file that contains sfConfig: remoteConfig.sf.

We provide here a list of attributes that must/can be defined in using base SmartDomains components.

Runtime update

Using the management console, it is possible to modify, add or delete at run-time attributes that affect the component only on termination. The snapshot below was taken from the deployment described in previous paragraph.