3 commits - backend/rhn-conf backend/satellite_tools
by Michael Mraka
backend/rhn-conf/rhn_server_iss.conf | 3
backend/rhn-conf/rhn_server_satellite.conf | 2
backend/satellite_tools/disk_dumper/dumper.py | 760 +++++++++++++-------------
backend/satellite_tools/exporter/exportLib.py | 51 +
4 files changed, 417 insertions(+), 399 deletions(-)
New commits:
commit 1ba0e6b27e4ff82956a228f4b45e1ea603a8ff57
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Tue Jan 5 15:04:43 2010 +0100
added channel checksum type to export
diff --git a/backend/satellite_tools/disk_dumper/dumper.py b/backend/satellite_tools/disk_dumper/dumper.py
index 7d078e9..754f768 100644
--- a/backend/satellite_tools/disk_dumper/dumper.py
+++ b/backend/satellite_tools/disk_dumper/dumper.py
@@ -1044,12 +1044,15 @@ class ChannelsDumper(CachedDumper, exportLib.ChannelsDumper):
select c.id, c.org_id,
c.label, ca.label channel_arch, c.basedir, c.name,
c.summary, c.description, c.gpg_key_url,
+ ct.label checksum_type,
TO_CHAR(c.last_modified, 'YYYYMMDDHH24MISS') last_modified,
pc.label parent_channel
- from rhnChannel c, rhnChannelArch ca, rhnChannel pc
+ from rhnChannel c, rhnChannelArch ca, rhnChannel pc,
+ rhnChecksumType ct
where c.id = :channel_id
and c.channel_arch_id = ca.id
and c.parent_channel = pc.id (+)
+ and c.checksum_type_id = ct.id (+)
""")
def __init__(self, writer, channels):
h = rhnSQL.prepare(self._query_list_channels)
@@ -1112,6 +1115,7 @@ class _ChannelsDumper(exportLib._ChannelDumper):
('rhn-channel-summary', 'summary'),
('rhn-channel-description', 'description'),
('rhn-channel-gpg-key-url', 'gpg_key_url'),
+ ('rhn-channel-checksum-type', 'checksum_type'),
]
for k, v in mappings:
arr.append(exportLib.SimpleDumper(self._writer, k, self._row[v]))
@@ -1259,12 +1263,15 @@ class ChannelsDumperEx(CachedDumper, exportLib.ChannelsDumper):
cp.product channel_product,
cp.version channel_product_version,
cp.beta channel_product_beta,
- c.receiving_updates
- from rhnChannel c, rhnChannelArch ca, rhnChannel pc, rhnChannelProduct cp
+ c.receiving_updates,
+ ct.label checksum_type
+ from rhnChannel c, rhnChannelArch ca, rhnChannel pc, rhnChannelProduct cp,
+ rhnChecksumType ct
where c.id = :channel_id
and c.channel_arch_id = ca.id
and c.parent_channel = pc.id (+)
and c.channel_product_id = cp.id (+)
+ and c.checksum_type_id = ct.id (+)
""")
def __init__(self, writer, channels):
h = rhnSQL.prepare(self._query_list_channels)
diff --git a/backend/satellite_tools/exporter/exportLib.py b/backend/satellite_tools/exporter/exportLib.py
index 7def917..b6ec961 100644
--- a/backend/satellite_tools/exporter/exportLib.py
+++ b/backend/satellite_tools/exporter/exportLib.py
@@ -215,6 +215,7 @@ class _ChannelDumper(BaseRowDumper):
('rhn-channel-summary', 'summary'),
('rhn-channel-description', 'description'),
('rhn-channel-gpg-key-url', 'gpg_key_url'),
+ ('rhn-channel-checksum-type', 'checksum_type'),
]
for k, v in mappings:
arr.append(SimpleDumper(self._writer, k, self._row[v]))
commit f579d620830160d4c497e45a5ac14aba549e6a72
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Tue Jan 5 14:18:12 2010 +0100
fixed rhn-satellite-exporter to export sha256 content properly
- md5sum="..." attribute was replaced by checksum_type=".." and
checksum="..." attributes
- xml_dumper_version bumped to 4.0
diff --git a/backend/rhn-conf/rhn_server_iss.conf b/backend/rhn-conf/rhn_server_iss.conf
index 129c3f6..f792dc2 100644
--- a/backend/rhn-conf/rhn_server_iss.conf
+++ b/backend/rhn-conf/rhn_server_iss.conf
@@ -4,8 +4,7 @@
# variables which affects live synchronization between two Spacewalk or
# between Satellite and hosted.
-# 2.2 -> 2.3 for satellite 3.6
-xml_dump_version = 3.3
+xml_dump_version = 4.0
use_database_cache = 0
diff --git a/backend/rhn-conf/rhn_server_satellite.conf b/backend/rhn-conf/rhn_server_satellite.conf
index 3e8fc93..0381070 100644
--- a/backend/rhn-conf/rhn_server_satellite.conf
+++ b/backend/rhn-conf/rhn_server_satellite.conf
@@ -29,4 +29,4 @@ cache_refresh_level = 2
cache_refresh_count_max = 5
# dump version
-xml_dump_version = 3.3
+xml_dump_version = 4.0
diff --git a/backend/satellite_tools/disk_dumper/dumper.py b/backend/satellite_tools/disk_dumper/dumper.py
index 0db88f8..7d078e9 100644
--- a/backend/satellite_tools/disk_dumper/dumper.py
+++ b/backend/satellite_tools/disk_dumper/dumper.py
@@ -1289,11 +1289,12 @@ class ShortPackagesDumper(CachedDumper, exportLib.ShortPackagesDumper):
pe.evr.release release,
pe.evr.epoch epoch,
pa.label package_arch,
- c.checksum md5sum,
+ c.checksum_type,
+ c.checksum,
p.package_size,
TO_CHAR(p.last_modified, 'YYYYMMDDHH24MISS') last_modified
from rhnPackage p, rhnPackageName pn, rhnPackageEVR pe,
- rhnPackageArch pa, rhnChecksum c
+ rhnPackageArch pa, rhnChecksumView c
where p.id = :package_id
and p.name_id = pn.id
and p.evr_id = pe.id
@@ -1332,7 +1333,8 @@ class PackagesDumper(CachedDumper, exportLib.PackagesDumper):
p.build_host,
TO_CHAR(p.build_time, 'YYYYMMDDHH24MISS') build_time,
sr.name source_rpm,
- c.checksum md5sum,
+ c.checksum_type,
+ c.checksum,
p.vendor,
p.payload_format,
p.compat,
@@ -1344,7 +1346,7 @@ class PackagesDumper(CachedDumper, exportLib.PackagesDumper):
TO_CHAR(p.last_modified, 'YYYYMMDDHH24MISS') last_modified
from rhnPackage p, rhnPackageName pn, rhnPackageEVR pe,
rhnPackageArch pa, rhnPackageGroup pg, rhnSourceRPM sr,
- rhnChecksum c
+ rhnChecksumView c
where p.id = :package_id
and p.name_id = pn.id
and p.evr_id = pe.id
@@ -1379,10 +1381,11 @@ class SourcePackagesDumper(CachedDumper, exportLib.SourcePackagesDumper):
ps.vendor,
ps.cookie,
ps.package_size,
- c.checksum md5sum,
+ c.checksum_type,
+ c.checksum,
TO_CHAR(ps.last_modified, 'YYYYMMDDHH24MISS') last_modified
from rhnPackageSource ps, rhnPackageGroup pg, rhnSourceRPM sr,
- rhnChecksum c, rhnChecksum sig
+ rhnChecksumView c, rhnChecksum sig
where ps.id = :package_id
and ps.package_group = pg.id
and ps.source_rpm_id = sr.id
diff --git a/backend/satellite_tools/exporter/exportLib.py b/backend/satellite_tools/exporter/exportLib.py
index 56eede5..7def917 100644
--- a/backend/satellite_tools/exporter/exportLib.py
+++ b/backend/satellite_tools/exporter/exportLib.py
@@ -570,7 +570,8 @@ class PackagesDumper(BaseDumper):
p.build_host,
TO_CHAR(p.build_time, 'YYYYMMDDHH24MISS') build_time,
sr.name source_rpm,
- c.checksum md5sum,
+ c.checksum_type,
+ c.checksum,
p.vendor,
p.payload_format,
p.compat,
@@ -582,7 +583,7 @@ class PackagesDumper(BaseDumper):
TO_CHAR(p.last_modified, 'YYYYMMDDHH24MISS') last_modified
from rhnPackage p, rhnPackageName pn, rhnPackageEVR pe,
rhnPackageArch pa, rhnPackageGroup pg, rhnSourceRPM sr,
- rhnChecksum c
+ rhnChecksumView c
where p.name_id = pn.id
and p.evr_id = pe.id
and p.package_arch_id = pa.id
@@ -606,7 +607,7 @@ class _PackageDumper(BaseRowDumper):
def set_attributes(self):
attrs = ["name", "version", "release", "package_arch",
"package_group", "rpm_version", "package_size", "payload_size",
- "build_host", "source_rpm", "md5sum", "payload_format",
+ "build_host", "source_rpm", "checksum_type", "checksum", "payload_format",
"compat", "cookie"]
dict = {
'id' : "rhn-package-%s" % self._row['id'],
@@ -673,9 +674,9 @@ class _PackageDumper(BaseRowDumper):
pc.name, pf.device, pf.inode, pf.file_mode, pf.username,
pf.groupname, pf.rdev, pf.file_size,
TO_CHAR(mtime, 'YYYYMMDDHH24MISS') mtime,
- c.checksum md5, pf.linkto, pf.flags, pf.verifyflags, pf.lang
+ c.checksum_type, c.checksum, pf.linkto, pf.flags, pf.verifyflags, pf.lang
from rhnPackageFile pf, rhnPackageCapability pc,
- rhnChecksum c
+ rhnChecksumView c
where pf.capability_id = pc.id
and pf.package_id = :package_id
and pf.checksum_id = c.id
@@ -701,11 +702,12 @@ class ShortPackagesDumper(BaseDumper):
pe.evr.release release,
pe.evr.epoch epoch,
pa.label package_arch,
- c.checksum md5sum,
+ c.checksum_type,
+ c.checksum,
p.org_id,
TO_CHAR(p.last_modified, 'YYYYMMDDHH24MISS') last_modified
from rhnPackage p, rhnPackageName pn, rhnPackageEVR pe,
- rhnPackageArch pa, rhnChecksum c
+ rhnPackageArch pa, rhnChecksumView c
where p.name_id = pn.id
and p.evr_id = pe.id
and p.package_arch_id = pa.id
@@ -720,7 +722,7 @@ class ShortPackagesDumper(BaseDumper):
attributes = {}
attrs = [
"id", "name", "version", "release", "epoch",
- "package_arch", "md5sum", "package_size",
+ "package_arch", "checksum_type", "checksum", "package_size",
]
for attr in attrs:
attributes[string.replace(attr, '_', '-')] = data[attr]
@@ -754,10 +756,11 @@ class SourcePackagesDumper(BaseDumper):
ps.vendor,
ps.cookie,
ps.package_size,
- c.checksum md5sum,
+ c.checksum_type,
+ c.checksum,
TO_CHAR(ps.last_modified, 'YYYYMMDDHH24MISS') last_modified
from rhnPackageSource ps, rhnPackageGroup pg, rhnSourceRPM sr,
- rhnChecksum c, rhnChecksum sig
+ rhnChecksumView c, rhnChecksum sig
where ps.package_group = pg.id
and ps.source_rpm_id = sr.id
and ps.path is not null
@@ -773,7 +776,7 @@ class SourcePackagesDumper(BaseDumper):
attrs = [
"id", "source_rpm", "package_group", "rpm_version",
"payload_size", "build_host", "sigmd5", "vendor",
- "cookie", "package_size", "md5sum"
+ "cookie", "package_size", "checksum_type", "checksum"
]
for attr in attrs:
attributes[string.replace(attr, '_', '-')] = data[attr]
@@ -830,7 +833,8 @@ class _PackageFilesDumper(BaseDumper):
def dump_subelement(self, data):
data['mtime'] = _dbtime2timestamp(data['mtime'])
- data['md5'] = data['md5'] or ""
+ data['checksum_type'] = data['checksum_type'] or ""
+ data['checksum'] = data['checksum'] or ""
data['linkto'] = data['linkto'] or ""
data['lang'] = data['lang'] or ""
d = EmptyDumper(self._writer, 'rhn-package-file',
@@ -958,12 +962,12 @@ class _ErratumDumper(BaseRowDumper):
h.execute(errata_id=self._row['id'])
arr.append(_ErratumBuglistDumper(self._writer, data_iterator=h))
_query_errata_file_info = """
- select ef.id errata_file_id, c.checksum md5sum,
+ select ef.id errata_file_id, c.checksum_type, c.checksum,
ef.filename, eft.label type,
efp.package_id, efps.package_id source_package_id
from rhnErrataFile ef, rhnErrataFileType eft,
rhnErrataFilePackage efp, rhnErrataFilePackageSource efps,
- rhnChecksum c
+ rhnChecksumView c
where ef.errata_id = :errata_id
and ef.type = eft.id
and ef.checksum_id = c.id
@@ -1026,7 +1030,8 @@ class _ErratumFilesDumper(BaseDumper):
def dump_subelement(self, data):
attributes = {
- 'md5sum' : data['md5sum'],
+ 'checksum_type' : data['checksum_type'],
+ 'checksum' : data['checksum'],
# XXX: band-aid - truncate to 128 chars for olde satellites.
'filename' : data['filename'][:128],
'type' : data['type'],
@@ -1388,10 +1393,11 @@ class _KickstartableTreeDumper(BaseRowDumper):
kstree_id = self._row['id']
h = rhnSQL.prepare("""
select relative_filename "relative-path",
- c.checksum md5sum,
+ c.checksum_type,
+ c.checksum,
file_size "file-size",
TO_CHAR(last_modified, 'YYYYMMDDHH24MISS') "last-modified"
- from rhnKSTreeFile, rhnChecksum c
+ from rhnKSTreeFile, rhnChecksumView c
where kstree_id = :kstree_id
and p.checksum_id = c.id
""")
@@ -1440,7 +1446,8 @@ def packages_cursor(package_id, sources=0):
p.build_host,
TO_CHAR(p.build_time, 'YYYYMMDDHH24MISS') build_time,
sr.name source_rpm,
- c.checksum md5sum,
+ c.checksum_type,
+ c.checksum,
p.vendor,
p.payload_format,
p.compat,
@@ -1451,7 +1458,7 @@ def packages_cursor(package_id, sources=0):
p.cookie
from rhnPackage p, rhnPackageName pn, rhnPackageEVR pe,
rhnPackageArch pa, rhnPackageGroup pg, rhnSourceRPM sr,
- rhnChecksum c
+ rhnChecksumView c
where p.name_id = pn.id
and p.evr_id = pe.id
and p.package_arch_id = pa.id
@@ -1479,9 +1486,10 @@ def _source_packages_cursor(package_id):
ps.vendor,
ps.cookie,
ps.package_size,
- c.checksum md5sum
+ c.checksum_type,
+ c.checksum
from rhnPackageSource ps, rhnPackageGroup pg, rhnSourceRPM sr,
- rhnChecksum c, rhnChecksum sig
+ rhnChecksumView c, rhnChecksum sig
where ps.package_group = pg.id
and ps.source_rpm_id = sr.id
and ps.path is not null
commit 15138f5ab9c2f5657cc6b78bc54ec3c997c4295f
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Tue Jan 5 13:37:18 2010 +0100
fixed order of classes
Traceback (most recent call last):
File "/usr/bin/rhn-satellite-exporter", line 22, in ?
from satellite_tools.disk_dumper import iss
File "/usr/share/rhn/satellite_tools/disk_dumper/iss.py", line 22, in ?
import dumper
File "/usr/share/rhn/satellite_tools/disk_dumper/dumper.py", line 60, in ?
class XML_DumperEx(XML_Dumper):
NameError: name 'XML_Dumper' is not defined
diff --git a/backend/satellite_tools/disk_dumper/dumper.py b/backend/satellite_tools/disk_dumper/dumper.py
index aad3c2d..0db88f8 100644
--- a/backend/satellite_tools/disk_dumper/dumper.py
+++ b/backend/satellite_tools/disk_dumper/dumper.py
@@ -57,333 +57,6 @@ class DatabaseStatement:
def __getattr__(self, name):
return getattr(self.statement, name)
-class XML_DumperEx(XML_Dumper):
- def __init__(self, req):
- self.compress_level = 5
- self.headers_out = UserDictCase()
- self._raw_stream = req
- self._raw_stream.content_type = 'application/octet-stream'
- # State machine
- self._headers_sent = 0
- self._is_closed = 0
- self._compressed_stream = None
- # Redefine in subclasses
- self._channel_family_query = """
- select pcf.channel_family_id, to_number(null) quantity
- from rhnPublicChannelFamily pcf
- """
-
- def _send_headers(self, error=0, init_compressed_stream=1):
- log_debug(4, "is_closed", self._is_closed)
- if self._is_closed:
- raise Exception, "Trying to write to a closed connection"
- if self._headers_sent:
- return
- self._headers_sent = 1
- if self.compress_level:
- self.headers_out['Content-Encoding'] = 'gzip'
- # Send the headers
- if error:
- # No compression
- self.compress_level = 0
- self._raw_stream.content_type = 'text/xml'
- for h, v in self.headers_out.items():
- self._raw_stream.headers_out[h] = str(v)
- self._raw_stream.send_http_header()
- # If need be, start gzipping
- if self.compress_level and init_compressed_stream:
- log_debug(4, "Compressing with factor %s" % self.compress_level)
- self._compressed_stream = gzip.GzipFile(None, "wb",
- self.compress_level, self._raw_stream)
-
- def send(self, data):
- log_debug(3, "Sending %d bytes" % len(data))
- try:
- self._send_headers()
- if self._compressed_stream:
- log_debug(4, "Sending through a compressed stream")
- self._compressed_stream.write(data)
- else:
- self._raw_stream.write(data)
- except IOError:
- log_error("Client appears to have closed connection")
- self.close()
- raise ClosedConnectionError
- log_debug(5, "Bytes sent", len(data))
-
- write = send
-
- def close(self):
- log_debug(2, "Closing")
- if self._is_closed:
- log_debug(3, "Already closed")
- return
-
- if self._compressed_stream:
- log_debug(5, "Closing a compressed stream")
- try:
- self._compressed_stream.close()
- except IOError, e:
- # Remote end has closed connection already
- log_error("Error closing the stream", str(e))
- pass
- self._compressed_stream = None
- self._is_closed = 1
- log_debug(3, "Closed")
-
- # Dumper functions here
- def dump_blacklist_obsoletes(self):
- log_debug(2)
- writer = self._get_xml_writer()
- dumper = SatelliteDumperEx(writer,
- exportLib.BlacklistObsoletesDumper(writer))
- dumper.dump()
- writer.flush()
- log_debug(4, "OK")
- self.close()
- return 0
-
- def dump_arches(self, rpm_arch_type_only=0):
- log_debug(2)
- writer = self._get_xml_writer()
- dumper = SatelliteDumperEx(writer,
- exportLib.ChannelArchesDumper(writer,
- rpm_arch_type_only=rpm_arch_type_only),
- exportLib.PackageArchesDumper(writer,
- rpm_arch_type_only=rpm_arch_type_only),
- exportLib.ServerArchesDumper(writer,
- rpm_arch_type_only=rpm_arch_type_only),
- exportLib.CPUArchesDumper(writer),
- exportLib.ServerPackageArchCompatDumper(writer,
- rpm_arch_type_only=rpm_arch_type_only),
- exportLib.ServerChannelArchCompatDumper(writer,
- rpm_arch_type_only=rpm_arch_type_only),
- exportLib.ChannelPackageArchCompatDumper(writer,
- rpm_arch_type_only=rpm_arch_type_only),
- )
- dumper.dump()
- writer.flush()
- log_debug(4, "OK")
- self.close()
- return 0
-
- def dump_server_group_type_server_arches(self, rpm_arch_type_only=0,
- virt_filter=0):
- log_debug(2)
- writer = self._get_xml_writer()
- dumper = SatelliteDumperEx(writer,
- exportLib.ServerGroupTypeServerArchCompatDumper(writer,
- rpm_arch_type_only=rpm_arch_type_only, virt_filter=virt_filter),
- )
- dumper.dump()
- writer.flush()
- log_debug(4, "OK")
- self.close()
- return 0
-
- def dump_channel_families(self, virt_filter=0):
- log_debug(2)
-
- h = self.get_channel_families_statement()
- h.execute()
-
- writer = self._get_xml_writer()
- dumper = SatelliteDumperEx(writer,
- exportLib.ChannelFamiliesDumper(writer,
- data_iterator=h, null_max_members=0, virt_filter=virt_filter),)
- dumper.dump()
- writer.flush()
- log_debug(4, "OK")
- self.close()
- return 0
-
- def dump_channels(self, channel_labels=None):
- log_debug(2)
- channels = self._validate_channels(channel_labels=channel_labels)
-
- writer = self._get_xml_writer()
- dumper = SatelliteDumperEx(writer, ChannelsDumperEx(writer,
- channels=channels.values()))
- dumper.dump()
- writer.flush()
- log_debug(4, "OK")
- self.close()
- return 0
-
- def dump_channel_packages_short(self, channel_label, last_modified):
- log_debug(2, channel_label)
- channels = self._validate_channels(channel_labels=[channel_label])
- channel_obj = channels[channel_label]
- db_last_modified = int(rhnLib.timestamp(channel_obj['last_modified']))
- last_modified = int(rhnLib.timestamp(last_modified))
- log_debug(3, "last modified", last_modified, "db last modified",
- db_last_modified)
- if last_modified != db_last_modified:
- raise rhnFault(3013, "The requested channel version does not match"
- " the upstream version", explain=0)
- channel_id = channel_obj['channel_id']
- key = "xml-channel-packages/rhn-channel-%d.data" % channel_id
- # Try to get everything off of the cache
- val = rhnCache.get(key, compressed=0, raw=1, modified=last_modified)
- if val is None:
- # Not generated yet
- log_debug(4, "Cache MISS for %s (%s)" % (channel_label,
- channel_id))
- stream = self._cache_channel_packages_short(channel_id, key,
- last_modified)
- else:
- log_debug(4, "Cache HIT for %s (%s)" % (channel_label,
- channel_id))
- temp_stream = tempfile.TemporaryFile()
- temp_stream.write(val)
- temp_stream.flush()
- stream = self._normalize_compressed_stream(temp_stream)
-
- # Copy the results to the output stream
- # They shold be already compressed if they were requested to be
- # compressed
- buffer_size = 16384
- # Send the HTTP headers - but don't init the compressed stream since
- # we send the data ourselves
- self._send_headers(init_compressed_stream=0)
- while 1:
- buff = stream.read(buffer_size)
- if not buff:
- break
- try:
- self._raw_stream.write(buff)
- except IOError:
- log_error("Client disconnected prematurely")
- self.close()
- raise ClosedConnectionError
- # We're done
- return 0
-
- def _cache_channel_packages_short(self, channel_id, key, last_modified):
- """ Caches the short package entries for channel_id """
- # Create a temporary file
- temp_stream = tempfile.TemporaryFile()
- # Always compress the result
- compress_level = 5
- stream = gzip.GzipFile(None, "wb", compress_level, temp_stream)
- writer = xmlWriter.XMLWriter(stream=stream)
-
- # Fetch packages
- h = rhnSQL.prepare(self._query_get_channel_packages)
- h.execute(channel_id=channel_id)
- package_ids = h.fetchall_dict() or []
- # Sort packages
- package_ids.sort(lambda a, b: cmp(a['package_id'], b['package_id']))
-
- dumper = SatelliteDumperEx(writer,
- ShortPackagesDumper(writer, package_ids))
- dumper.dump()
- writer.flush()
- # We're done with the stream object
- stream.close()
- del stream
- temp_stream.seek(0, 0)
- # Set the value in the cache. We don't recompress the result since
- # it's already compressed
- rhnCache.set(key, temp_stream.read(), modified=last_modified,
- compressed=0, raw=1)
- return self._normalize_compressed_stream(temp_stream)
-
- def _packages(self, packages, prefix, dump_class, sources=0):
- if sources:
- h = self.get_source_packages_statement()
- else:
- h = self.get_packages_statement()
-
- packages_hash = {}
- for package in packages:
- package = str(package)
- if package[:len(prefix)] != prefix:
- raise rhnFault(3002, "Invalid package name %s" % package)
- package_id = package[len(prefix):]
- try:
- package_id = int(package_id)
- except ValueError:
- raise rhnFault(3002, "Invalid package name %s" % package)
- if packages_hash.has_key(package_id):
- # Already verified
- continue
- h.execute(package_id=package_id)
- row = h.fetchone_dict()
- if not row:
- # XXX Silently ignore it?
- raise rhnFault(3003, "No such package %s" % package)
- # Saving the row, it's handy later when we create the iterator
- packages_hash[package_id] = row
-
- writer = self._get_xml_writer()
- dumper = SatelliteDumperEx(writer,
- dump_class(writer, packages_hash.values()))
- dumper.dump()
- writer.flush()
- log_debug(4, "OK")
- self.close()
- return 0
-
- def dump_errata(self, errata):
- log_debug(2)
-
- h = self.get_errata_statement()
-
- errata_hash = {}
- prefix = 'rhn-erratum-'
- for erratum in errata:
- erratum = str(erratum)
- if erratum[:len(prefix)] != prefix:
- raise rhnFault(3004, "Wrong erratum name %s" % erratum)
- errata_id = erratum[len(prefix):]
- try:
- errata_id = int(errata_id)
- except ValueError:
- raise rhnFault(3004, "Wrong erratum name %s" % erratum)
- if errata_hash.has_key(errata_id):
- # Already verified
- continue
- h.execute(errata_id=errata_id)
- row = h.fetchone_dict()
- if not row:
- # XXX Silently ignore it?
- raise rhnFault(3005, "No such erratum %s" % erratum)
- # Saving the row, it's handy later when we create the iterator
- errata_hash[errata_id] = row
-
- writer = self._get_xml_writer()
- dumper = SatelliteDumperEx(writer,
- ErrataDumperEx(writer, errata_hash.values()))
- dumper.dump()
- writer.flush()
- log_debug(4, "OK")
- self.close()
- return 0
-
- def dump_kickstartable_trees(self, kickstart_labels=None):
- log_debug(2)
- kickstarts = self._validate_kickstarts(
- kickstart_labels=kickstart_labels)
-
- writer = self._get_xml_writer()
- dumper = SatelliteDumperEx(writer,
- KickstartableTreesDumper(writer, kickstarts=kickstarts))
- dumper.dump()
- writer.flush()
- log_debug(4, "OK")
- self.close()
- return 0
-
- def dump_product_names(self):
- log_debug(4)
- writer = self._get_xml_writer()
- dumper = SatelliteDumperEx(writer, exportLib.ProductNamesDumper(writer))
- dumper.dump()
- writer.flush()
- self.close()
- return 0
-
class XML_Dumper:
def __init__(self):
self.compress_level = 5
@@ -854,12 +527,332 @@ class XML_Dumper:
return result
-class SatelliteDumperEx(SatelliteDumper):
- def set_attributes(self):
- """ Overriding with our own version """
- attributes = SatelliteDumper.set_attributes(self)
- attributes['version'] = constants.PROTOCOL_VERSION
- return attributes
+class XML_DumperEx(XML_Dumper):
+ def __init__(self, req):
+ self.compress_level = 5
+ self.headers_out = UserDictCase()
+ self._raw_stream = req
+ self._raw_stream.content_type = 'application/octet-stream'
+ # State machine
+ self._headers_sent = 0
+ self._is_closed = 0
+ self._compressed_stream = None
+ # Redefine in subclasses
+ self._channel_family_query = """
+ select pcf.channel_family_id, to_number(null) quantity
+ from rhnPublicChannelFamily pcf
+ """
+
+ def _send_headers(self, error=0, init_compressed_stream=1):
+ log_debug(4, "is_closed", self._is_closed)
+ if self._is_closed:
+ raise Exception, "Trying to write to a closed connection"
+ if self._headers_sent:
+ return
+ self._headers_sent = 1
+ if self.compress_level:
+ self.headers_out['Content-Encoding'] = 'gzip'
+ # Send the headers
+ if error:
+ # No compression
+ self.compress_level = 0
+ self._raw_stream.content_type = 'text/xml'
+ for h, v in self.headers_out.items():
+ self._raw_stream.headers_out[h] = str(v)
+ self._raw_stream.send_http_header()
+ # If need be, start gzipping
+ if self.compress_level and init_compressed_stream:
+ log_debug(4, "Compressing with factor %s" % self.compress_level)
+ self._compressed_stream = gzip.GzipFile(None, "wb",
+ self.compress_level, self._raw_stream)
+
+ def send(self, data):
+ log_debug(3, "Sending %d bytes" % len(data))
+ try:
+ self._send_headers()
+ if self._compressed_stream:
+ log_debug(4, "Sending through a compressed stream")
+ self._compressed_stream.write(data)
+ else:
+ self._raw_stream.write(data)
+ except IOError:
+ log_error("Client appears to have closed connection")
+ self.close()
+ raise ClosedConnectionError
+ log_debug(5, "Bytes sent", len(data))
+
+ write = send
+
+ def close(self):
+ log_debug(2, "Closing")
+ if self._is_closed:
+ log_debug(3, "Already closed")
+ return
+
+ if self._compressed_stream:
+ log_debug(5, "Closing a compressed stream")
+ try:
+ self._compressed_stream.close()
+ except IOError, e:
+ # Remote end has closed connection already
+ log_error("Error closing the stream", str(e))
+ pass
+ self._compressed_stream = None
+ self._is_closed = 1
+ log_debug(3, "Closed")
+
+ # Dumper functions here
+ def dump_blacklist_obsoletes(self):
+ log_debug(2)
+ writer = self._get_xml_writer()
+ dumper = SatelliteDumperEx(writer,
+ exportLib.BlacklistObsoletesDumper(writer))
+ dumper.dump()
+ writer.flush()
+ log_debug(4, "OK")
+ self.close()
+ return 0
+
+ def dump_arches(self, rpm_arch_type_only=0):
+ log_debug(2)
+ writer = self._get_xml_writer()
+ dumper = SatelliteDumperEx(writer,
+ exportLib.ChannelArchesDumper(writer,
+ rpm_arch_type_only=rpm_arch_type_only),
+ exportLib.PackageArchesDumper(writer,
+ rpm_arch_type_only=rpm_arch_type_only),
+ exportLib.ServerArchesDumper(writer,
+ rpm_arch_type_only=rpm_arch_type_only),
+ exportLib.CPUArchesDumper(writer),
+ exportLib.ServerPackageArchCompatDumper(writer,
+ rpm_arch_type_only=rpm_arch_type_only),
+ exportLib.ServerChannelArchCompatDumper(writer,
+ rpm_arch_type_only=rpm_arch_type_only),
+ exportLib.ChannelPackageArchCompatDumper(writer,
+ rpm_arch_type_only=rpm_arch_type_only),
+ )
+ dumper.dump()
+ writer.flush()
+ log_debug(4, "OK")
+ self.close()
+ return 0
+
+ def dump_server_group_type_server_arches(self, rpm_arch_type_only=0,
+ virt_filter=0):
+ log_debug(2)
+ writer = self._get_xml_writer()
+ dumper = SatelliteDumperEx(writer,
+ exportLib.ServerGroupTypeServerArchCompatDumper(writer,
+ rpm_arch_type_only=rpm_arch_type_only, virt_filter=virt_filter),
+ )
+ dumper.dump()
+ writer.flush()
+ log_debug(4, "OK")
+ self.close()
+ return 0
+
+ def dump_channel_families(self, virt_filter=0):
+ log_debug(2)
+
+ h = self.get_channel_families_statement()
+ h.execute()
+
+ writer = self._get_xml_writer()
+ dumper = SatelliteDumperEx(writer,
+ exportLib.ChannelFamiliesDumper(writer,
+ data_iterator=h, null_max_members=0, virt_filter=virt_filter),)
+ dumper.dump()
+ writer.flush()
+ log_debug(4, "OK")
+ self.close()
+ return 0
+
+ def dump_channels(self, channel_labels=None):
+ log_debug(2)
+ channels = self._validate_channels(channel_labels=channel_labels)
+
+ writer = self._get_xml_writer()
+ dumper = SatelliteDumperEx(writer, ChannelsDumperEx(writer,
+ channels=channels.values()))
+ dumper.dump()
+ writer.flush()
+ log_debug(4, "OK")
+ self.close()
+ return 0
+
+ def dump_channel_packages_short(self, channel_label, last_modified):
+ log_debug(2, channel_label)
+ channels = self._validate_channels(channel_labels=[channel_label])
+ channel_obj = channels[channel_label]
+ db_last_modified = int(rhnLib.timestamp(channel_obj['last_modified']))
+ last_modified = int(rhnLib.timestamp(last_modified))
+ log_debug(3, "last modified", last_modified, "db last modified",
+ db_last_modified)
+ if last_modified != db_last_modified:
+ raise rhnFault(3013, "The requested channel version does not match"
+ " the upstream version", explain=0)
+ channel_id = channel_obj['channel_id']
+ key = "xml-channel-packages/rhn-channel-%d.data" % channel_id
+ # Try to get everything off of the cache
+ val = rhnCache.get(key, compressed=0, raw=1, modified=last_modified)
+ if val is None:
+ # Not generated yet
+ log_debug(4, "Cache MISS for %s (%s)" % (channel_label,
+ channel_id))
+ stream = self._cache_channel_packages_short(channel_id, key,
+ last_modified)
+ else:
+ log_debug(4, "Cache HIT for %s (%s)" % (channel_label,
+ channel_id))
+ temp_stream = tempfile.TemporaryFile()
+ temp_stream.write(val)
+ temp_stream.flush()
+ stream = self._normalize_compressed_stream(temp_stream)
+
+ # Copy the results to the output stream
+ # They shold be already compressed if they were requested to be
+ # compressed
+ buffer_size = 16384
+ # Send the HTTP headers - but don't init the compressed stream since
+ # we send the data ourselves
+ self._send_headers(init_compressed_stream=0)
+ while 1:
+ buff = stream.read(buffer_size)
+ if not buff:
+ break
+ try:
+ self._raw_stream.write(buff)
+ except IOError:
+ log_error("Client disconnected prematurely")
+ self.close()
+ raise ClosedConnectionError
+ # We're done
+ return 0
+
+ def _cache_channel_packages_short(self, channel_id, key, last_modified):
+ """ Caches the short package entries for channel_id """
+ # Create a temporary file
+ temp_stream = tempfile.TemporaryFile()
+ # Always compress the result
+ compress_level = 5
+ stream = gzip.GzipFile(None, "wb", compress_level, temp_stream)
+ writer = xmlWriter.XMLWriter(stream=stream)
+
+ # Fetch packages
+ h = rhnSQL.prepare(self._query_get_channel_packages)
+ h.execute(channel_id=channel_id)
+ package_ids = h.fetchall_dict() or []
+ # Sort packages
+ package_ids.sort(lambda a, b: cmp(a['package_id'], b['package_id']))
+
+ dumper = SatelliteDumperEx(writer,
+ ShortPackagesDumper(writer, package_ids))
+ dumper.dump()
+ writer.flush()
+ # We're done with the stream object
+ stream.close()
+ del stream
+ temp_stream.seek(0, 0)
+ # Set the value in the cache. We don't recompress the result since
+ # it's already compressed
+ rhnCache.set(key, temp_stream.read(), modified=last_modified,
+ compressed=0, raw=1)
+ return self._normalize_compressed_stream(temp_stream)
+
+ def _packages(self, packages, prefix, dump_class, sources=0):
+ if sources:
+ h = self.get_source_packages_statement()
+ else:
+ h = self.get_packages_statement()
+
+ packages_hash = {}
+ for package in packages:
+ package = str(package)
+ if package[:len(prefix)] != prefix:
+ raise rhnFault(3002, "Invalid package name %s" % package)
+ package_id = package[len(prefix):]
+ try:
+ package_id = int(package_id)
+ except ValueError:
+ raise rhnFault(3002, "Invalid package name %s" % package)
+ if packages_hash.has_key(package_id):
+ # Already verified
+ continue
+ h.execute(package_id=package_id)
+ row = h.fetchone_dict()
+ if not row:
+ # XXX Silently ignore it?
+ raise rhnFault(3003, "No such package %s" % package)
+ # Saving the row, it's handy later when we create the iterator
+ packages_hash[package_id] = row
+
+ writer = self._get_xml_writer()
+ dumper = SatelliteDumperEx(writer,
+ dump_class(writer, packages_hash.values()))
+ dumper.dump()
+ writer.flush()
+ log_debug(4, "OK")
+ self.close()
+ return 0
+
+ def dump_errata(self, errata):
+ log_debug(2)
+
+ h = self.get_errata_statement()
+
+ errata_hash = {}
+ prefix = 'rhn-erratum-'
+ for erratum in errata:
+ erratum = str(erratum)
+ if erratum[:len(prefix)] != prefix:
+ raise rhnFault(3004, "Wrong erratum name %s" % erratum)
+ errata_id = erratum[len(prefix):]
+ try:
+ errata_id = int(errata_id)
+ except ValueError:
+ raise rhnFault(3004, "Wrong erratum name %s" % erratum)
+ if errata_hash.has_key(errata_id):
+ # Already verified
+ continue
+ h.execute(errata_id=errata_id)
+ row = h.fetchone_dict()
+ if not row:
+ # XXX Silently ignore it?
+ raise rhnFault(3005, "No such erratum %s" % erratum)
+ # Saving the row, it's handy later when we create the iterator
+ errata_hash[errata_id] = row
+
+ writer = self._get_xml_writer()
+ dumper = SatelliteDumperEx(writer,
+ ErrataDumperEx(writer, errata_hash.values()))
+ dumper.dump()
+ writer.flush()
+ log_debug(4, "OK")
+ self.close()
+ return 0
+
+ def dump_kickstartable_trees(self, kickstart_labels=None):
+ log_debug(2)
+ kickstarts = self._validate_kickstarts(
+ kickstart_labels=kickstart_labels)
+
+ writer = self._get_xml_writer()
+ dumper = SatelliteDumperEx(writer,
+ KickstartableTreesDumper(writer, kickstarts=kickstarts))
+ dumper.dump()
+ writer.flush()
+ log_debug(4, "OK")
+ self.close()
+ return 0
+
+ def dump_product_names(self):
+ log_debug(4)
+ writer = self._get_xml_writer()
+ dumper = SatelliteDumperEx(writer, exportLib.ProductNamesDumper(writer))
+ dumper.dump()
+ writer.flush()
+ self.close()
+ return 0
class SatelliteDumper(exportLib.SatelliteDumper):
def set_attributes(self):
@@ -869,6 +862,13 @@ class SatelliteDumper(exportLib.SatelliteDumper):
attributes['generation'] = CFG.SAT_CERT_GENERATION
return attributes
+class SatelliteDumperEx(SatelliteDumper):
+ def set_attributes(self):
+ """ Overriding with our own version """
+ attributes = SatelliteDumper.set_attributes(self)
+ attributes['version'] = constants.PROTOCOL_VERSION
+ return attributes
+
class QueryIterator:
""" A query iterator successively applies the list of params as execute() to the
statement that was passed in, and presents the union of the result sets as a
@@ -1039,35 +1039,6 @@ class CachedDumper(exportLib.BaseDumper):
self.cache_set(params, s.getvalue())
-class ChannelsDumperEx(CachedDumper, exportLib.ChannelsDumper):
- _query_list_channels = rhnSQL.Statement("""
- select c.id, c.label, ca.label channel_arch, c.basedir, c.name,
- c.summary, c.description, c.gpg_key_url, c.org_id,
- TO_CHAR(c.last_modified, 'YYYYMMDDHH24MISS') last_modified,
- c.channel_product_id,
- pc.label parent_channel,
- cp.product channel_product,
- cp.version channel_product_version,
- cp.beta channel_product_beta,
- c.receiving_updates
- from rhnChannel c, rhnChannelArch ca, rhnChannel pc, rhnChannelProduct cp
- where c.id = :channel_id
- and c.channel_arch_id = ca.id
- and c.parent_channel = pc.id (+)
- and c.channel_product_id = cp.id (+)
- """)
- def __init__(self, writer, channels):
- h = rhnSQL.prepare(self._query_list_channels)
- CachedDumper.__init__(self, writer, statement=h, params=channels)
-
- def _get_key(self, params):
- channel_id = params['channel_id']
- return "xml-channels/rhn-channel-%d.xml" % channel_id
-
- def _dump_subelement(self, data):
- log_debug(6, data)
- return exportLib.ChannelsDumper.dump_subelement(self, data)
-
class ChannelsDumper(CachedDumper, exportLib.ChannelsDumper):
_query_list_channels = rhnSQL.Statement("""
select c.id, c.org_id,
@@ -1278,6 +1249,35 @@ class _ChannelsDumper(exportLib._ChannelDumper):
return ks_trees
+class ChannelsDumperEx(CachedDumper, exportLib.ChannelsDumper):
+ _query_list_channels = rhnSQL.Statement("""
+ select c.id, c.label, ca.label channel_arch, c.basedir, c.name,
+ c.summary, c.description, c.gpg_key_url, c.org_id,
+ TO_CHAR(c.last_modified, 'YYYYMMDDHH24MISS') last_modified,
+ c.channel_product_id,
+ pc.label parent_channel,
+ cp.product channel_product,
+ cp.version channel_product_version,
+ cp.beta channel_product_beta,
+ c.receiving_updates
+ from rhnChannel c, rhnChannelArch ca, rhnChannel pc, rhnChannelProduct cp
+ where c.id = :channel_id
+ and c.channel_arch_id = ca.id
+ and c.parent_channel = pc.id (+)
+ and c.channel_product_id = cp.id (+)
+ """)
+ def __init__(self, writer, channels):
+ h = rhnSQL.prepare(self._query_list_channels)
+ CachedDumper.__init__(self, writer, statement=h, params=channels)
+
+ def _get_key(self, params):
+ channel_id = params['channel_id']
+ return "xml-channels/rhn-channel-%d.xml" % channel_id
+
+ def _dump_subelement(self, data):
+ log_debug(6, data)
+ return exportLib.ChannelsDumper.dump_subelement(self, data)
+
class ShortPackagesDumper(CachedDumper, exportLib.ShortPackagesDumper):
def __init__(self, writer, packages):
h = rhnSQL.prepare("""
@@ -1400,11 +1400,12 @@ class SourcePackagesDumper(CachedDumper, exportLib.SourcePackagesDumper):
log_debug(6, data)
return exportLib.SourcePackagesDumper.dump_subelement(self, data)
-class ErrataDumperEx(CachedDumper, exportLib.ErrataSynopsisDumper):
+class ErrataDumper(CachedDumper, exportLib.ErrataDumper):
def __init__(self, writer, errata):
h = rhnSQL.prepare("""
select
e.id,
+ e.org_id,
e.advisory_name,
e.advisory,
e.advisory_type,
@@ -1431,14 +1432,13 @@ class ErrataDumperEx(CachedDumper, exportLib.ErrataSynopsisDumper):
def _dump_subelement(self, data):
log_debug(6, data)
- return exportLib.ErrataSynopsisDumper.dump_subelement(self, data)
+ return exportLib.ErrataDumper.dump_subelement(self, data)
-class ErrataDumper(CachedDumper, exportLib.ErrataDumper):
+class ErrataDumperEx(CachedDumper, exportLib.ErrataSynopsisDumper):
def __init__(self, writer, errata):
h = rhnSQL.prepare("""
- select
+ select
e.id,
- e.org_id,
e.advisory_name,
e.advisory,
e.advisory_type,
@@ -1465,7 +1465,7 @@ class ErrataDumper(CachedDumper, exportLib.ErrataDumper):
def _dump_subelement(self, data):
log_debug(6, data)
- return exportLib.ErrataDumper.dump_subelement(self, data)
+ return exportLib.ErrataSynopsisDumper.dump_subelement(self, data)
class KickstartableTreesDumper(CachedDumper, exportLib.KickstartableTreesDumper):
_query_lookup_ks_tree = rhnSQL.Statement("""
14 years, 3 months
3 commits - web/modules
by Jan Pazdziora
web/modules/rhn/RHN/Channel.pm | 8
web/modules/rhn/RHN/DB/ConfigChannel.pm | 58 -----
web/modules/rhn/RHN/DB/Kickstart.pm | 324 --------------------------------
web/modules/rhn/RHN/Errata.pm | 8
web/modules/rhn/RHN/Package.pm | 8
5 files changed, 406 deletions(-)
New commits:
commit 874a2489b57a523f861e4beed1b1454909fb34c1
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 15:08:13 2010 +0100
Removing bunch of unused methods from RHN::DB::Kickstart:
lookup_ks_by_system_ip
lookup_ks_by_ip_in_range
lookup_org_default
pre_helper
valid_pre_helpers
nochroot_post_helper
post_helper
valid_post_helpers
remove_ip_range
change_dist
change_url_host
change_url
get_url_path
tinify_url
gpg_key_data
ssl_key_data
installer_generation
get_ip_url
get_regtokens
set_regtokens
diff --git a/web/modules/rhn/RHN/DB/Kickstart.pm b/web/modules/rhn/RHN/DB/Kickstart.pm
index a96e5fb..59720b8 100644
--- a/web/modules/rhn/RHN/DB/Kickstart.pm
+++ b/web/modules/rhn/RHN/DB/Kickstart.pm
@@ -580,48 +580,6 @@ EOQ
return $ks;
}
-sub lookup_ks_by_system_ip {
- return undef; # stub
-}
-
-sub lookup_ks_by_ip_in_range {
- my $class = shift;
- my %params = validate(@_, { org_id => { optional => 0 }, ip => { optional => 0 } });
-
- my @ranges = RHN::Kickstart::IPRange->org_ranges_for_ip(%params);
-
- my $best_fit;
-
- foreach my $range (@ranges) {
- $best_fit ||= $range;
-
- $best_fit = $range if ($range->subset_of($best_fit));
- }
-
- return unless $best_fit;
-
- return RHN::Kickstart->lookup(-id => $best_fit->ksid);
-}
-
-sub lookup_org_default {
- my $class = shift;
- my %params = validate(@_, { org_id => { optional => 0 } });
-
- my $dbh = RHN::DB->connect;
- my $sth = $dbh->prepare(<<EOQ);
-SELECT id FROM rhnKSData WHERE org_id = :org_id AND is_org_default = 'Y'
-EOQ
-
- $sth->execute_h(org_id => $params{org_id});
-
- my ($id) = $sth->fetchrow;
- $sth->finish;
-
- return unless $id;
-
- return $class->lookup(-id => $id);
-}
-
# set or get commands for this kickstart
# set with a hashref, array, or RHN::Kickstart::Commands object
sub commands {
@@ -743,21 +701,6 @@ sub pre {
return ($pre ? $pre->as_string : '');
}
-sub pre_helper {
- my $self = shift;
- my $method = shift;
-
- my $pre = $self->SUPER::pre;
-
- return ($pre ? $pre->$method(@_) : undef);
-}
-
-sub valid_pre_helpers {
- my $self = shift;
-
- return RHN::Kickstart::Pre::valid_helpers;
-}
-
sub post {
my $self = shift;
my $val = shift;
@@ -800,48 +743,6 @@ sub nochroot_post {
return ($post ? $post->as_string : '');
}
-sub nochroot_post_helper {
- my $self = shift;
- my $method = shift;
-
- my $post = $self->SUPER::nochroot_post;
-
- if ($post) {
- if ($post->can($method)) {
- return $post->$method(@_);
- }
- else {
- return $post->choose_action($method, @_);
- }
- }
-
- return;
-}
-
-sub post_helper {
- my $self = shift;
- my $method = shift;
-
- my $post = $self->SUPER::post;
-
- if ($post) {
- if ($post->can($method)) {
- return $post->$method(@_);
- }
- else {
- return $post->choose_action($method, @_);
- }
- }
-
- return;
-}
-
-sub valid_post_helpers {
- my $self = shift;
-
- return RHN::Kickstart::Post::valid_helpers;
-}
-
sub delete_kickstart {
my $class = shift;
my $id = shift;
@@ -910,29 +811,6 @@ EOQ
return;
}
-sub remove_ip_range {
- my $class = shift;
- my $ksid = shift;
- my $min = shift;
- my $max = shift;
-
- my $dbh = RHN::DB->connect;
- my $query =<<EOQ;
-DELETE
- FROM rhnKickstartIPRange KSIPR
- WHERE KSIPR.kickstart_id = :ksid
- AND KSIPR.min = :min
- AND KSIPR.max = :max
-EOQ
-
- my $sth = $dbh->prepare($query);
- $sth->execute_h(ksid => $ksid, min => $min, max => $max);
-
- $dbh->commit;
-
- return;
-}
-
sub kickstarts_for_org {
my $class = shift;
my $org_id = shift;
@@ -945,135 +823,6 @@ sub kickstarts_for_org {
return @{$data};
}
-# change kickstart from one 'dist' to another, and interject the
-# session strings if present. only works if 'url' command is like:
-# url --url http://rhn.webdev.redhat.com/kickstart/dist/ks-redhat-advanced-server-i386
-# An input of 'blinky' would change 'ks-redhat-advanced-server-i386'
-# to 'blinky' (or '/session/SOMESESSION/ks-redhat-blahblah' if a
-# session is present)
-
-sub change_dist {
- my $self = shift;
- my $dist = shift;
- my $session_id = shift;
-
- my $interjection = '';
- if ($session_id) {
- $interjection = join("/", "session", RHN::SessionSwap->encode_data($session_id), '');
- }
-
- return unless $self->commands and $self->commands->url;
-
- my @url_data = @{$self->commands->url};
- my $found = 0;
-
- foreach my $arg (@url_data) {
- if ($found) {
- $arg =~ s<dist/(.*)/?><"dist/$interjection" . ($dist || $1)>e;
- }
-
- if ($arg eq '--url') {
- $found = 1;
- }
- }
-
- $self->commands->url(\@url_data);
-
- return $dist;
-}
-
-sub change_url_host {
- my $self = shift;
- my $host = shift;
-
- return unless $self->commands and $self->commands->url;
-
- my @url_data = @{$self->commands->url};
- my $found = 0;
-
- foreach my $arg (@url_data) {
- if ($found) {
- $arg =~ s<(https?://)[^/]*><$1 . $host>e;
- }
-
- if ($arg eq '--url') {
- $found = 1;
- }
- }
-
- $self->commands->url(\@url_data);
-
- return;
-}
-
-sub change_url {
- my $self = shift;
- my $new_url = shift;
-
- throw "(missing_param) No url" unless $new_url;
-
- return unless $self->commands and $self->commands->url;
-
- my @url_data = @{$self->commands->url};
- my $found = 0;
-
- foreach my $arg (@url_data) {
- if ($found) {
- $arg =~ s|.*|$new_url|;
-
- }
-
- if ($arg eq '--url') {
- $found = 1;
- }
- }
-
- $self->commands->url(\@url_data);
-
- return;
-}
-
-sub get_url_path {
- my $self = shift;
-
- return unless $self->commands and $self->commands->url;
-
- my $path;
- my $found = 0;
-
- my @url_data = @{$self->commands->url};
-
- foreach my $arg (@url_data) {
- if ($found) {
- $arg =~ m<https?://[^/]*(.*)>;
- $path = $1;
- }
-
- if ($arg eq '--url') {
- $found = 1;
- }
- }
-
- return $path;
-}
-
-sub tinify_url {
- my $self = shift;
- my $expiration = shift;
-
- if ($self->host) {
- my $path = $self->get_url_path;
-
- my ($ty) = RHN::TinyURL->tinify_path(-path => $path,
- -host => $self->host,
- -expiration => $expiration);
-
- $self->change_url($ty);
- }
-
- return;
-}
-
sub dist {
my $self = shift;
@@ -1146,24 +895,6 @@ EOQ
return @{$data};
}
-sub gpg_key_data {
- my $self = shift;
-
- my @keys = $self->crypto_keys;
-
- return map { $_->{KEY} }
- grep { $_->{LABEL} eq 'GPG' } @keys;
-}
-
-sub ssl_key_data {
- my $self = shift;
-
- my @keys = $self->crypto_keys;
-
- return map { $_->{KEY} }
- grep { $_->{LABEL} eq 'SSL' } @keys;
-}
-
sub default_tree {
my $self = shift;
@@ -1197,14 +928,6 @@ EOQ
return $row->{'LABEL'};
}
-sub installer_generation {
- my $self = shift;
-
- my $tree = $self->default_tree;
-
- return $tree->install_type_label;
-}
-
sub org_ks_ip_ranges {
my $class = shift;
my $org_id = shift;
@@ -1259,52 +982,5 @@ sub generate_url {
return $url;
}
-sub get_ip_url {
- my $class = shift;
- my $url = generate_url(@_, -mode => 'ip_range');
-
- return $url->as_string;
-}
-
-sub get_regtokens {
- my $self = shift;
-
- my $ds = new RHN::DataSource::General(-mode => 'regtokens_for_kickstart_profile');
- my $data = $ds->execute_full(-ksid => $self->id);
-
- my @tokens = map { RHN::Token->lookup(-id => $_->{ID}) } @{$data};
-
- return @tokens;
-}
-
-sub set_regtokens {
- my $self = shift;
- my @token_ids = @_;
-
- my $dbh = RHN::DB->connect;
- my $del_sth = $dbh->prepare(<<EOQ);
-DELETE
- FROM rhnKickstartDefaultRegToken KDRT
- WHERE KDRT.kickstart_id = :ksid
-EOQ
-
- $del_sth->execute_h(ksid => $self->id);
-
- my $ins_sth = $dbh->prepare(<<EOQ);
-INSERT
- INTO rhnKickstartDefaultRegToken
- (kickstart_id, regtoken_id)
-VALUES (:ksid, :rtid)
-EOQ
-
- foreach my $tid (@token_ids) {
- $ins_sth->execute_h(ksid => $self->id, rtid => $tid);
- }
-
- $dbh->commit;
-
- return;
-}
-
1;
commit 4e2ff743a925d00250b0748102171f7585ec6fa5
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 14:56:30 2010 +0100
Remove four unused methods in RHN::DB::ConfigChannel:
delete_config_channel
find_overriding_system
presentation_name
latest_revisions
diff --git a/web/modules/rhn/RHN/DB/ConfigChannel.pm b/web/modules/rhn/RHN/DB/ConfigChannel.pm
index e48fa2d..1c808af 100644
--- a/web/modules/rhn/RHN/DB/ConfigChannel.pm
+++ b/web/modules/rhn/RHN/DB/ConfigChannel.pm
@@ -169,18 +169,6 @@ EOQ
return;
}
-sub delete_config_channel {
- my $self = shift;
-
- my $dbh = RHN::DB->connect;
-
- my $sth = $dbh->call_procedure('rhn_config.delete_channel', $self->id);
-
- $dbh->commit;
-
- return;
-}
-
sub commit {
my $self = shift;
my $transaction = shift;
@@ -366,52 +354,6 @@ sub vivify_file_existence {
return $ret;
}
-sub find_overriding_system {
- my $self = shift;
-
- my $sth = RHN::DB->connect->prepare(<<EOS);
-SELECT SCC.server_id
- FROM rhnServerConfigChannel SCC,
- rhnConfigChannelType CCT,
- rhnConfigChannel CC
- WHERE CC.id = :ccid
- AND CC.confchan_type_id = CCT.id
- AND SCC.config_channel_id = CC.id
-EOS
- $sth->execute_h(ccid => $self->id);
- my ($ret) = $sth->fetchrow;
- $sth->finish;
-
- return $ret;
-}
-
-sub presentation_name {
- my $self = shift;
-
- if ($self->type_label eq 'local_override') {
- my $sid = $self->find_overriding_system;
- my $server = RHN::Server->lookup(-id => $sid);
- return $server->name;
- }
- else {
- return $self->name;
- }
-}
-
-sub latest_revisions {
- my $class = shift;
- my $cc_id = shift;
-
- die "no cc_id" unless $cc_id;
-
- my $ds = new RHN::DataSource::Simple(-querybase => 'config_queries',
- -mode => 'latest_files_in_namespace',
- );
-
- my $revisions = $ds->execute_query(-ccid => $cc_id);
- return @{$revisions};
-}
-
sub lookup_latest_in_channel {
my $class = shift;
my %params = validate(@_, { channel_id => 1,
commit 03d5af1c9a554999b49d6d73c5013e2f7c51c8f6
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 14:54:12 2010 +0100
Remove the (deprecated and) unused lookup_channel, lookup_errata, and lookup_package methods.
diff --git a/web/modules/rhn/RHN/Channel.pm b/web/modules/rhn/RHN/Channel.pm
index c5268b9..a7c6f56 100644
--- a/web/modules/rhn/RHN/Channel.pm
+++ b/web/modules/rhn/RHN/Channel.pm
@@ -36,14 +36,6 @@ sub lookup {
}
}
-sub lookup_channel {
- my $class = shift;
-
- warn "deprecated use of $class->lookup_foo from (" . join(', ', caller) . "). Using $class->lookup instead\n";
-
- return $class->lookup(@_);
-}
-
sub user_subscribable_bases_for_system {
my $class = shift;
my $system = shift;
diff --git a/web/modules/rhn/RHN/Errata.pm b/web/modules/rhn/RHN/Errata.pm
index 69173b1..b897fe9 100644
--- a/web/modules/rhn/RHN/Errata.pm
+++ b/web/modules/rhn/RHN/Errata.pm
@@ -34,12 +34,4 @@ sub lookup {
}
}
-sub lookup_errata {
- my $class = shift;
-
- warn "deprecated use of $class->lookup_foo from (" . join(', ', caller) . "). Using $class->lookup instead\n";
-
- return $class->lookup(@_);
-}
-
1;
diff --git a/web/modules/rhn/RHN/Package.pm b/web/modules/rhn/RHN/Package.pm
index f942d39..b9b2613 100644
--- a/web/modules/rhn/RHN/Package.pm
+++ b/web/modules/rhn/RHN/Package.pm
@@ -37,14 +37,6 @@ sub lookup {
}
}
-sub lookup_package {
- my $class = shift;
-
- warn "deprecated use of $class->lookup_foo from (" . join(', ', caller) . "). Using $class->lookup instead\n";
-
- return $class->lookup(@_);
-}
-
my $RPMSENSE_LESS = 2;
my $RPMSENSE_GREATER = 4;
my $RPMSENSE_EQUAL = 8;
14 years, 3 months
3 commits - web/modules
by Jan Pazdziora
web/modules/rhn/RHN/DB/Errata.pm | 345 ----------------------
web/modules/rhn/RHN/DB/Server.pm | 603 ---------------------------------------
web/modules/rhn/RHN/Postal.pm | 21 -
3 files changed, 969 deletions(-)
New commits:
commit ffe0aa991779541411d0a1c4b0350605e93f34d1
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 14:50:19 2010 +0100
Removing bunch of unused methods from RHN::DBD::Server:
osa_ping
osa_status
osa_timestamps
get_latest_action
server_channel_names
server_channel_ids
change_base_channel
group_list_for_server
visible_group_list_for_server
rhn_packages
server_channel_tree
lookup_by_cert
generate_server_certificate
create_server
unentitled_set_count
random_server_id
client_capabilities
latest_managed_config_revisions
get_rhn_kickstart_package
get_latest_actions
lock_server
unlock_server
installable_up2date_version_at_least
proxy_sid
diff --git a/web/modules/rhn/RHN/DB/Server.pm b/web/modules/rhn/RHN/DB/Server.pm
index fb6c53e..6632fba 100644
--- a/web/modules/rhn/RHN/DB/Server.pm
+++ b/web/modules/rhn/RHN/DB/Server.pm
@@ -135,58 +135,6 @@ my $j = $s_table->create_join(
# Server object methods
############################
-sub osa_ping {
- my $self = shift;
-
- my $dbh = RHN::DB->connect();
- my $sth = $dbh->prepare(<<EOQ);
-UPDATE rhnPushClient
- SET last_ping_time = sysdate,
- next_action_time = NULL
- WHERE server_id = :server_id
-EOQ
- $sth->execute_h(server_id => $self->id);
- $dbh->commit;
-}
-
-sub osa_status {
- my $self = shift;
-
- my $dbh = RHN::DB->connect();
- my $sth = $dbh->prepare(<<EOQ);
-SELECT PCS.name
- FROM rhnPushClientState PCS,
- rhnPushClient PC
- WHERE PC.server_id = :server_id
- AND PC.state_id = PCS.id
-EOQ
-
- $sth->execute_h(server_id => $self->id);
- my ($state) = $sth->fetchrow;
- $sth->finish;
-
- return $state;
-}
-
-sub osa_timestamps {
- my $self = shift;
-
- my $dbh = RHN::DB->connect();
- my $sth = $dbh->prepare(<<EOQ);
-SELECT TO_CHAR(PC.last_message_time, 'YYYY-MM-DD HH24:MI:SS') AS LAST_MESSAGE_TIME,
- TO_CHAR(PC.last_ping_time, 'YYYY-MM-DD HH24:MI:SS') AS LAST_PING_TIME,
- TO_CHAR(PC.modified, 'YYYY-MM-DD HH24:MI:SS') AS MODIFIED
- FROM rhnPushClient PC
- WHERE PC.server_id = :server_id
-EOQ
-
- $sth->execute_h(server_id => $self->id);
- my ($timestamps) = $sth->fetchrow_hashref;
- $sth->finish;
-
- return $timestamps;
-}
-
sub applet_activated {
my $self = shift;
@@ -230,67 +178,6 @@ sub get_resolved_files {
return @ret;
}
-# given an actiontype label and status, get the latest action
-# that matches for this system
-sub get_latest_action {
- my $self = shift;
- my %params = validate(@_, {action_type => 1, status => 0});
-
- my $status_str = "";
-
- my @valid_statuses;
- my @params;
-
- my @status_values;
-
- if ($params{status}) {
- @valid_statuses = @{$params{status}};
-
- my $last_index = scalar @valid_statuses - 1;
- @params = map {"a$_"} (0..$last_index);
-
- for my $index (0..$last_index) {
- push @status_values, ($params[$index] => $valid_statuses[$index]);
- }
-
- $status_str = sprintf(<<EOQ, join(", ", map {":$_"} @params));
-AND AStat.name IN (%s)
-EOQ
-
- }
-
- my $dbh = RHN::DB->connect();
- my $sth = $dbh->prepare(<<EOQ);
-SELECT SA.action_id
- FROM rhnActionStatus AStat,
- rhnActionType AType,
- rhnAction A,
- rhnServerAction SA
- WHERE SA.server_id = :server_id
- AND SA.status = AStat.id
- AND SA.action_id = A.id
- AND AType.label = :action_type
- AND A.action_type = AType.id
- $status_str
-ORDER BY SA.action_id DESC
-EOQ
-
- $sth->execute_h(server_id => $self->id,
- action_type => $params{action_type},
- @status_values,
- );
-
- my ($action_id) = $sth->fetchrow;
- $sth->finish;
-
- return unless $action_id;
-
- my $action = RHN::Action->lookup(-id => $action_id);
- die "no action object for action_id $action_id" unless $action;
-
- return $action;
-}
-
sub get_cpu_arch_name {
my $self = shift;
@@ -1528,43 +1415,6 @@ sub server_channels {
return @{$data};
}
-sub server_channel_names {
- my $self = shift;
-
- my $dbh = RHN::DB->connect;
- my $sth = $dbh->prepare('SELECT C.name FROM rhnChannel C, rhnServerChannel SC WHERE C.id = SC.channel_id AND SC.server_id = ?');
- $sth->execute($self->id);
-
- my @ret;
- while (my ($name) = $sth->fetchrow) {
- push @ret, $name;
- }
-
- return @ret;
-}
-
-sub server_channel_ids {
- my $self = shift;
-
- my $dbh = RHN::DB->connect;
- my $query = <<EOQ;
-SELECT C.id
- FROM rhnChannel C, rhnServerChannel SC
- WHERE C.id = SC.channel_id
- AND SC.server_id = ?
-ORDER BY C.parent_channel NULLS LAST
-EOQ
- my $sth = $dbh->prepare($query);
- $sth->execute($self->id);
-
- my @ret;
- while (my ($id) = $sth->fetchrow) {
- push @ret, $id;
- }
-
- return @ret;
-}
-
sub channel_list {
my $self = shift;
@@ -1654,40 +1504,6 @@ EOH
}
}
-sub change_base_channel {
- my $self = shift;
- my $cid = shift;
-
- my @old_channels = $self->server_channel_ids;
-
- my $dbh = RHN::DB->connect;
- my $sth;
-
- foreach my $cid (@old_channels) {
- $sth = $dbh->prepare(<<EOH);
-BEGIN
- rhn_channel.unsubscribe_server(?, ?);
-END;
-EOH
- $sth->execute($self->id, $cid);
- }
-
- $sth = $dbh->prepare(<<EOH);
-BEGIN
- rhn_channel.subscribe_server(?, ?);
-END;
-EOH
- $sth->execute($self->id, $cid)
- if $cid;
-
- my ($add, $remove, $unc) = RHN::DB::Server->update_cache_for_server($dbh, $self->id);
- warn sprintf "EC update: %d added, %d removed, $unc unchanged", scalar @$add, scalar @$remove;
-
- $dbh->commit;
-
- return $cid;
-}
-
# returns an array of all the cd devices connected to a server
# TODO: should we be caching this result?
sub get_cd_devices {
@@ -1853,52 +1669,6 @@ sub commit {
delete $self->{":modified:"};
}
-sub group_list_for_server {
- my $self = shift;
-
- my $dbh = RHN::DB->connect;
- my $query = <<EOS;
- SELECT MAX(DECODE(server_id, ?, 1, 0)), GROUP_ID, GROUP_NAME, GROUP_TYPE, CURRENT_MEMBERS, MAX_MEMBERS
- FROM rhnServerGroupMembership
- WHERE ORG_ID = ?
-GROUP BY group_id, group_name, group_type, current_members, max_members
-ORDER BY UPPER(group_name), group_id
-EOS
-
- my $sth = $dbh->prepare($query);
- $sth->execute($self->id, $self->org_id);
-
- my @ret;
- while (my ($server_member, $id, $name, $label, $current, $max) = $sth->fetchrow) {
- push @ret, [ $server_member, $id, $name, $label, $current, $max ];
- }
-
- return @ret;
-}
-
-sub visible_group_list_for_server {
- my $self = shift;
-
- my $dbh = RHN::DB->connect;
- my $query = <<EOS;
- SELECT MAX(DECODE(server_id, ?, 1, 0)), GROUP_ID, GROUP_NAME, GROUP_TYPE, CURRENT_MEMBERS, MAX_MEMBERS
- FROM rhnVisServerGroupMembership
- WHERE ORG_ID = ?
-GROUP BY group_id, group_name, group_type, current_members, max_members
-ORDER BY UPPER(group_name), group_id
-EOS
-
- my $sth = $dbh->prepare($query);
- $sth->execute($self->id, $self->org_id);
-
- my @ret;
- while (my ($server_member, $id, $name, $label, $current, $max) = $sth->fetchrow) {
- push @ret, [ $server_member, $id, $name, $label, $current, $max ];
- }
-
- return @ret;
-}
-
sub package_groups {
my $self = shift;
@@ -2151,81 +1921,6 @@ sub can_switch_base_entitlement {
return $can ? 1 : 0;
}
-# returns name-evr info about the RHN-related packages installed on the system...
-# used for support tool...
-sub rhn_packages {
- my $self = shift;
-
- my $dbh = RHN::DB->connect;
- my $query = <<EOS;
-SELECT PN.name || '-' || PE.evr.as_vre_simple()
- FROM rhnPackageName PN, rhnPackageEVR PE, rhnServerPackage SP
- WHERE SP.server_id = ?
- AND SP.name_id = PN.id
- AND SP.evr_id = PE.id
- AND PN.name IN ('rhn_register', 'up2date', 'python', 'python-xmlrpc', 'python-popt', 'rpm')
-ORDER BY UPPER(PN.name)
-EOS
-
- my $sth = $dbh->prepare($query);
- $sth->execute($self->id);
-
- my @ret;
-
- while (my @row = $sth->fetchrow) {
- push @ret, [ @row ];
- }
-
- return @ret;
-}
-
-# returns all possible channels this server could be subscribed to,
-# as well as whether it's subscribed to each channel
-sub server_channel_tree {
- my $self = shift;
-
- my $dbh = RHN::DB->connect;
- my $query = <<EOS;
-SELECT C.id, C.name
- FROM rhnChannel C, rhnServerChannel SC
- WHERE C.id = SC.channel_id
- AND SC.server_id = ?
- AND C.parent_channel IS NULL
-EOS
-
- my $sth = $dbh->prepare($query);
- $sth->execute($self->id);
-
- my ($cid, $cname) = $sth->fetchrow;
- $sth->finish;
- if ($cid) {
- my $query = <<EOS;
-SELECT C.id,
- C.name,
- (SELECT COUNT(1) FROM rhnServerChannel WHERE server_id = ? AND channel_id = C.id),
- AC.current_members,
- AC.available_members,
- C.label
- FROM rhnAvailableChannels AC, rhnChannel C
- WHERE C.parent_channel = ?
- AND AC.org_id = ?
- AND AC.channel_id = C.id
-EOS
-
- my $sth = $dbh->prepare($query);
- $sth->execute($self->id, $cid, $self->org_id);
-
- my @ret;
- while (my ($cid, $cname, $subscribed, $current, $max, $clabel) = $sth->fetchrow) {
- push @ret, [ $cid, $cname, $subscribed, $current, $max , $clabel];
- }
-
- return ($cid, $cname, \@ret);
- }
-
- return;
-}
-
sub set_channels {
my $self = shift;
my %params = validate(@_, {user_id => 1, channels => 1});
@@ -2495,85 +2190,6 @@ EOQ
-# this is ugly. do a cert lookup based on the rhnserver
-my @checksum_fields = qw/username os_release operating_system architecture system_id type/;
-my %checksum_fields = map { $_ => 1 } @checksum_fields;
-sub lookup_by_cert {
- my $class = shift;
- my $cert_xml = shift;
-
- # massage the messy thing
- $cert_xml =~ s/<\?.*\?>//g;
- $cert_xml = "<methodResponse>$cert_xml</methodResponse>";
-
- my $decoder = new Frontier::RPC2;
- my $call = $decoder->decode($cert_xml);
- my @params = @{$call->{value}};
- my %cert = %{$call->{value}->[0]};
-
- my @provided_fields = @{$cert{fields}};
- my $id = $cert{system_id};
-
- for my $field (@provided_fields) {
- die "Invalid field '$field' provided while validating certificate"
- unless exists $checksum_fields{$field};
- }
-
- my $sid = (split /-/, $cert{system_id})[-1];
- my $s = $class->lookup(-id => $sid);
-
- my $md5 = new Digest::MD5;
-
- $md5->add($s->secret);
- for my $field (@provided_fields) {
- $md5->add($cert{$field});
- }
-
- for my $field (@provided_fields) {
- $md5->add($field);
- }
-
- my $signature = $md5->hexdigest;
-
- if ($signature eq $cert{checksum}) {
- return $s;
- }
- else {
- die "Signature mismatch: computerd sig($signature) != given cert($cert{checksum})";
- }
-}
-
-sub generate_server_certificate {
- my $self = shift;
-
- my %cert;
- $cert{username} = $self->org->find_responsible_user->login;
- $cert{os_release} = new Frontier::RPC2::String($self->release);
- $cert{operating_system} = $self->os;
- $cert{architecture} = $self->cpu_arch_name . "-redhat-linux";
- $cert{system_id} = "ID-" . $self->id;
- $cert{type} = 'REAL';
-
- my $md5 = new Digest::MD5;
- $md5->add($self->secret);
- for my $field (keys %cert) {
- $md5->add(ref $cert{$field} ? $cert{$field}->value : $cert{$field});
- }
-
- for my $field (keys %cert) {
- $md5->add($field);
- }
-
- $cert{fields} = [ keys %cert ];
- $cert{checksum} = $md5->hexdigest;
-
- my $encoder = new Frontier::RPC2;
- my $ret = $encoder->encode_call("foo", \%cert);
-
- $ret =~ s(^\s*</?method.*)()gm;
- return $ret;
-}
-
# retrieve a server given its unique id.
sub lookup {
my $class = shift;
@@ -2631,25 +2247,6 @@ sub org {
return $self->{__orgobj__};
}
-# creates a blank server object, sets its id to -1, and returns it.
-# used together with setter's and a commit call for creation of a new
-# object in the database.
-#
-# Note: between this call and the inital commit on the new server object,
-# ALL the attributes of the db object are settable.
-#
-# TODO: Figure wtf the rules for creating servers are.
-sub create_server {
-
- my $class = shift;
-
- my $server = $class->_blank_server();
- $server->{__id__} = -1;
- $server->{__newly_created__} = 1;
-
- return $server;
-}
-
#
# Delete a server given a server id
@@ -2812,30 +2409,6 @@ EOS
$dbh->commit;
}
-sub unentitled_set_count {
- my $class = shift;
- my $set = shift;
-
- my $dbh = RHN::DB->connect;
- my $query = <<EOS;
-SELECT element
- FROM rhnSet
- WHERE label = ?
- AND user_id = ?
- AND NOT EXISTS (SELECT 1 FROM rhnEntitledServers ES WHERE ES.id = element)
-EOS
-
- my $sth = $dbh->prepare($query);
- $sth->execute($set->label, $set->uid);
-
- my $ret;
- while (my ($id) = $sth->fetchrow) {
- $ret++;
- }
-
- return $ret;
-}
-
sub compatible_with_server { #returns the id and name of all servers which this server can be profiled against.
my $class = shift;
my $server_id = shift;
@@ -3042,25 +2615,6 @@ EOQ
$dbh->commit;
}
-sub random_server_id {
- my $class = shift;
-
- my $dbh = RHN::DB->connect;
- my $sth = $dbh->prepare('SELECT id FROM rhnServer');
- $sth->execute;
-
- my $sid;
- my $i = 0;
- while (my ($id) = $sth->fetchrow) {
- if (rand $i++ < 1) {
- $sid = $id;
- }
- last if $i == 10000;
- }
-
- return $sid;
-}
-
# eids of applicable errata for which the server does not have a
# pending update action
#
@@ -3158,27 +2712,6 @@ EOQ
return $first_row;
}
-sub client_capabilities {
- my $self = shift;
-
- my $dbh = RHN::DB->connect;
- my $sth = $dbh->prepare(<<EOS);
-SELECT cn.name, cc.version
- FROM rhnClientCapability CC,
- rhnClientCapabilityName CN
- WHERE server_id = :sid
- AND CN.id = CC.capability_name_id
-EOS
- $sth->execute_h(sid => $self->id);
-
- my %ret;
- while (my ($cap, $ver) = $sth->fetchrow) {
- $ret{$cap} = $ver;
- }
-
- return \%ret;
-}
-
sub client_capable {
my $self = shift;
my $cap = shift;
@@ -3283,77 +2816,6 @@ EOS
return @ret;
}
-sub latest_managed_config_revisions {
- my $self = shift;
-
- my $ds = new RHN::DataSource::Simple(-querybase => 'config_queries',
- -mode => 'system_managed_config_latest_revisions');
-
- return @{$ds->execute_query(-sid => $self->id)};
-}
-
-sub get_rhn_kickstart_package {
- my $self = shift;
- my $user_id = shift;
- my $boot_image = shift;
- my $kstree = shift;
- my @server_channels = $self->server_channels;
- my @subscribable_channels = RHN::Channel->subscribable_channels(server_id => $self->id,
- user_id => $user_id,
- base_channel_id => $self->base_channel_id);
-
- my $cid;
- my $pid;
- my $ks_rpm = 'auto-kickstart-'. $boot_image;
-
- if ("rhel_5" eq $kstree->install_type_label) {
- $ks_rpm = 'rhn-kickstart';
- }
- foreach my $c_data (@server_channels, @subscribable_channels) {
- my @pids = RHN::Channel->latest_package_equal($c_data->{ID}, $ks_rpm);
-
- if (@pids) {
- $cid = $c_data->{ID};
- $pid = $pids[0];
- last;
- }
- }
-
- return unless ($cid and $pid);
-
- $self->subscribe_to_channel($cid) unless (grep { $cid == $_->{ID} } @server_channels);
-
- return $pid;
-}
-
-sub get_latest_actions {
- my $class = shift;
- my %params = validate(@_, {server_id => 1, type => 1});
-
- my $dbh = RHN::DB->connect;
- my $sth = $dbh->prepare(<<EOQ);
-SELECT A.id, AST.name AS status,
- TO_CHAR(SA.modified, 'YYYY-MM-DD HH24:MI:SS') AS LAST_MODIFIED
- FROM rhnServerAction SA, rhnActionType AT, rhnAction A, rhnActionStatus AST
- WHERE SA.server_id = :sid
- AND A.id = SA.action_id
- AND AT.id = A.action_type
- AND AT.label = :action_type
- AND AST.id = SA.status
-ORDER BY SA.modified DESC
-EOQ
-
- $sth->execute_h(sid => $params{server_id}, action_type => $params{type});
-
- my @data;
-
- while (my $row = $sth->fetchrow_hashref) {
- push @data, $row;
- }
-
- return @data;
-}
-
sub unlock_server_set {
my $class = shift;
my $set = shift;
@@ -3392,27 +2854,6 @@ EOQ
$dbh->commit;
}
-sub lock_server {
- my $self = shift;
- my $locker = shift;
- my $reason = shift;
-
- $self->unlock_server;
-
- my $dbh = RHN::DB->connect;
- $dbh->do_h("INSERT INTO rhnServerLock (server_id, locker_id, reason) VALUES (:sid, :lid, :reason)",
- sid => $self->id, lid => ($locker ? $locker->id : undef), reason => $reason);
- $dbh->commit;
-}
-
-sub unlock_server {
- my $self = shift;
-
- my $dbh = RHN::DB->connect;
- $dbh->do_h("DELETE FROM rhnServerLock WHERE server_id = :server_id", server_id => $self->id);
- $dbh->commit;
-}
-
sub check_lock {
my $self = shift;
@@ -3436,36 +2877,6 @@ sub load_package_manifest {
}
-# The id of a version of up2date which can be installed on this system greater than 'version'.
-sub installable_up2date_version_at_least {
- my $self = shift;
- my %ver_info = @_;
-
- my $dbh = RHN::DB->connect;
- my $sth = $dbh->prepare(<<EOQ);
-SELECT P.id, PE.epoch, PE.version, PE.release
- FROM rhnPackageEVR PE, rhnPackageName PN, rhnPackage P, rhnServerNeededPackageCache SNPC
- WHERE SNPC.server_id = :sid
- AND P.id = SNPC.package_id
- AND PN.id = P.name_id
- AND PN.name = 'up2date'
- AND PE.id = P.evr_id
-EOQ
-
- $sth->execute_h(sid => $self->id);
-
- while (my ($id, $epoch, $version, $release) = $sth->fetchrow) {
- my $cmp = RHN::DB::Package->vercmp($epoch || 0, $version || 0, $release || 0,
- $ver_info{epoch} || 0, $ver_info{version} || 0, $ver_info{release} || 0);
-
- if ($cmp eq 0 or $cmp eq 1) {
- return $id;
- }
- }
-
- return;
-}
-
sub systems_subscribed_to_channel {
my $class = shift;
my %params = validate(@_, { org_id => 1, cid => 1, user_id => 1 });
@@ -3524,20 +2935,6 @@ sub proxy_hostname {
return;
}
-# The server_id of the proxy this system thinks it's connecting to
-sub proxy_sid {
- my $self = shift;
-
- my $ds = new RHN::DataSource::System(-mode => 'proxy_path_for_server');
- my $data = $ds->execute_query(-sid => $self->id);
-
- if ($data and ref $data eq 'ARRAY') {
- return $data->[0]->{ID};
- }
-
- return;
-}
-
sub packaging_type {
my $class_or_self = shift;
commit dcc793ba4178c027f57c7b4787d245df77116324
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 14:15:26 2010 +0100
Removing bunch of unused methods from RHN::DB::Errata:
add_bug
update_bug
set_keywords
affected_redhat_channels
channel_packages_in_errata
source_rpms
public_packages_overview
recent_errata_summary
get_product_types
get_errata_packages
is_locally_modified
diff --git a/web/modules/rhn/RHN/DB/Errata.pm b/web/modules/rhn/RHN/DB/Errata.pm
index 90d6bc5..89ec9e3 100644
--- a/web/modules/rhn/RHN/DB/Errata.pm
+++ b/web/modules/rhn/RHN/DB/Errata.pm
@@ -429,52 +429,6 @@ EOQ
return @ret;
}
-sub add_bug {
- my $self = shift;
- my ($id, $summary) = @_;
-
- my $dbh = RHN::DB->connect;
-
- my $bl_table = $self->table_map('rhnErrataBugList');
-
- my $query = <<EOQ;
-INSERT INTO $bl_table
- (errata_id, bug_id, summary)
-VALUES (?, ?, ?)
-EOQ
-
- my $sth = $dbh->prepare($query);
- $sth->execute($self->id, $id, $summary);
-
- $dbh->commit;
-
- return;
-}
-
-sub update_bug {
- my $self = shift;
- my ($old_id, $new_id, $summary) = @_;
-
- my $dbh = RHN::DB->connect;
-
- my $bl_table = $self->table_map('rhnErrataBugList');
-
- my $query = <<EOQ;
-UPDATE $bl_table
- SET bug_id = ?,
- summary = ?
- WHERE errata_id = ?
- AND bug_id = ?
-EOQ
-
- my $sth = $dbh->prepare($query);
- $sth->execute($new_id, $summary, $self->id, $old_id);
-
- $dbh->commit;
-
- return;
-}
-
sub keywords {
my $self = shift;
my $dbh = RHN::DB->connect;
@@ -504,44 +458,6 @@ EOQ
return @ret;
}
-sub set_keywords {
- my $self = shift;
- my @words = @_;
-
- my $dbh = RHN::DB->connect;
-
- my $kw_table = $self->table_map('rhnErrataKeyword');
-
- my $query;
- my $sth;
-
- $query = <<EOQ;
-DELETE FROM $kw_table EK
- WHERE EK.errata_id = ?
-EOQ
-
- $sth = $dbh->prepare($query);
- $sth->execute($self->id);
-
- $query = <<EOQ;
-INSERT INTO $kw_table EK
-(errata_id, keyword)
-VALUES
-(?, ?)
-EOQ
-
- $sth = $dbh->prepare($query);
-
- foreach my $word (@words) {
- $sth->execute($self->id, $word);
- }
-
- $sth->finish;
- $dbh->commit;
-
- return;
-}
-
#all channels affected by errata, pulled from rhnChannelErrata
sub channels {
my $class = shift;
@@ -610,41 +526,6 @@ EOQ
}
-# differs from the above in that this one only shows redhat channels affected by an errata...
-sub affected_redhat_channels {
- my $self = shift;
-
- my $dbh = RHN::DB->connect;
-
- my $query;
- my $sth;
-
- $query = <<EOQ;
-SELECT DISTINCT C.id, C.name
- FROM rhnChannelFamilyMembers CFM, rhnChannelFamily CF, rhnChannel C, rhnChannelErrata CE
- WHERE CE.errata_id = ?
- AND CE.channel_id = C.id
- AND C.org_id IS NULL
- AND CF.label = 'rh-public'
- AND CF.id = CFM.channel_family_id
- AND CFM.channel_id = C.id
-ORDER BY UPPER(C.name)
-EOQ
-
- $sth = $dbh->prepare($query);
- $sth->execute($self->id);
-
- my @ret;
-
- while (my @row = $sth->fetchrow) {
- push @ret, [ @row ];
- }
- $sth->finish;
-
- return @ret;
-
-}
-
# show channels which own packages referred to by this errata
sub related_channels_owned_by_org {
my $class = shift;
@@ -687,47 +568,6 @@ EOQ
return @ret;
}
-sub channel_packages_in_errata {
- my $self = shift;
- my $cid = shift;
-
- die "No channel id!" unless $cid;
-
- my $ep_table = $self->table_map('rhnErrataPackage');
-
- my $dbh = RHN::DB->connect;
- my $query;
- my $sth;
-
- $query = <<EOS;
- SELECT DISTINCT P1.name_id
- FROM rhnChannel C,
- rhnChannelPackage CP,
- rhnPackage P2,
- rhnPackage P1,
- $ep_table EP
- WHERE EP.errata_id = :eid
- AND EP.package_id = P1.id
- AND P1.name_id = P2.name_id
- AND P1.package_arch_id = P2.package_arch_id
- AND CP.package_id = P2.id
- AND C.id = CP.channel_id
- AND C.id = :cid
-EOS
-
- $sth = $dbh->prepare($query);
-
- $sth->execute_h(eid => $self->id, cid => $cid);
-
- my @result;
-
- while (my ($pid) = $sth->fetchrow) {
- push @result, $pid;
- }
-
- return @result;
-}
-
sub packages_in_errata {
my $class = shift;
my $eid = shift;
@@ -787,101 +627,6 @@ EOS
return @result;
}
-# return the srpms for the binary rpms entered in rhnPackage that
-# are associated w/ this errata
-# output is in same format as with packages_overview
-sub source_rpms {
- my $self = shift;
-
- my $dbh = RHN::DB->connect;
-
- my $query;
- my $sth;
-
- $query = <<EOS;
- SELECT PS.id, P.id, PS.id, C.label, 'src', PS.path, NULL, NULL, 'SRPMs',
- CPsum.checksum md5sum, CPSsum.checksum md5sum
- FROM rhnChannel C,
- rhnPackageSource PS,
- rhnPackage P,
- rhnChannelPackage CP,
- rhnChannelErrata CE,
- rhnErrataPackage EP
- rhnChecksum CPsum,
- rhnChecksum CPSsum
- WHERE EP.errata_id = ?
- AND CE.errata_id = ?
- AND EP.package_id = CP.package_id
- AND CE.channel_id = CP.channel_id
- AND CE.channel_id = C.id
- AND EP.package_id = P.id
- AND P.source_rpm_id = PS.source_rpm_id
- AND P.checksum_id = CPsum.id
- AND PS.checksum_id = CPSsum.id
-EOS
-
-
- $sth = $dbh->prepare($query);
- $sth->execute($self->id, $self->id);
-
- my @ret;
-
- while (my @row = $sth->fetchrow) {
- push @ret, [ @row ];
- }
- $sth->finish;
-
- return @ret;
-}
-
-# for an errata, give binary packages RHN knows about...
-sub public_packages_overview {
- my $self = shift;
-
- my $dbh = RHN::DB->connect;
-
- my $query;
- my $sth;
-
- $query = <<EOQ;
-SELECT P2.id, Csum.checksum md5sum, C.name, PN.name, PE.evr.version, PE.evr.release, PE.evr.epoch, P2.path, PA.name, C.label, CFM.channel_family_id,
- (
- SELECT CFP2.channel_family_id
- FROM rhnChannelFamilyPermissions CFP2
- WHERE CFP2.org_id IS NULL
- AND CFP2.channel_family_id = CFM.channel_family_id
- ) PUBLIC_PACKAGE
- FROM rhnChannelFamily CF, rhnChannelFamilyMembers CFM, rhnPackageArch PA, rhnPackageName PN, rhnPackageEVR PE, rhnPackage P2, rhnPackage P, rhnChannel C, rhnChannelPackage CP, rhnChannelErrata CE, rhnErrataPackage EP, rhnChecksum Csum
- WHERE EP.errata_id = ?
- AND CE.errata_id = ?
- AND EP.package_id = CP.package_id
- AND CE.channel_id = CP.channel_id
- AND CP.channel_id = C.id
- AND CP.package_id = P.id
- AND P.name_id = P2.name_id
- AND EXISTS (SELECT CP2.package_id FROM rhnChannelPackage CP2 WHERE CP2.channel_id = C.id AND CP2.package_id = P2.id)
- AND P2.name_id = PN.id
- AND P2.evr_id = PE.id
- AND P2.package_arch_id = PA.id
- AND C.id = CFM.channel_id
- AND CFM.channel_family_id = CF.id
- AND CF.org_id IS NULL
- AND P2.checksum_id = Csum.id
-EOQ
-
- $sth = $dbh->prepare($query);
- $sth->execute($self->id, $self->id);
-
- my @ret;
-
- while (my @row = $sth->fetchrow) {
- push @ret, [ @row ];
- }
- $sth->finish;
-
- return @ret;
-}
-
# shows the packages corresponding to the subscribed channels of your org.
sub rhn_files_overview {
my $self = shift;
@@ -1023,74 +768,6 @@ sub commit {
return $transaction;
}
-sub recent_errata_summary {
- my $class = shift;
- my $user = shift;
- my $count = shift;
-
- my $e_table = $class->table_map('rhnErrata');
-
- my $query = <<EOQ;
- SELECT id, advisory, advisory_type, synopsis, issue_date, update_date
- FROM $e_table
-ORDER BY update_date DESC, id
-EOQ
-
- my $dbh = RHN::DB->connect;
- my $sth = $dbh->prepare($query);
- $sth->execute;
-
- my @ret;
- while (my @row = $sth->fetchrow) {
- push @ret, [ @row, "n/a" ];
- last if @ret > $count;
- }
- $sth->finish;
-
- return @ret;
-}
-
-sub get_product_types {
- my $dbh = RHN::DB->connect;
- my $query = "SELECT DISTINCT(product) FROM rhnErrata";
-
- my $sth = $dbh->prepare($query);
- $sth->execute();
- my @res;
- my @row;
-
- push @res, [ @row ] while(@row = $sth->fetchrow);
-
- return @res;
-}
-
-sub get_errata_packages {
- my $class = shift;
- my $id = shift;
- my $pcols = shift;
- my $acols = shift || [];
-
- my $ep_table = $class->table_map('rhnErrataPackage');
-
- my $dbh = RHN::DB->connect;
-
- my $query = sprintf <<EOQ, join(", ",(map { "RP.$_"} @{$pcols}),(map { "RA.$_" } @{$acols}));
-SELECT %s
-FROM rhnPackage RP, rhnPackageArch RPA, $ep_table REP
-WHERE REP.errata_id = ? AND REP.package_id = RP.id AND RP.package_arch_id = RA.id
-EOQ
-
- my $sth = $dbh->prepare($query);
- $sth->execute($id);
-
- my @res;
- my @row;
-
- push @res, [ @row ] while(@row = $sth->fetchrow);
-
- return @res;
-}
-
sub add_errata_package {
my $class = shift;
my $errata_id = shift;
@@ -1407,28 +1084,6 @@ EOQ
return;
}
-sub is_locally_modified {
- my $class = shift;
- my $eid = shift;
-
- my $e_table = $class->table_map('rhnErrata');
-
- my $dbh = RHN::DB->connect;
- my $query =<<EOQ;
-SELECT E.locally_modified
- FROM $e_table E
- WHERE E.id = :eid
-EOQ
-
- my $sth = $dbh->prepare($query);
- $sth->execute_h(eid => $eid);
-
- my ($mod) = $sth->fetchrow;
-
- return (defined $mod) ? ($mod eq 'Y' ? 1 : 0)
- : undef;
-}
-
sub cloned_from {
my $self = shift;
commit 1c4ba541e4f04143b0572ccf14adf6e02e5ff9cb
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 14:10:36 2010 +0100
inline_template, hide_tag, and unhide_tag not referenced, removing.
diff --git a/web/modules/rhn/RHN/Postal.pm b/web/modules/rhn/RHN/Postal.pm
index 5510bba..2fdc10b 100644
--- a/web/modules/rhn/RHN/Postal.pm
+++ b/web/modules/rhn/RHN/Postal.pm
@@ -68,13 +68,6 @@ sub template {
$self->{original_body} = $body;
}
-sub inline_template {
- my $self = shift;
- my $text = shift;
-
- $self->{original_body} = $text;
-}
-
sub set_tag {
my $self = shift;
my $tag = shift;
@@ -83,20 +76,6 @@ sub set_tag {
$self->{tags}->{$tag} = $val;
}
-sub hide_tag {
- my $self = shift;
- my $tag = shift;
-
- $self->{hidden_tags}->{$tag} = 1;
-}
-
-sub unhide_tag {
- my $self = shift;
- my $tag = shift;
-
- $self->{passthrough_tags}->{$tag} = 1;
-}
-
sub subject {
my $self = shift;
my $subject = shift;
14 years, 3 months
8 commits - web/modules
by Jan Pazdziora
web/modules/rhn/RHN/DB/Notes.pm | 30 -----------------------
web/modules/rhn/RHN/DataSource.pm | 48 -------------------------------------
web/modules/rhn/RHN/Form.pm | 11 --------
web/modules/rhn/RHN/SearchTypes.pm | 46 -----------------------------------
web/modules/rhn/RHN/ServerNotes.pm | 22 ----------------
5 files changed, 157 deletions(-)
New commits:
commit 574d376acda1c69ea22dd6e08acfa1e2a4057f39
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 14:02:06 2010 +0100
Removal of add_category mad parse_mode unused, removing.
diff --git a/web/modules/rhn/RHN/SearchTypes.pm b/web/modules/rhn/RHN/SearchTypes.pm
index 3dccd1a..7b2fed5 100644
--- a/web/modules/rhn/RHN/SearchTypes.pm
+++ b/web/modules/rhn/RHN/SearchTypes.pm
@@ -120,22 +120,6 @@ sub new {
return $self;
}
-sub parse_mode {
- my $self = shift;
- my %params = @_;
-
- throw "No mode name" unless $params{-name};
- throw "No mode label" unless $params{-label};
-
- return {
- mode_choice_name => $params{-name},
- mode_label => $params{-label},
- mode_column_name => $params{-column_name} || $params{-label},
- acl => $params{-acl},
- acl_mixins => $params{-acl_mixins},
- };
-}
-
sub render_search_selectbox {
my $self = shift;
my %params = validate(@_, {pxt => 1, search_type => 0});
commit fd4c37776dac086a1f961b1134d68a49ab3ec06e
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 14:01:26 2010 +0100
set_min_search_length, valid_search_string, and add_category not referenced, removing.
diff --git a/web/modules/rhn/RHN/SearchTypes.pm b/web/modules/rhn/RHN/SearchTypes.pm
index 10d5988..3dccd1a 100644
--- a/web/modules/rhn/RHN/SearchTypes.pm
+++ b/web/modules/rhn/RHN/SearchTypes.pm
@@ -54,11 +54,6 @@ sub acl_test {
return $acl_parser->eval_acl($params{pxt}, $params{acl_string});
}
-sub set_min_search_length {
- my $self = shift;
- $self->{min_search_length} = shift;
-}
-
sub set_name {
my $self = shift;
@@ -110,12 +105,6 @@ sub label_to_column_name {
return $matches[0]->{mode_column_name};
}
-sub valid_search_string {
- my $self = shift;
- my $search_str = shift;
-
- return;
-}
package RHN::SearchType::System;
@@ -131,25 +120,6 @@ sub new {
return $self;
}
-sub add_category {
- my $self = shift;
- my %params = @_;
-
- throw "No category label" unless $params{-label};
- my $modes = $params{-modes} || [];
-
- throw "modes param should be array ref"
- unless (ref $modes eq 'ARRAY');
-
- push @{$self->{categories}},
- {
- label => $params{-label},
- modes => [ map { $self->parse_mode(%{$_}) } @{$modes} ],
- acl => $params{-acl},
- acl_mixins => $params{-acl_mixins},
- };
-}
-
sub parse_mode {
my $self = shift;
my %params = @_;
commit 2c737613371fcd98434708bfab69dbed179246c9
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 14:00:03 2010 +0100
lookup_value not used anywhere, removing.
diff --git a/web/modules/rhn/RHN/Form.pm b/web/modules/rhn/RHN/Form.pm
index 5820d39..363baff 100644
--- a/web/modules/rhn/RHN/Form.pm
+++ b/web/modules/rhn/RHN/Form.pm
@@ -180,17 +180,6 @@ sub lookup_widget {
return $self->{widgets_by_label}->{$label};
}
-sub lookup_value {
- my $self = shift;
- my $label = shift;
-
- my $widg = $self->{widgets_by_label}->{$label};
-
- return undef unless $widg;
-
- return $widg->value;
-}
-
sub clone_widgets {
my $self = shift;
commit e4bfa0642b175389611b0f41805da26e8004417d
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 13:59:03 2010 +0100
Removal of server_notes made notes_by_col unused, removing.
diff --git a/web/modules/rhn/RHN/DB/Notes.pm b/web/modules/rhn/RHN/DB/Notes.pm
index 97df80f..de55db0 100644
--- a/web/modules/rhn/RHN/DB/Notes.pm
+++ b/web/modules/rhn/RHN/DB/Notes.pm
@@ -156,36 +156,6 @@ sub commit {
delete $self->{":modified:"};
}
-# arg1 = column name
-# arg2 = column value
-# arg3 = columns wanted
-# return list of rows where column name has column value
-sub notes_by_col {
- my $self = shift;
- my $col = shift;
- my $colval = shift;
- my @cols = @_;
-
- my $dbh = RHN::DB->connect;
- my $query = sprintf <<EOS, join(", ", map { "T.$_" } @cols),$self->table,$col;
-SELECT %s
-FROM %s T
-WHERE T.%s = ?
-ORDER BY T.created
-EOS
-
- my $sth = $dbh->prepare($query);
- $sth->execute($colval);
-
- my @ret;
-
- while (my (@row) = $sth->fetchrow) {
- push @ret, [ @row ];
- }
-
- return @ret;
-}
-
#
# Generate getter/setters
#
commit 3345f8ca7854e0455b4a308f6a05a18bb4a07961
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 13:57:28 2010 +0100
lookup_note and server_notes are not used anywhere, removing.
diff --git a/web/modules/rhn/RHN/ServerNotes.pm b/web/modules/rhn/RHN/ServerNotes.pm
index 0877214..0929ceb 100644
--- a/web/modules/rhn/RHN/ServerNotes.pm
+++ b/web/modules/rhn/RHN/ServerNotes.pm
@@ -37,33 +37,11 @@ sub lookup {
}
}
-sub lookup_note {
- my $class = shift;
-
- warn "deprecated use of $class->lookup_foo from (" . join(', ', caller) . "). Using $class->lookup instead\n";
-
- return $class->lookup(@_);
-}
-
sub create {
my $class = shift;
return RHN::DB::ServerNotes->create_note(@_);
}
-sub server_notes {
- my $self = shift;
-
- my $id;
- if(ref $self) {
- $id = $self->id;
- }
- else {
- $id = shift;
- }
-
- return RHN::DB::ServerNotes->notes_by_col("server_id",$id,@_);
-}
-
1;
commit c21d07e85f8eeaaf1e160ebecc1ecffb927280e8
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 13:43:38 2010 +0100
available_datasource_files not used, removing as dead code.
diff --git a/web/modules/rhn/RHN/DataSource.pm b/web/modules/rhn/RHN/DataSource.pm
index b24dbc7..569fc81 100644
--- a/web/modules/rhn/RHN/DataSource.pm
+++ b/web/modules/rhn/RHN/DataSource.pm
@@ -255,35 +255,4 @@ sub collate_data {
return $data;
}
-# static method to return a list of all the available datasources.
-# used by test suite and by query performance metric script
-
-sub available_datasource_files {
- my $class = shift;
- my @extra_entries = @_;
-
- my $core_dir = $INC{"RHN/DB/DataSource.pm"};
- $core_dir =~ s(\.pm$)(/xml);
-
- my @ret;
-
- for my $entry ($core_dir, @extra_entries) {
- my @files;
-
- if (-d $entry) {
- my $dir = $entry;
- opendir DIR, $dir or die "opendir $dir: $!";
- push @files, grep { -f "$dir/$_" } readdir DIR;
- closedir DIR;
- }
- else {
- push @files, $entry;
- }
-
- push @ret, map { s(\.xml$)(); $_ } grep { m(\.xml$) } @files;
- }
-
- return sort @ret;
-}
-
1;
commit c9dfef03e7b8d185f26a9b175b02ed4484fc18b8
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 13:38:44 2010 +0100
get_query_params not used, removing as dead code.
diff --git a/web/modules/rhn/RHN/DataSource.pm b/web/modules/rhn/RHN/DataSource.pm
index 28d8439..b24dbc7 100644
--- a/web/modules/rhn/RHN/DataSource.pm
+++ b/web/modules/rhn/RHN/DataSource.pm
@@ -103,14 +103,6 @@ sub get_query_body {
return $mode_data->{query}->{body};
}
-sub get_query_params {
- my $self = shift;
-
- my $mode_data = $self->lookup_mode_data;
-
- return $mode_data->{query}->{params};
-}
-
sub execute_query {
my $self = shift;
my %params = @_;
commit 4d7720d80e58ec533f82e3932db7bf7ef9177962
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 13:35:33 2010 +0100
execute_one not used, removing as dead code.
diff --git a/web/modules/rhn/RHN/DataSource.pm b/web/modules/rhn/RHN/DataSource.pm
index 846f581..28d8439 100644
--- a/web/modules/rhn/RHN/DataSource.pm
+++ b/web/modules/rhn/RHN/DataSource.pm
@@ -96,15 +96,6 @@ sub required_params {
return @uniq_params;
}
-sub execute_one {
- my $self = shift;
-
- my $ret = $self->execute_query(@_);
- throw "Too many rows returned from query (mode $self->{mode})" if @$ret > 1;
-
- return @$ret > 0 ? $ret->[0] : ();
-}
-
sub get_query_body {
my $self = shift;
14 years, 3 months
java/code
by Tomas Lestach
java/code/webapp/WEB-INF/pages/channel/channeldetail.jsp | 11 +++++++++++
1 file changed, 11 insertions(+)
New commits:
commit 7367e84742540e26d9c6cb19d53f8ca724f6cdf6
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Tue Jan 5 13:41:28 2010 +0100
adding "Yum Repository Checksum Type" info to the channels/ChannelDetail.do page
diff --git a/java/code/webapp/WEB-INF/pages/channel/channeldetail.jsp b/java/code/webapp/WEB-INF/pages/channel/channeldetail.jsp
index 4733121..b4038cd 100644
--- a/java/code/webapp/WEB-INF/pages/channel/channeldetail.jsp
+++ b/java/code/webapp/WEB-INF/pages/channel/channeldetail.jsp
@@ -48,6 +48,17 @@
</td>
</tr>
<tr>
+ <th><bean:message key="channel.edit.jsp.checksum"/>:</th>
+ <td>
+ <c:if test="${empty channel.checksumType}">
+ <span class="no-details">(none)</span>
+ </c:if>
+ <c:if test="${!empty channel.checksumType}">
+ <c:out value="${channel.checksumType}" />
+ </c:if>
+ </td>
+ </tr>
+ <tr>
<th><bean:message key="packagelist.jsp.packagearch"/>:</th>
<td><c:out value="${channel.channelArch.name}" /></td>
</tr>
14 years, 3 months
5 commits - web/modules web/spacewalk-web.spec
by Jan Pazdziora
web/modules/pxt/PXT/ApacheHandler.pm | 1
web/modules/rhn/RHN/API/Exception.pm | 88 ----------
web/modules/rhn/RHN/API/ExceptionBox.pm | 83 ----------
web/modules/rhn/RHN/API/Interface.pm | 76 ---------
web/modules/rhn/RHN/API/Method.pm | 205 -------------------------
web/modules/rhn/RHN/API/Parser.pm | 159 -------------------
web/modules/rhn/RHN/API/TypeHandler.pm | 70 --------
web/modules/rhn/RHN/API/Types.pm | 262 --------------------------------
web/modules/rhn/RHN/DB/Server.pm | 5
web/modules/rhn/RHN/Exception.pm | 1
web/spacewalk-web.spec | 1
11 files changed, 2 insertions(+), 949 deletions(-)
New commits:
commit 42b52fdf4826a7991bcecbb032e9157e1e2b992a
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 13:30:37 2010 +0100
RHN::API::* namespace is not used from anywhere now (except RHN::API::* itself), removing.
diff --git a/web/modules/rhn/RHN/API/Exception.pm b/web/modules/rhn/RHN/API/Exception.pm
deleted file mode 100644
index 29942b5..0000000
--- a/web/modules/rhn/RHN/API/Exception.pm
+++ /dev/null
@@ -1,88 +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 RHN::API::Exception;
-
-use RHN::API::ExceptionBox;
-
-our @ISA = qw/RHN::Exception/;
-
-our $global_exception_box;
-
-sub exception_box {
- my $class = shift;
-
- $global_exception_box ||= new RHN::API::ExceptionBox;
-
- return $global_exception_box;
-}
-
-sub throw_named {
- my $class = shift;
- my $string = shift;
- my @extra = @_;
-
- my $box = $class->exception_box;
-
- my $exception = $class->new;
-
- # so, er have a named exception. huzzah! look it up. if it fails,
- # mark it slightly different than arbitrary unhandled exception.
-
- my $exc = $box->lookup_by_label($string);
- if ($exc) {
- $exception->{fault_code} = $exc->{code};
- $exception->{fault_label} = $exc->{label};
- $exception->{fault_text} = "Named exception: (" . $exc->{label} . ")";
- if ($exc->{description}) {
- $exception->{fault_text} .= "\n\n" . $exc->{description};
- }
- }
- else {
- $exc = $box->lookup_by_label('unhandled_named_exception');
- $exception->{fault_code} = $exc->{code};
- $exception->{fault_label} = $exc->{label};
- $exception->{fault_text} = "Unhandled exception '$string' (" . ($exc->{label} || '') . ")";
- }
-
- if (@extra) {
- $exception->{fault_text} .= "\n" . join("\n", @extra);
- }
-
- $exception->SUPER::throw;
-}
-
-sub is_rhn_exception {
- my $self = shift;
- my $label = shift;
-
- return ($self->{fault_label} eq $label) ? 1 : 0;
-}
-
-sub fault_code {
- return (shift)->{fault_code};
-}
-
-sub fault_text {
- return (shift)->{fault_text};
-}
-
-# can it serialize into an xmlrpc fault? why, yes, yes we can.
-sub serialize_xmlrpc_fault {
- return 1;
-}
-
-1;
diff --git a/web/modules/rhn/RHN/API/ExceptionBox.pm b/web/modules/rhn/RHN/API/ExceptionBox.pm
deleted file mode 100644
index ba49cdc..0000000
--- a/web/modules/rhn/RHN/API/ExceptionBox.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 RHN::API::ExceptionBox;
-
-sub new {
- my $class = shift;
-
- my $self = bless { label_map => {}, code_map => {}, exceptions => [] }, $class;
-
- return $self;
-}
-
-sub add_exception {
- my $self = shift;
- my $label = shift;
- my $code = shift;
- my $description = shift;
-
- my $found;
- for my $current ($self->lookup_by_label($label), $self->lookup_by_code($code)) {
- # already exist? if so, and if it is different, bomb out; otherwise return silent success
- if ($current) {
- $found++;
- if ($current->{label} ne $label or $current->{code} != $code) {
- die "Exception ($label, $code) already in exception box as ($current->{label}, $current->{code})";
- }
- }
- }
-
- # found one, and it was consistent...
- return if $found;
-
- # the index will be the next entry; since scalar(@a) == $#a + 1, we
- # can just set it like this, then push
-
- my $index = @{$self->{exceptions}};
- push @{$self->{exceptions}}, { code => $code, label => $label, index => $index, description => $description };
- $self->{label_map}->{$label} = $self->{code_map}->{$code} = $index;
-}
-
-sub lookup_by_label {
- my $self = shift;
- my $label = shift;
-
- my $found_idx = $self->{label_map}->{$label};
-
- return undef unless $found_idx;
-
- return $self->{exceptions}->[$found_idx];
-}
-
-sub lookup_by_code {
- my $self = shift;
- my $code = shift;
-
- my $found_idx = $self->{code_map}->{$code};
-
- return undef unless $found_idx;
-
- return $self->{exceptions}->[$found_idx];
-}
-
-sub is_empty {
- my $self = shift;
-
- return (@{$self->{exceptions}} ? 0 : 1);
-}
-
-1;
diff --git a/web/modules/rhn/RHN/API/Interface.pm b/web/modules/rhn/RHN/API/Interface.pm
deleted file mode 100644
index 9bdd83f..0000000
--- a/web/modules/rhn/RHN/API/Interface.pm
+++ /dev/null
@@ -1,76 +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 RHN::API::Interface;
-
-use RHN::API::Method;
-use RHN::API::Exception;
-use RHN::API::TypeHandler;
-use Carp;
-
-# pretty simple class. mainly a wrapper for methods. later will
-# include more data about type handlers, acls, etc
-
-sub new {
- my $class = shift;
- my $prefix = shift;
-
- my $self = bless { }, $class;
- $self->{type_handler} = new RHN::API::TypeHandler;
- $self->{prefix} = $prefix || '';
-
- return $self;
-}
-
-sub prefix {
- my $self = shift;
-
- return $self->{prefix};
-}
-
-sub add_method {
- my $self = shift;
- my $method = shift;
-
- $self->{methods}->{$method->name} = $method;
-}
-
-sub method_list {
- my $self = shift;
-
- return sort { $a->name cmp $b->name } values %{$self->{methods}};
-}
-
-sub find_method {
- my $self = shift;
- my $method_name = shift;
-
- my $ret = $self->{methods}->{$method_name};
- RHN::API::Exception->throw_named("method_not_found") unless $ret;
-
- return $ret;
-}
-
-sub invoke_method {
- my $self = shift;
- my $method_name = shift;
-
- my $method = $self->find_method($method_name);
-
- $method->invoke_method($self->{type_handler}, @_);
-}
-
-1;
diff --git a/web/modules/rhn/RHN/API/Method.pm b/web/modules/rhn/RHN/API/Method.pm
deleted file mode 100644
index 75b221b..0000000
--- a/web/modules/rhn/RHN/API/Method.pm
+++ /dev/null
@@ -1,205 +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 RHN::API::Method;
-
-use RHN::Cleansers;
-use RHN::SimpleStruct;
-our @ISA = qw/RHN::SimpleStruct/;
-our @simple_struct_fields = (qw/name min_params max_params version params required_params/,
- qw/description return_type return_kids handler sla/);
-
-use Carp;
-use Params::Validate;
-Params::Validate::validation_options(strip_leading => "-");
-
-sub new {
- my $class = shift;
- my $name = shift;
- my $version = shift;
-
- my $self = $class->SUPER::new();
- $self->name($name);
- $self->version($version);
- $self->min_params(0);
- $self->max_params(0);
- $self->params([]);
-
- return $self;
-}
-
-# used when building the method; add a new param to the list
-sub push_param {
- my $self = shift;
- my %params = validate(@_, { name => 1,
- type => 1,
- kids => 0,
- default => 0,
- required => 0,
- slurp => 0,
- mangle => 0 });
-
- my $self_params = $self->params;
-
- # slurp params, if present, must be the last param
- if ($self_params->[-1] and $self_params->[-1]->{slurp}) {
- die "attempt to add additional parameter after slurping parameter";
- }
-
- # once you declare a default param, you cannot have non-default params
- if ($self_params->[-1] and $self_params->[-1]->{default} and not $params{default}) {
- die "attempt to add parameter with non-default after parameter with default";
- }
-
- # can't have a required param after an optional one
- if ($self_params->[-1] and not $self_params->[-1]->{required} and $params{required}) {
- die "attempt to add required parameter after optional parameter";
- }
-
- # adjust counts now
- $self->min_params($self->min_params + 1) if $params{required};
- $self->max_params($self->max_params + 1);
- $self->max_params(undef) if $params{slurp};
-
- push @{$self_params}, \%params;
-}
-
-# set the handler for a method, optionally loading class as necessary
-sub set_handler {
- my $self = shift;
- my $handler = shift;
-
- if (ref $handler and ref $handler eq 'CODE') {
- $self->handler($handler);
- }
- else {
- my $class = $handler;
- my $method = shift;
-
- my $module = "$class.pm";
- $module =~ s/::/\//g;
- require $module;
-
- # 'can' returns a coderef to the func in question, if found, handily enough
- $self->handler($class->can($method));
- die "Unable to find method of name '$method' in class '$class'" unless $self->handler;
- }
-}
-
-# invoke a method. performs parameter count and type checking, as
-# well as return type checking
-
-sub invoke_method {
- my $self = shift;
- my $type_handler = shift;
- my @values = @_;
-
- # make sure we have enough params
- if (defined $self->min_params and scalar @values < $self->min_params) {
- RHN::API::Exception->throw_named("method_too_few_params");
- }
-
- if (defined $self->max_params and scalar @values > $self->max_params) {
- RHN::API::Exception->throw_named("method_too_many_params");
- }
-
- # okay. build the actual param list for the method in question...
- my @actual_values;
- my @actual_params;
-
- my %typemap;
- my $self_params = $self->params;
-
- for my $i (0 .. $#{$self_params}) {
- my $param = $self_params->[$i];
-
- # have we hit the slurp param? if so, consume the rest, end loop now
- if ($param->{slurp}) {
- push @actual_values, @values;
- push @actual_params, ($param) x @values;
- last;
- }
-
- # not slurp, okay, are there any supplied values left?
- if (@values) {
- push @actual_values, shift @values;
- push @actual_params, $param;
- }
- # okay, no supplied values left, grab the default for this position
- elsif (exists $param->{default}) {
- push @actual_values, $param->{default};
- push @actual_params, $param;
- }
- # this shouldn't hit since we verified the counts at the start of the func
- else {
- croak "Ran out of parameters?";
- }
- }
-
- my $active_user;
- my $perform_cleansing = 0;
- if ($actual_params[0] and $actual_params[0]->{name} eq 'session') {
- my $session = RHN::Session->load($actual_values[0]);
- RHN::API::Exception->throw_named("invalid_session") unless $session->uid;
-
- $active_user = RHN::User->lookup(-id => $session->uid);
- $perform_cleansing = 1;
- }
-
- # whew okay, now the easy part, validate and mangle params
- for my $i (0 .. $#actual_values) {
-
- my $skip = ((($i + 1) > $self->min_params) and (not defined $actual_values[$i])) ? 1 : 0;
-
- if ((not $skip) and (not $type_handler->validate_type($actual_params[$i]->{type}, $actual_values[$i]))) {
- RHN::API::Exception->throw_named("method_invalid_param", $i, $actual_params[$i]->{type});
- }
-
- if ($perform_cleansing) {
- my $pass = RHN::Cleansers->check_param($active_user,
- $actual_params[$i]->{name},
- $actual_values[$i]);
- if (not defined $pass) {
- # noop; undef means no cleanser
- }
- elsif ($pass) {
- # yep, we pass
- }
- else {
- RHN::API::Exception->throw_named("permission_check_failure");
- }
- }
-
- $actual_values[$i] = $type_handler->mangle_type($actual_params[$i]->{type},
- $actual_params[$i]->{mangle},
- $actual_values[$i])
- if $actual_params[$i]->{mangle};
- }
-
- # call it
- my $result = $self->handler->(@actual_values);
- my $return_type = $self->return_type;
-
- # validate return type
- if (not $type_handler->validate_type($return_type, $result)) {
- croak sprintf("Return type of '%s' mismatch: $result is not '$return_type'", $self->name);;
- }
-
- # and we're done!
- return $result;
-}
-
-1;
diff --git a/web/modules/rhn/RHN/API/Parser.pm b/web/modules/rhn/RHN/API/Parser.pm
deleted file mode 100644
index 2019713..0000000
--- a/web/modules/rhn/RHN/API/Parser.pm
+++ /dev/null
@@ -1,99 +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 RHN::API::Parser;
-
-use RHN::API::Method;
-use RHN::API::TypeHandler;
-
-use Carp;
-use XML::LibXML;
-
-sub helper_find_nodes {
- my $node = shift;
- my $node_name = shift;
- my $min = shift;
- my $max = shift;
-
- my @nodes = grep { $_->isa("XML::LibXML::Element") and $_->nodeName eq $node_name } $node->childNodes;
- if (defined $min and scalar @nodes < $min) {
- die "Too few nodes of type '$node_name' found in node " . $node->toString(1);
- }
- if (defined $max and scalar @nodes > $max) {
- die "Too many nodes of type '$node_name' found in node " . $node->toString(1);
- }
-
- return @nodes;
-}
-
-sub process_method {
- my $class = shift;
- my $xml_node = shift;
-
- my $method_name = $xml_node->getAttribute("name");
- die "Invalid method name '$method_name' -- must not contain namespace information" if $method_name =~ /[.]/;
-
- my $method_version = $xml_node->getAttribute("version") || '0.1';
- my $method_sla = $xml_node->getAttribute("sla") || 'experimental';
-
- my $method = new RHN::API::Method $method_name, $method_version;
- $method->sla($method_sla);
-
- my %allowed_child_nodes = map { $_ => 1 } qw/description handler param return variant/;
-
- for my $node (grep { $_->isa("XML::LibXML::Element") } $xml_node->childNodes) {
- if (not exists $allowed_child_nodes{$node->nodeName}) {
- die "invalid rhn-method child node: " . $node->toString;
- }
- }
-
- for my $param_node (helper_find_nodes($xml_node, 'param')) {
- my %attrs = map { $_ => $param_node->getAttribute($_) } qw/name type required default slurp mangle/;
-
- # FIXME: tie the information, not the whole node...
- my @kids = grep { $_->isa("XML::LibXML::Element") } $param_node->childNodes();
- $attrs{kids} = \@kids if @kids;
-
- $method->push_param(%attrs);
- }
-
- my ($return_node) = helper_find_nodes($xml_node, 'return', 1, 1);
- $method->return_type($return_node->getAttribute('type'));
-
- my @return_kids = grep { $_->isa("XML::LibXML::Element") } $return_node->childNodes();
- if (@return_kids) {
- # save 'em for rendering help...
- # FIXME: tie the information, not the whole node...
- $method->return_kids(\@return_kids);
- }
-
- my ($handler_node) = helper_find_nodes($xml_node, 'handler', 1, 1);
-
- # use $method's name if the method attribute is not set
- $method->set_handler($handler_node->getAttribute('class'),
- $handler_node->getAttribute('method') || $method->name)
- unless $handler_node->getAttribute('stub');
-
-
- my ($desc_node) = helper_find_nodes($xml_node, 'description', 0, 1);
- if ($desc_node) {
- $method->description($desc_node->textContent);
- }
-
- return $method;
-}
-
-1;
diff --git a/web/modules/rhn/RHN/API/TypeHandler.pm b/web/modules/rhn/RHN/API/TypeHandler.pm
deleted file mode 100644
index 758b709..0000000
--- a/web/modules/rhn/RHN/API/TypeHandler.pm
+++ /dev/null
@@ -1,70 +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 RHN::API::TypeHandler;
-
-use RHN::API::Types;
-use Carp;
-
-sub new {
- my $class = shift;
-
- my $self = bless { }, $class;
- RHN::API::Types->register_default_types($self);
-
- return $self;
-}
-
-sub register_type {
- my $self = shift;
- my $type = shift;
- my $func = shift;
-
- $self->{types}->{$type} = $func;
-}
-
-sub register_mangler {
- my $self = shift;
- my $type = shift;
- my $mangler = shift;
- my $func = shift;
-
- $self->{type_manglers}->{$type}->{$mangler} = $func;
-}
-
-sub mangle_type {
- my $self = shift;
- my $type = shift;
- my $mangler = shift;
- my $value = shift;
-
- my $mangle_func = $self->{generic_manglers}->{$mangler} || $self->{type_manglers}->{$type}->{$mangler};
- croak "No mangler '$mangler' for type '$type'" unless $mangle_func;
-
- return $mangle_func->($value);
-}
-
-sub validate_type {
- my $self = shift;
- my $type = shift;
- my $value = shift;
-
- croak "No registered API type '$type'" unless exists $self->{types}->{$type};
-
- return $self->{types}->{$type}->($value);
-}
-
-1;
diff --git a/web/modules/rhn/RHN/API/Types.pm b/web/modules/rhn/RHN/API/Types.pm
deleted file mode 100644
index c427370..0000000
--- a/web/modules/rhn/RHN/API/Types.pm
+++ /dev/null
@@ -1,262 +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 RHN::API::Types;
-
-use RHN::Session;
-use RHN::Server;
-
-use RHN::Exception qw/throw/;
-
-sub register_default_types {
- my $class = shift;
- my $api = shift;
-
- $api->register_type(id => \&RHN::API::Types::validate_id);
-
- $api->register_type(string => \&RHN::API::Types::validate_string);
- $api->register_type(session => \&RHN::API::Types::validate_session);
- $api->register_type(integer => \&RHN::API::Types::validate_integer);
- $api->register_type(double => \&RHN::API::Types::validate_double);
- $api->register_type(boolean => \&RHN::API::Types::validate_boolean);
- $api->register_type(date => \&RHN::API::Types::validate_date);
-
- $api->register_type(hash => \&RHN::API::Types::validate_hash);
- $api->register_type(list => \&RHN::API::Types::validate_list);
-
- $api->register_type(user => \&RHN::API::Types::validate_user);
- $api->register_type(system => \&RHN::API::Types::validate_system);
-
- $api->register_mangler("session", "session_user", \&RHN::API::Types::session_user_mangler);
- $api->register_mangler("id", "objectify_system", \&RHN::API::Types::objectify_system_mangler);
- $api->register_mangler("string", "objectify_errata", \&RHN::API::Types::objectify_errata_mangler);
- $api->register_mangler("id", "objectify_system_group", \&RHN::API::Types::objectify_system_group_mangler);
- $api->register_mangler("id", "objectify_system_snapshot", \&RHN::API::Types::objectify_system_snapshot_mangler);
- $api->register_mangler("id", "objectify_stored_profile", \&RHN::API::Types::objectify_stored_profile_mangler);
- $api->register_mangler("id", "objectify_kickstart_profile", \&RHN::API::Types::objectify_kickstart_profile_mangler);
- $api->register_mangler("string", "objectify_activation_key", \&RHN::API::Types::objectify_activation_key_mangler);
- $api->register_mangler("string", "objectify_system_id", \&RHN::API::Types::objectify_systemid_mangler);
- $api->register_mangler("string", "objectify_login", \&RHN::API::Types::objectify_login_mangler);
- $api->register_mangler("string", "objectify_channel", \&RHN::API::Types::objectify_channel_mangler);
- $api->register_mangler("id", "objectify_package", \&RHN::API::Types::objectify_package_mangler);
-}
-
-sub validate_id {
- return validate_integer(@_);
-}
-
-sub validate_session {
- my $value = shift;
-
- return $value =~ /^[0-9a-f]+x[0-9a-f]+$/;
-}
-
-sub validate_integer {
- my $value = shift;
-
- # FIXME: insufficient check for <i4 /> ?
- return $value =~ /^\d+$/;
-}
-
-sub validate_double {
- my $value = shift;
-
- # FIXME: insufficient check for <double /> ?
- return $value =~ /^\d+\.?\d*$/;
-}
-
-sub validate_string {
- return 1;
-}
-
-sub validate_boolean {
- my $value = shift;
-
- throw "no value?" unless defined $value;
-
- return 1 if defined $value and ($value == 0 or $value == 1);
-
- return 0;
-}
-
-sub validate_date {
- my $value = shift;
-
- return $value =~ /^\d\d\d\d-\d\d-\d\d [0-2][0-9]\:[0-5][0-9]\:[0-5][0-9]$/;
-}
-
-sub validate_hash {
- my $value = shift;
-
- return 1 if ref($value) eq 'HASH';
-
- return 0;
-}
-
-sub validate_list {
- my $value = shift;
-
- return 1 if ref($value) eq 'ARRAY';
-
- return 0;
-}
-
-sub validate_user {
- my $value = shift;
-}
-
-sub validate_system {
- my $value = shift;
-}
-
-sub session_user_mangler {
- my $value = shift;
-
- my $session = RHN::Session->load($value);
- RHN::API::Exception->throw_named("invalid_session") unless $session->uid;
-
- return RHN::User->lookup(-id => $session->uid);
-}
-
-sub objectify_system_mangler {
- my $value = shift;
- my $system;
- eval {
- $system = RHN::Server->lookup(-id => $value);
- };
- if ($@) {
- my $E = $@;
-
- if (ref $E and $E->is_rhn_exception('server_does_not_exist')) {
- RHN::API::Exception->throw_named("no_such_system");
- }
- }
-
- return $system;
-}
-
-sub objectify_package_mangler {
- my $value = shift;
- my $package;
-
- eval {
- $package = RHN::Package->lookup(-id => $value);
- };
- if ($@) {
- RHN::API::Exception->throw_named("no_such_package");
- }
-
- return $package;
-}
-
-sub objectify_system_group_mangler {
- my $value = shift;
-
- my $group = RHN::ServerGroup->lookup($value);
- RHN::API::Exception->throw_named("no_such_system_group") unless $group;
-
- return $group;
-}
-
-sub objectify_system_snapshot_mangler {
- my $value = shift;
-
- my $snapshot = RHN::SystemSnapshot->lookup_snapshot($value);
- RHN::API::Exception->throw_named("no_such_system_snapshot") unless $snapshot;
-
- return $snapshot;
-}
-
-sub objectify_stored_profile_mangler {
- my $value = shift;
-
- my $profile = RHN::Profile->lookup($value);
- RHN::API::Exception->throw_named("no_such_stored_profile") unless $profile;
-
- return $profile;
-}
-
-sub objectify_kickstart_profile_mangler {
- my $value = shift;
-
- my $ks_profile = RHN::Kickstart->lookup(-id => $value);
- RHN::API::Exception->throw_named("no_such_kickstart_profile") unless $ks_profile;
-
- return $ks_profile;
-}
-
-sub objectify_activation_key_mangler {
- my $value = shift;
-
- my $key = RHN::Token->lookup_token(-token => $value);
- RHN::API::Exception->throw_named("no_such_activation_key") unless $key;
-
- return $key;
-}
-
-sub objectify_systemid_mangler {
- my $value = shift;
-
- my $system;
- eval {
- $system = RHN::Server->lookup_by_cert($value);
- };
- if ($@) {
- my $E = $@;
- if (ref $E and $E->is_rhn_exception('server_does_not_exist')) {
- RHN::API::Exception->throw_named("no_such_system");
- }
- else {
- RHN::API::Exception->throw_named("problem_parsing_cert");
- }
- }
-
- return $system;
-}
-
-sub objectify_login_mangler {
- my $value = shift;
-
- my $user = RHN::User->lookup(-username => $value);
- RHN::API::Exception->throw_named("no_such_user") unless $user;
-
- return $user;
-}
-
-sub objectify_errata_mangler {
- my $value = shift;
-
- my ($type, $version) = split /[-]/, $value;
- my @errata = RHN::Errata->find_by_advisory(-type => $type, -version => $version);
-
- RHN::API::Exception->throw_named("no_such_errata") unless @errata;
-
- return RHN::Errata->lookup(-id => $errata[0][0]);
-}
-
-
-sub objectify_channel_mangler {
- my $value = shift;
-
- my $id = RHN::Channel->channel_id_by_label($value);
- my $channel = RHN::Channel->lookup(-id => $id);
- RHN::API::Exception->throw_named("no_such_channel") unless $channel;
-
- return $channel;
-}
-
-
-1;
diff --git a/web/modules/rhn/RHN/Exception.pm b/web/modules/rhn/RHN/Exception.pm
index 9d5af23..f6a711f 100644
--- a/web/modules/rhn/RHN/Exception.pm
+++ b/web/modules/rhn/RHN/Exception.pm
@@ -78,7 +78,6 @@ sub is_rhn_exception {
return $self->{-text} =~ /\(([^.]+\.)?$label\)/;
}
-# overloaded by RHN::API::Exception
sub fault_text {
my $self = shift;
diff --git a/web/spacewalk-web.spec b/web/spacewalk-web.spec
index 55d147b..4710799 100644
--- a/web/spacewalk-web.spec
+++ b/web/spacewalk-web.spec
@@ -141,7 +141,6 @@ rm -rf $RPM_BUILD_ROOT
%dir %{perl_vendorlib}/RHN
%dir %{perl_vendorlib}/PXT
%{perl_vendorlib}/RHN.pm
-%{perl_vendorlib}/RHN/API/
%{perl_vendorlib}/RHN/Access.pm
%{perl_vendorlib}/RHN/Access/
%{perl_vendorlib}/RHN/Action.pm
commit 1917ce0eeaf39b553406dbb08e0ec54a018d71fb
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 13:28:36 2010 +0100
Since the RHN::API::ExceptionBox is empty, calling RHN::API::Exception->throw_named does not bring any benefit, just call RHN::Exception::throw directly.
diff --git a/web/modules/rhn/RHN/DB/Server.pm b/web/modules/rhn/RHN/DB/Server.pm
index 498573d..fb6c53e 100644
--- a/web/modules/rhn/RHN/DB/Server.pm
+++ b/web/modules/rhn/RHN/DB/Server.pm
@@ -51,7 +51,6 @@ use Carp;
use RHN::Utils;
use RHN::Exception qw/throw/;
-use RHN::API::Exception;
# fields in the rhnServer table
@@ -666,7 +665,7 @@ EOQ
my $proxy_channel_info = $sth->fetchrow_hashref;
$sth->finish;
- RHN::API::Exception->throw_named("proxy_no_proxy_child_channel") unless $proxy_channel_info;
+ throw ("proxy_no_proxy_child_channel") unless $proxy_channel_info;
return $proxy_channel_info;
}
@@ -683,7 +682,7 @@ sub activate_proxy {
my $sth;
if ($self->is_satellite()) {
- RHN::API::Exception->throw_named("proxy_system_is_satellite");
+ throw("proxy_system_is_satellite");
}
$query = <<EOQ;
commit 80dcff32a174aaab4560d1823ccd593d859ff729
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 13:21:59 2010 +0100
Since we have removed RHN::API::Parser->parse_exceptions, use'ing RHN::API::Parser is not needed.
diff --git a/web/modules/pxt/PXT/ApacheHandler.pm b/web/modules/pxt/PXT/ApacheHandler.pm
index c72171c..03f2f8c 100644
--- a/web/modules/pxt/PXT/ApacheHandler.pm
+++ b/web/modules/pxt/PXT/ApacheHandler.pm
@@ -43,7 +43,6 @@ use PXT::SoapRequest;
use PXT::XmlrpcRequest;
use RHN::Session;
use RHN::Exception;
-use RHN::API::Parser;
use RHN::I18N;
use RHN::Mail;
commit 2c7074de1d4946ec92f6c2d8d677303c4081cb6e
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 13:02:54 2010 +0100
parse_interface is not used anywhere, removing.
diff --git a/web/modules/rhn/RHN/API/Parser.pm b/web/modules/rhn/RHN/API/Parser.pm
index d4b8b0c..2019713 100644
--- a/web/modules/rhn/RHN/API/Parser.pm
+++ b/web/modules/rhn/RHN/API/Parser.pm
@@ -22,32 +22,6 @@ use RHN::API::TypeHandler;
use Carp;
use XML::LibXML;
-sub parse_interface {
- my $class = shift;
- my $method_prefix = shift;
- my $file = shift;
-
- my $parser = new XML::LibXML;
- $parser->keep_blanks(0);
- $parser->expand_xinclude(1);
- my $doc = $parser->parse_file($file);
- my $root = $doc->getDocumentElement;
-
- my $iface = new RHN::API::Interface $method_prefix;
-
- for my $xml_node (grep { $_->isa("XML::LibXML::Element") } $root->childNodes) {
- if ($xml_node->nodeName ne 'rhn-method') {
- warn "non-rhn-method node: " . $xml_node->toString;
- next;
- }
-
- my $method = $class->process_method($xml_node);
- $iface->add_method($method);
- }
-
- return $iface;
-}
-
sub helper_find_nodes {
my $node = shift;
my $node_name = shift;
commit 3c06de02012e9c5df7f0d9d1450c793f6858e6f3
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 13:01:41 2010 +0100
Removal from PXT::ApacheHandler makes parse_exceptions unused as well.
diff --git a/web/modules/rhn/RHN/API/Parser.pm b/web/modules/rhn/RHN/API/Parser.pm
index b47cd57..d4b8b0c 100644
--- a/web/modules/rhn/RHN/API/Parser.pm
+++ b/web/modules/rhn/RHN/API/Parser.pm
@@ -22,40 +22,6 @@ use RHN::API::TypeHandler;
use Carp;
use XML::LibXML;
-sub parse_exceptions {
- my $class = shift;
- my $file = shift;
-
- my $parser = new XML::LibXML;
- $parser->keep_blanks(0);
- $parser->expand_xinclude(1);
- my $doc = $parser->parse_file($file);
- my $root = $doc->getDocumentElement;
-
- my $exception_box = RHN::API::Exception->exception_box;
-
- my ($lower, $upper) = ($root->getAttribute('lower'), $root->getAttribute('upper'));
-
- for my $xml_node (grep { $_->isa("XML::LibXML::Element") } $root->childNodes) {
- if ($xml_node->nodeName ne 'rhn-exception') {
- warn "non-rhn-exception node: " . $xml_node->toString;
- next;
- }
-
- my ($code, $label) = map { $xml_node->getAttribute($_) } qw/code label/;
- my $description = $xml_node->textContent || '';
-
- die "rhn-exception missing code" unless $code;
- die "rhn-exception missing label" unless $label;
- die "rhn-exception $label (code $code) outside bounds of ($lower, $upper)"
- unless $lower <= $code and $code <= $upper;
-
- $description =~ s/^\s+//gms;
- $description =~ s/\s+$//gms;
- $exception_box->add_exception($label, $code, $description);
- }
-}
-
sub parse_interface {
my $class = shift;
my $method_prefix = shift;
14 years, 3 months
4 commits - backend/satellite_exporter backend/satellite_tools backend/spacewalk-backend.spec rel-eng/packages
by Michael Mraka
backend/satellite_exporter/Makefile | 2
backend/satellite_exporter/exporter/Makefile | 10
backend/satellite_exporter/exporter/__init__.py | 16
backend/satellite_exporter/exporter/dumper.py | 984 -----------------
backend/satellite_exporter/exporter/string_buffer.py | 52
backend/satellite_exporter/handlers/non_auth_dumper.py | 6
backend/satellite_tools/disk_dumper/dumper.py | 405 ++++++
backend/spacewalk-backend.spec | 10
rel-eng/packages/spacewalk-backend | 2
9 files changed, 409 insertions(+), 1078 deletions(-)
New commits:
commit 7bc4ee42f72baf9a0bed7a24a94aa338e7a43782
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Tue Jan 5 13:21:04 2010 +0100
Automatic commit of package [spacewalk-backend] release [0.8.15-1].
diff --git a/backend/spacewalk-backend.spec b/backend/spacewalk-backend.spec
index c607d22..23ac2a2 100644
--- a/backend/spacewalk-backend.spec
+++ b/backend/spacewalk-backend.spec
@@ -8,7 +8,7 @@ Name: spacewalk-backend
Summary: Common programs needed to be installed on the Spacewalk servers/proxies
Group: Applications/Internet
License: GPLv2
-Version: 0.8.14
+Version: 0.8.15
Release: 1%{?dist}
URL: https://fedorahosted.org/spacewalk
Source0: https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
@@ -588,6 +588,9 @@ rm -f %{rhnconf}/rhnSecret.py*
# $Id$
%changelog
+* Tue Jan 05 2010 Michael Mraka <michael.mraka(a)redhat.com> 0.8.15-1
+- merged satellite_exporter/exporter into satellite_tools/disk_dumper
+
* Mon Jan 04 2010 Michael Mraka <michael.mraka(a)redhat.com> 0.8.14-1
- more fixes in SHA256 implementation
diff --git a/rel-eng/packages/spacewalk-backend b/rel-eng/packages/spacewalk-backend
index 48d6f9c..1abd8db 100644
--- a/rel-eng/packages/spacewalk-backend
+++ b/rel-eng/packages/spacewalk-backend
@@ -1 +1 @@
-0.8.14-1 backend/
+0.8.15-1 backend/
commit 4483d65f0177c827af0b80a3220fd3d0287ad0b5
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Tue Jan 5 13:00:32 2010 +0100
removed satellite_exporter/exporter from spec
diff --git a/backend/satellite_exporter/Makefile b/backend/satellite_exporter/Makefile
index c01d832..2689598 100644
--- a/backend/satellite_exporter/Makefile
+++ b/backend/satellite_exporter/Makefile
@@ -1,7 +1,7 @@
# Makefile for the backend directory
#
-CODE_DIRS = handlers exporter
+CODE_DIRS = handlers
SUBDIR = satellite_exporter
FILES = __init__ constants satexport
diff --git a/backend/spacewalk-backend.spec b/backend/spacewalk-backend.spec
index cad1a9d..c607d22 100644
--- a/backend/spacewalk-backend.spec
+++ b/backend/spacewalk-backend.spec
@@ -445,11 +445,6 @@ rm -f %{rhnconf}/rhnSecret.py*
%{rhnroot}/satellite_exporter/satexport.py*
%{rhnroot}/satellite_exporter/constants.py*
-%dir %{rhnroot}/satellite_exporter/exporter
-%{rhnroot}/satellite_exporter/exporter/__init__.py*
-%{rhnroot}/satellite_exporter/exporter/dumper.py*
-%{rhnroot}/satellite_exporter/exporter/string_buffer.py*
-
%dir %{rhnroot}/satellite_exporter/handlers
%{rhnroot}/satellite_exporter/handlers/__init__.py*
%{rhnroot}/satellite_exporter/handlers/non_auth_dumper.py*
commit 93204d74ad5bf08365afb7168d01c0fc231f28d0
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Tue Jan 5 12:57:49 2010 +0100
deleted the rest of satellite_exporter/exporter directory
diff --git a/backend/satellite_exporter/exporter/Makefile b/backend/satellite_exporter/exporter/Makefile
deleted file mode 100644
index 0245eaa..0000000
--- a/backend/satellite_exporter/exporter/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-# Makefile for pkgupload
-#
-# $Id: Makefile 118393 2007-12-27 17:38:45Z jbowes(a)REDHAT.COM $
-
-TOP = ../..
-
-SUBDIR = satellite_exporter/exporter
-FILES = __init__ dumper string_buffer
-
-include $(TOP)/Makefile.defs
diff --git a/backend/satellite_exporter/exporter/__init__.py b/backend/satellite_exporter/exporter/__init__.py
deleted file mode 100644
index 717a6a4..0000000
--- a/backend/satellite_exporter/exporter/__init__.py
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright (C) 2008 Red Hat, Inc.
-# Init module
-#
-# 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.
-#
-
-__all__ = []
commit 801d835c2e49b65a732d5d8d766632d834adeb2a
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Tue Jan 5 11:29:47 2010 +0100
merged satellite_exporter/exporter/dumper.py into satellite_tools/disk_dumper/dumper.py
diff --git a/backend/satellite_exporter/exporter/dumper.py b/backend/satellite_exporter/exporter/dumper.py
deleted file mode 100644
index 093d96c..0000000
--- a/backend/satellite_exporter/exporter/dumper.py
+++ /dev/null
@@ -1,984 +0,0 @@
-#!/usr/bin/python
-# Copyright (C) 2008 Red Hat, Inc.
-#
-# The actual dumper
-#
-# 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.
-#
-
-import time
-import math
-import gzip
-import tempfile
-from types import ListType
-from cStringIO import StringIO
-
-from common import log_debug, log_error, rhnFault, UserDictCase, rhnCache, \
- CFG, rhnLib
-from server import rhnSQL, rhnDatabaseCache
-from satellite_tools.exporter import exportLib, xmlWriter
-from satellite_exporter import constants
-from satellite_exporter.exporter.string_buffer import StringBuffer
-
-# A wrapper class for a database statement
-class DatabaseStatement:
- def __init__(self, **kwparams):
- self.statement = None
- self.init_params = kwparams
-
- def add_params(self, **kwparams):
- self.init_params.update(kwparams)
-
- def set_statement(self, statement):
- self.statement = statement
- return self
-
- def execute(self, **kwparams):
- kwparams.update(self.init_params)
- return self.statement.execute(**kwparams)
-
- def next(self):
- return self.statement.fetchone_dict()
-
- def __getattr__(self, name):
- return getattr(self.statement, name)
-
-class XML_Dumper:
- def __init__(self, req):
- self.compress_level = 5
- self.headers_out = UserDictCase()
- self._raw_stream = req
- self._raw_stream.content_type = 'application/octet-stream'
- # State machine
- self._headers_sent = 0
- self._is_closed = 0
- self._compressed_stream = None
- # Redefine in subclasses
- self._channel_family_query = """
- select pcf.channel_family_id, to_number(null) quantity
- from rhnPublicChannelFamily pcf
- """
-
- def _send_headers(self, error=0, init_compressed_stream=1):
- log_debug(4, "is_closed", self._is_closed)
- if self._is_closed:
- raise Exception, "Trying to write to a closed connection"
- if self._headers_sent:
- return
- self._headers_sent = 1
- if self.compress_level:
- self.headers_out['Content-Encoding'] = 'gzip'
- # Send the headers
- if error:
- # No compression
- self.compress_level = 0
- self._raw_stream.content_type = 'text/xml'
- for h, v in self.headers_out.items():
- self._raw_stream.headers_out[h] = str(v)
- self._raw_stream.send_http_header()
- # If need be, start gzipping
- if self.compress_level and init_compressed_stream:
- log_debug(4, "Compressing with factor %s" % self.compress_level)
- self._compressed_stream = gzip.GzipFile(None, "wb",
- self.compress_level, self._raw_stream)
-
- def send(self, data):
- log_debug(3, "Sending %d bytes" % len(data))
- try:
- self._send_headers()
- if self._compressed_stream:
- log_debug(4, "Sending through a compressed stream")
- self._compressed_stream.write(data)
- else:
- self._raw_stream.write(data)
- except IOError:
- log_error("Client appears to have closed connection")
- self.close()
- raise ClosedConnectionError
- log_debug(5, "Bytes sent", len(data))
-
- write = send
-
- def close(self):
- log_debug(2, "Closing")
- if self._is_closed:
- log_debug(3, "Already closed")
- return
-
- if self._compressed_stream:
- log_debug(5, "Closing a compressed stream")
- try:
- self._compressed_stream.close()
- except IOError, e:
- # Remote end has closed connection already
- log_error("Error closing the stream", str(e))
- pass
- self._compressed_stream = None
- self._is_closed = 1
- log_debug(3, "Closed")
-
- # Override the get_*_statement methods in subclasses
- def get_channel_families_statement(self):
- query = """
- select cf.*, scf.quantity max_members
- from rhnChannelFamily cf,
- (%s
- ) scf
- where scf.channel_family_id = cf.id
- """ % self._channel_family_query
- return DatabaseStatement().set_statement(rhnSQL.prepare(query))
-
- def get_channels_statement(self):
- query = """
- select c.id channel_id, c.label,
- TO_CHAR(c.last_modified, 'YYYYMMDDHH24MISS') last_modified
- from rhnChannel c, rhnChannelFamilyMembers cfm,
- (%s
- ) scf
- where scf.channel_family_id = cfm.channel_family_id
- and cfm.channel_id = c.id
- """ % self._channel_family_query
- return DatabaseStatement().set_statement(rhnSQL.prepare(query))
-
- def get_packages_statement(self):
- query = """
- select p.id package_id,
- TO_CHAR(p.last_modified, 'YYYYMMDDHH24MISS') last_modified
- from rhnChannelPackage cp, rhnPackage p,
- rhnChannelFamilyMembers cfm,
- (%s
- ) scf
- where scf.channel_family_id = cfm.channel_family_id
- and cfm.channel_id = cp.channel_id
- and cp.package_id = :package_id
- and p.id = :package_id
- """ % self._channel_family_query
- return DatabaseStatement().set_statement(rhnSQL.prepare(query))
-
- def get_source_packages_statement(self):
- query = """
- select ps.id package_id,
- TO_CHAR(ps.last_modified, 'YYYYMMDDHH24MISS') last_modified
- from rhnChannelPackage cp, rhnPackage p, rhnPackageSource ps,
- rhnChannelFamilyMembers cfm,
- (%s
- ) scf
- where scf.channel_family_id = cfm.channel_family_id
- and cfm.channel_id = cp.channel_id
- and cp.package_id = p.id
- and p.source_rpm_id = ps.source_rpm_id
- and ((p.org_id is null and ps.org_id is null) or
- p.org_id = ps.org_id)
- and ps.id = :package_id
- """ % self._channel_family_query
- return DatabaseStatement().set_statement(rhnSQL.prepare(query))
-
- def get_errata_statement(self):
- query = """
- select e.id errata_id,
- TO_CHAR(e.last_modified, 'YYYYMMDDHH24MISS') last_modified
- from rhnChannelErrata ce, rhnErrata e,
- rhnChannelFamilyMembers cfm,
- (%s
- ) scf
- where scf.channel_family_id = cfm.channel_family_id
- and cfm.channel_id = ce.channel_id
- and ce.errata_id = :errata_id
- and e.id = :errata_id
- """ % self._channel_family_query
- return DatabaseStatement().set_statement(rhnSQL.prepare(query))
-
- def _get_xml_writer(self):
- return xmlWriter.XMLWriter(stream=StringBuffer(self))
-
- # Dumper functions here
- def dump_blacklist_obsoletes(self):
- log_debug(2)
- writer = self._get_xml_writer()
- dumper = SatelliteDumper(writer,
- exportLib.BlacklistObsoletesDumper(writer))
- dumper.dump()
- writer.flush()
- log_debug(4, "OK")
- self.close()
- return 0
-
- def dump_arches(self, rpm_arch_type_only=0):
- log_debug(2)
- writer = self._get_xml_writer()
- dumper = SatelliteDumper(writer,
- exportLib.ChannelArchesDumper(writer,
- rpm_arch_type_only=rpm_arch_type_only),
- exportLib.PackageArchesDumper(writer,
- rpm_arch_type_only=rpm_arch_type_only),
- exportLib.ServerArchesDumper(writer,
- rpm_arch_type_only=rpm_arch_type_only),
- exportLib.CPUArchesDumper(writer),
- exportLib.ServerPackageArchCompatDumper(writer,
- rpm_arch_type_only=rpm_arch_type_only),
- exportLib.ServerChannelArchCompatDumper(writer,
- rpm_arch_type_only=rpm_arch_type_only),
- exportLib.ChannelPackageArchCompatDumper(writer,
- rpm_arch_type_only=rpm_arch_type_only),
- )
- dumper.dump()
- writer.flush()
- log_debug(4, "OK")
- self.close()
- return 0
-
- def dump_server_group_type_server_arches(self, rpm_arch_type_only=0,
- virt_filter=0):
- log_debug(2)
- writer = self._get_xml_writer()
- dumper = SatelliteDumper(writer,
- exportLib.ServerGroupTypeServerArchCompatDumper(writer,
- rpm_arch_type_only=rpm_arch_type_only, virt_filter=virt_filter),
- )
- dumper.dump()
- writer.flush()
- log_debug(4, "OK")
- self.close()
- return 0
-
- def dump_channel_families(self, virt_filter=0):
- log_debug(2)
-
- h = self.get_channel_families_statement()
- h.execute()
-
- writer = self._get_xml_writer()
- dumper = SatelliteDumper(writer,
- exportLib.ChannelFamiliesDumper(writer,
- data_iterator=h, null_max_members=0, virt_filter=virt_filter),)
- dumper.dump()
- writer.flush()
- log_debug(4, "OK")
- self.close()
- return 0
-
- def dump_channels(self, channel_labels=None):
- log_debug(2)
- channels = self._validate_channels(channel_labels=channel_labels)
-
- writer = self._get_xml_writer()
- dumper = SatelliteDumper(writer, ChannelsDumper(writer,
- channels=channels.values()))
- dumper.dump()
- writer.flush()
- log_debug(4, "OK")
- self.close()
- return 0
-
- def dump_channel_packages_short(self, channel_label, last_modified):
- log_debug(2, channel_label)
- channels = self._validate_channels(channel_labels=[channel_label])
- channel_obj = channels[channel_label]
- db_last_modified = int(rhnLib.timestamp(channel_obj['last_modified']))
- last_modified = int(rhnLib.timestamp(last_modified))
- log_debug(3, "last modified", last_modified, "db last modified",
- db_last_modified)
- if last_modified != db_last_modified:
- raise rhnFault(3013, "The requested channel version does not match"
- " the upstream version", explain=0)
- channel_id = channel_obj['channel_id']
- key = "xml-channel-packages/rhn-channel-%d.data" % channel_id
- # Try to get everything off of the cache
- val = rhnCache.get(key, compressed=0, raw=1, modified=last_modified)
- if val is None:
- # Not generated yet
- log_debug(4, "Cache MISS for %s (%s)" % (channel_label,
- channel_id))
- stream = self._cache_channel_packages_short(channel_id, key,
- last_modified)
- else:
- log_debug(4, "Cache HIT for %s (%s)" % (channel_label,
- channel_id))
- temp_stream = tempfile.TemporaryFile()
- temp_stream.write(val)
- temp_stream.flush()
- stream = self._normalize_compressed_stream(temp_stream)
-
- # Copy the results to the output stream
- # They shold be already compressed if they were requested to be
- # compressed
- buffer_size = 16384
- # Send the HTTP headers - but don't init the compressed stream since
- # we send the data ourselves
- self._send_headers(init_compressed_stream=0)
- while 1:
- buff = stream.read(buffer_size)
- if not buff:
- break
- try:
- self._raw_stream.write(buff)
- except IOError:
- log_error("Client disconnected prematurely")
- self.close()
- raise ClosedConnectionError
- # We're done
- return 0
-
- _query_get_channel_packages = rhnSQL.Statement("""
- select cp.package_id,
- TO_CHAR(p.last_modified, 'YYYYMMDDHH24MISS') last_modified
- from rhnChannelPackage cp,
- rhnPackage p
- where cp.channel_id = :channel_id
- and cp.package_id = p.id
- """)
-
- def _cache_channel_packages_short(self, channel_id, key, last_modified):
- # Caches the short package entries for channel_id
- # Create a temporary file
- temp_stream = tempfile.TemporaryFile()
- # Always compress the result
- compress_level = 5
- stream = gzip.GzipFile(None, "wb", compress_level, temp_stream)
- writer = xmlWriter.XMLWriter(stream=stream)
-
- # Fetch packages
- h = rhnSQL.prepare(self._query_get_channel_packages)
- h.execute(channel_id=channel_id)
- package_ids = h.fetchall_dict() or []
- # Sort packages
- package_ids.sort(lambda a, b: cmp(a['package_id'], b['package_id']))
-
- dumper = SatelliteDumper(writer,
- ShortPackagesDumper(writer, package_ids))
- dumper.dump()
- writer.flush()
- # We're done with the stream object
- stream.close()
- del stream
- temp_stream.seek(0, 0)
- # Set the value in the cache. We don't recompress the result since
- # it's already compressed
- rhnCache.set(key, temp_stream.read(), modified=last_modified,
- compressed=0, raw=1)
- return self._normalize_compressed_stream(temp_stream)
-
- def _normalize_compressed_stream(self, stream):
- # Given a compressed stream, will either return the stream, or will
- # decompress it and return it, depending on the compression level
- # self.compress_level
- stream.seek(0, 0)
- if self.compress_level:
- # Output should be compressed; nothing else to to
- return stream
- # Argh, have to decompress
- return gzip.GzipFile(None, "rb", 0, stream)
-
- def dump_packages(self, packages):
- log_debug(2)
- return self._packages(packages, prefix='rhn-package-',
- dump_class=PackagesDumper)
-
- def dump_packages_short(self, packages):
- log_debug(2)
- return self._packages(packages, prefix='rhn-package-',
- dump_class=ShortPackagesDumper)
-
- def dump_source_packages(self, packages):
- log_debug(2)
- return self._packages(packages, prefix='rhn-source-package-',
- dump_class=SourcePackagesDumper, sources=1)
-
- def _packages(self, packages, prefix, dump_class, sources=0):
- if sources:
- h = self.get_source_packages_statement()
- else:
- h = self.get_packages_statement()
-
- packages_hash = {}
- for package in packages:
- package = str(package)
- if package[:len(prefix)] != prefix:
- raise rhnFault(3002, "Invalid package name %s" % package)
- package_id = package[len(prefix):]
- try:
- package_id = int(package_id)
- except ValueError:
- raise rhnFault(3002, "Invalid package name %s" % package)
- if packages_hash.has_key(package_id):
- # Already verified
- continue
- h.execute(package_id=package_id)
- row = h.fetchone_dict()
- if not row:
- # XXX Silently ignore it?
- raise rhnFault(3003, "No such package %s" % package)
- # Saving the row, it's handy later when we create the iterator
- packages_hash[package_id] = row
-
- writer = self._get_xml_writer()
- dumper = SatelliteDumper(writer,
- dump_class(writer, packages_hash.values()))
- dumper.dump()
- writer.flush()
- log_debug(4, "OK")
- self.close()
- return 0
-
- def dump_errata(self, errata):
- log_debug(2)
-
- h = self.get_errata_statement()
-
- errata_hash = {}
- prefix = 'rhn-erratum-'
- for erratum in errata:
- erratum = str(erratum)
- if erratum[:len(prefix)] != prefix:
- raise rhnFault(3004, "Wrong erratum name %s" % erratum)
- errata_id = erratum[len(prefix):]
- try:
- errata_id = int(errata_id)
- except ValueError:
- raise rhnFault(3004, "Wrong erratum name %s" % erratum)
- if errata_hash.has_key(errata_id):
- # Already verified
- continue
- h.execute(errata_id=errata_id)
- row = h.fetchone_dict()
- if not row:
- # XXX Silently ignore it?
- raise rhnFault(3005, "No such erratum %s" % erratum)
- # Saving the row, it's handy later when we create the iterator
- errata_hash[errata_id] = row
-
- writer = self._get_xml_writer()
- dumper = SatelliteDumper(writer,
- ErrataDumper(writer, errata_hash.values()))
- dumper.dump()
- writer.flush()
- log_debug(4, "OK")
- self.close()
- return 0
-
- def dump_kickstartable_trees(self, kickstart_labels=None):
- log_debug(2)
- kickstarts = self._validate_kickstarts(
- kickstart_labels=kickstart_labels)
-
- writer = self._get_xml_writer()
- dumper = SatelliteDumper(writer,
- KickstartableTreesDumper(writer, kickstarts=kickstarts))
- dumper.dump()
- writer.flush()
- log_debug(4, "OK")
- self.close()
- return 0
-
- def dump_product_names(self):
- log_debug(4)
- writer = self._get_xml_writer()
- dumper = SatelliteDumper(writer, exportLib.ProductNamesDumper(writer))
- dumper.dump()
- writer.flush()
- self.close()
- return 0
-
- def _validate_channels(self, channel_labels=None):
- log_debug(4)
- # Sanity check
- if channel_labels:
- if not isinstance(channel_labels, ListType):
- raise rhnFault(3000,
- "Expected list of channels, got %s" % type(channel_labels))
-
- h = self.get_channels_statement()
- h.execute()
- # Hash the list of all available channels based on the label
- all_channels_hash = {}
- while 1:
- row = h.fetchone_dict()
- if not row:
- break
- all_channels_hash[row['label']] = row
-
- # Intersect the list of channels they've sent to us
- if not channel_labels:
- channels = all_channels_hash
- else:
- channels = {}
- for label in channel_labels:
- if not all_channels_hash.has_key(label):
- raise rhnFault(3001, "Could not retrieve channel %s" %
- label)
- channels[label] = all_channels_hash[label]
-
- return channels
-
- _query_validate_kickstarts = rhnSQL.Statement("""
- select kt.label kickstart_label,
- TO_CHAR(kt.modified, 'YYYYMMDDHH24MISS') last_modified
- from rhnKickstartableTree kt
- where kt.channel_id = :channel_id
- and kt.org_id is null
- """)
- def _validate_kickstarts(self, kickstart_labels):
- log_debug(4)
- # Saity check
- if kickstart_labels:
- if not isinstance(kickstart_labels, ListType):
- raise rhnFault(3000,
- "Expected list of kickstart labels, got %s" %
- type(kickstart_labels))
-
- all_ks_hash = {}
-
- h = self.get_channels_statement()
- h.execute()
-
- hk = rhnSQL.prepare(self._query_validate_kickstarts)
- while 1:
- channel = h.fetchone_dict()
- if not channel:
- break
-
- hk.execute(channel_id=channel['channel_id'])
- while 1:
- row = hk.fetchone_dict()
- if not row:
- break
- all_ks_hash[row['kickstart_label']] = row
-
- if not kickstart_labels:
- return all_ks_hash.values()
-
- result = []
- for l in kickstart_labels:
- if all_ks_hash.has_key(l):
- result.append(all_ks_hash[l])
-
- return result
-
-class SatelliteDumper(exportLib.SatelliteDumper):
- # Overriding with our own version
- def set_attributes(self):
- attributes = exportLib.SatelliteDumper.set_attributes(self)
- attributes['version'] = constants.PROTOCOL_VERSION
- attributes['generation'] = CFG.SAT_CERT_GENERATION
- return attributes
-
-
-# A query iterator successively applies the list of params as execute() to the
-# statement that was passed in, and presents the union of the result sets as a
-# single result set.
-# Params is a list of dictionaries that would fill the named bound variables
-# from the statement
-class QueryIterator:
- def __init__(self, statement, params):
- self._statement = statement
- self._params = params
- # Position in the params list
- self._params_pos = -1
- self._result_set_exhausted = 1
-
- def fetchone_dict(self):
- log_debug(4)
- while 1:
- if self._result_set_exhausted:
- # Nothing to do here, move to the next set of params
- pos = self._params_pos
- pos = pos + 1
- self._params_pos = pos
- if pos == len(self._params):
- # End of the list, we're done
- return None
- # Execute the satement
- log_debug(5, "Using param", pos, self._params[pos])
- self._statement.execute(**self._params[pos])
- self._result_set_exhausted = 0
- # Go back into the loop
- continue
-
- # Result set not exhausted yet
- row = self._statement.fetchone_dict()
- if row:
- return row
-
- self._result_set_exhausted = 1
-
- def _execute_next(self):
- log_debug(4)
- self._params_pos = self._params_pos + 1
- if self._params_pos == len(self._params):
- log_debug(5, "Done")
- self._statement = None
- return None
- self._statement.execute(**self._params[self._params_pos])
-
-# This class will attempt to retrieve information, either from the database or
-# from a local cache
-#
-# Note that we expect at most one result set per database query - this can be
-# easily fixed if we need more
-class CachedQueryIterator:
- def __init__(self, statement, params, cache_get):
- self._statement = statement
- # XXX params has to be a list of hashes, containing at least a
- # last_modified - which is stripped before the execution of the
- # statement
- self._params = params
- self._params_pos = 0
- self._cache_get = cache_get
-
- def fetchone_dict(self):
- log_debug(4)
- while 1:
- if self._params_pos == len(self._params):
- log_debug(4, "End of iteration")
- self.close()
- return None
- log_debug(4, "Fetching set for param", self._params_pos)
- # Get the last modified attribute
- params = self._params[self._params_pos]
- self._params_pos = self._params_pos + 1
-
- # Look up the object in the cache
- val = self._cache_get(params)
- if val is not None:
- # Entry is cached
- log_debug(2, "Cache HIT for %s" % params)
- return val
-
- log_debug(4, "Cache MISS for %s" % params)
- start = time.time()
- self._execute(params)
- row = self._statement.fetchone_dict()
-
- if row:
- log_debug(5, "Timer: %.2f" % (time.time() - start))
- return (params, row)
-
- # Dummy return
- return None
-
- def _execute(self, params):
- log_debug(4, params)
- self._statement.execute(**params)
-
- def close(self):
- # Make sure we remove references to these objects, or circular
- # references can occur
- log_debug(3, "Closing the iterator")
- self._statement = None
- self._cache_get = None
- self._params = None
-
-
-class CachedDumper(exportLib.BaseDumper):
- def __init__(self, writer, statement, params):
- iterator = CachedQueryIterator(statement, params,
- cache_get=self.cache_get)
- exportLib.BaseDumper.__init__(self, writer, data_iterator=iterator)
- self.use_database_cache = CFG.USE_DATABASE_CACHE
- log_debug(1, "Use database cache", self.use_database_cache)
-
- def _get_last_modified(self, params):
- # To be overwritten
- return params['last_modified']
-
- def _get_key(self, params):
- raise NotImplementedError
-
- def cache_get(self, params):
- log_debug(4, params)
- key = self._get_key(params)
- last_modified = self._get_last_modified(params)
- if not self.use_database_cache:
- return rhnCache.get(key, modified=last_modified, raw=1)
- return rhnDatabaseCache.get(key, modified=last_modified, raw=1,
- compressed=1)
-
- def cache_set(self, params, value):
- log_debug(4, params)
- last_modified = self._get_last_modified(params)
- key = self._get_key(params)
- if not self.use_database_cache:
- return rhnCache.set(key, value, modified=last_modified, raw=1)
- return rhnDatabaseCache.set(key, value, modified=last_modified, raw=1,
- compressed=1)
-
- def _dump_subelement(self, data):
- # To be overridden in subclasses
- pass
-
- def dump_subelement(self, data):
- log_debug(2)
- # CachedQueryIterator returns (params, row) as data
- params, row = data
- s = StringIO()
- # Back up the old writer and replace it with a StringIO-based one
- ow = self.get_writer()
- # Use into a tee stream (which writes to both streams at the same
- # time)
- tee_stream = TeeStream(s, ow.stream)
- self.set_writer(xmlWriter.XMLWriter(stream=tee_stream, skip_xml_decl=1))
-
- start = time.time()
- self._dump_subelement(row)
- log_debug(5,
- "Timer for _dump_subelement: %.2f" % (time.time() - start))
-
- # Restore the old writer
- self.set_writer(ow)
-
- self.cache_set(params, s.getvalue())
-
-
-class ChannelsDumper(CachedDumper, exportLib.ChannelsDumper):
- _query_list_channels = rhnSQL.Statement("""
- select c.id, c.label, ca.label channel_arch, c.basedir, c.name,
- c.summary, c.description, c.gpg_key_url, c.org_id,
- TO_CHAR(c.last_modified, 'YYYYMMDDHH24MISS') last_modified,
- c.channel_product_id,
- pc.label parent_channel,
- cp.product channel_product,
- cp.version channel_product_version,
- cp.beta channel_product_beta,
- c.receiving_updates
- from rhnChannel c, rhnChannelArch ca, rhnChannel pc, rhnChannelProduct cp
- where c.id = :channel_id
- and c.channel_arch_id = ca.id
- and c.parent_channel = pc.id (+)
- and c.channel_product_id = cp.id (+)
- """)
- def __init__(self, writer, channels):
- h = rhnSQL.prepare(self._query_list_channels)
- CachedDumper.__init__(self, writer, statement=h, params=channels)
-
- def _get_key(self, params):
- channel_id = params['channel_id']
- return "xml-channels/rhn-channel-%d.xml" % channel_id
-
- def _dump_subelement(self, data):
- log_debug(6, data)
- return exportLib.ChannelsDumper.dump_subelement(self, data)
-
-class ShortPackagesDumper(CachedDumper, exportLib.ShortPackagesDumper):
- def __init__(self, writer, packages):
- h = rhnSQL.prepare("""
- select
- p.id,
- p.org_id,
- pn.name,
- pe.evr.version version,
- pe.evr.release release,
- pe.evr.epoch epoch,
- pa.label package_arch,
- c.checksum md5sum,
- p.package_size,
- TO_CHAR(p.last_modified, 'YYYYMMDDHH24MISS') last_modified
- from rhnPackage p, rhnPackageName pn, rhnPackageEVR pe,
- rhnPackageArch pa, rhnChecksum c
- where p.id = :package_id
- and p.name_id = pn.id
- and p.evr_id = pe.id
- and p.package_arch_id = pa.id
- and p.checksum_id = c.id
- """)
- CachedDumper.__init__(self, writer, statement=h, params=packages)
-
- def _get_key(self, params):
- package_id = params['package_id']
- hash_val = hash_object_id(package_id, 100)
- return "xml-short-packages/%s/rhn-package-short-%s.xml" % (
- hash_val, package_id)
-
- def _dump_subelement(self, data):
- log_debug(6, data)
- return exportLib.ShortPackagesDumper.dump_subelement(self, data)
-
-class PackagesDumper(CachedDumper, exportLib.PackagesDumper):
- def __init__(self, writer, packages):
- h = rhnSQL.prepare("""
- select
- p.id,
- pn.name,
- p.org_id,
- pe.evr.version version,
- pe.evr.release release,
- pe.evr.epoch epoch,
- pa.label package_arch,
- pg.name package_group,
- p.rpm_version,
- p.description,
- p.summary,
- p.package_size,
- p.payload_size,
- p.build_host,
- TO_CHAR(p.build_time, 'YYYYMMDDHH24MISS') build_time,
- sr.name source_rpm,
- c.checksum md5sum,
- p.vendor,
- p.payload_format,
- p.compat,
- p.header_sig,
- p.header_start,
- p.header_end,
- p.copyright,
- p.cookie,
- TO_CHAR(p.last_modified, 'YYYYMMDDHH24MISS') last_modified
- from rhnPackage p, rhnPackageName pn, rhnPackageEVR pe,
- rhnPackageArch pa, rhnPackageGroup pg, rhnSourceRPM sr,
- rhnChecksum c
- where p.id = :package_id
- and p.name_id = pn.id
- and p.evr_id = pe.id
- and p.package_arch_id = pa.id
- and p.package_group = pg.id
- and p.source_rpm_id = sr.id
- and p.checksum_id = c.id
- """)
- CachedDumper.__init__(self, writer, statement=h, params=packages)
-
- def _get_key(self, params):
- package_id = params['package_id']
- hash_val = hash_object_id(package_id, 100)
- return "xml-packages/%s/rhn-package-%s.xml" % (hash_val, package_id)
-
- def _dump_subelement(self, data):
- log_debug(6, data)
- return exportLib.PackagesDumper.dump_subelement(self, data)
-
-class SourcePackagesDumper(CachedDumper, exportLib.SourcePackagesDumper):
- def __init__(self, writer, packages):
- h = rhnSQL.prepare("""
- select
- ps.id,
- sr.name source_rpm,
- pg.name package_group,
- ps.rpm_version,
- ps.payload_size,
- ps.build_host,
- TO_CHAR(ps.build_time, 'YYYYMMDDHH24MISS') build_time,
- sig.checksum sigmd5,
- ps.vendor,
- ps.cookie,
- ps.package_size,
- c.checksum md5sum,
- TO_CHAR(ps.last_modified, 'YYYYMMDDHH24MISS') last_modified
- from rhnPackageSource ps, rhnPackageGroup pg, rhnSourceRPM sr,
- rhnChecksum c, rhnChecksum sig
- where ps.id = :package_id
- and ps.package_group = pg.id
- and ps.source_rpm_id = sr.id
- and ps.checksum_id = c.id
- and ps.sigchecksum_id = sig.id
- """)
- CachedDumper.__init__(self, writer, statement=h, params=packages)
-
- def _get_key(self, params):
- package_id = params['package_id']
- hash_val = hash_object_id(package_id, 100)
- return "xml-packages/%s/rhn-source-package-%s.xml" % (hash_val,
- package_id)
-
- def _dump_subelement(self, data):
- log_debug(6, data)
- return exportLib.SourcePackagesDumper.dump_subelement(self, data)
-
-
-class ErrataDumper(CachedDumper, exportLib.ErrataSynopsisDumper):
- def __init__(self, writer, errata):
- h = rhnSQL.prepare("""
- select
- e.id,
- e.advisory_name,
- e.advisory,
- e.advisory_type,
- e.advisory_rel,
- e.product,
- e.description,
- e.synopsis,
- e.topic,
- e.solution,
- TO_CHAR(e.issue_date, 'YYYYMMDDHH24MISS') issue_date,
- TO_CHAR(e.update_date, 'YYYYMMDDHH24MISS') update_date,
- TO_CHAR(e.last_modified, 'YYYYMMDDHH24MISS') last_modified,
- e.refers_to,
- e.notes
- from rhnErrata e
- where e.id = :errata_id
- """)
- CachedDumper.__init__(self, writer, statement=h, params=errata)
-
- def _get_key(self, params):
- errata_id = params['errata_id']
- hash_val = hash_object_id(errata_id, 10)
- return "xml-errata/%s/rhn-erratum-%s.xml" % (hash_val, errata_id)
-
- def _dump_subelement(self, data):
- log_debug(6, data)
- return exportLib.ErrataSynopsisDumper.dump_subelement(self, data)
-
-class KickstartableTreesDumper(CachedDumper,
- exportLib.KickstartableTreesDumper):
- _query_lookup_ks_tree = rhnSQL.Statement("""
- select kt.id,
- c.label channel,
- kt.base_path "base-path",
- kt.label,
- kt.boot_image "boot-image",
- ktt.name "kstree-type-name",
- ktt.label "kstree-type-label",
- kit.name "install-type-name",
- kit.label "install-type-label",
- TO_CHAR(kt.last_modified, 'YYYYMMDDHH24MISS') "last-modified"
- from rhnKickstartableTree kt,
- rhnKSTreeType ktt,
- rhnKSInstallType kit,
- rhnChannel c
- where kt.channel_id = c.id
- and ktt.id = kt.kstree_type
- and kit.id = kt.install_type
- and kt.org_id is NULL
- and kt.label = :kickstart_label
- """)
- def __init__(self, writer, kickstarts):
- h = rhnSQL.prepare(self._query_lookup_ks_tree)
- CachedDumper.__init__(self, writer, statement=h, params=kickstarts)
-
- def _get_key(self, params):
- kickstart_label = params['kickstart_label']
- return "xml-kickstartable-tree/%s.xml" % kickstart_label
-
- def _dump_subelement(self, data):
- log_debug(6, data)
- return exportLib.KickstartableTreesDumper.dump_subelement(self, data)
-
-# This looks complicated; it returns the (integer part of)
-# obj_id, modulo factor
-# The string is left padded with as many 0 chars as necessary to
-# match factor
-def hash_object_id(obj_id, factor):
- # Make sure obj_id is a string
- obj_id = str(obj_id)
- format = int(math.ceil(math.log10(factor)))
- format = "%%0%sd" % format
- return format % (int(obj_id.split('-')[-1]) % factor, )
-
-class ClosedConnectionError(Exception):
- pass
-
-class TeeStream:
- """Writes to multiple streams at the same time"""
- def __init__(self, *streams):
- self.streams = streams
-
- def write(self, data):
- log_debug(6, "Writing %s bytes" % len(data))
- for stream in self.streams:
- stream.write(data)
diff --git a/backend/satellite_exporter/exporter/string_buffer.py b/backend/satellite_exporter/exporter/string_buffer.py
deleted file mode 100644
index e864485..0000000
--- a/backend/satellite_exporter/exporter/string_buffer.py
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/usr/bin/python
-# Copyright (C) 2008 Red Hat, Inc.
-#
-# Simple string buffer that wraps around streams to speed up writes
-#
-# 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.
-#
-
-class StringBuffer:
- def __init__(self, stream):
- self.stream = stream
- self.buffer_size = 65536
- self.buffer = ""
-
- def write(self, data):
- self.buffer = self.buffer + data
- if len(self.buffer) < self.buffer_size:
- return
- # The buffer is full, send it
- self.stream.write(self.buffer[:self.buffer_size])
- self.buffer = self.buffer[self.buffer_size:]
-
- def flush(self):
- if self.buffer:
- self.stream.write(self.buffer)
- self.buffer = ""
-
- def close(self):
- self.flush()
-
- def __del__(self):
- self.close()
-
-
-if __name__ == '__main__':
- import sys
- import time
- sb = StringBuffer(sys.stdout)
- sb.buffer_size = 10
-
- while 1:
- sb.write('a')
- time.sleep(.2)
diff --git a/backend/satellite_exporter/handlers/non_auth_dumper.py b/backend/satellite_exporter/handlers/non_auth_dumper.py
index f0431f0..24adaf3 100644
--- a/backend/satellite_exporter/handlers/non_auth_dumper.py
+++ b/backend/satellite_exporter/handlers/non_auth_dumper.py
@@ -27,7 +27,7 @@ from server.importlib.backendLib import localtime
from common.rhnTranslate import _
from satellite_tools.exporter import exportLib
-from satellite_exporter.exporter import dumper
+from satellite_tools.disk_dumper import dumper
class InvalidPackageError(Exception):
pass
@@ -38,10 +38,10 @@ class NullPathPackageError(Exception):
class MissingPackageError(Exception):
pass
-class NonAuthenticatedDumper(rhnHandler, dumper.XML_Dumper):
+class NonAuthenticatedDumper(rhnHandler, dumper.XML_DumperEx):
def __init__(self, req):
rhnHandler.__init__(self)
- dumper.XML_Dumper.__init__(self, req)
+ dumper.XML_DumperEx.__init__(self, req)
# Don't check for abuse
self.check_for_abuse = 0
diff --git a/backend/satellite_tools/disk_dumper/dumper.py b/backend/satellite_tools/disk_dumper/dumper.py
index f4d0b0b..aad3c2d 100644
--- a/backend/satellite_tools/disk_dumper/dumper.py
+++ b/backend/satellite_tools/disk_dumper/dumper.py
@@ -19,7 +19,7 @@ import math
import gzip
import string
import tempfile
-from types import ListType, DictType
+from types import ListType
from cStringIO import StringIO
from common import log_debug, log_error, rhnFault, UserDictCase, rhnCache, \
@@ -57,6 +57,333 @@ class DatabaseStatement:
def __getattr__(self, name):
return getattr(self.statement, name)
+class XML_DumperEx(XML_Dumper):
+ def __init__(self, req):
+ self.compress_level = 5
+ self.headers_out = UserDictCase()
+ self._raw_stream = req
+ self._raw_stream.content_type = 'application/octet-stream'
+ # State machine
+ self._headers_sent = 0
+ self._is_closed = 0
+ self._compressed_stream = None
+ # Redefine in subclasses
+ self._channel_family_query = """
+ select pcf.channel_family_id, to_number(null) quantity
+ from rhnPublicChannelFamily pcf
+ """
+
+ def _send_headers(self, error=0, init_compressed_stream=1):
+ log_debug(4, "is_closed", self._is_closed)
+ if self._is_closed:
+ raise Exception, "Trying to write to a closed connection"
+ if self._headers_sent:
+ return
+ self._headers_sent = 1
+ if self.compress_level:
+ self.headers_out['Content-Encoding'] = 'gzip'
+ # Send the headers
+ if error:
+ # No compression
+ self.compress_level = 0
+ self._raw_stream.content_type = 'text/xml'
+ for h, v in self.headers_out.items():
+ self._raw_stream.headers_out[h] = str(v)
+ self._raw_stream.send_http_header()
+ # If need be, start gzipping
+ if self.compress_level and init_compressed_stream:
+ log_debug(4, "Compressing with factor %s" % self.compress_level)
+ self._compressed_stream = gzip.GzipFile(None, "wb",
+ self.compress_level, self._raw_stream)
+
+ def send(self, data):
+ log_debug(3, "Sending %d bytes" % len(data))
+ try:
+ self._send_headers()
+ if self._compressed_stream:
+ log_debug(4, "Sending through a compressed stream")
+ self._compressed_stream.write(data)
+ else:
+ self._raw_stream.write(data)
+ except IOError:
+ log_error("Client appears to have closed connection")
+ self.close()
+ raise ClosedConnectionError
+ log_debug(5, "Bytes sent", len(data))
+
+ write = send
+
+ def close(self):
+ log_debug(2, "Closing")
+ if self._is_closed:
+ log_debug(3, "Already closed")
+ return
+
+ if self._compressed_stream:
+ log_debug(5, "Closing a compressed stream")
+ try:
+ self._compressed_stream.close()
+ except IOError, e:
+ # Remote end has closed connection already
+ log_error("Error closing the stream", str(e))
+ pass
+ self._compressed_stream = None
+ self._is_closed = 1
+ log_debug(3, "Closed")
+
+ # Dumper functions here
+ def dump_blacklist_obsoletes(self):
+ log_debug(2)
+ writer = self._get_xml_writer()
+ dumper = SatelliteDumperEx(writer,
+ exportLib.BlacklistObsoletesDumper(writer))
+ dumper.dump()
+ writer.flush()
+ log_debug(4, "OK")
+ self.close()
+ return 0
+
+ def dump_arches(self, rpm_arch_type_only=0):
+ log_debug(2)
+ writer = self._get_xml_writer()
+ dumper = SatelliteDumperEx(writer,
+ exportLib.ChannelArchesDumper(writer,
+ rpm_arch_type_only=rpm_arch_type_only),
+ exportLib.PackageArchesDumper(writer,
+ rpm_arch_type_only=rpm_arch_type_only),
+ exportLib.ServerArchesDumper(writer,
+ rpm_arch_type_only=rpm_arch_type_only),
+ exportLib.CPUArchesDumper(writer),
+ exportLib.ServerPackageArchCompatDumper(writer,
+ rpm_arch_type_only=rpm_arch_type_only),
+ exportLib.ServerChannelArchCompatDumper(writer,
+ rpm_arch_type_only=rpm_arch_type_only),
+ exportLib.ChannelPackageArchCompatDumper(writer,
+ rpm_arch_type_only=rpm_arch_type_only),
+ )
+ dumper.dump()
+ writer.flush()
+ log_debug(4, "OK")
+ self.close()
+ return 0
+
+ def dump_server_group_type_server_arches(self, rpm_arch_type_only=0,
+ virt_filter=0):
+ log_debug(2)
+ writer = self._get_xml_writer()
+ dumper = SatelliteDumperEx(writer,
+ exportLib.ServerGroupTypeServerArchCompatDumper(writer,
+ rpm_arch_type_only=rpm_arch_type_only, virt_filter=virt_filter),
+ )
+ dumper.dump()
+ writer.flush()
+ log_debug(4, "OK")
+ self.close()
+ return 0
+
+ def dump_channel_families(self, virt_filter=0):
+ log_debug(2)
+
+ h = self.get_channel_families_statement()
+ h.execute()
+
+ writer = self._get_xml_writer()
+ dumper = SatelliteDumperEx(writer,
+ exportLib.ChannelFamiliesDumper(writer,
+ data_iterator=h, null_max_members=0, virt_filter=virt_filter),)
+ dumper.dump()
+ writer.flush()
+ log_debug(4, "OK")
+ self.close()
+ return 0
+
+ def dump_channels(self, channel_labels=None):
+ log_debug(2)
+ channels = self._validate_channels(channel_labels=channel_labels)
+
+ writer = self._get_xml_writer()
+ dumper = SatelliteDumperEx(writer, ChannelsDumperEx(writer,
+ channels=channels.values()))
+ dumper.dump()
+ writer.flush()
+ log_debug(4, "OK")
+ self.close()
+ return 0
+
+ def dump_channel_packages_short(self, channel_label, last_modified):
+ log_debug(2, channel_label)
+ channels = self._validate_channels(channel_labels=[channel_label])
+ channel_obj = channels[channel_label]
+ db_last_modified = int(rhnLib.timestamp(channel_obj['last_modified']))
+ last_modified = int(rhnLib.timestamp(last_modified))
+ log_debug(3, "last modified", last_modified, "db last modified",
+ db_last_modified)
+ if last_modified != db_last_modified:
+ raise rhnFault(3013, "The requested channel version does not match"
+ " the upstream version", explain=0)
+ channel_id = channel_obj['channel_id']
+ key = "xml-channel-packages/rhn-channel-%d.data" % channel_id
+ # Try to get everything off of the cache
+ val = rhnCache.get(key, compressed=0, raw=1, modified=last_modified)
+ if val is None:
+ # Not generated yet
+ log_debug(4, "Cache MISS for %s (%s)" % (channel_label,
+ channel_id))
+ stream = self._cache_channel_packages_short(channel_id, key,
+ last_modified)
+ else:
+ log_debug(4, "Cache HIT for %s (%s)" % (channel_label,
+ channel_id))
+ temp_stream = tempfile.TemporaryFile()
+ temp_stream.write(val)
+ temp_stream.flush()
+ stream = self._normalize_compressed_stream(temp_stream)
+
+ # Copy the results to the output stream
+ # They shold be already compressed if they were requested to be
+ # compressed
+ buffer_size = 16384
+ # Send the HTTP headers - but don't init the compressed stream since
+ # we send the data ourselves
+ self._send_headers(init_compressed_stream=0)
+ while 1:
+ buff = stream.read(buffer_size)
+ if not buff:
+ break
+ try:
+ self._raw_stream.write(buff)
+ except IOError:
+ log_error("Client disconnected prematurely")
+ self.close()
+ raise ClosedConnectionError
+ # We're done
+ return 0
+
+ def _cache_channel_packages_short(self, channel_id, key, last_modified):
+ """ Caches the short package entries for channel_id """
+ # Create a temporary file
+ temp_stream = tempfile.TemporaryFile()
+ # Always compress the result
+ compress_level = 5
+ stream = gzip.GzipFile(None, "wb", compress_level, temp_stream)
+ writer = xmlWriter.XMLWriter(stream=stream)
+
+ # Fetch packages
+ h = rhnSQL.prepare(self._query_get_channel_packages)
+ h.execute(channel_id=channel_id)
+ package_ids = h.fetchall_dict() or []
+ # Sort packages
+ package_ids.sort(lambda a, b: cmp(a['package_id'], b['package_id']))
+
+ dumper = SatelliteDumperEx(writer,
+ ShortPackagesDumper(writer, package_ids))
+ dumper.dump()
+ writer.flush()
+ # We're done with the stream object
+ stream.close()
+ del stream
+ temp_stream.seek(0, 0)
+ # Set the value in the cache. We don't recompress the result since
+ # it's already compressed
+ rhnCache.set(key, temp_stream.read(), modified=last_modified,
+ compressed=0, raw=1)
+ return self._normalize_compressed_stream(temp_stream)
+
+ def _packages(self, packages, prefix, dump_class, sources=0):
+ if sources:
+ h = self.get_source_packages_statement()
+ else:
+ h = self.get_packages_statement()
+
+ packages_hash = {}
+ for package in packages:
+ package = str(package)
+ if package[:len(prefix)] != prefix:
+ raise rhnFault(3002, "Invalid package name %s" % package)
+ package_id = package[len(prefix):]
+ try:
+ package_id = int(package_id)
+ except ValueError:
+ raise rhnFault(3002, "Invalid package name %s" % package)
+ if packages_hash.has_key(package_id):
+ # Already verified
+ continue
+ h.execute(package_id=package_id)
+ row = h.fetchone_dict()
+ if not row:
+ # XXX Silently ignore it?
+ raise rhnFault(3003, "No such package %s" % package)
+ # Saving the row, it's handy later when we create the iterator
+ packages_hash[package_id] = row
+
+ writer = self._get_xml_writer()
+ dumper = SatelliteDumperEx(writer,
+ dump_class(writer, packages_hash.values()))
+ dumper.dump()
+ writer.flush()
+ log_debug(4, "OK")
+ self.close()
+ return 0
+
+ def dump_errata(self, errata):
+ log_debug(2)
+
+ h = self.get_errata_statement()
+
+ errata_hash = {}
+ prefix = 'rhn-erratum-'
+ for erratum in errata:
+ erratum = str(erratum)
+ if erratum[:len(prefix)] != prefix:
+ raise rhnFault(3004, "Wrong erratum name %s" % erratum)
+ errata_id = erratum[len(prefix):]
+ try:
+ errata_id = int(errata_id)
+ except ValueError:
+ raise rhnFault(3004, "Wrong erratum name %s" % erratum)
+ if errata_hash.has_key(errata_id):
+ # Already verified
+ continue
+ h.execute(errata_id=errata_id)
+ row = h.fetchone_dict()
+ if not row:
+ # XXX Silently ignore it?
+ raise rhnFault(3005, "No such erratum %s" % erratum)
+ # Saving the row, it's handy later when we create the iterator
+ errata_hash[errata_id] = row
+
+ writer = self._get_xml_writer()
+ dumper = SatelliteDumperEx(writer,
+ ErrataDumperEx(writer, errata_hash.values()))
+ dumper.dump()
+ writer.flush()
+ log_debug(4, "OK")
+ self.close()
+ return 0
+
+ def dump_kickstartable_trees(self, kickstart_labels=None):
+ log_debug(2)
+ kickstarts = self._validate_kickstarts(
+ kickstart_labels=kickstart_labels)
+
+ writer = self._get_xml_writer()
+ dumper = SatelliteDumperEx(writer,
+ KickstartableTreesDumper(writer, kickstarts=kickstarts))
+ dumper.dump()
+ writer.flush()
+ log_debug(4, "OK")
+ self.close()
+ return 0
+
+ def dump_product_names(self):
+ log_debug(4)
+ writer = self._get_xml_writer()
+ dumper = SatelliteDumperEx(writer, exportLib.ProductNamesDumper(writer))
+ dumper.dump()
+ writer.flush()
+ self.close()
+ return 0
+
class XML_Dumper:
def __init__(self):
self.compress_level = 5
@@ -194,12 +521,13 @@ class XML_Dumper:
self.close()
return 0
- def dump_server_group_type_server_arches(self, rpm_arch_type_only=0):
+ def dump_server_group_type_server_arches(self, rpm_arch_type_only=0,
+ virt_filter=0):
log_debug(2)
writer = self._get_xml_writer()
dumper = SatelliteDumper(writer,
exportLib.ServerGroupTypeServerArchCompatDumper(writer,
- rpm_arch_type_only=rpm_arch_type_only),
+ rpm_arch_type_only=rpm_arch_type_only, virt_filter=virt_filter),
)
dumper.dump()
writer.flush()
@@ -526,6 +854,13 @@ class XML_Dumper:
return result
+class SatelliteDumperEx(SatelliteDumper):
+ def set_attributes(self):
+ """ Overriding with our own version """
+ attributes = SatelliteDumper.set_attributes(self)
+ attributes['version'] = constants.PROTOCOL_VERSION
+ return attributes
+
class SatelliteDumper(exportLib.SatelliteDumper):
def set_attributes(self):
""" Overriding with our own version """
@@ -656,7 +991,7 @@ class CachedDumper(exportLib.BaseDumper):
return params['last_modified']
def _get_key(self, params):
- return "dummy"
+ raise NotImplementedError
def cache_get(self, params):
log_debug(4, params)
@@ -704,6 +1039,34 @@ class CachedDumper(exportLib.BaseDumper):
self.cache_set(params, s.getvalue())
+class ChannelsDumperEx(CachedDumper, exportLib.ChannelsDumper):
+ _query_list_channels = rhnSQL.Statement("""
+ select c.id, c.label, ca.label channel_arch, c.basedir, c.name,
+ c.summary, c.description, c.gpg_key_url, c.org_id,
+ TO_CHAR(c.last_modified, 'YYYYMMDDHH24MISS') last_modified,
+ c.channel_product_id,
+ pc.label parent_channel,
+ cp.product channel_product,
+ cp.version channel_product_version,
+ cp.beta channel_product_beta,
+ c.receiving_updates
+ from rhnChannel c, rhnChannelArch ca, rhnChannel pc, rhnChannelProduct cp
+ where c.id = :channel_id
+ and c.channel_arch_id = ca.id
+ and c.parent_channel = pc.id (+)
+ and c.channel_product_id = cp.id (+)
+ """)
+ def __init__(self, writer, channels):
+ h = rhnSQL.prepare(self._query_list_channels)
+ CachedDumper.__init__(self, writer, statement=h, params=channels)
+
+ def _get_key(self, params):
+ channel_id = params['channel_id']
+ return "xml-channels/rhn-channel-%d.xml" % channel_id
+
+ def _dump_subelement(self, data):
+ log_debug(6, data)
+ return exportLib.ChannelsDumper.dump_subelement(self, data)
class ChannelsDumper(CachedDumper, exportLib.ChannelsDumper):
_query_list_channels = rhnSQL.Statement("""
@@ -1018,7 +1381,7 @@ class SourcePackagesDumper(CachedDumper, exportLib.SourcePackagesDumper):
ps.package_size,
c.checksum md5sum,
TO_CHAR(ps.last_modified, 'YYYYMMDDHH24MISS') last_modified
- from rhnPackageSource ps, rhnPackageGroup pg, rhnSourceRPM sr
+ from rhnPackageSource ps, rhnPackageGroup pg, rhnSourceRPM sr,
rhnChecksum c, rhnChecksum sig
where ps.id = :package_id
and ps.package_group = pg.id
@@ -1037,6 +1400,38 @@ class SourcePackagesDumper(CachedDumper, exportLib.SourcePackagesDumper):
log_debug(6, data)
return exportLib.SourcePackagesDumper.dump_subelement(self, data)
+class ErrataDumperEx(CachedDumper, exportLib.ErrataSynopsisDumper):
+ def __init__(self, writer, errata):
+ h = rhnSQL.prepare("""
+ select
+ e.id,
+ e.advisory_name,
+ e.advisory,
+ e.advisory_type,
+ e.advisory_rel,
+ e.product,
+ e.description,
+ e.synopsis,
+ e.topic,
+ e.solution,
+ TO_CHAR(e.issue_date, 'YYYYMMDDHH24MISS') issue_date,
+ TO_CHAR(e.update_date, 'YYYYMMDDHH24MISS') update_date,
+ TO_CHAR(e.last_modified, 'YYYYMMDDHH24MISS') last_modified,
+ e.refers_to,
+ e.notes
+ from rhnErrata e
+ where e.id = :errata_id
+ """)
+ CachedDumper.__init__(self, writer, statement=h, params=errata)
+
+ def _get_key(self, params):
+ errata_id = params['errata_id']
+ hash_val = hash_object_id(errata_id, 10)
+ return "xml-errata/%s/rhn-erratum-%s.xml" % (hash_val, errata_id)
+
+ def _dump_subelement(self, data):
+ log_debug(6, data)
+ return exportLib.ErrataSynopsisDumper.dump_subelement(self, data)
class ErrataDumper(CachedDumper, exportLib.ErrataDumper):
def __init__(self, writer, errata):
14 years, 3 months
Changes to 'refs/tags/spacewalk-backend-0.8.15-1'
by Michael Mraka
Tag 'spacewalk-backend-0.8.15-1' created by Michael Mraka <michael.mraka(a)redhat.com> at 2010-01-05 12:21 +0000
Tagging package [spacewalk-backend] version [0.8.15-1] in directory [backend/].
Changes since spacewalk-utils-0.8.1-1:
Jan Pazdziora (14):
Do not point to rhn.redhat.com in emails sent by Spacewalk.
Do not confuse people by calling Spacewalk logins Red Hat logins.
install_types is not called, removing.
Removal of install_types makes KSTree_queries unused, removing.
Removal of pxtdb.conf and load_dsn_aliases made clear_aliases unused, removing.
reset_profiling is not called from anywhere, removing as dead code.
lookup_user_group is not called from anywhere, removing.
RHN::UserGroup was use'd but not used, removing, which makes RHN::DB::UserGroup obsolete as well, removing.
Methods set_zerombr, set_bootloader, get_bootloader, set_timezone, is_timezone_utc, and set_partition_info are not used, removing.
RHN::Kickstart's get_timezone not used anywhere, removing, together with @timezones and timezones.
RHN::Kickstart's render does not seem to be used anymore, removing, together with other render_ methods.
clear_exception_box and throw_generic are not used anywhere, removing.
We do not ship */rpc/api-exceptions/*.xml, so this code is noop, removing.
Remove the use RHN::API::Exception as well.
Michael Mraka (4):
merged satellite_exporter/exporter/dumper.py into satellite_tools/disk_dumper/dumper.py
deleted the rest of satellite_exporter/exporter directory
removed satellite_exporter/exporter from spec
Automatic commit of package [spacewalk-backend] release [0.8.15-1].
---
backend/satellite_exporter/Makefile | 2
backend/satellite_exporter/exporter/Makefile | 10
backend/satellite_exporter/exporter/__init__.py | 16
backend/satellite_exporter/exporter/dumper.py | 984 ---------------
backend/satellite_exporter/exporter/string_buffer.py | 52
backend/satellite_exporter/handlers/non_auth_dumper.py | 6
backend/satellite_tools/disk_dumper/dumper.py | 405 ++++++
backend/spacewalk-backend.spec | 10
rel-eng/packages/spacewalk-backend | 2
web/html/formletters/forgot_accounts.xml | 6
web/html/formletters/forgot_password.xml | 4
web/modules/pxt/PXT/ApacheHandler.pm | 12
web/modules/rhn/RHN/API/Exception.pm | 19
web/modules/rhn/RHN/DB.pm | 11
web/modules/rhn/RHN/DB/DataSource/xml/KSTree_queries.xml | 11
web/modules/rhn/RHN/DB/KSTree.pm | 7
web/modules/rhn/RHN/DB/UserGroup.pm | 253 ---
web/modules/rhn/RHN/Kickstart.pm | 591 ---------
web/modules/rhn/RHN/Postal.pm | 7
web/modules/rhn/RHN/UserGroup.pm | 47
web/modules/sniglets/Sniglets/ServerGroup.pm | 1
web/modules/sniglets/Sniglets/Users.pm | 1
22 files changed, 420 insertions(+), 2037 deletions(-)
---
14 years, 3 months
web/modules
by Jan Pazdziora
web/modules/pxt/PXT/ApacheHandler.pm | 1 -
1 file changed, 1 deletion(-)
New commits:
commit cbf419fb34b23d6937e9d41fff5f3057f8c8d4c8
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 12:57:20 2010 +0100
Remove the use RHN::API::Exception as well.
diff --git a/web/modules/pxt/PXT/ApacheHandler.pm b/web/modules/pxt/PXT/ApacheHandler.pm
index 9c8ba80..c72171c 100644
--- a/web/modules/pxt/PXT/ApacheHandler.pm
+++ b/web/modules/pxt/PXT/ApacheHandler.pm
@@ -43,7 +43,6 @@ use PXT::SoapRequest;
use PXT::XmlrpcRequest;
use RHN::Session;
use RHN::Exception;
-use RHN::API::Exception;
use RHN::API::Parser;
use RHN::I18N;
use RHN::Mail;
14 years, 3 months
5 commits - web/modules
by Jan Pazdziora
web/modules/pxt/PXT/ApacheHandler.pm | 11
web/modules/rhn/RHN/API/Exception.pm | 19 -
web/modules/rhn/RHN/Kickstart.pm | 591 -----------------------------------
3 files changed, 621 deletions(-)
New commits:
commit 8c9726c2aacf2d3c1e5cb625714f819b5a17083c
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 12:55:55 2010 +0100
We do not ship */rpc/api-exceptions/*.xml, so this code is noop, removing.
diff --git a/web/modules/pxt/PXT/ApacheHandler.pm b/web/modules/pxt/PXT/ApacheHandler.pm
index d68c800..9c8ba80 100644
--- a/web/modules/pxt/PXT/ApacheHandler.pm
+++ b/web/modules/pxt/PXT/ApacheHandler.pm
@@ -84,17 +84,6 @@ sub handler {
}
}
- # Load API exceptions
- my $exception_box = RHN::API::Exception->exception_box;
-
- if ($exception_box->is_empty) {
- my $path = File::Spec->catfile($request->document_root, "/rpc/api-exceptions/*.xml");
-
- foreach my $file (glob $path) {
- RHN::API::Parser->parse_exceptions($file);
- }
- }
-
my $filename = $r->filename;
my ($file_contents, $file_classes);
commit c5fa1dfe9ae89e2f3812c9dc6d8c7303baf6b26a
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 12:06:16 2010 +0100
clear_exception_box and throw_generic are not used anywhere, removing.
diff --git a/web/modules/rhn/RHN/API/Exception.pm b/web/modules/rhn/RHN/API/Exception.pm
index 0e65e53..29942b5 100644
--- a/web/modules/rhn/RHN/API/Exception.pm
+++ b/web/modules/rhn/RHN/API/Exception.pm
@@ -30,25 +30,6 @@ sub exception_box {
return $global_exception_box;
}
-sub clear_exception_box {
- my $class = shift;
-
- undef $global_exception_box;
-}
-
-sub throw_generic {
- my $class = shift;
- my $string = shift;
- my @extra = @_;
-
- my $exception = $class->new($string);
- $exception->{fault_code} = -1;
- $exception->{fault_text} = $string;
- $exception->{extra_data} = \@extra;
-
- $exception->SUPER::throw;
-}
-
sub throw_named {
my $class = shift;
my $string = shift;
commit 1ad6fc9ade1bbf08e95be373b57a2a3d68c03a85
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 11:58:37 2010 +0100
RHN::Kickstart's render does not seem to be used anymore, removing, together with other render_ methods.
diff --git a/web/modules/rhn/RHN/Kickstart.pm b/web/modules/rhn/RHN/Kickstart.pm
index d0f0d9e..b241029 100644
--- a/web/modules/rhn/RHN/Kickstart.pm
+++ b/web/modules/rhn/RHN/Kickstart.pm
@@ -25,80 +25,4 @@ our @ISA = qw/RHN::DB::Kickstart/;
use RHN::Kickstart::Commands;
use RHN::Kickstart::Packages;
-use RHN::SessionSwap;
-
-use PXT::Utils;
-
-our @simple_struct_fields = @RHN::DB::Kickstart::simple_struct_fields;
-
-sub render {
- my $self = shift;
-
- my $text = shift || <<EOQ;
-# Kickstart config file generated by RHN Config Management
-#
-# Profile Name: {kickstart_name}
-# Profile Label: {kickstart_label}
-#
-{kickstart_commands}
-
-%packages {kickstart_package_options}
-
-{kickstart_packages}
-
-%pre
-{kickstart_pre}
-
-{kickstart_interpreter_pre}
-
-%post --nochroot
-{kickstart_nochroot_post}
-
-{kickstart_interpreter_post}
-
-%post
-{kickstart_post}
-# end of generated kickstart file
-EOQ
-
- my %subs;
-
- $subs{"kickstart_${_}"} = $self->$_ foreach qw/name label pre post nochroot_post/;
- $subs{kickstart_commands} = $self->commands ? $self->commands->render : '# No commands section defined for kickstart profile';
- $subs{kickstart_package_options} = $self->render_package_options || '';
- $subs{kickstart_packages} = $self->packages->render || '';
- $subs{kickstart_interpreter_post} = $self->render_interpreter_post || '';
- $subs{kickstart_interpreter_pre} = $self->render_interpreter_pre || '';
-
- my $ret = PXT::Utils->perform_substitutions($text, \%subs);
-
- return $ret;
-}
-
-sub render_package_options {
- my $self = shift;
-
- my $options = join(" ", map { "--${_}" } @{$self->package_options}) || '';
-
- return $options;
-}
-
-sub render_interpreter_post {
- my $self = shift;
- my $post = '';
- $post = '%post --interpreter '
- . $self->interpreter_post_val
- . "\n" . $self->interpreter_post_script if $self->interpreter_post_val;
- return $post;
-}
-
-sub render_interpreter_pre {
- my $self = shift;
- my $pre = '';
- $pre = '%pre --interpreter '
- . $self->interpreter_pre_val
- . "\n" . $self->interpreter_pre_script if $self->interpreter_pre_val;
- return $pre;
-}
-
1;
commit 599206668c72e2ed64c4c24699cba4fb7f6efecc
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 11:49:24 2010 +0100
RHN::Kickstart's get_timezone not used anywhere, removing, together with @timezones and timezones.
diff --git a/web/modules/rhn/RHN/Kickstart.pm b/web/modules/rhn/RHN/Kickstart.pm
index 3502ec6..d0f0d9e 100644
--- a/web/modules/rhn/RHN/Kickstart.pm
+++ b/web/modules/rhn/RHN/Kickstart.pm
@@ -101,396 +101,4 @@ sub render_interpreter_pre {
return $pre;
}
-sub get_timezone {
- my $self = shift;
-
- return unless $self->commands;
-
- my $zn = $self->commands->timezone || '';
-
- my @opts = @{$zn};
- $zn = $opts[-1];
-
- return ( grep { $zn eq $_ } $self->timezones ) ? $zn : 'America/New_York';
-}
-
-my @timezones = qw|Europe/Andorra
-Asia/Dubai
-Asia/Kabul
-America/Antigua
-America/Anguilla
-Europe/Tirane
-Asia/Yerevan
-America/Curacao
-Africa/Luanda
-Antarctica/McMurdo
-Antarctica/South_Pole
-Antarctica/Palmer
-Antarctica/Mawson
-Antarctica/Davis
-Antarctica/Casey
-Antarctica/Vostok
-Antarctica/DumontDUrville
-Antarctica/Syowa
-America/Buenos_Aires
-America/Cordoba
-America/Jujuy
-America/Catamarca
-America/Mendoza
-Pacific/Pago_Pago
-Europe/Vienna
-Australia/Lord_Howe
-Australia/Hobart
-Australia/Melbourne
-Australia/Sydney
-Australia/Broken_Hill
-Australia/Brisbane
-Australia/Lindeman
-Australia/Adelaide
-Australia/Darwin
-Australia/Perth
-America/Aruba
-Asia/Baku
-Europe/Sarajevo
-America/Barbados
-Asia/Dhaka
-Europe/Brussels
-Africa/Ouagadougou
-Europe/Sofia
-Asia/Bahrain
-Africa/Bujumbura
-Africa/Porto-Novo
-Atlantic/Bermuda
-Asia/Brunei
-America/La_Paz
-America/Noronha
-America/Belem
-America/Fortaleza
-America/Recife
-America/Araguaina
-America/Maceio
-America/Sao_Paulo
-America/Cuiaba
-America/Porto_Velho
-America/Boa_Vista
-America/Manaus
-America/Eirunepe
-America/Rio_Branco
-America/Nassau
-Asia/Thimphu
-Africa/Gaborone
-Europe/Minsk
-America/Belize
-America/St_Johns
-America/Halifax
-America/Glace_Bay
-America/Goose_Bay
-America/Montreal
-America/Nipigon
-America/Thunder_Bay
-America/Pangnirtung
-America/Iqaluit
-America/Rankin_Inlet
-America/Winnipeg
-America/Rainy_River
-America/Cambridge_Bay
-America/Regina
-America/Swift_Current
-America/Edmonton
-America/Yellowknife
-America/Inuvik
-America/Dawson_Creek
-America/Vancouver
-America/Whitehorse
-America/Dawson
-Indian/Cocos
-Africa/Kinshasa
-Africa/Lubumbashi
-Africa/Bangui
-Africa/Brazzaville
-Europe/Zurich
-Africa/Abidjan
-Pacific/Rarotonga
-America/Santiago
-Pacific/Easter
-Africa/Douala
-Asia/Shanghai
-Asia/Harbin
-Asia/Chongqing
-Asia/Urumqi
-Asia/Kashgar
-America/Bogota
-America/Costa_Rica
-America/Havana
-Atlantic/Cape_Verde
-Indian/Christmas
-Asia/Nicosia
-Europe/Prague
-Europe/Berlin
-Africa/Djibouti
-Europe/Copenhagen
-America/Dominica
-America/Santo_Domingo
-Africa/Algiers
-America/Guayaquil
-Pacific/Galapagos
-Europe/Tallinn
-Africa/Cairo
-Africa/El_Aaiun
-Africa/Asmera
-Europe/Madrid
-Africa/Ceuta
-Atlantic/Canary
-Africa/Addis_Ababa
-Europe/Helsinki
-Pacific/Fiji
-Atlantic/Stanley
-Pacific/Yap
-Pacific/Truk
-Pacific/Ponape
-Pacific/Kosrae
-Atlantic/Faeroe
-Europe/Paris
-Africa/Libreville
-Europe/London
-Europe/Belfast
-America/Grenada
-Asia/Tbilisi
-America/Cayenne
-Africa/Accra
-Europe/Gibraltar
-America/Godthab
-America/Danmarkshavn
-America/Scoresbysund
-America/Thule
-Africa/Banjul
-Africa/Conakry
-America/Guadeloupe
-Africa/Malabo
-Europe/Athens
-Atlantic/South_Georgia
-America/Guatemala
-Pacific/Guam
-Africa/Bissau
-America/Guyana
-Asia/Hong_Kong
-America/Tegucigalpa
-Europe/Zagreb
-America/Port-au-Prince
-Europe/Budapest
-Asia/Jakarta
-Asia/Pontianak
-Asia/Makassar
-Asia/Jayapura
-Europe/Dublin
-Asia/Jerusalem
-Asia/Calcutta
-Indian/Chagos
-Asia/Baghdad
-Asia/Tehran
-Atlantic/Reykjavik
-Europe/Rome
-America/Jamaica
-Asia/Amman
-Asia/Tokyo
-Africa/Nairobi
-Asia/Bishkek
-Asia/Phnom_Penh
-Pacific/Tarawa
-Pacific/Enderbury
-Pacific/Kiritimati
-Indian/Comoro
-America/St_Kitts
-Asia/Pyongyang
-Asia/Seoul
-Asia/Kuwait
-America/Cayman
-Asia/Almaty
-Asia/Qyzylorda
-Asia/Aqtobe
-Asia/Aqtau
-Asia/Oral
-Asia/Vientiane
-Asia/Beirut
-America/St_Lucia
-Europe/Vaduz
-Asia/Colombo
-Africa/Monrovia
-Africa/Maseru
-Europe/Vilnius
-Europe/Luxembourg
-Europe/Riga
-Africa/Tripoli
-Africa/Casablanca
-Europe/Monaco
-Europe/Chisinau
-Indian/Antananarivo
-Pacific/Majuro
-Pacific/Kwajalein
-Europe/Skopje
-Africa/Bamako
-Africa/Timbuktu
-Asia/Rangoon
-Asia/Ulaanbaatar
-Asia/Hovd
-Asia/Choibalsan
-Asia/Macau
-Pacific/Saipan
-America/Martinique
-Africa/Nouakchott
-America/Montserrat
-Europe/Malta
-Indian/Mauritius
-Indian/Maldives
-Africa/Blantyre
-America/Mexico_City
-America/Cancun
-America/Merida
-America/Monterrey
-America/Mazatlan
-America/Chihuahua
-America/Hermosillo
-America/Tijuana
-Asia/Kuala_Lumpur
-Asia/Kuching
-Africa/Maputo
-Africa/Windhoek
-Pacific/Noumea
-Africa/Niamey
-Pacific/Norfolk
-Africa/Lagos
-America/Managua
-Europe/Amsterdam
-Europe/Oslo
-Asia/Katmandu
-Pacific/Nauru
-Pacific/Niue
-Pacific/Auckland
-Pacific/Chatham
-Asia/Muscat
-America/Panama
-America/Lima
-Pacific/Tahiti
-Pacific/Marquesas
-Pacific/Gambier
-Pacific/Port_Moresby
-Asia/Manila
-Asia/Karachi
-Europe/Warsaw
-America/Miquelon
-Pacific/Pitcairn
-America/Puerto_Rico
-Asia/Gaza
-Europe/Lisbon
-Atlantic/Madeira
-Atlantic/Azores
-Pacific/Palau
-America/Asuncion
-Asia/Qatar
-Indian/Reunion
-Europe/Bucharest
-Europe/Kaliningrad
-Europe/Moscow
-Europe/Samara
-Asia/Yekaterinburg
-Asia/Omsk
-Asia/Novosibirsk
-Asia/Krasnoyarsk
-Asia/Irkutsk
-Asia/Yakutsk
-Asia/Vladivostok
-Asia/Sakhalin
-Asia/Magadan
-Asia/Kamchatka
-Asia/Anadyr
-Africa/Kigali
-Asia/Riyadh
-Pacific/Guadalcanal
-Indian/Mahe
-Africa/Khartoum
-Europe/Stockholm
-Asia/Singapore
-Atlantic/St_Helena
-Europe/Ljubljana
-Arctic/Longyearbyen
-Atlantic/Jan_Mayen
-Europe/Bratislava
-Africa/Freetown
-Europe/San_Marino
-Africa/Dakar
-Africa/Mogadishu
-America/Paramaribo
-Africa/Sao_Tome
-America/El_Salvador
-Asia/Damascus
-Africa/Mbabane
-America/Grand_Turk
-Africa/Ndjamena
-Indian/Kerguelen
-Africa/Lome
-Asia/Bangkok
-Asia/Dushanbe
-Pacific/Fakaofo
-Asia/Ashgabat
-Africa/Tunis
-Pacific/Tongatapu
-Asia/Dili
-Europe/Istanbul
-America/Port_of_Spain
-Pacific/Funafuti
-Asia/Taipei
-Africa/Dar_es_Salaam
-Europe/Kiev
-Europe/Uzhgorod
-Europe/Zaporozhye
-Europe/Simferopol
-Africa/Kampala
-Pacific/Johnston
-Pacific/Midway
-Pacific/Wake
-America/New_York
-America/Detroit
-America/Louisville
-America/Kentucky/Monticello
-America/Indianapolis
-America/Indiana/Marengo
-America/Indiana/Knox
-America/Indiana/Vevay
-America/Chicago
-America/Menominee
-America/North_Dakota/Center
-America/Denver
-America/Boise
-America/Shiprock
-America/Phoenix
-America/Los_Angeles
-America/Anchorage
-America/Juneau
-America/Yakutat
-America/Nome
-America/Adak
-Pacific/Honolulu
-America/Montevideo
-Asia/Samarkand
-Asia/Tashkent
-Europe/Vatican
-America/St_Vincent
-America/Caracas
-America/Tortola
-America/St_Thomas
-Asia/Saigon
-Pacific/Efate
-Pacific/Wallis
-Pacific/Apia
-Asia/Aden
-Indian/Mayotte
-Europe/Belgrade
-Africa/Johannesburg
-Africa/Lusaka
-Africa/Harare|;
-
-sub timezones {
- return @timezones;
-}
-
1;
commit 8345fd06ed953e2b48874b0baa7de8c516089283
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 11:46:35 2010 +0100
Methods set_zerombr, set_bootloader, get_bootloader, set_timezone, is_timezone_utc, and set_partition_info are not used, removing.
diff --git a/web/modules/rhn/RHN/Kickstart.pm b/web/modules/rhn/RHN/Kickstart.pm
index a86a3f0..3502ec6 100644
--- a/web/modules/rhn/RHN/Kickstart.pm
+++ b/web/modules/rhn/RHN/Kickstart.pm
@@ -101,77 +101,6 @@ sub render_interpreter_pre {
return $pre;
}
-sub set_zerombr {
- my $self = shift;
- my $on = shift;
-
- return unless $self->commands;
-
- if (defined $on and $on ne 'no') {
- $self->commands->set(zerombr => 'yes');
- }
- else {
- $self->commands->unset('zerombr');
- }
-
- return;
-}
-
-sub set_bootloader {
- my $self = shift;
- my %params = validate(@_, { bootloader => 1, append => 0, driveorder => 0, location => 0,
- password => 0, md5pass => 0, upgrade => 0 });
-
- return unless $self->commands;
-
- my $location = $params{location} ? $params{location} : 'mbr';
- $location = 'mbr' unless (grep { $location eq $_ } qw/mbr partition none/);
- $location = '--location ' . $location;
-
- my $uselilo = ($params{bootloader} eq 'lilo') ? '--useLilo ' : '';
-
- my $extra;
-
- foreach my $key (qw/append driveorder password md5pass upgrade/) {
- if ($params{$key}) {
- $extra .= "--$key $params{$key}";
- }
- elsif (exists $params{$key}) {
- $extra .= "--$key";
- }
- }
-
- $extra = " " . $extra if $extra;
-
- $self->commands->bootloader("${uselilo}${location}${extra}");
-
- return;
-}
-
-sub get_bootloader {
- my $self = shift;
-
- return unless $self->commands;
-
- my $bl = $self->commands->bootloader;
- my @opts = @{$bl};
- return (grep { $_ =~ /lilo/i } @opts) ? 'lilo' : 'grub';
-}
-
-sub set_timezone {
- my $self = shift;
- my %params = validate(@_, { zone => 1, hardware_utc => 0 });
-
- return unless $self->commands;
-
- $params{zone} = 'America/New_York' unless (grep { $params{zone} eq $_ } $self->timezones);
- my $utc = $params{hardware_utc} ? '--utc ' : '';
-
- $self->commands->timezone($utc . $params{zone});
-
- return;
-}
-
sub get_timezone {
my $self = shift;
@@ -185,58 +114,6 @@ sub get_timezone {
return ( grep { $zn eq $_ } $self->timezones ) ? $zn : 'America/New_York';
}
-sub is_timezone_utc {
- my $self = shift;
-
- return unless $self->commands;
-
- my $zn = $self->commands->timezone || '';
-
- foreach my $opt (@{$zn}) {
- return 1 if ($opt eq '--utc');
- }
-
- return;
-}
-
-sub set_partition_info {
- my $self = shift;
- my %params = validate(@_, { parts => 1 });
-
- return unless $self->commands;
- my (@parts, @raids, @volgroups, @logvols, @include);
- foreach my $line (split /\n/, $params{parts}) {
- if ($line =~ /^part\S*\s+(.*)$/) {
- my $part = $1;
- push @parts, [ split /\s+/, $part ];
- }
- elsif ($line =~ /^raid\s+(.*)$/) {
- my $raid = $1;
- push @raids, [ split /\s+/, $raid ];
- }
- elsif ($line =~ /^volgroup\s+(.*)$/) {
- my $group = $1;
- push @volgroups, [ split /\s+/, $group ];
- }
- elsif ($line =~ /^logvol\s+(.*)$/) {
- my $vol = $1;
- push @logvols, [ split /\s+/, $vol ];
- }
- elsif ($line =~ /^\%?include\s+(.*)$/) {
- my $inc = $1;
- push @include, [ split /\s+/, $inc];
- }
- }
-
- $self->commands->partitions(new RHN::Kickstart::Partitions(@parts));
- $self->commands->raids(new RHN::Kickstart::Raids(@raids));
- $self->commands->volgroups(new RHN::Kickstart::Volgroups(@volgroups));
- $self->commands->logvols(new RHN::Kickstart::Logvols(@logvols));
- $self->commands->include(new RHN::Kickstart::Include(@include));
-
- return;
-}
-
my @timezones = qw|Europe/Andorra
Asia/Dubai
Asia/Kabul
14 years, 3 months