Subversion Repositories havirt

Rev

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

Rev 12 Rev 14
Line 50... Line 50...
50
   use Cwd 'abs_path';
50
   use Cwd 'abs_path';
51
   use File::Basename;
51
   use File::Basename;
52
   use lib dirname( abs_path( __FILE__ ) );
52
   use lib dirname( abs_path( __FILE__ ) );
53
}
53
}
54
 
54
 
55
 
-
 
56
 
-
 
57
 
-
 
58
 
-
 
59
use havirt; # Load all our shared stuff
55
use havirt; # Load all our shared stuff
60
 
56
 
61
use Data::Dumper;
57
use Data::Dumper;
62
use YAML::Tiny;
58
use YAML::Tiny;
63
 
59
 
Line 72... Line 68...
72
# allow -vvn (ie, --verbose --verbose --dryrun)
68
# allow -vvn (ie, --verbose --verbose --dryrun)
73
Getopt::Long::Configure ("bundling");
69
Getopt::Long::Configure ("bundling");
74
 
70
 
75
 
71
 
76
# global variables
72
# global variables
77
my $scriptDir = $FindBin::RealBin;
73
our $scriptDir = $FindBin::RealBin;
78
my $scriptName = $FindBin::Script;
74
my $scriptName = $FindBin::Script;
79
my $dbDir = "$scriptDir/var";
75
my $dbDir = "$scriptDir/var";
80
our $confDir = "$scriptDir/conf";
76
our $confDir = "$scriptDir/conf";
81
our $statusDBName = "$dbDir/status.yaml";
77
our $statusDBName = "$dbDir/status.yaml";
82
our $lastScanFileName = "$scriptDir/lastscan";
78
our $lastScanFileName = "$scriptDir/lastscan";
Line 96... Line 92...
96
my $version = 0;
92
my $version = 0;
97
 
93
 
98
sub help {
94
sub help {
99
   print "$0 command [argument]\n";
95
   print "$0 command [argument]\n";
100
   print "where command is one of\n";
96
   print "where command is one of\n";
101
   print "\tnode update|list|scan # work with a node\n";
97
   print "\tnode [help] # work with a node\n";
102
   print "\tdomain update|list # work with individual domains\n";
98
   print "\tdomain [help] # work with individual domains\n";
103
   print "\tcluster status # report of memory and vcpu status on all nodes\n";
99
   print "\tcluster [help] # report of memory and vcpu status on all nodes\n";
104
   print "For additional help, run command help\n";
-
 
105
   print "\tnode help # or domain, or cluster\n";
-
 
106
   print "Some flags can be used where appropriate\n";
100
   print "Some flags can be used where appropriate\n";
107
   print "\t--help|-h # show this screen\n";
101
   print "\t--help|-h # show this screen\n";
108
   print "\t--version|-v # show version of program\n";
102
   print "\t--version|-v # show version of program\n";
109
   print "\t--format|-f screen|tsv # output of list commands is either padded for screen or Tab Delim\n";
103
   print "\t--format|-f screen|tsv # output of list commands is either padded for screen or Tab Delim\n";
110
   print "\t--target|-t NODE # the action use NODE for the target of actions\n";
104
   print "\t--target|-t NODE # the action use NODE for the target of actions\n";
Line 129... Line 123...
129
   'quiet|q' => \$quiet
123
   'quiet|q' => \$quiet
130
) or die "Error parsing command line\n";
124
) or die "Error parsing command line\n";
131
 
125
 
132
my $command = shift; # the first one is the actual subsection
126
my $command = shift; # the first one is the actual subsection
133
my $action = shift; # second is action to run
127
my $action = shift; # second is action to run
-
 
128
$action = 'help' unless $action;
134
                  
129
                  
135
if ( $help || ! $command ) { &help() ; exit; }
130
if ( $help || $command eq 'help' || ! $command ) { &help() ; exit; }
136
if ( $version ) { use File::Basename; print basename($0) . " v$VERSION\n"; exit; }
131
if ( $version ) { use File::Basename; print basename($0) . " v$VERSION\n"; exit; }
137
 
132
 
138
 
133
 
139
print "Parameters are\nreportFormat\t$reportFormat\ntargetNode\t$targetNode\ndryRun\t$dryRun\nDEBUG\t$DEBUG\n" if $DEBUG;
134
print "Parameters are\nreportFormat\t$reportFormat\ntargetNode\t$targetNode\ndryRun\t$dryRun\nDEBUG\t$DEBUG\n" if $DEBUG;
140
print "Command = $command\nAction = $action\n" if $DEBUG;
135
print "Command = $command\nAction = $action\n" if $DEBUG;