Resource Manager (bash)

Resource Manager is composed by rm.sh, ImageManager_constructor.sh, ImageManager_basecreator.sh, ImagaManager_cache.sh and pool.Env.cfg bash files. The main file is rm.sh and this call ImageManager_constructor.sh, ImageManager_basecreator.sh or ImagaManager_cache.sh. Theese four bash files shares PoolEnv.cfg that contains variables description, default parameters, domains defaults settings, resource fabrics parameters and folders.

To use this scripts only you need to call rm.sh. This has a usefull help guide if you put <rm.sh help>

$ ./rm.sh help
—————————————————————————

ImageManager base creator
—————————————————————————
onlybase:    create base system image files
onlykernel:  compile system image files (Especific for KVM)
base:     create base system image files and compile (only compile in KVM)

—————————————————————————
ImageManager cache
—————————————————————————
cache:       create base system cache files and new machine caches
cachefile:   create just some new machine cache file
cachefiles:  create the whole cache files
cachehome:   create home cache
cacheswap:   create swap cache

—————————————————————————
ImageManager constructor
—————————————————————————
create [DOMAINNAME] create and run a full new domain. Optional extra options:
–id                    ID
–mem              MEMORY
–cpu                NUMBEROFCPUS
–ip                   IP
–gw                GATEWAY
–bridge          NETWORKBRIDGE
–hypervisor TYPEOFVIRTUALMACHINE
construct:    construct files needed for a new domain. Uses same syntax as create.
run:          run an already created virtual machine
destroy:      destroy a whole domain, including creating files.
link:         creates a unified name from a HOST to a DOMAIN.
linklocal:    creating unified link of a domain
extensions:
save:         save the current state of a guest to a file
recover:      restore a domain
shutdown:     shutdown a domain preserving its disk images

—————————————————————————

Imagemanager_BaseCreator.sh

This script in bash creates a linux image to use in the creation of virtual machines. Creates a basic system with debootstrap and other linux commands. KVM image needs to download linux sources and compile this because KVM (kernel based) has different architectura than Xen (hypervisor based).

Main things used to create a base for KVM and XEN.
- dd
- mkfs.ext3
- mount -o loop $pool $MOUNT
- debootstrap –arch –include $DISTRO $MOUNT $MIRROR
- Base system instalation.
- Chroot: This changes the root directory of the current process and all downstream processes

Kernel compile only used by KVM.
- wget kernel source
- compiling

onlybase:     create base system image files.
onlykernel:  compile system image files (Especific for KVM)
base:              create base system image files and compile (only compile in KVM)‏


BaseCreator

ImageManager_Constructor.sh

This bash script is the most long. Theese have more methods. The main methods to create and manage virtual machines is create, run and destroy.

Run, destroy and others only call xen or libvirsh methods to do the functions and Create domain has a lot of things. Theese is showed in the next graphic.

create [DOMAINNAME] create and run a full new domain. Optional extra options:
–id                    ID
–mem              MEMORY
–cpu                NUMBEROFCPUS
–ip                   IP
–gw                GATEWAY
–bridge          NETWORKBRIDGE
–hypervisor TYPEOFVIRTUALMACHINE
construct:    construct files needed for a new domain. Uses same syntax as create.
run:               run an already created virtual machine
destroy:       destroy a whole domain, including creating files.
link:              creates a unified name from a HOST to a DOMAIN.
linklocal:    creating unified link of a domain
extensions:
save:                 save the current state of a guest to a file
recover:          restore a domain
shutdown:     shutdown a domain preserving its disk images

Create domain is complex. To understand this, you can see the next graphic.

Constructor

First of all, constructor.sh catch the base system to create a personalized Linux image to be used how virtual machine. This constructor.sh create a home, swap and image linux with remote certificates, users, specific software, java and utils. Too create a Network configuration. Finally construct and XML and/or CFG config file to be used to new Virtualization. This config file has the definitions and configurations about new Virtual Machine to create.

ImageManager_cache.sh

It is used in java project in VtM/disk/Cache.java and this Java file manages the creation of caches and has the next java functions.

createCacheExtensionImage(int num): Creates a cached image of the application image using an already existing copy.
createCacheBaseImage(int num): Creates a cached image of the base image using an already existing copy.
createCacheSwapImage(): Creates a cached image of the swap image using the Script Manager.
createCacheHomeImage(): Creates a cached image of the home image using the Script Manager.

ImageManager_cache use use the next linux commands:
dd
mkfs
mkswap
debootstrap

cache:   create base system cache files and new machine   caches
cachefile: create just some new machine cache file
cachefiles:     create the whole cache files
cachehome:  create home cache
cacheswap:   create swap cache


Architecture RM.sh and VtM.java

Maybe you have wondered why you need these files. VtM has a VtM.java file that use rm.sh to construct, run and destroy machines. Rm.sh can be used to bash shell or can be used by this java file that is helped with ScriptManager.java. VirtMonitor.java has a similar methods than Rm.sh.

ArchRMandVtM