Archive

Archive for the ‘Articles’ Category

Creating Container Manually

February 15th, 2010 No comments

Creating Container

After the Container ID and the installed OS EZ template have been chosen, you can create the Container private area with the vzctl create command. The private area is the directory containing the VZFS symlinks, copy-on-write area, and private files of the given Container. The private area is mounted to the /vz/root/CT_ID directory on the Hardware Node and provides Container users with a complete Linux file system tree.

The vzctl create command requires only the Container ID and the name of the OS template as arguments; however, in order to avoid setting all the Container resource control parameters after creating the private area, you can specify a sample configuration to be used for your new Container. The sample configuration files are residing in the /etc/vz/conf directory and have names with the following mask: ve-<configname>.conf-sample. The most commonly used sample is the ve-basic.conf-sample file; this sample file has resource control parameters suitable for most Containers.

Thus, for example, you can create a new Container by typing the following string:

# vzctl create 101 –ostemplate redhat-el5-x86 -–config basic

Creating Container private area (redhat-el5-x86)

Container is mounted

Postcreate action done

Container is unmounted

Container private area was created

Delete port redirection

Adding port redirection to Container(1): 4643 8443

In this case, the Virtuozzo Containers software will create a Container with ID 101, the private area based on the redhat-el5-x86 OS EZ template, and configuration parameters taken from the ve-basic.conf-sample sample configuration file.

If you specify neither an OS template nor a sample configuration, vzctl will try to take the corresponding values from the global Virtuozzo configuration file (/etc/vz/vz.conf). So you can set the default values in this file using your favorite text file editor, for example:

DEF_OSTEMPLATE=”.redhat-el5-x86″

CONFIGFILE=”basic”

and do without specifying these parameters each time you create a new Container. Please keep in mind that the . symbol before the template name in the DEF_OSTEMPLATE parameter is used to indicate that the Container being created is to be based on an OS EZ template; otherwise, it will denote an OS standard template Now you can create a Container with ID 101 with the following command:

# vzctl create 101

Creating Container private area (redhat-el5-x86)

Container is mounted

Postcreate action done

Container is unmounted

Container private area was created

Delete port redirection

Adding port redirection to Container(1): 4643 8443

Source : parallels

Categories: Articles Tags:

LITE SPEED COMPARED TO APACHE WEB SERVER

September 17th, 2009 No comments

===========================

Advantages of using lite speed compared to apache:
===========================

1. Lite speed is 6 times faster than Apache.
2. When it comes to dynamic content, LiteSpeed is more than 50% faster in PHP content delivery than Apache with mod_php

3. Increases PHP performance and security while doubling server capacity.

4. Efficient CGI daemon

5. High performance Perl daemon

6. SECURE

* Strictest HTTP request validation
* Deny any buffer-overrun attempts
* Anti-DDoS: Throttling & Connection Accounting
* System overloading prevention
* Chroot web server process
* CGI/FCGI/LSAPI/PHP suEXEC
7.RELIABLE

* Watch Dog monitoring
* Recover from service failure instantly
* Zero down time graceful restart
8.SCALABLE

* Small memory footprint
* Thousands of concurrent connections
* Increase scalability of external web applications

9.LiteSpeed support a wide set of server API and scripting languages.

* CGI/1.1
* FastCGI
* LSAPI (LiteSpeed SAPI)
* JSP/Servlet via AJP 1.3
* Transparent Reverse Proxy (interface to any web server, application server support HTTP)
* PHP with 3rd party PHP Accelerators compatibilities (APC, eAccelerator, XCache).
* Perl/Python (CGI, FastCGI)
* Ruby/Roby on Rails
* C/C++ (CGI, FastCGI, LSAPI)
So, for shared hosting environment better to go for lite speed web server.

Categories: Articles Tags:

PIM Resource Parameters Description

August 18th, 2009 No comments

Resource Parameters Description

The CPU-related resource management is based on the following parameters:

Parameter

Description

cpuunits

This is a positive integer number that determines the minimal guaranteed share of the CPU time your Container will receive.

cpulimit

This is a positive number indicating the CPU time in percent the corresponding Container is not allowed to exceed.

Linux burst_cpulimit

The CPU power limit, in percent, the Container cannot exceed. The limitations set in this parameter are applied to the Container when it exceeds the limit specified in the burst_cpu_avg_usage parameter.

