Sunday, July 19, 2009

VMware Perl toolkit tutorial (3) - variable

1. Scalar variables
Scalar variables hold both strings and numbers. Strings and numbers are inter-changable, but the variables should not start with a number and the variable $_ is special. For example:
$variable1 = 10; or
$variable2 = 'test';

The operations and assignment are the same as C. I found out this on the website, which can help us to understand the operation.
Perl uses all the usual C arithmetic operators:

$a = 1 + 2; # Add 1 and 2 and store in $a
$a = 3 - 4; # Subtract 4 from 3 and store in $a
$a = 5 * 6; # Multiply 5 and 6
$a = 7 / 8; # Divide 7 by 8 to give 0.875
$a = 9 ** 10; # Nine to the power of 10
$a = 5 % 2; # Remainder of 5 divided by 2
++$a; # Increment $a and then return it
$a++; # Return $a and then increment it
--$a; # Decrement $a and then return it
$a--; # Return $a and then decrement it

and for strings Perl has the following among others:

$a = $b . $c; # Concatenate $b and $c
$a = $b x $c; # $b repeated $c times

To assign values Perl includes

$a = $b; # Assign $b to $a
$a += $b; # Add $b to $a
$a -= $b; # Subtract $b from $a
$a .= $b; # Append $b onto $a

2. Array Variable
Array variables are prefixed by an @ symbol. The statement
@variable = ("number1", "number2", "number3");
assigns a three element list to the array variable @variable. To access each item,
$variable[0] will returns number1. Notice that the @ has changed to a $.

Array assignment functions are put and pop. Here are some examples:
push(@array1, "item3", "item4");
push(@array1, ("item3", "item4"));
push(@array1, @array2);
The push function returns the length of the new list.

To remove the last item from a list and return it use the pop function.
$item1 = pop(@array1);
Now $item1 is the last item in @array1 and the @array1 has all the items except item1.
We can also assign an array to a scalar variable.
$item1 = @array1;
assigns the length of @array1

$item1 = "@array1";
turns the list into a string with a space between each element.

Arrays can also be used to make multiple assignments to scalar variables:
($a, $b) = ($c, $d); # Same as $a=$c; $b=$d;
($a, $b) = @food; # $a and $b are the first two
# items of @food.
($a, @somefood) = @food; # $a is the first item of @food
# @somefood is a list of the
# others.

VMware Perl toolkit tutorial (2) - basic programing

With VMware Perl installed, we are ready to write VMware perl script. The file extension for Perl scripts is .pl. There are a few elements every Perl script must contain in order to function.
1. The first line of every VMware Perl script is a commented line directed toward the Perl interpreter.
#!/usr/bin/perl
2. Comments can be inserted into a program with the # symbol, and anything from the # to the end of the line is ignored (with the exception of the first line). The only way to stretch comments over several lines is to use a # on each line.

3. Everything else is a Perl statement which must end with a semicolon, like the last line above.

Now let me give you a example.

#!/usr/local/bin/perl
#
# First VMware Perl
#
print 'Hello world.';


4. When the file is executed Perl first compiles it and then executes that compiled version. So after a short pause for compilation the program should run quite quickly. In order to run the Perl program, after you install the Perl,

A:) you can run the program by: perl program or ./program

B:) You can always run the program with warnings using the command by perl -w program. This will display warnings and other helpful messages before it tries to execute the program.

C:) To run the program with a debugger use the command by perl -d progname

Sunday, July 12, 2009

VMware Perl toolkit tutorial (1) installation

