Changes to 'refs/tags/spacewalk-repo-2.1.0-2'
by Michael Mraka
Tag 'spacewalk-repo-2.1.0-2' created by Michael Mraka <michael.mraka(a)redhat.com> at 2014-01-22 12:26 +0000
Tagging package [spacewalk-repo] version [2.1.0-2] in directory [spec-tree/spacewalk-repo/].
Changes since spacewalk-schema-2.1.37-1:
Johannes Renner (1):
SUSE Studio API will stop working via unencrypted HTTP
Michael Calmer (2):
port reboot_confirm.pxt from perl to java
remove unused perl code after porting reboot_confirm.pxt to java
Michael Mraka (2):
make spacewalk*.repo on Fedora more generic
Automatic commit of package [spacewalk-repo] minor release [2.1.0-2].
---
java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemRebootAction.java | 88 ++++++++++
java/code/src/com/redhat/rhn/frontend/action/user/UserCredentialsEditAction.java | 2
java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml | 24 ++
java/code/webapp/WEB-INF/nav/system_detail.xml | 2
java/code/webapp/WEB-INF/pages/systems/sdc/overview.jsp | 4
java/code/webapp/WEB-INF/pages/systems/sdc/rebootsystem.jsp | 52 +++++
java/code/webapp/WEB-INF/struts-config.xml | 13 +
rel-eng/packages/spacewalk-repo | 2
spec-tree/spacewalk-repo/spacewalk-repo.spec | 7
web/html/network/systems/details/reboot_confirm.pxt | 39 ----
web/include/nav/system_detail.xml | 2
web/modules/rhn/RHN/DB/Scheduler.pm | 22 --
web/modules/sniglets/Sniglets/Servers.pm | 26 --
13 files changed, 188 insertions(+), 95 deletions(-)
---
10 years, 4 months
2 commits - rel-eng/packages spec-tree/spacewalk-repo
by Michael Mraka
rel-eng/packages/spacewalk-repo | 2 +-
spec-tree/spacewalk-repo/spacewalk-repo.spec | 7 +++++--
2 files changed, 6 insertions(+), 3 deletions(-)
New commits:
commit 32e619b29e20184e175bd6b96cd22c68bcda8550
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Jan 22 13:26:20 2014 +0100
Automatic commit of package [spacewalk-repo] minor release [2.1.0-2].
diff --git a/rel-eng/packages/spacewalk-repo b/rel-eng/packages/spacewalk-repo
index 15638f6..9165e95 100644
--- a/rel-eng/packages/spacewalk-repo
+++ b/rel-eng/packages/spacewalk-repo
@@ -1 +1 @@
-2.1.0-1 spec-tree/spacewalk-repo/
+2.1.0-2 spec-tree/spacewalk-repo/
diff --git a/spec-tree/spacewalk-repo/spacewalk-repo.spec b/spec-tree/spacewalk-repo/spacewalk-repo.spec
index b9568e6..2cfcd3e 100644
--- a/spec-tree/spacewalk-repo/spacewalk-repo.spec
+++ b/spec-tree/spacewalk-repo/spacewalk-repo.spec
@@ -1,7 +1,7 @@
Summary: Spacewalk packages yum repository configuration
Name: spacewalk-repo
Version: 2.1.0
-Release: 1%{?dist}
+Release: 2%{?dist}
License: GPLv2
Group: System Environment/Base
# This src.rpm is cannonical upstream
@@ -96,6 +96,9 @@ rm -rf $RPM_BUILD_ROOT
%config(noreplace) %{_sysconfdir}/yum.repos.d/spacewalk-client-nightly.repo
%changelog
+* Wed Jan 22 2014 Michael Mraka <michael.mraka(a)redhat.com> 2.1.0-2
+- make spacewalk*.repo on Fedora more generic
+
* Thu Jul 18 2013 Tomas Kasparek <tkasparek(a)redhat.com> 2.1.0-1
- Bumping package versions for 2.1.
commit 5163fc82a68f5160aac8ae806ef830449940f2ce
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Jan 22 13:17:22 2014 +0100
make spacewalk*.repo on Fedora more generic
diff --git a/spec-tree/spacewalk-repo/spacewalk-repo.spec b/spec-tree/spacewalk-repo/spacewalk-repo.spec
index df51f3e..b9568e6 100644
--- a/spec-tree/spacewalk-repo/spacewalk-repo.spec
+++ b/spec-tree/spacewalk-repo/spacewalk-repo.spec
@@ -34,7 +34,7 @@ rm -rf $RPM_BUILD_ROOT
# some sane default value
%define reposubdir RHEL/%{rhel}
# redefine on fedora
-%{?fedora: %define reposubdir Fedora/%{fedora}}
+%{?fedora: %define reposubdir Fedora/\$releasever}
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/yum.repos.d
cat >>$RPM_BUILD_ROOT%{_sysconfdir}/yum.repos.d/spacewalk.repo <<REPO
10 years, 4 months
2 commits - java/code web/html web/include web/modules
by mkollar
java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemRebootAction.java | 88 ++++++++++
java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml | 24 ++
java/code/webapp/WEB-INF/nav/system_detail.xml | 2
java/code/webapp/WEB-INF/pages/systems/sdc/overview.jsp | 4
java/code/webapp/WEB-INF/pages/systems/sdc/rebootsystem.jsp | 52 +++++
java/code/webapp/WEB-INF/struts-config.xml | 13 +
web/html/network/systems/details/reboot_confirm.pxt | 39 ----
web/include/nav/system_detail.xml | 2
web/modules/rhn/RHN/DB/Scheduler.pm | 22 --
web/modules/sniglets/Sniglets/Servers.pm | 26 --
10 files changed, 181 insertions(+), 91 deletions(-)
New commits:
commit 6a11236104d95e085c676f522f73ec2858b52e12
Author: Michael Calmer <mc(a)suse.de>
Date: Thu Jan 16 17:20:53 2014 +0100
remove unused perl code after porting reboot_confirm.pxt to java
diff --git a/web/html/network/systems/details/reboot_confirm.pxt b/web/html/network/systems/details/reboot_confirm.pxt
deleted file mode 100644
index 898ff1f..0000000
--- a/web/html/network/systems/details/reboot_confirm.pxt
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf8"?>
-<pxt-passthrough>
-
-<pxt-use class="Grail::Frame" />
-<pxt-use class="Sniglets::Servers" />
-<pxt-use class="Sniglets::Sets" />
-<pxt-use class="Sniglets::HTML" />
-<pxt-use class="Sniglets::ServerActions" />
-
-
-<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" file="/nav/system_detail.xml" style="contentnav" />
-
-<pxt-include-late file="/network/components/message_queues/local.pxi" />
-
-<rhn-up2date-at-least version="2.9.3" release="2.2.1AS">
-
-<h2>System Reboot Confirmation</h2>
-
-<p>This will schedule a reboot of this system.</p>
-
-
-<pxt-form method="post">
-<p>If you are <strong>certain</strong> you wish to do this, you may schedule the reboot to take place as soon as possible, or no earlier than a specified time:</p>
-
-<rhn-schedule-action-interface action="schedule_errata_updates" callback="rhn:reboot_server_cb" label="Schedule Reboot" />
-
-<pxt-hidden name="sid" />
-
-</pxt-form>
-
-</rhn-up2date-at-least>
-
-</grail-canvas-template>
-</pxt-passthrough>
diff --git a/web/modules/rhn/RHN/DB/Scheduler.pm b/web/modules/rhn/RHN/DB/Scheduler.pm
index a23043f..cf190db 100644
--- a/web/modules/rhn/RHN/DB/Scheduler.pm
+++ b/web/modules/rhn/RHN/DB/Scheduler.pm
@@ -175,28 +175,6 @@ EOQ
}
}
-
-sub schedule_reboot {
- my $class = shift;
- my %params = @_;
-
- my ($org_id, $user_id, $server_set, $server_id, $earliest, $prerequisite, $transaction) =
- map { $params{"-" . $_} } qw/org_id user_id server_set server_id earliest prerequisite transaction/;
-
- my ($action_id, $stat_id) = $class->make_base_action(-org_id => $org_id,
- -user_id => $user_id,
- -type_label => 'reboot.reboot',
- -earliest => $earliest,
- -prerequisite => $prerequisite,
- -transaction => $transaction);
-
- $class->add_servers_to_action($action_id, $stat_id, $user_id, $server_set, $server_id);
-
- osa_wakeup_tickle();
-
- return $action_id;
-}
-
sub sscd_schedule_reboot {
my $class = shift;
my %params = @_;
diff --git a/web/modules/sniglets/Sniglets/Servers.pm b/web/modules/sniglets/Sniglets/Servers.pm
index 792dd3d..13a03e3 100644
--- a/web/modules/sniglets/Sniglets/Servers.pm
+++ b/web/modules/sniglets/Sniglets/Servers.pm
@@ -71,8 +71,6 @@ sub register_callbacks {
my $class = shift;
my $pxt = shift;
- $pxt->register_callback('rhn:reboot_server_cb' => \&reboot_server_cb);
-
$pxt->register_callback('rhn:server_prefs_form_cb' => \&server_prefs_form_cb);
$pxt->register_callback('rhn:ssm_change_system_prefs_cb' => \&ssm_change_system_prefs_cb);
@@ -313,30 +311,6 @@ sub server_history_event_details {
return $params{__block__};
}
-sub reboot_server_cb {
- my $pxt = shift;
- my $sid = $pxt->param('sid');
- die "no server id" unless $sid;
-
- my $server = RHN::Server->lookup(-id => $sid);
- die "no server obj" unless $server;
-
- my $earliest_date = Sniglets::ServerActions->parse_date_pickbox($pxt);
- my $action_id = RHN::Scheduler->schedule_reboot(-org_id => $pxt->user->org_id,
- -user_id => $pxt->user->id,
- -earliest => $earliest_date,
- -server_id => $sid);
-
-
- my $pretty_earliest_date = $pxt->user->convert_time($earliest_date);
-# my $message = sprintf(<<EOM, $server->name, $server->name, $action_id);
-#Reboot scheduled for system <strong>%s</strong> for $pretty_earliest_date. To cancel the reboot, remove <strong>%s</strong> from <a href="/rhn/schedule/InProgressSystems.do?aid=%d"><strong>the list of systems to be rebooted</strong></a>.
-#EOM
-#
-# $pxt->push_message(site_info => $message);
- $pxt->redirect("/rhn/systems/details/Overview.do?sid=$sid&message=system.reboot.scheduled&messagep1=" . $server->name . "&messagep2=" . $pretty_earliest_date . "&messagep3=" . $action_id);
-}
-
my @user_server_prefs = ( { name => 'receive_notifications',
label => 'Receive Notifications of Updates/Errata' },
{ name => 'include_in_daily_summary',
commit c98ed65274570d849a93c732b9082a353c4c861f
Author: Michael Calmer <mc(a)suse.de>
Date: Thu Jan 16 14:08:11 2014 +0100
port reboot_confirm.pxt from perl to java
diff --git a/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemRebootAction.java b/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemRebootAction.java
new file mode 100644
index 0000000..5e4c998
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemRebootAction.java
@@ -0,0 +1,88 @@
+/**
+ * Copyright (c) 2014 SUSE
+ *
+ * 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.
+ */
+package com.redhat.rhn.frontend.action.systems.sdc;
+
+import com.redhat.rhn.common.util.DatePicker;
+import com.redhat.rhn.domain.action.Action;
+import com.redhat.rhn.domain.action.ActionFactory;
+import com.redhat.rhn.domain.server.Server;
+import com.redhat.rhn.domain.user.User;
+import com.redhat.rhn.frontend.struts.RequestContext;
+import com.redhat.rhn.frontend.struts.RhnAction;
+import com.redhat.rhn.frontend.struts.RhnHelper;
+import com.redhat.rhn.manager.action.ActionManager;
+import com.redhat.rhn.manager.system.SystemManager;
+
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.DynaActionForm;
+
+import java.util.Date;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * SystemRebootAction handles the interaction of the system reboot.
+ */
+public class SystemRebootAction extends RhnAction {
+ /** Success forward name. */
+ private static final String CONFIRM_FORWARD = "confirm";
+
+ /** {@inheritDoc} */
+ @Override
+ @SuppressWarnings("unchecked")
+ public ActionForward execute(ActionMapping mapping, ActionForm formIn,
+ HttpServletRequest request, HttpServletResponse response) {
+
+ DynaActionForm form = (DynaActionForm) formIn;
+ RequestContext context = new RequestContext(request);
+ User user = context.getLoggedInUser();
+ Map<String, Object> params = (Map<String, Object>) makeParamMap(request);
+ String forward = RhnHelper.DEFAULT_FORWARD;
+
+ Long sid = context.getRequiredParam(RequestContext.SID);
+ Server server = SystemManager.lookupByIdAndUser(sid, user);
+
+ if (isSubmitted(form)) {
+ Date earliest = getStrutsDelegate().readDatePicker((DynaActionForm) formIn,
+ "date", DatePicker.YEAR_RANGE_POSITIVE);
+ Action action = ActionManager.scheduleRebootAction(user, server, earliest);
+ ActionFactory.save(action);
+
+ String[] messageParams = new String[3];
+ messageParams[0] = server.getName();
+ messageParams[1] = earliest.toString();
+ messageParams[2] = action.getId().toString();
+ createMessage(request, "system.reboot.scheduled", messageParams);
+
+ // goes to sdc/overview.jsp
+ params.put(RequestContext.SID, sid);
+ forward = CONFIRM_FORWARD;
+ }
+
+ DatePicker picker = getStrutsDelegate().prepopulateDatePicker(request, form,
+ "date", DatePicker.YEAR_RANGE_POSITIVE);
+ request.setAttribute("date", picker);
+ request.setAttribute(RequestContext.SID, sid);
+ request.setAttribute("system", server);
+
+ SdcHelper.ssmCheck(request, server.getId(), user);
+
+ return getStrutsDelegate().forwardParams(mapping.findForward(forward), params);
+ }
+}
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
index c4cdf75..62ec065 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
@@ -5130,6 +5130,30 @@ value for this entitlement, excluding the default organization's consumption.</s
<context context-type="sourcefile">/rhn/systems/SystemGroupList</context>
</context-group>
</trans-unit>
+ <trans-unit id="reboot.jsp.header">
+ <source>System Reboot Confirmation</source>
+ <context-group name="ctx">
+ <context context-type="sourcefile">/rhn/systems/details/RebootSystem</context>
+ </context-group>
+ </trans-unit>
+ <trans-unit id="reboot.jsp.summary">
+ <source>This will schedule a reboot of this system.</source>
+ <context-group name="ctx">
+ <context context-type="sourcefile">/rhn/systems/details/RebootSystem</context>
+ </context-group>
+ </trans-unit>
+ <trans-unit id="reboot.jsp.widgetsummary">
+ <source>If you are <strong>certain</strong> you wish to do this, you may schedule the reboot to take place after a specified time:</source>
+ <context-group name="ctx">
+ <context context-type="sourcefile">/rhn/systems/details/RebootSystem</context>
+ </context-group>
+ </trans-unit>
+ <trans-unit id="reboot.jsp.confirm">
+ <source>Reboot system</source>
+ <context-group name="ctx">
+ <context context-type="sourcefile">/rhn/systems/details/RebootSystem</context>
+ </context-group>
+ </trans-unit>
<!--- System Duplicates pages -->
<group>
<context-group name="ctx">
diff --git a/java/code/webapp/WEB-INF/nav/system_detail.xml b/java/code/webapp/WEB-INF/nav/system_detail.xml
index 6c20453..5261dec 100644
--- a/java/code/webapp/WEB-INF/nav/system_detail.xml
+++ b/java/code/webapp/WEB-INF/nav/system_detail.xml
@@ -4,7 +4,7 @@
<rhn-tab name="Details" url="/rhn/systems/details/Overview.do">
<rhn-tab name="Overview">
<rhn-tab-url>/rhn/systems/details/Overview.do</rhn-tab-url>
- <rhn-tab-url>/network/systems/details/reboot_confirm.pxt</rhn-tab-url>
+ <rhn-tab-url>/rhn/systems/details/RebootSystem.do</rhn-tab-url>
</rhn-tab>
<rhn-tab name="Properties" url="/rhn/systems/details/Edit.do" />
<rhn-tab name="Remote Command" acl="system_feature(ftr_remote_command)">
diff --git a/java/code/webapp/WEB-INF/pages/systems/sdc/overview.jsp b/java/code/webapp/WEB-INF/pages/systems/sdc/overview.jsp
index ce473c4..0dc87b4 100644
--- a/java/code/webapp/WEB-INF/pages/systems/sdc/overview.jsp
+++ b/java/code/webapp/WEB-INF/pages/systems/sdc/overview.jsp
@@ -54,7 +54,7 @@
<div class="systeminfo">
<div class="systeminfo-full">
<rhn:icon type="system-reboot" /><bean:message key="sdc.details.overview.requires_reboot"/>
- <bean:message key="sdc.details.overview.schedulereboot" arg0="/network/systems/details/reboot_confirm.pxt?sid=${system.id}"/>
+ <bean:message key="sdc.details.overview.schedulereboot" arg0="/rhn/systems/details/RebootSystem.do?sid=${system.id}"/>
</div>
</div>
</c:if>
@@ -255,7 +255,7 @@
<td><fmt:formatDate value="${system.lastBootAsDate}" type="both" dateStyle="short" timeStyle="long"/><br/>
<rhn:require acl="system_feature(ftr_reboot)"
mixins="com.redhat.rhn.common.security.acl.SystemAclHandler">
- <bean:message key="sdc.details.overview.schedulereboot" arg0="/network/systems/details/reboot_confirm.pxt?sid=${system.id}"/>
+ <bean:message key="sdc.details.overview.schedulereboot" arg0="/rhn/systems/details/RebootSystem.do?sid=${system.id}"/>
</rhn:require>
</td>
</tr>
diff --git a/java/code/webapp/WEB-INF/pages/systems/sdc/rebootsystem.jsp b/java/code/webapp/WEB-INF/pages/systems/sdc/rebootsystem.jsp
new file mode 100644
index 0000000..6e03b4a
--- /dev/null
+++ b/java/code/webapp/WEB-INF/pages/systems/sdc/rebootsystem.jsp
@@ -0,0 +1,52 @@
+<%--
+ Document : rebootsystem
+ Created on : Jan 15, 2014, 2:35:54 PM
+ Author : Michael Calmer <mc(a)suse.de>
+--%>
+
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+
+<%@taglib uri="http://rhn.redhat.com/rhn" prefix="rhn" %>
+<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
+<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
+<%@taglib uri="http://rhn.redhat.com/tags/list" prefix="rl" %>
+
+<html>
+ <body>
+ <%@ include file="/WEB-INF/pages/common/fragments/systems/system-header.jspf" %>
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <h4><bean:message key="reboot.jsp.header" /></h4>
+ </div>
+ <div class="panel-body">
+ <bean:message key="reboot.jsp.summary" />
+ <br>
+ <bean:message key="reboot.jsp.widgetsummary"/>
+
+ <form action="/rhn/systems/details/RebootSystem.do?sid=${sid}" method="post" class="form-horizontal">
+ <rhn:csrf />
+ <rhn:submitted />
+
+ <div class="form-group">
+ <div class="col-lg-offset-3 col-lg-6">
+ <jsp:include page="/WEB-INF/pages/common/fragments/date-picker.jsp">
+ <jsp:param name="widget" value="date"/>
+ </jsp:include>
+ </div>
+ </div>
+
+ <div class="form-group">
+ <div class="col-lg-offset-3 col-lg-6">
+ <html:submit styleClass="btn btn-danger">
+ <bean:message key="reboot.jsp.confirm"/>
+ </html:submit>
+ </div>
+ </div>
+
+ <input type="hidden" name="use_date" value="true" />
+ </form>
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml
index 1e96b02..c96c141 100644
--- a/java/code/webapp/WEB-INF/struts-config.xml
+++ b/java/code/webapp/WEB-INF/struts-config.xml
@@ -3063,6 +3063,19 @@
path="/systems/ssm/ListSystems.do" redirect="true" />
</action>
+ <action path="/systems/details/RebootSystem"
+ scope="request"
+ name="datePickerForm"
+ input="/WEB-INF/pages/systems/sdc/rebootsystem.jsp"
+ type="com.redhat.rhn.frontend.action.systems.sdc.SystemRebootAction"
+ className="com.redhat.rhn.frontend.struts.RhnActionMapping">
+ <set-property property="postRequiredIfSubmitted" value="true"/>
+ <forward name="confirm"
+ path="/WEB-INF/pages/systems/sdc/overview.jsp" />
+ <forward name="default"
+ path="/WEB-INF/pages/systems/sdc/rebootsystem.jsp" />
+ </action>
+
<action path="/systems/details/audit/ListScap"
scope="request"
input="/WEB-INF/pages/systems/details/audit/listscap.jsp"
diff --git a/web/include/nav/system_detail.xml b/web/include/nav/system_detail.xml
index 3332573..b45ba4d 100644
--- a/web/include/nav/system_detail.xml
+++ b/web/include/nav/system_detail.xml
@@ -4,7 +4,7 @@
<rhn-tab name="Details" url="/rhn/systems/details/Overview.do">
<rhn-tab name="Overview">
<rhn-tab-url>/rhn/systems/details/Overview.do</rhn-tab-url>
- <rhn-tab-url>/network/systems/details/reboot_confirm.pxt</rhn-tab-url>
+ <rhn-tab-url>/rhn/systems/details/RebootSystem.do</rhn-tab-url>
</rhn-tab>
<rhn-tab name="Properties" url="/rhn/systems/details/Edit.do" />
<rhn-tab name="Remote Command" acl="system_feature(ftr_remote_command)">
10 years, 4 months
java/code
by Milan Zazrivec
java/code/src/com/redhat/rhn/frontend/action/user/UserCredentialsEditAction.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 8373210db3c22057ac8d5f42eff886996734e122
Author: Johannes Renner <jrenner(a)suse.de>
Date: Wed Jan 22 10:41:08 2014 +0100
SUSE Studio API will stop working via unencrypted HTTP
diff --git a/java/code/src/com/redhat/rhn/frontend/action/user/UserCredentialsEditAction.java b/java/code/src/com/redhat/rhn/frontend/action/user/UserCredentialsEditAction.java
index 66efc89..72395f3 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/user/UserCredentialsEditAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/user/UserCredentialsEditAction.java
@@ -40,7 +40,7 @@ public class UserCredentialsEditAction extends RhnAction {
private static final String PARAM_USER = "studio_user";
private static final String PARAM_KEY = "studio_key";
private static final String PARAM_URL = "studio_url";
- private static final String DEFAULT_URL = "http://susestudio.com";
+ private static final String DEFAULT_URL = "https://susestudio.com";
/** {@inheritDoc} */
@Override
10 years, 4 months
Changes to 'refs/tags/spacewalk-schema-2.1.37-1'
by Milan Zazrivec
Tag 'spacewalk-schema-2.1.37-1' created by Milan Zazrivec <mzazrivec(a)redhat.com> at 2014-01-22 10:40 +0000
Tagging package [spacewalk-schema] version [2.1.37-1] in directory [schema/spacewalk/].
Changes since spacewalk-java-2.1.122-1:
Matej Kollar (1):
Inconsistency in build vs. eclipse checkstyle.
Milan Zazrivec (3):
Revert "'is' followed by 'declare' is rarely needed"
Revert "1053591 - refresh_newest_package: lock rhnChannel at the beginning"
Automatic commit of package [spacewalk-schema] release [2.1.37-1].
---
java/conf/eclipse/checkstyle_eclipse.xml | 4
rel-eng/packages/spacewalk-schema | 2
schema/spacewalk/oracle/packages/rhn_channel.pkb | 7
schema/spacewalk/postgres/packages/rhn_channel.pkb | 10
schema/spacewalk/spacewalk-schema.spec | 6
schema/spacewalk/upgrade/spacewalk-schema-2.0-to-spacewalk-schema-2.1/037-rhn_channel.pkb.oracle | 1246 ---------
schema/spacewalk/upgrade/spacewalk-schema-2.0-to-spacewalk-schema-2.1/037-rhn_channel.pkb.postgresql | 1270 ----------
7 files changed, 7 insertions(+), 2538 deletions(-)
---
10 years, 4 months
rel-eng/packages schema/spacewalk
by Milan Zazrivec
rel-eng/packages/spacewalk-schema | 2 +-
schema/spacewalk/spacewalk-schema.spec | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
New commits:
commit 7e9a0937939d38f0075f886c6549a3f5d5eff69b
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Wed Jan 22 11:40:44 2014 +0100
Automatic commit of package [spacewalk-schema] release [2.1.37-1].
diff --git a/rel-eng/packages/spacewalk-schema b/rel-eng/packages/spacewalk-schema
index aa4bcc8..1720fa6 100644
--- a/rel-eng/packages/spacewalk-schema
+++ b/rel-eng/packages/spacewalk-schema
@@ -1 +1 @@
-2.1.36-1 schema/spacewalk/
+2.1.37-1 schema/spacewalk/
diff --git a/schema/spacewalk/spacewalk-schema.spec b/schema/spacewalk/spacewalk-schema.spec
index 023335c..5c55530 100644
--- a/schema/spacewalk/spacewalk-schema.spec
+++ b/schema/spacewalk/spacewalk-schema.spec
@@ -4,7 +4,7 @@ Name: spacewalk-schema
Group: Applications/Internet
Summary: Oracle SQL schema for Spacewalk server
-Version: 2.1.36
+Version: 2.1.37
Release: 1%{?dist}
Source0: %{name}-%{version}.tar.gz
@@ -71,6 +71,10 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man1/spacewalk-sql*
%changelog
+* Wed Jan 22 2014 Milan Zazrivec <mzazrivec(a)redhat.com> 2.1.37-1
+- Revert "1053591 - refresh_newest_package: lock rhnChannel at the beginning"
+- Revert "'is' followed by 'declare' is rarely needed"
+
* Fri Jan 17 2014 Michael Mraka <michael.mraka(a)redhat.com> 2.1.36-1
- increase length of rhnCVE name column
10 years, 4 months
2 commits - schema/spacewalk
by Milan Zazrivec
schema/spacewalk/oracle/packages/rhn_channel.pkb | 7
schema/spacewalk/postgres/packages/rhn_channel.pkb | 10
schema/spacewalk/upgrade/spacewalk-schema-2.0-to-spacewalk-schema-2.1/037-rhn_channel.pkb.oracle | 1246 ---------
schema/spacewalk/upgrade/spacewalk-schema-2.0-to-spacewalk-schema-2.1/037-rhn_channel.pkb.postgresql | 1270 ----------
4 files changed, 1 insertion(+), 2532 deletions(-)
New commits:
commit aabceb78217f6402558bde106d886511ebacb027
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Wed Jan 22 11:37:23 2014 +0100
Revert "1053591 - refresh_newest_package: lock rhnChannel at the beginning"
This reverts commit d0815058c8892c8f5a0642cc592ff97fcaa49374.
Locking rhnChannel table at the beginning of refresh_newest_package
won't suffice, since the resources over which both sessions compete
were locked before the procedure.
diff --git a/schema/spacewalk/oracle/packages/rhn_channel.pkb b/schema/spacewalk/oracle/packages/rhn_channel.pkb
index b393579..325c18a 100644
--- a/schema/spacewalk/oracle/packages/rhn_channel.pkb
+++ b/schema/spacewalk/oracle/packages/rhn_channel.pkb
@@ -1102,15 +1102,7 @@ IS
is
-- procedure refreshes rows for name_id = package_name_id_in or
-- all rows if package_name_id_in is null
- declare
- channel_lm timestamp with local time zone;
begin
- select last_modified
- into channel_lm
- from rhnChannel
- where id = channel_id_in
- for update;
-
delete from rhnChannelNewestPackage
where channel_id = channel_id_in
and (package_name_id_in is null
diff --git a/schema/spacewalk/postgres/packages/rhn_channel.pkb b/schema/spacewalk/postgres/packages/rhn_channel.pkb
index 3471f21..5931562 100644
--- a/schema/spacewalk/postgres/packages/rhn_channel.pkb
+++ b/schema/spacewalk/postgres/packages/rhn_channel.pkb
@@ -1,4 +1,4 @@
--- oracle equivalent source sha1 b89b116bf39a095c05c4ae0f9813fd43f0437132
+-- oracle equivalent source sha1 e6fa92f40cfb0ac1645f53ecad5f2a8f99a616f7
--
-- Copyright (c) 2008--2013 Red Hat, Inc.
--
@@ -1124,15 +1124,7 @@ update pg_settings set setting = 'rhn_channel,' || setting where name = 'search_
as $$
-- procedure refreshes rows for name_id = package_name_id_in or
-- all rows if package_name_id_in is null
- declare
- channel_lm timestamptz;
begin
- select last_modified
- into channel_lm
- from rhnChannel
- where id = channel_id_in
- for update;
-
delete from rhnChannelNewestPackage
where channel_id = channel_id_in
and (package_name_id_in is null
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-2.0-to-spacewalk-schema-2.1/037-rhn_channel.pkb.oracle b/schema/spacewalk/upgrade/spacewalk-schema-2.0-to-spacewalk-schema-2.1/037-rhn_channel.pkb.oracle
deleted file mode 100644
index b393579..0000000
--- a/schema/spacewalk/upgrade/spacewalk-schema-2.0-to-spacewalk-schema-2.1/037-rhn_channel.pkb.oracle
+++ /dev/null
@@ -1,1247 +0,0 @@
---
--- Copyright (c) 2008--2013 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 rhnOrgDistChannelMap odcm,
- rhnServerChannelArchCompat scac,
- rhnChannel c
- where c.parent_channel is null
- and c.id = odcm.channel_id
- and c.channel_arch_id = odcm.channel_arch_id
- and odcm.release = release_in
- and odcm.for_org_id = org_id_in
- and scac.server_arch_id = server_arch_id_in
- and scac.channel_arch_id = c.channel_arch_id;
-
- procedure obtain_read_lock(channel_family_id_in in number, org_id_in in number)
- is
- read_lock timestamp with local time zone;
-
- begin
- select created into read_lock
- from rhnPrivateChannelFamily
- where channel_family_id = channel_family_id_in and org_id = org_id_in
- for update;
- end obtain_read_lock;
-
- 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;
- available_fve_subs NUMBER;
- consenting_user NUMBER;
- allowed number := 0;
- is_fve CHAR(1) := 'N';
- BEGIN
- if user_id_in is not null then
- allowed := rhn_channel.user_role_check(channel_id_in, user_id_in, 'subscribe');
- else
- allowed := 1;
- end if;
-
- if allowed = 0 then
- 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;
-
- begin
- obtain_read_lock(channel_family_id_val, server_org_id_val);
- exception
- when no_data_found then
- rhn_exception.raise_exception('channel_family_no_subscriptions');
- end;
-
- available_subscriptions := rhn_channel.available_family_subscriptions(channel_family_id_val, server_org_id_val);
- available_fve_subs := rhn_channel.available_fve_family_subs(channel_family_id_val, server_org_id_val);
-
- IF available_subscriptions IS NULL OR
- available_subscriptions > 0 or
- can_server_consume_virt_channl(server_id_in, channel_family_id_val) = 1 OR
- (available_fve_subs > 0 AND can_server_consume_fve(server_id_in) = 1)
- THEN
- if can_server_consume_virt_channl(server_id_in, channel_family_id_val) = 0 AND available_fve_subs > 0 AND can_server_consume_fve(server_id_in) = 1 THEN
- is_fve := 'Y';
- END IF;
- 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 = current_timestamp WHERE id = server_id_in;
- INSERT INTO rhnServerChannel (server_id, channel_id, is_fve) VALUES (server_id_in, channel_id_in, is_fve);
- 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_convert_to_fve(server_id_in IN NUMBER, channel_family_id_val IN NUMBER)
- RETURN NUMBER
- IS
- CURSOR fve_convertible_entries IS
- select 1 from
- rhnServerFveCapable cap
- where cap.server_id = server_id_in
- AND cap.channel_family_id = channel_family_id_val;
- BEGIN
- FOR entry IN fve_convertible_entries LOOP
- return 1;
- END LOOP;
- RETURN 0;
- END can_convert_to_fve;
-
-
-
- -- Converts server channel_family to use a flex entitlement
- PROCEDURE convert_to_fve(server_id_in IN NUMBER, channel_family_id_val IN NUMBER)
- IS
- available_fve_subs NUMBER;
- server_org_id_val NUMBER;
- BEGIN
-
- --
- -- 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 org_id
- INTO server_org_id_val
- FROM rhnServer
- WHERE id = server_id_in;
-
- begin
- obtain_read_lock(channel_family_id_val, server_org_id_val);
- exception
- when no_data_found then
- rhn_exception.raise_exception('channel_family_no_subscriptions');
- end;
- IF (can_convert_to_fve(server_id_in, channel_family_id_val ) = 0)
- THEN
- rhn_exception.raise_exception('server_cannot_convert_to_flex');
- END IF;
-
- available_fve_subs := rhn_channel.available_fve_family_subs(channel_family_id_val, server_org_id_val);
-
- IF (available_fve_subs > 0)
- THEN
-
- insert into rhnServerHistory (id,server_id,summary,details) (
- select rhn_event_id_seq.nextval,
- server_id_in,
- 'converted to flex entitlement' || SUBSTR(cf.label, 0, 99),
- cf.label
- from rhnChannelFamily cf
- where cf.id = channel_family_id_val
- );
-
- UPDATE rhnServerChannel sc set sc.is_fve = 'Y'
- where sc.server_id = server_id_in and
- sc.channel_id in
- (select cfm.channel_id from rhnChannelFamilyMembers cfm
- where cfm.CHANNEL_FAMILY_ID = channel_family_id_val);
-
- rhn_channel.update_family_counts(channel_family_id_val, server_org_id_val);
- ELSE
- rhn_exception.raise_exception('not_enough_flex_entitlements');
- END IF;
-
- END convert_to_fve;
-
- 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;
-
- FUNCTION can_server_consume_fve(server_id_in IN NUMBER)
- RETURN NUMBER
- IS
- CURSOR vi_entries IS
- SELECT 1
- FROM rhnVirtualInstance vi
- WHERE vi.virtual_system_id = server_id_in;
- vi_count NUMBER;
-
- BEGIN
- FOR vi_entry IN VI_ENTRIES LOOP
- return 1;
- END LOOP;
- RETURN 0;
- 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 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
- order by cfm.channel_family_id;
- last_channel_family_id rhnChannelFamilyMembers.channel_family_id%type := -1;
- last_channel_org_id rhnServer.org_id%type := -1;
- BEGIN
- for channel in server_channels(server_id_in)
- loop
- unsubscribe_server(server_id_in, channel.channel_id, 1, 1, deleting_server, 0);
- if update_family_countsYN > 0
- and channel.channel_family_id != last_channel_family_id then
- -- update family counts only once
- -- after all channels with same family has been fetched
- if last_channel_family_id != -1 then
- update_family_counts(last_channel_family_id, last_channel_org_id);
- end if;
- last_channel_family_id := channel.channel_family_id;
- last_channel_org_id := channel.org_id;
- end if;
- end loop channel;
- if update_family_countsYN > 0 and last_channel_family_id != -1 then
- -- update the last family fetched
- update_family_counts(last_channel_family_id, last_channel_org_id);
- end if;
- 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 = current_timestamp WHERE id = server_id_in;
- end if;
-
- DELETE FROM rhnServerChannel WHERE server_id = server_id_in AND channel_id = channel_id_in;
-
- if deleting_server = 0 then
- 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;
- 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 available_fve_family_subs(channel_family_id_in IN NUMBER, org_id_in IN NUMBER)
- RETURN NUMBER
- IS
- cfp channel_family_perm_cursor%ROWTYPE;
- fve_current_members_val NUMBER;
- fve_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;
- fve_current_members_val := cfp.fve_current_members;
- fve_max_members_val := cfp.fve_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;
-
- IF found IS NULL THEN
- RETURN 0;
- END IF;
-
- IF fve_max_members_val IS NULL THEN
- RETURN NULL;
- END IF;
-
- RETURN fve_max_members_val - fve_current_members_val;
-
- END available_fve_family_subs;
-
-
- -- *******************************************************************
- -- 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;
-
-
- function cfam_curr_fve_members(
- channel_family_id_in IN NUMBER,
- org_id_in IN NUMBER)
- return number
- is
- current_members_count number := 0;
-
- begin
- select count(sc.server_id)
- into current_members_count
- from rhnServerChannel sc,
- rhnChannelFamilyMembers cfm,
- rhnServer s
- where s.org_id = org_id_in
- and s.id = sc.server_id
- and cfm.channel_family_id = channel_family_id_in
- and cfm.channel_id = sc.channel_id
- and exists (
- select 1
- from rhnChannelFamilyServerFve cfsp
- where cfsp.CHANNEL_FAMILY_ID = channel_family_id_in
- and cfsp.server_id = s.id
- );
-
- 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)),
- fve_current_members = ( cfam_curr_fve_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;
-
- FUNCTION available_fve_chan_subs(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_fve_family_subs( channel_family_id_val, org_id_in);
- END available_fve_chan_subs;
-
- 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.fve_max_members > 0 or CFP.fve_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
- -- returns NULL if OK, error message otherwise
- function user_role_check_debug(channel_id_in in number,
- user_id_in in number,
- role_in in varchar2)
- return varchar2
- 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 NULL;
- end if;
-
- if role_in = 'manage' and
- NVL(rhn_channel.get_org_id(channel_id_in), -1) <> org_id then
- return 'channel_not_owned';
- end if;
-
- if role_in = 'subscribe' and
- rhn_channel.get_org_access(channel_id_in, org_id) = 0 then
- return 'channel_not_available';
- end if;
-
- -- channel admins have all roles
- if rhn_user.check_role_implied(user_id_in, 'channel_admin') = 1 then
- return NULL;
- 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
- return NULL;
- end if;
- end if;
-
- -- all other roles (manage right now) are explicitly granted
- if rhn_channel.direct_user_role_check(channel_id_in,
- user_id_in, role_in) = 1 then
- return NULL;
- end if;
- return 'direct_permission';
- end;
-
- -- same as above, but with 1/0 output; 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
- begin
- if rhn_channel.user_role_check_debug(channel_id_in,
- user_id_in, role_in) is NULL then
- return 1;
- else
- return 0;
- end if;
- 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 timestamp with local time zone;
- 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)',
- package_name_id_in in number := null)
- is
- -- procedure refreshes rows for name_id = package_name_id_in or
- -- all rows if package_name_id_in is null
- declare
- channel_lm timestamp with local time zone;
- begin
- select last_modified
- into channel_lm
- from rhnChannel
- where id = channel_id_in
- for update;
-
- delete from rhnChannelNewestPackage
- where channel_id = channel_id_in
- and (package_name_id_in is null
- or name_id = package_name_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
- and (package_name_id_in is null
- or name_id = package_name_id_in)
- );
- insert into rhnChannelNewestPackageAudit (channel_id, caller)
- values (channel_id_in, caller_in);
- update rhnChannel
- set last_modified = greatest(current_timestamp, last_modified + interval '1' second)
- where id = channel_id_in;
- end;
-
- procedure update_channel ( channel_id_in in number, invalidate_ss in number := 0,
- date_to_use in timestamp with local time zone := current_timestamp )
- is
-
- channel_last_modified timestamp with local time zone;
- last_modified_value timestamp with local time zone;
-
- 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 timestamp with local time zone := current_timestamp )
- 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 timestamp with local time zone := current_timestamp )
- 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;
-
- procedure update_needed_cache(channel_id_in in number)
- is
- -- update of needed cache ican be commited on a per server basis
- -- b/c failure of update for a server means nothing for the other servers
- begin
- -- we intentionaly do a loop here instead of one huge select
- -- b/c we want to break update into smaller transaction to unblock other sessions
- -- querying rhnServerNeededCache
- for server in (
- select sc.server_id as id
- from rhnServerChannel sc
- where sc.channel_id = channel_id_in
- ) loop
- rhn_server.update_needed_cache(server.id);
- commit;
- end loop;
- end update_needed_cache;
-
- procedure set_comps(channel_id_in in number, path_in in varchar2, timestamp_in in varchar2)
- is
- begin
- for row in (
- select relative_filename, last_modified
- from rhnChannelComps
- where channel_id = channel_id_in
- ) loop
- if row.relative_filename = path_in
- and row.last_modified = to_date(timestamp_in, 'YYYYMMDDHH24MISS') then
- return;
- end if;
- end loop;
- delete from rhnChannelComps
- where channel_id = channel_id_in;
- insert into rhnChannelComps (id, channel_id, relative_filename, last_modified, created, modified)
- values (sequence_nextval('rhn_channelcomps_id_seq'), channel_id_in, path_in, to_date(timestamp_in, 'YYYYMMDDHH24MISS'), current_timestamp, current_timestamp);
- end set_comps;
-
-END rhn_channel;
-/
-SHOW ERRORS
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-2.0-to-spacewalk-schema-2.1/037-rhn_channel.pkb.postgresql b/schema/spacewalk/upgrade/spacewalk-schema-2.0-to-spacewalk-schema-2.1/037-rhn_channel.pkb.postgresql
deleted file mode 100644
index 3471f21..0000000
--- a/schema/spacewalk/upgrade/spacewalk-schema-2.0-to-spacewalk-schema-2.1/037-rhn_channel.pkb.postgresql
+++ /dev/null
@@ -1,1270 +0,0 @@
--- oracle equivalent source sha1 b89b116bf39a095c05c4ae0f9813fd43f0437132
---
--- Copyright (c) 2008--2013 Red Hat, Inc.
---
--- This software is licensed to you under the GNU General Public License,
--- version 2 (GPLv2). There is NO WARRANTY for this software, express or
--- implied, including the implied warranties of MERCHANTABILITY or FITNESS
--- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
--- along with this software; if not, see
--- http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
---
--- Red Hat trademarks are not licensed under GPLv2. No permission is
--- granted to use or replicate Red Hat trademarks that are incorporated
--- in this software or its documentation.
---
---
---
---
-
--- create schema rhn_channel;
-
---update pg_setting
-update pg_settings set setting = 'rhn_channel,' || setting where name = 'search_path';
-
- create or replace function obtain_read_lock(channel_family_id_in in numeric, org_id_in in numeric)
- returns void as $$
- declare
- read_lock timestamptz;
- begin
- select created into read_lock
- from rhnPrivateChannelFamily
- where channel_family_id = channel_family_id_in and org_id = org_id_in
- for update;
- end$$ language plpgsql;
-
- -- this "emulates" cursor server_base_subscriptions defined in oracle/rhn_channel.pks
- create or replace function server_base_subscriptions(server_id_in NUMERIC)
- returns boolean as $$
- begin
- return exists(SELECT C.id FROM rhnChannel C, rhnServerChannel SC
- WHERE C.id = SC.channel_id
- AND SC.server_id = server_id_in
- AND C.parent_channel IS NULL);
- end$$ language plpgsql;
-
- -- this "emulates" cursor server_base_subscriptions defined in oracle/rhn_channel.pks
- create or replace function check_server_subscription(server_id_in NUMERIC, channel_id_in NUMERIC)
- returns boolean as $$
- begin
- return exists(SELECT channel_id FROM rhnServerChannel WHERE server_id = server_id_in AND channel_id = channel_id_in);
- end$$ language plpgsql;
-
-
- CREATE OR REPLACE FUNCTION subscribe_server(server_id_in IN NUMERIC, channel_id_in NUMERIC, immediate_in NUMERIC default 1, user_id_in in numeric default null, recalcfamily_in NUMERIC default 1) returns void
- AS $$
- declare
- channel_parent_val rhnChannel.parent_channel%TYPE;
- parent_subscribed BOOLEAN;
- server_has_base_chan BOOLEAN;
- server_already_in_chan BOOLEAN;
- channel_family_id_val NUMERIC;
- server_org_id_val NUMERIC;
- available_subscriptions NUMERIC;
- available_fve_subs numeric;
- consenting_user NUMERIC;
- allowed numeric;
- is_fve_char char(1) := 'N';
- BEGIN
- if user_id_in is not null then
- allowed := rhn_channel.user_role_check(channel_id_in, user_id_in, 'subscribe');
- else
- allowed := 1;
- end if;
-
- if allowed = 0 then
- perform rhn_exception.raise_exception('no_subscribe_permissions');
- end if;
-
-
- SELECT parent_channel INTO channel_parent_val FROM rhnChannel WHERE id = channel_id_in;
-
- IF channel_parent_val IS NOT NULL
- THEN
- -- child channel; if attempting to cross-subscribe a child to the wrong base, silently ignore
- parent_subscribed := rhn_channel.check_server_subscription(server_id_in, channel_parent_val);
-
- IF NOT parent_subscribed
- THEN
- RETURN;
- END IF;
- ELSE
- -- base channel
- server_has_base_chan := rhn_channel.server_base_subscriptions(server_id_in);
-
- IF server_has_base_chan
- THEN
- perform rhn_exception.raise_exception('channel_server_one_base');
- END IF;
- END IF;
-
- server_already_in_chan := rhn_channel.check_server_subscription(server_id_in, channel_id_in);
-
- IF server_already_in_chan
- THEN
- RETURN;
- END IF;
-
- channel_family_id_val := rhn_channel.family_for_channel(channel_id_in);
- IF channel_family_id_val IS NULL
- THEN
- perform rhn_exception.raise_exception('channel_subscribe_no_family');
- END IF;
-
- --
- -- Use the org_id of the server only if the org_id of the channel = NULL.
- -- This is required for subscribing to shared channels.
- --
- SELECT COALESCE(org_id, (SELECT org_id FROM rhnServer WHERE id = server_id_in))
- INTO server_org_id_val
- FROM rhnChannel
- WHERE id = channel_id_in;
-
- begin
- perform rhn_channel.obtain_read_lock(channel_family_id_val, server_org_id_val);
- exception
- when no_data_found then
- perform rhn_exception.raise_exception('channel_family_no_subscriptions');
- end;
-
- available_subscriptions := rhn_channel.available_family_subscriptions(channel_family_id_val, server_org_id_val);
- available_fve_subs := rhn_channel.available_fve_family_subs(channel_family_id_val, server_org_id_val);
-
- IF available_subscriptions IS NULL OR
- available_subscriptions > 0 or
- rhn_channel.can_server_consume_virt_channl(server_id_in, channel_family_id_val) = 1 OR
- (available_fve_subs > 0 AND rhn_channel.can_server_consume_fve(server_id_in) = 1)
- THEN
- if rhn_channel.can_server_consume_virt_channl(server_id_in, channel_family_id_val) = 0 AND available_fve_subs > 0 AND rhn_channel.can_server_consume_fve(server_id_in) = 1 THEN
- is_fve_char := 'Y';
- end if;
-
- insert into rhnServerHistory (id,server_id,summary,details) (
- select nextval('rhn_event_id_seq'),
- server_id_in,
- 'subscribed to channel ' || SUBSTR(c.label, 0, 106),
- c.label
- from rhnChannel c
- where c.id = channel_id_in
- );
- UPDATE rhnServer SET channels_changed = current_timestamp WHERE id = server_id_in;
- INSERT INTO rhnServerChannel (server_id, channel_id, is_fve) VALUES (server_id_in, channel_id_in, is_fve_char);
- IF recalcfamily_in > 0
- THEN
- perform rhn_channel.update_family_counts(channel_family_id_val, server_org_id_val);
- END IF;
- perform queue_server(server_id_in, immediate_in);
- ELSE
- perform rhn_exception.raise_exception('channel_family_no_subscriptions');
- END IF;
-
- END$$ language plpgsql;
-
-
-
- create or replace function can_convert_to_fve(server_id_in IN NUMERIC, channel_family_id_val IN NUMERIC)
- RETURNS NUMERIC
- as $$
- declare
- fve_convertible_entries cursor for
- select 1 from
- rhnServerFveCapable cap
- where cap.server_id = server_id_in
- AND cap.channel_family_id = channel_family_id_val;
- BEGIN
- FOR entry IN fve_convertible_entries LOOP
- return 1;
- END LOOP;
- RETURN 0;
- END$$ language plpgsql;
-
-
-
- -- Converts server channel_family to use a flex entitlement
- create or replace function convert_to_fve(server_id_in IN NUMERIC, channel_family_id_val IN NUMERIC)
- returns void
- as $$
- declare
- available_fve_subs NUMERIC;
- server_org_id_val NUMERIC;
- BEGIN
-
- --
- -- 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 org_id
- INTO server_org_id_val
- FROM rhnServer
- WHERE id = server_id_in;
-
-
- perform rhn_channel.obtain_read_lock(channel_family_id_val, server_org_id_val);
- if not found then
- perform rhn_exception.raise_exception('channel_family_no_subscriptions');
- end if;
- IF (rhn_channel.can_convert_to_fve(server_id_in, channel_family_id_val ) = 0)
- THEN
- perform rhn_exception.raise_exception('server_cannot_convert_to_flex');
- END IF;
-
- available_fve_subs := rhn_channel.available_fve_family_subs(channel_family_id_val, server_org_id_val);
-
- IF (available_fve_subs > 0)
- THEN
-
- insert into rhnServerHistory (id,server_id,summary,details) (
- select nextval('rhn_event_id_seq'),
- server_id_in,
- 'converted to flex entitlement' || SUBSTR(cf.label, 0, 99),
- cf.label
- from rhnChannelFamily cf
- where cf.id = channel_family_id_val
- );
-
- UPDATE rhnServerChannel sc set is_fve = 'Y'
- where sc.server_id = server_id_in and
- sc.channel_id in
- (select cfm.channel_id from rhnChannelFamilyMembers cfm
- where cfm.CHANNEL_FAMILY_ID = channel_family_id_val);
-
- perform rhn_channel.update_family_counts(channel_family_id_val, server_org_id_val);
- ELSE
- perform rhn_exception.raise_exception('not_enough_flex_entitlements');
- END IF;
-
- END$$ language plpgsql;
-
- create or replace function can_server_consume_virt_channl(
- server_id_in in numeric,
- family_id_in in numeric )
- returns numeric
- as $$
- begin
- if exists(
- select 1
- from
- rhnChannelFamilyVirtSubLevel cfvsl,
- rhnSGTypeVirtSubLevel sgtvsl,
- rhnVirtualInstance vi
- where
- vi.virtual_system_id = server_id_in
- and sgtvsl.virt_sub_level_id = cfvsl.virt_sub_level_id
- and cfvsl.channel_family_id = family_id_in
- and exists (
- select 1
- from rhnServerEntitlementView sev
- where vi.host_system_id = sev.server_id
- and sev.server_group_type_id = sgtvsl.server_group_type_id ))
- then
- return 1;
- else
- return 0;
- end if;
- end$$ language plpgsql;
-
- create or replace function can_server_consume_fve(server_id_in in numeric) returns numeric
- as $$
- declare
- vi_entries cursor for
- SELECT 1
- FROM rhnVirtualInstance vi
- WHERE vi.virtual_system_id = server_id_in;
- vi_count numeric;
-
- begin
- FOR vi_entry IN VI_ENTRIES LOOP
- return 1;
- END LOOP;
- RETURN 0;
- end$$ language plpgsql;
-
- create or replace function guess_server_base(
- server_id_in in numeric
- ) RETURNS numeric as $$
- declare
- server_cursor cursor for
- select s.server_arch_id, s.release, s.org_id
- from rhnServer s
- where s.id = server_id_in;
- -- Cursor that fetches all the possible base channels for a
- -- (server_arch_id, release, org_id) combination
- base_channel_cursor cursor(
- release_in varchar,
- server_arch_id_in numeric,
- org_id_in numeric
- ) for
- select distinct c.*
- from rhnOrgDistChannelMap odcm,
- rhnServerChannelArchCompat scac,
- rhnChannel c
- where c.parent_channel is null
- and c.id = odcm.channel_id
- and c.channel_arch_id = odcm.channel_arch_id
- and odcm.release = release_in
- and odcm.for_org_id = org_id_in
- and scac.server_arch_id = server_arch_id_in
- and scac.channel_arch_id = c.channel_arch_id;
-
- begin
- for s in server_cursor loop
- for channel in base_channel_cursor(s.release,
- s.server_arch_id, s.org_id)
- loop
- return channel.id;
- end loop;
- end loop;
- -- Server not found, or no base channel applies to it
- return null;
- end$$ language plpgsql;
-
- -- Private function
- create or replace function normalize_server_arch(server_arch_in in varchar)
- returns varchar
- as $$
- declare
- suffix VARCHAR(128) := '-redhat-linux';
- begin
- if server_arch_in is NULL then
- return NULL;
- end if;
- if position('-' IN server_arch_in) > 0
- then
- -- Suffix already present
- return server_arch_in;
- end if;
- return server_arch_in || suffix;
- end$$ language plpgsql;
-
- --
- -- Raises:
- -- server_arch_not_found
- -- no_subscribe_permissions
- create or replace function base_channel_for_release_arch(
- release_in in varchar,
- server_arch_in in varchar,
- org_id_in in numeric default -1,
- user_id_in in numeric default null
- ) returns numeric as $$
- declare
- server_arch varchar(256) := rhn_channel.normalize_server_arch(server_arch_in);
- server_arch_id numeric;
- begin
- -- Look up the server arch
- select id
- into server_arch_id
- from rhnServerArch
- where label = server_arch;
- if not found then
- perform rhn_exception.raise_exception('server_arch_not_found');
- end if;
-
- return rhn_channel.base_channel_rel_archid(release_in, server_arch_id,
- org_id_in, user_id_in);
- end$$ language plpgsql;
-
- create or replace function base_channel_rel_archid(
- release_in in varchar,
- server_arch_id_in in numeric,
- org_id_in in numeric default -1,
- user_id_in in numeric default null
- ) returns numeric as $$
- declare
- denied_channel_id numeric := null;
- valid_org_id numeric := org_id_in;
- valid_user_id numeric := user_id_in;
- channel_subscribable numeric;
- -- Cursor that fetches all the possible base channels for a
- -- (server_arch_id, release, org_id) combination
- base_channel_cursor cursor(
- release_in varchar,
- server_arch_id_in numeric,
- org_id_in numeric
- ) for
- select distinct c.*
- from rhnOrgDistChannelMap odcm,
- rhnServerChannelArchCompat scac,
- rhnChannel c
- where c.parent_channel is null
- and c.id = odcm.channel_id
- and c.channel_arch_id = odcm.channel_arch_id
- and odcm.release = release_in
- and odcm.for_org_id = org_id_in
- and scac.server_arch_id = server_arch_id_in
- and scac.channel_arch_id = c.channel_arch_id;
-
- begin
- if org_id_in = -1 and user_id_in is not null then
- -- Get the org id from the user id
-
- select org_id
- into valid_org_id
- from web_contact
- where id = user_id_in;
-
- if not found then
- -- User doesn't exist
- -- XXX Only list public stuff for now
- valid_user_id := null;
- valid_org_id := -1;
- end if;
- end if;
-
- for c in base_channel_cursor(release_in, server_arch_id_in, valid_org_id)
- loop
- -- This row is a possible match
- if valid_user_id is null then
- -- User ID not specified, so no user to channel permissions to
- -- check
- return c.id;
- end if;
-
- -- Check user to channel permissions
- select rhn_channel.loose_user_role_check(c.id, user_id_in, 'subscribe')
- into channel_subscribable;
-
- if channel_subscribable = 1 then
- return c.id;
- end if;
-
- -- Base channel exists, but is not subscribable; keep trying
- denied_channel_id := c.id;
- end loop;
-
- if denied_channel_id is not null then
- perform rhn_exception.raise_exception('no_subscribe_permissions');
- end if;
- -- No base channel applies
- return NULL;
- end$$ language plpgsql;
-
- CREATE OR REPLACE FUNCTION clear_subscriptions(server_id_in IN NUMERIC, deleting_server IN NUMERIC default 0,
- update_family_countsYN IN NUMERIC default 1 ) returns void
- AS $$
- declare
- server_channels cursor(server_id_in numeric) for
- select s.org_id, sc.channel_id, cfm.channel_family_id
- from rhnServer s,
- rhnServerChannel sc,
- rhnChannelFamilyMembers cfm
- where s.id = server_id_in
- and s.id = sc.server_id
- and sc.channel_id = cfm.channel_id
- order by cfm.channel_family_id;
- last_channel_family_id rhnChannelFamilyMembers.channel_family_id%type := -1;
- last_channel_org_id rhnServer.org_id%type := -1;
- BEGIN
- for channel in server_channels(server_id_in)
- loop
- perform rhn_channel.unsubscribe_server(server_id_in, channel.channel_id, 1, 1, deleting_server, 0);
- if update_family_countsYN > 0
- and channel.channel_family_id != last_channel_family_id then
- -- update family counts only once
- -- after all channels with same family has been fetched
- if last_channel_family_id != -1 then
- perform rhn_channel.update_family_counts(channel.channel_family_id, channel.org_id);
- end if;
- last_channel_family_id := channel.channel_family_id;
- last_channel_org_id := channel.org_id;
- end if;
- end loop;
- if update_family_countsYN > 0 and last_channel_family_id != -1 then
- -- update the last family fetched
- perform rhn_channel.update_family_counts(last_channel_family_id, last_channel_org_id);
- end if;
- END$$ language plpgsql;
-
- CREATE OR REPLACE FUNCTION unsubscribe_server(server_id_in IN NUMERIC, channel_id_in NUMERIC, immediate_in NUMERIC default 1, unsubscribe_children_in numeric default 0,
- deleting_server in numeric default 0,
- update_family_countsYN in numeric default 1) returns void
- AS $$
- declare
- channel_family_id_val NUMERIC;
- server_org_id_val NUMERIC;
- available_subscriptions NUMERIC;
- server_already_in_chan BOOLEAN;
- channel_family_is_proxy cursor(channel_family_id_in numeric) for
- select 1
- from rhnChannelFamily
- where id = channel_family_id_in
- and label = 'rhn-proxy';
- channel_family_is_satellite cursor(channel_family_id_in numeric) for
- select 1
- from rhnChannelFamily
- where id = channel_family_id_in
- and label = 'rhn-satellite';
- child record;
- BEGIN
- -- In PostgreSQL recursion with opened cursors is not allowed so we use
- -- FOR IN SELECT form which is ok.
- FOR child IN select c.id
- from rhnChannel c,
- rhnServerChannel sc
- where 1=1
- and c.parent_channel = channel_id_in
- and c.id = sc.channel_id
- and sc.server_id = server_id_in
- LOOP
- if unsubscribe_children_in = 1 then
- perform rhn_channel.unsubscribe_server(server_id_in,
- child.id,
- immediate_in,
- unsubscribe_children_in,
- deleting_server,
- update_family_countsYN);
- else
- perform rhn_exception.raise_exception('channel_unsubscribe_child_exists');
- end if;
- END LOOP;
-
- server_already_in_chan := rhn_channel.check_server_subscription(server_id_in, channel_id_in);
-
- IF NOT server_already_in_chan
- THEN
- RETURN;
- END IF;
-
- if deleting_server = 0 then
-
- insert into rhnServerHistory (id,server_id,summary,details) (
- select nextval('rhn_event_id_seq'),
- server_id_in,
- 'unsubscribed from channel ' || SUBSTR(c.label, 0, 106),
- c.label
- from rhnChannel c
- where c.id = channel_id_in
- );
-
- UPDATE rhnServer SET channels_changed = current_timestamp WHERE id = server_id_in;
- end if;
-
- DELETE FROM rhnServerChannel WHERE server_id = server_id_in AND channel_id = channel_id_in;
-
- if deleting_server = 0 then
- perform queue_server(server_id_in, immediate_in);
- end if;
-
- channel_family_id_val := rhn_channel.family_for_channel(channel_id_in);
- IF channel_family_id_val IS NULL
- THEN
- perform rhn_exception.raise_exception('channel_unsubscribe_no_family');
- END IF;
-
- for ignore in channel_family_is_satellite(channel_family_id_val) loop
- delete from rhnSatelliteInfo where server_id = server_id_in;
- end loop;
-
- for ignore in channel_family_is_proxy(channel_family_id_val) loop
- delete from rhnProxyInfo where server_id = server_id_in;
- end loop;
- SELECT org_id INTO server_org_id_val
- FROM rhnServer
- WHERE id = server_id_in;
-
- if update_family_countsYN = 1 then
- perform rhn_channel.update_family_counts(channel_family_id_val, server_org_id_val);
- end if;
- END$$ language plpgsql;
-
- CREATE OR REPLACE FUNCTION family_for_channel(channel_id_in IN NUMERIC)
- RETURNS NUMERIC
- AS $$
- declare
- channel_family_id_val NUMERIC;
- BEGIN
- SELECT channel_family_id INTO channel_family_id_val
- FROM rhnChannelFamilyMembers
- WHERE channel_id = channel_id_in;
-
- IF NOT FOUND THEN
- RETURN NULL;
- END IF;
-
- RETURN channel_family_id_val;
- END$$ language plpgsql;
-
- CREATE OR REPLACE FUNCTION available_family_subscriptions(channel_family_id_in IN NUMERIC, org_id_in IN NUMERIC)
- RETURNS NUMERIC
- AS $$
- declare
- cfp record;
- current_members_val NUMERIC;
- max_members_val NUMERIC;
- found NUMERIC;
- BEGIN
- for cfp in SELECT * FROM rhnOrgChannelFamilyPermissions
- WHERE channel_family_id = channel_family_id_in
- AND org_id = org_id_in
- LOOP
- found := 1;
- current_members_val := cfp.current_members;
- max_members_val := cfp.max_members;
- END LOOP;
-
- -- not found: either the channel fam doesn't have an entry in cfp, or the org doesn't have access to it.
- -- either way, there are no available subscriptions
-
- IF found IS NULL
- THEN
- RETURN 0;
- END IF;
-
- -- null max members? in that case, pass it on; NULL means infinite
- IF max_members_val IS NULL
- THEN
- RETURN NULL;
- END IF;
-
- -- otherwise, return the delta
- RETURN max_members_val - current_members_val;
- END$$ language plpgsql;
-
- CREATE OR REPLACE FUNCTION available_fve_family_subs(channel_family_id_in IN NUMERIC, org_id_in IN NUMERIC)
- RETURNS NUMERIC
- AS $$
- declare
- cfp record;
- fve_current_members_val NUMERIC;
- fve_max_members_val NUMERIC;
- found NUMERIC;
- BEGIN
- for cfp in SELECT * FROM rhnOrgChannelFamilyPermissions
- WHERE channel_family_id = channel_family_id_in
- AND org_id = org_id_in
- LOOP
- found := 1;
- fve_current_members_val := cfp.fve_current_members;
- fve_max_members_val := cfp.fve_max_members;
- END LOOP;
-
- -- not found: either the channel fam doesn't have an entry in cfp, or the org doesn't have access to it.
- -- either way, there are no available subscriptions
-
- IF found IS NULL
- THEN
- RETURN 0;
- END IF;
-
- -- null max members? in that case, pass it on; NULL means infinite
- IF fve_max_members_val IS NULL
- THEN
- RETURN NULL;
- END IF;
-
- -- otherwise, return the delta
- RETURN fve_max_members_val - fve_current_members_val;
- END$$ language plpgsql;
-
- -- *******************************************************************
- -- FUNCTION: channel_family_current_members
- -- Calculates and returns the actual count of systems consuming
- -- physical channel subscriptions.
- -- Called by: update_family_counts
- -- rhn_entitlements.repoll_virt_guest_entitlements
- -- *******************************************************************
- create or replace function channel_family_current_members(channel_family_id_in IN NUMERIC,
- org_id_in IN NUMERIC)
- returns numeric
- as $$
- declare
- current_members_count numeric := 0;
- begin
- select count(distinct 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$$ language plpgsql;
-
-
- create or replace function cfam_curr_fve_members(
- channel_family_id_in IN NUMERIC,
- org_id_in IN NUMERIC)
- returns numeric
- as $$
- declare
- current_members_count numeric := 0;
-
- begin
- select count(sc.server_id)
- into current_members_count
- from rhnServerChannel sc,
- rhnChannelFamilyMembers cfm,
- rhnServer s
- where s.org_id = org_id_in
- and s.id = sc.server_id
- and cfm.channel_family_id = channel_family_id_in
- and cfm.channel_id = sc.channel_id
- and exists (
- select 1
- from rhnChannelFamilyServerFve cfsp
- where cfsp.CHANNEL_FAMILY_ID = channel_family_id_in
- and cfsp.server_id = s.id
- );
-
- return current_members_count;
- end$$ language plpgsql;
- CREATE OR REPLACE FUNCTION update_family_counts(channel_family_id_in IN NUMERIC,
- org_id_in IN NUMERIC) returns void
- AS $$
- BEGIN
- update rhnPrivateChannelFamily
- set current_members = rhn_channel.channel_family_current_members(channel_family_id_in, org_id_in),
- fve_current_members = rhn_channel.cfam_curr_fve_members(channel_family_id_in,org_id_in)
- where org_id = org_id_in
- and channel_family_id = channel_family_id_in;
- END$$ language plpgsql;
-
- create or replace function update_group_family_counts(group_label_in IN VARCHAR,
- org_id_in IN NUMERIC)
- returns void
- as $$
- declare
- i record;
- 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
- perform rhn_channel.update_family_counts(i.channel_family_id, i.org_id);
- END LOOP;
- END$$ language plpgsql;
-
- CREATE OR REPLACE FUNCTION available_chan_subscriptions(channel_id_in IN NUMERIC,
- org_id_in IN NUMERIC)
- RETURNS NUMERIC
- AS $$
- declare
- channel_family_id_val NUMERIC;
- BEGIN
- SELECT channel_family_id INTO STRICT channel_family_id_val
- FROM rhnChannelFamilyMembers
- WHERE channel_id = channel_id_in;
-
- RETURN rhn_channel.available_family_subscriptions(
- channel_family_id_val, org_id_in);
- END$$ language plpgsql;
-
- CREATE OR REPLACE FUNCTION available_fve_chan_subs(channel_id_in IN NUMERIC,
- org_id_in IN NUMERIC)
- RETURNS NUMERIC
- AS $$
- declare
- channel_family_id_val NUMERIC;
- BEGIN
- SELECT channel_family_id INTO STRICT channel_family_id_val
- FROM rhnChannelFamilyMembers
- WHERE channel_id = channel_id_in;
-
- RETURN rhn_channel.available_fve_family_subs(
- channel_family_id_val, org_id_in);
- END$$ language plpgsql;
-
- create or replace function unsubscribe_server_from_family(server_id_in in numeric,
- channel_family_id_in in numeric)
- returns void
- as $$
- begin
- delete
- from rhnServerChannel rsc
- where rsc.server_id = server_id_in
- and channel_id in (
- select rcfm.channel_id
- from rhnChannelFamilyMembers rcfm
- where rcfm.channel_family_id = channel_family_id_in);
- end$$ language plpgsql;
-
- create or replace function get_org_id(channel_id_in in numeric)
- returns numeric
- as $$
- declare
- org_id_out numeric;
- begin
- select org_id into strict org_id_out
- from rhnChannel
- where id = channel_id_in;
-
- return org_id_out;
- end$$ language plpgsql;
-
- create or replace function get_cfam_org_access(cfam_id_in in numeric, org_id_in in numeric)
- returns numeric
- as $$
- begin
- if exists(
- select 1
- from rhnOrgChannelFamilyPermissions cfp
- where cfp.org_id = org_id_in
- ) then
- return 1;
- else
- return 0;
- end if;
- end$$ language plpgsql;
-
- create or replace function get_org_access(channel_id_in in numeric, org_id_in in numeric)
- returns integer
- as $$
- begin
- -- the idea: if we get past this query,
- -- the org has access to the channel, else not
- if exists(
- select 1
- from rhnChannelFamilyMembers CFM,
- rhnOrgChannelFamilyPermissions CFP
- where cfp.org_id = org_id_in
- and CFM.channel_family_id = CFP.channel_family_id
- and CFM.channel_id = channel_id_in
- and (CFP.max_members > 0 or CFP.max_members is null or CFP.fve_max_members > 0 or CFP.fve_max_members is null or CFP.org_id = 1) )
- then
- return 1;
- else
- return 0;
- end if;
- end$$ language plpgsql;
-
- -- check if a user has a given role, or if such a role is inferrable
- -- returns NULL if OK, error message otherwise
- create or replace function user_role_check_debug(channel_id_in in numeric,
- user_id_in in numeric,
- role_in in varchar)
- returns varchar
- as $$
- declare
- org_id numeric;
- begin
- org_id := rhn_user.get_org_id(user_id_in);
-
- -- channel might be shared
- if role_in = 'subscribe' and
- rhn_channel.shared_user_role_check(channel_id_in, user_id_in, role_in) = 1 then
- return NULL;
- end if;
-
- if role_in = 'manage' and
- COALESCE(rhn_channel.get_org_id(channel_id_in), -1) <> org_id then
- return 'channel_not_owned';
- end if;
-
- if role_in = 'subscribe' and
- rhn_channel.get_org_access(channel_id_in, org_id) = 0 then
- return 'channel_not_available';
- end if;
-
- -- channel admins have all roles
- if rhn_user.check_role_implied(user_id_in, 'channel_admin') = 1 then
- return NULL;
- 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
- return NULL;
- end if;
- end if;
-
- -- all other roles (manage right now) are explicitly granted
- if rhn_channel.direct_user_role_check(channel_id_in,
- user_id_in, role_in) = 1 then
- return NULL;
- end if;
- return 'direct_permission';
- end$$ language plpgsql;
-
- -- same as above, but with 1/0 output; useful in views, etc
- create or replace function user_role_check(channel_id_in in numeric, user_id_in in numeric, role_in in varchar)
- returns numeric
- as $$
- begin
- if rhn_channel.user_role_check_debug(channel_id_in,
- user_id_in, role_in) is NULL then
- return 1;
- else
- return 0;
- end if;
- end$$ language plpgsql;
-
- --
- -- For multiorg phase II, this function simply checks to see if the user's
- -- has a trust relationship that includes this channel by id.
- --
- create or replace function shared_user_role_check(channel_id in numeric, user_id in numeric, role in varchar)
- returns numeric
- as $$
- declare
- n numeric;
- oid numeric;
- begin
- oid := rhn_user.get_org_id(user_id);
- select 1 into n
- from rhnSharedChannelView s
- where s.id = channel_id and s.org_trust_id = oid;
-
- if not found then
- return 0;
- end if;
-
- return 1;
- end$$ language plpgsql;
-
- -- same as above, but returns 1 if user_id_in is null
- -- This is useful in queries where user_id is not specified
- create or replace function loose_user_role_check(channel_id_in in numeric, user_id_in in numeric, role_in in varchar)
- returns numeric
- as $$
- begin
- if user_id_in is null then
- return 1;
- end if;
- return rhn_channel.user_role_check(channel_id_in, user_id_in, role_in);
- end$$ language plpgsql;
-
- -- directly checks the table, no inferred permissions
- create or replace function direct_user_role_check(channel_id_in in numeric, user_id_in in numeric, role_in in varchar)
- returns numeric
- as $$
- declare
- throwaway numeric;
- begin
- -- the idea: if we get past this query, the user has the role, else no
- select 1 into throwaway
- from rhnChannelPermissionRole CPR,
- rhnChannelPermission CP
- where CP.user_id = user_id_in
- and CP.channel_id = channel_id_in
- and CPR.label = role_in
- and CP.role_id = CPR.id;
-
- if not found then
- return 0;
- end if;
-
- return 1;
- end$$ language plpgsql;
-
- -- check if an org has a certain setting
- create or replace function org_channel_setting(channel_id_in in numeric, org_id_in in numeric, setting_in in varchar)
- returns numeric
- as $$
- declare
- throwaway numeric;
- begin
- -- the idea: if we get past this query, the org has the setting
- select 1 into throwaway
- from rhnOrgChannelSettingsType OCST,
- rhnOrgChannelSettings OCS
- where OCS.org_id = org_id_in
- and OCS.channel_id = channel_id_in
- and OCST.label = setting_in
- and OCS.setting_id = OCST.id;
-
- if not found then
- return 0;
- end if;
-
- return 1;
- end$$ language plpgsql;
-
- CREATE OR REPLACE FUNCTION channel_priority(channel_id_in IN numeric)
- RETURNS numeric
- AS $$
- declare
- channel_name varchar(256);
- priority numeric;
- end_of_life_val timestamptz;
- org_id_val numeric;
- BEGIN
-
- select name, end_of_life, org_id
- into channel_name, end_of_life_val, org_id_val
- from rhnChannel
- where id = channel_id_in;
-
- if end_of_life_val is not null then
- return -400;
- end if;
-
- if channel_name like 'Red Hat Enterprise Linux%' or channel_name like 'RHEL%' then
- priority := 1000;
- if channel_name not like '%Beta%' then
- priority := priority + 1000;
- end if;
-
- priority := priority +
- case
- when channel_name like '%v. 5%' then 600
- when channel_name like '%v. 4%' then 500
- when channel_name like '%v. 3%' then 400
- when channel_name like '%v. 2%' then 300
- when channel_name like '%v. 1%' then 200
- else 0
- end;
-
- priority := priority +
- case
- when channel_name like 'Red Hat Enterprise Linux (v. 5%' then 60
- when (channel_name like '%AS%' and channel_name not like '%Extras%') then 50
- when (channel_name like '%ES%' and channel_name not like '%Extras%') then 40
- when (channel_name like '%WS%' and channel_name not like '%Extras%') then 30
- when (channel_name like '%Desktop%' and channel_name not like '%Extras%') then 20
- when channel_name like '%Extras%' then 10
- else 0
- end;
-
- priority := priority +
- case
- when channel_name like '%)' then 5
- else 0
- end;
-
- priority := priority +
- case
- when channel_name like '%32-bit x86%' then 4
- when channel_name like '%64-bit Intel Itanium%' then 3
- when channel_name like '%64-bit AMD64/Intel EM64T%' then 2
- else 0
- end;
- elsif channel_name like 'Red Hat Desktop%' then
- priority := 900;
-
- if channel_name not like '%Beta%' then
- priority := priority + 50;
- end if;
-
- priority := priority +
- case
- when channel_name like '%v. 4%' then 40
- when channel_name like '%v. 3%' then 30
- when channel_name like '%v. 2%' then 20
- when channel_name like '%v. 1%' then 10
- else 0
- end;
-
- priority := priority +
- case
- when channel_name like '%32-bit x86%' then 4
- when channel_name like '%64-bit Intel Itanium%' then 3
- when channel_name like '%64-bit AMD64/Intel EM64T%' then 2
- else 0
- end;
-
- elsif org_id_val is not null then
- priority := 600;
- else
- priority := 500;
- end if;
-
- return -priority;
-
- end$$ language plpgsql;
-
- -- right now this only does the accounting changes; the cascade
- -- actually does the rhnServerChannel delete.
- create or replace function delete_server_channels(server_id_in in numeric) returns void
- as $$
- begin
- update rhnPrivateChannelFamily
- set current_members = current_members -1
- where org_id in (
- select org_id
- from rhnServer
- where id = server_id_in
- )
- and channel_family_id in (
- select rcfm.channel_family_id
- from rhnChannelFamilyMembers rcfm,
- rhnServerChannel rsc
- where rsc.server_id = server_id_in
- and rsc.channel_id = rcfm.channel_id
- and not exists (
- select 1
- from
- rhnChannelFamilyVirtSubLevel cfvsl,
- rhnSGTypeVirtSubLevel sgtvsl,
- rhnServerEntitlementView sev,
- rhnVirtualInstance vi
- where
- -- system is a virtual instance
- vi.virtual_system_id = server_id_in
- and vi.host_system_id = sev.server_id
- -- system's host has a virt ent
- and sev.label in ('virtualization_host',
- 'virtualization_host_platform')
- and sev.server_group_type_id =
- sgtvsl.server_group_type_id
- -- the host's virt ent grants a cf virt sub level
- and sgtvsl.virt_sub_level_id = cfvsl.virt_sub_level_id
- -- the cf is in that virt sub level
- and cfvsl.channel_family_id = rcfm.channel_family_id
- )
- );
- end$$ language plpgsql;
-
- -- this could certainly be optimized to do updates if needs be
- create or replace function refresh_newest_package(channel_id_in in numeric,
- caller_in in varchar default '(unknown)',
- package_name_id_in in numeric default null)
- returns void
- as $$
- -- procedure refreshes rows for name_id = package_name_id_in or
- -- all rows if package_name_id_in is null
- declare
- channel_lm timestamptz;
- begin
- select last_modified
- into channel_lm
- from rhnChannel
- where id = channel_id_in
- for update;
-
- delete from rhnChannelNewestPackage
- where channel_id = channel_id_in
- and (package_name_id_in is null
- or name_id = package_name_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
- and (package_name_id_in is null
- or name_id = package_name_id_in)
- );
- insert into rhnChannelNewestPackageAudit (channel_id, caller)
- values (channel_id_in, caller_in);
- update rhnChannel
- set last_modified = greatest(current_timestamp,
- last_modified + interval '1 second')
- where id = channel_id_in;
- end$$ language plpgsql;
-
- create or replace function update_channel ( channel_id_in in numeric, invalidate_ss in numeric default 0,
- date_to_use in timestamptz default current_timestamp ) returns void
- as $$
- declare
- channel_last_modified timestamptz;
- last_modified_value timestamptz;
-
- snapshots cursor for
- select snapshot_id id
- from rhnSnapshotChannel
- where channel_id = channel_id_in;
-
- begin
-
- select last_modified
- into channel_last_modified
- from rhnChannel
- where id = channel_id_in;
-
- last_modified_value := date_to_use;
-
- if last_modified_value <= channel_last_modified then
- last_modified_value := last_modified_value + interval '1 second';
- end if;
-
- update rhnChannel set last_modified = last_modified_value
- where id = channel_id_in;
-
- if invalidate_ss = 1 then
- for snapshot in snapshots loop
- update rhnSnapshot
- set invalid = lookup_snapshot_invalid_reason('channel_modified')
- where id = snapshot.id;
- end loop;
- end if;
-
- end$$ language plpgsql;
-
- create or replace function update_channels_by_package ( package_id_in in numeric, date_to_use in timestamptz default current_timestamp ) returns void
- as $$
- declare
- channels cursor for
- select channel_id
- from rhnChannelPackage
- where package_id = package_id_in
- order by channel_id;
-
- begin
- for channel in channels loop
- -- we want to invalidate the snapshot assocated with the channel when we
- -- do this b/c we know we've added or removed or packages
- perform rhn_channel.update_channel ( channel.channel_id, 1, date_to_use );
- end loop;
- end$$ language plpgsql;
-
-
- create or replace function update_channels_by_errata ( errata_id_in numeric, date_to_use in timestamptz default current_timestamp ) returns void
- as $$
- declare
- channels cursor for
- select channel_id
- from rhnChannelErrata
- where errata_id = errata_id_in
- order by channel_id;
-
- begin
- for channel in channels loop
- -- we won't invalidate snapshots, b/c just changing the errata associated with
- -- a channel shouldn't invalidate snapshots
- perform rhn_channel.update_channel ( channel.channel_id, 0, date_to_use );
- end loop;
- end$$ language plpgsql;
-
- create or replace function update_needed_cache(channel_id_in in numeric) returns void
- as $$
- declare
- server record;
- begin
- -- we intentionaly do a loop here instead of one huge select
- -- b/c we want to break update into smaller transaction to unblock other sessions
- -- querying rhnServerNeededCache
- for server in (
- select sc.server_id as id
- from rhnServerChannel sc
- where sc.channel_id = channel_id_in
- ) loop
- perform rhn_server.update_needed_cache(server.id);
- end loop;
- end$$ language plpgsql;
-
- create or replace function set_comps(channel_id_in in numeric, path_in in varchar, timestamp_in in varchar) returns void
- as $$
- declare
- row record;
- begin
- for row in (
- select relative_filename, last_modified
- from rhnChannelComps
- where channel_id = channel_id_in
- ) loop
- if row.relative_filename = path_in
- and row.last_modified = to_timestamp(timestamp_in, 'YYYYMMDDHH24MISS') then
- return;
- end if;
- end loop;
- delete from rhnChannelComps
- where channel_id = channel_id_in;
- insert into rhnChannelComps (id, channel_id, relative_filename, last_modified, created, modified)
- values (sequence_nextval('rhn_channelcomps_id_seq'), channel_id_in, path_in, to_timestamp(timestamp_in, 'YYYYMMDDHH24MISS'), current_timestamp, current_timestamp);
- end$$ language plpgsql;
-
--- restore the original setting
-update pg_settings set setting = overlay( setting placing '' from 1 for (length('rhn_channel')+1) ) where name = 'search_path';
commit ab519082232175cba498721360298ddd80e458ab
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Wed Jan 22 11:37:14 2014 +0100
Revert "'is' followed by 'declare' is rarely needed"
This reverts commit 27b39e4923be5d9a865f891ced55e80f48f17e3e.
diff --git a/schema/spacewalk/oracle/packages/rhn_channel.pkb b/schema/spacewalk/oracle/packages/rhn_channel.pkb
index a7c56ff..b393579 100644
--- a/schema/spacewalk/oracle/packages/rhn_channel.pkb
+++ b/schema/spacewalk/oracle/packages/rhn_channel.pkb
@@ -1102,6 +1102,7 @@ IS
is
-- procedure refreshes rows for name_id = package_name_id_in or
-- all rows if package_name_id_in is null
+ declare
channel_lm timestamp with local time zone;
begin
select last_modified
diff --git a/schema/spacewalk/postgres/packages/rhn_channel.pkb b/schema/spacewalk/postgres/packages/rhn_channel.pkb
index c883c88..3471f21 100644
--- a/schema/spacewalk/postgres/packages/rhn_channel.pkb
+++ b/schema/spacewalk/postgres/packages/rhn_channel.pkb
@@ -1,4 +1,4 @@
--- oracle equivalent source sha1 10eaf6c8fb6cd20874ec411571cea6e1646cac72
+-- oracle equivalent source sha1 b89b116bf39a095c05c4ae0f9813fd43f0437132
--
-- Copyright (c) 2008--2013 Red Hat, Inc.
--
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-2.0-to-spacewalk-schema-2.1/037-rhn_channel.pkb.oracle b/schema/spacewalk/upgrade/spacewalk-schema-2.0-to-spacewalk-schema-2.1/037-rhn_channel.pkb.oracle
index a7c56ff..b393579 100644
--- a/schema/spacewalk/upgrade/spacewalk-schema-2.0-to-spacewalk-schema-2.1/037-rhn_channel.pkb.oracle
+++ b/schema/spacewalk/upgrade/spacewalk-schema-2.0-to-spacewalk-schema-2.1/037-rhn_channel.pkb.oracle
@@ -1102,6 +1102,7 @@ IS
is
-- procedure refreshes rows for name_id = package_name_id_in or
-- all rows if package_name_id_in is null
+ declare
channel_lm timestamp with local time zone;
begin
select last_modified
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-2.0-to-spacewalk-schema-2.1/037-rhn_channel.pkb.postgresql b/schema/spacewalk/upgrade/spacewalk-schema-2.0-to-spacewalk-schema-2.1/037-rhn_channel.pkb.postgresql
index c883c88..3471f21 100644
--- a/schema/spacewalk/upgrade/spacewalk-schema-2.0-to-spacewalk-schema-2.1/037-rhn_channel.pkb.postgresql
+++ b/schema/spacewalk/upgrade/spacewalk-schema-2.0-to-spacewalk-schema-2.1/037-rhn_channel.pkb.postgresql
@@ -1,4 +1,4 @@
--- oracle equivalent source sha1 10eaf6c8fb6cd20874ec411571cea6e1646cac72
+-- oracle equivalent source sha1 b89b116bf39a095c05c4ae0f9813fd43f0437132
--
-- Copyright (c) 2008--2013 Red Hat, Inc.
--
10 years, 4 months
java/conf
by mkollar
java/conf/eclipse/checkstyle_eclipse.xml | 4 ----
1 file changed, 4 deletions(-)
New commits:
commit 057279af1f70e32ff760f8fd5824d8a24ebf57a4
Author: Matej Kollar <mkollar(a)redhat.com>
Date: Tue Jan 21 18:19:31 2014 +0100
Inconsistency in build vs. eclipse checkstyle.
diff --git a/java/conf/eclipse/checkstyle_eclipse.xml b/java/conf/eclipse/checkstyle_eclipse.xml
index 600b707..c5de47b 100644
--- a/java/conf/eclipse/checkstyle_eclipse.xml
+++ b/java/conf/eclipse/checkstyle_eclipse.xml
@@ -37,10 +37,6 @@ test
<property name="scope" value="public"/>
<property name="allowUndeclaredRTE" value="true"/>
</module>
-<module name="JavadocType">
-<property name="scope" value="package"/>
-<property name="versionFormat" value="\$Rev.*\$"/>
-</module>
<module name="ConstantName">
</module>
<module name="LocalFinalVariableName">
10 years, 4 months
Changes to 'refs/tags/spacewalk-java-2.1.122-1'
by Tomas Lestach
Tag 'spacewalk-java-2.1.122-1' created by Tomas Lestach <tlestach(a)redhat.com> at 2014-01-22 09:42 +0000
Tagging package [spacewalk-java] version [2.1.122-1] in directory [java/].
Changes since spacewalk-backend-2.1.43-1:
Michael Calmer (1):
fix CVE URL in updateinfo references
Tomas Kasparek (1):
1009396 - escape system name for SystemRemoteCommand page
Tomas Lestach (2):
let taskomatic link commons-io
Automatic commit of package [spacewalk-java] release [2.1.122-1].
---
java/code/src/com/redhat/rhn/taskomatic/task/repomd/UpdateInfoWriter.java | 5 +++--
java/code/webapp/WEB-INF/pages/systems/system-remote-command.jsp | 3 ++-
java/conf/default/rhn_taskomatic_daemon.conf | 1 +
java/spacewalk-java.spec | 7 ++++++-
rel-eng/packages/spacewalk-java | 2 +-
5 files changed, 13 insertions(+), 5 deletions(-)
---
10 years, 4 months
java/spacewalk-java.spec rel-eng/packages
by Tomas Lestach
java/spacewalk-java.spec | 7 ++++++-
rel-eng/packages/spacewalk-java | 2 +-
2 files changed, 7 insertions(+), 2 deletions(-)
New commits:
commit af90c5896277d7cc0370df74551b93eec2b050a1
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Wed Jan 22 10:42:01 2014 +0100
Automatic commit of package [spacewalk-java] release [2.1.122-1].
diff --git a/java/spacewalk-java.spec b/java/spacewalk-java.spec
index b08a85c..8c02550 100644
--- a/java/spacewalk-java.spec
+++ b/java/spacewalk-java.spec
@@ -28,7 +28,7 @@ Name: spacewalk-java
Summary: Spacewalk Java site packages
Group: Applications/Internet
License: GPLv2
-Version: 2.1.121
+Version: 2.1.122
Release: 1%{?dist}
URL: https://fedorahosted.org/spacewalk
Source0: https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
@@ -801,6 +801,11 @@ fi
%{jardir}/postgresql-jdbc.jar
%changelog
+* Wed Jan 22 2014 Tomas Lestach <tlestach(a)redhat.com> 2.1.122-1
+- let taskomatic link commons-io
+- fix CVE URL in updateinfo references
+- 1009396 - escape system name for SystemRemoteCommand page
+
* Fri Jan 17 2014 Michael Mraka <michael.mraka(a)redhat.com> 2.1.121-1
- increase column length for CVE ids
diff --git a/rel-eng/packages/spacewalk-java b/rel-eng/packages/spacewalk-java
index 2e108ea..3d45759 100644
--- a/rel-eng/packages/spacewalk-java
+++ b/rel-eng/packages/spacewalk-java
@@ -1 +1 @@
-2.1.121-1 java/
+2.1.122-1 java/
10 years, 4 months