--- trunk/vz-create.pl 2008/02/09 00:28:10 44 +++ trunk/vz-create.pl 2009/04/27 12:08:07 77 @@ -8,6 +8,7 @@ use Regexp::Common qw/net/; use lib 'lib'; use VZ; +use Getopt::Long; # default debian distribution my $dist = 'etch'; @@ -15,14 +16,18 @@ my $debian_mirror_uri = 'http://www.debian.org/debian'; my $arh = 'i386'; # split physicial machine in how meny virtual ones? -my $ve_total = 4; +my $split = 4; # swap size (Mb) my $swap_size = 512; # diskspace my $diskspace = '2G:4G'; -$dist = 'testing'; -$arh = 'amd64'; +GetOptions( + 'dist=s' => \$dist, + 'arh=s' => \$arh, + 'mirror=s' => \$debian_mirror_uri, + 'split=i' => \$split, +); check_root; @@ -68,7 +73,16 @@ my @ip_split = split(/\./,$ip); -my $ve_id = sprintf('%d%03d', $ip_split[2], $ip_split[3]); +# 192.168.42.1 -> 42 001 +# 10.60.0.3 -> 60 003 +# 10.60.1.42 -> 1 042 + +my $ve_id = sprintf('%d%03d', $ip_split[2] || $ip_split[1], $ip_split[3]); + +if ( $ve_id < 101 ) { + $ve_id += 100; + warn "# VEID moved to $ve_id because 0 .. 100 are reserved\n"; +} print "VEID: $ve_id hostname: $hostname ip: $ip\n"; @@ -94,7 +108,7 @@ if (-e $conf_path) { warn "$conf_path allready exists, not touching it\n"; } else { - vzsplit('-n', $ve_total, '-s', $swap_size * 1024, '>', $conf_path); + vzsplit('-n', $split, '-s', $swap_size * 1024, '>', $conf_path); die "configuration file not created" unless -e $conf_path; @@ -139,4 +153,5 @@ vzctl('set', $ve_id, '--userpasswd', "$login:$passwd" ); } +#runscript( $ve_id, 'custom/50-hypertable.sh' ); print "OK: $ve_id created\n";