Skip to content

Commit

Permalink
Adapt Inter Server Sync code to new SCC sync backend
Browse files Browse the repository at this point in the history
  • Loading branch information
lucidd authored and mcalmer committed Dec 19, 2018
1 parent dd00f67 commit 48bd885
Show file tree
Hide file tree
Showing 16 changed files with 706 additions and 43 deletions.
39 changes: 39 additions & 0 deletions backend/satellite_exporter/handlers/non_auth_dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ def __init__(self, req):
'suse_products',
'suse_product_channels',
'suse_upgrade_paths',
'suse_product_extensions',
'suse_product_repositories',
'scc_repositories',
'suse_subscriptions',
'cloned_channels',
]
Expand Down Expand Up @@ -333,6 +336,33 @@ def dump_suse_upgrade_paths(self):
self.close()
return 0

def dump_suse_product_extensions(self):
log_debug(4)
writer = self._get_xml_writer()
d = dumper.SatelliteDumper(writer, exportLib.SuseProductExtensionDumper(writer))
d.dump()
writer.flush()
self.close()
return 0

def dump_suse_product_repositories(self):
log_debug(4)
writer = self._get_xml_writer()
d = dumper.SatelliteDumper(writer, exportLib.SuseProductRepositoryDumper(writer))
d.dump()
writer.flush()
self.close()
return 0

def dump_scc_repositories(self):
log_debug(4)
writer = self._get_xml_writer()
d = dumper.SatelliteDumper(writer, exportLib.SCCRepositoryDumper(writer))
d.dump()
writer.flush()
self.close()
return 0

def dump_suse_subscriptions(self):
log_debug(4)
writer = self._get_xml_writer()
Expand Down Expand Up @@ -369,6 +399,15 @@ def suse_product_channels(self):
def suse_upgrade_paths(self):
self.dump_suse_upgrade_paths()

def suse_product_extensions(self):
self.dump_suse_product_extensions()

def suse_product_repositories(self):
self.dump_suse_product_repositories()

def scc_repositories(self):
self.dump_scc_repositories()

def suse_subscriptions(self):
self.dump_suse_subscriptions()

Expand Down
21 changes: 21 additions & 0 deletions backend/satellite_tools/diskImportLib.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,27 @@ def endContainerCallback(self):
return
diskImportLibContainer.endContainerCallback(self)

class SuseProductExtensionsContainer(diskImportLibContainer, xmlSource.SuseProductExtensionsContainer):
importer_class = suseProductsImport.SuseProductExtensionsImport
def endContainerCallback(self):
if not self.batch:
return
diskImportLibContainer.endContainerCallback(self)

class SuseProductRepositoriesContainer(diskImportLibContainer, xmlSource.SuseProductRepositoriesContainer):
importer_class = suseProductsImport.SuseProductRepositoriesImport
def endContainerCallback(self):
if not self.batch:
return
diskImportLibContainer.endContainerCallback(self)

class SCCRepositoriesContainer(diskImportLibContainer, xmlSource.SCCRepositoriesContainer):
importer_class = suseProductsImport.SCCRepositoriesImport
def endContainerCallback(self):
if not self.batch:
return
diskImportLibContainer.endContainerCallback(self)

class SuseSubscriptionsContainer(diskImportLibContainer, xmlSource.SuseSubscriptionsContainer):
importer_class = suseProductsImport.SuseSubscriptionsImport
def endContainerCallback(self):
Expand Down
15 changes: 15 additions & 0 deletions backend/satellite_tools/disk_dumper/dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,21 @@ def dump_suse_upgrade_paths(self):
self._write_dump(exportLib.SuseUpgradePathDumper)
return 0

def dump_suse_product_extensions(self):
log_debug(2)
self._write_dump(exportLib.SuseProductExtensionDumper)
return 0

def dump_suse_product_repositories(self):
log_debug(2)
self._write_dump(exportLib.SuseProductRepositoryDumper)
return 0