Well, when I first study the vmware perl, it was called VI Perl Toolkit. After the vSphere 4 was released, the name has changed to vSphere SDK for Perl 4.0. When I went through all the installation steps, I found there was no much difference from the older version to the new version.
VMware Perl is just like other perl version, except it has VMware specific components. So don't think it too complicate. Compared to other perl, the grammar, the infrastructure and the standard library should be the same.
The vmware perl toolkit can be installed on a standalone linux box, or as a virtual machine (VIMA). I do not like VIMA since it does not give me the flexibility. I like to install the vmware perl toolkit on standalone linux box, since I can bundle other software with the vmware perl toolkit together.
So, here I will introduce how to install the vmware perl toolkit on linux, or I should say vSphere SDK perl 4.0 in the new release.
1. Supported Linux Platforms
Red Hat Enterprise Linux (RHEL) 5.2 (64 bit)
Red Hat Enterprise Linux (RHEL) 5.2 (32 bit)
SUSE Enterprise Server 10 SP1 32 bit
Ubuntu 8.04 32 bit

2. Preparation:
Download the vSphere SDK for Perl
Check Connectivity, make sure that the connection from your development system
to the target ESX/ESXi or vCenter Server system is working.

3. Installation:
(install OpenSSL library if the linux does not have)
To install the vSphere SDK for Perl
3.1 Untar the vSphere SDK for Perl binary
3.2 Launch the installer: //vmware-install.pl
3.3 When prompted, read the license agreement.
3.4 Specify an installation directory, or press Enter to accept the default, which is /usr/bin.
When the installation process completes: A success message appears. The installer lists different version numbers for required modules. The prompt returns to the shell prompt.
The defaults utility applications and samples sub directories are in the following locations:
Utility applications – /usr/lib/vmware-vcli/apps
Sample scripts – /usr/share/doc/vmware-vcli/samples

4. Uninstall the vSphere SDK for Perl on Linux
In order to uninstall the vSphere SDK for Perl, run the vmware-uninstall-vSphereCLI.pl script:
//bin/vmware-uninstall-vSphereCLI.pl

Saturday, July 11, 2009

VMware Converter Usage

VMware converter is free from VMware (I think not the enterprise version). In the new released vSphere 4, it is bundled with vSphere 4. The VMware converter automate and simplify physical to virtual machine conversions as well as conversions between virtual machine formats. Here is an chart maybe useful.

I use the VMware converter in the following way:
1. physical to virtual (P2V)
When I want to convert a physical machine to a virtual machine, I need to install the converter on the physical box first, and I also need vCenter support.
2. virtual to virtual (V2V different virtual machine format)
some of my friends working on VMware workstation, but I usually work on ESX. When I need their virtual machines, I will use converter to convert from workstation virtual machine to the ESX virtual machine.
3. virtual to virtual (V2V same format, different setting)
I just do not understand why VMware does not allow me to change the virtual machine hard drive size in ESX after I have created a virtual machine. So I have to use VMware Converter to shrink to hard drive size or expand it.

VMware ESX Advance Features

I have to say, I still spend most of my time on ESX3.5 and ESX3.5i, since my old machines do not support the new released ESX4. Usually I use those ESX hosts as a standalone box to do my development. The features I used the most are snapshot, import and export OVF images, create template and clone machines. Even my ESX boxes do not have SAN, I still use vCenter to manage ESX hosts, since the template and clone are only available through vCenter. My structure actually looks like that:


All the standalone machines are managed by my vCenter, and each of those ESX host is operated by its own. The Virtual Machines can transferred from one host to another host, but we have to power off the virtual machines first.

Now I have a chance to access my friend's data center, then I can experience the new features which are listed on the VMware website.

1. VMotion:
I think all other features are based on this one more or less. VMotion enables the migration of running virtual machines from one physical server to another without
service interruption. It is obvious that my previous setting can migrate from one host to another ESX host, but the service has to be interrupted. It allows virtual
machines to move from a heavily loaded server to a lightly loaded one. The effect is a more efficient assignment of resources.


2. VMware DRS
Taking the VMotion capability one step further by adding an intelligent scheduler, VMware DRS enables the system administrator to set resource assignment policies that
reflect business needs and let VMware DRS do the calculation and automatically handle the detailed physical resource assignments. Now I am looking for the API to find out how to define the policy. If I know the API, I can define my own policy.


