Re: [Unattended] Product Keys from Spreadsheet

2004-03-14 Thread Patrick J. LoPresti
[EMAIL PROTECTED] writes:

> So what I mean is, can the sub ask_os be substituted for something that 
> cooperates with the asset number stuff? So the os installation is 
> completely based on the asset number I fill in.

Absolutely!  To get an idea how this works, read the later sections of
.

Something like this, if added to the sample config.pl I sent earlier,
should do the trick:

$u->{'_meta'}->{'OS_media} =
sub {
my $tag = $u->{'_meta'}->{'asset_tag'};
defined $tag
or return undef;
my $licenses = $soft_by_owner->{$tag} || [ ];
foreach my $license (@$licenses) {
my $desc = hash_ref ($license, 'Type');
$desc =~ /Windows 2000/
and return 'z:\\os\\win2k';
$desc =~ /Windows XP/
and return 'z:\\os\\winxp';
}
return undef;

};

In other words, you just write a subroutine to compute
[_meta]/OS_media from [_meta]/asset_tag.  You can compute anything
from anything in this way, if you can write the code to express it.

Hm, perhaps this whole thing would make a good example to add to
advanced.html.

> Another question; Isn't it possible to use qchain for all the
> Windows Updates so the systems wouldn't have to reboot for like a
> thousand times?

It is possible, but I do not trust it:

  http://www.mail-archive.com/[EMAIL PROTECTED]/msg00167.html

  http://www.mail-archive.com/[EMAIL PROTECTED]/msg00448.html

XP service pack 2 should be out in a few months, which will help
somewhat.

 - Pat


---
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
___
unattended-info mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/unattended-info


Re: [Unattended] Product Keys from Spreadsheet

2004-03-03 Thread Michel . Timmerman
Thanks alot for the spreadsheet stuff, this really works great. You say 
you have a field (column :) in the spreadsheet that has the type of OS in 
it e.g. Windows 2000 Professional or ...XP. Is it possible to compute the 
installfolder from this point. I mean now when install.pl runs, it first 
searches for os dirs and asks which os to install. Later on in config.pl 
when I fill in the asset number and it looks up the corresponding product 
key, but when I choose to install Windows 2000 which has a product key for 
XP in software.csv then the installation will fail later on.

So what I mean is, can the sub ask_os be substituted for something that 
cooperates with the asset number stuff? So the os installation is 
completely based on the asset number I fill in.

Another question; Isn't it possible to use qchain for all the Windows 
Updates so the systems wouldn't have to reboot for like a thousand times?

Thanks and keep up the very good work everyone!

Michel




"Patrick J. LoPresti" <[EMAIL PROTECTED]> 
Sent by: [EMAIL PROTECTED]
28-02-2004 14:37

To
"Aron Mangano" <[EMAIL PROTECTED]>
cc
[EMAIL PROTECTED]
Subject
Re: [Unattended] Product Keys from Spreadsheet






"Aron Mangano" <[EMAIL PROTECTED]> writes:

> Firstly, what has happended to the mailing list. I used to receive
> emails regulary but I haven't received one now for more than 2
> months. I used to receive them almost daily.

Well, you successfully sent this message to the list :-).

