/[vz-tools]/trunk/lib/VZ.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/VZ.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 42 by dpavlin, Fri Feb 8 23:53:40 2008 UTC revision 49 by dpavlin, Thu Aug 14 22:47:54 2008 UTC
# Line 7  ip2hostname Line 7  ip2hostname
7  hostname2ip  hostname2ip
8    
9  conf_veids  conf_veids
10    runscript
11    
12  vzctl  vzctl
13  vzlist  vzlist
# Line 87  sub conf_veids { Line 88  sub conf_veids {
88          open( my $cfgs, 'find /etc/vz/conf -maxdepth 1 -name "*.conf" |' ) || die "can't run find: $!";          open( my $cfgs, 'find /etc/vz/conf -maxdepth 1 -name "*.conf" |' ) || die "can't run find: $!";
89          while(<$cfgs>) {          while(<$cfgs>) {
90                  chomp;                  chomp;
91                  if ( m#^.+/(\d+)\.conf$# ) {                  if ( m{^.+/(\d+)\.conf$} ) {
92                          if ( -d "$vz_root/private/$1" ) {                          if ( -d "$vz_root/private/$1" ) {
93                                  push @c, $1;                                  push @c, $1;
94                          } else {                          } else {
# Line 100  sub conf_veids { Line 101  sub conf_veids {
101          return @c;          return @c;
102  }  }
103    
104    =head2 runscript
105    
106      runscript( $veid, '/path/to/script' );
107    
108    =cut
109    
110    sub runscript {
111            my ( $veid, $path ) = @_;
112    
113            if ( open(my $fh, $path) ) {
114                    while(<$fh>) {
115                            chomp;
116                            next if (m/^\s*$/);
117                            if (/^#\s+(.+)$/) {
118                                    warn ">> $1\n";
119                            } else {
120                                    vzctl('exec', $veid, $_);
121                            }
122                    }
123            } else {
124                    warn "can't open $path: $!";
125            }
126    }
127                    
128    
129  =head2 vzctl  =head2 vzctl
130    
131    vzctl('set','--something',42);    vzctl('set','--something',42);
# Line 108  sub conf_veids { Line 134  sub conf_veids {
134    
135  sub vzctl {  sub vzctl {
136          my @args = @_;          my @args = @_;
137          warn "## vzctl ", join(" ",@args), "\n";          my $a = join(' ', @args);
138            # hide passwords from output
139            $a =~ s/(--userpasswd\s+\w+:)\w+/$1********/;
140            warn "## vzctl $a\n";
141          system('vzctl',@args) == 0 or die "vzctl @args failed: $?"          system('vzctl',@args) == 0 or die "vzctl @args failed: $?"
142  }  }
143    

Legend:
Removed from v.42  
changed lines
  Added in v.49

  ViewVC Help
Powered by ViewVC 1.1.26