About Terminal Server, Citrix, Delphi and other stuff
I have created a little tool for myself that I have call Altiris Job Builder, it retreives the Jobs from the Altiris database and shows them in a Treeview.
Then I can assemble a Master Build Job by dragging the needed Jobs to another Treeview on the right. Since it’s just for me it doesn’t have a fancy gui:
So why did I write it? Well I have divided my Jobs into Prerequisites and Packages, for instance IIS and Terminal Server and Java are prereqisuites for Citrix. But many prereqisuites are required for one or more other packages, eg Java is also used for certain applications.I don’t want to make copies of Jobs since that means I have to change it in multiple places. For instance say we upgrade to a new Java version we would need to update multiple jobs instead of one (which is very likely to wrong ).
So the idea behind this master build is to create a Master Build Job that fires off all the needed jobs for a certain package. I use AxSched in an integrated script job for that. So my tool generates something like this:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
rem My Jobs\PKG\p003.Citrix_Prereqisuites\02.Java
AxSched %COMPNAME% -jid 2000266 /t %TIME:~0,5% /ulu
rem My Jobs\PKG\p003.Citrix_Prereqisuites\03.Web-Server
AxSched %COMPNAME% -jid 2000267 /t %TIME:~0,5% /ulu
rem My Jobs\PKG\p003.Citrix_Prereqisuites\05.TS_TerminalServer!
AxSched %COMPNAME% -jid 2000269 /t %TIME:~0,5% /ulu
rem My Jobs\PKG\p003.Citrix_Prereqisuites\08.VisualJ#
AxSched %COMPNAME% -jid 2000272 /t %TIME:~0,5% /ulu
rem My Jobs\PKG\p003.Citrix_Prereqisuites\06.CtxClient
AxSched %COMPNAME% -jid 2000270 /t %TIME:~0,5% /ulu
rem My Jobs\PKG\p015.Citrix_AddServer\02.InstallCitrix!
AxSched %COMPNAME% -jid 2000295 /t %TIME:~0,5% /ulu
rem My Jobs\PKG\p013.CitrixComponents\01.DeliveryServicesConsole
AxSched %COMPNAME% -jid 2000287 /t %TIME:~0,5% /ulu
rem My Jobs\PKG\p013.CitrixComponents\02.CMC
AxSched %COMPNAME% -jid 2000289 /t %TIME:~0,5% /ulu
rem My Jobs\PKG\p013.CitrixComponents\04.HDX
AxSched %COMPNAME% -jid 2000290 /t %TIME:~0,5% /ulu
rem My Jobs\PKG\p013.CitrixComponents\03.EnableFP2
AxSched %COMPNAME% -jid 2000293 /t %TIME:~0,5% /ulu
rem My Jobs\PKG\p014.CitrixHotFixes\01.HotfixRollup6!
AxSched %COMPNAME% -jid 2000292 /t %TIME:~0,5% /ulu |
But lazy as I am I don’t want to manually copy/paste this into a job but rather insert it directly into the database. If we look at the eXpress database scheme we can see that there is an event table (a Job is really an Event in Altiris):

Only the event_id field is mandatory and it’s also the Primary Key of the table. However the event_id is not auto generated so if we insert a new record how do we now the right value for event_id?
One approach could be to read the highest value and increment that by 1 but that seems dangerous for various reasons. So I figured there was probably a Stored Procedure for adding a new Job/Event.
In the SQL Server Management Studio we can find Stored Procedures under the Programmability Node of the Database:

If you look into the available Stored Procedures you will see that there are del_xxx and ins_xxx events. We need the ins_event Stored Procedure:

In Delphi we can use the TADOCommand object to call a Stored Procedure:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
function TForm1.AddEvent(const FolderId: Integer; const Name: String;
const Description: String=''): Integer;
var
cmd: TADOCommand;
begin
Result := -1;
cmd := TADOCommand.Create(nil);
try
cmd.Connection := ADOConnection1;
cmd.CommandType := cmdStoredProc;
cmd.CommandText := 'ins_event';
cmd.Parameters.Refresh;
cmd.Parameters.ParamByName('@name').Value := Name;
cmd.Parameters.ParamByName('@folder_id').Value := FolderId;
cmd.Parameters.ParamByName('@description').Value := Description;
cmd.Execute;
Result := cmd.Parameters.ParamValues['@RETURN_VALUE'];
finally
cmd.Free;
end;
end; |
The ins_event Stored Procedure returns the new JobId in the @RETURN_VALUE parameter. This is very convenient because we need the JobId to add tasks to the new Job, in this case a script task.
But enough talk for today, I hope you find the subject interesting and I would be very interested to hear about other solutions or concepts for a Master Build Job.
Related posts:
Active Directory Altiris Automation Manager bug Citrix Dell Delphi Exchange Exchange2003 Exchange2010 Hack Hewlett-Packard HP iOS Jailbreak Java LinkedIn Linux Lync McAfee MSI MySQL Navigation Objects Office Outlook Passat Password PowerPoint PowerShell RES RNS315 RNS510 SasLibEx Terminal Server ThinApp TSAdminEx VBS VCDS Vista VMWare Volkswagen Windows PE Wordpress XenApp
WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.
2 Responses for "Altiris Job Builder"
[...] today I wrote about my Altiris Job Builder tool but when I tested the actual produced build job I noticed something weird: the job was [...]
[...] to the Server and/or Job context (popupmenu) in DS? I would really like to be able to launch my Job Builder by right clicking a Job or Folder and ideally DS would pass the Folder or Job Id on the [...]
Leave a reply