def dump_scc_repositories(self):
log_debug(2)
self._write_dump(exportLib.SCCRepositoryDumper)
return 0

def dump_suse_subscriptions(self):
log_debug(2)
self._write_dump(exportLib.SuseSubscriptionDumper)
Expand Down
36 changes: 36 additions & 0 deletions backend/satellite_tools/disk_dumper/iss.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ def __init__(self, mount_point):
'suse_products': xmlDiskSource.SuseProductsDiskSource(self.mp),
'suse_product_channels': xmlDiskSource.SuseProductChannelsDiskSource(self.mp),
'suse_upgrade_paths': xmlDiskSource.SuseUpgradePathsDiskSource(self.mp),
'suse_product_extensions': xmlDiskSource.SuseProductEntensionsDiskSource(self.mp),
'suse_product_repositories': xmlDiskSource.SuseProductRepositoriesDiskSource(self.mp),
'scc_repositories': xmlDiskSource.SCCRepositoriesDiskSource(self.mp),
'suse_subscriptions': xmlDiskSource.SuseSubscriptionsDiskSource(self.mp),
'cloned_channels': xmlDiskSource.ClonedChannelsDiskSource(self.mp),
}
Expand Down Expand Up @@ -196,6 +199,15 @@ def getSuseProductChannelsFile(self):
def getSuseUpgradePathsFile(self):
return self.setup_file(self.filemap['suse_upgrade_paths']._getFile())

def getSuseProductExtensionsFile(self):
return self.setup_file(self.filemap['suse_product_extensions']._getFile())

def getSuseProductRepositoriesFile(self):
return self.setup_file(self.filemap['suse_product_repositories']._getFile())

def getSCCRepositoriesFile(self):
return self.setup_file(self.filemap['scc_repositories']._getFile())

def getSuseSubscriptionsFile(self):
return self.setup_file(self.filemap['suse_subscriptions']._getFile())

Expand Down Expand Up @@ -1099,6 +1111,27 @@ def dump_suse_upgrade_paths(self):
"Upgrade Path Information exported to %s",
"%s caught in dump_suse_upgrade_paths.")

def dump_suse_product_extensions(self):
self._dump_simple(self.fm.getSuseProductExtensionsFile(),
dumper.XML_Dumper.dump_suse_product_extensions,
"Exporting SUSE Product Extension Information...",
"SUSE Product Extension Information exported to %s",
"%s caught in dump_suse_product_extensions.")

def dump_suse_product_repositories(self):
self._dump_simple(self.fm.getSuseProductRepositoriesFile(),
dumper.XML_Dumper.dump_suse_product_repositories,
"Exporting SUSE Product Repository Information...",
"SUSE Product Repository Information exported to %s",
"%s caught in dump_suse_product_repositories.")

def dump_scc_repositories(self):
self._dump_simple(self.fm.getSCCRepositoriesFile(),
dumper.XML_Dumper.dump_scc_repositories,
"Exporting Repository Information...",
"Repository Information exported to %s",
"%s caught in dump_scc_repositories.")