Perhaps mail to you was bouncing and you got unsubscribed?  Try using
the Web interface (linked from the home page
http://unattended.sourceforge.net/) to retrieve your subscription
preferences, and resubscribe if necessary.

> Secondly you mentioned once that it is possible to extract the
> correct product key from a spreadsheet when building OEM machines.
> Could you please tell me how to do this. It would be greatly
> appreciated. Many thanks and keep up the great work.

You have to write some Perl.  Below is (most of) the Z:\site\config.pl
that I use.

It assumes you have comma-separated-value (CSV) spreadsheets named
"hardware.csv" and "software.csv" under Z:\lib.  It assumes both are
indexed by an asset tag field named "Tag".  Our asset tags are of the
form "" or "e" (don't ask).

The hardware.csv sheet is only used for setting the host name, which
lives in the "Etc" column of the spreadsheet.

Each software asset has an "Owner" field which is a hardware asset
tag.  (Conceptually, each software license is "owned" by a machine.)
It has a "Type" field which is something like "Microsoft Windows 2000
Professionsal".  It has a "Key" field which is the license key.

When I say "field", I guess I mean "column".

I really should document this better and turn it into a real
example...  If anybody feels like writing this up and submitting a
patch to advanced.html, let me know.

 - Pat


use warnings;
use strict;
use Carp;

# Look up an entry in a hash, bombing out if it does not exist.
sub hash_ref ($$) {
my ($hash, $key) = @_;

my $type = ref $hash;
$type eq 'HASH'
or croak "You blew it: What should be a hash is a $type";

(exists $hash->{$key})
or croak "$key not found in hash -- bailing out";
return $hash->{$key};
}

# Asset tag stuff
require 'csv.pl';

# Routine to canonicalize field names for indexing purposes.
sub canonicalize_field ($) {
my ($val) = @_;
# Convert to lower case.
$val = lc $val;
# Local custom: Comments may appear in parens.  Strip them.
$val =~ s/\s*\(.*?\)//g;
return $val;
}

# Read hardware inventory list, and index it by tag.
my $hard_inv = 'z:\\site\\hardware.csv';
my $hardware = CSV->read_file ($hard_inv);
my $hard_by_tag = $hardware->index_by ('Tag', \&canonicalize_field);

# Read software inventory list, and index it by owner (hardware tag).
my $soft_inv = 'z:\\site\\software.csv';
my $software = CSV->read_file ($soft_inv);
my $soft_by_owner = $software->index_by ('Owner', \&canonicalize_field);

# Create new [_meta]/asset_tag attribute.
$u->{'_meta'}->{'asset_tag'} =
sub {
my $ret = simple_q ('Enter asset tag (default = none): ');
defined $ret
or print "OK, have it your way.\n";
return defined $ret ? lc $ret : undef;
};

# Compute computer name from inventory sheet, if possible.
sub computer_name {
my $tag = $u->{'_meta'}->{'asset_tag'};
defined $tag
or return undef;
my @systems = @{$hard_by_tag->{$tag}};
scalar @systems == 0
and die "Tag $tag not found in $hard_inv -- bailing";
scala

Re: [Unattended] Product Keys from Spreadsheet

2004-02-28 Thread Patrick J. LoPresti
"Aron Mangano" <[EMAIL PROTECTED]> writes:

> Firstly, what has happended to the mailing list. I used to receive
> emails regulary but I haven't received one now for more than 2
> months. I used to receive them almost daily.

Well, you successfully sent this message to the list :-).

Perhaps mail to you was bouncing and you got unsubscribed?  Try using
the Web interface (linked from the home page
http://unattended.sourceforge.net/) to retrieve your subscription
preferences, and resubscribe if necessary.

> Secondly you mentioned once that it is possible to extract the
> correct product key from a spreadsheet when building OEM machines.
> Could you please tell me how to do this. It would be greatly
> appreciated. Many thanks and keep up the great work.

You have to write some Perl.  Below is (most of) the Z:\site\config.pl
that I use.

It assumes you have comma-separated-value (CSV) spreadsheets named
"hardware.csv" and "software.csv" under Z:\lib.  It assumes both are
indexed by an asset tag field named "Tag".  Our asset tags are of the
form "" or "e" (don't ask).

The hardware.csv sheet is only used for setting the host name, which
lives in the "Etc" column of the spreadsheet.

Each software asset has an "Owner" field which is a hardware asset
tag.  (Conceptually, each software license is "owned" by a machine.)
It has a "Type" field which is something like "Microsoft Windows 2000
Professionsal".  It has a "Key" field which is the license key.

When I say "field", I guess I mean "column".

I really should document this better and turn it into a real
example...  If anybody feels like writing this up and submitting a
patch to advanced.html, let me know.

 - Pat


use warnings;
use strict;
use Carp;

# Look up an entry in a hash, bombing out if it does not exist.
sub hash_ref ($$) {
my ($hash, $key) = @_;

my $type = ref $hash;
$type eq 'HASH'
or croak "You blew it: What should be a hash is a $type";

(exists $hash->{$key})
or croak "$key not found in hash -- bailing out";
return $hash->{$key};
}

# Asset tag stuff
require 'csv.pl';

# Routine to canonicalize field names for indexing purposes.
sub canonicalize_field ($) {
my ($val) = @_;
# Convert to lower case.
$val = lc $val;
# Local custom: Comments may appear in parens.  Strip them.
$val =~ s/\s*\(.*?\)//g;
return $val;
}

# Read hardware inventory list, and index it by tag.
my $hard_inv = 'z:\\site\\hardware.csv';
my $hardware = CSV->read_file ($hard_inv);
my $hard_by_tag = $hardware->index_by ('Tag', \&canonicalize_field);

# Read software inventory list, and index it by owner (hardware tag).
my $soft_inv = 'z:\\site\\software.csv';
my $software = CSV->read_file ($soft_inv);
my $soft_by_owner = $software->index_by ('Owner', \&canonicalize_field);

# Create new [_meta]/asset_tag attribute.
$u->{'_meta'}->{'asset_tag'} =
sub {
my $ret = simple_q ('Enter asset tag (default = none): ');
defined $ret
or print "OK, have it your way.\n";
return defined $ret ? lc $ret : undef;
};

# Compute computer name from inventory sheet, if possible.
sub computer_name {
my $tag = $u->{'_meta'}->{'asset_tag'};
defined $tag
or return undef;
my @systems = @{$hard_by_tag->{$tag}};
scalar @systems == 0
and die "Tag $tag not found in $hard_inv -- bailing";
scalar @systems > 1
and die "Tag $tag found more than once in $hard_inv -- bailing";
my $name = hash_ref ($systems[0], 'Etc');
$name =~ /\S/
or undef $name;
my $text = (defined $name
? "Found hostname for tag $tag: $name\n"
: "No hostname found for tag $tag in $hard_inv\n");
print $text;
return $name;
}

$u->push_value ('UserData', 'ComputerName', \&computer_name);

# Compute product key from inventory sheet, if possible.
sub product_key {
my $tag = $u->{'_meta'}->{'asset_tag'};
defined $tag
or return undef;
my $licenses = $soft_by_owner->{$tag} || [ ];
my $key;
foreach my $license (@$licenses) {
my $desc = hash_ref ($license, 'Type');
$desc =~ /^Microsoft Windows/
or next;
$key = hash_ref ($license, 'Key');
$key =~ /\S/
and last;
undef $key;
}

my $text = (defined $key
? "Found product key for tag $tag: $key\n"
: "No product key found for tag $tag in $soft_inv\n");
print $text;

return $key;
}

$u->push_value ('UserData', 'ProductKey', \&product_key);

$u->push_value ('_meta', 'ntp_servers',
sub {
my $tag = $u->{'_meta'}->{'asset_tag'};
defined $tag
or return undef;
my ($tail) = $tag =~ /(\d)\z/;
defined $tail
or return undef;
return ($tail % 2
? 'ntp-1 ntp-0'
: 'ntp-0 ntp-1');
});

1;


---
SF.Net is sponsored by: Speed St

[Unattended] Product Keys from Spreadsheet

2004-02-27 Thread Aron Mangano
Patrick

I have been using your system for more than a year and I think it is
fantastic. It has saved me an enormous amount of time and energy.

Firstly, what has happended to the mailing list. I used to receive
emails regulary but I haven't received one now for more than 2
months. I used to receive them almost daily.

Secondly you mentioned once that it is possible to extract the
correct product key from a spreadsheet when building OEM machines.
Could you please tell me how to do this. It would be greatly
appreciated. Many thanks and keep up the great work.



---
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id56&alloc_id438&op=click
___
unattended-info mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/unattended-info