Merge branch 'master' of ssh://git.code.sf.net/p/xcat/xcat-core
This commit is contained in:
commit
a632c7b307
@ -21,7 +21,7 @@ BEGIN
|
||||
}
|
||||
|
||||
if ($^O =~ /^aix/i) {
|
||||
print "ERROR - buildkit is not supported on AIX \n";
|
||||
print "ERROR - the buildkit command is not supported on AIX \n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
@ -34,7 +34,6 @@ use Cwd 'abs_path';
|
||||
use File::Path;
|
||||
use File::Basename;
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Main
|
||||
|
||||
@ -393,7 +392,7 @@ while ($arg) {
|
||||
$::current_dir = $::workdir;
|
||||
}
|
||||
if ( ! $::KIT_CREATE ) {
|
||||
print "kit basename not specified for buildkit create command \n";
|
||||
print "The Kit basename was not specified for the buildkit create command.\n";
|
||||
&usage;
|
||||
exit 1;
|
||||
}
|
||||
@ -402,7 +401,7 @@ while ($arg) {
|
||||
} elsif ( $command eq 'buildrepo' ) {
|
||||
$::KIT_BUILDREPO=shift(@ARGV);
|
||||
if ( ! $::KIT_BUILDREPO ) {
|
||||
print "kit package repository name not specified for buildkit buildrepo command \n";
|
||||
print "The Kit package repository name was not specified for buildkit buildrepo command.\n";
|
||||
&usage;
|
||||
exit 1;
|
||||
}
|
||||
@ -424,17 +423,17 @@ while ($arg) {
|
||||
} elsif ( $command eq 'addpkgs' ) {
|
||||
$::KIT_ADDPKGS=shift(@ARGV);
|
||||
if (!($::KIT_ADDPKGS)){
|
||||
print "Missing parameter: <kit tarfile> must be specified with \'buildkit addpkgs\' \n";
|
||||
print "Missing parameter: the <kit tarfile> name must be specified when using the \'buildkit addpkgs\' command.\n";
|
||||
&usage;
|
||||
exit (1);
|
||||
}
|
||||
if (!($::PKGDIR)){
|
||||
print "Missing option: -p <pkgdir> must be specified with \'buildkit addpkgs\' \n";
|
||||
print "Missing option: the -p <pkgdir> option must be specified with \'buildkit addpkgs\' command. \n";
|
||||
&usage;
|
||||
exit (1);
|
||||
}
|
||||
} else {
|
||||
print "buildkit command $arg not recognized \n";
|
||||
print "The buildkit command $arg is not recognized.\n";
|
||||
&usage;
|
||||
exit (1);
|
||||
}
|
||||
@ -470,8 +469,6 @@ if ( $::KIT_CLEANALL ) {
|
||||
}
|
||||
if ( $::KIT_ADDPKGS ) { $rc = &kit_addpkgs; }
|
||||
|
||||
|
||||
|
||||
exit $rc;
|
||||
|
||||
#####################################
|
||||
@ -619,20 +616,20 @@ sub kit_chkconfig
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
sub kit_buildrepo
|
||||
|
||||
{
|
||||
|
||||
my $rc = 0;
|
||||
my $repoid = $::KIT_BUILDREPO;
|
||||
|
||||
if ( !$debianflag ){
|
||||
|
||||
# Check if createrepo bin exists or not. Fail at the beginning.
|
||||
if (! (-e "/usr/bin/createrepo") ) {
|
||||
print "Error: /usr/bin/createrepo does not exist, install createrepo first\n";
|
||||
# Check if createrepo exists or not. Fail at the beginning.
|
||||
#- don't use specific path - may not be correct in build env
|
||||
my $rcmd = "createrepo -h > /dev/null";
|
||||
if ( system( $rcmd ) ) {
|
||||
print "Error: the createrepo command does not seem to be installed. Make sure createrepo is installed before running the buildkit command. \n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
$repoid =~ s/\s+//g;
|
||||
$repoid =~ tr/A-Z/a-z/; # convert to lowercase
|
||||
if ( $repoid ne 'all' ) {
|
||||
@ -654,11 +651,8 @@ sub kit_buildrepo
|
||||
=cut
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
sub kit_buildrepo1
|
||||
|
||||
{
|
||||
|
||||
my $rc = 0;
|
||||
my $repoid = shift;
|
||||
$repoid =~ s/\s+//g;
|
||||
@ -818,8 +812,6 @@ sub kit_buildrepo1
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
=head3 kit_listrepo
|
||||
@ -829,9 +821,7 @@ sub kit_buildrepo1
|
||||
=cut
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
sub kit_listrepo
|
||||
|
||||
{
|
||||
# print "Kit Repository: Status \n";
|
||||
foreach my $kr (@{$::bldkit_config->{kitrepo}{entries}}) {
|
||||
@ -853,9 +843,7 @@ sub kit_listrepo
|
||||
=cut
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
sub kit_cleanrepo
|
||||
|
||||
{
|
||||
my $repoid = $::KIT_CLEANREPO;
|
||||
my $tmp_repoid = $repoid;
|
||||
@ -915,9 +903,7 @@ sub kit_cleanrepo
|
||||
=cut
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
sub kit_buildtar
|
||||
|
||||
{
|
||||
foreach my $kr (@{$::bldkit_config->{kitrepo}{entries}}) {
|
||||
if (&validate_repo($kr)) {
|
||||
@ -1904,7 +1890,7 @@ sub build_kitcomp
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
# find the kitrepo hash for this component
|
||||
foreach my $kr (@{$::bldkit_config->{kitrepo}{entries}}) {
|
||||
if ($comp->{kitrepoid} eq $kr->{kitrepoid}) {
|
||||
@ -1913,7 +1899,7 @@ sub build_kitcomp
|
||||
}
|
||||
}
|
||||
my $repodir = $::base_repodir."/".$repo{kitreponame};
|
||||
|
||||
|
||||
# Fix the kitpkgdeps value for this kitcomponent
|
||||
# For any kitpkgdep that has an rpm file in the repo,
|
||||
# specifically reference it's version-release
|
||||
@ -2056,34 +2042,63 @@ sub update_kitcomp_kitpkgdeps
|
||||
my $repodir = shift;
|
||||
|
||||
if (defined($comp->{kitpkgdeps})) {
|
||||
my $new_kitpkgdeps = '';
|
||||
foreach my $d (split(/,/, $comp->{kitpkgdeps})) {
|
||||
$d =~ s/\s+//g;
|
||||
my $d_short = $d;
|
||||
$d_short =~ s/^([\w\.\-]+)[<>=]*.*$/$1/;
|
||||
if ( $d_short eq $d ) {
|
||||
# no version-release comparisons specified for this kitpkgdep
|
||||
# do we have an rpm file in the repo?
|
||||
my $cmd = "rpm -q --qf \"%{NAME} >= %{VERSION}-%{RELEASE},\" -p $repodir/$d-\[0-9\]\*.rpm 2>/dev/null";
|
||||
if ($::VERBOSE) {
|
||||
print "running rpm query to get version-release info: \n $cmd \n";
|
||||
}
|
||||
my $new_d = `$cmd`;
|
||||
chomp($new_d);
|
||||
if ($::VERBOSE) {
|
||||
print "output: \n \'$new_d\' \n";
|
||||
}
|
||||
if ( $new_d ne '' ) {
|
||||
$new_kitpkgdeps .= "$new_d,";
|
||||
# we have some rpms listed -n buildkit.conf file
|
||||
my $new_kitpkgdeps = '';
|
||||
foreach my $d (split(/,/, $comp->{kitpkgdeps})) {
|
||||
$d =~ s/\s+//g;
|
||||
my $d_short = $d;
|
||||
# strip off everything after ">="
|
||||
$d_short =~ s/^([\w\.\-]+)[<>=]*.*$/$1/;
|
||||
|
||||
# if they are the same then there was no v/r info provided
|
||||
if ( $d_short eq $d ) {
|
||||
# no version-release comparisons specified for this kitpkgdep
|
||||
# do we have this rpm file?
|
||||
# get a list of any matches
|
||||
my $lscmd = "cd $repodir; /bin/ls $d-\[0-9\]\*.rpm 2>/dev/null";
|
||||
my @rpmlist = `$lscmd`;
|
||||
|
||||
if ( scalar(@rpmlist) == 0) {
|
||||
print "Error: Could not find rpm named $d in $repodir. \n";
|
||||
next;
|
||||
}
|
||||
|
||||
# get the newest version there is
|
||||
my $newestrpm = xCAT::BuildKitUtils->get_latest_version($repodir, \@rpmlist);
|
||||
|
||||
if (!$newestrpm) {
|
||||
print "Error: Could not determine the latest version of rpm $d contained in $repodir. \n";
|
||||
next;
|
||||
}
|
||||
|
||||
# get the Version and release values for this rpm
|
||||
my $cmd = "rpm -q --qf \"%{NAME} >= %{VERSION}-%{RELEASE}\" -p $repodir/$newestrpm 2>/dev/null";
|
||||
if ($::VERBOSE) {
|
||||
print "running rpm query to get version-release info: \n $cmd \n";
|
||||
}
|
||||
|
||||
my $new_d = `$cmd`;
|
||||
if (!$new_d) {
|
||||
print "Error: Could not determine the latest version of rpm $d. \n";
|
||||
next;
|
||||
}
|
||||
|
||||
chomp($new_d);
|
||||
if ($::VERBOSE) {
|
||||
print "output: \n \'$new_d\' \n";
|
||||
}
|
||||
if ( $new_d ne '' ) {
|
||||
$new_kitpkgdeps .= "$new_d,";
|
||||
} else {
|
||||
$new_kitpkgdeps .= "$d,";
|
||||
}
|
||||
} else {
|
||||
$new_kitpkgdeps .= "$d,";
|
||||
}
|
||||
} else {
|
||||
$new_kitpkgdeps .= "$d,";
|
||||
}
|
||||
}
|
||||
$new_kitpkgdeps =~ s/(\,)*$//;
|
||||
$comp->{kitpkgdeps} = $new_kitpkgdeps;
|
||||
|
||||
$new_kitpkgdeps =~ s/(\,)*$//;
|
||||
$comp->{kitpkgdeps} = $new_kitpkgdeps;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -2091,7 +2106,7 @@ sub update_kitcomp_kitpkgdeps
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
=head3 gen_kitcomp_spec
|
||||
|
||||
|
||||
generate the rpm spec file for the kitcomponent metapkg rpm
|
||||
input: kitcomponent hash
|
||||
kitrepo hash
|
||||
@ -2504,9 +2519,7 @@ sub gen_kitcomp_debdir{
|
||||
=cut
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
sub load_script
|
||||
|
||||
{
|
||||
my $scriptname = shift;
|
||||
my $SF;
|
||||
@ -2524,8 +2537,6 @@ sub load_script
|
||||
return $script_contents;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
=head3 create_kitconf
|
||||
@ -3075,13 +3086,14 @@ sub kit_addpkgs
|
||||
{
|
||||
# add RPM pkgs to an existing kit tarfile
|
||||
my $kittarfile=$::KIT_ADDPKGS;
|
||||
my $rpmdir = $::PKGDIR;
|
||||
my $kitbfname = basename($kittarfile);
|
||||
$kitbfname =~ s/.tar.bz2$//;
|
||||
$kitbfname =~ s/.NEED_PRODUCT_PKGS$//;
|
||||
|
||||
my $tmpdir_base = "/tmp/$kitbfname";
|
||||
|
||||
# - could be list of pkgdir s
|
||||
my @pkgdirlist = split(",", $::PKGDIR);
|
||||
|
||||
# Cleanup - should have been removed when last command ran
|
||||
# - but just in case
|
||||
system ("rm -Rf $tmpdir_base");
|
||||
@ -3095,9 +3107,11 @@ sub kit_addpkgs
|
||||
}
|
||||
$kittarfile = abs_path($kittarfile);
|
||||
|
||||
if ( !(-d $rpmdir) ) {
|
||||
print "The package directory $rpmdir could not be read. \n";
|
||||
return 1;
|
||||
foreach my $rpmdir (@pkgdirlist) {
|
||||
if ( !(-d $rpmdir) ) {
|
||||
print "The package directory $rpmdir could not be read. \n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
# Create work directory
|
||||
@ -3159,6 +3173,8 @@ sub kit_addpkgs
|
||||
exit 1;
|
||||
}
|
||||
|
||||
my $rpmdir=$::PKGDIR;
|
||||
|
||||
my $ext_filename = '';
|
||||
my $ext_reponames = '';
|
||||
my $non_native_filename = '';
|
||||
@ -3435,7 +3451,9 @@ sub NEW_kit_addpkgs
|
||||
# add RPM pkgs to an existing kit tarfile
|
||||
my $tmpdir_base = shift;
|
||||
my $tmpdir = shift;
|
||||
my $rpmdir = $::PKGDIR;
|
||||
|
||||
# - could be list of pkgdir dirs
|
||||
my @pkgdirlist = split(",", $::PKGDIR);
|
||||
|
||||
$::NEW_PARTIAL_KIT = 1;
|
||||
$::workdir = "$tmpdir_base/build_input";
|
||||
@ -3447,12 +3465,13 @@ sub NEW_kit_addpkgs
|
||||
if ($tmp_buildkit_conf ne $::full_buildkit_conf) {
|
||||
print "$tmp_buildkit_conf should match $::full_buildkit_conf .... error??? \n";
|
||||
}
|
||||
|
||||
my $loadrc = &load_bldkitconf($tmp_buildkit_conf);
|
||||
if ( $loadrc != 0 ) {
|
||||
print "Error reading buildkit config file $tmp_buildkit_conf \n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if ( defined($::KITVERSION) ) {
|
||||
$::bldkit_config->{kit}{entries}[0]->{version} = $::KITVERSION;
|
||||
}
|
||||
@ -3465,6 +3484,7 @@ sub NEW_kit_addpkgs
|
||||
print "Error validating buildkit config file $tmp_buildkit_conf \n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ($tmpdir ne $::deploy_dir) {
|
||||
if (system ("mv $tmpdir $::deploy_dir ") ) {
|
||||
print "Error moving $tmpdir to $::deploy_dir \n";
|
||||
@ -3475,20 +3495,23 @@ sub NEW_kit_addpkgs
|
||||
$::base_repodir = "$::deploy_dir/repos";
|
||||
my $kitname = $::bldkit_config->{kit}{entries}[0]->{kitname};
|
||||
|
||||
|
||||
# Handle external packages
|
||||
# Handle external packages
|
||||
if ($::HAVE_EXTERNAL_PKG) {
|
||||
foreach my $kp (@{$::bldkit_config->{kitpackage}{entries}}) {
|
||||
if ($kp->{isexternalpkg} eq 'yes') {
|
||||
my $ext_filename = $kp->{filename};
|
||||
my $ext_reponames = $kp->{kitreponame};
|
||||
my $fromfile = $rpmdir."/".$ext_filename;
|
||||
if ( system("ls $fromfile > /dev/null") ){
|
||||
print "The product package file $ext_filename could not be read from the package directory $rpmdir. \n";
|
||||
|
||||
my $files = xCAT::BuildKitUtils->find_latest_pkg(\@pkgdirlist, $ext_filename);
|
||||
my @fromfiles=@$files;
|
||||
|
||||
if (scalar(@fromfiles) ==0 ) {
|
||||
print "Error: The product package file $ext_filename was not found in the package directory(s) @pkgdirlist.\n";
|
||||
# Cleanup
|
||||
system ("rm -Rf $tmpdir_base");
|
||||
return 1;
|
||||
}
|
||||
|
||||
foreach my $repo (split(/,/, $ext_reponames)) {
|
||||
my $repodir = $::base_repodir."/".$repo;
|
||||
if ( ! -d ($repodir) && (! mkpath($repodir)) ) {
|
||||
@ -3497,18 +3520,28 @@ sub NEW_kit_addpkgs
|
||||
system ("rm -Rf $tmpdir_base");
|
||||
return 1;
|
||||
}
|
||||
|
||||
foreach my $fromfile (@fromfiles) {
|
||||
if (system("cp -fp $fromfile $repodir")) {
|
||||
print "Error copying package file $fromfile to $repodir \n";
|
||||
# Cleanup
|
||||
system ("rm -Rf $tmpdir_base");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if ($::VERBOSE) {
|
||||
print "Copied @fromfiles\n to $repodir\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Handle non_native_pkgs
|
||||
# Comma-separated list of non-native package
|
||||
# paths that will be included as files in this kit
|
||||
# component.
|
||||
# these are not RPMs!
|
||||
my $to_source_dir = "$::workdir/source_packages";
|
||||
mkpath("$to_source_dir");
|
||||
foreach my $kc (@{$::bldkit_config->{kitcomponent}{entries}}) {
|
||||
@ -3519,16 +3552,28 @@ sub NEW_kit_addpkgs
|
||||
if ("$key" =~ /EXTERNALPKGS/) {
|
||||
#the $non_native_filename may contain several pkgs, can check and copy at the same time
|
||||
foreach my $nnpkg (split(/,/, $value)){
|
||||
|
||||
my $fromfile = $rpmdir."/".$nnpkg;
|
||||
if ( system("ls $fromfile > /dev/null") ){
|
||||
print "The product package file $nnpkg could not be read from the package directory $rpmdir. \n";
|
||||
return 1;
|
||||
}
|
||||
if (system("cp -fp $fromfile $to_source_dir")) {
|
||||
print "Error copying package file $fromfile to $to_source_dir \n";
|
||||
return 1;
|
||||
}
|
||||
my $found=0;
|
||||
foreach my $pdir (@pkgdirlist) {
|
||||
my $fromfile = $pdir."/".$nnpkg;
|
||||
if ( system("ls $fromfile > /dev/null") ){
|
||||
next;
|
||||
} else {
|
||||
$found++;
|
||||
if (system("cp -fp $fromfile $to_source_dir")) {
|
||||
print "Error copying package file $fromfile to $to_source_dir \n";
|
||||
# Cleanup
|
||||
system ("rm -Rf $tmpdir_base");
|
||||
next;
|
||||
} else {
|
||||
if ($::VERBOSE) {
|
||||
print "Copied $fromfile to $to_source_dir\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$found) {
|
||||
print "Could not find $nnpkg.\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3539,6 +3584,7 @@ sub NEW_kit_addpkgs
|
||||
$::HAVE_EXTERNAL_PKG = '';
|
||||
$::HAVE_NON_NATIVE_PKGS = '';
|
||||
$::NON_NATIVE_PKGS = {};
|
||||
|
||||
foreach my $kc (@{$::bldkit_config->{kitcomponent}{entries}}) {
|
||||
my $rc=0;
|
||||
if ( $debianflag ){
|
||||
@ -3552,6 +3598,7 @@ sub NEW_kit_addpkgs
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
# run createrepo
|
||||
foreach my $kr (@{$::bldkit_config->{kitrepo}{entries}}) {
|
||||
my $repodir = "$::base_repodir/$kr->{kitreponame}";
|
||||
@ -3575,7 +3622,6 @@ sub NEW_kit_addpkgs
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Build the full kit tar file
|
||||
my $buildtar_rc = &kit_buildtar;
|
||||
|
||||
|
@ -85,7 +85,7 @@ sub get_latest_version
|
||||
my $fullrpmpath = "$repodir/$rpm*";
|
||||
|
||||
# get the basename, version, and release for this rpm
|
||||
my $rcmd = "rpm -qp --queryformat '%{N} %{V} %{R}\n' $repodir/$rpm*";
|
||||
my $rcmd = "rpm -qp --queryformat '%{N} %{V} %{R}\n' $repodir/$rpm";
|
||||
my $out = `$rcmd`;
|
||||
|
||||
my ($rpkg, $VERSION, $RELEASE) = split(' ', $out);
|
||||
@ -125,10 +125,107 @@ sub get_latest_version
|
||||
$i++;
|
||||
}
|
||||
|
||||
return ($file_name_hash{$versionout}{$releaseout});
|
||||
if ($i == 0)
|
||||
{
|
||||
print "Error: Could not determine the latest version for the following list of rpms: @rpmlist\n";
|
||||
return undef;
|
||||
} else {
|
||||
return ($file_name_hash{$versionout}{$releaseout});
|
||||
}
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
=head3 find_latest_pkg
|
||||
|
||||
Find the latest rpm package give the rpm name and a list of
|
||||
possible package locations.
|
||||
|
||||
Arguments:
|
||||
- a list of package directories
|
||||
- the name of the rpm
|
||||
Returns:
|
||||
- \@foundrpmlist
|
||||
- undef
|
||||
Example:
|
||||
my $newrpm = xCAT::BuildKitUtils->find_latest_pkg(\@pkgdirs, $rpmname);
|
||||
Comments:
|
||||
|
||||
=cut
|
||||
#--------------------------------------------------------------------------
|
||||
sub find_latest_pkg
|
||||
{
|
||||
my ($class, $pkgdirs, $rpmname) = @_;
|
||||
my @pkgdirlist = @$pkgdirs;
|
||||
|
||||
my @rpms;
|
||||
my %foundrpm;
|
||||
|
||||
# need to check each pkgdir for the rpm(s)
|
||||
# - if more than one match need to pick latest
|
||||
# find all the matches in all the directories
|
||||
foreach my $rpmdir (@pkgdirlist) {
|
||||
my $ffile = $rpmdir."/".$rpmname;
|
||||
|
||||
if ( system("/bin/ls $ffile > /dev/null 2>&1") ){
|
||||
# if not then skip to next dir
|
||||
next;
|
||||
} else {
|
||||
# if so then get the details and add it to the %foundrpm hash
|
||||
my $cmd = "/bin/ls $ffile 2>/dev/null";
|
||||
my $output = `$cmd`;
|
||||
my @rpmlist = split(/\n/, $output);
|
||||
|
||||
if ( scalar(@rpmlist) == 0) {
|
||||
# no rpms to check
|
||||
next;
|
||||
}
|
||||
|
||||
foreach my $r (@rpmlist) {
|
||||
my $rcmd = "rpm -qp --queryformat '%{N} %{V} %{R}\n' $r*";
|
||||
my $out = `$rcmd`;
|
||||
my ($name, $fromV, $fromR) = split(' ', $out);
|
||||
chomp $fromV;
|
||||
chomp $fromR;
|
||||
|
||||
# ex. {ppe_rte_man}{/tmp/rpm1/ppe_rte_man-1.3.0.5-s005a.x86_64.rpm}{version}=$fromV;
|
||||
$foundrpm{$name}{$r}{version}=$fromV;
|
||||
$foundrpm{$name}{$r}{release}=$fromR;
|
||||
|
||||
#print "name=$name, full=$r, verson= $fromV, release=$fromR\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# for each unique rpm basename
|
||||
foreach my $r (keys %foundrpm ) {
|
||||
# if more than one with same basename then find the latest
|
||||
my $latestmatch="";
|
||||
foreach my $frpm (keys %{$foundrpm{$r}} ) {
|
||||
# if we already found a match in some other dir
|
||||
if ($latestmatch) {
|
||||
# then we need to figure out which is the newest
|
||||
# if the $frpm is newer than use it
|
||||
if ( xCAT::BuildKitUtils->testVersion($foundrpm{$r}{$frpm}{version}, ">", $foundrpm{$r}{$latestmatch}{version}, $foundrpm{$r}{$frpm}{release}, $foundrpm{$r}{$latestmatch}{release}) ) {
|
||||
$latestmatch = $frpm;
|
||||
}
|
||||
|
||||
} else {
|
||||
$latestmatch = $frpm;
|
||||
}
|
||||
}
|
||||
push(@rpms, $latestmatch);
|
||||
}
|
||||
|
||||
if (scalar(@rpms)) {
|
||||
return \@rpms;
|
||||
} else {
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
=head3 testVersion
|
||||
|
||||
Compare version1 and version2 according to the operator and
|
||||
|
@ -23,6 +23,7 @@ use File::Temp qw/tempdir/;
|
||||
use File::Copy;
|
||||
use Fcntl qw/:flock/;
|
||||
use IO::Socket; #Need name resolution
|
||||
use Scalar::Util qw/looks_like_number/;
|
||||
#use Data::Dumper;
|
||||
Getopt::Long::Configure("bundling");
|
||||
Getopt::Long::Configure("pass_through");
|
||||
@ -2087,11 +2088,16 @@ sub chhypervisor {
|
||||
my $maintenance;
|
||||
my $online;
|
||||
my $stat;
|
||||
my $vlanaddspec;
|
||||
my $vlanremspec;
|
||||
require Getopt::Long;
|
||||
GetOptions(
|
||||
'maintenance|m' => \$maintenance,
|
||||
'online|o' => \$online,
|
||||
'show|s' => \$stat,
|
||||
'show|s' => \$stat,
|
||||
'addvlan=s' => \$vlanaddspec,
|
||||
'removevlan=s' => \$vlanremspec,
|
||||
);
|
||||
my $hyp = $args{hyp};
|
||||
$hyphash{$hyp}->{hostview} = get_hostview(hypname=>$hyp,conn=>$hyphash{$hyp}->{conn}); #,properties=>['config','configManager']);
|
||||
@ -2119,8 +2125,11 @@ sub chhypervisor {
|
||||
xCAT::SvrUtils::sendmsg("hypervisor online", $output_handler,$hyp);
|
||||
}
|
||||
}
|
||||
} elsif ($vlanaddspec) {
|
||||
fixup_hostportgroup($vlanaddspec, $hyp);
|
||||
} elsif ($vlanremspec) {
|
||||
fixup_hostportgroup($vlanremspec, $hyp, action=>'remove');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -3736,6 +3745,93 @@ sub scan_cluster_networks {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub fixup_hostportgroup {
|
||||
my $vlanspec = shift;
|
||||
my $hyp = shift;
|
||||
my %args = @_;
|
||||
my $action = 'add';
|
||||
if ($args{action}) { $action = $args{action} }
|
||||
my $hostview = $hyphash{$hyp}->{hostview};
|
||||
my $switchsupport = 0;
|
||||
eval {
|
||||
require xCAT::SwitchHandler;
|
||||
$switchsupport = 1;
|
||||
};
|
||||
my $hypconn = $hyphash{$hyp}->{conn}; #this function can't work in clustered mode anyway, so this is appropriote.
|
||||
my $vldata = $vlanspec;
|
||||
my $switchname = get_default_switch_for_hypervisor($hyp);
|
||||
my $pgname;
|
||||
$vldata =~ s/=.*//; #TODO specify nic model with <blah>=model
|
||||
if ($vldata =~ /:/) { #The config specifies a particular path in some way
|
||||
$vldata =~ s/(.*)://;
|
||||
$switchname = get_switchname_for_portdesc($hyp,$1);
|
||||
$pgname=$switchname."-".$vldata;
|
||||
} else { #Use the default vswitch per table config to connect this through, use the same name we did before to maintain compatibility
|
||||
$pgname=$vldata;
|
||||
}
|
||||
my $netsys;
|
||||
$hyphash{$hyp}->{pgnames}->{$vlanspec}=$pgname;
|
||||
my $policy = HostNetworkPolicy->new();
|
||||
unless ($hyphash{$hyp}->{nets}->{$pgname}) {
|
||||
my $vlanid;
|
||||
if (looks_like_number($vldata)) {
|
||||
$vlanid = $vldata;
|
||||
} elsif ($vldata =~ /trunk/) {
|
||||
$vlanid=4095;
|
||||
} elsif ($vldata =~ /vl(an)?(\d+)$/) {
|
||||
$vlanid=$2;
|
||||
} else {
|
||||
$vlanid = 0;
|
||||
}
|
||||
if ($vlanid > 0 and $vlanid < 4095 and $switchsupport) {
|
||||
my $switchtab = xCAT::Table->new("switch", -create=>0);
|
||||
if ($switchtab) {
|
||||
my $swent = $switchtab->getNodeAttribs($hyp, [qw/switch port/]);
|
||||
if ($swent and $swent->{'switch'}) {
|
||||
my $swh = new xCAT::SwitchHandler->new($swent->{'switch'});
|
||||
my @vlids = $swh->get_vlan_ids();
|
||||
if ($action eq 'add') {
|
||||
unless (grep {$_ eq $vlanid} @vlids) {
|
||||
$swh->create_vlan($vlanid);
|
||||
}
|
||||
$swh->add_ports_to_vlan($vlanid, $swent->{'port'});
|
||||
} elsif ($action eq 'remove') {
|
||||
$swh->remove_ports_from_vlan($vlanid, $swent->{'port'});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
my $hostgroupdef = HostPortGroupSpec->new(
|
||||
name =>$pgname,
|
||||
vlanId=>$vlanid,
|
||||
policy=>$policy,
|
||||
vswitchName=>$switchname
|
||||
);
|
||||
unless ($netsys) {
|
||||
$netsys = $hyphash{$hyp}->{conn}->get_view(mo_ref=>$hostview->configManager->networkSystem);
|
||||
}
|
||||
if ($action eq 'remove') {
|
||||
$netsys->RemovePortGroup(pgName=>$pgname);
|
||||
return;
|
||||
} elsif ($action eq 'add') {
|
||||
$netsys->AddPortGroup(portgrp=>$hostgroupdef);
|
||||
}
|
||||
#$hyphash{$hyp}->{nets}->{$netname}=1;
|
||||
while ((not defined $hyphash{$hyp}->{nets}->{$pgname}) and sleep 1) { #we will only sleep if we know something will be waiting for
|
||||
$hostview->update_view_data(); #pull in changes induced by previous activity
|
||||
if (defined $hostview->{network}) { #We load the new object references
|
||||
foreach (@{$hostview->network}) {
|
||||
my $nvw = $hypconn->get_view(mo_ref=>$_);
|
||||
if (defined $nvw->name) {
|
||||
$hyphash{$hyp}->{nets}->{$nvw->name}=$_;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub validate_network_prereqs {
|
||||
my $nodes = shift;
|
||||
my $hyp = shift;
|
||||
@ -3761,53 +3857,7 @@ sub validate_network_prereqs {
|
||||
foreach $node (@$nodes) {
|
||||
my @networks = split /,/,$tablecfg{vm}->{$node}->[0]->{nics};
|
||||
foreach (@networks) {
|
||||
my $switchname = get_default_switch_for_hypervisor($hyp);
|
||||
my $tabval=$_;
|
||||
my $pgname;
|
||||
s/=.*//; #TODO specify nic model with <blah>=model
|
||||
if (/:/) { #The config specifies a particular path in some way
|
||||
s/(.*)://;
|
||||
$switchname = get_switchname_for_portdesc($hyp,$1);
|
||||
$pgname=$switchname."-".$_;
|
||||
} else { #Use the default vswitch per table config to connect this through, use the same name we did before to maintain compatibility
|
||||
$pgname=$_;
|
||||
}
|
||||
my $netname = $_;
|
||||
my $netsys;
|
||||
$hyphash{$hyp}->{pgnames}->{$tabval}=$pgname;
|
||||
my $policy = HostNetworkPolicy->new();
|
||||
unless ($hyphash{$hyp}->{nets}->{$pgname}) {
|
||||
my $vlanid;
|
||||
if ($netname =~ /trunk/) {
|
||||
$vlanid=4095;
|
||||
} elsif ($netname =~ /vl(an)?(\d+)$/) {
|
||||
$vlanid=$2;
|
||||
} else {
|
||||
$vlanid = 0;
|
||||
}
|
||||
my $hostgroupdef = HostPortGroupSpec->new(
|
||||
name =>$pgname,
|
||||
vlanId=>$vlanid,
|
||||
policy=>$policy,
|
||||
vswitchName=>$switchname
|
||||
);
|
||||
unless ($netsys) {
|
||||
$netsys = $hyphash{$hyp}->{conn}->get_view(mo_ref=>$hostview->configManager->networkSystem);
|
||||
}
|
||||
$netsys->AddPortGroup(portgrp=>$hostgroupdef);
|
||||
#$hyphash{$hyp}->{nets}->{$netname}=1;
|
||||
while ((not defined $hyphash{$hyp}->{nets}->{$pgname}) and sleep 1) { #we will only sleep if we know something will be waiting for
|
||||
$hostview->update_view_data(); #pull in changes induced by previous activity
|
||||
if (defined $hostview->{network}) { #We load the new object references
|
||||
foreach (@{$hostview->network}) {
|
||||
my $nvw = $hypconn->get_view(mo_ref=>$_);
|
||||
if (defined $nvw->name) {
|
||||
$hyphash{$hyp}->{nets}->{$nvw->name}=$_;
|
||||
}
|
||||
}
|
||||
}
|
||||
} #end while loop
|
||||
}
|
||||
fixup_hostportgroup($_, $hyp);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
|
@ -21,6 +21,7 @@ sub handled_commands {
|
||||
return {
|
||||
mkstorage => "storage:type",
|
||||
rmstorage => "storage:type",
|
||||
lspool => "storage:type",
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,6 +87,25 @@ sub mkstorage {
|
||||
}
|
||||
}
|
||||
|
||||
sub hashifyoutput {
|
||||
my @svcoutput = @_;
|
||||
my $hdr = shift @svcoutput;
|
||||
my @columns = split /:/, $hdr;
|
||||
my @ret;
|
||||
foreach my $line (@svcoutput) {
|
||||
my $index = 0;
|
||||
my %record = ();
|
||||
my $keyname;
|
||||
foreach my $datum (split /:/, $line) {
|
||||
$keyname = $columns[$index];
|
||||
$record{$keyname} = $datum;
|
||||
$index += 1;
|
||||
}
|
||||
push @ret,\%record;
|
||||
}
|
||||
pop @ret; # discard data from prompt
|
||||
return @ret;
|
||||
}
|
||||
sub bindhosts {
|
||||
my $nodes = shift;
|
||||
my $lun = shift;
|
||||
@ -283,10 +303,24 @@ sub process_request {
|
||||
$dorequest = shift;
|
||||
if ($request->{command}->[0] eq 'mkstorage') {
|
||||
mkstorage($request);
|
||||
} elsif ($request->{command}->[0] eq 'lspool') {
|
||||
lsmdiskgrp($request);
|
||||
}
|
||||
foreach (values %controllersessions) {
|
||||
$_->close();
|
||||
}
|
||||
}
|
||||
|
||||
sub lsmdiskgrp {
|
||||
my $req = shift;
|
||||
foreach my $node (@{$req->{node}}) {
|
||||
my $session = establish_session(controller=>$node);
|
||||
my @pools = hashifyoutput($session->cmd("lsmdiskgrp -delim :"));
|
||||
foreach my $pool (@pools) {
|
||||
sendmsg($pool->{name}. " available capacity: ".$pool->{free_capacity},$callback,$node);
|
||||
sendmsg($pool->{name}. " total capacity: ".$pool->{capacity},$callback,$node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user