3. VMware HA
I probably mentioned this in previous post. VMware HA offers a simple and low cost high availability alternative to application clustering. It enables quick restart
of virtual machines on a different physical server within a Cluster automatically should the hosting server fail. The mechanism behind vmware HA, I think is: The agent keeps testing the heart beat of the machines, and make a clone of this machine periodically, but did not put it online. When the heart beat is lost, then powers up the latest cloned virtual machine, and powers off the original one.

VMware vSphere Released

ESX4, ESX4i and vSphere have been released recently to replace ESX3.5 and ESX3.5i and vCenter. The previous ESX35 kernel is similar to Linux AS4 kernel. The new ESX4 is similar to Linux AS5 kernel. I found the new virtual switches are from 1G to 10G.

The upgrade are fairly easy comparing to the upgrade from ESX2 to ESX3. However, there are still some compatible issues. For example, when I tried to use vSphere to manage the ESX35 host, some functions did not work properly. Also, I wrote some VI perl script codes in ESX35 environment, but they do not work properly in new setting.

The new ESX4 release focuses on the 64bit systems. So when I upgrade from ESX35 to ESX4 on my old machines, they are all failed.
I started testing the new release few days ago. I will some comments when I finish the testing.

Monday, March 30, 2009

ESX3i installation

ESX3i will be the main product of VMware in the future. It is high performance, and it is the building block of Virtual Infrastructure 3.Once you have ESX 3i, you can install it on any server that is supported by VMware ESX Server 3i. The installation of ESX3i is very easy.

1. burn an ISO file onto a bootable CD first.

After the black screen, it moved to the yellow screen.

Then, it comes to the welcome screen.

Pressed Enter to Install and pressed F11 to accept the license agreement.

Select the hard drive and Enter.

Next, press F11.

After the installation, Pressed Enter and rebooted the system, and manual eject the CD. Once rebooted, comes to this screen:

Then the installation process is done. now we should configure the network setting.

Sunday, February 15, 2009

Which VMware product should I use? (3) VMware datacenter product, VI 3 basic

VMware Infrastructure 3 is a suite of industry-leading infrastructure datacenter virtualization software that virtualizes servers, storage and networking, allowing multiple unmodified operating systems and their applications to run independently in virtual machines while sharing physical resources. The suite delivers comprehensive virtualization, management, resource optimization, application availability and operational automation capabilities. A virtual infrastructure lets you share your physical resources of multiple machines across your entire infrastructure. A virtual machine lets you share the resources of a single physical computer across multiple virtual machines for maximum efficiency. Resources are shared across multiple virtual machines and applications.

Virtualization Infrastructure dramatically improves the efficiency and availability of resources and applications, and gets the flexibility you need to build and sustain your competitive advantage while reducing infrastructure costs. Internal resources are underutilized under the old “one server, one application” model. VMware Infrastructure delivers resources, applications—even servers—when and where they’re needed. The customers typically save on the overall IT costs by consolidating their resource pools and delivering highly available machines to users. The Virtualization Infrastructure will reduce capital costs by requiring less hardware and lowering operational costs while increasing your server usability, ensure the enterprise applications perform with the highest availability and performance, build up business continuity through improved disaster recovery solutions and deliver high availability throughout the datacenter, and improve desktop management with faster deployment of desktops and fewer support calls due to application conflicts.

The basic VI 3 can set up in the following. As my personal experience, it is good enough for the everyday usage of a small organization.

ESX(ESXi): In this infrastructure, each physical machine installs an ESX (ESXi) bare metal product. The ESX(ESXi) takes the responsibilities of managing the whole physical machines and supports multiple virtual machines. In the VMware virtual concept, each virtual machine is a file, so in the ESX, the file system is VMFS. Virtual SMP enables you to have a single virtual machine use up to four physical processors simultaneously.

VMware vCenter is the management server in the VMware Infrastructure. vCenter intelligently optimizes resources, ensures high availability to all applications in virtual machines and makes your IT environment more responsive with virtualization-based distributed services such as VMware DRS, VMware High Availability (HA), VMware Consolidated Backup and VMware VMotion. Here are examples of the vCenter benefit:


