]>
Commit | Line | Data |
---|---|---|
80e7574f DM |
1 | #!/usr/bin/perl |
2 | ||
3 | use strict; | |
4 | use warnings; | |
460f26d3 | 5 | use lib '/usr/share/pve-ha-simulator'; |
80e7574f DM |
6 | use Getopt::Long; |
7 | use JSON; | |
8 | ||
9 | use PVE::Tools; | |
bf93e2a2 | 10 | use PVE::HA::Sim::TestHardware; |
9de9a6ce | 11 | use PVE::HA::Sim::RTHardware; |
80e7574f | 12 | |
460f26d3 | 13 | my $opt_batch; |
80e7574f DM |
14 | |
15 | sub show_usage { | |
460f26d3 | 16 | print "usage: $0 <testdir> [--batch]\n"; |
80e7574f DM |
17 | exit(-1); |
18 | }; | |
19 | ||
460f26d3 | 20 | if (!GetOptions ("batch" => \$opt_batch)) { |
80e7574f DM |
21 | show_usage(); |
22 | } | |
23 | ||
24 | my $testdir = shift || show_usage(); | |
25 | ||
9de9a6ce DM |
26 | my $hardware; |
27 | ||
460f26d3 | 28 | if ($opt_batch) { |
9de9a6ce | 29 | $hardware = PVE::HA::Sim::TestHardware->new($testdir); |
460f26d3 DM |
30 | } else { |
31 | $hardware = PVE::HA::Sim::RTHardware->new($testdir); | |
9de9a6ce | 32 | } |
80e7574f | 33 | |
caa07bae | 34 | $hardware->log('info', "starting simulation"); |
80e7574f DM |
35 | |
36 | eval { $hardware->run(); }; | |
37 | if (my $err = $@) { | |
38 | $hardware->log('err', "exit simulation - $err "); | |
39 | } else { | |
40 | $hardware->log('info', "exit simulation - done"); | |
41 | } | |
42 | ||
43 | exit(0); | |
44 | ||
45 | ||
46 |