backend/satellite_exporter/exporter/dumper.py | 2 ++
backend/satellite_exporter/exporter/exportLib.py | 6 ++++--
backend/satellite_tools/satsync.py | 22 +++++++++++++++++++---
backend/satellite_tools/sync_handlers.py | 6 +++++-
4 files changed, 30 insertions(+), 6 deletions(-)
New commits:
commit 0985d35c7b29c786346f262f109131a6c3cd5412
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Wed Jul 1 17:41:53 2009 -0400
509187 - Resolves the parent key constraint issue. The package org was not accounted
causing constraints if the org is not on the source satellite. This fix should default the
org to 1 if the org is not present for custom channels.
509194
Fixes the ISE issue on UI which is caused due to mismatched package org id.
509195 - Fixes the Channel permissions issue on UI as its was defaulting to Null org
instead of org 1.
diff --git a/backend/satellite_exporter/exporter/dumper.py
b/backend/satellite_exporter/exporter/dumper.py
index 1f95d34..b505dea 100644
--- a/backend/satellite_exporter/exporter/dumper.py
+++ b/backend/satellite_exporter/exporter/dumper.py
@@ -772,6 +772,7 @@ class ShortPackagesDumper(CachedDumper,
exportLib.ShortPackagesDumper):
h = rhnSQL.prepare("""
select
p.id,
+ p.org_id,
pn.name,
pe.evr.version version,
pe.evr.release release,
@@ -805,6 +806,7 @@ class PackagesDumper(CachedDumper, exportLib.PackagesDumper):
select
p.id,
pn.name,
+ p.org_id,
pe.evr.version version,
pe.evr.release release,
pe.evr.epoch epoch,
diff --git a/backend/satellite_exporter/exporter/exportLib.py
b/backend/satellite_exporter/exporter/exportLib.py
index 3b0ce75..d0e2d82 100644
--- a/backend/satellite_exporter/exporter/exportLib.py
+++ b/backend/satellite_exporter/exporter/exportLib.py
@@ -544,6 +544,7 @@ class PackagesDumper(BaseDumper):
select
p.id,
pn.name,
+ p.org_id,
pe.evr.version version,
pe.evr.release release,
pe.evr.epoch epoch,
@@ -592,7 +593,7 @@ class _PackageDumper(BaseRowDumper):
attrs = ["name", "version", "release",
"package_arch",
"package_group", "rpm_version", "package_size",
"payload_size",
"build_host", "source_rpm", "md5sum",
"payload_format",
- "compat", "cookie"]
+ "compat", "cookie", "org_id"]
attrdict = {
'id' : "rhn-package-%s" %
self._row['id'],
'epoch' : self._row['epoch'] or "",
@@ -684,6 +685,7 @@ class ShortPackagesDumper(BaseDumper):
pe.evr.epoch epoch,
pa.label package_arch,
p.md5sum,
+ p.org_id,
TO_CHAR(p.last_modified, 'YYYYMMDDHH24MISS') last_modified
from rhnPackage p, rhnPackageName pn, rhnPackageEVR pe,
rhnPackageArch pa
@@ -700,7 +702,7 @@ class ShortPackagesDumper(BaseDumper):
attributes = {}
attrs = [
"id", "name", "version", "release",
"epoch",
- "package_arch", "md5sum", "package_size",
+ "package_arch", "md5sum", "package_size",
"org_id",
]
for attr in attrs:
attributes[attr.replace('_', '-')] = data[attr]
diff --git a/backend/satellite_tools/satsync.py b/backend/satellite_tools/satsync.py
index cc39ac6..41a55a8 100644
--- a/backend/satellite_tools/satsync.py
+++ b/backend/satellite_tools/satsync.py
@@ -876,6 +876,7 @@ Please contact your RHN representative""" %
(generation, sat_cert.generation))
if OPTIONS.orgid is not None:
nevra['org_id'] = OPTIONS.orgid
+ package['org_id'] = OPTIONS.orgid
else:
nevra['org_id'] = package['org_id']
@@ -1644,6 +1645,7 @@ Please contact your RHN representative""" %
(generation, sat_cert.generation))
chunk = ss.getChunk()
item_count = len(chunk)
batch = self._get_cached_package_batch(chunk)
+ _validate_package_org(batch)
try:
sync_handlers.import_packages(batch)
except (SQLError, SQLSchemaError, SQLConnectError), e:
@@ -1686,12 +1688,13 @@ Please contact your RHN representative""" %
(generation, sat_cert.generation))
package['channels'] = [channel_obj]
uq_packages[pid] = package
+ uq_pkg_data = uq_packages.values()
+ _validate_package_org(uq_pkg_data)
try:
if OPTIONS.mount_point:
- importer = sync_handlers.link_channel_packages(uq_packages.values(),
strict=0)
+ importer = sync_handlers.link_channel_packages(uq_pkg_data, strict=0)
else:
- importer = sync_handlers.link_channel_packages(uq_packages.values())
-
+ importer = sync_handlers.link_channel_packages(uq_pkg_data)
except (SQLError, SQLSchemaError, SQLConnectError), e:
tbOut = cStringIO.StringIO()
Traceback(mail=0, ostream=tbOut, with_locals=1)
@@ -1993,6 +1996,19 @@ def _verifyPkgRepMountPoint():
log(-1, "ERROR: server.mount_point not set in the configuration file")
sys.exit(26)
+def _validate_package_org(batch):
+ orgid = OPTIONS.orgid or None
+ orgs = map(lambda a: a['id'], satCerts.get_all_orgs())
+ #if orgid is not None and orgid not in orgs:
+ # orgid = 1
+ for pkg in batch:
+ if pkg['org_id'] is not None and pkg['org_id'] not in orgs:
+ orgid = 1
+ print "Default ORG ID",orgid
+ if orgid is not None and pkg['org_id'] is not None and \
+ pkg['org_id'] != orgid:
+ pkg['org_id'] = orgid
+
def _getImportedChannels():
"Retrieves the channels already imported in the satellite's database"
diff --git a/backend/satellite_tools/sync_handlers.py
b/backend/satellite_tools/sync_handlers.py
index bcaf31c..f2488a7 100644
--- a/backend/satellite_tools/sync_handlers.py
+++ b/backend/satellite_tools/sync_handlers.py
@@ -182,7 +182,7 @@ def get_channel_handler():
def import_channels(channels, orgid=None):
collection = ChannelCollection()
batch = []
-
+ import satCerts
for c in channels:
try:
timestamp = collection.get_channel_timestamp(c)
@@ -196,6 +196,10 @@ def import_channels(channels, orgid=None):
# make sure the org from the export is not null org,
# finally if the orgs differ so we might wanna use
# requested org's channel-family.
+ orgs = map(lambda a: a['id'], satCerts.get_all_orgs())
+ if c_obj['org_id'] is not None and c_obj['org_id'] not in orgs:
+ #If the src org is not present default to org 1
+ orgid = str(1)
if orgid is not None and c_obj['org_id'] is not None and \
c_obj['org_id'] != orgid:
c_obj['org_id'] = orgid