Storage: In order to enable the advance functions in vCenter, SAN storage is required. All the virtual machines will share the same storages; even each physical machine has its own local storage. The virtual machines are independent.



Which VMware product should I use? (2) VMware desktop product.

There are three kinds of VMware products we can choose:
Customer Desktop Technology
Technical Desktop Technology
Enterprise Desktop Technology

1. Customer Desktop Technology
It is for the single user who wants to run software which is developed for different OSes on a single physical machine, and no needs to develop the software. Usually, we will only deploy one virtual machine in a single physical machine, because of the capability of customer desktop technology. In order to achieve this objective, the user will install VMware customer desktop product on existing OS, then import the OS required by the software to run the applications. For example, easily run Windows’ applications on your Mac, including high end games and other graphic applications, with VMware Fusion. Run Windows and Linux applications on Windows or Linux PCs with the free VMware Player.

2. Technical Desktop Technology
It is for the developers to reduce development time and reduce the QA and support costs. Consolidate multiple development and test workstations onto a single physical system by running multiple virtual machines. In order to achieve these goals, the developers have to install the technical desktop product on existing OS, then create multiple virtual machines. For example, one virtual machine for QA, one virtual machine for development, and one virtual machine for performance testing. VMware Workstation is a kind of technical desktop product, we can record and replay virtual machine activity to capture, diagnose, and resolve non-deterministic bugs and race conditions. On the development machine, if we mess up on one stage, we can easily go back to the last safe stage by using snapshot function and avoid the huge effort of roll back.

3. Enterprise Desktop Technology
This technology is used by the enterprises who have a lot of branches in different locations. Organizations use enterprise desktop technology to manage and support the needs of their extended, global workforce while strengthening security and control over corporate resources and sensitive information. VMware View (formerly VMware Virtual Desktop Infrastructure (VDI)) lets organizations streamline desktop management & control, reduce operating costs and deliver complete desktop environments with greater application compatibility. VMware View is based on the Virtual Infrastructure 3, and it provides customerlized desktops to remote workers and is managed in local service center. Using VI3 in this way enables an IT organization to run multiple, unique, isolated virtual desktops on one physical server. These virtual desktops are made up of a single-user copy of OS as well as typical PC applications, and they present to the user an environment that looks, feels, and operates exactly like a standalone PC. Users access these virtual desktops through local devices such as thin clients, diskless PCs, or even regular PCs that are located on an individual user’s desk. Because these virtual desktops are actually running within the tightly managed and more easily controlled environment of the datacenter, they bring together many of the advantages of the centralized and decentralized computing models.


which VMware product should I use? (1) VMware products

Now I will talk a little bit about the VMware products. The customers need to select products according to their special requirements. It is not cheap to buy the whole package. We have to use our money wisely.

The VMware once provided its products in three categories: Desktop products, datacenter products and management products. In the new release, the management products have been merged into the datacenter products category since most management products users will use these products in the datacenter. The desktop products include: VMware Fusion, VMware ThinkApp, VMware ACE, VMware Workstation, VMware MVP(not available now), VMware Player and VMware View. The datacenter product include: VMware Infrastructure 3, VMware vCenter Server, VMware ESX(ESXi), VMware Server, VMware vCenter Site Recovery Manager, VMware vCenter Lab Manager, VMware Capacity Planner, VMware vCenter Lifecycle Manager, VMware vCenter Stage Manger, VMware vCenter AppSpeed, and VMware vCenter Converter. Some other VMware products are also provided to the customers, but not as part of product line, such as VMware VMark for the performance, and VIMA, VMware RCLI and VMware Perl Tool kit for the development.

Wednesday, January 14, 2009

The virtualization products

