Changeset 755 in ProjectBuilder for devel/pb/bin/pb


Ignore:
Timestamp:
Apr 3, 2009, 4:19:09 PM (15 years ago)
Author:
Bruno Cornec
Message:
  • Adds snapshot support for VEs
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r754 r755  
    14351435
    14361436    foreach my $v (@$vm) {
    1437         # Launch the VM/VE
     1437        # Launch VM/VE
     1438        ($vmexist,$vmpid) = pb_launchv($vtype,$v,0,$snapme);
     1439
    14381440        if ($vtype eq "vm") {
    1439             ($vmexist,$vmpid) = pb_launchv($vtype,$v,0,$snapme);
    14401441            pb_log(2,"DEBUG: After pb_launchv, vmexist: $vmexist, vmpid: $vmpid\n");
    14411442
     
    14651466    my $vtype = shift;
    14661467    my $v = shift;
    1467     my $create = shift || 0;        # By default do not create a VM
    1468     my $snapme = shift || 0;        # By default do not create a VM
     1468    my $create = shift || 0;        # By default do not create a VM/VE
     1469    my $snapme = shift || 0;        # By default do not snap a VM/VE
    14691470
    14701471    pb_log(2,"DEBUG: pb_launchv($vtype,$v,$create)\n");
     
    14971498            $ENV{'PBVMOPT'} .= " $vmopt->{$ENV{'PBPROJ'}}" if ($ENV{'PBVMOPT'} !~ / $vmopt->{$ENV{'PBPROJ'}}/);
    14981499        }
    1499         # Do not use snapshot feature at creation
    1500         if ($create != 0) {
     1500        # Use snapshot feature when not creating VM
     1501        if ($create == 0) {
    15011502            if ((defined $vmsnap->{$v}) && ($vmsnap->{$v} =~ /true/i)) {
    15021503                $ENV{'PBVMOPT'} .= " -snapshot";
     
    15841585        # Get VE context
    15851586        my ($ptr,$vetmout,$vepath,$verebuild,$veconf,$vepostinstall) = pb_conf_get("vetype","vetmout","vepath","verebuild","veconf");
    1586         my ($veb4pi,$vepi,$vepkglist) = pb_conf_get_if("veb4pi","vepi","vepkglist");
     1587        my ($veb4pi,$vepi,$vepkglist,$vesnap) = pb_conf_get_if("veb4pi","vepi","vepkglist","vesnap");
    15871588        my $vetype = $ptr->{$ENV{'PBPROJ'}};
    15881589
     
    16531654                }
    16541655            }
     1656            # Test if an existing snapshot exists and use it if appropriate
     1657            # And also use it of no local extracted VE is present
     1658            if ((-f "$vepath->{$ENV{'PBPROJ'}}/$ddir-$dver-$darch.tar.gz") &&
     1659                (((defined $vesnap->{$v}) && ($vesnap->{$v} =~ /true/i)) ||
     1660                    ((defined $vesnap->{$ENV{'PBPROJ'}}) && ($vesnap->{$ENV{'PBPROJ'}} =~ /true/i)) ||
     1661                    ($pbsnap eq 1) ||
     1662                    (! -d "$vepath->{$ENV{'PBPROJ'}}/$ddir/$dver/$darch"))) {
     1663                        pb_system("sudo mkdir -p $vepath->{$ENV{'PBPROJ'}}/$ddir/$dver/$darch ; sudo tar xz  -C $vepath->{$ENV{'PBPROJ'}}/$ddir/$dver/$darch -f $vepath->{$ENV{'PBPROJ'}}/$ddir-$dver-$darch.tar.gz","Extracting snapshot of $ddir-$dver-$darch.tar.gz under $vepath->{$ENV{'PBPROJ'}}/$ddir/$dver/$darch");
     1664            }
    16551665            # Nothing more to do for VE. No real launch
    16561666        } else {
     
    17851795    chmod 0755,"$ENV{'PBDESTDIR'}/pbscript";
    17861796   
     1797    # Launch the VM/VE
     1798    ($vmexist,$vmpid) = pb_launchv($vtype,$v,0);
     1799
    17871800    if ($vtype eq "vm") {
    1788         # Launch the VM
    1789         ($vmexist,$vmpid) = pb_launchv($vtype,$v,0);
    1790 
    17911801        # Skip that VM if it something went wrong
    17921802        next if (($vmpid == 0) && ($vmexist == 0));
     
    19841994EOF
    19851995
     1996    # Launch the VM/VE
     1997    ($vmexist,$vmpid) = pb_launchv($vtype,$v,0);
     1998
    19861999    if ($vtype eq "vm") {
    19872000        # Prepare the key to be used and transfered remotely
     
    19922005        $nport = "$pbport" if (defined $pbport);
    19932006   
    1994         # Launch the VM
    1995         ($vmexist,$vmpid) = pb_launchv($vtype,$v,0);
    1996 
    19972007        # Skip that VM if something went wrong
    19982008        next if (($vmpid == 0) && ($vmexist == 0));
     
    21642174    print SCRIPT << "EOF";
    21652175# This is needed in order to be able to halt the machine from the $pbac->{$ENV{'PBPROJ'}} account at least
    2166 print PBOUT "Defaults:pb env_keep += \"http_proxy ftp_proxy\"\n";
     2176print PBOUT "Defaults:pb env_keep += \\\"http_proxy ftp_proxy\\\"\n";
    21672177print PBOUT "$pbac->{$ENV{'PBPROJ'}}   ALL=(ALL) NOPASSWD:ALL\n";
    21682178EOF
Note: See TracChangeset for help on using the changeset viewer.