Linux burst_cpu_avg_usage

The CPU usage limit, in percent, set for the Container. This limit is calculated as the ratio of the current Container CPU usage to the CPU limit (i.e to the value of the CPULIMIT parameter) set for the Container. If the limit is not specified, the full CPU power of the Hardware Node is considered as the CPU limit. Upon exceeding the burst_cpu_avg_usage limit, the burst_cpulimit limit is applied to the Container.

Windows cpuguarantee

This is a positive integer number indicating the CPU time, in percent, the corresponding Container is guaranteed to receive. If both the cpuguarantee and cpuunits parameters are set, the cpuguarantee parameter is first taken into account when distributing processor(s) time among the Containers existing on the Node; the remaining CPU time, if any, is given to the Containers in accordance with the value of the cpuunits parameter.

cpus

The number of CPUs set to handle all the processes inside the given Container. By default, any Container is allowed to consume the CPU time of all processors on the Node.

The disk-related resource management is based on the following parameters:

Parameter

Description

diskspace

Total size of disk space consumed by the Container.

Linux When the space used by the Container hits the soft limit, the Container can allocate additional disk space up to the hard limit during the grace period indicated by the quotatime parameter value.

Linux diskinodes

Total number of disk inodes (files, directories, and symbolic links) allocated by the Container. When the number of inodes used by the Container hits the soft limit, the Container can create additional inodes up to the hard limit during the grace period indicated by the quotatime parameter value.

Linux quotaugidlimit

Number of user/group IDs allowed for the Container internal disk quota. If set to 0, UID/GID quota will not be enabled.

Linux quotatime

The grace period for the disk quota overusage defined in seconds. The Container is allowed to temporarily exceed its quota soft limits for no more than the QUOTATIME period.

Linux ioprio

The Container priority for disk I/O operations. The allowed range of values is 0-7. The greater the priority, the more time the Container has for writing to and reading from the disk. The default Container priority is 4.

The memory-related resource management parameters are divided into 4 groups: memory parameters, primary system parameters, secondary system parameters, and auxiliary system parameters.

Windows Windows-based Containers use only the primary system parameters.

Linux For Linux-based Containers, this screen displays the memory-based, or the system-based, or both memory- and system-based Container resources data, depending on your settings:

* If the memory management mode is enabled for the Container, it can be allocated memory in much the same way as a certain amount of physical memory is installed on a physical computer. This is the recommended mode for managing Containers for most administrators.
* If the system management mode is enabled, the Container’s performance depends on the values of quite a number of fine-grained parameters. The primary parameters are the starting point for defining the relative power of a Container. The secondary parameters are dependent on the primary ones and are calculated from them according to a set of constraints. The auxiliary parameters help improve fault isolation among applications in a Container and the way applications handle errors and consume resources.
* If both resource management modes are used, the more restrictive value is taken into account each time the system makes the decision whether to allocate this or that resource to the Container.

Linux Memory parameters

Parameter

Description

slmmemorylimit

An approximation of the size of the physical memory allocated to the Container. In other words, the Container performance is similar to the performance of a physical computer with as much physical memory installed as is indicated in this parameter.

Primary system parameters

Parameter

Description

numproc

The maximal number of processes the Container may create.

Windows numsessions

The number of simultaneous terminal sessions that can be opened to the Container.

Windows vprvmem

The size of private (or potentially private) memory allocated by the Container. The memory that is always shared among different applications is not included in this resource parameter.

Linux numtcpsock

The number of TCP sockets (PF_INET family, SOCK_STREAM type). This parameter limits the number of TCP connections and, thus, the number of clients the server application can handle in parallel.

Linux numothersock

The number of sockets other than TCP ones. Local (UNIX-domain) sockets are used for communications inside the system. UDP sockets are used, for example, for Domain Name Service (DNS) queries. UDP and other sockets may also be used in some very specialized applications (SNMP agents and others).

Linux vmguarpages

The memory allocation guarantee, in pages. Container applications are guaranteed to be able to allocate additional memory so long as the amount of memory accounted as privvmpages (see the auxiliary parameters) does not exceed the configured barrier of the vmguarpages parameter. Above the barrier, additional memory allocation is not guaranteed and may fail in case of overall memory shortage.

Linux avnumproc

The average number of processes and threads.