def dump_suse_subscriptions(self):
self._dump_simple(self.fm.getSuseSubscriptionsFile(),
dumper.XML_Dumper.dump_suse_subscriptions,
Expand Down Expand Up @@ -1309,6 +1342,9 @@ def __init__(self):
'suse-products': {'dump': self.dumper.dump_suse_products},
'suse-product-channels': {'dump': self.dumper.dump_suse_product_channels},
'suse-upgrade-paths': {'dump': self.dumper.dump_suse_upgrade_paths},
'suse-product-extensions': {'dump': self.dumper.dump_suse_product_extensions},
'suse-product-repositories': {'dump': self.dumper.dump_suse_product_repositories},
'scc-repositories': {'dump': self.dumper.dump_scc_repositories},
'suse-subscriptions': {'dump': self.dumper.dump_suse_subscriptions},
'cloned-channels': {'dump': self.dumper.dump_cloned_channels},
}
Expand Down
6 changes: 6 additions & 0 deletions backend/satellite_tools/disk_dumper/iss_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def __init__(self, options):
'suse-products': [''],
'suse-product-channels': ['suse-products', 'channels'],
'suse-upgrade-paths': ['suse-products'],
'suse-product-extensions': ['suse-products'],
'scc-repositories': [''],
'suse-product-repositories': ['suse-products', 'scc-repositories'],
'suse-subscriptions': ['channel-families'],
'cloned-channels': ['channels'],
}
Expand All @@ -62,8 +65,11 @@ def __init__(self, options):
'kickstarts',
'supportinfo',
'suse-products',
'scc-repositories'
'suse-product-channels',
'suse-upgrade-paths',
'suse-product-extensions',
'suse-product-repositories',
'suse-subscriptions',
]
self.options = options
Expand Down
114 changes: 110 additions & 4 deletions backend/satellite_tools/exporter/exportLib.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,10 +799,16 @@ class SuseProductChannelDumper(BaseQueryDumper):
tag_name = 'suse-product-channels'
iterator_query = """
SELECT p.product_id AS pdid,
pc.channel_label AS clabel,
pc.parent_channel_label AS pclabel
FROM suseProductChannel pc
JOIN suseProducts p ON pc.product_id = p.id
pr.channel_label as clabel,
pr.parent_channel_label AS pclabel
FROM suseProductSCCRepository pr
JOIN suseProducts p ON pr.product_id = p.id
WHERE EXISTS (select 1
FROM suseProductChannel pc
JOIN rhnChannel c ON c.id = pc.channel_id
WHERE p.id = pc.product_id
AND pc.mandatory = 'Y'
AND c.label = pr.channel_label)
"""

def __init__(self, writer, data_iterator=None):
Expand Down Expand Up @@ -838,6 +844,106 @@ def dump_subelement(self, data):
cf = _SuseUpgradePathDumper(self._writer, data)
cf.dump()

class _SuseProductExtensionDumper(BaseRowDumper):
tag_name = 'suse-product-extension'

def set_attributes(self):
return {
'root-product-id' : self._row['rootid'],
'product-id' : self._row['pdid'],
'ext-product-id' : self._row['extid'],
'recommended': self._row['recommended']
}

class SuseProductExtensionDumper(BaseQueryDumper):
tag_name = 'suse-product-extensions'
iterator_query = """
SELECT p1.product_id AS pdid,
p2.product_id AS rootid,
p3.product_id AS extid,
e.recommended AS recommended
FROM suseProductExtension e
JOIN suseProducts p1 ON e.base_pdid = p1.id
JOIN suseProducts p2 ON e.root_pdid = p2.id
JOIN suseProducts p3 ON e.ext_pdid = p3.id
"""

def __init__(self, writer, data_iterator=None):
BaseDumper.__init__(self, writer, data_iterator=data_iterator)

def dump_subelement(self, data):
cf = _SuseProductExtensionDumper(self._writer, data)
cf.dump()

class _SuseProductRepositoryDumper(BaseRowDumper):
tag_name = 'suse-product-repository'

def set_attributes(self):
return {
'root-product-id' : self._row['rootid'],
'product-id' : self._row['pdid'],
'repository-id' : self._row['repoid'],
'channel-label': self._row['channel_label'],
'parent-channel-label': self._row['parent_channel_label'],
'channel-name': self._row['channel_name'],
'mandatory': self._row['mandatory'],
'update-tag': self._row['update_tag']
}

