Thursday, December 27, 2007

AltirisSVS Class

It's been a while since my last post and progress on my first little side-project is.... slow... The more I think of this project, the more I realize that I'm sort of reinventing the wheel. There are some great free alternative ways of doing what i want and i will look into them as soon as possible. So for now, 
* 1st project status: on-hold

As many of you programmers over the world would recognize, There's ALWAYS plenty of room for new ideas in a programmers head, but way to little free time to actually program those wonderful ideas. One of those ideas I challenged before is the idea of creating a general .NET class that will provide me with various methods for the purpose of controlling the SUPER COOL program AltirisSVS (Software Virtualization).

A little time ago I created a little solution but as messy as i am i don't know where I have the sourcecode of this little thingy. Didn't have a backup, so I'm forced to recreate the whole program, this time I will code my thing in C# (as apposed to the previous version that was created in VB.NET).
To give you a short overview of what the hell I'm going to do we will dive in a little deeper in the magical world of virtualization.

So what is AlririsSVS?
The guys at Altiris created a program that well... virtualizes software installations. To give you a more understandable image, imagine yourself having a pc. That's probably not that hard to imagine, since most of you reading this post are doing this on there own personal desktop. Next step is look at your word processor. Most likely you will find a program like Microsoft Word 2003 or something similar like it. Nothing crazy going on at this stage. Until your boss sends you an MS Word document that was created with the newer version of Microsoft Office 2007 (XDOC format). This is a document format that isn't supported by your older 2003 version of Office. Still not that big of a problem, just upgrade your Office version to the newer 2007 version and off we go! But maybe you just liked office 2003 or corporate policies prohibits you to delete this version. Now what to do???

Here is when AltirisSVS come's into play!!!
Most program's on your pc don't "bite" each other, but some programs will! Program's like Microsoft Office are using so called shared dll files. These files are transferred to your computer during installation and will nestle themselves wherever they are comfortable. Nothing wrong with this, those little dll's will do there work just fine and you probable will never notice them, until you want to run 2 different version of the same program next to another on one pc. Then the new installation will probably overwrite some of these shared dll files without notifying other programs on your pc.

Now you can find yourself with a computer who was 2 versions installed of the same program (for example MS Word 2003 / MS Word 2007). The shared files on your computer will all be version 2007 and you will have trouble running the older 2003 version.
So this is a big NO GO!!!
This problem doesn't occur if you virtualize these installations and run them in separated virtualized environments. Well, lets install VMware or Virtual PC, and install the software into a new virtual pc most of the people will think, but there are WRONG! Install AltirisSVS and you will be able to create the so called "Layers"
In this layer you can then install an application. The layer will be an "sandboxed" environment where all the program files and shared dll will be found. This layer is very flexible, you can enable/disable it, making it possible to totally hide you installed application from the operating systems perspective. You can download a free version from the website (need to be a registered user, so first register on there website). Just play with the software for a while and you will see!

Question some people might ask, if this software is that great, why wanna code something around it? Well, at Altiris they did a great job building the whole virtualisation platform, and on top of that, they created a nice WMI interface so that you can manage your layers through code. And, where there are interfaces, there are those annoying programmers who just can't resist to talk to it.
Well, that's the main reason i started this project.
Why? because i can!
So the first thing to do is making a little framework as a base, letting me extend this framework in the future.

  • Create a little WMI Wrapper for the Altiris WMI class
  • Create a C# Class
    • Activate_Layer(string LayerName)
    • DeActivate_Layer(string LayerName)
    • EnumerateLayers()

Additional resources:
Microsoft WMI Code Creator
Good article on how to make a SVS wmi script
Tech MOSS team, created some nice tools for developers

A little sample code preview (written by rcboenne)

    1 using System;

    2 using System.Collections.Generic;

    3 using System.Text;

    4 using System.Management;

    5 using System.Windows.Forms;

    6 

    7 namespace Focus_XP_SVS_Layer_Console

    8 {

    9     public class WMITest

   10     {

   11         public static void Test()

   12         {

   13             try

   14             {

   15 

   16                 ManagementScope scope = new ManagementScope("root\\default");

   17                 scope.Connect();

   18                 ManagementClass classInstance = new ManagementClass(

   19                 scope,

   20                 new ManagementPath("AltirisVSProv"),

   21                 null);

   22 

   23                 // Obtain in-parameters for the method

   24                 ManagementBaseObject inParams =

   25                 classInstance.GetMethodParameters("EnumerateLayers");

   26 

   27                 // Add the input parameters.

   28                 inParams["Verbose"] = 1;

   29 

   30                 // Execute the method and obtain the return values.

   31                 ManagementBaseObject outParams =

   32                 classInstance.InvokeMethod("EnumerateLayers", inParams, null);

   33 

   34                 // List outParams

   35                 Console.WriteLine("Out parameters:");

   36                 Console.WriteLine("EnumData: " + outParams["EnumData"]);

   37                 Console.WriteLine("ReturnValue: " + outParams["ReturnValue"]);

   38             }

   39             catch (ManagementException err)

   40             {

   41                 MessageBox.Show("An error occurred while trying to execute the WMI method: " + err.Message);

   42             }

   43         }

   44 

   45     }

   46 }




No comments: