Changes to 'refs/tags/spacewalk-setup-1.8.7-1'
by Milan Zazrivec
Tag 'spacewalk-setup-1.8.7-1' created by Milan Zazrivec <mzazrivec(a)redhat.com> at 2012-04-24 12:42 +0000
Tagging package [spacewalk-setup] version [1.8.7-1] in directory [spacewalk/setup/].
Changes since spacewalk-utils-1.8.9-1:
Milan Zazrivec (4):
Rename cobbler-setup to cobbler20-setup
spacewalk-setup-cobbler: script to configure cobbler for Spacewalk
modify Makefile.PL for new cobbler setup layout
Automatic commit of package [spacewalk-setup] release [1.8.7-1].
Tomas Lestach (1):
814836 - do not list ks session related activation keys
---
java/code/src/com/redhat/rhn/domain/token/ActivationKey.hbm.xml | 2
rel-eng/packages/spacewalk-setup | 2
spacewalk/setup/Makefile.PL | 6
spacewalk/setup/bin/cobbler-setup | 108 ----
spacewalk/setup/bin/cobbler20-setup | 108 ++++
spacewalk/setup/bin/spacewalk-setup | 88 ---
spacewalk/setup/bin/spacewalk-setup-cobbler | 261 ++++++++++
spacewalk/setup/share/cobbler/modules.conf | 1
spacewalk/setup/share/cobbler/settings | 5
spacewalk/setup/spacewalk-setup.spec | 12
10 files changed, 396 insertions(+), 197 deletions(-)
---
11 years, 11 months
4 commits - rel-eng/packages spacewalk/setup
by Milan Zazrivec
rel-eng/packages/spacewalk-setup | 2
spacewalk/setup/Makefile.PL | 6
spacewalk/setup/bin/cobbler-setup | 108 -----------
spacewalk/setup/bin/cobbler20-setup | 108 +++++++++++
spacewalk/setup/bin/spacewalk-setup | 88 ---------
spacewalk/setup/bin/spacewalk-setup-cobbler | 261 ++++++++++++++++++++++++++++
spacewalk/setup/share/cobbler/modules.conf | 1
spacewalk/setup/share/cobbler/settings | 5
spacewalk/setup/spacewalk-setup.spec | 12 +
9 files changed, 395 insertions(+), 196 deletions(-)
New commits:
commit 46ecb5b914911b9e775dbbd6f1363d7a5fe2b10a
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Tue Apr 24 14:42:28 2012 +0200
Automatic commit of package [spacewalk-setup] release [1.8.7-1].
diff --git a/rel-eng/packages/spacewalk-setup b/rel-eng/packages/spacewalk-setup
index 26c1762..fe88fd8 100644
--- a/rel-eng/packages/spacewalk-setup
+++ b/rel-eng/packages/spacewalk-setup
@@ -1 +1 @@
-1.8.6-1 spacewalk/setup/
+1.8.7-1 spacewalk/setup/
diff --git a/spacewalk/setup/spacewalk-setup.spec b/spacewalk/setup/spacewalk-setup.spec
index 24ef3dd..e26192c 100644
--- a/spacewalk/setup/spacewalk-setup.spec
+++ b/spacewalk/setup/spacewalk-setup.spec
@@ -1,5 +1,5 @@
Name: spacewalk-setup
-Version: 1.8.6
+Version: 1.8.7
Release: 1%{?dist}
Summary: Initial setup tools for Red Hat Spacewalk
@@ -110,6 +110,10 @@ rm -rf %{buildroot}
%{_mandir}/man8/spacewalk-make-mount-points*
%changelog
+* Tue Apr 24 2012 Milan Zazrivec <mzazrivec(a)redhat.com> 1.8.7-1
+- spacewalk-setup-cobbler: script to configure cobbler for Spacewalk
+- Rename cobbler-setup to cobbler20-setup
+
* Tue Apr 17 2012 Jan Pazdziora 1.8.6-1
- Create deploy.sql on PostgreSQL as well (mzazrivec(a)redhat.com)
commit 87d4fed998c5b354bb74a6f024d15c4942e9b325
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Tue Apr 24 14:21:07 2012 +0200
modify Makefile.PL for new cobbler setup layout
diff --git a/spacewalk/setup/Makefile.PL b/spacewalk/setup/Makefile.PL
index 9cae919..7bb7f09 100644
--- a/spacewalk/setup/Makefile.PL
+++ b/spacewalk/setup/Makefile.PL
@@ -8,12 +8,14 @@ WriteMakefile(
VERSION_FROM => 'lib/Spacewalk/Setup.pm',
ABSTRACT_FROM => 'lib/Spacewalk/Setup.pm',
PL_FILES => {},
- EXE_FILES => ['bin/spacewalk-setup', 'bin/cobbler20-setup', 'bin/spacewalk-make-mount-points'],
+ EXE_FILES => ['bin/spacewalk-setup', 'bin/cobbler20-setup', 'bin/spacewalk-make-mount-points',
+ 'bin/spacewalk-setup-cobbler'],
PREREQ_PM => {
'Test::More' => 0,
},
MAN1PODS => { 'lib/Spacewalk/Setup.pm' => '$(INST_MAN1DIR)/spacewalk-setup.$(MAN1EXT)',
- 'bin/cobbler-setup' => '$(INST_MAN1DIR)/cobbler20-setup.$(MAN1EXT)',
+ 'bin/cobbler20-setup' => '$(INST_MAN1DIR)/cobbler20-setup.$(MAN1EXT)',
+ 'bin/spacewalk-setup-cobbler' => '$(INST_MAN1DIR)/spacewalk-setup-cobbler.$(MAN1EXT)',
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Spacewalk-Setup-*' },
commit f467a5b2473f8da01544b115217d98653da828f5
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Tue Apr 24 14:17:46 2012 +0200
spacewalk-setup-cobbler: script to configure cobbler for Spacewalk
diff --git a/spacewalk/setup/bin/spacewalk-setup b/spacewalk/setup/bin/spacewalk-setup
index a5edec7..c08f777 100755
--- a/spacewalk/setup/bin/spacewalk-setup
+++ b/spacewalk/setup/bin/spacewalk-setup
@@ -38,7 +38,8 @@ $DEBUG = 0;
use constant DEFAULT_CA_CERT_NAME =>
'RHN-ORG-TRUSTED-SSL-CERT';
-use constant COBBLER_COMMAND => 'cobbler-setup';
+use constant COBBLER_20_COMMAND => 'cobbler20-setup';
+use constant COBBLER_COMMAND => 'spacewalk-setup-cobbler';
my %opts = Spacewalk::Setup::parse_options();
@@ -236,89 +237,9 @@ sub setup_cobbler {
# newer versions of Cobbler don't ship the config templates
if ($cobbler_version =~ /2\.0/) {
# Cobbler 2.0 can use the old helper script
- system(COBBLER_COMMAND);
+ system(COBBLER_20_COMMAND);
} else {
- my $cobbler_dir = '/etc/cobbler';
- my $cobbler_settings_file = 'settings';
- my $cobbler_modules_file = 'modules.conf';
-
- my %cobbler_settings = (
- 'server' => $answers->{'hostname'},
- 'next_server' => $answers->{'hostname'},
- 'redhat_management_server' => $answers->{'hostname'},
- 'redhat_management_type' => 'site',
- 'pxe_just_once' => 1
- );
-
- Spacewalk::Setup::backup_file($cobbler_dir, $cobbler_settings_file);
-
- open(FILE, "<$cobbler_dir/$cobbler_settings_file");
-
- my @output_lines;
- while(<FILE>) {
- my $line = $_;
-
- foreach my $key (keys(%cobbler_settings)) {
- if ($line =~ /^$key ?:/) {
- $line = "$key: $cobbler_settings{$key}\n";
- last;
- }
- }
-
- push(@output_lines, $line);
- }
-
- close(FILE);
-
- # write the new file
- open(FILE, ">$cobbler_dir/$cobbler_settings_file");
- for my $line (@output_lines) {
- print FILE $line;
- }
- close(FILE);
-
- my %cobbler_modules = ( 'authentication' => 'authn_spacewalk' );
- Spacewalk::Setup::backup_file($cobbler_dir, $cobbler_modules_file);
- open(FILE, "<$cobbler_dir/$cobbler_modules_file");
-
- @output_lines = ();
- my $replace = 0;
- my $value = '';
- while(<FILE>) {
- my $line = $_;
-
- # look for the next 'module' line
- if ($replace) {
- if ($line =~ /^module ?=/) {
- $line = "module = $value\n";
- push(@output_lines, $line);
- $replace = 0;
- next;
- } else {
- next;
- }
- }
-
- # look for a section in the config
- foreach my $key (keys(%cobbler_modules)) {
- if ($line =~ /^\[$key\]/) {
- $replace = 1;
- $value = $cobbler_modules{$key};
- last;
- }
- }
-
- push(@output_lines, $line);
- }
-
- close(FILE);
-
- # write the new file
- open(FILE, ">$cobbler_dir/$cobbler_modules_file");
- for my $line (@output_lines) {
- print FILE $line;
- }
- close(FILE);
+ system(COBBLER_COMMAND . " --verbose --macros hostname:$answers->{'hostname'}");
my $skip_rhnconf = 0;
open(FILE, "<" . Spacewalk::Setup::DEFAULT_RHN_CONF_LOCATION);
@@ -336,6 +257,7 @@ sub setup_cobbler {
print FILE "cobbler.host = " . $answers->{'hostname'} . "\n";
close(FILE);
}
+ system("/usr/bin/cobbler sync");
}
Spacewalk::Setup::ask(
diff --git a/spacewalk/setup/bin/spacewalk-setup-cobbler b/spacewalk/setup/bin/spacewalk-setup-cobbler
new file mode 100755
index 0000000..6fc9c00
--- /dev/null
+++ b/spacewalk/setup/bin/spacewalk-setup-cobbler
@@ -0,0 +1,261 @@
+#!/usr/bin/perl
+
+eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
+ if 0; # not running under some shell
+#
+# Copyright (c) 2012 Red Hat, Inc.
+#
+# This software is licensed to you under the GNU General Public License,
+# version 2 (GPLv2). There is NO WARRANTY for this software, express or
+# implied, including the implied warranties of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+# along with this software; if not, see
+# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+#
+# Red Hat trademarks are not licensed under GPLv2. No permission is
+# granted to use or replicate Red Hat trademarks that are incorporated
+# in this software or its documentation.
+
+use Sys::Hostname;
+use Getopt::Long;
+use Spacewalk::Setup;
+
+use strict 'refs';
+use warnings FATAL => 'all';;
+
+my $macros = '';
+my $verbose;
+my $help = 0;
+my %macros = ('hostname' => Sys::Hostname::hostname());
+
+my @ini_files = ('modules.conf');
+my @flat_files = ('settings');
+
+my $usage = <<EOHELP;
+Usage: $0 --help | --macros macros
+Options:
+ --help Print this help message
+ --verbose Verbose output
+ --macros Comma delimited list of macroname:macrovalue options
+EOHELP
+
+GetOptions("macros:s" => \$macros, "verbose" => \$verbose, "help" => \$help) or die $usage;
+if ($help) {
+ print $usage;
+ exit 0;
+}
+
+if ($macros) {
+ foreach my $i (split(/,/, $macros, 0)) {
+ my ($key, $value) = split(/:/, $i, 3);
+ $macros{$key} = $value;
+ }
+}
+
+foreach my $configfile ('modules.conf', 'settings') {
+ my $cfpath= "/etc/cobbler/" . $configfile;
+ my @original_content = my @modified_content = @{ read_filelines($cfpath) };
+ my %cf_def = %{ read_config_definition($configfile, \%macros) };
+ my $i = 0;
+ my $section;
+
+ print "Processing $cfpath\n" if $verbose;
+ foreach my $line (@original_content) {
+ next if ($line =~ /^\s*#/);
+
+ $section = $1 if ($line =~ /^\[(.+)\]\s*$/);
+
+ if ($line =~ /^([^#=:]+?)\s*[:=]\s*(.+?)\s*$/) {
+ if (defined $section) {
+ if (defined $cf_def{$section}{$1} && not $cf_def{$section}{$1} eq $2) {
+ $modified_content[$i] = "## disabled by spacewalk-setup-cobbler ## " .
+ "$line$1 = $cf_def{$section}{$1}\n";
+ }
+ } else {
+ if (defined $cf_def{$1} && not $cf_def{$1} eq $2) {
+ $modified_content[$i] = "## disabled by spacewalk-setup-cobbler ## " .
+ "$line$1: $cf_def{$1}\n";
+ }
+ }
+ }
+ } continue {
+ ++$i;
+ }
+
+ if (!arrays_match(\@original_content, \@modified_content)) {
+ my @backup_cmd = ('/bin/cp', '-p', '--backup=numbered', $cfpath, "$cfpath-swsave");
+ push @backup_cmd, '-v' if $verbose;
+ system(@backup_cmd);
+
+ local *FILE;
+ open FILE, ">$cfpath" or die "Error opening [$cfpath] for writing: $!\n";
+ print FILE @modified_content;
+ close FILE;
+ }
+}
+
+sub read_filelines {
+ my $path = shift;
+ my @content;
+
+ local *CF_FILE;
+ open (CF_FILE, $path) or die "Error opening [$path] for reading: $!\n";
+ @content = <CF_FILE>;
+ close CF_FILE;
+
+ return \@content;
+}
+
+sub read_config_definition {
+ my $file = shift;
+ my %macros = %{(shift)};
+ my %definition;
+
+ foreach my $line (@{read_filelines(Spacewalk::Setup::SHARED_DIR . "/cobbler/$file")}) {
+ chomp $line;
+ next if $line =~ /^\s*(#|$)/;
+ my @content = split / /, $line, 3;
+ my $value = $content[-1];
+
+ if ($value and $value =~ /^\@(.+)\(a)$/) {
+ $value = $macros{$1} if defined $macros{$1};
+ }
+
+ if (scalar(@content) == 2) {
+ $definition{$content[0]} = $value;
+ } elsif (scalar(@content) == 3) {
+ $definition{$content[0]}{$content[1]} = $value;
+ }
+ }
+
+ return \%definition;
+}
+
+sub arrays_match {
+ my @array1 = @{(shift)};
+ my @array2 = @{(shift)};
+
+ foreach my $i (@array1) {
+ return 0 if ! grep {$i eq $_} (@array2);
+ }
+
+ return 1;
+}
+
+1;
+
+=head1 NAME
+
+spacewalk-setup-cobbler - utility for configuring cobbler services to work with
+Spacewalk / Satellite
+
+=head1 SYNOPSIS
+
+B<spacewalk-setup-cobbler>
+[B<--help>]
+[B<--verbose>]
+[B<--macros macro1:macro1value,macro2:macro2value...>]
+
+=head1 OPTIONS
+
+=over 5
+
+=item B<--macros>
+
+Specify macro names and corresponding macro values that will be used for
+substitution for correct document modification. You can specify multiple
+macro:value pairs which you need to delimit by commas.
+
+Example: --macros hostname:host.domain.org
+
+=item B<--verbose>
+
+Verbose script operation.
+
+=item B<--help>
+
+Print help message.
+
+=back
+
+=head1 DESCRIPTION
+
+B<spacewalk-setup-cobbler> is a utility for configuring cobbler to work
+with Spacewalk / Satellite. The script uses template documents to modify
+default / existing cobbler configuration.
+
+Ordinarily, spacewalk-setup-cobbler is called by spacewalk-setup(1) during
+initial Spacewalk / Satellite configuration or upgrade.
+
+The workflow of the script is:
+
+=over 5
+
+=item
+
+For each of the cobbler configuration files, the script reads appropriate
+template file.
+
+=item
+
+Substitutes macros as found in template files with expanded values.
+
+=item
+
+Reads particular cobbler configuration files and substitutes default / existing
+values with values from template files.
+
+=item
+
+Resulting configuration files are written out while the original files are backed up.
+
+=back
+
+=head1 TEMPLATE FILES
+
+Basename of a template files must be the same as the basename of
+the corresponding configuration file.
+
+A template file for an INI-style configuration file (such as
+/etc/cobbler/modules.conf) has the following format:
+
+C<section parameter value>
+
+A template file for a key: value type of configuration file (such as
+/etc/cobbler/settings) has the following format:
+
+C<parameter value>
+
+In both cases, string enclosed in '@' signs (e.g. @hostname@) denotes a macro
+name rather than an actual value.
+
+=head1 MACROS
+
+Currently, the only recognized macro is B<hostname>. If not specified on
+command line, the hostname will be determined automatically.
+
+=head1 FILES
+
+Template files used for modification of existing cobbler configuration files:
+
+F</usr/share/spacewalk/setup/cobbler/modules.conf>
+
+F</usr/share/spacewalk/setup/cobbler/settings>
+
+Cobbler configuration files modified by spacewalk-setup-cobbler:
+
+F</etc/cobbler/modules.conf>
+
+F</etc/cobbler/settings>
+
+=head1 SEE ALSO
+
+B<spacewalk-setup>(1) - Spacewalk setup program
+
+B<cobbler>(1) - Cobbler manual page
+
+=head1 AUTHORS
+
+Milan Zazrivec
+
+=cut
diff --git a/spacewalk/setup/share/cobbler/modules.conf b/spacewalk/setup/share/cobbler/modules.conf
new file mode 100644
index 0000000..0f13ead
--- /dev/null
+++ b/spacewalk/setup/share/cobbler/modules.conf
@@ -0,0 +1 @@
+authentication module authn_spacewalk
diff --git a/spacewalk/setup/share/cobbler/settings b/spacewalk/setup/share/cobbler/settings
new file mode 100644
index 0000000..42f311a
--- /dev/null
+++ b/spacewalk/setup/share/cobbler/settings
@@ -0,0 +1,5 @@
+next_server @hostname@
+pxe_just_once 1
+redhat_management_type "site"
+redhat_management_server @hostname@
+server @hostname@
diff --git a/spacewalk/setup/spacewalk-setup.spec b/spacewalk/setup/spacewalk-setup.spec
index 50bdffe..24ef3dd 100644
--- a/spacewalk/setup/spacewalk-setup.spec
+++ b/spacewalk/setup/spacewalk-setup.spec
@@ -72,6 +72,8 @@ install -d -m 755 %{buildroot}/%{_datadir}/spacewalk/setup/defaults.d/
install -d -m 755 %{buildroot}/%{_datadir}/spacewalk/setup/upgrade
install -m 0755 share/upgrade/* %{buildroot}/%{_datadir}/spacewalk/setup/upgrade
install -m 0644 share/defaults.d/defaults.conf %{buildroot}/%{_datadir}/spacewalk/setup/defaults.d/
+install -d -m 755 %{buildroot}/%{_datadir}/spacewalk/setup/cobbler
+install -m 0644 share/cobbler/* %{buildroot}/%{_datadir}/spacewalk/setup/cobbler/
# Oracle specific stuff, possible candidate for sub-package down the road:
install -d -m 755 %{buildroot}/%{_datadir}/spacewalk/setup/oracle/
@@ -84,6 +86,7 @@ install -d -m 755 %{buildroot}/%{_var}/spacewalk
mkdir -p $RPM_BUILD_ROOT%{_mandir}/man8
/usr/bin/pod2man --section=8 $RPM_BUILD_ROOT/%{_bindir}/spacewalk-make-mount-points | gzip > $RPM_BUILD_ROOT%{_mandir}/man8/spacewalk-make-mount-points.8.gz
+/usr/bin/pod2man --section=1 $RPM_BUILD_ROOT/%{_bindir}/spacewalk-setup-cobbler | gzip > $RPM_BUILD_ROOT%{_mandir}/man1/spacewalk-setup-cobbler.1.gz
%check
make test
@@ -99,6 +102,7 @@ rm -rf %{buildroot}
%{perl_vendorlib}/*
%{_bindir}/spacewalk-setup
%{_bindir}/spacewalk-make-mount-points
+%{_bindir}/spacewalk-setup-cobbler
%{_bindir}/cobbler20-setup
%{_mandir}/man[13]/*.[13]*
%{_datadir}/spacewalk/*
commit b876b9d0e1fdb186a2e758a880e38e086735fca3
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Tue Apr 24 13:51:43 2012 +0200
Rename cobbler-setup to cobbler20-setup
This is left in case one would need to configure cobbler v2.0.
diff --git a/spacewalk/setup/Makefile.PL b/spacewalk/setup/Makefile.PL
index b0b8061..9cae919 100644
--- a/spacewalk/setup/Makefile.PL
+++ b/spacewalk/setup/Makefile.PL
@@ -8,12 +8,12 @@ WriteMakefile(
VERSION_FROM => 'lib/Spacewalk/Setup.pm',
ABSTRACT_FROM => 'lib/Spacewalk/Setup.pm',
PL_FILES => {},
- EXE_FILES => ['bin/spacewalk-setup', 'bin/cobbler-setup', 'bin/spacewalk-make-mount-points'],
+ EXE_FILES => ['bin/spacewalk-setup', 'bin/cobbler20-setup', 'bin/spacewalk-make-mount-points'],
PREREQ_PM => {
'Test::More' => 0,
},
MAN1PODS => { 'lib/Spacewalk/Setup.pm' => '$(INST_MAN1DIR)/spacewalk-setup.$(MAN1EXT)',
- 'bin/cobbler-setup' => '$(INST_MAN1DIR)/cobbler-setup.$(MAN1EXT)',
+ 'bin/cobbler-setup' => '$(INST_MAN1DIR)/cobbler20-setup.$(MAN1EXT)',
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Spacewalk-Setup-*' },
diff --git a/spacewalk/setup/bin/cobbler-setup b/spacewalk/setup/bin/cobbler-setup
deleted file mode 100755
index e8ba1ce..0000000
--- a/spacewalk/setup/bin/cobbler-setup
+++ /dev/null
@@ -1,108 +0,0 @@
-#!/usr/bin/python
-from yaml import load
-from Cheetah.Template import Template
-from socket import gethostbyname, gethostname
-import shutil
-from os.path import exists, join, dirname, basename, isdir, isfile
-from os import system, chmod
-import sys
-import re
-
-from spacewalk.common import rhnConfig
-
-TEMPLATES_DIR = '/usr/share/cobbler/installer_templates'
-MODULES_TEMPLATE = join(TEMPLATES_DIR, 'modules.conf.template')
-SETTINGS_TEMPLATE = join(TEMPLATES_DIR, 'settings.template')
-DEFAULTS = join(TEMPLATES_DIR, 'defaults')
-
-CONFIG_DIR = '/etc/cobbler/'
-MODULES = join(CONFIG_DIR, 'modules.conf')
-SETTINGS = join(CONFIG_DIR, 'settings')
-
-TEMP_MODULES = '/tmp/modules.conf'
-TEMP_SETTINGS = '/tmp/settings'
-
-def loadFile(fl):
- return load(open(fl).read())
-
-def copy(src, dest):
- if exists(dest):
- if isfile(dest):
- shutil.copy(dest, dest + ".old")
- elif isdir(dest) and isfile(src) and exists(join(dest, basename(src))):
- shutil.copy(join(dest,basename(src)), join(dest,basename(src)) + ".old")
- shutil.copy(src, dest)
-
-def ask_yes_no(question, default_val = None):
- if default_val and default_val.lower() == 'y':
- default_val = 'y'
- default_q = '[Y/n]'
- else:
- default_val = 'n'
- default_q = '[y/N]'
-
- ans = raw_input(question + " " + default_q + "?")
- if not ans:
- return default_val == 'y'
-
- return ans.lower() == 'y'
-
-def gen_template(template, answers, output):
- t = Template(file=template, searchList=answers)
- open(output,"w").write(t.respond())
-
-def main():
- answers = dict(loadFile(DEFAULTS))
- answers['server'] = gethostname()
- answers['next_server'] = answers['server']
- answers['redhat_management_server'] = answers['server']
- answers['redhat_management_type'] = 'site'
- answers['authn_module'] = 'authn_spacewalk'
- answers['pxe_once'] = '1'
- gen_template(SETTINGS_TEMPLATE, answers, TEMP_SETTINGS)
- gen_template(MODULES_TEMPLATE, answers, TEMP_MODULES)
- copy(TEMP_SETTINGS, SETTINGS)
- chmod(SETTINGS, 0644)
- copy(TEMP_MODULES, MODULES)
- chmod(MODULES, 0644)
- m = re.compile(r"^cobbler\.host\s*=\s*", re.MULTILINE)
-
- conf_lines = open(rhnConfig._CONFIG_FILE).read()
- if not m.search(conf_lines):
- system ("echo 'cobbler.host = %s' >> %s " % (answers['server'],
- rhnConfig._CONFIG_FILE))
- system("cobbler sync")
-
-
-if __name__=="__main__":
- main()
-
-
-"""
-
-=head1 NAME
-
-cobbler-setup
-
-=head1 SYNOPSIS
-
- cobbler-setup
-
-=head1 DESCRIPTION
-
-The B<cobbler-setup> program generates configuration files for cobbler
-in F</etc/cobbler>, based on templates in
-F</usr/share/cobbler/installer_templates>.
-
-The tool is generally called automatically by Spacewalk's
-B<spacewalk-setup>.
-
-=back
-
-=head1 SEE ALSO
-
-spacewalk-setup(1)
-
-=cut
-
-"""
diff --git a/spacewalk/setup/bin/cobbler20-setup b/spacewalk/setup/bin/cobbler20-setup
new file mode 100755
index 0000000..e8ba1ce
--- /dev/null
+++ b/spacewalk/setup/bin/cobbler20-setup
@@ -0,0 +1,108 @@
+#!/usr/bin/python
+from yaml import load
+from Cheetah.Template import Template
+from socket import gethostbyname, gethostname
+import shutil
+from os.path import exists, join, dirname, basename, isdir, isfile
+from os import system, chmod
+import sys
+import re
+
+from spacewalk.common import rhnConfig
+
+TEMPLATES_DIR = '/usr/share/cobbler/installer_templates'
+MODULES_TEMPLATE = join(TEMPLATES_DIR, 'modules.conf.template')
+SETTINGS_TEMPLATE = join(TEMPLATES_DIR, 'settings.template')
+DEFAULTS = join(TEMPLATES_DIR, 'defaults')
+
+CONFIG_DIR = '/etc/cobbler/'
+MODULES = join(CONFIG_DIR, 'modules.conf')
+SETTINGS = join(CONFIG_DIR, 'settings')
+
+TEMP_MODULES = '/tmp/modules.conf'
+TEMP_SETTINGS = '/tmp/settings'
+
+def loadFile(fl):
+ return load(open(fl).read())
+
+def copy(src, dest):
+ if exists(dest):
+ if isfile(dest):
+ shutil.copy(dest, dest + ".old")
+ elif isdir(dest) and isfile(src) and exists(join(dest, basename(src))):
+ shutil.copy(join(dest,basename(src)), join(dest,basename(src)) + ".old")
+ shutil.copy(src, dest)
+
+def ask_yes_no(question, default_val = None):
+ if default_val and default_val.lower() == 'y':
+ default_val = 'y'
+ default_q = '[Y/n]'
+ else:
+ default_val = 'n'
+ default_q = '[y/N]'
+
+ ans = raw_input(question + " " + default_q + "?")
+ if not ans:
+ return default_val == 'y'
+
+ return ans.lower() == 'y'
+
+def gen_template(template, answers, output):
+ t = Template(file=template, searchList=answers)
+ open(output,"w").write(t.respond())
+
+def main():
+ answers = dict(loadFile(DEFAULTS))
+ answers['server'] = gethostname()
+ answers['next_server'] = answers['server']
+ answers['redhat_management_server'] = answers['server']
+ answers['redhat_management_type'] = 'site'
+ answers['authn_module'] = 'authn_spacewalk'
+ answers['pxe_once'] = '1'
+ gen_template(SETTINGS_TEMPLATE, answers, TEMP_SETTINGS)
+ gen_template(MODULES_TEMPLATE, answers, TEMP_MODULES)
+ copy(TEMP_SETTINGS, SETTINGS)
+ chmod(SETTINGS, 0644)
+ copy(TEMP_MODULES, MODULES)
+ chmod(MODULES, 0644)
+ m = re.compile(r"^cobbler\.host\s*=\s*", re.MULTILINE)
+
+ conf_lines = open(rhnConfig._CONFIG_FILE).read()
+ if not m.search(conf_lines):
+ system ("echo 'cobbler.host = %s' >> %s " % (answers['server'],
+ rhnConfig._CONFIG_FILE))
+ system("cobbler sync")
+
+
+if __name__=="__main__":
+ main()
+
+
+"""
+
+=head1 NAME
+
+cobbler-setup
+
+=head1 SYNOPSIS
+
+ cobbler-setup
+
+=head1 DESCRIPTION
+
+The B<cobbler-setup> program generates configuration files for cobbler
+in F</etc/cobbler>, based on templates in
+F</usr/share/cobbler/installer_templates>.
+
+The tool is generally called automatically by Spacewalk's
+B<spacewalk-setup>.
+
+=back
+
+=head1 SEE ALSO
+
+spacewalk-setup(1)
+
+=cut
+
+"""
diff --git a/spacewalk/setup/spacewalk-setup.spec b/spacewalk/setup/spacewalk-setup.spec
index 112064d..50bdffe 100644
--- a/spacewalk/setup/spacewalk-setup.spec
+++ b/spacewalk/setup/spacewalk-setup.spec
@@ -99,7 +99,7 @@ rm -rf %{buildroot}
%{perl_vendorlib}/*
%{_bindir}/spacewalk-setup
%{_bindir}/spacewalk-make-mount-points
-%{_bindir}/cobbler-setup
+%{_bindir}/cobbler20-setup
%{_mandir}/man[13]/*.[13]*
%{_datadir}/spacewalk/*
%attr(755, apache, root) %{_var}/spacewalk
11 years, 11 months
java/code
by Tomas Lestach
java/code/src/com/redhat/rhn/domain/token/ActivationKey.hbm.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 03030a6b2c92ff046f0aa197c36ed063b803bba4
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Tue Apr 24 11:02:53 2012 +0200
814836 - do not list ks session related activation keys
diff --git a/java/code/src/com/redhat/rhn/domain/token/ActivationKey.hbm.xml b/java/code/src/com/redhat/rhn/domain/token/ActivationKey.hbm.xml
index 5f4508d..d4d4613 100644
--- a/java/code/src/com/redhat/rhn/domain/token/ActivationKey.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/token/ActivationKey.hbm.xml
@@ -43,7 +43,7 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
</query>
<query name="ActivationKey.findByOrg">
- <![CDATA[from com.redhat.rhn.domain.token.ActivationKey as ak where ak.token.org = :org]]>
+ <![CDATA[from com.redhat.rhn.domain.token.ActivationKey as ak where ak.token.org = :org and ak.kickstartSession = null and ak.token.server = null]]>
</query>
11 years, 11 months
Changes to 'refs/tags/spacewalk-utils-1.8.9-1'
by Miroslav Suchý
Tag 'spacewalk-utils-1.8.9-1' created by Miroslav Suchý <msuchy(a)redhat.com> at 2012-04-23 15:41 +0000
Tagging package [spacewalk-utils] version [1.8.9-1] in directory [utils/].
Changes since spacewalk-web-1.8.12-1:
Miroslav Suchý (2):
812886 - determine the advisory type by parsing "advisory_type"
Automatic commit of package [spacewalk-utils] release [1.8.9-1].
---
rel-eng/packages/spacewalk-utils | 2 +-
utils/apply_errata | 6 +++---
utils/spacewalk-utils.spec | 5 ++++-
3 files changed, 8 insertions(+), 5 deletions(-)
---
11 years, 11 months
2 commits - rel-eng/packages utils/apply_errata utils/spacewalk-utils.spec
by Miroslav Suchý
rel-eng/packages/spacewalk-utils | 2 +-
utils/apply_errata | 6 +++---
utils/spacewalk-utils.spec | 5 ++++-
3 files changed, 8 insertions(+), 5 deletions(-)
New commits:
commit 87c8b471a81efd0c0e0eff9d06643bff9ea7f332
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Mon Apr 23 17:41:09 2012 +0200
Automatic commit of package [spacewalk-utils] release [1.8.9-1].
diff --git a/rel-eng/packages/spacewalk-utils b/rel-eng/packages/spacewalk-utils
index 6eb8748..ec0afc2 100644
--- a/rel-eng/packages/spacewalk-utils
+++ b/rel-eng/packages/spacewalk-utils
@@ -1 +1 @@
-1.8.8-1 utils/
+1.8.9-1 utils/
diff --git a/utils/spacewalk-utils.spec b/utils/spacewalk-utils.spec
index b9485fb..d8a54d8 100644
--- a/utils/spacewalk-utils.spec
+++ b/utils/spacewalk-utils.spec
@@ -1,7 +1,7 @@
%define rhnroot %{_prefix}/share/rhn
Name: spacewalk-utils
-Version: 1.8.8
+Version: 1.8.9
Release: 1%{?dist}
Summary: Utilities that may be run against a Spacewalk server.
@@ -87,6 +87,9 @@ spacewalk-pylint $RPM_BUILD_ROOT%{rhnroot}
%changelog
+* Mon Apr 23 2012 Miroslav Suchý <msuchy(a)redhat.com> 1.8.9-1
+- 812886 - determine the advisory type by parsing "advisory_type"
+
* Mon Apr 23 2012 Miroslav Suchý <msuchy(a)redhat.com> 1.8.8-1
- 813281 - fix indetation
commit 7f8783c90db938d9bb1c051b01c8604b8a1e8bab
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Mon Apr 23 17:40:36 2012 +0200
812886 - determine the advisory type by parsing "advisory_type"
diff --git a/utils/apply_errata b/utils/apply_errata
index b0cab78..da485b3 100755
--- a/utils/apply_errata
+++ b/utils/apply_errata
@@ -251,13 +251,13 @@ def main():
result = pattern.search(e['advisory_synopsis'])
if result is not None:
- if type['b'] and e['advisory_name'].find("RHBA") == 0:
+ if type['b'] and (e['advisory_name'].find("RHBA") == 0 or e['advisory_type'].find("Bug Fix Advisory") == 0):
erratum.append(e['id'])
- if type['e'] and e['advisory_name'].find("RHEA") == 0:
+ if type['e'] and (e['advisory_name'].find("RHEA") == 0 or e['advisory_type'].find("Enhancement Advisory") == 0):
erratum.append(e['id'])
- if type['s'] and e['advisory_name'].find("RHSA") == 0:
+ if type['s'] and (e['advisory_name'].find("RHSA") == 0 or e['advisory_type'].find("Security Advisory") == 0):
erratum.append(e['id'])
if opt['verbose']:
11 years, 11 months
Changes to 'refs/tags/spacewalk-web-1.8.12-1'
by Miroslav Suchý
Tag 'spacewalk-web-1.8.12-1' created by Miroslav Suchý <msuchy(a)redhat.com> at 2012-04-23 15:25 +0000
Tagging package [spacewalk-web] version [1.8.12-1] in directory [web/].
Changes since spacewalk-schema-1.8.19-1:
Johannes Renner (1):
Fix errata clone name generation in perl code
Miroslav Suchý (1):
Automatic commit of package [spacewalk-web] release [1.8.12-1].
---
rel-eng/packages/spacewalk-web | 2
web/modules/rhn/RHN/DB/ErrataEditor.pm | 68 +++++++++++++++----
web/modules/sniglets/Sniglets/ListView/ErrataList.pm | 2
web/spacewalk-web.spec | 5 +
4 files changed, 61 insertions(+), 16 deletions(-)
---
11 years, 11 months
2 commits - rel-eng/packages web/modules web/spacewalk-web.spec
by Miroslav Suchý
rel-eng/packages/spacewalk-web | 2
web/modules/rhn/RHN/DB/ErrataEditor.pm | 68 +++++++++++++++----
web/modules/sniglets/Sniglets/ListView/ErrataList.pm | 2
web/spacewalk-web.spec | 5 +
4 files changed, 61 insertions(+), 16 deletions(-)
New commits:
commit 392790f1d88df96f4f17bfa1b294ca752c60924e
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Mon Apr 23 17:25:17 2012 +0200
Automatic commit of package [spacewalk-web] release [1.8.12-1].
diff --git a/rel-eng/packages/spacewalk-web b/rel-eng/packages/spacewalk-web
index 4d20a7f..881ce8a 100644
--- a/rel-eng/packages/spacewalk-web
+++ b/rel-eng/packages/spacewalk-web
@@ -1 +1 @@
-1.8.11-1 web/
+1.8.12-1 web/
diff --git a/web/spacewalk-web.spec b/web/spacewalk-web.spec
index 685d78a..2f62926 100644
--- a/web/spacewalk-web.spec
+++ b/web/spacewalk-web.spec
@@ -2,7 +2,7 @@ Name: spacewalk-web
Summary: Spacewalk Web site - Perl modules
Group: Applications/Internet
License: GPLv2
-Version: 1.8.11
+Version: 1.8.12
Release: 1%{?dist}
URL: https://fedorahosted.org/spacewalk/
Source0: https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
@@ -254,6 +254,9 @@ rm -rf $RPM_BUILD_ROOT
# $Id$
%changelog
+* Mon Apr 23 2012 Miroslav Suchý <msuchy(a)redhat.com> 1.8.12-1
+- Fix errata clone name generation in perl code
+
* Thu Apr 19 2012 Jan Pazdziora 1.8.11-1
- Removed double-dash from copyright notice on error pages.
commit 41ee9a76ec59496c120a4dfae08a87e93f752633
Author: Johannes Renner <jrenner(a)suse.de>
Date: Mon Apr 23 14:15:01 2012 +0200
Fix errata clone name generation in perl code
diff --git a/web/modules/rhn/RHN/DB/ErrataEditor.pm b/web/modules/rhn/RHN/DB/ErrataEditor.pm
index b295563..d175a75 100644
--- a/web/modules/rhn/RHN/DB/ErrataEditor.pm
+++ b/web/modules/rhn/RHN/DB/ErrataEditor.pm
@@ -153,24 +153,47 @@ EOQ
return ($new_eid);
}
+# This duplicates the algorithm in PublishErrataHelper.java
sub find_next_advisory {
my $adv = shift || '';
my $adv_name = shift || '';
- my $suffix = '';
- my $i = 1;
+ my $eid = shift;
- $adv = 'CL' . substr($adv, 2);
- $adv_name = 'CL' . substr($adv_name, 2);
+ # Set adv equal to adv_name if unset
+ unless ($adv) {
+ $adv = $adv_name;
+ }
- if (advisory_exists($adv) || advisory_name_exists($adv_name)) {
- $suffix = sprintf("-%u", $i++);
- $adv = $adv . $suffix;
- $adv_name = $adv_name . $suffix;
+ if (not erratum_is_clone($eid)) {
+ # For RH errata, replace 'RH' with 'CL-', else prepend
+ if ('RH' eq substr($adv_name, 0, 2)) {
+ $adv = 'CL-' . substr($adv, 2);
+ $adv_name = 'CL-' . substr($adv_name, 2);
+ } else {
+ $adv = 'CL-' . $adv;
+ $adv_name = 'CL-' . $adv_name;
+ }
+ } else {
+ # Erratum is a clone, prepend 'CL-', if there is no prefix yet
+ if ('-' ne substr($adv, 2, 1) || '-' ne substr($adv_name, 2, 1)) {
+ $adv = 'CL-' . $adv;
+ $adv_name = 'CL-' . $adv_name;
+ }
+ }
- while (advisory_exists($adv) || advisory_name_exists($adv_name)) {
- substr($adv, -1, 1) = $i;
- substr($adv_name, -1, 1) = $i;
- $i++;
+ # Find the next valid advisory name that doesn't exist yet
+ while (advisory_exists($adv) || advisory_name_exists($adv_name)) {
+ my $c1 = substr($adv, 1, 1);
+ if ('Z' eq $c1) {
+ # Get the next c0
+ my $c0next = ++substr($adv, 0, 1);
+ $adv = $c0next . 'A' . substr($adv, 2);
+ $adv_name = $c0next . 'A' . substr($adv_name, 2);
+ } else {
+ # Get the next c1
+ my $c1next = ++$c1;
+ $adv = substr($adv, 0, 1) . $c1next . substr($adv, 2);
+ $adv_name = substr($adv_name, 0, 1) . $c1next . substr($adv_name, 2);
}
}
@@ -200,7 +223,7 @@ sub clone_into_org {
my $adv = $new->advisory;
my $adv_name = $new->advisory_name;
- ($adv, $adv_name) = find_next_advisory($adv, $adv_name);
+ ($adv, $adv_name) = find_next_advisory($adv, $adv_name, $old_eid);
$new->advisory($adv);
$new->advisory_name($adv_name);
@@ -272,6 +295,25 @@ EOQ
return ($new_eid);
}
+sub erratum_is_clone {
+ my $eid = shift;
+ my $dbh = RHN::DB->connect;
+
+ my $query =<<EOQ;
+SELECT 1
+ FROM dual
+ WHERE EXISTS (SELECT 1 FROM rhnErrataCloned E WHERE E.id = :eid)
+ OR EXISTS (SELECT 1 FROM rhnErrataClonedTmp ET WHERE ET.id = :eid)
+EOQ
+
+ my $sth = $dbh->prepare($query);
+ $sth->execute_h(eid => $eid);
+ my ($exists) = $sth->fetchrow;
+ $sth->finish;
+
+ return ($exists ? 1 : 0);
+}
+
sub advisory_exists {
my $adv = shift;
diff --git a/web/modules/sniglets/Sniglets/ListView/ErrataList.pm b/web/modules/sniglets/Sniglets/ListView/ErrataList.pm
index 98642fb..c9d45f3 100644
--- a/web/modules/sniglets/Sniglets/ListView/ErrataList.pm
+++ b/web/modules/sniglets/Sniglets/ListView/ErrataList.pm
@@ -361,7 +361,7 @@ sub potential_for_cloned_channel_provider {
$row->{OWNED_ERRATA_LIST} = '(none)';
}
- my ($adv, $adv_name) = RHN::DB::ErrataEditor::find_next_advisory($row->{ADVISORY}, $row->{ADVISORY_NAME});
+ my ($adv, $adv_name) = RHN::DB::ErrataEditor::find_next_advisory($row->{ADVISORY}, $row->{ADVISORY_NAME}, $row->{ID});
push(@options, ( { label => "Clone as ${adv_name}",
value => 'clone_new' },
11 years, 11 months
Changes to 'refs/tags/spacewalk-schema-1.8.19-1'
by Michael Mraka
Tag 'spacewalk-schema-1.8.19-1' created by Michael Mraka <michael.mraka(a)redhat.com> at 2012-04-23 15:21 +0000
Tagging package [spacewalk-schema] version [1.8.19-1] in directory [schema/spacewalk/].
Changes since spacewalk-utils-1.8.8-1:
Michael Mraka (3):
811646 - assign number of free slots
upgrade script for free_slots
Automatic commit of package [spacewalk-schema] release [1.8.19-1].
---
rel-eng/packages/spacewalk-schema | 2
schema/spacewalk/postgres/packages/rhn_entitlements.pkb | 5
schema/spacewalk/spacewalk-schema.spec | 5
schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/033-rhn_entitlements.pkb.sql.oracle | 1
schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/033-rhn_entitlements.pkb.sql.postgresql | 254 ++++++++++
5 files changed, 265 insertions(+), 2 deletions(-)
---
11 years, 11 months
rel-eng/packages schema/spacewalk
by Michael Mraka
rel-eng/packages/spacewalk-schema | 2 +-
schema/spacewalk/spacewalk-schema.spec | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)
New commits:
commit eec0cc7feae12100ddccb955c0fba55304747275
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Mon Apr 23 17:21:07 2012 +0200
Automatic commit of package [spacewalk-schema] release [1.8.19-1].
diff --git a/rel-eng/packages/spacewalk-schema b/rel-eng/packages/spacewalk-schema
index 27d830a..be6f408 100644
--- a/rel-eng/packages/spacewalk-schema
+++ b/rel-eng/packages/spacewalk-schema
@@ -1 +1 @@
-1.8.18-1 schema/spacewalk/
+1.8.19-1 schema/spacewalk/
diff --git a/schema/spacewalk/spacewalk-schema.spec b/schema/spacewalk/spacewalk-schema.spec
index 77d5193..08e931e 100644
--- a/schema/spacewalk/spacewalk-schema.spec
+++ b/schema/spacewalk/spacewalk-schema.spec
@@ -2,7 +2,7 @@ Name: spacewalk-schema
Group: Applications/Internet
Summary: Oracle SQL schema for Spacewalk server
-Version: 1.8.18
+Version: 1.8.19
Release: 1%{?dist}
Source0: %{name}-%{version}.tar.gz
@@ -69,6 +69,9 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man1/spacewalk-sql*
%changelog
+* Mon Apr 23 2012 Michael Mraka <michael.mraka(a)redhat.com> 1.8.19-1
+- 811646 - assign number of free slots
+
* Mon Apr 23 2012 Jan Pazdziora 1.8.18-1
- Fixing the schema hardening trigger on rhnPackageEvr.
11 years, 11 months
2 commits - schema/spacewalk
by Michael Mraka
schema/spacewalk/postgres/packages/rhn_entitlements.pkb | 5
schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/033-rhn_entitlements.pkb.sql.oracle | 1
schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/033-rhn_entitlements.pkb.sql.postgresql | 254 ++++++++++
3 files changed, 260 insertions(+)
New commits:
commit 340aae7119793ddfe37691640b73eae2c0ea4dc3
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Mon Apr 23 17:18:55 2012 +0200
upgrade script for free_slots
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/033-rhn_entitlements.pkb.sql.oracle b/schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/033-rhn_entitlements.pkb.sql.oracle
new file mode 100644
index 0000000..cf2393b
--- /dev/null
+++ b/schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/033-rhn_entitlements.pkb.sql.oracle
@@ -0,0 +1 @@
+-- This file has intentionally been left empty.
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/033-rhn_entitlements.pkb.sql.postgresql b/schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/033-rhn_entitlements.pkb.sql.postgresql
new file mode 100644
index 0000000..421f24e
--- /dev/null
+++ b/schema/spacewalk/upgrade/spacewalk-schema-1.7-to-spacewalk-schema-1.8/033-rhn_entitlements.pkb.sql.postgresql
@@ -0,0 +1,254 @@
+-- oracle equivalent source sha1 b04dab2ff31049a8744e5ce1531ccd8b00152bbc
+
+-- setup search_path so that these functions are created in appropriate schema.
+update pg_settings set setting = 'rhn_entitlements,' || setting where name = 'search_path';
+
+
+ -- *******************************************************************
+ -- PROCEDURE: repoll_virt_guest_entitlements
+ --
+ -- Whenever we add/remove a virtualization_host* entitlement from
+ -- a host, we can call this procedure to update what type of slots
+ -- the guests are consuming.
+ --
+ -- If you're removing the entitlement, it's
+ -- possible the guests will become unentitled if you don't have enough
+ -- physical slots to cover them.
+ --
+ -- If you're adding the entitlement, you end up freeing up physical
+ -- slots for other systems.
+ --
+ -- *******************************************************************
+ create or replace function repoll_virt_guest_entitlements(
+ server_id_in in numeric
+ ) returns void
+as $$
+ declare
+ -- All channel families associated with the guests of server_id_in
+ families cursor for
+ select distinct cfs.channel_family_id
+ from
+ rhnChannelFamilyServers cfs,
+ rhnVirtualInstance vi
+ where
+ vi.host_system_id = server_id_in
+ and vi.virtual_system_id = cfs.server_id;
+
+ -- All of server group types associated with the guests of
+ -- server_id_in
+ group_types cursor for
+ select distinct sg.group_type, sgt.label
+ from
+ rhnServerGroupType sgt,
+ rhnServerGroup sg,
+ rhnServerGroupMembers sgm,
+ rhnVirtualInstance vi
+ where
+ vi.host_system_id = server_id_in
+ and vi.virtual_system_id = sgm.server_id
+ and sgm.server_group_id = sg.id
+ and sg.group_type = sgt.id;
+
+ -- Virtual servers from a certain family belonging to a specific
+ -- host that are consuming physical channel slots over the limit.
+ virt_servers_cfam cursor(family_id_in numeric, quantity_in numeric) for
+ select vi.virtual_system_id
+ from
+ rhnChannelFamilyMembers cfm,
+ rhnServerChannel sc,
+ rhnVirtualInstance vi
+ where
+ vi.host_system_id = server_id_in
+ and vi.virtual_system_id = sc.server_id
+ and sc.channel_id = cfm.channel_id
+ and cfm.channel_family_id = family_id_in
+ order by sc.modified desc
+ limit quantity_in;
+
+ -- Virtual servers from a certain family belonging to a specific
+ -- host that are consuming physical system slots over the limit.
+ virt_servers_sgt cursor(group_type_in numeric, quantity_in numeric) for
+ select vi.virtual_system_id
+ from
+ rhnServerGroup sg,
+ rhnServerGroupMembers sgm,
+ rhnVirtualInstance vi
+ where
+ vi.host_system_id = server_id_in
+ and vi.virtual_system_id = sgm.server_id
+ and sgm.server_group_id = sg.id
+ and sg.group_type = group_type_in
+ order by sgm.modified desc
+ limit quantity_in;
+
+ -- Get the orgs of Virtual guests
+ -- Since they may belong to different orgs
+ virt_guest_orgs cursor for
+ select distinct (s.org_id)
+ from rhnServer s
+ inner join rhnVirtualInstance vi on vi.virtual_system_id = s.id
+ where
+ vi.host_system_id = server_id_in
+ and s.org_id <> (select s1.org_id from rhnServer s1 where s1.id = vi.host_system_id) ;
+
+ org_id_val numeric;
+ max_members_val numeric;
+ max_flex_val numeric;
+ current_members_calc numeric;
+ sg_id numeric;
+ is_virt numeric := 0;
+ free_slots numeric := 0;
+ begin
+ select 1 into is_virt
+ from rhnServerEntitlementView
+ where server_id = server_id_in
+ and label in ('virtualization_host', 'virtualization_host_platform');
+
+ if not found then
+ is_virt := 0;
+ end if;
+
+ select org_id
+ into org_id_val
+ from rhnServer
+ where id = server_id_in;
+
+ -- deal w/ channel entitlements first ...
+ for family in families loop
+ if is_virt = 0 then
+ -- if the host_server does not have virt
+ --- find all possible flex slots
+ -- and set each of the flex eligible guests to Y
+ select sfc.max_members - sfc.current_members
+ into free_slots
+ from rhnServerFveCapable sfc
+ where sfc.channel_family_id = family.channel_family_id;
+ UPDATE rhnServerChannel sc set is_fve = 'Y'
+ where sc.server_id in (
+ select vi.virtual_system_id
+ from rhnServerFveCapable sfc
+ inner join rhnVirtualInstance vi on vi.virtual_system_id = sfc.server_id
+ where vi.host_system_id = server_id_in
+ and sfc.channel_family_id = family.channel_family_id
+ order by vi.modified desc
+ limit free_slots
+ );
+ else
+ -- if the host_server has virt
+ -- set all its flex guests to N
+ UPDATE rhnServerChannel sc set is_fve = 'N'
+ where
+ sc.channel_id in (select cfm.channel_id from rhnChannelFamilyMembers cfm
+ where cfm.CHANNEL_FAMILY_ID = family.channel_family_id)
+ and sc.is_fve = 'Y'
+ and sc.server_id in
+ (select vi.virtual_system_id from rhnVirtualInstance vi
+ where vi.host_system_id = server_id_in);
+ end if;
+
+ -- get the current (physical) members of the family
+ current_members_calc :=
+ rhn_channel.channel_family_current_members(family.channel_family_id,
+ org_id_val); -- fixed transposed args
+
+ -- get the max members of the family
+ select max_members
+ into max_members_val
+ from rhnPrivateChannelFamily
+ where channel_family_id = family.channel_family_id
+ and org_id = org_id_val;
+
+ select fve_max_members
+ into max_flex_val
+ from rhnPrivateChannelFamily
+ where channel_family_id = family.channel_family_id
+ and org_id = org_id_val;
+
+ if current_members_calc > max_members_val then
+ -- A virtualization_host* ent must have been removed, so we'll
+ -- unsubscribe guests from the host first.
+
+ -- hm, i don't think max_members - current_members_calc yielding a negative number
+ -- will work w/ rownum, swaping 'em in the body of this if...
+ for virt_server in virt_servers_cfam(family.channel_family_id,
+ current_members_calc - max_members_val) loop
+
+ perform rhn_channel.unsubscribe_server_from_family(
+ virt_server.virtual_system_id,
+ family.channel_family_id);
+ end loop;
+
+ -- if we're still over the limit, which would be odd,
+ -- just prune the group to max_members
+ --
+ -- er... wouldn't we actually have to refresh the values of
+ -- current_members_calc and max_members_val to actually ever
+ -- *skip this??
+ if current_members_calc > max_members_val then
+ -- argh, transposed again?!
+ perform rhn_entitlements.set_family_count(org_id_val,
+ family.channel_family_id,
+ max_members_val, max_flex_val);
+ --TODO calculate this correctly
+ end if;
+
+ end if;
+
+ -- update current_members for the family. This will set the value
+ -- to reflect adding/removing the entitlement.
+ --
+ -- what's the difference of doing this vs the unavoidable set_family_count above?
+ perform rhn_channel.update_family_counts(family.channel_family_id,
+ org_id_val);
+
+ -- It is possible that the guests belong to a different org than the host
+ -- so we are going to update the family counts in the guests orgs also
+ for org in virt_guest_orgs loop
+ perform rhn_channel.update_family_counts(family.channel_family_id,
+ org.org_id);
+ end loop;
+ end loop;
+
+ for a_group_type in group_types loop
+ -- get the current *physical* members of the system entitlement type for the org...
+ --
+ -- unlike channel families, it appears the standard rhnServerGroup.max_members represents
+ -- *physical* slots, vs physical+virt ... boy that's confusing...
+
+ select max_members, id
+ into max_members_val, sg_id
+ from rhnServerGroup
+ where group_type = a_group_type.group_type
+ and org_id = org_id_val;
+
+
+ select count(sep.server_id) into current_members_calc
+ from rhnServerEntitlementPhysical sep
+ where sep.server_group_id = sg_id
+ and sep.server_group_type_id = a_group_type.group_type;
+
+ if current_members_calc > max_members_val then
+ -- A virtualization_host* ent must have been removed, and we're over the limit, so unsubscribe guests
+ for virt_server in virt_servers_sgt(a_group_type.group_type,
+ current_members_calc - max_members_val) loop
+ perform rhn_entitlements.remove_server_entitlement(virt_server.virtual_system_id, a_group_type.label);
+
+ -- decrement current_members_calc, we'll use it to reset current_members for the group at the end...
+ current_members_calc := current_members_calc - 1;
+ end loop;
+
+ end if;
+
+ update rhnServerGroup set current_members = current_members_calc
+ where org_id = org_id_val
+ and group_type = a_group_type.group_type;
+
+ -- I think that's all the house-keeping we have to do...
+ end loop;
+
+ end$$
+language plpgsql;
+
+
+-- restore the original setting
+update pg_settings set setting = overlay( setting placing '' from 1 for (length('rhn_entitlements')+1) ) where name = 'search_path';
commit 391a70b6caf3325e9f9e0c3d9cf9ff705bf4319a
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Apr 19 15:41:44 2012 +0200
811646 - assign number of free slots
fixing
ERROR: column "free_slots" does not exist at character 295
QUERY: UPDATE rhnServerChannel sc set is_fve = 'Y' where sc.server_id in (
select vi.virtual_system_id from rhnServerFveCapable sfc inner join
rhnVirtualInstance vi on vi.virtual_system_id = sfc.server_id where
vi.host_system_id = $1 and sfc.channel_family_id = $2 order by vi.modified
desc limit free_slots )
CONTEXT: PL/pgSQL function "repoll_virt_guest_entitlements" line 96 at SQL
statement
diff --git a/schema/spacewalk/postgres/packages/rhn_entitlements.pkb b/schema/spacewalk/postgres/packages/rhn_entitlements.pkb
index ca87089..2ed168a 100644
--- a/schema/spacewalk/postgres/packages/rhn_entitlements.pkb
+++ b/schema/spacewalk/postgres/packages/rhn_entitlements.pkb
@@ -598,6 +598,7 @@ as $$
current_members_calc numeric;
sg_id numeric;
is_virt numeric := 0;
+ free_slots numeric := 0;
begin
select 1 into is_virt
from rhnServerEntitlementView
@@ -619,6 +620,10 @@ as $$
-- if the host_server does not have virt
--- find all possible flex slots
-- and set each of the flex eligible guests to Y
+ select sfc.max_members - sfc.current_members
+ into free_slots
+ from rhnServerFveCapable sfc
+ where sfc.channel_family_id = family.channel_family_id;
UPDATE rhnServerChannel sc set is_fve = 'Y'
where sc.server_id in (
select vi.virtual_system_id
11 years, 11 months