class SuseProductExtensionDumper(BaseQueryDumper):
tag_name = 'suse-product-repositories'
iterator_query = """
SELECT p1.product_id AS pdid,
p2.product_id AS rootid,
r.scc_id AS repoid,
pr.channel_label,
pr.parent_channel_label,
pr.channel_name,
pr.mandatory,
pr.update_tag
FROM suseProductSCCRepository pr
JOIN suseProducts p1 ON pr.product_id = p1.id
JOIN suseProducts p2 ON pr.root_product_id = p2.id
JOIN suseSCCRepository r ON pr.repo_id = r.id
"""

def __init__(self, writer, data_iterator=None):
BaseDumper.__init__(self, writer, data_iterator=data_iterator)

def dump_subelement(self, data):
cf = _SuseProductRepositoryDumper(self._writer, data)
cf.dump()

class _SCCRepositoryDumper(BaseRowDumper):
tag_name = 'scc-repository'

def set_attributes(self):
return {
'scc-id' : self._row['sccid'],
'autorefresh' : self._row['autorefresh'],
'name' : self._row['name'],
'distro-target': self._row['distro_target'],
'description': self._row['description'],
'url': self._row['url'],
'signed': self._row['signed']
}

class SCCRepositoryDumper(BaseQueryDumper):
tag_name = 'scc-repositories'
iterator_query = """
SELECT scc_id AS sccid,
autorefresh, name, distro_target,
description, url, signed
FROM suseSCCRepository
"""

def __init__(self, writer, data_iterator=None):
BaseDumper.__init__(self, writer, data_iterator=data_iterator)

def dump_subelement(self, data):
cf = _SCCRepositoryDumper(self._writer, data)
cf.dump()

class _SuseSubscriptionDumper(BaseRowDumper):
tag_name = 'suse-subscription'

Expand Down
27 changes: 27 additions & 0 deletions backend/satellite_tools/satsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,11 @@ class Runner:
'orgs': [''],
'supportinfo': ['channels', 'packages'],
'suse-products': ['arches'],
'scc-repositories': [''],
'suse-product-channels': ['suse-products', 'channels'],
'suse-upgrade-paths': ['suse-products'],
'suse-product-extensions': ['suse-products'],
'suse-product-repositories': ['suse-products', 'scc-repositories'],
'suse-subscriptions': ['channel-families'],
'cloned-channels': ['channels'],
}
Expand All @@ -137,8 +140,11 @@ class Runner:
'kickstarts',
'supportinfo',
'suse-products',
'scc-repositories',
'suse-product-channels',
'suse-upgrade-paths',
'suse-product-extensions',
'suse-product-repositories',
'suse-subscriptions',
]

Expand Down Expand Up @@ -412,6 +418,15 @@ def _step_suse_product_channels(self):
def _step_suse_upgrade_paths(self):
self.syncer.import_suse_upgrade_paths()

def _step_suse_product_extensions(self):
self.syncer.import_suse_product_extensions()

def _step_suse_product_repositories(self):
self.syncer.import_suse_product_repositories()

def _step_scc_repositories(self):
self.syncer.import_scc_repositories()

def _step_suse_subscriptions(self):
self.syncer.import_suse_subscriptions()

Expand Down Expand Up @@ -1915,6 +1930,18 @@ def import_suse_upgrade_paths(self):
"""Imports Upgrade Paths"""
self._process_simple("getSuseUpgradePathsXmlStream", "suse_upgrade_paths")

def import_suse_product_extensions(self):
"""Imports SUSE Product Extensions"""
self._process_simple("getSuseProductExtensionsXmlStream", "suse_product_extensions")

def import_suse_product_repositories(self):
"""Imports SUSE Product Repositories"""
self._process_simple("getSuseProductRepositoriesXmlStream", "suse_product_repositories")

def import_scc_repositories(self):
"""Imports SCC Repositories"""
self._process_simple("getSCCRepositoriesXmlStream", "scc_repositories")

def import_suse_subscriptions(self):
"""Imports Subscriptions"""
self._process_simple("getSuseSubscriptionsXmlStream", "suse_subscriptions")
Expand Down
Loading

0 comments on commit 48bd885

Please sign in to comment.