Linux Secondary system parameters

Parameter

Description

kmemsize

The size of unswappable kernel memory allocated for the internal kernel structures for the processes of a particular Container.

Note: For the Virtuozzo Containers 64-bit version for IA-64 processors, it takes 4 (four) times more the size of the kernel memory than that for the Virtuozzo Containers 32-bit version to handle one and the same process.

tcpsndbuf

The total size of send buffers for TCP sockets, i.e. the amount of kernel memory allocated for the data sent from an application to a TCP socket, but not acknowledged by the remote side yet.

tcprcvbuf

The total size of receive buffers for TCP sockets, i.e. the amount of kernel memory allocated for the data received from the remote side, but not read by the local application yet.

othersockbuf

The total size of UNIX-domain socket buffers, UDP, and other datagram protocol send buffers.

dgramrcvbuf

The total size of receive buffers of UDP and other datagram protocols.

oomguarpages

The out-of-memory guarantee, in pages. Any Container process will not be killed even in case of heavy memory shortage if the current memory consumption (including both physical memory and swap) does not reach the oomguarpages barrier.

privvmpages

The size of private (or potentially private) memory allocated by an application. The memory that is always shared among different applications is not included in this resource parameter.

Linux Auxiliary system parameters

Parameter

Description

lockedpages

The memory not allowed to be swapped out (locked with the mlock() system call), in pages.

shmpages

The total size of shared memory (including IPC, shared anonymous mappings and tmpfs objects) allocated by the processes of a particular Container, in pages.

numfile

The number of files opened by all Container processes.

numflock

The number of file locks created by all Container processes.

numpty

The number of pseudo-terminals, such as an ssh session, screen or xterm applications, etc.

numsiginfo

The number of siginfo structures (essentially, this parameter limits the size of the signal delivery queue).

dcachesize

The total size of dentry and inode structures locked in the memory.

numiptent

The number of IP packet filtering entries.

Source : PIM DOCS

Categories: Articles Tags:

vps command line usage

February 24th, 2009 No comments

Hi,

Some vps command line usage commands:
Add a domain from the command line

/script/add –class=domain –name=testdomain4.com v-docroot=testdomain.com/curent/public –v-password=xyz –v-dnstemplate_name=default.dnst

Delete a client who has no domains:

/script/update –class=client –name=testclient –action=delete

Vps that uses the maximum traffic by using this:

/script/filter/vps-sort-traffic | head -1

Vpses that have gone overquota re traffic.

/script/filter/vps-overquota-traffic

To add a simple cron job, that’s executed either  ‘every-hour’ every-day  with an  cron_day_hour  also specified.

/script/add –parent-class=client –parent-name=admin –class=cron –v-ttype=simple –v-simple_cron=every-day –v-cron_day_hour=6 –v-command=”ls -al”

Categories: Articles Tags:

Oracle 10g VE

December 31st, 2008 No comments

Create the container on the Host system

vzctl create 1001 --ostemplate centos-4-i386-default
vzctl set 1001 --userpasswd root:password --save
vzctl set 1001 --hostname ve-oracle.example.com --save
vzctl set 1001 --ipadd 192.168.0.62 --save

Reset resource limits

I decided to have max limits to avoid problems during installation. Once the installation is done and the system left running for some time, these limits should be adjusted.

Note: setting the UBC limits to “unlimited” value like below can only be done on a trusted single-container machine, and can create problems. For more info about UBC, see Resource shortage and UBC.

Warning: The above UBC values might not be consistent; see UBC consistency check.

vzctl set 1001 --kmemsize unlimited --save
vzctl set 1001 --lockedpages unlimited --save
vzctl set 1001 --privvmpages unlimited --save
vzctl set 1001 --shmpages unlimited --save
vzctl set 1001 --numproc unlimited --save
vzctl set 1001 --numtcpsock unlimited --save
vzctl set 1001 --numflock unlimited --save
vzctl set 1001 --numpty unlimited --save
vzctl set 1001 --numsiginfo unlimited --save
vzctl set 1001 --tcpsndbuf unlimited --save
vzctl set 1001 --tcprcvbuf unlimited --save
vzctl set 1001 --othersockbuf unlimited --save
vzctl set 1001 --dgramrcvbuf unlimited --save
vzctl set 1001 --numothersock unlimited --save
vzctl set 1001 --dcachesize unlimited --save
vzctl set 1001 --numfile unlimited --save
vzctl set 1001 --numiptent unlimited --save

