Changeset 1176


Ignore:
Timestamp:
Feb 7, 2011, 2:24:11 PM (9 years ago)
Author:
bruno
Message:

r4160@eelzbach2: bruno | 2011-02-06 13:30:39 +0100

  • Adds support for Remote Machines (RM). Not tested yet.
Location:
devel
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • devel/pb-modules/etc/pb.conf

    r1159 r1176  
    477477# Commands to check packages
    478478#
     479# Config-Model needs oschkcmd:rpm=/.... (Cf Config::Model::Loader)
    479480oschkcmd rpm = /usr/bin/rpmlint
    480481oschkopt rpm =
  • devel/pb-modules/etc/pb.conf.pod

    r1153 r1176  
    398398 Conffile: ve
    399399 Example: rbspi centos = /home/rinse/bin/post-install.sh
     400
     401=item B<rmhost>
     402
     403 Nature: Mandatory
     404 Key: OS (could be from the most generic up to the most specific from ostype, osfamily, os, os-ver, os-ver-arch). The family name is generaly used here.
     405 Value: IP address or name of the Remote Machine running the OS mentioned in the key, accessed through ssh.
     406 Conffile: rm
     407 Example: rmhost default = localhost - rmhost hpux-11.3-ia64 = 10.10.10.10 - rmhost mandriva-2010.2-x86_64 = machine1.domain.name
     408
     409=item B<rmlist>
     410
     411 Nature: Mandatory
     412 Key: project (as defined in the -p option or PBPROJ environment variable)
     413 Value: list of coma separated OS (under the form of os-ver-arch). The corresponding machines running these distributions are given in the rmpool parameter.
     414 Conffile: rm
     415 Example: rmlist default = mandriva-2010.2-i386,fedora-14-i386,rhel-6-i386,rhel-5-i386,pensuse-11.3-i386,sles-11-i386,gentoo-nover-i386,debian-5.0-i386,ubuntu-10.10-i386,solaris-10-i386,mandriva-2010.2-x86_64,fedora-14-x86_64,rhel-6-x86_64,rhel-5-x86_64,opensuse-11.3-x86_64,sles-11-x86_64,gentoo-nover-x86_64,debian-5.0-x86_64,ubuntu-10.10-x86_64,solaris-10-x86_64,hp-ux-11.3-ia64,rhel-5-ia64
     416
     417=item B<rmlogin>
     418
     419 Nature: Mandatory
     420 Key: project (as defined in the -p option or PBPROJ environment variable)
     421 Value: account name to use on the Remote Machine to build packages. Communication is done with ssh.
     422 Conffile: rm
     423 Example: rmlogin default = pb
     424
     425=item B<rmmonport>
     426
     427 Nature: Optional
     428 Key: project (as defined in the -p option or PBPROJ environment variable)
     429 Value: TCP port that is used to dialog with the monitor of the Remote Machine, to pass orders.
     430 Conffile: rm
     431 Example: rmmonport default = 4444
     432
     433=item B<rmntp>
     434
     435 Nature: Optional
     436 Key: project (as defined in the -p option or PBPROJ environment variable)
     437 Value: NTP server to contact for time accuracy with B<rmntpcmd> before building.
     438 Conffile: rm
     439 Example: rmntp default = 1.pool.ntp.org
     440
     441=item B<rmntpcmd>
     442
     443 Nature: Optional
     444 Key: project (as defined in the -p option or PBPROJ environment variable)
     445 Value: NTP command to use to perform time synchronization with the B<rmntp> server.
     446 Conffile: rm
     447 Example: rmntpcmd default = /usr/sbin/ntpdate,rmntpcmd opensuse-10.1-i386 = sntp -P no -r
     448
     449=item B<rmpath>
     450
     451 Nature: Mandatory
     452 Key: project (as defined in the -p option or PBPROJ environment variable)
     453 Value: path where to find configuration file for Remote Machines management.
     454 Conffile: rm
     455 Example: rmpath default = /home/remote
     456
     457=item B<rmport>
     458
     459 Nature: Mandatory
     460 Key: project (as defined in the -p option or PBPROJ environment variable)
     461 Value: port number to use to communicate with the RM using the SSH protocol. This localport is redirected to the port 22 of the RM.
     462 Conffile: rm
     463 Example: rmport pb = 2222,rmport mondorescue = 2223
     464
     465=item B<rmtmout>
     466
     467 Nature: Optional
     468 Key: OS (could be from the most generic up to the most specific from ostype, osfamily, os, os-ver, os-ver-arch). The family name is generaly used here.
     469 Value: Time in seconds to wait before interacting with the VM. This should correspond to the time the VM takes to boot.
     470 Conffile: rm
     471 Example: rmtmout default = 180
     472
     473=item B<rmtype>
     474
     475 Nature: Mandatory
     476 Key: project (as defined in the -p option or PBPROJ environment variable)
     477 Value: ssh. For the moment, only ssh is supported as a communication means with RM.
     478 Conffile: rm
     479 Example: rmrtype default = ssh
     480
    400481
    401482=item B<supfiles>
  • devel/pb/bin/pb

    r1174 r1176  
    1313
    1414# The modules mentioned here are required by pb when used both
    15 # locally or inside a VE/VM
     15# locally or inside a VE/VM/RM
    1616# Additional required modules only used locally are called with a require
    1717# in their respective section
     
    5151my %pbtag;                  # per package
    5252my $pbrev;                  # Global REVISION variable
    53 my $pbaccount;              # Login to use to connect to the VM
     53my $pbaccount;              # Login to use to connect to the VM/RM
    5454my $pbtarget;               # Target os-ver-arch you want to build for
    55 my $pbport;                 # Port to use to connect to the VM
     55my $pbport;                 # Port to use to connect to the VM/RM
    5656my $newver;                 # New version to create
    5757my $iso = undef;            # ISO image for the VM to create
     
    113113=item B<-m|--machine os-ver-arch[,os-ver-arch,...]>
    114114
    115 Name of the Virtual Machines (VM) or Virtual Environments (VE) you want to build on (coma separated).
     115Name of the Virtual Machines (VM), Virtual Environments (VE) or Remote Machines (RM)
     116you want to build on (coma separated).
    116117All if none precised (or use the env variable PBV).
    117118
    118119=item B<-s|--script script>
    119120
    120 Name of the script you want to execute on the related VMs or VEs.
     121Name of the script you want to execute on the related VMs/VEs/RMs.
    121122
    122123=item B<-g|--nographic>
     
    130131=item B<-a|--account account>
    131132
    132 Name of the account to use to connect on the related VMs.
     133Name of the account to use to connect on the related VMs/RMs.
    133134
    134135=item B<-P|--port port_number>
    135136
    136 Port number to use to connect on the related VMs.\n";
     137Port number to use to connect on the related VMs/RMs.";
    137138
    138139=item B<-p|--project project_name>
     
    204205Create packages in VMs, launching them if needed
    205206and send those packages to a SSH host once built
    206 VM type supported are QEMU
     207VM type supported are QEMU and KVM
    207208
    208209=item B<build2ve>
     
    211212and send those packages to a SSH host once built
    212213
     214=item B<build2rm>
     215
     216Create packages in RMs, which should pre-exist,
     217and send those packages to a SSH host once built
     218RM means Remote Machine, and could be a physical or Virtual one.
     219This is one buildfarm integration for pb.
     220
    213221=item B<sbx2vm>
    214222
     
    219227sbx2build + build2ve
    220228
     229=item B<sbx2rm>
     230
     231sbx2build + build2rm
     232
    221233=item B<cms2vm>
    222234
     
    226238
    227239cms2build + build2ve
     240
     241=item B<cms2rm>
     242
     243cms2build + build2rm
    228244
    229245=item B<launchvm>
     
    244260Execute a script in a virtual environment
    245261
     262=item B<script2rm>
     263
     264Execute a script on a remote machine
     265
    246266=item B<newvm>
    247267
     
    259279
    260280Setup a virtual environment for pb usage
     281
     282=item B<setuprm>
     283
     284Setup a remote machine for pb usage
    261285
    262286=item B<sbx2setupvm>
     
    270294Reserved to dev team.
    271295
     296=item B<sbx2setuprm>
     297
     298Setup a remote machine for pb usage using the sandbox version of pb instead of the latest stable
     299Reserved to dev team.
     300
    272301=item B<snapvm>
    273302
     
    286315Update the distribution in the virtual environment
    287316
     317=item B<updaterm>
     318
     319Update the distribution in the remote machine
     320
    288321=item B<test2pkg>
    289322
     
    297330
    298331Test a package in a virtual environment
     332
     333=item B<test2rm>
     334
     335Test a package in a remote machine
    299336
    300337=item B<newver>
     
    569606} elsif ($action =~ /^pkg2ssh$/) {
    570607    pb_pkg2ssh();
     608} elsif ($action =~ /^build2rm$/) {
     609    pb_build2v("rm","build");
    571610} elsif ($action =~ /^build2ve$/) {
    572611    pb_build2v("ve","build");
    573612} elsif ($action =~ /^build2vm$/) {
    574613    pb_build2v("vm","build");
     614} elsif ($action =~ /^cms2rm$/) {
     615    pb_cms2build("CMS");
     616    pb_build2v("rm","build");
    575617} elsif ($action =~ /^cms2ve$/) {
    576618    pb_cms2build("CMS");
    577619    pb_build2v("ve","build");
     620} elsif ($action =~ /^sbx2rm$/) {
     621    pb_cms2build("SandBox");
     622    pb_build2v("rm","build");
    578623} elsif ($action =~ /^sbx2ve$/) {
    579624    pb_cms2build("SandBox");
     
    593638} elsif ($action =~ /^script2ve$/) {
    594639    pb_script2v($pbscript,"ve");
     640} elsif ($action =~ /^script2rm$/) {
     641    pb_script2v($pbscript,"rm");
    595642} elsif ($action =~ /^newver$/) {
    596643    pb_newver();
     
    604651    pb_log(0, "and perl, sudo, ntpdate and scp/ssh installed\n");
    605652    pb_log(0, "You should then be able to login with ssh -p VMPORT root\@localhost (if VM started with pb)\n");
     653} elsif ($action =~ /^setuprm$/) {
     654    pb_setup2v("rm");
    606655} elsif ($action =~ /^setupve$/) {
    607656    pb_setup2v("ve");
    608657} elsif ($action =~ /^setupvm$/) {
    609658    pb_setup2v("vm");
     659} elsif ($action =~ /^sbx2setuprm$/) {
     660    die "This feature is limited to the pb project" if ($ENV{'PBPROJ'} ne $appname);
     661    pb_cms2build("SandBox");
     662    pb_setup2v("rm","SandBox");
    610663} elsif ($action =~ /^sbx2setupve$/) {
    611664    die "This feature is limited to the pb project" if ($ENV{'PBPROJ'} ne $appname);
     
    616669    pb_cms2build("SandBox");
    617670    pb_setup2v("vm","SandBox");
     671} elsif ($action =~ /^updaterm$/) {
     672    pb_update2v("rm");
    618673} elsif ($action =~ /^updateve$/) {
    619674    pb_update2v("ve");
     
    626681} elsif ($action =~ /^test2pkg$/) {
    627682    pb_test2pkg();
     683} elsif ($action =~ /^test2rm$/) {
     684    pb_build2v("rm","test");
    628685} elsif ($action =~ /^test2ve$/) {
    629686    pb_build2v("ve","test");
     
    827884            pb_log(0,"Build files are being generated for ...\n");
    828885            my %virt;
    829             # De-duplicate similar VM and VE
     886            # De-duplicate similar VM/VE/RM
    830887            foreach my $d (split(/,/,$tmpl)) {
    831888                # skip ill-formatted vms (name-ver-arch)
     
    835892
    836893            # Try to use // processing here
    837             my $pm = new Parallel::ForkManager($pbparallel) if (defined $pbparallel);
     894            my $pm;
     895            $pm = new Parallel::ForkManager($pbparallel) if (defined $pbparallel);
    838896
    839897            foreach my $d (keys %virt) {
     
    10801138    chdir "$ENV{'PBBUILDDIR'}";
    10811139    my $made = ""; # pkgs made during build
    1082     my $pm = new Parallel::ForkManager($pbparallel) if (defined $pbparallel);
     1140    my $pm;
     1141    $pm = new Parallel::ForkManager($pbparallel) if (defined $pbparallel);
    10831142
    10841143    # We need to communicate info back from the children if parallel so prepare a dir for that
     
    13481407    }
    13491408
    1350     # Keep track of what is generated so that we can get them back from VMs
     1409    # Keep track of what is generated so that we can get them back from VMs/RMs
    13511410    open(KEEP,"> $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}") || die "Unable to create $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}";
    13521411    print KEEP "$made\n";
     
    13841443
    13851444# By default deliver to the the public site hosting the
    1386 # ftp structure (or whatever) or a VM/VE
     1445# ftp structure (or whatever) or a VM/VE/RM
    13871446sub pb_send2target {
    13881447
     
    14091468        $host = "vmhost";
    14101469        $port = "vmport";
     1470    } elsif ($cmt =~ /^RM/) {
     1471        $login = "rmlogin";
     1472        $dir = "pbdefdir";
     1473        # Specific RM
     1474        $tmout = "rmtmout";
     1475        $path = "rmpath";
     1476        $host = "rmhost";
     1477        $port = "rmport";
    14111478    } elsif ($cmt =~ /^VE/) {
    14121479        $login = "velogin";
     
    14641531    }
    14651532
    1466     if ($cmt =~ /V[EM]build/) {
     1533    if ($cmt =~ /(V[EM]|RM)build/) {
    14671534        $src="$src $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb $ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb $ENV{'PBETC'} $ENV{'PBDESTDIR'}/pbrc $ENV{'PBDESTDIR'}/pbscript.$$";
    1468     } elsif ($cmt =~ /V[EM]Script/) {
     1535    } elsif ($cmt =~ /(V[EM]|RM)Script/) {
    14691536        $src="$src $ENV{'PBDESTDIR'}/pbscript.$$";
    1470     } elsif ($cmt =~ /V[EM]test/) {
     1537    } elsif ($cmt =~ /(V[EM]|RM)test/) {
    14711538        $src="$src $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb $ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb $ENV{'PBETC'} $ENV{'PBDESTDIR'}/pbrc $ENV{'PBDESTDIR'}/pbscript.$$ $ENV{'PBDESTDIR'}/pbtest";
    14721539    } elsif (($cmt eq "Announce") || ($cmt eq "Web")) {
     
    14981565        ($vepath) = pb_conf_get($path);
    14991566    }
    1500     if ($cmt =~ /^VM/) {
     1567    if ($cmt =~ /^(V|R)M/) {
    15011568        ($vtmout) = pb_conf_get($tmout);
     1569    }
     1570    my $sshmachine = $sshhost->{$ENV{'PBPROJ'}};
     1571    if ($cmt =~ /^RM/) {
     1572        # In that case our real host is in the rmhost with the OS as key, not project as above
     1573        $sshmachine = pb_distro_get_param($ddir,$dver,$darch,$sshhost,$dfam,$dtype,$dos);
    15021574    }
    15031575    pb_log(2,"ssh: ".Dumper(($sshhost,$sshlogin,$sshdir,$sshport,$vtmout,$vepath,$rbsconf))."\n");
     
    15051577    my $mac;
    15061578    if ($cmt !~ /^VE/) {
    1507         $mac = "$sshlogin->{$ENV{'PBPROJ'}}\@$sshhost->{$ENV{'PBPROJ'}}";
     1579        $mac = "$sshlogin->{$ENV{'PBPROJ'}}\@$sshmachine";
    15081580        # Overwrite account value if passed as parameter
    1509         $mac = "$pbaccount\@$sshhost->{$ENV{'PBPROJ'}}" if (defined $pbaccount);
     1581        $mac = "$pbaccount\@$sshmachine" if (defined $pbaccount);
    15101582        pb_log(2, "DEBUG: pbaccount: $pbaccount => mac: $mac\n") if (defined $pbaccount);
    15111583    } else {
     
    15181590    my $tdir;
    15191591    my $bdir;
    1520     if (($cmt eq "Sources") || ($cmt =~ /V[EM]Script/)) {
     1592    if (($cmt eq "Sources") || ($cmt =~ /(V[EM]|RM)Script/)) {
    15211593        $tdir = "$sshdir->{$ENV{'PBPROJ'}}/$delivery->{$ENV{'PBPROJ'}}/src";
    1522     } elsif (($cmt =~ /V[EM]build/)  || ($cmt =~ /V[EM]test/)) {
     1594    } elsif ($cmt =~ /(V[EM]|RM)(build|test)/) {
    15231595        $tdir = $sshdir->{$ENV{'PBPROJ'}}."/$ENV{'PBPROJ'}/delivery";
    15241596        $bdir = $sshdir->{$ENV{'PBPROJ'}}."/$ENV{'PBPROJ'}/build";
     
    17141786
    17151787    my $tm = undef;
    1716     if ($cmt =~ /^VM/) {
     1788    if ($cmt =~ /^(V|R)M/) {
    17171789        $tm = $vtmout->{$ENV{'PBPROJ'}};
    17181790    }
     
    17261798        $cpcmd = "scp -i $keyfile -p -o UserKnownHostsFile=/dev/null -P $nport";
    17271799        $cptarget = "$mac:$tdir";
    1728         if ($cmt =~ /^VMbuild/) {
     1800        if ($cmt =~ /^(V|R)Mbuild/) {
    17291801            $cp2target = "$mac:$bdir";
    17301802        }
     
    17731845    # Use the right script name depending on context
    17741846    my $pbscript;
    1775     if ($cmt =~ /^V[EM]/) {
     1847    if ($cmt =~ /^(V[EM]|RM)/) {
    17761848        $pbscript = "pbscript.$$";
    17771849    } else {
     
    17801852
    17811853    pb_system("$shcmd \"echo \'cd $tdir ; if [ -x $pbscript ]; then ./$pbscript; fi ; rm -f ./$pbscript\' | bash\"","Executing pbscript on $cptarget if needed","verbose");
    1782     if ($cmt =~ /^V[EM]build/) {
    1783         # Get back info on pkg produced, compute their name and get them from the VM
     1854    if ($cmt =~ /^(V[EM]|RM)build/) {
     1855        # Get back info on pkg produced, compute their name and get them from the VM/RM
    17841856        pb_system("$cpcmd $cp2target/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'} $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.$$ 2> /dev/null","Get package names in $cp2target");
    17851857        # For VE we need to change the owner manually
     
    17881860        }
    17891861        if (not -f "$ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.$$") {
    1790             pb_log(0,"Problem with VM $v on $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.$$");
     1862            pb_log(0,"Problem with VM/RM $v on $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.$$");
    17911863        } else {
    17921864            open(KEEP,"$ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.$$") || die "Unable to read $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.$$";
     
    18011873            my $made = "";
    18021874   
    1803             # For VM we don't want shell expansion to hapen locally but remotely
     1875            # For VM/RM we don't want shell expansion to hapen locally but remotely
    18041876            my $delim = '\'';
    18051877            if ($cmt =~ /^VEbuild/) {
     
    18341906        }
    18351907    }
    1836     unlink("$ENV{'PBDESTDIR'}/pbscript.$$") if ($cmt =~ /^V[ME]/);
     1908    unlink("$ENV{'PBDESTDIR'}/pbscript.$$") if ($cmt =~ /^(V[ME]|RM)/);
    18371909
    18381910    pb_log(2,"Before halt, vmexist: $vmexist, vmpid: $vmpid\n");
     
    18841956    my $vtype=shift;
    18851957    my $pbforce=shift || 0; # Force stop of VM. Default not.
    1886     my $vm1=shift || undef; # Only that VM to treat. Default all.
     1958    my $vm1=shift || undef; # Only that VM/VE/RM to treat. Default all.
    18871959    my $snapme=shift || 0;  # Do we have to create a snapshot. Default not.
    18881960    my $vm;
     
    18901962
    18911963    pb_log(2,"DEBUG: pb_script2v($pbscript,$vtype,$pbforce,".Dumper($vm1).",$snapme)\n");
    1892     # Prepare the script to be executed on the VM
     1964    # Prepare the script to be executed on the VM/VE/RM
    18931965    # in $ENV{'PBDESTDIR'}/pbscript.$$
    18941966    if ((defined $pbscript ) && ($pbscript ne "$ENV{'PBDESTDIR'}/pbscript.$$")) {
     
    19111983            pb_log(2,"DEBUG: After pb_launchv, vmexist: $vmexist, vmpid: $vmpid\n");
    19121984
    1913             # Skip that VM if something went wrong
     1985            # Skip that VM/RM if something went wrong
    19141986            next if (($vmpid == 0) && ($vmexist == 0));
    19151987
     
    19251997        }
    19261998
    1927         # Gather all required files to send them to the VM 
     1999        # Gather all required files to send them to the VM/VE/RM
    19282000        # and launch the build through pbscript
    19292001        pb_log(2,"DEBUG: Before send2target, vmexist: $vmexist, vmpid: $vmpid\n");
     
    19362008    my $vtype = shift;
    19372009    my $v = shift;
    1938     my $create = shift || 0;        # By default do not create a VM/VE
    1939     my $snapme = shift || 0;        # By default do not snap a VM/VE
    1940     my $usesnap = shift || 1;       # By default study the usage of the snapshot feature of VM/VE
     2010    my $create = shift || 0;        # By default do not create a VM/VE/RM
     2011    my $snapme = shift || 0;        # By default do not snap a VM/VE/RM
     2012    my $usesnap = shift || 1;       # By default study the usage of the snapshot feature of VM/VE/RM
    19412013
    19422014    # If creation or snapshot creation mode, no snapshot usable
     
    19462018
    19472019    pb_log(2,"DEBUG: pb_launchv($vtype,$v,$create,$snapme,$usesnap)\n");
    1948     die "No VM/VE defined, unable to launch" if (not defined $v);
     2020    die "No VM/VE/RM defined, unable to launch" if (not defined $v);
    19492021    # Keep only the first VM in case many were given
    19502022    $v =~ s/,.*//;
     
    20752147        pb_log(2,"DEBUG: pb_launchv returns ($vmexist,$vmpid)\n");
    20762148        return($vmexist,$vmpid);
    2077     # VE here
    2078     } else {
     2149    } elsif ($vtype eq "ve") {
     2150        # VE here
    20792151        # Get distro context
    20802152        my ($name,$ver,$darch) = split(/-/,$v);
     
    22442316            die "VE of type $vetype not supported. Report to the dev team";
    22452317        }
     2318    } else {
     2319        # RM here
     2320        # Get distro context
     2321        my ($name,$ver,$darch) = split(/-/,$v);
     2322        chomp($darch);
     2323        my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf) = pb_distro_init($name,$ver,$darch);
     2324
     2325        # Get RM context
     2326        my ($ptr,$rmpath) = pb_conf_get("rmtype","rmpath");
     2327
     2328        # Nothing more to do for RM. No real launch
     2329        # For the moment we support the RM is already running
     2330        # For ProLiant may be able to power them on if needed later on as an example.
    22462331    }
    22472332}
     
    22942379
    22952380my ($vmexist,$vmpid) = (undef,undef);
    2296 my $pm = new Parallel::ForkManager($pbparallel) if (defined $pbparallel);
    2297 
    2298 # Set which port the VM will use to communicate
    2299 $pm->run_on_start(\&pb_set_port);
     2381my $pm;
     2382if (defined $pbparallel) {
     2383    $pm = new Parallel::ForkManager($pbparallel);
     2384
     2385    # Set which port the VM/RM will use to communicate
     2386    $pm->run_on_start(\&pb_set_port);
     2387}
    23002388
    23012389my $counter = 0;
     
    23032391    $counter++;
    23042392    # Modulo 2 * pbparallel (to avoid synchronization problems)
    2305     $counter = 1 if ($counter > 2 * $pbparallel);
     2393    $counter = 1 if ((defined $pbparallel) && ($counter > 2 * $pbparallel));
    23062394    $pm->start($counter) and next if (defined $pbparallel);
    2307     # Prepare the script to be executed on the VM/VE
     2395    # Prepare the script to be executed on the VM/VE/RM
    23082396    # in $ENV{'PBDESTDIR'}/pbscript.$$
    23092397    open(SCRIPT,"> $ENV{'PBDESTDIR'}/pbscript.$$") || die "Unable to create $ENV{'PBDESTDIR'}/pbscript.$$";
     
    24022490    chmod 0755,"$ENV{'PBDESTDIR'}/pbscript.$$";
    24032491   
    2404     # Launch the VM/VE
     2492    # Launch the VM/VE/RM
    24052493    ($vmexist,$vmpid) = pb_launchv($vtype,$v,0);
    24062494
     
    24132501        }
    24142502    } else {
    2415         # VE
     2503        # VE/RM
    24162504        $vmexist = 0;
    24172505        $vmpid = 0;
     
    24232511    $pm->finish if (defined $pbparallel);
    24242512}
    2425 if (defined $pbparallel) {
    2426     $pm->wait_all_children;
    2427 }
     2513$pm->wait_all_children if (defined $pbparallel);
    24282514}
    24292515
     
    25342620
    25352621#
    2536 # Return the list of VMs/VEs we are working on
     2622# Return the list of VMs/VEs/RMs we are working on
    25372623# $all is a flag to know if we return all of them
    25382624# or only some (if all we publish also tar files in addition to pkgs
     
    25432629my @v;
    25442630my $all = 0;
    2545 my $vlist;
    25462631my $pbv = 'PBV';
    2547 
    2548 if ($vtype eq "vm") {
    2549     $vlist = "vmlist";
    2550 } elsif ($vtype eq "ve") {
    2551     $vlist = "velist";
    2552 }
     2632my $vlist = $vtype."list";
     2633
    25532634# Get VM/VE list
    25542635if ((not defined $ENV{$pbv}) || ($ENV{$pbv} =~ /^all$/)) {
     
    25622643}
    25632644
    2564 # Function to create a potentialy missing pb account on the VM/VE, and adds it to sudo
    2565 # Needs to use root account to connect to the VM/VE
     2645# Function to create a potentialy missing pb account on the VM/VE/RM, and adds it to sudo
     2646# Needs to use root account to connect to the VM/VE/RM
    25662647# pb will take your local public SSH key to access
    2567 # the pb account in the VM later on if needed
     2648# the pb account in the VM/VE/RM later on if needed
    25682649sub pb_setup2v {
    25692650
     
    25792660$pbparallel = pb_set_parallel($vtype);
    25802661
    2581 my $pm = new Parallel::ForkManager($pbparallel) if (defined $pbparallel);
    2582 
    2583 # Set which port the VM will use to communicate
    2584 $pm->run_on_start(\&pb_set_port);
     2662my $pm;
     2663if (defined $pbparallel) {
     2664    $pm = new Parallel::ForkManager($pbparallel);
     2665
     2666    # Set which port the VM/RM will use to communicate
     2667    $pm->run_on_start(\&pb_set_port);
     2668}
    25852669
    25862670my $counter = 0;
     
    25882672    $counter++;
    25892673    # Modulo pbparallel
    2590     $counter = 1 if ($counter > $pbparallel);
     2674    $counter = 1 if ((defined $pbparallel) && ($counter > $pbparallel));
    25912675    $pm->start($counter) and next if (defined $pbparallel);
    25922676
     
    25992683    my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins) = pb_distro_init($name,$ver,$darch);
    26002684   
    2601     # Name of the account to deal with for VM/VE
     2685    # Name of the account to deal with for VM/VE/RM
    26022686    # Do not use the one passed potentially with -a
    26032687    my ($pbac) = pb_conf_get($vtype."login");
     
    26052689    my ($vmexist,$vmpid);
    26062690
    2607     # Prepare the script to be executed on the VM/VE
     2691    # Prepare the script to be executed on the VM/VE/RM
    26082692    # in $ENV{'PBDESTDIR'}/setupv
    26092693    open(SCRIPT,"> $pbscript") || die "Unable to create $pbscript";
     
    26302714EOF
    26312715
    2632     # Launch the VM/VE - Usage of snapshot disabled
     2716    # Launch the VM/VE/RM - Usage of snapshot disabled
    26332717    ($vmexist,$vmpid) = pb_launchv($vtype,$v,0,0,0);
    26342718
     
    26372721    my $vmhost;
    26382722
    2639     if ($vtype eq "vm") {
     2723    if ($vtype =~ /(v|r)m/) {
    26402724        # Prepare the key to be used and transfered remotely
    26412725        $keyfile = pb_ssh_get(1);
    26422726       
    26432727        my ($vmport,$vmntp);
    2644         ($vmhost,$vmport,$vmntp) = pb_conf_get("vmhost","vmport","vmntp");
     2728        ($vmhost,$vmport,$vmntp) = pb_conf_get($vtype."host",$vtype."port",$vtype."ntp");
    26452729        $nport = pb_get_port($vmport->{$ENV{'PBPROJ'}});
    26462730   
    2647         # Skip that VM if something went wrong
     2731        # Skip that VM/RM if something went wrong
    26482732        next if (($vmpid == 0) && ($vmexist == 0));
    26492733   
     
    26572741        # We call true to avoid problems if SELinux is not activated, but chcon is present and returns in that case 1
    26582742        pb_system("cat $keyfile.pub | ssh -q -o UserKnownHostsFile=/dev/null -p $nport -i $keyfile root\@$vmhost->{$ENV{'PBPROJ'}} \"mkdir -p .ssh ; chmod 700 .ssh ; cat >> .ssh/authorized_keys ; chmod 600 .ssh/authorized_keys ; if [ -x /usr/bin/chcon ]; then /usr/bin/chcon -Rt home_ssh_t .ssh 2> /dev/null; /bin/true; fi\"","Copying local keys to $vtype. This may require the root password");
    2659         # once this is done, we can do what we want on the VM remotely
     2743        # once this is done, we can do what we need on the VM/RM remotely
    26602744    } elsif ($vtype eq "ve") {
    26612745        print SCRIPT << "EOF";
     
    26702754    }
    26712755
    2672 if ($vtype eq "vm") {
     2756if ($vtype =~ /(v|r)m/) {
    26732757        print SCRIPT << 'EOF';
    26742758# Removes duplicate in .ssh/authorized_keys of our key if needed
     
    27132797EOF
    27142798
     2799# TODO: use an external parameter
    27152800my $home = "/home";
    27162801# Solaris doesn't like that we use /home
     
    27262811    }
    27272812EOF
     2813    # TODO: Level of portability of these cmds ?
    27282814    print SCRIPT << "EOF";
    27292815pb_system("/usr/sbin/groupadd $pbac->{$ENV{'PBPROJ'}}","Adding group $pbac->{$ENV{'PBPROJ'}}");
     
    27322818EOF
    27332819
    2734     # Copy the content of our local conf file to the VM/VE
     2820    # Copy the content of our local conf file to the VM/VE/RM
    27352821    my $content = pb_get_content(pb_distro_conffile());
    27362822    print SCRIPT << "EOF";
     
    27462832EOF
    27472833
    2748     if ($vtype eq "vm") {
     2834    if ($vtype =~ /(v|r)m/) {
    27492835        print SCRIPT << "EOF";
    27502836# allow ssh entry to build
     
    28252911close(PBFILE);
    28262912EOF
     2913    # TODO: To be refined for RM
    28272914    print SCRIPT << "EOF";
    28282915# Some distro force requiretty at compile time, so disable here
     
    28672954    my ($instype) = pb_conf_get("pbinstalltype");
    28682955    my $itype = pb_distro_get_param($ddir,$dver,$darch,$instype,$dfam,$dtype,$dos);
    2869     if (defined $sbx) {
    2870         # Install from sandbox mean a file base install
    2871         $itype = "file";
    2872     }
     2956    # Install from sandbox mean a file base install
     2957    $itype = "file" if (defined $sbx);
    28732958    if ($itype =~ /^file/) {
    28742959        my $cmdget;
     
    29893074    $pm->finish if (defined $pbparallel);
    29903075}
    2991 if (defined $pbparallel) {
    2992     $pm->wait_all_children;
    2993 }
     3076$pm->wait_all_children if (defined $pbparallel);
    29943077return;
    29953078}
     
    30383121}
    30393122
    3040 # Function to update a VMs or VEs with the latest distribution content
     3123# Function to update VMs/VEs/RMs with the latest distribution content
    30413124sub pb_update2v {
    30423125
     
    30563139    my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins) = pb_distro_init($name,$ver,$darch);
    30573140
    3058     # Prepare the script to be executed on the VM/VE
     3141    # Prepare the script to be executed on the VM/VE/RM
    30593142    # in $ENV{'PBDESTDIR'}/updatev
    30603143    open(SCRIPT,"> $pbscript") || die "Unable to create $pbscript";
     
    35403623}
    35413624
    3542 # Manages VM SSH port communication
     3625# Manages VM/RM SSH port communication
    35433626sub pb_get_port {
    35443627
     
    36053688    }
    36063689}
    3607 pb_log(2,"pb_set_parallel returns: $pbparallel\n");
     3690pb_log(2,"pb_set_parallel returns: $pbparallel\n") if (defined $pbparallel);
    36083691return($pbparallel);
    36093692}
  • devel/pb/lib/ProjectBuilder/CMS.pm

    r1174 r1176  
    227227
    228228    # Check whether the file is well formed
    229     (containing already a directory with the project-version name)
     229    # (containing already a directory with the project-version name)
    230230    #
    231231    # If it's not the case, we try to adapt, but distro needing
     
    711711    my $cmsurl = pb_cms_get_uri($scheme,$ENV{$envar});
    712712    my ($scheme2, $account2, $host2, $port2, $path2) = pb_get_uri($cmsurl);
     713    # For svk, scheme doesn't appear in svk info so remove it here in uri coming from conf file
     714    # which needs it to trigger correct behaviour
     715    $uri =~ s/^svk://;
    713716    if ($cmsurl ne $uri) {
    714717        # The local content doesn't correpond to the repository
  • devel/pb/lib/ProjectBuilder/Env.pm

    r1156 r1176  
    9595# where to find Build System infos:
    9696#vmpath default = /home/qemu
    97 #vepath default = /home/rinse
     97#vepath default = /home/rpmbootstrap
     98#rmpath default = /home/remote
    9899
    99100# Overwrite generic setup
     
    168169# Adds a potential conf file now as it's less
    169170# important than the project conf file
    170 my ($vmpath,$vepath) = pb_conf_get_if("vmpath","vepath");
     171my ($vmpath,$vepath,$rmpath) = pb_conf_get_if("vmpath","vepath","rmpath");
    171172pb_conf_add("$vmpath->{$ENV{'PBPROJ'}}/.pbrc") if ((defined $vmpath) && (-f "$vmpath->{$ENV{'PBPROJ'}}/.pbrc"));
    172173pb_conf_add("$vepath->{$ENV{'PBPROJ'}}/.pbrc") if ((defined $vepath) && (-f "$vepath->{$ENV{'PBPROJ'}}/.pbrc"));
     174pb_conf_add("$rmpath->{$ENV{'PBPROJ'}}/.pbrc") if ((defined $rmpath) && (-f "$rmpath->{$ENV{'PBPROJ'}}/.pbrc"));
    173175
    174176#
     
    282284pb_log(2,"PBBUILDDIR: $ENV{'PBBUILDDIR'}\n");
    283285
    284 #
    285 # The following part is only useful when in cms2something or newsomething
    286 # In VMs/VEs we want to skip that by providing good env vars.
     286return if ($action =~ /^clean$/);
     287#
     288# The following part is only useful when in sbx|cms2something or newsomething
     289# In VMs/VEs/RMs we want to skip that by providing good env vars.
    287290# return values in that case are useless
    288291#
    289 return if ($action =~ /^clean$/);
    290292
    291293if (($action =~ /^cms2/) || ($action =~ /^sbx2/) || ($action =~ /^newver$/) || ($action =~ /pbinit/) || ($action =~ /^newproj$/) || ($action =~ /^announce/)) {
Note: See TracChangeset for help on using the changeset viewer.