6 commits - web/html web/modules
by Jan Pazdziora
web/html/errata_hidden/details.pxi | 137 --------------------------
web/html/errata_hidden/list.pxi | 80 ---------------
web/html/errata_hidden/login.pxi | 90 -----------------
web/html/errata_not_found.pxt | 85 ----------------
web/modules/sniglets/Sniglets/Errata.pm | 13 --
web/modules/sniglets/Sniglets/PublicErrata.pm | 13 --
6 files changed, 418 deletions(-)
New commits:
commit dd8f56cb9fd02da96c80692737052f39e0237a89
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Mon Feb 1 13:56:12 2010 +0100
Removal of public_errata_list_vs_details made /errata_hidden/list.pxi not used, removing.
diff --git a/web/html/errata_hidden/list.pxi b/web/html/errata_hidden/list.pxi
deleted file mode 100644
index 2f002e5..0000000
--- a/web/html/errata_hidden/list.pxi
+++ /dev/null
@@ -1,80 +0,0 @@
-<?xml version="1.0" encoding="utf8"?>
-<pxt-passthrough>
-
-<pxt-use class="Sniglets::ListUtils" />
-<pxt-use class="Sniglets::PublicErrata" />
-
-<table width="100%" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td width="99%" valign="top">
- <h1><img src="/img/rhn-icon-errata.gif"/>
- <pxt-formvar>
- <public-errata-product-name product="{formvar:product}"/>
- </pxt-formvar><public-errata-type /> Advisories
- </h1>
- </td>
- <td rowspan="2" valign="top" align="right">
- <table border="0" cellspacing="0" cellpadding="2">
- <tr>
- <td nowrap="1" align="right"><font style="color:#666666; font-family:helvetica; text-decoration:none; font-size:10pt;">Security</font></td>
- <td width="99%">
- <img align="absmiddle" src="/img/wrh-security.gif" alt="Security Advisory" /></td>
-
- </tr>
- <tr>
- <td nowrap="1" align="right"><font style="color:#666666; font-family:helvetica; text-decoration:none; font-size:10pt;">Bug Fix</font></td>
- <td>
- <img align="absmiddle" src="/img/wrh-bug.gif" alt="Bug Fix Advisory" /></td>
- </tr>
- <tr>
- <td nowrap="1" align="right"><font style="color:#666666; font-family:helvetica; text-decoration:none; font-size:10pt;">Enhancement</font></td>
- <td>
- <img align="absmiddle" src="/img/wrh-product.gif" alt="Enhancement Advisory" /></td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td><public-errata-filter /></td>
- </tr>
-</table>
-
-<br />
-
-
-<table cellpadding="4" cellspacing="0" border="0" width="100%" class="list">
-<public-errata-filter-type-url>
-<thead>
-<tr>
-<pxt-formvar>
- <th align="center">Type</th>
- <th align="left">{severity}</th>
- <th align="left">{advisory}</th>
- <th align="left">{synopsis}</th>
- <th align="center">{date}</th>
-</pxt-formvar>
-</tr>
-</thead>
-</public-errata-filter-type-url>
-<tbody>
-
-<rhn-fix-list list_type="errata">
-<empty_list_mesg>
- <tr class="list-row-odd">
- <td align="center" class="first-column last-column" colspan="4">No Errata</td>
- </tr>
-</empty_list_mesg>
-<public-errata-list>
- <tr class="{class}">
- <td valign="middle" align="center" class="first-column">{errata_icon}</td>
- <td valign="middle">{severity}</td>
- <td valign="middle">{errata_advisory_name}</td>
- <td valign="middle"><a href="/errata/{errata_advisory_html_version}">{errata_synopsis}</a></td>
- <td valign="middle" nowrap="1" class="last_column">{errata_update_date}</td>
-
- </tr>
-</public-errata-list>
-</rhn-fix-list>
-</tbody>
-</table>
-</pxt-passthrough>
commit caf8621fb07fc439881459d009686f17ae3779d1
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Mon Feb 1 13:55:11 2010 +0100
Removal of public_errata_list_vs_details made errata_not_found.pxt not used, removing.
diff --git a/web/html/errata_not_found.pxt b/web/html/errata_not_found.pxt
deleted file mode 100644
index eb0d697..0000000
--- a/web/html/errata_not_found.pxt
+++ /dev/null
@@ -1,85 +0,0 @@
-<?xml version="1.0" encoding="utf8"?>
-<pxt-passthrough>
-
-<pxt-use class="Grail::Frame" />
-<pxt-use class="Sniglets::Users" />
-<pxt-use class="Sniglets::Errata" />
-
-
-<public-secure-links-if-logged-in servers="www.redhat.com|rhn.redhat.com">
-<grail-canvas-template base="/errata_hidden/rh_template.pxt" mode="main">
-
-
-<table border="0" cellspacing="0" cellpadding="0">
-<tr>
-<td><img src="/img/pixel.gif" width="10" height="30" border="0" alt="" /></td>
-<td width="100%">
-
-</td>
-</tr>
-<tr>
-<td colspan="2"><img src="/img/pixel.gif" width="1" height="5" border="0" alt="" /></td>
-</tr>
-</table>
-
-
-<!-- begin wrapper table -->
-<!-- main body table -->
-<table width="100%" border="0" cellspacing="0" cellpadding="0">
-<!-- CONTROL ROW; adjust widths here -->
- <tr>
-<!-- left gutter 20px -->
- <td><img src="/img/pixel.gif" width="20" height="1" border="0" alt="" /></td>
-<!-- content is stretchy so 100% -->
- <td width="100%"><img src="/img/pixel.gif" width="1" height="1" border="0" alt="" /></td>
-<!-- right hand margin 15px -->
- <td><img src="/img/pixel.gif" width="15" height="1" border="0" alt="" /></td>
- </tr>
-<!-- CONTENT ROW -->
- <tr>
-<!-- left gutter; adjust width in control row above -->
- <td> </td>
-<!-- main body; adjust width in control row above -->
- <td valign="top">
-
-<!-- MAIN BODY TABLE is nested for scalability -->
- <table width="100%" border="0" cellspacing="0" cellpadding="0">
- <tr>
-
- <td width="100%">
-
-<h1>Erratum not found</h1>
-
-<p>Red Hat errata names are of the form RHSA-YYYY-XXX for security
-advisories, RHEA-YYYY-XXX for enhancement advisories, RHBA-YYYY-XXX
-for bug fix advisories, where YYYY is a year and XXX is a number.</p>
-
-<p>If the name you provided is in the proper format, then one of the
-following may have happened:</p>
-
-<ul>
-<li>
- We have assigned this erratum name but the issue is not yet
- public or our advisory is not yet ready. In some cases, a name may
- be used before the corresponding information has been added to the
- Red Hat web site. This may happen when a security problem is new.
-</li>
-<li>
- Your source provided or linked to an incorrect name
-</li>
-</ul>
-
-<p>Click <a href="http://www.redhat.com/apps/support/errata/">here</a> to find currently available errata.</p>
-
-
- </td>
- </tr>
- </table>
- </td>
- </tr>
-</table>
-
-
-</grail-canvas-template>
-</public-secure-links-if-logged-in>
-</pxt-passthrough>
commit 81a6d9ed257159f85108b7719a2e5ab16f632dca
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Mon Feb 1 13:54:06 2010 +0100
Removal of public_errata_list_vs_details made /errata_hidden/details.pxi not used, removing.
diff --git a/web/html/errata_hidden/details.pxi b/web/html/errata_hidden/details.pxi
deleted file mode 100644
index 6ff0bae..0000000
--- a/web/html/errata_hidden/details.pxi
+++ /dev/null
@@ -1,137 +0,0 @@
-<?xml version="1.0" encoding="utf8"?>
-<pxt-passthrough>
-
-<pxt-use class="Sniglets::PublicErrata" />
-
-<public-errata-details>
-
-<h1>{errata_icon} {errata_synopsis}</h1>
-
-<table class="details">
- <tr>
- <th>Advisory:</th>
- <td>{errata_advisory_id}</td>
- </tr>
- <tr>
- <th>Type:</th>
- <td>{errata_advisory_type}</td>
- </tr>
- <tr>
- <th>Severity:</th>
- <td>{severity}</td>
- </tr>
- <tr>
- <th>Issued on:</th>
- <td>{errata_issue_date}</td>
- </tr>
- <tr>
- <th>Last updated on:</th>
- <td>{errata_update_date}</td>
- </tr>
-<public-errata-affected-products>
- <tr>
- <th valign="top">Affected Products:</th>
- <td>{affected_products}</td>
- </tr>
-</public-errata-affected-products>
- <tr>
- <th valign="top">OVAL:</th>
- <td valign="top">{oval_link}</td>
- </tr>
-<public-errata-cves>
- <tr>
- <th valign="top">CVEs (<a href="http://cve.mitre.org">cve.mitre.org</a>):</th>
- <td rowspan="2" valign="top">
-<cve_entry_block><a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name={cve}">{cve}</a><br /></cve_entry_block>
- </td>
- </tr>
-</public-errata-cves>
-</table>
-
-<br />
-
-<h2>Details</h2>
-<div class="page-summary">
-<errata_topic><p>{errata_topic}</p></errata_topic>
-
-<p>{errata_description}</p>
-</div>
-
-
-<br />
-
-<h2>Solution</h2>
-<div class="page-summary">{errata_solution}</div>
-<br />
-
-<h2>Updated packages</h2>
-
-<table border="0" cellpadding="6" cellspacing="0">
-
-<errata_updated_packages>
- <tr>
- <td colspan="2"><font color="#666666"><strong><a name="{product}">{product}</a></strong></font></td>
- </tr>
- <tr>
- <td colspan="2"><hr noshade="1" size="1" /></td>
- </tr>
- <_arch>
- <tr>
- <td colspan="2"><font color="#666666"><strong>{arch}:</strong></font></td>
- </tr>
- <_file_entry>
- <tr bgcolor="{color}">
- <td>{filename}</td>
- <td valign="top" align="right">    <tt>{md5sum}</tt></td>
- </tr>
- </_file_entry>
- <tr>
- <td colspan="2"> </td>
- </tr>
- </_arch>
-</errata_updated_packages>
-
-</table>
-
-
-<errata_bugs_fixed>
-<br />
-<h2>Bugs fixed (see <A HREF="http://bugzilla.redhat.com/bugzilla">bugzilla</A> for more information)</h2>
-<div class="page-summary">
-<p>{errata_bugs_fixed}</p>
-</div>
-</errata_bugs_fixed>
-
-<errata_references>
-<br />
-<h2>References</h2>
-<div class="page-summary">
-<public-errata-cves>
-<cve_entry_block><a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name={cve}">http://cve.mitre.org/cgi-bin/cvename.cgi?name={cve}</a><br /></cve_entry_block>
-</public-errata-cves>
-{errata_references}
-</div>
-</errata_references>
-
-
-<errata_keywords>
-<br />
-<h2>Keywords</h2>
-<div class="page-summary">
-{errata_keywords}
-</div>
-</errata_keywords>
-
-</public-errata-details>
-
-<br />
-
-<hr border="1" />
-These packages are GPG signed by Red Hat for security. Our key and
-details on how to verify the signature are available from:<br />
-
-<a href="https://www.redhat.com/security/team/key/#package">https://www.redhat.com/security/team/key/#package</a>
-
-<p>The Red Hat security contact is <a href="mailto:secalert@redhat.com">secalert(a)redhat.com</a>. More contact details at <a href="http://www.redhat.com/security/team/contact/">http://www.redhat.com/security/team/contact/</a></p>
-
-</pxt-passthrough>
commit d1b6b18e2185632705437c9ed2be4d735992a755
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Mon Feb 1 13:53:23 2010 +0100
Removal of public_errata_list_vs_details made /errata_hidden/login.pxi not used, removing.
diff --git a/web/html/errata_hidden/login.pxi b/web/html/errata_hidden/login.pxi
deleted file mode 100644
index ccbe5d1..0000000
--- a/web/html/errata_hidden/login.pxi
+++ /dev/null
@@ -1,90 +0,0 @@
-<?xml version="1.0" encoding="utf8"?>
-<pxt-passthrough>
-
-<pxt-use class="Sniglets::Users" />
-
-<table cellpadding="0" cellspacing="0" border="0" style="table-layout:fixed">
- <col width="36" /><col width="100%" /><col width="14%" />
- <tr>
- <td width="36"><img src="/img/pixel.gif" width="36" height="1" alt="" border="0" /></td>
- <td width="100%" valign="top">
- <div class="pagetitle1"> </div>
- </td>
- <td width="14%"> </td>
- </tr>
-</table>
-<br />
-
-<!-- begin wrapper table -->
-<table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td><img src="/img/pixel.gif" width="20" height="1" alt="" /></td>
- <td width="98%" valign="top">
-
- <!-- begin page content -->
- <img src="/img/rhr_login.gif" width="89" height="33" alt="Sign In" /><br /> 
- <p>
-
- <p class="palenote">Note: Our personalized web services require that your browser be enabled for JavaScript and cookies.</p>
- </p>
- <table width="100%" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td><span class="subhead1">Registered Users:</span>
- <p><!-- begin login pane -->
-
-
-<pxt-form>
- <rhn-login-form method="POST">
-<table width="150" border="0" cellspacing="0" cellpadding="3">
-
- <tr>
-<pxt-include-late file="/network/components/message_queues/local.pxi" /> </tr>
- <tr>
- <td valign="middle">Username:</td>
-
-
- <td><input tabindex="2" type="text" name="username" size="20" maxlength="64" value="[formvar:username]"/></td>
- </tr>
- <tr>
- <td valign="middle">Password: </td>
-
- <td><input tabindex="2" type="password" name="password" size="20" maxlength="32" /></td>
- </tr>
- <tr>
- <td colspan="2" valign="middle" nowrap="nowrap"><input
- type="SUBMIT" name="SUBMIT" value="Sign In" /></td>
- </tr>
-</table>
- [login_form_hidden]
- <pxt-hidden name="url_bounce" />
- </rhn-login-form>
-</pxt-form>
-<!-- end login pane --></p>
-  
-
-
-</td>
-
- <!-- spacer columm -->
- <td><img src="/img/pixel.gif" width="20" height="1" alt="" /></td>
- <!-- /spacer column -->
-
- <td valign="top" nowrap="nowrap"><span class="subhead1">Where can I use my Red Hat login?</span>
- <ul>
- <li class="plushalfspace"><span class="smalltext">Convenient sitewide login for all of Red Hat</span></li>
- <li class="plushalfspace"><span class="smalltext">Free trial version of Red Hat Network</span></li>
- <li class="plushalfspace"><span class="smalltext">High speed software downloads</span></li>
- <li class="plushalfspace"><span class="smalltext">Free tech support in our lively Community Forums</span></li>
- <li class="plushalfspace"><span class="smalltext">Exclusive contests, discounts and promotions</span></li>
- </ul></td>
- </tr>
- </table>
-<p> <br /></p>
-<!-- end content -->
-
- </td>
- <td><div class="rightmargin"> </div></td>
- </tr>
-</table>
-<!-- end wrapper table -->
-</pxt-passthrough>
commit 5c5736f92199975f640589bad7c7054bd8d63c1d
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Mon Feb 1 13:50:52 2010 +0100
The other errata_in_db does not seem to be used either.
diff --git a/web/modules/sniglets/Sniglets/Errata.pm b/web/modules/sniglets/Sniglets/Errata.pm
index cffb439..2cf41f9 100644
--- a/web/modules/sniglets/Sniglets/Errata.pm
+++ b/web/modules/sniglets/Sniglets/Errata.pm
@@ -65,19 +65,6 @@ my %e_icons = ('Security Advisory' => { image => '/img/rhn-icon-security.gif',
alt => "Bug Fix Advisory" } );
-# returns true if we have db knowledge of an errata.
-sub errata_in_db {
- my $path_info = shift;
-
- $path_info =~ m/\/(.*?)-(.*?)\.html/;
- my ($type, $version) = ($1, $2);
- $version =~ s/-/:/;
-
- my $errata = RHN::Errata->find_by_advisory(-type => $type, -version => $version);
-
- return $errata;
-}
-
sub errata_name {
my $pxt = shift;
commit 654c79681cba9b9bea4a6e3570318af57de50786
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Mon Feb 1 13:49:41 2010 +0100
Removal of public_errata_list_vs_details made errata_in_db not called, removing.
diff --git a/web/modules/sniglets/Sniglets/PublicErrata.pm b/web/modules/sniglets/Sniglets/PublicErrata.pm
index a09840f..144f429 100644
--- a/web/modules/sniglets/Sniglets/PublicErrata.pm
+++ b/web/modules/sniglets/Sniglets/PublicErrata.pm
@@ -115,19 +115,6 @@ sub cve_in_db {
return $errata;
}
-# returns true if we have db knowledge of an errata.
-sub errata_in_db {
- my $path_info = shift;
-
- $path_info =~ m/\/(.*?)-(.*?)\.html/;
- my ($type, $version) = ($1, $2);
- $version =~ s/-/:/;
-
- my $errata = RHN::Errata->find_by_advisory(-type => $type, -version => $version);
-
- return $errata;
-}
-
sub public_errata_product_list {
my $pxt = shift;
my %params = @_;
14 years, 2 months
2 commits - web/html web/modules
by Jan Pazdziora
web/html/errata | 53 ----------------------
web/modules/sniglets/Sniglets/PublicErrata.pm | 60 --------------------------
2 files changed, 113 deletions(-)
New commits:
commit a372250556c965a25751a23d22de55eaf153bf04
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Mon Feb 1 13:42:56 2010 +0100
Removal of web/html/errata made public-errata-list-vs-details and public_errata_list_vs_details unused, removing.
diff --git a/web/modules/sniglets/Sniglets/PublicErrata.pm b/web/modules/sniglets/Sniglets/PublicErrata.pm
index fbcf52f..a09840f 100644
--- a/web/modules/sniglets/Sniglets/PublicErrata.pm
+++ b/web/modules/sniglets/Sniglets/PublicErrata.pm
@@ -41,7 +41,6 @@ sub register_tags {
# for www.redhat.com'ish public errata display
$pxt->register_tag('public-errata-product-list' => \&public_errata_product_list);
$pxt->register_tag('public-errata-affected-products' => \&public_errata_affected_products, 2);
- $pxt->register_tag('public-errata-list-vs-details' => \&public_errata_list_vs_details);
$pxt->register_tag('public-errata-filter' => \&public_errata_filter);
$pxt->register_tag('public-errata-filter-type-url' => \&public_errata_filter_type_url);
$pxt->register_tag('public-errata-type' => \&public_errata_type);
@@ -172,65 +171,6 @@ sub public_cve_list {
}
}
-sub public_errata_list_vs_details {
- my $pxt = shift;
-
- my $cache_time = PXT::Config->get("public_errata_cache_time") || "15 minutes";
-
- return $pxt->include('/errata_hidden/product_list.pxi') unless ($pxt->path_info and $pxt->path_info ne '/');
-
- PXT::Debug->log(7, "either list or details");
-
- if ($pxt->path_info eq '/') {
- return $pxt->include('/errata_hidden/product_list.pxi');
- }
-
- if ($pxt->path_info =~ m {^/login.pxt} ) {
- return $pxt->include('/errata_hidden/login.pxi');
- }
- elsif ($pxt->path_info =~ m {^/RH[BES]A-\d\d\d\d-\d\d\d.*?\.html}) {
- # figure out if we have in db...
- if (errata_in_db($pxt->path_info)) {
-
- # cache details page...
- $pxt->cache_document_contents($cache_time);
- return $pxt->include('/errata_hidden/details.pxi');;
- }
- else {
- if (-e $pxt->document_root() . '/errata_hidden/static_errata' . $pxt->path_info ) {
- return $pxt->include('/errata_hidden/static_errata' . $pxt->path_info);
- }
- else {
- $pxt->path_info =~ m {^/(RH[BES]A.*?)\.html$};
- my $attempted_adv = $1;
- $attempted_adv = PXT::Utils->escapeURI($attempted_adv);
- $pxt->redirect("/errata_not_found.pxt?attempted_adv=$attempted_adv");
- }
- }
- }
- elsif ($pxt->path_info =~ m {^/(CVE|CAN)-\d\d\d\d-\d\d\d\d.*?\.html}) {
- if (cve_in_db($pxt->path_info)) {
- $pxt->cache_document_contents($cache_time);
- return $pxt->include('/errata_hidden/cve_details.pxi');
- }
- else {
- $pxt->path_info =~ m {^/((CVE|CAN).*?)\.html$};
- my $attempted_adv = $1;
- $attempted_adv = PXT::Utils->escapeURI($attempted_adv);
- $pxt->redirect("/cve_not_found.pxt?attempted_adv=$attempted_adv");
- }
- }
- elsif ($pxt->path_info =~ m {^/rh}) {
-
- # cache errata list page...
- $pxt->cache_document_contents($cache_time);
- return $pxt->include('/errata_hidden/list.pxi');
- }
- else {
- $pxt->redirect("/file_not_found.pxt");
- }
-}
-
sub public_errata_affected_products {
my $pxt = shift;
my %params = @_;
commit eb4f6e7085eba0924845cb7600b557d0a30a6db0
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Mon Feb 1 13:40:07 2010 +0100
492161 - web/html/errata is not supported in Spacewalk/Satellite.
diff --git a/web/html/errata b/web/html/errata
deleted file mode 100644
index 06927fa..0000000
--- a/web/html/errata
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="utf8"?>
-<pxt-passthrough>
-<pxt-use class="Grail::Frame" />
-<pxt-use class="Sniglets::PublicErrata" />
-<pxt-use class="Sniglets::Users" />
-<pxt-use class="Sniglets::Packages" />
-
-<public-secure-links-if-logged-in servers="www.redhat.com|rhn.redhat.com">
-<grail-canvas-template base="/errata_hidden/rh_template.pxt" mode="main">
-
-<table border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td colspan="2"><img src="/img/pixel.gif" width="1" height="15" border="0" alt="" /></td>
- </tr>
-</table>
-<!-- begin wrapper table -->
-<!-- main body table -->
-<table width="100%" border="0" cellspacing="0" cellpadding="0">
-<!-- CONTROL ROW; adjust widths here -->
- <tr>
-<!-- left gutter 20px -->
- <td><img src="/img/pixel.gif" width="20" height="1" border="0" alt="" /></td>
-<!-- content is stretchy so 100% -->
- <td width="100%"><img src="/img/pixel.gif" width="1" height="1" border="0" alt="" /></td>
-<!-- right hand margin 15px -->
- <td><img src="/img/pixel.gif" width="15" height="1" border="0" alt="" /></td>
- </tr>
-<!-- CONTENT ROW -->
- <tr>
-<!-- left gutter; adjust width in control row above -->
- <td> </td>
-<!-- main body; adjust width in control row above -->
- <td valign="top">
-
-<!-- MAIN BODY TABLE is nested for scalability -->
- <table width="100%" border="0" cellspacing="0" cellpadding="0">
- <tr>
-
- <td width="100%">
-
-<public-errata-list-vs-details />
-
- </td>
- </tr>
- </table>
- </td>
- </tr>
-</table>
-
-
-</grail-canvas-template>
-</public-secure-links-if-logged-in>
-</pxt-passthrough>
14 years, 2 months
2 commits - web/modules
by Jan Pazdziora
web/modules/rhn/RHN/DB/Errata.pm | 78 ---------------------------------------
1 file changed, 78 deletions(-)
New commits:
commit 05de8c8b5f66c17603da0957d20d4781f0e987aa
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Mon Feb 1 13:34:10 2010 +0100
Removal of Sniglets::RSS made affected_product_lines not needed, removing.
diff --git a/web/modules/rhn/RHN/DB/Errata.pm b/web/modules/rhn/RHN/DB/Errata.pm
index 0cd213d..e9b47e9 100644
--- a/web/modules/rhn/RHN/DB/Errata.pm
+++ b/web/modules/rhn/RHN/DB/Errata.pm
@@ -66,48 +66,6 @@ EOQ
$sth->finish;
return $retval;
}
-sub affected_product_lines {
- my $self_or_id = shift;
- my $id;
-
- if (ref $self_or_id) {
- $id = $self_or_id->id;
- }
- else {
- $id = shift;
- }
-
- my $dbh = RHN::DB->connect;
-
- my $query;
- my $sth;
-
- $query = <<EOQ;
-SELECT DISTINCT PL.name
- FROM rhnProductLine PL,
- rhnProduct P,
- rhnProductChannel PC,
- rhnErrataFileChannel EFC,
- rhnErrataFile EF
- WHERE EF.errata_id = ?
- AND EF.id = EFC.errata_file_id
- AND EFC.channel_id = PC.channel_id
- AND PC.product_id = P.id
- AND P.product_line_id = PL.id
-EOQ
-
- $sth = $dbh->prepare($query);
- $sth->execute($id);
-
- my @ret;
-
- while (my ($row) = $sth->fetchrow) {
- push @ret, $row;
- }
- $sth->finish;
-
- return @ret;
-}
sub affected_products {
my $self = shift;
commit 54f2b3a4cfbcdc8cdd0206711232ca6cb539e06a
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Mon Feb 1 13:33:22 2010 +0100
Removal of Sniglets::RSS made rss_recent_errata not needed, removing.
diff --git a/web/modules/rhn/RHN/DB/Errata.pm b/web/modules/rhn/RHN/DB/Errata.pm
index d87fa90..0cd213d 100644
--- a/web/modules/rhn/RHN/DB/Errata.pm
+++ b/web/modules/rhn/RHN/DB/Errata.pm
@@ -932,42 +932,6 @@ EOQ
return @ret;
}
-sub rss_recent_errata {
- my $class = shift;
- my $n = shift;
-
- my $dbh = RHN::DB->connect;
- my $sth;
-
- my $query = <<EOQ;
-SELECT DISTINCT E.id, E.advisory, E.synopsis, E.description, E.topic, E.update_date
- FROM rhnErrata E,
- rhnChannelErrata CE,
- rhnProductChannel PC
- WHERE PC.channel_id = CE.channel_id
- AND CE.errata_id = E.id
-ORDER BY E.UPDATE_DATE DESC
-EOQ
-
- $sth = $dbh->prepare($query);
- $sth->execute();
-
- my @ret;
- while (my @row = $sth->fetchrow) {
- last unless --$n;
-
- my $h;
-
- for my $n (qw/id advisory synopsis description topic/) {
- $h->{$n} = shift @row || '';
- }
-
- push @ret, $h;
- }
-
- return @ret;
-}
-
sub method_names {
return $e->method_names;
}
14 years, 2 months
2 commits - web/html web/modules
by Jan Pazdziora
web/html/rpc/.htaccess | 10 ----
web/html/rpc/recent-errata.pxt | 1
web/modules/sniglets/Sniglets/RSS.pm | 83 -----------------------------------
3 files changed, 94 deletions(-)
New commits:
commit bae7ab219568dfebb0c4cf5b210fad1c46f565dd
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Mon Feb 1 13:27:18 2010 +0100
Removal of recent-errata.pxt made Sniglets::RSS unused, removing.
diff --git a/web/modules/sniglets/Sniglets/RSS.pm b/web/modules/sniglets/Sniglets/RSS.pm
deleted file mode 100644
index 02927ad..0000000
--- a/web/modules/sniglets/Sniglets/RSS.pm
+++ /dev/null
@@ -1,83 +0,0 @@
-#
-# Copyright (c) 2008 Red Hat, Inc.
-#
-# This software is licensed to you under the GNU General Public License,
-# version 2 (GPLv2). There is NO WARRANTY for this software, express or
-# implied, including the implied warranties of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
-# along with this software; if not, see
-# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
-#
-# Red Hat trademarks are not licensed under GPLv2. No permission is
-# granted to use or replicate Red Hat trademarks that are incorporated
-# in this software or its documentation.
-#
-
-use strict;
-
-package Sniglets::RSS;
-
-use RHN::Errata;
-
-use Cache::FileCache;
-use XML::RSS;
-
-sub register_tags {
- my $class = shift;
- my $pxt = shift;
-
- $pxt->register_tag('rhn-rss-recent-errata' => \&rss_recent_errata);
-}
-
-sub rss_recent_errata {
- my $pxt = shift;
- my %params = @_;
-
- $pxt->content_type("text/xml");
-
- my $num = 10;
-
- my $cache = new Cache::FileCache({namespace => 'rhn_recent_errata'});
-
- # if the cache is less than 7200 seconds old, return it, no questions
- # asked
-
- my $cached_errata_mtime = $cache->get("cached_errata_mtime");
-
- if ($cached_errata_mtime and time - $cached_errata_mtime < 7200) {
- return $cache->get('cached_errata_rss');
- }
-
- my @errata = RHN::Errata->rss_recent_errata($num);
-
- my $rss = new XML::RSS(version => '0.91');
-
- $rss->channel(title => "Red Hat Errata",
- link => "http://www.redhat.com/apps/support/errata/",
- description => "The latest Red Hat errata for Red Hat Linux");
-
- foreach my $e (@errata) {
- $e->{advisory} =~ m/^(.*?):(.*?)-(.*?)$/;
- my $advisory = "$1-$2.html";
-
- my @affected_prod_lines = RHN::Errata->affected_product_lines($e->{id});
- my @cves = RHN::Errata->related_cves($e->{id});
- my $affected_prod_str = @affected_prod_lines ? join(',', @affected_prod_lines) . ': ' : '';
- my $cve_str = @cves ? ' ' . join(", ", @cves) : '';
-
- my $description = "${affected_prod_str}$e->{topic}${cve_str}";
-
- $rss->add_item(title => "$e->{advisory}: $e->{synopsis}",
- link => qq{http://rhn.redhat.com/errata/$advisory},
- description => PXT::Utils->escapeHTML($description));
- }
-
- my $ret = $rss->as_string();
-
- $cache->set(cached_errata_rss => $ret);
- $cache->set(cached_errata_mtime => time);
-
- return $ret;
-}
-
-1;
commit 935b40b8dd8cf413793228a8b712b30c3ad44822
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Mon Feb 1 13:26:05 2010 +0100
recent-errata.pxt is not usable due to empty rhnProductChannel table; removing as dead code.
diff --git a/web/html/rpc/.htaccess b/web/html/rpc/.htaccess
deleted file mode 100644
index 5ac3cd4..0000000
--- a/web/html/rpc/.htaccess
+++ /dev/null
@@ -1,10 +0,0 @@
-<Files api>
- ForceType text/pxt
- SetHandler perl-script
- PerlModule PXT::ApacheHandler
- PerlHandler PXT::ApacheHandler
-</Files>
-
-<Files recent-errata.pxt>
- PerlSetVar no_sessions 1
-</Files>
diff --git a/web/html/rpc/recent-errata.pxt b/web/html/rpc/recent-errata.pxt
deleted file mode 100644
index 21465cc..0000000
--- a/web/html/rpc/recent-errata.pxt
+++ /dev/null
@@ -1 +0,0 @@
-<pxt-passthrough><pxt-use class="Sniglets::RSS" /><rhn-rss-recent-errata /></pxt-passthrough>
14 years, 2 months
Changes to 'refs/tags/spacewalk-monitoring-selinux-0.8.3-1'
by Jan Pazdziora
Tag 'spacewalk-monitoring-selinux-0.8.3-1' created by Jan Pazdziora <jpazdziora(a)redhat.com> at 2010-02-01 12:21 +0000
Tagging package [spacewalk-monitoring-selinux] version [0.8.3-1] in directory [selinux/spacewalk-monitoring-selinux/].
Changes since spacewalk-monitoring-selinux-0.8.2-1:
Jan Pazdziora (2):
529570 - allow monitoring to use winbind.
Automatic commit of package [spacewalk-monitoring-selinux] release [0.8.3-1].
Michael Mraka (1):
upgrade scripts for 9376fa4c50709439d71a5dc7071b22f552021820
---
rel-eng/packages/spacewalk-monitoring-selinux | 2
schema/spacewalk/upgrade/spacewalk-schema-0.7-to-spacewalk-schema-0.8/050-rhn_channel.pkb.sql | 1417 ++++++++
schema/spacewalk/upgrade/spacewalk-schema-0.7-to-spacewalk-schema-0.8/050-rhn_channel.pks.sql | 253 +
schema/spacewalk/upgrade/spacewalk-schema-0.7-to-spacewalk-schema-0.8/051-rhn_entitlements.pkb.sql | 1728 ++++++++++
schema/spacewalk/upgrade/spacewalk-schema-0.7-to-spacewalk-schema-0.8/051-rhn_entitlements.pks.sql | 226 +
selinux/spacewalk-monitoring-selinux/spacewalk-monitoring-selinux.spec | 5
selinux/spacewalk-monitoring-selinux/spacewalk-monitoring.te | 4
7 files changed, 3633 insertions(+), 2 deletions(-)
---
14 years, 2 months
rel-eng/packages selinux/spacewalk-monitoring-selinux
by Jan Pazdziora
rel-eng/packages/spacewalk-monitoring-selinux | 2 +-
selinux/spacewalk-monitoring-selinux/spacewalk-monitoring-selinux.spec | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)
New commits:
commit 2a96c7d7dabf5625d27c8740783eeb080d4445c4
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Mon Feb 1 13:21:53 2010 +0100
Automatic commit of package [spacewalk-monitoring-selinux] release [0.8.3-1].
diff --git a/rel-eng/packages/spacewalk-monitoring-selinux b/rel-eng/packages/spacewalk-monitoring-selinux
index a3ff7b7..4e3e640 100644
--- a/rel-eng/packages/spacewalk-monitoring-selinux
+++ b/rel-eng/packages/spacewalk-monitoring-selinux
@@ -1 +1 @@
-0.8.2-1 selinux/spacewalk-monitoring-selinux/
+0.8.3-1 selinux/spacewalk-monitoring-selinux/
diff --git a/selinux/spacewalk-monitoring-selinux/spacewalk-monitoring-selinux.spec b/selinux/spacewalk-monitoring-selinux/spacewalk-monitoring-selinux.spec
index 619cb87..65869da 100644
--- a/selinux/spacewalk-monitoring-selinux/spacewalk-monitoring-selinux.spec
+++ b/selinux/spacewalk-monitoring-selinux/spacewalk-monitoring-selinux.spec
@@ -7,7 +7,7 @@
%define modulename spacewalk-monitoring
Name: spacewalk-monitoring-selinux
-Version: 0.8.2
+Version: 0.8.3
Release: 1%{?dist}
Summary: SELinux policy module supporting Spacewalk monitoring
@@ -144,6 +144,9 @@ fi
%attr(0755,root,root) %{_sbindir}/%{name}-enable
%changelog
+* Mon Feb 01 2010 Jan Pazdziora 0.8.3-1
+- 529570 - allow monitoring to use winbind
+
* Mon Feb 01 2010 Jan Pazdziora 0.8.2-1
- 558448 - define context for /etc/nocpulse/SatCluster.ini
14 years, 2 months
selinux/spacewalk-monitoring-selinux
by Jan Pazdziora
selinux/spacewalk-monitoring-selinux/spacewalk-monitoring.te | 4 ++++
1 file changed, 4 insertions(+)
New commits:
commit 5d3d96cd5d57457de0b8c813adcb0321babc4e63
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Mon Feb 1 13:20:23 2010 +0100
529570 - allow monitoring to use winbind.
diff --git a/selinux/spacewalk-monitoring-selinux/spacewalk-monitoring.te b/selinux/spacewalk-monitoring-selinux/spacewalk-monitoring.te
index c344ddd..2a92320 100644
--- a/selinux/spacewalk-monitoring-selinux/spacewalk-monitoring.te
+++ b/selinux/spacewalk-monitoring-selinux/spacewalk-monitoring.te
@@ -163,3 +163,7 @@ corenet_udp_bind_all_nodes(spacewalk_monitoring_t)
corenet_tcp_connect_ftp_port(spacewalk_monitoring_t)
allow spacewalk_monitoring_t self:process setpgid;
+
+optional_policy(`
+ samba_stream_connect_winbind(spacewalk_monitoring_t)
+')
14 years, 2 months
schema/spacewalk
by Michael Mraka
schema/spacewalk/upgrade/spacewalk-schema-0.7-to-spacewalk-schema-0.8/050-rhn_channel.pkb.sql | 1417 ++++++++
schema/spacewalk/upgrade/spacewalk-schema-0.7-to-spacewalk-schema-0.8/050-rhn_channel.pks.sql | 253 +
schema/spacewalk/upgrade/spacewalk-schema-0.7-to-spacewalk-schema-0.8/051-rhn_entitlements.pkb.sql | 1728 ++++++++++
schema/spacewalk/upgrade/spacewalk-schema-0.7-to-spacewalk-schema-0.8/051-rhn_entitlements.pks.sql | 226 +
4 files changed, 3624 insertions(+)
New commits:
commit 58127693619043cd5fca329508cb881632550d67
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Mon Feb 1 11:47:24 2010 +0100
upgrade scripts for 9376fa4c50709439d71a5dc7071b22f552021820
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.7-to-spacewalk-schema-0.8/050-rhn_channel.pkb.sql b/schema/spacewalk/upgrade/spacewalk-schema-0.7-to-spacewalk-schema-0.8/050-rhn_channel.pkb.sql
new file mode 100644
index 0000000..e438524
--- /dev/null
+++ b/schema/spacewalk/upgrade/spacewalk-schema-0.7-to-spacewalk-schema-0.8/050-rhn_channel.pkb.sql
@@ -0,0 +1,1417 @@
+--
+-- Copyright (c) 2008 Red Hat, Inc.
+--
+-- This software is licensed to you under the GNU General Public License,
+-- version 2 (GPLv2). There is NO WARRANTY for this software, express or
+-- implied, including the implied warranties of MERCHANTABILITY or FITNESS
+-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+-- along with this software; if not, see
+-- http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+--
+-- Red Hat trademarks are not licensed under GPLv2. No permission is
+-- granted to use or replicate Red Hat trademarks that are incorporated
+-- in this software or its documentation.
+--
+--
+--
+--
+
+CREATE OR REPLACE
+PACKAGE BODY rhn_channel
+IS
+ body_version varchar2(100) := '';
+
+ -- Cursor that fetches all the possible base channels for a
+ -- (server_arch_id, release, org_id) combination
+ cursor base_channel_cursor(
+ release_in in varchar2,
+ server_arch_id_in in number,
+ org_id_in in number
+ ) return rhnChannel%ROWTYPE is
+ select distinct c.*
+ from rhnDistChannelMap dcm,
+ rhnServerChannelArchCompat scac,
+ rhnChannel c,
+ rhnChannelPermissions cp
+ where cp.org_id = org_id_in
+ and cp.channel_id = c.id
+ and c.parent_channel is null
+ and c.id = dcm.channel_id
+ and c.channel_arch_id = dcm.channel_arch_id
+ and dcm.release = release_in
+ and scac.server_arch_id = server_arch_id_in
+ and scac.channel_arch_id = c.channel_arch_id;
+
+ FUNCTION get_license_path(channel_id_in IN NUMBER)
+ RETURN VARCHAR2
+ IS
+ license_val VARCHAR2(1000);
+ BEGIN
+ SELECT CFL.license_path INTO license_val
+ FROM rhnChannelFamilyLicense CFL, rhnChannelFamilyMembers CFM
+ WHERE CFM.channel_id = channel_id_in
+ AND CFM.channel_family_id = CFL.channel_family_id;
+
+ RETURN license_val;
+
+ EXCEPTION
+ WHEN NO_DATA_FOUND
+ THEN
+ RETURN NULL;
+ END get_license_path;
+
+
+ PROCEDURE license_consent(channel_id_in IN NUMBER, user_id_in IN NUMBER, server_id_in IN NUMBER)
+ IS
+ channel_family_id_val NUMBER;
+ BEGIN
+ channel_family_id_val := rhn_channel.family_for_channel(channel_id_in);
+ IF channel_family_id_val IS NULL
+ THEN
+ rhn_exception.raise_exception('channel_subscribe_no_family');
+ END IF;
+
+ IF rhn_channel.get_license_path(channel_id_in) IS NULL
+ THEN
+ rhn_exception.raise_exception('channel_consent_no_license');
+ END IF;
+
+ INSERT INTO rhnChannelFamilyLicenseConsent (channel_family_id, user_id, server_id)
+ VALUES (channel_family_id_val, user_id_in, server_id_in);
+ END license_consent;
+
+ PROCEDURE subscribe_server(server_id_in IN NUMBER, channel_id_in NUMBER, immediate_in NUMBER := 1, user_id_in in number := null, recalcfamily_in NUMBER := 1)
+ IS
+ channel_parent_val rhnChannel.parent_channel%TYPE;
+ parent_subscribed BOOLEAN;
+ server_has_base_chan BOOLEAN;
+ server_already_in_chan BOOLEAN;
+ channel_family_id_val NUMBER;
+ server_org_id_val NUMBER;
+ available_subscriptions NUMBER;
+ consenting_user NUMBER;
+ allowed number := 0;
+ current_members_val number;
+ BEGIN
+ if user_id_in is not null then
+ allowed := rhn_channel.user_role_check(channel_id_in, user_id_in, 'subscribe');
+ else
+ allowed := 1;
+ end if;
+
+ if allowed = 0 then
+ rhn_exception.raise_exception('no_subscribe_permissions');
+ end if;
+
+
+ SELECT parent_channel INTO channel_parent_val FROM rhnChannel WHERE id = channel_id_in;
+
+ IF channel_parent_val IS NOT NULL
+ THEN
+ -- child channel; if attempting to cross-subscribe a child to the wrong base, silently ignore
+ parent_subscribed := FALSE;
+
+ FOR check_subscription IN check_server_subscription(server_id_in, channel_parent_val)
+ LOOP
+ parent_subscribed := TRUE;
+ END LOOP check_subscription;
+
+ IF NOT parent_subscribed
+ THEN
+ RETURN;
+ END IF;
+ ELSE
+ -- base channel
+ server_has_base_chan := FALSE;
+ FOR base IN server_base_subscriptions(server_id_in)
+ LOOP
+ server_has_base_chan := TRUE;
+ END LOOP base;
+
+ IF server_has_base_chan
+ THEN
+ rhn_exception.raise_exception('channel_server_one_base');
+ END IF;
+ END IF;
+
+ FOR check_subscription IN check_server_subscription(server_id_in, channel_id_in)
+ LOOP
+ server_already_in_chan := TRUE;
+ END LOOP check_subscription;
+
+ IF server_already_in_chan
+ THEN
+ RETURN;
+ END IF;
+
+ channel_family_id_val := rhn_channel.family_for_channel(channel_id_in);
+ IF channel_family_id_val IS NULL
+ THEN
+ rhn_exception.raise_exception('channel_subscribe_no_family');
+ END IF;
+
+ --
+ -- Use the org_id of the server only if the org_id of the channel = NULL.
+ -- This is required for subscribing to shared channels.
+ --
+ SELECT NVL(org_id, (SELECT org_id FROM rhnServer WHERE id = server_id_in))
+ INTO server_org_id_val
+ FROM rhnChannel
+ WHERE id = channel_id_in;
+
+ select current_members
+ into current_members_val
+ from rhnPrivateChannelFamily
+ where org_id = server_org_id_val and channel_family_id = channel_family_id_val
+ for update of current_members;
+
+ available_subscriptions := rhn_channel.available_family_subscriptions(channel_family_id_val, server_org_id_val);
+
+ IF available_subscriptions IS NULL OR
+ available_subscriptions > 0 or
+ can_server_consume_virt_channl(server_id_in, channel_family_id_val) = 1
+ THEN
+
+ IF rhn_channel.get_license_path(channel_id_in) IS NOT NULL
+ THEN
+ BEGIN
+
+ SELECT user_id INTO consenting_user
+ FROM rhnChannelFamilyLicenseConsent
+ WHERE channel_family_id = channel_family_id_val
+ AND server_id = server_id_in;
+
+ EXCEPTION
+ WHEN NO_DATA_FOUND THEN
+ rhn_exception.raise_exception('channel_subscribe_no_consent');
+ END;
+ END IF;
+
+ insert into rhnServerHistory (id,server_id,summary,details) (
+ select rhn_event_id_seq.nextval,
+ server_id_in,
+ 'subscribed to channel ' || SUBSTR(c.label, 0, 106),
+ c.label
+ from rhnChannel c
+ where c.id = channel_id_in
+ );
+ UPDATE rhnServer SET channels_changed = sysdate WHERE id = server_id_in;
+ INSERT INTO rhnServerChannel (server_id, channel_id) VALUES (server_id_in, channel_id_in);
+ IF recalcfamily_in > 0
+ THEN
+ rhn_channel.update_family_counts(channel_family_id_val, server_org_id_val);
+ END IF;
+ queue_server(server_id_in, immediate_in);
+ ELSE
+ rhn_exception.raise_exception('channel_family_no_subscriptions');
+ END IF;
+
+ END subscribe_server;
+
+ function can_server_consume_virt_channl(
+ server_id_in in number,
+ family_id_in in number )
+ return number
+ is
+
+ cursor server_virt_families is
+ select vi.virtual_system_id, cfvsl.channel_family_id
+ from
+ rhnChannelFamilyVirtSubLevel cfvsl,
+ rhnSGTypeVirtSubLevel sgtvsl,
+ rhnVirtualInstance vi
+ where
+ vi.virtual_system_id = server_id_in
+ and sgtvsl.virt_sub_level_id = cfvsl.virt_sub_level_id
+ and cfvsl.channel_family_id = family_id_in
+ and exists (
+ select 1
+ from rhnServerEntitlementView sev
+ where vi.host_system_id = sev.server_id
+ and sev.server_group_type_id = sgtvsl.server_group_type_id );
+ begin
+
+ for server_virt_family in server_virt_families loop
+ return 1;
+ end loop;
+
+ return 0;
+
+ end;
+
+
+ PROCEDURE bulk_subscribe_server(channel_id_in IN NUMBER, set_label_in IN VARCHAR2, set_uid_in IN NUMBER)
+ IS
+ BEGIN
+ FOR server IN rhn_set.set_iterator(set_label_in, set_uid_in)
+ LOOP
+ rhn_channel.subscribe_server(server.element, channel_id_in, 0, set_uid_in);
+ END LOOP server;
+ END bulk_subscribe_server;
+
+ PROCEDURE bulk_server_base_change(channel_id_in IN NUMBER, set_label_in IN VARCHAR2, set_uid_in IN NUMBER)
+ IS
+ BEGIN
+ FOR server IN rhn_set.set_iterator(set_label_in, set_uid_in)
+ LOOP
+ IF rhn_server.can_change_base_channel(server.element) = 1
+ THEN
+ rhn_channel.clear_subscriptions(TO_NUMBER(server.element));
+ rhn_channel.subscribe_server(server.element, channel_id_in, 0, set_uid_in);
+ END IF;
+ END LOOP server;
+ END bulk_server_base_change;
+
+ procedure bulk_server_basechange_from(
+ set_label_in in varchar2,
+ set_uid_in in number,
+ old_channel_id_in in number,
+ new_channel_id_in in number
+ ) is
+ cursor servers is
+ select sc.server_id id
+ from rhnChannel nc,
+ rhnServerChannelArchCompat scac,
+ rhnServer s,
+ rhnChannel oc,
+ rhnServerChannel sc,
+ rhnSet st
+ where 1=1
+ -- first, find the servers we're looking for.
+ and st.label = set_label_in
+ and st.user_id = set_uid_in
+ and st.element = sc.server_id
+ -- now, filter out anything that's not in the
+ -- old base channel.
+ and sc.channel_id = old_channel_id_in
+ and sc.channel_id = oc.id
+ and oc.parent_channel is null
+ -- now, see if it's compatible with the new base channel
+ and nc.id = new_channel_id_in
+ and nc.parent_channel is null
+ and sc.server_id = s.id
+ and s.server_arch_id = scac.server_arch_id
+ and scac.channel_arch_id = nc.channel_arch_id;
+ begin
+ for s in servers loop
+ insert into rhnSet (
+ user_id, label, element
+ ) values (
+ set_uid_in,
+ set_label_in || 'basechange',
+ s.id
+ );
+ end loop channel;
+ bulk_server_base_change(new_channel_id_in,
+ set_label_in || 'basechange',
+ set_uid_in);
+ delete from rhnSet
+ where label = set_label_in||'basechange'
+ and user_id = set_uid_in;
+ end bulk_server_basechange_from;
+
+ procedure bulk_guess_server_base(
+ set_label_in in varchar2,
+ set_uid_in in number
+ ) is
+ channel_id number;
+ begin
+ for server in rhn_set.set_iterator(set_label_in, set_uid_in)
+ loop
+ -- anything that doesn't work, we just ignore
+ begin
+ if rhn_server.can_change_base_channel(server.element) = 1
+ then
+ channel_id := guess_server_base(TO_NUMBER(server.element));
+ rhn_channel.clear_subscriptions(TO_NUMBER(server.element));
+ rhn_channel.subscribe_server(TO_NUMBER(server.element), channel_id, 0, set_uid_in);
+ end if;
+ exception when others then
+ null;
+ end;
+ end loop server;
+ end;
+
+ function guess_server_base(
+ server_id_in in number
+ ) RETURN number is
+ cursor server_cursor is
+ select s.server_arch_id, s.release, s.org_id
+ from rhnServer s
+ where s.id = server_id_in;
+ begin
+ for s in server_cursor loop
+ for channel in base_channel_cursor(s.release,
+ s.server_arch_id, s.org_id)
+ loop
+ return channel.id;
+ end loop base_channel_cursor;
+ end loop server_cursor;
+ -- Server not found, or no base channel applies to it
+ return null;
+ end;
+
+ -- Private function
+ function normalize_server_arch(server_arch_in in varchar2)
+ return varchar2
+ deterministic
+ is
+ suffix VARCHAR2(128) := '-redhat-linux';
+ suffix_len NUMBER := length(suffix);
+ begin
+ if server_arch_in is NULL then
+ return NULL;
+ end if;
+ if instr(server_arch_in, '-') > 0
+ then
+ -- Suffix already present
+ return server_arch_in;
+ end if;
+ return server_arch_in || suffix;
+ end normalize_server_arch;
+
+ --
+ --
+ -- Raises:
+ -- server_arch_not_found
+ -- no_subscribe_permissions
+ function base_channel_for_release_arch(
+ release_in in varchar2,
+ server_arch_in in varchar2,
+ org_id_in in number := -1,
+ user_id_in in number := null
+ ) return number is
+ server_arch varchar2(256) := normalize_server_arch(server_arch_in);
+ server_arch_id number;
+ begin
+ -- Look up the server arch
+ begin
+ select id
+ into server_arch_id
+ from rhnServerArch
+ where label = server_arch;
+ exception
+ when no_data_found then
+ rhn_exception.raise_exception('server_arch_not_found');
+ end;
+ return base_channel_rel_archid(release_in, server_arch_id,
+ org_id_in, user_id_in);
+ end base_channel_for_release_arch;
+
+ function base_channel_rel_archid(
+ release_in in varchar2,
+ server_arch_id_in in number,
+ org_id_in in number := -1,
+ user_id_in in number := null
+ ) return number is
+ denied_channel_id number := null;
+ valid_org_id number := org_id_in;
+ valid_user_id number := user_id_in;
+ channel_subscribable number;
+ begin
+ if org_id_in = -1 and user_id_in is not null then
+ -- Get the org id from the user id
+ begin
+ select org_id
+ into valid_org_id
+ from web_contact
+ where id = user_id_in;
+ exception
+ when no_data_found then
+ -- User doesn't exist
+ -- XXX Only list public stuff for now
+ valid_user_id := null;
+ valid_org_id := -1;
+ end;
+ end if;
+
+ for c in base_channel_cursor(release_in, server_arch_id_in, valid_org_id)
+ loop
+ -- This row is a possible match
+ if valid_user_id is null then
+ -- User ID not specified, so no user to channel permissions to
+ -- check
+ return c.id;
+ end if;
+
+ -- Check user to channel permissions
+ select loose_user_role_check(c.id, user_id_in, 'subscribe')
+ into channel_subscribable
+ from dual;
+
+ if channel_subscribable = 1 then
+ return c.id;
+ end if;
+
+ -- Base channel exists, but is not subscribable; keep trying
+ denied_channel_id := c.id;
+ end loop base_channel_fetch;
+
+ if denied_channel_id is not null then
+ rhn_exception.raise_exception('no_subscribe_permissions');
+ end if;
+ -- No base channel applies
+ return NULL;
+ end base_channel_rel_archid;
+
+ procedure bulk_guess_server_base_from(
+ set_label_in in varchar2,
+ set_uid_in in number,
+ channel_id_in in number
+ ) is
+ cursor channels(server_id_in in number) is
+ select rsc.channel_id
+ from rhnServerChannel rsc,
+ rhnChannel rc
+ where server_id_in = rsc.server_id
+ and rsc.channel_id = rc.id
+ and rc.parent_channel is null;
+ begin
+ for server in rhn_set.set_iterator(set_label_in, set_uid_in)
+ loop
+ for channel in channels(server.element)
+ loop
+ if channel.channel_id = channel_id_in
+ then
+ insert into rhnSet (user_id, label, element) values (set_uid_in, set_label_in || 'baseguess', server.element);
+ end if;
+ end loop channel;
+ end loop server;
+ bulk_guess_server_base(set_label_in||'baseguess',set_uid_in);
+ delete from rhnSet where label = set_label_in||'baseguess' and user_id = set_uid_in;
+ end;
+
+
+ PROCEDURE clear_subscriptions(server_id_in IN NUMBER, deleting_server IN NUMBER := 0,
+ update_family_countsYN IN NUMBER := 1)
+ IS
+ cursor server_channels(server_id_in in number) is
+ select s.org_id, sc.channel_id, cfm.channel_family_id
+ from rhnServer s,
+ rhnServerChannel sc,
+ rhnChannelFamilyMembers cfm
+ where s.id = server_id_in
+ and s.id = sc.server_id
+ and sc.channel_id = cfm.channel_id;
+ BEGIN
+ for channel in server_channels(server_id_in)
+ loop
+ unsubscribe_server(server_id_in, channel.channel_id, 1, 1, deleting_server, update_family_countsYN);
+ end loop channel;
+ END clear_subscriptions;
+
+ PROCEDURE unsubscribe_server(server_id_in IN NUMBER, channel_id_in NUMBER, immediate_in NUMBER := 1, unsubscribe_children_in number := 0,
+ deleting_server IN NUMBER := 0,
+ update_family_countsYN IN NUMBER := 1)
+ IS
+ channel_family_id_val NUMBER;
+ server_org_id_val NUMBER;
+ available_subscriptions NUMBER;
+ server_already_in_chan BOOLEAN;
+ cursor channel_family_is_proxy(channel_family_id_in in number) is
+ select 1
+ from rhnChannelFamily
+ where id = channel_family_id_in
+ and label = 'rhn-proxy';
+ cursor channel_family_is_satellite(channel_family_id_in in number) is
+ select 1
+ from rhnChannelFamily
+ where id = channel_family_id_in
+ and label = 'rhn-satellite';
+ -- this is *EXACTLY* like check_server_parent_membership, but if we recurse
+ -- with the package-level one, we get a "cursor already open", so we need a
+ -- copy on our call stack instead. GROAN.
+ cursor local_chk_server_parent_memb (
+ server_id_in number,
+ channel_id_in number ) is
+ select c.id
+ from rhnChannel c,
+ rhnServerChannel sc
+ where 1=1
+ and c.parent_channel = channel_id_in
+ and c.id = sc.channel_id
+ and sc.server_id = server_id_in;
+ BEGIN
+ FOR child IN local_chk_server_parent_memb(server_id_in, channel_id_in)
+ LOOP
+ if unsubscribe_children_in = 1 then
+ unsubscribe_server(server_id_in => server_id_in,
+ channel_id_in => child.id,
+ immediate_in => immediate_in,
+ unsubscribe_children_in => unsubscribe_children_in,
+ deleting_server => deleting_server,
+ update_family_countsYN => update_family_countsYN);
+ else
+ rhn_exception.raise_exception('channel_unsubscribe_child_exists');
+ end if;
+ END LOOP child;
+
+ server_already_in_chan := FALSE;
+
+ FOR check_subscription IN check_server_subscription(server_id_in, channel_id_in)
+ LOOP
+ server_already_in_chan := TRUE;
+ END LOOP check_subscription;
+
+ IF NOT server_already_in_chan
+ THEN
+ RETURN;
+ END IF;
+
+ if deleting_server = 0 then
+
+ insert into rhnServerHistory (id,server_id,summary,details) (
+ select rhn_event_id_seq.nextval,
+ server_id_in,
+ 'unsubscribed from channel ' || SUBSTR(c.label, 0, 106),
+ c.label
+ from rhnChannel c
+ where c.id = channel_id_in
+ );
+
+ UPDATE rhnServer SET channels_changed = sysdate WHERE id = server_id_in;
+ end if;
+
+ DELETE FROM rhnServerChannel WHERE server_id = server_id_in AND channel_id = channel_id_in;
+
+ if deleting_server = 0 then
+ queue_server(server_id_in, immediate_in);
+ end if;
+
+ channel_family_id_val := rhn_channel.family_for_channel(channel_id_in);
+ IF channel_family_id_val IS NULL
+ THEN
+ rhn_exception.raise_exception('channel_unsubscribe_no_family');
+ END IF;
+
+ for ignore in channel_family_is_satellite(channel_family_id_val) loop
+ delete from rhnSatelliteInfo where server_id = server_id_in;
+ delete from rhnSatelliteChannelFamily where server_id = server_id_in;
+ end loop;
+
+ for ignore in channel_family_is_proxy(channel_family_id_val) loop
+ delete from rhnProxyInfo where server_id = server_id_in;
+ end loop;
+
+ DELETE FROM rhnChannelFamilyLicenseConsent
+ WHERE channel_family_id = channel_family_id_val
+ AND server_id = server_id_in;
+
+ SELECT org_id INTO server_org_id_val
+ FROM rhnServer
+ WHERE id = server_id_in;
+
+ if update_family_countsYN = 1 then
+ rhn_channel.update_family_counts(channel_family_id_val, server_org_id_val);
+ end if;
+ END unsubscribe_server;
+
+ PROCEDURE bulk_unsubscribe_server(channel_id_in IN NUMBER, set_label_in IN VARCHAR2, set_uid_in IN NUMBER)
+ IS
+ BEGIN
+ FOR server IN rhn_set.set_iterator(set_label_in, set_uid_in)
+ LOOP
+ rhn_channel.unsubscribe_server(server.element, channel_id_in, 0);
+ END LOOP server;
+ END bulk_unsubscribe_server;
+
+ FUNCTION family_for_channel(channel_id_in IN NUMBER)
+ RETURN NUMBER
+ IS
+ channel_family_id_val NUMBER;
+ BEGIN
+ SELECT channel_family_id INTO channel_family_id_val
+ FROM rhnChannelFamilyMembers
+ WHERE channel_id = channel_id_in;
+
+ RETURN channel_family_id_val;
+ EXCEPTION
+ WHEN NO_DATA_FOUND
+ THEN
+ RETURN NULL;
+ END family_for_channel;
+
+ FUNCTION available_family_subscriptions(channel_family_id_in IN NUMBER, org_id_in IN NUMBER)
+ RETURN NUMBER
+ IS
+ cfp channel_family_perm_cursor%ROWTYPE;
+ current_members_val NUMBER;
+ max_members_val NUMBER;
+ found NUMBER;
+ BEGIN
+ IF NOT channel_family_perm_cursor%ISOPEN
+ THEN
+ OPEN channel_family_perm_cursor(channel_family_id_in, org_id_in);
+ END IF;
+
+ FETCH channel_family_perm_cursor INTO cfp;
+
+ WHILE channel_family_perm_cursor%FOUND
+ LOOP
+ found := 1;
+
+ current_members_val := cfp.current_members;
+ max_members_val := cfp.max_members;
+
+ FETCH channel_family_perm_cursor INTO cfp;
+ END LOOP;
+
+ IF channel_family_perm_cursor%ISOPEN
+ THEN
+ CLOSE channel_family_perm_cursor;
+ END IF;
+
+ -- not found: either the channel fam doesn't have an entry in cfp, or the org doesn't have access to it.
+ -- either way, there are no available subscriptions
+
+ IF found IS NULL
+ THEN
+ RETURN 0;
+ END IF;
+
+ -- null max members? in that case, pass it on; NULL means infinite
+ IF max_members_val IS NULL
+ THEN
+ RETURN NULL;
+ END IF;
+
+ -- otherwise, return the delta
+ RETURN max_members_val - current_members_val;
+ END available_family_subscriptions;
+
+ -- *******************************************************************
+ -- FUNCTION: channel_family_current_members
+ -- Calculates and returns the actual count of systems consuming
+ -- physical channel subscriptions.
+ -- Called by: update_family_counts
+ -- rhn_entitlements.repoll_virt_guest_entitlements
+ -- *******************************************************************
+ function channel_family_current_members(channel_family_id_in IN NUMBER,
+ org_id_in IN NUMBER)
+ return number
+ is
+ current_members_count number := 0;
+ begin
+ select count(distinct server_id)
+ into current_members_count
+ from rhnChannelFamilyServerPhysical cfsp
+ where cfsp.channel_family_id = channel_family_id_in
+ and cfsp.customer_id = org_id_in;
+ return current_members_count;
+ end;
+
+ PROCEDURE update_family_counts(channel_family_id_in IN NUMBER,
+ org_id_in IN NUMBER)
+ IS
+ BEGIN
+ update rhnPrivateChannelFamily
+ set current_members = (
+ channel_family_current_members(channel_family_id_in, org_id_in)
+ )
+ where org_id = org_id_in
+ and channel_family_id = channel_family_id_in;
+
+ END update_family_counts;
+
+ PROCEDURE update_group_family_counts(group_label_in IN VARCHAR2,
+ org_id_in IN NUMBER)
+ IS
+ BEGIN
+ FOR i IN (
+ SELECT DISTINCT CFM.channel_family_id, SG.org_id
+ FROM rhnChannelFamilyMembers CFM
+ JOIN rhnServerChannel SC
+ ON SC.channel_id = CFM.channel_id
+ JOIN rhnServerGroupMembers SGM
+ ON SC.server_id = SGM.server_id
+ JOIN rhnServerGroup SG
+ ON SGM.server_group_id = SG.id
+ JOIN rhnServerGroupType SGT
+ ON SG.group_type = SGT.id
+ WHERE SGT.label = group_label_in
+ AND SG.org_id = org_id_in
+ AND SGT.is_base = 'Y'
+ ) LOOP
+ rhn_channel.update_family_counts(i.channel_family_id, i.org_id);
+ END LOOP;
+ END update_group_family_counts;
+
+ FUNCTION available_chan_subscriptions(channel_id_in IN NUMBER,
+ org_id_in IN NUMBER)
+ RETURN NUMBER
+ IS
+ channel_family_id_val NUMBER;
+ BEGIN
+ SELECT channel_family_id INTO channel_family_id_val
+ FROM rhnChannelFamilyMembers
+ WHERE channel_id = channel_id_in;
+
+ RETURN rhn_channel.available_family_subscriptions(
+ channel_family_id_val, org_id_in);
+ END available_chan_subscriptions;
+
+ -- *******************************************************************
+ -- PROCEDURE: entitle_customer
+ -- Creates a chan fam bucket, or sets max_members for an existing bucket
+ -- Called by: rhn_ep.poll_customer_internal
+ -- Calls: set_family_maxmembers + update_family_counts if the row
+ -- already exists, else it creates it in rhnPrivateChannelFamily.
+ -- *******************************************************************
+ procedure entitle_customer(customer_id_in in number,
+ channel_family_id_in in number,
+ quantity_in in number)
+ is
+ cursor permissions is
+ select 1
+ from rhnPrivateChannelFamily pcf
+ where pcf.org_id = customer_id_in
+ and pcf.channel_family_id = channel_family_id_in;
+ begin
+ for perm in permissions loop
+ set_family_maxmembers(
+ customer_id_in,
+ channel_family_id_in,
+ quantity_in
+ );
+ rhn_channel.update_family_counts(
+ channel_family_id_in,
+ customer_id_in
+ );
+ return;
+ end loop;
+
+ insert into rhnPrivateChannelFamily pcf (
+ channel_family_id, org_id, max_members, current_members
+ ) values (
+ channel_family_id_in, customer_id_in, quantity_in, 0
+ );
+ end;
+
+ -- *******************************************************************
+ -- PROCEDURE: set_family_maxmembers
+ -- Prunes an existing channel family bucket by unsubscribing the
+ -- necessary servers and sets max_members.
+ -- Called by: rhn_channel.entitle_customer
+ -- Calls: unsubscribe_server_from_family
+ -- *******************************************************************
+ procedure set_family_maxmembers(customer_id_in in number,
+ channel_family_id_in in number,
+ quantity_in in number)
+ is
+ cursor servers is
+ select server_id from (
+ select rownum row_number, server_id, modified from (
+ select rcfsp.server_id,
+ rcfsp.modified
+ from rhnChannelFamilyServerPhysical rcfsp
+ where rcfsp.customer_id = customer_id_in
+ and rcfsp.channel_family_id = channel_family_id_in
+ order by modified
+ )
+ where rownum > quantity_in
+ );
+ begin
+ -- prune subscribed servers
+ for server in servers loop
+ rhn_channel.unsubscribe_server_from_family(server.server_id,
+ channel_family_id_in);
+ end loop;
+
+ update rhnPrivateChannelFamily pcf
+ set pcf.max_members = quantity_in
+ where pcf.org_id = customer_id_in
+ and pcf.channel_family_id = channel_family_id_in;
+ end;
+
+ procedure unsubscribe_server_from_family(server_id_in in number,
+ channel_family_id_in in number)
+ is
+ begin
+ delete
+ from rhnServerChannel rsc
+ where rsc.server_id = server_id_in
+ and channel_id in (
+ select rcfm.channel_id
+ from rhnChannelFamilyMembers rcfm
+ where rcfm.channel_family_id = channel_family_id_in);
+ end;
+
+ function get_org_id(channel_id_in in number)
+ return number
+ is
+ org_id_out number;
+ begin
+ select org_id into org_id_out
+ from rhnChannel
+ where id = channel_id_in;
+
+ return org_id_out;
+ end get_org_id;
+
+ function get_cfam_org_access(cfam_id_in in number, org_id_in in number)
+ return number
+ is
+ cursor families is
+ select 1
+ from rhnOrgChannelFamilyPermissions cfp
+ where cfp.org_id = org_id_in;
+ begin
+ -- the idea: if we get past this query,
+ -- the user has the role, else catch the exception and return 0
+ for family in families loop
+ return 1;
+ end loop;
+ return 0;
+ end;
+
+ function get_org_access(channel_id_in in number, org_id_in in number)
+ return number
+ is
+ throwaway number;
+ begin
+ -- the idea: if we get past this query,
+ -- the org has access to the channel, else catch the exception and return 0
+ select distinct 1 into throwaway
+ from rhnChannelFamilyMembers CFM,
+ rhnOrgChannelFamilyPermissions CFP
+ where cfp.org_id = org_id_in
+ and CFM.channel_family_id = CFP.channel_family_id
+ and CFM.channel_id = channel_id_in
+ and (CFP.max_members > 0 or CFP.max_members is null or CFP.org_id = 1);
+
+ return 1;
+ exception
+ when no_data_found
+ then
+ return 0;
+ end;
+
+ -- check if a user has a given role, or if such a role is inferrable
+ function user_role_check_debug(channel_id_in in number,
+ user_id_in in number,
+ role_in in varchar2,
+ reason_out out varchar2)
+ return number
+ is
+ org_id number;
+ begin
+ org_id := rhn_user.get_org_id(user_id_in);
+
+ -- channel might be shared
+ if role_in = 'subscribe' and
+ rhn_channel.shared_user_role_check(channel_id_in, user_id_in, role_in) = 1 then
+ return 1;
+ end if;
+
+ if role_in = 'manage' and
+ NVL(rhn_channel.get_org_id(channel_id_in), -1) <> org_id then
+ reason_out := 'channel_not_owned';
+ return 0;
+ end if;
+
+ if role_in = 'subscribe' and
+ rhn_channel.get_org_access(channel_id_in, org_id) = 0 then
+ reason_out := 'channel_not_available';
+ return 0;
+ end if;
+
+ -- channel admins have all roles
+ if rhn_user.check_role_implied(user_id_in, 'channel_admin') = 1 then
+ reason_out := 'channel_admin';
+ return 1;
+ end if;
+
+ -- the subscribe permission is inferred
+ -- UNLESS the not_globally_subscribable flag is set
+ if role_in = 'subscribe'
+ then
+ if rhn_channel.org_channel_setting(channel_id_in,
+ org_id,
+ 'not_globally_subscribable') = 0 then
+ reason_out := 'globally_subscribable';
+ return 1;
+ end if;
+ end if;
+
+ -- all other roles (manage right now) are explicitly granted
+ reason_out := 'direct_permission';
+ return rhn_channel.direct_user_role_check(channel_id_in,
+ user_id_in, role_in);
+ end;
+
+ -- same as above, but with no OUT param; useful in views, etc
+ function user_role_check(channel_id_in in number, user_id_in in number, role_in in varchar2)
+ return number
+ is
+ throwaway varchar2(256);
+ begin
+ return rhn_channel.user_role_check_debug(channel_id_in, user_id_in, role_in, throwaway);
+ end;
+
+ --
+ -- For multiorg phase II, this function simply checks to see if the user's
+ -- has a trust relationship that includes this channel by id.
+ --
+ function shared_user_role_check(channel_id in number, user_id in number, role in varchar2)
+ return number
+ is
+ n number;
+ oid number;
+ begin
+ oid := rhn_user.get_org_id(user_id);
+ select 1 into n
+ from rhnSharedChannelView s
+ where s.id = channel_id and s.org_trust_id = oid;
+ return 1;
+ exception
+ when no_data_found then
+ return 0;
+ end;
+
+ -- same as above, but returns 1 if user_id_in is null
+ -- This is useful in queries where user_id is not specified
+ function loose_user_role_check(channel_id_in in number, user_id_in in number, role_in in varchar2)
+ return number
+ is
+ begin
+ if user_id_in is null then
+ return 1;
+ end if;
+ return user_role_check(channel_id_in, user_id_in, role_in);
+ end loose_user_role_check;
+
+ -- directly checks the table, no inferred permissions
+ function direct_user_role_check(channel_id_in in number, user_id_in in number, role_in in varchar2)
+ return number
+ is
+ throwaway number;
+ begin
+ -- the idea: if we get past this query, the user has the role, else catch the exception and return 0
+ select 1 into throwaway
+ from rhnChannelPermissionRole CPR,
+ rhnChannelPermission CP
+ where CP.user_id = user_id_in
+ and CP.channel_id = channel_id_in
+ and CPR.label = role_in
+ and CP.role_id = CPR.id;
+
+ return 1;
+ exception
+ when no_data_found
+ then
+ return 0;
+ end;
+
+ -- check if an org has a certain setting
+ function org_channel_setting(channel_id_in in number, org_id_in in number, setting_in in varchar2)
+ return number
+ is
+ throwaway number;
+ begin
+ -- the idea: if we get past this query, the org has the setting, else catch the exception and return 0
+ select 1 into throwaway
+ from rhnOrgChannelSettingsType OCST,
+ rhnOrgChannelSettings OCS
+ where OCS.org_id = org_id_in
+ and OCS.channel_id = channel_id_in
+ and OCST.label = setting_in
+ and OCS.setting_id = OCST.id;
+
+ return 1;
+ exception
+ when no_data_found
+ then
+ return 0;
+ end;
+
+ FUNCTION channel_priority(channel_id_in IN number)
+ RETURN number
+ IS
+ channel_name varchar2(256);
+ priority number;
+ end_of_life_val date;
+ org_id_val number;
+ BEGIN
+
+ select name, end_of_life, org_id
+ into channel_name, end_of_life_val, org_id_val
+ from rhnChannel
+ where id = channel_id_in;
+
+ if end_of_life_val is not null then
+ return -400;
+ end if;
+
+ if channel_name like 'Red Hat Enterprise Linux%' or channel_name like 'RHEL%' then
+ priority := 1000;
+ if channel_name not like '%Beta%' then
+ priority := priority + 1000;
+ end if;
+
+ priority := priority +
+ case
+ when channel_name like '%v. 5%' then 600
+ when channel_name like '%v. 4%' then 500
+ when channel_name like '%v. 3%' then 400
+ when channel_name like '%v. 2%' then 300
+ when channel_name like '%v. 1%' then 200
+ else 0
+ end;
+
+ priority := priority +
+ case
+ when channel_name like 'Red Hat Enterprise Linux (v. 5%' then 60
+ when (channel_name like '%AS%' and channel_name not like '%Extras%') then 50
+ when (channel_name like '%ES%' and channel_name not like '%Extras%') then 40
+ when (channel_name like '%WS%' and channel_name not like '%Extras%') then 30
+ when (channel_name like '%Desktop%' and channel_name not like '%Extras%') then 20
+ when channel_name like '%Extras%' then 10
+ else 0
+ end;
+
+ priority := priority +
+ case
+ when channel_name like '%)' then 5
+ else 0
+ end;
+
+ priority := priority +
+ case
+ when channel_name like '%32-bit x86%' then 4
+ when channel_name like '%64-bit Intel Itanium%' then 3
+ when channel_name like '%64-bit AMD64/Intel EM64T%' then 2
+ else 0
+ end;
+ elsif channel_name like 'Red Hat Desktop%' then
+ priority := 900;
+
+ if channel_name not like '%Beta%' then
+ priority := priority + 50;
+ end if;
+
+ priority := priority +
+ case
+ when channel_name like '%v. 4%' then 40
+ when channel_name like '%v. 3%' then 30
+ when channel_name like '%v. 2%' then 20
+ when channel_name like '%v. 1%' then 10
+ else 0
+ end;
+
+ priority := priority +
+ case
+ when channel_name like '%32-bit x86%' then 4
+ when channel_name like '%64-bit Intel Itanium%' then 3
+ when channel_name like '%64-bit AMD64/Intel EM64T%' then 2
+ else 0
+ end;
+
+ elsif org_id_val is not null then
+ priority := 600;
+ else
+ priority := 500;
+ end if;
+
+ return -priority;
+
+ end channel_priority;
+
+ -- right now this only does the accounting changes; the cascade
+ -- actually does the rhnServerChannel delete.
+ procedure delete_server_channels(server_id_in in number)
+ is
+ begin
+ update rhnPrivateChannelFamily
+ set current_members = current_members -1
+ where org_id in (
+ select org_id
+ from rhnServer
+ where id = server_id_in
+ )
+ and channel_family_id in (
+ select rcfm.channel_family_id
+ from rhnChannelFamilyMembers rcfm,
+ rhnServerChannel rsc
+ where rsc.server_id = server_id_in
+ and rsc.channel_id = rcfm.channel_id
+ and not exists (
+ select 1
+ from
+ rhnChannelFamilyVirtSubLevel cfvsl,
+ rhnSGTypeVirtSubLevel sgtvsl,
+ rhnServerEntitlementView sev,
+ rhnVirtualInstance vi
+ where
+ -- system is a virtual instance
+ vi.virtual_system_id = server_id_in
+ and vi.host_system_id = sev.server_id
+ -- system's host has a virt ent
+ and sev.label in ('virtualization_host',
+ 'virtualization_host_platform')
+ and sev.server_group_type_id =
+ sgtvsl.server_group_type_id
+ -- the host's virt ent grants a cf virt sub level
+ and sgtvsl.virt_sub_level_id = cfvsl.virt_sub_level_id
+ -- the cf is in that virt sub level
+ and cfvsl.channel_family_id = rcfm.channel_family_id
+ )
+ );
+ end;
+
+ -- this could certainly be optimized to do updates if needs be
+ procedure refresh_newest_package(channel_id_in in number, caller_in in varchar2 := '(unknown)')
+ is
+ begin
+ delete from rhnChannelNewestPackage where channel_id = channel_id_in;
+ insert into rhnChannelNewestPackage
+ ( channel_id, name_id, evr_id, package_id, package_arch_id )
+ ( select channel_id,
+ name_id, evr_id,
+ package_id, package_arch_id
+ from rhnChannelNewestPackageView
+ where channel_id = channel_id_in
+ );
+ insert into rhnChannelNewestPackageAudit (channel_id, caller)
+ values (channel_id_in, caller_in);
+ update rhnChannel
+ set last_modified = greatest(sysdate, last_modified + 1/86400)
+ where id = channel_id_in;
+ end;
+
+ procedure update_channel ( channel_id_in in number, invalidate_ss in number := 0,
+ date_to_use in date := sysdate )
+ is
+
+ channel_last_modified date;
+ last_modified_value date;
+
+ cursor snapshots is
+ select snapshot_id id
+ from rhnSnapshotChannel
+ where channel_id = channel_id_in;
+
+ begin
+
+ select last_modified
+ into channel_last_modified
+ from rhnChannel
+ where id = channel_id_in;
+
+ last_modified_value := date_to_use;
+
+ if last_modified_value <= channel_last_modified then
+ last_modified_value := last_modified_value + 1/86400;
+ end if;
+
+ update rhnChannel set last_modified = last_modified_value
+ where id = channel_id_in;
+
+ if invalidate_ss = 1 then
+ for snapshot in snapshots loop
+ update rhnSnapshot
+ set invalid = lookup_snapshot_invalid_reason('channel_modified')
+ where id = snapshot.id;
+ end loop;
+ end if;
+
+ end update_channel;
+
+ procedure update_channels_by_package ( package_id_in in number, date_to_use in date := sysdate )
+ is
+
+ cursor channels is
+ select channel_id
+ from rhnChannelPackage
+ where package_id = package_id_in
+ order by channel_id;
+
+ begin
+ for channel in channels loop
+ -- we want to invalidate the snapshot assocated with the channel when we
+ -- do this b/c we know we've added or removed or packages
+ rhn_channel.update_channel ( channel.channel_id, 1, date_to_use );
+ end loop;
+ end update_channels_by_package;
+
+
+ procedure update_channels_by_errata ( errata_id_in number, date_to_use in date := sysdate )
+ is
+
+ cursor channels is
+ select channel_id
+ from rhnChannelErrata
+ where errata_id = errata_id_in
+ order by channel_id;
+
+ begin
+ for channel in channels loop
+ -- we won't invalidate snapshots, b/c just changing the errata associated with
+ -- a channel shouldn't invalidate snapshots
+ rhn_channel.update_channel ( channel.channel_id, 0, date_to_use );
+ end loop;
+ end update_channels_by_errata;
+
+END rhn_channel;
+/
+SHOW ERRORS
+
+--
+-- Revision 1.75 2005/03/04 00:04:19 jslagle
+-- bz #147617
+-- Made Red Hat Desktop sort a little better.
+--
+-- Revision 1.74 2005/02/22 03:24:47 jslagle
+-- bz #147617
+-- Improve channel_priority function to order channels better.
+--
+-- Revision 1.73 2004/08/16 20:39:30 pjones
+-- bugzilla: 129889 -- make bulk_server_basechange_from() actually work.
+--
+-- Revision 1.72 2004/04/14 00:09:24 pjones
+-- bugzilla: 120761 -- split rhnChannelPermissions into two tables, eliminating
+-- a frequent full table scan
+--
+-- Revision 1.71 2004/04/13 16:28:36 bretm
+-- bugzilla: 119871
+--
+-- keep track of rhnServer.channels_changed through the pl/sql fns
+--
+-- Revision 1.70 2004/03/26 18:11:32 rbb
+-- Bugzilla: 114057
+--
+-- Add a script to determine channel priority.
+--
+-- Revision 1.69 2004/02/17 20:16:52 pjones
+-- bugzilla: none -- add cvs tags into the package as long as we're touching
+-- it anyway
+--
+-- Revision 1.68 2004/02/17 20:05:38 pjones
+-- bugzilla: 115782 -- make bulk_server_basechange_from() filter out servers
+-- with arches incompatible with the target channel
+--
+-- Revision 1.67 2004/02/06 02:36:10 misa
+-- Changed normalize_server_arch to allow for solaris arches
+--
+-- Revision 1.66 2003/11/13 16:58:34 cturner
+-- make use of new rhn_user.check_role_implied call; pragmas broke, removed them for now since I have no idea how to fix them
+--
+-- Revision 1.65 2003/10/23 20:26:24 bretm
+-- bugzilla: none
+--
+-- note the channel label when we unsubscribe, too
+--
+-- Revision 1.64 2003/10/15 14:47:17 bretm
+-- bugzilla: none
+--
+-- add the channel label to the server history summary line when we log a channel change
+--
+-- Revision 1.63 2003/09/24 19:25:56 pjones
+-- this wasn't the right fix, put it back
+--
+-- Revision 1.62 2003/09/24 17:42:19 pjones
+-- bugzilla: none
+--
+-- limit our server base channel guess to channels with available permissions
+--
+-- Revision 1.61 2003/09/22 21:00:40 cturner
+-- add method for easy acl check
+--
+-- Revision 1.60 2003/09/17 22:14:11 misa
+-- bugzilla: 103639 Changes to allow me to move the base channel guess into plsql
+--
+-- Revision 1.59 2003/08/21 13:41:17 cturner
+-- bugzilla: 99187. properly test for satellite and proxy in bulk_guess_server_base; reorg code for better reuse
+--
+-- Revision 1.58 2003/07/24 16:46:22 cturner
+-- bugzilla: 100723, the perm check was returning duplicates, so now it just calls the function it should have called anyway
+--
+-- Revision 1.57 2003/07/24 16:44:16 misa
+-- bugzilla: none A function more usable on the rhnapp side
+--
+-- Revision 1.56 2003/07/23 22:36:51 cturner
+-- argh, max returns null even when now rows; use distinct. how revolting
+--
+-- Revision 1.55 2003/07/23 22:01:31 cturner
+-- oops, this one can return multiple rows; eliminate that in a lazy way
+--
+-- Revision 1.54 2003/07/23 21:59:19 cturner
+-- rework how rhnUserChannel works; move to plsql for speed and maintenance
+--
+-- Revision 1.53 2003/07/21 17:49:12 pjones
+-- bugzilla: none
+--
+-- add optional user for subscribe_server
+--
+-- Revision 1.52 2003/07/14 22:19:29 misa
+-- bugzilla: none Updating guess_base_channel to work more like the rhnapp server code
+--
+-- Revision 1.51 2003/06/26 22:09:04 pjones
+-- bugzilla: none
+--
+-- log subscribe and unsubscribe
+--
+-- Revision 1.50 2003/06/05 19:31:15 pjones
+-- bugzilla: 88278 -- make the cursor name smaller
+--
+-- Revision 1.49 2003/06/05 19:18:21 pjones
+-- bugzilla: 88278
+--
+-- unsubscribe_server() opens the package-level cursor when it invokes itself,
+-- so we're using a local copy instead.
+--
+-- Revision 1.48 2003/06/04 16:41:39 pjones
+-- bugzilla: none
+--
+-- make bulk_guess_server_base() silently ignore unguessables
+--
+-- Revision 1.47 2003/06/04 16:27:03 pjones
+-- bugzilla: 88822
+--
+-- eliminate the last outliers that remove things from channels without using
+-- unsubscribe_server, I think.
+--
+-- Revision 1.46 2003/06/03 20:49:37 pjones
+-- bugzilla: 88822
+-- unsubscribing from rhn-satellite now clears rhnSatelliteChannelFamily
+-- for the server in question
+--
+-- Revision 1.45 2003/06/02 20:41:45 pjones
+-- bugzilla: none - fix rhnProxyInfo/rhnSatelliteInfo channel unsubscribe
+-- problem. Basicly, if you're out of the channel for any reason, you're
+-- also out of rhnProxyInfo/rhnProxyInfo
+--
+-- Revision 1.44 2003/03/24 15:26:28 pjones
+-- bugzilla: 85812
+--
+-- bulk_server_base_change silently ignores servers that are satellites
+-- or proxies, as requested.
+--
+-- Revision 1.43 2003/02/26 20:28:17 pjones
+-- rhn_channel.update_family_counts() in rhn_channel.entitle_customer()
+-- the old codepath is:
+--
+-- ep ->
+-- rhn_ep.entitlement_run_me() ->
+-- rhn_ep.poll_customer() ->
+-- rhn_channel.entitle_customer()
+--
+-- which doesn't change current_members, even though it may remove servers
+-- from the family.
+--
+-- There's another bug here: currently, we don't try to order forced
+-- unsubscribes in any way; we just use
+-- rhn_channel.unsubscribe_server_from_family . If there are any child
+-- channel subscriptions, this will leave them subscribed. We really need
+-- to iterate across the channels again, and subscribe any channel for which
+-- there are no parent channel subscriptions.
+--
+-- Ugh.
+--
+-- Revision 1.42 2003/01/28 00:19:45 pjones
+-- fix clear_subscriptions; AFAICT, this is only hit on the
+-- bulk_server_base_change / bulk_server_base_guess codepaths, which puts
+-- it infrequent enough that it could be our "bad count" culprit.
+--
+-- Revision 1.41 2003/01/14 19:51:45 pjones
+-- make setting current_members on rhnChannelFamilyPermissions work when
+-- a server is in more than one channel in a single family.
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.7-to-spacewalk-schema-0.8/050-rhn_channel.pks.sql b/schema/spacewalk/upgrade/spacewalk-schema-0.7-to-spacewalk-schema-0.8/050-rhn_channel.pks.sql
new file mode 100644
index 0000000..972f3f4
--- /dev/null
+++ b/schema/spacewalk/upgrade/spacewalk-schema-0.7-to-spacewalk-schema-0.8/050-rhn_channel.pks.sql
@@ -0,0 +1,253 @@
+--
+-- Copyright (c) 2008 Red Hat, Inc.
+--
+-- This software is licensed to you under the GNU General Public License,
+-- version 2 (GPLv2). There is NO WARRANTY for this software, express or
+-- implied, including the implied warranties of MERCHANTABILITY or FITNESS
+-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+-- along with this software; if not, see
+-- http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+--
+-- Red Hat trademarks are not licensed under GPLv2. No permission is
+-- granted to use or replicate Red Hat trademarks that are incorporated
+-- in this software or its documentation.
+--
+--
+--
+--
+
+CREATE OR REPLACE
+PACKAGE rhn_channel
+IS
+ version varchar2(100) := '';
+
+ CURSOR server_base_subscriptions(server_id_in NUMBER) IS
+ SELECT C.id
+ FROM rhnChannel C, rhnServerChannel SC
+ WHERE C.id = SC.channel_id
+ AND SC.server_id = server_id_in
+ AND C.parent_channel IS NULL;
+
+ CURSOR check_server_subscription(server_id_in NUMBER, channel_id_in NUMBER) IS
+ SELECT channel_id
+ FROM rhnServerChannel
+ WHERE server_id = server_id_in
+ AND channel_id = channel_id_in;
+
+ CURSOR check_server_parent_membership(server_id_in NUMBER, channel_id_in NUMBER) IS
+ SELECT C.id
+ FROM rhnChannel C, rhnServerChannel SC
+ WHERE C.parent_channel = channel_id_in
+ AND C.id = SC.channel_id
+ AND SC.server_id = server_id_in;
+
+ CURSOR channel_family_perm_cursor(channel_family_id_in NUMBER, org_id_in NUMBER) IS
+ SELECT *
+ FROM rhnOrgChannelFamilyPermissions
+ WHERE channel_family_id = channel_family_id_in
+ AND org_id = org_id_in;
+
+ PROCEDURE license_consent(channel_id_in IN NUMBER, user_id_in IN NUMBER, server_id_in IN NUMBER);
+ FUNCTION get_license_path(channel_id_in IN NUMBER) RETURN VARCHAR2;
+
+ PROCEDURE unsubscribe_server(server_id_in IN NUMBER, channel_id_in NUMBER, immediate_in NUMBER := 1, unsubscribe_children_in number := 0,
+ deleting_server in number := 0,
+ update_family_countsYN IN NUMBER := 1);
+ PROCEDURE subscribe_server(server_id_in IN NUMBER, channel_id_in NUMBER, immediate_in NUMBER := 1, user_id_in number := null, recalcfamily_in number := 1);
+
+ function can_server_consume_virt_channl(
+ server_id_in IN NUMBER,
+ family_id_in in number)
+ return number;
+
+ FUNCTION guess_server_base(server_id_in IN NUMBER) RETURN NUMBER;
+
+ FUNCTION base_channel_for_release_arch(release_in in varchar2,
+ server_arch_in in varchar2, org_id_in in number := -1,
+ user_id_in in number := null) RETURN number;
+
+ FUNCTION base_channel_rel_archid(release_in in varchar2,
+ server_arch_id_in in number, org_id_in in number := -1,
+ user_id_in in number := null) RETURN number;
+
+ FUNCTION channel_priority(channel_id_in in number) RETURN number;
+
+ PROCEDURE bulk_subscribe_server(channel_id_in IN NUMBER, set_label_in IN VARCHAR2, set_uid_in IN NUMBER);
+ PROCEDURE bulk_unsubscribe_server(channel_id_in IN NUMBER, set_label_in IN VARCHAR2, set_uid_in IN NUMBER);
+
+ PROCEDURE bulk_server_base_change(channel_id_in IN NUMBER, set_label_in IN VARCHAR2, set_uid_in IN NUMBER);
+ procedure bulk_server_basechange_from(
+ set_label_in in varchar2,
+ set_uid_in in number,
+ old_channel_id_in in number,
+ new_channel_id_in in number);
+
+ procedure bulk_guess_server_base(
+ set_label_in in varchar2,
+ set_uid_in in number);
+
+ procedure bulk_guess_server_base_from(
+ set_label_in in varchar2,
+ set_uid_in in number,
+ channel_id_in in number);
+
+ PROCEDURE clear_subscriptions(server_id_in IN NUMBER, deleting_server in number := 0,
+ update_family_countsYN IN NUMBER := 1);
+
+ FUNCTION available_family_subscriptions(channel_family_id_in IN NUMBER, org_id_in IN NUMBER) RETURN NUMBER;
+
+ function channel_family_current_members(channel_family_id_in IN NUMBER,
+ org_id_in IN NUMBER)
+ return number;
+
+ PROCEDURE update_family_counts(channel_family_id_in IN NUMBER, org_id_in IN NUMBER);
+ PROCEDURE update_group_family_counts(group_label_in IN VARCHAR2, org_id_in IN NUMBER);
+ FUNCTION family_for_channel(channel_id_in IN NUMBER) RETURN NUMBER;
+
+ FUNCTION available_chan_subscriptions(channel_id_in IN NUMBER, org_id_in IN NUMBER) RETURN NUMBER;
+
+ procedure entitle_customer(customer_id_in in number, channel_family_id_in in number, quantity_in in number);
+ procedure set_family_maxmembers(customer_id_in in number, channel_family_id_in in number, quantity_in in number);
+ procedure unsubscribe_server_from_family(server_id_in in number, channel_family_id_in in number);
+
+ procedure delete_server_channels(server_id_in in number);
+ procedure refresh_newest_package(channel_id_in in number, caller_in in varchar2 := '(unknown)');
+
+ function get_org_id(channel_id_in in number) return number;
+ PRAGMA RESTRICT_REFERENCES(get_org_id, WNDS, RNPS, WNPS);
+
+ function get_org_access(channel_id_in in number, org_id_in in number) return number;
+ PRAGMA RESTRICT_REFERENCES(get_org_access, WNDS, RNPS, WNPS);
+
+ function get_cfam_org_access(cfam_id_in in number, org_id_in in number) return number;
+
+ function user_role_check_debug(channel_id_in in number, user_id_in in number, role_in in varchar2, reason_out out varchar2)
+ RETURN NUMBER;
+ PRAGMA RESTRICT_REFERENCES(user_role_check_debug, WNDS, RNPS, WNPS);
+
+ function user_role_check(channel_id_in in number, user_id_in in number, role_in in varchar2)
+ RETURN NUMBER;
+ PRAGMA RESTRICT_REFERENCES(user_role_check, WNDS, RNPS, WNPS);
+
+ function loose_user_role_check(channel_id_in in number, user_id_in in number, role_in in varchar2)
+ RETURN NUMBER;
+ PRAGMA RESTRICT_REFERENCES(loose_user_role_check, WNDS, RNPS, WNPS);
+
+ function direct_user_role_check(channel_id_in in number, user_id_in in number, role_in in varchar2)
+ RETURN NUMBER;
+ PRAGMA RESTRICT_REFERENCES(direct_user_role_check, WNDS, RNPS, WNPS);
+
+ function shared_user_role_check(channel_id in number, user_id in number, role in varchar2)
+ RETURN NUMBER;
+ PRAGMA RESTRICT_REFERENCES(shared_user_role_check, WNDS, RNPS, WNPS);
+
+ function org_channel_setting(channel_id_in in number, org_id_in in number, setting_in in varchar2)
+ RETURN NUMBER;
+
+ PROCEDURE update_channel ( channel_id_in in number, invalidate_ss in number := 0,
+ date_to_use in date := sysdate );
+
+ PROCEDURE update_channels_by_package ( package_id_in in number, date_to_use in date := sysdate );
+
+ PROCEDURE update_channels_by_errata ( errata_id_in number, date_to_use in date := sysdate );
+
+
+ PRAGMA RESTRICT_REFERENCES(org_channel_setting, WNDS, RNPS, WNPS);
+
+END rhn_channel;
+/
+SHOW ERRORS
+
+--
+-- Revision 1.37 2004/04/14 00:09:24 pjones
+-- bugzilla: 120761 -- split rhnChannelPermissions into two tables, eliminating
+-- a frequent full table scan
+--
+-- Revision 1.36 2004/03/26 18:11:32 rbb
+-- Bugzilla: 114057
+--
+-- Add a script to determine channel priority.
+--
+-- Revision 1.35 2004/02/17 20:16:52 pjones
+-- bugzilla: none -- add cvs tags into the package as long as we're touching
+-- it anyway
+--
+-- Revision 1.34 2003/11/13 18:13:09 cturner
+-- pragmas can now return now that rhn_user pragmas are fixed
+--
+-- Revision 1.32 2003/09/22 21:00:40 cturner
+-- add method for easy acl check
+--
+-- Revision 1.31 2003/09/17 22:14:11 misa
+-- bugzilla: 103639 Changes to allow me to move the base channel guess into plsql
+--
+-- Revision 1.30 2003/07/24 16:44:16 misa
+-- bugzilla: none A function more usable on the rhnapp side
+--
+-- Revision 1.29 2003/07/24 14:00:17 misa
+-- bugzilla: none PRAGMA RESTRICT_REFERENCES good
+--
+-- Revision 1.28 2003/07/23 21:59:19 cturner
+-- rework how rhnUserChannel works; move to plsql for speed and maintenance
+--
+-- Revision 1.27 2003/07/21 17:49:12 pjones
+-- bugzilla: none
+--
+-- add optional user for subscribe_server
+--
+-- Revision 1.26 2002/12/19 18:13:42 misa
+-- Added caller with a default value
+--
+-- Revision 1.25 2002/12/11 22:18:46 pjones
+-- rhnChannelNewestPackage
+--
+-- Revision 1.24 2002/11/21 22:08:11 pjones
+-- make unsubscribe_channels have a "unsubscribe_children_in number := 0"
+-- argument so that you can tell it to unsubscribe children.
+--
+-- Also, make it raise an exception instead of silent failure in the
+-- other case.
+--
+-- Revision 1.23 2002/11/18 17:20:50 pjones
+-- this should have gone back too
+--
+-- Revision 1.22 2002/11/13 23:16:18 pjones
+-- lookup_*_arch()
+--
+-- Revision 1.21 2002/10/07 20:01:59 rnorwood
+-- guess base channel for ssm and single system
+--
+-- Revision 1.20 2002/10/02 19:21:03 bretm
+-- o 3rd party channel schema changes, no more clobs...
+--
+-- Revision 1.19 2002/09/20 19:21:58 bretm
+-- o more 3rd party channel stuff...
+--
+-- Revision 1.18 2002/06/12 22:33:03 pjones
+-- procedure bulk_guess_server_base_from(
+-- set_label_in in varchar2,
+-- set_uid_in in number,
+-- channel_id_in in number);
+--
+-- for bretm
+--
+-- Revision 1.17 2002/06/12 22:12:25 pjones
+-- procedure bulk_guess_server_base(
+-- set_label_in in varchar2,
+-- set_uid_in in number);
+--
+-- for bretm
+--
+-- Revision 1.16 2002/06/12 19:37:55 pjones
+-- bulk_server_basechange_from(
+-- set_label_in in varchar2,
+-- set_uid_in in number,
+-- old_channel_id_in in number,
+-- new_channel_id_in in number
+-- );
+--
+-- for bretm
+--
+-- Revision 1.15 2002/05/10 22:08:22 pjones
+-- id/log
+--
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.7-to-spacewalk-schema-0.8/051-rhn_entitlements.pkb.sql b/schema/spacewalk/upgrade/spacewalk-schema-0.7-to-spacewalk-schema-0.8/051-rhn_entitlements.pkb.sql
new file mode 100644
index 0000000..555da10
--- /dev/null
+++ b/schema/spacewalk/upgrade/spacewalk-schema-0.7-to-spacewalk-schema-0.8/051-rhn_entitlements.pkb.sql
@@ -0,0 +1,1728 @@
+--
+-- Copyright (c) 2008 Red Hat, Inc.
+--
+-- This software is licensed to you under the GNU General Public License,
+-- version 2 (GPLv2). There is NO WARRANTY for this software, express or
+-- implied, including the implied warranties of MERCHANTABILITY or FITNESS
+-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+-- along with this software; if not, see
+-- http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+--
+-- Red Hat trademarks are not licensed under GPLv2. No permission is
+-- granted to use or replicate Red Hat trademarks that are incorporated
+-- in this software or its documentation.
+--
+--
+--
+--
+
+create or replace
+package body rhn_entitlements
+is
+ body_version varchar2(100) := '';
+
+
+ -- *******************************************************************
+ -- PROCEDURE: remove_org_entitlements
+ --
+ -- Removes both system entitlements and channel subscriptions
+ -- that are currently assigned to an org and re-assigns to the
+ -- master org (org_id = 1).
+ --
+ -- When we call this we expect everything to already be unentitled
+ -- which shoul be handled by delete_org.
+ --
+ -- Called by: delete_org
+ -- *******************************************************************
+ procedure remove_org_entitlements(
+ org_id_in in number
+ )
+ is
+
+ cursor system_ents is
+ select sg.id, sg.max_members, sg.group_type
+ from rhnServerGroup sg
+ where group_type is not null
+ and org_id = org_id_in;
+
+ cursor channel_subs is
+ select pcf.channel_family_id, pcf.max_members
+ from rhnChannelFamily cf,
+ rhnPrivateChannelFamily pcf
+ where pcf.org_id = org_id_in
+ and pcf.channel_family_id = cf.id
+ and cf.org_id is null;
+
+ begin
+
+ for system_ent in system_ents loop
+ update rhnServerGroup
+ set max_members = max_members + system_ent.max_members
+ where org_id = 1
+ and group_type = system_ent.group_type;
+ end loop;
+
+ update rhnServerGroup
+ set max_members = 0
+ where org_id = org_id_in;
+
+ for channel_sub in channel_subs loop
+ update rhnPrivateChannelFamily
+ set max_members = max_members + channel_sub.max_members
+ where org_id = 1
+ and channel_family_id = channel_sub.channel_family_id;
+ end loop;
+
+ update rhnPrivateChannelFamily
+ set max_members = 0
+ where org_id = org_id_in;
+
+ end remove_org_entitlements;
+
+ function entitlement_grants_service (
+ entitlement_in in varchar2,
+ service_level_in in varchar2
+ ) return number is
+ begin
+ if service_level_in = 'provisioning' then
+ if entitlement_in = 'provisioning_entitled' then
+ return 1;
+ else
+ return 0;
+ end if;
+ elsif service_level_in = 'management' then
+ if entitlement_in = 'enterprise_entitled' then
+ return 1;
+ else
+ return 0;
+ end if;
+ elsif service_level_in = 'monitoring' then
+ if entitlement_in = 'monitoring_entitled' then
+ return 1;
+ end if;
+ elsif service_level_in = 'updates' then
+ return 1;
+ else
+ return 0;
+ end if;
+ end entitlement_grants_service;
+
+ function lookup_entitlement_group (
+ org_id_in in number,
+ type_label_in in varchar2 := 'sw_mgr_entitled'
+ ) return number is
+ cursor server_groups is
+ select sg.id server_group_id
+ from rhnServerGroup sg,
+ rhnServerGroupType sgt
+ where sgt.label = type_label_in
+ and sgt.id = sg.group_type
+ and sg.org_id = org_id_in;
+ begin
+ for sg in server_groups loop
+ return sg.server_group_id;
+ end loop;
+ return rhn_entitlements.create_entitlement_group(
+ org_id_in,
+ type_label_in
+ );
+ end lookup_entitlement_group;
+
+ function create_entitlement_group (
+ org_id_in in number,
+ type_label_in in varchar2 := 'sw_mgr_entitled'
+ ) return number is
+ sg_id_val number;
+ begin
+ select rhn_server_group_id_seq.nextval
+ into sg_id_val
+ from dual;
+
+ insert into rhnServerGroup (
+ id, name, description, max_members, current_members,
+ group_type, org_id
+ ) (
+ select sg_id_val, sgt.label, sgt.label,
+ 0, 0, sgt.id, org_id_in
+ from rhnServerGroupType sgt
+ where sgt.label = type_label_in
+ );
+
+ return sg_id_val;
+ end create_entitlement_group;
+
+ function can_entitle_server (
+ server_id_in in number,
+ type_label_in in varchar2 )
+ return number is
+ cursor addon_servergroups (base_label_in in varchar2,
+ addon_label_in in varchar2) is
+ select
+ addon_id
+ from
+ rhnSGTypeBaseAddonCompat
+ where base_id = lookup_sg_type (base_label_in)
+ and addon_id = lookup_sg_type (addon_label_in);
+
+ previous_ent rhn_entitlements.ents_array;
+ is_base_in char := 'N';
+ is_base_current char := 'N';
+ i number := 0;
+ sgid number := 0;
+
+ begin
+
+ previous_ent := rhn_entitlements.ents_array();
+ previous_ent := rhn_entitlements.get_server_entitlement(server_id_in);
+
+ select distinct is_base
+ into is_base_in
+ from rhnServerGroupType
+ where label = type_label_in;
+
+ if previous_ent.count = 0 then
+ if (is_base_in = 'Y' and rhn_entitlements.find_compatible_sg (server_id_in, type_label_in, sgid)) then
+ -- rhn_server.insert_into_servergroup (server_id_in, sgid);
+ return 1;
+ else
+ -- rhn_exception.raise_exception ('invalid_base_entitlement');
+ return 0;
+ end if;
+
+ -- there are previous ents, first make sure we're not trying to entitle a base ent
+ elsif is_base_in = 'Y' then
+ -- rhn_exception.raise_exception ('invalid_addon_entitlement');
+ return 0;
+
+ -- it must be an addon, so proceed with the entitlement
+ else
+
+ -- find the servers base ent
+ is_base_current := 'N';
+ i := 0;
+ while is_base_current = 'N' and i <= previous_ent.count
+ loop
+ i := i + 1;
+ select is_base
+ into is_base_current
+ from rhnServerGroupType
+ where label = previous_ent(i);
+ end loop;
+
+ -- never found a base ent, that would be strange
+ if is_base_current = 'N' then
+ -- rhn_exception.raise_exception ('invalid_base_entitlement');
+ return 0;
+ end if;
+
+ -- this for loop verifies the validity of the addon path
+ for addon_servergroup in addon_servergroups (previous_ent(i), type_label_in) loop
+ -- find an appropriate sgid for the addon and entitle the server
+ if rhn_entitlements.find_compatible_sg (server_id_in, type_label_in, sgid) then
+ -- rhn_server.insert_into_servergroup (server_id_in, sgid);
+ return 1;
+ else
+ -- rhn_exception.raise_exception ('invalid_addon_entitlement');
+ return 0;
+ end if;
+ end loop;
+
+ end if;
+
+ return 0;
+
+ end can_entitle_server;
+
+ function can_switch_base (
+ server_id_in in integer,
+ type_label_in in varchar2
+ ) return number is
+
+ type_label_in_is_base char(1);
+ sgid number;
+
+ begin
+
+ begin
+ select is_base into type_label_in_is_base
+ from rhnServerGroupType
+ where label = type_label_in;
+ exception
+ when no_data_found then
+ rhn_exception.raise_exception ( 'invalid_entitlement' );
+ end;
+
+ if type_label_in_is_base = 'N' then
+ rhn_exception.raise_exception ( 'invalid_entitlement' );
+ elsif rhn_entitlements.find_compatible_sg ( server_id_in,
+ type_label_in, sgid ) then
+ return 1;
+ else
+ return 0;
+ end if;
+
+ end can_switch_base;
+
+
+ function find_compatible_sg (
+ server_id_in in number,
+ type_label_in in varchar2,
+ sgid_out out number
+ ) return boolean is
+
+ cursor servergroups is
+ select sg.id id
+ from rhnServerGroupType sgt,
+ rhnServerGroup sg,
+ rhnServer s,
+ rhnServerServerGroupArchCompat ssgac
+ where s.id = server_id_in
+ and s.org_id = sg.org_id
+ and sgt.label = type_label_in
+ and sg.group_type = sgt.id
+ and ssgac.server_group_type = sgt.id
+ and ssgac.server_arch_id = s.server_arch_id
+ and not exists (
+ select 1
+ from rhnServerGroupMembers sgm
+ where sgm.server_group_id = sg.id
+ and sgm.server_id = s.id);
+
+
+ begin
+ for servergroup in servergroups loop
+ sgid_out := servergroup.id;
+ return true;
+ end loop;
+
+ --no servergroup found
+ sgid_out := 0;
+ return false;
+ end find_compatible_sg;
+
+ procedure entitle_server (
+ server_id_in in number,
+ type_label_in in varchar2 := 'sw_mgr_entitled'
+ ) is
+ sgid number := 0;
+ is_virt number := 0;
+
+ begin
+
+ begin
+ select 1 into is_virt
+ from rhnServerEntitlementView
+ where server_id = server_id_in
+ and label in ('virtualization_host', 'virtualization_host_platform');
+ exception
+ when no_data_found then
+ is_virt := 0;
+ end;
+
+ if is_virt = 0 and (type_label_in = 'virtualization_host' or
+ type_label_in = 'virtualization_host_platform') then
+
+ is_virt := 1;
+ end if;
+
+
+
+ if rhn_entitlements.can_entitle_server(server_id_in,
+ type_label_in) = 1 then
+ if rhn_entitlements.find_compatible_sg (server_id_in,
+ type_label_in, sgid) then
+ insert into rhnServerHistory ( id, server_id, summary, details )
+ values ( rhn_event_id_seq.nextval, server_id_in,
+ 'added system entitlement ',
+ case type_label_in
+ when 'enterprise_entitled' then 'Management'
+ when 'sw_mgr_entitled' then 'Update'
+ when 'provisioning_entitled' then 'Provisioning'
+ when 'monitoring_entitled' then 'Monitoring'
+ when 'virtualization_host' then 'Virtualization'
+ when 'virtualization_host_platform' then
+ 'Virtualization Platform' end );
+
+ rhn_server.insert_into_servergroup (server_id_in, sgid);
+
+ if is_virt = 1 then
+ rhn_entitlements.repoll_virt_guest_entitlements(server_id_in);
+ end if;
+
+ else
+ rhn_exception.raise_exception ('no_available_server_group');
+ end if;
+ else
+ rhn_exception.raise_exception ('invalid_entitlement');
+ end if;
+ end entitle_server;
+
+ procedure remove_server_entitlement (
+ server_id_in in number,
+ type_label_in in varchar2 := 'sw_mgr_entitled',
+ repoll_virt_guests in number := 1
+ ) is
+ group_id number;
+ type_is_base char;
+ is_virt number := 0;
+ begin
+ begin
+
+
+ -- would be nice if there were a virt attribute of entitlement types, not have to specify 2 different ones...
+ begin
+ select 1 into is_virt
+ from rhnServerEntitlementView
+ where server_id = server_id_in
+ and label in ('virtualization_host', 'virtualization_host_platform');
+ exception
+ when no_data_found then
+ is_virt := 0;
+ end;
+
+ select sg.id, sgt.is_base
+ into group_id, type_is_base
+ from rhnServerGroupType sgt,
+ rhnServerGroup sg,
+ rhnServerGroupMembers sgm,
+ rhnServer s
+ where s.id = server_id_in
+ and s.id = sgm.server_id
+ and sgm.server_group_id = sg.id
+ and sg.org_id = s.org_id
+ and sgt.label = type_label_in
+ and sgt.id = sg.group_type;
+
+ if ( type_is_base = 'Y' ) then
+ -- unentitle_server should handle everything, don't really need to do anything else special here
+ unentitle_server ( server_id_in );
+ else
+
+ insert into rhnServerHistory ( id, server_id, summary, details )
+ values ( rhn_event_id_seq.nextval, server_id_in,
+ 'removed system entitlement ',
+ case type_label_in
+ when 'enterprise_entitled' then 'Management'
+ when 'sw_mgr_entitled' then 'Update'
+ when 'provisioning_entitled' then 'Provisioning'
+ when 'monitoring_entitled' then 'Monitoring'
+ when 'virtualization_host' then 'Virtualization'
+ when 'virtualization_host_platform' then
+ 'Virtualization Platforrm' end );
+
+ rhn_server.delete_from_servergroup(server_id_in, group_id);
+
+ -- special case: clean up related monitornig data
+ if type_label_in = 'monitoring_entitled' then
+ DELETE
+ FROM state_change
+ WHERE o_id IN (SELECT probe_id
+ FROM rhn_check_probe
+ WHERE host_id = server_id_in);
+ DELETE /*+index(time_series time_series_probe_id_idx)*/
+ FROM time_series
+ WHERE SUBSTR(o_id, INSTR(o_id, '-') + 1,
+ (INSTR(o_id, '-', INSTR(o_id, '-') + 1) - INSTR(o_id, '-')) - 1)
+ IN (SELECT to_char(probe_id)
+ FROM rhn_check_probe
+ WHERE host_id = server_id_in);
+ DELETE
+ FROM rhn_probe
+ WHERE recid IN (SELECT probe_id
+ FROM rhn_check_probe
+ WHERE host_id = server_id_in);
+ end if;
+
+ if is_virt = 1 and repoll_virt_guests = 1 then
+ rhn_entitlements.repoll_virt_guest_entitlements(server_id_in);
+ end if;
+ end if;
+
+ exception
+ when no_data_found then
+ rhn_exception.raise_exception('invalid_server_group_member');
+ end;
+
+ end remove_server_entitlement;
+
+
+ procedure unentitle_server (server_id_in in number) is
+
+ cursor servergroups is
+ select distinct sgt.label, sg.id server_group_id
+ from rhnServerGroupType sgt,
+ rhnServerGroup sg,
+ rhnServer s,
+ rhnServerGroupMembers sgm
+ where s.id = server_id_in
+ and s.org_id = sg.org_id
+ and sg.group_type = sgt.id
+ and sgm.server_group_id = sg.id
+ and sgm.server_id = s.id;
+
+ is_virt number := 0;
+
+ begin
+
+ begin
+ select 1 into is_virt
+ from rhnServerEntitlementView
+ where server_id = server_id_in
+ and label in ('virtualization_host', 'virtualization_host_platform');
+ exception
+ when no_data_found then
+ is_virt := 0;
+ end;
+
+ for servergroup in servergroups loop
+
+ insert into rhnServerHistory ( id, server_id, summary, details )
+ values ( rhn_event_id_seq.nextval, server_id_in,
+ 'removed system entitlement ',
+ case servergroup.label
+ when 'enterprise_entitled' then 'Management'
+ when 'sw_mgr_entitled' then 'Update'
+ when 'provisioning_entitled' then 'Provisioning'
+ when 'monitoring_entitled' then 'Monitoring'
+ when 'virtualization_host' then 'Virtualization'
+ when 'virtualization_host_platform' then
+ 'Virtualization Platform' end );
+
+ rhn_server.delete_from_servergroup(server_id_in,
+ servergroup.server_group_id );
+ end loop;
+
+ if is_virt = 1 then
+ rhn_entitlements.repoll_virt_guest_entitlements(server_id_in);
+ end if;
+
+ end unentitle_server;
+
+
+ -- *******************************************************************
+ -- PROCEDURE: repoll_virt_guest_entitlements
+ --
+ -- Whenever we add/remove a virtualization_host* entitlement from
+ -- a host, we can call this procedure to update what type of slots
+ -- the guests are consuming.
+ --
+ -- If you're removing the entitlement, it's
+ -- possible the guests will become unentitled if you don't have enough
+ -- physical slots to cover them.
+ --
+ -- If you're adding the entitlement, you end up freeing up physical
+ -- slots for other systems.
+ --
+ -- *******************************************************************
+ procedure repoll_virt_guest_entitlements(server_id_in in number)
+ is
+
+ -- All channel families associated with the guests of server_id_in
+ cursor families is
+ select distinct cfs.channel_family_id
+ from
+ rhnChannelFamilyServers cfs,
+ rhnVirtualInstance vi
+ where
+ vi.host_system_id = server_id_in
+ and vi.virtual_system_id = cfs.server_id;
+
+ -- All of server group types associated with the guests of
+ -- server_id_in
+ cursor group_types is
+ select distinct sg.group_type, sgt.label
+ from
+ rhnServerGroupType sgt,
+ rhnServerGroup sg,
+ rhnServerGroupMembers sgm,
+ rhnVirtualInstance vi
+ where
+ vi.host_system_id = server_id_in
+ and vi.virtual_system_id = sgm.server_id
+ and sgm.server_group_id = sg.id
+ and sg.group_type = sgt.id;
+
+ -- Virtual servers from a certain family belonging to a speicifc
+ -- host that are consuming physical channel slots over the limit.
+ cursor virt_servers_cfam(family_id_in in number, quantity_in in number) is
+ select virtual_system_id
+ from (
+ select rownum, vi.virtual_system_id
+ from
+ rhnChannelFamilyMembers cfm,
+ rhnServerChannel sc,
+ rhnVirtualInstance vi
+ where
+ vi.host_system_id = server_id_in
+ and vi.virtual_system_id = sc.server_id
+ and sc.channel_id = cfm.channel_id
+ and cfm.channel_family_id = family_id_in
+ order by sc.modified desc
+ )
+ where rownum <= quantity_in;
+
+ -- Virtual servers from a certain family belonging to a speicifc
+ -- host that are consuming physical system slots over the limit.
+ cursor virt_servers_sgt(group_type_in in number, quantity_in in number) is
+ select virtual_system_id
+ from (
+ select rownum, vi.virtual_system_id
+ from
+ rhnServerGroup sg,
+ rhnServerGroupMembers sgm,
+ rhnVirtualInstance vi
+ where
+ vi.host_system_id = server_id_in
+ and vi.virtual_system_id = sgm.server_id
+ and sgm.server_group_id = sg.id
+ and sg.group_type = group_type_in
+ order by sgm.modified desc
+ )
+ where rownum <= quantity_in;
+
+ org_id_val number;
+ max_members_val number;
+ current_members_calc number;
+ sg_id number;
+
+ begin
+
+ select org_id
+ into org_id_val
+ from rhnServer
+ where id = server_id_in;
+
+ -- deal w/ channel entitlements first ...
+ for family in families loop
+ -- get the current (physical) members of the family
+ current_members_calc :=
+ rhn_channel.channel_family_current_members(family.channel_family_id,
+ org_id_val); -- fixed transposed args
+
+ -- get the max members of the family
+ select max_members
+ into max_members_val
+ from rhnPrivateChannelFamily
+ where channel_family_id = family.channel_family_id
+ and org_id = org_id_val;
+
+ if current_members_calc > max_members_val then
+ -- A virtualization_host* ent must have been removed, so we'll
+ -- unsubscribe guests from the host first.
+
+ -- hm, i don't think max_members - current_members_calc yielding a negative number
+ -- will work w/ rownum, swaping 'em in the body of this if...
+ for virt_server in virt_servers_cfam(family.channel_family_id,
+ current_members_calc - max_members_val) loop
+
+ rhn_channel.unsubscribe_server_from_family(
+ virt_server.virtual_system_id,
+ family.channel_family_id);
+ end loop;
+
+ -- if we're still over the limit, which would be odd,
+ -- just prune the group to max_members
+ --
+ -- er... wouldn't we actually have to refresh the values of
+ -- current_members_calc and max_members_val to actually ever
+ -- *skip this??
+ if current_members_calc > max_members_val then
+ -- argh, transposed again?!
+ set_family_count(org_id_val,
+ family.channel_family_id,
+ max_members_val);
+ end if;
+
+ end if;
+
+ -- update current_members for the family. This will set the value
+ -- to reflect adding/removing the entitlement.
+ --
+ -- what's the difference of doing this vs the unavoidable set_family_count above?
+ rhn_channel.update_family_counts(family.channel_family_id,
+ org_id_val);
+ end loop;
+
+ for a_group_type in group_types loop
+ -- get the current *physical* members of the system entitlement type for the org...
+ --
+ -- unlike channel families, it appears the standard rhnServerGroup.max_members represents
+ -- *physical* slots, vs physical+virt ... boy that's confusing...
+
+ select max_members, id
+ into max_members_val, sg_id
+ from rhnServerGroup
+ where group_type = a_group_type.group_type
+ and org_id = org_id_val;
+
+
+ select count(sep.server_id) into current_members_calc
+ from rhnServerEntitlementPhysical sep
+ where sep.server_group_id = sg_id
+ and sep.server_group_type_id = a_group_type.group_type;
+
+ if current_members_calc > max_members_val then
+ -- A virtualization_host* ent must have been removed, and we're over the limit, so unsubscribe guests
+ for virt_server in virt_servers_sgt(a_group_type.group_type,
+ current_members_calc - max_members_val) loop
+ rhn_entitlements.remove_server_entitlement(virt_server.virtual_system_id, a_group_type.label);
+
+ -- decrement current_members_calc, we'll use it to reset current_members for the group at the end...
+ current_members_calc := current_members_calc - 1;
+ end loop;
+
+ end if;
+
+ update rhnServerGroup set current_members = current_members_calc
+ where org_id = org_id_val
+ and group_type = a_group_type.group_type;
+
+ -- I think that's all the house-keeping we have to do...
+ end loop;
+
+ end repoll_virt_guest_entitlements;
+
+
+ function get_server_entitlement (
+ server_id_in in number
+ ) return ents_array is
+
+ cursor server_groups is
+ select sgt.label
+ from rhnServerGroupType sgt,
+ rhnServerGroup sg,
+ rhnServerGroupMembers sgm
+ where 1=1
+ and sgm.server_id = server_id_in
+ and sg.id = sgm.server_group_id
+ and sgt.id = sg.group_type
+ and sgt.label in (
+ 'sw_mgr_entitled','enterprise_entitled',
+ 'provisioning_entitled', 'nonlinux_entitled',
+ 'monitoring_entitled', 'virtualization_host',
+ 'virtualization_host_platform'
+ );
+
+ ent_array ents_array;
+
+ begin
+
+ ent_array := ents_array();
+
+ for sg in server_groups loop
+ ent_array.extend;
+ ent_array(ent_array.count) := sg.label;
+ end loop;
+
+ return ent_array;
+
+ end get_server_entitlement;
+
+
+ -- this desperately needs to be table driven.
+ procedure modify_org_service (
+ org_id_in in number,
+ service_label_in in varchar2,
+ enable_in in char
+ ) is
+ type roles_v is varray(10) of rhnUserGroupType.label%TYPE;
+ roles_to_process roles_v;
+ cursor roles(role_label_in in varchar2) is
+ select label, id
+ from rhnUserGroupType
+ where label = role_label_in;
+ cursor org_roles(role_label_in in varchar2) is
+ select 1
+ from rhnUserGroup ug,
+ rhnUserGroupType ugt
+ where ugt.label = role_label_in
+ and ug.org_id = org_id_in
+ and ugt.id = ug.group_type;
+
+ type ents_v is varray(10) of rhnOrgEntitlementType.label%TYPE;
+ ents_to_process ents_v;
+ cursor ents(ent_label_in in varchar2) is
+ select label, id
+ from rhnOrgEntitlementType
+ where label = ent_label_in;
+ cursor org_ents(ent_label_in in varchar2) is
+ select 1
+ from rhnOrgEntitlements oe,
+ rhnOrgEntitlementType oet
+ where oet.label = ent_label_in
+ and oe.org_id = org_id_in
+ and oet.id = oe.entitlement_id;
+ create_row char(1);
+ begin
+ ents_to_process := ents_v();
+ roles_to_process := roles_v();
+ -- a bit kludgy, but only for 3.4 really. Certainly no
+ -- worse than the old code...
+ if service_label_in = 'enterprise' or
+ service_label_in = 'management' then
+ ents_to_process.extend;
+ ents_to_process(ents_to_process.count) := 'sw_mgr_enterprise';
+
+ roles_to_process.extend;
+ roles_to_process(roles_to_process.count) := 'org_admin';
+
+ roles_to_process.extend;
+ roles_to_process(roles_to_process.count) := 'system_group_admin';
+
+ roles_to_process.extend;
+ roles_to_process(roles_to_process.count) := 'activation_key_admin';
+
+ roles_to_process.extend;
+ roles_to_process(roles_to_process.count) := 'org_applicant';
+ elsif service_label_in = 'provisioning' then
+ ents_to_process.extend;
+ ents_to_process(ents_to_process.count) := 'rhn_provisioning';
+
+ roles_to_process.extend;
+ roles_to_process(roles_to_process.count) := 'system_group_admin';
+
+ roles_to_process.extend;
+ roles_to_process(roles_to_process.count) := 'activation_key_admin';
+
+ roles_to_process.extend;
+ roles_to_process(roles_to_process.count) := 'config_admin';
+ -- another nasty special case...
+ if enable_in = 'Y' then
+ ents_to_process.extend;
+ ents_to_process(ents_to_process.count) := 'sw_mgr_enterprise';
+ end if;
+ elsif service_label_in = 'monitoring' then
+ ents_to_process.extend;
+ ents_to_process(ents_to_process.count) := 'rhn_monitor';
+
+ roles_to_process.extend;
+ roles_to_process(roles_to_process.count) := 'monitoring_admin';
+ elsif service_label_in = 'virtualization' then
+ ents_to_process.extend;
+ ents_to_process(ents_to_process.count) := 'rhn_virtualization';
+
+ roles_to_process.extend;
+ roles_to_process(roles_to_process.count) := 'config_admin';
+ elsif service_label_in = 'virtualization_platform' then
+ ents_to_process.extend;
+ ents_to_process(ents_to_process.count) := 'rhn_virtualization_platform';
+ roles_to_process.extend;
+ roles_to_process(roles_to_process.count) := 'config_admin';
+ elsif service_label_in = 'nonlinux' then
+ ents_to_process.extend;
+ ents_to_process(ents_to_process.count) := 'rhn_nonlinux';
+ roles_to_process.extend;
+ roles_to_process(roles_to_process.count) := 'config_admin';
+ end if;
+
+ if enable_in = 'Y' then
+ for i in 1..ents_to_process.count loop
+ for ent in ents(ents_to_process(i)) loop
+ create_row := 'Y';
+ for oe in org_ents(ent.label) loop
+ create_row := 'N';
+ end loop;
+ if create_row = 'Y' then
+ insert into rhnOrgEntitlements(org_id, entitlement_id)
+ values (org_id_in, ent.id);
+ end if;
+ end loop;
+ end loop;
+ for i in 1..roles_to_process.count loop
+ for role in roles(roles_to_process(i)) loop
+ create_row := 'Y';
+ for o_r in org_roles(role.label) loop
+ create_row := 'N';
+ end loop;
+ if create_row = 'Y' then
+ insert into rhnUserGroup(
+ id, name, description, current_members,
+ group_type, org_id
+ ) (
+ select rhn_user_group_id_seq.nextval,
+ ugt.name || 's',
+ ugt.name || 's for Org ' ||
+ o.name || ' ('|| o.id ||')',
+ 0, ugt.id, o.id
+ from rhnUserGroupType ugt,
+ web_customer o
+ where o.id = org_id_in
+ and ugt.id = role.id
+ );
+ end if;
+ end loop;
+ end loop;
+ else
+ for i in 1..ents_to_process.count loop
+ for ent in ents(ents_to_process(i)) loop
+ delete from rhnOrgEntitlements
+ where org_id = org_id_in
+ and entitlement_id = ent.id;
+ end loop;
+ end loop;
+ end if;
+ end modify_org_service;
+
+ procedure set_customer_enterprise (
+ customer_id_in in number
+ ) is
+ begin
+ modify_org_service(customer_id_in, 'enterprise', 'Y');
+ end set_customer_enterprise;
+
+ procedure set_customer_provisioning (
+ customer_id_in in number
+ ) is
+ begin
+ modify_org_service(customer_id_in, 'provisioning', 'Y');
+ end set_customer_provisioning;
+
+ procedure set_customer_monitoring (
+ customer_id_in in number
+ ) is
+ begin
+ modify_org_service(customer_id_in, 'monitoring', 'Y');
+ end set_customer_monitoring;
+
+ procedure set_customer_nonlinux (
+ customer_id_in in number
+ ) is
+ begin
+ modify_org_service(customer_id_in, 'nonlinux', 'Y');
+ end set_customer_nonlinux;
+
+ procedure unset_customer_enterprise (
+ customer_id_in in number
+ ) is
+ begin
+ modify_org_service(customer_id_in, 'enterprise', 'N');
+ end unset_customer_enterprise;
+
+ procedure unset_customer_provisioning (
+ customer_id_in in number
+ ) is
+ begin
+ modify_org_service(customer_id_in, 'provisioning', 'N');
+ end unset_customer_provisioning;
+
+ procedure unset_customer_monitoring (
+ customer_id_in in number
+ ) is
+ begin
+ modify_org_service(customer_id_in, 'monitoring', 'N');
+ end unset_customer_monitoring;
+
+ procedure unset_customer_nonlinux (
+ customer_id_in in number
+ ) is
+ begin
+ modify_org_service(customer_id_in, 'nonlinux', 'N');
+ end unset_customer_nonlinux;
+
+ -- *******************************************************************
+ -- PROCEDURE: prune_group
+ -- Unsubscribes servers consuming physical slots that over the org's
+ -- limit.
+ -- Called by: set_group_count, prune_everything, repoll_virt_guest_entitlements
+ -- *******************************************************************
+ procedure prune_group (
+ group_id_in in number,
+ type_in in char,
+ quantity_in in number,
+ update_family_countsYN in number := 1
+ ) is
+ cursor usergroups is
+ select user_id, user_group_id, ugt.label
+ from rhnUserGroupType ugt,
+ rhnUserGroup ug,
+ rhnUserGroupMembers ugm
+ where 1=1
+ and ugm.user_group_id = group_id_in
+ and ugm.user_id in (
+ select user_id
+ from (
+ select rownum row_number,
+ user_id,
+ time
+ from (
+ select user_id,
+ modified time
+ from rhnUserGroupMembers
+ where user_group_id = group_id_in
+ order by time asc
+ )
+ )
+ where row_number > quantity_in
+ )
+ and ugm.user_group_id = ug.id
+ and ug.group_type = ugt.id;
+ cursor servergroups is
+ select server_id, server_group_id, sgt.id group_type_id, sgt.label
+ from rhnServerGroupType sgt,
+ rhnServerGroup sg,
+ rhnServerGroupMembers sgm
+ where 1=1
+ and sgm.server_group_id = group_id_in
+ and sgm.server_id in (
+ select server_id
+ from (
+ select rownum row_number,
+ server_id,
+ time
+ from (
+ select sep.server_id,
+ sep.modified time
+ from
+ rhnServerEntitlementPhysical sep
+ where
+ sep.server_group_id = group_id_in
+ order by time asc
+ )
+ )
+ where row_number > quantity_in
+ )
+ and sgm.server_group_id = sg.id
+ and sg.group_type = sgt.id;
+ type_is_base char;
+ begin
+ if type_in = 'U' then
+ update rhnUserGroup
+ set max_members = quantity_in
+ where id = group_id_in;
+
+ for ug in usergroups loop
+ rhn_user.remove_from_usergroup(ug.user_id, ug.user_group_id);
+ end loop;
+ elsif type_in = 'S' then
+ update rhnServerGroup
+ set max_members = quantity_in
+ where id = group_id_in;
+
+ for sg in servergroups loop
+ remove_server_entitlement(sg.server_id, sg.label);
+
+ select is_base
+ into type_is_base
+ from rhnServerGroupType sgt
+ where sgt.id = sg.group_type_id;
+
+ -- if we're removing a base ent, then be sure to
+ -- remove the server's channel subscriptions.
+ if ( type_is_base = 'Y' ) then
+ rhn_channel.clear_subscriptions(sg.server_id,
+ update_family_countsYN => update_family_countsYN);
+ end if;
+
+ end loop;
+ end if;
+ end prune_group;
+
+ -- *******************************************************************
+ -- PROCEDURE: assign_system_entitlement
+ --
+ -- Moves system entitlements from from_org_id_in to to_org_id_in.
+ -- Can raise not_enough_entitlements_in_base_org if from_org_id_in
+ -- does not have enough entitlements to cover the move.
+ -- Takes care of unentitling systems if necessary by calling
+ -- set_group_count
+ -- *******************************************************************
+ procedure assign_system_entitlement(
+ group_label_in in varchar2,
+ from_org_id_in in number,
+ to_org_id_in in number,
+ quantity_in in number
+ )
+ is
+ prev_ent_count number;
+ to_org_prev_ent_count number;
+ new_ent_count number;
+ new_quantity number;
+ group_type number;
+ begin
+
+ begin
+ select max_members
+ into prev_ent_count
+ from rhnServerGroupType sgt,
+ rhnServerGroup sg
+ where sg.org_id = from_org_id_in
+ and sg.group_type = sgt.id
+ and sgt.label = group_label_in;
+ exception
+ when NO_DATA_FOUND then
+ rhn_exception.raise_exception(
+ 'not_enough_entitlements_in_base_org');
+ end;
+
+ begin
+ select max_members
+ into to_org_prev_ent_count
+ from rhnServerGroupType sgt,
+ rhnServerGroup sg
+ where sg.org_id = to_org_id_in
+ and sg.group_type = sgt.id
+ and sgt.label = group_label_in;
+ exception
+ when NO_DATA_FOUND then
+ to_org_prev_ent_count := 0;
+ end;
+
+ begin
+ select id
+ into group_type
+ from rhnServerGroupType
+ where label = group_label_in;
+ exception
+ when NO_DATA_FOUND then
+ rhn_exception.raise_exception(
+ 'invalid_server_group');
+ end;
+
+ new_ent_count := prev_ent_count - quantity_in;
+
+ if prev_ent_count > new_ent_count then
+ new_quantity := to_org_prev_ent_count + quantity_in;
+ end if;
+
+ if new_ent_count < 0 then
+ rhn_exception.raise_exception(
+ 'not_enough_entitlements_in_base_org');
+ end if;
+
+
+ rhn_entitlements.set_group_count(from_org_id_in,
+ 'S',
+ group_type,
+ new_ent_count);
+
+ rhn_entitlements.set_group_count(to_org_id_in,
+ 'S',
+ group_type,
+ new_quantity);
+
+ -- Create or delete the entries in rhnOrgEntitlementType
+ if group_label_in = 'enterprise_entitled' then
+ if new_quantity > 0 then
+ set_customer_enterprise(to_org_id_in);
+ else
+ unset_customer_enterprise(to_org_id_in);
+ end if;
+ end if;
+
+ if group_label_in = 'provisioning_entitled' then
+ if new_quantity > 0 then
+ set_customer_provisioning(to_org_id_in);
+ else
+ unset_customer_provisioning(to_org_id_in);
+ end if;
+ end if;
+
+ if group_label_in = 'monitoring_entitled' then
+ if new_quantity > 0 then
+ set_customer_monitoring(to_org_id_in);
+ else
+ unset_customer_monitoring(to_org_id_in);
+ end if;
+ end if;
+
+ end assign_system_entitlement;
+
+ -- *******************************************************************
+ -- PROCEDURE: assign_channel_entitlement
+ --
+ -- Moves channel entitlements from from_org_id_in to to_org_id_in.
+ -- Can raise not_enough_entitlements_in_base_org if from_org_id_in
+ -- does not have enough entitlements to cover the move.
+ -- Takes care of unentitling systems if necessary by calling
+ -- set_family_count
+ -- *******************************************************************
+ procedure assign_channel_entitlement(
+ channel_family_label_in in varchar2,
+ from_org_id_in in number,
+ to_org_id_in in number,
+ quantity_in in number
+ )
+ is
+ prev_ent_count number;
+ new_ent_count number;
+ to_org_prev_ent_count number;
+ new_quantity number;
+ cfam_id number;
+ begin
+
+ begin
+ select max_members
+ into prev_ent_count
+ from rhnChannelFamily cf,
+ rhnPrivateChannelFamily pcf
+ where pcf.org_id = from_org_id_in
+ and pcf.channel_family_id = cf.id
+ and cf.label = channel_family_label_in;
+ exception
+ when NO_DATA_FOUND then
+ rhn_exception.raise_exception(
+ 'not_enough_entitlements_in_base_org');
+ end;
+
+ begin
+ select max_members
+ into to_org_prev_ent_count
+ from rhnChannelFamily cf,
+ rhnPrivateChannelFamily pcf
+ where pcf.org_id = to_org_id_in
+ and pcf.channel_family_id = cf.id
+ and cf.label = channel_family_label_in;
+ exception
+ when NO_DATA_FOUND then
+ to_org_prev_ent_count := 0;
+ end;
+
+
+ begin
+ select id
+ into cfam_id
+ from rhnChannelFamily
+ where label = channel_family_label_in;
+ exception
+ when NO_DATA_FOUND then
+ rhn_exception.raise_exception(
+ 'invalid_channel_family');
+ end;
+
+ new_ent_count := prev_ent_count - quantity_in;
+
+ if prev_ent_count > new_ent_count then
+ new_quantity := to_org_prev_ent_count + quantity_in;
+ end if;
+
+
+ if new_ent_count < 0 then
+ rhn_exception.raise_exception(
+ 'not_enough_entitlements_in_base_org');
+ end if;
+
+ rhn_entitlements.set_family_count(from_org_id_in,
+ cfam_id,
+ new_ent_count);
+
+ rhn_entitlements.set_family_count(to_org_id_in,
+ cfam_id,
+ new_quantity);
+
+ end assign_channel_entitlement;
+
+ -- *******************************************************************
+ -- PROCEDURE: activate_system_entitlement
+ --
+ -- Sets the values in rhnServerGroup for a given rhnServerGroupType.
+ --
+ -- Calls: set_group_count to update, prune, or create the group.
+ -- Called by: the code that activates a satellite cert.
+ --
+ -- Raises not_enough_entitlements_in_base_org if all entitlements
+ -- in the org are used so the free entitlements would not cover
+ -- the difference when descreasing the number of entitlements.
+ -- *******************************************************************
+ procedure activate_system_entitlement(
+ org_id_in in number,
+ group_label_in in varchar2,
+ quantity_in in number
+ )
+ is
+ prev_ent_count number;
+ prev_ent_count_sum number;
+ group_type number;
+ begin
+
+ -- Fetch the current entitlement count for the org
+ -- into prev_ent_count
+ begin
+ select current_members
+ into prev_ent_count
+ from rhnServerGroupType sgt,
+ rhnServerGroup sg
+ where sg.group_type = sgt.id
+ and sgt.label = group_label_in
+ and sg.org_id = org_id_in;
+ exception
+ when NO_DATA_FOUND then
+ prev_ent_count := 0;
+ end;
+
+ begin
+ select id
+ into group_type
+ from rhnServerGroupType
+ where label = group_label_in;
+ exception
+ when NO_DATA_FOUND then
+ rhn_exception.raise_exception(
+ 'invalid_server_group');
+ end;
+
+ -- If we're setting the total entitlemnt count to a lower value,
+ -- and that value is less than the allocated count in this org,
+ -- we need to raise an exception.
+ if quantity_in < prev_ent_count then
+ rhn_exception.raise_exception(
+ 'not_enough_entitlements_in_base_org');
+ else
+ -- don't update family counts after every server
+ -- will do bulk update afterwards
+ rhn_entitlements.set_group_count(org_id_in,
+ 'S',
+ group_type,
+ quantity_in,
+ update_family_countsYN => 0);
+ -- bulk update family counts
+ rhn_channel.update_group_family_counts(group_label_in, org_id_in);
+ end if;
+
+
+ end activate_system_entitlement;
+
+ -- *******************************************************************
+ -- PROCEDURE: activate_channel_entitlement
+ --
+ -- Calls: set_family_count to update, prune, or create the family
+ -- permission bucket.
+ -- Called by: the code that activates a satellite cert.
+ --
+ -- Raises not_enough_entitlements_in_base_org if there are not enough
+ -- entitlements in the org to cover the difference when you are
+ -- descreasing the number of entitlements.
+ --
+ -- The backend code in Python is expected to do whatever arithmetics
+ -- is needed.
+ -- *******************************************************************
+ procedure activate_channel_entitlement(
+ org_id_in in number,
+ channel_family_label_in in varchar2,
+ quantity_in in number
+ )
+ is
+ prev_ent_count number;
+ prev_ent_count_sum number;
+ cfam_id number;
+ begin
+
+ -- Fetch the current entitlement count for the org
+ -- into prev_ent_count
+ begin
+ select current_members
+ into prev_ent_count
+ from rhnChannelFamily cf,
+ rhnPrivateChannelFamily pcf
+ where pcf.org_id = org_id_in
+ and pcf.channel_family_id = cf.id
+ and cf.label = channel_family_label_in;
+ exception
+ when NO_DATA_FOUND then
+ prev_ent_count := 0;
+ end;
+
+ begin
+ select id
+ into cfam_id
+ from rhnChannelFamily
+ where label = channel_family_label_in;
+ exception
+ when NO_DATA_FOUND then
+ rhn_exception.raise_exception(
+ 'invalid_channel_family');
+ end;
+
+ -- If we're setting the total entitlemnt count to a lower value,
+ -- and that value is less than the count in that one org,
+ -- we need to raise an exception.
+ if quantity_in < prev_ent_count then
+ rhn_exception.raise_exception(
+ 'not_enough_entitlements_in_base_org');
+ else
+ rhn_entitlements.set_family_count(org_id_in,
+ cfam_id,
+ quantity_in);
+ end if;
+
+ end activate_channel_entitlement;
+
+
+ procedure set_group_count (
+ customer_id_in in number,
+ type_in in char,
+ group_type_in in number,
+ quantity_in in number,
+ update_family_countsYN in number := 1
+ ) is
+ group_id number;
+ quantity number;
+ begin
+ quantity := quantity_in;
+ if quantity is not null and quantity < 0 then
+ quantity := 0;
+ end if;
+
+ if type_in = 'U' then
+ select rug.id
+ into group_id
+ from rhnUserGroup rug
+ where 1=1
+ and rug.org_id = customer_id_in
+ and rug.group_type = group_type_in;
+ elsif type_in = 'S' then
+ select rsg.id
+ into group_id
+ from rhnServerGroup rsg
+ where 1=1
+ and rsg.org_id = customer_id_in
+ and rsg.group_type = group_type_in;
+ end if;
+
+ rhn_entitlements.prune_group(
+ group_id,
+ type_in,
+ quantity,
+ update_family_countsYN
+ );
+ exception
+ when no_data_found then
+ if type_in = 'U' then
+ insert into rhnUserGroup (
+ id, name, description, max_members, current_members,
+ group_type, org_id, created, modified
+ ) (
+ select rhn_user_group_id_seq.nextval, name, name,
+ quantity, 0, id, customer_id_in,
+ sysdate, sysdate
+ from rhnUserGroupType
+ where id = group_type_in
+ );
+ elsif type_in = 'S' then
+ insert into rhnServerGroup (
+ id, name, description, max_members, current_members,
+ group_type, org_id, created, modified
+ ) (
+ select rhn_server_group_id_seq.nextval, name, name,
+ quantity, 0, id, customer_id_in,
+ sysdate, sysdate
+ from rhnServerGroupType
+ where id = group_type_in
+ );
+ end if;
+ end set_group_count;
+
+ -- *******************************************************************
+ -- PROCEDURE: prune_family
+ -- Unsubscribes servers consuming physical slots from the channel family
+ -- that are over the org's limit.
+ -- Called by: set_family_count, prune_everything
+ -- *******************************************************************
+ procedure prune_family (
+ customer_id_in in number,
+ channel_family_id_in in number,
+ quantity_in in number
+ ) is
+ cursor serverchannels is
+ select sc.server_id,
+ sc.channel_id
+ from rhnServerChannel sc,
+ rhnChannelFamilyMembers cfm
+ where 1=1
+ and cfm.channel_family_id = channel_family_id_in
+ and cfm.channel_id = sc.channel_id
+ and server_id in (
+ select server_id
+ from (
+ select server_id,
+ time,
+ rownum row_number
+ from (
+ select rs.id server_id,
+ rcfm.modified time
+ from
+ rhnServerChannel rsc,
+ rhnChannelFamilyMembers rcfm,
+ rhnServer rs
+ where 1=1
+ and rs.org_id = customer_id_in
+ and rs.id = rsc.server_id
+ and rsc.channel_id = rcfm.channel_id
+ and rcfm.channel_family_id =
+ channel_family_id_in
+ -- we only want to grab servers consuming
+ -- physical slots.
+ and exists (
+ select 1
+ from rhnChannelFamilyServerPhysical cfsp
+ where cfsp.server_id = rs.id
+ and cfsp.channel_family_id =
+ channel_family_id_in
+ )
+ order by time asc
+ )
+ )
+ where row_number > quantity_in
+ );
+ begin
+ -- if we get a null customer_id, this is completely bogus.
+ if customer_id_in is null then
+ return;
+ end if;
+
+ update rhnPrivateChannelFamily
+ set max_members = quantity_in
+ where 1=1
+ and org_id = customer_id_in
+ and channel_family_id = channel_family_id_in;
+
+ for sc in serverchannels loop
+ rhn_channel.unsubscribe_server(sc.server_id, sc.channel_id, 1, 1);
+ end loop;
+ end prune_family;
+
+ procedure set_family_count (
+ customer_id_in in number,
+ channel_family_id_in in number,
+ quantity_in in number
+ ) is
+ cursor privperms is
+ select 1
+ from rhnPrivateChannelFamily
+ where org_id = customer_id_in
+ and channel_family_id = channel_family_id_in;
+ cursor pubperms is
+ select o.id org_id
+ from web_customer o,
+ rhnPublicChannelFamily pcf
+ where pcf.channel_family_id = channel_family_id_in;
+ quantity number;
+ done number := 0;
+ begin
+ quantity := quantity_in;
+ if quantity is not null and quantity < 0 then
+ quantity := 0;
+ end if;
+
+ if customer_id_in is not null then
+ for perm in privperms loop
+ rhn_entitlements.prune_family(
+ customer_id_in,
+ channel_family_id_in,
+ quantity
+ );
+ update rhnPrivateChannelFamily
+ set max_members = quantity
+ where org_id = customer_id_in
+ and channel_family_id = channel_family_id_in;
+ return;
+ end loop;
+
+ insert into rhnPrivateChannelFamily (
+ channel_family_id, org_id, max_members, current_members
+ ) values (
+ channel_family_id_in, customer_id_in, quantity, 0
+ );
+ return;
+ end if;
+
+ for perm in pubperms loop
+ if quantity = 0 then
+ rhn_entitlements.prune_family(
+ perm.org_id,
+ channel_family_id_in,
+ quantity
+ );
+ if done = 0 then
+ delete from rhnPublicChannelFamily
+ where channel_family_id = channel_family_id_in;
+ end if;
+ end if;
+ done := 1;
+ end loop;
+ -- if done's not 1, then we don't have any entitlements
+ if done != 1 then
+ insert into rhnPublicChannelFamily (
+ channel_family_id
+ ) values (
+ channel_family_id_in
+ );
+ end if;
+ end set_family_count;
+
+ -- this expects quantity_in to be the number of available slots, not the
+ -- max_members of the server group. If you give it too many, it'll fail
+ -- and raise servergroup_max_members.
+ -- We should NEVER run this unless we're SURE that we won't
+ -- be violating the max.
+ procedure entitle_last_modified_servers (
+ customer_id_in in number,
+ type_label_in in varchar2,
+ quantity_in in number
+ ) is
+ -- find the servers that aren't currently in slots
+ cursor servers(cid_in in number, quant_in in number) is
+ select server_id
+ from (
+ select rownum row_number,
+ server_id
+ from (
+ select rs.id server_iD
+ from rhnServer rs
+ where 1=1
+ and rs.org_id = cid_in
+ and not exists (
+ select 1
+ from rhnServerGroup sg,
+ rhnServerGroupMembers rsgm
+ where rsgm.server_id = rs.id
+ and rsgm.server_group_id = sg.id
+ and sg.group_type is not null
+ )
+ and not exists (
+ select 1
+ from rhnVirtualInstance vi
+ where vi.virtual_system_id =
+ rs.id
+ ) order by modified desc
+ )
+ )
+ where row_number <= quant_in;
+ begin
+ for server in servers(customer_id_in, quantity_in) loop
+ rhn_entitlements.entitle_server(server.server_id, type_label_in);
+ end loop;
+ end entitle_last_modified_servers;
+
+ procedure prune_everything (
+ customer_id_in in number
+ ) is
+ cursor everything is
+ -- all our server groups
+ select sg.id id,
+ 'S' type,
+ sg.max_members quantity
+ from rhnServerGroup sg
+ where sg.org_id = customer_id_in
+ union
+ -- all our user groups
+ select ug.id id,
+ 'U' type,
+ ug.max_members quantity
+ from rhnUserGroup ug
+ where ug.org_id = customer_id_in
+ union (
+ -- all the channel families we have perms to
+ select cfp.channel_family_id id,
+ 'C' type,
+ cfp.max_members quantity
+ from rhnOrgChannelFamilyPermissions cfp
+ where cfp.org_id = customer_id_in
+ union
+ -- plus all the ones we're using that we have no perms for
+ select cfm.channel_family_id id,
+ 'C' type,
+ 0 quantity
+ from rhnChannelFamily cf,
+ rhnChannelFamilyMembers cfm,
+ rhnServerChannel sc,
+ rhnServer s
+ where s.org_id = customer_id_in
+ and s.id = sc.server_id
+ and sc.channel_id = cfm.channel_id
+ and cfm.channel_family_id = cf.id
+ and cf.org_id is not null
+ and cf.org_id != customer_id_in
+ and not exists (
+ select 1
+ from rhnOrgChannelFamilyPermissions cfp
+ where cfp.org_id = customer_id_in
+ and cfp.channel_family_id = cfm.channel_family_id
+ )
+ );
+ begin
+ for one in everything loop
+ if one.type in ('U','S') then
+ prune_group(one.id, one.type, one.quantity);
+ else
+ prune_family(customer_id_in, one.id, one.quantity);
+ end if;
+ end loop;
+ end prune_everything;
+
+ procedure subscribe_newest_servers (
+ customer_id_in in number
+ ) is
+ -- find servers without base channels
+ cursor servers(cid_in in number) is
+ select s.id
+ from rhnServer s
+ where 1=1
+ and s.org_id = cid_in
+ and not exists (
+ select 1
+ from rhnChannel c,
+ rhnServerChannel sc
+ where sc.server_id = s.id
+ and sc.channel_id = c.id
+ and c.parent_channel is null
+ )
+ and not exists (
+ select 1
+ from rhnVirtualInstance vi
+ where vi.virtual_system_id = s.id
+ )
+ order by s.modified desc;
+ channel_id number;
+ begin
+ for server in servers(customer_id_in) loop
+ channel_id := rhn_channel.guess_server_base(server.id);
+ if channel_id is not null then
+ begin
+ rhn_channel.subscribe_server(server.id, channel_id);
+ commit;
+ -- exception is really channel_family_no_subscriptions
+ exception
+ when others then
+ null;
+ end;
+ end if;
+ end loop;
+ end subscribe_newest_servers;
+end rhn_entitlements;
+/
+show errors
+
+--
+--
+-- Revision 1.56 2004/07/21 21:27:36 nhansen
+-- bug 128196: use rhn_monitor instead of rhn_monitoring as the rhnOrgEntitlementType
+--
+-- Revision 1.55 2004/07/20 15:38:57 pjones
+-- bugzilla: 128196 -- make entitling "monitoring" work.
+--
+-- Revision 1.54 2004/07/14 19:13:13 pjones
+-- bugzilla: 126461 -- entitlement changes for new user roles
+--
+-- Revision 1.53 2004/07/02 19:18:20 pjones
+-- bugzilla: 125937 -- use rhn_user to remove user roles
+--
+-- Revision 1.52 2004/05/26 19:45:48 pjones
+-- bugzilla: 123639
+-- 1) reformat "entitlement_grants_service"
+-- 2) make the .pks and .pkb be in the same order.
+-- 3) add "modify_org_service" (to be used instead of set_customer_SERVICELEVEL)
+-- 4) add monitoring specific data.
+--
+-- Revision 1.51 2004/04/19 18:18:51 pjones
+-- bugzilla: none -- misa's using set_family_count() to set null org entitlements
+--
+-- Revision 1.50 2004/04/14 00:09:24 pjones
+-- bugzilla: 120761 -- split rhnChannelPermissions into two tables, eliminating
+-- a frequent full table scan
+--
+-- Revision 1.49 2004/03/26 16:53:42 pjones
+-- bugzilla: none -- make rhn_nonlinux give config_admin too on sat.
+--
+-- Revision 1.48 2004/03/25 22:29:56 pjones
+-- bugzilla: none -- only create config_admin in set_customer_prov if we're
+-- on a satellite
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.7-to-spacewalk-schema-0.8/051-rhn_entitlements.pks.sql b/schema/spacewalk/upgrade/spacewalk-schema-0.7-to-spacewalk-schema-0.8/051-rhn_entitlements.pks.sql
new file mode 100644
index 0000000..8860c36
--- /dev/null
+++ b/schema/spacewalk/upgrade/spacewalk-schema-0.7-to-spacewalk-schema-0.8/051-rhn_entitlements.pks.sql
@@ -0,0 +1,226 @@
+--
+-- Copyright (c) 2008 Red Hat, Inc.
+--
+-- This software is licensed to you under the GNU General Public License,
+-- version 2 (GPLv2). There is NO WARRANTY for this software, express or
+-- implied, including the implied warranties of MERCHANTABILITY or FITNESS
+-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+-- along with this software; if not, see
+-- http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+--
+-- Red Hat trademarks are not licensed under GPLv2. No permission is
+-- granted to use or replicate Red Hat trademarks that are incorporated
+-- in this software or its documentation.
+--
+--
+--
+--
+
+create or replace
+package rhn_entitlements
+is
+ body_version varchar2(100) := '';
+
+ type ents_array is varray(10) of rhnServerGroupType.label%TYPE;
+
+ procedure remove_org_entitlements (
+ org_id_in number
+ );
+
+ function entitlement_grants_service (
+ entitlement_in in varchar2,
+ service_level_in in varchar2
+ ) return number;
+
+ function lookup_entitlement_group (
+ org_id_in in number,
+ type_label_in in varchar2 := 'sw_mgr_entitled'
+ ) return number;
+
+ function create_entitlement_group (
+ org_id_in in number,
+ type_label_in in varchar2 := 'sw_mgr_entitled'
+ ) return number;
+
+ function can_entitle_server (
+ server_id_in in number,
+ type_label_in in varchar2
+ )
+ return number;
+
+ function can_switch_base (
+ server_id_in in integer,
+ type_label_in in varchar2
+ )
+ return number;
+
+ function find_compatible_sg (
+ server_id_in in number,
+ type_label_in in varchar2,
+ sgid_out out number
+ )
+ return boolean;
+
+ procedure entitle_server (
+ server_id_in in number,
+ type_label_in in varchar2 := 'sw_mgr_entitled'
+ );
+
+ procedure remove_server_entitlement (
+ server_id_in in number,
+ type_label_in in varchar2 := 'sw_mgr_entitled',
+ repoll_virt_guests in number := 1
+ );
+
+ procedure unentitle_server (
+ server_id_in in number
+ );
+
+ procedure repoll_virt_guest_entitlements(
+ server_id_in in number
+ );
+
+ function get_server_entitlement (
+ server_id_in in number
+ ) return ents_array;
+
+ procedure modify_org_service (
+ org_id_in in number,
+ service_label_in in varchar2,
+ enable_in in char
+ );
+
+ procedure set_customer_enterprise (
+ customer_id_in in number
+ );
+
+ procedure set_customer_provisioning (
+ customer_id_in in number
+ );
+
+ procedure set_customer_nonlinux (
+ customer_id_in in number
+ );
+
+ procedure unset_customer_enterprise (
+ customer_id_in in number
+ );
+
+ procedure unset_customer_provisioning (
+ customer_id_in in number
+ );
+
+ procedure unset_customer_nonlinux (
+ customer_id_in in number
+ );
+
+ procedure assign_system_entitlement(
+ group_label_in in varchar2,
+ from_org_id_in in number,
+ to_org_id_in in number,
+ quantity_in in number
+ );
+
+ procedure assign_channel_entitlement(
+ channel_family_label_in in varchar2,
+ from_org_id_in in number,
+ to_org_id_in in number,
+ quantity_in in number
+ );
+
+ procedure activate_system_entitlement(
+ org_id_in in number,
+ group_label_in in varchar2,
+ quantity_in in number
+ );
+
+ procedure activate_channel_entitlement(
+ org_id_in in number,
+ channel_family_label_in in varchar2,
+ quantity_in in number
+ );
+
+ procedure set_group_count (
+ customer_id_in in number, -- customer_id
+ type_in in char, -- 'U' or 'S'
+ group_type_in in number, -- rhn[User|Server]GroupType.id
+ quantity_in in number, -- quantity
+ update_family_countsYN in number := 1 -- call update_family_counts inside
+ );
+
+ procedure set_family_count (
+ customer_id_in in number, -- customer_id
+ channel_family_id_in in number, -- 246
+ quantity_in in number -- 3
+ );
+
+ -- this makes NO checks that the quantity is within max,
+ -- so we should NEVER run this unless we KNOW that we won't be
+ -- violating the max
+ procedure entitle_last_modified_servers (
+ customer_id_in in number, -- customer_id
+ type_label_in in varchar2, -- 'enterprise_entitled'
+ quantity_in in number -- 3
+ );
+
+ procedure prune_everything (
+ customer_id_in in number
+ );
+
+ procedure subscribe_newest_servers (
+ customer_id_in in number
+ );
+end rhn_entitlements;
+/
+show errors
+
+--
+-- Revision 1.19 2004/05/26 19:45:48 pjones
+-- bugzilla: 123639
+-- 1) reformat "entitlement_grants_service"
+-- 2) make the .pks and .pkb be in the same order.
+-- 3) add "modify_org_service" (to be used instead of set_customer_SERVICELEVEL)
+-- 4) add monitoring specific data.
+--
+-- Revision 1.18 2004/02/19 20:17:49 pjones
+-- bugzilla: 115896 -- add sgt and oet data for nonlinux, add
+-- [un]set_customer_nonlinux
+--
+-- Revision 1.17 2004/01/13 23:37:08 pjones
+-- bugzilla: none -- mate provisioning and management slots.
+--
+-- Revision 1.16 2003/09/23 22:14:41 bretm
+-- bugzilla: 103655
+--
+-- need something in the db that knows provisioning boxes are management boxes too, etc.
+--
+-- Revision 1.15 2003/09/19 22:35:07 pjones
+-- bugzilla: none
+--
+-- provisioning and config management entitlement support
+--
+-- Revision 1.14 2003/09/02 22:22:54 pjones
+-- bugzilla: none
+--
+-- attempt to autoentitle upon entitlement changes
+--
+-- Revision 1.13 2003/06/05 21:43:40 pjones
+-- bugzilla: none
+--
+-- add rhn_entitlements.prune_everything(customer_id_in in number);
+--
+-- Revision 1.12 2003/05/22 16:01:14 pjones
+-- reformat
+-- remove update_[server|user]group_counts (unused)
+--
+-- Revision 1.11 2002/06/03 16:07:29 pjones
+-- make prune_group and prune_family update respective max_members
+-- correctly.
+--
+-- Revision 1.10 2002/05/29 19:10:31 pjones
+-- code to entitle the last N modified servers to a particular service
+-- level
+--
+-- Revision 1.9 2002/05/10 22:08:23 pjones
+-- id/log
+--
14 years, 2 months
Changes to 'refs/tags/spacewalk-monitoring-selinux-0.8.2-1'
by Jan Pazdziora
Tag 'spacewalk-monitoring-selinux-0.8.2-1' created by Jan Pazdziora <jpazdziora(a)redhat.com> at 2010-02-01 10:14 +0000
Tagging package [spacewalk-monitoring-selinux] version [0.8.2-1] in directory [selinux/spacewalk-monitoring-selinux/].
Changes since spacewalk-backend-0.8.40-1:
Jan Pazdziora (2):
558448 - define context for /etc/nocpulse/SatCluster.ini.
Automatic commit of package [spacewalk-monitoring-selinux] release [0.8.2-1].
---
rel-eng/packages/spacewalk-monitoring-selinux | 2 +-
selinux/spacewalk-monitoring-selinux/spacewalk-monitoring-selinux.spec | 5 ++++-
selinux/spacewalk-monitoring-selinux/spacewalk-monitoring.fc | 1 +
3 files changed, 6 insertions(+), 2 deletions(-)
---
14 years, 2 months
rel-eng/packages selinux/spacewalk-monitoring-selinux
by Jan Pazdziora
rel-eng/packages/spacewalk-monitoring-selinux | 2 +-
selinux/spacewalk-monitoring-selinux/spacewalk-monitoring-selinux.spec | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)
New commits:
commit 75ab65fe10f08c7e2c36e68be31b93554cc1b16a
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Mon Feb 1 11:14:40 2010 +0100
Automatic commit of package [spacewalk-monitoring-selinux] release [0.8.2-1].
diff --git a/rel-eng/packages/spacewalk-monitoring-selinux b/rel-eng/packages/spacewalk-monitoring-selinux
index 5986761..a3ff7b7 100644
--- a/rel-eng/packages/spacewalk-monitoring-selinux
+++ b/rel-eng/packages/spacewalk-monitoring-selinux
@@ -1 +1 @@
-0.8.1-1 selinux/spacewalk-monitoring-selinux/
+0.8.2-1 selinux/spacewalk-monitoring-selinux/
diff --git a/selinux/spacewalk-monitoring-selinux/spacewalk-monitoring-selinux.spec b/selinux/spacewalk-monitoring-selinux/spacewalk-monitoring-selinux.spec
index 958d32e..619cb87 100644
--- a/selinux/spacewalk-monitoring-selinux/spacewalk-monitoring-selinux.spec
+++ b/selinux/spacewalk-monitoring-selinux/spacewalk-monitoring-selinux.spec
@@ -7,7 +7,7 @@
%define modulename spacewalk-monitoring
Name: spacewalk-monitoring-selinux
-Version: 0.8.1
+Version: 0.8.2
Release: 1%{?dist}
Summary: SELinux policy module supporting Spacewalk monitoring
@@ -144,6 +144,9 @@ fi
%attr(0755,root,root) %{_sbindir}/%{name}-enable
%changelog
+* Mon Feb 01 2010 Jan Pazdziora 0.8.2-1
+- 558448 - define context for /etc/nocpulse/SatCluster.ini
+
* Fri Jan 15 2010 Michael Mraka <michael.mraka(a)redhat.com> 0.8.1-1
- rebuild for spacewalk 0.8
14 years, 2 months