Or you can set these limits in your /etc/vz/conf/1001.conf file:

Note : The above UBC values might not be consistent; see UBC consistency check.

# Primary parameters
AVNUMPROC="unlimited"
NUMPROC="unlimited"
NUMTCPSOCK="unlimited"
NUMOTHERSOCK="unlimited"
VMGUARPAGES="unlimited"

# Secondary parameters
KMEMSIZE="unlimited"
TCPSNDBUF="unlimited"
TCPRCVBUF="unlimited"
OTHERSOCKBUF="unlimited"
DGRAMRCVBUF="unlimited"
OOMGUARPAGES="unlimited"

# Auxiliary parameters
LOCKEDPAGES="unlimited"
SHMPAGES="unlimited"
PRIVVMPAGES="unlimited"
NUMFILE="unlimited"
NUMFLOCK="unlimited"
NUMPTY="unlimited"
NUMSIGINFO="unlimited"
DCACHESIZE="unlimited"

PHYSPAGES="unlimited"
NUMIPTENT="unlimited"

Start the container

vzctl start 1001

Update /etc/resolv.conf on the container

Put the following into your container’s /etc/resolv.conf:

search example.com
nameserver <ip address of your name server>

Install Required Packages

vzyum 1001 install binutils compat-db gcc gcc-c++ glibc \
 glibc-common libstdc++ libstdc++-devel gnome-libs make \
 pdksh sysstat libaio xscreensaver openmotif21 xorg-x11-xfs \
 usbutils urw-fonts shared-mime-info perl-libwww-perl \
 perl-XML-Parser perl-URI perl-HTML-Tagset perl-HTML-Parser \
 patch lvm2 intltool libIDL libart_lgpl libbonobo xterm \
 libcap libcroco libgnomecanvas libexif libgnomecups \
 libgnomeprint22 libsoup libwnck libxklavier

Check the following rpms are installed on the container

vzctl exec 1001 rpm -q binutils gcc gcc-c++ glibc gnome-libs \
 libstdc++ libstdc++-devel make pdksh sysstat xscreensaver libaio

Add Oracle User/Group

vzctl exec 1001 /usr/sbin/groupadd oinstall
vzctl exec 1001 /usr/sbin/groupadd dba
vzctl exec 1001 /usr/sbin/useradd -m -g oinstall -G dba oracle
vzctl exec 1001 id oracle

Set Password for the Oracle user

vzctl exec 1001 passwd oracle

Create Directories for Oracle Home/Data and the download directory

vzctl exec 1001 mkdir /home/oracle/10gR2_db
vzctl exec 1001 mkdir -p /u01/app/oracle/product/10.2.0/db_1
vzctl exec 1001 mkdir /u01/app/oracle/oradata
vzctl exec 1001 chown -R oracle:oinstall /u01/app/oracle /home/oracle/10gR2_db
vzctl exec 1001 chmod -R 775 /u01/app/oracle /home/oracle/10gR2_db
vzctl exec 1001 ln -s /usr/lib/libstdc++.so.6.0.3 /usr/lib/libstdc++.so.5

Put these values in /etc/sysctl.conf on the HN

Put these values in /etc/sysctl.conf on the HN:

kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default=262144
net.core.wmem_default=262144
net.core.rmem_max=262144
net.core.wmem_max=262144

Then execute on the HN the following command:

/sbin/sysctl -p

At this point the container is ready for Oracle installation. We take a backup of the container at this point in case we need to rebuild the system or do a clean Oracle install.

Shutdown the container and take a backup

vzctl stop 1001
cd /u01/backups
tar czpvf ve-1001-preOracle.tar.gz /vz/private/1001/ /etc/vz/conf/1001.conf

Start the container again

vzctl start 1001

Put oracle distro into the container

Copy the downloaded Oracle zip file to the container and change its ownership to “oracle” on the container.

cp /u01/software/10201_database_linux32.zip /vz/private/1001/home/oracle/10gR2_db/
vzctl exec 1001 chown oracle:oinstall /home/oracle/10gR2_db/10201_database_linux32.zip

Start installation

Now login as oracle on the ve-1001, and run the following commands:

cd /home/oracle/10gR2_db
unzip 10201_database_linux32.zip
cd database/
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
export DISPLAY=192.168.0.149:0

Make sure you can run xterm, then:

./runInstaller

When prompted to run scripts as root. Login as root and execute

export DISPLAY=192.168.0.149:0
/u01/app/oracle/oraInventory/orainstRoot.sh
/u01/app/oracle/product/10.2.0/db_1/root.sh

Update oracle’s profile with the following

cd
vi /home/oracle/.bashrc
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=orcl

Delete installation files (optional)

cd /home/oracle/10gR2_db
rm -rf database

Time to take another backup of the container on the hardware node.

This backup will allow you to restore the container to the point where no database has yet been created.

vzctl stop 1001
cd /u01/backups
tar czpvf ve-1001-postOracleSoftware.tar.gz \
  /vz/private/1001/ /etc/vz/conf/1001.conf

Start the container

vzctl start 1001

Login as oracle and create the database

export DISPLAY=192.168.0.149:0
dbca

Create listener

netca

Now take another backup on the HN node

vzctl stop 1001
cd /u01/backups
tar czpvf ve-1001-postOracleDatabase.tar.gz \
  /vz/private/1001/ /etc/vz/conf/1001.conf

Source : wiki.openvz.org.
Categories: Articles Tags:

firewall for vps

December 25th, 2008 No comments

You can protect your HyperVM node (Master or slave) by adding the ConfigServer Security and Firewall.

Here’s howto:

wget http://www.configserver.com/free/csf.tgz
tar -zxvf csf.tgz
cd csf
ls
./install.sh

Once it has been installed, you’ll need to configure it correctly before use, or you’ll have some really weird problems.

Ok, so the configuration file is /etc/csf/csf.conf, edit with your favourite editor:

Leave ETH_DEVICE blank, CSF will work this out on it’s own.

Modify the following lines as follows: (These can be customized as per your own requirements, the 777*, 888* and 5558 ports are required for HyperVM to work)

# Allow incoming TCP ports
TCP_IN = “25,53,110,953,993,995,22,7776,7777,7778,7779,8886,8887,8888,8889,5558″
# Allow outgoing TCP ports
TCP_OUT = “25,53,80,110,113,443,953,7776,7777,7778,7779,8886,8887,8888,8889,5558″

If you want to be able to ping your HyperVM node, set:

# Allow incoming PING
ICMP_IN = “1″

Save and exit /etc/csf/csf.conf

If you’re using openvz in your node, you’ll have to add the following into /etc/csf/csfpre.sh

iptables -A INPUT -i venet0 -j ACCEPT
iptables -A OUTPUT -o venet0 -j ACCEPT
iptables -A FORWARD -j ACCEPT -p all -s 0/0 -i venet0
iptables -A FORWARD -j ACCEPT -p all -s 0/0 -o venet0

Note 1: The /etc/csf/csfpre.sh will probably not exist, you’ll have to create it. csfpre.sh will be executed each time before csf starts.

Note 2: I’ve added (cd /usr/local/lxlabs/hypervm/httpdocs/ ; lphp.exe ../bin/misc/openvz-iptables-traffic.php) to the top of my csfpre.sh due to the traffic calculations, yet I think something else is wrong… I’ll update this once I figured it out.

You are now ready to begin testing… run from the command line:

service csf start

Once you are happy with the configuration and everything works as you wish, disable the testing mode:

# Testing flag - enables a CRON job that clears iptables incase of
# configuration problems when you start csf. This should be enabled until you
# are sure that the firewall works - i.e. incase you get locked out of your
# server! Then do remember to set it to 0 and restart csf when you’re sure
# everything is OK. Stopping csf will remove the line from /etc/crontab
TESTING = “0″

Productionize with:

service csf restart

You are done.

Additionally you can disable disable process tracking and user process tracking by setting (in the csf.conf):

PT_USERTIME = “0″
PT_LIMIT = “0″
PT_USERPROC = “0″

Source : lxwiki

Categories: Articles Tags:

Guaranteed memory and burstable memory.

December 17th, 2008 No comments

Guaranteed memory is defined as the usable memory out of the memory available in VPS. This is available for the user at all time. Very often this guaranteed memory can be changed to burstable memory by the VPS.

