java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
| 7
java/code/src/com/redhat/rhn/common/security/acl/ChannelAclHandler.java
| 20
java/code/src/com/redhat/rhn/domain/channel/ChannelFamily.hbm.xml
| 12
java/code/src/com/redhat/rhn/domain/channel/ChannelFamilyFactory.java
| 12
java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java
| 3
java/code/webapp/WEB-INF/nav/channel_detail.xml
| 1
java/code/webapp/WEB-INF/nav/system_detail.xml
| 1
schema/spacewalk/common/tables/rhnChannelFamilyLicense.sql
| 35
schema/spacewalk/common/tables/rhnChannelFamilyLicenseConsent.sql
| 51
schema/spacewalk/common/tables/tables.deps
| 1
schema/spacewalk/oracle/packages/rhn_channel.pkb
| 56
schema/spacewalk/oracle/packages/rhn_channel.pks
| 2
schema/spacewalk/oracle/procs/delete_server.sql
| 1
schema/spacewalk/oracle/procs/procs.deps
| 2
schema/spacewalk/oracle/triggers/rhnChannelFamilyLicense.sql
| 25
schema/spacewalk/oracle/triggers/rhnChannelFamilyLicenseConsent.sql
| 25
schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/013-delete_server.sql
| 271 ++
schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/014-rhn_channel-pks.sql
| 248 +
schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/015-rhn_channel-pkb.sql
| 1344 ++++++++++
schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/100-drop-rhnChannelFamilyLicense-tables.sql
| 23
web/conf/rhn_web.conf
| 3
web/html/nav/channel_detail.xml
| 1
web/html/nav/system_detail.xml
| 1
web/html/network/software/channels/display_license.pxt
| 33
web/html/network/systems/details/channel_license.pxt
| 45
web/html/network/systems/ssm/channels/alter_subscriptions_conf.pxt
| 40
web/modules/rhn/RHN/Access/Channel.pm
| 12
web/modules/rhn/RHN/DB/Channel.pm
| 20
web/modules/rhn/RHN/DB/DataSource/xml/Channel_queries.xml
| 6
web/modules/rhn/RHN/DB/Server.pm
| 14
web/modules/rhn/RHN/DB/ServerActions.pm
| 36
web/modules/sniglets/Sniglets/ActivationKeys.pm
| 2
web/modules/sniglets/Sniglets/ChannelLicense.pm
| 346 --
33 files changed, 1893 insertions(+), 806 deletions(-)
New commits:
commit 20841b237216bccc459b6aae224c0a69dd16329b
Author: Partha Aji <paji(a)redhat.com>
Date: Fri Jun 18 11:49:50 2010 -0400
Good Bye rhnChannelFamilyLicense and rhnChannelFamilyLicenseConsent tables schemas
diff --git a/schema/spacewalk/common/tables/rhnChannelFamilyLicense.sql
b/schema/spacewalk/common/tables/rhnChannelFamilyLicense.sql
deleted file mode 100644
index dfca5ce..0000000
--- a/schema/spacewalk/common/tables/rhnChannelFamilyLicense.sql
+++ /dev/null
@@ -1,35 +0,0 @@
---
--- Copyright (c) 2008 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 TABLE rhnChannelFamilyLicense
-(
- channel_family_id NUMBER NOT NULL
- CONSTRAINT rhn_cfl_cfid_fk
- REFERENCES rhnChannelFamily (id)
- ON DELETE CASCADE,
- license_path VARCHAR2(1000) NOT NULL,
- created DATE
- DEFAULT (sysdate) NOT NULL,
- modified DATE
- DEFAULT (sysdate) NOT NULL
-)
-ENABLE ROW MOVEMENT
-;
-
-CREATE UNIQUE INDEX rhn_cf_license_cfid_uq
- ON rhnChannelFamilyLicense (channel_family_id)
- TABLESPACE [[64k_tbs]];
-
diff --git a/schema/spacewalk/common/tables/rhnChannelFamilyLicenseConsent.sql
b/schema/spacewalk/common/tables/rhnChannelFamilyLicenseConsent.sql
deleted file mode 100644
index 41af7ce..0000000
--- a/schema/spacewalk/common/tables/rhnChannelFamilyLicenseConsent.sql
+++ /dev/null
@@ -1,51 +0,0 @@
---
--- Copyright (c) 2008 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 TABLE rhnChannelFamilyLicenseConsent
-(
- channel_family_id NUMBER NOT NULL
- CONSTRAINT rhn_cfl_consent_cfid_fk
- REFERENCES rhnChannelFamily (id)
- ON DELETE CASCADE,
- user_id NUMBER NOT NULL
- CONSTRAINT rhn_cfl_consent_uid_fk
- REFERENCES web_contact (id)
- ON DELETE CASCADE,
- server_id NUMBER NOT NULL
- CONSTRAINT rhn_cfl_consent_sid_fk
- REFERENCES rhnServer (id),
- created DATE
- DEFAULT (sysdate) NOT NULL,
- modified DATE
- DEFAULT (sysdate) NOT NULL
-)
-ENABLE ROW MOVEMENT
-;
-
-CREATE UNIQUE INDEX rhn_cfl_consent_cf_s_uq
- ON rhnChannelFamilyLicenseConsent (channel_family_id, server_id)
- TABLESPACE [[64k_tbs]];
-
-CREATE INDEX rhn_cfl_consent_uid_idx
- ON rhnChannelFamilyLicenseConsent (user_id)
- TABLESPACE [[64k_tbs]]
- NOLOGGING;
-
-CREATE INDEX rhn_cfl_consent_sid_idx
- ON rhnChannelFamilyLicenseConsent (server_id)
- TABLESPACE [[8m_tbs]]
- NOLOGGING;
-
diff --git a/schema/spacewalk/common/tables/tables.deps
b/schema/spacewalk/common/tables/tables.deps
index 1515473..ce3799a 100644
--- a/schema/spacewalk/common/tables/tables.deps
+++ b/schema/spacewalk/common/tables/tables.deps
@@ -56,7 +56,6 @@ rhnChannelComps :: rhnChannel
rhnChannelCloned :: rhnChannelComps
rhnChannelErrata :: rhnChannel rhnErrata
rhnChannelFamily :: web_customer
-rhnChannelFamilyLicenseConsent :: rhnChannelFamily web_contact rhnServer
rhnChannelFamilyMembers :: rhnChannel rhnChannelFamily
rhnChannelFamilyVirtSubLevel :: rhnChannelFamily rhnVirtSubLevel
rhnPrivateChannelFamily :: web_customer rhnChannelFamily
diff --git a/schema/spacewalk/oracle/packages/rhn_channel.pkb
b/schema/spacewalk/oracle/packages/rhn_channel.pkb
index f5d5c96..77377f5 100644
--- a/schema/spacewalk/oracle/packages/rhn_channel.pkb
+++ b/schema/spacewalk/oracle/packages/rhn_channel.pkb
@@ -42,44 +42,8 @@ IS
and scac.server_arch_id = server_arch_id_in
and scac.channel_arch_id = c.channel_arch_id;
- FUNCTION get_license_path(channel_id_in IN NUMBER)
- RETURN VARCHAR2
- IS
- license_val VARCHAR2(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;
-
- RETURN license_val;
-
- EXCEPTION
- WHEN NO_DATA_FOUND
- THEN
- RETURN NULL;
- END get_license_path;
- PROCEDURE license_consent(channel_id_in IN NUMBER, user_id_in IN NUMBER, server_id_in
IN NUMBER)
- IS
- channel_family_id_val NUMBER;
- BEGIN
- channel_family_id_val := rhn_channel.family_for_channel(channel_id_in);
- IF channel_family_id_val IS NULL
- THEN
- rhn_exception.raise_exception('channel_subscribe_no_family');
- END IF;
-
- IF rhn_channel.get_license_path(channel_id_in) IS NULL
- THEN
- 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 license_consent;
-
PROCEDURE subscribe_server(server_id_in IN NUMBER, channel_id_in NUMBER, immediate_in
NUMBER := 1, user_id_in in number := null, recalcfamily_in NUMBER := 1)
IS
channel_parent_val rhnChannel.parent_channel%TYPE;
@@ -172,21 +136,6 @@ IS
can_server_consume_virt_channl(server_id_in, channel_family_id_val) = 1
THEN
- IF rhn_channel.get_license_path(channel_id_in) IS NOT NULL
- THEN
- BEGIN
-
- SELECT user_id INTO consenting_user
- FROM rhnChannelFamilyLicenseConsent
- WHERE channel_family_id = channel_family_id_val
- AND server_id = server_id_in;
-
- EXCEPTION
- WHEN NO_DATA_FOUND THEN
-
rhn_exception.raise_exception('channel_subscribe_no_consent');
- END;
- END IF;
-
insert into rhnServerHistory (id,server_id,summary,details) (
select rhn_event_id_seq.nextval,
server_id_in,
@@ -583,11 +532,6 @@ IS
for ignore in channel_family_is_proxy(channel_family_id_val) loop
delete from rhnProxyInfo where server_id = server_id_in;
end loop;
-
- DELETE FROM rhnChannelFamilyLicenseConsent
- WHERE channel_family_id = channel_family_id_val
- AND server_id = server_id_in;
-
SELECT org_id INTO server_org_id_val
FROM rhnServer
WHERE id = server_id_in;
diff --git a/schema/spacewalk/oracle/packages/rhn_channel.pks
b/schema/spacewalk/oracle/packages/rhn_channel.pks
index 2036f9a..9385a2a 100644
--- a/schema/spacewalk/oracle/packages/rhn_channel.pks
+++ b/schema/spacewalk/oracle/packages/rhn_channel.pks
@@ -47,8 +47,6 @@ IS
WHERE channel_family_id = channel_family_id_in
AND org_id = org_id_in;
- PROCEDURE license_consent(channel_id_in IN NUMBER, user_id_in IN NUMBER, server_id_in
IN NUMBER);
- FUNCTION get_license_path(channel_id_in IN NUMBER) RETURN VARCHAR2;
PROCEDURE unsubscribe_server(server_id_in IN NUMBER, channel_id_in NUMBER,
immediate_in NUMBER := 1, unsubscribe_children_in number := 0,
deleting_server in number := 0,
diff --git a/schema/spacewalk/oracle/procs/delete_server.sql
b/schema/spacewalk/oracle/procs/delete_server.sql
index d388cb9..3d75909 100644
--- a/schema/spacewalk/oracle/procs/delete_server.sql
+++ b/schema/spacewalk/oracle/procs/delete_server.sql
@@ -150,7 +150,6 @@ begin
delete from rhnActionConfigChannel where server_id = server_id_in;
delete from rhnActionConfigRevision where server_id = server_id_in;
delete from rhnActionPackageRemovalFailure where server_id = server_id_in;
- delete from rhnChannelFamilyLicenseConsent where server_id = server_id_in;
delete from rhnClientCapability where server_id = server_id_in;
delete from rhnCpu where server_id = server_id_in;
-- there's still a cascade here, because the constraint keeps the
diff --git a/schema/spacewalk/oracle/procs/procs.deps
b/schema/spacewalk/oracle/procs/procs.deps
index 4328b6a..f4e66e4 100644
--- a/schema/spacewalk/oracle/procs/procs.deps
+++ b/schema/spacewalk/oracle/procs/procs.deps
@@ -34,7 +34,7 @@ delete_server :: rhn_channel.pks rhn_config.pks \
rhnKickstartSession rhnActionConfigChannel \
rhnActionConfigRevision rhnClientCapability \
rhnActionPackageRemovalFailure rhnCpu \
- rhnChannelFamilyLicenseConsent rhnDevice \
+ rhnDevice \
rhnProxyInfo rhnRam rhnRegToken \
rhnSNPServerQueue rhnSatelliteChannelFamily \
rhnSatelliteInfo rhnServerAction \
diff --git a/schema/spacewalk/oracle/triggers/rhnChannelFamilyLicense.sql
b/schema/spacewalk/oracle/triggers/rhnChannelFamilyLicense.sql
deleted file mode 100644
index 483f7af..0000000
--- a/schema/spacewalk/oracle/triggers/rhnChannelFamilyLicense.sql
+++ /dev/null
@@ -1,25 +0,0 @@
-
---
--- Copyright (c) 2008 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 or replace trigger
-rhn_cf_license_mod_trig
-before insert or update on rhnChannelFamilyLicense
-for each row
-begin
- :new.modified := sysdate;
-end;
-/
-show errors
diff --git a/schema/spacewalk/oracle/triggers/rhnChannelFamilyLicenseConsent.sql
b/schema/spacewalk/oracle/triggers/rhnChannelFamilyLicenseConsent.sql
deleted file mode 100644
index bf1959d..0000000
--- a/schema/spacewalk/oracle/triggers/rhnChannelFamilyLicenseConsent.sql
+++ /dev/null
@@ -1,25 +0,0 @@
-
---
--- Copyright (c) 2008 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 or replace trigger
-rhn_cfl_consent_mod_trig
-before insert or update on rhnChannelFamilyLicenseConsent
-for each row
-begin
- :new.modified := sysdate;
-end;
-/
-show errors
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/013-delete_server.sql
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/013-delete_server.sql
new file mode 100644
index 0000000..3d75909
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/013-delete_server.sql
@@ -0,0 +1,271 @@
+--
+-- Copyright (c) 2008 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.
+--
+--
+--
+-- This deletes a server. All codepaths which delete servers should hit this
+-- or delete_server_bulk()
+
+create or replace
+procedure delete_server (
+ server_id_in in number
+) is
+ cursor servergroups is
+ select server_id, server_group_id
+ from rhnServerGroupMembers sgm
+ where sgm.server_id = server_id_in;
+ cursor configchannels is
+ select cc.id
+ from rhnConfigChannel cc,
+ rhnConfigChannelType cct,
+ rhnServerConfigChannel scc
+ where 1=1
+ and scc.server_id = server_id_in
+ and scc.config_channel_id = cc.id
+ -- these config channel types are reserved
+ -- for use by a single server, so we don't
+ -- need to check for other servers subscribed
+ and cct.label in
+ ('local_override','server_import')
+ and cct.id = cc.confchan_type_id;
+ type filelistsid_t is table of rhnServerPreserveFileList.file_list_id%type;
+ filelistsid_c filelistsid_t;
+
+ type probesid_t is table of rhn_check_probe.probe_id%type;
+ probesid_c probesid_t;
+
+ is_virt number := 0;
+begin
+ rhn_channel.delete_server_channels(server_id_in);
+ -- rhn_channel.clear_subscriptions(server_id_in);
+
+ -- filelists
+ select spfl.file_list_id id bulk collect into filelistsid_c
+ from rhnServerPreserveFileList spfl
+ where spfl.server_id = server_id_in
+ and not exists (
+ select 1
+ from rhnServerPreserveFileList
+ where file_list_id = spfl.file_list_id
+ and server_id != server_id_in
+ union
+ select 1
+ from rhnKickstartPreserveFileList
+ where file_list_id = spfl.file_list_id
+ );
+ if filelistsid_c.first is not null then
+ forall i in filelistsid_c.first..filelistsid_c.last
+ delete from rhnFileList where id = filelistsid_c(i);
+ end if;
+
+ for configchannel in configchannels loop
+ rhn_config.delete_channel(configchannel.id);
+ end loop;
+
+ select count(1) into is_virt
+ from rhnServerEntitlementView
+ where server_id = server_id_in
+ and label in ('virtualization_host',
'virtualization_host_platform')
+ and rownum <= 1;
+
+ for sgm in servergroups loop
+ rhn_server.delete_from_servergroup(
+ sgm.server_id, sgm.server_group_id);
+ end loop;
+
+ if is_virt = 1 then
+ rhn_entitlements.repoll_virt_guest_entitlements(server_id_in);
+ end if;
+
+ -- we're handling this instead of letting an "on delete
+ -- set null" do it so that we don't run the risk
+ -- of setting off the triggers and killing us with a
+ -- mutating table
+
+ -- this is merge of two single updates:
+ -- update ... set old_server_id = null where old_server_id = server_id_in;
+ -- update ... set new_server_id = null where new_server_id = server_id_in;
+ -- so we scan rhnKickstartSession table only once
+ update rhnKickstartSession
+ set old_server_id = case when old_server_id = server_id_in then null else old_server_id
end,
+ new_server_id = case when new_server_id = server_id_in then null else new_server_id
end
+ where old_server_id = server_id_in
+ or new_server_id = server_id_in;
+
+ rhn_channel.clear_subscriptions(server_id_in,1);
+
+ -- A little complicated here, but the goal is to
+ -- delete records from rhnVirtualInstace only if we don't
+ -- care about them anymore. We don't care about records
+ -- in rhnVirtualInstance if we are deleting the host
+ -- system and the virtual system is already null, or
+ -- vice-versa. We *do* care about them if either the
+ -- host or virtual system is still registered because we
+ -- still want them to show up in the UI.
+ -- If there's a newer row in rhnVirtualInstance with the same
+ -- uuid, this guest must have been re-registered, so we can clean
+ -- this data up.
+
+ delete from rhnVirtualInstance vi
+ where (host_system_id = server_id_in and virtual_system_id is null)
+ or (virtual_system_id = server_id_in and host_system_id is null)
+ or (vi.virtual_system_id = server_id_in and vi.modified < (select
max(vi2.modified)
+ from rhnVirtualInstance vi2 where vi2.uuid = vi.uuid));
+
+ -- this is merge of two single updates:
+ -- update ... set host_system_id = null where host_system_id = server_id_in;
+ -- update ... set virtual_system_id = null where virtual_system_id =
server_id_in;
+ -- so we scan rhnVirtualInstance table only once
+ update rhnVirtualInstance
+ set host_system_id = case when host_system_id = server_id_in then null else
host_system_id end,
+ virtual_system_id = case when virtual_system_id = server_id_in then null else
virtual_system_id end
+ where host_system_id = server_id_in
+ or virtual_system_id = server_id_in;
+
+ -- this is merge of two single updates:
+ -- update ... set old_host_system_id = null when old_host_system_id =
server_id_in;
+ -- update ... set new_host_system_id = null when new_host_system_id =
server_id_in;
+ -- so we scan rhnVirtualInstanceEventLog table only once
+ update rhnVirtualInstanceEventLog
+ set old_host_system_id = case when old_host_system_id = server_id_in then null else
old_host_system_id end,
+ new_host_system_id = case when new_host_system_id = server_id_in then null
else new_host_system_id end
+ where old_host_system_id = server_id_in
+ or new_host_system_id = server_id_in;
+
+ -- We're deleting everything with a foreign key to rhnServer
+ -- here, now. I'm hoping this will help aleviate our deadlock
+ -- problem.
+
+ delete from rhnActionConfigChannel where server_id = server_id_in;
+ delete from rhnActionConfigRevision where server_id = server_id_in;
+ delete from rhnActionPackageRemovalFailure where server_id = server_id_in;
+ delete from rhnClientCapability where server_id = server_id_in;
+ delete from rhnCpu where server_id = server_id_in;
+ -- there's still a cascade here, because the constraint keeps the
+ -- table locked for too long to rebuild it. Ugh...
+ delete from rhnDevice where server_id = server_id_in;
+ delete from rhnProxyInfo where server_id = server_id_in;
+ delete from rhnRam where server_id = server_id_in;
+ delete from rhnRegToken where server_id = server_id_in;
+ delete from rhnSNPServerQueue where server_id = server_id_in;
+ delete from rhnSatelliteChannelFamily where server_id = server_id_in;
+ delete from rhnSatelliteInfo where server_id = server_id_in;
+ -- this cascades to rhnActionConfigChannel and rhnActionConfigFileName
+ delete from rhnServerAction where server_id = server_id_in;
+ delete from rhnServerActionPackageResult where server_id = server_id_in;
+ delete from rhnServerActionScriptResult where server_id = server_id_in;
+ delete from rhnServerActionVerifyResult where server_id = server_id_in;
+ delete from rhnServerActionVerifyMissing where server_id = server_id_in;
+ -- counts are handled above. this should be a delete_ function.
+ delete from rhnServerChannel where server_id = server_id_in;
+ delete from rhnServerConfigChannel where server_id = server_id_in;
+ delete from rhnServerCustomDataValue where server_id = server_id_in;
+ delete from rhnServerDMI where server_id = server_id_in;
+ delete from rhnServerMessage where server_id = server_id_in;
+ -- this gets rhnServerMessage (only) on cascade; it's handled just above
+ delete from rhnServerEvent where server_id = server_id_in;
+ delete from rhnServerHistory where server_id = server_id_in;
+ delete from rhnServerInfo where server_id = server_id_in;
+ delete from rhnServerInstallInfo where server_id = server_id_in;
+ delete from rhnServerLocation where server_id = server_id_in;
+ delete from rhnServerLock where server_id = server_id_in;
+ delete from rhnServerNeededCache where server_id = server_id_in;
+ delete from rhnServerNetwork where server_id = server_id_in;
+ delete from rhnServerNotes where server_id = server_id_in;
+ -- I'm not removing the foreign key from rhnServerPackage; that'll
+ -- take forever. Do the delete anyway.
+ delete from rhnServerPackage where server_id = server_id_in;
+ delete from rhnServerTokenRegs where server_id = server_id_in;
+ delete from rhnSnapshotTag where server_id = server_id_in;
+ -- this cascades to:
+ -- rhnSnapshotChannel, rhnSnapshotConfigChannel, rhnSnapshotPackage,
+ -- rhnSnapshotConfigRevision, rhnSnapshotServerGroup,
+ -- rhnSnapshotTag.
+ -- We may want to consider delete_snapshot() at some point, but
+ -- I don't think we need to yet.
+ delete from rhnSnapshot where server_id = server_id_in;
+ delete from rhnTransaction where server_id = server_id_in;
+ delete from rhnUserServerPrefs where server_id = server_id_in;
+ -- hrm, this one's interesting... we _probably_ should delete
+ -- everything for the parent server_id when we delete the proxy,
+ -- but we don't currently.
+ delete from rhnServerPath where server_id_in in (server_id, proxy_server_id);
+ delete from rhnUserServerPerms where server_id = server_id_in;
+
+ delete from rhn_interface_monitoring where server_id = server_id_in;
+ delete from rhnServerNetInterface where server_id = server_id_in;
+ delete from rhn_server_monitoring_info where recid = server_id_in;
+
+ delete from rhnAppInstallSession where server_id = server_id_in;
+ delete from rhnServerUuid where server_id = server_id_in;
+ -- We delete all the probes running directly against this system
+ -- and any probes that were using this Server as a Proxy Scout.
+ SELECT CP.probe_id bulk collect into probesid_c
+ FROM rhn_check_probe CP
+ WHERE CP.host_id = server_id_in
+ OR CP.sat_cluster_id in
+ (SELECT SN.sat_cluster_id
+ FROM rhn_sat_node SN
+ WHERE SN.server_id = server_id_in);
+
+ if probesid_c.first is not null then
+ FORALL i IN probesid_c.first..probesid_c.last
+ DELETE FROM rhn_probe_state PS WHERE PS.probe_id = probesid_c(i);
+ FORALL i IN probesid_c.first..probesid_c.last
+ DELETE FROM rhn_probe P WHERE P.recid = probesid_c(i);
+ FORALL i IN probesid_c.first..probesid_c.last
+ DELETE /*+index(time_series time_series_probe_id_idx)*/
+ FROM time_series
+ WHERE substr(o_id, instr(o_id, '-') + 1,
+ (instr(o_id, '-', instr(o_id, '-') + 1) - instr(o_id,
'-')) - 1) = probesid_c(i);
+ end if;
+
+ delete from rhn_check_probe where host_id = server_id_in;
+ delete from rhn_host_probe where host_id = server_id_in;
+
+ delete from rhn_sat_cluster where recid in
+ ( select sat_cluster_id from rhn_sat_node where server_id = server_id_in );
+
+ delete from rhn_sat_node where server_id = server_id_in;
+
+ -- now get rhnServer itself.
+ delete
+ from rhnServer
+ where id = server_id_in;
+
+ delete
+ from rhnSet
+ where 1=1
+ and user_id in (
+ select wc.id
+ from rhnServer rs,
+ web_contact wc
+ where rs.id = server_id_in
+ and rs.org_id = wc.org_id
+ )
+ and label = 'system_list'
+ and element = server_id_in;
+end delete_server;
+/
+show errors;
+
+--
+-- Revision 1.25 2004/11/01 17:53:03 pjones
+-- bugzilla: 136124 -- Fix the "no data found" when deleting rhn_sat_cluster
+--
+--
+--
+--
+-- This deletes a list of server.
+--
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/014-rhn_channel-pks.sql
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/014-rhn_channel-pks.sql
new file mode 100644
index 0000000..9385a2a
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/014-rhn_channel-pks.sql
@@ -0,0 +1,248 @@
+--
+-- 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 OR REPLACE
+PACKAGE rhn_channel
+IS
+ version varchar2(100) := '';
+
+ CURSOR server_base_subscriptions(server_id_in NUMBER) IS
+ 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;
+
+ CURSOR check_server_subscription(server_id_in NUMBER, channel_id_in NUMBER) IS
+ SELECT channel_id
+ FROM rhnServerChannel
+ WHERE server_id = server_id_in
+ AND channel_id = channel_id_in;
+
+ CURSOR check_server_parent_membership(server_id_in NUMBER, channel_id_in NUMBER) IS
+ SELECT C.id
+ FROM rhnChannel C, rhnServerChannel SC
+ WHERE C.parent_channel = channel_id_in
+ AND C.id = SC.channel_id
+ AND SC.server_id = server_id_in;
+
+ CURSOR channel_family_perm_cursor(channel_family_id_in NUMBER, org_id_in NUMBER) IS
+ SELECT *
+ FROM rhnOrgChannelFamilyPermissions
+ WHERE channel_family_id = channel_family_id_in
+ AND org_id = org_id_in;
+
+
+ PROCEDURE unsubscribe_server(server_id_in IN NUMBER, channel_id_in NUMBER,
immediate_in NUMBER := 1, unsubscribe_children_in number := 0,
+ deleting_server in number := 0,
+ update_family_countsYN IN NUMBER := 1);
+ PROCEDURE subscribe_server(server_id_in IN NUMBER, channel_id_in NUMBER, immediate_in
NUMBER := 1, user_id_in number := null, recalcfamily_in number := 1);
+
+ function can_server_consume_virt_channl(
+ server_id_in IN NUMBER,
+ family_id_in in number)
+ return number;
+
+ FUNCTION guess_server_base(server_id_in IN NUMBER) RETURN NUMBER;
+
+ FUNCTION base_channel_for_release_arch(release_in in varchar2,
+ server_arch_in in varchar2, org_id_in in number := -1,
+ user_id_in in number := null) RETURN number;
+
+ FUNCTION base_channel_rel_archid(release_in in varchar2,
+ server_arch_id_in in number, org_id_in in number := -1,
+ user_id_in in number := null) RETURN number;
+
+ FUNCTION channel_priority(channel_id_in in number) RETURN number;
+
+ PROCEDURE bulk_server_base_change(channel_id_in IN NUMBER, set_label_in IN VARCHAR2,
set_uid_in IN NUMBER);
+ procedure bulk_server_basechange_from(
+ set_label_in in varchar2,
+ set_uid_in in number,
+ old_channel_id_in in number,
+ new_channel_id_in in number);
+
+ procedure bulk_guess_server_base(
+ set_label_in in varchar2,
+ set_uid_in in number);
+
+ procedure bulk_guess_server_base_from(
+ set_label_in in varchar2,
+ set_uid_in in number,
+ channel_id_in in number);
+
+ PROCEDURE clear_subscriptions(server_id_in IN NUMBER, deleting_server in number :=
0,
+ update_family_countsYN IN NUMBER := 1);
+
+ FUNCTION available_family_subscriptions(channel_family_id_in IN NUMBER, org_id_in IN
NUMBER) RETURN NUMBER;
+
+ function channel_family_current_members(channel_family_id_in IN NUMBER,
+ org_id_in IN NUMBER)
+ return number;
+
+ PROCEDURE update_family_counts(channel_family_id_in IN NUMBER, org_id_in IN NUMBER);
+ PROCEDURE update_group_family_counts(group_label_in IN VARCHAR2, org_id_in IN
NUMBER);
+ FUNCTION family_for_channel(channel_id_in IN NUMBER) RETURN NUMBER;
+
+ FUNCTION available_chan_subscriptions(channel_id_in IN NUMBER, org_id_in IN NUMBER)
RETURN NUMBER;
+
+ procedure entitle_customer(customer_id_in in number, channel_family_id_in in number,
quantity_in in number);
+ procedure set_family_maxmembers(customer_id_in in number, channel_family_id_in in
number, quantity_in in number);
+ procedure unsubscribe_server_from_family(server_id_in in number, channel_family_id_in
in number);
+
+ procedure delete_server_channels(server_id_in in number);
+ procedure refresh_newest_package(channel_id_in in number, caller_in in varchar2 :=
'(unknown)');
+
+ function get_org_id(channel_id_in in number) return number;
+ PRAGMA RESTRICT_REFERENCES(get_org_id, WNDS, RNPS, WNPS);
+
+ function get_org_access(channel_id_in in number, org_id_in in number) return number;
+ PRAGMA RESTRICT_REFERENCES(get_org_access, WNDS, RNPS, WNPS);
+
+ function get_cfam_org_access(cfam_id_in in number, org_id_in in number) return
number;
+
+ function user_role_check_debug(channel_id_in in number, user_id_in in number, role_in
in varchar2, reason_out out varchar2)
+ RETURN NUMBER;
+ PRAGMA RESTRICT_REFERENCES(user_role_check_debug, WNDS, RNPS, WNPS);
+
+ function user_role_check(channel_id_in in number, user_id_in in number, role_in in
varchar2)
+ RETURN NUMBER;
+ PRAGMA RESTRICT_REFERENCES(user_role_check, WNDS, RNPS, WNPS);
+
+ function loose_user_role_check(channel_id_in in number, user_id_in in number, role_in
in varchar2)
+ RETURN NUMBER;
+ PRAGMA RESTRICT_REFERENCES(loose_user_role_check, WNDS, RNPS, WNPS);
+
+ function direct_user_role_check(channel_id_in in number, user_id_in in number,
role_in in varchar2)
+ RETURN NUMBER;
+ PRAGMA RESTRICT_REFERENCES(direct_user_role_check, WNDS, RNPS, WNPS);
+
+ function shared_user_role_check(channel_id in number, user_id in number, role in
varchar2)
+ RETURN NUMBER;
+ PRAGMA RESTRICT_REFERENCES(shared_user_role_check, WNDS, RNPS, WNPS);
+
+ function org_channel_setting(channel_id_in in number, org_id_in in number, setting_in
in varchar2)
+ RETURN NUMBER;
+
+ PROCEDURE update_channel ( channel_id_in in number, invalidate_ss in number := 0,
+ date_to_use in date := sysdate );
+
+ PROCEDURE update_channels_by_package ( package_id_in in number, date_to_use in date
:= sysdate );
+
+ PROCEDURE update_channels_by_errata ( errata_id_in number, date_to_use in date :=
sysdate );
+
+
+ PRAGMA RESTRICT_REFERENCES(org_channel_setting, WNDS, RNPS, WNPS);
+
+END rhn_channel;
+/
+SHOW ERRORS
+
+--
+-- Revision 1.37 2004/04/14 00:09:24 pjones
+-- bugzilla: 120761 -- split rhnChannelPermissions into two tables, eliminating
+-- a frequent full table scan
+--
+-- Revision 1.36 2004/03/26 18:11:32 rbb
+-- Bugzilla: 114057
+--
+-- Add a script to determine channel priority.
+--
+-- Revision 1.35 2004/02/17 20:16:52 pjones
+-- bugzilla: none -- add cvs tags into the package as long as we're touching
+-- it anyway
+--
+-- Revision 1.34 2003/11/13 18:13:09 cturner
+-- pragmas can now return now that rhn_user pragmas are fixed
+--
+-- Revision 1.32 2003/09/22 21:00:40 cturner
+-- add method for easy acl check
+--
+-- Revision 1.31 2003/09/17 22:14:11 misa
+-- bugzilla: 103639 Changes to allow me to move the base channel guess into plsql
+--
+-- Revision 1.30 2003/07/24 16:44:16 misa
+-- bugzilla: none A function more usable on the rhnapp side
+--
+-- Revision 1.29 2003/07/24 14:00:17 misa
+-- bugzilla: none PRAGMA RESTRICT_REFERENCES good
+--
+-- Revision 1.28 2003/07/23 21:59:19 cturner
+-- rework how rhnUserChannel works; move to plsql for speed and maintenance
+--
+-- Revision 1.27 2003/07/21 17:49:12 pjones
+-- bugzilla: none
+--
+-- add optional user for subscribe_server
+--
+-- Revision 1.26 2002/12/19 18:13:42 misa
+-- Added caller with a default value
+--
+-- Revision 1.25 2002/12/11 22:18:46 pjones
+-- rhnChannelNewestPackage
+--
+-- Revision 1.24 2002/11/21 22:08:11 pjones
+-- make unsubscribe_channels have a "unsubscribe_children_in number := 0"
+-- argument so that you can tell it to unsubscribe children.
+--
+-- Also, make it raise an exception instead of silent failure in the
+-- other case.
+--
+-- Revision 1.23 2002/11/18 17:20:50 pjones
+-- this should have gone back too
+--
+-- Revision 1.22 2002/11/13 23:16:18 pjones
+-- lookup_*_arch()
+--
+-- Revision 1.21 2002/10/07 20:01:59 rnorwood
+-- guess base channel for ssm and single system
+--
+-- Revision 1.20 2002/10/02 19:21:03 bretm
+-- o 3rd party channel schema changes, no more clobs...
+--
+-- Revision 1.19 2002/09/20 19:21:58 bretm
+-- o more 3rd party channel stuff...
+--
+-- Revision 1.18 2002/06/12 22:33:03 pjones
+-- procedure bulk_guess_server_base_from(
+-- set_label_in in varchar2,
+-- set_uid_in in number,
+-- channel_id_in in number);
+--
+-- for bretm
+--
+-- Revision 1.17 2002/06/12 22:12:25 pjones
+-- procedure bulk_guess_server_base(
+-- set_label_in in varchar2,
+-- set_uid_in in number);
+--
+-- for bretm
+--
+-- Revision 1.16 2002/06/12 19:37:55 pjones
+-- bulk_server_basechange_from(
+-- set_label_in in varchar2,
+-- set_uid_in in number,
+-- old_channel_id_in in number,
+-- new_channel_id_in in number
+-- );
+--
+-- for bretm
+--
+-- Revision 1.15 2002/05/10 22:08:22 pjones
+-- id/log
+--
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/015-rhn_channel-pkb.sql
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/015-rhn_channel-pkb.sql
new file mode 100644
index 0000000..77377f5
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/015-rhn_channel-pkb.sql
@@ -0,0 +1,1344 @@
+--
+-- 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 OR REPLACE
+PACKAGE BODY rhn_channel
+IS
+ body_version varchar2(100) := '';
+
+ -- Cursor that fetches all the possible base channels for a
+ -- (server_arch_id, release, org_id) combination
+ cursor base_channel_cursor(
+ release_in in varchar2,
+ server_arch_id_in in number,
+ org_id_in in number
+ ) return rhnChannel%ROWTYPE is
+ 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;
+
+
+
+ PROCEDURE subscribe_server(server_id_in IN NUMBER, channel_id_in NUMBER, immediate_in
NUMBER := 1, user_id_in in number := null, recalcfamily_in NUMBER := 1)
+ IS
+ channel_parent_val rhnChannel.parent_channel%TYPE;
+ parent_subscribed BOOLEAN;
+ server_has_base_chan BOOLEAN;
+ server_already_in_chan BOOLEAN;
+ channel_family_id_val NUMBER;
+ server_org_id_val NUMBER;
+ available_subscriptions NUMBER;
+ consenting_user NUMBER;
+ allowed number := 0;
+ current_members_val number;
+ 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
+ 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 := FALSE;
+
+ FOR check_subscription IN check_server_subscription(server_id_in,
channel_parent_val)
+ LOOP
+ parent_subscribed := TRUE;
+ END LOOP check_subscription;
+
+ IF NOT parent_subscribed
+ THEN
+ RETURN;
+ END IF;
+ ELSE
+ -- base channel
+ server_has_base_chan := FALSE;
+ FOR base IN server_base_subscriptions(server_id_in)
+ LOOP
+ server_has_base_chan := TRUE;
+ END LOOP base;
+
+ IF server_has_base_chan
+ THEN
+ rhn_exception.raise_exception('channel_server_one_base');
+ END IF;
+ END IF;
+
+ FOR check_subscription IN check_server_subscription(server_id_in, channel_id_in)
+ LOOP
+ server_already_in_chan := TRUE;
+ END LOOP check_subscription;
+
+ 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
+ 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 NVL(org_id, (SELECT org_id FROM rhnServer WHERE id = server_id_in))
+ INTO server_org_id_val
+ FROM rhnChannel
+ WHERE id = channel_id_in;
+
+ select current_members
+ into current_members_val
+ from rhnPrivateChannelFamily
+ where org_id = server_org_id_val and channel_family_id = channel_family_id_val
+ for update of current_members;
+
+ available_subscriptions :=
rhn_channel.available_family_subscriptions(channel_family_id_val, server_org_id_val);
+
+ IF available_subscriptions IS NULL OR
+ available_subscriptions > 0 or
+ can_server_consume_virt_channl(server_id_in, channel_family_id_val) = 1
+ THEN
+
+ insert into rhnServerHistory (id,server_id,summary,details) (
+ select rhn_event_id_seq.nextval,
+ 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 = sysdate WHERE id = server_id_in;
+ INSERT INTO rhnServerChannel (server_id, channel_id) VALUES (server_id_in,
channel_id_in);
+ IF recalcfamily_in > 0
+ THEN
+ rhn_channel.update_family_counts(channel_family_id_val,
server_org_id_val);
+ END IF;
+ queue_server(server_id_in, immediate_in);
+ ELSE
+ rhn_exception.raise_exception('channel_family_no_subscriptions');
+ END IF;
+
+ END subscribe_server;
+
+ function can_server_consume_virt_channl(
+ server_id_in in number,
+ family_id_in in number )
+ return number
+ is
+
+ cursor server_virt_families is
+ select vi.virtual_system_id, cfvsl.channel_family_id
+ 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 );
+ begin
+
+ for server_virt_family in server_virt_families loop
+ return 1;
+ end loop;
+
+ return 0;
+
+ end;
+
+
+ PROCEDURE bulk_server_base_change(channel_id_in IN NUMBER, set_label_in IN VARCHAR2,
set_uid_in IN NUMBER)
+ IS
+ BEGIN
+ FOR server IN rhn_set.set_iterator(set_label_in, set_uid_in)
+ LOOP
+ IF rhn_server.can_change_base_channel(server.element) = 1
+ THEN
+ rhn_channel.clear_subscriptions(TO_NUMBER(server.element));
+ rhn_channel.subscribe_server(server.element, channel_id_in, 0,
set_uid_in);
+ END IF;
+ END LOOP server;
+ END bulk_server_base_change;
+
+ procedure bulk_server_basechange_from(
+ set_label_in in varchar2,
+ set_uid_in in number,
+ old_channel_id_in in number,
+ new_channel_id_in in number
+ ) is
+ cursor servers is
+ select sc.server_id id
+ from rhnChannel nc,
+ rhnServerChannelArchCompat scac,
+ rhnServer s,
+ rhnChannel oc,
+ rhnServerChannel sc,
+ rhnSet st
+ where 1=1
+ -- first, find the servers we're looking for.
+ and st.label = set_label_in
+ and st.user_id = set_uid_in
+ and st.element = sc.server_id
+ -- now, filter out anything that's not in the
+ -- old base channel.
+ and sc.channel_id = old_channel_id_in
+ and sc.channel_id = oc.id
+ and oc.parent_channel is null
+ -- now, see if it's compatible with the new base channel
+ and nc.id = new_channel_id_in
+ and nc.parent_channel is null
+ and sc.server_id = s.id
+ and s.server_arch_id = scac.server_arch_id
+ and scac.channel_arch_id = nc.channel_arch_id;
+ begin
+ for s in servers loop
+ insert into rhnSet (
+ user_id, label, element
+ ) values (
+ set_uid_in,
+ set_label_in || 'basechange',
+ s.id
+ );
+ end loop channel;
+ bulk_server_base_change(new_channel_id_in,
+ set_label_in || 'basechange',
+ set_uid_in);
+ delete from rhnSet
+ where label = set_label_in||'basechange'
+ and user_id = set_uid_in;
+ end bulk_server_basechange_from;
+
+ procedure bulk_guess_server_base(
+ set_label_in in varchar2,
+ set_uid_in in number
+ ) is
+ channel_id number;
+ begin
+ for server in rhn_set.set_iterator(set_label_in, set_uid_in)
+ loop
+ -- anything that doesn't work, we just ignore
+ begin
+ if rhn_server.can_change_base_channel(server.element) = 1
+ then
+ channel_id := guess_server_base(TO_NUMBER(server.element));
+ rhn_channel.clear_subscriptions(TO_NUMBER(server.element));
+ rhn_channel.subscribe_server(TO_NUMBER(server.element), channel_id,
0, set_uid_in);
+ end if;
+ exception when others then
+ null;
+ end;
+ end loop server;
+ end;
+
+ function guess_server_base(
+ server_id_in in number
+ ) RETURN number is
+ cursor server_cursor is
+ select s.server_arch_id, s.release, s.org_id
+ from rhnServer s
+ where s.id = server_id_in;
+ 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 base_channel_cursor;
+ end loop server_cursor;
+ -- Server not found, or no base channel applies to it
+ return null;
+ end;
+
+ -- Private function
+ function normalize_server_arch(server_arch_in in varchar2)
+ return varchar2
+ deterministic
+ is
+ suffix VARCHAR2(128) := '-redhat-linux';
+ suffix_len NUMBER := length(suffix);
+ begin
+ if server_arch_in is NULL then
+ return NULL;
+ end if;
+ if instr(server_arch_in, '-') > 0
+ then
+ -- Suffix already present
+ return server_arch_in;
+ end if;
+ return server_arch_in || suffix;
+ end normalize_server_arch;
+
+ --
+ --
+ -- Raises:
+ -- server_arch_not_found
+ -- no_subscribe_permissions
+ function base_channel_for_release_arch(
+ release_in in varchar2,
+ server_arch_in in varchar2,
+ org_id_in in number := -1,
+ user_id_in in number := null
+ ) return number is
+ server_arch varchar2(256) := normalize_server_arch(server_arch_in);
+ server_arch_id number;
+ begin
+ -- Look up the server arch
+ begin
+ select id
+ into server_arch_id
+ from rhnServerArch
+ where label = server_arch;
+ exception
+ when no_data_found then
+ rhn_exception.raise_exception('server_arch_not_found');
+ end;
+ return base_channel_rel_archid(release_in, server_arch_id,
+ org_id_in, user_id_in);
+ end base_channel_for_release_arch;
+
+ function base_channel_rel_archid(
+ release_in in varchar2,
+ server_arch_id_in in number,
+ org_id_in in number := -1,
+ user_id_in in number := null
+ ) return number is
+ denied_channel_id number := null;
+ valid_org_id number := org_id_in;
+ valid_user_id number := user_id_in;
+ channel_subscribable number;
+ begin
+ if org_id_in = -1 and user_id_in is not null then
+ -- Get the org id from the user id
+ begin
+ select org_id
+ into valid_org_id
+ from web_contact
+ where id = user_id_in;
+ exception
+ when no_data_found then
+ -- User doesn't exist
+ -- XXX Only list public stuff for now
+ valid_user_id := null;
+ valid_org_id := -1;
+ end;
+ 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 loose_user_role_check(c.id, user_id_in, 'subscribe')
+ into channel_subscribable
+ from dual;
+
+ 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 base_channel_fetch;
+
+ if denied_channel_id is not null then
+ rhn_exception.raise_exception('no_subscribe_permissions');
+ end if;
+ -- No base channel applies
+ return NULL;
+ end base_channel_rel_archid;
+
+ procedure bulk_guess_server_base_from(
+ set_label_in in varchar2,
+ set_uid_in in number,
+ channel_id_in in number
+ ) is
+ cursor channels(server_id_in in number) is
+ select rsc.channel_id
+ from rhnServerChannel rsc,
+ rhnChannel rc
+ where server_id_in = rsc.server_id
+ and rsc.channel_id = rc.id
+ and rc.parent_channel is null;
+ begin
+ for server in rhn_set.set_iterator(set_label_in, set_uid_in)
+ loop
+ for channel in channels(server.element)
+ loop
+ if channel.channel_id = channel_id_in
+ then
+ insert into rhnSet (user_id, label, element) values (set_uid_in,
set_label_in || 'baseguess', server.element);
+ end if;
+ end loop channel;
+ end loop server;
+ bulk_guess_server_base(set_label_in||'baseguess',set_uid_in);
+ delete from rhnSet where label = set_label_in||'baseguess' and user_id =
set_uid_in;
+ end;
+
+
+ PROCEDURE clear_subscriptions(server_id_in IN NUMBER, deleting_server IN NUMBER :=
0,
+ update_family_countsYN IN NUMBER := 1)
+ IS
+ cursor server_channels(server_id_in in number) is
+ 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
+ unsubscribe_server(server_id_in, channel.channel_id, 1, 1,
deleting_server, update_family_countsYN);
+ end loop channel;
+ END clear_subscriptions;
+
+ PROCEDURE unsubscribe_server(server_id_in IN NUMBER, channel_id_in NUMBER,
immediate_in NUMBER := 1, unsubscribe_children_in number := 0,
+ deleting_server IN NUMBER := 0,
+ update_family_countsYN IN NUMBER := 1)
+ IS
+ channel_family_id_val NUMBER;
+ server_org_id_val NUMBER;
+ available_subscriptions NUMBER;
+ server_already_in_chan BOOLEAN;
+ cursor channel_family_is_proxy(channel_family_id_in in number) is
+ select 1
+ from rhnChannelFamily
+ where id = channel_family_id_in
+ and label = 'rhn-proxy';
+ cursor channel_family_is_satellite(channel_family_id_in in number) is
+ select 1
+ from rhnChannelFamily
+ where id = channel_family_id_in
+ and label = 'rhn-satellite';
+ -- this is *EXACTLY* like check_server_parent_membership, but if we recurse
+ -- with the package-level one, we get a "cursor already open", so we
need a
+ -- copy on our call stack instead. GROAN.
+ cursor local_chk_server_parent_memb (
+ server_id_in number,
+ channel_id_in number ) is
+ 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;
+ BEGIN
+ FOR child IN local_chk_server_parent_memb(server_id_in, channel_id_in)
+ LOOP
+ if unsubscribe_children_in = 1 then
+ unsubscribe_server(server_id_in => server_id_in,
+ channel_id_in =>
child.id,
+ immediate_in =>
immediate_in,
+ unsubscribe_children_in
=> unsubscribe_children_in,
+ deleting_server => deleting_server,
+ update_family_countsYN => update_family_countsYN);
+ else
+
rhn_exception.raise_exception('channel_unsubscribe_child_exists');
+ end if;
+ END LOOP child;
+
+ server_already_in_chan := FALSE;
+
+ FOR check_subscription IN check_server_subscription(server_id_in, channel_id_in)
+ LOOP
+ server_already_in_chan := TRUE;
+ END LOOP check_subscription;
+
+ IF NOT server_already_in_chan
+ THEN
+ RETURN;
+ END IF;
+
+ if deleting_server = 0 then
+
+ insert into rhnServerHistory (id,server_id,summary,details) (
+ select rhn_event_id_seq.nextval,
+ 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 = sysdate 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
+ 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
+ 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;
+ delete from rhnSatelliteChannelFamily 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
+ rhn_channel.update_family_counts(channel_family_id_val, server_org_id_val);
+ end if;
+ END unsubscribe_server;
+
+
+ FUNCTION family_for_channel(channel_id_in IN NUMBER)
+ RETURN NUMBER
+ IS
+ channel_family_id_val NUMBER;
+ BEGIN
+ SELECT channel_family_id INTO channel_family_id_val
+ FROM rhnChannelFamilyMembers
+ WHERE channel_id = channel_id_in;
+
+ RETURN channel_family_id_val;
+ EXCEPTION
+ WHEN NO_DATA_FOUND
+ THEN
+ RETURN NULL;
+ END family_for_channel;
+
+ FUNCTION available_family_subscriptions(channel_family_id_in IN NUMBER, org_id_in IN
NUMBER)
+ RETURN NUMBER
+ IS
+ cfp channel_family_perm_cursor%ROWTYPE;
+ current_members_val NUMBER;
+ max_members_val NUMBER;
+ found NUMBER;
+ BEGIN
+ IF NOT channel_family_perm_cursor%ISOPEN
+ THEN
+ OPEN channel_family_perm_cursor(channel_family_id_in, org_id_in);
+ END IF;
+
+ FETCH channel_family_perm_cursor INTO cfp;
+
+ WHILE channel_family_perm_cursor%FOUND
+ LOOP
+ found := 1;
+
+ current_members_val := cfp.current_members;
+ max_members_val := cfp.max_members;
+
+ FETCH channel_family_perm_cursor INTO cfp;
+ END LOOP;
+
+ IF channel_family_perm_cursor%ISOPEN
+ THEN
+ CLOSE channel_family_perm_cursor;
+ END IF;
+
+ -- 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 available_family_subscriptions;
+
+ -- *******************************************************************
+ -- 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
+ -- *******************************************************************
+ function channel_family_current_members(channel_family_id_in IN NUMBER,
+ org_id_in IN NUMBER)
+ return number
+ is
+ current_members_count number := 0;
+ begin
+ select count(distinct server_id)
+ into current_members_count
+ from rhnChannelFamilyServerPhysical cfsp
+ where cfsp.channel_family_id = channel_family_id_in
+ and cfsp.customer_id = org_id_in;
+ return current_members_count;
+ end;
+
+ PROCEDURE update_family_counts(channel_family_id_in IN NUMBER,
+ org_id_in IN NUMBER)
+ IS
+ BEGIN
+ update rhnPrivateChannelFamily
+ set current_members = (
+ 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 update_family_counts;
+
+ PROCEDURE update_group_family_counts(group_label_in IN VARCHAR2,
+ org_id_in IN NUMBER)
+ IS
+ BEGIN
+ FOR i IN (
+ SELECT DISTINCT CFM.channel_family_id, SG.org_id
+ FROM rhnChannelFamilyMembers CFM
+ JOIN rhnServerChannel SC
+ ON SC.channel_id = CFM.channel_id
+ JOIN rhnServerGroupMembers SGM
+ ON SC.server_id = SGM.server_id
+ JOIN rhnServerGroup SG
+ ON SGM.server_group_id = SG.id
+ JOIN rhnServerGroupType SGT
+ ON SG.group_type = SGT.id
+ WHERE SGT.label = group_label_in
+ AND SG.org_id = org_id_in
+ AND SGT.is_base = 'Y'
+ ) LOOP
+ rhn_channel.update_family_counts(i.channel_family_id, i.org_id);
+ END LOOP;
+ END update_group_family_counts;
+
+ FUNCTION available_chan_subscriptions(channel_id_in IN NUMBER,
+ org_id_in IN NUMBER)
+ RETURN NUMBER
+ IS
+ channel_family_id_val NUMBER;
+ BEGIN
+ SELECT channel_family_id INTO 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 available_chan_subscriptions;
+
+ -- *******************************************************************
+ -- PROCEDURE: entitle_customer
+ -- Creates a chan fam bucket, or sets max_members for an existing bucket
+ -- Called by: rhn_ep.poll_customer_internal
+ -- Calls: set_family_maxmembers + update_family_counts if the row
+ -- already exists, else it creates it in rhnPrivateChannelFamily.
+ -- *******************************************************************
+ procedure entitle_customer(customer_id_in in number,
+ channel_family_id_in in number,
+ quantity_in in number)
+ is
+ cursor permissions is
+ select 1
+ from rhnPrivateChannelFamily pcf
+ where pcf.org_id = customer_id_in
+ and pcf.channel_family_id = channel_family_id_in;
+ begin
+ for perm in permissions loop
+ set_family_maxmembers(
+ customer_id_in,
+ channel_family_id_in,
+ quantity_in
+ );
+ rhn_channel.update_family_counts(
+ channel_family_id_in,
+ customer_id_in
+ );
+ return;
+ end loop;
+
+ insert into rhnPrivateChannelFamily pcf (
+ channel_family_id, org_id, max_members, current_members
+ ) values (
+ channel_family_id_in, customer_id_in, quantity_in, 0
+ );
+ end;
+
+ -- *******************************************************************
+ -- PROCEDURE: set_family_maxmembers
+ -- Prunes an existing channel family bucket by unsubscribing the
+ -- necessary servers and sets max_members.
+ -- Called by: rhn_channel.entitle_customer
+ -- Calls: unsubscribe_server_from_family
+ -- *******************************************************************
+ procedure set_family_maxmembers(customer_id_in in number,
+ channel_family_id_in in number,
+ quantity_in in number)
+ is
+ cursor servers is
+ select server_id from (
+ select rownum row_number, server_id, modified from (
+ select rcfsp.server_id,
+ rcfsp.modified
+ from rhnChannelFamilyServerPhysical rcfsp
+ where rcfsp.customer_id = customer_id_in
+ and rcfsp.channel_family_id = channel_family_id_in
+ order by modified
+ )
+ where rownum > quantity_in
+ );
+ begin
+ -- prune subscribed servers
+ for server in servers loop
+ rhn_channel.unsubscribe_server_from_family(server.server_id,
+ channel_family_id_in);
+ end loop;
+
+ update rhnPrivateChannelFamily pcf
+ set pcf.max_members = quantity_in
+ where pcf.org_id = customer_id_in
+ and pcf.channel_family_id = channel_family_id_in;
+ end;
+
+ procedure unsubscribe_server_from_family(server_id_in in number,
+ channel_family_id_in in number)
+ is
+ 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;
+
+ function get_org_id(channel_id_in in number)
+ return number
+ is
+ org_id_out number;
+ begin
+ select org_id into org_id_out
+ from rhnChannel
+ where id = channel_id_in;
+
+ return org_id_out;
+ end get_org_id;
+
+ function get_cfam_org_access(cfam_id_in in number, org_id_in in number)
+ return number
+ is
+ cursor families is
+ select 1
+ from rhnOrgChannelFamilyPermissions cfp
+ where cfp.org_id = org_id_in;
+ begin
+ -- the idea: if we get past this query,
+ -- the user has the role, else catch the exception and return 0
+ for family in families loop
+ return 1;
+ end loop;
+ return 0;
+ end;
+
+ function get_org_access(channel_id_in in number, org_id_in in number)
+ return number
+ is
+ throwaway number;
+ begin
+ -- the idea: if we get past this query,
+ -- the org has access to the channel, else catch the exception and return 0
+ select distinct 1 into throwaway
+ 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);
+
+ return 1;
+ exception
+ when no_data_found
+ then
+ return 0;
+ end;
+
+ -- check if a user has a given role, or if such a role is inferrable
+ function user_role_check_debug(channel_id_in in number,
+ user_id_in in number,
+ role_in in varchar2,
+ reason_out out varchar2)
+ return number
+ is
+ org_id number;
+ 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
+ return 1;
+ end if;
+
+ if role_in = 'manage' and
+ NVL(rhn_channel.get_org_id(channel_id_in), -1) <> org_id then
+ reason_out := 'channel_not_owned';
+ return 0;
+ end if;
+
+ if role_in = 'subscribe' and
+ rhn_channel.get_org_access(channel_id_in, org_id) = 0 then
+ reason_out := 'channel_not_available';
+ return 0;
+ end if;
+
+ -- channel admins have all roles
+ if rhn_user.check_role_implied(user_id_in, 'channel_admin') = 1 then
+ reason_out := 'channel_admin';
+ return 1;
+ 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';
+ return 1;
+ end if;
+ end if;
+
+ -- all other roles (manage right now) are explicitly granted
+ reason_out := 'direct_permission';
+ return rhn_channel.direct_user_role_check(channel_id_in,
+ user_id_in, role_in);
+ end;
+
+ -- same as above, but with no OUT param; useful in views, etc
+ function user_role_check(channel_id_in in number, user_id_in in number, role_in in
varchar2)
+ return number
+ is
+ throwaway varchar2(256);
+ begin
+ return rhn_channel.user_role_check_debug(channel_id_in, user_id_in, role_in,
throwaway);
+ end;
+
+ --
+ -- For multiorg phase II, this function simply checks to see if the user's
+ -- has a trust relationship that includes this channel by id.
+ --
+ function shared_user_role_check(channel_id in number, user_id in number, role in
varchar2)
+ return number
+ is
+ n number;
+ oid number;
+ 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;
+ return 1;
+ exception
+ when no_data_found then
+ return 0;
+ end;
+
+ -- same as above, but returns 1 if user_id_in is null
+ -- This is useful in queries where user_id is not specified
+ function loose_user_role_check(channel_id_in in number, user_id_in in number, role_in
in varchar2)
+ return number
+ is
+ begin
+ if user_id_in is null then
+ return 1;
+ end if;
+ return user_role_check(channel_id_in, user_id_in, role_in);
+ end loose_user_role_check;
+
+ -- directly checks the table, no inferred permissions
+ function direct_user_role_check(channel_id_in in number, user_id_in in number,
role_in in varchar2)
+ return number
+ is
+ throwaway number;
+ begin
+ -- the idea: if we get past this query, the user has the role, else catch the
exception and return 0
+ 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;
+
+ return 1;
+ exception
+ when no_data_found
+ then
+ return 0;
+ end;
+
+ -- check if an org has a certain setting
+ function org_channel_setting(channel_id_in in number, org_id_in in number, setting_in
in varchar2)
+ return number
+ is
+ throwaway number;
+ begin
+ -- the idea: if we get past this query, the org has the setting, else catch the
exception and return 0
+ 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;
+
+ return 1;
+ exception
+ when no_data_found
+ then
+ return 0;
+ end;
+
+ FUNCTION channel_priority(channel_id_in IN number)
+ RETURN number
+ IS
+ channel_name varchar2(256);
+ priority number;
+ end_of_life_val date;
+ org_id_val number;
+ 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 channel_priority;
+
+ -- right now this only does the accounting changes; the cascade
+ -- actually does the rhnServerChannel delete.
+ procedure delete_server_channels(server_id_in in number)
+ is
+ 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;
+
+ -- this could certainly be optimized to do updates if needs be
+ procedure refresh_newest_package(channel_id_in in number, caller_in in varchar2
:= '(unknown)')
+ is
+ 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(sysdate, last_modified + 1/86400)
+ where id = channel_id_in;
+ end;
+
+ procedure update_channel ( channel_id_in in number, invalidate_ss in number := 0,
+ date_to_use in date := sysdate )
+ is
+
+ channel_last_modified date;
+ last_modified_value date;
+
+ cursor snapshots is
+ 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 + 1/86400;
+ 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 update_channel;
+
+ procedure update_channels_by_package ( package_id_in in number, date_to_use in date :=
sysdate )
+ is
+
+ cursor channels is
+ 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
+ rhn_channel.update_channel ( channel.channel_id, 1, date_to_use );
+ end loop;
+ end update_channels_by_package;
+
+
+ procedure update_channels_by_errata ( errata_id_in number, date_to_use in date :=
sysdate )
+ is
+
+ cursor channels is
+ 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
+ rhn_channel.update_channel ( channel.channel_id, 0, date_to_use );
+ end loop;
+ end update_channels_by_errata;
+
+END rhn_channel;
+/
+SHOW ERRORS
+
+--
+-- Revision 1.75 2005/03/04 00:04:19 jslagle
+-- bz #147617
+-- Made Red Hat Desktop sort a little better.
+--
+-- Revision 1.74 2005/02/22 03:24:47 jslagle
+-- bz #147617
+-- Improve channel_priority function to order channels better.
+--
+-- Revision 1.73 2004/08/16 20:39:30 pjones
+-- bugzilla: 129889 -- make bulk_server_basechange_from() actually work.
+--
+-- Revision 1.72 2004/04/14 00:09:24 pjones
+-- bugzilla: 120761 -- split rhnChannelPermissions into two tables, eliminating
+-- a frequent full table scan
+--
+-- Revision 1.71 2004/04/13 16:28:36 bretm
+-- bugzilla: 119871
+--
+-- keep track of rhnServer.channels_changed through the pl/sql fns
+--
+-- Revision 1.70 2004/03/26 18:11:32 rbb
+-- Bugzilla: 114057
+--
+-- Add a script to determine channel priority.
+--
+-- Revision 1.69 2004/02/17 20:16:52 pjones
+-- bugzilla: none -- add cvs tags into the package as long as we're touching
+-- it anyway
+--
+-- Revision 1.68 2004/02/17 20:05:38 pjones
+-- bugzilla: 115782 -- make bulk_server_basechange_from() filter out servers
+-- with arches incompatible with the target channel
+--
+-- Revision 1.67 2004/02/06 02:36:10 misa
+-- Changed normalize_server_arch to allow for solaris arches
+--
+-- Revision 1.66 2003/11/13 16:58:34 cturner
+-- make use of new rhn_user.check_role_implied call; pragmas broke, removed them for now
since I have no idea how to fix them
+--
+-- Revision 1.65 2003/10/23 20:26:24 bretm
+-- bugzilla: none
+--
+-- note the channel label when we unsubscribe, too
+--
+-- Revision 1.64 2003/10/15 14:47:17 bretm
+-- bugzilla: none
+--
+-- add the channel label to the server history summary line when we log a channel change
+--
+-- Revision 1.63 2003/09/24 19:25:56 pjones
+-- this wasn't the right fix, put it back
+--
+-- Revision 1.62 2003/09/24 17:42:19 pjones
+-- bugzilla: none
+--
+-- limit our server base channel guess to channels with available permissions
+--
+-- Revision 1.61 2003/09/22 21:00:40 cturner
+-- add method for easy acl check
+--
+-- Revision 1.60 2003/09/17 22:14:11 misa
+-- bugzilla: 103639 Changes to allow me to move the base channel guess into plsql
+--
+-- Revision 1.59 2003/08/21 13:41:17 cturner
+-- bugzilla: 99187. properly test for satellite and proxy in bulk_guess_server_base;
reorg code for better reuse
+--
+-- Revision 1.58 2003/07/24 16:46:22 cturner
+-- bugzilla: 100723, the perm check was returning duplicates, so now it just calls the
function it should have called anyway
+--
+-- Revision 1.57 2003/07/24 16:44:16 misa
+-- bugzilla: none A function more usable on the rhnapp side
+--
+-- Revision 1.56 2003/07/23 22:36:51 cturner
+-- argh, max returns null even when now rows; use distinct. how revolting
+--
+-- Revision 1.55 2003/07/23 22:01:31 cturner
+-- oops, this one can return multiple rows; eliminate that in a lazy way
+--
+-- Revision 1.54 2003/07/23 21:59:19 cturner
+-- rework how rhnUserChannel works; move to plsql for speed and maintenance
+--
+-- Revision 1.53 2003/07/21 17:49:12 pjones
+-- bugzilla: none
+--
+-- add optional user for subscribe_server
+--
+-- Revision 1.52 2003/07/14 22:19:29 misa
+-- bugzilla: none Updating guess_base_channel to work more like the rhnapp server code
+--
+-- Revision 1.51 2003/06/26 22:09:04 pjones
+-- bugzilla: none
+--
+-- log subscribe and unsubscribe
+--
+-- Revision 1.50 2003/06/05 19:31:15 pjones
+-- bugzilla: 88278 -- make the cursor name smaller
+--
+-- Revision 1.49 2003/06/05 19:18:21 pjones
+-- bugzilla: 88278
+--
+-- unsubscribe_server() opens the package-level cursor when it invokes itself,
+-- so we're using a local copy instead.
+--
+-- Revision 1.48 2003/06/04 16:41:39 pjones
+-- bugzilla: none
+--
+-- make bulk_guess_server_base() silently ignore unguessables
+--
+-- Revision 1.47 2003/06/04 16:27:03 pjones
+-- bugzilla: 88822
+--
+-- eliminate the last outliers that remove things from channels without using
+-- unsubscribe_server, I think.
+--
+-- Revision 1.46 2003/06/03 20:49:37 pjones
+-- bugzilla: 88822
+-- unsubscribing from rhn-satellite now clears rhnSatelliteChannelFamily
+-- for the server in question
+--
+-- Revision 1.45 2003/06/02 20:41:45 pjones
+-- bugzilla: none - fix rhnProxyInfo/rhnSatelliteInfo channel unsubscribe
+-- problem. Basicly, if you're out of the channel for any reason, you're
+-- also out of rhnProxyInfo/rhnProxyInfo
+--
+-- Revision 1.44 2003/03/24 15:26:28 pjones
+-- bugzilla: 85812
+--
+-- bulk_server_base_change silently ignores servers that are satellites
+-- or proxies, as requested.
+--
+-- Revision 1.43 2003/02/26 20:28:17 pjones
+-- rhn_channel.update_family_counts() in rhn_channel.entitle_customer()
+-- the old codepath is:
+--
+-- ep ->
+-- rhn_ep.entitlement_run_me() ->
+-- rhn_ep.poll_customer() ->
+-- rhn_channel.entitle_customer()
+--
+-- which doesn't change current_members, even though it may remove servers
+-- from the family.
+--
+-- There's another bug here: currently, we don't try to order forced
+-- unsubscribes in any way; we just use
+-- rhn_channel.unsubscribe_server_from_family . If there are any child
+-- channel subscriptions, this will leave them subscribed. We really need
+-- to iterate across the channels again, and subscribe any channel for which
+-- there are no parent channel subscriptions.
+--
+-- Ugh.
+--
+-- Revision 1.42 2003/01/28 00:19:45 pjones
+-- fix clear_subscriptions; AFAICT, this is only hit on the
+-- bulk_server_base_change / bulk_server_base_guess codepaths, which puts
+-- it infrequent enough that it could be our "bad count" culprit.
+--
+-- Revision 1.41 2003/01/14 19:51:45 pjones
+-- make setting current_members on rhnChannelFamilyPermissions work when
+-- a server is in more than one channel in a single family.
diff --git
a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/100-drop-rhnChannelFamilyLicense-tables.sql
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/100-drop-rhnChannelFamilyLicense-tables.sql
new file mode 100644
index 0000000..5bd06db
--- /dev/null
+++
b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/100-drop-rhnChannelFamilyLicense-tables.sql
@@ -0,0 +1,23 @@
+--
+-- Copyright (c) 2008 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.
+--
+--
+--
+--
+drop trigger rhn_cf_license_mod_trig;
+drop trigger rhn_cfl_consent_mod_trig;
+drop table rhnChannelFamilyLicense;
+drop table rhnChannelFamilyLicenseConsent;
+
+
commit cf366a1603dc7c3610e429444354feec9163b043
Author: Partha Aji <paji(a)redhat.com>
Date: Fri Jun 18 11:40:15 2010 -0400
Good Bye Channel License Code
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
index 00cf97e..69eefd8 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
@@ -867,11 +867,9 @@ SELECT C.id, C.name, C.label, 1 AS IS_CUSTOM
SELECT DISTINCT C.id,
C.label,
C.name,
- C.summary,
- CFL.channel_family_id AS HAS_LICENSE,
+ C.summary
C.gpg_key_url
- FROM rhnChannelFamilyLicense CFL,
- rhnChannelFamilyMembers CFM,
+ FROM rhnChannelFamilyMembers CFM,
rhnChannel C,
rhnUserChannel UC
WHERE UC.user_id = :user_id
@@ -881,7 +879,6 @@ SELECT DISTINCT C.id,
AND C.id = CFM.channel_id
AND C.parent_channel IS NOT NULL
AND NOT EXISTS (SELECT 1 FROM rhnServerChannel WHERE server_id = :server_id AND
channel_id = C.id)
- AND CFM.channel_family_id = CFL.channel_family_id (+)
</query>
</mode>
diff --git a/java/code/src/com/redhat/rhn/common/security/acl/ChannelAclHandler.java
b/java/code/src/com/redhat/rhn/common/security/acl/ChannelAclHandler.java
index 17d4061..47e6042 100644
--- a/java/code/src/com/redhat/rhn/common/security/acl/ChannelAclHandler.java
+++ b/java/code/src/com/redhat/rhn/common/security/acl/ChannelAclHandler.java
@@ -17,7 +17,6 @@ package com.redhat.rhn.common.security.acl;
import com.redhat.rhn.common.db.datasource.DataResult;
import com.redhat.rhn.domain.channel.Channel;
import com.redhat.rhn.domain.channel.ChannelFactory;
-import com.redhat.rhn.domain.channel.ChannelFamilyFactory;
import com.redhat.rhn.domain.channel.ChannelVersion;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.manager.channel.ChannelManager;
@@ -183,24 +182,7 @@ public class ChannelAclHandler extends BaseHandler {
return false;
}
}
-
- /**
- * Does this channel have an associated license to be displayed?
- *
rhnChannel<--rhnChannelFamilyMembers-->rhnChannelFamily<--rhnChannelFamilyLicense
- * @param ctx request context (user, cid)
- * @param params check parameters
- * @return true if allowed, false else
- */
- public boolean aclChannelLicensed(Object ctx, String[] params) {
- HashMap ctxMap = (HashMap)ctx;
- User usr = (User)ctxMap.get(USER);
- Channel chan = getChannel(usr, ctxMap);
- return (chan != null &&
- chan.getChannelFamily() != null &&
- ChannelFamilyFactory.lookupLicense(
- chan.getChannelFamily().getId()) != null);
- }
-
+
/**
* Does the channel have anything to download?
* @param ctx request context (user,cid)
diff --git a/java/code/src/com/redhat/rhn/domain/channel/ChannelFamily.hbm.xml
b/java/code/src/com/redhat/rhn/domain/channel/ChannelFamily.hbm.xml
index 0a3888b..a64a2d4 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/ChannelFamily.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/channel/ChannelFamily.hbm.xml
@@ -50,16 +50,4 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<query name="ChannelFamily.findByOrgId">
<![CDATA[from com.redhat.rhn.domain.channel.ChannelFamily as cfam where cfam.org.id
= :orgId]]>
</query>
-
- <sql-query name="ChannelFamily.findLicensePath">
- <return-scalar column="LICENSE_PATH" type="string" />
- <![CDATA[
- SELECT
- LICENSE_PATH
- FROM
- RHNCHANNELFAMILYLICENSE
- WHERE
- CHANNEL_FAMILY_ID = :id
- ]]>
- </sql-query>
</hibernate-mapping>
diff --git a/java/code/src/com/redhat/rhn/domain/channel/ChannelFamilyFactory.java
b/java/code/src/com/redhat/rhn/domain/channel/ChannelFamilyFactory.java
index f414335..5a39bc9 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/ChannelFamilyFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/channel/ChannelFamilyFactory.java
@@ -203,17 +203,5 @@ public class ChannelFamilyFactory extends HibernateFactory {
Restrictions.isNull("org")));
return c.list();
}
-
- /**
- * Returns the license-path for this channel-family, if one exists.
- * @param cid Channel-Family-Id whose license we're looking forl we want.
- * @return String containing the license-text pathm or null if not found
- */
- public static String lookupLicense(Long cid) {
- Map params = new HashMap();
- params.put("id", cid);
- return (String) singleton.lookupObjectByNamedQuery(
- "ChannelFamily.findLicensePath", params);
- }
}
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java
index 6421bef..58557cc 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java
@@ -685,8 +685,7 @@ public class SystemHandler extends BaseHandler {
channel.put("label", row.get("label"));
channel.put("name", row.get("name"));
channel.put("summary", row.get("summary"));
- channel.put("has_license", StringUtils.defaultString(
- (String) row.get("has_license")));
+ channel.put("has_license", "");
channel.put("gpg_key_url", StringUtils.defaultString(
(String) row.get("gpg_key_url")));
diff --git a/java/code/webapp/WEB-INF/nav/channel_detail.xml
b/java/code/webapp/WEB-INF/nav/channel_detail.xml
index 991bef8..7178253 100644
--- a/java/code/webapp/WEB-INF/nav/channel_detail.xml
+++ b/java/code/webapp/WEB-INF/nav/channel_detail.xml
@@ -31,6 +31,5 @@
<rhn-tab-url>/rhn/channels/TargetSystemsConfirm.do</rhn-tab-url>
</rhn-tab>
<rhn-tab name="Downloads" acl="org_is_paying_customer();
channel_has_downloads()" url="/rhn/software/channel/downloads/Download.do"
/>
- <rhn-tab name="License" acl="channel_licensed()"
url="/network/software/channels/display_license.pxt" />
</rhn-navi-tree>
diff --git a/java/code/webapp/WEB-INF/nav/system_detail.xml
b/java/code/webapp/WEB-INF/nav/system_detail.xml
index ea57a2f..2b6c4c9 100644
--- a/java/code/webapp/WEB-INF/nav/system_detail.xml
+++ b/java/code/webapp/WEB-INF/nav/system_detail.xml
@@ -79,7 +79,6 @@
<rhn-tab name="Software Channels"
acl="system_feature(ftr_package_updates)">
<rhn-tab-url>/rhn/systems/details/SystemChannels.do</rhn-tab-url>
-
<rhn-tab-url>/network/systems/details/channel_license.pxt</rhn-tab-url>
</rhn-tab>
</rhn-tab>
diff --git a/web/conf/rhn_web.conf b/web/conf/rhn_web.conf
index 4e94b63..b032acf 100644
--- a/web/conf/rhn_web.conf
+++ b/web/conf/rhn_web.conf
@@ -15,9 +15,6 @@ web.post_max = 512000
# host bounces should be set to
-# Location of external channel family licenses (ex. BEA JRockit, etc)
-web.channel_licenses_path =
-
# offset for the database's timezone from utc
web.db_tz_offset = 0
diff --git a/web/html/nav/channel_detail.xml b/web/html/nav/channel_detail.xml
index 0a92216..b0c0864 100644
--- a/web/html/nav/channel_detail.xml
+++ b/web/html/nav/channel_detail.xml
@@ -29,6 +29,5 @@
<rhn-tab-url>/network/software/channels/target_systems.pxt</rhn-tab-url>
</rhn-tab>
<rhn-tab name="Downloads" acl="org_is_paying_customer();
channel_has_downloads()" url="/rhn/software/channel/downloads/Download.do"
/>
- <rhn-tab name="License" acl="channel_licensed()"
url="/network/software/channels/display_license.pxt" />
</rhn-navi-tree>
diff --git a/web/html/nav/system_detail.xml b/web/html/nav/system_detail.xml
index 86987bf..216426c 100644
--- a/web/html/nav/system_detail.xml
+++ b/web/html/nav/system_detail.xml
@@ -78,7 +78,6 @@
<rhn-tab name="Software Channels"
acl="system_feature(ftr_package_updates)">
<rhn-tab-url>/rhn/systems/details/SystemChannels.do</rhn-tab-url>
-
<rhn-tab-url>/network/systems/details/channel_license.pxt</rhn-tab-url>
</rhn-tab>
</rhn-tab>
diff --git a/web/html/network/software/channels/display_license.pxt
b/web/html/network/software/channels/display_license.pxt
deleted file mode 100644
index 82163b5..0000000
--- a/web/html/network/software/channels/display_license.pxt
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf8"?>
-<pxt-passthrough>
- <pxt-use class="Grail::Frame" />
- <pxt-use class="Sniglets::Channel" />
- <pxt-use class="Sniglets::Users" />
- <pxt-use class="Sniglets::Lists" />
- <pxt-use class="Sniglets::Navi" />
- <pxt-use class="Sniglets::HTML" />
- <pxt-use class="Sniglets::ChannelLicense" />
-
- <grail-canvas-template base="/templates/c.pxt"
mode="main_canvas">
-
-<rhn-channel-license-details>
- <h1><img src="/img/rhn-icon-channels.gif" /> {channel_name}
<rhn-help href="s1-sm-channels-packages.jsp#s3-sm-channel-details"
/></h1>
-
- <rhn-navi-nav prefix="channel_details" depth="0"
file="/nav/channel_detail.xml" style="contentnav" />
-
- <h2>Channel License</h2>
-
- <div class="page-summary">
- <p>
- The following license agreement must be accepted for each system
- subscribed to this channel.
- </p>
-
- <pre>{channel_license}</pre>
-
-</div>
-
-</rhn-channel-license-details>
- </grail-canvas-template>
-</pxt-passthrough>
-
diff --git a/web/html/network/systems/details/channel_license.pxt
b/web/html/network/systems/details/channel_license.pxt
deleted file mode 100644
index 234530b..0000000
--- a/web/html/network/systems/details/channel_license.pxt
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="utf8"?>
-<pxt-passthrough>
- <pxt-use class="Grail::Frame" />
- <pxt-use class="Sniglets::ChannelLicense" />
- <pxt-use class="Sniglets::Users" />
- <pxt-use class="Sniglets::Servers" />
-
- <pxt-use class="Sniglets::HTML" />
-
- <grail-canvas-template base="/templates/c.pxt"
mode="main_canvas">
-<pxt-formvar>
- <pxt-include-late
file="/network/components/systems/system_details_toolbar.pxi" />
-</pxt-formvar>
-
- <rhn-navi-nav prefix="system_details" depth="0"
file="/nav/system_detail.xml" style="contentnav" />
-
-
-<rhn-channel-license-dialog>
- <h2>End User License Agreement for
<strong>{channel_name}</strong></h2>
-
- <div class="page-summary">
- <p>You must agree to the following EULA before you may subscribe the selected
systems to this channel:</p>
- <br />
- <pre>{channel_license}</pre>
- <br />
- </div>
-
-<pxt-include-late file="/network/components/message_queues/local.pxi" />
-
- <pxt-form method="POST">
- <div align="right">
- <hr />
- <input type="submit" name="cancel"
value="Cancel" />
- <input type="submit" name="accept"
value="Accept" />
- <input type="hidden" name="pxt:trap"
value="rhn:channel_license_dialog_cb" />
- <input type="hidden" name="sdc" value="1" />
- <input type="hidden" name="cid"
value="{channel_id}" />
- {additional_channels}
- <pxt-hidden name="sid" />
- </div>
- </pxt-form>
-</rhn-channel-license-dialog>
-
- </grail-canvas-template>
-</pxt-passthrough>
diff --git a/web/html/network/systems/ssm/channels/alter_subscriptions_conf.pxt
b/web/html/network/systems/ssm/channels/alter_subscriptions_conf.pxt
deleted file mode 100644
index b45e4d0..0000000
--- a/web/html/network/systems/ssm/channels/alter_subscriptions_conf.pxt
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf8"?>
-<pxt-passthrough>
- <pxt-use class="Grail::Frame" />
- <pxt-use class="Sniglets::ListUtils" />
- <pxt-use class="Sniglets::Channel" />
- <pxt-use class="Sniglets::Lists" />
- <pxt-use class="Sniglets::HTML" />
-
-
- <grail-canvas-template base="/templates/c.pxt"
mode="main_canvas">
-
- <h1><img src="/img/rhn-icon-system_group.gif" alt="system
set" /> System Set Manager <rhn-help
href="s1-sm-systems.jsp#s2-sm-ssm" /></h1>
-
- <rhn-navi-nav prefix="system_set_manager" depth="0"
- file="/nav/ssm.xml" style="contentnav" />
-
-
-<h2>Alter Channel Subscriptions Confirmation</h2>
-
-<p>Below is a per system summary of the channel subscription changes
-that will occur.</p>
-
-<rhn-listview class="Sniglets::ListView::SystemList"
mode="ssm_channel_change_conf">
- <empty_list_message>
- No systems would be affected by your channel subscription choices.
- </empty_list_message>
-
- <column name="Name" label="server_name"
align="left"/>
-
- <column name="To Subscribe" label="channels_to_subscribe"
align="left"/>
- <column name="To Unsubscribe" label="channels_to_unsubscribe"
- align="left"/>
-
- <action name="Change Subscriptions"
label="ssm_change_channel_subscriptions" />
-</rhn-listview>
-
-
- </grail-canvas-template>
-
-</pxt-passthrough>
diff --git a/web/modules/rhn/RHN/Access/Channel.pm
b/web/modules/rhn/RHN/Access/Channel.pm
index 245c357..dcdad72 100644
--- a/web/modules/rhn/RHN/Access/Channel.pm
+++ b/web/modules/rhn/RHN/Access/Channel.pm
@@ -30,7 +30,6 @@ sub register_acl_handlers {
$acl->register_handler(channel_exists => \&channel_exists);
$acl->register_handler(channel_accessible => \&channel_accessible);
$acl->register_handler(base_channel => \&channel_is_base);
- $acl->register_handler(channel_licensed => \&channel_is_licensed);
$acl->register_handler(channel_eoled => \&channel_eoled);
$acl->register_handler(org_owns_cloned_channels =>
\&org_owns_cloned_channels);
$acl->register_handler(org_channel_setting => \&org_channel_setting);
@@ -163,17 +162,6 @@ sub channel_is_proxy {
return 1;
}
-sub channel_is_licensed {
- my $pxt = shift;
-
- my $cid = $pxt->param('cid');
- throw 'no cid param' unless $cid;
-
- return 0 unless (RHN::Channel->license_path($cid));
-
- return 1;
-}
-
sub channel_subscribable {
my $pxt = shift;
diff --git a/web/modules/rhn/RHN/DB/Channel.pm b/web/modules/rhn/RHN/DB/Channel.pm
index bd14e1d..3ba753e 100644
--- a/web/modules/rhn/RHN/DB/Channel.pm
+++ b/web/modules/rhn/RHN/DB/Channel.pm
@@ -147,25 +147,6 @@ sub is_protected {
return ($self->channel_access() eq 'protected') ? 1 : 0;
}
-sub license_path {
- my $self = shift;
- my $cid;
-
- if (ref $self) {
- $cid = $self->id;
- }
- else {
- $cid = shift;
- }
-
- undef $self;
- die "No channel id" unless defined $cid;
-
- my $dbh = RHN::DB->connect;
-
- return $dbh->call_function('rhn_channel.get_license_path', $cid);
-}
-
sub parent {
my $self = shift;
my $channel = shift;
@@ -343,7 +324,6 @@ sub proxy_channels_by_version {
return @{$proxy_chans_by_version{$params{version}}};
}
-
sub has_downloads {
my $class = shift;
my $cid = shift;
diff --git a/web/modules/rhn/RHN/DB/DataSource/xml/Channel_queries.xml
b/web/modules/rhn/RHN/DB/DataSource/xml/Channel_queries.xml
index ad7fb93..5167e45 100644
--- a/web/modules/rhn/RHN/DB/DataSource/xml/Channel_queries.xml
+++ b/web/modules/rhn/RHN/DB/DataSource/xml/Channel_queries.xml
@@ -341,7 +341,6 @@ ORDER BY rhn_channel.channel_priority(ACh.parent_or_self_id),
ACh.parent_or_self
<mode name="token_channels_tree">
<query params="org_id">
SELECT ACh.channel_name NAME, ACh.channel_id ID, ACh.channel_depth AS DEPTH,
- rhn_channel.get_license_path(ACh.channel_id) LICENSE_PATH,
NVL(C.org_id, 0) ORG_ID, C.parent_channel,
(SELECT CF.label
FROM rhnChannelFamilyMembers CFM,
@@ -406,10 +405,8 @@ SELECT DISTINCT C.id,
C.label,
C.name,
C.summary,
- CFL.channel_family_id AS HAS_LICENSE,
C.gpg_key_url
- FROM rhnChannelFamilyLicense CFL,
- rhnChannelFamilyMembers CFM,
+ FROM rhnChannelFamilyMembers CFM,
rhnChannel C,
rhnUserChannel UC
WHERE UC.user_id = :user_id
@@ -419,7 +416,6 @@ SELECT DISTINCT C.id,
AND C.id = CFM.channel_id
AND C.parent_channel IS NOT NULL
AND NOT EXISTS (SELECT 1 FROM rhnServerChannel WHERE server_id = :server_id AND
channel_id = C.id)
- AND CFM.channel_family_id = CFL.channel_family_id (+)
</query>
</mode>
diff --git a/web/modules/rhn/RHN/DB/Server.pm b/web/modules/rhn/RHN/DB/Server.pm
index 1bde1f5..e1d7880 100644
--- a/web/modules/rhn/RHN/DB/Server.pm
+++ b/web/modules/rhn/RHN/DB/Server.pm
@@ -1843,20 +1843,6 @@ sub remove_entitlement {
return;
}
-sub channel_license_consent {
- my $self = shift;
- my $user_id = shift;
- my $channel_id = shift;
-
-
- my $dbh = RHN::DB->connect;
-
- $dbh->call_procedure('rhn_channel.license_consent', $channel_id, $user_id,
$self->id);
-
- # used in transaction...
- return $dbh;
-}
-
############################
# Server package functions
diff --git a/web/modules/rhn/RHN/DB/ServerActions.pm
b/web/modules/rhn/RHN/DB/ServerActions.pm
index ffe0007..89ff3d8 100644
--- a/web/modules/rhn/RHN/DB/ServerActions.pm
+++ b/web/modules/rhn/RHN/DB/ServerActions.pm
@@ -22,42 +22,6 @@ use RHN::DB ();
use Params::Validate qw/:all/;
Params::Validate::validation_options(strip_leading => "-");
-sub channel_license_consent_for_set {
- my $class = shift;
- my $set = shift;
- my $channel_id = shift;
- my $user_id = shift;
- my $transaction = shift;
-
- my $query = <<EOQ;
-INSERT INTO rhnChannelFamilyLicenseConsent (channel_family_id, user_id, server_id)
-SELECT CFM.channel_family_id, ?, SC.server_id
- FROM rhnChannelFamilyLicense CFL,
- rhnChannelFamilyMembers CFM,
- rhnServerChannel SC,
- rhnChannel C,
- rhnSet ST
- WHERE ST.user_id = ?
- AND ST.label = ?
- AND C.id = ?
- AND ST.element = SC.server_id
- AND SC.channel_id = C.parent_channel
- AND C.id = CFM.channel_id
- AND CFM.channel_family_id = CFL.channel_family_id
- AND CFL.license_path IS NOT NULL
- AND NOT EXISTS (SELECT user_id FROM rhnChannelFamilyLicenseConsent WHERE
channel_family_id = CFM.channel_family_id AND server_id = SC.server_id)
-EOQ
-
- my $dbh = RHN::DB->connect();
- my $sth = $dbh->prepare($query);
-
- $sth->execute($user_id, $user_id, $set->label, $channel_id);
-
- $dbh->commit unless $transaction;
-
- return $dbh;
-}
-
sub assign_set_to_group {
my $class = shift;
my $set = shift;
diff --git a/web/modules/sniglets/Sniglets/ActivationKeys.pm
b/web/modules/sniglets/Sniglets/ActivationKeys.pm
index 7b49c8e..15753ca 100644
--- a/web/modules/sniglets/Sniglets/ActivationKeys.pm
+++ b/web/modules/sniglets/Sniglets/ActivationKeys.pm
@@ -125,7 +125,7 @@ sub good_token_channels {
my $all_channels = $ds->execute_query(-org_id => $org_id);
#filter out channels which require a license agreement:
- my @channel_list = grep { not defined $_->{LICENSE_PATH} } @{$all_channels};
+ my @channel_list = @{$all_channels};
#filter out proxy and satellite channels:
@channel_list = grep { ($_->{CHANNEL_FAMILY_LABEL} ne 'rhn-satellite')
diff --git a/web/modules/sniglets/Sniglets/ChannelLicense.pm
b/web/modules/sniglets/Sniglets/ChannelLicense.pm
deleted file mode 100644
index 73526cd..0000000
--- a/web/modules/sniglets/Sniglets/ChannelLicense.pm
+++ /dev/null
@@ -1,346 +0,0 @@
-#
-# 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.
-#
-
-use strict;
-
-package Sniglets::ChannelLicense;
-
-use PXT::Utils;
-use RHN::Exception;
-use RHN::ServerActions;
-
-use File::Spec;
-
-sub register_tags {
- my $class = shift;
- my $pxt = shift;
-
- $pxt->register_tag("rhn-channel-license-dialog",
\&channel_license_dialog);
- $pxt->register_tag("rhn-channel-license-details",
\&channel_license_details);
-}
-
-sub register_callbacks {
- my $class = shift;
- my $pxt = shift;
-
- $pxt->register_callback("rhn:channel_license_dialog_cb",
\&channel_license_dialog_cb);
-}
-
-sub get_license {
- my $channel = shift;
-
- my $license_path =
File::Spec->catfile(PXT::Config->get('channel_licenses_path'),
$channel->license_path);
-
-
- PXT::Debug->log(7, "license path: $license_path");
-
-# warn "license_path: '$license_path'\n";
-# warn "no_upwards results: " . join(', ',
File::Spec::Unix->no_upwards($license_path));
-# warn "is_absolute_path: " .
File::Spec::Unix->file_name_is_absolute($license_path);
-
- if ($license_path =~ m{\.\./}) {
- throw "DON'T PUT ../'s IN THE CHANNEL LICENSE PATH! License path:
$license_path";
- }
-
- if (! -e $license_path) {
- throw "channel license missing: " . $license_path;
- }
-
- open MYFILE, ($license_path) || throw "could not open file: " .
$license_path;
-
- my $f = join('', <MYFILE>);
-
- close MYFILE;
-
- return $f;
-}
-
-sub channel_license_details {
- my $pxt = shift;
- my %params = @_;
-
- my %subst;
- my $block = $params{__block__};
-
- $subst{channel_id} = $pxt->param('cid');
- throw "no cid" unless (defined $subst{channel_id});
-
- my $channel = RHN::Channel->lookup(-id => $subst{channel_id});
- throw "no channel" unless ($channel);
- $subst{channel_name} = $channel->name();
-
- $subst{channel_license} = get_license($channel);
- throw "no license" unless (defined $subst{channel_license});
-
- return PXT::Utils->perform_substitutions($block, \%subst);
-}
-
-sub channel_license_dialog {
- my $pxt = shift;
- my %params = @_;
-
- my $block = $params{__block__};
-
- my $cid = $pxt->param('current_channel');
-
- if (not $cid and $pxt->dirty_param('cdc')) {
- $cid = $pxt->param('cid');
- }
-
- throw "no cid" unless ($cid);
-
- my $channel = RHN::Channel->lookup(-id => $cid);
- throw "no channel" unless ($channel);
-
- my $channel_name = $channel->name;
-
- if (not $pxt->user->verify_channel_subscribe($cid)) {
- my $error_msg = <<EOM;
-You no longer have subscription permission to the $channel_name channel.
-EOM
- $pxt->push_message(local_alert => $error_msg);
-
- my $sid = $pxt->param('sid');
-
- if ($sid) {
- $pxt->redirect("/network/systems/details/channels.pxt?sid=$sid");
- }
- elsif ($pxt->dirty_param('cdc')) {
- $pxt->redirect("/network/software/channels/details.pxt?cid=$cid");
- }
-
- $pxt->redirect("/network/systems/ssm/channels/index.pxt");
- }
-
- my $license = get_license($channel) || '';
-
- my @additional_channels = $pxt->param('additional_channel');
- my $additional_channels_str = '';
-
- if (@additional_channels) {
- $additional_channels_str = PXT::HTML->hidden(-name =>
'current_channel', -value => $additional_channels[0]);
-
- if (@additional_channels > 1) {
- foreach my $xtra_cid (@additional_channels[1..-1]) {
- $additional_channels_str .= "\n" . PXT::HTML->hidden(-name =>
"additional_channel", -value => $xtra_cid);
- }
- }
- }
-
- my %subs;
-
- $subs{channel_license} = $license;
- $subs{channel_name} = $channel->name;
- $subs{channel_id} = $cid;
-
- PXT::Utils->escapeHTML_multi(\%subs);
-
- $subs{additional_channels} = $additional_channels_str; # don't escape me
-
- $block = PXT::Utils->perform_substitutions($block, \%subs);
- return $block;
-}
-
-sub channel_license_dialog_cb {
- my $pxt = shift;
-
- my $sid = $pxt->param('sid');
- my $system_set;
- my $server;
- my $channel_set;
- my $system_entitlement;
-
- if ($sid) {
- $server = RHN::Server->lookup(-id => $sid);
- $system_entitlement = $server->is_entitled;
- }
- else {
- my $set_label = $pxt->dirty_param('set_label') || 'system_list';
- $system_set = RHN::Set->new($set_label, $pxt->user->id);
- }
-
- my $cid = $pxt->param('cid');
- throw "no channel id to subscribe to..." unless ($cid);
- my $channel = RHN::Channel->lookup(-id => $cid);
- throw "no channel" unless ($channel);
-
- my $channel_name = $channel->name;
-
- if (not $pxt->user->verify_channel_subscribe($cid)) {
- my $error_msg = <<EOM;
-You no longer have subscription permission to the $channel_name channel.
-EOM
- $pxt->push_message(local_alert => $error_msg);
-
- if ($sid) {
- $pxt->redirect("/network/systems/details/channels.pxt?sid=$sid");
- }
- elsif ($pxt->dirty_param('cdc')) {
- $pxt->redirect("/network/software/channels/details.pxt?cid=$cid");
- }
-
- $pxt->redirect("/network/systems/ssm/channels/index.pxt");
- }
-
-
- if ($pxt->dirty_param('accept')) {
-
- eval {
- my $transaction;
-
- if ($server) {
- $transaction = $server->channel_license_consent($pxt->user->id,
$channel->id, $transaction);
- $transaction = $server->subscribe_to_channel($channel->label, $transaction);
-
- # hrm. w/out heavily rearchitecting eula's, gotta snapshot each acceptance...
- if ($server->has_feature('ftr_snapshotting')) {
- $transaction = RHN::Server->snapshot_server(-server_id => $server->id,
- -reason => "Channel subscription alterations",
- -transaction => $transaction);
- }
-
- }
- else {
-
- # handle stupid case of multiple licenses, hitting cancel for one, going back, and
accepting...
- if ($pxt->dirty_param('ssm')) {
-
- $channel_set = RHN::Set->new('channel_list', $pxt->user->id);
-
- unless ($channel_set->contains($cid)) {
- $channel_set->add("$cid|1");
- $channel_set->commit;
- }
- }
-
- $transaction = RHN::ServerActions->channel_license_consent_for_set($system_set,
$channel->id, $pxt->user->id, $transaction);
-
- # in this case, don't actually subscribe to the channel, this will be handled
later.
- # might have to worry about giving consent w/out subscribing to channel.
- #$transaction = RHN::ServerActions->subscribe_set_to_channel($system_set,
$channel->id, $transaction);
- }
-
- $transaction->commit;
-
- if ($server) {
- $pxt->push_message(site_info => "<strong>" . $server->name .
"</strong> subscribed to <strong>" . $channel->name .
"</strong>");
- }
- };
-
-
- if ($@) {
- my $E = $@;
- PXT::Debug->log(9, "error: $E");
- if (ref $E and catchable($E)) {
- if ($E->is_rhn_exception('channel_family_no_subscriptions')) {
- $pxt->push_message(local_alert => "This assignment would exceed your
allowed subscriptions in one or more channels.");
- return;
- }
- elsif ($E->constraint_value eq 'RHN_CFL_CONSENT_CF_S_UQ'){
- # consent was given to the channel family for the server through another channel...
- # do everything except ignore the license consent stuff
- PXT::Debug->log(7, "passing through consent because consent was already given
for " . $channel->id);
-
- eval {
- if ($server) {
- $server->subscribe_to_channel($channel->label);
-
- if ($server->has_feature('ftr_snapshotting')) {
- RHN::Server->snapshot_server(-server_id => $server->id,
- -reason => "Channel subscription alterations",
- );
- }
-
- }
- else {
- if ($pxt->dirty_param('ssm')) {
-
- $channel_set = RHN::Set->new('channel_list', $pxt->user->id);
-
- unless ($channel_set->contains($cid)) {
- $channel_set->add("$cid|1");
- $channel_set->commit;
- }
- }
- RHN::ServerActions->channel_license_consent_for_set($system_set,
$channel->id, $pxt->user->id);
- }
- };
-
- if ($@) {
-
- my $E = $@;
-
- # this is happening with people trying to subscribe to k12ltsp channel + general edu
channel...
- if (ref $E and catchable($E)) {
- if ($E->is_rhn_exception('channel_family_no_subscriptions')) {
- $pxt->push_message(local_alert => "Could not subscribe to " .
$channel->name . "; insufficient channel entitlements");
- }
- }
- else {
- die $@;
- }
- }
- }
- else {
- throw $E;
- }
- }
- else {
- PXT::Debug->log_dump(7, $E);
- die $E;
- }
- }
- }
- elsif ($pxt->dirty_param('cancel')) {
-
- PXT::Debug->log(7, "cancel...");
-
- if ($pxt->dirty_param('cdc')) {
- $pxt->redirect("/rhn/channels/TargetSystems.do?cid=$cid");
- }
-
- if ($system_set) {
- # remove the current channel from the channel list
-
- $channel_set = RHN::Set->new('channel_list', $pxt->user->id);
-
- $channel_set->remove("$cid|1");
- $channel_set->commit;
- }
- }
-
- PXT::Debug->log(7, "are we done?");
-
- # canceled, if there aren't any other eulas to deal with, return to system channel
list?
- if (not $pxt->param('current_channel')) {
- if ($server) {
- $pxt->redirect("/network/systems/details/channels.pxt?sid=$sid");
- }
- elsif ($pxt->dirty_param('ssm')) {
-
$pxt->redirect("/network/systems/ssm/channels/alter_subscriptions_conf.pxt");
- }
- elsif ($pxt->dirty_param('cdc')) {
-
$pxt->redirect(sprintf("/network/software/channels/subscribe_confirm.pxt?cid=%d&set_label=%s",
$pxt->param('cid'), $pxt->dirty_param('set_label')));
- }
- else {
- die "shouldn't have gotten here...";
- }
- }
- else {
- warn "current channel: " . $pxt->param('current_channel');
- }
-}
-
-1;