backend/common/rhnLib.py | 2
backend/satellite_exporter/handlers/non_auth_dumper.py | 362 -----------------
backend/satellite_tools/disk_dumper/dumper.py | 10
schema/spacewalk/common/tables/tables.deps | 5
4 files changed, 8 insertions(+), 371 deletions(-)
New commits:
commit cd0037f54ecaf3b590afc087ba5a0fb8396373a1
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri May 28 22:58:47 2010 +0200
fixed AttributeError: 'int' object has no attribute 'split'
diff --git a/backend/satellite_tools/disk_dumper/dumper.py
b/backend/satellite_tools/disk_dumper/dumper.py
index 61c915f..67f49dd 100644
--- a/backend/satellite_tools/disk_dumper/dumper.py
+++ b/backend/satellite_tools/disk_dumper/dumper.py
@@ -1327,7 +1327,7 @@ class ShortPackagesDumper(CachedDumper,
exportLib.ShortPackagesDumper):
CachedDumper.__init__(self, writer, statement=h, params=packages)
def _get_key(self, params):
- package_id = params['package_id']
+ package_id = str(params['package_id'])
hash_val = rhnLib.hash_object_id(package_id, 2)
return "xml-short-packages/%s/rhn-package-short-%s.xml" % (
hash_val, package_id)
@@ -1381,7 +1381,7 @@ class PackagesDumper(CachedDumper, exportLib.PackagesDumper):
CachedDumper.__init__(self, writer, statement=h, params=packages)
def _get_key(self, params):
- package_id = params['package_id']
+ package_id = str(params['package_id'])
hash_val = rhnLib.hash_object_id(package_id, 2)
return "xml-packages/%s/rhn-package-%s.xml" % (hash_val, package_id)
@@ -1419,7 +1419,7 @@ class SourcePackagesDumper(CachedDumper,
exportLib.SourcePackagesDumper):
CachedDumper.__init__(self, writer, statement=h, params=packages)
def _get_key(self, params):
- package_id = params['package_id']
+ package_id = str(params['package_id'])
hash_val = rhnLib.hash_object_id(package_id, 2)
return "xml-packages/%s/rhn-source-package-%s.xml" % (hash_val,
package_id)
@@ -1453,7 +1453,7 @@ class ErrataDumper(CachedDumper, exportLib.ErrataDumper):
CachedDumper.__init__(self, writer, statement=h, params=errata)
def _get_key(self, params):
- errata_id = params['errata_id']
+ errata_id = str(params['errata_id'])
hash_val = rhnLib.hash_object_id(errata_id, 1)
return "xml-errata/%s/rhn-erratum-%s.xml" % (hash_val, errata_id)
@@ -1487,7 +1487,7 @@ class ErrataDumperEx(CachedDumper, exportLib.ErrataSynopsisDumper):
CachedDumper.__init__(self, writer, statement=h, params=errata)
def _get_key(self, params):
- errata_id = params['errata_id']
+ errata_id = str(params['errata_id'])
hash_val = rhnLib.hash_object_id(errata_id, 1)
return "xml-errata/%s/rhn-erratum-%s.xml" % (hash_val, errata_id)
commit 6de0b98d21b3c6f7b7a47c25ef35126846624ee1
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri May 28 22:51:04 2010 +0200
fixed TypeError: hash_object_id() takes exactly 3 arguments (2 given)
diff --git a/backend/common/rhnLib.py b/backend/common/rhnLib.py
index 0905f9b..752cc38 100644
--- a/backend/common/rhnLib.py
+++ b/backend/common/rhnLib.py
@@ -172,7 +172,7 @@ def fix_url(url, scheme="http", path="/"):
_fragment))
return url
-def hash_object_id(self, object_id, factor):
+def hash_object_id(object_id, factor):
"""Given an object id (assumed to be <label>-<number>),
returns the
last few digits for the number. For instance, (812345, 3) should
return 345"""
commit ff5c842964d193027194431cfe5bddc8e02a40ee
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri May 28 16:29:16 2010 +0200
list_minus() not used anywhere
diff --git a/backend/satellite_exporter/handlers/non_auth_dumper.py
b/backend/satellite_exporter/handlers/non_auth_dumper.py
index 220e2f0..e4fcd31 100644
--- a/backend/satellite_exporter/handlers/non_auth_dumper.py
+++ b/backend/satellite_exporter/handlers/non_auth_dumper.py
@@ -511,23 +511,6 @@ class ChannelsDumper(exportLib.ChannelsDumper):
except:
raise
-def list_minus(l1, l2, comp_func=lambda x: x):
- """
- Returns l1 minus l2, comparing each item of l1 and l2 after filtering
- them through comp_func
- """
- h = {}
- for i in l2:
- index = comp_func(i)
- h[index] = i
-
- ret = []
- for i in l1:
- index = comp_func(i)
- if not h.has_key(index):
- ret.append(i)
- return ret
-
_query_lookup_last_modified_packages = rhnSQL.Statement("""
select TO_CHAR(last_modified, 'YYYY-MM-DD HH24:MI:SS') last_modified
from rhnPackage
commit d5f2a6d1e943572cb7146f728ab959cbf1028d6b
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri May 28 16:13:26 2010 +0200
removed empty _ChannelSnapshotter()
diff --git a/backend/satellite_exporter/handlers/non_auth_dumper.py
b/backend/satellite_exporter/handlers/non_auth_dumper.py
index d339f59..220e2f0 100644
--- a/backend/satellite_exporter/handlers/non_auth_dumper.py
+++ b/backend/satellite_exporter/handlers/non_auth_dumper.py
@@ -505,15 +505,12 @@ class ChannelsDumper(exportLib.ChannelsDumper):
return dumper.QueryIterator(statement=h, params=self._channels)
def dump_subelement(self, data):
- c = _ChannelSnapshotter(self._writer, data)
+ c = exportLib.ChannelDumper(self._writer, data)
try:
c.dump()
except:
raise
-class _ChannelSnapshotter(exportLib.ChannelDumper):
- pass
-
def list_minus(l1, l2, comp_func=lambda x: x):
"""
Returns l1 minus l2, comparing each item of l1 and l2 after filtering
commit 0c9879e8361461b1d981f0323a02567cb77aa6aa
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri May 28 16:10:46 2010 +0200
_query_lookup_last_modified_errata() not used anywhere
diff --git a/backend/satellite_exporter/handlers/non_auth_dumper.py
b/backend/satellite_exporter/handlers/non_auth_dumper.py
index 8d95ca3..d339f59 100644
--- a/backend/satellite_exporter/handlers/non_auth_dumper.py
+++ b/backend/satellite_exporter/handlers/non_auth_dumper.py
@@ -546,21 +546,6 @@ def _lookup_last_modified_packages(package_ids):
ret.append((pid, row['last_modified']))
return ret
-_query_lookup_last_modified_errata = rhnSQL.Statement("""
- select TO_CHAR(last_modified, 'YYYY-MM-DD HH24:MI:SS') last_modified
- from rhnErrata
- where id = :id
-""")
-def _lookup_last_modified_errata(errata_ids):
- h = rhnSQL.prepare(_query_lookup_last_modified_errata)
- ret = []
- for eid in errata_ids:
- h.execute(id=eid)
- row = h.fetchone_dict()
- assert row, "Invalid errata id %s" % eid
- ret.append((eid, row['last_modified']))
- return ret
-
_query_lookup_last_modified_ks_trees = rhnSQL.Statement("""
select TO_CHAR(kt.last_modified, 'YYYY-MM-DD HH24:MI:SS') last_modified
from rhnKickstartableTree kt, rhnChannel c
commit 9dd317a466a36ede6454146a1f528edf775420a5
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri May 28 16:07:59 2010 +0200
_ChannelDumper is dead since removal of snapshot from ChannelDumper
diff --git a/backend/satellite_exporter/handlers/non_auth_dumper.py
b/backend/satellite_exporter/handlers/non_auth_dumper.py
index 3ead30f..8d95ca3 100644
--- a/backend/satellite_exporter/handlers/non_auth_dumper.py
+++ b/backend/satellite_exporter/handlers/non_auth_dumper.py
@@ -514,109 +514,6 @@ class ChannelsDumper(exportLib.ChannelsDumper):
class _ChannelSnapshotter(exportLib.ChannelDumper):
pass
-class _ChannelDumper(exportLib.ChannelDumper):
- def __init__(self, writer, data, snapshot, incremental=0):
- exportLib.ChannelDumper.__init__(self, writer, data)
- self.snapshot = snapshot
- assert self.snapshot is not None, \
- "Programmer error: wrong class for snapshotting"
- self.channel_id = None
- self.channel_label = None
- self.snapshot_id = None
- self.snapshot_channel_id = None
- self.incremental = incremental
- # Initialize snapshot_id and snapshot_channel_id
- self.init()
- log_debug(4, snapshot, incremental, self.snapshot_id,
- self.snapshot_channel_id)
-
- def init(self):
- self.channel_id = self._row['id']
- self.channel_label = self._row['label']
- h = rhnSQL.prepare(self._query_get_snapshot_ids)
- h.execute(snapshot=self.snapshot, channel_id=self.channel_id)
- row = h.fetchone_dict()
- self.snapshot_id = row['snapshot_id']
- self.snapshot_channel_id = row['snapshot_channel_id']
- self._all_packages = None
-
- def set_attributes(self):
- ret = exportLib.ChannelDumper.set_attributes(self)
-
- if self.incremental:
- # create all-packages
- # self._get_package_ids() will populate self._all_packages
- all_packages = [ "rhn-package-%s" % x for x in self._all_packages
]
- ret['all-packages'] = " ".join(all_packages)
- return ret
-
- def _get_package_ids(self):
- # this function has a side-effect of populating self._all_packages
- # if we are doing an incremental
- # It will return:
- # - all packages in the snapshot if we are trying to generate a
- # baseline
- # - all packages in the channel minus all packages in the snapshot if
- # we are generating an incremental
-
- snapshot_packages = self.__get_snapshot_packages()
- if not self.incremental:
- # All we need is the snapshotted packages
- # Drop last_modified
- return [ x[0] for x in snapshot_packages ]
-
- # Get a list of all packages in this channel
- self._all_packages = exportLib.ChannelDumper._get_package_ids(self)
- all_packages = _lookup_last_modified_packages(self._all_packages)
-
- # need to return self._all_packages minus snapshot_packages
- minus = list_minus(all_packages, snapshot_packages)
- return [ x[0] for x in minus ]
-
- def __get_statement_data(self, statement):
- h = rhnSQL.prepare(statement)
- h.execute(snapshot_channel_id=self.snapshot_channel_id)
- data = h.fetchall()
- data.sort()
- return data
-
- def _get_cursor_source_packages(self):
- snapshot_source_packages = self.__get_snapshot_source_packages()
- if not self.incremental:
- # If a baseline, return objects from snapshot
- return exportLib.ArrayIterator(snapshot_source_packages)
-
- h = exportLib.ChannelDumper._get_cursor_source_packages(self)
- all_source_packages = h.fetchall_dict() or []
-
- new_objs = list_minus(all_source_packages, snapshot_source_packages,
- lambda x: (x['id'], x['last_modified']))
- return exportLib.ArrayIterator(new_objs)
-
- def _get_errata_ids(self):
- snapshot_errata = self.__get_snapshot_errata()
- if not self.incremental:
- # If a baseline, return objects from snapshot
- return [ x[0] for x in snapshot_errata ]
-
- all_errata = exportLib.ChannelDumper._get_errata_ids(self)
- all_errata = _lookup_last_modified_errata(all_errata)
- minus = list_minus(all_errata, snapshot_errata)
- return [ x[0] for x in minus ]
-
- def _get_kickstartable_trees(self):
- snapshot_ks_trees = self.__get_snapshot_ks_tree()
- if not self.incremental:
- # If a baseline, return objects from snapshot
- return [ x[0] for x in snapshot_ks_trees ]
-
- all_ks_trees = exportLib.ChannelDumper._get_kickstartable_trees(self)
- all_ks_trees = _lookup_last_modified_ks_trees(self.channel_label,
- all_ks_trees)
-
- minus = list_minus(all_ks_trees, snapshot_ks_trees)
- return [ x[0] for x in minus ]
-
def list_minus(l1, l2, comp_func=lambda x: x):
"""
Returns l1 minus l2, comparing each item of l1 and l2 after filtering
commit 9638acfa075859ba660212ca0bc3c01ee435d0ed
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri May 28 16:05:05 2010 +0200
nobody pass snapshot or incremental to ChannelsDumper(), removing
diff --git a/backend/satellite_exporter/handlers/non_auth_dumper.py
b/backend/satellite_exporter/handlers/non_auth_dumper.py
index c77386e..3ead30f 100644
--- a/backend/satellite_exporter/handlers/non_auth_dumper.py
+++ b/backend/satellite_exporter/handlers/non_auth_dumper.py
@@ -490,12 +490,10 @@ class ContainerWriter:
# based on the creation date
# XXX No caching for now
class ChannelsDumper(exportLib.ChannelsDumper):
- def __init__(self, writer, channels, snapshot=None, incremental=0):
+ def __init__(self, writer, channels)
# if snapshot is None, then all the objects from the channel are
# returned - this is useful for snapshotting
exportLib.ChannelsDumper.__init__(self, writer, channels)
- self.snapshot = snapshot
- self.incremental = incremental
def set_iterator(self):
if not self._channels:
@@ -507,11 +505,7 @@ class ChannelsDumper(exportLib.ChannelsDumper):
return dumper.QueryIterator(statement=h, params=self._channels)
def dump_subelement(self, data):
- if self.snapshot:
- c = _ChannelDumper(self._writer, data, self.snapshot,
- self.incremental)
- else:
- c = _ChannelSnapshotter(self._writer, data)
+ c = _ChannelSnapshotter(self._writer, data)
try:
c.dump()
except:
commit e737a41088953b6857d9b5bbf417ee1b9cc4c934
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri May 28 15:46:13 2010 +0200
__get_snapshot_ks_tree() is dead since _query_get_snapshot_ks_tree
removal
diff --git a/backend/satellite_exporter/handlers/non_auth_dumper.py
b/backend/satellite_exporter/handlers/non_auth_dumper.py
index 10fe2f9..c77386e 100644
--- a/backend/satellite_exporter/handlers/non_auth_dumper.py
+++ b/backend/satellite_exporter/handlers/non_auth_dumper.py
@@ -586,9 +586,6 @@ class _ChannelDumper(exportLib.ChannelDumper):
data.sort()
return data
- def __get_snapshot_ks_tree(self):
- return self.__get_statement_data(self._query_get_snapshot_ks_tree)
-
def _get_cursor_source_packages(self):
snapshot_source_packages = self.__get_snapshot_source_packages()
if not self.incremental:
commit 847d5814f05dcd66cc00a88024b8230fcc258e2b
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri May 28 15:45:30 2010 +0200
__get_snapshot_errata() is dead since _query_get_snapshot_errata removal
diff --git a/backend/satellite_exporter/handlers/non_auth_dumper.py
b/backend/satellite_exporter/handlers/non_auth_dumper.py
index 53309f5..10fe2f9 100644
--- a/backend/satellite_exporter/handlers/non_auth_dumper.py
+++ b/backend/satellite_exporter/handlers/non_auth_dumper.py
@@ -586,9 +586,6 @@ class _ChannelDumper(exportLib.ChannelDumper):
data.sort()
return data
- def __get_snapshot_errata(self):
- return self.__get_statement_data(self._query_get_snapshot_errata)
-
def __get_snapshot_ks_tree(self):
return self.__get_statement_data(self._query_get_snapshot_ks_tree)
commit 46467eb01e248acbdb90b137af92c569fc86e7d7
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri May 28 15:44:55 2010 +0200
__get_snapshot_source_packages() is dead since _query_get_snapshot_source_packages
removal
diff --git a/backend/satellite_exporter/handlers/non_auth_dumper.py
b/backend/satellite_exporter/handlers/non_auth_dumper.py
index 854c1d2..53309f5 100644
--- a/backend/satellite_exporter/handlers/non_auth_dumper.py
+++ b/backend/satellite_exporter/handlers/non_auth_dumper.py
@@ -586,12 +586,6 @@ class _ChannelDumper(exportLib.ChannelDumper):
data.sort()
return data
- def __get_snapshot_source_packages(self):
- h = rhnSQL.prepare(self._query_get_snapshot_source_packages)
- h.execute(snapshot_channel_id=self.snapshot_channel_id)
- data = h.fetchall_dict() or []
- return data
-
def __get_snapshot_errata(self):
return self.__get_statement_data(self._query_get_snapshot_errata)
commit bef2edea7d580c77313f2cbd2a49a972fb8c5b05
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri May 28 15:43:53 2010 +0200
__get_snapshot_packages() is dead since _query_get_snapshot_packages removal
diff --git a/backend/satellite_exporter/handlers/non_auth_dumper.py
b/backend/satellite_exporter/handlers/non_auth_dumper.py
index 81f1300..854c1d2 100644
--- a/backend/satellite_exporter/handlers/non_auth_dumper.py
+++ b/backend/satellite_exporter/handlers/non_auth_dumper.py
@@ -586,9 +586,6 @@ class _ChannelDumper(exportLib.ChannelDumper):
data.sort()
return data
- def __get_snapshot_packages(self):
- return self.__get_statement_data(self._query_get_snapshot_packages)
-
def __get_snapshot_source_packages(self):
h = rhnSQL.prepare(self._query_get_snapshot_source_packages)
h.execute(snapshot_channel_id=self.snapshot_channel_id)
commit e6ac61ec5dd7b9f070d2e2ac7b69e1811725cded
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri May 28 15:43:08 2010 +0200
_snapshot_channel_ks_trees() is dead since _query_snapshot_channel_ks_trees removal
diff --git a/backend/satellite_exporter/handlers/non_auth_dumper.py
b/backend/satellite_exporter/handlers/non_auth_dumper.py
index 30d5e67..81f1300 100644
--- a/backend/satellite_exporter/handlers/non_auth_dumper.py
+++ b/backend/satellite_exporter/handlers/non_auth_dumper.py
@@ -206,13 +206,6 @@ class NonAuthenticatedDumper(rhnHandler, dumper.XML_DumperEx):
h.executemany(snapshot_channel_id=snapshot_channel_ids,
obj_id=obj_ids, last_modified=last_modifieds)
- def _snapshot_channel_ks_trees(self, channels, channel_data):
- self._do_snapshot('ks_trees', channels, channel_data,
- self._query_snapshot_channel_ks_trees,
- with_channels=1)
- return {}
-
-
def arches(self):
return self.dump_arches(rpm_arch_type_only=1)
commit a341a0b66ec37bc0ff6731c82c7b6ba8ffc71ca7
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri May 28 15:42:31 2010 +0200
_snapshot_channel_errata() is dead since _query_snapshot_channel_errata removal
diff --git a/backend/satellite_exporter/handlers/non_auth_dumper.py
b/backend/satellite_exporter/handlers/non_auth_dumper.py
index 85cd8d3..30d5e67 100644
--- a/backend/satellite_exporter/handlers/non_auth_dumper.py
+++ b/backend/satellite_exporter/handlers/non_auth_dumper.py
@@ -206,11 +206,6 @@ class NonAuthenticatedDumper(rhnHandler, dumper.XML_DumperEx):
h.executemany(snapshot_channel_id=snapshot_channel_ids,
obj_id=obj_ids, last_modified=last_modifieds)
- def _snapshot_channel_errata(self, channels, channel_data):
- self._do_snapshot('errata', channels, channel_data,
- self._query_snapshot_channel_errata)
- return {}
-
def _snapshot_channel_ks_trees(self, channels, channel_data):
self._do_snapshot('ks_trees', channels, channel_data,
self._query_snapshot_channel_ks_trees,
commit 64726e217e49544ed0f2c1d360e089bf683d6353
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri May 28 15:41:44 2010 +0200
_snapshot_channel_package_sources() is dead since
_query_snapshot_channel_source_packages removal
diff --git a/backend/satellite_exporter/handlers/non_auth_dumper.py
b/backend/satellite_exporter/handlers/non_auth_dumper.py
index 26ac75d..85cd8d3 100644
--- a/backend/satellite_exporter/handlers/non_auth_dumper.py
+++ b/backend/satellite_exporter/handlers/non_auth_dumper.py
@@ -206,11 +206,6 @@ class NonAuthenticatedDumper(rhnHandler, dumper.XML_DumperEx):
h.executemany(snapshot_channel_id=snapshot_channel_ids,
obj_id=obj_ids, last_modified=last_modifieds)
- def _snapshot_channel_package_sources(self, channels, channel_data):
- self._do_snapshot('source_packages', channels, channel_data,
- self._query_snapshot_channel_source_packages)
- return {}
-
def _snapshot_channel_errata(self, channels, channel_data):
self._do_snapshot('errata', channels, channel_data,
self._query_snapshot_channel_errata)
commit 90d5cc966bfc31f496a45264cbc3cdeeb674e395
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri May 28 15:40:43 2010 +0200
_snapshot_channel_packages() is dead since _query_snapshot_channel_packages removal
diff --git a/backend/satellite_exporter/handlers/non_auth_dumper.py
b/backend/satellite_exporter/handlers/non_auth_dumper.py
index 20fe651..26ac75d 100644
--- a/backend/satellite_exporter/handlers/non_auth_dumper.py
+++ b/backend/satellite_exporter/handlers/non_auth_dumper.py
@@ -206,11 +206,6 @@ class NonAuthenticatedDumper(rhnHandler, dumper.XML_DumperEx):
h.executemany(snapshot_channel_id=snapshot_channel_ids,
obj_id=obj_ids, last_modified=last_modifieds)
- def _snapshot_channel_packages(self, channels, channel_data):
- self._do_snapshot('packages', channels, channel_data,
- self._query_snapshot_channel_packages)
- return {}
-
def _snapshot_channel_package_sources(self, channels, channel_data):
self._do_snapshot('source_packages', channels, channel_data,
self._query_snapshot_channel_source_packages)
commit b05ecf06ab791c24ae2867e6539cc7b8fdd15130
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri May 28 15:38:51 2010 +0200
none of rhnDumpSnapshot* exists anymore
diff --git a/backend/satellite_exporter/handlers/non_auth_dumper.py
b/backend/satellite_exporter/handlers/non_auth_dumper.py
index ff4f71b..20fe651 100644
--- a/backend/satellite_exporter/handlers/non_auth_dumper.py
+++ b/backend/satellite_exporter/handlers/non_auth_dumper.py
@@ -94,14 +94,6 @@ class NonAuthenticatedDumper(rhnHandler, dumper.XML_DumperEx):
', '.join(["'%s'" % x for x in channel_labels]), )
return self
- _query_purge_snapshot = rhnSQL.Statement("""
- delete from rhnDumpSnapshotChannel where snapshot_id = :snapshot_id
- """)
- _query_snapshot_channels = rhnSQL.Statement("""
- insert into rhnDumpSnapshotChannel (id, snapshot_id, channel_id)
- values (:id, :snapshot_id, :channel_id)
- """)
-
def _get_channel_data(self, channels):
writer = ContainerWriter()
d = ChannelsDumper(writer, channels=channels.values())
@@ -214,48 +206,21 @@ class NonAuthenticatedDumper(rhnHandler, dumper.XML_DumperEx):
h.executemany(snapshot_channel_id=snapshot_channel_ids,
obj_id=obj_ids, last_modified=last_modifieds)
- _query_snapshot_channel_packages = rhnSQL.Statement("""
- insert into rhnDumpSnapshotChannelPackage
- (snapshot_channel_id, package_id, last_modified)
- values (:snapshot_channel_id, :obj_id,
- TO_DATE(:last_modified, 'YYYY-MM-DD HH24:MI:SS'))
- """)
def _snapshot_channel_packages(self, channels, channel_data):
self._do_snapshot('packages', channels, channel_data,
self._query_snapshot_channel_packages)
return {}
- _query_snapshot_channel_source_packages = rhnSQL.Statement("""
- insert into rhnDumpSnapshotChannelPkgSrc
- (snapshot_channel_id, package_source_id, last_modified)
- values (:snapshot_channel_id, :obj_id,
- TO_DATE(:last_modified, 'YYYY-MM-DD HH24:MI:SS'))
- """)
def _snapshot_channel_package_sources(self, channels, channel_data):
self._do_snapshot('source_packages', channels, channel_data,
self._query_snapshot_channel_source_packages)
return {}
- _query_snapshot_channel_errata = rhnSQL.Statement("""
- insert into rhnDumpSnapshotChannelErrata
- (snapshot_channel_id, errata_id, last_modified)
- values (:snapshot_channel_id, :obj_id,
- TO_DATE(:last_modified, 'YYYY-MM-DD HH24:MI:SS'))
- """)
def _snapshot_channel_errata(self, channels, channel_data):
self._do_snapshot('errata', channels, channel_data,
self._query_snapshot_channel_errata)
return {}
- _query_snapshot_channel_ks_trees = rhnSQL.Statement("""
- insert into rhnDumpSnapshotChannelKSTree
- (snapshot_channel_id, ks_tree_id, last_modified)
- select :snapshot_channel_id, id, TO_DATE(:last_modified, 'YYYY-MM-DD
HH24:MI:SS')
- from rhnKickstartableTree
- where label = :obj_id
- and org_id is null
- and channel_id = :channel_id
- """)
def _snapshot_channel_ks_trees(self, channels, channel_data):
self._do_snapshot('ks_trees', channels, channel_data,
self._query_snapshot_channel_ks_trees,
@@ -643,52 +608,18 @@ class _ChannelDumper(exportLib.ChannelDumper):
data.sort()
return data
- _query_get_snapshot_packages = rhnSQL.Statement("""
- select dscp.package_id,
- TO_CHAR(dscp.last_modified, 'YYYY-MM-DD HH24:MI:SS')
last_modified
- from rhnDumpSnapshotChannelPackage dscp
- where dscp.snapshot_channel_id = :snapshot_channel_id
- """)
def __get_snapshot_packages(self):
return self.__get_statement_data(self._query_get_snapshot_packages)
- _query_get_snapshot_source_packages = rhnSQL.Statement("""
- select dscps.package_source_id id,
- sr.name source_rpm,
- TO_CHAR(ps.last_modified, 'YYYYMMDDHH24MISS') last_modified
- from rhnSourceRPM sr,
- rhnPackageSource ps,
- rhnDumpSnapshotChannelPkgSrc dscps
- where dscps.snapshot_channel_id = :snapshot_channel_id
- and dscps.package_source_id = ps.id
- and ps.source_rpm_id = sr.id
- """)
def __get_snapshot_source_packages(self):
h = rhnSQL.prepare(self._query_get_snapshot_source_packages)
h.execute(snapshot_channel_id=self.snapshot_channel_id)
data = h.fetchall_dict() or []
return data
- _query_get_snapshot_errata = rhnSQL.Statement("""
- select dsce.errata_id,
- TO_CHAR(dsce.last_modified, 'YYYY-MM-DD HH24:MI:SS')
last_modified
- from rhnDumpSnapshotChannelErrata dsce
- where dsce.snapshot_channel_id = :snapshot_channel_id
- """)
def __get_snapshot_errata(self):
return self.__get_statement_data(self._query_get_snapshot_errata)
- _query_get_snapshot_ks_tree = rhnSQL.Statement("""
- select kt.label,
- TO_CHAR(dsckt.last_modified, 'YYYY-MM-DD HH24:MI:SS')
last_modified
- from rhnDumpSnapshotChannelKSTree dsckt,
- rhnDumpSnapshotChannel dsc,
- rhnKickstartableTree kt
- where dsckt.snapshot_channel_id = :snapshot_channel_id
- and dsckt.ks_tree_id = kt.id
- and dsc.id = :snapshot_channel_id
- and dsc.channel_id = kt.channel_id
- """)
def __get_snapshot_ks_tree(self):
return self.__get_statement_data(self._query_get_snapshot_ks_tree)
diff --git a/schema/spacewalk/common/tables/tables.deps
b/schema/spacewalk/common/tables/tables.deps
index 1b6df11..1515473 100644
--- a/schema/spacewalk/common/tables/tables.deps
+++ b/schema/spacewalk/common/tables/tables.deps
@@ -81,10 +81,6 @@ rhnCryptoKeyKickstart :: rhnCryptoKey rhnKSData
rhnDevice :: rhnServer
rhnDistChannelMap :: rhnChannel rhnChannelArch
rhnDownloads :: rhnChannelFamily rhnFile rhnDownloadType
-rhnDumpSnapshotChannelErrata :: rhnDumpSnapshotChannel rhnErrata
-rhnDumpSnapshotChannelPackage :: rhnDumpSnapshotChannel rhnPackage
-rhnDumpSnapshotChannelPkgSrc :: rhnDumpSnapshotChannel rhnPackageSource
-rhnDumpSnapshotChannelKSTree :: rhnDumpSnapshotChannel rhnKickstartableTree
rhnEmailAddress :: rhnEmailAddressState web_contact
rhnEntitlementQueue :: web_customer
rhnErrata :: rhnChecksum web_customer rhnErrataSeverity
commit f9adeea76a3eb26cb419532438765af0ba480437
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri May 28 15:15:09 2010 +0200
_validate_channels_snapshot() is dead since _query_validate_channel_snapshot removal
diff --git a/backend/satellite_exporter/handlers/non_auth_dumper.py
b/backend/satellite_exporter/handlers/non_auth_dumper.py
index 9159617..ff4f71b 100644
--- a/backend/satellite_exporter/handlers/non_auth_dumper.py
+++ b/backend/satellite_exporter/handlers/non_auth_dumper.py
@@ -484,24 +484,6 @@ class NonAuthenticatedDumper(rhnHandler, dumper.XML_DumperEx):
_get_package_id = staticmethod(_get_package_id)
- def _validate_channels_snapshot(self, snapshot, channels):
- h = rhnSQL.prepare(self._query_validate_channel_snapshot)
- missing_channels = []
- snapshot_id = None
- for c in channels.values():
- channel_id = c['channel_id']
- h.execute(channel_id=channel_id, snapshot=snapshot)
- row = h.fetchone_dict()
- if row:
- snapshot_id = row['snapshot_id']
- else:
- missing_channels.append(c)
- if missing_channels:
- missing_labels = [ x['label'] for x in missing_channels ]
- raise rhnFault(3014, "snapshot: %s; channels: %s" %
- (snapshot, ' '.join(missing_labels)))
- return snapshot_id
-
def _respond_xmlrpc(self, data):
# Marshal
s = xmlrpclib.dumps((data, ))
commit c9322412ab2e8da00ad68cf25def3da17aba3527
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri May 28 15:13:56 2010 +0200
snapshot_channels() is dead since _snapshot_channels() removal
diff --git a/backend/satellite_exporter/handlers/non_auth_dumper.py
b/backend/satellite_exporter/handlers/non_auth_dumper.py
index 4db0274..9159617 100644
--- a/backend/satellite_exporter/handlers/non_auth_dumper.py
+++ b/backend/satellite_exporter/handlers/non_auth_dumper.py
@@ -62,7 +62,6 @@ class NonAuthenticatedDumper(rhnHandler, dumper.XML_DumperEx):
'get_source_rpm',
'kickstartable_trees',
'get_ks_file',
- 'snapshot_channels',
]
self.system_id = None
@@ -95,20 +94,6 @@ class NonAuthenticatedDumper(rhnHandler, dumper.XML_DumperEx):
', '.join(["'%s'" % x for x in channel_labels]), )
return self
- def snapshot_channels(self, snapshot, channel_labels=[], flags={}):
- """ Snapshotting channels - *does* writes in the DB
"""
- log_debug(2, snapshot, channel_labels)
- self.set_channel_family_query(channel_labels=channel_labels)
- channels = self._validate_channels(channel_labels=channel_labels)
- try:
- ret = self._snapshot_channels(snapshot, channels, flags)
- except:
- rhnSQL.rollback()
- raise
- else:
- rhnSQL.commit()
- return self._respond_xmlrpc(ret)
-
_query_purge_snapshot = rhnSQL.Statement("""
delete from rhnDumpSnapshotChannel where snapshot_id = :snapshot_id
""")
commit 3b54ca3716d14e0ecfbbfca5f3868ab5c1d1e803
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri May 28 15:07:49 2010 +0200
_snapshot_channels() is dead since query_lookup_snapshot and _query_create_snapshot
removal
diff --git a/backend/satellite_exporter/handlers/non_auth_dumper.py
b/backend/satellite_exporter/handlers/non_auth_dumper.py
index 27993be..4db0274 100644
--- a/backend/satellite_exporter/handlers/non_auth_dumper.py
+++ b/backend/satellite_exporter/handlers/non_auth_dumper.py
@@ -116,61 +116,6 @@ class NonAuthenticatedDumper(rhnHandler, dumper.XML_DumperEx):
insert into rhnDumpSnapshotChannel (id, snapshot_id, channel_id)
values (:id, :snapshot_id, :channel_id)
""")
- def _snapshot_channels(self, snapshot, channels, flags):
- log_debug(3, snapshot, channels)
- retval = {}
- # Does the snapshot exist?
- h = rhnSQL.prepare(self._query_lookup_snapshot)
- h.execute(snapshot=snapshot)
- row = h.fetchone_dict()
- if row:
- # Did they ask to force this snapshot?
- if not flags.has_key('force'):
- # XXX
- raise Exception("did not ask for force")
- snapshot_id = row['id']
- # Remove old stuff
- h = rhnSQL.prepare(self._query_purge_snapshot)
- h.execute(snapshot_id=snapshot_id)
- else:
- snapshot_id = rhnSQL.Sequence('rhn_dump_snapshot_id_seq').next()
- h = rhnSQL.prepare(self._query_create_snapshot)
- h.execute(snapshot_id=snapshot_id, snapshot=snapshot)
-
- if not channels:
- # Nothing more to do
- # We don't exit from the very beginning because we may want to
- # clear a specific tag
- return retval
-
- channel_ids = []
- snapshot_ids = []
- snapshot_channel_ids = []
-
- seq = rhnSQL.Sequence('rhn_dump_snap_chan_id_seq')
- for channel_hash in channels.values():
- channel_id = channel_hash['channel_id']
- snapshot_channel_id = channel_hash['snapshot_channel_id'] = \
- seq.next()
-
- channel_ids.append(channel_id)
- snapshot_ids.append(snapshot_id)
- snapshot_channel_ids.append(snapshot_channel_id)
-
- h = rhnSQL.prepare(self._query_snapshot_channels)
- h.executemany(id=snapshot_channel_ids, snapshot_id=snapshot_ids,
- channel_id=channel_ids)
-
- channel_data = self._get_channel_data(channels)
- channel_data = self._lookup_last_modified(channel_data)
-
- retval.update(self._snapshot_channel_packages(channels, channel_data))
- retval.update(self._snapshot_channel_package_sources(channels,
- channel_data))
- retval.update(self._snapshot_channel_errata(channels, channel_data))
- retval.update(self._snapshot_channel_ks_trees(channels, channel_data))
-
- return retval
def _get_channel_data(self, channels):
writer = ContainerWriter()
commit e0f395fc153ddb353342e039859fb7f9f4ff8445
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Fri May 28 15:02:47 2010 +0200
there is no rhnDumpSnapshot table - removing dead SQL code
diff --git a/backend/satellite_exporter/handlers/non_auth_dumper.py
b/backend/satellite_exporter/handlers/non_auth_dumper.py
index e3b7319..27993be 100644
--- a/backend/satellite_exporter/handlers/non_auth_dumper.py
+++ b/backend/satellite_exporter/handlers/non_auth_dumper.py
@@ -109,12 +109,6 @@ class NonAuthenticatedDumper(rhnHandler, dumper.XML_DumperEx):
rhnSQL.commit()
return self._respond_xmlrpc(ret)
- _query_lookup_snapshot = rhnSQL.Statement("""
- select id from rhnDumpSnapshot where snapshot = :snapshot
- """)
- _query_create_snapshot = rhnSQL.Statement("""
- insert into rhnDumpSnapshot (id, snapshot) values (:snapshot_id, :snapshot)
- """)
_query_purge_snapshot = rhnSQL.Statement("""
delete from rhnDumpSnapshotChannel where snapshot_id = :snapshot_id
""")
@@ -560,13 +554,6 @@ class NonAuthenticatedDumper(rhnHandler, dumper.XML_DumperEx):
_get_package_id = staticmethod(_get_package_id)
- _query_validate_channel_snapshot = rhnSQL.Statement("""
- select dsc.snapshot_id
- from rhnDumpSnapshot ds, rhnDumpSnapshotChannel dsc
- where dsc.channel_id = :channel_id
- and dsc.snapshot_id = ds.id
- and ds.snapshot = :snapshot
- """)
def _validate_channels_snapshot(self, snapshot, channels):
h = rhnSQL.prepare(self._query_validate_channel_snapshot)
missing_channels = []
@@ -694,13 +681,6 @@ class _ChannelDumper(exportLib.ChannelDumper):
log_debug(4, snapshot, incremental, self.snapshot_id,
self.snapshot_channel_id)
- _query_get_snapshot_ids = rhnSQL.Statement("""
- select ds.id snapshot_id, dsc.id snapshot_channel_id
- from rhnDumpSnapshot ds, rhnDumpSnapshotChannel dsc
- where dsc.channel_id = :channel_id
- and dsc.snapshot_id = ds.id
- and ds.snapshot = :snapshot
- """)
def init(self):
self.channel_id = self._row['id']
self.channel_label = self._row['label']
diff --git a/schema/spacewalk/common/tables/tables.deps
b/schema/spacewalk/common/tables/tables.deps
index 5300439..1b6df11 100644
--- a/schema/spacewalk/common/tables/tables.deps
+++ b/schema/spacewalk/common/tables/tables.deps
@@ -81,7 +81,6 @@ rhnCryptoKeyKickstart :: rhnCryptoKey rhnKSData
rhnDevice :: rhnServer
rhnDistChannelMap :: rhnChannel rhnChannelArch
rhnDownloads :: rhnChannelFamily rhnFile rhnDownloadType
-rhnDumpSnapshotChannel :: rhnDumpSnapshot rhnChannel
rhnDumpSnapshotChannelErrata :: rhnDumpSnapshotChannel rhnErrata
rhnDumpSnapshotChannelPackage :: rhnDumpSnapshotChannel rhnPackage
rhnDumpSnapshotChannelPkgSrc :: rhnDumpSnapshotChannel rhnPackageSource