Burstable memory set a maximum limit for the memory available where as guaranteed memory is a minimum limit. That is, even if the guaranteed memory is exhausted, the users of VPS can use the memory up to the limit of burstable memory. The simplest example to understand the difference is: if the guaranteed memory of a VPS is 256mb and the burstable memory limit is 1024 mb, the users can use the remaining 768MB RAM once their guaranteed memory is completely used up. This is possible only if the host server has that much memory available with it.

It is always a procedure to keep certain part of the memory in host server as burstable. This can be used by the virtual servers when they are in need of extra memory. Also the guaranteed memory unused in any virtual server can be used by other virtual servers when they want burstable memory. It is known that guaranteed memory should be available for use for the virtual servers. So when they are in need of guaranteed RAM, they usually kill the processes that use their memory as burstable to get the memory released. So it is always better not to use the burstable memory unless it is so needed.

When trying to get a VPS server, it should be clearly understood that the memory availability that they demand is not burst memory. The guaranteed memory must be available in sufficient amount to get proper working in VPS. The memory burstable is not readily available always as it can be obtained only on a lapse of guaranteed memory by other virtual servers in the system.

Categories: Articles Tags:

Is a VPS Right For Me

December 17th, 2008 No comments

Virtual private server is the technique of splitting the physical server into many virtual servers to get multiple servers. This is mainly a cost effective technique. The physical servers are really very costly. So when these can be split to many logical servers, the cost remains the same of getting a physical server. But at the same time, there are many servers available. This is mainly useful in the hosting of web sites. So the users often come up with the doubt of whether VPS is a best choice for them. It is essential to understand the scenario to answer the question.

VPS is ideal for those web developers who are technically advanced. Those who require access to the root server for their administrative purposes can go for a VPS hosting service. They aim at getting total control over the system.

Those who want a control over the resources in the server can opt VPS. The control over space and the programs necessarily requires the system to be VPS. The users can allocate the resources as per the availability when he can carry out the administration of the environment.

If you want to start a hosting company aiming at making profit in your business, then VPS is a right choice for you.

Categories: Articles Tags:

Virtualization Types

November 19th, 2008 No comments

There are several different forms of virtualization that need to be understood as a basis for making the right technology choice.

  • Server Hardware Virtualization. Also known as a hypervisor, Server Hardware Virtualization runs a very lightweight core operating system. The hypervisor can host independent virtual machines (VMs). This form of virtualization requires hardware that has embedded virtualization awareness capabilities. Since the hypervisor is very lightweight, there is little overhead in the system, which allows for more scalability in the virtual machines.
  • Server Software Virtualization. An operating system, such as Windows Server® 2003 or Windows Server 2008, runs an application that is able to host virtual machines. Each virtual machine runs a completely separate operating system and application set.
  • Presentation Virtualization. Centralized systems host multiple user sessions, and all processing is done on those host systems. The user sessions are isolated from each other. Only the presentation information, such as keyboard and mouse inputs, and video updates are sent between the client and the host system. The client can be a full Windows-based workstation or a Windows-based terminal device.
  • Application Virtualization. An application is isolated from the underlying operating system by means of wrapper software that encapsulates it. This allows multiple applications that may have conflicting dynamic link libraries (DLLs) or other incompatibilities to run on the same machine without affecting each other.
  • Desktop Virtualization. This is similar to Server Software Virtualization, but it runs on client systems such as Windows Vista®. The client operating system runs a virtualization application that hosts virtual machines. This is often used when a specific person needs to run one or a limited number of legacy applications on a legacy operating system.
Categories: Articles Tags:

Creating a Virtuozzo Container

November 19th, 2008 No comments

When creating a new Virtuozzo Container, the following configuration parameters are mandatory and must be selected every time:

  • Sample configuration name. Virtuozzo Containers software comes with a set of sample configurations that are installed on the Hardware Node at the time the Virtuozzo Containers software is installed. XML API provides the env_samplem/get_sample_conf call to retrieve the list of the available configurations. In the example provided in this section, the C# equivalent of that call is the env_samplemBinding.get_sample_conf() method.
  • Operating System Template. The list of the available templates can be retrieved using the vzapkgm.get_list XML API call. The C# equivalent is vzapkgmBinding.get_list call. For simplicity, we are not including this call in the example because Virtuozzo Containers for Windows currently comes with just one OS template, and Virtuozzo for Linux has one template for each supported Linux distribution. For example, the standard Red Hat Linux OS template name is redhat-as3-minimal.

