annotate bin/minions.pl @ 3:7b132bac6d4d

Fixed systemd dependencies
author andrei <andrei@nap21.upri>
date Tue, 15 Nov 2016 12:11:55 +0300
parents cd5df456ee84
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
1 #!/usr/bin/perl -T
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
2 use strict;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
3 use warnings;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
4
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
5 package Hive;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
6
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
7 package main;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
8 use Pod::Usage;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
9 use Getopt::Long qw(:config auto_help);
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
10 use Sys::Virt;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
11 use Sys::Virt::Domain;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
12
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
13 our $VERSION = 0.1;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
14 our $CONFIG_FILE = '/etc/minions/hive.yaml';
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
15 our $STATE_FILE = '/var/lib/minions/session.yaml';
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
16 our $TIMEOUT = 300;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
17 our $PARALLEL = 0;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
18 our $RETRY_INTERVAL = 60;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
19
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
20 my $tasks = 2;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
21 my @pending;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
22
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
23 my @uri = qw(qemu:///system lxc:///);
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
24
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
25 my %commands = (
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
26 stop => \&doStop,
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
27 start => \&doStart,
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
28 help => \&doHelp
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
29 );
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
30
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
31 my $cmd = shift @ARGV;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
32
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
33 &{ $commands{ lc( $cmd || '' ) } || \&doHelp }(@ARGV);
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
34
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
35 exit 0;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
36
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
37 sub doHelp {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
38 print <<END_HELP;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
39 Minions v.$VERSION manages libvirt domains...
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
40 stop [domain[ stop-method]]
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
41 Stops the specified libvirt domain with the specified method. If the
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
42 domain isn't specified then stops all domains on all configured
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
43 connections and saves the list of stopped domains to
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
44 /var/lib/minions/session.yaml file.
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
45
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
46 start [domain]
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
47 Starts the specified domain, if the domain is ommited restores the
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
48 previous session from /var/lib/minions/session.yaml and deletes this
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
49 file.
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
50 help
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
51 Prints this help
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
52
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
53 domain must be written in format {connection}.{domain} where {connection} is
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
54 the one of configured connections from /etc/minions/hive.yaml and {domain}
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
55 is the name of the libvirt domain.
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
56 END_HELP
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
57 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
58
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
59 sub doStart {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
60 my $hive = Hive->new($CONFIG_FILE);
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
61
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
62 if ( @_ > 0 ) {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
63 if ( my ( $cn, $dn ) = ( $_[0] =~ m/(\w+)\.(\w+)/ ) ) {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
64 $hive->startDomain( $cn, $dn );
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
65 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
66 else {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
67 die "Invalid parameter: {connection}.{domain} format is required";
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
68 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
69 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
70 else {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
71 $hive->start();
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
72 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
73 $hive->waitPending();
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
74 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
75
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
76 sub doStop {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
77 my $hive = Hive->new($CONFIG_FILE);
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
78
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
79 if ( @_ > 0 ) {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
80 if ( my ( $cn, $dn ) = ( $_[0] =~ m/(\w+)\.(\w+)/ ) ) {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
81 $hive->stopDomain( $cn, $dn );
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
82 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
83 else {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
84 die "Invalid parameter: {connection}.{domain} format is required";
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
85 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
86 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
87 else {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
88 $hive->stop();
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
89 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
90
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
91 $hive->waitPending();
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
92 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
93
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
94 package Hive;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
95 use fields qw(config vmms _pending);
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
96 use YAML::XS qw(DumpFile LoadFile Dump);
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
97 use Sys::Virt;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
98 use Sys::Virt::Domain;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
99 use File::Spec;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
100
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
101 BEGIN {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
102 no strict 'refs';
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
103 *{ __PACKAGE__ . "::$_" } = \*{"Sys::Virt::Domain::$_"}
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
104 for qw(STATE_SHUTOFF LIST_PERSISTENT LIST_ACTIVE);
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
105 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
106
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
107 sub new {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
108 my Hive $this = fields::new(shift);
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
109 $this->init(@_);
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
110 return $this;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
111 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
112
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
113 sub init {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
114 my Hive $this = shift;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
115 my $file = shift;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
116
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
117 my $config = $this->{config} = LoadFile($file);
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
118
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
119 while ( my ( $name, $info ) = each %{ $config->{vmms} || {} } ) {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
120 eval {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
121 die "Invalid connection info $name"
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
122 unless ref($info) and $info->{uri};
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
123
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
124 $this->trace_info("Connection '$name': $info->{uri}");
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
125 $this->{vmms}{$name}{stop} = lc( $info->{stop} || 'shutdown' );
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
126
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
127 die "Unsupported stop method: $info->{stop}"
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
128 unless grep $_ eq $this->{vmms}{$name}{stop},
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
129 qw(suspend shutdown);
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
130
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
131 $this->{vmms}{$name}{instance} =
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
132 Sys::Virt->new( uri => $info->{uri} );
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
133 };
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
134 $this->trace_error("Failed to connect '$name': $@") if $@;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
135 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
136 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
137
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
138 sub stop {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
139 my Hive $this = shift;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
140
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
141 my @pending;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
142
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
143 my %stopped;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
144
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
145 while ( my ( $name, $vmm ) = each %{ $this->{vmms} || {} } ) {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
146 next unless $vmm->{instance};
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
147
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
148 $this->trace_info("Do $vmm->{stop} for all domains on $name");
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
149
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
150 my @domains =
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
151 $vmm->{instance}->list_all_domains( LIST_PERSISTENT | LIST_ACTIVE );
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
152 $stopped{$name} = [ map $_->get_name(), @domains ];
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
153
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
154 $this->trace_info( "\t-" . $_->get_name() )
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
155 and $this->_safeStop( $_, $vmm->{stop} )
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
156 for @domains;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
157 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
158
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
159 my $state = $this->{config}{sate_file} || $STATE_FILE;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
160
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
161 my $dir = ( File::Spec->splitpath($state) )[1];
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
162 mkdir $dir unless -e $dir;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
163
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
164 DumpFile( $state, \%stopped );
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
165 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
166
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
167 sub start {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
168 my Hive $this = shift;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
169
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
170 my $state = $this->{config}{sate_file} || $STATE_FILE;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
171 my $session = -f $state ? LoadFile($state) : {};
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
172
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
173 while ( my ( $name, $machines ) = each %{$session} ) {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
174 my $vmm = $this->{vmms}{$name}
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
175 or $this->trace_error(
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
176 "Failed to resotre session for '$name': no such connection")
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
177 and next;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
178
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
179 $this->trace_info("Restoring domains on '$name'");
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
180 for my $m ( @{ $machines || [] } ) {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
181 my $d = $vmm->{instance}->get_domain_by_name($m)
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
182 or $this->trace_error("\t-$m not found")
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
183 and next;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
184
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
185 eval {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
186 $this->trace_info("\t-$m");
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
187 $this->_safeStart($d);
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
188 };
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
189 $this->trace_error("$@") if $@;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
190 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
191 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
192
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
193 unlink $state if -f $state;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
194 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
195
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
196 sub startDomain {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
197 my Hive $this = shift;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
198 my ( $cn, $dn ) = @_;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
199
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
200 $this->trace_info("Start $cn.$dn");
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
201 my $con = $this->{vmms}{$cn}
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
202 or die "Connection '$cn' doesn't exists";
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
203
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
204 my $dom = $con->{instance}->get_domain_by_name($dn)
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
205 or die "Domain $dn isn't found in '$cn'";
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
206
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
207 return $this->_safeStart($dom);
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
208 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
209
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
210 sub _resolveDomain {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
211 my Hive $this = shift;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
212 my ( $cn, $dn ) = @_;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
213
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
214 my $con = $this->{vmms}{$cn}
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
215 or die "Connection '$cn' doesn't exists";
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
216
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
217 my $dom = $con->{instance}->get_domain_by_name($dn)
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
218 or die "Domain $dn isn't found in '$cn'";
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
219 return $dom;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
220 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
221
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
222 sub _safeStart {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
223 my Hive $this = shift;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
224 my $dom = shift;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
225
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
226 eval {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
227 unless ( $dom->is_active() ) {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
228 $dom->create();
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
229 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
230 else {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
231 $this->trace_info(
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
232 "The domain " . $dom->get_name() . " already active" );
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
233 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
234 };
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
235 if ($@) {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
236 die "$@" unless $dom->is_active();
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
237 $this->trace_info("$@");
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
238 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
239 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
240
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
241 sub stopDomain {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
242 my Hive $this = shift;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
243 my ( $cn, $dn, $method ) = @_;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
244
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
245 $this->trace_info("Stop $cn.$dn");
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
246 my $dom = $this->_resolveDomain( $cn, $dn );
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
247
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
248 # if stop method is not specified use the default one
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
249 $method = $this->{vmms}{$cn}{stop} || 'shutdown'
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
250 unless $method;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
251
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
252 return $this->_safeStop( $dom, $method );
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
253 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
254
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
255 sub _safeStop {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
256 my Hive $this = shift;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
257 my ( $dom, $method ) = @_;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
258
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
259 eval {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
260 if ( $method eq 'shutdown' ) {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
261 push @{ $this->{_pending} }, Shutdown->new($dom);
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
262 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
263 elsif ( $method eq 'suspend' ) {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
264 $dom->managed_save();
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
265 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
266 };
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
267 $this->trace_error( "failed to $method " . $dom->get_name() . ": $@" )
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
268 if $@;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
269 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
270
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
271 sub waitPending {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
272 my Hive $this = shift;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
273
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
274 my $timeout = $this->{config}{timeout} || $TIMEOUT;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
275 my $parallel = $this->{config}{parallel} || $PARALLEL;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
276 my $retry = $this->{config}{retryInterval} || $RETRY_INTERVAL;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
277
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
278 my @pending = @{ $this->{_pending} || [] };
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
279 $this->{_pending} = [];
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
280
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
281 my $spins = 0;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
282
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
283 $this->trace_info("Waiting for operations to complete")
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
284 if @pending;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
285
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
286 while (@pending) {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
287 my @queue;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
288 my $slots = $parallel;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
289 $spins++;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
290 foreach my $task (@pending) {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
291 my $name = $task->getName();
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
292 my $duration = $task->getDuration();
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
293
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
294 if ( $task->isComplete() ) {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
295 $this->trace_info("\t- $name stopped in $duration s");
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
296 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
297 elsif ( $duration > $timeout ) {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
298 $this->trace_info(
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
299 "\t- $name destroyed due timeout after $duration s");
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
300 $task->terminate();
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
301 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
302 else {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
303 $task->start()
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
304 if not $task->isStarted()
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
305 and ( $parallel == 0 || --$slots >= 0 );
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
306 $this->trace_info("\tretry $name after $duration s")
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
307 and $task->signal()
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
308 if $retry and $spins % $retry == 0;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
309 push @queue, $task;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
310 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
311 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
312 sleep(1) if @pending = @queue;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
313 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
314 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
315
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
316 sub trace_info {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
317 shift;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
318 print @_, "\n";
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
319 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
320
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
321 sub trace_error {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
322 shift;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
323 print STDERR @_, "\n";
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
324 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
325
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
326 package Shutdown;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
327 use fields qw(_domain _startTime _started);
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
328
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
329 BEGIN {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
330 no strict 'refs';
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
331 *{ __PACKAGE__ . "::$_" } = \*{"Sys::Virt::Domain::$_"}
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
332 for qw(STATE_SHUTOFF LIST_PERSISTENT LIST_ACTIVE);
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
333 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
334
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
335 sub new {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
336 my Shutdown $self = fields::new(shift);
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
337 $self->{_domain} = shift;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
338 return $self;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
339 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
340
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
341 sub isComplete {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
342 my Shutdown $this = shift;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
343 return $this->{_domain}->get_info()->{state} == STATE_SHUTOFF;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
344 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
345
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
346 sub getName {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
347 my Shutdown $this = shift;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
348 return $this->{_domain}->get_name();
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
349 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
350
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
351 sub getDuration {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
352 my Shutdown $this = shift;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
353 return ( $this->{_startTime} ? time - $this->{_startTime} : 0 );
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
354 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
355
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
356 sub terminate {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
357 my Shutdown $this = shift;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
358 return eval { $this->{_domain}->destroy() };
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
359 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
360
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
361 sub signal {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
362 my Shutdown $this = shift;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
363
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
364 eval { $this->{_domain}->shutdown() };
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
365 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
366
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
367 sub start {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
368 my Shutdown $this = shift;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
369
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
370 $this->{_started} = 1;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
371 $this->{_startTime} = time;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
372
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
373 $this->signal();
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
374 }
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
375
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
376 sub isStarted {
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
377 my Shutdown $this = shift;
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
378 return $this->{_started};
cd5df456ee84 Initial working version of minions.pl ans sysyemd units
cin
parents:
diff changeset
379 }