Changes to 'refs/tags/spacewalk-backend-1.5.10-1'
by Michael Mraka
Tag 'spacewalk-backend-1.5.10-1' created by Michael Mraka <michael.mraka(a)redhat.com> at 2011-04-18 13:03 +0000
Tagging package [spacewalk-backend] version [1.5.10-1] in directory [backend/].
Changes since spacewalk-utils-1.5.1-1:
Michael Mraka (8):
fd's for already seen packages should be also closed
620486 - errata xml caching doesn't work for cloned channels
don't convert ids to strings
postgresql can't order by column alias (PG)
added available_fve_chan_subs to postgresql rhn_channel.pkb
added missing oracle equivalent checksum
schema upgrade scripts for ebb5eddf9ccc9eef287a066804ea38a726303ce2
Automatic commit of package [spacewalk-backend] release [1.5.10-1].
Milan Zazrivec (1):
694735 - export ks files based on ks tree's last_modified
Tomas Lestach (5):
remove duplicate code
removing curr_cfps since it is never used
fixing EditActionTest.testUpdateErrata test
fixing ErrataSearchActionTest.testExecute test
checkstyle fix
---
backend/satellite_tools/disk_dumper/dumper.py | 10
backend/satellite_tools/disk_dumper/iss.py | 4
backend/satellite_tools/reposync.py | 2
backend/satellite_tools/sync_handlers.py | 5
backend/spacewalk-backend.spec | 9
java/code/src/com/redhat/rhn/common/db/datasource/xml/Package_queries.xml | 4
java/code/src/com/redhat/rhn/frontend/action/errata/test/EditActionTest.java | 4
java/code/src/com/redhat/rhn/frontend/action/errata/test/ErrataSearchActionTest.java | 2
java/code/src/com/redhat/rhn/manager/rhnpackage/PackageManager.java | 4
rel-eng/packages/spacewalk-backend | 2
schema/spacewalk/postgres/packages/rhn_channel.pkb | 17
schema/spacewalk/upgrade/spacewalk-schema-1.4-to-spacewalk-schema-1.5/016-rhn_channel.pkb.sql.oracle | 1
schema/spacewalk/upgrade/spacewalk-schema-1.4-to-spacewalk-schema-1.5/016-rhn_channel.pkb.sql.postgresql | 1146 ++++++++++
13 files changed, 1192 insertions(+), 18 deletions(-)
---
13 years, 1 month
Changes to 'refs/tags/spacewalk-schema-1.5.3-1'
by Michael Mraka
Tag 'spacewalk-schema-1.5.3-1' created by Michael Mraka <michael.mraka(a)redhat.com> at 2011-04-18 13:03 +0000
Tagging package [spacewalk-schema] version [1.5.3-1] in directory [schema/spacewalk/].
Changes since spacewalk-backend-1.5.10-1:
Michael Mraka (1):
Automatic commit of package [spacewalk-schema] release [1.5.3-1].
---
rel-eng/packages/spacewalk-schema | 2 +-
schema/spacewalk/spacewalk-schema.spec | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)
---
13 years, 1 month
2 commits - backend/spacewalk-backend.spec rel-eng/packages schema/spacewalk
by Michael Mraka
backend/spacewalk-backend.spec | 9 ++++++++-
rel-eng/packages/spacewalk-backend | 2 +-
rel-eng/packages/spacewalk-schema | 2 +-
schema/spacewalk/spacewalk-schema.spec | 5 ++++-
4 files changed, 14 insertions(+), 4 deletions(-)
New commits:
commit ee118e8b66767413b55ba4360e45d232f1391511
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Mon Apr 18 15:03:34 2011 +0200
Automatic commit of package [spacewalk-schema] release [1.5.3-1].
diff --git a/rel-eng/packages/spacewalk-schema b/rel-eng/packages/spacewalk-schema
index 32a5e1b..8d1e29a 100644
--- a/rel-eng/packages/spacewalk-schema
+++ b/rel-eng/packages/spacewalk-schema
@@ -1 +1 @@
-1.5.2-1 schema/spacewalk/
+1.5.3-1 schema/spacewalk/
diff --git a/schema/spacewalk/spacewalk-schema.spec b/schema/spacewalk/spacewalk-schema.spec
index eea0a0b..24f944e 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.5.2
+Version: 1.5.3
Release: 1%{?dist}
Source0: %{name}-%{version}.tar.gz
@@ -66,6 +66,9 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man1/spacewalk-sql*
%changelog
+* Mon Apr 18 2011 Michael Mraka <michael.mraka(a)redhat.com> 1.5.3-1
+- added available_fve_chan_subs to postgresql rhn_channel.pkb
+
* Mon Apr 18 2011 Jan Pazdziora 1.5.2-1
- Need to have separate schema upgrade for PostgreSQL, we do not process schema
upgrades with chameleon.
commit 435148952e3c1386bba5d0bbd1b9c061af2d67f0
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Mon Apr 18 15:03:22 2011 +0200
Automatic commit of package [spacewalk-backend] release [1.5.10-1].
diff --git a/backend/spacewalk-backend.spec b/backend/spacewalk-backend.spec
index 8d3fbaf..a05d5d5 100644
--- a/backend/spacewalk-backend.spec
+++ b/backend/spacewalk-backend.spec
@@ -11,7 +11,7 @@ Name: spacewalk-backend
Summary: Common programs needed to be installed on the Spacewalk servers/proxies
Group: Applications/Internet
License: GPLv2 and Python
-Version: 1.5.9
+Version: 1.5.10
Release: 1%{?dist}
URL: https://fedorahosted.org/spacewalk
Source0: https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
@@ -679,6 +679,13 @@ rm -f %{rhnconf}/rhnSecret.py*
# $Id$
%changelog
+* Mon Apr 18 2011 Michael Mraka <michael.mraka(a)redhat.com> 1.5.10-1
+- 620486 - errata xml caching doesn't work for cloned channels
+- fd's for already seen packages should be also closed
+- 694735 - export ks files based on ks tree's last_modified
+- removing curr_cfps since it is never used
+- remove duplicate code
+
* Fri Apr 15 2011 Jan Pazdziora 1.5.9-1
- use RPMTAG numbers instead of names. (mc(a)suse.de)
- more weak deps stuff (mc(a)suse.de)
diff --git a/rel-eng/packages/spacewalk-backend b/rel-eng/packages/spacewalk-backend
index f3defcc..0e3dcdd 100644
--- a/rel-eng/packages/spacewalk-backend
+++ b/rel-eng/packages/spacewalk-backend
@@ -1 +1 @@
-1.5.9-1 backend/
+1.5.10-1 backend/
13 years, 1 month
schema/spacewalk
by Michael Mraka
schema/spacewalk/upgrade/spacewalk-schema-1.4-to-spacewalk-schema-1.5/016-rhn_channel.pkb.sql.oracle | 1
schema/spacewalk/upgrade/spacewalk-schema-1.4-to-spacewalk-schema-1.5/016-rhn_channel.pkb.sql.postgresql | 1146 ++++++++++
2 files changed, 1147 insertions(+)
New commits:
commit 5b114d19f0e9ccd96e089ebd57a1a2f22cf2a248
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Mon Apr 18 14:37:48 2011 +0200
schema upgrade scripts for ebb5eddf9ccc9eef287a066804ea38a726303ce2
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-1.4-to-spacewalk-schema-1.5/016-rhn_channel.pkb.sql.oracle b/schema/spacewalk/upgrade/spacewalk-schema-1.4-to-spacewalk-schema-1.5/016-rhn_channel.pkb.sql.oracle
new file mode 100644
index 0000000..b7b00b1
--- /dev/null
+++ b/schema/spacewalk/upgrade/spacewalk-schema-1.4-to-spacewalk-schema-1.5/016-rhn_channel.pkb.sql.oracle
@@ -0,0 +1 @@
+-- This file is intentionally left empty.
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-1.4-to-spacewalk-schema-1.5/016-rhn_channel.pkb.sql.postgresql b/schema/spacewalk/upgrade/spacewalk-schema-1.4-to-spacewalk-schema-1.5/016-rhn_channel.pkb.sql.postgresql
new file mode 100644
index 0000000..c9b769e
--- /dev/null
+++ b/schema/spacewalk/upgrade/spacewalk-schema-1.4-to-spacewalk-schema-1.5/016-rhn_channel.pkb.sql.postgresql
@@ -0,0 +1,1146 @@
+-- oracle equivalent source sha1 b14267384bc104605623a41b755e68e0103b5aa8
+--
+-- This file is not yet in sync with Oracle. Synced functions are:
+-- subscribe_server + all subfunctions
+-- unsubscribe_server + all subfunctions
+--
+-- Copyright (c) 2008--2010 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.
+--
+--
+--
+--
+
+create schema rhn_channel;
+
+--update pg_setting
+update pg_settings set setting = 'rhn_channel,' || setting where name = 'search_path';
+
+ create or replace function server_base_subscriptions(server_id_in NUMERIC)
+ returns boolean as $$
+ begin
+ return exists(SELECT C.id FROM rhnChannel C, rhnServerChannel SC
+ WHERE C.id = SC.channel_id
+ AND SC.server_id = server_id_in
+ AND C.parent_channel IS NULL);
+ end$$ language plpgsql;
+
+ create or replace function check_server_subscription(server_id_in NUMERIC, channel_id_in NUMERIC)
+ returns boolean as $$
+ begin
+ return exists(SELECT channel_id FROM rhnServerChannel WHERE server_id = server_id_in AND channel_id = channel_id_in);
+ end$$ language plpgsql;
+
+ CREATE OR REPLACE FUNCTION get_license_path(channel_id_in IN NUMERIC)
+ RETURNS VARCHAR
+ AS $$
+ declare
+ license_val VARCHAR(1000);
+ BEGIN
+ SELECT CFL.license_path INTO license_val
+ FROM rhnChannelFamilyLicense CFL, rhnChannelFamilyMembers CFM
+ WHERE CFM.channel_id = channel_id_in
+ AND CFM.channel_family_id = CFL.channel_family_id;
+
+ IF NOT FOUND THEN
+ RETURN NULL;
+ END IF;
+
+ RETURN license_val;
+ END$$ language plpgsql;
+
+
+ CREATE OR REPLACE FUNCTION license_consent(channel_id_in IN NUMERIC, user_id_in IN NUMERIC, server_id_in IN NUMERIC) returns void
+ AS $$
+ declare
+ channel_family_id_val NUMERIC;
+ BEGIN
+ channel_family_id_val := rhn_channel.family_for_channel(channel_id_in);
+ IF channel_family_id_val IS NULL
+ THEN
+ perform rhn_exception.raise_exception('channel_subscribe_no_family');
+ END IF;
+
+ IF rhn_channel.get_license_path(channel_id_in) IS NULL
+ THEN
+ perform rhn_exception.raise_exception('channel_consent_no_license');
+ END IF;
+
+ INSERT INTO rhnChannelFamilyLicenseConsent (channel_family_id, user_id, server_id)
+ VALUES (channel_family_id_val, user_id_in, server_id_in);
+ END$$ language plpgsql;
+
+ create or replace function obtain_read_lock(channel_family_id_in in numeric, org_id_in in numeric)
+ returns void as $$
+ declare
+ read_lock date;
+ begin
+ select created into read_lock
+ from rhnPrivateChannelFamily
+ where channel_family_id = channel_family_id_in and org_id = org_id_in
+ for update;
+ end$$ language plpgsql;
+
+ CREATE OR REPLACE FUNCTION subscribe_server(server_id_in IN NUMERIC, channel_id_in NUMERIC, immediate_in NUMERIC default 1, user_id_in in numeric default null, recalcfamily_in NUMERIC default 1) returns void
+ AS $$
+ declare
+ channel_parent_val rhnChannel.parent_channel%TYPE;
+ parent_subscribed BOOLEAN;
+ server_has_base_chan BOOLEAN;
+ server_already_in_chan BOOLEAN;
+ channel_family_id_val NUMERIC;
+ server_org_id_val NUMERIC;
+ available_subscriptions NUMERIC;
+ available_fve_subs numeric;
+ consenting_user NUMERIC;
+ allowed numeric;
+ is_fve_char char(1) := 'N';
+ BEGIN
+ if user_id_in is not null then
+ allowed := rhn_channel.user_role_check(channel_id_in, user_id_in, 'subscribe');
+ else
+ allowed := 1;
+ end if;
+
+ if allowed = 0 then
+ perform rhn_exception.raise_exception('no_subscribe_permissions');
+ end if;
+
+
+ SELECT parent_channel INTO channel_parent_val FROM rhnChannel WHERE id = channel_id_in;
+
+ IF channel_parent_val IS NOT NULL
+ THEN
+ -- child channel; if attempting to cross-subscribe a child to the wrong base, silently ignore
+ parent_subscribed := rhn_channel.check_server_subscription(server_id_in, channel_parent_val);
+
+ IF NOT parent_subscribed
+ THEN
+ RETURN;
+ END IF;
+ ELSE
+ -- base channel
+ server_has_base_chan := rhn_channel.server_base_subscriptions(server_id_in);
+
+ IF server_has_base_chan
+ THEN
+ perform rhn_exception.raise_exception('channel_server_one_base');
+ END IF;
+ END IF;
+
+ server_already_in_chan := rhn_channel.check_server_subscription(server_id_in, channel_id_in);
+
+ IF server_already_in_chan
+ THEN
+ RETURN;
+ END IF;
+
+ channel_family_id_val := rhn_channel.family_for_channel(channel_id_in);
+ IF channel_family_id_val IS NULL
+ THEN
+ perform rhn_exception.raise_exception('channel_subscribe_no_family');
+ END IF;
+
+ --
+ -- Use the org_id of the server only if the org_id of the channel = NULL.
+ -- This is required for subscribing to shared channels.
+ --
+ SELECT COALESCE(org_id, (SELECT org_id FROM rhnServer WHERE id = server_id_in))
+ INTO server_org_id_val
+ FROM rhnChannel
+ WHERE id = channel_id_in;
+
+ begin
+ perform rhn_channel.obtain_read_lock(channel_family_id_val, server_org_id_val);
+ exception
+ when no_data_found then
+ perform rhn_exception.raise_exception('channel_family_no_subscriptions');
+ end;
+
+ available_subscriptions := rhn_channel.available_family_subscriptions(channel_family_id_val, server_org_id_val);
+ available_fve_subs := rhn_channel.available_fve_family_subs(channel_family_id_val, server_org_id_val);
+
+ IF available_subscriptions IS NULL OR
+ available_subscriptions > 0 or
+ rhn_channel.can_server_consume_virt_channl(server_id_in, channel_family_id_val) = 1 OR
+ (available_fve_subs > 0 AND rhn_channel.can_server_consume_fve(server_id_in) = 1)
+ THEN
+ if rhn_channel.can_server_consume_virt_channl(server_id_in, channel_family_id_val) = 0
+ AND available_subscriptions> 0 AND rhn_channel.can_server_consume_fve(server_id_in) = 1 THEN
+ is_fve_char := 'Y';
+ end if;
+
+ insert into rhnServerHistory (id,server_id,summary,details) (
+ select nextval('rhn_event_id_seq'),
+ server_id_in,
+ 'subscribed to channel ' || SUBSTR(c.label, 0, 106),
+ c.label
+ from rhnChannel c
+ where c.id = channel_id_in
+ );
+ UPDATE rhnServer SET channels_changed = current_timestamp WHERE id = server_id_in;
+ INSERT INTO rhnServerChannel (server_id, channel_id, is_fve) VALUES (server_id_in, channel_id_in, is_fve_char);
+ IF recalcfamily_in > 0
+ THEN
+ perform rhn_channel.update_family_counts(channel_family_id_val, server_org_id_val);
+ END IF;
+ perform queue_server(server_id_in, immediate_in);
+ ELSE
+ perform rhn_exception.raise_exception('channel_family_no_subscriptions');
+ END IF;
+
+ END$$ language plpgsql;
+
+ create or replace function can_server_consume_virt_channl(
+ server_id_in in numeric,
+ family_id_in in numeric )
+ returns numeric
+ as $$
+ begin
+ if exists(
+ select 1
+ from
+ rhnChannelFamilyVirtSubLevel cfvsl,
+ rhnSGTypeVirtSubLevel sgtvsl,
+ rhnVirtualInstance vi
+ where
+ vi.virtual_system_id = server_id_in
+ and sgtvsl.virt_sub_level_id = cfvsl.virt_sub_level_id
+ and cfvsl.channel_family_id = family_id_in
+ and exists (
+ select 1
+ from rhnServerEntitlementView sev
+ where vi.host_system_id = sev.server_id
+ and sev.server_group_type_id = sgtvsl.server_group_type_id ))
+ then
+ return 1;
+ else
+ return 0;
+ end if;
+ end$$ language plpgsql;
+
+ create or replace function can_server_consume_fve(server_id_in in numeric) returns numeric
+ as $$
+ declare
+ vi_entries cursor for
+ SELECT 1
+ FROM rhnVirtualInstance vi
+ WHERE vi.virtual_system_id = server_id_in;
+ vi_count numeric;
+
+ begin
+ FOR vi_entry IN VI_ENTRIES LOOP
+ return 1;
+ END LOOP;
+ RETURN 0;
+ end$$ language plpgsql;
+
+ create or replace function guess_server_base(
+ server_id_in in numeric
+ ) RETURNS numeric as $$
+ declare
+ server_cursor cursor for
+ select s.server_arch_id, s.release, s.org_id
+ from rhnServer s
+ where s.id = server_id_in;
+ -- Cursor that fetches all the possible base channels for a
+ -- (server_arch_id, release, org_id) combination
+ base_channel_cursor cursor(
+ release_in varchar,
+ server_arch_id_in numeric,
+ org_id_in numeric
+ ) for
+ select distinct c.*
+ from rhnDistChannelMap dcm,
+ rhnServerChannelArchCompat scac,
+ rhnChannel c,
+ rhnChannelPermissions cp
+ where cp.org_id = org_id_in
+ and cp.channel_id = c.id
+ and c.parent_channel is null
+ and c.id = dcm.channel_id
+ and c.channel_arch_id = dcm.channel_arch_id
+ and dcm.release = release_in
+ and scac.server_arch_id = server_arch_id_in
+ and scac.channel_arch_id = c.channel_arch_id;
+
+ begin
+ for s in server_cursor loop
+ for channel in base_channel_cursor(s.release,
+ s.server_arch_id, s.org_id)
+ loop
+ return channel.id;
+ end loop;
+ end loop;
+ -- Server not found, or no base channel applies to it
+ return null;
+ end$$ language plpgsql;
+
+ -- Private function
+ create or replace function normalize_server_arch(server_arch_in in varchar)
+ returns varchar
+ as $$
+ declare
+ suffix VARCHAR(128) := '-redhat-linux';
+ begin
+ if server_arch_in is NULL then
+ return NULL;
+ end if;
+ if position('-' IN server_arch_in) > 0
+ then
+ -- Suffix already present
+ return server_arch_in;
+ end if;
+ return server_arch_in || suffix;
+ end$$ language plpgsql;
+
+ --
+ -- Raises:
+ -- server_arch_not_found
+ -- no_subscribe_permissions
+ create or replace function base_channel_for_release_arch(
+ release_in in varchar,
+ server_arch_in in varchar,
+ org_id_in in numeric default -1,
+ user_id_in in numeric default null
+ ) returns numeric as $$
+ declare
+ server_arch varchar(256) := rhn_channel.normalize_server_arch(server_arch_in);
+ server_arch_id numeric;
+ begin
+ -- Look up the server arch
+ select id
+ into server_arch_id
+ from rhnServerArch
+ where label = server_arch;
+ if not found then
+ perform rhn_exception.raise_exception('server_arch_not_found');
+ end if;
+
+ return rhn_channel.base_channel_rel_archid(release_in, server_arch_id,
+ org_id_in, user_id_in);
+ end$$ language plpgsql;
+
+ create or replace function base_channel_rel_archid(
+ release_in in varchar,
+ server_arch_id_in in numeric,
+ org_id_in in numeric default -1,
+ user_id_in in numeric default null
+ ) returns numeric as $$
+ declare
+ denied_channel_id numeric := null;
+ valid_org_id numeric := org_id_in;
+ valid_user_id numeric := user_id_in;
+ channel_subscribable numeric;
+ -- Cursor that fetches all the possible base channels for a
+ -- (server_arch_id, release, org_id) combination
+ base_channel_cursor cursor(
+ release_in varchar,
+ server_arch_id_in numeric,
+ org_id_in numeric
+ ) for
+ select distinct c.*
+ from rhnDistChannelMap dcm,
+ rhnServerChannelArchCompat scac,
+ rhnChannel c,
+ rhnChannelPermissions cp
+ where cp.org_id = org_id_in
+ and cp.channel_id = c.id
+ and c.parent_channel is null
+ and c.id = dcm.channel_id
+ and c.channel_arch_id = dcm.channel_arch_id
+ and dcm.release = release_in
+ and scac.server_arch_id = server_arch_id_in
+ and scac.channel_arch_id = c.channel_arch_id;
+
+ begin
+ if org_id_in = -1 and user_id_in is not null then
+ -- Get the org id from the user id
+
+ select org_id
+ into valid_org_id
+ from web_contact
+ where id = user_id_in;
+
+ if not found then
+ -- User doesn't exist
+ -- XXX Only list public stuff for now
+ valid_user_id := null;
+ valid_org_id := -1;
+ end if;
+ end if;
+
+ for c in base_channel_cursor(release_in, server_arch_id_in, valid_org_id)
+ loop
+ -- This row is a possible match
+ if valid_user_id is null then
+ -- User ID not specified, so no user to channel permissions to
+ -- check
+ return c.id;
+ end if;
+
+ -- Check user to channel permissions
+ select rhn_channel.loose_user_role_check(c.id, user_id_in, 'subscribe')
+ into channel_subscribable;
+
+ if channel_subscribable = 1 then
+ return c.id;
+ end if;
+
+ -- Base channel exists, but is not subscribable; keep trying
+ denied_channel_id := c.id;
+ end loop;
+
+ if denied_channel_id is not null then
+ perform rhn_exception.raise_exception('no_subscribe_permissions');
+ end if;
+ -- No base channel applies
+ return NULL;
+ end$$ language plpgsql;
+
+ CREATE OR REPLACE FUNCTION clear_subscriptions(server_id_in IN NUMERIC, deleting_server IN NUMERIC default 0 ) returns void
+ AS $$
+ declare
+ server_channels cursor(server_id_in numeric) for
+ select s.org_id, sc.channel_id, cfm.channel_family_id
+ from rhnServer s,
+ rhnServerChannel sc,
+ rhnChannelFamilyMembers cfm
+ where s.id = server_id_in
+ and s.id = sc.server_id
+ and sc.channel_id = cfm.channel_id;
+ BEGIN
+ for channel in server_channels(server_id_in)
+ loop
+ perform rhn_channel.unsubscribe_server(server_id_in, channel.channel_id, 1, 1, deleting_server);
+ perform rhn_channel.update_family_counts(channel.channel_family_id, channel.org_id);
+ end loop;
+ END$$ language plpgsql;
+
+ CREATE OR REPLACE FUNCTION unsubscribe_server(server_id_in IN NUMERIC, channel_id_in NUMERIC, immediate_in NUMERIC default 1, unsubscribe_children_in numeric default 0,
+ deleting_server in numeric default 0,
+ update_family_countsYN in numeric default 1) returns void
+ AS $$
+ declare
+ channel_family_id_val NUMERIC;
+ server_org_id_val NUMERIC;
+ available_subscriptions NUMERIC;
+ server_already_in_chan BOOLEAN;
+ channel_family_is_proxy cursor(channel_family_id_in numeric) for
+ select 1
+ from rhnChannelFamily
+ where id = channel_family_id_in
+ and label = 'rhn-proxy';
+ channel_family_is_satellite cursor(channel_family_id_in numeric) for
+ select 1
+ from rhnChannelFamily
+ where id = channel_family_id_in
+ and label = 'rhn-satellite';
+ child record;
+ BEGIN
+ -- In PostgreSQL recursion with opened cursors is not allowed so we use
+ -- FOR IN SELECT form which is ok.
+ FOR child IN select c.id
+ from rhnChannel c,
+ rhnServerChannel sc
+ where 1=1
+ and c.parent_channel = channel_id_in
+ and c.id = sc.channel_id
+ and sc.server_id = server_id_in
+ LOOP
+ if unsubscribe_children_in = 1 then
+ perform rhn_channel.unsubscribe_server(server_id_in,
+ child.id,
+ immediate_in,
+ unsubscribe_children_in,
+ deleting_server,
+ update_family_countsYN);
+ else
+ perform rhn_exception.raise_exception('channel_unsubscribe_child_exists');
+ end if;
+ END LOOP;
+
+ server_already_in_chan := rhn_channel.check_server_subscription(server_id_in, channel_id_in);
+
+ IF NOT server_already_in_chan
+ THEN
+ RETURN;
+ END IF;
+
+ if deleting_server = 0 then
+
+ insert into rhnServerHistory (id,server_id,summary,details) (
+ select nextval('rhn_event_id_seq'),
+ server_id_in,
+ 'unsubscribed from channel ' || SUBSTR(c.label, 0, 106),
+ c.label
+ from rhnChannel c
+ where c.id = channel_id_in
+ );
+
+ UPDATE rhnServer SET channels_changed = current_timestamp WHERE id = server_id_in;
+ end if;
+
+ DELETE FROM rhnServerChannel WHERE server_id = server_id_in AND channel_id = channel_id_in;
+
+ if deleting_server = 0 then
+ perform queue_server(server_id_in, immediate_in);
+ end if;
+
+ channel_family_id_val := rhn_channel.family_for_channel(channel_id_in);
+ IF channel_family_id_val IS NULL
+ THEN
+ perform rhn_exception.raise_exception('channel_unsubscribe_no_family');
+ END IF;
+
+ for ignore in channel_family_is_satellite(channel_family_id_val) loop
+ delete from rhnSatelliteInfo where server_id = server_id_in;
+ end loop;
+
+ for ignore in channel_family_is_proxy(channel_family_id_val) loop
+ delete from rhnProxyInfo where server_id = server_id_in;
+ end loop;
+ SELECT org_id INTO server_org_id_val
+ FROM rhnServer
+ WHERE id = server_id_in;
+
+ if update_family_countsYN = 1 then
+ perform rhn_channel.update_family_counts(channel_family_id_val, server_org_id_val);
+ end if;
+ END$$ language plpgsql;
+
+ CREATE OR REPLACE FUNCTION family_for_channel(channel_id_in IN NUMERIC)
+ RETURNS NUMERIC
+ AS $$
+ declare
+ channel_family_id_val NUMERIC;
+ BEGIN
+ SELECT channel_family_id INTO channel_family_id_val
+ FROM rhnChannelFamilyMembers
+ WHERE channel_id = channel_id_in;
+
+ IF NOT FOUND THEN
+ RETURN NULL;
+ END IF;
+
+ RETURN channel_family_id_val;
+ END$$ language plpgsql;
+
+ CREATE OR REPLACE FUNCTION available_family_subscriptions(channel_family_id_in IN NUMERIC, org_id_in IN NUMERIC)
+ RETURNS NUMERIC
+ AS $$
+ declare
+ cfp record;
+ current_members_val NUMERIC;
+ max_members_val NUMERIC;
+ found NUMERIC;
+ BEGIN
+ for cfp in SELECT * FROM rhnOrgChannelFamilyPermissions
+ WHERE channel_family_id = channel_family_id_in
+ AND org_id = org_id_in
+ LOOP
+ found := 1;
+ current_members_val := cfp.current_members;
+ max_members_val := cfp.max_members;
+ END LOOP;
+
+ -- not found: either the channel fam doesn't have an entry in cfp, or the org doesn't have access to it.
+ -- either way, there are no available subscriptions
+
+ IF found IS NULL
+ THEN
+ RETURN 0;
+ END IF;
+
+ -- null max members? in that case, pass it on; NULL means infinite
+ IF max_members_val IS NULL
+ THEN
+ RETURN NULL;
+ END IF;
+
+ -- otherwise, return the delta
+ RETURN max_members_val - current_members_val;
+ END$$ language plpgsql;
+
+ CREATE OR REPLACE FUNCTION available_fve_family_subs(channel_family_id_in IN NUMERIC, org_id_in IN NUMERIC)
+ RETURNS NUMERIC
+ AS $$
+ declare
+ cfp record;
+ fve_current_members_val NUMERIC;
+ fve_max_members_val NUMERIC;
+ found NUMERIC;
+ BEGIN
+ for cfp in SELECT * FROM rhnOrgChannelFamilyPermissions
+ WHERE channel_family_id = channel_family_id_in
+ AND org_id = org_id_in
+ LOOP
+ found := 1;
+ fve_current_members_val := cfp.fve_current_members;
+ fve_max_members_val := cfp.fve_max_members;
+ END LOOP;
+
+ -- not found: either the channel fam doesn't have an entry in cfp, or the org doesn't have access to it.
+ -- either way, there are no available subscriptions
+
+ IF found IS NULL
+ THEN
+ RETURN 0;
+ END IF;
+
+ -- null max members? in that case, pass it on; NULL means infinite
+ IF fve_max_members_val IS NULL
+ THEN
+ RETURN NULL;
+ END IF;
+
+ -- otherwise, return the delta
+ RETURN fve_max_members_val - fve_current_members_val;
+ END$$ language plpgsql;
+
+ -- *******************************************************************
+ -- FUNCTION: channel_family_current_members
+ -- Calculates and returns the actual count of systems consuming
+ -- physical channel subscriptions.
+ -- Called by: update_family_counts
+ -- rhn_entitlements.repoll_virt_guest_entitlements
+ -- *******************************************************************
+ create or replace function channel_family_current_members(channel_family_id_in IN NUMERIC,
+ org_id_in IN NUMERIC)
+ returns numeric
+ as $$
+ declare
+ current_members_count numeric := 0;
+ begin
+ select count(distinct sc.server_id)
+ into current_members_count
+ from rhnChannelFamilyMembers cfm,
+ rhnServerChannel sc,
+ rhnServer s
+ where s.org_id = org_id_in
+ and s.id = sc.server_id
+ and cfm.channel_family_id = channel_family_id_in
+ and cfm.channel_id = sc.channel_id
+ and exists (
+ select 1
+ from rhnChannelFamilyServerPhysical cfsp
+ where cfsp.CHANNEL_FAMILY_ID = channel_family_id_in
+ and cfsp.server_id = s.id
+ );
+
+ return current_members_count;
+ end$$ language plpgsql;
+
+ CREATE OR REPLACE FUNCTION update_family_counts(channel_family_id_in IN NUMERIC,
+ org_id_in IN NUMERIC) returns void
+ AS $$
+ BEGIN
+ update rhnPrivateChannelFamily
+ set current_members =
+ rhn_channel.channel_family_current_members(channel_family_id_in, org_id_in)
+ where org_id = org_id_in
+ and channel_family_id = channel_family_id_in;
+ END$$ language plpgsql;
+
+ CREATE OR REPLACE FUNCTION available_chan_subscriptions(channel_id_in IN NUMERIC,
+ org_id_in IN NUMERIC)
+ RETURNS NUMERIC
+ AS $$
+ declare
+ channel_family_id_val NUMERIC;
+ BEGIN
+ SELECT channel_family_id INTO STRICT channel_family_id_val
+ FROM rhnChannelFamilyMembers
+ WHERE channel_id = channel_id_in;
+
+ RETURN rhn_channel.available_family_subscriptions(
+ channel_family_id_val, org_id_in);
+ END$$ language plpgsql;
+
+ CREATE OR REPLACE FUNCTION available_fve_chan_subs(channel_id_in IN NUMERIC,
+ org_id_in IN NUMERIC)
+ RETURNS NUMERIC
+ AS $$
+ declare
+ channel_family_id_val NUMERIC;
+ BEGIN
+ SELECT channel_family_id INTO STRICT channel_family_id_val
+ FROM rhnChannelFamilyMembers
+ WHERE channel_id = channel_id_in;
+
+ RETURN rhn_channel.available_fve_family_subs(
+ channel_family_id_val, org_id_in);
+ END$$ language plpgsql;
+
+ create or replace function unsubscribe_server_from_family(server_id_in in numeric,
+ channel_family_id_in in numeric)
+ returns void
+ as $$
+ begin
+ delete
+ from rhnServerChannel rsc
+ where rsc.server_id = server_id_in
+ and channel_id in (
+ select rcfm.channel_id
+ from rhnChannelFamilyMembers rcfm
+ where rcfm.channel_family_id = channel_family_id_in);
+ end$$ language plpgsql;
+
+ create or replace function get_org_id(channel_id_in in numeric)
+ returns numeric
+ as $$
+ declare
+ org_id_out numeric;
+ begin
+ select org_id into strict org_id_out
+ from rhnChannel
+ where id = channel_id_in;
+
+ return org_id_out;
+ end$$ language plpgsql;
+
+ create or replace function get_cfam_org_access(cfam_id_in in numeric, org_id_in in numeric)
+ returns numeric
+ as $$
+ begin
+ if exists(
+ select 1
+ from rhnOrgChannelFamilyPermissions cfp
+ where cfp.org_id = org_id_in
+ ) then
+ return 1;
+ else
+ return 0;
+ end if;
+ end$$ language plpgsql;
+
+ create or replace function get_org_access(channel_id_in in numeric, org_id_in in numeric)
+ returns integer
+ as $$
+ begin
+ -- the idea: if we get past this query,
+ -- the org has access to the channel, else not
+ if exists(
+ select 1
+ from rhnChannelFamilyMembers CFM,
+ rhnOrgChannelFamilyPermissions CFP
+ where cfp.org_id = org_id_in
+ and CFM.channel_family_id = CFP.channel_family_id
+ and CFM.channel_id = channel_id_in
+ and (CFP.max_members > 0 or CFP.max_members is null or CFP.org_id = 1) )
+ then
+ return 1;
+ else
+ return 0;
+ end if;
+ end$$ language plpgsql;
+
+ -- check if a user has a given role, or if such a role is inferrable
+ create or replace function user_role_check_debug(channel_id_in in numeric,
+ user_id_in in numeric,
+ role_in in varchar,
+ status out numeric,
+ reason_out out varchar)
+ as $$
+ declare
+ org_id numeric;
+ begin
+ org_id := rhn_user.get_org_id(user_id_in);
+
+ -- channel might be shared
+ if role_in = 'subscribe' and
+ rhn_channel.shared_user_role_check(channel_id_in, user_id_in, role_in) = 1 then
+ status := 1;
+ return;
+ end if;
+
+ if role_in = 'manage' and
+ COALESCE(rhn_channel.get_org_id(channel_id_in), -1) <> org_id then
+ reason_out := 'channel_not_owned';
+ status := 0;
+ return;
+ end if;
+
+ if role_in = 'subscribe' and
+ rhn_channel.get_org_access(channel_id_in, org_id) = 0 then
+ reason_out := 'channel_not_available';
+ status := 0;
+ return;
+ end if;
+
+ -- channel admins have all roles
+ if rhn_user.check_role_implied(user_id_in, 'channel_admin') = 1 then
+ reason_out := 'channel_admin';
+ status := 1;
+ return;
+ end if;
+
+ -- the subscribe permission is inferred
+ -- UNLESS the not_globally_subscribable flag is set
+ if role_in = 'subscribe'
+ then
+ if rhn_channel.org_channel_setting(channel_id_in,
+ org_id,
+ 'not_globally_subscribable') = 0 then
+ reason_out := 'globally_subscribable';
+ status := 1;
+ return;
+ end if;
+ end if;
+
+ -- all other roles (manage right now) are explicitly granted
+ reason_out := 'direct_permission';
+ status := rhn_channel.direct_user_role_check(channel_id_in,
+ user_id_in, role_in);
+ return;
+ end$$ language plpgsql;
+
+ -- same as above, but with no OUT param; useful in views, etc
+ create or replace function user_role_check(channel_id_in in numeric, user_id_in in numeric, role_in in varchar)
+ returns numeric
+ as $$
+ declare
+ throwaway record;
+ begin
+ throwaway := rhn_channel.user_role_check_debug(channel_id_in, user_id_in, role_in);
+ return throwaway.status;
+ end$$ language plpgsql;
+
+ --
+ -- For multiorg phase II, this function simply checks to see if the user's
+ -- has a trust relationship that includes this channel by id.
+ --
+ create or replace function shared_user_role_check(channel_id in numeric, user_id in numeric, role in varchar)
+ returns numeric
+ as $$
+ declare
+ n numeric;
+ oid numeric;
+ begin
+ oid := rhn_user.get_org_id(user_id);
+ select 1 into n
+ from rhnSharedChannelView s
+ where s.id = channel_id and s.org_trust_id = oid;
+
+ if not found then
+ return 0;
+ end if;
+
+ return 1;
+ end$$ language plpgsql;
+
+ -- same as above, but returns 1 if user_id_in is null
+ -- This is useful in queries where user_id is not specified
+ create or replace function loose_user_role_check(channel_id_in in numeric, user_id_in in numeric, role_in in varchar)
+ returns numeric
+ as $$
+ begin
+ if user_id_in is null then
+ return 1;
+ end if;
+ return rhn_channel.user_role_check(channel_id_in, user_id_in, role_in);
+ end$$ language plpgsql;
+
+ -- directly checks the table, no inferred permissions
+ create or replace function direct_user_role_check(channel_id_in in numeric, user_id_in in numeric, role_in in varchar)
+ returns numeric
+ as $$
+ declare
+ throwaway numeric;
+ begin
+ -- the idea: if we get past this query, the user has the role, else no
+ select 1 into throwaway
+ from rhnChannelPermissionRole CPR,
+ rhnChannelPermission CP
+ where CP.user_id = user_id_in
+ and CP.channel_id = channel_id_in
+ and CPR.label = role_in
+ and CP.role_id = CPR.id;
+
+ if not found then
+ return 0;
+ end if;
+
+ return 1;
+ end$$ language plpgsql;
+
+ -- check if an org has a certain setting
+ create or replace function org_channel_setting(channel_id_in in numeric, org_id_in in numeric, setting_in in varchar)
+ returns numeric
+ as $$
+ declare
+ throwaway numeric;
+ begin
+ -- the idea: if we get past this query, the org has the setting
+ select 1 into throwaway
+ from rhnOrgChannelSettingsType OCST,
+ rhnOrgChannelSettings OCS
+ where OCS.org_id = org_id_in
+ and OCS.channel_id = channel_id_in
+ and OCST.label = setting_in
+ and OCS.setting_id = OCST.id;
+
+ if not found then
+ return 0;
+ end if;
+
+ return 1;
+ end$$ language plpgsql;
+
+ CREATE OR REPLACE FUNCTION channel_priority(channel_id_in IN numeric)
+ RETURNS numeric
+ AS $$
+ declare
+ channel_name varchar(256);
+ priority numeric;
+ end_of_life_val timestamptz;
+ org_id_val numeric;
+ BEGIN
+
+ select name, end_of_life, org_id
+ into channel_name, end_of_life_val, org_id_val
+ from rhnChannel
+ where id = channel_id_in;
+
+ if end_of_life_val is not null then
+ return -400;
+ end if;
+
+ if channel_name like 'Red Hat Enterprise Linux%' or channel_name like 'RHEL%' then
+ priority := 1000;
+ if channel_name not like '%Beta%' then
+ priority := priority + 1000;
+ end if;
+
+ priority := priority +
+ case
+ when channel_name like '%v. 5%' then 600
+ when channel_name like '%v. 4%' then 500
+ when channel_name like '%v. 3%' then 400
+ when channel_name like '%v. 2%' then 300
+ when channel_name like '%v. 1%' then 200
+ else 0
+ end;
+
+ priority := priority +
+ case
+ when channel_name like 'Red Hat Enterprise Linux (v. 5%' then 60
+ when (channel_name like '%AS%' and channel_name not like '%Extras%') then 50
+ when (channel_name like '%ES%' and channel_name not like '%Extras%') then 40
+ when (channel_name like '%WS%' and channel_name not like '%Extras%') then 30
+ when (channel_name like '%Desktop%' and channel_name not like '%Extras%') then 20
+ when channel_name like '%Extras%' then 10
+ else 0
+ end;
+
+ priority := priority +
+ case
+ when channel_name like '%)' then 5
+ else 0
+ end;
+
+ priority := priority +
+ case
+ when channel_name like '%32-bit x86%' then 4
+ when channel_name like '%64-bit Intel Itanium%' then 3
+ when channel_name like '%64-bit AMD64/Intel EM64T%' then 2
+ else 0
+ end;
+ elsif channel_name like 'Red Hat Desktop%' then
+ priority := 900;
+
+ if channel_name not like '%Beta%' then
+ priority := priority + 50;
+ end if;
+
+ priority := priority +
+ case
+ when channel_name like '%v. 4%' then 40
+ when channel_name like '%v. 3%' then 30
+ when channel_name like '%v. 2%' then 20
+ when channel_name like '%v. 1%' then 10
+ else 0
+ end;
+
+ priority := priority +
+ case
+ when channel_name like '%32-bit x86%' then 4
+ when channel_name like '%64-bit Intel Itanium%' then 3
+ when channel_name like '%64-bit AMD64/Intel EM64T%' then 2
+ else 0
+ end;
+
+ elsif org_id_val is not null then
+ priority := 600;
+ else
+ priority := 500;
+ end if;
+
+ return -priority;
+
+ end$$ language plpgsql;
+
+ -- right now this only does the accounting changes; the cascade
+ -- actually does the rhnServerChannel delete.
+ create or replace function delete_server_channels(server_id_in in numeric) returns void
+ as $$
+ begin
+ update rhnPrivateChannelFamily
+ set current_members = current_members -1
+ where org_id in (
+ select org_id
+ from rhnServer
+ where id = server_id_in
+ )
+ and channel_family_id in (
+ select rcfm.channel_family_id
+ from rhnChannelFamilyMembers rcfm,
+ rhnServerChannel rsc
+ where rsc.server_id = server_id_in
+ and rsc.channel_id = rcfm.channel_id
+ and not exists (
+ select 1
+ from
+ rhnChannelFamilyVirtSubLevel cfvsl,
+ rhnSGTypeVirtSubLevel sgtvsl,
+ rhnServerEntitlementView sev,
+ rhnVirtualInstance vi
+ where
+ -- system is a virtual instance
+ vi.virtual_system_id = server_id_in
+ and vi.host_system_id = sev.server_id
+ -- system's host has a virt ent
+ and sev.label in ('virtualization_host',
+ 'virtualization_host_platform')
+ and sev.server_group_type_id =
+ sgtvsl.server_group_type_id
+ -- the host's virt ent grants a cf virt sub level
+ and sgtvsl.virt_sub_level_id = cfvsl.virt_sub_level_id
+ -- the cf is in that virt sub level
+ and cfvsl.channel_family_id = rcfm.channel_family_id
+ )
+ );
+ end$$ language plpgsql;
+
+ -- this could certainly be optimized to do updates if needs be
+ create or replace function refresh_newest_package(channel_id_in in numeric, caller_in in varchar default '(unknown)') returns void
+ as $$
+ begin
+ delete from rhnChannelNewestPackage where channel_id = channel_id_in;
+ insert into rhnChannelNewestPackage
+ ( channel_id, name_id, evr_id, package_id, package_arch_id )
+ ( select channel_id,
+ name_id, evr_id,
+ package_id, package_arch_id
+ from rhnChannelNewestPackageView
+ where channel_id = channel_id_in
+ );
+ insert into rhnChannelNewestPackageAudit (channel_id, caller)
+ values (channel_id_in, caller_in);
+ update rhnChannel
+ set last_modified = greatest(current_timestamp, last_modified + interval '1 second')
+ where id = channel_id_in;
+ end$$ language plpgsql;
+
+ create or replace function update_channel ( channel_id_in in numeric, invalidate_ss in numeric default 0,
+ date_to_use in timestamptz default current_timestamp ) returns void
+ as $$
+ declare
+ channel_last_modified timestamptz;
+ last_modified_value timestamptz;
+
+ snapshots cursor for
+ select snapshot_id id
+ from rhnSnapshotChannel
+ where channel_id = channel_id_in;
+
+ begin
+
+ select last_modified
+ into channel_last_modified
+ from rhnChannel
+ where id = channel_id_in;
+
+ last_modified_value := date_to_use;
+
+ if last_modified_value <= channel_last_modified then
+ last_modified_value := last_modified_value + interval '1 second';
+ end if;
+
+ update rhnChannel set last_modified = last_modified_value
+ where id = channel_id_in;
+
+ if invalidate_ss = 1 then
+ for snapshot in snapshots loop
+ update rhnSnapshot
+ set invalid = lookup_snapshot_invalid_reason('channel_modified')
+ where id = snapshot.id;
+ end loop;
+ end if;
+
+ end$$ language plpgsql;
+
+ create or replace function update_channels_by_package ( package_id_in in numeric, date_to_use in timestamptz default current_timestamp ) returns void
+ as $$
+ declare
+ channels cursor for
+ select channel_id
+ from rhnChannelPackage
+ where package_id = package_id_in
+ order by channel_id;
+
+ begin
+ for channel in channels loop
+ -- we want to invalidate the snapshot assocated with the channel when we
+ -- do this b/c we know we've added or removed or packages
+ perform rhn_channel.update_channel ( channel.channel_id, 1, date_to_use );
+ end loop;
+ end$$ language plpgsql;
+
+
+ create or replace function update_channels_by_errata ( errata_id_in numeric, date_to_use in timestamptz default current_timestamp ) returns void
+ as $$
+ declare
+ channels cursor for
+ select channel_id
+ from rhnChannelErrata
+ where errata_id = errata_id_in
+ order by channel_id;
+
+ begin
+ for channel in channels loop
+ -- we won't invalidate snapshots, b/c just changing the errata associated with
+ -- a channel shouldn't invalidate snapshots
+ perform rhn_channel.update_channel ( channel.channel_id, 0, date_to_use );
+ end loop;
+ end$$ language plpgsql;
+
+ create or replace function update_needed_cache(channel_id_in in numeric) returns void
+ as $$
+ declare
+ server record;
+ begin
+ -- we intentionaly do a loop here instead of one huge select
+ -- b/c we want to break update into smaller transaction to unblock other sessions
+ -- querying rhnServerNeededCache
+ for server in (
+ select sc.server_id as id
+ from rhnServerChannel sc
+ where sc.channel_id = channel_id_in
+ ) loop
+ perform rhn_server.update_needed_cache(server.id);
+ end loop;
+ end$$ language plpgsql;
+
+-- restore the original setting
+update pg_settings set setting = overlay( setting placing '' from 1 for (length('rhn_channel')+1) ) where name = 'search_path';
13 years, 1 month
2 commits - schema/spacewalk
by Michael Mraka
schema/spacewalk/postgres/packages/rhn_channel.pkb | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
New commits:
commit d3cae83be59cd4d98284a635d1175a9b4f648fe3
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Mon Apr 18 14:26:14 2011 +0200
added missing oracle equivalent checksum
diff --git a/schema/spacewalk/postgres/packages/rhn_channel.pkb b/schema/spacewalk/postgres/packages/rhn_channel.pkb
index 88a7001..ab6deba 100644
--- a/schema/spacewalk/postgres/packages/rhn_channel.pkb
+++ b/schema/spacewalk/postgres/packages/rhn_channel.pkb
@@ -1,3 +1,5 @@
+-- oracle equivalent source sha1 57ec75b0aacf78d2bba70e5ad4158bccacccf265
+--
-- This file is not yet in sync with Oracle. Synced functions are:
-- subscribe_server + all subfunctions
-- unsubscribe_server + all subfunctions
commit 3e489582281026de187037eb24fac449f00b000e
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Mon Apr 18 14:16:41 2011 +0200
added available_fve_chan_subs to postgresql rhn_channel.pkb
fixing
ERROR: function rhn_channel.available_fve_chan_subs(bigint, bigint) does not exist at character 8
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
STATEMENT: select rhn_channel.available_fve_chan_subs($1, $2) as entitlements from dual
diff --git a/schema/spacewalk/postgres/packages/rhn_channel.pkb b/schema/spacewalk/postgres/packages/rhn_channel.pkb
index 19c32e6..88a7001 100644
--- a/schema/spacewalk/postgres/packages/rhn_channel.pkb
+++ b/schema/spacewalk/postgres/packages/rhn_channel.pkb
@@ -665,6 +665,21 @@ update pg_settings set setting = 'rhn_channel,' || setting where name = 'search_
channel_family_id_val, org_id_in);
END$$ language plpgsql;
+ CREATE OR REPLACE FUNCTION available_fve_chan_subs(channel_id_in IN NUMERIC,
+ org_id_in IN NUMERIC)
+ RETURNS NUMERIC
+ AS $$
+ declare
+ channel_family_id_val NUMERIC;
+ BEGIN
+ SELECT channel_family_id INTO STRICT channel_family_id_val
+ FROM rhnChannelFamilyMembers
+ WHERE channel_id = channel_id_in;
+
+ RETURN rhn_channel.available_fve_family_subs(
+ channel_family_id_val, org_id_in);
+ END$$ language plpgsql;
+
create or replace function unsubscribe_server_from_family(server_id_in in numeric,
channel_family_id_in in numeric)
returns void
13 years, 1 month
4 commits - backend/satellite_tools java/code
by Michael Mraka
backend/satellite_tools/disk_dumper/dumper.py | 10 ++++++----
backend/satellite_tools/reposync.py | 2 +-
java/code/src/com/redhat/rhn/common/db/datasource/xml/Package_queries.xml | 4 ++--
java/code/src/com/redhat/rhn/manager/rhnpackage/PackageManager.java | 4 ++--
4 files changed, 11 insertions(+), 9 deletions(-)
New commits:
commit 97efa47f9c7e716ab51d3772b98f80d06247fdae
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri Apr 15 15:30:38 2011 +0200
postgresql can't order by column alias (PG)
fixing
ERROR: column "package_nvre" does not exist at character 459
STATEMENT: SELECT P.id AS ID,
PN.name || '-' || evr_t_as_vre_simple(PE.evr) AS PACKAGE_NVRE,
...
ORDER BY UPPER(PACKAGE_NVRE)
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Package_queries.xml b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Package_queries.xml
index c935503..a3f9ee6 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Package_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Package_queries.xml
@@ -582,7 +582,7 @@ SELECT P.id AS ID,
FROM rhnErrataPackage EP
WHERE EP.errata_id = :target_eid
AND EP.package_id = P.id)
-ORDER BY UPPER(PACKAGE_NVRE)
+ORDER BY UPPER(PN.name || '-' || evr_t_as_vre_simple(PE.evr))
</query>
<elaborator name="package_channels" />
</mode>
@@ -602,7 +602,7 @@ SELECT P.id AS ID,
FROM rhnErrataPackagetmp EP
WHERE EP.errata_id = :target_eid
AND EP.package_id = P.id)
-ORDER BY UPPER(PACKAGE_NVRE)
+ORDER BY UPPER(PN.name || '-' || evr_t_as_vre_simple(PE.evr))
</query>
<elaborator name="package_channels" />
</mode>
commit 68da0cae6c15d0676275f90ba69cfd7d00bf7ce8
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri Apr 15 14:35:06 2011 +0200
don't convert ids to strings
fixing
ERROR: operator does not exist: numeric = character varying at character 214
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
STATEMENT: SELECT P.id AS ID,
PN.name || '-' || evr_t_as_vre_simple(PE.evr) AS PACKAGE_NVRE,
P.summary
...
diff --git a/java/code/src/com/redhat/rhn/manager/rhnpackage/PackageManager.java b/java/code/src/com/redhat/rhn/manager/rhnpackage/PackageManager.java
index fa1f5b1..ab18c79 100644
--- a/java/code/src/com/redhat/rhn/manager/rhnpackage/PackageManager.java
+++ b/java/code/src/com/redhat/rhn/manager/rhnpackage/PackageManager.java
@@ -344,8 +344,8 @@ public class PackageManager extends BaseManager {
//Setup params and execute query
SelectMode m = ModeFactory.getMode("Package_queries", mode);
Map params = new HashMap();
- params.put("target_eid", errata.getId().toString());
- params.put("source_cid", cid.toString());
+ params.put("target_eid", errata.getId());
+ params.put("source_cid", cid);
Map elabParams = new HashMap();
elabParams.put("org_id", user.getOrg().getId());
commit 2989f2487a80ba2aeca1953e280671200d36e6e5
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri Apr 15 14:22:39 2011 +0200
620486 - errata xml caching doesn't work for cloned channels
diff --git a/backend/satellite_tools/disk_dumper/dumper.py b/backend/satellite_tools/disk_dumper/dumper.py
index 0e1b1bb..a7eaeea 100644
--- a/backend/satellite_tools/disk_dumper/dumper.py
+++ b/backend/satellite_tools/disk_dumper/dumper.py
@@ -817,7 +817,7 @@ class SourcePackagesDumper(CachedDumper, exportLib.SourcePackagesDumper):
hash_factor = 2
key_template = 'xml-packages/%s/rhn-source-package-%s.xml'
-class ErrataDumper(CachedDumper, exportLib.ErrataDumper):
+class ErrataDumper(exportLib.ErrataDumper):
iterator_query = rhnSQL.Statement("""
select
e.id,
@@ -840,9 +840,11 @@ class ErrataDumper(CachedDumper, exportLib.ErrataDumper):
from rhnErrata e
where e.id = :errata_id
""")
- item_id_key = 'errata_id'
- hash_factor = 1
- key_template = 'xml-errata/%s/rhn-erratum-%s.xml'
+ def __init__(self, writer, params):
+ statement = rhnSQL.prepare(self.iterator_query)
+ iterator = QueryIterator(statement, params)
+ exportLib.ErrataDumper.__init__(self, writer, iterator)
+
class KickstartableTreesDumper(CachedDumper, exportLib.KickstartableTreesDumper):
iterator_query = rhnSQL.Statement("""
commit 1a32855f75d1e2936b7feed2072506e8a4233562
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Apr 13 15:47:21 2011 +0200
fd's for already seen packages should be also closed
diff --git a/backend/satellite_tools/reposync.py b/backend/satellite_tools/reposync.py
index 00d0aa6..7094213 100644
--- a/backend/satellite_tools/reposync.py
+++ b/backend/satellite_tools/reposync.py
@@ -358,6 +358,7 @@ class RepoSync:
if to_download:
self.upload_package(pack)
finally_remove(localpath)
+ pack.payload_stream.close()
if to_link:
self.associate_package(pack)
except KeyboardInterrupt:
@@ -386,7 +387,6 @@ class RepoSync:
header_start=package.header_start, header_end=package.header_end,
relative_path=rel_package_path,
org_id=self.channel['org_id'])
- package.payload_stream.close()
def associate_package(self, pack):
caller = "server.app.yumreposync"
13 years, 1 month
backend/satellite_tools
by Milan Zazrivec
backend/satellite_tools/disk_dumper/iss.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit c5bcfcc658c69df7005772c424dfb0f7cd82b365
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Mon Apr 18 11:46:15 2011 +0200
694735 - export ks files based on ks tree's last_modified
diff --git a/backend/satellite_tools/disk_dumper/iss.py b/backend/satellite_tools/disk_dumper/iss.py
index 2eef195..3240204 100644
--- a/backend/satellite_tools/disk_dumper/iss.py
+++ b/backend/satellite_tools/disk_dumper/iss.py
@@ -447,8 +447,8 @@ class Dumper(dumper.XML_Dumper):
"""
if self.start_date:
query += """
- and rkt.modified >= TO_DATE(:start_date, 'YYYYMMDDHH24MISS')
- and rkt.modified <= TO_DATE(:end_date, 'YYYYMMDDHH24MISS')
+ and rkt.last_modified >= TO_DATE(:start_date, 'YYYYMMDDHH24MISS')
+ and rkt.last_modified <= TO_DATE(:end_date, 'YYYYMMDDHH24MISS')
"""
self.kickstart_files_query = rhnSQL.Statement(query)
kickstart_files = rhnSQL.prepare(self.kickstart_files_query)
13 years, 1 month
java/code
by Tomas Lestach
java/code/src/com/redhat/rhn/frontend/action/errata/test/EditActionTest.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
New commits:
commit 02ef1472f6ad1bb4b8718c7e968bd8f32dc6bd07
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Mon Apr 18 10:59:48 2011 +0200
checkstyle fix
addressing: Line is longer than 92 characters.
diff --git a/java/code/src/com/redhat/rhn/frontend/action/errata/test/EditActionTest.java b/java/code/src/com/redhat/rhn/frontend/action/errata/test/EditActionTest.java
index 1bc9082..bd865dc 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/errata/test/EditActionTest.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/errata/test/EditActionTest.java
@@ -121,7 +121,8 @@ public class EditActionTest extends RhnBaseTestCase {
request.setupGetParameterMap(params);
request.setupAddParameter("buglistIdNew", "123");
request.setupAddParameter("buglistSummaryNew", "test bug for a test errata");
- request.setupAddParameter("buglistUrlNew", "https://bugzilla.redhat.com/show_bug.cgi?id=123");
+ request.setupAddParameter("buglistUrlNew",
+ "https://bugzilla.redhat.com/show_bug.cgi?id=123");
result = action.update(mapping, form, request, response);
assertEquals("default", result.getName());
13 years, 1 month
4 commits - backend/satellite_tools java/code
by Tomas Lestach
backend/satellite_tools/sync_handlers.py | 5 -----
java/code/src/com/redhat/rhn/frontend/action/errata/test/EditActionTest.java | 3 +++
java/code/src/com/redhat/rhn/frontend/action/errata/test/ErrataSearchActionTest.java | 2 ++
3 files changed, 5 insertions(+), 5 deletions(-)
New commits:
commit aa57ccdbd99238d22f4b8777f819486a01122b08
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Mon Apr 18 10:41:29 2011 +0200
fixing ErrataSearchActionTest.testExecute test
addressing: parameters does not contain fineGrained
diff --git a/java/code/src/com/redhat/rhn/frontend/action/errata/test/ErrataSearchActionTest.java b/java/code/src/com/redhat/rhn/frontend/action/errata/test/ErrataSearchActionTest.java
index 9ce09c6..29220d1 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/errata/test/ErrataSearchActionTest.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/errata/test/ErrataSearchActionTest.java
@@ -49,6 +49,8 @@ public class ErrataSearchActionTest extends RhnBaseTestCase {
ah.getRequest().setupAddParameter("search_string", name);
ah.getRequest().setupAddParameter("view_mode", "errata_search_by_advisory");
ah.getRequest().setupAddParameter("view_mode", "errata_search_by_advisory");
+ ah.getRequest().setupAddParameter("fineGrained", "on");
+ ah.getRequest().setupAddParameter("fineGrained", "on");
// I *HATE* Mockobjects
Map paramnames = new HashMap();
commit 4aae301579983cb3d686906c92a8913e59328c66
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Mon Apr 18 10:36:51 2011 +0200
fixing EditActionTest.testUpdateErrata test
adressing: parameters does not contain buglistUrlNew
diff --git a/java/code/src/com/redhat/rhn/frontend/action/errata/test/EditActionTest.java b/java/code/src/com/redhat/rhn/frontend/action/errata/test/EditActionTest.java
index 2658cac..1bc9082 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/errata/test/EditActionTest.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/errata/test/EditActionTest.java
@@ -110,15 +110,18 @@ public class EditActionTest extends RhnBaseTestCase {
//add a bug
form.set("buglistIdNew", "123");
form.set("buglistSummaryNew", "test bug for a test errata");
+ form.set("buglistUrlNew", "https://bugzilla.redhat.com/show_bug.cgi?id=123");
//edit the keywords
form.set("keywords", "yankee, hotel, foxtrot");
Map params = new HashMap();
params.put("eid", errata.getId().toString());
params.put("buglistIdNew", "123");
params.put("buglistSummaryNew", "test bug for a test errata");
+ params.put("buglistUrlNew", "https://bugzilla.redhat.com/show_bug.cgi?id=123");
request.setupGetParameterMap(params);
request.setupAddParameter("buglistIdNew", "123");
request.setupAddParameter("buglistSummaryNew", "test bug for a test errata");
+ request.setupAddParameter("buglistUrlNew", "https://bugzilla.redhat.com/show_bug.cgi?id=123");
result = action.update(mapping, form, request, response);
assertEquals("default", result.getName());
commit 0dde4029e93892e1727383447c3863a6afcbf147
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Fri Apr 15 16:38:51 2011 +0200
removing curr_cfps since it is never used
diff --git a/backend/satellite_tools/sync_handlers.py b/backend/satellite_tools/sync_handlers.py
index d8a3182..55bddd6 100644
--- a/backend/satellite_tools/sync_handlers.py
+++ b/backend/satellite_tools/sync_handlers.py
@@ -554,7 +554,6 @@ def populate_channel_family_permissions(cert):
# Generate the channel family permissions data structure
cfps = {}
- curr_cfps = {}
for cfp in _fetch_channel_family_permissions():
cf_name = cfp['channel_family']
@@ -563,7 +562,6 @@ def populate_channel_family_permissions(cert):
# Initially populate cf info with old limits from db
cfps[(cf_name, org_id)] = [cfp['max_members'], cfp['max_flex']]
- curr_cfps[(cf_name, org_id)] = [cfp['current_members'], cfp['current_flex']]
# Now set max_members based on the cert's max_members
for cf_name, max_tuple in cert_chfam_hash.items():
commit 9081425cd136281375b1787738ad77b3cd935d62
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Fri Apr 15 16:35:43 2011 +0200
remove duplicate code
same code is 6 lines above
diff --git a/backend/satellite_tools/sync_handlers.py b/backend/satellite_tools/sync_handlers.py
index b1d4108..d8a3182 100644
--- a/backend/satellite_tools/sync_handlers.py
+++ b/backend/satellite_tools/sync_handlers.py
@@ -548,9 +548,6 @@ def populate_channel_family_permissions(cert):
if flex is not None:
flex = int(flex)
- if quant is not None:
- quant = int(quant)
-
#we subtract flex from quantity since flex count is included
# in the full quantity for backwards compatibility
cert_chfam_hash[cf.name] = [quant - flex, flex]
13 years, 1 month
Changes to 'refs/tags/spacewalk-utils-1.5.1-1'
by Jan Pazdziora
Tag 'spacewalk-utils-1.5.1-1' created by Jan Pazdziora <jpazdziora(a)redhat.com> at 2011-04-18 07:57 +0000
Tagging package [spacewalk-utils] version [1.5.1-1] in directory [utils/].
Changes since spacewalk-schema-1.5.2-1:
Jan Pazdziora (1):
Automatic commit of package [spacewalk-utils] release [1.5.1-1].
---
rel-eng/packages/spacewalk-utils | 2 +-
utils/spacewalk-utils.spec | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)
---
13 years, 1 month