Subversion Repositories havirt

Rev

Rev 11 | Rev 14 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 11 Rev 12
Line 76... Line 76...
76
# global variables
76
# global variables
77
my $scriptDir = $FindBin::RealBin;
77
my $scriptDir = $FindBin::RealBin;
78
my $scriptName = $FindBin::Script;
78
my $scriptName = $FindBin::Script;
79
my $dbDir = "$scriptDir/var";
79
my $dbDir = "$scriptDir/var";
80
our $confDir = "$scriptDir/conf";
80
our $confDir = "$scriptDir/conf";
81
our $nodeDBName = "$dbDir/node.yaml";
81
our $statusDBName = "$dbDir/status.yaml";
82
our $domainDBName = "$dbDir/domains.yaml";
82
our $lastScanFileName = "$scriptDir/lastscan";
83
our $nodePopulationDBName = "$dbDir/node_population.yaml";
83
our $minScanTimes = 5 * 60; # do not scan more than once every 5 minutes
84
 
84
 
85
# these contain the values from the databases
85
# Big hash that contains all information about system
86
# loaded on demand
-
 
87
our $nodeDB;
-
 
88
our $virtDB;
86
our $statusDB;
89
our $nodePopulations;
-
 
90
 
87
 
91
# options variables
88
# options variables
92
our $reportFormat = 'screen';
89
our $reportFormat = 'screen';
-
 
90
our $force = 0;
-
 
91
our $quiet = 0;
93
our $targetNode = '';
92
our $targetNode = '';
94
our $dryRun = 1;
93
our $dryRun = 1;
95
our $DEBUG = 0;
94
our $DEBUG = 0;
96
my $help = 0;
95
my $help = 0;
97
my $version = 0;
96
my $version = 0;
Line 109... Line 108...
109
   print "\t--version|-v # show version of program\n";
108
   print "\t--version|-v # show version of program\n";
110
   print "\t--format|-f screen|tsv # output of list commands is either padded for screen or Tab Delim\n";
109
   print "\t--format|-f screen|tsv # output of list commands is either padded for screen or Tab Delim\n";
111
   print "\t--target|-t NODE # the action use NODE for the target of actions\n";
110
   print "\t--target|-t NODE # the action use NODE for the target of actions\n";
112
   print "\t--dryrun|-n # does not perform the actions, simply shows what commands would be executed\n";
111
   print "\t--dryrun|-n # does not perform the actions, simply shows what commands would be executed\n";
113
   print "\t--debug|d # increases verbosity, with -ddd, totally outragious\n";
112
   print "\t--debug|d # increases verbosity, with -ddd, totally outragious\n";
-
 
113
   print "\t--yes|y # force an action (like scan) even if it is not a good idea\n";
-
 
114
   print "\t-quiet|q # do not print anything except major errors\n";
114
}
115
}
115
 
116
 
116
 
117
 
117
 
118
 
118
# handle any command line parameters that may have been passed in
119
# handle any command line parameters that may have been passed in
Line 121... Line 122...
121
   'format|f=s' => \$reportFormat,
122
   'format|f=s' => \$reportFormat,
122
   'target|t=s' => \$targetNode,
123
   'target|t=s' => \$targetNode,
123
   'dryrun|n!' => \$dryRun,
124
   'dryrun|n!' => \$dryRun,
124
   'debug|d+' => \$DEBUG,
125
   'debug|d+' => \$DEBUG,
125
   'help|h' => \$help,
126
   'help|h' => \$help,
-
 
127
   'yes|y' => \$force,
126
   'version|v' => \$version
128
   'version|v' => \$version,
-
 
129
   'quiet|q' => \$quiet
127
) or die "Error parsing command line\n";
130
) or die "Error parsing command line\n";
128
 
131
 
129
my $command = shift; # the first one is the actual subsection
132
my $command = shift; # the first one is the actual subsection
130
my $action = shift; # second is action to run
133
my $action = shift; # second is action to run
131
                  
134
                  
Line 169... Line 172...
169
} else {
172
} else {
170
   die "Error, I don't know the command [$command]\n";
173
   die "Error, I don't know the command [$command]\n";
171
}
174
}
172
 
175
 
173
if ( defined &{\&{$execute}} ) { # check if module::sub exists (ie, $command::action)
176
if ( defined &{\&{$execute}} ) { # check if module::sub exists (ie, $command::action)
174
  print &{\&{$execute}}(@ARGV); # yes, it exists, so call it with any remaining arguments
177
  my $message =  &{\&{$execute}}(@ARGV); # yes, it exists, so call it with any remaining arguments
-
 
178
  print $message unless $quiet;
175
} else { # method $action does not exist in module $command, so just a brief error message
179
} else { # method $action does not exist in module $command, so just a brief error message
176
  die "Error, could not find action [$action] for module [$command]\n";
180
  die "Error, could not find action [$action] for module [$command]\n";
177
} 
181
} 
178
 
182
 
179
 
183