The rest of the parameters that we use in this example are optional but are typically used when a new Container is created. The following sample shows how to create a Virtuozzo Container.

Sample Function Parameters:

Name

Description

name

The name that you would like to use for the Container.

os_template

The name of the OS template to use for the Container.

platform

Operating system type: linux or windows. This parameter will be used in our function to select a sample configuration for the Container. If the sample configuration is compatible with the specified platform, we will use it. In a real application, you would probably select the sample configuration in advance and would pass its name to the method that actually creates a Container. In this example, we automate this task while providing a demonstration of how to retrieve the list of the available sample configurations.

architecture

CPU architecture, e.g. x86, ia64. This parameter, together with the platform parameter (above) will also be used to determine the sample configuration compatibility with the specified CPU architecture.

hostname

The hostname that you would like to use for the Container.

ip

The IP address to assign to the Container.

netmask

Netmask.

network

Network interface ID: venet0 for Linux; venet1 for Windows. These are the standard host-routed Virtuozzo network interfaces. For other network configuration scenarios, please refer to Parallels Agent XML Programmer’s Reference.

offline_management

Specifies whether to turn the Container Offline Management feature on or off.

Sample Function:

/// <summary>

/// Sample function CreateCT.

/// Creates a new Virtuozzo Container.

/// </summary>

/// <param name=”name”>Container name.</param>

/// <param name=”os_template”>OS template name.</param>

/// <param name=”platform”>Operating system type: linux or windows.</param>

/// <param name=”architecture”>CPU architecture (x86, ia64)</param>

/// <param name=”hostname”>Container hostname.</param>

/// <param name=”ip”>Container IP address.</param>

/// <param name=”netmask”>Netmask.</param>

/// <param name=”network”>Network interface ID.</param>

/// <param name=”offline_management”>

/// A flag specifyin whether to turn the “offline management”

/// feature on or off.

/// </param>

/// <returns>Server ID of the new Container.</returns>

public string CreateCT(string name, string os_template, string platform, string architecture, string hostname, string ip, string netmask, string network, bool offline_management)

{

try {

// Instantiate the proxy class.

vzaenvmBinding env = (vzaenvmBinding)binder.InitBinding(typeof(vzaenvmBinding));

// The main input object.

create create_input = new create();

// Container configuration information.

venv_configType1 veconfig = new venv_configType1();

/* Retrieve the list of sample configurations.

* Select the first one that is compatible with the

* specified platform (Linux, Windows) and CPU architecture.

*/

env_samplemBinding env_sample = (env_samplemBinding)binder.InitBinding(typeof(env_samplemBinding));

get_sample_conf get_sample = new get_sample_conf();

sample_confType[] samples = env_sample.get_sample_conf(get_sample);

if (samples != null) {

foreach (sample_confType sample in samples) {

if (sample.env_config.os != null) {

if (sample.env_config.os.platform == platform && sample.env_config.architecture == architecture) {

// Set sample configuration ID.

veconfig.base_sample_id = sample.id;

break;

}

}

}

}

// Set OS template.

templateType osTemplate = new templateType();

osTemplate.name = os_template;

veconfig.os_template = osTemplate;

// Set Container name

veconfig.name = name;

// Set Container hostname

veconfig.hostname = hostname;

// Set Container IP address and netmask.

ip_addressType[] ip_address = new ip_addressType[1];

ip_address[0] = new ip_addressType();

ip_address[0].ip = ip;

ip_address[0].netmask = netmask;

// Set network.

net_vethType[] net = new net_vethType[1];

net[0] = new net_vethType();

net[0].host_routed = new object();

net[0].id = network;

net[0].ip_address = ip_address;

veconfig.net_device = net;

// Set the offline management feature.

veconfig.offline_managementSpecified = true;

veconfig.offline_management = offline_management;

// Finalize the new Container configuration.

create_input.config = veconfig;

// Create the Container.

return env.create(create_input).env.eid;

}

catch (Exception e) {

return “Exception: ” + e.Message;

}

}

The function invocation example:

createCT(”sample_ve”, “redhat-as3-minimal”, “linux”,”x86″, “sample_ve_hostname”, “10.16.3.179″, “255.255.255.0″, “venet0″, true );

Categories: Articles Tags: