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

Contents of /trunk/vz-enter.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 54 - (show annotations)
Fri Aug 15 10:53:25 2008 UTC (14 years, 5 months ago) by dpavlin
File MIME type: text/plain
File size: 672 byte(s)
enter into any virtual machine by unique part of hostname
1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 use lib 'lib';
7 use VZ;
8
9 my $hostname = $ARGV[0] || die "usage: $0 part_of_hostname\n";
10
11 check_root;
12 my $vzlist = vzlist( hash => 1 );
13
14 sub ve_info {
15 my ( $veid ) = @_;
16 return join("\t", map { $vzlist->{$veid}->{$_} } ( qw/ip hostname laverage numproc/ ) );
17 }
18
19 my @veids = grep {
20 $vzlist->{$_}->{status} eq 'running' &&
21 $vzlist->{$_}->{hostname} =~ m/\Q$hostname\E/ &&
22 $vzlist->{$_}->{vpsid}
23 } keys %$vzlist;
24
25 die "$hostname not unique:\n", join("\n",
26 map { ve_info( $_ ) } @veids
27 ), "\n" unless $#veids == 0;
28 my $veid = shift @veids or die "can't find $hostname";
29
30 print ve_info( $veid ), "\n";
31
32 vzctl( 'enter', $veid );
33

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26