Changeset 262 in ProjectBuilder
- Timestamp:
- Oct 27, 2007, 2:18:22 AM (16 years ago)
- Location:
- devel/pb
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb/bin/pb
r239 r262 44 44 my $pbport; # Port to use to connect to the VM 45 45 my $newver; # New version to create 46 my $iso; # ISO iage for the VM to create 46 47 my $LOG = \*STDOUT; 47 48 48 getopts('a:h l:m:P:p:qr:s:tvV:',\%opts);49 getopts('a:hi:l:m:P:p:qr:s:tvV:',\%opts); 49 50 50 51 my ($projectbuilderver,$projectbuilderrev) = pb_version_init(); … … 90 91 if (defined $opts{'V'}) { 91 92 $newver = $opts{'V'}; 93 } 94 if (defined $opts{'i'}) { 95 $iso = $opts{'i'}; 92 96 } 93 97 … … 136 140 pb_build2vm(); 137 141 } elsif ($action =~ /^launchvm$/) { 138 pb_launchvm($ENV{'PBVM'} );142 pb_launchvm($ENV{'PBVM'},0); 139 143 } elsif ($action =~ /^script2vm$/) { 140 144 pb_script2vm($pbscript); 141 145 } elsif ($action =~ /^newver$/) { 142 146 pb_newver(); 147 } elsif ($action =~ /^newvm$/) { 148 pb_launchvm($ENV{'PBVM'},1); 143 149 } elsif ($action =~ /^clean$/) { 144 150 } else { … … 600 606 foreach my $v (@$vm) { 601 607 # Launch the VM 602 my ($vmexist,$vmpid) = pb_launchvm($v );608 my ($vmexist,$vmpid) = pb_launchvm($v,0); 603 609 604 610 # Gather all required files to send them to the VM … … 611 617 sub pb_launchvm { 612 618 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)); 614 622 die "No VM defined, unable to launch" if (not defined $vm); 615 623 # Keep only the first VM in case many were given … … 617 625 618 626 # 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"); 620 628 my $vmtype = $ptr->{$ENV{'PBPROJ'}}; 629 if (not defined $ENV{'PBVMOPT'}) { 630 $ENV{'PBVMOPT'} = ""; 631 } 621 632 if (defined $vmopt->{$ENV{'PBPROJ'}}) { 622 $ENV{'PBVMOPT'} = $vmopt->{$ENV{'PBPROJ'}}; 623 } else { 624 $ENV{'PBVMOPT'} = ""; 633 $ENV{'PBVMOPT'} .= " $vmopt->{$ENV{'PBPROJ'}}"; 625 634 } 626 635 my $nport = $vmport->{$ENV{'PBPROJ'}}; … … 648 657 } 649 658 $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"; 652 661 } 653 662 $cmd = "$vmcmd $ENV{'PBVMOPT'} -redir tcp:$nport:10.0.2.15:22 $vmm" … … 661 670 my $vmpid = 0; 662 671 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 } 663 678 pb_system("$cmd &","Launching the VM $vmm"); 664 679 pb_system("sleep $vmtmout->{$ENV{'PBPROJ'}}","Waiting for VM $vm to come up"); … … 708 723 foreach my $v (@$vm) { 709 724 # Launch the VM 710 my ($vmexist,$vmpid) = pb_launchvm($v );725 my ($vmexist,$vmpid) = pb_launchvm($v,0); 711 726 712 727 # Gather all required files to send them to the VM … … 715 730 } 716 731 } 732 717 733 718 734 sub pb_newver { … … 888 904 print "\t and executes a script on it \n"; 889 905 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 16 16 17 17 export PBPROJ=pb 18 export PBROOT=/users/bruno/pb/svn/ 0.8.518 export PBROOT=/users/bruno/pb/svn/devel 19 19 20 20 for m in $opt; do … … 27 27 pb -m $m -a root -s /tmp/pbscript script2vm 28 28 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}'` 30 30 if [ _"$job" != _"" ]; then 31 31 echo "Really halting $m" -
devel/pb/lib/ProjectBuilder/Base.pm
r259 r262 233 233 my $p2; 234 234 235 #print "DEBUG: param1: ".Dumper(@ptr1)."\n"; # if ($debug >= 1); 236 #print "DEBUG: param2: ".Dumper(@ptr2)."\n"; # if ($debug >= 1); 237 235 238 foreach 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)); 237 243 # Always try to take the param from the home dir conf file in priority 238 244 # in order to mask what could be defined under the CMS to allow for overloading 239 $p1 = $ptr1[$i];240 $p2 = $ptr2[$i];241 245 if (not defined $p2) { 242 246 # No ref in CMS project conf file so use the home dir one. … … 266 270 } 267 271 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 } 270 275 return(@ptr1); 271 276 }
Note:
See TracChangeset
for help on using the changeset viewer.