本文整理汇总了Python中Bcfg2.Server.Plugins.Packages.Collection.Collection.setup_data方法的典型用法代码示例。如果您正苦于以下问题:Python Collection.setup_data方法的具体用法?Python Collection.setup_data怎么用?Python Collection.setup_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bcfg2.Server.Plugins.Packages.Collection.Collection
的用法示例。
在下文中一共展示了Collection.setup_data方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_data
# 需要导入模块: from Bcfg2.Server.Plugins.Packages.Collection import Collection [as 别名]
# 或者: from Bcfg2.Server.Plugins.Packages.Collection.Collection import setup_data [as 别名]
def setup_data(self, force_update=False):
""" Do any collection-level data setup tasks. This is called
when sources are loaded or reloaded by
:class:`Bcfg2.Server.Plugins.Packages.Packages`.
If the builtin yum parsers are in use, this defers to
:func:`Bcfg2.Server.Plugins.Packages.Collection.Collection.setup_data`.
If using the yum Python libraries, this cleans up cached yum
metadata, regenerates the server-side yum config (in order to
catch any new sources that have been added to this server),
and then cleans up cached yum metadata again, in case the new
config has any preexisting cache.
:param force_update: Ignore all local cache and setup data
from its original upstream sources (i.e.,
the package repositories)
:type force_update: bool
"""
if not self.use_yum:
return Collection.setup_data(self, force_update)
if force_update:
# we call this twice: one to clean up data from the old
# config, and once to clean up data from the new config
self.call_helper("clean")
os.unlink(self.cfgfile)
self.write_config()
if force_update:
self.call_helper("clean")
示例2: setup_data
# 需要导入模块: from Bcfg2.Server.Plugins.Packages.Collection import Collection [as 别名]
# 或者: from Bcfg2.Server.Plugins.Packages.Collection.Collection import setup_data [as 别名]
def setup_data(self, force_update=False):
if not self.use_yum:
return Collection.setup_data(self, force_update)
for cfile in glob.glob(os.path.join(self.configdir, "*-yum.conf")):
os.unlink(cfile)
self._yb = None
self.pkgs_cache.clear()
self.deps_cache.clear()
self.vpkgs_cache.clear()
self.group_cache.clear()
self.pkgset_cache.clear()
if force_update:
for mdtype in ["Headers", "Packages", "Sqlite", "Metadata",
"ExpireCache"]:
# for reasons that are entirely obvious, all of the
# yum API clean* methods return a tuple of 0 (zero,
# always zero) and a list containing a single message
# about how many files were deleted. so useful.
# thanks, yum.
self.logger.info("Packages: %s" %
getattr(self.yumbase,
"clean%s" % mdtype)()[1][0])
示例3: setup_data
# 需要导入模块: from Bcfg2.Server.Plugins.Packages.Collection import Collection [as 别名]
# 或者: from Bcfg2.Server.Plugins.Packages.Collection.Collection import setup_data [as 别名]
def setup_data(self, force_update=False):
if not self.use_yum:
return Collection.setup_data(self, force_update)
if force_update:
# we call this twice: one to clean up data from the old
# config, and once to clean up data from the new config
self.call_helper("clean")
os.unlink(self.cfgfile)
self.write_config()
if force_update:
self.call_helper("clean")