Virtualization software products can be divided in two groups: 1) Hosted and 2) Bare Metal.
Hosted products require a general purpose OS to be running directly on the hardware, such as Windows, Linux and Mac OS X. The Mircosoft Hyper-V product and VMware workstation, VMware server are hosted products. The bare metal products released by VMware are ESXi and ESX Servers.
In host environment, the virtualization layer needs to provide both OS specific user-level components to access the general purpose OS, and kernel components to build virtual environment. The virtualization overhead is higher on this model because every I/O operation needs to go through a general purpose OS.
In bare metal product, the virtualization overhead is much lower since the I/O operation will be on the hardware directly.
Since the performance concern, I would use the hosted virtualization products on my desktop, and bare metal products for enterprise usage.
The popular hosted products are:
1. VMware Workstation: It is targeted to power users and developers. The concept is quite like the Windows workstation: it can perform most of the virtual features, but it only focus on one virtual machine.
2. VMware Server: It allows installing and running multiple VMs on a small server. The customer can control multiple servers remotely via a remote client. This product is targeted to small environments, mostly development and testing. The concept of VMware server is quite similar to Windows server: it focus on multiple virtual machines, and provide services for all the virtual machines. It should be all right to support 2~8 virtual machines, but if we have more virtual machines, the performance will be hugely impacted by the indirect accessing hardware.
3. VMware Fusion: this is the only VMware product for the Macintosh. It allows the user to run
Windows, Linux or any other supported OS as a virtual machine on a Mac. It includes several
advanced features not available on other products such as complete application integration with the Mac OS look-and-feel.
4. VMware Player: Free product and it allows users to run-only virtual machine created in other VMware products such as Workstation or Server. It does not have many management functions as other VMware product, but it is a good product for less powerful machines.
5. Windows Hyper-V: I would describe it as the prodcut in the same level as VMware server. Basically it is a windows OS with capability to run other OS. It is all right to run multiple Virtual Machines, but when come to more virtual machines, the performance degrade dramatially.
Since the bare metal products are mostly used on enterprise, and used as IT infrastructure , it always goes with Virtualization Infrastructure. I will spend more effort on these bare metal products in the later articles. The current popular bare metal products are:
1. VMware ESX: It is very scalable, and have a lot of fancy features. It typically has better performance than hosted products. The number of Virtual Machines in one physical server is much higher.
2. VMware ESXi: It is free! ESXi is a thin version of ESX. It almost has the same features as ESX, but spends less amount of system resources: It only uses 32M harddrive. It is a perfect version to play with. The ESXi does not have the host console as ESX, so the virtualization client needs to be downloaded by customers to manage the virtual host and virtual machines.


Monday, January 12, 2009

What is Virtualization

Virtualization is a technology that is changing the IT deployment and the way that people use servers. Current powerful computer hardware was designed to run a single operating system and a single application. However, this leaves most machines vastly underutilized. Each virtual machines can run different operating systems and multiple applications on the same physical computer. Virtualization technology can lets you run multiple virtual machines on a single physical machine, and sharing the resources of that single computer across multiple platforms.
In the market, we can find two major branches of products: Microsoft Virtualization with Hyper-V, and VMware Virtualization.
VMware products provides a virtualized set of hardware to the guest OS. The hardware includes video adapters, network adapters, and hard drive adapters. The virtual host can also provides pass-through drivers for guest USB, serial, and parallel devices. The virtual machines become highly portable between computers, because every host looks identical to the guests OS. A systems administrator can pause operations on a virtual machine guest, move or copy that guest OS to another physical computer, and there resume execution exactly at the point of suspension. VMotion product allows the virtual host to move a running virtual machine from one virtual host to another.
Microsoft Hyper-V is also called as Windows Server Virtualization, is a hypervisor-based virtualization system for x86 64bits systems. In Hyper-V, a partition is a logical unit which is supported by the hypervisor.
A hypervisor instance has to have at least one parent partition, running Windows Server 2008. The virtualization stack runs in the parent partition and has direct access to the hardware devices. The parent partition then creates the child partitions which host the guest OSs. A child partition can also spawn further child partitions of their own. A parent partition creates child partitions using the hypercall API, which is the application programming interface exposed by Hyper-V.
Child partitions do not have direct access to hardware resources, but instead have a virtual device. Any request to the virtual devices is redirected via the VMBus to the devices in the parent partition, which will manage the requests.