Changeset 1728


Ignore:
Timestamp:
Mar 17, 2013, 6:10:40 AM (5 years ago)
Author:
bruno
Message:
  • pb_check_ps now may return 2 params, the second one being the port number used by the VM for SSH communication
  • If an existing VM is found, force the port number to the value used for further comm. Avoids to restart from base port, where a group of VMs has been launched and numbering doesn't correspond.
  • pb_get_port now uses pbport var only for VMs
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r1726 r1728  
    26842684
    26852685        my ($tmpcmd,$void) = split(/ +/,$cmd);
    2686         my $vmexist = pb_check_ps($tmpcmd,$vmm);
     2686        my ($vmexist,$vmmport) = pb_check_ps($tmpcmd,$vmm);
    26872687        my $vmpid = 0;
    26882688        if (! $vmexist) {
     
    27232723        } else {
    27242724            pb_log(0,"Found an existing VM $vmm (pid $vmexist)\n");
     2725            # Set the correct port here based on what is done
     2726            $pbport = $vmmport;
     2727            $vmpid = $vmexist;
    27252728        }
    27262729        pb_log(2,"DEBUG: pb_launchv returns ($vmexist,$vmpid)\n");
     
    37343737            my $ntag = "[2-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]";
    37353738            $pbver .= $ntag;
    3736             $findstr .= "-name \'$pbrealpkgrpm-$pbver-$pbtag\.*.rpm\' -o -name \'$pbrealpkgrpm-debug-$pbver-$pbtag\.*.rpm\' -o -name \'$pbrealpkgdeb"."_$pbver-$pbtag"."_*\.deb\' -o -name \'$pbrealpkgdeb"."_$pbver-$pbtag.dsc\' -o -name \'$pbrealpkgdeb"."_$pbver-$pbtag.tar.gz\' -o -name \'$pbrealpkg-$nver"."_p$ntag\.ebuild\' -o -name \'$pbrealpkg-$pbver-$pbtag*\.pkg\' -o -name \'$pbrealpkg-$pbver-$pbtag*\.sd\' ";
     3739            $findstr .= "-name \'$pbrealpkgrpm-$pbver-$pbtag\.*.rpm\' -o -name \'$pbrealpkgrpm-debug-$pbver-$pbtag\.*.rpm\' -o -name \'$pbrealpkgdeb"."_$pbver-$pbtag"."_*\.deb\' -o -name \'$pbrealpkgdeb"."_$pbver-$pbtag.dsc\' -o -name \'$pbrealpkgdeb"."_$pbver-$pbtag.tar.gz\' -o -name \'$pbrealpkg-$nver"."_p$ntag\.ebuild\' -o -name \'$pbrealpkg-$pbver-$pbtag*\.pkg\.gz\' -o -name \'$pbrealpkg-$pbver-$pbtag*\.sd\' ";
    37373740            $srcstr .= "src/$pbrealpkg-$pbver.tar.gz src/$pbrealpkg-$pbver.pbconf.tar.gz ";
    37383741        } else {
     
    37493752                $nver = $pbver."-r$pbtag";
    37503753            }
    3751             $findstr .= "-name \'$pbrealpkgrpm-$pbver-$pbtag\.*.rpm\' -o -name \'$pbrealpkgdeb"."_$pbver-$pbtag"."_*\.deb\' -o -name \'$pbrealpkg-$nver\.ebuild\' -o -name \'$pbrealpkg-$pbver\.pkg\' -o -name \'$pbrealpkg-$pbver\.sd\' ";
     3754            $findstr .= "-name \'$pbrealpkgrpm-$pbver-$pbtag\.*.rpm\' -o -name \'$pbrealpkgdeb"."_$pbver-$pbtag"."_*\.deb\' -o -name \'$pbrealpkg-$nver\.ebuild\' -o -name \'$pbrealpkg-$pbver\.pkg\.gz\' -o -name \'$pbrealpkg-$pbver\.sd\' ";
    37523755        }
    37533756
     
    37933796                    $archlist{"$pbos->{'name'}/$pbos->{'version'}/$pbrealpkg-$pbver$prefix$pbtag.ebuild"} = "$pbos->{'arch'}";
    37943797                } elsif ($pbos->{'type'} eq "pkg") {
    3795                     $theorlist{"$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}/$pbrealpkg-$pbver-$pbtag.pkg"} = 0;
     3798                    $theorlist{"$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}/$pbrealpkg-$pbver-$pbtag.pkg.gz"} = 0;
    37963799                } else {
    37973800                    pb_log(1,"No theoritical list possible for type $pbos->{'type'}\n");
     
    39173920                $excl .= $chkex->{$pkgn} if (defined $chkex->{$pkgn});
    39183921                $excl .= $chkex->{"all"} if (defined $chkex->{"all"});
     3922
     3923                pb_log(2,"Searching in excl $excl\n");
    39193924                foreach my $ex (split(/,/,$excl)) {
    39203925                    $found = 1 if ("$os-$ver-$arch" =~ /^$ex/);
     
    41604165
    41614166
    4162 # Returns the pid of a running VM command using a specific VM file
     4167# Returns the pid of a running VM command using a specific VM file, and the port used if the VM exists
    41634168sub pb_check_ps {
    41644169    my $vmcmd = shift;
    41654170    my $vmm = shift;
    41664171    my $vmexist = 0;        # FALSE by default
     4172    my $vmport = undef;         # NONE by default
    41674173
    41684174    open(PS, "ps auxhww|") || die "Unable to call ps";
     
    41714177        next if (! /$vmm/);
    41724178        my ($void1, $void2);
    4173         ($void1, $vmexist, $void2) = split(/ +/);
     4179        ($void1, $vmexist, $vmport) = split(/ +/,$_,3);
     4180        pb_log(2,"pb_check_ps $vmport\n");
     4181        $vmport =~ s/.*\stcp\:([0-9]+)\:10.0.2.15:22.*/$1/;
     4182        chomp($vmport);
     4183        pb_log(2,"pb_check_ps found a VM $vmexist using port $vmport\n");
    41744184        last;
    41754185    }
     4186    # Maintain compatibility by just returning PID if no port
     4187    return($vmexist,$vmport) if (defined $vmport);
    41764188    return($vmexist);
    41774189}
     
    43314343}
    43324344pb_log(2,"pb_get_port with $nport\n");
    4333 # Maybe a port was given as parameter so overwrite
    4334 $nport = "$pbport" if (defined $pbport);
    4335 # Maybe in // mode so use the env var set up as an offset to the base port, except when called from send2target for Packages or for RM
    4336 if (($cmt ne "Packages") && ($cmt !~ /^RM/i)) {
     4345if ($cmt =~ /^VM/i) {
     4346    # Maybe a port was given as parameter so overwrite
     4347    $nport = "$pbport" if (defined $pbport);
     4348    # Maybe in // mode so use the env var set up as an offset to the base port
    43374349    $nport += $ENV{'PBVMPORT'} if ((defined $pbparallel) && (defined $ENV{'PBVMPORT'}));
    43384350}
Note: See TracChangeset for help on using the changeset viewer.