zone_map and the associated scripts zone_to_physical.pl and physical_to_zones.pl are used to remind users/admins of the global to local (and vice versa) zone relationships (http://www.sun.com/bigadmin/content/zones/ -- the totally inadequate summary being "zone =~ virtualized solaris environment").
zone_map is generated dynamically (future (brief) post), but ends up looking something like this:
global_zone1,local_zone1a
global_zone1,local_zone1b
global_zone2,local_zone2a
physical_to_zones.pl and zone_to_physical.pl are hard links to the same file, the guts of which look like this:
open (ZONEMAP,"/usr/local/bin/zone_map") or die;
foreach $line (){
chomp $line;
($global_zone,$zone)=split(/,/,$line);
debug_msg("working with global zone $global_zone and local zone $zone");
push(@{ $global_zones{$global_zone} }, $zone);
}
close (ZONEMAP);
if ($#ARGV == 0) {
debug_msg("ARGV defined");
$input = shift(@ARGV);
chomp($input);
debug_msg("input is $input");
}
if ($0 =~ /physical_to_zones/) {
debug_msg("called as physical_to_zones");
if ($input){
if ($global_zones{$input}){
print "$input runs:\n";
foreach $zone(sort @{$global_zones{$input}}) {
print "\t$zone\n";
}
} else {
print "zone information for $input not defined\n";
}
} else {
foreach $global_zone (sort keys %global_zones) {
print "$global_zone runs:\n";
foreach $zone (sort @{$global_zones{$global_zone}}) {
print "\t$zone\n";
}
}
}
} else {
debug_msg("must have been called as zone_to_physical");
unless ($input) {
print "zone_to_physical.pl requires a zone name as input\n";
print "maybe you wanted physical_to_zones.pl?\n";
exit;
}
foreach $global_zone (keys %global_zones) {
@local_zones = @{$global_zones{$global_zone}};
foreach $zone (@local_zones){
if ($zone =~ /$input/i){
print "$input runs on $global_zone\n";
exit;
}
}
}
}
If you run zone_to_physical.pl local_zone1a you get local_zone1a runs on global_zone1
If you run physical_to_zones.pl you get:
global_zone1
local_zone1a
local_zone1b
global_zone2
local_zone2a
No comments:
Post a Comment