Changeset 262


Ignore:
Timestamp:
Oct 27, 2007, 2:18:22 AM (12 years ago)
Author:
bruno
Message:

Fix bug #7 where .pbrc nearly empty wasn't working

Location:
devel/pb
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r239 r262  
    4444my $pbport;                 # Port to use to connect to the VM
    4545my $newver;                 # New version to create
     46my $iso;                    # ISO iage for the VM to create
    4647my $LOG = \*STDOUT;
    4748
    48 getopts('a:hl:m:P:p:qr:s:tvV:',\%opts);
     49getopts('a:hi:l:m:P:p:qr:s:tvV:',\%opts);
    4950
    5051my ($projectbuilderver,$projectbuilderrev) = pb_version_init();
     
    9091if (defined $opts{'V'}) {
    9192    $newver = $opts{'V'};
     93}
     94if (defined $opts{'i'}) {
     95    $iso = $opts{'i'};
    9296}
    9397
     
    136140    pb_build2vm();
    137141} elsif ($action =~ /^launchvm$/) {
    138     pb_launchvm($ENV{'PBVM'});
     142    pb_launchvm($ENV{'PBVM'},0);
    139143} elsif ($action =~ /^script2vm$/) {
    140144    pb_script2vm($pbscript);
    141145} elsif ($action =~ /^newver$/) {
    142146    pb_newver();
     147} elsif ($action =~ /^newvm$/) {
     148    pb_launchvm($ENV{'PBVM'},1);
    143149} elsif ($action =~ /^clean$/) {
    144150} else {
     
    600606    foreach my $v (@$vm) {
    601607        # Launch the VM
    602         my ($vmexist,$vmpid) = pb_launchvm($v);
     608        my ($vmexist,$vmpid) = pb_launchvm($v,0);
    603609
    604610        # Gather all required files to send them to the VM
     
    611617sub pb_launchvm {
    612618    my $vm = shift;
    613 
     619    my $create = shift || 0;        # By default do not create a VM
     620
     621    die "-i iso parameter needed" if (((not defined $iso) || ($iso eq "")) && ($create != 0));
    614622    die "No VM defined, unable to launch" if (not defined $vm);
    615623    # Keep only the first VM in case many were given
     
    617625
    618626    # Launch the VMs
    619     my ($ptr,$vmopt,$vmport,$vmpath,$vmtmout) = pb_conf_get("vmtype","vmopt","vmport","vmpath","vmtmout");
     627    my ($ptr,$vmopt,$vmport,$vmpath,$vmtmout,$vmsize) = pb_conf_get("vmtype","vmopt","vmport","vmpath","vmtmout","vmsize");
    620628    my $vmtype = $ptr->{$ENV{'PBPROJ'}};
     629    if (not defined $ENV{'PBVMOPT'}) {
     630        $ENV{'PBVMOPT'} = "";
     631    }
    621632    if (defined $vmopt->{$ENV{'PBPROJ'}}) {
    622         $ENV{'PBVMOPT'} = $vmopt->{$ENV{'PBPROJ'}};
    623     } else {
    624         $ENV{'PBVMOPT'} = "";
     633        $ENV{'PBVMOPT'} .= " $vmopt->{$ENV{'PBPROJ'}}";
    625634    }
    626635    my $nport = $vmport->{$ENV{'PBPROJ'}};
     
    648657        }
    649658        $vmm = "$vmpath->{$ENV{'PBPROJ'}}/$vm.qemu";
    650         if (! -f "$vmm") {
    651             die "Unable to find VM $vmm";
     659        if ($create != 0) {
     660            $ENV{'PBVMOPT'} .= " -cdrom $iso -boot d";
    652661        }
    653662        $cmd = "$vmcmd $ENV{'PBVMOPT'} -redir tcp:$nport:10.0.2.15:22 $vmm"
     
    661670    my $vmpid = 0;
    662671    if (! $vmexist) {
     672        if ($create != 0) {
     673            pb_system("/usr/bin/qemu-img create -f qcow2 $vmm $vmsize->{$ENV{'PBPROJ'}}","Creating the QEMU VM");
     674        }
     675        if (! -f "$vmm") {
     676            die "Unable to find VM $vmm";
     677        }
    663678        pb_system("$cmd &","Launching the VM $vmm");
    664679        pb_system("sleep $vmtmout->{$ENV{'PBPROJ'}}","Waiting for VM $vm to come up");
     
    708723    foreach my $v (@$vm) {
    709724        # Launch the VM
    710         my ($vmexist,$vmpid) = pb_launchvm($v);
     725        my ($vmexist,$vmpid) = pb_launchvm($v,0);
    711726
    712727        # Gather all required files to send them to the VM
     
    715730    }
    716731}
     732
    717733
    718734sub pb_newver {
     
    888904    print "\t           and executes a script on it                 \n";
    889905    print "\n";
    890     print "\tnewver:    Create a new version of the project derived \n";
    891     print "\t           from the current one                        \n";
    892     print "\n";
    893 }
     906    print "\tnewvm:     Create a new virtual machine\n";
     907    print "\n";
     908    print "\tnewver:    Create a new version of the project derived \n";
     909    print "\t           from the current one                        \n";
     910    print "\n";
     911}
  • devel/pb/contrib/updateqemu

    r226 r262  
    1616
    1717export PBPROJ=pb
    18 export PBROOT=/users/bruno/pb/svn/0.8.5
     18export PBROOT=/users/bruno/pb/svn/devel
    1919
    2020for m in $opt; do
     
    2727    pb -m $m -a root -s /tmp/pbscript script2vm
    2828    sleep 120
    29     job=`ps auhxww | grep qemu | grep -Ev 'grep|updateqemu' | awk '{print $2}'`
     29    job=`ps auhxww | grep qemu | grep $m | grep -Ev 'grep|updateqemu' | awk '{print $2}'`
    3030    if [ _"$job" != _"" ]; then
    3131        echo "Really halting $m"
  • devel/pb/lib/ProjectBuilder/Base.pm

    r259 r262  
    233233my $p2;
    234234
     235#print "DEBUG: param1: ".Dumper(@ptr1)."\n"; # if ($debug >= 1);
     236#print "DEBUG: param2: ".Dumper(@ptr2)."\n"; # if ($debug >= 1);
     237
    235238foreach my $i (0..$#param) {
    236     die "No $param[$i] defined for $ENV{'PBPROJ'}" if ((not defined $ptr1[$i]) && (not defined $ptr2[$i]));
     239    $p1 = $ptr1[$i];
     240    $p2 = $ptr2[$i];
     241    die "No $param[$i] defined for $ENV{'PBPROJ'}" if ((not defined @ptr1) && (not defined @ptr2));
     242    die "No $param[$i] defined for $ENV{'PBPROJ'}" if ((not defined $p1) && (not defined $p2));
    237243    # Always try to take the param from the home dir conf file in priority
    238244    # in order to mask what could be defined under the CMS to allow for overloading
    239     $p1 = $ptr1[$i];
    240     $p2 = $ptr2[$i];
    241245    if (not defined $p2) {
    242246        # No ref in CMS project conf file so use the home dir one.
     
    266270    }
    267271    die "No $param[$i] defined for $ENV{'PBPROJ'}" if (not defined $p1->{$ENV{'PBPROJ'}});
    268 }
    269 #print "DEBUG: param: ".Dumper(@ptr)."\n" if ($debug >= 1);
     272    $ptr1[$i] = $p1;
     273    #print "DEBUG: param ptr1: ".Dumper(@ptr1)."\n"; # if ($debug >= 1);
     274}
    270275return(@ptr1);
    271276}
Note: See TracChangeset for help on using the changeset viewer.